UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 10.9 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ChartClusterBarComponent = /** @class */ (function () { function ChartClusterBarComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartClusterBarComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartClusterBarComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarComponent.prototype, "size", void 0); ChartClusterBarComponent = __decorate([ Component({ selector: "ibm-icon-chart-cluster-bar", template: "\n <svg\n ibmIconChartClusterBar\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 " }) ], ChartClusterBarComponent); return ChartClusterBarComponent; }()); var ChartClusterBarDirective = /** @class */ (function () { function ChartClusterBarDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ChartClusterBar32", "filepath": "chart--cluster-bar/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": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "path", "attrs": { "d": "M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z" } }, { "elem": "path", "attrs": { "d": "M15 12H17V26H15z", "transform": "rotate(-180 16 19)" } }, { "elem": "path", "attrs": { "d": "M18 18H20V26H18z", "transform": "rotate(-180 19 22)" } }], "name": "chart--cluster-bar", "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=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path><path d=\"M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z\"></path><path d=\"M15 12H17V26H15z\" transform=\"rotate(-180 16 19)\"></path><path d=\"M18 18H20V26H18z\" transform=\"rotate(-180 19 22)\"></path></svg>" }, "24": { metadata: { "moduleName": "ChartClusterBar24", "filepath": "chart--cluster-bar/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": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "path", "attrs": { "d": "M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z" } }, { "elem": "path", "attrs": { "d": "M15 12H17V26H15z", "transform": "rotate(-180 16 19)" } }, { "elem": "path", "attrs": { "d": "M18 18H20V26H18z", "transform": "rotate(-180 19 22)" } }], "name": "chart--cluster-bar", "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=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path><path d=\"M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z\"></path><path d=\"M15 12H17V26H15z\" transform=\"rotate(-180 16 19)\"></path><path d=\"M18 18H20V26H18z\" transform=\"rotate(-180 19 22)\"></path></svg>" }, "20": { metadata: { "moduleName": "ChartClusterBar20", "filepath": "chart--cluster-bar/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": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "path", "attrs": { "d": "M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z" } }, { "elem": "path", "attrs": { "d": "M15 12H17V26H15z", "transform": "rotate(-180 16 19)" } }, { "elem": "path", "attrs": { "d": "M18 18H20V26H18z", "transform": "rotate(-180 19 22)" } }], "name": "chart--cluster-bar", "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=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path><path d=\"M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z\"></path><path d=\"M15 12H17V26H15z\" transform=\"rotate(-180 16 19)\"></path><path d=\"M18 18H20V26H18z\" transform=\"rotate(-180 19 22)\"></path></svg>" }, "16": { metadata: { "moduleName": "ChartClusterBar16", "filepath": "chart--cluster-bar/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": "M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z" } }, { "elem": "path", "attrs": { "d": "M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z" } }, { "elem": "path", "attrs": { "d": "M15 12H17V26H15z", "transform": "rotate(-180 16 19)" } }, { "elem": "path", "attrs": { "d": "M18 18H20V26H18z", "transform": "rotate(-180 19 22)" } }], "name": "chart--cluster-bar", "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=\"M30,30H4a2,2,0,0,1-2-2V2H4V28H30Z\"></path><path d=\"M10 16H12V26H10zM7 22H9V26H7zM26 8H28V26H26zM23 14H25V26H23z\"></path><path d=\"M15 12H17V26H15z\" transform=\"rotate(-180 16 19)\"></path><path d=\"M18 18H20V26H18z\" transform=\"rotate(-180 19 22)\"></path></svg>" }, }; } ChartClusterBarDirective_1 = ChartClusterBarDirective; ChartClusterBarDirective.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; ChartClusterBarDirective_1.titleIdCounter++; title.setAttribute("id", "chart-cluster-bar-" + ChartClusterBarDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "chart-cluster-bar-" + ChartClusterBarDirective_1.titleIdCounter); } }; var ChartClusterBarDirective_1; ChartClusterBarDirective.titleIdCounter = 0; ChartClusterBarDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartClusterBarDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ChartClusterBarDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ChartClusterBarDirective.prototype, "size", void 0); ChartClusterBarDirective = ChartClusterBarDirective_1 = __decorate([ Directive({ selector: "[ibmIconChartClusterBar]" }), __metadata("design:paramtypes", [ElementRef]) ], ChartClusterBarDirective); return ChartClusterBarDirective; }()); var ChartClusterBarModule = /** @class */ (function () { function ChartClusterBarModule() { } ChartClusterBarModule = __decorate([ NgModule({ declarations: [ ChartClusterBarComponent, ChartClusterBarDirective, ], exports: [ ChartClusterBarComponent, ChartClusterBarDirective, ] }) ], ChartClusterBarModule); return ChartClusterBarModule; }()); export { ChartClusterBarComponent, ChartClusterBarDirective, ChartClusterBarModule };