@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
177 lines (172 loc) • 11.8 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('/core'), require('@carbon/icon-helpers')) :
typeof define === 'function' && define.amd ? define(['exports', 'tslib', '/core', '@carbon/icon-helpers'], factory) :
(global = global || self, factory((global.CarbonIconsAngular = global.CarbonIconsAngular || {}, global.CarbonIconsAngular.Van = {}), global.tslib, global.ng.core, global.CarbonIconHelpers));
}(this, (function (exports, tslib, core, iconHelpers) { 'use strict';
var VanComponent = /** @class */ (function () {
function VanComponent() {
this.focusable = false;
}
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanComponent.prototype, "ariaLabel", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanComponent.prototype, "ariaLabelledby", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], VanComponent.prototype, "ariaHidden", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanComponent.prototype, "title", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], VanComponent.prototype, "focusable", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanComponent.prototype, "innerClass", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanComponent.prototype, "size", void 0);
VanComponent = tslib.__decorate([
core.Component({
selector: "ibm-icon-van",
template: "\n <svg\n ibmIconVan\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 "
})
], VanComponent);
return VanComponent;
}());
var VanDirective = /** @class */ (function () {
function VanDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "Van32", "filepath": "van/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": "M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z" } }], "name": "van", "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=\"M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "Van24", "filepath": "van/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": "M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z" } }], "name": "van", "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=\"M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "Van20", "filepath": "van/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": "M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z" } }], "name": "van", "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=\"M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "Van16", "filepath": "van/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": "M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z" } }], "name": "van", "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=\"M29.81,16l-7-9.56A1,1,0,0,0,22,6H3A1,1,0,0,0,2,7V24a1,1,0,0,0,1,1H5.14a4,4,0,0,0,7.72,0h6.28a4,4,0,0,0,7.72,0H29a1,1,0,0,0,1-1V16.56A1,1,0,0,0,29.81,16ZM20,8h1.49l5.13,7H20ZM9,26a2,2,0,1,1,2-2A2,2,0,0,1,9,26Zm14,0a2,2,0,1,1,2-2A2,2,0,0,1,23,26Zm5-3H26.86a4,4,0,0,0-7.72,0H12.86a4,4,0,0,0-7.72,0H4V8H18v9H28Z\"></path></svg>"
},
};
}
VanDirective_1 = VanDirective;
VanDirective.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 = iconHelpers.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;
VanDirective_1.titleIdCounter++;
title.setAttribute("id", "van-" + VanDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "van-" + VanDirective_1.titleIdCounter);
}
};
var VanDirective_1;
VanDirective.titleIdCounter = 0;
VanDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanDirective.prototype, "ariaLabel", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanDirective.prototype, "ariaLabelledby", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], VanDirective.prototype, "ariaHidden", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanDirective.prototype, "title", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", Boolean)
], VanDirective.prototype, "isFocusable", void 0);
tslib.__decorate([
core.Input(),
tslib.__metadata("design:type", String)
], VanDirective.prototype, "size", void 0);
VanDirective = VanDirective_1 = tslib.__decorate([
core.Directive({
selector: "[ibmIconVan]"
}),
tslib.__metadata("design:paramtypes", [core.ElementRef])
], VanDirective);
return VanDirective;
}());
var VanModule = /** @class */ (function () {
function VanModule() {
}
VanModule = tslib.__decorate([
core.NgModule({
declarations: [
VanComponent,
VanDirective,
],
exports: [
VanComponent,
VanDirective,
]
})
], VanModule);
return VanModule;
}());
exports.VanComponent = VanComponent;
exports.VanDirective = VanDirective;
exports.VanModule = VanModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));