module.d-C9bwr5Wr.d.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. import * as i0 from '@angular/core';
  2. import { InjectionToken, OnDestroy, AfterViewInit, ElementRef } from '@angular/core';
  3. import * as i1 from '@angular/cdk/a11y';
  4. import * as i2 from '@angular/cdk/overlay';
  5. import { ScrollStrategy, Overlay, OverlayRef, ConnectedPosition, OriginConnectionPosition, OverlayConnectionPosition } from '@angular/cdk/overlay';
  6. import { M as MatCommonModule } from './common-module.d-C8xzHJDr.js';
  7. import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
  8. import { Directionality } from '@angular/cdk/bidi';
  9. import { Observable } from 'rxjs';
  10. import * as i5 from '@angular/cdk/scrolling';
  11. /** Possible positions for a tooltip. */
  12. type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after';
  13. /**
  14. * Options for how the tooltip trigger should handle touch gestures.
  15. * See `MatTooltip.touchGestures` for more information.
  16. */
  17. type TooltipTouchGestures = 'auto' | 'on' | 'off';
  18. /** Possible visibility states of a tooltip. */
  19. type TooltipVisibility = 'initial' | 'visible' | 'hidden';
  20. /** Time in ms to throttle repositioning after scroll events. */
  21. declare const SCROLL_THROTTLE_MS = 20;
  22. /**
  23. * Creates an error to be thrown if the user supplied an invalid tooltip position.
  24. * @docs-private
  25. */
  26. declare function getMatTooltipInvalidPositionError(position: string): Error;
  27. /** Injection token that determines the scroll handling while a tooltip is visible. */
  28. declare const MAT_TOOLTIP_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
  29. /**
  30. * @docs-private
  31. * @deprecated No longer used, will be removed.
  32. * @breaking-change 21.0.0
  33. */
  34. declare function MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
  35. /**
  36. * @docs-private
  37. * @deprecated No longer used, will be removed.
  38. * @breaking-change 21.0.0
  39. */
  40. declare const MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER: {
  41. provide: InjectionToken<() => ScrollStrategy>;
  42. deps: (typeof Overlay)[];
  43. useFactory: typeof MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY;
  44. };
  45. /**
  46. * @docs-private
  47. * @deprecated No longer used, will be removed.
  48. * @breaking-change 21.0.0
  49. */
  50. declare function MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY(): MatTooltipDefaultOptions;
  51. /** Injection token to be used to override the default options for `matTooltip`. */
  52. declare const MAT_TOOLTIP_DEFAULT_OPTIONS: InjectionToken<MatTooltipDefaultOptions>;
  53. /** Default `matTooltip` options that can be overridden. */
  54. interface MatTooltipDefaultOptions {
  55. /** Default delay when the tooltip is shown. */
  56. showDelay: number;
  57. /** Default delay when the tooltip is hidden. */
  58. hideDelay: number;
  59. /** Default delay when hiding the tooltip on a touch device. */
  60. touchendHideDelay: number;
  61. /** Time between the user putting the pointer on a tooltip trigger and the long press event being fired on a touch device. */
  62. touchLongPressShowDelay?: number;
  63. /** Default touch gesture handling for tooltips. */
  64. touchGestures?: TooltipTouchGestures;
  65. /** Default position for tooltips. */
  66. position?: TooltipPosition;
  67. /**
  68. * Default value for whether tooltips should be positioned near the click or touch origin
  69. * instead of outside the element bounding box.
  70. */
  71. positionAtOrigin?: boolean;
  72. /** Disables the ability for the user to interact with the tooltip element. */
  73. disableTooltipInteractivity?: boolean;
  74. /**
  75. * Default classes to be applied to the tooltip. These default classes will not be applied if
  76. * `tooltipClass` is defined directly on the tooltip element, as it will override the default.
  77. */
  78. tooltipClass?: string | string[];
  79. }
  80. /**
  81. * CSS class that will be attached to the overlay panel.
  82. * @deprecated
  83. * @breaking-change 13.0.0 remove this variable
  84. */
  85. declare const TOOLTIP_PANEL_CLASS = "mat-mdc-tooltip-panel";
  86. /**
  87. * Directive that attaches a material design tooltip to the host element. Animates the showing and
  88. * hiding of a tooltip provided position (defaults to below the element).
  89. *
  90. * https://material.io/design/components/tooltips.html
  91. */
  92. declare class MatTooltip implements OnDestroy, AfterViewInit {
  93. private _elementRef;
  94. private _ngZone;
  95. private _platform;
  96. private _ariaDescriber;
  97. private _focusMonitor;
  98. protected _dir: Directionality;
  99. private _injector;
  100. private _viewContainerRef;
  101. private _defaultOptions;
  102. _overlayRef: OverlayRef | null;
  103. _tooltipInstance: TooltipComponent | null;
  104. private _portal;
  105. private _position;
  106. private _positionAtOrigin;
  107. private _disabled;
  108. private _tooltipClass;
  109. private _viewInitialized;
  110. private _pointerExitEventsInitialized;
  111. private readonly _tooltipComponent;
  112. private _viewportMargin;
  113. private _currentPosition;
  114. private readonly _cssClassPrefix;
  115. private _ariaDescriptionPending;
  116. private _dirSubscribed;
  117. /** Allows the user to define the position of the tooltip relative to the parent element */
  118. get position(): TooltipPosition;
  119. set position(value: TooltipPosition);
  120. /**
  121. * Whether tooltip should be relative to the click or touch origin
  122. * instead of outside the element bounding box.
  123. */
  124. get positionAtOrigin(): boolean;
  125. set positionAtOrigin(value: BooleanInput);
  126. /** Disables the display of the tooltip. */
  127. get disabled(): boolean;
  128. set disabled(value: BooleanInput);
  129. /** The default delay in ms before showing the tooltip after show is called */
  130. get showDelay(): number;
  131. set showDelay(value: NumberInput);
  132. private _showDelay;
  133. /** The default delay in ms before hiding the tooltip after hide is called */
  134. get hideDelay(): number;
  135. set hideDelay(value: NumberInput);
  136. private _hideDelay;
  137. /**
  138. * How touch gestures should be handled by the tooltip. On touch devices the tooltip directive
  139. * uses a long press gesture to show and hide, however it can conflict with the native browser
  140. * gestures. To work around the conflict, Angular Material disables native gestures on the
  141. * trigger, but that might not be desirable on particular elements (e.g. inputs and draggable
  142. * elements). The different values for this option configure the touch event handling as follows:
  143. * - `auto` - Enables touch gestures for all elements, but tries to avoid conflicts with native
  144. * browser gestures on particular elements. In particular, it allows text selection on inputs
  145. * and textareas, and preserves the native browser dragging on elements marked as `draggable`.
  146. * - `on` - Enables touch gestures for all elements and disables native
  147. * browser gestures with no exceptions.
  148. * - `off` - Disables touch gestures. Note that this will prevent the tooltip from
  149. * showing on touch devices.
  150. */
  151. touchGestures: TooltipTouchGestures;
  152. /** The message to be displayed in the tooltip */
  153. get message(): string;
  154. set message(value: string | null | undefined);
  155. private _message;
  156. /** Classes to be passed to the tooltip. Supports the same syntax as `ngClass`. */
  157. get tooltipClass(): string | string[] | Set<string> | {
  158. [key: string]: any;
  159. };
  160. set tooltipClass(value: string | string[] | Set<string> | {
  161. [key: string]: any;
  162. });
  163. /** Manually-bound passive event listeners. */
  164. private readonly _passiveListeners;
  165. /** Timer started at the last `touchstart` event. */
  166. private _touchstartTimeout;
  167. /** Emits when the component is destroyed. */
  168. private readonly _destroyed;
  169. /** Whether ngOnDestroyed has been called. */
  170. private _isDestroyed;
  171. constructor(...args: unknown[]);
  172. ngAfterViewInit(): void;
  173. /**
  174. * Dispose the tooltip when destroyed.
  175. */
  176. ngOnDestroy(): void;
  177. /** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */
  178. show(delay?: number, origin?: {
  179. x: number;
  180. y: number;
  181. }): void;
  182. /** Hides the tooltip after the delay in ms, defaults to tooltip-delay-hide or 0ms if no input */
  183. hide(delay?: number): void;
  184. /** Shows/hides the tooltip */
  185. toggle(origin?: {
  186. x: number;
  187. y: number;
  188. }): void;
  189. /** Returns true if the tooltip is currently visible to the user */
  190. _isTooltipVisible(): boolean;
  191. /** Create the overlay config and position strategy */
  192. private _createOverlay;
  193. /** Detaches the currently-attached tooltip. */
  194. private _detach;
  195. /** Updates the position of the current tooltip. */
  196. private _updatePosition;
  197. /** Adds the configured offset to a position. Used as a hook for child classes. */
  198. protected _addOffset(position: ConnectedPosition): ConnectedPosition;
  199. /**
  200. * Returns the origin position and a fallback position based on the user's position preference.
  201. * The fallback position is the inverse of the origin (e.g. `'below' -> 'above'`).
  202. */
  203. _getOrigin(): {
  204. main: OriginConnectionPosition;
  205. fallback: OriginConnectionPosition;
  206. };
  207. /** Returns the overlay position and a fallback position based on the user's preference */
  208. _getOverlayPosition(): {
  209. main: OverlayConnectionPosition;
  210. fallback: OverlayConnectionPosition;
  211. };
  212. /** Updates the tooltip message and repositions the overlay according to the new message length */
  213. private _updateTooltipMessage;
  214. /** Updates the tooltip class */
  215. private _setTooltipClass;
  216. /** Inverts an overlay position. */
  217. private _invertPosition;
  218. /** Updates the class on the overlay panel based on the current position of the tooltip. */
  219. private _updateCurrentPositionClass;
  220. /** Binds the pointer events to the tooltip trigger. */
  221. private _setupPointerEnterEventsIfNeeded;
  222. private _setupPointerExitEventsIfNeeded;
  223. private _addListeners;
  224. private _platformSupportsMouseEvents;
  225. /** Listener for the `wheel` event on the element. */
  226. private _wheelListener;
  227. /** Disables the native browser gestures, based on how the tooltip has been configured. */
  228. private _disableNativeGesturesIfNecessary;
  229. /** Updates the tooltip's ARIA description based on it current state. */
  230. private _syncAriaDescription;
  231. static ɵfac: i0.ɵɵFactoryDeclaration<MatTooltip, never>;
  232. static ɵdir: i0.ɵɵDirectiveDeclaration<MatTooltip, "[matTooltip]", ["matTooltip"], { "position": { "alias": "matTooltipPosition"; "required": false; }; "positionAtOrigin": { "alias": "matTooltipPositionAtOrigin"; "required": false; }; "disabled": { "alias": "matTooltipDisabled"; "required": false; }; "showDelay": { "alias": "matTooltipShowDelay"; "required": false; }; "hideDelay": { "alias": "matTooltipHideDelay"; "required": false; }; "touchGestures": { "alias": "matTooltipTouchGestures"; "required": false; }; "message": { "alias": "matTooltip"; "required": false; }; "tooltipClass": { "alias": "matTooltipClass"; "required": false; }; }, {}, never, never, true, never>;
  233. }
  234. /**
  235. * Internal component that wraps the tooltip's content.
  236. * @docs-private
  237. */
  238. declare class TooltipComponent implements OnDestroy {
  239. private _changeDetectorRef;
  240. protected _elementRef: ElementRef<HTMLElement>;
  241. _isMultiline: boolean;
  242. /** Message to display in the tooltip */
  243. message: string;
  244. /** Classes to be added to the tooltip. Supports the same syntax as `ngClass`. */
  245. tooltipClass: string | string[] | Set<string> | {
  246. [key: string]: any;
  247. };
  248. /** The timeout ID of any current timer set to show the tooltip */
  249. private _showTimeoutId;
  250. /** The timeout ID of any current timer set to hide the tooltip */
  251. private _hideTimeoutId;
  252. /** Element that caused the tooltip to open. */
  253. _triggerElement: HTMLElement;
  254. /** Amount of milliseconds to delay the closing sequence. */
  255. _mouseLeaveHideDelay: number;
  256. /** Whether animations are currently disabled. */
  257. private _animationsDisabled;
  258. /** Reference to the internal tooltip element. */
  259. _tooltip: ElementRef<HTMLElement>;
  260. /** Whether interactions on the page should close the tooltip */
  261. private _closeOnInteraction;
  262. /** Whether the tooltip is currently visible. */
  263. private _isVisible;
  264. /** Subject for notifying that the tooltip has been hidden from the view */
  265. private readonly _onHide;
  266. /** Name of the show animation and the class that toggles it. */
  267. private readonly _showAnimation;
  268. /** Name of the hide animation and the class that toggles it. */
  269. private readonly _hideAnimation;
  270. constructor(...args: unknown[]);
  271. /**
  272. * Shows the tooltip with an animation originating from the provided origin
  273. * @param delay Amount of milliseconds to the delay showing the tooltip.
  274. */
  275. show(delay: number): void;
  276. /**
  277. * Begins the animation to hide the tooltip after the provided delay in ms.
  278. * @param delay Amount of milliseconds to delay showing the tooltip.
  279. */
  280. hide(delay: number): void;
  281. /** Returns an observable that notifies when the tooltip has been hidden from view. */
  282. afterHidden(): Observable<void>;
  283. /** Whether the tooltip is being displayed. */
  284. isVisible(): boolean;
  285. ngOnDestroy(): void;
  286. /**
  287. * Interactions on the HTML body should close the tooltip immediately as defined in the
  288. * material design spec.
  289. * https://material.io/design/components/tooltips.html#behavior
  290. */
  291. _handleBodyInteraction(): void;
  292. /**
  293. * Marks that the tooltip needs to be checked in the next change detection run.
  294. * Mainly used for rendering the initial text before positioning a tooltip, which
  295. * can be problematic in components with OnPush change detection.
  296. */
  297. _markForCheck(): void;
  298. _handleMouseLeave({ relatedTarget }: MouseEvent): void;
  299. /**
  300. * Callback for when the timeout in this.show() gets completed.
  301. * This method is only needed by the mdc-tooltip, and so it is only implemented
  302. * in the mdc-tooltip, not here.
  303. */
  304. protected _onShow(): void;
  305. /** Whether the tooltip text has overflown to the next line */
  306. private _isTooltipMultiline;
  307. /** Event listener dispatched when an animation on the tooltip finishes. */
  308. _handleAnimationEnd({ animationName }: AnimationEvent): void;
  309. /** Cancels any pending animation sequences. */
  310. _cancelPendingAnimations(): void;
  311. /** Handles the cleanup after an animation has finished. */
  312. private _finalizeAnimation;
  313. /** Toggles the visibility of the tooltip element. */
  314. private _toggleVisibility;
  315. static ɵfac: i0.ɵɵFactoryDeclaration<TooltipComponent, never>;
  316. static ɵcmp: i0.ɵɵComponentDeclaration<TooltipComponent, "mat-tooltip-component", never, {}, {}, never, never, true, never>;
  317. }
  318. declare class MatTooltipModule {
  319. static ɵfac: i0.ɵɵFactoryDeclaration<MatTooltipModule, never>;
  320. static ɵmod: i0.ɵɵNgModuleDeclaration<MatTooltipModule, never, [typeof i1.A11yModule, typeof i2.OverlayModule, typeof MatCommonModule, typeof MatTooltip, typeof TooltipComponent], [typeof MatTooltip, typeof TooltipComponent, typeof MatCommonModule, typeof i5.CdkScrollableModule]>;
  321. static ɵinj: i0.ɵɵInjectorDeclaration<MatTooltipModule>;
  322. }
  323. export { MatTooltipModule as M, SCROLL_THROTTLE_MS as S, MAT_TOOLTIP_SCROLL_STRATEGY as c, MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY as d, MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER as e, MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY as f, getMatTooltipInvalidPositionError as g, MAT_TOOLTIP_DEFAULT_OPTIONS as h, TOOLTIP_PANEL_CLASS as j, MatTooltip as k, TooltipComponent as l };
  324. export type { TooltipPosition as T, TooltipTouchGestures as a, TooltipVisibility as b, MatTooltipDefaultOptions as i };