UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.32 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var TimeComponent = /** @class */ (function () { function TimeComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], TimeComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], TimeComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], TimeComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeComponent.prototype, "size", void 0); TimeComponent = __decorate([ Component({ selector: "ibm-icon-time", template: "\n <svg\n ibmIconTime\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 " }) ], TimeComponent); return TimeComponent; }()); var TimeDirective = /** @class */ (function () { function TimeDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Time32", "filepath": "time/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,30A14,14,0,1,1,30,16,14,14,0,0,1,16,30ZM16,4A12,12,0,1,0,28,16,12,12,0,0,0,16,4Z" } }, { "elem": "path", "attrs": { "d": "M20.59 22L15 16.41 15 7 17 7 17 15.58 22 20.59 20.59 22z" } }], "name": "time", "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,30A14,14,0,1,1,30,16,14,14,0,0,1,16,30ZM16,4A12,12,0,1,0,28,16,12,12,0,0,0,16,4Z\"></path><path d=\"M20.59 22L15 16.41 15 7 17 7 17 15.58 22 20.59 20.59 22z\"></path></svg>" }, "24": { metadata: { "moduleName": "Time24", "filepath": "time/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,30A14,14,0,1,1,30,16,14,14,0,0,1,16,30ZM16,4A12,12,0,1,0,28,16,12,12,0,0,0,16,4Z" } }, { "elem": "path", "attrs": { "d": "M20.59 22L15 16.41 15 7 17 7 17 15.58 22 20.59 20.59 22z" } }], "name": "time", "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,30A14,14,0,1,1,30,16,14,14,0,0,1,16,30ZM16,4A12,12,0,1,0,28,16,12,12,0,0,0,16,4Z\"></path><path d=\"M20.59 22L15 16.41 15 7 17 7 17 15.58 22 20.59 20.59 22z\"></path></svg>" }, "20": { metadata: { "moduleName": "Time20", "filepath": "time/20.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 20 20", "fill": "currentColor", "width": 20, "height": 20 }, "content": [{ "elem": "path", "attrs": { "d": "M10,19c-5,0-9-4-9-9s4-9,9-9s9,4,9,9S15,19,10,19z M10,2.3c-4.3,0-7.7,3.5-7.7,7.7s3.5,7.7,7.7,7.7s7.7-3.5,7.7-7.7\tS14.3,2.3,10,2.3z" } }, { "elem": "path", "attrs": { "d": "M13 13.9L9.4 10.3 9.4 4 10.6 4 10.6 9.7 13.9 13z" } }], "name": "time", "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 20 20\" aria-hidden=\"true\"><path d=\"M10,19c-5,0-9-4-9-9s4-9,9-9s9,4,9,9S15,19,10,19z M10,2.3c-4.3,0-7.7,3.5-7.7,7.7s3.5,7.7,7.7,7.7s7.7-3.5,7.7-7.7\tS14.3,2.3,10,2.3z\"></path><path d=\"M13 13.9L9.4 10.3 9.4 4 10.6 4 10.6 9.7 13.9 13z\"></path></svg>" }, "16": { metadata: { "moduleName": "Time16", "filepath": "time/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,30A14,14,0,1,1,30,16,14,14,0,0,1,16,30ZM16,4A12,12,0,1,0,28,16,12,12,0,0,0,16,4Z" } }, { "elem": "path", "attrs": { "d": "M20.59 22L15 16.41 15 7 17 7 17 15.58 22 20.59 20.59 22z" } }], "name": "time", "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,30A14,14,0,1,1,30,16,14,14,0,0,1,16,30ZM16,4A12,12,0,1,0,28,16,12,12,0,0,0,16,4Z\"></path><path d=\"M20.59 22L15 16.41 15 7 17 7 17 15.58 22 20.59 20.59 22z\"></path></svg>" }, }; } TimeDirective_1 = TimeDirective; TimeDirective.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; TimeDirective_1.titleIdCounter++; title.setAttribute("id", "time-" + TimeDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "time-" + TimeDirective_1.titleIdCounter); } }; var TimeDirective_1; TimeDirective.titleIdCounter = 0; TimeDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], TimeDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], TimeDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], TimeDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], TimeDirective.prototype, "size", void 0); TimeDirective = TimeDirective_1 = __decorate([ Directive({ selector: "[ibmIconTime]" }), __metadata("design:paramtypes", [ElementRef]) ], TimeDirective); return TimeDirective; }()); var TimeModule = /** @class */ (function () { function TimeModule() { } TimeModule = __decorate([ NgModule({ declarations: [ TimeComponent, TimeDirective, ], exports: [ TimeComponent, TimeDirective, ] }) ], TimeModule); return TimeModule; }()); export { TimeComponent, TimeDirective, TimeModule };