@teamnovu/kit-vue-forms 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +143 -142
- package/package.json +1 -1
- package/src/utils/path.ts +6 -4
package/dist/index.js
CHANGED
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
var T = Object.defineProperty;
|
|
2
|
-
var G = (
|
|
3
|
-
var E = (
|
|
4
|
-
import { toValue as L, toRaw as Z, computed as c, unref as d, isRef as
|
|
2
|
+
var G = (t, e, r) => e in t ? T(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var E = (t, e, r) => G(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { toValue as L, toRaw as Z, computed as c, unref as d, isRef as O, reactive as D, toRefs as W, shallowReactive as q, toRef as _, onScopeDispose as H, ref as k, watch as w, getCurrentScope as Q, onBeforeUnmount as X, defineComponent as $, renderSlot as j, normalizeProps as z, guardReactiveProps as B, resolveComponent as Y, createBlock as A, openBlock as C, withCtx as M, resolveDynamicComponent as x, mergeProps as ee } from "vue";
|
|
5
5
|
import { cloneDeep as re } from "lodash-es";
|
|
6
6
|
import "zod";
|
|
7
|
-
function g(
|
|
8
|
-
const e = L(
|
|
9
|
-
return re(
|
|
7
|
+
function g(t) {
|
|
8
|
+
const e = L(t), r = Z(e);
|
|
9
|
+
return re(r);
|
|
10
10
|
}
|
|
11
|
-
function K(
|
|
12
|
-
return
|
|
11
|
+
function K(t) {
|
|
12
|
+
return t === "" ? [] : t.split(/\s*\.\s*/).filter(Boolean);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function P(t, e) {
|
|
15
15
|
return (Array.isArray(e) ? e : K(e)).reduce(
|
|
16
16
|
(s, o) => s == null ? void 0 : s[o],
|
|
17
|
-
|
|
17
|
+
t
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
function te(
|
|
20
|
+
function te(t, e, r) {
|
|
21
21
|
const s = Array.isArray(e) ? e : K(e), o = s.at(-1);
|
|
22
|
-
if (
|
|
23
|
-
r.value = t;
|
|
24
|
-
else if (D(r)) {
|
|
22
|
+
if (o) {
|
|
25
23
|
const n = s.slice(0, -1).reduce(
|
|
26
24
|
(p, h) => p[h],
|
|
27
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
d(
|
|
26
|
+
d(t)
|
|
29
27
|
);
|
|
30
|
-
n[o] =
|
|
31
|
-
} else
|
|
32
|
-
|
|
28
|
+
n[o] = r;
|
|
29
|
+
} else {
|
|
30
|
+
if (!O(t))
|
|
31
|
+
return;
|
|
32
|
+
t.value = r;
|
|
33
|
+
}
|
|
33
34
|
}
|
|
34
|
-
const U = (
|
|
35
|
+
const U = (t, e) => c({
|
|
35
36
|
get() {
|
|
36
|
-
return
|
|
37
|
+
return P(d(t), d(e));
|
|
37
38
|
},
|
|
38
|
-
set(
|
|
39
|
-
te(
|
|
39
|
+
set(r) {
|
|
40
|
+
te(t, d(e), r);
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
|
-
function R(
|
|
43
|
-
return !
|
|
43
|
+
function R(t, e) {
|
|
44
|
+
return !t && !e ? "" : !t && e ? e : !e && t ? t : `${t}.${e}`;
|
|
44
45
|
}
|
|
45
|
-
function se(
|
|
46
|
+
function se(t, e) {
|
|
46
47
|
if (!e)
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
Object.entries(
|
|
50
|
-
([o, n]) => [o.slice(
|
|
48
|
+
return t;
|
|
49
|
+
const r = `${e}.`, s = Object.fromEntries(
|
|
50
|
+
Object.entries(t.propertyErrors).filter(([o]) => o.startsWith(r)).map(
|
|
51
|
+
([o, n]) => [o.slice(r.length), n]
|
|
51
52
|
)
|
|
52
53
|
);
|
|
53
54
|
return {
|
|
54
|
-
general:
|
|
55
|
+
general: t.general,
|
|
55
56
|
// Keep general errors
|
|
56
57
|
propertyErrors: s
|
|
57
58
|
};
|
|
@@ -68,14 +69,14 @@ class ae {
|
|
|
68
69
|
this.rc > 0 && (this.rc -= 1, this.rc === 0 && this.drop && this.drop());
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
function oe(
|
|
72
|
-
const e =
|
|
73
|
-
value:
|
|
74
|
-
path:
|
|
75
|
-
initialValue: c(() => Object.freeze(g(
|
|
76
|
-
errors:
|
|
72
|
+
function oe(t) {
|
|
73
|
+
const e = D({
|
|
74
|
+
value: t.value,
|
|
75
|
+
path: t.path,
|
|
76
|
+
initialValue: c(() => Object.freeze(g(t.initialValue))),
|
|
77
|
+
errors: t.errors,
|
|
77
78
|
touched: !1
|
|
78
|
-
}),
|
|
79
|
+
}), r = c(() => JSON.stringify(e.value) !== JSON.stringify(e.initialValue)), s = (a) => {
|
|
79
80
|
e.value = a;
|
|
80
81
|
}, o = () => {
|
|
81
82
|
e.touched = !0;
|
|
@@ -93,7 +94,7 @@ function oe(r) {
|
|
|
93
94
|
initialValue: i.initialValue,
|
|
94
95
|
errors: i.errors,
|
|
95
96
|
touched: i.touched,
|
|
96
|
-
dirty:
|
|
97
|
+
dirty: r,
|
|
97
98
|
setData: s,
|
|
98
99
|
onBlur: o,
|
|
99
100
|
onFocus: n,
|
|
@@ -102,24 +103,24 @@ function oe(r) {
|
|
|
102
103
|
clearErrors: V
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
|
-
function ne(
|
|
106
|
-
const
|
|
106
|
+
function ne(t, e) {
|
|
107
|
+
const r = /* @__PURE__ */ new Map(), s = q(/* @__PURE__ */ new Map()), o = (a) => {
|
|
107
108
|
const u = d(a.path);
|
|
108
109
|
s.set(u, a);
|
|
109
110
|
}, n = (a) => {
|
|
110
111
|
s.delete(a);
|
|
111
112
|
}, p = (a) => {
|
|
112
113
|
var u;
|
|
113
|
-
|
|
114
|
+
r.has(a) ? (u = r.get(a)) == null || u.inc() : r.set(a, new ae(() => n(a)));
|
|
114
115
|
}, h = (a) => {
|
|
115
116
|
var u;
|
|
116
|
-
|
|
117
|
+
r.has(a) && ((u = r.get(a)) == null || u.dec());
|
|
117
118
|
}, V = (a) => {
|
|
118
119
|
if (!s.has(a)) {
|
|
119
120
|
const v = oe({
|
|
120
121
|
path: a,
|
|
121
|
-
value: U(
|
|
122
|
-
initialValue: c(() =>
|
|
122
|
+
value: U(_(t, "data"), a),
|
|
123
|
+
initialValue: c(() => P(t.initialData, a)),
|
|
123
124
|
errors: c({
|
|
124
125
|
get() {
|
|
125
126
|
return e.errors.value.propertyErrors[a] || [];
|
|
@@ -144,62 +145,62 @@ function ne(r, e) {
|
|
|
144
145
|
defineField: i
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
|
-
function ie(
|
|
148
|
-
const e = c(() =>
|
|
148
|
+
function ie(t) {
|
|
149
|
+
const e = c(() => t.fields.value.some((s) => d(s.dirty))), r = c(() => t.fields.value.some((s) => d(s.touched)));
|
|
149
150
|
return {
|
|
150
151
|
isDirty: e,
|
|
151
|
-
isTouched:
|
|
152
|
+
isTouched: r
|
|
152
153
|
};
|
|
153
154
|
}
|
|
154
|
-
function le(
|
|
155
|
-
return
|
|
156
|
-
(e,
|
|
155
|
+
function le(t) {
|
|
156
|
+
return t.filter(
|
|
157
|
+
(e, r, s) => s.indexOf(e) === r
|
|
157
158
|
);
|
|
158
159
|
}
|
|
159
|
-
function I(...
|
|
160
|
-
return
|
|
161
|
-
if (!e && !
|
|
160
|
+
function I(...t) {
|
|
161
|
+
return t.slice(1).reduce((e, r) => {
|
|
162
|
+
if (!e && !r)
|
|
162
163
|
return;
|
|
163
|
-
const s = ((
|
|
164
|
-
if (!e && ((
|
|
165
|
-
return
|
|
164
|
+
const s = ((r == null ? void 0 : r.length) ?? 0) > 0;
|
|
165
|
+
if (!e && ((r == null ? void 0 : r.length) ?? 0) > 0)
|
|
166
|
+
return r;
|
|
166
167
|
if (!s)
|
|
167
168
|
return e;
|
|
168
|
-
const o = (e ?? []).concat(
|
|
169
|
+
const o = (e ?? []).concat(r);
|
|
169
170
|
return le(o);
|
|
170
|
-
},
|
|
171
|
+
}, t[0]);
|
|
171
172
|
}
|
|
172
|
-
function ce(...
|
|
173
|
-
return
|
|
174
|
-
const o =
|
|
173
|
+
function ce(...t) {
|
|
174
|
+
return t.map((r) => Object.keys(r)).flat().reduce((r, s) => {
|
|
175
|
+
const o = t.map((n) => n[s]).filter(Boolean);
|
|
175
176
|
return {
|
|
176
|
-
...
|
|
177
|
+
...r,
|
|
177
178
|
[s]: I(...o)
|
|
178
179
|
};
|
|
179
180
|
}, {});
|
|
180
181
|
}
|
|
181
|
-
function
|
|
182
|
-
if (!
|
|
182
|
+
function S(...t) {
|
|
183
|
+
if (!t.length)
|
|
183
184
|
return {
|
|
184
185
|
general: [],
|
|
185
186
|
propertyErrors: {}
|
|
186
187
|
};
|
|
187
|
-
const e =
|
|
188
|
-
return
|
|
189
|
-
(
|
|
190
|
-
general: I(
|
|
191
|
-
propertyErrors: ce(
|
|
188
|
+
const e = t[0];
|
|
189
|
+
return t.length === 1 ? e : t.slice(1).reduce(
|
|
190
|
+
(r, s) => ({
|
|
191
|
+
general: I(r.general, s.general),
|
|
192
|
+
propertyErrors: ce(r.propertyErrors ?? {}, s.propertyErrors ?? {})
|
|
192
193
|
}),
|
|
193
194
|
e
|
|
194
195
|
);
|
|
195
196
|
}
|
|
196
|
-
function N(
|
|
197
|
+
function N(t) {
|
|
197
198
|
var s;
|
|
198
|
-
const e = (((s =
|
|
199
|
-
return e ||
|
|
199
|
+
const e = (((s = t.general) == null ? void 0 : s.length) ?? 0) > 0, r = Object.entries(t.propertyErrors).filter(([, o]) => o == null ? void 0 : o.length).length > 0;
|
|
200
|
+
return e || r;
|
|
200
201
|
}
|
|
201
|
-
function ue(
|
|
202
|
-
const e =
|
|
202
|
+
function ue(t) {
|
|
203
|
+
const e = t.issues.filter((s) => s.path.length === 0).map((s) => s.message), r = t.issues.filter((s) => s.path.length > 0).reduce((s, o) => {
|
|
203
204
|
const n = o.path.join(".");
|
|
204
205
|
return {
|
|
205
206
|
...s,
|
|
@@ -208,7 +209,7 @@ function ue(r) {
|
|
|
208
209
|
}, {});
|
|
209
210
|
return {
|
|
210
211
|
general: e,
|
|
211
|
-
propertyErrors:
|
|
212
|
+
propertyErrors: r
|
|
212
213
|
};
|
|
213
214
|
}
|
|
214
215
|
const m = {
|
|
@@ -225,10 +226,10 @@ class de {
|
|
|
225
226
|
async validate(e) {
|
|
226
227
|
if (!this.schema)
|
|
227
228
|
return m;
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
229
|
+
const r = await this.schema.safeParseAsync(e);
|
|
230
|
+
if (r.success)
|
|
230
231
|
return m;
|
|
231
|
-
const s = ue(
|
|
232
|
+
const s = ue(r.error);
|
|
232
233
|
return {
|
|
233
234
|
isValid: !1,
|
|
234
235
|
errors: {
|
|
@@ -246,13 +247,13 @@ class fe {
|
|
|
246
247
|
if (!this.validateFn)
|
|
247
248
|
return m;
|
|
248
249
|
try {
|
|
249
|
-
const
|
|
250
|
-
return
|
|
251
|
-
} catch (
|
|
250
|
+
const r = await this.validateFn(e);
|
|
251
|
+
return r.isValid ? m : r;
|
|
252
|
+
} catch (r) {
|
|
252
253
|
return {
|
|
253
254
|
isValid: !1,
|
|
254
255
|
errors: {
|
|
255
|
-
general: [
|
|
256
|
+
general: [r.message || "Validation error"],
|
|
256
257
|
propertyErrors: {}
|
|
257
258
|
}
|
|
258
259
|
};
|
|
@@ -260,72 +261,72 @@ class fe {
|
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
263
|
class pe {
|
|
263
|
-
constructor(e,
|
|
264
|
+
constructor(e, r) {
|
|
264
265
|
E(this, "schemaValidator");
|
|
265
266
|
E(this, "functionValidator");
|
|
266
|
-
this.schema = e, this.validateFn =
|
|
267
|
+
this.schema = e, this.validateFn = r, this.schemaValidator = new de(this.schema), this.functionValidator = new fe(this.validateFn);
|
|
267
268
|
}
|
|
268
269
|
async validate(e) {
|
|
269
|
-
const [
|
|
270
|
+
const [r, s] = await Promise.all([
|
|
270
271
|
this.schemaValidator.validate(e),
|
|
271
272
|
this.functionValidator.validate(e)
|
|
272
273
|
]);
|
|
273
274
|
return {
|
|
274
|
-
isValid:
|
|
275
|
-
errors:
|
|
275
|
+
isValid: r.isValid && s.isValid,
|
|
276
|
+
errors: S(r.errors, s.errors)
|
|
276
277
|
};
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
|
-
function b(
|
|
280
|
+
function b(t) {
|
|
280
281
|
return c(() => new pe(
|
|
281
|
-
d(
|
|
282
|
-
d(
|
|
282
|
+
d(t.schema),
|
|
283
|
+
d(t.validateFn)
|
|
283
284
|
));
|
|
284
285
|
}
|
|
285
|
-
function he(
|
|
286
|
-
const
|
|
286
|
+
function he(t, e) {
|
|
287
|
+
const r = D({
|
|
287
288
|
validators: k([b(e)]),
|
|
288
289
|
isValidated: !1,
|
|
289
290
|
errors: d(e.errors) ?? m.errors
|
|
290
291
|
}), s = (i = m.errors) => {
|
|
291
|
-
|
|
292
|
+
r.errors = S(d(e.errors) ?? m.errors, i);
|
|
292
293
|
};
|
|
293
294
|
w(() => d(e.errors), async () => {
|
|
294
|
-
if (
|
|
295
|
+
if (r.isValidated) {
|
|
295
296
|
const i = await n();
|
|
296
297
|
s(i.errors);
|
|
297
298
|
} else
|
|
298
299
|
s();
|
|
299
300
|
}, { immediate: !0 }), w(
|
|
300
|
-
[() =>
|
|
301
|
+
[() => r.validators],
|
|
301
302
|
async (i) => {
|
|
302
|
-
if (
|
|
303
|
+
if (r.isValidated)
|
|
303
304
|
if (i) {
|
|
304
305
|
const a = await n();
|
|
305
|
-
|
|
306
|
+
r.errors = a.errors;
|
|
306
307
|
} else
|
|
307
|
-
|
|
308
|
+
r.errors = m.errors;
|
|
308
309
|
},
|
|
309
310
|
{ immediate: !0 }
|
|
310
|
-
), w(() =>
|
|
311
|
-
|
|
311
|
+
), w(() => t.data, () => {
|
|
312
|
+
r.isValidated && p();
|
|
312
313
|
});
|
|
313
314
|
const o = (i) => {
|
|
314
|
-
const a =
|
|
315
|
-
return
|
|
316
|
-
|
|
315
|
+
const a = O(i) ? i : b(i);
|
|
316
|
+
return r.validators.push(a), Q() && X(() => {
|
|
317
|
+
r.validators = r.validators.filter(
|
|
317
318
|
(u) => u !== a
|
|
318
319
|
);
|
|
319
320
|
}), a;
|
|
320
321
|
};
|
|
321
322
|
async function n() {
|
|
322
323
|
const i = await Promise.all(
|
|
323
|
-
|
|
324
|
+
r.validators.filter((v) => d(v) !== void 0).map((v) => d(v).validate(t.data))
|
|
324
325
|
), a = i.every((v) => v.isValid);
|
|
325
326
|
let { errors: u } = m;
|
|
326
327
|
if (!a) {
|
|
327
328
|
const v = i.map((F) => F.errors);
|
|
328
|
-
u =
|
|
329
|
+
u = S(...v);
|
|
329
330
|
}
|
|
330
331
|
return {
|
|
331
332
|
errors: u,
|
|
@@ -334,15 +335,15 @@ function he(r, e) {
|
|
|
334
335
|
}
|
|
335
336
|
const p = async () => {
|
|
336
337
|
const i = await n();
|
|
337
|
-
return s(i.errors),
|
|
338
|
+
return s(i.errors), r.isValidated = !0, {
|
|
338
339
|
isValid: !N(i.errors),
|
|
339
|
-
errors:
|
|
340
|
+
errors: r.errors
|
|
340
341
|
};
|
|
341
|
-
}, h = c(() => !N(
|
|
342
|
-
|
|
342
|
+
}, h = c(() => !N(r.errors)), V = () => {
|
|
343
|
+
r.isValidated = !1, r.errors = d(e.errors) ?? m.errors;
|
|
343
344
|
};
|
|
344
345
|
return {
|
|
345
|
-
...W(
|
|
346
|
+
...W(r),
|
|
346
347
|
validateForm: p,
|
|
347
348
|
defineValidator: o,
|
|
348
349
|
isValid: h,
|
|
@@ -350,14 +351,14 @@ function he(r, e) {
|
|
|
350
351
|
};
|
|
351
352
|
}
|
|
352
353
|
class ve {
|
|
353
|
-
constructor(e,
|
|
354
|
-
this.path = e, this.validator =
|
|
354
|
+
constructor(e, r) {
|
|
355
|
+
this.path = e, this.validator = r;
|
|
355
356
|
}
|
|
356
357
|
async validate(e) {
|
|
357
|
-
const
|
|
358
|
+
const r = P(e, this.path);
|
|
358
359
|
if (!this.validator)
|
|
359
360
|
return m;
|
|
360
|
-
const s = await this.validator.validate(
|
|
361
|
+
const s = await this.validator.validate(r);
|
|
361
362
|
return {
|
|
362
363
|
isValid: s.isValid,
|
|
363
364
|
errors: {
|
|
@@ -372,29 +373,29 @@ class ve {
|
|
|
372
373
|
};
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
|
-
function me(
|
|
376
|
-
const s = U(
|
|
376
|
+
function me(t, e, r) {
|
|
377
|
+
const s = U(t.data, e), o = c(() => P(t.initialData.value, e)), n = (l) => ({
|
|
377
378
|
...l,
|
|
378
379
|
path: c(() => d(l.path).replace(e + ".", "")),
|
|
379
380
|
setData: (f) => {
|
|
380
381
|
l.setData(f);
|
|
381
382
|
}
|
|
382
383
|
}), p = (l) => {
|
|
383
|
-
const f = R(e, l), y =
|
|
384
|
+
const f = R(e, l), y = t.getField(f);
|
|
384
385
|
return y ? n(y) : {};
|
|
385
386
|
}, h = (l) => {
|
|
386
|
-
const f = R(e, l.path), y =
|
|
387
|
+
const f = R(e, l.path), y = t.defineField({
|
|
387
388
|
...l,
|
|
388
389
|
path: f
|
|
389
390
|
});
|
|
390
391
|
return n(y);
|
|
391
|
-
}, V = c(() =>
|
|
392
|
+
}, V = c(() => t.fields.value.filter((l) => {
|
|
392
393
|
const f = l.path.value;
|
|
393
394
|
return f.startsWith(e + ".") || f === e;
|
|
394
|
-
}).map((l) => n(l))), i = () =>
|
|
395
|
+
}).map((l) => n(l))), i = () => t.fields.value.filter((l) => {
|
|
395
396
|
const f = l.path.value;
|
|
396
397
|
return f.startsWith(e + ".") || f === e;
|
|
397
|
-
}), a = c(() => i().some((l) => l.dirty.value)), u = c(() => i().some((l) => l.touched.value)), v = c(() =>
|
|
398
|
+
}), a = c(() => i().some((l) => l.dirty.value)), u = c(() => i().some((l) => l.touched.value)), v = c(() => t.isValid.value), F = c(() => t.isValidated.value), J = c(() => se(d(t.errors), e));
|
|
398
399
|
return {
|
|
399
400
|
data: s,
|
|
400
401
|
fields: V,
|
|
@@ -407,32 +408,32 @@ function me(r, e, t) {
|
|
|
407
408
|
isValidated: F,
|
|
408
409
|
errors: J,
|
|
409
410
|
defineValidator: (l) => {
|
|
410
|
-
const f =
|
|
411
|
+
const f = O(l) ? l : b(l), y = c(
|
|
411
412
|
() => new ve(e, d(f))
|
|
412
413
|
);
|
|
413
|
-
return
|
|
414
|
+
return t.defineValidator(y), f;
|
|
414
415
|
},
|
|
415
416
|
reset: () => i().forEach((l) => l.reset()),
|
|
416
|
-
validateForm: () =>
|
|
417
|
+
validateForm: () => t.validateForm(),
|
|
417
418
|
getSubForm: (l, f) => {
|
|
418
419
|
const y = R(e, l);
|
|
419
|
-
return
|
|
420
|
+
return t.getSubForm(
|
|
420
421
|
y,
|
|
421
422
|
f
|
|
422
423
|
);
|
|
423
424
|
}
|
|
424
425
|
};
|
|
425
426
|
}
|
|
426
|
-
function Pe(
|
|
427
|
-
const e = c(() => Object.freeze(g(
|
|
427
|
+
function Pe(t) {
|
|
428
|
+
const e = c(() => Object.freeze(g(t.initialData))), r = k(g(e)), s = D({
|
|
428
429
|
initialData: e,
|
|
429
|
-
data:
|
|
430
|
+
data: r
|
|
430
431
|
});
|
|
431
432
|
w(e, (a) => {
|
|
432
433
|
s.data = g(a);
|
|
433
434
|
});
|
|
434
|
-
const o = he(s,
|
|
435
|
-
|
|
435
|
+
const o = he(s, t), n = ne(s, o), p = ie(n), h = () => {
|
|
436
|
+
r.value = g(e), o.reset(), n.fields.value.forEach(
|
|
436
437
|
(a) => a.reset()
|
|
437
438
|
);
|
|
438
439
|
};
|
|
@@ -445,8 +446,8 @@ function Pe(r) {
|
|
|
445
446
|
...p,
|
|
446
447
|
reset: h,
|
|
447
448
|
getSubForm: V,
|
|
448
|
-
initialData:
|
|
449
|
-
data:
|
|
449
|
+
initialData: _(s, "initialData"),
|
|
450
|
+
data: _(s, "data")
|
|
450
451
|
};
|
|
451
452
|
return i;
|
|
452
453
|
}
|
|
@@ -459,10 +460,10 @@ const _e = /* @__PURE__ */ $({
|
|
|
459
460
|
path: {},
|
|
460
461
|
errors: {}
|
|
461
462
|
},
|
|
462
|
-
setup(
|
|
463
|
-
const e =
|
|
463
|
+
setup(t) {
|
|
464
|
+
const e = t, r = e.form.defineField({
|
|
464
465
|
path: e.path
|
|
465
|
-
}), s =
|
|
466
|
+
}), s = D(r);
|
|
466
467
|
return (o, n) => j(o.$slots, "default", z(B(s)));
|
|
467
468
|
}
|
|
468
469
|
}), Se = /* @__PURE__ */ $({
|
|
@@ -474,8 +475,8 @@ const _e = /* @__PURE__ */ $({
|
|
|
474
475
|
form: {},
|
|
475
476
|
path: {}
|
|
476
477
|
},
|
|
477
|
-
setup(
|
|
478
|
-
return (e,
|
|
478
|
+
setup(t) {
|
|
479
|
+
return (e, r) => {
|
|
479
480
|
const s = Y("Field");
|
|
480
481
|
return C(), A(s, {
|
|
481
482
|
form: e.form,
|
|
@@ -498,20 +499,20 @@ const _e = /* @__PURE__ */ $({
|
|
|
498
499
|
}, 8, ["form", "path"]);
|
|
499
500
|
};
|
|
500
501
|
}
|
|
501
|
-
}),
|
|
502
|
+
}), be = /* @__PURE__ */ $({
|
|
502
503
|
__name: "FormPart",
|
|
503
504
|
props: {
|
|
504
505
|
form: {},
|
|
505
506
|
path: {}
|
|
506
507
|
},
|
|
507
|
-
setup(
|
|
508
|
-
const e =
|
|
509
|
-
return (s, o) => j(s.$slots, "default", z(B({ subform:
|
|
508
|
+
setup(t) {
|
|
509
|
+
const e = t, r = c(() => e.form.getSubForm(e.path));
|
|
510
|
+
return (s, o) => j(s.$slots, "default", z(B({ subform: r.value })));
|
|
510
511
|
}
|
|
511
512
|
});
|
|
512
513
|
export {
|
|
513
514
|
_e as Field,
|
|
514
515
|
Se as FormFieldWrapper,
|
|
515
|
-
|
|
516
|
+
be as FormPart,
|
|
516
517
|
Pe as useForm
|
|
517
518
|
};
|
package/package.json
CHANGED
package/src/utils/path.ts
CHANGED
|
@@ -22,11 +22,13 @@ export function setNestedValue<T, K extends Paths<T>>(obj: MaybeRef<T>, path: K
|
|
|
22
22
|
|
|
23
23
|
const lastKey = keys.at(-1)!
|
|
24
24
|
|
|
25
|
-
if (!lastKey
|
|
25
|
+
if (!lastKey) {
|
|
26
|
+
if (!isRef(obj)) {
|
|
27
|
+
// We cannot do anything here as we have nothing we can assign to
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
obj.value = value
|
|
27
|
-
} else if (!isRef(obj)) {
|
|
28
|
-
// We cannot do anything here as we have nothing we can assign to
|
|
29
|
-
return
|
|
30
32
|
} else {
|
|
31
33
|
const target = keys
|
|
32
34
|
.slice(0, -1)
|