UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 12.9 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var LightFilledDirective_1; let LightFilledComponent = class LightFilledComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], LightFilledComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], LightFilledComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], LightFilledComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledComponent.prototype, "size", void 0); LightFilledComponent = __decorate([ Component({ selector: "ibm-icon-light-filled", template: ` <svg ibmIconLightFilled [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], LightFilledComponent); let LightFilledDirective = LightFilledDirective_1 = class LightFilledDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "LightFilled32", "filepath": "light--filled/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": "M15 2H17V7H15z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.147 7.853)" } }, { "elem": "path", "attrs": { "d": "M25 15H30V17H25z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.147 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.853 24.146)" } }, { "elem": "path", "attrs": { "d": "M2 15H7V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.854 7.853)" } }, { "elem": "path", "attrs": { "d": "M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "light--filled", "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="M15 2H17V7H15z"></path><path d="M21.668 6.854H26.625999999999998V8.854H21.668z" transform="rotate(-45 24.147 7.853)"></path><path d="M25 15H30V17H25z"></path><path d="M23.147 21.668H25.147V26.625999999999998H23.147z" transform="rotate(-45 24.147 24.146)"></path><path d="M15 25H17V30H15z"></path><path d="M5.375 23.147H10.333V25.147H5.375z" transform="rotate(-45 7.853 24.146)"></path><path d="M2 15H7V17H2z"></path><path d="M6.854 5.375H8.854V10.333H6.854z" transform="rotate(-45 7.854 7.853)"></path><path d="M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z"></path></svg>` }, "24": { metadata: { "moduleName": "LightFilled24", "filepath": "light--filled/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": "M15 2H17V7H15z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.147 7.853)" } }, { "elem": "path", "attrs": { "d": "M25 15H30V17H25z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.147 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.853 24.146)" } }, { "elem": "path", "attrs": { "d": "M2 15H7V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.854 7.853)" } }, { "elem": "path", "attrs": { "d": "M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "light--filled", "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="M15 2H17V7H15z"></path><path d="M21.668 6.854H26.625999999999998V8.854H21.668z" transform="rotate(-45 24.147 7.853)"></path><path d="M25 15H30V17H25z"></path><path d="M23.147 21.668H25.147V26.625999999999998H23.147z" transform="rotate(-45 24.147 24.146)"></path><path d="M15 25H17V30H15z"></path><path d="M5.375 23.147H10.333V25.147H5.375z" transform="rotate(-45 7.853 24.146)"></path><path d="M2 15H7V17H2z"></path><path d="M6.854 5.375H8.854V10.333H6.854z" transform="rotate(-45 7.854 7.853)"></path><path d="M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z"></path></svg>` }, "20": { metadata: { "moduleName": "LightFilled20", "filepath": "light--filled/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": "M15 2H17V7H15z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.147 7.853)" } }, { "elem": "path", "attrs": { "d": "M25 15H30V17H25z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.147 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.853 24.146)" } }, { "elem": "path", "attrs": { "d": "M2 15H7V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.854 7.853)" } }, { "elem": "path", "attrs": { "d": "M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "light--filled", "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="M15 2H17V7H15z"></path><path d="M21.668 6.854H26.625999999999998V8.854H21.668z" transform="rotate(-45 24.147 7.853)"></path><path d="M25 15H30V17H25z"></path><path d="M23.147 21.668H25.147V26.625999999999998H23.147z" transform="rotate(-45 24.147 24.146)"></path><path d="M15 25H17V30H15z"></path><path d="M5.375 23.147H10.333V25.147H5.375z" transform="rotate(-45 7.853 24.146)"></path><path d="M2 15H7V17H2z"></path><path d="M6.854 5.375H8.854V10.333H6.854z" transform="rotate(-45 7.854 7.853)"></path><path d="M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z"></path></svg>` }, "16": { metadata: { "moduleName": "LightFilled16", "filepath": "light--filled/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": "M15 2H17V7H15z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.147 7.853)" } }, { "elem": "path", "attrs": { "d": "M25 15H30V17H25z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.147 24.146)" } }, { "elem": "path", "attrs": { "d": "M15 25H17V30H15z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.853 24.146)" } }, { "elem": "path", "attrs": { "d": "M2 15H7V17H2z" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.854 7.853)" } }, { "elem": "path", "attrs": { "d": "M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z" } }], "name": "light--filled", "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="M15 2H17V7H15z"></path><path d="M21.668 6.854H26.625999999999998V8.854H21.668z" transform="rotate(-45 24.147 7.853)"></path><path d="M25 15H30V17H25z"></path><path d="M23.147 21.668H25.147V26.625999999999998H23.147z" transform="rotate(-45 24.147 24.146)"></path><path d="M15 25H17V30H15z"></path><path d="M5.375 23.147H10.333V25.147H5.375z" transform="rotate(-45 7.853 24.146)"></path><path d="M2 15H7V17H2z"></path><path d="M6.854 5.375H8.854V10.333H6.854z" transform="rotate(-45 7.854 7.853)"></path><path d="M16,10a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z"></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; LightFilledDirective_1.titleIdCounter++; title.setAttribute("id", `light-filled-${LightFilledDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `light-filled-${LightFilledDirective_1.titleIdCounter}`); } } }; LightFilledDirective.titleIdCounter = 0; LightFilledDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], LightFilledDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], LightFilledDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], LightFilledDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], LightFilledDirective.prototype, "size", void 0); LightFilledDirective = LightFilledDirective_1 = __decorate([ Directive({ selector: "[ibmIconLightFilled]" }), __metadata("design:paramtypes", [ElementRef]) ], LightFilledDirective); let LightFilledModule = class LightFilledModule { }; LightFilledModule = __decorate([ NgModule({ declarations: [ LightFilledComponent, LightFilledDirective, ], exports: [ LightFilledComponent, LightFilledDirective, ] }) ], LightFilledModule); export { LightFilledComponent, LightFilledDirective, LightFilledModule };