@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 13.6 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var GraphicalDataFlowDirective_1;
let GraphicalDataFlowComponent = class GraphicalDataFlowComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GraphicalDataFlowComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GraphicalDataFlowComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowComponent.prototype, "size", void 0);
GraphicalDataFlowComponent = __decorate([
Component({
selector: "ibm-icon-graphical-data-flow",
template: `
<svg
ibmIconGraphicalDataFlow
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], GraphicalDataFlowComponent);
let GraphicalDataFlowDirective = GraphicalDataFlowDirective_1 = class GraphicalDataFlowDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "GraphicalDataFlow32", "filepath": "graphical-data-flow/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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z" } }], "name": "graphical-data-flow", "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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z"></path></svg>`
},
"24": {
metadata: { "moduleName": "GraphicalDataFlow24", "filepath": "graphical-data-flow/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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z" } }], "name": "graphical-data-flow", "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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z"></path></svg>`
},
"20": {
metadata: { "moduleName": "GraphicalDataFlow20", "filepath": "graphical-data-flow/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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z" } }], "name": "graphical-data-flow", "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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z"></path></svg>`
},
"16": {
metadata: { "moduleName": "GraphicalDataFlow16", "filepath": "graphical-data-flow/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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z" } }], "name": "graphical-data-flow", "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 30H22a2.0023 2.0023 0 01-2-2V22a2.0023 2.0023 0 012-2h6a2.0023 2.0023 0 012 2v6A2.0023 2.0023 0 0128 30zm-6-8h-.0012L22 28h6V22zM18 26H12a3.0033 3.0033 0 01-3-3V19h2v4a1.001 1.001 0 001 1h6zM26 18H24V15a1.001 1.001 0 00-1-1H18V12h5a3.0033 3.0033 0 013 3zM15 18a.9986.9986 0 01-.4971-.1323L10 15.2886 5.4968 17.8677a1 1 0 01-1.4712-1.0938l1.0618-4.572L2.269 9.1824a1 1 0 01.5662-1.6687l4.2-.7019L9.1006 2.5627a1 1 0 011.7881-.0214l2.2046 4.271 4.0764.7021a1 1 0 01.5613 1.668l-2.8184 3.02 1.0613 4.5718A1 1 0 0115 18zm-5-5s.343.18.4971.2686l3.01 1.7241-.7837-3.3763 2.282-2.4453-3.2331-.5569-1.7456-3.382L8.3829 8.6144l-3.3809.565 2.2745 2.437-.7841 3.3763 3.0105-1.7241C9.657 13.18 10 13 10 13z"></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;
GraphicalDataFlowDirective_1.titleIdCounter++;
title.setAttribute("id", `graphical-data-flow-${GraphicalDataFlowDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `graphical-data-flow-${GraphicalDataFlowDirective_1.titleIdCounter}`);
}
}
};
GraphicalDataFlowDirective.titleIdCounter = 0;
GraphicalDataFlowDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GraphicalDataFlowDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GraphicalDataFlowDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GraphicalDataFlowDirective.prototype, "size", void 0);
GraphicalDataFlowDirective = GraphicalDataFlowDirective_1 = __decorate([
Directive({
selector: "[ibmIconGraphicalDataFlow]"
}),
__metadata("design:paramtypes", [ElementRef])
], GraphicalDataFlowDirective);
let GraphicalDataFlowModule = class GraphicalDataFlowModule {
};
GraphicalDataFlowModule = __decorate([
NgModule({
declarations: [
GraphicalDataFlowComponent,
GraphicalDataFlowDirective,
],
exports: [
GraphicalDataFlowComponent,
GraphicalDataFlowDirective,
]
})
], GraphicalDataFlowModule);
export { GraphicalDataFlowComponent, GraphicalDataFlowDirective, GraphicalDataFlowModule };