overlay-directives.d.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 { Direction, Directionality } from '@angular/cdk/bidi';
  9. import { ElementRef, EventEmitter, InjectionToken, OnChanges, OnDestroy, SimpleChanges, TemplateRef, ViewContainerRef } from '@angular/core';
  10. import { Overlay } from './overlay';
  11. import { OverlayRef } from './overlay-ref';
  12. import { ConnectedOverlayPositionChange } from './position/connected-position';
  13. import { ConnectedPosition } from './position/flexible-connected-position-strategy';
  14. import { RepositionScrollStrategy, ScrollStrategy } from './scroll/index';
  15. /** Injection token that determines the scroll handling while the connected overlay is open. */
  16. export declare const CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
  17. /** @docs-private @deprecated @breaking-change 8.0.0 */
  18. export declare function CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
  19. /**
  20. * Directive applied to an element to make it usable as an origin for an Overlay using a
  21. * ConnectedPositionStrategy.
  22. */
  23. export declare class CdkOverlayOrigin {
  24. /** Reference to the element on which the directive is applied. */
  25. elementRef: ElementRef;
  26. constructor(
  27. /** Reference to the element on which the directive is applied. */
  28. elementRef: ElementRef);
  29. }
  30. /**
  31. * Directive to facilitate declarative creation of an
  32. * Overlay using a FlexibleConnectedPositionStrategy.
  33. */
  34. export declare class CdkConnectedOverlay implements OnDestroy, OnChanges {
  35. private _overlay;
  36. private _dir;
  37. private _overlayRef;
  38. private _templatePortal;
  39. private _hasBackdrop;
  40. private _lockPosition;
  41. private _growAfterOpen;
  42. private _flexibleDimensions;
  43. private _push;
  44. private _backdropSubscription;
  45. private _offsetX;
  46. private _offsetY;
  47. private _position;
  48. private _scrollStrategyFactory;
  49. /** Origin for the connected overlay. */
  50. origin: CdkOverlayOrigin;
  51. /** Registered connected position pairs. */
  52. positions: ConnectedPosition[];
  53. /** The offset in pixels for the overlay connection point on the x-axis */
  54. offsetX: number;
  55. /** The offset in pixels for the overlay connection point on the y-axis */
  56. offsetY: number;
  57. /** The width of the overlay panel. */
  58. width: number | string;
  59. /** The height of the overlay panel. */
  60. height: number | string;
  61. /** The min width of the overlay panel. */
  62. minWidth: number | string;
  63. /** The min height of the overlay panel. */
  64. minHeight: number | string;
  65. /** The custom class to be set on the backdrop element. */
  66. backdropClass: string;
  67. /** The custom class to add to the overlay pane element. */
  68. panelClass: string | string[];
  69. /** Margin between the overlay and the viewport edges. */
  70. viewportMargin: number;
  71. /** Strategy to be used when handling scroll events while the overlay is open. */
  72. scrollStrategy: ScrollStrategy;
  73. /** Whether the overlay is open. */
  74. open: boolean;
  75. /** Whether or not the overlay should attach a backdrop. */
  76. hasBackdrop: any;
  77. /** Whether or not the overlay should be locked when scrolling. */
  78. lockPosition: any;
  79. /** Whether the overlay's width and height can be constrained to fit within the viewport. */
  80. flexibleDimensions: boolean;
  81. /** Whether the overlay can grow after the initial open when flexible positioning is turned on. */
  82. growAfterOpen: boolean;
  83. /** Whether the overlay can be pushed on-screen if none of the provided positions fit. */
  84. push: boolean;
  85. /** Event emitted when the backdrop is clicked. */
  86. backdropClick: EventEmitter<MouseEvent>;
  87. /** Event emitted when the position has changed. */
  88. positionChange: EventEmitter<ConnectedOverlayPositionChange>;
  89. /** Event emitted when the overlay has been attached. */
  90. attach: EventEmitter<void>;
  91. /** Event emitted when the overlay has been detached. */
  92. detach: EventEmitter<void>;
  93. /** Emits when there are keyboard events that are targeted at the overlay. */
  94. overlayKeydown: EventEmitter<KeyboardEvent>;
  95. constructor(_overlay: Overlay, templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef, scrollStrategyFactory: any, _dir: Directionality);
  96. /** The associated overlay reference. */
  97. readonly overlayRef: OverlayRef;
  98. /** The element's layout direction. */
  99. readonly dir: Direction;
  100. ngOnDestroy(): void;
  101. ngOnChanges(changes: SimpleChanges): void;
  102. /** Creates an overlay */
  103. private _createOverlay;
  104. /** Builds the overlay config based on the directive's inputs */
  105. private _buildConfig;
  106. /** Updates the state of a position strategy, based on the values of the directive inputs. */
  107. private _updatePositionStrategy;
  108. /** Returns the position strategy of the overlay to be set on the overlay config */
  109. private _createPositionStrategy;
  110. /** Attaches the overlay and subscribes to backdrop clicks if backdrop exists */
  111. private _attachOverlay;
  112. /** Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists */
  113. private _detachOverlay;
  114. }
  115. /** @docs-private */
  116. export declare function CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy;
  117. /** @docs-private */
  118. export declare const CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER: {
  119. provide: InjectionToken<() => ScrollStrategy>;
  120. deps: (typeof Overlay)[];
  121. useFactory: typeof CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY;
  122. };