1 | import { ComponentFactoryResolver, ComponentRef, TemplateRef, ViewContainerRef } from '@angular/core';
|
2 | import { NbComponentType, NbOverlayPositionBuilder, NbOverlayRef } from '../cdk/overlay/mapping';
|
3 | import { NbOverlayService } from '../cdk/overlay/overlay-service';
|
4 | import { NbBlockScrollStrategyAdapter } from '../cdk/adapter/block-scroll-strategy-adapter';
|
5 | import { NbWindowConfig } from './window.options';
|
6 | import { NbWindowRef } from './window-ref';
|
7 | import { NbWindowComponent } from './window.component';
|
8 | /**
|
9 | * The `NbWindowService` can be used to open windows.
|
10 | *
|
11 | * @stacked-example(Showcase, window/window-showcase.component)
|
12 | *
|
13 | * ### Installation
|
14 | *
|
15 | * Import `NbWindowModule` to your app module.
|
16 | * ```ts
|
17 | * @NgModule({
|
18 | * imports: [
|
19 | * // ...
|
20 | * NbWindowModule.forRoot(config),
|
21 | * ],
|
22 | * })
|
23 | * export class AppModule { }
|
24 | * ```
|
25 | *
|
26 | * If you are using it in a lazy loaded module than you have to install `NbWindowModule.forChild`:
|
27 | * ```ts
|
28 | * @NgModule({
|
29 | * imports: [
|
30 | * // ...
|
31 | * NbWindowModule.forChild(config),
|
32 | * ],
|
33 | * })
|
34 | * export class LazyLoadedModule { }
|
35 | * ```
|
36 | *
|
37 | * ### Usage
|
38 | *
|
39 | * A new window can be opened by calling the `open` method with a component or template to be loaded
|
40 | * and an optional configuration.
|
41 | * `open` method will return `NbWindowRef` that can be used for the further manipulations.
|
42 | *
|
43 | * ```ts
|
44 | * const windowRef = this.windowService.open(MyComponent, { ... });
|
45 | * ```
|
46 | *
|
47 | * `NbWindowRef` gives you ability manipulate opened window.
|
48 | * Also, you can inject `NbWindowRef` inside provided component which rendered in window.
|
49 | *
|
50 | * ```ts
|
51 | * this.windowService.open(MyWindowComponent, { ... });
|
52 | *
|
53 | * // my.component.ts
|
54 | * constructor(protected windowRef: NbWindowRef) {
|
55 | * }
|
56 | *
|
57 | * minimize() {
|
58 | * this.windowRef.minimize();
|
59 | * }
|
60 | *
|
61 | * close() {
|
62 | * this.windowRef.close();
|
63 | * }
|
64 | * ```
|
65 | *
|
66 | * Instead of component you can create window from TemplateRef. As usual you can access context provided via config
|
67 | * via `let-` variables. Also you can get reference to the `NbWindowRef` in context's `windowRef` property.
|
68 | *
|
69 | * @stacked-example(Window content from TemplateRef, window/template-window.component)
|
70 | *
|
71 | * ### Configuration
|
72 | *
|
73 | * As mentioned above, `open` method of the `NbWindowService` may receive optional configuration options.
|
74 | * Also, you can modify default windows configuration through `NbWindowModule.forRoot({ ... })`.
|
75 | * You can read about all available options on [API tab](docs/components/window/api#nbwindowconfig).
|
76 | *
|
77 | * @stacked-example(Configuration, window/windows-backdrop.component)
|
78 | */
|
79 | export declare class NbWindowService {
|
80 | protected componentFactoryResolver: ComponentFactoryResolver;
|
81 | protected overlayService: NbOverlayService;
|
82 | protected overlayPositionBuilder: NbOverlayPositionBuilder;
|
83 | protected blockScrollStrategy: NbBlockScrollStrategyAdapter;
|
84 | protected readonly defaultWindowsConfig: NbWindowConfig;
|
85 | protected cfr: ComponentFactoryResolver;
|
86 | protected document: Document;
|
87 | protected overlayRef: NbOverlayRef;
|
88 | protected windowsContainerViewRef: ViewContainerRef;
|
89 | protected openWindows: NbWindowRef[];
|
90 | constructor(componentFactoryResolver: ComponentFactoryResolver, overlayService: NbOverlayService, overlayPositionBuilder: NbOverlayPositionBuilder, blockScrollStrategy: NbBlockScrollStrategyAdapter, defaultWindowsConfig: NbWindowConfig, cfr: ComponentFactoryResolver, document: any);
|
91 | /**
|
92 | * Opens new window.
|
93 | * @param windowContent
|
94 | * @param windowConfig
|
95 | * */
|
96 | open(windowContent: TemplateRef<any> | NbComponentType, windowConfig?: Partial<NbWindowConfig>): NbWindowRef;
|
97 | protected shouldCreateWindowsContainer(): boolean;
|
98 | protected createWindowsContainer(): void;
|
99 | protected appendWindow(content: TemplateRef<any> | NbComponentType, config: NbWindowConfig, windowRef: NbWindowRef): ComponentRef<NbWindowComponent>;
|
100 | protected subscribeToEvents(windowRef: NbWindowRef): void;
|
101 | protected checkAndUpdateOverlay(): void;
|
102 | }
|