UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 10.3 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var WarningSquareComponent = /** @class */ (function () { function WarningSquareComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], WarningSquareComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningSquareComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningSquareComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareComponent.prototype, "size", void 0); WarningSquareComponent = __decorate([ Component({ selector: "ibm-icon-warning-square", template: "\n <svg\n ibmIconWarningSquare\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 " }) ], WarningSquareComponent); return WarningSquareComponent; }()); var WarningSquareDirective = /** @class */ (function () { function WarningSquareDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "WarningSquare32", "filepath": "warning-square/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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z" } }], "name": "warning-square", "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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z\"></path></svg>" }, "24": { metadata: { "moduleName": "WarningSquare24", "filepath": "warning-square/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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z" } }], "name": "warning-square", "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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z\"></path></svg>" }, "20": { metadata: { "moduleName": "WarningSquare20", "filepath": "warning-square/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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z" } }], "name": "warning-square", "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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z\"></path></svg>" }, "16": { metadata: { "moduleName": "WarningSquare16", "filepath": "warning-square/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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z" } }, { "elem": "path", "attrs": { "d": "M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z" } }], "name": "warning-square", "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 20a1.5 1.5 0 101.5 1.5A1.5 1.5 0 0016 20zM15 9H17V18H15z\"></path><path d=\"M26,28H6a2.0023,2.0023,0,0,1-2-2V6A2.0023,2.0023,0,0,1,6,4H26a2.0023,2.0023,0,0,1,2,2V26A2.0023,2.0023,0,0,1,26,28ZM6,6V26H26.0012L26,6Z\"></path></svg>" }, }; } WarningSquareDirective_1 = WarningSquareDirective; WarningSquareDirective.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; WarningSquareDirective_1.titleIdCounter++; title.setAttribute("id", "warning-square-" + WarningSquareDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "warning-square-" + WarningSquareDirective_1.titleIdCounter); } }; var WarningSquareDirective_1; WarningSquareDirective.titleIdCounter = 0; WarningSquareDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], WarningSquareDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningSquareDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], WarningSquareDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], WarningSquareDirective.prototype, "size", void 0); WarningSquareDirective = WarningSquareDirective_1 = __decorate([ Directive({ selector: "[ibmIconWarningSquare]" }), __metadata("design:paramtypes", [ElementRef]) ], WarningSquareDirective); return WarningSquareDirective; }()); var WarningSquareModule = /** @class */ (function () { function WarningSquareModule() { } WarningSquareModule = __decorate([ NgModule({ declarations: [ WarningSquareComponent, WarningSquareDirective, ], exports: [ WarningSquareComponent, WarningSquareDirective, ] }) ], WarningSquareModule); return WarningSquareModule; }()); export { WarningSquareComponent, WarningSquareDirective, WarningSquareModule };