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 { FocusOrigin } from '@angular/cdk/a11y';
|
---|
9 | import { Direction } from '@angular/cdk/bidi';
|
---|
10 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
11 | import { AfterContentInit, ElementRef, EventEmitter, InjectionToken, NgZone, OnDestroy, TemplateRef, QueryList, OnInit } from '@angular/core';
|
---|
12 | import { Observable, Subject } from 'rxjs';
|
---|
13 | import { MatMenuContent } from './menu-content';
|
---|
14 | import { MenuPositionX, MenuPositionY } from './menu-positions';
|
---|
15 | import { MatMenuItem } from './menu-item';
|
---|
16 | import { MatMenuPanel } from './menu-panel';
|
---|
17 | import { AnimationEvent } from '@angular/animations';
|
---|
18 | /** Default `mat-menu` options that can be overridden. */
|
---|
19 | export interface MatMenuDefaultOptions {
|
---|
20 | /** The x-axis position of the menu. */
|
---|
21 | xPosition: MenuPositionX;
|
---|
22 | /** The y-axis position of the menu. */
|
---|
23 | yPosition: MenuPositionY;
|
---|
24 | /** Whether the menu should overlap the menu trigger. */
|
---|
25 | overlapTrigger: boolean;
|
---|
26 | /** Class to be applied to the menu's backdrop. */
|
---|
27 | backdropClass: string;
|
---|
28 | /** Class or list of classes to be applied to the menu's overlay panel. */
|
---|
29 | overlayPanelClass?: string | string[];
|
---|
30 | /** Whether the menu has a backdrop. */
|
---|
31 | hasBackdrop?: boolean;
|
---|
32 | }
|
---|
33 | /** Injection token to be used to override the default options for `mat-menu`. */
|
---|
34 | export declare const MAT_MENU_DEFAULT_OPTIONS: InjectionToken<MatMenuDefaultOptions>;
|
---|
35 | /** @docs-private */
|
---|
36 | export declare function MAT_MENU_DEFAULT_OPTIONS_FACTORY(): MatMenuDefaultOptions;
|
---|
37 | /** Reason why the menu was closed. */
|
---|
38 | export declare type MenuCloseReason = void | 'click' | 'keydown' | 'tab';
|
---|
39 | /** Base class with all of the `MatMenu` functionality. */
|
---|
40 | export declare class _MatMenuBase implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnInit, OnDestroy {
|
---|
41 | private _elementRef;
|
---|
42 | private _ngZone;
|
---|
43 | private _defaultOptions;
|
---|
44 | private _keyManager;
|
---|
45 | private _xPosition;
|
---|
46 | private _yPosition;
|
---|
47 | private _previousElevation;
|
---|
48 | protected _elevationPrefix: string;
|
---|
49 | protected _baseElevation: number;
|
---|
50 | /** All items inside the menu. Includes items nested inside another menu. */
|
---|
51 | _allItems: QueryList<MatMenuItem>;
|
---|
52 | /** Only the direct descendant menu items. */
|
---|
53 | private _directDescendantItems;
|
---|
54 | /** Subscription to tab events on the menu panel */
|
---|
55 | private _tabSubscription;
|
---|
56 | /** Config object to be passed into the menu's ngClass */
|
---|
57 | _classList: {
|
---|
58 | [key: string]: boolean;
|
---|
59 | };
|
---|
60 | /** Current state of the panel animation. */
|
---|
61 | _panelAnimationState: 'void' | 'enter';
|
---|
62 | /** Emits whenever an animation on the menu completes. */
|
---|
63 | readonly _animationDone: Subject<AnimationEvent>;
|
---|
64 | /** Whether the menu is animating. */
|
---|
65 | _isAnimating: boolean;
|
---|
66 | /** Parent menu of the current menu panel. */
|
---|
67 | parentMenu: MatMenuPanel | undefined;
|
---|
68 | /** Layout direction of the menu. */
|
---|
69 | direction: Direction;
|
---|
70 | /** Class or list of classes to be added to the overlay panel. */
|
---|
71 | overlayPanelClass: string | string[];
|
---|
72 | /** Class to be added to the backdrop element. */
|
---|
73 | backdropClass: string;
|
---|
74 | /** aria-label for the menu panel. */
|
---|
75 | ariaLabel: string;
|
---|
76 | /** aria-labelledby for the menu panel. */
|
---|
77 | ariaLabelledby: string;
|
---|
78 | /** aria-describedby for the menu panel. */
|
---|
79 | ariaDescribedby: string;
|
---|
80 | /** Position of the menu in the X axis. */
|
---|
81 | get xPosition(): MenuPositionX;
|
---|
82 | set xPosition(value: MenuPositionX);
|
---|
83 | /** Position of the menu in the Y axis. */
|
---|
84 | get yPosition(): MenuPositionY;
|
---|
85 | set yPosition(value: MenuPositionY);
|
---|
86 | /** @docs-private */
|
---|
87 | templateRef: TemplateRef<any>;
|
---|
88 | /**
|
---|
89 | * List of the items inside of a menu.
|
---|
90 | * @deprecated
|
---|
91 | * @breaking-change 8.0.0
|
---|
92 | */
|
---|
93 | items: QueryList<MatMenuItem>;
|
---|
94 | /**
|
---|
95 | * Menu content that will be rendered lazily.
|
---|
96 | * @docs-private
|
---|
97 | */
|
---|
98 | lazyContent: MatMenuContent;
|
---|
99 | /** Whether the menu should overlap its trigger. */
|
---|
100 | get overlapTrigger(): boolean;
|
---|
101 | set overlapTrigger(value: boolean);
|
---|
102 | private _overlapTrigger;
|
---|
103 | /** Whether the menu has a backdrop. */
|
---|
104 | get hasBackdrop(): boolean | undefined;
|
---|
105 | set hasBackdrop(value: boolean | undefined);
|
---|
106 | private _hasBackdrop;
|
---|
107 | /**
|
---|
108 | * This method takes classes set on the host mat-menu element and applies them on the
|
---|
109 | * menu template that displays in the overlay container. Otherwise, it's difficult
|
---|
110 | * to style the containing menu from outside the component.
|
---|
111 | * @param classes list of class names
|
---|
112 | */
|
---|
113 | set panelClass(classes: string);
|
---|
114 | private _previousPanelClass;
|
---|
115 | /**
|
---|
116 | * This method takes classes set on the host mat-menu element and applies them on the
|
---|
117 | * menu template that displays in the overlay container. Otherwise, it's difficult
|
---|
118 | * to style the containing menu from outside the component.
|
---|
119 | * @deprecated Use `panelClass` instead.
|
---|
120 | * @breaking-change 8.0.0
|
---|
121 | */
|
---|
122 | get classList(): string;
|
---|
123 | set classList(classes: string);
|
---|
124 | /** Event emitted when the menu is closed. */
|
---|
125 | readonly closed: EventEmitter<MenuCloseReason>;
|
---|
126 | /**
|
---|
127 | * Event emitted when the menu is closed.
|
---|
128 | * @deprecated Switch to `closed` instead
|
---|
129 | * @breaking-change 8.0.0
|
---|
130 | */
|
---|
131 | readonly close: EventEmitter<MenuCloseReason>;
|
---|
132 | readonly panelId: string;
|
---|
133 | constructor(_elementRef: ElementRef<HTMLElement>, _ngZone: NgZone, _defaultOptions: MatMenuDefaultOptions);
|
---|
134 | ngOnInit(): void;
|
---|
135 | ngAfterContentInit(): void;
|
---|
136 | ngOnDestroy(): void;
|
---|
137 | /** Stream that emits whenever the hovered menu item changes. */
|
---|
138 | _hovered(): Observable<MatMenuItem>;
|
---|
139 | addItem(_item: MatMenuItem): void;
|
---|
140 | /**
|
---|
141 | * Removes an item from the menu.
|
---|
142 | * @docs-private
|
---|
143 | * @deprecated No longer being used. To be removed.
|
---|
144 | * @breaking-change 9.0.0
|
---|
145 | */
|
---|
146 | removeItem(_item: MatMenuItem): void;
|
---|
147 | /** Handle a keyboard event from the menu, delegating to the appropriate action. */
|
---|
148 | _handleKeydown(event: KeyboardEvent): void;
|
---|
149 | /**
|
---|
150 | * Focus the first item in the menu.
|
---|
151 | * @param origin Action from which the focus originated. Used to set the correct styling.
|
---|
152 | */
|
---|
153 | focusFirstItem(origin?: FocusOrigin): void;
|
---|
154 | /**
|
---|
155 | * Actual implementation that focuses the first item. Needs to be separated
|
---|
156 | * out so we don't repeat the same logic in the public `focusFirstItem` method.
|
---|
157 | */
|
---|
158 | private _focusFirstItem;
|
---|
159 | /**
|
---|
160 | * Resets the active item in the menu. This is used when the menu is opened, allowing
|
---|
161 | * the user to start from the first option when pressing the down arrow.
|
---|
162 | */
|
---|
163 | resetActiveItem(): void;
|
---|
164 | /**
|
---|
165 | * Sets the menu panel elevation.
|
---|
166 | * @param depth Number of parent menus that come before the menu.
|
---|
167 | */
|
---|
168 | setElevation(depth: number): void;
|
---|
169 | /**
|
---|
170 | * Adds classes to the menu panel based on its position. Can be used by
|
---|
171 | * consumers to add specific styling based on the position.
|
---|
172 | * @param posX Position of the menu along the x axis.
|
---|
173 | * @param posY Position of the menu along the y axis.
|
---|
174 | * @docs-private
|
---|
175 | */
|
---|
176 | setPositionClasses(posX?: MenuPositionX, posY?: MenuPositionY): void;
|
---|
177 | /** Starts the enter animation. */
|
---|
178 | _startAnimation(): void;
|
---|
179 | /** Resets the panel animation to its initial state. */
|
---|
180 | _resetAnimation(): void;
|
---|
181 | /** Callback that is invoked when the panel animation completes. */
|
---|
182 | _onAnimationDone(event: AnimationEvent): void;
|
---|
183 | _onAnimationStart(event: AnimationEvent): void;
|
---|
184 | /**
|
---|
185 | * Sets up a stream that will keep track of any newly-added menu items and will update the list
|
---|
186 | * of direct descendants. We collect the descendants this way, because `_allItems` can include
|
---|
187 | * items that are part of child menus, and using a custom way of registering items is unreliable
|
---|
188 | * when it comes to maintaining the item order.
|
---|
189 | */
|
---|
190 | private _updateDirectDescendants;
|
---|
191 | static ngAcceptInputType_overlapTrigger: BooleanInput;
|
---|
192 | static ngAcceptInputType_hasBackdrop: BooleanInput;
|
---|
193 | }
|
---|
194 | /** @docs-public MatMenu */
|
---|
195 | export declare class MatMenu extends _MatMenuBase {
|
---|
196 | protected _elevationPrefix: string;
|
---|
197 | protected _baseElevation: number;
|
---|
198 | constructor(elementRef: ElementRef<HTMLElement>, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions);
|
---|
199 | }
|
---|