source: trip-planner-front/node_modules/@angular/material/esm2015/dialog/dialog-ref.js@ 76712b2

Last change on this file since 76712b2 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 25.1 KB
Line 
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 */
8import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
9import { Subject } from 'rxjs';
10import { filter, take } from 'rxjs/operators';
11// TODO(jelbourn): resizing
12// Counter for unique dialog ids.
13let uniqueId = 0;
14/**
15 * Reference to a dialog opened via the MatDialog service.
16 */
17export class MatDialogRef {
18 constructor(_overlayRef, _containerInstance,
19 /** Id of the dialog. */
20 id = `mat-dialog-${uniqueId++}`) {
21 this._overlayRef = _overlayRef;
22 this._containerInstance = _containerInstance;
23 this.id = id;
24 /** Whether the user is allowed to close the dialog. */
25 this.disableClose = this._containerInstance._config.disableClose;
26 /** Subject for notifying the user that the dialog has finished opening. */
27 this._afterOpened = new Subject();
28 /** Subject for notifying the user that the dialog has finished closing. */
29 this._afterClosed = new Subject();
30 /** Subject for notifying the user that the dialog has started closing. */
31 this._beforeClosed = new Subject();
32 /** Current state of the dialog. */
33 this._state = 0 /* OPEN */;
34 // Pass the id along to the container.
35 _containerInstance._id = id;
36 // Emit when opening animation completes
37 _containerInstance._animationStateChanged.pipe(filter(event => event.state === 'opened'), take(1))
38 .subscribe(() => {
39 this._afterOpened.next();
40 this._afterOpened.complete();
41 });
42 // Dispose overlay when closing animation is complete
43 _containerInstance._animationStateChanged.pipe(filter(event => event.state === 'closed'), take(1)).subscribe(() => {
44 clearTimeout(this._closeFallbackTimeout);
45 this._finishDialogClose();
46 });
47 _overlayRef.detachments().subscribe(() => {
48 this._beforeClosed.next(this._result);
49 this._beforeClosed.complete();
50 this._afterClosed.next(this._result);
51 this._afterClosed.complete();
52 this.componentInstance = null;
53 this._overlayRef.dispose();
54 });
55 _overlayRef.keydownEvents()
56 .pipe(filter(event => {
57 return event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event);
58 }))
59 .subscribe(event => {
60 event.preventDefault();
61 _closeDialogVia(this, 'keyboard');
62 });
63 _overlayRef.backdropClick().subscribe(() => {
64 if (this.disableClose) {
65 this._containerInstance._recaptureFocus();
66 }
67 else {
68 _closeDialogVia(this, 'mouse');
69 }
70 });
71 }
72 /**
73 * Close the dialog.
74 * @param dialogResult Optional result to return to the dialog opener.
75 */
76 close(dialogResult) {
77 this._result = dialogResult;
78 // Transition the backdrop in parallel to the dialog.
79 this._containerInstance._animationStateChanged.pipe(filter(event => event.state === 'closing'), take(1))
80 .subscribe(event => {
81 this._beforeClosed.next(dialogResult);
82 this._beforeClosed.complete();
83 this._overlayRef.detachBackdrop();
84 // The logic that disposes of the overlay depends on the exit animation completing, however
85 // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
86 // timeout which will clean everything up if the animation hasn't fired within the specified
87 // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
88 // vast majority of cases the timeout will have been cleared before it has the chance to fire.
89 this._closeFallbackTimeout = setTimeout(() => this._finishDialogClose(), event.totalTime + 100);
90 });
91 this._state = 1 /* CLOSING */;
92 this._containerInstance._startExitAnimation();
93 }
94 /**
95 * Gets an observable that is notified when the dialog is finished opening.
96 */
97 afterOpened() {
98 return this._afterOpened;
99 }
100 /**
101 * Gets an observable that is notified when the dialog is finished closing.
102 */
103 afterClosed() {
104 return this._afterClosed;
105 }
106 /**
107 * Gets an observable that is notified when the dialog has started closing.
108 */
109 beforeClosed() {
110 return this._beforeClosed;
111 }
112 /**
113 * Gets an observable that emits when the overlay's backdrop has been clicked.
114 */
115 backdropClick() {
116 return this._overlayRef.backdropClick();
117 }
118 /**
119 * Gets an observable that emits when keydown events are targeted on the overlay.
120 */
121 keydownEvents() {
122 return this._overlayRef.keydownEvents();
123 }
124 /**
125 * Updates the dialog's position.
126 * @param position New dialog position.
127 */
128 updatePosition(position) {
129 let strategy = this._getPositionStrategy();
130 if (position && (position.left || position.right)) {
131 position.left ? strategy.left(position.left) : strategy.right(position.right);
132 }
133 else {
134 strategy.centerHorizontally();
135 }
136 if (position && (position.top || position.bottom)) {
137 position.top ? strategy.top(position.top) : strategy.bottom(position.bottom);
138 }
139 else {
140 strategy.centerVertically();
141 }
142 this._overlayRef.updatePosition();
143 return this;
144 }
145 /**
146 * Updates the dialog's width and height.
147 * @param width New width of the dialog.
148 * @param height New height of the dialog.
149 */
150 updateSize(width = '', height = '') {
151 this._overlayRef.updateSize({ width, height });
152 this._overlayRef.updatePosition();
153 return this;
154 }
155 /** Add a CSS class or an array of classes to the overlay pane. */
156 addPanelClass(classes) {
157 this._overlayRef.addPanelClass(classes);
158 return this;
159 }
160 /** Remove a CSS class or an array of classes from the overlay pane. */
161 removePanelClass(classes) {
162 this._overlayRef.removePanelClass(classes);
163 return this;
164 }
165 /** Gets the current state of the dialog's lifecycle. */
166 getState() {
167 return this._state;
168 }
169 /**
170 * Finishes the dialog close by updating the state of the dialog
171 * and disposing the overlay.
172 */
173 _finishDialogClose() {
174 this._state = 2 /* CLOSED */;
175 this._overlayRef.dispose();
176 }
177 /** Fetches the position strategy object from the overlay ref. */
178 _getPositionStrategy() {
179 return this._overlayRef.getConfig().positionStrategy;
180 }
181}
182/**
183 * Closes the dialog with the specified interaction type. This is currently not part of
184 * `MatDialogRef` as that would conflict with custom dialog ref mocks provided in tests.
185 * More details. See: https://github.com/angular/components/pull/9257#issuecomment-651342226.
186 */
187// TODO: TODO: Move this back into `MatDialogRef` when we provide an official mock dialog ref.
188export function _closeDialogVia(ref, interactionType, result) {
189 // Some mock dialog ref instances in tests do not have the `_containerInstance` property.
190 // For those, we keep the behavior as is and do not deal with the interaction type.
191 if (ref._containerInstance !== undefined) {
192 ref._containerInstance._closeInteractionType = interactionType;
193 }
194 return ref.close(result);
195}
196//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJma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