@wishbone-media/spark 0.1.2 → 0.1.3
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 +150 -34
- package/package.json +1 -1
- package/src/components/SparkModal.vue +109 -0
- package/src/components/index.js +3 -6
- package/src/composables/index.js +1 -1
- package/src/composables/{useOverlay.js → useSparkOverlay.js} +1 -1
- /package/src/components/{AppOverlay.vue → SparkOverlay.vue} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,122 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TransitionRoot as
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import { computed as b, createBlock as u, openBlock as r, unref as s, withCtx as a, createVNode as o, createElementVNode as l, normalizeClass as y, createElementBlock as v, createCommentVNode as p, renderSlot as d, ref as k, resolveDynamicComponent as $, normalizeProps as _, guardReactiveProps as C, reactive as z, markRaw as S } from "vue";
|
|
2
|
+
import { TransitionRoot as x, Dialog as g, TransitionChild as f, DialogPanel as w, DialogTitle as V } from "@headlessui/vue";
|
|
3
|
+
const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class: "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0" }, D = { key: 0 }, I = { class: "text-center sm:mt-5" }, O = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3"
|
|
6
|
+
}, T = {
|
|
7
|
+
__name: "SparkModal",
|
|
8
|
+
props: {
|
|
9
|
+
open: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
required: !0
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "md",
|
|
16
|
+
validator: (e) => ["sm", "md", "lg", "xl", "2xl"].includes(e)
|
|
17
|
+
},
|
|
18
|
+
icon: {
|
|
19
|
+
type: String
|
|
20
|
+
},
|
|
21
|
+
iconColor: {
|
|
22
|
+
type: String
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
emits: ["close"],
|
|
26
|
+
setup(e) {
|
|
27
|
+
const n = e, c = b(() => ({
|
|
28
|
+
sm: "sm:max-w-sm",
|
|
29
|
+
md: "sm:max-w-lg",
|
|
30
|
+
lg: "sm:max-w-2xl",
|
|
31
|
+
xl: "sm:max-w-4xl",
|
|
32
|
+
"2xl": "sm:max-w-6xl"
|
|
33
|
+
})[n.size]);
|
|
34
|
+
return (t, i) => (r(), u(s(x), {
|
|
35
|
+
as: "template",
|
|
36
|
+
show: e.open
|
|
37
|
+
}, {
|
|
38
|
+
default: a(() => [
|
|
39
|
+
o(s(g), {
|
|
40
|
+
class: "relative z-50",
|
|
41
|
+
onClose: i[0] || (i[0] = (h) => t.$emit("close"))
|
|
42
|
+
}, {
|
|
43
|
+
default: a(() => [
|
|
44
|
+
o(s(f), {
|
|
45
|
+
as: "template",
|
|
46
|
+
enter: "ease-out duration-300",
|
|
47
|
+
"enter-from": "opacity-0",
|
|
48
|
+
"enter-to": "opacity-100",
|
|
49
|
+
leave: "ease-in duration-200",
|
|
50
|
+
"leave-from": "opacity-100",
|
|
51
|
+
"leave-to": "opacity-0"
|
|
52
|
+
}, {
|
|
53
|
+
default: a(() => i[1] || (i[1] = [
|
|
54
|
+
l("div", { class: "fixed inset-0 bg-gray-500/75 transition-opacity" }, null, -1)
|
|
55
|
+
])),
|
|
56
|
+
_: 1,
|
|
57
|
+
__: [1]
|
|
58
|
+
}),
|
|
59
|
+
l("div", R, [
|
|
60
|
+
l("div", B, [
|
|
61
|
+
o(s(f), {
|
|
62
|
+
as: "template",
|
|
63
|
+
enter: "ease-out duration-300",
|
|
64
|
+
"enter-from": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
|
65
|
+
"enter-to": "opacity-100 translate-y-0 sm:scale-100",
|
|
66
|
+
leave: "ease-in duration-200",
|
|
67
|
+
"leave-from": "opacity-100 translate-y-0 sm:scale-100",
|
|
68
|
+
"leave-to": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
69
|
+
}, {
|
|
70
|
+
default: a(() => [
|
|
71
|
+
o(s(w), {
|
|
72
|
+
class: y([
|
|
73
|
+
"relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:p-6",
|
|
74
|
+
c.value
|
|
75
|
+
])
|
|
76
|
+
}, {
|
|
77
|
+
default: a(() => [
|
|
78
|
+
l("div", null, [
|
|
79
|
+
t.$slots.icon ? (r(), v("div", D, [
|
|
80
|
+
d(t.$slots, "icon")
|
|
81
|
+
])) : p("", !0),
|
|
82
|
+
l("div", I, [
|
|
83
|
+
t.$slots.title ? (r(), u(s(V), {
|
|
84
|
+
key: 0,
|
|
85
|
+
as: "div",
|
|
86
|
+
class: "text-base font-semibold text-gray-900"
|
|
87
|
+
}, {
|
|
88
|
+
default: a(() => [
|
|
89
|
+
d(t.$slots, "title")
|
|
90
|
+
]),
|
|
91
|
+
_: 3
|
|
92
|
+
})) : p("", !0),
|
|
93
|
+
l("div", {
|
|
94
|
+
class: y({ "mt-2": t.$slots.title })
|
|
95
|
+
}, [
|
|
96
|
+
d(t.$slots, "default")
|
|
97
|
+
], 2)
|
|
98
|
+
])
|
|
99
|
+
]),
|
|
100
|
+
t.$slots.actions ? (r(), v("div", O, [
|
|
101
|
+
d(t.$slots, "actions")
|
|
102
|
+
])) : p("", !0)
|
|
103
|
+
]),
|
|
104
|
+
_: 3
|
|
105
|
+
}, 8, ["class"])
|
|
106
|
+
]),
|
|
107
|
+
_: 3
|
|
108
|
+
})
|
|
109
|
+
])
|
|
110
|
+
])
|
|
111
|
+
]),
|
|
112
|
+
_: 3
|
|
113
|
+
})
|
|
114
|
+
]),
|
|
115
|
+
_: 3
|
|
116
|
+
}, 8, ["show"]));
|
|
117
|
+
}
|
|
118
|
+
}, q = { class: "fixed inset-0 flex" }, j = {
|
|
119
|
+
__name: "SparkOverlay",
|
|
5
120
|
props: {
|
|
6
121
|
position: {
|
|
7
122
|
type: String,
|
|
@@ -14,19 +129,19 @@ const C = { class: "fixed inset-0 flex" }, O = {
|
|
|
14
129
|
}
|
|
15
130
|
},
|
|
16
131
|
setup(e) {
|
|
17
|
-
const
|
|
18
|
-
return (
|
|
132
|
+
const n = k(null);
|
|
133
|
+
return (c, t) => (r(), u(s(x), {
|
|
19
134
|
show: e.overlayInstance.state.isVisible,
|
|
20
135
|
as: "template"
|
|
21
136
|
}, {
|
|
22
|
-
default:
|
|
23
|
-
|
|
24
|
-
initialFocus:
|
|
137
|
+
default: a(() => [
|
|
138
|
+
o(s(g), {
|
|
139
|
+
initialFocus: n.value,
|
|
25
140
|
class: "relative z-200",
|
|
26
141
|
onClose: e.overlayInstance.close
|
|
27
142
|
}, {
|
|
28
|
-
default:
|
|
29
|
-
|
|
143
|
+
default: a(() => [
|
|
144
|
+
o(s(f), {
|
|
30
145
|
as: "template",
|
|
31
146
|
enter: "transition-opacity ease-linear duration-150",
|
|
32
147
|
"enter-from": "opacity-0",
|
|
@@ -35,14 +150,14 @@ const C = { class: "fixed inset-0 flex" }, O = {
|
|
|
35
150
|
"leave-from": "opacity-100",
|
|
36
151
|
"leave-to": "opacity-0"
|
|
37
152
|
}, {
|
|
38
|
-
default:
|
|
39
|
-
|
|
153
|
+
default: a(() => t[0] || (t[0] = [
|
|
154
|
+
l("div", { class: "fixed inset-0 bg-gray-600/30" }, null, -1)
|
|
40
155
|
])),
|
|
41
156
|
_: 1,
|
|
42
157
|
__: [0]
|
|
43
158
|
}),
|
|
44
|
-
|
|
45
|
-
|
|
159
|
+
l("div", q, [
|
|
160
|
+
o(s(f), {
|
|
46
161
|
as: "template",
|
|
47
162
|
enter: "transition ease-in-out duration-150 transform",
|
|
48
163
|
"enter-from": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0",
|
|
@@ -51,17 +166,17 @@ const C = { class: "fixed inset-0 flex" }, O = {
|
|
|
51
166
|
"leave-from": "translate-x-0 opacity-100",
|
|
52
167
|
"leave-to": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0"
|
|
53
168
|
}, {
|
|
54
|
-
default:
|
|
55
|
-
|
|
169
|
+
default: a(() => [
|
|
170
|
+
o(s(w), {
|
|
56
171
|
ref_key: "panelRef",
|
|
57
|
-
ref:
|
|
58
|
-
class:
|
|
172
|
+
ref: n,
|
|
173
|
+
class: y([
|
|
59
174
|
"flex w-[400px] py-2.5",
|
|
60
175
|
e.position === "left" ? "relative left-[10px]" : "absolute right-[10px] h-full"
|
|
61
176
|
])
|
|
62
177
|
}, {
|
|
63
|
-
default:
|
|
64
|
-
(
|
|
178
|
+
default: a(() => [
|
|
179
|
+
(r(), u($(e.overlayInstance.state.content), _(C(c.$attrs)), null, 16))
|
|
65
180
|
]),
|
|
66
181
|
_: 1
|
|
67
182
|
}, 8, ["class"])
|
|
@@ -77,31 +192,32 @@ const C = { class: "fixed inset-0 flex" }, O = {
|
|
|
77
192
|
}, 8, ["show"]));
|
|
78
193
|
}
|
|
79
194
|
};
|
|
80
|
-
function
|
|
81
|
-
const e =
|
|
195
|
+
function E() {
|
|
196
|
+
const e = z({
|
|
82
197
|
isVisible: !1,
|
|
83
198
|
content: null
|
|
84
|
-
}),
|
|
199
|
+
}), n = () => {
|
|
85
200
|
e.isVisible = !e.isVisible;
|
|
86
|
-
},
|
|
201
|
+
}, c = () => {
|
|
87
202
|
e.isVisible = !1;
|
|
88
203
|
}, t = () => {
|
|
89
204
|
e.isVisible = !0;
|
|
90
|
-
},
|
|
91
|
-
e.content =
|
|
205
|
+
}, i = (m) => {
|
|
206
|
+
e.content = S(m);
|
|
92
207
|
};
|
|
93
208
|
return {
|
|
94
209
|
state: e,
|
|
95
|
-
toggle:
|
|
96
|
-
close:
|
|
210
|
+
toggle: n,
|
|
211
|
+
close: c,
|
|
97
212
|
open: t,
|
|
98
|
-
setContent:
|
|
99
|
-
show: (
|
|
100
|
-
|
|
213
|
+
setContent: i,
|
|
214
|
+
show: (m) => {
|
|
215
|
+
m && i(m), t();
|
|
101
216
|
}
|
|
102
217
|
};
|
|
103
218
|
}
|
|
104
219
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
220
|
+
T as SparkModal,
|
|
221
|
+
j as SparkOverlay,
|
|
222
|
+
E as useSparkOverlay
|
|
107
223
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<TransitionRoot as="template" :show="open">
|
|
3
|
+
<Dialog class="relative z-50" @close="$emit('close')">
|
|
4
|
+
<TransitionChild
|
|
5
|
+
as="template"
|
|
6
|
+
enter="ease-out duration-300"
|
|
7
|
+
enter-from="opacity-0"
|
|
8
|
+
enter-to="opacity-100"
|
|
9
|
+
leave="ease-in duration-200"
|
|
10
|
+
leave-from="opacity-100"
|
|
11
|
+
leave-to="opacity-0"
|
|
12
|
+
>
|
|
13
|
+
<div class="fixed inset-0 bg-gray-500/75 transition-opacity" />
|
|
14
|
+
</TransitionChild>
|
|
15
|
+
|
|
16
|
+
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
|
17
|
+
<div
|
|
18
|
+
class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"
|
|
19
|
+
>
|
|
20
|
+
<TransitionChild
|
|
21
|
+
as="template"
|
|
22
|
+
enter="ease-out duration-300"
|
|
23
|
+
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
24
|
+
enter-to="opacity-100 translate-y-0 sm:scale-100"
|
|
25
|
+
leave="ease-in duration-200"
|
|
26
|
+
leave-from="opacity-100 translate-y-0 sm:scale-100"
|
|
27
|
+
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
28
|
+
>
|
|
29
|
+
<DialogPanel
|
|
30
|
+
:class="[
|
|
31
|
+
'relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:p-6',
|
|
32
|
+
sizeClasses,
|
|
33
|
+
]"
|
|
34
|
+
>
|
|
35
|
+
<div>
|
|
36
|
+
<!-- Icon -->
|
|
37
|
+
<div v-if="$slots.icon">
|
|
38
|
+
<slot name="icon" />
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="text-center sm:mt-5">
|
|
42
|
+
<!-- Header with title -->
|
|
43
|
+
<template v-if="$slots.title">
|
|
44
|
+
<DialogTitle as="div" class="text-base font-semibold text-gray-900">
|
|
45
|
+
<slot name="title" />
|
|
46
|
+
</DialogTitle>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<!-- Main content -->
|
|
50
|
+
<div :class="{ 'mt-2': $slots.title }">
|
|
51
|
+
<slot />
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Actions/Buttons -->
|
|
57
|
+
<div
|
|
58
|
+
v-if="$slots.actions"
|
|
59
|
+
class="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3"
|
|
60
|
+
>
|
|
61
|
+
<slot name="actions" />
|
|
62
|
+
</div>
|
|
63
|
+
</DialogPanel>
|
|
64
|
+
</TransitionChild>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</Dialog>
|
|
68
|
+
</TransitionRoot>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup>
|
|
72
|
+
import { computed } from 'vue'
|
|
73
|
+
import { Dialog, DialogPanel, DialogTitle, TransitionChild, TransitionRoot } from '@headlessui/vue'
|
|
74
|
+
|
|
75
|
+
const props = defineProps({
|
|
76
|
+
open: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
required: true,
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
size: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: 'md',
|
|
84
|
+
validator: (value) => ['sm', 'md', 'lg', 'xl', '2xl'].includes(value),
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
icon: {
|
|
88
|
+
type: String,
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
iconColor: {
|
|
92
|
+
type: String,
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
defineEmits(['close'])
|
|
97
|
+
|
|
98
|
+
const sizeClasses = computed(() => {
|
|
99
|
+
const sizes = {
|
|
100
|
+
sm: 'sm:max-w-sm',
|
|
101
|
+
md: 'sm:max-w-lg',
|
|
102
|
+
lg: 'sm:max-w-2xl',
|
|
103
|
+
xl: 'sm:max-w-4xl',
|
|
104
|
+
'2xl': 'sm:max-w-6xl',
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return sizes[props.size]
|
|
108
|
+
})
|
|
109
|
+
</script>
|
package/src/components/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SparkModal from './SparkModal.vue'
|
|
2
|
+
import SparkOverlay from './SparkOverlay.vue'
|
|
2
3
|
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
// import Modal from './Modal.vue'
|
|
6
|
-
// import Dropdown from './Dropdown.vue'
|
|
7
|
-
// export { AppOverlay, Modal, Dropdown }
|
|
4
|
+
export { SparkModal, SparkOverlay }
|
package/src/composables/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useSparkOverlay } from './useSparkOverlay.js'
|
|
File without changes
|