UNPKG

@ng-flexy/skins

Version:

Flexy components and tools to build Angular 8+ applications

94 lines (85 loc) 3.64 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@ng-flexy/core')) : typeof define === 'function' && define.amd ? define('@ng-flexy/skins', ['exports', '@angular/common', '@angular/core', '@ng-flexy/core'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["ng-flexy"] = global["ng-flexy"] || {}, global["ng-flexy"].skins = {}), global.ng.common, global.ng.core, global.core$1)); })(this, (function (exports, common, core, core$1) { 'use strict'; var FLEXY_SKINS_LIST_TOKEN = new core.InjectionToken('FLEXY_SKINS_LIST_TOKEN'); var SKIN_STATE_WINDOW_NAME = 'skinState'; var FlexySkinsService = /** @class */ (function () { function FlexySkinsService(supportedSkins, logger) { this.logger = logger; // its global class skin-switcher.js this.skinStateService = window[SKIN_STATE_WINDOW_NAME]; this.supported = supportedSkins; var currentSkin = this.skinStateService.getCurrent(); this.logger.debug('Current skin: ' + currentSkin); if (!this.supported.includes(currentSkin)) { this.skinStateService.switch(supportedSkins[0]); } } FlexySkinsService.prototype.getCurrent = function () { return this.skinStateService.getCurrent(); }; FlexySkinsService.prototype.set = function (skin) { if (this.supported.includes(skin)) { this.skinStateService.switch(skin); return true; } else { this.logger.warn('Skin is not supported', skin); return false; } }; return FlexySkinsService; }()); FlexySkinsService.decorators = [ { type: core.Injectable } ]; FlexySkinsService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FLEXY_SKINS_LIST_TOKEN,] }] }, { type: core$1.FlexyLoggerService } ]; }; var FLEXY_SKIN_DEFAULT_SKIN = 'default'; var ɵ0 = [FLEXY_SKIN_DEFAULT_SKIN]; var FlexySkinsModule = /** @class */ (function () { function FlexySkinsModule() { } FlexySkinsModule.forRoot = function (skins) { return { ngModule: FlexySkinsModule, providers: [ { provide: FLEXY_SKINS_LIST_TOKEN, useValue: skins }, FlexySkinsService ] }; }; return FlexySkinsModule; }()); FlexySkinsModule.decorators = [ { type: core.NgModule, args: [{ imports: [common.CommonModule, core$1.FlexyLoggerModule], providers: [ { provide: FLEXY_SKINS_LIST_TOKEN, useValue: ɵ0 }, FlexySkinsService ] },] } ]; /* * Public API Surface of skins */ /** * Generated bundle index. Do not edit. */ exports.FlexySkinsModule = FlexySkinsModule; exports.FlexySkinsService = FlexySkinsService; exports["ɵ0"] = ɵ0; exports["ɵa"] = FLEXY_SKINS_LIST_TOKEN; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=ng-flexy-skins.umd.js.map