UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 10.5 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ReflectVerticalDirective_1; let ReflectVerticalComponent = class ReflectVerticalComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ReflectVerticalComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ReflectVerticalComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalComponent.prototype, "size", void 0); ReflectVerticalComponent = __decorate([ Component({ selector: "ibm-icon-reflect-vertical", template: ` <svg ibmIconReflectVertical [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], ReflectVerticalComponent); let ReflectVerticalDirective = ReflectVerticalDirective_1 = class ReflectVerticalDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ReflectVertical32", "filepath": "reflect--vertical/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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V30H15z", "transform": "rotate(-90 16 16)" } }, { "elem": "path", "attrs": { "d": "M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z" } }], "name": "reflect--vertical", "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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z"></path><path d="M15 2H17V30H15z" transform="rotate(-90 16 16)"></path><path d="M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z"></path></svg>` }, "24": { metadata: { "moduleName": "ReflectVertical24", "filepath": "reflect--vertical/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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V30H15z", "transform": "rotate(-90 16 16)" } }, { "elem": "path", "attrs": { "d": "M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z" } }], "name": "reflect--vertical", "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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z"></path><path d="M15 2H17V30H15z" transform="rotate(-90 16 16)"></path><path d="M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z"></path></svg>` }, "20": { metadata: { "moduleName": "ReflectVertical20", "filepath": "reflect--vertical/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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V30H15z", "transform": "rotate(-90 16 16)" } }, { "elem": "path", "attrs": { "d": "M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z" } }], "name": "reflect--vertical", "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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z"></path><path d="M15 2H17V30H15z" transform="rotate(-90 16 16)"></path><path d="M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z"></path></svg>` }, "16": { metadata: { "moduleName": "ReflectVertical16", "filepath": "reflect--vertical/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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V30H15z", "transform": "rotate(-90 16 16)" } }, { "elem": "path", "attrs": { "d": "M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,4Z" } }], "name": "reflect--vertical", "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.79,19.386l7,9A1,1,0,0,1,23,30H9a1,1,0,0,1-.79-1.614l7-9a1,1,0,0,1,1.5791,0Z"></path><path d="M15 2H17V30H15z" transform="rotate(-90 16 16)"></path><path d="M16,13a1.001,1.001,0,0,1-.79-.386l-7-9A1,1,0,0,1,9,2H23a1,1,0,0,1,.79,1.614l-7,9A1.001,1.001,0,0,1,16,13ZM11.0444,4,16,10.3711,20.9556,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; ReflectVerticalDirective_1.titleIdCounter++; title.setAttribute("id", `reflect-vertical-${ReflectVerticalDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `reflect-vertical-${ReflectVerticalDirective_1.titleIdCounter}`); } } }; ReflectVerticalDirective.titleIdCounter = 0; ReflectVerticalDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ReflectVerticalDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ReflectVerticalDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ReflectVerticalDirective.prototype, "size", void 0); ReflectVerticalDirective = ReflectVerticalDirective_1 = __decorate([ Directive({ selector: "[ibmIconReflectVertical]" }), __metadata("design:paramtypes", [ElementRef]) ], ReflectVerticalDirective); let ReflectVerticalModule = class ReflectVerticalModule { }; ReflectVerticalModule = __decorate([ NgModule({ declarations: [ ReflectVerticalComponent, ReflectVerticalDirective, ], exports: [ ReflectVerticalComponent, ReflectVerticalDirective, ] }) ], ReflectVerticalModule); export { ReflectVerticalComponent, ReflectVerticalDirective, ReflectVerticalModule };