1 | import * as React from 'react';
|
2 | import React__default, { HTMLAttributes } from 'react';
|
3 |
|
4 | interface CloseButtonProps {
|
5 | closeToast: CloseToastFunc;
|
6 | type: TypeOptions;
|
7 | ariaLabel?: string;
|
8 | theme: Theme;
|
9 | }
|
10 | declare function CloseButton({ closeToast, theme, ariaLabel }: CloseButtonProps): React__default.JSX.Element;
|
11 |
|
12 | declare function ToastContainer(props: ToastContainerProps): React__default.JSX.Element;
|
13 |
|
14 | declare const Bounce: ({ children, position, preventExitTransition, done, nodeRef, isIn, playToast }: ToastTransitionProps) => React.JSX.Element;
|
15 | declare const Slide: ({ children, position, preventExitTransition, done, nodeRef, isIn, playToast }: ToastTransitionProps) => React.JSX.Element;
|
16 | declare const Zoom: ({ children, position, preventExitTransition, done, nodeRef, isIn, playToast }: ToastTransitionProps) => React.JSX.Element;
|
17 | declare const Flip: ({ children, position, preventExitTransition, done, nodeRef, isIn, playToast }: ToastTransitionProps) => React.JSX.Element;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | interface IconProps {
|
23 | theme: Theme;
|
24 | type: TypeOptions;
|
25 | isLoading?: boolean;
|
26 | }
|
27 | type BuiltInIconProps = React__default.SVGProps<SVGSVGElement> & IconProps;
|
28 | declare function Warning(props: BuiltInIconProps): React__default.JSX.Element;
|
29 | declare function Info(props: BuiltInIconProps): React__default.JSX.Element;
|
30 | declare function Success(props: BuiltInIconProps): React__default.JSX.Element;
|
31 | declare function Error(props: BuiltInIconProps): React__default.JSX.Element;
|
32 | declare function Spinner(): React__default.JSX.Element;
|
33 | declare const Icons: {
|
34 | info: typeof Info;
|
35 | warning: typeof Warning;
|
36 | success: typeof Success;
|
37 | error: typeof Error;
|
38 | spinner: typeof Spinner;
|
39 | };
|
40 |
|
41 | declare function isToastActive(id: Id, containerId?: Id): boolean;
|
42 | declare const clearWaitingQueue: (p?: ClearWaitingQueueParams) => void;
|
43 |
|
44 | type Nullable<T> = {
|
45 | [P in keyof T]: T[P] | null;
|
46 | };
|
47 | type TypeOptions = 'info' | 'success' | 'warning' | 'error' | 'default';
|
48 | type Theme = 'light' | 'dark' | 'colored' | (string & {});
|
49 | type ToastPosition = 'top-right' | 'top-center' | 'top-left' | 'bottom-right' | 'bottom-center' | 'bottom-left';
|
50 | type CloseToastFunc = ((reason?: boolean | string) => void) & ((e: React__default.MouseEvent) => void);
|
51 | interface ToastContentProps<Data = unknown> {
|
52 | closeToast: CloseToastFunc;
|
53 | toastProps: ToastProps;
|
54 | isPaused: boolean;
|
55 | data: Data;
|
56 | }
|
57 | type ToastContent<T = unknown> = React__default.ReactNode | ((props: ToastContentProps<T>) => React__default.ReactNode);
|
58 | type ToastIcon = false | ((props: IconProps) => React__default.ReactNode) | React__default.ReactElement<IconProps>;
|
59 | type Id = number | string;
|
60 | type ToastTransition = React__default.FC<ToastTransitionProps> | React__default.ComponentClass<ToastTransitionProps>;
|
61 | /**
|
62 | * ClassName for the elements - can take a function to build a classname or a raw string that is cx'ed to defaults
|
63 | */
|
64 | type ToastClassName = ((context?: {
|
65 | type?: TypeOptions;
|
66 | defaultClassName?: string;
|
67 | position?: ToastPosition;
|
68 | rtl?: boolean;
|
69 | }) => string) | string;
|
70 | interface ClearWaitingQueueParams {
|
71 | containerId?: Id;
|
72 | }
|
73 | type DraggableDirection = 'x' | 'y';
|
74 | interface CommonOptions {
|
75 | /**
|
76 | * Pause the timer when the mouse hover the toast.
|
77 | * `Default: true`
|
78 | */
|
79 | pauseOnHover?: boolean;
|
80 | /**
|
81 | * Pause the toast when the window loses focus.
|
82 | * `Default: true`
|
83 | */
|
84 | pauseOnFocusLoss?: boolean;
|
85 | /**
|
86 | * Remove the toast when clicked.
|
87 | * `Default: false`
|
88 | */
|
89 | closeOnClick?: boolean;
|
90 | /**
|
91 | * Set the delay in ms to close the toast automatically.
|
92 | * Use `false` to prevent the toast from closing.
|
93 | * `Default: 5000`
|
94 | */
|
95 | autoClose?: number | false;
|
96 | /**
|
97 | * Set the default position to use.
|
98 | * `One of: 'top-right', 'top-center', 'top-left', 'bottom-right', 'bottom-center', 'bottom-left'`
|
99 | * `Default: 'top-right'`
|
100 | */
|
101 | position?: ToastPosition;
|
102 | /**
|
103 | * Pass a custom close button.
|
104 | * To remove the close button pass `false`
|
105 | */
|
106 | closeButton?: boolean | ((props: CloseButtonProps) => React__default.ReactNode) | React__default.ReactElement<CloseButtonProps>;
|
107 | /**
|
108 | * An optional css class to set for the progress bar.
|
109 | */
|
110 | progressClassName?: ToastClassName;
|
111 | /**
|
112 | * Hide or show the progress bar.
|
113 | * `Default: false`
|
114 | */
|
115 | hideProgressBar?: boolean;
|
116 | /**
|
117 | * Pass a custom transition see https://fkhadra.github.io/react-toastify/custom-animation/
|
118 | */
|
119 | transition?: ToastTransition;
|
120 | /**
|
121 | * Allow toast to be draggable
|
122 | * `Default: 'touch'`
|
123 | */
|
124 | draggable?: boolean | 'mouse' | 'touch';
|
125 | /**
|
126 | * The percentage of the toast's width it takes for a drag to dismiss a toast
|
127 | * `Default: 80`
|
128 | */
|
129 | draggablePercent?: number;
|
130 | /**
|
131 | * Specify in which direction should you swipe to dismiss the toast
|
132 | * `Default: "x"`
|
133 | */
|
134 | draggableDirection?: DraggableDirection;
|
135 | /**
|
136 | * Define the ARIA role for the toast
|
137 | * `Default: alert`
|
138 | * https://www.w3.org/WAI/PF/aria/roles
|
139 | */
|
140 | role?: string;
|
141 | /**
|
142 | * Set id to handle multiple container
|
143 | */
|
144 | containerId?: Id;
|
145 | /**
|
146 | * Fired when clicking inside toaster
|
147 | */
|
148 | onClick?: (event: React__default.MouseEvent) => void;
|
149 | |
150 |
|
151 |
|
152 |
|
153 | rtl?: boolean;
|
154 | |
155 |
|
156 |
|
157 |
|
158 | icon?: ToastIcon;
|
159 | |
160 |
|
161 |
|
162 |
|
163 |
|
164 | theme?: Theme;
|
165 | |
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 | customProgressBar?: boolean;
|
172 | }
|
173 | interface ToastOptions<Data = unknown> extends CommonOptions {
|
174 | |
175 |
|
176 |
|
177 | className?: ToastClassName;
|
178 | |
179 |
|
180 |
|
181 | onOpen?: () => void;
|
182 | |
183 |
|
184 |
|
185 |
|
186 |
|
187 | onClose?: (reason?: boolean | string) => void;
|
188 | |
189 |
|
190 |
|
191 | style?: React__default.CSSProperties;
|
192 | |
193 |
|
194 |
|
195 |
|
196 | type?: TypeOptions;
|
197 | |
198 |
|
199 |
|
200 | toastId?: Id;
|
201 | |
202 |
|
203 |
|
204 | updateId?: Id;
|
205 | |
206 |
|
207 |
|
208 | progress?: number;
|
209 | |
210 |
|
211 |
|
212 | data?: Data;
|
213 | |
214 |
|
215 |
|
216 | ariaLabel?: string;
|
217 | |
218 |
|
219 |
|
220 | delay?: number;
|
221 | isLoading?: boolean;
|
222 | }
|
223 | interface UpdateOptions<T = unknown> extends Nullable<ToastOptions<T>> {
|
224 | |
225 |
|
226 |
|
227 |
|
228 | render?: ToastContent<T>;
|
229 | }
|
230 | interface ToastContainerProps extends CommonOptions, Pick<HTMLAttributes<HTMLElement>, 'aria-label'> {
|
231 | |
232 |
|
233 |
|
234 | className?: ToastClassName;
|
235 | |
236 |
|
237 |
|
238 | stacked?: boolean;
|
239 | |
240 |
|
241 |
|
242 |
|
243 | newestOnTop?: boolean;
|
244 | |
245 |
|
246 |
|
247 | style?: React__default.CSSProperties;
|
248 | |
249 |
|
250 |
|
251 | toastStyle?: React__default.CSSProperties;
|
252 | |
253 |
|
254 |
|
255 | toastClassName?: ToastClassName;
|
256 | |
257 |
|
258 |
|
259 | limit?: number;
|
260 | |
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | hotKeys?: (e: KeyboardEvent) => boolean;
|
270 | }
|
271 | interface ToastTransitionProps {
|
272 | isIn: boolean;
|
273 | done: () => void;
|
274 | position: ToastPosition | string;
|
275 | preventExitTransition: boolean;
|
276 | nodeRef: React__default.RefObject<HTMLElement>;
|
277 | children?: React__default.ReactNode;
|
278 | playToast(): void;
|
279 | }
|
280 |
|
281 |
|
282 |
|
283 | interface ToastProps extends ToastOptions {
|
284 | isIn: boolean;
|
285 | staleId?: Id;
|
286 | toastId: Id;
|
287 | key: Id;
|
288 | transition: ToastTransition;
|
289 | closeToast: CloseToastFunc;
|
290 | position: ToastPosition;
|
291 | children?: ToastContent;
|
292 | draggablePercent: number;
|
293 | draggableDirection?: DraggableDirection;
|
294 | progressClassName?: ToastClassName;
|
295 | className?: ToastClassName;
|
296 | deleteToast: () => void;
|
297 | theme: Theme;
|
298 | type: TypeOptions;
|
299 | collapseAll: () => void;
|
300 | stacked?: boolean;
|
301 | }
|
302 | type ToastItemStatus = 'added' | 'removed' | 'updated';
|
303 | interface ToastItem<Data = {}> {
|
304 | content: ToastContent<Data>;
|
305 | id: Id;
|
306 | theme?: Theme;
|
307 | type?: TypeOptions;
|
308 | isLoading?: boolean;
|
309 | containerId?: Id;
|
310 | data: Data;
|
311 | icon?: ToastIcon;
|
312 | status: ToastItemStatus;
|
313 | reason?: boolean | string;
|
314 | }
|
315 | type OnChangeCallback = (toast: ToastItem) => void;
|
316 | type IdOpts = {
|
317 | id?: Id;
|
318 | containerId?: Id;
|
319 | };
|
320 | type ClearWaitingQueueFunc = typeof clearWaitingQueue;
|
321 |
|
322 | declare const enum Default {
|
323 | COLLAPSE_DURATION = 300,
|
324 | DEBOUNCE_DURATION = 50,
|
325 | CSS_NAMESPACE = "Toastify",
|
326 | DRAGGABLE_PERCENT = 80,
|
327 | CONTAINER_ID = 1
|
328 | }
|
329 |
|
330 | interface CSSTransitionProps {
|
331 | |
332 |
|
333 |
|
334 | enter: string;
|
335 | |
336 |
|
337 |
|
338 | exit: string;
|
339 | |
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | appendPosition?: boolean;
|
346 | |
347 |
|
348 |
|
349 |
|
350 | collapse?: boolean;
|
351 | |
352 |
|
353 |
|
354 |
|
355 | collapseDuration?: number;
|
356 | }
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 | declare function cssTransition({ enter, exit, appendPosition, collapse, collapseDuration }: CSSTransitionProps): ({ children, position, preventExitTransition, done, nodeRef, isIn, playToast }: ToastTransitionProps) => React__default.JSX.Element;
|
371 |
|
372 |
|
373 |
|
374 |
|
375 | declare function collapseToast(node: HTMLElement, done: () => void, duration?: Default): void;
|
376 |
|
377 | declare function toast<TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>): Id;
|
378 | declare namespace toast {
|
379 | var loading: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>) => Id;
|
380 | var promise: typeof handlePromise;
|
381 | var success: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>) => Id;
|
382 | var info: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>) => Id;
|
383 | var error: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>) => Id;
|
384 | var warning: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>) => Id;
|
385 | var warn: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>) => Id;
|
386 | var dark: (content: ToastContent, options?: ToastOptions) => Id;
|
387 | var dismiss: {
|
388 | (params: RemoveParams): void;
|
389 | (params?: Id): void;
|
390 | };
|
391 | var clearWaitingQueue: (p?: ClearWaitingQueueParams) => void;
|
392 | var isActive: typeof isToastActive;
|
393 | var update: <TData = unknown>(toastId: Id, options?: UpdateOptions<TData>) => void;
|
394 | var done: (id: Id) => void;
|
395 | var onChange: (cb: OnChangeCallback) => () => void;
|
396 | var play: (opts?: IdOpts) => void;
|
397 | var pause: (opts?: IdOpts) => void;
|
398 | }
|
399 | interface ToastPromiseParams<TData = unknown, TError = unknown, TPending = unknown> {
|
400 | pending?: string | UpdateOptions<TPending>;
|
401 | success?: string | UpdateOptions<TData>;
|
402 | error?: string | UpdateOptions<TError>;
|
403 | }
|
404 | declare function handlePromise<TData = unknown, TError = unknown, TPending = unknown>(promise: Promise<TData> | (() => Promise<TData>), { pending, error, success }: ToastPromiseParams<TData, TError, TPending>, options?: ToastOptions<TData>): Promise<TData>;
|
405 | interface RemoveParams {
|
406 | id?: Id;
|
407 | containerId: Id;
|
408 | }
|
409 |
|
410 | export { Bounce, type ClearWaitingQueueFunc, type ClearWaitingQueueParams, CloseButton, type CloseButtonProps, type DraggableDirection, Flip, type IconProps, Icons, type Id, type OnChangeCallback, Slide, type Theme, type ToastClassName, ToastContainer, type ToastContainerProps, type ToastContent, type ToastContentProps, type ToastItem, type ToastOptions, type ToastPosition, type ToastPromiseParams, type ToastTransition, type ToastTransitionProps, type TypeOptions, type UpdateOptions, Zoom, collapseToast, cssTransition, toast };
|