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.10.1 to 1.10.2

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.10.1
* jenesius-vue-modal v1.10.2
* (c) 2023 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 B(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 m(t,e,n,i){function o(r){return r instanceof n?r:new n(function(a){a(r)})}return new(n||(n=Promise))(function(r,a){function c(d){try{u(i.next(d))}catch(b){a(b)}}function l(d){try{u(i.throw(d))}catch(b){a(b)}}function u(d){d.done?r(d.value):o(d.value).then(c,l)}u((i=i.apply(t,e||[])).next())})}function p(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(d){return l([u,d])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(n=0)),n;)try{if(i=1,o&&(r=u[0]&2?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=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++,o=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(d){u=[6,d],o=0}finally{i=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var f=function(t){B(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),h=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}(),P=function(){var t=new h,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},disableInitializationCheck:!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 P.namespaceStore.getByName(t)}var g=P.configuration;function N(t){var e={backgroundClose:g.backgroundClose,isRoute:!1,namespace:h.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 q(t){t===void 0&&(t={});var e={background:!1,esc:!1};return Object.assign(e,t)}function R(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(a){return a.id===t});if(o===-1)return Promise.reject(f.Undefined(t));var r=y.get(t,"close").map(function(a){return z(a,t,q(e))});return I(r).then(function(){i.queue.splice(o,1),y.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&&y.add(this.id,"close",e.beforeModalClose);var r=N(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){y.add(this.id,"close",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 T(t){return M.STORE.get(t)}var D={store:{},add:function(t,e,n){var i;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]=[]),this.store[t][e].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 y=D;function I(t){return t.reduce(function(e,n){return e.then(function(){return n()})},Promise.resolve())}function z(t,e,n){return function(){return new Promise(function(i,o){var r,a=function(c){c===void 0&&(c=!0),c===!1&&o(f.NextReject(e)),i()};Promise.resolve(t.call((r=T(e))===null||r===void 0?void 0:r.instance,n)).then(a).catch(function(c){return o(c)})})}}function O(t){return t=R(t),I(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 F(t){t=R(t);var e=C(t.namespace);return e?e.close():Promise.resolve()}function G(t,e,n){var i=N(n),o=v(i.namespace);if(i.namespace===h.DEFAULT_NAMESPACE&&!o.initialized&&!g.disableInitializationCheck)throw f.NotInitialized(i.namespace);if(typeof t=="string"){var r=x(t);if(!r)throw f.ModalNotExistsInStore(t);t=r}if(!t)throw f.ModalComponentNotProvided();var a=new M(t,e,i);return o.queue.push(s.markRaw(a)),a}function S(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return G(t,e,n)})}function A(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),O({namespace:n.namespace}).then(function(){var i=v(n.namespace);if(i.queue.length)throw f.QueueNoEmpty()}).then(function(){return S(t,e,n)})}function Q(t){if(typeof t!="object")throw f.ConfigurationType(t);Object.assign(g,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)),a=r.replace(/[^0-9]/g,"");y.add(Number(a),"close",t)}function L(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),m(this,void 0,void 0,function(){var i,o=this;return p(this,function(r){switch(r.label){case 0:return[4,S(t,e,n)];case 1:return i=r.sent(),[2,new Promise(function(a){i.on(M.EVENT_PROMPT,function(c){return m(o,void 0,void 0,function(){return p(this,function(l){switch(l.label){case 0:return[4,i.close()];case 1:return l.sent(),a(c),[2]}})})})})]}})})}function x(t){return g.store[t]||void 0}const k={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=s.ref(null),n=s.ref(null),o=T(t.id);function r(a){if(a.target===n.value&&o.backgroundClose)return w(o.id,{background:!0}).catch(()=>{})}return s.watch(()=>e.value,a=>{o.instance=a}),(a,c)=>(s.openBlock(),s.createElementBlock("div",{class:"widget__modal-container__item modal-container",ref_key:"containerRef",ref:n,onClick:r},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(s.unref(o).component),s.mergeProps(s.unref(o).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${t.id}`,ref_key:"modalRef",ref:e},s.toHandlers(s.unref(o).events)),null,16,["modalId"]))],512))}};function V(t){t===void 0&&(t=h.DEFAULT_NAMESPACE);var e=h.instance.getByName(t);e.initialized=!0,t===h.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(g.escClose&&(n.key==="Escape"||n.code==="Escape")){var i=C(t);if(!i)return;w(i.id,{esc:!0}).catch(function(){})}})}const W={props:{namespace:String},setup(t){return s.onMounted(()=>{V(t.namespace)}),()=>{const e=v(t.namespace);return s.h(s.TransitionGroup,{name:g.animation},{default:()=>e.queue.map(n=>s.h(k,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:k}};var _={router:null};function $(t){var e=this;if(_.router)throw f.DuplicatedRouterIntegration();_.router=t;function n(i){for(var o=i.matched.length-1;o>=0;o--){var r=i.matched[o].components,a=Object.values(r).find(function(c){return c._isModal});if(a)return a}return null}t.beforeEach(function(i,o){return m(e,void 0,void 0,function(){var r,a,c;return p(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),r=n(o),r&&!(!((c=(a=r.getModalObject())===null||a===void 0?void 0:a.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 m(e,void 0,void 0,function(){var o;return p(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 j(t){var e=null,n=!1;function i(){return m(this,void 0,void 0,function(){return p(this,function(o){switch(o.label){case 0:if(!_.router)throw f.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,A(t,s.computed(function(){var r;return(r=_.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=_.router)===null||r===void 0||r.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(o){return o===void 0&&(o=!1),m(this,void 0,void 0,function(){return p(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}}}}j.init=$;var H=v().queue;function Y(t){return v(t).queue}exports.Modal=M;exports.closeById=w;exports.closeModal=O;exports.config=Q;exports.container=W;exports.getComponentFromStore=x;exports.getCurrentModal=C;exports.getQueueByNamespace=Y;exports.modalQueue=H;exports.onBeforeModalClose=U;exports.openModal=A;exports.popModal=F;exports.promptModal=L;exports.pushModal=S;exports.useModalRouter=j;
*/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 B(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 m(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 p(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){B(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),h=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}(),P=function(){var t=new h,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 P.namespaceStore.getByName(t)}var g=P.configuration;function N(t){var e={backgroundClose:g.backgroundClose,isRoute:!1,namespace:h.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 q(t){t===void 0&&(t={});var e={background:!1,esc:!1};return Object.assign(e,t)}function R(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=y.get(t,"close").map(function(u){return F(u,t,q(e))});return I(r).then(function(){i.queue.splice(o,1),y.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&&y.add(this.id,"close",e.beforeModalClose);var r=N(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){y.add(this.id,"close",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 T(t){return M.STORE.get(t)}var D={store:{},add:function(t,e,n){var i;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]=[]),this.store[t][e].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 y=D;function I(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=T(e))===null||r===void 0?void 0:r.instance,n)).then(u).catch(function(c){return o(c)})})}}function O(t){return t=R(t),I(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=R(t);var e=C(t.namespace);return e?e.close():Promise.resolve()}function G(t,e,n){var i=N(n),o=v(i.namespace);if(i.namespace===h.DEFAULT_NAMESPACE&&!o.initialized&&!g.skipInitCheck)throw f.NotInitialized(i.namespace);if(typeof t=="string"){var r=x(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 k(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return G(t,e,n)})}function A(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),O({namespace:n.namespace}).then(function(){var i=v(n.namespace);if(i.queue.length)throw f.QueueNoEmpty()}).then(function(){return k(t,e,n)})}function Q(t){if(typeof t!="object")throw f.ConfigurationType(t);Object.assign(g,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,"");y.add(Number(u),"close",t)}function L(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),m(this,void 0,void 0,function(){var i,o=this;return p(this,function(r){switch(r.label){case 0:return[4,k(t,e,n)];case 1:return i=r.sent(),[2,new Promise(function(u){i.on(M.EVENT_PROMPT,function(c){return m(o,void 0,void 0,function(){return p(this,function(l){switch(l.label){case 0:return[4,i.close()];case 1:return l.sent(),u(c),[2]}})})})})]}})})}function x(t){return g.store[t]||void 0}const S={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=s.ref(null),n=s.ref(null),o=T(t.id);function r(u){if(u.target===n.value&&o.backgroundClose)return w(o.id,{background:!0}).catch(()=>{})}return s.watch(()=>e.value,u=>{o.instance=u}),(u,c)=>(s.openBlock(),s.createElementBlock("div",{class:"widget__modal-container__item modal-container",ref_key:"containerRef",ref:n,onClick:r},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(s.unref(o).component),s.mergeProps(s.unref(o).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${t.id}`,ref_key:"modalRef",ref:e},s.toHandlers(s.unref(o).events)),null,16,["modalId"]))],512))}};function V(t){t===void 0&&(t=h.DEFAULT_NAMESPACE);var e=h.instance.getByName(t);e.initialized=!0,t===h.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(g.escClose&&(n.key==="Escape"||n.code==="Escape")){var i=C(t);if(!i)return;w(i.id,{esc:!0}).catch(function(){})}})}const W={props:{namespace:String},setup(t){return s.onMounted(()=>{V(t.namespace)}),()=>{const e=v(t.namespace);return s.h(s.TransitionGroup,{name:g.animation},{default:()=>e.queue.map(n=>s.h(S,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:S}};var _={router:null};function $(t){var e=this;if(_.router)throw f.DuplicatedRouterIntegration();_.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 m(e,void 0,void 0,function(){var r,u,c;return p(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 m(e,void 0,void 0,function(){var o;return p(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 j(t){var e=null,n=!1;function i(){return m(this,void 0,void 0,function(){return p(this,function(o){switch(o.label){case 0:if(!_.router)throw f.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,A(t,s.computed(function(){var r;return(r=_.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=_.router)===null||r===void 0||r.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(o){return o===void 0&&(o=!1),m(this,void 0,void 0,function(){return p(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}}}}j.init=$;var H=v().queue;function Y(t){return v(t).queue}exports.Modal=M;exports.closeById=w;exports.closeModal=O;exports.config=Q;exports.container=W;exports.getComponentFromStore=x;exports.getCurrentModal=C;exports.getQueueByNamespace=Y;exports.modalQueue=H;exports.onBeforeModalClose=U;exports.openModal=A;exports.popModal=z;exports.promptModal=L;exports.pushModal=k;exports.useModalRouter=j;
//# 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 b, computed as T, markRaw as B, getCurrentInstance as z, openBlock as k, createElementBlock as F, createBlock as G, resolveDynamicComponent as U, unref as M, mergeProps as L, toHandlers as Q, onMounted as V, h as S, TransitionGroup as W } from "vue";
/*!
* jenesius-vue-modal v1.10.1
* jenesius-vue-modal v1.10.2
* (c) 2023 Jenesius

@@ -27,12 +27,12 @@ * @license MIT

function o(r) {
return r instanceof n ? r : new n(function(a) {
a(r);
return r instanceof n ? r : new n(function(u) {
u(r);
});
}
return new (n || (n = Promise))(function(r, a) {
return new (n || (n = Promise))(function(r, u) {
function s(l) {
try {
u(i.next(l));
a(i.next(l));
} catch (w) {
a(w);
u(w);
}

@@ -42,11 +42,11 @@ }

try {
u(i.throw(l));
a(i.throw(l));
} catch (w) {
a(w);
u(w);
}
}
function u(l) {
function a(l) {
l.done ? r(l.value) : o(l.value).then(s, c);
}
u((i = i.apply(t, e || [])).next());
a((i = i.apply(t, e || [])).next());
});

@@ -59,46 +59,46 @@ }

return r[1];
}, trys: [], ops: [] }, i, o, r, a;
return a = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (a[Symbol.iterator] = function() {
}, trys: [], ops: [] }, i, o, r, u;
return u = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (u[Symbol.iterator] = function() {
return this;
}), a;
function s(u) {
}), u;
function s(a) {
return function(l) {
return c([u, l]);
return c([a, l]);
};
}
function c(u) {
function c(a) {
if (i)
throw new TypeError("Generator is already executing.");
for (; a && (a = 0, u[0] && (n = 0)), n; )
for (; u && (u = 0, a[0] && (n = 0)), n; )
try {
if (i = 1, o && (r = u[0] & 2 ? o.return : u[0] ? o.throw || ((r = o.return) && r.call(o), 0) : o.next) && !(r = r.call(o, u[1])).done)
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 && (u = [u[0] & 2, r.value]), u[0]) {
switch (o = 0, r && (a = [a[0] & 2, r.value]), a[0]) {
case 0:
case 1:
r = u;
r = a;
break;
case 4:
return n.label++, { value: u[1], done: !1 };
return n.label++, { value: a[1], done: !1 };
case 5:
n.label++, o = u[1], u = [0];
n.label++, o = a[1], a = [0];
continue;
case 7:
u = n.ops.pop(), n.trys.pop();
a = 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)) {
if (r = n.trys, !(r = r.length > 0 && r[r.length - 1]) && (a[0] === 6 || a[0] === 2)) {
n = 0;
continue;
}
if (u[0] === 3 && (!r || u[1] > r[0] && u[1] < r[3])) {
n.label = u[1];
if (a[0] === 3 && (!r || a[1] > r[0] && a[1] < r[3])) {
n.label = a[1];
break;
}
if (u[0] === 6 && n.label < r[1]) {
n.label = r[1], r = u;
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(u);
n.label = r[2], n.ops.push(a);
break;

@@ -109,11 +109,11 @@ }

}
u = e.call(t, n);
a = e.call(t, n);
} catch (l) {
u = [6, l], o = 0;
a = [6, l], o = 0;
} finally {
i = r = 0;
}
if (u[0] & 5)
throw u[1];
return { value: u[0] ? u[1] : void 0, done: !0 };
if (a[0] & 5)
throw a[1];
return { value: a[0] ? a[1] : void 0, done: !0 };
}

@@ -186,3 +186,3 @@ }

store: {},
disableInitializationCheck: !1
skipInitCheck: !1
}, n = t.getByName().queue;

@@ -226,9 +226,9 @@ return R(function() {

return Promise.reject(d.ModalNotFoundByID(t));
var i = f(n.namespace), o = i.queue.findIndex(function(a) {
return a.id === t;
var i = f(n.namespace), o = i.queue.findIndex(function(u) {
return u.id === t;
});
if (o === -1)
return Promise.reject(d.Undefined(t));
var r = g.get(t, "close").map(function(a) {
return J(a, t, H(e));
var r = g.get(t, "close").map(function(u) {
return J(u, t, H(e));
});

@@ -299,6 +299,6 @@ return j(r).then(function() {

return new Promise(function(i, o) {
var r, a = function(s) {
var r, u = function(s) {
s === void 0 && (s = !0), s === !1 && o(d.NextReject(e)), i();
};
Promise.resolve(t.call((r = x(e)) === null || r === void 0 ? void 0 : r.instance, n)).then(a).catch(function(s) {
Promise.resolve(t.call((r = x(e)) === null || r === void 0 ? void 0 : r.instance, n)).then(u).catch(function(s) {
return o(s);

@@ -328,3 +328,3 @@ });

var i = O(n), o = f(i.namespace);
if (i.namespace === v.DEFAULT_NAMESPACE && !o.initialized && !p.disableInitializationCheck)
if (i.namespace === v.DEFAULT_NAMESPACE && !o.initialized && !p.skipInitCheck)
throw d.NotInitialized(i.namespace);

@@ -339,4 +339,4 @@ if (typeof t == "string") {

throw d.ModalComponentNotProvided();
var a = new y(t, e, i);
return o.queue.push(B(a)), a;
var u = new y(t, e, i);
return o.queue.push(B(u)), u;
}

@@ -359,3 +359,3 @@ function q(t, e, n) {

}
function ae(t) {
function ue(t) {
if (typeof t != "object")

@@ -365,5 +365,5 @@ throw d.ConfigurationType(t);

}
function ue(t) {
var e, n, i, o = z(), 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)), a = r.replace(/[^0-9]/g, "");
g.add(Number(a), "close", t);
function ae(t) {
var e, n, i, o = z(), 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, "");
g.add(Number(u), "close", t);
}

@@ -378,3 +378,3 @@ function se(t, e, n) {

case 1:
return i = r.sent(), [2, new Promise(function(a) {
return i = r.sent(), [2, new Promise(function(u) {
i.on(y.EVENT_PROMPT, function(s) {

@@ -387,3 +387,3 @@ return h(o, void 0, void 0, function() {

case 1:
return c.sent(), a(s), [
return c.sent(), u(s), [
2

@@ -411,10 +411,10 @@ /*return*/

const e = b(null), n = b(null), o = x(t.id);
function r(a) {
if (a.target === n.value && o.backgroundClose)
function r(u) {
if (u.target === n.value && o.backgroundClose)
return C(o.id, { background: !0 }).catch(() => {
});
}
return R(() => e.value, (a) => {
o.instance = a;
}), (a, s) => (k(), F("div", {
return R(() => e.value, (u) => {
o.instance = u;
}), (u, s) => (k(), F("div", {
class: "widget__modal-container__item modal-container",

@@ -476,7 +476,7 @@ ref_key: "containerRef",

for (var o = i.matched.length - 1; o >= 0; o--) {
var r = i.matched[o].components, a = Object.values(r).find(function(s) {
var r = i.matched[o].components, u = Object.values(r).find(function(s) {
return s._isModal;
});
if (a)
return a;
if (u)
return u;
}

@@ -487,7 +487,7 @@ return null;

return h(e, void 0, void 0, function() {
var r, a, s;
var r, u, s;
return m(this, function(c) {
switch (c.label) {
case 0:
return c.trys.push([0, 3, , 4]), r = n(o), r && !(!((s = (a = r.getModalObject()) === null || a === void 0 ? void 0 : a.closed) === null || s === void 0) && s.value) ? [4, r.close(!0)] : [3, 2];
return c.trys.push([0, 3, , 4]), r = n(o), r && !(!((s = (u = r.getModalObject()) === null || u === void 0 ? void 0 : u.closed) === null || s === void 0) && s.value) ? [4, r.close(!0)] : [3, 2];
case 1:

@@ -601,3 +601,3 @@ c.sent(), c.label = 2;

K as closeModal,
ae as config,
ue as config,
ce as container,

@@ -608,3 +608,3 @@ ee as getComponentFromStore,

le as modalQueue,
ue as onBeforeModalClose,
ae as onBeforeModalClose,
Z as openModal,

@@ -611,0 +611,0 @@ ie as popModal,

(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.10.1
* jenesius-vue-modal v1.10.2
* (c) 2023 Jenesius
* @license MIT
*/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 D(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 v(t,e,n,i){function o(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(i.next(h))}catch(k){a(k)}}function d(h){try{u(i.throw(h))}catch(k){a(k)}}function u(h){h.done?r(h.value):o(h.value).then(l,d)}u((i=i.apply(t,e||[])).next())})}function p(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,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 d([u,h])}}function d(u){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(n=0)),n;)try{if(i=1,o&&(r=u[0]&2?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=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++,o=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],o=0}finally{i=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var f=function(t){D(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),g=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}(),P=function(){var t=new g,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},disableInitializationCheck:!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 P.namespaceStore.getByName(t)}var _=P.configuration;function N(t){var e={backgroundClose:_.backgroundClose,isRoute:!1,namespace:g.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 z(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=y.STORE.get(t);if(!n)return Promise.reject(f.ModalNotFoundByID(t));var i=m(n.namespace),o=i.queue.findIndex(function(a){return a.id===t});if(o===-1)return Promise.reject(f.Undefined(t));var r=M.get(t,"close").map(function(a){return G(a,t,z(e))});return I(r).then(function(){i.queue.splice(o,1),M.delete(t)})}var y=function(){function t(e,n,i){var o=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(i.namespace).queue.includes(o)}),e.beforeModalClose&&M.add(this.id,"close",e.beforeModalClose);var r=N(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 b(this.id)},Object.defineProperty(t.prototype,"onclose",{set:function(e){M.add(this.id,"close",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 T(t){return y.STORE.get(t)}var F={store:{},add:function(t,e,n){var i;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]=[]),this.store[t][e].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 M=F;function I(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(i,o){var r,a=function(l){l===void 0&&(l=!0),l===!1&&o(f.NextReject(e)),i()};Promise.resolve(t.call((r=T(e))===null||r===void 0?void 0:r.instance,n)).then(a).catch(function(l){return o(l)})})}}function O(t){return t=R(t),I(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 i=N(n),o=m(i.namespace);if(i.namespace===g.DEFAULT_NAMESPACE&&!o.initialized&&!_.disableInitializationCheck)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 a=new y(t,e,i);return o.queue.push(c.markRaw(a)),a}function S(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return U(t,e,n)})}function A(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),O({namespace:n.namespace}).then(function(){var i=m(n.namespace);if(i.queue.length)throw f.QueueNoEmpty()}).then(function(){return S(t,e,n)})}function x(t){if(typeof t!="object")throw f.ConfigurationType(t);Object.assign(_,t)}function L(t){var e,n,i,o=c.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)),a=r.replace(/[^0-9]/g,"");M.add(Number(a),"close",t)}function V(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),v(this,void 0,void 0,function(){var i,o=this;return p(this,function(r){switch(r.label){case 0:return[4,S(t,e,n)];case 1:return i=r.sent(),[2,new Promise(function(a){i.on(y.EVENT_PROMPT,function(l){return v(o,void 0,void 0,function(){return p(this,function(d){switch(d.label){case 0:return[4,i.close()];case 1:return d.sent(),a(l),[2]}})})})})]}})})}function j(t){return _.store[t]||void 0}const K="",B={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=c.ref(null),n=c.ref(null),o=T(t.id);function r(a){if(a.target===n.value&&o.backgroundClose)return b(o.id,{background:!0}).catch(()=>{})}return c.watch(()=>e.value,a=>{o.instance=a}),(a,l)=>(c.openBlock(),c.createElementBlock("div",{class:"widget__modal-container__item modal-container",ref_key:"containerRef",ref:n,onClick:r},[(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"]))],512))}};function W(t){t===void 0&&(t=g.DEFAULT_NAMESPACE);var e=g.instance.getByName(t);e.initialized=!0,t===g.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(_.escClose&&(n.key==="Escape"||n.code==="Escape")){var i=C(t);if(!i)return;b(i.id,{esc:!0}).catch(function(){})}})}const X="",$={props:{namespace:String},setup(t){return c.onMounted(()=>{W(t.namespace)}),()=>{const e=m(t.namespace);return c.h(c.TransitionGroup,{name:_.animation},{default:()=>e.queue.map(n=>c.h(B,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:B}};var w={router:null};function H(t){var e=this;if(w.router)throw f.DuplicatedRouterIntegration();w.router=t;function n(i){for(var o=i.matched.length-1;o>=0;o--){var r=i.matched[o].components,a=Object.values(r).find(function(l){return l._isModal});if(a)return a}return null}t.beforeEach(function(i,o){return v(e,void 0,void 0,function(){var r,a,l;return p(this,function(d){switch(d.label){case 0:return d.trys.push([0,3,,4]),r=n(o),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:d.sent(),d.label=2;case 2:return[3,4];case 3:return d.sent(),[2,!1];case 4:return[2]}})})}),t.afterEach(function(i){return v(e,void 0,void 0,function(){var o;return p(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 q(t){var e=null,n=!1;function i(){return v(this,void 0,void 0,function(){return p(this,function(o){switch(o.label){case 0:if(!w.router)throw f.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,A(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=o.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(o){return o===void 0&&(o=!1),v(this,void 0,void 0,function(){return p(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}}}}q.init=H;var Y=m().queue;function J(t){return m(t).queue}s.Modal=y,s.closeById=b,s.closeModal=O,s.config=x,s.container=$,s.getComponentFromStore=j,s.getCurrentModal=C,s.getQueueByNamespace=J,s.modalQueue=Y,s.onBeforeModalClose=L,s.openModal=A,s.popModal=Q,s.promptModal=V,s.pushModal=S,s.useModalRouter=q,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
*/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 D(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 v(t,e,n,i){function o(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(i.next(h))}catch(S){a(S)}}function d(h){try{u(i.throw(h))}catch(S){a(S)}}function u(h){h.done?r(h.value):o(h.value).then(l,d)}u((i=i.apply(t,e||[])).next())})}function p(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,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 d([u,h])}}function d(u){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(n=0)),n;)try{if(i=1,o&&(r=u[0]&2?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=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++,o=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],o=0}finally{i=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var f=function(t){D(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),g=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}(),P=function(){var t=new g,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 P.namespaceStore.getByName(t)}var _=P.configuration;function N(t){var e={backgroundClose:_.backgroundClose,isRoute:!1,namespace:g.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 F(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=y.STORE.get(t);if(!n)return Promise.reject(f.ModalNotFoundByID(t));var i=m(n.namespace),o=i.queue.findIndex(function(a){return a.id===t});if(o===-1)return Promise.reject(f.Undefined(t));var r=M.get(t,"close").map(function(a){return G(a,t,F(e))});return I(r).then(function(){i.queue.splice(o,1),M.delete(t)})}var y=function(){function t(e,n,i){var o=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(i.namespace).queue.includes(o)}),e.beforeModalClose&&M.add(this.id,"close",e.beforeModalClose);var r=N(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 b(this.id)},Object.defineProperty(t.prototype,"onclose",{set:function(e){M.add(this.id,"close",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 T(t){return y.STORE.get(t)}var z={store:{},add:function(t,e,n){var i;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]=[]),this.store[t][e].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 M=z;function I(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(i,o){var r,a=function(l){l===void 0&&(l=!0),l===!1&&o(f.NextReject(e)),i()};Promise.resolve(t.call((r=T(e))===null||r===void 0?void 0:r.instance,n)).then(a).catch(function(l){return o(l)})})}}function O(t){return t=R(t),I(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 i=N(n),o=m(i.namespace);if(i.namespace===g.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 a=new y(t,e,i);return o.queue.push(c.markRaw(a)),a}function k(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),Promise.resolve().then(function(){return U(t,e,n)})}function A(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),O({namespace:n.namespace}).then(function(){var i=m(n.namespace);if(i.queue.length)throw f.QueueNoEmpty()}).then(function(){return k(t,e,n)})}function x(t){if(typeof t!="object")throw f.ConfigurationType(t);Object.assign(_,t)}function L(t){var e,n,i,o=c.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)),a=r.replace(/[^0-9]/g,"");M.add(Number(a),"close",t)}function V(t,e,n){return e===void 0&&(e={}),n===void 0&&(n={}),v(this,void 0,void 0,function(){var i,o=this;return p(this,function(r){switch(r.label){case 0:return[4,k(t,e,n)];case 1:return i=r.sent(),[2,new Promise(function(a){i.on(y.EVENT_PROMPT,function(l){return v(o,void 0,void 0,function(){return p(this,function(d){switch(d.label){case 0:return[4,i.close()];case 1:return d.sent(),a(l),[2]}})})})})]}})})}function j(t){return _.store[t]||void 0}const K="",B={__name:"WidgetModalContainerItem",props:{id:Number},setup(t){const e=c.ref(null),n=c.ref(null),o=T(t.id);function r(a){if(a.target===n.value&&o.backgroundClose)return b(o.id,{background:!0}).catch(()=>{})}return c.watch(()=>e.value,a=>{o.instance=a}),(a,l)=>(c.openBlock(),c.createElementBlock("div",{class:"widget__modal-container__item modal-container",ref_key:"containerRef",ref:n,onClick:r},[(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"]))],512))}};function W(t){t===void 0&&(t=g.DEFAULT_NAMESPACE);var e=g.instance.getByName(t);e.initialized=!0,t===g.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(n){if(_.escClose&&(n.key==="Escape"||n.code==="Escape")){var i=C(t);if(!i)return;b(i.id,{esc:!0}).catch(function(){})}})}const X="",$={props:{namespace:String},setup(t){return c.onMounted(()=>{W(t.namespace)}),()=>{const e=m(t.namespace);return c.h(c.TransitionGroup,{name:_.animation},{default:()=>e.queue.map(n=>c.h(B,{key:n.id,id:n.id}))})}},components:{WidgetContainerModalItem:B}};var w={router:null};function H(t){var e=this;if(w.router)throw f.DuplicatedRouterIntegration();w.router=t;function n(i){for(var o=i.matched.length-1;o>=0;o--){var r=i.matched[o].components,a=Object.values(r).find(function(l){return l._isModal});if(a)return a}return null}t.beforeEach(function(i,o){return v(e,void 0,void 0,function(){var r,a,l;return p(this,function(d){switch(d.label){case 0:return d.trys.push([0,3,,4]),r=n(o),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:d.sent(),d.label=2;case 2:return[3,4];case 3:return d.sent(),[2,!1];case 4:return[2]}})})}),t.afterEach(function(i){return v(e,void 0,void 0,function(){var o;return p(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 q(t){var e=null,n=!1;function i(){return v(this,void 0,void 0,function(){return p(this,function(o){switch(o.label){case 0:if(!w.router)throw f.ModalRouterIntegrationNotInitialized();return n=!1,e=null,[4,A(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=o.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(o){return o===void 0&&(o=!1),v(this,void 0,void 0,function(){return p(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}}}}q.init=H;var Y=m().queue;function J(t){return m(t).queue}s.Modal=y,s.closeById=b,s.closeModal=O,s.config=x,s.container=$,s.getComponentFromStore=j,s.getCurrentModal=C,s.getQueueByNamespace=J,s.modalQueue=Y,s.onBeforeModalClose=L,s.openModal=A,s.popModal=Q,s.promptModal=V,s.pushModal=k,s.useModalRouter=q,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=jenesius-vue-modal.umd.js.map

@@ -38,4 +38,4 @@ /**

* */
disableInitializationCheck: boolean;
skipInitCheck: boolean;
store: Record<string, Component>;
}
{
"name": "jenesius-vue-modal",
"version": "1.10.1",
"version": "1.10.2",
"private": false,

@@ -5,0 +5,0 @@ "description": "Simple modal plugin for Vue3",

import {mount} from "@vue/test-utils";
import {closeModal, config, container, getQueueByNamespace, openModal, popModal, pushModal} from "../src/index";
import {closeModal, config, container, getQueueByNamespace, openModal, popModal} from "../src/index";
import wait from "./wait";

@@ -135,3 +135,3 @@ import ModalTitle from "./components/modal-title.vue";

config({
disableInitializationCheck: true
skipInitCheck: true
})

@@ -138,0 +138,0 @@ await expect(openModal(ModalTitle)).resolves.not.toThrow();

Sorry, the diff of this file is not supported yet

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