UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.35 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var DownloadComponent = /** @class */ (function () { function DownloadComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], DownloadComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DownloadComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DownloadComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadComponent.prototype, "size", void 0); DownloadComponent = __decorate([ Component({ selector: "ibm-icon-download", template: "\n <svg\n ibmIconDownload\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 " }) ], DownloadComponent); return DownloadComponent; }()); var DownloadDirective = /** @class */ (function () { function DownloadDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Download32", "filepath": "download/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 15L24.59 13.59 17 21.17 17 2 15 2 15 21.17 7.41 13.59 6 15 16 25 26 15z" } }, { "elem": "path", "attrs": { "d": "M26,24v4H6V24H4v4H4a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2h0V24Z" } }], "name": "download", "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 15L24.59 13.59 17 21.17 17 2 15 2 15 21.17 7.41 13.59 6 15 16 25 26 15z\"></path><path d=\"M26,24v4H6V24H4v4H4a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2h0V24Z\"></path></svg>" }, "24": { metadata: { "moduleName": "Download24", "filepath": "download/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 15L24.59 13.59 17 21.17 17 2 15 2 15 21.17 7.41 13.59 6 15 16 25 26 15z" } }, { "elem": "path", "attrs": { "d": "M26,24v4H6V24H4v4H4a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2h0V24Z" } }], "name": "download", "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 15L24.59 13.59 17 21.17 17 2 15 2 15 21.17 7.41 13.59 6 15 16 25 26 15z\"></path><path d=\"M26,24v4H6V24H4v4H4a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2h0V24Z\"></path></svg>" }, "20": { metadata: { "moduleName": "Download20", "filepath": "download/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 15L24.59 13.59 17 21.17 17 2 15 2 15 21.17 7.41 13.59 6 15 16 25 26 15z" } }, { "elem": "path", "attrs": { "d": "M26,24v4H6V24H4v4H4a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2h0V24Z" } }], "name": "download", "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 15L24.59 13.59 17 21.17 17 2 15 2 15 21.17 7.41 13.59 6 15 16 25 26 15z\"></path><path d=\"M26,24v4H6V24H4v4H4a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2h0V24Z\"></path></svg>" }, "16": { metadata: { "moduleName": "Download16", "filepath": "download/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": "M13 7L12.3 6.3 8.5 10.1 8.5 1 7.5 1 7.5 10.1 3.7 6.3 3 7 8 12zM13 12v2H3v-2H2v2l0 0c0 .6.4 1 1 1h10c.6 0 1-.4 1-1l0 0v-2H13z" } }], "name": "download", "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=\"M13 7L12.3 6.3 8.5 10.1 8.5 1 7.5 1 7.5 10.1 3.7 6.3 3 7 8 12zM13 12v2H3v-2H2v2l0 0c0 .6.4 1 1 1h10c.6 0 1-.4 1-1l0 0v-2H13z\"></path></svg>" }, }; } DownloadDirective_1 = DownloadDirective; DownloadDirective.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; DownloadDirective_1.titleIdCounter++; title.setAttribute("id", "download-" + DownloadDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "download-" + DownloadDirective_1.titleIdCounter); } }; var DownloadDirective_1; DownloadDirective.titleIdCounter = 0; DownloadDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], DownloadDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DownloadDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DownloadDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DownloadDirective.prototype, "size", void 0); DownloadDirective = DownloadDirective_1 = __decorate([ Directive({ selector: "[ibmIconDownload]" }), __metadata("design:paramtypes", [ElementRef]) ], DownloadDirective); return DownloadDirective; }()); var DownloadModule = /** @class */ (function () { function DownloadModule() { } DownloadModule = __decorate([ NgModule({ declarations: [ DownloadComponent, DownloadDirective, ], exports: [ DownloadComponent, DownloadDirective, ] }) ], DownloadModule); return DownloadModule; }()); export { DownloadComponent, DownloadDirective, DownloadModule };