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 { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
|
---|
9 | import { merge, Subject } from 'rxjs';
|
---|
10 | import { filter, take } from 'rxjs/operators';
|
---|
11 | /**
|
---|
12 | * Reference to a bottom sheet dispatched from the bottom sheet service.
|
---|
13 | */
|
---|
14 | export class MatBottomSheetRef {
|
---|
15 | constructor(containerInstance, _overlayRef) {
|
---|
16 | this._overlayRef = _overlayRef;
|
---|
17 | /** Subject for notifying the user that the bottom sheet has been dismissed. */
|
---|
18 | this._afterDismissed = new Subject();
|
---|
19 | /** Subject for notifying the user that the bottom sheet has opened and appeared. */
|
---|
20 | this._afterOpened = new Subject();
|
---|
21 | this.containerInstance = containerInstance;
|
---|
22 | this.disableClose = containerInstance.bottomSheetConfig.disableClose;
|
---|
23 | // Emit when opening animation completes
|
---|
24 | containerInstance._animationStateChanged.pipe(filter(event => event.phaseName === 'done' && event.toState === 'visible'), take(1))
|
---|
25 | .subscribe(() => {
|
---|
26 | this._afterOpened.next();
|
---|
27 | this._afterOpened.complete();
|
---|
28 | });
|
---|
29 | // Dispose overlay when closing animation is complete
|
---|
30 | containerInstance._animationStateChanged
|
---|
31 | .pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1))
|
---|
32 | .subscribe(() => {
|
---|
33 | clearTimeout(this._closeFallbackTimeout);
|
---|
34 | _overlayRef.dispose();
|
---|
35 | });
|
---|
36 | _overlayRef.detachments().pipe(take(1)).subscribe(() => {
|
---|
37 | this._afterDismissed.next(this._result);
|
---|
38 | this._afterDismissed.complete();
|
---|
39 | });
|
---|
40 | merge(_overlayRef.backdropClick(), _overlayRef.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => {
|
---|
41 | if (!this.disableClose &&
|
---|
42 | (event.type !== 'keydown' || !hasModifierKey(event))) {
|
---|
43 | event.preventDefault();
|
---|
44 | this.dismiss();
|
---|
45 | }
|
---|
46 | });
|
---|
47 | }
|
---|
48 | /**
|
---|
49 | * Dismisses the bottom sheet.
|
---|
50 | * @param result Data to be passed back to the bottom sheet opener.
|
---|
51 | */
|
---|
52 | dismiss(result) {
|
---|
53 | if (!this._afterDismissed.closed) {
|
---|
54 | // Transition the backdrop in parallel to the bottom sheet.
|
---|
55 | this.containerInstance._animationStateChanged.pipe(filter(event => event.phaseName === 'start'), take(1)).subscribe(event => {
|
---|
56 | // The logic that disposes of the overlay depends on the exit animation completing, however
|
---|
57 | // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
|
---|
58 | // timeout which will clean everything up if the animation hasn't fired within the specified
|
---|
59 | // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
|
---|
60 | // vast majority of cases the timeout will have been cleared before it has fired.
|
---|
61 | this._closeFallbackTimeout = setTimeout(() => {
|
---|
62 | this._overlayRef.dispose();
|
---|
63 | }, event.totalTime + 100);
|
---|
64 | this._overlayRef.detachBackdrop();
|
---|
65 | });
|
---|
66 | this._result = result;
|
---|
67 | this.containerInstance.exit();
|
---|
68 | }
|
---|
69 | }
|
---|
70 | /** Gets an observable that is notified when the bottom sheet is finished closing. */
|
---|
71 | afterDismissed() {
|
---|
72 | return this._afterDismissed;
|
---|
73 | }
|
---|
74 | /** Gets an observable that is notified when the bottom sheet has opened and appeared. */
|
---|
75 | afterOpened() {
|
---|
76 | return this._afterOpened;
|
---|
77 | }
|
---|
78 | /**
|
---|
79 | * Gets an observable that emits when the overlay's backdrop has been clicked.
|
---|
80 | */
|
---|
81 | backdropClick() {
|
---|
82 | return this._overlayRef.backdropClick();
|
---|
83 | }
|
---|
84 | /**
|
---|
85 | * Gets an observable that emits when keydown events are targeted on the overlay.
|
---|
86 | */
|
---|
87 | keydownEvents() {
|
---|
88 | return this._overlayRef.keydownEvents();
|
---|
89 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