/** * @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 { Dialog } from '@angular/cdk/dialog'; import { Overlay } from '@angular/cdk/overlay'; import { Injectable, Optional, SkipSelf, InjectionToken, Inject, Injector, } from '@angular/core'; import { MAT_BOTTOM_SHEET_DATA, MatBottomSheetConfig } from './bottom-sheet-config'; import { MatBottomSheetContainer } from './bottom-sheet-container'; import { MatBottomSheetModule } from './bottom-sheet-module'; import { MatBottomSheetRef } from './bottom-sheet-ref'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/overlay"; import * as i2 from "./bottom-sheet-config"; /** Injection token that can be used to specify default bottom sheet options. */ export const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken('mat-bottom-sheet-default-options'); /** * Service to trigger Material Design bottom sheets. */ export class MatBottomSheet { /** Reference to the currently opened bottom sheet. */ get _openedBottomSheetRef() { const parent = this._parentBottomSheet; return parent ? parent._openedBottomSheetRef : this._bottomSheetRefAtThisLevel; } set _openedBottomSheetRef(value) { if (this._parentBottomSheet) { this._parentBottomSheet._openedBottomSheetRef = value; } else { this._bottomSheetRefAtThisLevel = value; } } constructor(_overlay, injector, _parentBottomSheet, _defaultOptions) { this._overlay = _overlay; this._parentBottomSheet = _parentBottomSheet; this._defaultOptions = _defaultOptions; this._bottomSheetRefAtThisLevel = null; this._dialog = injector.get(Dialog); } open(componentOrTemplateRef, config) { const _config = { ...(this._defaultOptions || new MatBottomSheetConfig()), ...config }; let ref; this._dialog.open(componentOrTemplateRef, { ..._config, // Disable closing since we need to sync it up to the animation ourselves. disableClose: true, // Disable closing on detachments so that we can sync up the animation. closeOnOverlayDetachments: false, maxWidth: '100%', container: MatBottomSheetContainer, scrollStrategy: _config.scrollStrategy || this._overlay.scrollStrategies.block(), positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'), templateContext: () => ({ bottomSheetRef: ref }), providers: (cdkRef, _cdkConfig, container) => { ref = new MatBottomSheetRef(cdkRef, _config, container); return [ { provide: MatBottomSheetRef, useValue: ref }, { provide: MAT_BOTTOM_SHEET_DATA, useValue: _config.data }, ]; }, }); // When the bottom sheet is dismissed, clear the reference to it. ref.afterDismissed().subscribe(() => { // Clear the bottom sheet ref if it hasn't already been replaced by a newer one. if (this._openedBottomSheetRef === ref) { this._openedBottomSheetRef = null; } }); if (this._openedBottomSheetRef) { // If a bottom sheet is already in view, dismiss it and enter the // new bottom sheet after exit animation is complete. this._openedBottomSheetRef.afterDismissed().subscribe(() => ref.containerInstance?.enter()); this._openedBottomSheetRef.dismiss(); } else { // If no bottom sheet is in view, enter the new bottom sheet. ref.containerInstance.enter(); } this._openedBottomSheetRef = ref; return ref; } /** * Dismisses the currently-visible bottom sheet. * @param result Data to pass to the bottom sheet instance. */ dismiss(result) { if (this._openedBottomSheetRef) { this._openedBottomSheetRef.dismiss(result); } } ngOnDestroy() { if (this._bottomSheetRefAtThisLevel) { this._bottomSheetRefAtThisLevel.dismiss(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatBottomSheet, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: MatBottomSheet, optional: true, skipSelf: true }, { token: MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatBottomSheet, providedIn: MatBottomSheetModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatBottomSheet, decorators: [{ type: Injectable, args: [{ providedIn: MatBottomSheetModule }] }], ctorParameters: function () { return [{ type: i1.Overlay }, { type: i0.Injector }, { type: MatBottomSheet, decorators: [{ type: Optional }, { type: SkipSelf }] }, { type: i2.MatBottomSheetConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_BOTTOM_SHEET_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