UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 11 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var AlarmComponent = /** @class */ (function () { function AlarmComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], AlarmComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], AlarmComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], AlarmComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmComponent.prototype, "size", void 0); AlarmComponent = __decorate([ Component({ selector: "ibm-icon-alarm", template: "\n <svg\n ibmIconAlarm\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 " }) ], AlarmComponent); return AlarmComponent; }()); var AlarmDirective = /** @class */ (function () { function AlarmDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Alarm32", "filepath": "alarm/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": "M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z" } }, { "elem": "path", "attrs": { "d": "M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z" } }, { "elem": "path", "attrs": { "d": "M3.96 5.5H9.030000000000001V7.5H3.96z", "transform": "rotate(-45.06 6.502 6.497)" } }, { "elem": "path", "attrs": { "d": "M24.5 3.96H26.5V9.030000000000001H24.5z", "transform": "rotate(-44.94 25.5 6.498)" } }], "name": "alarm", "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=\"M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z\"></path><path d=\"M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z\"></path><path d=\"M3.96 5.5H9.030000000000001V7.5H3.96z\" transform=\"rotate(-45.06 6.502 6.497)\"></path><path d=\"M24.5 3.96H26.5V9.030000000000001H24.5z\" transform=\"rotate(-44.94 25.5 6.498)\"></path></svg>" }, "24": { metadata: { "moduleName": "Alarm24", "filepath": "alarm/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": "M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z" } }, { "elem": "path", "attrs": { "d": "M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z" } }, { "elem": "path", "attrs": { "d": "M3.96 5.5H9.030000000000001V7.5H3.96z", "transform": "rotate(-45.06 6.502 6.497)" } }, { "elem": "path", "attrs": { "d": "M24.5 3.96H26.5V9.030000000000001H24.5z", "transform": "rotate(-44.94 25.5 6.498)" } }], "name": "alarm", "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=\"M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z\"></path><path d=\"M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z\"></path><path d=\"M3.96 5.5H9.030000000000001V7.5H3.96z\" transform=\"rotate(-45.06 6.502 6.497)\"></path><path d=\"M24.5 3.96H26.5V9.030000000000001H24.5z\" transform=\"rotate(-44.94 25.5 6.498)\"></path></svg>" }, "20": { metadata: { "moduleName": "Alarm20", "filepath": "alarm/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": "M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z" } }, { "elem": "path", "attrs": { "d": "M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z" } }, { "elem": "path", "attrs": { "d": "M3.96 5.5H9.030000000000001V7.5H3.96z", "transform": "rotate(-45.06 6.502 6.497)" } }, { "elem": "path", "attrs": { "d": "M24.5 3.96H26.5V9.030000000000001H24.5z", "transform": "rotate(-44.94 25.5 6.498)" } }], "name": "alarm", "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=\"M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z\"></path><path d=\"M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z\"></path><path d=\"M3.96 5.5H9.030000000000001V7.5H3.96z\" transform=\"rotate(-45.06 6.502 6.497)\"></path><path d=\"M24.5 3.96H26.5V9.030000000000001H24.5z\" transform=\"rotate(-44.94 25.5 6.498)\"></path></svg>" }, "16": { metadata: { "moduleName": "Alarm16", "filepath": "alarm/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": "M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z" } }, { "elem": "path", "attrs": { "d": "M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z" } }, { "elem": "path", "attrs": { "d": "M3.96 5.5H9.030000000000001V7.5H3.96z", "transform": "rotate(-45.06 6.502 6.497)" } }, { "elem": "path", "attrs": { "d": "M24.5 3.96H26.5V9.030000000000001H24.5z", "transform": "rotate(-44.94 25.5 6.498)" } }], "name": "alarm", "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=\"M16,28A11,11,0,1,1,27,17,11,11,0,0,1,16,28ZM16,8a9,9,0,1,0,9,9A9,9,0,0,0,16,8Z\"></path><path d=\"M18.59 21L15 17.41 15 11 17 11 17 16.58 20 19.59 18.59 21z\"></path><path d=\"M3.96 5.5H9.030000000000001V7.5H3.96z\" transform=\"rotate(-45.06 6.502 6.497)\"></path><path d=\"M24.5 3.96H26.5V9.030000000000001H24.5z\" transform=\"rotate(-44.94 25.5 6.498)\"></path></svg>" }, }; } AlarmDirective_1 = AlarmDirective; AlarmDirective.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; AlarmDirective_1.titleIdCounter++; title.setAttribute("id", "alarm-" + AlarmDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "alarm-" + AlarmDirective_1.titleIdCounter); } }; var AlarmDirective_1; AlarmDirective.titleIdCounter = 0; AlarmDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], AlarmDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], AlarmDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], AlarmDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], AlarmDirective.prototype, "size", void 0); AlarmDirective = AlarmDirective_1 = __decorate([ Directive({ selector: "[ibmIconAlarm]" }), __metadata("design:paramtypes", [ElementRef]) ], AlarmDirective); return AlarmDirective; }()); var AlarmModule = /** @class */ (function () { function AlarmModule() { } AlarmModule = __decorate([ NgModule({ declarations: [ AlarmComponent, AlarmDirective, ], exports: [ AlarmComponent, AlarmDirective, ] }) ], AlarmModule); return AlarmModule; }()); export { AlarmComponent, AlarmDirective, AlarmModule };