@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 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 DashboardReferenceComponent = /** @class */ (function () {
function DashboardReferenceComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DashboardReferenceComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DashboardReferenceComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceComponent.prototype, "size", void 0);
DashboardReferenceComponent = __decorate([
Component({
selector: "ibm-icon-dashboard-reference",
template: "\n <svg\n ibmIconDashboardReference\n [size]=\"size\"\n [ariaLabel]=\"ariaLabel\"\n [ariaLabelledby]=\"ariaLabelledby\"\n [ariaHidden]=\"ariaHidden\"\n [title]=\"title\"\n [isFocusable]=\"focusable\"\n [attr.class]=\"innerClass\">\n </svg>\n "
})
], DashboardReferenceComponent);
return DashboardReferenceComponent;
}());
var DashboardReferenceDirective = /** @class */ (function () {
function DashboardReferenceDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "DashboardReference32", "filepath": "dashboard--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z" } }, { "elem": "path", "attrs": { "d": "M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z" } }], "name": "dashboard--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z\"></path><path d=\"M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "DashboardReference24", "filepath": "dashboard--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z" } }, { "elem": "path", "attrs": { "d": "M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z" } }], "name": "dashboard--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z\"></path><path d=\"M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "DashboardReference20", "filepath": "dashboard--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z" } }, { "elem": "path", "attrs": { "d": "M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z" } }], "name": "dashboard--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z\"></path><path d=\"M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "DashboardReference16", "filepath": "dashboard--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z" } }, { "elem": "path", "attrs": { "d": "M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z" } }], "name": "dashboard--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM24 21H26V26H24zM20 16H22V26H20zM16 18H18V26H16z\"></path><path d=\"M28,2H4A2.002,2.002,0,0,0,2,4V16H4V13H28.001l.001,15H16v2H28a2.0027,2.0027,0,0,0,2-2V4A2.0023,2.0023,0,0,0,28,2ZM12,11H4V4h8Zm2,0V4H28l.0007,7Z\"></path></svg>"
},
};
}
DashboardReferenceDirective_1 = DashboardReferenceDirective;
DashboardReferenceDirective.prototype.ngAfterViewInit = function () {
var svg = this.elementRef.nativeElement;
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
var icon = this.icons[this.size];
var domParser = new DOMParser();
var rawSVG = icon.svg;
var svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement;
var 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;
}
var 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()
});
var attrKeys = Object.keys(attributes);
for (var i = 0; i < attrKeys.length; i++) {
var key = attrKeys[i];
var value = attributes[key];
if (key === "title") {
continue;
}
if (value) {
svg.setAttribute(key, value);
}
}
if (attributes.title) {
var title = document.createElement("title");
title.textContent = attributes.title;
DashboardReferenceDirective_1.titleIdCounter++;
title.setAttribute("id", "dashboard-reference-" + DashboardReferenceDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "dashboard-reference-" + DashboardReferenceDirective_1.titleIdCounter);
}
};
var DashboardReferenceDirective_1;
DashboardReferenceDirective.titleIdCounter = 0;
DashboardReferenceDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DashboardReferenceDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], DashboardReferenceDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], DashboardReferenceDirective.prototype, "size", void 0);
DashboardReferenceDirective = DashboardReferenceDirective_1 = __decorate([
Directive({
selector: "[ibmIconDashboardReference]"
}),
__metadata("design:paramtypes", [ElementRef])
], DashboardReferenceDirective);
return DashboardReferenceDirective;
}());
var DashboardReferenceModule = /** @class */ (function () {
function DashboardReferenceModule() {
}
DashboardReferenceModule = __decorate([
NgModule({
declarations: [
DashboardReferenceComponent,
DashboardReferenceDirective,
],
exports: [
DashboardReferenceComponent,
DashboardReferenceDirective,
]
})
], DashboardReferenceModule);
return DashboardReferenceModule;
}());
export { DashboardReferenceComponent, DashboardReferenceDirective, DashboardReferenceModule };