UNPKG

4.7 kBTypeScriptView Raw
1import { InjectionToken } from '@angular/core';
2import { Observable } from 'rxjs';
3import { ComponentType } from '../portal/portal';
4import { ToastRef } from './toast-ref';
5export type ProgressAnimationType = 'increasing' | 'decreasing';
6export type DisableTimoutType = boolean | 'timeOut' | 'extendedTimeOut';
7/**
8 * Configuration for an individual toast.
9 */
10export interface IndividualConfig<ConfigPayload = any> {
11 /**
12 * disable both timeOut and extendedTimeOut
13 * default: false
14 */
15 disableTimeOut: DisableTimoutType;
16 /**
17 * toast time to live in milliseconds
18 * default: 5000
19 */
20 timeOut: number;
21 /**
22 * toast show close button
23 * default: false
24 */
25 closeButton: boolean;
26 /**
27 * time to close after a user hovers over toast
28 * default: 1000
29 */
30 extendedTimeOut: number;
31 /**
32 * show toast progress bar
33 * default: false
34 */
35 progressBar: boolean;
36 /**
37 * changes toast progress bar animation
38 * default: decreasing
39 */
40 progressAnimation: ProgressAnimationType;
41 /**
42 * render html in toast message (possibly unsafe)
43 * default: false
44 */
45 enableHtml: boolean;
46 /**
47 * css class on toast component
48 * default: ngx-toastr
49 */
50 toastClass: string;
51 /**
52 * css class on toast container
53 * default: toast-top-right
54 */
55 positionClass: string;
56 /**
57 * css class on toast title
58 * default: toast-title
59 */
60 titleClass: string;
61 /**
62 * css class on toast message
63 * default: toast-message
64 */
65 messageClass: string;
66 /**
67 * animation easing on toast
68 * default: ease-in
69 */
70 easing: string;
71 /**
72 * animation ease time on toast
73 * default: 300
74 */
75 easeTime: string | number;
76 /**
77 * clicking on toast dismisses it
78 * default: true
79 */
80 tapToDismiss: boolean;
81 /**
82 * Angular toast component to be shown
83 * default: Toast
84 */
85 toastComponent?: ComponentType<any>;
86 /**
87 * Helps show toast from a websocket or from event outside Angular
88 * default: false
89 */
90 onActivateTick: boolean;
91 /**
92 * New toast placement
93 * default: true
94 */
95 newestOnTop: boolean;
96 /**
97 * Payload to pass to the toast component
98 */
99 payload?: ConfigPayload;
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<ConfigPayload = any> {
150 toastId: number;
151 config: IndividualConfig<ConfigPayload>;
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<ConfigPayload>, 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>;