UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 11 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var FunctionComponent = /** @class */ (function () { function FunctionComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], FunctionComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FunctionComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FunctionComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionComponent.prototype, "size", void 0); FunctionComponent = __decorate([ Component({ selector: "ibm-icon-function", template: "\n <svg\n ibmIconFunction\n [size]=\"size\"\n [ariaLabel]=\"ariaLabel\"\n [ariaLabelledby]=\"ariaLabelledby\"\n [ariaHidden]=\"ariaHidden\"\n [title]=\"title\"\n [isFocusable]=\"focusable\"\n [attr.class]=\"innerClass\">\n </svg>\n " }) ], FunctionComponent); return FunctionComponent; }()); var FunctionDirective = /** @class */ (function () { function FunctionDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Function32", "filepath": "function/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": "M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z" } }], "name": "function", "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=\"M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z\"></path></svg>" }, "24": { metadata: { "moduleName": "Function24", "filepath": "function/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": "M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z" } }], "name": "function", "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=\"M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z\"></path></svg>" }, "20": { metadata: { "moduleName": "Function20", "filepath": "function/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": "M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z" } }], "name": "function", "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=\"M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z\"></path></svg>" }, "16": { metadata: { "moduleName": "Function16", "filepath": "function/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": "M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z" } }], "name": "function", "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=\"M19.23 29.6252l-.46-1.9462A12.0032 12.0032 0 0025.2312 8.3323l1.5376-1.2788A14.0029 14.0029 0 0119.23 29.6252zM23 6V4H17.9133a1.9906 1.9906 0 00-1.9919 1.8188L15.2686 13H11v2h4.0867l-1 11H9v2h5.0867a1.9906 1.9906 0 001.9919-1.8189L17.0952 15H22V13H17.2769l.6364-7zM5.2312 24.9465A14.0029 14.0029 0 0112.77 2.3748l.46 1.9462A12.0032 12.0032 0 006.7688 23.6677z\"></path></svg>" }, }; } FunctionDirective_1 = FunctionDirective; FunctionDirective.prototype.ngAfterViewInit = function () { var svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); var icon = this.icons[this.size]; var domParser = new DOMParser(); var rawSVG = icon.svg; var svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; var 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; } var 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() }); var attrKeys = Object.keys(attributes); for (var i = 0; i < attrKeys.length; i++) { var key = attrKeys[i]; var value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { var title = document.createElement("title"); title.textContent = attributes.title; FunctionDirective_1.titleIdCounter++; title.setAttribute("id", "function-" + FunctionDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "function-" + FunctionDirective_1.titleIdCounter); } }; var FunctionDirective_1; FunctionDirective.titleIdCounter = 0; FunctionDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], FunctionDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FunctionDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], FunctionDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], FunctionDirective.prototype, "size", void 0); FunctionDirective = FunctionDirective_1 = __decorate([ Directive({ selector: "[ibmIconFunction]" }), __metadata("design:paramtypes", [ElementRef]) ], FunctionDirective); return FunctionDirective; }()); var FunctionModule = /** @class */ (function () { function FunctionModule() { } FunctionModule = __decorate([ NgModule({ declarations: [ FunctionComponent, FunctionDirective, ], exports: [ FunctionComponent, FunctionDirective, ] }) ], FunctionModule); return FunctionModule; }()); export { FunctionComponent, FunctionDirective, FunctionModule };