UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 12.3 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var HazeComponent = /** @class */ (function () { function HazeComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], HazeComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeComponent.prototype, "size", void 0); HazeComponent = __decorate([ Component({ selector: "ibm-icon-haze", template: "\n <svg\n ibmIconHaze\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 " }) ], HazeComponent); return HazeComponent; }()); var HazeDirective = /** @class */ (function () { function HazeDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Haze32", "filepath": "haze/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": "M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z" } }, { "elem": "path", "attrs": { "d": "M24.5 23.5H28.5V25.5H24.5z", "transform": "rotate(45 26.5 24.5)" } }, { "elem": "path", "attrs": { "d": "M28 15H32V17H28z" } }, { "elem": "path", "attrs": { "d": "M24.5 6.5H28.5V8.5H24.5z", "transform": "rotate(-45 26.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M17 2H19V6H17z" } }, { "elem": "path", "attrs": { "d": "M7.5 6.5H11.5V8.5H7.5z", "transform": "rotate(-135 9.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z" } }], "name": "haze", "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=\"M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z\"></path><path d=\"M24.5 23.5H28.5V25.5H24.5z\" transform=\"rotate(45 26.5 24.5)\"></path><path d=\"M28 15H32V17H28z\"></path><path d=\"M24.5 6.5H28.5V8.5H24.5z\" transform=\"rotate(-45 26.5 7.5)\"></path><path d=\"M17 2H19V6H17z\"></path><path d=\"M7.5 6.5H11.5V8.5H7.5z\" transform=\"rotate(-135 9.5 7.5)\"></path><path d=\"M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z\"></path></svg>" }, "24": { metadata: { "moduleName": "Haze24", "filepath": "haze/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": "M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z" } }, { "elem": "path", "attrs": { "d": "M24.5 23.5H28.5V25.5H24.5z", "transform": "rotate(45 26.5 24.5)" } }, { "elem": "path", "attrs": { "d": "M28 15H32V17H28z" } }, { "elem": "path", "attrs": { "d": "M24.5 6.5H28.5V8.5H24.5z", "transform": "rotate(-45 26.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M17 2H19V6H17z" } }, { "elem": "path", "attrs": { "d": "M7.5 6.5H11.5V8.5H7.5z", "transform": "rotate(-135 9.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z" } }], "name": "haze", "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=\"M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z\"></path><path d=\"M24.5 23.5H28.5V25.5H24.5z\" transform=\"rotate(45 26.5 24.5)\"></path><path d=\"M28 15H32V17H28z\"></path><path d=\"M24.5 6.5H28.5V8.5H24.5z\" transform=\"rotate(-45 26.5 7.5)\"></path><path d=\"M17 2H19V6H17z\"></path><path d=\"M7.5 6.5H11.5V8.5H7.5z\" transform=\"rotate(-135 9.5 7.5)\"></path><path d=\"M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z\"></path></svg>" }, "20": { metadata: { "moduleName": "Haze20", "filepath": "haze/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": "M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z" } }, { "elem": "path", "attrs": { "d": "M24.5 23.5H28.5V25.5H24.5z", "transform": "rotate(45 26.5 24.5)" } }, { "elem": "path", "attrs": { "d": "M28 15H32V17H28z" } }, { "elem": "path", "attrs": { "d": "M24.5 6.5H28.5V8.5H24.5z", "transform": "rotate(-45 26.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M17 2H19V6H17z" } }, { "elem": "path", "attrs": { "d": "M7.5 6.5H11.5V8.5H7.5z", "transform": "rotate(-135 9.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z" } }], "name": "haze", "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=\"M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z\"></path><path d=\"M24.5 23.5H28.5V25.5H24.5z\" transform=\"rotate(45 26.5 24.5)\"></path><path d=\"M28 15H32V17H28z\"></path><path d=\"M24.5 6.5H28.5V8.5H24.5z\" transform=\"rotate(-45 26.5 7.5)\"></path><path d=\"M17 2H19V6H17z\"></path><path d=\"M7.5 6.5H11.5V8.5H7.5z\" transform=\"rotate(-135 9.5 7.5)\"></path><path d=\"M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z\"></path></svg>" }, "16": { metadata: { "moduleName": "Haze16", "filepath": "haze/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": "M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z" } }, { "elem": "path", "attrs": { "d": "M24.5 23.5H28.5V25.5H24.5z", "transform": "rotate(45 26.5 24.5)" } }, { "elem": "path", "attrs": { "d": "M28 15H32V17H28z" } }, { "elem": "path", "attrs": { "d": "M24.5 6.5H28.5V8.5H24.5z", "transform": "rotate(-45 26.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M17 2H19V6H17z" } }, { "elem": "path", "attrs": { "d": "M7.5 6.5H11.5V8.5H7.5z", "transform": "rotate(-135 9.5 7.5)" } }, { "elem": "path", "attrs": { "d": "M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z" } }], "name": "haze", "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=\"M19 28H3a1 1 0 010-2H19a1 1 0 010 2zM15 20H3a1 1 0 010-2H15a1 1 0 010 2z\"></path><path d=\"M24.5 23.5H28.5V25.5H24.5z\" transform=\"rotate(45 26.5 24.5)\"></path><path d=\"M28 15H32V17H28z\"></path><path d=\"M24.5 6.5H28.5V8.5H24.5z\" transform=\"rotate(-45 26.5 7.5)\"></path><path d=\"M17 2H19V6H17z\"></path><path d=\"M7.5 6.5H11.5V8.5H7.5z\" transform=\"rotate(-135 9.5 7.5)\"></path><path d=\"M18,8a8.0092,8.0092,0,0,0-8,8h2a6,6,0,1,1,6,6H7a1,1,0,0,0,0,2H18A8,8,0,0,0,18,8Z\"></path></svg>" }, }; } HazeDirective_1 = HazeDirective; HazeDirective.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; HazeDirective_1.titleIdCounter++; title.setAttribute("id", "haze-" + HazeDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "haze-" + HazeDirective_1.titleIdCounter); } }; var HazeDirective_1; HazeDirective.titleIdCounter = 0; HazeDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], HazeDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeDirective.prototype, "size", void 0); HazeDirective = HazeDirective_1 = __decorate([ Directive({ selector: "[ibmIconHaze]" }), __metadata("design:paramtypes", [ElementRef]) ], HazeDirective); return HazeDirective; }()); var HazeModule = /** @class */ (function () { function HazeModule() { } HazeModule = __decorate([ NgModule({ declarations: [ HazeComponent, HazeDirective, ], exports: [ HazeComponent, HazeDirective, ] }) ], HazeModule); return HazeModule; }()); export { HazeComponent, HazeDirective, HazeModule };