@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 AwakeComponent = /** @class */ (function () {
function AwakeComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], AwakeComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], AwakeComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], AwakeComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeComponent.prototype, "size", void 0);
AwakeComponent = __decorate([
Component({
selector: "ibm-icon-awake",
template: "\n <svg\n ibmIconAwake\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 "
})
], AwakeComponent);
return AwakeComponent;
}());
var AwakeDirective = /** @class */ (function () {
function AwakeDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Awake32", "filepath": "awake/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": "M15 2H17V6.96H15z" } }, { "elem": "path", "attrs": { "d": "M21.67 6.85H26.630000000000003V8.85H21.67z", "transform": "rotate(-45 24.142 7.85)" } }, { "elem": "path", "attrs": { "d": "M25.04 15H30V17H25.04z" } }, { "elem": "path", "attrs": { "d": "M23.15 21.67H25.15V26.630000000000003H23.15z", "transform": "rotate(-45 24.152 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25.04H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.37 23.15H10.33V25.15H5.37z", "transform": "rotate(-45 7.86 24.144)" } }, { "elem": "path", "attrs": { "d": "M2 15H6.96V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.85 5.37H8.85V10.33H6.85z", "transform": "rotate(-45 7.85 7.848)" } }, { "elem": "path", "attrs": { "d": "M16,12a4,4,0,1,1-4,4,4,4,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "awake", "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=\"M15 2H17V6.96H15z\"></path><path d=\"M21.67 6.85H26.630000000000003V8.85H21.67z\" transform=\"rotate(-45 24.142 7.85)\"></path><path d=\"M25.04 15H30V17H25.04z\"></path><path d=\"M23.15 21.67H25.15V26.630000000000003H23.15z\" transform=\"rotate(-45 24.152 24.146)\"></path><path d=\"M15 25.04H17V30H15z\"></path><path d=\"M5.37 23.15H10.33V25.15H5.37z\" transform=\"rotate(-45 7.86 24.144)\"></path><path d=\"M2 15H6.96V17H2z\"></path><path d=\"M6.85 5.37H8.85V10.33H6.85z\" transform=\"rotate(-45 7.85 7.848)\"></path><path d=\"M16,12a4,4,0,1,1-4,4,4,4,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Awake24", "filepath": "awake/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": "M15 2H17V6.96H15z" } }, { "elem": "path", "attrs": { "d": "M21.67 6.85H26.630000000000003V8.85H21.67z", "transform": "rotate(-45 24.142 7.85)" } }, { "elem": "path", "attrs": { "d": "M25.04 15H30V17H25.04z" } }, { "elem": "path", "attrs": { "d": "M23.15 21.67H25.15V26.630000000000003H23.15z", "transform": "rotate(-45 24.152 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25.04H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.37 23.15H10.33V25.15H5.37z", "transform": "rotate(-45 7.86 24.144)" } }, { "elem": "path", "attrs": { "d": "M2 15H6.96V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.85 5.37H8.85V10.33H6.85z", "transform": "rotate(-45 7.85 7.848)" } }, { "elem": "path", "attrs": { "d": "M16,12a4,4,0,1,1-4,4,4,4,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "awake", "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=\"M15 2H17V6.96H15z\"></path><path d=\"M21.67 6.85H26.630000000000003V8.85H21.67z\" transform=\"rotate(-45 24.142 7.85)\"></path><path d=\"M25.04 15H30V17H25.04z\"></path><path d=\"M23.15 21.67H25.15V26.630000000000003H23.15z\" transform=\"rotate(-45 24.152 24.146)\"></path><path d=\"M15 25.04H17V30H15z\"></path><path d=\"M5.37 23.15H10.33V25.15H5.37z\" transform=\"rotate(-45 7.86 24.144)\"></path><path d=\"M2 15H6.96V17H2z\"></path><path d=\"M6.85 5.37H8.85V10.33H6.85z\" transform=\"rotate(-45 7.85 7.848)\"></path><path d=\"M16,12a4,4,0,1,1-4,4,4,4,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Awake20", "filepath": "awake/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": "M15 2H17V6.96H15z" } }, { "elem": "path", "attrs": { "d": "M21.67 6.85H26.630000000000003V8.85H21.67z", "transform": "rotate(-45 24.142 7.85)" } }, { "elem": "path", "attrs": { "d": "M25.04 15H30V17H25.04z" } }, { "elem": "path", "attrs": { "d": "M23.15 21.67H25.15V26.630000000000003H23.15z", "transform": "rotate(-45 24.152 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25.04H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.37 23.15H10.33V25.15H5.37z", "transform": "rotate(-45 7.86 24.144)" } }, { "elem": "path", "attrs": { "d": "M2 15H6.96V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.85 5.37H8.85V10.33H6.85z", "transform": "rotate(-45 7.85 7.848)" } }, { "elem": "path", "attrs": { "d": "M16,12a4,4,0,1,1-4,4,4,4,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "awake", "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=\"M15 2H17V6.96H15z\"></path><path d=\"M21.67 6.85H26.630000000000003V8.85H21.67z\" transform=\"rotate(-45 24.142 7.85)\"></path><path d=\"M25.04 15H30V17H25.04z\"></path><path d=\"M23.15 21.67H25.15V26.630000000000003H23.15z\" transform=\"rotate(-45 24.152 24.146)\"></path><path d=\"M15 25.04H17V30H15z\"></path><path d=\"M5.37 23.15H10.33V25.15H5.37z\" transform=\"rotate(-45 7.86 24.144)\"></path><path d=\"M2 15H6.96V17H2z\"></path><path d=\"M6.85 5.37H8.85V10.33H6.85z\" transform=\"rotate(-45 7.85 7.848)\"></path><path d=\"M16,12a4,4,0,1,1-4,4,4,4,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Awake16", "filepath": "awake/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 16 16", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M7.5 1H8.5V3.5H7.5z" } }, { "elem": "path", "attrs": { "d": "M10.8 3.4H13.3V4.4H10.8z", "transform": "rotate(-45.001 12.074 3.922)" } }, { "elem": "path", "attrs": { "d": "M12.5 7.5H15V8.5H12.5z" } }, { "elem": "path", "attrs": { "d": "M11.6 10.8H12.6V13.3H11.6z", "transform": "rotate(-45.001 12.077 12.075)" } }, { "elem": "path", "attrs": { "d": "M7.5 12.5H8.5V15H7.5z" } }, { "elem": "path", "attrs": { "d": "M2.7 11.6H5.2V12.6H2.7z", "transform": "rotate(-45.001 3.929 12.078)" } }, { "elem": "path", "attrs": { "d": "M1 7.5H3.5V8.5H1z" } }, { "elem": "path", "attrs": { "d": "M3.4 2.7H4.4V5.2H3.4z", "transform": "rotate(-45.001 3.926 3.925)" } }, { "elem": "path", "attrs": { "d": "M8,6c1.1,0,2,0.9,2,2s-0.9,2-2,2S6,9.1,6,8S6.9,6,8,6 M8,5C6.3,5,5,6.3,5,8s1.3,3,3,3s3-1.3,3-3S9.7,5,8,5z" } }], "name": "awake", "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 16 16\" aria-hidden=\"true\"><path d=\"M7.5 1H8.5V3.5H7.5z\"></path><path d=\"M10.8 3.4H13.3V4.4H10.8z\" transform=\"rotate(-45.001 12.074 3.922)\"></path><path d=\"M12.5 7.5H15V8.5H12.5z\"></path><path d=\"M11.6 10.8H12.6V13.3H11.6z\" transform=\"rotate(-45.001 12.077 12.075)\"></path><path d=\"M7.5 12.5H8.5V15H7.5z\"></path><path d=\"M2.7 11.6H5.2V12.6H2.7z\" transform=\"rotate(-45.001 3.929 12.078)\"></path><path d=\"M1 7.5H3.5V8.5H1z\"></path><path d=\"M3.4 2.7H4.4V5.2H3.4z\" transform=\"rotate(-45.001 3.926 3.925)\"></path><path d=\"M8,6c1.1,0,2,0.9,2,2s-0.9,2-2,2S6,9.1,6,8S6.9,6,8,6 M8,5C6.3,5,5,6.3,5,8s1.3,3,3,3s3-1.3,3-3S9.7,5,8,5z\"></path></svg>"
},
};
}
AwakeDirective_1 = AwakeDirective;
AwakeDirective.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;
AwakeDirective_1.titleIdCounter++;
title.setAttribute("id", "awake-" + AwakeDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "awake-" + AwakeDirective_1.titleIdCounter);
}
};
var AwakeDirective_1;
AwakeDirective.titleIdCounter = 0;
AwakeDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], AwakeDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], AwakeDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], AwakeDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], AwakeDirective.prototype, "size", void 0);
AwakeDirective = AwakeDirective_1 = __decorate([
Directive({
selector: "[ibmIconAwake]"
}),
__metadata("design:paramtypes", [ElementRef])
], AwakeDirective);
return AwakeDirective;
}());
var AwakeModule = /** @class */ (function () {
function AwakeModule() {
}
AwakeModule = __decorate([
NgModule({
declarations: [
AwakeComponent,
AwakeDirective,
],
exports: [
AwakeComponent,
AwakeDirective,
]
})
], AwakeModule);
return AwakeModule;
}());
export { AwakeComponent, AwakeDirective, AwakeModule };