|
5 | 5 |
|
6 | 6 | import 'vs/css!./dropdown'; |
7 | 7 | import { Gesture, EventType as GestureEventType } from 'vs/base/browser/touch'; |
8 | | -import { ActionRunner, IAction, IActionRunner, IActionViewItemProvider } from 'vs/base/common/actions'; |
| 8 | +import { ActionRunner, IAction } from 'vs/base/common/actions'; |
9 | 9 | import { IDisposable } from 'vs/base/common/lifecycle'; |
10 | 10 | import { IContextViewProvider, IAnchor, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview'; |
11 | 11 | import { IMenuOptions } from 'vs/base/browser/ui/menu/menu'; |
12 | | -import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes'; |
13 | | -import { EventHelper, EventType, removeClass, addClass, append, $, addDisposableListener, addClasses, DOMEvent } from 'vs/base/browser/dom'; |
| 12 | +import { KeyCode } from 'vs/base/common/keyCodes'; |
| 13 | +import { EventHelper, EventType, removeClass, addClass, append, $, addDisposableListener, DOMEvent } from 'vs/base/browser/dom'; |
14 | 14 | import { IContextMenuDelegate } from 'vs/base/browser/contextmenu'; |
15 | 15 | import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; |
16 | 16 | import { Emitter } from 'vs/base/common/event'; |
17 | | -import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems'; |
18 | 17 |
|
19 | 18 | export interface ILabelRenderer { |
20 | 19 | (container: HTMLElement): IDisposable | null; |
@@ -283,104 +282,3 @@ export class DropdownMenu extends BaseDropdown { |
283 | 282 | removeClass(this.element, 'active'); |
284 | 283 | } |
285 | 284 | } |
286 | | - |
287 | | -export class DropdownMenuActionViewItem extends BaseActionViewItem { |
288 | | - private menuActionsOrProvider: ReadonlyArray<IAction> | IActionProvider; |
289 | | - private dropdownMenu: DropdownMenu | undefined; |
290 | | - private contextMenuProvider: IContextMenuProvider; |
291 | | - private actionViewItemProvider?: IActionViewItemProvider; |
292 | | - private keybindings?: (action: IAction) => ResolvedKeybinding | undefined; |
293 | | - private clazz: string | undefined; |
294 | | - private anchorAlignmentProvider: (() => AnchorAlignment) | undefined; |
295 | | - private menuAsChild?: boolean; |
296 | | - |
297 | | - private _onDidChangeVisibility = this._register(new Emitter<boolean>()); |
298 | | - readonly onDidChangeVisibility = this._onDidChangeVisibility.event; |
299 | | - |
300 | | - constructor(action: IAction, menuActions: ReadonlyArray<IAction>, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment, menuAsChild?: boolean); |
301 | | - constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment, menuAsChild?: boolean); |
302 | | - constructor(action: IAction, menuActionsOrProvider: ReadonlyArray<IAction> | IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment, menuAsChild?: boolean) { |
303 | | - super(null, action); |
304 | | - |
305 | | - this.menuActionsOrProvider = menuActionsOrProvider; |
306 | | - this.contextMenuProvider = contextMenuProvider; |
307 | | - this.actionViewItemProvider = actionViewItemProvider; |
308 | | - this.actionRunner = actionRunner; |
309 | | - this.keybindings = keybindings; |
310 | | - this.clazz = clazz; |
311 | | - this.anchorAlignmentProvider = anchorAlignmentProvider; |
312 | | - this.menuAsChild = menuAsChild; |
313 | | - } |
314 | | - |
315 | | - render(container: HTMLElement): void { |
316 | | - const labelRenderer: ILabelRenderer = (el: HTMLElement): IDisposable | null => { |
317 | | - this.element = append(el, $('a.action-label.codicon')); // todo@aeschli: remove codicon, should come through `this.clazz` |
318 | | - if (this.clazz) { |
319 | | - addClasses(this.element, this.clazz); |
320 | | - } |
321 | | - |
322 | | - this.element.tabIndex = 0; |
323 | | - this.element.setAttribute('role', 'button'); |
324 | | - this.element.setAttribute('aria-haspopup', 'true'); |
325 | | - this.element.setAttribute('aria-expanded', 'false'); |
326 | | - this.element.title = this._action.label || ''; |
327 | | - |
328 | | - return null; |
329 | | - }; |
330 | | - |
331 | | - const options: IDropdownMenuOptions = { |
332 | | - contextMenuProvider: this.contextMenuProvider, |
333 | | - labelRenderer: labelRenderer, |
334 | | - menuAsChild: this.menuAsChild |
335 | | - }; |
336 | | - |
337 | | - // Render the DropdownMenu around a simple action to toggle it |
338 | | - if (Array.isArray(this.menuActionsOrProvider)) { |
339 | | - options.actions = this.menuActionsOrProvider; |
340 | | - } else { |
341 | | - options.actionProvider = this.menuActionsOrProvider as IActionProvider; |
342 | | - } |
343 | | - |
344 | | - this.dropdownMenu = this._register(new DropdownMenu(container, options)); |
345 | | - this._register(this.dropdownMenu.onDidChangeVisibility(visible => { |
346 | | - this.element?.setAttribute('aria-expanded', `${visible}`); |
347 | | - this._onDidChangeVisibility.fire(visible); |
348 | | - })); |
349 | | - |
350 | | - this.dropdownMenu.menuOptions = { |
351 | | - actionViewItemProvider: this.actionViewItemProvider, |
352 | | - actionRunner: this.actionRunner, |
353 | | - getKeyBinding: this.keybindings, |
354 | | - context: this._context |
355 | | - }; |
356 | | - |
357 | | - if (this.anchorAlignmentProvider) { |
358 | | - const that = this; |
359 | | - |
360 | | - this.dropdownMenu.menuOptions = { |
361 | | - ...this.dropdownMenu.menuOptions, |
362 | | - get anchorAlignment(): AnchorAlignment { |
363 | | - return that.anchorAlignmentProvider!(); |
364 | | - } |
365 | | - }; |
366 | | - } |
367 | | - } |
368 | | - |
369 | | - setActionContext(newContext: unknown): void { |
370 | | - super.setActionContext(newContext); |
371 | | - |
372 | | - if (this.dropdownMenu) { |
373 | | - if (this.dropdownMenu.menuOptions) { |
374 | | - this.dropdownMenu.menuOptions.context = newContext; |
375 | | - } else { |
376 | | - this.dropdownMenu.menuOptions = { context: newContext }; |
377 | | - } |
378 | | - } |
379 | | - } |
380 | | - |
381 | | - show(): void { |
382 | | - if (this.dropdownMenu) { |
383 | | - this.dropdownMenu.show(); |
384 | | - } |
385 | | - } |
386 | | -} |
0 commit comments