-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathtypes.ts
More file actions
194 lines (174 loc) Β· 4.16 KB
/
types.ts
File metadata and controls
194 lines (174 loc) Β· 4.16 KB
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
import type { CSSProperties, Component } from 'vue'
export type ToastTypes =
| 'normal'
| 'action'
| 'success'
| 'info'
| 'warning'
| 'error'
| 'loading'
| 'default'
export type PromiseT<Data = any> = Promise<Data> | (() => Promise<Data>)
export type PromiseTResult<Data = any> =
| string
| Component
| ((data: Data) => Component | string | Promise<Component | string>)
export type PromiseExternalToast = Omit<ExternalToast, 'description'>
export type PromiseData<ToastData = any> = ExternalToast & {
loading?: string | Component
success?: PromiseTResult<ToastData>
error?: PromiseTResult
description?: PromiseTResult
finally?: () => void | Promise<void>
}
export interface ToastClasses {
toast?: string
title?: string
description?: string
loader?: string
closeButton?: string
cancelButton?: string
actionButton?: string
success?: string
error?: string
info?: string
warning?: string
loading?: string
default?: string
content?: string
icon?: string
}
export interface ToastIcons {
success?: Component
info?: Component
warning?: Component
error?: Component
loading?: Component
close?: Component
}
export interface Action {
label: Component | string
onClick: (event: MouseEvent) => void
actionButtonStyle?: CSSProperties
}
export interface ToastT<T extends Component = Component> {
id: number | string
title?: string | Component
type?: ToastTypes
icon?: Component
component?: T
componentProps?: any
richColors?: boolean
invert?: boolean
closeButton?: boolean
dismissible?: boolean
description?: string | Component
duration?: number
delete?: boolean
important?: boolean
action?: Action | Component
cancel?: Action | Component
onDismiss?: (toast: ToastT) => void
onAutoClose?: (toast: ToastT) => void
promise?: PromiseT
cancelButtonStyle?: CSSProperties
actionButtonStyle?: CSSProperties
style?: CSSProperties
unstyled?: boolean
class?: string
classes?: ToastClasses
descriptionClass?: string
position?: Position
}
export function isAction(action: Action | Component): action is Action {
return (action as Action).label !== undefined
}
export type Position =
| 'top-left'
| 'top-right'
| 'bottom-left'
| 'bottom-right'
| 'top-center'
| 'bottom-center'
export interface HeightT {
height: number
toastId: number | string
position: Position
}
export interface ToastOptions {
class?: string
closeButton?: boolean
descriptionClass?: string
style?: CSSProperties
cancelButtonStyle?: CSSProperties
actionButtonStyle?: CSSProperties
duration?: number
unstyled?: boolean
classes?: ToastClasses
}
export type CnFunction = (...classes: Array<string | undefined>) => string
export interface ToasterProps {
invert?: boolean
theme?: Theme
position?: Position
hotkey?: string[]
richColors?: boolean
expand?: boolean
duration?: number
gap?: number
visibleToasts?: number
closeButton?: boolean
toastOptions?: ToastOptions
class?: string
style?: CSSProperties
offset?: string | number
dir?: 'rtl' | 'ltr' | 'auto'
icons?: ToastIcons
containerAriaLabel?: string
pauseWhenPageIsHidden?: boolean
cn?: CnFunction
}
export interface ToastProps {
toast: ToastT
toasts: ToastT[]
index: number
expanded: boolean
invert: boolean
heights: HeightT[]
gap?: number
position: Position
visibleToasts: number
expandByDefault: boolean
closeButton: boolean
interacting: boolean
style?: CSSProperties
cancelButtonStyle?: CSSProperties
actionButtonStyle?: CSSProperties
duration?: number
class: string
unstyled?: boolean
descriptionClass?: string
loadingIcon?: Component
classes?: ToastClasses
icons?: ToastIcons
closeButtonAriaLabel?: string
pauseWhenPageIsHidden: boolean
cn: CnFunction
defaultRichColors?: boolean
}
export enum SwipeStateTypes {
SwipedOut = 'SwipedOut',
SwipedBack = 'SwipedBack',
NotSwiped = 'NotSwiped'
}
export type Theme = 'light' | 'dark' | 'system'
export interface ToastToDismiss {
id: number | string
dismiss: boolean
}
export type ExternalToast<T extends Component = Component> = Omit<
ToastT<T>,
'id' | 'type' | 'title' | 'promise' | 'delete'
> & {
id?: number | string
}