UNPKG

3.42 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Akveo. All Rights Reserved.
4 * Licensed under the MIT License. See License.txt in the project root for license information.
5 */
6import { NgModule, PLATFORM_ID } from '@angular/core';
7import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
8import { NB_BUILT_IN_JS_THEMES, NB_MEDIA_BREAKPOINTS, NB_THEME_OPTIONS, NB_JS_THEMES, NB_DOCUMENT, NB_WINDOW, } from './theme.options';
9import { NbThemeService } from './services/theme.service';
10import { NbSpinnerService } from './services/spinner.service';
11import { BUILT_IN_THEMES, NbJSThemesRegistry } from './services/js-themes-registry.service';
12import { DEFAULT_MEDIA_BREAKPOINTS, NbMediaBreakpointsService, } from './services/breakpoints.service';
13import { NbLayoutDirectionService, NbLayoutDirection, NB_LAYOUT_DIRECTION } from './services/direction.service';
14import { NbLayoutScrollService } from './services/scroll.service';
15import { NbLayoutRulerService } from './services/ruler.service';
16import { NbOverlayModule } from './components/cdk/overlay/overlay.module';
17import { NbStatusService } from './services/status.service';
18export function windowFactory(platformId) {
19 if (isPlatformBrowser(platformId)) {
20 return window;
21 }
22 // Provide undefined to get the error when trying to access the window as it
23 // shouldn't be used outside the browser. Those who need to provide something
24 // instead of window (e.g. domino window when running in node) could override
25 // NB_WINDOW token.
26 return undefined;
27}
28export class NbThemeModule {
29 // TODO: check the options (throw exception?)
30 /**
31 * Main Theme Module
32 *
33 * @param nbThemeOptions {NbThemeOptions} Main theme options
34 * @param nbJSThemes {NbJSThemeOptions[]} List of JS Themes, will be merged with default themes
35 * @param nbMediaBreakpoints {NbMediaBreakpoint} Available media breakpoints
36 * @param layoutDirection {NbLayoutDirection} Layout direction
37 *
38 * @returns {ModuleWithProviders}
39 */
40 static forRoot(nbThemeOptions = { name: 'default' }, nbJSThemes, nbMediaBreakpoints, layoutDirection) {
41 return {
42 ngModule: NbThemeModule,
43 providers: [
44 { provide: NB_THEME_OPTIONS, useValue: nbThemeOptions || {} },
45 { provide: NB_BUILT_IN_JS_THEMES, useValue: BUILT_IN_THEMES },
46 { provide: NB_JS_THEMES, useValue: nbJSThemes || [] },
47 { provide: NB_MEDIA_BREAKPOINTS, useValue: nbMediaBreakpoints || DEFAULT_MEDIA_BREAKPOINTS },
48 { provide: NB_DOCUMENT, useExisting: DOCUMENT },
49 { provide: NB_WINDOW, useFactory: windowFactory, deps: [PLATFORM_ID] },
50 NbJSThemesRegistry,
51 NbThemeService,
52 NbMediaBreakpointsService,
53 NbSpinnerService,
54 { provide: NB_LAYOUT_DIRECTION, useValue: layoutDirection || NbLayoutDirection.LTR },
55 NbLayoutDirectionService,
56 NbLayoutScrollService,
57 NbLayoutRulerService,
58 ...NbOverlayModule.forRoot().providers,
59 NbStatusService,
60 ],
61 };
62 }
63}
64NbThemeModule.decorators = [
65 { type: NgModule, args: [{
66 imports: [
67 CommonModule,
68 ],
69 exports: [],
70 },] }
71];
72//# sourceMappingURL=theme.module.js.map
\No newline at end of file