@ram_28/kf-ai-sdk 2.0.14 → 2.0.15
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 +2 -1
- package/dist/FileField-BWrSHNRq.js +296 -0
- package/dist/FileField-eDeuzln8.cjs +1 -0
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +228 -472
- package/dist/{client-DnO2KKrw.cjs → client-D5k4SYuw.cjs} +1 -1
- package/dist/{client-iQTqFDNI.js → client-_ayziI1d.js} +33 -32
- package/dist/components/hooks/index.d.ts +9 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/{workflow/components → components/hooks}/useActivityForm/createActivityItemProxy.d.ts +9 -5
- package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts +23 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/index.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/types.d.ts +11 -7
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/useActivityForm.d.ts +2 -2
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/index.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/types.d.ts +36 -0
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/index.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/types.d.ts +26 -0
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -0
- package/dist/components/hooks/useTable/index.d.ts +2 -2
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +11 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/createResolver-AIgUwoS6.cjs +1 -0
- package/dist/createResolver-ZHXQ7QMa.js +1078 -0
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +252 -314
- package/dist/{metadata-DpfI3zRN.js → metadata-Cc1mBcLS.js} +1 -1
- package/dist/{metadata-DgLSJkF5.cjs → metadata-DWXQPDav.cjs} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.mjs +16 -192
- package/dist/table.types.d.ts +2 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/base-fields.d.ts +4 -4
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/useTable-CeRklbdT.cjs +1 -0
- package/dist/useTable-DS0-WInw.js +203 -0
- package/dist/workflow/Activity.d.ts +9 -9
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/client.d.ts.map +1 -1
- package/dist/workflow/createFieldFromMeta.d.ts +29 -0
- package/dist/workflow/createFieldFromMeta.d.ts.map +1 -0
- package/dist/workflow/index.d.ts +1 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +12 -12
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.d.ts +5 -2
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.mjs +716 -338
- package/dist/workflow.types.d.ts +1 -0
- package/dist/workflow.types.d.ts.map +1 -1
- package/docs/gaps.md +410 -0
- package/docs/useActivityTable.md +481 -0
- package/docs/useBDOTable.md +317 -0
- package/docs/workflow.md +143 -34
- package/package.json +1 -1
- package/sdk/bdo/fields/UserField.ts +1 -1
- package/sdk/components/hooks/index.ts +28 -5
- package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +400 -0
- package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +87 -0
- package/sdk/{workflow/components → components/hooks}/useActivityForm/types.ts +21 -8
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +628 -0
- package/sdk/components/hooks/useActivityTable/index.ts +8 -0
- package/sdk/components/hooks/useActivityTable/types.ts +45 -0
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +71 -0
- package/sdk/components/hooks/useBDOTable/index.ts +2 -0
- package/sdk/components/hooks/useBDOTable/types.ts +24 -0
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +15 -0
- package/sdk/components/hooks/useTable/index.ts +3 -3
- package/sdk/components/hooks/useTable/types.ts +16 -12
- package/sdk/components/hooks/useTable/useTable.ts +56 -49
- package/sdk/table.ts +4 -1
- package/sdk/table.types.ts +7 -4
- package/sdk/types/base-fields.ts +4 -4
- package/sdk/workflow/Activity.ts +14 -13
- package/sdk/workflow/client.ts +21 -8
- package/sdk/workflow/createFieldFromMeta.ts +110 -0
- package/sdk/workflow/index.ts +1 -6
- package/sdk/workflow/types.ts +13 -12
- package/sdk/workflow.ts +11 -2
- package/sdk/workflow.types.ts +7 -0
- package/dist/BaseField-B6da88U7.js +0 -40
- package/dist/BaseField-Drp0-OxL.cjs +0 -1
- package/dist/error-handling-CAoD0Kwb.cjs +0 -1
- package/dist/error-handling-CrhTtD88.js +0 -14
- package/dist/index.esm-Cj63v5ny.js +0 -1014
- package/dist/index.esm-DuwT11sx.cjs +0 -1
- package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts +0 -22
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/index.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/types.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/useActivityForm.d.ts.map +0 -1
- package/docs/useTable.md +0 -369
- package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +0 -130
- package/sdk/workflow/components/useActivityForm/createActivityResolver.ts +0 -61
- package/sdk/workflow/components/useActivityForm/useActivityForm.ts +0 -386
- /package/dist/{workflow/components → components/hooks}/useActivityForm/index.d.ts +0 -0
- /package/sdk/{workflow/components → components/hooks}/useActivityForm/index.ts +0 -0
|
@@ -1,1014 +0,0 @@
|
|
|
1
|
-
import P from "react";
|
|
2
|
-
var he = (e) => e.type === "checkbox", re = (e) => e instanceof Date, I = (e) => e == null;
|
|
3
|
-
const rt = (e) => typeof e == "object";
|
|
4
|
-
var k = (e) => !I(e) && !Array.isArray(e) && rt(e) && !re(e), _t = (e) => k(e) && e.target ? he(e.target) ? e.target.checked : e.target.value : e, Ft = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, At = (e, s) => e.has(Ft(s)), xt = (e) => {
|
|
5
|
-
const s = e.constructor && e.constructor.prototype;
|
|
6
|
-
return k(s) && s.hasOwnProperty("isPrototypeOf");
|
|
7
|
-
}, Se = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
8
|
-
function T(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 && !(k(e) && xt(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] = T(e[u]));
|
|
20
|
-
return a;
|
|
21
|
-
}
|
|
22
|
-
var _e = (e) => /^\w*$/.test(e), w = (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 || !k(e))
|
|
24
|
-
return r;
|
|
25
|
-
const a = (_e(s) ? [s] : Te(s)).reduce((u, n) => I(u) ? u : u[n], e);
|
|
26
|
-
return w(a) || a === e ? w(e[s]) ? r : e[s] : a;
|
|
27
|
-
}, K = (e) => typeof e == "boolean", H = (e) => typeof e == "function", m = (e, s, r) => {
|
|
28
|
-
let a = -1;
|
|
29
|
-
const u = _e(s) ? [s] : Te(s), n = u.length, d = n - 1;
|
|
30
|
-
for (; ++a < n; ) {
|
|
31
|
-
const y = u[a];
|
|
32
|
-
let U = r;
|
|
33
|
-
if (a !== d) {
|
|
34
|
-
const j = e[y];
|
|
35
|
-
U = k(j) || Array.isArray(j) ? j : isNaN(+u[a + 1]) ? {} : [];
|
|
36
|
-
}
|
|
37
|
-
if (y === "__proto__" || y === "constructor" || y === "prototype")
|
|
38
|
-
return;
|
|
39
|
-
e[y] = U, e = e[y];
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const $e = {
|
|
43
|
-
BLUR: "blur",
|
|
44
|
-
FOCUS_OUT: "focusout"
|
|
45
|
-
}, $ = {
|
|
46
|
-
onBlur: "onBlur",
|
|
47
|
-
onChange: "onChange",
|
|
48
|
-
onSubmit: "onSubmit",
|
|
49
|
-
onTouched: "onTouched",
|
|
50
|
-
all: "all"
|
|
51
|
-
}, X = {
|
|
52
|
-
max: "max",
|
|
53
|
-
min: "min",
|
|
54
|
-
maxLength: "maxLength",
|
|
55
|
-
minLength: "minLength",
|
|
56
|
-
pattern: "pattern",
|
|
57
|
-
required: "required",
|
|
58
|
-
validate: "validate"
|
|
59
|
-
}, mt = P.createContext(null);
|
|
60
|
-
mt.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 d = n;
|
|
69
|
-
return s._proxyFormState[d] !== $.all && (s._proxyFormState[d] = !a || $.all), e[d];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return u;
|
|
73
|
-
};
|
|
74
|
-
const Dt = typeof window < "u" ? P.useLayoutEffect : P.useEffect;
|
|
75
|
-
var B = (e) => typeof e == "string", kt = (e, s, r, a, u) => B(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) => I(e) || !rt(e);
|
|
76
|
-
function G(e, s, r = /* @__PURE__ */ new WeakSet()) {
|
|
77
|
-
if (ke(e) || ke(s))
|
|
78
|
-
return Object.is(e, s);
|
|
79
|
-
if (re(e) && re(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 d = e[n];
|
|
89
|
-
if (!u.includes(n))
|
|
90
|
-
return !1;
|
|
91
|
-
if (n !== "ref") {
|
|
92
|
-
const y = s[n];
|
|
93
|
-
if (re(d) && re(y) || k(d) && k(y) || Array.isArray(d) && Array.isArray(y) ? !G(d, y, r) : !Object.is(d, y))
|
|
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 && k(u) && n) {
|
|
131
|
-
const d = st(u, n);
|
|
132
|
-
k(d) && (r[a] = d);
|
|
133
|
-
} else e[a] && (r[a] = n);
|
|
134
|
-
}
|
|
135
|
-
return r;
|
|
136
|
-
}
|
|
137
|
-
var R = (e) => k(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", Le = (e) => e.type === "radio", St = (e) => Le(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 = w(e) ? a++ : e[s[a++]];
|
|
148
|
-
return e;
|
|
149
|
-
}
|
|
150
|
-
function Tt(e) {
|
|
151
|
-
for (const s in e)
|
|
152
|
-
if (e.hasOwnProperty(s) && !w(e[s]))
|
|
153
|
-
return !1;
|
|
154
|
-
return !0;
|
|
155
|
-
}
|
|
156
|
-
function D(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 && (k(a) && R(a) || Array.isArray(a) && Tt(a)) && D(e, r.slice(0, -1)), e;
|
|
159
|
-
}
|
|
160
|
-
var Ct = (e) => {
|
|
161
|
-
for (const s in e)
|
|
162
|
-
if (H(e[s]))
|
|
163
|
-
return !0;
|
|
164
|
-
return !1;
|
|
165
|
-
};
|
|
166
|
-
function at(e) {
|
|
167
|
-
return Array.isArray(e) || k(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])) : w(a) || (s[r] = !0);
|
|
173
|
-
}
|
|
174
|
-
return s;
|
|
175
|
-
}
|
|
176
|
-
function ae(e, s, r) {
|
|
177
|
-
r || (r = Ee(s));
|
|
178
|
-
for (const a in e) {
|
|
179
|
-
const u = e[a];
|
|
180
|
-
if (at(u))
|
|
181
|
-
w(s) || ke(r[a]) ? r[a] = Ee(u, Array.isArray(u) ? [] : {}) : ae(u, I(s) ? {} : s[a], r[a]);
|
|
182
|
-
else {
|
|
183
|
-
const n = s[a];
|
|
184
|
-
r[a] = !G(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 lt = (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 && !w(e[0].attributes.value) ? w(e[0].value) || e[0].value === "" ? ze : { value: e[0].value, isValid: !0 } : ze
|
|
202
|
-
) : Ke;
|
|
203
|
-
}
|
|
204
|
-
return Ke;
|
|
205
|
-
}, nt = (e, { valueAsNumber: s, valueAsDate: r, setValueAs: a }) => w(e) ? e : s ? e === "" ? NaN : e && +e : r && B(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 : Le(s) ? ut(e.refs).value : it(s) ? [...s.selectedOptions].map(({ value: r }) => r) : he(s) ? lt(e.refs).value : nt(w(s.value) ? e.ref.value : s.value, e);
|
|
217
|
-
}
|
|
218
|
-
var Lt = (e, s, r, a) => {
|
|
219
|
-
const u = {};
|
|
220
|
-
for (const n of e) {
|
|
221
|
-
const d = h(s, n);
|
|
222
|
-
d && m(u, n, d._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) => w(e) ? e : Ve(e) ? e.source : k(e) ? Ve(e.value) ? e.value.source : e.value : e, Qe = (e) => ({
|
|
231
|
-
isOnSubmit: !e || e === $.onSubmit,
|
|
232
|
-
isOnBlur: e === $.onBlur,
|
|
233
|
-
isOnChange: e === $.onChange,
|
|
234
|
-
isOnAll: e === $.all,
|
|
235
|
-
isOnTouch: e === $.onTouched
|
|
236
|
-
});
|
|
237
|
-
const Xe = "AsyncFunction";
|
|
238
|
-
var Rt = (e) => !!e && !!e.validate && !!(H(e.validate) && e.validate.constructor.name === Xe || k(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: d, ...y } = n;
|
|
244
|
-
if (d) {
|
|
245
|
-
if (d.refs && d.refs[0] && s(d.refs[0], u) && !a)
|
|
246
|
-
return !0;
|
|
247
|
-
if (d.ref && s(d.ref, d.name) && !a)
|
|
248
|
-
return !0;
|
|
249
|
-
if (ye(y, s))
|
|
250
|
-
break;
|
|
251
|
-
} else if (k(y) && ye(y, 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("."), d = h(s, n), y = h(e, n);
|
|
266
|
-
if (d && !Array.isArray(d) && r !== n)
|
|
267
|
-
return { name: r };
|
|
268
|
-
if (y && y.type)
|
|
269
|
-
return {
|
|
270
|
-
name: n,
|
|
271
|
-
error: y
|
|
272
|
-
};
|
|
273
|
-
if (y && y.root && y.root.type)
|
|
274
|
-
return {
|
|
275
|
-
name: `${n}.root`,
|
|
276
|
-
error: y.root
|
|
277
|
-
};
|
|
278
|
-
u.pop();
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
name: r
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
var It = (e, s, r, a) => {
|
|
285
|
-
r(e);
|
|
286
|
-
const { name: u, ...n } = e;
|
|
287
|
-
return R(n) || Object.keys(n).length >= Object.keys(s).length || Object.keys(n).find((d) => s[d] === (!a || $.all));
|
|
288
|
-
}, Mt = (e, s, r) => !e || !s || e === s || ce(e).some((a) => a && (r ? a === s : a.startsWith(s) || s.startsWith(a))), Nt = (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, Pt = (e, s) => !Oe(h(e, s)).length && D(e, s), Bt = (e, s, r) => {
|
|
289
|
-
const a = ce(h(e, r));
|
|
290
|
-
return m(a, "root", s[r]), m(e, r, a), e;
|
|
291
|
-
};
|
|
292
|
-
function et(e, s, r = "validate") {
|
|
293
|
-
if (B(e) || Array.isArray(e) && e.every(B) || K(e) && !e)
|
|
294
|
-
return {
|
|
295
|
-
type: r,
|
|
296
|
-
message: B(e) ? e : "",
|
|
297
|
-
ref: s
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
var ie = (e) => k(e) && !Ve(e) ? e : {
|
|
301
|
-
value: e,
|
|
302
|
-
message: ""
|
|
303
|
-
}, tt = async (e, s, r, a, u, n) => {
|
|
304
|
-
const { ref: d, refs: y, required: U, maxLength: j, minLength: le, min: x, max: E, pattern: b, validate: z, name: M, valueAsNumber: Y, mount: q } = e._f, V = h(r, M);
|
|
305
|
-
if (!q || s.has(M))
|
|
306
|
-
return {};
|
|
307
|
-
const J = y ? y[0] : d, Q = (v) => {
|
|
308
|
-
u && J.reportValidity && (J.setCustomValidity(K(v) ? "" : v || ""), J.reportValidity());
|
|
309
|
-
}, S = {}, ne = Le(d), ge = he(d), ee = ne || ge, se = (Y || Ce(d)) && w(d.value) && w(V) || be(d) && d.value === "" || V === "" || Array.isArray(V) && !V.length, W = Et.bind(null, M, a, S), ve = (v, _, O, C = X.maxLength, p = X.minLength) => {
|
|
310
|
-
const N = v ? _ : O;
|
|
311
|
-
S[M] = {
|
|
312
|
-
type: v ? C : p,
|
|
313
|
-
message: N,
|
|
314
|
-
ref: d,
|
|
315
|
-
...W(v ? C : p, N)
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
|
-
if (n ? !Array.isArray(V) || !V.length : U && (!ee && (se || I(V)) || K(V) && !V || ge && !lt(y).isValid || ne && !ut(y).isValid)) {
|
|
319
|
-
const { value: v, message: _ } = B(U) ? { value: !!U, message: U } : ie(U);
|
|
320
|
-
if (v && (S[M] = {
|
|
321
|
-
type: X.required,
|
|
322
|
-
message: _,
|
|
323
|
-
ref: J,
|
|
324
|
-
...W(X.required, _)
|
|
325
|
-
}, !a))
|
|
326
|
-
return Q(_), S;
|
|
327
|
-
}
|
|
328
|
-
if (!se && (!I(x) || !I(E))) {
|
|
329
|
-
let v, _;
|
|
330
|
-
const O = ie(E), C = ie(x);
|
|
331
|
-
if (!I(V) && !isNaN(V)) {
|
|
332
|
-
const p = d.valueAsNumber || V && +V;
|
|
333
|
-
I(O.value) || (v = p > O.value), I(C.value) || (_ = p < C.value);
|
|
334
|
-
} else {
|
|
335
|
-
const p = d.valueAsDate || new Date(V), N = (fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + fe), ue = d.type == "time", oe = d.type == "week";
|
|
336
|
-
B(O.value) && V && (v = ue ? N(V) > N(O.value) : oe ? V > O.value : p > new Date(O.value)), B(C.value) && V && (_ = ue ? N(V) < N(C.value) : oe ? V < C.value : p < new Date(C.value));
|
|
337
|
-
}
|
|
338
|
-
if ((v || _) && (ve(!!v, O.message, C.message, X.max, X.min), !a))
|
|
339
|
-
return Q(S[M].message), S;
|
|
340
|
-
}
|
|
341
|
-
if ((j || le) && !se && (B(V) || n && Array.isArray(V))) {
|
|
342
|
-
const v = ie(j), _ = ie(le), O = !I(v.value) && V.length > +v.value, C = !I(_.value) && V.length < +_.value;
|
|
343
|
-
if ((O || C) && (ve(O, v.message, _.message), !a))
|
|
344
|
-
return Q(S[M].message), S;
|
|
345
|
-
}
|
|
346
|
-
if (b && !se && B(V)) {
|
|
347
|
-
const { value: v, message: _ } = ie(b);
|
|
348
|
-
if (Ve(v) && !V.match(v) && (S[M] = {
|
|
349
|
-
type: X.pattern,
|
|
350
|
-
message: _,
|
|
351
|
-
ref: d,
|
|
352
|
-
...W(X.pattern, _)
|
|
353
|
-
}, !a))
|
|
354
|
-
return Q(_), S;
|
|
355
|
-
}
|
|
356
|
-
if (z) {
|
|
357
|
-
if (H(z)) {
|
|
358
|
-
const v = await z(V, r), _ = et(v, J);
|
|
359
|
-
if (_ && (S[M] = {
|
|
360
|
-
..._,
|
|
361
|
-
...W(X.validate, _.message)
|
|
362
|
-
}, !a))
|
|
363
|
-
return Q(_.message), S;
|
|
364
|
-
} else if (k(z)) {
|
|
365
|
-
let v = {};
|
|
366
|
-
for (const _ in z) {
|
|
367
|
-
if (!R(v) && !a)
|
|
368
|
-
break;
|
|
369
|
-
const O = et(await z[_](V, r), J, _);
|
|
370
|
-
O && (v = {
|
|
371
|
-
...O,
|
|
372
|
-
...W(_, O.message)
|
|
373
|
-
}, Q(O.message), a && (S[M] = v));
|
|
374
|
-
}
|
|
375
|
-
if (!R(v) && (S[M] = {
|
|
376
|
-
ref: J,
|
|
377
|
-
...v
|
|
378
|
-
}, !a))
|
|
379
|
-
return S;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
return Q(!0), S;
|
|
383
|
-
};
|
|
384
|
-
const qt = {
|
|
385
|
-
mode: $.onSubmit,
|
|
386
|
-
reValidateMode: $.onChange,
|
|
387
|
-
shouldFocusError: !0
|
|
388
|
-
};
|
|
389
|
-
function Wt(e = {}) {
|
|
390
|
-
let s = {
|
|
391
|
-
...qt,
|
|
392
|
-
...e
|
|
393
|
-
}, r = {
|
|
394
|
-
submitCount: 0,
|
|
395
|
-
isDirty: !1,
|
|
396
|
-
isReady: !1,
|
|
397
|
-
isLoading: H(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 = k(s.defaultValues) || k(s.values) ? T(s.defaultValues || s.values) || {} : {}, n = s.shouldUnregister ? {} : T(u), d = {
|
|
409
|
-
action: !1,
|
|
410
|
-
mount: !1,
|
|
411
|
-
watch: !1,
|
|
412
|
-
keepIsValid: !1
|
|
413
|
-
}, y = {
|
|
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
|
-
}, U, j = 0;
|
|
420
|
-
const le = {
|
|
421
|
-
isDirty: !1,
|
|
422
|
-
dirtyFields: !1,
|
|
423
|
-
validatingFields: !1,
|
|
424
|
-
touchedFields: !1,
|
|
425
|
-
isValidating: !1,
|
|
426
|
-
isValid: !1,
|
|
427
|
-
errors: !1
|
|
428
|
-
}, x = {
|
|
429
|
-
...le
|
|
430
|
-
};
|
|
431
|
-
let E = {
|
|
432
|
-
...x
|
|
433
|
-
};
|
|
434
|
-
const b = {
|
|
435
|
-
array: je(),
|
|
436
|
-
state: je()
|
|
437
|
-
}, z = s.criteriaMode === $.all, M = (t) => (i) => {
|
|
438
|
-
clearTimeout(j), j = setTimeout(t, i);
|
|
439
|
-
}, Y = async (t) => {
|
|
440
|
-
if (!d.keepIsValid && !s.disabled && (x.isValid || E.isValid || t)) {
|
|
441
|
-
let i;
|
|
442
|
-
s.resolver ? (i = R((await ee()).errors), q()) : i = await W(a, !0), i !== r.isValid && b.state.next({
|
|
443
|
-
isValid: i
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}, q = (t, i) => {
|
|
447
|
-
!s.disabled && (x.isValidating || x.validatingFields || E.isValidating || E.validatingFields) && ((t || Array.from(y.mount)).forEach((l) => {
|
|
448
|
-
l && (i ? m(r.validatingFields, l, i) : D(r.validatingFields, l));
|
|
449
|
-
}), b.state.next({
|
|
450
|
-
validatingFields: r.validatingFields,
|
|
451
|
-
isValidating: !R(r.validatingFields)
|
|
452
|
-
}));
|
|
453
|
-
}, V = (t, i = [], l, c, f = !0, o = !0) => {
|
|
454
|
-
if (c && l && !s.disabled) {
|
|
455
|
-
if (d.action = !0, o && Array.isArray(h(a, t))) {
|
|
456
|
-
const g = l(h(a, t), c.argA, c.argB);
|
|
457
|
-
f && m(a, t, g);
|
|
458
|
-
}
|
|
459
|
-
if (o && Array.isArray(h(r.errors, t))) {
|
|
460
|
-
const g = l(h(r.errors, t), c.argA, c.argB);
|
|
461
|
-
f && m(r.errors, t, g), Pt(r.errors, t);
|
|
462
|
-
}
|
|
463
|
-
if ((x.touchedFields || E.touchedFields) && o && Array.isArray(h(r.touchedFields, t))) {
|
|
464
|
-
const g = l(h(r.touchedFields, t), c.argA, c.argB);
|
|
465
|
-
f && m(r.touchedFields, t, g);
|
|
466
|
-
}
|
|
467
|
-
(x.dirtyFields || E.dirtyFields) && (r.dirtyFields = ae(u, n)), b.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
|
-
m(n, t, i);
|
|
476
|
-
}, J = (t, i) => {
|
|
477
|
-
m(r.errors, t, i), b.state.next({
|
|
478
|
-
errors: r.errors
|
|
479
|
-
});
|
|
480
|
-
}, Q = (t) => {
|
|
481
|
-
r.errors = t, b.state.next({
|
|
482
|
-
errors: r.errors,
|
|
483
|
-
isValid: !1
|
|
484
|
-
});
|
|
485
|
-
}, S = (t, i, l, c) => {
|
|
486
|
-
const f = h(a, t);
|
|
487
|
-
if (f) {
|
|
488
|
-
const o = h(n, t, w(l) ? h(u, t) : l);
|
|
489
|
-
w(o) || c && c.defaultChecked || i ? m(n, t, i ? o : Je(f._f)) : C(t, o), d.mount && !d.action && Y();
|
|
490
|
-
}
|
|
491
|
-
}, ne = (t, i, l, c, f) => {
|
|
492
|
-
let o = !1, g = !1;
|
|
493
|
-
const F = {
|
|
494
|
-
name: t
|
|
495
|
-
};
|
|
496
|
-
if (!s.disabled) {
|
|
497
|
-
if (!l || c) {
|
|
498
|
-
(x.isDirty || E.isDirty) && (g = r.isDirty, r.isDirty = F.isDirty = v(), o = g !== F.isDirty);
|
|
499
|
-
const A = G(h(u, t), i);
|
|
500
|
-
g = !!h(r.dirtyFields, t), A ? D(r.dirtyFields, t) : m(r.dirtyFields, t, !0), F.dirtyFields = r.dirtyFields, o = o || (x.dirtyFields || E.dirtyFields) && g !== !A;
|
|
501
|
-
}
|
|
502
|
-
if (l) {
|
|
503
|
-
const A = h(r.touchedFields, t);
|
|
504
|
-
A || (m(r.touchedFields, t, l), F.touchedFields = r.touchedFields, o = o || (x.touchedFields || E.touchedFields) && A !== l);
|
|
505
|
-
}
|
|
506
|
-
o && f && b.state.next(F);
|
|
507
|
-
}
|
|
508
|
-
return o ? F : {};
|
|
509
|
-
}, ge = (t, i, l, c) => {
|
|
510
|
-
const f = h(r.errors, t), o = (x.isValid || E.isValid) && K(i) && r.isValid !== i;
|
|
511
|
-
if (s.delayError && l ? (U = M(() => J(t, l)), U(s.delayError)) : (clearTimeout(j), U = null, l ? m(r.errors, t, l) : D(r.errors, t)), (l ? !G(f, l) : f) || !R(c) || o) {
|
|
512
|
-
const g = {
|
|
513
|
-
...c,
|
|
514
|
-
...o && K(i) ? { isValid: i } : {},
|
|
515
|
-
errors: r.errors,
|
|
516
|
-
name: t
|
|
517
|
-
};
|
|
518
|
-
r = {
|
|
519
|
-
...r,
|
|
520
|
-
...g
|
|
521
|
-
}, b.state.next(g);
|
|
522
|
-
}
|
|
523
|
-
}, ee = async (t) => (q(t, !0), await s.resolver(n, s.context, Lt(t || y.mount, a, s.criteriaMode, s.shouldUseNativeValidation))), se = async (t) => {
|
|
524
|
-
const { errors: i } = await ee(t);
|
|
525
|
-
if (q(t), t)
|
|
526
|
-
for (const l of t) {
|
|
527
|
-
const c = h(i, l);
|
|
528
|
-
c ? m(r.errors, l, c) : D(r.errors, l);
|
|
529
|
-
}
|
|
530
|
-
else
|
|
531
|
-
r.errors = i;
|
|
532
|
-
return i;
|
|
533
|
-
}, W = async (t, i, l = {
|
|
534
|
-
valid: !0
|
|
535
|
-
}) => {
|
|
536
|
-
for (const c in t) {
|
|
537
|
-
const f = t[c];
|
|
538
|
-
if (f) {
|
|
539
|
-
const { _f: o, ...g } = f;
|
|
540
|
-
if (o) {
|
|
541
|
-
const F = y.array.has(o.name), A = f._f && Rt(f._f);
|
|
542
|
-
A && x.validatingFields && q([o.name], !0);
|
|
543
|
-
const L = await tt(f, y.disabled, n, z, s.shouldUseNativeValidation && !i, F);
|
|
544
|
-
if (A && x.validatingFields && q([o.name]), L[o.name] && (l.valid = !1, i || e.shouldUseNativeValidation))
|
|
545
|
-
break;
|
|
546
|
-
!i && (h(L, o.name) ? F ? Bt(r.errors, L, o.name) : m(r.errors, o.name, L[o.name]) : D(r.errors, o.name));
|
|
547
|
-
}
|
|
548
|
-
!R(g) && await W(g, i, l);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
return l.valid;
|
|
552
|
-
}, ve = () => {
|
|
553
|
-
for (const t of y.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
|
-
y.unMount = /* @__PURE__ */ new Set();
|
|
558
|
-
}, v = (t, i) => !s.disabled && (t && i && m(n, t, i), !G(Re(), u)), _ = (t, i, l) => kt(t, y, {
|
|
559
|
-
...d.mount ? n : w(i) ? u : B(t) ? { [t]: i } : i
|
|
560
|
-
}, l, i), O = (t) => Oe(h(d.mount ? n : u, t, s.shouldUnregister ? h(u, t, []) : [])), C = (t, i, l = {}) => {
|
|
561
|
-
const c = h(a, t);
|
|
562
|
-
let f = i;
|
|
563
|
-
if (c) {
|
|
564
|
-
const o = c._f;
|
|
565
|
-
o && (!o.disabled && m(n, t, nt(i, o)), f = be(o.ref) && I(i) ? "" : i, it(o.ref) ? [...o.ref.options].forEach((g) => g.selected = f.includes(g.value)) : o.refs ? he(o.ref) ? o.refs.forEach((g) => {
|
|
566
|
-
(!g.defaultChecked || !g.disabled) && (Array.isArray(f) ? g.checked = !!f.find((F) => F === g.value) : g.checked = f === g.value || !!f);
|
|
567
|
-
}) : o.refs.forEach((g) => g.checked = g.value === f) : Ce(o.ref) ? o.ref.value = "" : (o.ref.value = f, o.ref.type || b.state.next({
|
|
568
|
-
name: t,
|
|
569
|
-
values: T(n)
|
|
570
|
-
})));
|
|
571
|
-
}
|
|
572
|
-
(l.shouldDirty || l.shouldTouch) && ne(t, f, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && fe(t);
|
|
573
|
-
}, p = (t, i, l) => {
|
|
574
|
-
for (const c in i) {
|
|
575
|
-
if (!i.hasOwnProperty(c))
|
|
576
|
-
return;
|
|
577
|
-
const f = i[c], o = t + "." + c, g = h(a, o);
|
|
578
|
-
(y.array.has(t) || k(f) || g && !g._f) && !re(f) ? p(o, f, l) : C(o, f, l);
|
|
579
|
-
}
|
|
580
|
-
}, N = (t, i, l = {}) => {
|
|
581
|
-
const c = h(a, t), f = y.array.has(t), o = T(i);
|
|
582
|
-
m(n, t, o), f ? (b.array.next({
|
|
583
|
-
name: t,
|
|
584
|
-
values: T(n)
|
|
585
|
-
}), (x.isDirty || x.dirtyFields || E.isDirty || E.dirtyFields) && l.shouldDirty && b.state.next({
|
|
586
|
-
name: t,
|
|
587
|
-
dirtyFields: ae(u, n),
|
|
588
|
-
isDirty: v(t, o)
|
|
589
|
-
})) : c && !c._f && !I(o) ? p(t, o, l) : C(t, o, l), Ze(t, y) ? b.state.next({
|
|
590
|
-
...r,
|
|
591
|
-
name: t,
|
|
592
|
-
values: T(n)
|
|
593
|
-
}) : b.state.next({
|
|
594
|
-
name: d.mount ? t : void 0,
|
|
595
|
-
values: T(n)
|
|
596
|
-
});
|
|
597
|
-
}, ue = async (t) => {
|
|
598
|
-
d.mount = !0;
|
|
599
|
-
const i = t.target;
|
|
600
|
-
let l = i.name, c = !0;
|
|
601
|
-
const f = h(a, l), o = (A) => {
|
|
602
|
-
c = Number.isNaN(A) || re(A) && isNaN(A.getTime()) || G(A, h(n, l, A));
|
|
603
|
-
}, g = Qe(s.mode), F = Qe(s.reValidateMode);
|
|
604
|
-
if (f) {
|
|
605
|
-
let A, L;
|
|
606
|
-
const te = i.type ? Je(f._f) : _t(t), Z = t.type === $e.BLUR || t.type === $e.FOCUS_OUT, vt = !Ut(f._f) && !s.resolver && !h(r.errors, l) && !f._f.deps || Nt(Z, h(r.touchedFields, l), r.isSubmitted, F, g), me = Ze(l, y, Z);
|
|
607
|
-
m(n, l, te), Z ? (!i || !i.readOnly) && (f._f.onBlur && f._f.onBlur(t), U && U(0)) : f._f.onChange && f._f.onChange(t);
|
|
608
|
-
const we = ne(l, te, Z), bt = !R(we) || me;
|
|
609
|
-
if (!Z && b.state.next({
|
|
610
|
-
name: l,
|
|
611
|
-
type: t.type,
|
|
612
|
-
values: T(n)
|
|
613
|
-
}), vt)
|
|
614
|
-
return (x.isValid || E.isValid) && (s.mode === "onBlur" ? Z && Y() : Z || Y()), bt && b.state.next({ name: l, ...me ? {} : we });
|
|
615
|
-
if (!Z && me && b.state.next({ ...r }), s.resolver) {
|
|
616
|
-
const { errors: pe } = await ee([l]);
|
|
617
|
-
if (q([l]), o(te), c) {
|
|
618
|
-
const Vt = Ge(r.errors, a, l), He = Ge(pe, a, Vt.name || l);
|
|
619
|
-
A = He.error, l = He.name, L = R(pe);
|
|
620
|
-
}
|
|
621
|
-
} else
|
|
622
|
-
q([l], !0), A = (await tt(f, y.disabled, n, z, s.shouldUseNativeValidation))[l], q([l]), o(te), c && (A ? L = !1 : (x.isValid || E.isValid) && (L = await W(a, !0)));
|
|
623
|
-
c && (f._f.deps && (!Array.isArray(f._f.deps) || f._f.deps.length > 0) && fe(f._f.deps), ge(l, L, 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, c;
|
|
630
|
-
const f = ce(t);
|
|
631
|
-
if (s.resolver) {
|
|
632
|
-
const o = await se(w(t) ? t : f);
|
|
633
|
-
l = R(o), c = t ? !f.some((g) => h(o, g)) : l;
|
|
634
|
-
} else t ? (c = (await Promise.all(f.map(async (o) => {
|
|
635
|
-
const g = h(a, o);
|
|
636
|
-
return await W(g && g._f ? { [o]: g } : g);
|
|
637
|
-
}))).every(Boolean), !(!c && !r.isValid) && Y()) : c = l = await W(a);
|
|
638
|
-
return b.state.next({
|
|
639
|
-
...!B(t) || (x.isValid || E.isValid) && l !== r.isValid ? {} : { name: t },
|
|
640
|
-
...s.resolver || !t ? { isValid: l } : {},
|
|
641
|
-
errors: r.errors
|
|
642
|
-
}), i.shouldFocus && !c && ye(a, oe, t ? f : y.mount), c;
|
|
643
|
-
}, Re = (t, i) => {
|
|
644
|
-
let l = {
|
|
645
|
-
...d.mount ? n : u
|
|
646
|
-
};
|
|
647
|
-
return i && (l = st(i.dirtyFields ? r.dirtyFields : r.touchedFields, l)), w(t) ? l : B(t) ? h(l, t) : t.map((c) => h(l, c));
|
|
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) => D(r.errors, i)), b.state.next({
|
|
656
|
-
errors: t ? r.errors : {}
|
|
657
|
-
});
|
|
658
|
-
}, Ie = (t, i, l) => {
|
|
659
|
-
const c = (h(a, t, { _f: {} })._f || {}).ref, f = h(r.errors, t) || {}, { ref: o, message: g, type: F, ...A } = f;
|
|
660
|
-
m(r.errors, t, {
|
|
661
|
-
...A,
|
|
662
|
-
...i,
|
|
663
|
-
ref: c
|
|
664
|
-
}), b.state.next({
|
|
665
|
-
name: t,
|
|
666
|
-
errors: r.errors,
|
|
667
|
-
isValid: !1
|
|
668
|
-
}), l && l.shouldFocus && c && c.focus && c.focus();
|
|
669
|
-
}, ft = (t, i) => H(t) ? b.state.subscribe({
|
|
670
|
-
next: (l) => "values" in l && t(_(void 0, i), l)
|
|
671
|
-
}) : _(t, i, !0), Me = (t) => b.state.subscribe({
|
|
672
|
-
next: (i) => {
|
|
673
|
-
Mt(t.name, i.name, t.exact) && It(i, t.formState || x, gt, t.reRenderRoot) && t.callback({
|
|
674
|
-
values: { ...n },
|
|
675
|
-
...r,
|
|
676
|
-
...i,
|
|
677
|
-
defaultValues: u
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
}).unsubscribe, dt = (t) => (d.mount = !0, E = {
|
|
681
|
-
...E,
|
|
682
|
-
...t.formState
|
|
683
|
-
}, Me({
|
|
684
|
-
...t,
|
|
685
|
-
formState: {
|
|
686
|
-
...le,
|
|
687
|
-
...t.formState
|
|
688
|
-
}
|
|
689
|
-
})), Fe = (t, i = {}) => {
|
|
690
|
-
for (const l of t ? ce(t) : y.mount)
|
|
691
|
-
y.mount.delete(l), y.array.delete(l), i.keepValue || (D(a, l), D(n, l)), !i.keepError && D(r.errors, l), !i.keepDirty && D(r.dirtyFields, l), !i.keepTouched && D(r.touchedFields, l), !i.keepIsValidating && D(r.validatingFields, l), !s.shouldUnregister && !i.keepDefaultValue && D(u, l);
|
|
692
|
-
b.state.next({
|
|
693
|
-
values: T(n)
|
|
694
|
-
}), b.state.next({
|
|
695
|
-
...r,
|
|
696
|
-
...i.keepDirty ? { isDirty: v() } : {}
|
|
697
|
-
}), !i.keepIsValid && Y();
|
|
698
|
-
}, Ne = ({ disabled: t, name: i }) => {
|
|
699
|
-
(K(t) && d.mount || t || y.disabled.has(i)) && (t ? y.disabled.add(i) : y.disabled.delete(i));
|
|
700
|
-
}, Ae = (t, i = {}) => {
|
|
701
|
-
let l = h(a, t);
|
|
702
|
-
const c = K(i.disabled) || K(s.disabled);
|
|
703
|
-
return m(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
|
-
}), y.mount.add(t), l ? Ne({
|
|
712
|
-
disabled: K(i.disabled) ? i.disabled : s.disabled,
|
|
713
|
-
name: t
|
|
714
|
-
}) : S(t, !0, i.value), {
|
|
715
|
-
...c ? { 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: (f) => {
|
|
728
|
-
if (f) {
|
|
729
|
-
Ae(t, i), l = h(a, t);
|
|
730
|
-
const o = w(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, g = St(o), F = l._f.refs || [];
|
|
731
|
-
if (g ? F.find((A) => A === o) : o === l._f.ref)
|
|
732
|
-
return;
|
|
733
|
-
m(a, t, {
|
|
734
|
-
_f: {
|
|
735
|
-
...l._f,
|
|
736
|
-
...g ? {
|
|
737
|
-
refs: [
|
|
738
|
-
...F.filter(De),
|
|
739
|
-
o,
|
|
740
|
-
...Array.isArray(h(u, t)) ? [{}] : []
|
|
741
|
-
],
|
|
742
|
-
ref: { type: o.type, name: t }
|
|
743
|
-
} : { ref: o }
|
|
744
|
-
}
|
|
745
|
-
}), S(t, !1, void 0, o);
|
|
746
|
-
} else
|
|
747
|
-
l = h(a, t, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || i.shouldUnregister) && !(At(y.array, t) && d.action) && y.unMount.add(t);
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
}, xe = () => s.shouldFocusError && ye(a, oe, y.mount), ct = (t) => {
|
|
751
|
-
K(t) && (b.state.next({ disabled: t }), ye(a, (i, l) => {
|
|
752
|
-
const c = h(a, l);
|
|
753
|
-
c && (i.disabled = c._f.disabled || t, Array.isArray(c._f.refs) && c._f.refs.forEach((f) => {
|
|
754
|
-
f.disabled = c._f.disabled || t;
|
|
755
|
-
}));
|
|
756
|
-
}, 0, !1));
|
|
757
|
-
}, Pe = (t, i) => async (l) => {
|
|
758
|
-
let c;
|
|
759
|
-
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
760
|
-
let f = T(n);
|
|
761
|
-
if (b.state.next({
|
|
762
|
-
isSubmitting: !0
|
|
763
|
-
}), s.resolver) {
|
|
764
|
-
const { errors: o, values: g } = await ee();
|
|
765
|
-
q(), r.errors = o, f = T(g);
|
|
766
|
-
} else
|
|
767
|
-
await W(a);
|
|
768
|
-
if (y.disabled.size)
|
|
769
|
-
for (const o of y.disabled)
|
|
770
|
-
D(f, o);
|
|
771
|
-
if (D(r.errors, "root"), R(r.errors)) {
|
|
772
|
-
b.state.next({
|
|
773
|
-
errors: {}
|
|
774
|
-
});
|
|
775
|
-
try {
|
|
776
|
-
await t(f, l);
|
|
777
|
-
} catch (o) {
|
|
778
|
-
c = o;
|
|
779
|
-
}
|
|
780
|
-
} else
|
|
781
|
-
i && await i({ ...r.errors }, l), xe(), setTimeout(xe);
|
|
782
|
-
if (b.state.next({
|
|
783
|
-
isSubmitted: !0,
|
|
784
|
-
isSubmitting: !1,
|
|
785
|
-
isSubmitSuccessful: R(r.errors) && !c,
|
|
786
|
-
submitCount: r.submitCount + 1,
|
|
787
|
-
errors: r.errors
|
|
788
|
-
}), c)
|
|
789
|
-
throw c;
|
|
790
|
-
}, yt = (t, i = {}) => {
|
|
791
|
-
h(a, t) && (w(i.defaultValue) ? N(t, T(h(u, t))) : (N(t, i.defaultValue), m(u, t, T(i.defaultValue))), i.keepTouched || D(r.touchedFields, t), i.keepDirty || (D(r.dirtyFields, t), r.isDirty = i.defaultValue ? v(t, T(h(u, t))) : v()), i.keepError || (D(r.errors, t), x.isValid && Y()), b.state.next({ ...r }));
|
|
792
|
-
}, Be = (t, i = {}) => {
|
|
793
|
-
const l = t ? T(t) : u, c = T(l), f = R(t), o = f ? u : c;
|
|
794
|
-
if (i.keepDefaultValues || (u = l), !i.keepValues) {
|
|
795
|
-
if (i.keepDirtyValues) {
|
|
796
|
-
const g = /* @__PURE__ */ new Set([
|
|
797
|
-
...y.mount,
|
|
798
|
-
...Object.keys(ae(u, n))
|
|
799
|
-
]);
|
|
800
|
-
for (const F of Array.from(g)) {
|
|
801
|
-
const A = h(r.dirtyFields, F), L = h(n, F), te = h(o, F);
|
|
802
|
-
A && !w(L) ? m(o, F, L) : !A && !w(te) && N(F, te);
|
|
803
|
-
}
|
|
804
|
-
} else {
|
|
805
|
-
if (Se && w(t))
|
|
806
|
-
for (const g of y.mount) {
|
|
807
|
-
const F = h(a, g);
|
|
808
|
-
if (F && F._f) {
|
|
809
|
-
const A = Array.isArray(F._f.refs) ? F._f.refs[0] : F._f.ref;
|
|
810
|
-
if (be(A)) {
|
|
811
|
-
const L = A.closest("form");
|
|
812
|
-
if (L) {
|
|
813
|
-
L.reset();
|
|
814
|
-
break;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
if (i.keepFieldsRef)
|
|
820
|
-
for (const g of y.mount)
|
|
821
|
-
N(g, h(o, g));
|
|
822
|
-
else
|
|
823
|
-
a = {};
|
|
824
|
-
}
|
|
825
|
-
n = s.shouldUnregister ? i.keepDefaultValues ? T(u) : {} : T(o), b.array.next({
|
|
826
|
-
values: { ...o }
|
|
827
|
-
}), b.state.next({
|
|
828
|
-
values: { ...o }
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
y = {
|
|
832
|
-
mount: i.keepDirtyValues ? y.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
|
-
}, d.mount = !x.isValid || !!i.keepIsValid || !!i.keepDirtyValues || !s.shouldUnregister && !R(o), d.watch = !!s.shouldUnregister, d.keepIsValid = !!i.keepIsValid, d.action = !1, i.keepErrors || (r.errors = {}), b.state.next({
|
|
840
|
-
submitCount: i.keepSubmitCount ? r.submitCount : 0,
|
|
841
|
-
isDirty: f ? !1 : i.keepDirty ? r.isDirty : !!(i.keepDefaultValues && !G(t, u)),
|
|
842
|
-
isSubmitted: i.keepIsSubmitted ? r.isSubmitted : !1,
|
|
843
|
-
dirtyFields: f ? {} : i.keepDirtyValues ? i.keepDefaultValues && n ? ae(u, n) : r.dirtyFields : i.keepDefaultValues && t ? ae(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
|
-
}, qe = (t, i) => Be(H(t) ? t(n) : t, { ...s.resetOptions, ...i }), ht = (t, i = {}) => {
|
|
851
|
-
const l = h(a, t), c = l && l._f;
|
|
852
|
-
if (c) {
|
|
853
|
-
const f = c.refs ? c.refs[0] : c.ref;
|
|
854
|
-
f.focus && setTimeout(() => {
|
|
855
|
-
f.focus(), i.shouldSelect && H(f.select) && f.select();
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
}, gt = (t) => {
|
|
859
|
-
r = {
|
|
860
|
-
...r,
|
|
861
|
-
...t
|
|
862
|
-
};
|
|
863
|
-
}, We = {
|
|
864
|
-
control: {
|
|
865
|
-
register: Ae,
|
|
866
|
-
unregister: Fe,
|
|
867
|
-
getFieldState: Ue,
|
|
868
|
-
handleSubmit: Pe,
|
|
869
|
-
setError: Ie,
|
|
870
|
-
_subscribe: Me,
|
|
871
|
-
_runSchema: ee,
|
|
872
|
-
_updateIsValidating: q,
|
|
873
|
-
_focusError: xe,
|
|
874
|
-
_getWatch: _,
|
|
875
|
-
_getDirty: v,
|
|
876
|
-
_setValid: Y,
|
|
877
|
-
_setFieldArray: V,
|
|
878
|
-
_setDisabledField: Ne,
|
|
879
|
-
_setErrors: Q,
|
|
880
|
-
_getFieldArray: O,
|
|
881
|
-
_reset: Be,
|
|
882
|
-
_resetDefaultValues: () => H(s.defaultValues) && s.defaultValues().then((t) => {
|
|
883
|
-
qe(t, s.resetOptions), b.state.next({
|
|
884
|
-
isLoading: !1
|
|
885
|
-
});
|
|
886
|
-
}),
|
|
887
|
-
_removeUnmounted: ve,
|
|
888
|
-
_disableForm: ct,
|
|
889
|
-
_subjects: b,
|
|
890
|
-
_proxyFormState: x,
|
|
891
|
-
get _fields() {
|
|
892
|
-
return a;
|
|
893
|
-
},
|
|
894
|
-
get _formValues() {
|
|
895
|
-
return n;
|
|
896
|
-
},
|
|
897
|
-
get _state() {
|
|
898
|
-
return d;
|
|
899
|
-
},
|
|
900
|
-
set _state(t) {
|
|
901
|
-
d = t;
|
|
902
|
-
},
|
|
903
|
-
get _defaultValues() {
|
|
904
|
-
return u;
|
|
905
|
-
},
|
|
906
|
-
get _names() {
|
|
907
|
-
return y;
|
|
908
|
-
},
|
|
909
|
-
set _names(t) {
|
|
910
|
-
y = 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: Ae,
|
|
928
|
-
handleSubmit: Pe,
|
|
929
|
-
watch: ft,
|
|
930
|
-
setValue: N,
|
|
931
|
-
getValues: Re,
|
|
932
|
-
reset: qe,
|
|
933
|
-
resetField: yt,
|
|
934
|
-
clearErrors: ot,
|
|
935
|
-
unregister: Fe,
|
|
936
|
-
setError: Ie,
|
|
937
|
-
setFocus: ht,
|
|
938
|
-
getFieldState: Ue
|
|
939
|
-
};
|
|
940
|
-
return {
|
|
941
|
-
...We,
|
|
942
|
-
formControl: We
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
function $t(e = {}) {
|
|
946
|
-
const s = P.useRef(void 0), r = P.useRef(void 0), [a, u] = P.useState({
|
|
947
|
-
isDirty: !1,
|
|
948
|
-
isValidating: !1,
|
|
949
|
-
isLoading: H(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: H(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 && !H(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
969
|
-
else {
|
|
970
|
-
const { formControl: d, ...y } = Wt(e);
|
|
971
|
-
s.current = {
|
|
972
|
-
...y,
|
|
973
|
-
formState: a
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
const n = s.current.control;
|
|
977
|
-
return n._options = e, Dt(() => {
|
|
978
|
-
const d = n._subscribe({
|
|
979
|
-
formState: n._proxyFormState,
|
|
980
|
-
callback: () => u({ ...n._formState }),
|
|
981
|
-
reRenderRoot: !0
|
|
982
|
-
});
|
|
983
|
-
return u((y) => ({
|
|
984
|
-
...y,
|
|
985
|
-
isReady: !0
|
|
986
|
-
})), n._formState.isReady = !0, d;
|
|
987
|
-
}, [n]), P.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), P.useEffect(() => {
|
|
988
|
-
e.mode && (n._options.mode = e.mode), e.reValidateMode && (n._options.reValidateMode = e.reValidateMode);
|
|
989
|
-
}, [n, e.mode, e.reValidateMode]), P.useEffect(() => {
|
|
990
|
-
e.errors && (n._setErrors(e.errors), n._focusError());
|
|
991
|
-
}, [n, e.errors]), P.useEffect(() => {
|
|
992
|
-
e.shouldUnregister && n._subjects.state.next({
|
|
993
|
-
values: n._getWatch()
|
|
994
|
-
});
|
|
995
|
-
}, [n, e.shouldUnregister]), P.useEffect(() => {
|
|
996
|
-
if (n._proxyFormState.isDirty) {
|
|
997
|
-
const d = n._getDirty();
|
|
998
|
-
d !== a.isDirty && n._subjects.state.next({
|
|
999
|
-
isDirty: d
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
}, [n, a.isDirty]), P.useEffect(() => {
|
|
1003
|
-
var d;
|
|
1004
|
-
e.values && !G(e.values, r.current) ? (n._reset(e.values, {
|
|
1005
|
-
keepFieldsRef: !0,
|
|
1006
|
-
...n._options.resetOptions
|
|
1007
|
-
}), !((d = n._options.resetOptions) === null || d === void 0) && d.keepIsValid || n._setValid(), r.current = e.values, u((y) => ({ ...y }))) : n._resetDefaultValues();
|
|
1008
|
-
}, [n, e.values]), P.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
|
-
export {
|
|
1013
|
-
$t as u
|
|
1014
|
-
};
|