@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 8.99 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var RedoComponent = /** @class */ (function () {
function RedoComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], RedoComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], RedoComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], RedoComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoComponent.prototype, "size", void 0);
RedoComponent = __decorate([
Component({
selector: "ibm-icon-redo",
template: "\n <svg\n ibmIconRedo\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 "
})
], RedoComponent);
return RedoComponent;
}());
var RedoDirective = /** @class */ (function () {
function RedoDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Redo32", "filepath": "redo/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": "M9,15c-2.5,0-4,1.5-4,4c0,2.5,1.5,4,4,4h5v2H9c-3.5,0-6-2.5-6-6c0-3.5,2.5-6,6-6h16.2l-4-4l1.4-1.5L29,14\tl-6.4,6.4L21.2,19l4-4H9z" } }], "name": "redo", "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=\"M9,15c-2.5,0-4,1.5-4,4c0,2.5,1.5,4,4,4h5v2H9c-3.5,0-6-2.5-6-6c0-3.5,2.5-6,6-6h16.2l-4-4l1.4-1.5L29,14\tl-6.4,6.4L21.2,19l4-4H9z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Redo24", "filepath": "redo/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": "M6.8,11.2c-1.8,0-3.2,1.7-3.2,3.3c0,1.5,1.5,3.2,3.2,3.2H10v1.5H6.8C4.6,19.2,2,17,2,14.5s2-4.8,4.8-4.8\th12.4l-3-3l1.1-1.1l4.8,4.8l-4.8,4.8l-1.1-1.1l3-3H6.8z" } }], "name": "redo", "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=\"M6.8,11.2c-1.8,0-3.2,1.7-3.2,3.3c0,1.5,1.5,3.2,3.2,3.2H10v1.5H6.8C4.6,19.2,2,17,2,14.5s2-4.8,4.8-4.8\th12.4l-3-3l1.1-1.1l4.8,4.8l-4.8,4.8l-1.1-1.1l3-3H6.8z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Redo20", "filepath": "redo/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": "M5,9.3c-1.5,0-2.8,1.3-2.8,2.7c0,1.5,1.3,2.7,2.8,2.7h4V16H5c-2.3,0-4-1.7-4-4c0-2.2,1.8-4,4-4h11.6\tl-2.5-2.5L15,4.6l4,4l-4,4l-0.9-0.9l2.5-2.5H5z" } }], "name": "redo", "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=\"M5,9.3c-1.5,0-2.8,1.3-2.8,2.7c0,1.5,1.3,2.7,2.8,2.7h4V16H5c-2.3,0-4-1.7-4-4c0-2.2,1.8-4,4-4h11.6\tl-2.5-2.5L15,4.6l4,4l-4,4l-0.9-0.9l2.5-2.5H5z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Redo16", "filepath": "redo/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": "M4,8c-1.2,0-2,0.8-2,2c0,1.2,0.8,2,2,2h3v1H4c-1.7,0-3-1.2-3-3c0-1.7,1.3-3,3-3l9.1,0l-2-2l0.7-0.7\tL15,7.5l-3.2,3.2L11.1,10l2-2L4,8z" } }], "name": "redo", "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=\"M4,8c-1.2,0-2,0.8-2,2c0,1.2,0.8,2,2,2h3v1H4c-1.7,0-3-1.2-3-3c0-1.7,1.3-3,3-3l9.1,0l-2-2l0.7-0.7\tL15,7.5l-3.2,3.2L11.1,10l2-2L4,8z\"></path></svg>"
},
};
}
RedoDirective_1 = RedoDirective;
RedoDirective.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;
RedoDirective_1.titleIdCounter++;
title.setAttribute("id", "redo-" + RedoDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "redo-" + RedoDirective_1.titleIdCounter);
}
};
var RedoDirective_1;
RedoDirective.titleIdCounter = 0;
RedoDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], RedoDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], RedoDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], RedoDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], RedoDirective.prototype, "size", void 0);
RedoDirective = RedoDirective_1 = __decorate([
Directive({
selector: "[ibmIconRedo]"
}),
__metadata("design:paramtypes", [ElementRef])
], RedoDirective);
return RedoDirective;
}());
var RedoModule = /** @class */ (function () {
function RedoModule() {
}
RedoModule = __decorate([
NgModule({
declarations: [
RedoComponent,
RedoDirective,
],
exports: [
RedoComponent,
RedoDirective,
]
})
], RedoModule);
return RedoModule;
}());
export { RedoComponent, RedoDirective, RedoModule };