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 VirtualColumnKeyDirective_1; let VirtualColumnKeyComponent = class VirtualColumnKeyComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], VirtualColumnKeyComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], VirtualColumnKeyComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyComponent.prototype, "size", void 0); VirtualColumnKeyComponent = __decorate([ Component({ selector: "ibm-icon-virtual-column-key", template: ` <svg ibmIconVirtualColumnKey [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], VirtualColumnKeyComponent); let VirtualColumnKeyDirective = VirtualColumnKeyDirective_1 = class VirtualColumnKeyDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "VirtualColumnKey32", "filepath": "virtual-column--key/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": "circle", "attrs": { "cx": "24.5", "cy": "9.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z" } }, { "elem": "path", "attrs": { "d": "M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z" } }], "name": "virtual-column--key", "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"><circle cx="24.5" cy="9.5" r="1.5"></circle><path d="M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z"></path><path d="M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z"></path></svg>` }, "24": { metadata: { "moduleName": "VirtualColumnKey24", "filepath": "virtual-column--key/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": "circle", "attrs": { "cx": "24.5", "cy": "9.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z" } }, { "elem": "path", "attrs": { "d": "M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z" } }], "name": "virtual-column--key", "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"><circle cx="24.5" cy="9.5" r="1.5"></circle><path d="M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z"></path><path d="M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z"></path></svg>` }, "20": { metadata: { "moduleName": "VirtualColumnKey20", "filepath": "virtual-column--key/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": "circle", "attrs": { "cx": "24.5", "cy": "9.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z" } }, { "elem": "path", "attrs": { "d": "M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z" } }], "name": "virtual-column--key", "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"><circle cx="24.5" cy="9.5" r="1.5"></circle><path d="M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z"></path><path d="M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z"></path></svg>` }, "16": { metadata: { "moduleName": "VirtualColumnKey16", "filepath": "virtual-column--key/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": "circle", "attrs": { "cx": "24.5", "cy": "9.5", "r": "1.5" } }, { "elem": "path", "attrs": { "d": "M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z" } }, { "elem": "path", "attrs": { "d": "M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z" } }], "name": "virtual-column--key", "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"><circle cx="24.5" cy="9.5" r="1.5"></circle><path d="M17.4143,22H12V16.5857l6.03-6.03A5.3518,5.3518,0,0,1,18,10a6,6,0,1,1,6,6,5.3583,5.3583,0,0,1-.5559-.03ZM14,20h2.5857l6.1706-6.1709.5174.0957A3.935,3.935,0,0,0,24,14a4.0507,4.0507,0,1,0-3.925-3.2729l.0952.5166L14,17.4143Z"></path><path d="M28,18v8H10V6h4V4H4A2.0025,2.0025,0,0,0,2,6V26a2.0025,2.0025,0,0,0,2,2H28a2.0025,2.0025,0,0,0,2-2V18ZM4,6H8V26H4Z"></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; VirtualColumnKeyDirective_1.titleIdCounter++; title.setAttribute("id", `virtual-column-key-${VirtualColumnKeyDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `virtual-column-key-${VirtualColumnKeyDirective_1.titleIdCounter}`); } } }; VirtualColumnKeyDirective.titleIdCounter = 0; VirtualColumnKeyDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], VirtualColumnKeyDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], VirtualColumnKeyDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], VirtualColumnKeyDirective.prototype, "size", void 0); VirtualColumnKeyDirective = VirtualColumnKeyDirective_1 = __decorate([ Directive({ selector: "[ibmIconVirtualColumnKey]" }), __metadata("design:paramtypes", [ElementRef]) ], VirtualColumnKeyDirective); let VirtualColumnKeyModule = class VirtualColumnKeyModule { }; VirtualColumnKeyModule = __decorate([ NgModule({ declarations: [ VirtualColumnKeyComponent, VirtualColumnKeyDirective, ], exports: [ VirtualColumnKeyComponent, VirtualColumnKeyDirective, ] }) ], VirtualColumnKeyModule); export { VirtualColumnKeyComponent, VirtualColumnKeyDirective, VirtualColumnKeyModule };