UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 10 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var WarningAltComponent = /** @class */ (function () { function WarningAltComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], WarningAltComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningAltComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningAltComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltComponent.prototype, "size", void 0); WarningAltComponent = __decorate([ Component({ selector: "ibm-icon-warning-alt", template: "\n <svg\n ibmIconWarningAlt\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 " }) ], WarningAltComponent); return WarningAltComponent; }()); var WarningAltDirective = /** @class */ (function () { function WarningAltDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "WarningAlt32", "filepath": "warning--alt/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 22a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 22zM15 11H17V20H15z" } }, { "elem": "path", "attrs": { "d": "M29,29H3a1,1,0,0,1-.89-1.46l13-25a1,1,0,0,1,1.78,0l13,25A1,1,0,0,1,29,29ZM4.65,27h22.7L16,5.17Z" } }], "name": "warning--alt", "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 22a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 22zM15 11H17V20H15z\"></path><path d=\"M29,29H3a1,1,0,0,1-.89-1.46l13-25a1,1,0,0,1,1.78,0l13,25A1,1,0,0,1,29,29ZM4.65,27h22.7L16,5.17Z\"></path></svg>" }, "24": { metadata: { "moduleName": "WarningAlt24", "filepath": "warning--alt/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 22a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 22zM15 11H17V20H15z" } }, { "elem": "path", "attrs": { "d": "M29,29H3a1,1,0,0,1-.89-1.46l13-25a1,1,0,0,1,1.78,0l13,25A1,1,0,0,1,29,29ZM4.65,27h22.7L16,5.17Z" } }], "name": "warning--alt", "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 22a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 22zM15 11H17V20H15z\"></path><path d=\"M29,29H3a1,1,0,0,1-.89-1.46l13-25a1,1,0,0,1,1.78,0l13,25A1,1,0,0,1,29,29ZM4.65,27h22.7L16,5.17Z\"></path></svg>" }, "20": { metadata: { "moduleName": "WarningAlt20", "filepath": "warning--alt/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 22a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 22zM15 11H17V20H15z" } }, { "elem": "path", "attrs": { "d": "M29,29H3a1,1,0,0,1-.89-1.46l13-25a1,1,0,0,1,1.78,0l13,25A1,1,0,0,1,29,29ZM4.65,27h22.7L16,5.17Z" } }], "name": "warning--alt", "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 22a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 22zM15 11H17V20H15z\"></path><path d=\"M29,29H3a1,1,0,0,1-.89-1.46l13-25a1,1,0,0,1,1.78,0l13,25A1,1,0,0,1,29,29ZM4.65,27h22.7L16,5.17Z\"></path></svg>" }, "16": { metadata: { "moduleName": "WarningAlt16", "filepath": "warning--alt/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 16 16", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "path", "attrs": { "d": "M14.5,14h-13c-0.2,0-0.3-0.1-0.4-0.2c-0.1-0.2-0.1-0.3,0-0.5l6.5-12C7.7,1,8,0.9,8.2,1.1c0.1,0,0.2,0.1,0.2,0.2l6.5,12\tc0.1,0.2,0.1,0.3,0,0.5C14.9,13.9,14.7,14,14.5,14z M2.3,13h11.3L8,2.5L2.3,13z" } }, { "elem": "path", "attrs": { "d": "M7.5 6H8.5V9.5H7.5zM8 10.8c-.4 0-.8.3-.8.8s.3.8.8.8c.4 0 .8-.3.8-.8S8.4 10.8 8 10.8z" } }], "name": "warning--alt", "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 16 16\" aria-hidden=\"true\"><path d=\"M14.5,14h-13c-0.2,0-0.3-0.1-0.4-0.2c-0.1-0.2-0.1-0.3,0-0.5l6.5-12C7.7,1,8,0.9,8.2,1.1c0.1,0,0.2,0.1,0.2,0.2l6.5,12\tc0.1,0.2,0.1,0.3,0,0.5C14.9,13.9,14.7,14,14.5,14z M2.3,13h11.3L8,2.5L2.3,13z\"></path><path d=\"M7.5 6H8.5V9.5H7.5zM8 10.8c-.4 0-.8.3-.8.8s.3.8.8.8c.4 0 .8-.3.8-.8S8.4 10.8 8 10.8z\"></path></svg>" }, }; } WarningAltDirective_1 = WarningAltDirective; WarningAltDirective.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; WarningAltDirective_1.titleIdCounter++; title.setAttribute("id", "warning-alt-" + WarningAltDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "warning-alt-" + WarningAltDirective_1.titleIdCounter); } }; var WarningAltDirective_1; WarningAltDirective.titleIdCounter = 0; WarningAltDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], WarningAltDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningAltDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningAltDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningAltDirective.prototype, "size", void 0); WarningAltDirective = WarningAltDirective_1 = __decorate([ Directive({ selector: "[ibmIconWarningAlt]" }), __metadata("design:paramtypes", [ElementRef]) ], WarningAltDirective); return WarningAltDirective; }()); var WarningAltModule = /** @class */ (function () { function WarningAltModule() { } WarningAltModule = __decorate([ NgModule({ declarations: [ WarningAltComponent, WarningAltDirective, ], exports: [ WarningAltComponent, WarningAltDirective, ] }) ], WarningAltModule); return WarningAltModule; }()); export { WarningAltComponent, WarningAltDirective, WarningAltModule };