@harnessio/forms 0.11.0 → 0.11.2

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/index.js CHANGED
@@ -1,13 +1,13 @@
1
- var Ce = Object.defineProperty;
2
- var Ie = (r, e, n) => e in r ? Ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var D = (r, e, n) => Ie(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { isEmpty as k, set as E, get as T, forOwn as me, isArray as V, isObject as he, merge as M, isUndefined as B, cloneDeep as H, unset as pe, pick as we, isNull as ye, omitBy as ge, isNil as je, isString as Oe, capitalize as Ve } from "lodash-es";
5
- import xe, { createContext as Fe, useContext as Pe, Component as qe, memo as Ae, useMemo as $, useRef as O, useEffect as C, useCallback as ke, forwardRef as Ne, Fragment as De } from "react";
6
- import { useFormContext as Me, get as $e, useForm as Ze, FormProvider as Be, appendErrors as We, useController as Ue } from "react-hook-form";
7
- import { Controller as Wr, Form as Ur, FormProvider as Jr, get as Lr, set as Hr, useFieldArray as Kr, useForm as Gr, useFormContext as Qr, useFormState as Xr, useWatch as Yr } from "react-hook-form";
1
+ var Ie = Object.defineProperty;
2
+ var Oe = (r, e, n) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var D = (r, e, n) => Oe(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { isEmpty as k, set as S, get as T, forOwn as me, isArray as j, isObject as he, merge as M, isUndefined as B, cloneDeep as H, unset as ye, pick as we, isPlainObject as je, isNull as pe, omitBy as ge, isNil as Ve, isString as xe, capitalize as Fe } from "lodash-es";
5
+ import Pe, { createContext as qe, useContext as Ae, Component as ke, memo as Ne, useMemo as $, useRef as w, useEffect as O, useCallback as De, forwardRef as Me, Fragment as $e } from "react";
6
+ import { useFormContext as Ze, get as Be, useForm as We, FormProvider as Je, appendErrors as Ue, useController as Le } from "react-hook-form";
7
+ import { Controller as Ur, Form as Lr, FormProvider as Hr, get as Gr, set as Kr, useFieldArray as Qr, useForm as Xr, useFormContext as Yr, useFormState as zr, useWatch as et } from "react-hook-form";
8
8
  import * as d from "zod";
9
- import { toNestErrors as Je } from "@hookform/resolvers";
10
- class Le extends Error {
9
+ import { toNestErrors as He } from "@hookform/resolvers";
10
+ class Ge extends Error {
11
11
  constructor(e) {
12
12
  super(`Input component '${e}' is already registered.`);
13
13
  }
@@ -26,7 +26,7 @@ class be {
26
26
  */
27
27
  registerComponent(e) {
28
28
  if (!this.allowOverride && this.getComponent(e.internalType))
29
- throw new Le(e.internalType);
29
+ throw new Ge(e.internalType);
30
30
  this.componentBank.set(e.internalType, e);
31
31
  }
32
32
  getComponent(e) {
@@ -55,15 +55,15 @@ class be {
55
55
  }), e;
56
56
  }
57
57
  }
58
- var W = { exports: {} }, j = {};
58
+ var W = { exports: {} }, V = {};
59
59
  /*
60
60
  object-assign
61
61
  (c) Sindre Sorhus
62
62
  @license MIT
63
63
  */
64
- var U, oe;
65
- function He() {
66
- if (oe) return U;
64
+ var J, oe;
65
+ function Ke() {
66
+ if (oe) return J;
67
67
  oe = 1;
68
68
  var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
69
69
  function t(s) {
@@ -93,7 +93,7 @@ function He() {
93
93
  return !1;
94
94
  }
95
95
  }
96
- return U = a() ? Object.assign : function(s, o) {
96
+ return J = a() ? Object.assign : function(s, o) {
97
97
  for (var u, i = t(s), c, f = 1; f < arguments.length; f++) {
98
98
  u = Object(arguments[f]);
99
99
  for (var m in u)
@@ -105,7 +105,7 @@ function He() {
105
105
  }
106
106
  }
107
107
  return i;
108
- }, U;
108
+ }, J;
109
109
  }
110
110
  /** @license React v17.0.2
111
111
  * react-jsx-runtime.production.min.js
@@ -116,13 +116,13 @@ function He() {
116
116
  * LICENSE file in the root directory of this source tree.
117
117
  */
118
118
  var ue;
119
- function Ke() {
120
- if (ue) return j;
121
- ue = 1, He();
122
- var r = xe, e = 60103;
123
- if (j.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
119
+ function Qe() {
120
+ if (ue) return V;
121
+ ue = 1, Ke();
122
+ var r = Pe, e = 60103;
123
+ if (V.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
124
124
  var n = Symbol.for;
125
- e = n("react.element"), j.Fragment = n("react.fragment");
125
+ e = n("react.element"), V.Fragment = n("react.fragment");
126
126
  }
127
127
  var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, a = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
128
128
  function o(u, i, c) {
@@ -132,21 +132,21 @@ function Ke() {
132
132
  if (u && u.defaultProps) for (f in i = u.defaultProps, i) m[f] === void 0 && (m[f] = i[f]);
133
133
  return { $$typeof: e, type: u, key: l, ref: h, props: m, _owner: t.current };
134
134
  }
135
- return j.jsx = o, j.jsxs = o, j;
135
+ return V.jsx = o, V.jsxs = o, V;
136
136
  }
137
137
  var ie;
138
- function Ge() {
139
- return ie || (ie = 1, W.exports = Ke()), W.exports;
138
+ function Xe() {
139
+ return ie || (ie = 1, W.exports = Qe()), W.exports;
140
140
  }
141
- var p = Ge();
142
- const ve = Fe({});
143
- function Qe({
141
+ var y = Xe();
142
+ const ve = qe({});
143
+ function Ye({
144
144
  children: r,
145
145
  metadata: e,
146
146
  inputErrorHandler: n,
147
147
  readonly: t
148
148
  }) {
149
- return /* @__PURE__ */ p.jsx(
149
+ return /* @__PURE__ */ y.jsx(
150
150
  ve.Provider,
151
151
  {
152
152
  value: {
@@ -158,11 +158,11 @@ function Qe({
158
158
  }
159
159
  );
160
160
  }
161
- function Xe() {
162
- const r = Pe(ve);
161
+ function ze() {
162
+ const r = Ae(ve);
163
163
  return r || console.warn("useRootFormContext must be used within RootFormProvider"), r;
164
164
  }
165
- class Ye extends qe {
165
+ class er extends ke {
166
166
  constructor() {
167
167
  super(...arguments);
168
168
  D(this, "state", {
@@ -181,13 +181,13 @@ class Ye extends qe {
181
181
  (o = (s = this.props).inputErrorHandler) == null || o.call(s, a);
182
182
  }
183
183
  render() {
184
- return this.state.hasError ? /* @__PURE__ */ p.jsx(p.Fragment, {}) : this.props.children;
184
+ return this.state.hasError ? /* @__PURE__ */ y.jsx(y.Fragment, {}) : this.props.children;
185
185
  }
186
186
  }
187
187
  const ce = ({
188
188
  children: r,
189
189
  withoutWrapper: e = !1
190
- }) => e || !r ? r : /* @__PURE__ */ p.jsx("div", { children: r }), ze = Ae(function({
190
+ }) => e || !r ? r : /* @__PURE__ */ y.jsx("div", { children: r }), rr = Ne(function({
191
191
  path: e,
192
192
  factory: n,
193
193
  onUpdate: t,
@@ -197,19 +197,19 @@ const ce = ({
197
197
  withoutWrapper: u = !1
198
198
  }) {
199
199
  var Y, z, ee, re, te;
200
- const i = Me(), { formState: c } = i, { fixedValues: f = {} } = {}, { metadata: m, readonly: l, inputErrorHandler: h } = Xe(), g = n == null ? void 0 : n.getComponent(o.inputType), b = !!(o.isVisible || typeof o.disabled == "function" || typeof ((Y = o.validation) == null ? void 0 : Y.schema) == "function" || typeof ((z = o.warning) == null ? void 0 : z.schema) == "function"), R = !!((ee = o.warning) != null && ee.schema || (re = o.validation) != null && re.schema), v = b ? i.watch() : {}, I = R ? b ? $e(v, o.path) : i.watch(o.path) : void 0, w = $(() => {
201
- if (!b) return {};
202
- let F = v;
200
+ const i = Ze(), { formState: c } = i, { fixedValues: f = {} } = {}, { metadata: m, readonly: l, inputErrorHandler: h } = ze(), p = n == null ? void 0 : n.getComponent(o.inputType), g = !!(o.isVisible || typeof o.disabled == "function" || typeof ((Y = o.validation) == null ? void 0 : Y.schema) == "function" || typeof ((z = o.warning) == null ? void 0 : z.schema) == "function"), x = !!((ee = o.warning) != null && ee.schema || (re = o.validation) != null && re.schema), E = g ? i.watch() : {}, R = x ? g ? Be(E, o.path) : i.watch(o.path) : void 0, C = $(() => {
201
+ if (!g) return {};
202
+ let F = E;
203
203
  return f && Object.keys(f).forEach((N) => {
204
204
  const P = f[N];
205
- F = E(F, N, P);
205
+ F = S(F, N, P);
206
206
  }), F;
207
- }, [b, v, f]), y = !o.isVisible || o.isVisible(w, m), S = l || o.readonly, _ = typeof o.disabled == "function" ? o.disabled(w, m) : o.disabled, x = (te = o.warning) == null ? void 0 : te.schema, Q = $(() => {
207
+ }, [g, E, f]), I = !o.isVisible || o.isVisible(C, m), b = l || o.readonly, _ = typeof o.disabled == "function" ? o.disabled(C, m) : o.disabled, v = (te = o.warning) == null ? void 0 : te.schema, Q = $(() => {
208
208
  var se, ae;
209
- if (!y || typeof x > "u") return;
210
- const F = typeof x == "function" ? x(w) : x, { success: N, error: P } = F.safeParse(I), ne = (ae = (se = P == null ? void 0 : P.errors) == null ? void 0 : se[0]) == null ? void 0 : ae.message;
209
+ if (!I || typeof v > "u") return;
210
+ const F = typeof v == "function" ? v(C) : v, { success: N, error: P } = F.safeParse(R), ne = (ae = (se = P == null ? void 0 : P.errors) == null ? void 0 : se[0]) == null ? void 0 : ae.message;
211
211
  return !N && ne ? ne : void 0;
212
- }, [o.path, I, x, y]), X = $(
212
+ }, [o.path, R, v, I]), X = $(
213
213
  () => ({
214
214
  path: e,
215
215
  key: e,
@@ -217,24 +217,24 @@ const ce = ({
217
217
  onUpdate: t,
218
218
  onChange: a,
219
219
  factory: n,
220
- readonly: S,
220
+ readonly: b,
221
221
  input: o,
222
222
  disabled: _,
223
223
  warning: Q
224
224
  }),
225
- [n, s, o, a, t, e, S, c.errors, _, Q]
226
- ), Se = $(() => y ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
225
+ [n, s, o, a, t, e, b, c.errors, _, Q]
226
+ ), Ce = $(() => I ? /* @__PURE__ */ y.jsxs(y.Fragment, { children: [
227
227
  o.before ? o.before : null,
228
- /* @__PURE__ */ p.jsx(Ye, { path: e, inputType: o.inputType, inputErrorHandler: h, children: g == null ? void 0 : g.renderComponent(X) }),
228
+ /* @__PURE__ */ y.jsx(er, { path: e, inputType: o.inputType, inputErrorHandler: h, children: p == null ? void 0 : p.renderComponent(X) }),
229
229
  o.after ? o.after : null
230
- ] }) : null, [y, o.before, o.inputType, o.after, e, g, X, c.errors]);
231
- return g ? /* @__PURE__ */ p.jsx(ce, { withoutWrapper: u, children: Se }) : /* @__PURE__ */ p.jsx(ce, { withoutWrapper: u, children: /* @__PURE__ */ p.jsxs("p", { children: [
230
+ ] }) : null, [I, o.before, o.inputType, o.after, e, p, X, c.errors]);
231
+ return p ? /* @__PURE__ */ y.jsx(ce, { withoutWrapper: u, children: Ce }) : /* @__PURE__ */ y.jsx(ce, { withoutWrapper: u, children: /* @__PURE__ */ y.jsxs("p", { children: [
232
232
  "Input component not found (internal type: ",
233
233
  o.inputType,
234
234
  ")"
235
235
  ] }) });
236
236
  });
237
- class Er {
237
+ class Tr {
238
238
  getType() {
239
239
  return this.internalType;
240
240
  }
@@ -255,7 +255,7 @@ function fe() {
255
255
  function le() {
256
256
  return typeof window < "u" && "cancelIdleCallback" in window ? window.cancelIdleCallback : clearTimeout;
257
257
  }
258
- function Tr(r) {
258
+ function _r(r) {
259
259
  const {
260
260
  mode: e = "onSubmit",
261
261
  resolver: n,
@@ -274,17 +274,17 @@ function Tr(r) {
274
274
  // fixedValues
275
275
  autoFocusPath: m,
276
276
  readonly: l
277
- } = r, h = Ze({
277
+ } = r, h = We({
278
278
  mode: e,
279
279
  reValidateMode: "onChange",
280
280
  defaultValues: t,
281
281
  shouldFocusError: a,
282
282
  resolver: n
283
- }), g = O(!1);
284
- C(() => {
285
- h.reset(t, {});
286
- }, [h.reset, t]), C(() => {
287
- const y = fe(), S = le(), _ = y(() => {
283
+ }), p = w(!1), g = w(JSON.stringify(t ?? {}));
284
+ O(() => {
285
+ g.current = JSON.stringify(t ?? {}), h.reset(t, {});
286
+ }, [h.reset, t]), O(() => {
287
+ const b = fe(), _ = le(), v = b(() => {
288
288
  h.reset({}, {
289
289
  keepErrors: !0,
290
290
  keepDirty: !0,
@@ -298,79 +298,79 @@ function Tr(r) {
298
298
  keepSubmitCount: !0
299
299
  });
300
300
  });
301
- return () => S(_);
301
+ return () => _(v);
302
302
  }, []);
303
- const { handleSubmit: b } = h, R = O(s);
304
- C(() => {
305
- R.current = s;
303
+ const { handleSubmit: x } = h, E = w(s);
304
+ O(() => {
305
+ E.current = s;
306
306
  }, [s]);
307
- const v = O(o);
308
- C(() => {
309
- v.current = o;
307
+ const R = w(o);
308
+ O(() => {
309
+ R.current = o;
310
310
  }, [o]);
311
- const I = O(!1);
312
- C(() => {
313
- const y = h.watch((S) => {
314
- var _;
315
- I.current || ((_ = R.current) == null || _.call(R, { ...S }), g.current === !0 && (I.current = !0, h.trigger().finally(() => {
316
- I.current = !1;
311
+ const C = w(!1);
312
+ O(() => {
313
+ const b = h.watch((_) => {
314
+ var v;
315
+ C.current || JSON.stringify(_ ?? {}) !== g.current && ((v = E.current) == null || v.call(E, { ..._ }), p.current === !0 && (C.current = !0, h.trigger().finally(() => {
316
+ C.current = !1;
317
317
  })));
318
318
  });
319
319
  return () => {
320
- y.unsubscribe();
320
+ b.unsubscribe();
321
321
  };
322
322
  }, [h]);
323
- const w = O(!0);
324
- return C(() => {
325
- var y;
326
- if (w.current) {
327
- w.current = !1;
323
+ const I = w(!0);
324
+ return O(() => {
325
+ var b;
326
+ if (I.current) {
327
+ I.current = !1;
328
328
  return;
329
329
  }
330
- (y = v.current) == null || y.call(v, { isValid: h.formState.isValid, isSubmitted: h.formState.isSubmitted });
331
- }, [h.formState.isValid, h.formState.isSubmitted]), C(() => {
330
+ (b = R.current) == null || b.call(R, { isValid: h.formState.isValid, isSubmitted: h.formState.isSubmitted });
331
+ }, [h.formState.isValid, h.formState.isSubmitted]), O(() => {
332
332
  if (m) {
333
- const y = fe(), S = le(), _ = y(() => {
333
+ const b = fe(), _ = le(), v = b(() => {
334
334
  h.setFocus(m);
335
335
  });
336
- return () => S(_);
336
+ return () => _(v);
337
337
  }
338
- }, [h, m]), /* @__PURE__ */ p.jsx(Qe, { metadata: c, readonly: l, inputErrorHandler: i, children: /* @__PURE__ */ p.jsx(Be, { ...h, children: typeof f == "function" ? f({
338
+ }, [h, m]), /* @__PURE__ */ y.jsx(Ye, { metadata: c, readonly: l, inputErrorHandler: i, children: /* @__PURE__ */ y.jsx(Je, { ...h, children: typeof f == "function" ? f({
339
339
  ...h,
340
340
  submitForm: async () => {
341
- u && (g.current = !0, b((y) => {
342
- u(y);
341
+ u && (p.current = !0, x((b) => {
342
+ u(b);
343
343
  })());
344
344
  }
345
345
  }) : f }) });
346
346
  }
347
- const _r = (r) => {
347
+ const Rr = (r) => {
348
348
  const e = {}, n = (t) => {
349
349
  t.forEach((a) => {
350
350
  const { path: s, default: o, inputType: u, inputs: i } = a;
351
- (u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : T(e, s) === void 0 && E(e, s, o);
351
+ (u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : T(e, s) === void 0 && S(e, s, o);
352
352
  });
353
353
  };
354
354
  return Array.isArray(r.inputs) && n(r.inputs), e;
355
355
  };
356
- function Rr(r, e) {
356
+ function Cr(r, e) {
357
357
  const n = r.inputs.map((t) => {
358
- const a = er(e, t.path);
358
+ const a = tr(e, t.path);
359
359
  return a || t;
360
360
  });
361
361
  return { ...r, inputs: n };
362
362
  }
363
- function er(r, e) {
363
+ function tr(r, e) {
364
364
  return r.inputs.find((n) => n.path === e);
365
365
  }
366
- const Ee = "__temp_", Sr = (r) => Ee + r.split(".").join("__");
367
- function rr(r) {
366
+ const Ee = "__temp_", Ir = (r) => Ee + r.split(".").join("__");
367
+ function nr(r) {
368
368
  const e = { ...r };
369
369
  return me(e, (n, t) => {
370
370
  t.startsWith(Ee) && delete e[t];
371
371
  }), e;
372
372
  }
373
- const tr = "Required field";
373
+ const sr = "Required field";
374
374
  function q(r) {
375
375
  let e;
376
376
  if (typeof r == "string")
@@ -383,20 +383,20 @@ function q(r) {
383
383
  e = r;
384
384
  if (typeof e == "string")
385
385
  return e;
386
- if (V(e))
386
+ if (j(e))
387
387
  return q(e[0]);
388
388
  const n = e;
389
389
  return he(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
390
390
  }
391
- function nr(r, e, n) {
391
+ function ar(r, e, n) {
392
392
  let t = {};
393
393
  if (Z(t, r.inputs, e, n), n != null && n.prefix) {
394
394
  const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
395
- t = E({}, s, t);
395
+ t = S({}, s, t);
396
396
  }
397
397
  return d.object(A(t, e, n));
398
398
  }
399
- function sr(r, e, n) {
399
+ function or(r, e, n) {
400
400
  const t = Object.keys(r).filter((o) => /^\d+$/.test(o) && !o.startsWith("_")).map((o) => parseInt(o, 10)).sort((o, u) => o - u);
401
401
  if (t.length === 0) return null;
402
402
  const a = Math.max(...t), s = [];
@@ -422,50 +422,53 @@ function A(r, e, n) {
422
422
  /*...nestedSchemaObj*/
423
423
  } = r[a];
424
424
  if (f && !i && !c) {
425
- const l = sr(r[a], e, n);
425
+ const l = or(r[a], e, n);
426
426
  if (l) {
427
427
  t[a] = l;
428
428
  return;
429
429
  }
430
430
  }
431
431
  if (i && o && u) {
432
- const l = d.array(d.object(A(o, e, n))).optional(), h = de(m, u, e, n, l);
433
- t[a] = h;
432
+ const l = d.object(A(o, e, n)), h = d.union([
433
+ d.array(l).optional(),
434
+ Se(u, n)
435
+ ]), p = de(m, u, e, n, h);
436
+ t[a] = p;
434
437
  } else if (c && u) {
435
- const l = o != null && o.___array ? A({ ___array: o.___array }, e, n) : { ___array: d.any() }, h = ar(l, u, n), g = de(m, u, e, n, h);
436
- t[a] = g;
438
+ const l = o != null && o.___array ? A({ ___array: o.___array }, e, n) : { ___array: d.any() }, h = ur(l, u, n), p = de(m, u, e, n, h);
439
+ t[a] = p;
437
440
  } else if (m && u) {
438
- const l = or(m, u, e, n);
441
+ const l = ir(m, u, e, n);
439
442
  t[a] = l;
440
- } else s && u ? t[a] = K(u, n) : t[a] = d.object(A(r[a], e, n)).optional();
443
+ } else s && u ? t[a] = G(u, n) : t[a] = d.object(A(r[a], e, n)).optional();
441
444
  }), t;
442
445
  }
443
- function ar(r, e, n) {
444
- return d.union([
445
- d.array(r.___array).optional(),
446
- d.string().superRefine((t, a) => {
447
- var s;
448
- if ((s = n == null ? void 0 : n.validationConfig) != null && s.globalValidation) {
449
- const o = n.validationConfig.globalValidation(t, e, n.metadata);
450
- if (o.error)
451
- return a.addIssue({
452
- code: d.ZodIssueCode.custom,
453
- message: o.error
454
- }), !1;
455
- if (!o.continue)
456
- return !0;
457
- }
458
- return !0;
459
- })
460
- ]);
446
+ function Se(r, e) {
447
+ return d.string().superRefine((n, t) => {
448
+ var a;
449
+ if ((a = e == null ? void 0 : e.validationConfig) != null && a.globalValidation) {
450
+ const s = e.validationConfig.globalValidation(n, r, e.metadata);
451
+ if (s.error)
452
+ return t.addIssue({
453
+ code: d.ZodIssueCode.custom,
454
+ message: s.error
455
+ }), !1;
456
+ if (!s.continue)
457
+ return !0;
458
+ }
459
+ return !0;
460
+ });
461
+ }
462
+ function ur(r, e, n) {
463
+ return d.union([d.array(r.___array).optional(), Se(e, n)]);
461
464
  }
462
- function or(r, e, n, t) {
465
+ function ir(r, e, n, t) {
463
466
  return d.any().optional().superRefine(async (a, s) => {
464
467
  var u, i;
465
- if (e.required && !(await K(e, t).safeParseAsync(a)).success)
468
+ if (e.required && !(await G(e, t).safeParseAsync(a)).success)
466
469
  return s.addIssue({
467
470
  code: d.ZodIssueCode.custom,
468
- message: J(e, t)
471
+ message: U(e, t)
469
472
  }), d.NEVER;
470
473
  if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
471
474
  const c = (i = t == null ? void 0 : t.validationConfig) == null ? void 0 : i.globalValidation(a, e, t.metadata);
@@ -481,7 +484,7 @@ function or(r, e, n, t) {
481
484
  if (o) {
482
485
  const c = await o.safeParseAsync(a);
483
486
  if (!c.success) {
484
- const f = q(c == null ? void 0 : c.error.message), m = f === "Required" ? J(e, t) : f;
487
+ const f = q(c == null ? void 0 : c.error.message), m = f === "Required" ? U(e, t) : f;
485
488
  s.addIssue({
486
489
  code: d.ZodIssueCode.custom,
487
490
  message: m
@@ -493,7 +496,7 @@ function or(r, e, n, t) {
493
496
  function de(r, e, n, t, a) {
494
497
  return d.any().optional().superRefine(async (s, o) => {
495
498
  var f, m;
496
- const i = await K(e, t).safeParseAsync(s);
499
+ const i = await G(e, t).safeParseAsync(s);
497
500
  if (e.required && !i.success) {
498
501
  const l = q(i.error.message);
499
502
  return o.addIssue({ code: d.ZodIssueCode.custom, message: l, fatal: !0 }), d.NEVER;
@@ -508,9 +511,9 @@ function de(r, e, n, t, a) {
508
511
  message: q(l.error)
509
512
  }), d.NEVER;
510
513
  if (!l.continue)
511
- return d.NEVER;
514
+ return !0;
512
515
  }
513
- if (!V(s))
516
+ if (!j(s))
514
517
  return o.addIssue({
515
518
  code: d.ZodIssueCode.custom,
516
519
  message: "'Value is not array'"
@@ -531,40 +534,40 @@ function Z(r, e, n, t, a) {
531
534
  var u, i, c, f, m, l, h;
532
535
  const o = n;
533
536
  if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
534
- const g = T(r, s.path);
535
- if ((i = s.validation) != null && i.schema ? E(
537
+ const p = T(r, s.path);
538
+ if ((i = s.validation) != null && i.schema ? S(
536
539
  r,
537
540
  s.path,
538
- M(g, {
541
+ M(p, {
539
542
  _schema: (c = s.validation) == null ? void 0 : c.schema,
540
543
  _input: s
541
544
  })
542
- ) : s.required && E(r, s.path, M(g, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
543
- const b = {};
545
+ ) : s.required && S(r, s.path, M(p, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
546
+ const g = {};
544
547
  Z(
545
- b,
546
- (m = (f = s.inputConfig) == null ? void 0 : f.inputs) == null ? void 0 : m.map((v) => ({
547
- ...v,
548
- path: v.relativePath
548
+ g,
549
+ (m = (f = s.inputConfig) == null ? void 0 : f.inputs) == null ? void 0 : m.map((E) => ({
550
+ ...E,
551
+ path: E.relativePath
549
552
  })),
550
553
  n,
551
554
  t
552
555
  );
553
- const R = T(r, s.path);
554
- E(r, s.path, M(R, { _schemaObj: b, _isList: !0, _input: s }));
556
+ const x = T(r, s.path);
557
+ S(r, s.path, M(x, { _schemaObj: g, _isList: !0, _input: s }));
555
558
  }
556
559
  if (!((l = s.validation) != null && l.schema) && s.inputType === "array") {
557
- const b = {};
560
+ const g = {};
558
561
  Z(
559
- b,
562
+ g,
560
563
  [{ ...s.inputConfig.input, path: "___array" }],
561
564
  n,
562
565
  t
563
- ), E(
566
+ ), S(
564
567
  r,
565
568
  s.path,
566
- M(g, {
567
- _schemaObj: b,
569
+ M(p, {
570
+ _schemaObj: g,
568
571
  _schema: (h = s.validation) == null ? void 0 : h.schema,
569
572
  _isArrayItem: !0,
570
573
  _input: s
@@ -575,7 +578,7 @@ function Z(r, e, n, t, a) {
575
578
  }), e.forEach((s) => {
576
579
  var u;
577
580
  const o = n;
578
- if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
581
+ if ((!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) && s.path) {
579
582
  const i = s.path.split(".");
580
583
  i.forEach((c, f) => {
581
584
  if (f > 0 && /^\d+$/.test(c)) {
@@ -586,17 +589,17 @@ function Z(r, e, n, t, a) {
586
589
  }
587
590
  });
588
591
  }
589
- function J(r, e) {
592
+ function U(r, e) {
590
593
  var n, t, a;
591
- return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((a = e == null ? void 0 : e.validationConfig) == null ? void 0 : a.requiredMessage) ?? tr;
594
+ return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((a = e == null ? void 0 : e.validationConfig) == null ? void 0 : a.requiredMessage) ?? sr;
592
595
  }
593
- function K(r, e) {
596
+ function G(r, e) {
594
597
  var t, a, s, o, u, i;
595
598
  if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
596
599
  return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
597
600
  if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
598
601
  return (i = e == null ? void 0 : e.validationConfig) == null ? void 0 : i.requiredSchema;
599
- const n = J(r, e);
602
+ const n = U(r, e);
600
603
  return d.any().optional().superRefine((c, f) => {
601
604
  typeof c == "object" && k(c) && f.addIssue({
602
605
  code: d.ZodIssueCode.custom,
@@ -613,7 +616,7 @@ function Te(r, e) {
613
616
  if (typeof r == "function")
614
617
  return r(e);
615
618
  }
616
- const ur = (r) => Array.isArray(r == null ? void 0 : r.errors), ir = (r, e) => {
619
+ const cr = (r) => Array.isArray(r == null ? void 0 : r.errors), fr = (r, e) => {
617
620
  const n = {};
618
621
  for (; r.length; ) {
619
622
  const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
@@ -629,7 +632,7 @@ const ur = (r) => Array.isArray(r == null ? void 0 : r.errors), ir = (r, e) => {
629
632
  "unionErrors" in t && t.unionErrors.forEach((i) => i.errors.forEach((c) => r.push(c)));
630
633
  {
631
634
  const i = n[u].types, c = i && i[t.code];
632
- n[u] = We(
635
+ n[u] = Ue(
633
636
  u,
634
637
  e,
635
638
  n,
@@ -641,19 +644,19 @@ const ur = (r) => Array.isArray(r == null ? void 0 : r.errors), ir = (r, e) => {
641
644
  }
642
645
  return n;
643
646
  };
644
- function Cr(r, e) {
645
- return ke(
647
+ function Or(r, e) {
648
+ return De(
646
649
  async (n, t, a) => {
647
650
  try {
648
- return await nr(r, n, e).parseAsync(n), {
651
+ return await ar(r, n, e).parseAsync(n), {
649
652
  values: n,
650
653
  errors: {}
651
654
  };
652
655
  } catch (s) {
653
- if (ur(s))
656
+ if (cr(s))
654
657
  return {
655
658
  values: {},
656
- errors: Je(ir(s.errors, !0), a)
659
+ errors: He(fr(s.errors, !0), a)
657
660
  };
658
661
  throw s;
659
662
  }
@@ -661,31 +664,31 @@ function Cr(r, e) {
661
664
  [r, e]
662
665
  );
663
666
  }
664
- function cr(r, e) {
667
+ function lr(r, e) {
665
668
  const n = H(r);
666
669
  return e.forEach((t) => {
667
- t.inputTransform && (V(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
670
+ t.inputTransform && (j(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
668
671
  const o = T(n, t.path), u = s(o, n);
669
- u && E(n, u.path ?? t.path, u.value);
672
+ u && S(n, u.path ?? t.path, u.value);
670
673
  });
671
674
  }), n;
672
675
  }
673
- function fr(r, e) {
676
+ function dr(r, e) {
674
677
  const n = [], t = H(r);
675
678
  return e.forEach((a) => {
676
- a.outputTransform && (V(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((o) => {
679
+ a.outputTransform && (j(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((o) => {
677
680
  const u = T(t, a.path), i = o(u, t);
678
- i && (i.path ? (E(t, i.path, i.value), i.unset && n.push(a.path)) : E(t, a.path, i.value));
681
+ i && (i.path ? (S(t, i.path, i.value), i.unset && n.push(a.path)) : S(t, a.path, i.value));
679
682
  });
680
683
  }), n.forEach((a) => {
681
- pe(t, a);
684
+ ye(t, a);
682
685
  }), t;
683
686
  }
684
- function G(r) {
685
- return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...G(t.inputs)] : [...n, t], []);
687
+ function K(r) {
688
+ return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...K(t.inputs)] : [...n, t], []);
686
689
  }
687
690
  function _e(r) {
688
- const n = G(r.inputs).reduce((t, a) => {
691
+ const n = K(r.inputs).reduce((t, a) => {
689
692
  const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
690
693
  return (a.inputTransform || a.outputTransform) && t.push({
691
694
  ...we(a, "path", "inputTransform", "outputTransform"),
@@ -695,42 +698,42 @@ function _e(r) {
695
698
  }, []);
696
699
  return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
697
700
  }
698
- function lr(r, e, n, t = {}) {
699
- const { preserve: a } = t, s = G(r.inputs), o = H(e);
701
+ function mr(r, e, n, t = {}) {
702
+ const { preserve: a } = t, s = K(r.inputs), o = H(e);
700
703
  return s.forEach((u) => {
701
- a && a.includes(u.path) || u.isVisible && !u.isVisible(e, n) && pe(o, u.path);
704
+ a && a.includes(u.path) || u.isVisible && !u.isVisible(e, n) && ye(o, u.path);
702
705
  }), o;
703
706
  }
704
- function Ir(r, e) {
707
+ function wr(r, e) {
705
708
  const n = _e(e);
706
- return cr(r, n);
709
+ return lr(r, n);
707
710
  }
708
- function wr(r, e, n, t = {}) {
711
+ function jr(r, e, n, t = {}) {
709
712
  const a = _e(e);
710
- let s = lr(e, r, n, t);
711
- return s = fr(s, a), s = rr(s), s;
713
+ let s = mr(e, r, n, t);
714
+ return s = dr(s, a), s = nr(s), s;
712
715
  }
713
- function jr(r) {
716
+ function Vr(r) {
714
717
  const e = {}, n = (t) => {
715
718
  t.forEach((a) => {
716
719
  const { default: s, path: o, inputType: u, inputs: i } = a;
717
- (u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : s !== void 0 && E(e, o, s);
720
+ (u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : s !== void 0 && S(e, o, s);
718
721
  });
719
722
  };
720
723
  return Array.isArray(r.inputs) && n(r.inputs), e;
721
724
  }
722
- function Or() {
725
+ function xr() {
723
726
  return function(r, e) {
724
727
  if (!(typeof r > "u"))
725
- return r ? {
728
+ return !r || !je(r) ? { value: r } : {
726
729
  value: Object.getOwnPropertyNames(r).map((n) => ({ key: n, value: r[n] }))
727
- } : { value: r };
730
+ };
728
731
  };
729
732
  }
730
- function Vr(r) {
733
+ function Fr(r) {
731
734
  return function(e, n) {
732
735
  if (typeof e > "u") return;
733
- if (!e) return { value: e };
736
+ if (!e || !j(e)) return { value: e };
734
737
  const t = {
735
738
  value: e.reduce((a, s) => ({
736
739
  ...a,
@@ -740,19 +743,19 @@ function Vr(r) {
740
743
  return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
741
744
  };
742
745
  }
743
- function xr() {
746
+ function Pr() {
744
747
  return function(r, e) {
745
748
  if (!(typeof r > "u"))
746
- return V(r) && k(r) ? { value: void 0 } : { value: r };
749
+ return j(r) && k(r) ? { value: void 0 } : { value: r };
747
750
  };
748
751
  }
749
- function Fr(r) {
752
+ function qr(r) {
750
753
  return function(e, n) {
751
754
  const t = r ? T(n, r) : e;
752
755
  if (!(typeof t > "u")) {
753
- if (ye(t)) return { value: void 0, path: r };
756
+ if (pe(t)) return { value: void 0, path: r };
754
757
  if (he(t)) {
755
- const a = ge(t, je);
758
+ const a = ge(t, Ve);
756
759
  if (k(a))
757
760
  return { value: void 0, path: r };
758
761
  }
@@ -760,44 +763,44 @@ function Fr(r) {
760
763
  }
761
764
  };
762
765
  }
763
- function Pr() {
766
+ function Ar() {
764
767
  return function(r, e) {
765
768
  if (!(typeof r > "u"))
766
- return Oe(r) && k(r) ? { value: void 0 } : { value: r };
769
+ return xe(r) && k(r) ? { value: void 0 } : { value: r };
767
770
  };
768
771
  }
769
- function qr(r) {
772
+ function kr(r) {
770
773
  return function(e, n) {
771
774
  const t = T(n, r);
772
775
  return typeof t == "string" ? { value: t } : { value: e };
773
776
  };
774
777
  }
775
- function Ar(r) {
778
+ function Nr(r) {
776
779
  return function(e, n) {
777
780
  if (typeof e > "u") return;
778
781
  if (!e) return { value: e };
779
782
  const t = T(n, r);
780
783
  if (typeof t == "object") {
781
- const a = dr(t);
784
+ const a = hr(t);
782
785
  if (Object.getOwnPropertyNames(a).length === 1)
783
786
  return { value: e, path: r };
784
787
  }
785
788
  return { value: e };
786
789
  };
787
790
  }
788
- function kr(r) {
791
+ function Dr(r) {
789
792
  return function(e, n) {
790
793
  if (typeof e > "u") return;
791
794
  const t = T(n, r);
792
795
  return typeof t == "string" ? { value: [t] } : { value: e };
793
796
  };
794
797
  }
795
- function Nr(r, e) {
798
+ function Mr(r, e) {
796
799
  return function(n, t) {
797
800
  if (typeof n > "u") return;
798
801
  if (!n) return { value: n };
799
802
  const a = T(t, r);
800
- if (V(a)) {
803
+ if (j(a)) {
801
804
  if (a.length === 1)
802
805
  return { value: a[0], path: r };
803
806
  if (a.length === 0 && e != null && e.unsetIfEmpty)
@@ -809,13 +812,13 @@ function Nr(r, e) {
809
812
  function Re(r) {
810
813
  return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !Re(r[e])) : B(r);
811
814
  }
812
- function dr(r) {
815
+ function hr(r) {
813
816
  return ge(r, (e) => typeof e == "object" ? Re(e) : B(e));
814
817
  }
815
818
  function L(r) {
816
819
  const { items: e, ...n } = r;
817
- return /* @__PURE__ */ p.jsx(p.Fragment, { children: e.map((t) => /* @__PURE__ */ p.jsx(
818
- ze,
820
+ return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => /* @__PURE__ */ y.jsx(
821
+ rr,
819
822
  {
820
823
  input: t,
821
824
  path: t.path,
@@ -825,24 +828,24 @@ function L(r) {
825
828
  )) });
826
829
  }
827
830
  L.displayName = "RenderInputs";
828
- const mr = Ne((r, e) => {
831
+ const yr = Me((r, e) => {
829
832
  const { inputs: n, className: t, factory: a, withoutWrapper: s } = r;
830
- return s ? /* @__PURE__ */ p.jsxs(De, { children: [
833
+ return s ? /* @__PURE__ */ y.jsxs($e, { children: [
831
834
  n.hero,
832
- /* @__PURE__ */ p.jsx(L, { items: n.inputs, factory: a, withoutWrapper: s })
833
- ] }) : /* @__PURE__ */ p.jsxs("div", { className: t, ref: e, children: [
835
+ /* @__PURE__ */ y.jsx(L, { items: n.inputs, factory: a, withoutWrapper: s })
836
+ ] }) : /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
834
837
  n.hero,
835
- /* @__PURE__ */ p.jsx(L, { items: n.inputs, factory: a, withoutWrapper: s })
838
+ /* @__PURE__ */ y.jsx(L, { items: n.inputs, factory: a, withoutWrapper: s })
836
839
  ] });
837
840
  });
838
- mr.displayName = "RenderForm";
839
- function Dr(r) {
841
+ yr.displayName = "RenderForm";
842
+ function $r(r) {
840
843
  let e = !0;
841
844
  return me(r, (n) => {
842
- e = e && (n === "" || ye(n) || B(n));
845
+ e = e && (n === "" || pe(n) || B(n));
843
846
  }), e;
844
847
  }
845
- const Mr = (r = "") => Ve(r.split("_").join(" ")), hr = (r, e = 2, n, t = 1e3) => {
848
+ const Zr = (r = "") => Fe(r.split("_").join(" ")), pr = (r, e = 2, n, t = 1e3) => {
846
849
  let a = !1;
847
850
  const s = () => {
848
851
  requestAnimationFrame(() => {
@@ -854,64 +857,64 @@ const Mr = (r = "") => Ve(r.split("_").join(" ")), hr = (r, e = 2, n, t = 1e3) =
854
857
  a = !0;
855
858
  });
856
859
  };
857
- function $r(r) {
860
+ function Br(r) {
858
861
  const {
859
862
  field: { onBlur: e, ...n },
860
863
  ...t
861
- } = Ue(r), a = O(Date.now());
864
+ } = Le(r), a = w(Date.now());
862
865
  return {
863
866
  ...t,
864
867
  field: {
865
868
  ...n,
866
- onBlur: hr(e, 2, a.current)
869
+ onBlur: pr(e, 2, a.current)
867
870
  }
868
871
  };
869
872
  }
870
873
  export {
871
- Wr as Controller,
872
- Ur as Form,
873
- Jr as FormProvider,
874
- Er as InputComponent,
875
- ze as InputComponentRenderer,
874
+ Ur as Controller,
875
+ Lr as Form,
876
+ Hr as FormProvider,
877
+ Tr as InputComponent,
878
+ rr as InputComponentRenderer,
876
879
  be as InputFactory,
877
- Le as InputOverrideError,
878
- mr as RenderForm,
880
+ Ge as InputOverrideError,
881
+ yr as RenderForm,
879
882
  L as RenderInputs,
880
- Tr as RootForm,
881
- hr as afterFrames,
882
- Vr as arrayToObjectOutputTransformer,
883
- jr as collectDefaultValues,
884
- Ir as convertDataToFormModel,
885
- wr as convertFormModelToData,
886
- Mr as generateReadableLabel,
887
- Lr as get,
888
- _r as getDefaultValuesFromFormDefinition,
889
- Sr as getTemporaryPath,
883
+ _r as RootForm,
884
+ pr as afterFrames,
885
+ Fr as arrayToObjectOutputTransformer,
886
+ Vr as collectDefaultValues,
887
+ wr as convertDataToFormModel,
888
+ jr as convertFormModelToData,
889
+ Zr as generateReadableLabel,
890
+ Gr as get,
891
+ Rr as getDefaultValuesFromFormDefinition,
892
+ Ir as getTemporaryPath,
890
893
  _e as getTransformers,
891
- nr as getValidationSchema,
892
- cr as inputTransformValues,
893
- Dr as isChildrenEmpty,
894
- Or as objectToArrayInputTransformer,
895
- fr as outputTransformValues,
896
- Rr as overrideFormDefinition,
894
+ ar as getValidationSchema,
895
+ lr as inputTransformValues,
896
+ $r as isChildrenEmpty,
897
+ xr as objectToArrayInputTransformer,
898
+ dr as outputTransformValues,
899
+ Cr as overrideFormDefinition,
897
900
  q as processValidationParseResponse,
898
- rr as removeTemporaryFieldsValue,
899
- Hr as set,
900
- kr as shorthandArrayInputTransformer,
901
- Nr as shorthandArrayOutputTransformer,
902
- qr as shorthandObjectInputTransformer,
903
- Ar as shorthandObjectOutputTransformer,
904
- xr as unsetEmptyArrayOutputTransformer,
905
- Fr as unsetEmptyObjectOutputTransformer,
906
- Pr as unsetEmptyStringOutputTransformer,
907
- lr as unsetHiddenInputsValues,
908
- $r as useController,
909
- Kr as useFieldArray,
910
- Gr as useForm,
911
- Qr as useFormContext,
912
- Xr as useFormState,
913
- Xe as useRootFormContext,
914
- Yr as useWatch,
915
- Cr as useZodValidationResolver
901
+ nr as removeTemporaryFieldsValue,
902
+ Kr as set,
903
+ Dr as shorthandArrayInputTransformer,
904
+ Mr as shorthandArrayOutputTransformer,
905
+ kr as shorthandObjectInputTransformer,
906
+ Nr as shorthandObjectOutputTransformer,
907
+ Pr as unsetEmptyArrayOutputTransformer,
908
+ qr as unsetEmptyObjectOutputTransformer,
909
+ Ar as unsetEmptyStringOutputTransformer,
910
+ mr as unsetHiddenInputsValues,
911
+ Br as useController,
912
+ Qr as useFieldArray,
913
+ Xr as useForm,
914
+ Yr as useFormContext,
915
+ zr as useFormState,
916
+ ze as useRootFormContext,
917
+ et as useWatch,
918
+ Or as useZodValidationResolver
916
919
  };
917
920
  //# sourceMappingURL=index.js.map