UNPKG

@angular/material

Version:
10 lines (9 loc) 16.4 kB
/** * @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/core"),require("@angular/common"),require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/cdk/a11y"),require("@angular/material/core"),require("@angular/cdk/bidi"),require("rxjs/observable/defer"),require("rxjs/observable/of"),require("rxjs/operators/startWith"),require("rxjs/Subject"),require("@angular/animations"),require("@angular/cdk/keycodes"),require("rxjs/operators/filter"),require("rxjs/operators/take"),require("rxjs/Subscription")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","@angular/cdk/overlay","@angular/cdk/portal","@angular/cdk/a11y","@angular/material/core","@angular/cdk/bidi","rxjs/observable/defer","rxjs/observable/of","rxjs/operators/startWith","rxjs/Subject","@angular/animations","@angular/cdk/keycodes","rxjs/operators/filter","rxjs/operators/take","rxjs/Subscription"],e):e((t.ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.dialog=t.ng.material.dialog||{}),t.ng.core,t.ng.common,t.ng.cdk.overlay,t.ng.cdk.portal,t.ng.cdk.a11y,t.ng.material.core,t.ng.cdk.bidi,t.Rx.Observable,t.Rx.Observable,t.Rx.operators,t.Rx,t.ng.animations,t.ng.cdk.keycodes,t.Rx.operators,t.Rx.operators,t.Rx)}(this,function(t,e,o,a,i,n,r,s,l,c,p,u,d,g,h,f,m){"use strict";function _(t,e){function o(){this.constructor=t}D(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function y(){throw Error("Attempting to attach dialog content after content is already attached")}function b(t){return function(){return t.scrollStrategies.block()}}function v(t,e){return O({},e,t)}function C(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 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])},O=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},x=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.direction="ltr",this.ariaDescribedBy=null,this.ariaLabel=null,this.autoFocus=!0,this.closeOnNavigation=!0}return t}(),R={slideDialog:d.trigger("slideDialog",[d.state("enter",d.style({transform:"none",opacity:1})),d.state("void",d.style({transform:"translate3d(0, 25%, 0) scale(0.9)",opacity:0})),d.state("exit",d.style({transform:"translate3d(0, 25%, 0)",opacity:0})),d.transition("* => *",d.animate("400ms cubic-bezier(0.25, 0.8, 0.25, 1)"))])},k=function(t){function a(o,a,i,n){var r=t.call(this)||this;return r._elementRef=o,r._focusTrapFactory=a,r._changeDetectorRef=i,r._document=n,r._elementFocusedBeforeDialogWasOpened=null,r._state="enter",r._animationStateChanged=new e.EventEmitter,r._ariaLabelledBy=null,r}return _(a,t),a.prototype.attachComponentPortal=function(t){return this._portalOutlet.hasAttached()&&y(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachComponentPortal(t)},a.prototype.attachTemplatePortal=function(t){return this._portalOutlet.hasAttached()&&y(),this._savePreviouslyFocusedElement(),this._portalOutlet.attachTemplatePortal(t)},a.prototype._trapFocus=function(){this._focusTrap||(this._focusTrap=this._focusTrapFactory.create(this._elementRef.nativeElement)),this._config.autoFocus&&this._focusTrap.focusInitialElementWhenReady()},a.prototype._restoreFocus=function(){var t=this._elementFocusedBeforeDialogWasOpened;t&&"function"==typeof t.focus&&t.focus(),this._focusTrap&&this._focusTrap.destroy()},a.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()}))},a.prototype._onAnimationDone=function(t){"enter"===t.toState?this._trapFocus():"exit"===t.toState&&this._restoreFocus(),this._animationStateChanged.emit(t)},a.prototype._onAnimationStart=function(t){this._animationStateChanged.emit(t)},a.prototype._startExitAnimation=function(){this._state="exit",this._changeDetectorRef.markForCheck()},a.decorators=[{type:e.Component,args:[{selector:"mat-dialog-container",template:"<ng-template cdkPortalOutlet></ng-template>",styles:[".mat-dialog-container{box-shadow:0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14),0 9px 46px 8px rgba(0,0,0,.12);display:block;padding:24px;border-radius:2px;box-sizing:border-box;overflow:auto;outline:0;width:100%;height:100%}@media screen and (-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;-webkit-backface-visibility:hidden;backface-visibility:hidden}.mat-dialog-title{margin:0 0 20px;display:block}.mat-dialog-actions{padding:12px 0;display:flex;flex-wrap:wrap}.mat-dialog-actions:last-child{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:e.ViewEncapsulation.None,preserveWhitespaces:!1,changeDetection:e.ChangeDetectionStrategy.Default,animations:[R.slideDialog],host:{class:"mat-dialog-container",tabindex:"-1","[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","[@slideDialog]":"_state","(@slideDialog.start)":"_onAnimationStart($event)","(@slideDialog.done)":"_onAnimationDone($event)"}}]}],a.ctorParameters=function(){return[{type:e.ElementRef},{type:n.FocusTrapFactory},{type:e.ChangeDetectorRef},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[o.DOCUMENT]}]}]},a.propDecorators={_portalOutlet:[{type:e.ViewChild,args:[i.CdkPortalOutlet]}]},a}(i.BasePortalOutlet),A=0,S=function(){function t(t,e,o,a){void 0===a&&(a="mat-dialog-"+A++);var i=this;this._overlayRef=t,this._containerInstance=e,this.id=a,this.disableClose=this._containerInstance._config.disableClose,this._afterOpen=new u.Subject,this._afterClosed=new u.Subject,this._beforeClose=new u.Subject,this._locationChanges=m.Subscription.EMPTY,e._id=a,e._animationStateChanged.pipe(h.filter(function(t){return"done"===t.phaseName&&"enter"===t.toState}),f.take(1)).subscribe(function(){i._afterOpen.next(),i._afterOpen.complete()}),e._animationStateChanged.pipe(h.filter(function(t){return"done"===t.phaseName&&"exit"===t.toState}),f.take(1)).subscribe(function(){i._overlayRef.dispose(),i._locationChanges.unsubscribe(),i._afterClosed.next(i._result),i._afterClosed.complete(),i.componentInstance=null}),t.keydownEvents().pipe(h.filter(function(t){return t.keyCode===g.ESCAPE&&!i.disableClose})).subscribe(function(){return i.close()}),o&&(this._locationChanges=o.subscribe(function(){i._containerInstance._config.closeOnNavigation&&i.close()}))}return t.prototype.close=function(t){var e=this;this._result=t,this._containerInstance._animationStateChanged.pipe(h.filter(function(t){return"start"===t.phaseName}),f.take(1)).subscribe(function(){e._beforeClose.next(t),e._beforeClose.complete(),e._overlayRef.detachBackdrop()}),this._containerInstance._startExitAnimation()},t.prototype.afterOpen=function(){return this._afterOpen.asObservable()},t.prototype.afterClosed=function(){return this._afterClosed.asObservable()},t.prototype.beforeClose=function(){return this._beforeClose.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="auto"),void 0===e&&(e="auto"),this._getPositionStrategy().width(t).height(e),this._overlayRef.updatePosition(),this},t.prototype._getPositionStrategy=function(){return this._overlayRef.getConfig().positionStrategy},t}(),T=new e.InjectionToken("MatDialogData"),j=new e.InjectionToken("mat-dialog-default-options"),w=new e.InjectionToken("mat-dialog-scroll-strategy"),P={provide:w,deps:[a.Overlay],useFactory:b},E=function(){function t(t,e,o,a,i,n,r){var s=this;this._overlay=t,this._injector=e,this._location=o,this._defaultOptions=a,this._scrollStrategy=i,this._parentDialog=n,this._overlayContainer=r,this._openDialogsAtThisLevel=[],this._afterAllClosedAtThisLevel=new u.Subject,this._afterOpenAtThisLevel=new u.Subject,this._ariaHiddenElements=new Map,this.afterAllClosed=l.defer(function(){return s.openDialogs.length?s._afterAllClosed:s._afterAllClosed.pipe(p.startWith(void 0))})}return Object.defineProperty(t.prototype,"openDialogs",{get:function(){return this._parentDialog?this._parentDialog.openDialogs:this._openDialogsAtThisLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"afterOpen",{get:function(){return this._parentDialog?this._parentDialog.afterOpen:this._afterOpenAtThisLevel},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=v(e,this._defaultOptions||new x),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.afterOpen.next(n),n},t.prototype.closeAll=function(){for(var t=this.openDialogs.length;t--;)this.openDialogs[t].close()},t.prototype.getDialogById=function(t){return this.openDialogs.find(function(e){return e.id===t})},t.prototype._createOverlay=function(t){var e=this._getOverlayConfig(t);return this._overlay.create(e)},t.prototype._getOverlayConfig=function(t){var e=new a.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});return t.backdropClass&&(e.backdropClass=t.backdropClass),e},t.prototype._attachDialogContainer=function(t,e){var o=new i.ComponentPortal(k,e.viewContainerRef),a=t.attach(o);return a.instance._config=e,a.instance},t.prototype._attachDialogContent=function(t,o,a,n){var r=new S(a,o,this._location,n.id);if(n.hasBackdrop&&a.backdropClick().subscribe(function(){r.disableClose||r.close()}),t instanceof e.TemplateRef)o.attachTemplatePortal(new i.TemplatePortal(t,null,{$implicit:n.data,dialogRef:r}));else{var s=this._createInjector(n,r,o),l=o.attachComponentPortal(new i.ComponentPortal(t,void 0,s));r.componentInstance=l.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;return n.set(S,e),n.set(k,o),n.set(T,t.data),n.set(s.Directionality,{value:t.direction,change:c.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.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:a.Overlay},{type:e.Injector},{type:o.Location,decorators:[{type:e.Optional}]},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[j]}]},{type:void 0,decorators:[{type:e.Inject,args:[w]}]},{type:t,decorators:[{type:e.Optional},{type:e.SkipSelf}]},{type:a.OverlayContainer}]},t}(),I=0,L=function(){function t(t,e,o){this.dialogRef=t,this._elementRef=e,this._dialog=o,this.ariaLabel="Close dialog"}return t.prototype.ngOnInit=function(){this.dialogRef||(this.dialogRef=C(this._elementRef,this._dialog.openDialogs))},t.prototype.ngOnChanges=function(t){var e=t._matDialogClose||t._matDialogCloseResult;e&&(this.dialogResult=e.currentValue)},t.decorators=[{type:e.Directive,args:[{selector:"button[mat-dialog-close], button[matDialogClose]",exportAs:"matDialogClose",host:{"(click)":"dialogRef.close(dialogResult)","[attr.aria-label]":"ariaLabel",type:"button"}}]}],t.ctorParameters=function(){return[{type:S,decorators:[{type:e.Optional}]},{type:e.ElementRef},{type:E}]},t.propDecorators={ariaLabel:[{type:e.Input,args:["aria-label"]}],dialogResult:[{type:e.Input,args:["mat-dialog-close"]}],_matDialogClose:[{type:e.Input,args:["matDialogClose"]}]},t}(),M=function(){function t(t,e,o){this._dialogRef=t,this._elementRef=e,this._dialog=o,this.id="mat-dialog-title-"+I++}return t.prototype.ngOnInit=function(){var t=this;this._dialogRef||(this._dialogRef=C(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:e.Directive,args:[{selector:"[mat-dialog-title], [matDialogTitle]",exportAs:"matDialogTitle",host:{class:"mat-dialog-title","[id]":"id"}}]}],t.ctorParameters=function(){return[{type:S,decorators:[{type:e.Optional}]},{type:e.ElementRef},{type:E}]},t.propDecorators={id:[{type:e.Input}]},t}(),F=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"[mat-dialog-content], mat-dialog-content, [matDialogContent]",host:{class:"mat-dialog-content"}}]}],t.ctorParameters=function(){return[]},t}(),q=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"[mat-dialog-actions], mat-dialog-actions, [matDialogActions]",host:{class:"mat-dialog-actions"}}]}],t.ctorParameters=function(){return[]},t}(),B=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[o.CommonModule,a.OverlayModule,i.PortalModule,n.A11yModule,r.MatCommonModule],exports:[k,L,M,F,q,r.MatCommonModule],declarations:[k,L,M,q,F],providers:[E,P],entryComponents:[k]}]}],t.ctorParameters=function(){return[]},t}();t.MatDialogModule=B,t.MAT_DIALOG_DATA=T,t.MAT_DIALOG_DEFAULT_OPTIONS=j,t.MAT_DIALOG_SCROLL_STRATEGY=w,t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY=b,t.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER=P,t.MatDialog=E,t.throwMatDialogContentAlreadyAttachedError=y,t.MatDialogContainer=k,t.MatDialogClose=L,t.MatDialogTitle=M,t.MatDialogContent=F,t.MatDialogActions=q,t.MatDialogConfig=x,t.MatDialogRef=S,t.matDialogAnimations=R,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=material-dialog.umd.min.js.map