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