@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 13.4 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var QuadrantPlotDirective_1;
let QuadrantPlotComponent = class QuadrantPlotComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], QuadrantPlotComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], QuadrantPlotComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotComponent.prototype, "size", void 0);
QuadrantPlotComponent = __decorate([
Component({
selector: "ibm-icon-quadrant-plot",
template: `
<svg
ibmIconQuadrantPlot
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], QuadrantPlotComponent);
let QuadrantPlotDirective = QuadrantPlotDirective_1 = class QuadrantPlotDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "QuadrantPlot32", "filepath": "quadrant-plot/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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z" } }, { "elem": "path", "attrs": { "d": "M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "21", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "22", "cy": "28", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "24", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "4", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "4", "r": "2" } }], "name": "quadrant-plot", "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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z"></path><path d="M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z"></path><circle cx="11" cy="11" r="2"></circle><circle cx="11" cy="21" r="2"></circle><circle cx="21" cy="21" r="2"></circle><circle cx="22" cy="28" r="2"></circle><circle cx="28" cy="24" r="2"></circle><circle cx="4" cy="11" r="2"></circle><circle cx="28" cy="4" r="2"></circle></svg>`
},
"24": {
metadata: { "moduleName": "QuadrantPlot24", "filepath": "quadrant-plot/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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z" } }, { "elem": "path", "attrs": { "d": "M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "21", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "22", "cy": "28", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "24", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "4", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "4", "r": "2" } }], "name": "quadrant-plot", "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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z"></path><path d="M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z"></path><circle cx="11" cy="11" r="2"></circle><circle cx="11" cy="21" r="2"></circle><circle cx="21" cy="21" r="2"></circle><circle cx="22" cy="28" r="2"></circle><circle cx="28" cy="24" r="2"></circle><circle cx="4" cy="11" r="2"></circle><circle cx="28" cy="4" r="2"></circle></svg>`
},
"20": {
metadata: { "moduleName": "QuadrantPlot20", "filepath": "quadrant-plot/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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z" } }, { "elem": "path", "attrs": { "d": "M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "21", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "22", "cy": "28", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "24", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "4", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "4", "r": "2" } }], "name": "quadrant-plot", "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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z"></path><path d="M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z"></path><circle cx="11" cy="11" r="2"></circle><circle cx="11" cy="21" r="2"></circle><circle cx="21" cy="21" r="2"></circle><circle cx="22" cy="28" r="2"></circle><circle cx="28" cy="24" r="2"></circle><circle cx="4" cy="11" r="2"></circle><circle cx="28" cy="4" r="2"></circle></svg>`
},
"16": {
metadata: { "moduleName": "QuadrantPlot16", "filepath": "quadrant-plot/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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z" } }, { "elem": "path", "attrs": { "d": "M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "21", "cy": "21", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "22", "cy": "28", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "24", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "4", "cy": "11", "r": "2" } }, { "elem": "circle", "attrs": { "cx": "28", "cy": "4", "r": "2" } }], "name": "quadrant-plot", "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 15L17 15 17 2 15 2 15 15 2 15 2 17 15 17 15 30 17 30 17 17 30 17 30 15z"></path><path d="M5 30a3 3 0 113-3A3.0033 3.0033 0 015 30zm0-4a1 1 0 101 1A1.001 1.001 0 005 26zM8 8a3 3 0 113-3A3.0033 3.0033 0 018 8zM8 4A1 1 0 109 5 1.001 1.001 0 008 4zM22 13a3 3 0 113-3A3.0033 3.0033 0 0122 13zm0-4a1 1 0 101 1A1.001 1.001 0 0022 9z"></path><circle cx="11" cy="11" r="2"></circle><circle cx="11" cy="21" r="2"></circle><circle cx="21" cy="21" r="2"></circle><circle cx="22" cy="28" r="2"></circle><circle cx="28" cy="24" r="2"></circle><circle cx="4" cy="11" r="2"></circle><circle cx="28" cy="4" r="2"></circle></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;
QuadrantPlotDirective_1.titleIdCounter++;
title.setAttribute("id", `quadrant-plot-${QuadrantPlotDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `quadrant-plot-${QuadrantPlotDirective_1.titleIdCounter}`);
}
}
};
QuadrantPlotDirective.titleIdCounter = 0;
QuadrantPlotDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], QuadrantPlotDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], QuadrantPlotDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QuadrantPlotDirective.prototype, "size", void 0);
QuadrantPlotDirective = QuadrantPlotDirective_1 = __decorate([
Directive({
selector: "[ibmIconQuadrantPlot]"
}),
__metadata("design:paramtypes", [ElementRef])
], QuadrantPlotDirective);
let QuadrantPlotModule = class QuadrantPlotModule {
};
QuadrantPlotModule = __decorate([
NgModule({
declarations: [
QuadrantPlotComponent,
QuadrantPlotDirective,
],
exports: [
QuadrantPlotComponent,
QuadrantPlotDirective,
]
})
], QuadrantPlotModule);
export { QuadrantPlotComponent, QuadrantPlotDirective, QuadrantPlotModule };