vlite3 0.3.8 → 0.4.2
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/components/Button.vue.js +32 -26
- package/components/ConfirmationModal.vue.js +30 -24
- package/components/Form/composables/useForm.js +107 -93
- package/components/Form/types.d.ts +2 -0
- package/components/Form/utils/form.utils.d.ts +1 -0
- package/components/Form/utils/form.utils.js +17 -15
- package/components/Screen/Screen.vue.js +23 -23
- package/package.json +1 -1
- package/style.css +1 -1
- package/types/button.d.ts +2 -2
package/components/Button.vue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as B, useSlots as I, computed as r, inject as R, withDirectives as S, openBlock as s, createElementBlock as g, normalizeClass as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as B, useSlots as I, computed as r, inject as R, withDirectives as S, openBlock as s, createElementBlock as g, normalizeClass as i, createBlock as d, createCommentVNode as h, renderSlot as m, createTextVNode as f, toDisplayString as b, unref as G } from "vue";
|
|
2
|
+
import u from "./Icon.vue.js";
|
|
3
3
|
import { vRipple as j } from "../directives/vRipple.js";
|
|
4
4
|
const V = ["type", "disabled"], E = /* @__PURE__ */ B({
|
|
5
5
|
__name: "Button",
|
|
@@ -20,8 +20,8 @@ const V = ["type", "disabled"], E = /* @__PURE__ */ B({
|
|
|
20
20
|
asIcon: { type: Boolean }
|
|
21
21
|
},
|
|
22
22
|
setup(e) {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const n = e, x = I(), l = r(() => n?.asIcon || n.icon && !n.text && !x.default), v = R("buttonGroup", null), w = r(() => !!v?.isInGroup), p = r(() => {
|
|
24
|
+
const t = "inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 active:scale-[0.98] cursor-pointer gap-2", o = {
|
|
25
25
|
primary: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
26
26
|
"primary-light": "bg-primary-light text-primary-fg-light hover:bg-primary/20",
|
|
27
27
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
@@ -41,27 +41,31 @@ const V = ["type", "disabled"], E = /* @__PURE__ */ B({
|
|
|
41
41
|
"outline-success": "border border-success text-success hover:bg-success/10",
|
|
42
42
|
ghost: "hover:bg-accent hover:text-accent-foreground text-foreground",
|
|
43
43
|
link: "text-primary underline-offset-4 hover:underline"
|
|
44
|
-
},
|
|
44
|
+
}, y = {
|
|
45
45
|
xs: "h-6.5 px-2",
|
|
46
46
|
sm: "h-7.5 px-3",
|
|
47
|
+
sm2: "h-8 px-3",
|
|
47
48
|
md: "h-9 px-4 py-2",
|
|
48
49
|
lg: "h-10 px-6",
|
|
49
50
|
xl: "h-12 px-10"
|
|
50
51
|
}, z = {
|
|
51
52
|
xs: "h-6.5 w-6.5 min-h-6.5 min-w-6.5",
|
|
52
53
|
sm: "h-7 w-7 min-h-7 min-w-7",
|
|
54
|
+
sm2: "h-7 w-7 min-h-7 min-w-7",
|
|
53
55
|
md: "h-7.5 w-7.5 min-h-7.5 min-w-7.5",
|
|
54
56
|
lg: "h-8 w-8 min-h-8 min-w-8",
|
|
55
57
|
xl: "h-8.5 w-8.5 min-h-8.5 min-w-8.5"
|
|
56
58
|
}, C = {
|
|
57
59
|
xs: "px-2",
|
|
58
60
|
sm: "px-3",
|
|
61
|
+
sm2: "px-3",
|
|
59
62
|
md: "px-4",
|
|
60
63
|
lg: "px-6",
|
|
61
64
|
xl: "px-10"
|
|
62
65
|
}, k = {
|
|
63
66
|
none: "rounded-none",
|
|
64
67
|
sm: "rounded-sm",
|
|
68
|
+
sm2: "rounded-sm",
|
|
65
69
|
md: "rounded",
|
|
66
70
|
lg: "rounded-lg",
|
|
67
71
|
xl: "rounded-xl",
|
|
@@ -69,57 +73,59 @@ const V = ["type", "disabled"], E = /* @__PURE__ */ B({
|
|
|
69
73
|
full: "rounded-full"
|
|
70
74
|
};
|
|
71
75
|
let c;
|
|
72
|
-
return l.value ? c = w.value ? C[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
k[
|
|
76
|
+
return l.value ? c = w.value ? C[n.size] : z[n.size] : c = y[n.size], [
|
|
77
|
+
t,
|
|
78
|
+
o[n.variant],
|
|
79
|
+
k[n.rounded],
|
|
76
80
|
c,
|
|
77
|
-
|
|
81
|
+
n.class
|
|
78
82
|
].join(" ");
|
|
79
83
|
}), a = r(() => {
|
|
80
|
-
const
|
|
84
|
+
const t = {
|
|
81
85
|
xs: "w-3 h-3",
|
|
82
86
|
sm: "w-4 h-4",
|
|
87
|
+
sm2: "w-4 h-4",
|
|
83
88
|
md: "w-4 h-4",
|
|
84
89
|
lg: "w-4 h-4",
|
|
85
90
|
xl: "w-4 h-4"
|
|
86
|
-
},
|
|
91
|
+
}, o = {
|
|
87
92
|
xs: "w-3 h-3",
|
|
88
93
|
sm: "w-3.5 h-3.5",
|
|
94
|
+
sm2: "w-3.5 h-3.5",
|
|
89
95
|
md: "w-3.5 h-3.5",
|
|
90
96
|
lg: "w-4 h-4",
|
|
91
97
|
xl: "w-4 h-4"
|
|
92
98
|
};
|
|
93
|
-
return l.value ?
|
|
99
|
+
return l.value ? o[n.size] : t[n.size];
|
|
94
100
|
});
|
|
95
|
-
return (
|
|
101
|
+
return (t, o) => S((s(), g("button", {
|
|
96
102
|
type: e.type,
|
|
97
|
-
class:
|
|
103
|
+
class: i(p.value),
|
|
98
104
|
disabled: e.disabled || e.loading
|
|
99
105
|
}, [
|
|
100
|
-
e.loading ? (s(), u
|
|
106
|
+
e.loading ? (s(), d(u, {
|
|
101
107
|
key: 0,
|
|
102
108
|
icon: "lucide:loader-2",
|
|
103
|
-
class:
|
|
104
|
-
}, null, 8, ["class"])) : e.icon ? (s(), u
|
|
109
|
+
class: i(["animate-spin pointer-events-none", a.value])
|
|
110
|
+
}, null, 8, ["class"])) : e.icon ? (s(), d(u, {
|
|
105
111
|
key: 1,
|
|
106
112
|
icon: e.icon,
|
|
107
|
-
class:
|
|
113
|
+
class: i(["pointer-events-none", [e.iconClass, a.value, l.value ? "mx-auto" : ""]])
|
|
108
114
|
}, null, 8, ["icon", "class"])) : h("", !0),
|
|
109
115
|
e.textClass ? (s(), g("span", {
|
|
110
116
|
key: 2,
|
|
111
|
-
class:
|
|
117
|
+
class: i(e.textClass)
|
|
112
118
|
}, [
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
m(t.$slots, "default", {}, () => [
|
|
120
|
+
f(b(e.text), 1)
|
|
115
121
|
])
|
|
116
|
-
], 2)) :
|
|
117
|
-
|
|
122
|
+
], 2)) : m(t.$slots, "default", { key: 3 }, () => [
|
|
123
|
+
f(b(e.text), 1)
|
|
118
124
|
]),
|
|
119
|
-
e.iconRight && !e.loading ? (s(), u
|
|
125
|
+
e.iconRight && !e.loading ? (s(), d(u, {
|
|
120
126
|
key: 4,
|
|
121
127
|
icon: e.iconRight,
|
|
122
|
-
class:
|
|
128
|
+
class: i([[e.iconRightClass, a.value], "h-4 w-4 pointer-events-none"])
|
|
123
129
|
}, null, 8, ["icon", "class"])) : h("", !0)
|
|
124
130
|
], 10, V)), [
|
|
125
131
|
[G(j)]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const w = { class: "flex w-full items-center justify-end space-x-2" },
|
|
1
|
+
import { defineComponent as x, openBlock as u, createBlock as g, withCtx as i, createElementVNode as n, toDisplayString as d, createVNode as c, renderSlot as r } from "vue";
|
|
2
|
+
import p from "./Modal.vue.js";
|
|
3
|
+
import m from "./Button.vue.js";
|
|
4
|
+
const h = { class: "py-2 px-[2px]" }, w = { class: "mb-1.5" }, C = { class: "text-sm text-muted" }, v = { class: "flex w-full items-center justify-end space-x-2 px-[2px]" }, B = /* @__PURE__ */ x({
|
|
5
5
|
__name: "ConfirmationModal",
|
|
6
6
|
props: {
|
|
7
7
|
show: { type: Boolean, default: !1 },
|
|
@@ -13,46 +13,52 @@ const w = { class: "flex w-full items-center justify-end space-x-2" }, k = /* @_
|
|
|
13
13
|
variant: { default: "danger" }
|
|
14
14
|
},
|
|
15
15
|
emits: ["cancel", "confirm"],
|
|
16
|
-
setup(e, { emit:
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
setup(e, { emit: f }) {
|
|
17
|
+
const l = f, o = () => {
|
|
18
|
+
l("cancel");
|
|
19
19
|
};
|
|
20
|
-
return (
|
|
20
|
+
return (s, t) => (u(), g(p, {
|
|
21
21
|
show: e.show,
|
|
22
|
-
title: e.title,
|
|
23
|
-
description: e.description,
|
|
24
22
|
footerClass: "border-t-0! pt-0! pb-3.5!",
|
|
25
23
|
"max-width": "max-w-[400px]",
|
|
26
|
-
onClose:
|
|
27
|
-
"onUpdate:show": t[1] || (t[1] = (
|
|
24
|
+
onClose: o,
|
|
25
|
+
"onUpdate:show": t[1] || (t[1] = (a) => !a && o())
|
|
28
26
|
}, {
|
|
29
|
-
trigger:
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
trigger: i(() => [
|
|
28
|
+
r(s.$slots, "trigger", {}, () => [
|
|
29
|
+
r(s.$slots, "default")
|
|
32
30
|
])
|
|
33
31
|
]),
|
|
34
|
-
footer:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
variant: "
|
|
32
|
+
footer: i(({ close: a }) => [
|
|
33
|
+
n("div", v, [
|
|
34
|
+
c(m, {
|
|
35
|
+
variant: "secondary",
|
|
38
36
|
text: e.cancelText,
|
|
39
37
|
disabled: e.loading,
|
|
38
|
+
size: "sm2",
|
|
40
39
|
onClick: () => {
|
|
41
|
-
|
|
40
|
+
a?.(), o?.();
|
|
42
41
|
}
|
|
43
42
|
}, null, 8, ["text", "disabled", "onClick"]),
|
|
44
|
-
|
|
43
|
+
c(m, {
|
|
44
|
+
size: "sm2",
|
|
45
45
|
variant: e.variant,
|
|
46
46
|
text: e.confirmText,
|
|
47
47
|
loading: e.loading,
|
|
48
|
-
onClick: t[0] || (t[0] = (
|
|
48
|
+
onClick: t[0] || (t[0] = (y) => l("confirm"))
|
|
49
49
|
}, null, 8, ["variant", "text", "loading"])
|
|
50
50
|
])
|
|
51
51
|
]),
|
|
52
|
+
default: i(() => [
|
|
53
|
+
n("div", h, [
|
|
54
|
+
n("h3", w, d(e.title), 1),
|
|
55
|
+
n("p", C, d(e.description), 1)
|
|
56
|
+
])
|
|
57
|
+
]),
|
|
52
58
|
_: 3
|
|
53
|
-
}, 8, ["show"
|
|
59
|
+
}, 8, ["show"]));
|
|
54
60
|
}
|
|
55
61
|
});
|
|
56
62
|
export {
|
|
57
|
-
|
|
63
|
+
B as default
|
|
58
64
|
};
|
|
@@ -1,134 +1,148 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { initializeFormValues as q, deepClone as
|
|
3
|
-
import { useFileUpload as
|
|
4
|
-
function
|
|
5
|
-
const { schema:
|
|
6
|
-
|
|
7
|
-
() =>
|
|
1
|
+
import { ref as v, computed as K, watch as L } from "vue";
|
|
2
|
+
import { initializeFormValues as q, deepClone as m, getNestedValue as B, evaluateConditional as z, setNestedValue as w, collectFileFields as Q, filterNullCustomFields as W } from "../utils/form.utils.js";
|
|
3
|
+
import { useFileUpload as X } from "./useFileUpload.js";
|
|
4
|
+
function se(M) {
|
|
5
|
+
const { schema: c, values: x, isUpdate: F = !1, folderId: U, onSubmit: g } = M, { handleUploadFile: j } = X(), t = v(q(c, x)), o = v({}), b = v(!1), d = v(!1), h = v(m(t.value)), y = K(() => c ? Array.isArray(c[0]) ? c.flat() : c : []);
|
|
6
|
+
L(
|
|
7
|
+
() => x,
|
|
8
8
|
(e) => {
|
|
9
|
-
e && (t.value = q(
|
|
9
|
+
e && (t.value = q(c, e), h.value = m(t.value), d.value = !1);
|
|
10
10
|
},
|
|
11
11
|
{ deep: !0 }
|
|
12
12
|
);
|
|
13
|
-
const
|
|
13
|
+
const V = () => ({
|
|
14
14
|
values: t.value,
|
|
15
|
-
isUpdate:
|
|
16
|
-
}),
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
let
|
|
23
|
-
if (e.required && (
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
15
|
+
isUpdate: F
|
|
16
|
+
}), E = (e) => B(t.value, e), T = (e) => o.value[e] || "", C = (e, l) => {
|
|
17
|
+
l ? o.value[e] = l : delete o.value[e];
|
|
18
|
+
}, A = () => {
|
|
19
|
+
o.value = {};
|
|
20
|
+
}, N = (e) => e.when ? z(e.when, V()) : !0, O = (e) => z(e.disabled, V()), I = (e) => z(e.readonly, V()), D = (e) => {
|
|
21
|
+
const l = E(e.name);
|
|
22
|
+
let a = "";
|
|
23
|
+
if (e.required && (l == null || l === "" || Array.isArray(l) && l.length === 0) && (a = `${e.label || e.name} is required`), !a && e.maxFileSize) {
|
|
24
|
+
const i = e.maxFileSize * 1024 * 1024;
|
|
25
|
+
if (l != null && l !== "") {
|
|
26
|
+
const n = Array.isArray(l) ? l : [l];
|
|
27
|
+
for (const s of n) {
|
|
28
|
+
const u = s instanceof File ? s.size : s?.fileSize || s?.file?.size || s?.size;
|
|
29
|
+
if (u !== void 0 && u > i) {
|
|
30
|
+
a = `${e.label || e.name} size must be less than ${e.maxFileSize}MB`;
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
if (!
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
if (!a && (e.type === "file" || e.type === "fileUploader") && (e.props?.multiple || e.maxFiles)) {
|
|
37
|
+
const i = e.maxFiles || e.props?.maxFiles;
|
|
38
|
+
i && Array.isArray(l) && l.length > i && (a = `Maximum ${i} files allowed`);
|
|
39
39
|
}
|
|
40
|
-
return !
|
|
41
|
-
value:
|
|
40
|
+
return !a && e.validation && (a = e.validation({
|
|
41
|
+
value: l,
|
|
42
42
|
values: t.value,
|
|
43
|
-
isUpdate:
|
|
44
|
-
})),
|
|
45
|
-
},
|
|
46
|
-
|
|
43
|
+
isUpdate: F
|
|
44
|
+
})), a ? o.value[e.name] = a : delete o.value[e.name], a;
|
|
45
|
+
}, P = () => {
|
|
46
|
+
A();
|
|
47
47
|
let e = !0;
|
|
48
|
-
for (const
|
|
49
|
-
if (!
|
|
50
|
-
|
|
48
|
+
for (const l of y.value) {
|
|
49
|
+
if (!N(l) || O(l)) continue;
|
|
50
|
+
D(l) && (e = !1);
|
|
51
51
|
}
|
|
52
52
|
return e;
|
|
53
|
-
},
|
|
54
|
-
t.value =
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
53
|
+
}, R = (e, l, a) => {
|
|
54
|
+
t.value = w(t.value, e, l), d.value = !0, delete o.value[e];
|
|
55
|
+
const i = y.value.find((n) => n.name === e);
|
|
56
|
+
if (i?.updateValues) {
|
|
57
|
+
const n = i.updateValues({
|
|
58
58
|
values: t.value,
|
|
59
|
-
data:
|
|
60
|
-
isUpdate:
|
|
61
|
-
updateError:
|
|
59
|
+
data: a,
|
|
60
|
+
isUpdate: F,
|
|
61
|
+
updateError: C
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
n && typeof n == "object" && (t.value = { ...t.value, ...n });
|
|
64
64
|
}
|
|
65
|
-
},
|
|
66
|
-
const e =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
}, G = async () => {
|
|
66
|
+
const e = m(t.value), l = Q(c, e), a = (s, u) => {
|
|
67
|
+
let r = null;
|
|
68
|
+
return s instanceof File ? r = s : s && typeof s == "object" && s.file instanceof File && (r = s.file), {
|
|
69
|
+
fileName: s?.fileName || r?.name || u.split("/").pop() || "unknown",
|
|
70
|
+
fileUrl: u,
|
|
71
|
+
fileType: s?.fileType || r?.type || "application/octet-stream",
|
|
72
|
+
fileSize: s?.fileSize || r?.size || 0
|
|
73
|
+
};
|
|
74
|
+
}, i = l.map(async (s) => {
|
|
75
|
+
const { name: u, value: r, field: J } = s, $ = J.returnFileObject === !0;
|
|
76
|
+
if (Array.isArray(r)) {
|
|
77
|
+
const k = r.map(async (f) => {
|
|
78
|
+
if (f instanceof File || f && typeof f == "object" && f.file instanceof File) {
|
|
79
|
+
const S = await j(f, U);
|
|
80
|
+
return S ? $ ? a(f, S) : S : null;
|
|
81
|
+
}
|
|
82
|
+
return f;
|
|
83
|
+
}), p = await Promise.all(k);
|
|
84
|
+
return { name: u, value: p };
|
|
71
85
|
} else {
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
return { name:
|
|
86
|
+
if (r instanceof File || r && typeof r == "object" && r.file instanceof File) {
|
|
87
|
+
const p = await j(r, U);
|
|
88
|
+
if (p)
|
|
89
|
+
return { name: u, value: $ ? a(r, p) : p };
|
|
76
90
|
}
|
|
77
91
|
return null;
|
|
78
92
|
}
|
|
79
93
|
});
|
|
80
|
-
return (await Promise.all(
|
|
81
|
-
s && Object.assign(e,
|
|
94
|
+
return (await Promise.all(i)).forEach((s) => {
|
|
95
|
+
s && Object.assign(e, w(e, s.name, s.value));
|
|
82
96
|
}), e;
|
|
83
|
-
},
|
|
84
|
-
const
|
|
85
|
-
for (const
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
if (Array.isArray(
|
|
89
|
-
const
|
|
90
|
-
Object.assign(
|
|
97
|
+
}, H = (e) => {
|
|
98
|
+
const l = { ...e };
|
|
99
|
+
for (const a of y.value)
|
|
100
|
+
if (a.type === "customFields" && a.props?.schema) {
|
|
101
|
+
const i = B(l, a.name);
|
|
102
|
+
if (Array.isArray(i)) {
|
|
103
|
+
const n = W(i, a.props.schema);
|
|
104
|
+
Object.assign(l, w(l, a.name, n));
|
|
91
105
|
}
|
|
92
106
|
}
|
|
93
|
-
return
|
|
107
|
+
return l;
|
|
94
108
|
};
|
|
95
109
|
return {
|
|
96
110
|
formValues: t,
|
|
97
|
-
errors:
|
|
98
|
-
isSubmitting:
|
|
99
|
-
isDirty:
|
|
100
|
-
handleFieldChange:
|
|
101
|
-
validateField:
|
|
102
|
-
validateAll:
|
|
103
|
-
isFieldVisible:
|
|
104
|
-
isFieldDisabled:
|
|
105
|
-
isFieldReadonly:
|
|
106
|
-
getFieldValue:
|
|
107
|
-
getFieldError:
|
|
108
|
-
setFieldError:
|
|
109
|
-
clearErrors:
|
|
111
|
+
errors: o,
|
|
112
|
+
isSubmitting: b,
|
|
113
|
+
isDirty: d,
|
|
114
|
+
handleFieldChange: R,
|
|
115
|
+
validateField: D,
|
|
116
|
+
validateAll: P,
|
|
117
|
+
isFieldVisible: N,
|
|
118
|
+
isFieldDisabled: O,
|
|
119
|
+
isFieldReadonly: I,
|
|
120
|
+
getFieldValue: E,
|
|
121
|
+
getFieldError: T,
|
|
122
|
+
setFieldError: C,
|
|
123
|
+
clearErrors: A,
|
|
110
124
|
resetForm: () => {
|
|
111
|
-
t.value =
|
|
125
|
+
t.value = m(h.value), A(), d.value = !1;
|
|
112
126
|
},
|
|
113
127
|
handleSubmit: async () => {
|
|
114
|
-
if (
|
|
115
|
-
|
|
128
|
+
if (P()) {
|
|
129
|
+
b.value = !0;
|
|
116
130
|
try {
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
values:
|
|
120
|
-
isUpdate:
|
|
121
|
-
}),
|
|
122
|
-
} catch (
|
|
123
|
-
throw console.error("[useForm] Submit error:",
|
|
131
|
+
let l = await G();
|
|
132
|
+
l = H(l), g && await g({
|
|
133
|
+
values: l,
|
|
134
|
+
isUpdate: F
|
|
135
|
+
}), d.value = !1, h.value = m(l);
|
|
136
|
+
} catch (l) {
|
|
137
|
+
throw console.error("[useForm] Submit error:", l), l;
|
|
124
138
|
} finally {
|
|
125
|
-
|
|
139
|
+
b.value = !1;
|
|
126
140
|
}
|
|
127
141
|
}
|
|
128
142
|
},
|
|
129
|
-
flatSchema:
|
|
143
|
+
flatSchema: y
|
|
130
144
|
};
|
|
131
145
|
}
|
|
132
146
|
export {
|
|
133
|
-
|
|
147
|
+
se as useForm
|
|
134
148
|
};
|
|
@@ -117,6 +117,8 @@ export interface IForm {
|
|
|
117
117
|
maxFileSize?: number;
|
|
118
118
|
/** Maximum number of files allowed when multiple is true */
|
|
119
119
|
maxFiles?: number;
|
|
120
|
+
/** Return file values as objects { fileName, fileUrl, fileType, fileSize } instead of string URLs */
|
|
121
|
+
returnFileObject?: boolean;
|
|
120
122
|
}
|
|
121
123
|
/**
|
|
122
124
|
* Timeline step for multi-step forms
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function v(e) {
|
|
2
2
|
return !!e && typeof e == "object";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function u(e, n) {
|
|
5
5
|
if (!n || !e) return;
|
|
6
6
|
const t = n.split(".");
|
|
7
7
|
let f = e;
|
|
@@ -22,14 +22,14 @@ function d(e, n, t) {
|
|
|
22
22
|
return i[f[f.length - 1]] = t, r;
|
|
23
23
|
}
|
|
24
24
|
function m(e, n) {
|
|
25
|
-
return !v(n) || !n.name ? e :
|
|
25
|
+
return !v(n) || !n.name ? e : u(e, n.name) === void 0 && n.value !== void 0 ? d(e, n.name, n.value) : e;
|
|
26
26
|
}
|
|
27
27
|
function g(e, n) {
|
|
28
28
|
let t = n ? c(n) : {};
|
|
29
29
|
const f = Array.isArray(e[0]) ? e.flat() : e;
|
|
30
30
|
for (const r of f) {
|
|
31
31
|
if (!r.name) continue;
|
|
32
|
-
if (
|
|
32
|
+
if (u(t, r.name) === void 0) {
|
|
33
33
|
const o = typeof r.value == "function" ? r.value() : r.value;
|
|
34
34
|
o !== void 0 && Object.assign(t, d(t, r.name, o));
|
|
35
35
|
}
|
|
@@ -40,38 +40,40 @@ function g(e, n) {
|
|
|
40
40
|
function h(e, n) {
|
|
41
41
|
return e === void 0 ? !1 : typeof e == "boolean" ? e : typeof e == "function" ? e(n) : !1;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function V(e, n) {
|
|
44
44
|
return Array.isArray(e) ? e.filter((t) => t ? !n.every((r) => {
|
|
45
45
|
const i = t[r.name];
|
|
46
46
|
return i == null || i === "";
|
|
47
47
|
}) : !1) : [];
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function F(e, n) {
|
|
50
50
|
const t = [], f = Array.isArray(e[0]) ? e.flat() : e;
|
|
51
51
|
for (const r of f) {
|
|
52
52
|
if (!r.name) continue;
|
|
53
53
|
const i = r.type;
|
|
54
54
|
if (i === "file" || i === "avatarUpload" || i === "fileUploader") {
|
|
55
|
-
const o =
|
|
55
|
+
const o = u(n, r.name);
|
|
56
56
|
o && t.push({
|
|
57
57
|
name: r.name,
|
|
58
58
|
value: o,
|
|
59
|
-
type: i
|
|
59
|
+
type: i,
|
|
60
|
+
field: r
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
if (i === "customFields" && r.props?.schema) {
|
|
63
|
-
const o =
|
|
64
|
+
const o = u(n, r.name);
|
|
64
65
|
if (Array.isArray(o)) {
|
|
65
66
|
const y = r.props.schema.filter(
|
|
66
67
|
(a) => a.type === "file" || a.type === "avatarUpload" || a.type === "fileUploader"
|
|
67
68
|
);
|
|
68
69
|
y.length > 0 && o.forEach((a, A) => {
|
|
69
|
-
y.forEach((
|
|
70
|
-
const p = a?.[
|
|
70
|
+
y.forEach((s) => {
|
|
71
|
+
const p = a?.[s.name];
|
|
71
72
|
p && t.push({
|
|
72
|
-
name: `${r.name}.${A}.${
|
|
73
|
+
name: `${r.name}.${A}.${s.name}`,
|
|
73
74
|
value: p,
|
|
74
|
-
type:
|
|
75
|
+
type: s.type,
|
|
76
|
+
field: s
|
|
75
77
|
});
|
|
76
78
|
});
|
|
77
79
|
});
|
|
@@ -94,11 +96,11 @@ function k(e) {
|
|
|
94
96
|
return e ? typeof e == "object" && (typeof e.render == "function" || typeof e.setup == "function" || e.__name !== void 0 || e.name !== void 0) : !1;
|
|
95
97
|
}
|
|
96
98
|
export {
|
|
97
|
-
|
|
99
|
+
F as collectFileFields,
|
|
98
100
|
c as deepClone,
|
|
99
101
|
h as evaluateConditional,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
V as filterNullCustomFields,
|
|
103
|
+
u as getNestedValue,
|
|
102
104
|
g as initializeFormValues,
|
|
103
105
|
v as isAddonObject,
|
|
104
106
|
k as isComponent,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as W, computed as
|
|
1
|
+
import { defineComponent as W, computed as N, ref as y, provide as E, watch as R, resolveComponent as X, openBlock as a, createElementBlock as i, normalizeClass as D, createElementVNode as h, renderSlot as B, toDisplayString as f, createCommentVNode as m, createBlock as s, unref as I, createVNode as r, resolveDynamicComponent as U, Fragment as P, mergeProps as c, withCtx as o, createTextVNode as v } from "vue";
|
|
2
2
|
import Y from "../Input.vue.js";
|
|
3
3
|
import u from "../Button.vue.js";
|
|
4
4
|
import F from "../Icon.vue.js";
|
|
@@ -61,32 +61,32 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
61
61
|
},
|
|
62
62
|
emits: ["add", "delete"],
|
|
63
63
|
setup(e, { emit: L }) {
|
|
64
|
-
const l = e,
|
|
64
|
+
const l = e, j = L, K = N(() => l.name || l.title || "default-screen"), b = te(
|
|
65
65
|
`view-mode-${K.value}`,
|
|
66
66
|
l.table ? "table" : "list"
|
|
67
|
-
), x = y(""), A = y({}), w = y(l.pageInfo?.currentPage || 1), $ = y(l.pageInfo?.itemsPerPage || l.paginationProps?.itemsPerPage || 10), g = y([]),
|
|
68
|
-
E("screen-selected-rows", g), E("screen-request-delete", (t) =>
|
|
69
|
-
const
|
|
70
|
-
|
|
67
|
+
), x = y(""), A = y({}), w = y(l.pageInfo?.currentPage || 1), $ = y(l.pageInfo?.itemsPerPage || l.paginationProps?.itemsPerPage || 10), g = y([]), V = y([]), k = y(!1);
|
|
68
|
+
E("screen-selected-rows", g), E("screen-request-delete", (t) => S(t));
|
|
69
|
+
const S = (t) => {
|
|
70
|
+
V.value = t, k.value = !0;
|
|
71
71
|
}, O = () => {
|
|
72
|
-
|
|
72
|
+
j("delete", V.value), k.value = !1, g.value = [];
|
|
73
73
|
}, Q = (t) => {
|
|
74
|
-
|
|
74
|
+
j("delete", t), g.value = [];
|
|
75
75
|
};
|
|
76
|
-
|
|
76
|
+
R(
|
|
77
77
|
() => l.pageInfo?.currentPage,
|
|
78
78
|
(t) => {
|
|
79
79
|
t && (w.value = t);
|
|
80
80
|
}
|
|
81
|
-
),
|
|
81
|
+
), R(
|
|
82
82
|
() => l.pageInfo?.itemsPerPage,
|
|
83
83
|
(t) => {
|
|
84
84
|
t && ($.value = t);
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
let T = null;
|
|
88
|
+
R(x, (t) => {
|
|
89
|
+
T && clearTimeout(T), T = setTimeout(() => {
|
|
90
90
|
w.value = 1, C();
|
|
91
91
|
}, 300);
|
|
92
92
|
});
|
|
@@ -108,7 +108,7 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
108
108
|
filter: A.value
|
|
109
109
|
};
|
|
110
110
|
l.refetch && l.refetch(t);
|
|
111
|
-
}, z =
|
|
111
|
+
}, z = N(() => b.value === "table" && l.table ? l.table : l.list), M = N(() => l.data && l.data.length > 0);
|
|
112
112
|
return (t, n) => {
|
|
113
113
|
const q = X("router-link");
|
|
114
114
|
return a(), i("div", ae, [
|
|
@@ -132,13 +132,13 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
132
132
|
class: "hover:bg-destructive/10 shrink-0 h-9! w-9!",
|
|
133
133
|
icon: "lucide:trash-2",
|
|
134
134
|
title: "Delete Selected",
|
|
135
|
-
onClick: n[0] || (n[0] = (d) =>
|
|
135
|
+
onClick: n[0] || (n[0] = (d) => S(g.value))
|
|
136
136
|
})) : m("", !0),
|
|
137
137
|
e.table && e.list ? (a(), i("div", se, [
|
|
138
138
|
h("button", {
|
|
139
139
|
onClick: n[1] || (n[1] = (d) => b.value = "list"),
|
|
140
140
|
class: D(["p-1.5 rounded", [
|
|
141
|
-
I(b) === "list" ? "bg-secondary/85 dark:bg-
|
|
141
|
+
I(b) === "list" ? "bg-secondary/85 dark:bg-secondary shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"
|
|
142
142
|
]]),
|
|
143
143
|
title: "List View"
|
|
144
144
|
}, [
|
|
@@ -150,7 +150,7 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
150
150
|
h("button", {
|
|
151
151
|
onClick: n[2] || (n[2] = (d) => b.value = "table"),
|
|
152
152
|
class: D(["p-1.5 rounded", [
|
|
153
|
-
I(b) === "table" ? "bg-secondary/85 dark:bg-
|
|
153
|
+
I(b) === "table" ? "bg-secondary/85 dark:bg-secondary shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"
|
|
154
154
|
]]),
|
|
155
155
|
title: "Table View"
|
|
156
156
|
}, [
|
|
@@ -194,7 +194,7 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
194
194
|
]),
|
|
195
195
|
h("div", ue, [
|
|
196
196
|
B(t.$slots, "actions", {}, () => [
|
|
197
|
-
e.addComponent ? (a(), s(
|
|
197
|
+
e.addComponent ? (a(), s(U(e.addComponent), { key: 0 })) : e.canAdd ? (a(), i(P, { key: 1 }, [
|
|
198
198
|
e.addBtn ? (a(), i(P, { key: 0 }, [
|
|
199
199
|
e.addBtn.modal ? (a(), s(H, c({
|
|
200
200
|
key: 0,
|
|
@@ -293,7 +293,7 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
293
293
|
icon: e.emptyIcon
|
|
294
294
|
}, {
|
|
295
295
|
action: o(() => [
|
|
296
|
-
e.addComponent ? (a(), s(
|
|
296
|
+
e.addComponent ? (a(), s(U(e.addComponent), { key: 0 })) : e.canAdd ? (a(), i(P, { key: 1 }, [
|
|
297
297
|
e.addBtn ? (a(), i(P, { key: 0 }, [
|
|
298
298
|
e.addBtn.modal ? (a(), s(H, c({
|
|
299
299
|
key: 0,
|
|
@@ -373,14 +373,14 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
373
373
|
_: 1
|
|
374
374
|
}, 8, ["title", "description", "icon"])
|
|
375
375
|
]) : (a(), i(P, { key: 1 }, [
|
|
376
|
-
z.value ? (a(), s(
|
|
376
|
+
z.value ? (a(), s(U(z.value), {
|
|
377
377
|
key: 0,
|
|
378
378
|
data: e.data,
|
|
379
379
|
loading: e.loading,
|
|
380
380
|
refetch: e.refetch,
|
|
381
381
|
selectedRows: g.value,
|
|
382
382
|
"onUpdate:selectedRows": n[9] || (n[9] = (d) => g.value = d),
|
|
383
|
-
delete:
|
|
383
|
+
delete: S,
|
|
384
384
|
onDelete: Q
|
|
385
385
|
}, null, 40, ["data", "loading", "refetch", "selectedRows"])) : (a(), i("div", me, " Please provide a `:list` or `:table` component. "))
|
|
386
386
|
], 64))
|
|
@@ -399,13 +399,13 @@ const ae = { class: "flex flex-col w-full space-y-8" }, ne = { class: "flex flex
|
|
|
399
399
|
show: k.value,
|
|
400
400
|
"onUpdate:show": n[10] || (n[10] = (d) => k.value = d),
|
|
401
401
|
title: "Confirm Deletion",
|
|
402
|
-
description:
|
|
402
|
+
description: `Are you sure you want to delete the selected ${V.value.length > 1 ? "items" : "item"}?`,
|
|
403
403
|
"confirm-text": "Delete",
|
|
404
404
|
"cancel-text": "Cancel",
|
|
405
405
|
variant: "danger",
|
|
406
406
|
onConfirm: O,
|
|
407
407
|
onCancel: n[11] || (n[11] = (d) => k.value = !1)
|
|
408
|
-
}, null, 8, ["show"])
|
|
408
|
+
}, null, 8, ["show", "description"])
|
|
409
409
|
]);
|
|
410
410
|
};
|
|
411
411
|
}
|
package/package.json
CHANGED
package/style.css
CHANGED
package/types/button.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type ButtonVariant = 'primary' | 'primary-light' | 'secondary' | 'danger' | 'danger-light' | 'warning' | 'warning-light' | 'info' | 'info-light' | 'success' | 'success-light' | 'outline' | 'outline-primary' | 'outline-danger' | 'outline-warning' | 'outline-info' | 'outline-success' | 'ghost' | 'link';
|
|
2
|
-
export type ButtonSize = 'xs' | '
|
|
3
|
-
export type ButtonRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
|
2
|
+
export type ButtonSize = 'xs' | 'sm' | 'sm2' | 'md' | 'lg' | 'xl';
|
|
3
|
+
export type ButtonRounded = 'none' | 'sm' | 'sm2' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
|
4
4
|
export interface ButtonProps {
|
|
5
5
|
variant?: ButtonVariant;
|
|
6
6
|
size?: ButtonSize;
|