vlite3 0.9.6 → 0.9.7
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/ColorPicker/ColorIro.vue3.js +2 -2
- package/components/ColorPicker/ColorPicker.vue.js +2 -2
- package/components/DatePicker.vue.js +38 -32
- package/components/DateRangePicker.vue.js +28 -26
- package/components/Dropdown/DropdownBooleanItem.vue.js +12 -9
- package/components/Dropdown/DropdownMenu.vue.js +2 -2
- package/components/Dropdown/DropdownMenu.vue2.js +51 -51
- package/components/Form/CustomFields.vue.d.ts +4 -0
- package/components/Form/CustomFields.vue.js +2 -2
- package/components/Form/CustomFields.vue2.js +147 -115
- package/components/Form/FormField.vue.d.ts +1 -0
- package/components/Form/FormField.vue.js +3 -0
- package/components/Form/FormFields.vue.js +2 -2
- package/components/Form/FormFields.vue2.js +38 -37
- package/components/Form/composables/useForm.d.ts +1 -1
- package/components/Form/composables/useForm.js +142 -125
- package/components/Form/types.d.ts +6 -0
- package/components/Form/utils/form.utils.js +115 -106
- package/components/Screen/ScreenFilter.vue.js +1 -1
- package/package.json +2 -2
- package/style.css +6 -1
- /package/components/ColorPicker/{ColorIro.vue2.js → ColorIro.vue.js} +0 -0
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { VueDraggable as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { $t as
|
|
8
|
-
import { evaluateConditional as
|
|
9
|
-
const
|
|
1
|
+
import { defineComponent as Y, computed as f, shallowRef as Z, watch as I, openBlock as n, createElementBlock as d, createElementVNode as y, createBlock as B, withCtx as D, createTextVNode as ee, toDisplayString as v, createCommentVNode as c, createVNode as p, Fragment as k, renderList as V, normalizeClass as C, unref as te, isMemoSame as ae } from "vue";
|
|
2
|
+
import { VueDraggable as re } from "vue-draggable-plus";
|
|
3
|
+
import le from "./FormField.vue.js";
|
|
4
|
+
import N from "../Button.vue.js";
|
|
5
|
+
import se from "../Label.vue.js";
|
|
6
|
+
import oe from "../Icon.vue.js";
|
|
7
|
+
import { $t as w } from "../../utils/i18n.js";
|
|
8
|
+
import { setNestedValue as E, evaluateConditional as $ } from "./utils/form.utils.js";
|
|
9
|
+
const ne = { class: "custom-fields-wrapper" }, de = { class: "flex justify-between items-center mb-2" }, ue = { class: "custom-fields-table border border-border rounded overflow-hidden bg-background" }, ie = {
|
|
10
10
|
key: 0,
|
|
11
11
|
class: "flex border-b border-border bg-muted/50 text-gray-800 text-xs font-semibold uppercase tracking-wider"
|
|
12
|
-
},
|
|
12
|
+
}, ce = {
|
|
13
13
|
key: 0,
|
|
14
14
|
class: "w-10 flex-none p-3 border-r border-border"
|
|
15
|
-
},
|
|
15
|
+
}, me = {
|
|
16
16
|
key: 1,
|
|
17
17
|
class: "w-10 flex-none p-3 text-center border-r border-border"
|
|
18
|
-
},
|
|
18
|
+
}, be = {
|
|
19
19
|
key: 2,
|
|
20
20
|
class: "w-10 flex-none p-3"
|
|
21
|
-
},
|
|
21
|
+
}, fe = {
|
|
22
22
|
key: 1,
|
|
23
23
|
class: "w-10 flex-none flex items-center justify-center text-xs text-muted-foreground border-r border-border bg-muted/20"
|
|
24
|
-
},
|
|
24
|
+
}, ve = {
|
|
25
25
|
key: 2,
|
|
26
26
|
class: "w-10 flex-none flex items-center justify-center border-l border-border bg-muted/20"
|
|
27
|
-
},
|
|
27
|
+
}, ge = {
|
|
28
28
|
key: 1,
|
|
29
29
|
class: "flex flex-col items-center justify-center py-6 text-center bg-muted/5"
|
|
30
|
-
},
|
|
30
|
+
}, he = { class: "text-sm font-medium text-foreground" }, ye = { class: "text-xs text-muted-foreground mt-1" }, Fe = /* @__PURE__ */ Y({
|
|
31
31
|
__name: "CustomFields",
|
|
32
32
|
props: {
|
|
33
|
+
name: {},
|
|
33
34
|
modelValue: { default: () => [] },
|
|
34
35
|
schema: {},
|
|
35
36
|
headers: { default: () => [] },
|
|
@@ -46,168 +47,199 @@ const re = { class: "custom-fields-wrapper" }, se = { class: "flex justify-betwe
|
|
|
46
47
|
labelI18n: {},
|
|
47
48
|
showRowNumbers: { type: Boolean, default: !1 },
|
|
48
49
|
values: {},
|
|
50
|
+
errors: { default: () => ({}) },
|
|
49
51
|
isUpdate: { type: Boolean, default: !1 }
|
|
50
52
|
},
|
|
51
53
|
emits: ["update:modelValue", "change"],
|
|
52
|
-
setup(
|
|
53
|
-
const
|
|
54
|
-
const e =
|
|
54
|
+
setup(s, { emit: z }) {
|
|
55
|
+
const t = s, F = z, U = f(() => t.labelI18n ? w(t.labelI18n) : t.label), A = f(() => {
|
|
56
|
+
const e = w("vlite.customFields.emptyTitle");
|
|
55
57
|
return e !== "vlite.customFields.emptyTitle" ? e : "No items added";
|
|
56
|
-
}),
|
|
57
|
-
const e =
|
|
58
|
+
}), T = f(() => {
|
|
59
|
+
const e = w("vlite.customFields.emptyDescription");
|
|
58
60
|
return e !== "vlite.customFields.emptyDescription" ? e : "Add a new item to get started";
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
() =>
|
|
61
|
+
}), l = Z([]), _ = () => `row_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
62
|
+
I(
|
|
63
|
+
() => t.modelValue,
|
|
62
64
|
(e) => {
|
|
63
|
-
Array.isArray(e) ?
|
|
64
|
-
const
|
|
65
|
+
Array.isArray(e) ? l.value = e.map((a, o) => {
|
|
66
|
+
const r = l.value[o];
|
|
65
67
|
return {
|
|
66
|
-
...
|
|
67
|
-
_id:
|
|
68
|
+
...a,
|
|
69
|
+
_id: r?._id || _()
|
|
68
70
|
};
|
|
69
|
-
}) :
|
|
71
|
+
}) : l.value = [];
|
|
70
72
|
},
|
|
71
73
|
{ immediate: !0, deep: !0 }
|
|
72
74
|
);
|
|
73
|
-
const
|
|
75
|
+
const S = () => {
|
|
74
76
|
const e = {};
|
|
75
|
-
for (const
|
|
76
|
-
const
|
|
77
|
-
e[
|
|
77
|
+
for (const a of t.schema) {
|
|
78
|
+
const o = typeof a.value == "function" ? a.value() : a.value;
|
|
79
|
+
e[a.name] = o ?? null;
|
|
78
80
|
}
|
|
79
|
-
return { ...e, _id:
|
|
80
|
-
},
|
|
81
|
-
if (
|
|
82
|
-
const e = [...
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
...
|
|
92
|
-
[
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
81
|
+
return { ...e, _id: _() };
|
|
82
|
+
}, H = () => {
|
|
83
|
+
if (t.disabled || t.maxRows && l.value.length >= t.maxRows) return;
|
|
84
|
+
const e = [...l.value, S()];
|
|
85
|
+
l.value = e, g(e);
|
|
86
|
+
}, L = (e) => {
|
|
87
|
+
if (t.disabled || l.value.length <= t.minRows) return;
|
|
88
|
+
const a = [...l.value];
|
|
89
|
+
a.splice(e, 1), l.value = a, g(a);
|
|
90
|
+
}, M = async (e, a, o) => {
|
|
91
|
+
const r = [...l.value];
|
|
92
|
+
r[e] = {
|
|
93
|
+
...r[e],
|
|
94
|
+
[a]: o.value
|
|
95
|
+
};
|
|
96
|
+
const h = t.schema.find((i) => i.name === a);
|
|
97
|
+
if (h && h.updateValues)
|
|
98
|
+
try {
|
|
99
|
+
const i = r[e];
|
|
100
|
+
let m = { ...t.values || {} };
|
|
101
|
+
t.name && (m = E(m, t.name, r));
|
|
102
|
+
const b = await h.updateValues({
|
|
103
|
+
value: o.value,
|
|
104
|
+
values: i,
|
|
105
|
+
// strictly local row scope
|
|
106
|
+
globalValues: m,
|
|
107
|
+
// strictly global root scope
|
|
108
|
+
data: o.data,
|
|
109
|
+
isUpdate: t.isUpdate
|
|
110
|
+
});
|
|
111
|
+
b && typeof b == "object" && (r[e] = { ...r[e], ...b });
|
|
112
|
+
} catch (i) {
|
|
113
|
+
console.error(`[CustomFields] Error in updateValues for ${a}:`, i);
|
|
114
|
+
}
|
|
115
|
+
l.value = r, g(r);
|
|
116
|
+
}, G = (e) => {
|
|
117
|
+
l.value = e, g(e);
|
|
118
|
+
}, g = (e) => {
|
|
119
|
+
const a = e.map(({ _id: o, ...r }) => r);
|
|
120
|
+
F("update:modelValue", a), F("change", a);
|
|
121
|
+
}, O = (e, a) => l.value[e]?.[a], W = f(() => !(t.disabled || t.maxRows && l.value.length >= t.maxRows)), x = f(() => t.disabled ? !1 : l.value.length > t.minRows), j = f(() => t.headers && t.headers.length > 0 ? t.headers : t.schema.map((e) => e.labelI18n ? w(e.labelI18n) : e.label || e.name)), R = (e) => {
|
|
122
|
+
let a = { ...t.values || {} };
|
|
123
|
+
return t.name && (a = E(a, t.name, l.value)), {
|
|
124
|
+
values: l.value[e] || {},
|
|
125
|
+
globalValues: a,
|
|
126
|
+
isUpdate: t.isUpdate
|
|
127
|
+
};
|
|
128
|
+
}, q = (e, a) => t.disabled ? !0 : $(a.disabled, R(e)), J = (e, a) => $(a.readonly, R(e)), K = (e, a) => a.when ? $(a.when, R(e)) : !0, P = (e) => {
|
|
129
|
+
if (!t.errors || !t.name) return "";
|
|
130
|
+
const a = `${t.name}.${e}.`;
|
|
131
|
+
return Object.keys(t.errors).filter((o) => o.startsWith(a)).map((o) => t.errors[o]).join(",");
|
|
132
|
+
};
|
|
133
|
+
return (e, a) => (n(), d("div", ne, [
|
|
134
|
+
y("div", de, [
|
|
135
|
+
U.value ? (n(), B(se, {
|
|
106
136
|
key: 0,
|
|
107
137
|
class: "text-sm font-medium text-foreground"
|
|
108
138
|
}, {
|
|
109
139
|
default: D(() => [
|
|
110
|
-
|
|
140
|
+
ee(v(U.value), 1)
|
|
111
141
|
]),
|
|
112
142
|
_: 1
|
|
113
|
-
})) :
|
|
114
|
-
|
|
143
|
+
})) : c("", !0),
|
|
144
|
+
p(N, {
|
|
115
145
|
type: "button",
|
|
116
146
|
variant: "outline",
|
|
117
147
|
size: "xs",
|
|
118
148
|
rounded: "full",
|
|
119
149
|
icon: "lucide:plus",
|
|
120
|
-
disabled: !
|
|
121
|
-
onClick:
|
|
150
|
+
disabled: !W.value,
|
|
151
|
+
onClick: H
|
|
122
152
|
}, null, 8, ["disabled"])
|
|
123
153
|
]),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
(
|
|
129
|
-
key:
|
|
130
|
-
class:
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
])) :
|
|
134
|
-
|
|
135
|
-
"model-value":
|
|
136
|
-
"onUpdate:modelValue":
|
|
137
|
-
disabled: !
|
|
154
|
+
y("div", ue, [
|
|
155
|
+
j.value.length > 0 ? (n(), d("div", ie, [
|
|
156
|
+
s.draggable ? (n(), d("div", ce)) : c("", !0),
|
|
157
|
+
s.showRowNumbers ? (n(), d("div", me, " # ")) : c("", !0),
|
|
158
|
+
(n(!0), d(k, null, V(j.value, (o, r) => (n(), d("div", {
|
|
159
|
+
key: r,
|
|
160
|
+
class: C(["flex-1 p-3 min-w-0 truncate", { "border-l border-border": r > 0 }])
|
|
161
|
+
}, v(o), 3))), 128)),
|
|
162
|
+
x.value ? (n(), d("div", be)) : c("", !0)
|
|
163
|
+
])) : c("", !0),
|
|
164
|
+
p(te(re), {
|
|
165
|
+
"model-value": l.value,
|
|
166
|
+
"onUpdate:modelValue": G,
|
|
167
|
+
disabled: !s.draggable || s.disabled,
|
|
138
168
|
animation: 150,
|
|
139
169
|
handle: ".drag-handle",
|
|
140
170
|
"ghost-class": "opacity-50",
|
|
141
171
|
class: "divide-y divide-border"
|
|
142
172
|
}, {
|
|
143
173
|
default: D(() => [
|
|
144
|
-
(
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
key:
|
|
174
|
+
(n(!0), d(k, null, V(l.value, (o, r, h, i) => {
|
|
175
|
+
const m = [o, s.disabled, s.isUpdate, s.showRowNumbers, x.value, s.draggable, r, P(r)];
|
|
176
|
+
if (i && i.key === o._id && ae(i, m)) return i;
|
|
177
|
+
const b = (n(), d("div", {
|
|
178
|
+
key: o._id,
|
|
149
179
|
class: "flex group bg-white transition-colors"
|
|
150
180
|
}, [
|
|
151
|
-
|
|
181
|
+
s.draggable ? (n(), d("div", {
|
|
152
182
|
key: 0,
|
|
153
|
-
class:
|
|
183
|
+
class: C(["w-10 flex-none flex items-center justify-center border-r border-border bg-muted/5 drag-handle transition-colors", s.disabled ? "cursor-not-allowed opacity-50" : "cursor-grab active:cursor-grabbing hover:bg-muted/10 text-muted-foreground hover:text-foreground"])
|
|
154
184
|
}, [
|
|
155
|
-
|
|
185
|
+
p(oe, {
|
|
156
186
|
icon: "lucide:grip-vertical",
|
|
157
187
|
class: "w-4 h-4"
|
|
158
188
|
})
|
|
159
|
-
], 2)) :
|
|
160
|
-
|
|
161
|
-
(
|
|
162
|
-
key:
|
|
163
|
-
class:
|
|
189
|
+
], 2)) : c("", !0),
|
|
190
|
+
s.showRowNumbers ? (n(), d("div", fe, v(r + 1), 1)) : c("", !0),
|
|
191
|
+
(n(!0), d(k, null, V(s.schema, (u, Q) => (n(), d("div", {
|
|
192
|
+
key: u.name,
|
|
193
|
+
class: C(["flex-1 min-w-0 relative", { "border-l border-border": Q > 0 }])
|
|
164
194
|
}, [
|
|
165
|
-
K(
|
|
195
|
+
K(r, u) ? (n(), B(le, {
|
|
166
196
|
key: 0,
|
|
167
197
|
field: {
|
|
168
|
-
...
|
|
198
|
+
...u,
|
|
169
199
|
props: {
|
|
170
|
-
...
|
|
171
|
-
...
|
|
200
|
+
...u.type === "multiSelect" ? { showControls: !1, wrap: !1 } : {},
|
|
201
|
+
...u.props || {}
|
|
172
202
|
},
|
|
173
203
|
label: void 0
|
|
174
204
|
},
|
|
175
|
-
value:
|
|
176
|
-
values:
|
|
205
|
+
value: O(r, u.name),
|
|
206
|
+
values: l.value[r] || {},
|
|
207
|
+
errors: s.errors,
|
|
208
|
+
error: s.name && s.errors ? s.errors[`${s.name}.${r}.${u.name}`] : "",
|
|
177
209
|
variant: "transparent",
|
|
178
210
|
size: "sm",
|
|
179
211
|
rounded: "none",
|
|
180
|
-
disabled:
|
|
181
|
-
readonly: J(
|
|
182
|
-
isUpdate:
|
|
212
|
+
disabled: q(r, u),
|
|
213
|
+
readonly: J(r, u),
|
|
214
|
+
isUpdate: s.isUpdate,
|
|
183
215
|
class: "w-full h-full min-h-[40px]",
|
|
184
|
-
onChange: (
|
|
185
|
-
}, null, 8, ["field", "value", "values", "disabled", "readonly", "isUpdate", "onChange"])) :
|
|
216
|
+
onChange: (X) => M(r, u.name, X)
|
|
217
|
+
}, null, 8, ["field", "value", "values", "errors", "error", "disabled", "readonly", "isUpdate", "onChange"])) : c("", !0)
|
|
186
218
|
], 2))), 128)),
|
|
187
|
-
|
|
188
|
-
|
|
219
|
+
x.value ? (n(), d("div", ve, [
|
|
220
|
+
p(N, {
|
|
189
221
|
type: "button",
|
|
190
222
|
variant: "ghost",
|
|
191
223
|
size: "xs",
|
|
192
224
|
icon: "lucide:trash-2",
|
|
193
|
-
disabled:
|
|
194
|
-
onClick: (
|
|
225
|
+
disabled: s.disabled,
|
|
226
|
+
onClick: (u) => L(r)
|
|
195
227
|
}, null, 8, ["disabled", "onClick"])
|
|
196
|
-
])) :
|
|
228
|
+
])) : c("", !0)
|
|
197
229
|
]));
|
|
198
|
-
return
|
|
199
|
-
},
|
|
230
|
+
return b.memo = m, b;
|
|
231
|
+
}, a, 0), 128))
|
|
200
232
|
]),
|
|
201
233
|
_: 1
|
|
202
234
|
}, 8, ["model-value", "disabled"]),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
])) :
|
|
235
|
+
l.value.length === 0 ? (n(), d("div", ge, [
|
|
236
|
+
y("p", he, v(A.value), 1),
|
|
237
|
+
y("p", ye, v(T.value), 1)
|
|
238
|
+
])) : c("", !0)
|
|
207
239
|
])
|
|
208
240
|
]));
|
|
209
241
|
}
|
|
210
242
|
});
|
|
211
243
|
export {
|
|
212
|
-
|
|
244
|
+
Fe as default
|
|
213
245
|
};
|
|
@@ -21,6 +21,7 @@ const ge = /* @__PURE__ */ T({
|
|
|
21
21
|
field: {},
|
|
22
22
|
value: {},
|
|
23
23
|
values: {},
|
|
24
|
+
errors: {},
|
|
24
25
|
variant: { default: "outline" },
|
|
25
26
|
size: { default: "md" },
|
|
26
27
|
rounded: { default: "md" },
|
|
@@ -206,6 +207,7 @@ const ge = /* @__PURE__ */ T({
|
|
|
206
207
|
value: e.value || "lucide:smile"
|
|
207
208
|
} : a === "customFields" ? {
|
|
208
209
|
...i,
|
|
210
|
+
name: e.field.name,
|
|
209
211
|
label: e?.field?.label,
|
|
210
212
|
labelI18n: e?.field?.labelI18n,
|
|
211
213
|
modelValue: Array.isArray(e.value) ? e.value : [],
|
|
@@ -213,6 +215,7 @@ const ge = /* @__PURE__ */ T({
|
|
|
213
215
|
headers: e.field.props?.headers || [],
|
|
214
216
|
draggable: e.field.props?.draggable || !1,
|
|
215
217
|
values: e.values,
|
|
218
|
+
errors: e.errors,
|
|
216
219
|
variant: e.variant,
|
|
217
220
|
size: e.size,
|
|
218
221
|
rounded: e.rounded,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./FormFields.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import r from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const
|
|
4
|
+
const f = /* @__PURE__ */ r(o, [["__scopeId", "data-v-e60dfb65"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
f as default
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as M, computed as O, ref as j, openBlock as s, createElementBlock as
|
|
2
|
-
import { isComponent as
|
|
1
|
+
import { defineComponent as M, computed as O, ref as j, openBlock as s, createElementBlock as o, normalizeClass as m, Fragment as y, renderList as G, withMemo as J, createBlock as h, withCtx as L, unref as R, resolveDynamicComponent as z, createTextVNode as k, toDisplayString as v, createCommentVNode as c, createElementVNode as K, createVNode as P, markRaw as Q } from "vue";
|
|
2
|
+
import { isComponent as p, getNestedValue as W } from "./utils/form.utils.js";
|
|
3
3
|
import U from "../Label.vue.js";
|
|
4
4
|
import X from "./FormField.vue.js";
|
|
5
5
|
import { $t as Y } from "../../utils/i18n.js";
|
|
@@ -33,30 +33,30 @@ const Z = {
|
|
|
33
33
|
isFieldReadonly: {}
|
|
34
34
|
},
|
|
35
35
|
emits: ["change", "addonAction"],
|
|
36
|
-
setup(a, { emit:
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
}), F = (t) => W(
|
|
36
|
+
setup(a, { emit: f }) {
|
|
37
|
+
const r = a, g = f, q = O(() => {
|
|
38
|
+
if (r.className) return r.className;
|
|
39
|
+
}), F = (t) => W(r.values, t.name), l = (t) => r.errors[t.name] || "", D = (t) => r.isFieldVisible ? r.isFieldVisible(t) : !0, x = (t) => r.isFieldDisabled ? r.isFieldDisabled(t) : t.disabled === !0, A = (t) => r.isFieldReadonly ? r.isFieldReadonly(t) : t.readonly === !0, u = (t) => t.labelI18n ? Y(t.labelI18n) : t.label, w = (t) => {
|
|
40
40
|
if (t)
|
|
41
|
-
return
|
|
42
|
-
},
|
|
41
|
+
return p(t) ? Q(t) : t;
|
|
42
|
+
}, $ = (t, n) => {
|
|
43
43
|
g("change", t.name, n);
|
|
44
44
|
}, B = (t) => t.itemClass || "", I = (t, n) => {
|
|
45
45
|
g("change", t, n);
|
|
46
46
|
}, E = (t) => {
|
|
47
47
|
g("addonAction", t);
|
|
48
|
-
},
|
|
49
|
-
|
|
48
|
+
}, d = j({}), T = (t) => {
|
|
49
|
+
d.value[t] = !0;
|
|
50
50
|
}, S = (t) => {
|
|
51
|
-
|
|
51
|
+
d.value[t] = !1;
|
|
52
52
|
}, C = (t) => {
|
|
53
53
|
const n = F(t), e = n != null && n !== "" && !(Array.isArray(n) && n.length === 0), i = typeof n == "number" && !isNaN(n);
|
|
54
|
-
return V(t) || t.type === "number" ?
|
|
54
|
+
return V(t) || t.type === "number" ? d.value[t.name] || e || i : e || i;
|
|
55
55
|
}, V = (t) => {
|
|
56
56
|
const n = t.type || "text";
|
|
57
57
|
return ["text", "email", "password", "tel", "url", "search", "textarea"].includes(n);
|
|
58
58
|
}, H = (t) => t.type === "number" ? (t.props?.variant ?? "split") === "split" ? "left-4" : "left-3" : t.type === "date" || t.type === "time" || t.type === "color" ? "left-10" : "left-3", b = (t) => {
|
|
59
|
-
if (
|
|
59
|
+
if (r.variant !== "floating") return !1;
|
|
60
60
|
const n = t.type || "text";
|
|
61
61
|
return ![
|
|
62
62
|
"switch",
|
|
@@ -68,65 +68,65 @@ const Z = {
|
|
|
68
68
|
].includes(n);
|
|
69
69
|
}, N = (t) => {
|
|
70
70
|
const n = u(t);
|
|
71
|
-
if (!(!n ||
|
|
71
|
+
if (!(!n || p(n)))
|
|
72
72
|
return n;
|
|
73
73
|
};
|
|
74
|
-
return (t, n) => (s(),
|
|
75
|
-
class:
|
|
74
|
+
return (t, n) => (s(), o("div", {
|
|
75
|
+
class: m(["grid", a.variant === "floating" ? "gap-5 mt-1" : "gap-4", q.value])
|
|
76
76
|
}, [
|
|
77
|
-
(s(!0),
|
|
77
|
+
(s(!0), o(y, null, G(a.schema, (e) => (s(), o(y, {
|
|
78
78
|
key: e.name
|
|
79
79
|
}, [
|
|
80
|
-
|
|
80
|
+
D(e) ? J([
|
|
81
81
|
e,
|
|
82
82
|
F(e),
|
|
83
83
|
l(e),
|
|
84
84
|
x(e),
|
|
85
85
|
A(e),
|
|
86
|
-
|
|
86
|
+
d.value[e.name],
|
|
87
87
|
a.variant,
|
|
88
88
|
a.size,
|
|
89
89
|
a.rounded,
|
|
90
90
|
a.isUpdate,
|
|
91
91
|
a.showRequiredAsterisk,
|
|
92
92
|
a.fieldLoading[e.name]
|
|
93
|
-
], () => (s(),
|
|
93
|
+
], () => (s(), o("div", {
|
|
94
94
|
key: 0,
|
|
95
|
-
class:
|
|
95
|
+
class: m(["max-md:col-span-full! form-field-item", B(e)])
|
|
96
96
|
}, [
|
|
97
97
|
u(e) && e.type !== "switch" && e.type !== "check" && e.type !== "customFields" && !b(e) ? (s(), h(U, {
|
|
98
98
|
key: 0,
|
|
99
99
|
for: e.name,
|
|
100
|
-
class: "mb-2 block text-
|
|
100
|
+
class: "mb-2 block -text-fs-2! font-medium"
|
|
101
101
|
}, {
|
|
102
102
|
default: L(() => [
|
|
103
|
-
R(
|
|
104
|
-
k(
|
|
105
|
-
e.required && a.showRequiredAsterisk ? (s(),
|
|
103
|
+
R(p)(u(e)) ? (s(), h(z(w(u(e))), { key: 0 })) : (s(), o(y, { key: 1 }, [
|
|
104
|
+
k(v(u(e)) + " ", 1),
|
|
105
|
+
e.required && a.showRequiredAsterisk ? (s(), o("span", Z, "*")) : c("", !0)
|
|
106
106
|
], 64))
|
|
107
107
|
]),
|
|
108
108
|
_: 2
|
|
109
109
|
}, 1032, ["for"])) : c("", !0),
|
|
110
110
|
K("div", {
|
|
111
|
-
class:
|
|
111
|
+
class: m(["relative", ["switch", "check"].includes(e.type) ? "w-auto" : "w-full"]),
|
|
112
112
|
onFocusin: (i) => T(e.name),
|
|
113
113
|
onFocusout: (i) => S(e.name)
|
|
114
114
|
}, [
|
|
115
|
-
b(e) && N(e) && !V(e) ? (s(),
|
|
115
|
+
b(e) && N(e) && !V(e) ? (s(), o("label", {
|
|
116
116
|
key: 0,
|
|
117
117
|
for: e.name,
|
|
118
|
-
class:
|
|
118
|
+
class: m([
|
|
119
119
|
"absolute transition-all duration-200 ease-in-out pointer-events-none z-20",
|
|
120
120
|
C(e) ? "-top-2.5 left-3 text-xs bg-background px-1 text-black shadow-[0_4px_4px_-4px_bg-background]" : `top-1/2 -translate-y-1/2 text-sm text-muted-foreground/70 ${H(e)}`
|
|
121
121
|
])
|
|
122
122
|
}, [
|
|
123
|
-
R(
|
|
124
|
-
k(
|
|
125
|
-
e.required ? (s(),
|
|
123
|
+
R(p)(u(e)) ? (s(), h(z(w(u(e))), { key: 0 })) : (s(), o(y, { key: 1 }, [
|
|
124
|
+
k(v(u(e)) + " ", 1),
|
|
125
|
+
e.required ? (s(), o("span", te, "*")) : c("", !0)
|
|
126
126
|
], 64))
|
|
127
127
|
], 10, ee)) : c("", !0),
|
|
128
128
|
P(X, {
|
|
129
|
-
field:
|
|
129
|
+
field: r.variant === "floating" ? {
|
|
130
130
|
...e,
|
|
131
131
|
placeholder: void 0,
|
|
132
132
|
placeholderI18n: void 0,
|
|
@@ -136,6 +136,7 @@ const Z = {
|
|
|
136
136
|
floatingActive: C(e),
|
|
137
137
|
label: e.type === "customFields" ? void 0 : b(e) ? N(e) : void 0,
|
|
138
138
|
values: a.values,
|
|
139
|
+
errors: a.errors,
|
|
139
140
|
variant: a.variant,
|
|
140
141
|
size: a.size,
|
|
141
142
|
rounded: a.rounded,
|
|
@@ -144,10 +145,10 @@ const Z = {
|
|
|
144
145
|
error: l(e),
|
|
145
146
|
isUpdate: a.isUpdate,
|
|
146
147
|
loading: a.fieldLoading[e.name],
|
|
147
|
-
onChange: (i) =>
|
|
148
|
+
onChange: (i) => $(e, i),
|
|
148
149
|
onAddonChange: I,
|
|
149
150
|
onAddonAction: E
|
|
150
|
-
}, null, 8, ["field", "value", "floatingActive", "label", "values", "variant", "size", "rounded", "disabled", "readonly", "error", "isUpdate", "loading", "onChange"])
|
|
151
|
+
}, null, 8, ["field", "value", "floatingActive", "label", "values", "errors", "variant", "size", "rounded", "disabled", "readonly", "error", "isUpdate", "loading", "onChange"])
|
|
151
152
|
], 42, _),
|
|
152
153
|
u(e) && (e.type === "switch" || e.type === "check") ? (s(), h(U, {
|
|
153
154
|
key: 1,
|
|
@@ -155,12 +156,12 @@ const Z = {
|
|
|
155
156
|
class: "ml-2 text-sm font-medium cursor-pointer"
|
|
156
157
|
}, {
|
|
157
158
|
default: L(() => [
|
|
158
|
-
k(
|
|
159
|
-
e.required ? (s(),
|
|
159
|
+
k(v(u(e)) + " ", 1),
|
|
160
|
+
e.required ? (s(), o("span", ne, "*")) : c("", !0)
|
|
160
161
|
]),
|
|
161
162
|
_: 2
|
|
162
163
|
}, 1032, ["for"])) : c("", !0),
|
|
163
|
-
l(e) ? (s(),
|
|
164
|
+
l(e) ? (s(), o("p", ae, v(l(e)), 1)) : c("", !0)
|
|
164
165
|
], 2)), n, 0) : c("", !0)
|
|
165
166
|
], 64))), 128))
|
|
166
167
|
], 2));
|
|
@@ -22,7 +22,7 @@ export interface UseFormReturn {
|
|
|
22
22
|
/** Handle field value change */
|
|
23
23
|
handleFieldChange: (name: string, value: any, data?: any) => Promise<void>;
|
|
24
24
|
/** Validate a single field */
|
|
25
|
-
validateField: (field: IForm) => Promise<string>;
|
|
25
|
+
validateField: (field: IForm, basePath?: string) => Promise<string>;
|
|
26
26
|
/** Validate all fields */
|
|
27
27
|
validateAll: () => Promise<boolean>;
|
|
28
28
|
/** Check if field is visible */
|