UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 12.4 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var WatsonHealthAiResultsDirective_1; let WatsonHealthAiResultsComponent = class WatsonHealthAiResultsComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthAiResultsComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthAiResultsComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsComponent.prototype, "size", void 0); WatsonHealthAiResultsComponent = __decorate([ Component({ selector: "ibm-icon-watson-health-ai-results", template: ` <svg ibmIconWatsonHealthAiResults [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], WatsonHealthAiResultsComponent); let WatsonHealthAiResultsDirective = WatsonHealthAiResultsDirective_1 = class WatsonHealthAiResultsDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "WatsonHealthAiResults32", "filepath": "watson-health/ai-results/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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z" } }], "name": "ai-results", "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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z"></path></svg>` }, "24": { metadata: { "moduleName": "WatsonHealthAiResults24", "filepath": "watson-health/ai-results/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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z" } }], "name": "ai-results", "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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z"></path></svg>` }, "20": { metadata: { "moduleName": "WatsonHealthAiResults20", "filepath": "watson-health/ai-results/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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z" } }], "name": "ai-results", "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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z"></path></svg>` }, "16": { metadata: { "moduleName": "WatsonHealthAiResults16", "filepath": "watson-health/ai-results/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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z" } }], "name": "ai-results", "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 8a5.9908 5.9908 0 009.4712 4.8853L28.586 16 30 14.586l-3.115-3.1148A5.997 5.997 0 1016 8zm2 0a4 4 0 114 4A4.0045 4.0045 0 0118 8zM11 24H21V26H11zM13 28H19V30H13zM10.8145 18.1406A7.1851 7.1851 0 018 12a8.0055 8.0055 0 016-7.7373L13.6138 2.3A10.0088 10.0088 0 006 12a9.1793 9.1793 0 003.46 7.6162C10.4717 20.5508 11 21.0815 11 22h2C13 20.16 11.8892 19.1338 10.8145 18.1406zM23.0493 16a9.5991 9.5991 0 01-1.8716 2.1426C20.1069 19.1348 19 20.1611 19 22h2c0-.9194.5264-1.45 1.5352-2.3857a10.9664 10.9664 0 002.3686-2.8331z"></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; WatsonHealthAiResultsDirective_1.titleIdCounter++; title.setAttribute("id", `watson-health-ai-results-${WatsonHealthAiResultsDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `watson-health-ai-results-${WatsonHealthAiResultsDirective_1.titleIdCounter}`); } } }; WatsonHealthAiResultsDirective.titleIdCounter = 0; WatsonHealthAiResultsDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthAiResultsDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthAiResultsDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthAiResultsDirective.prototype, "size", void 0); WatsonHealthAiResultsDirective = WatsonHealthAiResultsDirective_1 = __decorate([ Directive({ selector: "[ibmIconWatsonHealthAiResults]" }), __metadata("design:paramtypes", [ElementRef]) ], WatsonHealthAiResultsDirective); let WatsonHealthAiResultsModule = class WatsonHealthAiResultsModule { }; WatsonHealthAiResultsModule = __decorate([ NgModule({ declarations: [ WatsonHealthAiResultsComponent, WatsonHealthAiResultsDirective, ], exports: [ WatsonHealthAiResultsComponent, WatsonHealthAiResultsDirective, ] }) ], WatsonHealthAiResultsModule); export { WatsonHealthAiResultsComponent, WatsonHealthAiResultsDirective, WatsonHealthAiResultsModule };