@ux-aspects/ux-aspects
Version:
Open source user interface framework for building modern, responsive, mobile big data applications
87 lines (86 loc) • 4.19 kB
TypeScript
import { FocusOrigin } from '@angular/cdk/a11y';
import { BooleanInput } from '@angular/cdk/coercion';
import { ElementRef, EventEmitter, OnDestroy, OnInit, QueryList } from '@angular/core';
import { Observable } from 'rxjs';
import { MenuComponent } from '../menu/menu.component';
import * as i0 from "@angular/core";
export declare class MenuTriggerDirective implements OnInit, OnDestroy {
private readonly _overlay;
private readonly _elementRef;
private readonly _viewContainerRef;
private readonly _focusOrigin;
private readonly _focusIndicatorService;
private readonly _overlayPlacement;
private readonly _parentMenu;
private readonly _menuItem;
/** Access the menu we should show */
menu: MenuComponent;
/** Determine if we should disable the trigger */
disabled: boolean;
/** Optionally specify the menu's parent element */
parent: ElementRef;
/** Determine if the menu should close when it loses focus */
set closeOnBlur(value: boolean);
get closeOnBlur(): boolean;
/** Emit when the menu is closed */
readonly closed: EventEmitter<void>;
/** Reference to the portal based off the MenuCompont templateRef */
private _portal;
/** Store the reference to the overlay */
private _overlayRef?;
/** Get the aria controls for accessibility */
get ariaControls(): string | null;
/** Store the instance of the focus indicator */
private _focusIndicator;
/** Automatically unsubscribe on directive destroy */
private readonly _onDestroy$;
/** Reference to the menu should close when it loses focus */
private _closeOnBlur;
/** Determine if this triggers a submenu */
private get _isSubmenuTrigger();
/** Determine if this is the root trigger */
private get _isRootTrigger();
private readonly _debounceTime;
menuTriggers: QueryList<MenuTriggerDirective>;
/** If this is a submenu we want to know when the mouse leaves the items or parent item */
private get _menuShouldClose();
ngOnInit(): void;
ngOnDestroy(): void;
/** Focus the next focusable element */
focusNextElement(): void;
/** Open the menu */
openMenu(): void;
/** Close a menu or submenu */
closeMenu(origin?: FocusOrigin, closeParents?: boolean, focusTrigger?: boolean, focusNextElement?: boolean): Observable<void>;
/** Toggle the open state of a menu */
toggleMenu(event?: MouseEvent | KeyboardEvent): void;
/** Submenus should be opened by hovering on the menu item */
_onMouseEnter(): void;
_onMouseMove(): void;
/** Pressing the escape key should close all menus */
_onEscape(): void;
/** Handle keyboard events for opening submenus */
_onKeydown(event: KeyboardEvent): void;
/** Blurring the trigger should check if the menu has focus and close it if not */
_onBlur(): void;
/** Remove the menu from the DOM */
private destroyMenu;
/** Create an overlay or return an existing instance */
private getOverlay;
/** Create a Template portal if one does not already exist (or the template has changed) */
private getPortal;
/** Get an observable that emits on any of the triggers that close a menu */
private didMenuClose;
/** When the menu opens we want to focus the first item in the list */
private menuDidOpen;
/** Handle keypresses in submenus where we may want to close them */
private onMenuKeydown;
/** Check whether the overlay has focus */
private hasFocus;
/** Close the menu if there is no element focused */
private closeOnFocusout;
private getSubMenuPlacement;
static ngAcceptInputType_closeOnBlur: BooleanInput;
static ɵfac: i0.ɵɵFactoryDeclaration<MenuTriggerDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MenuTriggerDirective, "[uxMenuTriggerFor]", ["ux-menu-trigger"], { "menu": { "alias": "uxMenuTriggerFor"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "parent": { "alias": "uxMenuParent"; "required": false; }; "closeOnBlur": { "alias": "closeOnBlur"; "required": false; }; }, { "closed": "closed"; }, ["menuTriggers"], never, false, never>;
}