UNPKG

@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
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var CyclistComponent = /** @class */ (function () { function CyclistComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], CyclistComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CyclistComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CyclistComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistComponent.prototype, "size", void 0); CyclistComponent = __decorate([ Component({ selector: "ibm-icon-cyclist", template: "\n <svg\n ibmIconCyclist\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 " }) ], CyclistComponent); return CyclistComponent; }()); var CyclistDirective = /** @class */ (function () { function CyclistDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Cyclist32", "filepath": "cyclist/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": "M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z" } }, { "elem": "path", "attrs": { "d": "M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z" } }], "name": "cyclist", "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=\"M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z\"></path><path d=\"M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z\"></path></svg>" }, "24": { metadata: { "moduleName": "Cyclist24", "filepath": "cyclist/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": "M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z" } }, { "elem": "path", "attrs": { "d": "M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z" } }], "name": "cyclist", "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=\"M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z\"></path><path d=\"M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z\"></path></svg>" }, "20": { metadata: { "moduleName": "Cyclist20", "filepath": "cyclist/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": "M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z" } }, { "elem": "path", "attrs": { "d": "M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z" } }], "name": "cyclist", "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=\"M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z\"></path><path d=\"M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z\"></path></svg>" }, "16": { metadata: { "moduleName": "Cyclist16", "filepath": "cyclist/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": "M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z" } }, { "elem": "path", "attrs": { "d": "M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z" } }], "name": "cyclist", "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=\"M25 30a6 6 0 116-6A6.0069 6.0069 0 0125 30zm0-10a4 4 0 104 4A4.0045 4.0045 0 0025 20zM7 30a6 6 0 116-6A6.0069 6.0069 0 017 30zM7 20a4 4 0 104 4A4.0045 4.0045 0 007 20z\"></path><path d=\"M17 27H15V20.4139L9.5849 15a2.003 2.003 0 010-2.8292l4.5859-4.5859a2.0024 2.0024 0 012.8286 0L21.414 12H27v1.9993L20.5853 14l-5-5L11 13.5849l6 6zM21.5 8A3.5 3.5 0 1125 4.5 3.5042 3.5042 0 0121.5 8zm0-5A1.5 1.5 0 1023 4.5 1.5017 1.5017 0 0021.5 3z\"></path></svg>" }, }; } CyclistDirective_1 = CyclistDirective; CyclistDirective.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; CyclistDirective_1.titleIdCounter++; title.setAttribute("id", "cyclist-" + CyclistDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "cyclist-" + CyclistDirective_1.titleIdCounter); } }; var CyclistDirective_1; CyclistDirective.titleIdCounter = 0; CyclistDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], CyclistDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CyclistDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CyclistDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CyclistDirective.prototype, "size", void 0); CyclistDirective = CyclistDirective_1 = __decorate([ Directive({ selector: "[ibmIconCyclist]" }), __metadata("design:paramtypes", [ElementRef]) ], CyclistDirective); return CyclistDirective; }()); var CyclistModule = /** @class */ (function () { function CyclistModule() { } CyclistModule = __decorate([ NgModule({ declarations: [ CyclistComponent, CyclistDirective, ], exports: [ CyclistComponent, CyclistDirective, ] }) ], CyclistModule); return CyclistModule; }()); export { CyclistComponent, CyclistDirective, CyclistModule };