Socket
Socket
Sign inDemoInstall

vuedl

Package Overview
Dependencies
22
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 0.3.3

11

dist/vuedl.cjs.js

@@ -802,3 +802,3 @@ 'use strict';

actions: {
type: [Array, Object],
type: [Array, Object, Function],
default: function () { return []; }

@@ -812,5 +812,6 @@ },

var actions = [];
var acts = typeof this.actions === 'function' ? this.actions(this) : this.actions || [];
for (var key in this.actions) {
var action = this.actions[key];
for (var key in acts) {
var action = acts[key];

@@ -925,3 +926,3 @@ if (typeof action === 'string') {

var ret;
return Promise.resolve(handle(this.params)).then(function ($await_3) {
return Promise.resolve(handle(this.params, action)).then(function ($await_3) {
try {

@@ -971,3 +972,3 @@ ret = $await_3;

actions: {
type: [Array, Object]
type: [Array, Object, Function]
}

@@ -974,0 +975,0 @@ }

@@ -796,3 +796,3 @@ import Vue from 'vue';

actions: {
type: [Array, Object],
type: [Array, Object, Function],
default: function () { return []; }

@@ -806,5 +806,6 @@ },

var actions = [];
var acts = typeof this.actions === 'function' ? this.actions(this) : this.actions || [];
for (var key in this.actions) {
var action = this.actions[key];
for (var key in acts) {
var action = acts[key];

@@ -919,3 +920,3 @@ if (typeof action === 'string') {

var ret;
return Promise.resolve(handle(this.params)).then(function ($await_3) {
return Promise.resolve(handle(this.params, action)).then(function ($await_3) {
try {

@@ -965,3 +966,3 @@ ret = $await_3;

actions: {
type: [Array, Object]
type: [Array, Object, Function]
}

@@ -968,0 +969,0 @@ }

@@ -952,3 +952,3 @@ (function (global, factory) {

actions: {
type: [Array, Object],
type: [Array, Object, Function],
default: function () { return []; }

@@ -962,5 +962,6 @@ },

var actions = [];
var acts = typeof this.actions === 'function' ? this.actions(this) : this.actions || [];
for (var key in this.actions) {
var action = this.actions[key];
for (var key in acts) {
var action = acts[key];

@@ -1075,3 +1076,3 @@ if (typeof action === 'string') {

var ret;
return Promise.resolve(handle(this.params)).then(function ($await_3) {
return Promise.resolve(handle(this.params, action)).then(function ($await_3) {
try {

@@ -1121,3 +1122,3 @@ ret = $await_3;

actions: {
type: [Array, Object]
type: [Array, Object, Function]
}

@@ -1124,0 +1125,0 @@ }

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e(t.vuedl={},t.Vue)}(this,function(t,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var n={computed:{$parameters:function(){return this.$attrs||this.$options.propsData||this.$props||{}},isNewRecord:function(){return!this.$parameters||!this.$parameters[this.$options.primaryKey]}}},i={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}}},o={name:"Layoutable",mixins:[i],inheritAttrs:!1,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(){"function"==typeof this.$el.remove?this.$el.remove():this.$el.parentNode&&this.$el.parentNode.removeChild(this.$el)}};var r=function(t,e,n,i,o,r,s,a,c,u){"boolean"!=typeof s&&(c=a,a=s,s=!1);var h,l="function"==typeof n?n.options:n;if(t&&t.render&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),i&&(l._scopeId=i),r?(h=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,c(t)),t&&t._registeredComponents&&t._registeredComponents.add(r)},l._ssrRegister=h):e&&(h=s?function(){e.call(this,u(this.$root.$options.shadowRoot))}:function(t){e.call(this,a(t))}),h)if(l.functional){var f=l.render;l.render=function(t,e){return h.call(e),f(t,e)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,h):[h]}return n},s=r({render:function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"dialog-layout"},[e("dialog-child",this._b({ref:"dialog"},"dialog-child",this.$options.propsData,!1))],1)},staticRenderFns:[]},void 0,{},void 0,!1,void 0,void 0,void 0),a=function(t){return"function"==typeof t},c=function(t){return null==t},u=function(t){return t&&(t instanceof Promise||"function"==typeof t.then)};function h(t,e){var n=this,i=[],o=this,r={};if("object"!=typeof t)return t;var s=function(s){var h=t[s];a(h)&&(h=h.call(n,e)),u(h)?(h=h.then(function(t){if(!c(t))return s.startsWith("...")?r=Object.assign({},r,t):r[s]=t,t}),e&&a(e.asyncDataError)&&(h=h.catch(function(n){return e.asyncDataError.call(o,n,{key:s,obj:t})})),i.push(h)):r[s]=h};for(var h in t)s(h);return Promise.all(i).then(function(){return Promise.resolve(r)})}var l=function(t,e){var n=[];if(t.options.asyncData&&!t.options.__hasAsyncData){var i=function(t,e){var n;if(n=a(t)?t.call(this,e):t,!u(n)){if("object"==typeof n)return h.call(this,n,e);n=Promise.resolve(n)}var i=this;return n.then(function(t){return h.call(i,t)})}(t.options.asyncData,e);i.then(function(e){return function(t,e){if(e||!t.options.__hasAsyncData){var n=t.options._originDataFn||t.options.data||function(){return{}};t.options._originDataFn=n,t.options.data=function(){var t=n.call(this);return Object.assign({},t,e)},t.options.__hasAsyncData=!0,t._Ctor&&t._Ctor.options&&(t._Ctor.options.data=t.options.data)}}(t,e),e}),n.push(i)}return t.options.fetch&&!t.options.__hasAsyncData&&n.push(t.options.fetch(e)),t.options.__hasAsyncData=!0,Promise.all(n)};function f(t){t&&!t._isDestroyed&&"function"==typeof t.$destroy&&t.$destroy()}function d(t){var e;return(e="string"==typeof t?document.querySelector(t):t)||(e=document.body),e}var p=1,y=function(t,e){void 0===e&&(e={});var n=e.layout,i=e.container;if(!t)throw Error("Component was not set");this._layout=n||{component:s,options:{}},this._component=t,this._vm=null,this._vmDialog=null,this._options={},this.id=++p,this._resolvers=[],this.container=d(i)},v={showed:{configurable:!0},element:{configurable:!0},hasAsyncPreload:{configurable:!0},vm:{configurable:!0},vmd:{configurable:!0}};y.prototype.show=function(t,i){return void 0===t&&(t={}),void 0===i&&(i={}),new Promise(function(r,s){var a,c,u,h,f;if(e.prototype.$isServer)return r();if("object"!=typeof(a=this._component)||a.options||(a=e.extend(Object.assign({},this._component))),a.options.primaryKey&&(a=a.extend({mixins:[n]})),this.hasAsyncPreload)return Promise.resolve(l(a,Object.assign({},this.context,{params:t}))).then(function(t){try{return p.call(this)}catch(t){return s(t)}}.bind(this),s);function p(){return c=(c=e.extend({mixins:[o],components:{"dialog-child":a}})).extend(this._layout.component),a.options.inheritAttrs=!1,u=Object.assign({},this._layout.options,t,i&&i.propsData),(h=new c(Object.assign({},this.context,i,{propsData:u}))).$mount(),f=h.$refs.dialog,h.$on("hook:destroyed",this._onDestroyed.bind(this)),h.$on("submit",this.onReturn.bind(this)),f&&f.$on("submit",this.onReturn.bind(this)),this._vm=h,this._vm._dialogInstance=f,this._vmDialog=f,this.container=i.container?d(i.container):this.container,this.container.appendChild(this.element),r(this)}return p.call(this)}.bind(this))},y.prototype.wait=function(){var t=this;return new Promise(function(e){t._resolvers.push(e)})},y.prototype._onDestroyed=function(){this.remove()},y.prototype.remove=function(){this.onDestroyed&&this.onDestroyed(this),this._processResultPromises(),f(this._vm),f(this._vmDialog),this._vm=null,this._vmDialog=null},y.prototype._processResultPromises=function(t){this._resolvers.length&&(this._resolvers.forEach(function(e){return e(t)}),this._resolvers=[])},y.prototype.onReturn=function(t){this._processResultPromises(t),this.close()},v.showed.get=function(){return!!this._vm&&!this._vm._isDestroyed},v.element.get=function(){return this._vm&&this._vm.$el},v.hasAsyncPreload.get=function(){return this._component&&(t=this._component.options||this._component,Boolean(!t.__hasAsyncData&&(t.asyncData||t.fetch)));var t},v.vm.get=function(){return this._vm},v.vmd.get=function(){return this._vmDialog},y.prototype.close=function(){this._vm&&this._vm.close()},Object.defineProperties(y.prototype,v);var m=function(t){this._component=t,this._vm=null};m.prototype.show=function(){if(!this._vm){var t=e.extend(this._component);this._vm=new t,this._vm.$mount(),document.body.appendChild(this._vm.$el)}this._vm.visible=!0},m.prototype.hide=function(){this._vm.visible=!1},m.prototype.destroy=function(){this._vm&&(this._vm.$el.parentNode.removeChild(this._vm.$el),this._vm.$destroy(),this._vm=null)};var _=function(t){void 0===t&&(t={});var n=t.context,i=t.container;this._context=n||{},y.prototype.context=n||{},this._components={},this._layouts={},this._overlays={},this._container=i,this._emitter=new e({}),this._instances=[]},g={context:{configurable:!0}};g.context.get=function(){return this._context},_.prototype.layout=function(t,e,n){void 0===n&&(n={}),this._layouts[t]={component:e,options:n}},_.prototype.getLayout=function(t){if("function"==typeof t){var e=t.call(this._context);return t=this._layouts[e.name||"default"],Object.assign({},t,{options:e})}if("object"==typeof t&&"function"==typeof t.render)return{component:t};if(Array.isArray(t)){var n=t[0],i=t[1]||{},o="object"==typeof n&&"function"==typeof n.render?{component:n}:this._layouts[n];return o&&{component:o.component,options:Object.assign({},o.options,i)}}return this._layouts[t]},_.prototype.overlay=function(t,e){if(void 0===e){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 m(e)},_.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]},_.prototype.component=function(t,e,n){var i=this;if(void 0===n&&(n={}),void 0===e)return this._components[t];this._components[t]={component:e,options:n},Object.defineProperty(this,t,{get:function(){return i.createFunctionWrapper(t)}})},_.prototype.getComponentProperty=function(t,e){return t.options?t.options[e]:t[e]},_.prototype.create=function(t){if(!t)throw new Error("Component is incorrect");var e=this.getLayout(this.getComponentProperty(t,"layout")||"default"),n=new y(t,{layout:e,context:this._context,container:this._container});return this._emitter.$emit("created",{dialog:n}),n},_.prototype.show=function(t,e){return void 0===e&&(e={}),new Promise(function(n,i){var o,r,s;r=!!(o=this.create(t)).hasAsyncPreload&&(this.getComponentProperty(t,"overlay")||"default"),(s=r&&this._overlays[r]&&this.overlay(r))&&s.show();var a=function(t){try{throw this._emitter.$emit("error",{error:t,dialog:o}),s&&s.hide(),t}catch(t){return i(t)}}.bind(this);try{return Promise.resolve(o.show(e)).then(function(t){try{return this._emitter.$emit("shown",{dialog:o}),s&&s.hide(),o.onDestroyed=this.onDialogDestroyed.bind(this),n(e.waitForResult?o.wait():o)}catch(t){return a(t)}}.bind(this),a)}catch(t){a(t)}}.bind(this))},_.prototype.createFunctionWrapper=function(t){var e=this,n=this.getComponent(t);return function(t){return e.show(n.component,Object.assign({},n.options,t))}},_.prototype.showAndWait=function(t,e){return new Promise(function(n,i){return Promise.resolve(this.show(t,e)).then(function(t){try{return n(t.wait())}catch(t){return i(t)}},i)}.bind(this))},_.prototype.on=function(t,e){this._emitter.$on(t,e)},_.prototype.off=function(t,e){this._emitter.$off(t,e)},_.prototype.once=function(t,e){this._emitter.$once(t,e)},_.prototype.onDialogDestroyed=function(t){this._emitter.$emit("destroyed",{dialog:t})},Object.defineProperties(_.prototype,g);var b=r({render:function(){var t=this.$createElement,e=this._self._c||t;return e("transition",{attrs:{name:"opacity"}},[this.visible?e("div",{staticClass:"dialog-overlay-loading",style:{zIndex:this.zIndex}},[this._v("\n Loading…\n ")]):this._e()])},staticRenderFns:[]},void 0,{name:"VDialogOverlay",props:{zIndex:{type:Number,default:function(){return 1250}},visible:{type:Boolean,default:function(){return!1}}}},void 0,!1,void 0,void 0,void 0),w={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)}}},$={name:"Actionable",mixins:[w],data:function(){return{loadingAction:null}},props:{actions:{type:[Array,Object],default:function(){return[]}},handle:Function,params:Object},computed:{actionlist:function(){var t=[];for(var e in this.actions){var n=this.actions[e];"string"==typeof n&&(n={text:n}),n.key||(n.key=isNaN(e)?e:n.text||e),["true","false"].indexOf(n.key)>=0&&(n.key=JSON.parse(n.key)),this.isActionVisible(n)&&("string"==typeof n.icon&&(n.icon={text:n.icon}),t.push(n))}return t}},methods:{trigger:function(t){var e=this.actionlist.find(function(e){return e.key===t});e&&!this.isActionDisabled(e)&&this.isActionVisible(e)&&this.onActionClick(e)},setLoadingToInstance:function(t,e){t&&void 0!==t.loading&&(t.loading=e)},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,e){return void 0===t?e:"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(e,n){var i,o;if(i=void 0===t.closable||!0===t.closable,"function"!=typeof(o=t.handle||this.handle))return i&&this.return(t.key),c.call(this);this.loadingAction=t.key,this.setLoadingState(!0);var r=function(){try{return c.call(this)}catch(t){return n(t)}}.bind(this),s=function(t){try{throw this.setLoadingState(!1),console.log("error",t),t}catch(t){return n(t)}}.bind(this);try{var a;return Promise.resolve(o(this.params)).then(function(e){try{return a=e,this.setLoadingState(!1),!1!==a&&i&&this.return(a||t.key),r()}catch(t){return s(t)}}.bind(this),s)}catch(t){s(t)}function c(){return e()}}.bind(this))}}},A={name:"Confirmable",props:{type:{type:String},text:{type:[String,Function],reqiured:!0},title:{type:String},actions:{type:[Array,Object]}}},x=[],D={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}}},data:function(){return{activeTimeout:null}},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.activeTimeout)},startTimer:function(){this.timeout>0&&(this.activeTimeout=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 e,n,i;t?(n=(e=this).position,i=10,x.filter(function(t){return t.position===n}).forEach(function(t){i+=t.$el.offsetHeight+10}),x.push(e),e.verticalOffset=i):function(t){var e=x.findIndex(function(e){return e===t});if(!(e<0)){x.splice(e,1);var n=x.length,i=t.position;if(n){var o=10;x.filter(function(t){return t.position===i}).forEach(function(t){t.verticalOffset=o,o+=t.$el.offsetHeight+10})}}}(this)}},mounted:function(){this.startTimer(),document.addEventListener("keydown",this.keydown)},beforeDestroy:function(){document.removeEventListener("keydown",this.keydown)}};var P={install:function t(e,n){if(void 0===n&&(n={}),!t.installed){t.installed=!0;var i=n.property||"$dialog",o=new _(n);o.overlay("default",b),e.prototype[i]?console.warn("Property "+i+" is already defined in Vue prototype"):Object.defineProperty(e.prototype,i,{get:function(){return o}})}}},C=null;"undefined"!=typeof window?C=window.Vue:"undefined"!=typeof global&&(C=global.Vue),C&&C.use(P),t.default=P,t.Actionable=$,t.Activable=i,t.Confirmable=A,t.Notifiable=D,t.Recordable=n,t.Returnable=w,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e(t.vuedl={},t.Vue)}(this,function(t,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var n={computed:{$parameters:function(){return this.$attrs||this.$options.propsData||this.$props||{}},isNewRecord:function(){return!this.$parameters||!this.$parameters[this.$options.primaryKey]}}},i={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}}},o={name:"Layoutable",mixins:[i],inheritAttrs:!1,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(){"function"==typeof this.$el.remove?this.$el.remove():this.$el.parentNode&&this.$el.parentNode.removeChild(this.$el)}};var r=function(t,e,n,i,o,r,s,a,c,u){"boolean"!=typeof s&&(c=a,a=s,s=!1);var h,l="function"==typeof n?n.options:n;if(t&&t.render&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),i&&(l._scopeId=i),r?(h=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,c(t)),t&&t._registeredComponents&&t._registeredComponents.add(r)},l._ssrRegister=h):e&&(h=s?function(){e.call(this,u(this.$root.$options.shadowRoot))}:function(t){e.call(this,a(t))}),h)if(l.functional){var f=l.render;l.render=function(t,e){return h.call(e),f(t,e)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,h):[h]}return n},s=r({render:function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"dialog-layout"},[e("dialog-child",this._b({ref:"dialog"},"dialog-child",this.$options.propsData,!1))],1)},staticRenderFns:[]},void 0,{},void 0,!1,void 0,void 0,void 0),a=function(t){return"function"==typeof t},c=function(t){return null==t},u=function(t){return t&&(t instanceof Promise||"function"==typeof t.then)};function h(t,e){var n=this,i=[],o=this,r={};if("object"!=typeof t)return t;var s=function(s){var h=t[s];a(h)&&(h=h.call(n,e)),u(h)?(h=h.then(function(t){if(!c(t))return s.startsWith("...")?r=Object.assign({},r,t):r[s]=t,t}),e&&a(e.asyncDataError)&&(h=h.catch(function(n){return e.asyncDataError.call(o,n,{key:s,obj:t})})),i.push(h)):r[s]=h};for(var h in t)s(h);return Promise.all(i).then(function(){return Promise.resolve(r)})}var l=function(t,e){var n=[];if(t.options.asyncData&&!t.options.__hasAsyncData){var i=function(t,e){var n;if(n=a(t)?t.call(this,e):t,!u(n)){if("object"==typeof n)return h.call(this,n,e);n=Promise.resolve(n)}var i=this;return n.then(function(t){return h.call(i,t)})}(t.options.asyncData,e);i.then(function(e){return function(t,e){if(e||!t.options.__hasAsyncData){var n=t.options._originDataFn||t.options.data||function(){return{}};t.options._originDataFn=n,t.options.data=function(){var t=n.call(this);return Object.assign({},t,e)},t.options.__hasAsyncData=!0,t._Ctor&&t._Ctor.options&&(t._Ctor.options.data=t.options.data)}}(t,e),e}),n.push(i)}return t.options.fetch&&!t.options.__hasAsyncData&&n.push(t.options.fetch(e)),t.options.__hasAsyncData=!0,Promise.all(n)};function f(t){t&&!t._isDestroyed&&"function"==typeof t.$destroy&&t.$destroy()}function d(t){var e;return(e="string"==typeof t?document.querySelector(t):t)||(e=document.body),e}var p=1,y=function(t,e){void 0===e&&(e={});var n=e.layout,i=e.container;if(!t)throw Error("Component was not set");this._layout=n||{component:s,options:{}},this._component=t,this._vm=null,this._vmDialog=null,this._options={},this.id=++p,this._resolvers=[],this.container=d(i)},v={showed:{configurable:!0},element:{configurable:!0},hasAsyncPreload:{configurable:!0},vm:{configurable:!0},vmd:{configurable:!0}};y.prototype.show=function(t,i){return void 0===t&&(t={}),void 0===i&&(i={}),new Promise(function(r,s){var a,c,u,h,f;if(e.prototype.$isServer)return r();if("object"!=typeof(a=this._component)||a.options||(a=e.extend(Object.assign({},this._component))),a.options.primaryKey&&(a=a.extend({mixins:[n]})),this.hasAsyncPreload)return Promise.resolve(l(a,Object.assign({},this.context,{params:t}))).then(function(t){try{return p.call(this)}catch(t){return s(t)}}.bind(this),s);function p(){return c=(c=e.extend({mixins:[o],components:{"dialog-child":a}})).extend(this._layout.component),a.options.inheritAttrs=!1,u=Object.assign({},this._layout.options,t,i&&i.propsData),(h=new c(Object.assign({},this.context,i,{propsData:u}))).$mount(),f=h.$refs.dialog,h.$on("hook:destroyed",this._onDestroyed.bind(this)),h.$on("submit",this.onReturn.bind(this)),f&&f.$on("submit",this.onReturn.bind(this)),this._vm=h,this._vm._dialogInstance=f,this._vmDialog=f,this.container=i.container?d(i.container):this.container,this.container.appendChild(this.element),r(this)}return p.call(this)}.bind(this))},y.prototype.wait=function(){var t=this;return new Promise(function(e){t._resolvers.push(e)})},y.prototype._onDestroyed=function(){this.remove()},y.prototype.remove=function(){this.onDestroyed&&this.onDestroyed(this),this._processResultPromises(),f(this._vm),f(this._vmDialog),this._vm=null,this._vmDialog=null},y.prototype._processResultPromises=function(t){this._resolvers.length&&(this._resolvers.forEach(function(e){return e(t)}),this._resolvers=[])},y.prototype.onReturn=function(t){this._processResultPromises(t),this.close()},v.showed.get=function(){return!!this._vm&&!this._vm._isDestroyed},v.element.get=function(){return this._vm&&this._vm.$el},v.hasAsyncPreload.get=function(){return this._component&&(t=this._component.options||this._component,Boolean(!t.__hasAsyncData&&(t.asyncData||t.fetch)));var t},v.vm.get=function(){return this._vm},v.vmd.get=function(){return this._vmDialog},y.prototype.close=function(){this._vm&&this._vm.close()},Object.defineProperties(y.prototype,v);var m=function(t){this._component=t,this._vm=null};m.prototype.show=function(){if(!this._vm){var t=e.extend(this._component);this._vm=new t,this._vm.$mount(),document.body.appendChild(this._vm.$el)}this._vm.visible=!0},m.prototype.hide=function(){this._vm.visible=!1},m.prototype.destroy=function(){this._vm&&(this._vm.$el.parentNode.removeChild(this._vm.$el),this._vm.$destroy(),this._vm=null)};var _=function(t){void 0===t&&(t={});var n=t.context,i=t.container;this._context=n||{},y.prototype.context=n||{},this._components={},this._layouts={},this._overlays={},this._container=i,this._emitter=new e({}),this._instances=[]},g={context:{configurable:!0}};g.context.get=function(){return this._context},_.prototype.layout=function(t,e,n){void 0===n&&(n={}),this._layouts[t]={component:e,options:n}},_.prototype.getLayout=function(t){if("function"==typeof t){var e=t.call(this._context);return t=this._layouts[e.name||"default"],Object.assign({},t,{options:e})}if("object"==typeof t&&"function"==typeof t.render)return{component:t};if(Array.isArray(t)){var n=t[0],i=t[1]||{},o="object"==typeof n&&"function"==typeof n.render?{component:n}:this._layouts[n];return o&&{component:o.component,options:Object.assign({},o.options,i)}}return this._layouts[t]},_.prototype.overlay=function(t,e){if(void 0===e){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 m(e)},_.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]},_.prototype.component=function(t,e,n){var i=this;if(void 0===n&&(n={}),void 0===e)return this._components[t];this._components[t]={component:e,options:n},Object.defineProperty(this,t,{get:function(){return i.createFunctionWrapper(t)}})},_.prototype.getComponentProperty=function(t,e){return t.options?t.options[e]:t[e]},_.prototype.create=function(t){if(!t)throw new Error("Component is incorrect");var e=this.getLayout(this.getComponentProperty(t,"layout")||"default"),n=new y(t,{layout:e,context:this._context,container:this._container});return this._emitter.$emit("created",{dialog:n}),n},_.prototype.show=function(t,e){return void 0===e&&(e={}),new Promise(function(n,i){var o,r,s;r=!!(o=this.create(t)).hasAsyncPreload&&(this.getComponentProperty(t,"overlay")||"default"),(s=r&&this._overlays[r]&&this.overlay(r))&&s.show();var a=function(t){try{throw this._emitter.$emit("error",{error:t,dialog:o}),s&&s.hide(),t}catch(t){return i(t)}}.bind(this);try{return Promise.resolve(o.show(e)).then(function(t){try{return this._emitter.$emit("shown",{dialog:o}),s&&s.hide(),o.onDestroyed=this.onDialogDestroyed.bind(this),n(e.waitForResult?o.wait():o)}catch(t){return a(t)}}.bind(this),a)}catch(t){a(t)}}.bind(this))},_.prototype.createFunctionWrapper=function(t){var e=this,n=this.getComponent(t);return function(t){return e.show(n.component,Object.assign({},n.options,t))}},_.prototype.showAndWait=function(t,e){return new Promise(function(n,i){return Promise.resolve(this.show(t,e)).then(function(t){try{return n(t.wait())}catch(t){return i(t)}},i)}.bind(this))},_.prototype.on=function(t,e){this._emitter.$on(t,e)},_.prototype.off=function(t,e){this._emitter.$off(t,e)},_.prototype.once=function(t,e){this._emitter.$once(t,e)},_.prototype.onDialogDestroyed=function(t){this._emitter.$emit("destroyed",{dialog:t})},Object.defineProperties(_.prototype,g);var b=r({render:function(){var t=this.$createElement,e=this._self._c||t;return e("transition",{attrs:{name:"opacity"}},[this.visible?e("div",{staticClass:"dialog-overlay-loading",style:{zIndex:this.zIndex}},[this._v("\n Loading…\n ")]):this._e()])},staticRenderFns:[]},void 0,{name:"VDialogOverlay",props:{zIndex:{type:Number,default:function(){return 1250}},visible:{type:Boolean,default:function(){return!1}}}},void 0,!1,void 0,void 0,void 0),w={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)}}},$={name:"Actionable",mixins:[w],data:function(){return{loadingAction:null}},props:{actions:{type:[Array,Object,Function],default:function(){return[]}},handle:Function,params:Object},computed:{actionlist:function(){var t=[],e="function"==typeof this.actions?this.actions(this):this.actions||[];for(var n in e){var i=e[n];"string"==typeof i&&(i={text:i}),i.key||(i.key=isNaN(n)?n:i.text||n),["true","false"].indexOf(i.key)>=0&&(i.key=JSON.parse(i.key)),this.isActionVisible(i)&&("string"==typeof i.icon&&(i.icon={text:i.icon}),t.push(i))}return t}},methods:{trigger:function(t){var e=this.actionlist.find(function(e){return e.key===t});e&&!this.isActionDisabled(e)&&this.isActionVisible(e)&&this.onActionClick(e)},setLoadingToInstance:function(t,e){t&&void 0!==t.loading&&(t.loading=e)},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,e){return void 0===t?e:"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(e,n){var i,o;if(i=void 0===t.closable||!0===t.closable,"function"!=typeof(o=t.handle||this.handle))return i&&this.return(t.key),c.call(this);this.loadingAction=t.key,this.setLoadingState(!0);var r=function(){try{return c.call(this)}catch(t){return n(t)}}.bind(this),s=function(t){try{throw this.setLoadingState(!1),console.log("error",t),t}catch(t){return n(t)}}.bind(this);try{var a;return Promise.resolve(o(this.params,t)).then(function(e){try{return a=e,this.setLoadingState(!1),!1!==a&&i&&this.return(a||t.key),r()}catch(t){return s(t)}}.bind(this),s)}catch(t){s(t)}function c(){return e()}}.bind(this))}}},A={name:"Confirmable",props:{type:{type:String},text:{type:[String,Function],reqiured:!0},title:{type:String},actions:{type:[Array,Object,Function]}}},x=[],D={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}}},data:function(){return{activeTimeout:null}},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.activeTimeout)},startTimer:function(){this.timeout>0&&(this.activeTimeout=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 e,n,i;t?(n=(e=this).position,i=10,x.filter(function(t){return t.position===n}).forEach(function(t){i+=t.$el.offsetHeight+10}),x.push(e),e.verticalOffset=i):function(t){var e=x.findIndex(function(e){return e===t});if(!(e<0)){x.splice(e,1);var n=x.length,i=t.position;if(n){var o=10;x.filter(function(t){return t.position===i}).forEach(function(t){t.verticalOffset=o,o+=t.$el.offsetHeight+10})}}}(this)}},mounted:function(){this.startTimer(),document.addEventListener("keydown",this.keydown)},beforeDestroy:function(){document.removeEventListener("keydown",this.keydown)}};var P={install:function t(e,n){if(void 0===n&&(n={}),!t.installed){t.installed=!0;var i=n.property||"$dialog",o=new _(n);o.overlay("default",b),e.prototype[i]?console.warn("Property "+i+" is already defined in Vue prototype"):Object.defineProperty(e.prototype,i,{get:function(){return o}})}}},C=null;"undefined"!=typeof window?C=window.Vue:"undefined"!=typeof global&&(C=global.Vue),C&&C.use(P),t.default=P,t.Actionable=$,t.Activable=i,t.Confirmable=A,t.Notifiable=D,t.Recordable=n,t.Returnable=w,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=vuedl.min.js.map
{
"name": "vuedl",
"version": "0.3.2",
"version": "0.3.3",
"description": "Vue dialog helper",

@@ -17,3 +17,6 @@ "scripts": {

"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
"docs:build": "vuepress build docs",
"build:umd": "rollup --config build/rollup.config.js --format umd --file dist/vue-flag.umd.js",
"build:es": "rollup --config build/rollup.config.js --format es --file dist/vue-flag.esm.js",
"build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/vue-flag.min.js"
},

@@ -62,2 +65,5 @@ "main": "dist/vuedl.cjs.js",

"lodash": "^4.17.11",
"rollup-plugin-async": "^1.2.0",
"rollup-plugin-regenerator": "^0.6.0",
"rollup-plugin-uglify-es": "0.0.1",
"rollup-plugin-vue": "^4.7.1",

@@ -64,0 +70,0 @@ "vue": "^2.6.5",

@@ -17,3 +17,3 @@

actions: {
type: [Array, Object],
type: [Array, Object, Function],
default: () => []

@@ -28,4 +28,5 @@ },

const actions = []
for (let key in this.actions) {
let action = this.actions[key]
const acts = typeof this.actions === 'function' ? this.actions(this) : (this.actions || [])
for (let key in acts) {
let action = acts[key]
if (typeof action === 'string') {

@@ -97,3 +98,3 @@ action = { text: action }

try {
let ret = await handle(this.params)
let ret = await handle(this.params, action)
this.setLoadingState(false)

@@ -100,0 +101,0 @@ if (ret !== false && closable) {

@@ -9,3 +9,3 @@ export default {

text: {
type: [String, Function],
type: [ String, Function ],
reqiured: true

@@ -17,5 +17,5 @@ },

actions: {
type: [Array, Object]
type: [ Array, Object, Function ]
}
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc