@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 15.7 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var MachineLearningModelDirective_1;
let MachineLearningModelComponent = class MachineLearningModelComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], MachineLearningModelComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], MachineLearningModelComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelComponent.prototype, "size", void 0);
MachineLearningModelComponent = __decorate([
Component({
selector: "ibm-icon-machine-learning-model",
template: `
<svg
ibmIconMachineLearningModel
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], MachineLearningModelComponent);
let MachineLearningModelDirective = MachineLearningModelDirective_1 = class MachineLearningModelDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "MachineLearningModel32", "filepath": "machine-learning-model/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": "M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z" } }, { "elem": "path", "attrs": { "d": "M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z" } }], "name": "machine-learning-model", "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="M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z"></path><path d="M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z"></path></svg>`
},
"24": {
metadata: { "moduleName": "MachineLearningModel24", "filepath": "machine-learning-model/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": "M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z" } }, { "elem": "path", "attrs": { "d": "M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z" } }], "name": "machine-learning-model", "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="M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z"></path><path d="M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z"></path></svg>`
},
"20": {
metadata: { "moduleName": "MachineLearningModel20", "filepath": "machine-learning-model/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": "M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z" } }, { "elem": "path", "attrs": { "d": "M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z" } }], "name": "machine-learning-model", "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="M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z"></path><path d="M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z"></path></svg>`
},
"16": {
metadata: { "moduleName": "MachineLearningModel16", "filepath": "machine-learning-model/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": "M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z" } }, { "elem": "path", "attrs": { "d": "M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z" } }], "name": "machine-learning-model", "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="M27 24a2.9609 2.9609 0 00-1.2854.3008L21.4141 20H18v2h2.5859l3.7146 3.7148A2.9665 2.9665 0 0024 27a3 3 0 103-3zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 28zM27 13a2.9948 2.9948 0 00-2.8157 2H18v2h6.1843A2.9947 2.9947 0 1027 13zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 17zM27 2a3.0033 3.0033 0 00-3 3 2.9657 2.9657 0 00.3481 1.373L20.5957 10H18v2h3.4043l4.3989-4.2524A2.9987 2.9987 0 1027 2zm0 4a1 1 0 111-1A1.0009 1.0009 0 0127 6z"></path><path d="M18,6h2V4H18a3.9756,3.9756,0,0,0-3,1.3823A3.9756,3.9756,0,0,0,12,4H11a9.01,9.01,0,0,0-9,9v6a9.01,9.01,0,0,0,9,9h1a3.9756,3.9756,0,0,0,3-1.3823A3.9756,3.9756,0,0,0,18,28h2V26H18a2.0023,2.0023,0,0,1-2-2V8A2.0023,2.0023,0,0,1,18,6ZM12,26H11a7.0047,7.0047,0,0,1-6.92-6H6V18H4V14H7a3.0033,3.0033,0,0,0,3-3V9H8v2a1.0009,1.0009,0,0,1-1,1H4.08A7.0047,7.0047,0,0,1,11,6h1a2.0023,2.0023,0,0,1,2,2v4H12v2h2v4H12a3.0033,3.0033,0,0,0-3,3v2h2V21a1.0009,1.0009,0,0,1,1-1h2v4A2.0023,2.0023,0,0,1,12,26Z"></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;
MachineLearningModelDirective_1.titleIdCounter++;
title.setAttribute("id", `machine-learning-model-${MachineLearningModelDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `machine-learning-model-${MachineLearningModelDirective_1.titleIdCounter}`);
}
}
};
MachineLearningModelDirective.titleIdCounter = 0;
MachineLearningModelDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], MachineLearningModelDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], MachineLearningModelDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], MachineLearningModelDirective.prototype, "size", void 0);
MachineLearningModelDirective = MachineLearningModelDirective_1 = __decorate([
Directive({
selector: "[ibmIconMachineLearningModel]"
}),
__metadata("design:paramtypes", [ElementRef])
], MachineLearningModelDirective);
let MachineLearningModelModule = class MachineLearningModelModule {
};
MachineLearningModelModule = __decorate([
NgModule({
declarations: [
MachineLearningModelComponent,
MachineLearningModelDirective,
],
exports: [
MachineLearningModelComponent,
MachineLearningModelDirective,
]
})
], MachineLearningModelModule);
export { MachineLearningModelComponent, MachineLearningModelDirective, MachineLearningModelModule };