1 | import { ComponentRef, Injector, NgZone } from '@angular/core';
|
2 | import { DomSanitizer } from '@angular/platform-browser';
|
3 | import { Observable } from 'rxjs';
|
4 | import { Overlay } from '../overlay/overlay';
|
5 | import { ToastRef } from './toast-injector';
|
6 | import { ToastContainerDirective } from './toast.directive';
|
7 | import { GlobalConfig, IndividualConfig, ToastToken } from './toastr-config';
|
8 | export interface ActiveToast<C> {
|
9 |
|
10 | toastId: number;
|
11 |
|
12 | title: string;
|
13 |
|
14 | message: string;
|
15 |
|
16 | portal: ComponentRef<C>;
|
17 |
|
18 | toastRef: ToastRef<C>;
|
19 |
|
20 | onShown: Observable<void>;
|
21 |
|
22 | onHidden: Observable<void>;
|
23 |
|
24 | onTap: Observable<void>;
|
25 |
|
26 | onAction: Observable<any>;
|
27 | }
|
28 | export declare class ToastrService {
|
29 | private overlay;
|
30 | private _injector;
|
31 | private sanitizer;
|
32 | private ngZone;
|
33 | toastrConfig: GlobalConfig;
|
34 | currentlyActive: number;
|
35 | toasts: ActiveToast<any>[];
|
36 | overlayContainer?: ToastContainerDirective;
|
37 | previousToastMessage: string | undefined;
|
38 | private index;
|
39 | constructor(token: ToastToken, overlay: Overlay, _injector: Injector, sanitizer: DomSanitizer, ngZone: NgZone);
|
40 | /** show toast */
|
41 | show(message?: string, title?: string, override?: Partial<IndividualConfig>, type?: string): ActiveToast<any>;
|
42 | /** show successful toast */
|
43 | success(message?: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>;
|
44 | /** show error toast */
|
45 | error(message?: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>;
|
46 | /** show info toast */
|
47 | info(message?: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>;
|
48 | /** show warning toast */
|
49 | warning(message?: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>;
|
50 | /**
|
51 | * Remove all or a single toast by id
|
52 | */
|
53 | clear(toastId?: number): void;
|
54 | /**
|
55 | * Remove and destroy a single toast by id
|
56 | */
|
57 | remove(toastId: number): boolean;
|
58 | /**
|
59 | * Determines if toast message is already shown
|
60 | */
|
61 | findDuplicate(title: string, message: string, resetOnDuplicate: boolean, countDuplicates: boolean): ActiveToast<any>;
|
62 | /** create a clone of global config and apply individual settings */
|
63 | private applyConfig;
|
64 | /**
|
65 | * Find toast object by id
|
66 | */
|
67 | private _findToast;
|
68 | /**
|
69 | * Determines the need to run inside angular's zone then builds the toast
|
70 | */
|
71 | private _preBuildNotification;
|
72 | /**
|
73 | * Creates and attaches toast data to component
|
74 | * returns the active toast, or in case preventDuplicates is enabled the original/non-duplicate active toast.
|
75 | */
|
76 | private _buildNotification;
|
77 | }
|