UNPKG

@carbon/icons-angular

Version:

Angular components for icons in digital and software products using the Carbon Design System

169 lines (166 loc) 10.8 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var MisuseComponent = /** @class */ (function () { function MisuseComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], MisuseComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MisuseComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MisuseComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseComponent.prototype, "size", void 0); MisuseComponent = __decorate([ Component({ selector: "ibm-icon-misuse", template: "\n <svg\n ibmIconMisuse\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 " }) ], MisuseComponent); return MisuseComponent; }()); var MisuseDirective = /** @class */ (function () { function MisuseDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Misuse32", "filepath": "misuse/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": "M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M21.4,23L16,17.6L10.6,23L9,21.4l5.4-5.4L9,10.6L10.6,9\tl5.4,5.4L21.4,9l1.6,1.6L17.6,16l5.4,5.4L21.4,23z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M21.4,23L16,17.6L10.6,23L9,21.4l5.4-5.4L9,10.6L10.6,9l5.4,5.4L21.4,9l1.6,1.6L17.6,16\tl5.4,5.4L21.4,23z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "misuse", "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=\"M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M21.4,23L16,17.6L10.6,23L9,21.4l5.4-5.4L9,10.6L10.6,9\tl5.4,5.4L21.4,9l1.6,1.6L17.6,16l5.4,5.4L21.4,23z\"></path><path fill=\"none\" d=\"M21.4,23L16,17.6L10.6,23L9,21.4l5.4-5.4L9,10.6L10.6,9l5.4,5.4L21.4,9l1.6,1.6L17.6,16\tl5.4,5.4L21.4,23z\" data-icon-path=\"inner-path\" opacity=\"0\"></path></svg>" }, "24": { metadata: { "moduleName": "Misuse24", "filepath": "misuse/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": "M12,1C6,1,1,6,1,12s5,11,11,11s11-4.9,11-11S18.1,1,12,1z M16.2,17.5L12,13.3l-4.2,4.2l-1.3-1.3l4.2-4.2L6.5,7.8l1.3-1.3\tl4.2,4.2l4.2-4.2l1.3,1.3L13.3,12l4.2,4.2L16.2,17.5z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M16.2,17.5L12,13.3l-4.2,4.2l-1.3-1.3l4.2-4.2L6.5,7.8l1.3-1.3l4.2,4.2l4.2-4.2l1.3,1.3\tL13.3,12l4.2,4.2L16.2,17.5z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "misuse", "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=\"M12,1C6,1,1,6,1,12s5,11,11,11s11-4.9,11-11S18.1,1,12,1z M16.2,17.5L12,13.3l-4.2,4.2l-1.3-1.3l4.2-4.2L6.5,7.8l1.3-1.3\tl4.2,4.2l4.2-4.2l1.3,1.3L13.3,12l4.2,4.2L16.2,17.5z\"></path><path fill=\"none\" d=\"M16.2,17.5L12,13.3l-4.2,4.2l-1.3-1.3l4.2-4.2L6.5,7.8l1.3-1.3l4.2,4.2l4.2-4.2l1.3,1.3\tL13.3,12l4.2,4.2L16.2,17.5z\" data-icon-path=\"inner-path\" opacity=\"0\"></path></svg>" }, "20": { metadata: { "moduleName": "Misuse20", "filepath": "misuse/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": "M10,1c-4.9,0-9,4.1-9,9s4.1,9,9,9s9-4,9-9S15,1,10,1z M13.5,14.5L10,11l-3.5,3.5l-1-1L9,10L5.5,6.5l1-1L10,9l3.5-3.5l1,1\tL11,10l3.5,3.5L13.5,14.5z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M13.5,14.5L10,11l-3.5,3.5l-1-1L9,10L5.5,6.5l1-1L10,9l3.5-3.5l1,1L11,10l3.5,3.5L13.5,14.5z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "misuse", "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=\"M10,1c-4.9,0-9,4.1-9,9s4.1,9,9,9s9-4,9-9S15,1,10,1z M13.5,14.5L10,11l-3.5,3.5l-1-1L9,10L5.5,6.5l1-1L10,9l3.5-3.5l1,1\tL11,10l3.5,3.5L13.5,14.5z\"></path><path fill=\"none\" d=\"M13.5,14.5L10,11l-3.5,3.5l-1-1L9,10L5.5,6.5l1-1L10,9l3.5-3.5l1,1L11,10l3.5,3.5L13.5,14.5z\" data-icon-path=\"inner-path\" opacity=\"0\"></path></svg>" }, "16": { metadata: { "moduleName": "Misuse16", "filepath": "misuse/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": "M8,1C4.1,1,1,4.1,1,8s3.1,7,7,7s7-3.1,7-7S11.9,1,8,1z M10.7,11.5L8,8.8l-2.7,2.7l-0.8-0.8L7.2,8L4.5,5.3l0.8-0.8L8,7.2\tl2.7-2.7l0.8,0.8L8.8,8l2.7,2.7L10.7,11.5z" } }, { "elem": "path", "attrs": { "d": "M10.7,11.5L8,8.8l-2.7,2.7l-0.8-0.8L7.2,8L4.5,5.3l0.8-0.8L8,7.2l2.7-2.7l0.8,0.8L8.8,8\tl2.7,2.7L10.7,11.5z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "misuse", "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=\"M8,1C4.1,1,1,4.1,1,8s3.1,7,7,7s7-3.1,7-7S11.9,1,8,1z M10.7,11.5L8,8.8l-2.7,2.7l-0.8-0.8L7.2,8L4.5,5.3l0.8-0.8L8,7.2\tl2.7-2.7l0.8,0.8L8.8,8l2.7,2.7L10.7,11.5z\"></path><path d=\"M10.7,11.5L8,8.8l-2.7,2.7l-0.8-0.8L7.2,8L4.5,5.3l0.8-0.8L8,7.2l2.7-2.7l0.8,0.8L8.8,8\tl2.7,2.7L10.7,11.5z\" data-icon-path=\"inner-path\" opacity=\"0\"></path></svg>" }, }; } MisuseDirective_1 = MisuseDirective; MisuseDirective.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; MisuseDirective_1.titleIdCounter++; title.setAttribute("id", "misuse-" + MisuseDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "misuse-" + MisuseDirective_1.titleIdCounter); } }; var MisuseDirective_1; MisuseDirective.titleIdCounter = 0; MisuseDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], MisuseDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MisuseDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MisuseDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MisuseDirective.prototype, "size", void 0); MisuseDirective = MisuseDirective_1 = __decorate([ Directive({ selector: "[ibmIconMisuse]" }), __metadata("design:paramtypes", [ElementRef]) ], MisuseDirective); return MisuseDirective; }()); var MisuseModule = /** @class */ (function () { function MisuseModule() { } MisuseModule = __decorate([ NgModule({ declarations: [ MisuseComponent, MisuseDirective, ], exports: [ MisuseComponent, MisuseDirective, ] }) ], MisuseModule); return MisuseModule; }()); export { MisuseComponent, MisuseDirective, MisuseModule };