UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 12.4 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var PoliceComponent = /** @class */ (function () { function PoliceComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], PoliceComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PoliceComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PoliceComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceComponent.prototype, "size", void 0); PoliceComponent = __decorate([ Component({ selector: "ibm-icon-police", template: "\n <svg\n ibmIconPolice\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 " }) ], PoliceComponent); return PoliceComponent; }()); var PoliceDirective = /** @class */ (function () { function PoliceDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Police32", "filepath": "police/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": "M10 24H12V30H10z" } }, { "elem": "path", "attrs": { "d": "M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z" } }, { "elem": "path", "attrs": { "d": "M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z" } }], "name": "police", "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=\"M10 24H12V30H10z\"></path><path d=\"M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z\"></path><path d=\"M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z\"></path></svg>" }, "24": { metadata: { "moduleName": "Police24", "filepath": "police/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": "M10 24H12V30H10z" } }, { "elem": "path", "attrs": { "d": "M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z" } }, { "elem": "path", "attrs": { "d": "M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z" } }], "name": "police", "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=\"M10 24H12V30H10z\"></path><path d=\"M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z\"></path><path d=\"M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z\"></path></svg>" }, "20": { metadata: { "moduleName": "Police20", "filepath": "police/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": "M10 24H12V30H10z" } }, { "elem": "path", "attrs": { "d": "M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z" } }, { "elem": "path", "attrs": { "d": "M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z" } }], "name": "police", "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=\"M10 24H12V30H10z\"></path><path d=\"M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z\"></path><path d=\"M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z\"></path></svg>" }, "16": { metadata: { "moduleName": "Police16", "filepath": "police/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": "M10 24H12V30H10z" } }, { "elem": "path", "attrs": { "d": "M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z" } }, { "elem": "path", "attrs": { "d": "M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z" } }], "name": "police", "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=\"M10 24H12V30H10z\"></path><path d=\"M21,20H7a3.0033,3.0033,0,0,1-3-3V6H2V17a5.0059,5.0059,0,0,0,5,5H21a4.9419,4.9419,0,0,1,2.105.481L17,28.5859,18.4141,30l6.3071-6.3071A4.96,4.96,0,0,1,26,27v3h2V27A7.0078,7.0078,0,0,0,21,20Z\"></path><path d=\"M25.2746,4.0386l-7-2a1.0013,1.0013,0,0,0-.55,0l-7,2A.9993.9993,0,0,0,10.03,5.2422L11,9.123V11A7,7,0,1,0,25,11V9.123l.97-3.8808A.9993.9993,0,0,0,25.2746,4.0386ZM18,4.04l5.7952,1.6558L23.219,8H19V6H17V8H12.781l-.5762-2.3042ZM18,16a5.0058,5.0058,0,0,1-5-5V10H23v1A5.0058,5.0058,0,0,1,18,16Z\"></path></svg>" }, }; } PoliceDirective_1 = PoliceDirective; PoliceDirective.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; PoliceDirective_1.titleIdCounter++; title.setAttribute("id", "police-" + PoliceDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "police-" + PoliceDirective_1.titleIdCounter); } }; var PoliceDirective_1; PoliceDirective.titleIdCounter = 0; PoliceDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], PoliceDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PoliceDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], PoliceDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], PoliceDirective.prototype, "size", void 0); PoliceDirective = PoliceDirective_1 = __decorate([ Directive({ selector: "[ibmIconPolice]" }), __metadata("design:paramtypes", [ElementRef]) ], PoliceDirective); return PoliceDirective; }()); var PoliceModule = /** @class */ (function () { function PoliceModule() { } PoliceModule = __decorate([ NgModule({ declarations: [ PoliceComponent, PoliceDirective, ], exports: [ PoliceComponent, PoliceDirective, ] }) ], PoliceModule); return PoliceModule; }()); export { PoliceComponent, PoliceDirective, PoliceModule };