Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jenesius-vue-modal

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jenesius-vue-modal - npm Package Compare versions

Comparing version 1.11.0 to 1.11.1

4

dist/jenesius-vue-modal.cjs.js
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".modal-container{position:fixed;left:0;top:0;height:100%;width:100%;display:flex;align-items:center;justify-content:center;background-color:#3e3e3e21;cursor:pointer}.modal-item{cursor:default}.modal-list-enter-active,.modal-list-leave-active,.modal-list-enter-active .modal-item,.modal-list-leave-active .modal-item{transition:all .2s ease}.modal-list-enter-from,.modal-list-leave-to{opacity:0!important}.modal-list-enter-from .modal-item,.modal-list-leave-to .modal-item{transform:translateY(-60px)}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
"use strict";/*!
* jenesius-vue-modal v1.11.0
* jenesius-vue-modal v1.11.1
* (c) 2024 Jenesius
* @license MIT
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue");var E=function(t,e){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},E(t,e)};function q(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");E(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function p(t,e,n,i){function o(r){return r instanceof n?r:new n(function(u){u(r)})}return new(n||(n=Promise))(function(r,u){function c(d){try{a(i.next(d))}catch(b){u(b)}}function l(d){try{a(i.throw(d))}catch(b){u(b)}}function a(d){d.done?r(d.value):o(d.value).then(c,l)}a((i=i.apply(t,e||[])).next())})}function g(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,u;return u={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(a){return function(d){return l([a,d])}}function l(a){if(i)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(n=0)),n;)try{if(i=1,o&&(r=a[0]&2?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[a[0]&2,r.value]),a[0]){case 0:case 1:r=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(r=n.trys,!(r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1],r=a;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(a);break}r[2]&&n.ops.pop(),n.trys.pop();continue}a=e.call(t,n)}catch(d){a=[6,d],o=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}var f=function(t){q(e,t);function e(n,i){i===void 0&&(i=null);var o=t.call(this)||this;return o.isModalError=!0,o.message=n,o.details=i,o}return e.Undefined=function(n){return new e("Modal with id: ".concat(n," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(n){return new e("Guard's name ".concat(n," is not declaration."))},e.NextReject=function(n){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(n))},e.GuardDeclarationType=function(n){return new e("Guard's type should be a function. Provided:",n)},e.ConfigurationType=function(n){return new e("Configuration type must be an Object. Provided",n)},e.ConfigurationUndefinedParam=function(n,i){return new e("In configuration founded unknown parameter: ".concat(n,". Available are ").concat(i.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(n){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(n,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(n){return new e("Event name must be a string. Provided: ".concat(n))},e.ModalNotFoundByID=function(n){return new e("Modal with ID ".concat(n," was not found."))},e.ModalNotExistsInStore=function(n){return new e("Provided name(".concat(n,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),m=function(){function t(){this.state=new Map,t.instance=this}return t.prototype.getByName=function(e){return e===void 0&&(e=t.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:s.reactive([]),initialized:!1}),this.state.get(e)},t.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},t.DEFAULT_NAMESPACE="default",t}(),N=function(){var t=new m,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1},n=t.getByName().queue;return s.watch(function(){return n},function(){e.scrollLock&&(n.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:t,configuration:e}}();function v(t){return N.namespaceStore.getByName(t)}var _=N.configuration;function R(t){var e={backgroundClose:_.backgroundClose,isRoute:!1,namespace:m.DEFAULT_NAMESPACE};return t.backgroundClose!==void 0&&(e.backgroundClose=t.backgroundClose),t.isRoute&&(e.isRoute=t.isRoute),t.namespace&&(e.namespace=t.namespace),e}function S(t){t===void 0&&(t={});var e={background:!1,esc:!1};return Object.assign(e,t)}function T(t){return t||(t={}),t}function w(t,e){e===void 0&&(e={});var n=M.STORE.get(t);if(!n)return Promise.reject(f.ModalNotFoundByID(t));var i=v(n.namespace),o=i.queue.findIndex(function(u){return u.id===t});if(o===-1)return Promise.reject(f.Undefined(t));var r=h.get(t,"close").map(function(u){return F(u,t,S(e))});return O(r).then(function(){i.queue.splice(o,1)}).then(function(){h.get(t,"destroy").forEach(function(u){return u(S(e))})}).then(function(){h.delete(t)})}var M=function(){function t(e,n,i){var o=this;this.events=s.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=t.modalId++,this.component=e,this.props=s.ref(n),this.closed=s.computed(function(){return!v(i.namespace).queue.includes(o)}),e.beforeModalClose&&h.add(this.id,"close",e.beforeModalClose);var r=R(i);this.backgroundClose=r.backgroundClose,this.isRoute=r.isRoute,this.namespace=r.namespace,t.STORE.set(this.id,this)}return t.prototype.close=function(){return w(this.id)},Object.defineProperty(t.prototype,"onclose",{set:function(e){h.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ondestroy",{set:function(e){h.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),t.prototype.on=function(e,n){var i=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(n),function(){var o=i.events[e].indexOf(n);o!==-1&&i.events[e].splice(o,1)}},t.STORE=new Map,t.modalId=0,t.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",t}();function I(t){return M.STORE.get(t)}var D={store:{},add:function(t,e,n){var i,o;if(typeof n!="function")throw f.GuardDeclarationType(n);this.store[t]||(this.store[t]=(i={},i[e]=[],i)),this.store[t][e]||(this.store[t][e]=[]),(o=this.store[t][e])===null||o===void 0||o.push(n)},get:function(t,e){return t in this.store?e in this.store[t]?this.store[t][e]||[]:[]:[]},delete:function(t){t in this.store&&delete this.store[t]}};const h=D;function O(t){return t.reduce(function(e,n){return e.then(function(){return n()})},Promise.resolve())}function F(t,e,n){return function(){return new Promise(function(i,o){var r,u=function(c){c===void 0&&(c=!0),c===!1&&o(f.NextReject(e)),i()};Promise.resolve(t.call((r=I(e))===null||r===void 0?void 0:r.instance,n)).then(u).catch(function(c){return o(c)})})}}function A(t){return t=T(t),O(v(t.namespace).queue.map(function(e){return function(){return e.close()}}))}function C(t){var e=v(t),n=e.queue;if(n.length!==0)return n[n.length-1]}function z(t){t=T(t);var e=C(t.namespace);return e?e.close():Promise.resolve()}function G(t,e,n){var i=R(n),o=v(i.namespace);if(i.namespace===m.DEFAULT_NAMESPACE&&!o.initialized&&!_.skipInitCheck)throw f.NotInitialized(i.namespace);if(typeof t=="string"){var r=j(t);if(!r)throw f.ModalNotExistsInStore(t);t=r}if(!t)throw f.ModalComponentNotProvided();var u=new M(t,e,i);return o.queue.push(s.markRaw(u)),u}function P(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return G(t,e,n)})}function x(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),A({namespace:n.namespace}).then(function(){var i=v(n.namespace);if(i.queue.length)throw f.QueueNoEmpty()}).then(function(){return P(t,e,n)})}function Q(t){if(typeof t!="object")throw f.ConfigurationType(t);Object.assign(_,t)}function U(t){var e,n,i,o=s.getCurrentInstance(),r=String(((e=o==null?void 0:o.props)===null||e===void 0?void 0:e.modalId)||((n=o==null?void 0:o.props)===null||n===void 0?void 0:n["modal-id"])||((i=o==null?void 0:o.attrs)===null||i===void 0?void 0:i.modalId)),u=r.replace(/[^0-9]/g,"");h.add(Number(u),"close",t)}function L(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),p(this,void 0,void 0,function(){var i,o,r=this;return g(this,function(u){switch(u.label){case 0:return[4,P(t,e,n)];case 1:return i=u.sent(),o=!1,[2,new Promise(function(c){i.on(M.EVENT_PROMPT,function(l){return p(r,void 0,void 0,function(){return g(this,function(a){return o=!0,[2,i.close().then(function(){return c(l)}).catch(function(){return o=!1})]})})}),i.ondestroy=function(){o||c(null)}})]}})})}function j(t){return _.store[t]||void 0}const V=["onPointerdown"],k={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=s.ref(null),i=I(t.id);function o(){if(i.backgroundClose)return w(i.id,{background:!0}).catch(()=>{})}return s.watch(()=>e.value,r=>{i.instance=r}),(r,u)=>(s.openBlock(),s.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:s.withModifiers(o,["self","stop"])},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(s.unref(i).component),s.mergeProps(s.unref(i).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${t.id}`,ref_key:"modalRef",ref:e},s.toHandlers(s.unref(i).events)),null,16,["modalId"]))],40,V))}};function W(t){t===void 0&&(t=m.DEFAULT_NAMESPACE);var e=m.instance.getByName(t);e.initialized=!0,t===m.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(_.escClose&&(n.key==="Escape"||n.code==="Escape")){var i=C(t);if(!i)return;w(i.id,{esc:!0}).catch(function(){})}})}const $={props:{namespace:String},setup(t){return s.onMounted(()=>{W(t.namespace)}),()=>{const e=v(t.namespace);return s.h(s.TransitionGroup,{name:_.animation},{default:()=>e.queue.map(n=>s.h(k,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:k}};var y={router:null};function H(t){var e=this;if(y.router)throw f.DuplicatedRouterIntegration();y.router=t;function n(i){for(var o=i.matched.length-1;o>=0;o--){var r=i.matched[o].components,u=Object.values(r).find(function(c){return c._isModal});if(u)return u}return null}t.beforeEach(function(i,o){return p(e,void 0,void 0,function(){var r,u,c;return g(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),r=n(o),r&&!(!((c=(u=r.getModalObject())===null||u===void 0?void 0:u.closed)===null||c===void 0)&&c.value)?[4,r.close(!0)]:[3,2];case 1:l.sent(),l.label=2;case 2:return[3,4];case 3:return l.sent(),[2,!1];case 4:return[2]}})})}),t.afterEach(function(i){return p(e,void 0,void 0,function(){var o;return g(this,function(r){switch(r.label){case 0:return o=n(i),o?[4,o.initialize()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})})}function B(t){var e=null,n=!1;function i(){return p(this,void 0,void 0,function(){return g(this,function(o){switch(o.label){case 0:if(!y.router)throw f.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,x(t,s.computed(function(){var r;return(r=y.router)===null||r===void 0?void 0:r.currentRoute.value.params}),{isRoute:!0})];case 1:return e=o.sent(),e.onclose=function(){var r;n||(r=y.router)===null||r===void 0||r.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(o){return o===void 0&&(o=!1),p(this,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return n=o,e?[4,e.close()]:[3,2];case 1:return[2,r.sent()];case 2:return[2]}})})},initialize:i,setup:function(){return function(){return null}}}}B.init=H;var Y=v().queue;function J(t){return v(t).queue}exports.Modal=M;exports.closeById=w;exports.closeModal=A;exports.config=Q;exports.container=$;exports.getComponentFromStore=j;exports.getCurrentModal=C;exports.getQueueByNamespace=J;exports.modalQueue=Y;exports.onBeforeModalClose=U;exports.openModal=x;exports.popModal=z;exports.promptModal=L;exports.pushModal=P;exports.useModalRouter=B;
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue");var E=function(t,e){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},E(t,e)};function q(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");E(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function p(t,e,n,i){function o(r){return r instanceof n?r:new n(function(u){u(r)})}return new(n||(n=Promise))(function(r,u){function c(d){try{a(i.next(d))}catch(b){u(b)}}function l(d){try{a(i.throw(d))}catch(b){u(b)}}function a(d){d.done?r(d.value):o(d.value).then(c,l)}a((i=i.apply(t,e||[])).next())})}function g(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,u;return u={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(a){return function(d){return l([a,d])}}function l(a){if(i)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(n=0)),n;)try{if(i=1,o&&(r=a[0]&2?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[a[0]&2,r.value]),a[0]){case 0:case 1:r=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(r=n.trys,!(r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1],r=a;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(a);break}r[2]&&n.ops.pop(),n.trys.pop();continue}a=e.call(t,n)}catch(d){a=[6,d],o=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}var f=function(t){q(e,t);function e(n,i){i===void 0&&(i=null);var o=t.call(this)||this;return o.isModalError=!0,o.message=n,o.details=i,o}return e.Undefined=function(n){return new e("Modal with id: ".concat(n," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(n){return new e("Guard's name ".concat(n," is not declaration."))},e.NextReject=function(n){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(n))},e.GuardDeclarationType=function(n){return new e("Guard's type should be a function. Provided:",n)},e.ConfigurationType=function(n){return new e("Configuration type must be an Object. Provided",n)},e.ConfigurationUndefinedParam=function(n,i){return new e("In configuration founded unknown parameter: ".concat(n,". Available are ").concat(i.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(n){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(n,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(n){return new e("Event name must be a string. Provided: ".concat(n))},e.ModalNotFoundByID=function(n){return new e("Modal with ID ".concat(n," was not found."))},e.ModalNotExistsInStore=function(n){return new e("Provided name(".concat(n,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),m=function(){function t(){this.state=new Map,t.instance=this}return t.prototype.getByName=function(e){return e===void 0&&(e=t.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:s.reactive([]),initialized:!1}),this.state.get(e)},t.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},t.DEFAULT_NAMESPACE="default",t}(),N=function(){var t=new m,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1},n=t.getByName().queue;return s.watch(function(){return n},function(){e.scrollLock&&(n.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:t,configuration:e}}();function v(t){return N.namespaceStore.getByName(t)}var _=N.configuration;function R(t){var e={backgroundClose:_.backgroundClose,isRoute:!1,namespace:m.DEFAULT_NAMESPACE};return t.backgroundClose!==void 0&&(e.backgroundClose=t.backgroundClose),t.isRoute&&(e.isRoute=t.isRoute),t.namespace&&(e.namespace=t.namespace),e}function S(t){t===void 0&&(t={});var e={background:!1,esc:!1};return Object.assign(e,t)}function T(t){return t||(t={}),t}function w(t,e){e===void 0&&(e={});var n=M.STORE.get(t);if(!n)return Promise.reject(f.ModalNotFoundByID(t));var i=v(n.namespace),o=i.queue.findIndex(function(u){return u.id===t});if(o===-1)return Promise.reject(f.Undefined(t));var r=h.get(t,"close").map(function(u){return F(u,t,S(e))});return O(r).then(function(){i.queue.splice(o,1)}).then(function(){h.get(t,"destroy").forEach(function(u){return u(S(e))})}).then(function(){h.delete(t)})}var M=function(){function t(e,n,i){var o=this;this.events=s.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=t.modalId++,this.component=e,this.props=s.ref(n),this.closed=s.computed(function(){return!v(i.namespace).queue.includes(o)}),e.beforeModalClose&&h.add(this.id,"close",e.beforeModalClose);var r=R(i);this.backgroundClose=r.backgroundClose,this.isRoute=r.isRoute,this.namespace=r.namespace,t.STORE.set(this.id,this)}return t.prototype.close=function(){return w(this.id)},Object.defineProperty(t.prototype,"onclose",{set:function(e){h.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ondestroy",{set:function(e){h.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),t.prototype.on=function(e,n){var i=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(n),function(){var o=i.events[e].indexOf(n);o!==-1&&i.events[e].splice(o,1)}},t.STORE=new Map,t.modalId=0,t.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",t}();function I(t){return M.STORE.get(t)}var D={store:{},add:function(t,e,n){var i,o;if(typeof n!="function")throw f.GuardDeclarationType(n);this.store[t]||(this.store[t]=(i={},i[e]=[],i)),this.store[t][e]||(this.store[t][e]=[]),(o=this.store[t][e])===null||o===void 0||o.push(n)},get:function(t,e){return t in this.store?e in this.store[t]?this.store[t][e]||[]:[]:[]},delete:function(t){t in this.store&&delete this.store[t]}};const h=D;function O(t){return t.reduce(function(e,n){return e.then(function(){return n()})},Promise.resolve())}function F(t,e,n){return function(){return new Promise(function(i,o){var r,u=function(c){c===void 0&&(c=!0),c===!1&&o(f.NextReject(e)),i()};Promise.resolve(t.call((r=I(e))===null||r===void 0?void 0:r.instance,n)).then(u).catch(function(c){return o(c)})})}}function A(t){return t=T(t),O(v(t.namespace).queue.map(function(e){return function(){return e.close()}}))}function C(t){var e=v(t),n=e.queue;if(n.length!==0)return n[n.length-1]}function z(t){t=T(t);var e=C(t.namespace);return e?e.close():Promise.resolve()}function G(t,e,n){var i=R(n),o=v(i.namespace);if(i.namespace===m.DEFAULT_NAMESPACE&&!o.initialized&&!_.skipInitCheck)throw f.NotInitialized(i.namespace);if(typeof t=="string"){var r=j(t);if(!r)throw f.ModalNotExistsInStore(t);t=r}if(!t)throw f.ModalComponentNotProvided();var u=new M(t,e,i);return o.queue.push(s.markRaw(u)),u}function P(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return G(t,e,n)})}function x(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),A({namespace:n.namespace}).then(function(){var i=v(n.namespace);if(i.queue.length)throw f.QueueNoEmpty()}).then(function(){return P(t,e,n)})}function Q(t){if(typeof t!="object")throw f.ConfigurationType(t);Object.assign(_,t)}function U(t){var e,n,i,o=s.getCurrentInstance(),r=String(((e=o==null?void 0:o.props)===null||e===void 0?void 0:e.modalId)||((n=o==null?void 0:o.props)===null||n===void 0?void 0:n["modal-id"])||((i=o==null?void 0:o.attrs)===null||i===void 0?void 0:i.modalId)),u=r.replace(/[^0-9]/g,"");h.add(Number(u),"close",t)}function L(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),p(this,void 0,void 0,function(){var i,o,r=this;return g(this,function(u){switch(u.label){case 0:return[4,P(t,e,n)];case 1:return i=u.sent(),o=!1,[2,new Promise(function(c){i.on(M.EVENT_PROMPT,function(l){return p(r,void 0,void 0,function(){return g(this,function(a){return o=!0,[2,i.close().then(function(){return c(l)}).catch(function(){return o=!1})]})})}),i.ondestroy=function(){o||c(null)}})]}})})}function j(t){return _.store[t]||void 0}const V=["onPointerdown"],k={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=s.ref(null),i=I(t.id);function o(){if(i.backgroundClose)return w(i.id,{background:!0}).catch(()=>{})}return s.watch(()=>e.value,r=>{i.instance=r}),(r,u)=>(s.openBlock(),s.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:s.withModifiers(o,["self","stop"])},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(s.unref(i).component),s.mergeProps(s.unref(i).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${t.id}`,ref_key:"modalRef",ref:e},s.toHandlers(s.unref(i).events)),null,16,["modalId"]))],40,V))}};function W(t){t===void 0&&(t=m.DEFAULT_NAMESPACE);var e=m.instance.getByName(t);e.initialized=!0,t===m.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(_.escClose&&(n.key==="Escape"||n.code==="Escape")){var i=C(t);if(!i)return;w(i.id,{esc:!0}).catch(function(){})}})}const $={props:{namespace:String},setup(t){return s.onMounted(()=>{W(t.namespace)}),()=>{const e=v(t.namespace);return s.h(s.TransitionGroup,{name:_.animation,tag:"div"},{default:()=>e.queue.map(n=>s.h(k,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:k}};var y={router:null};function H(t){var e=this;if(y.router)throw f.DuplicatedRouterIntegration();y.router=t;function n(i){for(var o=i.matched.length-1;o>=0;o--){var r=i.matched[o].components,u=Object.values(r).find(function(c){return c._isModal});if(u)return u}return null}t.beforeEach(function(i,o){return p(e,void 0,void 0,function(){var r,u,c;return g(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),r=n(o),r&&!(!((c=(u=r.getModalObject())===null||u===void 0?void 0:u.closed)===null||c===void 0)&&c.value)?[4,r.close(!0)]:[3,2];case 1:l.sent(),l.label=2;case 2:return[3,4];case 3:return l.sent(),[2,!1];case 4:return[2]}})})}),t.afterEach(function(i){return p(e,void 0,void 0,function(){var o;return g(this,function(r){switch(r.label){case 0:return o=n(i),o?[4,o.initialize()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})})}function B(t){var e=null,n=!1;function i(){return p(this,void 0,void 0,function(){return g(this,function(o){switch(o.label){case 0:if(!y.router)throw f.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,x(t,s.computed(function(){var r;return(r=y.router)===null||r===void 0?void 0:r.currentRoute.value.params}),{isRoute:!0})];case 1:return e=o.sent(),e.onclose=function(){var r;n||(r=y.router)===null||r===void 0||r.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(o){return o===void 0&&(o=!1),p(this,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return n=o,e?[4,e.close()]:[3,2];case 1:return[2,r.sent()];case 2:return[2]}})})},initialize:i,setup:function(){return function(){return null}}}}B.init=H;var Y=v().queue;function J(t){return v(t).queue}exports.Modal=M;exports.closeById=w;exports.closeModal=A;exports.config=Q;exports.container=$;exports.getComponentFromStore=j;exports.getCurrentModal=C;exports.getQueueByNamespace=J;exports.modalQueue=Y;exports.onBeforeModalClose=U;exports.openModal=x;exports.popModal=z;exports.promptModal=L;exports.pushModal=P;exports.useModalRouter=B;
//# sourceMappingURL=jenesius-vue-modal.cjs.js.map
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".modal-container{position:fixed;left:0;top:0;height:100%;width:100%;display:flex;align-items:center;justify-content:center;background-color:#3e3e3e21;cursor:pointer}.modal-item{cursor:default}.modal-list-enter-active,.modal-list-leave-active,.modal-list-enter-active .modal-item,.modal-list-leave-active .modal-item{transition:all .2s ease}.modal-list-enter-from,.modal-list-leave-to{opacity:0!important}.modal-list-enter-from .modal-item,.modal-list-leave-to .modal-item{transform:translateY(-60px)}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
import { reactive as N, watch as R, ref as T, computed as I, markRaw as z, getCurrentInstance as F, openBlock as C, createElementBlock as G, withModifiers as U, createBlock as L, resolveDynamicComponent as Q, unref as M, mergeProps as V, toHandlers as W, onMounted as $, h as P, TransitionGroup as H } from "vue";
/*!
* jenesius-vue-modal v1.11.0
* jenesius-vue-modal v1.11.1
* (c) 2024 Jenesius

@@ -453,3 +453,3 @@ * @license MIT

const e = f(t.namespace);
return P(H, { name: _.animation }, {
return P(H, { name: _.animation, tag: "div" }, {
default: () => e.queue.map((n) => P(S, {

@@ -456,0 +456,0 @@ key: n.id,

(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".modal-container{position:fixed;left:0;top:0;height:100%;width:100%;display:flex;align-items:center;justify-content:center;background-color:#3e3e3e21;cursor:pointer}.modal-item{cursor:default}.modal-list-enter-active,.modal-list-leave-active,.modal-list-enter-active .modal-item,.modal-list-leave-active .modal-item{transition:all .2s ease}.modal-list-enter-from,.modal-list-leave-to{opacity:0!important}.modal-list-enter-from .modal-item,.modal-list-leave-to .modal-item{transform:translateY(-60px)}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.JenesiusVueModal={},s.Vue))})(this,function(s,c){"use strict";/*!
* jenesius-vue-modal v1.11.0
* jenesius-vue-modal v1.11.1
* (c) 2024 Jenesius
* @license MIT
*/var E=function(t,e){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},E(t,e)};function F(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");E(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function p(t,e,n,o){function i(r){return r instanceof n?r:new n(function(a){a(r)})}return new(n||(n=Promise))(function(r,a){function l(h){try{u(o.next(h))}catch(S){a(S)}}function f(h){try{u(o.throw(h))}catch(S){a(S)}}function u(h){h.done?r(h.value):i(h.value).then(l,f)}u((o=o.apply(t,e||[])).next())})}function g(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(u){return function(h){return f([u,h])}}function f(u){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(n=0)),n;)try{if(o=1,i&&(r=u[0]&2?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[u[0]&2,r.value]),u[0]){case 0:case 1:r=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(r=n.trys,!(r=r.length>0&&r[r.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!r||u[1]>r[0]&&u[1]<r[3])){n.label=u[1];break}if(u[0]===6&&n.label<r[1]){n.label=r[1],r=u;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(u);break}r[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(h){u=[6,h],i=0}finally{o=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var d=function(t){F(e,t);function e(n,o){o===void 0&&(o=null);var i=t.call(this)||this;return i.isModalError=!0,i.message=n,i.details=o,i}return e.Undefined=function(n){return new e("Modal with id: ".concat(n," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(n){return new e("Guard's name ".concat(n," is not declaration."))},e.NextReject=function(n){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(n))},e.GuardDeclarationType=function(n){return new e("Guard's type should be a function. Provided:",n)},e.ConfigurationType=function(n){return new e("Configuration type must be an Object. Provided",n)},e.ConfigurationUndefinedParam=function(n,o){return new e("In configuration founded unknown parameter: ".concat(n,". Available are ").concat(o.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(n){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(n,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(n){return new e("Event name must be a string. Provided: ".concat(n))},e.ModalNotFoundByID=function(n){return new e("Modal with ID ".concat(n," was not found."))},e.ModalNotExistsInStore=function(n){return new e("Provided name(".concat(n,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),_=function(){function t(){this.state=new Map,t.instance=this}return t.prototype.getByName=function(e){return e===void 0&&(e=t.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:c.reactive([]),initialized:!1}),this.state.get(e)},t.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},t.DEFAULT_NAMESPACE="default",t}(),k=function(){var t=new _,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1},n=t.getByName().queue;return c.watch(function(){return n},function(){e.scrollLock&&(n.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:t,configuration:e}}();function m(t){return k.namespaceStore.getByName(t)}var y=k.configuration;function N(t){var e={backgroundClose:y.backgroundClose,isRoute:!1,namespace:_.DEFAULT_NAMESPACE};return t.backgroundClose!==void 0&&(e.backgroundClose=t.backgroundClose),t.isRoute&&(e.isRoute=t.isRoute),t.namespace&&(e.namespace=t.namespace),e}function T(t){t===void 0&&(t={});var e={background:!1,esc:!1};return Object.assign(e,t)}function R(t){return t||(t={}),t}function b(t,e){e===void 0&&(e={});var n=M.STORE.get(t);if(!n)return Promise.reject(d.ModalNotFoundByID(t));var o=m(n.namespace),i=o.queue.findIndex(function(a){return a.id===t});if(i===-1)return Promise.reject(d.Undefined(t));var r=v.get(t,"close").map(function(a){return G(a,t,T(e))});return O(r).then(function(){o.queue.splice(i,1)}).then(function(){v.get(t,"destroy").forEach(function(a){return a(T(e))})}).then(function(){v.delete(t)})}var M=function(){function t(e,n,o){var i=this;this.events=c.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=t.modalId++,this.component=e,this.props=c.ref(n),this.closed=c.computed(function(){return!m(o.namespace).queue.includes(i)}),e.beforeModalClose&&v.add(this.id,"close",e.beforeModalClose);var r=N(o);this.backgroundClose=r.backgroundClose,this.isRoute=r.isRoute,this.namespace=r.namespace,t.STORE.set(this.id,this)}return t.prototype.close=function(){return b(this.id)},Object.defineProperty(t.prototype,"onclose",{set:function(e){v.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ondestroy",{set:function(e){v.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),t.prototype.on=function(e,n){var o=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(n),function(){var i=o.events[e].indexOf(n);i!==-1&&o.events[e].splice(i,1)}},t.STORE=new Map,t.modalId=0,t.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",t}();function I(t){return M.STORE.get(t)}var z={store:{},add:function(t,e,n){var o,i;if(typeof n!="function")throw d.GuardDeclarationType(n);this.store[t]||(this.store[t]=(o={},o[e]=[],o)),this.store[t][e]||(this.store[t][e]=[]),(i=this.store[t][e])===null||i===void 0||i.push(n)},get:function(t,e){return t in this.store?e in this.store[t]?this.store[t][e]||[]:[]:[]},delete:function(t){t in this.store&&delete this.store[t]}};const v=z;function O(t){return t.reduce(function(e,n){return e.then(function(){return n()})},Promise.resolve())}function G(t,e,n){return function(){return new Promise(function(o,i){var r,a=function(l){l===void 0&&(l=!0),l===!1&&i(d.NextReject(e)),o()};Promise.resolve(t.call((r=I(e))===null||r===void 0?void 0:r.instance,n)).then(a).catch(function(l){return i(l)})})}}function A(t){return t=R(t),O(m(t.namespace).queue.map(function(e){return function(){return e.close()}}))}function C(t){var e=m(t),n=e.queue;if(n.length!==0)return n[n.length-1]}function Q(t){t=R(t);var e=C(t.namespace);return e?e.close():Promise.resolve()}function U(t,e,n){var o=N(n),i=m(o.namespace);if(o.namespace===_.DEFAULT_NAMESPACE&&!i.initialized&&!y.skipInitCheck)throw d.NotInitialized(o.namespace);if(typeof t=="string"){var r=B(t);if(!r)throw d.ModalNotExistsInStore(t);t=r}if(!t)throw d.ModalComponentNotProvided();var a=new M(t,e,o);return i.queue.push(c.markRaw(a)),a}function P(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return U(t,e,n)})}function j(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),A({namespace:n.namespace}).then(function(){var o=m(n.namespace);if(o.queue.length)throw d.QueueNoEmpty()}).then(function(){return P(t,e,n)})}function x(t){if(typeof t!="object")throw d.ConfigurationType(t);Object.assign(y,t)}function L(t){var e,n,o,i=c.getCurrentInstance(),r=String(((e=i==null?void 0:i.props)===null||e===void 0?void 0:e.modalId)||((n=i==null?void 0:i.props)===null||n===void 0?void 0:n["modal-id"])||((o=i==null?void 0:i.attrs)===null||o===void 0?void 0:o.modalId)),a=r.replace(/[^0-9]/g,"");v.add(Number(a),"close",t)}function V(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),p(this,void 0,void 0,function(){var o,i,r=this;return g(this,function(a){switch(a.label){case 0:return[4,P(t,e,n)];case 1:return o=a.sent(),i=!1,[2,new Promise(function(l){o.on(M.EVENT_PROMPT,function(f){return p(r,void 0,void 0,function(){return g(this,function(u){return i=!0,[2,o.close().then(function(){return l(f)}).catch(function(){return i=!1})]})})}),o.ondestroy=function(){i||l(null)}})]}})})}function B(t){return y.store[t]||void 0}const X="",W=["onPointerdown"],q={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=c.ref(null),o=I(t.id);function i(){if(o.backgroundClose)return b(o.id,{background:!0}).catch(()=>{})}return c.watch(()=>e.value,r=>{o.instance=r}),(r,a)=>(c.openBlock(),c.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:c.withModifiers(i,["self","stop"])},[(c.openBlock(),c.createBlock(c.resolveDynamicComponent(c.unref(o).component),c.mergeProps(c.unref(o).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${t.id}`,ref_key:"modalRef",ref:e},c.toHandlers(c.unref(o).events)),null,16,["modalId"]))],40,W))}};function $(t){t===void 0&&(t=_.DEFAULT_NAMESPACE);var e=_.instance.getByName(t);e.initialized=!0,t===_.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(y.escClose&&(n.key==="Escape"||n.code==="Escape")){var o=C(t);if(!o)return;b(o.id,{esc:!0}).catch(function(){})}})}const Z="",H={props:{namespace:String},setup(t){return c.onMounted(()=>{$(t.namespace)}),()=>{const e=m(t.namespace);return c.h(c.TransitionGroup,{name:y.animation},{default:()=>e.queue.map(n=>c.h(q,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:q}};var w={router:null};function Y(t){var e=this;if(w.router)throw d.DuplicatedRouterIntegration();w.router=t;function n(o){for(var i=o.matched.length-1;i>=0;i--){var r=o.matched[i].components,a=Object.values(r).find(function(l){return l._isModal});if(a)return a}return null}t.beforeEach(function(o,i){return p(e,void 0,void 0,function(){var r,a,l;return g(this,function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),r=n(i),r&&!(!((l=(a=r.getModalObject())===null||a===void 0?void 0:a.closed)===null||l===void 0)&&l.value)?[4,r.close(!0)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[3,4];case 3:return f.sent(),[2,!1];case 4:return[2]}})})}),t.afterEach(function(o){return p(e,void 0,void 0,function(){var i;return g(this,function(r){switch(r.label){case 0:return i=n(o),i?[4,i.initialize()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})})}function D(t){var e=null,n=!1;function o(){return p(this,void 0,void 0,function(){return g(this,function(i){switch(i.label){case 0:if(!w.router)throw d.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,j(t,c.computed(function(){var r;return(r=w.router)===null||r===void 0?void 0:r.currentRoute.value.params}),{isRoute:!0})];case 1:return e=i.sent(),e.onclose=function(){var r;n||(r=w.router)===null||r===void 0||r.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(i){return i===void 0&&(i=!1),p(this,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return n=i,e?[4,e.close()]:[3,2];case 1:return[2,r.sent()];case 2:return[2]}})})},initialize:o,setup:function(){return function(){return null}}}}D.init=Y;var J=m().queue;function K(t){return m(t).queue}s.Modal=M,s.closeById=b,s.closeModal=A,s.config=x,s.container=H,s.getComponentFromStore=B,s.getCurrentModal=C,s.getQueueByNamespace=K,s.modalQueue=J,s.onBeforeModalClose=L,s.openModal=j,s.popModal=Q,s.promptModal=V,s.pushModal=P,s.useModalRouter=D,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
*/var E=function(t,e){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},E(t,e)};function F(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");E(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function p(t,e,n,o){function i(r){return r instanceof n?r:new n(function(a){a(r)})}return new(n||(n=Promise))(function(r,a){function l(h){try{u(o.next(h))}catch(S){a(S)}}function f(h){try{u(o.throw(h))}catch(S){a(S)}}function u(h){h.done?r(h.value):i(h.value).then(l,f)}u((o=o.apply(t,e||[])).next())})}function g(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(u){return function(h){return f([u,h])}}function f(u){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(n=0)),n;)try{if(o=1,i&&(r=u[0]&2?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[u[0]&2,r.value]),u[0]){case 0:case 1:r=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(r=n.trys,!(r=r.length>0&&r[r.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!r||u[1]>r[0]&&u[1]<r[3])){n.label=u[1];break}if(u[0]===6&&n.label<r[1]){n.label=r[1],r=u;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(u);break}r[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(h){u=[6,h],i=0}finally{o=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var d=function(t){F(e,t);function e(n,o){o===void 0&&(o=null);var i=t.call(this)||this;return i.isModalError=!0,i.message=n,i.details=o,i}return e.Undefined=function(n){return new e("Modal with id: ".concat(n," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(n){return new e("Guard's name ".concat(n," is not declaration."))},e.NextReject=function(n){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(n))},e.GuardDeclarationType=function(n){return new e("Guard's type should be a function. Provided:",n)},e.ConfigurationType=function(n){return new e("Configuration type must be an Object. Provided",n)},e.ConfigurationUndefinedParam=function(n,o){return new e("In configuration founded unknown parameter: ".concat(n,". Available are ").concat(o.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(n){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(n,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(n){return new e("Event name must be a string. Provided: ".concat(n))},e.ModalNotFoundByID=function(n){return new e("Modal with ID ".concat(n," was not found."))},e.ModalNotExistsInStore=function(n){return new e("Provided name(".concat(n,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),_=function(){function t(){this.state=new Map,t.instance=this}return t.prototype.getByName=function(e){return e===void 0&&(e=t.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:c.reactive([]),initialized:!1}),this.state.get(e)},t.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},t.DEFAULT_NAMESPACE="default",t}(),k=function(){var t=new _,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1},n=t.getByName().queue;return c.watch(function(){return n},function(){e.scrollLock&&(n.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:t,configuration:e}}();function m(t){return k.namespaceStore.getByName(t)}var y=k.configuration;function N(t){var e={backgroundClose:y.backgroundClose,isRoute:!1,namespace:_.DEFAULT_NAMESPACE};return t.backgroundClose!==void 0&&(e.backgroundClose=t.backgroundClose),t.isRoute&&(e.isRoute=t.isRoute),t.namespace&&(e.namespace=t.namespace),e}function T(t){t===void 0&&(t={});var e={background:!1,esc:!1};return Object.assign(e,t)}function R(t){return t||(t={}),t}function b(t,e){e===void 0&&(e={});var n=M.STORE.get(t);if(!n)return Promise.reject(d.ModalNotFoundByID(t));var o=m(n.namespace),i=o.queue.findIndex(function(a){return a.id===t});if(i===-1)return Promise.reject(d.Undefined(t));var r=v.get(t,"close").map(function(a){return G(a,t,T(e))});return O(r).then(function(){o.queue.splice(i,1)}).then(function(){v.get(t,"destroy").forEach(function(a){return a(T(e))})}).then(function(){v.delete(t)})}var M=function(){function t(e,n,o){var i=this;this.events=c.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=t.modalId++,this.component=e,this.props=c.ref(n),this.closed=c.computed(function(){return!m(o.namespace).queue.includes(i)}),e.beforeModalClose&&v.add(this.id,"close",e.beforeModalClose);var r=N(o);this.backgroundClose=r.backgroundClose,this.isRoute=r.isRoute,this.namespace=r.namespace,t.STORE.set(this.id,this)}return t.prototype.close=function(){return b(this.id)},Object.defineProperty(t.prototype,"onclose",{set:function(e){v.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ondestroy",{set:function(e){v.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),t.prototype.on=function(e,n){var o=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(n),function(){var i=o.events[e].indexOf(n);i!==-1&&o.events[e].splice(i,1)}},t.STORE=new Map,t.modalId=0,t.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",t}();function I(t){return M.STORE.get(t)}var z={store:{},add:function(t,e,n){var o,i;if(typeof n!="function")throw d.GuardDeclarationType(n);this.store[t]||(this.store[t]=(o={},o[e]=[],o)),this.store[t][e]||(this.store[t][e]=[]),(i=this.store[t][e])===null||i===void 0||i.push(n)},get:function(t,e){return t in this.store?e in this.store[t]?this.store[t][e]||[]:[]:[]},delete:function(t){t in this.store&&delete this.store[t]}};const v=z;function O(t){return t.reduce(function(e,n){return e.then(function(){return n()})},Promise.resolve())}function G(t,e,n){return function(){return new Promise(function(o,i){var r,a=function(l){l===void 0&&(l=!0),l===!1&&i(d.NextReject(e)),o()};Promise.resolve(t.call((r=I(e))===null||r===void 0?void 0:r.instance,n)).then(a).catch(function(l){return i(l)})})}}function A(t){return t=R(t),O(m(t.namespace).queue.map(function(e){return function(){return e.close()}}))}function C(t){var e=m(t),n=e.queue;if(n.length!==0)return n[n.length-1]}function Q(t){t=R(t);var e=C(t.namespace);return e?e.close():Promise.resolve()}function U(t,e,n){var o=N(n),i=m(o.namespace);if(o.namespace===_.DEFAULT_NAMESPACE&&!i.initialized&&!y.skipInitCheck)throw d.NotInitialized(o.namespace);if(typeof t=="string"){var r=B(t);if(!r)throw d.ModalNotExistsInStore(t);t=r}if(!t)throw d.ModalComponentNotProvided();var a=new M(t,e,o);return i.queue.push(c.markRaw(a)),a}function P(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return U(t,e,n)})}function j(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),A({namespace:n.namespace}).then(function(){var o=m(n.namespace);if(o.queue.length)throw d.QueueNoEmpty()}).then(function(){return P(t,e,n)})}function x(t){if(typeof t!="object")throw d.ConfigurationType(t);Object.assign(y,t)}function L(t){var e,n,o,i=c.getCurrentInstance(),r=String(((e=i==null?void 0:i.props)===null||e===void 0?void 0:e.modalId)||((n=i==null?void 0:i.props)===null||n===void 0?void 0:n["modal-id"])||((o=i==null?void 0:i.attrs)===null||o===void 0?void 0:o.modalId)),a=r.replace(/[^0-9]/g,"");v.add(Number(a),"close",t)}function V(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),p(this,void 0,void 0,function(){var o,i,r=this;return g(this,function(a){switch(a.label){case 0:return[4,P(t,e,n)];case 1:return o=a.sent(),i=!1,[2,new Promise(function(l){o.on(M.EVENT_PROMPT,function(f){return p(r,void 0,void 0,function(){return g(this,function(u){return i=!0,[2,o.close().then(function(){return l(f)}).catch(function(){return i=!1})]})})}),o.ondestroy=function(){i||l(null)}})]}})})}function B(t){return y.store[t]||void 0}const X="",W=["onPointerdown"],q={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=c.ref(null),o=I(t.id);function i(){if(o.backgroundClose)return b(o.id,{background:!0}).catch(()=>{})}return c.watch(()=>e.value,r=>{o.instance=r}),(r,a)=>(c.openBlock(),c.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:c.withModifiers(i,["self","stop"])},[(c.openBlock(),c.createBlock(c.resolveDynamicComponent(c.unref(o).component),c.mergeProps(c.unref(o).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${t.id}`,ref_key:"modalRef",ref:e},c.toHandlers(c.unref(o).events)),null,16,["modalId"]))],40,W))}};function $(t){t===void 0&&(t=_.DEFAULT_NAMESPACE);var e=_.instance.getByName(t);e.initialized=!0,t===_.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(y.escClose&&(n.key==="Escape"||n.code==="Escape")){var o=C(t);if(!o)return;b(o.id,{esc:!0}).catch(function(){})}})}const Z="",H={props:{namespace:String},setup(t){return c.onMounted(()=>{$(t.namespace)}),()=>{const e=m(t.namespace);return c.h(c.TransitionGroup,{name:y.animation,tag:"div"},{default:()=>e.queue.map(n=>c.h(q,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:q}};var w={router:null};function Y(t){var e=this;if(w.router)throw d.DuplicatedRouterIntegration();w.router=t;function n(o){for(var i=o.matched.length-1;i>=0;i--){var r=o.matched[i].components,a=Object.values(r).find(function(l){return l._isModal});if(a)return a}return null}t.beforeEach(function(o,i){return p(e,void 0,void 0,function(){var r,a,l;return g(this,function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),r=n(i),r&&!(!((l=(a=r.getModalObject())===null||a===void 0?void 0:a.closed)===null||l===void 0)&&l.value)?[4,r.close(!0)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[3,4];case 3:return f.sent(),[2,!1];case 4:return[2]}})})}),t.afterEach(function(o){return p(e,void 0,void 0,function(){var i;return g(this,function(r){switch(r.label){case 0:return i=n(o),i?[4,i.initialize()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})})}function D(t){var e=null,n=!1;function o(){return p(this,void 0,void 0,function(){return g(this,function(i){switch(i.label){case 0:if(!w.router)throw d.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,j(t,c.computed(function(){var r;return(r=w.router)===null||r===void 0?void 0:r.currentRoute.value.params}),{isRoute:!0})];case 1:return e=i.sent(),e.onclose=function(){var r;n||(r=w.router)===null||r===void 0||r.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(i){return i===void 0&&(i=!1),p(this,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return n=i,e?[4,e.close()]:[3,2];case 1:return[2,r.sent()];case 2:return[2]}})})},initialize:o,setup:function(){return function(){return null}}}}D.init=Y;var J=m().queue;function K(t){return m(t).queue}s.Modal=M,s.closeById=b,s.closeModal=A,s.config=x,s.container=H,s.getComponentFromStore=B,s.getCurrentModal=C,s.getQueueByNamespace=K,s.modalQueue=J,s.onBeforeModalClose=L,s.openModal=j,s.popModal=Q,s.promptModal=V,s.pushModal=P,s.useModalRouter=D,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=jenesius-vue-modal.umd.js.map
{
"name": "jenesius-vue-modal",
"version": "1.11.0",
"version": "1.11.1",
"private": false,

@@ -8,3 +8,3 @@ "description": "The progressive and simple modal system for Vue.js v3",

"scripts": {
"serve": "vue-cli-service serve",
"serve": "vue-cli-service serve --mode development",
"build": "vite build --config vite.config.mjs",

@@ -57,3 +57,3 @@ "lint": "vue-cli-service lint",

"vite-tsconfig-paths": "4.2.0",
"vitepress": "1.0.0-rc.25",
"vitepress": "1.0.0-rc.44",
"vue-router": "^4.0.12"

@@ -60,0 +60,0 @@ },

@@ -11,5 +11,5 @@ import {mount} from "@vue/test-utils";

beforeEach(async () => {
NamespaceStore.instance.forceClean()
guards.store = {}
await wait()
NamespaceStore.instance.forceClean()
guards.store = {}
await wait()
})

@@ -19,55 +19,55 @@

it('Test for opened modal window', async function () {
it('Test for opened modal window', async function () {
const value = '123';
const value = '123';
promptModal(ModalPromptValue, {value})
promptModal(ModalPromptValue, {value})
await wait(1);
await wait(1);
expect(app.text()).toEqual(value);
});
it("Should be returned with provided value", async function () {
expect(app.text()).toEqual(value);
});
it("Should be returned with provided value", async function () {
const value = Math.random();
const prResult = promptModal(ModalPromptValue, {
value
})
await wait()
app.find('button').trigger('click')
const value = Math.random();
const prResult = promptModal(ModalPromptValue, {
value
})
await wait()
app.find('button').trigger('click')
await wait()
await wait()
expect(await prResult).toEqual(value)
})
expect(await prResult).toEqual(value)
})
it('If modal was prompted and then just closed, promise should be resolved with value null', async () => {
it('If modal was prompted and then just closed, promise should be resolved with value null', async () => {
const value = Math.random();
const prResult = promptModal(ModalPromptValue, {
value
})
await wait()
await closeModal()
const value = Math.random();
const prResult = promptModal(ModalPromptValue, {
value
})
await wait()
await closeModal()
expect(await prResult).toEqual(null)
})
expect(await prResult).toEqual(null)
})
it("Should not be executed, if on of close's handler stop closing process", async () => {
const value = Math.random();
let isResolved = false
const prResult = promptModal(ModalPromptValueWithHandler, {
value
}).then(data => {
isResolved = true;
return data;
})
await wait()
await app.find('button').trigger('click')
await wait()
await app.find('button').trigger('click')
await wait()
expect(await prResult).toEqual(value)
})
it("Should not be executed, if on of close's handler stop closing process", async () => {
const value = Math.random();
let isResolved = false
const prResult = promptModal(ModalPromptValueWithHandler, {
value
}).then(data => {
isResolved = true;
return data;
})
await wait()
await app.find('button').trigger('click')
await wait()
await app.find('button').trigger('click')
await wait()
expect(await prResult).toEqual(value)
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc