UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 10.7 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ContainerSoftwareComponent = /** @class */ (function () { function ContainerSoftwareComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ContainerSoftwareComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ContainerSoftwareComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareComponent.prototype, "size", void 0); ContainerSoftwareComponent = __decorate([ Component({ selector: "ibm-icon-container-software", template: "\n <svg\n ibmIconContainerSoftware\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 " }) ], ContainerSoftwareComponent); return ContainerSoftwareComponent; }()); var ContainerSoftwareDirective = /** @class */ (function () { function ContainerSoftwareDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ContainerSoftware32", "filepath": "container-software/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": "M28,12H20V4h8Zm-6-2h4V6H22Z" } }, { "elem": "path", "attrs": { "d": "M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z" } }], "name": "container-software", "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=\"M28,12H20V4h8Zm-6-2h4V6H22Z\"></path><path d=\"M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z\"></path></svg>" }, "24": { metadata: { "moduleName": "ContainerSoftware24", "filepath": "container-software/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": "M28,12H20V4h8Zm-6-2h4V6H22Z" } }, { "elem": "path", "attrs": { "d": "M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z" } }], "name": "container-software", "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=\"M28,12H20V4h8Zm-6-2h4V6H22Z\"></path><path d=\"M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z\"></path></svg>" }, "20": { metadata: { "moduleName": "ContainerSoftware20", "filepath": "container-software/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": "M28,12H20V4h8Zm-6-2h4V6H22Z" } }, { "elem": "path", "attrs": { "d": "M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z" } }], "name": "container-software", "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=\"M28,12H20V4h8Zm-6-2h4V6H22Z\"></path><path d=\"M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z\"></path></svg>" }, "16": { metadata: { "moduleName": "ContainerSoftware16", "filepath": "container-software/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": "M28,12H20V4h8Zm-6-2h4V6H22Z" } }, { "elem": "path", "attrs": { "d": "M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z" } }], "name": "container-software", "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=\"M28,12H20V4h8Zm-6-2h4V6H22Z\"></path><path d=\"M17,15V9H9V23H23V15Zm-6-4h4v4H11Zm4,10H11V17h4Zm6,0H17V17h4Z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H16V6H6V26H26V16h2V26A2.0023,2.0023,0,0,1,26,28Z\"></path></svg>" }, }; } ContainerSoftwareDirective_1 = ContainerSoftwareDirective; ContainerSoftwareDirective.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; ContainerSoftwareDirective_1.titleIdCounter++; title.setAttribute("id", "container-software-" + ContainerSoftwareDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "container-software-" + ContainerSoftwareDirective_1.titleIdCounter); } }; var ContainerSoftwareDirective_1; ContainerSoftwareDirective.titleIdCounter = 0; ContainerSoftwareDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ContainerSoftwareDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ContainerSoftwareDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ContainerSoftwareDirective.prototype, "size", void 0); ContainerSoftwareDirective = ContainerSoftwareDirective_1 = __decorate([ Directive({ selector: "[ibmIconContainerSoftware]" }), __metadata("design:paramtypes", [ElementRef]) ], ContainerSoftwareDirective); return ContainerSoftwareDirective; }()); var ContainerSoftwareModule = /** @class */ (function () { function ContainerSoftwareModule() { } ContainerSoftwareModule = __decorate([ NgModule({ declarations: [ ContainerSoftwareComponent, ContainerSoftwareDirective, ], exports: [ ContainerSoftwareComponent, ContainerSoftwareDirective, ] }) ], ContainerSoftwareModule); return ContainerSoftwareModule; }()); export { ContainerSoftwareComponent, ContainerSoftwareDirective, ContainerSoftwareModule };