@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 UserSimulationDirective_1;
let UserSimulationComponent = class UserSimulationComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UserSimulationComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UserSimulationComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationComponent.prototype, "size", void 0);
UserSimulationComponent = __decorate([
Component({
selector: "ibm-icon-user-simulation",
template: `
<svg
ibmIconUserSimulation
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], UserSimulationComponent);
let UserSimulationDirective = UserSimulationDirective_1 = class UserSimulationDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "UserSimulation32", "filepath": "user--simulation/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": "M25.232 12.866H29.232V14.866H25.232z", "transform": "rotate(30 27.232 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 8H30V10H26z" } }, { "elem": "path", "attrs": { "d": "M2.768 12.866H6.768V14.866H2.768z", "transform": "rotate(150 4.768 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z" } }, { "elem": "path", "attrs": { "d": "M25.232 3.134H29.232V5.134H25.232z", "transform": "rotate(-30 27.232 4.134)" } }, { "elem": "path", "attrs": { "d": "M2 8H6V10H2z" } }, { "elem": "path", "attrs": { "d": "M2.768 3.134H6.768V5.134H2.768z", "transform": "rotate(-150 4.768 4.134)" } }], "name": "user--simulation", "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="M25.232 12.866H29.232V14.866H25.232z" transform="rotate(30 27.232 13.866)"></path><path d="M26 8H30V10H26z"></path><path d="M2.768 12.866H6.768V14.866H2.768z" transform="rotate(150 4.768 13.866)"></path><path d="M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z"></path><path d="M25.232 3.134H29.232V5.134H25.232z" transform="rotate(-30 27.232 4.134)"></path><path d="M2 8H6V10H2z"></path><path d="M2.768 3.134H6.768V5.134H2.768z" transform="rotate(-150 4.768 4.134)"></path></svg>`
},
"24": {
metadata: { "moduleName": "UserSimulation24", "filepath": "user--simulation/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": "M25.232 12.866H29.232V14.866H25.232z", "transform": "rotate(30 27.232 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 8H30V10H26z" } }, { "elem": "path", "attrs": { "d": "M2.768 12.866H6.768V14.866H2.768z", "transform": "rotate(150 4.768 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z" } }, { "elem": "path", "attrs": { "d": "M25.232 3.134H29.232V5.134H25.232z", "transform": "rotate(-30 27.232 4.134)" } }, { "elem": "path", "attrs": { "d": "M2 8H6V10H2z" } }, { "elem": "path", "attrs": { "d": "M2.768 3.134H6.768V5.134H2.768z", "transform": "rotate(-150 4.768 4.134)" } }], "name": "user--simulation", "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="M25.232 12.866H29.232V14.866H25.232z" transform="rotate(30 27.232 13.866)"></path><path d="M26 8H30V10H26z"></path><path d="M2.768 12.866H6.768V14.866H2.768z" transform="rotate(150 4.768 13.866)"></path><path d="M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z"></path><path d="M25.232 3.134H29.232V5.134H25.232z" transform="rotate(-30 27.232 4.134)"></path><path d="M2 8H6V10H2z"></path><path d="M2.768 3.134H6.768V5.134H2.768z" transform="rotate(-150 4.768 4.134)"></path></svg>`
},
"20": {
metadata: { "moduleName": "UserSimulation20", "filepath": "user--simulation/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": "M25.232 12.866H29.232V14.866H25.232z", "transform": "rotate(30 27.232 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 8H30V10H26z" } }, { "elem": "path", "attrs": { "d": "M2.768 12.866H6.768V14.866H2.768z", "transform": "rotate(150 4.768 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z" } }, { "elem": "path", "attrs": { "d": "M25.232 3.134H29.232V5.134H25.232z", "transform": "rotate(-30 27.232 4.134)" } }, { "elem": "path", "attrs": { "d": "M2 8H6V10H2z" } }, { "elem": "path", "attrs": { "d": "M2.768 3.134H6.768V5.134H2.768z", "transform": "rotate(-150 4.768 4.134)" } }], "name": "user--simulation", "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="M25.232 12.866H29.232V14.866H25.232z" transform="rotate(30 27.232 13.866)"></path><path d="M26 8H30V10H26z"></path><path d="M2.768 12.866H6.768V14.866H2.768z" transform="rotate(150 4.768 13.866)"></path><path d="M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z"></path><path d="M25.232 3.134H29.232V5.134H25.232z" transform="rotate(-30 27.232 4.134)"></path><path d="M2 8H6V10H2z"></path><path d="M2.768 3.134H6.768V5.134H2.768z" transform="rotate(-150 4.768 4.134)"></path></svg>`
},
"16": {
metadata: { "moduleName": "UserSimulation16", "filepath": "user--simulation/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": "M25.232 12.866H29.232V14.866H25.232z", "transform": "rotate(30 27.232 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 8H30V10H26z" } }, { "elem": "path", "attrs": { "d": "M2.768 12.866H6.768V14.866H2.768z", "transform": "rotate(150 4.768 13.866)" } }, { "elem": "path", "attrs": { "d": "M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z" } }, { "elem": "path", "attrs": { "d": "M25.232 3.134H29.232V5.134H25.232z", "transform": "rotate(-30 27.232 4.134)" } }, { "elem": "path", "attrs": { "d": "M2 8H6V10H2z" } }, { "elem": "path", "attrs": { "d": "M2.768 3.134H6.768V5.134H2.768z", "transform": "rotate(-150 4.768 4.134)" } }], "name": "user--simulation", "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="M25.232 12.866H29.232V14.866H25.232z" transform="rotate(30 27.232 13.866)"></path><path d="M26 8H30V10H26z"></path><path d="M2.768 12.866H6.768V14.866H2.768z" transform="rotate(150 4.768 13.866)"></path><path d="M26 30H24V25a5.0059 5.0059 0 00-5-5H13a5.0059 5.0059 0 00-5 5v5H6V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM16 4a5 5 0 11-5 5 5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0016 2z"></path><path d="M25.232 3.134H29.232V5.134H25.232z" transform="rotate(-30 27.232 4.134)"></path><path d="M2 8H6V10H2z"></path><path d="M2.768 3.134H6.768V5.134H2.768z" transform="rotate(-150 4.768 4.134)"></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;
UserSimulationDirective_1.titleIdCounter++;
title.setAttribute("id", `user-simulation-${UserSimulationDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `user-simulation-${UserSimulationDirective_1.titleIdCounter}`);
}
}
};
UserSimulationDirective.titleIdCounter = 0;
UserSimulationDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UserSimulationDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], UserSimulationDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], UserSimulationDirective.prototype, "size", void 0);
UserSimulationDirective = UserSimulationDirective_1 = __decorate([
Directive({
selector: "[ibmIconUserSimulation]"
}),
__metadata("design:paramtypes", [ElementRef])
], UserSimulationDirective);
let UserSimulationModule = class UserSimulationModule {
};
UserSimulationModule = __decorate([
NgModule({
declarations: [
UserSimulationComponent,
UserSimulationDirective,
],
exports: [
UserSimulationComponent,
UserSimulationDirective,
]
})
], UserSimulationModule);
export { UserSimulationComponent, UserSimulationDirective, UserSimulationModule };