UNPKG

4.39 kBTypeScriptView Raw
1import { ITranslator } from '@jupyterlab/translation';
2import { Message } from '@lumino/messaging';
3import { BoxPanel, Widget } from '@lumino/widgets';
4import { Printing } from './printing';
5import { Toolbar } from './toolbar';
6/**
7 * A widget meant to be contained in the JupyterLab main area.
8 *
9 * #### Notes
10 * Mirrors all of the `title` attributes of the content.
11 * This widget is `closable` by default.
12 * This widget is automatically disposed when closed.
13 * This widget ensures its own focus when activated.
14 */
15export declare class MainAreaWidget<T extends Widget = Widget> extends Widget implements Printing.IPrintable {
16 /**
17 * Construct a new main area widget.
18 *
19 * @param options - The options for initializing the widget.
20 */
21 constructor(options: MainAreaWidget.IOptions<T>);
22 /**
23 * Print method. Deferred to content.
24 */
25 [Printing.symbol](): Printing.OptionalAsyncThunk;
26 /**
27 * The content hosted by the widget.
28 */
29 get content(): T;
30 /**
31 * The toolbar hosted by the widget.
32 */
33 get toolbar(): Toolbar;
34 /**
35 * A panel for widgets that sit between the toolbar and the content.
36 * Imagine a formatting toolbar, notification headers, etc.
37 */
38 get contentHeader(): BoxPanel;
39 /**
40 * Whether the content widget or an error is revealed.
41 */
42 get isRevealed(): boolean;
43 /**
44 * A promise that resolves when the widget is revealed.
45 */
46 get revealed(): Promise<void>;
47 /**
48 * Handle `'activate-request'` messages.
49 */
50 protected onActivateRequest(msg: Message): void;
51 /**
52 * Handle `after-attach` messages for the widget.
53 */
54 protected onAfterAttach(msg: Message): void;
55 /**
56 * Handle `before-detach` messages for the widget.
57 */
58 protected onBeforeDetach(msg: Message): void;
59 /**
60 * Handle `'close-request'` messages.
61 */
62 protected onCloseRequest(msg: Message): void;
63 /**
64 * Handle `'update-request'` messages by forwarding them to the content.
65 */
66 protected onUpdateRequest(msg: Message): void;
67 private _disposeSpinner;
68 /**
69 * Update the title based on the attributes of the child widget.
70 */
71 private _updateTitle;
72 /**
73 * Update the content title based on attributes of the main widget.
74 */
75 private _updateContentTitle;
76 /**
77 * Give focus to the content.
78 */
79 private _focusContent;
80 private _content;
81 private _toolbar;
82 private _contentHeader;
83 private _changeGuard;
84 private _spinner;
85 private _isRevealed;
86 private _revealed;
87 private _evtMouseDown;
88}
89/**
90 * The namespace for the `MainAreaWidget` class statics.
91 */
92export declare namespace MainAreaWidget {
93 /**
94 * An options object for creating a main area widget.
95 */
96 interface IOptions<T extends Widget = Widget> extends Widget.IOptions {
97 /**
98 * The child widget to wrap.
99 */
100 content: T;
101 /**
102 * The toolbar to use for the widget. Defaults to an empty toolbar.
103 */
104 toolbar?: Toolbar;
105 /**
106 * The layout to sit underneath the toolbar and above the content,
107 * and that extensions can populate. Defaults to an empty BoxPanel.
108 */
109 contentHeader?: BoxPanel;
110 /**
111 * An optional promise for when the content is ready to be revealed.
112 */
113 reveal?: Promise<any>;
114 /**
115 * The application language translator.
116 */
117 translator?: ITranslator;
118 }
119 /**
120 * An options object for main area widget subclasses providing their own
121 * default content.
122 *
123 * #### Notes
124 * This makes it easier to have a subclass that provides its own default
125 * content. This can go away once we upgrade to TypeScript 2.8 and have an
126 * easy way to make a single property optional, ala
127 * https://stackoverflow.com/a/46941824
128 */
129 interface IOptionsOptionalContent<T extends Widget = Widget> extends Widget.IOptions {
130 /**
131 * The child widget to wrap.
132 */
133 content?: T;
134 /**
135 * The toolbar to use for the widget. Defaults to an empty toolbar.
136 */
137 toolbar?: Toolbar;
138 /**
139 * An optional promise for when the content is ready to be revealed.
140 */
141 reveal?: Promise<any>;
142 }
143}