UNPKG

4.6 kBTypeScriptView Raw
1import { InjectionToken } from '@angular/core';
2import { Observable } from 'rxjs';
3import { ComponentType } from '../portal/portal';
4import { ToastRef } from './toast-injector';
5export declare type ProgressAnimationType = 'increasing' | 'decreasing';
6/**
7 * Configuration for an individual toast.
8 */
9export interface IndividualConfig {
10 /**
11 * disable both timeOut and extendedTimeOut
12 * default: false
13 */
14 disableTimeOut: boolean | 'timeOut' | 'extendedTimeOut';
15 /**
16 * toast time to live in milliseconds
17 * default: 5000
18 */
19 timeOut: number;
20 /**
21 * toast show close button
22 * default: false
23 */
24 closeButton: boolean;
25 /**
26 * time to close after a user hovers over toast
27 * default: 1000
28 */
29 extendedTimeOut: number;
30 /**
31 * show toast progress bar
32 * default: false
33 */
34 progressBar: boolean;
35 /**
36 * changes toast progress bar animation
37 * default: decreasing
38 */
39 progressAnimation: ProgressAnimationType;
40 /**
41 * render html in toast message (possibly unsafe)
42 * default: false
43 */
44 enableHtml: boolean;
45 /**
46 * css class on toast component
47 * default: ngx-toastr
48 */
49 toastClass: string;
50 /**
51 * css class on toast container
52 * default: toast-top-right
53 */
54 positionClass: string;
55 /**
56 * css class on toast title
57 * default: toast-title
58 */
59 titleClass: string;
60 /**
61 * css class on toast message
62 * default: toast-message
63 */
64 messageClass: string;
65 /**
66 * animation easing on toast
67 * default: ease-in
68 */
69 easing: string;
70 /**
71 * animation ease time on toast
72 * default: 300
73 */
74 easeTime: string | number;
75 /**
76 * clicking on toast dismisses it
77 * default: true
78 */
79 tapToDismiss: boolean;
80 /**
81 * Angular toast component to be shown
82 * default: Toast
83 */
84 toastComponent?: ComponentType<any>;
85 /**
86 * Helps show toast from a websocket or from event outside Angular
87 * default: false
88 */
89 onActivateTick: boolean;
90 /**
91 * New toast placement
92 * default: true
93 */
94 newestOnTop: boolean;
95 /**
96 * payload to pass to the toastComponent
97 * default: null
98 */
99 payload: any;
100}
101export interface ToastrIconClasses {
102 error: string;
103 info: string;
104 success: string;
105 warning: string;
106 [key: string]: string;
107}
108/**
109 * Global Toast configuration
110 * Includes all IndividualConfig
111 */
112export interface GlobalConfig extends IndividualConfig {
113 /**
114 * max toasts opened. Toasts will be queued
115 * Zero is unlimited
116 * default: 0
117 */
118 maxOpened: number;
119 /**
120 * dismiss current toast when max is reached
121 * default: false
122 */
123 autoDismiss: boolean;
124 iconClasses: Partial<ToastrIconClasses>;
125 /**
126 * block duplicate messages
127 * default: false
128 */
129 preventDuplicates: boolean;
130 /**
131 * display the number of duplicate messages
132 * default: false
133 */
134 countDuplicates: boolean;
135 /**
136 * Reset toast timeout when there's a duplicate (preventDuplicates needs to be set to true)
137 * default: false
138 */
139 resetTimeoutOnDuplicate: boolean;
140 /**
141 * consider the title of a toast when checking if duplicate
142 * default: false
143 */
144 includeTitleDuplicates: boolean;
145}
146/**
147 * Everything a toast needs to launch
148 */
149export declare class ToastPackage {
150 toastId: number;
151 config: IndividualConfig;
152 message: string | null | undefined;
153 title: string | undefined;
154 toastType: string;
155 toastRef: ToastRef<any>;
156 private _onTap;
157 private _onAction;
158 constructor(toastId: number, config: IndividualConfig, message: string | null | undefined, title: string | undefined, toastType: string, toastRef: ToastRef<any>);
159 /** Fired on click */
160 triggerTap(): void;
161 onTap(): Observable<void>;
162 /** available for use in custom toast */
163 triggerAction(action?: any): void;
164 onAction(): Observable<void>;
165}
166/** @deprecated use GlobalConfig */
167export interface GlobalToastrConfig extends GlobalConfig {
168}
169/** @deprecated use IndividualConfig */
170export interface IndividualToastrConfig extends IndividualConfig {
171}
172/** @deprecated use IndividualConfig */
173export interface ToastrConfig extends IndividualConfig {
174}
175export declare const DefaultNoComponentGlobalConfig: GlobalConfig;
176export interface ToastToken {
177 default: GlobalConfig;
178 config: Partial<GlobalConfig>;
179}
180export declare const TOAST_CONFIG: InjectionToken<ToastToken>;