UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 10.1 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ChartHighLowComponent = /** @class */ (function () { function ChartHighLowComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartHighLowComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartHighLowComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowComponent.prototype, "size", void 0); ChartHighLowComponent = __decorate([ Component({ selector: "ibm-icon-chart-high-low", template: "\n <svg\n ibmIconChartHighLow\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 " }) ], ChartHighLowComponent); return ChartHighLowComponent; }()); var ChartHighLowDirective = /** @class */ (function () { function ChartHighLowDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ChartHighLow32", "filepath": "chart--high-low/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": "M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z" } }, { "elem": "path", "attrs": { "d": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }], "name": "chart--high-low", "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=\"M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z\"></path><path d=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path></svg>" }, "24": { metadata: { "moduleName": "ChartHighLow24", "filepath": "chart--high-low/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": "M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z" } }, { "elem": "path", "attrs": { "d": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }], "name": "chart--high-low", "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=\"M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z\"></path><path d=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path></svg>" }, "20": { metadata: { "moduleName": "ChartHighLow20", "filepath": "chart--high-low/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": "M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z" } }, { "elem": "path", "attrs": { "d": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }], "name": "chart--high-low", "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=\"M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z\"></path><path d=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path></svg>" }, "16": { metadata: { "moduleName": "ChartHighLow16", "filepath": "chart--high-low/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": "M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z" } }, { "elem": "path", "attrs": { "d": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }], "name": "chart--high-low", "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=\"M15 8L12 8 12 6 10 6 10 20 7 20 7 22 10 22 10 24 12 24 12 10 15 10 15 8zM27 10L24 10 24 6 22 6 22 18 19 18 19 20 22 20 22 24 24 24 24 12 27 12 27 10z\"></path><path d=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path></svg>" }, }; } ChartHighLowDirective_1 = ChartHighLowDirective; ChartHighLowDirective.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; ChartHighLowDirective_1.titleIdCounter++; title.setAttribute("id", "chart-high-low-" + ChartHighLowDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "chart-high-low-" + ChartHighLowDirective_1.titleIdCounter); } }; var ChartHighLowDirective_1; ChartHighLowDirective.titleIdCounter = 0; ChartHighLowDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartHighLowDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartHighLowDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartHighLowDirective.prototype, "size", void 0); ChartHighLowDirective = ChartHighLowDirective_1 = __decorate([ Directive({ selector: "[ibmIconChartHighLow]" }), __metadata("design:paramtypes", [ElementRef]) ], ChartHighLowDirective); return ChartHighLowDirective; }()); var ChartHighLowModule = /** @class */ (function () { function ChartHighLowModule() { } ChartHighLowModule = __decorate([ NgModule({ declarations: [ ChartHighLowComponent, ChartHighLowDirective, ], exports: [ ChartHighLowComponent, ChartHighLowDirective, ] }) ], ChartHighLowModule); return ChartHighLowModule; }()); export { ChartHighLowComponent, ChartHighLowDirective, ChartHighLowModule };