UNPKG

@carbon/icons-angular

Version:

Angular components for icons in digital and software products using the Carbon Design System

169 lines (166 loc) 10.5 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var BusComponent = /** @class */ (function () { function BusComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], BusComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BusComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BusComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusComponent.prototype, "size", void 0); BusComponent = __decorate([ Component({ selector: "ibm-icon-bus", template: "\n <svg\n ibmIconBus\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 " }) ], BusComponent); return BusComponent; }()); var BusDirective = /** @class */ (function () { function BusDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Bus32", "filepath": "bus/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": "M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z" } }, { "elem": "path", "attrs": { "d": "M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z" } }], "name": "bus", "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=\"M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z\"></path><path d=\"M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z\"></path></svg>" }, "24": { metadata: { "moduleName": "Bus24", "filepath": "bus/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": "M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z" } }, { "elem": "path", "attrs": { "d": "M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z" } }], "name": "bus", "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=\"M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z\"></path><path d=\"M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z\"></path></svg>" }, "20": { metadata: { "moduleName": "Bus20", "filepath": "bus/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": "M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z" } }, { "elem": "path", "attrs": { "d": "M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z" } }], "name": "bus", "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=\"M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z\"></path><path d=\"M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z\"></path></svg>" }, "16": { metadata: { "moduleName": "Bus16", "filepath": "bus/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": "M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z" } }, { "elem": "path", "attrs": { "d": "M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z" } }], "name": "bus", "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=\"M27 11H29V15H27zM3 11H5V15H3zM20 20H22V22H20zM10 20H12V22H10z\"></path><path d=\"M21,4H11A5.0059,5.0059,0,0,0,6,9V23a2.0023,2.0023,0,0,0,2,2v3h2V25H22v3h2V25a2.0027,2.0027,0,0,0,2-2V9A5.0059,5.0059,0,0,0,21,4Zm3,6,.0009,6H8V10ZM11,6H21a2.995,2.995,0,0,1,2.8157,2H8.1843A2.995,2.995,0,0,1,11,6ZM8,23V18H24.0012l.0008,5Z\"></path></svg>" }, }; } BusDirective_1 = BusDirective; BusDirective.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; BusDirective_1.titleIdCounter++; title.setAttribute("id", "bus-" + BusDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "bus-" + BusDirective_1.titleIdCounter); } }; var BusDirective_1; BusDirective.titleIdCounter = 0; BusDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], BusDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BusDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], BusDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], BusDirective.prototype, "size", void 0); BusDirective = BusDirective_1 = __decorate([ Directive({ selector: "[ibmIconBus]" }), __metadata("design:paramtypes", [ElementRef]) ], BusDirective); return BusDirective; }()); var BusModule = /** @class */ (function () { function BusModule() { } BusModule = __decorate([ NgModule({ declarations: [ BusComponent, BusDirective, ], exports: [ BusComponent, BusDirective, ] }) ], BusModule); return BusModule; }()); export { BusComponent, BusDirective, BusModule };