UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 12.3 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var SnowHeavyDirective_1; let SnowHeavyComponent = class SnowHeavyComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SnowHeavyComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SnowHeavyComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyComponent.prototype, "size", void 0); SnowHeavyComponent = __decorate([ Component({ selector: "ibm-icon-snow-heavy", template: ` <svg ibmIconSnowHeavy [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], SnowHeavyComponent); let SnowHeavyDirective = SnowHeavyDirective_1 = class SnowHeavyDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "SnowHeavy32", "filepath": "snow--heavy/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": "M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z" } }], "name": "snow--heavy", "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="M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z"></path></svg>` }, "24": { metadata: { "moduleName": "SnowHeavy24", "filepath": "snow--heavy/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": "M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z" } }], "name": "snow--heavy", "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="M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z"></path></svg>` }, "20": { metadata: { "moduleName": "SnowHeavy20", "filepath": "snow--heavy/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": "M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z" } }], "name": "snow--heavy", "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="M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z"></path></svg>` }, "16": { metadata: { "moduleName": "SnowHeavy16", "filepath": "snow--heavy/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": "M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z" } }], "name": "snow--heavy", "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="M4 26H6V28H4zM6 28H8V30H6zM8 30H10V32H8zM8 26H10V28H8zM4 30H6V32H4zM8 18H10V20H8zM10 20H12V22H10zM12 22H14V24H12zM12 18H14V20H12zM8 22H10V24H8zM18 18H20V20H18zM20 20H22V22H20zM22 22H24V24H22zM22 18H24V20H22zM18 22H20V24H18zM14 26H16V28H14zM16 28H18V30H16zM18 30H20V32H18zM18 26H20V28H18zM14 30H16V32H14z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4957,6.4957,0,0,0,6,21.4985v-2.26A4.4943,4.4943,0,0,1,8.144,11.019l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4944,4.4944,0,0,1,26,19.2383v2.26A6.4958,6.4958,0,0,0,24.8008,9.1362Z"></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; SnowHeavyDirective_1.titleIdCounter++; title.setAttribute("id", `snow-heavy-${SnowHeavyDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `snow-heavy-${SnowHeavyDirective_1.titleIdCounter}`); } } }; SnowHeavyDirective.titleIdCounter = 0; SnowHeavyDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SnowHeavyDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], SnowHeavyDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], SnowHeavyDirective.prototype, "size", void 0); SnowHeavyDirective = SnowHeavyDirective_1 = __decorate([ Directive({ selector: "[ibmIconSnowHeavy]" }), __metadata("design:paramtypes", [ElementRef]) ], SnowHeavyDirective); let SnowHeavyModule = class SnowHeavyModule { }; SnowHeavyModule = __decorate([ NgModule({ declarations: [ SnowHeavyComponent, SnowHeavyDirective, ], exports: [ SnowHeavyComponent, SnowHeavyDirective, ] }) ], SnowHeavyModule); export { SnowHeavyComponent, SnowHeavyDirective, SnowHeavyModule };