@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 11.5 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var InteractionsComponent = /** @class */ (function () {
function InteractionsComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], InteractionsComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], InteractionsComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsComponent.prototype, "size", void 0);
InteractionsComponent = __decorate([
Component({
selector: "ibm-icon-interactions",
template: "\n <svg\n ibmIconInteractions\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 "
})
], InteractionsComponent);
return InteractionsComponent;
}());
var InteractionsDirective = /** @class */ (function () {
function InteractionsDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Interactions32", "filepath": "interactions/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": "M26 18H22V14H20V28h6a2.0027 2.0027 0 002-2V20A2.0023 2.0023 0 0026 18zm-4 8V20h4v6zM20 6.076L19.256 4.219 16 5.522 16 2 14 2 14 5.523 10.744 4.22 10 6.077 13.417 7.444 10.9 10.8 12.5 12 15 8.667 17.5 12 19.1 10.8 16.583 7.443 20 6.076zM10 18H5v2h5v2H6a2 2 0 00-2 2v2a2 2 0 002 2h6V20A2.0023 2.0023 0 0010 18zm0 8H6V24h4z" } }], "name": "interactions", "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=\"M26 18H22V14H20V28h6a2.0027 2.0027 0 002-2V20A2.0023 2.0023 0 0026 18zm-4 8V20h4v6zM20 6.076L19.256 4.219 16 5.522 16 2 14 2 14 5.523 10.744 4.22 10 6.077 13.417 7.444 10.9 10.8 12.5 12 15 8.667 17.5 12 19.1 10.8 16.583 7.443 20 6.076zM10 18H5v2h5v2H6a2 2 0 00-2 2v2a2 2 0 002 2h6V20A2.0023 2.0023 0 0010 18zm0 8H6V24h4z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Interactions24", "filepath": "interactions/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": "M26 18H22V14H20V28h6a2.0027 2.0027 0 002-2V20A2.0023 2.0023 0 0026 18zm-4 8V20h4v6zM20 6.076L19.256 4.219 16 5.522 16 2 14 2 14 5.523 10.744 4.22 10 6.077 13.417 7.444 10.9 10.8 12.5 12 15 8.667 17.5 12 19.1 10.8 16.583 7.443 20 6.076zM10 18H5v2h5v2H6a2 2 0 00-2 2v2a2 2 0 002 2h6V20A2.0023 2.0023 0 0010 18zm0 8H6V24h4z" } }], "name": "interactions", "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=\"M26 18H22V14H20V28h6a2.0027 2.0027 0 002-2V20A2.0023 2.0023 0 0026 18zm-4 8V20h4v6zM20 6.076L19.256 4.219 16 5.522 16 2 14 2 14 5.523 10.744 4.22 10 6.077 13.417 7.444 10.9 10.8 12.5 12 15 8.667 17.5 12 19.1 10.8 16.583 7.443 20 6.076zM10 18H5v2h5v2H6a2 2 0 00-2 2v2a2 2 0 002 2h6V20A2.0023 2.0023 0 0010 18zm0 8H6V24h4z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Interactions20", "filepath": "interactions/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": "M26 18H22V14H20V28h6a2.0027 2.0027 0 002-2V20A2.0023 2.0023 0 0026 18zm-4 8V20h4v6zM20 6.076L19.256 4.219 16 5.522 16 2 14 2 14 5.523 10.744 4.22 10 6.077 13.417 7.444 10.9 10.8 12.5 12 15 8.667 17.5 12 19.1 10.8 16.583 7.443 20 6.076zM10 18H5v2h5v2H6a2 2 0 00-2 2v2a2 2 0 002 2h6V20A2.0023 2.0023 0 0010 18zm0 8H6V24h4z" } }], "name": "interactions", "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=\"M26 18H22V14H20V28h6a2.0027 2.0027 0 002-2V20A2.0023 2.0023 0 0026 18zm-4 8V20h4v6zM20 6.076L19.256 4.219 16 5.522 16 2 14 2 14 5.523 10.744 4.22 10 6.077 13.417 7.444 10.9 10.8 12.5 12 15 8.667 17.5 12 19.1 10.8 16.583 7.443 20 6.076zM10 18H5v2h5v2H6a2 2 0 00-2 2v2a2 2 0 002 2h6V20A2.0023 2.0023 0 0010 18zm0 8H6V24h4z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Interactions16", "filepath": "interactions/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": { "fill-rule": "evenodd", "d": "M11,7 L11,9 L13,9 C13.5522847,9 14,9.44771525 14,10 L14,10 L14,13 C14,13.5522847 13.5522847,14 13,14 L13,14 L10,14 L10,7 L11,7 Z M5,9 C5.55228475,9 6,9.44771525 6,10 L6,10 L6,14 L3,14 C2.44771525,14 2,13.5522847 2,13 L2,13 L2,12 C2,11.4477153 2.44771525,11 3,11 L3,11 L5,11 L5,10 L2.5,10 L2.5,9 Z M13,10 L11,10 L11,13 L13,13 L13,10 Z M5,12 L3,12 L3,13 L5,13 L5,12 Z M7.912,2 L7.834,3.911 L9.628,3.248 L9.914,4.119 L8.068,4.626 L9.251,6.134 L8.523,6.667 L7.457,5.068 L6.391,6.667 L5.663,6.134 L6.846,4.626 L5,4.119 L5.286,3.248 L7.08,3.911 L7.002,2 L7.912,2 Z" } }], "name": "interactions", "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 fill-rule=\"evenodd\" d=\"M11,7 L11,9 L13,9 C13.5522847,9 14,9.44771525 14,10 L14,10 L14,13 C14,13.5522847 13.5522847,14 13,14 L13,14 L10,14 L10,7 L11,7 Z M5,9 C5.55228475,9 6,9.44771525 6,10 L6,10 L6,14 L3,14 C2.44771525,14 2,13.5522847 2,13 L2,13 L2,12 C2,11.4477153 2.44771525,11 3,11 L3,11 L5,11 L5,10 L2.5,10 L2.5,9 Z M13,10 L11,10 L11,13 L13,13 L13,10 Z M5,12 L3,12 L3,13 L5,13 L5,12 Z M7.912,2 L7.834,3.911 L9.628,3.248 L9.914,4.119 L8.068,4.626 L9.251,6.134 L8.523,6.667 L7.457,5.068 L6.391,6.667 L5.663,6.134 L6.846,4.626 L5,4.119 L5.286,3.248 L7.08,3.911 L7.002,2 L7.912,2 Z\"></path></svg>"
},
};
}
InteractionsDirective_1 = InteractionsDirective;
InteractionsDirective.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;
InteractionsDirective_1.titleIdCounter++;
title.setAttribute("id", "interactions-" + InteractionsDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "interactions-" + InteractionsDirective_1.titleIdCounter);
}
};
var InteractionsDirective_1;
InteractionsDirective.titleIdCounter = 0;
InteractionsDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], InteractionsDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], InteractionsDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], InteractionsDirective.prototype, "size", void 0);
InteractionsDirective = InteractionsDirective_1 = __decorate([
Directive({
selector: "[ibmIconInteractions]"
}),
__metadata("design:paramtypes", [ElementRef])
], InteractionsDirective);
return InteractionsDirective;
}());
var InteractionsModule = /** @class */ (function () {
function InteractionsModule() {
}
InteractionsModule = __decorate([
NgModule({
declarations: [
InteractionsComponent,
InteractionsDirective,
],
exports: [
InteractionsComponent,
InteractionsDirective,
]
})
], InteractionsModule);
return InteractionsModule;
}());
export { InteractionsComponent, InteractionsDirective, InteractionsModule };