@angular/material
Version:
Angular Material
51 lines (49 loc) • 18.9 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/bidi"),require("@angular/common"),require("rxjs"),require("rxjs/operators"),require("@angular/animations"),require("@angular/cdk/a11y"),require("@angular/cdk/keycodes")):"function"==typeof define&&define.amd?define("@angular/material/dialog",["exports","@angular/cdk/overlay","@angular/cdk/portal","@angular/core","@angular/material/core","@angular/cdk/bidi","@angular/common","rxjs","rxjs/operators","@angular/animations","@angular/cdk/a11y","@angular/cdk/keycodes"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.dialog={}),t.ng.cdk.overlay,t.ng.cdk.portal,t.ng.core,t.ng.material.core,t.ng.cdk.bidi,t.ng.common,t.rxjs,t.rxjs.operators,t.ng.animations,t.ng.cdk.a11y,t.ng.cdk.keycodes)}(this,(function(t,e,o,a,i,n,r,s,l,c,p,u){"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)},h=function(){return(h=Object.assign||function t(e){for(var o,a=1,i=arguments.length;a<i;a++)for(var n in o=arguments[a])Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n]);return e}).apply(this,arguments)},g=function g(){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},f={dialogContainer:c.trigger("dialogContainer",[c.state("void, exit",c.style({opacity:0,transform:"scale(0.7)"})),c.state("enter",c.style({transform:"none"})),c.transition("* => enter",c.animate("150ms cubic-bezier(0, 0, 0.2, 1)",c.style({transform:"none",opacity:1}))),c.transition("* => void, * => exit",c.animate("75ms cubic-bezier(0.4, 0.0, 0.2, 1)",c.style({opacity:0})))])};
/**
* @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 m(){throw Error("Attempting to attach dialog content after content is already attached")}var _=function(t){function e(e,o,i,n,r){var s=t.call(this)||this;return s._elementRef=e,s._focusTrapFactory=o,s._changeDetectorRef=i,s._config=r,s._elementFocusedBeforeDialogWasOpened=null,s._state="enter",s._animationStateChanged=new a.EventEmitter,s.attachDomPortal=function(t){return s._portalOutlet.hasAttached()&&m(),s._savePreviouslyFocusedElement(),s._portalOutlet.attachDomPortal(t)},s._ariaLabelledBy=r.ariaLabelledBy||null,s._document=n,s}return function i(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._portalOutlet.hasAttached()&&m(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachComponentPortal(t)},e.prototype.attachTemplatePortal=function(t){return this._portalOutlet.hasAttached()&&m(),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;if(this._config.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._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:a.Component,args:[{selector:"mat-dialog-container",template:"<ng-template cdkPortalOutlet></ng-template>\n",encapsulation:a.ViewEncapsulation.None,changeDetection:a.ChangeDetectionStrategy.Default,animations:[f.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)"},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}.cdk-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-base+.mat-button-base,.mat-dialog-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:8px}[dir=rtl] .mat-dialog-actions .mat-button-base+.mat-button-base,[dir=rtl] .mat-dialog-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:0;margin-right:8px}\n"]}]}],e.ctorParameters=function(){return[{type:a.ElementRef},{type:p.FocusTrapFactory},{type:a.ChangeDetectorRef},{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[r.DOCUMENT]}]},{type:g}]},e.propDecorators={_portalOutlet:[{type:a.ViewChild,args:[o.CdkPortalOutlet,{static:!0}]}]},e}(o.BasePortalOutlet),y=0,v=function(){function t(t,e,o){var a=this;void 0===o&&(o="mat-dialog-"+y++),this._overlayRef=t,this._containerInstance=e,this.id=o,this.disableClose=this._containerInstance._config.disableClose,this._afterOpened=new s.Subject,this._afterClosed=new s.Subject,this._beforeClosed=new s.Subject,this._state=0,e._id=o,e._animationStateChanged.pipe(l.filter((function(t){return"done"===t.phaseName&&"enter"===t.toState})),l.take(1)).subscribe((function(){a._afterOpened.next(),a._afterOpened.complete()})),e._animationStateChanged.pipe(l.filter((function(t){return"done"===t.phaseName&&"exit"===t.toState})),l.take(1)).subscribe((function(){clearTimeout(a._closeFallbackTimeout),a._overlayRef.dispose()})),t.detachments().subscribe((function(){a._beforeClosed.next(a._result),a._beforeClosed.complete(),a._afterClosed.next(a._result),a._afterClosed.complete(),a.componentInstance=null,a._overlayRef.dispose()})),t.keydownEvents().pipe(l.filter((function(t){return t.keyCode===u.ESCAPE&&!a.disableClose&&!u.hasModifierKey(t)}))).subscribe((function(t){t.preventDefault(),a.close()}))}return t.prototype.close=function(t){var e=this;this._result=t,this._containerInstance._animationStateChanged.pipe(l.filter((function(t){return"start"===t.phaseName})),l.take(1)).subscribe((function(o){e._beforeClosed.next(t),e._beforeClosed.complete(),e._state=2,e._overlayRef.detachBackdrop(),e._closeFallbackTimeout=setTimeout((function(){e._overlayRef.dispose()}),o.totalTime+100)})),this._containerInstance._startExitAnimation(),this._state=1},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.getState=function(){return this._state},t.prototype._getPositionStrategy=function(){return this._overlayRef.getConfig().positionStrategy},t}(),b=new a.InjectionToken("MatDialogData"),C=new a.InjectionToken("mat-dialog-default-options"),D=new a.InjectionToken("mat-dialog-scroll-strategy");
/**
* @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 O(t){return function(){return t.scrollStrategies.block()}}var A={provide:D,deps:[e.Overlay],useFactory:O},R=function(){function t(t,e,o,a,i,n,r){var c=this;this._overlay=t,this._injector=e,this._defaultOptions=a,this._parentDialog=n,this._overlayContainer=r,this._openDialogsAtThisLevel=[],this._afterAllClosedAtThisLevel=new s.Subject,this._afterOpenedAtThisLevel=new s.Subject,this._ariaHiddenElements=new Map,this.afterAllClosed=s.defer((function(){return c.openDialogs.length?c._afterAllClosed:c._afterAllClosed.pipe(l.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,"_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=function a(t,e){return h(h({},e),t)}
/**
* @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
*/(e,this._defaultOptions||new g)).id&&this.getDialogById(e.id))throw Error('Dialog with id "'+e.id+'" exists already. The dialog id must be unique.');var i=this._createOverlay(e),n=this._attachDialogContainer(i,e),r=this._attachDialogContent(t,n,i,e);return this.openDialogs.length||this._hideNonDialogContentFromAssistiveTechnology(),this.openDialogs.push(r),r.afterClosed().subscribe((function(){return o._removeOpenDialog(r)})),this.afterOpened.next(r),r},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 o=new e.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&&(o.backdropClass=t.backdropClass),o},t.prototype._attachDialogContainer=function(t,e){var i=a.Injector.create({parent:e&&e.viewContainerRef&&e.viewContainerRef.injector||this._injector,providers:[{provide:g,useValue:e}]}),n=new o.ComponentPortal(_,e.viewContainerRef,i,e.componentFactoryResolver);return t.attach(n).instance},t.prototype._attachDialogContent=function(t,e,i,n){var r=new v(i,e,n.id);if(n.hasBackdrop&&i.backdropClick().subscribe((function(){r.disableClose||r.close()})),t instanceof a.TemplateRef)e.attachTemplatePortal(new o.TemplatePortal(t,null,{$implicit:n.data,dialogRef:r}));else{var s=this._createInjector(n,r,e),l=e.attachComponentPortal(new o.ComponentPortal(t,n.viewContainerRef,s));r.componentInstance=l.instance}return r.updateSize(n.width,n.height).updatePosition(n.position),r},t.prototype._createInjector=function(t,e,o){var i=t&&t.viewContainerRef&&t.viewContainerRef.injector,r=[{provide:_,useValue:o},{provide:b,useValue:t.data},{provide:v,useValue:e}];return!t.direction||i&&i.get(n.Directionality,null)||r.push({provide:n.Directionality,useValue:{value:t.direction,change:s.of()}}),a.Injector.create({parent:i||this._injector,providers:r})},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:a.Injectable}],t.ctorParameters=function(){return[{type:e.Overlay},{type:a.Injector},{type:r.Location,decorators:[{type:a.Optional}]},{type:g,decorators:[{type:a.Optional},{type:a.Inject,args:[C]}]},{type:void 0,decorators:[{type:a.Inject,args:[D]}]},{type:t,decorators:[{type:a.Optional},{type:a.SkipSelf}]},{type:e.OverlayContainer}]},t}(),k=0,T=function(){function t(t,e,o){this.dialogRef=t,this._elementRef=e,this._dialog=o,this.type="button"}return t.prototype.ngOnInit=function(){this.dialogRef||(this.dialogRef=S(this._elementRef,this._dialog.openDialogs))},t.prototype.ngOnChanges=function(t){var e=t._matDialogClose||t._matDialogCloseResult;e&&(this.dialogResult=e.currentValue)},t.decorators=[{type:a.Directive,args:[{selector:"[mat-dialog-close], [matDialogClose]",exportAs:"matDialogClose",host:{"(click)":"dialogRef.close(dialogResult)","[attr.aria-label]":"ariaLabel || null","[attr.type]":"type"}}]}],t.ctorParameters=function(){return[{type:v,decorators:[{type:a.Optional}]},{type:a.ElementRef},{type:R}]},t.propDecorators={ariaLabel:[{type:a.Input,args:["aria-label"]}],type:[{type:a.Input}],dialogResult:[{type:a.Input,args:["mat-dialog-close"]}],_matDialogClose:[{type:a.Input,args:["matDialogClose"]}]},t}(),x=function(){function t(t,e,o){this._dialogRef=t,this._elementRef=e,this._dialog=o,this.id="mat-dialog-title-"+k++}return t.prototype.ngOnInit=function(){var t=this;this._dialogRef||(this._dialogRef=S(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:a.Directive,args:[{selector:"[mat-dialog-title], [matDialogTitle]",exportAs:"matDialogTitle",host:{class:"mat-dialog-title","[id]":"id"}}]}],t.ctorParameters=function(){return[{type:v,decorators:[{type:a.Optional}]},{type:a.ElementRef},{type:R}]},t.propDecorators={id:[{type:a.Input}]},t}(),E=function(){function t(){}return t.decorators=[{type:a.Directive,args:[{selector:"[mat-dialog-content], mat-dialog-content, [matDialogContent]",host:{class:"mat-dialog-content"}}]}],t}(),P=function(){function t(){}return t.decorators=[{type:a.Directive,args:[{selector:"[mat-dialog-actions], mat-dialog-actions, [matDialogActions]",host:{class:"mat-dialog-actions"}}]}],t}();function S(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}
/**
* @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 w=function(){function t(){}return t.decorators=[{type:a.NgModule,args:[{imports:[e.OverlayModule,o.PortalModule,i.MatCommonModule],exports:[_,T,x,E,P,i.MatCommonModule],declarations:[_,T,x,P,E],providers:[R,A],entryComponents:[_]}]}],t}();
/**
* @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
*/t.MAT_DIALOG_DATA=b,t.MAT_DIALOG_DEFAULT_OPTIONS=C,t.MAT_DIALOG_SCROLL_STRATEGY=D,t.MAT_DIALOG_SCROLL_STRATEGY_FACTORY=function j(t){return function(){return t.scrollStrategies.block()}},t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER=A,t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY=O,t.MatDialog=R,t.MatDialogActions=P,t.MatDialogClose=T,t.MatDialogConfig=g,t.MatDialogContainer=_,t.MatDialogContent=E,t.MatDialogModule=w,t.MatDialogRef=v,t.MatDialogTitle=x,t.matDialogAnimations=f,t.throwMatDialogContentAlreadyAttachedError=m,Object.defineProperty(t,"__esModule",{value:!0})}));