forked from fkhadra/react-toastify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
326 lines (269 loc) Β· 6.53 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
import * as React from 'react';
export const enum ToastType {
INFO = 'info',
SUCCESS = 'success',
WARNING = 'warning',
ERROR = 'error',
DEFAULT = 'default'
}
export const enum ToastPosition {
TOP_RIGHT = 'top-right',
TOP_CENTER = 'top-center',
TOP_LEFT = 'top-left',
BOTTOM_RIGHT = 'bottom-right',
BOTTOM_CENTER = 'bottom-center',
BOTTOM_LEFT = 'bottom-left'
}
type ToastContent = React.ReactNode | { (): void };
interface cssTransitionProps {
/**
* Css class to apply when toast enter
*/
enter: string;
/**
* Css class to apply when toast leave
*/
exit: string;
/**
* Define the duration of the transition in ms
* `Default: 750`
*/
duration?: number | Array<number>;
/**
* Append current toast position to the classname.
* For instance `myclass--top-center`...
* `Default: false`
*/
appendPosition?: boolean;
}
interface CommonOptions {
/**
* Pause the timer when the mouse hover the toast.
* `Default: true`
*/
pauseOnHover?: boolean;
/**
* Pause the toast when the window loose focus.
* `Default: true`
*/
pauseOnFocusLoss?: boolean;
/**
* Remove the toast when clicked.
* `Default: true`
*/
closeOnClick?: boolean;
/**
* Set the delay in ms to close the toast automatically.
* Use `false` to prevent the toast from closing.
* `Default: 5000`
*/
autoClose?: number | false;
/**
* Set the default position to use.
* `One of: 'top-right', 'top-center', 'top-left', 'bottom-right', 'bottom-center', 'bottom-left'`
* `Default: 'top-right'`
*/
position?: ToastPosition;
/**
* Pass a custom close button.
* To remove the close button pass `false`
*/
closeButton?: React.ReactNode | false;
/**
* An optional css class to set for the progress bar.
*/
progressClassName?: string | object;
/**
* An optional style to set for the progress bar.
*/
progressStyle?: object;
/**
* An optional css class to set.
*/
className?: string | object;
/**
* An optional css class to set for the toast content.
*/
bodyClassName?: string | object;
/**
* Hide or show the progress bar.
* `Default: false`
*/
hideProgressBar?: boolean;
/**
* Pass a custom transition built with react-transition-group.
*/
transition?: React.ComponentType;
/**
* Allow toast to be draggable
* `Default: true`
*/
draggable?: boolean;
/**
* The percentage of the toast's width it takes for a drag to dismiss a toast
* `Default: 80`
*/
draggablePercent?: number;
}
interface ToastOptions extends CommonOptions {
/**
* Called inside componentDidMount.
*/
onOpen?: () => void;
/**
* Called inside componentWillUnMount.
*/
onClose?: () => void;
/**
* Set the toast type.
* `One of: 'info', 'success', 'warning', 'error', 'default'`
*/
type?: ToastType;
/**
* Set a custom `toastId`
*/
toastId?: number|string;
}
interface UpdateOptions extends ToastOptions {
/**
* Used to update a toast.
* Pass any valid ReactNode(string, number, component)
*/
render?: ToastContent;
}
interface ToastContainerProps extends CommonOptions {
/**
* Whether or not to display the newest toast on top.
* `Default: false`
*/
newestOnTop?: boolean;
/**
* An optional inline style to apply.
*/
style?: object;
/**
* An optional css class for the toast.
*/
toastClassName?: string | object;
/**
* Support right to left display.
* `Default: false`
*/
rtl?: boolean;
}
interface Toast {
/**
* Shorthand to display toast of type 'success'.
*/
success(content: ToastContent, options?: ToastOptions): number;
/**
* Shorthand to display toast of type 'info'.
*/
info(content: ToastContent, options?: ToastOptions): number;
/**
* Shorthand to display toast of type 'warning'.
*/
warn(content: ToastContent, options?: ToastOptions): number;
/**
* Shorthand to display toast of type 'error'.
*/
error(content: ToastContent, options?: ToastOptions): number;
/**
* Check if a toast is active by passing the `toastId`.
* Each time you display a toast you receive a `toastId`.
*/
isActive(toastId: number): boolean;
/**
* Remove a toast. If no `toastId` is used, all the active toast
* will be removed.
*/
dismiss(toastId?: number): void;
/**
* Update an existing toast. By default, we keep the initial content and options of the toast.
*/
update(toastId: number, options?: UpdateOptions): void;
/**
* Listen for change when a toast is added or removed. The number of toast displayed is passed as paran to the callback
*/
onChange(callback: ((count?: number) => void)): void;
/**
* Display a toast without a specific type.
*/
(content: ToastContent, options?: ToastOptions): number;
/**
* Helper to set notification type
*/
TYPE: {
/**
* Set notification type to `'info'`
*/
INFO: ToastType.INFO;
/**
* Set notification type to `'success'`
*/
SUCCESS: ToastType.SUCCESS;
/**
* Set notification type to `'warning'`
*/
WARNING: ToastType.WARNING;
/**
* Set notification type to `'error'`
*/
ERROR: ToastType.ERROR;
/**
* Set notification type to `'default'`
*/
DEFAULT: ToastType.DEFAULT;
};
/**
* Helper to set position
*/
POSITION: {
/**
* Set the position to `'top-left'`
*/
TOP_LEFT: ToastPosition.TOP_LEFT;
/**
* Set the position to `'top-right'`
*/
TOP_RIGHT: ToastPosition.TOP_RIGHT;
/**
* Set the position to `'top-center'`
*/
TOP_CENTER: ToastPosition.TOP_CENTER;
/**
* Set the position to `'bottom-left'`
*/
BOTTOM_LEFT: ToastPosition.BOTTOM_LEFT;
/**
* Set the position to `'bottom-right'`
*/
BOTTOM_RIGHT: ToastPosition.BOTTOM_RIGHT;
/**
* Set the position to `'bottom-center'`
*/
BOTTOM_CENTER: ToastPosition.BOTTOM_CENTER;
};
}
export class ToastContainer extends React.Component<ToastContainerProps, any> {}
/**
* Helper to build custom entrance and exit transition
*/
export function cssTransition(props: cssTransitionProps): React.ComponentType;
export const toast: Toast;
/**
* Built-in entrance and exit transition
*/
export const Slide: React.ComponentType;
/**
* Built-in entrance and exit transition
*/
export const Bounce: React.ComponentType;
/**
* Built-in entrance and exit transition
*/
export const Flip: React.ComponentType;
/**
* Built-in entrance and exit transition
*/
export const Zoom: React.ComponentType;