@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 WintryMixDirective_1;
let WintryMixComponent = class WintryMixComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], WintryMixComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], WintryMixComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixComponent.prototype, "size", void 0);
WintryMixComponent = __decorate([
Component({
selector: "ibm-icon-wintry-mix",
template: `
<svg
ibmIconWintryMix
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], WintryMixComponent);
let WintryMixDirective = WintryMixDirective_1 = class WintryMixDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "WintryMix32", "filepath": "wintry-mix/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": "M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z" } }], "name": "wintry-mix", "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="M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z"></path></svg>`
},
"24": {
metadata: { "moduleName": "WintryMix24", "filepath": "wintry-mix/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": "M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z" } }], "name": "wintry-mix", "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="M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z"></path></svg>`
},
"20": {
metadata: { "moduleName": "WintryMix20", "filepath": "wintry-mix/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": "M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z" } }], "name": "wintry-mix", "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="M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z"></path></svg>`
},
"16": {
metadata: { "moduleName": "WintryMix16", "filepath": "wintry-mix/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": "M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z" } }], "name": "wintry-mix", "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="M15 26H17V28H15zM17 28H19V30H17zM19 30H21V32H19zM19 26H21V28H19zM15 30H17V32H15zM13 16H15V18H13zM15 18H17V20H15zM17 20H19V22H17zM17 16H19V18H17zM13 20H15V22H13zM10 30a1 1 0 01-.8944-1.4474l2-4.0005a1 1 0 111.7888.8947l-2 4A.9981.9981 0 0110 30z"></path><path d="M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.5321,6.5321,0,0,0,2,15.5V22l1,2,1-2V20.18a6.4891,6.4891,0,0,0,3.4294,1.7246L6.106,24.5527a1,1,0,1,0,1.7885.8946l2-4a1,1,0,0,0-.447-1.3418.977.977,0,0,0-.489-.0894V20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20h-.542v.0083A.9955.9955,0,0,0,22,21v3l1,2,1-2V21.9746a6.4473,6.4473,0,0,0,2-.4761V26l1,2,1-2V20.18A6.4876,6.4876,0,0,0,24.8008,9.1362Z"></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;
WintryMixDirective_1.titleIdCounter++;
title.setAttribute("id", `wintry-mix-${WintryMixDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `wintry-mix-${WintryMixDirective_1.titleIdCounter}`);
}
}
};
WintryMixDirective.titleIdCounter = 0;
WintryMixDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], WintryMixDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], WintryMixDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], WintryMixDirective.prototype, "size", void 0);
WintryMixDirective = WintryMixDirective_1 = __decorate([
Directive({
selector: "[ibmIconWintryMix]"
}),
__metadata("design:paramtypes", [ElementRef])
], WintryMixDirective);
let WintryMixModule = class WintryMixModule {
};
WintryMixModule = __decorate([
NgModule({
declarations: [
WintryMixComponent,
WintryMixDirective,
],
exports: [
WintryMixComponent,
WintryMixDirective,
]
})
], WintryMixModule);
export { WintryMixComponent, WintryMixDirective, WintryMixModule };