UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 11.9 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var CheckmarkFilledWarningDirective_1; let CheckmarkFilledWarningComponent = class CheckmarkFilledWarningComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CheckmarkFilledWarningComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CheckmarkFilledWarningComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningComponent.prototype, "size", void 0); CheckmarkFilledWarningComponent = __decorate([ Component({ selector: "ibm-icon-checkmark-filled-warning", template: ` <svg ibmIconCheckmarkFilledWarning [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], CheckmarkFilledWarningComponent); let CheckmarkFilledWarningDirective = CheckmarkFilledWarningDirective_1 = class CheckmarkFilledWarningDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "CheckmarkFilledWarning32", "filepath": "checkmark--filled--warning/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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z" } }, { "elem": "path", "attrs": { "d": "M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z" } }], "name": "checkmark--filled--warning", "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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z"></path><path d="M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z"></path><path fill="none" d="M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z"></path></svg>` }, "24": { metadata: { "moduleName": "CheckmarkFilledWarning24", "filepath": "checkmark--filled--warning/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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z" } }, { "elem": "path", "attrs": { "d": "M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z" } }], "name": "checkmark--filled--warning", "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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z"></path><path d="M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z"></path><path fill="none" d="M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z"></path></svg>` }, "20": { metadata: { "moduleName": "CheckmarkFilledWarning20", "filepath": "checkmark--filled--warning/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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z" } }, { "elem": "path", "attrs": { "d": "M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z" } }], "name": "checkmark--filled--warning", "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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z"></path><path d="M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z"></path><path fill="none" d="M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z"></path></svg>` }, "16": { metadata: { "moduleName": "CheckmarkFilledWarning16", "filepath": "checkmark--filled--warning/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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z" } }, { "elem": "path", "attrs": { "d": "M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z" } }, { "elem": "path", "attrs": { "fill": "none", "d": "M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z" } }], "name": "checkmark--filled--warning", "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,2a12,12,0,1,0,3.3928,23.5059l3.9246-7.8492A2.9846,2.9846,0,0,1,24,16h1.82A11.9348,11.9348,0,0,0,14,2ZM12,18.5908l-4-4L9.5908,13,12,15.4092,17.4092,10,19,11.5908Z"></path><path d="M27.38,28H20.6178L24,21.2358ZM24,18a1,1,0,0,0-.8947.5527l-5,10A1.0005,1.0005,0,0,0,19,30H29a1,1,0,0,0,.9214-1.3892L24.8946,18.5527A1,1,0,0,0,24,18Z"></path><path fill="none" d="M12 18.591L8 14.591 9.591 13 12 15.409 17.409 10 19 11.591 12 18.591z"></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; CheckmarkFilledWarningDirective_1.titleIdCounter++; title.setAttribute("id", `checkmark-filled-warning-${CheckmarkFilledWarningDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `checkmark-filled-warning-${CheckmarkFilledWarningDirective_1.titleIdCounter}`); } } }; CheckmarkFilledWarningDirective.titleIdCounter = 0; CheckmarkFilledWarningDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CheckmarkFilledWarningDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CheckmarkFilledWarningDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CheckmarkFilledWarningDirective.prototype, "size", void 0); CheckmarkFilledWarningDirective = CheckmarkFilledWarningDirective_1 = __decorate([ Directive({ selector: "[ibmIconCheckmarkFilledWarning]" }), __metadata("design:paramtypes", [ElementRef]) ], CheckmarkFilledWarningDirective); let CheckmarkFilledWarningModule = class CheckmarkFilledWarningModule { }; CheckmarkFilledWarningModule = __decorate([ NgModule({ declarations: [ CheckmarkFilledWarningComponent, CheckmarkFilledWarningDirective, ], exports: [ CheckmarkFilledWarningComponent, CheckmarkFilledWarningDirective, ] }) ], CheckmarkFilledWarningModule); export { CheckmarkFilledWarningComponent, CheckmarkFilledWarningDirective, CheckmarkFilledWarningModule };