@middag-io/react 0.38.0 → 0.39.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-lib/{FormField-B4_ub94_.js → FormField-CKzrwqSV.js} +94 -20
- package/dist-lib/FormPanelBlock-0knL5-AY.js +1425 -0
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/EditablePanelContext.d.ts +53 -0
- package/dist-lib/base/shell/partials/EditablePanelContext.d.ts.map +1 -0
- package/dist-lib/base/shell/partials/EditablePanelContext.js +19 -0
- package/dist-lib/base/shell/partials/EditablePanelProvider.d.ts +20 -0
- package/dist-lib/base/shell/partials/EditablePanelProvider.d.ts.map +1 -0
- package/dist-lib/base/shell/partials/EditablePanelProvider.js +83 -0
- package/dist-lib/base/shell/partials/InlineEditablePanel.d.ts +13 -0
- package/dist-lib/base/shell/partials/InlineEditablePanel.d.ts.map +1 -0
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +1420 -0
- package/dist-lib/base/shell/partials/PageActionButton.js +0 -1
- package/dist-lib/chunks/subpath--GXsYu-v.js +122 -0
- package/dist-lib/chunks/subpath-55YUOrvG.js +22 -0
- package/dist-lib/chunks/subpath-7b9-j7in.js +68 -0
- package/dist-lib/chunks/subpath-B30yU5uo.js +25 -0
- package/dist-lib/chunks/subpath-BhcZoWUz.js +221 -0
- package/dist-lib/chunks/{subpath-DLFO_UGQ.js → subpath-C0XqfmBB.js} +2 -0
- package/dist-lib/contracts/generated/contract-schema.d.ts +1 -1
- package/dist-lib/contracts/generated/contract-types.d.ts +10 -2
- package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
- package/dist-lib/contracts/generated/index.d.ts +1 -1
- package/dist-lib/i18n/I18nProvider.js +1 -1
- package/dist-lib/i18n/instance.js +1 -1
- package/dist-lib/i18n/locales/en/ui.json +1 -0
- package/dist-lib/i18n/locales/pt-BR/ui.json +1 -0
- package/dist-lib/i18n/register-strings.js +1 -1
- package/dist-lib/index.d.ts +3 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/lib/actions/resolve-action-target.d.ts +5 -2
- package/dist-lib/lib/actions/resolve-action-target.d.ts.map +1 -1
- package/dist-lib/lib/actions/resolve-action-target.js +6 -0
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +7820 -7556
- package/package.json +1 -1
- package/dist-lib/FormPanelBlock-3fH3TyZX.js +0 -1499
|
@@ -1,1499 +0,0 @@
|
|
|
1
|
-
import { $ as e, At as t, Ft as n, G as r, J as i, Lt as a, Mt as o, Nt as s, Ot as c, P as l, Rt as u, X as d, Z as f, a as p, at as m, i as h, it as g, jt as _, kt as v, lt as y, n as b, o as x, ot as S, r as ee, rt as te, t as C, tt as w, zt as T } from "./FormField-B4_ub94_.js";
|
|
2
|
-
import { t as E } from "./button-CxyXN3nw.js";
|
|
3
|
-
import { t as D } from "./useTranslation-D-tjJhTn.js";
|
|
4
|
-
import { t as O } from "./utils-CpaZ5_iF.js";
|
|
5
|
-
import k, { useCallback as A, useEffect as j, useMemo as M, useRef as N, useState as ne } from "react";
|
|
6
|
-
import { Fragment as re, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
7
|
-
import { router as ie } from "@inertiajs/core";
|
|
8
|
-
//#region node_modules/react-hook-form/dist/index.esm.mjs
|
|
9
|
-
var I = (e) => e.type === "checkbox", L = (e) => e instanceof Date, R = (e) => e == null, ae = (e) => typeof e == "object", z = (e) => !R(e) && !Array.isArray(e) && ae(e) && !L(e), oe = (e) => z(e) && e.target ? I(e.target) ? e.target.checked : e.target.value : e, se = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), ce = (e) => {
|
|
10
|
-
let t = e.constructor && e.constructor.prototype;
|
|
11
|
-
return z(t) && t.hasOwnProperty("isPrototypeOf");
|
|
12
|
-
}, le = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
13
|
-
function B(e) {
|
|
14
|
-
if (e instanceof Date) return new Date(e);
|
|
15
|
-
let t = typeof FileList < "u" && e instanceof FileList;
|
|
16
|
-
if (le && (e instanceof Blob || t)) return e;
|
|
17
|
-
let n = Array.isArray(e);
|
|
18
|
-
if (!n && !(z(e) && ce(e))) return e;
|
|
19
|
-
let r = n ? [] : Object.create(Object.getPrototypeOf(e));
|
|
20
|
-
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = B(e[t]));
|
|
21
|
-
return r;
|
|
22
|
-
}
|
|
23
|
-
var V = (e) => /^\w*$/.test(e), H = (e) => e === void 0, ue = (e) => Array.isArray(e) ? e.filter(Boolean) : [], de = (e) => ue(e.replace(/["|']|\]/g, "").split(/\.|\[/)), U = (e, t, n) => {
|
|
24
|
-
if (!t || !z(e)) return n;
|
|
25
|
-
let r = (V(t) ? [t] : de(t)).reduce((e, t) => R(e) ? void 0 : e[t], e);
|
|
26
|
-
return H(r) || r === e ? H(e[t]) ? n : e[t] : r;
|
|
27
|
-
}, W = (e) => typeof e == "boolean", G = (e) => typeof e == "function", K = (e, t, n) => {
|
|
28
|
-
let r = -1, i = V(t) ? [t] : de(t), a = i.length, o = a - 1;
|
|
29
|
-
for (; ++r < a;) {
|
|
30
|
-
let t = i[r], a = n;
|
|
31
|
-
if (r !== o) {
|
|
32
|
-
let n = e[t];
|
|
33
|
-
a = z(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
|
|
34
|
-
}
|
|
35
|
-
if (t === "__proto__" || t === "constructor" || t === "prototype") return;
|
|
36
|
-
e[t] = a, e = e[t];
|
|
37
|
-
}
|
|
38
|
-
}, q = {
|
|
39
|
-
BLUR: "blur",
|
|
40
|
-
FOCUS_OUT: "focusout",
|
|
41
|
-
CHANGE: "change",
|
|
42
|
-
SUBMIT: "submit",
|
|
43
|
-
TRIGGER: "trigger",
|
|
44
|
-
VALID: "valid"
|
|
45
|
-
}, J = {
|
|
46
|
-
onBlur: "onBlur",
|
|
47
|
-
onChange: "onChange",
|
|
48
|
-
onSubmit: "onSubmit",
|
|
49
|
-
onTouched: "onTouched",
|
|
50
|
-
all: "all"
|
|
51
|
-
}, Y = {
|
|
52
|
-
max: "max",
|
|
53
|
-
min: "min",
|
|
54
|
-
maxLength: "maxLength",
|
|
55
|
-
minLength: "minLength",
|
|
56
|
-
pattern: "pattern",
|
|
57
|
-
required: "required",
|
|
58
|
-
validate: "validate"
|
|
59
|
-
}, fe = "form", pe = "root", me = k.createContext(null);
|
|
60
|
-
me.displayName = "HookFormControlContext";
|
|
61
|
-
var he = () => k.useContext(me), ge = (e, t, n, r = !0) => {
|
|
62
|
-
let i = {};
|
|
63
|
-
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
64
|
-
let i = a;
|
|
65
|
-
return t._proxyFormState[i] !== J.all && (t._proxyFormState[i] = !r || J.all), n && (n[i] = !0), e[i];
|
|
66
|
-
} });
|
|
67
|
-
return i;
|
|
68
|
-
}, _e = typeof window < "u" ? k.useLayoutEffect : k.useEffect, X = (e) => typeof e == "string", ve = (e, t, n, r, i) => X(e) ? (r && t.watch.add(e), U(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), U(n, e))) : (r && (t.watchAll = !0), n), ye = (e) => R(e) || !ae(e);
|
|
69
|
-
function Z(e, t, n = /* @__PURE__ */ new WeakSet()) {
|
|
70
|
-
if (e === t) return !0;
|
|
71
|
-
if (ye(e) || ye(t)) return Object.is(e, t);
|
|
72
|
-
if (L(e) && L(t)) return Object.is(e.getTime(), t.getTime());
|
|
73
|
-
let r = Object.keys(e), i = Object.keys(t);
|
|
74
|
-
if (r.length !== i.length) return !1;
|
|
75
|
-
if (n.has(e) || n.has(t)) return !0;
|
|
76
|
-
n.add(e), n.add(t);
|
|
77
|
-
for (let i of r) {
|
|
78
|
-
let r = e[i];
|
|
79
|
-
if (!(i in t)) return !1;
|
|
80
|
-
if (i !== "ref") {
|
|
81
|
-
let e = t[i];
|
|
82
|
-
if (L(r) && L(e) || (z(r) || Array.isArray(r)) && (z(e) || Array.isArray(e)) ? !Z(r, e, n) : !Object.is(r, e)) return !1;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return !0;
|
|
86
|
-
}
|
|
87
|
-
function be(e) {
|
|
88
|
-
let t = he(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = k.useRef(i), l = k.useRef(s), u = k.useRef(void 0), d = k.useRef(n), f = k.useRef(r);
|
|
89
|
-
l.current = s;
|
|
90
|
-
let [p, m] = k.useState(() => {
|
|
91
|
-
let e = n._getWatch(r, c.current);
|
|
92
|
-
return l.current ? l.current(e) : e;
|
|
93
|
-
}), h = k.useCallback((e) => {
|
|
94
|
-
let t = ve(r, n._names, e || n._formValues, !1, c.current);
|
|
95
|
-
return l.current ? l.current(t) : t;
|
|
96
|
-
}, [
|
|
97
|
-
n._formValues,
|
|
98
|
-
n._names,
|
|
99
|
-
r
|
|
100
|
-
]), g = k.useCallback((e) => {
|
|
101
|
-
if (!a) {
|
|
102
|
-
let t = ve(r, n._names, e || n._formValues, !1, c.current);
|
|
103
|
-
if (l.current) {
|
|
104
|
-
let e = l.current(t);
|
|
105
|
-
Z(e, u.current) || (m(e), u.current = e);
|
|
106
|
-
} else m(t);
|
|
107
|
-
}
|
|
108
|
-
}, [
|
|
109
|
-
n._formValues,
|
|
110
|
-
n._names,
|
|
111
|
-
a,
|
|
112
|
-
r
|
|
113
|
-
]);
|
|
114
|
-
_e(() => ((d.current !== n || !Z(f.current, r)) && (d.current = n, f.current = r, g()), n._subscribe({
|
|
115
|
-
name: r,
|
|
116
|
-
formState: { values: !0 },
|
|
117
|
-
exact: o,
|
|
118
|
-
callback: (e) => {
|
|
119
|
-
g(e.values);
|
|
120
|
-
}
|
|
121
|
-
})), [
|
|
122
|
-
n,
|
|
123
|
-
o,
|
|
124
|
-
r,
|
|
125
|
-
g
|
|
126
|
-
]), k.useEffect(() => n._removeUnmounted());
|
|
127
|
-
let _ = d.current !== n, v = f.current, y = k.useMemo(() => {
|
|
128
|
-
if (a) return null;
|
|
129
|
-
let e = !_ && !Z(v, r);
|
|
130
|
-
return _ || e ? h() : null;
|
|
131
|
-
}, [
|
|
132
|
-
a,
|
|
133
|
-
_,
|
|
134
|
-
r,
|
|
135
|
-
v,
|
|
136
|
-
h
|
|
137
|
-
]);
|
|
138
|
-
return y === null ? p : y;
|
|
139
|
-
}
|
|
140
|
-
var xe = k.createContext(null);
|
|
141
|
-
xe.displayName = "HookFormContext";
|
|
142
|
-
var Se = (e, t, n, r, i) => t ? {
|
|
143
|
-
...n[e],
|
|
144
|
-
types: {
|
|
145
|
-
...n[e] && n[e].types ? n[e].types : {},
|
|
146
|
-
[r]: i || !0
|
|
147
|
-
}
|
|
148
|
-
} : {}, Ce = (e) => Array.isArray(e) ? e : [e], we = () => {
|
|
149
|
-
let e = [];
|
|
150
|
-
return {
|
|
151
|
-
get observers() {
|
|
152
|
-
return e;
|
|
153
|
-
},
|
|
154
|
-
next: (t) => {
|
|
155
|
-
for (let n of e) n.next && n.next(t);
|
|
156
|
-
},
|
|
157
|
-
subscribe: (t) => (e.push(t), { unsubscribe: () => {
|
|
158
|
-
e = e.filter((e) => e !== t);
|
|
159
|
-
} }),
|
|
160
|
-
unsubscribe: () => {
|
|
161
|
-
e = [];
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
function Te(e, t) {
|
|
166
|
-
let n = {};
|
|
167
|
-
for (let r in e) if (e.hasOwnProperty(r)) {
|
|
168
|
-
let i = e[r], a = t[r];
|
|
169
|
-
if (i && z(i) && a) {
|
|
170
|
-
let e = Te(i, a);
|
|
171
|
-
z(e) && (n[r] = e);
|
|
172
|
-
} else e[r] && (n[r] = a);
|
|
173
|
-
}
|
|
174
|
-
return n;
|
|
175
|
-
}
|
|
176
|
-
var Q = (e) => z(e) && !Object.keys(e).length, Ee = (e) => e.type === "file", De = (e) => {
|
|
177
|
-
if (!le) return !1;
|
|
178
|
-
let t = e ? e.ownerDocument : 0;
|
|
179
|
-
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
180
|
-
}, Oe = (e) => e.type === "select-multiple", ke = (e) => e.type === "radio", Ae = (e) => ke(e) || I(e), je = (e) => De(e) && e.isConnected;
|
|
181
|
-
function Me(e, t) {
|
|
182
|
-
let n = t.slice(0, -1).length, r = 0;
|
|
183
|
-
for (; r < n;) {
|
|
184
|
-
if (R(e)) {
|
|
185
|
-
e = void 0;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
e = e[t[r]], r++;
|
|
189
|
-
}
|
|
190
|
-
return e;
|
|
191
|
-
}
|
|
192
|
-
function Ne(e) {
|
|
193
|
-
for (let t in e) if (e.hasOwnProperty(t) && !H(e[t])) return !1;
|
|
194
|
-
return !0;
|
|
195
|
-
}
|
|
196
|
-
function $(e, t) {
|
|
197
|
-
if (X(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
|
|
198
|
-
let n = Array.isArray(t) ? t : V(t) ? [t] : de(t), r = n.length === 1 ? e : Me(e, n), i = n.length - 1, a = n[i];
|
|
199
|
-
return r && delete r[a], i !== 0 && (z(r) && Q(r) || Array.isArray(r) && Ne(r)) && $(e, n.slice(0, -1)), e;
|
|
200
|
-
}
|
|
201
|
-
var Pe = (e) => {
|
|
202
|
-
for (let t in e) if (G(e[t])) return !0;
|
|
203
|
-
return !1;
|
|
204
|
-
};
|
|
205
|
-
function Fe(e) {
|
|
206
|
-
return Array.isArray(e) || z(e) && !Pe(e);
|
|
207
|
-
}
|
|
208
|
-
function Ie(e, t = {}) {
|
|
209
|
-
for (let n in e) {
|
|
210
|
-
let r = e[n];
|
|
211
|
-
Fe(r) ? (t[n] = Array.isArray(r) ? [] : {}, Ie(r, t[n])) : H(r) || (t[n] = !0);
|
|
212
|
-
}
|
|
213
|
-
return t;
|
|
214
|
-
}
|
|
215
|
-
function Le(e) {
|
|
216
|
-
if (e !== !1) {
|
|
217
|
-
if (e === !0) return !0;
|
|
218
|
-
if (Array.isArray(e)) {
|
|
219
|
-
let t = e.map((e) => Le(e));
|
|
220
|
-
return t.some((e) => e !== void 0) ? t : void 0;
|
|
221
|
-
}
|
|
222
|
-
if (z(e)) {
|
|
223
|
-
let t = {};
|
|
224
|
-
for (let n in e) {
|
|
225
|
-
let r = Le(e[n]);
|
|
226
|
-
H(r) || (t[n] = r);
|
|
227
|
-
}
|
|
228
|
-
return Object.keys(t).length ? t : void 0;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function Re(e, t, n) {
|
|
233
|
-
n ||= Ie(t);
|
|
234
|
-
for (let r in e) {
|
|
235
|
-
let i = e[r];
|
|
236
|
-
if (Fe(i)) H(t) || ye(n[r]) ? n[r] = Ie(i, Array.isArray(i) ? [] : {}) : Re(i, R(t) ? {} : t[r], n[r]);
|
|
237
|
-
else {
|
|
238
|
-
let e = t[r];
|
|
239
|
-
n[r] = !Z(i, e);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return Le(n) || {};
|
|
243
|
-
}
|
|
244
|
-
var ze = {
|
|
245
|
-
value: !1,
|
|
246
|
-
isValid: !1
|
|
247
|
-
}, Be = {
|
|
248
|
-
value: !0,
|
|
249
|
-
isValid: !0
|
|
250
|
-
}, Ve = (e) => {
|
|
251
|
-
if (Array.isArray(e)) {
|
|
252
|
-
if (e.length > 1) {
|
|
253
|
-
let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
254
|
-
return {
|
|
255
|
-
value: t,
|
|
256
|
-
isValid: !!t.length
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
return e[0].checked && !e[0].disabled ? e[0].attributes && !H(e[0].attributes.value) ? H(e[0].value) || e[0].value === "" ? Be : {
|
|
260
|
-
value: e[0].value,
|
|
261
|
-
isValid: !0
|
|
262
|
-
} : Be : ze;
|
|
263
|
-
}
|
|
264
|
-
return ze;
|
|
265
|
-
}, He = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => H(e) ? e : t ? e === "" ? NaN : e && +e : n && X(e) ? new Date(e) : r ? r(e) : e, Ue = {
|
|
266
|
-
isValid: !1,
|
|
267
|
-
value: null
|
|
268
|
-
}, We = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
|
|
269
|
-
isValid: !0,
|
|
270
|
-
value: t.value
|
|
271
|
-
} : e, Ue) : Ue;
|
|
272
|
-
function Ge(e) {
|
|
273
|
-
let t = e.ref;
|
|
274
|
-
return Ee(t) ? t.files : ke(t) ? We(e.refs).value : Oe(t) ? [...t.selectedOptions].map(({ value: e }) => e) : I(t) ? Ve(e.refs).value : He(H(t.value) ? e.ref.value : t.value, e);
|
|
275
|
-
}
|
|
276
|
-
var Ke = (e, t, n, r) => {
|
|
277
|
-
let i = {};
|
|
278
|
-
for (let n of e) {
|
|
279
|
-
let e = U(t, n);
|
|
280
|
-
e && K(i, n, e._f);
|
|
281
|
-
}
|
|
282
|
-
return {
|
|
283
|
-
criteriaMode: n,
|
|
284
|
-
names: [...e],
|
|
285
|
-
fields: i,
|
|
286
|
-
shouldUseNativeValidation: r
|
|
287
|
-
};
|
|
288
|
-
}, qe = (e) => e instanceof RegExp, Je = (e) => H(e) ? e : qe(e) ? e.source : z(e) ? qe(e.value) ? e.value.source : e.value : e, Ye = (e) => ({
|
|
289
|
-
isOnSubmit: !e || e === J.onSubmit,
|
|
290
|
-
isOnBlur: e === J.onBlur,
|
|
291
|
-
isOnChange: e === J.onChange,
|
|
292
|
-
isOnAll: e === J.all,
|
|
293
|
-
isOnTouch: e === J.onTouched
|
|
294
|
-
}), Xe = "AsyncFunction", Ze = (e) => !!e && !!e.validate && !!(G(e.validate) && e.validate.constructor.name === Xe || z(e.validate) && Object.values(e.validate).find((e) => e.constructor.name === Xe)), Qe = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), $e = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(t) && /^\.\w+/.test(e.slice(t.length)))), et = (e, t, n, r) => {
|
|
295
|
-
for (let i of n || Object.keys(e)) {
|
|
296
|
-
let n = U(e, i);
|
|
297
|
-
if (n) {
|
|
298
|
-
let { _f: e, ...a } = n;
|
|
299
|
-
if (e) {
|
|
300
|
-
if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
|
|
301
|
-
if (et(a, t)) break;
|
|
302
|
-
} else if (z(a) && et(a, t)) break;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
function tt(e, t, n) {
|
|
307
|
-
let r = U(e, n);
|
|
308
|
-
if (r || V(n)) return {
|
|
309
|
-
error: r,
|
|
310
|
-
name: n
|
|
311
|
-
};
|
|
312
|
-
let i = n.split(".");
|
|
313
|
-
for (; i.length;) {
|
|
314
|
-
let r = i.join("."), a = U(t, r), o = U(e, r);
|
|
315
|
-
if (a && !Array.isArray(a) && n !== r) return { name: n };
|
|
316
|
-
if (o && o.type) return {
|
|
317
|
-
name: r,
|
|
318
|
-
error: o
|
|
319
|
-
};
|
|
320
|
-
if (o && o.root && o.root.type) return {
|
|
321
|
-
name: `${r}.root`,
|
|
322
|
-
error: o.root
|
|
323
|
-
};
|
|
324
|
-
i.pop();
|
|
325
|
-
}
|
|
326
|
-
return { name: n };
|
|
327
|
-
}
|
|
328
|
-
var nt = (e, t, n, r) => {
|
|
329
|
-
n(e);
|
|
330
|
-
let { name: i, ...a } = e;
|
|
331
|
-
return Q(a) || r && Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((e) => t[e] === (!r || J.all));
|
|
332
|
-
}, rt = (e, t, n) => !e || !t || e === t || Ce(e).some((e) => e && (n ? e === t : e.startsWith(t) || t.startsWith(e))), it = (e, t, n, r, i) => i.isOnAll ? !1 : !n && i.isOnTouch ? !(t || e) : (n ? r.isOnBlur : i.isOnBlur) ? !e : (n ? r.isOnChange : i.isOnChange) ? e : !0, at = (e, t) => !ue(U(e, t)).length && $(e, t), ot = (e, t, n) => {
|
|
333
|
-
let r = Ce(U(e, n));
|
|
334
|
-
return K(r, pe, t[n]), K(e, n, r), e;
|
|
335
|
-
};
|
|
336
|
-
function st(e, t, n = "validate") {
|
|
337
|
-
if (X(e) || Array.isArray(e) && e.every(X) || W(e) && !e) return {
|
|
338
|
-
type: n,
|
|
339
|
-
message: X(e) ? e : "",
|
|
340
|
-
ref: t
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
var ct = (e) => z(e) && !qe(e) ? e : {
|
|
344
|
-
value: e,
|
|
345
|
-
message: ""
|
|
346
|
-
}, lt = async (e, t, n, r, i, a) => {
|
|
347
|
-
let { ref: o, refs: s, required: c, maxLength: l, minLength: u, min: d, max: f, pattern: p, validate: m, name: h, valueAsNumber: g, mount: _ } = e._f, v = U(n, h);
|
|
348
|
-
if (!_ || t.has(h)) return {};
|
|
349
|
-
let y = s ? s[0] : o, b = (e) => {
|
|
350
|
-
i && y.reportValidity && (y.setCustomValidity(W(e) ? "" : e || ""), y.reportValidity());
|
|
351
|
-
}, x = {}, S = ke(o), ee = I(o), te = S || ee, C = (g || Ee(o)) && H(o.value) && H(v) || De(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), w = Se.bind(null, h, r, x), T = (e, t, n, r = Y.maxLength, i = Y.minLength) => {
|
|
352
|
-
let a = e ? t : n;
|
|
353
|
-
x[h] = {
|
|
354
|
-
type: e ? r : i,
|
|
355
|
-
message: a,
|
|
356
|
-
ref: o,
|
|
357
|
-
...w(e ? r : i, a)
|
|
358
|
-
};
|
|
359
|
-
};
|
|
360
|
-
if (a ? !Array.isArray(v) || !v.length : c && (!te && (C || R(v)) || W(v) && !v || ee && !Ve(s).isValid || S && !We(s).isValid)) {
|
|
361
|
-
let { value: e, message: t } = X(c) ? {
|
|
362
|
-
value: !!c,
|
|
363
|
-
message: c
|
|
364
|
-
} : ct(c);
|
|
365
|
-
if (e && (x[h] = {
|
|
366
|
-
type: Y.required,
|
|
367
|
-
message: t,
|
|
368
|
-
ref: y,
|
|
369
|
-
...w(Y.required, t)
|
|
370
|
-
}, !r)) return b(t), x;
|
|
371
|
-
}
|
|
372
|
-
if (!C && (!R(d) || !R(f))) {
|
|
373
|
-
let e, t, n = ct(f), i = ct(d);
|
|
374
|
-
if (!R(v) && !isNaN(v)) {
|
|
375
|
-
let r = o.valueAsNumber || v && +v;
|
|
376
|
-
R(n.value) || (e = r > n.value), R(i.value) || (t = r < i.value);
|
|
377
|
-
} else {
|
|
378
|
-
let r = o.valueAsDate || new Date(v), a = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), s = o.type == "time", c = o.type == "week";
|
|
379
|
-
X(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), X(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
|
|
380
|
-
}
|
|
381
|
-
if ((e || t) && (T(!!e, n.message, i.message, Y.max, Y.min), !r)) return b(x[h].message), x;
|
|
382
|
-
}
|
|
383
|
-
if ((l || u) && !C && (X(v) || a && Array.isArray(v))) {
|
|
384
|
-
let e = ct(l), t = ct(u), n = !R(e.value) && v.length > +e.value, i = !R(t.value) && v.length < +t.value;
|
|
385
|
-
if ((n || i) && (T(n, e.message, t.message), !r)) return b(x[h].message), x;
|
|
386
|
-
}
|
|
387
|
-
if (p && !C && X(v)) {
|
|
388
|
-
let { value: e, message: t } = ct(p);
|
|
389
|
-
if (qe(e) && !v.match(e) && (x[h] = {
|
|
390
|
-
type: Y.pattern,
|
|
391
|
-
message: t,
|
|
392
|
-
ref: o,
|
|
393
|
-
...w(Y.pattern, t)
|
|
394
|
-
}, !r)) return b(t), x;
|
|
395
|
-
}
|
|
396
|
-
if (m) {
|
|
397
|
-
if (G(m)) {
|
|
398
|
-
let e = st(await m(v, n), y);
|
|
399
|
-
if (e && (x[h] = {
|
|
400
|
-
...e,
|
|
401
|
-
...w(Y.validate, e.message)
|
|
402
|
-
}, !r)) return b(e.message), x;
|
|
403
|
-
} else if (z(m)) {
|
|
404
|
-
let e = {};
|
|
405
|
-
for (let t in m) {
|
|
406
|
-
if (!Q(e) && !r) break;
|
|
407
|
-
let i = st(await m[t](v, n), y, t);
|
|
408
|
-
i && (e = {
|
|
409
|
-
...i,
|
|
410
|
-
...w(t, i.message)
|
|
411
|
-
}, b(i.message), r && (x[h] = e));
|
|
412
|
-
}
|
|
413
|
-
if (!Q(e) && (x[h] = {
|
|
414
|
-
ref: y,
|
|
415
|
-
...e
|
|
416
|
-
}, !r)) return x;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return b(!0), x;
|
|
420
|
-
}, ut = {
|
|
421
|
-
mode: J.onSubmit,
|
|
422
|
-
reValidateMode: J.onChange,
|
|
423
|
-
shouldFocusError: !0
|
|
424
|
-
}, dt = {
|
|
425
|
-
submitCount: 0,
|
|
426
|
-
isDirty: !1,
|
|
427
|
-
isReady: !1,
|
|
428
|
-
isValidating: !1,
|
|
429
|
-
isSubmitted: !1,
|
|
430
|
-
isSubmitting: !1,
|
|
431
|
-
isSubmitSuccessful: !1,
|
|
432
|
-
isValid: !1,
|
|
433
|
-
touchedFields: {},
|
|
434
|
-
dirtyFields: {},
|
|
435
|
-
validatingFields: {}
|
|
436
|
-
};
|
|
437
|
-
function ft(e = {}) {
|
|
438
|
-
let t = {
|
|
439
|
-
...ut,
|
|
440
|
-
...e
|
|
441
|
-
}, n = {
|
|
442
|
-
...B(dt),
|
|
443
|
-
isLoading: G(t.defaultValues),
|
|
444
|
-
errors: t.errors || {},
|
|
445
|
-
disabled: t.disabled || !1
|
|
446
|
-
}, r = {}, i = (z(t.defaultValues) || z(t.values)) && B(t.defaultValues || t.values) || {}, a = t.shouldUnregister ? {} : B(i), o = {
|
|
447
|
-
action: !1,
|
|
448
|
-
mount: !1,
|
|
449
|
-
watch: !1,
|
|
450
|
-
keepIsValid: !1
|
|
451
|
-
}, s = {
|
|
452
|
-
mount: /* @__PURE__ */ new Set(),
|
|
453
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
454
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
455
|
-
array: /* @__PURE__ */ new Set(),
|
|
456
|
-
watch: /* @__PURE__ */ new Set(),
|
|
457
|
-
registerName: /* @__PURE__ */ new Set()
|
|
458
|
-
}, c, l = 0, u = {
|
|
459
|
-
isDirty: !1,
|
|
460
|
-
dirtyFields: !1,
|
|
461
|
-
validatingFields: !1,
|
|
462
|
-
touchedFields: !1,
|
|
463
|
-
isValidating: !1,
|
|
464
|
-
isValid: !1,
|
|
465
|
-
errors: !1
|
|
466
|
-
}, d = { ...u }, f = { ...d }, p = {
|
|
467
|
-
array: we(),
|
|
468
|
-
state: we()
|
|
469
|
-
}, m = t.criteriaMode === J.all, h = (e) => (t) => {
|
|
470
|
-
clearTimeout(l), l = setTimeout(e, t);
|
|
471
|
-
}, g = async (e) => {
|
|
472
|
-
if (!o.keepIsValid && !t.disabled && (d.isValid || f.isValid || e)) {
|
|
473
|
-
let e;
|
|
474
|
-
t.resolver ? (e = Q((await C()).errors), _()) : e = await E({
|
|
475
|
-
fields: r,
|
|
476
|
-
onlyCheckValid: !0,
|
|
477
|
-
eventType: q.VALID
|
|
478
|
-
}), e !== n.isValid && p.state.next({ isValid: e });
|
|
479
|
-
}
|
|
480
|
-
}, _ = (e, r) => {
|
|
481
|
-
!t.disabled && (d.isValidating || d.validatingFields || f.isValidating || f.validatingFields) && ((e || Array.from(s.mount)).forEach((e) => {
|
|
482
|
-
e && (r ? K(n.validatingFields, e, r) : $(n.validatingFields, e));
|
|
483
|
-
}), p.state.next({
|
|
484
|
-
validatingFields: n.validatingFields,
|
|
485
|
-
isValidating: !Q(n.validatingFields)
|
|
486
|
-
}));
|
|
487
|
-
}, v = () => {
|
|
488
|
-
n.dirtyFields = Re(i, a);
|
|
489
|
-
}, y = (e, i = [], s, c, l = !0, u = !0) => {
|
|
490
|
-
if (c && s && !t.disabled) {
|
|
491
|
-
if (o.action = !0, u && Array.isArray(U(r, e))) {
|
|
492
|
-
let t = s(U(r, e), c.argA, c.argB);
|
|
493
|
-
l && K(r, e, t);
|
|
494
|
-
}
|
|
495
|
-
if (u && Array.isArray(U(n.errors, e))) {
|
|
496
|
-
let t = s(U(n.errors, e), c.argA, c.argB);
|
|
497
|
-
l && K(n.errors, e, t), at(n.errors, e);
|
|
498
|
-
}
|
|
499
|
-
if ((d.touchedFields || f.touchedFields) && u && Array.isArray(U(n.touchedFields, e))) {
|
|
500
|
-
let t = s(U(n.touchedFields, e), c.argA, c.argB);
|
|
501
|
-
l && K(n.touchedFields, e, t);
|
|
502
|
-
}
|
|
503
|
-
(d.dirtyFields || f.dirtyFields) && v(), p.state.next({
|
|
504
|
-
name: e,
|
|
505
|
-
isDirty: O(e, i),
|
|
506
|
-
dirtyFields: n.dirtyFields,
|
|
507
|
-
errors: n.errors,
|
|
508
|
-
isValid: n.isValid
|
|
509
|
-
});
|
|
510
|
-
} else K(a, e, i);
|
|
511
|
-
}, b = (e, t) => {
|
|
512
|
-
K(n.errors, e, t), p.state.next({ errors: n.errors });
|
|
513
|
-
}, x = (e) => {
|
|
514
|
-
n.errors = e, p.state.next({
|
|
515
|
-
errors: n.errors,
|
|
516
|
-
isValid: !1
|
|
517
|
-
});
|
|
518
|
-
}, S = (e, t, s, c) => {
|
|
519
|
-
let l = U(r, e);
|
|
520
|
-
if (l) {
|
|
521
|
-
let r = H(U(a, e)), u = U(a, e, H(s) ? U(i, e) : s);
|
|
522
|
-
H(u) || c && c.defaultChecked || t ? K(a, e, t ? u : Ge(l._f)) : j(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (O() || (n.isDirty = !1, p.state.next({ ...n }))));
|
|
523
|
-
}
|
|
524
|
-
}, ee = (e, r, a, o, s) => {
|
|
525
|
-
let c = !1, l = !1, u = { name: e };
|
|
526
|
-
if (!t.disabled) {
|
|
527
|
-
if (!a || o) {
|
|
528
|
-
(d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = O(), c = l !== u.isDirty);
|
|
529
|
-
let t = Z(U(i, e), r);
|
|
530
|
-
l = !!U(n.dirtyFields, e), t ? $(n.dirtyFields, e) : K(n.dirtyFields, e, !0), u.dirtyFields = n.dirtyFields, c ||= (d.dirtyFields || f.dirtyFields) && l !== !t;
|
|
531
|
-
}
|
|
532
|
-
if (a) {
|
|
533
|
-
let t = U(n.touchedFields, e);
|
|
534
|
-
t || (K(n.touchedFields, e, a), u.touchedFields = n.touchedFields, c ||= (d.touchedFields || f.touchedFields) && t !== a);
|
|
535
|
-
}
|
|
536
|
-
c && s && p.state.next(u);
|
|
537
|
-
}
|
|
538
|
-
return c ? u : {};
|
|
539
|
-
}, te = (e, r, i, a) => {
|
|
540
|
-
let o = U(n.errors, e), s = (d.isValid || f.isValid) && W(r) && n.isValid !== r;
|
|
541
|
-
if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? K(n.errors, e, i) : $(n.errors, e)), (i ? !Z(o, i) : o) || !Q(a) || s) {
|
|
542
|
-
let t = {
|
|
543
|
-
...a,
|
|
544
|
-
...s && W(r) ? { isValid: r } : {},
|
|
545
|
-
errors: n.errors,
|
|
546
|
-
name: e
|
|
547
|
-
};
|
|
548
|
-
n = {
|
|
549
|
-
...n,
|
|
550
|
-
...t
|
|
551
|
-
}, p.state.next(t);
|
|
552
|
-
}
|
|
553
|
-
}, C = async (e) => (_(e, !0), await t.resolver(a, t.context, Ke(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), w = async (e) => {
|
|
554
|
-
let { errors: t } = await C(e);
|
|
555
|
-
if (_(e), e) for (let r of e) {
|
|
556
|
-
let e = U(t, r);
|
|
557
|
-
e ? K(n.errors, r, e) : $(n.errors, r);
|
|
558
|
-
}
|
|
559
|
-
else n.errors = t;
|
|
560
|
-
return t;
|
|
561
|
-
}, T = async ({ name: t, eventType: r }) => {
|
|
562
|
-
if (e.validate) {
|
|
563
|
-
let i = await e.validate({
|
|
564
|
-
formValues: a,
|
|
565
|
-
formState: n,
|
|
566
|
-
name: t,
|
|
567
|
-
eventType: r
|
|
568
|
-
});
|
|
569
|
-
if (z(i)) for (let e in i) i[e] && V(`${fe}.${e}`, {
|
|
570
|
-
message: X(i.message) ? i.message : "",
|
|
571
|
-
type: Y.validate
|
|
572
|
-
});
|
|
573
|
-
else X(i) || !i ? V(fe, {
|
|
574
|
-
message: i || "",
|
|
575
|
-
type: Y.validate
|
|
576
|
-
}) : ce(fe);
|
|
577
|
-
return i;
|
|
578
|
-
}
|
|
579
|
-
return !0;
|
|
580
|
-
}, E = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
|
|
581
|
-
valid: !0,
|
|
582
|
-
runRootValidation: !1
|
|
583
|
-
} }) => {
|
|
584
|
-
if (e.validate && (l.runRootValidation = !0, !await T({
|
|
585
|
-
name: o,
|
|
586
|
-
eventType: c
|
|
587
|
-
}) && (l.valid = !1, i))) return l.valid;
|
|
588
|
-
for (let o in r) {
|
|
589
|
-
let u = r[o];
|
|
590
|
-
if (u) {
|
|
591
|
-
let { _f: r, ...f } = u;
|
|
592
|
-
if (r) {
|
|
593
|
-
let o = s.array.has(r.name), c = u._f && Ze(u._f);
|
|
594
|
-
c && d.validatingFields && _([r.name], !0);
|
|
595
|
-
let f = await lt(u, s.disabled, a, m, t.shouldUseNativeValidation && !i, o);
|
|
596
|
-
if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (U(f, r.name) ? o ? ot(n.errors, f, r.name) : K(n.errors, r.name, f[r.name]) : $(n.errors, r.name)), e.shouldUseNativeValidation && f[r.name])) break;
|
|
597
|
-
}
|
|
598
|
-
!Q(f) && await E({
|
|
599
|
-
context: l,
|
|
600
|
-
onlyCheckValid: i,
|
|
601
|
-
fields: f,
|
|
602
|
-
name: o,
|
|
603
|
-
eventType: c
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
return l.valid;
|
|
608
|
-
}, D = () => {
|
|
609
|
-
for (let e of s.unMount) {
|
|
610
|
-
let t = U(r, e);
|
|
611
|
-
t && (t._f.refs ? t._f.refs.every((e) => !je(e)) : !je(t._f.ref)) && ge(e);
|
|
612
|
-
}
|
|
613
|
-
s.unMount = /* @__PURE__ */ new Set();
|
|
614
|
-
}, O = (e, n) => !t.disabled && (e && n && K(a, e, n), !Z(ie(), i)), k = (e, t, n) => ve(e, s, { ...o.mount ? a : H(t) ? i : X(e) ? { [e]: t } : t }, n, t), A = (e) => ue(U(o.mount ? a : i, e, t.shouldUnregister ? U(i, e, []) : [])), j = (e, t, n = {}) => {
|
|
615
|
-
let i = U(r, e), o = t;
|
|
616
|
-
if (i) {
|
|
617
|
-
let n = i._f;
|
|
618
|
-
n && (!n.disabled && K(a, e, He(t, n)), o = De(n.ref) && R(t) ? "" : t, Oe(n.ref) ? [...n.ref.options].forEach((e) => e.selected = o.includes(e.value)) : n.refs ? I(n.ref) ? n.refs.forEach((e) => {
|
|
619
|
-
(!e.defaultChecked || !e.disabled) && (Array.isArray(o) ? e.checked = !!o.find((t) => t === e.value) : e.checked = o === e.value || !!o);
|
|
620
|
-
}) : n.refs.forEach((e) => e.checked = e.value === o) : Ee(n.ref) ? n.ref.value = "" : (n.ref.value = o, n.ref.type || p.state.next({
|
|
621
|
-
name: e,
|
|
622
|
-
values: B(a)
|
|
623
|
-
})));
|
|
624
|
-
}
|
|
625
|
-
(n.shouldDirty || n.shouldTouch) && ee(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && F(e);
|
|
626
|
-
}, M = (e, t, n) => {
|
|
627
|
-
for (let i in t) {
|
|
628
|
-
if (!t.hasOwnProperty(i)) return;
|
|
629
|
-
let a = t[i], o = e + "." + i, c = U(r, o);
|
|
630
|
-
(s.array.has(e) || z(a) || c && !c._f) && !L(a) ? M(o, a, n) : j(o, a, n);
|
|
631
|
-
}
|
|
632
|
-
}, N = (e, t, i = {}) => {
|
|
633
|
-
let c = U(r, e), l = s.array.has(e), u = B(t), m = Z(U(a, e), u);
|
|
634
|
-
if (K(a, e, u), l) p.array.next({
|
|
635
|
-
name: e,
|
|
636
|
-
values: B(a)
|
|
637
|
-
}), (d.isDirty || d.dirtyFields || f.isDirty || f.dirtyFields) && i.shouldDirty && (v(), p.state.next({
|
|
638
|
-
name: e,
|
|
639
|
-
dirtyFields: n.dirtyFields,
|
|
640
|
-
isDirty: O(e, u)
|
|
641
|
-
}));
|
|
642
|
-
else {
|
|
643
|
-
let t = Array.isArray(u) && !u.length || Q(u);
|
|
644
|
-
!c || c._f || R(u) || t ? j(e, u, i) : M(e, u, i);
|
|
645
|
-
}
|
|
646
|
-
if (!m) {
|
|
647
|
-
let t = $e(e, s);
|
|
648
|
-
p.state.next({
|
|
649
|
-
...t && n,
|
|
650
|
-
name: o.mount || t ? e : void 0,
|
|
651
|
-
values: B(a)
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
}, ne = (e) => {
|
|
655
|
-
let t = G(e) ? e(a) : e;
|
|
656
|
-
Z(a, t) || (a = {
|
|
657
|
-
...a,
|
|
658
|
-
...t
|
|
659
|
-
}, p.state.next({
|
|
660
|
-
...n,
|
|
661
|
-
values: a
|
|
662
|
-
}));
|
|
663
|
-
}, re = async (i) => {
|
|
664
|
-
o.mount = !0;
|
|
665
|
-
let l = i.target, u = l.name, h = !0, v = U(r, u), y = (e) => {
|
|
666
|
-
h = Number.isNaN(e) || L(e) && isNaN(e.getTime()) || Z(e, U(a, u, e));
|
|
667
|
-
}, b = Ye(t.mode), x = Ye(t.reValidateMode);
|
|
668
|
-
if (v) {
|
|
669
|
-
let o, S, w = l.type ? Ge(v._f) : oe(i), D = i.type === q.BLUR || i.type === q.FOCUS_OUT, O = !Qe(v._f) && !e.validate && !t.resolver && !U(n.errors, u) && !v._f.deps || it(D, U(n.touchedFields, u), n.isSubmitted, x, b), k = $e(u, s, D);
|
|
670
|
-
K(a, u, w), D ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
|
|
671
|
-
let A = ee(u, w, D), j = !Q(A) || k;
|
|
672
|
-
if (!D && p.state.next({
|
|
673
|
-
name: u,
|
|
674
|
-
type: i.type,
|
|
675
|
-
values: B(a)
|
|
676
|
-
}), O) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? D && g() : D || g()), j && p.state.next({
|
|
677
|
-
name: u,
|
|
678
|
-
...k ? {} : A
|
|
679
|
-
});
|
|
680
|
-
if (!t.resolver && e.validate && await T({
|
|
681
|
-
name: u,
|
|
682
|
-
eventType: i.type
|
|
683
|
-
}), !D && k && p.state.next({ ...n }), t.resolver) {
|
|
684
|
-
let { errors: e } = await C([u]);
|
|
685
|
-
if (_([u]), y(w), h) {
|
|
686
|
-
let t = tt(n.errors, r, u), i = tt(e, r, t.name || u);
|
|
687
|
-
o = i.error, u = i.name, S = Q(e);
|
|
688
|
-
}
|
|
689
|
-
} else _([u], !0), o = (await lt(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(w), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await E({
|
|
690
|
-
fields: r,
|
|
691
|
-
onlyCheckValid: !0,
|
|
692
|
-
name: u,
|
|
693
|
-
eventType: i.type
|
|
694
|
-
})));
|
|
695
|
-
h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && F(v._f.deps), te(u, S, o, A));
|
|
696
|
-
}
|
|
697
|
-
}, P = (e, t) => {
|
|
698
|
-
if (U(n.errors, t) && e.focus) return e.focus(), 1;
|
|
699
|
-
}, F = async (e, i = {}) => {
|
|
700
|
-
let a, o, c = Ce(e);
|
|
701
|
-
if (t.resolver) {
|
|
702
|
-
let t = await w(H(e) ? e : c);
|
|
703
|
-
a = Q(t), o = e ? !c.some((e) => U(t, e)) : a;
|
|
704
|
-
} else e ? (o = (await Promise.all(c.map(async (e) => {
|
|
705
|
-
let t = U(r, e);
|
|
706
|
-
return await E({
|
|
707
|
-
fields: t && t._f ? { [e]: t } : t,
|
|
708
|
-
eventType: q.TRIGGER
|
|
709
|
-
});
|
|
710
|
-
}))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await E({
|
|
711
|
-
fields: r,
|
|
712
|
-
name: e,
|
|
713
|
-
eventType: q.TRIGGER
|
|
714
|
-
});
|
|
715
|
-
return p.state.next({
|
|
716
|
-
...!X(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
|
|
717
|
-
...t.resolver || !e ? { isValid: a } : {},
|
|
718
|
-
errors: n.errors
|
|
719
|
-
}), i.shouldFocus && !o && et(r, P, e ? c : s.mount), o;
|
|
720
|
-
}, ie = (e, t) => {
|
|
721
|
-
let r = { ...o.mount ? a : i };
|
|
722
|
-
return t && (r = Te(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), H(e) ? r : X(e) ? U(r, e) : e.map((e) => U(r, e));
|
|
723
|
-
}, ae = (e, t) => ({
|
|
724
|
-
invalid: !!U((t || n).errors, e),
|
|
725
|
-
isDirty: !!U((t || n).dirtyFields, e),
|
|
726
|
-
error: U((t || n).errors, e),
|
|
727
|
-
isValidating: !!U(n.validatingFields, e),
|
|
728
|
-
isTouched: !!U((t || n).touchedFields, e)
|
|
729
|
-
}), ce = (e) => {
|
|
730
|
-
let t = e ? Ce(e) : void 0;
|
|
731
|
-
t?.forEach((e) => $(n.errors, e)), t ? t.forEach((e) => {
|
|
732
|
-
p.state.next({
|
|
733
|
-
name: e,
|
|
734
|
-
errors: n.errors
|
|
735
|
-
});
|
|
736
|
-
}) : p.state.next({ errors: {} });
|
|
737
|
-
}, V = (e, t, i) => {
|
|
738
|
-
let a = (U(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = U(n.errors, e) || {};
|
|
739
|
-
K(n.errors, e, {
|
|
740
|
-
...l,
|
|
741
|
-
...t,
|
|
742
|
-
ref: a
|
|
743
|
-
}), p.state.next({
|
|
744
|
-
name: e,
|
|
745
|
-
errors: n.errors,
|
|
746
|
-
isValid: !1
|
|
747
|
-
}), i && i.shouldFocus && a && a.focus && a.focus();
|
|
748
|
-
}, de = (e, t) => G(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || k(void 0, t), n) }) : k(e, t, !0), me = (e) => p.state.subscribe({ next: (t) => {
|
|
749
|
-
if (rt(e.name, t.name, e.exact) && nt(t, e.formState || d, Fe, e.reRenderRoot)) {
|
|
750
|
-
let r = { ...a };
|
|
751
|
-
e.callback({
|
|
752
|
-
values: r,
|
|
753
|
-
...n,
|
|
754
|
-
...t,
|
|
755
|
-
defaultValues: i
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
} }).unsubscribe, he = (e) => (o.mount = !0, f = {
|
|
759
|
-
...f,
|
|
760
|
-
...e.formState
|
|
761
|
-
}, me({
|
|
762
|
-
...e,
|
|
763
|
-
formState: {
|
|
764
|
-
...u,
|
|
765
|
-
...e.formState
|
|
766
|
-
}
|
|
767
|
-
})), ge = (e, o = {}) => {
|
|
768
|
-
for (let c of e ? Ce(e) : s.mount) s.mount.delete(c), s.array.delete(c), o.keepValue || ($(r, c), $(a, c)), !o.keepError && $(n.errors, c), !o.keepDirty && $(n.dirtyFields, c), !o.keepTouched && $(n.touchedFields, c), !o.keepIsValidating && $(n.validatingFields, c), !t.shouldUnregister && !o.keepDefaultValue && $(i, c);
|
|
769
|
-
p.state.next({ values: B(a) }), p.state.next({
|
|
770
|
-
...n,
|
|
771
|
-
...o.keepDirty ? { isDirty: O() } : {}
|
|
772
|
-
}), !o.keepIsValid && g();
|
|
773
|
-
}, _e = ({ disabled: e, name: t }) => {
|
|
774
|
-
if (W(e) && o.mount || e || s.disabled.has(t)) {
|
|
775
|
-
let n = s.disabled.has(t) !== !!e;
|
|
776
|
-
e ? s.disabled.add(t) : s.disabled.delete(t), n && o.mount && !o.action && g();
|
|
777
|
-
}
|
|
778
|
-
}, ye = (e, n = {}) => {
|
|
779
|
-
let a = U(r, e), c = W(n.disabled) || W(t.disabled), l = !s.registerName.has(e) && a && a._f && !a._f.mount;
|
|
780
|
-
return K(r, e, {
|
|
781
|
-
...a || {},
|
|
782
|
-
_f: {
|
|
783
|
-
...a && a._f ? a._f : { ref: { name: e } },
|
|
784
|
-
name: e,
|
|
785
|
-
mount: !0,
|
|
786
|
-
...n
|
|
787
|
-
}
|
|
788
|
-
}), s.mount.add(e), a && !l ? _e({
|
|
789
|
-
disabled: W(n.disabled) ? n.disabled : t.disabled,
|
|
790
|
-
name: e
|
|
791
|
-
}) : S(e, !0, n.value), {
|
|
792
|
-
...c ? { disabled: n.disabled || t.disabled } : {},
|
|
793
|
-
...t.progressive ? {
|
|
794
|
-
required: !!n.required,
|
|
795
|
-
min: Je(n.min),
|
|
796
|
-
max: Je(n.max),
|
|
797
|
-
minLength: Je(n.minLength),
|
|
798
|
-
maxLength: Je(n.maxLength),
|
|
799
|
-
pattern: Je(n.pattern)
|
|
800
|
-
} : {},
|
|
801
|
-
name: e,
|
|
802
|
-
onChange: re,
|
|
803
|
-
onBlur: re,
|
|
804
|
-
ref: (c) => {
|
|
805
|
-
if (c) {
|
|
806
|
-
s.registerName.add(e), ye(e, n), s.registerName.delete(e), a = U(r, e);
|
|
807
|
-
let t = H(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = Ae(t), l = a._f.refs || [];
|
|
808
|
-
if (o ? l.find((e) => e === t) : t === a._f.ref) return;
|
|
809
|
-
K(r, e, { _f: {
|
|
810
|
-
...a._f,
|
|
811
|
-
...o ? {
|
|
812
|
-
refs: [
|
|
813
|
-
...l.filter(je),
|
|
814
|
-
t,
|
|
815
|
-
...Array.isArray(U(i, e)) ? [{}] : []
|
|
816
|
-
],
|
|
817
|
-
ref: {
|
|
818
|
-
type: t.type,
|
|
819
|
-
name: e
|
|
820
|
-
}
|
|
821
|
-
} : { ref: t }
|
|
822
|
-
} }), S(e, !1, void 0, t);
|
|
823
|
-
} else a = U(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(se(s.array, e) && o.action) && s.unMount.add(e);
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
}, be = () => t.shouldFocusError && et(r, P, s.mount), xe = (e) => {
|
|
827
|
-
W(e) && (p.state.next({ disabled: e }), et(r, (t, n) => {
|
|
828
|
-
let i = U(r, n);
|
|
829
|
-
i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
|
|
830
|
-
t.disabled = i._f.disabled || e;
|
|
831
|
-
}));
|
|
832
|
-
}, 0, !1));
|
|
833
|
-
}, Se = (e, i) => async (o) => {
|
|
834
|
-
let c;
|
|
835
|
-
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
836
|
-
let l = B(a);
|
|
837
|
-
if (p.state.next({ isSubmitting: !0 }), t.resolver) {
|
|
838
|
-
let { errors: e, values: t } = await C();
|
|
839
|
-
_(), n.errors = e, l = B(t);
|
|
840
|
-
} else await E({
|
|
841
|
-
fields: r,
|
|
842
|
-
eventType: q.SUBMIT
|
|
843
|
-
});
|
|
844
|
-
if (s.disabled.size) for (let e of s.disabled) $(l, e);
|
|
845
|
-
if ($(n.errors, pe), Q(n.errors)) {
|
|
846
|
-
p.state.next({ errors: {} });
|
|
847
|
-
try {
|
|
848
|
-
await e(l, o);
|
|
849
|
-
} catch (e) {
|
|
850
|
-
c = e;
|
|
851
|
-
}
|
|
852
|
-
} else i && await i({ ...n.errors }, o), be(), setTimeout(be);
|
|
853
|
-
if (p.state.next({
|
|
854
|
-
isSubmitted: !0,
|
|
855
|
-
isSubmitting: !1,
|
|
856
|
-
isSubmitSuccessful: Q(n.errors) && !c,
|
|
857
|
-
submitCount: n.submitCount + 1,
|
|
858
|
-
errors: n.errors
|
|
859
|
-
}), c) throw c;
|
|
860
|
-
}, ke = (e, t = {}) => {
|
|
861
|
-
U(r, e) && (H(t.defaultValue) ? N(e, B(U(i, e))) : (N(e, t.defaultValue), K(i, e, B(t.defaultValue))), t.keepTouched || $(n.touchedFields, e), t.keepDirty || ($(n.dirtyFields, e), n.isDirty = t.defaultValue ? O(e, B(U(i, e))) : O()), t.keepError || ($(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
|
|
862
|
-
}, Me = (e, c = {}) => {
|
|
863
|
-
let l = e ? B(e) : i, u = B(l), f = Q(e), m = f ? i : u;
|
|
864
|
-
if (c.keepDefaultValues || (i = l), !c.keepValues) {
|
|
865
|
-
if (c.keepDirtyValues) {
|
|
866
|
-
let e = new Set([...s.mount, ...Object.keys(Re(i, a))]);
|
|
867
|
-
for (let t of Array.from(e)) {
|
|
868
|
-
let e = U(n.dirtyFields, t), r = U(a, t), i = U(m, t);
|
|
869
|
-
e && !H(r) ? K(m, t, r) : !e && !H(i) && N(t, i);
|
|
870
|
-
}
|
|
871
|
-
} else {
|
|
872
|
-
if (le && H(e)) for (let e of s.mount) {
|
|
873
|
-
let t = U(r, e);
|
|
874
|
-
if (t && t._f) {
|
|
875
|
-
let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
|
|
876
|
-
if (De(e)) {
|
|
877
|
-
let t = e.closest("form");
|
|
878
|
-
if (t) {
|
|
879
|
-
t.reset();
|
|
880
|
-
break;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
if (c.keepFieldsRef) for (let e of s.mount) N(e, U(m, e));
|
|
886
|
-
else r = {};
|
|
887
|
-
}
|
|
888
|
-
a = t.shouldUnregister ? c.keepDefaultValues ? B(i) : {} : B(m), p.array.next({ values: { ...m } }), p.state.next({ values: { ...m } });
|
|
889
|
-
}
|
|
890
|
-
s = {
|
|
891
|
-
mount: c.keepDirtyValues ? s.mount : /* @__PURE__ */ new Set(),
|
|
892
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
893
|
-
array: /* @__PURE__ */ new Set(),
|
|
894
|
-
registerName: /* @__PURE__ */ new Set(),
|
|
895
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
896
|
-
watch: /* @__PURE__ */ new Set(),
|
|
897
|
-
watchAll: !1,
|
|
898
|
-
focus: ""
|
|
899
|
-
}, o.mount = !d.isValid || !!c.keepIsValid || !!c.keepDirtyValues || !t.shouldUnregister && !Q(m), o.watch = !!t.shouldUnregister, o.keepIsValid = !!c.keepIsValid, o.action = !1, c.keepErrors || (n.errors = {}), p.state.next({
|
|
900
|
-
submitCount: c.keepSubmitCount ? n.submitCount : 0,
|
|
901
|
-
isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !Z(e, i)),
|
|
902
|
-
isSubmitted: c.keepIsSubmitted ? n.isSubmitted : !1,
|
|
903
|
-
dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? Re(i, a) : n.dirtyFields : c.keepDefaultValues && e ? Re(i, e) : c.keepDirty ? n.dirtyFields : {},
|
|
904
|
-
touchedFields: c.keepTouched ? n.touchedFields : {},
|
|
905
|
-
errors: c.keepErrors ? n.errors : {},
|
|
906
|
-
isSubmitSuccessful: c.keepIsSubmitSuccessful ? n.isSubmitSuccessful : !1,
|
|
907
|
-
isSubmitting: !1,
|
|
908
|
-
defaultValues: i
|
|
909
|
-
});
|
|
910
|
-
}, Ne = (e, n) => Me(G(e) ? e(a) : e, {
|
|
911
|
-
...t.resetOptions,
|
|
912
|
-
...n
|
|
913
|
-
}), Pe = (e, t = {}) => {
|
|
914
|
-
let n = U(r, e), i = n && n._f;
|
|
915
|
-
if (i) {
|
|
916
|
-
let e = i.refs ? i.refs[0] : i.ref;
|
|
917
|
-
e.focus && setTimeout(() => {
|
|
918
|
-
e.focus(), t.shouldSelect && G(e.select) && e.select();
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
}, Fe = (e) => {
|
|
922
|
-
n = {
|
|
923
|
-
...n,
|
|
924
|
-
...e
|
|
925
|
-
};
|
|
926
|
-
}, Ie = {
|
|
927
|
-
control: {
|
|
928
|
-
register: ye,
|
|
929
|
-
unregister: ge,
|
|
930
|
-
getFieldState: ae,
|
|
931
|
-
handleSubmit: Se,
|
|
932
|
-
setError: V,
|
|
933
|
-
_subscribe: me,
|
|
934
|
-
_runSchema: C,
|
|
935
|
-
_updateIsValidating: _,
|
|
936
|
-
_focusError: be,
|
|
937
|
-
_getWatch: k,
|
|
938
|
-
_getDirty: O,
|
|
939
|
-
_setValid: g,
|
|
940
|
-
_setFieldArray: y,
|
|
941
|
-
_setDisabledField: _e,
|
|
942
|
-
_setErrors: x,
|
|
943
|
-
_getFieldArray: A,
|
|
944
|
-
_reset: Me,
|
|
945
|
-
_resetDefaultValues: () => G(t.defaultValues) && t.defaultValues().then((e) => {
|
|
946
|
-
Ne(e, t.resetOptions), p.state.next({ isLoading: !1 });
|
|
947
|
-
}),
|
|
948
|
-
_removeUnmounted: D,
|
|
949
|
-
_disableForm: xe,
|
|
950
|
-
_subjects: p,
|
|
951
|
-
_proxyFormState: d,
|
|
952
|
-
get _fields() {
|
|
953
|
-
return r;
|
|
954
|
-
},
|
|
955
|
-
get _formValues() {
|
|
956
|
-
return a;
|
|
957
|
-
},
|
|
958
|
-
get _state() {
|
|
959
|
-
return o;
|
|
960
|
-
},
|
|
961
|
-
set _state(e) {
|
|
962
|
-
o = e;
|
|
963
|
-
},
|
|
964
|
-
get _defaultValues() {
|
|
965
|
-
return i;
|
|
966
|
-
},
|
|
967
|
-
get _names() {
|
|
968
|
-
return s;
|
|
969
|
-
},
|
|
970
|
-
set _names(e) {
|
|
971
|
-
s = e;
|
|
972
|
-
},
|
|
973
|
-
get _formState() {
|
|
974
|
-
return n;
|
|
975
|
-
},
|
|
976
|
-
get _options() {
|
|
977
|
-
return t;
|
|
978
|
-
},
|
|
979
|
-
set _options(e) {
|
|
980
|
-
t = {
|
|
981
|
-
...t,
|
|
982
|
-
...e
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
},
|
|
986
|
-
subscribe: he,
|
|
987
|
-
trigger: F,
|
|
988
|
-
register: ye,
|
|
989
|
-
handleSubmit: Se,
|
|
990
|
-
watch: de,
|
|
991
|
-
setValue: N,
|
|
992
|
-
setValues: ne,
|
|
993
|
-
getValues: ie,
|
|
994
|
-
reset: Ne,
|
|
995
|
-
resetField: ke,
|
|
996
|
-
clearErrors: ce,
|
|
997
|
-
unregister: ge,
|
|
998
|
-
setError: V,
|
|
999
|
-
setFocus: Pe,
|
|
1000
|
-
getFieldState: ae
|
|
1001
|
-
};
|
|
1002
|
-
return {
|
|
1003
|
-
...Ie,
|
|
1004
|
-
formControl: Ie
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
function pt(e = {}) {
|
|
1008
|
-
let t = k.useRef(void 0), n = k.useRef(void 0), [r, i] = k.useState(() => ({
|
|
1009
|
-
...B(dt),
|
|
1010
|
-
isLoading: G(e.defaultValues),
|
|
1011
|
-
errors: e.errors || {},
|
|
1012
|
-
disabled: e.disabled || !1,
|
|
1013
|
-
defaultValues: G(e.defaultValues) ? void 0 : e.defaultValues
|
|
1014
|
-
}));
|
|
1015
|
-
if (!t.current) if (e.formControl) t.current = {
|
|
1016
|
-
...e.formControl,
|
|
1017
|
-
formState: r
|
|
1018
|
-
}, e.defaultValues && !G(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1019
|
-
else {
|
|
1020
|
-
let { formControl: n, ...i } = ft(e);
|
|
1021
|
-
t.current = {
|
|
1022
|
-
...i,
|
|
1023
|
-
formState: r
|
|
1024
|
-
};
|
|
1025
|
-
}
|
|
1026
|
-
let a = t.current.control;
|
|
1027
|
-
return a._options = e, _e(() => {
|
|
1028
|
-
let e = a._subscribe({
|
|
1029
|
-
formState: a._proxyFormState,
|
|
1030
|
-
callback: () => i({ ...a._formState }),
|
|
1031
|
-
reRenderRoot: !0
|
|
1032
|
-
});
|
|
1033
|
-
return i((e) => ({
|
|
1034
|
-
...e,
|
|
1035
|
-
isReady: !0
|
|
1036
|
-
})), a._formState.isReady = !0, e;
|
|
1037
|
-
}, [a]), k.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), k.useEffect(() => {
|
|
1038
|
-
e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
|
|
1039
|
-
}, [
|
|
1040
|
-
a,
|
|
1041
|
-
e.mode,
|
|
1042
|
-
e.reValidateMode
|
|
1043
|
-
]), k.useEffect(() => {
|
|
1044
|
-
e.errors && (a._setErrors(e.errors), a._focusError());
|
|
1045
|
-
}, [a, e.errors]), k.useEffect(() => {
|
|
1046
|
-
e.shouldUnregister && a._subjects.state.next({ values: a._getWatch() });
|
|
1047
|
-
}, [a, e.shouldUnregister]), k.useEffect(() => {
|
|
1048
|
-
if (a._proxyFormState.isDirty) {
|
|
1049
|
-
let e = a._getDirty();
|
|
1050
|
-
e !== r.isDirty && a._subjects.state.next({ isDirty: e });
|
|
1051
|
-
}
|
|
1052
|
-
}, [a, r.isDirty]), k.useEffect(() => {
|
|
1053
|
-
e.values && !Z(e.values, n.current) ? (a._reset(e.values, {
|
|
1054
|
-
keepFieldsRef: !0,
|
|
1055
|
-
...a._options.resetOptions
|
|
1056
|
-
}), a._options.resetOptions?.keepIsValid || a._setValid(), n.current = e.values, i((e) => ({ ...e }))) : a._resetDefaultValues();
|
|
1057
|
-
}, [a, e.values]), k.useEffect(() => {
|
|
1058
|
-
a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
|
|
1059
|
-
}), t.current.formState = k.useMemo(() => ge(r, a), [a, r]), t.current;
|
|
1060
|
-
}
|
|
1061
|
-
//#endregion
|
|
1062
|
-
//#region node_modules/@hookform/resolvers/dist/resolvers.mjs
|
|
1063
|
-
var mt = (e, t, n) => {
|
|
1064
|
-
if (e && "reportValidity" in e) {
|
|
1065
|
-
let r = U(n, t);
|
|
1066
|
-
e.setCustomValidity(r && r.message || ""), e.reportValidity();
|
|
1067
|
-
}
|
|
1068
|
-
}, ht = (e, t) => {
|
|
1069
|
-
for (let n in t.fields) {
|
|
1070
|
-
let r = t.fields[n];
|
|
1071
|
-
r && r.ref && "reportValidity" in r.ref ? mt(r.ref, n, e) : r && r.refs && r.refs.forEach((t) => mt(t, n, e));
|
|
1072
|
-
}
|
|
1073
|
-
}, gt = (e, t) => {
|
|
1074
|
-
t.shouldUseNativeValidation && ht(e, t);
|
|
1075
|
-
let n = {};
|
|
1076
|
-
for (let r in e) {
|
|
1077
|
-
let i = U(t.fields, r), a = Object.assign(e[r] || {}, { ref: i && i.ref });
|
|
1078
|
-
if (_t(t.names || Object.keys(e), r)) {
|
|
1079
|
-
let e = Object.assign({}, U(n, r));
|
|
1080
|
-
K(e, "root", a), K(n, r, e);
|
|
1081
|
-
} else K(n, r, a);
|
|
1082
|
-
}
|
|
1083
|
-
return n;
|
|
1084
|
-
}, _t = (e, t) => {
|
|
1085
|
-
let n = vt(t);
|
|
1086
|
-
return e.some((e) => vt(e).match(`^${n}\\.\\d+`));
|
|
1087
|
-
};
|
|
1088
|
-
function vt(e) {
|
|
1089
|
-
return e.replace(/\]|\[/g, "");
|
|
1090
|
-
}
|
|
1091
|
-
//#endregion
|
|
1092
|
-
//#region node_modules/@hookform/resolvers/zod/dist/zod.mjs
|
|
1093
|
-
function yt(e, t) {
|
|
1094
|
-
try {
|
|
1095
|
-
var n = e();
|
|
1096
|
-
} catch (e) {
|
|
1097
|
-
return t(e);
|
|
1098
|
-
}
|
|
1099
|
-
return n && n.then ? n.then(void 0, t) : n;
|
|
1100
|
-
}
|
|
1101
|
-
function bt(e, t) {
|
|
1102
|
-
for (var n = {}; e.length;) {
|
|
1103
|
-
var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
|
|
1104
|
-
if (!n[o]) if ("unionErrors" in r) {
|
|
1105
|
-
var s = r.unionErrors[0].errors[0];
|
|
1106
|
-
n[o] = {
|
|
1107
|
-
message: s.message,
|
|
1108
|
-
type: s.code
|
|
1109
|
-
};
|
|
1110
|
-
} else n[o] = {
|
|
1111
|
-
message: a,
|
|
1112
|
-
type: i
|
|
1113
|
-
};
|
|
1114
|
-
if ("unionErrors" in r && r.unionErrors.forEach(function(t) {
|
|
1115
|
-
return t.errors.forEach(function(t) {
|
|
1116
|
-
return e.push(t);
|
|
1117
|
-
});
|
|
1118
|
-
}), t) {
|
|
1119
|
-
var c = n[o].types, l = c && c[r.code];
|
|
1120
|
-
n[o] = Se(o, t, n, i, l ? [].concat(l, r.message) : r.message);
|
|
1121
|
-
}
|
|
1122
|
-
e.shift();
|
|
1123
|
-
}
|
|
1124
|
-
return n;
|
|
1125
|
-
}
|
|
1126
|
-
function xt(e, t) {
|
|
1127
|
-
for (var n = {}; e.length;) {
|
|
1128
|
-
var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
|
|
1129
|
-
if (!n[o]) if (r.code === "invalid_union" && r.errors.length > 0) {
|
|
1130
|
-
var s = r.errors[0][0];
|
|
1131
|
-
n[o] = {
|
|
1132
|
-
message: s.message,
|
|
1133
|
-
type: s.code
|
|
1134
|
-
};
|
|
1135
|
-
} else n[o] = {
|
|
1136
|
-
message: a,
|
|
1137
|
-
type: i
|
|
1138
|
-
};
|
|
1139
|
-
if (r.code === "invalid_union" && r.errors.forEach(function(t) {
|
|
1140
|
-
return t.forEach(function(t) {
|
|
1141
|
-
return e.push(t);
|
|
1142
|
-
});
|
|
1143
|
-
}), t) {
|
|
1144
|
-
var c = n[o].types, l = c && c[r.code];
|
|
1145
|
-
n[o] = Se(o, t, n, i, l ? [].concat(l, r.message) : r.message);
|
|
1146
|
-
}
|
|
1147
|
-
e.shift();
|
|
1148
|
-
}
|
|
1149
|
-
return n;
|
|
1150
|
-
}
|
|
1151
|
-
function St(e, t, n) {
|
|
1152
|
-
if (n === void 0 && (n = {}), function(e) {
|
|
1153
|
-
return "_def" in e && typeof e._def == "object" && "typeName" in e._def;
|
|
1154
|
-
}(e)) return function(r, i, a) {
|
|
1155
|
-
try {
|
|
1156
|
-
return Promise.resolve(yt(function() {
|
|
1157
|
-
return Promise.resolve(e[n.mode === "sync" ? "parse" : "parseAsync"](r, t)).then(function(e) {
|
|
1158
|
-
return a.shouldUseNativeValidation && ht({}, a), {
|
|
1159
|
-
errors: {},
|
|
1160
|
-
values: n.raw ? Object.assign({}, r) : e
|
|
1161
|
-
};
|
|
1162
|
-
});
|
|
1163
|
-
}, function(e) {
|
|
1164
|
-
if (function(e) {
|
|
1165
|
-
return Array.isArray(e?.issues);
|
|
1166
|
-
}(e)) return {
|
|
1167
|
-
values: {},
|
|
1168
|
-
errors: gt(bt(e.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
|
|
1169
|
-
};
|
|
1170
|
-
throw e;
|
|
1171
|
-
}));
|
|
1172
|
-
} catch (e) {
|
|
1173
|
-
return Promise.reject(e);
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
if (function(e) {
|
|
1177
|
-
return "_zod" in e && typeof e._zod == "object";
|
|
1178
|
-
}(e)) return function(r, i, o) {
|
|
1179
|
-
try {
|
|
1180
|
-
return Promise.resolve(yt(function() {
|
|
1181
|
-
return Promise.resolve((n.mode === "sync" ? a : u)(e, r, t)).then(function(e) {
|
|
1182
|
-
return o.shouldUseNativeValidation && ht({}, o), {
|
|
1183
|
-
errors: {},
|
|
1184
|
-
values: n.raw ? Object.assign({}, r) : e
|
|
1185
|
-
};
|
|
1186
|
-
});
|
|
1187
|
-
}, function(e) {
|
|
1188
|
-
if (function(e) {
|
|
1189
|
-
return e instanceof T;
|
|
1190
|
-
}(e)) return {
|
|
1191
|
-
values: {},
|
|
1192
|
-
errors: gt(xt(e.issues, !o.shouldUseNativeValidation && o.criteriaMode === "all"), o)
|
|
1193
|
-
};
|
|
1194
|
-
throw e;
|
|
1195
|
-
}));
|
|
1196
|
-
} catch (e) {
|
|
1197
|
-
return Promise.reject(e);
|
|
1198
|
-
}
|
|
1199
|
-
};
|
|
1200
|
-
throw Error("Invalid input: not a Zod schema");
|
|
1201
|
-
}
|
|
1202
|
-
//#endregion
|
|
1203
|
-
//#region src/base/form/form-schema-builder.ts
|
|
1204
|
-
function Ct(e, r, i) {
|
|
1205
|
-
let { component: a, props: s } = e, l = s.validation, u = i;
|
|
1206
|
-
switch (a) {
|
|
1207
|
-
case "text":
|
|
1208
|
-
case "textarea":
|
|
1209
|
-
case "password":
|
|
1210
|
-
case "slug":
|
|
1211
|
-
case "color": {
|
|
1212
|
-
let e = n();
|
|
1213
|
-
return u && (e = e.min(1, r("middag.ui.validation.required"))), l?.minLength && (e = e.min(l.minLength, r("middag.ui.validation.min_length", { min: l.minLength }))), l?.maxLength && (e = e.max(l.maxLength, r("middag.ui.validation.max_length", { max: l.maxLength }))), l?.pattern && (e = e.regex(new RegExp(l.pattern), l.patternMessage ?? r("middag.ui.validation.pattern"))), u ? e : e.or(_(""));
|
|
1214
|
-
}
|
|
1215
|
-
case "email": {
|
|
1216
|
-
let e = n();
|
|
1217
|
-
if (u) e = e.min(1, r("middag.ui.validation.required")).email(r("middag.ui.validation.email"));
|
|
1218
|
-
else return e.email(r("middag.ui.validation.email")).or(_(""));
|
|
1219
|
-
return e;
|
|
1220
|
-
}
|
|
1221
|
-
case "url": {
|
|
1222
|
-
let e = n();
|
|
1223
|
-
if (u) e = e.min(1, r("middag.ui.validation.required")).url(r("middag.ui.validation.url"));
|
|
1224
|
-
else return e.url(r("middag.ui.validation.url")).or(_(""));
|
|
1225
|
-
return e;
|
|
1226
|
-
}
|
|
1227
|
-
case "int": {
|
|
1228
|
-
let e = o({ message: r("middag.ui.validation.integer") }).int(r("middag.ui.validation.integer"));
|
|
1229
|
-
return s.min != null && (e = e.min(s.min, r("middag.ui.validation.min_value", { min: s.min }))), s.max != null && (e = e.max(s.max, r("middag.ui.validation.max_value", { max: s.max }))), u ? e : e.nullable();
|
|
1230
|
-
}
|
|
1231
|
-
case "float": {
|
|
1232
|
-
let e = o();
|
|
1233
|
-
return s.min != null && (e = e.min(s.min, r("middag.ui.validation.min_value", { min: s.min }))), s.max != null && (e = e.max(s.max, r("middag.ui.validation.max_value", { max: s.max }))), u ? e : e.nullable();
|
|
1234
|
-
}
|
|
1235
|
-
case "currency": {
|
|
1236
|
-
let e = o();
|
|
1237
|
-
return u ? e : e.nullable();
|
|
1238
|
-
}
|
|
1239
|
-
case "select":
|
|
1240
|
-
case "radio":
|
|
1241
|
-
case "entity_picker": {
|
|
1242
|
-
let e = n();
|
|
1243
|
-
return u ? e.min(1, r("middag.ui.validation.required")) : e;
|
|
1244
|
-
}
|
|
1245
|
-
case "multiselect":
|
|
1246
|
-
case "tags": {
|
|
1247
|
-
let e = v(n());
|
|
1248
|
-
return u ? e.min(1, r("middag.ui.validation.required")) : e;
|
|
1249
|
-
}
|
|
1250
|
-
case "checkbox":
|
|
1251
|
-
case "switch": return t();
|
|
1252
|
-
case "date":
|
|
1253
|
-
case "datetime": {
|
|
1254
|
-
let e = n();
|
|
1255
|
-
return u ? e.min(1, r("middag.ui.validation.required")) : e;
|
|
1256
|
-
}
|
|
1257
|
-
case "phone": {
|
|
1258
|
-
let e = n();
|
|
1259
|
-
return u ? e.min(1, r("middag.ui.validation.required")) : e;
|
|
1260
|
-
}
|
|
1261
|
-
case "document": {
|
|
1262
|
-
let e = s.documentType ?? "generic", t = s.documentScope ?? "any", i = n(), a = async (n) => {
|
|
1263
|
-
let { isValidDocument: r } = await import("./document-validation-BSjTDZhG.js");
|
|
1264
|
-
return r(n, e, t);
|
|
1265
|
-
};
|
|
1266
|
-
return u ? i.min(1, r("middag.ui.validation.required")).refine(a, r("middag.ui.validation.document_invalid")) : i.refine(async (e) => e === "" || await a(e), r("middag.ui.validation.document_invalid"));
|
|
1267
|
-
}
|
|
1268
|
-
default: return c();
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
function wt(e, t, n) {
|
|
1272
|
-
let r = b(e), i = {};
|
|
1273
|
-
for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" || h(e, t) && (i[e.key] = Ct(e, n, ee(e, t)));
|
|
1274
|
-
return s(i);
|
|
1275
|
-
}
|
|
1276
|
-
//#endregion
|
|
1277
|
-
//#region src/base/blocks/FormPanelBlock.tsx
|
|
1278
|
-
function Tt(e, t) {
|
|
1279
|
-
let n = t[e.key];
|
|
1280
|
-
if (n != null) return n;
|
|
1281
|
-
switch (e.component) {
|
|
1282
|
-
case "int":
|
|
1283
|
-
case "float":
|
|
1284
|
-
case "currency":
|
|
1285
|
-
case "slider":
|
|
1286
|
-
case "rating": return null;
|
|
1287
|
-
case "checkbox":
|
|
1288
|
-
case "switch": return !1;
|
|
1289
|
-
case "multiselect":
|
|
1290
|
-
case "tags": return [];
|
|
1291
|
-
default: return "";
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
function Et(e, t) {
|
|
1295
|
-
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : Tt(e, t);
|
|
1296
|
-
}
|
|
1297
|
-
function Dt({ nodes: e, values: t, errors: n, onChange: r, sourceValues: i }) {
|
|
1298
|
-
return /* @__PURE__ */ P(re, { children: e.map((e, a) => {
|
|
1299
|
-
switch (e.kind) {
|
|
1300
|
-
case "field": return h(e, t) ? /* @__PURE__ */ P(C, {
|
|
1301
|
-
field: e,
|
|
1302
|
-
value: Et(e, t),
|
|
1303
|
-
onChange: (t) => r(e.key, t),
|
|
1304
|
-
error: n[e.key],
|
|
1305
|
-
sourceValues: i
|
|
1306
|
-
}, e.key) : null;
|
|
1307
|
-
case "section": return /* @__PURE__ */ P(x, {
|
|
1308
|
-
id: e.id,
|
|
1309
|
-
title: e.label,
|
|
1310
|
-
defaultCollapsed: e.defaultCollapsed,
|
|
1311
|
-
hasErrors: e.children.some((e) => e.kind === "field" && !!n[e.key]),
|
|
1312
|
-
errorCount: e.children.filter((e) => e.kind === "field" && !!n[e.key]).length,
|
|
1313
|
-
children: /* @__PURE__ */ P(Dt, {
|
|
1314
|
-
nodes: e.children,
|
|
1315
|
-
values: t,
|
|
1316
|
-
errors: n,
|
|
1317
|
-
onChange: r,
|
|
1318
|
-
sourceValues: i
|
|
1319
|
-
})
|
|
1320
|
-
}, e.id);
|
|
1321
|
-
case "group": return /* @__PURE__ */ P("div", {
|
|
1322
|
-
className: O("grid gap-6", e.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
|
|
1323
|
-
children: /* @__PURE__ */ P(Dt, {
|
|
1324
|
-
nodes: e.children,
|
|
1325
|
-
values: t,
|
|
1326
|
-
errors: n,
|
|
1327
|
-
onChange: r,
|
|
1328
|
-
sourceValues: i
|
|
1329
|
-
})
|
|
1330
|
-
}, e.id);
|
|
1331
|
-
case "header": return /* @__PURE__ */ F("div", {
|
|
1332
|
-
className: "space-y-2",
|
|
1333
|
-
children: [/* @__PURE__ */ P(l, {}), /* @__PURE__ */ P("h4", {
|
|
1334
|
-
className: "text-foreground text-base font-semibold",
|
|
1335
|
-
children: e.label
|
|
1336
|
-
})]
|
|
1337
|
-
}, `header-${a}`);
|
|
1338
|
-
default: return null;
|
|
1339
|
-
}
|
|
1340
|
-
}) });
|
|
1341
|
-
}
|
|
1342
|
-
function Ot({ block: t }) {
|
|
1343
|
-
let { t: n } = D(), { data: a } = t, o = M(() => b(a.schema), [a.schema]), s = M(() => new Set(o.map((e) => e.key)), [o]), c = (a.meta.validation ?? "both") !== "server", l = M(() => Object.fromEntries(o.map((e) => [e.key, Tt(e, a.values)])), [o, a.values]), u = N(c ? wt(a.schema, l, n) : null), _ = pt({
|
|
1344
|
-
defaultValues: l,
|
|
1345
|
-
mode: "onTouched",
|
|
1346
|
-
resolver: M(() => {
|
|
1347
|
-
if (c) return async (e, t, n) => u.current ? St(u.current)(e, t, n) : {
|
|
1348
|
-
values: e,
|
|
1349
|
-
errors: {}
|
|
1350
|
-
};
|
|
1351
|
-
}, [c])
|
|
1352
|
-
}), v = be({ control: _.control }) ?? l, x = o.map((e) => `${h(e, v) ? "1" : "0"}${ee(e, v) ? "1" : "0"}`).join("");
|
|
1353
|
-
j(() => {
|
|
1354
|
-
c && (u.current = wt(a.schema, v, n));
|
|
1355
|
-
}, [
|
|
1356
|
-
c,
|
|
1357
|
-
a.schema,
|
|
1358
|
-
n,
|
|
1359
|
-
x
|
|
1360
|
-
]);
|
|
1361
|
-
let [C, T] = ne(!1), [O, k] = ne(null), [I, L] = ne({}), R = JSON.stringify(a.values), ae = N(!0);
|
|
1362
|
-
j(() => {
|
|
1363
|
-
if (ae.current) {
|
|
1364
|
-
ae.current = !1;
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
1367
|
-
_.reset(l);
|
|
1368
|
-
for (let [e, t] of Object.entries(a.errors)) s.has(e) && _.setError(e, {
|
|
1369
|
-
type: "server",
|
|
1370
|
-
message: p(t, n)
|
|
1371
|
-
});
|
|
1372
|
-
}, [R]), j(() => {
|
|
1373
|
-
if (Object.keys(a.errors).length > 0) for (let [e, t] of Object.entries(a.errors)) s.has(e) && _.setError(e, {
|
|
1374
|
-
type: "server",
|
|
1375
|
-
message: p(t, n)
|
|
1376
|
-
});
|
|
1377
|
-
}, [JSON.stringify(a.errors)]);
|
|
1378
|
-
let { isDirty: z, isSubmitting: oe } = _.formState;
|
|
1379
|
-
j(() => {
|
|
1380
|
-
if (!z) return;
|
|
1381
|
-
let e = (e) => {
|
|
1382
|
-
e.preventDefault();
|
|
1383
|
-
};
|
|
1384
|
-
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1385
|
-
}, [z]);
|
|
1386
|
-
let se = A((e, t) => {
|
|
1387
|
-
_.setValue(e, t, {
|
|
1388
|
-
shouldDirty: !0,
|
|
1389
|
-
shouldValidate: _.formState.isSubmitted
|
|
1390
|
-
}), _.clearErrors(e);
|
|
1391
|
-
}, [_]), ce = A((e) => {
|
|
1392
|
-
L({});
|
|
1393
|
-
let t = o.filter((t) => h(t, e)), r = Object.fromEntries(t.map((t) => [t.key, e[t.key]])), i = Object.values(r).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File));
|
|
1394
|
-
ie[a.method === "put" ? "put" : a.method === "patch" ? "patch" : "post"](a.action, r, {
|
|
1395
|
-
forceFormData: i,
|
|
1396
|
-
onProgress: (e) => {
|
|
1397
|
-
e && typeof e.percentage == "number" && k(Math.round(e.percentage));
|
|
1398
|
-
},
|
|
1399
|
-
onError: (e) => {
|
|
1400
|
-
let t = {};
|
|
1401
|
-
for (let [r, i] of Object.entries(e)) s.has(r) ? _.setError(r, {
|
|
1402
|
-
type: "server",
|
|
1403
|
-
message: p(i, n)
|
|
1404
|
-
}) : t[r] = i;
|
|
1405
|
-
Object.keys(t).length > 0 && L((e) => ({
|
|
1406
|
-
...e,
|
|
1407
|
-
...t
|
|
1408
|
-
}));
|
|
1409
|
-
},
|
|
1410
|
-
onFinish: () => k(null)
|
|
1411
|
-
});
|
|
1412
|
-
}, [
|
|
1413
|
-
o,
|
|
1414
|
-
a,
|
|
1415
|
-
_,
|
|
1416
|
-
n,
|
|
1417
|
-
s
|
|
1418
|
-
]), le = A(() => {
|
|
1419
|
-
z ? T(!0) : a.meta.cancelHref ? ie.visit(a.meta.cancelHref) : window.history.back();
|
|
1420
|
-
}, [z, a.meta.cancelHref]), B = M(() => {
|
|
1421
|
-
let e = {};
|
|
1422
|
-
for (let [t, n] of Object.entries(_.formState.errors)) n?.message && (e[t] = n.message);
|
|
1423
|
-
return e;
|
|
1424
|
-
}, [_.formState.errors]), V = M(() => {
|
|
1425
|
-
let e = /* @__PURE__ */ new Map(), t = (t) => {
|
|
1426
|
-
for (let [r, i] of Object.entries(t)) {
|
|
1427
|
-
if (s.has(r)) continue;
|
|
1428
|
-
let t = p(i, n);
|
|
1429
|
-
t && e.set(r, t);
|
|
1430
|
-
}
|
|
1431
|
-
};
|
|
1432
|
-
return t(a.errors), t(I), Array.from(e, ([e, t]) => ({
|
|
1433
|
-
key: e,
|
|
1434
|
-
message: t
|
|
1435
|
-
}));
|
|
1436
|
-
}, [
|
|
1437
|
-
a.errors,
|
|
1438
|
-
I,
|
|
1439
|
-
s,
|
|
1440
|
-
n
|
|
1441
|
-
]);
|
|
1442
|
-
return o.filter((e) => h(e, v)).length === 0 && a.schema.length === 0 ? /* @__PURE__ */ P(r, {
|
|
1443
|
-
variant: "inline",
|
|
1444
|
-
title: n("middag.ui.form.no_fields")
|
|
1445
|
-
}) : /* @__PURE__ */ F(re, { children: [/* @__PURE__ */ F("form", {
|
|
1446
|
-
onSubmit: _.handleSubmit(ce),
|
|
1447
|
-
className: "mx-auto max-w-[720px] space-y-6",
|
|
1448
|
-
noValidate: !0,
|
|
1449
|
-
role: "form",
|
|
1450
|
-
"aria-label": e(t.title, n) || n("middag.ui.form.default_title"),
|
|
1451
|
-
children: [
|
|
1452
|
-
V.length > 0 && /* @__PURE__ */ F(i, {
|
|
1453
|
-
variant: "destructive",
|
|
1454
|
-
children: [/* @__PURE__ */ P(f, { children: n("middag.ui.form.errors_title") }), /* @__PURE__ */ P(d, { children: /* @__PURE__ */ P("ul", {
|
|
1455
|
-
className: "list-disc ps-4",
|
|
1456
|
-
children: V.map((e) => /* @__PURE__ */ P("li", { children: e.message }, e.key))
|
|
1457
|
-
}) })]
|
|
1458
|
-
}),
|
|
1459
|
-
/* @__PURE__ */ P(Dt, {
|
|
1460
|
-
nodes: a.schema,
|
|
1461
|
-
values: v,
|
|
1462
|
-
errors: B,
|
|
1463
|
-
onChange: se,
|
|
1464
|
-
sourceValues: v
|
|
1465
|
-
}),
|
|
1466
|
-
/* @__PURE__ */ F("div", {
|
|
1467
|
-
className: "flex gap-3 pt-4",
|
|
1468
|
-
children: [/* @__PURE__ */ P(E, {
|
|
1469
|
-
type: "submit",
|
|
1470
|
-
disabled: oe,
|
|
1471
|
-
"aria-disabled": oe,
|
|
1472
|
-
"aria-busy": oe,
|
|
1473
|
-
children: oe ? O === null ? n("middag.ui.form.saving") : `${n("middag.ui.form.saving")} ${O}%` : a.meta.submitLabel ?? n("middag.ui.form.save")
|
|
1474
|
-
}), /* @__PURE__ */ P(E, {
|
|
1475
|
-
type: "button",
|
|
1476
|
-
variant: "outline",
|
|
1477
|
-
onClick: le,
|
|
1478
|
-
children: a.meta.cancelLabel ?? n("middag.ui.cancel")
|
|
1479
|
-
})]
|
|
1480
|
-
})
|
|
1481
|
-
]
|
|
1482
|
-
}), /* @__PURE__ */ P(w, {
|
|
1483
|
-
open: C,
|
|
1484
|
-
onOpenChange: T,
|
|
1485
|
-
children: /* @__PURE__ */ F(te, { children: [/* @__PURE__ */ F(S, { children: [/* @__PURE__ */ P(y, { children: n("middag.ui.form.dirty_title") }), /* @__PURE__ */ P(g, { children: n("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ F(m, { children: [/* @__PURE__ */ P(E, {
|
|
1486
|
-
variant: "outline",
|
|
1487
|
-
onClick: () => T(!1),
|
|
1488
|
-
children: n("middag.ui.cancel")
|
|
1489
|
-
}), /* @__PURE__ */ P(E, {
|
|
1490
|
-
variant: "destructive",
|
|
1491
|
-
onClick: () => {
|
|
1492
|
-
T(!1), a.meta.cancelHref ? ie.visit(a.meta.cancelHref) : window.history.back();
|
|
1493
|
-
},
|
|
1494
|
-
children: n("middag.ui.form.dirty_leave")
|
|
1495
|
-
})] })] })
|
|
1496
|
-
})] });
|
|
1497
|
-
}
|
|
1498
|
-
//#endregion
|
|
1499
|
-
export { Ot as FormPanelBlock };
|