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