UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 9.72 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var CloseOutlineDirective_1; let CloseOutlineComponent = class CloseOutlineComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloseOutlineComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloseOutlineComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineComponent.prototype, "size", void 0); CloseOutlineComponent = __decorate([ Component({ selector: "ibm-icon-close-outline", template: ` <svg ibmIconCloseOutline [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], CloseOutlineComponent); let CloseOutlineDirective = CloseOutlineDirective_1 = class CloseOutlineDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "CloseOutline32", "filepath": "close--outline/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 M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12\tS22.6,28,16,28z" } }, { "elem": "path", "attrs": { "d": "M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z" } }], "name": "close--outline", "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 M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12 S22.6,28,16,28z"></path><path d="M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z"></path></svg>` }, "24": { metadata: { "moduleName": "CloseOutline24", "filepath": "close--outline/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": "M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12\tS22.6,28,16,28z" } }, { "elem": "path", "attrs": { "d": "M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z" } }], "name": "close--outline", "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="M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12 S22.6,28,16,28z"></path><path d="M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z"></path></svg>` }, "20": { metadata: { "moduleName": "CloseOutline20", "filepath": "close--outline/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": "M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12\tS22.6,28,16,28z" } }, { "elem": "path", "attrs": { "d": "M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z" } }], "name": "close--outline", "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="M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12 S22.6,28,16,28z"></path><path d="M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z"></path></svg>` }, "16": { metadata: { "moduleName": "CloseOutline16", "filepath": "close--outline/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": "M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12\tS22.6,28,16,28z" } }, { "elem": "path", "attrs": { "d": "M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z" } }], "name": "close--outline", "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="M16,2C8.2,2,2,8.2,2,16s6.2,14,14,14s14-6.2,14-14S23.8,2,16,2z M16,28C9.4,28,4,22.6,4,16S9.4,4,16,4s12,5.4,12,12 S22.6,28,16,28z"></path><path d="M21.4 23L16 17.6 10.6 23 9 21.4 14.4 16 9 10.6 10.6 9 16 14.4 21.4 9 23 10.6 17.6 16 23 21.4z"></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; CloseOutlineDirective_1.titleIdCounter++; title.setAttribute("id", `close-outline-${CloseOutlineDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `close-outline-${CloseOutlineDirective_1.titleIdCounter}`); } } }; CloseOutlineDirective.titleIdCounter = 0; CloseOutlineDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloseOutlineDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloseOutlineDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloseOutlineDirective.prototype, "size", void 0); CloseOutlineDirective = CloseOutlineDirective_1 = __decorate([ Directive({ selector: "[ibmIconCloseOutline]" }), __metadata("design:paramtypes", [ElementRef]) ], CloseOutlineDirective); let CloseOutlineModule = class CloseOutlineModule { }; CloseOutlineModule = __decorate([ NgModule({ declarations: [ CloseOutlineComponent, CloseOutlineDirective, ], exports: [ CloseOutlineComponent, CloseOutlineDirective, ] }) ], CloseOutlineModule); export { CloseOutlineComponent, CloseOutlineDirective, CloseOutlineModule };