| /** |
| * @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 |
| */ |
| (function (global, factory) { |
| typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/animations'), require('@angular/material/core'), require('@angular/cdk/portal'), require('@angular/cdk/layout'), require('@angular/common'), require('@angular/cdk/a11y'), require('@angular/cdk/overlay'), require('@angular/cdk/keycodes'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/bidi')) : |
| typeof define === 'function' && define.amd ? define('@angular/material/bottom-sheet', ['exports', '@angular/core', '@angular/animations', '@angular/material/core', '@angular/cdk/portal', '@angular/cdk/layout', '@angular/common', '@angular/cdk/a11y', '@angular/cdk/overlay', '@angular/cdk/keycodes', 'rxjs', 'rxjs/operators', '@angular/cdk/bidi'], factory) : |
| (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.bottomSheet = {}),global.ng.core,global.ng.animations,global.ng.material.core,global.ng.cdk.portal,global.ng.cdk.layout,global.ng.common,global.ng.cdk.a11y,global.ng.cdk.overlay,global.ng.cdk.keycodes,global.rxjs,global.rxjs.operators,global.ng.cdk.bidi)); |
| }(this, (function (exports,core,animations,core$1,portal,layout,common,a11y,overlay,keycodes,rxjs,operators,bidi) { 'use strict'; |
| |
| /*! *****************************************************************************
|
| Copyright (c) Microsoft Corporation. All rights reserved.
|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
| this file except in compliance with the License. You may obtain a copy of the
|
| License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
| THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
| KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
| WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
| MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
| See the Apache Version 2.0 License for specific language governing permissions
|
| and limitations under the License.
|
| ***************************************************************************** */
|
| /* global Reflect, Promise */
|
|
|
| var extendStatics = function(d, b) {
|
| extendStatics = Object.setPrototypeOf ||
|
| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
| function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
| return extendStatics(d, b);
|
| };
|
|
|
| function __extends(d, b) {
|
| extendStatics(d, b);
|
| function __() { this.constructor = d; }
|
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
| }
|
|
|
| var __assign = function() {
|
| __assign = Object.assign || function __assign(t) {
|
| for (var s, i = 1, n = arguments.length; i < n; i++) {
|
| s = arguments[i];
|
| for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
| }
|
| return t;
|
| };
|
| return __assign.apply(this, arguments);
|
| }; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** |
| * Injection token that can be used to access the data that was passed in to a bottom sheet. |
| * @type {?} |
| */ |
| var MAT_BOTTOM_SHEET_DATA = new core.InjectionToken('MatBottomSheetData'); |
| /** |
| * Configuration used when opening a bottom sheet. |
| * @template D |
| */ |
| var /** |
| * Configuration used when opening a bottom sheet. |
| * @template D |
| */ |
| MatBottomSheetConfig = /** @class */ (function () { |
| function MatBottomSheetConfig() { |
| /** |
| * Data being injected into the child component. |
| */ |
| this.data = null; |
| /** |
| * Whether the bottom sheet has a backdrop. |
| */ |
| this.hasBackdrop = true; |
| /** |
| * Whether the user can use escape or clicking outside to close the bottom sheet. |
| */ |
| this.disableClose = false; |
| /** |
| * Aria label to assign to the bottom sheet element. |
| */ |
| this.ariaLabel = null; |
| /** |
| * Whether the bottom sheet should close when the user goes backwards/forwards in history. |
| * Note that this usually doesn't include clicking on links (unless the user is using |
| * the `HashLocationStrategy`). |
| */ |
| this.closeOnNavigation = true; |
| // Note that this is disabled by default, because while the a11y recommendations are to focus |
| // the first focusable element, doing so prevents screen readers from reading out the |
| // rest of the bottom sheet content. |
| /** |
| * Whether the bottom sheet should focus the first focusable element on open. |
| */ |
| this.autoFocus = false; |
| /** |
| * Whether the bottom sheet should restore focus to the |
| * previously-focused element, after it's closed. |
| */ |
| this.restoreFocus = true; |
| } |
| return MatBottomSheetConfig; |
| }()); |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** |
| * Animations used by the Material bottom sheet. |
| * @type {?} |
| */ |
| var matBottomSheetAnimations = { |
| /** |
| * Animation that shows and hides a bottom sheet. |
| */ |
| bottomSheetState: animations.trigger('state', [ |
| animations.state('void, hidden', animations.style({ transform: 'translateY(100%)' })), |
| animations.state('visible', animations.style({ transform: 'translateY(0%)' })), |
| animations.transition('visible => void, visible => hidden', animations.animate(core$1.AnimationDurations.COMPLEX + " " + core$1.AnimationCurves.ACCELERATION_CURVE)), |
| animations.transition('void => visible', animations.animate(core$1.AnimationDurations.EXITING + " " + core$1.AnimationCurves.DECELERATION_CURVE)), |
| ]) |
| }; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| // TODO(crisbeto): consolidate some logic between this, MatDialog and MatSnackBar |
| /** |
| * Internal component that wraps user-provided bottom sheet content. |
| * \@docs-private |
| */ |
| var MatBottomSheetContainer = /** @class */ (function (_super) { |
| __extends(MatBottomSheetContainer, _super); |
| function MatBottomSheetContainer(_elementRef, _changeDetectorRef, _focusTrapFactory, breakpointObserver, document, bottomSheetConfig) { |
| var _this = _super.call(this) || this; |
| _this._elementRef = _elementRef; |
| _this._changeDetectorRef = _changeDetectorRef; |
| _this._focusTrapFactory = _focusTrapFactory; |
| _this.bottomSheetConfig = bottomSheetConfig; |
| /** |
| * The state of the bottom sheet animations. |
| */ |
| _this._animationState = 'void'; |
| /** |
| * Emits whenever the state of the animation changes. |
| */ |
| _this._animationStateChanged = new core.EventEmitter(); |
| /** |
| * Element that was focused before the bottom sheet was opened. |
| */ |
| _this._elementFocusedBeforeOpened = null; |
| _this._document = document; |
| _this._breakpointSubscription = breakpointObserver |
| .observe([layout.Breakpoints.Medium, layout.Breakpoints.Large, layout.Breakpoints.XLarge]) |
| .subscribe((/** |
| * @return {?} |
| */ |
| function () { |
| _this._toggleClass('mat-bottom-sheet-container-medium', breakpointObserver.isMatched(layout.Breakpoints.Medium)); |
| _this._toggleClass('mat-bottom-sheet-container-large', breakpointObserver.isMatched(layout.Breakpoints.Large)); |
| _this._toggleClass('mat-bottom-sheet-container-xlarge', breakpointObserver.isMatched(layout.Breakpoints.XLarge)); |
| })); |
| return _this; |
| } |
| /** Attach a component portal as content to this bottom sheet container. */ |
| /** |
| * Attach a component portal as content to this bottom sheet container. |
| * @template T |
| * @param {?} portal |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype.attachComponentPortal = /** |
| * Attach a component portal as content to this bottom sheet container. |
| * @template T |
| * @param {?} portal |
| * @return {?} |
| */ |
| function (portal$$1) { |
| this._validatePortalAttached(); |
| this._setPanelClass(); |
| this._savePreviouslyFocusedElement(); |
| return this._portalOutlet.attachComponentPortal(portal$$1); |
| }; |
| /** Attach a template portal as content to this bottom sheet container. */ |
| /** |
| * Attach a template portal as content to this bottom sheet container. |
| * @template C |
| * @param {?} portal |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype.attachTemplatePortal = /** |
| * Attach a template portal as content to this bottom sheet container. |
| * @template C |
| * @param {?} portal |
| * @return {?} |
| */ |
| function (portal$$1) { |
| this._validatePortalAttached(); |
| this._setPanelClass(); |
| this._savePreviouslyFocusedElement(); |
| return this._portalOutlet.attachTemplatePortal(portal$$1); |
| }; |
| /** Begin animation of bottom sheet entrance into view. */ |
| /** |
| * Begin animation of bottom sheet entrance into view. |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype.enter = /** |
| * Begin animation of bottom sheet entrance into view. |
| * @return {?} |
| */ |
| function () { |
| if (!this._destroyed) { |
| this._animationState = 'visible'; |
| this._changeDetectorRef.detectChanges(); |
| } |
| }; |
| /** Begin animation of the bottom sheet exiting from view. */ |
| /** |
| * Begin animation of the bottom sheet exiting from view. |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype.exit = /** |
| * Begin animation of the bottom sheet exiting from view. |
| * @return {?} |
| */ |
| function () { |
| if (!this._destroyed) { |
| this._animationState = 'hidden'; |
| this._changeDetectorRef.markForCheck(); |
| } |
| }; |
| /** |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype.ngOnDestroy = /** |
| * @return {?} |
| */ |
| function () { |
| this._breakpointSubscription.unsubscribe(); |
| this._destroyed = true; |
| }; |
| /** |
| * @param {?} event |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._onAnimationDone = /** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { |
| if (event.toState === 'hidden') { |
| this._restoreFocus(); |
| } |
| else if (event.toState === 'visible') { |
| this._trapFocus(); |
| } |
| this._animationStateChanged.emit(event); |
| }; |
| /** |
| * @param {?} event |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._onAnimationStart = /** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { |
| this._animationStateChanged.emit(event); |
| }; |
| /** |
| * @private |
| * @param {?} cssClass |
| * @param {?} add |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._toggleClass = /** |
| * @private |
| * @param {?} cssClass |
| * @param {?} add |
| * @return {?} |
| */ |
| function (cssClass, add) { |
| /** @type {?} */ |
| var classList = this._elementRef.nativeElement.classList; |
| add ? classList.add(cssClass) : classList.remove(cssClass); |
| }; |
| /** |
| * @private |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._validatePortalAttached = /** |
| * @private |
| * @return {?} |
| */ |
| function () { |
| if (this._portalOutlet.hasAttached()) { |
| throw Error('Attempting to attach bottom sheet content after content is already attached'); |
| } |
| }; |
| /** |
| * @private |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._setPanelClass = /** |
| * @private |
| * @return {?} |
| */ |
| function () { |
| /** @type {?} */ |
| var element = this._elementRef.nativeElement; |
| /** @type {?} */ |
| var panelClass = this.bottomSheetConfig.panelClass; |
| if (Array.isArray(panelClass)) { |
| // Note that we can't use a spread here, because IE doesn't support multiple arguments. |
| panelClass.forEach((/** |
| * @param {?} cssClass |
| * @return {?} |
| */ |
| function (cssClass) { return element.classList.add(cssClass); })); |
| } |
| else if (panelClass) { |
| element.classList.add(panelClass); |
| } |
| }; |
| /** Moves the focus inside the focus trap. */ |
| /** |
| * Moves the focus inside the focus trap. |
| * @private |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._trapFocus = /** |
| * Moves the focus inside the focus trap. |
| * @private |
| * @return {?} |
| */ |
| function () { |
| if (!this._focusTrap) { |
| this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement); |
| } |
| if (this.bottomSheetConfig.autoFocus) { |
| this._focusTrap.focusInitialElementWhenReady(); |
| } |
| }; |
| /** Restores focus to the element that was focused before the bottom sheet was opened. */ |
| /** |
| * Restores focus to the element that was focused before the bottom sheet was opened. |
| * @private |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._restoreFocus = /** |
| * Restores focus to the element that was focused before the bottom sheet was opened. |
| * @private |
| * @return {?} |
| */ |
| function () { |
| /** @type {?} */ |
| var toFocus = this._elementFocusedBeforeOpened; |
| // We need the extra check, because IE can set the `activeElement` to null in some cases. |
| if (this.bottomSheetConfig.restoreFocus && toFocus && typeof toFocus.focus === 'function') { |
| toFocus.focus(); |
| } |
| if (this._focusTrap) { |
| this._focusTrap.destroy(); |
| } |
| }; |
| /** Saves a reference to the element that was focused before the bottom sheet was opened. */ |
| /** |
| * Saves a reference to the element that was focused before the bottom sheet was opened. |
| * @private |
| * @return {?} |
| */ |
| MatBottomSheetContainer.prototype._savePreviouslyFocusedElement = /** |
| * Saves a reference to the element that was focused before the bottom sheet was opened. |
| * @private |
| * @return {?} |
| */ |
| function () { |
| var _this = this; |
| this._elementFocusedBeforeOpened = (/** @type {?} */ (this._document.activeElement)); |
| // The `focus` method isn't available during server-side rendering. |
| if (this._elementRef.nativeElement.focus) { |
| Promise.resolve().then((/** |
| * @return {?} |
| */ |
| function () { return _this._elementRef.nativeElement.focus(); })); |
| } |
| }; |
| MatBottomSheetContainer.decorators = [ |
| { type: core.Component, args: [{selector: 'mat-bottom-sheet-container', |
| template: "<ng-template cdkPortalOutlet></ng-template>", |
| styles: [".mat-bottom-sheet-container{padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto}@media (-ms-high-contrast:active){.mat-bottom-sheet-container{outline:1px solid}}.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium,.mat-bottom-sheet-container-xlarge{border-top-left-radius:4px;border-top-right-radius:4px}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}"], |
| changeDetection: core.ChangeDetectionStrategy.OnPush, |
| encapsulation: core.ViewEncapsulation.None, |
| animations: [matBottomSheetAnimations.bottomSheetState], |
| host: { |
| 'class': 'mat-bottom-sheet-container', |
| 'tabindex': '-1', |
| 'role': 'dialog', |
| 'aria-modal': 'true', |
| '[attr.aria-label]': 'bottomSheetConfig?.ariaLabel', |
| '[@state]': '_animationState', |
| '(@state.start)': '_onAnimationStart($event)', |
| '(@state.done)': '_onAnimationDone($event)' |
| }, |
| },] }, |
| ]; |
| /** @nocollapse */ |
| MatBottomSheetContainer.ctorParameters = function () { return [ |
| { type: core.ElementRef }, |
| { type: core.ChangeDetectorRef }, |
| { type: a11y.FocusTrapFactory }, |
| { type: layout.BreakpointObserver }, |
| { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [common.DOCUMENT,] }] }, |
| { type: MatBottomSheetConfig } |
| ]; }; |
| MatBottomSheetContainer.propDecorators = { |
| _portalOutlet: [{ type: core.ViewChild, args: [portal.CdkPortalOutlet, { static: true },] }] |
| }; |
| return MatBottomSheetContainer; |
| }(portal.BasePortalOutlet)); |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| var MatBottomSheetModule = /** @class */ (function () { |
| function MatBottomSheetModule() { |
| } |
| MatBottomSheetModule.decorators = [ |
| { type: core.NgModule, args: [{ |
| imports: [ |
| common.CommonModule, |
| overlay.OverlayModule, |
| core$1.MatCommonModule, |
| portal.PortalModule, |
| ], |
| exports: [MatBottomSheetContainer, core$1.MatCommonModule], |
| declarations: [MatBottomSheetContainer], |
| entryComponents: [MatBottomSheetContainer], |
| },] }, |
| ]; |
| return MatBottomSheetModule; |
| }()); |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** |
| * Reference to a bottom sheet dispatched from the bottom sheet service. |
| * @template T, R |
| */ |
| var /** |
| * Reference to a bottom sheet dispatched from the bottom sheet service. |
| * @template T, R |
| */ |
| MatBottomSheetRef = /** @class */ (function () { |
| function MatBottomSheetRef(containerInstance, _overlayRef, |
| // @breaking-change 8.0.0 `_location` parameter to be removed. |
| _location) { |
| var _this = this; |
| this._overlayRef = _overlayRef; |
| /** |
| * Subject for notifying the user that the bottom sheet has been dismissed. |
| */ |
| this._afterDismissed = new rxjs.Subject(); |
| /** |
| * Subject for notifying the user that the bottom sheet has opened and appeared. |
| */ |
| this._afterOpened = new rxjs.Subject(); |
| this.containerInstance = containerInstance; |
| this.disableClose = containerInstance.bottomSheetConfig.disableClose; |
| // Emit when opening animation completes |
| containerInstance._animationStateChanged.pipe(operators.filter((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { return event.phaseName === 'done' && event.toState === 'visible'; })), operators.take(1)) |
| .subscribe((/** |
| * @return {?} |
| */ |
| function () { |
| _this._afterOpened.next(); |
| _this._afterOpened.complete(); |
| })); |
| // Dispose overlay when closing animation is complete |
| containerInstance._animationStateChanged |
| .pipe(operators.filter((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { return event.phaseName === 'done' && event.toState === 'hidden'; })), operators.take(1)) |
| .subscribe((/** |
| * @return {?} |
| */ |
| function () { |
| clearTimeout(_this._closeFallbackTimeout); |
| _overlayRef.dispose(); |
| })); |
| _overlayRef.detachments().pipe(operators.take(1)).subscribe((/** |
| * @return {?} |
| */ |
| function () { |
| _this._afterDismissed.next(_this._result); |
| _this._afterDismissed.complete(); |
| })); |
| rxjs.merge(_overlayRef.backdropClick(), _overlayRef.keydownEvents().pipe(operators.filter((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { return event.keyCode === keycodes.ESCAPE; })))).subscribe((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { |
| if (!_this.disableClose && |
| (event.type !== 'keydown' || !keycodes.hasModifierKey((/** @type {?} */ (event))))) { |
| event.preventDefault(); |
| _this.dismiss(); |
| } |
| })); |
| } |
| /** |
| * Dismisses the bottom sheet. |
| * @param result Data to be passed back to the bottom sheet opener. |
| */ |
| /** |
| * Dismisses the bottom sheet. |
| * @param {?=} result Data to be passed back to the bottom sheet opener. |
| * @return {?} |
| */ |
| MatBottomSheetRef.prototype.dismiss = /** |
| * Dismisses the bottom sheet. |
| * @param {?=} result Data to be passed back to the bottom sheet opener. |
| * @return {?} |
| */ |
| function (result) { |
| var _this = this; |
| if (!this._afterDismissed.closed) { |
| // Transition the backdrop in parallel to the bottom sheet. |
| this.containerInstance._animationStateChanged.pipe(operators.filter((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (event) { return event.phaseName === 'start'; })), operators.take(1)).subscribe((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| function (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((/** |
| * @return {?} |
| */ |
| function () { |
| _this._overlayRef.dispose(); |
| }), event.totalTime + 100); |
| _this._overlayRef.detachBackdrop(); |
| })); |
| this._result = result; |
| this.containerInstance.exit(); |
| } |
| }; |
| /** Gets an observable that is notified when the bottom sheet is finished closing. */ |
| /** |
| * Gets an observable that is notified when the bottom sheet is finished closing. |
| * @return {?} |
| */ |
| MatBottomSheetRef.prototype.afterDismissed = /** |
| * Gets an observable that is notified when the bottom sheet is finished closing. |
| * @return {?} |
| */ |
| function () { |
| return this._afterDismissed.asObservable(); |
| }; |
| /** Gets an observable that is notified when the bottom sheet has opened and appeared. */ |
| /** |
| * Gets an observable that is notified when the bottom sheet has opened and appeared. |
| * @return {?} |
| */ |
| MatBottomSheetRef.prototype.afterOpened = /** |
| * Gets an observable that is notified when the bottom sheet has opened and appeared. |
| * @return {?} |
| */ |
| function () { |
| return this._afterOpened.asObservable(); |
| }; |
| /** |
| * Gets an observable that emits when the overlay's backdrop has been clicked. |
| */ |
| /** |
| * Gets an observable that emits when the overlay's backdrop has been clicked. |
| * @return {?} |
| */ |
| MatBottomSheetRef.prototype.backdropClick = /** |
| * Gets an observable that emits when the overlay's backdrop has been clicked. |
| * @return {?} |
| */ |
| function () { |
| return this._overlayRef.backdropClick(); |
| }; |
| /** |
| * Gets an observable that emits when keydown events are targeted on the overlay. |
| */ |
| /** |
| * Gets an observable that emits when keydown events are targeted on the overlay. |
| * @return {?} |
| */ |
| MatBottomSheetRef.prototype.keydownEvents = /** |
| * Gets an observable that emits when keydown events are targeted on the overlay. |
| * @return {?} |
| */ |
| function () { |
| return this._overlayRef.keydownEvents(); |
| }; |
| return MatBottomSheetRef; |
| }()); |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** |
| * Injection token that can be used to specify default bottom sheet options. |
| * @type {?} |
| */ |
| var MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new core.InjectionToken('mat-bottom-sheet-default-options'); |
| /** |
| * Service to trigger Material Design bottom sheets. |
| */ |
| var MatBottomSheet = /** @class */ (function () { |
| function MatBottomSheet(_overlay, _injector, _parentBottomSheet, _location, _defaultOptions) { |
| this._overlay = _overlay; |
| this._injector = _injector; |
| this._parentBottomSheet = _parentBottomSheet; |
| this._location = _location; |
| this._defaultOptions = _defaultOptions; |
| this._bottomSheetRefAtThisLevel = null; |
| } |
| Object.defineProperty(MatBottomSheet.prototype, "_openedBottomSheetRef", { |
| /** Reference to the currently opened bottom sheet. */ |
| get: /** |
| * Reference to the currently opened bottom sheet. |
| * @return {?} |
| */ |
| function () { |
| /** @type {?} */ |
| var parent = this._parentBottomSheet; |
| return parent ? parent._openedBottomSheetRef : this._bottomSheetRefAtThisLevel; |
| }, |
| set: /** |
| * @param {?} value |
| * @return {?} |
| */ |
| function (value) { |
| if (this._parentBottomSheet) { |
| this._parentBottomSheet._openedBottomSheetRef = value; |
| } |
| else { |
| this._bottomSheetRefAtThisLevel = value; |
| } |
| }, |
| enumerable: true, |
| configurable: true |
| }); |
| /** |
| * @template T, D, R |
| * @param {?} componentOrTemplateRef |
| * @param {?=} config |
| * @return {?} |
| */ |
| MatBottomSheet.prototype.open = /** |
| * @template T, D, R |
| * @param {?} componentOrTemplateRef |
| * @param {?=} config |
| * @return {?} |
| */ |
| function (componentOrTemplateRef, config) { |
| var _this = this; |
| /** @type {?} */ |
| var _config = _applyConfigDefaults(this._defaultOptions || new MatBottomSheetConfig(), config); |
| /** @type {?} */ |
| var overlayRef = this._createOverlay(_config); |
| /** @type {?} */ |
| var container = this._attachContainer(overlayRef, _config); |
| /** @type {?} */ |
| var ref = new MatBottomSheetRef(container, overlayRef, this._location); |
| if (componentOrTemplateRef instanceof core.TemplateRef) { |
| container.attachTemplatePortal(new portal.TemplatePortal(componentOrTemplateRef, (/** @type {?} */ (null)), (/** @type {?} */ ({ |
| $implicit: _config.data, |
| bottomSheetRef: ref |
| })))); |
| } |
| else { |
| /** @type {?} */ |
| var portal$$1 = new portal.ComponentPortal(componentOrTemplateRef, undefined, this._createInjector(_config, ref)); |
| /** @type {?} */ |
| var contentRef = container.attachComponentPortal(portal$$1); |
| ref.instance = contentRef.instance; |
| } |
| // When the bottom sheet is dismissed, clear the reference to it. |
| ref.afterDismissed().subscribe((/** |
| * @return {?} |
| */ |
| function () { |
| // 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((/** |
| * @return {?} |
| */ |
| function () { return 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. |
| */ |
| /** |
| * Dismisses the currently-visible bottom sheet. |
| * @return {?} |
| */ |
| MatBottomSheet.prototype.dismiss = /** |
| * Dismisses the currently-visible bottom sheet. |
| * @return {?} |
| */ |
| function () { |
| if (this._openedBottomSheetRef) { |
| this._openedBottomSheetRef.dismiss(); |
| } |
| }; |
| /** |
| * @return {?} |
| */ |
| MatBottomSheet.prototype.ngOnDestroy = /** |
| * @return {?} |
| */ |
| function () { |
| if (this._bottomSheetRefAtThisLevel) { |
| this._bottomSheetRefAtThisLevel.dismiss(); |
| } |
| }; |
| /** |
| * Attaches the bottom sheet container component to the overlay. |
| */ |
| /** |
| * Attaches the bottom sheet container component to the overlay. |
| * @private |
| * @param {?} overlayRef |
| * @param {?} config |
| * @return {?} |
| */ |
| MatBottomSheet.prototype._attachContainer = /** |
| * Attaches the bottom sheet container component to the overlay. |
| * @private |
| * @param {?} overlayRef |
| * @param {?} config |
| * @return {?} |
| */ |
| function (overlayRef, config) { |
| /** @type {?} */ |
| var userInjector = config && config.viewContainerRef && config.viewContainerRef.injector; |
| /** @type {?} */ |
| var injector = new portal.PortalInjector(userInjector || this._injector, new WeakMap([ |
| [MatBottomSheetConfig, config] |
| ])); |
| /** @type {?} */ |
| var containerPortal = new portal.ComponentPortal(MatBottomSheetContainer, config.viewContainerRef, injector); |
| /** @type {?} */ |
| var containerRef = overlayRef.attach(containerPortal); |
| return containerRef.instance; |
| }; |
| /** |
| * Creates a new overlay and places it in the correct location. |
| * @param config The user-specified bottom sheet config. |
| */ |
| /** |
| * Creates a new overlay and places it in the correct location. |
| * @private |
| * @param {?} config The user-specified bottom sheet config. |
| * @return {?} |
| */ |
| MatBottomSheet.prototype._createOverlay = /** |
| * Creates a new overlay and places it in the correct location. |
| * @private |
| * @param {?} config The user-specified bottom sheet config. |
| * @return {?} |
| */ |
| function (config) { |
| /** @type {?} */ |
| var overlayConfig = new overlay.OverlayConfig({ |
| direction: config.direction, |
| hasBackdrop: config.hasBackdrop, |
| disposeOnNavigation: config.closeOnNavigation, |
| maxWidth: '100%', |
| scrollStrategy: config.scrollStrategy || this._overlay.scrollStrategies.block(), |
| positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0') |
| }); |
| if (config.backdropClass) { |
| overlayConfig.backdropClass = config.backdropClass; |
| } |
| return this._overlay.create(overlayConfig); |
| }; |
| /** |
| * Creates an injector to be used inside of a bottom sheet component. |
| * @param config Config that was used to create the bottom sheet. |
| * @param bottomSheetRef Reference to the bottom sheet. |
| */ |
| /** |
| * Creates an injector to be used inside of a bottom sheet component. |
| * @private |
| * @template T |
| * @param {?} config Config that was used to create the bottom sheet. |
| * @param {?} bottomSheetRef Reference to the bottom sheet. |
| * @return {?} |
| */ |
| MatBottomSheet.prototype._createInjector = /** |
| * Creates an injector to be used inside of a bottom sheet component. |
| * @private |
| * @template T |
| * @param {?} config Config that was used to create the bottom sheet. |
| * @param {?} bottomSheetRef Reference to the bottom sheet. |
| * @return {?} |
| */ |
| function (config, bottomSheetRef) { |
| /** @type {?} */ |
| var userInjector = config && config.viewContainerRef && config.viewContainerRef.injector; |
| /** @type {?} */ |
| var injectionTokens = new WeakMap([ |
| [MatBottomSheetRef, bottomSheetRef], |
| [MAT_BOTTOM_SHEET_DATA, config.data] |
| ]); |
| if (config.direction && |
| (!userInjector || !userInjector.get(bidi.Directionality, null))) { |
| injectionTokens.set(bidi.Directionality, { |
| value: config.direction, |
| change: rxjs.of() |
| }); |
| } |
| return new portal.PortalInjector(userInjector || this._injector, injectionTokens); |
| }; |
| MatBottomSheet.decorators = [ |
| { type: core.Injectable, args: [{ providedIn: MatBottomSheetModule },] }, |
| ]; |
| /** @nocollapse */ |
| MatBottomSheet.ctorParameters = function () { return [ |
| { type: overlay.Overlay }, |
| { type: core.Injector }, |
| { type: MatBottomSheet, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] }, |
| { type: common.Location, decorators: [{ type: core.Optional }] }, |
| { type: MatBottomSheetConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [MAT_BOTTOM_SHEET_DEFAULT_OPTIONS,] }] } |
| ]; }; |
| /** @nocollapse */ MatBottomSheet.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function MatBottomSheet_Factory() { return new MatBottomSheet(core.ɵɵinject(overlay.Overlay), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(MatBottomSheet, 12), core.ɵɵinject(common.Location, 8), core.ɵɵinject(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, 8)); }, token: MatBottomSheet, providedIn: MatBottomSheetModule }); |
| return MatBottomSheet; |
| }()); |
| /** |
| * Applies default options to the bottom sheet config. |
| * @param {?} defaults Object containing the default values to which to fall back. |
| * @param {?=} config The configuration to which the defaults will be applied. |
| * @return {?} The new configuration object with defaults applied. |
| */ |
| function _applyConfigDefaults(defaults, config) { |
| return __assign({}, defaults, config); |
| } |
| |
| exports.MatBottomSheetModule = MatBottomSheetModule; |
| exports.MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = MAT_BOTTOM_SHEET_DEFAULT_OPTIONS; |
| exports.MatBottomSheet = MatBottomSheet; |
| exports.MAT_BOTTOM_SHEET_DATA = MAT_BOTTOM_SHEET_DATA; |
| exports.MatBottomSheetConfig = MatBottomSheetConfig; |
| exports.MatBottomSheetContainer = MatBottomSheetContainer; |
| exports.matBottomSheetAnimations = matBottomSheetAnimations; |
| exports.MatBottomSheetRef = MatBottomSheetRef; |
| |
| Object.defineProperty(exports, '__esModule', { value: true }); |
| |
| }))); |
| //# sourceMappingURL=material-bottom-sheet.umd.js.map |