react-form-dto 1.0.4 → 1.0.5
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/components/FormBuilder.d.ts +17 -11
- package/dist/example/Demo.d.ts +1 -0
- package/dist/form/FormContext.d.ts +41 -0
- package/dist/form/FormProvider.d.ts +8 -0
- package/dist/form/useFieldArray.d.ts +10 -0
- package/dist/form/useForm.d.ts +10 -0
- package/dist/form/useWatch.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useFormDTO.d.ts +21 -0
- package/dist/index.d.ts +8 -1
- package/dist/react-form-dto.es.js +570 -363
- package/dist/react-form-dto.umd.js +2 -2
- package/dist/stories/Demo.stories.d.ts +16 -0
- package/package.json +4 -4
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FormControl as
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
9
|
-
function n(a, o
|
|
1
|
+
import ce, { useState as I, createContext as Ee, useContext as de, useImperativeHandle as ye, useRef as z, useCallback as S, useMemo as ae } from "react";
|
|
2
|
+
import { FormControl as fe, InputLabel as je, Select as Re, MenuItem as _e, Typography as L, TextField as W, FormControlLabel as me, Checkbox as Te, FormHelperText as pe, Autocomplete as be, FormLabel as Ae, RadioGroup as Fe, Radio as Se, Box as ke, Grid as oe } from "@mui/material";
|
|
3
|
+
var q = { exports: {} }, P = {};
|
|
4
|
+
var ue;
|
|
5
|
+
function we() {
|
|
6
|
+
if (ue) return P;
|
|
7
|
+
ue = 1;
|
|
8
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
|
+
function n(s, a, o) {
|
|
10
10
|
var u = null;
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
for (var
|
|
14
|
-
|
|
15
|
-
} else
|
|
16
|
-
return
|
|
11
|
+
if (o !== void 0 && (u = "" + o), a.key !== void 0 && (u = "" + a.key), "key" in a) {
|
|
12
|
+
o = {};
|
|
13
|
+
for (var l in a)
|
|
14
|
+
l !== "key" && (o[l] = a[l]);
|
|
15
|
+
} else o = a;
|
|
16
|
+
return a = o.ref, {
|
|
17
17
|
$$typeof: e,
|
|
18
|
-
type:
|
|
18
|
+
type: s,
|
|
19
19
|
key: u,
|
|
20
|
-
ref:
|
|
21
|
-
props:
|
|
20
|
+
ref: a !== void 0 ? a : null,
|
|
21
|
+
props: o
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return P.Fragment = t, P.jsx = n, P.jsxs = n, P;
|
|
25
25
|
}
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
return
|
|
26
|
+
var V = {};
|
|
27
|
+
var le;
|
|
28
|
+
function $e() {
|
|
29
|
+
return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
30
|
function e(r) {
|
|
31
31
|
if (r == null) return null;
|
|
32
32
|
if (typeof r == "function")
|
|
33
|
-
return r.$$typeof ===
|
|
33
|
+
return r.$$typeof === N ? null : r.displayName || r.name || null;
|
|
34
34
|
if (typeof r == "string") return r;
|
|
35
35
|
switch (r) {
|
|
36
36
|
case O:
|
|
37
37
|
return "Fragment";
|
|
38
|
-
case
|
|
38
|
+
case C:
|
|
39
39
|
return "Profiler";
|
|
40
|
-
case
|
|
40
|
+
case B:
|
|
41
41
|
return "StrictMode";
|
|
42
|
-
case
|
|
42
|
+
case T:
|
|
43
43
|
return "Suspense";
|
|
44
|
-
case
|
|
44
|
+
case A:
|
|
45
45
|
return "SuspenseList";
|
|
46
|
-
case
|
|
46
|
+
case U:
|
|
47
47
|
return "Activity";
|
|
48
48
|
}
|
|
49
49
|
if (typeof r == "object")
|
|
@@ -52,19 +52,19 @@ function _e() {
|
|
|
52
52
|
), r.$$typeof) {
|
|
53
53
|
case w:
|
|
54
54
|
return "Portal";
|
|
55
|
-
case
|
|
55
|
+
case b:
|
|
56
56
|
return r.displayName || "Context";
|
|
57
|
-
case
|
|
57
|
+
case f:
|
|
58
58
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
59
|
-
case
|
|
60
|
-
var
|
|
61
|
-
return r = r.displayName, r || (r =
|
|
62
|
-
case le:
|
|
63
|
-
return i = r.displayName || null, i !== null ? i : e(r.type) || "Memo";
|
|
59
|
+
case R:
|
|
60
|
+
var d = r.render;
|
|
61
|
+
return r = r.displayName, r || (r = d.displayName || d.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
64
62
|
case F:
|
|
65
|
-
|
|
63
|
+
return d = r.displayName || null, d !== null ? d : e(r.type) || "Memo";
|
|
64
|
+
case k:
|
|
65
|
+
d = r._payload, r = r._init;
|
|
66
66
|
try {
|
|
67
|
-
return e(r(
|
|
67
|
+
return e(r(d));
|
|
68
68
|
} catch {
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -76,74 +76,74 @@ function _e() {
|
|
|
76
76
|
function n(r) {
|
|
77
77
|
try {
|
|
78
78
|
t(r);
|
|
79
|
-
var
|
|
79
|
+
var d = !1;
|
|
80
80
|
} catch {
|
|
81
|
-
|
|
81
|
+
d = !0;
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
return
|
|
87
|
-
|
|
83
|
+
if (d) {
|
|
84
|
+
d = console;
|
|
85
|
+
var h = d.error, g = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
86
|
+
return h.call(
|
|
87
|
+
d,
|
|
88
88
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
89
|
-
|
|
89
|
+
g
|
|
90
90
|
), t(r);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function s(r) {
|
|
94
94
|
if (r === O) return "<>";
|
|
95
|
-
if (typeof r == "object" && r !== null && r.$$typeof ===
|
|
95
|
+
if (typeof r == "object" && r !== null && r.$$typeof === k)
|
|
96
96
|
return "<...>";
|
|
97
97
|
try {
|
|
98
|
-
var
|
|
99
|
-
return
|
|
98
|
+
var d = e(r);
|
|
99
|
+
return d ? "<" + d + ">" : "<...>";
|
|
100
100
|
} catch {
|
|
101
101
|
return "<...>";
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
var r =
|
|
104
|
+
function a() {
|
|
105
|
+
var r = G.A;
|
|
106
106
|
return r === null ? null : r.getOwner();
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function o() {
|
|
109
109
|
return Error("react-stack-top-frame");
|
|
110
110
|
}
|
|
111
111
|
function u(r) {
|
|
112
|
-
if (
|
|
113
|
-
var
|
|
114
|
-
if (
|
|
112
|
+
if (K.call(r, "key")) {
|
|
113
|
+
var d = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
114
|
+
if (d && d.isReactWarning) return !1;
|
|
115
115
|
}
|
|
116
116
|
return r.key !== void 0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
function
|
|
120
|
-
|
|
118
|
+
function l(r, d) {
|
|
119
|
+
function h() {
|
|
120
|
+
ee || (ee = !0, console.error(
|
|
121
121
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
122
|
-
|
|
122
|
+
d
|
|
123
123
|
));
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
get:
|
|
125
|
+
h.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
126
|
+
get: h,
|
|
127
127
|
configurable: !0
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function m() {
|
|
131
131
|
var r = e(this.type);
|
|
132
|
-
return
|
|
132
|
+
return re[r] || (re[r] = !0, console.error(
|
|
133
133
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
134
134
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var
|
|
136
|
+
function j(r, d, h, g, D, X) {
|
|
137
|
+
var E = h.ref;
|
|
138
138
|
return r = {
|
|
139
|
-
$$typeof:
|
|
139
|
+
$$typeof: _,
|
|
140
140
|
type: r,
|
|
141
|
-
key:
|
|
142
|
-
props:
|
|
143
|
-
_owner:
|
|
144
|
-
}, (
|
|
141
|
+
key: d,
|
|
142
|
+
props: h,
|
|
143
|
+
_owner: g
|
|
144
|
+
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(r, "ref", {
|
|
145
145
|
enumerable: !1,
|
|
146
|
-
get:
|
|
146
|
+
get: m
|
|
147
147
|
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
148
148
|
configurable: !1,
|
|
149
149
|
enumerable: !1,
|
|
@@ -158,159 +158,159 @@ function _e() {
|
|
|
158
158
|
configurable: !1,
|
|
159
159
|
enumerable: !1,
|
|
160
160
|
writable: !0,
|
|
161
|
-
value:
|
|
161
|
+
value: D
|
|
162
162
|
}), Object.defineProperty(r, "_debugTask", {
|
|
163
163
|
configurable: !1,
|
|
164
164
|
enumerable: !1,
|
|
165
165
|
writable: !0,
|
|
166
|
-
value:
|
|
166
|
+
value: X
|
|
167
167
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
var
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
if (
|
|
174
|
-
for (
|
|
175
|
-
|
|
176
|
-
Object.freeze && Object.freeze(
|
|
169
|
+
function x(r, d, h, g, D, X) {
|
|
170
|
+
var E = d.children;
|
|
171
|
+
if (E !== void 0)
|
|
172
|
+
if (g)
|
|
173
|
+
if (xe(E)) {
|
|
174
|
+
for (g = 0; g < E.length; g++)
|
|
175
|
+
p(E[g]);
|
|
176
|
+
Object.freeze && Object.freeze(E);
|
|
177
177
|
} else
|
|
178
178
|
console.error(
|
|
179
179
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
180
180
|
);
|
|
181
|
-
else
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
var
|
|
185
|
-
return
|
|
181
|
+
else p(E);
|
|
182
|
+
if (K.call(d, "key")) {
|
|
183
|
+
E = e(r);
|
|
184
|
+
var $ = Object.keys(d).filter(function(ge) {
|
|
185
|
+
return ge !== "key";
|
|
186
186
|
});
|
|
187
|
-
|
|
187
|
+
g = 0 < $.length ? "{key: someKey, " + $.join(": ..., ") + ": ...}" : "{key: someKey}", se[E + g] || ($ = 0 < $.length ? "{" + $.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
188
188
|
`A props object containing a "key" prop is being spread into JSX:
|
|
189
189
|
let props = %s;
|
|
190
190
|
<%s {...props} />
|
|
191
191
|
React keys must be passed directly to JSX without using spread:
|
|
192
192
|
let props = %s;
|
|
193
193
|
<%s key={someKey} {...props} />`,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
),
|
|
194
|
+
g,
|
|
195
|
+
E,
|
|
196
|
+
$,
|
|
197
|
+
E
|
|
198
|
+
), se[E + g] = !0);
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
for (var
|
|
203
|
-
|
|
204
|
-
} else
|
|
205
|
-
return
|
|
206
|
-
|
|
200
|
+
if (E = null, h !== void 0 && (n(h), E = "" + h), u(d) && (n(d.key), E = "" + d.key), "key" in d) {
|
|
201
|
+
h = {};
|
|
202
|
+
for (var H in d)
|
|
203
|
+
H !== "key" && (h[H] = d[H]);
|
|
204
|
+
} else h = d;
|
|
205
|
+
return E && l(
|
|
206
|
+
h,
|
|
207
207
|
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
208
|
-
),
|
|
208
|
+
), j(
|
|
209
209
|
r,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
E,
|
|
211
|
+
h,
|
|
212
|
+
a(),
|
|
213
|
+
D,
|
|
214
|
+
X
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
217
|
+
function p(r) {
|
|
218
|
+
c(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === k && (r._payload.status === "fulfilled" ? c(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
|
|
219
219
|
}
|
|
220
|
-
function
|
|
221
|
-
return typeof r == "object" && r !== null && r.$$typeof ===
|
|
220
|
+
function c(r) {
|
|
221
|
+
return typeof r == "object" && r !== null && r.$$typeof === _;
|
|
222
222
|
}
|
|
223
|
-
var
|
|
223
|
+
var v = ce, _ = /* @__PURE__ */ Symbol.for("react.transitional.element"), w = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), B = /* @__PURE__ */ Symbol.for("react.strict_mode"), C = /* @__PURE__ */ Symbol.for("react.profiler"), f = /* @__PURE__ */ Symbol.for("react.consumer"), b = /* @__PURE__ */ Symbol.for("react.context"), R = /* @__PURE__ */ Symbol.for("react.forward_ref"), T = /* @__PURE__ */ Symbol.for("react.suspense"), A = /* @__PURE__ */ Symbol.for("react.suspense_list"), F = /* @__PURE__ */ Symbol.for("react.memo"), k = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), N = /* @__PURE__ */ Symbol.for("react.client.reference"), G = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, xe = Array.isArray, J = console.createTask ? console.createTask : function() {
|
|
224
224
|
return null;
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
v = {
|
|
227
227
|
react_stack_bottom_frame: function(r) {
|
|
228
228
|
return r();
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
)(),
|
|
235
|
-
|
|
236
|
-
var
|
|
237
|
-
return
|
|
231
|
+
var ee, re = {}, te = v.react_stack_bottom_frame.bind(
|
|
232
|
+
v,
|
|
233
|
+
o
|
|
234
|
+
)(), ne = J(s(o)), se = {};
|
|
235
|
+
V.Fragment = O, V.jsx = function(r, d, h) {
|
|
236
|
+
var g = 1e4 > G.recentlyCreatedOwnerStacks++;
|
|
237
|
+
return x(
|
|
238
238
|
r,
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
d,
|
|
240
|
+
h,
|
|
241
241
|
!1,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
g ? Error("react-stack-top-frame") : te,
|
|
243
|
+
g ? J(s(r)) : ne
|
|
244
244
|
);
|
|
245
|
-
},
|
|
246
|
-
var
|
|
247
|
-
return
|
|
245
|
+
}, V.jsxs = function(r, d, h) {
|
|
246
|
+
var g = 1e4 > G.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return x(
|
|
248
248
|
r,
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
d,
|
|
250
|
+
h,
|
|
251
251
|
!0,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
g ? Error("react-stack-top-frame") : te,
|
|
253
|
+
g ? J(s(r)) : ne
|
|
254
254
|
);
|
|
255
255
|
};
|
|
256
|
-
})()),
|
|
256
|
+
})()), V;
|
|
257
257
|
}
|
|
258
|
-
var
|
|
259
|
-
function
|
|
260
|
-
return
|
|
258
|
+
var ie;
|
|
259
|
+
function Oe() {
|
|
260
|
+
return ie || (ie = 1, process.env.NODE_ENV === "production" ? q.exports = we() : q.exports = $e()), q.exports;
|
|
261
261
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
262
|
+
var i = Oe();
|
|
263
|
+
function y(e, t = "en") {
|
|
264
264
|
return e ? typeof e == "string" ? e : e[t] || e.en || Object.values(e)[0] || "" : "";
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function Y(e, t = "en") {
|
|
267
267
|
return e ? e.map((n) => typeof n == "string" ? { value: n, label: n } : {
|
|
268
268
|
value: n.value,
|
|
269
|
-
label:
|
|
269
|
+
label: y(n.label, t)
|
|
270
270
|
}) : [];
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Ce({
|
|
273
273
|
field: e,
|
|
274
274
|
value: t,
|
|
275
275
|
onChange: n,
|
|
276
|
-
error:
|
|
277
|
-
locale:
|
|
276
|
+
error: s,
|
|
277
|
+
locale: a = "en"
|
|
278
278
|
}) {
|
|
279
|
-
const
|
|
280
|
-
return /* @__PURE__ */
|
|
281
|
-
/* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
|
|
279
|
+
const o = Y(e.options || [], a);
|
|
280
|
+
return /* @__PURE__ */ i.jsxs(fe, { fullWidth: !0, children: [
|
|
281
|
+
/* @__PURE__ */ i.jsx(je, { id: `${e.id}-label`, children: y(e.label, a) }),
|
|
282
|
+
/* @__PURE__ */ i.jsx(
|
|
283
|
+
Re,
|
|
284
284
|
{
|
|
285
285
|
labelId: `${e.id}-label`,
|
|
286
286
|
value: t,
|
|
287
287
|
id: e.id,
|
|
288
288
|
name: e.id,
|
|
289
289
|
onChange: (u) => n(u.target.value),
|
|
290
|
-
label:
|
|
291
|
-
error: !!
|
|
292
|
-
children:
|
|
290
|
+
label: y(e.label, a),
|
|
291
|
+
error: !!s,
|
|
292
|
+
children: o?.map((u) => /* @__PURE__ */ i.jsx(_e, { value: u.value, children: u.label }, u.label))
|
|
293
293
|
}
|
|
294
294
|
),
|
|
295
|
-
|
|
295
|
+
s && /* @__PURE__ */ i.jsx(L, { variant: "caption", color: "error", children: s })
|
|
296
296
|
] });
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function Pe({
|
|
299
299
|
field: e,
|
|
300
300
|
value: t,
|
|
301
301
|
onChange: n,
|
|
302
|
-
error:
|
|
303
|
-
locale:
|
|
302
|
+
error: s,
|
|
303
|
+
locale: a
|
|
304
304
|
}) {
|
|
305
|
-
return console.log("error",
|
|
306
|
-
|
|
305
|
+
return console.log("error", s), /* @__PURE__ */ i.jsx(
|
|
306
|
+
W,
|
|
307
307
|
{
|
|
308
308
|
fullWidth: !0,
|
|
309
|
-
label:
|
|
310
|
-
placeholder:
|
|
309
|
+
label: y(e.label, a),
|
|
310
|
+
placeholder: y(e.placeholder || "", a),
|
|
311
311
|
value: t || "",
|
|
312
312
|
name: e.id,
|
|
313
|
-
onChange: (
|
|
313
|
+
onChange: (o) => n(o.target.value),
|
|
314
314
|
disabled: e.disabled,
|
|
315
315
|
type: e.type,
|
|
316
316
|
slotProps: {
|
|
@@ -318,147 +318,147 @@ function Ae({
|
|
|
318
318
|
shrink: e.type === "date" ? !0 : void 0
|
|
319
319
|
}
|
|
320
320
|
},
|
|
321
|
-
error: !!
|
|
322
|
-
helperText:
|
|
321
|
+
error: !!s,
|
|
322
|
+
helperText: s
|
|
323
323
|
}
|
|
324
324
|
);
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function Ve({
|
|
327
327
|
field: e,
|
|
328
328
|
value: t,
|
|
329
329
|
onChange: n,
|
|
330
|
-
error:
|
|
331
|
-
locale:
|
|
330
|
+
error: s,
|
|
331
|
+
locale: a
|
|
332
332
|
}) {
|
|
333
|
-
return /* @__PURE__ */
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
|
|
333
|
+
return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
334
|
+
/* @__PURE__ */ i.jsx(
|
|
335
|
+
me,
|
|
336
336
|
{
|
|
337
337
|
name: e.id,
|
|
338
|
-
control: /* @__PURE__ */
|
|
339
|
-
|
|
338
|
+
control: /* @__PURE__ */ i.jsx(
|
|
339
|
+
Te,
|
|
340
340
|
{
|
|
341
341
|
checked: !!t,
|
|
342
|
-
onChange: (
|
|
342
|
+
onChange: (o) => n(o.target.checked),
|
|
343
343
|
disabled: e.disabled
|
|
344
344
|
}
|
|
345
345
|
),
|
|
346
|
-
label:
|
|
346
|
+
label: y(e.label, a)
|
|
347
347
|
}
|
|
348
348
|
),
|
|
349
|
-
|
|
349
|
+
s && /* @__PURE__ */ i.jsx(pe, { children: s })
|
|
350
350
|
] });
|
|
351
351
|
}
|
|
352
|
-
const
|
|
352
|
+
const Ie = ({
|
|
353
353
|
field: e,
|
|
354
354
|
value: t,
|
|
355
355
|
onChange: n,
|
|
356
|
-
error:
|
|
357
|
-
locale:
|
|
356
|
+
error: s,
|
|
357
|
+
locale: a
|
|
358
358
|
}) => {
|
|
359
|
-
const
|
|
360
|
-
return /* @__PURE__ */
|
|
361
|
-
|
|
359
|
+
const o = Y(e.options || [], a);
|
|
360
|
+
return /* @__PURE__ */ i.jsx(
|
|
361
|
+
be,
|
|
362
362
|
{
|
|
363
363
|
fullWidth: !0,
|
|
364
|
-
options:
|
|
364
|
+
options: o || [],
|
|
365
365
|
value: t || null,
|
|
366
|
-
onChange: (u,
|
|
367
|
-
renderInput: (u) => /* @__PURE__ */
|
|
368
|
-
|
|
366
|
+
onChange: (u, l) => n(l),
|
|
367
|
+
renderInput: (u) => /* @__PURE__ */ i.jsx(
|
|
368
|
+
W,
|
|
369
369
|
{
|
|
370
370
|
...u,
|
|
371
371
|
name: e.id,
|
|
372
|
-
label:
|
|
373
|
-
placeholder:
|
|
372
|
+
label: y(e.label, a),
|
|
373
|
+
placeholder: y(
|
|
374
374
|
e.placeholder || "",
|
|
375
|
-
|
|
375
|
+
a
|
|
376
376
|
),
|
|
377
377
|
disabled: e.disabled,
|
|
378
|
-
error: !!
|
|
379
|
-
helperText:
|
|
378
|
+
error: !!s,
|
|
379
|
+
helperText: s
|
|
380
380
|
}
|
|
381
381
|
)
|
|
382
382
|
}
|
|
383
383
|
);
|
|
384
|
-
},
|
|
384
|
+
}, Le = ({
|
|
385
385
|
field: e,
|
|
386
386
|
value: t,
|
|
387
387
|
onChange: n,
|
|
388
|
-
error:
|
|
389
|
-
locale:
|
|
388
|
+
error: s,
|
|
389
|
+
locale: a
|
|
390
390
|
}) => {
|
|
391
|
-
const
|
|
392
|
-
return /* @__PURE__ */
|
|
393
|
-
|
|
391
|
+
const o = Y(e.options || [], a);
|
|
392
|
+
return /* @__PURE__ */ i.jsx(
|
|
393
|
+
be,
|
|
394
394
|
{
|
|
395
395
|
multiple: !0,
|
|
396
396
|
fullWidth: !0,
|
|
397
|
-
options:
|
|
397
|
+
options: o || [],
|
|
398
398
|
value: t || [],
|
|
399
|
-
onChange: (u,
|
|
400
|
-
renderInput: (u) => /* @__PURE__ */
|
|
401
|
-
|
|
399
|
+
onChange: (u, l) => n(l),
|
|
400
|
+
renderInput: (u) => /* @__PURE__ */ i.jsx(
|
|
401
|
+
W,
|
|
402
402
|
{
|
|
403
403
|
...u,
|
|
404
404
|
name: e.id,
|
|
405
|
-
label:
|
|
406
|
-
placeholder:
|
|
405
|
+
label: y(e.label, a),
|
|
406
|
+
placeholder: y(
|
|
407
407
|
e.placeholder || "",
|
|
408
|
-
|
|
408
|
+
a
|
|
409
409
|
),
|
|
410
410
|
disabled: e.disabled,
|
|
411
|
-
error: !!
|
|
412
|
-
helperText:
|
|
411
|
+
error: !!s,
|
|
412
|
+
helperText: s
|
|
413
413
|
}
|
|
414
414
|
)
|
|
415
415
|
}
|
|
416
416
|
);
|
|
417
|
-
},
|
|
417
|
+
}, Ne = ({
|
|
418
418
|
field: e,
|
|
419
419
|
value: t,
|
|
420
420
|
onChange: n,
|
|
421
|
-
error:
|
|
422
|
-
locale:
|
|
423
|
-
}) => /* @__PURE__ */
|
|
424
|
-
|
|
421
|
+
error: s,
|
|
422
|
+
locale: a = "en"
|
|
423
|
+
}) => /* @__PURE__ */ i.jsx(
|
|
424
|
+
W,
|
|
425
425
|
{
|
|
426
426
|
fullWidth: !0,
|
|
427
427
|
multiline: !0,
|
|
428
428
|
rows: e.rows || 4,
|
|
429
|
-
label:
|
|
430
|
-
placeholder:
|
|
429
|
+
label: y(e.label, a),
|
|
430
|
+
placeholder: y(e.placeholder || "", a),
|
|
431
431
|
value: t || "",
|
|
432
|
-
onChange: (
|
|
432
|
+
onChange: (o) => n(o.target.value),
|
|
433
433
|
required: !!e.validations?.required,
|
|
434
434
|
disabled: e.disabled,
|
|
435
|
-
error: !!
|
|
436
|
-
helperText:
|
|
435
|
+
error: !!s,
|
|
436
|
+
helperText: s
|
|
437
437
|
}
|
|
438
|
-
),
|
|
438
|
+
), De = ({
|
|
439
439
|
field: e,
|
|
440
440
|
value: t,
|
|
441
441
|
onChange: n,
|
|
442
|
-
error:
|
|
443
|
-
locale:
|
|
442
|
+
error: s,
|
|
443
|
+
locale: a = "en"
|
|
444
444
|
}) => {
|
|
445
|
-
const
|
|
446
|
-
return /* @__PURE__ */
|
|
447
|
-
/* @__PURE__ */
|
|
448
|
-
|
|
445
|
+
const o = Y(e.options || [], a);
|
|
446
|
+
return /* @__PURE__ */ i.jsxs(fe, { component: "fieldset", fullWidth: !0, error: !!s, children: [
|
|
447
|
+
/* @__PURE__ */ i.jsxs(Ae, { component: "legend", children: [
|
|
448
|
+
y(e.label, a),
|
|
449
449
|
e.validations?.required ? " *" : ""
|
|
450
450
|
] }),
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
|
|
451
|
+
/* @__PURE__ */ i.jsx(
|
|
452
|
+
Fe,
|
|
453
453
|
{
|
|
454
454
|
row: e.layout?.direction === "row" || !1,
|
|
455
455
|
value: t || "",
|
|
456
456
|
onChange: (u) => n(u.target.value),
|
|
457
|
-
children: (
|
|
458
|
-
|
|
457
|
+
children: (o || []).map((u) => /* @__PURE__ */ i.jsx(
|
|
458
|
+
me,
|
|
459
459
|
{
|
|
460
460
|
value: u.value,
|
|
461
|
-
control: /* @__PURE__ */
|
|
461
|
+
control: /* @__PURE__ */ i.jsx(Se, {}),
|
|
462
462
|
label: u.label,
|
|
463
463
|
disabled: e.disabled
|
|
464
464
|
},
|
|
@@ -466,14 +466,14 @@ const ke = ({
|
|
|
466
466
|
))
|
|
467
467
|
}
|
|
468
468
|
),
|
|
469
|
-
|
|
469
|
+
s && /* @__PURE__ */ i.jsx(pe, { children: s })
|
|
470
470
|
] });
|
|
471
|
-
},
|
|
471
|
+
}, qe = ({
|
|
472
472
|
field: e,
|
|
473
473
|
value: t,
|
|
474
474
|
onChange: n,
|
|
475
|
-
error:
|
|
476
|
-
locale:
|
|
475
|
+
error: s,
|
|
476
|
+
locale: a = "en"
|
|
477
477
|
}) => {
|
|
478
478
|
switch (e.type) {
|
|
479
479
|
case "text":
|
|
@@ -481,109 +481,109 @@ const ke = ({
|
|
|
481
481
|
case "email":
|
|
482
482
|
case "password":
|
|
483
483
|
case "number":
|
|
484
|
-
return /* @__PURE__ */
|
|
485
|
-
|
|
484
|
+
return /* @__PURE__ */ i.jsx(
|
|
485
|
+
Pe,
|
|
486
486
|
{
|
|
487
487
|
field: e,
|
|
488
488
|
value: t,
|
|
489
489
|
onChange: n,
|
|
490
|
-
error:
|
|
491
|
-
locale:
|
|
490
|
+
error: s,
|
|
491
|
+
locale: a
|
|
492
492
|
}
|
|
493
493
|
);
|
|
494
494
|
case "select":
|
|
495
|
-
return /* @__PURE__ */
|
|
496
|
-
|
|
495
|
+
return /* @__PURE__ */ i.jsx(
|
|
496
|
+
Ce,
|
|
497
497
|
{
|
|
498
498
|
field: e,
|
|
499
499
|
value: t,
|
|
500
500
|
onChange: n,
|
|
501
|
-
error:
|
|
502
|
-
locale:
|
|
501
|
+
error: s,
|
|
502
|
+
locale: a
|
|
503
503
|
}
|
|
504
504
|
);
|
|
505
505
|
case "autocomplete":
|
|
506
|
-
return /* @__PURE__ */
|
|
507
|
-
|
|
506
|
+
return /* @__PURE__ */ i.jsx(
|
|
507
|
+
Ie,
|
|
508
508
|
{
|
|
509
509
|
field: e,
|
|
510
510
|
value: t,
|
|
511
511
|
onChange: n,
|
|
512
|
-
error:
|
|
513
|
-
locale:
|
|
512
|
+
error: s,
|
|
513
|
+
locale: a
|
|
514
514
|
}
|
|
515
515
|
);
|
|
516
516
|
case "multi-autocomplete":
|
|
517
|
-
return /* @__PURE__ */
|
|
518
|
-
|
|
517
|
+
return /* @__PURE__ */ i.jsx(
|
|
518
|
+
Le,
|
|
519
519
|
{
|
|
520
520
|
field: e,
|
|
521
521
|
value: t,
|
|
522
522
|
onChange: n,
|
|
523
|
-
error:
|
|
524
|
-
locale:
|
|
523
|
+
error: s,
|
|
524
|
+
locale: a
|
|
525
525
|
}
|
|
526
526
|
);
|
|
527
527
|
case "checkbox":
|
|
528
|
-
return /* @__PURE__ */
|
|
529
|
-
|
|
528
|
+
return /* @__PURE__ */ i.jsx(
|
|
529
|
+
Ve,
|
|
530
530
|
{
|
|
531
531
|
field: e,
|
|
532
532
|
value: t,
|
|
533
533
|
onChange: n,
|
|
534
|
-
error:
|
|
535
|
-
locale:
|
|
534
|
+
error: s,
|
|
535
|
+
locale: a
|
|
536
536
|
}
|
|
537
537
|
);
|
|
538
538
|
case "textarea":
|
|
539
|
-
return /* @__PURE__ */
|
|
540
|
-
|
|
539
|
+
return /* @__PURE__ */ i.jsx(
|
|
540
|
+
Ne,
|
|
541
541
|
{
|
|
542
542
|
field: e,
|
|
543
543
|
value: t,
|
|
544
544
|
onChange: n,
|
|
545
|
-
error:
|
|
546
|
-
locale:
|
|
545
|
+
error: s,
|
|
546
|
+
locale: a
|
|
547
547
|
}
|
|
548
548
|
);
|
|
549
549
|
case "radio":
|
|
550
|
-
return /* @__PURE__ */
|
|
551
|
-
|
|
550
|
+
return /* @__PURE__ */ i.jsx(
|
|
551
|
+
De,
|
|
552
552
|
{
|
|
553
553
|
field: e,
|
|
554
554
|
value: t,
|
|
555
555
|
onChange: n,
|
|
556
|
-
error:
|
|
557
|
-
locale:
|
|
556
|
+
error: s,
|
|
557
|
+
locale: a
|
|
558
558
|
}
|
|
559
559
|
);
|
|
560
560
|
default:
|
|
561
|
-
return /* @__PURE__ */
|
|
561
|
+
return /* @__PURE__ */ i.jsxs("span", { children: [
|
|
562
562
|
"Unsupported field type: ",
|
|
563
563
|
e.type
|
|
564
564
|
] });
|
|
565
565
|
}
|
|
566
|
-
},
|
|
566
|
+
}, ze = ({
|
|
567
567
|
field: e,
|
|
568
568
|
value: t,
|
|
569
569
|
onChange: n,
|
|
570
|
-
error:
|
|
571
|
-
renderers:
|
|
572
|
-
locale:
|
|
570
|
+
error: s,
|
|
571
|
+
renderers: a = {},
|
|
572
|
+
locale: o = "en"
|
|
573
573
|
}) => {
|
|
574
|
-
const u =
|
|
575
|
-
return /* @__PURE__ */
|
|
574
|
+
const u = a[e.type] || qe;
|
|
575
|
+
return /* @__PURE__ */ i.jsx(
|
|
576
576
|
u,
|
|
577
577
|
{
|
|
578
578
|
field: e,
|
|
579
579
|
value: t,
|
|
580
580
|
onChange: n,
|
|
581
|
-
error:
|
|
582
|
-
locale:
|
|
581
|
+
error: s,
|
|
582
|
+
locale: o
|
|
583
583
|
}
|
|
584
584
|
);
|
|
585
585
|
};
|
|
586
|
-
function
|
|
586
|
+
function We(e) {
|
|
587
587
|
const t = e ?? 12;
|
|
588
588
|
return {
|
|
589
589
|
xs: 12,
|
|
@@ -597,7 +597,7 @@ function Ce(e) {
|
|
|
597
597
|
xl: t
|
|
598
598
|
};
|
|
599
599
|
}
|
|
600
|
-
const
|
|
600
|
+
const He = {
|
|
601
601
|
/**
|
|
602
602
|
* Validates that a required field has a value.
|
|
603
603
|
* @param field - The field definition
|
|
@@ -677,55 +677,55 @@ const ze = {
|
|
|
677
677
|
}
|
|
678
678
|
return null;
|
|
679
679
|
}
|
|
680
|
-
},
|
|
681
|
-
const
|
|
682
|
-
return e.sections.forEach((
|
|
683
|
-
|
|
684
|
-
const u =
|
|
685
|
-
u.length > 0 && (
|
|
680
|
+
}, he = (e, t, n = "en") => {
|
|
681
|
+
const s = {};
|
|
682
|
+
return e.sections.forEach((a) => {
|
|
683
|
+
a.fields.forEach((o) => {
|
|
684
|
+
const u = M(e, t, o.id);
|
|
685
|
+
u.length > 0 && (s[o.id] = u);
|
|
686
686
|
});
|
|
687
|
-
}),
|
|
688
|
-
},
|
|
689
|
-
const
|
|
690
|
-
if (!
|
|
691
|
-
const
|
|
692
|
-
if (
|
|
693
|
-
typeof
|
|
694
|
-
),
|
|
695
|
-
const
|
|
696
|
-
|
|
687
|
+
}), s;
|
|
688
|
+
}, M = (e, t, n, s = "en") => {
|
|
689
|
+
const a = e.sections.flatMap((j) => j.fields).find((j) => j.id === n);
|
|
690
|
+
if (!a) return [];
|
|
691
|
+
const o = a.validations || {}, u = t[n], l = [], m = y(a.label, s);
|
|
692
|
+
if (o.required && (u == null || u === "") && l.push(
|
|
693
|
+
typeof o.required == "string" ? o.required : `${m} is required`
|
|
694
|
+
), o.min !== void 0 && typeof u == "number" && u < o.min && l.push(`${m} must be at least ${o.min}`), o.max !== void 0 && typeof u == "number" && u > o.max && l.push(`${m} must be at most ${o.max}`), o.minLength !== void 0 && typeof u == "string" && u.length < o.minLength && l.push(`${m} must be at least ${o.minLength} characters`), o.maxLength !== void 0 && typeof u == "string" && u.length > o.maxLength && l.push(`${m} must be at most ${o.maxLength} characters`), o.pattern && typeof u == "string" && !o.pattern.test(u) && l.push(`${m} is invalid`), o.validate) {
|
|
695
|
+
const j = o.validate(u);
|
|
696
|
+
j && l.push(y(j, s));
|
|
697
697
|
}
|
|
698
|
-
return
|
|
698
|
+
return l;
|
|
699
699
|
};
|
|
700
|
-
function
|
|
700
|
+
function Z(e, t) {
|
|
701
701
|
if (!e)
|
|
702
702
|
return !0;
|
|
703
703
|
if ("field" in e) {
|
|
704
704
|
let n = t[e.field] ?? "";
|
|
705
|
-
return Array.isArray(n) ? n = n.map((
|
|
705
|
+
return Array.isArray(n) ? n = n.map((s) => s.value ?? "") : typeof n == "object" && n !== null && (n = n.value ?? ""), e.equals !== void 0 ? n === e.equals : e.notEquals !== void 0 ? n !== e.notEquals : e.in !== void 0 ? Array.isArray(n) ? e.in ? n.some((s) => e.in.includes(s)) : !1 : e.in.includes(n) : e.notIn !== void 0 ? Array.isArray(n) ? n.every((s) => !e.notIn.includes(s)) : !e.notIn.includes(n) : e.greaterThan !== void 0 ? n > e.greaterThan : e.lessThan !== void 0 ? n < e.lessThan : !0;
|
|
706
706
|
}
|
|
707
707
|
if ("operator" in e) {
|
|
708
708
|
if (e.operator === "AND")
|
|
709
709
|
return e.conditions.every(
|
|
710
|
-
(
|
|
710
|
+
(s) => Z(s, t)
|
|
711
711
|
);
|
|
712
712
|
if (e.operator === "OR")
|
|
713
713
|
return e.conditions.some(
|
|
714
|
-
(n) =>
|
|
714
|
+
(n) => Z(n, t)
|
|
715
715
|
);
|
|
716
716
|
}
|
|
717
717
|
return !1;
|
|
718
718
|
}
|
|
719
|
-
const
|
|
719
|
+
const Ye = ({
|
|
720
720
|
section: e,
|
|
721
721
|
values: t,
|
|
722
722
|
onChange: n,
|
|
723
|
-
renderers:
|
|
724
|
-
validateField:
|
|
725
|
-
locale:
|
|
726
|
-
}) => /* @__PURE__ */
|
|
727
|
-
e.heading && /* @__PURE__ */
|
|
728
|
-
|
|
723
|
+
renderers: s,
|
|
724
|
+
validateField: a,
|
|
725
|
+
locale: o = "en"
|
|
726
|
+
}) => /* @__PURE__ */ i.jsxs(ke, { mb: 2, children: [
|
|
727
|
+
e.heading && /* @__PURE__ */ i.jsx(
|
|
728
|
+
L,
|
|
729
729
|
{
|
|
730
730
|
variant: "h6",
|
|
731
731
|
sx: {
|
|
@@ -733,11 +733,11 @@ const Le = ({
|
|
|
733
733
|
},
|
|
734
734
|
gutterBottom: !0,
|
|
735
735
|
color: "black",
|
|
736
|
-
children:
|
|
736
|
+
children: y(e.heading, o)
|
|
737
737
|
}
|
|
738
738
|
),
|
|
739
|
-
e.description && /* @__PURE__ */
|
|
740
|
-
|
|
739
|
+
e.description && /* @__PURE__ */ i.jsx(
|
|
740
|
+
L,
|
|
741
741
|
{
|
|
742
742
|
variant: "body2",
|
|
743
743
|
sx: {
|
|
@@ -745,23 +745,23 @@ const Le = ({
|
|
|
745
745
|
},
|
|
746
746
|
color: "textSecondary",
|
|
747
747
|
gutterBottom: !0,
|
|
748
|
-
children:
|
|
748
|
+
children: y(e.description, o)
|
|
749
749
|
}
|
|
750
750
|
),
|
|
751
|
-
/* @__PURE__ */
|
|
752
|
-
(u) =>
|
|
753
|
-
|
|
751
|
+
/* @__PURE__ */ i.jsx(oe, { container: !0, spacing: 2, children: e.fields.map(
|
|
752
|
+
(u) => Z(u.visibleWhen, t) && /* @__PURE__ */ i.jsx(
|
|
753
|
+
oe,
|
|
754
754
|
{
|
|
755
|
-
size:
|
|
756
|
-
children: /* @__PURE__ */
|
|
757
|
-
|
|
755
|
+
size: We(u.layout?.cols),
|
|
756
|
+
children: /* @__PURE__ */ i.jsx(
|
|
757
|
+
ze,
|
|
758
758
|
{
|
|
759
759
|
field: u,
|
|
760
760
|
value: t[u.id],
|
|
761
|
-
onChange: (
|
|
762
|
-
renderers:
|
|
763
|
-
error:
|
|
764
|
-
locale:
|
|
761
|
+
onChange: (l) => n(u.id, l),
|
|
762
|
+
renderers: s,
|
|
763
|
+
error: a(u.id)?.join(","),
|
|
764
|
+
locale: o
|
|
765
765
|
}
|
|
766
766
|
)
|
|
767
767
|
},
|
|
@@ -769,46 +769,74 @@ const Le = ({
|
|
|
769
769
|
)
|
|
770
770
|
) })
|
|
771
771
|
] });
|
|
772
|
-
function
|
|
773
|
-
const [
|
|
772
|
+
function Me(e, t = "en", n) {
|
|
773
|
+
const [s, a] = I({}), [o, u] = I({});
|
|
774
774
|
return {
|
|
775
775
|
/** Current form values for all fields */
|
|
776
|
-
values:
|
|
776
|
+
values: s,
|
|
777
777
|
/** Function to update a field value */
|
|
778
|
-
handleChange: (
|
|
779
|
-
if (
|
|
780
|
-
let
|
|
781
|
-
Array.isArray(
|
|
778
|
+
handleChange: (c, v) => {
|
|
779
|
+
if (a((_) => ({ ..._, [c]: v })), u((_) => ({ ..._, [c]: null })), n) {
|
|
780
|
+
let _ = v;
|
|
781
|
+
Array.isArray(v) ? _ = v.map((w) => w.value ?? "") : typeof v == "object" && v !== null && (_ = v.value ?? ""), n(c, _);
|
|
782
782
|
}
|
|
783
783
|
},
|
|
784
784
|
/** Function to validate all fields */
|
|
785
|
-
validateAll: () =>
|
|
785
|
+
validateAll: () => he(e, s, t),
|
|
786
786
|
/** Function to get all current form values */
|
|
787
|
-
getValues: () =>
|
|
787
|
+
getValues: () => s,
|
|
788
788
|
/** Function to get all current form errors */
|
|
789
|
-
getErrors: () =>
|
|
789
|
+
getErrors: () => o,
|
|
790
790
|
/** Function to validate a specific field */
|
|
791
|
-
validateField: (
|
|
791
|
+
validateField: (c) => M(e, s, c, t)
|
|
792
792
|
};
|
|
793
793
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
794
|
+
const Q = Ee(
|
|
795
|
+
void 0
|
|
796
|
+
);
|
|
797
|
+
function ve() {
|
|
798
|
+
const e = de(Q);
|
|
799
|
+
if (!e)
|
|
800
|
+
throw new Error("useFormContext must be used inside a <FormProvider>.");
|
|
801
|
+
return e;
|
|
802
|
+
}
|
|
803
|
+
function Be() {
|
|
804
|
+
return de(Q);
|
|
805
|
+
}
|
|
806
|
+
const Ue = ce.forwardRef(({ dto: e, renderers: t, locale: n = "en", handleChangeCallback: s }, a) => {
|
|
807
|
+
const o = Be(), u = Me(e, n, s), l = !!o, m = l ? o.values : u.values, j = (p, c) => {
|
|
808
|
+
if (l) {
|
|
809
|
+
if (o.setValue(p, c, !0), s) {
|
|
810
|
+
let v = c;
|
|
811
|
+
Array.isArray(c) ? v = c.map((_) => _.value ?? "") : typeof c == "object" && c !== null && (v = c.value ?? ""), s(p, v);
|
|
812
|
+
}
|
|
813
|
+
} else
|
|
814
|
+
u.handleChange(p, c);
|
|
815
|
+
}, x = (p) => {
|
|
816
|
+
if (l && o) {
|
|
817
|
+
const c = o.errors[p];
|
|
818
|
+
return c ? [c] : [];
|
|
819
|
+
}
|
|
820
|
+
return u.validateField(p);
|
|
821
|
+
};
|
|
822
|
+
return ye(a, () => ({
|
|
823
|
+
getValues: () => l ? o.getValues() : u.getValues(),
|
|
824
|
+
getErrors: () => l ? o.errors : u.getErrors(),
|
|
825
|
+
validateAll: () => {
|
|
826
|
+
const p = he(e, m, n);
|
|
827
|
+
return l && e.sections.flatMap((c) => c.fields).forEach((c) => {
|
|
828
|
+
const v = p[c.id];
|
|
829
|
+
v?.length ? o.setError(c.id, v[0]) : o.clearError(c.id);
|
|
830
|
+
}), p;
|
|
831
|
+
},
|
|
832
|
+
validateField: (p) => {
|
|
833
|
+
const c = M(e, m, p, n);
|
|
834
|
+
return l && o.setError(p, c[0] ?? null), c;
|
|
835
|
+
},
|
|
836
|
+
handleChange: j
|
|
837
|
+
})), /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
838
|
+
e.title && /* @__PURE__ */ i.jsx(
|
|
839
|
+
L,
|
|
812
840
|
{
|
|
813
841
|
variant: "h5",
|
|
814
842
|
color: "black",
|
|
@@ -817,11 +845,11 @@ const Ye = X.forwardRef(({ dto: e, renderers: t, locale: n = "en", handleChangeC
|
|
|
817
845
|
fontWeight: "bold"
|
|
818
846
|
},
|
|
819
847
|
gutterBottom: !0,
|
|
820
|
-
children:
|
|
848
|
+
children: y(e.title, n)
|
|
821
849
|
}
|
|
822
850
|
),
|
|
823
|
-
e.description && /* @__PURE__ */
|
|
824
|
-
|
|
851
|
+
e.description && /* @__PURE__ */ i.jsx(
|
|
852
|
+
L,
|
|
825
853
|
{
|
|
826
854
|
component: "p",
|
|
827
855
|
sx: {
|
|
@@ -829,36 +857,215 @@ const Ye = X.forwardRef(({ dto: e, renderers: t, locale: n = "en", handleChangeC
|
|
|
829
857
|
},
|
|
830
858
|
color: "textSecondary",
|
|
831
859
|
gutterBottom: !0,
|
|
832
|
-
children:
|
|
860
|
+
children: y(e.description, n)
|
|
833
861
|
}
|
|
834
862
|
),
|
|
835
|
-
e.sections.map((
|
|
836
|
-
|
|
863
|
+
e.sections.map((p) => /* @__PURE__ */ i.jsx(
|
|
864
|
+
Ye,
|
|
837
865
|
{
|
|
838
|
-
section:
|
|
839
|
-
values:
|
|
840
|
-
onChange:
|
|
866
|
+
section: p,
|
|
867
|
+
values: m,
|
|
868
|
+
onChange: j,
|
|
841
869
|
renderers: t,
|
|
842
|
-
validateField:
|
|
870
|
+
validateField: x,
|
|
843
871
|
locale: n
|
|
844
872
|
},
|
|
845
|
-
|
|
873
|
+
p.id
|
|
846
874
|
))
|
|
847
875
|
] });
|
|
848
|
-
})
|
|
876
|
+
}), Ze = (e) => {
|
|
877
|
+
const t = z(null), { dto: n, locale: s, renderers: a, handleChangeCallback: o } = e;
|
|
878
|
+
return {
|
|
879
|
+
getValues: () => t.current?.getValues() ?? {},
|
|
880
|
+
getErrors: () => t.current?.getErrors() ?? {},
|
|
881
|
+
validateAll: () => t.current?.validateAll() ?? {},
|
|
882
|
+
validateField: (u) => t.current?.validateField(u) ?? [],
|
|
883
|
+
handleChange: (u, l) => t.current?.handleChange?.(u, l),
|
|
884
|
+
Form: () => /* @__PURE__ */ i.jsx(
|
|
885
|
+
Ue,
|
|
886
|
+
{
|
|
887
|
+
ref: t,
|
|
888
|
+
dto: n,
|
|
889
|
+
locale: s,
|
|
890
|
+
renderers: a,
|
|
891
|
+
handleChangeCallback: o
|
|
892
|
+
}
|
|
893
|
+
)
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
function Ge(e = {}) {
|
|
897
|
+
const [t, n] = I({ ...e.defaultValues }), [s, a] = I({}), [o, u] = I({}), l = z({}), m = z(t);
|
|
898
|
+
m.current = t;
|
|
899
|
+
const j = S(
|
|
900
|
+
(f, b) => ({
|
|
901
|
+
name: f,
|
|
902
|
+
ref: (R) => {
|
|
903
|
+
l.current[f] = R;
|
|
904
|
+
},
|
|
905
|
+
onChange: (R) => {
|
|
906
|
+
const T = R.target.value;
|
|
907
|
+
n((F) => ({ ...F, [f]: T })), u((F) => ({
|
|
908
|
+
...F,
|
|
909
|
+
[f]: !0
|
|
910
|
+
}));
|
|
911
|
+
const A = b?.validate ?? e.validate?.[f];
|
|
912
|
+
a((F) => ({
|
|
913
|
+
...F,
|
|
914
|
+
[f]: A ? A(T) : null
|
|
915
|
+
}));
|
|
916
|
+
},
|
|
917
|
+
onBlur: () => {
|
|
918
|
+
u((R) => ({
|
|
919
|
+
...R,
|
|
920
|
+
[f]: !0
|
|
921
|
+
}));
|
|
922
|
+
}
|
|
923
|
+
}),
|
|
924
|
+
[e.validate]
|
|
925
|
+
), x = S(
|
|
926
|
+
(f, b, R) => {
|
|
927
|
+
if (n((T) => ({ ...T, [f]: b })), R) {
|
|
928
|
+
const T = e.validate?.[f];
|
|
929
|
+
a((A) => ({
|
|
930
|
+
...A,
|
|
931
|
+
[f]: T ? T(b) : null
|
|
932
|
+
}));
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
[e.validate]
|
|
936
|
+
), p = S((f, b) => {
|
|
937
|
+
a((R) => ({ ...R, [f]: b }));
|
|
938
|
+
}, []), c = S((f) => {
|
|
939
|
+
a((b) => ({ ...b, [f]: null }));
|
|
940
|
+
}, []), v = S(() => m.current, []), _ = S(
|
|
941
|
+
(f) => {
|
|
942
|
+
const b = f ?? e.defaultValues ?? {};
|
|
943
|
+
n(b), m.current = b, a({}), u({});
|
|
944
|
+
},
|
|
945
|
+
[e.defaultValues]
|
|
946
|
+
), w = S(
|
|
947
|
+
(f) => {
|
|
948
|
+
const b = m.current;
|
|
949
|
+
if (!f) {
|
|
950
|
+
const A = {};
|
|
951
|
+
let F = !0;
|
|
952
|
+
for (const [k, U] of Object.entries(
|
|
953
|
+
e.validate ?? {}
|
|
954
|
+
)) {
|
|
955
|
+
const N = U(
|
|
956
|
+
b[k]
|
|
957
|
+
);
|
|
958
|
+
A[k] = N ?? null, N && (F = !1);
|
|
959
|
+
}
|
|
960
|
+
return a((k) => ({ ...k, ...A })), F;
|
|
961
|
+
}
|
|
962
|
+
const R = e.validate?.[f], T = R ? R(b[f]) : null;
|
|
963
|
+
return a((A) => ({ ...A, [f]: T ?? null })), !T;
|
|
964
|
+
},
|
|
965
|
+
[e.validate]
|
|
966
|
+
), O = S(
|
|
967
|
+
(f) => (b) => {
|
|
968
|
+
b?.preventDefault && b.preventDefault(), w() && f(m.current, b);
|
|
969
|
+
},
|
|
970
|
+
[w]
|
|
971
|
+
), B = S(
|
|
972
|
+
(f) => {
|
|
973
|
+
const b = m.current;
|
|
974
|
+
return f ? typeof f == "string" ? b[f] : f.map((R) => b[R]) : b;
|
|
975
|
+
},
|
|
976
|
+
[]
|
|
977
|
+
), C = {
|
|
978
|
+
values: t,
|
|
979
|
+
errors: s,
|
|
980
|
+
touchedFields: o,
|
|
981
|
+
register: j,
|
|
982
|
+
setValue: x,
|
|
983
|
+
getValues: v,
|
|
984
|
+
setError: p,
|
|
985
|
+
clearError: c,
|
|
986
|
+
handleSubmit: O,
|
|
987
|
+
reset: _,
|
|
988
|
+
trigger: w,
|
|
989
|
+
watch: B,
|
|
990
|
+
control: void 0
|
|
991
|
+
};
|
|
992
|
+
return C.control = C, C;
|
|
993
|
+
}
|
|
994
|
+
function Qe(e, t) {
|
|
995
|
+
const n = t?.locale ?? "en", s = ae(
|
|
996
|
+
() => e.sections.flatMap((l) => l.fields).reduce((l, m) => (l[m.id] = m.defaultValue ?? "", l), {}),
|
|
997
|
+
// dto is expected to be a stable reference (defined outside renders)
|
|
998
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
999
|
+
[]
|
|
1000
|
+
), a = z(s), o = ae(
|
|
1001
|
+
() => e.sections.flatMap((l) => l.fields).filter((l) => l.validations).reduce(
|
|
1002
|
+
(l, m) => (l[m.id] = (j) => {
|
|
1003
|
+
const x = {
|
|
1004
|
+
...a.current,
|
|
1005
|
+
[m.id]: j
|
|
1006
|
+
};
|
|
1007
|
+
return M(
|
|
1008
|
+
e,
|
|
1009
|
+
x,
|
|
1010
|
+
m.id,
|
|
1011
|
+
n
|
|
1012
|
+
)[0] ?? null;
|
|
1013
|
+
}, l),
|
|
1014
|
+
{}
|
|
1015
|
+
),
|
|
1016
|
+
// locale changes rebuild validate fns; dto is assumed stable
|
|
1017
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1018
|
+
[n]
|
|
1019
|
+
), u = Ge({
|
|
1020
|
+
defaultValues: s,
|
|
1021
|
+
validate: o
|
|
1022
|
+
});
|
|
1023
|
+
return a.current = u.values, u;
|
|
1024
|
+
}
|
|
1025
|
+
function Ke(e) {
|
|
1026
|
+
const { values: t, setValue: n } = ve(), s = e.name, a = t[s] ?? [];
|
|
1027
|
+
return { fields: a, append: (x) => n(s, [...a, x]), prepend: (x) => n(s, [x, ...a]), remove: (x) => n(
|
|
1028
|
+
s,
|
|
1029
|
+
a.filter((p, c) => c !== x)
|
|
1030
|
+
), swap: (x, p) => {
|
|
1031
|
+
const c = [...a];
|
|
1032
|
+
[c[x], c[p]] = [c[p], c[x]], n(s, c);
|
|
1033
|
+
}, insert: (x, p) => {
|
|
1034
|
+
const c = [...a];
|
|
1035
|
+
c.splice(x, 0, p), n(s, c);
|
|
1036
|
+
} };
|
|
1037
|
+
}
|
|
1038
|
+
function er(e) {
|
|
1039
|
+
const { values: t } = ve();
|
|
1040
|
+
return Array.isArray(e) ? e.map((n) => t[n]) : t[e];
|
|
1041
|
+
}
|
|
1042
|
+
function rr({
|
|
1043
|
+
value: e,
|
|
1044
|
+
children: t
|
|
1045
|
+
}) {
|
|
1046
|
+
return /* @__PURE__ */ i.jsx(Q.Provider, { value: e, children: t });
|
|
1047
|
+
}
|
|
849
1048
|
export {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
1049
|
+
Ie as AutoCompleteField,
|
|
1050
|
+
Ve as CheckBoxInput,
|
|
1051
|
+
ze as Field,
|
|
1052
|
+
Ue as FormBuilder,
|
|
1053
|
+
rr as FormProvider,
|
|
1054
|
+
Le as MultiAutoCompleteField,
|
|
1055
|
+
De as RadioInput,
|
|
1056
|
+
Ye as Section,
|
|
1057
|
+
Ce as SelectInput,
|
|
1058
|
+
Ne as TextAreaInput,
|
|
1059
|
+
Pe as TextInput,
|
|
1060
|
+
Ke as useFieldArray,
|
|
1061
|
+
Ge as useForm,
|
|
1062
|
+
Me as useFormBuilder,
|
|
1063
|
+
Ze as useFormBuilderController,
|
|
1064
|
+
ve as useFormContext,
|
|
1065
|
+
Qe as useFormDTO,
|
|
1066
|
+
Be as useOptionalFormContext,
|
|
1067
|
+
er as useWatch,
|
|
1068
|
+
he as validateAll,
|
|
1069
|
+
M as validateField,
|
|
1070
|
+
He as validationRules
|
|
864
1071
|
};
|