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

vue-haystack

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-haystack - npm Package Compare versions

Comparing version 1.0.0-beta.4 to 1.0.0-rc.1

10

dist/src/genericStore.d.ts

@@ -16,3 +16,3 @@ import { ComponentPropsOptions, Ref } from "vue";

}
export declare const createItemStoreInstance: <CBase extends ComponentBaseType, I extends ItemBase<O>, Res extends {
export declare const createItemStoreInstance: <I extends ItemBase<O>, Res extends {
[key: string]: unknown;

@@ -26,3 +26,3 @@ }, O extends {

useReturn: Res;
}, extendStore?: (items: Ref<I[]>) => Extend, defaultComponent?: CBase | undefined) => {
}, extendStore?: (items: Ref<I[]>) => Extend) => {
store: {

@@ -34,5 +34,2 @@ items: Ref<I[]>;

} | undefined, options?: I["options"] | undefined) => Res;
pushDefault: (props?: InstanceType<CBase>["$props"] | null, listeners?: {
[key: string]: (...params: any[]) => unknown;
} | undefined, options?: I["options"] | undefined) => Res;
} & Extend;

@@ -45,5 +42,2 @@ useStore: () => {

} | undefined, options?: I["options"] | undefined) => Res;
pushDefault: (props?: InstanceType<CBase>["$props"] | null, listeners?: {
[key: string]: (...params: any[]) => unknown;
} | undefined, options?: I["options"] | undefined) => Res;
} & Extend;

@@ -50,0 +44,0 @@ useItem: () => I;

1

dist/src/index.d.ts

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

export * from "./genericStore";
export * from "./modal";
export * from "./snackbar";

@@ -32,3 +32,3 @@ import { useModal } from "./store";

overlayClick: (modal: ReturnType<typeof useModal>) => void;
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
export default _default;

@@ -20,35 +20,21 @@ import { PropType } from "vue";

};
}, {
item: {
close: <T>(data?: T | undefined) => void;
options: {
closeOnOverlayClick: boolean;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
};
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
modal?: unknown;
} & {
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
modal: {
close: <T>(data?: T | undefined) => void;
options: {
closeOnOverlayClick: boolean;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
type: PropType<{
close: <T>(data?: T | undefined) => void;
options: {
closeOnOverlayClick: boolean;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
}>;
required: true;
};
} & {}>, {}>;
}>>, {}>;
export default _default;

@@ -37,22 +37,2 @@ export declare const useModalStore: () => {

};
pushDefault: (props?: any, listeners?: {
[key: string]: (...params: any[]) => unknown;
} | undefined, options?: {
closeOnOverlayClick: boolean;
} | undefined) => {
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => {
close: <T>(data?: T | undefined) => void;
options: {
closeOnOverlayClick: boolean;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
};
};
} & {

@@ -148,22 +128,2 @@ activeModal: import("vue").ComputedRef<{

};
pushDefault: (props?: any, listeners?: {
[key: string]: (...params: any[]) => unknown;
} | undefined, options?: {
closeOnOverlayClick: boolean;
} | undefined) => {
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => {
close: <T>(data?: T | undefined) => void;
options: {
closeOnOverlayClick: boolean;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
};
};
} & {

@@ -170,0 +130,0 @@ activeModal: import("vue").ComputedRef<{

@@ -28,3 +28,3 @@ declare const _default: import("vue").DefineComponent<{}, {

}[]>;
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
export default _default;

@@ -32,59 +32,33 @@ import { PropType } from "vue";

};
}, {
item: {
close: <T>(data?: T | undefined) => void;
timer: {
clear: () => void;
pause: () => void;
resume: () => void;
remainingTime: {
value: number;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
snack: {
type: PropType<{
close: <T>(data?: T | undefined) => void;
timer: {
clear: () => void;
pause: () => void;
resume: () => void;
remainingTime: {
value: number;
};
progress: {
value: number;
};
duration: number;
};
progress: {
value: number;
options: {
time?: number | undefined;
};
duration: number;
};
options: {
time?: number | undefined;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
};
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
snack?: unknown;
} & {
snack: {
close: <T>(data?: T | undefined) => void;
timer: {
clear: () => void;
pause: () => void;
resume: () => void;
remainingTime: {
value: number;
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
progress: {
value: number;
};
duration: number;
};
options: {
time?: number | undefined;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
}>;
required: true;
};
} & {}>, {}>;
}>>, {}>;
export default _default;
export declare const snackTimer: (callback: () => void, duration?: number, updateInterval?: number) => {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -17,11 +23,17 @@ };

timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -50,11 +62,17 @@ };

timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -75,46 +93,22 @@ };

};
pushDefault: (props?: any, listeners?: {
[key: string]: (...params: any[]) => unknown;
} | undefined, options?: {
time?: number | undefined;
} | undefined) => {
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => {
close: <T>(data?: T | undefined) => void;
timer: {
clear: () => void;
pause: () => void;
resume: () => void;
remainingTime: {
value: number;
};
progress: {
value: number;
};
duration: number;
};
options: {
time?: number | undefined;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
};
};
} & {
log: () => void;
}, useSnack: () => {
close: <T>(data?: T | undefined) => void;
timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -136,11 +130,17 @@ };

timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -162,11 +162,17 @@ };

timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -189,11 +195,17 @@ };

timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -222,11 +234,17 @@ };

timer: {
/** stop/reset the timer */
clear: () => void;
/** pause the timer */
pause: () => void;
/** resume the timer */
resume: () => void;
/** remaining lifetime */
remainingTime: {
value: number;
};
/** lifetime progress value counting from 1 to 0 */
progress: {
value: number;
};
/** total duration */
duration: number;

@@ -247,34 +265,4 @@ };

};
pushDefault: (props?: any, listeners?: {
[key: string]: (...params: any[]) => unknown;
} | undefined, options?: {
time?: number | undefined;
} | undefined) => {
onClose: <T_2>(callback: (data?: T_2 | undefined) => void) => {
close: <T>(data?: T | undefined) => void;
timer: {
clear: () => void;
pause: () => void;
resume: () => void;
remainingTime: {
value: number;
};
progress: {
value: number;
};
duration: number;
};
options: {
time?: number | undefined;
};
id: string;
component: any;
props: import("vue").ComponentPropsOptions<{
[x: string]: unknown;
}> | null;
listeners: {
[key: string]: (...params: any[]) => unknown;
};
};
};
} & {
log: () => void;
};

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

"use strict";var X=Object.defineProperty,Y=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var P=(e,r,n)=>r in e?X(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,f=(e,r)=>{for(var n in r||(r={}))b.call(r,n)&&P(e,n,r[n]);if(T)for(var n of T(r))ee.call(r,n)&&P(e,n,r[n]);return e},S=(e,r)=>Y(e,Z(r));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var o=require("vue"),y={exports:{}},x=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(x){var I=new Uint8Array(16);y.exports=function(){return x(I),I}}else{var B=new Array(16);y.exports=function(){for(var r=0,n;r<16;r++)(r&3)==0&&(n=Math.random()*4294967296),B[r]=n>>>((r&3)<<3)&255;return B}}var R=[];for(var $=0;$<256;++$)R[$]=($+256).toString(16).substr(1);function oe(e,r){var n=r||0,t=R;return[t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]]].join("")}var D=oe,re=y.exports,te=D,E,M,w=0,h=0;function ne(e,r,n){var t=r&&n||0,s=r||[];e=e||{};var l=e.node||E,c=e.clockseq!==void 0?e.clockseq:M;if(l==null||c==null){var a=re();l==null&&(l=E=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),c==null&&(c=M=(a[6]<<8|a[7])&16383)}var i=e.msecs!==void 0?e.msecs:new Date().getTime(),v=e.nsecs!==void 0?e.nsecs:h+1,u=i-w+(v-h)/1e4;if(u<0&&e.clockseq===void 0&&(c=c+1&16383),(u<0||i>w)&&e.nsecs===void 0&&(v=0),v>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");w=i,h=v,M=c,i+=122192928e5;var m=((i&268435455)*1e4+v)%4294967296;s[t++]=m>>>24&255,s[t++]=m>>>16&255,s[t++]=m>>>8&255,s[t++]=m&255;var p=i/4294967296*1e4&268435455;s[t++]=p>>>8&255,s[t++]=p&255,s[t++]=p>>>24&15|16,s[t++]=p>>>16&255,s[t++]=c>>>8|128,s[t++]=c&255;for(var d=0;d<6;++d)s[t+d]=l[d];return r||te(s)}var se=ne,ae=y.exports,le=D;function ce(e,r,n){var t=r&&n||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var s=e.random||(e.rng||ae)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,r)for(var l=0;l<16;++l)r[t+l]=s[l];return r||le(s)}var ie=ce,ve=se,O=ie,g=O;g.v1=ve;g.v4=O;var de=g;const q=(e,r=()=>({}),n)=>{const t=o.ref([]),s=d=>{const k=t.value.findIndex(_=>_.id===d);k!==-1&&t.value.splice(k,1)},l=(d,k,_,K)=>{const{item:Q,useReturn:W}=e({id:de.v4(),component:o.markRaw(d),props:k||{},listeners:_||{},options:K||null});return t.value.push(Q),W},i=f(f({},{items:t,remove:s,push:l,pushDefault:(d=null,k,_)=>{if(!n)throw new Error("No default component passed to the item store, cannot show item.");return l(n,d,k,_)}}),r(t)),v=()=>i,u=Symbol("item");return{store:i,useStore:v,useItem:()=>o.inject(u),provideItem:d=>(o.provide(u,d),d)}},ue=q(e=>{let r;const n=new Promise(s=>{r=s}),t=S(f({},e),{close:s=>{N.remove(e.id),r(s)},options:f({closeOnOverlayClick:!0},e.options)});return{item:t,useReturn:{onClose:s=>(n.then(s),t)},options:t.options}},e=>({activeModal:o.computed(()=>e.value.slice(-1)[0]||null)})),{useStore:V,useItem:me,provideItem:A,store:N}=ue;var C=(e,r)=>{for(const[n,t]of r)e[n]=t;return e};const pe=o.defineComponent({name:"ModalProvider",components:{},props:{modal:{type:Object,required:!0}},setup:e=>({item:A(e.modal)})});function fe(e,r,n,t,s,l){return o.openBlock(),o.createElementBlock("div",null,[o.renderSlot(e.$slots,"default",{modal:e.item})])}var F=C(pe,[["render",fe]]);const ke="_modalContainer_ato2o_1",_e="_overlay_ato2o_13",ye="_layer_ato2o_21",$e="_clickable_ato2o_26",Ce="_modal_ato2o_1";var Se={modalContainer:ke,overlay:_e,layer:ye,clickable:$e,modal:Ce};const Me=o.defineComponent({name:"ModalContainer",components:{ModalProvider:F},setup:e=>{const r=V(),n=o.computed(()=>r.activeModal.value),t=l=>{var c;((c=l.options)==null?void 0:c.closeOnOverlayClick)&&l.close()};return{modals:o.computed(()=>r.items.value),activeModal:n,overlayClick:t}}}),we=["onClick"];function he(e,r,n,t,s,l){const c=o.resolveComponent("ModalProvider");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(e.$style.modalContainer)},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(e.modals,a=>(o.openBlock(),o.createBlock(c,{key:a.id,modal:a},{default:o.withCtx(()=>{var i,v;return[o.withDirectives(o.createElementVNode("div",{class:o.normalizeClass([e.$style.overlay,{[e.$style.clickable]:(i=a.options)==null?void 0:i.closeOnOverlayClick}]),onClick:u=>e.overlayClick(a)},[o.renderSlot(e.$slots,"overlay",{},()=>[o.createElementVNode("div",{class:o.normalizeClass(e.$style.layer)},null,2)])],10,we),[[o.vShow,a.id===((v=e.activeModal)==null?void 0:v.id)]]),o.renderSlot(e.$slots,"default",{modal:a,activeModal:e.activeModal},()=>{var u;return[o.withDirectives((o.openBlock(),o.createBlock(o.resolveDynamicComponent(a.component),o.mergeProps({key:a.id,class:e.$style.modal},a.props,o.toHandlers(a.listeners)),null,16,["class"])),[[o.vShow,a.id===((u=e.activeModal)==null?void 0:u.id)]])]})]}),_:2},1032,["modal"]))),128))],2)}const j={};j.$style=Se;var ge=C(Me,[["render",he],["__cssModules",j]]);const Te=o.defineComponent({name:"ModalProvider",components:{},props:{snack:{type:Object,required:!0}},setup:e=>({item:H(e.snack)})});function Pe(e,r,n,t,s,l){return o.openBlock(),o.createElementBlock("div",null,[o.renderSlot(e.$slots,"default",{snack:e.item})])}var z=C(Te,[["render",Pe]]);const U=(e,r=0,n=100)=>{let t=new Date().getTime(),s=r;const l=o.reactive({value:r}),c=o.reactive({value:1});let a=null,i=null;const v=()=>{a&&(clearTimeout(a),a=null),i&&(clearInterval(i),i=null)},u=()=>{v(),s=s-(new Date().getTime()-t)},m=()=>{r<=0||(a||(a=setTimeout(e,s)),t=new Date().getTime(),i||(i=setInterval(()=>{const p=s-(new Date().getTime()-t);l.value=p,c.value=p/r},n)))};return m(),{clear:v,pause:u,resume:m,remainingTime:l,progress:c,duration:r}},xe=q(e=>{let r;const n=new Promise(l=>{r=l}),t=f({time:0},e.options),s=S(f({},e),{close:l=>{L.remove(e.id),r(l),s.timer.clear()},timer:U(()=>{s.close()},t.time),options:t});return{item:s,useReturn:{onClose:l=>(n.then(l),s)},options:s.options}},e=>({})),{useStore:G,useItem:Ie,provideItem:H,store:L}=xe,Be="_snackContainer_1io5o_1",Re="_snackProvider_1io5o_13",De="_snack_1io5o_1",Ee="_leaveActive_1io5o_20",Oe="_enterFrom_1io5o_24",qe="_leaveTo_1io5o_29";var Ve={snackContainer:Be,snackProvider:Re,snack:De,leaveActive:Ee,enterFrom:Oe,leaveTo:qe};const Ae=o.defineComponent({name:"SnackContainer",components:{SnackProvider:z},setup:e=>{const r=G();return{snacks:o.computed(()=>r.items.value)}}});function Ne(e,r,n,t,s,l){const c=o.resolveComponent("SnackProvider");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(e.$style.snackContainer)},[o.createVNode(o.TransitionGroup,{"leave-active-class":e.$style.leaveActive,"enter-from-class":e.$style.enterFrom,"leave-to-class":e.$style.leaveTo,appear:""},{default:o.withCtx(()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(e.snacks,a=>(o.openBlock(),o.createBlock(c,{key:a.id,class:o.normalizeClass(e.$style.snackProvider),snack:a},{default:o.withCtx(()=>[o.renderSlot(e.$slots,"default",{snack:a},()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(a.component),o.mergeProps({key:a.id,class:e.$style.snack},a.props,o.toHandlers(a.listeners)),null,16,["class"]))])]),_:2},1032,["class","snack"]))),128))]),_:3},8,["leave-active-class","enter-from-class","leave-to-class"])],2)}const J={};J.$style=Ve;var Fe=C(Ae,[["render",Ne],["__cssModules",J]]);exports.ModalContainer=ge;exports.ModalProvider=F;exports.SnackContainer=Fe;exports.SnackProvider=z;exports.modalStore=N;exports.provideModal=A;exports.provideSnack=H;exports.snackTimer=U;exports.snackbarStore=L;exports.useModal=me;exports.useModalStore=V;exports.useSnack=Ie;exports.useSnackbar=G;
"use strict";var F=Object.defineProperty,j=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var M=(e,t,n)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))A.call(t,n)&&M(e,n,t[n]);if(g)for(var n of g(t))q.call(t,n)&&M(e,n,t[n]);return e},$=(e,t)=>j(e,z(t));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var o=require("vue"),f,H=new Uint8Array(16);function L(){if(!f&&(f=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!f))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return f(H)}var N=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function U(e){return typeof e=="string"&&N.test(e)}var l=[];for(var C=0;C<256;++C)l.push((C+256).toString(16).substr(1));function G(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase();if(!U(n))throw TypeError("Stringified UUID is invalid");return n}function X(e,t,n){e=e||{};var a=e.random||(e.rng||L)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=a[r];return t}return G(a)}const S=(e,t=()=>({}))=>{const n=o.ref([]),i=v(v({},{items:n,remove:d=>{const m=n.value.findIndex(_=>_.id===d);m!==-1&&n.value.splice(m,1)},push:(d,m,_,O)=>{const{item:D,useReturn:V}=e({id:X(),component:o.markRaw(d),props:m||{},listeners:_||{},options:O||null});return n.value.push(D),V}}),t(n)),s=()=>i,u=Symbol("item");return{store:i,useStore:s,useItem:()=>o.inject(u),provideItem:d=>(o.provide(u,d),d)}},J=S(e=>{let t;const n=new Promise(r=>{t=r}),a=$(v({},e),{close:r=>{P.remove(e.id),t(r)},options:v({closeOnOverlayClick:!0},e.options)});return{item:a,useReturn:{onClose:r=>(n.then(r),a)},options:a.options}},e=>({activeModal:o.computed(()=>e.value.slice(-1)[0]||null)})),{useStore:h,useItem:K,provideItem:w,store:P}=J;var y=(e,t)=>{const n=e.__vccOpts||e;for(const[a,r]of t)n[a]=r;return n};const Q=o.defineComponent({name:"ModalProvider",components:{},props:{modal:{type:Object,required:!0}},setup:e=>(w(e.modal),{})});function W(e,t,n,a,r,c){return o.openBlock(),o.createElementBlock("div",null,[o.renderSlot(e.$slots,"default",{modal:e.modal})])}var B=y(Q,[["render",W]]);const Y="_modalContainer_ato2o_1",Z="_overlay_ato2o_13",x="_layer_ato2o_21",ee="_clickable_ato2o_26",oe="_modal_ato2o_1";var te={modalContainer:Y,overlay:Z,layer:x,clickable:ee,modal:oe};const ne=o.defineComponent({name:"ModalContainer",components:{ModalProvider:B},setup:e=>{const t=h(),n=o.computed(()=>t.activeModal.value),a=c=>{var i;((i=c.options)==null?void 0:i.closeOnOverlayClick)&&c.close()};return{modals:o.computed(()=>t.items.value),activeModal:n,overlayClick:a}}}),re=["onClick"];function se(e,t,n,a,r,c){const i=o.resolveComponent("ModalProvider");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(e.$style.modalContainer)},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(e.modals,s=>(o.openBlock(),o.createBlock(i,{key:s.id,modal:s},{default:o.withCtx(()=>{var u,p;return[o.withDirectives(o.createElementVNode("div",{class:o.normalizeClass([e.$style.overlay,{[e.$style.clickable]:(u=s.options)==null?void 0:u.closeOnOverlayClick}]),onClick:k=>e.overlayClick(s)},[o.renderSlot(e.$slots,"overlay",{},()=>[o.createElementVNode("div",{class:o.normalizeClass(e.$style.layer)},null,2)])],10,re),[[o.vShow,s.id===((p=e.activeModal)==null?void 0:p.id)]]),o.renderSlot(e.$slots,"default",{modal:s,activeModal:e.activeModal},()=>{var k;return[o.withDirectives((o.openBlock(),o.createBlock(o.resolveDynamicComponent(s.component),o.mergeProps({key:s.id,class:e.$style.modal},s.props,o.toHandlers(s.listeners)),null,16,["class"])),[[o.vShow,s.id===((k=e.activeModal)==null?void 0:k.id)]])]})]}),_:2},1032,["modal"]))),128))],2)}const ae={$style:te};var le=y(ne,[["render",se],["__cssModules",ae]]);const I=(e,t=0,n=100)=>{let a=new Date().getTime(),r=t;const c=o.reactive({value:t}),i=o.reactive({value:1});let s=null,u=null;const p=()=>{s&&(clearTimeout(s),s=null),u&&(clearInterval(u),u=null)},k=()=>{p(),r=r-(new Date().getTime()-a)},d=()=>{t<=0||(s||(s=setTimeout(e,r)),a=new Date().getTime(),u||(u=setInterval(()=>{const m=r-(new Date().getTime()-a);c.value=m,i.value=m/t},n)))};return d(),{clear:p,pause:k,resume:d,remainingTime:c,progress:i,duration:t}},ce=S(e=>{let t;const n=new Promise(c=>{t=c}),a=v({time:0},e.options),r=$(v({},e),{close:c=>{R.remove(e.id),t(c),r.timer.clear()},timer:I(()=>{r.close()},a.time),options:a});return{item:r,useReturn:{onClose:c=>(n.then(c),r)},options:r.options}},e=>({log:()=>{console.log(e)}})),{useStore:T,useItem:ie,provideItem:b,store:R}=ce,ue=o.defineComponent({name:"SnackProvider",components:{},props:{snack:{type:Object,required:!0}},setup:e=>(b(e.snack),{})});function de(e,t,n,a,r,c){return o.openBlock(),o.createElementBlock("div",null,[o.renderSlot(e.$slots,"default",{snack:e.snack})])}var E=y(ue,[["render",de]]);const me="_snackContainer_1io5o_1",ve="_snackProvider_1io5o_13",pe="_snack_1io5o_1",ke="_leaveActive_1io5o_20",fe="_enterFrom_1io5o_24",ye="_leaveTo_1io5o_29";var _e={snackContainer:me,snackProvider:ve,snack:pe,leaveActive:ke,enterFrom:fe,leaveTo:ye};const $e=o.defineComponent({name:"SnackContainer",components:{SnackProvider:E},setup:e=>{const t=T();return{snacks:o.computed(()=>t.items.value)}}});function Ce(e,t,n,a,r,c){const i=o.resolveComponent("SnackProvider");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(e.$style.snackContainer)},[o.createVNode(o.TransitionGroup,{"leave-active-class":e.$style.leaveActive,"enter-from-class":e.$style.enterFrom,"leave-to-class":e.$style.leaveTo,appear:""},{default:o.withCtx(()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(e.snacks,s=>(o.openBlock(),o.createBlock(i,{key:s.id,class:o.normalizeClass(e.$style.snackProvider),snack:s},{default:o.withCtx(()=>[o.renderSlot(e.$slots,"default",{snack:s},()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(s.component),o.mergeProps({key:s.id,class:e.$style.snack},s.props,o.toHandlers(s.listeners)),null,16,["class"]))])]),_:2},1032,["class","snack"]))),128))]),_:3},8,["leave-active-class","enter-from-class","leave-to-class"])],2)}const Se={$style:_e};var ge=y($e,[["render",Ce],["__cssModules",Se]]);exports.ModalContainer=le;exports.ModalProvider=B;exports.SnackContainer=ge;exports.SnackProvider=E;exports.createItemStoreInstance=S;exports.modalStore=P;exports.provideModal=w;exports.provideSnack=b;exports.snackTimer=I;exports.snackbarStore=R;exports.useModal=K;exports.useModalStore=h;exports.useSnack=ie;exports.useSnackbar=T;

@@ -21,122 +21,30 @@ var __defProp = Object.defineProperty;

import { ref, provide, inject, markRaw, computed, defineComponent, openBlock, createElementBlock, renderSlot, resolveComponent, normalizeClass, Fragment, renderList, createBlock, withCtx, withDirectives, createElementVNode, vShow, resolveDynamicComponent, mergeProps, toHandlers, reactive, createVNode, TransitionGroup } from "vue";
var rngBrowser = { exports: {} };
var getRandomValues = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != "undefined" && typeof window.msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto);
if (getRandomValues) {
var rnds8 = new Uint8Array(16);
rngBrowser.exports = function whatwgRNG() {
getRandomValues(rnds8);
return rnds8;
};
} else {
var rnds = new Array(16);
rngBrowser.exports = function mathRNG() {
for (var i = 0, r; i < 16; i++) {
if ((i & 3) === 0)
r = Math.random() * 4294967296;
rnds[i] = r >>> ((i & 3) << 3) & 255;
var getRandomValues;
var rnds8 = new Uint8Array(16);
function rng() {
if (!getRandomValues) {
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
if (!getRandomValues) {
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
}
return rnds;
};
}
return getRandomValues(rnds8);
}
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
function validate(uuid) {
return typeof uuid === "string" && REGEX.test(uuid);
}
var byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex[i] = (i + 256).toString(16).substr(1);
byteToHex.push((i + 256).toString(16).substr(1));
}
function bytesToUuid$2(buf, offset) {
var i = offset || 0;
var bth = byteToHex;
return [
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
"-",
bth[buf[i++]],
bth[buf[i++]],
"-",
bth[buf[i++]],
bth[buf[i++]],
"-",
bth[buf[i++]],
bth[buf[i++]],
"-",
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]]
].join("");
}
var bytesToUuid_1 = bytesToUuid$2;
var rng$1 = rngBrowser.exports;
var bytesToUuid$1 = bytesToUuid_1;
var _nodeId;
var _clockseq;
var _lastMSecs = 0;
var _lastNSecs = 0;
function v1$1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || [];
options = options || {};
var node = options.node || _nodeId;
var clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq;
if (node == null || clockseq == null) {
var seedBytes = rng$1();
if (node == null) {
node = _nodeId = [
seedBytes[0] | 1,
seedBytes[1],
seedBytes[2],
seedBytes[3],
seedBytes[4],
seedBytes[5]
];
}
if (clockseq == null) {
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
}
function stringify(arr) {
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
if (!validate(uuid)) {
throw TypeError("Stringified UUID is invalid");
}
var msecs = options.msecs !== void 0 ? options.msecs : new Date().getTime();
var nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1;
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
if (dt < 0 && options.clockseq === void 0) {
clockseq = clockseq + 1 & 16383;
}
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) {
nsecs = 0;
}
if (nsecs >= 1e4) {
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
}
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq;
msecs += 122192928e5;
var tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
b[i++] = tl >>> 24 & 255;
b[i++] = tl >>> 16 & 255;
b[i++] = tl >>> 8 & 255;
b[i++] = tl & 255;
var tmh = msecs / 4294967296 * 1e4 & 268435455;
b[i++] = tmh >>> 8 & 255;
b[i++] = tmh & 255;
b[i++] = tmh >>> 24 & 15 | 16;
b[i++] = tmh >>> 16 & 255;
b[i++] = clockseq >>> 8 | 128;
b[i++] = clockseq & 255;
for (var n = 0; n < 6; ++n) {
b[i + n] = node[n];
}
return buf ? buf : bytesToUuid$1(b);
return uuid;
}
var v1_1 = v1$1;
var rng = rngBrowser.exports;
var bytesToUuid = bytesToUuid_1;
function v4$1(options, buf, offset) {
var i = buf && offset || 0;
if (typeof options == "string") {
buf = options === "binary" ? new Array(16) : null;
options = null;
}
function v4(options, buf, offset) {
options = options || {};

@@ -147,16 +55,11 @@ var rnds = options.random || (options.rng || rng)();

if (buf) {
for (var ii = 0; ii < 16; ++ii) {
buf[i + ii] = rnds[ii];
offset = offset || 0;
for (var i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return buf || bytesToUuid(rnds);
return stringify(rnds);
}
var v4_1 = v4$1;
var v1 = v1_1;
var v4 = v4_1;
var uuid = v4;
uuid.v1 = v1;
uuid.v4 = v4;
var uuid_1 = uuid;
const createItemStoreInstance = (createItem, extendStore = () => ({}), defaultComponent) => {
const createItemStoreInstance = (createItem, extendStore = () => ({})) => {
const items = ref([]);

@@ -172,3 +75,3 @@ const remove = (itemId) => {

const { item, useReturn } = createItem({
id: uuid_1.v4(),
id: v4(),
component: markRaw(component),

@@ -182,13 +85,6 @@ props: props || {},

};
const pushDefault = (props = null, listeners, options) => {
if (!defaultComponent) {
throw new Error("No default component passed to the item store, cannot show item.");
}
return push(defaultComponent, props, listeners, options);
};
const rawStore = {
items,
remove,
push,
pushDefault
push
};

@@ -247,6 +143,7 @@ const store2 = __spreadValues(__spreadValues({}, rawStore), extendStore(items));

var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
sfc[key] = val;
target[key] = val;
}
return sfc;
return target;
};

@@ -263,4 +160,4 @@ const _sfc_main$3 = defineComponent({

setup: (props) => {
const item = provideModal(props.modal);
return { item };
provideModal(props.modal);
return {};
}

@@ -270,3 +167,3 @@ });

return openBlock(), createElementBlock("div", null, [
renderSlot(_ctx.$slots, "default", { modal: _ctx.item })
renderSlot(_ctx.$slots, "default", { modal: _ctx.modal })
]);

@@ -354,25 +251,6 @@ }

}
const cssModules$1 = {};
cssModules$1["$style"] = style0$1;
const cssModules$1 = {
"$style": style0$1
};
var ModalContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__cssModules", cssModules$1]]);
const _sfc_main$1 = defineComponent({
name: "ModalProvider",
components: {},
props: {
snack: {
type: Object,
required: true
}
},
setup: (props) => {
const item = provideSnack(props.snack);
return { item };
}
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, [
renderSlot(_ctx.$slots, "default", { snack: _ctx.item })
]);
}
var SnackProvider = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
const snackTimer = (callback, duration = 0, updateInterval = 100) => {

@@ -455,5 +333,29 @@ let startTime = new Date().getTime();

}, (_items) => {
return {};
return {
log: () => {
console.log(_items);
}
};
});
const { useStore: useSnackbar, useItem: useSnack, provideItem: provideSnack, store: snackbarStore } = store;
const _sfc_main$1 = defineComponent({
name: "SnackProvider",
components: {},
props: {
snack: {
type: Object,
required: true
}
},
setup: (props) => {
provideSnack(props.snack);
return {};
}
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, [
renderSlot(_ctx.$slots, "default", { snack: _ctx.snack })
]);
}
var SnackProvider = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
const snackContainer = "_snackContainer_1io5o_1";

@@ -518,5 +420,6 @@ const snackProvider = "_snackProvider_1io5o_13";

}
const cssModules = {};
cssModules["$style"] = style0;
const cssModules = {
"$style": style0
};
var SnackContainer = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__cssModules", cssModules]]);
export { ModalContainer, ModalProvider, SnackContainer, SnackProvider, modalStore, provideModal, provideSnack, snackTimer, snackbarStore, useModal, useModalStore, useSnack, useSnackbar };
export { ModalContainer, ModalProvider, SnackContainer, SnackProvider, createItemStoreInstance, modalStore, provideModal, provideSnack, snackTimer, snackbarStore, useModal, useModalStore, useSnack, useSnackbar };
{
"name": "vue-haystack",
"version": "1.0.0-beta.4",
"version": "1.0.0-rc.1",
"description": "Lightweight, flexible system for modal dialogs, snackbars, toasts, ...",
"homepage": "https://jshmrtn.github.io/vue-haystack/",
"repository": {

@@ -51,27 +52,27 @@ "type": "git",

"devDependencies": {
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"@vitejs/plugin-vue": "^1.9.4",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^9.1.0",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"@vitejs/plugin-vue": "^2.2.0",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vuedx/typescript-plugin-vue": "^0.7.4",
"@vuepress/bundler-vite": "^2.0.0-beta.27",
"@vuepress/plugin-search": "^1.8.2",
"eslint": "^8.3.0",
"@vuepress/bundler-vite": "^2.0.0-beta.35",
"@vuepress/plugin-search": "^2.0.0-beta.35",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.1.1",
"prettier": "^2.5.0",
"ts-node": "^10.4.0",
"eslint-plugin-vue": "^8.4.1",
"prettier": "^2.5.1",
"ts-node": "^10.5.0",
"tslib": "^2.3.1",
"typescript": "^4.4.4",
"vite": "^2.6.14",
"vite-plugin-dts": "^0.9.6",
"vue": "^3.2.21",
"vuepress": "^2.0.0-beta.27"
"typescript": "^4.5.5",
"vite": "^2.8.0",
"vite-plugin-dts": "^0.9.9",
"vue": "^3.2.30",
"vuepress": "^2.0.0-beta.35"
},
"dependencies": {
"uuid": "^3.4.0"
"uuid": "^8.3.2"
}
}

@@ -5,2 +5,14 @@ # vue-haystack

## [Docs](https://jshmrtn.github.io/vue-haystack/)
[Documentation and Demos](https://jshmrtn.github.io/vue-haystack/)
## Installation
```sh
npm i vue-haystack
```
Import the styles (e.g. in your `App.vue`):
```ts
import "vue-haystack/style.css";
```
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