UNPKG

2.9 kBTypeScriptView Raw
1import { CommandRegistry } from '@lumino/commands';
2import { Widget } from '@lumino/widgets';
3import { IToolbarWidgetRegistry, ToolbarRegistry } from '../tokens';
4import { ISignal, Signal } from '@lumino/signaling';
5/**
6 * Concrete implementation of IToolbarWidgetRegistry interface
7 */
8export declare class ToolbarWidgetRegistry implements IToolbarWidgetRegistry {
9 constructor(options: ToolbarRegistry.IOptions);
10 /**
11 * Default toolbar item factory
12 */
13 get defaultFactory(): (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
14 set defaultFactory(factory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget);
15 /**
16 * A signal emitted when a factory widget has been added.
17 */
18 get factoryAdded(): ISignal<this, string>;
19 /**
20 * Create a toolbar item widget
21 *
22 * @param widgetFactory The widget factory name that creates the toolbar
23 * @param widget The newly widget containing the toolbar
24 * @param toolbarItem The toolbar item definition
25 * @returns The widget to be inserted in the toolbar.
26 */
27 createWidget(widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget): Widget;
28 /**
29 * Add a new toolbar item factory
30 *
31 * @param widgetFactory The widget factory name that creates the toolbar
32 * @param toolbarItemName The unique toolbar item
33 * @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
34 * @returns The previously defined factory
35 */
36 addFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
37 /**
38 * Register a new toolbar item factory
39 *
40 * @param widgetFactory The widget factory name that creates the toolbar
41 * @param toolbarItemName The unique toolbar item
42 * @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
43 * @returns The previously defined factory
44 *
45 * @deprecated since v4 use `addFactory` instead
46 */
47 registerFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
48 protected _defaultFactory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
49 protected _widgets: Map<string, Map<string, (main: Widget) => Widget>>;
50 protected _factoryAdded: Signal<this, string>;
51}
52/**
53 * Create the default toolbar item widget factory
54 *
55 * @param commands Application commands registry
56 * @returns Default factory
57 */
58export declare function createDefaultFactory(commands: CommandRegistry): (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;