1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';
|
---|
9 | import { Direction, Directionality } from '@angular/cdk/bidi';
|
---|
10 | import { Overlay, ScrollStrategy } from '@angular/cdk/overlay';
|
---|
11 | import { AfterContentInit, ElementRef, EventEmitter, InjectionToken, OnDestroy, ViewContainerRef } from '@angular/core';
|
---|
12 | import { MatMenuItem } from './menu-item';
|
---|
13 | import { MatMenuPanel } from './menu-panel';
|
---|
14 | /** Injection token that determines the scroll handling while the menu is open. */
|
---|
15 | export declare const MAT_MENU_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
|
---|
16 | /** @docs-private */
|
---|
17 | export declare function MAT_MENU_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
|
---|
18 | /** @docs-private */
|
---|
19 | export declare const MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER: {
|
---|
20 | provide: InjectionToken<() => ScrollStrategy>;
|
---|
21 | deps: (typeof Overlay)[];
|
---|
22 | useFactory: typeof MAT_MENU_SCROLL_STRATEGY_FACTORY;
|
---|
23 | };
|
---|
24 | /** Default top padding of the menu panel. */
|
---|
25 | export declare const MENU_PANEL_TOP_PADDING = 8;
|
---|
26 | export declare abstract class _MatMenuTriggerBase implements AfterContentInit, OnDestroy {
|
---|
27 | private _overlay;
|
---|
28 | private _element;
|
---|
29 | private _viewContainerRef;
|
---|
30 | private _menuItemInstance;
|
---|
31 | private _dir;
|
---|
32 | private _focusMonitor?;
|
---|
33 | private _portal;
|
---|
34 | private _overlayRef;
|
---|
35 | private _menuOpen;
|
---|
36 | private _closingActionsSubscription;
|
---|
37 | private _hoverSubscription;
|
---|
38 | private _menuCloseSubscription;
|
---|
39 | private _scrollStrategy;
|
---|
40 | /**
|
---|
41 | * We're specifically looking for a `MatMenu` here since the generic `MatMenuPanel`
|
---|
42 | * interface lacks some functionality around nested menus and animations.
|
---|
43 | */
|
---|
44 | private _parentMaterialMenu;
|
---|
45 | /**
|
---|
46 | * Handles touch start events on the trigger.
|
---|
47 | * Needs to be an arrow function so we can easily use addEventListener and removeEventListener.
|
---|
48 | */
|
---|
49 | private _handleTouchStart;
|
---|
50 | _openedBy: Exclude<FocusOrigin, 'program' | null> | undefined;
|
---|
51 | get _ariaExpanded(): true | null;
|
---|
52 | get _ariaControl(): string | null | undefined;
|
---|
53 | _ariaHaspopup: boolean;
|
---|
54 | /**
|
---|
55 | * @deprecated
|
---|
56 | * @breaking-change 8.0.0
|
---|
57 | */
|
---|
58 | get _deprecatedMatMenuTriggerFor(): MatMenuPanel;
|
---|
59 | set _deprecatedMatMenuTriggerFor(v: MatMenuPanel);
|
---|
60 | /** References the menu instance that the trigger is associated with. */
|
---|
61 | get menu(): MatMenuPanel;
|
---|
62 | set menu(menu: MatMenuPanel);
|
---|
63 | private _menu;
|
---|
64 | /** Data to be passed along to any lazily-rendered content. */
|
---|
65 | menuData: any;
|
---|
66 | /**
|
---|
67 | * Whether focus should be restored when the menu is closed.
|
---|
68 | * Note that disabling this option can have accessibility implications
|
---|
69 | * and it's up to you to manage focus, if you decide to turn it off.
|
---|
70 | */
|
---|
71 | restoreFocus: boolean;
|
---|
72 | /** Event emitted when the associated menu is opened. */
|
---|
73 | readonly menuOpened: EventEmitter<void>;
|
---|
74 | /**
|
---|
75 | * Event emitted when the associated menu is opened.
|
---|
76 | * @deprecated Switch to `menuOpened` instead
|
---|
77 | * @breaking-change 8.0.0
|
---|
78 | */
|
---|
79 | readonly onMenuOpen: EventEmitter<void>;
|
---|
80 | /** Event emitted when the associated menu is closed. */
|
---|
81 | readonly menuClosed: EventEmitter<void>;
|
---|
82 | /**
|
---|
83 | * Event emitted when the associated menu is closed.
|
---|
84 | * @deprecated Switch to `menuClosed` instead
|
---|
85 | * @breaking-change 8.0.0
|
---|
86 | */
|
---|
87 | readonly onMenuClose: EventEmitter<void>;
|
---|
88 | constructor(_overlay: Overlay, _element: ElementRef<HTMLElement>, _viewContainerRef: ViewContainerRef, scrollStrategy: any, parentMenu: MatMenuPanel, _menuItemInstance: MatMenuItem, _dir: Directionality, _focusMonitor?: FocusMonitor | undefined);
|
---|
89 | ngAfterContentInit(): void;
|
---|
90 | ngOnDestroy(): void;
|
---|
91 | /** Whether the menu is open. */
|
---|
92 | get menuOpen(): boolean;
|
---|
93 | /** The text direction of the containing app. */
|
---|
94 | get dir(): Direction;
|
---|
95 | /** Whether the menu triggers a sub-menu or a top-level one. */
|
---|
96 | triggersSubmenu(): boolean;
|
---|
97 | /** Toggles the menu between the open and closed states. */
|
---|
98 | toggleMenu(): void;
|
---|
99 | /** Opens the menu. */
|
---|
100 | openMenu(): void;
|
---|
101 | /** Closes the menu. */
|
---|
102 | closeMenu(): void;
|
---|
103 | /**
|
---|
104 | * Focuses the menu trigger.
|
---|
105 | * @param origin Source of the menu trigger's focus.
|
---|
106 | */
|
---|
107 | focus(origin?: FocusOrigin, options?: FocusOptions): void;
|
---|
108 | /**
|
---|
109 | * Updates the position of the menu to ensure that it fits all options within the viewport.
|
---|
110 | */
|
---|
111 | updatePosition(): void;
|
---|
112 | /** Closes the menu and does the necessary cleanup. */
|
---|
113 | private _destroyMenu;
|
---|
114 | /**
|
---|
115 | * This method sets the menu state to open and focuses the first item if
|
---|
116 | * the menu was opened via the keyboard.
|
---|
117 | */
|
---|
118 | private _initMenu;
|
---|
119 | /** Updates the menu elevation based on the amount of parent menus that it has. */
|
---|
120 | private _setMenuElevation;
|
---|
121 | private _setIsMenuOpen;
|
---|
122 | /**
|
---|
123 | * This method checks that a valid instance of MatMenu has been passed into
|
---|
124 | * matMenuTriggerFor. If not, an exception is thrown.
|
---|
125 | */
|
---|
126 | private _checkMenu;
|
---|
127 | /**
|
---|
128 | * This method creates the overlay from the provided menu's template and saves its
|
---|
129 | * OverlayRef so that it can be attached to the DOM when openMenu is called.
|
---|
130 | */
|
---|
131 | private _createOverlay;
|
---|
132 | /**
|
---|
133 | * This method builds the configuration object needed to create the overlay, the OverlayState.
|
---|
134 | * @returns OverlayConfig
|
---|
135 | */
|
---|
136 | private _getOverlayConfig;
|
---|
137 | /**
|
---|
138 | * Listens to changes in the position of the overlay and sets the correct classes
|
---|
139 | * on the menu based on the new position. This ensures the animation origin is always
|
---|
140 | * correct, even if a fallback position is used for the overlay.
|
---|
141 | */
|
---|
142 | private _subscribeToPositions;
|
---|
143 | /**
|
---|
144 | * Sets the appropriate positions on a position strategy
|
---|
145 | * so the overlay connects with the trigger correctly.
|
---|
146 | * @param positionStrategy Strategy whose position to update.
|
---|
147 | */
|
---|
148 | private _setPosition;
|
---|
149 | /** Returns a stream that emits whenever an action that should close the menu occurs. */
|
---|
150 | private _menuClosingActions;
|
---|
151 | /** Handles mouse presses on the trigger. */
|
---|
152 | _handleMousedown(event: MouseEvent): void;
|
---|
153 | /** Handles key presses on the trigger. */
|
---|
154 | _handleKeydown(event: KeyboardEvent): void;
|
---|
155 | /** Handles click events on the trigger. */
|
---|
156 | _handleClick(event: MouseEvent): void;
|
---|
157 | /** Handles the cases where the user hovers over the trigger. */
|
---|
158 | private _handleHover;
|
---|
159 | /** Gets the portal that should be attached to the overlay. */
|
---|
160 | private _getPortal;
|
---|
161 | }
|
---|
162 | /** Directive applied to an element that should trigger a `mat-menu`. */
|
---|
163 | export declare class MatMenuTrigger extends _MatMenuTriggerBase {
|
---|
164 | }
|
---|