UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.93 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var EnterpriseComponent = /** @class */ (function () { function EnterpriseComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], EnterpriseComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EnterpriseComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EnterpriseComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseComponent.prototype, "size", void 0); EnterpriseComponent = __decorate([ Component({ selector: "ibm-icon-enterprise", template: "\n <svg\n ibmIconEnterprise\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 " }) ], EnterpriseComponent); return EnterpriseComponent; }()); var EnterpriseDirective = /** @class */ (function () { function EnterpriseDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Enterprise32", "filepath": "enterprise/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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z" } }, { "elem": "path", "attrs": { "d": "M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z" } }], "name": "enterprise", "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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z\"></path><path d=\"M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z\"></path></svg>" }, "24": { metadata: { "moduleName": "Enterprise24", "filepath": "enterprise/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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z" } }, { "elem": "path", "attrs": { "d": "M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z" } }], "name": "enterprise", "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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z\"></path><path d=\"M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z\"></path></svg>" }, "20": { metadata: { "moduleName": "Enterprise20", "filepath": "enterprise/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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z" } }, { "elem": "path", "attrs": { "d": "M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z" } }], "name": "enterprise", "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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z\"></path><path d=\"M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z\"></path></svg>" }, "16": { metadata: { "moduleName": "Enterprise16", "filepath": "enterprise/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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z" } }, { "elem": "path", "attrs": { "d": "M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z" } }], "name": "enterprise", "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 8H10V12H8zM8 14H10V18H8zM14 8H16V12H14zM14 14H16V18H14zM8 20H10V24H8zM14 20H16V24H14z\"></path><path d=\"M30,14a2,2,0,0,0-2-2H22V4a2,2,0,0,0-2-2H4A2,2,0,0,0,2,4V30H30ZM4,4H20V28H4ZM22,28V14h6V28Z\"></path></svg>" }, }; } EnterpriseDirective_1 = EnterpriseDirective; EnterpriseDirective.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; EnterpriseDirective_1.titleIdCounter++; title.setAttribute("id", "enterprise-" + EnterpriseDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "enterprise-" + EnterpriseDirective_1.titleIdCounter); } }; var EnterpriseDirective_1; EnterpriseDirective.titleIdCounter = 0; EnterpriseDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], EnterpriseDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EnterpriseDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], EnterpriseDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], EnterpriseDirective.prototype, "size", void 0); EnterpriseDirective = EnterpriseDirective_1 = __decorate([ Directive({ selector: "[ibmIconEnterprise]" }), __metadata("design:paramtypes", [ElementRef]) ], EnterpriseDirective); return EnterpriseDirective; }()); var EnterpriseModule = /** @class */ (function () { function EnterpriseModule() { } EnterpriseModule = __decorate([ NgModule({ declarations: [ EnterpriseComponent, EnterpriseDirective, ], exports: [ EnterpriseComponent, EnterpriseDirective, ] }) ], EnterpriseModule); return EnterpriseModule; }()); export { EnterpriseComponent, EnterpriseDirective, EnterpriseModule };