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