@middag-io/react 0.29.0 → 0.30.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/{DateField-BCCidKwl.js → DateField-CcRD2r-Z.js} +5 -5
- package/dist-lib/{DateRangeField-CvU7wiyr.js → DateRangeField-DKZMfKB2.js} +199 -198
- package/dist-lib/{DocumentField-5uXJyXlL.js → DocumentField-DjnK9T7o.js} +3 -3
- package/dist-lib/{FormPanelBlock-DJ0T69X7.js → FormPanelBlock-BW2oi2_O.js} +635 -556
- package/dist-lib/{MarkdownContent-aIIUC0Fl.js → MarkdownContent-C-X2QGA2.js} +18 -17
- package/dist-lib/MarkdownContent-D5FIjx_W.js +2 -0
- package/dist-lib/{PhoneField-DpHb6FQE.js → PhoneField-D_djeYhK.js} +38 -37
- package/dist-lib/base/blocks/ActionGridBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/MetricCardBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/StatusStripBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/TabbedPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/WorkflowProgressBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts +2 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/DateRangeField.d.ts +1 -1
- package/dist-lib/base/form/fields/DateRangeField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/FileUploadField.d.ts +2 -2
- package/dist-lib/base/form/fields/FileUploadField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/NativeSelectField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/RatingField.d.ts +1 -1
- package/dist-lib/base/form/fields/RatingField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/SlugField.d.ts.map +1 -1
- package/dist-lib/base/form/form-schema-builder.d.ts.map +1 -1
- package/dist-lib/base/form/form-utils.d.ts +15 -0
- package/dist-lib/base/form/form-utils.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/partials/StatusBar/index.d.ts.map +1 -1
- package/dist-lib/base/partials/StatusIndicator/index.d.ts.map +1 -1
- package/dist-lib/base/utils/time.d.ts.map +1 -1
- package/dist-lib/{button-Ba1PcsOx.js → button-Bm0X9WO5.js} +1 -1
- package/dist-lib/{calendar-DnlbmjNu.js → calendar-CucaItjm.js} +51 -50
- package/dist-lib/{chevron-right-Casn6MFU.js → chevron-right-DY3SdwdB.js} +1 -1
- package/dist-lib/chunk-DeC0fbbY.js +22 -0
- package/dist-lib/{combobox-DZ_qm1VH.js → combobox-yfHHEi6f.js} +65 -64
- package/dist-lib/contracts/block-data/form.d.ts +64 -197
- package/dist-lib/contracts/block-data/form.d.ts.map +1 -1
- package/dist-lib/contracts/block-data/shared.d.ts +1 -16
- package/dist-lib/contracts/block-data/shared.d.ts.map +1 -1
- package/dist-lib/contracts/generated/contract-schema.d.ts +2 -1
- package/dist-lib/contracts/generated/contract-schema.d.ts.map +1 -1
- package/dist-lib/contracts/generated/contract-types.d.ts +239 -4
- 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/contracts/page-contract-schema.d.ts +1 -0
- package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
- package/dist-lib/contracts/page-contract.d.ts +0 -2
- package/dist-lib/contracts/page-contract.d.ts.map +1 -1
- package/dist-lib/contracts/shared-props.d.ts +4 -0
- package/dist-lib/contracts/shared-props.d.ts.map +1 -1
- package/dist-lib/{dist-B-MyAb3x.js → dist-B7gC4peV.js} +1 -1
- package/dist-lib/{dist-7c0PXlrb.js → dist-Bbnbom8g.js} +2 -2
- package/dist-lib/{dist-DuO9WodV.js → dist-DdgpZG8v.js} +3 -3
- package/dist-lib/{document-validation-YgxIqb8k.js → document-validation-DX0fB9cu.js} +2 -2
- package/dist-lib/i18n/resolve-field-error.d.ts +2 -2
- package/dist-lib/i18n/resolve-field-error.d.ts.map +1 -1
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/{input-CdUVNe54.js → input-BC9whKEm.js} +1 -1
- package/dist-lib/middag-react.js +3274 -3217
- package/dist-lib/{popover-Bxsp1hlN.js → popover-BaiQ-JSz.js} +29 -29
- package/dist-lib/{resolve-field-error-bG2_dMOY.js → resolve-field-error-dbUy6DeX.js} +2155 -2069
- package/dist-lib/{scroll-area-B9TZ05bl.js → scroll-area-D94_a2-1.js} +57 -57
- package/dist-lib/{skeleton-HpnbVVji.js → skeleton-xL_Hzxj-.js} +1 -1
- package/dist-lib/{use-mobile-Kp3Dy8mh.js → use-mobile-CBJJLRL8.js} +36 -36
- package/dist-lib/{useTranslation-CHN-BFba.js → useTranslation-BuyMWJ9T.js} +1 -1
- package/dist-lib/{utils-Yj2czlvU.js → utils-CpaZ5_iF.js} +517 -538
- package/package.json +1 -1
- package/dist-lib/MarkdownContent-CN-ZN_69.js +0 -2
- /package/dist-lib/{dist-CmB86BdM.js → dist-3F0-lo64.js} +0 -0
- /package/dist-lib/{dist-axU0pUop.js → dist-DdfRh_k3.js} +0 -0
- /package/dist-lib/{floating-ui.react-dom-BnOzLaz1.js → floating-ui.react-dom-CNntavPo.js} +0 -0
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { Fragment as Se, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
1
|
+
import { C as e, D as t, E as n, F as r, G as i, H as a, J as o, K as s, L as c, St as l, T as u, V as d, W as f, Y as p, _ as m, a as h, bt as g, c as _, d as v, dt as y, f as b, ft as x, g as S, gt as C, h as w, ht as T, i as E, k as D, l as O, m as k, mt as A, n as j, o as ee, p as te, pt as ne, q as re, r as ie, s as ae, t as M, u as oe, v as se, vt as N, w as ce, xt as le, y as ue, z as de } from "./resolve-field-error-dbUy6DeX.js";
|
|
2
|
+
import { t as fe } from "./button-Bm0X9WO5.js";
|
|
3
|
+
import { t as pe } from "./useTranslation-BuyMWJ9T.js";
|
|
4
|
+
import { t as me } from "./utils-CpaZ5_iF.js";
|
|
5
|
+
import { t as he } from "./skeleton-xL_Hzxj-.js";
|
|
6
|
+
import P, { Suspense as ge, lazy as _e, useCallback as ve, useEffect as ye, useId as be, useMemo as F, useRef as xe, useState as Se } from "react";
|
|
7
|
+
import { router as Ce } from "@inertiajs/core";
|
|
8
|
+
import { Fragment as we, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
10
9
|
//#region node_modules/react-hook-form/dist/index.esm.mjs
|
|
11
|
-
var
|
|
10
|
+
var Te = (e) => e.type === "checkbox", R = (e) => e instanceof Date, z = (e) => e == null, Ee = (e) => typeof e == "object", B = (e) => !z(e) && !Array.isArray(e) && Ee(e) && !R(e), De = (e) => B(e) && e.target ? Te(e.target) ? e.target.checked : e.target.value : e, Oe = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), ke = (e) => {
|
|
12
11
|
let t = e.constructor && e.constructor.prototype;
|
|
13
12
|
return B(t) && t.hasOwnProperty("isPrototypeOf");
|
|
14
|
-
},
|
|
13
|
+
}, Ae = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
15
14
|
function V(e) {
|
|
16
15
|
if (e instanceof Date) return new Date(e);
|
|
17
16
|
let t = typeof FileList < "u" && e instanceof FileList;
|
|
18
|
-
if (
|
|
17
|
+
if (Ae && (e instanceof Blob || t)) return e;
|
|
19
18
|
let n = Array.isArray(e);
|
|
20
|
-
if (!n && !(B(e) &&
|
|
19
|
+
if (!n && !(B(e) && ke(e))) return e;
|
|
21
20
|
let r = n ? [] : Object.create(Object.getPrototypeOf(e));
|
|
22
21
|
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = V(e[t]));
|
|
23
22
|
return r;
|
|
24
23
|
}
|
|
25
|
-
var
|
|
24
|
+
var je = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Me = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Ne = (e) => Me(e.replace(/["|']|\]/g, "").split(/\.|\[/)), U = (e, t, n) => {
|
|
26
25
|
if (!t || !B(e)) return n;
|
|
27
|
-
let r = (
|
|
26
|
+
let r = (je(t) ? [t] : Ne(t)).reduce((e, t) => z(e) ? void 0 : e[t], e);
|
|
28
27
|
return H(r) || r === e ? H(e[t]) ? n : e[t] : r;
|
|
29
28
|
}, W = (e) => typeof e == "boolean", G = (e) => typeof e == "function", K = (e, t, n) => {
|
|
30
|
-
let r = -1, i =
|
|
29
|
+
let r = -1, i = je(t) ? [t] : Ne(t), a = i.length, o = a - 1;
|
|
31
30
|
for (; ++r < a;) {
|
|
32
31
|
let t = i[r], a = n;
|
|
33
32
|
if (r !== o) {
|
|
@@ -37,20 +36,20 @@ var ke = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Ae = (e) => Array.isAr
|
|
|
37
36
|
if (t === "__proto__" || t === "constructor" || t === "prototype") return;
|
|
38
37
|
e[t] = a, e = e[t];
|
|
39
38
|
}
|
|
40
|
-
},
|
|
39
|
+
}, Pe = {
|
|
41
40
|
BLUR: "blur",
|
|
42
41
|
FOCUS_OUT: "focusout",
|
|
43
42
|
CHANGE: "change",
|
|
44
43
|
SUBMIT: "submit",
|
|
45
44
|
TRIGGER: "trigger",
|
|
46
45
|
VALID: "valid"
|
|
47
|
-
},
|
|
46
|
+
}, q = {
|
|
48
47
|
onBlur: "onBlur",
|
|
49
48
|
onChange: "onChange",
|
|
50
49
|
onSubmit: "onSubmit",
|
|
51
50
|
onTouched: "onTouched",
|
|
52
51
|
all: "all"
|
|
53
|
-
},
|
|
52
|
+
}, J = {
|
|
54
53
|
max: "max",
|
|
55
54
|
min: "min",
|
|
56
55
|
maxLength: "maxLength",
|
|
@@ -58,19 +57,19 @@ var ke = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Ae = (e) => Array.isAr
|
|
|
58
57
|
pattern: "pattern",
|
|
59
58
|
required: "required",
|
|
60
59
|
validate: "validate"
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
var
|
|
60
|
+
}, Fe = "form", Ie = "root", Le = P.createContext(null);
|
|
61
|
+
Le.displayName = "HookFormControlContext";
|
|
62
|
+
var Re = () => P.useContext(Le), ze = (e, t, n, r = !0) => {
|
|
64
63
|
let i = {};
|
|
65
64
|
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
66
65
|
let i = a;
|
|
67
|
-
return t._proxyFormState[i] !==
|
|
66
|
+
return t._proxyFormState[i] !== q.all && (t._proxyFormState[i] = !r || q.all), n && (n[i] = !0), e[i];
|
|
68
67
|
} });
|
|
69
68
|
return i;
|
|
70
|
-
},
|
|
71
|
-
function
|
|
69
|
+
}, Be = typeof window < "u" ? P.useLayoutEffect : P.useEffect, Y = (e) => typeof e == "string", Ve = (e, t, n, r, i) => Y(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), He = (e) => z(e) || !Ee(e);
|
|
70
|
+
function X(e, t, n = /* @__PURE__ */ new WeakSet()) {
|
|
72
71
|
if (e === t) return !0;
|
|
73
|
-
if (
|
|
72
|
+
if (He(e) || He(t)) return Object.is(e, t);
|
|
74
73
|
if (R(e) && R(t)) return Object.is(e.getTime(), t.getTime());
|
|
75
74
|
let r = Object.keys(e), i = Object.keys(t);
|
|
76
75
|
if (r.length !== i.length) return !1;
|
|
@@ -81,30 +80,30 @@ function Z(e, t, n = /* @__PURE__ */ new WeakSet()) {
|
|
|
81
80
|
if (!(i in t)) return !1;
|
|
82
81
|
if (i !== "ref") {
|
|
83
82
|
let e = t[i];
|
|
84
|
-
if (R(r) && R(e) || (B(r) || Array.isArray(r)) && (B(e) || Array.isArray(e)) ? !
|
|
83
|
+
if (R(r) && R(e) || (B(r) || Array.isArray(r)) && (B(e) || Array.isArray(e)) ? !X(r, e, n) : !Object.is(r, e)) return !1;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
return !0;
|
|
88
87
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
88
|
+
function Ue(e) {
|
|
89
|
+
let t = Re(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = P.useRef(i), l = P.useRef(s), u = P.useRef(void 0), d = P.useRef(n), f = P.useRef(r);
|
|
91
90
|
l.current = s;
|
|
92
|
-
let [p, m] =
|
|
91
|
+
let [p, m] = P.useState(() => {
|
|
93
92
|
let e = n._getWatch(r, c.current);
|
|
94
93
|
return l.current ? l.current(e) : e;
|
|
95
|
-
}), h =
|
|
96
|
-
let t =
|
|
94
|
+
}), h = P.useCallback((e) => {
|
|
95
|
+
let t = Ve(r, n._names, e || n._formValues, !1, c.current);
|
|
97
96
|
return l.current ? l.current(t) : t;
|
|
98
97
|
}, [
|
|
99
98
|
n._formValues,
|
|
100
99
|
n._names,
|
|
101
100
|
r
|
|
102
|
-
]), g =
|
|
101
|
+
]), g = P.useCallback((e) => {
|
|
103
102
|
if (!a) {
|
|
104
|
-
let t =
|
|
103
|
+
let t = Ve(r, n._names, e || n._formValues, !1, c.current);
|
|
105
104
|
if (l.current) {
|
|
106
105
|
let e = l.current(t);
|
|
107
|
-
|
|
106
|
+
X(e, u.current) || (m(e), u.current = e);
|
|
108
107
|
} else m(t);
|
|
109
108
|
}
|
|
110
109
|
}, [
|
|
@@ -113,7 +112,7 @@ function Be(e) {
|
|
|
113
112
|
a,
|
|
114
113
|
r
|
|
115
114
|
]);
|
|
116
|
-
|
|
115
|
+
Be(() => ((d.current !== n || !X(f.current, r)) && (d.current = n, f.current = r, g()), n._subscribe({
|
|
117
116
|
name: r,
|
|
118
117
|
formState: { values: !0 },
|
|
119
118
|
exact: o,
|
|
@@ -125,10 +124,10 @@ function Be(e) {
|
|
|
125
124
|
o,
|
|
126
125
|
r,
|
|
127
126
|
g
|
|
128
|
-
]),
|
|
129
|
-
let _ = d.current !== n, v = f.current, y =
|
|
127
|
+
]), P.useEffect(() => n._removeUnmounted());
|
|
128
|
+
let _ = d.current !== n, v = f.current, y = P.useMemo(() => {
|
|
130
129
|
if (a) return null;
|
|
131
|
-
let e = !_ && !
|
|
130
|
+
let e = !_ && !X(v, r);
|
|
132
131
|
return _ || e ? h() : null;
|
|
133
132
|
}, [
|
|
134
133
|
a,
|
|
@@ -139,15 +138,15 @@ function Be(e) {
|
|
|
139
138
|
]);
|
|
140
139
|
return y === null ? p : y;
|
|
141
140
|
}
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
var
|
|
141
|
+
var We = P.createContext(null);
|
|
142
|
+
We.displayName = "HookFormContext";
|
|
143
|
+
var Ge = (e, t, n, r, i) => t ? {
|
|
145
144
|
...n[e],
|
|
146
145
|
types: {
|
|
147
146
|
...n[e] && n[e].types ? n[e].types : {},
|
|
148
147
|
[r]: i || !0
|
|
149
148
|
}
|
|
150
|
-
} : {},
|
|
149
|
+
} : {}, Ke = (e) => Array.isArray(e) ? e : [e], qe = () => {
|
|
151
150
|
let e = [];
|
|
152
151
|
return {
|
|
153
152
|
get observers() {
|
|
@@ -164,23 +163,23 @@ var He = (e, t, n, r, i) => t ? {
|
|
|
164
163
|
}
|
|
165
164
|
};
|
|
166
165
|
};
|
|
167
|
-
function
|
|
166
|
+
function Je(e, t) {
|
|
168
167
|
let n = {};
|
|
169
168
|
for (let r in e) if (e.hasOwnProperty(r)) {
|
|
170
169
|
let i = e[r], a = t[r];
|
|
171
170
|
if (i && B(i) && a) {
|
|
172
|
-
let e =
|
|
171
|
+
let e = Je(i, a);
|
|
173
172
|
B(e) && (n[r] = e);
|
|
174
173
|
} else e[r] && (n[r] = a);
|
|
175
174
|
}
|
|
176
175
|
return n;
|
|
177
176
|
}
|
|
178
|
-
var
|
|
179
|
-
if (!
|
|
177
|
+
var Z = (e) => B(e) && !Object.keys(e).length, Ye = (e) => e.type === "file", Xe = (e) => {
|
|
178
|
+
if (!Ae) return !1;
|
|
180
179
|
let t = e ? e.ownerDocument : 0;
|
|
181
180
|
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
182
|
-
},
|
|
183
|
-
function
|
|
181
|
+
}, Ze = (e) => e.type === "select-multiple", Qe = (e) => e.type === "radio", $e = (e) => Qe(e) || Te(e), et = (e) => Xe(e) && e.isConnected;
|
|
182
|
+
function tt(e, t) {
|
|
184
183
|
let n = t.slice(0, -1).length, r = 0;
|
|
185
184
|
for (; r < n;) {
|
|
186
185
|
if (z(e)) {
|
|
@@ -191,65 +190,65 @@ function Qe(e, t) {
|
|
|
191
190
|
}
|
|
192
191
|
return e;
|
|
193
192
|
}
|
|
194
|
-
function
|
|
193
|
+
function nt(e) {
|
|
195
194
|
for (let t in e) if (e.hasOwnProperty(t) && !H(e[t])) return !1;
|
|
196
195
|
return !0;
|
|
197
196
|
}
|
|
198
|
-
function
|
|
199
|
-
if (
|
|
200
|
-
let n = Array.isArray(t) ? t :
|
|
201
|
-
return r && delete r[a], i !== 0 && (B(r) &&
|
|
197
|
+
function Q(e, t) {
|
|
198
|
+
if (Y(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
|
|
199
|
+
let n = Array.isArray(t) ? t : je(t) ? [t] : Ne(t), r = n.length === 1 ? e : tt(e, n), i = n.length - 1, a = n[i];
|
|
200
|
+
return r && delete r[a], i !== 0 && (B(r) && Z(r) || Array.isArray(r) && nt(r)) && Q(e, n.slice(0, -1)), e;
|
|
202
201
|
}
|
|
203
|
-
var
|
|
202
|
+
var rt = (e) => {
|
|
204
203
|
for (let t in e) if (G(e[t])) return !0;
|
|
205
204
|
return !1;
|
|
206
205
|
};
|
|
207
|
-
function
|
|
208
|
-
return Array.isArray(e) || B(e) && !
|
|
206
|
+
function it(e) {
|
|
207
|
+
return Array.isArray(e) || B(e) && !rt(e);
|
|
209
208
|
}
|
|
210
|
-
function
|
|
209
|
+
function at(e, t = {}) {
|
|
211
210
|
for (let n in e) {
|
|
212
211
|
let r = e[n];
|
|
213
|
-
|
|
212
|
+
it(r) ? (t[n] = Array.isArray(r) ? [] : {}, at(r, t[n])) : H(r) || (t[n] = !0);
|
|
214
213
|
}
|
|
215
214
|
return t;
|
|
216
215
|
}
|
|
217
|
-
function
|
|
216
|
+
function ot(e) {
|
|
218
217
|
if (e !== !1) {
|
|
219
218
|
if (e === !0) return !0;
|
|
220
219
|
if (Array.isArray(e)) {
|
|
221
|
-
let t = e.map((e) =>
|
|
220
|
+
let t = e.map((e) => ot(e));
|
|
222
221
|
return t.some((e) => e !== void 0) ? t : void 0;
|
|
223
222
|
}
|
|
224
223
|
if (B(e)) {
|
|
225
224
|
let t = {};
|
|
226
225
|
for (let n in e) {
|
|
227
|
-
let r =
|
|
226
|
+
let r = ot(e[n]);
|
|
228
227
|
H(r) || (t[n] = r);
|
|
229
228
|
}
|
|
230
229
|
return Object.keys(t).length ? t : void 0;
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
232
|
}
|
|
234
|
-
function
|
|
235
|
-
n ||=
|
|
233
|
+
function st(e, t, n) {
|
|
234
|
+
n ||= at(t);
|
|
236
235
|
for (let r in e) {
|
|
237
236
|
let i = e[r];
|
|
238
|
-
if (
|
|
237
|
+
if (it(i)) H(t) || He(n[r]) ? n[r] = at(i, Array.isArray(i) ? [] : {}) : st(i, z(t) ? {} : t[r], n[r]);
|
|
239
238
|
else {
|
|
240
239
|
let e = t[r];
|
|
241
|
-
n[r] = !
|
|
240
|
+
n[r] = !X(i, e);
|
|
242
241
|
}
|
|
243
242
|
}
|
|
244
|
-
return
|
|
243
|
+
return ot(n) || {};
|
|
245
244
|
}
|
|
246
|
-
var
|
|
245
|
+
var ct = {
|
|
247
246
|
value: !1,
|
|
248
247
|
isValid: !1
|
|
249
|
-
},
|
|
248
|
+
}, lt = {
|
|
250
249
|
value: !0,
|
|
251
250
|
isValid: !0
|
|
252
|
-
},
|
|
251
|
+
}, ut = (e) => {
|
|
253
252
|
if (Array.isArray(e)) {
|
|
254
253
|
if (e.length > 1) {
|
|
255
254
|
let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
@@ -258,24 +257,24 @@ var at = {
|
|
|
258
257
|
isValid: !!t.length
|
|
259
258
|
};
|
|
260
259
|
}
|
|
261
|
-
return e[0].checked && !e[0].disabled ? e[0].attributes && !H(e[0].attributes.value) ? H(e[0].value) || e[0].value === "" ?
|
|
260
|
+
return e[0].checked && !e[0].disabled ? e[0].attributes && !H(e[0].attributes.value) ? H(e[0].value) || e[0].value === "" ? lt : {
|
|
262
261
|
value: e[0].value,
|
|
263
262
|
isValid: !0
|
|
264
|
-
} :
|
|
263
|
+
} : lt : ct;
|
|
265
264
|
}
|
|
266
|
-
return
|
|
267
|
-
},
|
|
265
|
+
return ct;
|
|
266
|
+
}, dt = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => H(e) ? e : t ? e === "" ? NaN : e && +e : n && Y(e) ? new Date(e) : r ? r(e) : e, ft = {
|
|
268
267
|
isValid: !1,
|
|
269
268
|
value: null
|
|
270
|
-
},
|
|
269
|
+
}, pt = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
|
|
271
270
|
isValid: !0,
|
|
272
271
|
value: t.value
|
|
273
|
-
} : e,
|
|
274
|
-
function
|
|
272
|
+
} : e, ft) : ft;
|
|
273
|
+
function mt(e) {
|
|
275
274
|
let t = e.ref;
|
|
276
|
-
return
|
|
275
|
+
return Ye(t) ? t.files : Qe(t) ? pt(e.refs).value : Ze(t) ? [...t.selectedOptions].map(({ value: e }) => e) : Te(t) ? ut(e.refs).value : dt(H(t.value) ? e.ref.value : t.value, e);
|
|
277
276
|
}
|
|
278
|
-
var
|
|
277
|
+
var ht = (e, t, n, r) => {
|
|
279
278
|
let i = {};
|
|
280
279
|
for (let n of e) {
|
|
281
280
|
let e = U(t, n);
|
|
@@ -287,27 +286,27 @@ var ft = (e, t, n, r) => {
|
|
|
287
286
|
fields: i,
|
|
288
287
|
shouldUseNativeValidation: r
|
|
289
288
|
};
|
|
290
|
-
},
|
|
291
|
-
isOnSubmit: !e || e ===
|
|
292
|
-
isOnBlur: e ===
|
|
293
|
-
isOnChange: e ===
|
|
294
|
-
isOnAll: e ===
|
|
295
|
-
isOnTouch: e ===
|
|
296
|
-
}),
|
|
289
|
+
}, gt = (e) => e instanceof RegExp, _t = (e) => H(e) ? e : gt(e) ? e.source : B(e) ? gt(e.value) ? e.value.source : e.value : e, vt = (e) => ({
|
|
290
|
+
isOnSubmit: !e || e === q.onSubmit,
|
|
291
|
+
isOnBlur: e === q.onBlur,
|
|
292
|
+
isOnChange: e === q.onChange,
|
|
293
|
+
isOnAll: e === q.all,
|
|
294
|
+
isOnTouch: e === q.onTouched
|
|
295
|
+
}), yt = "AsyncFunction", bt = (e) => !!e && !!e.validate && !!(G(e.validate) && e.validate.constructor.name === yt || B(e.validate) && Object.values(e.validate).find((e) => e.constructor.name === yt)), xt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), St = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(t) && /^\.\w+/.test(e.slice(t.length)))), Ct = (e, t, n, r) => {
|
|
297
296
|
for (let i of n || Object.keys(e)) {
|
|
298
297
|
let n = U(e, i);
|
|
299
298
|
if (n) {
|
|
300
299
|
let { _f: e, ...a } = n;
|
|
301
300
|
if (e) {
|
|
302
301
|
if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
|
|
303
|
-
if (
|
|
304
|
-
} else if (B(a) &&
|
|
302
|
+
if (Ct(a, t)) break;
|
|
303
|
+
} else if (B(a) && Ct(a, t)) break;
|
|
305
304
|
}
|
|
306
305
|
}
|
|
307
306
|
};
|
|
308
|
-
function
|
|
307
|
+
function wt(e, t, n) {
|
|
309
308
|
let r = U(e, n);
|
|
310
|
-
if (r ||
|
|
309
|
+
if (r || je(n)) return {
|
|
311
310
|
error: r,
|
|
312
311
|
name: n
|
|
313
312
|
};
|
|
@@ -327,103 +326,103 @@ function xt(e, t, n) {
|
|
|
327
326
|
}
|
|
328
327
|
return { name: n };
|
|
329
328
|
}
|
|
330
|
-
var
|
|
329
|
+
var Tt = (e, t, n, r) => {
|
|
331
330
|
n(e);
|
|
332
331
|
let { name: i, ...a } = e;
|
|
333
|
-
return
|
|
334
|
-
},
|
|
335
|
-
let r =
|
|
336
|
-
return K(r,
|
|
332
|
+
return Z(a) || r && Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((e) => t[e] === (!r || q.all));
|
|
333
|
+
}, Et = (e, t, n) => !e || !t || e === t || Ke(e).some((e) => e && (n ? e === t : e.startsWith(t) || t.startsWith(e))), Dt = (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, Ot = (e, t) => !Me(U(e, t)).length && Q(e, t), kt = (e, t, n) => {
|
|
334
|
+
let r = Ke(U(e, n));
|
|
335
|
+
return K(r, Ie, t[n]), K(e, n, r), e;
|
|
337
336
|
};
|
|
338
|
-
function
|
|
339
|
-
if (
|
|
337
|
+
function At(e, t, n = "validate") {
|
|
338
|
+
if (Y(e) || Array.isArray(e) && e.every(Y) || W(e) && !e) return {
|
|
340
339
|
type: n,
|
|
341
|
-
message:
|
|
340
|
+
message: Y(e) ? e : "",
|
|
342
341
|
ref: t
|
|
343
342
|
};
|
|
344
343
|
}
|
|
345
|
-
var
|
|
344
|
+
var $ = (e) => B(e) && !gt(e) ? e : {
|
|
346
345
|
value: e,
|
|
347
346
|
message: ""
|
|
348
|
-
},
|
|
347
|
+
}, jt = async (e, t, n, r, i, a) => {
|
|
349
348
|
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);
|
|
350
349
|
if (!_ || t.has(h)) return {};
|
|
351
350
|
let y = s ? s[0] : o, b = (e) => {
|
|
352
351
|
i && y.reportValidity && (y.setCustomValidity(W(e) ? "" : e || ""), y.reportValidity());
|
|
353
|
-
}, x = {}, S =
|
|
352
|
+
}, x = {}, S = Qe(o), C = Te(o), w = S || C, T = (g || Ye(o)) && H(o.value) && H(v) || Xe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), E = Ge.bind(null, h, r, x), D = (e, t, n, r = J.maxLength, i = J.minLength) => {
|
|
354
353
|
let a = e ? t : n;
|
|
355
354
|
x[h] = {
|
|
356
355
|
type: e ? r : i,
|
|
357
356
|
message: a,
|
|
358
357
|
ref: o,
|
|
359
|
-
...
|
|
358
|
+
...E(e ? r : i, a)
|
|
360
359
|
};
|
|
361
360
|
};
|
|
362
|
-
if (a ? !Array.isArray(v) || !v.length : c && (!
|
|
363
|
-
let { value: e, message: t } =
|
|
361
|
+
if (a ? !Array.isArray(v) || !v.length : c && (!w && (T || z(v)) || W(v) && !v || C && !ut(s).isValid || S && !pt(s).isValid)) {
|
|
362
|
+
let { value: e, message: t } = Y(c) ? {
|
|
364
363
|
value: !!c,
|
|
365
364
|
message: c
|
|
366
|
-
} :
|
|
365
|
+
} : $(c);
|
|
367
366
|
if (e && (x[h] = {
|
|
368
|
-
type:
|
|
367
|
+
type: J.required,
|
|
369
368
|
message: t,
|
|
370
369
|
ref: y,
|
|
371
|
-
...
|
|
370
|
+
...E(J.required, t)
|
|
372
371
|
}, !r)) return b(t), x;
|
|
373
372
|
}
|
|
374
|
-
if (!
|
|
375
|
-
let e, t, n =
|
|
373
|
+
if (!T && (!z(d) || !z(f))) {
|
|
374
|
+
let e, t, n = $(f), i = $(d);
|
|
376
375
|
if (!z(v) && !isNaN(v)) {
|
|
377
376
|
let r = o.valueAsNumber || v && +v;
|
|
378
377
|
z(n.value) || (e = r > n.value), z(i.value) || (t = r < i.value);
|
|
379
378
|
} else {
|
|
380
379
|
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";
|
|
381
|
-
|
|
380
|
+
Y(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), Y(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
|
|
382
381
|
}
|
|
383
|
-
if ((e || t) && (
|
|
382
|
+
if ((e || t) && (D(!!e, n.message, i.message, J.max, J.min), !r)) return b(x[h].message), x;
|
|
384
383
|
}
|
|
385
|
-
if ((l || u) && !
|
|
386
|
-
let e =
|
|
387
|
-
if ((n || i) && (
|
|
384
|
+
if ((l || u) && !T && (Y(v) || a && Array.isArray(v))) {
|
|
385
|
+
let e = $(l), t = $(u), n = !z(e.value) && v.length > +e.value, i = !z(t.value) && v.length < +t.value;
|
|
386
|
+
if ((n || i) && (D(n, e.message, t.message), !r)) return b(x[h].message), x;
|
|
388
387
|
}
|
|
389
|
-
if (p && !
|
|
390
|
-
let { value: e, message: t } =
|
|
391
|
-
if (
|
|
392
|
-
type:
|
|
388
|
+
if (p && !T && Y(v)) {
|
|
389
|
+
let { value: e, message: t } = $(p);
|
|
390
|
+
if (gt(e) && !v.match(e) && (x[h] = {
|
|
391
|
+
type: J.pattern,
|
|
393
392
|
message: t,
|
|
394
393
|
ref: o,
|
|
395
|
-
...
|
|
394
|
+
...E(J.pattern, t)
|
|
396
395
|
}, !r)) return b(t), x;
|
|
397
396
|
}
|
|
398
397
|
if (m) {
|
|
399
398
|
if (G(m)) {
|
|
400
|
-
let e =
|
|
399
|
+
let e = At(await m(v, n), y);
|
|
401
400
|
if (e && (x[h] = {
|
|
402
401
|
...e,
|
|
403
|
-
...
|
|
402
|
+
...E(J.validate, e.message)
|
|
404
403
|
}, !r)) return b(e.message), x;
|
|
405
404
|
} else if (B(m)) {
|
|
406
405
|
let e = {};
|
|
407
406
|
for (let t in m) {
|
|
408
|
-
if (!
|
|
409
|
-
let i =
|
|
407
|
+
if (!Z(e) && !r) break;
|
|
408
|
+
let i = At(await m[t](v, n), y, t);
|
|
410
409
|
i && (e = {
|
|
411
410
|
...i,
|
|
412
|
-
...
|
|
411
|
+
...E(t, i.message)
|
|
413
412
|
}, b(i.message), r && (x[h] = e));
|
|
414
413
|
}
|
|
415
|
-
if (!
|
|
414
|
+
if (!Z(e) && (x[h] = {
|
|
416
415
|
ref: y,
|
|
417
416
|
...e
|
|
418
417
|
}, !r)) return x;
|
|
419
418
|
}
|
|
420
419
|
}
|
|
421
420
|
return b(!0), x;
|
|
422
|
-
},
|
|
423
|
-
mode:
|
|
424
|
-
reValidateMode:
|
|
421
|
+
}, Mt = {
|
|
422
|
+
mode: q.onSubmit,
|
|
423
|
+
reValidateMode: q.onChange,
|
|
425
424
|
shouldFocusError: !0
|
|
426
|
-
},
|
|
425
|
+
}, Nt = {
|
|
427
426
|
submitCount: 0,
|
|
428
427
|
isDirty: !1,
|
|
429
428
|
isReady: !1,
|
|
@@ -436,12 +435,12 @@ var Ot = (e) => B(e) && !pt(e) ? e : {
|
|
|
436
435
|
dirtyFields: {},
|
|
437
436
|
validatingFields: {}
|
|
438
437
|
};
|
|
439
|
-
function
|
|
438
|
+
function Pt(e = {}) {
|
|
440
439
|
let t = {
|
|
441
|
-
...
|
|
440
|
+
...Mt,
|
|
442
441
|
...e
|
|
443
442
|
}, n = {
|
|
444
|
-
...V(
|
|
443
|
+
...V(Nt),
|
|
445
444
|
isLoading: G(t.defaultValues),
|
|
446
445
|
errors: t.errors || {},
|
|
447
446
|
disabled: t.disabled || !1
|
|
@@ -466,28 +465,28 @@ function Mt(e = {}) {
|
|
|
466
465
|
isValid: !1,
|
|
467
466
|
errors: !1
|
|
468
467
|
}, d = { ...u }, f = { ...d }, p = {
|
|
469
|
-
array:
|
|
470
|
-
state:
|
|
471
|
-
}, m = t.criteriaMode ===
|
|
468
|
+
array: qe(),
|
|
469
|
+
state: qe()
|
|
470
|
+
}, m = t.criteriaMode === q.all, h = (e) => (t) => {
|
|
472
471
|
clearTimeout(l), l = setTimeout(e, t);
|
|
473
472
|
}, g = async (e) => {
|
|
474
473
|
if (!o.keepIsValid && !t.disabled && (d.isValid || f.isValid || e)) {
|
|
475
474
|
let e;
|
|
476
|
-
t.resolver ? (e =
|
|
475
|
+
t.resolver ? (e = Z((await T()).errors), _()) : e = await O({
|
|
477
476
|
fields: r,
|
|
478
477
|
onlyCheckValid: !0,
|
|
479
|
-
eventType:
|
|
478
|
+
eventType: Pe.VALID
|
|
480
479
|
}), e !== n.isValid && p.state.next({ isValid: e });
|
|
481
480
|
}
|
|
482
481
|
}, _ = (e, r) => {
|
|
483
482
|
!t.disabled && (d.isValidating || d.validatingFields || f.isValidating || f.validatingFields) && ((e || Array.from(s.mount)).forEach((e) => {
|
|
484
|
-
e && (r ? K(n.validatingFields, e, r) :
|
|
483
|
+
e && (r ? K(n.validatingFields, e, r) : Q(n.validatingFields, e));
|
|
485
484
|
}), p.state.next({
|
|
486
485
|
validatingFields: n.validatingFields,
|
|
487
|
-
isValidating: !
|
|
486
|
+
isValidating: !Z(n.validatingFields)
|
|
488
487
|
}));
|
|
489
488
|
}, v = () => {
|
|
490
|
-
n.dirtyFields =
|
|
489
|
+
n.dirtyFields = st(i, a);
|
|
491
490
|
}, y = (e, i = [], s, c, l = !0, u = !0) => {
|
|
492
491
|
if (c && s && !t.disabled) {
|
|
493
492
|
if (o.action = !0, u && Array.isArray(U(r, e))) {
|
|
@@ -496,7 +495,7 @@ function Mt(e = {}) {
|
|
|
496
495
|
}
|
|
497
496
|
if (u && Array.isArray(U(n.errors, e))) {
|
|
498
497
|
let t = s(U(n.errors, e), c.argA, c.argB);
|
|
499
|
-
l && K(n.errors, e, t),
|
|
498
|
+
l && K(n.errors, e, t), Ot(n.errors, e);
|
|
500
499
|
}
|
|
501
500
|
if ((d.touchedFields || f.touchedFields) && u && Array.isArray(U(n.touchedFields, e))) {
|
|
502
501
|
let t = s(U(n.touchedFields, e), c.argA, c.argB);
|
|
@@ -504,7 +503,7 @@ function Mt(e = {}) {
|
|
|
504
503
|
}
|
|
505
504
|
(d.dirtyFields || f.dirtyFields) && v(), p.state.next({
|
|
506
505
|
name: e,
|
|
507
|
-
isDirty:
|
|
506
|
+
isDirty: A(e, i),
|
|
508
507
|
dirtyFields: n.dirtyFields,
|
|
509
508
|
errors: n.errors,
|
|
510
509
|
isValid: n.isValid
|
|
@@ -521,15 +520,15 @@ function Mt(e = {}) {
|
|
|
521
520
|
let l = U(r, e);
|
|
522
521
|
if (l) {
|
|
523
522
|
let r = H(U(a, e)), u = U(a, e, H(s) ? U(i, e) : s);
|
|
524
|
-
H(u) || c && c.defaultChecked || t ? K(a, e, t ? u :
|
|
523
|
+
H(u) || c && c.defaultChecked || t ? K(a, e, t ? u : mt(l._f)) : te(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (A() || (n.isDirty = !1, p.state.next({ ...n }))));
|
|
525
524
|
}
|
|
526
525
|
}, C = (e, r, a, o, s) => {
|
|
527
526
|
let c = !1, l = !1, u = { name: e };
|
|
528
527
|
if (!t.disabled) {
|
|
529
528
|
if (!a || o) {
|
|
530
|
-
(d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty =
|
|
531
|
-
let t =
|
|
532
|
-
l = !!U(n.dirtyFields, e), t ?
|
|
529
|
+
(d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = A(), c = l !== u.isDirty);
|
|
530
|
+
let t = X(U(i, e), r);
|
|
531
|
+
l = !!U(n.dirtyFields, e), t ? Q(n.dirtyFields, e) : K(n.dirtyFields, e, !0), u.dirtyFields = n.dirtyFields, c ||= (d.dirtyFields || f.dirtyFields) && l !== !t;
|
|
533
532
|
}
|
|
534
533
|
if (a) {
|
|
535
534
|
let t = U(n.touchedFields, e);
|
|
@@ -538,9 +537,9 @@ function Mt(e = {}) {
|
|
|
538
537
|
c && s && p.state.next(u);
|
|
539
538
|
}
|
|
540
539
|
return c ? u : {};
|
|
541
|
-
},
|
|
540
|
+
}, w = (e, r, i, a) => {
|
|
542
541
|
let o = U(n.errors, e), s = (d.isValid || f.isValid) && W(r) && n.isValid !== r;
|
|
543
|
-
if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? K(n.errors, e, i) :
|
|
542
|
+
if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? K(n.errors, e, i) : Q(n.errors, e)), (i ? !X(o, i) : o) || !Z(a) || s) {
|
|
544
543
|
let t = {
|
|
545
544
|
...a,
|
|
546
545
|
...s && W(r) ? { isValid: r } : {},
|
|
@@ -552,15 +551,15 @@ function Mt(e = {}) {
|
|
|
552
551
|
...t
|
|
553
552
|
}, p.state.next(t);
|
|
554
553
|
}
|
|
555
|
-
},
|
|
556
|
-
let { errors: t } = await
|
|
554
|
+
}, T = async (e) => (_(e, !0), await t.resolver(a, t.context, ht(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), E = async (e) => {
|
|
555
|
+
let { errors: t } = await T(e);
|
|
557
556
|
if (_(e), e) for (let r of e) {
|
|
558
557
|
let e = U(t, r);
|
|
559
|
-
e ? K(n.errors, r, e) :
|
|
558
|
+
e ? K(n.errors, r, e) : Q(n.errors, r);
|
|
560
559
|
}
|
|
561
560
|
else n.errors = t;
|
|
562
561
|
return t;
|
|
563
|
-
},
|
|
562
|
+
}, D = async ({ name: t, eventType: r }) => {
|
|
564
563
|
if (e.validate) {
|
|
565
564
|
let i = await e.validate({
|
|
566
565
|
formValues: a,
|
|
@@ -568,22 +567,22 @@ function Mt(e = {}) {
|
|
|
568
567
|
name: t,
|
|
569
568
|
eventType: r
|
|
570
569
|
});
|
|
571
|
-
if (B(i)) for (let e in i) i[e] &&
|
|
572
|
-
message:
|
|
573
|
-
type:
|
|
570
|
+
if (B(i)) for (let e in i) i[e] && le(`${Fe}.${e}`, {
|
|
571
|
+
message: Y(i.message) ? i.message : "",
|
|
572
|
+
type: J.validate
|
|
574
573
|
});
|
|
575
|
-
else
|
|
574
|
+
else Y(i) || !i ? le(Fe, {
|
|
576
575
|
message: i || "",
|
|
577
|
-
type:
|
|
578
|
-
}) :
|
|
576
|
+
type: J.validate
|
|
577
|
+
}) : ce(Fe);
|
|
579
578
|
return i;
|
|
580
579
|
}
|
|
581
580
|
return !0;
|
|
582
|
-
},
|
|
581
|
+
}, O = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
|
|
583
582
|
valid: !0,
|
|
584
583
|
runRootValidation: !1
|
|
585
584
|
} }) => {
|
|
586
|
-
if (e.validate && (l.runRootValidation = !0, !await
|
|
585
|
+
if (e.validate && (l.runRootValidation = !0, !await D({
|
|
587
586
|
name: o,
|
|
588
587
|
eventType: c
|
|
589
588
|
}) && (l.valid = !1, i))) return l.valid;
|
|
@@ -592,12 +591,12 @@ function Mt(e = {}) {
|
|
|
592
591
|
if (u) {
|
|
593
592
|
let { _f: r, ...f } = u;
|
|
594
593
|
if (r) {
|
|
595
|
-
let o = s.array.has(r.name), c = u._f &&
|
|
594
|
+
let o = s.array.has(r.name), c = u._f && bt(u._f);
|
|
596
595
|
c && d.validatingFields && _([r.name], !0);
|
|
597
|
-
let f = await
|
|
598
|
-
if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (U(f, r.name) ? o ?
|
|
596
|
+
let f = await jt(u, s.disabled, a, m, t.shouldUseNativeValidation && !i, o);
|
|
597
|
+
if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (U(f, r.name) ? o ? kt(n.errors, f, r.name) : K(n.errors, r.name, f[r.name]) : Q(n.errors, r.name)), e.shouldUseNativeValidation && f[r.name])) break;
|
|
599
598
|
}
|
|
600
|
-
!
|
|
599
|
+
!Z(f) && await O({
|
|
601
600
|
context: l,
|
|
602
601
|
onlyCheckValid: i,
|
|
603
602
|
fields: f,
|
|
@@ -607,136 +606,136 @@ function Mt(e = {}) {
|
|
|
607
606
|
}
|
|
608
607
|
}
|
|
609
608
|
return l.valid;
|
|
610
|
-
},
|
|
609
|
+
}, k = () => {
|
|
611
610
|
for (let e of s.unMount) {
|
|
612
611
|
let t = U(r, e);
|
|
613
|
-
t && (t._f.refs ? t._f.refs.every((e) => !
|
|
612
|
+
t && (t._f.refs ? t._f.refs.every((e) => !et(e)) : !et(t._f.ref)) && pe(e);
|
|
614
613
|
}
|
|
615
614
|
s.unMount = /* @__PURE__ */ new Set();
|
|
616
|
-
},
|
|
615
|
+
}, A = (e, n) => !t.disabled && (e && n && K(a, e, n), !X(se(), i)), j = (e, t, n) => Ve(e, s, { ...o.mount ? a : H(t) ? i : Y(e) ? { [e]: t } : t }, n, t), ee = (e) => Me(U(o.mount ? a : i, e, t.shouldUnregister ? U(i, e, []) : [])), te = (e, t, n = {}) => {
|
|
617
616
|
let i = U(r, e), o = t;
|
|
618
617
|
if (i) {
|
|
619
618
|
let n = i._f;
|
|
620
|
-
n && (!n.disabled && K(a, e,
|
|
619
|
+
n && (!n.disabled && K(a, e, dt(t, n)), o = Xe(n.ref) && z(t) ? "" : t, Ze(n.ref) ? [...n.ref.options].forEach((e) => e.selected = o.includes(e.value)) : n.refs ? Te(n.ref) ? n.refs.forEach((e) => {
|
|
621
620
|
(!e.defaultChecked || !e.disabled) && (Array.isArray(o) ? e.checked = !!o.find((t) => t === e.value) : e.checked = o === e.value || !!o);
|
|
622
|
-
}) : n.refs.forEach((e) => e.checked = e.value === o) :
|
|
621
|
+
}) : n.refs.forEach((e) => e.checked = e.value === o) : Ye(n.ref) ? n.ref.value = "" : (n.ref.value = o, n.ref.type || p.state.next({
|
|
623
622
|
name: e,
|
|
624
623
|
values: V(a)
|
|
625
624
|
})));
|
|
626
625
|
}
|
|
627
|
-
(n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate &&
|
|
628
|
-
},
|
|
626
|
+
(n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && oe(e);
|
|
627
|
+
}, ne = (e, t, n) => {
|
|
629
628
|
for (let i in t) {
|
|
630
629
|
if (!t.hasOwnProperty(i)) return;
|
|
631
630
|
let a = t[i], o = e + "." + i, c = U(r, o);
|
|
632
|
-
(s.array.has(e) || B(a) || c && !c._f) && !R(a) ?
|
|
631
|
+
(s.array.has(e) || B(a) || c && !c._f) && !R(a) ? ne(o, a, n) : te(o, a, n);
|
|
633
632
|
}
|
|
634
|
-
},
|
|
635
|
-
let c = U(r, e), l = s.array.has(e), u = V(t), m =
|
|
633
|
+
}, re = (e, t, i = {}) => {
|
|
634
|
+
let c = U(r, e), l = s.array.has(e), u = V(t), m = X(U(a, e), u);
|
|
636
635
|
if (K(a, e, u), l) p.array.next({
|
|
637
636
|
name: e,
|
|
638
637
|
values: V(a)
|
|
639
638
|
}), (d.isDirty || d.dirtyFields || f.isDirty || f.dirtyFields) && i.shouldDirty && (v(), p.state.next({
|
|
640
639
|
name: e,
|
|
641
640
|
dirtyFields: n.dirtyFields,
|
|
642
|
-
isDirty:
|
|
641
|
+
isDirty: A(e, u)
|
|
643
642
|
}));
|
|
644
643
|
else {
|
|
645
|
-
let t = Array.isArray(u) && !u.length ||
|
|
646
|
-
!c || c._f || z(u) || t ?
|
|
644
|
+
let t = Array.isArray(u) && !u.length || Z(u);
|
|
645
|
+
!c || c._f || z(u) || t ? te(e, u, i) : ne(e, u, i);
|
|
647
646
|
}
|
|
648
647
|
if (!m) {
|
|
649
|
-
let t =
|
|
648
|
+
let t = St(e, s);
|
|
650
649
|
p.state.next({
|
|
651
650
|
...t && n,
|
|
652
651
|
name: o.mount || t ? e : void 0,
|
|
653
652
|
values: V(a)
|
|
654
653
|
});
|
|
655
654
|
}
|
|
656
|
-
},
|
|
655
|
+
}, ie = (e) => {
|
|
657
656
|
let t = G(e) ? e(a) : e;
|
|
658
|
-
|
|
657
|
+
X(a, t) || (a = {
|
|
659
658
|
...a,
|
|
660
659
|
...t
|
|
661
660
|
}, p.state.next({
|
|
662
661
|
...n,
|
|
663
662
|
values: a
|
|
664
663
|
}));
|
|
665
|
-
},
|
|
664
|
+
}, ae = async (i) => {
|
|
666
665
|
o.mount = !0;
|
|
667
666
|
let l = i.target, u = l.name, h = !0, v = U(r, u), y = (e) => {
|
|
668
|
-
h = Number.isNaN(e) || R(e) && isNaN(e.getTime()) ||
|
|
669
|
-
}, b =
|
|
667
|
+
h = Number.isNaN(e) || R(e) && isNaN(e.getTime()) || X(e, U(a, u, e));
|
|
668
|
+
}, b = vt(t.mode), x = vt(t.reValidateMode);
|
|
670
669
|
if (v) {
|
|
671
|
-
let o, S,
|
|
672
|
-
K(a, u,
|
|
673
|
-
let
|
|
674
|
-
if (!
|
|
670
|
+
let o, S, E = l.type ? mt(v._f) : De(i), k = i.type === Pe.BLUR || i.type === Pe.FOCUS_OUT, A = !xt(v._f) && !e.validate && !t.resolver && !U(n.errors, u) && !v._f.deps || Dt(k, U(n.touchedFields, u), n.isSubmitted, x, b), j = St(u, s, k);
|
|
671
|
+
K(a, u, E), k ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
|
|
672
|
+
let ee = C(u, E, k), te = !Z(ee) || j;
|
|
673
|
+
if (!k && p.state.next({
|
|
675
674
|
name: u,
|
|
676
675
|
type: i.type,
|
|
677
676
|
values: V(a)
|
|
678
|
-
}),
|
|
677
|
+
}), A) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? k && g() : k || g()), te && p.state.next({
|
|
679
678
|
name: u,
|
|
680
|
-
...
|
|
679
|
+
...j ? {} : ee
|
|
681
680
|
});
|
|
682
|
-
if (!t.resolver && e.validate && await
|
|
681
|
+
if (!t.resolver && e.validate && await D({
|
|
683
682
|
name: u,
|
|
684
683
|
eventType: i.type
|
|
685
|
-
}), !
|
|
686
|
-
let { errors: e } = await
|
|
687
|
-
if (_([u]), y(
|
|
688
|
-
let t =
|
|
689
|
-
o = i.error, u = i.name, S =
|
|
684
|
+
}), !k && j && p.state.next({ ...n }), t.resolver) {
|
|
685
|
+
let { errors: e } = await T([u]);
|
|
686
|
+
if (_([u]), y(E), h) {
|
|
687
|
+
let t = wt(n.errors, r, u), i = wt(e, r, t.name || u);
|
|
688
|
+
o = i.error, u = i.name, S = Z(e);
|
|
690
689
|
}
|
|
691
|
-
} else _([u], !0), o = (await
|
|
690
|
+
} else _([u], !0), o = (await jt(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(E), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await O({
|
|
692
691
|
fields: r,
|
|
693
692
|
onlyCheckValid: !0,
|
|
694
693
|
name: u,
|
|
695
694
|
eventType: i.type
|
|
696
695
|
})));
|
|
697
|
-
h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) &&
|
|
696
|
+
h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && oe(v._f.deps), w(u, S, o, ee));
|
|
698
697
|
}
|
|
699
|
-
},
|
|
698
|
+
}, M = (e, t) => {
|
|
700
699
|
if (U(n.errors, t) && e.focus) return e.focus(), 1;
|
|
701
|
-
},
|
|
702
|
-
let a, o, c =
|
|
700
|
+
}, oe = async (e, i = {}) => {
|
|
701
|
+
let a, o, c = Ke(e);
|
|
703
702
|
if (t.resolver) {
|
|
704
|
-
let t = await
|
|
705
|
-
a =
|
|
703
|
+
let t = await E(H(e) ? e : c);
|
|
704
|
+
a = Z(t), o = e ? !c.some((e) => U(t, e)) : a;
|
|
706
705
|
} else e ? (o = (await Promise.all(c.map(async (e) => {
|
|
707
706
|
let t = U(r, e);
|
|
708
|
-
return await
|
|
707
|
+
return await O({
|
|
709
708
|
fields: t && t._f ? { [e]: t } : t,
|
|
710
|
-
eventType:
|
|
709
|
+
eventType: Pe.TRIGGER
|
|
711
710
|
});
|
|
712
|
-
}))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await
|
|
711
|
+
}))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await O({
|
|
713
712
|
fields: r,
|
|
714
713
|
name: e,
|
|
715
|
-
eventType:
|
|
714
|
+
eventType: Pe.TRIGGER
|
|
716
715
|
});
|
|
717
716
|
return p.state.next({
|
|
718
|
-
...!
|
|
717
|
+
...!Y(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
|
|
719
718
|
...t.resolver || !e ? { isValid: a } : {},
|
|
720
719
|
errors: n.errors
|
|
721
|
-
}), i.shouldFocus && !o &&
|
|
722
|
-
},
|
|
720
|
+
}), i.shouldFocus && !o && Ct(r, M, e ? c : s.mount), o;
|
|
721
|
+
}, se = (e, t) => {
|
|
723
722
|
let r = { ...o.mount ? a : i };
|
|
724
|
-
return t && (r =
|
|
725
|
-
},
|
|
723
|
+
return t && (r = Je(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), H(e) ? r : Y(e) ? U(r, e) : e.map((e) => U(r, e));
|
|
724
|
+
}, N = (e, t) => ({
|
|
726
725
|
invalid: !!U((t || n).errors, e),
|
|
727
726
|
isDirty: !!U((t || n).dirtyFields, e),
|
|
728
727
|
error: U((t || n).errors, e),
|
|
729
728
|
isValidating: !!U(n.validatingFields, e),
|
|
730
729
|
isTouched: !!U((t || n).touchedFields, e)
|
|
731
|
-
}),
|
|
732
|
-
let t = e ?
|
|
733
|
-
t?.forEach((e) =>
|
|
730
|
+
}), ce = (e) => {
|
|
731
|
+
let t = e ? Ke(e) : void 0;
|
|
732
|
+
t?.forEach((e) => Q(n.errors, e)), t ? t.forEach((e) => {
|
|
734
733
|
p.state.next({
|
|
735
734
|
name: e,
|
|
736
735
|
errors: n.errors
|
|
737
736
|
});
|
|
738
737
|
}) : p.state.next({ errors: {} });
|
|
739
|
-
},
|
|
738
|
+
}, le = (e, t, i) => {
|
|
740
739
|
let a = (U(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = U(n.errors, e) || {};
|
|
741
740
|
K(n.errors, e, {
|
|
742
741
|
...l,
|
|
@@ -747,8 +746,8 @@ function Mt(e = {}) {
|
|
|
747
746
|
errors: n.errors,
|
|
748
747
|
isValid: !1
|
|
749
748
|
}), i && i.shouldFocus && a && a.focus && a.focus();
|
|
750
|
-
},
|
|
751
|
-
if (
|
|
749
|
+
}, ue = (e, t) => G(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || j(void 0, t), n) }) : j(e, t, !0), de = (e) => p.state.subscribe({ next: (t) => {
|
|
750
|
+
if (Et(e.name, t.name, e.exact) && Tt(t, e.formState || d, xe, e.reRenderRoot)) {
|
|
752
751
|
let r = { ...a };
|
|
753
752
|
e.callback({
|
|
754
753
|
values: r,
|
|
@@ -757,27 +756,27 @@ function Mt(e = {}) {
|
|
|
757
756
|
defaultValues: i
|
|
758
757
|
});
|
|
759
758
|
}
|
|
760
|
-
} }).unsubscribe,
|
|
759
|
+
} }).unsubscribe, fe = (e) => (o.mount = !0, f = {
|
|
761
760
|
...f,
|
|
762
761
|
...e.formState
|
|
763
|
-
},
|
|
762
|
+
}, de({
|
|
764
763
|
...e,
|
|
765
764
|
formState: {
|
|
766
765
|
...u,
|
|
767
766
|
...e.formState
|
|
768
767
|
}
|
|
769
|
-
})),
|
|
770
|
-
for (let c of e ?
|
|
768
|
+
})), pe = (e, o = {}) => {
|
|
769
|
+
for (let c of e ? Ke(e) : s.mount) s.mount.delete(c), s.array.delete(c), o.keepValue || (Q(r, c), Q(a, c)), !o.keepError && Q(n.errors, c), !o.keepDirty && Q(n.dirtyFields, c), !o.keepTouched && Q(n.touchedFields, c), !o.keepIsValidating && Q(n.validatingFields, c), !t.shouldUnregister && !o.keepDefaultValue && Q(i, c);
|
|
771
770
|
p.state.next({ values: V(a) }), p.state.next({
|
|
772
771
|
...n,
|
|
773
|
-
...o.keepDirty ? { isDirty:
|
|
772
|
+
...o.keepDirty ? { isDirty: A() } : {}
|
|
774
773
|
}), !o.keepIsValid && g();
|
|
775
|
-
},
|
|
774
|
+
}, me = ({ disabled: e, name: t }) => {
|
|
776
775
|
if (W(e) && o.mount || e || s.disabled.has(t)) {
|
|
777
776
|
let n = s.disabled.has(t) !== !!e;
|
|
778
777
|
e ? s.disabled.add(t) : s.disabled.delete(t), n && o.mount && !o.action && g();
|
|
779
778
|
}
|
|
780
|
-
},
|
|
779
|
+
}, he = (e, n = {}) => {
|
|
781
780
|
let a = U(r, e), c = W(n.disabled) || W(t.disabled), l = !s.registerName.has(e) && a && a._f && !a._f.mount;
|
|
782
781
|
return K(r, e, {
|
|
783
782
|
...a || {},
|
|
@@ -787,32 +786,32 @@ function Mt(e = {}) {
|
|
|
787
786
|
mount: !0,
|
|
788
787
|
...n
|
|
789
788
|
}
|
|
790
|
-
}), s.mount.add(e), a && !l ?
|
|
789
|
+
}), s.mount.add(e), a && !l ? me({
|
|
791
790
|
disabled: W(n.disabled) ? n.disabled : t.disabled,
|
|
792
791
|
name: e
|
|
793
792
|
}) : S(e, !0, n.value), {
|
|
794
793
|
...c ? { disabled: n.disabled || t.disabled } : {},
|
|
795
794
|
...t.progressive ? {
|
|
796
795
|
required: !!n.required,
|
|
797
|
-
min:
|
|
798
|
-
max:
|
|
799
|
-
minLength:
|
|
800
|
-
maxLength:
|
|
801
|
-
pattern:
|
|
796
|
+
min: _t(n.min),
|
|
797
|
+
max: _t(n.max),
|
|
798
|
+
minLength: _t(n.minLength),
|
|
799
|
+
maxLength: _t(n.maxLength),
|
|
800
|
+
pattern: _t(n.pattern)
|
|
802
801
|
} : {},
|
|
803
802
|
name: e,
|
|
804
|
-
onChange:
|
|
805
|
-
onBlur:
|
|
803
|
+
onChange: ae,
|
|
804
|
+
onBlur: ae,
|
|
806
805
|
ref: (c) => {
|
|
807
806
|
if (c) {
|
|
808
|
-
s.registerName.add(e),
|
|
809
|
-
let t = H(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o =
|
|
807
|
+
s.registerName.add(e), he(e, n), s.registerName.delete(e), a = U(r, e);
|
|
808
|
+
let t = H(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = $e(t), l = a._f.refs || [];
|
|
810
809
|
if (o ? l.find((e) => e === t) : t === a._f.ref) return;
|
|
811
810
|
K(r, e, { _f: {
|
|
812
811
|
...a._f,
|
|
813
812
|
...o ? {
|
|
814
813
|
refs: [
|
|
815
|
-
...l.filter(
|
|
814
|
+
...l.filter(et),
|
|
816
815
|
t,
|
|
817
816
|
...Array.isArray(U(i, e)) ? [{}] : []
|
|
818
817
|
],
|
|
@@ -822,11 +821,11 @@ function Mt(e = {}) {
|
|
|
822
821
|
}
|
|
823
822
|
} : { ref: t }
|
|
824
823
|
} }), S(e, !1, void 0, t);
|
|
825
|
-
} else a = U(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(
|
|
824
|
+
} else a = U(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(Oe(s.array, e) && o.action) && s.unMount.add(e);
|
|
826
825
|
}
|
|
827
826
|
};
|
|
828
|
-
}, P = () => t.shouldFocusError &&
|
|
829
|
-
W(e) && (p.state.next({ disabled: e }),
|
|
827
|
+
}, P = () => t.shouldFocusError && Ct(r, M, s.mount), ge = (e) => {
|
|
828
|
+
W(e) && (p.state.next({ disabled: e }), Ct(r, (t, n) => {
|
|
830
829
|
let i = U(r, n);
|
|
831
830
|
i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
|
|
832
831
|
t.disabled = i._f.disabled || e;
|
|
@@ -837,14 +836,14 @@ function Mt(e = {}) {
|
|
|
837
836
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
838
837
|
let l = V(a);
|
|
839
838
|
if (p.state.next({ isSubmitting: !0 }), t.resolver) {
|
|
840
|
-
let { errors: e, values: t } = await
|
|
839
|
+
let { errors: e, values: t } = await T();
|
|
841
840
|
_(), n.errors = e, l = V(t);
|
|
842
|
-
} else await
|
|
841
|
+
} else await O({
|
|
843
842
|
fields: r,
|
|
844
|
-
eventType:
|
|
843
|
+
eventType: Pe.SUBMIT
|
|
845
844
|
});
|
|
846
|
-
if (s.disabled.size) for (let e of s.disabled)
|
|
847
|
-
if (
|
|
845
|
+
if (s.disabled.size) for (let e of s.disabled) Q(l, e);
|
|
846
|
+
if (Q(n.errors, Ie), Z(n.errors)) {
|
|
848
847
|
p.state.next({ errors: {} });
|
|
849
848
|
try {
|
|
850
849
|
await e(l, o);
|
|
@@ -855,27 +854,27 @@ function Mt(e = {}) {
|
|
|
855
854
|
if (p.state.next({
|
|
856
855
|
isSubmitted: !0,
|
|
857
856
|
isSubmitting: !1,
|
|
858
|
-
isSubmitSuccessful:
|
|
857
|
+
isSubmitSuccessful: Z(n.errors) && !c,
|
|
859
858
|
submitCount: n.submitCount + 1,
|
|
860
859
|
errors: n.errors
|
|
861
860
|
}), c) throw c;
|
|
862
861
|
}, ve = (e, t = {}) => {
|
|
863
|
-
U(r, e) && (H(t.defaultValue) ?
|
|
864
|
-
},
|
|
865
|
-
let l = e ? V(e) : i, u = V(l), f =
|
|
862
|
+
U(r, e) && (H(t.defaultValue) ? re(e, V(U(i, e))) : (re(e, t.defaultValue), K(i, e, V(t.defaultValue))), t.keepTouched || Q(n.touchedFields, e), t.keepDirty || (Q(n.dirtyFields, e), n.isDirty = t.defaultValue ? A(e, V(U(i, e))) : A()), t.keepError || (Q(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
|
|
863
|
+
}, ye = (e, c = {}) => {
|
|
864
|
+
let l = e ? V(e) : i, u = V(l), f = Z(e), m = f ? i : u;
|
|
866
865
|
if (c.keepDefaultValues || (i = l), !c.keepValues) {
|
|
867
866
|
if (c.keepDirtyValues) {
|
|
868
|
-
let e = new Set([...s.mount, ...Object.keys(
|
|
867
|
+
let e = new Set([...s.mount, ...Object.keys(st(i, a))]);
|
|
869
868
|
for (let t of Array.from(e)) {
|
|
870
869
|
let e = U(n.dirtyFields, t), r = U(a, t), i = U(m, t);
|
|
871
|
-
e && !H(r) ? K(m, t, r) : !e && !H(i) &&
|
|
870
|
+
e && !H(r) ? K(m, t, r) : !e && !H(i) && re(t, i);
|
|
872
871
|
}
|
|
873
872
|
} else {
|
|
874
|
-
if (
|
|
873
|
+
if (Ae && H(e)) for (let e of s.mount) {
|
|
875
874
|
let t = U(r, e);
|
|
876
875
|
if (t && t._f) {
|
|
877
876
|
let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
|
|
878
|
-
if (
|
|
877
|
+
if (Xe(e)) {
|
|
879
878
|
let t = e.closest("form");
|
|
880
879
|
if (t) {
|
|
881
880
|
t.reset();
|
|
@@ -884,7 +883,7 @@ function Mt(e = {}) {
|
|
|
884
883
|
}
|
|
885
884
|
}
|
|
886
885
|
}
|
|
887
|
-
if (c.keepFieldsRef) for (let e of s.mount)
|
|
886
|
+
if (c.keepFieldsRef) for (let e of s.mount) re(e, U(m, e));
|
|
888
887
|
else r = {};
|
|
889
888
|
}
|
|
890
889
|
a = t.shouldUnregister ? c.keepDefaultValues ? V(i) : {} : V(m), p.array.next({ values: { ...m } }), p.state.next({ values: { ...m } });
|
|
@@ -898,21 +897,21 @@ function Mt(e = {}) {
|
|
|
898
897
|
watch: /* @__PURE__ */ new Set(),
|
|
899
898
|
watchAll: !1,
|
|
900
899
|
focus: ""
|
|
901
|
-
}, o.mount = !d.isValid || !!c.keepIsValid || !!c.keepDirtyValues || !t.shouldUnregister && !
|
|
900
|
+
}, o.mount = !d.isValid || !!c.keepIsValid || !!c.keepDirtyValues || !t.shouldUnregister && !Z(m), o.watch = !!t.shouldUnregister, o.keepIsValid = !!c.keepIsValid, o.action = !1, c.keepErrors || (n.errors = {}), p.state.next({
|
|
902
901
|
submitCount: c.keepSubmitCount ? n.submitCount : 0,
|
|
903
|
-
isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !
|
|
902
|
+
isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !X(e, i)),
|
|
904
903
|
isSubmitted: c.keepIsSubmitted ? n.isSubmitted : !1,
|
|
905
|
-
dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ?
|
|
904
|
+
dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? st(i, a) : n.dirtyFields : c.keepDefaultValues && e ? st(i, e) : c.keepDirty ? n.dirtyFields : {},
|
|
906
905
|
touchedFields: c.keepTouched ? n.touchedFields : {},
|
|
907
906
|
errors: c.keepErrors ? n.errors : {},
|
|
908
907
|
isSubmitSuccessful: c.keepIsSubmitSuccessful ? n.isSubmitSuccessful : !1,
|
|
909
908
|
isSubmitting: !1,
|
|
910
909
|
defaultValues: i
|
|
911
910
|
});
|
|
912
|
-
},
|
|
911
|
+
}, be = (e, n) => ye(G(e) ? e(a) : e, {
|
|
913
912
|
...t.resetOptions,
|
|
914
913
|
...n
|
|
915
|
-
}),
|
|
914
|
+
}), F = (e, t = {}) => {
|
|
916
915
|
let n = U(r, e), i = n && n._f;
|
|
917
916
|
if (i) {
|
|
918
917
|
let e = i.refs ? i.refs[0] : i.ref;
|
|
@@ -927,27 +926,27 @@ function Mt(e = {}) {
|
|
|
927
926
|
};
|
|
928
927
|
}, Se = {
|
|
929
928
|
control: {
|
|
930
|
-
register:
|
|
931
|
-
unregister:
|
|
932
|
-
getFieldState:
|
|
929
|
+
register: he,
|
|
930
|
+
unregister: pe,
|
|
931
|
+
getFieldState: N,
|
|
933
932
|
handleSubmit: _e,
|
|
934
|
-
setError:
|
|
935
|
-
_subscribe:
|
|
936
|
-
_runSchema:
|
|
933
|
+
setError: le,
|
|
934
|
+
_subscribe: de,
|
|
935
|
+
_runSchema: T,
|
|
937
936
|
_updateIsValidating: _,
|
|
938
937
|
_focusError: P,
|
|
939
|
-
_getWatch:
|
|
940
|
-
_getDirty:
|
|
938
|
+
_getWatch: j,
|
|
939
|
+
_getDirty: A,
|
|
941
940
|
_setValid: g,
|
|
942
941
|
_setFieldArray: y,
|
|
943
|
-
_setDisabledField:
|
|
942
|
+
_setDisabledField: me,
|
|
944
943
|
_setErrors: x,
|
|
945
|
-
_getFieldArray:
|
|
946
|
-
_reset:
|
|
944
|
+
_getFieldArray: ee,
|
|
945
|
+
_reset: ye,
|
|
947
946
|
_resetDefaultValues: () => G(t.defaultValues) && t.defaultValues().then((e) => {
|
|
948
|
-
|
|
947
|
+
be(e, t.resetOptions), p.state.next({ isLoading: !1 });
|
|
949
948
|
}),
|
|
950
|
-
_removeUnmounted:
|
|
949
|
+
_removeUnmounted: k,
|
|
951
950
|
_disableForm: ge,
|
|
952
951
|
_subjects: p,
|
|
953
952
|
_proxyFormState: d,
|
|
@@ -985,30 +984,30 @@ function Mt(e = {}) {
|
|
|
985
984
|
};
|
|
986
985
|
}
|
|
987
986
|
},
|
|
988
|
-
subscribe:
|
|
989
|
-
trigger:
|
|
990
|
-
register:
|
|
987
|
+
subscribe: fe,
|
|
988
|
+
trigger: oe,
|
|
989
|
+
register: he,
|
|
991
990
|
handleSubmit: _e,
|
|
992
|
-
watch:
|
|
993
|
-
setValue:
|
|
994
|
-
setValues:
|
|
995
|
-
getValues:
|
|
996
|
-
reset:
|
|
991
|
+
watch: ue,
|
|
992
|
+
setValue: re,
|
|
993
|
+
setValues: ie,
|
|
994
|
+
getValues: se,
|
|
995
|
+
reset: be,
|
|
997
996
|
resetField: ve,
|
|
998
|
-
clearErrors:
|
|
999
|
-
unregister:
|
|
1000
|
-
setError:
|
|
1001
|
-
setFocus:
|
|
1002
|
-
getFieldState:
|
|
997
|
+
clearErrors: ce,
|
|
998
|
+
unregister: pe,
|
|
999
|
+
setError: le,
|
|
1000
|
+
setFocus: F,
|
|
1001
|
+
getFieldState: N
|
|
1003
1002
|
};
|
|
1004
1003
|
return {
|
|
1005
1004
|
...Se,
|
|
1006
1005
|
formControl: Se
|
|
1007
1006
|
};
|
|
1008
1007
|
}
|
|
1009
|
-
function
|
|
1010
|
-
let t =
|
|
1011
|
-
...V(
|
|
1008
|
+
function Ft(e = {}) {
|
|
1009
|
+
let t = P.useRef(void 0), n = P.useRef(void 0), [r, i] = P.useState(() => ({
|
|
1010
|
+
...V(Nt),
|
|
1012
1011
|
isLoading: G(e.defaultValues),
|
|
1013
1012
|
errors: e.errors || {},
|
|
1014
1013
|
disabled: e.disabled || !1,
|
|
@@ -1019,14 +1018,14 @@ function Nt(e = {}) {
|
|
|
1019
1018
|
formState: r
|
|
1020
1019
|
}, e.defaultValues && !G(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1021
1020
|
else {
|
|
1022
|
-
let { formControl: n, ...i } =
|
|
1021
|
+
let { formControl: n, ...i } = Pt(e);
|
|
1023
1022
|
t.current = {
|
|
1024
1023
|
...i,
|
|
1025
1024
|
formState: r
|
|
1026
1025
|
};
|
|
1027
1026
|
}
|
|
1028
1027
|
let a = t.current.control;
|
|
1029
|
-
return a._options = e,
|
|
1028
|
+
return a._options = e, Be(() => {
|
|
1030
1029
|
let e = a._subscribe({
|
|
1031
1030
|
formState: a._proxyFormState,
|
|
1032
1031
|
callback: () => i({ ...a._formState }),
|
|
@@ -1036,63 +1035,63 @@ function Nt(e = {}) {
|
|
|
1036
1035
|
...e,
|
|
1037
1036
|
isReady: !0
|
|
1038
1037
|
})), a._formState.isReady = !0, e;
|
|
1039
|
-
}, [a]),
|
|
1038
|
+
}, [a]), P.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), P.useEffect(() => {
|
|
1040
1039
|
e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
|
|
1041
1040
|
}, [
|
|
1042
1041
|
a,
|
|
1043
1042
|
e.mode,
|
|
1044
1043
|
e.reValidateMode
|
|
1045
|
-
]),
|
|
1044
|
+
]), P.useEffect(() => {
|
|
1046
1045
|
e.errors && (a._setErrors(e.errors), a._focusError());
|
|
1047
|
-
}, [a, e.errors]),
|
|
1046
|
+
}, [a, e.errors]), P.useEffect(() => {
|
|
1048
1047
|
e.shouldUnregister && a._subjects.state.next({ values: a._getWatch() });
|
|
1049
|
-
}, [a, e.shouldUnregister]),
|
|
1048
|
+
}, [a, e.shouldUnregister]), P.useEffect(() => {
|
|
1050
1049
|
if (a._proxyFormState.isDirty) {
|
|
1051
1050
|
let e = a._getDirty();
|
|
1052
1051
|
e !== r.isDirty && a._subjects.state.next({ isDirty: e });
|
|
1053
1052
|
}
|
|
1054
|
-
}, [a, r.isDirty]),
|
|
1055
|
-
e.values && !
|
|
1053
|
+
}, [a, r.isDirty]), P.useEffect(() => {
|
|
1054
|
+
e.values && !X(e.values, n.current) ? (a._reset(e.values, {
|
|
1056
1055
|
keepFieldsRef: !0,
|
|
1057
1056
|
...a._options.resetOptions
|
|
1058
1057
|
}), a._options.resetOptions?.keepIsValid || a._setValid(), n.current = e.values, i((e) => ({ ...e }))) : a._resetDefaultValues();
|
|
1059
|
-
}, [a, e.values]),
|
|
1058
|
+
}, [a, e.values]), P.useEffect(() => {
|
|
1060
1059
|
a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
|
|
1061
|
-
}), t.current.formState =
|
|
1060
|
+
}), t.current.formState = P.useMemo(() => ze(r, a), [a, r]), t.current;
|
|
1062
1061
|
}
|
|
1063
1062
|
//#endregion
|
|
1064
1063
|
//#region node_modules/@hookform/resolvers/dist/resolvers.mjs
|
|
1065
|
-
var
|
|
1064
|
+
var It = (e, t, n) => {
|
|
1066
1065
|
if (e && "reportValidity" in e) {
|
|
1067
1066
|
let r = U(n, t);
|
|
1068
1067
|
e.setCustomValidity(r && r.message || ""), e.reportValidity();
|
|
1069
1068
|
}
|
|
1070
|
-
},
|
|
1069
|
+
}, Lt = (e, t) => {
|
|
1071
1070
|
for (let n in t.fields) {
|
|
1072
1071
|
let r = t.fields[n];
|
|
1073
|
-
r && r.ref && "reportValidity" in r.ref ?
|
|
1072
|
+
r && r.ref && "reportValidity" in r.ref ? It(r.ref, n, e) : r && r.refs && r.refs.forEach((t) => It(t, n, e));
|
|
1074
1073
|
}
|
|
1075
|
-
},
|
|
1076
|
-
t.shouldUseNativeValidation &&
|
|
1074
|
+
}, Rt = (e, t) => {
|
|
1075
|
+
t.shouldUseNativeValidation && Lt(e, t);
|
|
1077
1076
|
let n = {};
|
|
1078
1077
|
for (let r in e) {
|
|
1079
1078
|
let i = U(t.fields, r), a = Object.assign(e[r] || {}, { ref: i && i.ref });
|
|
1080
|
-
if (
|
|
1079
|
+
if (zt(t.names || Object.keys(e), r)) {
|
|
1081
1080
|
let e = Object.assign({}, U(n, r));
|
|
1082
1081
|
K(e, "root", a), K(n, r, e);
|
|
1083
1082
|
} else K(n, r, a);
|
|
1084
1083
|
}
|
|
1085
1084
|
return n;
|
|
1086
|
-
},
|
|
1087
|
-
let n =
|
|
1088
|
-
return e.some((e) =>
|
|
1085
|
+
}, zt = (e, t) => {
|
|
1086
|
+
let n = Bt(t);
|
|
1087
|
+
return e.some((e) => Bt(e).match(`^${n}\\.\\d+`));
|
|
1089
1088
|
};
|
|
1090
|
-
function
|
|
1089
|
+
function Bt(e) {
|
|
1091
1090
|
return e.replace(/\]|\[/g, "");
|
|
1092
1091
|
}
|
|
1093
1092
|
//#endregion
|
|
1094
1093
|
//#region node_modules/@hookform/resolvers/zod/dist/zod.mjs
|
|
1095
|
-
function
|
|
1094
|
+
function Vt(e, t) {
|
|
1096
1095
|
try {
|
|
1097
1096
|
var n = e();
|
|
1098
1097
|
} catch (e) {
|
|
@@ -1100,7 +1099,7 @@ function zt(e, t) {
|
|
|
1100
1099
|
}
|
|
1101
1100
|
return n && n.then ? n.then(void 0, t) : n;
|
|
1102
1101
|
}
|
|
1103
|
-
function
|
|
1102
|
+
function Ht(e, t) {
|
|
1104
1103
|
for (var n = {}; e.length;) {
|
|
1105
1104
|
var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
|
|
1106
1105
|
if (!n[o]) if ("unionErrors" in r) {
|
|
@@ -1119,13 +1118,13 @@ function Bt(e, t) {
|
|
|
1119
1118
|
});
|
|
1120
1119
|
}), t) {
|
|
1121
1120
|
var c = n[o].types, l = c && c[r.code];
|
|
1122
|
-
n[o] =
|
|
1121
|
+
n[o] = Ge(o, t, n, i, l ? [].concat(l, r.message) : r.message);
|
|
1123
1122
|
}
|
|
1124
1123
|
e.shift();
|
|
1125
1124
|
}
|
|
1126
1125
|
return n;
|
|
1127
1126
|
}
|
|
1128
|
-
function
|
|
1127
|
+
function Ut(e, t) {
|
|
1129
1128
|
for (var n = {}; e.length;) {
|
|
1130
1129
|
var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
|
|
1131
1130
|
if (!n[o]) if (r.code === "invalid_union" && r.errors.length > 0) {
|
|
@@ -1144,20 +1143,20 @@ function Vt(e, t) {
|
|
|
1144
1143
|
});
|
|
1145
1144
|
}), t) {
|
|
1146
1145
|
var c = n[o].types, l = c && c[r.code];
|
|
1147
|
-
n[o] =
|
|
1146
|
+
n[o] = Ge(o, t, n, i, l ? [].concat(l, r.message) : r.message);
|
|
1148
1147
|
}
|
|
1149
1148
|
e.shift();
|
|
1150
1149
|
}
|
|
1151
1150
|
return n;
|
|
1152
1151
|
}
|
|
1153
|
-
function
|
|
1152
|
+
function Wt(e, t, n) {
|
|
1154
1153
|
if (n === void 0 && (n = {}), function(e) {
|
|
1155
1154
|
return "_def" in e && typeof e._def == "object" && "typeName" in e._def;
|
|
1156
1155
|
}(e)) return function(r, i, a) {
|
|
1157
1156
|
try {
|
|
1158
|
-
return Promise.resolve(
|
|
1157
|
+
return Promise.resolve(Vt(function() {
|
|
1159
1158
|
return Promise.resolve(e[n.mode === "sync" ? "parse" : "parseAsync"](r, t)).then(function(e) {
|
|
1160
|
-
return a.shouldUseNativeValidation &&
|
|
1159
|
+
return a.shouldUseNativeValidation && Lt({}, a), {
|
|
1161
1160
|
errors: {},
|
|
1162
1161
|
values: n.raw ? Object.assign({}, r) : e
|
|
1163
1162
|
};
|
|
@@ -1167,7 +1166,7 @@ function Ht(e, t, n) {
|
|
|
1167
1166
|
return Array.isArray(e?.issues);
|
|
1168
1167
|
}(e)) return {
|
|
1169
1168
|
values: {},
|
|
1170
|
-
errors:
|
|
1169
|
+
errors: Rt(Ht(e.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
|
|
1171
1170
|
};
|
|
1172
1171
|
throw e;
|
|
1173
1172
|
}));
|
|
@@ -1179,19 +1178,19 @@ function Ht(e, t, n) {
|
|
|
1179
1178
|
return "_zod" in e && typeof e._zod == "object";
|
|
1180
1179
|
}(e)) return function(r, i, a) {
|
|
1181
1180
|
try {
|
|
1182
|
-
return Promise.resolve(
|
|
1183
|
-
return Promise.resolve((n.mode === "sync" ?
|
|
1184
|
-
return a.shouldUseNativeValidation &&
|
|
1181
|
+
return Promise.resolve(Vt(function() {
|
|
1182
|
+
return Promise.resolve((n.mode === "sync" ? g : le)(e, r, t)).then(function(e) {
|
|
1183
|
+
return a.shouldUseNativeValidation && Lt({}, a), {
|
|
1185
1184
|
errors: {},
|
|
1186
1185
|
values: n.raw ? Object.assign({}, r) : e
|
|
1187
1186
|
};
|
|
1188
1187
|
});
|
|
1189
1188
|
}, function(e) {
|
|
1190
1189
|
if (function(e) {
|
|
1191
|
-
return e instanceof
|
|
1190
|
+
return e instanceof l;
|
|
1192
1191
|
}(e)) return {
|
|
1193
1192
|
values: {},
|
|
1194
|
-
errors:
|
|
1193
|
+
errors: Rt(Ut(e.issues, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
|
|
1195
1194
|
};
|
|
1196
1195
|
throw e;
|
|
1197
1196
|
}));
|
|
@@ -1203,94 +1202,107 @@ function Ht(e, t, n) {
|
|
|
1203
1202
|
}
|
|
1204
1203
|
//#endregion
|
|
1205
1204
|
//#region src/base/form/form-utils.ts
|
|
1206
|
-
function
|
|
1205
|
+
function Gt(e) {
|
|
1207
1206
|
let t = [];
|
|
1208
|
-
for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...
|
|
1207
|
+
for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...Gt(n.children));
|
|
1209
1208
|
return t;
|
|
1210
1209
|
}
|
|
1211
|
-
function
|
|
1210
|
+
function Kt(e, n) {
|
|
1212
1211
|
if (e.component === "header") return !0;
|
|
1213
|
-
let { props:
|
|
1214
|
-
return !(
|
|
1212
|
+
let { props: r } = e;
|
|
1213
|
+
return !(r.hidden_when && t(r.hidden_when, n) || r.visible_when && !t(r.visible_when, n));
|
|
1214
|
+
}
|
|
1215
|
+
function qt(e, n) {
|
|
1216
|
+
if (e.component === "header") return !1;
|
|
1217
|
+
let { props: r } = e;
|
|
1218
|
+
return !!(r.disabled || r.disabled_when && t(r.disabled_when, n));
|
|
1219
|
+
}
|
|
1220
|
+
function Jt(e, n) {
|
|
1221
|
+
if (e.component === "header" || qt(e, n)) return !1;
|
|
1222
|
+
let { props: r } = e;
|
|
1223
|
+
return !!(r.required || r.required_when && t(r.required_when, n));
|
|
1215
1224
|
}
|
|
1216
1225
|
//#endregion
|
|
1217
1226
|
//#region src/base/form/form-schema-builder.ts
|
|
1218
|
-
function
|
|
1219
|
-
let { component:
|
|
1220
|
-
switch (
|
|
1227
|
+
function Yt(e, t, n) {
|
|
1228
|
+
let { component: r, props: i } = e, a = i.validation, o = n;
|
|
1229
|
+
switch (r) {
|
|
1221
1230
|
case "text":
|
|
1222
1231
|
case "textarea":
|
|
1223
1232
|
case "password":
|
|
1224
1233
|
case "slug":
|
|
1225
1234
|
case "color": {
|
|
1226
|
-
let e =
|
|
1227
|
-
return
|
|
1235
|
+
let e = N();
|
|
1236
|
+
return o && (e = e.min(1, t("middag.ui.validation.required"))), a?.minLength && (e = e.min(a.minLength, t("middag.ui.validation.min_length", { min: a.minLength }))), a?.maxLength && (e = e.max(a.maxLength, t("middag.ui.validation.max_length", { max: a.maxLength }))), a?.pattern && (e = e.regex(new RegExp(a.pattern), a.patternMessage ?? t("middag.ui.validation.pattern"))), o ? e : e.or(A(""));
|
|
1228
1237
|
}
|
|
1229
1238
|
case "email": {
|
|
1230
|
-
let e =
|
|
1231
|
-
if (
|
|
1232
|
-
else return e.email(t("middag.ui.validation.email")).or(
|
|
1239
|
+
let e = N();
|
|
1240
|
+
if (o) e = e.min(1, t("middag.ui.validation.required")).email(t("middag.ui.validation.email"));
|
|
1241
|
+
else return e.email(t("middag.ui.validation.email")).or(A(""));
|
|
1233
1242
|
return e;
|
|
1234
1243
|
}
|
|
1235
1244
|
case "url": {
|
|
1236
|
-
let e =
|
|
1237
|
-
if (
|
|
1238
|
-
else return e.url(t("middag.ui.validation.url")).or(
|
|
1245
|
+
let e = N();
|
|
1246
|
+
if (o) e = e.min(1, t("middag.ui.validation.required")).url(t("middag.ui.validation.url"));
|
|
1247
|
+
else return e.url(t("middag.ui.validation.url")).or(A(""));
|
|
1239
1248
|
return e;
|
|
1240
1249
|
}
|
|
1241
1250
|
case "int": {
|
|
1242
|
-
let e =
|
|
1243
|
-
return
|
|
1251
|
+
let e = T({ message: t("middag.ui.validation.integer") }).int(t("middag.ui.validation.integer"));
|
|
1252
|
+
return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
|
|
1244
1253
|
}
|
|
1245
1254
|
case "float": {
|
|
1246
|
-
let e =
|
|
1247
|
-
return
|
|
1255
|
+
let e = T();
|
|
1256
|
+
return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
|
|
1248
1257
|
}
|
|
1249
1258
|
case "currency": {
|
|
1250
|
-
let e =
|
|
1251
|
-
return
|
|
1259
|
+
let e = T();
|
|
1260
|
+
return o ? e : e.nullable();
|
|
1252
1261
|
}
|
|
1253
1262
|
case "select":
|
|
1254
1263
|
case "radio":
|
|
1255
1264
|
case "entity_picker": {
|
|
1256
|
-
let e =
|
|
1257
|
-
return
|
|
1265
|
+
let e = N();
|
|
1266
|
+
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
1258
1267
|
}
|
|
1259
1268
|
case "multiselect":
|
|
1260
1269
|
case "tags": {
|
|
1261
|
-
let e =
|
|
1262
|
-
return
|
|
1270
|
+
let e = x(N());
|
|
1271
|
+
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
1263
1272
|
}
|
|
1264
1273
|
case "checkbox":
|
|
1265
|
-
case "switch": return
|
|
1274
|
+
case "switch": return ne();
|
|
1266
1275
|
case "date":
|
|
1267
1276
|
case "datetime": {
|
|
1268
|
-
let e =
|
|
1269
|
-
return
|
|
1277
|
+
let e = N();
|
|
1278
|
+
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
1270
1279
|
}
|
|
1271
1280
|
case "phone": {
|
|
1272
|
-
let e =
|
|
1273
|
-
return
|
|
1281
|
+
let e = N();
|
|
1282
|
+
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
1274
1283
|
}
|
|
1275
1284
|
case "document": {
|
|
1276
|
-
let e =
|
|
1277
|
-
|
|
1285
|
+
let e = i.documentType ?? "generic", n = i.documentScope ?? "any", r = N(), a = async (t) => {
|
|
1286
|
+
let { isValidDocument: r } = await import("./document-validation-DX0fB9cu.js");
|
|
1287
|
+
return r(t, e, n);
|
|
1288
|
+
};
|
|
1289
|
+
return o ? r.min(1, t("middag.ui.validation.required")).refine(a, t("middag.ui.validation.document_invalid")) : r.refine(async (e) => e === "" || await a(e), t("middag.ui.validation.document_invalid"));
|
|
1278
1290
|
}
|
|
1279
|
-
default: return
|
|
1291
|
+
default: return y();
|
|
1280
1292
|
}
|
|
1281
1293
|
}
|
|
1282
|
-
function
|
|
1283
|
-
let r =
|
|
1284
|
-
for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" ||
|
|
1285
|
-
return
|
|
1294
|
+
function Xt(e, t, n) {
|
|
1295
|
+
let r = Gt(e), i = {};
|
|
1296
|
+
for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" || Kt(e, t) && (i[e.key] = Yt(e, n, Jt(e, t)));
|
|
1297
|
+
return C(i);
|
|
1286
1298
|
}
|
|
1287
1299
|
//#endregion
|
|
1288
1300
|
//#region src/base/form/FormField.tsx
|
|
1289
|
-
var
|
|
1290
|
-
function
|
|
1291
|
-
return /* @__PURE__ */ I(
|
|
1301
|
+
var Zt = _e(() => import("./PhoneField-D_djeYhK.js").then((e) => ({ default: e.PhoneField }))), Qt = _e(() => import("./DateField-CcRD2r-Z.js").then((e) => ({ default: e.DateField }))), $t = _e(() => import("./DocumentField-DjnK9T7o.js").then((e) => ({ default: e.DocumentField }))), en = _e(() => import("./DateRangeField-DKZMfKB2.js").then((e) => ({ default: e.DateRangeField })));
|
|
1302
|
+
function tn() {
|
|
1303
|
+
return /* @__PURE__ */ I(he, { className: "h-9 w-full rounded-md" });
|
|
1292
1304
|
}
|
|
1293
|
-
function
|
|
1305
|
+
function nn({ label: e }) {
|
|
1294
1306
|
return /* @__PURE__ */ I("div", {
|
|
1295
1307
|
className: "pt-4 pb-1",
|
|
1296
1308
|
children: /* @__PURE__ */ I("h4", {
|
|
@@ -1299,147 +1311,147 @@ function Qt({ label: e }) {
|
|
|
1299
1311
|
})
|
|
1300
1312
|
});
|
|
1301
1313
|
}
|
|
1302
|
-
function
|
|
1314
|
+
function rn({ id: e, value: t }) {
|
|
1303
1315
|
return /* @__PURE__ */ I("input", {
|
|
1304
1316
|
type: "hidden",
|
|
1305
1317
|
id: e,
|
|
1306
1318
|
value: String(t ?? "")
|
|
1307
1319
|
});
|
|
1308
1320
|
}
|
|
1309
|
-
function
|
|
1310
|
-
let { t:
|
|
1311
|
-
if (
|
|
1312
|
-
if (
|
|
1313
|
-
id:
|
|
1321
|
+
function an({ field: e, value: t, onChange: r, error: i, sourceValues: a = {} }) {
|
|
1322
|
+
let { t: o } = pe(), s = be(), c = `field-${e.key}-${s}`, l = `${c}-help`, u = `${c}-error`, { component: d, props: f } = e;
|
|
1323
|
+
if (d === "header") return /* @__PURE__ */ I(nn, { label: f.label });
|
|
1324
|
+
if (d === "hidden") return /* @__PURE__ */ I(rn, {
|
|
1325
|
+
id: c,
|
|
1314
1326
|
value: t
|
|
1315
1327
|
});
|
|
1316
|
-
let
|
|
1328
|
+
let p = qt(e, a), m = Jt(e, a), h = d === "checkbox" || d === "switch", g = on(d, c, t, r, f, i, l, u, o, a, p, m);
|
|
1317
1329
|
return /* @__PURE__ */ L("div", {
|
|
1318
1330
|
className: "space-y-1.5",
|
|
1319
1331
|
children: [
|
|
1320
|
-
!
|
|
1321
|
-
htmlFor:
|
|
1322
|
-
children: [
|
|
1332
|
+
!h && /* @__PURE__ */ L(n, {
|
|
1333
|
+
htmlFor: c,
|
|
1334
|
+
children: [f.label, m && /* @__PURE__ */ I("span", {
|
|
1323
1335
|
className: "text-destructive ml-0.5",
|
|
1324
1336
|
children: "*"
|
|
1325
1337
|
})]
|
|
1326
1338
|
}),
|
|
1327
|
-
|
|
1328
|
-
id:
|
|
1339
|
+
f.helpText && /* @__PURE__ */ I("p", {
|
|
1340
|
+
id: l,
|
|
1329
1341
|
className: "text-muted-foreground text-xs",
|
|
1330
|
-
children:
|
|
1342
|
+
children: f.helpText
|
|
1331
1343
|
}),
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
id:
|
|
1344
|
+
g,
|
|
1345
|
+
i && /* @__PURE__ */ I("p", {
|
|
1346
|
+
id: u,
|
|
1335
1347
|
className: "text-destructive text-xs",
|
|
1336
1348
|
"aria-live": "polite",
|
|
1337
|
-
children:
|
|
1349
|
+
children: i
|
|
1338
1350
|
})
|
|
1339
1351
|
]
|
|
1340
1352
|
});
|
|
1341
1353
|
}
|
|
1342
|
-
function
|
|
1343
|
-
let
|
|
1344
|
-
id:
|
|
1354
|
+
function on(t, n, r, i, a, o, s, c, l, d, f, p) {
|
|
1355
|
+
let g = {
|
|
1356
|
+
id: n,
|
|
1345
1357
|
error: o,
|
|
1346
1358
|
helpTextId: s,
|
|
1347
1359
|
errorId: c,
|
|
1348
|
-
disabled:
|
|
1349
|
-
required:
|
|
1360
|
+
disabled: f,
|
|
1361
|
+
required: p
|
|
1350
1362
|
};
|
|
1351
|
-
switch (
|
|
1352
|
-
case "text": return /* @__PURE__ */ I(
|
|
1353
|
-
...
|
|
1363
|
+
switch (t) {
|
|
1364
|
+
case "text": return /* @__PURE__ */ I(ie, {
|
|
1365
|
+
...g,
|
|
1354
1366
|
type: "text",
|
|
1355
1367
|
value: r,
|
|
1356
1368
|
onChange: i,
|
|
1357
1369
|
placeholder: a.placeholder,
|
|
1358
1370
|
readOnly: a.readOnly
|
|
1359
1371
|
});
|
|
1360
|
-
case "email": return /* @__PURE__ */ I(
|
|
1361
|
-
...
|
|
1372
|
+
case "email": return /* @__PURE__ */ I(ie, {
|
|
1373
|
+
...g,
|
|
1362
1374
|
type: "email",
|
|
1363
1375
|
value: r,
|
|
1364
1376
|
onChange: i,
|
|
1365
1377
|
placeholder: a.placeholder,
|
|
1366
1378
|
readOnly: a.readOnly
|
|
1367
1379
|
});
|
|
1368
|
-
case "url": return /* @__PURE__ */ I(
|
|
1369
|
-
...
|
|
1380
|
+
case "url": return /* @__PURE__ */ I(ie, {
|
|
1381
|
+
...g,
|
|
1370
1382
|
type: "url",
|
|
1371
1383
|
value: r,
|
|
1372
1384
|
onChange: i,
|
|
1373
1385
|
placeholder: a.placeholder,
|
|
1374
1386
|
readOnly: a.readOnly
|
|
1375
1387
|
});
|
|
1376
|
-
case "textarea": return /* @__PURE__ */ I(
|
|
1377
|
-
...
|
|
1388
|
+
case "textarea": return /* @__PURE__ */ I(E, {
|
|
1389
|
+
...g,
|
|
1378
1390
|
value: r,
|
|
1379
1391
|
onChange: i,
|
|
1380
1392
|
placeholder: a.placeholder,
|
|
1381
1393
|
rows: a.rows,
|
|
1382
1394
|
readOnly: a.readOnly
|
|
1383
1395
|
});
|
|
1384
|
-
case "password": return /* @__PURE__ */ I(
|
|
1385
|
-
...
|
|
1396
|
+
case "password": return /* @__PURE__ */ I(te, {
|
|
1397
|
+
...g,
|
|
1386
1398
|
value: r,
|
|
1387
1399
|
onChange: i,
|
|
1388
1400
|
placeholder: a.placeholder
|
|
1389
1401
|
});
|
|
1390
|
-
case "otp": return /* @__PURE__ */ I(
|
|
1391
|
-
...
|
|
1402
|
+
case "otp": return /* @__PURE__ */ I(k, {
|
|
1403
|
+
...g,
|
|
1392
1404
|
value: r,
|
|
1393
1405
|
onChange: i,
|
|
1394
1406
|
maxLength: a.maxLength,
|
|
1395
1407
|
pattern: a.pattern,
|
|
1396
1408
|
groupSize: a.groupSize
|
|
1397
1409
|
});
|
|
1398
|
-
case "select": return /* @__PURE__ */ I(
|
|
1399
|
-
...
|
|
1410
|
+
case "select": return /* @__PURE__ */ I(oe, {
|
|
1411
|
+
...g,
|
|
1400
1412
|
value: r,
|
|
1401
1413
|
onChange: i,
|
|
1402
1414
|
options: a.options ?? [],
|
|
1403
1415
|
placeholder: a.placeholder
|
|
1404
1416
|
});
|
|
1405
1417
|
case "native_select": return /* @__PURE__ */ I(S, {
|
|
1406
|
-
...
|
|
1418
|
+
...g,
|
|
1407
1419
|
value: r,
|
|
1408
1420
|
onChange: i,
|
|
1409
1421
|
options: a.options ?? [],
|
|
1410
1422
|
placeholder: a.placeholder
|
|
1411
1423
|
});
|
|
1412
|
-
case "multiselect": return /* @__PURE__ */ I(
|
|
1413
|
-
...
|
|
1424
|
+
case "multiselect": return /* @__PURE__ */ I(m, {
|
|
1425
|
+
...g,
|
|
1414
1426
|
value: r,
|
|
1415
1427
|
onChange: i,
|
|
1416
1428
|
options: a.options ?? [],
|
|
1417
1429
|
placeholder: a.placeholder
|
|
1418
1430
|
});
|
|
1419
1431
|
case "radio": return /* @__PURE__ */ I(b, {
|
|
1420
|
-
...
|
|
1432
|
+
...g,
|
|
1421
1433
|
value: r,
|
|
1422
1434
|
onChange: i,
|
|
1423
1435
|
options: a.options ?? []
|
|
1424
1436
|
});
|
|
1425
|
-
case "int": return /* @__PURE__ */ I(
|
|
1426
|
-
...
|
|
1437
|
+
case "int": return /* @__PURE__ */ I(w, {
|
|
1438
|
+
...g,
|
|
1427
1439
|
value: r,
|
|
1428
1440
|
onChange: i,
|
|
1429
1441
|
min: a.min,
|
|
1430
1442
|
max: a.max,
|
|
1431
1443
|
step: 1
|
|
1432
1444
|
});
|
|
1433
|
-
case "float": return /* @__PURE__ */ I(
|
|
1434
|
-
...
|
|
1445
|
+
case "float": return /* @__PURE__ */ I(w, {
|
|
1446
|
+
...g,
|
|
1435
1447
|
value: r,
|
|
1436
1448
|
onChange: i,
|
|
1437
1449
|
min: a.min,
|
|
1438
1450
|
max: a.max,
|
|
1439
1451
|
step: a.step ?? .1
|
|
1440
1452
|
});
|
|
1441
|
-
case "slider": return /* @__PURE__ */ I(
|
|
1442
|
-
...
|
|
1453
|
+
case "slider": return /* @__PURE__ */ I(O, {
|
|
1454
|
+
...g,
|
|
1443
1455
|
value: r,
|
|
1444
1456
|
onChange: i,
|
|
1445
1457
|
min: a.min,
|
|
@@ -1447,40 +1459,40 @@ function tn(e, t, r, i, a, o, s, c, u) {
|
|
|
1447
1459
|
step: a.step,
|
|
1448
1460
|
multiple: a.multiple
|
|
1449
1461
|
});
|
|
1450
|
-
case "checkbox": return /* @__PURE__ */ I(
|
|
1451
|
-
...
|
|
1462
|
+
case "checkbox": return /* @__PURE__ */ I(u, {
|
|
1463
|
+
...g,
|
|
1452
1464
|
value: r,
|
|
1453
1465
|
onChange: i,
|
|
1454
1466
|
label: a.label
|
|
1455
1467
|
});
|
|
1456
|
-
case "switch": return /* @__PURE__ */ I(
|
|
1457
|
-
...
|
|
1468
|
+
case "switch": return /* @__PURE__ */ I(ee, {
|
|
1469
|
+
...g,
|
|
1458
1470
|
value: r,
|
|
1459
1471
|
onChange: i,
|
|
1460
1472
|
label: a.label
|
|
1461
1473
|
});
|
|
1462
|
-
case "date": return /* @__PURE__ */ I(
|
|
1463
|
-
fallback: /* @__PURE__ */ I(
|
|
1464
|
-
children: /* @__PURE__ */ I(
|
|
1465
|
-
...
|
|
1474
|
+
case "date": return /* @__PURE__ */ I(ge, {
|
|
1475
|
+
fallback: /* @__PURE__ */ I(tn, {}),
|
|
1476
|
+
children: /* @__PURE__ */ I(Qt, {
|
|
1477
|
+
...g,
|
|
1466
1478
|
mode: "date",
|
|
1467
1479
|
value: r,
|
|
1468
1480
|
onChange: i,
|
|
1469
1481
|
placeholder: a.placeholder
|
|
1470
1482
|
})
|
|
1471
1483
|
});
|
|
1472
|
-
case "datetime": return /* @__PURE__ */ I(
|
|
1473
|
-
fallback: /* @__PURE__ */ I(
|
|
1474
|
-
children: /* @__PURE__ */ I(
|
|
1475
|
-
...
|
|
1484
|
+
case "datetime": return /* @__PURE__ */ I(ge, {
|
|
1485
|
+
fallback: /* @__PURE__ */ I(tn, {}),
|
|
1486
|
+
children: /* @__PURE__ */ I(Qt, {
|
|
1487
|
+
...g,
|
|
1476
1488
|
mode: "datetime",
|
|
1477
1489
|
value: r,
|
|
1478
1490
|
onChange: i,
|
|
1479
1491
|
placeholder: a.placeholder
|
|
1480
1492
|
})
|
|
1481
1493
|
});
|
|
1482
|
-
case "file": return /* @__PURE__ */ I(
|
|
1483
|
-
...
|
|
1494
|
+
case "file": return /* @__PURE__ */ I(se, {
|
|
1495
|
+
...g,
|
|
1484
1496
|
value: r,
|
|
1485
1497
|
onChange: i,
|
|
1486
1498
|
accept: a.accept,
|
|
@@ -1488,8 +1500,8 @@ function tn(e, t, r, i, a, o, s, c, u) {
|
|
|
1488
1500
|
maxFiles: a.maxFiles,
|
|
1489
1501
|
maxSize: a.maxSize
|
|
1490
1502
|
});
|
|
1491
|
-
case "entity_picker": return /* @__PURE__ */ I(
|
|
1492
|
-
...
|
|
1503
|
+
case "entity_picker": return /* @__PURE__ */ I(ue, {
|
|
1504
|
+
...g,
|
|
1493
1505
|
value: r,
|
|
1494
1506
|
onChange: i,
|
|
1495
1507
|
options: a.options,
|
|
@@ -1500,14 +1512,14 @@ function tn(e, t, r, i, a, o, s, c, u) {
|
|
|
1500
1512
|
entitySubtitleField: a.entitySubtitleField,
|
|
1501
1513
|
placeholder: a.placeholder
|
|
1502
1514
|
});
|
|
1503
|
-
case "static": return /* @__PURE__ */ I(
|
|
1504
|
-
id:
|
|
1515
|
+
case "static": return /* @__PURE__ */ I(ae, {
|
|
1516
|
+
id: n,
|
|
1505
1517
|
value: r
|
|
1506
1518
|
});
|
|
1507
|
-
case "phone": return /* @__PURE__ */ I(
|
|
1508
|
-
fallback: /* @__PURE__ */ I(
|
|
1509
|
-
children: /* @__PURE__ */ I(
|
|
1510
|
-
...
|
|
1519
|
+
case "phone": return /* @__PURE__ */ I(ge, {
|
|
1520
|
+
fallback: /* @__PURE__ */ I(tn, {}),
|
|
1521
|
+
children: /* @__PURE__ */ I(Zt, {
|
|
1522
|
+
...g,
|
|
1511
1523
|
value: r,
|
|
1512
1524
|
onChange: i,
|
|
1513
1525
|
placeholder: a.placeholder,
|
|
@@ -1515,10 +1527,10 @@ function tn(e, t, r, i, a, o, s, c, u) {
|
|
|
1515
1527
|
fixedCountry: a.fixedCountry
|
|
1516
1528
|
})
|
|
1517
1529
|
});
|
|
1518
|
-
case "document": return /* @__PURE__ */ I(
|
|
1519
|
-
fallback: /* @__PURE__ */ I(
|
|
1520
|
-
children: /* @__PURE__ */ I(
|
|
1521
|
-
...
|
|
1530
|
+
case "document": return /* @__PURE__ */ I(ge, {
|
|
1531
|
+
fallback: /* @__PURE__ */ I(tn, {}),
|
|
1532
|
+
children: /* @__PURE__ */ I($t, {
|
|
1533
|
+
...g,
|
|
1522
1534
|
value: r,
|
|
1523
1535
|
onChange: i,
|
|
1524
1536
|
documentType: a.documentType,
|
|
@@ -1527,8 +1539,8 @@ function tn(e, t, r, i, a, o, s, c, u) {
|
|
|
1527
1539
|
placeholder: a.placeholder
|
|
1528
1540
|
})
|
|
1529
1541
|
});
|
|
1530
|
-
case "currency": return /* @__PURE__ */ I(
|
|
1531
|
-
...
|
|
1542
|
+
case "currency": return /* @__PURE__ */ I(e, {
|
|
1543
|
+
...g,
|
|
1532
1544
|
value: r,
|
|
1533
1545
|
onChange: i,
|
|
1534
1546
|
currency: a.currency,
|
|
@@ -1536,202 +1548,269 @@ function tn(e, t, r, i, a, o, s, c, u) {
|
|
|
1536
1548
|
min: a.min,
|
|
1537
1549
|
max: a.max
|
|
1538
1550
|
});
|
|
1539
|
-
case "color": return /* @__PURE__ */ I(
|
|
1540
|
-
...
|
|
1551
|
+
case "color": return /* @__PURE__ */ I(ce, {
|
|
1552
|
+
...g,
|
|
1541
1553
|
value: r,
|
|
1542
1554
|
onChange: i,
|
|
1543
1555
|
placeholder: a.placeholder
|
|
1544
1556
|
});
|
|
1545
|
-
case "slug": return /* @__PURE__ */ I(
|
|
1546
|
-
...
|
|
1557
|
+
case "slug": return /* @__PURE__ */ I(_, {
|
|
1558
|
+
...g,
|
|
1547
1559
|
value: r,
|
|
1548
1560
|
onChange: i,
|
|
1549
|
-
sourceValue: a.sourceField,
|
|
1561
|
+
sourceValue: a.sourceField === void 0 ? void 0 : String(d[a.sourceField] ?? ""),
|
|
1550
1562
|
prefix: a.prefix,
|
|
1551
1563
|
placeholder: a.placeholder
|
|
1552
1564
|
});
|
|
1553
1565
|
case "tags": return /* @__PURE__ */ I(h, {
|
|
1554
|
-
...
|
|
1566
|
+
...g,
|
|
1555
1567
|
value: r,
|
|
1556
1568
|
onChange: i,
|
|
1557
1569
|
placeholder: a.placeholder,
|
|
1558
1570
|
maxTags: a.maxTags
|
|
1559
1571
|
});
|
|
1560
|
-
case "date_range": return /* @__PURE__ */ I(
|
|
1561
|
-
fallback: /* @__PURE__ */ I(
|
|
1562
|
-
children: /* @__PURE__ */ I(
|
|
1563
|
-
...
|
|
1572
|
+
case "date_range": return /* @__PURE__ */ I(ge, {
|
|
1573
|
+
fallback: /* @__PURE__ */ I(tn, {}),
|
|
1574
|
+
children: /* @__PURE__ */ I(en, {
|
|
1575
|
+
...g,
|
|
1564
1576
|
value: r,
|
|
1565
1577
|
onChange: i,
|
|
1566
1578
|
operator: a.operator
|
|
1567
1579
|
})
|
|
1568
1580
|
});
|
|
1569
1581
|
case "rating": return /* @__PURE__ */ I(v, {
|
|
1570
|
-
...
|
|
1582
|
+
...g,
|
|
1571
1583
|
value: r,
|
|
1572
1584
|
onChange: i,
|
|
1573
1585
|
maxRating: a.maxRating
|
|
1574
1586
|
});
|
|
1575
1587
|
default: return /* @__PURE__ */ L("p", {
|
|
1576
1588
|
className: "text-destructive text-xs",
|
|
1577
|
-
children: ["Unknown field component: ",
|
|
1589
|
+
children: ["Unknown field component: ", t]
|
|
1578
1590
|
});
|
|
1579
1591
|
}
|
|
1580
1592
|
}
|
|
1581
1593
|
//#endregion
|
|
1582
1594
|
//#region src/base/blocks/FormPanelBlock.tsx
|
|
1583
|
-
function
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1595
|
+
function sn(e, t) {
|
|
1596
|
+
let n = t[e.key];
|
|
1597
|
+
if (n != null) return n;
|
|
1598
|
+
switch (e.component) {
|
|
1599
|
+
case "int":
|
|
1600
|
+
case "float":
|
|
1601
|
+
case "currency":
|
|
1602
|
+
case "slider":
|
|
1603
|
+
case "rating": return null;
|
|
1604
|
+
case "checkbox":
|
|
1605
|
+
case "switch": return !1;
|
|
1606
|
+
case "multiselect":
|
|
1607
|
+
case "tags": return [];
|
|
1608
|
+
default: return "";
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
function cn(e, t) {
|
|
1612
|
+
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : sn(e, t);
|
|
1613
|
+
}
|
|
1614
|
+
function ln({ nodes: e, values: t, errors: n, onChange: r, sourceValues: i }) {
|
|
1615
|
+
return /* @__PURE__ */ I(we, { children: e.map((e, a) => {
|
|
1616
|
+
switch (e.kind) {
|
|
1617
|
+
case "field": return Kt(e, t) ? /* @__PURE__ */ I(an, {
|
|
1618
|
+
field: e,
|
|
1619
|
+
value: cn(e, t),
|
|
1620
|
+
onChange: (t) => r(e.key, t),
|
|
1621
|
+
error: n[e.key],
|
|
1622
|
+
sourceValues: i
|
|
1623
|
+
}, e.key) : null;
|
|
1624
|
+
case "section": return /* @__PURE__ */ I(j, {
|
|
1625
|
+
id: e.id,
|
|
1626
|
+
title: e.label,
|
|
1627
|
+
defaultCollapsed: e.defaultCollapsed,
|
|
1628
|
+
hasErrors: e.children.some((e) => e.kind === "field" && !!n[e.key]),
|
|
1629
|
+
errorCount: e.children.filter((e) => e.kind === "field" && !!n[e.key]).length,
|
|
1630
|
+
children: /* @__PURE__ */ I(ln, {
|
|
1631
|
+
nodes: e.children,
|
|
1632
|
+
values: t,
|
|
1633
|
+
errors: n,
|
|
1634
|
+
onChange: r,
|
|
1635
|
+
sourceValues: i
|
|
1603
1636
|
})
|
|
1604
|
-
},
|
|
1637
|
+
}, e.id);
|
|
1605
1638
|
case "group": return /* @__PURE__ */ I("div", {
|
|
1606
|
-
className:
|
|
1607
|
-
children: /* @__PURE__ */ I(
|
|
1608
|
-
nodes:
|
|
1609
|
-
values:
|
|
1610
|
-
errors:
|
|
1611
|
-
onChange:
|
|
1639
|
+
className: me("grid gap-6", e.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
|
|
1640
|
+
children: /* @__PURE__ */ I(ln, {
|
|
1641
|
+
nodes: e.children,
|
|
1642
|
+
values: t,
|
|
1643
|
+
errors: n,
|
|
1644
|
+
onChange: r,
|
|
1645
|
+
sourceValues: i
|
|
1612
1646
|
})
|
|
1613
|
-
},
|
|
1647
|
+
}, e.id);
|
|
1614
1648
|
case "header": return /* @__PURE__ */ L("div", {
|
|
1615
1649
|
className: "space-y-2",
|
|
1616
|
-
children: [/* @__PURE__ */ I(
|
|
1650
|
+
children: [/* @__PURE__ */ I(D, {}), /* @__PURE__ */ I("h4", {
|
|
1617
1651
|
className: "text-foreground text-base font-semibold",
|
|
1618
|
-
children:
|
|
1652
|
+
children: e.label
|
|
1619
1653
|
})]
|
|
1620
1654
|
}, `header-${a}`);
|
|
1621
1655
|
default: return null;
|
|
1622
1656
|
}
|
|
1623
1657
|
}) });
|
|
1624
1658
|
}
|
|
1625
|
-
function
|
|
1626
|
-
let { t
|
|
1627
|
-
defaultValues:
|
|
1659
|
+
function un({ block: e }) {
|
|
1660
|
+
let { t } = pe(), { data: n } = e, l = F(() => Gt(n.schema), [n.schema]), u = F(() => new Set(l.map((e) => e.key)), [l]), m = (n.meta.validation ?? "both") !== "server", h = F(() => Object.fromEntries(l.map((e) => [e.key, sn(e, n.values)])), [l, n.values]), g = xe(m ? Xt(n.schema, h, t) : null), _ = Ft({
|
|
1661
|
+
defaultValues: h,
|
|
1628
1662
|
mode: "onTouched",
|
|
1629
1663
|
resolver: F(() => {
|
|
1630
|
-
if (
|
|
1664
|
+
if (m) return async (e, t, n) => g.current ? Wt(g.current)(e, t, n) : {
|
|
1631
1665
|
values: e,
|
|
1632
1666
|
errors: {}
|
|
1633
1667
|
};
|
|
1634
|
-
}, [
|
|
1635
|
-
}),
|
|
1636
|
-
|
|
1637
|
-
|
|
1668
|
+
}, [m])
|
|
1669
|
+
}), v = Ue({ control: _.control }) ?? h, y = l.map((e) => `${Kt(e, v) ? "1" : "0"}${Jt(e, v) ? "1" : "0"}`).join("");
|
|
1670
|
+
ye(() => {
|
|
1671
|
+
m && (g.current = Xt(n.schema, v, t));
|
|
1638
1672
|
}, [
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1673
|
+
m,
|
|
1674
|
+
n.schema,
|
|
1675
|
+
t,
|
|
1676
|
+
y
|
|
1643
1677
|
]);
|
|
1644
|
-
let [
|
|
1645
|
-
|
|
1646
|
-
if (
|
|
1678
|
+
let [b, x] = Se(!1), [S, C] = Se(null), [w, T] = Se({}), E = JSON.stringify(n.values), D = xe(!0);
|
|
1679
|
+
ye(() => {
|
|
1680
|
+
if (D.current) {
|
|
1681
|
+
D.current = !1;
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
_.reset(h);
|
|
1685
|
+
for (let [e, r] of Object.entries(n.errors)) u.has(e) && _.setError(e, {
|
|
1647
1686
|
type: "server",
|
|
1648
|
-
message:
|
|
1687
|
+
message: M(r, t)
|
|
1649
1688
|
});
|
|
1650
|
-
}, [
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1689
|
+
}, [E]), ye(() => {
|
|
1690
|
+
if (Object.keys(n.errors).length > 0) for (let [e, r] of Object.entries(n.errors)) u.has(e) && _.setError(e, {
|
|
1691
|
+
type: "server",
|
|
1692
|
+
message: M(r, t)
|
|
1693
|
+
});
|
|
1694
|
+
}, [JSON.stringify(n.errors)]);
|
|
1695
|
+
let { isDirty: O, isSubmitting: k } = _.formState;
|
|
1696
|
+
ye(() => {
|
|
1697
|
+
if (!O) return;
|
|
1654
1698
|
let e = (e) => {
|
|
1655
1699
|
e.preventDefault();
|
|
1656
1700
|
};
|
|
1657
1701
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1658
|
-
}, [
|
|
1659
|
-
let
|
|
1660
|
-
|
|
1702
|
+
}, [O]);
|
|
1703
|
+
let A = ve((e, t) => {
|
|
1704
|
+
_.setValue(e, t, {
|
|
1661
1705
|
shouldDirty: !0,
|
|
1662
|
-
shouldValidate:
|
|
1663
|
-
}),
|
|
1664
|
-
}, [
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1706
|
+
shouldValidate: _.formState.isSubmitted
|
|
1707
|
+
}), _.clearErrors(e);
|
|
1708
|
+
}, [_]), j = ve((e) => {
|
|
1709
|
+
T({});
|
|
1710
|
+
let r = l.filter((t) => Kt(t, e)), i = Object.fromEntries(r.map((t) => [t.key, e[t.key]])), a = Object.values(i).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File));
|
|
1711
|
+
Ce[n.method === "put" ? "put" : n.method === "patch" ? "patch" : "post"](n.action, i, {
|
|
1712
|
+
forceFormData: a,
|
|
1668
1713
|
onProgress: (e) => {
|
|
1669
|
-
e && typeof e.percentage == "number" &&
|
|
1714
|
+
e && typeof e.percentage == "number" && C(Math.round(e.percentage));
|
|
1670
1715
|
},
|
|
1671
1716
|
onError: (e) => {
|
|
1672
|
-
|
|
1717
|
+
let n = {};
|
|
1718
|
+
for (let [r, i] of Object.entries(e)) u.has(r) ? _.setError(r, {
|
|
1673
1719
|
type: "server",
|
|
1674
|
-
message:
|
|
1675
|
-
});
|
|
1720
|
+
message: M(i, t)
|
|
1721
|
+
}) : n[r] = i;
|
|
1722
|
+
Object.keys(n).length > 0 && T((e) => ({
|
|
1723
|
+
...e,
|
|
1724
|
+
...n
|
|
1725
|
+
}));
|
|
1676
1726
|
},
|
|
1677
|
-
onFinish: () =>
|
|
1727
|
+
onFinish: () => C(null)
|
|
1678
1728
|
});
|
|
1679
1729
|
}, [
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1730
|
+
l,
|
|
1731
|
+
n,
|
|
1732
|
+
_,
|
|
1733
|
+
t,
|
|
1734
|
+
u
|
|
1735
|
+
]), ee = ve(() => {
|
|
1736
|
+
O ? x(!0) : n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
|
|
1737
|
+
}, [O, n.meta.cancelHref]), te = F(() => {
|
|
1687
1738
|
let e = {};
|
|
1688
|
-
for (let [t, n] of Object.entries(
|
|
1739
|
+
for (let [t, n] of Object.entries(_.formState.errors)) n?.message && (e[t] = n.message);
|
|
1689
1740
|
return e;
|
|
1690
|
-
}, [
|
|
1691
|
-
|
|
1741
|
+
}, [_.formState.errors]), ne = F(() => {
|
|
1742
|
+
let e = /* @__PURE__ */ new Map(), r = (n) => {
|
|
1743
|
+
for (let [r, i] of Object.entries(n)) {
|
|
1744
|
+
if (u.has(r)) continue;
|
|
1745
|
+
let n = M(i, t);
|
|
1746
|
+
n && e.set(r, n);
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
return r(n.errors), r(w), Array.from(e, ([e, t]) => ({
|
|
1750
|
+
key: e,
|
|
1751
|
+
message: t
|
|
1752
|
+
}));
|
|
1753
|
+
}, [
|
|
1754
|
+
n.errors,
|
|
1755
|
+
w,
|
|
1756
|
+
u,
|
|
1757
|
+
t
|
|
1758
|
+
]);
|
|
1759
|
+
return l.filter((e) => Kt(e, v)).length === 0 && n.schema.length === 0 ? /* @__PURE__ */ I(r, {
|
|
1692
1760
|
variant: "inline",
|
|
1693
|
-
title:
|
|
1694
|
-
}) : /* @__PURE__ */ L(
|
|
1695
|
-
onSubmit:
|
|
1761
|
+
title: t("middag.ui.form.no_fields")
|
|
1762
|
+
}) : /* @__PURE__ */ L(we, { children: [/* @__PURE__ */ L("form", {
|
|
1763
|
+
onSubmit: _.handleSubmit(j),
|
|
1696
1764
|
className: "mx-auto max-w-[720px] space-y-6",
|
|
1697
1765
|
noValidate: !0,
|
|
1698
1766
|
role: "form",
|
|
1699
|
-
"aria-label": c(e.title,
|
|
1700
|
-
children: [
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
children:
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1767
|
+
"aria-label": c(e.title, t) || t("middag.ui.form.default_title"),
|
|
1768
|
+
children: [
|
|
1769
|
+
ne.length > 0 && /* @__PURE__ */ L(de, {
|
|
1770
|
+
variant: "destructive",
|
|
1771
|
+
children: [/* @__PURE__ */ I(a, { children: t("middag.ui.form.errors_title") }), /* @__PURE__ */ I(d, { children: /* @__PURE__ */ I("ul", {
|
|
1772
|
+
className: "list-disc ps-4",
|
|
1773
|
+
children: ne.map((e) => /* @__PURE__ */ I("li", { children: e.message }, e.key))
|
|
1774
|
+
}) })]
|
|
1775
|
+
}),
|
|
1776
|
+
/* @__PURE__ */ I(ln, {
|
|
1777
|
+
nodes: n.schema,
|
|
1778
|
+
values: v,
|
|
1779
|
+
errors: te,
|
|
1780
|
+
onChange: A,
|
|
1781
|
+
sourceValues: v
|
|
1782
|
+
}),
|
|
1783
|
+
/* @__PURE__ */ L("div", {
|
|
1784
|
+
className: "flex gap-3 pt-4",
|
|
1785
|
+
children: [/* @__PURE__ */ I(fe, {
|
|
1786
|
+
type: "submit",
|
|
1787
|
+
disabled: k,
|
|
1788
|
+
"aria-disabled": k,
|
|
1789
|
+
"aria-busy": k,
|
|
1790
|
+
children: k ? S === null ? t("middag.ui.form.saving") : `${t("middag.ui.form.saving")} ${S}%` : n.meta.submitLabel ?? t("middag.ui.form.save")
|
|
1791
|
+
}), /* @__PURE__ */ I(fe, {
|
|
1792
|
+
type: "button",
|
|
1793
|
+
variant: "outline",
|
|
1794
|
+
onClick: ee,
|
|
1795
|
+
children: n.meta.cancelLabel ?? t("middag.ui.cancel")
|
|
1796
|
+
})]
|
|
1797
|
+
})
|
|
1798
|
+
]
|
|
1799
|
+
}), /* @__PURE__ */ I(f, {
|
|
1800
|
+
open: b,
|
|
1801
|
+
onOpenChange: x,
|
|
1802
|
+
children: /* @__PURE__ */ L(i, { children: [/* @__PURE__ */ L(o, { children: [/* @__PURE__ */ I(p, { children: t("middag.ui.form.dirty_title") }), /* @__PURE__ */ I(s, { children: t("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ L(re, { children: [/* @__PURE__ */ I(fe, {
|
|
1724
1803
|
variant: "outline",
|
|
1725
|
-
onClick: () =>
|
|
1726
|
-
children:
|
|
1804
|
+
onClick: () => x(!1),
|
|
1805
|
+
children: t("middag.ui.cancel")
|
|
1727
1806
|
}), /* @__PURE__ */ I(fe, {
|
|
1728
1807
|
variant: "destructive",
|
|
1729
1808
|
onClick: () => {
|
|
1730
|
-
|
|
1809
|
+
x(!1), n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
|
|
1731
1810
|
},
|
|
1732
|
-
children:
|
|
1811
|
+
children: t("middag.ui.form.dirty_leave")
|
|
1733
1812
|
})] })] })
|
|
1734
1813
|
})] });
|
|
1735
1814
|
}
|
|
1736
1815
|
//#endregion
|
|
1737
|
-
export {
|
|
1816
|
+
export { un as FormPanelBlock };
|