UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 11.2 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var WatsonHealthHangingProtocolDirective_1; let WatsonHealthHangingProtocolComponent = class WatsonHealthHangingProtocolComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthHangingProtocolComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthHangingProtocolComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolComponent.prototype, "size", void 0); WatsonHealthHangingProtocolComponent = __decorate([ Component({ selector: "ibm-icon-watson-health-hanging-protocol", template: ` <svg ibmIconWatsonHealthHangingProtocol [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], WatsonHealthHangingProtocolComponent); let WatsonHealthHangingProtocolDirective = WatsonHealthHangingProtocolDirective_1 = class WatsonHealthHangingProtocolDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "WatsonHealthHangingProtocol32", "filepath": "watson-health/hanging-protocol/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": "M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z" } }], "name": "hanging-protocol", "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="M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z"></path></svg>` }, "24": { metadata: { "moduleName": "WatsonHealthHangingProtocol24", "filepath": "watson-health/hanging-protocol/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": "M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z" } }], "name": "hanging-protocol", "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="M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z"></path></svg>` }, "20": { metadata: { "moduleName": "WatsonHealthHangingProtocol20", "filepath": "watson-health/hanging-protocol/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": "M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z" } }], "name": "hanging-protocol", "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="M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z"></path></svg>` }, "16": { metadata: { "moduleName": "WatsonHealthHangingProtocol16", "filepath": "watson-health/hanging-protocol/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": "M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z" } }], "name": "hanging-protocol", "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="M26.37,20.52,17,15.41V13.86A4,4,0,1,0,12,10h2a2,2,0,1,1,4,.34A2.08,2.08,0,0,1,15.89,12h0a.89.89,0,0,0-.89.89v2.52L5.63,20.52A3.1,3.1,0,0,0,4.25,22a2.83,2.83,0,0,0,2.56,4H25.19a2.83,2.83,0,0,0,2.56-4A3.1,3.1,0,0,0,26.37,20.52ZM25.19,24H6.81A.81.81,0,0,1,6,23.19a1,1,0,0,1,.52-.88L16,17.14l9.48,5.17a1,1,0,0,1,.52.88A.81.81,0,0,1,25.19,24Z"></path></svg>` }, }; } ngAfterViewInit() { const svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); const icon = this.icons[this.size]; const domParser = new DOMParser(); const rawSVG = icon.svg; const svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; let 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; } const 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() }); const attrKeys = Object.keys(attributes); for (let i = 0; i < attrKeys.length; i++) { const key = attrKeys[i]; const value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { const title = document.createElement("title"); title.textContent = attributes.title; WatsonHealthHangingProtocolDirective_1.titleIdCounter++; title.setAttribute("id", `watson-health-hanging-protocol-${WatsonHealthHangingProtocolDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `watson-health-hanging-protocol-${WatsonHealthHangingProtocolDirective_1.titleIdCounter}`); } } }; WatsonHealthHangingProtocolDirective.titleIdCounter = 0; WatsonHealthHangingProtocolDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthHangingProtocolDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WatsonHealthHangingProtocolDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WatsonHealthHangingProtocolDirective.prototype, "size", void 0); WatsonHealthHangingProtocolDirective = WatsonHealthHangingProtocolDirective_1 = __decorate([ Directive({ selector: "[ibmIconWatsonHealthHangingProtocol]" }), __metadata("design:paramtypes", [ElementRef]) ], WatsonHealthHangingProtocolDirective); let WatsonHealthHangingProtocolModule = class WatsonHealthHangingProtocolModule { }; WatsonHealthHangingProtocolModule = __decorate([ NgModule({ declarations: [ WatsonHealthHangingProtocolComponent, WatsonHealthHangingProtocolDirective, ], exports: [ WatsonHealthHangingProtocolComponent, WatsonHealthHangingProtocolDirective, ] }) ], WatsonHealthHangingProtocolModule); export { WatsonHealthHangingProtocolComponent, WatsonHealthHangingProtocolDirective, WatsonHealthHangingProtocolModule };