@wishbone-media/spark 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,199 @@
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 = {
4
- __name: "AppOverlay",
1
+ import { computed as u, resolveComponent as $, createElementBlock as x, openBlock as d, normalizeClass as m, createElementVNode as s, createVNode as r, unref as a, renderSlot as f, createBlock as p, withCtx as n, createCommentVNode as g, ref as S, resolveDynamicComponent as z, normalizeProps as I, guardReactiveProps as V, reactive as T, markRaw as X } from "vue";
2
+ import { library as E } from "@fortawesome/fontawesome-svg-core";
3
+ import { faCheck as O, faXmark as R, faCircleXmark as B, faInfoCircle as D, faCheckCircle as N, faExclamationTriangle as j } from "@fortawesome/pro-regular-svg-icons";
4
+ import { TransitionRoot as h, Dialog as k, TransitionChild as y, DialogPanel as _, DialogTitle as q } from "@headlessui/vue";
5
+ const b = {
6
+ farExclamationTriangle: j,
7
+ farCheckCircle: N,
8
+ farInfoCircle: D,
9
+ farCircleXmark: B,
10
+ farXmark: R,
11
+ farCheck: O
12
+ };
13
+ function se() {
14
+ E.add(...Object.values(b));
15
+ }
16
+ const P = { class: "flex items-center" }, A = { class: "shrink-0 self-start" }, F = { class: "ml-3" }, M = { class: "ml-auto pl-3 pt-1 self-start" }, G = { class: "-mx-1.5 -my-1.5" }, ae = {
17
+ __name: "SparkAlert",
18
+ props: {
19
+ type: {
20
+ type: String,
21
+ default: "info",
22
+ validator: (e) => ["success", "warning", "danger", "info"].includes(e)
23
+ }
24
+ },
25
+ emits: ["close"],
26
+ setup(e) {
27
+ const o = e, c = u(() => ({
28
+ success: "bg-green-50 border-green-200 text-green-700",
29
+ warning: "bg-yellow-50 border-yellow-200 text-yellow-700",
30
+ danger: "bg-red-50 border-red-200 text-red-700",
31
+ info: "bg-blue-50 border-blue-200 text-blue-700"
32
+ })[o.type]), t = u(() => ({
33
+ success: "text-green-400",
34
+ warning: "text-yellow-400",
35
+ danger: "text-red-400",
36
+ info: "text-blue-400"
37
+ })[o.type]), i = u(() => ({
38
+ success: "farCheckCircle",
39
+ warning: "farExclamationTriangle",
40
+ danger: "farCircleXmark",
41
+ info: "farInfoCircle"
42
+ })[o.type]), v = u(() => ({
43
+ success: "text-green-400 hover:bg-green-100",
44
+ warning: "text-yellow-400 hover:bg-yellow-100",
45
+ danger: "text-red-400 hover:bg-red-100",
46
+ info: "text-blue-400 hover:bg-blue-100"
47
+ })[o.type]);
48
+ return (l, w) => {
49
+ const C = $("font-awesome-icon");
50
+ return d(), x("div", {
51
+ class: m(["rounded-md border p-4", c.value])
52
+ }, [
53
+ s("div", P, [
54
+ s("div", A, [
55
+ r(C, {
56
+ icon: a(b)[i.value],
57
+ class: m(t.value)
58
+ }, null, 8, ["icon", "class"])
59
+ ]),
60
+ s("div", F, [
61
+ f(l.$slots, "default")
62
+ ]),
63
+ s("div", M, [
64
+ s("div", G, [
65
+ s("button", {
66
+ type: "button",
67
+ class: m(["inline-flex rounded-md px-2 py-1.5", v.value]),
68
+ onClick: w[0] || (w[0] = (W) => l.$emit("close"))
69
+ }, [
70
+ r(C, {
71
+ icon: a(b).farXmark
72
+ }, null, 8, ["icon"])
73
+ ], 2)
74
+ ])
75
+ ])
76
+ ])
77
+ ], 2);
78
+ };
79
+ }
80
+ }, H = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, J = { class: "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0" }, K = { key: 0 }, L = { class: "text-center sm:mt-5" }, Q = {
81
+ key: 0,
82
+ class: "mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3"
83
+ }, oe = {
84
+ __name: "SparkModal",
85
+ props: {
86
+ open: {
87
+ type: Boolean,
88
+ required: !0
89
+ },
90
+ size: {
91
+ type: String,
92
+ default: "md",
93
+ validator: (e) => ["sm", "md", "lg", "xl", "2xl"].includes(e)
94
+ },
95
+ icon: {
96
+ type: String
97
+ },
98
+ iconColor: {
99
+ type: String
100
+ }
101
+ },
102
+ emits: ["close"],
103
+ setup(e) {
104
+ const o = e, c = u(() => ({
105
+ sm: "sm:max-w-sm",
106
+ md: "sm:max-w-lg",
107
+ lg: "sm:max-w-2xl",
108
+ xl: "sm:max-w-4xl",
109
+ "2xl": "sm:max-w-6xl"
110
+ })[o.size]);
111
+ return (t, i) => (d(), p(a(h), {
112
+ as: "template",
113
+ show: e.open
114
+ }, {
115
+ default: n(() => [
116
+ r(a(k), {
117
+ class: "relative z-50",
118
+ onClose: i[0] || (i[0] = (v) => t.$emit("close"))
119
+ }, {
120
+ default: n(() => [
121
+ r(a(y), {
122
+ as: "template",
123
+ enter: "ease-out duration-300",
124
+ "enter-from": "opacity-0",
125
+ "enter-to": "opacity-100",
126
+ leave: "ease-in duration-200",
127
+ "leave-from": "opacity-100",
128
+ "leave-to": "opacity-0"
129
+ }, {
130
+ default: n(() => i[1] || (i[1] = [
131
+ s("div", { class: "fixed inset-0 bg-gray-500/75 transition-opacity" }, null, -1)
132
+ ])),
133
+ _: 1,
134
+ __: [1]
135
+ }),
136
+ s("div", H, [
137
+ s("div", J, [
138
+ r(a(y), {
139
+ as: "template",
140
+ enter: "ease-out duration-300",
141
+ "enter-from": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
142
+ "enter-to": "opacity-100 translate-y-0 sm:scale-100",
143
+ leave: "ease-in duration-200",
144
+ "leave-from": "opacity-100 translate-y-0 sm:scale-100",
145
+ "leave-to": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
146
+ }, {
147
+ default: n(() => [
148
+ r(a(_), {
149
+ class: m([
150
+ "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",
151
+ c.value
152
+ ])
153
+ }, {
154
+ default: n(() => [
155
+ s("div", null, [
156
+ t.$slots.icon ? (d(), x("div", K, [
157
+ f(t.$slots, "icon")
158
+ ])) : g("", !0),
159
+ s("div", L, [
160
+ t.$slots.title ? (d(), p(a(q), {
161
+ key: 0,
162
+ as: "div",
163
+ class: "text-base font-semibold text-gray-900"
164
+ }, {
165
+ default: n(() => [
166
+ f(t.$slots, "title")
167
+ ]),
168
+ _: 3
169
+ })) : g("", !0),
170
+ s("div", {
171
+ class: m({ "mt-2": t.$slots.title })
172
+ }, [
173
+ f(t.$slots, "default")
174
+ ], 2)
175
+ ])
176
+ ]),
177
+ t.$slots.actions ? (d(), x("div", Q, [
178
+ f(t.$slots, "actions")
179
+ ])) : g("", !0)
180
+ ]),
181
+ _: 3
182
+ }, 8, ["class"])
183
+ ]),
184
+ _: 3
185
+ })
186
+ ])
187
+ ])
188
+ ]),
189
+ _: 3
190
+ })
191
+ ]),
192
+ _: 3
193
+ }, 8, ["show"]));
194
+ }
195
+ }, U = { class: "fixed inset-0 flex" }, le = {
196
+ __name: "SparkOverlay",
5
197
  props: {
6
198
  position: {
7
199
  type: String,
@@ -14,19 +206,19 @@ const C = { class: "fixed inset-0 flex" }, O = {
14
206
  }
15
207
  },
16
208
  setup(e) {
17
- const i = y(null);
18
- return (s, t) => (f(), c(a(h), {
209
+ const o = S(null);
210
+ return (c, t) => (d(), p(a(h), {
19
211
  show: e.overlayInstance.state.isVisible,
20
212
  as: "template"
21
213
  }, {
22
- default: o(() => [
23
- n(a(V), {
24
- initialFocus: i.value,
214
+ default: n(() => [
215
+ r(a(k), {
216
+ initialFocus: o.value,
25
217
  class: "relative z-200",
26
218
  onClose: e.overlayInstance.close
27
219
  }, {
28
- default: o(() => [
29
- n(a(p), {
220
+ default: n(() => [
221
+ r(a(y), {
30
222
  as: "template",
31
223
  enter: "transition-opacity ease-linear duration-150",
32
224
  "enter-from": "opacity-0",
@@ -35,14 +227,14 @@ const C = { class: "fixed inset-0 flex" }, O = {
35
227
  "leave-from": "opacity-100",
36
228
  "leave-to": "opacity-0"
37
229
  }, {
38
- default: o(() => t[0] || (t[0] = [
39
- u("div", { class: "fixed inset-0 bg-gray-600/30" }, null, -1)
230
+ default: n(() => t[0] || (t[0] = [
231
+ s("div", { class: "fixed inset-0 bg-gray-600/30" }, null, -1)
40
232
  ])),
41
233
  _: 1,
42
234
  __: [0]
43
235
  }),
44
- u("div", C, [
45
- n(a(p), {
236
+ s("div", U, [
237
+ r(a(y), {
46
238
  as: "template",
47
239
  enter: "transition ease-in-out duration-150 transform",
48
240
  "enter-from": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0",
@@ -51,17 +243,17 @@ const C = { class: "fixed inset-0 flex" }, O = {
51
243
  "leave-from": "translate-x-0 opacity-100",
52
244
  "leave-to": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0"
53
245
  }, {
54
- default: o(() => [
55
- n(a(w), {
246
+ default: n(() => [
247
+ r(a(_), {
56
248
  ref_key: "panelRef",
57
- ref: i,
58
- class: v([
249
+ ref: o,
250
+ class: m([
59
251
  "flex w-[400px] py-2.5",
60
252
  e.position === "left" ? "relative left-[10px]" : "absolute right-[10px] h-full"
61
253
  ])
62
254
  }, {
63
- default: o(() => [
64
- (f(), c(d(e.overlayInstance.state.content), m(x(s.$attrs)), null, 16))
255
+ default: n(() => [
256
+ (d(), p(z(e.overlayInstance.state.content), I(V(c.$attrs)), null, 16))
65
257
  ]),
66
258
  _: 1
67
259
  }, 8, ["class"])
@@ -77,31 +269,35 @@ const C = { class: "fixed inset-0 flex" }, O = {
77
269
  }, 8, ["show"]));
78
270
  }
79
271
  };
80
- function z() {
81
- const e = g({
272
+ function ne() {
273
+ const e = T({
82
274
  isVisible: !1,
83
275
  content: null
84
- }), i = () => {
276
+ }), o = () => {
85
277
  e.isVisible = !e.isVisible;
86
- }, s = () => {
278
+ }, c = () => {
87
279
  e.isVisible = !1;
88
280
  }, t = () => {
89
281
  e.isVisible = !0;
90
- }, r = (l) => {
91
- e.content = b(l);
282
+ }, i = (l) => {
283
+ e.content = X(l);
92
284
  };
93
285
  return {
94
286
  state: e,
95
- toggle: i,
96
- close: s,
287
+ toggle: o,
288
+ close: c,
97
289
  open: t,
98
- setContent: r,
290
+ setContent: i,
99
291
  show: (l) => {
100
- l && r(l), t();
292
+ l && i(l), t();
101
293
  }
102
294
  };
103
295
  }
104
296
  export {
105
- O as AppOverlay,
106
- z as useOverlay
297
+ b as Icons,
298
+ ae as SparkAlert,
299
+ oe as SparkModal,
300
+ le as SparkOverlay,
301
+ se as addSparkIcons,
302
+ ne as useSparkOverlay
107
303
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wishbone-media/spark",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -10,6 +10,8 @@
10
10
  ],
11
11
  "peerDependencies": {
12
12
  "@headlessui/vue": "^1.7.0",
13
+ "@fortawesome/fontawesome-svg-core": "^6.7.2",
14
+ "@fortawesome/pro-regular-svg-icons": "^6.7.2",
13
15
  "vue": "^3.5.0"
14
16
  },
15
17
  "devDependencies": {
@@ -0,0 +1,83 @@
1
+ <template>
2
+ <div :class="['rounded-md border p-4', containerClasses]">
3
+ <div class="flex items-center">
4
+ <div class="shrink-0 self-start">
5
+ <font-awesome-icon :icon="Icons[iconName]" :class="iconClasses" />
6
+ </div>
7
+ <div class="ml-3">
8
+ <slot />
9
+ </div>
10
+ <div class="ml-auto pl-3 pt-1 self-start">
11
+ <div class="-mx-1.5 -my-1.5">
12
+ <button
13
+ type="button"
14
+ class="inline-flex rounded-md px-2 py-1.5"
15
+ :class="closeClasses"
16
+ @click="$emit('close')"
17
+ >
18
+ <font-awesome-icon :icon="Icons.farXmark" />
19
+ </button>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <script setup>
27
+ import { computed } from 'vue'
28
+ import { Icons } from '@/plugins/fontawesome'
29
+
30
+ const props = defineProps({
31
+ type: {
32
+ type: String,
33
+ default: 'info',
34
+ validator: (value) => ['success', 'warning', 'danger', 'info'].includes(value),
35
+ },
36
+ })
37
+
38
+ defineEmits(['close'])
39
+
40
+ const containerClasses = computed(() => {
41
+ const types = {
42
+ success: 'bg-green-50 border-green-200 text-green-700',
43
+ warning: 'bg-yellow-50 border-yellow-200 text-yellow-700',
44
+ danger: 'bg-red-50 border-red-200 text-red-700',
45
+ info: 'bg-blue-50 border-blue-200 text-blue-700',
46
+ }
47
+
48
+ return types[props.type]
49
+ })
50
+
51
+ const iconClasses = computed(() => {
52
+ const iconClasses = {
53
+ success: 'text-green-400',
54
+ warning: 'text-yellow-400',
55
+ danger: 'text-red-400',
56
+ info: 'text-blue-400',
57
+ }
58
+
59
+ return iconClasses[props.type]
60
+ })
61
+
62
+ const iconName = computed(() => {
63
+ const icons = {
64
+ success: 'farCheckCircle',
65
+ warning: 'farExclamationTriangle',
66
+ danger: 'farCircleXmark',
67
+ info: 'farInfoCircle',
68
+ }
69
+
70
+ return icons[props.type]
71
+ })
72
+
73
+ const closeClasses = computed(() => {
74
+ const closeClasses = {
75
+ success: 'text-green-400 hover:bg-green-100',
76
+ warning: 'text-yellow-400 hover:bg-yellow-100',
77
+ danger: 'text-red-400 hover:bg-red-100',
78
+ info: 'text-blue-400 hover:bg-blue-100',
79
+ }
80
+
81
+ return closeClasses[props.type]
82
+ })
83
+ </script>
@@ -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>
@@ -1,7 +1,5 @@
1
- import AppOverlay from './AppOverlay.vue'
1
+ import SparkAlert from './SparkAlert.vue'
2
+ import SparkModal from './SparkModal.vue'
3
+ import SparkOverlay from './SparkOverlay.vue'
2
4
 
3
- export { AppOverlay }
4
-
5
- // import Modal from './Modal.vue'
6
- // import Dropdown from './Dropdown.vue'
7
- // export { AppOverlay, Modal, Dropdown }
5
+ export { SparkAlert, SparkModal, SparkOverlay }
@@ -1 +1 @@
1
- export { useOverlay } from './useOverlay.js'
1
+ export { useSparkOverlay } from './useSparkOverlay.js'
@@ -1,6 +1,6 @@
1
1
  import { markRaw, reactive } from 'vue'
2
2
 
3
- export function useOverlay() {
3
+ export function useSparkOverlay() {
4
4
  const state = reactive({
5
5
  isVisible: false,
6
6
  content: null,
package/src/index.js CHANGED
@@ -1,5 +1,3 @@
1
- // Export all components
2
1
  export * from './components/index.js'
3
-
4
- // Export all composables
5
2
  export * from './composables/index.js'
3
+ export * from './plugins/index.js'
@@ -0,0 +1,23 @@
1
+ import { library } from '@fortawesome/fontawesome-svg-core'
2
+
3
+ import {
4
+ faExclamationTriangle,
5
+ faCheckCircle,
6
+ faInfoCircle,
7
+ faCircleXmark,
8
+ faXmark,
9
+ faCheck,
10
+ } from '@fortawesome/pro-regular-svg-icons'
11
+
12
+ export const Icons = {
13
+ farExclamationTriangle: faExclamationTriangle,
14
+ farCheckCircle: faCheckCircle,
15
+ farInfoCircle: faInfoCircle,
16
+ farCircleXmark: faCircleXmark,
17
+ farXmark: faXmark,
18
+ farCheck: faCheck,
19
+ }
20
+
21
+ export function addSparkIcons() {
22
+ library.add(...Object.values(Icons))
23
+ }
@@ -0,0 +1 @@
1
+ export { Icons, addSparkIcons } from './fontawesome.js'