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 WatsonMachineLearningDirective_1; let WatsonMachineLearningComponent = class WatsonMachineLearningComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonMachineLearningComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonMachineLearningComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningComponent.prototype, "size", void 0); WatsonMachineLearningComponent = __decorate([ Component({ selector: "ibm-icon-watson-machine-learning", template: ` <svg ibmIconWatsonMachineLearning [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], WatsonMachineLearningComponent); let WatsonMachineLearningDirective = WatsonMachineLearningDirective_1 = class WatsonMachineLearningDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "WatsonMachineLearning32", "filepath": "watson--machine-learning/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": "M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z" } }], "name": "watson--machine-learning", "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="M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z"></path></svg>` }, "24": { metadata: { "moduleName": "WatsonMachineLearning24", "filepath": "watson--machine-learning/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": "M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z" } }], "name": "watson--machine-learning", "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="M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z"></path></svg>` }, "20": { metadata: { "moduleName": "WatsonMachineLearning20", "filepath": "watson--machine-learning/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": "M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z" } }], "name": "watson--machine-learning", "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="M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z"></path></svg>` }, "16": { metadata: { "moduleName": "WatsonMachineLearning16", "filepath": "watson--machine-learning/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": "M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z" } }], "name": "watson--machine-learning", "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="M22 26H20V17.76l-3.23 3.88a1 1 0 01-1.54 0L12 17.76V26H10V15a1 1 0 01.66-.94 1 1 0 011.11.3L16 19.44l4.23-5.08a1 1 0 011.11-.3A1 1 0 0122 15zM4.16 14.65l-3-1.75a.76.76 0 10-.76 1.32L3.4 16a.76.76 0 10.76-1.31zM8.29 10.52a.73.73 0 001 .27.75.75 0 00.28-1l-1.74-3a.76.76 0 10-1.32.76zM16 9a.76.76 0 00.76-.76V4.76a.76.76 0 10-1.52 0V8.25A.76.76 0 0016 9zM22.68 10.79a.75.75 0 00.37.11.76.76 0 00.66-.38l1.75-3a.76.76 0 00-1.32-.76l-1.74 3A.75.75 0 0022.68 10.79zM31.9 13.18a.76.76 0 00-1-.28l-3 1.75A.76.76 0 0028.6 16l3-1.74A.77.77 0 0031.9 13.18z"></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; WatsonMachineLearningDirective_1.titleIdCounter++; title.setAttribute("id", `watson-machine-learning-${WatsonMachineLearningDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `watson-machine-learning-${WatsonMachineLearningDirective_1.titleIdCounter}`); } } }; WatsonMachineLearningDirective.titleIdCounter = 0; WatsonMachineLearningDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonMachineLearningDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonMachineLearningDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonMachineLearningDirective.prototype, "size", void 0); WatsonMachineLearningDirective = WatsonMachineLearningDirective_1 = __decorate([ Directive({ selector: "[ibmIconWatsonMachineLearning]" }), __metadata("design:paramtypes", [ElementRef]) ], WatsonMachineLearningDirective); let WatsonMachineLearningModule = class WatsonMachineLearningModule { }; WatsonMachineLearningModule = __decorate([ NgModule({ declarations: [ WatsonMachineLearningComponent, WatsonMachineLearningDirective, ], exports: [ WatsonMachineLearningComponent, WatsonMachineLearningDirective, ] }) ], WatsonMachineLearningModule); export { WatsonMachineLearningComponent, WatsonMachineLearningDirective, WatsonMachineLearningModule };