@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 11.1 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var GeneratePdfDirective_1;
let GeneratePdfComponent = class GeneratePdfComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GeneratePdfComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GeneratePdfComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfComponent.prototype, "size", void 0);
GeneratePdfComponent = __decorate([
Component({
selector: "ibm-icon-generate-pdf",
template: `
<svg
ibmIconGeneratePdf
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], GeneratePdfComponent);
let GeneratePdfDirective = GeneratePdfDirective_1 = class GeneratePdfDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "GeneratePdf32", "filepath": "generate-pdf/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": "M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z" } }, { "elem": "path", "attrs": { "d": "M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z" } }], "name": "generate-pdf", "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="M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z"></path><path d="M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z"></path></svg>`
},
"24": {
metadata: { "moduleName": "GeneratePdf24", "filepath": "generate-pdf/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": "M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z" } }, { "elem": "path", "attrs": { "d": "M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z" } }], "name": "generate-pdf", "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="M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z"></path><path d="M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z"></path></svg>`
},
"20": {
metadata: { "moduleName": "GeneratePdf20", "filepath": "generate-pdf/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": "M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z" } }, { "elem": "path", "attrs": { "d": "M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z" } }], "name": "generate-pdf", "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="M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z"></path><path d="M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z"></path></svg>`
},
"16": {
metadata: { "moduleName": "GeneratePdf16", "filepath": "generate-pdf/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": "M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z" } }, { "elem": "path", "attrs": { "d": "M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z" } }], "name": "generate-pdf", "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="M24,24v4H8V24H6v4H6a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2h0V24Z"></path><path d="M21 21L19.586 19.586 17 22.172 17 14 15 14 15 22.172 12.414 19.586 11 21 16 26 21 21zM28 4L28 2 22 2 22 12 24 12 24 8 27 8 27 6 24 6 24 4 28 4zM17 12H13V2h4a3.0033 3.0033 0 013 3V9A3.0033 3.0033 0 0117 12zm-2-2h2a1.0011 1.0011 0 001-1V5a1.0011 1.0011 0 00-1-1H15zM9 2H4V12H6V9H9a2.0027 2.0027 0 002-2V4A2.0023 2.0023 0 009 2zM6 7V4H9l.001 3z"></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;
GeneratePdfDirective_1.titleIdCounter++;
title.setAttribute("id", `generate-pdf-${GeneratePdfDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `generate-pdf-${GeneratePdfDirective_1.titleIdCounter}`);
}
}
};
GeneratePdfDirective.titleIdCounter = 0;
GeneratePdfDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GeneratePdfDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], GeneratePdfDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], GeneratePdfDirective.prototype, "size", void 0);
GeneratePdfDirective = GeneratePdfDirective_1 = __decorate([
Directive({
selector: "[ibmIconGeneratePdf]"
}),
__metadata("design:paramtypes", [ElementRef])
], GeneratePdfDirective);
let GeneratePdfModule = class GeneratePdfModule {
};
GeneratePdfModule = __decorate([
NgModule({
declarations: [
GeneratePdfComponent,
GeneratePdfDirective,
],
exports: [
GeneratePdfComponent,
GeneratePdfDirective,
]
})
], GeneratePdfModule);
export { GeneratePdfComponent, GeneratePdfDirective, GeneratePdfModule };