UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 11.3 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var HazeNightDirective_1; let HazeNightComponent = class HazeNightComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], HazeNightComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeNightComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeNightComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightComponent.prototype, "size", void 0); HazeNightComponent = __decorate([ Component({ selector: "ibm-icon-haze-night", template: ` <svg ibmIconHazeNight [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], HazeNightComponent); let HazeNightDirective = HazeNightDirective_1 = class HazeNightDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "HazeNight32", "filepath": "haze--night/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": "M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z" } }, { "elem": "path", "attrs": { "d": "M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z" } }], "name": "haze--night", "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="M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z"></path><path d="M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z"></path></svg>` }, "24": { metadata: { "moduleName": "HazeNight24", "filepath": "haze--night/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": "M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z" } }, { "elem": "path", "attrs": { "d": "M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z" } }], "name": "haze--night", "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="M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z"></path><path d="M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z"></path></svg>` }, "20": { metadata: { "moduleName": "HazeNight20", "filepath": "haze--night/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": "M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z" } }, { "elem": "path", "attrs": { "d": "M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z" } }], "name": "haze--night", "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="M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z"></path><path d="M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z"></path></svg>` }, "16": { metadata: { "moduleName": "HazeNight16", "filepath": "haze--night/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": "M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z" } }, { "elem": "path", "attrs": { "d": "M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z" } }], "name": "haze--night", "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="M29,22H13a1,1,0,0,0,0,2h9.6772a11.0991,11.0991,0,0,1-7.5561,2.9976c-.1384,0-.2783.0048-.4177,0a11.0945,11.0945,0,0,1-3.201-21.584,15.1528,15.1528,0,0,0-.0488,6.5869h2.0457a13.15,13.15,0,0,1,.39-7.6206A1.015,1.015,0,0,0,12.98,3a.9825.9825,0,0,0-.1746.0156A13.0958,13.0958,0,0,0,14.63,28.9971c.164.0063.3281,0,.4907,0A13.04,13.04,0,0,0,25.3779,24H29a1,1,0,0,0,0-2Z"></path><path d="M27 20H17a1 1 0 010-2H27a1 1 0 010 2zM25 16H13a1 1 0 010-2H25a1 1 0 010 2z"></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; HazeNightDirective_1.titleIdCounter++; title.setAttribute("id", `haze-night-${HazeNightDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `haze-night-${HazeNightDirective_1.titleIdCounter}`); } } }; HazeNightDirective.titleIdCounter = 0; HazeNightDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], HazeNightDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeNightDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HazeNightDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HazeNightDirective.prototype, "size", void 0); HazeNightDirective = HazeNightDirective_1 = __decorate([ Directive({ selector: "[ibmIconHazeNight]" }), __metadata("design:paramtypes", [ElementRef]) ], HazeNightDirective); let HazeNightModule = class HazeNightModule { }; HazeNightModule = __decorate([ NgModule({ declarations: [ HazeNightComponent, HazeNightDirective, ], exports: [ HazeNightComponent, HazeNightDirective, ] }) ], HazeNightModule); export { HazeNightComponent, HazeNightDirective, HazeNightModule };