1 |
|
2 | import { ITranslator } from '@jupyterlab/translation';
|
3 | import { LabIcon } from '@jupyterlab/ui-components';
|
4 | import { IIterator } from '@lumino/algorithm';
|
5 | import { CommandRegistry } from '@lumino/commands';
|
6 | import { ReadonlyJSONObject } from '@lumino/coreutils';
|
7 | import { Message } from '@lumino/messaging';
|
8 | import { Layout, Widget } from '@lumino/widgets';
|
9 | import { ISessionContext } from '../sessioncontext';
|
10 | import { ReactWidget } from '../vdom';
|
11 |
|
12 |
|
13 |
|
14 | export declare class Toolbar<T extends Widget = Widget> extends Widget {
|
15 | |
16 |
|
17 |
|
18 | constructor(options?: Toolbar.IOptions);
|
19 | /**
|
20 | * Get an iterator over the ordered toolbar item names.
|
21 | *
|
22 | * @returns An iterator over the toolbar item names.
|
23 | */
|
24 | names(): IIterator<string>;
|
25 | /**
|
26 | * Add an item to the end of the toolbar.
|
27 | *
|
28 | * @param name - The name of the widget to add to the toolbar.
|
29 | *
|
30 | * @param widget - The widget to add to the toolbar.
|
31 | *
|
32 | * @param index - The optional name of the item to insert after.
|
33 | *
|
34 | * @returns Whether the item was added to toolbar. Returns false if
|
35 | * an item of the same name is already in the toolbar.
|
36 | *
|
37 | * #### Notes
|
38 | * The item can be removed from the toolbar by setting its parent to `null`.
|
39 | */
|
40 | addItem(name: string, widget: T): boolean;
|
41 | /**
|
42 | * Insert an item into the toolbar at the specified index.
|
43 | *
|
44 | * @param index - The index at which to insert the item.
|
45 | *
|
46 | * @param name - The name of the item.
|
47 | *
|
48 | * @param widget - The widget to add.
|
49 | *
|
50 | * @returns Whether the item was added to the toolbar. Returns false if
|
51 | * an item of the same name is already in the toolbar.
|
52 | *
|
53 | * #### Notes
|
54 | * The index will be clamped to the bounds of the items.
|
55 | * The item can be removed from the toolbar by setting its parent to `null`.
|
56 | */
|
57 | insertItem(index: number, name: string, widget: T): boolean;
|
58 | /**
|
59 | * Insert an item into the toolbar at the after a target item.
|
60 | *
|
61 | * @param at - The target item to insert after.
|
62 | *
|
63 | * @param name - The name of the item.
|
64 | *
|
65 | * @param widget - The widget to add.
|
66 | *
|
67 | * @returns Whether the item was added to the toolbar. Returns false if
|
68 | * an item of the same name is already in the toolbar.
|
69 | *
|
70 | * #### Notes
|
71 | * The index will be clamped to the bounds of the items.
|
72 | * The item can be removed from the toolbar by setting its parent to `null`.
|
73 | */
|
74 | insertAfter(at: string, name: string, widget: T): boolean;
|
75 | /**
|
76 | * Insert an item into the toolbar at the before a target item.
|
77 | *
|
78 | * @param at - The target item to insert before.
|
79 | *
|
80 | * @param name - The name of the item.
|
81 | *
|
82 | * @param widget - The widget to add.
|
83 | *
|
84 | * @returns Whether the item was added to the toolbar. Returns false if
|
85 | * an item of the same name is already in the toolbar.
|
86 | *
|
87 | * #### Notes
|
88 | * The index will be clamped to the bounds of the items.
|
89 | * The item can be removed from the toolbar by setting its parent to `null`.
|
90 | */
|
91 | insertBefore(at: string, name: string, widget: T): boolean;
|
92 | private _insertRelative;
|
93 | /**
|
94 | * Handle the DOM events for the widget.
|
95 | *
|
96 | * @param event - The DOM event sent to the widget.
|
97 | *
|
98 | * #### Notes
|
99 | * This method implements the DOM `EventListener` interface and is
|
100 | * called in response to events on the dock panel's node. It should
|
101 | * not be called directly by user code.
|
102 | */
|
103 | handleEvent(event: Event): void;
|
104 | /**
|
105 | * Handle a DOM click event.
|
106 | */
|
107 | protected handleClick(event: Event): void;
|
108 | /**
|
109 | * Handle `after-attach` messages for the widget.
|
110 | */
|
111 | protected onAfterAttach(msg: Message): void;
|
112 | /**
|
113 | * Handle `before-detach` messages for the widget.
|
114 | */
|
115 | protected onBeforeDetach(msg: Message): void;
|
116 | }
|
117 | /**
|
118 | * A class which provides a toolbar widget.
|
119 | */
|
120 | export declare class ReactiveToolbar extends Toolbar<Widget> {
|
121 | |
122 |
|
123 |
|
124 | constructor();
|
125 | /**
|
126 | * Dispose of the widget and its descendant widgets.
|
127 | */
|
128 | dispose(): void;
|
129 | /**
|
130 | * Insert an item into the toolbar at the after a target item.
|
131 | *
|
132 | * @param at - The target item to insert after.
|
133 | *
|
134 | * @param name - The name of the item.
|
135 | *
|
136 | * @param widget - The widget to add.
|
137 | *
|
138 | * @returns Whether the item was added to the toolbar. Returns false if
|
139 | * an item of the same name is already in the toolbar or if the target
|
140 | * is the toolbar pop-up opener.
|
141 | *
|
142 | * #### Notes
|
143 | * The index will be clamped to the bounds of the items.
|
144 | * The item can be removed from the toolbar by setting its parent to `null`.
|
145 | */
|
146 | insertAfter(at: string, name: string, widget: Widget): boolean;
|
147 | /**
|
148 | * Insert an item into the toolbar at the specified index.
|
149 | *
|
150 | * @param index - The index at which to insert the item.
|
151 | *
|
152 | * @param name - The name of the item.
|
153 | *
|
154 | * @param widget - The widget to add.
|
155 | *
|
156 | * @returns Whether the item was added to the toolbar. Returns false if
|
157 | * an item of the same name is already in the toolbar.
|
158 | *
|
159 | * #### Notes
|
160 | * The index will be clamped to the bounds of the items.
|
161 | * The item can be removed from the toolbar by setting its parent to `null`.
|
162 | */
|
163 | insertItem(index: number, name: string, widget: Widget): boolean;
|
164 | /**
|
165 | * A message handler invoked on a `'before-hide'` message.
|
166 | *
|
167 | * It will hide the pop-up panel
|
168 | */
|
169 | onBeforeHide(msg: Message): void;
|
170 | protected onResize(msg: Widget.ResizeMessage): void;
|
171 | private _onResize;
|
172 | private _saveWidgetWidth;
|
173 | private _getWidgetWidth;
|
174 | protected readonly popupOpener: ToolbarPopupOpener;
|
175 | private readonly _widgetWidths;
|
176 | private readonly _resizer;
|
177 | }
|
178 | /**
|
179 | * The namespace for Toolbar class statics.
|
180 | */
|
181 | export declare namespace Toolbar {
|
182 | |
183 |
|
184 |
|
185 | interface IOptions {
|
186 | |
187 |
|
188 |
|
189 | layout?: Layout;
|
190 | }
|
191 | |
192 |
|
193 |
|
194 | interface IWidgetToolbar extends Widget {
|
195 | |
196 |
|
197 |
|
198 | toolbar?: Toolbar;
|
199 | }
|
200 | |
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | function createInterruptButton(sessionContext: ISessionContext, translator?: ITranslator): Widget;
|
207 | |
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | function createRestartButton(sessionContext: ISessionContext, dialogs?: ISessionContext.IDialogs, translator?: ITranslator): Widget;
|
214 | |
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 | function createSpacerItem(): Widget;
|
222 | |
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 | function createKernelNameItem(sessionContext: ISessionContext, dialogs?: ISessionContext.IDialogs, translator?: ITranslator): Widget;
|
230 | |
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | function createKernelStatusItem(sessionContext: ISessionContext, translator?: ITranslator): Widget;
|
242 | }
|
243 |
|
244 |
|
245 |
|
246 | export declare namespace ToolbarButtonComponent {
|
247 | |
248 |
|
249 |
|
250 | interface IProps {
|
251 | className?: string;
|
252 | |
253 |
|
254 |
|
255 | dataset?: DOMStringMap;
|
256 | label?: string;
|
257 | icon?: LabIcon.IMaybeResolvable;
|
258 | iconClass?: string;
|
259 | iconLabel?: string;
|
260 | tooltip?: string;
|
261 | onClick?: () => void;
|
262 | enabled?: boolean;
|
263 | pressed?: boolean;
|
264 | pressedIcon?: LabIcon.IMaybeResolvable;
|
265 | pressedTooltip?: string;
|
266 | disabledTooltip?: string;
|
267 | |
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | actualOnClick?: boolean;
|
274 | |
275 |
|
276 |
|
277 | translator?: ITranslator;
|
278 | }
|
279 | }
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 | export declare function ToolbarButtonComponent(props: ToolbarButtonComponent.IProps): JSX.Element;
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | export declare function addToolbarButtonClass(w: Widget): Widget;
|
291 |
|
292 |
|
293 |
|
294 | export declare class ToolbarButton extends ReactWidget {
|
295 | private props;
|
296 | |
297 |
|
298 |
|
299 |
|
300 | constructor(props?: ToolbarButtonComponent.IProps);
|
301 | /**
|
302 | * Sets the pressed state for the button
|
303 | * @param value true if button is pressed, false otherwise
|
304 | */
|
305 | set pressed(value: boolean);
|
306 | /**
|
307 | * Returns true if button is pressed, false otherwise
|
308 | */
|
309 | get pressed(): boolean;
|
310 | /**
|
311 | * Sets the enabled state for the button
|
312 | * @param value true to enable the button, false otherwise
|
313 | */
|
314 | set enabled(value: boolean);
|
315 | /**
|
316 | * Returns true if button is enabled, false otherwise
|
317 | */
|
318 | get enabled(): boolean;
|
319 | /**
|
320 | * Sets the click handler for the button
|
321 | * @param value click handler
|
322 | */
|
323 | set onClick(value: () => void);
|
324 | /**
|
325 | * Returns the click handler for the button
|
326 | */
|
327 | get onClick(): () => void;
|
328 | render(): JSX.Element;
|
329 | private _pressed;
|
330 | private _enabled;
|
331 | private _onClick;
|
332 | }
|
333 | /**
|
334 | * Namespace for CommandToolbarButtonComponent.
|
335 | */
|
336 | export declare namespace CommandToolbarButtonComponent {
|
337 | |
338 |
|
339 |
|
340 | interface IProps {
|
341 | |
342 |
|
343 |
|
344 | commands: CommandRegistry;
|
345 | |
346 |
|
347 |
|
348 | id: string;
|
349 | |
350 |
|
351 |
|
352 | args?: ReadonlyJSONObject;
|
353 | |
354 |
|
355 |
|
356 | icon?: LabIcon;
|
357 | |
358 |
|
359 |
|
360 | label?: string;
|
361 | }
|
362 | }
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 | export declare function CommandToolbarButtonComponent(props: CommandToolbarButtonComponent.IProps): JSX.Element;
|
370 | export declare function addCommandToolbarButtonClass(w: Widget): Widget;
|
371 |
|
372 |
|
373 |
|
374 | export declare class CommandToolbarButton extends ReactWidget {
|
375 | private props;
|
376 | |
377 |
|
378 |
|
379 |
|
380 | constructor(props: CommandToolbarButtonComponent.IProps);
|
381 | render(): JSX.Element;
|
382 | }
|
383 | /**
|
384 | * A class which provides a toolbar popup
|
385 | * used to store widgets that don't fit
|
386 | * in the toolbar when it is resized
|
387 | */
|
388 | declare class ToolbarPopup extends Widget {
|
389 | width: number;
|
390 | |
391 |
|
392 |
|
393 | constructor();
|
394 | /**
|
395 | * Updates the width of the popup, this
|
396 | * should match with the toolbar width
|
397 | *
|
398 | * @param width - The width to resize to
|
399 | * @protected
|
400 | */
|
401 | updateWidth(width: number): void;
|
402 | /**
|
403 | * Aligns the popup to left bottom of widget
|
404 | *
|
405 | * @param widget the widget to align to
|
406 | * @private
|
407 | */
|
408 | alignTo(widget: Widget): void;
|
409 | /**
|
410 | * Inserts the widget at specified index
|
411 | * @param index the index
|
412 | * @param widget widget to add
|
413 | */
|
414 | insertWidget(index: number, widget: Widget): void;
|
415 | /**
|
416 | * Total number of widgets in the popup
|
417 | */
|
418 | widgetCount(): number;
|
419 | /**
|
420 | * Returns the widget at index
|
421 | * @param index the index
|
422 | */
|
423 | widgetAt(index: number): Widget;
|
424 | }
|
425 | /**
|
426 | * A class that provides a ToolbarPopupOpener,
|
427 | * which is a button added to toolbar when
|
428 | * the toolbar items overflow toolbar width
|
429 | */
|
430 | declare class ToolbarPopupOpener extends ToolbarButton {
|
431 | |
432 |
|
433 |
|
434 | constructor();
|
435 | /**
|
436 | * Add widget to the popup, prepends widgets
|
437 | * @param widget the widget to add
|
438 | */
|
439 | addWidget(widget: Widget): void;
|
440 | /**
|
441 | * Dispose of the widget and its descendant widgets.
|
442 | *
|
443 | * #### Notes
|
444 | * It is unsafe to use the widget after it has been disposed.
|
445 | *
|
446 | * All calls made to this method after the first are a no-op.
|
447 | */
|
448 | dispose(): void;
|
449 | /**
|
450 | * Hides the opener and the popup
|
451 | */
|
452 | hide(): void;
|
453 | /**
|
454 | * Hides the popup
|
455 | */
|
456 | hidePopup(): void;
|
457 | /**
|
458 | * Updates width and position of the popup
|
459 | * to align with the toolbar
|
460 | */
|
461 | updatePopup(): void;
|
462 | /**
|
463 | * Returns widget at index in the popup
|
464 | * @param index
|
465 | */
|
466 | widgetAt(index: number): Widget;
|
467 | /**
|
468 | * Returns total number of widgets in the popup
|
469 | *
|
470 | * @returns Number of widgets
|
471 | */
|
472 | widgetCount(): number;
|
473 | protected handleClick(): void;
|
474 | protected popup: ToolbarPopup;
|
475 | }
|
476 | export {};
|