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