@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 12 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var SunriseComponent = /** @class */ (function () {
function SunriseComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], SunriseComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunriseComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunriseComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseComponent.prototype, "size", void 0);
SunriseComponent = __decorate([
Component({
selector: "ibm-icon-sunrise",
template: "\n <svg\n ibmIconSunrise\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 "
})
], SunriseComponent);
return SunriseComponent;
}());
var SunriseDirective = /** @class */ (function () {
function SunriseDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Sunrise32", "filepath": "sunrise/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": "M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 14.854H26.625999999999998V16.854H21.668z", "transform": "rotate(-45 24.146 15.854)" } }, { "elem": "path", "attrs": { "d": "M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z" } }, { "elem": "path", "attrs": { "d": "M6.854 13.374H8.854V18.332H6.854z", "transform": "rotate(-45 7.854 15.854)" } }, { "elem": "path", "attrs": { "d": "M2 22H7V24H2z" } }], "name": "sunrise", "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=\"M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z\"></path><path d=\"M21.668 14.854H26.625999999999998V16.854H21.668z\" transform=\"rotate(-45 24.146 15.854)\"></path><path d=\"M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z\"></path><path d=\"M6.854 13.374H8.854V18.332H6.854z\" transform=\"rotate(-45 7.854 15.854)\"></path><path d=\"M2 22H7V24H2z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Sunrise24", "filepath": "sunrise/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": "M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 14.854H26.625999999999998V16.854H21.668z", "transform": "rotate(-45 24.146 15.854)" } }, { "elem": "path", "attrs": { "d": "M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z" } }, { "elem": "path", "attrs": { "d": "M6.854 13.374H8.854V18.332H6.854z", "transform": "rotate(-45 7.854 15.854)" } }, { "elem": "path", "attrs": { "d": "M2 22H7V24H2z" } }], "name": "sunrise", "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=\"M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z\"></path><path d=\"M21.668 14.854H26.625999999999998V16.854H21.668z\" transform=\"rotate(-45 24.146 15.854)\"></path><path d=\"M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z\"></path><path d=\"M6.854 13.374H8.854V18.332H6.854z\" transform=\"rotate(-45 7.854 15.854)\"></path><path d=\"M2 22H7V24H2z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Sunrise20", "filepath": "sunrise/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": "M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 14.854H26.625999999999998V16.854H21.668z", "transform": "rotate(-45 24.146 15.854)" } }, { "elem": "path", "attrs": { "d": "M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z" } }, { "elem": "path", "attrs": { "d": "M6.854 13.374H8.854V18.332H6.854z", "transform": "rotate(-45 7.854 15.854)" } }, { "elem": "path", "attrs": { "d": "M2 22H7V24H2z" } }], "name": "sunrise", "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=\"M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z\"></path><path d=\"M21.668 14.854H26.625999999999998V16.854H21.668z\" transform=\"rotate(-45 24.146 15.854)\"></path><path d=\"M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z\"></path><path d=\"M6.854 13.374H8.854V18.332H6.854z\" transform=\"rotate(-45 7.854 15.854)\"></path><path d=\"M2 22H7V24H2z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Sunrise16", "filepath": "sunrise/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": "M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 14.854H26.625999999999998V16.854H21.668z", "transform": "rotate(-45 24.146 15.854)" } }, { "elem": "path", "attrs": { "d": "M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z" } }, { "elem": "path", "attrs": { "d": "M6.854 13.374H8.854V18.332H6.854z", "transform": "rotate(-45 7.854 15.854)" } }, { "elem": "path", "attrs": { "d": "M2 22H7V24H2z" } }], "name": "sunrise", "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=\"M2 27H29.998V29H2zM16 20a4.0045 4.0045 0 014 4h2a6 6 0 00-12 0h2A4.0045 4.0045 0 0116 20zM25 22H30V24H25z\"></path><path d=\"M21.668 14.854H26.625999999999998V16.854H21.668z\" transform=\"rotate(-45 24.146 15.854)\"></path><path d=\"M16 4L11 9 12.41 10.41 15 7.83 15 8 15 15 17 15 17 8 17 7.83 19.59 10.41 21 9 16 4z\"></path><path d=\"M6.854 13.374H8.854V18.332H6.854z\" transform=\"rotate(-45 7.854 15.854)\"></path><path d=\"M2 22H7V24H2z\"></path></svg>"
},
};
}
SunriseDirective_1 = SunriseDirective;
SunriseDirective.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;
SunriseDirective_1.titleIdCounter++;
title.setAttribute("id", "sunrise-" + SunriseDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "sunrise-" + SunriseDirective_1.titleIdCounter);
}
};
var SunriseDirective_1;
SunriseDirective.titleIdCounter = 0;
SunriseDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], SunriseDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunriseDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], SunriseDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], SunriseDirective.prototype, "size", void 0);
SunriseDirective = SunriseDirective_1 = __decorate([
Directive({
selector: "[ibmIconSunrise]"
}),
__metadata("design:paramtypes", [ElementRef])
], SunriseDirective);
return SunriseDirective;
}());
var SunriseModule = /** @class */ (function () {
function SunriseModule() {
}
SunriseModule = __decorate([
NgModule({
declarations: [
SunriseComponent,
SunriseDirective,
],
exports: [
SunriseComponent,
SunriseDirective,
]
})
], SunriseModule);
return SunriseModule;
}());
export { SunriseComponent, SunriseDirective, SunriseModule };