react-form-dto 1.0.3 → 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.
@@ -1,49 +1,49 @@
1
- import X, { useState as M, useImperativeHandle as de } from "react";
2
- import { FormControl as H, InputLabel as fe, Select as be, MenuItem as he, Typography as T, TextField as k, FormControlLabel as Z, Checkbox as xe, FormHelperText as Q, Autocomplete as K, FormLabel as ve, RadioGroup as ge, Radio as Ee, Box as ye, Grid as B } from "@mui/material";
3
- var S = { exports: {} }, _ = {};
4
- var U;
5
- function je() {
6
- if (U) return _;
7
- U = 1;
8
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
9
- function n(a, o, s) {
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 (s !== void 0 && (u = "" + s), o.key !== void 0 && (u = "" + o.key), "key" in o) {
12
- s = {};
13
- for (var c in o)
14
- c !== "key" && (s[c] = o[c]);
15
- } else s = o;
16
- return o = s.ref, {
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: a,
18
+ type: s,
19
19
  key: u,
20
- ref: o !== void 0 ? o : null,
21
- props: s
20
+ ref: a !== void 0 ? a : null,
21
+ props: o
22
22
  };
23
23
  }
24
- return _.Fragment = t, _.jsx = n, _.jsxs = n, _;
24
+ return P.Fragment = t, P.jsx = n, P.jsxs = n, P;
25
25
  }
26
- var R = {};
27
- var G;
28
- function _e() {
29
- return G || (G = 1, process.env.NODE_ENV !== "production" && (function() {
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 === ce ? null : r.displayName || r.name || null;
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 te:
38
+ case C:
39
39
  return "Profiler";
40
- case re:
40
+ case B:
41
41
  return "StrictMode";
42
- case oe:
42
+ case T:
43
43
  return "Suspense";
44
- case ue:
44
+ case A:
45
45
  return "SuspenseList";
46
- case ie:
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 ae:
55
+ case b:
56
56
  return r.displayName || "Context";
57
- case ne:
57
+ case f:
58
58
  return (r._context.displayName || "Context") + ".Consumer";
59
- case se:
60
- var i = r.render;
61
- return r = r.displayName, r || (r = i.displayName || i.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), 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
- i = r._payload, r = r._init;
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(i));
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 i = !1;
79
+ var d = !1;
80
80
  } catch {
81
- i = !0;
81
+ d = !0;
82
82
  }
83
- if (i) {
84
- i = console;
85
- var m = i.error, p = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
86
- return m.call(
87
- i,
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
- p
89
+ g
90
90
  ), t(r);
91
91
  }
92
92
  }
93
- function a(r) {
93
+ function s(r) {
94
94
  if (r === O) return "<>";
95
- if (typeof r == "object" && r !== null && r.$$typeof === F)
95
+ if (typeof r == "object" && r !== null && r.$$typeof === k)
96
96
  return "<...>";
97
97
  try {
98
- var i = e(r);
99
- return i ? "<" + i + ">" : "<...>";
98
+ var d = e(r);
99
+ return d ? "<" + d + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function o() {
105
- var r = P.A;
104
+ function a() {
105
+ var r = G.A;
106
106
  return r === null ? null : r.getOwner();
107
107
  }
108
- function s() {
108
+ function o() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
111
  function u(r) {
112
- if (D.call(r, "key")) {
113
- var i = Object.getOwnPropertyDescriptor(r, "key").get;
114
- if (i && i.isReactWarning) return !1;
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 c(r, i) {
119
- function m() {
120
- q || (q = !0, console.error(
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
- i
122
+ d
123
123
  ));
124
124
  }
125
- m.isReactWarning = !0, Object.defineProperty(r, "key", {
126
- get: m,
125
+ h.isReactWarning = !0, Object.defineProperty(r, "key", {
126
+ get: h,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function h() {
130
+ function m() {
131
131
  var r = e(this.type);
132
- return z[r] || (z[r] = !0, console.error(
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 x(r, i, m, p, A, I) {
137
- var d = m.ref;
136
+ function j(r, d, h, g, D, X) {
137
+ var E = h.ref;
138
138
  return r = {
139
- $$typeof: v,
139
+ $$typeof: _,
140
140
  type: r,
141
- key: i,
142
- props: m,
143
- _owner: p
144
- }, (d !== void 0 ? d : null) !== null ? Object.defineProperty(r, "ref", {
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: h
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: A
161
+ value: D
162
162
  }), Object.defineProperty(r, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: I
166
+ value: X
167
167
  }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
168
168
  }
169
- function E(r, i, m, p, A, I) {
170
- var d = i.children;
171
- if (d !== void 0)
172
- if (p)
173
- if (me(d)) {
174
- for (p = 0; p < d.length; p++)
175
- y(d[p]);
176
- Object.freeze && Object.freeze(d);
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 y(d);
182
- if (D.call(i, "key")) {
183
- d = e(r);
184
- var j = Object.keys(i).filter(function(pe) {
185
- return pe !== "key";
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
- p = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", V[d + p] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
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
- p,
195
- d,
196
- j,
197
- d
198
- ), V[d + p] = !0);
194
+ g,
195
+ E,
196
+ $,
197
+ E
198
+ ), se[E + g] = !0);
199
199
  }
200
- if (d = null, m !== void 0 && (n(m), d = "" + m), u(i) && (n(i.key), d = "" + i.key), "key" in i) {
201
- m = {};
202
- for (var L in i)
203
- L !== "key" && (m[L] = i[L]);
204
- } else m = i;
205
- return d && c(
206
- m,
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
- ), x(
208
+ ), j(
209
209
  r,
210
- d,
211
- m,
212
- o(),
213
- A,
214
- I
210
+ E,
211
+ h,
212
+ a(),
213
+ D,
214
+ X
215
215
  );
216
216
  }
217
- function y(r) {
218
- g(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === F && (r._payload.status === "fulfilled" ? g(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
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 g(r) {
221
- return typeof r == "object" && r !== null && r.$$typeof === v;
220
+ function c(r) {
221
+ return typeof r == "object" && r !== null && r.$$typeof === _;
222
222
  }
223
- var b = X, v = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), re = Symbol.for("react.strict_mode"), te = Symbol.for("react.profiler"), ne = Symbol.for("react.consumer"), ae = Symbol.for("react.context"), se = Symbol.for("react.forward_ref"), oe = Symbol.for("react.suspense"), ue = Symbol.for("react.suspense_list"), le = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), ce = Symbol.for("react.client.reference"), P = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, me = Array.isArray, C = console.createTask ? console.createTask : function() {
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
- b = {
226
+ v = {
227
227
  react_stack_bottom_frame: function(r) {
228
228
  return r();
229
229
  }
230
230
  };
231
- var q, z = {}, Y = b.react_stack_bottom_frame.bind(
232
- b,
233
- s
234
- )(), W = C(a(s)), V = {};
235
- R.Fragment = O, R.jsx = function(r, i, m) {
236
- var p = 1e4 > P.recentlyCreatedOwnerStacks++;
237
- return E(
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
- i,
240
- m,
239
+ d,
240
+ h,
241
241
  !1,
242
- p ? Error("react-stack-top-frame") : Y,
243
- p ? C(a(r)) : W
242
+ g ? Error("react-stack-top-frame") : te,
243
+ g ? J(s(r)) : ne
244
244
  );
245
- }, R.jsxs = function(r, i, m) {
246
- var p = 1e4 > P.recentlyCreatedOwnerStacks++;
247
- return E(
245
+ }, V.jsxs = function(r, d, h) {
246
+ var g = 1e4 > G.recentlyCreatedOwnerStacks++;
247
+ return x(
248
248
  r,
249
- i,
250
- m,
249
+ d,
250
+ h,
251
251
  !0,
252
- p ? Error("react-stack-top-frame") : Y,
253
- p ? C(a(r)) : W
252
+ g ? Error("react-stack-top-frame") : te,
253
+ g ? J(s(r)) : ne
254
254
  );
255
255
  };
256
- })()), R;
256
+ })()), V;
257
257
  }
258
- var J;
259
- function Re() {
260
- return J || (J = 1, process.env.NODE_ENV === "production" ? S.exports = je() : S.exports = _e()), S.exports;
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 l = Re();
263
- function f(e, t = "en") {
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 $(e, t = "en") {
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: f(n.label, t)
269
+ label: y(n.label, t)
270
270
  }) : [];
271
271
  }
272
- function Te({
272
+ function Ce({
273
273
  field: e,
274
274
  value: t,
275
275
  onChange: n,
276
- error: a,
277
- locale: o = "en"
276
+ error: s,
277
+ locale: a = "en"
278
278
  }) {
279
- const s = $(e.options || [], o);
280
- return /* @__PURE__ */ l.jsxs(H, { fullWidth: !0, children: [
281
- /* @__PURE__ */ l.jsx(fe, { id: `${e.id}-label`, children: f(e.label, o) }),
282
- /* @__PURE__ */ l.jsx(
283
- be,
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: f(e.label, o),
291
- error: !!a,
292
- children: s?.map((u) => /* @__PURE__ */ l.jsx(he, { value: u.value, children: u.label }, u.label))
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
- a && /* @__PURE__ */ l.jsx(T, { variant: "caption", color: "error", children: a })
295
+ s && /* @__PURE__ */ i.jsx(L, { variant: "caption", color: "error", children: s })
296
296
  ] });
297
297
  }
298
- function Ae({
298
+ function Pe({
299
299
  field: e,
300
300
  value: t,
301
301
  onChange: n,
302
- error: a,
303
- locale: o
302
+ error: s,
303
+ locale: a
304
304
  }) {
305
- return console.log("error", a), /* @__PURE__ */ l.jsx(
306
- k,
305
+ return console.log("error", s), /* @__PURE__ */ i.jsx(
306
+ W,
307
307
  {
308
308
  fullWidth: !0,
309
- label: f(e.label, o),
310
- placeholder: f(e.placeholder || "", o),
309
+ label: y(e.label, a),
310
+ placeholder: y(e.placeholder || "", a),
311
311
  value: t || "",
312
312
  name: e.id,
313
- onChange: (s) => n(s.target.value),
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: !!a,
322
- helperText: a
321
+ error: !!s,
322
+ helperText: s
323
323
  }
324
324
  );
325
325
  }
326
- function Se({
326
+ function Ve({
327
327
  field: e,
328
328
  value: t,
329
329
  onChange: n,
330
- error: a,
331
- locale: o
330
+ error: s,
331
+ locale: a
332
332
  }) {
333
- return /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
334
- /* @__PURE__ */ l.jsx(
335
- Z,
333
+ return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
334
+ /* @__PURE__ */ i.jsx(
335
+ me,
336
336
  {
337
337
  name: e.id,
338
- control: /* @__PURE__ */ l.jsx(
339
- xe,
338
+ control: /* @__PURE__ */ i.jsx(
339
+ Te,
340
340
  {
341
341
  checked: !!t,
342
- onChange: (s) => n(s.target.checked),
342
+ onChange: (o) => n(o.target.checked),
343
343
  disabled: e.disabled
344
344
  }
345
345
  ),
346
- label: f(e.label, o)
346
+ label: y(e.label, a)
347
347
  }
348
348
  ),
349
- a && /* @__PURE__ */ l.jsx(Q, { children: a })
349
+ s && /* @__PURE__ */ i.jsx(pe, { children: s })
350
350
  ] });
351
351
  }
352
- const ke = ({
352
+ const Ie = ({
353
353
  field: e,
354
354
  value: t,
355
355
  onChange: n,
356
- error: a,
357
- locale: o
356
+ error: s,
357
+ locale: a
358
358
  }) => {
359
- const s = $(e.options || [], o);
360
- return /* @__PURE__ */ l.jsx(
361
- K,
359
+ const o = Y(e.options || [], a);
360
+ return /* @__PURE__ */ i.jsx(
361
+ be,
362
362
  {
363
363
  fullWidth: !0,
364
- options: s || [],
364
+ options: o || [],
365
365
  value: t || null,
366
- onChange: (u, c) => n(c),
367
- renderInput: (u) => /* @__PURE__ */ l.jsx(
368
- k,
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: f(e.label, o),
373
- placeholder: f(
372
+ label: y(e.label, a),
373
+ placeholder: y(
374
374
  e.placeholder || "",
375
- o
375
+ a
376
376
  ),
377
377
  disabled: e.disabled,
378
- error: !!a,
379
- helperText: a
378
+ error: !!s,
379
+ helperText: s
380
380
  }
381
381
  )
382
382
  }
383
383
  );
384
- }, $e = ({
384
+ }, Le = ({
385
385
  field: e,
386
386
  value: t,
387
387
  onChange: n,
388
- error: a,
389
- locale: o
388
+ error: s,
389
+ locale: a
390
390
  }) => {
391
- const s = $(e.options || [], o);
392
- return /* @__PURE__ */ l.jsx(
393
- K,
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: s || [],
397
+ options: o || [],
398
398
  value: t || [],
399
- onChange: (u, c) => n(c),
400
- renderInput: (u) => /* @__PURE__ */ l.jsx(
401
- k,
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: f(e.label, o),
406
- placeholder: f(
405
+ label: y(e.label, a),
406
+ placeholder: y(
407
407
  e.placeholder || "",
408
- o
408
+ a
409
409
  ),
410
410
  disabled: e.disabled,
411
- error: !!a,
412
- helperText: a
411
+ error: !!s,
412
+ helperText: s
413
413
  }
414
414
  )
415
415
  }
416
416
  );
417
- }, we = ({
417
+ }, Ne = ({
418
418
  field: e,
419
419
  value: t,
420
420
  onChange: n,
421
- error: a,
422
- locale: o = "en"
423
- }) => /* @__PURE__ */ l.jsx(
424
- k,
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: f(e.label, o),
430
- placeholder: f(e.placeholder || "", o),
429
+ label: y(e.label, a),
430
+ placeholder: y(e.placeholder || "", a),
431
431
  value: t || "",
432
- onChange: (s) => n(s.target.value),
432
+ onChange: (o) => n(o.target.value),
433
433
  required: !!e.validations?.required,
434
434
  disabled: e.disabled,
435
- error: !!a,
436
- helperText: a
435
+ error: !!s,
436
+ helperText: s
437
437
  }
438
- ), Oe = ({
438
+ ), De = ({
439
439
  field: e,
440
440
  value: t,
441
441
  onChange: n,
442
- error: a,
443
- locale: o = "en"
442
+ error: s,
443
+ locale: a = "en"
444
444
  }) => {
445
- const s = $(e.options || [], o);
446
- return /* @__PURE__ */ l.jsxs(H, { component: "fieldset", fullWidth: !0, error: !!a, children: [
447
- /* @__PURE__ */ l.jsxs(ve, { component: "legend", children: [
448
- f(e.label, o),
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__ */ l.jsx(
452
- ge,
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: (s || []).map((u) => /* @__PURE__ */ l.jsx(
458
- Z,
457
+ children: (o || []).map((u) => /* @__PURE__ */ i.jsx(
458
+ me,
459
459
  {
460
460
  value: u.value,
461
- control: /* @__PURE__ */ l.jsx(Ee, {}),
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
- a && /* @__PURE__ */ l.jsx(Q, { children: a })
469
+ s && /* @__PURE__ */ i.jsx(pe, { children: s })
470
470
  ] });
471
- }, Fe = ({
471
+ }, qe = ({
472
472
  field: e,
473
473
  value: t,
474
474
  onChange: n,
475
- error: a,
476
- locale: o = "en"
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__ */ l.jsx(
485
- Ae,
484
+ return /* @__PURE__ */ i.jsx(
485
+ Pe,
486
486
  {
487
487
  field: e,
488
488
  value: t,
489
489
  onChange: n,
490
- error: a,
491
- locale: o
490
+ error: s,
491
+ locale: a
492
492
  }
493
493
  );
494
494
  case "select":
495
- return /* @__PURE__ */ l.jsx(
496
- Te,
495
+ return /* @__PURE__ */ i.jsx(
496
+ Ce,
497
497
  {
498
498
  field: e,
499
499
  value: t,
500
500
  onChange: n,
501
- error: a,
502
- locale: o
501
+ error: s,
502
+ locale: a
503
503
  }
504
504
  );
505
505
  case "autocomplete":
506
- return /* @__PURE__ */ l.jsx(
507
- ke,
506
+ return /* @__PURE__ */ i.jsx(
507
+ Ie,
508
508
  {
509
509
  field: e,
510
510
  value: t,
511
511
  onChange: n,
512
- error: a,
513
- locale: o
512
+ error: s,
513
+ locale: a
514
514
  }
515
515
  );
516
516
  case "multi-autocomplete":
517
- return /* @__PURE__ */ l.jsx(
518
- $e,
517
+ return /* @__PURE__ */ i.jsx(
518
+ Le,
519
519
  {
520
520
  field: e,
521
521
  value: t,
522
522
  onChange: n,
523
- error: a,
524
- locale: o
523
+ error: s,
524
+ locale: a
525
525
  }
526
526
  );
527
527
  case "checkbox":
528
- return /* @__PURE__ */ l.jsx(
529
- Se,
528
+ return /* @__PURE__ */ i.jsx(
529
+ Ve,
530
530
  {
531
531
  field: e,
532
532
  value: t,
533
533
  onChange: n,
534
- error: a,
535
- locale: o
534
+ error: s,
535
+ locale: a
536
536
  }
537
537
  );
538
538
  case "textarea":
539
- return /* @__PURE__ */ l.jsx(
540
- we,
539
+ return /* @__PURE__ */ i.jsx(
540
+ Ne,
541
541
  {
542
542
  field: e,
543
543
  value: t,
544
544
  onChange: n,
545
- error: a,
546
- locale: o
545
+ error: s,
546
+ locale: a
547
547
  }
548
548
  );
549
549
  case "radio":
550
- return /* @__PURE__ */ l.jsx(
551
- Oe,
550
+ return /* @__PURE__ */ i.jsx(
551
+ De,
552
552
  {
553
553
  field: e,
554
554
  value: t,
555
555
  onChange: n,
556
- error: a,
557
- locale: o
556
+ error: s,
557
+ locale: a
558
558
  }
559
559
  );
560
560
  default:
561
- return /* @__PURE__ */ l.jsxs("span", { children: [
561
+ return /* @__PURE__ */ i.jsxs("span", { children: [
562
562
  "Unsupported field type: ",
563
563
  e.type
564
564
  ] });
565
565
  }
566
- }, Pe = ({
566
+ }, ze = ({
567
567
  field: e,
568
568
  value: t,
569
569
  onChange: n,
570
- error: a,
571
- renderers: o = {},
572
- locale: s = "en"
570
+ error: s,
571
+ renderers: a = {},
572
+ locale: o = "en"
573
573
  }) => {
574
- const u = o[e.type] || Fe;
575
- return /* @__PURE__ */ l.jsx(
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: a,
582
- locale: s
581
+ error: s,
582
+ locale: o
583
583
  }
584
584
  );
585
585
  };
586
- function Ce(e) {
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 ze = {
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
- }, Ie = (e, t, n = "en") => {
681
- const a = {};
682
- return e.sections.forEach((o) => {
683
- o.fields.forEach((s) => {
684
- const u = ee(e, t, s.id);
685
- u.length > 0 && (a[s.id] = u);
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
- }), a;
688
- }, ee = (e, t, n, a = "en") => {
689
- const o = e.sections.flatMap((x) => x.fields).find((x) => x.id === n);
690
- if (!o) return [];
691
- const s = o.validations || {}, u = t[n], c = [], h = f(o.label, a);
692
- if (s.required && (u == null || u === "") && c.push(
693
- typeof s.required == "string" ? s.required : `${h} is required`
694
- ), s.min !== void 0 && typeof u == "number" && u < s.min && c.push(`${h} must be at least ${s.min}`), s.max !== void 0 && typeof u == "number" && u > s.max && c.push(`${h} must be at most ${s.max}`), s.minLength !== void 0 && typeof u == "string" && u.length < s.minLength && c.push(`${h} must be at least ${s.minLength} characters`), s.maxLength !== void 0 && typeof u == "string" && u.length > s.maxLength && c.push(`${h} must be at most ${s.maxLength} characters`), s.pattern && typeof u == "string" && !s.pattern.test(u) && c.push(`${h} is invalid`), s.validate) {
695
- const x = s.validate(u);
696
- x && c.push(f(x, a));
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 c;
698
+ return l;
699
699
  };
700
- function N(e, t) {
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((a) => a.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((a) => e.in.includes(a)) : !1 : e.in.includes(n) : e.notIn !== void 0 ? Array.isArray(n) ? n.every((a) => !e.notIn.includes(a)) : !e.notIn.includes(n) : e.greaterThan !== void 0 ? n > e.greaterThan : e.lessThan !== void 0 ? n < e.lessThan : !0;
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
- (a) => N(a, t)
710
+ (s) => Z(s, t)
711
711
  );
712
712
  if (e.operator === "OR")
713
713
  return e.conditions.some(
714
- (n) => N(n, t)
714
+ (n) => Z(n, t)
715
715
  );
716
716
  }
717
717
  return !1;
718
718
  }
719
- const Le = ({
719
+ const Ye = ({
720
720
  section: e,
721
721
  values: t,
722
722
  onChange: n,
723
- renderers: a,
724
- validateField: o,
725
- locale: s = "en"
726
- }) => /* @__PURE__ */ l.jsxs(ye, { mb: 2, children: [
727
- e.heading && /* @__PURE__ */ l.jsx(
728
- T,
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: f(e.heading, s)
736
+ children: y(e.heading, o)
737
737
  }
738
738
  ),
739
- e.description && /* @__PURE__ */ l.jsx(
740
- T,
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: f(e.description, s)
748
+ children: y(e.description, o)
749
749
  }
750
750
  ),
751
- /* @__PURE__ */ l.jsx(B, { container: !0, spacing: 2, children: e.fields.map(
752
- (u) => N(u.visibleWhen, t) && /* @__PURE__ */ l.jsx(
753
- B,
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: Ce(u.layout?.cols),
756
- children: /* @__PURE__ */ l.jsx(
757
- Pe,
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: (c) => n(u.id, c),
762
- renderers: a,
763
- error: o(u.id)?.join(","),
764
- locale: s
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,45 +769,74 @@ const Le = ({
769
769
  )
770
770
  ) })
771
771
  ] });
772
- function Ne(e, t = "en", n) {
773
- const [a, o] = M({}), [s, u] = M({});
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: a,
776
+ values: s,
777
777
  /** Function to update a field value */
778
- handleChange: (g, b) => {
779
- if (o((v) => ({ ...v, [g]: b })), u((v) => ({ ...v, [g]: null })), n) {
780
- let v = b;
781
- Array.isArray(b) ? v = b.map((w) => w.value ?? "") : typeof b == "object" && b !== null && (v = b.value ?? ""), n(g, v);
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: () => Ie(e, a, t),
785
+ validateAll: () => he(e, s, t),
786
786
  /** Function to get all current form values */
787
- getValues: () => a,
787
+ getValues: () => s,
788
788
  /** Function to get all current form errors */
789
- getErrors: () => s,
789
+ getErrors: () => o,
790
790
  /** Function to validate a specific field */
791
- validateField: (g) => ee(e, a, g, t)
791
+ validateField: (c) => M(e, s, c, t)
792
792
  };
793
793
  }
794
- const Ye = X.forwardRef(({ dto: e, renderers: t, locale: n = "en", handleChangeCallback: a }, o) => {
795
- const {
796
- values: s,
797
- handleChange: u,
798
- getValues: c,
799
- getErrors: h,
800
- validateAll: x,
801
- validateField: E
802
- } = Ne(e, n, a);
803
- return de(o, () => ({
804
- getValues: c,
805
- getErrors: h,
806
- validateAll: x,
807
- validateField: E
808
- })), /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
809
- e.title && /* @__PURE__ */ l.jsx(
810
- T,
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,
811
840
  {
812
841
  variant: "h5",
813
842
  color: "black",
@@ -816,11 +845,11 @@ const Ye = X.forwardRef(({ dto: e, renderers: t, locale: n = "en", handleChangeC
816
845
  fontWeight: "bold"
817
846
  },
818
847
  gutterBottom: !0,
819
- children: f(e.title, n)
848
+ children: y(e.title, n)
820
849
  }
821
850
  ),
822
- e.description && /* @__PURE__ */ l.jsx(
823
- T,
851
+ e.description && /* @__PURE__ */ i.jsx(
852
+ L,
824
853
  {
825
854
  component: "p",
826
855
  sx: {
@@ -828,36 +857,215 @@ const Ye = X.forwardRef(({ dto: e, renderers: t, locale: n = "en", handleChangeC
828
857
  },
829
858
  color: "textSecondary",
830
859
  gutterBottom: !0,
831
- children: f(e.description, n)
860
+ children: y(e.description, n)
832
861
  }
833
862
  ),
834
- e.sections.map((y) => /* @__PURE__ */ l.jsx(
835
- Le,
863
+ e.sections.map((p) => /* @__PURE__ */ i.jsx(
864
+ Ye,
836
865
  {
837
- section: y,
838
- values: s,
839
- onChange: u,
866
+ section: p,
867
+ values: m,
868
+ onChange: j,
840
869
  renderers: t,
841
- validateField: E,
870
+ validateField: x,
842
871
  locale: n
843
872
  },
844
- y.id
873
+ p.id
845
874
  ))
846
875
  ] });
847
- });
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
+ }
848
1048
  export {
849
- ke as AutoCompleteField,
850
- Se as CheckBoxInput,
851
- Pe as Field,
852
- Ye as FormBuilder,
853
- $e as MultiAutoCompleteField,
854
- Oe as RadioInput,
855
- Le as Section,
856
- Te as SelectInput,
857
- we as TextAreaInput,
858
- Ae as TextInput,
859
- Ne as useFormBuilder,
860
- Ie as validateAll,
861
- ee as validateField,
862
- ze as validationRules
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
863
1071
  };