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