@ram_28/kf-ai-sdk 2.0.15 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/bdo/core/BaseBdo.d.ts +1 -1
- package/dist/bdo.mjs +2 -2
- package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts +1 -1
- package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -1
- package/dist/components/hooks/useActivityForm/types.d.ts +2 -2
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/types.d.ts +4 -4
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +1 -1
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/createResolver.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/index.d.ts +6 -0
- package/dist/components/hooks/useBDOForm/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOForm/shared.d.ts +50 -0
- package/dist/components/hooks/useBDOForm/shared.d.ts.map +1 -0
- package/dist/components/hooks/{useForm → useBDOForm}/types.d.ts +6 -6
- package/dist/components/hooks/useBDOForm/types.d.ts.map +1 -0
- package/dist/components/hooks/{useForm/useForm.d.ts → useBDOForm/useBDOForm.d.ts} +4 -4
- package/dist/components/hooks/useBDOForm/useBDOForm.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/types.d.ts +1 -3
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.mjs +250 -253
- package/dist/form.types.d.ts +1 -1
- package/dist/form.types.d.ts.map +1 -1
- package/dist/shared-5a7UkED1.js +1180 -0
- package/dist/shared-nnmlRVs7.cjs +1 -0
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +12 -11
- package/dist/types/constants.d.ts +3 -3
- package/dist/workflow/Activity.d.ts +15 -3
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/client.d.ts +2 -2
- package/dist/workflow/client.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +7 -3
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +503 -546
- package/docs/bdo.md +1 -1
- package/docs/gaps.md +14 -64
- package/docs/useActivityForm.md +393 -0
- package/docs/useActivityTable.md +42 -105
- package/docs/{useForm.md → useBDOForm.md} +24 -24
- package/docs/useBDOTable.md +6 -39
- package/docs/workflow.md +43 -301
- package/package.json +2 -2
- package/sdk/bdo/core/BaseBdo.ts +2 -2
- package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +1 -1
- package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +1 -1
- package/sdk/components/hooks/useActivityForm/types.ts +4 -4
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +44 -194
- package/sdk/components/hooks/useActivityTable/types.ts +4 -2
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +8 -39
- package/sdk/components/hooks/{useForm → useBDOForm}/index.ts +4 -3
- package/sdk/components/hooks/useBDOForm/shared.ts +250 -0
- package/sdk/components/hooks/{useForm → useBDOForm}/types.ts +9 -9
- package/sdk/components/hooks/{useForm/useForm.ts → useBDOForm/useBDOForm.ts} +70 -96
- package/sdk/components/hooks/useBDOTable/types.ts +1 -3
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +3 -2
- package/sdk/form.ts +2 -2
- package/sdk/form.types.ts +4 -4
- package/sdk/types/constants.ts +3 -3
- package/sdk/workflow/Activity.ts +29 -6
- package/sdk/workflow/client.ts +65 -25
- package/sdk/workflow/types.ts +10 -2
- package/dist/components/hooks/useForm/createItemProxy.d.ts.map +0 -1
- package/dist/components/hooks/useForm/createResolver.d.ts.map +0 -1
- package/dist/components/hooks/useForm/index.d.ts +0 -5
- package/dist/components/hooks/useForm/index.d.ts.map +0 -1
- package/dist/components/hooks/useForm/types.d.ts.map +0 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +0 -1
- package/dist/createResolver-AIgUwoS6.cjs +0 -1
- package/dist/createResolver-ZHXQ7QMa.js +0 -1078
- /package/dist/components/hooks/{useForm → useBDOForm}/createItemProxy.d.ts +0 -0
- /package/dist/components/hooks/{useForm → useBDOForm}/createResolver.d.ts +0 -0
- /package/sdk/components/hooks/{useForm → useBDOForm}/createItemProxy.ts +0 -0
- /package/sdk/components/hooks/{useForm → useBDOForm}/createResolver.ts +0 -0
|
@@ -1,1078 +0,0 @@
|
|
|
1
|
-
import B from "react";
|
|
2
|
-
var he = (e) => e.type === "checkbox", se = (e) => e instanceof Date, P = (e) => e == null;
|
|
3
|
-
const rt = (e) => typeof e == "object";
|
|
4
|
-
var S = (e) => !P(e) && !Array.isArray(e) && rt(e) && !se(e), _t = (e) => S(e) && e.target ? he(e.target) ? e.target.checked : e.target.value : e, Ft = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, mt = (e, s) => e.has(Ft(s)), At = (e) => {
|
|
5
|
-
const s = e.constructor && e.constructor.prototype;
|
|
6
|
-
return S(s) && s.hasOwnProperty("isPrototypeOf");
|
|
7
|
-
}, Se = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
8
|
-
function C(e) {
|
|
9
|
-
if (e instanceof Date)
|
|
10
|
-
return new Date(e);
|
|
11
|
-
const s = typeof FileList < "u" && e instanceof FileList;
|
|
12
|
-
if (Se && (e instanceof Blob || s))
|
|
13
|
-
return e;
|
|
14
|
-
const r = Array.isArray(e);
|
|
15
|
-
if (!r && !(S(e) && At(e)))
|
|
16
|
-
return e;
|
|
17
|
-
const a = r ? [] : Object.create(Object.getPrototypeOf(e));
|
|
18
|
-
for (const u in e)
|
|
19
|
-
Object.prototype.hasOwnProperty.call(e, u) && (a[u] = C(e[u]));
|
|
20
|
-
return a;
|
|
21
|
-
}
|
|
22
|
-
var _e = (e) => /^\w*$/.test(e), D = (e) => e === void 0, Oe = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Te = (e) => Oe(e.replace(/["|']|\]/g, "").split(/\.|\[/)), h = (e, s, r) => {
|
|
23
|
-
if (!s || !S(e))
|
|
24
|
-
return r;
|
|
25
|
-
const a = (_e(s) ? [s] : Te(s)).reduce((u, n) => P(u) ? u : u[n], e);
|
|
26
|
-
return D(a) || a === e ? D(e[s]) ? r : e[s] : a;
|
|
27
|
-
}, z = (e) => typeof e == "boolean", j = (e) => typeof e == "function", x = (e, s, r) => {
|
|
28
|
-
let a = -1;
|
|
29
|
-
const u = _e(s) ? [s] : Te(s), n = u.length, f = n - 1;
|
|
30
|
-
for (; ++a < n; ) {
|
|
31
|
-
const c = u[a];
|
|
32
|
-
let R = r;
|
|
33
|
-
if (a !== f) {
|
|
34
|
-
const k = e[c];
|
|
35
|
-
R = S(k) || Array.isArray(k) ? k : isNaN(+u[a + 1]) ? {} : [];
|
|
36
|
-
}
|
|
37
|
-
if (c === "__proto__" || c === "constructor" || c === "prototype")
|
|
38
|
-
return;
|
|
39
|
-
e[c] = R, e = e[c];
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const He = {
|
|
43
|
-
BLUR: "blur",
|
|
44
|
-
FOCUS_OUT: "focusout"
|
|
45
|
-
}, K = {
|
|
46
|
-
onBlur: "onBlur",
|
|
47
|
-
onChange: "onChange",
|
|
48
|
-
onSubmit: "onSubmit",
|
|
49
|
-
onTouched: "onTouched",
|
|
50
|
-
all: "all"
|
|
51
|
-
}, Z = {
|
|
52
|
-
max: "max",
|
|
53
|
-
min: "min",
|
|
54
|
-
maxLength: "maxLength",
|
|
55
|
-
minLength: "minLength",
|
|
56
|
-
pattern: "pattern",
|
|
57
|
-
required: "required",
|
|
58
|
-
validate: "validate"
|
|
59
|
-
}, xt = B.createContext(null);
|
|
60
|
-
xt.displayName = "HookFormContext";
|
|
61
|
-
var wt = (e, s, r, a = !0) => {
|
|
62
|
-
const u = {
|
|
63
|
-
defaultValues: s._defaultValues
|
|
64
|
-
};
|
|
65
|
-
for (const n in e)
|
|
66
|
-
Object.defineProperty(u, n, {
|
|
67
|
-
get: () => {
|
|
68
|
-
const f = n;
|
|
69
|
-
return s._proxyFormState[f] !== K.all && (s._proxyFormState[f] = !a || K.all), e[f];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return u;
|
|
73
|
-
};
|
|
74
|
-
const Dt = typeof window < "u" ? B.useLayoutEffect : B.useEffect;
|
|
75
|
-
var p = (e) => typeof e == "string", kt = (e, s, r, a, u) => p(e) ? (a && s.watch.add(e), h(r, e, u)) : Array.isArray(e) ? e.map((n) => (a && s.watch.add(n), h(r, n))) : (a && (s.watchAll = !0), r), ke = (e) => P(e) || !rt(e);
|
|
76
|
-
function ee(e, s, r = /* @__PURE__ */ new WeakSet()) {
|
|
77
|
-
if (ke(e) || ke(s))
|
|
78
|
-
return Object.is(e, s);
|
|
79
|
-
if (se(e) && se(s))
|
|
80
|
-
return Object.is(e.getTime(), s.getTime());
|
|
81
|
-
const a = Object.keys(e), u = Object.keys(s);
|
|
82
|
-
if (a.length !== u.length)
|
|
83
|
-
return !1;
|
|
84
|
-
if (r.has(e) || r.has(s))
|
|
85
|
-
return !0;
|
|
86
|
-
r.add(e), r.add(s);
|
|
87
|
-
for (const n of a) {
|
|
88
|
-
const f = e[n];
|
|
89
|
-
if (!u.includes(n))
|
|
90
|
-
return !1;
|
|
91
|
-
if (n !== "ref") {
|
|
92
|
-
const c = s[n];
|
|
93
|
-
if (se(f) && se(c) || S(f) && S(c) || Array.isArray(f) && Array.isArray(c) ? !ee(f, c, r) : !Object.is(f, c))
|
|
94
|
-
return !1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return !0;
|
|
98
|
-
}
|
|
99
|
-
var Et = (e, s, r, a, u) => s ? {
|
|
100
|
-
...r[e],
|
|
101
|
-
types: {
|
|
102
|
-
...r[e] && r[e].types ? r[e].types : {},
|
|
103
|
-
[a]: u || !0
|
|
104
|
-
}
|
|
105
|
-
} : {}, ce = (e) => Array.isArray(e) ? e : [e], je = () => {
|
|
106
|
-
let e = [];
|
|
107
|
-
return {
|
|
108
|
-
get observers() {
|
|
109
|
-
return e;
|
|
110
|
-
},
|
|
111
|
-
next: (u) => {
|
|
112
|
-
for (const n of e)
|
|
113
|
-
n.next && n.next(u);
|
|
114
|
-
},
|
|
115
|
-
subscribe: (u) => (e.push(u), {
|
|
116
|
-
unsubscribe: () => {
|
|
117
|
-
e = e.filter((n) => n !== u);
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
unsubscribe: () => {
|
|
121
|
-
e = [];
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
function st(e, s) {
|
|
126
|
-
const r = {};
|
|
127
|
-
for (const a in e)
|
|
128
|
-
if (e.hasOwnProperty(a)) {
|
|
129
|
-
const u = e[a], n = s[a];
|
|
130
|
-
if (u && S(u) && n) {
|
|
131
|
-
const f = st(u, n);
|
|
132
|
-
S(f) && (r[a] = f);
|
|
133
|
-
} else e[a] && (r[a] = n);
|
|
134
|
-
}
|
|
135
|
-
return r;
|
|
136
|
-
}
|
|
137
|
-
var M = (e) => S(e) && !Object.keys(e).length, Ce = (e) => e.type === "file", be = (e) => {
|
|
138
|
-
if (!Se)
|
|
139
|
-
return !1;
|
|
140
|
-
const s = e ? e.ownerDocument : 0;
|
|
141
|
-
return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
|
|
142
|
-
}, it = (e) => e.type === "select-multiple", Re = (e) => e.type === "radio", St = (e) => Re(e) || he(e), De = (e) => be(e) && e.isConnected;
|
|
143
|
-
function Ot(e, s) {
|
|
144
|
-
const r = s.slice(0, -1).length;
|
|
145
|
-
let a = 0;
|
|
146
|
-
for (; a < r; )
|
|
147
|
-
e = D(e) ? a++ : e[s[a++]];
|
|
148
|
-
return e;
|
|
149
|
-
}
|
|
150
|
-
function Tt(e) {
|
|
151
|
-
for (const s in e)
|
|
152
|
-
if (e.hasOwnProperty(s) && !D(e[s]))
|
|
153
|
-
return !1;
|
|
154
|
-
return !0;
|
|
155
|
-
}
|
|
156
|
-
function E(e, s) {
|
|
157
|
-
const r = Array.isArray(s) ? s : _e(s) ? [s] : Te(s), a = r.length === 1 ? e : Ot(e, r), u = r.length - 1, n = r[u];
|
|
158
|
-
return a && delete a[n], u !== 0 && (S(a) && M(a) || Array.isArray(a) && Tt(a)) && E(e, r.slice(0, -1)), e;
|
|
159
|
-
}
|
|
160
|
-
var Ct = (e) => {
|
|
161
|
-
for (const s in e)
|
|
162
|
-
if (j(e[s]))
|
|
163
|
-
return !0;
|
|
164
|
-
return !1;
|
|
165
|
-
};
|
|
166
|
-
function at(e) {
|
|
167
|
-
return Array.isArray(e) || S(e) && !Ct(e);
|
|
168
|
-
}
|
|
169
|
-
function Ee(e, s = {}) {
|
|
170
|
-
for (const r in e) {
|
|
171
|
-
const a = e[r];
|
|
172
|
-
at(a) ? (s[r] = Array.isArray(a) ? [] : {}, Ee(a, s[r])) : D(a) || (s[r] = !0);
|
|
173
|
-
}
|
|
174
|
-
return s;
|
|
175
|
-
}
|
|
176
|
-
function ne(e, s, r) {
|
|
177
|
-
r || (r = Ee(s));
|
|
178
|
-
for (const a in e) {
|
|
179
|
-
const u = e[a];
|
|
180
|
-
if (at(u))
|
|
181
|
-
D(s) || ke(r[a]) ? r[a] = Ee(u, Array.isArray(u) ? [] : {}) : ne(u, P(s) ? {} : s[a], r[a]);
|
|
182
|
-
else {
|
|
183
|
-
const n = s[a];
|
|
184
|
-
r[a] = !ee(u, n);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return r;
|
|
188
|
-
}
|
|
189
|
-
const Ke = {
|
|
190
|
-
value: !1,
|
|
191
|
-
isValid: !1
|
|
192
|
-
}, ze = { value: !0, isValid: !0 };
|
|
193
|
-
var nt = (e) => {
|
|
194
|
-
if (Array.isArray(e)) {
|
|
195
|
-
if (e.length > 1) {
|
|
196
|
-
const s = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
|
|
197
|
-
return { value: s, isValid: !!s.length };
|
|
198
|
-
}
|
|
199
|
-
return e[0].checked && !e[0].disabled ? (
|
|
200
|
-
// @ts-expect-error expected to work in the browser
|
|
201
|
-
e[0].attributes && !D(e[0].attributes.value) ? D(e[0].value) || e[0].value === "" ? ze : { value: e[0].value, isValid: !0 } : ze
|
|
202
|
-
) : Ke;
|
|
203
|
-
}
|
|
204
|
-
return Ke;
|
|
205
|
-
}, lt = (e, { valueAsNumber: s, valueAsDate: r, setValueAs: a }) => D(e) ? e : s ? e === "" ? NaN : e && +e : r && p(e) ? new Date(e) : a ? a(e) : e;
|
|
206
|
-
const Ye = {
|
|
207
|
-
isValid: !1,
|
|
208
|
-
value: null
|
|
209
|
-
};
|
|
210
|
-
var ut = (e) => Array.isArray(e) ? e.reduce((s, r) => r && r.checked && !r.disabled ? {
|
|
211
|
-
isValid: !0,
|
|
212
|
-
value: r.value
|
|
213
|
-
} : s, Ye) : Ye;
|
|
214
|
-
function Je(e) {
|
|
215
|
-
const s = e.ref;
|
|
216
|
-
return Ce(s) ? s.files : Re(s) ? ut(e.refs).value : it(s) ? [...s.selectedOptions].map(({ value: r }) => r) : he(s) ? nt(e.refs).value : lt(D(s.value) ? e.ref.value : s.value, e);
|
|
217
|
-
}
|
|
218
|
-
var Rt = (e, s, r, a) => {
|
|
219
|
-
const u = {};
|
|
220
|
-
for (const n of e) {
|
|
221
|
-
const f = h(s, n);
|
|
222
|
-
f && x(u, n, f._f);
|
|
223
|
-
}
|
|
224
|
-
return {
|
|
225
|
-
criteriaMode: r,
|
|
226
|
-
names: [...e],
|
|
227
|
-
fields: u,
|
|
228
|
-
shouldUseNativeValidation: a
|
|
229
|
-
};
|
|
230
|
-
}, Ve = (e) => e instanceof RegExp, de = (e) => D(e) ? e : Ve(e) ? e.source : S(e) ? Ve(e.value) ? e.value.source : e.value : e, Qe = (e) => ({
|
|
231
|
-
isOnSubmit: !e || e === K.onSubmit,
|
|
232
|
-
isOnBlur: e === K.onBlur,
|
|
233
|
-
isOnChange: e === K.onChange,
|
|
234
|
-
isOnAll: e === K.all,
|
|
235
|
-
isOnTouch: e === K.onTouched
|
|
236
|
-
});
|
|
237
|
-
const Xe = "AsyncFunction";
|
|
238
|
-
var Lt = (e) => !!e && !!e.validate && !!(j(e.validate) && e.validate.constructor.name === Xe || S(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === Xe)), Ut = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Ze = (e, s, r) => !r && (s.watchAll || s.watch.has(e) || [...s.watch].some((a) => e.startsWith(a) && /^\.\w+/.test(e.slice(a.length))));
|
|
239
|
-
const ye = (e, s, r, a) => {
|
|
240
|
-
for (const u of r || Object.keys(e)) {
|
|
241
|
-
const n = h(e, u);
|
|
242
|
-
if (n) {
|
|
243
|
-
const { _f: f, ...c } = n;
|
|
244
|
-
if (f) {
|
|
245
|
-
if (f.refs && f.refs[0] && s(f.refs[0], u) && !a)
|
|
246
|
-
return !0;
|
|
247
|
-
if (f.ref && s(f.ref, f.name) && !a)
|
|
248
|
-
return !0;
|
|
249
|
-
if (ye(c, s))
|
|
250
|
-
break;
|
|
251
|
-
} else if (S(c) && ye(c, s))
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
function Ge(e, s, r) {
|
|
257
|
-
const a = h(e, r);
|
|
258
|
-
if (a || _e(r))
|
|
259
|
-
return {
|
|
260
|
-
error: a,
|
|
261
|
-
name: r
|
|
262
|
-
};
|
|
263
|
-
const u = r.split(".");
|
|
264
|
-
for (; u.length; ) {
|
|
265
|
-
const n = u.join("."), f = h(s, n), c = h(e, n);
|
|
266
|
-
if (f && !Array.isArray(f) && r !== n)
|
|
267
|
-
return { name: r };
|
|
268
|
-
if (c && c.type)
|
|
269
|
-
return {
|
|
270
|
-
name: n,
|
|
271
|
-
error: c
|
|
272
|
-
};
|
|
273
|
-
if (c && c.root && c.root.type)
|
|
274
|
-
return {
|
|
275
|
-
name: `${n}.root`,
|
|
276
|
-
error: c.root
|
|
277
|
-
};
|
|
278
|
-
u.pop();
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
name: r
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
var Mt = (e, s, r, a) => {
|
|
285
|
-
r(e);
|
|
286
|
-
const { name: u, ...n } = e;
|
|
287
|
-
return M(n) || Object.keys(n).length >= Object.keys(s).length || Object.keys(n).find((f) => s[f] === (!a || K.all));
|
|
288
|
-
}, Pt = (e, s, r) => !e || !s || e === s || ce(e).some((a) => a && (r ? a === s : a.startsWith(s) || s.startsWith(a))), It = (e, s, r, a, u) => u.isOnAll ? !1 : !r && u.isOnTouch ? !(s || e) : (r ? a.isOnBlur : u.isOnBlur) ? !e : (r ? a.isOnChange : u.isOnChange) ? e : !0, Nt = (e, s) => !Oe(h(e, s)).length && E(e, s), Bt = (e, s, r) => {
|
|
289
|
-
const a = ce(h(e, r));
|
|
290
|
-
return x(a, "root", s[r]), x(e, r, a), e;
|
|
291
|
-
};
|
|
292
|
-
function et(e, s, r = "validate") {
|
|
293
|
-
if (p(e) || Array.isArray(e) && e.every(p) || z(e) && !e)
|
|
294
|
-
return {
|
|
295
|
-
type: r,
|
|
296
|
-
message: p(e) ? e : "",
|
|
297
|
-
ref: s
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
var ae = (e) => S(e) && !Ve(e) ? e : {
|
|
301
|
-
value: e,
|
|
302
|
-
message: ""
|
|
303
|
-
}, tt = async (e, s, r, a, u, n) => {
|
|
304
|
-
const { ref: f, refs: c, required: R, maxLength: k, minLength: W, min: b, max: w, pattern: v, validate: Y, name: I, valueAsNumber: J, mount: q } = e._f, _ = h(r, I);
|
|
305
|
-
if (!q || s.has(I))
|
|
306
|
-
return {};
|
|
307
|
-
const Q = c ? c[0] : f, X = (V) => {
|
|
308
|
-
u && Q.reportValidity && (Q.setCustomValidity(z(V) ? "" : V || ""), Q.reportValidity());
|
|
309
|
-
}, O = {}, le = Re(f), ge = he(f), te = le || ge, ie = (J || Ce(f)) && D(f.value) && D(_) || be(f) && f.value === "" || _ === "" || Array.isArray(_) && !_.length, $ = Et.bind(null, I, a, O), ve = (V, F, T, L = Z.maxLength, H = Z.minLength) => {
|
|
310
|
-
const N = V ? F : T;
|
|
311
|
-
O[I] = {
|
|
312
|
-
type: V ? L : H,
|
|
313
|
-
message: N,
|
|
314
|
-
ref: f,
|
|
315
|
-
...$(V ? L : H, N)
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
|
-
if (n ? !Array.isArray(_) || !_.length : R && (!te && (ie || P(_)) || z(_) && !_ || ge && !nt(c).isValid || le && !ut(c).isValid)) {
|
|
319
|
-
const { value: V, message: F } = p(R) ? { value: !!R, message: R } : ae(R);
|
|
320
|
-
if (V && (O[I] = {
|
|
321
|
-
type: Z.required,
|
|
322
|
-
message: F,
|
|
323
|
-
ref: Q,
|
|
324
|
-
...$(Z.required, F)
|
|
325
|
-
}, !a))
|
|
326
|
-
return X(F), O;
|
|
327
|
-
}
|
|
328
|
-
if (!ie && (!P(b) || !P(w))) {
|
|
329
|
-
let V, F;
|
|
330
|
-
const T = ae(w), L = ae(b);
|
|
331
|
-
if (!P(_) && !isNaN(_)) {
|
|
332
|
-
const H = f.valueAsNumber || _ && +_;
|
|
333
|
-
P(T.value) || (V = H > T.value), P(L.value) || (F = H < L.value);
|
|
334
|
-
} else {
|
|
335
|
-
const H = f.valueAsDate || new Date(_), N = (fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + fe), ue = f.type == "time", oe = f.type == "week";
|
|
336
|
-
p(T.value) && _ && (V = ue ? N(_) > N(T.value) : oe ? _ > T.value : H > new Date(T.value)), p(L.value) && _ && (F = ue ? N(_) < N(L.value) : oe ? _ < L.value : H < new Date(L.value));
|
|
337
|
-
}
|
|
338
|
-
if ((V || F) && (ve(!!V, T.message, L.message, Z.max, Z.min), !a))
|
|
339
|
-
return X(O[I].message), O;
|
|
340
|
-
}
|
|
341
|
-
if ((k || W) && !ie && (p(_) || n && Array.isArray(_))) {
|
|
342
|
-
const V = ae(k), F = ae(W), T = !P(V.value) && _.length > +V.value, L = !P(F.value) && _.length < +F.value;
|
|
343
|
-
if ((T || L) && (ve(T, V.message, F.message), !a))
|
|
344
|
-
return X(O[I].message), O;
|
|
345
|
-
}
|
|
346
|
-
if (v && !ie && p(_)) {
|
|
347
|
-
const { value: V, message: F } = ae(v);
|
|
348
|
-
if (Ve(V) && !_.match(V) && (O[I] = {
|
|
349
|
-
type: Z.pattern,
|
|
350
|
-
message: F,
|
|
351
|
-
ref: f,
|
|
352
|
-
...$(Z.pattern, F)
|
|
353
|
-
}, !a))
|
|
354
|
-
return X(F), O;
|
|
355
|
-
}
|
|
356
|
-
if (Y) {
|
|
357
|
-
if (j(Y)) {
|
|
358
|
-
const V = await Y(_, r), F = et(V, Q);
|
|
359
|
-
if (F && (O[I] = {
|
|
360
|
-
...F,
|
|
361
|
-
...$(Z.validate, F.message)
|
|
362
|
-
}, !a))
|
|
363
|
-
return X(F.message), O;
|
|
364
|
-
} else if (S(Y)) {
|
|
365
|
-
let V = {};
|
|
366
|
-
for (const F in Y) {
|
|
367
|
-
if (!M(V) && !a)
|
|
368
|
-
break;
|
|
369
|
-
const T = et(await Y[F](_, r), Q, F);
|
|
370
|
-
T && (V = {
|
|
371
|
-
...T,
|
|
372
|
-
...$(F, T.message)
|
|
373
|
-
}, X(T.message), a && (O[I] = V));
|
|
374
|
-
}
|
|
375
|
-
if (!M(V) && (O[I] = {
|
|
376
|
-
ref: Q,
|
|
377
|
-
...V
|
|
378
|
-
}, !a))
|
|
379
|
-
return O;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
return X(!0), O;
|
|
383
|
-
};
|
|
384
|
-
const pt = {
|
|
385
|
-
mode: K.onSubmit,
|
|
386
|
-
reValidateMode: K.onChange,
|
|
387
|
-
shouldFocusError: !0
|
|
388
|
-
};
|
|
389
|
-
function qt(e = {}) {
|
|
390
|
-
let s = {
|
|
391
|
-
...pt,
|
|
392
|
-
...e
|
|
393
|
-
}, r = {
|
|
394
|
-
submitCount: 0,
|
|
395
|
-
isDirty: !1,
|
|
396
|
-
isReady: !1,
|
|
397
|
-
isLoading: j(s.defaultValues),
|
|
398
|
-
isValidating: !1,
|
|
399
|
-
isSubmitted: !1,
|
|
400
|
-
isSubmitting: !1,
|
|
401
|
-
isSubmitSuccessful: !1,
|
|
402
|
-
isValid: !1,
|
|
403
|
-
touchedFields: {},
|
|
404
|
-
dirtyFields: {},
|
|
405
|
-
validatingFields: {},
|
|
406
|
-
errors: s.errors || {},
|
|
407
|
-
disabled: s.disabled || !1
|
|
408
|
-
}, a = {}, u = S(s.defaultValues) || S(s.values) ? C(s.defaultValues || s.values) || {} : {}, n = s.shouldUnregister ? {} : C(u), f = {
|
|
409
|
-
action: !1,
|
|
410
|
-
mount: !1,
|
|
411
|
-
watch: !1,
|
|
412
|
-
keepIsValid: !1
|
|
413
|
-
}, c = {
|
|
414
|
-
mount: /* @__PURE__ */ new Set(),
|
|
415
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
416
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
417
|
-
array: /* @__PURE__ */ new Set(),
|
|
418
|
-
watch: /* @__PURE__ */ new Set()
|
|
419
|
-
}, R, k = 0;
|
|
420
|
-
const W = {
|
|
421
|
-
isDirty: !1,
|
|
422
|
-
dirtyFields: !1,
|
|
423
|
-
validatingFields: !1,
|
|
424
|
-
touchedFields: !1,
|
|
425
|
-
isValidating: !1,
|
|
426
|
-
isValid: !1,
|
|
427
|
-
errors: !1
|
|
428
|
-
}, b = {
|
|
429
|
-
...W
|
|
430
|
-
};
|
|
431
|
-
let w = {
|
|
432
|
-
...b
|
|
433
|
-
};
|
|
434
|
-
const v = {
|
|
435
|
-
array: je(),
|
|
436
|
-
state: je()
|
|
437
|
-
}, Y = s.criteriaMode === K.all, I = (t) => (i) => {
|
|
438
|
-
clearTimeout(k), k = setTimeout(t, i);
|
|
439
|
-
}, J = async (t) => {
|
|
440
|
-
if (!f.keepIsValid && !s.disabled && (b.isValid || w.isValid || t)) {
|
|
441
|
-
let i;
|
|
442
|
-
s.resolver ? (i = M((await te()).errors), q()) : i = await $(a, !0), i !== r.isValid && v.state.next({
|
|
443
|
-
isValid: i
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}, q = (t, i) => {
|
|
447
|
-
!s.disabled && (b.isValidating || b.validatingFields || w.isValidating || w.validatingFields) && ((t || Array.from(c.mount)).forEach((l) => {
|
|
448
|
-
l && (i ? x(r.validatingFields, l, i) : E(r.validatingFields, l));
|
|
449
|
-
}), v.state.next({
|
|
450
|
-
validatingFields: r.validatingFields,
|
|
451
|
-
isValidating: !M(r.validatingFields)
|
|
452
|
-
}));
|
|
453
|
-
}, _ = (t, i = [], l, y, d = !0, o = !0) => {
|
|
454
|
-
if (y && l && !s.disabled) {
|
|
455
|
-
if (f.action = !0, o && Array.isArray(h(a, t))) {
|
|
456
|
-
const g = l(h(a, t), y.argA, y.argB);
|
|
457
|
-
d && x(a, t, g);
|
|
458
|
-
}
|
|
459
|
-
if (o && Array.isArray(h(r.errors, t))) {
|
|
460
|
-
const g = l(h(r.errors, t), y.argA, y.argB);
|
|
461
|
-
d && x(r.errors, t, g), Nt(r.errors, t);
|
|
462
|
-
}
|
|
463
|
-
if ((b.touchedFields || w.touchedFields) && o && Array.isArray(h(r.touchedFields, t))) {
|
|
464
|
-
const g = l(h(r.touchedFields, t), y.argA, y.argB);
|
|
465
|
-
d && x(r.touchedFields, t, g);
|
|
466
|
-
}
|
|
467
|
-
(b.dirtyFields || w.dirtyFields) && (r.dirtyFields = ne(u, n)), v.state.next({
|
|
468
|
-
name: t,
|
|
469
|
-
isDirty: V(t, i),
|
|
470
|
-
dirtyFields: r.dirtyFields,
|
|
471
|
-
errors: r.errors,
|
|
472
|
-
isValid: r.isValid
|
|
473
|
-
});
|
|
474
|
-
} else
|
|
475
|
-
x(n, t, i);
|
|
476
|
-
}, Q = (t, i) => {
|
|
477
|
-
x(r.errors, t, i), v.state.next({
|
|
478
|
-
errors: r.errors
|
|
479
|
-
});
|
|
480
|
-
}, X = (t) => {
|
|
481
|
-
r.errors = t, v.state.next({
|
|
482
|
-
errors: r.errors,
|
|
483
|
-
isValid: !1
|
|
484
|
-
});
|
|
485
|
-
}, O = (t, i, l, y) => {
|
|
486
|
-
const d = h(a, t);
|
|
487
|
-
if (d) {
|
|
488
|
-
const o = h(n, t, D(l) ? h(u, t) : l);
|
|
489
|
-
D(o) || y && y.defaultChecked || i ? x(n, t, i ? o : Je(d._f)) : L(t, o), f.mount && !f.action && J();
|
|
490
|
-
}
|
|
491
|
-
}, le = (t, i, l, y, d) => {
|
|
492
|
-
let o = !1, g = !1;
|
|
493
|
-
const m = {
|
|
494
|
-
name: t
|
|
495
|
-
};
|
|
496
|
-
if (!s.disabled) {
|
|
497
|
-
if (!l || y) {
|
|
498
|
-
(b.isDirty || w.isDirty) && (g = r.isDirty, r.isDirty = m.isDirty = V(), o = g !== m.isDirty);
|
|
499
|
-
const A = ee(h(u, t), i);
|
|
500
|
-
g = !!h(r.dirtyFields, t), A ? E(r.dirtyFields, t) : x(r.dirtyFields, t, !0), m.dirtyFields = r.dirtyFields, o = o || (b.dirtyFields || w.dirtyFields) && g !== !A;
|
|
501
|
-
}
|
|
502
|
-
if (l) {
|
|
503
|
-
const A = h(r.touchedFields, t);
|
|
504
|
-
A || (x(r.touchedFields, t, l), m.touchedFields = r.touchedFields, o = o || (b.touchedFields || w.touchedFields) && A !== l);
|
|
505
|
-
}
|
|
506
|
-
o && d && v.state.next(m);
|
|
507
|
-
}
|
|
508
|
-
return o ? m : {};
|
|
509
|
-
}, ge = (t, i, l, y) => {
|
|
510
|
-
const d = h(r.errors, t), o = (b.isValid || w.isValid) && z(i) && r.isValid !== i;
|
|
511
|
-
if (s.delayError && l ? (R = I(() => Q(t, l)), R(s.delayError)) : (clearTimeout(k), R = null, l ? x(r.errors, t, l) : E(r.errors, t)), (l ? !ee(d, l) : d) || !M(y) || o) {
|
|
512
|
-
const g = {
|
|
513
|
-
...y,
|
|
514
|
-
...o && z(i) ? { isValid: i } : {},
|
|
515
|
-
errors: r.errors,
|
|
516
|
-
name: t
|
|
517
|
-
};
|
|
518
|
-
r = {
|
|
519
|
-
...r,
|
|
520
|
-
...g
|
|
521
|
-
}, v.state.next(g);
|
|
522
|
-
}
|
|
523
|
-
}, te = async (t) => (q(t, !0), await s.resolver(n, s.context, Rt(t || c.mount, a, s.criteriaMode, s.shouldUseNativeValidation))), ie = async (t) => {
|
|
524
|
-
const { errors: i } = await te(t);
|
|
525
|
-
if (q(t), t)
|
|
526
|
-
for (const l of t) {
|
|
527
|
-
const y = h(i, l);
|
|
528
|
-
y ? x(r.errors, l, y) : E(r.errors, l);
|
|
529
|
-
}
|
|
530
|
-
else
|
|
531
|
-
r.errors = i;
|
|
532
|
-
return i;
|
|
533
|
-
}, $ = async (t, i, l = {
|
|
534
|
-
valid: !0
|
|
535
|
-
}) => {
|
|
536
|
-
for (const y in t) {
|
|
537
|
-
const d = t[y];
|
|
538
|
-
if (d) {
|
|
539
|
-
const { _f: o, ...g } = d;
|
|
540
|
-
if (o) {
|
|
541
|
-
const m = c.array.has(o.name), A = d._f && Lt(d._f);
|
|
542
|
-
A && b.validatingFields && q([o.name], !0);
|
|
543
|
-
const U = await tt(d, c.disabled, n, Y, s.shouldUseNativeValidation && !i, m);
|
|
544
|
-
if (A && b.validatingFields && q([o.name]), U[o.name] && (l.valid = !1, i || e.shouldUseNativeValidation))
|
|
545
|
-
break;
|
|
546
|
-
!i && (h(U, o.name) ? m ? Bt(r.errors, U, o.name) : x(r.errors, o.name, U[o.name]) : E(r.errors, o.name));
|
|
547
|
-
}
|
|
548
|
-
!M(g) && await $(g, i, l);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
return l.valid;
|
|
552
|
-
}, ve = () => {
|
|
553
|
-
for (const t of c.unMount) {
|
|
554
|
-
const i = h(a, t);
|
|
555
|
-
i && (i._f.refs ? i._f.refs.every((l) => !De(l)) : !De(i._f.ref)) && Fe(t);
|
|
556
|
-
}
|
|
557
|
-
c.unMount = /* @__PURE__ */ new Set();
|
|
558
|
-
}, V = (t, i) => !s.disabled && (t && i && x(n, t, i), !ee(Le(), u)), F = (t, i, l) => kt(t, c, {
|
|
559
|
-
...f.mount ? n : D(i) ? u : p(t) ? { [t]: i } : i
|
|
560
|
-
}, l, i), T = (t) => Oe(h(f.mount ? n : u, t, s.shouldUnregister ? h(u, t, []) : [])), L = (t, i, l = {}) => {
|
|
561
|
-
const y = h(a, t);
|
|
562
|
-
let d = i;
|
|
563
|
-
if (y) {
|
|
564
|
-
const o = y._f;
|
|
565
|
-
o && (!o.disabled && x(n, t, lt(i, o)), d = be(o.ref) && P(i) ? "" : i, it(o.ref) ? [...o.ref.options].forEach((g) => g.selected = d.includes(g.value)) : o.refs ? he(o.ref) ? o.refs.forEach((g) => {
|
|
566
|
-
(!g.defaultChecked || !g.disabled) && (Array.isArray(d) ? g.checked = !!d.find((m) => m === g.value) : g.checked = d === g.value || !!d);
|
|
567
|
-
}) : o.refs.forEach((g) => g.checked = g.value === d) : Ce(o.ref) ? o.ref.value = "" : (o.ref.value = d, o.ref.type || v.state.next({
|
|
568
|
-
name: t,
|
|
569
|
-
values: C(n)
|
|
570
|
-
})));
|
|
571
|
-
}
|
|
572
|
-
(l.shouldDirty || l.shouldTouch) && le(t, d, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && fe(t);
|
|
573
|
-
}, H = (t, i, l) => {
|
|
574
|
-
for (const y in i) {
|
|
575
|
-
if (!i.hasOwnProperty(y))
|
|
576
|
-
return;
|
|
577
|
-
const d = i[y], o = t + "." + y, g = h(a, o);
|
|
578
|
-
(c.array.has(t) || S(d) || g && !g._f) && !se(d) ? H(o, d, l) : L(o, d, l);
|
|
579
|
-
}
|
|
580
|
-
}, N = (t, i, l = {}) => {
|
|
581
|
-
const y = h(a, t), d = c.array.has(t), o = C(i);
|
|
582
|
-
x(n, t, o), d ? (v.array.next({
|
|
583
|
-
name: t,
|
|
584
|
-
values: C(n)
|
|
585
|
-
}), (b.isDirty || b.dirtyFields || w.isDirty || w.dirtyFields) && l.shouldDirty && v.state.next({
|
|
586
|
-
name: t,
|
|
587
|
-
dirtyFields: ne(u, n),
|
|
588
|
-
isDirty: V(t, o)
|
|
589
|
-
})) : y && !y._f && !P(o) ? H(t, o, l) : L(t, o, l), Ze(t, c) ? v.state.next({
|
|
590
|
-
...r,
|
|
591
|
-
name: t,
|
|
592
|
-
values: C(n)
|
|
593
|
-
}) : v.state.next({
|
|
594
|
-
name: f.mount ? t : void 0,
|
|
595
|
-
values: C(n)
|
|
596
|
-
});
|
|
597
|
-
}, ue = async (t) => {
|
|
598
|
-
f.mount = !0;
|
|
599
|
-
const i = t.target;
|
|
600
|
-
let l = i.name, y = !0;
|
|
601
|
-
const d = h(a, l), o = (A) => {
|
|
602
|
-
y = Number.isNaN(A) || se(A) && isNaN(A.getTime()) || ee(A, h(n, l, A));
|
|
603
|
-
}, g = Qe(s.mode), m = Qe(s.reValidateMode);
|
|
604
|
-
if (d) {
|
|
605
|
-
let A, U;
|
|
606
|
-
const re = i.type ? Je(d._f) : _t(t), G = t.type === He.BLUR || t.type === He.FOCUS_OUT, vt = !Ut(d._f) && !s.resolver && !h(r.errors, l) && !d._f.deps || It(G, h(r.touchedFields, l), r.isSubmitted, m, g), xe = Ze(l, c, G);
|
|
607
|
-
x(n, l, re), G ? (!i || !i.readOnly) && (d._f.onBlur && d._f.onBlur(t), R && R(0)) : d._f.onChange && d._f.onChange(t);
|
|
608
|
-
const we = le(l, re, G), bt = !M(we) || xe;
|
|
609
|
-
if (!G && v.state.next({
|
|
610
|
-
name: l,
|
|
611
|
-
type: t.type,
|
|
612
|
-
values: C(n)
|
|
613
|
-
}), vt)
|
|
614
|
-
return (b.isValid || w.isValid) && (s.mode === "onBlur" ? G && J() : G || J()), bt && v.state.next({ name: l, ...xe ? {} : we });
|
|
615
|
-
if (!G && xe && v.state.next({ ...r }), s.resolver) {
|
|
616
|
-
const { errors: $e } = await te([l]);
|
|
617
|
-
if (q([l]), o(re), y) {
|
|
618
|
-
const Vt = Ge(r.errors, a, l), We = Ge($e, a, Vt.name || l);
|
|
619
|
-
A = We.error, l = We.name, U = M($e);
|
|
620
|
-
}
|
|
621
|
-
} else
|
|
622
|
-
q([l], !0), A = (await tt(d, c.disabled, n, Y, s.shouldUseNativeValidation))[l], q([l]), o(re), y && (A ? U = !1 : (b.isValid || w.isValid) && (U = await $(a, !0)));
|
|
623
|
-
y && (d._f.deps && (!Array.isArray(d._f.deps) || d._f.deps.length > 0) && fe(d._f.deps), ge(l, U, A, we));
|
|
624
|
-
}
|
|
625
|
-
}, oe = (t, i) => {
|
|
626
|
-
if (h(r.errors, i) && t.focus)
|
|
627
|
-
return t.focus(), 1;
|
|
628
|
-
}, fe = async (t, i = {}) => {
|
|
629
|
-
let l, y;
|
|
630
|
-
const d = ce(t);
|
|
631
|
-
if (s.resolver) {
|
|
632
|
-
const o = await ie(D(t) ? t : d);
|
|
633
|
-
l = M(o), y = t ? !d.some((g) => h(o, g)) : l;
|
|
634
|
-
} else t ? (y = (await Promise.all(d.map(async (o) => {
|
|
635
|
-
const g = h(a, o);
|
|
636
|
-
return await $(g && g._f ? { [o]: g } : g);
|
|
637
|
-
}))).every(Boolean), !(!y && !r.isValid) && J()) : y = l = await $(a);
|
|
638
|
-
return v.state.next({
|
|
639
|
-
...!p(t) || (b.isValid || w.isValid) && l !== r.isValid ? {} : { name: t },
|
|
640
|
-
...s.resolver || !t ? { isValid: l } : {},
|
|
641
|
-
errors: r.errors
|
|
642
|
-
}), i.shouldFocus && !y && ye(a, oe, t ? d : c.mount), y;
|
|
643
|
-
}, Le = (t, i) => {
|
|
644
|
-
let l = {
|
|
645
|
-
...f.mount ? n : u
|
|
646
|
-
};
|
|
647
|
-
return i && (l = st(i.dirtyFields ? r.dirtyFields : r.touchedFields, l)), D(t) ? l : p(t) ? h(l, t) : t.map((y) => h(l, y));
|
|
648
|
-
}, Ue = (t, i) => ({
|
|
649
|
-
invalid: !!h((i || r).errors, t),
|
|
650
|
-
isDirty: !!h((i || r).dirtyFields, t),
|
|
651
|
-
error: h((i || r).errors, t),
|
|
652
|
-
isValidating: !!h(r.validatingFields, t),
|
|
653
|
-
isTouched: !!h((i || r).touchedFields, t)
|
|
654
|
-
}), ot = (t) => {
|
|
655
|
-
t && ce(t).forEach((i) => E(r.errors, i)), v.state.next({
|
|
656
|
-
errors: t ? r.errors : {}
|
|
657
|
-
});
|
|
658
|
-
}, Me = (t, i, l) => {
|
|
659
|
-
const y = (h(a, t, { _f: {} })._f || {}).ref, d = h(r.errors, t) || {}, { ref: o, message: g, type: m, ...A } = d;
|
|
660
|
-
x(r.errors, t, {
|
|
661
|
-
...A,
|
|
662
|
-
...i,
|
|
663
|
-
ref: y
|
|
664
|
-
}), v.state.next({
|
|
665
|
-
name: t,
|
|
666
|
-
errors: r.errors,
|
|
667
|
-
isValid: !1
|
|
668
|
-
}), l && l.shouldFocus && y && y.focus && y.focus();
|
|
669
|
-
}, ft = (t, i) => j(t) ? v.state.subscribe({
|
|
670
|
-
next: (l) => "values" in l && t(F(void 0, i), l)
|
|
671
|
-
}) : F(t, i, !0), Pe = (t) => v.state.subscribe({
|
|
672
|
-
next: (i) => {
|
|
673
|
-
Pt(t.name, i.name, t.exact) && Mt(i, t.formState || b, gt, t.reRenderRoot) && t.callback({
|
|
674
|
-
values: { ...n },
|
|
675
|
-
...r,
|
|
676
|
-
...i,
|
|
677
|
-
defaultValues: u
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
}).unsubscribe, dt = (t) => (f.mount = !0, w = {
|
|
681
|
-
...w,
|
|
682
|
-
...t.formState
|
|
683
|
-
}, Pe({
|
|
684
|
-
...t,
|
|
685
|
-
formState: {
|
|
686
|
-
...W,
|
|
687
|
-
...t.formState
|
|
688
|
-
}
|
|
689
|
-
})), Fe = (t, i = {}) => {
|
|
690
|
-
for (const l of t ? ce(t) : c.mount)
|
|
691
|
-
c.mount.delete(l), c.array.delete(l), i.keepValue || (E(a, l), E(n, l)), !i.keepError && E(r.errors, l), !i.keepDirty && E(r.dirtyFields, l), !i.keepTouched && E(r.touchedFields, l), !i.keepIsValidating && E(r.validatingFields, l), !s.shouldUnregister && !i.keepDefaultValue && E(u, l);
|
|
692
|
-
v.state.next({
|
|
693
|
-
values: C(n)
|
|
694
|
-
}), v.state.next({
|
|
695
|
-
...r,
|
|
696
|
-
...i.keepDirty ? { isDirty: V() } : {}
|
|
697
|
-
}), !i.keepIsValid && J();
|
|
698
|
-
}, Ie = ({ disabled: t, name: i }) => {
|
|
699
|
-
(z(t) && f.mount || t || c.disabled.has(i)) && (t ? c.disabled.add(i) : c.disabled.delete(i));
|
|
700
|
-
}, me = (t, i = {}) => {
|
|
701
|
-
let l = h(a, t);
|
|
702
|
-
const y = z(i.disabled) || z(s.disabled);
|
|
703
|
-
return x(a, t, {
|
|
704
|
-
...l || {},
|
|
705
|
-
_f: {
|
|
706
|
-
...l && l._f ? l._f : { ref: { name: t } },
|
|
707
|
-
name: t,
|
|
708
|
-
mount: !0,
|
|
709
|
-
...i
|
|
710
|
-
}
|
|
711
|
-
}), c.mount.add(t), l ? Ie({
|
|
712
|
-
disabled: z(i.disabled) ? i.disabled : s.disabled,
|
|
713
|
-
name: t
|
|
714
|
-
}) : O(t, !0, i.value), {
|
|
715
|
-
...y ? { disabled: i.disabled || s.disabled } : {},
|
|
716
|
-
...s.progressive ? {
|
|
717
|
-
required: !!i.required,
|
|
718
|
-
min: de(i.min),
|
|
719
|
-
max: de(i.max),
|
|
720
|
-
minLength: de(i.minLength),
|
|
721
|
-
maxLength: de(i.maxLength),
|
|
722
|
-
pattern: de(i.pattern)
|
|
723
|
-
} : {},
|
|
724
|
-
name: t,
|
|
725
|
-
onChange: ue,
|
|
726
|
-
onBlur: ue,
|
|
727
|
-
ref: (d) => {
|
|
728
|
-
if (d) {
|
|
729
|
-
me(t, i), l = h(a, t);
|
|
730
|
-
const o = D(d.value) && d.querySelectorAll && d.querySelectorAll("input,select,textarea")[0] || d, g = St(o), m = l._f.refs || [];
|
|
731
|
-
if (g ? m.find((A) => A === o) : o === l._f.ref)
|
|
732
|
-
return;
|
|
733
|
-
x(a, t, {
|
|
734
|
-
_f: {
|
|
735
|
-
...l._f,
|
|
736
|
-
...g ? {
|
|
737
|
-
refs: [
|
|
738
|
-
...m.filter(De),
|
|
739
|
-
o,
|
|
740
|
-
...Array.isArray(h(u, t)) ? [{}] : []
|
|
741
|
-
],
|
|
742
|
-
ref: { type: o.type, name: t }
|
|
743
|
-
} : { ref: o }
|
|
744
|
-
}
|
|
745
|
-
}), O(t, !1, void 0, o);
|
|
746
|
-
} else
|
|
747
|
-
l = h(a, t, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || i.shouldUnregister) && !(mt(c.array, t) && f.action) && c.unMount.add(t);
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
}, Ae = () => s.shouldFocusError && ye(a, oe, c.mount), ct = (t) => {
|
|
751
|
-
z(t) && (v.state.next({ disabled: t }), ye(a, (i, l) => {
|
|
752
|
-
const y = h(a, l);
|
|
753
|
-
y && (i.disabled = y._f.disabled || t, Array.isArray(y._f.refs) && y._f.refs.forEach((d) => {
|
|
754
|
-
d.disabled = y._f.disabled || t;
|
|
755
|
-
}));
|
|
756
|
-
}, 0, !1));
|
|
757
|
-
}, Ne = (t, i) => async (l) => {
|
|
758
|
-
let y;
|
|
759
|
-
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
760
|
-
let d = C(n);
|
|
761
|
-
if (v.state.next({
|
|
762
|
-
isSubmitting: !0
|
|
763
|
-
}), s.resolver) {
|
|
764
|
-
const { errors: o, values: g } = await te();
|
|
765
|
-
q(), r.errors = o, d = C(g);
|
|
766
|
-
} else
|
|
767
|
-
await $(a);
|
|
768
|
-
if (c.disabled.size)
|
|
769
|
-
for (const o of c.disabled)
|
|
770
|
-
E(d, o);
|
|
771
|
-
if (E(r.errors, "root"), M(r.errors)) {
|
|
772
|
-
v.state.next({
|
|
773
|
-
errors: {}
|
|
774
|
-
});
|
|
775
|
-
try {
|
|
776
|
-
await t(d, l);
|
|
777
|
-
} catch (o) {
|
|
778
|
-
y = o;
|
|
779
|
-
}
|
|
780
|
-
} else
|
|
781
|
-
i && await i({ ...r.errors }, l), Ae(), setTimeout(Ae);
|
|
782
|
-
if (v.state.next({
|
|
783
|
-
isSubmitted: !0,
|
|
784
|
-
isSubmitting: !1,
|
|
785
|
-
isSubmitSuccessful: M(r.errors) && !y,
|
|
786
|
-
submitCount: r.submitCount + 1,
|
|
787
|
-
errors: r.errors
|
|
788
|
-
}), y)
|
|
789
|
-
throw y;
|
|
790
|
-
}, yt = (t, i = {}) => {
|
|
791
|
-
h(a, t) && (D(i.defaultValue) ? N(t, C(h(u, t))) : (N(t, i.defaultValue), x(u, t, C(i.defaultValue))), i.keepTouched || E(r.touchedFields, t), i.keepDirty || (E(r.dirtyFields, t), r.isDirty = i.defaultValue ? V(t, C(h(u, t))) : V()), i.keepError || (E(r.errors, t), b.isValid && J()), v.state.next({ ...r }));
|
|
792
|
-
}, Be = (t, i = {}) => {
|
|
793
|
-
const l = t ? C(t) : u, y = C(l), d = M(t), o = d ? u : y;
|
|
794
|
-
if (i.keepDefaultValues || (u = l), !i.keepValues) {
|
|
795
|
-
if (i.keepDirtyValues) {
|
|
796
|
-
const g = /* @__PURE__ */ new Set([
|
|
797
|
-
...c.mount,
|
|
798
|
-
...Object.keys(ne(u, n))
|
|
799
|
-
]);
|
|
800
|
-
for (const m of Array.from(g)) {
|
|
801
|
-
const A = h(r.dirtyFields, m), U = h(n, m), re = h(o, m);
|
|
802
|
-
A && !D(U) ? x(o, m, U) : !A && !D(re) && N(m, re);
|
|
803
|
-
}
|
|
804
|
-
} else {
|
|
805
|
-
if (Se && D(t))
|
|
806
|
-
for (const g of c.mount) {
|
|
807
|
-
const m = h(a, g);
|
|
808
|
-
if (m && m._f) {
|
|
809
|
-
const A = Array.isArray(m._f.refs) ? m._f.refs[0] : m._f.ref;
|
|
810
|
-
if (be(A)) {
|
|
811
|
-
const U = A.closest("form");
|
|
812
|
-
if (U) {
|
|
813
|
-
U.reset();
|
|
814
|
-
break;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
if (i.keepFieldsRef)
|
|
820
|
-
for (const g of c.mount)
|
|
821
|
-
N(g, h(o, g));
|
|
822
|
-
else
|
|
823
|
-
a = {};
|
|
824
|
-
}
|
|
825
|
-
n = s.shouldUnregister ? i.keepDefaultValues ? C(u) : {} : C(o), v.array.next({
|
|
826
|
-
values: { ...o }
|
|
827
|
-
}), v.state.next({
|
|
828
|
-
values: { ...o }
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
c = {
|
|
832
|
-
mount: i.keepDirtyValues ? c.mount : /* @__PURE__ */ new Set(),
|
|
833
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
834
|
-
array: /* @__PURE__ */ new Set(),
|
|
835
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
836
|
-
watch: /* @__PURE__ */ new Set(),
|
|
837
|
-
watchAll: !1,
|
|
838
|
-
focus: ""
|
|
839
|
-
}, f.mount = !b.isValid || !!i.keepIsValid || !!i.keepDirtyValues || !s.shouldUnregister && !M(o), f.watch = !!s.shouldUnregister, f.keepIsValid = !!i.keepIsValid, f.action = !1, i.keepErrors || (r.errors = {}), v.state.next({
|
|
840
|
-
submitCount: i.keepSubmitCount ? r.submitCount : 0,
|
|
841
|
-
isDirty: d ? !1 : i.keepDirty ? r.isDirty : !!(i.keepDefaultValues && !ee(t, u)),
|
|
842
|
-
isSubmitted: i.keepIsSubmitted ? r.isSubmitted : !1,
|
|
843
|
-
dirtyFields: d ? {} : i.keepDirtyValues ? i.keepDefaultValues && n ? ne(u, n) : r.dirtyFields : i.keepDefaultValues && t ? ne(u, t) : i.keepDirty ? r.dirtyFields : {},
|
|
844
|
-
touchedFields: i.keepTouched ? r.touchedFields : {},
|
|
845
|
-
errors: i.keepErrors ? r.errors : {},
|
|
846
|
-
isSubmitSuccessful: i.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
847
|
-
isSubmitting: !1,
|
|
848
|
-
defaultValues: u
|
|
849
|
-
});
|
|
850
|
-
}, pe = (t, i) => Be(j(t) ? t(n) : t, { ...s.resetOptions, ...i }), ht = (t, i = {}) => {
|
|
851
|
-
const l = h(a, t), y = l && l._f;
|
|
852
|
-
if (y) {
|
|
853
|
-
const d = y.refs ? y.refs[0] : y.ref;
|
|
854
|
-
d.focus && setTimeout(() => {
|
|
855
|
-
d.focus(), i.shouldSelect && j(d.select) && d.select();
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
}, gt = (t) => {
|
|
859
|
-
r = {
|
|
860
|
-
...r,
|
|
861
|
-
...t
|
|
862
|
-
};
|
|
863
|
-
}, qe = {
|
|
864
|
-
control: {
|
|
865
|
-
register: me,
|
|
866
|
-
unregister: Fe,
|
|
867
|
-
getFieldState: Ue,
|
|
868
|
-
handleSubmit: Ne,
|
|
869
|
-
setError: Me,
|
|
870
|
-
_subscribe: Pe,
|
|
871
|
-
_runSchema: te,
|
|
872
|
-
_updateIsValidating: q,
|
|
873
|
-
_focusError: Ae,
|
|
874
|
-
_getWatch: F,
|
|
875
|
-
_getDirty: V,
|
|
876
|
-
_setValid: J,
|
|
877
|
-
_setFieldArray: _,
|
|
878
|
-
_setDisabledField: Ie,
|
|
879
|
-
_setErrors: X,
|
|
880
|
-
_getFieldArray: T,
|
|
881
|
-
_reset: Be,
|
|
882
|
-
_resetDefaultValues: () => j(s.defaultValues) && s.defaultValues().then((t) => {
|
|
883
|
-
pe(t, s.resetOptions), v.state.next({
|
|
884
|
-
isLoading: !1
|
|
885
|
-
});
|
|
886
|
-
}),
|
|
887
|
-
_removeUnmounted: ve,
|
|
888
|
-
_disableForm: ct,
|
|
889
|
-
_subjects: v,
|
|
890
|
-
_proxyFormState: b,
|
|
891
|
-
get _fields() {
|
|
892
|
-
return a;
|
|
893
|
-
},
|
|
894
|
-
get _formValues() {
|
|
895
|
-
return n;
|
|
896
|
-
},
|
|
897
|
-
get _state() {
|
|
898
|
-
return f;
|
|
899
|
-
},
|
|
900
|
-
set _state(t) {
|
|
901
|
-
f = t;
|
|
902
|
-
},
|
|
903
|
-
get _defaultValues() {
|
|
904
|
-
return u;
|
|
905
|
-
},
|
|
906
|
-
get _names() {
|
|
907
|
-
return c;
|
|
908
|
-
},
|
|
909
|
-
set _names(t) {
|
|
910
|
-
c = t;
|
|
911
|
-
},
|
|
912
|
-
get _formState() {
|
|
913
|
-
return r;
|
|
914
|
-
},
|
|
915
|
-
get _options() {
|
|
916
|
-
return s;
|
|
917
|
-
},
|
|
918
|
-
set _options(t) {
|
|
919
|
-
s = {
|
|
920
|
-
...s,
|
|
921
|
-
...t
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
},
|
|
925
|
-
subscribe: dt,
|
|
926
|
-
trigger: fe,
|
|
927
|
-
register: me,
|
|
928
|
-
handleSubmit: Ne,
|
|
929
|
-
watch: ft,
|
|
930
|
-
setValue: N,
|
|
931
|
-
getValues: Le,
|
|
932
|
-
reset: pe,
|
|
933
|
-
resetField: yt,
|
|
934
|
-
clearErrors: ot,
|
|
935
|
-
unregister: Fe,
|
|
936
|
-
setError: Me,
|
|
937
|
-
setFocus: ht,
|
|
938
|
-
getFieldState: Ue
|
|
939
|
-
};
|
|
940
|
-
return {
|
|
941
|
-
...qe,
|
|
942
|
-
formControl: qe
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
function jt(e = {}) {
|
|
946
|
-
const s = B.useRef(void 0), r = B.useRef(void 0), [a, u] = B.useState({
|
|
947
|
-
isDirty: !1,
|
|
948
|
-
isValidating: !1,
|
|
949
|
-
isLoading: j(e.defaultValues),
|
|
950
|
-
isSubmitted: !1,
|
|
951
|
-
isSubmitting: !1,
|
|
952
|
-
isSubmitSuccessful: !1,
|
|
953
|
-
isValid: !1,
|
|
954
|
-
submitCount: 0,
|
|
955
|
-
dirtyFields: {},
|
|
956
|
-
touchedFields: {},
|
|
957
|
-
validatingFields: {},
|
|
958
|
-
errors: e.errors || {},
|
|
959
|
-
disabled: e.disabled || !1,
|
|
960
|
-
isReady: !1,
|
|
961
|
-
defaultValues: j(e.defaultValues) ? void 0 : e.defaultValues
|
|
962
|
-
});
|
|
963
|
-
if (!s.current)
|
|
964
|
-
if (e.formControl)
|
|
965
|
-
s.current = {
|
|
966
|
-
...e.formControl,
|
|
967
|
-
formState: a
|
|
968
|
-
}, e.defaultValues && !j(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
969
|
-
else {
|
|
970
|
-
const { formControl: f, ...c } = qt(e);
|
|
971
|
-
s.current = {
|
|
972
|
-
...c,
|
|
973
|
-
formState: a
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
const n = s.current.control;
|
|
977
|
-
return n._options = e, Dt(() => {
|
|
978
|
-
const f = n._subscribe({
|
|
979
|
-
formState: n._proxyFormState,
|
|
980
|
-
callback: () => u({ ...n._formState }),
|
|
981
|
-
reRenderRoot: !0
|
|
982
|
-
});
|
|
983
|
-
return u((c) => ({
|
|
984
|
-
...c,
|
|
985
|
-
isReady: !0
|
|
986
|
-
})), n._formState.isReady = !0, f;
|
|
987
|
-
}, [n]), B.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), B.useEffect(() => {
|
|
988
|
-
e.mode && (n._options.mode = e.mode), e.reValidateMode && (n._options.reValidateMode = e.reValidateMode);
|
|
989
|
-
}, [n, e.mode, e.reValidateMode]), B.useEffect(() => {
|
|
990
|
-
e.errors && (n._setErrors(e.errors), n._focusError());
|
|
991
|
-
}, [n, e.errors]), B.useEffect(() => {
|
|
992
|
-
e.shouldUnregister && n._subjects.state.next({
|
|
993
|
-
values: n._getWatch()
|
|
994
|
-
});
|
|
995
|
-
}, [n, e.shouldUnregister]), B.useEffect(() => {
|
|
996
|
-
if (n._proxyFormState.isDirty) {
|
|
997
|
-
const f = n._getDirty();
|
|
998
|
-
f !== a.isDirty && n._subjects.state.next({
|
|
999
|
-
isDirty: f
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
}, [n, a.isDirty]), B.useEffect(() => {
|
|
1003
|
-
var f;
|
|
1004
|
-
e.values && !ee(e.values, r.current) ? (n._reset(e.values, {
|
|
1005
|
-
keepFieldsRef: !0,
|
|
1006
|
-
...n._options.resetOptions
|
|
1007
|
-
}), !((f = n._options.resetOptions) === null || f === void 0) && f.keepIsValid || n._setValid(), r.current = e.values, u((c) => ({ ...c }))) : n._resetDefaultValues();
|
|
1008
|
-
}, [n, e.values]), B.useEffect(() => {
|
|
1009
|
-
n._state.mount || (n._setValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
|
|
1010
|
-
}), s.current.formState = wt(a, n), s.current;
|
|
1011
|
-
}
|
|
1012
|
-
function $t(e, s) {
|
|
1013
|
-
const r = [];
|
|
1014
|
-
if (e.required && (s == null || s === "" || Array.isArray(s) && s.length === 0))
|
|
1015
|
-
return r.push(`${e.label} is required`), { valid: !1, errors: r };
|
|
1016
|
-
if (s == null || s === "")
|
|
1017
|
-
return { valid: !0, errors: [] };
|
|
1018
|
-
if ("length" in e && typeof e.length == "number" && typeof s == "string" && s.length > e.length && r.push(`${e.label} must be at most ${e.length} characters`), "integerPart" in e && typeof s == "number") {
|
|
1019
|
-
const a = Math.floor(Math.abs(s)), u = e.integerPart ?? 9;
|
|
1020
|
-
a.toString().length > u && r.push(`${e.label} integer part must be at most ${u} digits`);
|
|
1021
|
-
const n = e.fractionPart;
|
|
1022
|
-
n !== void 0 && (s.toString().split(".")[1] ?? "").length > n && r.push(`${e.label} can have at most ${n} decimal places`);
|
|
1023
|
-
}
|
|
1024
|
-
return r.length > 0 ? { valid: !1, errors: r } : { valid: !0, errors: [] };
|
|
1025
|
-
}
|
|
1026
|
-
function Kt(e, s) {
|
|
1027
|
-
return async (r, a, u) => {
|
|
1028
|
-
var R;
|
|
1029
|
-
const n = {}, f = e.getFields(), c = (u == null ? void 0 : u.names) ?? Object.keys(f);
|
|
1030
|
-
for (const k of c) {
|
|
1031
|
-
if (k === "_id" || (R = f[k]) != null && R.readOnly) continue;
|
|
1032
|
-
const W = f[k];
|
|
1033
|
-
if (!W) continue;
|
|
1034
|
-
let b = r[k];
|
|
1035
|
-
if ("integerPart" in W && typeof b == "string" && b !== "") {
|
|
1036
|
-
const v = Number(b);
|
|
1037
|
-
isNaN(v) || (b = v, r[k] = v);
|
|
1038
|
-
}
|
|
1039
|
-
if (!W.required && (b == null || b === "" || Array.isArray(b) && b.length === 0))
|
|
1040
|
-
continue;
|
|
1041
|
-
const w = W.validate(b);
|
|
1042
|
-
if (!w.valid && w.errors.length > 0) {
|
|
1043
|
-
n[k] = {
|
|
1044
|
-
type: "validate",
|
|
1045
|
-
message: w.errors[0] || `${k} is invalid`
|
|
1046
|
-
};
|
|
1047
|
-
continue;
|
|
1048
|
-
}
|
|
1049
|
-
if ((s == null ? void 0 : s.enableConstraintValidation) !== !1) {
|
|
1050
|
-
const v = $t(W, b);
|
|
1051
|
-
if (!v.valid && v.errors.length > 0) {
|
|
1052
|
-
n[k] = {
|
|
1053
|
-
type: "constraint",
|
|
1054
|
-
message: v.errors[0]
|
|
1055
|
-
};
|
|
1056
|
-
continue;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
if (e.hasMetadata()) {
|
|
1060
|
-
const v = e.validateFieldExpression(
|
|
1061
|
-
k,
|
|
1062
|
-
b,
|
|
1063
|
-
r
|
|
1064
|
-
);
|
|
1065
|
-
!v.valid && v.errors.length > 0 && (n[k] = {
|
|
1066
|
-
type: "validate",
|
|
1067
|
-
message: v.errors[0]
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
return Object.keys(n).length === 0 ? { values: r, errors: {} } : { values: {}, errors: n };
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
export {
|
|
1075
|
-
Kt as c,
|
|
1076
|
-
jt as u,
|
|
1077
|
-
$t as v
|
|
1078
|
-
};
|