UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.17 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var MinimizeComponent = /** @class */ (function () { function MinimizeComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], MinimizeComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MinimizeComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MinimizeComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeComponent.prototype, "size", void 0); MinimizeComponent = __decorate([ Component({ selector: "ibm-icon-minimize", template: "\n <svg\n ibmIconMinimize\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 " }) ], MinimizeComponent); return MinimizeComponent; }()); var MinimizeDirective = /** @class */ (function () { function MinimizeDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Minimize32", "filepath": "minimize/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": "M6 17L6 19 11.59 19 2 28.58 3.41 30 13 20.41 13 26 15 26 15 17 6 17zM30 3.42L28.59 2 19 11.59 19 6 17 6 17 15 26 15 26 13 20.41 13 30 3.42z" } }], "name": "minimize", "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=\"M6 17L6 19 11.59 19 2 28.58 3.41 30 13 20.41 13 26 15 26 15 17 6 17zM30 3.42L28.59 2 19 11.59 19 6 17 6 17 15 26 15 26 13 20.41 13 30 3.42z\"></path></svg>" }, "24": { metadata: { "moduleName": "Minimize24", "filepath": "minimize/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": "M6 17L6 19 11.59 19 2 28.58 3.41 30 13 20.41 13 26 15 26 15 17 6 17zM30 3.42L28.59 2 19 11.59 19 6 17 6 17 15 26 15 26 13 20.41 13 30 3.42z" } }], "name": "minimize", "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=\"M6 17L6 19 11.59 19 2 28.58 3.41 30 13 20.41 13 26 15 26 15 17 6 17zM30 3.42L28.59 2 19 11.59 19 6 17 6 17 15 26 15 26 13 20.41 13 30 3.42z\"></path></svg>" }, "20": { metadata: { "moduleName": "Minimize20", "filepath": "minimize/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": "M6 17L6 19 11.59 19 2 28.58 3.41 30 13 20.41 13 26 15 26 15 17 6 17zM30 3.42L28.59 2 19 11.59 19 6 17 6 17 15 26 15 26 13 20.41 13 30 3.42z" } }], "name": "minimize", "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=\"M6 17L6 19 11.59 19 2 28.58 3.41 30 13 20.41 13 26 15 26 15 17 6 17zM30 3.42L28.59 2 19 11.59 19 6 17 6 17 15 26 15 26 13 20.41 13 30 3.42z\"></path></svg>" }, "16": { metadata: { "moduleName": "Minimize16", "filepath": "minimize/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": "M2 9L2 10 5.3 10 1 14.3 1.7 15 6 10.7 6 14 7 14 7 9zM14 7L14 6 10.7 6 15 1.7 14.3 1 10 5.3 10 2 9 2 9 7z" } }], "name": "minimize", "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=\"M2 9L2 10 5.3 10 1 14.3 1.7 15 6 10.7 6 14 7 14 7 9zM14 7L14 6 10.7 6 15 1.7 14.3 1 10 5.3 10 2 9 2 9 7z\"></path></svg>" }, }; } MinimizeDirective_1 = MinimizeDirective; MinimizeDirective.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; MinimizeDirective_1.titleIdCounter++; title.setAttribute("id", "minimize-" + MinimizeDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "minimize-" + MinimizeDirective_1.titleIdCounter); } }; var MinimizeDirective_1; MinimizeDirective.titleIdCounter = 0; MinimizeDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], MinimizeDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MinimizeDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], MinimizeDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], MinimizeDirective.prototype, "size", void 0); MinimizeDirective = MinimizeDirective_1 = __decorate([ Directive({ selector: "[ibmIconMinimize]" }), __metadata("design:paramtypes", [ElementRef]) ], MinimizeDirective); return MinimizeDirective; }()); var MinimizeModule = /** @class */ (function () { function MinimizeModule() { } MinimizeModule = __decorate([ NgModule({ declarations: [ MinimizeComponent, MinimizeDirective, ], exports: [ MinimizeComponent, MinimizeDirective, ] }) ], MinimizeModule); return MinimizeModule; }()); export { MinimizeComponent, MinimizeDirective, MinimizeModule };