@angular/material
Version:
Angular Material
15 lines • 11.9 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/common"),require("@angular/core"),require("@angular/material/core"),require("tslib"),require("@angular/cdk/layout"),require("@angular/animations"),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/common","@angular/core","@angular/material/core","tslib","@angular/cdk/layout","@angular/animations","@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.common,t.ng.core,t.ng.material.core,t.tslib,t.ng.cdk.layout,t.ng.animations,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,h,p,d){"use strict";
/**
* @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
*/var m=new a.InjectionToken("MatBottomSheetData"),f=function f(){this.data=null,this.hasBackdrop=!0,this.disableClose=!1,this.ariaLabel=null,this.closeOnNavigation=!0,this.autoFocus=!1,this.restoreFocus=!0},_={bottomSheetState:c.trigger("state",[c.state("void, hidden",c.style({transform:"translateY(100%)"})),c.state("visible",c.style({transform:"translateY(0%)"})),c.transition("visible => void, visible => hidden",c.animate(i.AnimationDurations.COMPLEX+" "+i.AnimationCurves.ACCELERATION_CURVE)),c.transition("void => visible",c.animate(i.AnimationDurations.EXITING+" "+i.AnimationCurves.DECELERATION_CURVE))])},y=function(t){function e(e,o,n,i,r,c){var l=t.call(this)||this;return l._elementRef=e,l._changeDetectorRef=o,l._focusTrapFactory=n,l.bottomSheetConfig=c,l._animationState="void",l._animationStateChanged=new a.EventEmitter,l._elementFocusedBeforeOpened=null,l.attachDomPortal=function(t){return l._validatePortalAttached(),l._setPanelClass(),l._savePreviouslyFocusedElement(),l._portalOutlet.attachDomPortal(t)},l._document=r,l._breakpointSubscription=i.observe([s.Breakpoints.Medium,s.Breakpoints.Large,s.Breakpoints.XLarge]).subscribe((function(){l._toggleClass("mat-bottom-sheet-container-medium",i.isMatched(s.Breakpoints.Medium)),l._toggleClass("mat-bottom-sheet-container-large",i.isMatched(s.Breakpoints.Large)),l._toggleClass("mat-bottom-sheet-container-xlarge",i.isMatched(s.Breakpoints.XLarge))})),l}return r.__extends(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:a.Component,args:[{selector:"mat-bottom-sheet-container",template:"<ng-template cdkPortalOutlet></ng-template>\r\n",changeDetection:a.ChangeDetectionStrategy.OnPush,encapsulation:a.ViewEncapsulation.None,animations:[_.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:a.ElementRef},{type:a.ChangeDetectorRef},{type:l.FocusTrapFactory},{type:s.BreakpointObserver},{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[n.DOCUMENT]}]},{type:f}]},e.propDecorators={_portalOutlet:[{type:a.ViewChild,args:[o.CdkPortalOutlet,{static:!0}]}]},e}(o.BasePortalOutlet),g=function(){function t(){}return t.decorators=[{type:a.NgModule,args:[{imports:[n.CommonModule,e.OverlayModule,i.MatCommonModule,o.PortalModule],exports:[y,i.MatCommonModule],declarations:[y],entryComponents:[y]}]}],t}(),v=function(){function t(t,e,o){var n=this;this._overlayRef=e,this._afterDismissed=new h.Subject,this._afterOpened=new h.Subject,this.containerInstance=t,this.disableClose=t.bottomSheetConfig.disableClose,t._animationStateChanged.pipe(d.filter((function(t){return"done"===t.phaseName&&"visible"===t.toState})),d.take(1)).subscribe((function(){n._afterOpened.next(),n._afterOpened.complete()})),t._animationStateChanged.pipe(d.filter((function(t){return"done"===t.phaseName&&"hidden"===t.toState})),d.take(1)).subscribe((function(){clearTimeout(n._closeFallbackTimeout),e.dispose()})),e.detachments().pipe(d.take(1)).subscribe((function(){n._afterDismissed.next(n._result),n._afterDismissed.complete()})),h.merge(e.backdropClick(),e.keydownEvents().pipe(d.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(d.filter((function(t){return"start"===t.phaseName})),d.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}(),b=new a.InjectionToken("mat-bottom-sheet-default-options"),S=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 n=this,i=function s(t,e){return r.__assign(r.__assign({},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 f,e),c=this._createOverlay(i),l=this._attachContainer(c,i),u=new v(l,c,this._location);if(t instanceof a.TemplateRef)l.attachTemplatePortal(new o.TemplatePortal(t,null,{$implicit:i.data,bottomSheetRef:u}));else{var h=new o.ComponentPortal(t,void 0,this._createInjector(i,u)),p=l.attachComponentPortal(h);u.instance=p.instance}return u.afterDismissed().subscribe((function(){n._openedBottomSheetRef==u&&(n._openedBottomSheetRef=null)})),this._openedBottomSheetRef?(this._openedBottomSheetRef.afterDismissed().subscribe((function(){return u.containerInstance.enter()})),this._openedBottomSheetRef.dismiss()):u.containerInstance.enter(),this._openedBottomSheetRef=u,u},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([[f,e]])),a=new o.ComponentPortal(y,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([[v,e],[m,t.data]]);return!t.direction||n&&n.get(u.Directionality,null)||a.set(u.Directionality,{value:t.direction,change:h.of()}),new o.PortalInjector(n||this._injector,a)},t.decorators=[{type:a.Injectable,args:[{providedIn:g}]}],t.ctorParameters=function(){return[{type:e.Overlay},{type:a.Injector},{type:t,decorators:[{type:a.Optional},{type:a.SkipSelf}]},{type:n.Location,decorators:[{type:a.Optional}]},{type:f,decorators:[{type:a.Optional},{type:a.Inject,args:[b]}]}]},t.ɵprov=a.ɵɵdefineInjectable({factory:function o(){return new t(a.ɵɵinject(e.Overlay),a.ɵɵinject(a.INJECTOR),a.ɵɵinject(t,12),a.ɵɵinject(n.Location,8),a.ɵɵinject(b,8))},token:t,providedIn:g}),t}();t.MAT_BOTTOM_SHEET_DATA=m,t.MAT_BOTTOM_SHEET_DEFAULT_OPTIONS=b,t.MatBottomSheet=S,t.MatBottomSheetConfig=f,t.MatBottomSheetContainer=y,t.MatBottomSheetModule=g,t.MatBottomSheetRef=v,t.matBottomSheetAnimations=_,Object.defineProperty(t,"__esModule",{value:!0})}));