@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
174 lines (171 loc) • 10.1 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var TextLinkAnalysisDirective_1;
let TextLinkAnalysisComponent = class TextLinkAnalysisComponent {
constructor() {
this.focusable = false;
}
};
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TextLinkAnalysisComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TextLinkAnalysisComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisComponent.prototype, "size", void 0);
TextLinkAnalysisComponent = __decorate([
Component({
selector: "ibm-icon-text-link-analysis",
template: `
<svg
ibmIconTextLinkAnalysis
[size]="size"
[ariaLabel]="ariaLabel"
[ariaLabelledby]="ariaLabelledby"
[ariaHidden]="ariaHidden"
[title]="title"
[isFocusable]="focusable"
[attr.class]="innerClass">
</svg>
`
})
], TextLinkAnalysisComponent);
let TextLinkAnalysisDirective = TextLinkAnalysisDirective_1 = class TextLinkAnalysisDirective {
constructor(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "TextLinkAnalysis32", "filepath": "text-link--analysis/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": "M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z" } }, { "elem": "path", "attrs": { "d": "M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z" } }], "name": "text-link--analysis", "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="M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z"></path><path d="M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z"></path></svg>`
},
"24": {
metadata: { "moduleName": "TextLinkAnalysis24", "filepath": "text-link--analysis/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": "M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z" } }, { "elem": "path", "attrs": { "d": "M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z" } }], "name": "text-link--analysis", "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="M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z"></path><path d="M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z"></path></svg>`
},
"20": {
metadata: { "moduleName": "TextLinkAnalysis20", "filepath": "text-link--analysis/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": "M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z" } }, { "elem": "path", "attrs": { "d": "M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z" } }], "name": "text-link--analysis", "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="M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z"></path><path d="M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z"></path></svg>`
},
"16": {
metadata: { "moduleName": "TextLinkAnalysis16", "filepath": "text-link--analysis/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": "M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z" } }, { "elem": "path", "attrs": { "d": "M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z" } }], "name": "text-link--analysis", "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="M8 10H16V12H8zM8 6H20V8H8zM8 2H20V4H8z"></path><path d="M4.7111,28l5.6312-9.9961,7.4341,6.49A2,2,0,0,0,20.86,23.96l6.9707-10.4034-1.6622-1.1132-7,10.4472-.07.1035-7.4345-6.4907a2.0032,2.0032,0,0,0-3.0806.5308L4,25.1826V2H2V28a2.0023,2.0023,0,0,0,2,2H30V28Z"></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;
TextLinkAnalysisDirective_1.titleIdCounter++;
title.setAttribute("id", `text-link-analysis-${TextLinkAnalysisDirective_1.titleIdCounter}`);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", `text-link-analysis-${TextLinkAnalysisDirective_1.titleIdCounter}`);
}
}
};
TextLinkAnalysisDirective.titleIdCounter = 0;
TextLinkAnalysisDirective.ctorParameters = () => [
{ type: ElementRef }
];
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TextLinkAnalysisDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], TextLinkAnalysisDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], TextLinkAnalysisDirective.prototype, "size", void 0);
TextLinkAnalysisDirective = TextLinkAnalysisDirective_1 = __decorate([
Directive({
selector: "[ibmIconTextLinkAnalysis]"
}),
__metadata("design:paramtypes", [ElementRef])
], TextLinkAnalysisDirective);
let TextLinkAnalysisModule = class TextLinkAnalysisModule {
};
TextLinkAnalysisModule = __decorate([
NgModule({
declarations: [
TextLinkAnalysisComponent,
TextLinkAnalysisDirective,
],
exports: [
TextLinkAnalysisComponent,
TextLinkAnalysisDirective,
]
})
], TextLinkAnalysisModule);
export { TextLinkAnalysisComponent, TextLinkAnalysisDirective, TextLinkAnalysisModule };