UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 11.8 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var RainDrizzleComponent = /** @class */ (function () { function RainDrizzleComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RainDrizzleComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RainDrizzleComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleComponent.prototype, "size", void 0); RainDrizzleComponent = __decorate([ Component({ selector: "ibm-icon-rain-drizzle", template: "\n <svg\n ibmIconRainDrizzle\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 " }) ], RainDrizzleComponent); return RainDrizzleComponent; }()); var RainDrizzleDirective = /** @class */ (function () { function RainDrizzleDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "RainDrizzle32", "filepath": "rain--drizzle/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": "M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z" } }], "name": "rain--drizzle", "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=\"M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z\"></path><path d=\"M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z\"></path></svg>" }, "24": { metadata: { "moduleName": "RainDrizzle24", "filepath": "rain--drizzle/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": "M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z" } }], "name": "rain--drizzle", "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=\"M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z\"></path><path d=\"M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z\"></path></svg>" }, "20": { metadata: { "moduleName": "RainDrizzle20", "filepath": "rain--drizzle/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": "M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z" } }], "name": "rain--drizzle", "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=\"M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z\"></path><path d=\"M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z\"></path></svg>" }, "16": { metadata: { "moduleName": "RainDrizzle16", "filepath": "rain--drizzle/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": "M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z" } }, { "elem": "path", "attrs": { "d": "M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z" } }], "name": "rain--drizzle", "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=\"M11,30a1,1,0,0,1-.8944-1.4474l2-4a1,1,0,1,1,1.7887.8946l-2,4A.9979.9979,0,0,1,11,30Z\"></path><path d=\"M24.8008,9.1362a8.9943,8.9943,0,0,0-17.6006,0A6.4973,6.4973,0,0,0,8.5,22H19.3813L18.105,24.5527a1,1,0,0,0,1.789.8946L21.6177,22H23.5A6.4974,6.4974,0,0,0,24.8008,9.1362ZM23.5,20H8.5a4.4975,4.4975,0,0,1-.356-8.981l.8155-.0639.0991-.812a6.9938,6.9938,0,0,1,13.8838,0l.0986.812.8154.0639A4.4975,4.4975,0,0,1,23.5,20Z\"></path></svg>" }, }; } RainDrizzleDirective_1 = RainDrizzleDirective; RainDrizzleDirective.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; RainDrizzleDirective_1.titleIdCounter++; title.setAttribute("id", "rain-drizzle-" + RainDrizzleDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "rain-drizzle-" + RainDrizzleDirective_1.titleIdCounter); } }; var RainDrizzleDirective_1; RainDrizzleDirective.titleIdCounter = 0; RainDrizzleDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RainDrizzleDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], RainDrizzleDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], RainDrizzleDirective.prototype, "size", void 0); RainDrizzleDirective = RainDrizzleDirective_1 = __decorate([ Directive({ selector: "[ibmIconRainDrizzle]" }), __metadata("design:paramtypes", [ElementRef]) ], RainDrizzleDirective); return RainDrizzleDirective; }()); var RainDrizzleModule = /** @class */ (function () { function RainDrizzleModule() { } RainDrizzleModule = __decorate([ NgModule({ declarations: [ RainDrizzleComponent, RainDrizzleDirective, ], exports: [ RainDrizzleComponent, RainDrizzleDirective, ] }) ], RainDrizzleModule); return RainDrizzleModule; }()); export { RainDrizzleComponent, RainDrizzleDirective, RainDrizzleModule };