UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.05 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var PowerComponent = /** @class */ (function () { function PowerComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], PowerComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PowerComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PowerComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerComponent.prototype, "size", void 0); PowerComponent = __decorate([ Component({ selector: "ibm-icon-power", template: "\n <svg\n ibmIconPower\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 " }) ], PowerComponent); return PowerComponent; }()); var PowerDirective = /** @class */ (function () { function PowerDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Power32", "filepath": "power/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": "M22.5,5.74l-1,1.73a11,11,0,1,1-11,0l-1-1.73a13,13,0,1,0,13,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V16H15z" } }], "name": "power", "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=\"M22.5,5.74l-1,1.73a11,11,0,1,1-11,0l-1-1.73a13,13,0,1,0,13,0Z\"></path><path d=\"M15 2H17V16H15z\"></path></svg>" }, "24": { metadata: { "moduleName": "Power24", "filepath": "power/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": "M22.5,5.74l-1,1.73a11,11,0,1,1-11,0l-1-1.73a13,13,0,1,0,13,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V16H15z" } }], "name": "power", "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=\"M22.5,5.74l-1,1.73a11,11,0,1,1-11,0l-1-1.73a13,13,0,1,0,13,0Z\"></path><path d=\"M15 2H17V16H15z\"></path></svg>" }, "20": { metadata: { "moduleName": "Power20", "filepath": "power/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": "M22.5,5.74l-1,1.73a11,11,0,1,1-11,0l-1-1.73a13,13,0,1,0,13,0Z" } }, { "elem": "path", "attrs": { "d": "M15 2H17V16H15z" } }], "name": "power", "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=\"M22.5,5.74l-1,1.73a11,11,0,1,1-11,0l-1-1.73a13,13,0,1,0,13,0Z\"></path><path d=\"M15 2H17V16H15z\"></path></svg>" }, "16": { metadata: { "moduleName": "Power16", "filepath": "power/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 16 16", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M11.2,2.9l-0.5,0.9c2.6,1.5,3.5,4.9,2,7.5s-4.9,3.5-7.5,2s-3.5-4.9-2-7.5c0.5-0.8,1.2-1.5,2-2L4.8,2.9\tc-3.1,1.8-4.2,5.8-2.4,8.9s5.8,4.2,8.9,2.4s4.2-5.8,2.4-8.9C13.1,4.3,12.2,3.4,11.2,2.9z" } }, { "elem": "path", "attrs": { "d": "M7.5 1H8.5V8H7.5z" } }], "name": "power", "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 16 16\" aria-hidden=\"true\"><path d=\"M11.2,2.9l-0.5,0.9c2.6,1.5,3.5,4.9,2,7.5s-4.9,3.5-7.5,2s-3.5-4.9-2-7.5c0.5-0.8,1.2-1.5,2-2L4.8,2.9\tc-3.1,1.8-4.2,5.8-2.4,8.9s5.8,4.2,8.9,2.4s4.2-5.8,2.4-8.9C13.1,4.3,12.2,3.4,11.2,2.9z\"></path><path d=\"M7.5 1H8.5V8H7.5z\"></path></svg>" }, }; } PowerDirective_1 = PowerDirective; PowerDirective.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; PowerDirective_1.titleIdCounter++; title.setAttribute("id", "power-" + PowerDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "power-" + PowerDirective_1.titleIdCounter); } }; var PowerDirective_1; PowerDirective.titleIdCounter = 0; PowerDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], PowerDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PowerDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PowerDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], PowerDirective.prototype, "size", void 0); PowerDirective = PowerDirective_1 = __decorate([ Directive({ selector: "[ibmIconPower]" }), __metadata("design:paramtypes", [ElementRef]) ], PowerDirective); return PowerDirective; }()); var PowerModule = /** @class */ (function () { function PowerModule() { } PowerModule = __decorate([ NgModule({ declarations: [ PowerComponent, PowerDirective, ], exports: [ PowerComponent, PowerDirective, ] }) ], PowerModule); return PowerModule; }()); export { PowerComponent, PowerDirective, PowerModule };