UNPKG

2.09 kBTypeScriptView Raw
1import { CommandRegistry } from '@lumino/commands';
2import { Widget } from '@lumino/widgets';
3import { IToolbarWidgetRegistry, ToolbarRegistry } from '../tokens';
4/**
5 * Concrete implementation of IToolbarWidgetRegistry interface
6 */
7export declare class ToolbarWidgetRegistry implements IToolbarWidgetRegistry {
8 constructor(options: ToolbarRegistry.IOptions);
9 /**
10 * Default toolbar item factory
11 */
12 get defaultFactory(): (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
13 set defaultFactory(factory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget);
14 /**
15 * Create a toolbar item widget
16 *
17 * @param widgetFactory The widget factory name that creates the toolbar
18 * @param widget The newly widget containing the toolbar
19 * @param toolbarItem The toolbar item definition
20 * @returns The widget to be inserted in the toolbar.
21 */
22 createWidget(widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget): Widget;
23 /**
24 * Register a new toolbar item factory
25 *
26 * @param widgetFactory The widget factory name that creates the toolbar
27 * @param toolbarItemName The unique toolbar item
28 * @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
29 * @returns The previously defined factory
30 */
31 registerFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
32 protected _defaultFactory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
33 protected _widgets: Map<string, Map<string, (main: Widget) => Widget>>;
34}
35/**
36 * Create the default toolbar item widget factory
37 *
38 * @param commands Application commands registry
39 * @returns Default factory
40 */
41export declare function createDefaultFactory(commands: CommandRegistry): (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;