UNPKG

@carbon/icons-angular

Version:

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

177 lines (172 loc) 15.6 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('@angular/core'), require('@carbon/icon-helpers')) : typeof define === 'function' && define.amd ? define(['exports', 'tslib', '@angular/core', '@carbon/icon-helpers'], factory) : (global = global || self, factory((global.CarbonIconsAngular = global.CarbonIconsAngular || {}, global.CarbonIconsAngular.Sun = {}), global.tslib, global.ng.core, global.CarbonIconHelpers)); }(this, (function (exports, tslib, core, iconHelpers) { 'use strict'; var SunComponent = /** @class */ (function () { function SunComponent() { this.focusable = false; } tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunComponent.prototype, "ariaLabel", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunComponent.prototype, "ariaLabelledby", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", Boolean) ], SunComponent.prototype, "ariaHidden", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunComponent.prototype, "title", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", Boolean) ], SunComponent.prototype, "focusable", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunComponent.prototype, "innerClass", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunComponent.prototype, "size", void 0); SunComponent = tslib.__decorate([ core.Component({ selector: "ibm-icon-sun", template: "\n <svg\n ibmIconSun\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 " }) ], SunComponent); return SunComponent; }()); var SunDirective = /** @class */ (function () { function SunDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "Sun32", "filepath": "sun/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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sun", "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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>" }, "24": { metadata: { "moduleName": "Sun24", "filepath": "sun/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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sun", "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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>" }, "20": { metadata: { "moduleName": "Sun20", "filepath": "sun/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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sun", "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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>" }, "16": { metadata: { "moduleName": "Sun16", "filepath": "sun/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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z", "transform": "translate(0 .005)" } }, { "elem": "path", "attrs": { "d": "M6.854 5.375H8.854V10.333H6.854z", "transform": "rotate(-45 7.86 7.856)" } }, { "elem": "path", "attrs": { "d": "M2 15.005H7V17.005000000000003H2z" } }, { "elem": "path", "attrs": { "d": "M5.375 23.147H10.333V25.147H5.375z", "transform": "rotate(-45 7.86 24.149)" } }, { "elem": "path", "attrs": { "d": "M15 25.005H17V30.005H15z" } }, { "elem": "path", "attrs": { "d": "M23.147 21.668H25.147V26.625999999999998H23.147z", "transform": "rotate(-45 24.152 24.149)" } }, { "elem": "path", "attrs": { "d": "M25 15.005H30V17.005000000000003H25z" } }, { "elem": "path", "attrs": { "d": "M21.668 6.854H26.625999999999998V8.854H21.668z", "transform": "rotate(-45 24.152 7.856)" } }, { "elem": "path", "attrs": { "d": "M15 2.005H17V7.005H15z" } }], "name": "sun", "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,12a4,4,0,1,1-4,4,4.0045,4.0045,0,0,1,4-4m0-2a6,6,0,1,0,6,6,6,6,0,0,0-6-6Z\" transform=\"translate(0 .005)\"></path><path d=\"M6.854 5.375H8.854V10.333H6.854z\" transform=\"rotate(-45 7.86 7.856)\"></path><path d=\"M2 15.005H7V17.005000000000003H2z\"></path><path d=\"M5.375 23.147H10.333V25.147H5.375z\" transform=\"rotate(-45 7.86 24.149)\"></path><path d=\"M15 25.005H17V30.005H15z\"></path><path d=\"M23.147 21.668H25.147V26.625999999999998H23.147z\" transform=\"rotate(-45 24.152 24.149)\"></path><path d=\"M25 15.005H30V17.005000000000003H25z\"></path><path d=\"M21.668 6.854H26.625999999999998V8.854H21.668z\" transform=\"rotate(-45 24.152 7.856)\"></path><path d=\"M15 2.005H17V7.005H15z\"></path></svg>" }, }; } SunDirective_1 = SunDirective; SunDirective.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 = iconHelpers.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; SunDirective_1.titleIdCounter++; title.setAttribute("id", "sun-" + SunDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "sun-" + SunDirective_1.titleIdCounter); } }; var SunDirective_1; SunDirective.titleIdCounter = 0; SunDirective.ctorParameters = function () { return [ { type: core.ElementRef } ]; }; tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunDirective.prototype, "ariaLabel", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunDirective.prototype, "ariaLabelledby", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", Boolean) ], SunDirective.prototype, "ariaHidden", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunDirective.prototype, "title", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", Boolean) ], SunDirective.prototype, "isFocusable", void 0); tslib.__decorate([ core.Input(), tslib.__metadata("design:type", String) ], SunDirective.prototype, "size", void 0); SunDirective = SunDirective_1 = tslib.__decorate([ core.Directive({ selector: "[ibmIconSun]" }), tslib.__metadata("design:paramtypes", [core.ElementRef]) ], SunDirective); return SunDirective; }()); var SunModule = /** @class */ (function () { function SunModule() { } SunModule = tslib.__decorate([ core.NgModule({ declarations: [ SunComponent, SunDirective, ], exports: [ SunComponent, SunDirective, ] }) ], SunModule); return SunModule; }()); exports.SunComponent = SunComponent; exports.SunDirective = SunDirective; exports.SunModule = SunModule; Object.defineProperty(exports, '__esModule', { value: true }); })));