UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 9.43 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ErrorFilledDirective_1; let ErrorFilledComponent = class ErrorFilledComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ErrorFilledComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ErrorFilledComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledComponent.prototype, "size", void 0); ErrorFilledComponent = __decorate([ Component({ selector: "ibm-icon-error-filled", template: ` <svg ibmIconErrorFilled [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], ErrorFilledComponent); let ErrorFilledDirective = ErrorFilledDirective_1 = class ErrorFilledDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ErrorFilled32", "filepath": "error--filled/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": "M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M21.4,23L9,10.6L10.6,9L23,21.4L21.4,23z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M21.4,23L9,10.6L10.6,9L23,21.4L21.4,23z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "error--filled", "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="M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M21.4,23L9,10.6L10.6,9L23,21.4L21.4,23z"></path><path fill="none" d="M21.4,23L9,10.6L10.6,9L23,21.4L21.4,23z" data-icon-path="inner-path" opacity="0"></path></svg>` }, "24": { metadata: { "moduleName": "ErrorFilled24", "filepath": "error--filled/24.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 24 24", "fill": "currentColor", "width": 24, "height": 24 }, "content": [{ "elem": "path", "attrs": { "d": "M12,1C5.9,1,1,5.9,1,12s4.9,11,11,11s11-4.9,11-11S18.1,1,12,1z M16.3,17.5L6.5,7.7l1.2-1.2l9.8,9.8L16.3,17.5z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M16.3,17.5L6.5,7.7l1.2-1.2l9.8,9.8L16.3,17.5z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "error--filled", "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 24 24" aria-hidden="true"><path d="M12,1C5.9,1,1,5.9,1,12s4.9,11,11,11s11-4.9,11-11S18.1,1,12,1z M16.3,17.5L6.5,7.7l1.2-1.2l9.8,9.8L16.3,17.5z"></path><path fill="none" d="M16.3,17.5L6.5,7.7l1.2-1.2l9.8,9.8L16.3,17.5z" data-icon-path="inner-path" opacity="0"></path></svg>` }, "20": { metadata: { "moduleName": "ErrorFilled20", "filepath": "error--filled/20.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 20 20", "fill": "currentColor", "width": 20, "height": 20 }, "content": [{ "elem": "path", "attrs": { "d": "M10,1c-5,0-9,4-9,9s4,9,9,9s9-4,9-9S15,1,10,1z M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z" } }, { "elem": "path", "attrs": { "d": "M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "error--filled", "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 20 20" aria-hidden="true"><path d="M10,1c-5,0-9,4-9,9s4,9,9,9s9-4,9-9S15,1,10,1z M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z"></path><path d="M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z" data-icon-path="inner-path" opacity="0"></path></svg>` }, "16": { metadata: { "moduleName": "ErrorFilled16", "filepath": "error--filled/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 16 16", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M8,1C4.1,1,1,4.1,1,8s3.1,7,7,7s7-3.1,7-7S11.9,1,8,1z M10.7,11.5L4.5,5.3l0.8-0.8l6.2,6.2L10.7,11.5z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M10.7,11.5L4.5,5.3l0.8-0.8l6.2,6.2L10.7,11.5z", "data-icon-path": "inner-path", "opacity": "0" } }], "name": "error--filled", "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 16 16" aria-hidden="true"><path d="M8,1C4.1,1,1,4.1,1,8s3.1,7,7,7s7-3.1,7-7S11.9,1,8,1z M10.7,11.5L4.5,5.3l0.8-0.8l6.2,6.2L10.7,11.5z"></path><path fill="none" d="M10.7,11.5L4.5,5.3l0.8-0.8l6.2,6.2L10.7,11.5z" data-icon-path="inner-path" opacity="0"></path></svg>` }, }; } ngAfterViewInit() { const svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); const icon = this.icons[this.size]; const domParser = new DOMParser(); const rawSVG = icon.svg; const svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; let 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; } const 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() }); const attrKeys = Object.keys(attributes); for (let i = 0; i < attrKeys.length; i++) { const key = attrKeys[i]; const value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { const title = document.createElement("title"); title.textContent = attributes.title; ErrorFilledDirective_1.titleIdCounter++; title.setAttribute("id", `error-filled-${ErrorFilledDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `error-filled-${ErrorFilledDirective_1.titleIdCounter}`); } } }; ErrorFilledDirective.titleIdCounter = 0; ErrorFilledDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ErrorFilledDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ErrorFilledDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ErrorFilledDirective.prototype, "size", void 0); ErrorFilledDirective = ErrorFilledDirective_1 = __decorate([ Directive({ selector: "[ibmIconErrorFilled]" }), __metadata("design:paramtypes", [ElementRef]) ], ErrorFilledDirective); let ErrorFilledModule = class ErrorFilledModule { }; ErrorFilledModule = __decorate([ NgModule({ declarations: [ ErrorFilledComponent, ErrorFilledDirective, ], exports: [ ErrorFilledComponent, ErrorFilledDirective, ] }) ], ErrorFilledModule); export { ErrorFilledComponent, ErrorFilledDirective, ErrorFilledModule };