UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 13.2 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var EdgeNodeComponent = /** @class */ (function () { function EdgeNodeComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EdgeNodeComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EdgeNodeComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeComponent.prototype, "size", void 0); EdgeNodeComponent = __decorate([ Component({ selector: "ibm-icon-edge-node", template: "\n <svg\n ibmIconEdgeNode\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 " }) ], EdgeNodeComponent); return EdgeNodeComponent; }()); var EdgeNodeDirective = /** @class */ (function () { function EdgeNodeDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "EdgeNode32", "filepath": "edge-node/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": "M22 6H26V10H22z" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "25", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "21", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "17", "r": "1" } }, { "elem": "path", "attrs": { "d": "M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z" } }, { "elem": "path", "attrs": { "d": "M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z" } }], "name": "edge-node", "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=\"M22 6H26V10H22z\"></path><circle cx=\"7\" cy=\"7\" r=\"1\"></circle><circle cx=\"25\" cy=\"25\" r=\"1\"></circle><circle cx=\"25\" cy=\"21\" r=\"1\"></circle><circle cx=\"25\" cy=\"17\" r=\"1\"></circle><path d=\"M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z\"></path><path d=\"M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z\"></path></svg>" }, "24": { metadata: { "moduleName": "EdgeNode24", "filepath": "edge-node/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": "M22 6H26V10H22z" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "25", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "21", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "17", "r": "1" } }, { "elem": "path", "attrs": { "d": "M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z" } }, { "elem": "path", "attrs": { "d": "M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z" } }], "name": "edge-node", "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=\"M22 6H26V10H22z\"></path><circle cx=\"7\" cy=\"7\" r=\"1\"></circle><circle cx=\"25\" cy=\"25\" r=\"1\"></circle><circle cx=\"25\" cy=\"21\" r=\"1\"></circle><circle cx=\"25\" cy=\"17\" r=\"1\"></circle><path d=\"M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z\"></path><path d=\"M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z\"></path></svg>" }, "20": { metadata: { "moduleName": "EdgeNode20", "filepath": "edge-node/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": "M22 6H26V10H22z" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "25", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "21", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "17", "r": "1" } }, { "elem": "path", "attrs": { "d": "M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z" } }, { "elem": "path", "attrs": { "d": "M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z" } }], "name": "edge-node", "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=\"M22 6H26V10H22z\"></path><circle cx=\"7\" cy=\"7\" r=\"1\"></circle><circle cx=\"25\" cy=\"25\" r=\"1\"></circle><circle cx=\"25\" cy=\"21\" r=\"1\"></circle><circle cx=\"25\" cy=\"17\" r=\"1\"></circle><path d=\"M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z\"></path><path d=\"M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z\"></path></svg>" }, "16": { metadata: { "moduleName": "EdgeNode16", "filepath": "edge-node/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": "M22 6H26V10H22z" } }, { "elem": "circle", "attrs": { "cx": "7", "cy": "7", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "25", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "21", "r": "1" } }, { "elem": "circle", "attrs": { "cx": "25", "cy": "17", "r": "1" } }, { "elem": "path", "attrs": { "d": "M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z" } }, { "elem": "path", "attrs": { "d": "M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z" } }], "name": "edge-node", "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=\"M22 6H26V10H22z\"></path><circle cx=\"7\" cy=\"7\" r=\"1\"></circle><circle cx=\"25\" cy=\"25\" r=\"1\"></circle><circle cx=\"25\" cy=\"21\" r=\"1\"></circle><circle cx=\"25\" cy=\"17\" r=\"1\"></circle><path d=\"M22,17V15H20V14a2.0023,2.0023,0,0,0-2-2H17V10H15v2H13V10H11v2H10a2.0023,2.0023,0,0,0-2,2v1H6v2H8v2H6v2H8v1a2.0023,2.0023,0,0,0,2,2h1v2h2V24h2v2h2V24h1a2.0023,2.0023,0,0,0,2-2V21h2V19H20V17Zm-4,5H10V14h8Z\"></path><path d=\"M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z\"></path></svg>" }, }; } EdgeNodeDirective_1 = EdgeNodeDirective; EdgeNodeDirective.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; EdgeNodeDirective_1.titleIdCounter++; title.setAttribute("id", "edge-node-" + EdgeNodeDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "edge-node-" + EdgeNodeDirective_1.titleIdCounter); } }; var EdgeNodeDirective_1; EdgeNodeDirective.titleIdCounter = 0; EdgeNodeDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EdgeNodeDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EdgeNodeDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], EdgeNodeDirective.prototype, "size", void 0); EdgeNodeDirective = EdgeNodeDirective_1 = __decorate([ Directive({ selector: "[ibmIconEdgeNode]" }), __metadata("design:paramtypes", [ElementRef]) ], EdgeNodeDirective); return EdgeNodeDirective; }()); var EdgeNodeModule = /** @class */ (function () { function EdgeNodeModule() { } EdgeNodeModule = __decorate([ NgModule({ declarations: [ EdgeNodeComponent, EdgeNodeDirective, ], exports: [ EdgeNodeComponent, EdgeNodeDirective, ] }) ], EdgeNodeModule); return EdgeNodeModule; }()); export { EdgeNodeComponent, EdgeNodeDirective, EdgeNodeModule };