UNPKG

@angular/material

Version:
51 lines 17.8 kB
!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/bidi"),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/common","@angular/core","@angular/material/core","tslib","@angular/cdk/bidi","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.common,t.ng.core,t.ng.material.core,t.tslib,t.ng.cdk.bidi,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,l,s,c,p,d,u){"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 h=function h(){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},g={dialogContainer:p.trigger("dialogContainer",[p.state("void, exit",p.style({opacity:0,transform:"scale(0.7)"})),p.state("enter",p.style({transform:"none"})),p.transition("* => enter",p.animate("150ms cubic-bezier(0, 0, 0.2, 1)",p.style({transform:"none",opacity:1}))),p.transition("* => void, * => exit",p.animate("75ms cubic-bezier(0.4, 0.0, 0.2, 1)",p.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 */ /** * @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 f(){throw Error("Attempting to attach dialog content after content is already attached")}var m=function(t){function e(e,o,a,n,r){var l=t.call(this)||this;return l._elementRef=e,l._focusTrapFactory=o,l._changeDetectorRef=a,l._config=r,l._elementFocusedBeforeDialogWasOpened=null,l._state="enter",l._animationStateChanged=new i.EventEmitter,l.attachDomPortal=function(t){return l._portalOutlet.hasAttached()&&f(),l._savePreviouslyFocusedElement(),l._portalOutlet.attachDomPortal(t)},l._ariaLabelledBy=r.ariaLabelledBy||null,l._document=n,l}return r.__extends(e,t),e.prototype.attachComponentPortal=function(t){return this._portalOutlet.hasAttached()&&f(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachComponentPortal(t)},e.prototype.attachTemplatePortal=function(t){return this._portalOutlet.hasAttached()&&f(),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:i.Component,args:[{selector:"mat-dialog-container",template:"<ng-template cdkPortalOutlet></ng-template>\n",encapsulation:i.ViewEncapsulation.None,changeDetection:i.ChangeDetectionStrategy.Default,animations:[g.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{margin-left:8px}[dir=rtl] .mat-dialog-actions .mat-button-base+.mat-button-base{margin-left:0;margin-right:8px}\n"]}]}],e.ctorParameters=function(){return[{type:i.ElementRef},{type:d.FocusTrapFactory},{type:i.ChangeDetectorRef},{type:void 0,decorators:[{type:i.Optional},{type:i.Inject,args:[a.DOCUMENT]}]},{type:h}]},e.propDecorators={_portalOutlet:[{type:i.ViewChild,args:[o.CdkPortalOutlet,{static:!0}]}]},e}(o.BasePortalOutlet),_=0,y=function(){function t(t,e,o){var a=this;void 0===o&&(o="mat-dialog-"+_++),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(c.filter((function(t){return"done"===t.phaseName&&"enter"===t.toState})),c.take(1)).subscribe((function(){a._afterOpened.next(),a._afterOpened.complete()})),e._animationStateChanged.pipe(c.filter((function(t){return"done"===t.phaseName&&"exit"===t.toState})),c.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(c.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(c.filter((function(t){return"start"===t.phaseName})),c.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}(),v=new i.InjectionToken("MatDialogData"),b=new i.InjectionToken("mat-dialog-default-options"),C=new i.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 D(t){return function(){return t.scrollStrategies.block()}}var O={provide:C,deps:[e.Overlay],useFactory:D},R=function(){function t(t,e,o,a,i,n,r){var l=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 l.openDialogs.length?l._afterAllClosed:l._afterAllClosed.pipe(c.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 r.__assign(r.__assign({},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 h)).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),l=this._attachDialogContent(t,n,i,e);return this.openDialogs.length||this._hideNonDialogContentFromAssistiveTechnology(),this.openDialogs.push(l),l.afterClosed().subscribe((function(){return o._removeOpenDialog(l)})),this.afterOpened.next(l),l},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 a=new o.PortalInjector(e&&e.viewContainerRef&&e.viewContainerRef.injector||this._injector,new WeakMap([[h,e]])),i=new o.ComponentPortal(m,e.viewContainerRef,a,e.componentFactoryResolver);return t.attach(i).instance},t.prototype._attachDialogContent=function(t,e,a,n){var r=new y(a,e,n.id);if(n.hasBackdrop&&a.backdropClick().subscribe((function(){r.disableClose||r.close()})),t instanceof i.TemplateRef)e.attachTemplatePortal(new o.TemplatePortal(t,null,{$implicit:n.data,dialogRef:r}));else{var l=this._createInjector(n,r,e),s=e.attachComponentPortal(new o.ComponentPortal(t,n.viewContainerRef,l));r.componentInstance=s.instance}return r.updateSize(n.width,n.height).updatePosition(n.position),r},t.prototype._createInjector=function(t,e,a){var i=t&&t.viewContainerRef&&t.viewContainerRef.injector,n=new WeakMap([[m,a],[v,t.data],[y,e]]);return!t.direction||i&&i.get(l.Directionality,null)||n.set(l.Directionality,{value:t.direction,change:s.of()}),new o.PortalInjector(i||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:i.Injectable}],t.ctorParameters=function(){return[{type:e.Overlay},{type:i.Injector},{type:a.Location,decorators:[{type:i.Optional}]},{type:h,decorators:[{type:i.Optional},{type:i.Inject,args:[b]}]},{type:void 0,decorators:[{type:i.Inject,args:[C]}]},{type:t,decorators:[{type:i.Optional},{type:i.SkipSelf}]},{type:e.OverlayContainer}]},t}(),A=0,k=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=P(this._elementRef,this._dialog.openDialogs))},t.prototype.ngOnChanges=function(t){var e=t._matDialogClose||t._matDialogCloseResult;e&&(this.dialogResult=e.currentValue)},t.decorators=[{type:i.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:y,decorators:[{type:i.Optional}]},{type:i.ElementRef},{type:R}]},t.propDecorators={ariaLabel:[{type:i.Input,args:["aria-label"]}],type:[{type:i.Input}],dialogResult:[{type:i.Input,args:["mat-dialog-close"]}],_matDialogClose:[{type:i.Input,args:["matDialogClose"]}]},t}(),T=function(){function t(t,e,o){this._dialogRef=t,this._elementRef=e,this._dialog=o,this.id="mat-dialog-title-"+A++}return t.prototype.ngOnInit=function(){var t=this;this._dialogRef||(this._dialogRef=P(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:i.Directive,args:[{selector:"[mat-dialog-title], [matDialogTitle]",exportAs:"matDialogTitle",host:{class:"mat-dialog-title","[id]":"id"}}]}],t.ctorParameters=function(){return[{type:y,decorators:[{type:i.Optional}]},{type:i.ElementRef},{type:R}]},t.propDecorators={id:[{type:i.Input}]},t}(),x=function(){function t(){}return t.decorators=[{type:i.Directive,args:[{selector:"[mat-dialog-content], mat-dialog-content, [matDialogContent]",host:{class:"mat-dialog-content"}}]}],t}(),E=function(){function t(){}return t.decorators=[{type:i.Directive,args:[{selector:"[mat-dialog-actions], mat-dialog-actions, [matDialogActions]",host:{class:"mat-dialog-actions"}}]}],t}();function P(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:i.NgModule,args:[{imports:[a.CommonModule,e.OverlayModule,o.PortalModule,n.MatCommonModule],exports:[m,k,T,x,E,n.MatCommonModule],declarations:[m,k,T,E,x],providers:[R,O],entryComponents:[m]}]}],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=v,t.MAT_DIALOG_DEFAULT_OPTIONS=b,t.MAT_DIALOG_SCROLL_STRATEGY=C,t.MAT_DIALOG_SCROLL_STRATEGY_FACTORY=function S(t){return function(){return t.scrollStrategies.block()}},t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER=O,t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY=D,t.MatDialog=R,t.MatDialogActions=E,t.MatDialogClose=k,t.MatDialogConfig=h,t.MatDialogContainer=m,t.MatDialogContent=x,t.MatDialogModule=w,t.MatDialogRef=y,t.MatDialogTitle=T,t.matDialogAnimations=g,t.throwMatDialogContentAlreadyAttachedError=f,Object.defineProperty(t,"__esModule",{value:!0})}));