/** * @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 { Overlay, OverlayContainer } from '@angular/cdk/overlay'; import { Location } from '@angular/common'; import { ANIMATION_MODULE_TYPE, Inject, Injectable, InjectionToken, Injector, Optional, SkipSelf, Type, } from '@angular/core'; import { MatDialogConfig } from './dialog-config'; import { MatDialogContainer } from './dialog-container'; import { MatDialogRef } from './dialog-ref'; import { defer, Subject } from 'rxjs'; import { Dialog, DialogConfig } from '@angular/cdk/dialog'; import { startWith } from 'rxjs/operators'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/overlay"; import * as i2 from "@angular/common"; import * as i3 from "./dialog-config"; /** Injection token that can be used to access the data that was passed in to a dialog. */ export const MAT_DIALOG_DATA = new InjectionToken('MatMdcDialogData'); /** Injection token that can be used to specify default dialog options. */ export const MAT_DIALOG_DEFAULT_OPTIONS = new InjectionToken('mat-mdc-dialog-default-options'); /** Injection token that determines the scroll handling while the dialog is open. */ export const MAT_DIALOG_SCROLL_STRATEGY = new InjectionToken('mat-mdc-dialog-scroll-strategy'); /** @docs-private */ export function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) { return () => overlay.scrollStrategies.block(); } /** @docs-private */ export const MAT_DIALOG_SCROLL_STRATEGY_PROVIDER = { provide: MAT_DIALOG_SCROLL_STRATEGY, deps: [Overlay], useFactory: MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY, }; /** @docs-private */ export function MAT_DIALOG_SCROLL_STRATEGY_FACTORY(overlay) { return () => overlay.scrollStrategies.block(); } // Counter for unique dialog ids. let uniqueId = 0; /** * Base class for dialog services. The base dialog service allows * for arbitrary dialog refs and dialog container components. */ export class _MatDialogBase { /** Keeps track of the currently-open dialogs. */ get openDialogs() { return this._parentDialog ? this._parentDialog.openDialogs : this._openDialogsAtThisLevel; } /** Stream that emits when a dialog has been opened. */ get afterOpened() { return this._parentDialog ? this._parentDialog.afterOpened : this._afterOpenedAtThisLevel; } _getAfterAllClosed() { const parent = this._parentDialog; return parent ? parent._getAfterAllClosed() : this._afterAllClosedAtThisLevel; } constructor(_overlay, injector, _defaultOptions, _parentDialog, /** * @deprecated No longer used. To be removed. * @breaking-change 15.0.0 */ _overlayContainer, scrollStrategy, _dialogRefConstructor, _dialogContainerType, _dialogDataToken, /** * @deprecated No longer used. To be removed. * @breaking-change 14.0.0 */ _animationMode) { this._overlay = _overlay; this._defaultOptions = _defaultOptions; this._parentDialog = _parentDialog; this._dialogRefConstructor = _dialogRefConstructor; this._dialogContainerType = _dialogContainerType; this._dialogDataToken = _dialogDataToken; this._openDialogsAtThisLevel = []; this._afterAllClosedAtThisLevel = new Subject(); this._afterOpenedAtThisLevel = new Subject(); this._idPrefix = 'mat-dialog-'; this.dialogConfigClass = MatDialogConfig; /** * Stream that emits when all open dialog have finished closing. * Will emit on subscribe if there are no open dialogs to begin with. */ this.afterAllClosed = defer(() => this.openDialogs.length ? this._getAfterAllClosed() : this._getAfterAllClosed().pipe(startWith(undefined))); this._scrollStrategy = scrollStrategy; this._dialog = injector.get(Dialog); } open(componentOrTemplateRef, config) { let dialogRef; config = { ...(this._defaultOptions || new MatDialogConfig()), ...config }; config.id = config.id || `${this._idPrefix}${uniqueId++}`; config.scrollStrategy = config.scrollStrategy || this._scrollStrategy(); const cdkRef = this._dialog.open(componentOrTemplateRef, { ...config, positionStrategy: this._overlay.position().global().centerHorizontally().centerVertically(), // Disable closing since we need to sync it up to the animation ourselves. disableClose: true, // Disable closing on destroy, because this service cleans up its open dialogs as well. // We want to do the cleanup here, rather than the CDK service, because the CDK destroys // the dialogs immediately whereas we want it to wait for the animations to finish. closeOnDestroy: false, // Disable closing on detachments so that we can sync up the animation. // The Material dialog ref handles this manually. closeOnOverlayDetachments: false, container: { type: this._dialogContainerType, providers: () => [ // Provide our config as the CDK config as well since it has the same interface as the // CDK one, but it contains the actual values passed in by the user for things like // `disableClose` which we disable for the CDK dialog since we handle it ourselves. { provide: this.dialogConfigClass, useValue: config }, { provide: DialogConfig, useValue: config }, ], }, templateContext: () => ({ dialogRef }), providers: (ref, cdkConfig, dialogContainer) => { dialogRef = new this._dialogRefConstructor(ref, config, dialogContainer); dialogRef.updatePosition(config?.position); return [ { provide: this._dialogContainerType, useValue: dialogContainer }, { provide: this._dialogDataToken, useValue: cdkConfig.data }, { provide: this._dialogRefConstructor, useValue: dialogRef }, ]; }, }); // This can't be assigned in the `providers` callback, because // the instance hasn't been assigned to the CDK ref yet. dialogRef.componentRef = cdkRef.componentRef; dialogRef.componentInstance = cdkRef.componentInstance; this.openDialogs.push(dialogRef); this.afterOpened.next(dialogRef); dialogRef.afterClosed().subscribe(() => { const index = this.openDialogs.indexOf(dialogRef); if (index > -1) { this.openDialogs.splice(index, 1); if (!this.openDialogs.length) { this._getAfterAllClosed().next(); } } }); return dialogRef; } /** * Closes all of the currently-open dialogs. */ closeAll() { this._closeDialogs(this.openDialogs); } /** * Finds an open dialog by its id. * @param id ID to use when looking up the dialog. */ getDialogById(id) { return this.openDialogs.find(dialog => dialog.id === id); } ngOnDestroy() { // Only close the dialogs at this level on destroy // since the parent service may still be active. this._closeDialogs(this._openDialogsAtThisLevel); this._afterAllClosedAtThisLevel.complete(); this._afterOpenedAtThisLevel.complete(); } _closeDialogs(dialogs) { let i = dialogs.length; while (i--) { dialogs[i].close(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: _MatDialogBase, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: _MatDialogBase }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: _MatDialogBase, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i1.Overlay }, { type: i0.Injector }, { type: undefined }, { type: undefined }, { type: i1.OverlayContainer }, { type: undefined }, { type: i0.Type }, { type: i0.Type }, { type: i0.InjectionToken }, { type: undefined }]; } }); /** * Service to open Material Design modal dialogs. */ export class MatDialog extends _MatDialogBase { constructor(overlay, injector, /** * @deprecated `_location` parameter to be removed. * @breaking-change 10.0.0 */ location, defaultOptions, scrollStrategy, parentDialog, /** * @deprecated No longer used. To be removed. * @breaking-change 15.0.0 */ overlayContainer, /** * @deprecated No longer used. To be removed. * @breaking-change 14.0.0 */ animationMode) { super(overlay, injector, defaultOptions, parentDialog, overlayContainer, scrollStrategy, MatDialogRef, MatDialogContainer, MAT_DIALOG_DATA, animationMode); this._idPrefix = 'mat-mdc-dialog-'; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialog, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: i2.Location, optional: true }, { token: MAT_DIALOG_DEFAULT_OPTIONS, optional: true }, { token: MAT_DIALOG_SCROLL_STRATEGY }, { token: MatDialog, optional: true, skipSelf: true }, { token: i1.OverlayContainer }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialog }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialog, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i1.Overlay }, { type: i0.Injector }, { type: i2.Location, decorators: [{ type: Optional }] }, { type: i3.MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS] }] }, { type: undefined, decorators: [{ type: Inject, args: [MAT_DIALOG_SCROLL_STRATEGY] }] }, { type: MatDialog, decorators: [{ type: Optional }, { type: SkipSelf }] }, { type: i1.OverlayContainer }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE] }] }]; } }); //#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