UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 10.5 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var FaceDizzyDirective_1; let FaceDizzyComponent = class FaceDizzyComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FaceDizzyComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FaceDizzyComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyComponent.prototype, "size", void 0); FaceDizzyComponent = __decorate([ Component({ selector: "ibm-icon-face-dizzy", template: ` <svg ibmIconFaceDizzy [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], FaceDizzyComponent); let FaceDizzyDirective = FaceDizzyDirective_1 = class FaceDizzyDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "FaceDizzy32", "filepath": "face--dizzy/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,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z" } }, { "elem": "path", "attrs": { "d": "M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z" } }], "name": "face--dizzy", "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,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z"></path><path d="M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z"></path></svg>` }, "24": { metadata: { "moduleName": "FaceDizzy24", "filepath": "face--dizzy/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": "M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z" } }, { "elem": "path", "attrs": { "d": "M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z" } }], "name": "face--dizzy", "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="M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z"></path><path d="M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z"></path></svg>` }, "20": { metadata: { "moduleName": "FaceDizzy20", "filepath": "face--dizzy/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": "M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z" } }, { "elem": "path", "attrs": { "d": "M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z" } }], "name": "face--dizzy", "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="M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z"></path><path d="M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z"></path></svg>` }, "16": { metadata: { "moduleName": "FaceDizzy16", "filepath": "face--dizzy/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": "M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z" } }, { "elem": "path", "attrs": { "d": "M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z" } }], "name": "face--dizzy", "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="M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2Zm0,26A12,12,0,1,1,28,16,12,12,0,0,1,16,28Z"></path><path d="M24.41 11L23 9.59 21 11.59 19 9.59 17.59 11 19.59 13 17.59 15 19 16.41 21 14.41 23 16.41 24.41 15 22.41 13 24.41 11zM14.41 11L13 9.59 11 11.59 9 9.59 7.59 11 9.59 13 7.59 15 9 16.41 11 14.41 13 16.41 14.41 15 12.41 13 14.41 11zM16 19a3 3 0 103 3 3 3 0 00-3-3z"></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; FaceDizzyDirective_1.titleIdCounter++; title.setAttribute("id", `face-dizzy-${FaceDizzyDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `face-dizzy-${FaceDizzyDirective_1.titleIdCounter}`); } } }; FaceDizzyDirective.titleIdCounter = 0; FaceDizzyDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FaceDizzyDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FaceDizzyDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], FaceDizzyDirective.prototype, "size", void 0); FaceDizzyDirective = FaceDizzyDirective_1 = __decorate([ Directive({ selector: "[ibmIconFaceDizzy]" }), __metadata("design:paramtypes", [ElementRef]) ], FaceDizzyDirective); let FaceDizzyModule = class FaceDizzyModule { }; FaceDizzyModule = __decorate([ NgModule({ declarations: [ FaceDizzyComponent, FaceDizzyDirective, ], exports: [ FaceDizzyComponent, FaceDizzyDirective, ] }) ], FaceDizzyModule); export { FaceDizzyComponent, FaceDizzyDirective, FaceDizzyModule };