overlay-module.d-B3qEQtts.d.ts 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. import * as i0 from '@angular/core';
  2. import { OnDestroy, NgZone, EnvironmentInjector, Renderer2, ComponentRef, EmbeddedViewRef, ElementRef, OnChanges, EventEmitter, SimpleChanges } from '@angular/core';
  3. import { a as Direction, D as Directionality, B as BidiModule } from './bidi-module.d-D-fEBKdS.js';
  4. import { b as PortalOutlet, a as ComponentPortal, T as TemplatePortal, j as PortalModule } from './portal-directives.d-BoG39gYN.js';
  5. import { C as CdkScrollable, g as ScrollingModule } from './scrolling-module.d-ud2XrbF8.js';
  6. import { Location } from '@angular/common';
  7. import { Subject, Observable } from 'rxjs';
  8. import { ViewportRuler } from './scrolling/index.js';
  9. import { P as Platform } from './platform.d-B3vREl3q.js';
  10. import { _ as _CdkPrivateStyleLoader } from './style-loader.d-BXZfQZTF.js';
  11. /**
  12. * Service for dispatching events that land on the body to appropriate overlay ref,
  13. * if any. It maintains a list of attached overlays to determine best suited overlay based
  14. * on event target and order of overlay opens.
  15. */
  16. declare abstract class BaseOverlayDispatcher implements OnDestroy {
  17. /** Currently attached overlays in the order they were attached. */
  18. _attachedOverlays: OverlayRef[];
  19. protected _document: Document;
  20. protected _isAttached: boolean;
  21. constructor(...args: unknown[]);
  22. ngOnDestroy(): void;
  23. /** Add a new overlay to the list of attached overlay refs. */
  24. add(overlayRef: OverlayRef): void;
  25. /** Remove an overlay from the list of attached overlay refs. */
  26. remove(overlayRef: OverlayRef): void;
  27. /** Detaches the global event listener. */
  28. protected abstract detach(): void;
  29. static ɵfac: i0.ɵɵFactoryDeclaration<BaseOverlayDispatcher, never>;
  30. static ɵprov: i0.ɵɵInjectableDeclaration<BaseOverlayDispatcher>;
  31. }
  32. /**
  33. * Service for dispatching keyboard events that land on the body to appropriate overlay ref,
  34. * if any. It maintains a list of attached overlays to determine best suited overlay based
  35. * on event target and order of overlay opens.
  36. */
  37. declare class OverlayKeyboardDispatcher extends BaseOverlayDispatcher {
  38. private _ngZone;
  39. private _renderer;
  40. private _cleanupKeydown;
  41. /** Add a new overlay to the list of attached overlay refs. */
  42. add(overlayRef: OverlayRef): void;
  43. /** Detaches the global keyboard event listener. */
  44. protected detach(): void;
  45. /** Keyboard event listener that will be attached to the body. */
  46. private _keydownListener;
  47. static ɵfac: i0.ɵɵFactoryDeclaration<OverlayKeyboardDispatcher, never>;
  48. static ɵprov: i0.ɵɵInjectableDeclaration<OverlayKeyboardDispatcher>;
  49. }
  50. /**
  51. * Service for dispatching mouse click events that land on the body to appropriate overlay ref,
  52. * if any. It maintains a list of attached overlays to determine best suited overlay based
  53. * on event target and order of overlay opens.
  54. */
  55. declare class OverlayOutsideClickDispatcher extends BaseOverlayDispatcher {
  56. private _platform;
  57. private _ngZone;
  58. private _renderer;
  59. private _cursorOriginalValue;
  60. private _cursorStyleIsSet;
  61. private _pointerDownEventTarget;
  62. private _cleanups;
  63. /** Add a new overlay to the list of attached overlay refs. */
  64. add(overlayRef: OverlayRef): void;
  65. /** Detaches the global keyboard event listener. */
  66. protected detach(): void;
  67. /** Store pointerdown event target to track origin of click. */
  68. private _pointerDownListener;
  69. /** Click event listener that will be attached to the body propagate phase. */
  70. private _clickListener;
  71. static ɵfac: i0.ɵɵFactoryDeclaration<OverlayOutsideClickDispatcher, never>;
  72. static ɵprov: i0.ɵɵInjectableDeclaration<OverlayOutsideClickDispatcher>;
  73. }
  74. /**
  75. * Describes a strategy that will be used by an overlay to handle scroll events while it is open.
  76. */
  77. interface ScrollStrategy {
  78. /** Enable this scroll strategy (called when the attached overlay is attached to a portal). */
  79. enable: () => void;
  80. /** Disable this scroll strategy (called when the attached overlay is detached from a portal). */
  81. disable: () => void;
  82. /** Attaches this `ScrollStrategy` to an overlay. */
  83. attach: (overlayRef: OverlayRef) => void;
  84. /** Detaches the scroll strategy from the current overlay. */
  85. detach?: () => void;
  86. }
  87. /** An object where all of its properties cannot be written. */
  88. type ImmutableObject<T> = {
  89. readonly [P in keyof T]: T[P];
  90. };
  91. /**
  92. * Reference to an overlay that has been created with the Overlay service.
  93. * Used to manipulate or dispose of said overlay.
  94. */
  95. declare class OverlayRef implements PortalOutlet {
  96. private _portalOutlet;
  97. private _host;
  98. private _pane;
  99. private _config;
  100. private _ngZone;
  101. private _keyboardDispatcher;
  102. private _document;
  103. private _location;
  104. private _outsideClickDispatcher;
  105. private _animationsDisabled;
  106. private _injector;
  107. private _renderer;
  108. private readonly _backdropClick;
  109. private readonly _attachments;
  110. private readonly _detachments;
  111. private _positionStrategy;
  112. private _scrollStrategy;
  113. private _locationChanges;
  114. private _backdropRef;
  115. /**
  116. * Reference to the parent of the `_host` at the time it was detached. Used to restore
  117. * the `_host` to its original position in the DOM when it gets re-attached.
  118. */
  119. private _previousHostParent;
  120. /** Stream of keydown events dispatched to this overlay. */
  121. readonly _keydownEvents: Subject<KeyboardEvent>;
  122. /** Stream of mouse outside events dispatched to this overlay. */
  123. readonly _outsidePointerEvents: Subject<MouseEvent>;
  124. private _renders;
  125. private _afterRenderRef;
  126. /** Reference to the currently-running `afterNextRender` call. */
  127. private _afterNextRenderRef;
  128. constructor(_portalOutlet: PortalOutlet, _host: HTMLElement, _pane: HTMLElement, _config: ImmutableObject<OverlayConfig>, _ngZone: NgZone, _keyboardDispatcher: OverlayKeyboardDispatcher, _document: Document, _location: Location, _outsideClickDispatcher: OverlayOutsideClickDispatcher, _animationsDisabled: boolean | undefined, _injector: EnvironmentInjector, _renderer: Renderer2);
  129. /** The overlay's HTML element */
  130. get overlayElement(): HTMLElement;
  131. /** The overlay's backdrop HTML element. */
  132. get backdropElement(): HTMLElement | null;
  133. /**
  134. * Wrapper around the panel element. Can be used for advanced
  135. * positioning where a wrapper with specific styling is
  136. * required around the overlay pane.
  137. */
  138. get hostElement(): HTMLElement;
  139. attach<T>(portal: ComponentPortal<T>): ComponentRef<T>;
  140. attach<T>(portal: TemplatePortal<T>): EmbeddedViewRef<T>;
  141. attach(portal: any): any;
  142. /**
  143. * Detaches an overlay from a portal.
  144. * @returns The portal detachment result.
  145. */
  146. detach(): any;
  147. /** Cleans up the overlay from the DOM. */
  148. dispose(): void;
  149. /** Whether the overlay has attached content. */
  150. hasAttached(): boolean;
  151. /** Gets an observable that emits when the backdrop has been clicked. */
  152. backdropClick(): Observable<MouseEvent>;
  153. /** Gets an observable that emits when the overlay has been attached. */
  154. attachments(): Observable<void>;
  155. /** Gets an observable that emits when the overlay has been detached. */
  156. detachments(): Observable<void>;
  157. /** Gets an observable of keydown events targeted to this overlay. */
  158. keydownEvents(): Observable<KeyboardEvent>;
  159. /** Gets an observable of pointer events targeted outside this overlay. */
  160. outsidePointerEvents(): Observable<MouseEvent>;
  161. /** Gets the current overlay configuration, which is immutable. */
  162. getConfig(): OverlayConfig;
  163. /** Updates the position of the overlay based on the position strategy. */
  164. updatePosition(): void;
  165. /** Switches to a new position strategy and updates the overlay position. */
  166. updatePositionStrategy(strategy: PositionStrategy): void;
  167. /** Update the size properties of the overlay. */
  168. updateSize(sizeConfig: OverlaySizeConfig): void;
  169. /** Sets the LTR/RTL direction for the overlay. */
  170. setDirection(dir: Direction | Directionality): void;
  171. /** Add a CSS class or an array of classes to the overlay pane. */
  172. addPanelClass(classes: string | string[]): void;
  173. /** Remove a CSS class or an array of classes from the overlay pane. */
  174. removePanelClass(classes: string | string[]): void;
  175. /**
  176. * Returns the layout direction of the overlay panel.
  177. */
  178. getDirection(): Direction;
  179. /** Switches to a new scroll strategy. */
  180. updateScrollStrategy(strategy: ScrollStrategy): void;
  181. /** Updates the text direction of the overlay panel. */
  182. private _updateElementDirection;
  183. /** Updates the size of the overlay element based on the overlay config. */
  184. private _updateElementSize;
  185. /** Toggles the pointer events for the overlay pane element. */
  186. private _togglePointerEvents;
  187. /** Attaches a backdrop for this overlay. */
  188. private _attachBackdrop;
  189. /**
  190. * Updates the stacking order of the element, moving it to the top if necessary.
  191. * This is required in cases where one overlay was detached, while another one,
  192. * that should be behind it, was destroyed. The next time both of them are opened,
  193. * the stacking will be wrong, because the detached element's pane will still be
  194. * in its original DOM position.
  195. */
  196. private _updateStackingOrder;
  197. /** Detaches the backdrop (if any) associated with the overlay. */
  198. detachBackdrop(): void;
  199. /** Toggles a single CSS class or an array of classes on an element. */
  200. private _toggleClasses;
  201. /** Detaches the overlay content next time the zone stabilizes. */
  202. private _detachContentWhenEmpty;
  203. /** Disposes of a scroll strategy. */
  204. private _disposeScrollStrategy;
  205. }
  206. /** Size properties for an overlay. */
  207. interface OverlaySizeConfig {
  208. width?: number | string;
  209. height?: number | string;
  210. minWidth?: number | string;
  211. minHeight?: number | string;
  212. maxWidth?: number | string;
  213. maxHeight?: number | string;
  214. }
  215. /** Strategy for setting the position on an overlay. */
  216. interface PositionStrategy {
  217. /** Attaches this position strategy to an overlay. */
  218. attach(overlayRef: OverlayRef): void;
  219. /** Updates the position of the overlay element. */
  220. apply(): void;
  221. /** Called when the overlay is detached. */
  222. detach?(): void;
  223. /** Cleans up any DOM modifications made by the position strategy, if necessary. */
  224. dispose(): void;
  225. }
  226. /** Initial configuration used when creating an overlay. */
  227. declare class OverlayConfig {
  228. /** Strategy with which to position the overlay. */
  229. positionStrategy?: PositionStrategy;
  230. /** Strategy to be used when handling scroll events while the overlay is open. */
  231. scrollStrategy?: ScrollStrategy;
  232. /** Custom class to add to the overlay pane. */
  233. panelClass?: string | string[];
  234. /** Whether the overlay has a backdrop. */
  235. hasBackdrop?: boolean;
  236. /** Custom class to add to the backdrop */
  237. backdropClass?: string | string[];
  238. /** The width of the overlay panel. If a number is provided, pixel units are assumed. */
  239. width?: number | string;
  240. /** The height of the overlay panel. If a number is provided, pixel units are assumed. */
  241. height?: number | string;
  242. /** The min-width of the overlay panel. If a number is provided, pixel units are assumed. */
  243. minWidth?: number | string;
  244. /** The min-height of the overlay panel. If a number is provided, pixel units are assumed. */
  245. minHeight?: number | string;
  246. /** The max-width of the overlay panel. If a number is provided, pixel units are assumed. */
  247. maxWidth?: number | string;
  248. /** The max-height of the overlay panel. If a number is provided, pixel units are assumed. */
  249. maxHeight?: number | string;
  250. /**
  251. * Direction of the text in the overlay panel. If a `Directionality` instance
  252. * is passed in, the overlay will handle changes to its value automatically.
  253. */
  254. direction?: Direction | Directionality;
  255. /**
  256. * Whether the overlay should be disposed of when the user goes backwards/forwards in history.
  257. * Note that this usually doesn't include clicking on links (unless the user is using
  258. * the `HashLocationStrategy`).
  259. */
  260. disposeOnNavigation?: boolean;
  261. constructor(config?: OverlayConfig);
  262. }
  263. /** Horizontal dimension of a connection point on the perimeter of the origin or overlay element. */
  264. type HorizontalConnectionPos = 'start' | 'center' | 'end';
  265. /** Vertical dimension of a connection point on the perimeter of the origin or overlay element. */
  266. type VerticalConnectionPos = 'top' | 'center' | 'bottom';
  267. /** A connection point on the origin element. */
  268. interface OriginConnectionPosition {
  269. originX: HorizontalConnectionPos;
  270. originY: VerticalConnectionPos;
  271. }
  272. /** A connection point on the overlay element. */
  273. interface OverlayConnectionPosition {
  274. overlayX: HorizontalConnectionPos;
  275. overlayY: VerticalConnectionPos;
  276. }
  277. /** The points of the origin element and the overlay element to connect. */
  278. declare class ConnectionPositionPair {
  279. /** Offset along the X axis. */
  280. offsetX?: number | undefined;
  281. /** Offset along the Y axis. */
  282. offsetY?: number | undefined;
  283. /** Class(es) to be applied to the panel while this position is active. */
  284. panelClass?: string | string[] | undefined;
  285. /** X-axis attachment point for connected overlay origin. Can be 'start', 'end', or 'center'. */
  286. originX: HorizontalConnectionPos;
  287. /** Y-axis attachment point for connected overlay origin. Can be 'top', 'bottom', or 'center'. */
  288. originY: VerticalConnectionPos;
  289. /** X-axis attachment point for connected overlay. Can be 'start', 'end', or 'center'. */
  290. overlayX: HorizontalConnectionPos;
  291. /** Y-axis attachment point for connected overlay. Can be 'top', 'bottom', or 'center'. */
  292. overlayY: VerticalConnectionPos;
  293. constructor(origin: OriginConnectionPosition, overlay: OverlayConnectionPosition,
  294. /** Offset along the X axis. */
  295. offsetX?: number | undefined,
  296. /** Offset along the Y axis. */
  297. offsetY?: number | undefined,
  298. /** Class(es) to be applied to the panel while this position is active. */
  299. panelClass?: string | string[] | undefined);
  300. }
  301. /**
  302. * Set of properties regarding the position of the origin and overlay relative to the viewport
  303. * with respect to the containing Scrollable elements.
  304. *
  305. * The overlay and origin are clipped if any part of their bounding client rectangle exceeds the
  306. * bounds of any one of the strategy's Scrollable's bounding client rectangle.
  307. *
  308. * The overlay and origin are outside view if there is no overlap between their bounding client
  309. * rectangle and any one of the strategy's Scrollable's bounding client rectangle.
  310. *
  311. * ----------- -----------
  312. * | outside | | clipped |
  313. * | view | --------------------------
  314. * | | | | | |
  315. * ---------- | ----------- |
  316. * -------------------------- | |
  317. * | | | Scrollable |
  318. * | | | |
  319. * | | --------------------------
  320. * | Scrollable |
  321. * | |
  322. * --------------------------
  323. *
  324. * @docs-private
  325. */
  326. declare class ScrollingVisibility {
  327. isOriginClipped: boolean;
  328. isOriginOutsideView: boolean;
  329. isOverlayClipped: boolean;
  330. isOverlayOutsideView: boolean;
  331. }
  332. /** The change event emitted by the strategy when a fallback position is used. */
  333. declare class ConnectedOverlayPositionChange {
  334. /** The position used as a result of this change. */
  335. connectionPair: ConnectionPositionPair;
  336. /** @docs-private */
  337. scrollableViewProperties: ScrollingVisibility;
  338. constructor(
  339. /** The position used as a result of this change. */
  340. connectionPair: ConnectionPositionPair,
  341. /** @docs-private */
  342. scrollableViewProperties: ScrollingVisibility);
  343. }
  344. /**
  345. * Validates whether a vertical position property matches the expected values.
  346. * @param property Name of the property being validated.
  347. * @param value Value of the property being validated.
  348. * @docs-private
  349. */
  350. declare function validateVerticalPosition(property: string, value: VerticalConnectionPos): void;
  351. /**
  352. * Validates whether a horizontal position property matches the expected values.
  353. * @param property Name of the property being validated.
  354. * @param value Value of the property being validated.
  355. * @docs-private
  356. */
  357. declare function validateHorizontalPosition(property: string, value: HorizontalConnectionPos): void;
  358. /** Container inside which all overlays will render. */
  359. declare class OverlayContainer implements OnDestroy {
  360. protected _platform: Platform;
  361. protected _containerElement: HTMLElement;
  362. protected _document: Document;
  363. protected _styleLoader: _CdkPrivateStyleLoader;
  364. constructor(...args: unknown[]);
  365. ngOnDestroy(): void;
  366. /**
  367. * This method returns the overlay container element. It will lazily
  368. * create the element the first time it is called to facilitate using
  369. * the container in non-browser environments.
  370. * @returns the container element
  371. */
  372. getContainerElement(): HTMLElement;
  373. /**
  374. * Create the overlay container element, which is simply a div
  375. * with the 'cdk-overlay-container' class on the document body.
  376. */
  377. protected _createContainer(): void;
  378. /** Loads the structural styles necessary for the overlay to work. */
  379. protected _loadStyles(): void;
  380. static ɵfac: i0.ɵɵFactoryDeclaration<OverlayContainer, never>;
  381. static ɵprov: i0.ɵɵInjectableDeclaration<OverlayContainer>;
  382. }
  383. /** Possible values that can be set as the origin of a FlexibleConnectedPositionStrategy. */
  384. type FlexibleConnectedPositionStrategyOrigin = ElementRef | Element | (Point & {
  385. width?: number;
  386. height?: number;
  387. });
  388. /**
  389. * A strategy for positioning overlays. Using this strategy, an overlay is given an
  390. * implicit position relative some origin element. The relative position is defined in terms of
  391. * a point on the origin element that is connected to a point on the overlay element. For example,
  392. * a basic dropdown is connecting the bottom-left corner of the origin to the top-left corner
  393. * of the overlay.
  394. */
  395. declare class FlexibleConnectedPositionStrategy implements PositionStrategy {
  396. private _viewportRuler;
  397. private _document;
  398. private _platform;
  399. private _overlayContainer;
  400. /** The overlay to which this strategy is attached. */
  401. private _overlayRef;
  402. /** Whether we're performing the very first positioning of the overlay. */
  403. private _isInitialRender;
  404. /** Last size used for the bounding box. Used to avoid resizing the overlay after open. */
  405. private _lastBoundingBoxSize;
  406. /** Whether the overlay was pushed in a previous positioning. */
  407. private _isPushed;
  408. /** Whether the overlay can be pushed on-screen on the initial open. */
  409. private _canPush;
  410. /** Whether the overlay can grow via flexible width/height after the initial open. */
  411. private _growAfterOpen;
  412. /** Whether the overlay's width and height can be constrained to fit within the viewport. */
  413. private _hasFlexibleDimensions;
  414. /** Whether the overlay position is locked. */
  415. private _positionLocked;
  416. /** Cached origin dimensions */
  417. private _originRect;
  418. /** Cached overlay dimensions */
  419. private _overlayRect;
  420. /** Cached viewport dimensions */
  421. private _viewportRect;
  422. /** Cached container dimensions */
  423. private _containerRect;
  424. /** Amount of space that must be maintained between the overlay and the edge of the viewport. */
  425. private _viewportMargin;
  426. /** The Scrollable containers used to check scrollable view properties on position change. */
  427. private _scrollables;
  428. /** Ordered list of preferred positions, from most to least desirable. */
  429. _preferredPositions: ConnectionPositionPair[];
  430. /** The origin element against which the overlay will be positioned. */
  431. _origin: FlexibleConnectedPositionStrategyOrigin;
  432. /** The overlay pane element. */
  433. private _pane;
  434. /** Whether the strategy has been disposed of already. */
  435. private _isDisposed;
  436. /**
  437. * Parent element for the overlay panel used to constrain the overlay panel's size to fit
  438. * within the viewport.
  439. */
  440. private _boundingBox;
  441. /** The last position to have been calculated as the best fit position. */
  442. private _lastPosition;
  443. /** The last calculated scroll visibility. Only tracked */
  444. private _lastScrollVisibility;
  445. /** Subject that emits whenever the position changes. */
  446. private readonly _positionChanges;
  447. /** Subscription to viewport size changes. */
  448. private _resizeSubscription;
  449. /** Default offset for the overlay along the x axis. */
  450. private _offsetX;
  451. /** Default offset for the overlay along the y axis. */
  452. private _offsetY;
  453. /** Selector to be used when finding the elements on which to set the transform origin. */
  454. private _transformOriginSelector;
  455. /** Keeps track of the CSS classes that the position strategy has applied on the overlay panel. */
  456. private _appliedPanelClasses;
  457. /** Amount by which the overlay was pushed in each axis during the last time it was positioned. */
  458. private _previousPushAmount;
  459. /** Observable sequence of position changes. */
  460. positionChanges: Observable<ConnectedOverlayPositionChange>;
  461. /** Ordered list of preferred positions, from most to least desirable. */
  462. get positions(): ConnectionPositionPair[];
  463. constructor(connectedTo: FlexibleConnectedPositionStrategyOrigin, _viewportRuler: ViewportRuler, _document: Document, _platform: Platform, _overlayContainer: OverlayContainer);
  464. /** Attaches this position strategy to an overlay. */
  465. attach(overlayRef: OverlayRef): void;
  466. /**
  467. * Updates the position of the overlay element, using whichever preferred position relative
  468. * to the origin best fits on-screen.
  469. *
  470. * The selection of a position goes as follows:
  471. * - If any positions fit completely within the viewport as-is,
  472. * choose the first position that does so.
  473. * - If flexible dimensions are enabled and at least one satisfies the given minimum width/height,
  474. * choose the position with the greatest available size modified by the positions' weight.
  475. * - If pushing is enabled, take the position that went off-screen the least and push it
  476. * on-screen.
  477. * - If none of the previous criteria were met, use the position that goes off-screen the least.
  478. * @docs-private
  479. */
  480. apply(): void;
  481. detach(): void;
  482. /** Cleanup after the element gets destroyed. */
  483. dispose(): void;
  484. /**
  485. * This re-aligns the overlay element with the trigger in its last calculated position,
  486. * even if a position higher in the "preferred positions" list would now fit. This
  487. * allows one to re-align the panel without changing the orientation of the panel.
  488. */
  489. reapplyLastPosition(): void;
  490. /**
  491. * Sets the list of Scrollable containers that host the origin element so that
  492. * on reposition we can evaluate if it or the overlay has been clipped or outside view. Every
  493. * Scrollable must be an ancestor element of the strategy's origin element.
  494. */
  495. withScrollableContainers(scrollables: CdkScrollable[]): this;
  496. /**
  497. * Adds new preferred positions.
  498. * @param positions List of positions options for this overlay.
  499. */
  500. withPositions(positions: ConnectedPosition[]): this;
  501. /**
  502. * Sets a minimum distance the overlay may be positioned to the edge of the viewport.
  503. * @param margin Required margin between the overlay and the viewport edge in pixels.
  504. */
  505. withViewportMargin(margin: number): this;
  506. /** Sets whether the overlay's width and height can be constrained to fit within the viewport. */
  507. withFlexibleDimensions(flexibleDimensions?: boolean): this;
  508. /** Sets whether the overlay can grow after the initial open via flexible width/height. */
  509. withGrowAfterOpen(growAfterOpen?: boolean): this;
  510. /** Sets whether the overlay can be pushed on-screen if none of the provided positions fit. */
  511. withPush(canPush?: boolean): this;
  512. /**
  513. * Sets whether the overlay's position should be locked in after it is positioned
  514. * initially. When an overlay is locked in, it won't attempt to reposition itself
  515. * when the position is re-applied (e.g. when the user scrolls away).
  516. * @param isLocked Whether the overlay should locked in.
  517. */
  518. withLockedPosition(isLocked?: boolean): this;
  519. /**
  520. * Sets the origin, relative to which to position the overlay.
  521. * Using an element origin is useful for building components that need to be positioned
  522. * relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be
  523. * used for cases like contextual menus which open relative to the user's pointer.
  524. * @param origin Reference to the new origin.
  525. */
  526. setOrigin(origin: FlexibleConnectedPositionStrategyOrigin): this;
  527. /**
  528. * Sets the default offset for the overlay's connection point on the x-axis.
  529. * @param offset New offset in the X axis.
  530. */
  531. withDefaultOffsetX(offset: number): this;
  532. /**
  533. * Sets the default offset for the overlay's connection point on the y-axis.
  534. * @param offset New offset in the Y axis.
  535. */
  536. withDefaultOffsetY(offset: number): this;
  537. /**
  538. * Configures that the position strategy should set a `transform-origin` on some elements
  539. * inside the overlay, depending on the current position that is being applied. This is
  540. * useful for the cases where the origin of an animation can change depending on the
  541. * alignment of the overlay.
  542. * @param selector CSS selector that will be used to find the target
  543. * elements onto which to set the transform origin.
  544. */
  545. withTransformOriginOn(selector: string): this;
  546. /**
  547. * Gets the (x, y) coordinate of a connection point on the origin based on a relative position.
  548. */
  549. private _getOriginPoint;
  550. /**
  551. * Gets the (x, y) coordinate of the top-left corner of the overlay given a given position and
  552. * origin point to which the overlay should be connected.
  553. */
  554. private _getOverlayPoint;
  555. /** Gets how well an overlay at the given point will fit within the viewport. */
  556. private _getOverlayFit;
  557. /**
  558. * Whether the overlay can fit within the viewport when it may resize either its width or height.
  559. * @param fit How well the overlay fits in the viewport at some position.
  560. * @param point The (x, y) coordinates of the overlay at some position.
  561. * @param viewport The geometry of the viewport.
  562. */
  563. private _canFitWithFlexibleDimensions;
  564. /**
  565. * Gets the point at which the overlay can be "pushed" on-screen. If the overlay is larger than
  566. * the viewport, the top-left corner will be pushed on-screen (with overflow occurring on the
  567. * right and bottom).
  568. *
  569. * @param start Starting point from which the overlay is pushed.
  570. * @param rawOverlayRect Dimensions of the overlay.
  571. * @param scrollPosition Current viewport scroll position.
  572. * @returns The point at which to position the overlay after pushing. This is effectively a new
  573. * originPoint.
  574. */
  575. private _pushOverlayOnScreen;
  576. /**
  577. * Applies a computed position to the overlay and emits a position change.
  578. * @param position The position preference
  579. * @param originPoint The point on the origin element where the overlay is connected.
  580. */
  581. private _applyPosition;
  582. /** Sets the transform origin based on the configured selector and the passed-in position. */
  583. private _setTransformOrigin;
  584. /**
  585. * Gets the position and size of the overlay's sizing container.
  586. *
  587. * This method does no measuring and applies no styles so that we can cheaply compute the
  588. * bounds for all positions and choose the best fit based on these results.
  589. */
  590. private _calculateBoundingBoxRect;
  591. /**
  592. * Sets the position and size of the overlay's sizing wrapper. The wrapper is positioned on the
  593. * origin's connection point and stretches to the bounds of the viewport.
  594. *
  595. * @param origin The point on the origin element where the overlay is connected.
  596. * @param position The position preference
  597. */
  598. private _setBoundingBoxStyles;
  599. /** Resets the styles for the bounding box so that a new positioning can be computed. */
  600. private _resetBoundingBoxStyles;
  601. /** Resets the styles for the overlay pane so that a new positioning can be computed. */
  602. private _resetOverlayElementStyles;
  603. /** Sets positioning styles to the overlay element. */
  604. private _setOverlayElementStyles;
  605. /** Gets the exact top/bottom for the overlay when not using flexible sizing or when pushing. */
  606. private _getExactOverlayY;
  607. /** Gets the exact left/right for the overlay when not using flexible sizing or when pushing. */
  608. private _getExactOverlayX;
  609. /**
  610. * Gets the view properties of the trigger and overlay, including whether they are clipped
  611. * or completely outside the view of any of the strategy's scrollables.
  612. */
  613. private _getScrollVisibility;
  614. /** Subtracts the amount that an element is overflowing on an axis from its length. */
  615. private _subtractOverflows;
  616. /** Narrows the given viewport rect by the current _viewportMargin. */
  617. private _getNarrowedViewportRect;
  618. /** Whether the we're dealing with an RTL context */
  619. private _isRtl;
  620. /** Determines whether the overlay uses exact or flexible positioning. */
  621. private _hasExactPosition;
  622. /** Retrieves the offset of a position along the x or y axis. */
  623. private _getOffset;
  624. /** Validates that the current position match the expected values. */
  625. private _validatePositions;
  626. /** Adds a single CSS class or an array of classes on the overlay panel. */
  627. private _addPanelClasses;
  628. /** Clears the classes that the position strategy has applied from the overlay panel. */
  629. private _clearPanelClasses;
  630. /** Returns the DOMRect of the current origin. */
  631. private _getOriginRect;
  632. }
  633. /** A simple (x, y) coordinate. */
  634. interface Point {
  635. x: number;
  636. y: number;
  637. }
  638. /** A connected position as specified by the user. */
  639. interface ConnectedPosition {
  640. originX: 'start' | 'center' | 'end';
  641. originY: 'top' | 'center' | 'bottom';
  642. overlayX: 'start' | 'center' | 'end';
  643. overlayY: 'top' | 'center' | 'bottom';
  644. weight?: number;
  645. offsetX?: number;
  646. offsetY?: number;
  647. panelClass?: string | string[];
  648. }
  649. declare const STANDARD_DROPDOWN_BELOW_POSITIONS: ConnectedPosition[];
  650. declare const STANDARD_DROPDOWN_ADJACENT_POSITIONS: ConnectedPosition[];
  651. /**
  652. * Directive applied to an element to make it usable as an origin for an Overlay using a
  653. * ConnectedPositionStrategy.
  654. */
  655. declare class CdkOverlayOrigin {
  656. elementRef: ElementRef<any>;
  657. constructor(...args: unknown[]);
  658. static ɵfac: i0.ɵɵFactoryDeclaration<CdkOverlayOrigin, never>;
  659. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkOverlayOrigin, "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", ["cdkOverlayOrigin"], {}, {}, never, never, true, never>;
  660. }
  661. /**
  662. * Directive to facilitate declarative creation of an
  663. * Overlay using a FlexibleConnectedPositionStrategy.
  664. */
  665. declare class CdkConnectedOverlay implements OnDestroy, OnChanges {
  666. private _overlay;
  667. private _dir;
  668. private _overlayRef;
  669. private _templatePortal;
  670. private _backdropSubscription;
  671. private _attachSubscription;
  672. private _detachSubscription;
  673. private _positionSubscription;
  674. private _offsetX;
  675. private _offsetY;
  676. private _position;
  677. private _scrollStrategyFactory;
  678. private _disposeOnNavigation;
  679. private _ngZone;
  680. /** Origin for the connected overlay. */
  681. origin: CdkOverlayOrigin | FlexibleConnectedPositionStrategyOrigin;
  682. /** Registered connected position pairs. */
  683. positions: ConnectedPosition[];
  684. /**
  685. * This input overrides the positions input if specified. It lets users pass
  686. * in arbitrary positioning strategies.
  687. */
  688. positionStrategy: FlexibleConnectedPositionStrategy;
  689. /** The offset in pixels for the overlay connection point on the x-axis */
  690. get offsetX(): number;
  691. set offsetX(offsetX: number);
  692. /** The offset in pixels for the overlay connection point on the y-axis */
  693. get offsetY(): number;
  694. set offsetY(offsetY: number);
  695. /** The width of the overlay panel. */
  696. width: number | string;
  697. /** The height of the overlay panel. */
  698. height: number | string;
  699. /** The min width of the overlay panel. */
  700. minWidth: number | string;
  701. /** The min height of the overlay panel. */
  702. minHeight: number | string;
  703. /** The custom class to be set on the backdrop element. */
  704. backdropClass: string | string[];
  705. /** The custom class to add to the overlay pane element. */
  706. panelClass: string | string[];
  707. /** Margin between the overlay and the viewport edges. */
  708. viewportMargin: number;
  709. /** Strategy to be used when handling scroll events while the overlay is open. */
  710. scrollStrategy: ScrollStrategy;
  711. /** Whether the overlay is open. */
  712. open: boolean;
  713. /** Whether the overlay can be closed by user interaction. */
  714. disableClose: boolean;
  715. /** CSS selector which to set the transform origin. */
  716. transformOriginSelector: string;
  717. /** Whether or not the overlay should attach a backdrop. */
  718. hasBackdrop: boolean;
  719. /** Whether or not the overlay should be locked when scrolling. */
  720. lockPosition: boolean;
  721. /** Whether the overlay's width and height can be constrained to fit within the viewport. */
  722. flexibleDimensions: boolean;
  723. /** Whether the overlay can grow after the initial open when flexible positioning is turned on. */
  724. growAfterOpen: boolean;
  725. /** Whether the overlay can be pushed on-screen if none of the provided positions fit. */
  726. push: boolean;
  727. /** Whether the overlay should be disposed of when the user goes backwards/forwards in history. */
  728. get disposeOnNavigation(): boolean;
  729. set disposeOnNavigation(value: boolean);
  730. /** Event emitted when the backdrop is clicked. */
  731. readonly backdropClick: EventEmitter<MouseEvent>;
  732. /** Event emitted when the position has changed. */
  733. readonly positionChange: EventEmitter<ConnectedOverlayPositionChange>;
  734. /** Event emitted when the overlay has been attached. */
  735. readonly attach: EventEmitter<void>;
  736. /** Event emitted when the overlay has been detached. */
  737. readonly detach: EventEmitter<void>;
  738. /** Emits when there are keyboard events that are targeted at the overlay. */
  739. readonly overlayKeydown: EventEmitter<KeyboardEvent>;
  740. /** Emits when there are mouse outside click events that are targeted at the overlay. */
  741. readonly overlayOutsideClick: EventEmitter<MouseEvent>;
  742. constructor(...args: unknown[]);
  743. /** The associated overlay reference. */
  744. get overlayRef(): OverlayRef;
  745. /** The element's layout direction. */
  746. get dir(): Direction;
  747. ngOnDestroy(): void;
  748. ngOnChanges(changes: SimpleChanges): void;
  749. /** Creates an overlay */
  750. private _createOverlay;
  751. /** Builds the overlay config based on the directive's inputs */
  752. private _buildConfig;
  753. /** Updates the state of a position strategy, based on the values of the directive inputs. */
  754. private _updatePositionStrategy;
  755. /** Returns the position strategy of the overlay to be set on the overlay config */
  756. private _createPositionStrategy;
  757. private _getOrigin;
  758. private _getOriginElement;
  759. /** Attaches the overlay. */
  760. attachOverlay(): void;
  761. /** Detaches the overlay. */
  762. detachOverlay(): void;
  763. static ɵfac: i0.ɵɵFactoryDeclaration<CdkConnectedOverlay, never>;
  764. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkConnectedOverlay, "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", ["cdkConnectedOverlay"], { "origin": { "alias": "cdkConnectedOverlayOrigin"; "required": false; }; "positions": { "alias": "cdkConnectedOverlayPositions"; "required": false; }; "positionStrategy": { "alias": "cdkConnectedOverlayPositionStrategy"; "required": false; }; "offsetX": { "alias": "cdkConnectedOverlayOffsetX"; "required": false; }; "offsetY": { "alias": "cdkConnectedOverlayOffsetY"; "required": false; }; "width": { "alias": "cdkConnectedOverlayWidth"; "required": false; }; "height": { "alias": "cdkConnectedOverlayHeight"; "required": false; }; "minWidth": { "alias": "cdkConnectedOverlayMinWidth"; "required": false; }; "minHeight": { "alias": "cdkConnectedOverlayMinHeight"; "required": false; }; "backdropClass": { "alias": "cdkConnectedOverlayBackdropClass"; "required": false; }; "panelClass": { "alias": "cdkConnectedOverlayPanelClass"; "required": false; }; "viewportMargin": { "alias": "cdkConnectedOverlayViewportMargin"; "required": false; }; "scrollStrategy": { "alias": "cdkConnectedOverlayScrollStrategy"; "required": false; }; "open": { "alias": "cdkConnectedOverlayOpen"; "required": false; }; "disableClose": { "alias": "cdkConnectedOverlayDisableClose"; "required": false; }; "transformOriginSelector": { "alias": "cdkConnectedOverlayTransformOriginOn"; "required": false; }; "hasBackdrop": { "alias": "cdkConnectedOverlayHasBackdrop"; "required": false; }; "lockPosition": { "alias": "cdkConnectedOverlayLockPosition"; "required": false; }; "flexibleDimensions": { "alias": "cdkConnectedOverlayFlexibleDimensions"; "required": false; }; "growAfterOpen": { "alias": "cdkConnectedOverlayGrowAfterOpen"; "required": false; }; "push": { "alias": "cdkConnectedOverlayPush"; "required": false; }; "disposeOnNavigation": { "alias": "cdkConnectedOverlayDisposeOnNavigation"; "required": false; }; }, { "backdropClick": "backdropClick"; "positionChange": "positionChange"; "attach": "attach"; "detach": "detach"; "overlayKeydown": "overlayKeydown"; "overlayOutsideClick": "overlayOutsideClick"; }, never, never, true, never>;
  765. static ngAcceptInputType_hasBackdrop: unknown;
  766. static ngAcceptInputType_lockPosition: unknown;
  767. static ngAcceptInputType_flexibleDimensions: unknown;
  768. static ngAcceptInputType_growAfterOpen: unknown;
  769. static ngAcceptInputType_push: unknown;
  770. static ngAcceptInputType_disposeOnNavigation: unknown;
  771. }
  772. declare class OverlayModule {
  773. static ɵfac: i0.ɵɵFactoryDeclaration<OverlayModule, never>;
  774. static ɵmod: i0.ɵɵNgModuleDeclaration<OverlayModule, never, [typeof BidiModule, typeof PortalModule, typeof ScrollingModule, typeof CdkConnectedOverlay, typeof CdkOverlayOrigin], [typeof CdkConnectedOverlay, typeof CdkOverlayOrigin, typeof ScrollingModule]>;
  775. static ɵinj: i0.ɵɵInjectorDeclaration<OverlayModule>;
  776. }
  777. export { CdkOverlayOrigin as C, FlexibleConnectedPositionStrategy as F, OverlayContainer as O, STANDARD_DROPDOWN_ADJACENT_POSITIONS as S, CdkConnectedOverlay as a, OverlayRef as b, STANDARD_DROPDOWN_BELOW_POSITIONS as f, OverlayConfig as g, ConnectionPositionPair as j, ScrollingVisibility as k, ConnectedOverlayPositionChange as l, validateHorizontalPosition as m, OverlayModule as o, OverlayOutsideClickDispatcher as p, OverlayKeyboardDispatcher as q, validateVerticalPosition as v };
  778. export type { HorizontalConnectionPos as H, PositionStrategy as P, VerticalConnectionPos as V, OverlaySizeConfig as c, ConnectedPosition as d, FlexibleConnectedPositionStrategyOrigin as e, OriginConnectionPosition as h, OverlayConnectionPosition as i, ScrollStrategy as n };