@wishbone-media/spark 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +106 -0
- package/package.json +26 -0
- package/src/components/AppOverlay.vue +64 -0
- package/src/components/index.js +7 -0
- package/src/index.js +9 -0
- package/src/stores/index.js +4 -0
- package/src/stores/overlay.js +39 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { reactive as y, markRaw as m, ref as d, createBlock as f, openBlock as c, unref as a, withCtx as o, createVNode as n, createElementVNode as u, normalizeClass as x, resolveDynamicComponent as g, normalizeProps as O, guardReactiveProps as b } from "vue";
|
|
2
|
+
import { TransitionRoot as V, Dialog as C, TransitionChild as p, DialogPanel as h } from "@headlessui/vue";
|
|
3
|
+
import { defineStore as w } from "pinia";
|
|
4
|
+
const R = w("overlay", () => {
|
|
5
|
+
const e = y({
|
|
6
|
+
left: {
|
|
7
|
+
isVisible: !1,
|
|
8
|
+
content: null
|
|
9
|
+
},
|
|
10
|
+
right: {
|
|
11
|
+
isVisible: !1,
|
|
12
|
+
content: null
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
state: e,
|
|
17
|
+
toggleOverlay: (t) => {
|
|
18
|
+
e[t].isVisible = !e[t].isVisible;
|
|
19
|
+
},
|
|
20
|
+
closeOverlay: (t) => {
|
|
21
|
+
e[t].isVisible = !1;
|
|
22
|
+
},
|
|
23
|
+
openOverlay: (t) => {
|
|
24
|
+
e[t].isVisible = !0;
|
|
25
|
+
},
|
|
26
|
+
setOverlayContent: (t, v) => {
|
|
27
|
+
e[t].content = m(v);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}), k = { class: "fixed inset-0 flex" }, P = {
|
|
31
|
+
__name: "AppOverlay",
|
|
32
|
+
props: {
|
|
33
|
+
position: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: !0,
|
|
36
|
+
validator: (e) => ["left", "right"].includes(e)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setup(e) {
|
|
40
|
+
const i = R(), r = d(null);
|
|
41
|
+
return (s, l) => (c(), f(a(V), {
|
|
42
|
+
show: a(i).state[e.position].isVisible,
|
|
43
|
+
as: "template"
|
|
44
|
+
}, {
|
|
45
|
+
default: o(() => [
|
|
46
|
+
n(a(C), {
|
|
47
|
+
initialFocus: r.value,
|
|
48
|
+
class: "relative z-200",
|
|
49
|
+
onClose: l[0] || (l[0] = (t) => a(i).closeOverlay(e.position))
|
|
50
|
+
}, {
|
|
51
|
+
default: o(() => [
|
|
52
|
+
n(a(p), {
|
|
53
|
+
as: "template",
|
|
54
|
+
enter: "transition-opacity ease-linear duration-150",
|
|
55
|
+
"enter-from": "opacity-0",
|
|
56
|
+
"enter-to": "opacity-100",
|
|
57
|
+
leave: "transition-opacity ease-linear duration-150",
|
|
58
|
+
"leave-from": "opacity-100",
|
|
59
|
+
"leave-to": "opacity-0"
|
|
60
|
+
}, {
|
|
61
|
+
default: o(() => l[1] || (l[1] = [
|
|
62
|
+
u("div", { class: "fixed inset-0 bg-gray-600/30" }, null, -1)
|
|
63
|
+
])),
|
|
64
|
+
_: 1,
|
|
65
|
+
__: [1]
|
|
66
|
+
}),
|
|
67
|
+
u("div", k, [
|
|
68
|
+
n(a(p), {
|
|
69
|
+
as: "template",
|
|
70
|
+
enter: "transition ease-in-out duration-150 transform",
|
|
71
|
+
"enter-from": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0",
|
|
72
|
+
"enter-to": "translate-x-0 opacity-100",
|
|
73
|
+
leave: "transition ease-in-out duration-150 transform",
|
|
74
|
+
"leave-from": "translate-x-0 opacity-100",
|
|
75
|
+
"leave-to": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0"
|
|
76
|
+
}, {
|
|
77
|
+
default: o(() => [
|
|
78
|
+
n(a(h), {
|
|
79
|
+
ref_key: "panelRef",
|
|
80
|
+
ref: r,
|
|
81
|
+
class: x([
|
|
82
|
+
"flex w-[400px] py-2.5",
|
|
83
|
+
e.position === "left" ? "relative left-[10px]" : "absolute right-[10px] h-full"
|
|
84
|
+
])
|
|
85
|
+
}, {
|
|
86
|
+
default: o(() => [
|
|
87
|
+
(c(), f(g(a(i).state[e.position].content), O(b(s.$attrs)), null, 16))
|
|
88
|
+
]),
|
|
89
|
+
_: 1
|
|
90
|
+
}, 8, ["class"])
|
|
91
|
+
]),
|
|
92
|
+
_: 1
|
|
93
|
+
}, 8, ["enter-from", "leave-to"])
|
|
94
|
+
])
|
|
95
|
+
]),
|
|
96
|
+
_: 1
|
|
97
|
+
}, 8, ["initialFocus"])
|
|
98
|
+
]),
|
|
99
|
+
_: 1
|
|
100
|
+
}, 8, ["show"]));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
P as AppOverlay,
|
|
105
|
+
R as useOverlayStore
|
|
106
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wishbone-media/spark",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"files": ["dist", "src"],
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@headlessui/vue": "^1.7.0",
|
|
10
|
+
"pinia": "^3.0.0",
|
|
11
|
+
"vue": "^3.5.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
15
|
+
"vite": "^6.3.5",
|
|
16
|
+
"vue": "^3.5.13"
|
|
17
|
+
},
|
|
18
|
+
"packageManager": "pnpm@10.11.1",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "vite build"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./src/*": "./src/*"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<TransitionRoot :show="overlayStore.state[position].isVisible" as="template">
|
|
3
|
+
<Dialog
|
|
4
|
+
:initialFocus="panelRef"
|
|
5
|
+
class="relative z-200"
|
|
6
|
+
@close="overlayStore.closeOverlay(position)"
|
|
7
|
+
>
|
|
8
|
+
<TransitionChild
|
|
9
|
+
as="template"
|
|
10
|
+
enter="transition-opacity ease-linear duration-150"
|
|
11
|
+
enter-from="opacity-0"
|
|
12
|
+
enter-to="opacity-100"
|
|
13
|
+
leave="transition-opacity ease-linear duration-150"
|
|
14
|
+
leave-from="opacity-100"
|
|
15
|
+
leave-to="opacity-0"
|
|
16
|
+
>
|
|
17
|
+
<div class="fixed inset-0 bg-gray-600/30" />
|
|
18
|
+
</TransitionChild>
|
|
19
|
+
|
|
20
|
+
<div class="fixed inset-0 flex">
|
|
21
|
+
<TransitionChild
|
|
22
|
+
as="template"
|
|
23
|
+
enter="transition ease-in-out duration-150 transform"
|
|
24
|
+
:enter-from="
|
|
25
|
+
position === 'left' ? '-translate-x-full opacity-0' : 'translate-x-full opacity-0'
|
|
26
|
+
"
|
|
27
|
+
enter-to="translate-x-0 opacity-100"
|
|
28
|
+
leave="transition ease-in-out duration-150 transform"
|
|
29
|
+
leave-from="translate-x-0 opacity-100"
|
|
30
|
+
:leave-to="
|
|
31
|
+
position === 'left' ? '-translate-x-full opacity-0' : 'translate-x-full opacity-0'
|
|
32
|
+
"
|
|
33
|
+
>
|
|
34
|
+
<DialogPanel
|
|
35
|
+
ref="panelRef"
|
|
36
|
+
:class="[
|
|
37
|
+
'flex w-[400px] py-2.5',
|
|
38
|
+
position === 'left' ? 'relative left-[10px]' : 'absolute right-[10px] h-full',
|
|
39
|
+
]"
|
|
40
|
+
>
|
|
41
|
+
<component :is="overlayStore.state[position].content" v-bind="$attrs" />
|
|
42
|
+
</DialogPanel>
|
|
43
|
+
</TransitionChild>
|
|
44
|
+
</div>
|
|
45
|
+
</Dialog>
|
|
46
|
+
</TransitionRoot>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script setup>
|
|
50
|
+
import { ref } from 'vue'
|
|
51
|
+
import { Dialog, DialogPanel, TransitionChild, TransitionRoot } from '@headlessui/vue'
|
|
52
|
+
import { useOverlayStore } from '../stores/overlay'
|
|
53
|
+
|
|
54
|
+
const overlayStore = useOverlayStore()
|
|
55
|
+
const panelRef = ref(null)
|
|
56
|
+
|
|
57
|
+
defineProps({
|
|
58
|
+
position: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: true,
|
|
61
|
+
validator: (value) => ['left', 'right'].includes(value),
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
</script>
|
package/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Export all components
|
|
2
|
+
export * from './components/index.js'
|
|
3
|
+
|
|
4
|
+
// Export all stores
|
|
5
|
+
export * from './stores/index.js'
|
|
6
|
+
|
|
7
|
+
// Add any global utilities, composables, etc. here later
|
|
8
|
+
// export * from './composables/index.js'
|
|
9
|
+
// export * from './utilities/index.js'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { markRaw, reactive } from 'vue'
|
|
3
|
+
|
|
4
|
+
export const useOverlayStore = defineStore('overlay', () => {
|
|
5
|
+
const state = reactive({
|
|
6
|
+
left: {
|
|
7
|
+
isVisible: false,
|
|
8
|
+
content: null,
|
|
9
|
+
},
|
|
10
|
+
right: {
|
|
11
|
+
isVisible: false,
|
|
12
|
+
content: null,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const toggleOverlay = (position) => {
|
|
17
|
+
state[position].isVisible = !state[position].isVisible
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const closeOverlay = (position) => {
|
|
21
|
+
state[position].isVisible = false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const openOverlay = (position) => {
|
|
25
|
+
state[position].isVisible = true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const setOverlayContent = (position, content) => {
|
|
29
|
+
state[position].content = markRaw(content)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
state,
|
|
34
|
+
toggleOverlay,
|
|
35
|
+
closeOverlay,
|
|
36
|
+
openOverlay,
|
|
37
|
+
setOverlayContent,
|
|
38
|
+
}
|
|
39
|
+
})
|