@akinon/akiform-builder 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/FormBuilderWatch.d.ts.map +1 -0
- package/dist/cjs/FormBuilderWatch.js +75 -0
- package/dist/cjs/RenderField.d.ts.map +1 -0
- package/dist/cjs/RenderField.js +45 -0
- package/dist/cjs/component.d.ts.map +1 -0
- package/dist/cjs/component.js +46 -0
- package/dist/cjs/hook.d.ts.map +1 -0
- package/dist/cjs/hook.js +38 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/transformers/index.d.ts.map +1 -0
- package/dist/cjs/transformers/index.js +77 -0
- package/dist/cjs/transformers/types.d.ts.map +1 -0
- package/dist/cjs/transformers/types.js +18 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +2 -0
- package/dist/esm/FormBuilderWatch.d.ts +16 -0
- package/dist/esm/FormBuilderWatch.d.ts.map +1 -0
- package/dist/esm/FormBuilderWatch.js +71 -0
- package/dist/esm/RenderField.d.ts +5 -0
- package/dist/esm/RenderField.d.ts.map +1 -0
- package/dist/esm/RenderField.js +41 -0
- package/dist/esm/component.d.ts +4 -0
- package/dist/esm/component.d.ts.map +1 -0
- package/dist/esm/component.js +42 -0
- package/dist/esm/hook.d.ts +3 -0
- package/dist/esm/hook.d.ts.map +1 -0
- package/dist/esm/hook.js +34 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/transformers/index.d.ts +4 -0
- package/dist/esm/transformers/index.d.ts.map +1 -0
- package/dist/esm/transformers/index.js +73 -0
- package/dist/esm/transformers/types.d.ts +22 -0
- package/dist/esm/transformers/types.d.ts.map +1 -0
- package/dist/esm/transformers/types.js +15 -0
- package/dist/esm/types.d.ts +82 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +1 -0
- package/package.json +13 -7
- package/dist/FormBuilderWatch.d.ts.map +0 -1
- package/dist/RenderField.d.ts.map +0 -1
- package/dist/component.d.ts.map +0 -1
- package/dist/hook.d.ts.map +0 -1
- package/dist/index.cjs +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3129
- package/dist/transformers/index.d.ts.map +0 -1
- package/dist/transformers/types.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{FormBuilderWatch.d.ts → cjs/FormBuilderWatch.d.ts} +0 -0
- /package/dist/{RenderField.d.ts → cjs/RenderField.d.ts} +0 -0
- /package/dist/{component.d.ts → cjs/component.d.ts} +0 -0
- /package/dist/{hook.d.ts → cjs/hook.d.ts} +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{transformers → cjs/transformers}/index.d.ts +0 -0
- /package/dist/{transformers → cjs/transformers}/types.d.ts +0 -0
- /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
package/dist/index.js
DELETED
|
@@ -1,3129 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".akinon-input{box-shadow:none!important}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
-
import { jsx as q, jsxs as Hr, Fragment as Yr } from "react/jsx-runtime";
|
|
3
|
-
import { Form as Ee, Checkbox as qr, DatePicker as zr, Input as We, InputNumber as Zr, Select as Gr } from "antd";
|
|
4
|
-
import T, { useEffect as Jr, Children as Kr, isValidElement as Xr, cloneElement as Qr } from "react";
|
|
5
|
-
var He = (t) => t.type === "checkbox", Ie = (t) => t instanceof Date, ae = (t) => t == null;
|
|
6
|
-
const or = (t) => typeof t == "object";
|
|
7
|
-
var J = (t) => !ae(t) && !Array.isArray(t) && or(t) && !Ie(t), cr = (t) => J(t) && t.target ? He(t.target) ? t.target.checked : t.target.value : t, es = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, fr = (t, r) => t.has(es(r)), ts = (t) => {
|
|
8
|
-
const r = t.constructor && t.constructor.prototype;
|
|
9
|
-
return J(r) && r.hasOwnProperty("isPrototypeOf");
|
|
10
|
-
}, Tt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
11
|
-
function G(t) {
|
|
12
|
-
let r;
|
|
13
|
-
const e = Array.isArray(t);
|
|
14
|
-
if (t instanceof Date)
|
|
15
|
-
r = new Date(t);
|
|
16
|
-
else if (t instanceof Set)
|
|
17
|
-
r = new Set(t);
|
|
18
|
-
else if (!(Tt && (t instanceof Blob || t instanceof FileList)) && (e || J(t)))
|
|
19
|
-
if (r = e ? [] : {}, !e && !ts(t))
|
|
20
|
-
r = t;
|
|
21
|
-
else
|
|
22
|
-
for (const s in t)
|
|
23
|
-
t.hasOwnProperty(s) && (r[s] = G(t[s]));
|
|
24
|
-
else
|
|
25
|
-
return t;
|
|
26
|
-
return r;
|
|
27
|
-
}
|
|
28
|
-
var Le = (t) => Array.isArray(t) ? t.filter(Boolean) : [], W = (t) => t === void 0, v = (t, r, e) => {
|
|
29
|
-
if (!r || !J(t))
|
|
30
|
-
return e;
|
|
31
|
-
const s = Le(r.split(/[,[\].]+?/)).reduce((n, i) => ae(n) ? n : n[i], t);
|
|
32
|
-
return W(s) || s === t ? W(t[r]) ? e : t[r] : s;
|
|
33
|
-
}, he = (t) => typeof t == "boolean";
|
|
34
|
-
const Ge = {
|
|
35
|
-
BLUR: "blur",
|
|
36
|
-
FOCUS_OUT: "focusout",
|
|
37
|
-
CHANGE: "change"
|
|
38
|
-
}, ce = {
|
|
39
|
-
onBlur: "onBlur",
|
|
40
|
-
onChange: "onChange",
|
|
41
|
-
onSubmit: "onSubmit",
|
|
42
|
-
onTouched: "onTouched",
|
|
43
|
-
all: "all"
|
|
44
|
-
}, be = {
|
|
45
|
-
max: "max",
|
|
46
|
-
min: "min",
|
|
47
|
-
maxLength: "maxLength",
|
|
48
|
-
minLength: "minLength",
|
|
49
|
-
pattern: "pattern",
|
|
50
|
-
required: "required",
|
|
51
|
-
validate: "validate"
|
|
52
|
-
}, rs = T.createContext(null), rt = () => T.useContext(rs);
|
|
53
|
-
var dr = (t, r, e, s = !0) => {
|
|
54
|
-
const n = {
|
|
55
|
-
defaultValues: r._defaultValues
|
|
56
|
-
};
|
|
57
|
-
for (const i in t)
|
|
58
|
-
Object.defineProperty(n, i, {
|
|
59
|
-
get: () => {
|
|
60
|
-
const a = i;
|
|
61
|
-
return r._proxyFormState[a] !== ce.all && (r._proxyFormState[a] = !s || ce.all), e && (e[a] = !0), t[a];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return n;
|
|
65
|
-
}, le = (t) => J(t) && !Object.keys(t).length, hr = (t, r, e, s) => {
|
|
66
|
-
e(t);
|
|
67
|
-
const { name: n, ...i } = t;
|
|
68
|
-
return le(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((a) => r[a] === (!s || ce.all));
|
|
69
|
-
}, oe = (t) => Array.isArray(t) ? t : [t], yr = (t, r, e) => !t || !r || t === r || oe(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s)));
|
|
70
|
-
function st(t) {
|
|
71
|
-
const r = T.useRef(t);
|
|
72
|
-
r.current = t, T.useEffect(() => {
|
|
73
|
-
const e = !t.disabled && r.current.subject && r.current.subject.subscribe({
|
|
74
|
-
next: r.current.next
|
|
75
|
-
});
|
|
76
|
-
return () => {
|
|
77
|
-
e && e.unsubscribe();
|
|
78
|
-
};
|
|
79
|
-
}, [t.disabled]);
|
|
80
|
-
}
|
|
81
|
-
function ss(t) {
|
|
82
|
-
const r = rt(), { control: e = r.control, disabled: s, name: n, exact: i } = t || {}, [a, l] = T.useState(e._formState), o = T.useRef(!0), d = T.useRef({
|
|
83
|
-
isDirty: !1,
|
|
84
|
-
isLoading: !1,
|
|
85
|
-
dirtyFields: !1,
|
|
86
|
-
touchedFields: !1,
|
|
87
|
-
isValidating: !1,
|
|
88
|
-
isValid: !1,
|
|
89
|
-
errors: !1
|
|
90
|
-
}), p = T.useRef(n);
|
|
91
|
-
return p.current = n, st({
|
|
92
|
-
disabled: s,
|
|
93
|
-
next: (h) => o.current && yr(p.current, h.name, i) && hr(h, d.current, e._updateFormState) && l({
|
|
94
|
-
...e._formState,
|
|
95
|
-
...h
|
|
96
|
-
}),
|
|
97
|
-
subject: e._subjects.state
|
|
98
|
-
}), T.useEffect(() => (o.current = !0, d.current.isValid && e._updateValid(!0), () => {
|
|
99
|
-
o.current = !1;
|
|
100
|
-
}), [e]), dr(a, e, d.current, !1);
|
|
101
|
-
}
|
|
102
|
-
var ge = (t) => typeof t == "string", pr = (t, r, e, s, n) => ge(t) ? (s && r.watch.add(t), v(e, t, n)) : Array.isArray(t) ? t.map((i) => (s && r.watch.add(i), v(e, i))) : (s && (r.watchAll = !0), e);
|
|
103
|
-
function mr(t) {
|
|
104
|
-
const r = rt(), { control: e = r.control, name: s, defaultValue: n, disabled: i, exact: a } = t || {}, l = T.useRef(s);
|
|
105
|
-
l.current = s, st({
|
|
106
|
-
disabled: i,
|
|
107
|
-
subject: e._subjects.values,
|
|
108
|
-
next: (p) => {
|
|
109
|
-
yr(l.current, p.name, a) && d(G(pr(l.current, e._names, p.values || e._formValues, !1, n)));
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
const [o, d] = T.useState(e._getWatch(s, n));
|
|
113
|
-
return T.useEffect(() => e._removeUnmounted()), o;
|
|
114
|
-
}
|
|
115
|
-
var Dt = (t) => /^\w*$/.test(t), gr = (t) => Le(t.replace(/["|']|\]/g, "").split(/\.|\[/)), L = (t, r, e) => {
|
|
116
|
-
let s = -1;
|
|
117
|
-
const n = Dt(r) ? [r] : gr(r), i = n.length, a = i - 1;
|
|
118
|
-
for (; ++s < i; ) {
|
|
119
|
-
const l = n[s];
|
|
120
|
-
let o = e;
|
|
121
|
-
if (s !== a) {
|
|
122
|
-
const d = t[l];
|
|
123
|
-
o = J(d) || Array.isArray(d) ? d : isNaN(+n[s + 1]) ? {} : [];
|
|
124
|
-
}
|
|
125
|
-
t[l] = o, t = t[l];
|
|
126
|
-
}
|
|
127
|
-
return t;
|
|
128
|
-
};
|
|
129
|
-
function ns(t) {
|
|
130
|
-
const r = rt(), { name: e, disabled: s, control: n = r.control, shouldUnregister: i } = t, a = fr(n._names.array, e), l = mr({
|
|
131
|
-
control: n,
|
|
132
|
-
name: e,
|
|
133
|
-
defaultValue: v(n._formValues, e, v(n._defaultValues, e, t.defaultValue)),
|
|
134
|
-
exact: !0
|
|
135
|
-
}), o = ss({
|
|
136
|
-
control: n,
|
|
137
|
-
name: e
|
|
138
|
-
}), d = T.useRef(n.register(e, {
|
|
139
|
-
...t.rules,
|
|
140
|
-
value: l,
|
|
141
|
-
...he(t.disabled) ? { disabled: t.disabled } : {}
|
|
142
|
-
}));
|
|
143
|
-
return T.useEffect(() => {
|
|
144
|
-
const p = n._options.shouldUnregister || i, h = (y, N) => {
|
|
145
|
-
const I = v(n._fields, y);
|
|
146
|
-
I && (I._f.mount = N);
|
|
147
|
-
};
|
|
148
|
-
if (h(e, !0), p) {
|
|
149
|
-
const y = G(v(n._options.defaultValues, e));
|
|
150
|
-
L(n._defaultValues, e, y), W(v(n._formValues, e)) && L(n._formValues, e, y);
|
|
151
|
-
}
|
|
152
|
-
return () => {
|
|
153
|
-
(a ? p && !n._state.action : p) ? n.unregister(e) : h(e, !1);
|
|
154
|
-
};
|
|
155
|
-
}, [e, n, a, i]), T.useEffect(() => {
|
|
156
|
-
v(n._fields, e) && n._updateDisabledField({
|
|
157
|
-
disabled: s,
|
|
158
|
-
fields: n._fields,
|
|
159
|
-
name: e,
|
|
160
|
-
value: v(n._fields, e)._f.value
|
|
161
|
-
});
|
|
162
|
-
}, [s, e, n]), {
|
|
163
|
-
field: {
|
|
164
|
-
name: e,
|
|
165
|
-
value: l,
|
|
166
|
-
...he(s) || o.disabled ? { disabled: o.disabled || s } : {},
|
|
167
|
-
onChange: T.useCallback((p) => d.current.onChange({
|
|
168
|
-
target: {
|
|
169
|
-
value: cr(p),
|
|
170
|
-
name: e
|
|
171
|
-
},
|
|
172
|
-
type: Ge.CHANGE
|
|
173
|
-
}), [e]),
|
|
174
|
-
onBlur: T.useCallback(() => d.current.onBlur({
|
|
175
|
-
target: {
|
|
176
|
-
value: v(n._formValues, e),
|
|
177
|
-
name: e
|
|
178
|
-
},
|
|
179
|
-
type: Ge.BLUR
|
|
180
|
-
}), [e, n]),
|
|
181
|
-
ref: (p) => {
|
|
182
|
-
const h = v(n._fields, e);
|
|
183
|
-
h && p && (h._f.ref = {
|
|
184
|
-
focus: () => p.focus(),
|
|
185
|
-
select: () => p.select(),
|
|
186
|
-
setCustomValidity: (y) => p.setCustomValidity(y),
|
|
187
|
-
reportValidity: () => p.reportValidity()
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
formState: o,
|
|
192
|
-
fieldState: Object.defineProperties({}, {
|
|
193
|
-
invalid: {
|
|
194
|
-
enumerable: !0,
|
|
195
|
-
get: () => !!v(o.errors, e)
|
|
196
|
-
},
|
|
197
|
-
isDirty: {
|
|
198
|
-
enumerable: !0,
|
|
199
|
-
get: () => !!v(o.dirtyFields, e)
|
|
200
|
-
},
|
|
201
|
-
isTouched: {
|
|
202
|
-
enumerable: !0,
|
|
203
|
-
get: () => !!v(o.touchedFields, e)
|
|
204
|
-
},
|
|
205
|
-
error: {
|
|
206
|
-
enumerable: !0,
|
|
207
|
-
get: () => v(o.errors, e)
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
var is = (t, r, e, s, n) => r ? {
|
|
213
|
-
...e[t],
|
|
214
|
-
types: {
|
|
215
|
-
...e[t] && e[t].types ? e[t].types : {},
|
|
216
|
-
[s]: n || !0
|
|
217
|
-
}
|
|
218
|
-
} : {}, Se = () => {
|
|
219
|
-
const t = typeof performance > "u" ? Date.now() : performance.now() * 1e3;
|
|
220
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
|
|
221
|
-
const e = (Math.random() * 16 + t) % 16 | 0;
|
|
222
|
-
return (r == "x" ? e : e & 3 | 8).toString(16);
|
|
223
|
-
});
|
|
224
|
-
}, ot = (t, r, e = {}) => e.shouldFocus || W(e.shouldFocus) ? e.focusName || `${t}.${W(e.focusIndex) ? r : e.focusIndex}.` : "", $t = (t) => ({
|
|
225
|
-
isOnSubmit: !t || t === ce.onSubmit,
|
|
226
|
-
isOnBlur: t === ce.onBlur,
|
|
227
|
-
isOnChange: t === ce.onChange,
|
|
228
|
-
isOnAll: t === ce.all,
|
|
229
|
-
isOnTouch: t === ce.onTouched
|
|
230
|
-
}), St = (t, r, e) => !e && (r.watchAll || r.watch.has(t) || [...r.watch].some((s) => t.startsWith(s) && /^\.\w+/.test(t.slice(s.length))));
|
|
231
|
-
const Ue = (t, r, e, s) => {
|
|
232
|
-
for (const n of e || Object.keys(t)) {
|
|
233
|
-
const i = v(t, n);
|
|
234
|
-
if (i) {
|
|
235
|
-
const { _f: a, ...l } = i;
|
|
236
|
-
if (a) {
|
|
237
|
-
if (a.refs && a.refs[0] && r(a.refs[0], n) && !s)
|
|
238
|
-
break;
|
|
239
|
-
if (a.ref && r(a.ref, a.name) && !s)
|
|
240
|
-
break;
|
|
241
|
-
Ue(l, r);
|
|
242
|
-
} else
|
|
243
|
-
J(l) && Ue(l, r);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
var br = (t, r, e) => {
|
|
248
|
-
const s = Le(v(t, e));
|
|
249
|
-
return L(s, "root", r[e]), L(t, e, s), t;
|
|
250
|
-
}, Ct = (t) => t.type === "file", Ae = (t) => typeof t == "function", Je = (t) => {
|
|
251
|
-
if (!Tt)
|
|
252
|
-
return !1;
|
|
253
|
-
const r = t ? t.ownerDocument : 0;
|
|
254
|
-
return t instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
|
|
255
|
-
}, ze = (t) => ge(t), Mt = (t) => t.type === "radio", Ke = (t) => t instanceof RegExp;
|
|
256
|
-
const zt = {
|
|
257
|
-
value: !1,
|
|
258
|
-
isValid: !1
|
|
259
|
-
}, Zt = { value: !0, isValid: !0 };
|
|
260
|
-
var vr = (t) => {
|
|
261
|
-
if (Array.isArray(t)) {
|
|
262
|
-
if (t.length > 1) {
|
|
263
|
-
const r = t.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
264
|
-
return { value: r, isValid: !!r.length };
|
|
265
|
-
}
|
|
266
|
-
return t[0].checked && !t[0].disabled ? (
|
|
267
|
-
// @ts-expect-error expected to work in the browser
|
|
268
|
-
t[0].attributes && !W(t[0].attributes.value) ? W(t[0].value) || t[0].value === "" ? Zt : { value: t[0].value, isValid: !0 } : Zt
|
|
269
|
-
) : zt;
|
|
270
|
-
}
|
|
271
|
-
return zt;
|
|
272
|
-
};
|
|
273
|
-
const Gt = {
|
|
274
|
-
isValid: !1,
|
|
275
|
-
value: null
|
|
276
|
-
};
|
|
277
|
-
var xr = (t) => Array.isArray(t) ? t.reduce((r, e) => e && e.checked && !e.disabled ? {
|
|
278
|
-
isValid: !0,
|
|
279
|
-
value: e.value
|
|
280
|
-
} : r, Gt) : Gt;
|
|
281
|
-
function Jt(t, r, e = "validate") {
|
|
282
|
-
if (ze(t) || Array.isArray(t) && t.every(ze) || he(t) && !t)
|
|
283
|
-
return {
|
|
284
|
-
type: e,
|
|
285
|
-
message: ze(t) ? t : "",
|
|
286
|
-
ref: r
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
var je = (t) => J(t) && !Ke(t) ? t : {
|
|
290
|
-
value: t,
|
|
291
|
-
message: ""
|
|
292
|
-
}, At = async (t, r, e, s, n) => {
|
|
293
|
-
const { ref: i, refs: a, required: l, maxLength: o, minLength: d, min: p, max: h, pattern: y, validate: N, name: I, valueAsNumber: z, mount: ne, disabled: te } = t._f, D = v(r, I);
|
|
294
|
-
if (!ne || te)
|
|
295
|
-
return {};
|
|
296
|
-
const K = a ? a[0] : i, re = (j) => {
|
|
297
|
-
s && K.reportValidity && (K.setCustomValidity(he(j) ? "" : j || ""), K.reportValidity());
|
|
298
|
-
}, w = {}, A = Mt(i), C = He(i), H = A || C, P = (z || Ct(i)) && W(i.value) && W(D) || Je(i) && i.value === "" || D === "" || Array.isArray(D) && !D.length, R = is.bind(null, I, e, w), O = (j, M, k, b = be.maxLength, m = be.minLength) => {
|
|
299
|
-
const $ = j ? M : k;
|
|
300
|
-
w[I] = {
|
|
301
|
-
type: j ? b : m,
|
|
302
|
-
message: $,
|
|
303
|
-
ref: i,
|
|
304
|
-
...R(j ? b : m, $)
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
if (n ? !Array.isArray(D) || !D.length : l && (!H && (P || ae(D)) || he(D) && !D || C && !vr(a).isValid || A && !xr(a).isValid)) {
|
|
308
|
-
const { value: j, message: M } = ze(l) ? { value: !!l, message: l } : je(l);
|
|
309
|
-
if (j && (w[I] = {
|
|
310
|
-
type: be.required,
|
|
311
|
-
message: M,
|
|
312
|
-
ref: K,
|
|
313
|
-
...R(be.required, M)
|
|
314
|
-
}, !e))
|
|
315
|
-
return re(M), w;
|
|
316
|
-
}
|
|
317
|
-
if (!P && (!ae(p) || !ae(h))) {
|
|
318
|
-
let j, M;
|
|
319
|
-
const k = je(h), b = je(p);
|
|
320
|
-
if (!ae(D) && !isNaN(D)) {
|
|
321
|
-
const m = i.valueAsNumber || D && +D;
|
|
322
|
-
ae(k.value) || (j = m > k.value), ae(b.value) || (M = m < b.value);
|
|
323
|
-
} else {
|
|
324
|
-
const m = i.valueAsDate || new Date(D), $ = (F) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + F), _ = i.type == "time", V = i.type == "week";
|
|
325
|
-
ge(k.value) && D && (j = _ ? $(D) > $(k.value) : V ? D > k.value : m > new Date(k.value)), ge(b.value) && D && (M = _ ? $(D) < $(b.value) : V ? D < b.value : m < new Date(b.value));
|
|
326
|
-
}
|
|
327
|
-
if ((j || M) && (O(!!j, k.message, b.message, be.max, be.min), !e))
|
|
328
|
-
return re(w[I].message), w;
|
|
329
|
-
}
|
|
330
|
-
if ((o || d) && !P && (ge(D) || n && Array.isArray(D))) {
|
|
331
|
-
const j = je(o), M = je(d), k = !ae(j.value) && D.length > +j.value, b = !ae(M.value) && D.length < +M.value;
|
|
332
|
-
if ((k || b) && (O(k, j.message, M.message), !e))
|
|
333
|
-
return re(w[I].message), w;
|
|
334
|
-
}
|
|
335
|
-
if (y && !P && ge(D)) {
|
|
336
|
-
const { value: j, message: M } = je(y);
|
|
337
|
-
if (Ke(j) && !D.match(j) && (w[I] = {
|
|
338
|
-
type: be.pattern,
|
|
339
|
-
message: M,
|
|
340
|
-
ref: i,
|
|
341
|
-
...R(be.pattern, M)
|
|
342
|
-
}, !e))
|
|
343
|
-
return re(M), w;
|
|
344
|
-
}
|
|
345
|
-
if (N) {
|
|
346
|
-
if (Ae(N)) {
|
|
347
|
-
const j = await N(D, r), M = Jt(j, K);
|
|
348
|
-
if (M && (w[I] = {
|
|
349
|
-
...M,
|
|
350
|
-
...R(be.validate, M.message)
|
|
351
|
-
}, !e))
|
|
352
|
-
return re(M.message), w;
|
|
353
|
-
} else if (J(N)) {
|
|
354
|
-
let j = {};
|
|
355
|
-
for (const M in N) {
|
|
356
|
-
if (!le(j) && !e)
|
|
357
|
-
break;
|
|
358
|
-
const k = Jt(await N[M](D, r), K, M);
|
|
359
|
-
k && (j = {
|
|
360
|
-
...k,
|
|
361
|
-
...R(M, k.message)
|
|
362
|
-
}, re(k.message), e && (w[I] = j));
|
|
363
|
-
}
|
|
364
|
-
if (!le(j) && (w[I] = {
|
|
365
|
-
ref: K,
|
|
366
|
-
...j
|
|
367
|
-
}, !e))
|
|
368
|
-
return w;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
return re(!0), w;
|
|
372
|
-
}, ct = (t, r) => [
|
|
373
|
-
...t,
|
|
374
|
-
...oe(r)
|
|
375
|
-
], ft = (t) => Array.isArray(t) ? t.map(() => {
|
|
376
|
-
}) : void 0;
|
|
377
|
-
function dt(t, r, e) {
|
|
378
|
-
return [
|
|
379
|
-
...t.slice(0, r),
|
|
380
|
-
...oe(e),
|
|
381
|
-
...t.slice(r)
|
|
382
|
-
];
|
|
383
|
-
}
|
|
384
|
-
var ht = (t, r, e) => Array.isArray(t) ? (W(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], yt = (t, r) => [
|
|
385
|
-
...oe(r),
|
|
386
|
-
...oe(t)
|
|
387
|
-
];
|
|
388
|
-
function as(t, r) {
|
|
389
|
-
let e = 0;
|
|
390
|
-
const s = [...t];
|
|
391
|
-
for (const n of r)
|
|
392
|
-
s.splice(n - e, 1), e++;
|
|
393
|
-
return Le(s).length ? s : [];
|
|
394
|
-
}
|
|
395
|
-
var pt = (t, r) => W(r) ? [] : as(t, oe(r).sort((e, s) => e - s)), mt = (t, r, e) => {
|
|
396
|
-
[t[r], t[e]] = [t[e], t[r]];
|
|
397
|
-
};
|
|
398
|
-
function us(t, r) {
|
|
399
|
-
const e = r.slice(0, -1).length;
|
|
400
|
-
let s = 0;
|
|
401
|
-
for (; s < e; )
|
|
402
|
-
t = W(t) ? s++ : t[r[s++]];
|
|
403
|
-
return t;
|
|
404
|
-
}
|
|
405
|
-
function ls(t) {
|
|
406
|
-
for (const r in t)
|
|
407
|
-
if (t.hasOwnProperty(r) && !W(t[r]))
|
|
408
|
-
return !1;
|
|
409
|
-
return !0;
|
|
410
|
-
}
|
|
411
|
-
function ee(t, r) {
|
|
412
|
-
const e = Array.isArray(r) ? r : Dt(r) ? [r] : gr(r), s = e.length === 1 ? t : us(t, e), n = e.length - 1, i = e[n];
|
|
413
|
-
return s && delete s[i], n !== 0 && (J(s) && le(s) || Array.isArray(s) && ls(s)) && ee(t, e.slice(0, -1)), t;
|
|
414
|
-
}
|
|
415
|
-
var Kt = (t, r, e) => (t[r] = e, t);
|
|
416
|
-
function os(t) {
|
|
417
|
-
const r = rt(), { control: e = r.control, name: s, keyName: n = "id", shouldUnregister: i } = t, [a, l] = T.useState(e._getFieldArray(s)), o = T.useRef(e._getFieldArray(s).map(Se)), d = T.useRef(a), p = T.useRef(s), h = T.useRef(!1);
|
|
418
|
-
p.current = s, d.current = a, e._names.array.add(s), t.rules && e.register(s, t.rules), st({
|
|
419
|
-
next: ({ values: w, name: A }) => {
|
|
420
|
-
if (A === p.current || !A) {
|
|
421
|
-
const C = v(w, p.current);
|
|
422
|
-
Array.isArray(C) && (l(C), o.current = C.map(Se));
|
|
423
|
-
}
|
|
424
|
-
},
|
|
425
|
-
subject: e._subjects.array
|
|
426
|
-
});
|
|
427
|
-
const y = T.useCallback((w) => {
|
|
428
|
-
h.current = !0, e._updateFieldArray(s, w);
|
|
429
|
-
}, [e, s]), N = (w, A) => {
|
|
430
|
-
const C = oe(G(w)), H = ct(e._getFieldArray(s), C);
|
|
431
|
-
e._names.focus = ot(s, H.length - 1, A), o.current = ct(o.current, C.map(Se)), y(H), l(H), e._updateFieldArray(s, H, ct, {
|
|
432
|
-
argA: ft(w)
|
|
433
|
-
});
|
|
434
|
-
}, I = (w, A) => {
|
|
435
|
-
const C = oe(G(w)), H = yt(e._getFieldArray(s), C);
|
|
436
|
-
e._names.focus = ot(s, 0, A), o.current = yt(o.current, C.map(Se)), y(H), l(H), e._updateFieldArray(s, H, yt, {
|
|
437
|
-
argA: ft(w)
|
|
438
|
-
});
|
|
439
|
-
}, z = (w) => {
|
|
440
|
-
const A = pt(e._getFieldArray(s), w);
|
|
441
|
-
o.current = pt(o.current, w), y(A), l(A), e._updateFieldArray(s, A, pt, {
|
|
442
|
-
argA: w
|
|
443
|
-
});
|
|
444
|
-
}, ne = (w, A, C) => {
|
|
445
|
-
const H = oe(G(A)), P = dt(e._getFieldArray(s), w, H);
|
|
446
|
-
e._names.focus = ot(s, w, C), o.current = dt(o.current, w, H.map(Se)), y(P), l(P), e._updateFieldArray(s, P, dt, {
|
|
447
|
-
argA: w,
|
|
448
|
-
argB: ft(A)
|
|
449
|
-
});
|
|
450
|
-
}, te = (w, A) => {
|
|
451
|
-
const C = e._getFieldArray(s);
|
|
452
|
-
mt(C, w, A), mt(o.current, w, A), y(C), l(C), e._updateFieldArray(s, C, mt, {
|
|
453
|
-
argA: w,
|
|
454
|
-
argB: A
|
|
455
|
-
}, !1);
|
|
456
|
-
}, D = (w, A) => {
|
|
457
|
-
const C = e._getFieldArray(s);
|
|
458
|
-
ht(C, w, A), ht(o.current, w, A), y(C), l(C), e._updateFieldArray(s, C, ht, {
|
|
459
|
-
argA: w,
|
|
460
|
-
argB: A
|
|
461
|
-
}, !1);
|
|
462
|
-
}, K = (w, A) => {
|
|
463
|
-
const C = G(A), H = Kt(e._getFieldArray(s), w, C);
|
|
464
|
-
o.current = [...H].map((P, R) => !P || R === w ? Se() : o.current[R]), y(H), l([...H]), e._updateFieldArray(s, H, Kt, {
|
|
465
|
-
argA: w,
|
|
466
|
-
argB: C
|
|
467
|
-
}, !0, !1);
|
|
468
|
-
}, re = (w) => {
|
|
469
|
-
const A = oe(G(w));
|
|
470
|
-
o.current = A.map(Se), y([...A]), l([...A]), e._updateFieldArray(s, [...A], (C) => C, {}, !0, !1);
|
|
471
|
-
};
|
|
472
|
-
return T.useEffect(() => {
|
|
473
|
-
if (e._state.action = !1, St(s, e._names) && e._subjects.state.next({
|
|
474
|
-
...e._formState
|
|
475
|
-
}), h.current && (!$t(e._options.mode).isOnSubmit || e._formState.isSubmitted))
|
|
476
|
-
if (e._options.resolver)
|
|
477
|
-
e._executeSchema([s]).then((w) => {
|
|
478
|
-
const A = v(w.errors, s), C = v(e._formState.errors, s);
|
|
479
|
-
(C ? !A && C.type || A && (C.type !== A.type || C.message !== A.message) : A && A.type) && (A ? L(e._formState.errors, s, A) : ee(e._formState.errors, s), e._subjects.state.next({
|
|
480
|
-
errors: e._formState.errors
|
|
481
|
-
}));
|
|
482
|
-
});
|
|
483
|
-
else {
|
|
484
|
-
const w = v(e._fields, s);
|
|
485
|
-
w && w._f && At(w, e._formValues, e._options.criteriaMode === ce.all, e._options.shouldUseNativeValidation, !0).then((A) => !le(A) && e._subjects.state.next({
|
|
486
|
-
errors: br(e._formState.errors, A, s)
|
|
487
|
-
}));
|
|
488
|
-
}
|
|
489
|
-
e._subjects.values.next({
|
|
490
|
-
name: s,
|
|
491
|
-
values: { ...e._formValues }
|
|
492
|
-
}), e._names.focus && Ue(e._fields, (w, A) => {
|
|
493
|
-
if (e._names.focus && A.startsWith(e._names.focus) && w.focus)
|
|
494
|
-
return w.focus(), 1;
|
|
495
|
-
}), e._names.focus = "", e._updateValid(), h.current = !1;
|
|
496
|
-
}, [a, s, e]), T.useEffect(() => (!v(e._formValues, s) && e._updateFieldArray(s), () => {
|
|
497
|
-
(e._options.shouldUnregister || i) && e.unregister(s);
|
|
498
|
-
}), [s, e, n, i]), {
|
|
499
|
-
swap: T.useCallback(te, [y, s, e]),
|
|
500
|
-
move: T.useCallback(D, [y, s, e]),
|
|
501
|
-
prepend: T.useCallback(I, [y, s, e]),
|
|
502
|
-
append: T.useCallback(N, [y, s, e]),
|
|
503
|
-
remove: T.useCallback(z, [y, s, e]),
|
|
504
|
-
insert: T.useCallback(ne, [y, s, e]),
|
|
505
|
-
update: T.useCallback(K, [y, s, e]),
|
|
506
|
-
replace: T.useCallback(re, [y, s, e]),
|
|
507
|
-
fields: T.useMemo(() => a.map((w, A) => ({
|
|
508
|
-
...w,
|
|
509
|
-
[n]: o.current[A] || Se()
|
|
510
|
-
})), [a, n])
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
var gt = () => {
|
|
514
|
-
let t = [];
|
|
515
|
-
return {
|
|
516
|
-
get observers() {
|
|
517
|
-
return t;
|
|
518
|
-
},
|
|
519
|
-
next: (n) => {
|
|
520
|
-
for (const i of t)
|
|
521
|
-
i.next && i.next(n);
|
|
522
|
-
},
|
|
523
|
-
subscribe: (n) => (t.push(n), {
|
|
524
|
-
unsubscribe: () => {
|
|
525
|
-
t = t.filter((i) => i !== n);
|
|
526
|
-
}
|
|
527
|
-
}),
|
|
528
|
-
unsubscribe: () => {
|
|
529
|
-
t = [];
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
}, Xe = (t) => ae(t) || !or(t);
|
|
533
|
-
function Ve(t, r) {
|
|
534
|
-
if (Xe(t) || Xe(r))
|
|
535
|
-
return t === r;
|
|
536
|
-
if (Ie(t) && Ie(r))
|
|
537
|
-
return t.getTime() === r.getTime();
|
|
538
|
-
const e = Object.keys(t), s = Object.keys(r);
|
|
539
|
-
if (e.length !== s.length)
|
|
540
|
-
return !1;
|
|
541
|
-
for (const n of e) {
|
|
542
|
-
const i = t[n];
|
|
543
|
-
if (!s.includes(n))
|
|
544
|
-
return !1;
|
|
545
|
-
if (n !== "ref") {
|
|
546
|
-
const a = r[n];
|
|
547
|
-
if (Ie(i) && Ie(a) || J(i) && J(a) || Array.isArray(i) && Array.isArray(a) ? !Ve(i, a) : i !== a)
|
|
548
|
-
return !1;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
return !0;
|
|
552
|
-
}
|
|
553
|
-
var _r = (t) => t.type === "select-multiple", cs = (t) => Mt(t) || He(t), bt = (t) => Je(t) && t.isConnected, wr = (t) => {
|
|
554
|
-
for (const r in t)
|
|
555
|
-
if (Ae(t[r]))
|
|
556
|
-
return !0;
|
|
557
|
-
return !1;
|
|
558
|
-
};
|
|
559
|
-
function Qe(t, r = {}) {
|
|
560
|
-
const e = Array.isArray(t);
|
|
561
|
-
if (J(t) || e)
|
|
562
|
-
for (const s in t)
|
|
563
|
-
Array.isArray(t[s]) || J(t[s]) && !wr(t[s]) ? (r[s] = Array.isArray(t[s]) ? [] : {}, Qe(t[s], r[s])) : ae(t[s]) || (r[s] = !0);
|
|
564
|
-
return r;
|
|
565
|
-
}
|
|
566
|
-
function kr(t, r, e) {
|
|
567
|
-
const s = Array.isArray(t);
|
|
568
|
-
if (J(t) || s)
|
|
569
|
-
for (const n in t)
|
|
570
|
-
Array.isArray(t[n]) || J(t[n]) && !wr(t[n]) ? W(r) || Xe(e[n]) ? e[n] = Array.isArray(t[n]) ? Qe(t[n], []) : { ...Qe(t[n]) } : kr(t[n], ae(r) ? {} : r[n], e[n]) : e[n] = !Ve(t[n], r[n]);
|
|
571
|
-
return e;
|
|
572
|
-
}
|
|
573
|
-
var vt = (t, r) => kr(t, r, Qe(r)), $r = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => W(t) ? t : r ? t === "" ? NaN : t && +t : e && ge(t) ? new Date(t) : s ? s(t) : t;
|
|
574
|
-
function xt(t) {
|
|
575
|
-
const r = t.ref;
|
|
576
|
-
if (!(t.refs ? t.refs.every((e) => e.disabled) : r.disabled))
|
|
577
|
-
return Ct(r) ? r.files : Mt(r) ? xr(t.refs).value : _r(r) ? [...r.selectedOptions].map(({ value: e }) => e) : He(r) ? vr(t.refs).value : $r(W(r.value) ? t.ref.value : r.value, t);
|
|
578
|
-
}
|
|
579
|
-
var fs = (t, r, e, s) => {
|
|
580
|
-
const n = {};
|
|
581
|
-
for (const i of t) {
|
|
582
|
-
const a = v(r, i);
|
|
583
|
-
a && L(n, i, a._f);
|
|
584
|
-
}
|
|
585
|
-
return {
|
|
586
|
-
criteriaMode: e,
|
|
587
|
-
names: [...t],
|
|
588
|
-
fields: n,
|
|
589
|
-
shouldUseNativeValidation: s
|
|
590
|
-
};
|
|
591
|
-
}, Pe = (t) => W(t) ? t : Ke(t) ? t.source : J(t) ? Ke(t.value) ? t.value.source : t.value : t, ds = (t) => t.mount && (t.required || t.min || t.max || t.maxLength || t.minLength || t.pattern || t.validate);
|
|
592
|
-
function Xt(t, r, e) {
|
|
593
|
-
const s = v(t, e);
|
|
594
|
-
if (s || Dt(e))
|
|
595
|
-
return {
|
|
596
|
-
error: s,
|
|
597
|
-
name: e
|
|
598
|
-
};
|
|
599
|
-
const n = e.split(".");
|
|
600
|
-
for (; n.length; ) {
|
|
601
|
-
const i = n.join("."), a = v(r, i), l = v(t, i);
|
|
602
|
-
if (a && !Array.isArray(a) && e !== i)
|
|
603
|
-
return { name: e };
|
|
604
|
-
if (l && l.type)
|
|
605
|
-
return {
|
|
606
|
-
name: i,
|
|
607
|
-
error: l
|
|
608
|
-
};
|
|
609
|
-
n.pop();
|
|
610
|
-
}
|
|
611
|
-
return {
|
|
612
|
-
name: e
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
var hs = (t, r, e, s, n) => n.isOnAll ? !1 : !e && n.isOnTouch ? !(r || t) : (e ? s.isOnBlur : n.isOnBlur) ? !t : (e ? s.isOnChange : n.isOnChange) ? t : !0, ys = (t, r) => !Le(v(t, r)).length && ee(t, r);
|
|
616
|
-
const ps = {
|
|
617
|
-
mode: ce.onSubmit,
|
|
618
|
-
reValidateMode: ce.onChange,
|
|
619
|
-
shouldFocusError: !0
|
|
620
|
-
};
|
|
621
|
-
function ms(t = {}, r) {
|
|
622
|
-
let e = {
|
|
623
|
-
...ps,
|
|
624
|
-
...t
|
|
625
|
-
}, s = {
|
|
626
|
-
submitCount: 0,
|
|
627
|
-
isDirty: !1,
|
|
628
|
-
isLoading: Ae(e.defaultValues),
|
|
629
|
-
isValidating: !1,
|
|
630
|
-
isSubmitted: !1,
|
|
631
|
-
isSubmitting: !1,
|
|
632
|
-
isSubmitSuccessful: !1,
|
|
633
|
-
isValid: !1,
|
|
634
|
-
touchedFields: {},
|
|
635
|
-
dirtyFields: {},
|
|
636
|
-
errors: e.errors || {},
|
|
637
|
-
disabled: e.disabled || !1
|
|
638
|
-
}, n = {}, i = J(e.defaultValues) || J(e.values) ? G(e.defaultValues || e.values) || {} : {}, a = e.shouldUnregister ? {} : G(i), l = {
|
|
639
|
-
action: !1,
|
|
640
|
-
mount: !1,
|
|
641
|
-
watch: !1
|
|
642
|
-
}, o = {
|
|
643
|
-
mount: /* @__PURE__ */ new Set(),
|
|
644
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
645
|
-
array: /* @__PURE__ */ new Set(),
|
|
646
|
-
watch: /* @__PURE__ */ new Set()
|
|
647
|
-
}, d, p = 0;
|
|
648
|
-
const h = {
|
|
649
|
-
isDirty: !1,
|
|
650
|
-
dirtyFields: !1,
|
|
651
|
-
touchedFields: !1,
|
|
652
|
-
isValidating: !1,
|
|
653
|
-
isValid: !1,
|
|
654
|
-
errors: !1
|
|
655
|
-
}, y = {
|
|
656
|
-
values: gt(),
|
|
657
|
-
array: gt(),
|
|
658
|
-
state: gt()
|
|
659
|
-
}, N = $t(e.mode), I = $t(e.reValidateMode), z = e.criteriaMode === ce.all, ne = (u) => (c) => {
|
|
660
|
-
clearTimeout(p), p = setTimeout(u, c);
|
|
661
|
-
}, te = async (u) => {
|
|
662
|
-
if (h.isValid || u) {
|
|
663
|
-
const c = e.resolver ? le((await P()).errors) : await O(n, !0);
|
|
664
|
-
c !== s.isValid && y.state.next({
|
|
665
|
-
isValid: c
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
}, D = (u) => h.isValidating && y.state.next({
|
|
669
|
-
isValidating: u
|
|
670
|
-
}), K = (u, c = [], f, S, x = !0, g = !0) => {
|
|
671
|
-
if (S && f) {
|
|
672
|
-
if (l.action = !0, g && Array.isArray(v(n, u))) {
|
|
673
|
-
const E = f(v(n, u), S.argA, S.argB);
|
|
674
|
-
x && L(n, u, E);
|
|
675
|
-
}
|
|
676
|
-
if (g && Array.isArray(v(s.errors, u))) {
|
|
677
|
-
const E = f(v(s.errors, u), S.argA, S.argB);
|
|
678
|
-
x && L(s.errors, u, E), ys(s.errors, u);
|
|
679
|
-
}
|
|
680
|
-
if (h.touchedFields && g && Array.isArray(v(s.touchedFields, u))) {
|
|
681
|
-
const E = f(v(s.touchedFields, u), S.argA, S.argB);
|
|
682
|
-
x && L(s.touchedFields, u, E);
|
|
683
|
-
}
|
|
684
|
-
h.dirtyFields && (s.dirtyFields = vt(i, a)), y.state.next({
|
|
685
|
-
name: u,
|
|
686
|
-
isDirty: M(u, c),
|
|
687
|
-
dirtyFields: s.dirtyFields,
|
|
688
|
-
errors: s.errors,
|
|
689
|
-
isValid: s.isValid
|
|
690
|
-
});
|
|
691
|
-
} else
|
|
692
|
-
L(a, u, c);
|
|
693
|
-
}, re = (u, c) => {
|
|
694
|
-
L(s.errors, u, c), y.state.next({
|
|
695
|
-
errors: s.errors
|
|
696
|
-
});
|
|
697
|
-
}, w = (u) => {
|
|
698
|
-
s.errors = u, y.state.next({
|
|
699
|
-
errors: s.errors,
|
|
700
|
-
isValid: !1
|
|
701
|
-
});
|
|
702
|
-
}, A = (u, c, f, S) => {
|
|
703
|
-
const x = v(n, u);
|
|
704
|
-
if (x) {
|
|
705
|
-
const g = v(a, u, W(f) ? v(i, u) : f);
|
|
706
|
-
W(g) || S && S.defaultChecked || c ? L(a, u, c ? g : xt(x._f)) : m(u, g), l.mount && te();
|
|
707
|
-
}
|
|
708
|
-
}, C = (u, c, f, S, x) => {
|
|
709
|
-
let g = !1, E = !1;
|
|
710
|
-
const B = {
|
|
711
|
-
name: u
|
|
712
|
-
}, Q = !!(v(n, u) && v(n, u)._f.disabled);
|
|
713
|
-
if (!f || S) {
|
|
714
|
-
h.isDirty && (E = s.isDirty, s.isDirty = B.isDirty = M(), g = E !== B.isDirty);
|
|
715
|
-
const me = Q || Ve(v(i, u), c);
|
|
716
|
-
E = !!(!Q && v(s.dirtyFields, u)), me || Q ? ee(s.dirtyFields, u) : L(s.dirtyFields, u, !0), B.dirtyFields = s.dirtyFields, g = g || h.dirtyFields && E !== !me;
|
|
717
|
-
}
|
|
718
|
-
if (f) {
|
|
719
|
-
const me = v(s.touchedFields, u);
|
|
720
|
-
me || (L(s.touchedFields, u, f), B.touchedFields = s.touchedFields, g = g || h.touchedFields && me !== f);
|
|
721
|
-
}
|
|
722
|
-
return g && x && y.state.next(B), g ? B : {};
|
|
723
|
-
}, H = (u, c, f, S) => {
|
|
724
|
-
const x = v(s.errors, u), g = h.isValid && he(c) && s.isValid !== c;
|
|
725
|
-
if (t.delayError && f ? (d = ne(() => re(u, f)), d(t.delayError)) : (clearTimeout(p), d = null, f ? L(s.errors, u, f) : ee(s.errors, u)), (f ? !Ve(x, f) : x) || !le(S) || g) {
|
|
726
|
-
const E = {
|
|
727
|
-
...S,
|
|
728
|
-
...g && he(c) ? { isValid: c } : {},
|
|
729
|
-
errors: s.errors,
|
|
730
|
-
name: u
|
|
731
|
-
};
|
|
732
|
-
s = {
|
|
733
|
-
...s,
|
|
734
|
-
...E
|
|
735
|
-
}, y.state.next(E);
|
|
736
|
-
}
|
|
737
|
-
D(!1);
|
|
738
|
-
}, P = async (u) => e.resolver(a, e.context, fs(u || o.mount, n, e.criteriaMode, e.shouldUseNativeValidation)), R = async (u) => {
|
|
739
|
-
const { errors: c } = await P(u);
|
|
740
|
-
if (u)
|
|
741
|
-
for (const f of u) {
|
|
742
|
-
const S = v(c, f);
|
|
743
|
-
S ? L(s.errors, f, S) : ee(s.errors, f);
|
|
744
|
-
}
|
|
745
|
-
else
|
|
746
|
-
s.errors = c;
|
|
747
|
-
return c;
|
|
748
|
-
}, O = async (u, c, f = {
|
|
749
|
-
valid: !0
|
|
750
|
-
}) => {
|
|
751
|
-
for (const S in u) {
|
|
752
|
-
const x = u[S];
|
|
753
|
-
if (x) {
|
|
754
|
-
const { _f: g, ...E } = x;
|
|
755
|
-
if (g) {
|
|
756
|
-
const B = o.array.has(g.name), Q = await At(x, a, z, e.shouldUseNativeValidation && !c, B);
|
|
757
|
-
if (Q[g.name] && (f.valid = !1, c))
|
|
758
|
-
break;
|
|
759
|
-
!c && (v(Q, g.name) ? B ? br(s.errors, Q, g.name) : L(s.errors, g.name, Q[g.name]) : ee(s.errors, g.name));
|
|
760
|
-
}
|
|
761
|
-
E && await O(E, c, f);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
return f.valid;
|
|
765
|
-
}, j = () => {
|
|
766
|
-
for (const u of o.unMount) {
|
|
767
|
-
const c = v(n, u);
|
|
768
|
-
c && (c._f.refs ? c._f.refs.every((f) => !bt(f)) : !bt(c._f.ref)) && fe(u);
|
|
769
|
-
}
|
|
770
|
-
o.unMount = /* @__PURE__ */ new Set();
|
|
771
|
-
}, M = (u, c) => (u && c && L(a, u, c), !Ve(Y(), i)), k = (u, c, f) => pr(u, o, {
|
|
772
|
-
...l.mount ? a : W(c) ? i : ge(u) ? { [u]: c } : c
|
|
773
|
-
}, f, c), b = (u) => Le(v(l.mount ? a : i, u, t.shouldUnregister ? v(i, u, []) : [])), m = (u, c, f = {}) => {
|
|
774
|
-
const S = v(n, u);
|
|
775
|
-
let x = c;
|
|
776
|
-
if (S) {
|
|
777
|
-
const g = S._f;
|
|
778
|
-
g && (!g.disabled && L(a, u, $r(c, g)), x = Je(g.ref) && ae(c) ? "" : c, _r(g.ref) ? [...g.ref.options].forEach((E) => E.selected = x.includes(E.value)) : g.refs ? He(g.ref) ? g.refs.length > 1 ? g.refs.forEach((E) => (!E.defaultChecked || !E.disabled) && (E.checked = Array.isArray(x) ? !!x.find((B) => B === E.value) : x === E.value)) : g.refs[0] && (g.refs[0].checked = !!x) : g.refs.forEach((E) => E.checked = E.value === x) : Ct(g.ref) ? g.ref.value = "" : (g.ref.value = x, g.ref.type || y.values.next({
|
|
779
|
-
name: u,
|
|
780
|
-
values: { ...a }
|
|
781
|
-
})));
|
|
782
|
-
}
|
|
783
|
-
(f.shouldDirty || f.shouldTouch) && C(u, x, f.shouldTouch, f.shouldDirty, !0), f.shouldValidate && U(u);
|
|
784
|
-
}, $ = (u, c, f) => {
|
|
785
|
-
for (const S in c) {
|
|
786
|
-
const x = c[S], g = `${u}.${S}`, E = v(n, g);
|
|
787
|
-
(o.array.has(u) || !Xe(x) || E && !E._f) && !Ie(x) ? $(g, x, f) : m(g, x, f);
|
|
788
|
-
}
|
|
789
|
-
}, _ = (u, c, f = {}) => {
|
|
790
|
-
const S = v(n, u), x = o.array.has(u), g = G(c);
|
|
791
|
-
L(a, u, g), x ? (y.array.next({
|
|
792
|
-
name: u,
|
|
793
|
-
values: { ...a }
|
|
794
|
-
}), (h.isDirty || h.dirtyFields) && f.shouldDirty && y.state.next({
|
|
795
|
-
name: u,
|
|
796
|
-
dirtyFields: vt(i, a),
|
|
797
|
-
isDirty: M(u, g)
|
|
798
|
-
})) : S && !S._f && !ae(g) ? $(u, g, f) : m(u, g, f), St(u, o) && y.state.next({ ...s }), y.values.next({
|
|
799
|
-
name: u,
|
|
800
|
-
values: { ...a }
|
|
801
|
-
}), !l.mount && r();
|
|
802
|
-
}, V = async (u) => {
|
|
803
|
-
const c = u.target;
|
|
804
|
-
let f = c.name, S = !0;
|
|
805
|
-
const x = v(n, f), g = () => c.type ? xt(x._f) : cr(u), E = (B) => {
|
|
806
|
-
S = Number.isNaN(B) || B === v(a, f, B);
|
|
807
|
-
};
|
|
808
|
-
if (x) {
|
|
809
|
-
let B, Q;
|
|
810
|
-
const me = g(), Me = u.type === Ge.BLUR || u.type === Ge.FOCUS_OUT, Pr = !ds(x._f) && !e.resolver && !v(s.errors, f) && !x._f.deps || hs(Me, v(s.touchedFields, f), s.isSubmitted, I, N), ut = St(f, o, Me);
|
|
811
|
-
L(a, f, me), Me ? (x._f.onBlur && x._f.onBlur(u), d && d(0)) : x._f.onChange && x._f.onChange(u);
|
|
812
|
-
const lt = C(f, me, Me, !1), Br = !le(lt) || ut;
|
|
813
|
-
if (!Me && y.values.next({
|
|
814
|
-
name: f,
|
|
815
|
-
type: u.type,
|
|
816
|
-
values: { ...a }
|
|
817
|
-
}), Pr)
|
|
818
|
-
return h.isValid && te(), Br && y.state.next({ name: f, ...ut ? {} : lt });
|
|
819
|
-
if (!Me && ut && y.state.next({ ...s }), D(!0), e.resolver) {
|
|
820
|
-
const { errors: Yt } = await P([f]);
|
|
821
|
-
if (E(me), S) {
|
|
822
|
-
const Wr = Xt(s.errors, n, f), qt = Xt(Yt, n, Wr.name || f);
|
|
823
|
-
B = qt.error, f = qt.name, Q = le(Yt);
|
|
824
|
-
}
|
|
825
|
-
} else
|
|
826
|
-
B = (await At(x, a, z, e.shouldUseNativeValidation))[f], E(me), S && (B ? Q = !1 : h.isValid && (Q = await O(n, !0)));
|
|
827
|
-
S && (x._f.deps && U(x._f.deps), H(f, Q, B, lt));
|
|
828
|
-
}
|
|
829
|
-
}, F = (u, c) => {
|
|
830
|
-
if (v(s.errors, c) && u.focus)
|
|
831
|
-
return u.focus(), 1;
|
|
832
|
-
}, U = async (u, c = {}) => {
|
|
833
|
-
let f, S;
|
|
834
|
-
const x = oe(u);
|
|
835
|
-
if (D(!0), e.resolver) {
|
|
836
|
-
const g = await R(W(u) ? u : x);
|
|
837
|
-
f = le(g), S = u ? !x.some((E) => v(g, E)) : f;
|
|
838
|
-
} else
|
|
839
|
-
u ? (S = (await Promise.all(x.map(async (g) => {
|
|
840
|
-
const E = v(n, g);
|
|
841
|
-
return await O(E && E._f ? { [g]: E } : E);
|
|
842
|
-
}))).every(Boolean), !(!S && !s.isValid) && te()) : S = f = await O(n);
|
|
843
|
-
return y.state.next({
|
|
844
|
-
...!ge(u) || h.isValid && f !== s.isValid ? {} : { name: u },
|
|
845
|
-
...e.resolver || !u ? { isValid: f } : {},
|
|
846
|
-
errors: s.errors,
|
|
847
|
-
isValidating: !1
|
|
848
|
-
}), c.shouldFocus && !S && Ue(n, F, u ? x : o.mount), S;
|
|
849
|
-
}, Y = (u) => {
|
|
850
|
-
const c = {
|
|
851
|
-
...i,
|
|
852
|
-
...l.mount ? a : {}
|
|
853
|
-
};
|
|
854
|
-
return W(u) ? c : ge(u) ? v(c, u) : u.map((f) => v(c, f));
|
|
855
|
-
}, Z = (u, c) => ({
|
|
856
|
-
invalid: !!v((c || s).errors, u),
|
|
857
|
-
isDirty: !!v((c || s).dirtyFields, u),
|
|
858
|
-
isTouched: !!v((c || s).touchedFields, u),
|
|
859
|
-
error: v((c || s).errors, u)
|
|
860
|
-
}), X = (u) => {
|
|
861
|
-
u && oe(u).forEach((c) => ee(s.errors, c)), y.state.next({
|
|
862
|
-
errors: u ? s.errors : {}
|
|
863
|
-
});
|
|
864
|
-
}, ie = (u, c, f) => {
|
|
865
|
-
const S = (v(n, u, { _f: {} })._f || {}).ref;
|
|
866
|
-
L(s.errors, u, {
|
|
867
|
-
...c,
|
|
868
|
-
ref: S
|
|
869
|
-
}), y.state.next({
|
|
870
|
-
name: u,
|
|
871
|
-
errors: s.errors,
|
|
872
|
-
isValid: !1
|
|
873
|
-
}), f && f.shouldFocus && S && S.focus && S.focus();
|
|
874
|
-
}, we = (u, c) => Ae(u) ? y.values.subscribe({
|
|
875
|
-
next: (f) => u(k(void 0, c), f)
|
|
876
|
-
}) : k(u, c, !0), fe = (u, c = {}) => {
|
|
877
|
-
for (const f of u ? oe(u) : o.mount)
|
|
878
|
-
o.mount.delete(f), o.array.delete(f), c.keepValue || (ee(n, f), ee(a, f)), !c.keepError && ee(s.errors, f), !c.keepDirty && ee(s.dirtyFields, f), !c.keepTouched && ee(s.touchedFields, f), !e.shouldUnregister && !c.keepDefaultValue && ee(i, f);
|
|
879
|
-
y.values.next({
|
|
880
|
-
values: { ...a }
|
|
881
|
-
}), y.state.next({
|
|
882
|
-
...s,
|
|
883
|
-
...c.keepDirty ? { isDirty: M() } : {}
|
|
884
|
-
}), !c.keepIsValid && te();
|
|
885
|
-
}, ke = ({ disabled: u, name: c, field: f, fields: S, value: x }) => {
|
|
886
|
-
if (he(u)) {
|
|
887
|
-
const g = u ? void 0 : W(x) ? xt(f ? f._f : v(S, c)._f) : x;
|
|
888
|
-
L(a, c, g), C(c, g, !1, !1, !0);
|
|
889
|
-
}
|
|
890
|
-
}, de = (u, c = {}) => {
|
|
891
|
-
let f = v(n, u);
|
|
892
|
-
const S = he(c.disabled);
|
|
893
|
-
return L(n, u, {
|
|
894
|
-
...f || {},
|
|
895
|
-
_f: {
|
|
896
|
-
...f && f._f ? f._f : { ref: { name: u } },
|
|
897
|
-
name: u,
|
|
898
|
-
mount: !0,
|
|
899
|
-
...c
|
|
900
|
-
}
|
|
901
|
-
}), o.mount.add(u), f ? ke({
|
|
902
|
-
field: f,
|
|
903
|
-
disabled: c.disabled,
|
|
904
|
-
name: u,
|
|
905
|
-
value: c.value
|
|
906
|
-
}) : A(u, !0, c.value), {
|
|
907
|
-
...S ? { disabled: c.disabled } : {},
|
|
908
|
-
...e.progressive ? {
|
|
909
|
-
required: !!c.required,
|
|
910
|
-
min: Pe(c.min),
|
|
911
|
-
max: Pe(c.max),
|
|
912
|
-
minLength: Pe(c.minLength),
|
|
913
|
-
maxLength: Pe(c.maxLength),
|
|
914
|
-
pattern: Pe(c.pattern)
|
|
915
|
-
} : {},
|
|
916
|
-
name: u,
|
|
917
|
-
onChange: V,
|
|
918
|
-
onBlur: V,
|
|
919
|
-
ref: (x) => {
|
|
920
|
-
if (x) {
|
|
921
|
-
de(u, c), f = v(n, u);
|
|
922
|
-
const g = W(x.value) && x.querySelectorAll && x.querySelectorAll("input,select,textarea")[0] || x, E = cs(g), B = f._f.refs || [];
|
|
923
|
-
if (E ? B.find((Q) => Q === g) : g === f._f.ref)
|
|
924
|
-
return;
|
|
925
|
-
L(n, u, {
|
|
926
|
-
_f: {
|
|
927
|
-
...f._f,
|
|
928
|
-
...E ? {
|
|
929
|
-
refs: [
|
|
930
|
-
...B.filter(bt),
|
|
931
|
-
g,
|
|
932
|
-
...Array.isArray(v(i, u)) ? [{}] : []
|
|
933
|
-
],
|
|
934
|
-
ref: { type: g.type, name: u }
|
|
935
|
-
} : { ref: g }
|
|
936
|
-
}
|
|
937
|
-
}), A(u, !1, void 0, g);
|
|
938
|
-
} else
|
|
939
|
-
f = v(n, u, {}), f._f && (f._f.mount = !1), (e.shouldUnregister || c.shouldUnregister) && !(fr(o.array, u) && l.action) && o.unMount.add(u);
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
}, se = () => e.shouldFocusError && Ue(n, F, o.mount), pe = (u) => {
|
|
943
|
-
he(u) && (y.state.next({ disabled: u }), Ue(n, (c, f) => {
|
|
944
|
-
let S = u;
|
|
945
|
-
const x = v(n, f);
|
|
946
|
-
x && he(x._f.disabled) && (S || (S = x._f.disabled)), c.disabled = S;
|
|
947
|
-
}, 0, !1));
|
|
948
|
-
}, $e = (u, c) => async (f) => {
|
|
949
|
-
f && (f.preventDefault && f.preventDefault(), f.persist && f.persist());
|
|
950
|
-
let S = G(a);
|
|
951
|
-
if (y.state.next({
|
|
952
|
-
isSubmitting: !0
|
|
953
|
-
}), e.resolver) {
|
|
954
|
-
const { errors: x, values: g } = await P();
|
|
955
|
-
s.errors = x, S = g;
|
|
956
|
-
} else
|
|
957
|
-
await O(n);
|
|
958
|
-
ee(s.errors, "root"), le(s.errors) ? (y.state.next({
|
|
959
|
-
errors: {}
|
|
960
|
-
}), await u(S, f)) : (c && await c({ ...s.errors }, f), se(), setTimeout(se)), y.state.next({
|
|
961
|
-
isSubmitted: !0,
|
|
962
|
-
isSubmitting: !1,
|
|
963
|
-
isSubmitSuccessful: le(s.errors),
|
|
964
|
-
submitCount: s.submitCount + 1,
|
|
965
|
-
errors: s.errors
|
|
966
|
-
});
|
|
967
|
-
}, Ce = (u, c = {}) => {
|
|
968
|
-
v(n, u) && (W(c.defaultValue) ? _(u, G(v(i, u))) : (_(u, c.defaultValue), L(i, u, G(c.defaultValue))), c.keepTouched || ee(s.touchedFields, u), c.keepDirty || (ee(s.dirtyFields, u), s.isDirty = c.defaultValue ? M(u, G(v(i, u))) : M()), c.keepError || (ee(s.errors, u), h.isValid && te()), y.state.next({ ...s }));
|
|
969
|
-
}, Wt = (u, c = {}) => {
|
|
970
|
-
const f = u ? G(u) : i, S = G(f), x = u && !le(u) ? S : i;
|
|
971
|
-
if (c.keepDefaultValues || (i = f), !c.keepValues) {
|
|
972
|
-
if (c.keepDirtyValues)
|
|
973
|
-
for (const g of o.mount)
|
|
974
|
-
v(s.dirtyFields, g) ? L(x, g, v(a, g)) : _(g, v(x, g));
|
|
975
|
-
else {
|
|
976
|
-
if (Tt && W(u))
|
|
977
|
-
for (const g of o.mount) {
|
|
978
|
-
const E = v(n, g);
|
|
979
|
-
if (E && E._f) {
|
|
980
|
-
const B = Array.isArray(E._f.refs) ? E._f.refs[0] : E._f.ref;
|
|
981
|
-
if (Je(B)) {
|
|
982
|
-
const Q = B.closest("form");
|
|
983
|
-
if (Q) {
|
|
984
|
-
Q.reset();
|
|
985
|
-
break;
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
n = {};
|
|
991
|
-
}
|
|
992
|
-
a = t.shouldUnregister ? c.keepDefaultValues ? G(i) : {} : G(x), y.array.next({
|
|
993
|
-
values: { ...x }
|
|
994
|
-
}), y.values.next({
|
|
995
|
-
values: { ...x }
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
o = {
|
|
999
|
-
mount: /* @__PURE__ */ new Set(),
|
|
1000
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
1001
|
-
array: /* @__PURE__ */ new Set(),
|
|
1002
|
-
watch: /* @__PURE__ */ new Set(),
|
|
1003
|
-
watchAll: !1,
|
|
1004
|
-
focus: ""
|
|
1005
|
-
}, !l.mount && r(), l.mount = !h.isValid || !!c.keepIsValid, l.watch = !!t.shouldUnregister, y.state.next({
|
|
1006
|
-
submitCount: c.keepSubmitCount ? s.submitCount : 0,
|
|
1007
|
-
isDirty: c.keepDirty ? s.isDirty : !!(c.keepDefaultValues && !Ve(u, i)),
|
|
1008
|
-
isSubmitted: c.keepIsSubmitted ? s.isSubmitted : !1,
|
|
1009
|
-
dirtyFields: c.keepDirtyValues ? s.dirtyFields : c.keepDefaultValues && u ? vt(i, u) : {},
|
|
1010
|
-
touchedFields: c.keepTouched ? s.touchedFields : {},
|
|
1011
|
-
errors: c.keepErrors ? s.errors : {},
|
|
1012
|
-
isSubmitSuccessful: c.keepIsSubmitSuccessful ? s.isSubmitSuccessful : !1,
|
|
1013
|
-
isSubmitting: !1
|
|
1014
|
-
});
|
|
1015
|
-
}, Ht = (u, c) => Wt(Ae(u) ? u(a) : u, c);
|
|
1016
|
-
return {
|
|
1017
|
-
control: {
|
|
1018
|
-
register: de,
|
|
1019
|
-
unregister: fe,
|
|
1020
|
-
getFieldState: Z,
|
|
1021
|
-
handleSubmit: $e,
|
|
1022
|
-
setError: ie,
|
|
1023
|
-
_executeSchema: P,
|
|
1024
|
-
_getWatch: k,
|
|
1025
|
-
_getDirty: M,
|
|
1026
|
-
_updateValid: te,
|
|
1027
|
-
_removeUnmounted: j,
|
|
1028
|
-
_updateFieldArray: K,
|
|
1029
|
-
_updateDisabledField: ke,
|
|
1030
|
-
_getFieldArray: b,
|
|
1031
|
-
_reset: Wt,
|
|
1032
|
-
_resetDefaultValues: () => Ae(e.defaultValues) && e.defaultValues().then((u) => {
|
|
1033
|
-
Ht(u, e.resetOptions), y.state.next({
|
|
1034
|
-
isLoading: !1
|
|
1035
|
-
});
|
|
1036
|
-
}),
|
|
1037
|
-
_updateFormState: (u) => {
|
|
1038
|
-
s = {
|
|
1039
|
-
...s,
|
|
1040
|
-
...u
|
|
1041
|
-
};
|
|
1042
|
-
},
|
|
1043
|
-
_disableForm: pe,
|
|
1044
|
-
_subjects: y,
|
|
1045
|
-
_proxyFormState: h,
|
|
1046
|
-
_setErrors: w,
|
|
1047
|
-
get _fields() {
|
|
1048
|
-
return n;
|
|
1049
|
-
},
|
|
1050
|
-
get _formValues() {
|
|
1051
|
-
return a;
|
|
1052
|
-
},
|
|
1053
|
-
get _state() {
|
|
1054
|
-
return l;
|
|
1055
|
-
},
|
|
1056
|
-
set _state(u) {
|
|
1057
|
-
l = u;
|
|
1058
|
-
},
|
|
1059
|
-
get _defaultValues() {
|
|
1060
|
-
return i;
|
|
1061
|
-
},
|
|
1062
|
-
get _names() {
|
|
1063
|
-
return o;
|
|
1064
|
-
},
|
|
1065
|
-
set _names(u) {
|
|
1066
|
-
o = u;
|
|
1067
|
-
},
|
|
1068
|
-
get _formState() {
|
|
1069
|
-
return s;
|
|
1070
|
-
},
|
|
1071
|
-
set _formState(u) {
|
|
1072
|
-
s = u;
|
|
1073
|
-
},
|
|
1074
|
-
get _options() {
|
|
1075
|
-
return e;
|
|
1076
|
-
},
|
|
1077
|
-
set _options(u) {
|
|
1078
|
-
e = {
|
|
1079
|
-
...e,
|
|
1080
|
-
...u
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
},
|
|
1084
|
-
trigger: U,
|
|
1085
|
-
register: de,
|
|
1086
|
-
handleSubmit: $e,
|
|
1087
|
-
watch: we,
|
|
1088
|
-
setValue: _,
|
|
1089
|
-
getValues: Y,
|
|
1090
|
-
reset: Ht,
|
|
1091
|
-
resetField: Ce,
|
|
1092
|
-
clearErrors: X,
|
|
1093
|
-
unregister: fe,
|
|
1094
|
-
setError: ie,
|
|
1095
|
-
setFocus: (u, c = {}) => {
|
|
1096
|
-
const f = v(n, u), S = f && f._f;
|
|
1097
|
-
if (S) {
|
|
1098
|
-
const x = S.refs ? S.refs[0] : S.ref;
|
|
1099
|
-
x.focus && (x.focus(), c.shouldSelect && x.select());
|
|
1100
|
-
}
|
|
1101
|
-
},
|
|
1102
|
-
getFieldState: Z
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
function jt(t = {}) {
|
|
1106
|
-
const r = T.useRef(), e = T.useRef(), [s, n] = T.useState({
|
|
1107
|
-
isDirty: !1,
|
|
1108
|
-
isValidating: !1,
|
|
1109
|
-
isLoading: Ae(t.defaultValues),
|
|
1110
|
-
isSubmitted: !1,
|
|
1111
|
-
isSubmitting: !1,
|
|
1112
|
-
isSubmitSuccessful: !1,
|
|
1113
|
-
isValid: !1,
|
|
1114
|
-
submitCount: 0,
|
|
1115
|
-
dirtyFields: {},
|
|
1116
|
-
touchedFields: {},
|
|
1117
|
-
errors: t.errors || {},
|
|
1118
|
-
disabled: t.disabled || !1,
|
|
1119
|
-
defaultValues: Ae(t.defaultValues) ? void 0 : t.defaultValues
|
|
1120
|
-
});
|
|
1121
|
-
r.current || (r.current = {
|
|
1122
|
-
...ms(t, () => n((a) => ({ ...a }))),
|
|
1123
|
-
formState: s
|
|
1124
|
-
});
|
|
1125
|
-
const i = r.current.control;
|
|
1126
|
-
return i._options = t, st({
|
|
1127
|
-
subject: i._subjects.state,
|
|
1128
|
-
next: (a) => {
|
|
1129
|
-
hr(a, i._proxyFormState, i._updateFormState, !0) && n({ ...i._formState });
|
|
1130
|
-
}
|
|
1131
|
-
}), T.useEffect(() => i._disableForm(t.disabled), [i, t.disabled]), T.useEffect(() => {
|
|
1132
|
-
if (i._proxyFormState.isDirty) {
|
|
1133
|
-
const a = i._getDirty();
|
|
1134
|
-
a !== s.isDirty && i._subjects.state.next({
|
|
1135
|
-
isDirty: a
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
}, [i, s.isDirty]), T.useEffect(() => {
|
|
1139
|
-
t.values && !Ve(t.values, e.current) ? (i._reset(t.values, i._options.resetOptions), e.current = t.values, n((a) => ({ ...a }))) : i._resetDefaultValues();
|
|
1140
|
-
}, [t.values, i]), T.useEffect(() => {
|
|
1141
|
-
t.errors && i._setErrors(t.errors);
|
|
1142
|
-
}, [t.errors, i]), T.useEffect(() => {
|
|
1143
|
-
i._state.mount || (i._updateValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
|
|
1144
|
-
}), r.current.formState = dr(s, i), r.current;
|
|
1145
|
-
}
|
|
1146
|
-
const ye = ({ children: t, ...r }) => /* @__PURE__ */ q("div", { children: /* @__PURE__ */ q(Ee, { ...r, children: t }) });
|
|
1147
|
-
ye.useForm = Ee.useForm;
|
|
1148
|
-
ye.useFormInstance = Ee.useFormInstance;
|
|
1149
|
-
ye.useWatch = Ee.useWatch;
|
|
1150
|
-
ye.Item = Ee.Item;
|
|
1151
|
-
ye.List = Ee.List;
|
|
1152
|
-
ye.ErrorList = Ee.ErrorList;
|
|
1153
|
-
ye.Provider = Ee.Provider;
|
|
1154
|
-
const Be = ({
|
|
1155
|
-
children: t,
|
|
1156
|
-
control: r,
|
|
1157
|
-
name: e,
|
|
1158
|
-
disabled: s,
|
|
1159
|
-
help: n,
|
|
1160
|
-
valuePropName: i,
|
|
1161
|
-
...a
|
|
1162
|
-
}) => {
|
|
1163
|
-
var p;
|
|
1164
|
-
const { field: l, fieldState: o } = ns({ name: e, control: r, disabled: s }), d = ye.useFormInstance();
|
|
1165
|
-
return Jr(() => {
|
|
1166
|
-
d.setFieldValue(e, l.value);
|
|
1167
|
-
}, [l.value]), /* @__PURE__ */ q(
|
|
1168
|
-
ye.Item,
|
|
1169
|
-
{
|
|
1170
|
-
...a,
|
|
1171
|
-
name: e,
|
|
1172
|
-
initialValue: l.value,
|
|
1173
|
-
validateStatus: o.invalid ? "error" : void 0,
|
|
1174
|
-
help: ((p = o.error) == null ? void 0 : p.message) ?? n,
|
|
1175
|
-
children: Kr.map(
|
|
1176
|
-
t,
|
|
1177
|
-
(h) => Xr(h) && Qr(h, {
|
|
1178
|
-
...l,
|
|
1179
|
-
//@ts-expect-error onChange type safe is not necessary here
|
|
1180
|
-
onChange: (...y) => {
|
|
1181
|
-
h.props.onChange && h.props.onChange(...y), l.onChange(...y);
|
|
1182
|
-
},
|
|
1183
|
-
onBlur: () => {
|
|
1184
|
-
h.props.onBlur && h.props.onBlur(), l.onBlur();
|
|
1185
|
-
},
|
|
1186
|
-
...i && {
|
|
1187
|
-
[i]: l.value
|
|
1188
|
-
}
|
|
1189
|
-
})
|
|
1190
|
-
)
|
|
1191
|
-
}
|
|
1192
|
-
);
|
|
1193
|
-
};
|
|
1194
|
-
var gs = (t) => t instanceof Date, Sr = (t) => t == null;
|
|
1195
|
-
const bs = (t) => typeof t == "object";
|
|
1196
|
-
var Ar = (t) => !Sr(t) && !Array.isArray(t) && bs(t) && !gs(t), Or = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Qt = (t) => t === void 0, Ot = (t, r, e) => {
|
|
1197
|
-
if (!r || !Ar(t))
|
|
1198
|
-
return e;
|
|
1199
|
-
const s = Or(r.split(/[,[\].]+?/)).reduce((n, i) => Sr(n) ? n : n[i], t);
|
|
1200
|
-
return Qt(s) || s === t ? Qt(t[r]) ? e : t[r] : s;
|
|
1201
|
-
};
|
|
1202
|
-
T.createContext(null);
|
|
1203
|
-
var vs = (t) => /^\w*$/.test(t), xs = (t) => Or(t.replace(/["|']|\]/g, "").split(/\.|\[/)), _t = (t, r, e) => {
|
|
1204
|
-
let s = -1;
|
|
1205
|
-
const n = vs(r) ? [r] : xs(r), i = n.length, a = i - 1;
|
|
1206
|
-
for (; ++s < i; ) {
|
|
1207
|
-
const l = n[s];
|
|
1208
|
-
let o = e;
|
|
1209
|
-
if (s !== a) {
|
|
1210
|
-
const d = t[l];
|
|
1211
|
-
o = Ar(d) || Array.isArray(d) ? d : isNaN(+n[s + 1]) ? {} : [];
|
|
1212
|
-
}
|
|
1213
|
-
t[l] = o, t = t[l];
|
|
1214
|
-
}
|
|
1215
|
-
return t;
|
|
1216
|
-
}, _s = (t, r, e, s, n) => r ? {
|
|
1217
|
-
...e[t],
|
|
1218
|
-
types: {
|
|
1219
|
-
...e[t] && e[t].types ? e[t].types : {},
|
|
1220
|
-
[s]: n || !0
|
|
1221
|
-
}
|
|
1222
|
-
} : {}, er = function(t, r, e) {
|
|
1223
|
-
if (t && "reportValidity" in t) {
|
|
1224
|
-
var s = Ot(e, r);
|
|
1225
|
-
t.setCustomValidity(s && s.message || ""), t.reportValidity();
|
|
1226
|
-
}
|
|
1227
|
-
}, Er = function(t, r) {
|
|
1228
|
-
var e = function(n) {
|
|
1229
|
-
var i = r.fields[n];
|
|
1230
|
-
i && i.ref && "reportValidity" in i.ref ? er(i.ref, n, t) : i.refs && i.refs.forEach(function(a) {
|
|
1231
|
-
return er(a, n, t);
|
|
1232
|
-
});
|
|
1233
|
-
};
|
|
1234
|
-
for (var s in r.fields)
|
|
1235
|
-
e(s);
|
|
1236
|
-
}, ws = function(t, r) {
|
|
1237
|
-
r.shouldUseNativeValidation && Er(t, r);
|
|
1238
|
-
var e = {};
|
|
1239
|
-
for (var s in t) {
|
|
1240
|
-
var n = Ot(r.fields, s), i = Object.assign(t[s] || {}, { ref: n && n.ref });
|
|
1241
|
-
if (ks(r.names || Object.keys(t), s)) {
|
|
1242
|
-
var a = Object.assign({}, Ot(e, s));
|
|
1243
|
-
_t(a, "root", i), _t(e, s, a);
|
|
1244
|
-
} else
|
|
1245
|
-
_t(e, s, i);
|
|
1246
|
-
}
|
|
1247
|
-
return e;
|
|
1248
|
-
}, ks = function(t, r) {
|
|
1249
|
-
return t.some(function(e) {
|
|
1250
|
-
return e.startsWith(r + ".");
|
|
1251
|
-
});
|
|
1252
|
-
};
|
|
1253
|
-
function Vr(t, r, e) {
|
|
1254
|
-
return r === void 0 && (r = {}), e === void 0 && (e = {}), function(s, n, i) {
|
|
1255
|
-
try {
|
|
1256
|
-
return Promise.resolve(function(a, l) {
|
|
1257
|
-
try {
|
|
1258
|
-
var o = (r.context && process.env.NODE_ENV === "development" && console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"), Promise.resolve(t[e.mode === "sync" ? "validateSync" : "validate"](s, Object.assign({ abortEarly: !1 }, r, { context: n }))).then(function(d) {
|
|
1259
|
-
return i.shouldUseNativeValidation && Er({}, i), { values: e.raw ? s : d, errors: {} };
|
|
1260
|
-
}));
|
|
1261
|
-
} catch (d) {
|
|
1262
|
-
return l(d);
|
|
1263
|
-
}
|
|
1264
|
-
return o && o.then ? o.then(void 0, l) : o;
|
|
1265
|
-
}(0, function(a) {
|
|
1266
|
-
if (!a.inner)
|
|
1267
|
-
throw a;
|
|
1268
|
-
return { values: {}, errors: ws((l = a, o = !i.shouldUseNativeValidation && i.criteriaMode === "all", (l.inner || []).reduce(function(d, p) {
|
|
1269
|
-
if (d[p.path] || (d[p.path] = { message: p.message, type: p.type }), o) {
|
|
1270
|
-
var h = d[p.path].types, y = h && h[p.type];
|
|
1271
|
-
d[p.path] = _s(p.path, o, d, p.type, y ? [].concat(y, p.message) : p.message);
|
|
1272
|
-
}
|
|
1273
|
-
return d;
|
|
1274
|
-
}, {})), i) };
|
|
1275
|
-
var l, o;
|
|
1276
|
-
}));
|
|
1277
|
-
} catch (a) {
|
|
1278
|
-
return Promise.reject(a);
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
var $s = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
1283
|
-
function Fr(t) {
|
|
1284
|
-
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
1285
|
-
}
|
|
1286
|
-
function Te(t) {
|
|
1287
|
-
this._maxSize = t, this.clear();
|
|
1288
|
-
}
|
|
1289
|
-
Te.prototype.clear = function() {
|
|
1290
|
-
this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
|
|
1291
|
-
};
|
|
1292
|
-
Te.prototype.get = function(t) {
|
|
1293
|
-
return this._values[t];
|
|
1294
|
-
};
|
|
1295
|
-
Te.prototype.set = function(t, r) {
|
|
1296
|
-
return this._size >= this._maxSize && this.clear(), t in this._values || this._size++, this._values[t] = r;
|
|
1297
|
-
};
|
|
1298
|
-
var Ss = /[^.^\]^[]+|(?=\[\]|\.\.)/g, Tr = /^\d+$/, As = /^\d/, Os = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, Es = /^\s*(['"]?)(.*?)(\1)\s*$/, Nt = 512, tr = new Te(Nt), rr = new Te(Nt), sr = new Te(Nt), Fe = {
|
|
1299
|
-
Cache: Te,
|
|
1300
|
-
split: Et,
|
|
1301
|
-
normalizePath: wt,
|
|
1302
|
-
setter: function(t) {
|
|
1303
|
-
var r = wt(t);
|
|
1304
|
-
return rr.get(t) || rr.set(t, function(s, n) {
|
|
1305
|
-
for (var i = 0, a = r.length, l = s; i < a - 1; ) {
|
|
1306
|
-
var o = r[i];
|
|
1307
|
-
if (o === "__proto__" || o === "constructor" || o === "prototype")
|
|
1308
|
-
return s;
|
|
1309
|
-
l = l[r[i++]];
|
|
1310
|
-
}
|
|
1311
|
-
l[r[i]] = n;
|
|
1312
|
-
});
|
|
1313
|
-
},
|
|
1314
|
-
getter: function(t, r) {
|
|
1315
|
-
var e = wt(t);
|
|
1316
|
-
return sr.get(t) || sr.set(t, function(n) {
|
|
1317
|
-
for (var i = 0, a = e.length; i < a; )
|
|
1318
|
-
if (n != null || !r)
|
|
1319
|
-
n = n[e[i++]];
|
|
1320
|
-
else
|
|
1321
|
-
return;
|
|
1322
|
-
return n;
|
|
1323
|
-
});
|
|
1324
|
-
},
|
|
1325
|
-
join: function(t) {
|
|
1326
|
-
return t.reduce(function(r, e) {
|
|
1327
|
-
return r + (It(e) || Tr.test(e) ? "[" + e + "]" : (r ? "." : "") + e);
|
|
1328
|
-
}, "");
|
|
1329
|
-
},
|
|
1330
|
-
forEach: function(t, r, e) {
|
|
1331
|
-
Vs(Array.isArray(t) ? t : Et(t), r, e);
|
|
1332
|
-
}
|
|
1333
|
-
};
|
|
1334
|
-
function wt(t) {
|
|
1335
|
-
return tr.get(t) || tr.set(
|
|
1336
|
-
t,
|
|
1337
|
-
Et(t).map(function(r) {
|
|
1338
|
-
return r.replace(Es, "$2");
|
|
1339
|
-
})
|
|
1340
|
-
);
|
|
1341
|
-
}
|
|
1342
|
-
function Et(t) {
|
|
1343
|
-
return t.match(Ss) || [""];
|
|
1344
|
-
}
|
|
1345
|
-
function Vs(t, r, e) {
|
|
1346
|
-
var s = t.length, n, i, a, l;
|
|
1347
|
-
for (i = 0; i < s; i++)
|
|
1348
|
-
n = t[i], n && (Ds(n) && (n = '"' + n + '"'), l = It(n), a = !l && /^\d+$/.test(n), r.call(e, n, l, a, i, t));
|
|
1349
|
-
}
|
|
1350
|
-
function It(t) {
|
|
1351
|
-
return typeof t == "string" && t && ["'", '"'].indexOf(t.charAt(0)) !== -1;
|
|
1352
|
-
}
|
|
1353
|
-
function Fs(t) {
|
|
1354
|
-
return t.match(As) && !t.match(Tr);
|
|
1355
|
-
}
|
|
1356
|
-
function Ts(t) {
|
|
1357
|
-
return Os.test(t);
|
|
1358
|
-
}
|
|
1359
|
-
function Ds(t) {
|
|
1360
|
-
return !It(t) && (Fs(t) || Ts(t));
|
|
1361
|
-
}
|
|
1362
|
-
const Cs = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g, nt = (t) => t.match(Cs) || [], it = (t) => t[0].toUpperCase() + t.slice(1), Rt = (t, r) => nt(t).join(r).toLowerCase(), Dr = (t) => nt(t).reduce(
|
|
1363
|
-
(r, e) => `${r}${r ? e[0].toUpperCase() + e.slice(1).toLowerCase() : e.toLowerCase()}`,
|
|
1364
|
-
""
|
|
1365
|
-
), Ms = (t) => it(Dr(t)), js = (t) => Rt(t, "_"), Ns = (t) => Rt(t, "-"), Is = (t) => it(Rt(t, " ")), Rs = (t) => nt(t).map(it).join(" ");
|
|
1366
|
-
var kt = {
|
|
1367
|
-
words: nt,
|
|
1368
|
-
upperFirst: it,
|
|
1369
|
-
camelCase: Dr,
|
|
1370
|
-
pascalCase: Ms,
|
|
1371
|
-
snakeCase: js,
|
|
1372
|
-
kebabCase: Ns,
|
|
1373
|
-
sentenceCase: Is,
|
|
1374
|
-
titleCase: Rs
|
|
1375
|
-
}, Ut = { exports: {} };
|
|
1376
|
-
Ut.exports = function(t) {
|
|
1377
|
-
return Cr(Us(t), t);
|
|
1378
|
-
};
|
|
1379
|
-
Ut.exports.array = Cr;
|
|
1380
|
-
function Cr(t, r) {
|
|
1381
|
-
var e = t.length, s = new Array(e), n = {}, i = e, a = Ls(r), l = Ps(t);
|
|
1382
|
-
for (r.forEach(function(d) {
|
|
1383
|
-
if (!l.has(d[0]) || !l.has(d[1]))
|
|
1384
|
-
throw new Error("Unknown node. There is an unknown node in the supplied edges.");
|
|
1385
|
-
}); i--; )
|
|
1386
|
-
n[i] || o(t[i], i, /* @__PURE__ */ new Set());
|
|
1387
|
-
return s;
|
|
1388
|
-
function o(d, p, h) {
|
|
1389
|
-
if (h.has(d)) {
|
|
1390
|
-
var y;
|
|
1391
|
-
try {
|
|
1392
|
-
y = ", node was:" + JSON.stringify(d);
|
|
1393
|
-
} catch {
|
|
1394
|
-
y = "";
|
|
1395
|
-
}
|
|
1396
|
-
throw new Error("Cyclic dependency" + y);
|
|
1397
|
-
}
|
|
1398
|
-
if (!l.has(d))
|
|
1399
|
-
throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(d));
|
|
1400
|
-
if (!n[p]) {
|
|
1401
|
-
n[p] = !0;
|
|
1402
|
-
var N = a.get(d) || /* @__PURE__ */ new Set();
|
|
1403
|
-
if (N = Array.from(N), p = N.length) {
|
|
1404
|
-
h.add(d);
|
|
1405
|
-
do {
|
|
1406
|
-
var I = N[--p];
|
|
1407
|
-
o(I, l.get(I), h);
|
|
1408
|
-
} while (p);
|
|
1409
|
-
h.delete(d);
|
|
1410
|
-
}
|
|
1411
|
-
s[--e] = d;
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
function Us(t) {
|
|
1416
|
-
for (var r = /* @__PURE__ */ new Set(), e = 0, s = t.length; e < s; e++) {
|
|
1417
|
-
var n = t[e];
|
|
1418
|
-
r.add(n[0]), r.add(n[1]);
|
|
1419
|
-
}
|
|
1420
|
-
return Array.from(r);
|
|
1421
|
-
}
|
|
1422
|
-
function Ls(t) {
|
|
1423
|
-
for (var r = /* @__PURE__ */ new Map(), e = 0, s = t.length; e < s; e++) {
|
|
1424
|
-
var n = t[e];
|
|
1425
|
-
r.has(n[0]) || r.set(n[0], /* @__PURE__ */ new Set()), r.has(n[1]) || r.set(n[1], /* @__PURE__ */ new Set()), r.get(n[0]).add(n[1]);
|
|
1426
|
-
}
|
|
1427
|
-
return r;
|
|
1428
|
-
}
|
|
1429
|
-
function Ps(t) {
|
|
1430
|
-
for (var r = /* @__PURE__ */ new Map(), e = 0, s = t.length; e < s; e++)
|
|
1431
|
-
r.set(t[e], e);
|
|
1432
|
-
return r;
|
|
1433
|
-
}
|
|
1434
|
-
var Bs = Ut.exports;
|
|
1435
|
-
const Ws = /* @__PURE__ */ Fr(Bs), Hs = Object.prototype.toString, Ys = Error.prototype.toString, qs = RegExp.prototype.toString, zs = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", Zs = /^Symbol\((.*)\)(.*)$/;
|
|
1436
|
-
function Gs(t) {
|
|
1437
|
-
return t != +t ? "NaN" : t === 0 && 1 / t < 0 ? "-0" : "" + t;
|
|
1438
|
-
}
|
|
1439
|
-
function nr(t, r = !1) {
|
|
1440
|
-
if (t == null || t === !0 || t === !1)
|
|
1441
|
-
return "" + t;
|
|
1442
|
-
const e = typeof t;
|
|
1443
|
-
if (e === "number")
|
|
1444
|
-
return Gs(t);
|
|
1445
|
-
if (e === "string")
|
|
1446
|
-
return r ? `"${t}"` : t;
|
|
1447
|
-
if (e === "function")
|
|
1448
|
-
return "[Function " + (t.name || "anonymous") + "]";
|
|
1449
|
-
if (e === "symbol")
|
|
1450
|
-
return zs.call(t).replace(Zs, "Symbol($1)");
|
|
1451
|
-
const s = Hs.call(t).slice(8, -1);
|
|
1452
|
-
return s === "Date" ? isNaN(t.getTime()) ? "" + t : t.toISOString(t) : s === "Error" || t instanceof Error ? "[" + Ys.call(t) + "]" : s === "RegExp" ? qs.call(t) : null;
|
|
1453
|
-
}
|
|
1454
|
-
function Oe(t, r) {
|
|
1455
|
-
let e = nr(t, r);
|
|
1456
|
-
return e !== null ? e : JSON.stringify(t, function(s, n) {
|
|
1457
|
-
let i = nr(this[s], r);
|
|
1458
|
-
return i !== null ? i : n;
|
|
1459
|
-
}, 2);
|
|
1460
|
-
}
|
|
1461
|
-
function Mr(t) {
|
|
1462
|
-
return t == null ? [] : [].concat(t);
|
|
1463
|
-
}
|
|
1464
|
-
let jr, Js = /\$\{\s*(\w+)\s*\}/g;
|
|
1465
|
-
jr = Symbol.toStringTag;
|
|
1466
|
-
class ue extends Error {
|
|
1467
|
-
static formatError(r, e) {
|
|
1468
|
-
const s = e.label || e.path || "this";
|
|
1469
|
-
return s !== e.path && (e = Object.assign({}, e, {
|
|
1470
|
-
path: s
|
|
1471
|
-
})), typeof r == "string" ? r.replace(Js, (n, i) => Oe(e[i])) : typeof r == "function" ? r(e) : r;
|
|
1472
|
-
}
|
|
1473
|
-
static isError(r) {
|
|
1474
|
-
return r && r.name === "ValidationError";
|
|
1475
|
-
}
|
|
1476
|
-
constructor(r, e, s, n, i) {
|
|
1477
|
-
super(), this.value = void 0, this.path = void 0, this.type = void 0, this.errors = void 0, this.params = void 0, this.inner = void 0, this[jr] = "Error", this.name = "ValidationError", this.value = e, this.path = s, this.type = n, this.errors = [], this.inner = [], Mr(r).forEach((a) => {
|
|
1478
|
-
if (ue.isError(a)) {
|
|
1479
|
-
this.errors.push(...a.errors);
|
|
1480
|
-
const l = a.inner.length ? a.inner : [a];
|
|
1481
|
-
this.inner.push(...l);
|
|
1482
|
-
} else
|
|
1483
|
-
this.errors.push(a);
|
|
1484
|
-
}), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0], !i && Error.captureStackTrace && Error.captureStackTrace(this, ue);
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
let xe = {
|
|
1488
|
-
default: "${path} is invalid",
|
|
1489
|
-
required: "${path} is a required field",
|
|
1490
|
-
defined: "${path} must be defined",
|
|
1491
|
-
notNull: "${path} cannot be null",
|
|
1492
|
-
oneOf: "${path} must be one of the following values: ${values}",
|
|
1493
|
-
notOneOf: "${path} must not be one of the following values: ${values}",
|
|
1494
|
-
notType: ({
|
|
1495
|
-
path: t,
|
|
1496
|
-
type: r,
|
|
1497
|
-
value: e,
|
|
1498
|
-
originalValue: s
|
|
1499
|
-
}) => {
|
|
1500
|
-
const n = s != null && s !== e ? ` (cast from the value \`${Oe(s, !0)}\`).` : ".";
|
|
1501
|
-
return r !== "mixed" ? `${t} must be a \`${r}\` type, but the final value was: \`${Oe(e, !0)}\`` + n : `${t} must match the configured type. The validated value was: \`${Oe(e, !0)}\`` + n;
|
|
1502
|
-
}
|
|
1503
|
-
}, Ks = {
|
|
1504
|
-
length: "${path} must be exactly ${length} characters",
|
|
1505
|
-
min: "${path} must be at least ${min} characters",
|
|
1506
|
-
max: "${path} must be at most ${max} characters",
|
|
1507
|
-
matches: '${path} must match the following: "${regex}"',
|
|
1508
|
-
email: "${path} must be a valid email",
|
|
1509
|
-
url: "${path} must be a valid URL",
|
|
1510
|
-
uuid: "${path} must be a valid UUID",
|
|
1511
|
-
trim: "${path} must be a trimmed string",
|
|
1512
|
-
lowercase: "${path} must be a lowercase string",
|
|
1513
|
-
uppercase: "${path} must be a upper case string"
|
|
1514
|
-
}, Xs = {
|
|
1515
|
-
min: "${path} must be greater than or equal to ${min}",
|
|
1516
|
-
max: "${path} must be less than or equal to ${max}",
|
|
1517
|
-
lessThan: "${path} must be less than ${less}",
|
|
1518
|
-
moreThan: "${path} must be greater than ${more}",
|
|
1519
|
-
positive: "${path} must be a positive number",
|
|
1520
|
-
negative: "${path} must be a negative number",
|
|
1521
|
-
integer: "${path} must be an integer"
|
|
1522
|
-
}, Vt = {
|
|
1523
|
-
min: "${path} field must be later than ${min}",
|
|
1524
|
-
max: "${path} field must be at earlier than ${max}"
|
|
1525
|
-
}, Qs = {
|
|
1526
|
-
isValue: "${path} field must be ${value}"
|
|
1527
|
-
}, Ft = {
|
|
1528
|
-
noUnknown: "${path} field has unspecified keys: ${unknown}"
|
|
1529
|
-
}, en = {
|
|
1530
|
-
min: "${path} field must have at least ${min} items",
|
|
1531
|
-
max: "${path} field must have less than or equal to ${max} items",
|
|
1532
|
-
length: "${path} must have ${length} items"
|
|
1533
|
-
}, tn = {
|
|
1534
|
-
notType: (t) => {
|
|
1535
|
-
const {
|
|
1536
|
-
path: r,
|
|
1537
|
-
value: e,
|
|
1538
|
-
spec: s
|
|
1539
|
-
} = t, n = s.types.length;
|
|
1540
|
-
if (Array.isArray(e)) {
|
|
1541
|
-
if (e.length < n)
|
|
1542
|
-
return `${r} tuple value has too few items, expected a length of ${n} but got ${e.length} for value: \`${Oe(e, !0)}\``;
|
|
1543
|
-
if (e.length > n)
|
|
1544
|
-
return `${r} tuple value has too many items, expected a length of ${n} but got ${e.length} for value: \`${Oe(e, !0)}\``;
|
|
1545
|
-
}
|
|
1546
|
-
return ue.formatError(xe.notType, t);
|
|
1547
|
-
}
|
|
1548
|
-
};
|
|
1549
|
-
Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1550
|
-
mixed: xe,
|
|
1551
|
-
string: Ks,
|
|
1552
|
-
number: Xs,
|
|
1553
|
-
date: Vt,
|
|
1554
|
-
object: Ft,
|
|
1555
|
-
array: en,
|
|
1556
|
-
boolean: Qs,
|
|
1557
|
-
tuple: tn
|
|
1558
|
-
});
|
|
1559
|
-
const Lt = (t) => t && t.__isYupSchema__;
|
|
1560
|
-
class et {
|
|
1561
|
-
static fromOptions(r, e) {
|
|
1562
|
-
if (!e.then && !e.otherwise)
|
|
1563
|
-
throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
|
|
1564
|
-
let {
|
|
1565
|
-
is: s,
|
|
1566
|
-
then: n,
|
|
1567
|
-
otherwise: i
|
|
1568
|
-
} = e, a = typeof s == "function" ? s : (...l) => l.every((o) => o === s);
|
|
1569
|
-
return new et(r, (l, o) => {
|
|
1570
|
-
var d;
|
|
1571
|
-
let p = a(...l) ? n : i;
|
|
1572
|
-
return (d = p == null ? void 0 : p(o)) != null ? d : o;
|
|
1573
|
-
});
|
|
1574
|
-
}
|
|
1575
|
-
constructor(r, e) {
|
|
1576
|
-
this.fn = void 0, this.refs = r, this.refs = r, this.fn = e;
|
|
1577
|
-
}
|
|
1578
|
-
resolve(r, e) {
|
|
1579
|
-
let s = this.refs.map((i) => (
|
|
1580
|
-
// TODO: ? operator here?
|
|
1581
|
-
i.getValue(e == null ? void 0 : e.value, e == null ? void 0 : e.parent, e == null ? void 0 : e.context)
|
|
1582
|
-
)), n = this.fn(s, r, e);
|
|
1583
|
-
if (n === void 0 || // @ts-ignore this can be base
|
|
1584
|
-
n === r)
|
|
1585
|
-
return r;
|
|
1586
|
-
if (!Lt(n))
|
|
1587
|
-
throw new TypeError("conditions must return a schema object");
|
|
1588
|
-
return n.resolve(e);
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
const qe = {
|
|
1592
|
-
context: "$",
|
|
1593
|
-
value: "."
|
|
1594
|
-
};
|
|
1595
|
-
class De {
|
|
1596
|
-
constructor(r, e = {}) {
|
|
1597
|
-
if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof r != "string")
|
|
1598
|
-
throw new TypeError("ref must be a string, got: " + r);
|
|
1599
|
-
if (this.key = r.trim(), r === "")
|
|
1600
|
-
throw new TypeError("ref must be a non-empty string");
|
|
1601
|
-
this.isContext = this.key[0] === qe.context, this.isValue = this.key[0] === qe.value, this.isSibling = !this.isContext && !this.isValue;
|
|
1602
|
-
let s = this.isContext ? qe.context : this.isValue ? qe.value : "";
|
|
1603
|
-
this.path = this.key.slice(s.length), this.getter = this.path && Fe.getter(this.path, !0), this.map = e.map;
|
|
1604
|
-
}
|
|
1605
|
-
getValue(r, e, s) {
|
|
1606
|
-
let n = this.isContext ? s : this.isValue ? r : e;
|
|
1607
|
-
return this.getter && (n = this.getter(n || {})), this.map && (n = this.map(n)), n;
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
|
-
*
|
|
1611
|
-
* @param {*} value
|
|
1612
|
-
* @param {Object} options
|
|
1613
|
-
* @param {Object=} options.context
|
|
1614
|
-
* @param {Object=} options.parent
|
|
1615
|
-
*/
|
|
1616
|
-
cast(r, e) {
|
|
1617
|
-
return this.getValue(r, e == null ? void 0 : e.parent, e == null ? void 0 : e.context);
|
|
1618
|
-
}
|
|
1619
|
-
resolve() {
|
|
1620
|
-
return this;
|
|
1621
|
-
}
|
|
1622
|
-
describe() {
|
|
1623
|
-
return {
|
|
1624
|
-
type: "ref",
|
|
1625
|
-
key: this.key
|
|
1626
|
-
};
|
|
1627
|
-
}
|
|
1628
|
-
toString() {
|
|
1629
|
-
return `Ref(${this.key})`;
|
|
1630
|
-
}
|
|
1631
|
-
static isRef(r) {
|
|
1632
|
-
return r && r.__isYupRef;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
De.prototype.__isYupRef = !0;
|
|
1636
|
-
const Nr = (t) => t == null;
|
|
1637
|
-
function Ne(t) {
|
|
1638
|
-
function r({
|
|
1639
|
-
value: e,
|
|
1640
|
-
path: s = "",
|
|
1641
|
-
options: n,
|
|
1642
|
-
originalValue: i,
|
|
1643
|
-
schema: a
|
|
1644
|
-
}, l, o) {
|
|
1645
|
-
const {
|
|
1646
|
-
name: d,
|
|
1647
|
-
test: p,
|
|
1648
|
-
params: h,
|
|
1649
|
-
message: y,
|
|
1650
|
-
skipAbsent: N
|
|
1651
|
-
} = t;
|
|
1652
|
-
let {
|
|
1653
|
-
parent: I,
|
|
1654
|
-
context: z,
|
|
1655
|
-
abortEarly: ne = a.spec.abortEarly,
|
|
1656
|
-
disableStackTrace: te = a.spec.disableStackTrace
|
|
1657
|
-
} = n;
|
|
1658
|
-
function D(O) {
|
|
1659
|
-
return De.isRef(O) ? O.getValue(e, I, z) : O;
|
|
1660
|
-
}
|
|
1661
|
-
function K(O = {}) {
|
|
1662
|
-
var j;
|
|
1663
|
-
const M = Object.assign({
|
|
1664
|
-
value: e,
|
|
1665
|
-
originalValue: i,
|
|
1666
|
-
label: a.spec.label,
|
|
1667
|
-
path: O.path || s,
|
|
1668
|
-
spec: a.spec
|
|
1669
|
-
}, h, O.params);
|
|
1670
|
-
for (const b of Object.keys(M))
|
|
1671
|
-
M[b] = D(M[b]);
|
|
1672
|
-
const k = new ue(ue.formatError(O.message || y, M), e, M.path, O.type || d, (j = O.disableStackTrace) != null ? j : te);
|
|
1673
|
-
return k.params = M, k;
|
|
1674
|
-
}
|
|
1675
|
-
const re = ne ? l : o;
|
|
1676
|
-
let w = {
|
|
1677
|
-
path: s,
|
|
1678
|
-
parent: I,
|
|
1679
|
-
type: d,
|
|
1680
|
-
from: n.from,
|
|
1681
|
-
createError: K,
|
|
1682
|
-
resolve: D,
|
|
1683
|
-
options: n,
|
|
1684
|
-
originalValue: i,
|
|
1685
|
-
schema: a
|
|
1686
|
-
};
|
|
1687
|
-
const A = (O) => {
|
|
1688
|
-
ue.isError(O) ? re(O) : O ? o(null) : re(K());
|
|
1689
|
-
}, C = (O) => {
|
|
1690
|
-
ue.isError(O) ? re(O) : l(O);
|
|
1691
|
-
};
|
|
1692
|
-
if (N && Nr(e))
|
|
1693
|
-
return A(!0);
|
|
1694
|
-
let P;
|
|
1695
|
-
try {
|
|
1696
|
-
var R;
|
|
1697
|
-
if (P = p.call(w, e, w), typeof ((R = P) == null ? void 0 : R.then) == "function") {
|
|
1698
|
-
if (n.sync)
|
|
1699
|
-
throw new Error(`Validation test of type: "${w.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
|
|
1700
|
-
return Promise.resolve(P).then(A, C);
|
|
1701
|
-
}
|
|
1702
|
-
} catch (O) {
|
|
1703
|
-
C(O);
|
|
1704
|
-
return;
|
|
1705
|
-
}
|
|
1706
|
-
A(P);
|
|
1707
|
-
}
|
|
1708
|
-
return r.OPTIONS = t, r;
|
|
1709
|
-
}
|
|
1710
|
-
function rn(t, r, e, s = e) {
|
|
1711
|
-
let n, i, a;
|
|
1712
|
-
return r ? (Fe.forEach(r, (l, o, d) => {
|
|
1713
|
-
let p = o ? l.slice(1, l.length - 1) : l;
|
|
1714
|
-
t = t.resolve({
|
|
1715
|
-
context: s,
|
|
1716
|
-
parent: n,
|
|
1717
|
-
value: e
|
|
1718
|
-
});
|
|
1719
|
-
let h = t.type === "tuple", y = d ? parseInt(p, 10) : 0;
|
|
1720
|
-
if (t.innerType || h) {
|
|
1721
|
-
if (h && !d)
|
|
1722
|
-
throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);
|
|
1723
|
-
if (e && y >= e.length)
|
|
1724
|
-
throw new Error(`Yup.reach cannot resolve an array item at index: ${l}, in the path: ${r}. because there is no value at that index. `);
|
|
1725
|
-
n = e, e = e && e[y], t = h ? t.spec.types[y] : t.innerType;
|
|
1726
|
-
}
|
|
1727
|
-
if (!d) {
|
|
1728
|
-
if (!t.fields || !t.fields[p])
|
|
1729
|
-
throw new Error(`The schema does not contain the path: ${r}. (failed at: ${a} which is a type: "${t.type}")`);
|
|
1730
|
-
n = e, e = e && e[p], t = t.fields[p];
|
|
1731
|
-
}
|
|
1732
|
-
i = p, a = o ? "[" + l + "]" : "." + l;
|
|
1733
|
-
}), {
|
|
1734
|
-
schema: t,
|
|
1735
|
-
parent: n,
|
|
1736
|
-
parentPath: i
|
|
1737
|
-
}) : {
|
|
1738
|
-
parent: n,
|
|
1739
|
-
parentPath: r,
|
|
1740
|
-
schema: t
|
|
1741
|
-
};
|
|
1742
|
-
}
|
|
1743
|
-
class tt extends Set {
|
|
1744
|
-
describe() {
|
|
1745
|
-
const r = [];
|
|
1746
|
-
for (const e of this.values())
|
|
1747
|
-
r.push(De.isRef(e) ? e.describe() : e);
|
|
1748
|
-
return r;
|
|
1749
|
-
}
|
|
1750
|
-
resolveAll(r) {
|
|
1751
|
-
let e = [];
|
|
1752
|
-
for (const s of this.values())
|
|
1753
|
-
e.push(r(s));
|
|
1754
|
-
return e;
|
|
1755
|
-
}
|
|
1756
|
-
clone() {
|
|
1757
|
-
return new tt(this.values());
|
|
1758
|
-
}
|
|
1759
|
-
merge(r, e) {
|
|
1760
|
-
const s = this.clone();
|
|
1761
|
-
return r.forEach((n) => s.add(n)), e.forEach((n) => s.delete(n)), s;
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
function Re(t, r = /* @__PURE__ */ new Map()) {
|
|
1765
|
-
if (Lt(t) || !t || typeof t != "object")
|
|
1766
|
-
return t;
|
|
1767
|
-
if (r.has(t))
|
|
1768
|
-
return r.get(t);
|
|
1769
|
-
let e;
|
|
1770
|
-
if (t instanceof Date)
|
|
1771
|
-
e = new Date(t.getTime()), r.set(t, e);
|
|
1772
|
-
else if (t instanceof RegExp)
|
|
1773
|
-
e = new RegExp(t), r.set(t, e);
|
|
1774
|
-
else if (Array.isArray(t)) {
|
|
1775
|
-
e = new Array(t.length), r.set(t, e);
|
|
1776
|
-
for (let s = 0; s < t.length; s++)
|
|
1777
|
-
e[s] = Re(t[s], r);
|
|
1778
|
-
} else if (t instanceof Map) {
|
|
1779
|
-
e = /* @__PURE__ */ new Map(), r.set(t, e);
|
|
1780
|
-
for (const [s, n] of t.entries())
|
|
1781
|
-
e.set(s, Re(n, r));
|
|
1782
|
-
} else if (t instanceof Set) {
|
|
1783
|
-
e = /* @__PURE__ */ new Set(), r.set(t, e);
|
|
1784
|
-
for (const s of t)
|
|
1785
|
-
e.add(Re(s, r));
|
|
1786
|
-
} else if (t instanceof Object) {
|
|
1787
|
-
e = {}, r.set(t, e);
|
|
1788
|
-
for (const [s, n] of Object.entries(t))
|
|
1789
|
-
e[s] = Re(n, r);
|
|
1790
|
-
} else
|
|
1791
|
-
throw Error(`Unable to clone ${t}`);
|
|
1792
|
-
return e;
|
|
1793
|
-
}
|
|
1794
|
-
class _e {
|
|
1795
|
-
constructor(r) {
|
|
1796
|
-
this.type = void 0, this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this.internalTests = {}, this._whitelist = new tt(), this._blacklist = new tt(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this._typeCheck = void 0, this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
|
|
1797
|
-
this.typeError(xe.notType);
|
|
1798
|
-
}), this.type = r.type, this._typeCheck = r.check, this.spec = Object.assign({
|
|
1799
|
-
strip: !1,
|
|
1800
|
-
strict: !1,
|
|
1801
|
-
abortEarly: !0,
|
|
1802
|
-
recursive: !0,
|
|
1803
|
-
disableStackTrace: !1,
|
|
1804
|
-
nullable: !1,
|
|
1805
|
-
optional: !0,
|
|
1806
|
-
coerce: !0
|
|
1807
|
-
}, r == null ? void 0 : r.spec), this.withMutation((e) => {
|
|
1808
|
-
e.nonNullable();
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
// TODO: remove
|
|
1812
|
-
get _type() {
|
|
1813
|
-
return this.type;
|
|
1814
|
-
}
|
|
1815
|
-
clone(r) {
|
|
1816
|
-
if (this._mutate)
|
|
1817
|
-
return r && Object.assign(this.spec, r), this;
|
|
1818
|
-
const e = Object.create(Object.getPrototypeOf(this));
|
|
1819
|
-
return e.type = this.type, e._typeCheck = this._typeCheck, e._whitelist = this._whitelist.clone(), e._blacklist = this._blacklist.clone(), e.internalTests = Object.assign({}, this.internalTests), e.exclusiveTests = Object.assign({}, this.exclusiveTests), e.deps = [...this.deps], e.conditions = [...this.conditions], e.tests = [...this.tests], e.transforms = [...this.transforms], e.spec = Re(Object.assign({}, this.spec, r)), e;
|
|
1820
|
-
}
|
|
1821
|
-
label(r) {
|
|
1822
|
-
let e = this.clone();
|
|
1823
|
-
return e.spec.label = r, e;
|
|
1824
|
-
}
|
|
1825
|
-
meta(...r) {
|
|
1826
|
-
if (r.length === 0)
|
|
1827
|
-
return this.spec.meta;
|
|
1828
|
-
let e = this.clone();
|
|
1829
|
-
return e.spec.meta = Object.assign(e.spec.meta || {}, r[0]), e;
|
|
1830
|
-
}
|
|
1831
|
-
withMutation(r) {
|
|
1832
|
-
let e = this._mutate;
|
|
1833
|
-
this._mutate = !0;
|
|
1834
|
-
let s = r(this);
|
|
1835
|
-
return this._mutate = e, s;
|
|
1836
|
-
}
|
|
1837
|
-
concat(r) {
|
|
1838
|
-
if (!r || r === this)
|
|
1839
|
-
return this;
|
|
1840
|
-
if (r.type !== this.type && this.type !== "mixed")
|
|
1841
|
-
throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${r.type}`);
|
|
1842
|
-
let e = this, s = r.clone();
|
|
1843
|
-
const n = Object.assign({}, e.spec, s.spec);
|
|
1844
|
-
return s.spec = n, s.internalTests = Object.assign({}, e.internalTests, s.internalTests), s._whitelist = e._whitelist.merge(r._whitelist, r._blacklist), s._blacklist = e._blacklist.merge(r._blacklist, r._whitelist), s.tests = e.tests, s.exclusiveTests = e.exclusiveTests, s.withMutation((i) => {
|
|
1845
|
-
r.tests.forEach((a) => {
|
|
1846
|
-
i.test(a.OPTIONS);
|
|
1847
|
-
});
|
|
1848
|
-
}), s.transforms = [...e.transforms, ...s.transforms], s;
|
|
1849
|
-
}
|
|
1850
|
-
isType(r) {
|
|
1851
|
-
return r == null ? !!(this.spec.nullable && r === null || this.spec.optional && r === void 0) : this._typeCheck(r);
|
|
1852
|
-
}
|
|
1853
|
-
resolve(r) {
|
|
1854
|
-
let e = this;
|
|
1855
|
-
if (e.conditions.length) {
|
|
1856
|
-
let s = e.conditions;
|
|
1857
|
-
e = e.clone(), e.conditions = [], e = s.reduce((n, i) => i.resolve(n, r), e), e = e.resolve(r);
|
|
1858
|
-
}
|
|
1859
|
-
return e;
|
|
1860
|
-
}
|
|
1861
|
-
resolveOptions(r) {
|
|
1862
|
-
var e, s, n, i;
|
|
1863
|
-
return Object.assign({}, r, {
|
|
1864
|
-
from: r.from || [],
|
|
1865
|
-
strict: (e = r.strict) != null ? e : this.spec.strict,
|
|
1866
|
-
abortEarly: (s = r.abortEarly) != null ? s : this.spec.abortEarly,
|
|
1867
|
-
recursive: (n = r.recursive) != null ? n : this.spec.recursive,
|
|
1868
|
-
disableStackTrace: (i = r.disableStackTrace) != null ? i : this.spec.disableStackTrace
|
|
1869
|
-
});
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* Run the configured transform pipeline over an input value.
|
|
1873
|
-
*/
|
|
1874
|
-
cast(r, e = {}) {
|
|
1875
|
-
let s = this.resolve(Object.assign({
|
|
1876
|
-
value: r
|
|
1877
|
-
}, e)), n = e.assert === "ignore-optionality", i = s._cast(r, e);
|
|
1878
|
-
if (e.assert !== !1 && !s.isType(i)) {
|
|
1879
|
-
if (n && Nr(i))
|
|
1880
|
-
return i;
|
|
1881
|
-
let a = Oe(r), l = Oe(i);
|
|
1882
|
-
throw new TypeError(`The value of ${e.path || "field"} could not be cast to a value that satisfies the schema type: "${s.type}".
|
|
1883
|
-
|
|
1884
|
-
attempted value: ${a}
|
|
1885
|
-
` + (l !== a ? `result of cast: ${l}` : ""));
|
|
1886
|
-
}
|
|
1887
|
-
return i;
|
|
1888
|
-
}
|
|
1889
|
-
_cast(r, e) {
|
|
1890
|
-
let s = r === void 0 ? r : this.transforms.reduce((n, i) => i.call(this, n, r, this), r);
|
|
1891
|
-
return s === void 0 && (s = this.getDefault(e)), s;
|
|
1892
|
-
}
|
|
1893
|
-
_validate(r, e = {}, s, n) {
|
|
1894
|
-
let {
|
|
1895
|
-
path: i,
|
|
1896
|
-
originalValue: a = r,
|
|
1897
|
-
strict: l = this.spec.strict
|
|
1898
|
-
} = e, o = r;
|
|
1899
|
-
l || (o = this._cast(o, Object.assign({
|
|
1900
|
-
assert: !1
|
|
1901
|
-
}, e)));
|
|
1902
|
-
let d = [];
|
|
1903
|
-
for (let p of Object.values(this.internalTests))
|
|
1904
|
-
p && d.push(p);
|
|
1905
|
-
this.runTests({
|
|
1906
|
-
path: i,
|
|
1907
|
-
value: o,
|
|
1908
|
-
originalValue: a,
|
|
1909
|
-
options: e,
|
|
1910
|
-
tests: d
|
|
1911
|
-
}, s, (p) => {
|
|
1912
|
-
if (p.length)
|
|
1913
|
-
return n(p, o);
|
|
1914
|
-
this.runTests({
|
|
1915
|
-
path: i,
|
|
1916
|
-
value: o,
|
|
1917
|
-
originalValue: a,
|
|
1918
|
-
options: e,
|
|
1919
|
-
tests: this.tests
|
|
1920
|
-
}, s, n);
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
/**
|
|
1924
|
-
* Executes a set of validations, either schema, produced Tests or a nested
|
|
1925
|
-
* schema validate result.
|
|
1926
|
-
*/
|
|
1927
|
-
runTests(r, e, s) {
|
|
1928
|
-
let n = !1, {
|
|
1929
|
-
tests: i,
|
|
1930
|
-
value: a,
|
|
1931
|
-
originalValue: l,
|
|
1932
|
-
path: o,
|
|
1933
|
-
options: d
|
|
1934
|
-
} = r, p = (z) => {
|
|
1935
|
-
n || (n = !0, e(z, a));
|
|
1936
|
-
}, h = (z) => {
|
|
1937
|
-
n || (n = !0, s(z, a));
|
|
1938
|
-
}, y = i.length, N = [];
|
|
1939
|
-
if (!y)
|
|
1940
|
-
return h([]);
|
|
1941
|
-
let I = {
|
|
1942
|
-
value: a,
|
|
1943
|
-
originalValue: l,
|
|
1944
|
-
path: o,
|
|
1945
|
-
options: d,
|
|
1946
|
-
schema: this
|
|
1947
|
-
};
|
|
1948
|
-
for (let z = 0; z < i.length; z++) {
|
|
1949
|
-
const ne = i[z];
|
|
1950
|
-
ne(I, p, function(D) {
|
|
1951
|
-
D && (Array.isArray(D) ? N.push(...D) : N.push(D)), --y <= 0 && h(N);
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
asNestedTest({
|
|
1956
|
-
key: r,
|
|
1957
|
-
index: e,
|
|
1958
|
-
parent: s,
|
|
1959
|
-
parentPath: n,
|
|
1960
|
-
originalParent: i,
|
|
1961
|
-
options: a
|
|
1962
|
-
}) {
|
|
1963
|
-
const l = r ?? e;
|
|
1964
|
-
if (l == null)
|
|
1965
|
-
throw TypeError("Must include `key` or `index` for nested validations");
|
|
1966
|
-
const o = typeof l == "number";
|
|
1967
|
-
let d = s[l];
|
|
1968
|
-
const p = Object.assign({}, a, {
|
|
1969
|
-
// Nested validations fields are always strict:
|
|
1970
|
-
// 1. parent isn't strict so the casting will also have cast inner values
|
|
1971
|
-
// 2. parent is strict in which case the nested values weren't cast either
|
|
1972
|
-
strict: !0,
|
|
1973
|
-
parent: s,
|
|
1974
|
-
value: d,
|
|
1975
|
-
originalValue: i[l],
|
|
1976
|
-
// FIXME: tests depend on `index` being passed around deeply,
|
|
1977
|
-
// we should not let the options.key/index bleed through
|
|
1978
|
-
key: void 0,
|
|
1979
|
-
// index: undefined,
|
|
1980
|
-
[o ? "index" : "key"]: l,
|
|
1981
|
-
path: o || l.includes(".") ? `${n || ""}[${d ? l : `"${l}"`}]` : (n ? `${n}.` : "") + r
|
|
1982
|
-
});
|
|
1983
|
-
return (h, y, N) => this.resolve(p)._validate(d, p, y, N);
|
|
1984
|
-
}
|
|
1985
|
-
validate(r, e) {
|
|
1986
|
-
var s;
|
|
1987
|
-
let n = this.resolve(Object.assign({}, e, {
|
|
1988
|
-
value: r
|
|
1989
|
-
})), i = (s = e == null ? void 0 : e.disableStackTrace) != null ? s : n.spec.disableStackTrace;
|
|
1990
|
-
return new Promise((a, l) => n._validate(r, e, (o, d) => {
|
|
1991
|
-
ue.isError(o) && (o.value = d), l(o);
|
|
1992
|
-
}, (o, d) => {
|
|
1993
|
-
o.length ? l(new ue(o, d, void 0, void 0, i)) : a(d);
|
|
1994
|
-
}));
|
|
1995
|
-
}
|
|
1996
|
-
validateSync(r, e) {
|
|
1997
|
-
var s;
|
|
1998
|
-
let n = this.resolve(Object.assign({}, e, {
|
|
1999
|
-
value: r
|
|
2000
|
-
})), i, a = (s = e == null ? void 0 : e.disableStackTrace) != null ? s : n.spec.disableStackTrace;
|
|
2001
|
-
return n._validate(r, Object.assign({}, e, {
|
|
2002
|
-
sync: !0
|
|
2003
|
-
}), (l, o) => {
|
|
2004
|
-
throw ue.isError(l) && (l.value = o), l;
|
|
2005
|
-
}, (l, o) => {
|
|
2006
|
-
if (l.length)
|
|
2007
|
-
throw new ue(l, r, void 0, void 0, a);
|
|
2008
|
-
i = o;
|
|
2009
|
-
}), i;
|
|
2010
|
-
}
|
|
2011
|
-
isValid(r, e) {
|
|
2012
|
-
return this.validate(r, e).then(() => !0, (s) => {
|
|
2013
|
-
if (ue.isError(s))
|
|
2014
|
-
return !1;
|
|
2015
|
-
throw s;
|
|
2016
|
-
});
|
|
2017
|
-
}
|
|
2018
|
-
isValidSync(r, e) {
|
|
2019
|
-
try {
|
|
2020
|
-
return this.validateSync(r, e), !0;
|
|
2021
|
-
} catch (s) {
|
|
2022
|
-
if (ue.isError(s))
|
|
2023
|
-
return !1;
|
|
2024
|
-
throw s;
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
_getDefault(r) {
|
|
2028
|
-
let e = this.spec.default;
|
|
2029
|
-
return e == null ? e : typeof e == "function" ? e.call(this, r) : Re(e);
|
|
2030
|
-
}
|
|
2031
|
-
getDefault(r) {
|
|
2032
|
-
return this.resolve(r || {})._getDefault(r);
|
|
2033
|
-
}
|
|
2034
|
-
default(r) {
|
|
2035
|
-
return arguments.length === 0 ? this._getDefault() : this.clone({
|
|
2036
|
-
default: r
|
|
2037
|
-
});
|
|
2038
|
-
}
|
|
2039
|
-
strict(r = !0) {
|
|
2040
|
-
return this.clone({
|
|
2041
|
-
strict: r
|
|
2042
|
-
});
|
|
2043
|
-
}
|
|
2044
|
-
nullability(r, e) {
|
|
2045
|
-
const s = this.clone({
|
|
2046
|
-
nullable: r
|
|
2047
|
-
});
|
|
2048
|
-
return s.internalTests.nullable = Ne({
|
|
2049
|
-
message: e,
|
|
2050
|
-
name: "nullable",
|
|
2051
|
-
test(n) {
|
|
2052
|
-
return n === null ? this.schema.spec.nullable : !0;
|
|
2053
|
-
}
|
|
2054
|
-
}), s;
|
|
2055
|
-
}
|
|
2056
|
-
optionality(r, e) {
|
|
2057
|
-
const s = this.clone({
|
|
2058
|
-
optional: r
|
|
2059
|
-
});
|
|
2060
|
-
return s.internalTests.optionality = Ne({
|
|
2061
|
-
message: e,
|
|
2062
|
-
name: "optionality",
|
|
2063
|
-
test(n) {
|
|
2064
|
-
return n === void 0 ? this.schema.spec.optional : !0;
|
|
2065
|
-
}
|
|
2066
|
-
}), s;
|
|
2067
|
-
}
|
|
2068
|
-
optional() {
|
|
2069
|
-
return this.optionality(!0);
|
|
2070
|
-
}
|
|
2071
|
-
defined(r = xe.defined) {
|
|
2072
|
-
return this.optionality(!1, r);
|
|
2073
|
-
}
|
|
2074
|
-
nullable() {
|
|
2075
|
-
return this.nullability(!0);
|
|
2076
|
-
}
|
|
2077
|
-
nonNullable(r = xe.notNull) {
|
|
2078
|
-
return this.nullability(!1, r);
|
|
2079
|
-
}
|
|
2080
|
-
required(r = xe.required) {
|
|
2081
|
-
return this.clone().withMutation((e) => e.nonNullable(r).defined(r));
|
|
2082
|
-
}
|
|
2083
|
-
notRequired() {
|
|
2084
|
-
return this.clone().withMutation((r) => r.nullable().optional());
|
|
2085
|
-
}
|
|
2086
|
-
transform(r) {
|
|
2087
|
-
let e = this.clone();
|
|
2088
|
-
return e.transforms.push(r), e;
|
|
2089
|
-
}
|
|
2090
|
-
/**
|
|
2091
|
-
* Adds a test function to the schema's queue of tests.
|
|
2092
|
-
* tests can be exclusive or non-exclusive.
|
|
2093
|
-
*
|
|
2094
|
-
* - exclusive tests, will replace any existing tests of the same name.
|
|
2095
|
-
* - non-exclusive: can be stacked
|
|
2096
|
-
*
|
|
2097
|
-
* If a non-exclusive test is added to a schema with an exclusive test of the same name
|
|
2098
|
-
* the exclusive test is removed and further tests of the same name will be stacked.
|
|
2099
|
-
*
|
|
2100
|
-
* If an exclusive test is added to a schema with non-exclusive tests of the same name
|
|
2101
|
-
* the previous tests are removed and further tests of the same name will replace each other.
|
|
2102
|
-
*/
|
|
2103
|
-
test(...r) {
|
|
2104
|
-
let e;
|
|
2105
|
-
if (r.length === 1 ? typeof r[0] == "function" ? e = {
|
|
2106
|
-
test: r[0]
|
|
2107
|
-
} : e = r[0] : r.length === 2 ? e = {
|
|
2108
|
-
name: r[0],
|
|
2109
|
-
test: r[1]
|
|
2110
|
-
} : e = {
|
|
2111
|
-
name: r[0],
|
|
2112
|
-
message: r[1],
|
|
2113
|
-
test: r[2]
|
|
2114
|
-
}, e.message === void 0 && (e.message = xe.default), typeof e.test != "function")
|
|
2115
|
-
throw new TypeError("`test` is a required parameters");
|
|
2116
|
-
let s = this.clone(), n = Ne(e), i = e.exclusive || e.name && s.exclusiveTests[e.name] === !0;
|
|
2117
|
-
if (e.exclusive && !e.name)
|
|
2118
|
-
throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
|
|
2119
|
-
return e.name && (s.exclusiveTests[e.name] = !!e.exclusive), s.tests = s.tests.filter((a) => !(a.OPTIONS.name === e.name && (i || a.OPTIONS.test === n.OPTIONS.test))), s.tests.push(n), s;
|
|
2120
|
-
}
|
|
2121
|
-
when(r, e) {
|
|
2122
|
-
!Array.isArray(r) && typeof r != "string" && (e = r, r = ".");
|
|
2123
|
-
let s = this.clone(), n = Mr(r).map((i) => new De(i));
|
|
2124
|
-
return n.forEach((i) => {
|
|
2125
|
-
i.isSibling && s.deps.push(i.key);
|
|
2126
|
-
}), s.conditions.push(typeof e == "function" ? new et(n, e) : et.fromOptions(n, e)), s;
|
|
2127
|
-
}
|
|
2128
|
-
typeError(r) {
|
|
2129
|
-
let e = this.clone();
|
|
2130
|
-
return e.internalTests.typeError = Ne({
|
|
2131
|
-
message: r,
|
|
2132
|
-
name: "typeError",
|
|
2133
|
-
skipAbsent: !0,
|
|
2134
|
-
test(s) {
|
|
2135
|
-
return this.schema._typeCheck(s) ? !0 : this.createError({
|
|
2136
|
-
params: {
|
|
2137
|
-
type: this.schema.type
|
|
2138
|
-
}
|
|
2139
|
-
});
|
|
2140
|
-
}
|
|
2141
|
-
}), e;
|
|
2142
|
-
}
|
|
2143
|
-
oneOf(r, e = xe.oneOf) {
|
|
2144
|
-
let s = this.clone();
|
|
2145
|
-
return r.forEach((n) => {
|
|
2146
|
-
s._whitelist.add(n), s._blacklist.delete(n);
|
|
2147
|
-
}), s.internalTests.whiteList = Ne({
|
|
2148
|
-
message: e,
|
|
2149
|
-
name: "oneOf",
|
|
2150
|
-
skipAbsent: !0,
|
|
2151
|
-
test(n) {
|
|
2152
|
-
let i = this.schema._whitelist, a = i.resolveAll(this.resolve);
|
|
2153
|
-
return a.includes(n) ? !0 : this.createError({
|
|
2154
|
-
params: {
|
|
2155
|
-
values: Array.from(i).join(", "),
|
|
2156
|
-
resolved: a
|
|
2157
|
-
}
|
|
2158
|
-
});
|
|
2159
|
-
}
|
|
2160
|
-
}), s;
|
|
2161
|
-
}
|
|
2162
|
-
notOneOf(r, e = xe.notOneOf) {
|
|
2163
|
-
let s = this.clone();
|
|
2164
|
-
return r.forEach((n) => {
|
|
2165
|
-
s._blacklist.add(n), s._whitelist.delete(n);
|
|
2166
|
-
}), s.internalTests.blacklist = Ne({
|
|
2167
|
-
message: e,
|
|
2168
|
-
name: "notOneOf",
|
|
2169
|
-
test(n) {
|
|
2170
|
-
let i = this.schema._blacklist, a = i.resolveAll(this.resolve);
|
|
2171
|
-
return a.includes(n) ? this.createError({
|
|
2172
|
-
params: {
|
|
2173
|
-
values: Array.from(i).join(", "),
|
|
2174
|
-
resolved: a
|
|
2175
|
-
}
|
|
2176
|
-
}) : !0;
|
|
2177
|
-
}
|
|
2178
|
-
}), s;
|
|
2179
|
-
}
|
|
2180
|
-
strip(r = !0) {
|
|
2181
|
-
let e = this.clone();
|
|
2182
|
-
return e.spec.strip = r, e;
|
|
2183
|
-
}
|
|
2184
|
-
/**
|
|
2185
|
-
* Return a serialized description of the schema including validations, flags, types etc.
|
|
2186
|
-
*
|
|
2187
|
-
* @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
|
|
2188
|
-
*/
|
|
2189
|
-
describe(r) {
|
|
2190
|
-
const e = (r ? this.resolve(r) : this).clone(), {
|
|
2191
|
-
label: s,
|
|
2192
|
-
meta: n,
|
|
2193
|
-
optional: i,
|
|
2194
|
-
nullable: a
|
|
2195
|
-
} = e.spec;
|
|
2196
|
-
return {
|
|
2197
|
-
meta: n,
|
|
2198
|
-
label: s,
|
|
2199
|
-
optional: i,
|
|
2200
|
-
nullable: a,
|
|
2201
|
-
default: e.getDefault(r),
|
|
2202
|
-
type: e.type,
|
|
2203
|
-
oneOf: e._whitelist.describe(),
|
|
2204
|
-
notOneOf: e._blacklist.describe(),
|
|
2205
|
-
tests: e.tests.map((o) => ({
|
|
2206
|
-
name: o.OPTIONS.name,
|
|
2207
|
-
params: o.OPTIONS.params
|
|
2208
|
-
})).filter((o, d, p) => p.findIndex((h) => h.name === o.name) === d)
|
|
2209
|
-
};
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
_e.prototype.__isYupSchema__ = !0;
|
|
2213
|
-
for (const t of ["validate", "validateSync"])
|
|
2214
|
-
_e.prototype[`${t}At`] = function(r, e, s = {}) {
|
|
2215
|
-
const {
|
|
2216
|
-
parent: n,
|
|
2217
|
-
parentPath: i,
|
|
2218
|
-
schema: a
|
|
2219
|
-
} = rn(this, r, e, s.context);
|
|
2220
|
-
return a[t](n && n[i], Object.assign({}, s, {
|
|
2221
|
-
parent: n,
|
|
2222
|
-
path: r
|
|
2223
|
-
}));
|
|
2224
|
-
};
|
|
2225
|
-
for (const t of ["equals", "is"])
|
|
2226
|
-
_e.prototype[t] = _e.prototype.oneOf;
|
|
2227
|
-
for (const t of ["not", "nope"])
|
|
2228
|
-
_e.prototype[t] = _e.prototype.notOneOf;
|
|
2229
|
-
const sn = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
|
|
2230
|
-
function ve(t, r = 0) {
|
|
2231
|
-
return Number(t) || r;
|
|
2232
|
-
}
|
|
2233
|
-
function nn(t) {
|
|
2234
|
-
const r = sn.exec(t);
|
|
2235
|
-
if (!r)
|
|
2236
|
-
return Date.parse ? Date.parse(t) : Number.NaN;
|
|
2237
|
-
const e = {
|
|
2238
|
-
year: ve(r[1]),
|
|
2239
|
-
month: ve(r[2], 1) - 1,
|
|
2240
|
-
day: ve(r[3], 1),
|
|
2241
|
-
hour: ve(r[4]),
|
|
2242
|
-
minute: ve(r[5]),
|
|
2243
|
-
second: ve(r[6]),
|
|
2244
|
-
millisecond: r[7] ? (
|
|
2245
|
-
// allow arbitrary sub-second precision beyond milliseconds
|
|
2246
|
-
ve(r[7].substring(0, 3))
|
|
2247
|
-
) : 0,
|
|
2248
|
-
z: r[8] || void 0,
|
|
2249
|
-
plusMinus: r[9] || void 0,
|
|
2250
|
-
hourOffset: ve(r[10]),
|
|
2251
|
-
minuteOffset: ve(r[11])
|
|
2252
|
-
};
|
|
2253
|
-
if (e.z === void 0 && e.plusMinus === void 0)
|
|
2254
|
-
return new Date(e.year, e.month, e.day, e.hour, e.minute, e.second, e.millisecond).valueOf();
|
|
2255
|
-
let s = 0;
|
|
2256
|
-
return e.z !== "Z" && e.plusMinus !== void 0 && (s = e.hourOffset * 60 + e.minuteOffset, e.plusMinus === "+" && (s = 0 - s)), Date.UTC(e.year, e.month, e.day, e.hour, e.minute + s, e.second, e.millisecond);
|
|
2257
|
-
}
|
|
2258
|
-
let an = /* @__PURE__ */ new Date(""), un = (t) => Object.prototype.toString.call(t) === "[object Date]";
|
|
2259
|
-
class at extends _e {
|
|
2260
|
-
constructor() {
|
|
2261
|
-
super({
|
|
2262
|
-
type: "date",
|
|
2263
|
-
check(r) {
|
|
2264
|
-
return un(r) && !isNaN(r.getTime());
|
|
2265
|
-
}
|
|
2266
|
-
}), this.withMutation(() => {
|
|
2267
|
-
this.transform((r, e, s) => !s.spec.coerce || s.isType(r) || r === null ? r : (r = nn(r), isNaN(r) ? at.INVALID_DATE : new Date(r)));
|
|
2268
|
-
});
|
|
2269
|
-
}
|
|
2270
|
-
prepareParam(r, e) {
|
|
2271
|
-
let s;
|
|
2272
|
-
if (De.isRef(r))
|
|
2273
|
-
s = r;
|
|
2274
|
-
else {
|
|
2275
|
-
let n = this.cast(r);
|
|
2276
|
-
if (!this._typeCheck(n))
|
|
2277
|
-
throw new TypeError(`\`${e}\` must be a Date or a value that can be \`cast()\` to a Date`);
|
|
2278
|
-
s = n;
|
|
2279
|
-
}
|
|
2280
|
-
return s;
|
|
2281
|
-
}
|
|
2282
|
-
min(r, e = Vt.min) {
|
|
2283
|
-
let s = this.prepareParam(r, "min");
|
|
2284
|
-
return this.test({
|
|
2285
|
-
message: e,
|
|
2286
|
-
name: "min",
|
|
2287
|
-
exclusive: !0,
|
|
2288
|
-
params: {
|
|
2289
|
-
min: r
|
|
2290
|
-
},
|
|
2291
|
-
skipAbsent: !0,
|
|
2292
|
-
test(n) {
|
|
2293
|
-
return n >= this.resolve(s);
|
|
2294
|
-
}
|
|
2295
|
-
});
|
|
2296
|
-
}
|
|
2297
|
-
max(r, e = Vt.max) {
|
|
2298
|
-
let s = this.prepareParam(r, "max");
|
|
2299
|
-
return this.test({
|
|
2300
|
-
message: e,
|
|
2301
|
-
name: "max",
|
|
2302
|
-
exclusive: !0,
|
|
2303
|
-
params: {
|
|
2304
|
-
max: r
|
|
2305
|
-
},
|
|
2306
|
-
skipAbsent: !0,
|
|
2307
|
-
test(n) {
|
|
2308
|
-
return n <= this.resolve(s);
|
|
2309
|
-
}
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
at.INVALID_DATE = an;
|
|
2314
|
-
at.prototype;
|
|
2315
|
-
function ln(t, r = []) {
|
|
2316
|
-
let e = [], s = /* @__PURE__ */ new Set(), n = new Set(r.map(([a, l]) => `${a}-${l}`));
|
|
2317
|
-
function i(a, l) {
|
|
2318
|
-
let o = Fe.split(a)[0];
|
|
2319
|
-
s.add(o), n.has(`${l}-${o}`) || e.push([l, o]);
|
|
2320
|
-
}
|
|
2321
|
-
for (const a of Object.keys(t)) {
|
|
2322
|
-
let l = t[a];
|
|
2323
|
-
s.add(a), De.isRef(l) && l.isSibling ? i(l.path, a) : Lt(l) && "deps" in l && l.deps.forEach((o) => i(o, a));
|
|
2324
|
-
}
|
|
2325
|
-
return Ws.array(Array.from(s), e).reverse();
|
|
2326
|
-
}
|
|
2327
|
-
function ir(t, r) {
|
|
2328
|
-
let e = 1 / 0;
|
|
2329
|
-
return t.some((s, n) => {
|
|
2330
|
-
var i;
|
|
2331
|
-
if ((i = r.path) != null && i.includes(s))
|
|
2332
|
-
return e = n, !0;
|
|
2333
|
-
}), e;
|
|
2334
|
-
}
|
|
2335
|
-
function Ir(t) {
|
|
2336
|
-
return (r, e) => ir(t, r) - ir(t, e);
|
|
2337
|
-
}
|
|
2338
|
-
const on = (t, r, e) => {
|
|
2339
|
-
if (typeof t != "string")
|
|
2340
|
-
return t;
|
|
2341
|
-
let s = t;
|
|
2342
|
-
try {
|
|
2343
|
-
s = JSON.parse(t);
|
|
2344
|
-
} catch {
|
|
2345
|
-
}
|
|
2346
|
-
return e.isType(s) ? s : t;
|
|
2347
|
-
};
|
|
2348
|
-
function Ze(t) {
|
|
2349
|
-
if ("fields" in t) {
|
|
2350
|
-
const r = {};
|
|
2351
|
-
for (const [e, s] of Object.entries(t.fields))
|
|
2352
|
-
r[e] = Ze(s);
|
|
2353
|
-
return t.setFields(r);
|
|
2354
|
-
}
|
|
2355
|
-
if (t.type === "array") {
|
|
2356
|
-
const r = t.optional();
|
|
2357
|
-
return r.innerType && (r.innerType = Ze(r.innerType)), r;
|
|
2358
|
-
}
|
|
2359
|
-
return t.type === "tuple" ? t.optional().clone({
|
|
2360
|
-
types: t.spec.types.map(Ze)
|
|
2361
|
-
}) : "optional" in t ? t.optional() : t;
|
|
2362
|
-
}
|
|
2363
|
-
const cn = (t, r) => {
|
|
2364
|
-
const e = [...Fe.normalizePath(r)];
|
|
2365
|
-
if (e.length === 1)
|
|
2366
|
-
return e[0] in t;
|
|
2367
|
-
let s = e.pop(), n = Fe.getter(Fe.join(e), !0)(t);
|
|
2368
|
-
return !!(n && s in n);
|
|
2369
|
-
};
|
|
2370
|
-
let ar = (t) => Object.prototype.toString.call(t) === "[object Object]";
|
|
2371
|
-
function fn(t, r) {
|
|
2372
|
-
let e = Object.keys(t.fields);
|
|
2373
|
-
return Object.keys(r).filter((s) => e.indexOf(s) === -1);
|
|
2374
|
-
}
|
|
2375
|
-
const dn = Ir([]);
|
|
2376
|
-
function Pt(t) {
|
|
2377
|
-
return new Rr(t);
|
|
2378
|
-
}
|
|
2379
|
-
class Rr extends _e {
|
|
2380
|
-
constructor(r) {
|
|
2381
|
-
super({
|
|
2382
|
-
type: "object",
|
|
2383
|
-
check(e) {
|
|
2384
|
-
return ar(e) || typeof e == "function";
|
|
2385
|
-
}
|
|
2386
|
-
}), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = dn, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
|
|
2387
|
-
r && this.shape(r);
|
|
2388
|
-
});
|
|
2389
|
-
}
|
|
2390
|
-
_cast(r, e = {}) {
|
|
2391
|
-
var s;
|
|
2392
|
-
let n = super._cast(r, e);
|
|
2393
|
-
if (n === void 0)
|
|
2394
|
-
return this.getDefault(e);
|
|
2395
|
-
if (!this._typeCheck(n))
|
|
2396
|
-
return n;
|
|
2397
|
-
let i = this.fields, a = (s = e.stripUnknown) != null ? s : this.spec.noUnknown, l = [].concat(this._nodes, Object.keys(n).filter((h) => !this._nodes.includes(h))), o = {}, d = Object.assign({}, e, {
|
|
2398
|
-
parent: o,
|
|
2399
|
-
__validating: e.__validating || !1
|
|
2400
|
-
}), p = !1;
|
|
2401
|
-
for (const h of l) {
|
|
2402
|
-
let y = i[h], N = h in n;
|
|
2403
|
-
if (y) {
|
|
2404
|
-
let I, z = n[h];
|
|
2405
|
-
d.path = (e.path ? `${e.path}.` : "") + h, y = y.resolve({
|
|
2406
|
-
value: z,
|
|
2407
|
-
context: e.context,
|
|
2408
|
-
parent: o
|
|
2409
|
-
});
|
|
2410
|
-
let ne = y instanceof _e ? y.spec : void 0, te = ne == null ? void 0 : ne.strict;
|
|
2411
|
-
if (ne != null && ne.strip) {
|
|
2412
|
-
p = p || h in n;
|
|
2413
|
-
continue;
|
|
2414
|
-
}
|
|
2415
|
-
I = !e.__validating || !te ? (
|
|
2416
|
-
// TODO: use _cast, this is double resolving
|
|
2417
|
-
y.cast(n[h], d)
|
|
2418
|
-
) : n[h], I !== void 0 && (o[h] = I);
|
|
2419
|
-
} else
|
|
2420
|
-
N && !a && (o[h] = n[h]);
|
|
2421
|
-
(N !== h in o || o[h] !== n[h]) && (p = !0);
|
|
2422
|
-
}
|
|
2423
|
-
return p ? o : n;
|
|
2424
|
-
}
|
|
2425
|
-
_validate(r, e = {}, s, n) {
|
|
2426
|
-
let {
|
|
2427
|
-
from: i = [],
|
|
2428
|
-
originalValue: a = r,
|
|
2429
|
-
recursive: l = this.spec.recursive
|
|
2430
|
-
} = e;
|
|
2431
|
-
e.from = [{
|
|
2432
|
-
schema: this,
|
|
2433
|
-
value: a
|
|
2434
|
-
}, ...i], e.__validating = !0, e.originalValue = a, super._validate(r, e, s, (o, d) => {
|
|
2435
|
-
if (!l || !ar(d)) {
|
|
2436
|
-
n(o, d);
|
|
2437
|
-
return;
|
|
2438
|
-
}
|
|
2439
|
-
a = a || d;
|
|
2440
|
-
let p = [];
|
|
2441
|
-
for (let h of this._nodes) {
|
|
2442
|
-
let y = this.fields[h];
|
|
2443
|
-
!y || De.isRef(y) || p.push(y.asNestedTest({
|
|
2444
|
-
options: e,
|
|
2445
|
-
key: h,
|
|
2446
|
-
parent: d,
|
|
2447
|
-
parentPath: e.path,
|
|
2448
|
-
originalParent: a
|
|
2449
|
-
}));
|
|
2450
|
-
}
|
|
2451
|
-
this.runTests({
|
|
2452
|
-
tests: p,
|
|
2453
|
-
value: d,
|
|
2454
|
-
originalValue: a,
|
|
2455
|
-
options: e
|
|
2456
|
-
}, s, (h) => {
|
|
2457
|
-
n(h.sort(this._sortErrors).concat(o), d);
|
|
2458
|
-
});
|
|
2459
|
-
});
|
|
2460
|
-
}
|
|
2461
|
-
clone(r) {
|
|
2462
|
-
const e = super.clone(r);
|
|
2463
|
-
return e.fields = Object.assign({}, this.fields), e._nodes = this._nodes, e._excludedEdges = this._excludedEdges, e._sortErrors = this._sortErrors, e;
|
|
2464
|
-
}
|
|
2465
|
-
concat(r) {
|
|
2466
|
-
let e = super.concat(r), s = e.fields;
|
|
2467
|
-
for (let [n, i] of Object.entries(this.fields)) {
|
|
2468
|
-
const a = s[n];
|
|
2469
|
-
s[n] = a === void 0 ? i : a;
|
|
2470
|
-
}
|
|
2471
|
-
return e.withMutation((n) => (
|
|
2472
|
-
// XXX: excludes here is wrong
|
|
2473
|
-
n.setFields(s, [...this._excludedEdges, ...r._excludedEdges])
|
|
2474
|
-
));
|
|
2475
|
-
}
|
|
2476
|
-
_getDefault(r) {
|
|
2477
|
-
if ("default" in this.spec)
|
|
2478
|
-
return super._getDefault(r);
|
|
2479
|
-
if (!this._nodes.length)
|
|
2480
|
-
return;
|
|
2481
|
-
let e = {};
|
|
2482
|
-
return this._nodes.forEach((s) => {
|
|
2483
|
-
var n;
|
|
2484
|
-
const i = this.fields[s];
|
|
2485
|
-
let a = r;
|
|
2486
|
-
(n = a) != null && n.value && (a = Object.assign({}, a, {
|
|
2487
|
-
parent: a.value,
|
|
2488
|
-
value: a.value[s]
|
|
2489
|
-
})), e[s] = i && "getDefault" in i ? i.getDefault(a) : void 0;
|
|
2490
|
-
}), e;
|
|
2491
|
-
}
|
|
2492
|
-
setFields(r, e) {
|
|
2493
|
-
let s = this.clone();
|
|
2494
|
-
return s.fields = r, s._nodes = ln(r, e), s._sortErrors = Ir(Object.keys(r)), e && (s._excludedEdges = e), s;
|
|
2495
|
-
}
|
|
2496
|
-
shape(r, e = []) {
|
|
2497
|
-
return this.clone().withMutation((s) => {
|
|
2498
|
-
let n = s._excludedEdges;
|
|
2499
|
-
return e.length && (Array.isArray(e[0]) || (e = [e]), n = [...s._excludedEdges, ...e]), s.setFields(Object.assign(s.fields, r), n);
|
|
2500
|
-
});
|
|
2501
|
-
}
|
|
2502
|
-
partial() {
|
|
2503
|
-
const r = {};
|
|
2504
|
-
for (const [e, s] of Object.entries(this.fields))
|
|
2505
|
-
r[e] = "optional" in s && s.optional instanceof Function ? s.optional() : s;
|
|
2506
|
-
return this.setFields(r);
|
|
2507
|
-
}
|
|
2508
|
-
deepPartial() {
|
|
2509
|
-
return Ze(this);
|
|
2510
|
-
}
|
|
2511
|
-
pick(r) {
|
|
2512
|
-
const e = {};
|
|
2513
|
-
for (const s of r)
|
|
2514
|
-
this.fields[s] && (e[s] = this.fields[s]);
|
|
2515
|
-
return this.setFields(e, this._excludedEdges.filter(([s, n]) => r.includes(s) && r.includes(n)));
|
|
2516
|
-
}
|
|
2517
|
-
omit(r) {
|
|
2518
|
-
const e = [];
|
|
2519
|
-
for (const s of Object.keys(this.fields))
|
|
2520
|
-
r.includes(s) || e.push(s);
|
|
2521
|
-
return this.pick(e);
|
|
2522
|
-
}
|
|
2523
|
-
from(r, e, s) {
|
|
2524
|
-
let n = Fe.getter(r, !0);
|
|
2525
|
-
return this.transform((i) => {
|
|
2526
|
-
if (!i)
|
|
2527
|
-
return i;
|
|
2528
|
-
let a = i;
|
|
2529
|
-
return cn(i, r) && (a = Object.assign({}, i), s || delete a[r], a[e] = n(i)), a;
|
|
2530
|
-
});
|
|
2531
|
-
}
|
|
2532
|
-
/** Parse an input JSON string to an object */
|
|
2533
|
-
json() {
|
|
2534
|
-
return this.transform(on);
|
|
2535
|
-
}
|
|
2536
|
-
noUnknown(r = !0, e = Ft.noUnknown) {
|
|
2537
|
-
typeof r != "boolean" && (e = r, r = !0);
|
|
2538
|
-
let s = this.test({
|
|
2539
|
-
name: "noUnknown",
|
|
2540
|
-
exclusive: !0,
|
|
2541
|
-
message: e,
|
|
2542
|
-
test(n) {
|
|
2543
|
-
if (n == null)
|
|
2544
|
-
return !0;
|
|
2545
|
-
const i = fn(this.schema, n);
|
|
2546
|
-
return !r || i.length === 0 || this.createError({
|
|
2547
|
-
params: {
|
|
2548
|
-
unknown: i.join(", ")
|
|
2549
|
-
}
|
|
2550
|
-
});
|
|
2551
|
-
}
|
|
2552
|
-
});
|
|
2553
|
-
return s.spec.noUnknown = r, s;
|
|
2554
|
-
}
|
|
2555
|
-
unknown(r = !0, e = Ft.noUnknown) {
|
|
2556
|
-
return this.noUnknown(!r, e);
|
|
2557
|
-
}
|
|
2558
|
-
transformKeys(r) {
|
|
2559
|
-
return this.transform((e) => {
|
|
2560
|
-
if (!e)
|
|
2561
|
-
return e;
|
|
2562
|
-
const s = {};
|
|
2563
|
-
for (const n of Object.keys(e))
|
|
2564
|
-
s[r(n)] = e[n];
|
|
2565
|
-
return s;
|
|
2566
|
-
});
|
|
2567
|
-
}
|
|
2568
|
-
camelCase() {
|
|
2569
|
-
return this.transformKeys(kt.camelCase);
|
|
2570
|
-
}
|
|
2571
|
-
snakeCase() {
|
|
2572
|
-
return this.transformKeys(kt.snakeCase);
|
|
2573
|
-
}
|
|
2574
|
-
constantCase() {
|
|
2575
|
-
return this.transformKeys((r) => kt.snakeCase(r).toUpperCase());
|
|
2576
|
-
}
|
|
2577
|
-
describe(r) {
|
|
2578
|
-
const e = (r ? this.resolve(r) : this).clone(), s = super.describe(r);
|
|
2579
|
-
s.fields = {};
|
|
2580
|
-
for (const [i, a] of Object.entries(e.fields)) {
|
|
2581
|
-
var n;
|
|
2582
|
-
let l = r;
|
|
2583
|
-
(n = l) != null && n.value && (l = Object.assign({}, l, {
|
|
2584
|
-
parent: l.value,
|
|
2585
|
-
value: l.value[i]
|
|
2586
|
-
})), s.fields[i] = a.describe(l);
|
|
2587
|
-
}
|
|
2588
|
-
return s;
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
Pt.prototype = Rr.prototype;
|
|
2592
|
-
const hn = ({ children: t, ...r }) => /* @__PURE__ */ q(qr, { ...r, children: t }), yn = ({ ...t }) => /* @__PURE__ */ q(
|
|
2593
|
-
zr,
|
|
2594
|
-
{
|
|
2595
|
-
...t
|
|
2596
|
-
}
|
|
2597
|
-
);
|
|
2598
|
-
const Ye = (t) => /* @__PURE__ */ q(We, { ...t });
|
|
2599
|
-
Ye.Password = We.Password;
|
|
2600
|
-
Ye.Search = We.Search;
|
|
2601
|
-
Ye.Group = We.Group;
|
|
2602
|
-
Ye.TextArea = We.TextArea;
|
|
2603
|
-
const pn = ({ ...t }) => /* @__PURE__ */ q(
|
|
2604
|
-
Zr,
|
|
2605
|
-
{
|
|
2606
|
-
...t
|
|
2607
|
-
}
|
|
2608
|
-
), ur = ({ children: t, ...r }) => /* @__PURE__ */ q(Gr, { ...r, children: t }), Bt = (t, r) => {
|
|
2609
|
-
var e, s;
|
|
2610
|
-
switch (t.type) {
|
|
2611
|
-
case "input":
|
|
2612
|
-
const n = t;
|
|
2613
|
-
return /* @__PURE__ */ q(
|
|
2614
|
-
Be,
|
|
2615
|
-
{
|
|
2616
|
-
name: n.key,
|
|
2617
|
-
label: n.label,
|
|
2618
|
-
control: r,
|
|
2619
|
-
children: ((e = n.props) == null ? void 0 : e.mode) !== "multiple" ? /* @__PURE__ */ q(Ye, { placeholder: n.placeholder }) : /* @__PURE__ */ q(ur, { mode: "tags", placeholder: n.placeholder })
|
|
2620
|
-
},
|
|
2621
|
-
n.key
|
|
2622
|
-
);
|
|
2623
|
-
case "number":
|
|
2624
|
-
const i = t;
|
|
2625
|
-
return /* @__PURE__ */ q(
|
|
2626
|
-
Be,
|
|
2627
|
-
{
|
|
2628
|
-
name: i.key,
|
|
2629
|
-
label: i.label,
|
|
2630
|
-
control: r,
|
|
2631
|
-
children: /* @__PURE__ */ q(pn, { keyboard: !1, placeholder: i.placeholder })
|
|
2632
|
-
},
|
|
2633
|
-
i.key
|
|
2634
|
-
);
|
|
2635
|
-
case "select":
|
|
2636
|
-
const a = t;
|
|
2637
|
-
return /* @__PURE__ */ q(
|
|
2638
|
-
Be,
|
|
2639
|
-
{
|
|
2640
|
-
name: a.key,
|
|
2641
|
-
label: a.label,
|
|
2642
|
-
control: r,
|
|
2643
|
-
children: /* @__PURE__ */ q(
|
|
2644
|
-
ur,
|
|
2645
|
-
{
|
|
2646
|
-
mode: (s = a.props) == null ? void 0 : s.mode,
|
|
2647
|
-
options: a.options,
|
|
2648
|
-
placeholder: a.placeholder
|
|
2649
|
-
}
|
|
2650
|
-
)
|
|
2651
|
-
},
|
|
2652
|
-
a.key
|
|
2653
|
-
);
|
|
2654
|
-
case "checkbox":
|
|
2655
|
-
const l = t, { labelRightAligned: o } = l.props || {};
|
|
2656
|
-
return /* @__PURE__ */ q(
|
|
2657
|
-
Be,
|
|
2658
|
-
{
|
|
2659
|
-
name: l.key,
|
|
2660
|
-
initialValue: l.value,
|
|
2661
|
-
control: r,
|
|
2662
|
-
valuePropName: "checked",
|
|
2663
|
-
label: o ? "" : l.label,
|
|
2664
|
-
children: /* @__PURE__ */ q(hn, { children: o ? l.label : "" })
|
|
2665
|
-
},
|
|
2666
|
-
l.key
|
|
2667
|
-
);
|
|
2668
|
-
case "datepicker":
|
|
2669
|
-
const d = t;
|
|
2670
|
-
return /* @__PURE__ */ q(
|
|
2671
|
-
Be,
|
|
2672
|
-
{
|
|
2673
|
-
name: d.key,
|
|
2674
|
-
label: d.label,
|
|
2675
|
-
control: r,
|
|
2676
|
-
children: /* @__PURE__ */ q(yn, { placeholder: d.placeholder })
|
|
2677
|
-
},
|
|
2678
|
-
d.key
|
|
2679
|
-
);
|
|
2680
|
-
case "field-array":
|
|
2681
|
-
if (t.config)
|
|
2682
|
-
return /* @__PURE__ */ q(T.Fragment, { children: t.config.fields.map(
|
|
2683
|
-
(p) => Bt(p, r)
|
|
2684
|
-
) }, t.key);
|
|
2685
|
-
break;
|
|
2686
|
-
default:
|
|
2687
|
-
return "unsupported field type";
|
|
2688
|
-
}
|
|
2689
|
-
}, An = ({
|
|
2690
|
-
builderFields: t,
|
|
2691
|
-
children: r,
|
|
2692
|
-
...e
|
|
2693
|
-
}) => {
|
|
2694
|
-
const s = Pt(
|
|
2695
|
-
t.reduce((a, l) => l.type !== "field-array" && l.validation ? { ...a, [l.key]: l.validation } : a, {})
|
|
2696
|
-
), n = jt({
|
|
2697
|
-
defaultValues: t.reduce((a, l) => (l.defaultValue !== void 0 && (a[l.key] = l.defaultValue), a), {}),
|
|
2698
|
-
resolver: Vr(s)
|
|
2699
|
-
}), { control: i } = n;
|
|
2700
|
-
return /* @__PURE__ */ Hr(
|
|
2701
|
-
ye,
|
|
2702
|
-
{
|
|
2703
|
-
...e,
|
|
2704
|
-
onFinish: n.handleSubmit(
|
|
2705
|
-
() => {
|
|
2706
|
-
var a;
|
|
2707
|
-
return (a = e.onFinish) == null ? void 0 : a.call(e, n.getValues());
|
|
2708
|
-
},
|
|
2709
|
-
() => console.error("Form validation failed")
|
|
2710
|
-
),
|
|
2711
|
-
children: [
|
|
2712
|
-
t.map((a) => Bt(a, i)),
|
|
2713
|
-
/* @__PURE__ */ q("div", { children: r })
|
|
2714
|
-
]
|
|
2715
|
-
}
|
|
2716
|
-
);
|
|
2717
|
-
};
|
|
2718
|
-
var Ur = { exports: {} };
|
|
2719
|
-
(function(t, r) {
|
|
2720
|
-
(function(e, s) {
|
|
2721
|
-
t.exports = s();
|
|
2722
|
-
})($s, function() {
|
|
2723
|
-
var e = 1e3, s = 6e4, n = 36e5, i = "millisecond", a = "second", l = "minute", o = "hour", d = "day", p = "week", h = "month", y = "quarter", N = "year", I = "date", z = "Invalid Date", ne = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, te = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, D = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(k) {
|
|
2724
|
-
var b = ["th", "st", "nd", "rd"], m = k % 100;
|
|
2725
|
-
return "[" + k + (b[(m - 20) % 10] || b[m] || b[0]) + "]";
|
|
2726
|
-
} }, K = function(k, b, m) {
|
|
2727
|
-
var $ = String(k);
|
|
2728
|
-
return !$ || $.length >= b ? k : "" + Array(b + 1 - $.length).join(m) + k;
|
|
2729
|
-
}, re = { s: K, z: function(k) {
|
|
2730
|
-
var b = -k.utcOffset(), m = Math.abs(b), $ = Math.floor(m / 60), _ = m % 60;
|
|
2731
|
-
return (b <= 0 ? "+" : "-") + K($, 2, "0") + ":" + K(_, 2, "0");
|
|
2732
|
-
}, m: function k(b, m) {
|
|
2733
|
-
if (b.date() < m.date())
|
|
2734
|
-
return -k(m, b);
|
|
2735
|
-
var $ = 12 * (m.year() - b.year()) + (m.month() - b.month()), _ = b.clone().add($, h), V = m - _ < 0, F = b.clone().add($ + (V ? -1 : 1), h);
|
|
2736
|
-
return +(-($ + (m - _) / (V ? _ - F : F - _)) || 0);
|
|
2737
|
-
}, a: function(k) {
|
|
2738
|
-
return k < 0 ? Math.ceil(k) || 0 : Math.floor(k);
|
|
2739
|
-
}, p: function(k) {
|
|
2740
|
-
return { M: h, y: N, w: p, d, D: I, h: o, m: l, s: a, ms: i, Q: y }[k] || String(k || "").toLowerCase().replace(/s$/, "");
|
|
2741
|
-
}, u: function(k) {
|
|
2742
|
-
return k === void 0;
|
|
2743
|
-
} }, w = "en", A = {};
|
|
2744
|
-
A[w] = D;
|
|
2745
|
-
var C = "$isDayjsObject", H = function(k) {
|
|
2746
|
-
return k instanceof j || !(!k || !k[C]);
|
|
2747
|
-
}, P = function k(b, m, $) {
|
|
2748
|
-
var _;
|
|
2749
|
-
if (!b)
|
|
2750
|
-
return w;
|
|
2751
|
-
if (typeof b == "string") {
|
|
2752
|
-
var V = b.toLowerCase();
|
|
2753
|
-
A[V] && (_ = V), m && (A[V] = m, _ = V);
|
|
2754
|
-
var F = b.split("-");
|
|
2755
|
-
if (!_ && F.length > 1)
|
|
2756
|
-
return k(F[0]);
|
|
2757
|
-
} else {
|
|
2758
|
-
var U = b.name;
|
|
2759
|
-
A[U] = b, _ = U;
|
|
2760
|
-
}
|
|
2761
|
-
return !$ && _ && (w = _), _ || !$ && w;
|
|
2762
|
-
}, R = function(k, b) {
|
|
2763
|
-
if (H(k))
|
|
2764
|
-
return k.clone();
|
|
2765
|
-
var m = typeof b == "object" ? b : {};
|
|
2766
|
-
return m.date = k, m.args = arguments, new j(m);
|
|
2767
|
-
}, O = re;
|
|
2768
|
-
O.l = P, O.i = H, O.w = function(k, b) {
|
|
2769
|
-
return R(k, { locale: b.$L, utc: b.$u, x: b.$x, $offset: b.$offset });
|
|
2770
|
-
};
|
|
2771
|
-
var j = function() {
|
|
2772
|
-
function k(m) {
|
|
2773
|
-
this.$L = P(m.locale, null, !0), this.parse(m), this.$x = this.$x || m.x || {}, this[C] = !0;
|
|
2774
|
-
}
|
|
2775
|
-
var b = k.prototype;
|
|
2776
|
-
return b.parse = function(m) {
|
|
2777
|
-
this.$d = function($) {
|
|
2778
|
-
var _ = $.date, V = $.utc;
|
|
2779
|
-
if (_ === null)
|
|
2780
|
-
return /* @__PURE__ */ new Date(NaN);
|
|
2781
|
-
if (O.u(_))
|
|
2782
|
-
return /* @__PURE__ */ new Date();
|
|
2783
|
-
if (_ instanceof Date)
|
|
2784
|
-
return new Date(_);
|
|
2785
|
-
if (typeof _ == "string" && !/Z$/i.test(_)) {
|
|
2786
|
-
var F = _.match(ne);
|
|
2787
|
-
if (F) {
|
|
2788
|
-
var U = F[2] - 1 || 0, Y = (F[7] || "0").substring(0, 3);
|
|
2789
|
-
return V ? new Date(Date.UTC(F[1], U, F[3] || 1, F[4] || 0, F[5] || 0, F[6] || 0, Y)) : new Date(F[1], U, F[3] || 1, F[4] || 0, F[5] || 0, F[6] || 0, Y);
|
|
2790
|
-
}
|
|
2791
|
-
}
|
|
2792
|
-
return new Date(_);
|
|
2793
|
-
}(m), this.init();
|
|
2794
|
-
}, b.init = function() {
|
|
2795
|
-
var m = this.$d;
|
|
2796
|
-
this.$y = m.getFullYear(), this.$M = m.getMonth(), this.$D = m.getDate(), this.$W = m.getDay(), this.$H = m.getHours(), this.$m = m.getMinutes(), this.$s = m.getSeconds(), this.$ms = m.getMilliseconds();
|
|
2797
|
-
}, b.$utils = function() {
|
|
2798
|
-
return O;
|
|
2799
|
-
}, b.isValid = function() {
|
|
2800
|
-
return this.$d.toString() !== z;
|
|
2801
|
-
}, b.isSame = function(m, $) {
|
|
2802
|
-
var _ = R(m);
|
|
2803
|
-
return this.startOf($) <= _ && _ <= this.endOf($);
|
|
2804
|
-
}, b.isAfter = function(m, $) {
|
|
2805
|
-
return R(m) < this.startOf($);
|
|
2806
|
-
}, b.isBefore = function(m, $) {
|
|
2807
|
-
return this.endOf($) < R(m);
|
|
2808
|
-
}, b.$g = function(m, $, _) {
|
|
2809
|
-
return O.u(m) ? this[$] : this.set(_, m);
|
|
2810
|
-
}, b.unix = function() {
|
|
2811
|
-
return Math.floor(this.valueOf() / 1e3);
|
|
2812
|
-
}, b.valueOf = function() {
|
|
2813
|
-
return this.$d.getTime();
|
|
2814
|
-
}, b.startOf = function(m, $) {
|
|
2815
|
-
var _ = this, V = !!O.u($) || $, F = O.p(m), U = function(de, se) {
|
|
2816
|
-
var pe = O.w(_.$u ? Date.UTC(_.$y, se, de) : new Date(_.$y, se, de), _);
|
|
2817
|
-
return V ? pe : pe.endOf(d);
|
|
2818
|
-
}, Y = function(de, se) {
|
|
2819
|
-
return O.w(_.toDate()[de].apply(_.toDate("s"), (V ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(se)), _);
|
|
2820
|
-
}, Z = this.$W, X = this.$M, ie = this.$D, we = "set" + (this.$u ? "UTC" : "");
|
|
2821
|
-
switch (F) {
|
|
2822
|
-
case N:
|
|
2823
|
-
return V ? U(1, 0) : U(31, 11);
|
|
2824
|
-
case h:
|
|
2825
|
-
return V ? U(1, X) : U(0, X + 1);
|
|
2826
|
-
case p:
|
|
2827
|
-
var fe = this.$locale().weekStart || 0, ke = (Z < fe ? Z + 7 : Z) - fe;
|
|
2828
|
-
return U(V ? ie - ke : ie + (6 - ke), X);
|
|
2829
|
-
case d:
|
|
2830
|
-
case I:
|
|
2831
|
-
return Y(we + "Hours", 0);
|
|
2832
|
-
case o:
|
|
2833
|
-
return Y(we + "Minutes", 1);
|
|
2834
|
-
case l:
|
|
2835
|
-
return Y(we + "Seconds", 2);
|
|
2836
|
-
case a:
|
|
2837
|
-
return Y(we + "Milliseconds", 3);
|
|
2838
|
-
default:
|
|
2839
|
-
return this.clone();
|
|
2840
|
-
}
|
|
2841
|
-
}, b.endOf = function(m) {
|
|
2842
|
-
return this.startOf(m, !1);
|
|
2843
|
-
}, b.$set = function(m, $) {
|
|
2844
|
-
var _, V = O.p(m), F = "set" + (this.$u ? "UTC" : ""), U = (_ = {}, _[d] = F + "Date", _[I] = F + "Date", _[h] = F + "Month", _[N] = F + "FullYear", _[o] = F + "Hours", _[l] = F + "Minutes", _[a] = F + "Seconds", _[i] = F + "Milliseconds", _)[V], Y = V === d ? this.$D + ($ - this.$W) : $;
|
|
2845
|
-
if (V === h || V === N) {
|
|
2846
|
-
var Z = this.clone().set(I, 1);
|
|
2847
|
-
Z.$d[U](Y), Z.init(), this.$d = Z.set(I, Math.min(this.$D, Z.daysInMonth())).$d;
|
|
2848
|
-
} else
|
|
2849
|
-
U && this.$d[U](Y);
|
|
2850
|
-
return this.init(), this;
|
|
2851
|
-
}, b.set = function(m, $) {
|
|
2852
|
-
return this.clone().$set(m, $);
|
|
2853
|
-
}, b.get = function(m) {
|
|
2854
|
-
return this[O.p(m)]();
|
|
2855
|
-
}, b.add = function(m, $) {
|
|
2856
|
-
var _, V = this;
|
|
2857
|
-
m = Number(m);
|
|
2858
|
-
var F = O.p($), U = function(X) {
|
|
2859
|
-
var ie = R(V);
|
|
2860
|
-
return O.w(ie.date(ie.date() + Math.round(X * m)), V);
|
|
2861
|
-
};
|
|
2862
|
-
if (F === h)
|
|
2863
|
-
return this.set(h, this.$M + m);
|
|
2864
|
-
if (F === N)
|
|
2865
|
-
return this.set(N, this.$y + m);
|
|
2866
|
-
if (F === d)
|
|
2867
|
-
return U(1);
|
|
2868
|
-
if (F === p)
|
|
2869
|
-
return U(7);
|
|
2870
|
-
var Y = (_ = {}, _[l] = s, _[o] = n, _[a] = e, _)[F] || 1, Z = this.$d.getTime() + m * Y;
|
|
2871
|
-
return O.w(Z, this);
|
|
2872
|
-
}, b.subtract = function(m, $) {
|
|
2873
|
-
return this.add(-1 * m, $);
|
|
2874
|
-
}, b.format = function(m) {
|
|
2875
|
-
var $ = this, _ = this.$locale();
|
|
2876
|
-
if (!this.isValid())
|
|
2877
|
-
return _.invalidDate || z;
|
|
2878
|
-
var V = m || "YYYY-MM-DDTHH:mm:ssZ", F = O.z(this), U = this.$H, Y = this.$m, Z = this.$M, X = _.weekdays, ie = _.months, we = _.meridiem, fe = function(se, pe, $e, Ce) {
|
|
2879
|
-
return se && (se[pe] || se($, V)) || $e[pe].slice(0, Ce);
|
|
2880
|
-
}, ke = function(se) {
|
|
2881
|
-
return O.s(U % 12 || 12, se, "0");
|
|
2882
|
-
}, de = we || function(se, pe, $e) {
|
|
2883
|
-
var Ce = se < 12 ? "AM" : "PM";
|
|
2884
|
-
return $e ? Ce.toLowerCase() : Ce;
|
|
2885
|
-
};
|
|
2886
|
-
return V.replace(te, function(se, pe) {
|
|
2887
|
-
return pe || function($e) {
|
|
2888
|
-
switch ($e) {
|
|
2889
|
-
case "YY":
|
|
2890
|
-
return String($.$y).slice(-2);
|
|
2891
|
-
case "YYYY":
|
|
2892
|
-
return O.s($.$y, 4, "0");
|
|
2893
|
-
case "M":
|
|
2894
|
-
return Z + 1;
|
|
2895
|
-
case "MM":
|
|
2896
|
-
return O.s(Z + 1, 2, "0");
|
|
2897
|
-
case "MMM":
|
|
2898
|
-
return fe(_.monthsShort, Z, ie, 3);
|
|
2899
|
-
case "MMMM":
|
|
2900
|
-
return fe(ie, Z);
|
|
2901
|
-
case "D":
|
|
2902
|
-
return $.$D;
|
|
2903
|
-
case "DD":
|
|
2904
|
-
return O.s($.$D, 2, "0");
|
|
2905
|
-
case "d":
|
|
2906
|
-
return String($.$W);
|
|
2907
|
-
case "dd":
|
|
2908
|
-
return fe(_.weekdaysMin, $.$W, X, 2);
|
|
2909
|
-
case "ddd":
|
|
2910
|
-
return fe(_.weekdaysShort, $.$W, X, 3);
|
|
2911
|
-
case "dddd":
|
|
2912
|
-
return X[$.$W];
|
|
2913
|
-
case "H":
|
|
2914
|
-
return String(U);
|
|
2915
|
-
case "HH":
|
|
2916
|
-
return O.s(U, 2, "0");
|
|
2917
|
-
case "h":
|
|
2918
|
-
return ke(1);
|
|
2919
|
-
case "hh":
|
|
2920
|
-
return ke(2);
|
|
2921
|
-
case "a":
|
|
2922
|
-
return de(U, Y, !0);
|
|
2923
|
-
case "A":
|
|
2924
|
-
return de(U, Y, !1);
|
|
2925
|
-
case "m":
|
|
2926
|
-
return String(Y);
|
|
2927
|
-
case "mm":
|
|
2928
|
-
return O.s(Y, 2, "0");
|
|
2929
|
-
case "s":
|
|
2930
|
-
return String($.$s);
|
|
2931
|
-
case "ss":
|
|
2932
|
-
return O.s($.$s, 2, "0");
|
|
2933
|
-
case "SSS":
|
|
2934
|
-
return O.s($.$ms, 3, "0");
|
|
2935
|
-
case "Z":
|
|
2936
|
-
return F;
|
|
2937
|
-
}
|
|
2938
|
-
return null;
|
|
2939
|
-
}(se) || F.replace(":", "");
|
|
2940
|
-
});
|
|
2941
|
-
}, b.utcOffset = function() {
|
|
2942
|
-
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
2943
|
-
}, b.diff = function(m, $, _) {
|
|
2944
|
-
var V, F = this, U = O.p($), Y = R(m), Z = (Y.utcOffset() - this.utcOffset()) * s, X = this - Y, ie = function() {
|
|
2945
|
-
return O.m(F, Y);
|
|
2946
|
-
};
|
|
2947
|
-
switch (U) {
|
|
2948
|
-
case N:
|
|
2949
|
-
V = ie() / 12;
|
|
2950
|
-
break;
|
|
2951
|
-
case h:
|
|
2952
|
-
V = ie();
|
|
2953
|
-
break;
|
|
2954
|
-
case y:
|
|
2955
|
-
V = ie() / 3;
|
|
2956
|
-
break;
|
|
2957
|
-
case p:
|
|
2958
|
-
V = (X - Z) / 6048e5;
|
|
2959
|
-
break;
|
|
2960
|
-
case d:
|
|
2961
|
-
V = (X - Z) / 864e5;
|
|
2962
|
-
break;
|
|
2963
|
-
case o:
|
|
2964
|
-
V = X / n;
|
|
2965
|
-
break;
|
|
2966
|
-
case l:
|
|
2967
|
-
V = X / s;
|
|
2968
|
-
break;
|
|
2969
|
-
case a:
|
|
2970
|
-
V = X / e;
|
|
2971
|
-
break;
|
|
2972
|
-
default:
|
|
2973
|
-
V = X;
|
|
2974
|
-
}
|
|
2975
|
-
return _ ? V : O.a(V);
|
|
2976
|
-
}, b.daysInMonth = function() {
|
|
2977
|
-
return this.endOf(h).$D;
|
|
2978
|
-
}, b.$locale = function() {
|
|
2979
|
-
return A[this.$L];
|
|
2980
|
-
}, b.locale = function(m, $) {
|
|
2981
|
-
if (!m)
|
|
2982
|
-
return this.$L;
|
|
2983
|
-
var _ = this.clone(), V = P(m, $, !0);
|
|
2984
|
-
return V && (_.$L = V), _;
|
|
2985
|
-
}, b.clone = function() {
|
|
2986
|
-
return O.w(this.$d, this);
|
|
2987
|
-
}, b.toDate = function() {
|
|
2988
|
-
return new Date(this.valueOf());
|
|
2989
|
-
}, b.toJSON = function() {
|
|
2990
|
-
return this.isValid() ? this.toISOString() : null;
|
|
2991
|
-
}, b.toISOString = function() {
|
|
2992
|
-
return this.$d.toISOString();
|
|
2993
|
-
}, b.toString = function() {
|
|
2994
|
-
return this.$d.toUTCString();
|
|
2995
|
-
}, k;
|
|
2996
|
-
}(), M = j.prototype;
|
|
2997
|
-
return R.prototype = M, [["$ms", i], ["$s", a], ["$m", l], ["$H", o], ["$W", d], ["$M", h], ["$y", N], ["$D", I]].forEach(function(k) {
|
|
2998
|
-
M[k[1]] = function(b) {
|
|
2999
|
-
return this.$g(b, k[0], k[1]);
|
|
3000
|
-
};
|
|
3001
|
-
}), R.extend = function(k, b) {
|
|
3002
|
-
return k.$i || (k(b, j, R), k.$i = !0), R;
|
|
3003
|
-
}, R.locale = P, R.isDayjs = H, R.unix = function(k) {
|
|
3004
|
-
return R(1e3 * k);
|
|
3005
|
-
}, R.en = A[w], R.Ls = A, R.p = {}, R;
|
|
3006
|
-
});
|
|
3007
|
-
})(Ur);
|
|
3008
|
-
var mn = Ur.exports;
|
|
3009
|
-
const lr = /* @__PURE__ */ Fr(mn), On = ({
|
|
3010
|
-
builderFields: t,
|
|
3011
|
-
handleChange: r,
|
|
3012
|
-
isDebounced: e = !1
|
|
3013
|
-
}) => {
|
|
3014
|
-
const { control: s, setValue: n } = jt(), i = mr({ control: s });
|
|
3015
|
-
return T.useEffect(() => {
|
|
3016
|
-
if (!Object.keys(i).length || t.every((o) => o.type === "datepicker" ? (i[o.key] === null && (i[o.key] = void 0), i[o.key] ? o.value === lr(i[o.key]).format("YYYY-MM-DD") : o.value === i[o.key]) : typeof i[o.key] == "object" ? JSON.stringify(o.value) === JSON.stringify(i[o.key]) : o.value === i[o.key]))
|
|
3017
|
-
return;
|
|
3018
|
-
if (!e) {
|
|
3019
|
-
r(i);
|
|
3020
|
-
return;
|
|
3021
|
-
}
|
|
3022
|
-
const l = setTimeout(() => {
|
|
3023
|
-
r(i);
|
|
3024
|
-
}, 1e3);
|
|
3025
|
-
return () => {
|
|
3026
|
-
clearTimeout(l);
|
|
3027
|
-
};
|
|
3028
|
-
}, [i]), T.useEffect(() => {
|
|
3029
|
-
t.forEach((a) => {
|
|
3030
|
-
const { key: l, value: o, type: d } = a;
|
|
3031
|
-
if (d === "datepicker" && o) {
|
|
3032
|
-
n(l, lr(o));
|
|
3033
|
-
return;
|
|
3034
|
-
}
|
|
3035
|
-
n(l, o);
|
|
3036
|
-
});
|
|
3037
|
-
}, [t]), /* @__PURE__ */ q(Yr, { children: /* @__PURE__ */ q("div", { className: "form-builder", children: /* @__PURE__ */ q(ye, { children: t.map((a) => Bt(a, s)) }) }) });
|
|
3038
|
-
}, En = (t) => {
|
|
3039
|
-
const r = Pt(
|
|
3040
|
-
t.reduce((n, i) => i.type !== "field-array" && i.validation ? { ...n, [i.key]: i.validation } : n, {})
|
|
3041
|
-
), e = jt({
|
|
3042
|
-
resolver: Vr(r)
|
|
3043
|
-
}), s = t.filter((n) => n.type === "field-array").map((n) => {
|
|
3044
|
-
const { fields: i, ...a } = os({
|
|
3045
|
-
control: e.control,
|
|
3046
|
-
name: n.config.name
|
|
3047
|
-
});
|
|
3048
|
-
return {
|
|
3049
|
-
...n,
|
|
3050
|
-
name: n.config.name,
|
|
3051
|
-
fields: i,
|
|
3052
|
-
...a
|
|
3053
|
-
};
|
|
3054
|
-
});
|
|
3055
|
-
return { ...e, fieldArrays: s };
|
|
3056
|
-
};
|
|
3057
|
-
var Lr = /* @__PURE__ */ ((t) => (t.Dropdown = "dropdown", t.Input = "input", t.Select = "select", t.Text = "text", t.Bool = "bool", t.DateTime = "datetime", t.Nested = "nested", t))(Lr || {});
|
|
3058
|
-
const gn = {
|
|
3059
|
-
text: "input",
|
|
3060
|
-
input: "input",
|
|
3061
|
-
dropdown: "select",
|
|
3062
|
-
select: "select",
|
|
3063
|
-
datetime: "datepicker",
|
|
3064
|
-
nested: "field-array",
|
|
3065
|
-
boolean: "select",
|
|
3066
|
-
bool: "checkbox"
|
|
3067
|
-
};
|
|
3068
|
-
function bn(t) {
|
|
3069
|
-
return typeof t.key == "string" && typeof t.name == "string" && Object.values(Lr).includes(t.data_type);
|
|
3070
|
-
}
|
|
3071
|
-
const vn = (t) => Object.values(t).reduce((r, e) => {
|
|
3072
|
-
if (!bn(e))
|
|
3073
|
-
return console.warn(
|
|
3074
|
-
"Incompatible item detected on field type transformer:",
|
|
3075
|
-
e
|
|
3076
|
-
), r;
|
|
3077
|
-
const s = gn[e.data_type];
|
|
3078
|
-
if (!s)
|
|
3079
|
-
return console.error("Unsupported data type:", e.data_type), r;
|
|
3080
|
-
let n = null;
|
|
3081
|
-
switch (s) {
|
|
3082
|
-
case "field-array":
|
|
3083
|
-
e.schema && (n = {
|
|
3084
|
-
key: e.key,
|
|
3085
|
-
label: e.name,
|
|
3086
|
-
type: s,
|
|
3087
|
-
config: {
|
|
3088
|
-
name: e.key,
|
|
3089
|
-
fields: vn(e.schema)
|
|
3090
|
-
}
|
|
3091
|
-
});
|
|
3092
|
-
break;
|
|
3093
|
-
case "select":
|
|
3094
|
-
if (e.choices) {
|
|
3095
|
-
const i = e.choices;
|
|
3096
|
-
n = {
|
|
3097
|
-
key: e.key,
|
|
3098
|
-
label: e.name,
|
|
3099
|
-
type: s,
|
|
3100
|
-
placeholder: e.placeholder,
|
|
3101
|
-
options: i.map((a) => ({
|
|
3102
|
-
key: a.value.toString(),
|
|
3103
|
-
value: a.value,
|
|
3104
|
-
label: a.label
|
|
3105
|
-
})),
|
|
3106
|
-
validation: e.validation
|
|
3107
|
-
};
|
|
3108
|
-
}
|
|
3109
|
-
break;
|
|
3110
|
-
default:
|
|
3111
|
-
n = {
|
|
3112
|
-
...e,
|
|
3113
|
-
key: e.key,
|
|
3114
|
-
label: e.name,
|
|
3115
|
-
validation: e.validation,
|
|
3116
|
-
type: s,
|
|
3117
|
-
children: null,
|
|
3118
|
-
control: e.control
|
|
3119
|
-
};
|
|
3120
|
-
break;
|
|
3121
|
-
}
|
|
3122
|
-
return n !== null && r.push(n), r;
|
|
3123
|
-
}, []).filter((r) => r !== null);
|
|
3124
|
-
export {
|
|
3125
|
-
An as FormBuilder,
|
|
3126
|
-
On as FormBuilderWatch,
|
|
3127
|
-
vn as transformToFormFields,
|
|
3128
|
-
En as useFormBuilder
|
|
3129
|
-
};
|