UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 12.7 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var JsonReferenceComponent = /** @class */ (function () { function JsonReferenceComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], JsonReferenceComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], JsonReferenceComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceComponent.prototype, "size", void 0); JsonReferenceComponent = __decorate([ Component({ selector: "ibm-icon-json-reference", template: "\n <svg\n ibmIconJsonReference\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 " }) ], JsonReferenceComponent); return JsonReferenceComponent; }()); var JsonReferenceDirective = /** @class */ (function () { function JsonReferenceDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "JsonReference32", "filepath": "JSON--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z" } }], "name": "JSON--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z\"></path></svg>" }, "24": { metadata: { "moduleName": "JsonReference24", "filepath": "JSON--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z" } }], "name": "JSON--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z\"></path></svg>" }, "20": { metadata: { "moduleName": "JsonReference20", "filepath": "JSON--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z" } }], "name": "JSON--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z\"></path></svg>" }, "16": { metadata: { "moduleName": "JsonReference16", "filepath": "JSON--reference/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": "M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z" } }], "name": "JSON--reference", "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=\"M4 20L4 22 8.586 22 2 28.586 3.414 30 10 23.414 10 28 12 28 12 20 4 20zM29 12L27 6 25 6 25 16 27 16 27 10 29 16 31 16 31 6 29 6 29 12zM21.3335 6h-2.667A1.6683 1.6683 0 0017 7.6665v6.667A1.6684 1.6684 0 0018.6665 16h2.667A1.6683 1.6683 0 0023 14.3335V7.6665A1.6683 1.6683 0 0021.3335 6zM21 14H19V8h2zM9 7.6665V10a2.002 2.002 0 002 2h2v2H9v2h4.3335A1.6683 1.6683 0 0015 14.3335V12a2.002 2.002 0 00-2-2H11V8h4V6H10.6665A1.6683 1.6683 0 009 7.6665zM5 14H3V12H1v2.3335A1.6684 1.6684 0 002.6665 16h2.667A1.6683 1.6683 0 007 14.3335V6H5z\"></path></svg>" }, }; } JsonReferenceDirective_1 = JsonReferenceDirective; JsonReferenceDirective.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; JsonReferenceDirective_1.titleIdCounter++; title.setAttribute("id", "json-reference-" + JsonReferenceDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "json-reference-" + JsonReferenceDirective_1.titleIdCounter); } }; var JsonReferenceDirective_1; JsonReferenceDirective.titleIdCounter = 0; JsonReferenceDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], JsonReferenceDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], JsonReferenceDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], JsonReferenceDirective.prototype, "size", void 0); JsonReferenceDirective = JsonReferenceDirective_1 = __decorate([ Directive({ selector: "[ibmIconJsonReference]" }), __metadata("design:paramtypes", [ElementRef]) ], JsonReferenceDirective); return JsonReferenceDirective; }()); var JsonReferenceModule = /** @class */ (function () { function JsonReferenceModule() { } JsonReferenceModule = __decorate([ NgModule({ declarations: [ JsonReferenceComponent, JsonReferenceDirective, ], exports: [ JsonReferenceComponent, JsonReferenceDirective, ] }) ], JsonReferenceModule); return JsonReferenceModule; }()); export { JsonReferenceComponent, JsonReferenceDirective, JsonReferenceModule };