Comparing version 0.1.0 to 0.1.1
@@ -404,3 +404,3 @@ 'use strict'; | ||
return new Promise(function ($return, $error) { | ||
var LayoutCtor, layout, DialogCtor, dialog; | ||
var LayoutCtor, layout, Component, dialog; | ||
if (Vue.prototype.$isServer) { return $return(); } // create layout | ||
@@ -415,26 +415,36 @@ | ||
}, this.context, options)); | ||
DialogCtor = Vue.extend(Object.assign({}, this._component, { | ||
parent: layout | ||
})); | ||
Component = this._component; | ||
if (this._component.primaryKey) { | ||
DialogCtor = DialogCtor.extend({ | ||
mixins: [Recordable] | ||
}); | ||
} | ||
if (typeof Component === 'object' && !Component.options) { | ||
Component = Vue.extend(Object.assign({}, this._component, { | ||
parent: layout | ||
})); | ||
if (this.hasAsyncPreload) { | ||
return Promise.resolve(ensureAsyncDatas(DialogCtor, Object.assign({}, this.context, { | ||
params: params | ||
}))).then(function ($await_2) { | ||
try { | ||
return $If_1.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
if (this._component.primaryKey) { | ||
Component = Component.extend({ | ||
mixins: [Recordable] | ||
}); | ||
} | ||
if (this.hasAsyncPreload) { | ||
return Promise.resolve(ensureAsyncDatas(Component, Object.assign({}, this.context, { | ||
params: params | ||
}))).then(function ($await_3) { | ||
try { | ||
return $If_2.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} | ||
function $If_2() { | ||
return $If_1.call(this); | ||
} | ||
return $If_2.call(this); | ||
} | ||
function $If_1() { | ||
dialog = new DialogCtor(merge({ | ||
dialog = new Component(merge({ | ||
propsData: params | ||
@@ -441,0 +451,0 @@ }, this.context, options)); |
@@ -398,3 +398,3 @@ import Vue from 'vue'; | ||
return new Promise(function ($return, $error) { | ||
var LayoutCtor, layout, DialogCtor, dialog; | ||
var LayoutCtor, layout, Component, dialog; | ||
if (Vue.prototype.$isServer) { return $return(); } // create layout | ||
@@ -409,26 +409,36 @@ | ||
}, this.context, options)); | ||
DialogCtor = Vue.extend(Object.assign({}, this._component, { | ||
parent: layout | ||
})); | ||
Component = this._component; | ||
if (this._component.primaryKey) { | ||
DialogCtor = DialogCtor.extend({ | ||
mixins: [Recordable] | ||
}); | ||
} | ||
if (typeof Component === 'object' && !Component.options) { | ||
Component = Vue.extend(Object.assign({}, this._component, { | ||
parent: layout | ||
})); | ||
if (this.hasAsyncPreload) { | ||
return Promise.resolve(ensureAsyncDatas(DialogCtor, Object.assign({}, this.context, { | ||
params: params | ||
}))).then(function ($await_2) { | ||
try { | ||
return $If_1.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
if (this._component.primaryKey) { | ||
Component = Component.extend({ | ||
mixins: [Recordable] | ||
}); | ||
} | ||
if (this.hasAsyncPreload) { | ||
return Promise.resolve(ensureAsyncDatas(Component, Object.assign({}, this.context, { | ||
params: params | ||
}))).then(function ($await_3) { | ||
try { | ||
return $If_2.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} | ||
function $If_2() { | ||
return $If_1.call(this); | ||
} | ||
return $If_2.call(this); | ||
} | ||
function $If_1() { | ||
dialog = new DialogCtor(merge({ | ||
dialog = new Component(merge({ | ||
propsData: params | ||
@@ -435,0 +445,0 @@ }, this.context, options)); |
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],n):n(t.vuedl={},t.Vue)}(this,function(t,n){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var e={computed:{$parameters:function(){return this.$options.propsData},isNewRecord:function(){return!this.$options.primaryKey||!this.$options.propsData||!this.$options.propsData[this.$options.primaryKey]}}},r={name:"Activable",data:function(){return{isActive:!1}},watch:{isActive:function(t){this._dialogInstance?void 0!==this._dialogInstance.isActive&&(this._dialogInstance.isActive=t):this.$parent&&void 0!==this.$parent.isActive&&(this.$parent.isActive=t)}},methods:{close:function(){this.isActive=!1}}},i={name:"Layoutable",mixins:[r],props:{width:{type:[String,Number],default:function(){return 450}},persistent:Boolean},data:function(){return{loading:!1}},computed:{isLayout:function(){return!0},getWidth:function(){return"string"==typeof this.width?this.width:this.width+"px"}},watch:{isActive:function(t){t||this._destroy()}},mounted:function(){this.isActive=!0},methods:{_destroy:function(){this.$destroy()},dismiss:function(){this.persistent||this.loading||(this.isActive=!1)},close:function(){this.isActive=!1}},beforeDestroy:function(){void 0!==this.$el.remove?this.$el.remove():this.$el.parentNode.removeChild(this.$el)}};var o=function(){this.__data__=[],this.size=0};var s=function(t,n){return t===n||t!=t&&n!=n};var u=function(t,n){for(var e=t.length;e--;)if(s(t[e][0],n))return e;return-1},a=Array.prototype.splice;var c=function(t){var n=this.__data__,e=u(n,t);return!(e<0||(e==n.length-1?n.pop():a.call(n,e,1),--this.size,0))};var f=function(t){var n=this.__data__,e=u(n,t);return e<0?void 0:n[e][1]};var h=function(t){return u(this.__data__,t)>-1};var l=function(t,n){var e=this.__data__,r=u(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this};function p(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}p.prototype.clear=o,p.prototype.delete=c,p.prototype.get=f,p.prototype.has=h,p.prototype.set=l;var v=p;var d=function(){this.__data__=new v,this.size=0};var y=function(t){var n=this.__data__,e=n.delete(t);return this.size=n.size,e};var _=function(t){return this.__data__.get(t)};var b=function(t){return this.__data__.has(t)},g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t,n){return t(n={exports:{}},n.exports),n.exports}var w="object"==typeof g&&g&&g.Object===Object&&g,j="object"==typeof self&&self&&self.Object===Object&&self,A=w||j||Function("return this")(),O=A.Symbol,$=Object.prototype,P=$.hasOwnProperty,x=$.toString,S=O?O.toStringTag:void 0;var z=function(t){var n=P.call(t,S),e=t[S];try{t[S]=void 0}catch(t){}var r=x.call(t);return n?t[S]=e:delete t[S],r},E=Object.prototype.toString;var L=function(t){return E.call(t)},T="[object Null]",F="[object Undefined]",I=O?O.toStringTag:void 0;var D=function(t){return null==t?void 0===t?F:T:I&&I in Object(t)?z(t):L(t)};var R=function(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)},k="[object AsyncFunction]",N="[object Function]",V="[object GeneratorFunction]",B="[object Proxy]";var q,U=function(t){if(!R(t))return!1;var n=D(t);return n==N||n==V||n==k||n==B},W=A["__core-js_shared__"],K=(q=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"";var G=function(t){return!!K&&K in t},J=Function.prototype.toString;var H=function(t){if(null!=t){try{return J.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Q=/^\[object .+?Constructor\]$/,X=Function.prototype,Y=Object.prototype,Z=X.toString,M=Y.hasOwnProperty,C=RegExp("^"+Z.call(M).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var tt=function(t){return!(!R(t)||G(t))&&(U(t)?C:Q).test(H(t))};var nt=function(t,n){return null==t?void 0:t[n]};var et=function(t,n){var e=nt(t,n);return tt(e)?e:void 0},rt=et(A,"Map"),it=et(Object,"create");var ot=function(){this.__data__=it?it(null):{},this.size=0};var st=function(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n},ut="__lodash_hash_undefined__",at=Object.prototype.hasOwnProperty;var ct=function(t){var n=this.__data__;if(it){var e=n[t];return e===ut?void 0:e}return at.call(n,t)?n[t]:void 0},ft=Object.prototype.hasOwnProperty;var ht=function(t){var n=this.__data__;return it?void 0!==n[t]:ft.call(n,t)},lt="__lodash_hash_undefined__";var pt=function(t,n){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=it&&void 0===n?lt:n,this};function vt(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}vt.prototype.clear=ot,vt.prototype.delete=st,vt.prototype.get=ct,vt.prototype.has=ht,vt.prototype.set=pt;var dt=vt;var yt=function(){this.size=0,this.__data__={hash:new dt,map:new(rt||v),string:new dt}};var _t=function(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t};var bt=function(t,n){var e=t.__data__;return _t(n)?e["string"==typeof n?"string":"hash"]:e.map};var gt=function(t){var n=bt(this,t).delete(t);return this.size-=n?1:0,n};var mt=function(t){return bt(this,t).get(t)};var wt=function(t){return bt(this,t).has(t)};var jt=function(t,n){var e=bt(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this};function At(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}At.prototype.clear=yt,At.prototype.delete=gt,At.prototype.get=mt,At.prototype.has=wt,At.prototype.set=jt;var Ot=At,$t=200;var Pt=function(t,n){var e=this.__data__;if(e instanceof v){var r=e.__data__;if(!rt||r.length<$t-1)return r.push([t,n]),this.size=++e.size,this;e=this.__data__=new Ot(r)}return e.set(t,n),this.size=e.size,this};function xt(t){var n=this.__data__=new v(t);this.size=n.size}xt.prototype.clear=d,xt.prototype.delete=y,xt.prototype.get=_,xt.prototype.has=b,xt.prototype.set=Pt;var St=xt,zt=function(){try{var t=et(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var Et=function(t,n,e){"__proto__"==n&&zt?zt(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e};var Lt=function(t,n,e){(void 0===e||s(t[n],e))&&(void 0!==e||n in t)||Et(t,n,e)};var Tt=function(t){return function(n,e,r){for(var i=-1,o=Object(n),s=r(n),u=s.length;u--;){var a=s[t?u:++i];if(!1===e(o[a],a,o))break}return n}}(),Ft=m(function(t,n){var e=n&&!n.nodeType&&n,r=e&&t&&!t.nodeType&&t,i=r&&r.exports===e?A.Buffer:void 0,o=i?i.allocUnsafe:void 0;t.exports=function(t,n){if(n)return t.slice();var e=t.length,r=o?o(e):new t.constructor(e);return t.copy(r),r}}),It=A.Uint8Array;var Dt=function(t){var n=new t.constructor(t.byteLength);return new It(n).set(new It(t)),n};var Rt=function(t,n){var e=n?Dt(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)};var kt=function(t,n){var e=-1,r=t.length;for(n||(n=Array(r));++e<r;)n[e]=t[e];return n},Nt=Object.create,Vt=function(){function t(){}return function(n){if(!R(n))return{};if(Nt)return Nt(n);t.prototype=n;var e=new t;return t.prototype=void 0,e}}();var Bt=function(t,n){return function(e){return t(n(e))}}(Object.getPrototypeOf,Object),qt=Object.prototype;var Ut=function(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||qt)};var Wt=function(t){return"function"!=typeof t.constructor||Ut(t)?{}:Vt(Bt(t))};var Kt=function(t){return null!=t&&"object"==typeof t},Gt="[object Arguments]";var Jt=function(t){return Kt(t)&&D(t)==Gt},Ht=Object.prototype,Qt=Ht.hasOwnProperty,Xt=Ht.propertyIsEnumerable,Yt=Jt(function(){return arguments}())?Jt:function(t){return Kt(t)&&Qt.call(t,"callee")&&!Xt.call(t,"callee")},Zt=Array.isArray,Mt=9007199254740991;var Ct=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Mt};var tn=function(t){return null!=t&&Ct(t.length)&&!U(t)};var nn=function(t){return Kt(t)&&tn(t)};var en=function(){return!1},rn=m(function(t,n){var e=n&&!n.nodeType&&n,r=e&&t&&!t.nodeType&&t,i=r&&r.exports===e?A.Buffer:void 0,o=(i?i.isBuffer:void 0)||en;t.exports=o}),on="[object Object]",sn=Function.prototype,un=Object.prototype,an=sn.toString,cn=un.hasOwnProperty,fn=an.call(Object);var hn=function(t){if(!Kt(t)||D(t)!=on)return!1;var n=Bt(t);if(null===n)return!0;var e=cn.call(n,"constructor")&&n.constructor;return"function"==typeof e&&e instanceof e&&an.call(e)==fn},ln={};ln["[object Float32Array]"]=ln["[object Float64Array]"]=ln["[object Int8Array]"]=ln["[object Int16Array]"]=ln["[object Int32Array]"]=ln["[object Uint8Array]"]=ln["[object Uint8ClampedArray]"]=ln["[object Uint16Array]"]=ln["[object Uint32Array]"]=!0,ln["[object Arguments]"]=ln["[object Array]"]=ln["[object ArrayBuffer]"]=ln["[object Boolean]"]=ln["[object DataView]"]=ln["[object Date]"]=ln["[object Error]"]=ln["[object Function]"]=ln["[object Map]"]=ln["[object Number]"]=ln["[object Object]"]=ln["[object RegExp]"]=ln["[object Set]"]=ln["[object String]"]=ln["[object WeakMap]"]=!1;var pn=function(t){return Kt(t)&&Ct(t.length)&&!!ln[D(t)]};var vn=function(t){return function(n){return t(n)}},dn=m(function(t,n){var e=n&&!n.nodeType&&n,r=e&&t&&!t.nodeType&&t,i=r&&r.exports===e&&w.process,o=function(){try{var t=r&&r.require&&r.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=o}),yn=dn&&dn.isTypedArray,_n=yn?vn(yn):pn;var bn=function(t,n){if("__proto__"!=n)return t[n]},gn=Object.prototype.hasOwnProperty;var mn=function(t,n,e){var r=t[n];gn.call(t,n)&&s(r,e)&&(void 0!==e||n in t)||Et(t,n,e)};var wn=function(t,n,e,r){var i=!e;e||(e={});for(var o=-1,s=n.length;++o<s;){var u=n[o],a=r?r(e[u],t[u],u,e,t):void 0;void 0===a&&(a=t[u]),i?Et(e,u,a):mn(e,u,a)}return e};var jn=function(t,n){for(var e=-1,r=Array(t);++e<t;)r[e]=n(e);return r},An=9007199254740991,On=/^(?:0|[1-9]\d*)$/;var $n=function(t,n){var e=typeof t;return!!(n=null==n?An:n)&&("number"==e||"symbol"!=e&&On.test(t))&&t>-1&&t%1==0&&t<n},Pn=Object.prototype.hasOwnProperty;var xn=function(t,n){var e=Zt(t),r=!e&&Yt(t),i=!e&&!r&&rn(t),o=!e&&!r&&!i&&_n(t),s=e||r||i||o,u=s?jn(t.length,String):[],a=u.length;for(var c in t)!n&&!Pn.call(t,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||$n(c,a))||u.push(c);return u};var Sn=function(t){var n=[];if(null!=t)for(var e in Object(t))n.push(e);return n},zn=Object.prototype.hasOwnProperty;var En=function(t){if(!R(t))return Sn(t);var n=Ut(t),e=[];for(var r in t)("constructor"!=r||!n&&zn.call(t,r))&&e.push(r);return e};var Ln=function(t){return tn(t)?xn(t,!0):En(t)};var Tn=function(t){return wn(t,Ln(t))};var Fn=function(t,n,e,r,i,o,s){var u=bn(t,e),a=bn(n,e),c=s.get(a);if(c)Lt(t,e,c);else{var f=o?o(u,a,e+"",t,n,s):void 0,h=void 0===f;if(h){var l=Zt(a),p=!l&&rn(a),v=!l&&!p&&_n(a);f=a,l||p||v?Zt(u)?f=u:nn(u)?f=kt(u):p?(h=!1,f=Ft(a,!0)):v?(h=!1,f=Rt(a,!0)):f=[]:hn(a)||Yt(a)?(f=u,Yt(u)?f=Tn(u):R(u)&&!U(u)||(f=Wt(a))):h=!1}h&&(s.set(a,f),i(f,a,r,o,s),s.delete(a)),Lt(t,e,f)}};var In=function t(n,e,r,i,o){n!==e&&Tt(e,function(s,u){if(R(s))o||(o=new St),Fn(n,e,u,r,t,i,o);else{var a=i?i(bn(n,u),s,u+"",n,e,o):void 0;void 0===a&&(a=s),Lt(n,u,a)}},Ln)};var Dn=function(t){return t};var Rn=function(t,n,e){switch(e.length){case 0:return t.call(n);case 1:return t.call(n,e[0]);case 2:return t.call(n,e[0],e[1]);case 3:return t.call(n,e[0],e[1],e[2])}return t.apply(n,e)},kn=Math.max;var Nn=function(t,n,e){return n=kn(void 0===n?t.length-1:n,0),function(){for(var r=arguments,i=-1,o=kn(r.length-n,0),s=Array(o);++i<o;)s[i]=r[n+i];i=-1;for(var u=Array(n+1);++i<n;)u[i]=r[i];return u[n]=e(s),Rn(t,this,u)}};var Vn=function(t){return function(){return t}},Bn=zt?function(t,n){return zt(t,"toString",{configurable:!0,enumerable:!1,value:Vn(n),writable:!0})}:Dn,qn=800,Un=16,Wn=Date.now;var Kn=function(t){var n=0,e=0;return function(){var r=Wn(),i=Un-(r-e);if(e=r,i>0){if(++n>=qn)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}(Bn);var Gn=function(t,n){return Kn(Nn(t,n,Dn),t+"")};var Jn=function(t,n,e){if(!R(e))return!1;var r=typeof n;return!!("number"==r?tn(e)&&$n(n,e.length):"string"==r&&n in e)&&s(e[n],t)};var Hn=function(t){return Gn(function(n,e){var r=-1,i=e.length,o=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(o=t.length>3&&"function"==typeof o?(i--,o):void 0,s&&Jn(e[0],e[1],s)&&(o=i<3?void 0:o,i=1),n=Object(n);++r<i;){var u=e[r];u&&t(n,u,r,o)}return n})}(function(t,n,e){In(t,n,e)});var Qn,Xn,Yn,Zn,Mn,Cn=(Qn={render:function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"dialog-layout"},[this._t("default")],2)},staticRenderFns:[]},Yn=void 0,Zn=!1,(Mn=("function"==typeof(Xn={})?Xn.options:Xn)||{}).__file="DefaultLayout.vue",Mn.render||(Mn.render=Qn.render,Mn.staticRenderFns=Qn.staticRenderFns,Mn._compiled=!0,Zn&&(Mn.functional=!0)),Mn._scopeId=Yn,Mn),te=function(){return{}};function ne(t){t&&!t._isDestroyed&&"function"==typeof t.$destroy&&t.$destroy()}function ee(t){var n;return(n="string"==typeof t?document.querySelector(t):t)||(n=document.body),n}function re(t,n){return new Promise(function(e,r){if(!Array.isArray(t)){if(!t)return e(null);t=[t]}return e(Promise.all(t.map(function(t){var e=[];if(t.options.asyncData&&"function"==typeof t.options.asyncData){var r=function(t,n){var e;return(e=2===t.length?new Promise(function(e){t(n,function(t,r){t&&n.error(t),e(r=r||{})})}):t(n))&&(e instanceof Promise||"function"==typeof e.then)||(e=Promise.resolve(e)),e}(t.options.asyncData,n);r.then(function(n){return function(t,n){var e=t.options.data||te;!n&&t.options.hasAsyncData||(t.options.hasAsyncData=!0,t.options.data=function(){var r=e.call(this);return this.$ssrContext&&(n=this.$ssrContext.asyncData[t.cid]),Object.assign({},r,n)},t._Ctor&&t._Ctor.options&&(t._Ctor.options.data=t.options.data))}(t,n),n}),e.push(r)}else e.push(null);return t.options.fetch?e.push(t.options.fetch(n)):e.push(null),Promise.all(e)})))})}var ie=1,oe=function(t,n){void 0===n&&(n={});var e=n.layout,r=n.container;if(!t)throw Error("Component was not setted");this._layout=e||{component:Cn,options:{}},this._component=t,this._vm=null,this._vmDialog=null,this._options={},this.id=++ie,this._resolvers=[],this.container=ee(r)},se={showed:{configurable:!0},element:{configurable:!0},hasAsyncPreload:{configurable:!0},vm:{configurable:!0},vmd:{configurable:!0}};oe.prototype.show=function(t,r){return void 0===t&&(t={}),void 0===r&&(r={}),new Promise(function(o,s){var u,a,c,f;if(n.prototype.$isServer)return o();if(u=(u=n.extend({mixins:[i]})).extend(this._layout.component),a=new u(Hn({propsData:Object.assign({},this._layout.options,t)},this.context,r)),c=n.extend(Object.assign({},this._component,{parent:a})),this._component.primaryKey&&(c=c.extend({mixins:[e]})),this.hasAsyncPreload)return Promise.resolve(re(c,Object.assign({},this.context,{params:t}))).then(function(t){try{return h.call(this)}catch(t){return s(t)}}.bind(this),s);function h(){return(f=new c(Hn({propsData:t},this.context,r))).$mount(),a.$slots.default=f._vnode,a.$mount(),a.$on("hook:destroyed",this._onDestroyed.bind(this)),a.$on("submit",this.onReturn.bind(this)),f.$on("submit",this.onReturn.bind(this)),this._vm=a,this._vm._dialogInstance=f,this._vmDialog=f,this.container=r.container?ee(r.container):this.container,this.container.appendChild(this.element),o(this)}return h.call(this)}.bind(this))},oe.prototype.wait=function(){var t=this;return new Promise(function(n){t._resolvers.push(n)})},oe.prototype._onDestroyed=function(){this.remove()},oe.prototype.remove=function(){this.onDestroyed&&this.onDestroyed(this),this._processResultPromises(),ne(this._vm),ne(this._vmDialog),this._vm=null,this._vmDialog=null},oe.prototype._processResultPromises=function(t){this._resolvers.length&&(this._resolvers.forEach(function(n){return n(t)}),this._resolvers=[])},oe.prototype.onReturn=function(t){this._processResultPromises(t),this.close()},se.showed.get=function(){return!!this._vm&&!this._vm._isDestroyed},se.element.get=function(){return this._vm&&this._vm.$el},se.hasAsyncPreload.get=function(){return this._component&&(this._component.asyncData||this._component.fetch)},se.vm.get=function(){return this._vm},se.vmd.get=function(){return this._vmDialog},oe.prototype.close=function(){this._vm&&this._vm.close()},Object.defineProperties(oe.prototype,se);var ue=function(t){this._component=t,this._vm=null};ue.prototype.show=function(){if(!this._vm){var t=n.extend(this._component);this._vm=new t,this._vm.$mount(),document.body.appendChild(this._vm.$el)}this._vm.visible=!0},ue.prototype.hide=function(){this._vm.visible=!1};var ae={get:function(t,n){return"symbol"==typeof n||"inspect"===n?t[n]:t[n]?t[n]:t._components[n]?t.createFunctionWrapper(n):t[n]}},ce=function(t){void 0===t&&(t={});var e=t.context,r=t.container;return this._context=e||{},oe.prototype.context=e||{},this._components={},this._layouts={},this._overlays={},this._container=r,this._emitter=new n({}),this._instances=[],new Proxy(this,ae)},fe={context:{configurable:!0}};fe.context.get=function(){return this._context},ce.prototype.layout=function(t,n,e){void 0===e&&(e={}),this._layouts[t]={component:n,options:e}},ce.prototype.getLayout=function(t){if("function"==typeof t){var n=t.call(this._context);return t=this._layouts[n.name||"default"],Object.assign({},t,{options:n})}if("object"==typeof t&&"function"==typeof t.render)return{component:t};if(Array.isArray(t)){var e=t[0],r=t[1]||{},i="object"==typeof e&&"function"==typeof e.render?{component:e}:this._layouts[e];return i&&{component:i.component,options:Object.assign({},i.options,r)}}return this._layouts[t]},ce.prototype.overlay=function(t,n){if(void 0===n){if(this._overlays[t])return this._overlays[t];throw new Error('Overlay "'+t+" not found\n Please register it by calling dialog.overlay('"+t+"', component)")}this._overlays[t]=new ue(n)},ce.prototype.getComponent=function(t){if(!this._components[t])throw new Error('Component "'+t+"\" was not found.\n Please register it by calling dialog.register('"+t+"', component)");return this._components[t]},ce.prototype.component=function(t,n,e){if(void 0===e&&(e={}),void 0===n)return this._components[t];this._components[t]={component:n,options:e}},ce.prototype.create=function(t){if(!t)throw new Error("Component is incorrect");var n=this.getLayout(t.layout||"default"),e=new oe(t,{layout:n,context:this._context,container:this._container});return this._emitter.$emit("created",{dialog:e}),e},ce.prototype.show=function(t,n){return void 0===n&&(n={}),new Promise(function(e,r){var i,o,s;o=!!(i=this.create(t)).hasAsyncPreload&&(t.overlay||"default"),(s=o&&this._overlays[o]&&this.overlay(o))&&s.show();var u=function(t){try{throw this._emitter.$emit("error",{error:t,dialog:i}),s&&s.hide(),t}catch(t){return r(t)}}.bind(this);try{return Promise.resolve(i.show(n)).then(function(t){try{return this._emitter.$emit("shown",{dialog:i}),s&&s.hide(),i.onDestroyed=this.onDialogDestroyed.bind(this),e(n.waitForResult?i.wait():i)}catch(t){return u(t)}}.bind(this),u)}catch(t){u(t)}}.bind(this))},ce.prototype.createFunctionWrapper=function(t){var n=this,e=this.getComponent(t);return function(t){return n.show(e.component,Object.assign({},e.options,t))}},ce.prototype.showAndWait=function(t,n){return new Promise(function(e,r){return Promise.resolve(this.show(t,n)).then(function(t){try{return e(t.wait())}catch(t){return r(t)}},r)}.bind(this))},ce.prototype.on=function(t,n){this._emitter.$on(t,n)},ce.prototype.off=function(t,n){this._emitter.$off(t,n)},ce.prototype.once=function(t,n){this._emitter.$once(t,n)},ce.prototype.onDialogDestroyed=function(t){this._emitter.$emit("destroyed",{dialog:t})},Object.defineProperties(ce.prototype,fe);var he={name:"Returnable",props:{returnValue:null},data:function(){return{originalValue:this.returnValue,returnResovers:[]}},methods:{return:function(t){this.originalValue=t,this.$root.$emit("submit",this.originalValue),this.$emit("submit",this.originalValue)}}},le={name:"Actionable",mixins:[he],data:function(){return{loadingAction:null}},props:{actions:{type:[Array,Object],default:function(){return[]}},handle:Function,params:Object},computed:{actionlist:function(){var t=[];for(var n in this.actions){var e=this.actions[n];"string"==typeof e&&(e={text:e}),e.key||(e.key=isNaN(n)?n:e.text||n),["true","false"].indexOf(e.key)>=0&&(e.key=JSON.parse(e.key)),this.isActionVisible(e)&&("string"==typeof e.icon&&(e.icon={text:e.icon}),t.push(e))}return t}},methods:{trigger:function(t){var n=this.actionlist.find(function(n){return n.key===t});n&&!this.isActionDisabled(n)&&this.isActionVisible(n)&&this.onActionClick(n)},setLoadingToInstance:function(t,n){t&&void 0!==t.loading&&(t.loading=n)},setLoadingState:function(t){this.$emit("loading",t),!t&&(this.loadingAction=null),this.setLoadingToInstance(this.$root,t),this.setLoadingToInstance(this.$root._dialogInstance,t)},get:function(t,n){return void 0===t?n:"function"==typeof t?t(this.params):t},isActionDisabled:function(t){return this.get(t.disabled,!1)},isActionVisible:function(t){return this.get(t.visible,!0)},isActionInLoading:function(t){return this.loadingAction===t.key||this.get(t.loading)},onActionClick:function(t){return new Promise(function(n,e){var r,i;if(r=void 0===t.closable||!0===t.closable,"function"!=typeof(i=t.handle||this.handle))return r&&this.return(t.key),a.call(this);this.loadingAction=t.key,this.setLoadingState(!0);var o=function(){try{return a.call(this)}catch(t){return e(t)}}.bind(this),s=function(t){try{throw this.setLoadingState(!1),console.log("error",t),t}catch(t){return e(t)}}.bind(this);try{var u;return Promise.resolve(i(this.params)).then(function(n){try{return u=n,this.setLoadingState(!1),!1!==u&&r&&this.return(u||t.key),o()}catch(t){return s(t)}}.bind(this),s)}catch(t){s(t)}function a(){return n()}}.bind(this))}}},pe={name:"Confirmable",props:{type:{type:String},text:{type:String,reqiured:!0},title:{type:String},actions:{type:[Array,Object]}}},ve=[],de={props:{verticalOffset:Number,showClose:{type:Boolean,default:function(){return!0}},position:{type:String,default:function(){return"top-right"}},timeout:{type:[Number,Boolean],default:function(){return 4500}},width:{type:Number,default:function(){return 330}},zIndex:{type:Number,default:function(){return 2e3}}},computed:{horizontalClass:function(){return this.position.indexOf("right")>-1?"right":"left"},verticalProperty:function(){return/^top-/.test(this.position)?"top":"bottom"},getStyle:function(){var t;return(t={})[this.verticalProperty]=this.verticalOffset+"px",t["max-width"]=this.width+"px",t["z-index"]=this.zIndex,t}},methods:{_destroy:function(){this.$el.addEventListener("transitionend",this.onTransitionEnd)},onTransitionEnd:function(){this.$el.removeEventListener("transitionend",this.onTransitionEnd),this.$destroy()},clearTimer:function(){clearTimeout(this.timer)},startTimer:function(){this.timeout>0&&(this.timer=setTimeout(this.close,this.timeout))},keydown:function(t){46===t.keyCode||8===t.keyCode?this.clearTimer():27===t.keyCode?this.close():this.startTimer()},close:function(){this.isActive=!1}},watch:{isActive:function(t){var n,e,r;t?(e=(n=this).position,r=10,ve.filter(function(t){return t.position===e}).forEach(function(t){r+=t.$el.offsetHeight+10}),ve.push(n),n.verticalOffset=r):function(t){var n=ve.findIndex(function(n){return n===t});if(!(n<0)){ve.splice(n,1);var e=ve.length,r=t.position;if(e){var i=10;ve.filter(function(t){return t.position===r}).forEach(function(t){t.verticalOffset=i,i+=t.$el.offsetHeight+10})}}}(this)}},mounted:function(){this.startTimer(),document.addEventListener("keydown",this.keydown)},beforeDestroy:function(){document.removeEventListener("keydown",this.keydown)}};var ye={install:function(t,n){void 0===n&&(n={});var e=n.property||"$dialog",r=new ce(n);Object.defineProperty(t.prototype,e,{get:function(){return r}})}},_e=null;"undefined"!=typeof window?_e=window.Vue:"undefined"!=typeof global&&(_e=global.Vue),_e&&_e.use(ye),t.default=ye,t.Actionable=le,t.Activable=r,t.Confirmable=pe,t.Notifiable=de,t.Recordable=e,t.Returnable=he,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],n):n(t.vuedl={},t.Vue)}(this,function(t,n){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var e={computed:{$parameters:function(){return this.$options.propsData},isNewRecord:function(){return!this.$options.primaryKey||!this.$options.propsData||!this.$options.propsData[this.$options.primaryKey]}}},r={name:"Activable",data:function(){return{isActive:!1}},watch:{isActive:function(t){this._dialogInstance?void 0!==this._dialogInstance.isActive&&(this._dialogInstance.isActive=t):this.$parent&&void 0!==this.$parent.isActive&&(this.$parent.isActive=t)}},methods:{close:function(){this.isActive=!1}}},i={name:"Layoutable",mixins:[r],props:{width:{type:[String,Number],default:function(){return 450}},persistent:Boolean},data:function(){return{loading:!1}},computed:{isLayout:function(){return!0},getWidth:function(){return"string"==typeof this.width?this.width:this.width+"px"}},watch:{isActive:function(t){t||this._destroy()}},mounted:function(){this.isActive=!0},methods:{_destroy:function(){this.$destroy()},dismiss:function(){this.persistent||this.loading||(this.isActive=!1)},close:function(){this.isActive=!1}},beforeDestroy:function(){void 0!==this.$el.remove?this.$el.remove():this.$el.parentNode.removeChild(this.$el)}};var o=function(){this.__data__=[],this.size=0};var s=function(t,n){return t===n||t!=t&&n!=n};var u=function(t,n){for(var e=t.length;e--;)if(s(t[e][0],n))return e;return-1},a=Array.prototype.splice;var c=function(t){var n=this.__data__,e=u(n,t);return!(e<0||(e==n.length-1?n.pop():a.call(n,e,1),--this.size,0))};var f=function(t){var n=this.__data__,e=u(n,t);return e<0?void 0:n[e][1]};var h=function(t){return u(this.__data__,t)>-1};var l=function(t,n){var e=this.__data__,r=u(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this};function p(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}p.prototype.clear=o,p.prototype.delete=c,p.prototype.get=f,p.prototype.has=h,p.prototype.set=l;var v=p;var d=function(){this.__data__=new v,this.size=0};var y=function(t){var n=this.__data__,e=n.delete(t);return this.size=n.size,e};var _=function(t){return this.__data__.get(t)};var b=function(t){return this.__data__.has(t)},g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t,n){return t(n={exports:{}},n.exports),n.exports}var w="object"==typeof g&&g&&g.Object===Object&&g,j="object"==typeof self&&self&&self.Object===Object&&self,A=w||j||Function("return this")(),O=A.Symbol,$=Object.prototype,P=$.hasOwnProperty,x=$.toString,S=O?O.toStringTag:void 0;var z=function(t){var n=P.call(t,S),e=t[S];try{t[S]=void 0}catch(t){}var r=x.call(t);return n?t[S]=e:delete t[S],r},E=Object.prototype.toString;var L=function(t){return E.call(t)},T="[object Null]",F="[object Undefined]",I=O?O.toStringTag:void 0;var D=function(t){return null==t?void 0===t?F:T:I&&I in Object(t)?z(t):L(t)};var R=function(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)},k="[object AsyncFunction]",N="[object Function]",V="[object GeneratorFunction]",B="[object Proxy]";var q,U=function(t){if(!R(t))return!1;var n=D(t);return n==N||n==V||n==k||n==B},W=A["__core-js_shared__"],K=(q=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"";var G=function(t){return!!K&&K in t},J=Function.prototype.toString;var H=function(t){if(null!=t){try{return J.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Q=/^\[object .+?Constructor\]$/,X=Function.prototype,Y=Object.prototype,Z=X.toString,M=Y.hasOwnProperty,C=RegExp("^"+Z.call(M).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var tt=function(t){return!(!R(t)||G(t))&&(U(t)?C:Q).test(H(t))};var nt=function(t,n){return null==t?void 0:t[n]};var et=function(t,n){var e=nt(t,n);return tt(e)?e:void 0},rt=et(A,"Map"),it=et(Object,"create");var ot=function(){this.__data__=it?it(null):{},this.size=0};var st=function(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n},ut="__lodash_hash_undefined__",at=Object.prototype.hasOwnProperty;var ct=function(t){var n=this.__data__;if(it){var e=n[t];return e===ut?void 0:e}return at.call(n,t)?n[t]:void 0},ft=Object.prototype.hasOwnProperty;var ht=function(t){var n=this.__data__;return it?void 0!==n[t]:ft.call(n,t)},lt="__lodash_hash_undefined__";var pt=function(t,n){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=it&&void 0===n?lt:n,this};function vt(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}vt.prototype.clear=ot,vt.prototype.delete=st,vt.prototype.get=ct,vt.prototype.has=ht,vt.prototype.set=pt;var dt=vt;var yt=function(){this.size=0,this.__data__={hash:new dt,map:new(rt||v),string:new dt}};var _t=function(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t};var bt=function(t,n){var e=t.__data__;return _t(n)?e["string"==typeof n?"string":"hash"]:e.map};var gt=function(t){var n=bt(this,t).delete(t);return this.size-=n?1:0,n};var mt=function(t){return bt(this,t).get(t)};var wt=function(t){return bt(this,t).has(t)};var jt=function(t,n){var e=bt(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this};function At(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}At.prototype.clear=yt,At.prototype.delete=gt,At.prototype.get=mt,At.prototype.has=wt,At.prototype.set=jt;var Ot=At,$t=200;var Pt=function(t,n){var e=this.__data__;if(e instanceof v){var r=e.__data__;if(!rt||r.length<$t-1)return r.push([t,n]),this.size=++e.size,this;e=this.__data__=new Ot(r)}return e.set(t,n),this.size=e.size,this};function xt(t){var n=this.__data__=new v(t);this.size=n.size}xt.prototype.clear=d,xt.prototype.delete=y,xt.prototype.get=_,xt.prototype.has=b,xt.prototype.set=Pt;var St=xt,zt=function(){try{var t=et(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var Et=function(t,n,e){"__proto__"==n&&zt?zt(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e};var Lt=function(t,n,e){(void 0===e||s(t[n],e))&&(void 0!==e||n in t)||Et(t,n,e)};var Tt=function(t){return function(n,e,r){for(var i=-1,o=Object(n),s=r(n),u=s.length;u--;){var a=s[t?u:++i];if(!1===e(o[a],a,o))break}return n}}(),Ft=m(function(t,n){var e=n&&!n.nodeType&&n,r=e&&t&&!t.nodeType&&t,i=r&&r.exports===e?A.Buffer:void 0,o=i?i.allocUnsafe:void 0;t.exports=function(t,n){if(n)return t.slice();var e=t.length,r=o?o(e):new t.constructor(e);return t.copy(r),r}}),It=A.Uint8Array;var Dt=function(t){var n=new t.constructor(t.byteLength);return new It(n).set(new It(t)),n};var Rt=function(t,n){var e=n?Dt(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)};var kt=function(t,n){var e=-1,r=t.length;for(n||(n=Array(r));++e<r;)n[e]=t[e];return n},Nt=Object.create,Vt=function(){function t(){}return function(n){if(!R(n))return{};if(Nt)return Nt(n);t.prototype=n;var e=new t;return t.prototype=void 0,e}}();var Bt=function(t,n){return function(e){return t(n(e))}}(Object.getPrototypeOf,Object),qt=Object.prototype;var Ut=function(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||qt)};var Wt=function(t){return"function"!=typeof t.constructor||Ut(t)?{}:Vt(Bt(t))};var Kt=function(t){return null!=t&&"object"==typeof t},Gt="[object Arguments]";var Jt=function(t){return Kt(t)&&D(t)==Gt},Ht=Object.prototype,Qt=Ht.hasOwnProperty,Xt=Ht.propertyIsEnumerable,Yt=Jt(function(){return arguments}())?Jt:function(t){return Kt(t)&&Qt.call(t,"callee")&&!Xt.call(t,"callee")},Zt=Array.isArray,Mt=9007199254740991;var Ct=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Mt};var tn=function(t){return null!=t&&Ct(t.length)&&!U(t)};var nn=function(t){return Kt(t)&&tn(t)};var en=function(){return!1},rn=m(function(t,n){var e=n&&!n.nodeType&&n,r=e&&t&&!t.nodeType&&t,i=r&&r.exports===e?A.Buffer:void 0,o=(i?i.isBuffer:void 0)||en;t.exports=o}),on="[object Object]",sn=Function.prototype,un=Object.prototype,an=sn.toString,cn=un.hasOwnProperty,fn=an.call(Object);var hn=function(t){if(!Kt(t)||D(t)!=on)return!1;var n=Bt(t);if(null===n)return!0;var e=cn.call(n,"constructor")&&n.constructor;return"function"==typeof e&&e instanceof e&&an.call(e)==fn},ln={};ln["[object Float32Array]"]=ln["[object Float64Array]"]=ln["[object Int8Array]"]=ln["[object Int16Array]"]=ln["[object Int32Array]"]=ln["[object Uint8Array]"]=ln["[object Uint8ClampedArray]"]=ln["[object Uint16Array]"]=ln["[object Uint32Array]"]=!0,ln["[object Arguments]"]=ln["[object Array]"]=ln["[object ArrayBuffer]"]=ln["[object Boolean]"]=ln["[object DataView]"]=ln["[object Date]"]=ln["[object Error]"]=ln["[object Function]"]=ln["[object Map]"]=ln["[object Number]"]=ln["[object Object]"]=ln["[object RegExp]"]=ln["[object Set]"]=ln["[object String]"]=ln["[object WeakMap]"]=!1;var pn=function(t){return Kt(t)&&Ct(t.length)&&!!ln[D(t)]};var vn=function(t){return function(n){return t(n)}},dn=m(function(t,n){var e=n&&!n.nodeType&&n,r=e&&t&&!t.nodeType&&t,i=r&&r.exports===e&&w.process,o=function(){try{var t=r&&r.require&&r.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=o}),yn=dn&&dn.isTypedArray,_n=yn?vn(yn):pn;var bn=function(t,n){if("__proto__"!=n)return t[n]},gn=Object.prototype.hasOwnProperty;var mn=function(t,n,e){var r=t[n];gn.call(t,n)&&s(r,e)&&(void 0!==e||n in t)||Et(t,n,e)};var wn=function(t,n,e,r){var i=!e;e||(e={});for(var o=-1,s=n.length;++o<s;){var u=n[o],a=r?r(e[u],t[u],u,e,t):void 0;void 0===a&&(a=t[u]),i?Et(e,u,a):mn(e,u,a)}return e};var jn=function(t,n){for(var e=-1,r=Array(t);++e<t;)r[e]=n(e);return r},An=9007199254740991,On=/^(?:0|[1-9]\d*)$/;var $n=function(t,n){var e=typeof t;return!!(n=null==n?An:n)&&("number"==e||"symbol"!=e&&On.test(t))&&t>-1&&t%1==0&&t<n},Pn=Object.prototype.hasOwnProperty;var xn=function(t,n){var e=Zt(t),r=!e&&Yt(t),i=!e&&!r&&rn(t),o=!e&&!r&&!i&&_n(t),s=e||r||i||o,u=s?jn(t.length,String):[],a=u.length;for(var c in t)!n&&!Pn.call(t,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||$n(c,a))||u.push(c);return u};var Sn=function(t){var n=[];if(null!=t)for(var e in Object(t))n.push(e);return n},zn=Object.prototype.hasOwnProperty;var En=function(t){if(!R(t))return Sn(t);var n=Ut(t),e=[];for(var r in t)("constructor"!=r||!n&&zn.call(t,r))&&e.push(r);return e};var Ln=function(t){return tn(t)?xn(t,!0):En(t)};var Tn=function(t){return wn(t,Ln(t))};var Fn=function(t,n,e,r,i,o,s){var u=bn(t,e),a=bn(n,e),c=s.get(a);if(c)Lt(t,e,c);else{var f=o?o(u,a,e+"",t,n,s):void 0,h=void 0===f;if(h){var l=Zt(a),p=!l&&rn(a),v=!l&&!p&&_n(a);f=a,l||p||v?Zt(u)?f=u:nn(u)?f=kt(u):p?(h=!1,f=Ft(a,!0)):v?(h=!1,f=Rt(a,!0)):f=[]:hn(a)||Yt(a)?(f=u,Yt(u)?f=Tn(u):R(u)&&!U(u)||(f=Wt(a))):h=!1}h&&(s.set(a,f),i(f,a,r,o,s),s.delete(a)),Lt(t,e,f)}};var In=function t(n,e,r,i,o){n!==e&&Tt(e,function(s,u){if(R(s))o||(o=new St),Fn(n,e,u,r,t,i,o);else{var a=i?i(bn(n,u),s,u+"",n,e,o):void 0;void 0===a&&(a=s),Lt(n,u,a)}},Ln)};var Dn=function(t){return t};var Rn=function(t,n,e){switch(e.length){case 0:return t.call(n);case 1:return t.call(n,e[0]);case 2:return t.call(n,e[0],e[1]);case 3:return t.call(n,e[0],e[1],e[2])}return t.apply(n,e)},kn=Math.max;var Nn=function(t,n,e){return n=kn(void 0===n?t.length-1:n,0),function(){for(var r=arguments,i=-1,o=kn(r.length-n,0),s=Array(o);++i<o;)s[i]=r[n+i];i=-1;for(var u=Array(n+1);++i<n;)u[i]=r[i];return u[n]=e(s),Rn(t,this,u)}};var Vn=function(t){return function(){return t}},Bn=zt?function(t,n){return zt(t,"toString",{configurable:!0,enumerable:!1,value:Vn(n),writable:!0})}:Dn,qn=800,Un=16,Wn=Date.now;var Kn=function(t){var n=0,e=0;return function(){var r=Wn(),i=Un-(r-e);if(e=r,i>0){if(++n>=qn)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}(Bn);var Gn=function(t,n){return Kn(Nn(t,n,Dn),t+"")};var Jn=function(t,n,e){if(!R(e))return!1;var r=typeof n;return!!("number"==r?tn(e)&&$n(n,e.length):"string"==r&&n in e)&&s(e[n],t)};var Hn=function(t){return Gn(function(n,e){var r=-1,i=e.length,o=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(o=t.length>3&&"function"==typeof o?(i--,o):void 0,s&&Jn(e[0],e[1],s)&&(o=i<3?void 0:o,i=1),n=Object(n);++r<i;){var u=e[r];u&&t(n,u,r,o)}return n})}(function(t,n,e){In(t,n,e)});var Qn,Xn,Yn,Zn,Mn,Cn=(Qn={render:function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"dialog-layout"},[this._t("default")],2)},staticRenderFns:[]},Yn=void 0,Zn=!1,(Mn=("function"==typeof(Xn={})?Xn.options:Xn)||{}).__file="DefaultLayout.vue",Mn.render||(Mn.render=Qn.render,Mn.staticRenderFns=Qn.staticRenderFns,Mn._compiled=!0,Zn&&(Mn.functional=!0)),Mn._scopeId=Yn,Mn),te=function(){return{}};function ne(t){t&&!t._isDestroyed&&"function"==typeof t.$destroy&&t.$destroy()}function ee(t){var n;return(n="string"==typeof t?document.querySelector(t):t)||(n=document.body),n}function re(t,n){return new Promise(function(e,r){if(!Array.isArray(t)){if(!t)return e(null);t=[t]}return e(Promise.all(t.map(function(t){var e=[];if(t.options.asyncData&&"function"==typeof t.options.asyncData){var r=function(t,n){var e;return(e=2===t.length?new Promise(function(e){t(n,function(t,r){t&&n.error(t),e(r=r||{})})}):t(n))&&(e instanceof Promise||"function"==typeof e.then)||(e=Promise.resolve(e)),e}(t.options.asyncData,n);r.then(function(n){return function(t,n){var e=t.options.data||te;!n&&t.options.hasAsyncData||(t.options.hasAsyncData=!0,t.options.data=function(){var r=e.call(this);return this.$ssrContext&&(n=this.$ssrContext.asyncData[t.cid]),Object.assign({},r,n)},t._Ctor&&t._Ctor.options&&(t._Ctor.options.data=t.options.data))}(t,n),n}),e.push(r)}else e.push(null);return t.options.fetch?e.push(t.options.fetch(n)):e.push(null),Promise.all(e)})))})}var ie=1,oe=function(t,n){void 0===n&&(n={});var e=n.layout,r=n.container;if(!t)throw Error("Component was not setted");this._layout=e||{component:Cn,options:{}},this._component=t,this._vm=null,this._vmDialog=null,this._options={},this.id=++ie,this._resolvers=[],this.container=ee(r)},se={showed:{configurable:!0},element:{configurable:!0},hasAsyncPreload:{configurable:!0},vm:{configurable:!0},vmd:{configurable:!0}};oe.prototype.show=function(t,r){return void 0===t&&(t={}),void 0===r&&(r={}),new Promise(function(o,s){var u,a,c,f;if(n.prototype.$isServer)return o();if(u=(u=n.extend({mixins:[i]})).extend(this._layout.component),a=new u(Hn({propsData:Object.assign({},this._layout.options,t)},this.context,r)),"object"==typeof(c=this._component)&&!c.options){if(c=n.extend(Object.assign({},this._component,{parent:a})),this._component.primaryKey&&(c=c.extend({mixins:[e]})),this.hasAsyncPreload)return Promise.resolve(re(c,Object.assign({},this.context,{params:t}))).then(function(t){try{return h.call(this)}catch(t){return s(t)}}.bind(this),s);function h(){return l.call(this)}return h.call(this)}function l(){return(f=new c(Hn({propsData:t},this.context,r))).$mount(),a.$slots.default=f._vnode,a.$mount(),a.$on("hook:destroyed",this._onDestroyed.bind(this)),a.$on("submit",this.onReturn.bind(this)),f.$on("submit",this.onReturn.bind(this)),this._vm=a,this._vm._dialogInstance=f,this._vmDialog=f,this.container=r.container?ee(r.container):this.container,this.container.appendChild(this.element),o(this)}return l.call(this)}.bind(this))},oe.prototype.wait=function(){var t=this;return new Promise(function(n){t._resolvers.push(n)})},oe.prototype._onDestroyed=function(){this.remove()},oe.prototype.remove=function(){this.onDestroyed&&this.onDestroyed(this),this._processResultPromises(),ne(this._vm),ne(this._vmDialog),this._vm=null,this._vmDialog=null},oe.prototype._processResultPromises=function(t){this._resolvers.length&&(this._resolvers.forEach(function(n){return n(t)}),this._resolvers=[])},oe.prototype.onReturn=function(t){this._processResultPromises(t),this.close()},se.showed.get=function(){return!!this._vm&&!this._vm._isDestroyed},se.element.get=function(){return this._vm&&this._vm.$el},se.hasAsyncPreload.get=function(){return this._component&&(this._component.asyncData||this._component.fetch)},se.vm.get=function(){return this._vm},se.vmd.get=function(){return this._vmDialog},oe.prototype.close=function(){this._vm&&this._vm.close()},Object.defineProperties(oe.prototype,se);var ue=function(t){this._component=t,this._vm=null};ue.prototype.show=function(){if(!this._vm){var t=n.extend(this._component);this._vm=new t,this._vm.$mount(),document.body.appendChild(this._vm.$el)}this._vm.visible=!0},ue.prototype.hide=function(){this._vm.visible=!1};var ae={get:function(t,n){return"symbol"==typeof n||"inspect"===n?t[n]:t[n]?t[n]:t._components[n]?t.createFunctionWrapper(n):t[n]}},ce=function(t){void 0===t&&(t={});var e=t.context,r=t.container;return this._context=e||{},oe.prototype.context=e||{},this._components={},this._layouts={},this._overlays={},this._container=r,this._emitter=new n({}),this._instances=[],new Proxy(this,ae)},fe={context:{configurable:!0}};fe.context.get=function(){return this._context},ce.prototype.layout=function(t,n,e){void 0===e&&(e={}),this._layouts[t]={component:n,options:e}},ce.prototype.getLayout=function(t){if("function"==typeof t){var n=t.call(this._context);return t=this._layouts[n.name||"default"],Object.assign({},t,{options:n})}if("object"==typeof t&&"function"==typeof t.render)return{component:t};if(Array.isArray(t)){var e=t[0],r=t[1]||{},i="object"==typeof e&&"function"==typeof e.render?{component:e}:this._layouts[e];return i&&{component:i.component,options:Object.assign({},i.options,r)}}return this._layouts[t]},ce.prototype.overlay=function(t,n){if(void 0===n){if(this._overlays[t])return this._overlays[t];throw new Error('Overlay "'+t+" not found\n Please register it by calling dialog.overlay('"+t+"', component)")}this._overlays[t]=new ue(n)},ce.prototype.getComponent=function(t){if(!this._components[t])throw new Error('Component "'+t+"\" was not found.\n Please register it by calling dialog.register('"+t+"', component)");return this._components[t]},ce.prototype.component=function(t,n,e){if(void 0===e&&(e={}),void 0===n)return this._components[t];this._components[t]={component:n,options:e}},ce.prototype.create=function(t){if(!t)throw new Error("Component is incorrect");var n=this.getLayout(t.layout||"default"),e=new oe(t,{layout:n,context:this._context,container:this._container});return this._emitter.$emit("created",{dialog:e}),e},ce.prototype.show=function(t,n){return void 0===n&&(n={}),new Promise(function(e,r){var i,o,s;o=!!(i=this.create(t)).hasAsyncPreload&&(t.overlay||"default"),(s=o&&this._overlays[o]&&this.overlay(o))&&s.show();var u=function(t){try{throw this._emitter.$emit("error",{error:t,dialog:i}),s&&s.hide(),t}catch(t){return r(t)}}.bind(this);try{return Promise.resolve(i.show(n)).then(function(t){try{return this._emitter.$emit("shown",{dialog:i}),s&&s.hide(),i.onDestroyed=this.onDialogDestroyed.bind(this),e(n.waitForResult?i.wait():i)}catch(t){return u(t)}}.bind(this),u)}catch(t){u(t)}}.bind(this))},ce.prototype.createFunctionWrapper=function(t){var n=this,e=this.getComponent(t);return function(t){return n.show(e.component,Object.assign({},e.options,t))}},ce.prototype.showAndWait=function(t,n){return new Promise(function(e,r){return Promise.resolve(this.show(t,n)).then(function(t){try{return e(t.wait())}catch(t){return r(t)}},r)}.bind(this))},ce.prototype.on=function(t,n){this._emitter.$on(t,n)},ce.prototype.off=function(t,n){this._emitter.$off(t,n)},ce.prototype.once=function(t,n){this._emitter.$once(t,n)},ce.prototype.onDialogDestroyed=function(t){this._emitter.$emit("destroyed",{dialog:t})},Object.defineProperties(ce.prototype,fe);var he={name:"Returnable",props:{returnValue:null},data:function(){return{originalValue:this.returnValue,returnResovers:[]}},methods:{return:function(t){this.originalValue=t,this.$root.$emit("submit",this.originalValue),this.$emit("submit",this.originalValue)}}},le={name:"Actionable",mixins:[he],data:function(){return{loadingAction:null}},props:{actions:{type:[Array,Object],default:function(){return[]}},handle:Function,params:Object},computed:{actionlist:function(){var t=[];for(var n in this.actions){var e=this.actions[n];"string"==typeof e&&(e={text:e}),e.key||(e.key=isNaN(n)?n:e.text||n),["true","false"].indexOf(e.key)>=0&&(e.key=JSON.parse(e.key)),this.isActionVisible(e)&&("string"==typeof e.icon&&(e.icon={text:e.icon}),t.push(e))}return t}},methods:{trigger:function(t){var n=this.actionlist.find(function(n){return n.key===t});n&&!this.isActionDisabled(n)&&this.isActionVisible(n)&&this.onActionClick(n)},setLoadingToInstance:function(t,n){t&&void 0!==t.loading&&(t.loading=n)},setLoadingState:function(t){this.$emit("loading",t),!t&&(this.loadingAction=null),this.setLoadingToInstance(this.$root,t),this.setLoadingToInstance(this.$root._dialogInstance,t)},get:function(t,n){return void 0===t?n:"function"==typeof t?t(this.params):t},isActionDisabled:function(t){return this.get(t.disabled,!1)},isActionVisible:function(t){return this.get(t.visible,!0)},isActionInLoading:function(t){return this.loadingAction===t.key||this.get(t.loading)},onActionClick:function(t){return new Promise(function(n,e){var r,i;if(r=void 0===t.closable||!0===t.closable,"function"!=typeof(i=t.handle||this.handle))return r&&this.return(t.key),a.call(this);this.loadingAction=t.key,this.setLoadingState(!0);var o=function(){try{return a.call(this)}catch(t){return e(t)}}.bind(this),s=function(t){try{throw this.setLoadingState(!1),console.log("error",t),t}catch(t){return e(t)}}.bind(this);try{var u;return Promise.resolve(i(this.params)).then(function(n){try{return u=n,this.setLoadingState(!1),!1!==u&&r&&this.return(u||t.key),o()}catch(t){return s(t)}}.bind(this),s)}catch(t){s(t)}function a(){return n()}}.bind(this))}}},pe={name:"Confirmable",props:{type:{type:String},text:{type:String,reqiured:!0},title:{type:String},actions:{type:[Array,Object]}}},ve=[],de={props:{verticalOffset:Number,showClose:{type:Boolean,default:function(){return!0}},position:{type:String,default:function(){return"top-right"}},timeout:{type:[Number,Boolean],default:function(){return 4500}},width:{type:Number,default:function(){return 330}},zIndex:{type:Number,default:function(){return 2e3}}},computed:{horizontalClass:function(){return this.position.indexOf("right")>-1?"right":"left"},verticalProperty:function(){return/^top-/.test(this.position)?"top":"bottom"},getStyle:function(){var t;return(t={})[this.verticalProperty]=this.verticalOffset+"px",t["max-width"]=this.width+"px",t["z-index"]=this.zIndex,t}},methods:{_destroy:function(){this.$el.addEventListener("transitionend",this.onTransitionEnd)},onTransitionEnd:function(){this.$el.removeEventListener("transitionend",this.onTransitionEnd),this.$destroy()},clearTimer:function(){clearTimeout(this.timer)},startTimer:function(){this.timeout>0&&(this.timer=setTimeout(this.close,this.timeout))},keydown:function(t){46===t.keyCode||8===t.keyCode?this.clearTimer():27===t.keyCode?this.close():this.startTimer()},close:function(){this.isActive=!1}},watch:{isActive:function(t){var n,e,r;t?(e=(n=this).position,r=10,ve.filter(function(t){return t.position===e}).forEach(function(t){r+=t.$el.offsetHeight+10}),ve.push(n),n.verticalOffset=r):function(t){var n=ve.findIndex(function(n){return n===t});if(!(n<0)){ve.splice(n,1);var e=ve.length,r=t.position;if(e){var i=10;ve.filter(function(t){return t.position===r}).forEach(function(t){t.verticalOffset=i,i+=t.$el.offsetHeight+10})}}}(this)}},mounted:function(){this.startTimer(),document.addEventListener("keydown",this.keydown)},beforeDestroy:function(){document.removeEventListener("keydown",this.keydown)}};var ye={install:function(t,n){void 0===n&&(n={});var e=n.property||"$dialog",r=new ce(n);Object.defineProperty(t.prototype,e,{get:function(){return r}})}},_e=null;"undefined"!=typeof window?_e=window.Vue:"undefined"!=typeof global&&(_e=global.Vue),_e&&_e.use(ye),t.default=ye,t.Actionable=le,t.Activable=r,t.Confirmable=pe,t.Notifiable=de,t.Recordable=e,t.Returnable=he,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=vuedl.min.js.map |
{ | ||
"name": "vuedl", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Vue dialog helper", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -51,13 +51,15 @@ /* | ||
// create dialog | ||
let DialogCtor = Vue.extend({ ...this._component, parent: layout }) | ||
if (this._component.primaryKey) { | ||
DialogCtor = DialogCtor.extend({ mixins: [ Recordable ] }) | ||
let Component = this._component | ||
if (typeof Component === 'object' && !Component.options) { | ||
Component = Vue.extend({ ...this._component, parent: layout }) | ||
if (this._component.primaryKey) { | ||
Component = Component.extend({ mixins: [ Recordable ] }) | ||
} | ||
if (this.hasAsyncPreload) { | ||
await ensureAsyncDatas(Component, { ...this.context, params }) | ||
} | ||
} | ||
if (this.hasAsyncPreload) { | ||
await ensureAsyncDatas(DialogCtor, { ...this.context, params }) | ||
} | ||
const dialog = new Component(merge({ propsData: params }, this.context, options)) | ||
const dialog = new DialogCtor(merge({ propsData: params }, this.context, options)) | ||
// mounting | ||
@@ -64,0 +66,0 @@ dialog.$mount() |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
720073
6608