@wishbone-media/spark 0.1.3 → 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,9 +1,86 @@
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 = {
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 = {
4
81
  key: 0,
5
82
  class: "mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3"
6
- }, T = {
83
+ }, oe = {
7
84
  __name: "SparkModal",
8
85
  props: {
9
86
  open: {
@@ -24,24 +101,24 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
24
101
  },
25
102
  emits: ["close"],
26
103
  setup(e) {
27
- const n = e, c = b(() => ({
104
+ const o = e, c = u(() => ({
28
105
  sm: "sm:max-w-sm",
29
106
  md: "sm:max-w-lg",
30
107
  lg: "sm:max-w-2xl",
31
108
  xl: "sm:max-w-4xl",
32
109
  "2xl": "sm:max-w-6xl"
33
- })[n.size]);
34
- return (t, i) => (r(), u(s(x), {
110
+ })[o.size]);
111
+ return (t, i) => (d(), p(a(h), {
35
112
  as: "template",
36
113
  show: e.open
37
114
  }, {
38
- default: a(() => [
39
- o(s(g), {
115
+ default: n(() => [
116
+ r(a(k), {
40
117
  class: "relative z-50",
41
- onClose: i[0] || (i[0] = (h) => t.$emit("close"))
118
+ onClose: i[0] || (i[0] = (v) => t.$emit("close"))
42
119
  }, {
43
- default: a(() => [
44
- o(s(f), {
120
+ default: n(() => [
121
+ r(a(y), {
45
122
  as: "template",
46
123
  enter: "ease-out duration-300",
47
124
  "enter-from": "opacity-0",
@@ -50,15 +127,15 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
50
127
  "leave-from": "opacity-100",
51
128
  "leave-to": "opacity-0"
52
129
  }, {
53
- default: a(() => i[1] || (i[1] = [
54
- l("div", { class: "fixed inset-0 bg-gray-500/75 transition-opacity" }, null, -1)
130
+ default: n(() => i[1] || (i[1] = [
131
+ s("div", { class: "fixed inset-0 bg-gray-500/75 transition-opacity" }, null, -1)
55
132
  ])),
56
133
  _: 1,
57
134
  __: [1]
58
135
  }),
59
- l("div", R, [
60
- l("div", B, [
61
- o(s(f), {
136
+ s("div", H, [
137
+ s("div", J, [
138
+ r(a(y), {
62
139
  as: "template",
63
140
  enter: "ease-out duration-300",
64
141
  "enter-from": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
@@ -67,39 +144,39 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
67
144
  "leave-from": "opacity-100 translate-y-0 sm:scale-100",
68
145
  "leave-to": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
69
146
  }, {
70
- default: a(() => [
71
- o(s(w), {
72
- class: y([
147
+ default: n(() => [
148
+ r(a(_), {
149
+ class: m([
73
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",
74
151
  c.value
75
152
  ])
76
153
  }, {
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), {
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), {
84
161
  key: 0,
85
162
  as: "div",
86
163
  class: "text-base font-semibold text-gray-900"
87
164
  }, {
88
- default: a(() => [
89
- d(t.$slots, "title")
165
+ default: n(() => [
166
+ f(t.$slots, "title")
90
167
  ]),
91
168
  _: 3
92
- })) : p("", !0),
93
- l("div", {
94
- class: y({ "mt-2": t.$slots.title })
169
+ })) : g("", !0),
170
+ s("div", {
171
+ class: m({ "mt-2": t.$slots.title })
95
172
  }, [
96
- d(t.$slots, "default")
173
+ f(t.$slots, "default")
97
174
  ], 2)
98
175
  ])
99
176
  ]),
100
- t.$slots.actions ? (r(), v("div", O, [
101
- d(t.$slots, "actions")
102
- ])) : p("", !0)
177
+ t.$slots.actions ? (d(), x("div", Q, [
178
+ f(t.$slots, "actions")
179
+ ])) : g("", !0)
103
180
  ]),
104
181
  _: 3
105
182
  }, 8, ["class"])
@@ -115,7 +192,7 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
115
192
  _: 3
116
193
  }, 8, ["show"]));
117
194
  }
118
- }, q = { class: "fixed inset-0 flex" }, j = {
195
+ }, U = { class: "fixed inset-0 flex" }, le = {
119
196
  __name: "SparkOverlay",
120
197
  props: {
121
198
  position: {
@@ -129,19 +206,19 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
129
206
  }
130
207
  },
131
208
  setup(e) {
132
- const n = k(null);
133
- return (c, t) => (r(), u(s(x), {
209
+ const o = S(null);
210
+ return (c, t) => (d(), p(a(h), {
134
211
  show: e.overlayInstance.state.isVisible,
135
212
  as: "template"
136
213
  }, {
137
- default: a(() => [
138
- o(s(g), {
139
- initialFocus: n.value,
214
+ default: n(() => [
215
+ r(a(k), {
216
+ initialFocus: o.value,
140
217
  class: "relative z-200",
141
218
  onClose: e.overlayInstance.close
142
219
  }, {
143
- default: a(() => [
144
- o(s(f), {
220
+ default: n(() => [
221
+ r(a(y), {
145
222
  as: "template",
146
223
  enter: "transition-opacity ease-linear duration-150",
147
224
  "enter-from": "opacity-0",
@@ -150,14 +227,14 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
150
227
  "leave-from": "opacity-100",
151
228
  "leave-to": "opacity-0"
152
229
  }, {
153
- default: a(() => t[0] || (t[0] = [
154
- l("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)
155
232
  ])),
156
233
  _: 1,
157
234
  __: [0]
158
235
  }),
159
- l("div", q, [
160
- o(s(f), {
236
+ s("div", U, [
237
+ r(a(y), {
161
238
  as: "template",
162
239
  enter: "transition ease-in-out duration-150 transform",
163
240
  "enter-from": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0",
@@ -166,17 +243,17 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
166
243
  "leave-from": "translate-x-0 opacity-100",
167
244
  "leave-to": e.position === "left" ? "-translate-x-full opacity-0" : "translate-x-full opacity-0"
168
245
  }, {
169
- default: a(() => [
170
- o(s(w), {
246
+ default: n(() => [
247
+ r(a(_), {
171
248
  ref_key: "panelRef",
172
- ref: n,
173
- class: y([
249
+ ref: o,
250
+ class: m([
174
251
  "flex w-[400px] py-2.5",
175
252
  e.position === "left" ? "relative left-[10px]" : "absolute right-[10px] h-full"
176
253
  ])
177
254
  }, {
178
- default: a(() => [
179
- (r(), u($(e.overlayInstance.state.content), _(C(c.$attrs)), null, 16))
255
+ default: n(() => [
256
+ (d(), p(z(e.overlayInstance.state.content), I(V(c.$attrs)), null, 16))
180
257
  ]),
181
258
  _: 1
182
259
  }, 8, ["class"])
@@ -192,32 +269,35 @@ const R = { class: "fixed inset-0 z-10 w-screen overflow-y-auto" }, B = { class:
192
269
  }, 8, ["show"]));
193
270
  }
194
271
  };
195
- function E() {
196
- const e = z({
272
+ function ne() {
273
+ const e = T({
197
274
  isVisible: !1,
198
275
  content: null
199
- }), n = () => {
276
+ }), o = () => {
200
277
  e.isVisible = !e.isVisible;
201
278
  }, c = () => {
202
279
  e.isVisible = !1;
203
280
  }, t = () => {
204
281
  e.isVisible = !0;
205
- }, i = (m) => {
206
- e.content = S(m);
282
+ }, i = (l) => {
283
+ e.content = X(l);
207
284
  };
208
285
  return {
209
286
  state: e,
210
- toggle: n,
287
+ toggle: o,
211
288
  close: c,
212
289
  open: t,
213
290
  setContent: i,
214
- show: (m) => {
215
- m && i(m), t();
291
+ show: (l) => {
292
+ l && i(l), t();
216
293
  }
217
294
  };
218
295
  }
219
296
  export {
220
- T as SparkModal,
221
- j as SparkOverlay,
222
- E as useSparkOverlay
297
+ b as Icons,
298
+ ae as SparkAlert,
299
+ oe as SparkModal,
300
+ le as SparkOverlay,
301
+ se as addSparkIcons,
302
+ ne as useSparkOverlay
223
303
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wishbone-media/spark",
3
- "version": "0.1.3",
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>
@@ -1,4 +1,5 @@
1
+ import SparkAlert from './SparkAlert.vue'
1
2
  import SparkModal from './SparkModal.vue'
2
3
  import SparkOverlay from './SparkOverlay.vue'
3
4
 
4
- export { SparkModal, SparkOverlay }
5
+ export { SparkAlert, SparkModal, SparkOverlay }
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'