import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y'; import { Overlay, ScrollStrategy } from '@angular/cdk/overlay'; import { AfterContentInit, ElementRef, EventEmitter, InjectionToken, OnDestroy, ViewContainerRef } from '@angular/core'; import { OuiMenu } from './menu-directive'; import { OuiMenuItem } from './menu-item'; import { OuiMenuPanel } from './menu-panel'; import * as i0 from "@angular/core"; /** Injection token that determines the scroll handling while the menu is open. */ export declare const OUI_MENU_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; /** @docs-private */ export declare function OUI_MENU_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy; /** @docs-private */ export declare const OUI_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER: { provide: InjectionToken<() => ScrollStrategy>; deps: (typeof Overlay)[]; useFactory: typeof OUI_MENU_SCROLL_STRATEGY_FACTORY; }; /** Default top padding of the menu panel. */ export declare const MENU_PANEL_TOP_PADDING = 11; /** Default left padding of the menu panel */ export declare const MENU_PANEL_LEFT_PADDING = 2; /** * This directive is intended to be used in conjunction with an oui-menu tag. It is * responsible for toggling the display of the provided menu instance. */ export declare class OuiMenuTrigger implements AfterContentInit, OnDestroy { private _overlay; private _element; private _viewContainerRef; private _parentMenu; private _menuItemInstance; private _focusMonitor?; private _portal; private _overlayRef; private _menuOpen; private _closeSubscription; private _hoverSubscription; private _menuCloseSubscription; private _scrollStrategy; private _openViaFocus; _openedBy: 'mouse' | 'touch' | null; /** References the menu instance that the trigger is associated with. */ get menu(): OuiMenuPanel; set menu(menu: OuiMenuPanel); private _menu; /** 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 closed. */ readonly menuClosed: EventEmitter; /** * Handles touch start events on the trigger. * Needs to be an arrow function so we can easily use addEventListener and removeEventListener. */ private _handleTouchStart; constructor(_overlay: Overlay, _element: ElementRef, _viewContainerRef: ViewContainerRef, scrollStrategy: any, _parentMenu: OuiMenu, _menuItemInstance: OuiMenuItem, _focusMonitor?: FocusMonitor); ngAfterContentInit(): void; ngOnDestroy(): void; /** Whether the menu is open. */ get menuOpen(): boolean; /** 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(event?: 'click' | 'keydown' | 'tab'): 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; /** * 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; /** * This method checks that a valid instance of OuiMenu has been passed into * ouiMenuTriggerFor. 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; /** * 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; /** 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; _handleFocus(): void; /** Handles the cases where the user hovers over the trigger. */ private _handleHover; /** Gets the portal that should be attached to the overlay. */ private _getPortal; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } //# sourceMappingURL=menu-trigger.d.ts.map