@ram_28/kf-ai-sdk 1.0.22 → 1.0.24
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/auth.cjs +1 -1
- package/dist/auth.mjs +15 -15
- package/dist/components/hooks/useForm/types.d.ts +3 -5
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +193 -194
- package/docs/QUICK_REFERENCE.md +24 -0
- package/docs/api.md +648 -0
- package/docs/datetime.md +144 -0
- package/docs/useFilter.md +58 -18
- package/docs/useForm.md +447 -588
- package/docs/useTable.md +160 -26
- package/package.json +1 -1
- package/sdk/auth/authClient.ts +2 -2
- package/sdk/components/hooks/useForm/types.ts +4 -7
- package/sdk/components/hooks/useForm/useForm.ts +5 -4
package/dist/form.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var jt = Object.defineProperty;
|
|
2
2
|
var Wt = (e, t, r) => t in e ? jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var we = (e, t, r) => Wt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import Z, { useState as pe, useRef as
|
|
4
|
+
import Z, { useState as pe, useRef as Oe, useEffect as He, useMemo as Ce, useCallback as se } from "react";
|
|
5
5
|
import { useQuery as mt } from "@tanstack/react-query";
|
|
6
6
|
import { a as Ee } from "./client-BIkaIr2y.js";
|
|
7
7
|
import { g as Ht } from "./metadata-VbQzyD2C.js";
|
|
8
|
-
import { t as
|
|
9
|
-
var
|
|
8
|
+
import { t as Me } from "./error-handling-CrhTtD88.js";
|
|
9
|
+
var ke = (e) => e.type === "checkbox", be = (e) => e instanceof Date, X = (e) => e == null;
|
|
10
10
|
const Ct = (e) => typeof e == "object";
|
|
11
|
-
var B = (e) => !X(e) && !Array.isArray(e) && Ct(e) && !be(e), Yt = (e) => B(e) && e.target ?
|
|
11
|
+
var B = (e) => !X(e) && !Array.isArray(e) && Ct(e) && !be(e), Yt = (e) => B(e) && e.target ? ke(e.target) ? e.target.checked : e.target.value : e, Kt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, zt = (e, t) => e.has(Kt(t)), Jt = (e) => {
|
|
12
12
|
const t = e.constructor && e.constructor.prototype;
|
|
13
13
|
return B(t) && t.hasOwnProperty("isPrototypeOf");
|
|
14
14
|
}, nt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
@@ -109,7 +109,7 @@ var er = (e, t, r, s, i) => t ? {
|
|
|
109
109
|
...r[e] && r[e].types ? r[e].types : {},
|
|
110
110
|
[s]: i || !0
|
|
111
111
|
}
|
|
112
|
-
} : {},
|
|
112
|
+
} : {}, Le = (e) => Array.isArray(e) ? e : [e], gt = () => {
|
|
113
113
|
let e = [];
|
|
114
114
|
return {
|
|
115
115
|
get observers() {
|
|
@@ -146,7 +146,7 @@ var z = (e) => B(e) && !Object.keys(e).length, lt = (e) => e.type === "file", Ye
|
|
|
146
146
|
return !1;
|
|
147
147
|
const t = e ? e.ownerDocument : 0;
|
|
148
148
|
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
149
|
-
},
|
|
149
|
+
}, Mt = (e) => e.type === "select-multiple", ct = (e) => e.type === "radio", tr = (e) => ct(e) || ke(e), rt = (e) => Ye(e) && e.isConnected;
|
|
150
150
|
function rr(e, t) {
|
|
151
151
|
const r = t.slice(0, -1).length;
|
|
152
152
|
let s = 0;
|
|
@@ -170,13 +170,13 @@ var ir = (e) => {
|
|
|
170
170
|
return !0;
|
|
171
171
|
return !1;
|
|
172
172
|
};
|
|
173
|
-
function
|
|
173
|
+
function Lt(e) {
|
|
174
174
|
return Array.isArray(e) || B(e) && !ir(e);
|
|
175
175
|
}
|
|
176
176
|
function at(e, t = {}) {
|
|
177
177
|
for (const r in e) {
|
|
178
178
|
const s = e[r];
|
|
179
|
-
|
|
179
|
+
Lt(s) ? (t[r] = Array.isArray(s) ? [] : {}, at(s, t[r])) : I(s) || (t[r] = !0);
|
|
180
180
|
}
|
|
181
181
|
return t;
|
|
182
182
|
}
|
|
@@ -184,7 +184,7 @@ function Ve(e, t, r) {
|
|
|
184
184
|
r || (r = at(t));
|
|
185
185
|
for (const s in e) {
|
|
186
186
|
const i = e[s];
|
|
187
|
-
if (
|
|
187
|
+
if (Lt(i))
|
|
188
188
|
I(t) || it(r[s]) ? r[s] = at(i, Array.isArray(i) ? [] : {}) : Ve(i, X(t) ? {} : t[s], r[s]);
|
|
189
189
|
else {
|
|
190
190
|
const n = t[s];
|
|
@@ -220,7 +220,7 @@ var Ut = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disab
|
|
|
220
220
|
} : t, wt) : wt;
|
|
221
221
|
function vt(e) {
|
|
222
222
|
const t = e.ref;
|
|
223
|
-
return lt(t) ? t.files : ct(t) ? Ut(e.refs).value :
|
|
223
|
+
return lt(t) ? t.files : ct(t) ? Ut(e.refs).value : Mt(t) ? [...t.selectedOptions].map(({ value: r }) => r) : ke(t) ? It(e.refs).value : kt(I(t.value) ? e.ref.value : t.value, e);
|
|
224
224
|
}
|
|
225
225
|
var ar = (e, t, r, s) => {
|
|
226
226
|
const i = {};
|
|
@@ -234,7 +234,7 @@ var ar = (e, t, r, s) => {
|
|
|
234
234
|
fields: i,
|
|
235
235
|
shouldUseNativeValidation: s
|
|
236
236
|
};
|
|
237
|
-
}, Ke = (e) => e instanceof RegExp,
|
|
237
|
+
}, Ke = (e) => e instanceof RegExp, Te = (e) => I(e) ? e : Ke(e) ? e.source : B(e) ? Ke(e.value) ? e.value.source : e.value : e, Vt = (e) => ({
|
|
238
238
|
isOnSubmit: !e || e === ae.onSubmit,
|
|
239
239
|
isOnBlur: e === ae.onBlur,
|
|
240
240
|
isOnChange: e === ae.onChange,
|
|
@@ -243,7 +243,7 @@ var ar = (e, t, r, s) => {
|
|
|
243
243
|
});
|
|
244
244
|
const Et = "AsyncFunction";
|
|
245
245
|
var nr = (e) => !!e && !!e.validate && !!(ie(e.validate) && e.validate.constructor.name === Et || B(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === Et)), ur = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Ft = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
|
|
246
|
-
const
|
|
246
|
+
const Ie = (e, t, r, s) => {
|
|
247
247
|
for (const i of r || Object.keys(e)) {
|
|
248
248
|
const n = g(e, i);
|
|
249
249
|
if (n) {
|
|
@@ -253,9 +253,9 @@ const Ue = (e, t, r, s) => {
|
|
|
253
253
|
return !0;
|
|
254
254
|
if (c.ref && t(c.ref, c.name) && !s)
|
|
255
255
|
return !0;
|
|
256
|
-
if (
|
|
256
|
+
if (Ie(h, t))
|
|
257
257
|
break;
|
|
258
|
-
} else if (B(h) &&
|
|
258
|
+
} else if (B(h) && Ie(h, t))
|
|
259
259
|
break;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
@@ -292,8 +292,8 @@ var or = (e, t, r, s) => {
|
|
|
292
292
|
r(e);
|
|
293
293
|
const { name: i, ...n } = e;
|
|
294
294
|
return z(n) || Object.keys(n).length >= Object.keys(t).length || Object.keys(n).find((c) => t[c] === (!s || ae.all));
|
|
295
|
-
}, lr = (e, t, r) => !e || !t || e === t ||
|
|
296
|
-
const s =
|
|
295
|
+
}, lr = (e, t, r) => !e || !t || e === t || Le(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), cr = (e, t, r, s, i) => i.isOnAll ? !1 : !r && i.isOnTouch ? !(t || e) : (r ? s.isOnBlur : i.isOnBlur) ? !e : (r ? s.isOnChange : i.isOnChange) ? e : !0, dr = (e, t) => !ut(g(e, t)).length && U(e, t), fr = (e, t, r) => {
|
|
296
|
+
const s = Le(g(e, r));
|
|
297
297
|
return T(s, "root", t[r]), T(e, r, s), e;
|
|
298
298
|
};
|
|
299
299
|
function xt(e, t, r = "validate") {
|
|
@@ -308,14 +308,14 @@ var ve = (e) => B(e) && !Ke(e) ? e : {
|
|
|
308
308
|
value: e,
|
|
309
309
|
message: ""
|
|
310
310
|
}, _t = async (e, t, r, s, i, n) => {
|
|
311
|
-
const { ref: c, refs: h, required: w, maxLength: V, minLength: N, min:
|
|
311
|
+
const { ref: c, refs: h, required: w, maxLength: V, minLength: N, min: S, max: A, pattern: v, validate: y, name: P, valueAsNumber: H, mount: Q } = e._f, _ = g(r, P);
|
|
312
312
|
if (!Q || t.has(P))
|
|
313
313
|
return {};
|
|
314
314
|
const te = h ? h[0] : c, re = (E) => {
|
|
315
315
|
i && te.reportValidity && (te.setCustomValidity(oe(E) ? "" : E || ""), te.reportValidity());
|
|
316
|
-
},
|
|
317
|
-
const K = E ? x :
|
|
318
|
-
|
|
316
|
+
}, D = {}, de = ct(c), ge = ke(c), ne = de || ge, fe = (H || lt(c)) && I(c.value) && I(_) || Ye(c) && c.value === "" || _ === "" || Array.isArray(_) && !_.length, Y = er.bind(null, P, s, D), le = (E, x, M, O = ce.maxLength, W = ce.minLength) => {
|
|
317
|
+
const K = E ? x : M;
|
|
318
|
+
D[P] = {
|
|
319
319
|
type: E ? O : W,
|
|
320
320
|
message: K,
|
|
321
321
|
ref: c,
|
|
@@ -324,69 +324,69 @@ var ve = (e) => B(e) && !Ke(e) ? e : {
|
|
|
324
324
|
};
|
|
325
325
|
if (n ? !Array.isArray(_) || !_.length : w && (!ne && (fe || X(_)) || oe(_) && !_ || ge && !It(h).isValid || de && !Ut(h).isValid)) {
|
|
326
326
|
const { value: E, message: x } = ee(w) ? { value: !!w, message: w } : ve(w);
|
|
327
|
-
if (E && (
|
|
327
|
+
if (E && (D[P] = {
|
|
328
328
|
type: ce.required,
|
|
329
329
|
message: x,
|
|
330
330
|
ref: te,
|
|
331
331
|
...Y(ce.required, x)
|
|
332
332
|
}, !s))
|
|
333
|
-
return re(x),
|
|
333
|
+
return re(x), D;
|
|
334
334
|
}
|
|
335
|
-
if (!fe && (!X(
|
|
335
|
+
if (!fe && (!X(S) || !X(A))) {
|
|
336
336
|
let E, x;
|
|
337
|
-
const
|
|
337
|
+
const M = ve(A), O = ve(S);
|
|
338
338
|
if (!X(_) && !isNaN(_)) {
|
|
339
339
|
const W = c.valueAsNumber || _ && +_;
|
|
340
|
-
X(
|
|
340
|
+
X(M.value) || (E = W > M.value), X(O.value) || (x = W < O.value);
|
|
341
341
|
} else {
|
|
342
342
|
const W = c.valueAsDate || new Date(_), K = (J) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + J), ue = c.type == "time", he = c.type == "week";
|
|
343
|
-
ee(
|
|
343
|
+
ee(M.value) && _ && (E = ue ? K(_) > K(M.value) : he ? _ > M.value : W > new Date(M.value)), ee(O.value) && _ && (x = ue ? K(_) < K(O.value) : he ? _ < O.value : W < new Date(O.value));
|
|
344
344
|
}
|
|
345
|
-
if ((E || x) && (le(!!E,
|
|
346
|
-
return re(
|
|
345
|
+
if ((E || x) && (le(!!E, M.message, O.message, ce.max, ce.min), !s))
|
|
346
|
+
return re(D[P].message), D;
|
|
347
347
|
}
|
|
348
348
|
if ((V || N) && !fe && (ee(_) || n && Array.isArray(_))) {
|
|
349
|
-
const E = ve(V), x = ve(N),
|
|
350
|
-
if ((
|
|
351
|
-
return re(
|
|
349
|
+
const E = ve(V), x = ve(N), M = !X(E.value) && _.length > +E.value, O = !X(x.value) && _.length < +x.value;
|
|
350
|
+
if ((M || O) && (le(M, E.message, x.message), !s))
|
|
351
|
+
return re(D[P].message), D;
|
|
352
352
|
}
|
|
353
353
|
if (v && !fe && ee(_)) {
|
|
354
354
|
const { value: E, message: x } = ve(v);
|
|
355
|
-
if (Ke(E) && !_.match(E) && (
|
|
355
|
+
if (Ke(E) && !_.match(E) && (D[P] = {
|
|
356
356
|
type: ce.pattern,
|
|
357
357
|
message: x,
|
|
358
358
|
ref: c,
|
|
359
359
|
...Y(ce.pattern, x)
|
|
360
360
|
}, !s))
|
|
361
|
-
return re(x),
|
|
361
|
+
return re(x), D;
|
|
362
362
|
}
|
|
363
363
|
if (y) {
|
|
364
364
|
if (ie(y)) {
|
|
365
365
|
const E = await y(_, r), x = xt(E, te);
|
|
366
|
-
if (x && (
|
|
366
|
+
if (x && (D[P] = {
|
|
367
367
|
...x,
|
|
368
368
|
...Y(ce.validate, x.message)
|
|
369
369
|
}, !s))
|
|
370
|
-
return re(x.message),
|
|
370
|
+
return re(x.message), D;
|
|
371
371
|
} else if (B(y)) {
|
|
372
372
|
let E = {};
|
|
373
373
|
for (const x in y) {
|
|
374
374
|
if (!z(E) && !s)
|
|
375
375
|
break;
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
...
|
|
379
|
-
...Y(x,
|
|
380
|
-
}, re(
|
|
376
|
+
const M = xt(await y[x](_, r), te, x);
|
|
377
|
+
M && (E = {
|
|
378
|
+
...M,
|
|
379
|
+
...Y(x, M.message)
|
|
380
|
+
}, re(M.message), s && (D[P] = E));
|
|
381
381
|
}
|
|
382
|
-
if (!z(E) && (
|
|
382
|
+
if (!z(E) && (D[P] = {
|
|
383
383
|
ref: te,
|
|
384
384
|
...E
|
|
385
385
|
}, !s))
|
|
386
|
-
return
|
|
386
|
+
return D;
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
return re(!0),
|
|
389
|
+
return re(!0), D;
|
|
390
390
|
};
|
|
391
391
|
const hr = {
|
|
392
392
|
mode: ae.onSubmit,
|
|
@@ -432,11 +432,11 @@ function mr(e = {}) {
|
|
|
432
432
|
isValidating: !1,
|
|
433
433
|
isValid: !1,
|
|
434
434
|
errors: !1
|
|
435
|
-
},
|
|
435
|
+
}, S = {
|
|
436
436
|
...N
|
|
437
437
|
};
|
|
438
438
|
let A = {
|
|
439
|
-
...
|
|
439
|
+
...S
|
|
440
440
|
};
|
|
441
441
|
const v = {
|
|
442
442
|
array: gt(),
|
|
@@ -444,14 +444,14 @@ function mr(e = {}) {
|
|
|
444
444
|
}, y = t.criteriaMode === ae.all, P = (a) => (u) => {
|
|
445
445
|
clearTimeout(V), V = setTimeout(a, u);
|
|
446
446
|
}, H = async (a) => {
|
|
447
|
-
if (!c.keepIsValid && !t.disabled && (
|
|
447
|
+
if (!c.keepIsValid && !t.disabled && (S.isValid || A.isValid || a)) {
|
|
448
448
|
let u;
|
|
449
449
|
t.resolver ? (u = z((await ne()).errors), Q()) : u = await Y(s, !0), u !== r.isValid && v.state.next({
|
|
450
450
|
isValid: u
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
453
|
}, Q = (a, u) => {
|
|
454
|
-
!t.disabled && (
|
|
454
|
+
!t.disabled && (S.isValidating || S.validatingFields || A.isValidating || A.validatingFields) && ((a || Array.from(h.mount)).forEach((o) => {
|
|
455
455
|
o && (u ? T(r.validatingFields, o, u) : U(r.validatingFields, o));
|
|
456
456
|
}), v.state.next({
|
|
457
457
|
validatingFields: r.validatingFields,
|
|
@@ -467,11 +467,11 @@ function mr(e = {}) {
|
|
|
467
467
|
const m = o(g(r.errors, a), d.argA, d.argB);
|
|
468
468
|
f && T(r.errors, a, m), dr(r.errors, a);
|
|
469
469
|
}
|
|
470
|
-
if ((
|
|
470
|
+
if ((S.touchedFields || A.touchedFields) && l && Array.isArray(g(r.touchedFields, a))) {
|
|
471
471
|
const m = o(g(r.touchedFields, a), d.argA, d.argB);
|
|
472
472
|
f && T(r.touchedFields, a, m);
|
|
473
473
|
}
|
|
474
|
-
(
|
|
474
|
+
(S.dirtyFields || A.dirtyFields) && (r.dirtyFields = Ve(i, n)), v.state.next({
|
|
475
475
|
name: a,
|
|
476
476
|
isDirty: E(a, u),
|
|
477
477
|
dirtyFields: r.dirtyFields,
|
|
@@ -489,7 +489,7 @@ function mr(e = {}) {
|
|
|
489
489
|
errors: r.errors,
|
|
490
490
|
isValid: !1
|
|
491
491
|
});
|
|
492
|
-
},
|
|
492
|
+
}, D = (a, u, o, d) => {
|
|
493
493
|
const f = g(s, a);
|
|
494
494
|
if (f) {
|
|
495
495
|
const l = g(n, a, I(o) ? g(i, a) : o);
|
|
@@ -502,19 +502,19 @@ function mr(e = {}) {
|
|
|
502
502
|
};
|
|
503
503
|
if (!t.disabled) {
|
|
504
504
|
if (!o || d) {
|
|
505
|
-
(
|
|
505
|
+
(S.isDirty || A.isDirty) && (m = r.isDirty, r.isDirty = p.isDirty = E(), l = m !== p.isDirty);
|
|
506
506
|
const b = me(g(i, a), u);
|
|
507
|
-
m = !!g(r.dirtyFields, a), b ? U(r.dirtyFields, a) : T(r.dirtyFields, a, !0), p.dirtyFields = r.dirtyFields, l = l || (
|
|
507
|
+
m = !!g(r.dirtyFields, a), b ? U(r.dirtyFields, a) : T(r.dirtyFields, a, !0), p.dirtyFields = r.dirtyFields, l = l || (S.dirtyFields || A.dirtyFields) && m !== !b;
|
|
508
508
|
}
|
|
509
509
|
if (o) {
|
|
510
510
|
const b = g(r.touchedFields, a);
|
|
511
|
-
b || (T(r.touchedFields, a, o), p.touchedFields = r.touchedFields, l = l || (
|
|
511
|
+
b || (T(r.touchedFields, a, o), p.touchedFields = r.touchedFields, l = l || (S.touchedFields || A.touchedFields) && b !== o);
|
|
512
512
|
}
|
|
513
513
|
l && f && v.state.next(p);
|
|
514
514
|
}
|
|
515
515
|
return l ? p : {};
|
|
516
516
|
}, ge = (a, u, o, d) => {
|
|
517
|
-
const f = g(r.errors, a), l = (
|
|
517
|
+
const f = g(r.errors, a), l = (S.isValid || A.isValid) && oe(u) && r.isValid !== u;
|
|
518
518
|
if (t.delayError && o ? (w = P(() => te(a, o)), w(t.delayError)) : (clearTimeout(V), w = null, o ? T(r.errors, a, o) : U(r.errors, a)), (o ? !me(f, o) : f) || !z(d) || l) {
|
|
519
519
|
const m = {
|
|
520
520
|
...d,
|
|
@@ -546,9 +546,9 @@ function mr(e = {}) {
|
|
|
546
546
|
const { _f: l, ...m } = f;
|
|
547
547
|
if (l) {
|
|
548
548
|
const p = h.array.has(l.name), b = f._f && nr(f._f);
|
|
549
|
-
b &&
|
|
549
|
+
b && S.validatingFields && Q([l.name], !0);
|
|
550
550
|
const R = await _t(f, h.disabled, n, y, t.shouldUseNativeValidation && !u, p);
|
|
551
|
-
if (b &&
|
|
551
|
+
if (b && S.validatingFields && Q([l.name]), R[l.name] && (o.valid = !1, u || e.shouldUseNativeValidation))
|
|
552
552
|
break;
|
|
553
553
|
!u && (g(R, l.name) ? p ? fr(r.errors, R, l.name) : T(r.errors, l.name, R[l.name]) : U(r.errors, l.name));
|
|
554
554
|
}
|
|
@@ -559,17 +559,17 @@ function mr(e = {}) {
|
|
|
559
559
|
}, le = () => {
|
|
560
560
|
for (const a of h.unMount) {
|
|
561
561
|
const u = g(s, a);
|
|
562
|
-
u && (u._f.refs ? u._f.refs.every((o) => !rt(o)) : !rt(u._f.ref)) &&
|
|
562
|
+
u && (u._f.refs ? u._f.refs.every((o) => !rt(o)) : !rt(u._f.ref)) && _e(a);
|
|
563
563
|
}
|
|
564
564
|
h.unMount = /* @__PURE__ */ new Set();
|
|
565
|
-
}, E = (a, u) => !t.disabled && (a && u && T(n, a, u), !me(
|
|
565
|
+
}, E = (a, u) => !t.disabled && (a && u && T(n, a, u), !me(Ue(), i)), x = (a, u, o) => Zt(a, h, {
|
|
566
566
|
...c.mount ? n : I(u) ? i : ee(a) ? { [a]: u } : u
|
|
567
|
-
}, o, u),
|
|
567
|
+
}, o, u), M = (a) => ut(g(c.mount ? n : i, a, t.shouldUnregister ? g(i, a, []) : [])), O = (a, u, o = {}) => {
|
|
568
568
|
const d = g(s, a);
|
|
569
569
|
let f = u;
|
|
570
570
|
if (d) {
|
|
571
571
|
const l = d._f;
|
|
572
|
-
l && (!l.disabled && T(n, a, kt(u, l)), f = Ye(l.ref) && X(u) ? "" : u,
|
|
572
|
+
l && (!l.disabled && T(n, a, kt(u, l)), f = Ye(l.ref) && X(u) ? "" : u, Mt(l.ref) ? [...l.ref.options].forEach((m) => m.selected = f.includes(m.value)) : l.refs ? ke(l.ref) ? l.refs.forEach((m) => {
|
|
573
573
|
(!m.defaultChecked || !m.disabled) && (Array.isArray(f) ? m.checked = !!f.find((p) => p === m.value) : m.checked = f === m.value || !!f);
|
|
574
574
|
}) : l.refs.forEach((m) => m.checked = m.value === f) : lt(l.ref) ? l.ref.value = "" : (l.ref.value = f, l.ref.type || v.state.next({
|
|
575
575
|
name: a,
|
|
@@ -589,7 +589,7 @@ function mr(e = {}) {
|
|
|
589
589
|
T(n, a, l), f ? (v.array.next({
|
|
590
590
|
name: a,
|
|
591
591
|
values: $(n)
|
|
592
|
-
}), (
|
|
592
|
+
}), (S.isDirty || S.dirtyFields || A.isDirty || A.dirtyFields) && o.shouldDirty && v.state.next({
|
|
593
593
|
name: a,
|
|
594
594
|
dirtyFields: Ve(i, n),
|
|
595
595
|
isDirty: E(a, l)
|
|
@@ -610,23 +610,23 @@ function mr(e = {}) {
|
|
|
610
610
|
}, m = Vt(t.mode), p = Vt(t.reValidateMode);
|
|
611
611
|
if (f) {
|
|
612
612
|
let b, R;
|
|
613
|
-
const
|
|
614
|
-
T(n, o,
|
|
615
|
-
const k = de(o,
|
|
613
|
+
const L = u.type ? vt(f._f) : Yt(a), C = a.type === yt.BLUR || a.type === yt.FOCUS_OUT, q = !ur(f._f) && !t.resolver && !g(r.errors, o) && !f._f.deps || cr(C, g(r.touchedFields, o), r.isSubmitted, p, m), j = Ft(o, h, C);
|
|
614
|
+
T(n, o, L), C ? (!u || !u.readOnly) && (f._f.onBlur && f._f.onBlur(a), w && w(0)) : f._f.onChange && f._f.onChange(a);
|
|
615
|
+
const k = de(o, L, C), G = !z(k) || j;
|
|
616
616
|
if (!C && v.state.next({
|
|
617
617
|
name: o,
|
|
618
618
|
type: a.type,
|
|
619
619
|
values: $(n)
|
|
620
620
|
}), q)
|
|
621
|
-
return (
|
|
621
|
+
return (S.isValid || A.isValid) && (t.mode === "onBlur" ? C && H() : C || H()), G && v.state.next({ name: o, ...j ? {} : k });
|
|
622
622
|
if (!C && j && v.state.next({ ...r }), t.resolver) {
|
|
623
|
-
const { errors:
|
|
624
|
-
if (Q([o]), l(
|
|
625
|
-
const ft = At(r.errors, s, o), et = At(
|
|
626
|
-
b = et.error, o = et.name, R = z(
|
|
623
|
+
const { errors: Ne } = await ne([o]);
|
|
624
|
+
if (Q([o]), l(L), d) {
|
|
625
|
+
const ft = At(r.errors, s, o), et = At(Ne, s, ft.name || o);
|
|
626
|
+
b = et.error, o = et.name, R = z(Ne);
|
|
627
627
|
}
|
|
628
628
|
} else
|
|
629
|
-
Q([o], !0), b = (await _t(f, h.disabled, n, y, t.shouldUseNativeValidation))[o], Q([o]), l(
|
|
629
|
+
Q([o], !0), b = (await _t(f, h.disabled, n, y, t.shouldUseNativeValidation))[o], Q([o]), l(L), d && (b ? R = !1 : (S.isValid || A.isValid) && (R = await Y(s, !0)));
|
|
630
630
|
d && (f._f.deps && (!Array.isArray(f._f.deps) || f._f.deps.length > 0) && J(f._f.deps), ge(o, R, b, k));
|
|
631
631
|
}
|
|
632
632
|
}, he = (a, u) => {
|
|
@@ -634,7 +634,7 @@ function mr(e = {}) {
|
|
|
634
634
|
return a.focus(), 1;
|
|
635
635
|
}, J = async (a, u = {}) => {
|
|
636
636
|
let o, d;
|
|
637
|
-
const f =
|
|
637
|
+
const f = Le(a);
|
|
638
638
|
if (t.resolver) {
|
|
639
639
|
const l = await fe(I(a) ? a : f);
|
|
640
640
|
o = z(l), d = a ? !f.some((m) => g(l, m)) : o;
|
|
@@ -643,23 +643,23 @@ function mr(e = {}) {
|
|
|
643
643
|
return await Y(m && m._f ? { [l]: m } : m);
|
|
644
644
|
}))).every(Boolean), !(!d && !r.isValid) && H()) : d = o = await Y(s);
|
|
645
645
|
return v.state.next({
|
|
646
|
-
...!ee(a) || (
|
|
646
|
+
...!ee(a) || (S.isValid || A.isValid) && o !== r.isValid ? {} : { name: a },
|
|
647
647
|
...t.resolver || !a ? { isValid: o } : {},
|
|
648
648
|
errors: r.errors
|
|
649
|
-
}), u.shouldFocus && !d &&
|
|
650
|
-
},
|
|
649
|
+
}), u.shouldFocus && !d && Ie(s, he, a ? f : h.mount), d;
|
|
650
|
+
}, Ue = (a, u) => {
|
|
651
651
|
let o = {
|
|
652
652
|
...c.mount ? n : i
|
|
653
653
|
};
|
|
654
654
|
return u && (o = Tt(u.dirtyFields ? r.dirtyFields : r.touchedFields, o)), I(a) ? o : ee(a) ? g(o, a) : a.map((d) => g(o, d));
|
|
655
|
-
},
|
|
655
|
+
}, Be = (a, u) => ({
|
|
656
656
|
invalid: !!g((u || r).errors, a),
|
|
657
657
|
isDirty: !!g((u || r).dirtyFields, a),
|
|
658
658
|
error: g((u || r).errors, a),
|
|
659
659
|
isValidating: !!g(r.validatingFields, a),
|
|
660
660
|
isTouched: !!g((u || r).touchedFields, a)
|
|
661
661
|
}), Je = (a) => {
|
|
662
|
-
a &&
|
|
662
|
+
a && Le(a).forEach((u) => U(r.errors, u)), v.state.next({
|
|
663
663
|
errors: a ? r.errors : {}
|
|
664
664
|
});
|
|
665
665
|
}, F = (a, u, o) => {
|
|
@@ -673,11 +673,11 @@ function mr(e = {}) {
|
|
|
673
673
|
errors: r.errors,
|
|
674
674
|
isValid: !1
|
|
675
675
|
}), o && o.shouldFocus && d && d.focus && d.focus();
|
|
676
|
-
},
|
|
676
|
+
}, Ae = (a, u) => ie(a) ? v.state.subscribe({
|
|
677
677
|
next: (o) => "values" in o && a(x(void 0, u), o)
|
|
678
|
-
}) : x(a, u, !0),
|
|
678
|
+
}) : x(a, u, !0), xe = (a) => v.state.subscribe({
|
|
679
679
|
next: (u) => {
|
|
680
|
-
lr(a.name, u.name, a.exact) && or(u, a.formState ||
|
|
680
|
+
lr(a.name, u.name, a.exact) && or(u, a.formState || S, Re, a.reRenderRoot) && a.callback({
|
|
681
681
|
values: { ...n },
|
|
682
682
|
...r,
|
|
683
683
|
...u,
|
|
@@ -687,14 +687,14 @@ function mr(e = {}) {
|
|
|
687
687
|
}).unsubscribe, Ge = (a) => (c.mount = !0, A = {
|
|
688
688
|
...A,
|
|
689
689
|
...a.formState
|
|
690
|
-
},
|
|
690
|
+
}, xe({
|
|
691
691
|
...a,
|
|
692
692
|
formState: {
|
|
693
693
|
...N,
|
|
694
694
|
...a.formState
|
|
695
695
|
}
|
|
696
|
-
})),
|
|
697
|
-
for (const o of a ?
|
|
696
|
+
})), _e = (a, u = {}) => {
|
|
697
|
+
for (const o of a ? Le(a) : h.mount)
|
|
698
698
|
h.mount.delete(o), h.array.delete(o), u.keepValue || (U(s, o), U(n, o)), !u.keepError && U(r.errors, o), !u.keepDirty && U(r.dirtyFields, o), !u.keepTouched && U(r.touchedFields, o), !u.keepIsValidating && U(r.validatingFields, o), !t.shouldUnregister && !u.keepDefaultValue && U(i, o);
|
|
699
699
|
v.state.next({
|
|
700
700
|
values: $(n)
|
|
@@ -702,7 +702,7 @@ function mr(e = {}) {
|
|
|
702
702
|
...r,
|
|
703
703
|
...u.keepDirty ? { isDirty: E() } : {}
|
|
704
704
|
}), !u.keepIsValid && H();
|
|
705
|
-
},
|
|
705
|
+
}, Pe = ({ disabled: a, name: u }) => {
|
|
706
706
|
(oe(a) && c.mount || a || h.disabled.has(u)) && (a ? h.disabled.add(u) : h.disabled.delete(u));
|
|
707
707
|
}, Se = (a, u = {}) => {
|
|
708
708
|
let o = g(s, a);
|
|
@@ -715,18 +715,18 @@ function mr(e = {}) {
|
|
|
715
715
|
mount: !0,
|
|
716
716
|
...u
|
|
717
717
|
}
|
|
718
|
-
}), h.mount.add(a), o ?
|
|
718
|
+
}), h.mount.add(a), o ? Pe({
|
|
719
719
|
disabled: oe(u.disabled) ? u.disabled : t.disabled,
|
|
720
720
|
name: a
|
|
721
|
-
}) :
|
|
721
|
+
}) : D(a, !0, u.value), {
|
|
722
722
|
...d ? { disabled: u.disabled || t.disabled } : {},
|
|
723
723
|
...t.progressive ? {
|
|
724
724
|
required: !!u.required,
|
|
725
|
-
min:
|
|
726
|
-
max:
|
|
727
|
-
minLength:
|
|
728
|
-
maxLength:
|
|
729
|
-
pattern:
|
|
725
|
+
min: Te(u.min),
|
|
726
|
+
max: Te(u.max),
|
|
727
|
+
minLength: Te(u.minLength),
|
|
728
|
+
maxLength: Te(u.maxLength),
|
|
729
|
+
pattern: Te(u.pattern)
|
|
730
730
|
} : {},
|
|
731
731
|
name: a,
|
|
732
732
|
onChange: ue,
|
|
@@ -749,19 +749,19 @@ function mr(e = {}) {
|
|
|
749
749
|
ref: { type: l.type, name: a }
|
|
750
750
|
} : { ref: l }
|
|
751
751
|
}
|
|
752
|
-
}),
|
|
752
|
+
}), D(a, !1, void 0, l);
|
|
753
753
|
} else
|
|
754
754
|
o = g(s, a, {}), o._f && (o._f.mount = !1), (t.shouldUnregister || u.shouldUnregister) && !(zt(h.array, a) && c.action) && h.unMount.add(a);
|
|
755
755
|
}
|
|
756
756
|
};
|
|
757
|
-
},
|
|
758
|
-
oe(a) && (v.state.next({ disabled: a }),
|
|
757
|
+
}, De = () => t.shouldFocusError && Ie(s, he, h.mount), Xe = (a) => {
|
|
758
|
+
oe(a) && (v.state.next({ disabled: a }), Ie(s, (u, o) => {
|
|
759
759
|
const d = g(s, o);
|
|
760
760
|
d && (u.disabled = d._f.disabled || a, Array.isArray(d._f.refs) && d._f.refs.forEach((f) => {
|
|
761
761
|
f.disabled = d._f.disabled || a;
|
|
762
762
|
}));
|
|
763
763
|
}, 0, !1));
|
|
764
|
-
},
|
|
764
|
+
}, qe = (a, u) => async (o) => {
|
|
765
765
|
let d;
|
|
766
766
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
767
767
|
let f = $(n);
|
|
@@ -785,7 +785,7 @@ function mr(e = {}) {
|
|
|
785
785
|
d = l;
|
|
786
786
|
}
|
|
787
787
|
} else
|
|
788
|
-
u && await u({ ...r.errors }, o),
|
|
788
|
+
u && await u({ ...r.errors }, o), De(), setTimeout(De);
|
|
789
789
|
if (v.state.next({
|
|
790
790
|
isSubmitted: !0,
|
|
791
791
|
isSubmitting: !1,
|
|
@@ -795,8 +795,8 @@ function mr(e = {}) {
|
|
|
795
795
|
}), d)
|
|
796
796
|
throw d;
|
|
797
797
|
}, Qe = (a, u = {}) => {
|
|
798
|
-
g(s, a) && (I(u.defaultValue) ? K(a, $(g(i, a))) : (K(a, u.defaultValue), T(i, a, $(u.defaultValue))), u.keepTouched || U(r.touchedFields, a), u.keepDirty || (U(r.dirtyFields, a), r.isDirty = u.defaultValue ? E(a, $(g(i, a))) : E()), u.keepError || (U(r.errors, a),
|
|
799
|
-
},
|
|
798
|
+
g(s, a) && (I(u.defaultValue) ? K(a, $(g(i, a))) : (K(a, u.defaultValue), T(i, a, $(u.defaultValue))), u.keepTouched || U(r.touchedFields, a), u.keepDirty || (U(r.dirtyFields, a), r.isDirty = u.defaultValue ? E(a, $(g(i, a))) : E()), u.keepError || (U(r.errors, a), S.isValid && H()), v.state.next({ ...r }));
|
|
799
|
+
}, $e = (a, u = {}) => {
|
|
800
800
|
const o = a ? $(a) : i, d = $(o), f = z(a), l = f ? i : d;
|
|
801
801
|
if (u.keepDefaultValues || (i = o), !u.keepValues) {
|
|
802
802
|
if (u.keepDirtyValues) {
|
|
@@ -805,8 +805,8 @@ function mr(e = {}) {
|
|
|
805
805
|
...Object.keys(Ve(i, n))
|
|
806
806
|
]);
|
|
807
807
|
for (const p of Array.from(m)) {
|
|
808
|
-
const b = g(r.dirtyFields, p), R = g(n, p),
|
|
809
|
-
b && !I(R) ? T(l, p, R) : !b && !I(
|
|
808
|
+
const b = g(r.dirtyFields, p), R = g(n, p), L = g(l, p);
|
|
809
|
+
b && !I(R) ? T(l, p, R) : !b && !I(L) && K(p, L);
|
|
810
810
|
}
|
|
811
811
|
} else {
|
|
812
812
|
if (nt && I(a))
|
|
@@ -843,7 +843,7 @@ function mr(e = {}) {
|
|
|
843
843
|
watch: /* @__PURE__ */ new Set(),
|
|
844
844
|
watchAll: !1,
|
|
845
845
|
focus: ""
|
|
846
|
-
}, c.mount = !
|
|
846
|
+
}, c.mount = !S.isValid || !!u.keepIsValid || !!u.keepDirtyValues || !t.shouldUnregister && !z(l), c.watch = !!t.shouldUnregister, c.keepIsValid = !!u.keepIsValid, c.action = !1, u.keepErrors || (r.errors = {}), v.state.next({
|
|
847
847
|
submitCount: u.keepSubmitCount ? r.submitCount : 0,
|
|
848
848
|
isDirty: f ? !1 : u.keepDirty ? r.isDirty : !!(u.keepDefaultValues && !me(a, i)),
|
|
849
849
|
isSubmitted: u.keepIsSubmitted ? r.isSubmitted : !1,
|
|
@@ -854,7 +854,7 @@ function mr(e = {}) {
|
|
|
854
854
|
isSubmitting: !1,
|
|
855
855
|
defaultValues: i
|
|
856
856
|
});
|
|
857
|
-
},
|
|
857
|
+
}, je = (a, u) => $e(ie(a) ? a(n) : a, { ...t.resetOptions, ...u }), Ze = (a, u = {}) => {
|
|
858
858
|
const o = g(s, a), d = o && o._f;
|
|
859
859
|
if (d) {
|
|
860
860
|
const f = d.refs ? d.refs[0] : d.ref;
|
|
@@ -862,7 +862,7 @@ function mr(e = {}) {
|
|
|
862
862
|
f.focus(), u.shouldSelect && ie(f.select) && f.select();
|
|
863
863
|
});
|
|
864
864
|
}
|
|
865
|
-
},
|
|
865
|
+
}, Re = (a) => {
|
|
866
866
|
r = {
|
|
867
867
|
...r,
|
|
868
868
|
...a
|
|
@@ -870,31 +870,31 @@ function mr(e = {}) {
|
|
|
870
870
|
}, We = {
|
|
871
871
|
control: {
|
|
872
872
|
register: Se,
|
|
873
|
-
unregister:
|
|
874
|
-
getFieldState:
|
|
875
|
-
handleSubmit:
|
|
873
|
+
unregister: _e,
|
|
874
|
+
getFieldState: Be,
|
|
875
|
+
handleSubmit: qe,
|
|
876
876
|
setError: F,
|
|
877
|
-
_subscribe:
|
|
877
|
+
_subscribe: xe,
|
|
878
878
|
_runSchema: ne,
|
|
879
879
|
_updateIsValidating: Q,
|
|
880
|
-
_focusError:
|
|
880
|
+
_focusError: De,
|
|
881
881
|
_getWatch: x,
|
|
882
882
|
_getDirty: E,
|
|
883
883
|
_setValid: H,
|
|
884
884
|
_setFieldArray: _,
|
|
885
|
-
_setDisabledField:
|
|
885
|
+
_setDisabledField: Pe,
|
|
886
886
|
_setErrors: re,
|
|
887
|
-
_getFieldArray:
|
|
888
|
-
_reset:
|
|
887
|
+
_getFieldArray: M,
|
|
888
|
+
_reset: $e,
|
|
889
889
|
_resetDefaultValues: () => ie(t.defaultValues) && t.defaultValues().then((a) => {
|
|
890
|
-
|
|
890
|
+
je(a, t.resetOptions), v.state.next({
|
|
891
891
|
isLoading: !1
|
|
892
892
|
});
|
|
893
893
|
}),
|
|
894
894
|
_removeUnmounted: le,
|
|
895
895
|
_disableForm: Xe,
|
|
896
896
|
_subjects: v,
|
|
897
|
-
_proxyFormState:
|
|
897
|
+
_proxyFormState: S,
|
|
898
898
|
get _fields() {
|
|
899
899
|
return s;
|
|
900
900
|
},
|
|
@@ -932,17 +932,17 @@ function mr(e = {}) {
|
|
|
932
932
|
subscribe: Ge,
|
|
933
933
|
trigger: J,
|
|
934
934
|
register: Se,
|
|
935
|
-
handleSubmit:
|
|
936
|
-
watch:
|
|
935
|
+
handleSubmit: qe,
|
|
936
|
+
watch: Ae,
|
|
937
937
|
setValue: K,
|
|
938
|
-
getValues:
|
|
939
|
-
reset:
|
|
938
|
+
getValues: Ue,
|
|
939
|
+
reset: je,
|
|
940
940
|
resetField: Qe,
|
|
941
941
|
clearErrors: Je,
|
|
942
|
-
unregister:
|
|
942
|
+
unregister: _e,
|
|
943
943
|
setError: F,
|
|
944
944
|
setFocus: Ze,
|
|
945
|
-
getFieldState:
|
|
945
|
+
getFieldState: Be
|
|
946
946
|
};
|
|
947
947
|
return {
|
|
948
948
|
...We,
|
|
@@ -1108,10 +1108,10 @@ function ye(e, t) {
|
|
|
1108
1108
|
return t.systemValues[e.Name];
|
|
1109
1109
|
case "Identifier":
|
|
1110
1110
|
if (e.Property) {
|
|
1111
|
-
const V =
|
|
1111
|
+
const V = St(e, t);
|
|
1112
1112
|
return st(V, e.Property.Name);
|
|
1113
1113
|
}
|
|
1114
|
-
return
|
|
1114
|
+
return St(e, t);
|
|
1115
1115
|
case "MemberExpression":
|
|
1116
1116
|
if (!e.Arguments || e.Arguments.length === 0)
|
|
1117
1117
|
throw new Error("MemberExpression requires Arguments array");
|
|
@@ -1144,7 +1144,7 @@ function ye(e, t) {
|
|
|
1144
1144
|
throw new Error(`Unknown expression type: ${e.Type}`);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
function
|
|
1147
|
+
function St(e, t) {
|
|
1148
1148
|
const { Name: r, Source: s } = e;
|
|
1149
1149
|
if (!r)
|
|
1150
1150
|
throw new Error("Identifier requires Name");
|
|
@@ -1208,7 +1208,7 @@ function Bt(e, t, r = {}) {
|
|
|
1208
1208
|
return console.warn("Expression evaluation failed:", i), !1;
|
|
1209
1209
|
}
|
|
1210
1210
|
}
|
|
1211
|
-
function
|
|
1211
|
+
function Dt(e, t, r = {}) {
|
|
1212
1212
|
const s = [];
|
|
1213
1213
|
for (const i of e)
|
|
1214
1214
|
try {
|
|
@@ -1345,12 +1345,12 @@ function xr(e, t) {
|
|
|
1345
1345
|
hidden: !1
|
|
1346
1346
|
};
|
|
1347
1347
|
return Object.keys(e.Fields).forEach((i) => {
|
|
1348
|
-
var w, V, N,
|
|
1348
|
+
var w, V, N, S, A, v;
|
|
1349
1349
|
if (!t || !((w = e.RolePermission) != null && w[t])) {
|
|
1350
1350
|
r[i] = s;
|
|
1351
1351
|
return;
|
|
1352
1352
|
}
|
|
1353
|
-
const n = e.RolePermission[t], c = ((V = n.Editable) == null ? void 0 : V.includes(i)) || ((N = n.Editable) == null ? void 0 : N.includes("*")) || !1, h = ((
|
|
1353
|
+
const n = e.RolePermission[t], c = ((V = n.Editable) == null ? void 0 : V.includes(i)) || ((N = n.Editable) == null ? void 0 : N.includes("*")) || !1, h = ((S = n.ReadOnly) == null ? void 0 : S.includes(i)) || ((A = n.ReadOnly) == null ? void 0 : A.includes("*")) || c;
|
|
1354
1354
|
r[i] = {
|
|
1355
1355
|
editable: c && !((v = n.ReadOnly) != null && v.includes(i)),
|
|
1356
1356
|
readable: h,
|
|
@@ -1382,7 +1382,7 @@ function _r(e, t) {
|
|
|
1382
1382
|
function Pt(e) {
|
|
1383
1383
|
return e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).replace(/_/g, " ").trim();
|
|
1384
1384
|
}
|
|
1385
|
-
function
|
|
1385
|
+
function Sr(e, t, r) {
|
|
1386
1386
|
const s = {};
|
|
1387
1387
|
switch (t.Required && (s.required = {
|
|
1388
1388
|
value: !0,
|
|
@@ -1398,7 +1398,7 @@ function Dr(e, t, r) {
|
|
|
1398
1398
|
}
|
|
1399
1399
|
return t.Validation && t.Validation.length > 0 && (s.validate = () => !0), s;
|
|
1400
1400
|
}
|
|
1401
|
-
function
|
|
1401
|
+
function Dr(e) {
|
|
1402
1402
|
return e.Values ? e.Values.Mode === "Static" && e.Values.Items ? e.Values.Items.map((t) => ({
|
|
1403
1403
|
value: t.Value,
|
|
1404
1404
|
label: t.Label
|
|
@@ -1434,7 +1434,7 @@ function Nr(e, t, r, s = {}, i, n) {
|
|
|
1434
1434
|
validation: [],
|
|
1435
1435
|
computation: [],
|
|
1436
1436
|
businessLogic: []
|
|
1437
|
-
}, V = t.Computed || !!t.Formula || w.computation.length > 0, N =
|
|
1437
|
+
}, V = t.Computed || !!t.Formula || w.computation.length > 0, N = Sr(e, t);
|
|
1438
1438
|
return V && (N.disabled = !0), {
|
|
1439
1439
|
name: e,
|
|
1440
1440
|
type: _r(t.Type, e),
|
|
@@ -1442,7 +1442,7 @@ function Nr(e, t, r, s = {}, i, n) {
|
|
|
1442
1442
|
required: t.Required || !1,
|
|
1443
1443
|
computed: V,
|
|
1444
1444
|
defaultValue: Rr(t, s),
|
|
1445
|
-
options:
|
|
1445
|
+
options: Dr(t),
|
|
1446
1446
|
validation: N,
|
|
1447
1447
|
description: t.Description,
|
|
1448
1448
|
_bdoField: t,
|
|
@@ -1453,11 +1453,11 @@ function Nr(e, t, r, s = {}, i, n) {
|
|
|
1453
1453
|
function Or(e, t = {}, r) {
|
|
1454
1454
|
let s = e;
|
|
1455
1455
|
s = Vr(s);
|
|
1456
|
-
const i = {}, n = [], c = [], h = [], w = [], V = Er(s), N = Ar(s, V),
|
|
1456
|
+
const i = {}, n = [], c = [], h = [], w = [], V = Er(s), N = Ar(s, V), S = xr(s, r);
|
|
1457
1457
|
for (const [A, v] of Object.entries(s.Fields)) {
|
|
1458
1458
|
if (A.startsWith("_") && !["_id"].includes(A))
|
|
1459
1459
|
continue;
|
|
1460
|
-
const y =
|
|
1460
|
+
const y = S[A];
|
|
1461
1461
|
if (y.hidden)
|
|
1462
1462
|
continue;
|
|
1463
1463
|
const P = Nr(
|
|
@@ -1503,7 +1503,7 @@ async function Tr(e, t = 3) {
|
|
|
1503
1503
|
try {
|
|
1504
1504
|
return await Cr(e);
|
|
1505
1505
|
} catch (i) {
|
|
1506
|
-
if (r =
|
|
1506
|
+
if (r = Me(i), s < t) {
|
|
1507
1507
|
const n = Math.min(1e3 * Math.pow(2, s - 1), 5e3);
|
|
1508
1508
|
await new Promise((c) => setTimeout(c, n));
|
|
1509
1509
|
continue;
|
|
@@ -1511,7 +1511,7 @@ async function Tr(e, t = 3) {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
throw r;
|
|
1513
1513
|
}
|
|
1514
|
-
async function
|
|
1514
|
+
async function Mr(e, t) {
|
|
1515
1515
|
try {
|
|
1516
1516
|
return await Ee(e).get(t);
|
|
1517
1517
|
} catch (r) {
|
|
@@ -1520,7 +1520,7 @@ async function Lr(e, t) {
|
|
|
1520
1520
|
);
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
|
-
async function
|
|
1523
|
+
async function Lr(e, t, r, s) {
|
|
1524
1524
|
try {
|
|
1525
1525
|
let i;
|
|
1526
1526
|
if (t === "create")
|
|
@@ -1915,13 +1915,13 @@ function Zr(e) {
|
|
|
1915
1915
|
onSchemaError: w,
|
|
1916
1916
|
skipSchemaFetch: V = !1,
|
|
1917
1917
|
schema: N,
|
|
1918
|
-
interactionMode:
|
|
1918
|
+
interactionMode: S = "interactive",
|
|
1919
1919
|
enableDraftInUpdateMode: A = !1
|
|
1920
|
-
} = e, v =
|
|
1920
|
+
} = e, v = S === "interactive", [y, P] = pe(
|
|
1921
1921
|
null
|
|
1922
1922
|
), [H, Q] = pe(
|
|
1923
1923
|
{}
|
|
1924
|
-
), [_, te] = pe(!1), [re] = pe({}), [
|
|
1924
|
+
), [_, te] = pe(!1), [re] = pe({}), [D, de] = pe(null), [ge, ne] = pe(!1), [fe, Y] = pe(null), le = Oe(!1), E = Oe(null), x = Oe(null), M = Oe(!1), O = Oe(w);
|
|
1925
1925
|
He(() => {
|
|
1926
1926
|
O.current = w;
|
|
1927
1927
|
}, [w]);
|
|
@@ -1942,11 +1942,11 @@ function Zr(e) {
|
|
|
1942
1942
|
throwOnError: !1
|
|
1943
1943
|
}), {
|
|
1944
1944
|
data: J,
|
|
1945
|
-
isLoading:
|
|
1946
|
-
error:
|
|
1945
|
+
isLoading: Ue,
|
|
1946
|
+
error: Be
|
|
1947
1947
|
} = mt({
|
|
1948
1948
|
queryKey: ["form-record", t, s],
|
|
1949
|
-
queryFn: () =>
|
|
1949
|
+
queryFn: () => Mr(t, s),
|
|
1950
1950
|
enabled: c && r === "update" && !!s,
|
|
1951
1951
|
retry: 3,
|
|
1952
1952
|
staleTime: 5 * 60 * 1e3,
|
|
@@ -1954,7 +1954,7 @@ function Zr(e) {
|
|
|
1954
1954
|
gcTime: 15 * 60 * 1e3,
|
|
1955
1955
|
// 15 minutes - keep records for a reasonable time
|
|
1956
1956
|
throwOnError: !1
|
|
1957
|
-
}), Je =
|
|
1957
|
+
}), Je = Ce(() => {
|
|
1958
1958
|
const d = { ...i };
|
|
1959
1959
|
if (r === "update" && J && Object.assign(d, J), y)
|
|
1960
1960
|
for (const [f, l] of Object.entries(y.fields))
|
|
@@ -1977,15 +1977,15 @@ function Zr(e) {
|
|
|
1977
1977
|
);
|
|
1978
1978
|
P(f);
|
|
1979
1979
|
} catch (f) {
|
|
1980
|
-
console.error("Schema processing failed:", f), (d = O.current) == null || d.call(O,
|
|
1980
|
+
console.error("Schema processing failed:", f), (d = O.current) == null || d.call(O, Me(f));
|
|
1981
1981
|
}
|
|
1982
1982
|
}, [W, h]), He(() => {
|
|
1983
1983
|
var d;
|
|
1984
1984
|
ue && ((d = O.current) == null || d.call(O, ue));
|
|
1985
1985
|
}, [ue]), He(() => {
|
|
1986
|
-
if (!v || r !== "create" || !y || !c ||
|
|
1986
|
+
if (!v || r !== "create" || !y || !c || D || M.current)
|
|
1987
1987
|
return;
|
|
1988
|
-
|
|
1988
|
+
M.current = !0;
|
|
1989
1989
|
let d = !0;
|
|
1990
1990
|
return (async () => {
|
|
1991
1991
|
ne(!0), Y(null);
|
|
@@ -2001,22 +2001,22 @@ function Zr(e) {
|
|
|
2001
2001
|
});
|
|
2002
2002
|
} catch (l) {
|
|
2003
2003
|
if (!d) return;
|
|
2004
|
-
console.error("Failed to create initial draft:", l), Y(
|
|
2004
|
+
console.error("Failed to create initial draft:", l), Y(Me(l)), M.current = !1;
|
|
2005
2005
|
} finally {
|
|
2006
2006
|
d && ne(!1);
|
|
2007
2007
|
}
|
|
2008
2008
|
})(), () => {
|
|
2009
2009
|
d = !1;
|
|
2010
2010
|
};
|
|
2011
|
-
}, [v, r, y, c,
|
|
2012
|
-
const
|
|
2011
|
+
}, [v, r, y, c, D, t]);
|
|
2012
|
+
const Ae = Ce(() => {
|
|
2013
2013
|
if (!y) return [];
|
|
2014
2014
|
const d = /* @__PURE__ */ new Set(), f = new Set(y.computedFields);
|
|
2015
2015
|
return Object.entries(y.fieldRules).forEach(([l, m]) => {
|
|
2016
2016
|
m.computation.forEach((p) => {
|
|
2017
2017
|
const b = y.rules.computation[p];
|
|
2018
|
-
b != null && b.ExpressionTree && Ot(b.ExpressionTree).forEach((
|
|
2019
|
-
y.fields[
|
|
2018
|
+
b != null && b.ExpressionTree && Ot(b.ExpressionTree).forEach((L) => {
|
|
2019
|
+
y.fields[L] && L !== l && !f.has(L) && d.add(L);
|
|
2020
2020
|
});
|
|
2021
2021
|
});
|
|
2022
2022
|
}), y.computedFields.forEach((l) => {
|
|
@@ -2027,10 +2027,10 @@ function Zr(e) {
|
|
|
2027
2027
|
y.fields[b] && b !== l && !f.has(b) && d.add(b);
|
|
2028
2028
|
});
|
|
2029
2029
|
}), Array.from(d);
|
|
2030
|
-
}, [y]),
|
|
2030
|
+
}, [y]), xe = se(
|
|
2031
2031
|
async (d) => {
|
|
2032
|
-
if (!(!y || r === "update" && !A || !(v && r !== "update" ||
|
|
2033
|
-
if (v && r === "create" && !
|
|
2032
|
+
if (!(!y || r === "update" && !A || !(v && r !== "update" || Ae.length > 0 && Ae.includes(d)))) {
|
|
2033
|
+
if (v && r === "create" && !D) {
|
|
2034
2034
|
console.warn("Interactive create mode: waiting for draft ID");
|
|
2035
2035
|
return;
|
|
2036
2036
|
}
|
|
@@ -2042,16 +2042,16 @@ function Zr(e) {
|
|
|
2042
2042
|
le.current = !0;
|
|
2043
2043
|
try {
|
|
2044
2044
|
const p = Ee(t), b = {};
|
|
2045
|
-
r === "update" && s && "_id" in l && (b._id = l._id), v && r === "create" &&
|
|
2046
|
-
const R = x.current ?? (r === "update" ? J : null) ?? {},
|
|
2045
|
+
r === "update" && s && "_id" in l && (b._id = l._id), v && r === "create" && D && (b._id = D);
|
|
2046
|
+
const R = x.current ?? (r === "update" ? J : null) ?? {}, L = new Set(
|
|
2047
2047
|
y.computedFields || []
|
|
2048
2048
|
);
|
|
2049
2049
|
Object.keys(l).forEach((k) => {
|
|
2050
2050
|
var ht;
|
|
2051
|
-
if (k === "_id" ||
|
|
2051
|
+
if (k === "_id" || L.has(k)) return;
|
|
2052
2052
|
let G = l[k];
|
|
2053
|
-
const
|
|
2054
|
-
if (JSON.stringify(G) !== JSON.stringify(
|
|
2053
|
+
const Ne = R[k];
|
|
2054
|
+
if (JSON.stringify(G) !== JSON.stringify(Ne) && (G !== "" && G !== null && G !== void 0)) {
|
|
2055
2055
|
const tt = y.fields[k];
|
|
2056
2056
|
((ht = tt == null ? void 0 : tt._bdoField) == null ? void 0 : ht.Type) === "Reference" && (G = qt(G)), b[k] = G;
|
|
2057
2057
|
}
|
|
@@ -2060,13 +2060,13 @@ function Zr(e) {
|
|
|
2060
2060
|
...x.current
|
|
2061
2061
|
};
|
|
2062
2062
|
Object.keys(l).forEach((k) => {
|
|
2063
|
-
|
|
2063
|
+
L.has(k) || (q[k] = l[k]);
|
|
2064
2064
|
}), x.current = q;
|
|
2065
2065
|
let j;
|
|
2066
2066
|
r === "update" && s ? j = await p.draftPatch(
|
|
2067
2067
|
s,
|
|
2068
2068
|
C
|
|
2069
|
-
) : v &&
|
|
2069
|
+
) : v && D ? j = await p.draftInteraction(C) : j = await p.draft(C), j && typeof j == "object" && (Object.entries(j).forEach(
|
|
2070
2070
|
([k, G]) => {
|
|
2071
2071
|
l[k] !== G && F.setValue(k, G, {
|
|
2072
2072
|
shouldDirty: !1,
|
|
@@ -2075,7 +2075,7 @@ function Zr(e) {
|
|
|
2075
2075
|
}
|
|
2076
2076
|
), Object.entries(j).forEach(
|
|
2077
2077
|
([k, G]) => {
|
|
2078
|
-
|
|
2078
|
+
L.has(k) && (x.current[k] = G);
|
|
2079
2079
|
}
|
|
2080
2080
|
));
|
|
2081
2081
|
} catch (p) {
|
|
@@ -2094,9 +2094,9 @@ function Zr(e) {
|
|
|
2094
2094
|
J,
|
|
2095
2095
|
t,
|
|
2096
2096
|
F,
|
|
2097
|
-
|
|
2097
|
+
Ae,
|
|
2098
2098
|
v,
|
|
2099
|
-
|
|
2099
|
+
D,
|
|
2100
2100
|
A
|
|
2101
2101
|
]
|
|
2102
2102
|
), Ge = se(async () => {
|
|
@@ -2109,7 +2109,7 @@ function Zr(e) {
|
|
|
2109
2109
|
Id: p.Id,
|
|
2110
2110
|
Condition: { ExpressionTree: p.ExpressionTree },
|
|
2111
2111
|
Message: p.Message || `Validation failed for ${p.Name}`
|
|
2112
|
-
})), m =
|
|
2112
|
+
})), m = Dt(
|
|
2113
2113
|
l,
|
|
2114
2114
|
d,
|
|
2115
2115
|
H
|
|
@@ -2126,7 +2126,7 @@ function Zr(e) {
|
|
|
2126
2126
|
F.trigger,
|
|
2127
2127
|
F.setError,
|
|
2128
2128
|
H
|
|
2129
|
-
]),
|
|
2129
|
+
]), _e = se(
|
|
2130
2130
|
(d, f) => F.handleSubmit(
|
|
2131
2131
|
// RHF onValid handler - validation passed, now do cross-field + API
|
|
2132
2132
|
async (l, m) => {
|
|
@@ -2143,7 +2143,7 @@ function Zr(e) {
|
|
|
2143
2143
|
Condition: { ExpressionTree: q.ExpressionTree },
|
|
2144
2144
|
Message: q.Message || `Validation failed for ${q.Name}`
|
|
2145
2145
|
})
|
|
2146
|
-
), b =
|
|
2146
|
+
), b = Dt(
|
|
2147
2147
|
p,
|
|
2148
2148
|
l,
|
|
2149
2149
|
H
|
|
@@ -2163,7 +2163,7 @@ function Zr(e) {
|
|
|
2163
2163
|
R[q] = j._bdoField.Type;
|
|
2164
2164
|
}
|
|
2165
2165
|
);
|
|
2166
|
-
const
|
|
2166
|
+
const L = Ir(
|
|
2167
2167
|
l,
|
|
2168
2168
|
y.computedFields,
|
|
2169
2169
|
r,
|
|
@@ -2174,26 +2174,26 @@ function Zr(e) {
|
|
|
2174
2174
|
if (v) {
|
|
2175
2175
|
const q = Ee(t);
|
|
2176
2176
|
if (r === "create") {
|
|
2177
|
-
if (!
|
|
2177
|
+
if (!D)
|
|
2178
2178
|
throw new Error(
|
|
2179
2179
|
"Interactive create mode requires a draft ID. Draft creation may have failed."
|
|
2180
2180
|
);
|
|
2181
2181
|
C = { success: !0, data: await q.draft({
|
|
2182
|
-
...
|
|
2183
|
-
_id:
|
|
2182
|
+
...L,
|
|
2183
|
+
_id: D
|
|
2184
2184
|
}) };
|
|
2185
2185
|
} else
|
|
2186
|
-
C = { success: !0, data: await q.update(s,
|
|
2187
|
-
} else if (C = await
|
|
2186
|
+
C = { success: !0, data: await q.update(s, L) };
|
|
2187
|
+
} else if (C = await Lr(
|
|
2188
2188
|
t,
|
|
2189
2189
|
r,
|
|
2190
|
-
|
|
2190
|
+
L,
|
|
2191
2191
|
s
|
|
2192
2192
|
), !C.success)
|
|
2193
2193
|
throw C.error || new Error("Submission failed");
|
|
2194
2194
|
r === "create" && (F.reset(), v && de(null)), await (d == null ? void 0 : d(C.data || l, m));
|
|
2195
2195
|
} catch (p) {
|
|
2196
|
-
f == null || f(
|
|
2196
|
+
f == null || f(Me(p), m);
|
|
2197
2197
|
} finally {
|
|
2198
2198
|
te(!1);
|
|
2199
2199
|
}
|
|
@@ -2212,9 +2212,9 @@ function Zr(e) {
|
|
|
2212
2212
|
s,
|
|
2213
2213
|
J,
|
|
2214
2214
|
v,
|
|
2215
|
-
|
|
2215
|
+
D
|
|
2216
2216
|
]
|
|
2217
|
-
),
|
|
2217
|
+
), Pe = se(
|
|
2218
2218
|
(d) => (y == null ? void 0 : y.fields[d]) || null,
|
|
2219
2219
|
[y]
|
|
2220
2220
|
), Se = se(() => {
|
|
@@ -2223,26 +2223,26 @@ function Zr(e) {
|
|
|
2223
2223
|
return Object.entries(y.fields).forEach(([f, l]) => {
|
|
2224
2224
|
d[f] = l;
|
|
2225
2225
|
}), d;
|
|
2226
|
-
}, [y]),
|
|
2226
|
+
}, [y]), De = se(
|
|
2227
2227
|
(d) => !!(y != null && y.fields[d]),
|
|
2228
2228
|
[y]
|
|
2229
2229
|
), Xe = se(
|
|
2230
2230
|
(d) => (y == null ? void 0 : y.requiredFields.includes(d)) || !1,
|
|
2231
2231
|
[y]
|
|
2232
|
-
),
|
|
2232
|
+
), qe = se(
|
|
2233
2233
|
(d) => (y == null ? void 0 : y.computedFields.includes(d)) || !1,
|
|
2234
2234
|
[y]
|
|
2235
2235
|
), Qe = se(async () => {
|
|
2236
2236
|
await he();
|
|
2237
|
-
}, [he]),
|
|
2237
|
+
}, [he]), $e = se(() => {
|
|
2238
2238
|
F.clearErrors();
|
|
2239
|
-
}, [F]),
|
|
2239
|
+
}, [F]), je = K || r === "update" && Ue || v && r === "create" && ge, Ze = _, Re = ue || Be || fe, dt = !!Re, We = Ce(
|
|
2240
2240
|
() => (y == null ? void 0 : y.computedFields) || [],
|
|
2241
2241
|
[y]
|
|
2242
|
-
), a =
|
|
2242
|
+
), a = Ce(
|
|
2243
2243
|
() => (y == null ? void 0 : y.requiredFields) || [],
|
|
2244
2244
|
[y]
|
|
2245
|
-
), u =
|
|
2245
|
+
), u = Ce(() => {
|
|
2246
2246
|
if (!y) return {};
|
|
2247
2247
|
const d = {};
|
|
2248
2248
|
return Object.entries(y.fields).forEach(([f, l]) => {
|
|
@@ -2260,8 +2260,8 @@ function Zr(e) {
|
|
|
2260
2260
|
p.length > 0 && (m.validate = {
|
|
2261
2261
|
expressionValidation: (b) => {
|
|
2262
2262
|
const R = F.getValues();
|
|
2263
|
-
for (const
|
|
2264
|
-
const C = y.rules.validation[
|
|
2263
|
+
for (const L of p) {
|
|
2264
|
+
const C = y.rules.validation[L];
|
|
2265
2265
|
if (C) {
|
|
2266
2266
|
const q = $r(
|
|
2267
2267
|
f,
|
|
@@ -2286,7 +2286,7 @@ function Zr(e) {
|
|
|
2286
2286
|
const l = u[d], m = f == null ? void 0 : f.onBlur, p = async (b) => {
|
|
2287
2287
|
m && await m(b);
|
|
2288
2288
|
let R = !0;
|
|
2289
|
-
n === "onBlur" || n === "onTouched" || n === "all" ? R = await F.trigger(d) : R = !F.getFieldState(d, F.formState).error, R && await
|
|
2289
|
+
n === "onBlur" || n === "onTouched" || n === "all" ? R = await F.trigger(d) : R = !F.getFieldState(d, F.formState).error, R && await xe(d);
|
|
2290
2290
|
};
|
|
2291
2291
|
return F.register(d, {
|
|
2292
2292
|
...l,
|
|
@@ -2294,9 +2294,9 @@ function Zr(e) {
|
|
|
2294
2294
|
onBlur: p
|
|
2295
2295
|
});
|
|
2296
2296
|
},
|
|
2297
|
-
[F, u,
|
|
2297
|
+
[F, u, xe, n]
|
|
2298
2298
|
),
|
|
2299
|
-
handleSubmit:
|
|
2299
|
+
handleSubmit: _e,
|
|
2300
2300
|
watch: F.watch,
|
|
2301
2301
|
// Type assertion for complex generic constraints
|
|
2302
2302
|
setValue: F.setValue,
|
|
@@ -2308,14 +2308,13 @@ function Zr(e) {
|
|
|
2308
2308
|
isSubmitting: F.formState.isSubmitting || _,
|
|
2309
2309
|
isSubmitSuccessful: F.formState.isSubmitSuccessful,
|
|
2310
2310
|
// Loading states
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
isLoading: Ze,
|
|
2311
|
+
isLoading: je,
|
|
2312
|
+
isFetching: Ze,
|
|
2314
2313
|
// Interactive mode state
|
|
2315
|
-
draftId:
|
|
2314
|
+
draftId: D,
|
|
2316
2315
|
isCreatingDraft: ge,
|
|
2317
2316
|
// Error handling
|
|
2318
|
-
loadError:
|
|
2317
|
+
loadError: Re ? Me(Re) : null,
|
|
2319
2318
|
hasError: dt,
|
|
2320
2319
|
// Schema information
|
|
2321
2320
|
schema: W,
|
|
@@ -2323,15 +2322,15 @@ function Zr(e) {
|
|
|
2323
2322
|
computedFields: We,
|
|
2324
2323
|
requiredFields: a,
|
|
2325
2324
|
// Field helpers
|
|
2326
|
-
getField:
|
|
2325
|
+
getField: Pe,
|
|
2327
2326
|
getFields: Se,
|
|
2328
|
-
hasField:
|
|
2327
|
+
hasField: De,
|
|
2329
2328
|
isFieldRequired: Xe,
|
|
2330
|
-
isFieldComputed:
|
|
2329
|
+
isFieldComputed: qe,
|
|
2331
2330
|
// Operations
|
|
2332
2331
|
refreshSchema: Qe,
|
|
2333
2332
|
validateForm: Ge,
|
|
2334
|
-
clearErrors:
|
|
2333
|
+
clearErrors: $e
|
|
2335
2334
|
};
|
|
2336
2335
|
}
|
|
2337
2336
|
export {
|