UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 14.6 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var HearingDirective_1; let HearingComponent = class HearingComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], HearingComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HearingComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HearingComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingComponent.prototype, "size", void 0); HearingComponent = __decorate([ Component({ selector: "ibm-icon-hearing", template: ` <svg ibmIconHearing [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], HearingComponent); let HearingDirective = HearingDirective_1 = class HearingDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Hearing32", "filepath": "hearing/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": "M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z" } }, { "elem": "path", "attrs": { "d": "M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z" } }, { "elem": "path", "attrs": { "d": "M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z" } }, { "elem": "path", "attrs": { "d": "M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z" } }], "name": "hearing", "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="M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z"></path><path d="M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z"></path><path d="M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z"></path><path d="M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z"></path></svg>` }, "24": { metadata: { "moduleName": "Hearing24", "filepath": "hearing/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": "M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z" } }, { "elem": "path", "attrs": { "d": "M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z" } }, { "elem": "path", "attrs": { "d": "M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z" } }, { "elem": "path", "attrs": { "d": "M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z" } }], "name": "hearing", "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="M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z"></path><path d="M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z"></path><path d="M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z"></path><path d="M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z"></path></svg>` }, "20": { metadata: { "moduleName": "Hearing20", "filepath": "hearing/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": "M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z" } }, { "elem": "path", "attrs": { "d": "M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z" } }, { "elem": "path", "attrs": { "d": "M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z" } }, { "elem": "path", "attrs": { "d": "M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z" } }], "name": "hearing", "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="M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z"></path><path d="M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z"></path><path d="M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z"></path><path d="M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z"></path></svg>` }, "16": { metadata: { "moduleName": "Hearing16", "filepath": "hearing/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": "M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z" } }, { "elem": "path", "attrs": { "d": "M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z" } }, { "elem": "path", "attrs": { "d": "M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z" } }, { "elem": "path", "attrs": { "d": "M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z" } }], "name": "hearing", "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="M18,30V28A10.0114,10.0114,0,0,0,28,18h2A12.0134,12.0134,0,0,1,18,30Z"></path><path d="M18,26V24a6.0066,6.0066,0,0,0,6-6h2A8.0092,8.0092,0,0,1,18,26Z"></path><path d="M18 22V20a2.0023 2.0023 0 002-2h2A4.0042 4.0042 0 0118 22zM10 2a9.01 9.01 0 00-9 9H3a7 7 0 0114 0 7.09 7.09 0 01-3.501 6.1348L13 17.4229v3.0732a2.9354 2.9354 0 01-.9009 2.1514 4.1824 4.1824 0 01-4.6318 1.03A4.0918 4.0918 0 015 20H3a6.1156 6.1156 0 003.6694 5.5117 5.7822 5.7822 0 002.3145.4863A6.5854 6.5854 0 0013.4624 24.11 4.94 4.94 0 0015 20.4961V18.5537A9.1077 9.1077 0 0019 11 9.01 9.01 0 0010 2z"></path><path d="M9.28,8.0825A3.0061,3.0061,0,0,1,13,11h2a4.9786,4.9786,0,0,0-1.8843-3.9111A5.0414,5.0414,0,0,0,8.835,6.1323,4.95,4.95,0,0,0,5.1323,9.835,5.0318,5.0318,0,0,0,7.436,15.2935,3.0777,3.0777,0,0,1,9,17.9229V20h2V17.9229a5.0608,5.0608,0,0,0-2.5371-4.3458A3.0016,3.0016,0,0,1,9.28,8.0825Z"></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; HearingDirective_1.titleIdCounter++; title.setAttribute("id", `hearing-${HearingDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `hearing-${HearingDirective_1.titleIdCounter}`); } } }; HearingDirective.titleIdCounter = 0; HearingDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], HearingDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HearingDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], HearingDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], HearingDirective.prototype, "size", void 0); HearingDirective = HearingDirective_1 = __decorate([ Directive({ selector: "[ibmIconHearing]" }), __metadata("design:paramtypes", [ElementRef]) ], HearingDirective); let HearingModule = class HearingModule { }; HearingModule = __decorate([ NgModule({ declarations: [ HearingComponent, HearingDirective, ], exports: [ HearingComponent, HearingDirective, ] }) ], HearingModule); export { HearingComponent, HearingDirective, HearingModule };