forked from StefanKoenen/typed-sweetalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
232 lines (194 loc) · 7.43 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
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
// Type definitions for SweetAlert 1.3.0
/**
* SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert.
* @param title The title of the modal.
*/
declare function swal(title: string): Promise<boolean>;
/**
* SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert.
* @param title The title of the modal.
* @param text A description for the modal.
*/
declare function swal(title: string, text: string): Promise<boolean>;
/**
* SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert.
* @param title The title of the modal.
* @param text A description for the modal.
* @param type The type of the modal. SweetAlert comes with 4 built-in types which will show a corresponding icon animation: "warning", "error", "success" and "info". You can also set it as "input" to get a prompt modal.
*/
declare function swal(title: string, text: string, type: 'warning' | 'error' | 'success' | 'info' | 'question'): Promise<boolean>;
/**
* SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. An awesome replacement for JavaScript's alert.
* @param callback The callback from the users action. The value is true or false if the user confirms or cancels the alert. Except for the type "input", then when the user confirms the alert, the argument contains the value of the input element.
*/
declare function swal(settings: swal.SweetAlertOptions): Promise<boolean>;
declare namespace swal {
export interface SweetAlertOptions {
/**
* The title of the modal. It can either be added to the object under the key "title" or passed as the first parameter of the function.
* Default: null
*/
title?: string;
/**
* A description for the modal.
* Default: null
*/
text?: string;
/**
* A HTML description for the modal. If "text" and "html" parameters are provided in the same time, "text" will be used.
* Default: null
*/
html?: string;
/**
* The type of the modal. SweetAlert2 comes with 5 built-in types which will show a corresponding icon animation: warning, error, success, info and question. It can either be put in the array under the key type or passed as the third parameter of the function.
* Default: null
*/
type?: 'warning' | 'error' | 'success' | 'info' | 'question';
/**
* A custom CSS class for the modal.
* Default: null
*/
customClass?: string;
/**
* Defines the type of input to show on the sweetalert
* Default: null
*/
input?: string;
/**
* If set to true, loader icon will display on confirmation
* Default: false
*/
showLoaderOnConfirm?: boolean;
/**
* Function which is executed before confirmation
* Default: null
*/
preConfirm?: Function;
/**
* If set to false, modal CSS animation will be disabled.
* Default: true
*/
animation?: boolean;
/**
* If set to false, the user can't dismiss the modal by clicking outside it.
* Default: true
*/
allowOutsideClick?: boolean;
/**
* If set to false, the user can't dismiss the modal by pressing the Escape key.
* Default: true
*/
allowEscapeKey?: boolean;
/**
* If set to false, a "Confirm"-button will not be shown. It can be useful when you're using html parameter for custom HTML description.
* Default: true
*/
showConfirmButton?: boolean;
/**
* If set to true, a "Cancel"-button will be shown, which the user can click on to dismiss the modal.
* Default: false
*/
showCancelButton?: boolean;
/**
* Use this to change the text on the "Confirm"-button.
* Default: "OK"
*/
confirmButtonText?: string;
/**
* Use this to change the text on the "Cancel"-button.
* Default: "Cancel"
*/
cancelButtonText?: string;
/**
* Use this to change the background color of the "Confirm"-button (must be a HEX value).
* Default: "#3085d6"
*/
confirmButtonColor?: string;
/**
* Use this to change the background color of the "Cancel"-button (must be a HEX value).
* Default: "#aaa"
*/
cancelButtonColor?: string;
/**
* A custom CSS class for the "Confirm"-button.
* Default: null
*/
confirmButtonClass?: string;
/**
* A custom CSS class for the "Cancel"-button.
* Default: null
*/
cancelButtonClass?: string;
/**
* Apply default swal2 styling to buttons. If you want to use your own classes (e.g. Bootstrap classes) set this parameter to false.
* Default: true
*/
buttonStyling?: boolean;
/**
* Set this parameter to true if you want to invert default buttons positions.
* Default: false
*/
reverseButtons?: boolean;
/**
* Set this parameter to true to show close button in top right corner of the modal.
* Default: false
*/
showCloseButton?: boolean;
/**
* Set to false if you want the modal to stay open even if the user presses the "Confirm"-button.
* This is especially useful if the function attached to the "Confirm"-button is another SweetAlert2.
* Default: true
*/
closeOnConfirm?: boolean;
/**
* Add a customized icon for the modal. Should contain a string with the path or URL to the image.
* Default: null
*/
imageUrl?: string;
/**
* If imageUrl is set, you can specify imageWidth to describes image width in px.
* Default: null
*/
imageWidth?: number;
/**
* Custom image height in px.
* Default: null
*/
imageHeight?: number;
/**
* A custom CSS class for the customized icon.
* Default: null
*/
imageClass?: string;
/**
* Auto close timer of the modal. Set in ms (milliseconds).
* Default: null
*/
timer?: number;
/**
* Modal window width, including paddings (box-sizing: border-box).
* Default: 500
*/
width?: number;
/**
* Modal window padding.
* @type Default: number
*/
padding?: number;
/**
* Modal window background (CSS background property).
* @type Default: "#fff"
*/
background?: string;
/**
* Input validator (Promise function)
* Default: null
*/
inputValidator?: Function;
}
/**
* If you end up using a lot of the same settings when calling SweetAlert, you can use setDefaults at the start of your program to set them once and for all!
*/
export function setDefaults(settings: SweetAlertOptions): void;
}
export = swal;