@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 8.97 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var UndoComponent = /** @class */ (function () {
function UndoComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], UndoComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UndoComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UndoComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoComponent.prototype, "size", void 0);
UndoComponent = __decorate([
Component({
selector: "ibm-icon-undo",
template: "\n <svg\n ibmIconUndo\n [size]=\"size\"\n [ariaLabel]=\"ariaLabel\"\n [ariaLabelledby]=\"ariaLabelledby\"\n [ariaHidden]=\"ariaHidden\"\n [title]=\"title\"\n [isFocusable]=\"focusable\"\n [attr.class]=\"innerClass\">\n </svg>\n "
})
], UndoComponent);
return UndoComponent;
}());
var UndoDirective = /** @class */ (function () {
function UndoDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Undo32", "filepath": "undo/32.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 32, "height": 32 }, "content": [{ "elem": "path", "attrs": { "d": "M23,15c2.5,0,4,1.5,4,4c0,2.5-1.5,4-4,4h-5v2h5c3.5,0,6-2.5,6-6c0-3.5-2.5-6-6-6H6.8l4-4L9.4,7.6L3,14\tl6.4,6.4l1.4-1.4l-4-4H23z" } }], "name": "undo", "size": 32 }, "size": 32 },
svg: "<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" aria-hidden=\"true\"><path d=\"M23,15c2.5,0,4,1.5,4,4c0,2.5-1.5,4-4,4h-5v2h5c3.5,0,6-2.5,6-6c0-3.5-2.5-6-6-6H6.8l4-4L9.4,7.6L3,14\tl6.4,6.4l1.4-1.4l-4-4H23z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Undo24", "filepath": "undo/24.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 24 24", "fill": "currentColor", "width": 24, "height": 24 }, "content": [{ "elem": "path", "attrs": { "d": "M17.2,11.2c1.8,0,3.2,1.7,3.2,3.3c0,1.5-1.5,3.2-3.2,3.2H14v1.5h3.2c2.2,0,4.8-2.3,4.8-4.8s-2-4.8-4.8-4.8\tH4.8l3-3L6.8,5.7L2,10.5l4.8,4.8l1.1-1.1l-3-3H17.2z" } }], "name": "undo", "size": 24 }, "size": 24 },
svg: "<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M17.2,11.2c1.8,0,3.2,1.7,3.2,3.3c0,1.5-1.5,3.2-3.2,3.2H14v1.5h3.2c2.2,0,4.8-2.3,4.8-4.8s-2-4.8-4.8-4.8\tH4.8l3-3L6.8,5.7L2,10.5l4.8,4.8l1.1-1.1l-3-3H17.2z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Undo20", "filepath": "undo/20.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 20 20", "fill": "currentColor", "width": 20, "height": 20 }, "content": [{ "elem": "path", "attrs": { "d": "M15,9.3c1.5,0,2.8,1.3,2.8,2.7c0,1.5-1.3,2.7-2.8,2.7h-4V16h4c2.3,0,4-1.7,4-4c0-2.2-1.8-4-4-4H3.4\tl2.5-2.5L5,4.6l-4,4l4,4l0.9-0.9L3.4,9.3H15z" } }], "name": "undo", "size": 20 }, "size": 20 },
svg: "<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" aria-hidden=\"true\"><path d=\"M15,9.3c1.5,0,2.8,1.3,2.8,2.7c0,1.5-1.3,2.7-2.8,2.7h-4V16h4c2.3,0,4-1.7,4-4c0-2.2-1.8-4-4-4H3.4\tl2.5-2.5L5,4.6l-4,4l4,4l0.9-0.9L3.4,9.3H15z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Undo16", "filepath": "undo/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 16 16", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M12,8c1.2,0,2,0.8,2,2c0,1.2-0.8,2-2,2H9v1h3c1.7,0,3-1.2,3-3c0-1.7-1.3-3-3-3L2.9,7l2-2L4.2,4.3L1,7.5\tl3.2,3.2L4.9,10l-2-2L12,8z" } }], "name": "undo", "size": 16 }, "size": 16 },
svg: "<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M12,8c1.2,0,2,0.8,2,2c0,1.2-0.8,2-2,2H9v1h3c1.7,0,3-1.2,3-3c0-1.7-1.3-3-3-3L2.9,7l2-2L4.2,4.3L1,7.5\tl3.2,3.2L4.9,10l-2-2L12,8z\"></path></svg>"
},
};
}
UndoDirective_1 = UndoDirective;
UndoDirective.prototype.ngAfterViewInit = function () {
var svg = this.elementRef.nativeElement;
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
var icon = this.icons[this.size];
var domParser = new DOMParser();
var rawSVG = icon.svg;
var svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement;
var node = svgElement.firstChild;
while (node) {
// importNode makes a clone of the node
// this ensures we keep looping over the nodes in the parsed document
svg.appendChild(svg.ownerDocument.importNode(node, true));
node = node.nextSibling;
}
var attributes = getAttributes({
width: icon.metadata.descriptor.attrs.height,
height: icon.metadata.descriptor.attrs.height,
viewBox: icon.metadata.descriptor.attrs.viewBox,
title: this.title,
"aria-label": this.ariaLabel,
"aria-labelledby": this.ariaLabelledby,
"aria-hidden": this.ariaHidden,
focusable: this.isFocusable.toString()
});
var attrKeys = Object.keys(attributes);
for (var i = 0; i < attrKeys.length; i++) {
var key = attrKeys[i];
var value = attributes[key];
if (key === "title") {
continue;
}
if (value) {
svg.setAttribute(key, value);
}
}
if (attributes.title) {
var title = document.createElement("title");
title.textContent = attributes.title;
UndoDirective_1.titleIdCounter++;
title.setAttribute("id", "undo-" + UndoDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "undo-" + UndoDirective_1.titleIdCounter);
}
};
var UndoDirective_1;
UndoDirective.titleIdCounter = 0;
UndoDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], UndoDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UndoDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UndoDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UndoDirective.prototype, "size", void 0);
UndoDirective = UndoDirective_1 = __decorate([
Directive({
selector: "[ibmIconUndo]"
}),
__metadata("design:paramtypes", [ElementRef])
], UndoDirective);
return UndoDirective;
}());
var UndoModule = /** @class */ (function () {
function UndoModule() {
}
UndoModule = __decorate([
NgModule({
declarations: [
UndoComponent,
UndoDirective,
],
exports: [
UndoComponent,
UndoDirective,
]
})
], UndoModule);
return UndoModule;
}());
export { UndoComponent, UndoDirective, UndoModule };