UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

39 lines (37 loc) 36.2 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/core"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/logger"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/a11y"),require("@angular/common"),require("@angular/platform-browser/animations"),require("ng-zorro-antd/i18n"),require("@angular/animations"),require("@angular/cdk/keycodes"),require("ng-zorro-antd/button"),require("ng-zorro-antd/core/no-animation"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/core/pipe"),require("ng-zorro-antd/icon")):"function"==typeof define&&define.amd?define("ng-zorro-antd/modal",["exports","@angular/cdk/overlay","@angular/cdk/portal","@angular/core","ng-zorro-antd/core/config","ng-zorro-antd/core/logger","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/cdk/a11y","@angular/common","@angular/platform-browser/animations","ng-zorro-antd/i18n","@angular/animations","@angular/cdk/keycodes","ng-zorro-antd/button","ng-zorro-antd/core/no-animation","ng-zorro-antd/core/outlet","ng-zorro-antd/core/pipe","ng-zorro-antd/icon"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].modal={}),e.ng.cdk.overlay,e.ng.cdk.portal,e.ng.core,e["ng-zorro-antd"].core.config,e["ng-zorro-antd"].core.logger,e["ng-zorro-antd"].core.util,e.rxjs,e.rxjs.operators,e.ng.cdk.a11y,e.ng.common,e.ng.platformBrowser.animations,e["ng-zorro-antd"].i18n,e.ng.animations,e.ng.cdk.keycodes,e["ng-zorro-antd"].button,e["ng-zorro-antd"].core["no-animation"],e["ng-zorro-antd"].core.outlet,e["ng-zorro-antd"].core.pipe,e["ng-zorro-antd"].icon)}(this,(function(e,t,n,o,i,a,r,l,s,c,p,d,u,f,g,m,y,h,z,C){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var v=function(e,t){return(v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function b(e,t){function n(){this.constructor=e}v(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var O=function(){return(O=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function k(e,t,n,o){var i,a=arguments.length,r=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,o);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(r=(a<3?i(r):a>3?i(t,n,r):i(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r}function M(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create;Object.create;var T=function(){},I=function(){this.nzClosable=!0,this.nzOkLoading=!1,this.nzOkDisabled=!1,this.nzCancelDisabled=!1,this.nzCancelLoading=!1,this.nzNoAnimation=!1,this.nzAutofocus="auto",this.nzKeyboard=!0,this.nzZIndex=1e3,this.nzWidth=520,this.nzCloseIcon="close",this.nzOkType="primary",this.nzModalType="default",this.nzOnCancel=T,this.nzOnOk=T,this.nzIconType="question-circle"}; /** * @license * Copyright Alibaba.com 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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ var A={enter:"zoom-enter",enterActive:"zoom-enter-active",leave:"zoom-leave",leaveActive:"zoom-leave-active"},E={enter:"fade-enter",enterActive:"fade-enter-active",leave:"fade-leave",leaveActive:"fade-leave-active"},S={modalContainer:f.trigger("modalContainer",[f.state("void, exit",f.style({})),f.state("enter",f.style({})),f.transition("* => enter",f.animate(".24s",f.style({}))),f.transition("* => void, * => exit",f.animate(".2s",f.style({})))])}; /** * @license * Copyright Alibaba.com 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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ function R(e,t){return O(O({},t),e)}function w(e,t,n){return void 0===e?void 0===t?n:t:e}function N(e,t){Object.assign(e,t)}function x(e){return{nzMask:e.nzMask,nzMaskClosable:e.nzMaskClosable,nzClosable:e.nzClosable,nzOkLoading:e.nzOkLoading,nzOkDisabled:e.nzOkDisabled,nzCancelDisabled:e.nzCancelDisabled,nzCancelLoading:e.nzCancelLoading,nzKeyboard:e.nzKeyboard,nzNoAnimation:e.nzNoAnimation,nzContent:e.nzContent,nzComponentParams:e.nzComponentParams,nzFooter:e.nzFooter,nzGetContainer:e.nzGetContainer,nzZIndex:e.nzZIndex,nzWidth:e.nzWidth,nzWrapClassName:e.nzWrapClassName,nzClassName:e.nzClassName,nzStyle:e.nzStyle,nzTitle:e.nzTitle,nzCloseIcon:e.nzCloseIcon,nzMaskStyle:e.nzMaskStyle,nzBodyStyle:e.nzBodyStyle,nzOkText:e.nzOkText,nzCancelText:e.nzCancelText,nzOkType:e.nzOkType,nzIconType:e.nzIconType,nzModalType:e.nzModalType,nzOnOk:e.nzOnOk,nzOnCancel:e.nzOnCancel,nzAfterOpen:e.nzAfterOpen,nzAfterClose:e.nzAfterClose,nzCloseOnNavigation:e.nzCloseOnNavigation}}function P(){throw Error("Attempting to attach modal content after content is already attached")}var F=function(e){function t(t,n,i,a,r,c,p,d,u,f){var g=e.call(this)||this;return g.elementRef=t,g.focusTrapFactory=n,g.cdr=i,g.render=a,g.zone=r,g.overlayRef=c,g.nzConfigService=p,g.config=d,g.animationType=f,g.animationStateChanged=new o.EventEmitter,g.containerClick=new o.EventEmitter,g.cancelTriggered=new o.EventEmitter,g.okTriggered=new o.EventEmitter,g.onDestroy=new o.EventEmitter,g.state="enter",g.isStringContent=!1,g.elementFocusedBeforeModalWasOpened=null,g.latestMousedownTarget=null,g.oldMaskStyle=null,g.destroy$=new l.Subject,g.document=u,g.isStringContent="string"==typeof d.nzContent,g.setContainer(),g.nzConfigService.getConfigChangeEventForComponent("modal").pipe(s.takeUntil(g.destroy$)).subscribe((function(){g.updateMaskClassname()})),g}return b(t,e),Object.defineProperty(t.prototype,"showMask",{get:function(){var e=this.nzConfigService.getConfigForComponent("modal")||{};return!!w(this.config.nzMask,e.nzMask,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maskClosable",{get:function(){var e=this.nzConfigService.getConfigForComponent("modal")||{};return!!w(this.config.nzMaskClosable,e.nzMaskClosable,!0)},enumerable:!0,configurable:!0}),t.prototype.onMousedown=function(e){this.latestMousedownTarget=e.target||null},t.prototype.onMouseup=function(e){e.target===this.latestMousedownTarget&&e.target===this.elementRef.nativeElement&&this.showMask&&this.maskClosable&&this.containerClick.emit(),this.latestMousedownTarget=null},t.prototype.onCloseClick=function(){this.cancelTriggered.emit()},t.prototype.onOkClick=function(){this.okTriggered.emit()},t.prototype.attachComponentPortal=function(e){return this.portalOutlet.hasAttached()&&P(),this.savePreviouslyFocusedElement(),this.setModalTransformOrigin(),this.portalOutlet.attachComponentPortal(e)},t.prototype.attachTemplatePortal=function(e){return this.portalOutlet.hasAttached()&&P(),this.savePreviouslyFocusedElement(),this.portalOutlet.attachTemplatePortal(e)},t.prototype.getNativeElement=function(){return this.elementRef.nativeElement},t.prototype.animationDisabled=function(){return this.config.nzNoAnimation||"NoopAnimations"===this.animationType},t.prototype.setModalTransformOrigin=function(){var e=this.modalElementRef.nativeElement;if(this.elementFocusedBeforeModalWasOpened){var t=this.elementFocusedBeforeModalWasOpened.getBoundingClientRect(),n=r.getElementOffset(this.elementFocusedBeforeModalWasOpened),o=n.left+t.width/2,i=n.top+t.height/2,a=o-e.offsetLeft+"px "+(i-e.offsetTop)+"px 0px";this.render.setStyle(e,"transform-origin",a)}},t.prototype.savePreviouslyFocusedElement=function(){var e=this;this.document&&(this.elementFocusedBeforeModalWasOpened=this.document.activeElement,this.elementRef.nativeElement.focus&&Promise.resolve().then((function(){return e.elementRef.nativeElement.focus()})))},t.prototype.trapFocus=function(){var e=this.elementRef.nativeElement;if(this.focusTrap||(this.focusTrap=this.focusTrapFactory.create(e)),this.config.nzAutofocus)this.focusTrap.focusInitialElementWhenReady().then();else{var t=this.document.activeElement;t===e||e.contains(t)||e.focus()}},t.prototype.restoreFocus=function(){var e=this.elementFocusedBeforeModalWasOpened;if(e&&"function"==typeof e.focus){var t=this.document.activeElement,n=this.elementRef.nativeElement;t&&t!==this.document.body&&t!==n&&!n.contains(t)||e.focus()}this.focusTrap&&this.focusTrap.destroy()},t.prototype.setEnterAnimationClass=function(){var e=this;this.animationDisabled()||this.zone.runOutsideAngular((function(){e.setModalTransformOrigin();var t=e.modalElementRef.nativeElement,n=e.overlayRef.backdropElement;e.render.addClass(t,A.enter),e.render.addClass(t,A.enterActive),e.render.addClass(n,E.enter),e.render.addClass(n,E.enterActive)}))},t.prototype.setExitAnimationClass=function(){var e=this;this.zone.runOutsideAngular((function(){var t=e.modalElementRef.nativeElement,n=e.overlayRef.backdropElement;e.animationDisabled()?e.render.removeClass(n,"ant-modal-mask"):(e.render.addClass(t,A.leave),e.render.addClass(t,A.leaveActive),e.render.addClass(n,E.leave),e.render.addClass(n,E.leaveActive))}))},t.prototype.cleanAnimationClass=function(){var e=this;this.animationDisabled()||this.zone.runOutsideAngular((function(){var t=e.overlayRef.backdropElement,n=e.modalElementRef.nativeElement;e.render.removeClass(n,A.enter),e.render.removeClass(n,A.enterActive),e.render.removeClass(n,A.leave),e.render.removeClass(n,A.leaveActive),e.render.removeClass(t,E.enter),e.render.removeClass(t,E.enterActive)}))},t.prototype.bindBackdropStyle=function(){var e=this;this.zone.runOutsideAngular((function(){if(e.oldMaskStyle){var t=e.overlayRef.backdropElement,n=e.oldMaskStyle;Object.keys(n).forEach((function(n){e.render.removeStyle(t,n)})),e.oldMaskStyle=null}if("object"==typeof e.config.nzMaskStyle&&Object.keys(e.config.nzMaskStyle).length){var o=e.overlayRef.backdropElement,i=O({},e.config.nzMaskStyle);Object.keys(i).forEach((function(t){e.render.setStyle(o,t,i[t])})),e.oldMaskStyle=i}}))},t.prototype.setContainer=function(){var e=this.getContainer();e&&this.render.appendChild(e,this.elementRef.nativeElement)},t.prototype.resetContainer=function(){this.getContainer()&&this.render.appendChild(this.overlayRef.overlayElement,this.elementRef.nativeElement)},t.prototype.getContainer=function(){var e=this.config.nzGetContainer,t="function"==typeof e?e():e;return t instanceof HTMLElement?t:null},t.prototype.updateMaskClassname=function(){var e=this.overlayRef.backdropElement;this.showMask?this.render.addClass(e,"ant-modal-mask"):this.render.removeClass(e,"ant-modal-mask")},t.prototype.onAnimationDone=function(e){"void"!==e.toState&&("enter"===e.toState?(this.setContainer(),this.trapFocus()):"exit"===e.toState&&this.restoreFocus(),this.cleanAnimationClass(),this.animationStateChanged.emit(e))},t.prototype.onAnimationStart=function(e){"enter"===e.toState?(this.setEnterAnimationClass(),this.bindBackdropStyle()):"exit"===e.toState&&(this.resetContainer(),this.setExitAnimationClass()),this.animationStateChanged.emit(e)},t.prototype.startExitAnimation=function(){this.state="exit",this.cdr.markForCheck()},t.prototype.ngOnDestroy=function(){this.onDestroy.emit(),this.destroy$.next(),this.destroy$.complete()},t}(n.BasePortalOutlet);var D=function(e){function a(t,n,i,a,r,l,c,p,d,u,f){var g=e.call(this,n,i,a,r,l,c,p,d,u,f)||this;return g.i18n=t,g.config=d,g.cancelTriggered=new o.EventEmitter,g.okTriggered=new o.EventEmitter,g.locale={},g.i18n.localeChange.pipe(s.takeUntil(g.destroy$)).subscribe((function(){g.locale=g.i18n.getLocaleData("Modal")})),g}return b(a,e),a.prototype.onCancel=function(){this.cancelTriggered.emit()},a.prototype.onOk=function(){this.okTriggered.emit()},a.decorators=[{type:o.Component,args:[{selector:"nz-modal-confirm-container",exportAs:"nzModalConfirmContainer",template:'\n <div\n #modalElement\n role="document"\n class="ant-modal"\n [ngClass]="config.nzClassName!"\n [ngStyle]="config.nzStyle!"\n [style.width]="config?.nzWidth! | nzToCssUnit"\n >\n <div class="ant-modal-content">\n <button *ngIf="config.nzClosable" nz-modal-close (click)="onCloseClick()"></button>\n <div class="ant-modal-body" [ngStyle]="config.nzBodyStyle!">\n <div class="ant-modal-confirm-body-wrapper">\n <div class="ant-modal-confirm-body">\n <i nz-icon [nzType]="config.nzIconType!"></i>\n <span class="ant-modal-confirm-title">\n <ng-container *nzStringTemplateOutlet="config.nzTitle">\n <span [innerHTML]="config.nzTitle"></span>\n </ng-container>\n </span>\n <div class="ant-modal-confirm-content">\n <ng-template cdkPortalOutlet></ng-template>\n <div *ngIf="isStringContent" [innerHTML]="config.nzContent"></div>\n </div>\n </div>\n <div class="ant-modal-confirm-btns">\n <button\n *ngIf="config.nzCancelText !== null"\n [attr.cdkFocusInitial]="config.nzAutofocus === \'cancel\'"\n nz-button\n (click)="onCancel()"\n [nzLoading]="!!config.nzCancelLoading"\n [disabled]="config.nzCancelDisabled"\n >\n {{ config.nzCancelText || locale.cancelText }}\n </button>\n <button\n *ngIf="config.nzOkText !== null"\n [attr.cdkFocusInitial]="config.nzAutofocus === \'ok\'"\n nz-button\n [nzType]="config.nzOkType!"\n (click)="onOk()"\n [nzLoading]="!!config.nzOkLoading"\n [disabled]="config.nzOkDisabled"\n >\n {{ config.nzOkText || locale.okText }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n ',animations:[S.modalContainer],changeDetection:o.ChangeDetectionStrategy.Default,host:{tabindex:"-1",role:"dialog","[class]":'config.nzWrapClassName ? "ant-modal-wrap " + config.nzWrapClassName : "ant-modal-wrap"',"[style.zIndex]":"config.nzZIndex","[@.disabled]":"config.nzNoAnimation","[@modalContainer]":"state","(@modalContainer.start)":"onAnimationStart($event)","(@modalContainer.done)":"onAnimationDone($event)","(mousedown)":"onMousedown($event)","(mouseup)":"onMouseup($event)"}}]}],a.ctorParameters=function(){return[{type:u.NzI18nService},{type:o.ElementRef},{type:c.FocusTrapFactory},{type:o.ChangeDetectorRef},{type:o.Renderer2},{type:o.NgZone},{type:t.OverlayRef},{type:i.NzConfigService},{type:I},{type:void 0,decorators:[{type:o.Optional},{type:o.Inject,args:[p.DOCUMENT]}]},{type:String,decorators:[{type:o.Optional},{type:o.Inject,args:[d.ANIMATION_MODULE_TYPE]}]}]},a.propDecorators={portalOutlet:[{type:o.ViewChild,args:[n.CdkPortalOutlet,{static:!0}]}],modalElementRef:[{type:o.ViewChild,args:["modalElement",{static:!0}]}],cancelTriggered:[{type:o.Output}],okTriggered:[{type:o.Output}]},a}(F);var j=function(e){function a(t,n,o,i,a,r,l,s,c,p){var d=e.call(this,t,n,o,i,a,r,l,s,c,p)||this;return d.config=s,d}return b(a,e),a.decorators=[{type:o.Component,args:[{selector:"nz-modal-container",exportAs:"nzModalContainer",template:'\n <div\n #modalElement\n role="document"\n class="ant-modal"\n [ngClass]="config.nzClassName!"\n [ngStyle]="config.nzStyle!"\n [style.width]="config?.nzWidth! | nzToCssUnit"\n >\n <div class="ant-modal-content">\n <button *ngIf="config.nzClosable" nz-modal-close (click)="onCloseClick()"></button>\n <div *ngIf="config.nzTitle" nz-modal-title></div>\n <div class="ant-modal-body" [ngStyle]="config.nzBodyStyle!">\n <ng-template cdkPortalOutlet></ng-template>\n <div *ngIf="isStringContent" [innerHTML]="config.nzContent"></div>\n </div>\n <div\n *ngIf="config.nzFooter !== null"\n nz-modal-footer\n [modalRef]="modalRef"\n (cancelTriggered)="onCloseClick()"\n (okTriggered)="onOkClick()"\n ></div>\n </div>\n </div>\n ',animations:[S.modalContainer],changeDetection:o.ChangeDetectionStrategy.Default,host:{tabindex:"-1",role:"dialog","[class]":'config.nzWrapClassName ? "ant-modal-wrap " + config.nzWrapClassName : "ant-modal-wrap"',"[style.zIndex]":"config.nzZIndex","[@.disabled]":"config.nzNoAnimation","[@modalContainer]":"state","(@modalContainer.start)":"onAnimationStart($event)","(@modalContainer.done)":"onAnimationDone($event)","(mousedown)":"onMousedown($event)","(mouseup)":"onMouseup($event)"}}]}],a.ctorParameters=function(){return[{type:o.ElementRef},{type:c.FocusTrapFactory},{type:o.ChangeDetectorRef},{type:o.Renderer2},{type:o.NgZone},{type:t.OverlayRef},{type:i.NzConfigService},{type:I},{type:void 0,decorators:[{type:o.Optional},{type:o.Inject,args:[p.DOCUMENT]}]},{type:String,decorators:[{type:o.Optional},{type:o.Inject,args:[d.ANIMATION_MODULE_TYPE]}]}]},a.propDecorators={portalOutlet:[{type:o.ViewChild,args:[n.CdkPortalOutlet,{static:!0}]}],modalElementRef:[{type:o.ViewChild,args:["modalElement",{static:!0}]}]},a}(F);var B=function(){function e(e,t,n){var i=this;this.overlayRef=e,this.config=t,this.containerInstance=n,this.componentInstance=null,this.state=0,this.afterClose=new l.Subject,this.afterOpen=new l.Subject,n.animationStateChanged.pipe(s.filter((function(e){return"done"===e.phaseName&&"enter"===e.toState})),s.take(1)).subscribe((function(){i.afterOpen.next(),i.afterOpen.complete(),t.nzAfterOpen instanceof o.EventEmitter&&t.nzAfterOpen.emit()})),l.merge(n.onDestroy,n.animationStateChanged.pipe(s.filter((function(e){return"done"===e.phaseName&&"exit"===e.toState})),s.take(1))).pipe(s.take(1)).subscribe((function(){clearTimeout(i.closeTimeout),i.finishDialogClose()})),n.containerClick.pipe(s.take(1)).subscribe((function(){!i.config.nzCancelLoading&&!i.config.nzOkLoading&&i.trigger("cancel")})),e.keydownEvents().pipe(s.filter((function(e){return i.config.nzKeyboard&&!i.config.nzCancelLoading&&!i.config.nzOkLoading&&e.keyCode===g.ESCAPE&&!g.hasModifierKey(e)}))).subscribe((function(e){e.preventDefault(),i.trigger("cancel")})),n.cancelTriggered.subscribe((function(){return i.trigger("cancel")})),n.okTriggered.subscribe((function(){return i.trigger("ok")})),e.detachments().subscribe((function(){i.afterClose.next(i.result),i.afterClose.complete(),t.nzAfterClose instanceof o.EventEmitter&&t.nzAfterClose.emit(i.result),i.componentInstance=null,i.overlayRef.dispose()}))}return e.prototype.getContentComponent=function(){return this.componentInstance},e.prototype.getElement=function(){return this.containerInstance.getNativeElement()},e.prototype.destroy=function(e){this.close(e)},e.prototype.triggerOk=function(){this.trigger("ok")},e.prototype.triggerCancel=function(){this.trigger("cancel")},e.prototype.open=function(){},e.prototype.close=function(e){var t=this;this.result=e,this.containerInstance.animationStateChanged.pipe(s.filter((function(e){return"start"===e.phaseName})),s.take(1)).subscribe((function(e){t.overlayRef.detachBackdrop(),t.closeTimeout=setTimeout((function(){t.finishDialogClose()}),e.totalTime+100)})),this.containerInstance.startExitAnimation(),this.state=1},e.prototype.updateConfig=function(e){Object.assign(this.config,e),this.containerInstance.cdr.markForCheck()},e.prototype.getState=function(){return this.state},e.prototype.getConfig=function(){return this.config},e.prototype.getBackdropElement=function(){return this.overlayRef.backdropElement},e.prototype.trigger=function(e){var t,n=this,i={ok:this.config.nzOnOk,cancel:this.config.nzOnCancel}[e],a={ok:"nzOkLoading",cancel:"nzCancelLoading"}[e];if(!this.config[a])if(i instanceof o.EventEmitter)i.emit(this.getContentComponent());else if("function"==typeof i){var l=i(this.getContentComponent());if(r.isPromise(l)){this.config[a]=!0;var s=function(e){n.config[a]=!1,n.closeWhitResult(e)};l.then(s).catch(s)}else!1!==(t=l)&&n.close(t)}},e.prototype.closeWhitResult=function(e){!1!==e&&this.close(e)},e.prototype.finishDialogClose=function(){this.state=2,this.overlayRef.dispose()},e}();var L=function(){function e(e,t,n,o){var i=this;this.overlay=e,this.injector=t,this.nzConfigService=n,this.parentModal=o,this.openModalsAtThisLevel=[],this.afterAllClosedAtThisLevel=new l.Subject,this.afterAllClose=l.defer((function(){return i.openModals.length?i._afterAllClosed:i._afterAllClosed.pipe(s.startWith(void 0))}))}return Object.defineProperty(e.prototype,"openModals",{get:function(){return this.parentModal?this.parentModal.openModals:this.openModalsAtThisLevel},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_afterAllClosed",{get:function(){var e=this.parentModal;return e?e._afterAllClosed:this.afterAllClosedAtThisLevel},enumerable:!0,configurable:!0}),e.prototype.create=function(e){return this.open(e.nzContent,e)},e.prototype.closeAll=function(){this.closeModals(this.openModals)},e.prototype.confirm=function(e,t){return void 0===e&&(e={}),void 0===t&&(t="confirm"),"nzFooter"in e&&a.warn('The Confirm-Modal doesn\'t support "nzFooter", this property will be ignored.'),"nzWidth"in e||(e.nzWidth=416),"nzMaskClosable"in e||(e.nzMaskClosable=!1),e.nzModalType="confirm",e.nzClassName="ant-modal-confirm ant-modal-confirm-"+t+" "+(e.nzClassName||""),this.create(e)},e.prototype.info=function(e){return void 0===e&&(e={}),this.confirmFactory(e,"info")},e.prototype.success=function(e){return void 0===e&&(e={}),this.confirmFactory(e,"success")},e.prototype.error=function(e){return void 0===e&&(e={}),this.confirmFactory(e,"error")},e.prototype.warning=function(e){return void 0===e&&(e={}),this.confirmFactory(e,"warning")},e.prototype.open=function(e,t){var n=this,o=R(t||{},new I),i=this.createOverlay(o),a=this.attachModalContainer(i,o),r=this.attachModalContent(e,a,i,o);return a.modalRef=r,this.openModals.push(r),r.afterClose.subscribe((function(){return n.removeOpenModal(r)})),r},e.prototype.removeOpenModal=function(e){var t=this.openModals.indexOf(e);t>-1&&(this.openModals.splice(t,1),this.openModals.length||this._afterAllClosed.next())},e.prototype.closeModals=function(e){for(var t=e.length;t--;)e[t].close(),this.openModals.length||this._afterAllClosed.next()},e.prototype.createOverlay=function(e){var n=this.nzConfigService.getConfigForComponent("modal")||{},o=new t.OverlayConfig({hasBackdrop:!0,scrollStrategy:this.overlay.scrollStrategies.block(),positionStrategy:this.overlay.position().global(),disposeOnNavigation:w(e.nzCloseOnNavigation,n.nzCloseOnNavigation,!0)});return w(e.nzMask,n.nzMask,!0)&&(o.backdropClass="ant-modal-mask"),this.overlay.create(o)},e.prototype.attachModalContainer=function(e,o){var i=o&&o.nzViewContainerRef&&o.nzViewContainerRef.injector,a=new n.PortalInjector(i||this.injector,new WeakMap([[t.OverlayRef,e],[I,o]])),r="confirm"===o.nzModalType?D:j,l=new n.ComponentPortal(r,o.nzViewContainerRef,a);return e.attach(l).instance},e.prototype.attachModalContent=function(e,t,i,a){var l=new B(i,a,t);if(e instanceof o.TemplateRef)t.attachTemplatePortal(new n.TemplatePortal(e,null,{$implicit:a.nzComponentParams,modalRef:l}));else if(r.isNotNil(e)&&"string"!=typeof e){var s=this.createInjector(l,a),c=t.attachComponentPortal(new n.ComponentPortal(e,a.nzViewContainerRef,s));N(c.instance,a.nzComponentParams),l.componentInstance=c.instance}return l},e.prototype.createInjector=function(e,t){var o=t&&t.nzViewContainerRef&&t.nzViewContainerRef.injector,i=new WeakMap([[B,e]]);return new n.PortalInjector(o||this.injector,i)},e.prototype.confirmFactory=function(e,t){void 0===e&&(e={});return"nzIconType"in e||(e.nzIconType={info:"info-circle",success:"check-circle",error:"close-circle",warning:"exclamation-circle"}[t]),"nzCancelText"in e||(e.nzCancelText=null),this.confirm(e,t)},e.prototype.ngOnDestroy=function(){this.closeModals(this.openModalsAtThisLevel),this.afterAllClosedAtThisLevel.complete()},e.decorators=[{type:o.Injectable}],e.ctorParameters=function(){return[{type:t.Overlay},{type:o.Injector},{type:i.NzConfigService},{type:e,decorators:[{type:o.Optional},{type:o.SkipSelf}]}]},e}();var _=function(){function e(e,t){this.nzModalRef=e,this.templateRef=t,this.nzModalRef&&this.nzModalRef.updateConfig({nzFooter:this.templateRef})}return e.decorators=[{type:o.Directive,args:[{selector:"[nzModalFooter]",exportAs:"nzModalFooter"}]}],e.ctorParameters=function(){return[{type:B,decorators:[{type:o.Optional}]},{type:o.TemplateRef}]},e}();var W=function(){function e(e,t,n){this.cdr=e,this.modal=t,this.viewContainerRef=n,this.nzVisible=!1,this.nzClosable=!0,this.nzOkLoading=!1,this.nzOkDisabled=!1,this.nzCancelDisabled=!1,this.nzCancelLoading=!1,this.nzKeyboard=!0,this.nzNoAnimation=!1,this.nzZIndex=1e3,this.nzWidth=520,this.nzCloseIcon="close",this.nzOkType="primary",this.nzIconType="question-circle",this.nzModalType="default",this.nzOnOk=new o.EventEmitter,this.nzOnCancel=new o.EventEmitter,this.nzAfterOpen=new o.EventEmitter,this.nzAfterClose=new o.EventEmitter,this.nzVisibleChange=new o.EventEmitter,this.modalRef=null}return Object.defineProperty(e.prototype,"modalFooter",{set:function(e){e&&e.templateRef&&this.setFooterWithTemplate(e.templateRef)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"afterOpen",{get:function(){return this.nzAfterOpen.asObservable()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"afterClose",{get:function(){return this.nzAfterClose.asObservable()},enumerable:!0,configurable:!0}),e.prototype.open=function(){if(this.nzVisible||(this.nzVisible=!0,this.nzVisibleChange.emit(!0)),!this.modalRef){var e=this.getConfig();this.modalRef=this.modal.create(e)}},e.prototype.close=function(e){this.nzVisible&&(this.nzVisible=!1,this.nzVisibleChange.emit(!1)),this.modalRef&&(this.modalRef.close(e),this.modalRef=null)},e.prototype.destroy=function(e){this.close(e)},e.prototype.triggerOk=function(){var e;null===(e=this.modalRef)||void 0===e||e.triggerOk()},e.prototype.triggerCancel=function(){var e;null===(e=this.modalRef)||void 0===e||e.triggerCancel()},e.prototype.getContentComponent=function(){var e;return null===(e=this.modalRef)||void 0===e?void 0:e.getContentComponent()},e.prototype.getElement=function(){var e;return null===(e=this.modalRef)||void 0===e?void 0:e.getElement()},e.prototype.getModalRef=function(){return this.modalRef},e.prototype.setFooterWithTemplate=function(e){var t=this;this.nzFooter=e,this.modalRef&&Promise.resolve().then((function(){t.modalRef.updateConfig({nzFooter:t.nzFooter})})),this.cdr.markForCheck()},e.prototype.getConfig=function(){var e=x(this);return e.nzViewContainerRef=this.viewContainerRef,this.nzContent||(e.nzContent=this.contentTemplateRef),e},e.prototype.ngOnChanges=function(e){var t=e.nzVisible,n=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}(e,["nzVisible"]);Object.keys(n).length&&this.modalRef&&this.modalRef.updateConfig(x(this)),t&&(this.nzVisible?this.open():this.close())},e.decorators=[{type:o.Component,args:[{selector:"nz-modal",exportAs:"nzModal",template:" <ng-template><ng-content></ng-content></ng-template> ",changeDetection:o.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:o.ChangeDetectorRef},{type:L},{type:o.ViewContainerRef}]},e.propDecorators={nzMask:[{type:o.Input}],nzMaskClosable:[{type:o.Input}],nzCloseOnNavigation:[{type:o.Input}],nzVisible:[{type:o.Input}],nzClosable:[{type:o.Input}],nzOkLoading:[{type:o.Input}],nzOkDisabled:[{type:o.Input}],nzCancelDisabled:[{type:o.Input}],nzCancelLoading:[{type:o.Input}],nzKeyboard:[{type:o.Input}],nzNoAnimation:[{type:o.Input}],nzContent:[{type:o.Input}],nzComponentParams:[{type:o.Input}],nzFooter:[{type:o.Input}],nzGetContainer:[{type:o.Input}],nzZIndex:[{type:o.Input}],nzWidth:[{type:o.Input}],nzWrapClassName:[{type:o.Input}],nzClassName:[{type:o.Input}],nzStyle:[{type:o.Input}],nzTitle:[{type:o.Input}],nzCloseIcon:[{type:o.Input}],nzMaskStyle:[{type:o.Input}],nzBodyStyle:[{type:o.Input}],nzOkText:[{type:o.Input}],nzCancelText:[{type:o.Input}],nzOkType:[{type:o.Input}],nzIconType:[{type:o.Input}],nzModalType:[{type:o.Input}],nzOnOk:[{type:o.Input},{type:o.Output}],nzOnCancel:[{type:o.Input},{type:o.Output}],nzAfterOpen:[{type:o.Output}],nzAfterClose:[{type:o.Output}],nzVisibleChange:[{type:o.Output}],contentTemplateRef:[{type:o.ViewChild,args:[o.TemplateRef,{static:!0}]}],modalFooter:[{type:o.ContentChild,args:[_]}]},k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzMask",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzMaskClosable",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzCloseOnNavigation",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzVisible",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzClosable",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzOkLoading",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzOkDisabled",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzCancelDisabled",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzCancelLoading",void 0),k([r.InputBoolean(),M("design:type",Boolean)],e.prototype,"nzKeyboard",void 0),k([r.InputBoolean(),M("design:type",Object)],e.prototype,"nzNoAnimation",void 0),e}();var V=function(){function e(e){this.config=e}return e.decorators=[{type:o.Component,args:[{selector:"button[nz-modal-close]",exportAs:"NzModalCloseBuiltin",template:'\n <span class="ant-modal-close-x">\n <ng-container *nzStringTemplateOutlet="config.nzCloseIcon; let closeIcon">\n <i nz-icon [nzType]="closeIcon" class="ant-modal-close-icon"></i>\n </ng-container>\n </span>\n ',host:{class:"ant-modal-close","aria-label":"Close"},changeDetection:o.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:I}]},e}();var q=function(){function e(e,t){var n=this;this.i18n=e,this.config=t,this.buttonsFooter=!1,this.buttons=[],this.locale={},this.cancelTriggered=new o.EventEmitter,this.okTriggered=new o.EventEmitter,this.destroy$=new l.Subject,Array.isArray(t.nzFooter)&&(this.buttonsFooter=!0,this.buttons=t.nzFooter.map($)),this.i18n.localeChange.pipe(s.takeUntil(this.destroy$)).subscribe((function(){n.locale=n.i18n.getLocaleData("Modal")}))}return e.prototype.onCancel=function(){this.cancelTriggered.emit()},e.prototype.onOk=function(){this.okTriggered.emit()},e.prototype.getButtonCallableProp=function(e,t){var n=e[t],o=this.modalRef.getContentComponent();return"function"==typeof n?n.apply(e,o&&[o]):n},e.prototype.onButtonClick=function(e){if(!this.getButtonCallableProp(e,"loading")){var t=this.getButtonCallableProp(e,"onClick");e.autoLoading&&r.isPromise(t)&&(e.loading=!0,t.then((function(){return e.loading=!1})).catch((function(){return e.loading=!1})))}},e.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},e.decorators=[{type:o.Component,args:[{selector:"div[nz-modal-footer]",exportAs:"NzModalFooterBuiltin",template:'\n <ng-container *ngIf="config.nzFooter; else defaultFooterButtons">\n <ng-container *nzStringTemplateOutlet="config.nzFooter">\n <div *ngIf="!buttonsFooter" [innerHTML]="config.nzTitle"></div>\n <ng-container *ngIf="buttonsFooter">\n <button\n *ngFor="let button of buttons"\n nz-button\n (click)="onButtonClick(button)"\n [hidden]="!getButtonCallableProp(button, \'show\')"\n [nzLoading]="getButtonCallableProp(button, \'loading\')"\n [disabled]="getButtonCallableProp(button, \'disabled\')"\n [nzType]="button.type!"\n [nzShape]="button.shape!"\n [nzSize]="button.size!"\n [nzGhost]="button.ghost!"\n >\n {{ button.label }}\n </button>\n </ng-container>\n </ng-container>\n </ng-container>\n <ng-template #defaultFooterButtons>\n <button\n *ngIf="config.nzCancelText !== null"\n [attr.cdkFocusInitial]="config.nzAutofocus === \'cancel\'"\n nz-button\n (click)="onCancel()"\n [nzLoading]="!!config.nzCancelLoading"\n [disabled]="config.nzCancelDisabled"\n >\n {{ config.nzCancelText || locale.cancelText }}\n </button>\n <button\n *ngIf="config.nzOkText !== null"\n [attr.cdkFocusInitial]="config.nzAutofocus === \'ok\'"\n nz-button\n [nzType]="config.nzOkType!"\n (click)="onOk()"\n [nzLoading]="!!config.nzOkLoading"\n [disabled]="config.nzOkDisabled"\n >\n {{ config.nzOkText || locale.okText }}\n </button>\n </ng-template>\n ',host:{class:"ant-modal-footer"},changeDetection:o.ChangeDetectionStrategy.Default}]}],e.ctorParameters=function(){return[{type:u.NzI18nService},{type:I}]},e.propDecorators={cancelTriggered:[{type:o.Output}],okTriggered:[{type:o.Output}],modalRef:[{type:o.Input}]},e}();function $(e){return O({type:null,size:"default",autoLoading:!0,show:!0,loading:!1,disabled:!1},e)}var Z=function(){function e(e){this.config=e}return e.decorators=[{type:o.Component,args:[{selector:"div[nz-modal-title]",exportAs:"NzModalTitleBuiltin",template:'\n <div class="ant-modal-title">\n <ng-container *nzStringTemplateOutlet="config.nzTitle">\n <div [innerHTML]="config.nzTitle"></div>\n </ng-container>\n </div>\n ',host:{class:"ant-modal-header"},changeDetection:o.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:I}]},e}();var K=function(){function e(){}return e.decorators=[{type:o.NgModule,args:[{imports:[p.CommonModule,t.OverlayModule,h.NzOutletModule,n.PortalModule,u.NzI18nModule,m.NzButtonModule,C.NzIconModule,z.NzPipesModule,y.NzNoAnimationModule],exports:[W,_],providers:[L],entryComponents:[j,D],declarations:[W,_,V,q,Z,j,D,W]}]}],e}(),U=function(){}; /** * @license * Copyright Alibaba.com 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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */e.BaseModalContainer=F,e.FADE_CLASS_NAME_MAP=E,e.MODAL_MASK_CLASS_NAME="ant-modal-mask",e.ModalOptions=I,e.NZ_CONFIG_COMPONENT_NAME="modal",e.NzModalCloseComponent=V,e.NzModalComponent=W,e.NzModalConfirmContainerComponent=D,e.NzModalContainerComponent=j,e.NzModalFooterComponent=q,e.NzModalFooterDirective=_,e.NzModalLegacyAPI=U,e.NzModalModule=K,e.NzModalRef=B,e.NzModalService=L,e.NzModalTitleComponent=Z,e.ZOOM_CLASS_NAME_MAP=A,e.applyConfigDefaults=R,e.getConfigFromComponent=x,e.getValueWithConfig=w,e.nzModalAnimations=S,e.setContentInstanceParams=N,e.throwNzModalContentAlreadyAttachedError=P,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-modal.umd.min.js.map