@jupyterlab/apputils
Version:
JupyterLab - Application Utilities
59 lines (58 loc) • 2.9 kB
TypeScript
import { CommandRegistry } from '@lumino/commands';
import { Widget } from '@lumino/widgets';
import { IToolbarWidgetRegistry, ToolbarRegistry } from '../tokens';
import { ISignal, Signal } from '@lumino/signaling';
/**
* Concrete implementation of IToolbarWidgetRegistry interface
*/
export declare class ToolbarWidgetRegistry implements IToolbarWidgetRegistry {
constructor(options: ToolbarRegistry.IOptions);
/**
* Default toolbar item factory
*/
get defaultFactory(): (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
set defaultFactory(factory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget);
/**
* A signal emitted when a factory widget has been added.
*/
get factoryAdded(): ISignal<this, string>;
/**
* Create a toolbar item widget
*
* @param widgetFactory The widget factory name that creates the toolbar
* @param widget The newly widget containing the toolbar
* @param toolbarItem The toolbar item definition
* @returns The widget to be inserted in the toolbar.
*/
createWidget(widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget): Widget;
/**
* Add a new toolbar item factory
*
* @param widgetFactory The widget factory name that creates the toolbar
* @param toolbarItemName The unique toolbar item
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
* @returns The previously defined factory
*/
addFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
/**
* Register a new toolbar item factory
*
* @param widgetFactory The widget factory name that creates the toolbar
* @param toolbarItemName The unique toolbar item
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
* @returns The previously defined factory
*
* @deprecated since v4 use `addFactory` instead
*/
registerFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
protected _defaultFactory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
protected _widgets: Map<string, Map<string, (main: Widget) => Widget>>;
protected _factoryAdded: Signal<this, string>;
}
/**
* Create the default toolbar item widget factory
*
* @param commands Application commands registry
* @returns Default factory
*/
export declare function createDefaultFactory(commands: CommandRegistry): (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;