UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 12.6 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var HeatMapDirective_1; let HeatMapComponent = class HeatMapComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], HeatMapComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HeatMapComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HeatMapComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapComponent.prototype, "size", void 0); HeatMapComponent = __decorate([ Component({ selector: "ibm-icon-heat-map", template: ` <svg ibmIconHeatMap [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], HeatMapComponent); let HeatMapDirective = HeatMapDirective_1 = class HeatMapDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "HeatMap32", "filepath": "heat-map/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": "M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z" } }], "name": "heat-map", "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="M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z"></path></svg>` }, "24": { metadata: { "moduleName": "HeatMap24", "filepath": "heat-map/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": "M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z" } }], "name": "heat-map", "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="M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z"></path></svg>` }, "20": { metadata: { "moduleName": "HeatMap20", "filepath": "heat-map/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": "M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z" } }], "name": "heat-map", "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="M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z"></path></svg>` }, "16": { metadata: { "moduleName": "HeatMap16", "filepath": "heat-map/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": "M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z" } }], "name": "heat-map", "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="M20 18H22V20H20zM28 16H30V18H28zM14 6H16V8H14zM16 22H12V16a2.0023 2.0023 0 00-2-2H4a2.0023 2.0023 0 00-2 2v6a2.0023 2.0023 0 002 2h6v4a2.0023 2.0023 0 002 2h4a2.0023 2.0023 0 002-2V24A2.0023 2.0023 0 0016 22zM4 22V16h6v6zm8 6V24h4v4zM28 30H24a2.0021 2.0021 0 01-2-2V24a2.0021 2.0021 0 012-2h4a2.0021 2.0021 0 012 2v4A2.0021 2.0021 0 0128 30zm-4-6v4h4V24zM28 2H22a2.0023 2.0023 0 00-2 2v6H18a2.0023 2.0023 0 00-2 2v2a2.0023 2.0023 0 002 2h2a2.0023 2.0023 0 002-2V12h6a2.0023 2.0023 0 002-2V4A2.0023 2.0023 0 0028 2zM18 14V12h2v2zm4-4V4h6v6zM8 10H4A2.0021 2.0021 0 012 8V4A2.0021 2.0021 0 014 2H8a2.0021 2.0021 0 012 2V8A2.0021 2.0021 0 018 10zM4 4V8H8V4z"></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; HeatMapDirective_1.titleIdCounter++; title.setAttribute("id", `heat-map-${HeatMapDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `heat-map-${HeatMapDirective_1.titleIdCounter}`); } } }; HeatMapDirective.titleIdCounter = 0; HeatMapDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], HeatMapDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HeatMapDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HeatMapDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HeatMapDirective.prototype, "size", void 0); HeatMapDirective = HeatMapDirective_1 = __decorate([ Directive({ selector: "[ibmIconHeatMap]" }), __metadata("design:paramtypes", [ElementRef]) ], HeatMapDirective); let HeatMapModule = class HeatMapModule { }; HeatMapModule = __decorate([ NgModule({ declarations: [ HeatMapComponent, HeatMapDirective, ], exports: [ HeatMapComponent, HeatMapDirective, ] }) ], HeatMapModule); export { HeatMapComponent, HeatMapDirective, HeatMapModule };