@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 13.2 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var ChartPointDirective_1;
let ChartPointComponent = class ChartPointComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ChartPointComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ChartPointComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointComponent.prototype, "size", void 0);
ChartPointComponent = __decorate([
Component({
selector: "ibm-icon-chart-point",
template: `
<svg
ibmIconChartPoint
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], ChartPointComponent);
let ChartPointDirective = ChartPointDirective_1 = class ChartPointDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "ChartPoint32", "filepath": "chart--point/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": "M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "22", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "18", "cy": "14", "r": "3" } }, { "elem": "path", "attrs": { "d": "M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "22", "r": "3" } }, { "elem": "path", "attrs": { "d": "M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z" } }], "name": "chart--point", "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="M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z"></path><circle cx="9" cy="6" r="3"></circle><circle cx="9" cy="22" r="3"></circle><circle cx="18" cy="14" r="3"></circle><path d="M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z"></path><circle cx="27" cy="6" r="3"></circle><circle cx="27" cy="22" r="3"></circle><path d="M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z"></path></svg>`
},
"24": {
metadata: { "moduleName": "ChartPoint24", "filepath": "chart--point/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": "M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "22", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "18", "cy": "14", "r": "3" } }, { "elem": "path", "attrs": { "d": "M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "22", "r": "3" } }, { "elem": "path", "attrs": { "d": "M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z" } }], "name": "chart--point", "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="M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z"></path><circle cx="9" cy="6" r="3"></circle><circle cx="9" cy="22" r="3"></circle><circle cx="18" cy="14" r="3"></circle><path d="M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z"></path><circle cx="27" cy="6" r="3"></circle><circle cx="27" cy="22" r="3"></circle><path d="M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z"></path></svg>`
},
"20": {
metadata: { "moduleName": "ChartPoint20", "filepath": "chart--point/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": "M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "22", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "18", "cy": "14", "r": "3" } }, { "elem": "path", "attrs": { "d": "M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "22", "r": "3" } }, { "elem": "path", "attrs": { "d": "M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z" } }], "name": "chart--point", "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="M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z"></path><circle cx="9" cy="6" r="3"></circle><circle cx="9" cy="22" r="3"></circle><circle cx="18" cy="14" r="3"></circle><path d="M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z"></path><circle cx="27" cy="6" r="3"></circle><circle cx="27" cy="22" r="3"></circle><path d="M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z"></path></svg>`
},
"16": {
metadata: { "moduleName": "ChartPoint16", "filepath": "chart--point/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": "M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "9", "cy": "22", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "18", "cy": "14", "r": "3" } }, { "elem": "path", "attrs": { "d": "M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "6", "r": "3" } }, { "elem": "circle", "attrs": { "cx": "27", "cy": "22", "r": "3" } }, { "elem": "path", "attrs": { "d": "M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z" } }], "name": "chart--point", "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="M30,30H4a2.0023,2.0023,0,0,1-2-2V2H4V28H30Z"></path><circle cx="9" cy="6" r="3"></circle><circle cx="9" cy="22" r="3"></circle><circle cx="18" cy="14" r="3"></circle><path d="M9,17a3,3,0,1,1,3-3A3.0033,3.0033,0,0,1,9,17Zm0-4a1,1,0,1,0,1,1A1.001,1.001,0,0,0,9,13Z"></path><circle cx="27" cy="6" r="3"></circle><circle cx="27" cy="22" r="3"></circle><path d="M27 17a3 3 0 113-3A3.0033 3.0033 0 0127 17zm0-4a1 1 0 101 1A1.001 1.001 0 0027 13zM18 26a3 3 0 113-3A3.0033 3.0033 0 0118 26zm0-4a1 1 0 101 1A1.001 1.001 0 0018 22zM18 8a3 3 0 113-3A3.0033 3.0033 0 0118 8zm0-4a1 1 0 101 1A1.001 1.001 0 0018 4z"></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;
ChartPointDirective_1.titleIdCounter++;
title.setAttribute("id", `chart-point-${ChartPointDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `chart-point-${ChartPointDirective_1.titleIdCounter}`);
}
}
};
ChartPointDirective.titleIdCounter = 0;
ChartPointDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ChartPointDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ChartPointDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ChartPointDirective.prototype, "size", void 0);
ChartPointDirective = ChartPointDirective_1 = __decorate([
Directive({
selector: "[ibmIconChartPoint]"
}),
__metadata("design:paramtypes", [ElementRef])
], ChartPointDirective);
let ChartPointModule = class ChartPointModule {
};
ChartPointModule = __decorate([
NgModule({
declarations: [
ChartPointComponent,
ChartPointDirective,
],
exports: [
ChartPointComponent,
ChartPointDirective,
]
})
], ChartPointModule);
export { ChartPointComponent, ChartPointDirective, ChartPointModule };