UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.82 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var RowCollapseComponent = /** @class */ (function () { function RowCollapseComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], RowCollapseComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RowCollapseComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RowCollapseComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseComponent.prototype, "size", void 0); RowCollapseComponent = __decorate([ Component({ selector: "ibm-icon-row-collapse", template: "\n <svg\n ibmIconRowCollapse\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 " }) ], RowCollapseComponent); return RowCollapseComponent; }()); var RowCollapseDirective = /** @class */ (function () { function RowCollapseDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "RowCollapse32", "filepath": "row--collapse/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": "M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z" } }], "name": "row--collapse", "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=\"M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z\"></path></svg>" }, "24": { metadata: { "moduleName": "RowCollapse24", "filepath": "row--collapse/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": "M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z" } }], "name": "row--collapse", "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=\"M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z\"></path></svg>" }, "20": { metadata: { "moduleName": "RowCollapse20", "filepath": "row--collapse/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": "M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z" } }], "name": "row--collapse", "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=\"M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z\"></path></svg>" }, "16": { metadata: { "moduleName": "RowCollapse16", "filepath": "row--collapse/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": "M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z" } }], "name": "row--collapse", "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=\"M26 20H6a2 2 0 00-2 2v4a2 2 0 002 2H26a2 2 0 002-2V22A2 2 0 0026 20zm0 6H6V22H26zM17 7.828L19.586 10.414 21 9 16 4 11 9 12.414 10.414 15 7.828 15 14 4 14 4 16 28 16 28 14 17 14 17 7.828z\"></path></svg>" }, }; } RowCollapseDirective_1 = RowCollapseDirective; RowCollapseDirective.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; RowCollapseDirective_1.titleIdCounter++; title.setAttribute("id", "row-collapse-" + RowCollapseDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "row-collapse-" + RowCollapseDirective_1.titleIdCounter); } }; var RowCollapseDirective_1; RowCollapseDirective.titleIdCounter = 0; RowCollapseDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], RowCollapseDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RowCollapseDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RowCollapseDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], RowCollapseDirective.prototype, "size", void 0); RowCollapseDirective = RowCollapseDirective_1 = __decorate([ Directive({ selector: "[ibmIconRowCollapse]" }), __metadata("design:paramtypes", [ElementRef]) ], RowCollapseDirective); return RowCollapseDirective; }()); var RowCollapseModule = /** @class */ (function () { function RowCollapseModule() { } RowCollapseModule = __decorate([ NgModule({ declarations: [ RowCollapseComponent, RowCollapseDirective, ], exports: [ RowCollapseComponent, RowCollapseDirective, ] }) ], RowCollapseModule); return RowCollapseModule; }()); export { RowCollapseComponent, RowCollapseDirective, RowCollapseModule };