/** * @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 { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes'; import { merge, Subject } from 'rxjs'; import { filter, take } from 'rxjs/operators'; /** * Reference to a bottom sheet dispatched from the bottom sheet service. */ export class MatBottomSheetRef { constructor(containerInstance, _overlayRef) { this._overlayRef = _overlayRef; /** Subject for notifying the user that the bottom sheet has been dismissed. */ this._afterDismissed = new Subject(); /** Subject for notifying the user that the bottom sheet has opened and appeared. */ this._afterOpened = new Subject(); this.containerInstance = containerInstance; this.disableClose = containerInstance.bottomSheetConfig.disableClose; // Emit when opening animation completes containerInstance._animationStateChanged.pipe(filter(event => event.phaseName === 'done' && event.toState === 'visible'), take(1)) .subscribe(() => { this._afterOpened.next(); this._afterOpened.complete(); }); // Dispose overlay when closing animation is complete containerInstance._animationStateChanged .pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1)) .subscribe(() => { clearTimeout(this._closeFallbackTimeout); _overlayRef.dispose(); }); _overlayRef.detachments().pipe(take(1)).subscribe(() => { this._afterDismissed.next(this._result); this._afterDismissed.complete(); }); merge(_overlayRef.backdropClick(), _overlayRef.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => { if (!this.disableClose && (event.type !== 'keydown' || !hasModifierKey(event))) { event.preventDefault(); this.dismiss(); } }); } /** * Dismisses the bottom sheet. * @param result Data to be passed back to the bottom sheet opener. */ dismiss(result) { if (!this._afterDismissed.closed) { // Transition the backdrop in parallel to the bottom sheet. this.containerInstance._animationStateChanged.pipe(filter(event => event.phaseName === 'start'), take(1)).subscribe(event => { // The logic that disposes of the overlay depends on the exit animation completing, however // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback // timeout which will clean everything up if the animation hasn't fired within the specified // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the // vast majority of cases the timeout will have been cleared before it has fired. this._closeFallbackTimeout = setTimeout(() => { this._overlayRef.dispose(); }, event.totalTime + 100); this._overlayRef.detachBackdrop(); }); this._result = result; this.containerInstance.exit(); } } /** Gets an observable that is notified when the bottom sheet is finished closing. */ afterDismissed() { return this._afterDismissed; } /** Gets an observable that is notified when the bottom sheet has opened and appeared. */ afterOpened() { return this._afterOpened; } /** * Gets an observable that emits when the overlay's backdrop has been clicked. */ backdropClick() { return this._overlayRef.backdropClick(); } /** * Gets an observable that emits when keydown events are targeted on the overlay. */ keydownEvents() { return this._overlayRef.keydownEvents(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90dG9tLXNoZWV0LXJlZi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9ib3R0b20tc2hlZXQvYm90dG9tLXNoZWV0LXJlZi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsTUFBTSxFQUFFLGNBQWMsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBRTdELE9BQU8sRUFBQyxLQUFLLEVBQWMsT0FBTyxFQUFDLE1BQU0sTUFBTSxDQUFDO0FBQ2hELE9BQU8sRUFBQyxNQUFNLEVBQUUsSUFBSSxFQUFDLE1BQU0sZ0JBQWdCLENBQUM7QUFJNUM7O0dBRUc7QUFDSCxNQUFNLE9BQU8saUJBQWlCO0lBeUI1QixZQUNFLGlCQUEwQyxFQUNsQyxXQUF1QjtRQUF2QixnQkFBVyxHQUFYLFdBQVcsQ0FBWTtRQWRqQywrRUFBK0U7UUFDOUQsb0JBQWUsR0FBRyxJQUFJLE9BQU8sRUFBaUIsQ0FBQztRQUVoRSxvRkFBb0Y7UUFDbkUsaUJBQVksR0FBRyxJQUFJLE9BQU8sRUFBUSxDQUFDO1FBV2xELElBQUksQ0FBQyxpQkFBaUIsR0FBRyxpQkFBaUIsQ0FBQztR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