UNPKG

38.7 kBTypeScriptView Raw
1import { AfterContentInit } from '@angular/core';
2import { BooleanInput } from '@angular/cdk/coercion';
3import { ConnectedPosition } from '@angular/cdk/overlay';
4import { Directionality } from '@angular/cdk/bidi';
5import { ElementRef } from '@angular/core';
6import { EventEmitter } from '@angular/core';
7import { FocusableOption } from '@angular/cdk/a11y';
8import { FocusKeyManager } from '@angular/cdk/a11y';
9import { FocusOrigin } from '@angular/cdk/a11y';
10import * as i0 from '@angular/core';
11import * as i1 from '@angular/cdk/overlay';
12import { InjectionToken } from '@angular/core';
13import { Injector } from '@angular/core';
14import { NgZone } from '@angular/core';
15import { Observable } from 'rxjs';
16import { OnDestroy } from '@angular/core';
17import { Optional } from '@angular/core';
18import { OverlayRef } from '@angular/cdk/overlay';
19import { QueryList } from '@angular/core';
20import { Subject } from 'rxjs';
21import { TemplatePortal } from '@angular/cdk/portal';
22import { TemplateRef } from '@angular/core';
23import { ViewContainerRef } from '@angular/core';
24
25/** Injection token used to return classes implementing the Menu interface */
26export declare const CDK_MENU: InjectionToken<Menu>;
27
28/**
29 * A directive that opens a menu when a user right-clicks within its host element.
30 * It is aware of nested context menus and will trigger only the lowest level non-disabled context menu.
31 */
32export declare class CdkContextMenuTrigger extends CdkMenuTriggerBase implements OnDestroy {
33 /** The CDK overlay service. */
34 private readonly _overlay;
35 /** The directionality of the page. */
36 private readonly _directionality;
37 /** The app's context menu tracking registry */
38 private readonly _contextMenuTracker;
39 /** Whether the context menu is disabled. */
40 get disabled(): boolean;
41 set disabled(value: BooleanInput);
42 private _disabled;
43 constructor();
44 /**
45 * Open the attached menu at the specified location.
46 * @param coordinates where to open the context menu
47 */
48 open(coordinates: ContextMenuCoordinates): void;
49 /** Close the currently opened context menu. */
50 close(): void;
51 /**
52 * Open the context menu and closes any previously open menus.
53 * @param event the mouse event which opens the context menu.
54 */
55 _openOnContextMenu(event: MouseEvent): void;
56 /**
57 * Get the configuration object used to create the overlay.
58 * @param coordinates the location to place the opened menu
59 */
60 private _getOverlayConfig;
61 /**
62 * Get the position strategy for the overlay which specifies where to place the menu.
63 * @param coordinates the location to place the opened menu
64 */
65 private _getOverlayPositionStrategy;
66 /** Subscribe to the menu stack close events and close this menu when requested. */
67 private _setMenuStackCloseListener;
68 /**
69 * Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
70 * click occurs outside the menus.
71 * @param ignoreFirstAuxClick Whether to ignore the first auxclick event outside the menu.
72 */
73 private _subscribeToOutsideClicks;
74 /**
75 * Open the attached menu at the specified location.
76 * @param coordinates where to open the context menu
77 * @param ignoreFirstOutsideAuxClick Whether to ignore the first auxclick outside the menu after opening.
78 */
79 private _open;
80 static ɵfac: i0.ɵɵFactoryDeclaration<CdkContextMenuTrigger, never>;
81 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkContextMenuTrigger, "[cdkContextMenuTriggerFor]", ["cdkContextMenuTriggerFor"], { "menuTemplateRef": { "alias": "cdkContextMenuTriggerFor"; "required": false; }; "menuPosition": { "alias": "cdkContextMenuPosition"; "required": false; }; "menuData": { "alias": "cdkContextMenuTriggerData"; "required": false; }; "disabled": { "alias": "cdkContextMenuDisabled"; "required": false; }; }, { "opened": "cdkContextMenuOpened"; "closed": "cdkContextMenuClosed"; }, never, never, true, never>;
82}
83
84/**
85 * Directive which configures the element as a Menu which should contain child elements marked as
86 * CdkMenuItem or CdkMenuGroup. Sets the appropriate role and aria-attributes for a menu and
87 * contains accessible keyboard and mouse handling logic.
88 *
89 * It also acts as a RadioGroup for elements marked with role `menuitemradio`.
90 */
91export declare class CdkMenu extends CdkMenuBase implements AfterContentInit, OnDestroy {
92 private _parentTrigger;
93 /** Event emitted when the menu is closed. */
94 readonly closed: EventEmitter<void>;
95 /** The direction items in the menu flow. */
96 readonly orientation = "vertical";
97 /** Whether the menu is displayed inline (i.e. always present vs a conditional popup that the user triggers with a trigger element). */
98 readonly isInline: boolean;
99 constructor();
100 ngAfterContentInit(): void;
101 ngOnDestroy(): void;
102 /**
103 * Handle keyboard events for the Menu.
104 * @param event The keyboard event to be handled.
105 */
106 _handleKeyEvent(event: KeyboardEvent): void;
107 /**
108 * Set focus the either the current, previous or next item based on the FocusNext event.
109 * @param focusNext The element to focus.
110 */
111 private _toggleMenuFocus;
112 /** Subscribe to the MenuStack emptied events. */
113 private _subscribeToMenuStackEmptied;
114 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenu, never>;
115 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenu, "[cdkMenu]", ["cdkMenu"], {}, { "closed": "closed"; }, never, never, true, never>;
116}
117
118/**
119 * Directive applied to an element which configures it as a MenuBar by setting the appropriate
120 * role, aria attributes, and accessible keyboard and mouse handling logic. The component that
121 * this directive is applied to should contain components marked with CdkMenuItem.
122 *
123 */
124export declare class CdkMenuBar extends CdkMenuBase implements AfterContentInit {
125 /** The direction items in the menu flow. */
126 readonly orientation = "horizontal";
127 /** Whether the menu is displayed inline (i.e. always present vs a conditional popup that the user triggers with a trigger element). */
128 readonly isInline = true;
129 ngAfterContentInit(): void;
130 /**
131 * Handle keyboard events for the Menu.
132 * @param event The keyboard event to be handled.
133 */
134 _handleKeyEvent(event: KeyboardEvent): void;
135 /**
136 * Set focus to either the current, previous or next item based on the FocusNext event, then
137 * open the previous or next item.
138 * @param focusNext The element to focus.
139 */
140 private _toggleOpenMenu;
141 /** Subscribe to the MenuStack emptied events. */
142 private _subscribeToMenuStackEmptied;
143 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuBar, never>;
144 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuBar, "[cdkMenuBar]", ["cdkMenuBar"], {}, {}, never, never, true, never>;
145}
146
147/**
148 * Abstract directive that implements shared logic common to all menus.
149 * This class can be extended to create custom menu types.
150 */
151export declare abstract class CdkMenuBase extends CdkMenuGroup implements Menu, AfterContentInit, OnDestroy {
152 /** The menu's native DOM host element. */
153 readonly nativeElement: HTMLElement;
154 /** The Angular zone. */
155 protected ngZone: NgZone;
156 /** The stack of menus this menu belongs to. */
157 readonly menuStack: MenuStack;
158 /** The menu aim service used by this menu. */
159 protected readonly menuAim: MenuAim | null;
160 /** The directionality (text direction) of the current page. */
161 protected readonly dir: Directionality | null;
162 /** The id of the menu's host element. */
163 id: string;
164 /** All child MenuItem elements nested in this Menu. */
165 readonly items: QueryList<CdkMenuItem>;
166 /** The direction items in the menu flow. */
167 orientation: 'horizontal' | 'vertical';
168 /**
169 * Whether the menu is displayed inline (i.e. always present vs a conditional popup that the
170 * user triggers with a trigger element).
171 */
172 isInline: boolean;
173 /** Handles keyboard events for the menu. */
174 protected keyManager: FocusKeyManager<CdkMenuItem>;
175 /** Emits when the MenuBar is destroyed. */
176 protected readonly destroyed: Subject<void>;
177 /** The Menu Item which triggered the open submenu. */
178 protected triggerItem?: CdkMenuItem;
179 /** Tracks the users mouse movements over the menu. */
180 protected pointerTracker?: PointerFocusTracker<CdkMenuItem>;
181 /** Whether this menu's menu stack has focus. */
182 private _menuStackHasFocus;
183 ngAfterContentInit(): void;
184 ngOnDestroy(): void;
185 /**
186 * Place focus on the first MenuItem in the menu and set the focus origin.
187 * @param focusOrigin The origin input mode of the focus event.
188 */
189 focusFirstItem(focusOrigin?: FocusOrigin): void;
190 /**
191 * Place focus on the last MenuItem in the menu and set the focus origin.
192 * @param focusOrigin The origin input mode of the focus event.
193 */
194 focusLastItem(focusOrigin?: FocusOrigin): void;
195 /** Gets the tabindex for this menu. */
196 _getTabIndex(): 0 | -1 | null;
197 /**
198 * Close the open menu if the current active item opened the requested MenuStackItem.
199 * @param menu The menu requested to be closed.
200 * @param options Options to configure the behavior on close.
201 * - `focusParentTrigger` Whether to focus the parent trigger after closing the menu.
202 */
203 protected closeOpenMenu(menu: MenuStackItem, options?: {
204 focusParentTrigger?: boolean;
205 }): void;
206 /** Setup the FocusKeyManager with the correct orientation for the menu. */
207 private _setKeyManager;
208 /**
209 * Subscribe to the menu trigger's open events in order to track the trigger which opened the menu
210 * and stop tracking it when the menu is closed.
211 */
212 private _subscribeToMenuOpen;
213 /** Subscribe to the MenuStack close events. */
214 private _subscribeToMenuStackClosed;
215 /** Subscribe to the MenuStack hasFocus events. */
216 private _subscribeToMenuStackHasFocus;
217 /**
218 * Set the PointerFocusTracker and ensure that when mouse focus changes the key manager is updated
219 * with the latest menu item under mouse focus.
220 */
221 private _setUpPointerTracker;
222 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuBase, never>;
223 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuBase, never, never, { "id": { "alias": "id"; "required": false; }; }, {}, ["items"], never, false, never>;
224}
225
226/**
227 * A grouping container for `CdkMenuItemRadio` instances, similar to a `role="radiogroup"` element.
228 */
229export declare class CdkMenuGroup {
230 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuGroup, never>;
231 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuGroup, "[cdkMenuGroup]", ["cdkMenuGroup"], {}, {}, never, never, true, never>;
232}
233
234/**
235 * Directive which provides the ability for an element to be focused and navigated to using the
236 * keyboard when residing in a CdkMenu, CdkMenuBar, or CdkMenuGroup. It performs user defined
237 * behavior when clicked.
238 */
239export declare class CdkMenuItem implements FocusableOption, FocusableElement, Toggler, OnDestroy {
240 protected readonly _dir: Directionality | null;
241 private readonly _inputModalityDetector;
242 readonly _elementRef: ElementRef<HTMLElement>;
243 protected _ngZone: NgZone;
244 /** The menu aim service used by this menu. */
245 private readonly _menuAim;
246 /** The stack of menus this menu belongs to. */
247 private readonly _menuStack;
248 /** The parent menu in which this menuitem resides. */
249 private readonly _parentMenu;
250 /** Reference to the CdkMenuItemTrigger directive if one is added to the same element */
251 private readonly _menuTrigger;
252 /** Whether the CdkMenuItem is disabled - defaults to false */
253 get disabled(): boolean;
254 set disabled(value: BooleanInput);
255 private _disabled;
256 /**
257 * The text used to locate this item during menu typeahead. If not specified,
258 * the `textContent` of the item will be used.
259 */
260 typeaheadLabel: string | null;
261 /**
262 * If this MenuItem is a regular MenuItem, outputs when it is triggered by a keyboard or mouse
263 * event.
264 */
265 readonly triggered: EventEmitter<void>;
266 /** Whether the menu item opens a menu. */
267 get hasMenu(): boolean;
268 /**
269 * The tabindex for this menu item managed internally and used for implementing roving a
270 * tab index.
271 */
272 _tabindex: 0 | -1;
273 /** Whether the item should close the menu if triggered by the spacebar. */
274 protected closeOnSpacebarTrigger: boolean;
275 /** Emits when the menu item is destroyed. */
276 protected readonly destroyed: Subject<void>;
277 constructor();
278 ngOnDestroy(): void;
279 /** Place focus on the element. */
280 focus(): void;
281 /**
282 * If the menu item is not disabled and the element does not have a menu trigger attached, emit
283 * on the cdkMenuItemTriggered emitter and close all open menus.
284 * @param options Options the configure how the item is triggered
285 * - keepOpen: specifies that the menu should be kept open after triggering the item.
286 */
287 trigger(options?: {
288 keepOpen: boolean;
289 }): void;
290 /** Return true if this MenuItem has an attached menu and it is open. */
291 isMenuOpen(): boolean;
292 /**
293 * Get a reference to the rendered Menu if the Menu is open and it is visible in the DOM.
294 * @return the menu if it is open, otherwise undefined.
295 */
296 getMenu(): Menu | undefined;
297 /** Get the CdkMenuTrigger associated with this element. */
298 getMenuTrigger(): CdkMenuTrigger | null;
299 /** Get the label for this element which is required by the FocusableOption interface. */
300 getLabel(): string;
301 /** Reset the tabindex to -1. */
302 _resetTabIndex(): void;
303 /**
304 * Set the tab index to 0 if not disabled and it's a focus event, or a mouse enter if this element
305 * is not in a menu bar.
306 */
307 _setTabIndex(event?: MouseEvent): void;
308 /**
309 * Handles keyboard events for the menu item, specifically either triggering the user defined
310 * callback or opening/closing the current menu based on whether the left or right arrow key was
311 * pressed.
312 * @param event the keyboard event to handle
313 */
314 _onKeydown(event: KeyboardEvent): void;
315 /** Handles clicks on the menu item. */
316 _handleClick(): void;
317 /** Whether this menu item is standalone or within a menu or menu bar. */
318 private _isStandaloneItem;
319 /**
320 * Handles the user pressing the back arrow key.
321 * @param event The keyboard event.
322 */
323 private _backArrowPressed;
324 /**
325 * Handles the user pressing the forward arrow key.
326 * @param event The keyboard event.
327 */
328 private _forwardArrowPressed;
329 /**
330 * Subscribe to the mouseenter events and close any sibling menu items if this element is moused
331 * into.
332 */
333 private _setupMouseEnter;
334 /**
335 * Return true if the enclosing parent menu is configured in a horizontal orientation, false
336 * otherwise or if no parent.
337 */
338 private _isParentVertical;
339 /** Sets the `type` attribute of the menu item. */
340 private _setType;
341 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuItem, never>;
342 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuItem, "[cdkMenuItem]", ["cdkMenuItem"], { "disabled": { "alias": "cdkMenuItemDisabled"; "required": false; }; "typeaheadLabel": { "alias": "cdkMenuitemTypeaheadLabel"; "required": false; }; }, { "triggered": "cdkMenuItemTriggered"; }, never, never, true, never>;
343}
344
345/**
346 * A directive providing behavior for the "menuitemcheckbox" ARIA role, which behaves similarly to a
347 * conventional checkbox.
348 */
349export declare class CdkMenuItemCheckbox extends CdkMenuItemSelectable {
350 /**
351 * Toggle the checked state of the checkbox.
352 * @param options Options the configure how the item is triggered
353 * - keepOpen: specifies that the menu should be kept open after triggering the item.
354 */
355 trigger(options?: {
356 keepOpen: boolean;
357 }): void;
358 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuItemCheckbox, never>;
359 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuItemCheckbox, "[cdkMenuItemCheckbox]", ["cdkMenuItemCheckbox"], {}, {}, never, never, true, never>;
360}
361
362/**
363 * A directive providing behavior for the "menuitemradio" ARIA role, which behaves similarly to
364 * a conventional radio-button. Any sibling `CdkMenuItemRadio` instances within the same `CdkMenu`
365 * or `CdkMenuGroup` comprise a radio group with unique selection enforced.
366 */
367export declare class CdkMenuItemRadio extends CdkMenuItemSelectable implements OnDestroy {
368 /** The unique selection dispatcher for this radio's `CdkMenuGroup`. */
369 private readonly _selectionDispatcher;
370 /** An ID to identify this radio item to the `UniqueSelectionDispatcher`. */
371 private _id;
372 /** Function to unregister the selection dispatcher */
373 private _removeDispatcherListener;
374 constructor();
375 ngOnDestroy(): void;
376 /**
377 * Toggles the checked state of the radio-button.
378 * @param options Options the configure how the item is triggered
379 * - keepOpen: specifies that the menu should be kept open after triggering the item.
380 */
381 trigger(options?: {
382 keepOpen: boolean;
383 }): void;
384 /** Configure the unique selection dispatcher listener in order to toggle the checked state */
385 private _registerDispatcherListener;
386 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuItemRadio, never>;
387 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuItemRadio, "[cdkMenuItemRadio]", ["cdkMenuItemRadio"], {}, {}, never, never, true, never>;
388}
389
390/** Base class providing checked state for selectable MenuItems. */
391export declare abstract class CdkMenuItemSelectable extends CdkMenuItem {
392 /** Whether the element is checked */
393 get checked(): boolean;
394 set checked(value: BooleanInput);
395 private _checked;
396 /** Whether the item should close the menu if triggered by the spacebar. */
397 protected closeOnSpacebarTrigger: boolean;
398 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuItemSelectable, never>;
399 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuItemSelectable, never, never, { "checked": { "alias": "cdkMenuItemChecked"; "required": false; }; }, {}, never, never, false, never>;
400}
401
402/** Module that declares components and directives for the CDK menu. */
403export declare class CdkMenuModule {
404 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuModule, never>;
405 static ɵmod: i0.ɵɵNgModuleDeclaration<CdkMenuModule, never, [typeof i1.OverlayModule, typeof i2.CdkMenuBar, typeof i3.CdkMenu, typeof i4.CdkMenuItem, typeof i5.CdkMenuItemRadio, typeof i6.CdkMenuItemCheckbox, typeof i7.CdkMenuTrigger, typeof i8.CdkMenuGroup, typeof i9.CdkContextMenuTrigger, typeof i10.CdkTargetMenuAim], [typeof i2.CdkMenuBar, typeof i3.CdkMenu, typeof i4.CdkMenuItem, typeof i5.CdkMenuItemRadio, typeof i6.CdkMenuItemCheckbox, typeof i7.CdkMenuTrigger, typeof i8.CdkMenuGroup, typeof i9.CdkContextMenuTrigger, typeof i10.CdkTargetMenuAim]>;
406 static ɵinj: i0.ɵɵInjectorDeclaration<CdkMenuModule>;
407}
408
409/**
410 * A directive that turns its host element into a trigger for a popup menu.
411 * It can be combined with cdkMenuItem to create sub-menus. If the element is in a top level
412 * MenuBar it will open the menu on click, or if a sibling is already opened it will open on hover.
413 * If it is inside of a Menu it will open the attached Submenu on hover regardless of its sibling
414 * state.
415 */
416export declare class CdkMenuTrigger extends CdkMenuTriggerBase implements OnDestroy {
417 private readonly _elementRef;
418 private readonly _overlay;
419 private readonly _ngZone;
420 private readonly _directionality;
421 private readonly _inputModalityDetector;
422 /** The parent menu this trigger belongs to. */
423 private readonly _parentMenu;
424 /** The menu aim service used by this menu. */
425 private readonly _menuAim;
426 constructor();
427 /** Toggle the attached menu. */
428 toggle(): void;
429 /** Open the attached menu. */
430 open(): void;
431 /** Close the opened menu. */
432 close(): void;
433 /**
434 * Get a reference to the rendered Menu if the Menu is open and rendered in the DOM.
435 */
436 getMenu(): Menu | undefined;
437 /**
438 * Handles keyboard events for the menu item.
439 * @param event The keyboard event to handle
440 */
441 _toggleOnKeydown(event: KeyboardEvent): void;
442 /** Handles clicks on the menu trigger. */
443 _handleClick(): void;
444 /**
445 * Sets whether the trigger's menu stack has focus.
446 * @param hasFocus Whether the menu stack has focus.
447 */
448 _setHasFocus(hasFocus: boolean): void;
449 /**
450 * Subscribe to the mouseenter events and close any sibling menu items if this element is moused
451 * into.
452 */
453 private _subscribeToMouseEnter;
454 /** Close out any sibling menu trigger menus. */
455 private _closeSiblingTriggers;
456 /** Get the configuration object used to create the overlay. */
457 private _getOverlayConfig;
458 /** Build the position strategy for the overlay which specifies where to place the menu. */
459 private _getOverlayPositionStrategy;
460 /** Get the preferred positions for the opened menu relative to the menu item. */
461 private _getOverlayPositions;
462 /**
463 * Subscribe to the MenuStack close events if this is a standalone trigger and close out the menu
464 * this triggers when requested.
465 */
466 private _registerCloseHandler;
467 /**
468 * Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
469 * click occurs outside the menus.
470 */
471 private _subscribeToOutsideClicks;
472 /** Subscribe to the MenuStack hasFocus events. */
473 private _subscribeToMenuStackHasFocus;
474 /** Subscribe to the MenuStack closed events. */
475 private _subscribeToMenuStackClosed;
476 /** Sets the role attribute for this trigger if needed. */
477 private _setRole;
478 /** Sets thte `type` attribute of the trigger. */
479 private _setType;
480 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuTrigger, never>;
481 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuTrigger, "[cdkMenuTriggerFor]", ["cdkMenuTriggerFor"], { "menuTemplateRef": { "alias": "cdkMenuTriggerFor"; "required": false; }; "menuPosition": { "alias": "cdkMenuPosition"; "required": false; }; "menuData": { "alias": "cdkMenuTriggerData"; "required": false; }; }, { "opened": "cdkMenuOpened"; "closed": "cdkMenuClosed"; }, never, never, true, never>;
482}
483
484/**
485 * Abstract directive that implements shared logic common to all menu triggers.
486 * This class can be extended to create custom menu trigger types.
487 */
488export declare abstract class CdkMenuTriggerBase implements OnDestroy {
489 /** The DI injector for this component. */
490 readonly injector: Injector;
491 /** The view container ref for this component */
492 protected readonly viewContainerRef: ViewContainerRef;
493 /** The menu stack in which this menu resides. */
494 protected readonly menuStack: MenuStack;
495 /**
496 * A list of preferred menu positions to be used when constructing the
497 * `FlexibleConnectedPositionStrategy` for this trigger's menu.
498 */
499 menuPosition: ConnectedPosition[];
500 /** Emits when the attached menu is requested to open */
501 readonly opened: EventEmitter<void>;
502 /** Emits when the attached menu is requested to close */
503 readonly closed: EventEmitter<void>;
504 /** Template reference variable to the menu this trigger opens */
505 menuTemplateRef: TemplateRef<unknown> | null;
506 /** Context data to be passed along to the menu template */
507 menuData: unknown;
508 /** A reference to the overlay which manages the triggered menu */
509 protected overlayRef: OverlayRef | null;
510 /** Emits when this trigger is destroyed. */
511 protected readonly destroyed: Subject<void>;
512 /** Emits when the outside pointer events listener on the overlay should be stopped. */
513 protected readonly stopOutsideClicksListener: Observable<void>;
514 /** The child menu opened by this trigger. */
515 protected childMenu?: Menu;
516 /** The content of the menu panel opened by this trigger. */
517 private _menuPortal;
518 /** The injector to use for the child menu opened by this trigger. */
519 private _childMenuInjector?;
520 ngOnDestroy(): void;
521 /** Whether the attached menu is open. */
522 isOpen(): boolean;
523 /** Registers a child menu as having been opened by this trigger. */
524 registerChildMenu(child: Menu): void;
525 /**
526 * Get the portal to be attached to the overlay which contains the menu. Allows for the menu
527 * content to change dynamically and be reflected in the application.
528 */
529 protected getMenuContentPortal(): TemplatePortal<any>;
530 /**
531 * Whether the given element is inside the scope of this trigger's menu stack.
532 * @param element The element to check.
533 * @return Whether the element is inside the scope of this trigger's menu stack.
534 */
535 protected isElementInsideMenuStack(element: Element): boolean;
536 /** Destroy and unset the overlay reference it if exists */
537 private _destroyOverlay;
538 /** Gets the injector to use when creating a child menu. */
539 private _getChildMenuInjector;
540 static ɵfac: i0.ɵɵFactoryDeclaration<CdkMenuTriggerBase, never>;
541 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMenuTriggerBase, never, never, {}, {}, never, never, false, never>;
542}
543
544/**
545 * CdkTargetMenuAim is a provider for the TargetMenuAim service. It can be added to an
546 * element with either the `cdkMenu` or `cdkMenuBar` directive and child menu items.
547 */
548export declare class CdkTargetMenuAim {
549 static ɵfac: i0.ɵɵFactoryDeclaration<CdkTargetMenuAim, never>;
550 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTargetMenuAim, "[cdkTargetMenuAim]", ["cdkTargetMenuAim"], {}, {}, never, never, true, never>;
551}
552
553/** Options that can be provided to the close or closeAll methods. */
554export declare interface CloseOptions {
555 /** The element to focus next if the close operation causes the menu stack to become empty. */
556 focusNextOnEmpty?: FocusNext;
557 /** Whether to focus the parent trigger after closing the menu. */
558 focusParentTrigger?: boolean;
559}
560
561/** The coordinates where the context menu should open. */
562export declare type ContextMenuCoordinates = {
563 x: number;
564 y: number;
565};
566
567/** Tracks the last open context menu trigger across the entire application. */
568export declare class ContextMenuTracker {
569 /** The last open context menu trigger. */
570 private static _openContextMenuTrigger?;
571 /**
572 * Close the previous open context menu and set the given one as being open.
573 * @param trigger The trigger for the currently open Context Menu.
574 */
575 update(trigger: CdkContextMenuTrigger): void;
576 static ɵfac: i0.ɵɵFactoryDeclaration<ContextMenuTracker, never>;
577 static ɵprov: i0.ɵɵInjectableDeclaration<ContextMenuTracker>;
578}
579
580/** Item to track for mouse focus events. */
581export declare interface FocusableElement {
582 /** A reference to the element to be tracked. */
583 _elementRef: ElementRef<HTMLElement>;
584}
585
586/** The relative item in the inline menu to focus after closing all popup menus. */
587export declare const enum FocusNext {
588 nextItem = 0,
589 previousItem = 1,
590 currentItem = 2
591}
592
593declare namespace i10 {
594 export {
595 MenuAim,
596 MENU_AIM,
597 Toggler,
598 TargetMenuAim,
599 CdkTargetMenuAim
600 }
601}
602
603declare namespace i2 {
604 export {
605 CdkMenuBar
606 }
607}
608
609declare namespace i3 {
610 export {
611 CdkMenu
612 }
613}
614
615declare namespace i4 {
616 export {
617 CdkMenuItem
618 }
619}
620
621declare namespace i5 {
622 export {
623 CdkMenuItemRadio
624 }
625}
626
627declare namespace i6 {
628 export {
629 CdkMenuItemCheckbox
630 }
631}
632
633declare namespace i7 {
634 export {
635 CdkMenuTrigger
636 }
637}
638
639declare namespace i8 {
640 export {
641 CdkMenuGroup
642 }
643}
644
645declare namespace i9 {
646 export {
647 ContextMenuTracker,
648 ContextMenuCoordinates,
649 CdkContextMenuTrigger
650 }
651}
652
653/** Interface which specifies Menu operations and used to break circular dependency issues */
654export declare interface Menu extends MenuStackItem {
655 /** The id of the menu's host element. */
656 id: string;
657 /** The menu's native DOM host element. */
658 nativeElement: HTMLElement;
659 /** The direction items in the menu flow. */
660 readonly orientation: 'horizontal' | 'vertical';
661 /** Place focus on the first MenuItem in the menu. */
662 focusFirstItem(focusOrigin: FocusOrigin): void;
663 /** Place focus on the last MenuItem in the menu. */
664 focusLastItem(focusOrigin: FocusOrigin): void;
665}
666
667/** Injection token used for an implementation of MenuAim. */
668export declare const MENU_AIM: InjectionToken<MenuAim>;
669
670/** Injection token used for an implementation of MenuStack. */
671export declare const MENU_STACK: InjectionToken<MenuStack>;
672
673/** Injection token used for an implementation of MenuStack. */
674export declare const MENU_TRIGGER: InjectionToken<CdkMenuTriggerBase>;
675
676/**
677 * MenuAim is responsible for determining if a sibling menuitem's menu should be closed when a
678 * Toggler item is hovered into. It is up to the hovered in item to call the MenuAim service in
679 * order to determine if it may perform its close actions.
680 */
681export declare interface MenuAim {
682 /**
683 * Set the Menu and its PointerFocusTracker.
684 * @param menu The menu that this menu aim service controls.
685 * @param pointerTracker The `PointerFocusTracker` for the given menu.
686 */
687 initialize(menu: Menu, pointerTracker: PointerFocusTracker<FocusableElement & Toggler>): void;
688 /**
689 * Calls the `doToggle` callback when it is deemed that the user is not moving towards
690 * the submenu.
691 * @param doToggle the function called when the user is not moving towards the submenu.
692 */
693 toggle(doToggle: () => void): void;
694}
695
696/**
697 * MenuStack allows subscribers to listen for close events (when a MenuStackItem is popped off
698 * of the stack) in order to perform closing actions. Upon the MenuStack being empty it emits
699 * from the `empty` observable specifying the next focus action which the listener should perform
700 * as requested by the closer.
701 */
702export declare class MenuStack {
703 /** The ID of this menu stack. */
704 readonly id: string;
705 /** All MenuStackItems tracked by this MenuStack. */
706 private readonly _elements;
707 /** Emits the element which was popped off of the stack when requested by a closer. */
708 private readonly _close;
709 /** Emits once the MenuStack has become empty after popping off elements. */
710 private readonly _empty;
711 /** Emits whether any menu in the menu stack has focus. */
712 private readonly _hasFocus;
713 /** Observable which emits the MenuStackItem which has been requested to close. */
714 readonly closed: Observable<MenuStackCloseEvent>;
715 /** Observable which emits whether any menu in the menu stack has focus. */
716 readonly hasFocus: Observable<boolean>;
717 /**
718 * Observable which emits when the MenuStack is empty after popping off the last element. It
719 * emits a FocusNext event which specifies the action the closer has requested the listener
720 * perform.
721 */
722 readonly emptied: Observable<FocusNext | undefined>;
723 /**
724 * Whether the inline menu associated with this menu stack is vertical or horizontal.
725 * `null` indicates there is no inline menu associated with this menu stack.
726 */
727 private _inlineMenuOrientation;
728 /** Creates a menu stack that originates from an inline menu. */
729 static inline(orientation: 'vertical' | 'horizontal'): MenuStack;
730 /**
731 * Adds an item to the menu stack.
732 * @param menu the MenuStackItem to put on the stack.
733 */
734 push(menu: MenuStackItem): void;
735 /**
736 * Pop items off of the stack up to and including `lastItem` and emit each on the close
737 * observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
738 * @param lastItem the last item to pop off the stack.
739 * @param options Options that configure behavior on close.
740 */
741 close(lastItem: MenuStackItem, options?: CloseOptions): void;
742 /**
743 * Pop items off of the stack up to but excluding `lastItem` and emit each on the close
744 * observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
745 * @param lastItem the element which should be left on the stack
746 * @return whether or not an item was removed from the stack
747 */
748 closeSubMenuOf(lastItem: MenuStackItem): boolean;
749 /**
750 * Pop off all MenuStackItems and emit each one on the `close` observable one by one.
751 * @param options Options that configure behavior on close.
752 */
753 closeAll(options?: CloseOptions): void;
754 /** Return true if this stack is empty. */
755 isEmpty(): boolean;
756 /** Return the length of the stack. */
757 length(): number;
758 /** Get the top most element on the stack. */
759 peek(): MenuStackItem | undefined;
760 /** Whether the menu stack is associated with an inline menu. */
761 hasInlineMenu(): boolean;
762 /** The orientation of the associated inline menu. */
763 inlineMenuOrientation(): "vertical" | "horizontal" | null;
764 /** Sets whether the menu stack contains the focused element. */
765 setHasFocus(hasFocus: boolean): void;
766 static ɵfac: i0.ɵɵFactoryDeclaration<MenuStack, never>;
767 static ɵprov: i0.ɵɵInjectableDeclaration<MenuStack>;
768}
769
770/** Event dispatched when a menu is closed. */
771export declare interface MenuStackCloseEvent {
772 /** The menu being closed. */
773 item: MenuStackItem;
774 /** Whether to focus the parent trigger after closing the menu. */
775 focusParentTrigger?: boolean;
776}
777
778/** A single item (menu) in the menu stack. */
779export declare interface MenuStackItem {
780 /** A reference to the menu stack this menu stack item belongs to. */
781 menuStack?: MenuStack;
782}
783
784/** Provider that provides the parent menu stack, or a new inline menu stack if there is no parent one. */
785export declare const PARENT_OR_NEW_INLINE_MENU_STACK_PROVIDER: (orientation: 'vertical' | 'horizontal') => {
786 provide: InjectionToken<MenuStack>;
787 deps: Optional[][];
788 useFactory: (parentMenuStack?: MenuStack) => MenuStack;
789};
790
791/** Provider that provides the parent menu stack, or a new menu stack if there is no parent one. */
792export declare const PARENT_OR_NEW_MENU_STACK_PROVIDER: {
793 provide: InjectionToken<MenuStack>;
794 deps: Optional[][];
795 useFactory: (parentMenuStack?: MenuStack) => MenuStack;
796};
797
798/**
799 * PointerFocusTracker keeps track of the currently active item under mouse focus. It also has
800 * observables which emit when the users mouse enters and leaves a tracked element.
801 */
802export declare class PointerFocusTracker<T extends FocusableElement> {
803 /** The list of items being tracked. */
804 private readonly _items;
805 /** Emits when an element is moused into. */
806 readonly entered: Observable<T>;
807 /** Emits when an element is moused out. */
808 readonly exited: Observable<T>;
809 /** The element currently under mouse focus. */
810 activeElement?: T;
811 /** The element previously under mouse focus. */
812 previousElement?: T;
813 /** Emits when this is destroyed. */
814 private readonly _destroyed;
815 constructor(
816 /** The list of items being tracked. */
817 _items: QueryList<T>);
818 /** Stop the managers listeners. */
819 destroy(): void;
820 /**
821 * Gets a stream of pointer (mouse) entries into the given items.
822 * This should typically run outside the Angular zone.
823 */
824 private _getItemPointerEntries;
825 /**
826 * Gets a stream of pointer (mouse) exits out of the given items.
827 * This should typically run outside the Angular zone.
828 */
829 private _getItemPointerExits;
830}
831
832/**
833 * TargetMenuAim predicts if a user is moving into a submenu. It calculates the
834 * trajectory of the user's mouse movement in the current menu to determine if the
835 * mouse is moving towards an open submenu.
836 *
837 * The determination is made by calculating the slope of the users last NUM_POINTS moves where each
838 * pair of points determines if the trajectory line points into the submenu. It uses consensus
839 * approach by checking if at least NUM_POINTS / 2 pairs determine that the user is moving towards
840 * to submenu.
841 */
842export declare class TargetMenuAim implements MenuAim, OnDestroy {
843 /** The Angular zone. */
844 private readonly _ngZone;
845 /** The last NUM_POINTS mouse move events. */
846 private readonly _points;
847 /** Reference to the root menu in which we are tracking mouse moves. */
848 private _menu;
849 /** Reference to the root menu's mouse manager. */
850 private _pointerTracker;
851 /** The id associated with the current timeout call waiting to resolve. */
852 private _timeoutId;
853 /** Emits when this service is destroyed. */
854 private readonly _destroyed;
855 ngOnDestroy(): void;
856 /**
857 * Set the Menu and its PointerFocusTracker.
858 * @param menu The menu that this menu aim service controls.
859 * @param pointerTracker The `PointerFocusTracker` for the given menu.
860 */
861 initialize(menu: Menu, pointerTracker: PointerFocusTracker<FocusableElement & Toggler>): void;
862 /**
863 * Calls the `doToggle` callback when it is deemed that the user is not moving towards
864 * the submenu.
865 * @param doToggle the function called when the user is not moving towards the submenu.
866 */
867 toggle(doToggle: () => void): void;
868 /**
869 * Start the delayed toggle handler if one isn't running already.
870 *
871 * The delayed toggle handler executes the `doToggle` callback after some period of time iff the
872 * users mouse is on an item in the current menu.
873 *
874 * @param doToggle the function called when the user is not moving towards the submenu.
875 */
876 private _startTimeout;
877 /** Whether the user is heading towards the open submenu. */
878 private _isMovingToSubmenu;
879 /** Get the bounding DOMRect for the open submenu. */
880 private _getSubmenuBounds;
881 /**
882 * Check if a reference to the PointerFocusTracker and menu element is provided.
883 * @throws an error if neither reference is provided.
884 */
885 private _checkConfigured;
886 /** Subscribe to the root menus mouse move events and update the tracked mouse points. */
887 private _subscribeToMouseMoves;
888 static ɵfac: i0.ɵɵFactoryDeclaration<TargetMenuAim, never>;
889 static ɵprov: i0.ɵɵInjectableDeclaration<TargetMenuAim>;
890}
891
892/** An element which when hovered over may open or close a menu. */
893export declare interface Toggler {
894 /** Gets the open menu, or undefined if no menu is open. */
895 getMenu(): Menu | undefined;
896}
897
898export { }