@middag-io/react 0.43.0 → 0.44.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-ChfKYVSc.js → FormField-Bj43PjHH.js} +798 -773
- package/dist-lib/{FormPanelBlock-Cu2ATcpu.js → FormPanelBlock-C6eDfGoI.js} +442 -441
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/layout/BlockRegion.d.ts.map +1 -1
- package/dist-lib/base/layout/DashboardLayout.d.ts.map +1 -1
- package/dist-lib/base/partials/ActionBar/index.d.ts.map +1 -1
- package/dist-lib/base/partials/ConfirmationDialog/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +320 -318
- package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
- package/dist-lib/chunks/subpath-D0ykpYEG.js +154 -0
- package/dist-lib/lib/test-ids.d.ts +25 -0
- package/dist-lib/lib/test-ids.d.ts.map +1 -0
- package/dist-lib/lib/test-ids.js +25 -0
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +8810 -8787
- package/package.json +1 -1
- package/dist-lib/chunks/subpath-oMCFwhdB.js +0 -146
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { $ as e,
|
|
2
|
-
import { t as
|
|
1
|
+
import { $ as e, Gt as t, J as n, Kt as r, L as i, Tt as a, Z as o, a as s, ct as c, et as l, ft as u, i as d, it as f, lt as p, n as m, nt as h, o as g, ot as _, qt as v, r as y, s as b, st as x, t as S } from "./FormField-Bj43PjHH.js";
|
|
2
|
+
import { t as C } from "./button-PJdZDEA8.js";
|
|
3
3
|
import { t as ee } from "./useTranslation-u1Lygbup.js";
|
|
4
|
-
import { t as
|
|
5
|
-
import
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { router as
|
|
4
|
+
import { t as w } from "./utils-DXlQmFY8.js";
|
|
5
|
+
import T, { useCallback as E, useEffect as D, useMemo as O, useRef as k, useState as A } from "react";
|
|
6
|
+
import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
7
|
+
import { router as P } from "@inertiajs/core";
|
|
8
8
|
//#region node_modules/react-hook-form/dist/index.esm.mjs
|
|
9
|
-
var
|
|
9
|
+
var F = (e) => e.type === "checkbox", I = (e) => e instanceof Date, L = (e) => e == null, te = (e) => typeof e == "object", R = (e) => !L(e) && !Array.isArray(e) && te(e) && !I(e), ne = (e) => R(e) && e.target ? F(e.target) ? e.target.checked : e.target.value : e, re = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), ie = (e) => {
|
|
10
10
|
let t = e.constructor && e.constructor.prototype;
|
|
11
|
-
return
|
|
11
|
+
return R(t) && t.hasOwnProperty("isPrototypeOf");
|
|
12
12
|
}, ae = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
13
|
-
function
|
|
13
|
+
function z(e) {
|
|
14
14
|
if (e instanceof Date) return new Date(e);
|
|
15
15
|
let t = typeof FileList < "u" && e instanceof FileList;
|
|
16
16
|
if (ae && (e instanceof Blob || t)) return e;
|
|
17
17
|
let n = Array.isArray(e);
|
|
18
|
-
if (!n && !(
|
|
18
|
+
if (!n && !(R(e) && ie(e))) return e;
|
|
19
19
|
let r = n ? [] : Object.create(Object.getPrototypeOf(e));
|
|
20
|
-
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] =
|
|
20
|
+
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = z(e[t]));
|
|
21
21
|
return r;
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
if (!t || !
|
|
25
|
-
let r = (
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
let r = -1, i =
|
|
23
|
+
var B = (e) => /^\w*$/.test(e), V = (e) => e === void 0, H = (e) => Array.isArray(e) ? e.filter(Boolean) : [], U = (e) => H(e.replace(/["|']|\]/g, "").split(/\.|\[/)), W = (e, t, n) => {
|
|
24
|
+
if (!t || !R(e)) return n;
|
|
25
|
+
let r = (B(t) ? [t] : U(t)).reduce((e, t) => L(e) ? void 0 : e[t], e);
|
|
26
|
+
return V(r) || r === e ? V(e[t]) ? n : e[t] : r;
|
|
27
|
+
}, G = (e) => typeof e == "boolean", K = (e) => typeof e == "function", q = (e, t, n) => {
|
|
28
|
+
let r = -1, i = B(t) ? [t] : U(t), a = i.length, o = a - 1;
|
|
29
29
|
for (; ++r < a;) {
|
|
30
30
|
let t = i[r], a = n;
|
|
31
31
|
if (r !== o) {
|
|
32
32
|
let n = e[t];
|
|
33
|
-
a =
|
|
33
|
+
a = R(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
|
|
34
34
|
}
|
|
35
35
|
if (t === "__proto__" || t === "constructor" || t === "prototype") return;
|
|
36
36
|
e[t] = a, e = e[t];
|
|
37
37
|
}
|
|
38
|
-
},
|
|
38
|
+
}, oe = {
|
|
39
39
|
BLUR: "blur",
|
|
40
40
|
FOCUS_OUT: "focusout",
|
|
41
41
|
CHANGE: "change",
|
|
42
42
|
SUBMIT: "submit",
|
|
43
43
|
TRIGGER: "trigger",
|
|
44
44
|
VALID: "valid"
|
|
45
|
-
},
|
|
45
|
+
}, J = {
|
|
46
46
|
onBlur: "onBlur",
|
|
47
47
|
onChange: "onChange",
|
|
48
48
|
onSubmit: "onSubmit",
|
|
49
49
|
onTouched: "onTouched",
|
|
50
50
|
all: "all"
|
|
51
|
-
},
|
|
51
|
+
}, Y = {
|
|
52
52
|
max: "max",
|
|
53
53
|
min: "min",
|
|
54
54
|
maxLength: "maxLength",
|
|
@@ -56,20 +56,20 @@ var z = (e) => /^\w*$/.test(e), B = (e) => e === void 0, V = (e) => Array.isArra
|
|
|
56
56
|
pattern: "pattern",
|
|
57
57
|
required: "required",
|
|
58
58
|
validate: "validate"
|
|
59
|
-
}, se = "form", ce = "root", le =
|
|
59
|
+
}, se = "form", ce = "root", le = T.createContext(null);
|
|
60
60
|
le.displayName = "HookFormControlContext";
|
|
61
|
-
var ue = () =>
|
|
61
|
+
var ue = () => T.useContext(le), de = (e, t, n, r = !0) => {
|
|
62
62
|
let i = {};
|
|
63
63
|
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
64
64
|
let i = a;
|
|
65
|
-
return t._proxyFormState[i] !==
|
|
65
|
+
return t._proxyFormState[i] !== J.all && (t._proxyFormState[i] = !r || J.all), n && (n[i] = !0), e[i];
|
|
66
66
|
} });
|
|
67
67
|
return i;
|
|
68
|
-
}, fe = typeof window < "u" ?
|
|
68
|
+
}, fe = typeof window < "u" ? T.useLayoutEffect : T.useEffect, X = (e) => typeof e == "string", pe = (e, t, n, r, i) => X(e) ? (r && t.watch.add(e), W(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), W(n, e))) : (r && (t.watchAll = !0), n), me = (e) => L(e) || !te(e);
|
|
69
69
|
function Z(e, t, n = /* @__PURE__ */ new WeakSet()) {
|
|
70
70
|
if (e === t) return !0;
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
71
|
+
if (me(e) || me(t)) return Object.is(e, t);
|
|
72
|
+
if (I(e) && I(t)) return Object.is(e.getTime(), t.getTime());
|
|
73
73
|
let r = Object.keys(e), i = Object.keys(t);
|
|
74
74
|
if (r.length !== i.length) return !1;
|
|
75
75
|
if (n.has(e) || n.has(t)) return !0;
|
|
@@ -79,25 +79,25 @@ function Z(e, t, n = /* @__PURE__ */ new WeakSet()) {
|
|
|
79
79
|
if (!(i in t)) return !1;
|
|
80
80
|
if (i !== "ref") {
|
|
81
81
|
let e = t[i];
|
|
82
|
-
if (
|
|
82
|
+
if (I(r) && I(e) || (R(r) || Array.isArray(r)) && (R(e) || Array.isArray(e)) ? !Z(r, e, n) : !Object.is(r, e)) return !1;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
return !0;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
let t = ue(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c =
|
|
87
|
+
function he(e) {
|
|
88
|
+
let t = ue(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = T.useRef(i), l = T.useRef(s), u = T.useRef(void 0), d = T.useRef(n), f = T.useRef(r);
|
|
89
89
|
l.current = s;
|
|
90
|
-
let [p, m] =
|
|
90
|
+
let [p, m] = T.useState(() => {
|
|
91
91
|
let e = n._getWatch(r, c.current);
|
|
92
92
|
return l.current ? l.current(e) : e;
|
|
93
|
-
}), h =
|
|
93
|
+
}), h = T.useCallback((e) => {
|
|
94
94
|
let t = pe(r, n._names, e || n._formValues, !1, c.current);
|
|
95
95
|
return l.current ? l.current(t) : t;
|
|
96
96
|
}, [
|
|
97
97
|
n._formValues,
|
|
98
98
|
n._names,
|
|
99
99
|
r
|
|
100
|
-
]), g =
|
|
100
|
+
]), g = T.useCallback((e) => {
|
|
101
101
|
if (!a) {
|
|
102
102
|
let t = pe(r, n._names, e || n._formValues, !1, c.current);
|
|
103
103
|
if (l.current) {
|
|
@@ -123,8 +123,8 @@ function me(e) {
|
|
|
123
123
|
o,
|
|
124
124
|
r,
|
|
125
125
|
g
|
|
126
|
-
]),
|
|
127
|
-
let _ = d.current !== n, v = f.current, y =
|
|
126
|
+
]), T.useEffect(() => n._removeUnmounted());
|
|
127
|
+
let _ = d.current !== n, v = f.current, y = T.useMemo(() => {
|
|
128
128
|
if (a) return null;
|
|
129
129
|
let e = !_ && !Z(v, r);
|
|
130
130
|
return _ || e ? h() : null;
|
|
@@ -137,15 +137,15 @@ function me(e) {
|
|
|
137
137
|
]);
|
|
138
138
|
return y === null ? p : y;
|
|
139
139
|
}
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
var
|
|
140
|
+
var ge = T.createContext(null);
|
|
141
|
+
ge.displayName = "HookFormContext";
|
|
142
|
+
var _e = (e, t, n, r, i) => t ? {
|
|
143
143
|
...n[e],
|
|
144
144
|
types: {
|
|
145
145
|
...n[e] && n[e].types ? n[e].types : {},
|
|
146
146
|
[r]: i || !0
|
|
147
147
|
}
|
|
148
|
-
} : {},
|
|
148
|
+
} : {}, ve = (e) => Array.isArray(e) ? e : [e], ye = () => {
|
|
149
149
|
let e = [];
|
|
150
150
|
return {
|
|
151
151
|
get observers() {
|
|
@@ -162,26 +162,26 @@ var ge = (e, t, n, r, i) => t ? {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
};
|
|
165
|
-
function
|
|
165
|
+
function be(e, t) {
|
|
166
166
|
let n = {};
|
|
167
167
|
for (let r in e) if (e.hasOwnProperty(r)) {
|
|
168
168
|
let i = e[r], a = t[r];
|
|
169
|
-
if (i &&
|
|
170
|
-
let e =
|
|
171
|
-
|
|
169
|
+
if (i && R(i) && a) {
|
|
170
|
+
let e = be(i, a);
|
|
171
|
+
R(e) && (n[r] = e);
|
|
172
172
|
} else e[r] && (n[r] = a);
|
|
173
173
|
}
|
|
174
174
|
return n;
|
|
175
175
|
}
|
|
176
|
-
var Q = (e) =>
|
|
176
|
+
var Q = (e) => R(e) && !Object.keys(e).length, xe = (e) => e.type === "file", Se = (e) => {
|
|
177
177
|
if (!ae) return !1;
|
|
178
178
|
let t = e ? e.ownerDocument : 0;
|
|
179
179
|
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
180
|
-
},
|
|
181
|
-
function
|
|
180
|
+
}, Ce = (e) => e.type === "select-multiple", we = (e) => e.type === "radio", Te = (e) => we(e) || F(e), Ee = (e) => Se(e) && e.isConnected;
|
|
181
|
+
function De(e, t) {
|
|
182
182
|
let n = t.slice(0, -1).length, r = 0;
|
|
183
183
|
for (; r < n;) {
|
|
184
|
-
if (
|
|
184
|
+
if (L(e)) {
|
|
185
185
|
e = void 0;
|
|
186
186
|
break;
|
|
187
187
|
}
|
|
@@ -189,65 +189,65 @@ function Ee(e, t) {
|
|
|
189
189
|
}
|
|
190
190
|
return e;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
for (let t in e) if (e.hasOwnProperty(t) && !
|
|
192
|
+
function Oe(e) {
|
|
193
|
+
for (let t in e) if (e.hasOwnProperty(t) && !V(e[t])) return !1;
|
|
194
194
|
return !0;
|
|
195
195
|
}
|
|
196
196
|
function $(e, t) {
|
|
197
|
-
if (
|
|
198
|
-
let n = Array.isArray(t) ? t :
|
|
199
|
-
return r && delete r[a], i !== 0 && (
|
|
197
|
+
if (X(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
|
|
198
|
+
let n = Array.isArray(t) ? t : B(t) ? [t] : U(t), r = n.length === 1 ? e : De(e, n), i = n.length - 1, a = n[i];
|
|
199
|
+
return r && delete r[a], i !== 0 && (R(r) && Q(r) || Array.isArray(r) && Oe(r)) && $(e, n.slice(0, -1)), e;
|
|
200
200
|
}
|
|
201
|
-
var
|
|
202
|
-
for (let t in e) if (
|
|
201
|
+
var ke = (e) => {
|
|
202
|
+
for (let t in e) if (K(e[t])) return !0;
|
|
203
203
|
return !1;
|
|
204
204
|
};
|
|
205
|
-
function
|
|
206
|
-
return Array.isArray(e) ||
|
|
205
|
+
function Ae(e) {
|
|
206
|
+
return Array.isArray(e) || R(e) && !ke(e);
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function je(e, t = {}) {
|
|
209
209
|
for (let n in e) {
|
|
210
210
|
let r = e[n];
|
|
211
|
-
|
|
211
|
+
Ae(r) ? (t[n] = Array.isArray(r) ? [] : {}, je(r, t[n])) : V(r) || (t[n] = !0);
|
|
212
212
|
}
|
|
213
213
|
return t;
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function Me(e) {
|
|
216
216
|
if (e !== !1) {
|
|
217
217
|
if (e === !0) return !0;
|
|
218
218
|
if (Array.isArray(e)) {
|
|
219
|
-
let t = e.map((e) =>
|
|
219
|
+
let t = e.map((e) => Me(e));
|
|
220
220
|
return t.some((e) => e !== void 0) ? t : void 0;
|
|
221
221
|
}
|
|
222
|
-
if (
|
|
222
|
+
if (R(e)) {
|
|
223
223
|
let t = {};
|
|
224
224
|
for (let n in e) {
|
|
225
|
-
let r =
|
|
226
|
-
|
|
225
|
+
let r = Me(e[n]);
|
|
226
|
+
V(r) || (t[n] = r);
|
|
227
227
|
}
|
|
228
228
|
return Object.keys(t).length ? t : void 0;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
n ||=
|
|
232
|
+
function Ne(e, t, n) {
|
|
233
|
+
n ||= je(t);
|
|
234
234
|
for (let r in e) {
|
|
235
235
|
let i = e[r];
|
|
236
|
-
if (
|
|
236
|
+
if (Ae(i)) V(t) || me(n[r]) ? n[r] = je(i, Array.isArray(i) ? [] : {}) : Ne(i, L(t) ? {} : t[r], n[r]);
|
|
237
237
|
else {
|
|
238
238
|
let e = t[r];
|
|
239
239
|
n[r] = !Z(i, e);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
return
|
|
242
|
+
return Me(n) || {};
|
|
243
243
|
}
|
|
244
|
-
var
|
|
244
|
+
var Pe = {
|
|
245
245
|
value: !1,
|
|
246
246
|
isValid: !1
|
|
247
|
-
},
|
|
247
|
+
}, Fe = {
|
|
248
248
|
value: !0,
|
|
249
249
|
isValid: !0
|
|
250
|
-
},
|
|
250
|
+
}, Ie = (e) => {
|
|
251
251
|
if (Array.isArray(e)) {
|
|
252
252
|
if (e.length > 1) {
|
|
253
253
|
let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
@@ -256,28 +256,28 @@ var Ne = {
|
|
|
256
256
|
isValid: !!t.length
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
return e[0].checked && !e[0].disabled ? e[0].attributes && !
|
|
259
|
+
return e[0].checked && !e[0].disabled ? e[0].attributes && !V(e[0].attributes.value) ? V(e[0].value) || e[0].value === "" ? Fe : {
|
|
260
260
|
value: e[0].value,
|
|
261
261
|
isValid: !0
|
|
262
|
-
} :
|
|
262
|
+
} : Fe : Pe;
|
|
263
263
|
}
|
|
264
|
-
return
|
|
265
|
-
},
|
|
264
|
+
return Pe;
|
|
265
|
+
}, Le = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => V(e) ? e : t ? e === "" ? NaN : e && +e : n && X(e) ? new Date(e) : r ? r(e) : e, Re = {
|
|
266
266
|
isValid: !1,
|
|
267
267
|
value: null
|
|
268
|
-
},
|
|
268
|
+
}, ze = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
|
|
269
269
|
isValid: !0,
|
|
270
270
|
value: t.value
|
|
271
|
-
} : e,
|
|
272
|
-
function
|
|
271
|
+
} : e, Re) : Re;
|
|
272
|
+
function Be(e) {
|
|
273
273
|
let t = e.ref;
|
|
274
|
-
return
|
|
274
|
+
return xe(t) ? t.files : we(t) ? ze(e.refs).value : Ce(t) ? [...t.selectedOptions].map(({ value: e }) => e) : F(t) ? Ie(e.refs).value : Le(V(t.value) ? e.ref.value : t.value, e);
|
|
275
275
|
}
|
|
276
|
-
var
|
|
276
|
+
var Ve = (e, t, n, r) => {
|
|
277
277
|
let i = {};
|
|
278
278
|
for (let n of e) {
|
|
279
|
-
let e =
|
|
280
|
-
e &&
|
|
279
|
+
let e = W(t, n);
|
|
280
|
+
e && q(i, n, e._f);
|
|
281
281
|
}
|
|
282
282
|
return {
|
|
283
283
|
criteriaMode: n,
|
|
@@ -285,33 +285,33 @@ var Be = (e, t, n, r) => {
|
|
|
285
285
|
fields: i,
|
|
286
286
|
shouldUseNativeValidation: r
|
|
287
287
|
};
|
|
288
|
-
},
|
|
289
|
-
isOnSubmit: !e || e ===
|
|
290
|
-
isOnBlur: e ===
|
|
291
|
-
isOnChange: e ===
|
|
292
|
-
isOnAll: e ===
|
|
293
|
-
isOnTouch: e ===
|
|
294
|
-
}),
|
|
288
|
+
}, He = (e) => e instanceof RegExp, Ue = (e) => V(e) ? e : He(e) ? e.source : R(e) ? He(e.value) ? e.value.source : e.value : e, We = (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
|
+
}), Ge = "AsyncFunction", Ke = (e) => !!e && !!e.validate && !!(K(e.validate) && e.validate.constructor.name === Ge || R(e.validate) && Object.values(e.validate).find((e) => e.constructor.name === Ge)), qe = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Je = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(t) && /^\.\w+/.test(e.slice(t.length)))), Ye = (e, t, n, r) => {
|
|
295
295
|
for (let i of n || Object.keys(e)) {
|
|
296
|
-
let n =
|
|
296
|
+
let n = W(e, i);
|
|
297
297
|
if (n) {
|
|
298
298
|
let { _f: e, ...a } = n;
|
|
299
299
|
if (e) {
|
|
300
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 (
|
|
302
|
-
} else if (
|
|
301
|
+
if (Ye(a, t)) break;
|
|
302
|
+
} else if (R(a) && Ye(a, t)) break;
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
|
-
function
|
|
307
|
-
let r =
|
|
308
|
-
if (r ||
|
|
306
|
+
function Xe(e, t, n) {
|
|
307
|
+
let r = W(e, n);
|
|
308
|
+
if (r || B(n)) return {
|
|
309
309
|
error: r,
|
|
310
310
|
name: n
|
|
311
311
|
};
|
|
312
312
|
let i = n.split(".");
|
|
313
313
|
for (; i.length;) {
|
|
314
|
-
let r = i.join("."), a =
|
|
314
|
+
let r = i.join("."), a = W(t, r), o = W(e, r);
|
|
315
315
|
if (a && !Array.isArray(a) && n !== r) return { name: n };
|
|
316
316
|
if (o && o.type) return {
|
|
317
317
|
name: r,
|
|
@@ -325,30 +325,30 @@ function Ye(e, t, n) {
|
|
|
325
325
|
}
|
|
326
326
|
return { name: n };
|
|
327
327
|
}
|
|
328
|
-
var
|
|
328
|
+
var Ze = (e, t, n, r) => {
|
|
329
329
|
n(e);
|
|
330
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 ||
|
|
332
|
-
},
|
|
333
|
-
let r =
|
|
334
|
-
return
|
|
331
|
+
return Q(a) || r && Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((e) => t[e] === (!r || J.all));
|
|
332
|
+
}, Qe = (e, t, n) => !e || !t || e === t || ve(e).some((e) => e && (n ? e === t : e.startsWith(t) || t.startsWith(e))), $e = (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, et = (e, t) => !H(W(e, t)).length && $(e, t), tt = (e, t, n) => {
|
|
333
|
+
let r = ve(W(e, n));
|
|
334
|
+
return q(r, ce, t[n]), q(e, n, r), e;
|
|
335
335
|
};
|
|
336
|
-
function
|
|
337
|
-
if (
|
|
336
|
+
function nt(e, t, n = "validate") {
|
|
337
|
+
if (X(e) || Array.isArray(e) && e.every(X) || G(e) && !e) return {
|
|
338
338
|
type: n,
|
|
339
|
-
message:
|
|
339
|
+
message: X(e) ? e : "",
|
|
340
340
|
ref: t
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
var
|
|
343
|
+
var rt = (e) => R(e) && !He(e) ? e : {
|
|
344
344
|
value: e,
|
|
345
345
|
message: ""
|
|
346
|
-
},
|
|
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 =
|
|
346
|
+
}, it = 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 = W(n, h);
|
|
348
348
|
if (!_ || t.has(h)) return {};
|
|
349
349
|
let y = s ? s[0] : o, b = (e) => {
|
|
350
|
-
i && y.reportValidity && (y.setCustomValidity(
|
|
351
|
-
}, x = {}, S =
|
|
350
|
+
i && y.reportValidity && (y.setCustomValidity(G(e) ? "" : e || ""), y.reportValidity());
|
|
351
|
+
}, x = {}, S = we(o), C = F(o), ee = S || C, w = (g || xe(o)) && V(o.value) && V(v) || Se(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), T = _e.bind(null, h, r, x), E = (e, t, n, r = Y.maxLength, i = Y.minLength) => {
|
|
352
352
|
let a = e ? t : n;
|
|
353
353
|
x[h] = {
|
|
354
354
|
type: e ? r : i,
|
|
@@ -357,54 +357,54 @@ var nt = (e) => L(e) && !Ve(e) ? e : {
|
|
|
357
357
|
...T(e ? r : i, a)
|
|
358
358
|
};
|
|
359
359
|
};
|
|
360
|
-
if (a ? !Array.isArray(v) || !v.length : c && (!
|
|
361
|
-
let { value: e, message: t } =
|
|
360
|
+
if (a ? !Array.isArray(v) || !v.length : c && (!ee && (w || L(v)) || G(v) && !v || C && !Ie(s).isValid || S && !ze(s).isValid)) {
|
|
361
|
+
let { value: e, message: t } = X(c) ? {
|
|
362
362
|
value: !!c,
|
|
363
363
|
message: c
|
|
364
|
-
} :
|
|
364
|
+
} : rt(c);
|
|
365
365
|
if (e && (x[h] = {
|
|
366
|
-
type:
|
|
366
|
+
type: Y.required,
|
|
367
367
|
message: t,
|
|
368
368
|
ref: y,
|
|
369
|
-
...T(
|
|
369
|
+
...T(Y.required, t)
|
|
370
370
|
}, !r)) return b(t), x;
|
|
371
371
|
}
|
|
372
|
-
if (!w && (!
|
|
373
|
-
let e, t, n =
|
|
374
|
-
if (!
|
|
372
|
+
if (!w && (!L(d) || !L(f))) {
|
|
373
|
+
let e, t, n = rt(f), i = rt(d);
|
|
374
|
+
if (!L(v) && !isNaN(v)) {
|
|
375
375
|
let r = o.valueAsNumber || v && +v;
|
|
376
|
-
|
|
376
|
+
L(n.value) || (e = r > n.value), L(i.value) || (t = r < i.value);
|
|
377
377
|
} else {
|
|
378
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
|
-
|
|
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
380
|
}
|
|
381
|
-
if ((e || t) && (E(!!e, n.message, i.message,
|
|
381
|
+
if ((e || t) && (E(!!e, n.message, i.message, Y.max, Y.min), !r)) return b(x[h].message), x;
|
|
382
382
|
}
|
|
383
|
-
if ((l || u) && !w && (
|
|
384
|
-
let e =
|
|
383
|
+
if ((l || u) && !w && (X(v) || a && Array.isArray(v))) {
|
|
384
|
+
let e = rt(l), t = rt(u), n = !L(e.value) && v.length > +e.value, i = !L(t.value) && v.length < +t.value;
|
|
385
385
|
if ((n || i) && (E(n, e.message, t.message), !r)) return b(x[h].message), x;
|
|
386
386
|
}
|
|
387
|
-
if (p && !w &&
|
|
388
|
-
let { value: e, message: t } =
|
|
389
|
-
if (
|
|
390
|
-
type:
|
|
387
|
+
if (p && !w && X(v)) {
|
|
388
|
+
let { value: e, message: t } = rt(p);
|
|
389
|
+
if (He(e) && !v.match(e) && (x[h] = {
|
|
390
|
+
type: Y.pattern,
|
|
391
391
|
message: t,
|
|
392
392
|
ref: o,
|
|
393
|
-
...T(
|
|
393
|
+
...T(Y.pattern, t)
|
|
394
394
|
}, !r)) return b(t), x;
|
|
395
395
|
}
|
|
396
396
|
if (m) {
|
|
397
|
-
if (
|
|
398
|
-
let e =
|
|
397
|
+
if (K(m)) {
|
|
398
|
+
let e = nt(await m(v, n), y);
|
|
399
399
|
if (e && (x[h] = {
|
|
400
400
|
...e,
|
|
401
|
-
...T(
|
|
401
|
+
...T(Y.validate, e.message)
|
|
402
402
|
}, !r)) return b(e.message), x;
|
|
403
|
-
} else if (
|
|
403
|
+
} else if (R(m)) {
|
|
404
404
|
let e = {};
|
|
405
405
|
for (let t in m) {
|
|
406
406
|
if (!Q(e) && !r) break;
|
|
407
|
-
let i =
|
|
407
|
+
let i = nt(await m[t](v, n), y, t);
|
|
408
408
|
i && (e = {
|
|
409
409
|
...i,
|
|
410
410
|
...T(t, i.message)
|
|
@@ -417,11 +417,11 @@ var nt = (e) => L(e) && !Ve(e) ? e : {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
return b(!0), x;
|
|
420
|
-
}, it = {
|
|
421
|
-
mode: q.onSubmit,
|
|
422
|
-
reValidateMode: q.onChange,
|
|
423
|
-
shouldFocusError: !0
|
|
424
420
|
}, at = {
|
|
421
|
+
mode: J.onSubmit,
|
|
422
|
+
reValidateMode: J.onChange,
|
|
423
|
+
shouldFocusError: !0
|
|
424
|
+
}, ot = {
|
|
425
425
|
submitCount: 0,
|
|
426
426
|
isDirty: !1,
|
|
427
427
|
isReady: !1,
|
|
@@ -434,16 +434,16 @@ var nt = (e) => L(e) && !Ve(e) ? e : {
|
|
|
434
434
|
dirtyFields: {},
|
|
435
435
|
validatingFields: {}
|
|
436
436
|
};
|
|
437
|
-
function
|
|
437
|
+
function st(e = {}) {
|
|
438
438
|
let t = {
|
|
439
|
-
...
|
|
439
|
+
...at,
|
|
440
440
|
...e
|
|
441
441
|
}, n = {
|
|
442
|
-
...
|
|
443
|
-
isLoading:
|
|
442
|
+
...z(ot),
|
|
443
|
+
isLoading: K(t.defaultValues),
|
|
444
444
|
errors: t.errors || {},
|
|
445
445
|
disabled: t.disabled || !1
|
|
446
|
-
}, r = {}, i = (
|
|
446
|
+
}, r = {}, i = (R(t.defaultValues) || R(t.values)) && z(t.defaultValues || t.values) || {}, a = t.shouldUnregister ? {} : z(i), o = {
|
|
447
447
|
action: !1,
|
|
448
448
|
mount: !1,
|
|
449
449
|
watch: !1,
|
|
@@ -464,9 +464,9 @@ function ot(e = {}) {
|
|
|
464
464
|
isValid: !1,
|
|
465
465
|
errors: !1
|
|
466
466
|
}, d = { ...u }, f = { ...d }, p = {
|
|
467
|
-
array:
|
|
468
|
-
state:
|
|
469
|
-
}, m = t.criteriaMode ===
|
|
467
|
+
array: ye(),
|
|
468
|
+
state: ye()
|
|
469
|
+
}, m = t.criteriaMode === J.all, h = (e) => (t) => {
|
|
470
470
|
clearTimeout(l), l = setTimeout(e, t);
|
|
471
471
|
}, g = async (e) => {
|
|
472
472
|
if (!o.keepIsValid && !t.disabled && (d.isValid || f.isValid || e)) {
|
|
@@ -474,31 +474,31 @@ function ot(e = {}) {
|
|
|
474
474
|
t.resolver ? (e = Q((await w()).errors), _()) : e = await D({
|
|
475
475
|
fields: r,
|
|
476
476
|
onlyCheckValid: !0,
|
|
477
|
-
eventType:
|
|
477
|
+
eventType: oe.VALID
|
|
478
478
|
}), e !== n.isValid && p.state.next({ isValid: e });
|
|
479
479
|
}
|
|
480
480
|
}, _ = (e, r) => {
|
|
481
481
|
!t.disabled && (d.isValidating || d.validatingFields || f.isValidating || f.validatingFields) && ((e || Array.from(s.mount)).forEach((e) => {
|
|
482
|
-
e && (r ?
|
|
482
|
+
e && (r ? q(n.validatingFields, e, r) : $(n.validatingFields, e));
|
|
483
483
|
}), p.state.next({
|
|
484
484
|
validatingFields: n.validatingFields,
|
|
485
485
|
isValidating: !Q(n.validatingFields)
|
|
486
486
|
}));
|
|
487
487
|
}, v = () => {
|
|
488
|
-
n.dirtyFields =
|
|
488
|
+
n.dirtyFields = Ne(i, a);
|
|
489
489
|
}, y = (e, i = [], s, c, l = !0, u = !0) => {
|
|
490
490
|
if (c && s && !t.disabled) {
|
|
491
|
-
if (o.action = !0, u && Array.isArray(
|
|
492
|
-
let t = s(
|
|
493
|
-
l &&
|
|
491
|
+
if (o.action = !0, u && Array.isArray(W(r, e))) {
|
|
492
|
+
let t = s(W(r, e), c.argA, c.argB);
|
|
493
|
+
l && q(r, e, t);
|
|
494
494
|
}
|
|
495
|
-
if (u && Array.isArray(
|
|
496
|
-
let t = s(
|
|
497
|
-
l &&
|
|
495
|
+
if (u && Array.isArray(W(n.errors, e))) {
|
|
496
|
+
let t = s(W(n.errors, e), c.argA, c.argB);
|
|
497
|
+
l && q(n.errors, e, t), et(n.errors, e);
|
|
498
498
|
}
|
|
499
|
-
if ((d.touchedFields || f.touchedFields) && u && Array.isArray(
|
|
500
|
-
let t = s(
|
|
501
|
-
l &&
|
|
499
|
+
if ((d.touchedFields || f.touchedFields) && u && Array.isArray(W(n.touchedFields, e))) {
|
|
500
|
+
let t = s(W(n.touchedFields, e), c.argA, c.argB);
|
|
501
|
+
l && q(n.touchedFields, e, t);
|
|
502
502
|
}
|
|
503
503
|
(d.dirtyFields || f.dirtyFields) && v(), p.state.next({
|
|
504
504
|
name: e,
|
|
@@ -507,41 +507,41 @@ function ot(e = {}) {
|
|
|
507
507
|
errors: n.errors,
|
|
508
508
|
isValid: n.isValid
|
|
509
509
|
});
|
|
510
|
-
} else
|
|
510
|
+
} else q(a, e, i);
|
|
511
511
|
}, b = (e, t) => {
|
|
512
|
-
|
|
512
|
+
q(n.errors, e, t), p.state.next({ errors: n.errors });
|
|
513
513
|
}, x = (e) => {
|
|
514
514
|
n.errors = e, p.state.next({
|
|
515
515
|
errors: n.errors,
|
|
516
516
|
isValid: !1
|
|
517
517
|
});
|
|
518
518
|
}, S = (e, t, s, c) => {
|
|
519
|
-
let l =
|
|
519
|
+
let l = W(r, e);
|
|
520
520
|
if (l) {
|
|
521
|
-
let r =
|
|
522
|
-
|
|
521
|
+
let r = V(W(a, e)), u = W(a, e, V(s) ? W(i, e) : s);
|
|
522
|
+
V(u) || c && c.defaultChecked || t ? q(a, e, t ? u : Be(l._f)) : M(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (k() || (n.isDirty = !1, p.state.next({ ...n }))));
|
|
523
523
|
}
|
|
524
|
-
},
|
|
524
|
+
}, C = (e, r, a, o, s) => {
|
|
525
525
|
let c = !1, l = !1, u = { name: e };
|
|
526
526
|
if (!t.disabled) {
|
|
527
527
|
if (!a || o) {
|
|
528
528
|
(d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = k(), c = l !== u.isDirty);
|
|
529
|
-
let t = Z(
|
|
530
|
-
l = !!
|
|
529
|
+
let t = Z(W(i, e), r);
|
|
530
|
+
l = !!W(n.dirtyFields, e), t ? $(n.dirtyFields, e) : q(n.dirtyFields, e, !0), u.dirtyFields = n.dirtyFields, c ||= (d.dirtyFields || f.dirtyFields) && l !== !t;
|
|
531
531
|
}
|
|
532
532
|
if (a) {
|
|
533
|
-
let t =
|
|
534
|
-
t || (
|
|
533
|
+
let t = W(n.touchedFields, e);
|
|
534
|
+
t || (q(n.touchedFields, e, a), u.touchedFields = n.touchedFields, c ||= (d.touchedFields || f.touchedFields) && t !== a);
|
|
535
535
|
}
|
|
536
536
|
c && s && p.state.next(u);
|
|
537
537
|
}
|
|
538
538
|
return c ? u : {};
|
|
539
|
-
},
|
|
540
|
-
let o =
|
|
541
|
-
if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ?
|
|
539
|
+
}, ee = (e, r, i, a) => {
|
|
540
|
+
let o = W(n.errors, e), s = (d.isValid || f.isValid) && G(r) && n.isValid !== r;
|
|
541
|
+
if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? q(n.errors, e, i) : $(n.errors, e)), (i ? !Z(o, i) : o) || !Q(a) || s) {
|
|
542
542
|
let t = {
|
|
543
543
|
...a,
|
|
544
|
-
...s &&
|
|
544
|
+
...s && G(r) ? { isValid: r } : {},
|
|
545
545
|
errors: n.errors,
|
|
546
546
|
name: e
|
|
547
547
|
};
|
|
@@ -550,11 +550,11 @@ function ot(e = {}) {
|
|
|
550
550
|
...t
|
|
551
551
|
}, p.state.next(t);
|
|
552
552
|
}
|
|
553
|
-
}, w = async (e) => (_(e, !0), await t.resolver(a, t.context,
|
|
553
|
+
}, w = async (e) => (_(e, !0), await t.resolver(a, t.context, Ve(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), T = async (e) => {
|
|
554
554
|
let { errors: t } = await w(e);
|
|
555
555
|
if (_(e), e) for (let r of e) {
|
|
556
|
-
let e =
|
|
557
|
-
e ?
|
|
556
|
+
let e = W(t, r);
|
|
557
|
+
e ? q(n.errors, r, e) : $(n.errors, r);
|
|
558
558
|
}
|
|
559
559
|
else n.errors = t;
|
|
560
560
|
return t;
|
|
@@ -566,14 +566,14 @@ function ot(e = {}) {
|
|
|
566
566
|
name: t,
|
|
567
567
|
eventType: r
|
|
568
568
|
});
|
|
569
|
-
if (
|
|
570
|
-
message:
|
|
571
|
-
type:
|
|
569
|
+
if (R(i)) for (let e in i) i[e] && fe(`${se}.${e}`, {
|
|
570
|
+
message: X(i.message) ? i.message : "",
|
|
571
|
+
type: Y.validate
|
|
572
572
|
});
|
|
573
|
-
else
|
|
573
|
+
else X(i) || !i ? fe(se, {
|
|
574
574
|
message: i || "",
|
|
575
|
-
type:
|
|
576
|
-
}) :
|
|
575
|
+
type: Y.validate
|
|
576
|
+
}) : de(se);
|
|
577
577
|
return i;
|
|
578
578
|
}
|
|
579
579
|
return !0;
|
|
@@ -590,10 +590,10 @@ function ot(e = {}) {
|
|
|
590
590
|
if (u) {
|
|
591
591
|
let { _f: r, ...f } = u;
|
|
592
592
|
if (r) {
|
|
593
|
-
let o = s.array.has(r.name), c = u._f &&
|
|
593
|
+
let o = s.array.has(r.name), c = u._f && Ke(u._f);
|
|
594
594
|
c && d.validatingFields && _([r.name], !0);
|
|
595
|
-
let f = await
|
|
596
|
-
if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (
|
|
595
|
+
let f = await it(u, s.disabled, a, m, t.shouldUseNativeValidation && !i, o);
|
|
596
|
+
if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (W(f, r.name) ? o ? tt(n.errors, f, r.name) : q(n.errors, r.name, f[r.name]) : $(n.errors, r.name)), e.shouldUseNativeValidation && f[r.name])) break;
|
|
597
597
|
}
|
|
598
598
|
!Q(f) && await D({
|
|
599
599
|
context: l,
|
|
@@ -607,33 +607,33 @@ function ot(e = {}) {
|
|
|
607
607
|
return l.valid;
|
|
608
608
|
}, O = () => {
|
|
609
609
|
for (let e of s.unMount) {
|
|
610
|
-
let t =
|
|
611
|
-
t && (t._f.refs ? t._f.refs.every((e) => !
|
|
610
|
+
let t = W(r, e);
|
|
611
|
+
t && (t._f.refs ? t._f.refs.every((e) => !Ee(e)) : !Ee(t._f.ref)) && _e(e);
|
|
612
612
|
}
|
|
613
613
|
s.unMount = /* @__PURE__ */ new Set();
|
|
614
|
-
}, k = (e, n) => !t.disabled && (e && n &&
|
|
615
|
-
let i =
|
|
614
|
+
}, k = (e, n) => !t.disabled && (e && n && q(a, e, n), !Z(le(), i)), A = (e, t, n) => pe(e, s, { ...o.mount ? a : V(t) ? i : X(e) ? { [e]: t } : t }, n, t), j = (e) => H(W(o.mount ? a : i, e, t.shouldUnregister ? W(i, e, []) : [])), M = (e, t, n = {}) => {
|
|
615
|
+
let i = W(r, e), o = t;
|
|
616
616
|
if (i) {
|
|
617
617
|
let n = i._f;
|
|
618
|
-
n && (!n.disabled &&
|
|
618
|
+
n && (!n.disabled && q(a, e, Le(t, n)), o = Se(n.ref) && L(t) ? "" : t, Ce(n.ref) ? [...n.ref.options].forEach((e) => e.selected = o.includes(e.value)) : n.refs ? F(n.ref) ? n.refs.forEach((e) => {
|
|
619
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) :
|
|
620
|
+
}) : n.refs.forEach((e) => e.checked = e.value === o) : xe(n.ref) ? n.ref.value = "" : (n.ref.value = o, n.ref.type || p.state.next({
|
|
621
621
|
name: e,
|
|
622
|
-
values:
|
|
622
|
+
values: z(a)
|
|
623
623
|
})));
|
|
624
624
|
}
|
|
625
|
-
(n.shouldDirty || n.shouldTouch) &&
|
|
626
|
-
},
|
|
625
|
+
(n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && U(e);
|
|
626
|
+
}, N = (e, t, n) => {
|
|
627
627
|
for (let i in t) {
|
|
628
628
|
if (!t.hasOwnProperty(i)) return;
|
|
629
|
-
let a = t[i], o = e + "." + i, c =
|
|
630
|
-
(s.array.has(e) ||
|
|
629
|
+
let a = t[i], o = e + "." + i, c = W(r, o);
|
|
630
|
+
(s.array.has(e) || R(a) || c && !c._f) && !I(a) ? N(o, a, n) : M(o, a, n);
|
|
631
631
|
}
|
|
632
|
-
},
|
|
633
|
-
let c =
|
|
634
|
-
if (
|
|
632
|
+
}, P = (e, t, i = {}) => {
|
|
633
|
+
let c = W(r, e), l = s.array.has(e), u = z(t), m = Z(W(a, e), u);
|
|
634
|
+
if (q(a, e, u), l) p.array.next({
|
|
635
635
|
name: e,
|
|
636
|
-
values:
|
|
636
|
+
values: z(a)
|
|
637
637
|
}), (d.isDirty || d.dirtyFields || f.isDirty || f.dirtyFields) && i.shouldDirty && (v(), p.state.next({
|
|
638
638
|
name: e,
|
|
639
639
|
dirtyFields: n.dirtyFields,
|
|
@@ -641,18 +641,18 @@ function ot(e = {}) {
|
|
|
641
641
|
}));
|
|
642
642
|
else {
|
|
643
643
|
let t = Array.isArray(u) && !u.length || Q(u);
|
|
644
|
-
!c || c._f ||
|
|
644
|
+
!c || c._f || L(u) || t ? M(e, u, i) : N(e, u, i);
|
|
645
645
|
}
|
|
646
646
|
if (!m) {
|
|
647
|
-
let t =
|
|
647
|
+
let t = Je(e, s);
|
|
648
648
|
p.state.next({
|
|
649
649
|
...t && n,
|
|
650
650
|
name: o.mount || t ? e : void 0,
|
|
651
|
-
values:
|
|
651
|
+
values: z(a)
|
|
652
652
|
});
|
|
653
653
|
}
|
|
654
|
-
},
|
|
655
|
-
let t =
|
|
654
|
+
}, te = (e) => {
|
|
655
|
+
let t = K(e) ? e(a) : e;
|
|
656
656
|
Z(a, t) || (a = {
|
|
657
657
|
...a,
|
|
658
658
|
...t
|
|
@@ -660,19 +660,19 @@ function ot(e = {}) {
|
|
|
660
660
|
...n,
|
|
661
661
|
values: a
|
|
662
662
|
}));
|
|
663
|
-
},
|
|
663
|
+
}, ie = async (i) => {
|
|
664
664
|
o.mount = !0;
|
|
665
|
-
let l = i.target, u = l.name, h = !0, v =
|
|
666
|
-
h = Number.isNaN(e) ||
|
|
667
|
-
}, b =
|
|
665
|
+
let l = i.target, u = l.name, h = !0, v = W(r, u), y = (e) => {
|
|
666
|
+
h = Number.isNaN(e) || I(e) && isNaN(e.getTime()) || Z(e, W(a, u, e));
|
|
667
|
+
}, b = We(t.mode), x = We(t.reValidateMode);
|
|
668
668
|
if (v) {
|
|
669
|
-
let o, S, T = l.type ?
|
|
670
|
-
|
|
671
|
-
let j =
|
|
669
|
+
let o, S, T = l.type ? Be(v._f) : ne(i), O = i.type === oe.BLUR || i.type === oe.FOCUS_OUT, k = !qe(v._f) && !e.validate && !t.resolver && !W(n.errors, u) && !v._f.deps || $e(O, W(n.touchedFields, u), n.isSubmitted, x, b), A = Je(u, s, O);
|
|
670
|
+
q(a, u, T), O ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
|
|
671
|
+
let j = C(u, T, O), M = !Q(j) || A;
|
|
672
672
|
if (!O && p.state.next({
|
|
673
673
|
name: u,
|
|
674
674
|
type: i.type,
|
|
675
|
-
values:
|
|
675
|
+
values: z(a)
|
|
676
676
|
}), k) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? O && g() : O || g()), M && p.state.next({
|
|
677
677
|
name: u,
|
|
678
678
|
...A ? {} : j
|
|
@@ -683,60 +683,60 @@ function ot(e = {}) {
|
|
|
683
683
|
}), !O && A && p.state.next({ ...n }), t.resolver) {
|
|
684
684
|
let { errors: e } = await w([u]);
|
|
685
685
|
if (_([u]), y(T), h) {
|
|
686
|
-
let t =
|
|
686
|
+
let t = Xe(n.errors, r, u), i = Xe(e, r, t.name || u);
|
|
687
687
|
o = i.error, u = i.name, S = Q(e);
|
|
688
688
|
}
|
|
689
|
-
} else _([u], !0), o = (await
|
|
689
|
+
} else _([u], !0), o = (await it(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(T), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await D({
|
|
690
690
|
fields: r,
|
|
691
691
|
onlyCheckValid: !0,
|
|
692
692
|
name: u,
|
|
693
693
|
eventType: i.type
|
|
694
694
|
})));
|
|
695
|
-
h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) &&
|
|
695
|
+
h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && U(v._f.deps), ee(u, S, o, j));
|
|
696
696
|
}
|
|
697
|
-
},
|
|
698
|
-
if (
|
|
699
|
-
},
|
|
700
|
-
let a, o, c =
|
|
697
|
+
}, B = (e, t) => {
|
|
698
|
+
if (W(n.errors, t) && e.focus) return e.focus(), 1;
|
|
699
|
+
}, U = async (e, i = {}) => {
|
|
700
|
+
let a, o, c = ve(e);
|
|
701
701
|
if (t.resolver) {
|
|
702
|
-
let t = await T(
|
|
703
|
-
a = Q(t), o = e ? !c.some((e) =>
|
|
702
|
+
let t = await T(V(e) ? e : c);
|
|
703
|
+
a = Q(t), o = e ? !c.some((e) => W(t, e)) : a;
|
|
704
704
|
} else e ? (o = (await Promise.all(c.map(async (e) => {
|
|
705
|
-
let t =
|
|
705
|
+
let t = W(r, e);
|
|
706
706
|
return await D({
|
|
707
707
|
fields: t && t._f ? { [e]: t } : t,
|
|
708
|
-
eventType:
|
|
708
|
+
eventType: oe.TRIGGER
|
|
709
709
|
});
|
|
710
710
|
}))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await D({
|
|
711
711
|
fields: r,
|
|
712
712
|
name: e,
|
|
713
|
-
eventType:
|
|
713
|
+
eventType: oe.TRIGGER
|
|
714
714
|
});
|
|
715
715
|
return p.state.next({
|
|
716
|
-
...!
|
|
716
|
+
...!X(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
|
|
717
717
|
...t.resolver || !e ? { isValid: a } : {},
|
|
718
718
|
errors: n.errors
|
|
719
|
-
}), i.shouldFocus && !o &&
|
|
720
|
-
},
|
|
719
|
+
}), i.shouldFocus && !o && Ye(r, B, e ? c : s.mount), o;
|
|
720
|
+
}, le = (e, t) => {
|
|
721
721
|
let r = { ...o.mount ? a : i };
|
|
722
|
-
return t && (r =
|
|
723
|
-
},
|
|
724
|
-
invalid: !!
|
|
725
|
-
isDirty: !!
|
|
726
|
-
error:
|
|
727
|
-
isValidating: !!
|
|
728
|
-
isTouched: !!
|
|
729
|
-
}),
|
|
730
|
-
let t = e ?
|
|
722
|
+
return t && (r = be(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), V(e) ? r : X(e) ? W(r, e) : e.map((e) => W(r, e));
|
|
723
|
+
}, ue = (e, t) => ({
|
|
724
|
+
invalid: !!W((t || n).errors, e),
|
|
725
|
+
isDirty: !!W((t || n).dirtyFields, e),
|
|
726
|
+
error: W((t || n).errors, e),
|
|
727
|
+
isValidating: !!W(n.validatingFields, e),
|
|
728
|
+
isTouched: !!W((t || n).touchedFields, e)
|
|
729
|
+
}), de = (e) => {
|
|
730
|
+
let t = e ? ve(e) : void 0;
|
|
731
731
|
t?.forEach((e) => $(n.errors, e)), t ? t.forEach((e) => {
|
|
732
732
|
p.state.next({
|
|
733
733
|
name: e,
|
|
734
734
|
errors: n.errors
|
|
735
735
|
});
|
|
736
736
|
}) : p.state.next({ errors: {} });
|
|
737
|
-
},
|
|
738
|
-
let a = (
|
|
739
|
-
|
|
737
|
+
}, fe = (e, t, i) => {
|
|
738
|
+
let a = (W(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = W(n.errors, e) || {};
|
|
739
|
+
q(n.errors, e, {
|
|
740
740
|
...l,
|
|
741
741
|
...t,
|
|
742
742
|
ref: a
|
|
@@ -745,8 +745,8 @@ function ot(e = {}) {
|
|
|
745
745
|
errors: n.errors,
|
|
746
746
|
isValid: !1
|
|
747
747
|
}), i && i.shouldFocus && a && a.focus && a.focus();
|
|
748
|
-
}, me = (e, t) =>
|
|
749
|
-
if (
|
|
748
|
+
}, me = (e, t) => K(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || A(void 0, t), n) }) : A(e, t, !0), he = (e) => p.state.subscribe({ next: (t) => {
|
|
749
|
+
if (Qe(e.name, t.name, e.exact) && Ze(t, e.formState || d, Ie, e.reRenderRoot)) {
|
|
750
750
|
let r = { ...a };
|
|
751
751
|
e.callback({
|
|
752
752
|
values: r,
|
|
@@ -764,20 +764,20 @@ function ot(e = {}) {
|
|
|
764
764
|
...u,
|
|
765
765
|
...e.formState
|
|
766
766
|
}
|
|
767
|
-
})),
|
|
768
|
-
for (let c of e ?
|
|
769
|
-
p.state.next({ values:
|
|
767
|
+
})), _e = (e, o = {}) => {
|
|
768
|
+
for (let c of e ? ve(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: z(a) }), p.state.next({
|
|
770
770
|
...n,
|
|
771
771
|
...o.keepDirty ? { isDirty: k() } : {}
|
|
772
772
|
}), !o.keepIsValid && g();
|
|
773
|
-
},
|
|
774
|
-
if (
|
|
773
|
+
}, we = ({ disabled: e, name: t }) => {
|
|
774
|
+
if (G(e) && o.mount || e || s.disabled.has(t)) {
|
|
775
775
|
let n = s.disabled.has(t) !== !!e;
|
|
776
776
|
e ? s.disabled.add(t) : s.disabled.delete(t), n && o.mount && !o.action && g();
|
|
777
777
|
}
|
|
778
778
|
}, De = (e, n = {}) => {
|
|
779
|
-
let a =
|
|
780
|
-
return
|
|
779
|
+
let a = W(r, e), c = G(n.disabled) || G(t.disabled), l = !s.registerName.has(e) && a && a._f && !a._f.mount;
|
|
780
|
+
return q(r, e, {
|
|
781
781
|
...a || {},
|
|
782
782
|
_f: {
|
|
783
783
|
...a && a._f ? a._f : { ref: { name: e } },
|
|
@@ -785,34 +785,34 @@ function ot(e = {}) {
|
|
|
785
785
|
mount: !0,
|
|
786
786
|
...n
|
|
787
787
|
}
|
|
788
|
-
}), s.mount.add(e), a && !l ?
|
|
789
|
-
disabled:
|
|
788
|
+
}), s.mount.add(e), a && !l ? we({
|
|
789
|
+
disabled: G(n.disabled) ? n.disabled : t.disabled,
|
|
790
790
|
name: e
|
|
791
791
|
}) : S(e, !0, n.value), {
|
|
792
792
|
...c ? { disabled: n.disabled || t.disabled } : {},
|
|
793
793
|
...t.progressive ? {
|
|
794
794
|
required: !!n.required,
|
|
795
|
-
min:
|
|
796
|
-
max:
|
|
797
|
-
minLength:
|
|
798
|
-
maxLength:
|
|
799
|
-
pattern:
|
|
795
|
+
min: Ue(n.min),
|
|
796
|
+
max: Ue(n.max),
|
|
797
|
+
minLength: Ue(n.minLength),
|
|
798
|
+
maxLength: Ue(n.maxLength),
|
|
799
|
+
pattern: Ue(n.pattern)
|
|
800
800
|
} : {},
|
|
801
801
|
name: e,
|
|
802
|
-
onChange:
|
|
803
|
-
onBlur:
|
|
802
|
+
onChange: ie,
|
|
803
|
+
onBlur: ie,
|
|
804
804
|
ref: (c) => {
|
|
805
805
|
if (c) {
|
|
806
|
-
s.registerName.add(e), De(e, n), s.registerName.delete(e), a =
|
|
807
|
-
let t =
|
|
806
|
+
s.registerName.add(e), De(e, n), s.registerName.delete(e), a = W(r, e);
|
|
807
|
+
let t = V(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = Te(t), l = a._f.refs || [];
|
|
808
808
|
if (o ? l.find((e) => e === t) : t === a._f.ref) return;
|
|
809
|
-
|
|
809
|
+
q(r, e, { _f: {
|
|
810
810
|
...a._f,
|
|
811
811
|
...o ? {
|
|
812
812
|
refs: [
|
|
813
|
-
...l.filter(
|
|
813
|
+
...l.filter(Ee),
|
|
814
814
|
t,
|
|
815
|
-
...Array.isArray(
|
|
815
|
+
...Array.isArray(W(i, e)) ? [{}] : []
|
|
816
816
|
],
|
|
817
817
|
ref: {
|
|
818
818
|
type: t.type,
|
|
@@ -820,12 +820,12 @@ function ot(e = {}) {
|
|
|
820
820
|
}
|
|
821
821
|
} : { ref: t }
|
|
822
822
|
} }), S(e, !1, void 0, t);
|
|
823
|
-
} else a =
|
|
823
|
+
} else a = W(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(re(s.array, e) && o.action) && s.unMount.add(e);
|
|
824
824
|
}
|
|
825
825
|
};
|
|
826
|
-
}, Oe = () => t.shouldFocusError &&
|
|
827
|
-
|
|
828
|
-
let i =
|
|
826
|
+
}, Oe = () => t.shouldFocusError && Ye(r, B, s.mount), ke = (e) => {
|
|
827
|
+
G(e) && (p.state.next({ disabled: e }), Ye(r, (t, n) => {
|
|
828
|
+
let i = W(r, n);
|
|
829
829
|
i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
|
|
830
830
|
t.disabled = i._f.disabled || e;
|
|
831
831
|
}));
|
|
@@ -833,13 +833,13 @@ function ot(e = {}) {
|
|
|
833
833
|
}, Ae = (e, i) => async (o) => {
|
|
834
834
|
let c;
|
|
835
835
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
836
|
-
let l =
|
|
836
|
+
let l = z(a);
|
|
837
837
|
if (p.state.next({ isSubmitting: !0 }), t.resolver) {
|
|
838
838
|
let { errors: e, values: t } = await w();
|
|
839
|
-
_(), n.errors = e, l =
|
|
839
|
+
_(), n.errors = e, l = z(t);
|
|
840
840
|
} else await D({
|
|
841
841
|
fields: r,
|
|
842
|
-
eventType:
|
|
842
|
+
eventType: oe.SUBMIT
|
|
843
843
|
});
|
|
844
844
|
if (s.disabled.size) for (let e of s.disabled) $(l, e);
|
|
845
845
|
if ($(n.errors, ce), Q(n.errors)) {
|
|
@@ -858,22 +858,22 @@ function ot(e = {}) {
|
|
|
858
858
|
errors: n.errors
|
|
859
859
|
}), c) throw c;
|
|
860
860
|
}, je = (e, t = {}) => {
|
|
861
|
-
|
|
862
|
-
},
|
|
863
|
-
let l = e ?
|
|
861
|
+
W(r, e) && (V(t.defaultValue) ? P(e, z(W(i, e))) : (P(e, t.defaultValue), q(i, e, z(t.defaultValue))), t.keepTouched || $(n.touchedFields, e), t.keepDirty || ($(n.dirtyFields, e), n.isDirty = t.defaultValue ? k(e, z(W(i, e))) : k()), t.keepError || ($(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
|
|
862
|
+
}, Me = (e, c = {}) => {
|
|
863
|
+
let l = e ? z(e) : i, u = z(l), f = Q(e), m = f ? i : u;
|
|
864
864
|
if (c.keepDefaultValues || (i = l), !c.keepValues) {
|
|
865
865
|
if (c.keepDirtyValues) {
|
|
866
|
-
let e = /* @__PURE__ */ new Set([...s.mount, ...Object.keys(
|
|
866
|
+
let e = /* @__PURE__ */ new Set([...s.mount, ...Object.keys(Ne(i, a))]);
|
|
867
867
|
for (let t of Array.from(e)) {
|
|
868
|
-
let e =
|
|
869
|
-
e && !
|
|
868
|
+
let e = W(n.dirtyFields, t), r = W(a, t), i = W(m, t);
|
|
869
|
+
e && !V(r) ? q(m, t, r) : !e && !V(i) && P(t, i);
|
|
870
870
|
}
|
|
871
871
|
} else {
|
|
872
|
-
if (ae &&
|
|
873
|
-
let t =
|
|
872
|
+
if (ae && V(e)) for (let e of s.mount) {
|
|
873
|
+
let t = W(r, e);
|
|
874
874
|
if (t && t._f) {
|
|
875
875
|
let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
|
|
876
|
-
if (
|
|
876
|
+
if (Se(e)) {
|
|
877
877
|
let t = e.closest("form");
|
|
878
878
|
if (t) {
|
|
879
879
|
t.reset();
|
|
@@ -882,10 +882,10 @@ function ot(e = {}) {
|
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
-
if (c.keepFieldsRef) for (let e of s.mount)
|
|
885
|
+
if (c.keepFieldsRef) for (let e of s.mount) P(e, W(m, e));
|
|
886
886
|
else r = {};
|
|
887
887
|
}
|
|
888
|
-
a = t.shouldUnregister ? c.keepDefaultValues ?
|
|
888
|
+
a = t.shouldUnregister ? c.keepDefaultValues ? z(i) : {} : z(m), p.array.next({ values: { ...m } }), p.state.next({ values: { ...m } });
|
|
889
889
|
}
|
|
890
890
|
s = {
|
|
891
891
|
mount: c.keepDirtyValues ? s.mount : /* @__PURE__ */ new Set(),
|
|
@@ -900,25 +900,25 @@ function ot(e = {}) {
|
|
|
900
900
|
submitCount: c.keepSubmitCount ? n.submitCount : 0,
|
|
901
901
|
isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !Z(e, i)),
|
|
902
902
|
isSubmitted: c.keepIsSubmitted ? n.isSubmitted : !1,
|
|
903
|
-
dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ?
|
|
903
|
+
dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? Ne(i, a) : n.dirtyFields : c.keepDefaultValues && e ? Ne(i, e) : c.keepDirty ? n.dirtyFields : {},
|
|
904
904
|
touchedFields: c.keepTouched ? n.touchedFields : {},
|
|
905
905
|
errors: c.keepErrors ? n.errors : {},
|
|
906
906
|
isSubmitSuccessful: c.keepIsSubmitSuccessful ? n.isSubmitSuccessful : !1,
|
|
907
907
|
isSubmitting: !1,
|
|
908
908
|
defaultValues: i
|
|
909
909
|
});
|
|
910
|
-
}, Pe = (e, n) =>
|
|
910
|
+
}, Pe = (e, n) => Me(K(e) ? e(a) : e, {
|
|
911
911
|
...t.resetOptions,
|
|
912
912
|
...n
|
|
913
913
|
}), Fe = (e, t = {}) => {
|
|
914
|
-
let n =
|
|
914
|
+
let n = W(r, e), i = n && n._f;
|
|
915
915
|
if (i) {
|
|
916
916
|
let e = i.refs ? i.refs[0] : i.ref;
|
|
917
917
|
e.focus && setTimeout(() => {
|
|
918
|
-
e.focus(), t.shouldSelect &&
|
|
918
|
+
e.focus(), t.shouldSelect && K(e.select) && e.select();
|
|
919
919
|
});
|
|
920
920
|
}
|
|
921
|
-
},
|
|
921
|
+
}, Ie = (e) => {
|
|
922
922
|
n = {
|
|
923
923
|
...n,
|
|
924
924
|
...e
|
|
@@ -926,10 +926,10 @@ function ot(e = {}) {
|
|
|
926
926
|
}, Re = {
|
|
927
927
|
control: {
|
|
928
928
|
register: De,
|
|
929
|
-
unregister:
|
|
930
|
-
getFieldState:
|
|
929
|
+
unregister: _e,
|
|
930
|
+
getFieldState: ue,
|
|
931
931
|
handleSubmit: Ae,
|
|
932
|
-
setError:
|
|
932
|
+
setError: fe,
|
|
933
933
|
_subscribe: he,
|
|
934
934
|
_runSchema: w,
|
|
935
935
|
_updateIsValidating: _,
|
|
@@ -938,11 +938,11 @@ function ot(e = {}) {
|
|
|
938
938
|
_getDirty: k,
|
|
939
939
|
_setValid: g,
|
|
940
940
|
_setFieldArray: y,
|
|
941
|
-
_setDisabledField:
|
|
941
|
+
_setDisabledField: we,
|
|
942
942
|
_setErrors: x,
|
|
943
943
|
_getFieldArray: j,
|
|
944
|
-
_reset:
|
|
945
|
-
_resetDefaultValues: () =>
|
|
944
|
+
_reset: Me,
|
|
945
|
+
_resetDefaultValues: () => K(t.defaultValues) && t.defaultValues().then((e) => {
|
|
946
946
|
Pe(e, t.resetOptions), p.state.next({ isLoading: !1 });
|
|
947
947
|
}),
|
|
948
948
|
_removeUnmounted: O,
|
|
@@ -984,40 +984,40 @@ function ot(e = {}) {
|
|
|
984
984
|
}
|
|
985
985
|
},
|
|
986
986
|
subscribe: ge,
|
|
987
|
-
trigger:
|
|
987
|
+
trigger: U,
|
|
988
988
|
register: De,
|
|
989
989
|
handleSubmit: Ae,
|
|
990
990
|
watch: me,
|
|
991
|
-
setValue:
|
|
992
|
-
setValues:
|
|
993
|
-
getValues:
|
|
991
|
+
setValue: P,
|
|
992
|
+
setValues: te,
|
|
993
|
+
getValues: le,
|
|
994
994
|
reset: Pe,
|
|
995
995
|
resetField: je,
|
|
996
|
-
clearErrors:
|
|
997
|
-
unregister:
|
|
998
|
-
setError:
|
|
996
|
+
clearErrors: de,
|
|
997
|
+
unregister: _e,
|
|
998
|
+
setError: fe,
|
|
999
999
|
setFocus: Fe,
|
|
1000
|
-
getFieldState:
|
|
1000
|
+
getFieldState: ue
|
|
1001
1001
|
};
|
|
1002
1002
|
return {
|
|
1003
1003
|
...Re,
|
|
1004
1004
|
formControl: Re
|
|
1005
1005
|
};
|
|
1006
1006
|
}
|
|
1007
|
-
function
|
|
1008
|
-
let t =
|
|
1009
|
-
...
|
|
1010
|
-
isLoading:
|
|
1007
|
+
function ct(e = {}) {
|
|
1008
|
+
let t = T.useRef(void 0), n = T.useRef(void 0), [r, i] = T.useState(() => ({
|
|
1009
|
+
...z(ot),
|
|
1010
|
+
isLoading: K(e.defaultValues),
|
|
1011
1011
|
errors: e.errors || {},
|
|
1012
1012
|
disabled: e.disabled || !1,
|
|
1013
|
-
defaultValues:
|
|
1013
|
+
defaultValues: K(e.defaultValues) ? void 0 : e.defaultValues
|
|
1014
1014
|
}));
|
|
1015
1015
|
if (!t.current) if (e.formControl) t.current = {
|
|
1016
1016
|
...e.formControl,
|
|
1017
1017
|
formState: r
|
|
1018
|
-
}, e.defaultValues && !
|
|
1018
|
+
}, e.defaultValues && !K(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1019
1019
|
else {
|
|
1020
|
-
let { formControl: n, ...i } =
|
|
1020
|
+
let { formControl: n, ...i } = st(e);
|
|
1021
1021
|
t.current = {
|
|
1022
1022
|
...i,
|
|
1023
1023
|
formState: r
|
|
@@ -1034,63 +1034,63 @@ function st(e = {}) {
|
|
|
1034
1034
|
...e,
|
|
1035
1035
|
isReady: !0
|
|
1036
1036
|
})), a._formState.isReady = !0, e;
|
|
1037
|
-
}, [a]),
|
|
1037
|
+
}, [a]), T.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), T.useEffect(() => {
|
|
1038
1038
|
e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
|
|
1039
1039
|
}, [
|
|
1040
1040
|
a,
|
|
1041
1041
|
e.mode,
|
|
1042
1042
|
e.reValidateMode
|
|
1043
|
-
]),
|
|
1043
|
+
]), T.useEffect(() => {
|
|
1044
1044
|
e.errors && (a._setErrors(e.errors), a._focusError());
|
|
1045
|
-
}, [a, e.errors]),
|
|
1045
|
+
}, [a, e.errors]), T.useEffect(() => {
|
|
1046
1046
|
e.shouldUnregister && a._subjects.state.next({ values: a._getWatch() });
|
|
1047
|
-
}, [a, e.shouldUnregister]),
|
|
1047
|
+
}, [a, e.shouldUnregister]), T.useEffect(() => {
|
|
1048
1048
|
if (a._proxyFormState.isDirty) {
|
|
1049
1049
|
let e = a._getDirty();
|
|
1050
1050
|
e !== r.isDirty && a._subjects.state.next({ isDirty: e });
|
|
1051
1051
|
}
|
|
1052
|
-
}, [a, r.isDirty]),
|
|
1052
|
+
}, [a, r.isDirty]), T.useEffect(() => {
|
|
1053
1053
|
e.values && !Z(e.values, n.current) ? (a._reset(e.values, {
|
|
1054
1054
|
keepFieldsRef: !0,
|
|
1055
1055
|
...a._options.resetOptions
|
|
1056
1056
|
}), a._options.resetOptions?.keepIsValid || a._setValid(), n.current = e.values, i((e) => ({ ...e }))) : a._resetDefaultValues();
|
|
1057
|
-
}, [a, e.values]),
|
|
1057
|
+
}, [a, e.values]), T.useEffect(() => {
|
|
1058
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 =
|
|
1059
|
+
}), t.current.formState = T.useMemo(() => de(r, a), [a, r]), t.current;
|
|
1060
1060
|
}
|
|
1061
1061
|
//#endregion
|
|
1062
1062
|
//#region node_modules/@hookform/resolvers/dist/resolvers.mjs
|
|
1063
|
-
var
|
|
1063
|
+
var lt = (e, t, n) => {
|
|
1064
1064
|
if (e && "reportValidity" in e) {
|
|
1065
|
-
let r =
|
|
1065
|
+
let r = W(n, t);
|
|
1066
1066
|
e.setCustomValidity(r && r.message || ""), e.reportValidity();
|
|
1067
1067
|
}
|
|
1068
|
-
},
|
|
1068
|
+
}, ut = (e, t) => {
|
|
1069
1069
|
for (let n in t.fields) {
|
|
1070
1070
|
let r = t.fields[n];
|
|
1071
|
-
r && r.ref && "reportValidity" in r.ref ?
|
|
1071
|
+
r && r.ref && "reportValidity" in r.ref ? lt(r.ref, n, e) : r && r.refs && r.refs.forEach((t) => lt(t, n, e));
|
|
1072
1072
|
}
|
|
1073
|
-
},
|
|
1074
|
-
t.shouldUseNativeValidation &&
|
|
1073
|
+
}, dt = (e, t) => {
|
|
1074
|
+
t.shouldUseNativeValidation && ut(e, t);
|
|
1075
1075
|
let n = {};
|
|
1076
1076
|
for (let r in e) {
|
|
1077
|
-
let i =
|
|
1078
|
-
if (
|
|
1079
|
-
let e = Object.assign({},
|
|
1080
|
-
|
|
1081
|
-
} else
|
|
1077
|
+
let i = W(t.fields, r), a = Object.assign(e[r] || {}, { ref: i && i.ref });
|
|
1078
|
+
if (ft(t.names || Object.keys(e), r)) {
|
|
1079
|
+
let e = Object.assign({}, W(n, r));
|
|
1080
|
+
q(e, "root", a), q(n, r, e);
|
|
1081
|
+
} else q(n, r, a);
|
|
1082
1082
|
}
|
|
1083
1083
|
return n;
|
|
1084
|
-
},
|
|
1085
|
-
let n =
|
|
1086
|
-
return e.some((e) =>
|
|
1084
|
+
}, ft = (e, t) => {
|
|
1085
|
+
let n = pt(t);
|
|
1086
|
+
return e.some((e) => pt(e).match(`^${n}\\.\\d+`));
|
|
1087
1087
|
};
|
|
1088
|
-
function
|
|
1088
|
+
function pt(e) {
|
|
1089
1089
|
return e.replace(/\]|\[/g, "");
|
|
1090
1090
|
}
|
|
1091
1091
|
//#endregion
|
|
1092
1092
|
//#region node_modules/@hookform/resolvers/zod/dist/zod.mjs
|
|
1093
|
-
function
|
|
1093
|
+
function mt(e, t) {
|
|
1094
1094
|
try {
|
|
1095
1095
|
var n = e();
|
|
1096
1096
|
} catch (e) {
|
|
@@ -1098,7 +1098,7 @@ function pt(e, t) {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
return n && n.then ? n.then(void 0, t) : n;
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function ht(e, t) {
|
|
1102
1102
|
for (var n = {}; e.length;) {
|
|
1103
1103
|
var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
|
|
1104
1104
|
if (!n[o]) if ("unionErrors" in r) {
|
|
@@ -1117,13 +1117,13 @@ function mt(e, t) {
|
|
|
1117
1117
|
});
|
|
1118
1118
|
}), t) {
|
|
1119
1119
|
var c = n[o].types, l = c && c[r.code];
|
|
1120
|
-
n[o] =
|
|
1120
|
+
n[o] = _e(o, t, n, i, l ? [].concat(l, r.message) : r.message);
|
|
1121
1121
|
}
|
|
1122
1122
|
e.shift();
|
|
1123
1123
|
}
|
|
1124
1124
|
return n;
|
|
1125
1125
|
}
|
|
1126
|
-
function
|
|
1126
|
+
function gt(e, t) {
|
|
1127
1127
|
for (var n = {}; e.length;) {
|
|
1128
1128
|
var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
|
|
1129
1129
|
if (!n[o]) if (r.code === "invalid_union" && r.errors.length > 0) {
|
|
@@ -1142,20 +1142,20 @@ function ht(e, t) {
|
|
|
1142
1142
|
});
|
|
1143
1143
|
}), t) {
|
|
1144
1144
|
var c = n[o].types, l = c && c[r.code];
|
|
1145
|
-
n[o] =
|
|
1145
|
+
n[o] = _e(o, t, n, i, l ? [].concat(l, r.message) : r.message);
|
|
1146
1146
|
}
|
|
1147
1147
|
e.shift();
|
|
1148
1148
|
}
|
|
1149
1149
|
return n;
|
|
1150
1150
|
}
|
|
1151
|
-
function
|
|
1151
|
+
function _t(e, n, i) {
|
|
1152
1152
|
if (i === void 0 && (i = {}), function(e) {
|
|
1153
1153
|
return "_def" in e && typeof e._def == "object" && "typeName" in e._def;
|
|
1154
|
-
}(e)) return function(t,
|
|
1154
|
+
}(e)) return function(t, r, a) {
|
|
1155
1155
|
try {
|
|
1156
|
-
return Promise.resolve(
|
|
1157
|
-
return Promise.resolve(e[i.mode === "sync" ? "parse" : "parseAsync"](t,
|
|
1158
|
-
return a.shouldUseNativeValidation &&
|
|
1156
|
+
return Promise.resolve(mt(function() {
|
|
1157
|
+
return Promise.resolve(e[i.mode === "sync" ? "parse" : "parseAsync"](t, n)).then(function(e) {
|
|
1158
|
+
return a.shouldUseNativeValidation && ut({}, a), {
|
|
1159
1159
|
errors: {},
|
|
1160
1160
|
values: i.raw ? Object.assign({}, t) : e
|
|
1161
1161
|
};
|
|
@@ -1165,7 +1165,7 @@ function gt(e, r, i) {
|
|
|
1165
1165
|
return Array.isArray(e?.issues);
|
|
1166
1166
|
}(e)) return {
|
|
1167
1167
|
values: {},
|
|
1168
|
-
errors:
|
|
1168
|
+
errors: dt(ht(e.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
|
|
1169
1169
|
};
|
|
1170
1170
|
throw e;
|
|
1171
1171
|
}));
|
|
@@ -1175,21 +1175,21 @@ function gt(e, r, i) {
|
|
|
1175
1175
|
};
|
|
1176
1176
|
if (function(e) {
|
|
1177
1177
|
return "_zod" in e && typeof e._zod == "object";
|
|
1178
|
-
}(e)) return function(o, s
|
|
1178
|
+
}(e)) return function(a, o, s) {
|
|
1179
1179
|
try {
|
|
1180
|
-
return Promise.resolve(
|
|
1181
|
-
return Promise.resolve((i.mode === "sync" ? t :
|
|
1182
|
-
return
|
|
1180
|
+
return Promise.resolve(mt(function() {
|
|
1181
|
+
return Promise.resolve((i.mode === "sync" ? t : r)(e, a, n)).then(function(e) {
|
|
1182
|
+
return s.shouldUseNativeValidation && ut({}, s), {
|
|
1183
1183
|
errors: {},
|
|
1184
|
-
values: i.raw ? Object.assign({},
|
|
1184
|
+
values: i.raw ? Object.assign({}, a) : e
|
|
1185
1185
|
};
|
|
1186
1186
|
});
|
|
1187
1187
|
}, function(e) {
|
|
1188
1188
|
if (function(e) {
|
|
1189
|
-
return e instanceof
|
|
1189
|
+
return e instanceof v;
|
|
1190
1190
|
}(e)) return {
|
|
1191
1191
|
values: {},
|
|
1192
|
-
errors:
|
|
1192
|
+
errors: dt(gt(e.issues, !s.shouldUseNativeValidation && s.criteriaMode === "all"), s)
|
|
1193
1193
|
};
|
|
1194
1194
|
throw e;
|
|
1195
1195
|
}));
|
|
@@ -1201,7 +1201,7 @@ function gt(e, r, i) {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
//#endregion
|
|
1203
1203
|
//#region src/base/blocks/FormPanelBlock.tsx
|
|
1204
|
-
function
|
|
1204
|
+
function vt(e, t) {
|
|
1205
1205
|
let n = t[e.key];
|
|
1206
1206
|
if (n != null) return n;
|
|
1207
1207
|
switch (e.component) {
|
|
@@ -1217,26 +1217,26 @@ function _t(e, t) {
|
|
|
1217
1217
|
default: return "";
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
|
-
function
|
|
1221
|
-
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] :
|
|
1220
|
+
function yt(e, t) {
|
|
1221
|
+
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : vt(e, t);
|
|
1222
1222
|
}
|
|
1223
|
-
function
|
|
1224
|
-
return /* @__PURE__ */ j
|
|
1223
|
+
function bt({ nodes: e, values: t, errors: n, onChange: r, sourceValues: a }) {
|
|
1224
|
+
return /* @__PURE__ */ M(j, { children: e.map((e, o) => {
|
|
1225
1225
|
switch (e.kind) {
|
|
1226
|
-
case "field": return s(e, t) ? /* @__PURE__ */
|
|
1226
|
+
case "field": return s(e, t) ? /* @__PURE__ */ M(S, {
|
|
1227
1227
|
field: e,
|
|
1228
|
-
value:
|
|
1228
|
+
value: yt(e, t),
|
|
1229
1229
|
onChange: (t) => r(e.key, t),
|
|
1230
1230
|
error: n[e.key],
|
|
1231
1231
|
sourceValues: a
|
|
1232
1232
|
}, e.key) : null;
|
|
1233
|
-
case "section": return /* @__PURE__ */
|
|
1233
|
+
case "section": return /* @__PURE__ */ M(b, {
|
|
1234
1234
|
id: e.id,
|
|
1235
1235
|
title: e.label,
|
|
1236
1236
|
defaultCollapsed: e.defaultCollapsed,
|
|
1237
1237
|
hasErrors: e.children.some((e) => e.kind === "field" && !!n[e.key]),
|
|
1238
1238
|
errorCount: e.children.filter((e) => e.kind === "field" && !!n[e.key]).length,
|
|
1239
|
-
children: /* @__PURE__ */
|
|
1239
|
+
children: /* @__PURE__ */ M(bt, {
|
|
1240
1240
|
nodes: e.children,
|
|
1241
1241
|
values: t,
|
|
1242
1242
|
errors: n,
|
|
@@ -1244,9 +1244,9 @@ function yt({ nodes: e, values: t, errors: n, onChange: r, sourceValues: a }) {
|
|
|
1244
1244
|
sourceValues: a
|
|
1245
1245
|
})
|
|
1246
1246
|
}, e.id);
|
|
1247
|
-
case "group": return /* @__PURE__ */
|
|
1248
|
-
className:
|
|
1249
|
-
children: /* @__PURE__ */
|
|
1247
|
+
case "group": return /* @__PURE__ */ M("div", {
|
|
1248
|
+
className: w("grid gap-6", e.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
|
|
1249
|
+
children: /* @__PURE__ */ M(bt, {
|
|
1250
1250
|
nodes: e.children,
|
|
1251
1251
|
values: t,
|
|
1252
1252
|
errors: n,
|
|
@@ -1254,9 +1254,9 @@ function yt({ nodes: e, values: t, errors: n, onChange: r, sourceValues: a }) {
|
|
|
1254
1254
|
sourceValues: a
|
|
1255
1255
|
})
|
|
1256
1256
|
}, e.id);
|
|
1257
|
-
case "header": return /* @__PURE__ */
|
|
1257
|
+
case "header": return /* @__PURE__ */ N("div", {
|
|
1258
1258
|
className: "space-y-2",
|
|
1259
|
-
children: [/* @__PURE__ */
|
|
1259
|
+
children: [/* @__PURE__ */ M(i, {}), /* @__PURE__ */ M("h4", {
|
|
1260
1260
|
className: "text-foreground text-base font-semibold",
|
|
1261
1261
|
children: e.label
|
|
1262
1262
|
})]
|
|
@@ -1265,70 +1265,70 @@ function yt({ nodes: e, values: t, errors: n, onChange: r, sourceValues: a }) {
|
|
|
1265
1265
|
}
|
|
1266
1266
|
}) });
|
|
1267
1267
|
}
|
|
1268
|
-
function
|
|
1269
|
-
let { t:
|
|
1270
|
-
defaultValues:
|
|
1268
|
+
function xt({ block: t }) {
|
|
1269
|
+
let { t: r } = ee(), { data: i } = t, v = O(() => y(i.schema), [i.schema]), b = O(() => new Set(v.map((e) => e.key)), [v]), S = (i.meta.validation ?? "both") !== "server", w = O(() => Object.fromEntries(v.map((e) => [e.key, vt(e, i.values)])), [v, i.values]), T = k(S ? m(i.schema, w, r) : null), F = ct({
|
|
1270
|
+
defaultValues: w,
|
|
1271
1271
|
mode: "onTouched",
|
|
1272
|
-
resolver:
|
|
1273
|
-
if (
|
|
1272
|
+
resolver: O(() => {
|
|
1273
|
+
if (S) return async (e, t, n) => T.current ? _t(T.current)(e, t, n) : {
|
|
1274
1274
|
values: e,
|
|
1275
1275
|
errors: {}
|
|
1276
1276
|
};
|
|
1277
|
-
}, [
|
|
1278
|
-
}),
|
|
1279
|
-
|
|
1280
|
-
|
|
1277
|
+
}, [S])
|
|
1278
|
+
}), I = he({ control: F.control }) ?? w, L = v.map((e) => `${s(e, I) ? "1" : "0"}${d(e, I) ? "1" : "0"}`).join("");
|
|
1279
|
+
D(() => {
|
|
1280
|
+
S && (T.current = m(i.schema, I, r));
|
|
1281
1281
|
}, [
|
|
1282
|
-
|
|
1282
|
+
S,
|
|
1283
1283
|
i.schema,
|
|
1284
|
-
|
|
1285
|
-
|
|
1284
|
+
r,
|
|
1285
|
+
L
|
|
1286
1286
|
]);
|
|
1287
|
-
let [
|
|
1288
|
-
|
|
1289
|
-
if (
|
|
1290
|
-
|
|
1287
|
+
let [te, R] = A(!1), [ne, re] = A(null), [ie, ae] = A({}), z = JSON.stringify(i.values), B = k(!0);
|
|
1288
|
+
D(() => {
|
|
1289
|
+
if (B.current) {
|
|
1290
|
+
B.current = !1;
|
|
1291
1291
|
return;
|
|
1292
1292
|
}
|
|
1293
|
-
|
|
1294
|
-
for (let [e, t] of Object.entries(i.errors))
|
|
1293
|
+
F.reset(w);
|
|
1294
|
+
for (let [e, t] of Object.entries(i.errors)) b.has(e) && F.setError(e, {
|
|
1295
1295
|
type: "server",
|
|
1296
|
-
message: g(t,
|
|
1296
|
+
message: g(t, r)
|
|
1297
1297
|
});
|
|
1298
|
-
}, [
|
|
1299
|
-
if (Object.keys(i.errors).length > 0) for (let [e, t] of Object.entries(i.errors))
|
|
1298
|
+
}, [z]), D(() => {
|
|
1299
|
+
if (Object.keys(i.errors).length > 0) for (let [e, t] of Object.entries(i.errors)) b.has(e) && F.setError(e, {
|
|
1300
1300
|
type: "server",
|
|
1301
|
-
message: g(t,
|
|
1301
|
+
message: g(t, r)
|
|
1302
1302
|
});
|
|
1303
1303
|
}, [JSON.stringify(i.errors)]);
|
|
1304
|
-
let { isDirty:
|
|
1305
|
-
|
|
1306
|
-
if (!
|
|
1304
|
+
let { isDirty: V, isSubmitting: H } = F.formState;
|
|
1305
|
+
D(() => {
|
|
1306
|
+
if (!V) return;
|
|
1307
1307
|
let e = (e) => {
|
|
1308
1308
|
e.preventDefault();
|
|
1309
1309
|
};
|
|
1310
1310
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1311
|
-
}, [
|
|
1312
|
-
let
|
|
1313
|
-
|
|
1311
|
+
}, [V]);
|
|
1312
|
+
let U = E((e, t) => {
|
|
1313
|
+
F.setValue(e, t, {
|
|
1314
1314
|
shouldDirty: !0,
|
|
1315
|
-
shouldValidate:
|
|
1316
|
-
}),
|
|
1317
|
-
}, [
|
|
1315
|
+
shouldValidate: F.formState.isSubmitted
|
|
1316
|
+
}), F.clearErrors(e);
|
|
1317
|
+
}, [F]), W = E((e) => {
|
|
1318
1318
|
ae({});
|
|
1319
|
-
let t =
|
|
1319
|
+
let t = v.filter((t) => s(t, e)), n = Object.fromEntries(t.map((t) => [t.key, e[t.key]])), a = Object.values(n).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File)), o = i.method === "put" ? "put" : i.method === "patch" ? "patch" : "post";
|
|
1320
1320
|
return new Promise((e) => {
|
|
1321
|
-
|
|
1322
|
-
forceFormData:
|
|
1321
|
+
P[o](i.action, n, {
|
|
1322
|
+
forceFormData: a,
|
|
1323
1323
|
onProgress: (e) => {
|
|
1324
1324
|
e && typeof e.percentage == "number" && re(Math.round(e.percentage));
|
|
1325
1325
|
},
|
|
1326
1326
|
onError: (e) => {
|
|
1327
1327
|
let t = {};
|
|
1328
|
-
for (let [
|
|
1328
|
+
for (let [n, i] of Object.entries(e)) b.has(n) ? F.setError(n, {
|
|
1329
1329
|
type: "server",
|
|
1330
|
-
message: g(i,
|
|
1331
|
-
}) : t[
|
|
1330
|
+
message: g(i, r)
|
|
1331
|
+
}) : t[n] = i;
|
|
1332
1332
|
Object.keys(t).length > 0 && ae((e) => ({
|
|
1333
1333
|
...e,
|
|
1334
1334
|
...t
|
|
@@ -1340,23 +1340,23 @@ function bt({ block: t }) {
|
|
|
1340
1340
|
});
|
|
1341
1341
|
});
|
|
1342
1342
|
}, [
|
|
1343
|
-
|
|
1343
|
+
v,
|
|
1344
1344
|
i,
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
]),
|
|
1349
|
-
|
|
1350
|
-
}, [
|
|
1345
|
+
F,
|
|
1346
|
+
r,
|
|
1347
|
+
b
|
|
1348
|
+
]), G = E(() => {
|
|
1349
|
+
V ? R(!0) : i.meta.cancelHref ? P.visit(i.meta.cancelHref) : window.history.back();
|
|
1350
|
+
}, [V, i.meta.cancelHref]), K = O(() => {
|
|
1351
1351
|
let e = {};
|
|
1352
|
-
for (let [t, n] of Object.entries(
|
|
1352
|
+
for (let [t, n] of Object.entries(F.formState.errors)) n?.message && (e[t] = n.message);
|
|
1353
1353
|
return e;
|
|
1354
|
-
}, [
|
|
1354
|
+
}, [F.formState.errors]), q = O(() => {
|
|
1355
1355
|
let e = /* @__PURE__ */ new Map(), t = (t) => {
|
|
1356
|
-
for (let [
|
|
1357
|
-
if (
|
|
1358
|
-
let t = g(i,
|
|
1359
|
-
t && e.set(
|
|
1356
|
+
for (let [n, i] of Object.entries(t)) {
|
|
1357
|
+
if (b.has(n)) continue;
|
|
1358
|
+
let t = g(i, r);
|
|
1359
|
+
t && e.set(n, t);
|
|
1360
1360
|
}
|
|
1361
1361
|
};
|
|
1362
1362
|
return t(i.errors), t(ie), Array.from(e, ([e, t]) => ({
|
|
@@ -1366,64 +1366,65 @@ function bt({ block: t }) {
|
|
|
1366
1366
|
}, [
|
|
1367
1367
|
i.errors,
|
|
1368
1368
|
ie,
|
|
1369
|
-
|
|
1370
|
-
|
|
1369
|
+
b,
|
|
1370
|
+
r
|
|
1371
1371
|
]);
|
|
1372
|
-
return
|
|
1372
|
+
return v.filter((e) => s(e, I)).length === 0 && i.schema.length === 0 ? /* @__PURE__ */ M(n, {
|
|
1373
1373
|
variant: "inline",
|
|
1374
|
-
title:
|
|
1375
|
-
}) : /* @__PURE__ */
|
|
1376
|
-
onSubmit:
|
|
1374
|
+
title: r("middag.ui.form.no_fields")
|
|
1375
|
+
}) : /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ N("form", {
|
|
1376
|
+
onSubmit: F.handleSubmit(W),
|
|
1377
1377
|
className: "mx-auto max-w-[720px] space-y-6",
|
|
1378
1378
|
noValidate: !0,
|
|
1379
1379
|
role: "form",
|
|
1380
|
-
"aria-label": h(t.title,
|
|
1380
|
+
"aria-label": h(t.title, r) || r("middag.ui.form.default_title"),
|
|
1381
1381
|
children: [
|
|
1382
|
-
|
|
1382
|
+
q.length > 0 && /* @__PURE__ */ N(o, {
|
|
1383
1383
|
variant: "destructive",
|
|
1384
|
-
children: [/* @__PURE__ */
|
|
1384
|
+
children: [/* @__PURE__ */ M(l, { children: r("middag.ui.form.errors_title") }), /* @__PURE__ */ M(e, { children: /* @__PURE__ */ M("ul", {
|
|
1385
1385
|
className: "list-disc ps-4",
|
|
1386
|
-
children:
|
|
1386
|
+
children: q.map((e) => /* @__PURE__ */ M("li", { children: e.message }, e.key))
|
|
1387
1387
|
}) })]
|
|
1388
1388
|
}),
|
|
1389
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ M(bt, {
|
|
1390
1390
|
nodes: i.schema,
|
|
1391
|
-
values:
|
|
1392
|
-
errors:
|
|
1393
|
-
onChange:
|
|
1394
|
-
sourceValues:
|
|
1391
|
+
values: I,
|
|
1392
|
+
errors: K,
|
|
1393
|
+
onChange: U,
|
|
1394
|
+
sourceValues: I
|
|
1395
1395
|
}),
|
|
1396
|
-
/* @__PURE__ */
|
|
1396
|
+
/* @__PURE__ */ N("div", {
|
|
1397
1397
|
className: "flex gap-3 pt-4",
|
|
1398
|
-
children: [/* @__PURE__ */
|
|
1398
|
+
children: [/* @__PURE__ */ M(C, {
|
|
1399
1399
|
type: "submit",
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
"aria-
|
|
1403
|
-
|
|
1404
|
-
|
|
1400
|
+
"data-testid": a.formSubmit,
|
|
1401
|
+
disabled: H,
|
|
1402
|
+
"aria-disabled": H,
|
|
1403
|
+
"aria-busy": H,
|
|
1404
|
+
children: H ? ne === null ? r("middag.ui.form.saving") : `${r("middag.ui.form.saving")} ${ne}%` : i.meta.submitLabel ?? r("middag.ui.form.save")
|
|
1405
|
+
}), /* @__PURE__ */ M(C, {
|
|
1405
1406
|
type: "button",
|
|
1406
1407
|
variant: "outline",
|
|
1407
|
-
onClick:
|
|
1408
|
-
children: i.meta.cancelLabel ??
|
|
1408
|
+
onClick: G,
|
|
1409
|
+
children: i.meta.cancelLabel ?? r("middag.ui.cancel")
|
|
1409
1410
|
})]
|
|
1410
1411
|
})
|
|
1411
1412
|
]
|
|
1412
|
-
}), /* @__PURE__ */
|
|
1413
|
-
open:
|
|
1414
|
-
onOpenChange:
|
|
1415
|
-
children: /* @__PURE__ */
|
|
1413
|
+
}), /* @__PURE__ */ M(f, {
|
|
1414
|
+
open: te,
|
|
1415
|
+
onOpenChange: R,
|
|
1416
|
+
children: /* @__PURE__ */ N(_, { children: [/* @__PURE__ */ N(p, { children: [/* @__PURE__ */ M(u, { children: r("middag.ui.form.dirty_title") }), /* @__PURE__ */ M(x, { children: r("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ N(c, { children: [/* @__PURE__ */ M(C, {
|
|
1416
1417
|
variant: "outline",
|
|
1417
|
-
onClick: () =>
|
|
1418
|
-
children:
|
|
1419
|
-
}), /* @__PURE__ */
|
|
1418
|
+
onClick: () => R(!1),
|
|
1419
|
+
children: r("middag.ui.cancel")
|
|
1420
|
+
}), /* @__PURE__ */ M(C, {
|
|
1420
1421
|
variant: "destructive",
|
|
1421
1422
|
onClick: () => {
|
|
1422
|
-
|
|
1423
|
+
R(!1), i.meta.cancelHref ? P.visit(i.meta.cancelHref) : window.history.back();
|
|
1423
1424
|
},
|
|
1424
|
-
children:
|
|
1425
|
+
children: r("middag.ui.form.dirty_leave")
|
|
1425
1426
|
})] })] })
|
|
1426
1427
|
})] });
|
|
1427
1428
|
}
|
|
1428
1429
|
//#endregion
|
|
1429
|
-
export {
|
|
1430
|
+
export { xt as FormPanelBlock };
|