UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 11.8 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var DataErrorComponent = /** @class */ (function () { function DataErrorComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], DataErrorComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DataErrorComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DataErrorComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorComponent.prototype, "size", void 0); DataErrorComponent = __decorate([ Component({ selector: "ibm-icon-data-error", template: "\n <svg\n ibmIconDataError\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 " }) ], DataErrorComponent); return DataErrorComponent; }()); var DataErrorDirective = /** @class */ (function () { function DataErrorDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "DataError32", "filepath": "data--error/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": "circle", "attrs": { "cx": "11", "cy": "8", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "16", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "24", "r": "1" } }, { "elem": "path", "attrs": { "d": "M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z" } }, { "elem": "path", "attrs": { "d": "M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z" } }], "name": "data--error", "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\"><circle cx=\"11\" cy=\"8\" r=\"1\"></circle><circle cx=\"11\" cy=\"16\" r=\"1\"></circle><circle cx=\"11\" cy=\"24\" r=\"1\"></circle><path d=\"M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z\"></path><path d=\"M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z\"></path></svg>" }, "24": { metadata: { "moduleName": "DataError24", "filepath": "data--error/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": "circle", "attrs": { "cx": "11", "cy": "8", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "16", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "24", "r": "1" } }, { "elem": "path", "attrs": { "d": "M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z" } }, { "elem": "path", "attrs": { "d": "M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z" } }], "name": "data--error", "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\"><circle cx=\"11\" cy=\"8\" r=\"1\"></circle><circle cx=\"11\" cy=\"16\" r=\"1\"></circle><circle cx=\"11\" cy=\"24\" r=\"1\"></circle><path d=\"M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z\"></path><path d=\"M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z\"></path></svg>" }, "20": { metadata: { "moduleName": "DataError20", "filepath": "data--error/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": "circle", "attrs": { "cx": "11", "cy": "8", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "16", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "24", "r": "1" } }, { "elem": "path", "attrs": { "d": "M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z" } }, { "elem": "path", "attrs": { "d": "M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z" } }], "name": "data--error", "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\"><circle cx=\"11\" cy=\"8\" r=\"1\"></circle><circle cx=\"11\" cy=\"16\" r=\"1\"></circle><circle cx=\"11\" cy=\"24\" r=\"1\"></circle><path d=\"M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z\"></path><path d=\"M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z\"></path></svg>" }, "16": { metadata: { "moduleName": "DataError16", "filepath": "data--error/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": "circle", "attrs": { "cx": "11", "cy": "8", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "16", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "11", "cy": "24", "r": "1" } }, { "elem": "path", "attrs": { "d": "M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z" } }, { "elem": "path", "attrs": { "d": "M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z" } }], "name": "data--error", "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\"><circle cx=\"11\" cy=\"8\" r=\"1\"></circle><circle cx=\"11\" cy=\"16\" r=\"1\"></circle><circle cx=\"11\" cy=\"24\" r=\"1\"></circle><path d=\"M24,3H8A2,2,0,0,0,6,5V27a2,2,0,0,0,2,2h8V27H8V21H26V5A2,2,0,0,0,24,3Zm0,16H8V13H24Zm0-8H8V5H24Z\"></path><path d=\"M29.24 29.58L26.41 26.75 29.24 23.92 27.83 22.51 25 25.33 22.17 22.51 20.76 23.92 23.59 26.75 20.76 29.58 22.17 30.99 25 28.16 27.83 30.99 29.24 29.58z\"></path></svg>" }, }; } DataErrorDirective_1 = DataErrorDirective; DataErrorDirective.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; DataErrorDirective_1.titleIdCounter++; title.setAttribute("id", "data-error-" + DataErrorDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "data-error-" + DataErrorDirective_1.titleIdCounter); } }; var DataErrorDirective_1; DataErrorDirective.titleIdCounter = 0; DataErrorDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], DataErrorDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DataErrorDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DataErrorDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DataErrorDirective.prototype, "size", void 0); DataErrorDirective = DataErrorDirective_1 = __decorate([ Directive({ selector: "[ibmIconDataError]" }), __metadata("design:paramtypes", [ElementRef]) ], DataErrorDirective); return DataErrorDirective; }()); var DataErrorModule = /** @class */ (function () { function DataErrorModule() { } DataErrorModule = __decorate([ NgModule({ declarations: [ DataErrorComponent, DataErrorDirective, ], exports: [ DataErrorComponent, DataErrorDirective, ] }) ], DataErrorModule); return DataErrorModule; }()); export { DataErrorComponent, DataErrorDirective, DataErrorModule };