UNPKG

7.62 kBTypeScriptView Raw
1export * from './dialogs-common';
2/**
3 * Defines the input type for prompt dialog.
4 */
5export namespace inputType {
6 /**
7 * Plain text input type.
8 */
9 export const text: string;
10
11 /**
12 * Password input type.
13 */
14 export const password: string;
15
16 /**
17 * Email input type.
18 */
19 export const email: string;
20
21 /**
22 * Number input type.
23 */
24 export const number: string;
25
26 /**
27 * Decimal input type.
28 */
29 export const decimal: string;
30
31 /**
32 * Phone input type.
33 */
34 export const phone: string;
35}
36
37/**
38 * Defines the capitalization type for prompt dialog.
39 */
40export namespace capitalizationType {
41 /**
42 * No automatic capitalization.
43 */
44 export const none: string;
45
46 /**
47 * Capitalizes every character.
48 */
49 export const all: string;
50
51 /**
52 * Capitalize the first word of each sentence.
53 */
54 export const sentences: string;
55
56 /**
57 * Capitalize the first letter of every word.
58 */
59 export const words: string;
60}
61
62/**
63 * The alert() method displays an alert box with a specified message.
64 * @param message Specifies the text to display in the alert box.
65 */
66export function alert(message: string | number | boolean): Promise<void>;
67
68/**
69 * The alert() method displays an alert box with a specified message.
70 * @param options Specifies the options for the alert box.
71 */
72export function alert(options: AlertOptions): Promise<void>;
73
74/**
75 * The confirm() method displays a dialog box with a specified message.
76 * @param message Specifies the text to display in the confirm box.
77 */
78export function confirm(message: string): Promise<boolean>;
79
80/**
81 * The confirm() method displays a dialog box with a specified message.
82 * @param options Specifies the options for the confirm box.
83 */
84export function confirm(options: ConfirmOptions): Promise<boolean>;
85
86/**
87 * The prompt() method displays a dialog box that prompts the visitor for input.
88 * @param message The text to display in the dialog box.
89 * @param defaultText The default text to display in the input box. Optional.
90 */
91export function prompt(message: string, defaultText?: string): Promise<PromptResult>;
92
93/**
94 * The prompt() method displays a dialog box that prompts the visitor for input.
95 * @param options The options for the dialog box.
96 */
97export function prompt(options: PromptOptions): Promise<PromptResult>;
98
99/**
100 * The login() method displays a login dialog box that prompts the visitor for user name and password.
101 * @param message The text to display in the dialog box.
102 * @param userNameHint The default text to display as a hint in the username input. Optional.
103 * @param passwordHint The default text to display as a hint in the password input. Optional.
104 * @param userName The default text to display in the user name input box. Optional.
105 * @param password The default text to display in the password input box. Optional.
106 */
107export function login(message: string, userNameHint?: string, passwordHint?: string, userName?: string, password?: string): Promise<LoginResult>;
108
109/**
110 * The login() method displays a login dialog box that prompts the visitor for user name and password.
111 * @param message The text to display in the dialog box.
112 * @param userNameHint The default text to display as a hint in the username input. Optional.
113 * @param passwordHint The default text to display as a hint in the password input. Optional.
114 */
115export function login(message: string, userNameHint?: string, passwordHint?: string): Promise<LoginResult>;
116
117/**
118 * The login() method displays a login dialog box that prompts the visitor for user name and password.
119 * @param options The options for the dialog box.
120 */
121export function login(options: LoginOptions): Promise<LoginResult>;
122
123/**
124 * The action() method displays a action box that prompts the visitor to choose some action.
125 * @param message The text to display in the dialog box.
126 * @param cancelButtonText The text to display in the cancel button.
127 * @param actions List of available actions.
128 */
129export function action(message: string, cancelButtonText: string, actions: Array<string>): Promise<string>;
130
131/**
132 * The action() method displays a action box that prompts the visitor to choose some action.
133 * @param options The options for the dialog box.
134 */
135export function action(options: ActionOptions): Promise<string>;
136
137/**
138 * Provides options for the dialog.
139 */
140export interface CancelableOptions {
141 /**
142 * [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
143 */
144 cancelable?: boolean;
145
146 /**
147 * [Android only] Sets the theme of the Dialog. Usable themes can be found: https://developer.android.com/reference/android/R.style
148 */
149 theme?: number;
150}
151
152/**
153 * Provides options for the dialog.
154 */
155export interface ActionOptions extends CancelableOptions {
156 /**
157 * Gets or sets the dialog title.
158 */
159 title?: string;
160
161 /**
162 * Gets or sets the dialog message.
163 */
164 message?: string;
165
166 /**
167 * Gets or sets the Cancel button text.
168 */
169 cancelButtonText?: string;
170
171 /**
172 * Gets or sets the list of available actions.
173 */
174 actions?: Array<string>;
175
176 /**
177 * [iOS only] Gets or sets the indexes of destructive actions.
178 */
179 destructiveActionsIndexes?: Array<number>;
180}
181
182/**
183 * Provides options for the dialog.
184 */
185export interface DialogOptions extends CancelableOptions {
186 /**
187 * Gets or sets the dialog title.
188 */
189 title?: string;
190
191 /**
192 * Gets or sets the dialog message.
193 */
194 message?: string;
195}
196
197/**
198 * Provides options for the alert.
199 */
200export interface AlertOptions extends DialogOptions {
201 /**
202 * Gets or sets the OK button text.
203 */
204 okButtonText?: string;
205}
206
207/**
208 * Provides options for the confirm dialog.
209 */
210export interface ConfirmOptions extends AlertOptions {
211 /**
212 * Gets or sets the Cancel button text.
213 */
214 cancelButtonText?: string;
215
216 /**
217 * Gets or sets the neutral button text.
218 */
219 neutralButtonText?: string;
220}
221
222/**
223 * Provides options for the prompt dialog.
224 */
225export interface PromptOptions extends ConfirmOptions {
226 /**
227 * Gets or sets the default text to display in the input box.
228 */
229 defaultText?: string;
230
231 /**
232 * Gets or sets the prompt input type (plain text, password, or email).
233 */
234 inputType?: string;
235
236 /**
237 * Gets or sets the prompt capitalizationType (none, all, sentences, or words).
238 */
239 capitalizationType?: string;
240}
241
242/**
243 * Provides options for the login dialog.
244 */
245export interface LoginOptions extends ConfirmOptions {
246 /**
247 * Gets or sets the default text to display as hint in the user name input box.
248 */
249 userNameHint?: string;
250
251 /**
252 * Gets or sets the default text to display as hint in the password input box.
253 */
254 passwordHint?: string;
255
256 /**
257 * Gets or sets the default text to display in the user name input box.
258 */
259 userName?: string;
260
261 /**
262 * Gets or sets the default text to display in the password input box.
263 */
264 password?: string;
265}
266
267/**
268 * Provides result data from the prompt dialog.
269 */
270export interface PromptResult {
271 /**
272 * Gets or sets the prompt dialog boolean result.
273 */
274 result: boolean;
275
276 /**
277 * Gets or sets the text entered in the prompt dialog.
278 */
279 text: string;
280}
281
282/**
283 * Provides result data from the login dialog.
284 */
285export interface LoginResult {
286 /**
287 * Gets or sets the login dialog boolean result.
288 */
289 result: boolean;
290
291 /**
292 * Gets or sets the user entered in the login dialog.
293 */
294 userName: string;
295
296 /**
297 * Gets or sets the password entered in the login dialog.
298 */
299 password: string;
300}
301
302/**
303 * Singular rollup for convenience of all dialog methods
304 */
305export declare const Dialogs: {
306 alert: typeof alert;
307 confirm: typeof confirm;
308 prompt: typeof prompt;
309 login: typeof login;
310 action: typeof action;
311};