UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.43 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ConnectComponent = /** @class */ (function () { function ConnectComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], ConnectComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ConnectComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ConnectComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectComponent.prototype, "size", void 0); ConnectComponent = __decorate([ Component({ selector: "ibm-icon-connect", template: "\n <svg\n ibmIconConnect\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 " }) ], ConnectComponent); return ConnectComponent; }()); var ConnectDirective = /** @class */ (function () { function ConnectDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Connect32", "filepath": "connect/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": "M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z", "transform": "translate(0 .01)" } }], "name": "connect", "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=\"M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z\" transform=\"translate(0 .01)\"></path></svg>" }, "24": { metadata: { "moduleName": "Connect24", "filepath": "connect/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": "M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z", "transform": "translate(0 .01)" } }], "name": "connect", "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=\"M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z\" transform=\"translate(0 .01)\"></path></svg>" }, "20": { metadata: { "moduleName": "Connect20", "filepath": "connect/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": "M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z", "transform": "translate(0 .01)" } }], "name": "connect", "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=\"M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z\" transform=\"translate(0 .01)\"></path></svg>" }, "16": { metadata: { "moduleName": "Connect16", "filepath": "connect/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": "M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z", "transform": "translate(0 .01)" } }], "name": "connect", "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=\"M23,16a7,7,0,0,0-4.18,1.39L14.6,13.17A6.86,6.86,0,0,0,16,9a7,7,0,1,0-2.81,5.59l4.21,4.22A7,7,0,1,0,23,16ZM4,9a5,5,0,1,1,5,5A5,5,0,0,1,4,9Z\" transform=\"translate(0 .01)\"></path></svg>" }, }; } ConnectDirective_1 = ConnectDirective; ConnectDirective.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; ConnectDirective_1.titleIdCounter++; title.setAttribute("id", "connect-" + ConnectDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "connect-" + ConnectDirective_1.titleIdCounter); } }; var ConnectDirective_1; ConnectDirective.titleIdCounter = 0; ConnectDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], ConnectDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ConnectDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ConnectDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ConnectDirective.prototype, "size", void 0); ConnectDirective = ConnectDirective_1 = __decorate([ Directive({ selector: "[ibmIconConnect]" }), __metadata("design:paramtypes", [ElementRef]) ], ConnectDirective); return ConnectDirective; }()); var ConnectModule = /** @class */ (function () { function ConnectModule() { } ConnectModule = __decorate([ NgModule({ declarations: [ ConnectComponent, ConnectDirective, ], exports: [ ConnectComponent, ConnectDirective, ] }) ], ConnectModule); return ConnectModule; }()); export { ConnectComponent, ConnectDirective, ConnectModule };