UNPKG

3.46 kBTypeScriptView Raw
1import { IDisposable } from '@lumino/disposable';
2import { ISignal, Signal } from '@lumino/signaling';
3import { VirtualElement } from '@lumino/virtualdom';
4import { ContextMenu, Menu } from '@lumino/widgets';
5/**
6 * An object which implements a universal context menu.
7 * Tweaked to use inline svg icons
8 */
9export declare class ContextMenuSvg extends ContextMenu implements IDisposable {
10 /**
11 * Construct a new context menu.
12 *
13 * @param options - The options for initializing the menu.
14 */
15 constructor(options: ContextMenu.IOptions);
16 readonly menu: MenuSvg;
17 /**
18 * Test whether the context menu is disposed.
19 */
20 get isDisposed(): boolean;
21 /**
22 * A signal fired when the context menu is opened.
23 */
24 get opened(): ISignal<ContextMenu, void>;
25 /**
26 * Dispose of the resources held by the context menu.
27 */
28 dispose(): void;
29 /**
30 * Open the context menu in response to a `'contextmenu'` event.
31 *
32 * @param event - The `'contextmenu'` event of interest.
33 *
34 * @returns `true` if the menu was opened, or `false` if no items
35 * matched the event and the menu was not opened.
36 *
37 * #### Notes
38 * This method will populate the context menu with items which match
39 * the propagation path of the event, then open the menu at the mouse
40 * position indicated by the event.
41 */
42 open(event: MouseEvent): boolean;
43 protected _isDisposed: boolean;
44 protected _opened: Signal<ContextMenu, void>;
45}
46/**
47 * a widget which displays items as a canonical menu.
48 * Tweaked to use inline svg icons
49 */
50export declare class MenuSvg extends Menu {
51 /**
52 * construct a new menu. Overrides the default renderer
53 *
54 * @param options - The options for initializing the tab bar.
55 */
56 constructor(options: Menu.IOptions);
57 /**
58 * insert a menu item into the menu at the specified index. Replaces the
59 * default renderer for submenus
60 *
61 * @param index - The index at which to insert the item.
62 *
63 * @param options - The options for creating the menu item.
64 *
65 * @returns The menu item added to the menu.
66 *
67 * #### Notes
68 * The index will be clamped to the bounds of the items.
69 */
70 insertItem(index: number, options: Menu.IItemOptions): Menu.IItem;
71}
72export declare namespace MenuSvg {
73 function overrideDefaultRenderer(menu: Menu): void;
74 /**
75 * a modified implementation of the Menu Renderer
76 */
77 class Renderer extends Menu.Renderer {
78 /**
79 * Render the icon element for a menu item.
80 *
81 * @param data - The data to use for rendering the icon.
82 *
83 * @returns A virtual element representing the item icon.
84 */
85 renderIcon(data: Menu.IRenderData): VirtualElement;
86 /**
87 * Create the class name for the menu item icon.
88 *
89 * @param data - The data to use for the class name.
90 *
91 * @returns The full class name for the item icon.
92 */
93 createIconClass(data: Menu.IRenderData): string;
94 /**
95 * Render the submenu icon element for a menu item.
96 *
97 * @param data - The data to use for rendering the submenu icon.
98 *
99 * @returns A virtual element representing the submenu icon.
100 */
101 renderSubmenu(data: Menu.IRenderData): VirtualElement;
102 }
103 const defaultRenderer: Renderer;
104}