@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 13.5 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var HailComponent = /** @class */ (function () {
function HailComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], HailComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], HailComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], HailComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailComponent.prototype, "size", void 0);
HailComponent = __decorate([
Component({
selector: "ibm-icon-hail",
template: "\n <svg\n ibmIconHail\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 "
})
], HailComponent);
return HailComponent;
}());
var HailDirective = /** @class */ (function () {
function HailDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Hail32", "filepath": "hail/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": "circle", "attrs": { "cx": "21.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "24.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "7.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "4.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "10.499", "cy": "29.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z" } }, { "elem": "path", "attrs": { "d": "M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z" } }], "name": "hail", "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\"><circle cx=\"21.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"24.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"7.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"4.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"10.499\" cy=\"29.5\" r=\"1.5\"></circle><path d=\"M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z\"></path><path d=\"M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Hail24", "filepath": "hail/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": "circle", "attrs": { "cx": "21.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "24.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "7.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "4.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "10.499", "cy": "29.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z" } }, { "elem": "path", "attrs": { "d": "M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z" } }], "name": "hail", "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\"><circle cx=\"21.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"24.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"7.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"4.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"10.499\" cy=\"29.5\" r=\"1.5\"></circle><path d=\"M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z\"></path><path d=\"M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Hail20", "filepath": "hail/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": "circle", "attrs": { "cx": "21.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "24.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "7.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "4.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "10.499", "cy": "29.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z" } }, { "elem": "path", "attrs": { "d": "M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z" } }], "name": "hail", "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\"><circle cx=\"21.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"24.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"7.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"4.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"10.499\" cy=\"29.5\" r=\"1.5\"></circle><path d=\"M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z\"></path><path d=\"M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Hail16", "filepath": "hail/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": "circle", "attrs": { "cx": "21.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "24.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "7.5", "cy": "25.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "4.5", "cy": "29.5", "r": "1.5" } }, { "elem": "circle", "attrs": { "cx": "10.499", "cy": "29.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z" } }, { "elem": "path", "attrs": { "d": "M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z" } }], "name": "hail", "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\"><circle cx=\"21.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"24.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"7.5\" cy=\"25.5\" r=\"1.5\"></circle><circle cx=\"4.5\" cy=\"29.5\" r=\"1.5\"></circle><circle cx=\"10.499\" cy=\"29.5\" r=\"1.5\"></circle><path d=\"M15.868 30.496L14.132 29.504 17.276 24 11.277 24 16.132 15.504 17.868 16.496 14.723 22 20.724 22 15.868 30.496z\"></path><path d=\"M23.5,22H23V20h.5a4.4975,4.4975,0,0,0,.3564-8.981l-.8154-.0639-.0986-.812a6.9938,6.9938,0,0,0-13.8838,0l-.0991.812-.8155.0639A4.4975,4.4975,0,0,0,8.5,20H9v2H8.5A6.4973,6.4973,0,0,1,7.2,9.1362a8.9943,8.9943,0,0,1,17.6006,0A6.4974,6.4974,0,0,1,23.5,22Z\"></path></svg>"
},
};
}
HailDirective_1 = HailDirective;
HailDirective.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;
HailDirective_1.titleIdCounter++;
title.setAttribute("id", "hail-" + HailDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "hail-" + HailDirective_1.titleIdCounter);
}
};
var HailDirective_1;
HailDirective.titleIdCounter = 0;
HailDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], HailDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], HailDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], HailDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], HailDirective.prototype, "size", void 0);
HailDirective = HailDirective_1 = __decorate([
Directive({
selector: "[ibmIconHail]"
}),
__metadata("design:paramtypes", [ElementRef])
], HailDirective);
return HailDirective;
}());
var HailModule = /** @class */ (function () {
function HailModule() {
}
HailModule = __decorate([
NgModule({
declarations: [
HailComponent,
HailDirective,
],
exports: [
HailComponent,
HailDirective,
]
})
], HailModule);
return HailModule;
}());
export { HailComponent, HailDirective, HailModule };