@teamnovu/kit-vue-forms 0.2.18 → 0.3.0
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/CHANGELOG.md +16 -0
- package/dist/components/Field.vue.d.ts +4 -1
- package/dist/composables/useFieldRegistry.d.ts +2 -1
- package/dist/composables/useInitialDataOverride.d.ts +13 -0
- package/dist/index.js +489 -439
- package/dist/types/form.d.ts +15 -1
- package/dist/utils/path.d.ts +1 -0
- package/docs/reference.md +65 -0
- package/package.json +1 -1
- package/src/composables/useField.ts +10 -19
- package/src/composables/useFieldArray.ts +16 -0
- package/src/composables/useFieldRegistry.ts +33 -10
- package/src/composables/useForm.ts +4 -2
- package/src/composables/useInitialDataOverride.ts +130 -0
- package/src/types/form.ts +18 -1
- package/src/utils/path.ts +11 -0
- package/tests/formState.test.ts +6 -3
- package/tests/initialDataOverride.test.ts +479 -0
- package/tests/useFieldArray.test.ts +112 -0
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { toValue as J, toRaw as
|
|
5
|
-
import { cloneDeep as
|
|
1
|
+
var ne = Object.defineProperty;
|
|
2
|
+
var oe = (r, e, t) => e in r ? ne(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var A = (r, e, t) => oe(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { toValue as J, toRaw as ie, shallowRef as G, watch as b, isRef as x, unref as m, computed as p, reactive as k, toRefs as Z, shallowReactive as q, toRef as M, onScopeDispose as le, triggerRef as ce, ref as Q, getCurrentScope as ue, onBeforeUnmount as de, defineComponent as _, renderSlot as C, normalizeProps as W, guardReactiveProps as N, createBlock as K, openBlock as L, withCtx as B, resolveDynamicComponent as fe, mergeProps as he, createSlots as ve, renderList as me } from "vue";
|
|
5
|
+
import { cloneDeep as pe, merge as X, omit as ye } from "lodash-es";
|
|
6
6
|
function D(r) {
|
|
7
|
-
const
|
|
8
|
-
return
|
|
7
|
+
const e = J(r), t = ie(e);
|
|
8
|
+
return pe(t);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function Fe(r) {
|
|
11
11
|
return r.filter(
|
|
12
|
-
(
|
|
12
|
+
(e, t, a) => a.indexOf(e) === t
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return r.slice(1).reduce((
|
|
17
|
-
if (!
|
|
15
|
+
function Y(...r) {
|
|
16
|
+
return r.slice(1).reduce((e, t) => {
|
|
17
|
+
if (!e && !t)
|
|
18
18
|
return;
|
|
19
|
-
const a = ((
|
|
20
|
-
if (!
|
|
21
|
-
return e;
|
|
22
|
-
if (!a)
|
|
19
|
+
const a = ((t == null ? void 0 : t.length) ?? 0) > 0;
|
|
20
|
+
if (!e && ((t == null ? void 0 : t.length) ?? 0) > 0)
|
|
23
21
|
return t;
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
if (!a)
|
|
23
|
+
return e;
|
|
24
|
+
const n = (e ?? []).concat(t);
|
|
25
|
+
return Fe(n);
|
|
26
26
|
}, r[0]) ?? [];
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return r.map((
|
|
30
|
-
const
|
|
28
|
+
function ge(...r) {
|
|
29
|
+
return r.map((t) => Object.keys(t)).flat().reduce((t, a) => {
|
|
30
|
+
const n = r.map((o) => o[a]).filter((o) => !!o);
|
|
31
31
|
return {
|
|
32
|
-
...
|
|
33
|
-
[a]:
|
|
32
|
+
...t,
|
|
33
|
+
[a]: Y(t[a], ...n)
|
|
34
34
|
};
|
|
35
35
|
}, {});
|
|
36
36
|
}
|
|
@@ -40,156 +40,166 @@ function j(...r) {
|
|
|
40
40
|
general: [],
|
|
41
41
|
propertyErrors: {}
|
|
42
42
|
};
|
|
43
|
-
const
|
|
44
|
-
return r.length === 1 ?
|
|
45
|
-
(
|
|
46
|
-
general:
|
|
47
|
-
propertyErrors:
|
|
43
|
+
const e = r[0];
|
|
44
|
+
return r.length === 1 ? e : r.slice(1).reduce(
|
|
45
|
+
(t, a) => ({
|
|
46
|
+
general: Y(t.general, a.general),
|
|
47
|
+
propertyErrors: ge(t.propertyErrors ?? {}, a.propertyErrors ?? {})
|
|
48
48
|
}),
|
|
49
|
-
|
|
49
|
+
e
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function ee(r) {
|
|
53
53
|
var a;
|
|
54
|
-
const
|
|
55
|
-
return
|
|
54
|
+
const e = (((a = r.general) == null ? void 0 : a.length) ?? 0) > 0, t = Object.entries(r.propertyErrors).filter(([, n]) => n == null ? void 0 : n.length).length > 0;
|
|
55
|
+
return e || t;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
return !
|
|
57
|
+
function T(r) {
|
|
58
|
+
return !ee(r.errors);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
return (
|
|
62
|
-
if (a == null || a.preventDefault(),
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
60
|
+
function te(r, e) {
|
|
61
|
+
return (t) => async (a) => {
|
|
62
|
+
if (a == null || a.preventDefault(), e.canValidate("validateOnSubmit")) {
|
|
63
|
+
const n = await r.validateForm();
|
|
64
|
+
if (!T(n))
|
|
65
65
|
return;
|
|
66
|
-
const
|
|
67
|
-
await
|
|
66
|
+
const o = n.data ?? r.data.value;
|
|
67
|
+
await t(o);
|
|
68
68
|
} else
|
|
69
|
-
await
|
|
69
|
+
await t(r.data.value);
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
class
|
|
73
|
-
constructor(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.hashFn =
|
|
72
|
+
class Ve {
|
|
73
|
+
constructor(e = (t) => t) {
|
|
74
|
+
A(this, "weakMap", /* @__PURE__ */ new WeakMap());
|
|
75
|
+
A(this, "map", /* @__PURE__ */ new Map());
|
|
76
|
+
A(this, "hashFn");
|
|
77
|
+
this.hashFn = e;
|
|
78
78
|
}
|
|
79
|
-
isReferenceType(
|
|
80
|
-
return typeof
|
|
79
|
+
isReferenceType(e) {
|
|
80
|
+
return typeof e == "object" && e !== null;
|
|
81
81
|
}
|
|
82
|
-
has(
|
|
83
|
-
const
|
|
84
|
-
return this.isReferenceType(
|
|
82
|
+
has(e) {
|
|
83
|
+
const t = this.hashFn(e);
|
|
84
|
+
return this.isReferenceType(t) ? this.weakMap.has(t) : this.map.has(t);
|
|
85
85
|
}
|
|
86
|
-
get(
|
|
87
|
-
const
|
|
88
|
-
return this.isReferenceType(
|
|
86
|
+
get(e) {
|
|
87
|
+
const t = this.hashFn(e);
|
|
88
|
+
return this.isReferenceType(t) ? this.weakMap.get(t) : this.map.get(t);
|
|
89
89
|
}
|
|
90
|
-
set(
|
|
91
|
-
const a = this.hashFn(
|
|
92
|
-
this.isReferenceType(a) ? this.weakMap.set(a,
|
|
90
|
+
set(e, t) {
|
|
91
|
+
const a = this.hashFn(e);
|
|
92
|
+
this.isReferenceType(a) ? this.weakMap.set(a, t) : this.map.set(a, t);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function we(r, e, t) {
|
|
96
96
|
const a = /* @__PURE__ */ new Set();
|
|
97
|
-
return
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
return a.add(
|
|
101
|
-
id:
|
|
102
|
-
item:
|
|
103
|
-
path: `${
|
|
97
|
+
return e.map((n, o) => {
|
|
98
|
+
const i = [...r.get(n) ?? []], d = i.findIndex((v) => !a.has(v)), h = (d === -1 ? [] : i.slice(d))[0];
|
|
99
|
+
if (h)
|
|
100
|
+
return a.add(h), {
|
|
101
|
+
id: h,
|
|
102
|
+
item: n,
|
|
103
|
+
path: `${t}.${o}`
|
|
104
104
|
};
|
|
105
|
-
const
|
|
106
|
-
return r.set(
|
|
107
|
-
id:
|
|
108
|
-
item:
|
|
109
|
-
path: `${
|
|
105
|
+
const l = crypto.randomUUID();
|
|
106
|
+
return r.set(n, i.concat([l])), a.add(l), {
|
|
107
|
+
id: l,
|
|
108
|
+
item: n,
|
|
109
|
+
path: `${t}.${o}`
|
|
110
110
|
};
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
const a = new
|
|
113
|
+
function re(r, e, t) {
|
|
114
|
+
const a = new Ve(t == null ? void 0 : t.hashFn), n = r.getField(e), o = G([]);
|
|
115
115
|
return b(
|
|
116
|
-
|
|
116
|
+
n.data,
|
|
117
117
|
(l) => {
|
|
118
|
-
|
|
118
|
+
o.value = we(a, l, e);
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
121
|
immediate: !0,
|
|
122
122
|
flush: "sync"
|
|
123
123
|
}
|
|
124
124
|
), {
|
|
125
|
-
items:
|
|
125
|
+
items: o,
|
|
126
126
|
push: (l) => {
|
|
127
|
-
const
|
|
128
|
-
return
|
|
127
|
+
const v = n.data.value ?? [];
|
|
128
|
+
return n.setData([...v, l]), o.value.at(-1);
|
|
129
|
+
},
|
|
130
|
+
pushPristine: (l) => {
|
|
131
|
+
const v = n.data.value ?? [], c = v.length;
|
|
132
|
+
n.setData([...v, l]);
|
|
133
|
+
const s = `${e}.${c}`;
|
|
134
|
+
return r.getField(s).setInitialData(l, { scope: "subtree" }), o.value.at(-1);
|
|
129
135
|
},
|
|
130
136
|
remove: (l) => {
|
|
131
|
-
const
|
|
132
|
-
({ id:
|
|
137
|
+
const v = n.data.value ?? [], c = o.value.findIndex(
|
|
138
|
+
({ id: s }) => s === l
|
|
133
139
|
);
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
c !== -1 && n.setData(
|
|
141
|
+
v.slice(0, c).concat(v.slice(c + 1))
|
|
136
142
|
);
|
|
137
143
|
},
|
|
138
|
-
insert: (l,
|
|
139
|
-
const
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
),
|
|
144
|
+
insert: (l, v) => {
|
|
145
|
+
const c = n.data.value ?? [];
|
|
146
|
+
return n.setData(
|
|
147
|
+
c.slice(0, v).concat([l]).concat(c.slice(v))
|
|
148
|
+
), o.value[v];
|
|
143
149
|
},
|
|
144
|
-
field:
|
|
150
|
+
field: n
|
|
145
151
|
};
|
|
146
152
|
}
|
|
147
153
|
function H(r) {
|
|
148
154
|
return r === "" ? [] : r.split(/\s*\.\s*/).filter(Boolean);
|
|
149
155
|
}
|
|
150
|
-
function
|
|
151
|
-
const
|
|
152
|
-
return
|
|
156
|
+
function Ee(r, e) {
|
|
157
|
+
const t = Array.isArray(e) ? e : H(e);
|
|
158
|
+
return !!O(r, t.slice(0, -1));
|
|
153
159
|
}
|
|
154
|
-
function
|
|
155
|
-
return (Array.isArray(
|
|
156
|
-
(a,
|
|
160
|
+
function O(r, e) {
|
|
161
|
+
return (Array.isArray(e) ? e : H(e)).reduce(
|
|
162
|
+
(a, n) => a == null ? void 0 : a[n],
|
|
157
163
|
r
|
|
158
164
|
);
|
|
159
165
|
}
|
|
160
|
-
function
|
|
161
|
-
const a = Array.isArray(
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
(
|
|
166
|
+
function ae(r, e, t) {
|
|
167
|
+
const a = Array.isArray(e) ? e : H(e), n = a.at(-1);
|
|
168
|
+
if (n) {
|
|
169
|
+
const o = a.slice(0, -1).reduce(
|
|
170
|
+
(i, d) => ((i == null ? void 0 : i[d]) === void 0 && (i[d] = {}), i == null ? void 0 : i[d]),
|
|
165
171
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
-
|
|
172
|
+
m(r)
|
|
167
173
|
);
|
|
168
|
-
n
|
|
174
|
+
o[n] = t;
|
|
169
175
|
} else {
|
|
170
176
|
if (!x(r))
|
|
171
177
|
return;
|
|
172
|
-
r.value =
|
|
178
|
+
r.value = t;
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
|
-
const
|
|
181
|
+
const se = (r, e) => p({
|
|
176
182
|
get() {
|
|
177
|
-
return
|
|
183
|
+
return O(m(r), m(e));
|
|
178
184
|
},
|
|
179
|
-
set(
|
|
180
|
-
|
|
185
|
+
set(t) {
|
|
186
|
+
ae(r, m(e), t);
|
|
181
187
|
}
|
|
182
188
|
});
|
|
183
|
-
function
|
|
184
|
-
return !r && !
|
|
189
|
+
function $(r, e) {
|
|
190
|
+
return !r && !e ? "" : !r && e ? e : !e && r ? r : `${r}.${e}`;
|
|
191
|
+
}
|
|
192
|
+
function De(r, e) {
|
|
193
|
+
for (const t of [...r.keys()])
|
|
194
|
+
(t === e || e === "" || t.startsWith(e + ".")) && r.delete(t);
|
|
185
195
|
}
|
|
186
|
-
function
|
|
187
|
-
if (!
|
|
196
|
+
function Re(r, e) {
|
|
197
|
+
if (!e)
|
|
188
198
|
return r;
|
|
189
|
-
const
|
|
190
|
-
Object.entries(r.propertyErrors).filter(([
|
|
191
|
-
|
|
192
|
-
|
|
199
|
+
const t = `${e}.`, a = Object.fromEntries(
|
|
200
|
+
Object.entries(r.propertyErrors).filter(([n]) => n.startsWith(t)).map(([n, o]) => [
|
|
201
|
+
n.slice(t.length),
|
|
202
|
+
o
|
|
193
203
|
])
|
|
194
204
|
);
|
|
195
205
|
return {
|
|
@@ -198,10 +208,10 @@ function Ee(r, t) {
|
|
|
198
208
|
propertyErrors: a
|
|
199
209
|
};
|
|
200
210
|
}
|
|
201
|
-
class
|
|
202
|
-
constructor(
|
|
203
|
-
|
|
204
|
-
this.drop =
|
|
211
|
+
class Se {
|
|
212
|
+
constructor(e) {
|
|
213
|
+
A(this, "rc", 1);
|
|
214
|
+
this.drop = e;
|
|
205
215
|
}
|
|
206
216
|
inc() {
|
|
207
217
|
this.rc += 1;
|
|
@@ -210,170 +220,210 @@ class Re {
|
|
|
210
220
|
this.rc > 0 && (this.rc -= 1, this.rc === 0 && this.drop && this.drop());
|
|
211
221
|
}
|
|
212
222
|
}
|
|
213
|
-
function
|
|
214
|
-
const
|
|
223
|
+
function be(r) {
|
|
224
|
+
const t = {
|
|
215
225
|
...{
|
|
216
226
|
existsInForm: !0
|
|
217
227
|
},
|
|
218
228
|
...r
|
|
219
|
-
}, a =
|
|
220
|
-
value:
|
|
221
|
-
path:
|
|
222
|
-
initialValue:
|
|
223
|
-
errors:
|
|
229
|
+
}, a = k({
|
|
230
|
+
value: t.value,
|
|
231
|
+
path: t.path,
|
|
232
|
+
initialValue: t.initialValue,
|
|
233
|
+
errors: t.errors,
|
|
224
234
|
touched: !1
|
|
225
235
|
});
|
|
226
|
-
b(
|
|
227
|
-
|
|
228
|
-
()
|
|
229
|
-
a.value = Object.freeze(D(e.initialValue)), s.value !== h(e.initialValue) && (s.value = D(e.initialValue));
|
|
230
|
-
},
|
|
231
|
-
{ flush: "sync" }
|
|
232
|
-
), b(() => s.value, (f) => {
|
|
233
|
-
var E;
|
|
234
|
-
(E = r.onChange) == null || E.call(r, f);
|
|
236
|
+
b(() => a.value, (s) => {
|
|
237
|
+
var u;
|
|
238
|
+
(u = r.onChange) == null || u.call(r, s);
|
|
235
239
|
}, { deep: !0 });
|
|
236
|
-
const n =
|
|
237
|
-
|
|
238
|
-
}, v = () => {
|
|
239
|
-
var f;
|
|
240
|
-
s.touched = !0, s.errors = [], (f = e.onBlur) == null || f.call(e);
|
|
241
|
-
}, y = () => {
|
|
242
|
-
var f;
|
|
243
|
-
(f = e.onFocus) == null || f.call(e);
|
|
244
|
-
}, l = () => {
|
|
245
|
-
const f = s.path.split(".").at(-1) || "";
|
|
246
|
-
h(e.existsInForm) && !/^\d+$/.test(f) && (s.value = D(s.initialValue)), s.touched = !1, s.errors = [];
|
|
247
|
-
}, d = (f) => {
|
|
248
|
-
n.value || c(D(f)), s.initialValue = f;
|
|
249
|
-
}, F = (f) => {
|
|
250
|
-
s.errors = f;
|
|
240
|
+
const n = p(() => JSON.stringify(a.value) !== JSON.stringify(D(a.initialValue))), o = (s) => {
|
|
241
|
+
a.value = s;
|
|
251
242
|
}, i = () => {
|
|
252
|
-
s
|
|
253
|
-
|
|
243
|
+
var s;
|
|
244
|
+
a.touched = !0, a.errors = [], (s = t.onBlur) == null || s.call(t);
|
|
245
|
+
}, d = () => {
|
|
246
|
+
var s;
|
|
247
|
+
(s = t.onFocus) == null || s.call(t);
|
|
248
|
+
}, y = () => {
|
|
249
|
+
const s = a.path.split(".").at(-1) || "";
|
|
250
|
+
m(t.existsInForm) && !/^\d+$/.test(s) && (a.value = D(a.initialValue)), a.touched = !1, a.errors = [];
|
|
251
|
+
}, h = (s, u) => {
|
|
252
|
+
n.value || o(D(s)), a.initialValue = s;
|
|
253
|
+
}, l = (s) => {
|
|
254
|
+
a.errors = s;
|
|
255
|
+
}, v = () => {
|
|
256
|
+
a.errors = [];
|
|
257
|
+
}, c = Z(a);
|
|
254
258
|
return {
|
|
255
|
-
data:
|
|
256
|
-
path:
|
|
257
|
-
initialValue:
|
|
258
|
-
errors:
|
|
259
|
-
touched:
|
|
259
|
+
data: c.value,
|
|
260
|
+
path: c.path,
|
|
261
|
+
initialValue: c.initialValue,
|
|
262
|
+
errors: c.errors,
|
|
263
|
+
touched: c.touched,
|
|
260
264
|
dirty: n,
|
|
261
|
-
setData:
|
|
262
|
-
setInitialData:
|
|
263
|
-
onBlur:
|
|
264
|
-
onFocus:
|
|
265
|
-
reset:
|
|
266
|
-
setErrors:
|
|
267
|
-
clearErrors:
|
|
265
|
+
setData: o,
|
|
266
|
+
setInitialData: h,
|
|
267
|
+
onBlur: i,
|
|
268
|
+
onFocus: d,
|
|
269
|
+
reset: y,
|
|
270
|
+
setErrors: l,
|
|
271
|
+
clearErrors: v
|
|
268
272
|
};
|
|
269
273
|
}
|
|
270
|
-
const
|
|
274
|
+
const Pe = {
|
|
271
275
|
keepValuesOnUnmount: !0
|
|
272
276
|
};
|
|
273
|
-
function
|
|
274
|
-
const
|
|
277
|
+
function Ie(r, e) {
|
|
278
|
+
const a = G(r.resolveAt(e));
|
|
275
279
|
return b(
|
|
276
|
-
() => r.
|
|
277
|
-
() => {
|
|
278
|
-
a.value =
|
|
280
|
+
() => r.resolveAt(e),
|
|
281
|
+
(n) => {
|
|
282
|
+
a.value = n, ce(a);
|
|
279
283
|
},
|
|
280
284
|
{ flush: "sync" }
|
|
281
285
|
), a;
|
|
282
286
|
}
|
|
283
|
-
function
|
|
284
|
-
const
|
|
285
|
-
...
|
|
286
|
-
...
|
|
287
|
-
},
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
var
|
|
292
|
-
|
|
293
|
-
},
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
}, l = (
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
},
|
|
300
|
-
var
|
|
301
|
-
const { path:
|
|
302
|
-
if (!
|
|
303
|
-
const
|
|
304
|
-
path:
|
|
305
|
-
value:
|
|
306
|
-
initialValue:
|
|
307
|
-
existsInForm:
|
|
308
|
-
errors:
|
|
287
|
+
function Ae(r, e, t, a) {
|
|
288
|
+
const n = /* @__PURE__ */ new Map(), o = q(/* @__PURE__ */ new Map()), i = {
|
|
289
|
+
...Pe,
|
|
290
|
+
...a
|
|
291
|
+
}, d = (s) => {
|
|
292
|
+
const u = m(s.path);
|
|
293
|
+
o.set(u, s);
|
|
294
|
+
}, y = (s) => {
|
|
295
|
+
var u;
|
|
296
|
+
m((i == null ? void 0 : i.keepValuesOnUnmount) ?? !0) || (u = o.get(s)) == null || u.reset(), o.delete(s);
|
|
297
|
+
}, h = (s) => {
|
|
298
|
+
var u;
|
|
299
|
+
n.has(s) ? (u = n.get(s)) == null || u.inc() : n.set(s, new Se(() => y(s)));
|
|
300
|
+
}, l = (s) => {
|
|
301
|
+
var u;
|
|
302
|
+
n.has(s) && ((u = n.get(s)) == null || u.dec());
|
|
303
|
+
}, v = (s) => {
|
|
304
|
+
var V;
|
|
305
|
+
const { path: u } = s;
|
|
306
|
+
if (!o.has(u)) {
|
|
307
|
+
const I = be({
|
|
308
|
+
path: u,
|
|
309
|
+
value: se(M(r, "data"), u),
|
|
310
|
+
initialValue: Ie(t, u),
|
|
311
|
+
existsInForm: p(() => Ee(r.data, m(u))),
|
|
312
|
+
errors: p({
|
|
309
313
|
get() {
|
|
310
|
-
return
|
|
314
|
+
return e.errors.value.propertyErrors[u] || [];
|
|
311
315
|
},
|
|
312
|
-
set(
|
|
313
|
-
|
|
316
|
+
set(g) {
|
|
317
|
+
e.errors.value.propertyErrors[u] = g;
|
|
314
318
|
}
|
|
315
319
|
}),
|
|
316
320
|
onBlur: async () => {
|
|
317
|
-
var
|
|
321
|
+
var g, w;
|
|
318
322
|
await Promise.all([
|
|
319
|
-
(
|
|
320
|
-
(
|
|
323
|
+
(g = i == null ? void 0 : i.onBlur) == null ? void 0 : g.call(i, m(u)),
|
|
324
|
+
(w = s.onBlur) == null ? void 0 : w.call(s)
|
|
321
325
|
]);
|
|
322
326
|
},
|
|
323
327
|
onFocus: async () => {
|
|
324
|
-
var
|
|
328
|
+
var g, w;
|
|
325
329
|
await Promise.all([
|
|
326
|
-
(
|
|
327
|
-
(
|
|
330
|
+
(g = i == null ? void 0 : i.onFocus) == null ? void 0 : g.call(i, m(u)),
|
|
331
|
+
(w = s.onFocus) == null ? void 0 : w.call(s)
|
|
328
332
|
]);
|
|
329
333
|
},
|
|
330
|
-
onChange: async (
|
|
331
|
-
var
|
|
334
|
+
onChange: async (g) => {
|
|
335
|
+
var w, R;
|
|
332
336
|
await Promise.all([
|
|
333
|
-
(
|
|
334
|
-
(
|
|
337
|
+
(w = i == null ? void 0 : i.onChange) == null ? void 0 : w.call(i, m(u), g),
|
|
338
|
+
(R = s.onChange) == null ? void 0 : R.call(s, g)
|
|
335
339
|
]);
|
|
336
340
|
}
|
|
337
341
|
});
|
|
338
|
-
|
|
342
|
+
I.setInitialData = (g, w) => {
|
|
343
|
+
const R = I.dirty.value;
|
|
344
|
+
t.set(u, g, w), R || I.setData(D(g));
|
|
345
|
+
}, d(I);
|
|
339
346
|
}
|
|
340
|
-
const
|
|
341
|
-
return
|
|
342
|
-
l(
|
|
343
|
-
}), (
|
|
344
|
-
},
|
|
347
|
+
const P = o.get(u);
|
|
348
|
+
return h(u), le(() => {
|
|
349
|
+
l(u);
|
|
350
|
+
}), (V = i.onRegistered) == null || V.call(i, u, P), P;
|
|
351
|
+
}, c = (s) => v(s);
|
|
345
352
|
return {
|
|
346
|
-
fields:
|
|
347
|
-
getField: (
|
|
348
|
-
registerField:
|
|
349
|
-
deregisterField:
|
|
350
|
-
defineField:
|
|
353
|
+
fields: p(() => [...o.values()]),
|
|
354
|
+
getField: (s) => v({ path: s }),
|
|
355
|
+
registerField: d,
|
|
356
|
+
deregisterField: y,
|
|
357
|
+
defineField: c
|
|
351
358
|
};
|
|
352
359
|
}
|
|
353
|
-
function
|
|
354
|
-
const
|
|
360
|
+
function Oe(r) {
|
|
361
|
+
const e = p(() => r.fields.value.some((a) => m(a.dirty))), t = p(() => r.fields.value.some((a) => m(a.touched)));
|
|
355
362
|
return {
|
|
356
|
-
isDirty:
|
|
357
|
-
isTouched:
|
|
363
|
+
isDirty: e,
|
|
364
|
+
isTouched: t
|
|
358
365
|
};
|
|
359
366
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
367
|
+
const z = (r) => {
|
|
368
|
+
if (r === null || typeof r != "object") return !1;
|
|
369
|
+
const e = Object.getPrototypeOf(r);
|
|
370
|
+
return e === Object.prototype || e === null;
|
|
371
|
+
}, $e = (r, e) => e === "" ? r !== "" : r.startsWith(e + ".");
|
|
372
|
+
function Ce(r) {
|
|
373
|
+
const e = q(/* @__PURE__ */ new Map()), t = (o) => {
|
|
374
|
+
const i = D(r), d = [...e.entries()].sort(
|
|
375
|
+
([y], [h]) => y.split(".").length - h.split(".").length
|
|
376
|
+
);
|
|
377
|
+
for (const [y, h] of d) {
|
|
378
|
+
if (o !== void 0 && h.scope === "subtree" && $e(y, o))
|
|
379
|
+
continue;
|
|
380
|
+
const l = y, v = O(i, l), c = h.replace || !z(h.value) || !z(v) ? h.value : X({}, v, h.value);
|
|
381
|
+
ae(
|
|
382
|
+
i,
|
|
383
|
+
l,
|
|
384
|
+
c
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
return i;
|
|
388
|
+
}, a = p(() => t()), n = (o) => {
|
|
389
|
+
const i = t(o);
|
|
390
|
+
return o === "" ? i : O(i, o);
|
|
391
|
+
};
|
|
392
|
+
return b(
|
|
393
|
+
r,
|
|
394
|
+
() => {
|
|
395
|
+
e.clear();
|
|
396
|
+
},
|
|
397
|
+
{ flush: "sync" }
|
|
398
|
+
), {
|
|
399
|
+
effectiveInitialData: a,
|
|
400
|
+
resolveAt: n,
|
|
401
|
+
set(o, i, d) {
|
|
402
|
+
De(e, o), e.set(o, {
|
|
403
|
+
value: i,
|
|
404
|
+
replace: (d == null ? void 0 : d.replace) ?? !1,
|
|
405
|
+
scope: (d == null ? void 0 : d.scope) ?? "tree"
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function ke(r) {
|
|
411
|
+
const e = r.issues.filter((a) => a.path.length === 0).map((a) => a.message), t = r.issues.filter((a) => a.path.length > 0).reduce(
|
|
412
|
+
(a, n) => {
|
|
413
|
+
const o = n.path.join(".");
|
|
364
414
|
return {
|
|
365
415
|
...a,
|
|
366
|
-
[
|
|
416
|
+
[o]: [...a[o] ?? [], n.message]
|
|
367
417
|
};
|
|
368
418
|
},
|
|
369
419
|
{}
|
|
370
420
|
);
|
|
371
421
|
return {
|
|
372
|
-
general:
|
|
373
|
-
propertyErrors:
|
|
422
|
+
general: e,
|
|
423
|
+
propertyErrors: t
|
|
374
424
|
};
|
|
375
425
|
}
|
|
376
|
-
const
|
|
426
|
+
const Be = {
|
|
377
427
|
validationBeforeSubmit: {
|
|
378
428
|
validateOnBlur: !1,
|
|
379
429
|
validateOnFormOpen: !1,
|
|
@@ -388,25 +438,25 @@ const Oe = {
|
|
|
388
438
|
validateOnDataChange: !0,
|
|
389
439
|
validateOnFieldRegister: !0
|
|
390
440
|
}
|
|
391
|
-
},
|
|
441
|
+
}, E = {
|
|
392
442
|
errors: {
|
|
393
443
|
general: [],
|
|
394
444
|
propertyErrors: {}
|
|
395
445
|
}
|
|
396
446
|
};
|
|
397
|
-
class
|
|
398
|
-
constructor(
|
|
399
|
-
this.schema =
|
|
447
|
+
class Me {
|
|
448
|
+
constructor(e) {
|
|
449
|
+
this.schema = e;
|
|
400
450
|
}
|
|
401
|
-
async validate(
|
|
451
|
+
async validate(e) {
|
|
402
452
|
if (!this.schema)
|
|
403
|
-
return
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
return
|
|
407
|
-
const a =
|
|
453
|
+
return E;
|
|
454
|
+
const t = await this.schema.safeParseAsync(e);
|
|
455
|
+
if (t.success)
|
|
456
|
+
return E;
|
|
457
|
+
const a = ke(t.error);
|
|
408
458
|
return {
|
|
409
|
-
data:
|
|
459
|
+
data: t.data,
|
|
410
460
|
errors: {
|
|
411
461
|
general: a.general ?? [],
|
|
412
462
|
propertyErrors: a.propertyErrors ?? {}
|
|
@@ -414,272 +464,272 @@ class Ce {
|
|
|
414
464
|
};
|
|
415
465
|
}
|
|
416
466
|
}
|
|
417
|
-
class
|
|
418
|
-
constructor(
|
|
419
|
-
this.validateFn =
|
|
467
|
+
class je {
|
|
468
|
+
constructor(e) {
|
|
469
|
+
this.validateFn = e;
|
|
420
470
|
}
|
|
421
|
-
async validate(
|
|
471
|
+
async validate(e) {
|
|
422
472
|
if (!this.validateFn)
|
|
423
|
-
return
|
|
473
|
+
return E;
|
|
424
474
|
try {
|
|
425
|
-
const
|
|
426
|
-
return
|
|
427
|
-
} catch (
|
|
475
|
+
const t = await this.validateFn(e);
|
|
476
|
+
return T(t) ? E : t;
|
|
477
|
+
} catch (t) {
|
|
428
478
|
return {
|
|
429
479
|
errors: {
|
|
430
|
-
general: [
|
|
480
|
+
general: [t.message || "Validation error"],
|
|
431
481
|
propertyErrors: {}
|
|
432
482
|
}
|
|
433
483
|
};
|
|
434
484
|
}
|
|
435
485
|
}
|
|
436
486
|
}
|
|
437
|
-
class
|
|
438
|
-
constructor(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
this.schema =
|
|
487
|
+
class Ue {
|
|
488
|
+
constructor(e, t) {
|
|
489
|
+
A(this, "schemaValidator");
|
|
490
|
+
A(this, "functionValidator");
|
|
491
|
+
this.schema = e, this.validateFn = t, this.schemaValidator = new Me(this.schema), this.functionValidator = new je(this.validateFn);
|
|
442
492
|
}
|
|
443
|
-
async validate(
|
|
444
|
-
const [
|
|
445
|
-
this.schemaValidator.validate(
|
|
446
|
-
this.functionValidator.validate(
|
|
493
|
+
async validate(e) {
|
|
494
|
+
const [t, a] = await Promise.all([
|
|
495
|
+
this.schemaValidator.validate(e),
|
|
496
|
+
this.functionValidator.validate(e)
|
|
447
497
|
]);
|
|
448
498
|
return {
|
|
449
|
-
data:
|
|
450
|
-
errors: j(
|
|
499
|
+
data: t.data,
|
|
500
|
+
errors: j(t.errors, a.errors)
|
|
451
501
|
};
|
|
452
502
|
}
|
|
453
503
|
}
|
|
454
|
-
function
|
|
455
|
-
return
|
|
456
|
-
() => new
|
|
457
|
-
|
|
458
|
-
|
|
504
|
+
function U(r) {
|
|
505
|
+
return p(
|
|
506
|
+
() => new Ue(
|
|
507
|
+
m(r.schema),
|
|
508
|
+
m(r.validateFn)
|
|
459
509
|
)
|
|
460
510
|
);
|
|
461
511
|
}
|
|
462
|
-
function
|
|
463
|
-
const
|
|
464
|
-
validators:
|
|
512
|
+
function xe(r, e) {
|
|
513
|
+
const t = k({
|
|
514
|
+
validators: Q([U(e)]),
|
|
465
515
|
isValidated: !1,
|
|
466
|
-
errors:
|
|
467
|
-
}), a = (
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
516
|
+
errors: m(e.errors) ?? E.errors
|
|
517
|
+
}), a = (c = E.errors) => {
|
|
518
|
+
t.errors = j(
|
|
519
|
+
m(e.errors) ?? E.errors,
|
|
520
|
+
c
|
|
471
521
|
);
|
|
472
522
|
};
|
|
473
523
|
b(
|
|
474
|
-
() =>
|
|
524
|
+
() => m(e.errors),
|
|
475
525
|
async () => {
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
a(
|
|
526
|
+
if (t.isValidated) {
|
|
527
|
+
const c = await o();
|
|
528
|
+
a(c.errors);
|
|
479
529
|
} else
|
|
480
530
|
a();
|
|
481
531
|
},
|
|
482
532
|
{ immediate: !0 }
|
|
483
533
|
), b(
|
|
484
|
-
[() =>
|
|
485
|
-
async (
|
|
486
|
-
if (
|
|
487
|
-
if (
|
|
488
|
-
const
|
|
489
|
-
|
|
534
|
+
[() => t.validators],
|
|
535
|
+
async (c) => {
|
|
536
|
+
if (t.isValidated)
|
|
537
|
+
if (c) {
|
|
538
|
+
const s = await o();
|
|
539
|
+
t.errors = s.errors;
|
|
490
540
|
} else
|
|
491
|
-
|
|
541
|
+
t.errors = E.errors;
|
|
492
542
|
},
|
|
493
543
|
{ immediate: !0 }
|
|
494
|
-
), b([() => r.data, () =>
|
|
495
|
-
|
|
544
|
+
), b([() => r.data, () => m(e.schema)], () => {
|
|
545
|
+
t.isValidated && i();
|
|
496
546
|
});
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
return
|
|
500
|
-
|
|
501
|
-
),
|
|
502
|
-
|
|
503
|
-
(
|
|
547
|
+
const n = (c) => {
|
|
548
|
+
const s = x(c) ? c : U(c);
|
|
549
|
+
return t.validators.push(
|
|
550
|
+
s
|
|
551
|
+
), ue() && de(() => {
|
|
552
|
+
t.validators = t.validators.filter(
|
|
553
|
+
(u) => u !== s
|
|
504
554
|
);
|
|
505
|
-
}),
|
|
555
|
+
}), s;
|
|
506
556
|
};
|
|
507
|
-
async function
|
|
508
|
-
var
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
),
|
|
512
|
-
let { errors:
|
|
513
|
-
if (!
|
|
514
|
-
const
|
|
515
|
-
|
|
557
|
+
async function o() {
|
|
558
|
+
var P;
|
|
559
|
+
const c = await Promise.all(
|
|
560
|
+
t.validators.filter((V) => m(V) !== void 0).map((V) => m(V).validate(r.data))
|
|
561
|
+
), s = c.every((V) => T(V));
|
|
562
|
+
let { errors: u } = E;
|
|
563
|
+
if (!s) {
|
|
564
|
+
const V = c.map((I) => I.errors);
|
|
565
|
+
u = j(...V);
|
|
516
566
|
}
|
|
517
567
|
return {
|
|
518
|
-
errors:
|
|
568
|
+
errors: u,
|
|
519
569
|
// TODO: Implement data disambiguation strategy
|
|
520
|
-
data: (
|
|
570
|
+
data: (P = c.findLast((V) => !!V.data)) == null ? void 0 : P.data
|
|
521
571
|
};
|
|
522
572
|
}
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
return a(
|
|
526
|
-
errors:
|
|
573
|
+
const i = async () => {
|
|
574
|
+
const c = await o();
|
|
575
|
+
return a(c.errors), t.isValidated = !0, {
|
|
576
|
+
errors: t.errors
|
|
527
577
|
};
|
|
528
|
-
},
|
|
529
|
-
const
|
|
578
|
+
}, d = async (c) => {
|
|
579
|
+
const s = await o();
|
|
530
580
|
return a({
|
|
531
|
-
general:
|
|
581
|
+
general: s.errors.general,
|
|
532
582
|
propertyErrors: {
|
|
533
|
-
...
|
|
534
|
-
[
|
|
583
|
+
...t.errors.propertyErrors,
|
|
584
|
+
[c]: s.errors.propertyErrors[c] ?? []
|
|
535
585
|
}
|
|
536
586
|
}), {
|
|
537
|
-
data:
|
|
538
|
-
errors:
|
|
587
|
+
data: s.data,
|
|
588
|
+
errors: t.errors
|
|
539
589
|
};
|
|
540
|
-
}, y =
|
|
541
|
-
|
|
542
|
-
},
|
|
543
|
-
const
|
|
544
|
-
return J((
|
|
545
|
-
},
|
|
546
|
-
if (
|
|
547
|
-
return
|
|
590
|
+
}, y = p(() => !ee(t.errors)), h = () => {
|
|
591
|
+
t.isValidated = !1, t.errors = m(e.errors) ?? E.errors;
|
|
592
|
+
}, l = (c) => {
|
|
593
|
+
const s = t.isValidated ? e.validationAfterSubmit : e.validationBeforeSubmit;
|
|
594
|
+
return J((s == null ? void 0 : s[c]) ?? !1);
|
|
595
|
+
}, v = (c, s) => {
|
|
596
|
+
if (l(c))
|
|
597
|
+
return d(s);
|
|
548
598
|
};
|
|
549
599
|
return {
|
|
550
|
-
...
|
|
551
|
-
validateForm:
|
|
552
|
-
validateField:
|
|
553
|
-
validateStrategy:
|
|
554
|
-
canValidate:
|
|
555
|
-
defineValidator:
|
|
600
|
+
...Z(t),
|
|
601
|
+
validateForm: i,
|
|
602
|
+
validateField: d,
|
|
603
|
+
validateStrategy: v,
|
|
604
|
+
canValidate: l,
|
|
605
|
+
defineValidator: n,
|
|
556
606
|
isValid: y,
|
|
557
|
-
reset:
|
|
607
|
+
reset: h
|
|
558
608
|
};
|
|
559
609
|
}
|
|
560
|
-
class
|
|
561
|
-
constructor(
|
|
562
|
-
this.path =
|
|
610
|
+
class _e {
|
|
611
|
+
constructor(e, t) {
|
|
612
|
+
this.path = e, this.validator = t;
|
|
563
613
|
}
|
|
564
|
-
async validate(
|
|
565
|
-
const
|
|
614
|
+
async validate(e) {
|
|
615
|
+
const t = O(e, this.path);
|
|
566
616
|
if (!this.validator)
|
|
567
|
-
return
|
|
568
|
-
const a = await this.validator.validate(
|
|
617
|
+
return E;
|
|
618
|
+
const a = await this.validator.validate(t);
|
|
569
619
|
return {
|
|
570
620
|
errors: {
|
|
571
621
|
general: a.errors.general || [],
|
|
572
622
|
propertyErrors: a.errors.propertyErrors ? Object.fromEntries(
|
|
573
623
|
Object.entries(a.errors.propertyErrors).map(
|
|
574
|
-
([
|
|
624
|
+
([n, o]) => [$(this.path, n), o]
|
|
575
625
|
)
|
|
576
626
|
) : {}
|
|
577
627
|
}
|
|
578
628
|
};
|
|
579
629
|
}
|
|
580
630
|
}
|
|
581
|
-
function
|
|
582
|
-
const
|
|
583
|
-
...
|
|
584
|
-
path:
|
|
585
|
-
setData: (
|
|
586
|
-
|
|
631
|
+
function We(r, e, t, a) {
|
|
632
|
+
const n = se(r.data, e), o = p(() => O(r.initialData.value, e)), i = (f) => ({
|
|
633
|
+
...f,
|
|
634
|
+
path: p(() => m(f.path).replace(e + ".", "")),
|
|
635
|
+
setData: (F) => {
|
|
636
|
+
f.setData(F);
|
|
587
637
|
}
|
|
588
|
-
}),
|
|
589
|
-
const
|
|
590
|
-
return S ?
|
|
591
|
-
}, y = (
|
|
592
|
-
const
|
|
593
|
-
...
|
|
594
|
-
path:
|
|
638
|
+
}), d = (f) => {
|
|
639
|
+
const F = $(e, f), S = r.getField(F);
|
|
640
|
+
return S ? i(S) : {};
|
|
641
|
+
}, y = (f) => {
|
|
642
|
+
const F = $(e, f.path), S = r.defineField({
|
|
643
|
+
...f,
|
|
644
|
+
path: F
|
|
595
645
|
});
|
|
596
|
-
return
|
|
597
|
-
},
|
|
598
|
-
const
|
|
599
|
-
return
|
|
600
|
-
}).map((
|
|
601
|
-
const
|
|
602
|
-
return
|
|
603
|
-
}),
|
|
604
|
-
data:
|
|
605
|
-
fields:
|
|
606
|
-
initialData:
|
|
646
|
+
return i(S);
|
|
647
|
+
}, h = p(() => r.fields.value.filter((f) => {
|
|
648
|
+
const F = f.path.value;
|
|
649
|
+
return F.startsWith(e + ".") || F === e;
|
|
650
|
+
}).map((f) => i(f))), l = () => r.fields.value.filter((f) => {
|
|
651
|
+
const F = f.path.value;
|
|
652
|
+
return F.startsWith(e + ".") || F === e;
|
|
653
|
+
}), v = p(() => l().some((f) => f.dirty.value)), c = p(() => l().some((f) => f.touched.value)), s = p(() => r.isValid.value), u = p(() => r.isValidated.value), P = p(() => Re(m(r.errors), e)), R = {
|
|
654
|
+
data: n,
|
|
655
|
+
fields: h,
|
|
656
|
+
initialData: o,
|
|
607
657
|
defineField: y,
|
|
608
|
-
getField:
|
|
609
|
-
isDirty:
|
|
610
|
-
isTouched:
|
|
611
|
-
isValid:
|
|
612
|
-
isValidated:
|
|
613
|
-
errors:
|
|
614
|
-
defineValidator: (
|
|
615
|
-
const
|
|
616
|
-
() => new
|
|
658
|
+
getField: d,
|
|
659
|
+
isDirty: v,
|
|
660
|
+
isTouched: c,
|
|
661
|
+
isValid: s,
|
|
662
|
+
isValidated: u,
|
|
663
|
+
errors: P,
|
|
664
|
+
defineValidator: (f) => {
|
|
665
|
+
const F = x(f) ? f : U(f), S = p(
|
|
666
|
+
() => new _e(e, m(F))
|
|
617
667
|
);
|
|
618
|
-
return r.defineValidator(S),
|
|
668
|
+
return r.defineValidator(S), F;
|
|
619
669
|
},
|
|
620
|
-
reset: () =>
|
|
670
|
+
reset: () => l().forEach((f) => f.reset()),
|
|
621
671
|
validateForm: () => r.validateForm(),
|
|
622
|
-
getSubForm: (
|
|
623
|
-
const S =
|
|
672
|
+
getSubForm: (f, F) => {
|
|
673
|
+
const S = $(e, f);
|
|
624
674
|
return r.getSubForm(
|
|
625
675
|
S,
|
|
626
|
-
|
|
676
|
+
F
|
|
627
677
|
);
|
|
628
678
|
},
|
|
629
|
-
submitHandler: (
|
|
630
|
-
getFieldArray: (
|
|
679
|
+
submitHandler: (f) => te(R, t)(f),
|
|
680
|
+
getFieldArray: (f, F) => re(R, f, F)
|
|
631
681
|
};
|
|
632
|
-
return
|
|
682
|
+
return R;
|
|
633
683
|
}
|
|
634
|
-
const
|
|
684
|
+
const Ne = {
|
|
635
685
|
keepValuesOnUnmount: !0,
|
|
636
|
-
...
|
|
686
|
+
...Be
|
|
637
687
|
};
|
|
638
|
-
function
|
|
639
|
-
r =
|
|
640
|
-
const
|
|
641
|
-
initialData:
|
|
642
|
-
data:
|
|
688
|
+
function ze(r) {
|
|
689
|
+
r = X({}, Ne, r);
|
|
690
|
+
const e = p(() => D(r.initialData)), t = Ce(e), a = Q(D(e)), n = k({
|
|
691
|
+
initialData: e,
|
|
692
|
+
data: a
|
|
643
693
|
});
|
|
644
694
|
b(
|
|
645
|
-
|
|
695
|
+
e,
|
|
646
696
|
(l) => {
|
|
647
|
-
|
|
697
|
+
n.data = D(l);
|
|
648
698
|
},
|
|
649
699
|
{ flush: "sync" }
|
|
650
700
|
);
|
|
651
|
-
const
|
|
701
|
+
const o = xe(n, r), i = Ae(n, o, t, {
|
|
652
702
|
keepValuesOnUnmount: r.keepValuesOnUnmount,
|
|
653
703
|
onBlur: async (l) => {
|
|
654
|
-
|
|
704
|
+
o.validateStrategy("validateOnBlur", l);
|
|
655
705
|
},
|
|
656
706
|
onChange: async (l) => {
|
|
657
|
-
|
|
707
|
+
o.validateStrategy("validateOnDataChange", l);
|
|
658
708
|
},
|
|
659
709
|
onRegistered: async (l) => {
|
|
660
|
-
|
|
710
|
+
o.validateStrategy("validateOnFieldRegister", l);
|
|
661
711
|
}
|
|
662
|
-
}),
|
|
663
|
-
|
|
664
|
-
for (const l of
|
|
712
|
+
}), d = Oe(i), y = () => {
|
|
713
|
+
a.value = D(t.effectiveInitialData), o.reset();
|
|
714
|
+
for (const l of i.fields.value)
|
|
665
715
|
l.reset();
|
|
666
716
|
};
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
...
|
|
670
|
-
...
|
|
671
|
-
...
|
|
672
|
-
reset:
|
|
673
|
-
initialData:
|
|
674
|
-
data:
|
|
675
|
-
validateForm:
|
|
676
|
-
submitHandler: (l) =>
|
|
677
|
-
getSubForm: (l,
|
|
678
|
-
getFieldArray: (l,
|
|
717
|
+
o.canValidate("validateOnFormOpen") && o.validateForm();
|
|
718
|
+
const h = {
|
|
719
|
+
...i,
|
|
720
|
+
...d,
|
|
721
|
+
...ye(o, ["canValidate", "validateStrategy"]),
|
|
722
|
+
reset: y,
|
|
723
|
+
initialData: M(n, "initialData"),
|
|
724
|
+
data: M(n, "data"),
|
|
725
|
+
validateForm: o.validateForm,
|
|
726
|
+
submitHandler: (l) => te(h, o)(l),
|
|
727
|
+
getSubForm: (l, v) => We(h, l, o),
|
|
728
|
+
getFieldArray: (l, v) => re(h, l, v)
|
|
679
729
|
};
|
|
680
|
-
return
|
|
730
|
+
return h;
|
|
681
731
|
}
|
|
682
|
-
const
|
|
732
|
+
const Te = /* @__PURE__ */ _({
|
|
683
733
|
__name: "Field",
|
|
684
734
|
props: {
|
|
685
735
|
form: {},
|
|
@@ -693,12 +743,12 @@ const _e = /* @__PURE__ */ N({
|
|
|
693
743
|
onChange: { type: Function }
|
|
694
744
|
},
|
|
695
745
|
setup(r) {
|
|
696
|
-
const
|
|
697
|
-
path:
|
|
698
|
-
}), a =
|
|
699
|
-
return (
|
|
746
|
+
const e = r, t = e.form.defineField({
|
|
747
|
+
path: e.path
|
|
748
|
+
}), a = k(t);
|
|
749
|
+
return (n, o) => C(n.$slots, "default", W(N(a)));
|
|
700
750
|
}
|
|
701
|
-
}),
|
|
751
|
+
}), Je = /* @__PURE__ */ _({
|
|
702
752
|
inheritAttrs: !1,
|
|
703
753
|
__name: "FormFieldWrapper",
|
|
704
754
|
props: {
|
|
@@ -708,28 +758,28 @@ const _e = /* @__PURE__ */ N({
|
|
|
708
758
|
path: {}
|
|
709
759
|
},
|
|
710
760
|
setup(r) {
|
|
711
|
-
return (
|
|
761
|
+
return (e, t) => (L(), K(Te, {
|
|
712
762
|
form: r.form,
|
|
713
763
|
path: r.path
|
|
714
764
|
}, {
|
|
715
|
-
default:
|
|
716
|
-
(L(), K(
|
|
717
|
-
"on-blur":
|
|
718
|
-
"on-focus":
|
|
719
|
-
"model-value":
|
|
765
|
+
default: B(({ errors: a, data: n, setData: o, onBlur: i, onFocus: d }) => [
|
|
766
|
+
(L(), K(fe(r.component), he({ ...r.componentProps, ...e.$attrs }, {
|
|
767
|
+
"on-blur": i,
|
|
768
|
+
"on-focus": d,
|
|
769
|
+
"model-value": n,
|
|
720
770
|
errors: a,
|
|
721
771
|
name: r.path,
|
|
722
|
-
"onUpdate:modelValue":
|
|
723
|
-
}),
|
|
724
|
-
default:
|
|
725
|
-
C(
|
|
772
|
+
"onUpdate:modelValue": o
|
|
773
|
+
}), ve({
|
|
774
|
+
default: B(() => [
|
|
775
|
+
C(e.$slots, "default")
|
|
726
776
|
]),
|
|
727
777
|
_: 2
|
|
728
778
|
}, [
|
|
729
|
-
|
|
730
|
-
name:
|
|
731
|
-
fn:
|
|
732
|
-
C(
|
|
779
|
+
me(e.$slots, (y, h) => ({
|
|
780
|
+
name: h,
|
|
781
|
+
fn: B((l) => [
|
|
782
|
+
C(e.$slots, h, W(N(l ?? {})))
|
|
733
783
|
])
|
|
734
784
|
}))
|
|
735
785
|
]), 1040, ["on-blur", "on-focus", "model-value", "errors", "name", "onUpdate:modelValue"]))
|
|
@@ -737,20 +787,20 @@ const _e = /* @__PURE__ */ N({
|
|
|
737
787
|
_: 3
|
|
738
788
|
}, 8, ["form", "path"]));
|
|
739
789
|
}
|
|
740
|
-
}),
|
|
790
|
+
}), Ge = /* @__PURE__ */ _({
|
|
741
791
|
__name: "FormPart",
|
|
742
792
|
props: {
|
|
743
793
|
form: {},
|
|
744
794
|
path: {}
|
|
745
795
|
},
|
|
746
796
|
setup(r) {
|
|
747
|
-
const
|
|
748
|
-
return (a,
|
|
797
|
+
const e = r, t = p(() => e.form.getSubForm(e.path));
|
|
798
|
+
return (a, n) => C(a.$slots, "default", W(N({ subform: t.value })));
|
|
749
799
|
}
|
|
750
800
|
});
|
|
751
801
|
export {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
802
|
+
Te as Field,
|
|
803
|
+
Je as FormFieldWrapper,
|
|
804
|
+
Ge as FormPart,
|
|
805
|
+
ze as useForm
|
|
756
806
|
};
|