UNPKG

ngx-modialog-7

Version:
16 lines (14 loc) 10.4 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("@angular/core"),require("ngx-modialog-7"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngxModialog.plugins.vex",["exports","rxjs","@angular/core","ngx-modialog-7","@angular/common"],e):e(((t=t||self).ngxModialog=t.ngxModialog||{},t.ngxModialog.plugins=t.ngxModialog.plugins||{},t.ngxModialog.plugins.vex={}),t.rxjs,t.ng.core,t.ngxModialog,t.ng.common)}(this,(function(t,e,n,o,i){"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 a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var r=function(){function t(){this.onButtonClick=new n.EventEmitter}return t.prototype.onClick=function(t,e){e.stopPropagation(),this.onButtonClick.emit({btn:t,$event:e})},t.decorators=[{type:n.Component,args:[{selector:"vex-dialog-buttons",encapsulation:n.ViewEncapsulation.None,template:'<div class="vex-dialog-buttons">\n <button type="button"\n *ngFor="let btn of buttons;"\n [class]="btn.cssClass"\n (click)="onClick(btn, $event)">{{btn.caption}}</button>\n</div>'}]}],t.propDecorators={buttons:[{type:n.Input}],onButtonClick:[{type:n.Output}]},t}();var l=function(){function t(t){this.dialog=t,this.context=t.context}return t.prototype.onButtonClick=function(t){t.btn.onClick(this,t.$event)},t.decorators=[{type:n.Component,args:[{selector:"modal-dialog",encapsulation:n.ViewEncapsulation.None,template:'<form class="vex-dialog-form">\n <ng-container *ngComponentOutlet="context.content"></ng-container>\n <vex-dialog-buttons [buttons]="context.buttons"\n (onButtonClick)="onButtonClick($event)"></vex-dialog-buttons>\n</form>'}]}],t.ctorParameters=function(){return[{type:o.DialogRef}]},t}();var c=function(){function t(t){this.dialog=t,this.context=t.context}return t.decorators=[{type:n.Component,args:[{selector:"drop-in-dialog",encapsulation:n.ViewEncapsulation.None,template:'<div class="vex-dialog-message">{{context.message}}</div>\n <div *ngIf="context.showInput" class="vex-dialog-input">\n <input #input\n autofocus\n name="vex"\n type="text"\n class="vex-dialog-prompt-input"\n (change)="context.defaultResult = input.value"\n placeholder="{{context.placeholder}}">\n </div>\n <div *ngIf="context.showCloseButton"\n [class]="context.closeClassName"\n (click)="dialog.dismiss()"></div>'}]}],t.ctorParameters=function(){return[{type:o.DialogRef}]},t}();var u={className:"default",overlayClassName:"vex-overlay",contentClassName:"vex-content",closeClassName:"vex-close"},d=["className","overlayClassName","contentClassName","closeClassName","showCloseButton"],p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.normalize=function(){this.className||(this.className=u.className),this.overlayClassName||(this.overlayClassName=u.overlayClassName),this.contentClassName||(this.contentClassName=u.contentClassName),this.closeClassName||(this.closeClassName=u.closeClassName),t.prototype.normalize.call(this)},e}(o.ModalOpenContext);var v=function(t){function e(e,n,i){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),void 0===i&&(i=void 0),t.call(this,o.extend(u,e||{}),o.arrayUnion(d,n||[]),i||p)||this}return s(e,t),e.prototype.overlayClosesOnClick=function(t){return this[o.privateKey("isBlocking")]=!t,this},e}(o.ModalOpenContextBuilder);var m=["content"],y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e}(p);var f=function(t){function e(e,n,i,a){return void 0===n&&(n=void 0),void 0===i&&(i=void 0),void 0===a&&(a=void 0),t.call(this,o.extend({modal:e,component:l,buttons:[],defaultResult:!0},n||{}),o.arrayUnion(m,i||[]),a||y)||this}return s(e,t),e.prototype.addButton=function(t,e,n){var i={cssClass:t,caption:e,onClick:n};return this[o.privateKey("buttons")].push(i),this},e.prototype.addOkButton=function(t){return void 0===t&&(t="OK"),this.addButton("vex-dialog-button-primary vex-dialog-button vex-first",t,(function(t,e){return t.dialog.close(t.dialog.context.defaultResult)})),this},e.prototype.addCancelButton=function(t){return void 0===t&&(t="CANCEL"),this.addButton("vex-dialog-button-secondary vex-dialog-button vex-last",t,(function(t,e){return t.dialog.dismiss()})),this},e}(v);var g={component:l,content:c,okBtn:"OK",cancelBtn:"Cancel"},h=["okBtn","cancelBtn","placeholder"],x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),Object.defineProperty(e.prototype,"showInput",{get:function(){return this.dropInType===o.DROP_IN_TYPE.prompt},enumerable:!0,configurable:!0}),e}(y);var C=function(t){function e(e,n,i){return void 0===i&&(i=void 0),t.call(this,e,o.extend(o.extend({modal:e,dropInType:n},g),i||{}),h,x)||this}return s(e,t),e.prototype.$$beforeOpen=function(e){switch(t.prototype.$$beforeOpen.call(this,e),e.okBtn&&this.addOkButton(e.okBtn),e.dropInType){case o.DROP_IN_TYPE.prompt:e.defaultResult=void 0;break;case o.DROP_IN_TYPE.confirm:e.cancelBtn&&this.addCancelButton(e.cancelBtn)}},e}(f);var b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.apply=function(t){t.setClickBoundary(this.vexContentContainer.nativeElement),this.dialog.inElement&&(this.setStyle("padding","20px 0 0 0"),"bottom-right-corner"===this.dialog.context.className&&(this.setStyle("overflow-y","hidden"),this.renderer.setStyle(this.vexContentContainer.nativeElement,"position","absolute")))},e.decorators=[{type:n.Component,args:[{selector:"css-dialog-container",host:{tabindex:"-1",role:"dialog"},encapsulation:n.ViewEncapsulation.None,template:'<div #clickBoundary class="{{dialog.context.contentClassName}}"><ng-content></ng-content></div>'}]}],e.propDecorators={vexContentContainer:[{type:n.ViewChild,args:["clickBoundary",{read:n.ElementRef,static:!0}]}]},e}(o.CSSDialogContainer);var k=!("undefined"==typeof document||!document),B=!1;var N=function(t){function i(e){return t.call(this,e)||this}return s(i,t),i.prototype.alert=function(){return new C(this,o.DROP_IN_TYPE.alert,{isBlocking:!1})},i.prototype.prompt=function(){return new C(this,o.DROP_IN_TYPE.prompt,{isBlocking:!0,keyboard:null})},i.prototype.confirm=function(){return new C(this,o.DROP_IN_TYPE.confirm,{isBlocking:!0,keyboard:null})},i.prototype.create=function(t,e){var n=this;if(!0===B)return this.createV3(t,e);var i=this.createBackdrop(t,o.CSSBackdrop),a=this.createContainer(t,b,e),s=t.overlayRef.instance,r=i.instance,l=a.instance;return t.inElement?(s.insideElement(),s.setContainerStyle("position","relative").setContainerStyle("height","100%").setContainerStyle("width","100%"),r.setStyle("position","absolute").setStyle("display","block").setStyle("height","100%").setStyle("width","100%"),l.setStyle("position","relative").setStyle("display","block").setStyle("height","100%").setStyle("width","100%")):s.fullscreen(),k&&!document.body.classList.contains("vex-open")&&document.body.classList.add("vex-open"),r.addClass("vex-overlay"),l.addClass("vex vex-theme-"+t.context.className),l.setStyle("display","block"),a.location.nativeElement&&a.location.nativeElement.focus(),s.beforeDestroy((function(){r.addClass("vex-closing"),l.addClass("vex-closing");var e=new o.PromiseCompleter;return r.myAnimationEnd$().subscribe((function(o){k&&1===n.overlay.groupStackLength(t)&&document.body.classList.remove("vex-open"),e.resolve()})),e.promise})),l.apply(s),t},i.prototype.createV3=function(t,n){var i=this,a=this.createBackdrop(t,o.CSSBackdrop),s=this.createContainer(t,o.CSSDialogContainer,n),r=t.overlayRef.instance,l=a.instance,c=s.instance;return t.inElement?r.insideElement():r.fullscreen(),k&&!document.body.classList.contains("vex-open")&&document.body.classList.add("vex-open"),r.addClass("vex vex-theme-"+t.context.className),l.addClass("vex-overlay"),c.addClass(t.context.contentClassName),c.setStyle("display","block"),t.inElement&&(r.setStyle("padding","0"),c.setStyle("margin-top","20px")),s.location.nativeElement&&s.location.nativeElement.focus(),"bottom-right-corner"===t.context.className&&(r.setStyle("overflow-y","hidden"),c.setStyle("position","absolute")),r.beforeDestroy((function(){r.addClass("vex-closing");var n=new o.PromiseCompleter,a=c.myAnimationEnd$();return"bottom-right-corner"!==t.context.className&&(a=e.combineLatest.call(a,l.myAnimationEnd$(),(function(t,e){return[t,e]}))),a.subscribe((function(e){k&&1===i.overlay.groupStackLength(t)&&document.body.classList.remove("vex-open"),n.resolve()})),n.promise})),r.setClickBoundary(s.location.nativeElement),t},i.decorators=[{type:n.Injectable}],i.ctorParameters=function(){return[{type:o.Overlay}]},i}(o.Modal),E=[{provide:o.Modal,useClass:N},{provide:N,useClass:N}],S=function(){function t(){}return t.getProviders=function(){return E},t.decorators=[{type:n.NgModule,args:[{imports:[o.ModalModule,i.CommonModule],declarations:[b,r,c,l],providers:E,entryComponents:[b,l,c]}]}],t}();t.DialogFormModal=l,t.DialogPreset=y,t.DialogPresetBuilder=f,t.DropInPreset=x,t.DropInPresetBuilder=C,t.FormDropIn=c,t.Modal=N,t.VEXDialogButtons=r,t.VEXModalContext=p,t.VEXModalContextBuilder=v,t.VexModalModule=S,t.providers=E,t.vexV3Mode=function(){B=!0},t.ɵa=b,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ngx-modialog-7-plugins-vex.umd.min.js.map