[6a3a178] | 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 { ComponentPortal, PortalOutlet, TemplatePortal } from '@angular/cdk/portal';
|
---|
| 10 | import { ComponentRef, EmbeddedViewRef, NgZone } from '@angular/core';
|
---|
| 11 | import { Location } from '@angular/common';
|
---|
| 12 | import { Observable, Subject } from 'rxjs';
|
---|
| 13 | import { OverlayKeyboardDispatcher } from './dispatchers/overlay-keyboard-dispatcher';
|
---|
| 14 | import { OverlayOutsideClickDispatcher } from './dispatchers/overlay-outside-click-dispatcher';
|
---|
| 15 | import { OverlayConfig } from './overlay-config';
|
---|
| 16 | import { OverlayReference } from './overlay-reference';
|
---|
| 17 | import { PositionStrategy } from './position/position-strategy';
|
---|
| 18 | import { ScrollStrategy } from './scroll';
|
---|
| 19 | /** An object where all of its properties cannot be written. */
|
---|
| 20 | export declare type ImmutableObject<T> = {
|
---|
| 21 | readonly [P in keyof T]: T[P];
|
---|
| 22 | };
|
---|
| 23 | /**
|
---|
| 24 | * Reference to an overlay that has been created with the Overlay service.
|
---|
| 25 | * Used to manipulate or dispose of said overlay.
|
---|
| 26 | */
|
---|
| 27 | export declare class OverlayRef implements PortalOutlet, OverlayReference {
|
---|
| 28 | private _portalOutlet;
|
---|
| 29 | private _host;
|
---|
| 30 | private _pane;
|
---|
| 31 | private _config;
|
---|
| 32 | private _ngZone;
|
---|
| 33 | private _keyboardDispatcher;
|
---|
| 34 | private _document;
|
---|
| 35 | private _location;
|
---|
| 36 | private _outsideClickDispatcher;
|
---|
| 37 | private _backdropElement;
|
---|
| 38 | private readonly _backdropClick;
|
---|
| 39 | private readonly _attachments;
|
---|
| 40 | private readonly _detachments;
|
---|
| 41 | private _positionStrategy;
|
---|
| 42 | private _scrollStrategy;
|
---|
| 43 | private _locationChanges;
|
---|
| 44 | private _backdropClickHandler;
|
---|
| 45 | /**
|
---|
| 46 | * Reference to the parent of the `_host` at the time it was detached. Used to restore
|
---|
| 47 | * the `_host` to its original position in the DOM when it gets re-attached.
|
---|
| 48 | */
|
---|
| 49 | private _previousHostParent;
|
---|
| 50 | /** Stream of keydown events dispatched to this overlay. */
|
---|
| 51 | readonly _keydownEvents: Subject<KeyboardEvent>;
|
---|
| 52 | /** Stream of mouse outside events dispatched to this overlay. */
|
---|
| 53 | readonly _outsidePointerEvents: Subject<MouseEvent>;
|
---|
| 54 | constructor(_portalOutlet: PortalOutlet, _host: HTMLElement, _pane: HTMLElement, _config: ImmutableObject<OverlayConfig>, _ngZone: NgZone, _keyboardDispatcher: OverlayKeyboardDispatcher, _document: Document, _location: Location, _outsideClickDispatcher: OverlayOutsideClickDispatcher);
|
---|
| 55 | /** The overlay's HTML element */
|
---|
| 56 | get overlayElement(): HTMLElement;
|
---|
| 57 | /** The overlay's backdrop HTML element. */
|
---|
| 58 | get backdropElement(): HTMLElement | null;
|
---|
| 59 | /**
|
---|
| 60 | * Wrapper around the panel element. Can be used for advanced
|
---|
| 61 | * positioning where a wrapper with specific styling is
|
---|
| 62 | * required around the overlay pane.
|
---|
| 63 | */
|
---|
| 64 | get hostElement(): HTMLElement;
|
---|
| 65 | attach<T>(portal: ComponentPortal<T>): ComponentRef<T>;
|
---|
| 66 | attach<T>(portal: TemplatePortal<T>): EmbeddedViewRef<T>;
|
---|
| 67 | attach(portal: any): any;
|
---|
| 68 | /**
|
---|
| 69 | * Detaches an overlay from a portal.
|
---|
| 70 | * @returns The portal detachment result.
|
---|
| 71 | */
|
---|
| 72 | detach(): any;
|
---|
| 73 | /** Cleans up the overlay from the DOM. */
|
---|
| 74 | dispose(): void;
|
---|
| 75 | /** Whether the overlay has attached content. */
|
---|
| 76 | hasAttached(): boolean;
|
---|
| 77 | /** Gets an observable that emits when the backdrop has been clicked. */
|
---|
| 78 | backdropClick(): Observable<MouseEvent>;
|
---|
| 79 | /** Gets an observable that emits when the overlay has been attached. */
|
---|
| 80 | attachments(): Observable<void>;
|
---|
| 81 | /** Gets an observable that emits when the overlay has been detached. */
|
---|
| 82 | detachments(): Observable<void>;
|
---|
| 83 | /** Gets an observable of keydown events targeted to this overlay. */
|
---|
| 84 | keydownEvents(): Observable<KeyboardEvent>;
|
---|
| 85 | /** Gets an observable of pointer events targeted outside this overlay. */
|
---|
| 86 | outsidePointerEvents(): Observable<MouseEvent>;
|
---|
| 87 | /** Gets the current overlay configuration, which is immutable. */
|
---|
| 88 | getConfig(): OverlayConfig;
|
---|
| 89 | /** Updates the position of the overlay based on the position strategy. */
|
---|
| 90 | updatePosition(): void;
|
---|
| 91 | /** Switches to a new position strategy and updates the overlay position. */
|
---|
| 92 | updatePositionStrategy(strategy: PositionStrategy): void;
|
---|
| 93 | /** Update the size properties of the overlay. */
|
---|
| 94 | updateSize(sizeConfig: OverlaySizeConfig): void;
|
---|
| 95 | /** Sets the LTR/RTL direction for the overlay. */
|
---|
| 96 | setDirection(dir: Direction | Directionality): void;
|
---|
| 97 | /** Add a CSS class or an array of classes to the overlay pane. */
|
---|
| 98 | addPanelClass(classes: string | string[]): void;
|
---|
| 99 | /** Remove a CSS class or an array of classes from the overlay pane. */
|
---|
| 100 | removePanelClass(classes: string | string[]): void;
|
---|
| 101 | /**
|
---|
| 102 | * Returns the layout direction of the overlay panel.
|
---|
| 103 | */
|
---|
| 104 | getDirection(): Direction;
|
---|
| 105 | /** Switches to a new scroll strategy. */
|
---|
| 106 | updateScrollStrategy(strategy: ScrollStrategy): void;
|
---|
| 107 | /** Updates the text direction of the overlay panel. */
|
---|
| 108 | private _updateElementDirection;
|
---|
| 109 | /** Updates the size of the overlay element based on the overlay config. */
|
---|
| 110 | private _updateElementSize;
|
---|
| 111 | /** Toggles the pointer events for the overlay pane element. */
|
---|
| 112 | private _togglePointerEvents;
|
---|
| 113 | /** Attaches a backdrop for this overlay. */
|
---|
| 114 | private _attachBackdrop;
|
---|
| 115 | /**
|
---|
| 116 | * Updates the stacking order of the element, moving it to the top if necessary.
|
---|
| 117 | * This is required in cases where one overlay was detached, while another one,
|
---|
| 118 | * that should be behind it, was destroyed. The next time both of them are opened,
|
---|
| 119 | * the stacking will be wrong, because the detached element's pane will still be
|
---|
| 120 | * in its original DOM position.
|
---|
| 121 | */
|
---|
| 122 | private _updateStackingOrder;
|
---|
| 123 | /** Detaches the backdrop (if any) associated with the overlay. */
|
---|
| 124 | detachBackdrop(): void;
|
---|
| 125 | /** Toggles a single CSS class or an array of classes on an element. */
|
---|
| 126 | private _toggleClasses;
|
---|
| 127 | /** Detaches the overlay content next time the zone stabilizes. */
|
---|
| 128 | private _detachContentWhenStable;
|
---|
| 129 | /** Disposes of a scroll strategy. */
|
---|
| 130 | private _disposeScrollStrategy;
|
---|
| 131 | /** Removes a backdrop element from the DOM. */
|
---|
| 132 | private _disposeBackdrop;
|
---|
| 133 | }
|
---|
| 134 | /** Size properties for an overlay. */
|
---|
| 135 | export interface OverlaySizeConfig {
|
---|
| 136 | width?: number | string;
|
---|
| 137 | height?: number | string;
|
---|
| 138 | minWidth?: number | string;
|
---|
| 139 | minHeight?: number | string;
|
---|
| 140 | maxWidth?: number | string;
|
---|
| 141 | maxHeight?: number | string;
|
---|
| 142 | }
|
---|