/** * @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 { /** Instance of the component making up the content of the bottom sheet. */ get instance() { return this._ref.componentInstance; } /** * `ComponentRef` of the component opened into the bottom sheet. Will be * null when the bottom sheet is opened using a `TemplateRef`. */ get componentRef() { return this._ref.componentRef; } constructor(_ref, config, containerInstance) { this._ref = _ref; /** Subject for notifying the user that the bottom sheet has opened and appeared. */ this._afterOpened = new Subject(); this.containerInstance = containerInstance; this.disableClose = config.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); this._ref.close(this._result); }); _ref.overlayRef.detachments().subscribe(() => { this._ref.close(this._result); }); merge(this.backdropClick(), this.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.containerInstance) { return; } // 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._ref.close(this._result); }, event.totalTime + 100); this._ref.overlayRef.detachBackdrop(); }); this._result = result; this.containerInstance.exit(); this.containerInstance = null; } /** Gets an observable that is notified when the bottom sheet is finished closing. */ afterDismissed() { return this._ref.closed; } /** 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._ref.backdropClick; } /** * Gets an observable that emits when keydown events are targeted on the overlay. */ keydownEvents() { return this._ref.keydownEvents; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90dG9tLXNoZWV0LXJlZi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9ib3R0b20tc2hlZXQvYm90dG9tLXNoZWV0LXJlZi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFJSCxPQUFPLEVBQUMsTUFBTSxFQUFFLGNBQWMsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBQzdELE9BQU8sRUFBQyxLQUFLLEVBQWMsT0FBTyxFQUFDLE1BQU0sTUFBTSxDQUFDO0FBQ2hELE9BQU8sRUFBQyxNQUFNLEVBQUUsSUFBSSxFQUFDLE1BQU0sZ0JBQWdCLENBQUM7QUFJNUM7O0dBRUc7QUFDSCxNQUFNLE9BQU8saUJBQWlCO0lBQzVCLDJFQUEyRTtJQUMzRSxJQUFJLFFBQVE7UUFDVixPQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsaUJBQWtCLENBQUM7SUFDdEMsQ0FBQztJQUVEOzs7T0FHRztJQUNILElBQUksWUFBWTtRQUNkLE9BQU8sSUFBSSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUM7SUFDaEMsQ0FBQztJQW9CRCxZQUNVLElBQXFCLEVBQzdCLE1BQTRCLEVBQz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