blob: 0cd102e87867c43a62a31a35a278649b3c963d22 [file] [log] [blame]
/**
* @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(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/animations"),require("@angular/core"),require("@angular/common"),require("@angular/cdk/portal"),require("@angular/cdk/a11y"),require("@angular/cdk/keycodes"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/bidi"),require("@angular/cdk/overlay"),require("@angular/material/core")):"function"==typeof define&&define.amd?define("@angular/material/dialog",["exports","@angular/animations","@angular/core","@angular/common","@angular/cdk/portal","@angular/cdk/a11y","@angular/cdk/keycodes","rxjs","rxjs/operators","@angular/cdk/bidi","@angular/cdk/overlay","@angular/material/core"],e):e((t.ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.dialog={}),t.ng.animations,t.ng.core,t.ng.common,t.ng.cdk.portal,t.ng.cdk.a11y,t.ng.cdk.keycodes,t.rxjs,t.rxjs.operators,t.ng.cdk.bidi,t.ng.cdk.overlay,t.ng.material.core)}(this,function(t,e,o,a,i,n,r,l,s,c,u,d){"use strict";function p(t,e){function o(){this.constructor=t}y(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function g(){throw Error("Attempting to attach dialog content after content is already attached")}function h(t){return function(){return t.scrollStrategies.block()}}function f(t){return function(){return t.scrollStrategies.block()}}function m(t,e){return b({},e,t)}function _(t,e){for(var o=t.nativeElement.parentElement;o&&!o.classList.contains("mat-dialog-container");)o=o.parentElement;return o?e.find(function(t){return t.id===o.id}):null}var y=function(t,e){return(y=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)},b=function(){return b=Object.assign||function(t){for(var e,o=1,a=arguments.length;o<a;o++){e=arguments[o];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},b.apply(this,arguments)},v=function(){function t(){this.role="dialog",this.panelClass="",this.hasBackdrop=!0,this.backdropClass="",this.disableClose=!1,this.width="",this.height="",this.maxWidth="80vw",this.data=null,this.ariaDescribedBy=null,this.ariaLabelledBy=null,this.ariaLabel=null,this.autoFocus=!0,this.restoreFocus=!0,this.closeOnNavigation=!0}return t}(),C=[e.state("void, exit",e.style({opacity:0,transform:"scale(0.7)"})),e.state("enter",e.style({transform:"none"})),e.transition("* => enter",e.animate("150ms cubic-bezier(0, 0, 0.2, 1)",e.style({transform:"none",opacity:1}))),e.transition("* => void, * => exit",e.animate("75ms cubic-bezier(0.4, 0.0, 0.2, 1)",e.style({opacity:0})))],D={dialogContainer:e.trigger("dialogContainer",C),slideDialog:e.trigger("slideDialog",C)},O=function(t){function e(e,a,i,n,r){var l=t.call(this)||this;return l._elementRef=e,l._focusTrapFactory=a,l._changeDetectorRef=i,l._document=n,l._config=r,l._elementFocusedBeforeDialogWasOpened=null,l._state="enter",l._animationStateChanged=new o.EventEmitter,l._ariaLabelledBy=r.ariaLabelledBy||null,l}return p(e,t),e.prototype.attachComponentPortal=function(t){return this._portalOutlet.hasAttached()&&g(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachComponentPortal(t)},e.prototype.attachTemplatePortal=function(t){return this._portalOutlet.hasAttached()&&g(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachTemplatePortal(t)},e.prototype._trapFocus=function(){var t=this._elementRef.nativeElement;if(this._focusTrap||(this._focusTrap=this._focusTrapFactory.create(t)),this._config.autoFocus)this._focusTrap.focusInitialElementWhenReady();else{var e=this._document.activeElement;e===t||t.contains(e)||t.focus()}},e.prototype._restoreFocus=function(){var t=this._elementFocusedBeforeDialogWasOpened;this._config.restoreFocus&&t&&"function"==typeof t.focus&&t.focus(),this._focusTrap&&this._focusTrap.destroy()},e.prototype._savePreviouslyFocusedElement=function(){var t=this;this._document&&(this._elementFocusedBeforeDialogWasOpened=this._document.activeElement,this._elementRef.nativeElement.focus&&Promise.resolve().then(function(){return t._elementRef.nativeElement.focus()}))},e.prototype._onAnimationDone=function(t){"enter"===t.toState?this._trapFocus():"exit"===t.toState&&this._restoreFocus(),this._animationStateChanged.emit(t)},e.prototype._onAnimationStart=function(t){this._animationStateChanged.emit(t)},e.prototype._startExitAnimation=function(){this._state="exit",this._changeDetectorRef.markForCheck()},e.decorators=[{type:o.Component,args:[{selector:"mat-dialog-container",template:"<ng-template cdkPortalOutlet></ng-template>",styles:[".mat-dialog-container{display:block;padding:24px;border-radius:4px;box-sizing:border-box;overflow:auto;outline:0;width:100%;height:100%;min-height:inherit;max-height:inherit}@media (-ms-high-contrast:active){.mat-dialog-container{outline:solid 1px}}.mat-dialog-content{display:block;margin:0 -24px;padding:0 24px;max-height:65vh;overflow:auto;-webkit-overflow-scrolling:touch}.mat-dialog-title{margin:0 0 20px;display:block}.mat-dialog-actions{padding:8px 0;display:flex;flex-wrap:wrap;min-height:52px;align-items:center;margin-bottom:-24px}.mat-dialog-actions[align=end]{justify-content:flex-end}.mat-dialog-actions[align=center]{justify-content:center}.mat-dialog-actions .mat-button+.mat-button,.mat-dialog-actions .mat-button+.mat-raised-button,.mat-dialog-actions .mat-raised-button+.mat-button,.mat-dialog-actions .mat-raised-button+.mat-raised-button{margin-left:8px}[dir=rtl] .mat-dialog-actions .mat-button+.mat-button,[dir=rtl] .mat-dialog-actions .mat-button+.mat-raised-button,[dir=rtl] .mat-dialog-actions .mat-raised-button+.mat-button,[dir=rtl] .mat-dialog-actions .mat-raised-button+.mat-raised-button{margin-left:0;margin-right:8px}"],encapsulation:o.ViewEncapsulation.None,changeDetection:o.ChangeDetectionStrategy.Default,animations:[D.dialogContainer],host:{class:"mat-dialog-container",tabindex:"-1","aria-modal":"true","[attr.id]":"_id","[attr.role]":"_config.role","[attr.aria-labelledby]":"_config.ariaLabel ? null : _ariaLabelledBy","[attr.aria-label]":"_config.ariaLabel","[attr.aria-describedby]":"_config.ariaDescribedBy || null","[@dialogContainer]":"_state","(@dialogContainer.start)":"_onAnimationStart($event)","(@dialogContainer.done)":"_onAnimationDone($event)"}}]}],e.ctorParameters=function(){return[{type:o.ElementRef},{type:n.FocusTrapFactory},{type:o.ChangeDetectorRef},{type:void 0,decorators:[{type:o.Optional},{type:o.Inject,args:[a.DOCUMENT]}]},{type:v}]},e.propDecorators={_portalOutlet:[{type:o.ViewChild,args:[i.CdkPortalOutlet,{static:!0}]}]},e}(i.BasePortalOutlet),A=0,R=function(){function t(t,e,o,a){var i=this;void 0===a&&(a="mat-dialog-"+A++),this._overlayRef=t,this._containerInstance=e,this.id=a,this.disableClose=this._containerInstance._config.disableClose,this._afterOpened=new l.Subject,this._afterClosed=new l.Subject,this._beforeClosed=new l.Subject,e._id=a,e._animationStateChanged.pipe(s.filter(function(t){return"done"===t.phaseName&&"enter"===t.toState}),s.take(1)).subscribe(function(){i._afterOpened.next(),i._afterOpened.complete()}),e._animationStateChanged.pipe(s.filter(function(t){return"done"===t.phaseName&&"exit"===t.toState}),s.take(1)).subscribe(function(){clearTimeout(i._closeFallbackTimeout),i._overlayRef.dispose()}),t.detachments().subscribe(function(){i._beforeClosed.next(i._result),i._beforeClosed.complete(),i._afterClosed.next(i._result),i._afterClosed.complete(),i.componentInstance=null,i._overlayRef.dispose()}),t.keydownEvents().pipe(s.filter(function(t){return t.keyCode===r.ESCAPE&&!i.disableClose&&!r.hasModifierKey(t)})).subscribe(function(t){t.preventDefault(),i.close()})}return t.prototype.close=function(t){var e=this;this._result=t,this._containerInstance._animationStateChanged.pipe(s.filter(function(t){return"start"===t.phaseName}),s.take(1)).subscribe(function(o){e._beforeClosed.next(t),e._beforeClosed.complete(),e._overlayRef.detachBackdrop(),e._closeFallbackTimeout=setTimeout(function(){e._overlayRef.dispose()},o.totalTime+100)}),this._containerInstance._startExitAnimation()},t.prototype.afterOpened=function(){return this._afterOpened.asObservable()},t.prototype.afterClosed=function(){return this._afterClosed.asObservable()},t.prototype.beforeClosed=function(){return this._beforeClosed.asObservable()},t.prototype.backdropClick=function(){return this._overlayRef.backdropClick()},t.prototype.keydownEvents=function(){return this._overlayRef.keydownEvents()},t.prototype.updatePosition=function(t){var e=this._getPositionStrategy();return t&&(t.left||t.right)?t.left?e.left(t.left):e.right(t.right):e.centerHorizontally(),t&&(t.top||t.bottom)?t.top?e.top(t.top):e.bottom(t.bottom):e.centerVertically(),this._overlayRef.updatePosition(),this},t.prototype.updateSize=function(t,e){return void 0===t&&(t=""),void 0===e&&(e=""),this._getPositionStrategy().width(t).height(e),this._overlayRef.updatePosition(),this},t.prototype.addPanelClass=function(t){return this._overlayRef.addPanelClass(t),this},t.prototype.removePanelClass=function(t){return this._overlayRef.removePanelClass(t),this},t.prototype.afterOpen=function(){return this.afterOpened()},t.prototype.beforeClose=function(){return this.beforeClosed()},t.prototype._getPositionStrategy=function(){return this._overlayRef.getConfig().positionStrategy},t}(),k=new o.InjectionToken("MatDialogData"),T=new o.InjectionToken("mat-dialog-default-options"),x=new o.InjectionToken("mat-dialog-scroll-strategy"),w={provide:x,deps:[u.Overlay],useFactory:f},P=function(){function t(t,e,o,a,i,n,r){var c=this;this._overlay=t,this._injector=e,this._location=o,this._defaultOptions=a,this._parentDialog=n,this._overlayContainer=r,this._openDialogsAtThisLevel=[],this._afterAllClosedAtThisLevel=new l.Subject,this._afterOpenedAtThisLevel=new l.Subject,this._ariaHiddenElements=new Map,this.afterAllClosed=l.defer(function(){return c.openDialogs.length?c._afterAllClosed:c._afterAllClosed.pipe(s.startWith(void 0))}),this._scrollStrategy=i}return Object.defineProperty(t.prototype,"openDialogs",{get:function(){return this._parentDialog?this._parentDialog.openDialogs:this._openDialogsAtThisLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"afterOpened",{get:function(){return this._parentDialog?this._parentDialog.afterOpened:this._afterOpenedAtThisLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"afterOpen",{get:function(){return this.afterOpened},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_afterAllClosed",{get:function(){var t=this._parentDialog;return t?t._afterAllClosed:this._afterAllClosedAtThisLevel},enumerable:!0,configurable:!0}),t.prototype.open=function(t,e){var o=this;if(e=m(e,this._defaultOptions||new v),e.id&&this.getDialogById(e.id))throw Error('Dialog with id "'+e.id+'" exists already. The dialog id must be unique.');var a=this._createOverlay(e),i=this._attachDialogContainer(a,e),n=this._attachDialogContent(t,i,a,e);return this.openDialogs.length||this._hideNonDialogContentFromAssistiveTechnology(),this.openDialogs.push(n),n.afterClosed().subscribe(function(){return o._removeOpenDialog(n)}),this.afterOpened.next(n),n},t.prototype.closeAll=function(){this._closeDialogs(this.openDialogs)},t.prototype.getDialogById=function(t){return this.openDialogs.find(function(e){return e.id===t})},t.prototype.ngOnDestroy=function(){this._closeDialogs(this._openDialogsAtThisLevel),this._afterAllClosedAtThisLevel.complete(),this._afterOpenedAtThisLevel.complete()},t.prototype._createOverlay=function(t){var e=this._getOverlayConfig(t);return this._overlay.create(e)},t.prototype._getOverlayConfig=function(t){var e=new u.OverlayConfig({positionStrategy:this._overlay.position().global(),scrollStrategy:t.scrollStrategy||this._scrollStrategy(),panelClass:t.panelClass,hasBackdrop:t.hasBackdrop,direction:t.direction,minWidth:t.minWidth,minHeight:t.minHeight,maxWidth:t.maxWidth,maxHeight:t.maxHeight,disposeOnNavigation:t.closeOnNavigation});return t.backdropClass&&(e.backdropClass=t.backdropClass),e},t.prototype._attachDialogContainer=function(t,e){var o=e&&e.viewContainerRef&&e.viewContainerRef.injector,a=new i.PortalInjector(o||this._injector,new WeakMap([[v,e]])),n=new i.ComponentPortal(O,e.viewContainerRef,a);return t.attach(n).instance},t.prototype._attachDialogContent=function(t,e,a,n){var r=new R(a,e,this._location,n.id);if(n.hasBackdrop&&a.backdropClick().subscribe(function(){r.disableClose||r.close()}),t instanceof o.TemplateRef)e.attachTemplatePortal(new i.TemplatePortal(t,null,{$implicit:n.data,dialogRef:r}));else{var l=this._createInjector(n,r,e),s=e.attachComponentPortal(new i.ComponentPortal(t,void 0,l));r.componentInstance=s.instance}return r.updateSize(n.width,n.height).updatePosition(n.position),r},t.prototype._createInjector=function(t,e,o){var a=t&&t.viewContainerRef&&t.viewContainerRef.injector,n=new WeakMap([[O,o],[k,t.data],[R,e]]);return!t.direction||a&&a.get(c.Directionality,null)||n.set(c.Directionality,{value:t.direction,change:l.of()}),new i.PortalInjector(a||this._injector,n)},t.prototype._removeOpenDialog=function(t){var e=this.openDialogs.indexOf(t);e>-1&&(this.openDialogs.splice(e,1),this.openDialogs.length||(this._ariaHiddenElements.forEach(function(t,e){t?e.setAttribute("aria-hidden",t):e.removeAttribute("aria-hidden")}),this._ariaHiddenElements.clear(),this._afterAllClosed.next()))},t.prototype._hideNonDialogContentFromAssistiveTechnology=function(){var t=this._overlayContainer.getContainerElement();if(t.parentElement)for(var e=t.parentElement.children,o=e.length-1;o>-1;o--){var a=e[o];a===t||"SCRIPT"===a.nodeName||"STYLE"===a.nodeName||a.hasAttribute("aria-live")||(this._ariaHiddenElements.set(a,a.getAttribute("aria-hidden")),a.setAttribute("aria-hidden","true"))}},t.prototype._closeDialogs=function(t){for(var e=t.length;e--;)t[e].close()},t.decorators=[{type:o.Injectable}],t.ctorParameters=function(){return[{type:u.Overlay},{type:o.Injector},{type:a.Location,decorators:[{type:o.Optional}]},{type:v,decorators:[{type:o.Optional},{type:o.Inject,args:[T]}]},{type:void 0,decorators:[{type:o.Inject,args:[x]}]},{type:t,decorators:[{type:o.Optional},{type:o.SkipSelf}]},{type:u.OverlayContainer}]},t}(),E=0,S=function(){function t(t,e,o){this.dialogRef=t,this._elementRef=e,this._dialog=o}return t.prototype.ngOnInit=function(){this.dialogRef||(this.dialogRef=_(this._elementRef,this._dialog.openDialogs))},t.prototype.ngOnChanges=function(t){var e=t._matDialogClose||t._matDialogCloseResult;e&&(this.dialogResult=e.currentValue)},t.decorators=[{type:o.Directive,args:[{selector:"button[mat-dialog-close], button[matDialogClose]",exportAs:"matDialogClose",host:{"(click)":"dialogRef.close(dialogResult)","[attr.aria-label]":"ariaLabel || null",type:"button"}}]}],t.ctorParameters=function(){return[{type:R,decorators:[{type:o.Optional}]},{type:o.ElementRef},{type:P}]},t.propDecorators={ariaLabel:[{type:o.Input,args:["aria-label"]}],dialogResult:[{type:o.Input,args:["mat-dialog-close"]}],_matDialogClose:[{type:o.Input,args:["matDialogClose"]}]},t}(),j=function(){function t(t,e,o){this._dialogRef=t,this._elementRef=e,this._dialog=o,this.id="mat-dialog-title-"+E++}return t.prototype.ngOnInit=function(){var t=this;this._dialogRef||(this._dialogRef=_(this._elementRef,this._dialog.openDialogs)),this._dialogRef&&Promise.resolve().then(function(){var e=t._dialogRef._containerInstance;e&&!e._ariaLabelledBy&&(e._ariaLabelledBy=t.id)})},t.decorators=[{type:o.Directive,args:[{selector:"[mat-dialog-title], [matDialogTitle]",exportAs:"matDialogTitle",host:{class:"mat-dialog-title","[id]":"id"}}]}],t.ctorParameters=function(){return[{type:R,decorators:[{type:o.Optional}]},{type:o.ElementRef},{type:P}]},t.propDecorators={id:[{type:o.Input}]},t}(),I=function(){function t(){}return t.decorators=[{type:o.Directive,args:[{selector:"[mat-dialog-content], mat-dialog-content, [matDialogContent]",host:{class:"mat-dialog-content"}}]}],t}(),L=function(){function t(){}return t.decorators=[{type:o.Directive,args:[{selector:"[mat-dialog-actions], mat-dialog-actions, [matDialogActions]",host:{class:"mat-dialog-actions"}}]}],t}(),M=function(){function t(){}return t.decorators=[{type:o.NgModule,args:[{imports:[a.CommonModule,u.OverlayModule,i.PortalModule,d.MatCommonModule],exports:[O,S,j,I,L,d.MatCommonModule],declarations:[O,S,j,L,I],providers:[P,w],entryComponents:[O]}]}],t}();t.MatDialogModule=M,t.MAT_DIALOG_SCROLL_STRATEGY_FACTORY=h,t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY=f,t.MAT_DIALOG_DATA=k,t.MAT_DIALOG_DEFAULT_OPTIONS=T,t.MAT_DIALOG_SCROLL_STRATEGY=x,t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER=w,t.MatDialog=P,t.throwMatDialogContentAlreadyAttachedError=g,t.MatDialogContainer=O,t.MatDialogClose=S,t.MatDialogTitle=j,t.MatDialogContent=I,t.MatDialogActions=L,t.MatDialogConfig=v,t.MatDialogRef=R,t.matDialogAnimations=D,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=material-dialog.umd.min.js.map