UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.16 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var NewTabComponent = /** @class */ (function () { function NewTabComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], NewTabComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NewTabComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NewTabComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabComponent.prototype, "size", void 0); NewTabComponent = __decorate([ Component({ selector: "ibm-icon-new-tab", template: "\n <svg\n ibmIconNewTab\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 " }) ], NewTabComponent); return NewTabComponent; }()); var NewTabDirective = /** @class */ (function () { function NewTabDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "NewTab32", "filepath": "new-tab/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 26H6V6h9V4H6A2 2 0 004 6V26a2 2 0 002 2H26a2 2 0 002-2V17H26zM26 6L26 2 24 2 24 6 20 6 20 8 24 8 24 12 26 12 26 8 30 8 30 6 26 6z" } }], "name": "new-tab", "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 26H6V6h9V4H6A2 2 0 004 6V26a2 2 0 002 2H26a2 2 0 002-2V17H26zM26 6L26 2 24 2 24 6 20 6 20 8 24 8 24 12 26 12 26 8 30 8 30 6 26 6z\"></path></svg>" }, "24": { metadata: { "moduleName": "NewTab24", "filepath": "new-tab/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 26H6V6h9V4H6A2 2 0 004 6V26a2 2 0 002 2H26a2 2 0 002-2V17H26zM26 6L26 2 24 2 24 6 20 6 20 8 24 8 24 12 26 12 26 8 30 8 30 6 26 6z" } }], "name": "new-tab", "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 26H6V6h9V4H6A2 2 0 004 6V26a2 2 0 002 2H26a2 2 0 002-2V17H26zM26 6L26 2 24 2 24 6 20 6 20 8 24 8 24 12 26 12 26 8 30 8 30 6 26 6z\"></path></svg>" }, "20": { metadata: { "moduleName": "NewTab20", "filepath": "new-tab/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 26H6V6h9V4H6A2 2 0 004 6V26a2 2 0 002 2H26a2 2 0 002-2V17H26zM26 6L26 2 24 2 24 6 20 6 20 8 24 8 24 12 26 12 26 8 30 8 30 6 26 6z" } }], "name": "new-tab", "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 26H6V6h9V4H6A2 2 0 004 6V26a2 2 0 002 2H26a2 2 0 002-2V17H26zM26 6L26 2 24 2 24 6 20 6 20 8 24 8 24 12 26 12 26 8 30 8 30 6 26 6z\"></path></svg>" }, "16": { metadata: { "moduleName": "NewTab16", "filepath": "new-tab/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,13H3V3h5V2H3C2.4,2,2,2.4,2,3v10c0,0.6,0.4,1,1,1h10c0.6,0,1-0.4,1-1V8h-1V13z" } }, { "elem": "path", "attrs": { "d": "M13 3L13 1 12 1 12 3 10 3 10 4 12 4 12 6 13 6 13 4 15 4 15 3z" } }], "name": "new-tab", "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,13H3V3h5V2H3C2.4,2,2,2.4,2,3v10c0,0.6,0.4,1,1,1h10c0.6,0,1-0.4,1-1V8h-1V13z\"></path><path d=\"M13 3L13 1 12 1 12 3 10 3 10 4 12 4 12 6 13 6 13 4 15 4 15 3z\"></path></svg>" }, }; } NewTabDirective_1 = NewTabDirective; NewTabDirective.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; NewTabDirective_1.titleIdCounter++; title.setAttribute("id", "new-tab-" + NewTabDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "new-tab-" + NewTabDirective_1.titleIdCounter); } }; var NewTabDirective_1; NewTabDirective.titleIdCounter = 0; NewTabDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], NewTabDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NewTabDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NewTabDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], NewTabDirective.prototype, "size", void 0); NewTabDirective = NewTabDirective_1 = __decorate([ Directive({ selector: "[ibmIconNewTab]" }), __metadata("design:paramtypes", [ElementRef]) ], NewTabDirective); return NewTabDirective; }()); var NewTabModule = /** @class */ (function () { function NewTabModule() { } NewTabModule = __decorate([ NgModule({ declarations: [ NewTabComponent, NewTabDirective, ], exports: [ NewTabComponent, NewTabDirective, ] }) ], NewTabModule); return NewTabModule; }()); export { NewTabComponent, NewTabDirective, NewTabModule };