UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 12.2 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ChartMultitypeDirective_1; let ChartMultitypeComponent = class ChartMultitypeComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartMultitypeComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartMultitypeComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeComponent.prototype, "size", void 0); ChartMultitypeComponent = __decorate([ Component({ selector: "ibm-icon-chart-multitype", template: ` <svg ibmIconChartMultitype [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], ChartMultitypeComponent); let ChartMultitypeDirective = ChartMultitypeDirective_1 = class ChartMultitypeDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ChartMultitype32", "filepath": "chart--multitype/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": "M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "11", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "5", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "5", "cy": "9", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "3", "cy": "13", "r": "1" } }], "name": "chart--multitype", "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="M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z"></path><circle cx="11" cy="7" r="1"></circle><circle cx="9" cy="11" r="1"></circle><circle cx="7" cy="5" r="1"></circle><circle cx="5" cy="9" r="1"></circle><circle cx="3" cy="13" r="1"></circle></svg>` }, "24": { metadata: { "moduleName": "ChartMultitype24", "filepath": "chart--multitype/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": "M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "11", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "5", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "5", "cy": "9", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "3", "cy": "13", "r": "1" } }], "name": "chart--multitype", "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="M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z"></path><circle cx="11" cy="7" r="1"></circle><circle cx="9" cy="11" r="1"></circle><circle cx="7" cy="5" r="1"></circle><circle cx="5" cy="9" r="1"></circle><circle cx="3" cy="13" r="1"></circle></svg>` }, "20": { metadata: { "moduleName": "ChartMultitype20", "filepath": "chart--multitype/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": "M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "11", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "5", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "5", "cy": "9", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "3", "cy": "13", "r": "1" } }], "name": "chart--multitype", "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="M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z"></path><circle cx="11" cy="7" r="1"></circle><circle cx="9" cy="11" r="1"></circle><circle cx="7" cy="5" r="1"></circle><circle cx="5" cy="9" r="1"></circle><circle cx="3" cy="13" r="1"></circle></svg>` }, "16": { metadata: { "moduleName": "ChartMultitype16", "filepath": "chart--multitype/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": "M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "11", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "5", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "5", "cy": "9", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "3", "cy": "13", "r": "1" } }], "name": "chart--multitype", "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="M28 22H30V30H28zM24 18H26V30H24zM20 26H22V30H20zM9 16a7 7 0 107 7A7.0078 7.0078 0 009 16zm4.8989 6H10V18.1011A5.0145 5.0145 0 0113.8989 22zM9 28a5 5 0 01-1-9.8989V22a2 2 0 002 2h3.8989A5.0081 5.0081 0 019 28zM22.5352 12l4-6H30V4H25.4648l-4 6H18V2H16V14a2 2 0 002 2H30V14H18V12z"></path><circle cx="11" cy="7" r="1"></circle><circle cx="9" cy="11" r="1"></circle><circle cx="7" cy="5" r="1"></circle><circle cx="5" cy="9" r="1"></circle><circle cx="3" cy="13" r="1"></circle></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; ChartMultitypeDirective_1.titleIdCounter++; title.setAttribute("id", `chart-multitype-${ChartMultitypeDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `chart-multitype-${ChartMultitypeDirective_1.titleIdCounter}`); } } }; ChartMultitypeDirective.titleIdCounter = 0; ChartMultitypeDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartMultitypeDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartMultitypeDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartMultitypeDirective.prototype, "size", void 0); ChartMultitypeDirective = ChartMultitypeDirective_1 = __decorate([ Directive({ selector: "[ibmIconChartMultitype]" }), __metadata("design:paramtypes", [ElementRef]) ], ChartMultitypeDirective); let ChartMultitypeModule = class ChartMultitypeModule { }; ChartMultitypeModule = __decorate([ NgModule({ declarations: [ ChartMultitypeComponent, ChartMultitypeDirective, ], exports: [ ChartMultitypeComponent, ChartMultitypeDirective, ] }) ], ChartMultitypeModule); export { ChartMultitypeComponent, ChartMultitypeDirective, ChartMultitypeModule };