@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 12.3 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var SummaryKpiComponent = /** @class */ (function () {
function SummaryKpiComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SummaryKpiComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SummaryKpiComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiComponent.prototype, "size", void 0);
SummaryKpiComponent = __decorate([
Component({
selector: "ibm-icon-summary-kpi",
template: "\n <svg\n ibmIconSummaryKpi\n [size]=\"size\"\n [ariaLabel]=\"ariaLabel\"\n [ariaLabelledby]=\"ariaLabelledby\"\n [ariaHidden]=\"ariaHidden\"\n [title]=\"title\"\n [isFocusable]=\"focusable\"\n [attr.class]=\"innerClass\">\n </svg>\n "
})
], SummaryKpiComponent);
return SummaryKpiComponent;
}());
var SummaryKpiDirective = /** @class */ (function () {
function SummaryKpiDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "SummaryKpi32", "filepath": "summary--KPI/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": "M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z" } }], "name": "summary--KPI", "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=\"M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "SummaryKpi24", "filepath": "summary--KPI/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": "M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z" } }], "name": "summary--KPI", "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=\"M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "SummaryKpi20", "filepath": "summary--KPI/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": "M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z" } }], "name": "summary--KPI", "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=\"M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "SummaryKpi16", "filepath": "summary--KPI/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": "M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z" } }], "name": "summary--KPI", "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=\"M7.6667 27.5027L2 22.4484l1.3311-1.4927 5.6411 5.0316 7.6906-7.4449a1.9282 1.9282 0 012.6736-.0084L22.96 21.9983l5.5791-5.9735L30 17.3905l-5.5812 5.9758a1.996 1.996 0 01-2.8379.08l-3.5765-3.4191-7.666 7.4206A1.9629 1.9629 0 017.6667 27.5027zM30 11L26 11 28 8 30 11zM22 4H18V6h4V8H19v2h3v2H18v2h4a2.0027 2.0027 0 002-2V6A2.0023 2.0023 0 0022 4zM16 14H10V10a2.002 2.002 0 012-2h2V6H10V4h4a2.0023 2.0023 0 012 2V8a2.0023 2.0023 0 01-2 2H12v2h4zM6 12L6 4 4 4 4 5 2 5 2 7 4 7 4 12 2 12 2 14 8 14 8 12 6 12z\"></path></svg>"
},
};
}
SummaryKpiDirective_1 = SummaryKpiDirective;
SummaryKpiDirective.prototype.ngAfterViewInit = function () {
var svg = this.elementRef.nativeElement;
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
var icon = this.icons[this.size];
var domParser = new DOMParser();
var rawSVG = icon.svg;
var svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement;
var 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;
}
var 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()
});
var attrKeys = Object.keys(attributes);
for (var i = 0; i < attrKeys.length; i++) {
var key = attrKeys[i];
var value = attributes[key];
if (key === "title") {
continue;
}
if (value) {
svg.setAttribute(key, value);
}
}
if (attributes.title) {
var title = document.createElement("title");
title.textContent = attributes.title;
SummaryKpiDirective_1.titleIdCounter++;
title.setAttribute("id", "summary-kpi-" + SummaryKpiDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "summary-kpi-" + SummaryKpiDirective_1.titleIdCounter);
}
};
var SummaryKpiDirective_1;
SummaryKpiDirective.titleIdCounter = 0;
SummaryKpiDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SummaryKpiDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SummaryKpiDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SummaryKpiDirective.prototype, "size", void 0);
SummaryKpiDirective = SummaryKpiDirective_1 = __decorate([
Directive({
selector: "[ibmIconSummaryKpi]"
}),
__metadata("design:paramtypes", [ElementRef])
], SummaryKpiDirective);
return SummaryKpiDirective;
}());
var SummaryKpiModule = /** @class */ (function () {
function SummaryKpiModule() {
}
SummaryKpiModule = __decorate([
NgModule({
declarations: [
SummaryKpiComponent,
SummaryKpiDirective,
],
exports: [
SummaryKpiComponent,
SummaryKpiDirective,
]
})
], SummaryKpiModule);
return SummaryKpiModule;
}());
export { SummaryKpiComponent, SummaryKpiDirective, SummaryKpiModule };