UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 8.71 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var QCZComponent = /** @class */ (function () { function QCZComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], QCZComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QCZComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QCZComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZComponent.prototype, "size", void 0); QCZComponent = __decorate([ Component({ selector: "ibm-icon-q-c-z", template: "\n <svg\n ibmIconQCZ\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 " }) ], QCZComponent); return QCZComponent; }()); var QCZDirective = /** @class */ (function () { function QCZDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "QCZ32", "filepath": "Q/cZ/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": "M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z" } }], "name": "cZ", "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=\"M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z\"></path></svg>" }, "24": { metadata: { "moduleName": "QCZ24", "filepath": "Q/cZ/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": "M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z" } }], "name": "cZ", "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=\"M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z\"></path></svg>" }, "20": { metadata: { "moduleName": "QCZ20", "filepath": "Q/cZ/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": "M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z" } }], "name": "cZ", "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=\"M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z\"></path></svg>" }, "16": { metadata: { "moduleName": "QCZ16", "filepath": "Q/cZ/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": "M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z" } }], "name": "cZ", "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=\"M14 23H9a2 2 0 01-2-2V15a2 2 0 012-2h5v2H9v6h5zM24 9L16 9 16 11 22 11 16 21 16 23 24 23 24 21 18 21 24 11 24 9z\"></path></svg>" }, }; } QCZDirective_1 = QCZDirective; QCZDirective.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; QCZDirective_1.titleIdCounter++; title.setAttribute("id", "q-c-z-" + QCZDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "q-c-z-" + QCZDirective_1.titleIdCounter); } }; var QCZDirective_1; QCZDirective.titleIdCounter = 0; QCZDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], QCZDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QCZDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QCZDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], QCZDirective.prototype, "size", void 0); QCZDirective = QCZDirective_1 = __decorate([ Directive({ selector: "[ibmIconQCZ]" }), __metadata("design:paramtypes", [ElementRef]) ], QCZDirective); return QCZDirective; }()); var QCZModule = /** @class */ (function () { function QCZModule() { } QCZModule = __decorate([ NgModule({ declarations: [ QCZComponent, QCZDirective, ], exports: [ QCZComponent, QCZDirective, ] }) ], QCZModule); return QCZModule; }()); export { QCZComponent, QCZDirective, QCZModule };