@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 12.8 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var DataVis_3Directive_1;
let DataVis_3Component = class DataVis_3Component {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Component.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Component.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DataVis_3Component.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Component.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DataVis_3Component.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Component.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Component.prototype, "size", void 0);
DataVis_3Component = __decorate([
Component({
selector: "ibm-icon-data-vis-3",
template: `
<svg
ibmIconDataVis_3
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], DataVis_3Component);
let DataVis_3Directive = DataVis_3Directive_1 = class DataVis_3Directive {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "DataVis_332", "filepath": "data-vis--3/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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z" } }], "name": "data-vis--3", "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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z"></path></svg>`
},
"24": {
metadata: { "moduleName": "DataVis_324", "filepath": "data-vis--3/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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z" } }], "name": "data-vis--3", "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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z"></path></svg>`
},
"20": {
metadata: { "moduleName": "DataVis_320", "filepath": "data-vis--3/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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z" } }], "name": "data-vis--3", "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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z"></path></svg>`
},
"16": {
metadata: { "moduleName": "DataVis_316", "filepath": "data-vis--3/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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z" } }], "name": "data-vis--3", "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,3a2.9913,2.9913,0,0,0-2.8163,2H21.858a3.9807,3.9807,0,0,0-7.716,0H9.858A3.9916,3.9916,0,1,0,5,9.858v4.284a3.9807,3.9807,0,0,0,0,7.716v3.3257a3,3,0,1,0,2,0V21.858a3.978,3.978,0,0,0,1.6729-.9034l3.3638,1.6819A2.9635,2.9635,0,0,0,12,23a3.0117,3.0117,0,1,0,.9221-2.1572L9.7744,19.269A3.95,3.95,0,0,0,10,18a3.9963,3.9963,0,0,0-3-3.858V9.858A3.9947,3.9947,0,0,0,9.858,7h4.284a3.9366,3.9366,0,0,0,4.7816,2.8818l1.8118,3.1705a3.0451,3.0451,0,1,0,1.7326-.9987L20.6893,8.941A3.9839,3.9839,0,0,0,21.858,7h3.3257A2.995,2.995,0,1,0,28,3ZM8,18a2,2,0,1,1-2-2A2.0023,2.0023,0,0,1,8,18ZM6,8A2,2,0,1,1,8,6,2.002,2.002,0,0,1,6,8ZM16,6a2,2,0,1,1,2,2A2.002,2.002,0,0,1,16,6Z"></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;
DataVis_3Directive_1.titleIdCounter++;
title.setAttribute("id", `data-vis-3-${DataVis_3Directive_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `data-vis-3-${DataVis_3Directive_1.titleIdCounter}`);
}
}
};
DataVis_3Directive.titleIdCounter = 0;
DataVis_3Directive.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Directive.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Directive.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DataVis_3Directive.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Directive.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DataVis_3Directive.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DataVis_3Directive.prototype, "size", void 0);
DataVis_3Directive = DataVis_3Directive_1 = __decorate([
Directive({
selector: "[ibmIconDataVis_3]"
}),
__metadata("design:paramtypes", [ElementRef])
], DataVis_3Directive);
let DataVis_3Module = class DataVis_3Module {
};
DataVis_3Module = __decorate([
NgModule({
declarations: [
DataVis_3Component,
DataVis_3Directive,
],
exports: [
DataVis_3Component,
DataVis_3Directive,
]
})
], DataVis_3Module);
export { DataVis_3Component, DataVis_3Directive, DataVis_3Module };