-
Notifications
You must be signed in to change notification settings - Fork 175
/
index.d.ts
93 lines (78 loc) · 2.75 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
import { ReactNode, ComponentType } from 'react';
export type AppearanceTypes = 'error' | 'info' | 'success' | 'warning';
export type Placement = 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right';
export type TransitionState = 'entering' | 'entered' | 'exiting' | 'exited';
export interface ToastProps {
appearance: AppearanceTypes;
autoDismiss: boolean | number; // inherited from ToastProvider
autoDismissTimeout: number; // inherited from ToastProvider
children: ReactNode;
isRunning: boolean;
onDismiss: (id?: string) => void;
onMouseEnter: () => void;
onMouseLeave: () => void;
placement: Placement;
transitionDuration: number; // inherited from ToastProvider
transitionState: TransitionState; // inherited from ToastProvider
}
export interface ToastConsumerContext {
add: AddToast;
remove: RemoveToast;
toasts: Array<{
content: ReactNode;
id: string;
appearance: AppearanceTypes;
}>;
}
export interface ToastConsumerProps {
children: (context: ToastConsumerContext) => ReactNode;
}
export interface ToastContainerProps {
children: ReactNode;
className?: string;
hasToasts: boolean;
placement: Placement;
}
export interface ToastProviderProps {
autoDismiss?: boolean | number;
autoDismissTimeout?: number;
children: ReactNode;
components?: {
ToastContainer?: ComponentType<ToastContainerProps>;
Toast?: ComponentType<ToastProps>;
};
newestOnTop?: boolean;
placement?: Placement;
transitionDuration?: number;
portalTargetSelector?: string;
}
export interface Options {
appearance?: AppearanceTypes;
autoDismiss?: boolean;
id?: string;
onDismiss?: (id: string) => void;
[key: string]: any;
}
export interface UpdateOptions extends Options {
content?: ReactNode;
}
export type AddToast = (content: ReactNode, options?: Options, callback?: (id: string) => void) => void;
export type RemoveToast = (id: string, callback?: (id: string) => void) => void;
export type RemoveAllToasts = () => void;
export type UpdateToast = (id: string, options?: UpdateOptions, callback?: (id: string) => void) => void;
export const DefaultToastContainer: ComponentType<ToastContainerProps>;
export const DefaultToast: ComponentType<ToastProps>;
export const ToastConsumer: ComponentType<ToastConsumerProps>;
export const ToastProvider: ComponentType<ToastProviderProps>;
export function withToastManager(...args: any[]): any;
export function useToasts(): {
addToast: AddToast;
removeToast: RemoveToast;
removeAllToasts: RemoveAllToasts;
toastStack: Array<{
content: ReactNode;
id: string;
appearance: AppearanceTypes;
}>;
updateToast: UpdateToast;
};