-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathtoast.ts
147 lines (139 loc) · 3.38 KB
/
toast.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
import type { Component } from "vue"
import type { TYPE, POSITION } from "../ts/constants"
import type {
Button,
ClassNames,
Draggable,
EventBusable,
Focusable,
Hoverable,
Icon,
ToastID,
} from "./common"
export declare interface BaseToastOptions
extends EventBusable,
Draggable,
Hoverable,
Focusable {
/**
* Position of the toast on the screen.
*
* Can be any of top-right, top-center, top-left, bottom-right, bottom-center, bottom-left.
*/
position?: POSITION
/**
* Whether or not the toast is closed when clicked.
*/
closeOnClick?: boolean
/**
* How many milliseconds for the toast to be auto dismissed, or false to disable.
*/
timeout?: number | false
/**
* Custom classes applied to the toast.
*/
toastClassName?: ClassNames
/**
* Custom classes applied to the body of the toast.
*/
bodyClassName?: ClassNames
/**
* Whether or not the progress bar is hidden.
*/
hideProgressBar?: boolean
/**
* Only shows the close button when hovering the toast
*/
showCloseButtonOnHover?: boolean
/**
* Custom icon class to be used.
*
* When set to `true`, the icon is set automatically depending on the toast type and `false` disables the icon.
*/
icon?: Icon
/**
* Custom close button component
*
* Alternative close button component to be displayed in toasts
*/
closeButton?: Button
/**
* Custom classes applied to the close button of the toast.
*/
closeButtonClassName?: ClassNames
/**
* Accessibility options
*/
accessibility?: {
/**
* Toast accessibility role
*
* Accessibility option "role" for screen readers. Defaults to "alert".
*/
toastRole?: string
/**
* Close button label
*
* Accessibility option of the closeButton's "label" for screen readers. Defaults to "close".
*/
closeButtonLabel?: string
}
/**
* Right-to-Left support.
*
* If true, switches the toast contents from right to left. Defaults to false.
*/
rtl?: boolean
}
export declare interface ToastOptions extends BaseToastOptions {
/**
* ID of the toast.
*/
id?: ToastID
/**
* If unsafe HTML is allowed as content.
*/
allowUnsafeHtml?: boolean
/**
* Type of the toast.
*
* Can be any of `success error default info warning`
*/
type?: TYPE
/**
* Callback executed when the toast is clicked.
*
* A closeToast callback is passed as argument to onClick when it is called.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
onClick?: (closeToast: Function) => void
/**
* Callback executed when the toast is closed.
*/
onClose?: () => void
}
export declare type RenderableToastContent = string | Component
export declare interface ToastComponent {
/**
* Component that will be rendered.
*/
component: ToastContent
/**
* `propName: propValue` pairs of props that will be passed to the component.
*
* __These are not reactive__
*/
props?: { [propName: string]: unknown }
/**
* `eventName: eventHandler` pairs of events that the component can emit.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
listeners?: { [listenerEvent: string]: Function }
}
export declare type ToastContent =
| RenderableToastContent
| JSX.Element
| ToastComponent
export declare type ToastOptionsAndContent = ToastOptions & {
content: ToastContent
}