UNPKG

7.54 kBTypeScriptView 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 { ComponentFactoryResolver, ComponentRef } from '@angular/core';
7import { Observable } from 'rxjs';
8import { NbOverlayRef } from '../cdk/overlay/mapping';
9import { NbOverlayService } from '../cdk/overlay/overlay-service';
10import { NbPositionBuilderService } from '../cdk/overlay/overlay-position';
11import { NbGlobalLogicalPosition, NbGlobalPosition, NbPositionHelper } from '../cdk/overlay/position-helper';
12import { NbToastrContainerComponent } from './toastr-container.component';
13import { NbToastrConfig } from './toastr-config';
14import { NbToast } from './model';
15import { NbToastComponent } from './toast.component';
16import * as i0 from "@angular/core";
17export declare class NbToastRef {
18 private toastContainer;
19 private toast;
20 toastInstance: NbToastComponent;
21 constructor(toastContainer: NbToastContainer, toast: NbToast);
22 close(): void;
23 onClose(): Observable<void>;
24 onClick(): Observable<void>;
25}
26export declare class NbToastContainer {
27 protected position: NbGlobalPosition;
28 protected containerRef: ComponentRef<NbToastrContainerComponent>;
29 protected positionHelper: NbPositionHelper;
30 protected toasts: NbToast[];
31 protected prevToast: NbToast;
32 get nativeElement(): any;
33 constructor(position: NbGlobalPosition, containerRef: ComponentRef<NbToastrContainerComponent>, positionHelper: NbPositionHelper);
34 attach(toast: NbToast): NbToastRef;
35 destroy(toast: NbToast): void;
36 protected isDuplicate(toast: NbToast): boolean;
37 protected isDuplicatePrevious(toast: NbToast): boolean;
38 protected isDuplicateAmongAll(toast: NbToast): boolean;
39 protected toastDuplicateCompareFunc: (t1: NbToast, t2: NbToast) => boolean;
40 protected removeToastIfLimitReached(toast: NbToast): void;
41 protected attachToast(toast: NbToast): NbToastComponent;
42 protected attachToTop(toast: NbToast): NbToastComponent;
43 protected attachToBottom(toast: NbToast): NbToastComponent;
44 protected setDestroyTimeout(toast: NbToast): void;
45 protected subscribeOnClick(toastComponent: NbToastComponent, toast: NbToast): void;
46 protected updateContainer(): void;
47}
48interface NbToastrOverlayWithContainer {
49 overlayRef: NbOverlayRef;
50 toastrContainer: NbToastContainer;
51}
52export declare class NbToastrContainerRegistry {
53 protected overlay: NbOverlayService;
54 protected positionBuilder: NbPositionBuilderService;
55 protected positionHelper: NbPositionHelper;
56 protected cfr: ComponentFactoryResolver;
57 protected document: any;
58 protected overlays: Map<NbGlobalPosition, NbToastrOverlayWithContainer>;
59 constructor(overlay: NbOverlayService, positionBuilder: NbPositionBuilderService, positionHelper: NbPositionHelper, cfr: ComponentFactoryResolver, document: any);
60 get(position: NbGlobalPosition): NbToastContainer;
61 protected instantiateContainer(position: NbGlobalLogicalPosition): void;
62 protected createContainer(position: NbGlobalLogicalPosition): NbToastrOverlayWithContainer;
63 protected addClassToOverlayHost(overlayRef: NbOverlayRef): void;
64 protected existsInDom(toastContainer: NbToastContainer): boolean;
65 static ɵfac: i0.ɵɵFactoryDeclaration<NbToastrContainerRegistry, never>;
66 static ɵprov: i0.ɵɵInjectableDeclaration<NbToastrContainerRegistry>;
67}
68/**
69 * The `NbToastrService` provides a capability to build toast notifications.
70 *
71 * @stacked-example(Showcase, toastr/toastr-showcase.component)
72 *
73 * `NbToastrService.show(message, title, config)` accepts three params, title and config are optional.
74 *
75 * ### Installation
76 *
77 * Import `NbToastrModule.forRoot()` to your app module.
78 * ```ts
79 * @NgModule({
80 * imports: [
81 * // ...
82 * NbToastrModule.forRoot(config),
83 * ],
84 * })
85 * export class AppModule { }
86 * ```
87 *
88 * ### Usage
89 *
90 * Calling `NbToastrService.show(...)` will render new toast and return `NbToastrRef` with
91 * help of which you may close newly created toast by calling `close` method.
92 *
93 * ```ts
94 * const toastRef: NbToastRef = this.toastrService.show(...);
95 * toastRef.close();
96 * ```
97 *
98 * Config accepts following options:
99 *
100 * `position` - determines where on the screen toast will be rendered.
101 * Default is `top-end`.
102 *
103 * @stacked-example(Position, toastr/toastr-positions.component)
104 *
105 * `status` - coloring and icon of the toast.
106 * Default is `basic`.
107 *
108 * @stacked-example(Status, toastr/toastr-statuses.component)
109 *
110 * `duration` - the time after which the toast will be destroyed.
111 * `0` means endless toast, that may be destroyed by click only.
112 * Default is 3000 ms.
113 *
114 * @stacked-example(Duration, toastr/toastr-duration.component)
115 *
116 * `destroyByClick` - provides a capability to destroy toast by click.
117 * Default is true.
118 *
119 * @stacked-example(Destroy by click, toastr/toastr-destroy-by-click.component)
120 *
121 * `preventDuplicates` - don't create new toast if it has the same title, message and status.
122 * Default is false.
123 *
124 * @stacked-example(Prevent duplicates, toastr/toastr-prevent-duplicates.component)
125 *
126 * `duplicatesBehaviour` - determines how to treat the toasts duplication.
127 * Compare with the previous message `previous`
128 * or with all visible messages `all`.
129 *
130 * @stacked-example(Prevent duplicates behaviour , toastr/toastr-prevent-duplicates-behaviour.component)
131 *
132 * `limit` - the number of visible toasts in the toast container. The number of toasts is unlimited by default.
133 *
134 * @stacked-example(Prevent duplicates behaviour , toastr/toastr-limit.component)
135 *
136 * `hasIcon` - if true then render toast icon.
137 * `icon` - you can pass icon class that will be applied into the toast.
138 *
139 * @stacked-example(Has icon, toastr/toastr-icon.component)
140 * */
141export declare class NbToastrService {
142 protected globalConfig: NbToastrConfig;
143 protected containerRegistry: NbToastrContainerRegistry;
144 constructor(globalConfig: NbToastrConfig, containerRegistry: NbToastrContainerRegistry);
145 /**
146 * Shows toast with message, title and user config.
147 * */
148 show(message: any, title?: any, userConfig?: Partial<NbToastrConfig>): NbToastRef;
149 /**
150 * Shows success toast with message, title and user config.
151 * */
152 success(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
153 /**
154 * Shows info toast with message, title and user config.
155 * */
156 info(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
157 /**
158 * Shows warning toast with message, title and user config.
159 * */
160 warning(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
161 /**
162 * Shows primary toast with message, title and user config.
163 * */
164 primary(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
165 /**
166 * Shows danger toast with message, title and user config.
167 * */
168 danger(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
169 /**
170 * Shows default toast with message, title and user config.
171 * */
172 default(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
173 /**
174 * Shows control toast with message, title and user config.
175 * */
176 control(message: any, title?: any, config?: Partial<NbToastrConfig>): NbToastRef;
177 static ɵfac: i0.ɵɵFactoryDeclaration<NbToastrService, never>;
178 static ɵprov: i0.ɵɵInjectableDeclaration<NbToastrService>;
179}
180export {};
181
\No newline at end of file