@angular/material
Version:
Angular Material
22 lines (20 loc) • 13 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/core"),require("@angular/material/core"),require("@angular/cdk/layout"),require("@angular/animations"),require("@angular/common"),require("@angular/cdk/a11y"),require("@angular/cdk/bidi"),require("rxjs"),require("@angular/cdk/keycodes"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@angular/material/bottom-sheet",["exports","@angular/cdk/overlay","@angular/cdk/portal","@angular/core","@angular/material/core","@angular/cdk/layout","@angular/animations","@angular/common","@angular/cdk/a11y","@angular/cdk/bidi","rxjs","@angular/cdk/keycodes","rxjs/operators"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.bottomSheet={}),t.ng.cdk.overlay,t.ng.cdk.portal,t.ng.core,t.ng.material.core,t.ng.cdk.layout,t.ng.animations,t.ng.common,t.ng.cdk.a11y,t.ng.cdk.bidi,t.rxjs,t.ng.cdk.keycodes,t.rxjs.operators)}(this,(function(t,e,o,n,a,i,r,s,c,l,u,p,h){"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.
***************************************************************************** */var d=function(t,e){return(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)},m=function(){return(m=Object.assign||function t(e){for(var o,n=1,a=arguments.length;n<a;n++)for(var i in o=arguments[n])Object.prototype.hasOwnProperty.call(o,i)&&(e[i]=o[i]);return e}).apply(this,arguments)},f=new n.InjectionToken("MatBottomSheetData"),_=function _(){this.data=null,this.hasBackdrop=!0,this.disableClose=!1,this.ariaLabel=null,this.closeOnNavigation=!0,this.autoFocus=!1,this.restoreFocus=!0},y={bottomSheetState:r.trigger("state",[r.state("void, hidden",r.style({transform:"translateY(100%)"})),r.state("visible",r.style({transform:"translateY(0%)"})),r.transition("visible => void, visible => hidden",r.animate(a.AnimationDurations.COMPLEX+" "+a.AnimationCurves.ACCELERATION_CURVE)),r.transition("void => visible",r.animate(a.AnimationDurations.EXITING+" "+a.AnimationCurves.DECELERATION_CURVE))])},v=function(t){function e(e,o,a,r,s,c){var l=t.call(this)||this;return l._elementRef=e,l._changeDetectorRef=o,l._focusTrapFactory=a,l.bottomSheetConfig=c,l._animationState="void",l._animationStateChanged=new n.EventEmitter,l._elementFocusedBeforeOpened=null,l.attachDomPortal=function(t){return l._validatePortalAttached(),l._setPanelClass(),l._savePreviouslyFocusedElement(),l._portalOutlet.attachDomPortal(t)},l._document=s,l._breakpointSubscription=r.observe([i.Breakpoints.Medium,i.Breakpoints.Large,i.Breakpoints.XLarge]).subscribe((function(){l._toggleClass("mat-bottom-sheet-container-medium",r.isMatched(i.Breakpoints.Medium)),l._toggleClass("mat-bottom-sheet-container-large",r.isMatched(i.Breakpoints.Large)),l._toggleClass("mat-bottom-sheet-container-xlarge",r.isMatched(i.Breakpoints.XLarge))})),l}return function a(t,e){function o(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,t),e.prototype.attachComponentPortal=function(t){return this._validatePortalAttached(),this._setPanelClass(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachComponentPortal(t)},e.prototype.attachTemplatePortal=function(t){return this._validatePortalAttached(),this._setPanelClass(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachTemplatePortal(t)},e.prototype.enter=function(){this._destroyed||(this._animationState="visible",this._changeDetectorRef.detectChanges())},e.prototype.exit=function(){this._destroyed||(this._animationState="hidden",this._changeDetectorRef.markForCheck())},e.prototype.ngOnDestroy=function(){this._breakpointSubscription.unsubscribe(),this._destroyed=!0},e.prototype._onAnimationDone=function(t){"hidden"===t.toState?this._restoreFocus():"visible"===t.toState&&this._trapFocus(),this._animationStateChanged.emit(t)},e.prototype._onAnimationStart=function(t){this._animationStateChanged.emit(t)},e.prototype._toggleClass=function(t,e){var o=this._elementRef.nativeElement.classList;e?o.add(t):o.remove(t)},e.prototype._validatePortalAttached=function(){if(this._portalOutlet.hasAttached())throw Error("Attempting to attach bottom sheet content after content is already attached")},e.prototype._setPanelClass=function(){var t=this._elementRef.nativeElement,e=this.bottomSheetConfig.panelClass;Array.isArray(e)?e.forEach((function(e){return t.classList.add(e)})):e&&t.classList.add(e)},e.prototype._trapFocus=function(){var t=this._elementRef.nativeElement;if(this._focusTrap||(this._focusTrap=this._focusTrapFactory.create(t)),this.bottomSheetConfig.autoFocus)this._focusTrap.focusInitialElementWhenReady();else{var e=this._document.activeElement;e===t||t.contains(e)||t.focus()}},e.prototype._restoreFocus=function(){var t=this._elementFocusedBeforeOpened;if(this.bottomSheetConfig.restoreFocus&&t&&"function"==typeof t.focus){var e=this._document.activeElement,o=this._elementRef.nativeElement;e&&e!==this._document.body&&e!==o&&!o.contains(e)||t.focus()}this._focusTrap&&this._focusTrap.destroy()},e.prototype._savePreviouslyFocusedElement=function(){var t=this;this._elementFocusedBeforeOpened=this._document.activeElement,this._elementRef.nativeElement.focus&&Promise.resolve().then((function(){return t._elementRef.nativeElement.focus()}))},e.decorators=[{type:n.Component,args:[{selector:"mat-bottom-sheet-container",template:"<ng-template cdkPortalOutlet></ng-template>\r\n",changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None,animations:[y.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)"},styles:[".mat-bottom-sheet-container{padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto}.cdk-high-contrast-active .mat-bottom-sheet-container{outline:1px solid}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{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)}\n"]}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.ChangeDetectorRef},{type:c.FocusTrapFactory},{type:i.BreakpointObserver},{type:void 0,decorators:[{type:n.Optional},{type:n.Inject,args:[s.DOCUMENT]}]},{type:_}]},e.propDecorators={_portalOutlet:[{type:n.ViewChild,args:[o.CdkPortalOutlet,{static:!0}]}]},e}(o.BasePortalOutlet),g=function(){function t(){}return t.decorators=[{type:n.NgModule,args:[{imports:[e.OverlayModule,a.MatCommonModule,o.PortalModule],exports:[v,a.MatCommonModule],declarations:[v],entryComponents:[v]}]}],t}(),b=function(){function t(t,e,o){var n=this;this._overlayRef=e,this._afterDismissed=new u.Subject,this._afterOpened=new u.Subject,this.containerInstance=t,this.disableClose=t.bottomSheetConfig.disableClose,t._animationStateChanged.pipe(h.filter((function(t){return"done"===t.phaseName&&"visible"===t.toState})),h.take(1)).subscribe((function(){n._afterOpened.next(),n._afterOpened.complete()})),t._animationStateChanged.pipe(h.filter((function(t){return"done"===t.phaseName&&"hidden"===t.toState})),h.take(1)).subscribe((function(){clearTimeout(n._closeFallbackTimeout),e.dispose()})),e.detachments().pipe(h.take(1)).subscribe((function(){n._afterDismissed.next(n._result),n._afterDismissed.complete()})),u.merge(e.backdropClick(),e.keydownEvents().pipe(h.filter((function(t){return t.keyCode===p.ESCAPE})))).subscribe((function(t){n.disableClose||"keydown"===t.type&&p.hasModifierKey(t)||(t.preventDefault(),n.dismiss())}))}return t.prototype.dismiss=function(t){var e=this;this._afterDismissed.closed||(this.containerInstance._animationStateChanged.pipe(h.filter((function(t){return"start"===t.phaseName})),h.take(1)).subscribe((function(t){e._closeFallbackTimeout=setTimeout((function(){e._overlayRef.dispose()}),t.totalTime+100),e._overlayRef.detachBackdrop()})),this._result=t,this.containerInstance.exit())},t.prototype.afterDismissed=function(){return this._afterDismissed.asObservable()},t.prototype.afterOpened=function(){return this._afterOpened.asObservable()},t.prototype.backdropClick=function(){return this._overlayRef.backdropClick()},t.prototype.keydownEvents=function(){return this._overlayRef.keydownEvents()},t}(),S=new n.InjectionToken("mat-bottom-sheet-default-options"),C=function(){function t(t,e,o,n,a){this._overlay=t,this._injector=e,this._parentBottomSheet=o,this._location=n,this._defaultOptions=a,this._bottomSheetRefAtThisLevel=null}return Object.defineProperty(t.prototype,"_openedBottomSheetRef",{get:function(){var t=this._parentBottomSheet;return t?t._openedBottomSheetRef:this._bottomSheetRefAtThisLevel},set:function(t){this._parentBottomSheet?this._parentBottomSheet._openedBottomSheetRef=t:this._bottomSheetRefAtThisLevel=t},enumerable:!0,configurable:!0}),t.prototype.open=function(t,e){var a=this,i=function r(t,e){return m(m({},t),e)}
/**
* @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
*/(this._defaultOptions||new _,e),s=this._createOverlay(i),c=this._attachContainer(s,i),l=new b(c,s,this._location);if(t instanceof n.TemplateRef)c.attachTemplatePortal(new o.TemplatePortal(t,null,{$implicit:i.data,bottomSheetRef:l}));else{var u=new o.ComponentPortal(t,void 0,this._createInjector(i,l)),p=c.attachComponentPortal(u);l.instance=p.instance}return l.afterDismissed().subscribe((function(){a._openedBottomSheetRef==l&&(a._openedBottomSheetRef=null)})),this._openedBottomSheetRef?(this._openedBottomSheetRef.afterDismissed().subscribe((function(){return l.containerInstance.enter()})),this._openedBottomSheetRef.dismiss()):l.containerInstance.enter(),this._openedBottomSheetRef=l,l},t.prototype.dismiss=function(){this._openedBottomSheetRef&&this._openedBottomSheetRef.dismiss()},t.prototype.ngOnDestroy=function(){this._bottomSheetRefAtThisLevel&&this._bottomSheetRefAtThisLevel.dismiss()},t.prototype._attachContainer=function(t,e){var n=new o.PortalInjector(e&&e.viewContainerRef&&e.viewContainerRef.injector||this._injector,new WeakMap([[_,e]])),a=new o.ComponentPortal(v,e.viewContainerRef,n);return t.attach(a).instance},t.prototype._createOverlay=function(t){var o=new e.OverlayConfig({direction:t.direction,hasBackdrop:t.hasBackdrop,disposeOnNavigation:t.closeOnNavigation,maxWidth:"100%",scrollStrategy:t.scrollStrategy||this._overlay.scrollStrategies.block(),positionStrategy:this._overlay.position().global().centerHorizontally().bottom("0")});return t.backdropClass&&(o.backdropClass=t.backdropClass),this._overlay.create(o)},t.prototype._createInjector=function(t,e){var n=t&&t.viewContainerRef&&t.viewContainerRef.injector,a=new WeakMap([[b,e],[f,t.data]]);return!t.direction||n&&n.get(l.Directionality,null)||a.set(l.Directionality,{value:t.direction,change:u.of()}),new o.PortalInjector(n||this._injector,a)},t.decorators=[{type:n.Injectable,args:[{providedIn:g}]}],t.ctorParameters=function(){return[{type:e.Overlay},{type:n.Injector},{type:t,decorators:[{type:n.Optional},{type:n.SkipSelf}]},{type:s.Location,decorators:[{type:n.Optional}]},{type:_,decorators:[{type:n.Optional},{type:n.Inject,args:[S]}]}]},t.ɵprov=n.ɵɵdefineInjectable({factory:function o(){return new t(n.ɵɵinject(e.Overlay),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(t,12),n.ɵɵinject(s.Location,8),n.ɵɵinject(S,8))},token:t,providedIn:g}),t}();t.MAT_BOTTOM_SHEET_DATA=f,t.MAT_BOTTOM_SHEET_DEFAULT_OPTIONS=S,t.MatBottomSheet=C,t.MatBottomSheetConfig=_,t.MatBottomSheetContainer=v,t.MatBottomSheetModule=g,t.MatBottomSheetRef=b,t.matBottomSheetAnimations=y,Object.defineProperty(t,"__esModule",{value:!0})}));