UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 10.2 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var NotSentComponent = /** @class */ (function () { function NotSentComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], NotSentComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NotSentComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NotSentComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentComponent.prototype, "size", void 0); NotSentComponent = __decorate([ Component({ selector: "ibm-icon-not-sent", template: "\n <svg\n ibmIconNotSent\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 " }) ], NotSentComponent); return NotSentComponent; }()); var NotSentDirective = /** @class */ (function () { function NotSentDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "NotSent32", "filepath": "not-sent/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": "M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z" } }], "name": "not-sent", "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=\"M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z\"></path></svg>" }, "24": { metadata: { "moduleName": "NotSent24", "filepath": "not-sent/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": "M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z" } }], "name": "not-sent", "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=\"M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z\"></path></svg>" }, "20": { metadata: { "moduleName": "NotSent20", "filepath": "not-sent/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": "M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z" } }], "name": "not-sent", "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=\"M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z\"></path></svg>" }, "16": { metadata: { "moduleName": "NotSent16", "filepath": "not-sent/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": "M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z" } }], "name": "not-sent", "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=\"M30 28.59L3.41 2 2 3.41l8 8L2.66 14.06a1 1 0 000 1.87l9.6 3.84 3.84 9.6A1 1 0 0017 30h0a1 1 0 00.92-.66L20.6 22l8 8zM5.8 15L11.54 13l3.05 3-1.83 1.83zM17 26.2l-2.79-7L16 17.41l3 3.05zM15.69 11.45l7.64-2.78-2.78 7.64 1.56 1.56L25.94 7.34a1 1 0 00-1.28-1.28L14.13 9.89z\"></path></svg>" }, }; } NotSentDirective_1 = NotSentDirective; NotSentDirective.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; NotSentDirective_1.titleIdCounter++; title.setAttribute("id", "not-sent-" + NotSentDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "not-sent-" + NotSentDirective_1.titleIdCounter); } }; var NotSentDirective_1; NotSentDirective.titleIdCounter = 0; NotSentDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], NotSentDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NotSentDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], NotSentDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], NotSentDirective.prototype, "size", void 0); NotSentDirective = NotSentDirective_1 = __decorate([ Directive({ selector: "[ibmIconNotSent]" }), __metadata("design:paramtypes", [ElementRef]) ], NotSentDirective); return NotSentDirective; }()); var NotSentModule = /** @class */ (function () { function NotSentModule() { } NotSentModule = __decorate([ NgModule({ declarations: [ NotSentComponent, NotSentDirective, ], exports: [ NotSentComponent, NotSentDirective, ] }) ], NotSentModule); return NotSentModule; }()); export { NotSentComponent, NotSentDirective, NotSentModule };