UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 11.9 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var MagicWandFilledDirective_1; let MagicWandFilledComponent = class MagicWandFilledComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MagicWandFilledComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MagicWandFilledComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledComponent.prototype, "size", void 0); MagicWandFilledComponent = __decorate([ Component({ selector: "ibm-icon-magic-wand-filled", template: ` <svg ibmIconMagicWandFilled [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], MagicWandFilledComponent); let MagicWandFilledDirective = MagicWandFilledDirective_1 = class MagicWandFilledDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "MagicWandFilled32", "filepath": "magic-wand--filled/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": "M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z" } }, { "elem": "path", "attrs": { "d": "M2.586 14.586H5.414V17.414H2.586z", "transform": "rotate(-45 4 16)" } }, { "elem": "path", "attrs": { "d": "M14.586 2.586H17.414V5.414H14.586z", "transform": "rotate(-45 16 4)" } }, { "elem": "path", "attrs": { "d": "M2.586 2.586H5.414V5.414H2.586z", "transform": "rotate(-45 4 4)" } }], "name": "magic-wand--filled", "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="M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z"></path><path d="M2.586 14.586H5.414V17.414H2.586z" transform="rotate(-45 4 16)"></path><path d="M14.586 2.586H17.414V5.414H14.586z" transform="rotate(-45 16 4)"></path><path d="M2.586 2.586H5.414V5.414H2.586z" transform="rotate(-45 4 4)"></path></svg>` }, "24": { metadata: { "moduleName": "MagicWandFilled24", "filepath": "magic-wand--filled/24.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 24, "height": 24 }, "content": [{ "elem": "path", "attrs": { "d": "M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z" } }, { "elem": "path", "attrs": { "d": "M2.586 14.586H5.414V17.414H2.586z", "transform": "rotate(-45 4 16)" } }, { "elem": "path", "attrs": { "d": "M14.586 2.586H17.414V5.414H14.586z", "transform": "rotate(-45 16 4)" } }, { "elem": "path", "attrs": { "d": "M2.586 2.586H5.414V5.414H2.586z", "transform": "rotate(-45 4 4)" } }], "name": "magic-wand--filled", "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 32 32" aria-hidden="true"><path d="M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z"></path><path d="M2.586 14.586H5.414V17.414H2.586z" transform="rotate(-45 4 16)"></path><path d="M14.586 2.586H17.414V5.414H14.586z" transform="rotate(-45 16 4)"></path><path d="M2.586 2.586H5.414V5.414H2.586z" transform="rotate(-45 4 4)"></path></svg>` }, "20": { metadata: { "moduleName": "MagicWandFilled20", "filepath": "magic-wand--filled/20.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 20, "height": 20 }, "content": [{ "elem": "path", "attrs": { "d": "M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z" } }, { "elem": "path", "attrs": { "d": "M2.586 14.586H5.414V17.414H2.586z", "transform": "rotate(-45 4 16)" } }, { "elem": "path", "attrs": { "d": "M14.586 2.586H17.414V5.414H14.586z", "transform": "rotate(-45 16 4)" } }, { "elem": "path", "attrs": { "d": "M2.586 2.586H5.414V5.414H2.586z", "transform": "rotate(-45 4 4)" } }], "name": "magic-wand--filled", "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 32 32" aria-hidden="true"><path d="M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z"></path><path d="M2.586 14.586H5.414V17.414H2.586z" transform="rotate(-45 4 16)"></path><path d="M14.586 2.586H17.414V5.414H14.586z" transform="rotate(-45 16 4)"></path><path d="M2.586 2.586H5.414V5.414H2.586z" transform="rotate(-45 4 4)"></path></svg>` }, "16": { metadata: { "moduleName": "MagicWandFilled16", "filepath": "magic-wand--filled/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z" } }, { "elem": "path", "attrs": { "d": "M2.586 14.586H5.414V17.414H2.586z", "transform": "rotate(-45 4 16)" } }, { "elem": "path", "attrs": { "d": "M14.586 2.586H17.414V5.414H14.586z", "transform": "rotate(-45 16 4)" } }, { "elem": "path", "attrs": { "d": "M2.586 2.586H5.414V5.414H2.586z", "transform": "rotate(-45 4 4)" } }], "name": "magic-wand--filled", "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 32 32" aria-hidden="true"><path d="M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z"></path><path d="M2.586 14.586H5.414V17.414H2.586z" transform="rotate(-45 4 16)"></path><path d="M14.586 2.586H17.414V5.414H14.586z" transform="rotate(-45 16 4)"></path><path d="M2.586 2.586H5.414V5.414H2.586z" transform="rotate(-45 4 4)"></path></svg>` }, }; } ngAfterViewInit() { const svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); const icon = this.icons[this.size]; const domParser = new DOMParser(); const rawSVG = icon.svg; const svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; let 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; } const 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() }); const attrKeys = Object.keys(attributes); for (let i = 0; i < attrKeys.length; i++) { const key = attrKeys[i]; const value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { const title = document.createElement("title"); title.textContent = attributes.title; MagicWandFilledDirective_1.titleIdCounter++; title.setAttribute("id", `magic-wand-filled-${MagicWandFilledDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `magic-wand-filled-${MagicWandFilledDirective_1.titleIdCounter}`); } } }; MagicWandFilledDirective.titleIdCounter = 0; MagicWandFilledDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MagicWandFilledDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MagicWandFilledDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MagicWandFilledDirective.prototype, "size", void 0); MagicWandFilledDirective = MagicWandFilledDirective_1 = __decorate([ Directive({ selector: "[ibmIconMagicWandFilled]" }), __metadata("design:paramtypes", [ElementRef]) ], MagicWandFilledDirective); let MagicWandFilledModule = class MagicWandFilledModule { }; MagicWandFilledModule = __decorate([ NgModule({ declarations: [ MagicWandFilledComponent, MagicWandFilledDirective, ], exports: [ MagicWandFilledComponent, MagicWandFilledDirective, ] }) ], MagicWandFilledModule); export { MagicWandFilledComponent, MagicWandFilledDirective, MagicWandFilledModule };