import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y'; import { Direction, Directionality } from '@angular/cdk/bidi'; import { Overlay, ScrollStrategy } from '@angular/cdk/overlay'; import { AfterContentInit, ElementRef, EventEmitter, InjectionToken, OnDestroy, ViewContainerRef } from '@angular/core'; import { VdlMenu } from './menu-directive'; import { VdlMenuItem } from './menu-item'; import { VdlMenuPanel } from './menu-panel'; /** Injection token that determines the scroll handling while the menu is open. */ export declare const VDL_MENU_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; /** @docs-private */ export declare function VDL_MENU_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy; /** @docs-private */ export declare const VDL_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER: { provide: InjectionToken<() => ScrollStrategy>; deps: (typeof Overlay)[]; useFactory: typeof VDL_MENU_SCROLL_STRATEGY_FACTORY; }; /** Default top padding of the menu panel. */ export declare const MENU_PANEL_TOP_PADDING = 8; /** * This directive is intended to be used in conjunction with an vdl-menu tag. It is * responsible for toggling the display of the provided menu instance. */ export declare class VdlMenuTrigger implements AfterContentInit, OnDestroy { private _overlay; private _element; private _viewContainerRef; private _scrollStrategy; private _parentMenu; private _menuItemInstance; private _dir; private _focusMonitor; private _portal; private _overlayRef; private _menuOpen; private _closeSubscription; private _hoverSubscription; private _openedByMouse; /** * @deprecated * @deletion-target 7.0.0 */ _deprecatedVdlMenuTriggerFor: VdlMenuPanel; /** References the menu instance that the trigger is associated with. */ menu: VdlMenuPanel; /** Data to be passed along to any lazily-rendered content. */ menuData: any; /** Event emitted when the associated menu is opened. */ readonly menuOpened: EventEmitter; /** * Event emitted when the associated menu is opened. * @deprecated Switch to `menuOpened` instead * @deletion-target 7.0.0 */ readonly onMenuOpen: EventEmitter; /** Event emitted when the associated menu is closed. */ readonly menuClosed: EventEmitter; /** * Event emitted when the associated menu is closed. * @deprecated Switch to `menuClosed` instead * @deletion-target 7.0.0 */ readonly onMenuClose: EventEmitter; constructor(_overlay: Overlay, _element: ElementRef, _viewContainerRef: ViewContainerRef, _scrollStrategy: any, _parentMenu: VdlMenu, _menuItemInstance: VdlMenuItem, _dir: Directionality, _focusMonitor?: FocusMonitor); ngAfterContentInit(): void; ngOnDestroy(): void; /** Whether the menu is open. */ readonly menuOpen: boolean; /** The text direction of the containing app. */ readonly dir: Direction; /** Whether the menu triggers a sub-menu or a top-level one. */ triggersSubmenu(): boolean; /** Toggles the menu between the open and closed states. */ toggleMenu(): void; /** Opens the menu. */ openMenu(): void; /** Closes the menu. */ closeMenu(): void; /** * Focuses the menu trigger. * @param origin Source of the menu trigger's focus. */ focus(origin?: FocusOrigin): void; /** Closes the menu and does the necessary cleanup. */ private _destroyMenu(); /** * This method sets the menu state to open and focuses the first item if * the menu was opened via the keyboard. */ private _initMenu(); /** Updates the menu elevation based on the amount of parent menus that it has. */ private _setMenuElevation(); /** * This method resets the menu when it's closed, most importantly restoring * focus to the menu trigger if the menu was opened via the keyboard. */ private _resetMenu(); private _setIsMenuOpen(isOpen); /** * This method checks that a valid instance of VdlMenu has been passed into * VdlMenuTriggerFor. If not, an exception is thrown. */ private _checkMenu(); /** * This method creates the overlay from the provided menu's template and saves its * OverlayRef so that it can be attached to the DOM when openMenu is called. */ private _createOverlay(); /** * This method builds the configuration object needed to create the overlay, the OverlayState. * @returns OverlayConfig */ private _getOverlayConfig(); /** * Listens to changes in the position of the overlay and sets the correct classes * on the menu based on the new position. This ensures the animation origin is always * correct, even if a fallback position is used for the overlay. */ private _subscribeToPositions(position); /** * Sets the appropriate positions on a position strategy * so the overlay connects with the trigger correctly. * @param positionStrategy Strategy whose position to update. */ private _setPosition(positionStrategy); /** Cleans up the active subscriptions. */ private _cleanUpSubscriptions(); /** Returns a stream that emits whenever an action that should close the menu occurs. */ private _menuClosingActions(); /** Handles mouse presses on the trigger. */ _handleMousedown(event: MouseEvent): void; /** Handles key presses on the trigger. */ _handleKeydown(event: KeyboardEvent): void; /** Handles click events on the trigger. */ _handleClick(event: MouseEvent): void; /** Handles the cases where the user hovers over the trigger. */ private _handleHover(); }