-
-
Notifications
You must be signed in to change notification settings - Fork 702
/
Copy pathindex.ts
277 lines (234 loc) Β· 5.32 KB
/
index.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
import * as React from 'react';
type Nullable<T> = {
[P in keyof T]: T[P] | null;
};
export type TypeOptions =
| 'info'
| 'success'
| 'warning'
| 'error'
| 'default'
| 'dark';
export type ToastPosition =
| 'top-right'
| 'top-center'
| 'top-left'
| 'bottom-right'
| 'bottom-center'
| 'bottom-left';
export interface ToastContentProps {
closeToast?: () => void;
}
export type ToastContent =
| React.ReactNode
| ((props: ToastContentProps) => React.ReactNode);
export interface Toast {
content: ToastContent;
props: ToastProps;
}
export type Id = number | string;
export type ToastTransition =
| React.FC<ToastTransitionProps>
| React.ComponentClass<ToastTransitionProps>;
type ClassName = string | null;
export interface ClearWaitingQueueParams {
containerId?: Id;
}
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.ReactElement
| ((props: any) => React.ReactElement)
| boolean;
/**
* An optional css class to set for the progress bar.
*/
progressClassName?: ClassName;
/**
* An optional style to set for the progress bar.
*/
progressStyle?: React.CSSProperties;
/**
* An optional css class to set.
*/
className?: ClassName;
/**
* An optional css class to set for the toast content.
*/
bodyClassName?: ClassName;
/**
* An optional inline style to apply for the toast content.
*/
bodyStyle?: React.CSSProperties;
/**
* Hide or show the progress bar.
* `Default: false`
*/
hideProgressBar?: boolean;
/**
* Pass a custom transition built with react-transition-group.
*/
transition?: ToastTransition;
/**
* 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;
/**
* Define the ARIA role for the toast
* `Default: alert`
* https://www.w3.org/WAI/PF/aria/roles
*/
role?: string;
/**
* Set id to handle multiple container
*/
containerId?: Id;
/**
* Fired when clicking inside toaster
*/
onClick?: (event: React.MouseEvent) => void;
/**
* Support right to left display.
* `Default: false`
*/
rtl?: boolean;
}
export interface ToastOptions extends CommonOptions {
/**
* Called when toast is mounted.
*/
onOpen?: <T = {}>(props: T) => void;
/**
* Called when toast is unmounted.
*/
onClose?: <T = {}>(props: T) => void;
/**
* An optional inline style to apply.
*/
style?: React.CSSProperties;
/**
* Set the toast type.
* `One of: 'info', 'success', 'warning', 'error', 'default'`
*/
type?: TypeOptions;
/**
* Set a custom `toastId`
*/
toastId?: Id;
/**
* Used during update
*/
updateId?: Id;
/**
* Set the percentage for the controlled progress bar. `Value must be between 0 and 1.`
*/
progress?: number | string;
/**
* Add a delay in ms before the toast appear.
*/
delay?: number;
}
/**
* @INTERNAL
*/
export interface ToastProps extends ToastOptions {
in?: boolean;
staleId?: Id;
toastId: Id;
key: Id;
transition: ToastTransition;
closeToast: () => void;
position: ToastPosition;
children?: ToastContent;
draggablePercent: number;
progressClassName?: ClassName;
className?: ClassName;
bodyClassName?: ClassName;
deleteToast: () => void;
}
/**
* @INTERNAL
*/
export interface NotValidatedToastProps extends Partial<ToastProps> {
toastId: Id;
}
export interface UpdateOptions extends Nullable<ToastOptions> {
/**
* Used to update a toast.
* Pass any valid ReactNode(string, number, component)
*/
render?: ToastContent;
}
export 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?: React.CSSProperties;
/**
* An optional inline style to apply for the toast.
*/
toastStyle?: React.CSSProperties;
/**
* An optional css class for the toast.
*/
toastClassName?: ClassName;
/**
* Show the toast only if it includes containerId and it's the same as containerId
* `Default: false`
*/
enableMultiContainer?: boolean;
/**
* Limit the number of toast displayed at the same time
*/
limit?: number;
}
export interface ToastTransitionProps {
in: boolean;
appear: boolean;
done: () => void;
position: ToastPosition | string;
preventExitTransition: boolean;
nodeRef: React.RefObject<HTMLElement>;
children?: React.ReactNode;
}