vue-haystack
Advanced tools
Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3
@@ -1,2 +0,2 @@ | ||
import { App, ComponentPropsOptions, Ref } from "vue"; | ||
import { ComponentPropsOptions, Ref } from "vue"; | ||
declare type ComponentBaseType = abstract new (...args: any) => any; | ||
@@ -38,8 +38,2 @@ export interface ItemBase<OptionsType> { | ||
} & Extend; | ||
provideStore: (app?: App<any> | undefined) => { | ||
items: Ref<I[]>; | ||
remove: (itemId: I["id"]) => void; | ||
push: <T extends ComponentBaseType>(component: T, props?: InstanceType<T>["$props"] | undefined, listeners?: InstanceType<T>["$emits"] | undefined, options?: I["options"] | undefined) => Res; | ||
pushDefault: (props?: InstanceType<CBase>["$props"] | null, options?: I["options"] | undefined) => Res; | ||
} & Extend; | ||
useItem: () => I; | ||
@@ -46,0 +40,0 @@ provideItem: (item: I) => I; |
@@ -6,3 +6,3 @@ export declare const useModalStore: () => { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -20,8 +20,8 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null | undefined) => { | ||
onClose: (callback: (data: any) => void) => { | ||
} | undefined) => { | ||
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => { | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -39,8 +39,8 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null | undefined) => { | ||
onClose: (callback: (data: any) => void) => { | ||
} | undefined) => { | ||
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => { | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -61,18 +61,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
id: string; | ||
component: any; | ||
props: import("vue").ComponentPropsOptions<{ | ||
[x: string]: unknown; | ||
}> | null; | ||
listeners: { | ||
[key: string]: (...params: never) => never; | ||
}; | ||
} | null>; | ||
}, provideModalStore: (app?: import("vue").App<any> | undefined) => { | ||
items: import("@vue/reactivity").Ref<{ | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
id: string; | ||
@@ -86,54 +71,2 @@ component: any; | ||
}; | ||
}[]>; | ||
remove: (itemId: string) => void; | ||
push: <T_1 extends abstract new (...args: any) => any>(component: T_1, props?: InstanceType<T_1>["$props"] | undefined, listeners?: InstanceType<T_1>["$emits"] | undefined, options?: { | ||
closeOnOverlayClick: boolean; | ||
} | null | undefined) => { | ||
onClose: (callback: (data: any) => void) => { | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
id: string; | ||
component: any; | ||
props: import("vue").ComponentPropsOptions<{ | ||
[x: string]: unknown; | ||
}> | null; | ||
listeners: { | ||
[key: string]: (...params: never) => never; | ||
}; | ||
}; | ||
}; | ||
pushDefault: (props?: any, options?: { | ||
closeOnOverlayClick: boolean; | ||
} | null | undefined) => { | ||
onClose: (callback: (data: any) => void) => { | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
id: string; | ||
component: any; | ||
props: import("vue").ComponentPropsOptions<{ | ||
[x: string]: unknown; | ||
}> | null; | ||
listeners: { | ||
[key: string]: (...params: never) => never; | ||
}; | ||
}; | ||
}; | ||
} & { | ||
activeModal: import("@vue/reactivity").ComputedRef<{ | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
id: string; | ||
component: any; | ||
props: import("vue").ComponentPropsOptions<{ | ||
[x: string]: unknown; | ||
}> | null; | ||
listeners: { | ||
[key: string]: (...params: never) => never; | ||
}; | ||
} | null>; | ||
@@ -144,3 +77,3 @@ }, useModal: () => { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -158,3 +91,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -172,3 +105,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -187,3 +120,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -201,8 +134,8 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null | undefined) => { | ||
onClose: (callback: (data: any) => void) => { | ||
} | undefined) => { | ||
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => { | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -220,8 +153,8 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null | undefined) => { | ||
onClose: (callback: (data: any) => void) => { | ||
} | undefined) => { | ||
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => { | ||
close: <T>(data?: T | undefined) => void; | ||
options: { | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -242,3 +175,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -264,3 +197,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -279,3 +212,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -294,3 +227,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -318,3 +251,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -336,3 +269,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -354,3 +287,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -357,0 +290,0 @@ component: any; |
@@ -12,3 +12,3 @@ import { useModal } from "."; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -27,3 +27,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -30,0 +30,0 @@ component: any; |
@@ -8,3 +8,3 @@ import { PropType } from "vue"; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -26,3 +26,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -44,3 +44,3 @@ component: any; | ||
closeOnOverlayClick: boolean; | ||
} | null; | ||
}; | ||
id: string; | ||
@@ -47,0 +47,0 @@ component: any; |
@@ -1,1 +0,1 @@ | ||
"use strict";var te=Object.defineProperty,re=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var D=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))ne.call(t,r)&&D(e,r,t[r]);if(V)for(var r of V(t))se.call(t,r)&&D(e,r,t[r]);return e},N=(e,t)=>re(e,oe(t));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var s=require("vue");const ae=()=>{},le=Array.isArray,ie=e=>typeof e=="function",ce=e=>typeof e=="symbol";let de;function ue(e,t){t=t||de,t&&t.active&&t.effects.push(e)}const fe=e=>{const t=new Set(e);return t.w=0,t.n=0,t},q=e=>(e.w&v)>0,O=e=>(e.n&v)>0,ve=({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=v},pe=e=>{const{deps:t}=e;if(t.length){let r=0;for(let o=0;o<t.length;o++){const n=t[o];q(n)&&!O(n)?n.delete(e):t[r++]=n,n.w&=~v,n.n&=~v}t.length=r}};let k=0,v=1;const R=30,g=[];let m;class me{constructor(t,r=null,o){this.fn=t,this.scheduler=r,this.active=!0,this.deps=[],ue(this,o)}run(){if(!this.active)return this.fn();if(!g.includes(this))try{return g.push(m=this),he(),v=1<<++k,k<=R?ve(this):j(this),this.fn()}finally{k<=R&&pe(this),v=1<<--k,ye(),g.pop();const t=g.length;m=t>0?g[t-1]:void 0}}stop(){this.active&&(j(this),this.onStop&&this.onStop(),this.active=!1)}}function j(e){const{deps:t}=e;if(t.length){for(let r=0;r<t.length;r++)t[r].delete(e);t.length=0}}let S=!0;const A=[];function he(){A.push(S),S=!0}function ye(){const e=A.pop();S=e===void 0?!0:e}function _e(){return S&&m!==void 0}function ke(e,t){let r=!1;k<=R?O(e)||(e.n|=v,r=!q(e)):r=!e.has(m),r&&(e.add(m),m.deps.push(e))}function ge(e,t){for(const r of le(e)?e:[...e])(r!==m||r.allowRecurse)&&(r.scheduler?r.scheduler():r.run())}new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(ce));function M(e){const t=e&&e.__v_raw;return t?M(t):e}function we(e){_e()&&(e=M(e),e.dep||(e.dep=fe()),ke(e.dep))}function Se(e,t){e=M(e),e.dep&&ge(e.dep)}class Me{constructor(t,r,o){this._setter=r,this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.effect=new me(t,()=>{this._dirty||(this._dirty=!0,Se(this))}),this.__v_isReadonly=o}get value(){const t=M(this);return we(t),t._dirty&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function Ce(e,t){let r,o;const n=ie(e);return n?(r=e,o=ae):(r=e.get,o=e.set),new Me(r,o,n||!o)}Promise.resolve();var C={exports:{}},b=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(b){var B=new Uint8Array(16);C.exports=function(){return b(B),B}}else{var U=new Array(16);C.exports=function(){for(var t=0,r;t<16;t++)(t&3)==0&&(r=Math.random()*4294967296),U[t]=r>>>((t&3)<<3)&255;return U}}var z=[];for(var x=0;x<256;++x)z[x]=(x+256).toString(16).substr(1);function xe(e,t){var r=t||0,o=z;return[o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]]].join("")}var G=xe,$e=C.exports,Re=G,F,E,T=0,I=0;function Ee(e,t,r){var o=t&&r||0,n=t||[];e=e||{};var l=e.node||F,i=e.clockseq!==void 0?e.clockseq:E;if(l==null||i==null){var a=$e();l==null&&(l=F=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),i==null&&(i=E=(a[6]<<8|a[7])&16383)}var c=e.msecs!==void 0?e.msecs:new Date().getTime(),d=e.nsecs!==void 0?e.nsecs:I+1,f=c-T+(d-I)/1e4;if(f<0&&e.clockseq===void 0&&(i=i+1&16383),(f<0||c>T)&&e.nsecs===void 0&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");T=c,I=d,E=i,c+=122192928e5;var h=((c&268435455)*1e4+d)%4294967296;n[o++]=h>>>24&255,n[o++]=h>>>16&255,n[o++]=h>>>8&255,n[o++]=h&255;var p=c/4294967296*1e4&268435455;n[o++]=p>>>8&255,n[o++]=p&255,n[o++]=p>>>24&15|16,n[o++]=p>>>16&255,n[o++]=i>>>8|128,n[o++]=i&255;for(var _=0;_<6;++_)n[o+_]=l[_];return t||Re(n)}var Te=Ee,Ie=C.exports,Pe=G;function Ve(e,t,r){var o=t&&r||0;typeof e=="string"&&(t=e==="binary"?new Array(16):null,e=null),e=e||{};var n=e.random||(e.rng||Ie)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t)for(var l=0;l<16;++l)t[o+l]=n[l];return t||Pe(n)}var De=Ve,Ne=Te,H=De,P=H;P.v1=Ne;P.v4=H;var qe=P;const Oe=(e,t=()=>({}),r)=>{const o=s.ref([]),n=u=>{const y=o.value.findIndex($=>$.id===u);y!==-1&&o.value.splice(y,1)},l=(u,y,$,Y)=>{const{item:Z,useReturn:ee}=e({id:qe.v4(),component:s.markRaw(u),props:y||{},listeners:$||{},options:Y||null});return o.value.push(Z),ee},c=w(w({},{items:o,remove:n,push:l,pushDefault:(u=null,y)=>{if(!r)throw new Error("No default component passed to the item store, cannot show item.");return l(r,u,y)}}),t(o)),d=Symbol("genericstore"),f=u=>(u?u.provide(d,c):s.provide(d,c),c),h=()=>s.inject(d),p=Symbol("item");return{store:c,useStore:h,provideStore:f,useItem:()=>s.inject(p),provideItem:u=>(s.provide(p,u),u)}};var L=(e,t)=>{for(const[r,o]of t)e[r]=o;return e};const je=s.defineComponent({name:"ModalProvider",components:{},props:{modal:{type:Object,required:!0}},setup:e=>({item:W(e.modal)})});function Ae(e,t,r,o,n,l){return s.renderSlot(e.$slots,"default",{modal:e.item})}var J=L(je,[["render",Ae]]);const be="_modalContainer_ato2o_1",Be="_overlay_ato2o_13",Ue="_layer_ato2o_21",ze="_clickable_ato2o_26",Ge="_modal_ato2o_1";var Fe={modalContainer:be,overlay:Be,layer:Ue,clickable:ze,modal:Ge};const He=s.defineComponent({name:"ModalContainer",components:{ModalProvider:J},props:{showOverlay:{type:Boolean,default:!0}},setup:e=>{const t=Q(),r=s.computed(()=>t.activeModal.value),o=l=>{var i;((i=l.options)==null?void 0:i.closeOnOverlayClick)&&l.close()};return{modals:s.computed(()=>t.items.value),activeModal:r,overlayClick:o}}}),Le=["onClick"];function Je(e,t,r,o,n,l){const i=s.resolveComponent("ModalProvider");return s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("div",{class:s.normalizeClass(e.$style.modalContainer)},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(e.modals,a=>(s.openBlock(),s.createBlock(i,{key:a.id,modal:a},{default:s.withCtx(()=>{var c,d;return[s.withDirectives(s.createElementVNode("div",{class:s.normalizeClass([e.$style.overlay,{[e.$style.clickable]:(c=a.options)==null?void 0:c.closeOnOverlayClick}]),onClick:f=>e.overlayClick(a)},[s.renderSlot(e.$slots,"overlay",{},()=>[s.createElementVNode("div",{class:s.normalizeClass(e.$style.layer)},null,2)])],10,Le),[[s.vShow,a.id===((d=e.activeModal)==null?void 0:d.id)]]),s.renderSlot(e.$slots,"default",{modal:a,activeModal:e.activeModal},()=>{var f;return[s.withDirectives((s.openBlock(),s.createBlock(s.resolveDynamicComponent(a.component),s.mergeProps({key:a.id,class:e.$style.modal},a.props,s.toHandlers(a.listeners)),null,16,["class"])),[[s.vShow,a.id===((f=e.activeModal)==null?void 0:f.id)]])]})]}),_:2},1032,["modal"]))),128))],2)])}const K={};K.$style=Fe;var Ke=L(He,[["render",Je],["__cssModules",K]]);const{useStore:Q,provideStore:Qe,useItem:We,provideItem:W,store:X}=Oe(e=>{let t;const r=new Promise(n=>{t=n}),o=N(w({},e),{close:n=>{t(n),X.remove(e.id)},options:e.options});return{item:o,useReturn:{onClose:n=>(r.then(n),o)},options:o.options}},e=>({activeModal:Ce(()=>e.value.length>0?e.value[e.value.length-1]:null)})),Xe=Ke,Ye=J;exports.ModalContainer=Xe;exports.ModalProvider=Ye;exports.modalStore=X;exports.provideModal=W;exports.provideModalStore=Qe;exports.useModal=We;exports.useModalStore=Q; | ||
"use strict";var ee=Object.defineProperty,te=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var V=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_=(e,t)=>{for(var r in t||(t={}))ne.call(t,r)&&V(e,r,t[r]);if(P)for(var r of P(t))oe.call(t,r)&&V(e,r,t[r]);return e},D=(e,t)=>te(e,re(t));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var s=require("vue");const se=()=>{},ae=Array.isArray,le=e=>typeof e=="function",ie=e=>typeof e=="symbol";let ce;function ue(e,t){t=t||ce,t&&t.active&&t.effects.push(e)}const de=e=>{const t=new Set(e);return t.w=0,t.n=0,t},N=e=>(e.w&v)>0,O=e=>(e.n&v)>0,fe=({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=v},ve=e=>{const{deps:t}=e;if(t.length){let r=0;for(let n=0;n<t.length;n++){const o=t[n];N(o)&&!O(o)?o.delete(e):t[r++]=o,o.w&=~v,o.n&=~v}t.length=r}};let k=0,v=1;const $=30,g=[];let m;class me{constructor(t,r=null,n){this.fn=t,this.scheduler=r,this.active=!0,this.deps=[],ue(this,n)}run(){if(!this.active)return this.fn();if(!g.includes(this))try{return g.push(m=this),pe(),v=1<<++k,k<=$?fe(this):q(this),this.fn()}finally{k<=$&&ve(this),v=1<<--k,he(),g.pop();const t=g.length;m=t>0?g[t-1]:void 0}}stop(){this.active&&(q(this),this.onStop&&this.onStop(),this.active=!1)}}function q(e){const{deps:t}=e;if(t.length){for(let r=0;r<t.length;r++)t[r].delete(e);t.length=0}}let w=!0;const A=[];function pe(){A.push(w),w=!0}function he(){const e=A.pop();w=e===void 0?!0:e}function ye(){return w&&m!==void 0}function _e(e,t){let r=!1;k<=$?O(e)||(e.n|=v,r=!N(e)):r=!e.has(m),r&&(e.add(m),m.deps.push(e))}function ke(e,t){for(const r of ae(e)?e:[...e])(r!==m||r.allowRecurse)&&(r.scheduler?r.scheduler():r.run())}new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(ie));function M(e){const t=e&&e.__v_raw;return t?M(t):e}function ge(e){ye()&&(e=M(e),e.dep||(e.dep=de()),_e(e.dep))}function we(e,t){e=M(e),e.dep&&ke(e.dep)}class Me{constructor(t,r,n){this._setter=r,this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.effect=new me(t,()=>{this._dirty||(this._dirty=!0,we(this))}),this.__v_isReadonly=n}get value(){const t=M(this);return ge(t),t._dirty&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function Se(e,t){let r,n;const o=le(e);return o?(r=e,n=se):(r=e.get,n=e.set),new Me(r,n,o||!n)}Promise.resolve();var S={exports:{}},j=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(j){var B=new Uint8Array(16);S.exports=function(){return j(B),B}}else{var U=new Array(16);S.exports=function(){for(var t=0,r;t<16;t++)(t&3)==0&&(r=Math.random()*4294967296),U[t]=r>>>((t&3)<<3)&255;return U}}var z=[];for(var C=0;C<256;++C)z[C]=(C+256).toString(16).substr(1);function Ce(e,t){var r=t||0,n=z;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}var b=Ce,xe=S.exports,$e=b,G,R,E=0,T=0;function Re(e,t,r){var n=t&&r||0,o=t||[];e=e||{};var l=e.node||G,i=e.clockseq!==void 0?e.clockseq:R;if(l==null||i==null){var a=xe();l==null&&(l=G=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),i==null&&(i=R=(a[6]<<8|a[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),d=e.nsecs!==void 0?e.nsecs:T+1,f=u-E+(d-T)/1e4;if(f<0&&e.clockseq===void 0&&(i=i+1&16383),(f<0||u>E)&&e.nsecs===void 0&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");E=u,T=d,R=i,u+=122192928e5;var h=((u&268435455)*1e4+d)%4294967296;o[n++]=h>>>24&255,o[n++]=h>>>16&255,o[n++]=h>>>8&255,o[n++]=h&255;var y=u/4294967296*1e4&268435455;o[n++]=y>>>8&255,o[n++]=y&255,o[n++]=y>>>24&15|16,o[n++]=y>>>16&255,o[n++]=i>>>8|128,o[n++]=i&255;for(var c=0;c<6;++c)o[n+c]=l[c];return t||$e(o)}var Ee=Re,Te=S.exports,Ie=b;function Pe(e,t,r){var n=t&&r||0;typeof e=="string"&&(t=e==="binary"?new Array(16):null,e=null),e=e||{};var o=e.random||(e.rng||Te)();if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,t)for(var l=0;l<16;++l)t[n+l]=o[l];return t||Ie(o)}var Ve=Pe,De=Ee,F=Ve,I=F;I.v1=De;I.v4=F;var Ne=I;const Oe=(e,t=()=>({}),r)=>{const n=s.ref([]),o=c=>{const p=n.value.findIndex(x=>x.id===c);p!==-1&&n.value.splice(p,1)},l=(c,p,x,X)=>{const{item:Y,useReturn:Z}=e({id:Ne.v4(),component:s.markRaw(c),props:p||{},listeners:x||{},options:X||null});return n.value.push(Y),Z},u=_(_({},{items:n,remove:o,push:l,pushDefault:(c=null,p)=>{if(!r)throw new Error("No default component passed to the item store, cannot show item.");return l(r,c,p)}}),t(n)),d=()=>u,f=Symbol("item");return{store:u,useStore:d,useItem:()=>s.inject(f),provideItem:c=>(s.provide(f,c),c)}};var H=(e,t)=>{for(const[r,n]of t)e[r]=n;return e};const qe=s.defineComponent({name:"ModalProvider",components:{},props:{modal:{type:Object,required:!0}},setup:e=>({item:Q(e.modal)})});function Ae(e,t,r,n,o,l){return s.renderSlot(e.$slots,"default",{modal:e.item})}var L=H(qe,[["render",Ae]]);const je="_modalContainer_ato2o_1",Be="_overlay_ato2o_13",Ue="_layer_ato2o_21",ze="_clickable_ato2o_26",be="_modal_ato2o_1";var Ge={modalContainer:je,overlay:Be,layer:Ue,clickable:ze,modal:be};const Fe=s.defineComponent({name:"ModalContainer",components:{ModalProvider:L},props:{showOverlay:{type:Boolean,default:!0}},setup:e=>{const t=K(),r=s.computed(()=>t.activeModal.value),n=l=>{var i;((i=l.options)==null?void 0:i.closeOnOverlayClick)&&l.close()};return{modals:s.computed(()=>t.items.value),activeModal:r,overlayClick:n}}}),He=["onClick"];function Le(e,t,r,n,o,l){const i=s.resolveComponent("ModalProvider");return s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("div",{class:s.normalizeClass(e.$style.modalContainer)},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(e.modals,a=>(s.openBlock(),s.createBlock(i,{key:a.id,modal:a},{default:s.withCtx(()=>{var u,d;return[s.withDirectives(s.createElementVNode("div",{class:s.normalizeClass([e.$style.overlay,{[e.$style.clickable]:(u=a.options)==null?void 0:u.closeOnOverlayClick}]),onClick:f=>e.overlayClick(a)},[s.renderSlot(e.$slots,"overlay",{},()=>[s.createElementVNode("div",{class:s.normalizeClass(e.$style.layer)},null,2)])],10,He),[[s.vShow,a.id===((d=e.activeModal)==null?void 0:d.id)]]),s.renderSlot(e.$slots,"default",{modal:a,activeModal:e.activeModal},()=>{var f;return[s.withDirectives((s.openBlock(),s.createBlock(s.resolveDynamicComponent(a.component),s.mergeProps({key:a.id,class:e.$style.modal},a.props,s.toHandlers(a.listeners)),null,16,["class"])),[[s.vShow,a.id===((f=e.activeModal)==null?void 0:f.id)]])]})]}),_:2},1032,["modal"]))),128))],2)])}const J={};J.$style=Ge;var Je=H(Fe,[["render",Le],["__cssModules",J]]);const{useStore:K,useItem:Ke,provideItem:Q,store:W}=Oe(e=>{let t;const r=new Promise(o=>{t=o}),n=D(_({},e),{close:o=>{t(o),W.remove(e.id)},options:_({closeOnOverlayClick:!0},e.options)});return{item:n,useReturn:{onClose:o=>(r.then(o),n)},options:n.options}},e=>({activeModal:Se(()=>e.value.length>0?e.value[e.value.length-1]:null)})),Qe=Je,We=L;exports.ModalContainer=Qe;exports.ModalProvider=We;exports.modalStore=W;exports.provideModal=Q;exports.useModal=Ke;exports.useModalStore=K; |
@@ -399,10 +399,5 @@ var __defProp = Object.defineProperty; | ||
const store = __spreadValues(__spreadValues({}, rawStore), extendStore(items)); | ||
const GenericStoreSymbol = Symbol("genericstore"); | ||
const provideStore = (app) => { | ||
app ? app.provide(GenericStoreSymbol, store) : provide(GenericStoreSymbol, store); | ||
const useStore = () => { | ||
return store; | ||
}; | ||
const useStore = () => { | ||
return inject(GenericStoreSymbol); | ||
}; | ||
const ItemSymbol = Symbol("item"); | ||
@@ -419,3 +414,2 @@ const provideItem = (item) => { | ||
useStore, | ||
provideStore, | ||
useItem, | ||
@@ -541,3 +535,2 @@ provideItem | ||
useStore: useModalStore, | ||
provideStore: provideModalStore, | ||
useItem: useModal, | ||
@@ -556,3 +549,5 @@ provideItem: provideModal, | ||
}, | ||
options: base.options | ||
options: __spreadValues({ | ||
closeOnOverlayClick: true | ||
}, base.options) | ||
}); | ||
@@ -578,2 +573,2 @@ return { | ||
const ModalProvider = ModalProviderComp; | ||
export { ModalContainer, ModalProvider, modalStore, provideModal, provideModalStore, useModal, useModalStore }; | ||
export { ModalContainer, ModalProvider, modalStore, provideModal, useModal, useModalStore }; |
{ | ||
"name": "vue-haystack", | ||
"version": "1.0.0-alpha.2", | ||
"version": "1.0.0-alpha.3", | ||
"description": "Lightweight, flexible system for modal dialogs, snackbars, toasts, ...", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40778
1021