@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 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 PicnicAreaComponent = /** @class */ (function () {
function PicnicAreaComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PicnicAreaComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PicnicAreaComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaComponent.prototype, "size", void 0);
PicnicAreaComponent = __decorate([
Component({
selector: "ibm-icon-picnic-area",
template: "\n <svg\n ibmIconPicnicArea\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 "
})
], PicnicAreaComponent);
return PicnicAreaComponent;
}());
var PicnicAreaDirective = /** @class */ (function () {
function PicnicAreaDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "PicnicArea32", "filepath": "picnic-area/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": "M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z" } }], "name": "picnic-area", "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=\"M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "PicnicArea24", "filepath": "picnic-area/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": "M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z" } }], "name": "picnic-area", "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=\"M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "PicnicArea20", "filepath": "picnic-area/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": "M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z" } }], "name": "picnic-area", "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=\"M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "PicnicArea16", "filepath": "picnic-area/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": "M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z" } }], "name": "picnic-area", "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=\"M24 12a4 4 0 114-4A4.0045 4.0045 0 0124 12zm0-6a2 2 0 102 2A2.0021 2.0021 0 0024 6zM26 22H21.8472L21.18 18H24V16H8v2h2.82l-.6668 4H6v2H9.82l-.6668 4H11.18l.6668-4h8.3056l.6668 4h2.0276L22.18 24H26zM12.18 22l.6665-4h6.3062l.6665 4z\"></path></svg>"
},
};
}
PicnicAreaDirective_1 = PicnicAreaDirective;
PicnicAreaDirective.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;
PicnicAreaDirective_1.titleIdCounter++;
title.setAttribute("id", "picnic-area-" + PicnicAreaDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "picnic-area-" + PicnicAreaDirective_1.titleIdCounter);
}
};
var PicnicAreaDirective_1;
PicnicAreaDirective.titleIdCounter = 0;
PicnicAreaDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PicnicAreaDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], PicnicAreaDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], PicnicAreaDirective.prototype, "size", void 0);
PicnicAreaDirective = PicnicAreaDirective_1 = __decorate([
Directive({
selector: "[ibmIconPicnicArea]"
}),
__metadata("design:paramtypes", [ElementRef])
], PicnicAreaDirective);
return PicnicAreaDirective;
}());
var PicnicAreaModule = /** @class */ (function () {
function PicnicAreaModule() {
}
PicnicAreaModule = __decorate([
NgModule({
declarations: [
PicnicAreaComponent,
PicnicAreaDirective,
],
exports: [
PicnicAreaComponent,
PicnicAreaDirective,
]
})
], PicnicAreaModule);
return PicnicAreaModule;
}());
export { PicnicAreaComponent, PicnicAreaDirective, PicnicAreaModule };