@jupyterlab/apputils 4.0.0-alpha.8 → 4.0.0-beta.0

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.
Files changed (81) hide show
  1. package/lib/clipboard.d.ts +1 -1
  2. package/lib/dialog.d.ts +66 -4
  3. package/lib/dialog.js +126 -29
  4. package/lib/dialog.js.map +1 -1
  5. package/lib/domutils.js.map +1 -1
  6. package/lib/index.d.ts +1 -0
  7. package/lib/index.js +1 -0
  8. package/lib/index.js.map +1 -1
  9. package/lib/inputdialog.d.ts +35 -3
  10. package/lib/inputdialog.js +122 -12
  11. package/lib/inputdialog.js.map +1 -1
  12. package/lib/kernelstatuses.js +26 -25
  13. package/lib/kernelstatuses.js.map +1 -1
  14. package/lib/mainareawidget.d.ts +9 -0
  15. package/lib/mainareawidget.js +29 -4
  16. package/lib/mainareawidget.js.map +1 -1
  17. package/lib/menufactory.js +14 -15
  18. package/lib/menufactory.js.map +1 -1
  19. package/lib/notification.d.ts +336 -0
  20. package/lib/notification.js +310 -0
  21. package/lib/notification.js.map +1 -0
  22. package/lib/runningSessions.js +2 -2
  23. package/lib/runningSessions.js.map +1 -1
  24. package/lib/sanitizer.d.ts +20 -7
  25. package/lib/sanitizer.js +34 -7
  26. package/lib/sanitizer.js.map +1 -1
  27. package/lib/semanticCommand.js +11 -2
  28. package/lib/semanticCommand.js.map +1 -1
  29. package/lib/sessioncontext.d.ts +53 -6
  30. package/lib/sessioncontext.js +100 -68
  31. package/lib/sessioncontext.js.map +1 -1
  32. package/lib/testutils.d.ts +5 -0
  33. package/lib/testutils.js +46 -0
  34. package/lib/testutils.js.map +1 -0
  35. package/lib/thememanager.js +20 -5
  36. package/lib/thememanager.js.map +1 -1
  37. package/lib/tokens.d.ts +21 -42
  38. package/lib/tokens.js.map +1 -1
  39. package/lib/toolbar/factory.d.ts +2 -1
  40. package/lib/toolbar/factory.js +132 -105
  41. package/lib/toolbar/factory.js.map +1 -1
  42. package/lib/toolbar/index.js +4 -0
  43. package/lib/toolbar/index.js.map +1 -1
  44. package/lib/toolbar/registry.d.ts +11 -0
  45. package/lib/toolbar/registry.js +20 -3
  46. package/lib/toolbar/registry.js.map +1 -1
  47. package/lib/toolbar/widget.d.ts +3 -0
  48. package/lib/toolbar/widget.js +8 -5
  49. package/lib/toolbar/widget.js.map +1 -1
  50. package/lib/widgettracker.d.ts +13 -1
  51. package/lib/widgettracker.js +29 -2
  52. package/lib/widgettracker.js.map +1 -1
  53. package/package.json +31 -30
  54. package/src/clipboard.ts +107 -0
  55. package/src/commandlinker.ts +209 -0
  56. package/src/commandpalette.ts +175 -0
  57. package/src/dialog.tsx +1133 -0
  58. package/src/domutils.ts +53 -0
  59. package/src/index.ts +78 -0
  60. package/src/inputdialog.ts +551 -0
  61. package/src/kernelstatuses.tsx +279 -0
  62. package/src/mainareawidget.ts +362 -0
  63. package/src/menufactory.ts +201 -0
  64. package/src/notification.ts +559 -0
  65. package/src/printing.ts +180 -0
  66. package/src/runningSessions.tsx +233 -0
  67. package/src/sanitizer.ts +986 -0
  68. package/src/semanticCommand.ts +77 -0
  69. package/src/sessioncontext.tsx +1774 -0
  70. package/src/testutils.ts +49 -0
  71. package/src/thememanager.ts +530 -0
  72. package/src/tokens.ts +351 -0
  73. package/src/toolbar/factory.ts +422 -0
  74. package/src/toolbar/index.ts +8 -0
  75. package/src/toolbar/registry.ts +158 -0
  76. package/src/toolbar/widget.tsx +242 -0
  77. package/src/widgettracker.ts +391 -0
  78. package/src/windowresolver.ts +218 -0
  79. package/style/dialog.css +16 -1
  80. package/style/inputdialog.css +5 -0
  81. package/style/materialcolors.css +5 -0
@@ -0,0 +1,279 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { Session } from '@jupyterlab/services';
5
+ import { TextItem } from '@jupyterlab/statusbar';
6
+ import {
7
+ ITranslator,
8
+ nullTranslator,
9
+ TranslationBundle
10
+ } from '@jupyterlab/translation';
11
+ import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
12
+ import { JSONArray, JSONExt } from '@lumino/coreutils';
13
+ import React from 'react';
14
+ import { ISessionContext } from './sessioncontext';
15
+
16
+ /**
17
+ * Helper function to translate kernel statuses mapping by using
18
+ * input translator.
19
+ *
20
+ * @param translator - Language translator.
21
+ * @return The translated kernel status mapping.
22
+ */
23
+ export function translateKernelStatuses(
24
+ translator?: ITranslator
25
+ ): Record<ISessionContext.KernelDisplayStatus, string> {
26
+ translator = translator || nullTranslator;
27
+ const trans = translator.load('jupyterlab');
28
+ const translated: Record<ISessionContext.KernelDisplayStatus, string> = {
29
+ unknown: trans.__('Unknown'),
30
+ starting: trans.__('Starting'),
31
+ idle: trans.__('Idle'),
32
+ busy: trans.__('Busy'),
33
+ terminating: trans.__('Terminating'),
34
+ restarting: trans.__('Restarting'),
35
+ autorestarting: trans.__('Autorestarting'),
36
+ dead: trans.__('Dead'),
37
+ connected: trans.__('Connected'),
38
+ connecting: trans.__('Connecting'),
39
+ disconnected: trans.__('Disconnected'),
40
+ initializing: trans.__('Initializing'),
41
+ '': ''
42
+ };
43
+ return translated;
44
+ }
45
+
46
+ /**
47
+ * A pure functional component for rendering kernel status.
48
+ */
49
+ function KernelStatusComponent(
50
+ props: KernelStatusComponent.IProps
51
+ ): React.ReactElement<KernelStatusComponent.IProps> {
52
+ const translator = props.translator || nullTranslator;
53
+ const trans = translator.load('jupyterlab');
54
+ let statusText = '';
55
+ if (props.status) {
56
+ statusText = ` | ${props.status}`;
57
+ }
58
+ return (
59
+ <TextItem
60
+ onClick={props.handleClick}
61
+ source={`${props.kernelName}${statusText}`}
62
+ title={trans.__('Change kernel for %1', props.activityName)}
63
+ />
64
+ );
65
+ }
66
+
67
+ /**
68
+ * A namespace for KernelStatusComponent statics.
69
+ */
70
+ namespace KernelStatusComponent {
71
+ /**
72
+ * Props for the kernel status component.
73
+ */
74
+ export interface IProps {
75
+ /**
76
+ * A click handler for the kernel status component. By default
77
+ * we have it bring up the kernel change dialog.
78
+ */
79
+ handleClick: () => void;
80
+
81
+ /**
82
+ * The name the kernel.
83
+ */
84
+ kernelName: string;
85
+
86
+ /**
87
+ * The name of the activity using the kernel.
88
+ */
89
+ activityName: string;
90
+
91
+ /**
92
+ * The status of the kernel.
93
+ */
94
+ status?: string;
95
+
96
+ /**
97
+ * The application language translator.
98
+ */
99
+ translator?: ITranslator;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * A VDomRenderer widget for displaying the status of a kernel.
105
+ */
106
+ export class KernelStatus extends VDomRenderer<KernelStatus.Model> {
107
+ /**
108
+ * Construct the kernel status widget.
109
+ */
110
+ constructor(opts: KernelStatus.IOptions, translator?: ITranslator) {
111
+ super(new KernelStatus.Model(translator));
112
+ this.translator = translator || nullTranslator;
113
+ this._handleClick = opts.onClick;
114
+ this.addClass('jp-mod-highlighted');
115
+ }
116
+
117
+ /**
118
+ * Render the kernel status item.
119
+ */
120
+ render(): JSX.Element | null {
121
+ if (this.model === null) {
122
+ return null;
123
+ } else {
124
+ return (
125
+ <KernelStatusComponent
126
+ status={this.model.status}
127
+ kernelName={this.model.kernelName}
128
+ activityName={this.model.activityName}
129
+ handleClick={this._handleClick}
130
+ translator={this.translator}
131
+ />
132
+ );
133
+ }
134
+ }
135
+
136
+ translator: ITranslator;
137
+ private _handleClick: () => void;
138
+ }
139
+
140
+ /**
141
+ * A namespace for KernelStatus statics.
142
+ */
143
+ export namespace KernelStatus {
144
+ /**
145
+ * A VDomModel for the kernel status indicator.
146
+ */
147
+ export class Model extends VDomModel {
148
+ constructor(translator?: ITranslator) {
149
+ super();
150
+ translator = translator ?? nullTranslator;
151
+ this._trans = translator.load('jupyterlab');
152
+ this._statusNames = translateKernelStatuses(translator);
153
+ }
154
+
155
+ /**
156
+ * The name of the kernel.
157
+ */
158
+ get kernelName(): string {
159
+ return this._kernelName;
160
+ }
161
+
162
+ /**
163
+ * The current status of the kernel.
164
+ */
165
+ get status(): string | undefined {
166
+ return this._kernelStatus
167
+ ? this._statusNames[this._kernelStatus]
168
+ : undefined;
169
+ }
170
+
171
+ /**
172
+ * A display name for the activity.
173
+ */
174
+ get activityName(): string {
175
+ return this._activityName;
176
+ }
177
+ set activityName(val: string) {
178
+ const oldVal = this._activityName;
179
+ if (oldVal === val) {
180
+ return;
181
+ }
182
+ this._activityName = val;
183
+ this.stateChanged.emit();
184
+ }
185
+
186
+ /**
187
+ * The current client session associated with the kernel status indicator.
188
+ */
189
+ get sessionContext(): ISessionContext | null {
190
+ return this._sessionContext;
191
+ }
192
+ set sessionContext(sessionContext: ISessionContext | null) {
193
+ this._sessionContext?.statusChanged.disconnect(
194
+ this._onKernelStatusChanged,
195
+ this
196
+ );
197
+ this._sessionContext?.connectionStatusChanged.disconnect(
198
+ this._onKernelStatusChanged,
199
+ this
200
+ );
201
+ this._sessionContext?.kernelChanged.disconnect(
202
+ this._onKernelChanged,
203
+ this
204
+ );
205
+
206
+ const oldState = this._getAllState();
207
+ this._sessionContext = sessionContext;
208
+ this._kernelStatus = sessionContext?.kernelDisplayStatus;
209
+ this._kernelName =
210
+ sessionContext?.kernelDisplayName ?? this._trans.__('No Kernel');
211
+ sessionContext?.statusChanged.connect(this._onKernelStatusChanged, this);
212
+ sessionContext?.connectionStatusChanged.connect(
213
+ this._onKernelStatusChanged,
214
+ this
215
+ );
216
+ sessionContext?.kernelChanged.connect(this._onKernelChanged, this);
217
+ this._triggerChange(oldState, this._getAllState());
218
+ }
219
+
220
+ /**
221
+ * React to changes to the kernel status.
222
+ */
223
+ private _onKernelStatusChanged() {
224
+ this._kernelStatus = this._sessionContext?.kernelDisplayStatus;
225
+ this.stateChanged.emit(void 0);
226
+ }
227
+
228
+ /**
229
+ * React to changes in the kernel.
230
+ */
231
+ private _onKernelChanged(
232
+ _sessionContext: ISessionContext,
233
+ change: Session.ISessionConnection.IKernelChangedArgs
234
+ ) {
235
+ const oldState = this._getAllState();
236
+
237
+ // sync setting of status and display name
238
+ this._kernelStatus = this._sessionContext?.kernelDisplayStatus;
239
+ this._kernelName = _sessionContext.kernelDisplayName;
240
+ this._triggerChange(oldState, this._getAllState());
241
+ }
242
+
243
+ private _getAllState(): Private.State {
244
+ return [this._kernelName, this._kernelStatus, this._activityName];
245
+ }
246
+
247
+ private _triggerChange(oldState: Private.State, newState: Private.State) {
248
+ if (JSONExt.deepEqual(oldState as JSONArray, newState as JSONArray)) {
249
+ this.stateChanged.emit(void 0);
250
+ }
251
+ }
252
+
253
+ protected translation: ITranslator;
254
+ private _trans: TranslationBundle;
255
+ private _activityName: string = '';
256
+ private _kernelName: string = '';
257
+ private _kernelStatus: ISessionContext.KernelDisplayStatus | undefined = '';
258
+ private _sessionContext: ISessionContext | null = null;
259
+ private readonly _statusNames: Record<
260
+ ISessionContext.KernelDisplayStatus,
261
+ string
262
+ >;
263
+ }
264
+
265
+ /**
266
+ * Options for creating a KernelStatus object.
267
+ */
268
+ export interface IOptions {
269
+ /**
270
+ * A click handler for the item. By default
271
+ * we launch a kernel selection dialog.
272
+ */
273
+ onClick: () => void;
274
+ }
275
+ }
276
+
277
+ namespace Private {
278
+ export type State = [string, string | undefined, string];
279
+ }
@@ -0,0 +1,362 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
5
+ import { ReactiveToolbar, Spinner, Toolbar } from '@jupyterlab/ui-components';
6
+ import { Message, MessageLoop } from '@lumino/messaging';
7
+ import { BoxLayout, BoxPanel, Widget } from '@lumino/widgets';
8
+ import { DOMUtils } from './domutils';
9
+ import { Printing } from './printing';
10
+
11
+ /**
12
+ * A flag to indicate that event handlers are caught in the capture phase.
13
+ */
14
+ const USE_CAPTURE = true;
15
+
16
+ /**
17
+ * A widget meant to be contained in the JupyterLab main area.
18
+ *
19
+ * #### Notes
20
+ * Mirrors all of the `title` attributes of the content.
21
+ * This widget is `closable` by default.
22
+ * This widget is automatically disposed when closed.
23
+ * This widget ensures its own focus when activated.
24
+ */
25
+ export class MainAreaWidget<T extends Widget = Widget>
26
+ extends Widget
27
+ implements Printing.IPrintable
28
+ {
29
+ /**
30
+ * Construct a new main area widget.
31
+ *
32
+ * @param options - The options for initializing the widget.
33
+ */
34
+ constructor(options: MainAreaWidget.IOptions<T>) {
35
+ super(options);
36
+ this.addClass('jp-MainAreaWidget');
37
+ // Set contain=strict to avoid many forced layout rendering while adding cells.
38
+ // Don't forget to remove the CSS class when your remove the spinner to allow
39
+ // the content to be rendered.
40
+ // @see https://github.com/jupyterlab/jupyterlab/issues/9381
41
+ this.addClass('jp-MainAreaWidget-ContainStrict');
42
+ this.id = DOMUtils.createDomID();
43
+
44
+ const trans = (options.translator || nullTranslator).load('jupyterlab');
45
+ const content = (this._content = options.content);
46
+ content.node.setAttribute('role', 'region');
47
+ content.node.setAttribute('aria-label', trans.__('notebook content'));
48
+ const toolbar = (this._toolbar = options.toolbar || new ReactiveToolbar());
49
+ toolbar.node.setAttribute('role', 'navigation');
50
+ toolbar.node.setAttribute('aria-label', trans.__('notebook actions'));
51
+ const contentHeader = (this._contentHeader =
52
+ options.contentHeader ||
53
+ new BoxPanel({
54
+ direction: 'top-to-bottom',
55
+ spacing: 0
56
+ }));
57
+
58
+ const layout = (this.layout = new BoxLayout({ spacing: 0 }));
59
+ layout.direction = 'top-to-bottom';
60
+ BoxLayout.setStretch(toolbar, 0);
61
+ BoxLayout.setStretch(contentHeader, 0);
62
+ BoxLayout.setStretch(content, 1);
63
+ layout.addWidget(toolbar);
64
+ layout.addWidget(contentHeader);
65
+ layout.addWidget(content);
66
+
67
+ if (!content.id) {
68
+ content.id = DOMUtils.createDomID();
69
+ }
70
+ content.node.tabIndex = -1;
71
+
72
+ this._updateTitle();
73
+ content.title.changed.connect(this._updateTitle, this);
74
+ this.title.closable = true;
75
+ this.title.changed.connect(this._updateContentTitle, this);
76
+
77
+ if (options.reveal) {
78
+ this.node.appendChild(this._spinner.node);
79
+ this._revealed = options.reveal
80
+ .then(() => {
81
+ if (content.isDisposed) {
82
+ this.dispose();
83
+ return;
84
+ }
85
+ content.disposed.connect(() => this.dispose());
86
+ const active = document.activeElement === this._spinner.node;
87
+ this._disposeSpinner();
88
+ this._isRevealed = true;
89
+ if (active) {
90
+ this._focusContent();
91
+ }
92
+ })
93
+ .catch(e => {
94
+ // Show a revealed promise error.
95
+ const error = new Widget();
96
+ error.addClass('jp-MainAreaWidget-error');
97
+ // Show the error to the user.
98
+ const pre = document.createElement('pre');
99
+ pre.textContent = String(e);
100
+ error.node.appendChild(pre);
101
+ BoxLayout.setStretch(error, 1);
102
+ this._disposeSpinner();
103
+ content.dispose();
104
+ this._content = null!;
105
+ toolbar.dispose();
106
+ this._toolbar = null!;
107
+ layout.addWidget(error);
108
+ this._isRevealed = true;
109
+ throw error;
110
+ });
111
+ } else {
112
+ // Handle no reveal promise.
113
+ this._spinner.dispose();
114
+ this.removeClass('jp-MainAreaWidget-ContainStrict');
115
+ content.disposed.connect(() => this.dispose());
116
+ this._isRevealed = true;
117
+ this._revealed = Promise.resolve(undefined);
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Print method. Deferred to content.
123
+ */
124
+ [Printing.symbol](): Printing.OptionalAsyncThunk {
125
+ if (!this._content) {
126
+ return null;
127
+ }
128
+ return Printing.getPrintFunction(this._content);
129
+ }
130
+
131
+ /**
132
+ * The content hosted by the widget.
133
+ */
134
+ get content(): T {
135
+ return this._content;
136
+ }
137
+
138
+ /**
139
+ * The toolbar hosted by the widget.
140
+ */
141
+ get toolbar(): Toolbar {
142
+ return this._toolbar;
143
+ }
144
+
145
+ /**
146
+ * A panel for widgets that sit between the toolbar and the content.
147
+ * Imagine a formatting toolbar, notification headers, etc.
148
+ */
149
+ get contentHeader(): BoxPanel {
150
+ return this._contentHeader;
151
+ }
152
+
153
+ /**
154
+ * Whether the content widget or an error is revealed.
155
+ */
156
+ get isRevealed(): boolean {
157
+ return this._isRevealed;
158
+ }
159
+
160
+ /**
161
+ * A promise that resolves when the widget is revealed.
162
+ */
163
+ get revealed(): Promise<void> {
164
+ return this._revealed;
165
+ }
166
+
167
+ /**
168
+ * Handle `'activate-request'` messages.
169
+ */
170
+ protected onActivateRequest(msg: Message): void {
171
+ if (this._isRevealed) {
172
+ this._focusContent();
173
+ } else {
174
+ this._spinner.node.focus();
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Handle `after-attach` messages for the widget.
180
+ */
181
+ protected onAfterAttach(msg: Message): void {
182
+ super.onAfterAttach(msg);
183
+ // Focus content in capture phase to ensure relevant commands operate on the
184
+ // current main area widget.
185
+ // Add the event listener directly instead of using `handleEvent` in order
186
+ // to save sub-classes from needing to reason about calling it as well.
187
+ this.node.addEventListener('mousedown', this._evtMouseDown, USE_CAPTURE);
188
+ }
189
+
190
+ /**
191
+ * Handle `before-detach` messages for the widget.
192
+ */
193
+ protected onBeforeDetach(msg: Message): void {
194
+ this.node.removeEventListener('mousedown', this._evtMouseDown, USE_CAPTURE);
195
+ super.onBeforeDetach(msg);
196
+ }
197
+
198
+ /**
199
+ * Handle `'close-request'` messages.
200
+ */
201
+ protected onCloseRequest(msg: Message): void {
202
+ this.dispose();
203
+ }
204
+
205
+ /**
206
+ * Handle `'update-request'` messages by forwarding them to the content.
207
+ */
208
+ protected onUpdateRequest(msg: Message): void {
209
+ if (this._content) {
210
+ MessageLoop.sendMessage(this._content, msg);
211
+ }
212
+ }
213
+
214
+ private _disposeSpinner() {
215
+ this.node.removeChild(this._spinner.node);
216
+ this._spinner.dispose();
217
+ this.removeClass('jp-MainAreaWidget-ContainStrict');
218
+ }
219
+
220
+ /**
221
+ * Update the title based on the attributes of the child widget.
222
+ */
223
+ private _updateTitle(): void {
224
+ if (this._changeGuard || !this.content) {
225
+ return;
226
+ }
227
+ this._changeGuard = true;
228
+ const content = this.content;
229
+ this.title.label = content.title.label;
230
+ this.title.mnemonic = content.title.mnemonic;
231
+ this.title.icon = content.title.icon;
232
+ this.title.iconClass = content.title.iconClass;
233
+ this.title.iconLabel = content.title.iconLabel;
234
+ this.title.caption = content.title.caption;
235
+ this.title.className = content.title.className;
236
+ this.title.dataset = content.title.dataset;
237
+ this._changeGuard = false;
238
+ }
239
+
240
+ /**
241
+ * Update the content title based on attributes of the main widget.
242
+ */
243
+ private _updateContentTitle(): void {
244
+ if (this._changeGuard || !this.content) {
245
+ return;
246
+ }
247
+ this._changeGuard = true;
248
+ const content = this.content;
249
+ content.title.label = this.title.label;
250
+ content.title.mnemonic = this.title.mnemonic;
251
+ content.title.icon = this.title.icon;
252
+ content.title.iconClass = this.title.iconClass;
253
+ content.title.iconLabel = this.title.iconLabel;
254
+ content.title.caption = this.title.caption;
255
+ content.title.className = this.title.className;
256
+ content.title.dataset = this.title.dataset;
257
+ this._changeGuard = false;
258
+ }
259
+
260
+ /**
261
+ * Give focus to the content.
262
+ */
263
+ private _focusContent(): void {
264
+ if (!this.content) {
265
+ return;
266
+ }
267
+ // Focus the content node if we aren't already focused on it or a
268
+ // descendent.
269
+ if (!this.content.node.contains(document.activeElement)) {
270
+ this.content.node.focus();
271
+ }
272
+
273
+ // Activate the content asynchronously (which may change the focus).
274
+ this.content.activate();
275
+ }
276
+
277
+ /*
278
+ MainAreaWidget's layout:
279
+ - this.layout, a BoxLayout, from parent
280
+ - this._toolbar, a Toolbar
281
+ - this._contentHeader, a BoxPanel, empty by default
282
+ - this._content
283
+ */
284
+ private _content: T;
285
+ private _toolbar: Toolbar;
286
+ private _contentHeader: BoxPanel;
287
+
288
+ private _changeGuard = false;
289
+ private _spinner = new Spinner();
290
+
291
+ private _isRevealed = false;
292
+ private _revealed: Promise<void>;
293
+ private _evtMouseDown = () => {
294
+ if (!this.node.contains(document.activeElement)) {
295
+ this._focusContent();
296
+ }
297
+ };
298
+ }
299
+
300
+ /**
301
+ * The namespace for the `MainAreaWidget` class statics.
302
+ */
303
+ export namespace MainAreaWidget {
304
+ /**
305
+ * An options object for creating a main area widget.
306
+ */
307
+ export interface IOptions<T extends Widget = Widget> extends Widget.IOptions {
308
+ /**
309
+ * The child widget to wrap.
310
+ */
311
+ content: T;
312
+
313
+ /**
314
+ * The toolbar to use for the widget. Defaults to an empty toolbar.
315
+ */
316
+ toolbar?: Toolbar;
317
+
318
+ /**
319
+ * The layout to sit underneath the toolbar and above the content,
320
+ * and that extensions can populate. Defaults to an empty BoxPanel.
321
+ */
322
+ contentHeader?: BoxPanel;
323
+
324
+ /**
325
+ * An optional promise for when the content is ready to be revealed.
326
+ */
327
+ reveal?: Promise<any>;
328
+
329
+ /**
330
+ * The application language translator.
331
+ */
332
+ translator?: ITranslator;
333
+ }
334
+
335
+ /**
336
+ * An options object for main area widget subclasses providing their own
337
+ * default content.
338
+ *
339
+ * #### Notes
340
+ * This makes it easier to have a subclass that provides its own default
341
+ * content. This can go away once we upgrade to TypeScript 2.8 and have an
342
+ * easy way to make a single property optional, ala
343
+ * https://stackoverflow.com/a/46941824
344
+ */
345
+ export interface IOptionsOptionalContent<T extends Widget = Widget>
346
+ extends Widget.IOptions {
347
+ /**
348
+ * The child widget to wrap.
349
+ */
350
+ content?: T;
351
+
352
+ /**
353
+ * The toolbar to use for the widget. Defaults to an empty toolbar.
354
+ */
355
+ toolbar?: Toolbar;
356
+
357
+ /**
358
+ * An optional promise for when the content is ready to be revealed.
359
+ */
360
+ reveal?: Promise<any>;
361
+ }
362
+ }