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