1 | import { Message } from '@lumino/messaging';
|
2 | import { ElementARIAAttrs, ElementDataset, h, VirtualElement } from '@lumino/virtualdom';
|
3 | import { Menu } from './menu';
|
4 | import { Title } from './title';
|
5 | import { Widget } from './widget';
|
6 |
|
7 |
|
8 |
|
9 | export declare class MenuBar extends Widget {
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 | constructor(options?: MenuBar.IOptions);
|
16 | /**
|
17 | * Dispose of the resources held by the widget.
|
18 | */
|
19 | dispose(): void;
|
20 | /**
|
21 | * The renderer used by the menu bar.
|
22 | */
|
23 | readonly renderer: MenuBar.IRenderer;
|
24 | /**
|
25 | * The child menu of the menu bar.
|
26 | *
|
27 | * #### Notes
|
28 | * This will be `null` if the menu bar does not have an open menu.
|
29 | */
|
30 | readonly childMenu: Menu | null;
|
31 | /**
|
32 | * Get the menu bar content node.
|
33 | *
|
34 | * #### Notes
|
35 | * This is the node which holds the menu title nodes.
|
36 | *
|
37 | * Modifying this node directly can lead to undefined behavior.
|
38 | */
|
39 | readonly contentNode: HTMLUListElement;
|
40 | /**
|
41 | * Get the currently active menu.
|
42 | */
|
43 | /**
|
44 | * Set the currently active menu.
|
45 | *
|
46 | * #### Notes
|
47 | * If the menu does not exist, the menu will be set to `null`.
|
48 | */
|
49 | activeMenu: Menu | null;
|
50 | /**
|
51 | * Get the index of the currently active menu.
|
52 | *
|
53 | * #### Notes
|
54 | * This will be `-1` if no menu is active.
|
55 | */
|
56 | /**
|
57 | * Set the index of the currently active menu.
|
58 | *
|
59 | * #### Notes
|
60 | * If the menu cannot be activated, the index will be set to `-1`.
|
61 | */
|
62 | activeIndex: number;
|
63 | /**
|
64 | * A read-only array of the menus in the menu bar.
|
65 | */
|
66 | readonly menus: ReadonlyArray<Menu>;
|
67 | /**
|
68 | * Open the active menu and activate its first menu item.
|
69 | *
|
70 | * #### Notes
|
71 | * If there is no active menu, this is a no-op.
|
72 | */
|
73 | openActiveMenu(): void;
|
74 | /**
|
75 | * Add a menu to the end of the menu bar.
|
76 | *
|
77 | * @param menu - The menu to add to the menu bar.
|
78 | *
|
79 | * #### Notes
|
80 | * If the menu is already added to the menu bar, it will be moved.
|
81 | */
|
82 | addMenu(menu: Menu): void;
|
83 | /**
|
84 | * Insert a menu into the menu bar at the specified index.
|
85 | *
|
86 | * @param index - The index at which to insert the menu.
|
87 | *
|
88 | * @param menu - The menu to insert into the menu bar.
|
89 | *
|
90 | * #### Notes
|
91 | * The index will be clamped to the bounds of the menus.
|
92 | *
|
93 | * If the menu is already added to the menu bar, it will be moved.
|
94 | */
|
95 | insertMenu(index: number, menu: Menu): void;
|
96 | /**
|
97 | * Remove a menu from the menu bar.
|
98 | *
|
99 | * @param menu - The menu to remove from the menu bar.
|
100 | *
|
101 | * #### Notes
|
102 | * This is a no-op if the menu is not in the menu bar.
|
103 | */
|
104 | removeMenu(menu: Menu): void;
|
105 | /**
|
106 | * Remove the menu at a given index from the menu bar.
|
107 | *
|
108 | * @param index - The index of the menu to remove.
|
109 | *
|
110 | * #### Notes
|
111 | * This is a no-op if the index is out of range.
|
112 | */
|
113 | removeMenuAt(index: number): void;
|
114 | /**
|
115 | * Remove all menus from the menu bar.
|
116 | */
|
117 | clearMenus(): void;
|
118 | /**
|
119 | * Handle the DOM events for the menu bar.
|
120 | *
|
121 | * @param event - The DOM event sent to the menu bar.
|
122 | *
|
123 | * #### Notes
|
124 | * This method implements the DOM `EventListener` interface and is
|
125 | * called in response to events on the menu bar's DOM nodes. It
|
126 | * should not be called directly by user code.
|
127 | */
|
128 | handleEvent(event: Event): void;
|
129 | /**
|
130 | * A message handler invoked on a `'before-attach'` message.
|
131 | */
|
132 | protected onBeforeAttach(msg: Message): void;
|
133 | /**
|
134 | * A message handler invoked on an `'after-detach'` message.
|
135 | */
|
136 | protected onAfterDetach(msg: Message): void;
|
137 | /**
|
138 | * A message handler invoked on an `'activate-request'` message.
|
139 | */
|
140 | protected onActivateRequest(msg: Message): void;
|
141 | /**
|
142 | * A message handler invoked on an `'update-request'` message.
|
143 | */
|
144 | protected onUpdateRequest(msg: Message): void;
|
145 | /**
|
146 | * Handle the `'keydown'` event for the menu bar.
|
147 | */
|
148 | private _evtKeyDown;
|
149 | /**
|
150 | * Handle the `'mousedown'` event for the menu bar.
|
151 | */
|
152 | private _evtMouseDown;
|
153 | /**
|
154 | * Handle the `'mousemove'` event for the menu bar.
|
155 | */
|
156 | private _evtMouseMove;
|
157 | /**
|
158 | * Handle the `'mouseleave'` event for the menu bar.
|
159 | */
|
160 | private _evtMouseLeave;
|
161 | /**
|
162 | * Open the child menu at the active index immediately.
|
163 | *
|
164 | * If a different child menu is already open, it will be closed,
|
165 | * even if there is no active menu.
|
166 | */
|
167 | private _openChildMenu;
|
168 | /**
|
169 | * Close the child menu immediately.
|
170 | *
|
171 | * This is a no-op if a child menu is not open.
|
172 | */
|
173 | private _closeChildMenu;
|
174 | /**
|
175 | * Handle the `aboutToClose` signal of a menu.
|
176 | */
|
177 | private _onMenuAboutToClose;
|
178 | /**
|
179 | * Handle the `menuRequested` signal of a child menu.
|
180 | */
|
181 | private _onMenuMenuRequested;
|
182 | /**
|
183 | * Handle the `changed` signal of a title object.
|
184 | */
|
185 | private _onTitleChanged;
|
186 | private _activeIndex;
|
187 | private _forceItemsPosition;
|
188 | private _menus;
|
189 | private _childMenu;
|
190 | }
|
191 | /**
|
192 | * The namespace for the `MenuBar` class statics.
|
193 | */
|
194 | export declare namespace MenuBar {
|
195 | |
196 |
|
197 |
|
198 | interface IOptions {
|
199 | |
200 |
|
201 |
|
202 |
|
203 |
|
204 | renderer?: IRenderer;
|
205 | |
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | forceItemsPosition?: Menu.IOpenOptions;
|
215 | }
|
216 | |
217 |
|
218 |
|
219 | interface IRenderData {
|
220 | |
221 |
|
222 |
|
223 | readonly title: Title<Widget>;
|
224 | |
225 |
|
226 |
|
227 | readonly active: boolean;
|
228 | readonly onfocus?: (event: FocusEvent) => void;
|
229 | }
|
230 | |
231 |
|
232 |
|
233 | interface IRenderer {
|
234 | |
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | renderItem(data: IRenderData): VirtualElement;
|
242 | }
|
243 | |
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 | class Renderer implements IRenderer {
|
250 | |
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | renderItem(data: IRenderData): VirtualElement;
|
258 | |
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | renderIcon(data: IRenderData): VirtualElement;
|
266 | |
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | renderLabel(data: IRenderData): VirtualElement;
|
274 | |
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 | createItemClass(data: IRenderData): string;
|
282 | |
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 | createItemDataset(data: IRenderData): ElementDataset;
|
290 | |
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 | createItemARIA(data: IRenderData): ElementARIAAttrs;
|
298 | |
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | createIconClass(data: IRenderData): string;
|
306 | |
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 | formatLabel(data: IRenderData): h.Child;
|
314 | }
|
315 | |
316 |
|
317 |
|
318 | const defaultRenderer: Renderer;
|
319 | }
|
320 |
|
\ | No newline at end of file |