UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.06 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var QOperationIfComponent = /** @class */ (function () { function QOperationIfComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], QOperationIfComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QOperationIfComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QOperationIfComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfComponent.prototype, "size", void 0); QOperationIfComponent = __decorate([ Component({ selector: "ibm-icon-q-operation-if", template: "\n <svg\n ibmIconQOperationIf\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 " }) ], QOperationIfComponent); return QOperationIfComponent; }()); var QOperationIfDirective = /** @class */ (function () { function QOperationIfDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "QOperationIf32", "filepath": "Q/operation--if/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": "M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z" } }], "name": "operation--if", "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=\"M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z\"></path></svg>" }, "24": { metadata: { "moduleName": "QOperationIf24", "filepath": "Q/operation--if/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": "M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z" } }], "name": "operation--if", "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=\"M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z\"></path></svg>" }, "20": { metadata: { "moduleName": "QOperationIf20", "filepath": "Q/operation--if/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": "M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z" } }], "name": "operation--if", "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=\"M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z\"></path></svg>" }, "16": { metadata: { "moduleName": "QOperationIf16", "filepath": "Q/operation--if/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": "M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z" } }], "name": "operation--if", "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=\"M12 13H14V23H12zM12 9H14V11H12zM23 11V9H20a2 2 0 00-2 2v2H16v2h2v8h2V15h3V13H20V11z\"></path></svg>" }, }; } QOperationIfDirective_1 = QOperationIfDirective; QOperationIfDirective.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; QOperationIfDirective_1.titleIdCounter++; title.setAttribute("id", "q-operation-if-" + QOperationIfDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "q-operation-if-" + QOperationIfDirective_1.titleIdCounter); } }; var QOperationIfDirective_1; QOperationIfDirective.titleIdCounter = 0; QOperationIfDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], QOperationIfDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QOperationIfDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], QOperationIfDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], QOperationIfDirective.prototype, "size", void 0); QOperationIfDirective = QOperationIfDirective_1 = __decorate([ Directive({ selector: "[ibmIconQOperationIf]" }), __metadata("design:paramtypes", [ElementRef]) ], QOperationIfDirective); return QOperationIfDirective; }()); var QOperationIfModule = /** @class */ (function () { function QOperationIfModule() { } QOperationIfModule = __decorate([ NgModule({ declarations: [ QOperationIfComponent, QOperationIfDirective, ], exports: [ QOperationIfComponent, QOperationIfDirective, ] }) ], QOperationIfModule); return QOperationIfModule; }()); export { QOperationIfComponent, QOperationIfDirective, QOperationIfModule };