UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 14.8 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var DeploymentPatternComponent = /** @class */ (function () { function DeploymentPatternComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DeploymentPatternComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DeploymentPatternComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternComponent.prototype, "size", void 0); DeploymentPatternComponent = __decorate([ Component({ selector: "ibm-icon-deployment-pattern", template: "\n <svg\n ibmIconDeploymentPattern\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 " }) ], DeploymentPatternComponent); return DeploymentPatternComponent; }()); var DeploymentPatternDirective = /** @class */ (function () { function DeploymentPatternDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "DeploymentPattern32", "filepath": "deployment-pattern/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": "M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z" } }, { "elem": "path", "attrs": { "d": "M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z" } }, { "elem": "path", "attrs": { "d": "M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z" } }, { "elem": "path", "attrs": { "d": "M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z" } }, { "elem": "path", "attrs": { "d": "M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z" } }], "name": "deployment-pattern", "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=\"M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z\"></path><path d=\"M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z\"></path><path d=\"M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z\"></path><path d=\"M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z\"></path><path d=\"M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z\"></path></svg>" }, "24": { metadata: { "moduleName": "DeploymentPattern24", "filepath": "deployment-pattern/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": "M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z" } }, { "elem": "path", "attrs": { "d": "M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z" } }, { "elem": "path", "attrs": { "d": "M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z" } }, { "elem": "path", "attrs": { "d": "M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z" } }, { "elem": "path", "attrs": { "d": "M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z" } }], "name": "deployment-pattern", "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=\"M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z\"></path><path d=\"M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z\"></path><path d=\"M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z\"></path><path d=\"M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z\"></path><path d=\"M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z\"></path></svg>" }, "20": { metadata: { "moduleName": "DeploymentPattern20", "filepath": "deployment-pattern/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": "M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z" } }, { "elem": "path", "attrs": { "d": "M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z" } }, { "elem": "path", "attrs": { "d": "M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z" } }, { "elem": "path", "attrs": { "d": "M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z" } }, { "elem": "path", "attrs": { "d": "M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z" } }], "name": "deployment-pattern", "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=\"M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z\"></path><path d=\"M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z\"></path><path d=\"M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z\"></path><path d=\"M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z\"></path><path d=\"M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z\"></path></svg>" }, "16": { metadata: { "moduleName": "DeploymentPattern16", "filepath": "deployment-pattern/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": "M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z" } }, { "elem": "path", "attrs": { "d": "M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z" } }, { "elem": "path", "attrs": { "d": "M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z" } }, { "elem": "path", "attrs": { "d": "M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z" } }, { "elem": "path", "attrs": { "d": "M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z" } }], "name": "deployment-pattern", "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=\"M8 20H4.73A1.9735 1.9735 0 003 19a2 2 0 000 4A1.9735 1.9735 0 004.73 22H8zM29 9a1.9735 1.9735 0 00-1.73 1H24v2h3.27A1.9991 1.9991 0 1029 9z\"></path><path d=\"M25.4141 5L21 .5859 16.5859 5 20 8.4141V18h2V8.4141zM21 3.4141L22.5859 5 21 6.5859 19.4141 5zM12 23.5859V14H10v9.5859L6.5859 27 11 31.4141 15.4141 27zM9.4141 27L11 25.4141 12.5859 27 11 28.5859z\"></path><path d=\"M18,10H8.4141L5,6.5859.5859,11,5,15.4141,8.4141,12H18ZM5,12.5859,3.4141,11,5,9.4141,6.5859,11Z\"></path><path d=\"M13 3A2 2 0 009 3 1.9733 1.9733 0 0010 4.73V8h2V4.73A1.9733 1.9733 0 0013 3zM22 27.2705V24H20v3.27a2 2 0 102 0z\"></path><path d=\"M31.4141,21,27,16.5859,23.5859,20H14v2h9.5859L27,25.4141ZM27,19.4141,28.5859,21,27,22.5859,25.4141,21Z\"></path></svg>" }, }; } DeploymentPatternDirective_1 = DeploymentPatternDirective; DeploymentPatternDirective.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; DeploymentPatternDirective_1.titleIdCounter++; title.setAttribute("id", "deployment-pattern-" + DeploymentPatternDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "deployment-pattern-" + DeploymentPatternDirective_1.titleIdCounter); } }; var DeploymentPatternDirective_1; DeploymentPatternDirective.titleIdCounter = 0; DeploymentPatternDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DeploymentPatternDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DeploymentPatternDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DeploymentPatternDirective.prototype, "size", void 0); DeploymentPatternDirective = DeploymentPatternDirective_1 = __decorate([ Directive({ selector: "[ibmIconDeploymentPattern]" }), __metadata("design:paramtypes", [ElementRef]) ], DeploymentPatternDirective); return DeploymentPatternDirective; }()); var DeploymentPatternModule = /** @class */ (function () { function DeploymentPatternModule() { } DeploymentPatternModule = __decorate([ NgModule({ declarations: [ DeploymentPatternComponent, DeploymentPatternDirective, ], exports: [ DeploymentPatternComponent, DeploymentPatternDirective, ] }) ], DeploymentPatternModule); return DeploymentPatternModule; }()); export { DeploymentPatternComponent, DeploymentPatternDirective, DeploymentPatternModule };