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