@ram_28/kf-ai-sdk 1.0.20 → 1.0.22
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/types.d.ts +8 -0
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +1028 -1051
- 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/types.ts +9 -0
- package/sdk/components/hooks/useForm/useForm.ts +79 -60
- 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,61 +1,61 @@
|
|
|
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 jt = Object.defineProperty;
|
|
2
|
+
var Wt = (e, t, r) => t in e ? jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var we = (e, t, r) => Wt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import Z, { useState as pe, useRef as Te, useEffect as He, useMemo as Le, useCallback as se } from "react";
|
|
5
|
+
import { useQuery as mt } from "@tanstack/react-query";
|
|
6
|
+
import { a as Ee } from "./client-BIkaIr2y.js";
|
|
7
|
+
import { g as Ht } from "./metadata-VbQzyD2C.js";
|
|
8
|
+
import { t as Ie } from "./error-handling-CrhTtD88.js";
|
|
9
|
+
var Be = (e) => e.type === "checkbox", be = (e) => e instanceof Date, X = (e) => e == null;
|
|
10
|
+
const Ct = (e) => typeof e == "object";
|
|
11
|
+
var B = (e) => !X(e) && !Array.isArray(e) && Ct(e) && !be(e), Yt = (e) => B(e) && e.target ? Be(e.target) ? e.target.checked : e.target.value : e, Kt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, zt = (e, t) => e.has(Kt(t)), Jt = (e) => {
|
|
12
12
|
const t = e.constructor && e.constructor.prototype;
|
|
13
|
-
return
|
|
14
|
-
},
|
|
15
|
-
function
|
|
13
|
+
return B(t) && t.hasOwnProperty("isPrototypeOf");
|
|
14
|
+
}, nt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
15
|
+
function $(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 && !(B(e) && Jt(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] = $(e[i]));
|
|
27
27
|
return s;
|
|
28
28
|
}
|
|
29
|
-
var ze = (e) => /^\w*$/.test(e),
|
|
30
|
-
if (!t || !
|
|
29
|
+
var ze = (e) => /^\w*$/.test(e), I = (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 || !B(e))
|
|
31
31
|
return r;
|
|
32
|
-
const s = (ze(t) ? [t] :
|
|
33
|
-
return
|
|
34
|
-
},
|
|
32
|
+
const s = (ze(t) ? [t] : ot(t)).reduce((i, n) => X(i) ? i : i[n], e);
|
|
33
|
+
return I(s) || s === e ? I(e[t]) ? r : e[t] : s;
|
|
34
|
+
}, oe = (e) => typeof e == "boolean", ie = (e) => typeof e == "function", T = (e, t, r) => {
|
|
35
35
|
let s = -1;
|
|
36
|
-
const i = ze(t) ? [t] :
|
|
36
|
+
const i = ze(t) ? [t] : ot(t), n = i.length, c = n - 1;
|
|
37
37
|
for (; ++s < n; ) {
|
|
38
|
-
const
|
|
38
|
+
const h = i[s];
|
|
39
39
|
let w = r;
|
|
40
|
-
if (s !==
|
|
41
|
-
const
|
|
42
|
-
w =
|
|
40
|
+
if (s !== c) {
|
|
41
|
+
const V = e[h];
|
|
42
|
+
w = B(V) || Array.isArray(V) ? V : isNaN(+i[s + 1]) ? {} : [];
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
44
|
+
if (h === "__proto__" || h === "constructor" || h === "prototype")
|
|
45
45
|
return;
|
|
46
|
-
e[
|
|
46
|
+
e[h] = w, e = e[h];
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
const
|
|
49
|
+
const yt = {
|
|
50
50
|
BLUR: "blur",
|
|
51
51
|
FOCUS_OUT: "focusout"
|
|
52
|
-
},
|
|
52
|
+
}, ae = {
|
|
53
53
|
onBlur: "onBlur",
|
|
54
54
|
onChange: "onChange",
|
|
55
55
|
onSubmit: "onSubmit",
|
|
56
56
|
onTouched: "onTouched",
|
|
57
57
|
all: "all"
|
|
58
|
-
},
|
|
58
|
+
}, ce = {
|
|
59
59
|
max: "max",
|
|
60
60
|
min: "min",
|
|
61
61
|
maxLength: "maxLength",
|
|
@@ -63,27 +63,27 @@ const ht = {
|
|
|
63
63
|
pattern: "pattern",
|
|
64
64
|
required: "required",
|
|
65
65
|
validate: "validate"
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
var
|
|
66
|
+
}, Gt = Z.createContext(null);
|
|
67
|
+
Gt.displayName = "HookFormContext";
|
|
68
|
+
var Xt = (e, t, r, s = !0) => {
|
|
69
69
|
const i = {
|
|
70
70
|
defaultValues: t._defaultValues
|
|
71
71
|
};
|
|
72
72
|
for (const n in e)
|
|
73
73
|
Object.defineProperty(i, n, {
|
|
74
74
|
get: () => {
|
|
75
|
-
const
|
|
76
|
-
return t._proxyFormState[
|
|
75
|
+
const c = n;
|
|
76
|
+
return t._proxyFormState[c] !== ae.all && (t._proxyFormState[c] = !s || ae.all), e[c];
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
return i;
|
|
80
80
|
};
|
|
81
|
-
const
|
|
82
|
-
var
|
|
83
|
-
function
|
|
84
|
-
if (
|
|
81
|
+
const Qt = typeof window < "u" ? Z.useLayoutEffect : Z.useEffect;
|
|
82
|
+
var ee = (e) => typeof e == "string", Zt = (e, t, r, s, i) => ee(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) => X(e) || !Ct(e);
|
|
83
|
+
function me(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
84
|
+
if (it(e) || it(t))
|
|
85
85
|
return Object.is(e, t);
|
|
86
|
-
if (
|
|
86
|
+
if (be(e) && be(t))
|
|
87
87
|
return Object.is(e.getTime(), t.getTime());
|
|
88
88
|
const s = Object.keys(e), i = Object.keys(t);
|
|
89
89
|
if (s.length !== i.length)
|
|
@@ -92,24 +92,24 @@ function he(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
|
92
92
|
return !0;
|
|
93
93
|
r.add(e), r.add(t);
|
|
94
94
|
for (const n of s) {
|
|
95
|
-
const
|
|
95
|
+
const c = e[n];
|
|
96
96
|
if (!i.includes(n))
|
|
97
97
|
return !1;
|
|
98
98
|
if (n !== "ref") {
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
99
|
+
const h = t[n];
|
|
100
|
+
if (be(c) && be(h) || B(c) && B(h) || Array.isArray(c) && Array.isArray(h) ? !me(c, h, r) : !Object.is(c, h))
|
|
101
101
|
return !1;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
return !0;
|
|
105
105
|
}
|
|
106
|
-
var
|
|
106
|
+
var er = (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
|
+
} : {}, ke = (e) => Array.isArray(e) ? e : [e], gt = () => {
|
|
113
113
|
let e = [];
|
|
114
114
|
return {
|
|
115
115
|
get observers() {
|
|
@@ -129,75 +129,75 @@ var Xt = (e, t, r, s, i) => t ? {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
|
-
function
|
|
132
|
+
function Tt(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
|
|
139
|
-
|
|
137
|
+
if (i && B(i) && n) {
|
|
138
|
+
const c = Tt(i, n);
|
|
139
|
+
B(c) && (r[s] = c);
|
|
140
140
|
} else e[s] && (r[s] = n);
|
|
141
141
|
}
|
|
142
142
|
return r;
|
|
143
143
|
}
|
|
144
|
-
var
|
|
145
|
-
if (!
|
|
144
|
+
var z = (e) => B(e) && !Object.keys(e).length, lt = (e) => e.type === "file", Ye = (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
|
+
}, Lt = (e) => e.type === "select-multiple", ct = (e) => e.type === "radio", tr = (e) => ct(e) || Be(e), rt = (e) => Ye(e) && e.isConnected;
|
|
150
|
+
function rr(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 = I(e) ? s++ : e[t[s++]];
|
|
155
155
|
return e;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function sr(e) {
|
|
158
158
|
for (const t in e)
|
|
159
|
-
if (e.hasOwnProperty(t) && !
|
|
159
|
+
if (e.hasOwnProperty(t) && !I(e[t]))
|
|
160
160
|
return !1;
|
|
161
161
|
return !0;
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
const r = Array.isArray(t) ? t : ze(t) ? [t] :
|
|
165
|
-
return s && delete s[n], i !== 0 && (
|
|
163
|
+
function U(e, t) {
|
|
164
|
+
const r = Array.isArray(t) ? t : ze(t) ? [t] : ot(t), s = r.length === 1 ? e : rr(e, r), i = r.length - 1, n = r[i];
|
|
165
|
+
return s && delete s[n], i !== 0 && (B(s) && z(s) || Array.isArray(s) && sr(s)) && U(e, r.slice(0, -1)), e;
|
|
166
166
|
}
|
|
167
|
-
var
|
|
167
|
+
var ir = (e) => {
|
|
168
168
|
for (const t in e)
|
|
169
|
-
if (
|
|
169
|
+
if (ie(e[t]))
|
|
170
170
|
return !0;
|
|
171
171
|
return !1;
|
|
172
172
|
};
|
|
173
|
-
function
|
|
174
|
-
return Array.isArray(e) ||
|
|
173
|
+
function Mt(e) {
|
|
174
|
+
return Array.isArray(e) || B(e) && !ir(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
|
+
Mt(s) ? (t[r] = Array.isArray(s) ? [] : {}, at(s, t[r])) : I(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 (Mt(i))
|
|
188
|
+
I(t) || it(r[s]) ? r[s] = at(i, Array.isArray(i) ? [] : {}) : Ve(i, X(t) ? {} : t[s], r[s]);
|
|
189
189
|
else {
|
|
190
190
|
const n = t[s];
|
|
191
|
-
r[s] = !
|
|
191
|
+
r[s] = !me(i, n);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
return r;
|
|
195
195
|
}
|
|
196
|
-
const
|
|
196
|
+
const pt = {
|
|
197
197
|
value: !1,
|
|
198
198
|
isValid: !1
|
|
199
|
-
},
|
|
200
|
-
var
|
|
199
|
+
}, bt = { value: !0, isValid: !0 };
|
|
200
|
+
var It = (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 && !I(e[0].attributes.value) ? I(e[0].value) || e[0].value === "" ? bt : { value: e[0].value, isValid: !0 } : bt
|
|
209
|
+
) : pt;
|
|
210
210
|
}
|
|
211
|
-
return
|
|
212
|
-
},
|
|
213
|
-
const
|
|
211
|
+
return pt;
|
|
212
|
+
}, kt = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: s }) => I(e) ? e : t ? e === "" ? NaN : e && +e : r && ee(e) ? new Date(e) : s ? s(e) : e;
|
|
213
|
+
const wt = {
|
|
214
214
|
isValid: !1,
|
|
215
215
|
value: null
|
|
216
216
|
};
|
|
217
|
-
var
|
|
217
|
+
var Ut = (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, wt) : wt;
|
|
221
|
+
function vt(e) {
|
|
222
222
|
const t = e.ref;
|
|
223
|
-
return
|
|
223
|
+
return lt(t) ? t.files : ct(t) ? Ut(e.refs).value : Lt(t) ? [...t.selectedOptions].map(({ value: r }) => r) : Be(t) ? It(e.refs).value : kt(I(t.value) ? e.ref.value : t.value, e);
|
|
224
224
|
}
|
|
225
|
-
var
|
|
225
|
+
var ar = (e, t, r, s) => {
|
|
226
226
|
const i = {};
|
|
227
227
|
for (const n of e) {
|
|
228
|
-
const
|
|
229
|
-
|
|
228
|
+
const c = g(t, n);
|
|
229
|
+
c && T(i, n, c._f);
|
|
230
230
|
}
|
|
231
231
|
return {
|
|
232
232
|
criteriaMode: r,
|
|
@@ -234,33 +234,33 @@ var rr = (e, t, r, s) => {
|
|
|
234
234
|
fields: i,
|
|
235
235
|
shouldUseNativeValidation: s
|
|
236
236
|
};
|
|
237
|
-
}, Ke = (e) => e instanceof RegExp,
|
|
238
|
-
isOnSubmit: !e || e ===
|
|
239
|
-
isOnBlur: e ===
|
|
240
|
-
isOnChange: e ===
|
|
241
|
-
isOnAll: e ===
|
|
242
|
-
isOnTouch: e ===
|
|
237
|
+
}, Ke = (e) => e instanceof RegExp, Me = (e) => I(e) ? e : Ke(e) ? e.source : B(e) ? Ke(e.value) ? e.value.source : e.value : e, Vt = (e) => ({
|
|
238
|
+
isOnSubmit: !e || e === ae.onSubmit,
|
|
239
|
+
isOnBlur: e === ae.onBlur,
|
|
240
|
+
isOnChange: e === ae.onChange,
|
|
241
|
+
isOnAll: e === ae.all,
|
|
242
|
+
isOnTouch: e === ae.onTouched
|
|
243
243
|
});
|
|
244
|
-
const
|
|
245
|
-
var
|
|
246
|
-
const
|
|
244
|
+
const Et = "AsyncFunction";
|
|
245
|
+
var nr = (e) => !!e && !!e.validate && !!(ie(e.validate) && e.validate.constructor.name === Et || B(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === Et)), ur = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Ft = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
|
|
246
|
+
const Ue = (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) {
|
|
250
|
-
const { _f:
|
|
251
|
-
if (
|
|
252
|
-
if (
|
|
250
|
+
const { _f: c, ...h } = n;
|
|
251
|
+
if (c) {
|
|
252
|
+
if (c.refs && c.refs[0] && t(c.refs[0], i) && !s)
|
|
253
253
|
return !0;
|
|
254
|
-
if (
|
|
254
|
+
if (c.ref && t(c.ref, c.name) && !s)
|
|
255
255
|
return !0;
|
|
256
|
-
if (
|
|
256
|
+
if (Ue(h, t))
|
|
257
257
|
break;
|
|
258
|
-
} else if (
|
|
258
|
+
} else if (B(h) && Ue(h, t))
|
|
259
259
|
break;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
};
|
|
263
|
-
function
|
|
263
|
+
function At(e, t, r) {
|
|
264
264
|
const s = g(e, r);
|
|
265
265
|
if (s || ze(r))
|
|
266
266
|
return {
|
|
@@ -269,18 +269,18 @@ function Vt(e, t, r) {
|
|
|
269
269
|
};
|
|
270
270
|
const i = r.split(".");
|
|
271
271
|
for (; i.length; ) {
|
|
272
|
-
const n = i.join("."),
|
|
273
|
-
if (
|
|
272
|
+
const n = i.join("."), c = g(t, n), h = g(e, n);
|
|
273
|
+
if (c && !Array.isArray(c) && r !== n)
|
|
274
274
|
return { name: r };
|
|
275
|
-
if (
|
|
275
|
+
if (h && h.type)
|
|
276
276
|
return {
|
|
277
277
|
name: n,
|
|
278
|
-
error:
|
|
278
|
+
error: h
|
|
279
279
|
};
|
|
280
|
-
if (
|
|
280
|
+
if (h && h.root && h.root.type)
|
|
281
281
|
return {
|
|
282
282
|
name: `${n}.root`,
|
|
283
|
-
error:
|
|
283
|
+
error: h.root
|
|
284
284
|
};
|
|
285
285
|
i.pop();
|
|
286
286
|
}
|
|
@@ -288,120 +288,120 @@ function Vt(e, t, r) {
|
|
|
288
288
|
name: r
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
var
|
|
291
|
+
var or = (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 z(n) || Object.keys(n).length >= Object.keys(t).length || Object.keys(n).find((c) => t[c] === (!s || ae.all));
|
|
295
|
+
}, lr = (e, t, r) => !e || !t || e === t || ke(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), cr = (e, t, r, s, i) => i.isOnAll ? !1 : !r && i.isOnTouch ? !(t || e) : (r ? s.isOnBlur : i.isOnBlur) ? !e : (r ? s.isOnChange : i.isOnChange) ? e : !0, dr = (e, t) => !ut(g(e, t)).length && U(e, t), fr = (e, t, r) => {
|
|
296
|
+
const s = ke(g(e, r));
|
|
297
|
+
return T(s, "root", t[r]), T(e, r, s), e;
|
|
298
298
|
};
|
|
299
|
-
function
|
|
300
|
-
if (
|
|
299
|
+
function xt(e, t, r = "validate") {
|
|
300
|
+
if (ee(e) || Array.isArray(e) && e.every(ee) || oe(e) && !e)
|
|
301
301
|
return {
|
|
302
302
|
type: r,
|
|
303
|
-
message:
|
|
303
|
+
message: ee(e) ? e : "",
|
|
304
304
|
ref: t
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
|
-
var
|
|
307
|
+
var ve = (e) => B(e) && !Ke(e) ? e : {
|
|
308
308
|
value: e,
|
|
309
309
|
message: ""
|
|
310
|
-
},
|
|
311
|
-
const { ref:
|
|
312
|
-
if (!
|
|
310
|
+
}, _t = async (e, t, r, s, i, n) => {
|
|
311
|
+
const { ref: c, refs: h, required: w, maxLength: V, minLength: N, min: D, max: A, pattern: v, validate: y, name: P, valueAsNumber: H, mount: Q } = e._f, _ = g(r, P);
|
|
312
|
+
if (!Q || t.has(P))
|
|
313
313
|
return {};
|
|
314
|
-
const
|
|
315
|
-
i &&
|
|
316
|
-
},
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
type:
|
|
320
|
-
message:
|
|
321
|
-
ref:
|
|
322
|
-
...
|
|
314
|
+
const te = h ? h[0] : c, re = (E) => {
|
|
315
|
+
i && te.reportValidity && (te.setCustomValidity(oe(E) ? "" : E || ""), te.reportValidity());
|
|
316
|
+
}, S = {}, de = ct(c), ge = Be(c), ne = de || ge, fe = (H || lt(c)) && I(c.value) && I(_) || Ye(c) && c.value === "" || _ === "" || Array.isArray(_) && !_.length, Y = er.bind(null, P, s, S), le = (E, x, L, O = ce.maxLength, W = ce.minLength) => {
|
|
317
|
+
const K = E ? x : L;
|
|
318
|
+
S[P] = {
|
|
319
|
+
type: E ? O : W,
|
|
320
|
+
message: K,
|
|
321
|
+
ref: c,
|
|
322
|
+
...Y(E ? O : W, K)
|
|
323
323
|
};
|
|
324
324
|
};
|
|
325
|
-
if (n ? !Array.isArray(
|
|
326
|
-
const { value:
|
|
327
|
-
if (
|
|
328
|
-
type:
|
|
325
|
+
if (n ? !Array.isArray(_) || !_.length : w && (!ne && (fe || X(_)) || oe(_) && !_ || ge && !It(h).isValid || de && !Ut(h).isValid)) {
|
|
326
|
+
const { value: E, message: x } = ee(w) ? { value: !!w, message: w } : ve(w);
|
|
327
|
+
if (E && (S[P] = {
|
|
328
|
+
type: ce.required,
|
|
329
329
|
message: x,
|
|
330
|
-
ref:
|
|
331
|
-
...
|
|
330
|
+
ref: te,
|
|
331
|
+
...Y(ce.required, x)
|
|
332
332
|
}, !s))
|
|
333
|
-
return
|
|
333
|
+
return re(x), S;
|
|
334
334
|
}
|
|
335
|
-
if (!
|
|
336
|
-
let
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
339
|
-
const
|
|
340
|
-
|
|
335
|
+
if (!fe && (!X(D) || !X(A))) {
|
|
336
|
+
let E, x;
|
|
337
|
+
const L = ve(A), O = ve(D);
|
|
338
|
+
if (!X(_) && !isNaN(_)) {
|
|
339
|
+
const W = c.valueAsNumber || _ && +_;
|
|
340
|
+
X(L.value) || (E = W > L.value), X(O.value) || (x = W < O.value);
|
|
341
341
|
} else {
|
|
342
|
-
const
|
|
343
|
-
|
|
342
|
+
const W = c.valueAsDate || new Date(_), K = (J) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + J), ue = c.type == "time", he = c.type == "week";
|
|
343
|
+
ee(L.value) && _ && (E = ue ? K(_) > K(L.value) : he ? _ > L.value : W > new Date(L.value)), ee(O.value) && _ && (x = ue ? K(_) < K(O.value) : he ? _ < O.value : W < new Date(O.value));
|
|
344
344
|
}
|
|
345
|
-
if ((
|
|
346
|
-
return
|
|
345
|
+
if ((E || x) && (le(!!E, L.message, O.message, ce.max, ce.min), !s))
|
|
346
|
+
return re(S[P].message), S;
|
|
347
347
|
}
|
|
348
|
-
if ((
|
|
349
|
-
const
|
|
350
|
-
if ((
|
|
351
|
-
return
|
|
348
|
+
if ((V || N) && !fe && (ee(_) || n && Array.isArray(_))) {
|
|
349
|
+
const E = ve(V), x = ve(N), L = !X(E.value) && _.length > +E.value, O = !X(x.value) && _.length < +x.value;
|
|
350
|
+
if ((L || O) && (le(L, E.message, x.message), !s))
|
|
351
|
+
return re(S[P].message), S;
|
|
352
352
|
}
|
|
353
|
-
if (
|
|
354
|
-
const { value:
|
|
355
|
-
if (Ke(
|
|
356
|
-
type:
|
|
353
|
+
if (v && !fe && ee(_)) {
|
|
354
|
+
const { value: E, message: x } = ve(v);
|
|
355
|
+
if (Ke(E) && !_.match(E) && (S[P] = {
|
|
356
|
+
type: ce.pattern,
|
|
357
357
|
message: x,
|
|
358
|
-
ref:
|
|
359
|
-
...
|
|
358
|
+
ref: c,
|
|
359
|
+
...Y(ce.pattern, x)
|
|
360
360
|
}, !s))
|
|
361
|
-
return
|
|
361
|
+
return re(x), S;
|
|
362
362
|
}
|
|
363
|
-
if (
|
|
364
|
-
if (
|
|
365
|
-
const
|
|
366
|
-
if (x && (
|
|
363
|
+
if (y) {
|
|
364
|
+
if (ie(y)) {
|
|
365
|
+
const E = await y(_, r), x = xt(E, te);
|
|
366
|
+
if (x && (S[P] = {
|
|
367
367
|
...x,
|
|
368
|
-
...
|
|
368
|
+
...Y(ce.validate, x.message)
|
|
369
369
|
}, !s))
|
|
370
|
-
return
|
|
371
|
-
} else if (
|
|
372
|
-
let
|
|
373
|
-
for (const x in
|
|
374
|
-
if (!
|
|
370
|
+
return re(x.message), S;
|
|
371
|
+
} else if (B(y)) {
|
|
372
|
+
let E = {};
|
|
373
|
+
for (const x in y) {
|
|
374
|
+
if (!z(E) && !s)
|
|
375
375
|
break;
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
...
|
|
379
|
-
...
|
|
380
|
-
},
|
|
376
|
+
const L = xt(await y[x](_, r), te, x);
|
|
377
|
+
L && (E = {
|
|
378
|
+
...L,
|
|
379
|
+
...Y(x, L.message)
|
|
380
|
+
}, re(L.message), s && (S[P] = E));
|
|
381
381
|
}
|
|
382
|
-
if (!
|
|
383
|
-
ref:
|
|
384
|
-
...
|
|
382
|
+
if (!z(E) && (S[P] = {
|
|
383
|
+
ref: te,
|
|
384
|
+
...E
|
|
385
385
|
}, !s))
|
|
386
|
-
return
|
|
386
|
+
return S;
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
return
|
|
389
|
+
return re(!0), S;
|
|
390
390
|
};
|
|
391
|
-
const
|
|
392
|
-
mode:
|
|
393
|
-
reValidateMode:
|
|
391
|
+
const hr = {
|
|
392
|
+
mode: ae.onSubmit,
|
|
393
|
+
reValidateMode: ae.onChange,
|
|
394
394
|
shouldFocusError: !0
|
|
395
395
|
};
|
|
396
|
-
function
|
|
396
|
+
function mr(e = {}) {
|
|
397
397
|
let t = {
|
|
398
|
-
...
|
|
398
|
+
...hr,
|
|
399
399
|
...e
|
|
400
400
|
}, r = {
|
|
401
401
|
submitCount: 0,
|
|
402
402
|
isDirty: !1,
|
|
403
403
|
isReady: !1,
|
|
404
|
-
isLoading:
|
|
404
|
+
isLoading: ie(t.defaultValues),
|
|
405
405
|
isValidating: !1,
|
|
406
406
|
isSubmitted: !1,
|
|
407
407
|
isSubmitting: !1,
|
|
@@ -412,19 +412,19 @@ function dr(e = {}) {
|
|
|
412
412
|
validatingFields: {},
|
|
413
413
|
errors: t.errors || {},
|
|
414
414
|
disabled: t.disabled || !1
|
|
415
|
-
}, s = {}, i =
|
|
415
|
+
}, s = {}, i = B(t.defaultValues) || B(t.values) ? $(t.defaultValues || t.values) || {} : {}, n = t.shouldUnregister ? {} : $(i), c = {
|
|
416
416
|
action: !1,
|
|
417
417
|
mount: !1,
|
|
418
418
|
watch: !1,
|
|
419
419
|
keepIsValid: !1
|
|
420
|
-
},
|
|
420
|
+
}, h = {
|
|
421
421
|
mount: /* @__PURE__ */ new Set(),
|
|
422
422
|
disabled: /* @__PURE__ */ new Set(),
|
|
423
423
|
unMount: /* @__PURE__ */ new Set(),
|
|
424
424
|
array: /* @__PURE__ */ new Set(),
|
|
425
425
|
watch: /* @__PURE__ */ new Set()
|
|
426
|
-
}, w,
|
|
427
|
-
const
|
|
426
|
+
}, w, V = 0;
|
|
427
|
+
const N = {
|
|
428
428
|
isDirty: !1,
|
|
429
429
|
dirtyFields: !1,
|
|
430
430
|
validatingFields: !1,
|
|
@@ -433,467 +433,467 @@ function dr(e = {}) {
|
|
|
433
433
|
isValid: !1,
|
|
434
434
|
errors: !1
|
|
435
435
|
}, D = {
|
|
436
|
-
...
|
|
436
|
+
...N
|
|
437
437
|
};
|
|
438
|
-
let
|
|
438
|
+
let A = {
|
|
439
439
|
...D
|
|
440
440
|
};
|
|
441
|
-
const
|
|
442
|
-
array:
|
|
443
|
-
state:
|
|
444
|
-
},
|
|
445
|
-
clearTimeout(
|
|
446
|
-
},
|
|
447
|
-
if (!
|
|
448
|
-
let
|
|
449
|
-
t.resolver ? (
|
|
450
|
-
isValid:
|
|
441
|
+
const v = {
|
|
442
|
+
array: gt(),
|
|
443
|
+
state: gt()
|
|
444
|
+
}, y = t.criteriaMode === ae.all, P = (a) => (u) => {
|
|
445
|
+
clearTimeout(V), V = setTimeout(a, u);
|
|
446
|
+
}, H = async (a) => {
|
|
447
|
+
if (!c.keepIsValid && !t.disabled && (D.isValid || A.isValid || a)) {
|
|
448
|
+
let u;
|
|
449
|
+
t.resolver ? (u = z((await ne()).errors), Q()) : u = await Y(s, !0), u !== r.isValid && v.state.next({
|
|
450
|
+
isValid: u
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
|
-
},
|
|
454
|
-
!t.disabled && (D.isValidating || D.validatingFields ||
|
|
455
|
-
|
|
456
|
-
}),
|
|
453
|
+
}, Q = (a, u) => {
|
|
454
|
+
!t.disabled && (D.isValidating || D.validatingFields || A.isValidating || A.validatingFields) && ((a || Array.from(h.mount)).forEach((o) => {
|
|
455
|
+
o && (u ? T(r.validatingFields, o, u) : U(r.validatingFields, o));
|
|
456
|
+
}), v.state.next({
|
|
457
457
|
validatingFields: r.validatingFields,
|
|
458
|
-
isValidating: !
|
|
458
|
+
isValidating: !z(r.validatingFields)
|
|
459
459
|
}));
|
|
460
|
-
},
|
|
461
|
-
if (
|
|
462
|
-
if (
|
|
463
|
-
const
|
|
464
|
-
|
|
460
|
+
}, _ = (a, u = [], o, d, f = !0, l = !0) => {
|
|
461
|
+
if (d && o && !t.disabled) {
|
|
462
|
+
if (c.action = !0, l && Array.isArray(g(s, a))) {
|
|
463
|
+
const m = o(g(s, a), d.argA, d.argB);
|
|
464
|
+
f && T(s, a, m);
|
|
465
465
|
}
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
|
|
466
|
+
if (l && Array.isArray(g(r.errors, a))) {
|
|
467
|
+
const m = o(g(r.errors, a), d.argA, d.argB);
|
|
468
|
+
f && T(r.errors, a, m), dr(r.errors, a);
|
|
469
469
|
}
|
|
470
|
-
if ((D.touchedFields ||
|
|
471
|
-
const
|
|
472
|
-
|
|
470
|
+
if ((D.touchedFields || A.touchedFields) && l && Array.isArray(g(r.touchedFields, a))) {
|
|
471
|
+
const m = o(g(r.touchedFields, a), d.argA, d.argB);
|
|
472
|
+
f && T(r.touchedFields, a, m);
|
|
473
473
|
}
|
|
474
|
-
(D.dirtyFields ||
|
|
474
|
+
(D.dirtyFields || A.dirtyFields) && (r.dirtyFields = Ve(i, n)), v.state.next({
|
|
475
475
|
name: a,
|
|
476
|
-
isDirty:
|
|
476
|
+
isDirty: E(a, u),
|
|
477
477
|
dirtyFields: r.dirtyFields,
|
|
478
478
|
errors: r.errors,
|
|
479
479
|
isValid: r.isValid
|
|
480
480
|
});
|
|
481
481
|
} else
|
|
482
|
-
|
|
483
|
-
},
|
|
484
|
-
|
|
482
|
+
T(n, a, u);
|
|
483
|
+
}, te = (a, u) => {
|
|
484
|
+
T(r.errors, a, u), v.state.next({
|
|
485
485
|
errors: r.errors
|
|
486
486
|
});
|
|
487
|
-
},
|
|
488
|
-
r.errors = a,
|
|
487
|
+
}, re = (a) => {
|
|
488
|
+
r.errors = a, v.state.next({
|
|
489
489
|
errors: r.errors,
|
|
490
490
|
isValid: !1
|
|
491
491
|
});
|
|
492
|
-
},
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
495
|
-
const
|
|
496
|
-
|
|
492
|
+
}, S = (a, u, o, d) => {
|
|
493
|
+
const f = g(s, a);
|
|
494
|
+
if (f) {
|
|
495
|
+
const l = g(n, a, I(o) ? g(i, a) : o);
|
|
496
|
+
I(l) || d && d.defaultChecked || u ? T(n, a, u ? l : vt(f._f)) : O(a, l), c.mount && !c.action && H();
|
|
497
497
|
}
|
|
498
|
-
},
|
|
499
|
-
let
|
|
498
|
+
}, de = (a, u, o, d, f) => {
|
|
499
|
+
let l = !1, m = !1;
|
|
500
500
|
const p = {
|
|
501
501
|
name: a
|
|
502
502
|
};
|
|
503
503
|
if (!t.disabled) {
|
|
504
|
-
if (!
|
|
505
|
-
(D.isDirty ||
|
|
506
|
-
const
|
|
507
|
-
|
|
504
|
+
if (!o || d) {
|
|
505
|
+
(D.isDirty || A.isDirty) && (m = r.isDirty, r.isDirty = p.isDirty = E(), l = m !== p.isDirty);
|
|
506
|
+
const b = me(g(i, a), u);
|
|
507
|
+
m = !!g(r.dirtyFields, a), b ? U(r.dirtyFields, a) : T(r.dirtyFields, a, !0), p.dirtyFields = r.dirtyFields, l = l || (D.dirtyFields || A.dirtyFields) && m !== !b;
|
|
508
508
|
}
|
|
509
|
-
if (
|
|
510
|
-
const
|
|
511
|
-
|
|
509
|
+
if (o) {
|
|
510
|
+
const b = g(r.touchedFields, a);
|
|
511
|
+
b || (T(r.touchedFields, a, o), p.touchedFields = r.touchedFields, l = l || (D.touchedFields || A.touchedFields) && b !== o);
|
|
512
512
|
}
|
|
513
|
-
|
|
513
|
+
l && f && v.state.next(p);
|
|
514
514
|
}
|
|
515
|
-
return
|
|
516
|
-
},
|
|
517
|
-
const
|
|
518
|
-
if (t.delayError &&
|
|
519
|
-
const
|
|
520
|
-
...
|
|
521
|
-
...
|
|
515
|
+
return l ? p : {};
|
|
516
|
+
}, ge = (a, u, o, d) => {
|
|
517
|
+
const f = g(r.errors, a), l = (D.isValid || A.isValid) && oe(u) && r.isValid !== u;
|
|
518
|
+
if (t.delayError && o ? (w = P(() => te(a, o)), w(t.delayError)) : (clearTimeout(V), w = null, o ? T(r.errors, a, o) : U(r.errors, a)), (o ? !me(f, o) : f) || !z(d) || l) {
|
|
519
|
+
const m = {
|
|
520
|
+
...d,
|
|
521
|
+
...l && oe(u) ? { isValid: u } : {},
|
|
522
522
|
errors: r.errors,
|
|
523
523
|
name: a
|
|
524
524
|
};
|
|
525
525
|
r = {
|
|
526
526
|
...r,
|
|
527
|
-
...
|
|
528
|
-
},
|
|
527
|
+
...m
|
|
528
|
+
}, v.state.next(m);
|
|
529
529
|
}
|
|
530
|
-
},
|
|
531
|
-
const { errors:
|
|
532
|
-
if (
|
|
533
|
-
for (const
|
|
534
|
-
const
|
|
535
|
-
|
|
530
|
+
}, ne = async (a) => (Q(a, !0), await t.resolver(n, t.context, ar(a || h.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), fe = async (a) => {
|
|
531
|
+
const { errors: u } = await ne(a);
|
|
532
|
+
if (Q(a), a)
|
|
533
|
+
for (const o of a) {
|
|
534
|
+
const d = g(u, o);
|
|
535
|
+
d ? T(r.errors, o, d) : U(r.errors, o);
|
|
536
536
|
}
|
|
537
537
|
else
|
|
538
|
-
r.errors =
|
|
539
|
-
return
|
|
540
|
-
},
|
|
538
|
+
r.errors = u;
|
|
539
|
+
return u;
|
|
540
|
+
}, Y = async (a, u, o = {
|
|
541
541
|
valid: !0
|
|
542
542
|
}) => {
|
|
543
|
-
for (const
|
|
544
|
-
const
|
|
545
|
-
if (
|
|
546
|
-
const { _f:
|
|
547
|
-
if (
|
|
548
|
-
const p =
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
543
|
+
for (const d in a) {
|
|
544
|
+
const f = a[d];
|
|
545
|
+
if (f) {
|
|
546
|
+
const { _f: l, ...m } = f;
|
|
547
|
+
if (l) {
|
|
548
|
+
const p = h.array.has(l.name), b = f._f && nr(f._f);
|
|
549
|
+
b && D.validatingFields && Q([l.name], !0);
|
|
550
|
+
const R = await _t(f, h.disabled, n, y, t.shouldUseNativeValidation && !u, p);
|
|
551
|
+
if (b && D.validatingFields && Q([l.name]), R[l.name] && (o.valid = !1, u || e.shouldUseNativeValidation))
|
|
552
552
|
break;
|
|
553
|
-
!
|
|
553
|
+
!u && (g(R, l.name) ? p ? fr(r.errors, R, l.name) : T(r.errors, l.name, R[l.name]) : U(r.errors, l.name));
|
|
554
554
|
}
|
|
555
|
-
!
|
|
555
|
+
!z(m) && await Y(m, u, o);
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
return
|
|
559
|
-
},
|
|
560
|
-
for (const a of
|
|
561
|
-
const
|
|
562
|
-
|
|
558
|
+
return o.valid;
|
|
559
|
+
}, le = () => {
|
|
560
|
+
for (const a of h.unMount) {
|
|
561
|
+
const u = g(s, a);
|
|
562
|
+
u && (u._f.refs ? u._f.refs.every((o) => !rt(o)) : !rt(u._f.ref)) && De(a);
|
|
563
563
|
}
|
|
564
|
-
|
|
565
|
-
},
|
|
566
|
-
...
|
|
567
|
-
},
|
|
568
|
-
const
|
|
569
|
-
let
|
|
570
|
-
if (
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
(!
|
|
574
|
-
}) :
|
|
564
|
+
h.unMount = /* @__PURE__ */ new Set();
|
|
565
|
+
}, E = (a, u) => !t.disabled && (a && u && T(n, a, u), !me(Ae(), i)), x = (a, u, o) => Zt(a, h, {
|
|
566
|
+
...c.mount ? n : I(u) ? i : ee(a) ? { [a]: u } : u
|
|
567
|
+
}, o, u), L = (a) => ut(g(c.mount ? n : i, a, t.shouldUnregister ? g(i, a, []) : [])), O = (a, u, o = {}) => {
|
|
568
|
+
const d = g(s, a);
|
|
569
|
+
let f = u;
|
|
570
|
+
if (d) {
|
|
571
|
+
const l = d._f;
|
|
572
|
+
l && (!l.disabled && T(n, a, kt(u, l)), f = Ye(l.ref) && X(u) ? "" : u, Lt(l.ref) ? [...l.ref.options].forEach((m) => m.selected = f.includes(m.value)) : l.refs ? Be(l.ref) ? l.refs.forEach((m) => {
|
|
573
|
+
(!m.defaultChecked || !m.disabled) && (Array.isArray(f) ? m.checked = !!f.find((p) => p === m.value) : m.checked = f === m.value || !!f);
|
|
574
|
+
}) : l.refs.forEach((m) => m.checked = m.value === f) : lt(l.ref) ? l.ref.value = "" : (l.ref.value = f, l.ref.type || v.state.next({
|
|
575
575
|
name: a,
|
|
576
|
-
values:
|
|
576
|
+
values: $(n)
|
|
577
577
|
})));
|
|
578
578
|
}
|
|
579
|
-
(
|
|
580
|
-
},
|
|
581
|
-
for (const
|
|
582
|
-
if (!
|
|
579
|
+
(o.shouldDirty || o.shouldTouch) && de(a, f, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && J(a);
|
|
580
|
+
}, W = (a, u, o) => {
|
|
581
|
+
for (const d in u) {
|
|
582
|
+
if (!u.hasOwnProperty(d))
|
|
583
583
|
return;
|
|
584
|
-
const
|
|
585
|
-
(
|
|
584
|
+
const f = u[d], l = a + "." + d, m = g(s, l);
|
|
585
|
+
(h.array.has(a) || B(f) || m && !m._f) && !be(f) ? W(l, f, o) : O(l, f, o);
|
|
586
586
|
}
|
|
587
|
-
},
|
|
588
|
-
const
|
|
589
|
-
|
|
587
|
+
}, K = (a, u, o = {}) => {
|
|
588
|
+
const d = g(s, a), f = h.array.has(a), l = $(u);
|
|
589
|
+
T(n, a, l), f ? (v.array.next({
|
|
590
590
|
name: a,
|
|
591
|
-
values:
|
|
592
|
-
}), (D.isDirty || D.dirtyFields ||
|
|
591
|
+
values: $(n)
|
|
592
|
+
}), (D.isDirty || D.dirtyFields || A.isDirty || A.dirtyFields) && o.shouldDirty && v.state.next({
|
|
593
593
|
name: a,
|
|
594
|
-
dirtyFields:
|
|
595
|
-
isDirty:
|
|
596
|
-
})) :
|
|
594
|
+
dirtyFields: Ve(i, n),
|
|
595
|
+
isDirty: E(a, l)
|
|
596
|
+
})) : d && !d._f && !X(l) ? W(a, l, o) : O(a, l, o), Ft(a, h) ? v.state.next({
|
|
597
597
|
...r,
|
|
598
598
|
name: a,
|
|
599
|
-
values:
|
|
600
|
-
}) :
|
|
601
|
-
name:
|
|
602
|
-
values:
|
|
599
|
+
values: $(n)
|
|
600
|
+
}) : v.state.next({
|
|
601
|
+
name: c.mount ? a : void 0,
|
|
602
|
+
values: $(n)
|
|
603
603
|
});
|
|
604
|
-
},
|
|
605
|
-
|
|
606
|
-
const
|
|
607
|
-
let
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
},
|
|
611
|
-
if (
|
|
612
|
-
let
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
617
|
-
name:
|
|
604
|
+
}, ue = async (a) => {
|
|
605
|
+
c.mount = !0;
|
|
606
|
+
const u = a.target;
|
|
607
|
+
let o = u.name, d = !0;
|
|
608
|
+
const f = g(s, o), l = (b) => {
|
|
609
|
+
d = Number.isNaN(b) || be(b) && isNaN(b.getTime()) || me(b, g(n, o, b));
|
|
610
|
+
}, m = Vt(t.mode), p = Vt(t.reValidateMode);
|
|
611
|
+
if (f) {
|
|
612
|
+
let b, R;
|
|
613
|
+
const M = u.type ? vt(f._f) : Yt(a), C = a.type === yt.BLUR || a.type === yt.FOCUS_OUT, q = !ur(f._f) && !t.resolver && !g(r.errors, o) && !f._f.deps || cr(C, g(r.touchedFields, o), r.isSubmitted, p, m), j = Ft(o, h, C);
|
|
614
|
+
T(n, o, M), C ? (!u || !u.readOnly) && (f._f.onBlur && f._f.onBlur(a), w && w(0)) : f._f.onChange && f._f.onChange(a);
|
|
615
|
+
const k = de(o, M, C), G = !z(k) || j;
|
|
616
|
+
if (!C && v.state.next({
|
|
617
|
+
name: o,
|
|
618
618
|
type: a.type,
|
|
619
|
-
values:
|
|
620
|
-
}),
|
|
621
|
-
return (D.isValid ||
|
|
622
|
-
if (
|
|
623
|
-
const { errors:
|
|
624
|
-
if (
|
|
625
|
-
const
|
|
626
|
-
|
|
619
|
+
values: $(n)
|
|
620
|
+
}), q)
|
|
621
|
+
return (D.isValid || A.isValid) && (t.mode === "onBlur" ? C && H() : C || H()), G && v.state.next({ name: o, ...j ? {} : k });
|
|
622
|
+
if (!C && j && v.state.next({ ...r }), t.resolver) {
|
|
623
|
+
const { errors: Ce } = await ne([o]);
|
|
624
|
+
if (Q([o]), l(M), d) {
|
|
625
|
+
const ft = At(r.errors, s, o), et = At(Ce, s, ft.name || o);
|
|
626
|
+
b = et.error, o = et.name, R = z(Ce);
|
|
627
627
|
}
|
|
628
628
|
} else
|
|
629
|
-
|
|
630
|
-
|
|
629
|
+
Q([o], !0), b = (await _t(f, h.disabled, n, y, t.shouldUseNativeValidation))[o], Q([o]), l(M), d && (b ? R = !1 : (D.isValid || A.isValid) && (R = await Y(s, !0)));
|
|
630
|
+
d && (f._f.deps && (!Array.isArray(f._f.deps) || f._f.deps.length > 0) && J(f._f.deps), ge(o, R, b, k));
|
|
631
631
|
}
|
|
632
|
-
},
|
|
633
|
-
if (g(r.errors,
|
|
632
|
+
}, he = (a, u) => {
|
|
633
|
+
if (g(r.errors, u) && a.focus)
|
|
634
634
|
return a.focus(), 1;
|
|
635
|
-
},
|
|
636
|
-
let
|
|
637
|
-
const
|
|
635
|
+
}, J = async (a, u = {}) => {
|
|
636
|
+
let o, d;
|
|
637
|
+
const f = ke(a);
|
|
638
638
|
if (t.resolver) {
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
} else a ? (
|
|
642
|
-
const
|
|
643
|
-
return await
|
|
644
|
-
}))).every(Boolean), !(!
|
|
645
|
-
return
|
|
646
|
-
...!
|
|
647
|
-
...t.resolver || !a ? { isValid:
|
|
639
|
+
const l = await fe(I(a) ? a : f);
|
|
640
|
+
o = z(l), d = a ? !f.some((m) => g(l, m)) : o;
|
|
641
|
+
} else a ? (d = (await Promise.all(f.map(async (l) => {
|
|
642
|
+
const m = g(s, l);
|
|
643
|
+
return await Y(m && m._f ? { [l]: m } : m);
|
|
644
|
+
}))).every(Boolean), !(!d && !r.isValid) && H()) : d = o = await Y(s);
|
|
645
|
+
return v.state.next({
|
|
646
|
+
...!ee(a) || (D.isValid || A.isValid) && o !== r.isValid ? {} : { name: a },
|
|
647
|
+
...t.resolver || !a ? { isValid: o } : {},
|
|
648
648
|
errors: r.errors
|
|
649
|
-
}),
|
|
650
|
-
},
|
|
651
|
-
let
|
|
652
|
-
...
|
|
649
|
+
}), u.shouldFocus && !d && Ue(s, he, a ? f : h.mount), d;
|
|
650
|
+
}, Ae = (a, u) => {
|
|
651
|
+
let o = {
|
|
652
|
+
...c.mount ? n : i
|
|
653
653
|
};
|
|
654
|
-
return
|
|
655
|
-
},
|
|
656
|
-
invalid: !!g((
|
|
657
|
-
isDirty: !!g((
|
|
658
|
-
error: g((
|
|
654
|
+
return u && (o = Tt(u.dirtyFields ? r.dirtyFields : r.touchedFields, o)), I(a) ? o : ee(a) ? g(o, a) : a.map((d) => g(o, d));
|
|
655
|
+
}, Pe = (a, u) => ({
|
|
656
|
+
invalid: !!g((u || r).errors, a),
|
|
657
|
+
isDirty: !!g((u || r).dirtyFields, a),
|
|
658
|
+
error: g((u || r).errors, a),
|
|
659
659
|
isValidating: !!g(r.validatingFields, a),
|
|
660
|
-
isTouched: !!g((
|
|
661
|
-
}),
|
|
662
|
-
a &&
|
|
660
|
+
isTouched: !!g((u || r).touchedFields, a)
|
|
661
|
+
}), Je = (a) => {
|
|
662
|
+
a && ke(a).forEach((u) => U(r.errors, u)), v.state.next({
|
|
663
663
|
errors: a ? r.errors : {}
|
|
664
664
|
});
|
|
665
|
-
},
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
...
|
|
669
|
-
...
|
|
670
|
-
ref:
|
|
671
|
-
}),
|
|
665
|
+
}, F = (a, u, o) => {
|
|
666
|
+
const d = (g(s, a, { _f: {} })._f || {}).ref, f = g(r.errors, a) || {}, { ref: l, message: m, type: p, ...b } = f;
|
|
667
|
+
T(r.errors, a, {
|
|
668
|
+
...b,
|
|
669
|
+
...u,
|
|
670
|
+
ref: d
|
|
671
|
+
}), v.state.next({
|
|
672
672
|
name: a,
|
|
673
673
|
errors: r.errors,
|
|
674
674
|
isValid: !1
|
|
675
|
-
}),
|
|
676
|
-
},
|
|
677
|
-
next: (
|
|
678
|
-
}) : x(a,
|
|
679
|
-
next: (
|
|
680
|
-
|
|
675
|
+
}), o && o.shouldFocus && d && d.focus && d.focus();
|
|
676
|
+
}, xe = (a, u) => ie(a) ? v.state.subscribe({
|
|
677
|
+
next: (o) => "values" in o && a(x(void 0, u), o)
|
|
678
|
+
}) : x(a, u, !0), _e = (a) => v.state.subscribe({
|
|
679
|
+
next: (u) => {
|
|
680
|
+
lr(a.name, u.name, a.exact) && or(u, a.formState || D, Oe, a.reRenderRoot) && a.callback({
|
|
681
681
|
values: { ...n },
|
|
682
682
|
...r,
|
|
683
|
-
...
|
|
683
|
+
...u,
|
|
684
684
|
defaultValues: i
|
|
685
685
|
});
|
|
686
686
|
}
|
|
687
|
-
}).unsubscribe,
|
|
688
|
-
...
|
|
687
|
+
}).unsubscribe, Ge = (a) => (c.mount = !0, A = {
|
|
688
|
+
...A,
|
|
689
689
|
...a.formState
|
|
690
|
-
},
|
|
690
|
+
}, _e({
|
|
691
691
|
...a,
|
|
692
692
|
formState: {
|
|
693
|
-
...
|
|
693
|
+
...N,
|
|
694
694
|
...a.formState
|
|
695
695
|
}
|
|
696
|
-
})),
|
|
697
|
-
for (const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
values:
|
|
701
|
-
}),
|
|
696
|
+
})), De = (a, u = {}) => {
|
|
697
|
+
for (const o of a ? ke(a) : h.mount)
|
|
698
|
+
h.mount.delete(o), h.array.delete(o), u.keepValue || (U(s, o), U(n, o)), !u.keepError && U(r.errors, o), !u.keepDirty && U(r.dirtyFields, o), !u.keepTouched && U(r.touchedFields, o), !u.keepIsValidating && U(r.validatingFields, o), !t.shouldUnregister && !u.keepDefaultValue && U(i, o);
|
|
699
|
+
v.state.next({
|
|
700
|
+
values: $(n)
|
|
701
|
+
}), v.state.next({
|
|
702
702
|
...r,
|
|
703
|
-
...
|
|
704
|
-
}), !
|
|
705
|
-
},
|
|
706
|
-
(
|
|
707
|
-
},
|
|
708
|
-
let
|
|
709
|
-
const
|
|
710
|
-
return
|
|
711
|
-
...
|
|
703
|
+
...u.keepDirty ? { isDirty: E() } : {}
|
|
704
|
+
}), !u.keepIsValid && H();
|
|
705
|
+
}, qe = ({ disabled: a, name: u }) => {
|
|
706
|
+
(oe(a) && c.mount || a || h.disabled.has(u)) && (a ? h.disabled.add(u) : h.disabled.delete(u));
|
|
707
|
+
}, Se = (a, u = {}) => {
|
|
708
|
+
let o = g(s, a);
|
|
709
|
+
const d = oe(u.disabled) || oe(t.disabled);
|
|
710
|
+
return T(s, a, {
|
|
711
|
+
...o || {},
|
|
712
712
|
_f: {
|
|
713
|
-
...
|
|
713
|
+
...o && o._f ? o._f : { ref: { name: a } },
|
|
714
714
|
name: a,
|
|
715
715
|
mount: !0,
|
|
716
|
-
...
|
|
716
|
+
...u
|
|
717
717
|
}
|
|
718
|
-
}),
|
|
719
|
-
disabled:
|
|
718
|
+
}), h.mount.add(a), o ? qe({
|
|
719
|
+
disabled: oe(u.disabled) ? u.disabled : t.disabled,
|
|
720
720
|
name: a
|
|
721
|
-
}) :
|
|
722
|
-
...
|
|
721
|
+
}) : S(a, !0, u.value), {
|
|
722
|
+
...d ? { disabled: u.disabled || t.disabled } : {},
|
|
723
723
|
...t.progressive ? {
|
|
724
|
-
required: !!
|
|
725
|
-
min:
|
|
726
|
-
max:
|
|
727
|
-
minLength:
|
|
728
|
-
maxLength:
|
|
729
|
-
pattern:
|
|
724
|
+
required: !!u.required,
|
|
725
|
+
min: Me(u.min),
|
|
726
|
+
max: Me(u.max),
|
|
727
|
+
minLength: Me(u.minLength),
|
|
728
|
+
maxLength: Me(u.maxLength),
|
|
729
|
+
pattern: Me(u.pattern)
|
|
730
730
|
} : {},
|
|
731
731
|
name: a,
|
|
732
|
-
onChange:
|
|
733
|
-
onBlur:
|
|
734
|
-
ref: (
|
|
735
|
-
if (
|
|
736
|
-
|
|
737
|
-
const
|
|
738
|
-
if (
|
|
732
|
+
onChange: ue,
|
|
733
|
+
onBlur: ue,
|
|
734
|
+
ref: (f) => {
|
|
735
|
+
if (f) {
|
|
736
|
+
Se(a, u), o = g(s, a);
|
|
737
|
+
const l = I(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, m = tr(l), p = o._f.refs || [];
|
|
738
|
+
if (m ? p.find((b) => b === l) : l === o._f.ref)
|
|
739
739
|
return;
|
|
740
|
-
|
|
740
|
+
T(s, a, {
|
|
741
741
|
_f: {
|
|
742
|
-
...
|
|
743
|
-
...
|
|
742
|
+
...o._f,
|
|
743
|
+
...m ? {
|
|
744
744
|
refs: [
|
|
745
|
-
...p.filter(
|
|
746
|
-
|
|
745
|
+
...p.filter(rt),
|
|
746
|
+
l,
|
|
747
747
|
...Array.isArray(g(i, a)) ? [{}] : []
|
|
748
748
|
],
|
|
749
|
-
ref: { type:
|
|
750
|
-
} : { ref:
|
|
749
|
+
ref: { type: l.type, name: a }
|
|
750
|
+
} : { ref: l }
|
|
751
751
|
}
|
|
752
|
-
}),
|
|
752
|
+
}), S(a, !1, void 0, l);
|
|
753
753
|
} else
|
|
754
|
-
|
|
754
|
+
o = g(s, a, {}), o._f && (o._f.mount = !1), (t.shouldUnregister || u.shouldUnregister) && !(zt(h.array, a) && c.action) && h.unMount.add(a);
|
|
755
755
|
}
|
|
756
756
|
};
|
|
757
|
-
},
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
|
|
757
|
+
}, Re = () => t.shouldFocusError && Ue(s, he, h.mount), Xe = (a) => {
|
|
758
|
+
oe(a) && (v.state.next({ disabled: a }), Ue(s, (u, o) => {
|
|
759
|
+
const d = g(s, o);
|
|
760
|
+
d && (u.disabled = d._f.disabled || a, Array.isArray(d._f.refs) && d._f.refs.forEach((f) => {
|
|
761
|
+
f.disabled = d._f.disabled || a;
|
|
762
762
|
}));
|
|
763
763
|
}, 0, !1));
|
|
764
|
-
},
|
|
765
|
-
let
|
|
766
|
-
|
|
767
|
-
let
|
|
768
|
-
if (
|
|
764
|
+
}, $e = (a, u) => async (o) => {
|
|
765
|
+
let d;
|
|
766
|
+
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
767
|
+
let f = $(n);
|
|
768
|
+
if (v.state.next({
|
|
769
769
|
isSubmitting: !0
|
|
770
770
|
}), t.resolver) {
|
|
771
|
-
const { errors:
|
|
772
|
-
|
|
771
|
+
const { errors: l, values: m } = await ne();
|
|
772
|
+
Q(), r.errors = l, f = $(m);
|
|
773
773
|
} else
|
|
774
|
-
await
|
|
775
|
-
if (
|
|
776
|
-
for (const
|
|
777
|
-
|
|
778
|
-
if (
|
|
779
|
-
|
|
774
|
+
await Y(s);
|
|
775
|
+
if (h.disabled.size)
|
|
776
|
+
for (const l of h.disabled)
|
|
777
|
+
U(f, l);
|
|
778
|
+
if (U(r.errors, "root"), z(r.errors)) {
|
|
779
|
+
v.state.next({
|
|
780
780
|
errors: {}
|
|
781
781
|
});
|
|
782
782
|
try {
|
|
783
|
-
await a(
|
|
784
|
-
} catch (
|
|
785
|
-
|
|
783
|
+
await a(f, o);
|
|
784
|
+
} catch (l) {
|
|
785
|
+
d = l;
|
|
786
786
|
}
|
|
787
787
|
} else
|
|
788
|
-
|
|
789
|
-
if (
|
|
788
|
+
u && await u({ ...r.errors }, o), Re(), setTimeout(Re);
|
|
789
|
+
if (v.state.next({
|
|
790
790
|
isSubmitted: !0,
|
|
791
791
|
isSubmitting: !1,
|
|
792
|
-
isSubmitSuccessful:
|
|
792
|
+
isSubmitSuccessful: z(r.errors) && !d,
|
|
793
793
|
submitCount: r.submitCount + 1,
|
|
794
794
|
errors: r.errors
|
|
795
|
-
}),
|
|
796
|
-
throw
|
|
797
|
-
},
|
|
798
|
-
g(s, a) && (
|
|
799
|
-
},
|
|
800
|
-
const
|
|
801
|
-
if (
|
|
802
|
-
if (
|
|
803
|
-
const
|
|
804
|
-
...
|
|
805
|
-
...Object.keys(
|
|
795
|
+
}), d)
|
|
796
|
+
throw d;
|
|
797
|
+
}, Qe = (a, u = {}) => {
|
|
798
|
+
g(s, a) && (I(u.defaultValue) ? K(a, $(g(i, a))) : (K(a, u.defaultValue), T(i, a, $(u.defaultValue))), u.keepTouched || U(r.touchedFields, a), u.keepDirty || (U(r.dirtyFields, a), r.isDirty = u.defaultValue ? E(a, $(g(i, a))) : E()), u.keepError || (U(r.errors, a), D.isValid && H()), v.state.next({ ...r }));
|
|
799
|
+
}, je = (a, u = {}) => {
|
|
800
|
+
const o = a ? $(a) : i, d = $(o), f = z(a), l = f ? i : d;
|
|
801
|
+
if (u.keepDefaultValues || (i = o), !u.keepValues) {
|
|
802
|
+
if (u.keepDirtyValues) {
|
|
803
|
+
const m = /* @__PURE__ */ new Set([
|
|
804
|
+
...h.mount,
|
|
805
|
+
...Object.keys(Ve(i, n))
|
|
806
806
|
]);
|
|
807
|
-
for (const p of Array.from(
|
|
808
|
-
const
|
|
809
|
-
|
|
807
|
+
for (const p of Array.from(m)) {
|
|
808
|
+
const b = g(r.dirtyFields, p), R = g(n, p), M = g(l, p);
|
|
809
|
+
b && !I(R) ? T(l, p, R) : !b && !I(M) && K(p, M);
|
|
810
810
|
}
|
|
811
811
|
} else {
|
|
812
|
-
if (
|
|
813
|
-
for (const
|
|
814
|
-
const p = g(s,
|
|
812
|
+
if (nt && I(a))
|
|
813
|
+
for (const m of h.mount) {
|
|
814
|
+
const p = g(s, m);
|
|
815
815
|
if (p && p._f) {
|
|
816
|
-
const
|
|
817
|
-
if (Ye(
|
|
818
|
-
const
|
|
819
|
-
if (
|
|
820
|
-
|
|
816
|
+
const b = Array.isArray(p._f.refs) ? p._f.refs[0] : p._f.ref;
|
|
817
|
+
if (Ye(b)) {
|
|
818
|
+
const R = b.closest("form");
|
|
819
|
+
if (R) {
|
|
820
|
+
R.reset();
|
|
821
821
|
break;
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
-
if (
|
|
827
|
-
for (const
|
|
828
|
-
|
|
826
|
+
if (u.keepFieldsRef)
|
|
827
|
+
for (const m of h.mount)
|
|
828
|
+
K(m, g(l, m));
|
|
829
829
|
else
|
|
830
830
|
s = {};
|
|
831
831
|
}
|
|
832
|
-
n = t.shouldUnregister ?
|
|
833
|
-
values: { ...
|
|
834
|
-
}),
|
|
835
|
-
values: { ...
|
|
832
|
+
n = t.shouldUnregister ? u.keepDefaultValues ? $(i) : {} : $(l), v.array.next({
|
|
833
|
+
values: { ...l }
|
|
834
|
+
}), v.state.next({
|
|
835
|
+
values: { ...l }
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
|
-
|
|
839
|
-
mount:
|
|
838
|
+
h = {
|
|
839
|
+
mount: u.keepDirtyValues ? h.mount : /* @__PURE__ */ new Set(),
|
|
840
840
|
unMount: /* @__PURE__ */ new Set(),
|
|
841
841
|
array: /* @__PURE__ */ new Set(),
|
|
842
842
|
disabled: /* @__PURE__ */ new Set(),
|
|
843
843
|
watch: /* @__PURE__ */ new Set(),
|
|
844
844
|
watchAll: !1,
|
|
845
845
|
focus: ""
|
|
846
|
-
},
|
|
847
|
-
submitCount:
|
|
848
|
-
isDirty:
|
|
849
|
-
isSubmitted:
|
|
850
|
-
dirtyFields:
|
|
851
|
-
touchedFields:
|
|
852
|
-
errors:
|
|
853
|
-
isSubmitSuccessful:
|
|
846
|
+
}, c.mount = !D.isValid || !!u.keepIsValid || !!u.keepDirtyValues || !t.shouldUnregister && !z(l), c.watch = !!t.shouldUnregister, c.keepIsValid = !!u.keepIsValid, c.action = !1, u.keepErrors || (r.errors = {}), v.state.next({
|
|
847
|
+
submitCount: u.keepSubmitCount ? r.submitCount : 0,
|
|
848
|
+
isDirty: f ? !1 : u.keepDirty ? r.isDirty : !!(u.keepDefaultValues && !me(a, i)),
|
|
849
|
+
isSubmitted: u.keepIsSubmitted ? r.isSubmitted : !1,
|
|
850
|
+
dirtyFields: f ? {} : u.keepDirtyValues ? u.keepDefaultValues && n ? Ve(i, n) : r.dirtyFields : u.keepDefaultValues && a ? Ve(i, a) : u.keepDirty ? r.dirtyFields : {},
|
|
851
|
+
touchedFields: u.keepTouched ? r.touchedFields : {},
|
|
852
|
+
errors: u.keepErrors ? r.errors : {},
|
|
853
|
+
isSubmitSuccessful: u.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
854
854
|
isSubmitting: !1,
|
|
855
855
|
defaultValues: i
|
|
856
856
|
});
|
|
857
|
-
},
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
-
|
|
857
|
+
}, Ne = (a, u) => je(ie(a) ? a(n) : a, { ...t.resetOptions, ...u }), Ze = (a, u = {}) => {
|
|
858
|
+
const o = g(s, a), d = o && o._f;
|
|
859
|
+
if (d) {
|
|
860
|
+
const f = d.refs ? d.refs[0] : d.ref;
|
|
861
|
+
f.focus && setTimeout(() => {
|
|
862
|
+
f.focus(), u.shouldSelect && ie(f.select) && f.select();
|
|
863
863
|
});
|
|
864
864
|
}
|
|
865
|
-
},
|
|
865
|
+
}, Oe = (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: Se,
|
|
873
|
+
unregister: De,
|
|
874
|
+
getFieldState: Pe,
|
|
875
|
+
handleSubmit: $e,
|
|
876
|
+
setError: F,
|
|
877
|
+
_subscribe: _e,
|
|
878
|
+
_runSchema: ne,
|
|
879
|
+
_updateIsValidating: Q,
|
|
880
|
+
_focusError: Re,
|
|
881
881
|
_getWatch: x,
|
|
882
|
-
_getDirty:
|
|
883
|
-
_setValid:
|
|
884
|
-
_setFieldArray:
|
|
885
|
-
_setDisabledField:
|
|
886
|
-
_setErrors:
|
|
887
|
-
_getFieldArray:
|
|
888
|
-
_reset:
|
|
889
|
-
_resetDefaultValues: () =>
|
|
890
|
-
|
|
882
|
+
_getDirty: E,
|
|
883
|
+
_setValid: H,
|
|
884
|
+
_setFieldArray: _,
|
|
885
|
+
_setDisabledField: qe,
|
|
886
|
+
_setErrors: re,
|
|
887
|
+
_getFieldArray: L,
|
|
888
|
+
_reset: je,
|
|
889
|
+
_resetDefaultValues: () => ie(t.defaultValues) && t.defaultValues().then((a) => {
|
|
890
|
+
Ne(a, t.resetOptions), v.state.next({
|
|
891
891
|
isLoading: !1
|
|
892
892
|
});
|
|
893
893
|
}),
|
|
894
|
-
_removeUnmounted:
|
|
895
|
-
_disableForm:
|
|
896
|
-
_subjects:
|
|
894
|
+
_removeUnmounted: le,
|
|
895
|
+
_disableForm: Xe,
|
|
896
|
+
_subjects: v,
|
|
897
897
|
_proxyFormState: D,
|
|
898
898
|
get _fields() {
|
|
899
899
|
return s;
|
|
@@ -902,19 +902,19 @@ function dr(e = {}) {
|
|
|
902
902
|
return n;
|
|
903
903
|
},
|
|
904
904
|
get _state() {
|
|
905
|
-
return
|
|
905
|
+
return c;
|
|
906
906
|
},
|
|
907
907
|
set _state(a) {
|
|
908
|
-
|
|
908
|
+
c = a;
|
|
909
909
|
},
|
|
910
910
|
get _defaultValues() {
|
|
911
911
|
return i;
|
|
912
912
|
},
|
|
913
913
|
get _names() {
|
|
914
|
-
return
|
|
914
|
+
return h;
|
|
915
915
|
},
|
|
916
916
|
set _names(a) {
|
|
917
|
-
|
|
917
|
+
h = a;
|
|
918
918
|
},
|
|
919
919
|
get _formState() {
|
|
920
920
|
return r;
|
|
@@ -929,31 +929,31 @@ function dr(e = {}) {
|
|
|
929
929
|
};
|
|
930
930
|
}
|
|
931
931
|
},
|
|
932
|
-
subscribe:
|
|
933
|
-
trigger:
|
|
934
|
-
register:
|
|
935
|
-
handleSubmit:
|
|
936
|
-
watch:
|
|
937
|
-
setValue:
|
|
938
|
-
getValues:
|
|
939
|
-
reset:
|
|
940
|
-
resetField:
|
|
941
|
-
clearErrors:
|
|
942
|
-
unregister:
|
|
943
|
-
setError:
|
|
944
|
-
setFocus:
|
|
945
|
-
getFieldState:
|
|
932
|
+
subscribe: Ge,
|
|
933
|
+
trigger: J,
|
|
934
|
+
register: Se,
|
|
935
|
+
handleSubmit: $e,
|
|
936
|
+
watch: xe,
|
|
937
|
+
setValue: K,
|
|
938
|
+
getValues: Ae,
|
|
939
|
+
reset: Ne,
|
|
940
|
+
resetField: Qe,
|
|
941
|
+
clearErrors: Je,
|
|
942
|
+
unregister: De,
|
|
943
|
+
setError: F,
|
|
944
|
+
setFocus: Ze,
|
|
945
|
+
getFieldState: Pe
|
|
946
946
|
};
|
|
947
947
|
return {
|
|
948
|
-
...
|
|
949
|
-
formControl:
|
|
948
|
+
...We,
|
|
949
|
+
formControl: We
|
|
950
950
|
};
|
|
951
951
|
}
|
|
952
|
-
function
|
|
953
|
-
const t =
|
|
952
|
+
function yr(e = {}) {
|
|
953
|
+
const t = Z.useRef(void 0), r = Z.useRef(void 0), [s, i] = Z.useState({
|
|
954
954
|
isDirty: !1,
|
|
955
955
|
isValidating: !1,
|
|
956
|
-
isLoading:
|
|
956
|
+
isLoading: ie(e.defaultValues),
|
|
957
957
|
isSubmitted: !1,
|
|
958
958
|
isSubmitting: !1,
|
|
959
959
|
isSubmitSuccessful: !1,
|
|
@@ -965,58 +965,58 @@ function fr(e = {}) {
|
|
|
965
965
|
errors: e.errors || {},
|
|
966
966
|
disabled: e.disabled || !1,
|
|
967
967
|
isReady: !1,
|
|
968
|
-
defaultValues:
|
|
968
|
+
defaultValues: ie(e.defaultValues) ? void 0 : e.defaultValues
|
|
969
969
|
});
|
|
970
970
|
if (!t.current)
|
|
971
971
|
if (e.formControl)
|
|
972
972
|
t.current = {
|
|
973
973
|
...e.formControl,
|
|
974
974
|
formState: s
|
|
975
|
-
}, e.defaultValues && !
|
|
975
|
+
}, e.defaultValues && !ie(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
976
976
|
else {
|
|
977
|
-
const { formControl:
|
|
977
|
+
const { formControl: c, ...h } = mr(e);
|
|
978
978
|
t.current = {
|
|
979
|
-
...
|
|
979
|
+
...h,
|
|
980
980
|
formState: s
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
983
|
const n = t.current.control;
|
|
984
|
-
return n._options = e,
|
|
985
|
-
const
|
|
984
|
+
return n._options = e, Qt(() => {
|
|
985
|
+
const c = n._subscribe({
|
|
986
986
|
formState: n._proxyFormState,
|
|
987
987
|
callback: () => i({ ...n._formState }),
|
|
988
988
|
reRenderRoot: !0
|
|
989
989
|
});
|
|
990
|
-
return i((
|
|
991
|
-
...
|
|
990
|
+
return i((h) => ({
|
|
991
|
+
...h,
|
|
992
992
|
isReady: !0
|
|
993
|
-
})), n._formState.isReady = !0,
|
|
994
|
-
}, [n]),
|
|
993
|
+
})), n._formState.isReady = !0, c;
|
|
994
|
+
}, [n]), Z.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), Z.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]), Z.useEffect(() => {
|
|
997
997
|
e.errors && (n._setErrors(e.errors), n._focusError());
|
|
998
|
-
}, [n, e.errors]),
|
|
998
|
+
}, [n, e.errors]), Z.useEffect(() => {
|
|
999
999
|
e.shouldUnregister && n._subjects.state.next({
|
|
1000
1000
|
values: n._getWatch()
|
|
1001
1001
|
});
|
|
1002
|
-
}, [n, e.shouldUnregister]),
|
|
1002
|
+
}, [n, e.shouldUnregister]), Z.useEffect(() => {
|
|
1003
1003
|
if (n._proxyFormState.isDirty) {
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
isDirty:
|
|
1004
|
+
const c = n._getDirty();
|
|
1005
|
+
c !== s.isDirty && n._subjects.state.next({
|
|
1006
|
+
isDirty: c
|
|
1007
1007
|
});
|
|
1008
1008
|
}
|
|
1009
|
-
}, [n, s.isDirty]),
|
|
1010
|
-
var
|
|
1011
|
-
e.values && !
|
|
1009
|
+
}, [n, s.isDirty]), Z.useEffect(() => {
|
|
1010
|
+
var c;
|
|
1011
|
+
e.values && !me(e.values, r.current) ? (n._reset(e.values, {
|
|
1012
1012
|
keepFieldsRef: !0,
|
|
1013
1013
|
...n._options.resetOptions
|
|
1014
|
-
}), !((
|
|
1015
|
-
}, [n, e.values]),
|
|
1014
|
+
}), !((c = n._options.resetOptions) === null || c === void 0) && c.keepIsValid || n._setValid(), r.current = e.values, i((h) => ({ ...h }))) : n._resetDefaultValues();
|
|
1015
|
+
}, [n, e.values]), Z.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 = Xt(s, n), t.current;
|
|
1018
1018
|
}
|
|
1019
|
-
function
|
|
1019
|
+
function gr() {
|
|
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 pr = {
|
|
1036
1036
|
// String functions
|
|
1037
1037
|
CONCAT: (...e) => e.map((t) => String(t || "")).join(""),
|
|
1038
1038
|
TRIM: (e) => String(e || "").trim(),
|
|
@@ -1095,56 +1095,56 @@ const mr = {
|
|
|
1095
1095
|
ARRAY_CONTAINS: (e, t) => Array.isArray(e) ? e.includes(t) : !1,
|
|
1096
1096
|
ARRAY_JOIN: (e, t = ",") => Array.isArray(e) ? e.join(t) : ""
|
|
1097
1097
|
};
|
|
1098
|
-
function
|
|
1098
|
+
function ye(e, t) {
|
|
1099
1099
|
var r;
|
|
1100
1100
|
switch (e.Type) {
|
|
1101
1101
|
case "Literal":
|
|
1102
1102
|
return e.Value;
|
|
1103
1103
|
case "SystemIdentifier":
|
|
1104
1104
|
if (e.Property) {
|
|
1105
|
-
const
|
|
1106
|
-
return
|
|
1105
|
+
const V = t.systemValues[e.Name];
|
|
1106
|
+
return st(V, 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 V = Dt(e, t);
|
|
1112
|
+
return st(V, e.Property.Name);
|
|
1113
1113
|
}
|
|
1114
|
-
return
|
|
1114
|
+
return Dt(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
|
-
const s =
|
|
1119
|
-
return i ?
|
|
1118
|
+
const s = ye(e.Arguments[0], t), i = (r = e.Arguments[0].Property) == null ? void 0 : r.Name;
|
|
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
|
-
const n =
|
|
1124
|
-
return
|
|
1123
|
+
const n = ye(e.Arguments[0], t), c = ye(e.Arguments[1], t);
|
|
1124
|
+
return br(e.Operator, n, c);
|
|
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 wr(e.Operator, e.Arguments, t);
|
|
1129
1129
|
case "CallExpression":
|
|
1130
1130
|
if (!e.Callee)
|
|
1131
1131
|
throw new Error("CallExpression requires Callee");
|
|
1132
|
-
const
|
|
1133
|
-
if (!
|
|
1132
|
+
const h = pr[e.Callee];
|
|
1133
|
+
if (!h)
|
|
1134
1134
|
throw new Error(`Unknown function: ${e.Callee}`);
|
|
1135
1135
|
const w = (e.Arguments || []).map(
|
|
1136
|
-
(
|
|
1136
|
+
(V) => ye(V, t)
|
|
1137
1137
|
);
|
|
1138
|
-
return
|
|
1138
|
+
return h(...w);
|
|
1139
1139
|
case "AssignmentExpression":
|
|
1140
1140
|
if (!e.Arguments || e.Arguments.length !== 1)
|
|
1141
1141
|
throw new Error("AssignmentExpression requires exactly 1 argument");
|
|
1142
|
-
return
|
|
1142
|
+
return ye(e.Arguments[0], t);
|
|
1143
1143
|
default:
|
|
1144
1144
|
throw new Error(`Unknown expression type: ${e.Type}`);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
function
|
|
1147
|
+
function Dt(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 br(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,33 +1186,33 @@ function yr(e, t, r) {
|
|
|
1186
1186
|
throw new Error(`Unknown binary operator: ${e}`);
|
|
1187
1187
|
}
|
|
1188
1188
|
}
|
|
1189
|
-
function
|
|
1189
|
+
function wr(e, t, r) {
|
|
1190
1190
|
switch (e) {
|
|
1191
1191
|
case "AND":
|
|
1192
|
-
return t.every((s) => !!
|
|
1192
|
+
return t.every((s) => !!ye(s, r));
|
|
1193
1193
|
case "OR":
|
|
1194
|
-
return t.some((s) => !!
|
|
1194
|
+
return t.some((s) => !!ye(s, r));
|
|
1195
1195
|
default:
|
|
1196
1196
|
throw new Error(`Unknown logical operator: ${e}`);
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
|
-
function
|
|
1199
|
+
function Bt(e, t, r = {}) {
|
|
1200
1200
|
const s = {
|
|
1201
1201
|
formValues: t,
|
|
1202
|
-
systemValues:
|
|
1202
|
+
systemValues: gr(),
|
|
1203
1203
|
referenceData: r
|
|
1204
1204
|
};
|
|
1205
1205
|
try {
|
|
1206
|
-
return
|
|
1206
|
+
return ye(e, s);
|
|
1207
1207
|
} catch (i) {
|
|
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
|
+
Bt(
|
|
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 vr(e, t = {}, r = {}) {
|
|
1230
1230
|
try {
|
|
1231
|
-
return
|
|
1231
|
+
return Bt(e, t, r);
|
|
1232
1232
|
} catch (s) {
|
|
1233
1233
|
return console.warn("Default value calculation failed:", s), null;
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
1236
|
-
function
|
|
1237
|
-
var
|
|
1238
|
-
const r = ((
|
|
1236
|
+
function Rt(e, t) {
|
|
1237
|
+
var h, w, V;
|
|
1238
|
+
const r = ((h = e.Expression) == null ? void 0 : h.toLowerCase()) || "", s = ((w = e.Name) == null ? void 0 : w.toLowerCase()) || "", i = ((V = e.Id) == null ? void 0 : V.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: {},
|
|
@@ -1256,27 +1256,27 @@ function br(e) {
|
|
|
1256
1256
|
let n = i.Required || !1;
|
|
1257
1257
|
if (i.Validation && Array.isArray(i.Validation))
|
|
1258
1258
|
if (i.Validation.length > 0 && typeof i.Validation[0] == "object") {
|
|
1259
|
-
const
|
|
1260
|
-
i.Validation.forEach((
|
|
1261
|
-
t.Rules.Validation[
|
|
1259
|
+
const c = [];
|
|
1260
|
+
i.Validation.forEach((h) => {
|
|
1261
|
+
t.Rules.Validation[h.Id] = h, c.push(h.Id), Rt(h, s) && (n = !0);
|
|
1262
1262
|
}), r[s] = {
|
|
1263
1263
|
...i,
|
|
1264
|
-
Validation:
|
|
1264
|
+
Validation: c,
|
|
1265
1265
|
Required: n
|
|
1266
1266
|
};
|
|
1267
1267
|
} else
|
|
1268
|
-
i.Validation.forEach((
|
|
1269
|
-
var
|
|
1270
|
-
const w = (
|
|
1271
|
-
w &&
|
|
1268
|
+
i.Validation.forEach((h) => {
|
|
1269
|
+
var V;
|
|
1270
|
+
const w = (V = t.Rules.Validation) == null ? void 0 : V[h];
|
|
1271
|
+
w && Rt(w, s) && (n = !0);
|
|
1272
1272
|
}), n && !i.Required && (r[s] = {
|
|
1273
1273
|
...i,
|
|
1274
1274
|
Required: !0
|
|
1275
1275
|
});
|
|
1276
1276
|
if (i.Formula) {
|
|
1277
|
-
const
|
|
1278
|
-
t.Rules.Computation[
|
|
1279
|
-
Id:
|
|
1277
|
+
const c = `RULE_COMPUTE_${s.toUpperCase()}`;
|
|
1278
|
+
t.Rules.Computation[c] = {
|
|
1279
|
+
Id: c,
|
|
1280
1280
|
Name: i.Formula.Id || `Compute ${s}`,
|
|
1281
1281
|
Description: i.Formula.Description || `Computes value for ${s}`,
|
|
1282
1282
|
Expression: i.Formula.Expression,
|
|
@@ -1286,7 +1286,7 @@ function br(e) {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
}), t.Fields = r, t;
|
|
1288
1288
|
}
|
|
1289
|
-
function
|
|
1289
|
+
function Er(e) {
|
|
1290
1290
|
var r, s, i;
|
|
1291
1291
|
const t = {
|
|
1292
1292
|
validation: {},
|
|
@@ -1295,29 +1295,29 @@ 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 Fr(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
|
-
const
|
|
1304
|
+
const c = i.toUpperCase().replace(/[_-]/g, "");
|
|
1305
1305
|
for (const w of r) {
|
|
1306
|
-
const
|
|
1307
|
-
if (
|
|
1306
|
+
const V = w.toUpperCase().replace(/[_-]/g, "");
|
|
1307
|
+
if (c.includes(V)) {
|
|
1308
1308
|
t[i] = w;
|
|
1309
1309
|
return;
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
|
-
const
|
|
1312
|
+
const h = `${n.Name || ""} ${n.Description || ""}`.toLowerCase();
|
|
1313
1313
|
for (const w of r)
|
|
1314
|
-
if (
|
|
1314
|
+
if (h.includes(w.toLowerCase())) {
|
|
1315
1315
|
t[i] = w;
|
|
1316
1316
|
return;
|
|
1317
1317
|
}
|
|
1318
1318
|
}), t;
|
|
1319
1319
|
}
|
|
1320
|
-
function
|
|
1320
|
+
function Ar(e, t) {
|
|
1321
1321
|
const r = {};
|
|
1322
1322
|
Object.keys(e.Fields).forEach((i) => {
|
|
1323
1323
|
r[i] = {
|
|
@@ -1326,39 +1326,39 @@ function Fr(e, t) {
|
|
|
1326
1326
|
businessLogic: []
|
|
1327
1327
|
};
|
|
1328
1328
|
}), Object.entries(e.Fields).forEach(([i, n]) => {
|
|
1329
|
-
n.Validation && Array.isArray(n.Validation) && n.Validation.forEach((
|
|
1330
|
-
t.validation[
|
|
1331
|
-
}), n.Formula && Object.entries(t.computation).forEach(([
|
|
1329
|
+
n.Validation && Array.isArray(n.Validation) && n.Validation.forEach((h) => {
|
|
1330
|
+
t.validation[h] ? r[i].validation.push(h) : t.computation[h] ? r[i].computation.push(h) : t.businessLogic[h] && r[i].businessLogic.push(h);
|
|
1331
|
+
}), n.Formula && Object.entries(t.computation).forEach(([c, h]) => {
|
|
1332
1332
|
var w;
|
|
1333
|
-
|
|
1333
|
+
h.Expression === ((w = n.Formula) == null ? void 0 : w.Expression) && (r[i].computation.includes(c) || r[i].computation.push(c));
|
|
1334
1334
|
});
|
|
1335
1335
|
});
|
|
1336
|
-
const s =
|
|
1336
|
+
const s = Fr(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 xr(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 w,
|
|
1348
|
+
var w, V, N, D, A, v;
|
|
1349
1349
|
if (!t || !((w = e.RolePermission) != null && w[t])) {
|
|
1350
1350
|
r[i] = s;
|
|
1351
1351
|
return;
|
|
1352
1352
|
}
|
|
1353
|
-
const n = e.RolePermission[t],
|
|
1353
|
+
const n = e.RolePermission[t], c = ((V = n.Editable) == null ? void 0 : V.includes(i)) || ((N = n.Editable) == null ? void 0 : N.includes("*")) || !1, h = ((D = n.ReadOnly) == null ? void 0 : D.includes(i)) || ((A = n.ReadOnly) == null ? void 0 : A.includes("*")) || c;
|
|
1354
1354
|
r[i] = {
|
|
1355
|
-
editable:
|
|
1356
|
-
readable:
|
|
1357
|
-
hidden: !
|
|
1355
|
+
editable: c && !((v = n.ReadOnly) != null && v.includes(i)),
|
|
1356
|
+
readable: h,
|
|
1357
|
+
hidden: !h
|
|
1358
1358
|
};
|
|
1359
1359
|
}), r;
|
|
1360
1360
|
}
|
|
1361
|
-
function
|
|
1361
|
+
function _r(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 Pt(e) {
|
|
1383
1383
|
return e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).replace(/_/g, " ").trim();
|
|
1384
1384
|
}
|
|
1385
|
-
function
|
|
1385
|
+
function Dr(e, t, r) {
|
|
1386
1386
|
const s = {};
|
|
1387
1387
|
switch (t.Required && (s.required = {
|
|
1388
1388
|
value: !0,
|
|
1389
|
-
message: `${
|
|
1389
|
+
message: `${Pt(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 Rr(e, t = {}) {
|
|
1408
1408
|
if (!e.DefaultValue)
|
|
1409
1409
|
switch (e.Type) {
|
|
1410
1410
|
case "Boolean":
|
|
@@ -1420,13 +1420,13 @@ function _r(e, t = {}) {
|
|
|
1420
1420
|
default:
|
|
1421
1421
|
return;
|
|
1422
1422
|
}
|
|
1423
|
-
return
|
|
1423
|
+
return vr(
|
|
1424
1424
|
e.DefaultValue.ExpressionTree,
|
|
1425
1425
|
t
|
|
1426
1426
|
);
|
|
1427
1427
|
}
|
|
1428
|
-
function
|
|
1429
|
-
const
|
|
1428
|
+
function Nr(e, t, r, s = {}, i, n) {
|
|
1429
|
+
const c = {
|
|
1430
1430
|
editable: !0,
|
|
1431
1431
|
readable: !0,
|
|
1432
1432
|
hidden: !1
|
|
@@ -1434,82 +1434,60 @@ function Dr(e, t, r, s = {}, i, n) {
|
|
|
1434
1434
|
validation: [],
|
|
1435
1435
|
computation: [],
|
|
1436
1436
|
businessLogic: []
|
|
1437
|
-
},
|
|
1438
|
-
return
|
|
1437
|
+
}, V = t.Computed || !!t.Formula || w.computation.length > 0, N = Dr(e, t);
|
|
1438
|
+
return V && (N.disabled = !0), {
|
|
1439
1439
|
name: e,
|
|
1440
|
-
type:
|
|
1441
|
-
label: t.Name ||
|
|
1440
|
+
type: _r(t.Type, e),
|
|
1441
|
+
label: t.Name || Pt(e),
|
|
1442
1442
|
required: t.Required || !1,
|
|
1443
|
-
computed:
|
|
1444
|
-
defaultValue:
|
|
1445
|
-
options:
|
|
1446
|
-
validation:
|
|
1443
|
+
computed: V,
|
|
1444
|
+
defaultValue: Rr(t, s),
|
|
1445
|
+
options: Sr(t),
|
|
1446
|
+
validation: N,
|
|
1447
1447
|
description: t.Description,
|
|
1448
1448
|
_bdoField: t,
|
|
1449
|
-
permission: i ||
|
|
1449
|
+
permission: i || c,
|
|
1450
1450
|
rules: w
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
|
-
function
|
|
1453
|
+
function Or(e, t = {}, r) {
|
|
1454
1454
|
let s = e;
|
|
1455
|
-
s =
|
|
1456
|
-
const i = {}, n = [],
|
|
1457
|
-
for (const [
|
|
1458
|
-
if (
|
|
1455
|
+
s = Vr(s);
|
|
1456
|
+
const i = {}, n = [], c = [], h = [], w = [], V = Er(s), N = Ar(s, V), D = xr(s, r);
|
|
1457
|
+
for (const [A, v] of Object.entries(s.Fields)) {
|
|
1458
|
+
if (A.startsWith("_") && !["_id"].includes(A))
|
|
1459
1459
|
continue;
|
|
1460
|
-
const
|
|
1461
|
-
if (
|
|
1460
|
+
const y = D[A];
|
|
1461
|
+
if (y.hidden)
|
|
1462
1462
|
continue;
|
|
1463
|
-
const
|
|
1463
|
+
const P = Nr(
|
|
1464
|
+
A,
|
|
1464
1465
|
v,
|
|
1465
|
-
m,
|
|
1466
1466
|
s.Fields,
|
|
1467
1467
|
t,
|
|
1468
|
-
|
|
1469
|
-
|
|
1468
|
+
y,
|
|
1469
|
+
N[A] || {
|
|
1470
1470
|
validation: [],
|
|
1471
1471
|
computation: [],
|
|
1472
1472
|
businessLogic: []
|
|
1473
1473
|
}
|
|
1474
1474
|
);
|
|
1475
|
-
i[
|
|
1475
|
+
i[A] = P, n.push(A), P.computed && c.push(A), P.required && h.push(A);
|
|
1476
1476
|
}
|
|
1477
1477
|
return {
|
|
1478
1478
|
fields: i,
|
|
1479
1479
|
fieldOrder: n,
|
|
1480
|
-
computedFields:
|
|
1481
|
-
requiredFields:
|
|
1480
|
+
computedFields: c,
|
|
1481
|
+
requiredFields: h,
|
|
1482
1482
|
crossFieldValidation: w,
|
|
1483
|
-
rules:
|
|
1484
|
-
fieldRules:
|
|
1483
|
+
rules: V,
|
|
1484
|
+
fieldRules: N,
|
|
1485
1485
|
rolePermissions: s.RolePermission
|
|
1486
1486
|
};
|
|
1487
1487
|
}
|
|
1488
|
-
function
|
|
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
|
-
async function Or(e) {
|
|
1488
|
+
async function Cr(e) {
|
|
1511
1489
|
try {
|
|
1512
|
-
const r = (await
|
|
1490
|
+
const r = (await Ht(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;
|
|
@@ -1519,34 +1497,34 @@ async function Or(e) {
|
|
|
1519
1497
|
);
|
|
1520
1498
|
}
|
|
1521
1499
|
}
|
|
1522
|
-
async function
|
|
1500
|
+
async function Tr(e, t = 3) {
|
|
1523
1501
|
let r;
|
|
1524
1502
|
for (let s = 1; s <= t; s++)
|
|
1525
1503
|
try {
|
|
1526
|
-
return await
|
|
1504
|
+
return await Cr(e);
|
|
1527
1505
|
} catch (i) {
|
|
1528
|
-
if (r =
|
|
1506
|
+
if (r = Ie(i), s < t) {
|
|
1529
1507
|
const n = Math.min(1e3 * Math.pow(2, s - 1), 5e3);
|
|
1530
|
-
await new Promise((
|
|
1508
|
+
await new Promise((c) => setTimeout(c, n));
|
|
1531
1509
|
continue;
|
|
1532
1510
|
}
|
|
1533
1511
|
}
|
|
1534
1512
|
throw r;
|
|
1535
1513
|
}
|
|
1536
|
-
async function
|
|
1514
|
+
async function Lr(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"}`
|
|
1542
1520
|
);
|
|
1543
1521
|
}
|
|
1544
1522
|
}
|
|
1545
|
-
async function
|
|
1523
|
+
async function Mr(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 Ir(e, t, r = "create", s, i) {
|
|
1552
|
+
const n = {};
|
|
1553
|
+
return Object.keys(e).forEach((c) => {
|
|
1554
|
+
const h = c;
|
|
1555
|
+
let w = e[h];
|
|
1556
|
+
if (!t.includes(c) && w !== void 0) {
|
|
1557
|
+
if ((i == null ? void 0 : i[c]) === "Reference" && w !== null && (w = qt(w)), r === "create") {
|
|
1558
|
+
n[h] = w;
|
|
1611
1559
|
return;
|
|
1612
1560
|
}
|
|
1613
1561
|
if (r === "update") {
|
|
1614
1562
|
if (!s) {
|
|
1615
|
-
|
|
1563
|
+
n[h] = w;
|
|
1616
1564
|
return;
|
|
1617
1565
|
}
|
|
1618
|
-
const
|
|
1619
|
-
JSON.stringify(
|
|
1566
|
+
const V = s[h];
|
|
1567
|
+
JSON.stringify(w) !== JSON.stringify(V) && (n[h] = w);
|
|
1620
1568
|
}
|
|
1621
1569
|
}
|
|
1622
|
-
}),
|
|
1570
|
+
}), n;
|
|
1623
1571
|
}
|
|
1624
|
-
function
|
|
1572
|
+
function qt(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 Jr(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 Gr(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 Xr(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 kr(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 Ur(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 Qr(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 Br(e) {
|
|
1618
|
+
const t = `schema:${e}`, r = Ur(t);
|
|
1655
1619
|
if (r)
|
|
1656
1620
|
return r;
|
|
1657
|
-
const s = await
|
|
1658
|
-
return
|
|
1621
|
+
const s = await Tr(e);
|
|
1622
|
+
return kr(t, s, 30), s;
|
|
1659
1623
|
}
|
|
1660
|
-
class
|
|
1624
|
+
class Nt {
|
|
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 Pr(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 qr {
|
|
1703
1667
|
constructor() {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1668
|
+
we(this, "resultCache", new Nt(500));
|
|
1669
|
+
we(this, "dependencyCache", new Nt(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 = Pr(t), this.dependencyCache.set(r, s)), s;
|
|
1722
1686
|
}
|
|
1723
1687
|
/**
|
|
1724
1688
|
* Check if expression result is cached and context hasn't changed
|
|
@@ -1726,8 +1690,8 @@ class $r {
|
|
|
1726
1690
|
getCachedResult(t, r, s) {
|
|
1727
1691
|
if (!s) return;
|
|
1728
1692
|
const i = this.getDependencies(t);
|
|
1729
|
-
for (const
|
|
1730
|
-
if (r[
|
|
1693
|
+
for (const c of i)
|
|
1694
|
+
if (r[c] !== s[c])
|
|
1731
1695
|
return;
|
|
1732
1696
|
const n = this.createCacheKey(t, r);
|
|
1733
1697
|
return this.resultCache.get(n);
|
|
@@ -1739,8 +1703,8 @@ class $r {
|
|
|
1739
1703
|
const i = this.getCachedResult(t, r, s);
|
|
1740
1704
|
if (i !== void 0)
|
|
1741
1705
|
return i;
|
|
1742
|
-
const n = this.evaluateNode(t, r),
|
|
1743
|
-
return this.resultCache.set(
|
|
1706
|
+
const n = this.evaluateNode(t, r), c = this.createCacheKey(t, r);
|
|
1707
|
+
return this.resultCache.set(c, n), n;
|
|
1744
1708
|
}
|
|
1745
1709
|
/**
|
|
1746
1710
|
* Core expression evaluation logic
|
|
@@ -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((V) => String(V || "")).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((V, N) => V + (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((V) => !isNaN(Number(V)));
|
|
1833
|
+
return n.length > 0 ? n.reduce((V, N) => V + Number(N), 0) / n.length : 0;
|
|
1870
1834
|
case "MIN":
|
|
1871
|
-
return Math.min(...s.map((
|
|
1835
|
+
return Math.min(...s.map((V) => Number(V) || 0));
|
|
1872
1836
|
case "MAX":
|
|
1873
|
-
return Math.max(...s.map((
|
|
1837
|
+
return Math.max(...s.map((V) => Number(V) || 0));
|
|
1874
1838
|
case "ROUND":
|
|
1875
1839
|
return Math.round(Number(s[0]) || 0);
|
|
1876
1840
|
case "FLOOR":
|
|
@@ -1886,7 +1850,7 @@ class $r {
|
|
|
1886
1850
|
case "DAY":
|
|
1887
1851
|
return new Date(s[0]).getDate();
|
|
1888
1852
|
case "DATE_DIFF":
|
|
1889
|
-
const
|
|
1853
|
+
const c = new Date(s[0]), h = new Date(s[1]), w = Math.abs(c.getTime() - h.getTime());
|
|
1890
1854
|
return Math.ceil(w / (1e3 * 60 * 60 * 24));
|
|
1891
1855
|
case "IF":
|
|
1892
1856
|
return s[0] ? s[1] : s[2];
|
|
@@ -1913,32 +1877,32 @@ class $r {
|
|
|
1913
1877
|
this.resultCache.clear(), this.dependencyCache.clear(), this.compiledExpressions.clear();
|
|
1914
1878
|
}
|
|
1915
1879
|
}
|
|
1916
|
-
const
|
|
1917
|
-
function
|
|
1880
|
+
const $t = new qr();
|
|
1881
|
+
function $r(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
|
-
for (const
|
|
1885
|
+
for (const c of r)
|
|
1922
1886
|
try {
|
|
1923
|
-
if (
|
|
1924
|
-
|
|
1887
|
+
if (!$t.evaluate(
|
|
1888
|
+
c.ExpressionTree,
|
|
1925
1889
|
n,
|
|
1926
1890
|
i
|
|
1927
1891
|
))
|
|
1928
1892
|
return {
|
|
1929
1893
|
isValid: !1,
|
|
1930
|
-
message:
|
|
1894
|
+
message: c.Message || `Validation failed for ${c.Name}`,
|
|
1931
1895
|
fieldName: e
|
|
1932
1896
|
};
|
|
1933
|
-
} catch (
|
|
1934
|
-
console.warn(`Validation rule ${
|
|
1897
|
+
} catch (h) {
|
|
1898
|
+
console.warn(`Validation rule ${c.Id} failed to evaluate:`, h);
|
|
1935
1899
|
}
|
|
1936
1900
|
return { isValid: !0 };
|
|
1937
1901
|
}
|
|
1938
|
-
function
|
|
1939
|
-
return Array.from(
|
|
1902
|
+
function Ot(e) {
|
|
1903
|
+
return Array.from($t.getDependencies(e));
|
|
1940
1904
|
}
|
|
1941
|
-
function
|
|
1905
|
+
function Zr(e) {
|
|
1942
1906
|
const {
|
|
1943
1907
|
source: t,
|
|
1944
1908
|
operation: r,
|
|
@@ -1946,25 +1910,30 @@ function es(e) {
|
|
|
1946
1910
|
defaultValues: i = {},
|
|
1947
1911
|
mode: n = "onBlur",
|
|
1948
1912
|
// Validation mode - controls when errors are shown (see types.ts for details)
|
|
1949
|
-
enabled:
|
|
1950
|
-
userRole:
|
|
1913
|
+
enabled: c = !0,
|
|
1914
|
+
userRole: h,
|
|
1951
1915
|
onSchemaError: w,
|
|
1952
|
-
skipSchemaFetch:
|
|
1953
|
-
schema:
|
|
1954
|
-
interactionMode: D = "interactive"
|
|
1955
|
-
|
|
1916
|
+
skipSchemaFetch: V = !1,
|
|
1917
|
+
schema: N,
|
|
1918
|
+
interactionMode: D = "interactive",
|
|
1919
|
+
enableDraftInUpdateMode: A = !1
|
|
1920
|
+
} = e, v = D === "interactive", [y, P] = pe(
|
|
1921
|
+
null
|
|
1922
|
+
), [H, Q] = pe(
|
|
1923
|
+
{}
|
|
1924
|
+
), [_, te] = pe(!1), [re] = pe({}), [S, de] = pe(null), [ge, ne] = pe(!1), [fe, Y] = pe(null), le = Te(!1), E = Te(null), x = Te(null), L = Te(!1), O = Te(w);
|
|
1956
1925
|
He(() => {
|
|
1957
|
-
|
|
1926
|
+
O.current = w;
|
|
1958
1927
|
}, [w]);
|
|
1959
1928
|
const {
|
|
1960
|
-
data:
|
|
1961
|
-
isLoading:
|
|
1962
|
-
error:
|
|
1963
|
-
refetch:
|
|
1964
|
-
} =
|
|
1929
|
+
data: W,
|
|
1930
|
+
isLoading: K,
|
|
1931
|
+
error: ue,
|
|
1932
|
+
refetch: he
|
|
1933
|
+
} = mt({
|
|
1965
1934
|
queryKey: ["form-schema", t],
|
|
1966
|
-
queryFn: () =>
|
|
1967
|
-
enabled:
|
|
1935
|
+
queryFn: () => V ? Promise.resolve(N || {}) : Br(t),
|
|
1936
|
+
enabled: c && (!V || !!N),
|
|
1968
1937
|
retry: 3,
|
|
1969
1938
|
staleTime: 30 * 60 * 1e3,
|
|
1970
1939
|
// 30 minutes - schemas don't change frequently
|
|
@@ -1972,395 +1941,403 @@ function es(e) {
|
|
|
1972
1941
|
// 1 hour - keep schemas in cache longer
|
|
1973
1942
|
throwOnError: !1
|
|
1974
1943
|
}), {
|
|
1975
|
-
data:
|
|
1976
|
-
isLoading:
|
|
1977
|
-
error:
|
|
1978
|
-
} =
|
|
1944
|
+
data: J,
|
|
1945
|
+
isLoading: Ae,
|
|
1946
|
+
error: Pe
|
|
1947
|
+
} = mt({
|
|
1979
1948
|
queryKey: ["form-record", t, s],
|
|
1980
|
-
queryFn: () =>
|
|
1981
|
-
enabled:
|
|
1949
|
+
queryFn: () => Lr(t, s),
|
|
1950
|
+
enabled: c && r === "update" && !!s,
|
|
1982
1951
|
retry: 3,
|
|
1983
1952
|
staleTime: 5 * 60 * 1e3,
|
|
1984
1953
|
// 5 minutes - records can change more frequently
|
|
1985
1954
|
gcTime: 15 * 60 * 1e3,
|
|
1986
1955
|
// 15 minutes - keep records for a reasonable time
|
|
1987
1956
|
throwOnError: !1
|
|
1988
|
-
}),
|
|
1989
|
-
const
|
|
1990
|
-
if (r === "update" &&
|
|
1991
|
-
for (const [
|
|
1992
|
-
|
|
1993
|
-
return
|
|
1994
|
-
}, [i,
|
|
1957
|
+
}), Je = Le(() => {
|
|
1958
|
+
const d = { ...i };
|
|
1959
|
+
if (r === "update" && J && Object.assign(d, J), y)
|
|
1960
|
+
for (const [f, l] of Object.entries(y.fields))
|
|
1961
|
+
l.defaultValue !== void 0 && !(f in d) && (d[f] = l.defaultValue);
|
|
1962
|
+
return d;
|
|
1963
|
+
}, [i, J, r, y]), F = yr({
|
|
1995
1964
|
mode: n,
|
|
1996
1965
|
defaultValues: i,
|
|
1997
|
-
values: r === "update" &&
|
|
1966
|
+
values: r === "update" && J ? Je : void 0
|
|
1998
1967
|
});
|
|
1999
1968
|
He(() => {
|
|
2000
|
-
var
|
|
2001
|
-
if (
|
|
1969
|
+
var d;
|
|
1970
|
+
if (W)
|
|
2002
1971
|
try {
|
|
2003
|
-
const
|
|
2004
|
-
|
|
1972
|
+
const f = Or(
|
|
1973
|
+
W,
|
|
2005
1974
|
{},
|
|
2006
1975
|
// Pass empty object - validation functions get live values from react-hook-form
|
|
2007
|
-
|
|
1976
|
+
h
|
|
2008
1977
|
);
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
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
|
-
});
|
|
2016
|
-
} catch (h) {
|
|
2017
|
-
console.error("Schema processing failed:", h), (u = S.current) == null || u.call(S, Ve(h));
|
|
1978
|
+
P(f);
|
|
1979
|
+
} catch (f) {
|
|
1980
|
+
console.error("Schema processing failed:", f), (d = O.current) == null || d.call(O, Ie(f));
|
|
2018
1981
|
}
|
|
2019
|
-
}, [
|
|
2020
|
-
var
|
|
2021
|
-
|
|
2022
|
-
}, [
|
|
2023
|
-
if (!v || r !== "create" || !
|
|
1982
|
+
}, [W, h]), He(() => {
|
|
1983
|
+
var d;
|
|
1984
|
+
ue && ((d = O.current) == null || d.call(O, ue));
|
|
1985
|
+
}, [ue]), He(() => {
|
|
1986
|
+
if (!v || r !== "create" || !y || !c || S || L.current)
|
|
2024
1987
|
return;
|
|
2025
|
-
|
|
2026
|
-
let
|
|
1988
|
+
L.current = !0;
|
|
1989
|
+
let d = !0;
|
|
2027
1990
|
return (async () => {
|
|
2028
|
-
|
|
1991
|
+
ne(!0), Y(null);
|
|
2029
1992
|
try {
|
|
2030
|
-
const
|
|
2031
|
-
if (!
|
|
2032
|
-
|
|
2033
|
-
if (
|
|
2034
|
-
|
|
1993
|
+
const m = await Ee(t).draftInteraction({});
|
|
1994
|
+
if (!d) return;
|
|
1995
|
+
de(m._id), m && typeof m == "object" && Object.entries(m).forEach(([p, b]) => {
|
|
1996
|
+
if (p === "_id") return;
|
|
1997
|
+
F.getValues(p) !== b && F.setValue(p, b, {
|
|
2035
1998
|
shouldDirty: !1,
|
|
2036
1999
|
shouldValidate: !1
|
|
2037
2000
|
});
|
|
2038
2001
|
});
|
|
2039
|
-
} catch (
|
|
2040
|
-
if (!
|
|
2041
|
-
console.error("Failed to create initial draft:",
|
|
2002
|
+
} catch (l) {
|
|
2003
|
+
if (!d) return;
|
|
2004
|
+
console.error("Failed to create initial draft:", l), Y(Ie(l)), L.current = !1;
|
|
2042
2005
|
} finally {
|
|
2043
|
-
|
|
2006
|
+
d && ne(!1);
|
|
2044
2007
|
}
|
|
2045
2008
|
})(), () => {
|
|
2046
|
-
|
|
2009
|
+
d = !1;
|
|
2047
2010
|
};
|
|
2048
|
-
}, [v, r,
|
|
2049
|
-
const
|
|
2050
|
-
if (!
|
|
2051
|
-
const
|
|
2052
|
-
return Object.entries(
|
|
2053
|
-
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2056
|
-
|
|
2011
|
+
}, [v, r, y, c, S, t]);
|
|
2012
|
+
const xe = Le(() => {
|
|
2013
|
+
if (!y) return [];
|
|
2014
|
+
const d = /* @__PURE__ */ new Set(), f = new Set(y.computedFields);
|
|
2015
|
+
return Object.entries(y.fieldRules).forEach(([l, m]) => {
|
|
2016
|
+
m.computation.forEach((p) => {
|
|
2017
|
+
const b = y.rules.computation[p];
|
|
2018
|
+
b != null && b.ExpressionTree && Ot(b.ExpressionTree).forEach((M) => {
|
|
2019
|
+
y.fields[M] && M !== l && !f.has(M) && d.add(M);
|
|
2057
2020
|
});
|
|
2058
2021
|
});
|
|
2059
|
-
}),
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
).forEach((
|
|
2064
|
-
|
|
2022
|
+
}), y.computedFields.forEach((l) => {
|
|
2023
|
+
const m = y.fields[l];
|
|
2024
|
+
m._bdoField.Formula && Ot(
|
|
2025
|
+
m._bdoField.Formula.ExpressionTree
|
|
2026
|
+
).forEach((b) => {
|
|
2027
|
+
y.fields[b] && b !== l && !f.has(b) && d.add(b);
|
|
2065
2028
|
});
|
|
2066
|
-
}), Array.from(
|
|
2067
|
-
}, [
|
|
2068
|
-
async (
|
|
2069
|
-
if (!(!
|
|
2070
|
-
if (v && r === "create" && !
|
|
2029
|
+
}), Array.from(d);
|
|
2030
|
+
}, [y]), _e = se(
|
|
2031
|
+
async (d) => {
|
|
2032
|
+
if (!(!y || r === "update" && !A || !(v && r !== "update" || xe.length > 0 && xe.includes(d)))) {
|
|
2033
|
+
if (v && r === "create" && !S) {
|
|
2071
2034
|
console.warn("Interactive create mode: waiting for draft ID");
|
|
2072
2035
|
return;
|
|
2073
2036
|
}
|
|
2074
|
-
|
|
2075
|
-
if (!
|
|
2037
|
+
le.current || (E.current && clearTimeout(E.current), E.current = setTimeout(() => {
|
|
2038
|
+
if (!y || le.current)
|
|
2076
2039
|
return;
|
|
2077
|
-
const
|
|
2040
|
+
const l = F.getValues();
|
|
2078
2041
|
(async () => {
|
|
2079
|
-
|
|
2042
|
+
le.current = !0;
|
|
2080
2043
|
try {
|
|
2081
|
-
const
|
|
2082
|
-
r === "update" && s && "_id" in
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2044
|
+
const p = Ee(t), b = {};
|
|
2045
|
+
r === "update" && s && "_id" in l && (b._id = l._id), v && r === "create" && S && (b._id = S);
|
|
2046
|
+
const R = x.current ?? (r === "update" ? J : null) ?? {}, M = new Set(
|
|
2047
|
+
y.computedFields || []
|
|
2085
2048
|
);
|
|
2086
|
-
Object.keys(
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2049
|
+
Object.keys(l).forEach((k) => {
|
|
2050
|
+
var ht;
|
|
2051
|
+
if (k === "_id" || M.has(k)) return;
|
|
2052
|
+
let G = l[k];
|
|
2053
|
+
const Ce = R[k];
|
|
2054
|
+
if (JSON.stringify(G) !== JSON.stringify(Ce) && (G !== "" && G !== null && G !== void 0)) {
|
|
2055
|
+
const tt = y.fields[k];
|
|
2056
|
+
((ht = tt == null ? void 0 : tt._bdoField) == null ? void 0 : ht.Type) === "Reference" && (G = qt(G)), b[k] = G;
|
|
2057
|
+
}
|
|
2090
2058
|
});
|
|
2091
|
-
const
|
|
2092
|
-
...
|
|
2059
|
+
const C = b, q = {
|
|
2060
|
+
...x.current
|
|
2093
2061
|
};
|
|
2094
|
-
Object.keys(
|
|
2095
|
-
|
|
2096
|
-
}),
|
|
2097
|
-
let
|
|
2098
|
-
r === "update" && s ?
|
|
2099
|
-
|
|
2100
|
-
|
|
2062
|
+
Object.keys(l).forEach((k) => {
|
|
2063
|
+
M.has(k) || (q[k] = l[k]);
|
|
2064
|
+
}), x.current = q;
|
|
2065
|
+
let j;
|
|
2066
|
+
r === "update" && s ? j = await p.draftPatch(
|
|
2067
|
+
s,
|
|
2068
|
+
C
|
|
2069
|
+
) : v && S ? j = await p.draftInteraction(C) : j = await p.draft(C), j && typeof j == "object" && (Object.entries(j).forEach(
|
|
2070
|
+
([k, G]) => {
|
|
2071
|
+
l[k] !== G && F.setValue(k, G, {
|
|
2101
2072
|
shouldDirty: !1,
|
|
2102
2073
|
shouldValidate: !1
|
|
2103
2074
|
});
|
|
2104
2075
|
}
|
|
2105
|
-
), Object.entries(
|
|
2106
|
-
([
|
|
2107
|
-
|
|
2076
|
+
), Object.entries(j).forEach(
|
|
2077
|
+
([k, G]) => {
|
|
2078
|
+
M.has(k) && (x.current[k] = G);
|
|
2108
2079
|
}
|
|
2109
2080
|
));
|
|
2110
|
-
} catch (
|
|
2111
|
-
console.warn("Failed to compute fields via API:",
|
|
2081
|
+
} catch (p) {
|
|
2082
|
+
console.warn("Failed to compute fields via API:", p);
|
|
2112
2083
|
} finally {
|
|
2113
|
-
|
|
2084
|
+
le.current = !1;
|
|
2114
2085
|
}
|
|
2115
2086
|
})();
|
|
2116
2087
|
}, 300));
|
|
2117
2088
|
}
|
|
2118
2089
|
},
|
|
2119
2090
|
[
|
|
2120
|
-
|
|
2091
|
+
y,
|
|
2121
2092
|
r,
|
|
2122
2093
|
s,
|
|
2123
|
-
|
|
2094
|
+
J,
|
|
2124
2095
|
t,
|
|
2125
|
-
|
|
2126
|
-
|
|
2096
|
+
F,
|
|
2097
|
+
xe,
|
|
2127
2098
|
v,
|
|
2128
|
-
|
|
2099
|
+
S,
|
|
2100
|
+
A
|
|
2129
2101
|
]
|
|
2130
|
-
),
|
|
2131
|
-
if (!
|
|
2102
|
+
), Ge = se(async () => {
|
|
2103
|
+
if (!y)
|
|
2132
2104
|
return !1;
|
|
2133
|
-
const
|
|
2134
|
-
if (!await
|
|
2105
|
+
const d = F.getValues();
|
|
2106
|
+
if (!await F.trigger())
|
|
2135
2107
|
return !1;
|
|
2136
|
-
const
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
u,
|
|
2145
|
-
C
|
|
2108
|
+
const l = y.crossFieldValidation.map((p) => ({
|
|
2109
|
+
Id: p.Id,
|
|
2110
|
+
Condition: { ExpressionTree: p.ExpressionTree },
|
|
2111
|
+
Message: p.Message || `Validation failed for ${p.Name}`
|
|
2112
|
+
})), m = St(
|
|
2113
|
+
l,
|
|
2114
|
+
d,
|
|
2115
|
+
H
|
|
2146
2116
|
);
|
|
2147
|
-
return
|
|
2148
|
-
|
|
2117
|
+
return m.length > 0 ? (m.forEach((p, b) => {
|
|
2118
|
+
F.setError(`root.crossField${b}`, {
|
|
2149
2119
|
type: "validate",
|
|
2150
|
-
message:
|
|
2120
|
+
message: p.message
|
|
2151
2121
|
});
|
|
2152
2122
|
}), !1) : !0;
|
|
2153
2123
|
}, [
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
]),
|
|
2160
|
-
(
|
|
2124
|
+
y,
|
|
2125
|
+
F.getValues,
|
|
2126
|
+
F.trigger,
|
|
2127
|
+
F.setError,
|
|
2128
|
+
H
|
|
2129
|
+
]), De = se(
|
|
2130
|
+
(d, f) => F.handleSubmit(
|
|
2161
2131
|
// RHF onValid handler - validation passed, now do cross-field + API
|
|
2162
|
-
async (
|
|
2163
|
-
if (!
|
|
2164
|
-
const
|
|
2165
|
-
|
|
2132
|
+
async (l, m) => {
|
|
2133
|
+
if (!y) {
|
|
2134
|
+
const p = new Error("Schema not loaded");
|
|
2135
|
+
f == null || f(p, m);
|
|
2166
2136
|
return;
|
|
2167
2137
|
}
|
|
2168
|
-
|
|
2138
|
+
te(!0);
|
|
2169
2139
|
try {
|
|
2170
|
-
const
|
|
2171
|
-
(
|
|
2172
|
-
Id:
|
|
2173
|
-
Condition: { ExpressionTree:
|
|
2174
|
-
Message:
|
|
2140
|
+
const p = y.crossFieldValidation.map(
|
|
2141
|
+
(q) => ({
|
|
2142
|
+
Id: q.Id,
|
|
2143
|
+
Condition: { ExpressionTree: q.ExpressionTree },
|
|
2144
|
+
Message: q.Message || `Validation failed for ${q.Name}`
|
|
2175
2145
|
})
|
|
2176
|
-
),
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2146
|
+
), b = St(
|
|
2147
|
+
p,
|
|
2148
|
+
l,
|
|
2149
|
+
H
|
|
2180
2150
|
);
|
|
2181
|
-
if (
|
|
2182
|
-
|
|
2183
|
-
|
|
2151
|
+
if (b.length > 0) {
|
|
2152
|
+
b.forEach((q, j) => {
|
|
2153
|
+
F.setError(`root.crossField${j}`, {
|
|
2184
2154
|
type: "validate",
|
|
2185
|
-
message:
|
|
2155
|
+
message: q.message
|
|
2186
2156
|
});
|
|
2187
|
-
}),
|
|
2157
|
+
}), f == null || f(F.formState.errors, m);
|
|
2188
2158
|
return;
|
|
2189
2159
|
}
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
|
|
2160
|
+
const R = {};
|
|
2161
|
+
Object.entries(y.fields).forEach(
|
|
2162
|
+
([q, j]) => {
|
|
2163
|
+
R[q] = j._bdoField.Type;
|
|
2164
|
+
}
|
|
2165
|
+
);
|
|
2166
|
+
const M = Ir(
|
|
2167
|
+
l,
|
|
2168
|
+
y.computedFields,
|
|
2193
2169
|
r,
|
|
2194
|
-
|
|
2170
|
+
J,
|
|
2171
|
+
R
|
|
2195
2172
|
);
|
|
2196
|
-
let
|
|
2173
|
+
let C;
|
|
2197
2174
|
if (v) {
|
|
2198
|
-
const
|
|
2175
|
+
const q = Ee(t);
|
|
2199
2176
|
if (r === "create") {
|
|
2200
|
-
if (!
|
|
2177
|
+
if (!S)
|
|
2201
2178
|
throw new Error(
|
|
2202
2179
|
"Interactive create mode requires a draft ID. Draft creation may have failed."
|
|
2203
2180
|
);
|
|
2204
|
-
|
|
2205
|
-
...
|
|
2206
|
-
_id:
|
|
2181
|
+
C = { success: !0, data: await q.draft({
|
|
2182
|
+
...M,
|
|
2183
|
+
_id: S
|
|
2207
2184
|
}) };
|
|
2208
2185
|
} else
|
|
2209
|
-
|
|
2210
|
-
} else if (
|
|
2186
|
+
C = { success: !0, data: await q.update(s, M) };
|
|
2187
|
+
} else if (C = await Mr(
|
|
2211
2188
|
t,
|
|
2212
2189
|
r,
|
|
2213
|
-
|
|
2190
|
+
M,
|
|
2214
2191
|
s
|
|
2215
|
-
), !
|
|
2216
|
-
throw
|
|
2217
|
-
r === "create" && (
|
|
2218
|
-
} catch (
|
|
2219
|
-
|
|
2192
|
+
), !C.success)
|
|
2193
|
+
throw C.error || new Error("Submission failed");
|
|
2194
|
+
r === "create" && (F.reset(), v && de(null)), await (d == null ? void 0 : d(C.data || l, m));
|
|
2195
|
+
} catch (p) {
|
|
2196
|
+
f == null || f(Ie(p), m);
|
|
2220
2197
|
} finally {
|
|
2221
|
-
|
|
2198
|
+
te(!1);
|
|
2222
2199
|
}
|
|
2223
2200
|
},
|
|
2224
2201
|
// RHF onInvalid handler - validation failed
|
|
2225
|
-
(
|
|
2226
|
-
|
|
2202
|
+
(l, m) => {
|
|
2203
|
+
f == null || f(l, m);
|
|
2227
2204
|
}
|
|
2228
2205
|
),
|
|
2229
2206
|
[
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2207
|
+
F,
|
|
2208
|
+
y,
|
|
2209
|
+
H,
|
|
2233
2210
|
t,
|
|
2234
2211
|
r,
|
|
2235
2212
|
s,
|
|
2236
|
-
|
|
2213
|
+
J,
|
|
2237
2214
|
v,
|
|
2238
|
-
|
|
2215
|
+
S
|
|
2239
2216
|
]
|
|
2240
|
-
),
|
|
2241
|
-
(
|
|
2242
|
-
[
|
|
2243
|
-
),
|
|
2244
|
-
if (!
|
|
2245
|
-
const
|
|
2246
|
-
return Object.entries(
|
|
2247
|
-
|
|
2248
|
-
}),
|
|
2249
|
-
}, [
|
|
2250
|
-
(
|
|
2251
|
-
[
|
|
2252
|
-
),
|
|
2253
|
-
(
|
|
2254
|
-
[
|
|
2255
|
-
),
|
|
2256
|
-
(
|
|
2257
|
-
[
|
|
2258
|
-
),
|
|
2259
|
-
await
|
|
2260
|
-
}, [
|
|
2261
|
-
|
|
2262
|
-
}, [
|
|
2263
|
-
() => (
|
|
2264
|
-
[
|
|
2265
|
-
),
|
|
2266
|
-
() => (
|
|
2267
|
-
[
|
|
2268
|
-
),
|
|
2269
|
-
if (!
|
|
2270
|
-
const
|
|
2271
|
-
return Object.entries(
|
|
2272
|
-
const
|
|
2273
|
-
switch (
|
|
2217
|
+
), qe = se(
|
|
2218
|
+
(d) => (y == null ? void 0 : y.fields[d]) || null,
|
|
2219
|
+
[y]
|
|
2220
|
+
), Se = se(() => {
|
|
2221
|
+
if (!y) return {};
|
|
2222
|
+
const d = {};
|
|
2223
|
+
return Object.entries(y.fields).forEach(([f, l]) => {
|
|
2224
|
+
d[f] = l;
|
|
2225
|
+
}), d;
|
|
2226
|
+
}, [y]), Re = se(
|
|
2227
|
+
(d) => !!(y != null && y.fields[d]),
|
|
2228
|
+
[y]
|
|
2229
|
+
), Xe = se(
|
|
2230
|
+
(d) => (y == null ? void 0 : y.requiredFields.includes(d)) || !1,
|
|
2231
|
+
[y]
|
|
2232
|
+
), $e = se(
|
|
2233
|
+
(d) => (y == null ? void 0 : y.computedFields.includes(d)) || !1,
|
|
2234
|
+
[y]
|
|
2235
|
+
), Qe = se(async () => {
|
|
2236
|
+
await he();
|
|
2237
|
+
}, [he]), je = se(() => {
|
|
2238
|
+
F.clearErrors();
|
|
2239
|
+
}, [F]), Ne = K || r === "update" && Ae || v && r === "create" && ge, Ze = Ne || _, Oe = ue || Pe || fe, dt = !!Oe, We = Le(
|
|
2240
|
+
() => (y == null ? void 0 : y.computedFields) || [],
|
|
2241
|
+
[y]
|
|
2242
|
+
), a = Le(
|
|
2243
|
+
() => (y == null ? void 0 : y.requiredFields) || [],
|
|
2244
|
+
[y]
|
|
2245
|
+
), u = Le(() => {
|
|
2246
|
+
if (!y) return {};
|
|
2247
|
+
const d = {};
|
|
2248
|
+
return Object.entries(y.fields).forEach(([f, l]) => {
|
|
2249
|
+
const m = {};
|
|
2250
|
+
switch (l.required && (m.required = `${l.label} is required`), l.permission.editable || (m.disabled = !0), l.type) {
|
|
2274
2251
|
case "number":
|
|
2275
|
-
|
|
2252
|
+
m.valueAsNumber = !0;
|
|
2276
2253
|
break;
|
|
2277
2254
|
case "date":
|
|
2278
2255
|
case "datetime-local":
|
|
2279
|
-
|
|
2256
|
+
m.valueAsDate = !0;
|
|
2280
2257
|
break;
|
|
2281
2258
|
}
|
|
2282
|
-
const
|
|
2283
|
-
|
|
2284
|
-
expressionValidation: (
|
|
2285
|
-
const
|
|
2286
|
-
for (const
|
|
2287
|
-
const
|
|
2288
|
-
if (
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
[
|
|
2293
|
-
|
|
2294
|
-
|
|
2259
|
+
const p = l.rules.validation;
|
|
2260
|
+
p.length > 0 && (m.validate = {
|
|
2261
|
+
expressionValidation: (b) => {
|
|
2262
|
+
const R = F.getValues();
|
|
2263
|
+
for (const M of p) {
|
|
2264
|
+
const C = y.rules.validation[M];
|
|
2265
|
+
if (C) {
|
|
2266
|
+
const q = $r(
|
|
2267
|
+
f,
|
|
2268
|
+
b,
|
|
2269
|
+
[C],
|
|
2270
|
+
R,
|
|
2271
|
+
re
|
|
2295
2272
|
);
|
|
2296
|
-
if (
|
|
2297
|
-
return
|
|
2273
|
+
if (!q.isValid)
|
|
2274
|
+
return q.message || C.Message || "Invalid value";
|
|
2298
2275
|
}
|
|
2299
2276
|
}
|
|
2300
2277
|
return !0;
|
|
2301
2278
|
}
|
|
2302
|
-
}),
|
|
2303
|
-
}),
|
|
2304
|
-
}, [
|
|
2279
|
+
}), d[f] = m;
|
|
2280
|
+
}), d;
|
|
2281
|
+
}, [y, F, H]);
|
|
2305
2282
|
return {
|
|
2306
2283
|
// Form methods with strict typing
|
|
2307
|
-
register:
|
|
2308
|
-
(
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2311
|
-
let
|
|
2312
|
-
n === "onBlur" || n === "onTouched" || n === "all" ?
|
|
2284
|
+
register: se(
|
|
2285
|
+
(d, f) => {
|
|
2286
|
+
const l = u[d], m = f == null ? void 0 : f.onBlur, p = async (b) => {
|
|
2287
|
+
m && await m(b);
|
|
2288
|
+
let R = !0;
|
|
2289
|
+
n === "onBlur" || n === "onTouched" || n === "all" ? R = await F.trigger(d) : R = !F.getFieldState(d, F.formState).error, R && await _e(d);
|
|
2313
2290
|
};
|
|
2314
|
-
return
|
|
2315
|
-
...
|
|
2316
|
-
...
|
|
2317
|
-
onBlur:
|
|
2291
|
+
return F.register(d, {
|
|
2292
|
+
...l,
|
|
2293
|
+
...f,
|
|
2294
|
+
onBlur: p
|
|
2318
2295
|
});
|
|
2319
2296
|
},
|
|
2320
|
-
[
|
|
2297
|
+
[F, u, _e, n]
|
|
2321
2298
|
),
|
|
2322
|
-
handleSubmit:
|
|
2323
|
-
watch:
|
|
2299
|
+
handleSubmit: De,
|
|
2300
|
+
watch: F.watch,
|
|
2324
2301
|
// Type assertion for complex generic constraints
|
|
2325
|
-
setValue:
|
|
2326
|
-
reset:
|
|
2302
|
+
setValue: F.setValue,
|
|
2303
|
+
reset: F.reset,
|
|
2327
2304
|
// Flattened form state (NEW - direct access, no nested formState)
|
|
2328
|
-
errors:
|
|
2329
|
-
isValid:
|
|
2330
|
-
isDirty:
|
|
2331
|
-
isSubmitting:
|
|
2332
|
-
isSubmitSuccessful:
|
|
2305
|
+
errors: F.formState.errors,
|
|
2306
|
+
isValid: F.formState.isValid,
|
|
2307
|
+
isDirty: F.formState.isDirty,
|
|
2308
|
+
isSubmitting: F.formState.isSubmitting || _,
|
|
2309
|
+
isSubmitSuccessful: F.formState.isSubmitSuccessful,
|
|
2333
2310
|
// Loading states
|
|
2334
|
-
isLoadingInitialData:
|
|
2335
|
-
isLoadingRecord:
|
|
2336
|
-
isLoading:
|
|
2311
|
+
isLoadingInitialData: Ne,
|
|
2312
|
+
isLoadingRecord: Ae,
|
|
2313
|
+
isLoading: Ze,
|
|
2337
2314
|
// Interactive mode state
|
|
2338
|
-
draftId:
|
|
2339
|
-
isCreatingDraft:
|
|
2315
|
+
draftId: S,
|
|
2316
|
+
isCreatingDraft: ge,
|
|
2340
2317
|
// Error handling
|
|
2341
|
-
loadError:
|
|
2342
|
-
hasError:
|
|
2318
|
+
loadError: Oe ? Ie(Oe) : null,
|
|
2319
|
+
hasError: dt,
|
|
2343
2320
|
// Schema information
|
|
2344
|
-
schema:
|
|
2345
|
-
schemaConfig:
|
|
2346
|
-
computedFields:
|
|
2347
|
-
requiredFields:
|
|
2321
|
+
schema: W,
|
|
2322
|
+
schemaConfig: y,
|
|
2323
|
+
computedFields: We,
|
|
2324
|
+
requiredFields: a,
|
|
2348
2325
|
// Field helpers
|
|
2349
|
-
getField:
|
|
2350
|
-
getFields:
|
|
2351
|
-
hasField:
|
|
2352
|
-
isFieldRequired:
|
|
2353
|
-
isFieldComputed:
|
|
2326
|
+
getField: qe,
|
|
2327
|
+
getFields: Se,
|
|
2328
|
+
hasField: Re,
|
|
2329
|
+
isFieldRequired: Xe,
|
|
2330
|
+
isFieldComputed: $e,
|
|
2354
2331
|
// Operations
|
|
2355
|
-
refreshSchema:
|
|
2356
|
-
validateForm:
|
|
2357
|
-
clearErrors:
|
|
2332
|
+
refreshSchema: Qe,
|
|
2333
|
+
validateForm: Ge,
|
|
2334
|
+
clearErrors: je
|
|
2358
2335
|
};
|
|
2359
2336
|
}
|
|
2360
2337
|
export {
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2338
|
+
Qr as clearFormCache,
|
|
2339
|
+
Gr as isNetworkError,
|
|
2340
|
+
Xr as isValidationError,
|
|
2341
|
+
Jr as parseApiError,
|
|
2342
|
+
Zr as useForm
|
|
2366
2343
|
};
|