/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Subject, merge, Subscription } from 'rxjs'; import { take, takeUntil } from 'rxjs/operators'; import { coerceCssPixelValue, coerceArray } from '@angular/cdk/coercion'; /** * Reference to an overlay that has been created with the Overlay service. * Used to manipulate or dispose of said overlay. */ export class OverlayRef { constructor(_portalOutlet, _host, _pane, _config, _ngZone, _keyboardDispatcher, _document, _location, _outsideClickDispatcher, _animationsDisabled = false) { this._portalOutlet = _portalOutlet; this._host = _host; this._pane = _pane; this._config = _config; this._ngZone = _ngZone; this._keyboardDispatcher = _keyboardDispatcher; this._document = _document; this._location = _location; this._outsideClickDispatcher = _outsideClickDispatcher; this._animationsDisabled = _animationsDisabled; this._backdropElement = null; this._backdropClick = new Subject(); this._attachments = new Subject(); this._detachments = new Subject(); this._locationChanges = Subscription.EMPTY; this._backdropClickHandler = (event) => this._backdropClick.next(event); this._backdropTransitionendHandler = (event) => { this._disposeBackdrop(event.target); }; /** Stream of keydown events dispatched to this overlay. */ this._keydownEvents = new Subject(); /** Stream of mouse outside events dispatched to this overlay. */ this._outsidePointerEvents = new Subject(); if (_config.scrollStrategy) { this._scrollStrategy = _config.scrollStrategy; this._scrollStrategy.attach(this); } this._positionStrategy = _config.positionStrategy; } /** The overlay's HTML element */ get overlayElement() { return this._pane; } /** The overlay's backdrop HTML element. */ get backdropElement() { return this._backdropElement; } /** * Wrapper around the panel element. Can be used for advanced * positioning where a wrapper with specific styling is * required around the overlay pane. */ get hostElement() { return this._host; } /** * Attaches content, given via a Portal, to the overlay. * If the overlay is configured to have a backdrop, it will be created. * * @param portal Portal instance to which to attach the overlay. * @returns The portal attachment result. */ attach(portal) { // Insert the host into the DOM before attaching the portal, otherwise // the animations module will skip animations on repeat attachments. if (!this._host.parentElement && this._previousHostParent) { this._previousHostParent.appendChild(this._host); } const attachResult = this._portalOutlet.attach(portal); if (this._positionStrategy) { this._positionStrategy.attach(this); } this._updateStackingOrder(); this._updateElementSize(); this._updateElementDirection(); if (this._scrollStrategy) { this._scrollStrategy.enable(); } // Update the position once the zone is stable so that the overlay will be fully rendered // before attempting to position it, as the position may depend on the size of the rendered // content. this._ngZone.onStable.pipe(take(1)).subscribe(() => { // The overlay could've been detached before the zone has stabilized. if (this.hasAttached()) { this.updatePosition(); } }); // Enable pointer events for the overlay pane element. this._togglePointerEvents(true); if (this._config.hasBackdrop) { this._attachBackdrop(); } if (this._config.panelClass) { this._toggleClasses(this._pane, this._config.panelClass, true); } // Only emit the `attachments` event once all other setup is done. this._attachments.next(); // Track this overlay by the keyboard dispatcher this._keyboardDispatcher.add(this); if (this._config.disposeOnNavigation) { this._locationChanges = this._location.subscribe(() => this.dispose()); } this._outsideClickDispatcher.add(this); // TODO(crisbeto): the null check is here, because the portal outlet returns `any`. // We should be guaranteed for the result to be `ComponentRef | EmbeddedViewRef`, but // `instanceof EmbeddedViewRef` doesn't appear to work at the moment. if (typeof attachResult?.onDestroy === 'function') { // In most cases we control the portal and we know when it is being detached so that // we can finish the disposal process. The exception is if the user passes in a custom // `ViewContainerRef` that isn't destroyed through the overlay API. Note that we use // `detach` here instead of `dispose`, because we don't know if the user intends to // reattach the overlay at a later point. It also has the advantage of waiting for animations. attachResult.onDestroy(() => { if (this.hasAttached()) { // We have to delay the `detach` call, because detaching immediately prevents // other destroy hooks from running. This is likely a framework bug similar to // https://github.com/angular/angular/issues/46119 this._ngZone.runOutsideAngular(() => Promise.resolve().then(() => this.detach())); } }); } return attachResult; } /** * Detaches an overlay from a portal. * @returns The portal detachment result. */ detach() { if (!this.hasAttached()) { return; } this.detachBackdrop(); // When the overlay is detached, the pane element should disable pointer events. // This is necessary because otherwise the pane element will cover the page and disable // pointer events therefore. Depends on the position strategy and the applied pane boundaries. this._togglePointerEvents(false); if (this._positionStrategy && this._positionStrategy.detach) { this._positionStrategy.detach(); } if (this._scrollStrategy) { this._scrollStrategy.disable(); } const detachmentResult = this._portalOutlet.detach(); // Only emit after everything is detached. this._detachments.next(); // Remove this overlay from keyboard dispatcher tracking. this._keyboardDispatcher.remove(this); // Keeping the host element in the DOM can cause scroll jank, because it still gets // rendered, even though it's transparent and unclickable which is why we remove it. this._detachContentWhenStable(); this._locationChanges.unsubscribe(); this._outsideClickDispatcher.remove(this); return detachmentResult; } /** Cleans up the overlay from the DOM. */ dispose() { const isAttached = this.hasAttached(); if (this._positionStrategy) { this._positionStrategy.dispose(); } this._disposeScrollStrategy(); this._disposeBackdrop(this._backdropElement); this._locationChanges.unsubscribe(); this._keyboardDispatcher.remove(this); this._portalOutlet.dispose(); this._attachments.complete(); this._backdropClick.complete(); this._keydownEvents.complete(); this._outsidePointerEvents.complete(); this._outsideClickDispatcher.remove(this); this._host?.remove(); this._previousHostParent = this._pane = this._host = null; if (isAttached) { this._detachments.next(); } this._detachments.complete(); } /** Whether the overlay has attached content. */ hasAttached() { return this._portalOutlet.hasAttached(); } /** Gets an observable that emits when the backdrop has been clicked. */ backdropClick() { return this._backdropClick; } /** Gets an observable that emits when the overlay has been attached. */ attachments() { return this._attachments; } /** Gets an observable that emits when the overlay has been detached. */ detachments() { return this._detachments; } /** Gets an observable of keydown events targeted to this overlay. */ keydownEvents() { return this._keydownEvents; } /** Gets an observable of pointer events targeted outside this overlay. */ outsidePointerEvents() { return this._outsidePointerEvents; } /** Gets the current overlay configuration, which is immutable. */ getConfig() { return this._config; } /** Updates the position of the overlay based on the position strategy. */ updatePosition() { if (this._positionStrategy) { this._positionStrategy.apply(); } } /** Switches to a new position strategy and updates the overlay position. */ updatePositionStrategy(strategy) { if (strategy === this._positionStrategy) { return; } if (this._positionStrategy) { this._positionStrategy.dispose(); } this._positionStrategy = strategy; if (this.hasAttached()) { strategy.attach(this); this.updatePosition(); } } /** Update the size properties of the overlay. */ updateSize(sizeConfig) { this._config = { ...this._config, ...sizeConfig }; this._updateElementSize(); } /** Sets the LTR/RTL direction for the overlay. */ setDirection(dir) { this._config = { ...this._config, direction: dir }; this._updateElementDirection(); } /** Add a CSS class or an array of classes to the overlay pane. */ addPanelClass(classes) { if (this._pane) { this._toggleClasses(this._pane, classes, true); } } /** Remove a CSS class or an array of classes from the overlay pane. */ removePanelClass(classes) { if (this._pane) { this._toggleClasses(this._pane, classes, false); } } /** * Returns the layout direction of the overlay panel. */ getDirection() { const direction = this._config.direction; if (!direction) { return 'ltr'; } return typeof direction === 'string' ? direction : direction.value; } /** Switches to a new scroll strategy. */ updateScrollStrategy(strategy) { if (strategy === this._scrollStrategy) { return; } this._disposeScrollStrategy(); this._scrollStrategy = strategy; if (this.hasAttached()) { strategy.attach(this); strategy.enable(); } } /** Updates the text direction of the overlay panel. */ _updateElementDirection() { this._host.setAttribute('dir', this.getDirection()); } /** Updates the size of the overlay element based on the overlay config. */ _updateElementSize() { if (!this._pane) { return; } const style = this._pane.style; style.width = coerceCssPixelValue(this._config.width); style.height = coerceCssPixelValue(this._config.height); style.minWidth = coerceCssPixelValue(this._config.minWidth); style.minHeight = coerceCssPixelValue(this._config.minHeight); style.maxWidth = coerceCssPixelValue(this._config.maxWidth); style.maxHeight = coerceCssPixelValue(this._config.maxHeight); } /** Toggles the pointer events for the overlay pane element. */ _togglePointerEvents(enablePointer) { this._pane.style.pointerEvents = enablePointer ? '' : 'none'; } /** Attaches a backdrop for this overlay. */ _attachBackdrop() { const showingClass = 'cdk-overlay-backdrop-showing'; this._backdropElement = this._document.createElement('div'); this._backdropElement.classList.add('cdk-overlay-backdrop'); if (this._animationsDisabled) { this._backdropElement.classList.add('cdk-overlay-backdrop-noop-animation'); } if (this._config.backdropClass) { this._toggleClasses(this._backdropElement, this._config.backdropClass, true); } // Insert the backdrop before the pane in the DOM order, // in order to handle stacked overlays properly. this._host.parentElement.insertBefore(this._backdropElement, this._host); // Forward backdrop clicks such that the consumer of the overlay can perform whatever // action desired when such a click occurs (usually closing the overlay). this._backdropElement.addEventListener('click', this._backdropClickHandler); // Add class to fade-in the backdrop after one frame. if (!this._animationsDisabled && typeof requestAnimationFrame !== 'undefined') { this._ngZone.runOutsideAngular(() => { requestAnimationFrame(() => { if (this._backdropElement) { this._backdropElement.classList.add(showingClass); } }); }); } else { this._backdropElement.classList.add(showingClass); } } /** * Updates the stacking order of the element, moving it to the top if necessary. * This is required in cases where one overlay was detached, while another one, * that should be behind it, was destroyed. The next time both of them are opened, * the stacking will be wrong, because the detached element's pane will still be * in its original DOM position. */ _updateStackingOrder() { if (this._host.nextSibling) { this._host.parentNode.appendChild(this._host); } } /** Detaches the backdrop (if any) associated with the overlay. */ detachBackdrop() { const backdropToDetach = this._backdropElement; if (!backdropToDetach) { return; } if (this._animationsDisabled) { this._disposeBackdrop(backdropToDetach); return; } backdropToDetach.classList.remove('cdk-overlay-backdrop-showing'); this._ngZone.runOutsideAngular(() => { backdropToDetach.addEventListener('transitionend', this._backdropTransitionendHandler); }); // If the backdrop doesn't have a transition, the `transitionend` event won't fire. // In this case we make it unclickable and we try to remove it after a delay. backdropToDetach.style.pointerEvents = 'none'; // Run this outside the Angular zone because there's nothing that Angular cares about. // If it were to run inside the Angular zone, every test that used Overlay would have to be // either async or fakeAsync. this._backdropTimeout = this._ngZone.runOutsideAngular(() => setTimeout(() => { this._disposeBackdrop(backdropToDetach); }, 500)); } /** Toggles a single CSS class or an array of classes on an element. */ _toggleClasses(element, cssClasses, isAdd) { const classes = coerceArray(cssClasses || []).filter(c => !!c); if (classes.length) { isAdd ? element.classList.add(...classes) : element.classList.remove(...classes); } } /** Detaches the overlay content next time the zone stabilizes. */ _detachContentWhenStable() { // Normally we wouldn't have to explicitly run this outside the `NgZone`, however // if the consumer is using `zone-patch-rxjs`, the `Subscription.unsubscribe` call will // be patched to run inside the zone, which will throw us into an infinite loop. this._ngZone.runOutsideAngular(() => { // We can't remove the host here immediately, because the overlay pane's content // might still be animating. This stream helps us avoid interrupting the animation // by waiting for the pane to become empty. const subscription = this._ngZone.onStable .pipe(takeUntil(merge(this._attachments, this._detachments))) .subscribe(() => { // Needs a couple of checks for the pane and host, because // they may have been removed by the time the zone stabilizes. if (!this._pane || !this._host || this._pane.children.length === 0) { if (this._pane && this._config.panelClass) { this._toggleClasses(this._pane, this._config.panelClass, false); } if (this._host && this._host.parentElement) { this._previousHostParent = this._host.parentElement; this._host.remove(); } subscription.unsubscribe(); } }); }); } /** Disposes of a scroll strategy. */ _disposeScrollStrategy() { const scrollStrategy = this._scrollStrategy; if (scrollStrategy) { scrollStrategy.disable(); if (scrollStrategy.detach) { scrollStrategy.detach(); } } } /** Removes a backdrop element from the DOM. */ _disposeBackdrop(backdrop) { if (backdrop) { backdrop.removeEventListener('click', this._backdropClickHandler); backdrop.removeEventListener('transitionend', this._backdropTransitionendHandler); backdrop.remove(); // It is possible that a new portal has been attached to this overlay since we started // removing the backdrop. If that is the case, only clear the backdrop reference if it // is still the same instance that we started to remove. if (this._backdropElement === backdrop) { this._backdropElement = null; } } if (this._backdropTimeout) { clearTimeout(this._backdropTimeout); this._backdropTimeout = undefined; } } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3ZlcmxheS1yZWYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL292ZXJsYXkvb3ZlcmxheS1yZWYudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBTUgsT0FBTyxFQUFhLE9BQU8sRUFBRSxLQUFLLEVBQW9CLFlBQVksRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUNoRixPQUFPLEVBQUMsSUFBSSxFQUFFLFNBQVMsRUFBQyxNQUFNLGdCQUFnQixDQUFDO0FBSS9DLE9BQU8sRUFBQyxtQkFBbUIsRUFBRSxXQUFXLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQVN2RTs7O0dBR0c7QUFDSCxNQUFNLE9BQU8sVUFBVTtJQTBCckIsWUFDVSxhQUEyQixFQUMzQixLQUFrQixFQUNsQixLQUFrQix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