UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 12.8 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ChartCustomComponent = /** @class */ (function () { function ChartCustomComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], ChartCustomComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartCustomComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartCustomComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomComponent.prototype, "size", void 0); ChartCustomComponent = __decorate([ Component({ selector: "ibm-icon-chart-custom", template: "\n <svg\n ibmIconChartCustom\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 " }) ], ChartCustomComponent); return ChartCustomComponent; }()); var ChartCustomDirective = /** @class */ (function () { function ChartCustomDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ChartCustom32", "filepath": "chart--custom/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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z" } }, { "elem": "path", "attrs": { "d": "M17 15H21V17H17z", "transform": "rotate(-90 19 16)" } }, { "elem": "path", "attrs": { "d": "M12 14H18V16H12z", "transform": "rotate(-90 15 15)" } }, { "elem": "path", "attrs": { "d": "M6 12H16V14H6z", "transform": "rotate(-90 11 13)" } }, { "elem": "path", "attrs": { "d": "M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z" } }], "name": "chart--custom", "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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z\"></path><path d=\"M17 15H21V17H17z\" transform=\"rotate(-90 19 16)\"></path><path d=\"M12 14H18V16H12z\" transform=\"rotate(-90 15 15)\"></path><path d=\"M6 12H16V14H6z\" transform=\"rotate(-90 11 13)\"></path><path d=\"M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z\"></path></svg>" }, "24": { metadata: { "moduleName": "ChartCustom24", "filepath": "chart--custom/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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z" } }, { "elem": "path", "attrs": { "d": "M17 15H21V17H17z", "transform": "rotate(-90 19 16)" } }, { "elem": "path", "attrs": { "d": "M12 14H18V16H12z", "transform": "rotate(-90 15 15)" } }, { "elem": "path", "attrs": { "d": "M6 12H16V14H6z", "transform": "rotate(-90 11 13)" } }, { "elem": "path", "attrs": { "d": "M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z" } }], "name": "chart--custom", "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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z\"></path><path d=\"M17 15H21V17H17z\" transform=\"rotate(-90 19 16)\"></path><path d=\"M12 14H18V16H12z\" transform=\"rotate(-90 15 15)\"></path><path d=\"M6 12H16V14H6z\" transform=\"rotate(-90 11 13)\"></path><path d=\"M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z\"></path></svg>" }, "20": { metadata: { "moduleName": "ChartCustom20", "filepath": "chart--custom/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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z" } }, { "elem": "path", "attrs": { "d": "M17 15H21V17H17z", "transform": "rotate(-90 19 16)" } }, { "elem": "path", "attrs": { "d": "M12 14H18V16H12z", "transform": "rotate(-90 15 15)" } }, { "elem": "path", "attrs": { "d": "M6 12H16V14H6z", "transform": "rotate(-90 11 13)" } }, { "elem": "path", "attrs": { "d": "M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z" } }], "name": "chart--custom", "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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z\"></path><path d=\"M17 15H21V17H17z\" transform=\"rotate(-90 19 16)\"></path><path d=\"M12 14H18V16H12z\" transform=\"rotate(-90 15 15)\"></path><path d=\"M6 12H16V14H6z\" transform=\"rotate(-90 11 13)\"></path><path d=\"M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z\"></path></svg>" }, "16": { metadata: { "moduleName": "ChartCustom16", "filepath": "chart--custom/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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z" } }, { "elem": "path", "attrs": { "d": "M17 15H21V17H17z", "transform": "rotate(-90 19 16)" } }, { "elem": "path", "attrs": { "d": "M12 14H18V16H12z", "transform": "rotate(-90 15 15)" } }, { "elem": "path", "attrs": { "d": "M6 12H16V14H6z", "transform": "rotate(-90 11 13)" } }, { "elem": "path", "attrs": { "d": "M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z" } }], "name": "chart--custom", "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.707,19.293l-3-3a.9994.9994,0,0,0-1.414,0L16,25.5859V30h4.4141l9.2929-9.293A.9994.9994,0,0,0,29.707,19.293ZM19.5859,28H18V26.4141l5-5L24.5859,23ZM26,21.5859,24.4141,20,26,18.4141,27.5859,20Z\"></path><path d=\"M17 15H21V17H17z\" transform=\"rotate(-90 19 16)\"></path><path d=\"M12 14H18V16H12z\" transform=\"rotate(-90 15 15)\"></path><path d=\"M6 12H16V14H6z\" transform=\"rotate(-90 11 13)\"></path><path d=\"M12,30H6a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,6,2H22a2.0021,2.0021,0,0,1,2,2V14H22V4H6V28h6Z\"></path></svg>" }, }; } ChartCustomDirective_1 = ChartCustomDirective; ChartCustomDirective.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; ChartCustomDirective_1.titleIdCounter++; title.setAttribute("id", "chart-custom-" + ChartCustomDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "chart-custom-" + ChartCustomDirective_1.titleIdCounter); } }; var ChartCustomDirective_1; ChartCustomDirective.titleIdCounter = 0; ChartCustomDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], ChartCustomDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartCustomDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartCustomDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartCustomDirective.prototype, "size", void 0); ChartCustomDirective = ChartCustomDirective_1 = __decorate([ Directive({ selector: "[ibmIconChartCustom]" }), __metadata("design:paramtypes", [ElementRef]) ], ChartCustomDirective); return ChartCustomDirective; }()); var ChartCustomModule = /** @class */ (function () { function ChartCustomModule() { } ChartCustomModule = __decorate([ NgModule({ declarations: [ ChartCustomComponent, ChartCustomDirective, ], exports: [ ChartCustomComponent, ChartCustomDirective, ] }) ], ChartCustomModule); return ChartCustomModule; }()); export { ChartCustomComponent, ChartCustomDirective, ChartCustomModule };