@jupyterlab/apputils 0.19.1-alpha.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +34 -0
- package/lib/clientsession.d.ts +443 -443
- package/lib/clientsession.js +883 -883
- package/lib/clipboard.d.ts +33 -33
- package/lib/clipboard.js +88 -88
- package/lib/commandlinker.d.ts +121 -121
- package/lib/commandlinker.js +175 -175
- package/lib/commandpalette.d.ts +33 -33
- package/lib/commandpalette.js +12 -12
- package/lib/dialog.d.ts +357 -357
- package/lib/dialog.js +540 -540
- package/lib/domutils.d.ts +13 -13
- package/lib/domutils.js +28 -28
- package/lib/hoverbox.d.ts +82 -82
- package/lib/hoverbox.js +101 -101
- package/lib/iframe.d.ts +14 -14
- package/lib/iframe.js +45 -45
- package/lib/index.d.ts +19 -19
- package/lib/index.js +26 -26
- package/lib/instancetracker.d.ts +278 -278
- package/lib/instancetracker.js +318 -318
- package/lib/mainareawidget.d.ts +108 -108
- package/lib/mainareawidget.js +184 -184
- package/lib/sanitizer.d.ts +44 -44
- package/lib/sanitizer.js +913 -913
- package/lib/spinner.d.ts +15 -15
- package/lib/spinner.js +30 -30
- package/lib/splash.d.ts +19 -19
- package/lib/splash.js +10 -10
- package/lib/styling.d.ts +27 -27
- package/lib/styling.js +92 -92
- package/lib/thememanager.d.ts +141 -141
- package/lib/thememanager.js +238 -238
- package/lib/toolbar.d.ts +178 -178
- package/lib/toolbar.js +515 -515
- package/lib/vdom.d.ts +90 -90
- package/lib/vdom.js +130 -130
- package/lib/windowresolver.d.ts +37 -37
- package/lib/windowresolver.js +173 -173
- package/package.json +9 -6
package/lib/dialog.d.ts
CHANGED
|
@@ -1,357 +1,357 @@
|
|
|
1
|
-
import { Message } from '@phosphor/messaging';
|
|
2
|
-
import { Widget } from '@phosphor/widgets';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Create and show a dialog.
|
|
6
|
-
*
|
|
7
|
-
* @param options - The dialog setup options.
|
|
8
|
-
*
|
|
9
|
-
* @returns A promise that resolves with whether the dialog was accepted.
|
|
10
|
-
*/
|
|
11
|
-
export declare function showDialog<T>(options?: Partial<Dialog.IOptions<T>>): Promise<Dialog.IResult<T>>;
|
|
12
|
-
/**
|
|
13
|
-
* Show an error message dialog.
|
|
14
|
-
*
|
|
15
|
-
* @param title - The title of the dialog box.
|
|
16
|
-
*
|
|
17
|
-
* @param error - the error to show in the dialog body (either a string
|
|
18
|
-
* or an object with a string `message` property).
|
|
19
|
-
*/
|
|
20
|
-
export declare function showErrorMessage(title: string, error: any): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* A modal dialog widget.
|
|
23
|
-
*/
|
|
24
|
-
export declare class Dialog<T> extends Widget {
|
|
25
|
-
/**
|
|
26
|
-
* Create a dialog panel instance.
|
|
27
|
-
*
|
|
28
|
-
* @param options - The dialog setup options.
|
|
29
|
-
*/
|
|
30
|
-
constructor(options?: Partial<Dialog.IOptions<T>>);
|
|
31
|
-
/**
|
|
32
|
-
* Dispose of the resources used by the dialog.
|
|
33
|
-
*/
|
|
34
|
-
dispose(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Launch the dialog as a modal window.
|
|
37
|
-
*
|
|
38
|
-
* @returns a promise that resolves with the result of the dialog.
|
|
39
|
-
*/
|
|
40
|
-
launch(): Promise<Dialog.IResult<T>>;
|
|
41
|
-
/**
|
|
42
|
-
* Resolve the current dialog.
|
|
43
|
-
*
|
|
44
|
-
* @param index - An optional index to the button to resolve.
|
|
45
|
-
*
|
|
46
|
-
* #### Notes
|
|
47
|
-
* Will default to the defaultIndex.
|
|
48
|
-
* Will resolve the current `show()` with the button value.
|
|
49
|
-
* Will be a no-op if the dialog is not shown.
|
|
50
|
-
*/
|
|
51
|
-
resolve(index?: number): void;
|
|
52
|
-
/**
|
|
53
|
-
* Reject the current dialog with a default reject value.
|
|
54
|
-
*
|
|
55
|
-
* #### Notes
|
|
56
|
-
* Will be a no-op if the dialog is not shown.
|
|
57
|
-
*/
|
|
58
|
-
reject(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Handle the DOM events for the directory listing.
|
|
61
|
-
*
|
|
62
|
-
* @param event - The DOM event sent to the widget.
|
|
63
|
-
*
|
|
64
|
-
* #### Notes
|
|
65
|
-
* This method implements the DOM `EventListener` interface and is
|
|
66
|
-
* called in response to events on the panel's DOM node. It should
|
|
67
|
-
* not be called directly by user code.
|
|
68
|
-
*/
|
|
69
|
-
handleEvent(event: Event): void;
|
|
70
|
-
/**
|
|
71
|
-
* A message handler invoked on an `'after-attach'` message.
|
|
72
|
-
*/
|
|
73
|
-
protected onAfterAttach(msg: Message): void;
|
|
74
|
-
/**
|
|
75
|
-
* A message handler invoked on an `'after-detach'` message.
|
|
76
|
-
*/
|
|
77
|
-
protected onAfterDetach(msg: Message): void;
|
|
78
|
-
/**
|
|
79
|
-
* A message handler invoked on a `'close-request'` message.
|
|
80
|
-
*/
|
|
81
|
-
protected onCloseRequest(msg: Message): void;
|
|
82
|
-
/**
|
|
83
|
-
* Handle the `'click'` event for a dialog button.
|
|
84
|
-
*
|
|
85
|
-
* @param event - The DOM event sent to the widget
|
|
86
|
-
*/
|
|
87
|
-
protected _evtClick(event: MouseEvent): void;
|
|
88
|
-
/**
|
|
89
|
-
* Handle the `'keydown'` event for the widget.
|
|
90
|
-
*
|
|
91
|
-
* @param event - The DOM event sent to the widget
|
|
92
|
-
*/
|
|
93
|
-
protected _evtKeydown(event: KeyboardEvent): void;
|
|
94
|
-
/**
|
|
95
|
-
* Handle the `'focus'` event for the widget.
|
|
96
|
-
*
|
|
97
|
-
* @param event - The DOM event sent to the widget
|
|
98
|
-
*/
|
|
99
|
-
protected _evtFocus(event: FocusEvent): void;
|
|
100
|
-
/**
|
|
101
|
-
* Resolve a button item.
|
|
102
|
-
*/
|
|
103
|
-
private _resolve;
|
|
104
|
-
private _buttonNodes;
|
|
105
|
-
private _buttons;
|
|
106
|
-
private _original;
|
|
107
|
-
private _first;
|
|
108
|
-
private _primary;
|
|
109
|
-
private _promise;
|
|
110
|
-
private _defaultButton;
|
|
111
|
-
private _host;
|
|
112
|
-
private _body;
|
|
113
|
-
private _focusNodeSelector;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The namespace for Dialog class statics.
|
|
117
|
-
*/
|
|
118
|
-
export declare namespace Dialog {
|
|
119
|
-
/**
|
|
120
|
-
* The options used to create a dialog.
|
|
121
|
-
*/
|
|
122
|
-
interface IOptions<T> {
|
|
123
|
-
/**
|
|
124
|
-
* The top level text for the dialog. Defaults to an empty string.
|
|
125
|
-
*/
|
|
126
|
-
title: HeaderType;
|
|
127
|
-
/**
|
|
128
|
-
* The main body element for the dialog or a message to display.
|
|
129
|
-
* Defaults to an empty string.
|
|
130
|
-
*
|
|
131
|
-
* #### Notes
|
|
132
|
-
* If a widget is given as the body, it will be disposed after the
|
|
133
|
-
* dialog is resolved. If the widget has a `getValue()` method,
|
|
134
|
-
* the method will be called prior to disposal and the value
|
|
135
|
-
* will be provided as part of the dialog result.
|
|
136
|
-
* A string argument will be used as raw `textContent`.
|
|
137
|
-
* All `input` and `select` nodes will be wrapped and styled.
|
|
138
|
-
*/
|
|
139
|
-
body: BodyType<T>;
|
|
140
|
-
/**
|
|
141
|
-
* The host element for the dialog. Defaults to `document.body`.
|
|
142
|
-
*/
|
|
143
|
-
host: HTMLElement;
|
|
144
|
-
/**
|
|
145
|
-
* The to buttons to display. Defaults to cancel and accept buttons.
|
|
146
|
-
*/
|
|
147
|
-
buttons: ReadonlyArray<IButton>;
|
|
148
|
-
/**
|
|
149
|
-
* The index of the default button. Defaults to the last button.
|
|
150
|
-
*/
|
|
151
|
-
defaultButton: number;
|
|
152
|
-
/**
|
|
153
|
-
* A selector for the primary element that should take focus in the dialog.
|
|
154
|
-
* Defaults to an empty string, causing the [[defaultButton]] to take
|
|
155
|
-
* focus.
|
|
156
|
-
*/
|
|
157
|
-
focusNodeSelector: string;
|
|
158
|
-
/**
|
|
159
|
-
* An optional renderer for dialog items. Defaults to a shared
|
|
160
|
-
* default renderer.
|
|
161
|
-
*/
|
|
162
|
-
renderer: IRenderer;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* The options used to make a button item.
|
|
166
|
-
*/
|
|
167
|
-
interface IButton {
|
|
168
|
-
/**
|
|
169
|
-
* The label for the button.
|
|
170
|
-
*/
|
|
171
|
-
label: string;
|
|
172
|
-
/**
|
|
173
|
-
* The icon class for the button.
|
|
174
|
-
*/
|
|
175
|
-
iconClass: string;
|
|
176
|
-
/**
|
|
177
|
-
* The icon label for the button.
|
|
178
|
-
*/
|
|
179
|
-
iconLabel: string;
|
|
180
|
-
/**
|
|
181
|
-
* The caption for the button.
|
|
182
|
-
*/
|
|
183
|
-
caption: string;
|
|
184
|
-
/**
|
|
185
|
-
* The extra class name for the button.
|
|
186
|
-
*/
|
|
187
|
-
className: string;
|
|
188
|
-
/**
|
|
189
|
-
* The dialog action to perform when the button is clicked.
|
|
190
|
-
*/
|
|
191
|
-
accept: boolean;
|
|
192
|
-
/**
|
|
193
|
-
* The button display type.
|
|
194
|
-
*/
|
|
195
|
-
displayType: 'default' | 'warn';
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* The options used to create a button.
|
|
199
|
-
*/
|
|
200
|
-
type ButtonOptions = Partial<IButton>;
|
|
201
|
-
/**
|
|
202
|
-
* The header input types.
|
|
203
|
-
*/
|
|
204
|
-
type HeaderType = React.ReactElement<any> | string;
|
|
205
|
-
/**
|
|
206
|
-
* The result of a dialog.
|
|
207
|
-
*/
|
|
208
|
-
interface IResult<T> {
|
|
209
|
-
/**
|
|
210
|
-
* The button that was pressed.
|
|
211
|
-
*/
|
|
212
|
-
button: IButton;
|
|
213
|
-
/**
|
|
214
|
-
* The value retrieved from `.getValue()` if given on the widget.
|
|
215
|
-
*/
|
|
216
|
-
value: T | null;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* A widget used as a dialog body.
|
|
220
|
-
*/
|
|
221
|
-
interface IBodyWidget<T = string> extends Widget {
|
|
222
|
-
/**
|
|
223
|
-
* Get the serialized value of the widget.
|
|
224
|
-
*/
|
|
225
|
-
getValue?(): T;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* The body input types.
|
|
229
|
-
*/
|
|
230
|
-
type BodyType<T> = IBodyWidget<T> | React.ReactElement<any> | string;
|
|
231
|
-
/**
|
|
232
|
-
* Create an accept button.
|
|
233
|
-
*/
|
|
234
|
-
function okButton(options?: ButtonOptions): Readonly<IButton>;
|
|
235
|
-
/**
|
|
236
|
-
* Create a reject button.
|
|
237
|
-
*/
|
|
238
|
-
function cancelButton(options?: ButtonOptions): Readonly<IButton>;
|
|
239
|
-
/**
|
|
240
|
-
* Create a warn button.
|
|
241
|
-
*/
|
|
242
|
-
function warnButton(options?: ButtonOptions): Readonly<IButton>;
|
|
243
|
-
/**
|
|
244
|
-
* Create a button item.
|
|
245
|
-
*/
|
|
246
|
-
function createButton(value: Dialog.ButtonOptions): Readonly<IButton>;
|
|
247
|
-
/**
|
|
248
|
-
* A dialog renderer.
|
|
249
|
-
*/
|
|
250
|
-
interface IRenderer {
|
|
251
|
-
/**
|
|
252
|
-
* Create the header of the dialog.
|
|
253
|
-
*
|
|
254
|
-
* @param title - The title of the dialog.
|
|
255
|
-
*
|
|
256
|
-
* @returns A widget for the dialog header.
|
|
257
|
-
*/
|
|
258
|
-
createHeader(title: HeaderType): Widget;
|
|
259
|
-
/**
|
|
260
|
-
* Create the body of the dialog.
|
|
261
|
-
*
|
|
262
|
-
* @param value - The input value for the body.
|
|
263
|
-
*
|
|
264
|
-
* @returns A widget for the body.
|
|
265
|
-
*/
|
|
266
|
-
createBody(body: BodyType<any>): Widget;
|
|
267
|
-
/**
|
|
268
|
-
* Create the footer of the dialog.
|
|
269
|
-
*
|
|
270
|
-
* @param buttons - The button nodes to add to the footer.
|
|
271
|
-
*
|
|
272
|
-
* @returns A widget for the footer.
|
|
273
|
-
*/
|
|
274
|
-
createFooter(buttons: ReadonlyArray<HTMLElement>): Widget;
|
|
275
|
-
/**
|
|
276
|
-
* Create a button node for the dialog.
|
|
277
|
-
*
|
|
278
|
-
* @param button - The button data.
|
|
279
|
-
*
|
|
280
|
-
* @returns A node for the button.
|
|
281
|
-
*/
|
|
282
|
-
createButtonNode(button: IButton): HTMLElement;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* The default implementation of a dialog renderer.
|
|
286
|
-
*/
|
|
287
|
-
class Renderer {
|
|
288
|
-
/**
|
|
289
|
-
* Create the header of the dialog.
|
|
290
|
-
*
|
|
291
|
-
* @param title - The title of the dialog.
|
|
292
|
-
*
|
|
293
|
-
* @returns A widget for the dialog header.
|
|
294
|
-
*/
|
|
295
|
-
createHeader(title: HeaderType): Widget;
|
|
296
|
-
/**
|
|
297
|
-
* Create the body of the dialog.
|
|
298
|
-
*
|
|
299
|
-
* @param value - The input value for the body.
|
|
300
|
-
*
|
|
301
|
-
* @returns A widget for the body.
|
|
302
|
-
*/
|
|
303
|
-
createBody(value: BodyType<any>): Widget;
|
|
304
|
-
/**
|
|
305
|
-
* Create the footer of the dialog.
|
|
306
|
-
*
|
|
307
|
-
* @param buttonNodes - The buttons nodes to add to the footer.
|
|
308
|
-
*
|
|
309
|
-
* @returns A widget for the footer.
|
|
310
|
-
*/
|
|
311
|
-
createFooter(buttons: ReadonlyArray<HTMLElement>): Widget;
|
|
312
|
-
/**
|
|
313
|
-
* Create a button node for the dialog.
|
|
314
|
-
*
|
|
315
|
-
* @param button - The button data.
|
|
316
|
-
*
|
|
317
|
-
* @returns A node for the button.
|
|
318
|
-
*/
|
|
319
|
-
createButtonNode(button: IButton): HTMLElement;
|
|
320
|
-
/**
|
|
321
|
-
* Create the class name for the button.
|
|
322
|
-
*
|
|
323
|
-
* @param data - The data to use for the class name.
|
|
324
|
-
*
|
|
325
|
-
* @returns The full class name for the button.
|
|
326
|
-
*/
|
|
327
|
-
createItemClass(data: IButton): string;
|
|
328
|
-
/**
|
|
329
|
-
* Render an icon element for a dialog item.
|
|
330
|
-
*
|
|
331
|
-
* @param data - The data to use for rendering the icon.
|
|
332
|
-
*
|
|
333
|
-
* @returns An HTML element representing the icon.
|
|
334
|
-
*/
|
|
335
|
-
renderIcon(data: IButton): HTMLElement;
|
|
336
|
-
/**
|
|
337
|
-
* Create the class name for the button icon.
|
|
338
|
-
*
|
|
339
|
-
* @param data - The data to use for the class name.
|
|
340
|
-
*
|
|
341
|
-
* @returns The full class name for the item icon.
|
|
342
|
-
*/
|
|
343
|
-
createIconClass(data: IButton): string;
|
|
344
|
-
/**
|
|
345
|
-
* Render the label element for a button.
|
|
346
|
-
*
|
|
347
|
-
* @param data - The data to use for rendering the label.
|
|
348
|
-
*
|
|
349
|
-
* @returns An HTML element representing the item label.
|
|
350
|
-
*/
|
|
351
|
-
renderLabel(data: IButton): HTMLElement;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* The default renderer instance.
|
|
355
|
-
*/
|
|
356
|
-
const defaultRenderer: Renderer;
|
|
357
|
-
}
|
|
1
|
+
import { Message } from '@phosphor/messaging';
|
|
2
|
+
import { Widget } from '@phosphor/widgets';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Create and show a dialog.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The dialog setup options.
|
|
8
|
+
*
|
|
9
|
+
* @returns A promise that resolves with whether the dialog was accepted.
|
|
10
|
+
*/
|
|
11
|
+
export declare function showDialog<T>(options?: Partial<Dialog.IOptions<T>>): Promise<Dialog.IResult<T>>;
|
|
12
|
+
/**
|
|
13
|
+
* Show an error message dialog.
|
|
14
|
+
*
|
|
15
|
+
* @param title - The title of the dialog box.
|
|
16
|
+
*
|
|
17
|
+
* @param error - the error to show in the dialog body (either a string
|
|
18
|
+
* or an object with a string `message` property).
|
|
19
|
+
*/
|
|
20
|
+
export declare function showErrorMessage(title: string, error: any): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* A modal dialog widget.
|
|
23
|
+
*/
|
|
24
|
+
export declare class Dialog<T> extends Widget {
|
|
25
|
+
/**
|
|
26
|
+
* Create a dialog panel instance.
|
|
27
|
+
*
|
|
28
|
+
* @param options - The dialog setup options.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options?: Partial<Dialog.IOptions<T>>);
|
|
31
|
+
/**
|
|
32
|
+
* Dispose of the resources used by the dialog.
|
|
33
|
+
*/
|
|
34
|
+
dispose(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Launch the dialog as a modal window.
|
|
37
|
+
*
|
|
38
|
+
* @returns a promise that resolves with the result of the dialog.
|
|
39
|
+
*/
|
|
40
|
+
launch(): Promise<Dialog.IResult<T>>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the current dialog.
|
|
43
|
+
*
|
|
44
|
+
* @param index - An optional index to the button to resolve.
|
|
45
|
+
*
|
|
46
|
+
* #### Notes
|
|
47
|
+
* Will default to the defaultIndex.
|
|
48
|
+
* Will resolve the current `show()` with the button value.
|
|
49
|
+
* Will be a no-op if the dialog is not shown.
|
|
50
|
+
*/
|
|
51
|
+
resolve(index?: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* Reject the current dialog with a default reject value.
|
|
54
|
+
*
|
|
55
|
+
* #### Notes
|
|
56
|
+
* Will be a no-op if the dialog is not shown.
|
|
57
|
+
*/
|
|
58
|
+
reject(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Handle the DOM events for the directory listing.
|
|
61
|
+
*
|
|
62
|
+
* @param event - The DOM event sent to the widget.
|
|
63
|
+
*
|
|
64
|
+
* #### Notes
|
|
65
|
+
* This method implements the DOM `EventListener` interface and is
|
|
66
|
+
* called in response to events on the panel's DOM node. It should
|
|
67
|
+
* not be called directly by user code.
|
|
68
|
+
*/
|
|
69
|
+
handleEvent(event: Event): void;
|
|
70
|
+
/**
|
|
71
|
+
* A message handler invoked on an `'after-attach'` message.
|
|
72
|
+
*/
|
|
73
|
+
protected onAfterAttach(msg: Message): void;
|
|
74
|
+
/**
|
|
75
|
+
* A message handler invoked on an `'after-detach'` message.
|
|
76
|
+
*/
|
|
77
|
+
protected onAfterDetach(msg: Message): void;
|
|
78
|
+
/**
|
|
79
|
+
* A message handler invoked on a `'close-request'` message.
|
|
80
|
+
*/
|
|
81
|
+
protected onCloseRequest(msg: Message): void;
|
|
82
|
+
/**
|
|
83
|
+
* Handle the `'click'` event for a dialog button.
|
|
84
|
+
*
|
|
85
|
+
* @param event - The DOM event sent to the widget
|
|
86
|
+
*/
|
|
87
|
+
protected _evtClick(event: MouseEvent): void;
|
|
88
|
+
/**
|
|
89
|
+
* Handle the `'keydown'` event for the widget.
|
|
90
|
+
*
|
|
91
|
+
* @param event - The DOM event sent to the widget
|
|
92
|
+
*/
|
|
93
|
+
protected _evtKeydown(event: KeyboardEvent): void;
|
|
94
|
+
/**
|
|
95
|
+
* Handle the `'focus'` event for the widget.
|
|
96
|
+
*
|
|
97
|
+
* @param event - The DOM event sent to the widget
|
|
98
|
+
*/
|
|
99
|
+
protected _evtFocus(event: FocusEvent): void;
|
|
100
|
+
/**
|
|
101
|
+
* Resolve a button item.
|
|
102
|
+
*/
|
|
103
|
+
private _resolve;
|
|
104
|
+
private _buttonNodes;
|
|
105
|
+
private _buttons;
|
|
106
|
+
private _original;
|
|
107
|
+
private _first;
|
|
108
|
+
private _primary;
|
|
109
|
+
private _promise;
|
|
110
|
+
private _defaultButton;
|
|
111
|
+
private _host;
|
|
112
|
+
private _body;
|
|
113
|
+
private _focusNodeSelector;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The namespace for Dialog class statics.
|
|
117
|
+
*/
|
|
118
|
+
export declare namespace Dialog {
|
|
119
|
+
/**
|
|
120
|
+
* The options used to create a dialog.
|
|
121
|
+
*/
|
|
122
|
+
interface IOptions<T> {
|
|
123
|
+
/**
|
|
124
|
+
* The top level text for the dialog. Defaults to an empty string.
|
|
125
|
+
*/
|
|
126
|
+
title: HeaderType;
|
|
127
|
+
/**
|
|
128
|
+
* The main body element for the dialog or a message to display.
|
|
129
|
+
* Defaults to an empty string.
|
|
130
|
+
*
|
|
131
|
+
* #### Notes
|
|
132
|
+
* If a widget is given as the body, it will be disposed after the
|
|
133
|
+
* dialog is resolved. If the widget has a `getValue()` method,
|
|
134
|
+
* the method will be called prior to disposal and the value
|
|
135
|
+
* will be provided as part of the dialog result.
|
|
136
|
+
* A string argument will be used as raw `textContent`.
|
|
137
|
+
* All `input` and `select` nodes will be wrapped and styled.
|
|
138
|
+
*/
|
|
139
|
+
body: BodyType<T>;
|
|
140
|
+
/**
|
|
141
|
+
* The host element for the dialog. Defaults to `document.body`.
|
|
142
|
+
*/
|
|
143
|
+
host: HTMLElement;
|
|
144
|
+
/**
|
|
145
|
+
* The to buttons to display. Defaults to cancel and accept buttons.
|
|
146
|
+
*/
|
|
147
|
+
buttons: ReadonlyArray<IButton>;
|
|
148
|
+
/**
|
|
149
|
+
* The index of the default button. Defaults to the last button.
|
|
150
|
+
*/
|
|
151
|
+
defaultButton: number;
|
|
152
|
+
/**
|
|
153
|
+
* A selector for the primary element that should take focus in the dialog.
|
|
154
|
+
* Defaults to an empty string, causing the [[defaultButton]] to take
|
|
155
|
+
* focus.
|
|
156
|
+
*/
|
|
157
|
+
focusNodeSelector: string;
|
|
158
|
+
/**
|
|
159
|
+
* An optional renderer for dialog items. Defaults to a shared
|
|
160
|
+
* default renderer.
|
|
161
|
+
*/
|
|
162
|
+
renderer: IRenderer;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The options used to make a button item.
|
|
166
|
+
*/
|
|
167
|
+
interface IButton {
|
|
168
|
+
/**
|
|
169
|
+
* The label for the button.
|
|
170
|
+
*/
|
|
171
|
+
label: string;
|
|
172
|
+
/**
|
|
173
|
+
* The icon class for the button.
|
|
174
|
+
*/
|
|
175
|
+
iconClass: string;
|
|
176
|
+
/**
|
|
177
|
+
* The icon label for the button.
|
|
178
|
+
*/
|
|
179
|
+
iconLabel: string;
|
|
180
|
+
/**
|
|
181
|
+
* The caption for the button.
|
|
182
|
+
*/
|
|
183
|
+
caption: string;
|
|
184
|
+
/**
|
|
185
|
+
* The extra class name for the button.
|
|
186
|
+
*/
|
|
187
|
+
className: string;
|
|
188
|
+
/**
|
|
189
|
+
* The dialog action to perform when the button is clicked.
|
|
190
|
+
*/
|
|
191
|
+
accept: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* The button display type.
|
|
194
|
+
*/
|
|
195
|
+
displayType: 'default' | 'warn';
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The options used to create a button.
|
|
199
|
+
*/
|
|
200
|
+
type ButtonOptions = Partial<IButton>;
|
|
201
|
+
/**
|
|
202
|
+
* The header input types.
|
|
203
|
+
*/
|
|
204
|
+
type HeaderType = React.ReactElement<any> | string;
|
|
205
|
+
/**
|
|
206
|
+
* The result of a dialog.
|
|
207
|
+
*/
|
|
208
|
+
interface IResult<T> {
|
|
209
|
+
/**
|
|
210
|
+
* The button that was pressed.
|
|
211
|
+
*/
|
|
212
|
+
button: IButton;
|
|
213
|
+
/**
|
|
214
|
+
* The value retrieved from `.getValue()` if given on the widget.
|
|
215
|
+
*/
|
|
216
|
+
value: T | null;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A widget used as a dialog body.
|
|
220
|
+
*/
|
|
221
|
+
interface IBodyWidget<T = string> extends Widget {
|
|
222
|
+
/**
|
|
223
|
+
* Get the serialized value of the widget.
|
|
224
|
+
*/
|
|
225
|
+
getValue?(): T;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The body input types.
|
|
229
|
+
*/
|
|
230
|
+
type BodyType<T> = IBodyWidget<T> | React.ReactElement<any> | string;
|
|
231
|
+
/**
|
|
232
|
+
* Create an accept button.
|
|
233
|
+
*/
|
|
234
|
+
function okButton(options?: ButtonOptions): Readonly<IButton>;
|
|
235
|
+
/**
|
|
236
|
+
* Create a reject button.
|
|
237
|
+
*/
|
|
238
|
+
function cancelButton(options?: ButtonOptions): Readonly<IButton>;
|
|
239
|
+
/**
|
|
240
|
+
* Create a warn button.
|
|
241
|
+
*/
|
|
242
|
+
function warnButton(options?: ButtonOptions): Readonly<IButton>;
|
|
243
|
+
/**
|
|
244
|
+
* Create a button item.
|
|
245
|
+
*/
|
|
246
|
+
function createButton(value: Dialog.ButtonOptions): Readonly<IButton>;
|
|
247
|
+
/**
|
|
248
|
+
* A dialog renderer.
|
|
249
|
+
*/
|
|
250
|
+
interface IRenderer {
|
|
251
|
+
/**
|
|
252
|
+
* Create the header of the dialog.
|
|
253
|
+
*
|
|
254
|
+
* @param title - The title of the dialog.
|
|
255
|
+
*
|
|
256
|
+
* @returns A widget for the dialog header.
|
|
257
|
+
*/
|
|
258
|
+
createHeader(title: HeaderType): Widget;
|
|
259
|
+
/**
|
|
260
|
+
* Create the body of the dialog.
|
|
261
|
+
*
|
|
262
|
+
* @param value - The input value for the body.
|
|
263
|
+
*
|
|
264
|
+
* @returns A widget for the body.
|
|
265
|
+
*/
|
|
266
|
+
createBody(body: BodyType<any>): Widget;
|
|
267
|
+
/**
|
|
268
|
+
* Create the footer of the dialog.
|
|
269
|
+
*
|
|
270
|
+
* @param buttons - The button nodes to add to the footer.
|
|
271
|
+
*
|
|
272
|
+
* @returns A widget for the footer.
|
|
273
|
+
*/
|
|
274
|
+
createFooter(buttons: ReadonlyArray<HTMLElement>): Widget;
|
|
275
|
+
/**
|
|
276
|
+
* Create a button node for the dialog.
|
|
277
|
+
*
|
|
278
|
+
* @param button - The button data.
|
|
279
|
+
*
|
|
280
|
+
* @returns A node for the button.
|
|
281
|
+
*/
|
|
282
|
+
createButtonNode(button: IButton): HTMLElement;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The default implementation of a dialog renderer.
|
|
286
|
+
*/
|
|
287
|
+
class Renderer {
|
|
288
|
+
/**
|
|
289
|
+
* Create the header of the dialog.
|
|
290
|
+
*
|
|
291
|
+
* @param title - The title of the dialog.
|
|
292
|
+
*
|
|
293
|
+
* @returns A widget for the dialog header.
|
|
294
|
+
*/
|
|
295
|
+
createHeader(title: HeaderType): Widget;
|
|
296
|
+
/**
|
|
297
|
+
* Create the body of the dialog.
|
|
298
|
+
*
|
|
299
|
+
* @param value - The input value for the body.
|
|
300
|
+
*
|
|
301
|
+
* @returns A widget for the body.
|
|
302
|
+
*/
|
|
303
|
+
createBody(value: BodyType<any>): Widget;
|
|
304
|
+
/**
|
|
305
|
+
* Create the footer of the dialog.
|
|
306
|
+
*
|
|
307
|
+
* @param buttonNodes - The buttons nodes to add to the footer.
|
|
308
|
+
*
|
|
309
|
+
* @returns A widget for the footer.
|
|
310
|
+
*/
|
|
311
|
+
createFooter(buttons: ReadonlyArray<HTMLElement>): Widget;
|
|
312
|
+
/**
|
|
313
|
+
* Create a button node for the dialog.
|
|
314
|
+
*
|
|
315
|
+
* @param button - The button data.
|
|
316
|
+
*
|
|
317
|
+
* @returns A node for the button.
|
|
318
|
+
*/
|
|
319
|
+
createButtonNode(button: IButton): HTMLElement;
|
|
320
|
+
/**
|
|
321
|
+
* Create the class name for the button.
|
|
322
|
+
*
|
|
323
|
+
* @param data - The data to use for the class name.
|
|
324
|
+
*
|
|
325
|
+
* @returns The full class name for the button.
|
|
326
|
+
*/
|
|
327
|
+
createItemClass(data: IButton): string;
|
|
328
|
+
/**
|
|
329
|
+
* Render an icon element for a dialog item.
|
|
330
|
+
*
|
|
331
|
+
* @param data - The data to use for rendering the icon.
|
|
332
|
+
*
|
|
333
|
+
* @returns An HTML element representing the icon.
|
|
334
|
+
*/
|
|
335
|
+
renderIcon(data: IButton): HTMLElement;
|
|
336
|
+
/**
|
|
337
|
+
* Create the class name for the button icon.
|
|
338
|
+
*
|
|
339
|
+
* @param data - The data to use for the class name.
|
|
340
|
+
*
|
|
341
|
+
* @returns The full class name for the item icon.
|
|
342
|
+
*/
|
|
343
|
+
createIconClass(data: IButton): string;
|
|
344
|
+
/**
|
|
345
|
+
* Render the label element for a button.
|
|
346
|
+
*
|
|
347
|
+
* @param data - The data to use for rendering the label.
|
|
348
|
+
*
|
|
349
|
+
* @returns An HTML element representing the item label.
|
|
350
|
+
*/
|
|
351
|
+
renderLabel(data: IButton): HTMLElement;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The default renderer instance.
|
|
355
|
+
*/
|
|
356
|
+
const defaultRenderer: Renderer;
|
|
357
|
+
}
|