menu.d.ts 7.0 KB

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