UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.83 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var MovComponent = /** @class */ (function () { function MovComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], MovComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MovComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MovComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovComponent.prototype, "size", void 0); MovComponent = __decorate([ Component({ selector: "ibm-icon-mov", template: "\n <svg\n ibmIconMov\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 " }) ], MovComponent); return MovComponent; }()); var MovDirective = /** @class */ (function () { function MovDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Mov32", "filepath": "MOV/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": "M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z" } }], "name": "MOV", "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=\"M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z\"></path></svg>" }, "24": { metadata: { "moduleName": "Mov24", "filepath": "MOV/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": "M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z" } }], "name": "MOV", "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=\"M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z\"></path></svg>" }, "20": { metadata: { "moduleName": "Mov20", "filepath": "MOV/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": "M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z" } }], "name": "MOV", "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=\"M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z\"></path></svg>" }, "16": { metadata: { "moduleName": "Mov16", "filepath": "MOV/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": "M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z" } }], "name": "MOV", "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=\"M28 9L26 22 24 9 22 9 24.52 23 27.48 23 30 9 28 9zM18 23H14a2 2 0 01-2-2V11a2 2 0 012-2h4a2 2 0 012 2V21A2 2 0 0118 23zM14 11V21h4V11zM8 9L6.49 14 6 15.98 5.54 14 4 9 2 9 2 23 4 23 4 15 3.84 13 4.42 15 6 19.63 7.58 15 8.16 13 8 15 8 23 10 23 10 9 8 9z\"></path></svg>" }, }; } MovDirective_1 = MovDirective; MovDirective.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; MovDirective_1.titleIdCounter++; title.setAttribute("id", "mov-" + MovDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "mov-" + MovDirective_1.titleIdCounter); } }; var MovDirective_1; MovDirective.titleIdCounter = 0; MovDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], MovDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MovDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MovDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MovDirective.prototype, "size", void 0); MovDirective = MovDirective_1 = __decorate([ Directive({ selector: "[ibmIconMov]" }), __metadata("design:paramtypes", [ElementRef]) ], MovDirective); return MovDirective; }()); var MovModule = /** @class */ (function () { function MovModule() { } MovModule = __decorate([ NgModule({ declarations: [ MovComponent, MovDirective, ], exports: [ MovComponent, MovDirective, ] }) ], MovModule); return MovModule; }()); export { MovComponent, MovDirective, MovModule };