UNPKG

11.8 kBTypeScriptView Raw
1import { DocumentRegistry } from '@jupyterlab/docregistry';
2import { ITranslator } from '@jupyterlab/translation';
3import { IIterator } from '@lumino/algorithm';
4import { Token } from '@lumino/coreutils';
5import { Message } from '@lumino/messaging';
6import { ISignal } from '@lumino/signaling';
7import { DockLayout, DockPanel, FocusTracker, TabBar, Widget } from '@lumino/widgets';
8import { JupyterFrontEnd } from './frontend';
9/**
10 * The JupyterLab application shell token.
11 */
12export declare const ILabShell: Token<ILabShell>;
13/**
14 * The JupyterLab application shell interface.
15 */
16export interface ILabShell extends LabShell {
17}
18/**
19 * The namespace for `ILabShell` type information.
20 */
21export declare namespace ILabShell {
22 /**
23 * The areas of the application shell where widgets can reside.
24 */
25 type Area = 'main' | 'header' | 'top' | 'menu' | 'left' | 'right' | 'bottom' | 'down';
26 /**
27 * The restorable description of an area within the main dock panel.
28 */
29 type AreaConfig = DockLayout.AreaConfig;
30 /**
31 * An options object for creating a lab shell object.
32 */
33 type IOptions = {
34 /**
35 * The application language translator.
36 */
37 translator?: ITranslator;
38 };
39 /**
40 * An arguments object for the changed signals.
41 */
42 type IChangedArgs = FocusTracker.IChangedArgs<Widget>;
43 interface IConfig {
44 /**
45 * The method for hiding widgets in the dock panel.
46 *
47 * The default is `scale`.
48 *
49 * Using `scale` will often increase performance as most browsers will not trigger style computation
50 * for the transform action.
51 */
52 hiddenMode: 'display' | 'scale';
53 }
54 /**
55 * The args for the current path change signal.
56 */
57 interface ICurrentPathChangedArgs {
58 /**
59 * The new value of the tree path, not including '/tree'.
60 */
61 oldValue: string;
62 /**
63 * The old value of the tree path, not including '/tree'.
64 */
65 newValue: string;
66 }
67 /**
68 * A description of the application's user interface layout.
69 */
70 interface ILayout {
71 /**
72 * Indicates whether fetched session restore data was actually retrieved
73 * from the state database or whether it is a fresh blank slate.
74 *
75 * #### Notes
76 * This attribute is only relevant when the layout data is retrieved via a
77 * `fetch` call. If it is set when being passed into `save`, it will be
78 * ignored.
79 */
80 readonly fresh?: boolean;
81 /**
82 * The main area of the user interface.
83 */
84 readonly mainArea: IMainArea | null;
85 /**
86 * The down area of the user interface.
87 */
88 readonly downArea: IDownArea | null;
89 /**
90 * The left area of the user interface.
91 */
92 readonly leftArea: ISideArea | null;
93 /**
94 * The right area of the user interface.
95 */
96 readonly rightArea: ISideArea | null;
97 /**
98 * The relatives sizes of the areas of the user interface.
99 */
100 readonly relativeSizes: number[] | null;
101 }
102 /**
103 * The restorable description of the main application area.
104 */
105 interface IMainArea {
106 /**
107 * The current widget that has application focus.
108 */
109 readonly currentWidget: Widget | null;
110 /**
111 * The contents of the main application dock panel.
112 */
113 readonly dock: DockLayout.ILayoutConfig | null;
114 }
115 interface IDownArea {
116 /**
117 * The current widget that has down area focus.
118 */
119 readonly currentWidget: Widget | null;
120 /**
121 * The collection of widgets held by the panel.
122 */
123 readonly widgets: Array<Widget> | null;
124 /**
125 * Vertical relative size of the down area
126 *
127 * The main area will take the rest of the height
128 */
129 readonly size: number | null;
130 }
131 /**
132 * The restorable description of a sidebar in the user interface.
133 */
134 interface ISideArea {
135 /**
136 * A flag denoting whether the sidebar has been collapsed.
137 */
138 readonly collapsed: boolean;
139 /**
140 * The current widget that has side area focus.
141 */
142 readonly currentWidget: Widget | null;
143 /**
144 * The collection of widgets held by the sidebar.
145 */
146 readonly widgets: Array<Widget> | null;
147 }
148}
149/**
150 * The application shell for JupyterLab.
151 */
152export declare class LabShell extends Widget implements JupyterFrontEnd.IShell {
153 /**
154 * Construct a new application shell.
155 */
156 constructor(options?: ILabShell.IOptions);
157 /**
158 * A signal emitted when main area's active focus changes.
159 */
160 get activeChanged(): ISignal<this, ILabShell.IChangedArgs>;
161 /**
162 * The active widget in the shell's main area.
163 */
164 get activeWidget(): Widget | null;
165 /**
166 * A signal emitted when main area's current focus changes.
167 */
168 get currentChanged(): ISignal<this, ILabShell.IChangedArgs>;
169 /**
170 * A signal emitted when the shell/dock panel change modes (single/multiple document).
171 */
172 get modeChanged(): ISignal<this, DockPanel.Mode>;
173 /**
174 * A signal emitted when the path of the current document changes.
175 *
176 * This also fires when the current document itself changes.
177 */
178 get currentPathChanged(): ISignal<this, ILabShell.ICurrentPathChangedArgs>;
179 /**
180 * The current widget in the shell's main area.
181 */
182 get currentWidget(): Widget | null;
183 /**
184 * A signal emitted when the main area's layout is modified.
185 */
186 get layoutModified(): ISignal<this, void>;
187 /**
188 * Whether the left area is collapsed.
189 */
190 get leftCollapsed(): boolean;
191 /**
192 * Whether the left area is collapsed.
193 */
194 get rightCollapsed(): boolean;
195 /**
196 * Whether JupyterLab is in presentation mode with the
197 * `jp-mod-presentationMode` CSS class.
198 */
199 get presentationMode(): boolean;
200 /**
201 * Enable/disable presentation mode (`jp-mod-presentationMode` CSS class) with
202 * a boolean.
203 */
204 set presentationMode(value: boolean);
205 /**
206 * The main dock area's user interface mode.
207 */
208 get mode(): DockPanel.Mode;
209 set mode(mode: DockPanel.Mode);
210 /**
211 * Promise that resolves when state is first restored, returning layout
212 * description.
213 */
214 get restored(): Promise<ILabShell.ILayout>;
215 /**
216 * Activate a widget in its area.
217 */
218 activateById(id: string): void;
219 activateNextTab(): void;
220 get addButtonEnabled(): boolean;
221 set addButtonEnabled(value: boolean);
222 get addRequested(): ISignal<DockPanel, TabBar<Widget>>;
223 activatePreviousTab(): void;
224 activateNextTabBar(): void;
225 activatePreviousTabBar(): void;
226 add(widget: Widget, area?: ILabShell.Area, options?: DocumentRegistry.IOpenOptions): void;
227 /**
228 * Collapse the left area.
229 */
230 collapseLeft(): void;
231 /**
232 * Collapse the right area.
233 */
234 collapseRight(): void;
235 /**
236 * Dispose the shell.
237 */
238 dispose(): void;
239 /**
240 * Expand the left area.
241 *
242 * #### Notes
243 * This will open the most recently used tab,
244 * or the first tab if there is no most recently used.
245 */
246 expandLeft(): void;
247 /**
248 * Expand the right area.
249 *
250 * #### Notes
251 * This will open the most recently used tab,
252 * or the first tab if there is no most recently used.
253 */
254 expandRight(): void;
255 /**
256 * Close all widgets in the main and down area.
257 */
258 closeAll(): void;
259 /**
260 * True if the given area is empty.
261 */
262 isEmpty(area: ILabShell.Area): boolean;
263 /**
264 * Restore the layout state for the application shell.
265 */
266 restoreLayout(mode: DockPanel.Mode, layout: ILabShell.ILayout): void;
267 /**
268 * Save the dehydrated state of the application shell.
269 */
270 saveLayout(): ILabShell.ILayout;
271 /**
272 * Update the shell configuration.
273 *
274 * @param config Shell configuration
275 */
276 updateConfig(config: Partial<ILabShell.IConfig>): void;
277 /**
278 * Returns the widgets for an application area.
279 */
280 widgets(area?: ILabShell.Area): IIterator<Widget>;
281 /**
282 * Handle `after-attach` messages for the application shell.
283 */
284 protected onAfterAttach(msg: Message): void;
285 /**
286 * Update the title panel title based on the title of the current widget.
287 */
288 private _updateTitlePanelTitle;
289 /**
290 * The path of the current widget changed, fire the _currentPathChanged signal.
291 */
292 private _updateCurrentPath;
293 /**
294 * Add a widget to the left content area.
295 *
296 * #### Notes
297 * Widgets must have a unique `id` property, which will be used as the DOM id.
298 */
299 private _addToLeftArea;
300 /**
301 * Add a widget to the main content area.
302 *
303 * #### Notes
304 * Widgets must have a unique `id` property, which will be used as the DOM id.
305 * All widgets added to the main area should be disposed after removal
306 * (disposal before removal will remove the widget automatically).
307 *
308 * In the options, `ref` defaults to `null`, `mode` defaults to `'tab-after'`,
309 * and `activate` defaults to `true`.
310 */
311 private _addToMainArea;
312 /**
313 * Add a widget to the right content area.
314 *
315 * #### Notes
316 * Widgets must have a unique `id` property, which will be used as the DOM id.
317 */
318 private _addToRightArea;
319 /**
320 * Add a widget to the top content area.
321 *
322 * #### Notes
323 * Widgets must have a unique `id` property, which will be used as the DOM id.
324 */
325 private _addToTopArea;
326 /**
327 * Add a widget to the title content area.
328 *
329 * #### Notes
330 * Widgets must have a unique `id` property, which will be used as the DOM id.
331 */
332 private _addToMenuArea;
333 /**
334 * Add a widget to the header content area.
335 *
336 * #### Notes
337 * Widgets must have a unique `id` property, which will be used as the DOM id.
338 */
339 private _addToHeaderArea;
340 /**
341 * Add a widget to the bottom content area.
342 *
343 * #### Notes
344 * Widgets must have a unique `id` property, which will be used as the DOM id.
345 */
346 private _addToBottomArea;
347 private _addToDownArea;
348 private _adjacentBar;
349 private _currentTabBar;
350 /**
351 * Handle a change to the dock area active widget.
352 */
353 private _onActiveChanged;
354 /**
355 * Handle a change to the dock area current widget.
356 */
357 private _onCurrentChanged;
358 /**
359 * Handle a change on the down panel widgets
360 */
361 private _onTabPanelChanged;
362 /**
363 * Handle a change to the layout.
364 */
365 private _onLayoutModified;
366 /**
367 * A message hook for child add/remove messages on the main area dock panel.
368 */
369 private _dockChildHook;
370 private _activeChanged;
371 private _cachedLayout;
372 private _currentChanged;
373 private _currentPath;
374 private _currentPathChanged;
375 private _modeChanged;
376 private _dockPanel;
377 private _downPanel;
378 private _isRestored;
379 private _layoutModified;
380 private _layoutDebouncer;
381 private _leftHandler;
382 private _restored;
383 private _rightHandler;
384 private _tracker;
385 private _headerPanel;
386 private _hsplitPanel;
387 private _vsplitPanel;
388 private _topHandler;
389 private _menuHandler;
390 private _skipLinkWidget;
391 private _titleHandler;
392 private _bottomPanel;
393 private _mainOptionsCache;
394 private _sideOptionsCache;
395}