@ram_28/kf-ai-sdk 1.0.16 → 1.0.19
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/api/client.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
- package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +1 -1
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +740 -740
- package/dist/kanban.cjs +1 -1
- package/dist/kanban.mjs +4 -2
- package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
- package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +1 -1
- package/docs/QUICK_REFERENCE.md +528 -0
- package/docs/useAuth.md +402 -0
- package/docs/useFilter.md +273 -0
- package/docs/useForm.md +629 -0
- package/docs/useKanban.md +421 -0
- package/docs/useTable.md +372 -0
- package/package.json +4 -2
- package/sdk/api/client.ts +7 -1
- package/sdk/components/hooks/useForm/useForm.ts +12 -2
- package/sdk/components/hooks/useKanban/context.ts +5 -3
package/dist/form.mjs
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
var Bt = Object.defineProperty;
|
|
2
2
|
var Pt = (e, t, r) => t in e ? Bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
-
var
|
|
4
|
-
import X, { useState as
|
|
5
|
-
import { useQuery as
|
|
6
|
-
import { a as
|
|
7
|
-
import { g as qt } from "./metadata-
|
|
8
|
-
var
|
|
9
|
-
const
|
|
10
|
-
var
|
|
3
|
+
var ve = (e, t, r) => Pt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import X, { useState as ge, useRef as Se, useEffect as We, useMemo as Re, useCallback as te } from "react";
|
|
5
|
+
import { useQuery as dt } from "@tanstack/react-query";
|
|
6
|
+
import { a as be } from "./client-V-WzUb8H.js";
|
|
7
|
+
import { g as qt } from "./metadata-B88D_pVS.js";
|
|
8
|
+
var Te = (e) => e.type === "checkbox", pe = (e) => e instanceof Date, J = (e) => e == null;
|
|
9
|
+
const Rt = (e) => typeof e == "object";
|
|
10
|
+
var U = (e) => !J(e) && !Array.isArray(e) && Rt(e) && !pe(e), $t = (e) => U(e) && e.target ? Te(e.target) ? e.target.checked : e.target.value : e, jt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Wt = (e, t) => e.has(jt(t)), Ht = (e) => {
|
|
11
11
|
const t = e.constructor && e.constructor.prototype;
|
|
12
|
-
return
|
|
13
|
-
},
|
|
14
|
-
function
|
|
12
|
+
return U(t) && t.hasOwnProperty("isPrototypeOf");
|
|
13
|
+
}, st = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
14
|
+
function P(e) {
|
|
15
15
|
if (e instanceof Date)
|
|
16
16
|
return new Date(e);
|
|
17
17
|
const t = typeof FileList < "u" && e instanceof FileList;
|
|
18
|
-
if (
|
|
18
|
+
if (st && (e instanceof Blob || t))
|
|
19
19
|
return e;
|
|
20
20
|
const r = Array.isArray(e);
|
|
21
|
-
if (!r && !(
|
|
21
|
+
if (!r && !(U(e) && Ht(e)))
|
|
22
22
|
return e;
|
|
23
23
|
const s = r ? [] : Object.create(Object.getPrototypeOf(e));
|
|
24
24
|
for (const i in e)
|
|
25
|
-
Object.prototype.hasOwnProperty.call(e, i) && (s[i] =
|
|
25
|
+
Object.prototype.hasOwnProperty.call(e, i) && (s[i] = P(e[i]));
|
|
26
26
|
return s;
|
|
27
27
|
}
|
|
28
|
-
var
|
|
29
|
-
if (!t || !
|
|
28
|
+
var Ke = (e) => /^\w*$/.test(e), T = (e) => e === void 0, it = (e) => Array.isArray(e) ? e.filter(Boolean) : [], at = (e) => it(e.replace(/["|']|\]/g, "").split(/\.|\[/)), g = (e, t, r) => {
|
|
29
|
+
if (!t || !U(e))
|
|
30
30
|
return r;
|
|
31
|
-
const s = (
|
|
32
|
-
return
|
|
33
|
-
}, ie = (e) => typeof e == "boolean", re = (e) => typeof e == "function",
|
|
31
|
+
const s = (Ke(t) ? [t] : at(t)).reduce((i, n) => J(i) ? i : i[n], e);
|
|
32
|
+
return T(s) || s === e ? T(e[t]) ? r : e[t] : s;
|
|
33
|
+
}, ie = (e) => typeof e == "boolean", re = (e) => typeof e == "function", N = (e, t, r) => {
|
|
34
34
|
let s = -1;
|
|
35
|
-
const i =
|
|
35
|
+
const i = Ke(t) ? [t] : at(t), n = i.length, l = n - 1;
|
|
36
36
|
for (; ++s < n; ) {
|
|
37
|
-
const
|
|
37
|
+
const f = i[s];
|
|
38
38
|
let w = r;
|
|
39
39
|
if (s !== l) {
|
|
40
|
-
const
|
|
41
|
-
w =
|
|
40
|
+
const b = e[f];
|
|
41
|
+
w = U(b) || Array.isArray(b) ? b : isNaN(+i[s + 1]) ? {} : [];
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
43
|
+
if (f === "__proto__" || f === "constructor" || f === "prototype")
|
|
44
44
|
return;
|
|
45
|
-
e[
|
|
45
|
+
e[f] = w, e = e[f];
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
const
|
|
48
|
+
const ft = {
|
|
49
49
|
BLUR: "blur",
|
|
50
50
|
FOCUS_OUT: "focusout"
|
|
51
51
|
}, se = {
|
|
@@ -78,11 +78,11 @@ var Kt = (e, t, r, s = !0) => {
|
|
|
78
78
|
return i;
|
|
79
79
|
};
|
|
80
80
|
const zt = typeof window < "u" ? X.useLayoutEffect : X.useEffect;
|
|
81
|
-
var Q = (e) => typeof e == "string", Jt = (e, t, r, s, i) => Q(e) ? (s && t.watch.add(e), g(r, e, i)) : Array.isArray(e) ? e.map((n) => (s && t.watch.add(n), g(r, n))) : (s && (t.watchAll = !0), r),
|
|
82
|
-
function
|
|
83
|
-
if (
|
|
81
|
+
var Q = (e) => typeof e == "string", Jt = (e, t, r, s, i) => Q(e) ? (s && t.watch.add(e), g(r, e, i)) : Array.isArray(e) ? e.map((n) => (s && t.watch.add(n), g(r, n))) : (s && (t.watchAll = !0), r), tt = (e) => J(e) || !Rt(e);
|
|
82
|
+
function he(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
83
|
+
if (tt(e) || tt(t))
|
|
84
84
|
return Object.is(e, t);
|
|
85
|
-
if (
|
|
85
|
+
if (pe(e) && pe(t))
|
|
86
86
|
return Object.is(e.getTime(), t.getTime());
|
|
87
87
|
const s = Object.keys(e), i = Object.keys(t);
|
|
88
88
|
if (s.length !== i.length)
|
|
@@ -95,8 +95,8 @@ function de(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
|
95
95
|
if (!i.includes(n))
|
|
96
96
|
return !1;
|
|
97
97
|
if (n !== "ref") {
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
98
|
+
const f = t[n];
|
|
99
|
+
if (pe(l) && pe(f) || U(l) && U(f) || Array.isArray(l) && Array.isArray(f) ? !he(l, f, r) : !Object.is(l, f))
|
|
100
100
|
return !1;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -108,7 +108,7 @@ var Gt = (e, t, r, s, i) => t ? {
|
|
|
108
108
|
...r[e] && r[e].types ? r[e].types : {},
|
|
109
109
|
[s]: i || !0
|
|
110
110
|
}
|
|
111
|
-
} : {},
|
|
111
|
+
} : {}, Oe = (e) => Array.isArray(e) ? e : [e], ht = () => {
|
|
112
112
|
let e = [];
|
|
113
113
|
return {
|
|
114
114
|
get observers() {
|
|
@@ -128,40 +128,40 @@ var Gt = (e, t, r, s, i) => t ? {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
};
|
|
131
|
-
function
|
|
131
|
+
function Nt(e, t) {
|
|
132
132
|
const r = {};
|
|
133
133
|
for (const s in e)
|
|
134
134
|
if (e.hasOwnProperty(s)) {
|
|
135
135
|
const i = e[s], n = t[s];
|
|
136
|
-
if (i &&
|
|
137
|
-
const l =
|
|
138
|
-
|
|
136
|
+
if (i && U(i) && n) {
|
|
137
|
+
const l = Nt(i, n);
|
|
138
|
+
U(l) && (r[s] = l);
|
|
139
139
|
} else e[s] && (r[s] = n);
|
|
140
140
|
}
|
|
141
141
|
return r;
|
|
142
142
|
}
|
|
143
|
-
var
|
|
144
|
-
if (!
|
|
143
|
+
var H = (e) => U(e) && !Object.keys(e).length, nt = (e) => e.type === "file", He = (e) => {
|
|
144
|
+
if (!st)
|
|
145
145
|
return !1;
|
|
146
146
|
const t = e ? e.ownerDocument : 0;
|
|
147
147
|
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
148
|
-
},
|
|
148
|
+
}, Ot = (e) => e.type === "select-multiple", ut = (e) => e.type === "radio", Xt = (e) => ut(e) || Te(e), Ze = (e) => He(e) && e.isConnected;
|
|
149
149
|
function Qt(e, t) {
|
|
150
150
|
const r = t.slice(0, -1).length;
|
|
151
151
|
let s = 0;
|
|
152
152
|
for (; s < r; )
|
|
153
|
-
e =
|
|
153
|
+
e = T(e) ? s++ : e[t[s++]];
|
|
154
154
|
return e;
|
|
155
155
|
}
|
|
156
156
|
function Zt(e) {
|
|
157
157
|
for (const t in e)
|
|
158
|
-
if (e.hasOwnProperty(t) && !
|
|
158
|
+
if (e.hasOwnProperty(t) && !T(e[t]))
|
|
159
159
|
return !1;
|
|
160
160
|
return !0;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
const r = Array.isArray(t) ? t :
|
|
164
|
-
return s && delete s[n], i !== 0 && (
|
|
162
|
+
function k(e, t) {
|
|
163
|
+
const r = Array.isArray(t) ? t : Ke(t) ? [t] : at(t), s = r.length === 1 ? e : Qt(e, r), i = r.length - 1, n = r[i];
|
|
164
|
+
return s && delete s[n], i !== 0 && (U(s) && H(s) || Array.isArray(s) && Zt(s)) && k(e, r.slice(0, -1)), e;
|
|
165
165
|
}
|
|
166
166
|
var er = (e) => {
|
|
167
167
|
for (const t in e)
|
|
@@ -169,34 +169,34 @@ var er = (e) => {
|
|
|
169
169
|
return !0;
|
|
170
170
|
return !1;
|
|
171
171
|
};
|
|
172
|
-
function
|
|
173
|
-
return Array.isArray(e) ||
|
|
172
|
+
function Ct(e) {
|
|
173
|
+
return Array.isArray(e) || U(e) && !er(e);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function rt(e, t = {}) {
|
|
176
176
|
for (const r in e) {
|
|
177
177
|
const s = e[r];
|
|
178
|
-
|
|
178
|
+
Ct(s) ? (t[r] = Array.isArray(s) ? [] : {}, rt(s, t[r])) : T(s) || (t[r] = !0);
|
|
179
179
|
}
|
|
180
180
|
return t;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
r || (r =
|
|
182
|
+
function Ve(e, t, r) {
|
|
183
|
+
r || (r = rt(t));
|
|
184
184
|
for (const s in e) {
|
|
185
185
|
const i = e[s];
|
|
186
|
-
if (
|
|
187
|
-
|
|
186
|
+
if (Ct(i))
|
|
187
|
+
T(t) || tt(r[s]) ? r[s] = rt(i, Array.isArray(i) ? [] : {}) : Ve(i, J(t) ? {} : t[s], r[s]);
|
|
188
188
|
else {
|
|
189
189
|
const n = t[s];
|
|
190
|
-
r[s] = !
|
|
190
|
+
r[s] = !he(i, n);
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
return r;
|
|
194
194
|
}
|
|
195
|
-
const
|
|
195
|
+
const mt = {
|
|
196
196
|
value: !1,
|
|
197
197
|
isValid: !1
|
|
198
|
-
},
|
|
199
|
-
var
|
|
198
|
+
}, yt = { value: !0, isValid: !0 };
|
|
199
|
+
var Tt = (e) => {
|
|
200
200
|
if (Array.isArray(e)) {
|
|
201
201
|
if (e.length > 1) {
|
|
202
202
|
const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
|
|
@@ -204,28 +204,28 @@ var Ct = (e) => {
|
|
|
204
204
|
}
|
|
205
205
|
return e[0].checked && !e[0].disabled ? (
|
|
206
206
|
// @ts-expect-error expected to work in the browser
|
|
207
|
-
e[0].attributes && !
|
|
208
|
-
) :
|
|
207
|
+
e[0].attributes && !T(e[0].attributes.value) ? T(e[0].value) || e[0].value === "" ? yt : { value: e[0].value, isValid: !0 } : yt
|
|
208
|
+
) : mt;
|
|
209
209
|
}
|
|
210
|
-
return
|
|
211
|
-
},
|
|
212
|
-
const
|
|
210
|
+
return mt;
|
|
211
|
+
}, Lt = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: s }) => T(e) ? e : t ? e === "" ? NaN : e && +e : r && Q(e) ? new Date(e) : s ? s(e) : e;
|
|
212
|
+
const gt = {
|
|
213
213
|
isValid: !1,
|
|
214
214
|
value: null
|
|
215
215
|
};
|
|
216
|
-
var
|
|
216
|
+
var Mt = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
|
|
217
217
|
isValid: !0,
|
|
218
218
|
value: r.value
|
|
219
|
-
} : t,
|
|
220
|
-
function
|
|
219
|
+
} : t, gt) : gt;
|
|
220
|
+
function pt(e) {
|
|
221
221
|
const t = e.ref;
|
|
222
|
-
return
|
|
222
|
+
return nt(t) ? t.files : ut(t) ? Mt(e.refs).value : Ot(t) ? [...t.selectedOptions].map(({ value: r }) => r) : Te(t) ? Tt(e.refs).value : Lt(T(t.value) ? e.ref.value : t.value, e);
|
|
223
223
|
}
|
|
224
224
|
var tr = (e, t, r, s) => {
|
|
225
225
|
const i = {};
|
|
226
226
|
for (const n of e) {
|
|
227
227
|
const l = g(t, n);
|
|
228
|
-
l &&
|
|
228
|
+
l && N(i, n, l._f);
|
|
229
229
|
}
|
|
230
230
|
return {
|
|
231
231
|
criteriaMode: r,
|
|
@@ -233,53 +233,53 @@ var tr = (e, t, r, s) => {
|
|
|
233
233
|
fields: i,
|
|
234
234
|
shouldUseNativeValidation: s
|
|
235
235
|
};
|
|
236
|
-
},
|
|
236
|
+
}, Ye = (e) => e instanceof RegExp, Ne = (e) => T(e) ? e : Ye(e) ? e.source : U(e) ? Ye(e.value) ? e.value.source : e.value : e, bt = (e) => ({
|
|
237
237
|
isOnSubmit: !e || e === se.onSubmit,
|
|
238
238
|
isOnBlur: e === se.onBlur,
|
|
239
239
|
isOnChange: e === se.onChange,
|
|
240
240
|
isOnAll: e === se.all,
|
|
241
241
|
isOnTouch: e === se.onTouched
|
|
242
242
|
});
|
|
243
|
-
const
|
|
244
|
-
var rr = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name ===
|
|
245
|
-
const
|
|
243
|
+
const wt = "AsyncFunction";
|
|
244
|
+
var rr = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name === wt || U(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === wt)), sr = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), vt = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
|
|
245
|
+
const Ce = (e, t, r, s) => {
|
|
246
246
|
for (const i of r || Object.keys(e)) {
|
|
247
247
|
const n = g(e, i);
|
|
248
248
|
if (n) {
|
|
249
|
-
const { _f: l, ...
|
|
249
|
+
const { _f: l, ...f } = n;
|
|
250
250
|
if (l) {
|
|
251
251
|
if (l.refs && l.refs[0] && t(l.refs[0], i) && !s)
|
|
252
252
|
return !0;
|
|
253
253
|
if (l.ref && t(l.ref, l.name) && !s)
|
|
254
254
|
return !0;
|
|
255
|
-
if (
|
|
255
|
+
if (Ce(f, t))
|
|
256
256
|
break;
|
|
257
|
-
} else if (
|
|
257
|
+
} else if (U(f) && Ce(f, t))
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
|
-
function
|
|
262
|
+
function Ft(e, t, r) {
|
|
263
263
|
const s = g(e, r);
|
|
264
|
-
if (s ||
|
|
264
|
+
if (s || Ke(r))
|
|
265
265
|
return {
|
|
266
266
|
error: s,
|
|
267
267
|
name: r
|
|
268
268
|
};
|
|
269
269
|
const i = r.split(".");
|
|
270
270
|
for (; i.length; ) {
|
|
271
|
-
const n = i.join("."), l = g(t, n),
|
|
271
|
+
const n = i.join("."), l = g(t, n), f = g(e, n);
|
|
272
272
|
if (l && !Array.isArray(l) && r !== n)
|
|
273
273
|
return { name: r };
|
|
274
|
-
if (
|
|
274
|
+
if (f && f.type)
|
|
275
275
|
return {
|
|
276
276
|
name: n,
|
|
277
|
-
error:
|
|
277
|
+
error: f
|
|
278
278
|
};
|
|
279
|
-
if (
|
|
279
|
+
if (f && f.root && f.root.type)
|
|
280
280
|
return {
|
|
281
281
|
name: `${n}.root`,
|
|
282
|
-
error:
|
|
282
|
+
error: f.root
|
|
283
283
|
};
|
|
284
284
|
i.pop();
|
|
285
285
|
}
|
|
@@ -290,12 +290,12 @@ function vt(e, t, r) {
|
|
|
290
290
|
var ir = (e, t, r, s) => {
|
|
291
291
|
r(e);
|
|
292
292
|
const { name: i, ...n } = e;
|
|
293
|
-
return
|
|
294
|
-
}, ar = (e, t, r) => !e || !t || e === t ||
|
|
295
|
-
const s =
|
|
296
|
-
return
|
|
293
|
+
return H(n) || Object.keys(n).length >= Object.keys(t).length || Object.keys(n).find((l) => t[l] === (!s || se.all));
|
|
294
|
+
}, ar = (e, t, r) => !e || !t || e === t || Oe(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), nr = (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, ur = (e, t) => !it(g(e, t)).length && k(e, t), or = (e, t, r) => {
|
|
295
|
+
const s = Oe(g(e, r));
|
|
296
|
+
return N(s, "root", t[r]), N(e, r, s), e;
|
|
297
297
|
};
|
|
298
|
-
function
|
|
298
|
+
function Vt(e, t, r = "validate") {
|
|
299
299
|
if (Q(e) || Array.isArray(e) && e.every(Q) || ie(e) && !e)
|
|
300
300
|
return {
|
|
301
301
|
type: r,
|
|
@@ -303,89 +303,89 @@ function Ft(e, t, r = "validate") {
|
|
|
303
303
|
ref: t
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
|
-
var
|
|
306
|
+
var Fe = (e) => U(e) && !Ye(e) ? e : {
|
|
307
307
|
value: e,
|
|
308
308
|
message: ""
|
|
309
|
-
},
|
|
310
|
-
const { ref: l, refs:
|
|
311
|
-
if (!
|
|
309
|
+
}, Et = async (e, t, r, s, i, n) => {
|
|
310
|
+
const { ref: l, refs: f, required: w, maxLength: b, minLength: O, min: D, max: v, pattern: m, validate: Y, name: C, valueAsNumber: Z, mount: W } = e._f, A = g(r, C);
|
|
311
|
+
if (!W || t.has(C))
|
|
312
312
|
return {};
|
|
313
|
-
const ee =
|
|
313
|
+
const ee = f ? f[0] : l, M = (V) => {
|
|
314
314
|
i && ee.reportValidity && (ee.setCustomValidity(ie(V) ? "" : V || ""), ee.reportValidity());
|
|
315
|
-
},
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
type: V ?
|
|
319
|
-
message:
|
|
315
|
+
}, L = {}, le = ut(l), ye = Te(l), ae = le || ye, ne = (Z || nt(l)) && T(l.value) && T(A) || He(l) && l.value === "" || A === "" || Array.isArray(A) && !A.length, j = Gt.bind(null, C, s, L), ce = (V, x, S, I = oe.maxLength, G = oe.minLength) => {
|
|
316
|
+
const q = V ? x : S;
|
|
317
|
+
L[C] = {
|
|
318
|
+
type: V ? I : G,
|
|
319
|
+
message: q,
|
|
320
320
|
ref: l,
|
|
321
|
-
...
|
|
321
|
+
...j(V ? I : G, q)
|
|
322
322
|
};
|
|
323
323
|
};
|
|
324
|
-
if (n ? !Array.isArray(
|
|
325
|
-
const { value: V, message:
|
|
326
|
-
if (V && (
|
|
324
|
+
if (n ? !Array.isArray(A) || !A.length : w && (!ae && (ne || J(A)) || ie(A) && !A || ye && !Tt(f).isValid || le && !Mt(f).isValid)) {
|
|
325
|
+
const { value: V, message: x } = Q(w) ? { value: !!w, message: w } : Fe(w);
|
|
326
|
+
if (V && (L[C] = {
|
|
327
327
|
type: oe.required,
|
|
328
|
-
message:
|
|
328
|
+
message: x,
|
|
329
329
|
ref: ee,
|
|
330
|
-
...
|
|
330
|
+
...j(oe.required, x)
|
|
331
331
|
}, !s))
|
|
332
|
-
return
|
|
332
|
+
return M(x), L;
|
|
333
333
|
}
|
|
334
|
-
if (!ne && (!
|
|
335
|
-
let V,
|
|
336
|
-
const S =
|
|
337
|
-
if (!
|
|
338
|
-
const
|
|
339
|
-
|
|
334
|
+
if (!ne && (!J(D) || !J(v))) {
|
|
335
|
+
let V, x;
|
|
336
|
+
const S = Fe(v), I = Fe(D);
|
|
337
|
+
if (!J(A) && !isNaN(A)) {
|
|
338
|
+
const G = l.valueAsNumber || A && +A;
|
|
339
|
+
J(S.value) || (V = G > S.value), J(I.value) || (x = G < I.value);
|
|
340
340
|
} else {
|
|
341
|
-
const
|
|
342
|
-
Q(S.value) &&
|
|
341
|
+
const G = l.valueAsDate || new Date(A), q = (fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + fe), de = l.type == "time", K = l.type == "week";
|
|
342
|
+
Q(S.value) && A && (V = de ? q(A) > q(S.value) : K ? A > S.value : G > new Date(S.value)), Q(I.value) && A && (x = de ? q(A) < q(I.value) : K ? A < I.value : G < new Date(I.value));
|
|
343
343
|
}
|
|
344
|
-
if ((V ||
|
|
345
|
-
return L
|
|
344
|
+
if ((V || x) && (ce(!!V, S.message, I.message, oe.max, oe.min), !s))
|
|
345
|
+
return M(L[C].message), L;
|
|
346
346
|
}
|
|
347
|
-
if ((
|
|
348
|
-
const V =
|
|
349
|
-
if ((S ||
|
|
350
|
-
return L
|
|
347
|
+
if ((b || O) && !ne && (Q(A) || n && Array.isArray(A))) {
|
|
348
|
+
const V = Fe(b), x = Fe(O), S = !J(V.value) && A.length > +V.value, I = !J(x.value) && A.length < +x.value;
|
|
349
|
+
if ((S || I) && (ce(S, V.message, x.message), !s))
|
|
350
|
+
return M(L[C].message), L;
|
|
351
351
|
}
|
|
352
|
-
if (m && !ne && Q(
|
|
353
|
-
const { value: V, message:
|
|
354
|
-
if (
|
|
352
|
+
if (m && !ne && Q(A)) {
|
|
353
|
+
const { value: V, message: x } = Fe(m);
|
|
354
|
+
if (Ye(V) && !A.match(V) && (L[C] = {
|
|
355
355
|
type: oe.pattern,
|
|
356
|
-
message:
|
|
356
|
+
message: x,
|
|
357
357
|
ref: l,
|
|
358
|
-
...
|
|
358
|
+
...j(oe.pattern, x)
|
|
359
359
|
}, !s))
|
|
360
|
-
return
|
|
360
|
+
return M(x), L;
|
|
361
361
|
}
|
|
362
|
-
if (
|
|
363
|
-
if (re(
|
|
364
|
-
const V = await
|
|
365
|
-
if (
|
|
366
|
-
...
|
|
367
|
-
...
|
|
362
|
+
if (Y) {
|
|
363
|
+
if (re(Y)) {
|
|
364
|
+
const V = await Y(A, r), x = Vt(V, ee);
|
|
365
|
+
if (x && (L[C] = {
|
|
366
|
+
...x,
|
|
367
|
+
...j(oe.validate, x.message)
|
|
368
368
|
}, !s))
|
|
369
|
-
return
|
|
370
|
-
} else if (
|
|
369
|
+
return M(x.message), L;
|
|
370
|
+
} else if (U(Y)) {
|
|
371
371
|
let V = {};
|
|
372
|
-
for (const
|
|
373
|
-
if (!
|
|
372
|
+
for (const x in Y) {
|
|
373
|
+
if (!H(V) && !s)
|
|
374
374
|
break;
|
|
375
|
-
const S =
|
|
375
|
+
const S = Vt(await Y[x](A, r), ee, x);
|
|
376
376
|
S && (V = {
|
|
377
377
|
...S,
|
|
378
|
-
...
|
|
379
|
-
},
|
|
378
|
+
...j(x, S.message)
|
|
379
|
+
}, M(S.message), s && (L[C] = V));
|
|
380
380
|
}
|
|
381
|
-
if (!
|
|
381
|
+
if (!H(V) && (L[C] = {
|
|
382
382
|
ref: ee,
|
|
383
383
|
...V
|
|
384
384
|
}, !s))
|
|
385
|
-
return
|
|
385
|
+
return L;
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
return
|
|
388
|
+
return M(!0), L;
|
|
389
389
|
};
|
|
390
390
|
const lr = {
|
|
391
391
|
mode: se.onSubmit,
|
|
@@ -411,19 +411,19 @@ function cr(e = {}) {
|
|
|
411
411
|
validatingFields: {},
|
|
412
412
|
errors: t.errors || {},
|
|
413
413
|
disabled: t.disabled || !1
|
|
414
|
-
}, s = {}, i =
|
|
414
|
+
}, s = {}, i = U(t.defaultValues) || U(t.values) ? P(t.defaultValues || t.values) || {} : {}, n = t.shouldUnregister ? {} : P(i), l = {
|
|
415
415
|
action: !1,
|
|
416
416
|
mount: !1,
|
|
417
417
|
watch: !1,
|
|
418
418
|
keepIsValid: !1
|
|
419
|
-
},
|
|
419
|
+
}, f = {
|
|
420
420
|
mount: /* @__PURE__ */ new Set(),
|
|
421
421
|
disabled: /* @__PURE__ */ new Set(),
|
|
422
422
|
unMount: /* @__PURE__ */ new Set(),
|
|
423
423
|
array: /* @__PURE__ */ new Set(),
|
|
424
424
|
watch: /* @__PURE__ */ new Set()
|
|
425
|
-
}, w,
|
|
426
|
-
const
|
|
425
|
+
}, w, b = 0;
|
|
426
|
+
const O = {
|
|
427
427
|
isDirty: !1,
|
|
428
428
|
dirtyFields: !1,
|
|
429
429
|
validatingFields: !1,
|
|
@@ -432,45 +432,45 @@ function cr(e = {}) {
|
|
|
432
432
|
isValid: !1,
|
|
433
433
|
errors: !1
|
|
434
434
|
}, D = {
|
|
435
|
-
...
|
|
435
|
+
...O
|
|
436
436
|
};
|
|
437
437
|
let v = {
|
|
438
438
|
...D
|
|
439
439
|
};
|
|
440
440
|
const m = {
|
|
441
|
-
array:
|
|
442
|
-
state:
|
|
443
|
-
},
|
|
444
|
-
clearTimeout(
|
|
441
|
+
array: ht(),
|
|
442
|
+
state: ht()
|
|
443
|
+
}, Y = t.criteriaMode === se.all, C = (a) => (o) => {
|
|
444
|
+
clearTimeout(b), b = setTimeout(a, o);
|
|
445
445
|
}, Z = async (a) => {
|
|
446
446
|
if (!l.keepIsValid && !t.disabled && (D.isValid || v.isValid || a)) {
|
|
447
447
|
let o;
|
|
448
|
-
t.resolver ? (o =
|
|
448
|
+
t.resolver ? (o = H((await ae()).errors), W()) : o = await j(s, !0), o !== r.isValid && m.state.next({
|
|
449
449
|
isValid: o
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
|
-
},
|
|
453
|
-
!t.disabled && (D.isValidating || D.validatingFields || v.isValidating || v.validatingFields) && ((a || Array.from(
|
|
454
|
-
u && (o ?
|
|
452
|
+
}, W = (a, o) => {
|
|
453
|
+
!t.disabled && (D.isValidating || D.validatingFields || v.isValidating || v.validatingFields) && ((a || Array.from(f.mount)).forEach((u) => {
|
|
454
|
+
u && (o ? N(r.validatingFields, u, o) : k(r.validatingFields, u));
|
|
455
455
|
}), m.state.next({
|
|
456
456
|
validatingFields: r.validatingFields,
|
|
457
|
-
isValidating: !
|
|
457
|
+
isValidating: !H(r.validatingFields)
|
|
458
458
|
}));
|
|
459
|
-
},
|
|
460
|
-
if (
|
|
461
|
-
if (l.action = !0,
|
|
462
|
-
const y = u(g(s, a),
|
|
463
|
-
|
|
459
|
+
}, A = (a, o = [], u, h, c = !0, d = !0) => {
|
|
460
|
+
if (h && u && !t.disabled) {
|
|
461
|
+
if (l.action = !0, d && Array.isArray(g(s, a))) {
|
|
462
|
+
const y = u(g(s, a), h.argA, h.argB);
|
|
463
|
+
c && N(s, a, y);
|
|
464
464
|
}
|
|
465
|
-
if (
|
|
466
|
-
const y = u(g(r.errors, a),
|
|
467
|
-
|
|
465
|
+
if (d && Array.isArray(g(r.errors, a))) {
|
|
466
|
+
const y = u(g(r.errors, a), h.argA, h.argB);
|
|
467
|
+
c && N(r.errors, a, y), ur(r.errors, a);
|
|
468
468
|
}
|
|
469
|
-
if ((D.touchedFields || v.touchedFields) &&
|
|
470
|
-
const y = u(g(r.touchedFields, a),
|
|
471
|
-
|
|
469
|
+
if ((D.touchedFields || v.touchedFields) && d && Array.isArray(g(r.touchedFields, a))) {
|
|
470
|
+
const y = u(g(r.touchedFields, a), h.argA, h.argB);
|
|
471
|
+
c && N(r.touchedFields, a, y);
|
|
472
472
|
}
|
|
473
|
-
(D.dirtyFields || v.dirtyFields) && (r.dirtyFields =
|
|
473
|
+
(D.dirtyFields || v.dirtyFields) && (r.dirtyFields = Ve(i, n)), m.state.next({
|
|
474
474
|
name: a,
|
|
475
475
|
isDirty: V(a, o),
|
|
476
476
|
dirtyFields: r.dirtyFields,
|
|
@@ -478,46 +478,46 @@ function cr(e = {}) {
|
|
|
478
478
|
isValid: r.isValid
|
|
479
479
|
});
|
|
480
480
|
} else
|
|
481
|
-
|
|
481
|
+
N(n, a, o);
|
|
482
482
|
}, ee = (a, o) => {
|
|
483
|
-
|
|
483
|
+
N(r.errors, a, o), m.state.next({
|
|
484
484
|
errors: r.errors
|
|
485
485
|
});
|
|
486
|
-
},
|
|
486
|
+
}, M = (a) => {
|
|
487
487
|
r.errors = a, m.state.next({
|
|
488
488
|
errors: r.errors,
|
|
489
489
|
isValid: !1
|
|
490
490
|
});
|
|
491
|
-
},
|
|
492
|
-
const
|
|
493
|
-
if (
|
|
494
|
-
const
|
|
495
|
-
|
|
491
|
+
}, L = (a, o, u, h) => {
|
|
492
|
+
const c = g(s, a);
|
|
493
|
+
if (c) {
|
|
494
|
+
const d = g(n, a, T(u) ? g(i, a) : u);
|
|
495
|
+
T(d) || h && h.defaultChecked || o ? N(n, a, o ? d : pt(c._f)) : I(a, d), l.mount && !l.action && Z();
|
|
496
496
|
}
|
|
497
|
-
},
|
|
498
|
-
let
|
|
499
|
-
const
|
|
497
|
+
}, le = (a, o, u, h, c) => {
|
|
498
|
+
let d = !1, y = !1;
|
|
499
|
+
const p = {
|
|
500
500
|
name: a
|
|
501
501
|
};
|
|
502
502
|
if (!t.disabled) {
|
|
503
|
-
if (!u ||
|
|
504
|
-
(D.isDirty || v.isDirty) && (y = r.isDirty, r.isDirty =
|
|
505
|
-
const
|
|
506
|
-
y = !!g(r.dirtyFields, a),
|
|
503
|
+
if (!u || h) {
|
|
504
|
+
(D.isDirty || v.isDirty) && (y = r.isDirty, r.isDirty = p.isDirty = V(), d = y !== p.isDirty);
|
|
505
|
+
const F = he(g(i, a), o);
|
|
506
|
+
y = !!g(r.dirtyFields, a), F ? k(r.dirtyFields, a) : N(r.dirtyFields, a, !0), p.dirtyFields = r.dirtyFields, d = d || (D.dirtyFields || v.dirtyFields) && y !== !F;
|
|
507
507
|
}
|
|
508
508
|
if (u) {
|
|
509
|
-
const
|
|
510
|
-
|
|
509
|
+
const F = g(r.touchedFields, a);
|
|
510
|
+
F || (N(r.touchedFields, a, u), p.touchedFields = r.touchedFields, d = d || (D.touchedFields || v.touchedFields) && F !== u);
|
|
511
511
|
}
|
|
512
|
-
|
|
512
|
+
d && c && m.state.next(p);
|
|
513
513
|
}
|
|
514
|
-
return
|
|
515
|
-
},
|
|
516
|
-
const
|
|
517
|
-
if (t.delayError && u ? (w =
|
|
514
|
+
return d ? p : {};
|
|
515
|
+
}, ye = (a, o, u, h) => {
|
|
516
|
+
const c = g(r.errors, a), d = (D.isValid || v.isValid) && ie(o) && r.isValid !== o;
|
|
517
|
+
if (t.delayError && u ? (w = C(() => ee(a, u)), w(t.delayError)) : (clearTimeout(b), w = null, u ? N(r.errors, a, u) : k(r.errors, a)), (u ? !he(c, u) : c) || !H(h) || d) {
|
|
518
518
|
const y = {
|
|
519
|
-
...
|
|
520
|
-
...
|
|
519
|
+
...h,
|
|
520
|
+
...d && ie(o) ? { isValid: o } : {},
|
|
521
521
|
errors: r.errors,
|
|
522
522
|
name: a
|
|
523
523
|
};
|
|
@@ -526,187 +526,187 @@ function cr(e = {}) {
|
|
|
526
526
|
...y
|
|
527
527
|
}, m.state.next(y);
|
|
528
528
|
}
|
|
529
|
-
}, ae = async (a) => (
|
|
529
|
+
}, ae = async (a) => (W(a, !0), await t.resolver(n, t.context, tr(a || f.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), ne = async (a) => {
|
|
530
530
|
const { errors: o } = await ae(a);
|
|
531
|
-
if (
|
|
531
|
+
if (W(a), a)
|
|
532
532
|
for (const u of a) {
|
|
533
|
-
const
|
|
534
|
-
|
|
533
|
+
const h = g(o, u);
|
|
534
|
+
h ? N(r.errors, u, h) : k(r.errors, u);
|
|
535
535
|
}
|
|
536
536
|
else
|
|
537
537
|
r.errors = o;
|
|
538
538
|
return o;
|
|
539
|
-
},
|
|
539
|
+
}, j = async (a, o, u = {
|
|
540
540
|
valid: !0
|
|
541
541
|
}) => {
|
|
542
|
-
for (const
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
545
|
-
const { _f:
|
|
546
|
-
if (
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
const _ = await
|
|
550
|
-
if (
|
|
542
|
+
for (const h in a) {
|
|
543
|
+
const c = a[h];
|
|
544
|
+
if (c) {
|
|
545
|
+
const { _f: d, ...y } = c;
|
|
546
|
+
if (d) {
|
|
547
|
+
const p = f.array.has(d.name), F = c._f && rr(c._f);
|
|
548
|
+
F && D.validatingFields && W([d.name], !0);
|
|
549
|
+
const _ = await Et(c, f.disabled, n, Y, t.shouldUseNativeValidation && !o, p);
|
|
550
|
+
if (F && D.validatingFields && W([d.name]), _[d.name] && (u.valid = !1, o || e.shouldUseNativeValidation))
|
|
551
551
|
break;
|
|
552
|
-
!o && (g(_,
|
|
552
|
+
!o && (g(_, d.name) ? p ? or(r.errors, _, d.name) : N(r.errors, d.name, _[d.name]) : k(r.errors, d.name));
|
|
553
553
|
}
|
|
554
|
-
!
|
|
554
|
+
!H(y) && await j(y, o, u);
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
557
|
return u.valid;
|
|
558
|
-
},
|
|
559
|
-
for (const a of
|
|
558
|
+
}, ce = () => {
|
|
559
|
+
for (const a of f.unMount) {
|
|
560
560
|
const o = g(s, a);
|
|
561
|
-
o && (o._f.refs ? o._f.refs.every((u) => !
|
|
561
|
+
o && (o._f.refs ? o._f.refs.every((u) => !Ze(u)) : !Ze(o._f.ref)) && Ae(a);
|
|
562
562
|
}
|
|
563
|
-
|
|
564
|
-
}, V = (a, o) => !t.disabled && (a && o &&
|
|
565
|
-
...l.mount ? n :
|
|
566
|
-
}, u, o), S = (a) =>
|
|
567
|
-
const
|
|
568
|
-
let
|
|
569
|
-
if (
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
(!y.defaultChecked || !y.disabled) && (Array.isArray(
|
|
573
|
-
}) :
|
|
563
|
+
f.unMount = /* @__PURE__ */ new Set();
|
|
564
|
+
}, V = (a, o) => !t.disabled && (a && o && N(n, a, o), !he(Le(), i)), x = (a, o, u) => Jt(a, f, {
|
|
565
|
+
...l.mount ? n : T(o) ? i : Q(a) ? { [a]: o } : o
|
|
566
|
+
}, u, o), S = (a) => it(g(l.mount ? n : i, a, t.shouldUnregister ? g(i, a, []) : [])), I = (a, o, u = {}) => {
|
|
567
|
+
const h = g(s, a);
|
|
568
|
+
let c = o;
|
|
569
|
+
if (h) {
|
|
570
|
+
const d = h._f;
|
|
571
|
+
d && (!d.disabled && N(n, a, Lt(o, d)), c = He(d.ref) && J(o) ? "" : o, Ot(d.ref) ? [...d.ref.options].forEach((y) => y.selected = c.includes(y.value)) : d.refs ? Te(d.ref) ? d.refs.forEach((y) => {
|
|
572
|
+
(!y.defaultChecked || !y.disabled) && (Array.isArray(c) ? y.checked = !!c.find((p) => p === y.value) : y.checked = c === y.value || !!c);
|
|
573
|
+
}) : d.refs.forEach((y) => y.checked = y.value === c) : nt(d.ref) ? d.ref.value = "" : (d.ref.value = c, d.ref.type || m.state.next({
|
|
574
574
|
name: a,
|
|
575
|
-
values:
|
|
575
|
+
values: P(n)
|
|
576
576
|
})));
|
|
577
577
|
}
|
|
578
|
-
(u.shouldDirty || u.shouldTouch) &&
|
|
579
|
-
},
|
|
580
|
-
for (const
|
|
581
|
-
if (!o.hasOwnProperty(
|
|
578
|
+
(u.shouldDirty || u.shouldTouch) && le(a, c, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && fe(a);
|
|
579
|
+
}, G = (a, o, u) => {
|
|
580
|
+
for (const h in o) {
|
|
581
|
+
if (!o.hasOwnProperty(h))
|
|
582
582
|
return;
|
|
583
|
-
const
|
|
584
|
-
(
|
|
583
|
+
const c = o[h], d = a + "." + h, y = g(s, d);
|
|
584
|
+
(f.array.has(a) || U(c) || y && !y._f) && !pe(c) ? G(d, c, u) : I(d, c, u);
|
|
585
585
|
}
|
|
586
|
-
},
|
|
587
|
-
const
|
|
588
|
-
|
|
586
|
+
}, q = (a, o, u = {}) => {
|
|
587
|
+
const h = g(s, a), c = f.array.has(a), d = P(o);
|
|
588
|
+
N(n, a, d), c ? (m.array.next({
|
|
589
589
|
name: a,
|
|
590
|
-
values:
|
|
590
|
+
values: P(n)
|
|
591
591
|
}), (D.isDirty || D.dirtyFields || v.isDirty || v.dirtyFields) && u.shouldDirty && m.state.next({
|
|
592
592
|
name: a,
|
|
593
|
-
dirtyFields:
|
|
594
|
-
isDirty: V(a,
|
|
595
|
-
})) :
|
|
593
|
+
dirtyFields: Ve(i, n),
|
|
594
|
+
isDirty: V(a, d)
|
|
595
|
+
})) : h && !h._f && !J(d) ? G(a, d, u) : I(a, d, u), vt(a, f) ? m.state.next({
|
|
596
596
|
...r,
|
|
597
597
|
name: a,
|
|
598
|
-
values:
|
|
598
|
+
values: P(n)
|
|
599
599
|
}) : m.state.next({
|
|
600
600
|
name: l.mount ? a : void 0,
|
|
601
|
-
values:
|
|
601
|
+
values: P(n)
|
|
602
602
|
});
|
|
603
|
-
},
|
|
603
|
+
}, de = async (a) => {
|
|
604
604
|
l.mount = !0;
|
|
605
605
|
const o = a.target;
|
|
606
|
-
let u = o.name,
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
}, y =
|
|
610
|
-
if (
|
|
611
|
-
let
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
606
|
+
let u = o.name, h = !0;
|
|
607
|
+
const c = g(s, u), d = (F) => {
|
|
608
|
+
h = Number.isNaN(F) || pe(F) && isNaN(F.getTime()) || he(F, g(n, u, F));
|
|
609
|
+
}, y = bt(t.mode), p = bt(t.reValidateMode);
|
|
610
|
+
if (c) {
|
|
611
|
+
let F, _;
|
|
612
|
+
const R = o.type ? pt(c._f) : $t(a), $ = a.type === ft.BLUR || a.type === ft.FOCUS_OUT, ue = !sr(c._f) && !t.resolver && !g(r.errors, u) && !c._f.deps || nr($, g(r.touchedFields, u), r.isSubmitted, p, y), B = vt(u, f, $);
|
|
613
|
+
N(n, u, R), $ ? (!o || !o.readOnly) && (c._f.onBlur && c._f.onBlur(a), w && w(0)) : c._f.onChange && c._f.onChange(a);
|
|
614
|
+
const z = le(u, R, $), je = !H(z) || B;
|
|
615
|
+
if (!$ && m.state.next({
|
|
616
616
|
name: u,
|
|
617
617
|
type: a.type,
|
|
618
|
-
values:
|
|
619
|
-
}),
|
|
620
|
-
return (D.isValid || v.isValid) && (t.mode === "onBlur" ?
|
|
621
|
-
if (
|
|
622
|
-
const { errors:
|
|
623
|
-
if (
|
|
624
|
-
const
|
|
625
|
-
|
|
618
|
+
values: P(n)
|
|
619
|
+
}), ue)
|
|
620
|
+
return (D.isValid || v.isValid) && (t.mode === "onBlur" ? $ && Z() : $ || Z()), je && m.state.next({ name: u, ...B ? {} : z });
|
|
621
|
+
if (!$ && B && m.state.next({ ...r }), t.resolver) {
|
|
622
|
+
const { errors: Qe } = await ae([u]);
|
|
623
|
+
if (W([u]), d(R), h) {
|
|
624
|
+
const lt = Ft(r.errors, s, u), ct = Ft(Qe, s, lt.name || u);
|
|
625
|
+
F = ct.error, u = ct.name, _ = H(Qe);
|
|
626
626
|
}
|
|
627
627
|
} else
|
|
628
|
-
|
|
629
|
-
|
|
628
|
+
W([u], !0), F = (await Et(c, f.disabled, n, Y, t.shouldUseNativeValidation))[u], W([u]), d(R), h && (F ? _ = !1 : (D.isValid || v.isValid) && (_ = await j(s, !0)));
|
|
629
|
+
h && (c._f.deps && (!Array.isArray(c._f.deps) || c._f.deps.length > 0) && fe(c._f.deps), ye(u, _, F, z));
|
|
630
630
|
}
|
|
631
|
-
},
|
|
631
|
+
}, K = (a, o) => {
|
|
632
632
|
if (g(r.errors, o) && a.focus)
|
|
633
633
|
return a.focus(), 1;
|
|
634
|
-
},
|
|
635
|
-
let u,
|
|
636
|
-
const
|
|
634
|
+
}, fe = async (a, o = {}) => {
|
|
635
|
+
let u, h;
|
|
636
|
+
const c = Oe(a);
|
|
637
637
|
if (t.resolver) {
|
|
638
|
-
const
|
|
639
|
-
u =
|
|
640
|
-
} else a ? (
|
|
641
|
-
const y = g(s,
|
|
642
|
-
return await
|
|
643
|
-
}))).every(Boolean), !(!
|
|
638
|
+
const d = await ne(T(a) ? a : c);
|
|
639
|
+
u = H(d), h = a ? !c.some((y) => g(d, y)) : u;
|
|
640
|
+
} else a ? (h = (await Promise.all(c.map(async (d) => {
|
|
641
|
+
const y = g(s, d);
|
|
642
|
+
return await j(y && y._f ? { [d]: y } : y);
|
|
643
|
+
}))).every(Boolean), !(!h && !r.isValid) && Z()) : h = u = await j(s);
|
|
644
644
|
return m.state.next({
|
|
645
645
|
...!Q(a) || (D.isValid || v.isValid) && u !== r.isValid ? {} : { name: a },
|
|
646
646
|
...t.resolver || !a ? { isValid: u } : {},
|
|
647
647
|
errors: r.errors
|
|
648
|
-
}), o.shouldFocus && !
|
|
649
|
-
},
|
|
648
|
+
}), o.shouldFocus && !h && Ce(s, K, a ? c : f.mount), h;
|
|
649
|
+
}, Le = (a, o) => {
|
|
650
650
|
let u = {
|
|
651
651
|
...l.mount ? n : i
|
|
652
652
|
};
|
|
653
|
-
return o && (u =
|
|
654
|
-
},
|
|
653
|
+
return o && (u = Nt(o.dirtyFields ? r.dirtyFields : r.touchedFields, u)), T(a) ? u : Q(a) ? g(u, a) : a.map((h) => g(u, h));
|
|
654
|
+
}, Me = (a, o) => ({
|
|
655
655
|
invalid: !!g((o || r).errors, a),
|
|
656
656
|
isDirty: !!g((o || r).dirtyFields, a),
|
|
657
657
|
error: g((o || r).errors, a),
|
|
658
658
|
isValidating: !!g(r.validatingFields, a),
|
|
659
659
|
isTouched: !!g((o || r).touchedFields, a)
|
|
660
|
-
}),
|
|
661
|
-
a &&
|
|
660
|
+
}), E = (a) => {
|
|
661
|
+
a && Oe(a).forEach((o) => k(r.errors, o)), m.state.next({
|
|
662
662
|
errors: a ? r.errors : {}
|
|
663
663
|
});
|
|
664
|
-
},
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
...
|
|
664
|
+
}, we = (a, o, u) => {
|
|
665
|
+
const h = (g(s, a, { _f: {} })._f || {}).ref, c = g(r.errors, a) || {}, { ref: d, message: y, type: p, ...F } = c;
|
|
666
|
+
N(r.errors, a, {
|
|
667
|
+
...F,
|
|
668
668
|
...o,
|
|
669
|
-
ref:
|
|
669
|
+
ref: h
|
|
670
670
|
}), m.state.next({
|
|
671
671
|
name: a,
|
|
672
672
|
errors: r.errors,
|
|
673
673
|
isValid: !1
|
|
674
|
-
}), u && u.shouldFocus &&
|
|
675
|
-
},
|
|
676
|
-
next: (u) => "values" in u && a(
|
|
677
|
-
}) :
|
|
674
|
+
}), u && u.shouldFocus && h && h.focus && h.focus();
|
|
675
|
+
}, Ie = (a, o) => re(a) ? m.state.subscribe({
|
|
676
|
+
next: (u) => "values" in u && a(x(void 0, o), u)
|
|
677
|
+
}) : x(a, o, !0), ke = (a) => m.state.subscribe({
|
|
678
678
|
next: (o) => {
|
|
679
|
-
ar(a.name, o.name, a.exact) && ir(o, a.formState || D,
|
|
679
|
+
ar(a.name, o.name, a.exact) && ir(o, a.formState || D, Xe, a.reRenderRoot) && a.callback({
|
|
680
680
|
values: { ...n },
|
|
681
681
|
...r,
|
|
682
682
|
...o,
|
|
683
683
|
defaultValues: i
|
|
684
684
|
});
|
|
685
685
|
}
|
|
686
|
-
}).unsubscribe,
|
|
686
|
+
}).unsubscribe, ze = (a) => (l.mount = !0, v = {
|
|
687
687
|
...v,
|
|
688
688
|
...a.formState
|
|
689
|
-
},
|
|
689
|
+
}, ke({
|
|
690
690
|
...a,
|
|
691
691
|
formState: {
|
|
692
|
-
...
|
|
692
|
+
...O,
|
|
693
693
|
...a.formState
|
|
694
694
|
}
|
|
695
|
-
})),
|
|
696
|
-
for (const u of a ?
|
|
697
|
-
|
|
695
|
+
})), Ae = (a, o = {}) => {
|
|
696
|
+
for (const u of a ? Oe(a) : f.mount)
|
|
697
|
+
f.mount.delete(u), f.array.delete(u), o.keepValue || (k(s, u), k(n, u)), !o.keepError && k(r.errors, u), !o.keepDirty && k(r.dirtyFields, u), !o.keepTouched && k(r.touchedFields, u), !o.keepIsValidating && k(r.validatingFields, u), !t.shouldUnregister && !o.keepDefaultValue && k(i, u);
|
|
698
698
|
m.state.next({
|
|
699
|
-
values:
|
|
699
|
+
values: P(n)
|
|
700
700
|
}), m.state.next({
|
|
701
701
|
...r,
|
|
702
702
|
...o.keepDirty ? { isDirty: V() } : {}
|
|
703
703
|
}), !o.keepIsValid && Z();
|
|
704
|
-
},
|
|
705
|
-
(ie(a) && l.mount || a ||
|
|
706
|
-
},
|
|
704
|
+
}, Ue = ({ disabled: a, name: o }) => {
|
|
705
|
+
(ie(a) && l.mount || a || f.disabled.has(o)) && (a ? f.disabled.add(o) : f.disabled.delete(o));
|
|
706
|
+
}, xe = (a, o = {}) => {
|
|
707
707
|
let u = g(s, a);
|
|
708
|
-
const
|
|
709
|
-
return
|
|
708
|
+
const h = ie(o.disabled) || ie(t.disabled);
|
|
709
|
+
return N(s, a, {
|
|
710
710
|
...u || {},
|
|
711
711
|
_f: {
|
|
712
712
|
...u && u._f ? u._f : { ref: { name: a } },
|
|
@@ -714,107 +714,107 @@ function cr(e = {}) {
|
|
|
714
714
|
mount: !0,
|
|
715
715
|
...o
|
|
716
716
|
}
|
|
717
|
-
}),
|
|
717
|
+
}), f.mount.add(a), u ? Ue({
|
|
718
718
|
disabled: ie(o.disabled) ? o.disabled : t.disabled,
|
|
719
719
|
name: a
|
|
720
|
-
}) :
|
|
721
|
-
...
|
|
720
|
+
}) : L(a, !0, o.value), {
|
|
721
|
+
...h ? { disabled: o.disabled || t.disabled } : {},
|
|
722
722
|
...t.progressive ? {
|
|
723
723
|
required: !!o.required,
|
|
724
|
-
min:
|
|
725
|
-
max:
|
|
726
|
-
minLength:
|
|
727
|
-
maxLength:
|
|
728
|
-
pattern:
|
|
724
|
+
min: Ne(o.min),
|
|
725
|
+
max: Ne(o.max),
|
|
726
|
+
minLength: Ne(o.minLength),
|
|
727
|
+
maxLength: Ne(o.maxLength),
|
|
728
|
+
pattern: Ne(o.pattern)
|
|
729
729
|
} : {},
|
|
730
730
|
name: a,
|
|
731
|
-
onChange:
|
|
732
|
-
onBlur:
|
|
733
|
-
ref: (
|
|
734
|
-
if (
|
|
735
|
-
|
|
736
|
-
const
|
|
737
|
-
if (y ?
|
|
731
|
+
onChange: de,
|
|
732
|
+
onBlur: de,
|
|
733
|
+
ref: (c) => {
|
|
734
|
+
if (c) {
|
|
735
|
+
xe(a, o), u = g(s, a);
|
|
736
|
+
const d = T(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, y = Xt(d), p = u._f.refs || [];
|
|
737
|
+
if (y ? p.find((F) => F === d) : d === u._f.ref)
|
|
738
738
|
return;
|
|
739
|
-
|
|
739
|
+
N(s, a, {
|
|
740
740
|
_f: {
|
|
741
741
|
...u._f,
|
|
742
742
|
...y ? {
|
|
743
743
|
refs: [
|
|
744
|
-
...
|
|
745
|
-
|
|
744
|
+
...p.filter(Ze),
|
|
745
|
+
d,
|
|
746
746
|
...Array.isArray(g(i, a)) ? [{}] : []
|
|
747
747
|
],
|
|
748
|
-
ref: { type:
|
|
749
|
-
} : { ref:
|
|
748
|
+
ref: { type: d.type, name: a }
|
|
749
|
+
} : { ref: d }
|
|
750
750
|
}
|
|
751
|
-
}),
|
|
751
|
+
}), L(a, !1, void 0, d);
|
|
752
752
|
} else
|
|
753
|
-
u = g(s, a, {}), u._f && (u._f.mount = !1), (t.shouldUnregister || o.shouldUnregister) && !(Wt(
|
|
753
|
+
u = g(s, a, {}), u._f && (u._f.mount = !1), (t.shouldUnregister || o.shouldUnregister) && !(Wt(f.array, a) && l.action) && f.unMount.add(a);
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
|
-
},
|
|
757
|
-
ie(a) && (m.state.next({ disabled: a }),
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
756
|
+
}, _e = () => t.shouldFocusError && Ce(s, K, f.mount), Je = (a) => {
|
|
757
|
+
ie(a) && (m.state.next({ disabled: a }), Ce(s, (o, u) => {
|
|
758
|
+
const h = g(s, u);
|
|
759
|
+
h && (o.disabled = h._f.disabled || a, Array.isArray(h._f.refs) && h._f.refs.forEach((c) => {
|
|
760
|
+
c.disabled = h._f.disabled || a;
|
|
761
761
|
}));
|
|
762
762
|
}, 0, !1));
|
|
763
|
-
},
|
|
764
|
-
let
|
|
763
|
+
}, Be = (a, o) => async (u) => {
|
|
764
|
+
let h;
|
|
765
765
|
u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
|
|
766
|
-
let
|
|
766
|
+
let c = P(n);
|
|
767
767
|
if (m.state.next({
|
|
768
768
|
isSubmitting: !0
|
|
769
769
|
}), t.resolver) {
|
|
770
|
-
const { errors:
|
|
771
|
-
|
|
770
|
+
const { errors: d, values: y } = await ae();
|
|
771
|
+
W(), r.errors = d, c = P(y);
|
|
772
772
|
} else
|
|
773
|
-
await
|
|
774
|
-
if (
|
|
775
|
-
for (const
|
|
776
|
-
|
|
777
|
-
if (
|
|
773
|
+
await j(s);
|
|
774
|
+
if (f.disabled.size)
|
|
775
|
+
for (const d of f.disabled)
|
|
776
|
+
k(c, d);
|
|
777
|
+
if (k(r.errors, "root"), H(r.errors)) {
|
|
778
778
|
m.state.next({
|
|
779
779
|
errors: {}
|
|
780
780
|
});
|
|
781
781
|
try {
|
|
782
|
-
await a(
|
|
783
|
-
} catch (
|
|
784
|
-
|
|
782
|
+
await a(c, u);
|
|
783
|
+
} catch (d) {
|
|
784
|
+
h = d;
|
|
785
785
|
}
|
|
786
786
|
} else
|
|
787
|
-
o && await o({ ...r.errors }, u),
|
|
787
|
+
o && await o({ ...r.errors }, u), _e(), setTimeout(_e);
|
|
788
788
|
if (m.state.next({
|
|
789
789
|
isSubmitted: !0,
|
|
790
790
|
isSubmitting: !1,
|
|
791
|
-
isSubmitSuccessful:
|
|
791
|
+
isSubmitSuccessful: H(r.errors) && !h,
|
|
792
792
|
submitCount: r.submitCount + 1,
|
|
793
793
|
errors: r.errors
|
|
794
|
-
}),
|
|
795
|
-
throw
|
|
796
|
-
},
|
|
797
|
-
g(s, a) && (
|
|
798
|
-
},
|
|
799
|
-
const u = a ?
|
|
794
|
+
}), h)
|
|
795
|
+
throw h;
|
|
796
|
+
}, Ge = (a, o = {}) => {
|
|
797
|
+
g(s, a) && (T(o.defaultValue) ? q(a, P(g(i, a))) : (q(a, o.defaultValue), N(i, a, P(o.defaultValue))), o.keepTouched || k(r.touchedFields, a), o.keepDirty || (k(r.dirtyFields, a), r.isDirty = o.defaultValue ? V(a, P(g(i, a))) : V()), o.keepError || (k(r.errors, a), D.isValid && Z()), m.state.next({ ...r }));
|
|
798
|
+
}, De = (a, o = {}) => {
|
|
799
|
+
const u = a ? P(a) : i, h = P(u), c = H(a), d = c ? i : h;
|
|
800
800
|
if (o.keepDefaultValues || (i = u), !o.keepValues) {
|
|
801
801
|
if (o.keepDirtyValues) {
|
|
802
802
|
const y = /* @__PURE__ */ new Set([
|
|
803
|
-
...
|
|
804
|
-
...Object.keys(
|
|
803
|
+
...f.mount,
|
|
804
|
+
...Object.keys(Ve(i, n))
|
|
805
805
|
]);
|
|
806
|
-
for (const
|
|
807
|
-
const
|
|
808
|
-
|
|
806
|
+
for (const p of Array.from(y)) {
|
|
807
|
+
const F = g(r.dirtyFields, p), _ = g(n, p), R = g(d, p);
|
|
808
|
+
F && !T(_) ? N(d, p, _) : !F && !T(R) && q(p, R);
|
|
809
809
|
}
|
|
810
810
|
} else {
|
|
811
|
-
if (
|
|
812
|
-
for (const y of
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
815
|
-
const
|
|
816
|
-
if (
|
|
817
|
-
const _ =
|
|
811
|
+
if (st && T(a))
|
|
812
|
+
for (const y of f.mount) {
|
|
813
|
+
const p = g(s, y);
|
|
814
|
+
if (p && p._f) {
|
|
815
|
+
const F = Array.isArray(p._f.refs) ? p._f.refs[0] : p._f.ref;
|
|
816
|
+
if (He(F)) {
|
|
817
|
+
const _ = F.closest("form");
|
|
818
818
|
if (_) {
|
|
819
819
|
_.reset();
|
|
820
820
|
break;
|
|
@@ -823,75 +823,75 @@ function cr(e = {}) {
|
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
if (o.keepFieldsRef)
|
|
826
|
-
for (const y of
|
|
827
|
-
|
|
826
|
+
for (const y of f.mount)
|
|
827
|
+
q(y, g(d, y));
|
|
828
828
|
else
|
|
829
829
|
s = {};
|
|
830
830
|
}
|
|
831
|
-
n = t.shouldUnregister ? o.keepDefaultValues ?
|
|
832
|
-
values: { ...
|
|
831
|
+
n = t.shouldUnregister ? o.keepDefaultValues ? P(i) : {} : P(d), m.array.next({
|
|
832
|
+
values: { ...d }
|
|
833
833
|
}), m.state.next({
|
|
834
|
-
values: { ...
|
|
834
|
+
values: { ...d }
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
|
|
838
|
-
mount: o.keepDirtyValues ?
|
|
837
|
+
f = {
|
|
838
|
+
mount: o.keepDirtyValues ? f.mount : /* @__PURE__ */ new Set(),
|
|
839
839
|
unMount: /* @__PURE__ */ new Set(),
|
|
840
840
|
array: /* @__PURE__ */ new Set(),
|
|
841
841
|
disabled: /* @__PURE__ */ new Set(),
|
|
842
842
|
watch: /* @__PURE__ */ new Set(),
|
|
843
843
|
watchAll: !1,
|
|
844
844
|
focus: ""
|
|
845
|
-
}, l.mount = !D.isValid || !!o.keepIsValid || !!o.keepDirtyValues || !t.shouldUnregister && !
|
|
845
|
+
}, l.mount = !D.isValid || !!o.keepIsValid || !!o.keepDirtyValues || !t.shouldUnregister && !H(d), l.watch = !!t.shouldUnregister, l.keepIsValid = !!o.keepIsValid, l.action = !1, o.keepErrors || (r.errors = {}), m.state.next({
|
|
846
846
|
submitCount: o.keepSubmitCount ? r.submitCount : 0,
|
|
847
|
-
isDirty:
|
|
847
|
+
isDirty: c ? !1 : o.keepDirty ? r.isDirty : !!(o.keepDefaultValues && !he(a, i)),
|
|
848
848
|
isSubmitted: o.keepIsSubmitted ? r.isSubmitted : !1,
|
|
849
|
-
dirtyFields:
|
|
849
|
+
dirtyFields: c ? {} : o.keepDirtyValues ? o.keepDefaultValues && n ? Ve(i, n) : r.dirtyFields : o.keepDefaultValues && a ? Ve(i, a) : o.keepDirty ? r.dirtyFields : {},
|
|
850
850
|
touchedFields: o.keepTouched ? r.touchedFields : {},
|
|
851
851
|
errors: o.keepErrors ? r.errors : {},
|
|
852
852
|
isSubmitSuccessful: o.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
853
853
|
isSubmitting: !1,
|
|
854
854
|
defaultValues: i
|
|
855
855
|
});
|
|
856
|
-
},
|
|
857
|
-
const u = g(s, a),
|
|
858
|
-
if (
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
|
|
856
|
+
}, Pe = (a, o) => De(re(a) ? a(n) : a, { ...t.resetOptions, ...o }), qe = (a, o = {}) => {
|
|
857
|
+
const u = g(s, a), h = u && u._f;
|
|
858
|
+
if (h) {
|
|
859
|
+
const c = h.refs ? h.refs[0] : h.ref;
|
|
860
|
+
c.focus && setTimeout(() => {
|
|
861
|
+
c.focus(), o.shouldSelect && re(c.select) && c.select();
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
|
-
},
|
|
864
|
+
}, Xe = (a) => {
|
|
865
865
|
r = {
|
|
866
866
|
...r,
|
|
867
867
|
...a
|
|
868
868
|
};
|
|
869
|
-
},
|
|
869
|
+
}, $e = {
|
|
870
870
|
control: {
|
|
871
|
-
register:
|
|
872
|
-
unregister:
|
|
873
|
-
getFieldState:
|
|
874
|
-
handleSubmit:
|
|
875
|
-
setError:
|
|
876
|
-
_subscribe:
|
|
871
|
+
register: xe,
|
|
872
|
+
unregister: Ae,
|
|
873
|
+
getFieldState: Me,
|
|
874
|
+
handleSubmit: Be,
|
|
875
|
+
setError: we,
|
|
876
|
+
_subscribe: ke,
|
|
877
877
|
_runSchema: ae,
|
|
878
|
-
_updateIsValidating:
|
|
879
|
-
_focusError:
|
|
880
|
-
_getWatch:
|
|
878
|
+
_updateIsValidating: W,
|
|
879
|
+
_focusError: _e,
|
|
880
|
+
_getWatch: x,
|
|
881
881
|
_getDirty: V,
|
|
882
882
|
_setValid: Z,
|
|
883
|
-
_setFieldArray:
|
|
884
|
-
_setDisabledField:
|
|
885
|
-
_setErrors:
|
|
883
|
+
_setFieldArray: A,
|
|
884
|
+
_setDisabledField: Ue,
|
|
885
|
+
_setErrors: M,
|
|
886
886
|
_getFieldArray: S,
|
|
887
|
-
_reset:
|
|
887
|
+
_reset: De,
|
|
888
888
|
_resetDefaultValues: () => re(t.defaultValues) && t.defaultValues().then((a) => {
|
|
889
|
-
|
|
889
|
+
Pe(a, t.resetOptions), m.state.next({
|
|
890
890
|
isLoading: !1
|
|
891
891
|
});
|
|
892
892
|
}),
|
|
893
|
-
_removeUnmounted:
|
|
894
|
-
_disableForm:
|
|
893
|
+
_removeUnmounted: ce,
|
|
894
|
+
_disableForm: Je,
|
|
895
895
|
_subjects: m,
|
|
896
896
|
_proxyFormState: D,
|
|
897
897
|
get _fields() {
|
|
@@ -910,10 +910,10 @@ function cr(e = {}) {
|
|
|
910
910
|
return i;
|
|
911
911
|
},
|
|
912
912
|
get _names() {
|
|
913
|
-
return
|
|
913
|
+
return f;
|
|
914
914
|
},
|
|
915
915
|
set _names(a) {
|
|
916
|
-
|
|
916
|
+
f = a;
|
|
917
917
|
},
|
|
918
918
|
get _formState() {
|
|
919
919
|
return r;
|
|
@@ -928,24 +928,24 @@ function cr(e = {}) {
|
|
|
928
928
|
};
|
|
929
929
|
}
|
|
930
930
|
},
|
|
931
|
-
subscribe:
|
|
932
|
-
trigger:
|
|
933
|
-
register:
|
|
934
|
-
handleSubmit:
|
|
935
|
-
watch:
|
|
936
|
-
setValue:
|
|
937
|
-
getValues:
|
|
938
|
-
reset:
|
|
939
|
-
resetField:
|
|
940
|
-
clearErrors:
|
|
941
|
-
unregister:
|
|
942
|
-
setError:
|
|
943
|
-
setFocus:
|
|
944
|
-
getFieldState:
|
|
931
|
+
subscribe: ze,
|
|
932
|
+
trigger: fe,
|
|
933
|
+
register: xe,
|
|
934
|
+
handleSubmit: Be,
|
|
935
|
+
watch: Ie,
|
|
936
|
+
setValue: q,
|
|
937
|
+
getValues: Le,
|
|
938
|
+
reset: Pe,
|
|
939
|
+
resetField: Ge,
|
|
940
|
+
clearErrors: E,
|
|
941
|
+
unregister: Ae,
|
|
942
|
+
setError: we,
|
|
943
|
+
setFocus: qe,
|
|
944
|
+
getFieldState: Me
|
|
945
945
|
};
|
|
946
946
|
return {
|
|
947
|
-
|
|
948
|
-
formControl:
|
|
947
|
+
...$e,
|
|
948
|
+
formControl: $e
|
|
949
949
|
};
|
|
950
950
|
}
|
|
951
951
|
function dr(e = {}) {
|
|
@@ -973,9 +973,9 @@ function dr(e = {}) {
|
|
|
973
973
|
formState: s
|
|
974
974
|
}, e.defaultValues && !re(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
975
975
|
else {
|
|
976
|
-
const { formControl: l, ...
|
|
976
|
+
const { formControl: l, ...f } = cr(e);
|
|
977
977
|
t.current = {
|
|
978
|
-
...
|
|
978
|
+
...f,
|
|
979
979
|
formState: s
|
|
980
980
|
};
|
|
981
981
|
}
|
|
@@ -986,8 +986,8 @@ function dr(e = {}) {
|
|
|
986
986
|
callback: () => i({ ...n._formState }),
|
|
987
987
|
reRenderRoot: !0
|
|
988
988
|
});
|
|
989
|
-
return i((
|
|
990
|
-
...
|
|
989
|
+
return i((f) => ({
|
|
990
|
+
...f,
|
|
991
991
|
isReady: !0
|
|
992
992
|
})), n._formState.isReady = !0, l;
|
|
993
993
|
}, [n]), X.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), X.useEffect(() => {
|
|
@@ -1007,10 +1007,10 @@ function dr(e = {}) {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
}, [n, s.isDirty]), X.useEffect(() => {
|
|
1009
1009
|
var l;
|
|
1010
|
-
e.values && !
|
|
1010
|
+
e.values && !he(e.values, r.current) ? (n._reset(e.values, {
|
|
1011
1011
|
keepFieldsRef: !0,
|
|
1012
1012
|
...n._options.resetOptions
|
|
1013
|
-
}), !((l = n._options.resetOptions) === null || l === void 0) && l.keepIsValid || n._setValid(), r.current = e.values, i((
|
|
1013
|
+
}), !((l = n._options.resetOptions) === null || l === void 0) && l.keepIsValid || n._setValid(), r.current = e.values, i((f) => ({ ...f }))) : n._resetDefaultValues();
|
|
1014
1014
|
}, [n, e.values]), X.useEffect(() => {
|
|
1015
1015
|
n._state.mount || (n._setValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
|
|
1016
1016
|
}), t.current.formState = Kt(s, n), t.current;
|
|
@@ -1094,32 +1094,32 @@ const hr = {
|
|
|
1094
1094
|
ARRAY_CONTAINS: (e, t) => Array.isArray(e) ? e.includes(t) : !1,
|
|
1095
1095
|
ARRAY_JOIN: (e, t = ",") => Array.isArray(e) ? e.join(t) : ""
|
|
1096
1096
|
};
|
|
1097
|
-
function
|
|
1097
|
+
function me(e, t) {
|
|
1098
1098
|
var r;
|
|
1099
1099
|
switch (e.Type) {
|
|
1100
1100
|
case "Literal":
|
|
1101
1101
|
return e.Value;
|
|
1102
1102
|
case "SystemIdentifier":
|
|
1103
1103
|
if (e.Property) {
|
|
1104
|
-
const
|
|
1105
|
-
return
|
|
1104
|
+
const b = t.systemValues[e.Name];
|
|
1105
|
+
return et(b, e.Property.Name);
|
|
1106
1106
|
}
|
|
1107
1107
|
return t.systemValues[e.Name];
|
|
1108
1108
|
case "Identifier":
|
|
1109
1109
|
if (e.Property) {
|
|
1110
|
-
const
|
|
1111
|
-
return
|
|
1110
|
+
const b = At(e, t);
|
|
1111
|
+
return et(b, e.Property.Name);
|
|
1112
1112
|
}
|
|
1113
|
-
return
|
|
1113
|
+
return At(e, t);
|
|
1114
1114
|
case "MemberExpression":
|
|
1115
1115
|
if (!e.Arguments || e.Arguments.length === 0)
|
|
1116
1116
|
throw new Error("MemberExpression requires Arguments array");
|
|
1117
|
-
const s =
|
|
1118
|
-
return i ?
|
|
1117
|
+
const s = me(e.Arguments[0], t), i = (r = e.Arguments[0].Property) == null ? void 0 : r.Name;
|
|
1118
|
+
return i ? et(s, i) : s;
|
|
1119
1119
|
case "BinaryExpression":
|
|
1120
1120
|
if (!e.Arguments || e.Arguments.length !== 2)
|
|
1121
1121
|
throw new Error("BinaryExpression requires exactly 2 arguments");
|
|
1122
|
-
const n =
|
|
1122
|
+
const n = me(e.Arguments[0], t), l = me(e.Arguments[1], t);
|
|
1123
1123
|
return mr(e.Operator, n, l);
|
|
1124
1124
|
case "LogicalExpression":
|
|
1125
1125
|
if (!e.Arguments || e.Arguments.length < 2)
|
|
@@ -1128,22 +1128,22 @@ function fe(e, t) {
|
|
|
1128
1128
|
case "CallExpression":
|
|
1129
1129
|
if (!e.Callee)
|
|
1130
1130
|
throw new Error("CallExpression requires Callee");
|
|
1131
|
-
const
|
|
1132
|
-
if (!
|
|
1131
|
+
const f = hr[e.Callee];
|
|
1132
|
+
if (!f)
|
|
1133
1133
|
throw new Error(`Unknown function: ${e.Callee}`);
|
|
1134
1134
|
const w = (e.Arguments || []).map(
|
|
1135
|
-
(
|
|
1135
|
+
(b) => me(b, t)
|
|
1136
1136
|
);
|
|
1137
|
-
return
|
|
1137
|
+
return f(...w);
|
|
1138
1138
|
case "AssignmentExpression":
|
|
1139
1139
|
if (!e.Arguments || e.Arguments.length !== 1)
|
|
1140
1140
|
throw new Error("AssignmentExpression requires exactly 1 argument");
|
|
1141
|
-
return
|
|
1141
|
+
return me(e.Arguments[0], t);
|
|
1142
1142
|
default:
|
|
1143
1143
|
throw new Error(`Unknown expression type: ${e.Type}`);
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
|
-
function
|
|
1146
|
+
function At(e, t) {
|
|
1147
1147
|
const { Name: r, Source: s } = e;
|
|
1148
1148
|
if (!r)
|
|
1149
1149
|
throw new Error("Identifier requires Name");
|
|
@@ -1153,7 +1153,7 @@ function Et(e, t) {
|
|
|
1153
1153
|
return t.formValues[r];
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
|
-
function
|
|
1156
|
+
function et(e, t) {
|
|
1157
1157
|
if (!(!e || typeof e != "object"))
|
|
1158
1158
|
return e[t];
|
|
1159
1159
|
}
|
|
@@ -1188,30 +1188,30 @@ function mr(e, t, r) {
|
|
|
1188
1188
|
function yr(e, t, r) {
|
|
1189
1189
|
switch (e) {
|
|
1190
1190
|
case "AND":
|
|
1191
|
-
return t.every((s) => !!
|
|
1191
|
+
return t.every((s) => !!me(s, r));
|
|
1192
1192
|
case "OR":
|
|
1193
|
-
return t.some((s) => !!
|
|
1193
|
+
return t.some((s) => !!me(s, r));
|
|
1194
1194
|
default:
|
|
1195
1195
|
throw new Error(`Unknown logical operator: ${e}`);
|
|
1196
1196
|
}
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1198
|
+
function It(e, t, r = {}) {
|
|
1199
1199
|
const s = {
|
|
1200
1200
|
formValues: t,
|
|
1201
1201
|
systemValues: fr(),
|
|
1202
1202
|
referenceData: r
|
|
1203
1203
|
};
|
|
1204
1204
|
try {
|
|
1205
|
-
return
|
|
1205
|
+
return me(e, s);
|
|
1206
1206
|
} catch (i) {
|
|
1207
1207
|
return console.warn("Expression evaluation failed:", i), !1;
|
|
1208
1208
|
}
|
|
1209
1209
|
}
|
|
1210
|
-
function
|
|
1210
|
+
function xt(e, t, r = {}) {
|
|
1211
1211
|
const s = [];
|
|
1212
1212
|
for (const i of e)
|
|
1213
1213
|
try {
|
|
1214
|
-
|
|
1214
|
+
It(
|
|
1215
1215
|
i.Condition.ExpressionTree,
|
|
1216
1216
|
t,
|
|
1217
1217
|
r
|
|
@@ -1227,21 +1227,21 @@ function At(e, t, r = {}) {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
function gr(e, t = {}, r = {}) {
|
|
1229
1229
|
try {
|
|
1230
|
-
return
|
|
1230
|
+
return It(e, t, r);
|
|
1231
1231
|
} catch (s) {
|
|
1232
1232
|
return console.warn("Default value calculation failed:", s), null;
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1236
|
-
var
|
|
1237
|
-
const r = ((
|
|
1235
|
+
function _t(e, t) {
|
|
1236
|
+
var f, w, b;
|
|
1237
|
+
const r = ((f = e.Expression) == null ? void 0 : f.toLowerCase()) || "", s = ((w = e.Name) == null ? void 0 : w.toLowerCase()) || "", i = ((b = e.Id) == null ? void 0 : b.toLowerCase()) || "", n = t.toLowerCase();
|
|
1238
1238
|
return s.includes("required") || i.includes("required") ? !0 : [
|
|
1239
1239
|
`${n} != null`,
|
|
1240
1240
|
`${n} != ''`,
|
|
1241
1241
|
`trim(${n}) != ''`,
|
|
1242
1242
|
`${n}!=null`,
|
|
1243
1243
|
`${n}!=''`
|
|
1244
|
-
].some((
|
|
1244
|
+
].some((O) => r.includes(O));
|
|
1245
1245
|
}
|
|
1246
1246
|
function pr(e) {
|
|
1247
1247
|
const t = { ...e };
|
|
@@ -1256,18 +1256,18 @@ function pr(e) {
|
|
|
1256
1256
|
if (i.Validation && Array.isArray(i.Validation))
|
|
1257
1257
|
if (i.Validation.length > 0 && typeof i.Validation[0] == "object") {
|
|
1258
1258
|
const l = [];
|
|
1259
|
-
i.Validation.forEach((
|
|
1260
|
-
t.Rules.Validation[
|
|
1259
|
+
i.Validation.forEach((f) => {
|
|
1260
|
+
t.Rules.Validation[f.Id] = f, l.push(f.Id), _t(f, s) && (n = !0);
|
|
1261
1261
|
}), r[s] = {
|
|
1262
1262
|
...i,
|
|
1263
1263
|
Validation: l,
|
|
1264
1264
|
Required: n
|
|
1265
1265
|
};
|
|
1266
1266
|
} else
|
|
1267
|
-
i.Validation.forEach((
|
|
1268
|
-
var
|
|
1269
|
-
const w = (
|
|
1270
|
-
w &&
|
|
1267
|
+
i.Validation.forEach((f) => {
|
|
1268
|
+
var b;
|
|
1269
|
+
const w = (b = t.Rules.Validation) == null ? void 0 : b[f];
|
|
1270
|
+
w && _t(w, s) && (n = !0);
|
|
1271
1271
|
}), n && !i.Required && (r[s] = {
|
|
1272
1272
|
...i,
|
|
1273
1273
|
Required: !0
|
|
@@ -1302,15 +1302,15 @@ function wr(e) {
|
|
|
1302
1302
|
return r.sort((i, n) => n.length - i.length), Object.entries(e.Rules.Computation).forEach(([i, n]) => {
|
|
1303
1303
|
const l = i.toUpperCase().replace(/[_-]/g, "");
|
|
1304
1304
|
for (const w of r) {
|
|
1305
|
-
const
|
|
1306
|
-
if (l.includes(
|
|
1305
|
+
const b = w.toUpperCase().replace(/[_-]/g, "");
|
|
1306
|
+
if (l.includes(b)) {
|
|
1307
1307
|
t[i] = w;
|
|
1308
1308
|
return;
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
|
-
const
|
|
1311
|
+
const f = `${n.Name || ""} ${n.Description || ""}`.toLowerCase();
|
|
1312
1312
|
for (const w of r)
|
|
1313
|
-
if (
|
|
1313
|
+
if (f.includes(w.toLowerCase())) {
|
|
1314
1314
|
t[i] = w;
|
|
1315
1315
|
return;
|
|
1316
1316
|
}
|
|
@@ -1325,11 +1325,11 @@ function vr(e, t) {
|
|
|
1325
1325
|
businessLogic: []
|
|
1326
1326
|
};
|
|
1327
1327
|
}), Object.entries(e.Fields).forEach(([i, n]) => {
|
|
1328
|
-
n.Validation && Array.isArray(n.Validation) && n.Validation.forEach((
|
|
1329
|
-
t.validation[
|
|
1330
|
-
}), n.Formula && Object.entries(t.computation).forEach(([l,
|
|
1328
|
+
n.Validation && Array.isArray(n.Validation) && n.Validation.forEach((f) => {
|
|
1329
|
+
t.validation[f] ? r[i].validation.push(f) : t.computation[f] ? r[i].computation.push(f) : t.businessLogic[f] && r[i].businessLogic.push(f);
|
|
1330
|
+
}), n.Formula && Object.entries(t.computation).forEach(([l, f]) => {
|
|
1331
1331
|
var w;
|
|
1332
|
-
|
|
1332
|
+
f.Expression === ((w = n.Formula) == null ? void 0 : w.Expression) && (r[i].computation.includes(l) || r[i].computation.push(l));
|
|
1333
1333
|
});
|
|
1334
1334
|
});
|
|
1335
1335
|
const s = wr(e);
|
|
@@ -1344,16 +1344,16 @@ function Fr(e, t) {
|
|
|
1344
1344
|
hidden: !1
|
|
1345
1345
|
};
|
|
1346
1346
|
return Object.keys(e.Fields).forEach((i) => {
|
|
1347
|
-
var w,
|
|
1347
|
+
var w, b, O, D, v, m;
|
|
1348
1348
|
if (!t || !((w = e.RolePermission) != null && w[t])) {
|
|
1349
1349
|
r[i] = s;
|
|
1350
1350
|
return;
|
|
1351
1351
|
}
|
|
1352
|
-
const n = e.RolePermission[t], l = ((
|
|
1352
|
+
const n = e.RolePermission[t], l = ((b = n.Editable) == null ? void 0 : b.includes(i)) || ((O = n.Editable) == null ? void 0 : O.includes("*")) || !1, f = ((D = n.ReadOnly) == null ? void 0 : D.includes(i)) || ((v = n.ReadOnly) == null ? void 0 : v.includes("*")) || l;
|
|
1353
1353
|
r[i] = {
|
|
1354
1354
|
editable: l && !((m = n.ReadOnly) != null && m.includes(i)),
|
|
1355
|
-
readable:
|
|
1356
|
-
hidden: !
|
|
1355
|
+
readable: f,
|
|
1356
|
+
hidden: !f
|
|
1357
1357
|
};
|
|
1358
1358
|
}), r;
|
|
1359
1359
|
}
|
|
@@ -1378,14 +1378,14 @@ function Vr(e, t) {
|
|
|
1378
1378
|
return "text";
|
|
1379
1379
|
}
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1381
|
+
function kt(e) {
|
|
1382
1382
|
return e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).replace(/_/g, " ").trim();
|
|
1383
1383
|
}
|
|
1384
1384
|
function Er(e, t, r) {
|
|
1385
1385
|
const s = {};
|
|
1386
1386
|
switch (t.Required && (s.required = {
|
|
1387
1387
|
value: !0,
|
|
1388
|
-
message: `${
|
|
1388
|
+
message: `${kt(e)} is required`
|
|
1389
1389
|
}), t.Type) {
|
|
1390
1390
|
case "Number":
|
|
1391
1391
|
s.valueAsNumber = !0;
|
|
@@ -1433,16 +1433,16 @@ function _r(e, t, r, s = {}, i, n) {
|
|
|
1433
1433
|
validation: [],
|
|
1434
1434
|
computation: [],
|
|
1435
1435
|
businessLogic: []
|
|
1436
|
-
},
|
|
1437
|
-
return
|
|
1436
|
+
}, b = t.Computed || !!t.Formula || w.computation.length > 0, O = Er(e, t);
|
|
1437
|
+
return b && (O.disabled = !0), {
|
|
1438
1438
|
name: e,
|
|
1439
1439
|
type: Vr(t.Type, e),
|
|
1440
|
-
label: t.Name ||
|
|
1440
|
+
label: t.Name || kt(e),
|
|
1441
1441
|
required: t.Required || !1,
|
|
1442
|
-
computed:
|
|
1442
|
+
computed: b,
|
|
1443
1443
|
defaultValue: xr(t, s),
|
|
1444
1444
|
options: Ar(t),
|
|
1445
|
-
validation:
|
|
1445
|
+
validation: O,
|
|
1446
1446
|
description: t.Description,
|
|
1447
1447
|
_bdoField: t,
|
|
1448
1448
|
permission: i || l,
|
|
@@ -1452,35 +1452,35 @@ function _r(e, t, r, s = {}, i, n) {
|
|
|
1452
1452
|
function Dr(e, t = {}, r) {
|
|
1453
1453
|
let s = e;
|
|
1454
1454
|
s = pr(s);
|
|
1455
|
-
const i = {}, n = [], l = [],
|
|
1455
|
+
const i = {}, n = [], l = [], f = [], w = [], b = br(s), O = vr(s, b), D = Fr(s, r);
|
|
1456
1456
|
for (const [v, m] of Object.entries(s.Fields)) {
|
|
1457
1457
|
if (v.startsWith("_") && !["_id"].includes(v))
|
|
1458
1458
|
continue;
|
|
1459
|
-
const
|
|
1460
|
-
if (
|
|
1459
|
+
const Y = D[v];
|
|
1460
|
+
if (Y.hidden)
|
|
1461
1461
|
continue;
|
|
1462
|
-
const
|
|
1462
|
+
const C = _r(
|
|
1463
1463
|
v,
|
|
1464
1464
|
m,
|
|
1465
1465
|
s.Fields,
|
|
1466
1466
|
t,
|
|
1467
|
-
|
|
1468
|
-
|
|
1467
|
+
Y,
|
|
1468
|
+
O[v] || {
|
|
1469
1469
|
validation: [],
|
|
1470
1470
|
computation: [],
|
|
1471
1471
|
businessLogic: []
|
|
1472
1472
|
}
|
|
1473
1473
|
);
|
|
1474
|
-
i[v] =
|
|
1474
|
+
i[v] = C, n.push(v), C.computed && l.push(v), C.required && f.push(v);
|
|
1475
1475
|
}
|
|
1476
1476
|
return {
|
|
1477
1477
|
fields: i,
|
|
1478
1478
|
fieldOrder: n,
|
|
1479
1479
|
computedFields: l,
|
|
1480
|
-
requiredFields:
|
|
1480
|
+
requiredFields: f,
|
|
1481
1481
|
crossFieldValidation: w,
|
|
1482
|
-
rules:
|
|
1483
|
-
fieldRules:
|
|
1482
|
+
rules: b,
|
|
1483
|
+
fieldRules: O,
|
|
1484
1484
|
rolePermissions: s.RolePermission
|
|
1485
1485
|
};
|
|
1486
1486
|
}
|
|
@@ -1534,7 +1534,7 @@ async function Or(e, t = 3) {
|
|
|
1534
1534
|
}
|
|
1535
1535
|
async function Cr(e, t) {
|
|
1536
1536
|
try {
|
|
1537
|
-
return await
|
|
1537
|
+
return await be(e).get(t);
|
|
1538
1538
|
} catch (r) {
|
|
1539
1539
|
throw console.error(`Record fetch error for ${e}/${t}:`, r), new Error(
|
|
1540
1540
|
`Failed to load record: ${r instanceof Error ? r.message : "Unknown error"}`
|
|
@@ -1545,7 +1545,7 @@ async function Tr(e, t, r, s) {
|
|
|
1545
1545
|
try {
|
|
1546
1546
|
let i;
|
|
1547
1547
|
if (t === "create")
|
|
1548
|
-
return i = await
|
|
1548
|
+
return i = await be(e).create(r), {
|
|
1549
1549
|
success: !0,
|
|
1550
1550
|
data: i,
|
|
1551
1551
|
recordId: i._id || s
|
|
@@ -1553,7 +1553,7 @@ async function Tr(e, t, r, s) {
|
|
|
1553
1553
|
if (t === "update") {
|
|
1554
1554
|
if (!s)
|
|
1555
1555
|
throw new Error("Record ID is required for update operations");
|
|
1556
|
-
return i = await
|
|
1556
|
+
return i = await be(e).update(s, r), {
|
|
1557
1557
|
success: !0,
|
|
1558
1558
|
data: i,
|
|
1559
1559
|
recordId: i._id || s
|
|
@@ -1572,7 +1572,7 @@ async function Tr(e, t, r, s) {
|
|
|
1572
1572
|
async function Lr(e, t = ["_id"], r, s) {
|
|
1573
1573
|
try {
|
|
1574
1574
|
const i = {};
|
|
1575
|
-
return r && (i.Filter = r), s && (i.Sort = s), t.length > 0 && (i.Field = t), (await
|
|
1575
|
+
return r && (i.Filter = r), s && (i.Sort = s), t.length > 0 && (i.Field = t), (await be(e).list(i)).Data || [];
|
|
1576
1576
|
} catch (i) {
|
|
1577
1577
|
return console.error(`Reference data fetch error for ${e}:`, i), [];
|
|
1578
1578
|
}
|
|
@@ -1603,19 +1603,19 @@ async function Mr(e) {
|
|
|
1603
1603
|
function Ir(e, t, r = "create", s) {
|
|
1604
1604
|
const i = {};
|
|
1605
1605
|
return Object.keys(e).forEach((n) => {
|
|
1606
|
-
const l = n,
|
|
1607
|
-
if (!t.includes(n) &&
|
|
1606
|
+
const l = n, f = e[l];
|
|
1607
|
+
if (!t.includes(n) && f !== void 0) {
|
|
1608
1608
|
if (r === "create") {
|
|
1609
|
-
i[l] =
|
|
1609
|
+
i[l] = f;
|
|
1610
1610
|
return;
|
|
1611
1611
|
}
|
|
1612
1612
|
if (r === "update") {
|
|
1613
1613
|
if (!s) {
|
|
1614
|
-
i[l] =
|
|
1614
|
+
i[l] = f;
|
|
1615
1615
|
return;
|
|
1616
1616
|
}
|
|
1617
1617
|
const w = s[l];
|
|
1618
|
-
JSON.stringify(
|
|
1618
|
+
JSON.stringify(f) !== JSON.stringify(w) && (i[l] = f);
|
|
1619
1619
|
}
|
|
1620
1620
|
}
|
|
1621
1621
|
}), i;
|
|
@@ -1632,22 +1632,22 @@ function Gr(e) {
|
|
|
1632
1632
|
var t, r, s;
|
|
1633
1633
|
return (e == null ? void 0 : e.status) === 400 || ((t = e == null ? void 0 : e.response) == null ? void 0 : t.status) === 400 || ((r = e == null ? void 0 : e.message) == null ? void 0 : r.toLowerCase().includes("validation")) || ((s = e == null ? void 0 : e.message) == null ? void 0 : s.toLowerCase().includes("invalid"));
|
|
1634
1634
|
}
|
|
1635
|
-
const
|
|
1635
|
+
const Ee = /* @__PURE__ */ new Map();
|
|
1636
1636
|
function kr(e, t, r = 10) {
|
|
1637
|
-
|
|
1637
|
+
Ee.set(e, {
|
|
1638
1638
|
data: t,
|
|
1639
1639
|
timestamp: Date.now(),
|
|
1640
1640
|
ttl: r * 60 * 1e3
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
1643
1643
|
function Ur(e) {
|
|
1644
|
-
const t =
|
|
1645
|
-
return t ? Date.now() - t.timestamp > t.ttl ? (
|
|
1644
|
+
const t = Ee.get(e);
|
|
1645
|
+
return t ? Date.now() - t.timestamp > t.ttl ? (Ee.delete(e), null) : t.data : null;
|
|
1646
1646
|
}
|
|
1647
1647
|
function Xr(e) {
|
|
1648
|
-
e ? Array.from(
|
|
1648
|
+
e ? Array.from(Ee.keys()).filter(
|
|
1649
1649
|
(r) => r.startsWith(e)
|
|
1650
|
-
).forEach((r) =>
|
|
1650
|
+
).forEach((r) => Ee.delete(r)) : Ee.clear();
|
|
1651
1651
|
}
|
|
1652
1652
|
async function Br(e) {
|
|
1653
1653
|
const t = `schema:${e}`, r = Ur(t);
|
|
@@ -1656,10 +1656,10 @@ async function Br(e) {
|
|
|
1656
1656
|
const s = await Or(e);
|
|
1657
1657
|
return kr(t, s, 30), s;
|
|
1658
1658
|
}
|
|
1659
|
-
class
|
|
1659
|
+
class Dt {
|
|
1660
1660
|
constructor(t = 1e3) {
|
|
1661
|
-
|
|
1662
|
-
|
|
1661
|
+
ve(this, "cache", /* @__PURE__ */ new Map());
|
|
1662
|
+
ve(this, "maxSize");
|
|
1663
1663
|
this.maxSize = t;
|
|
1664
1664
|
}
|
|
1665
1665
|
get(t) {
|
|
@@ -1700,9 +1700,9 @@ function Pr(e) {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
class qr {
|
|
1702
1702
|
constructor() {
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1703
|
+
ve(this, "resultCache", new Dt(500));
|
|
1704
|
+
ve(this, "dependencyCache", new Dt(200));
|
|
1705
|
+
ve(this, "compiledExpressions", /* @__PURE__ */ new Map());
|
|
1706
1706
|
}
|
|
1707
1707
|
/**
|
|
1708
1708
|
* Create cache key from expression and context
|
|
@@ -1848,7 +1848,7 @@ class qr {
|
|
|
1848
1848
|
const s = ((i = t.Arguments) == null ? void 0 : i.map((n) => this.evaluateNode(n, r))) || [];
|
|
1849
1849
|
switch (t.Callee) {
|
|
1850
1850
|
case "CONCAT":
|
|
1851
|
-
return s.map((
|
|
1851
|
+
return s.map((b) => String(b || "")).join("");
|
|
1852
1852
|
case "TRIM":
|
|
1853
1853
|
return String(s[0] || "").trim();
|
|
1854
1854
|
case "LENGTH":
|
|
@@ -1862,14 +1862,14 @@ class qr {
|
|
|
1862
1862
|
case "MATCHES":
|
|
1863
1863
|
return new RegExp(String(s[1])).test(String(s[0] || ""));
|
|
1864
1864
|
case "SUM":
|
|
1865
|
-
return s.reduce((
|
|
1865
|
+
return s.reduce((b, O) => b + (Number(O) || 0), 0);
|
|
1866
1866
|
case "AVG":
|
|
1867
|
-
const n = s.filter((
|
|
1868
|
-
return n.length > 0 ? n.reduce((
|
|
1867
|
+
const n = s.filter((b) => !isNaN(Number(b)));
|
|
1868
|
+
return n.length > 0 ? n.reduce((b, O) => b + Number(O), 0) / n.length : 0;
|
|
1869
1869
|
case "MIN":
|
|
1870
|
-
return Math.min(...s.map((
|
|
1870
|
+
return Math.min(...s.map((b) => Number(b) || 0));
|
|
1871
1871
|
case "MAX":
|
|
1872
|
-
return Math.max(...s.map((
|
|
1872
|
+
return Math.max(...s.map((b) => Number(b) || 0));
|
|
1873
1873
|
case "ROUND":
|
|
1874
1874
|
return Math.round(Number(s[0]) || 0);
|
|
1875
1875
|
case "FLOOR":
|
|
@@ -1885,7 +1885,7 @@ class qr {
|
|
|
1885
1885
|
case "DAY":
|
|
1886
1886
|
return new Date(s[0]).getDate();
|
|
1887
1887
|
case "DATE_DIFF":
|
|
1888
|
-
const l = new Date(s[0]),
|
|
1888
|
+
const l = new Date(s[0]), f = new Date(s[1]), w = Math.abs(l.getTime() - f.getTime());
|
|
1889
1889
|
return Math.ceil(w / (1e3 * 60 * 60 * 24));
|
|
1890
1890
|
case "IF":
|
|
1891
1891
|
return s[0] ? s[1] : s[2];
|
|
@@ -1912,14 +1912,14 @@ class qr {
|
|
|
1912
1912
|
this.resultCache.clear(), this.dependencyCache.clear(), this.compiledExpressions.clear();
|
|
1913
1913
|
}
|
|
1914
1914
|
}
|
|
1915
|
-
const
|
|
1915
|
+
const Ut = new qr();
|
|
1916
1916
|
function $r(e, t, r, s, i) {
|
|
1917
1917
|
if (!r || r.length === 0)
|
|
1918
1918
|
return { isValid: !0 };
|
|
1919
1919
|
const n = { ...s, [e]: t };
|
|
1920
1920
|
for (const l of r)
|
|
1921
1921
|
try {
|
|
1922
|
-
if (!
|
|
1922
|
+
if (!Ut.evaluate(
|
|
1923
1923
|
l.ExpressionTree,
|
|
1924
1924
|
n,
|
|
1925
1925
|
i
|
|
@@ -1929,13 +1929,13 @@ function $r(e, t, r, s, i) {
|
|
|
1929
1929
|
message: l.Message || `Validation failed for ${l.Name}`,
|
|
1930
1930
|
fieldName: e
|
|
1931
1931
|
};
|
|
1932
|
-
} catch (
|
|
1933
|
-
console.warn(`Validation rule ${l.Id} failed to evaluate:`,
|
|
1932
|
+
} catch (f) {
|
|
1933
|
+
console.warn(`Validation rule ${l.Id} failed to evaluate:`, f);
|
|
1934
1934
|
}
|
|
1935
1935
|
return { isValid: !0 };
|
|
1936
1936
|
}
|
|
1937
|
-
function
|
|
1938
|
-
return Array.from(
|
|
1937
|
+
function St(e) {
|
|
1938
|
+
return Array.from(Ut.getDependencies(e));
|
|
1939
1939
|
}
|
|
1940
1940
|
function Qr(e) {
|
|
1941
1941
|
const {
|
|
@@ -1946,24 +1946,24 @@ function Qr(e) {
|
|
|
1946
1946
|
mode: n = "onBlur",
|
|
1947
1947
|
// Validation mode - controls when errors are shown (see types.ts for details)
|
|
1948
1948
|
enabled: l = !0,
|
|
1949
|
-
userRole:
|
|
1949
|
+
userRole: f,
|
|
1950
1950
|
onSchemaError: w,
|
|
1951
|
-
skipSchemaFetch:
|
|
1952
|
-
schema:
|
|
1951
|
+
skipSchemaFetch: b = !1,
|
|
1952
|
+
schema: O,
|
|
1953
1953
|
interactionMode: D = "interactive"
|
|
1954
|
-
} = e, v = D === "interactive", [m,
|
|
1955
|
-
|
|
1956
|
-
|
|
1954
|
+
} = e, v = D === "interactive", [m, Y] = ge(null), [C, Z] = ge({}), [W, A] = ge(!1), [ee] = ge({}), [M, L] = ge(null), [le, ye] = ge(!1), [ae, ne] = ge(null), j = Se(!1), ce = Se(null), V = Se(null), x = Se(!1), S = Se(w);
|
|
1955
|
+
We(() => {
|
|
1956
|
+
S.current = w;
|
|
1957
1957
|
}, [w]);
|
|
1958
1958
|
const {
|
|
1959
|
-
data:
|
|
1960
|
-
isLoading:
|
|
1961
|
-
error:
|
|
1962
|
-
refetch:
|
|
1963
|
-
} =
|
|
1959
|
+
data: I,
|
|
1960
|
+
isLoading: G,
|
|
1961
|
+
error: q,
|
|
1962
|
+
refetch: de
|
|
1963
|
+
} = dt({
|
|
1964
1964
|
queryKey: ["form-schema", t],
|
|
1965
|
-
queryFn: () =>
|
|
1966
|
-
enabled: l && (!
|
|
1965
|
+
queryFn: () => b ? Promise.resolve(O || {}) : Br(t),
|
|
1966
|
+
enabled: l && (!b || !!O),
|
|
1967
1967
|
retry: 3,
|
|
1968
1968
|
staleTime: 30 * 60 * 1e3,
|
|
1969
1969
|
// 30 minutes - schemas don't change frequently
|
|
@@ -1971,10 +1971,10 @@ function Qr(e) {
|
|
|
1971
1971
|
// 1 hour - keep schemas in cache longer
|
|
1972
1972
|
throwOnError: !1
|
|
1973
1973
|
}), {
|
|
1974
|
-
data:
|
|
1975
|
-
isLoading:
|
|
1976
|
-
error:
|
|
1977
|
-
} =
|
|
1974
|
+
data: K,
|
|
1975
|
+
isLoading: fe,
|
|
1976
|
+
error: Le
|
|
1977
|
+
} = dt({
|
|
1978
1978
|
queryKey: ["form-record", t, s],
|
|
1979
1979
|
queryFn: () => Cr(t, s),
|
|
1980
1980
|
enabled: l && r === "update" && !!s,
|
|
@@ -1984,122 +1984,122 @@ function Qr(e) {
|
|
|
1984
1984
|
gcTime: 15 * 60 * 1e3,
|
|
1985
1985
|
// 15 minutes - keep records for a reasonable time
|
|
1986
1986
|
throwOnError: !1
|
|
1987
|
-
}), Me =
|
|
1988
|
-
const
|
|
1989
|
-
if (r === "update" &&
|
|
1990
|
-
for (const [
|
|
1991
|
-
|
|
1992
|
-
return
|
|
1993
|
-
}, [i,
|
|
1987
|
+
}), Me = Re(() => {
|
|
1988
|
+
const u = { ...i };
|
|
1989
|
+
if (r === "update" && K && Object.assign(u, K), m)
|
|
1990
|
+
for (const [h, c] of Object.entries(m.fields))
|
|
1991
|
+
c.defaultValue !== void 0 && !(h in u) && (u[h] = c.defaultValue);
|
|
1992
|
+
return u;
|
|
1993
|
+
}, [i, K, r, m]), E = dr({
|
|
1994
1994
|
mode: n,
|
|
1995
1995
|
defaultValues: i,
|
|
1996
|
-
values: r === "update" &&
|
|
1996
|
+
values: r === "update" && K ? Me : void 0
|
|
1997
1997
|
});
|
|
1998
|
-
|
|
1999
|
-
var
|
|
2000
|
-
if (
|
|
1998
|
+
We(() => {
|
|
1999
|
+
var u;
|
|
2000
|
+
if (I)
|
|
2001
2001
|
try {
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2002
|
+
const h = Dr(
|
|
2003
|
+
I,
|
|
2004
2004
|
{},
|
|
2005
2005
|
// Pass empty object - validation functions get live values from react-hook-form
|
|
2006
|
-
|
|
2006
|
+
f
|
|
2007
2007
|
);
|
|
2008
|
-
|
|
2009
|
-
const
|
|
2010
|
-
Object.keys(
|
|
2011
|
-
} catch (
|
|
2012
|
-
console.error("Schema processing failed:",
|
|
2008
|
+
Y(h);
|
|
2009
|
+
const c = Rr(h);
|
|
2010
|
+
Object.keys(c).length > 0 && Mr(c).then(Z).catch(console.warn);
|
|
2011
|
+
} catch (h) {
|
|
2012
|
+
console.error("Schema processing failed:", h), (u = S.current) == null || u.call(S, h);
|
|
2013
2013
|
}
|
|
2014
|
-
}, [
|
|
2015
|
-
var
|
|
2016
|
-
|
|
2017
|
-
}, [
|
|
2018
|
-
if (!v || r !== "create" || !m || !l ||
|
|
2014
|
+
}, [I, f]), We(() => {
|
|
2015
|
+
var u;
|
|
2016
|
+
q && ((u = S.current) == null || u.call(S, q));
|
|
2017
|
+
}, [q]), We(() => {
|
|
2018
|
+
if (!v || r !== "create" || !m || !l || M || x.current)
|
|
2019
2019
|
return;
|
|
2020
|
-
(async () => {
|
|
2021
|
-
|
|
2020
|
+
x.current = !0, (async () => {
|
|
2021
|
+
ye(!0), ne(null);
|
|
2022
2022
|
try {
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2025
|
-
if (
|
|
2026
|
-
|
|
2023
|
+
const c = await be(t).draftInteraction({});
|
|
2024
|
+
L(c._id), c && typeof c == "object" && Object.entries(c).forEach(([d, y]) => {
|
|
2025
|
+
if (d === "_id") return;
|
|
2026
|
+
E.getValues(d) !== y && E.setValue(d, y, {
|
|
2027
2027
|
shouldDirty: !1,
|
|
2028
2028
|
shouldValidate: !1
|
|
2029
2029
|
});
|
|
2030
2030
|
});
|
|
2031
|
-
} catch (
|
|
2032
|
-
console.error("Failed to create initial draft:",
|
|
2031
|
+
} catch (h) {
|
|
2032
|
+
console.error("Failed to create initial draft:", h), ne(h), x.current = !1;
|
|
2033
2033
|
} finally {
|
|
2034
|
-
|
|
2034
|
+
ye(!1);
|
|
2035
2035
|
}
|
|
2036
2036
|
})();
|
|
2037
|
-
}, [v, r, m, l,
|
|
2038
|
-
const
|
|
2037
|
+
}, [v, r, m, l, M, t]);
|
|
2038
|
+
const we = Re(() => {
|
|
2039
2039
|
if (!m) return [];
|
|
2040
|
-
const
|
|
2041
|
-
return Object.entries(m.fieldRules).forEach(([
|
|
2042
|
-
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2045
|
-
m.fields[
|
|
2040
|
+
const u = /* @__PURE__ */ new Set(), h = new Set(m.computedFields);
|
|
2041
|
+
return Object.entries(m.fieldRules).forEach(([c, d]) => {
|
|
2042
|
+
d.computation.forEach((y) => {
|
|
2043
|
+
const p = m.rules.computation[y];
|
|
2044
|
+
p != null && p.ExpressionTree && St(p.ExpressionTree).forEach((_) => {
|
|
2045
|
+
m.fields[_] && _ !== c && !h.has(_) && u.add(_);
|
|
2046
2046
|
});
|
|
2047
2047
|
});
|
|
2048
|
-
}), m.computedFields.forEach((
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
).forEach((
|
|
2053
|
-
m.fields[
|
|
2048
|
+
}), m.computedFields.forEach((c) => {
|
|
2049
|
+
const d = m.fields[c];
|
|
2050
|
+
d._bdoField.Formula && St(
|
|
2051
|
+
d._bdoField.Formula.ExpressionTree
|
|
2052
|
+
).forEach((p) => {
|
|
2053
|
+
m.fields[p] && p !== c && !h.has(p) && u.add(p);
|
|
2054
2054
|
});
|
|
2055
|
-
}), Array.from(
|
|
2056
|
-
}, [m]),
|
|
2057
|
-
async (
|
|
2058
|
-
if (!(!m || !(v ||
|
|
2059
|
-
if (v && r === "create" && !
|
|
2055
|
+
}), Array.from(u);
|
|
2056
|
+
}, [m]), Ie = te(
|
|
2057
|
+
async (u) => {
|
|
2058
|
+
if (!(!m || !(v || we.length > 0 && we.includes(u)))) {
|
|
2059
|
+
if (v && r === "create" && !M) {
|
|
2060
2060
|
console.warn("Interactive create mode: waiting for draft ID");
|
|
2061
2061
|
return;
|
|
2062
2062
|
}
|
|
2063
|
-
|
|
2064
|
-
if (!m ||
|
|
2063
|
+
j.current || (ce.current && clearTimeout(ce.current), ce.current = setTimeout(() => {
|
|
2064
|
+
if (!m || j.current)
|
|
2065
2065
|
return;
|
|
2066
|
-
const
|
|
2066
|
+
const c = E.getValues();
|
|
2067
2067
|
(async () => {
|
|
2068
|
-
|
|
2068
|
+
j.current = !0;
|
|
2069
2069
|
try {
|
|
2070
|
-
const
|
|
2071
|
-
r === "update" && s && "_id" in
|
|
2072
|
-
const F = V.current ?? (r === "update" ?
|
|
2070
|
+
const y = be(t), p = {};
|
|
2071
|
+
r === "update" && s && "_id" in c && (p._id = c._id), v && r === "create" && M && (p._id = M);
|
|
2072
|
+
const F = V.current ?? (r === "update" ? K : null) ?? {}, _ = new Set(
|
|
2073
2073
|
m.computedFields || []
|
|
2074
2074
|
);
|
|
2075
|
-
Object.keys(
|
|
2076
|
-
if (
|
|
2077
|
-
const
|
|
2078
|
-
JSON.stringify(
|
|
2075
|
+
Object.keys(c).forEach((B) => {
|
|
2076
|
+
if (B === "_id" || _.has(B)) return;
|
|
2077
|
+
const z = c[B], je = F[B];
|
|
2078
|
+
JSON.stringify(z) !== JSON.stringify(je) && (z !== "" && z !== null && z !== void 0) && (p[B] = z);
|
|
2079
2079
|
});
|
|
2080
|
-
const
|
|
2080
|
+
const R = p, $ = {
|
|
2081
2081
|
...V.current
|
|
2082
2082
|
};
|
|
2083
|
-
Object.keys(
|
|
2084
|
-
|
|
2085
|
-
}), V.current =
|
|
2086
|
-
let
|
|
2087
|
-
r === "update" && s ?
|
|
2088
|
-
([
|
|
2089
|
-
|
|
2083
|
+
Object.keys(c).forEach((B) => {
|
|
2084
|
+
_.has(B) || ($[B] = c[B]);
|
|
2085
|
+
}), V.current = $;
|
|
2086
|
+
let ue;
|
|
2087
|
+
r === "update" && s ? ue = await y.draftPatch(s, R) : v && M ? ue = await y.draftInteraction(R) : ue = await y.draft(R), ue && typeof ue == "object" && (Object.entries(ue).forEach(
|
|
2088
|
+
([B, z]) => {
|
|
2089
|
+
c[B] !== z && E.setValue(B, z, {
|
|
2090
2090
|
shouldDirty: !1,
|
|
2091
2091
|
shouldValidate: !1
|
|
2092
2092
|
});
|
|
2093
2093
|
}
|
|
2094
|
-
), Object.entries(
|
|
2095
|
-
([
|
|
2096
|
-
|
|
2094
|
+
), Object.entries(ue).forEach(
|
|
2095
|
+
([B, z]) => {
|
|
2096
|
+
_.has(B) && (V.current[B] = z);
|
|
2097
2097
|
}
|
|
2098
2098
|
));
|
|
2099
|
-
} catch (
|
|
2100
|
-
console.warn("Failed to compute fields via API:",
|
|
2099
|
+
} catch (y) {
|
|
2100
|
+
console.warn("Failed to compute fields via API:", y);
|
|
2101
2101
|
} finally {
|
|
2102
|
-
|
|
2102
|
+
j.current = !1;
|
|
2103
2103
|
}
|
|
2104
2104
|
})();
|
|
2105
2105
|
}, 300));
|
|
@@ -2109,241 +2109,241 @@ function Qr(e) {
|
|
|
2109
2109
|
m,
|
|
2110
2110
|
r,
|
|
2111
2111
|
s,
|
|
2112
|
-
|
|
2112
|
+
K,
|
|
2113
2113
|
t,
|
|
2114
|
-
|
|
2115
|
-
|
|
2114
|
+
E,
|
|
2115
|
+
we,
|
|
2116
2116
|
v,
|
|
2117
|
-
|
|
2117
|
+
M
|
|
2118
2118
|
]
|
|
2119
|
-
),
|
|
2119
|
+
), ke = te(async () => {
|
|
2120
2120
|
if (!m)
|
|
2121
2121
|
return !1;
|
|
2122
|
-
const
|
|
2123
|
-
if (!await
|
|
2122
|
+
const u = E.getValues();
|
|
2123
|
+
if (!await E.trigger())
|
|
2124
2124
|
return !1;
|
|
2125
|
-
const
|
|
2126
|
-
(
|
|
2127
|
-
Id:
|
|
2128
|
-
Condition: { ExpressionTree:
|
|
2129
|
-
Message:
|
|
2125
|
+
const c = m.crossFieldValidation.map(
|
|
2126
|
+
(y) => ({
|
|
2127
|
+
Id: y.Id,
|
|
2128
|
+
Condition: { ExpressionTree: y.ExpressionTree },
|
|
2129
|
+
Message: y.Message || `Validation failed for ${y.Name}`
|
|
2130
2130
|
})
|
|
2131
|
-
),
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2131
|
+
), d = xt(
|
|
2132
|
+
c,
|
|
2133
|
+
u,
|
|
2134
|
+
C
|
|
2135
2135
|
);
|
|
2136
|
-
return
|
|
2137
|
-
|
|
2136
|
+
return d.length > 0 ? (d.forEach((y, p) => {
|
|
2137
|
+
E.setError(`root.crossField${p}`, {
|
|
2138
2138
|
type: "validate",
|
|
2139
|
-
message:
|
|
2139
|
+
message: y.message
|
|
2140
2140
|
});
|
|
2141
2141
|
}), !1) : !0;
|
|
2142
2142
|
}, [
|
|
2143
2143
|
m,
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
]),
|
|
2149
|
-
(
|
|
2144
|
+
E.getValues,
|
|
2145
|
+
E.trigger,
|
|
2146
|
+
E.setError,
|
|
2147
|
+
C
|
|
2148
|
+
]), ze = te(
|
|
2149
|
+
(u, h) => E.handleSubmit(
|
|
2150
2150
|
// RHF onValid handler - validation passed, now do cross-field + API
|
|
2151
|
-
async (
|
|
2151
|
+
async (c, d) => {
|
|
2152
2152
|
if (!m) {
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2153
|
+
const y = new Error("Schema not loaded");
|
|
2154
|
+
h == null || h(y, d);
|
|
2155
2155
|
return;
|
|
2156
2156
|
}
|
|
2157
|
-
|
|
2157
|
+
A(!0);
|
|
2158
2158
|
try {
|
|
2159
|
-
const
|
|
2160
|
-
(
|
|
2161
|
-
Id:
|
|
2162
|
-
Condition: { ExpressionTree:
|
|
2163
|
-
Message:
|
|
2159
|
+
const y = m.crossFieldValidation.map(
|
|
2160
|
+
(R) => ({
|
|
2161
|
+
Id: R.Id,
|
|
2162
|
+
Condition: { ExpressionTree: R.ExpressionTree },
|
|
2163
|
+
Message: R.Message || `Validation failed for ${R.Name}`
|
|
2164
2164
|
})
|
|
2165
|
-
),
|
|
2165
|
+
), p = xt(
|
|
2166
|
+
y,
|
|
2166
2167
|
c,
|
|
2167
|
-
|
|
2168
|
-
O
|
|
2168
|
+
C
|
|
2169
2169
|
);
|
|
2170
|
-
if (
|
|
2171
|
-
|
|
2172
|
-
|
|
2170
|
+
if (p.length > 0) {
|
|
2171
|
+
p.forEach((R, $) => {
|
|
2172
|
+
E.setError(`root.crossField${$}`, {
|
|
2173
2173
|
type: "validate",
|
|
2174
|
-
message:
|
|
2174
|
+
message: R.message
|
|
2175
2175
|
});
|
|
2176
|
-
}),
|
|
2176
|
+
}), h == null || h(E.formState.errors, d);
|
|
2177
2177
|
return;
|
|
2178
2178
|
}
|
|
2179
2179
|
const F = Ir(
|
|
2180
|
-
|
|
2180
|
+
c,
|
|
2181
2181
|
m.computedFields,
|
|
2182
2182
|
r,
|
|
2183
|
-
|
|
2183
|
+
K
|
|
2184
2184
|
);
|
|
2185
|
-
let
|
|
2185
|
+
let _;
|
|
2186
2186
|
if (v) {
|
|
2187
|
-
const
|
|
2187
|
+
const R = be(t);
|
|
2188
2188
|
if (r === "create") {
|
|
2189
|
-
if (!
|
|
2189
|
+
if (!M)
|
|
2190
2190
|
throw new Error(
|
|
2191
2191
|
"Interactive create mode requires a draft ID. Draft creation may have failed."
|
|
2192
2192
|
);
|
|
2193
|
-
|
|
2193
|
+
_ = { success: !0, data: await R.draft({
|
|
2194
2194
|
...F,
|
|
2195
|
-
_id:
|
|
2195
|
+
_id: M
|
|
2196
2196
|
}) };
|
|
2197
2197
|
} else
|
|
2198
|
-
|
|
2199
|
-
} else if (
|
|
2198
|
+
_ = { success: !0, data: await R.draftUpdate(s, F) };
|
|
2199
|
+
} else if (_ = await Tr(
|
|
2200
2200
|
t,
|
|
2201
2201
|
r,
|
|
2202
2202
|
F,
|
|
2203
2203
|
s
|
|
2204
|
-
), !
|
|
2205
|
-
throw
|
|
2206
|
-
r === "create" && (
|
|
2207
|
-
} catch (
|
|
2208
|
-
|
|
2204
|
+
), !_.success)
|
|
2205
|
+
throw _.error || new Error("Submission failed");
|
|
2206
|
+
r === "create" && (E.reset(), v && L(null)), await (u == null ? void 0 : u(_.data || c, d));
|
|
2207
|
+
} catch (y) {
|
|
2208
|
+
h == null || h(y, d);
|
|
2209
2209
|
} finally {
|
|
2210
|
-
|
|
2210
|
+
A(!1);
|
|
2211
2211
|
}
|
|
2212
2212
|
},
|
|
2213
2213
|
// RHF onInvalid handler - validation failed
|
|
2214
|
-
(
|
|
2215
|
-
|
|
2214
|
+
(c, d) => {
|
|
2215
|
+
h == null || h(c, d);
|
|
2216
2216
|
}
|
|
2217
2217
|
),
|
|
2218
2218
|
[
|
|
2219
|
-
|
|
2219
|
+
E,
|
|
2220
2220
|
m,
|
|
2221
|
-
|
|
2221
|
+
C,
|
|
2222
2222
|
t,
|
|
2223
2223
|
r,
|
|
2224
2224
|
s,
|
|
2225
|
-
|
|
2225
|
+
K,
|
|
2226
2226
|
v,
|
|
2227
|
-
|
|
2227
|
+
M
|
|
2228
2228
|
]
|
|
2229
|
-
),
|
|
2230
|
-
(
|
|
2229
|
+
), Ae = te(
|
|
2230
|
+
(u) => (m == null ? void 0 : m.fields[u]) || null,
|
|
2231
2231
|
[m]
|
|
2232
|
-
),
|
|
2232
|
+
), Ue = te(() => {
|
|
2233
2233
|
if (!m) return {};
|
|
2234
|
-
const
|
|
2235
|
-
return Object.entries(m.fields).forEach(([
|
|
2236
|
-
|
|
2237
|
-
}),
|
|
2238
|
-
}, [m]),
|
|
2239
|
-
(
|
|
2234
|
+
const u = {};
|
|
2235
|
+
return Object.entries(m.fields).forEach(([h, c]) => {
|
|
2236
|
+
u[h] = c;
|
|
2237
|
+
}), u;
|
|
2238
|
+
}, [m]), xe = te(
|
|
2239
|
+
(u) => !!(m != null && m.fields[u]),
|
|
2240
2240
|
[m]
|
|
2241
2241
|
), _e = te(
|
|
2242
|
-
(
|
|
2242
|
+
(u) => (m == null ? void 0 : m.requiredFields.includes(u)) || !1,
|
|
2243
2243
|
[m]
|
|
2244
|
-
),
|
|
2245
|
-
(
|
|
2244
|
+
), Je = te(
|
|
2245
|
+
(u) => (m == null ? void 0 : m.computedFields.includes(u)) || !1,
|
|
2246
2246
|
[m]
|
|
2247
|
-
),
|
|
2248
|
-
await
|
|
2249
|
-
}, [
|
|
2250
|
-
|
|
2251
|
-
}, [
|
|
2247
|
+
), Be = te(async () => {
|
|
2248
|
+
await de();
|
|
2249
|
+
}, [de]), Ge = te(() => {
|
|
2250
|
+
E.clearErrors();
|
|
2251
|
+
}, [E]), De = G || r === "update" && fe || v && r === "create" && le, Pe = De || W, qe = q || Le || ae, Xe = !!qe, ot = Re(
|
|
2252
2252
|
() => (m == null ? void 0 : m.computedFields) || [],
|
|
2253
2253
|
[m]
|
|
2254
|
-
),
|
|
2254
|
+
), $e = Re(
|
|
2255
2255
|
() => (m == null ? void 0 : m.requiredFields) || [],
|
|
2256
2256
|
[m]
|
|
2257
|
-
),
|
|
2257
|
+
), a = Re(() => {
|
|
2258
2258
|
if (!m) return {};
|
|
2259
|
-
const
|
|
2260
|
-
return Object.entries(m.fields).forEach(([
|
|
2261
|
-
const
|
|
2262
|
-
switch (
|
|
2259
|
+
const u = {};
|
|
2260
|
+
return Object.entries(m.fields).forEach(([h, c]) => {
|
|
2261
|
+
const d = {};
|
|
2262
|
+
switch (c.required && (d.required = `${c.label} is required`), c.permission.editable || (d.disabled = !0), c.type) {
|
|
2263
2263
|
case "number":
|
|
2264
|
-
|
|
2264
|
+
d.valueAsNumber = !0;
|
|
2265
2265
|
break;
|
|
2266
2266
|
case "date":
|
|
2267
2267
|
case "datetime-local":
|
|
2268
|
-
|
|
2268
|
+
d.valueAsDate = !0;
|
|
2269
2269
|
break;
|
|
2270
2270
|
}
|
|
2271
|
-
const
|
|
2272
|
-
|
|
2273
|
-
expressionValidation: (
|
|
2274
|
-
const F =
|
|
2275
|
-
for (const
|
|
2276
|
-
const
|
|
2277
|
-
if (
|
|
2278
|
-
const
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
[
|
|
2271
|
+
const y = c.rules.validation;
|
|
2272
|
+
y.length > 0 && (d.validate = {
|
|
2273
|
+
expressionValidation: (p) => {
|
|
2274
|
+
const F = E.getValues();
|
|
2275
|
+
for (const _ of y) {
|
|
2276
|
+
const R = m.rules.validation[_];
|
|
2277
|
+
if (R) {
|
|
2278
|
+
const $ = $r(
|
|
2279
|
+
h,
|
|
2280
|
+
p,
|
|
2281
|
+
[R],
|
|
2282
2282
|
F,
|
|
2283
2283
|
ee
|
|
2284
2284
|
);
|
|
2285
|
-
if (
|
|
2286
|
-
return
|
|
2285
|
+
if (!$.isValid)
|
|
2286
|
+
return $.message || R.Message || "Invalid value";
|
|
2287
2287
|
}
|
|
2288
2288
|
}
|
|
2289
2289
|
return !0;
|
|
2290
2290
|
}
|
|
2291
|
-
}),
|
|
2292
|
-
}),
|
|
2293
|
-
}, [m,
|
|
2291
|
+
}), u[h] = d;
|
|
2292
|
+
}), u;
|
|
2293
|
+
}, [m, E, C]);
|
|
2294
2294
|
return {
|
|
2295
2295
|
// Form methods with strict typing
|
|
2296
2296
|
register: te(
|
|
2297
|
-
(
|
|
2298
|
-
const
|
|
2299
|
-
|
|
2297
|
+
(u, h) => {
|
|
2298
|
+
const c = a[u], d = h == null ? void 0 : h.onBlur, y = async (p) => {
|
|
2299
|
+
d && await d(p);
|
|
2300
2300
|
let F = !0;
|
|
2301
|
-
n === "onBlur" || n === "onTouched" || n === "all" ? F = await
|
|
2301
|
+
n === "onBlur" || n === "onTouched" || n === "all" ? F = await E.trigger(u) : F = !E.getFieldState(u, E.formState).error, F && await Ie(u);
|
|
2302
2302
|
};
|
|
2303
|
-
return
|
|
2304
|
-
...
|
|
2305
|
-
...
|
|
2306
|
-
onBlur:
|
|
2303
|
+
return E.register(u, {
|
|
2304
|
+
...c,
|
|
2305
|
+
...h,
|
|
2306
|
+
onBlur: y
|
|
2307
2307
|
});
|
|
2308
2308
|
},
|
|
2309
|
-
[
|
|
2309
|
+
[E, a, Ie, n]
|
|
2310
2310
|
),
|
|
2311
|
-
handleSubmit:
|
|
2312
|
-
watch:
|
|
2311
|
+
handleSubmit: ze,
|
|
2312
|
+
watch: E.watch,
|
|
2313
2313
|
// Type assertion for complex generic constraints
|
|
2314
|
-
setValue:
|
|
2315
|
-
reset:
|
|
2314
|
+
setValue: E.setValue,
|
|
2315
|
+
reset: E.reset,
|
|
2316
2316
|
// Flattened form state (NEW - direct access, no nested formState)
|
|
2317
|
-
errors:
|
|
2318
|
-
isValid:
|
|
2319
|
-
isDirty:
|
|
2320
|
-
isSubmitting:
|
|
2321
|
-
isSubmitSuccessful:
|
|
2317
|
+
errors: E.formState.errors,
|
|
2318
|
+
isValid: E.formState.isValid,
|
|
2319
|
+
isDirty: E.formState.isDirty,
|
|
2320
|
+
isSubmitting: E.formState.isSubmitting || W,
|
|
2321
|
+
isSubmitSuccessful: E.formState.isSubmitSuccessful,
|
|
2322
2322
|
// Loading states
|
|
2323
|
-
isLoadingInitialData:
|
|
2324
|
-
isLoadingRecord:
|
|
2323
|
+
isLoadingInitialData: De,
|
|
2324
|
+
isLoadingRecord: fe,
|
|
2325
2325
|
isLoading: Pe,
|
|
2326
2326
|
// Interactive mode state
|
|
2327
|
-
draftId:
|
|
2328
|
-
isCreatingDraft:
|
|
2327
|
+
draftId: M,
|
|
2328
|
+
isCreatingDraft: le,
|
|
2329
2329
|
// Error handling
|
|
2330
|
-
loadError:
|
|
2331
|
-
hasError:
|
|
2330
|
+
loadError: qe,
|
|
2331
|
+
hasError: Xe,
|
|
2332
2332
|
// Schema information
|
|
2333
|
-
schema:
|
|
2333
|
+
schema: I,
|
|
2334
2334
|
schemaConfig: m,
|
|
2335
|
-
computedFields:
|
|
2336
|
-
requiredFields:
|
|
2335
|
+
computedFields: ot,
|
|
2336
|
+
requiredFields: $e,
|
|
2337
2337
|
// Field helpers
|
|
2338
|
-
getField:
|
|
2339
|
-
getFields:
|
|
2340
|
-
hasField:
|
|
2338
|
+
getField: Ae,
|
|
2339
|
+
getFields: Ue,
|
|
2340
|
+
hasField: xe,
|
|
2341
2341
|
isFieldRequired: _e,
|
|
2342
|
-
isFieldComputed:
|
|
2342
|
+
isFieldComputed: Je,
|
|
2343
2343
|
// Operations
|
|
2344
|
-
refreshSchema:
|
|
2345
|
-
validateForm:
|
|
2346
|
-
clearErrors:
|
|
2344
|
+
refreshSchema: Be,
|
|
2345
|
+
validateForm: ke,
|
|
2346
|
+
clearErrors: Ge
|
|
2347
2347
|
};
|
|
2348
2348
|
}
|
|
2349
2349
|
export {
|