@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 11.6 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var ScooterComponent = /** @class */ (function () {
function ScooterComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], ScooterComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ScooterComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ScooterComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterComponent.prototype, "size", void 0);
ScooterComponent = __decorate([
Component({
selector: "ibm-icon-scooter",
template: "\n <svg\n ibmIconScooter\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 "
})
], ScooterComponent);
return ScooterComponent;
}());
var ScooterDirective = /** @class */ (function () {
function ScooterDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Scooter32", "filepath": "scooter/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 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z" } }], "name": "scooter", "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 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Scooter24", "filepath": "scooter/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 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z" } }], "name": "scooter", "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 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Scooter20", "filepath": "scooter/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 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z" } }], "name": "scooter", "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 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Scooter16", "filepath": "scooter/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": "M26 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z" } }], "name": "scooter", "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=\"M26 28a4 4 0 114-4A4.0045 4.0045 0 0126 28zm0-6a2 2 0 102 2A2.0023 2.0023 0 0026 22zM24 8H18v2h6a1 1 0 010 2H21a1 1 0 00-.98 1.1963l.9241 4.6211L18.4338 22h-2.69l-2.5723-8.5752A1.988 1.988 0 0011.2559 12H6v2h5.2561l.6 2H7a5.0057 5.0057 0 00-5 5v2a1 1 0 001 1H4a4 4 0 008 0h7a1 1 0 00.8574-.4854l3-5a1 1 0 00.1231-.7109L22.22 14H24a3 3 0 000-6zM8 26a2.0025 2.0025 0 01-2-2h4A2.0025 2.0025 0 018 26zM4 22V21a3.0033 3.0033 0 013-3h5.4561l1.2 4z\"></path></svg>"
},
};
}
ScooterDirective_1 = ScooterDirective;
ScooterDirective.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;
ScooterDirective_1.titleIdCounter++;
title.setAttribute("id", "scooter-" + ScooterDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "scooter-" + ScooterDirective_1.titleIdCounter);
}
};
var ScooterDirective_1;
ScooterDirective.titleIdCounter = 0;
ScooterDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], ScooterDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ScooterDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], ScooterDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ScooterDirective.prototype, "size", void 0);
ScooterDirective = ScooterDirective_1 = __decorate([
Directive({
selector: "[ibmIconScooter]"
}),
__metadata("design:paramtypes", [ElementRef])
], ScooterDirective);
return ScooterDirective;
}());
var ScooterModule = /** @class */ (function () {
function ScooterModule() {
}
ScooterModule = __decorate([
NgModule({
declarations: [
ScooterComponent,
ScooterDirective,
],
exports: [
ScooterComponent,
ScooterDirective,
]
})
], ScooterModule);
return ScooterModule;
}());
export { ScooterComponent, ScooterDirective, ScooterModule };