@harnessio/forms 0.4.1 → 0.4.3

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,8 +1,8 @@
1
- var pe = Object.defineProperty;
2
- var ye = (r, e, n) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var N = (r, e, n) => ye(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { isEmpty as I, cloneDeep as q, set as y, get as v, forOwn as te, isArray as S, isObject as ne, merge as w, isUndefined as F, unset as se, pick as ge, isNull as ae, omitBy as oe, isNil as be, isString as ve, capitalize as _e } from "lodash-es";
5
- import Ee, { createContext as Re, useContext as Te, useMemo as D, useRef as M, useEffect as j, useCallback as Oe, forwardRef as Se, Fragment as je } from "react";
1
+ var ye = Object.defineProperty;
2
+ var pe = (r, e, n) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var N = (r, e, n) => pe(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { isEmpty as I, cloneDeep as q, set as g, get as _, forOwn as te, isArray as O, isObject as ne, merge as w, isUndefined as F, unset as se, pick as ge, isNull as ae, omitBy as ue, isNil as be, isString as ve, capitalize as _e } from "lodash-es";
5
+ import Re, { createContext as Ee, useContext as Te, useMemo as D, useRef as M, useEffect as j, useCallback as Se, forwardRef as Oe, Fragment as je } from "react";
6
6
  import { useFormContext as Ce, get as Ie, useForm as Ve, FormProvider as we, appendErrors as xe, useController as Pe } from "react-hook-form";
7
7
  export * from "react-hook-form";
8
8
  import * as d from "zod";
@@ -12,7 +12,7 @@ class Fe extends Error {
12
12
  super(`Input component '${e}' is already registered.`);
13
13
  }
14
14
  }
15
- class ue {
15
+ class oe {
16
16
  constructor(e) {
17
17
  N(this, "componentBank");
18
18
  N(this, "allowOverride");
@@ -47,7 +47,7 @@ class ue {
47
47
  * @returns new input factory
48
48
  */
49
49
  clone() {
50
- const e = new ue({
50
+ const e = new oe({
51
51
  allowOverride: this.allowOverride
52
52
  });
53
53
  return this.listRegisteredComponents().forEach((n) => {
@@ -55,7 +55,7 @@ class ue {
55
55
  }), e;
56
56
  }
57
57
  }
58
- var Z = { exports: {} }, O = {};
58
+ var Z = { exports: {} }, S = {};
59
59
  /*
60
60
  object-assign
61
61
  (c) Sindre Sorhus
@@ -78,12 +78,12 @@ function Ae() {
78
78
  var s = new String("abc");
79
79
  if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
80
80
  return !1;
81
- for (var i = {}, o = 0; o < 10; o++)
82
- i["_" + String.fromCharCode(o)] = o;
83
- var u = Object.getOwnPropertyNames(i).map(function(l) {
81
+ for (var i = {}, u = 0; u < 10; u++)
82
+ i["_" + String.fromCharCode(u)] = u;
83
+ var o = Object.getOwnPropertyNames(i).map(function(l) {
84
84
  return i[l];
85
85
  });
86
- if (u.join("") !== "0123456789")
86
+ if (o.join("") !== "0123456789")
87
87
  return !1;
88
88
  var c = {};
89
89
  return "abcdefghijklmnopqrst".split("").forEach(function(l) {
@@ -94,17 +94,17 @@ function Ae() {
94
94
  }
95
95
  }
96
96
  return B = a() ? Object.assign : function(s, i) {
97
- for (var o, u = t(s), c, l = 1; l < arguments.length; l++) {
98
- o = Object(arguments[l]);
99
- for (var m in o)
100
- e.call(o, m) && (u[m] = o[m]);
97
+ for (var u, o = t(s), c, l = 1; l < arguments.length; l++) {
98
+ u = Object(arguments[l]);
99
+ for (var m in u)
100
+ e.call(u, m) && (o[m] = u[m]);
101
101
  if (r) {
102
- c = r(o);
102
+ c = r(u);
103
103
  for (var f = 0; f < c.length; f++)
104
- n.call(o, c[f]) && (u[c[f]] = o[c[f]]);
104
+ n.call(u, c[f]) && (o[c[f]] = u[c[f]]);
105
105
  }
106
106
  }
107
- return u;
107
+ return o;
108
108
  }, B;
109
109
  }
110
110
  /** @license React v17.0.2
@@ -117,35 +117,35 @@ function Ae() {
117
117
  */
118
118
  var Y;
119
119
  function ke() {
120
- if (Y) return O;
120
+ if (Y) return S;
121
121
  Y = 1, Ae();
122
- var r = Ee, e = 60103;
123
- if (O.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
122
+ var r = Re, e = 60103;
123
+ if (S.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
124
124
  var n = Symbol.for;
125
- e = n("react.element"), O.Fragment = n("react.fragment");
125
+ e = n("react.element"), S.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
- function i(o, u, c) {
129
- var l, m = {}, f = null, h = null;
130
- c !== void 0 && (f = "" + c), u.key !== void 0 && (f = "" + u.key), u.ref !== void 0 && (h = u.ref);
131
- for (l in u) a.call(u, l) && !s.hasOwnProperty(l) && (m[l] = u[l]);
132
- if (o && o.defaultProps) for (l in u = o.defaultProps, u) m[l] === void 0 && (m[l] = u[l]);
133
- return { $$typeof: e, type: o, key: f, ref: h, props: m, _owner: t.current };
128
+ function i(u, o, c) {
129
+ var l, m = {}, f = null, y = null;
130
+ c !== void 0 && (f = "" + c), o.key !== void 0 && (f = "" + o.key), o.ref !== void 0 && (y = o.ref);
131
+ for (l in o) a.call(o, l) && !s.hasOwnProperty(l) && (m[l] = o[l]);
132
+ if (u && u.defaultProps) for (l in o = u.defaultProps, o) m[l] === void 0 && (m[l] = o[l]);
133
+ return { $$typeof: e, type: u, key: f, ref: y, props: m, _owner: t.current };
134
134
  }
135
- return O.jsx = i, O.jsxs = i, O;
135
+ return S.jsx = i, S.jsxs = i, S;
136
136
  }
137
137
  var K;
138
138
  function Ne() {
139
139
  return K || (K = 1, Z.exports = ke()), Z.exports;
140
140
  }
141
- var p = Ne();
142
- const ie = Re({});
141
+ var h = Ne();
142
+ const ie = Ee({});
143
143
  function De({
144
144
  children: r,
145
145
  metadata: e,
146
146
  readonly: n
147
147
  }) {
148
- return /* @__PURE__ */ p.jsx(
148
+ return /* @__PURE__ */ h.jsx(
149
149
  ie.Provider,
150
150
  {
151
151
  value: {
@@ -163,7 +163,7 @@ function Me() {
163
163
  const z = ({
164
164
  children: r,
165
165
  withoutWrapper: e = !1
166
- }) => e || !r ? r : /* @__PURE__ */ p.jsx("div", { children: r });
166
+ }) => e || !r ? r : /* @__PURE__ */ h.jsx("div", { children: r });
167
167
  function Ze({
168
168
  path: r,
169
169
  factory: e,
@@ -174,23 +174,23 @@ function Ze({
174
174
  withoutWrapper: i = !1
175
175
  }) {
176
176
  var W;
177
- const { formState: o, watch: u } = Ce(), {
177
+ const { formState: u, watch: o } = Ce(), {
178
178
  fixedValues: c = {}
179
179
  /*getValuesWithDependencies*/
180
- } = {}, { metadata: l, readonly: m } = Me(), f = e == null ? void 0 : e.getComponent(s.inputType), h = u(), _ = q(h);
180
+ } = {}, { metadata: l, readonly: m } = Me(), f = e == null ? void 0 : e.getComponent(s.inputType), y = o(), b = q(y);
181
181
  c && Object.keys(c).forEach((V) => {
182
182
  const A = c[V];
183
- y(_, V, A);
183
+ g(b, V, A);
184
184
  });
185
- const g = !s.isVisible || s.isVisible(_, l);
186
- let R, T;
187
- g && (R = m || s.readonly, T = typeof s.disabled == "function" ? s.disabled(_, l) : s.disabled);
188
- const E = (W = s.warning) == null ? void 0 : W.schema, b = D(() => {
185
+ const p = !s.isVisible || s.isVisible(b, l);
186
+ let E, R;
187
+ p && (E = m || s.readonly, R = typeof s.disabled == "function" ? s.disabled(b, l) : s.disabled);
188
+ const T = (W = s.warning) == null ? void 0 : W.schema, v = D(() => {
189
189
  var H, Q;
190
- if (!g || typeof E > "u") return;
191
- const V = Ie(h, s.path), A = typeof E == "function" ? E(_) : E, { success: he, error: k } = A.safeParse(V), G = (Q = (H = k == null ? void 0 : k.errors) == null ? void 0 : H[0]) == null ? void 0 : Q.message;
190
+ if (!p || typeof T > "u") return;
191
+ const V = Ie(y, s.path), A = typeof T == "function" ? T(b) : T, { success: he, error: k } = A.safeParse(V), G = (Q = (H = k == null ? void 0 : k.errors) == null ? void 0 : H[0]) == null ? void 0 : Q.message;
192
192
  return !he && G ? G : void 0;
193
- }, [s.path, h, E, g]), L = D(
193
+ }, [s.path, y, T, p]), L = D(
194
194
  () => ({
195
195
  path: r,
196
196
  key: r,
@@ -198,24 +198,24 @@ function Ze({
198
198
  onUpdate: n,
199
199
  onChange: t,
200
200
  factory: e,
201
- readonly: R,
201
+ readonly: E,
202
202
  input: s,
203
- disabled: T,
204
- warning: b
203
+ disabled: R,
204
+ warning: v
205
205
  }),
206
- [e, a, s, t, n, r, R, o.errors, T, b]
207
- ), me = D(() => g ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
206
+ [e, a, s, t, n, r, E, u.errors, R, v]
207
+ ), me = D(() => p ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
208
208
  s.before ? s.before : null,
209
209
  f == null ? void 0 : f.renderComponent(L),
210
210
  s.after ? s.after : null
211
- ] }) : null, [L, s.after, s.before, f, g, o.errors]);
212
- return f ? /* @__PURE__ */ p.jsx(z, { withoutWrapper: i, children: me }) : /* @__PURE__ */ p.jsx(z, { withoutWrapper: i, children: /* @__PURE__ */ p.jsxs("p", { children: [
211
+ ] }) : null, [L, s.after, s.before, f, p, u.errors]);
212
+ return f ? /* @__PURE__ */ h.jsx(z, { withoutWrapper: i, children: me }) : /* @__PURE__ */ h.jsx(z, { withoutWrapper: i, children: /* @__PURE__ */ h.jsxs("p", { children: [
213
213
  "Input component not found (internal type: ",
214
214
  s.inputType,
215
215
  ")"
216
216
  ] }) });
217
217
  }
218
- class ar {
218
+ class ur {
219
219
  getType() {
220
220
  return this.internalType;
221
221
  }
@@ -229,11 +229,11 @@ function or(r) {
229
229
  // validateAfterFirstSubmit,
230
230
  onValuesChange: s,
231
231
  onValidationChange: i,
232
- onSubmit: o,
232
+ onSubmit: u,
233
233
  // validate,
234
234
  // validateDebounceInterval,
235
235
  // validationConfig,
236
- metadata: u,
236
+ metadata: o,
237
237
  children: c,
238
238
  // fixedValues
239
239
  autoFocusPath: l,
@@ -244,11 +244,11 @@ function or(r) {
244
244
  defaultValues: t,
245
245
  shouldFocusError: a,
246
246
  resolver: n
247
- }), h = M(!1);
247
+ }), y = M(!1);
248
248
  j(() => {
249
249
  f.reset(t, {});
250
250
  }, [f.reset, t]), j(() => {
251
- const b = requestIdleCallback(() => {
251
+ const v = requestIdleCallback(() => {
252
252
  f.reset({}, {
253
253
  keepErrors: !0,
254
254
  keepDirty: !0,
@@ -262,55 +262,55 @@ function or(r) {
262
262
  keepSubmitCount: !0
263
263
  });
264
264
  });
265
- return () => cancelIdleCallback(b);
265
+ return () => cancelIdleCallback(v);
266
266
  }, []);
267
- const { getValues: _, handleSubmit: g } = f, R = _(), T = M(!0);
267
+ const { getValues: b, handleSubmit: p } = f, E = b(), R = M(!0);
268
268
  j(() => {
269
- if (T.current) {
270
- T.current = !1;
269
+ if (R.current) {
270
+ R.current = !1;
271
271
  return;
272
272
  }
273
- s == null || s({ ...R }), h.current === !0 && f.trigger();
274
- }, [JSON.stringify(R)]);
275
- const E = M(!0);
273
+ s == null || s({ ...E }), y.current === !0 && f.trigger();
274
+ }, [JSON.stringify(E)]);
275
+ const T = M(!0);
276
276
  return j(() => {
277
- if (E.current) {
278
- E.current = !1;
277
+ if (T.current) {
278
+ T.current = !1;
279
279
  return;
280
280
  }
281
281
  i == null || i({ isValid: f.formState.isValid, isSubmitted: f.formState.isSubmitted });
282
282
  }, [f.formState.isValid, f.formState.isSubmitted]), j(() => {
283
283
  if (l)
284
284
  if ("requestIdleCallback" in window) {
285
- const b = requestIdleCallback(() => {
285
+ const v = requestIdleCallback(() => {
286
286
  f.setFocus(l);
287
287
  });
288
- return () => cancelIdleCallback(b);
288
+ return () => cancelIdleCallback(v);
289
289
  } else {
290
- const b = setTimeout(() => {
290
+ const v = setTimeout(() => {
291
291
  f.setFocus(l);
292
292
  }, 100);
293
- return () => clearTimeout(b);
293
+ return () => clearTimeout(v);
294
294
  }
295
- }, [f]), /* @__PURE__ */ p.jsx(De, { metadata: u, readonly: m, children: /* @__PURE__ */ p.jsx(we, { ...f, children: typeof c == "function" ? c({
295
+ }, [f]), /* @__PURE__ */ h.jsx(De, { metadata: o, readonly: m, children: /* @__PURE__ */ h.jsx(we, { ...f, children: typeof c == "function" ? c({
296
296
  ...f,
297
297
  submitForm: async () => {
298
- o && (h.current = !0, g((b) => {
299
- o(b);
298
+ u && (y.current = !0, p((v) => {
299
+ u(v);
300
300
  })());
301
301
  }
302
302
  }) : c }) });
303
303
  }
304
- const ur = (r) => {
304
+ const ir = (r) => {
305
305
  const e = {}, n = (t) => {
306
306
  t.forEach((a) => {
307
- const { path: s, default: i, inputType: o, inputs: u } = a;
308
- (o === "group" || o === "accordion") && Array.isArray(u) ? n(u) : v(e, s) === void 0 && y(e, s, i);
307
+ const { path: s, default: i, inputType: u, inputs: o } = a;
308
+ (u === "group" || u === "accordion") && Array.isArray(o) ? n(o) : _(e, s) === void 0 && g(e, s, i);
309
309
  });
310
310
  };
311
311
  return Array.isArray(r.inputs) && n(r.inputs), e;
312
312
  };
313
- function ir(r, e) {
313
+ function cr(r, e) {
314
314
  const n = r.inputs.map((t) => {
315
315
  const a = Be(e, t.path);
316
316
  return a || t;
@@ -320,7 +320,7 @@ function ir(r, e) {
320
320
  function Be(r, e) {
321
321
  return r.inputs.find((n) => n.path === e);
322
322
  }
323
- const ce = "__temp_", cr = (r) => ce + r.split(".").join("__");
323
+ const ce = "__temp_", fr = (r) => ce + r.split(".").join("__");
324
324
  function $e(r) {
325
325
  const e = { ...r };
326
326
  return te(e, (n, t) => {
@@ -332,7 +332,7 @@ function C(r) {
332
332
  const e = typeof r == "string" ? JSON.parse(r) : r;
333
333
  if (typeof e == "string")
334
334
  return e;
335
- if (S(e))
335
+ if (O(e))
336
336
  return C(e[0]);
337
337
  const n = e;
338
338
  return ne(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
@@ -341,7 +341,7 @@ function Ue(r, e, n) {
341
341
  let t = {};
342
342
  if (P(t, r.inputs, e, n), n != null && n.prefix) {
343
343
  const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
344
- t = y({}, s, t);
344
+ t = g({}, s, t);
345
345
  }
346
346
  return d.object(x(t, e, n));
347
347
  }
@@ -351,34 +351,53 @@ function x(r, e, n) {
351
351
  const {
352
352
  _requiredOnly: s,
353
353
  _schemaObj: i,
354
- _input: o,
355
- _isList: u,
354
+ _input: u,
355
+ _isList: o,
356
356
  _isArrayItem: c,
357
357
  _schema: l
358
358
  /*...nestedSchemaObj*/
359
359
  } = r[a];
360
- if (u && i && o) {
361
- const m = d.array(d.object(x(i, e, n))).optional(), f = ee(l, o, e, n, m);
360
+ if (o && i && u) {
361
+ const m = d.array(d.object(x(i, e, n))).optional(), f = ee(l, u, e, n, m);
362
362
  t[a] = f;
363
- } else if (c && o) {
364
- const m = i != null && i.___array ? x({ ___array: i.___array }, e, n) : { ___array: d.any() }, f = d.array(m.___array).optional(), h = ee(l, o, e, n, f);
365
- t[a] = h;
366
- } else if (l && o) {
367
- const m = Le(l, o, e, n);
363
+ } else if (c && u) {
364
+ const m = i != null && i.___array ? x({ ___array: i.___array }, e, n) : { ___array: d.any() }, f = Le(m, u, n), y = ee(l, u, e, n, f);
365
+ t[a] = y;
366
+ } else if (l && u) {
367
+ const m = We(l, u, e, n);
368
368
  t[a] = m;
369
- } else s && o ? t[a] = J(o, n) : t[a] = d.object(x(r[a], e, n)).optional();
369
+ } else s && u ? t[a] = J(u, n) : t[a] = d.object(x(r[a], e, n)).optional();
370
370
  }), t;
371
371
  }
372
- function Le(r, e, n, t) {
372
+ function Le(r, e, n) {
373
+ return d.union([
374
+ d.array(r.___array).optional(),
375
+ d.string().superRefine((t, a) => {
376
+ var s;
377
+ if ((s = n == null ? void 0 : n.validationConfig) != null && s.globalValidation) {
378
+ const i = n.validationConfig.globalValidation(t, e, n.metadata);
379
+ if (i.error)
380
+ return a.addIssue({
381
+ code: d.ZodIssueCode.custom,
382
+ message: i.error
383
+ }), !1;
384
+ if (!i.continue)
385
+ return !0;
386
+ }
387
+ return !0;
388
+ })
389
+ ]);
390
+ }
391
+ function We(r, e, n, t) {
373
392
  return d.any().optional().superRefine(async (a, s) => {
374
- var o, u;
393
+ var u, o;
375
394
  if (e.required && !(await J(e, t).safeParseAsync(a)).success)
376
395
  return s.addIssue({
377
396
  code: d.ZodIssueCode.custom,
378
397
  message: $(e, t)
379
398
  }), d.NEVER;
380
- if ((o = t == null ? void 0 : t.validationConfig) != null && o.globalValidation) {
381
- const c = (u = t == null ? void 0 : t.validationConfig) == null ? void 0 : u.globalValidation(a, e, t.metadata);
399
+ if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
400
+ const c = (o = t == null ? void 0 : t.validationConfig) == null ? void 0 : o.globalValidation(a, e, t.metadata);
382
401
  if (c.error)
383
402
  return s.addIssue({
384
403
  code: d.ZodIssueCode.custom,
@@ -403,12 +422,12 @@ function Le(r, e, n, t) {
403
422
  function ee(r, e, n, t, a) {
404
423
  return d.any().optional().superRefine(async (s, i) => {
405
424
  var l, m;
406
- const u = await J(e, t).safeParseAsync(s);
407
- if (e.required && !u.success) {
408
- const f = C(u.error.message);
425
+ const o = await J(e, t).safeParseAsync(s);
426
+ if (e.required && !o.success) {
427
+ const f = C(o.error.message);
409
428
  return i.addIssue({ code: d.ZodIssueCode.custom, message: f, fatal: !0 }), d.NEVER;
410
429
  }
411
- if (!e.required && !u.success)
430
+ if (!e.required && !o.success)
412
431
  return d.NEVER;
413
432
  if ((l = t == null ? void 0 : t.validationConfig) != null && l.globalValidation) {
414
433
  const f = (m = t == null ? void 0 : t.validationConfig) == null ? void 0 : m.globalValidation(s, e, t.metadata);
@@ -420,7 +439,7 @@ function ee(r, e, n, t, a) {
420
439
  if (!f.continue)
421
440
  return d.NEVER;
422
441
  }
423
- if (!S(s))
442
+ if (!O(s))
424
443
  return i.addIssue({
425
444
  code: d.ZodIssueCode.custom,
426
445
  message: "'Value is not array'"
@@ -438,44 +457,44 @@ function ee(r, e, n, t, a) {
438
457
  }
439
458
  function P(r, e, n, t, a) {
440
459
  e.forEach((s) => {
441
- var o, u, c, l, m;
460
+ var u, o, c, l, m, f, y;
442
461
  const i = n;
443
- if (!s.isVisible || (o = s.isVisible) != null && o.call(s, i, t == null ? void 0 : t.metadata)) {
444
- const f = v(r, s.path);
445
- if ((u = s.validation) != null && u.schema ? y(
462
+ if (!s.isVisible || (u = s.isVisible) != null && u.call(s, i, t == null ? void 0 : t.metadata)) {
463
+ const b = _(r, s.path);
464
+ if ((o = s.validation) != null && o.schema ? g(
446
465
  r,
447
466
  s.path,
448
- w(f, {
467
+ w(b, {
449
468
  _schema: (c = s.validation) == null ? void 0 : c.schema,
450
469
  _input: s
451
470
  })
452
- ) : s.required && y(r, s.path, w(f, { _requiredOnly: !0, _input: s })), s.inputs && P(r, s.inputs, n, t), s.inputType === "list") {
453
- const h = {};
471
+ ) : s.required && g(r, s.path, w(b, { _requiredOnly: !0, _input: s })), s.inputs && P(r, s.inputs, n, t), s.inputType === "list") {
472
+ const p = {};
454
473
  P(
455
- h,
456
- s.inputConfig.inputs.map((g) => ({
457
- ...g,
458
- path: g.relativePath
474
+ p,
475
+ (m = (l = s.inputConfig) == null ? void 0 : l.inputs) == null ? void 0 : m.map((R) => ({
476
+ ...R,
477
+ path: R.relativePath
459
478
  })),
460
479
  n,
461
480
  t
462
481
  );
463
- const _ = v(r, s.path);
464
- y(r, s.path, w(_, { _schemaObj: h, _isList: !0, _input: s }));
482
+ const E = _(r, s.path);
483
+ g(r, s.path, w(E, { _schemaObj: p, _isList: !0, _input: s }));
465
484
  }
466
- if (!((l = s.validation) != null && l.schema) && s.inputType === "array") {
467
- const h = {};
485
+ if (!((f = s.validation) != null && f.schema) && s.inputType === "array") {
486
+ const p = {};
468
487
  P(
469
- h,
488
+ p,
470
489
  [{ ...s.inputConfig.input, path: "___array" }],
471
490
  n,
472
491
  t
473
- ), y(
492
+ ), g(
474
493
  r,
475
494
  s.path,
476
- w(f, {
477
- _schemaObj: h,
478
- _schema: (m = s.validation) == null ? void 0 : m.schema,
495
+ w(b, {
496
+ _schemaObj: p,
497
+ _schema: (y = s.validation) == null ? void 0 : y.schema,
479
498
  _isArrayItem: !0,
480
499
  _input: s
481
500
  })
@@ -489,11 +508,11 @@ function $(r, e) {
489
508
  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) ?? Je;
490
509
  }
491
510
  function J(r, e) {
492
- var t, a, s, i, o, u;
511
+ var t, a, s, i, u, o;
493
512
  if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
494
513
  return (i = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : i[r.inputType];
495
- if ((o = e == null ? void 0 : e.validationConfig) != null && o.requiredSchema)
496
- return (u = e == null ? void 0 : e.validationConfig) == null ? void 0 : u.requiredSchema;
514
+ if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
515
+ return (o = e == null ? void 0 : e.validationConfig) == null ? void 0 : o.requiredSchema;
497
516
  const n = $(r, e);
498
517
  return d.any().optional().superRefine((c, l) => {
499
518
  typeof c == "object" && I(c) && l.addIssue({
@@ -511,24 +530,24 @@ function fe(r, e) {
511
530
  if (typeof r == "function")
512
531
  return r(e);
513
532
  }
514
- const We = (r) => Array.isArray(r == null ? void 0 : r.errors), Ge = (r, e) => {
533
+ const Ge = (r) => Array.isArray(r == null ? void 0 : r.errors), He = (r, e) => {
515
534
  const n = {};
516
535
  for (; r.length; ) {
517
- const t = r[0], { code: a, message: s, path: i } = t, o = i.join(".");
518
- if (!n[o])
536
+ const t = r[0], { code: a, message: s, path: i } = t, u = i.join(".");
537
+ if (!n[u])
519
538
  if ("unionErrors" in t) {
520
- const u = t.unionErrors[0].errors[0];
521
- n[o] = {
522
- message: u.message,
523
- type: u.code
539
+ const o = t.unionErrors[0].errors[0];
540
+ n[u] = {
541
+ message: o.message,
542
+ type: o.code
524
543
  };
525
544
  } else
526
- n[o] = { message: s, type: a };
527
- "unionErrors" in t && t.unionErrors.forEach((u) => u.errors.forEach((c) => r.push(c)));
545
+ n[u] = { message: s, type: a };
546
+ "unionErrors" in t && t.unionErrors.forEach((o) => o.errors.forEach((c) => r.push(c)));
528
547
  {
529
- const u = n[o].types, c = u && u[t.code];
530
- n[o] = xe(
531
- o,
548
+ const o = n[u].types, c = o && o[t.code];
549
+ n[u] = xe(
550
+ u,
532
551
  e,
533
552
  n,
534
553
  a,
@@ -539,8 +558,8 @@ const We = (r) => Array.isArray(r == null ? void 0 : r.errors), Ge = (r, e) => {
539
558
  }
540
559
  return n;
541
560
  };
542
- function fr(r, e) {
543
- return Oe(
561
+ function lr(r, e) {
562
+ return Se(
544
563
  async (n, t, a) => {
545
564
  try {
546
565
  return await Ue(r, n, e).parseAsync(n), {
@@ -549,10 +568,10 @@ function fr(r, e) {
549
568
  errors: {}
550
569
  };
551
570
  } catch (s) {
552
- if (We(s))
571
+ if (Ge(s))
553
572
  return {
554
573
  values: {},
555
- errors: qe(Ge(s.errors, !0), a)
574
+ errors: qe(He(s.errors, !0), a)
556
575
  };
557
576
  throw s;
558
577
  }
@@ -560,21 +579,21 @@ function fr(r, e) {
560
579
  [r]
561
580
  );
562
581
  }
563
- function He(r, e) {
582
+ function Qe(r, e) {
564
583
  const n = q(r);
565
584
  return e.forEach((t) => {
566
- t.inputTransform && (S(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
567
- const i = v(n, t.path), o = s(i, n);
568
- o && y(n, o.path ?? t.path, o.value);
585
+ t.inputTransform && (O(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
586
+ const i = _(n, t.path), u = s(i, n);
587
+ u && g(n, u.path ?? t.path, u.value);
569
588
  });
570
589
  }), n;
571
590
  }
572
- function Qe(r, e) {
591
+ function Xe(r, e) {
573
592
  const n = [], t = q(r);
574
593
  return e.forEach((a) => {
575
- a.outputTransform && (S(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((i) => {
576
- const o = v(t, a.path), u = i(o, t);
577
- u && (u.path ? (y(t, u.path, u.value), u.unset && n.push(a.path)) : y(t, a.path, u.value));
594
+ a.outputTransform && (O(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((i) => {
595
+ const u = _(t, a.path), o = i(u, t);
596
+ o && (o.path ? (g(t, o.path, o.value), o.unset && n.push(a.path)) : g(t, a.path, o.value));
578
597
  });
579
598
  }), n.forEach((a) => {
580
599
  se(t, a);
@@ -594,31 +613,31 @@ function le(r) {
594
613
  }, []);
595
614
  return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
596
615
  }
597
- function Xe(r, e, n, t = {}) {
616
+ function Ye(r, e, n, t = {}) {
598
617
  const { preserve: a } = t, s = U(r.inputs), i = q(e);
599
- return s.forEach((o) => {
600
- a && a.includes(o.path) || o.isVisible && !o.isVisible(e, n) && se(i, o.path);
618
+ return s.forEach((u) => {
619
+ a && a.includes(u.path) || u.isVisible && !u.isVisible(e, n) && se(i, u.path);
601
620
  }), i;
602
621
  }
603
- function lr(r, e) {
622
+ function dr(r, e) {
604
623
  const n = le(e);
605
- return He(r, n);
624
+ return Qe(r, n);
606
625
  }
607
- function dr(r, e, n, t = {}) {
626
+ function mr(r, e, n, t = {}) {
608
627
  const a = le(e);
609
- let s = Xe(e, r, n, t);
610
- return s = Qe(s, a), s = $e(s), s;
628
+ let s = Ye(e, r, n, t);
629
+ return s = Xe(s, a), s = $e(s), s;
611
630
  }
612
- function mr(r) {
631
+ function hr(r) {
613
632
  const e = {}, n = (t) => {
614
633
  t.forEach((a) => {
615
- const { default: s, path: i, inputType: o, inputs: u } = a;
616
- (o === "group" || o === "accordion") && Array.isArray(u) ? n(u) : s !== void 0 && y(e, i, s);
634
+ const { default: s, path: i, inputType: u, inputs: o } = a;
635
+ (u === "group" || u === "accordion") && Array.isArray(o) ? n(o) : s !== void 0 && g(e, i, s);
617
636
  });
618
637
  };
619
638
  return Array.isArray(r.inputs) && n(r.inputs), e;
620
639
  }
621
- function hr() {
640
+ function yr() {
622
641
  return function(r, e) {
623
642
  if (!(typeof r > "u"))
624
643
  return r ? {
@@ -636,19 +655,19 @@ function pr(r) {
636
655
  return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
637
656
  };
638
657
  }
639
- function yr() {
658
+ function gr() {
640
659
  return function(r, e) {
641
660
  if (!(typeof r > "u"))
642
- return S(r) && I(r) ? { value: void 0 } : { value: r };
661
+ return O(r) && I(r) ? { value: void 0 } : { value: r };
643
662
  };
644
663
  }
645
- function gr(r) {
664
+ function br(r) {
646
665
  return function(e, n) {
647
- const t = r ? v(n, r) : e;
666
+ const t = r ? _(n, r) : e;
648
667
  if (!(typeof t > "u")) {
649
668
  if (ae(t)) return { value: void 0, path: r };
650
669
  if (ne(t)) {
651
- const a = oe(t, be);
670
+ const a = ue(t, be);
652
671
  if (I(a))
653
672
  return { value: void 0, path: r };
654
673
  }
@@ -656,25 +675,25 @@ function gr(r) {
656
675
  }
657
676
  };
658
677
  }
659
- function br() {
678
+ function vr() {
660
679
  return function(r, e) {
661
680
  if (!(typeof r > "u"))
662
681
  return ve(r) && I(r) ? { value: void 0 } : { value: r };
663
682
  };
664
683
  }
665
- function vr(r) {
684
+ function _r(r) {
666
685
  return function(e, n) {
667
- const t = v(n, r);
686
+ const t = _(n, r);
668
687
  return typeof t == "string" ? { value: t } : { value: e };
669
688
  };
670
689
  }
671
- function _r(r) {
690
+ function Rr(r) {
672
691
  return function(e, n) {
673
692
  if (typeof e > "u") return;
674
693
  if (!e) return { value: e };
675
- const t = v(n, r);
694
+ const t = _(n, r);
676
695
  if (typeof t == "object") {
677
- const a = Ye(t);
696
+ const a = Ke(t);
678
697
  if (Object.getOwnPropertyNames(a).length === 1)
679
698
  return { value: e, path: r };
680
699
  }
@@ -684,16 +703,16 @@ function _r(r) {
684
703
  function Er(r) {
685
704
  return function(e, n) {
686
705
  if (typeof e > "u") return;
687
- const t = v(n, r);
706
+ const t = _(n, r);
688
707
  return typeof t == "string" ? { value: [t] } : { value: e };
689
708
  };
690
709
  }
691
- function Rr(r, e) {
710
+ function Tr(r, e) {
692
711
  return function(n, t) {
693
712
  if (typeof n > "u") return;
694
713
  if (!n) return { value: n };
695
- const a = v(t, r);
696
- if (S(a)) {
714
+ const a = _(t, r);
715
+ if (O(a)) {
697
716
  if (a.length === 1)
698
717
  return { value: a[0], path: r };
699
718
  if (a.length === 0 && e != null && e.unsetIfEmpty)
@@ -705,12 +724,12 @@ function Rr(r, e) {
705
724
  function de(r) {
706
725
  return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !de(r[e])) : F(r);
707
726
  }
708
- function Ye(r) {
709
- return oe(r, (e) => typeof e == "object" ? de(e) : F(e));
727
+ function Ke(r) {
728
+ return ue(r, (e) => typeof e == "object" ? de(e) : F(e));
710
729
  }
711
730
  function re(r) {
712
731
  const { items: e, ...n } = r;
713
- return /* @__PURE__ */ p.jsx(p.Fragment, { children: e.map((t) => /* @__PURE__ */ p.jsx(
732
+ return /* @__PURE__ */ h.jsx(h.Fragment, { children: e.map((t) => /* @__PURE__ */ h.jsx(
714
733
  Ze,
715
734
  {
716
735
  input: t,
@@ -720,24 +739,24 @@ function re(r) {
720
739
  `${t.inputType}_${t.path}_${t.label}`
721
740
  )) });
722
741
  }
723
- const Ke = Se((r, e) => {
742
+ const ze = Oe((r, e) => {
724
743
  const { inputs: n, className: t, factory: a, withoutWrapper: s } = r;
725
- return s ? /* @__PURE__ */ p.jsxs(je, { children: [
744
+ return s ? /* @__PURE__ */ h.jsxs(je, { children: [
726
745
  n.hero,
727
- /* @__PURE__ */ p.jsx(re, { items: n.inputs, factory: a, withoutWrapper: s })
728
- ] }) : /* @__PURE__ */ p.jsxs("div", { className: t, ref: e, children: [
746
+ /* @__PURE__ */ h.jsx(re, { items: n.inputs, factory: a, withoutWrapper: s })
747
+ ] }) : /* @__PURE__ */ h.jsxs("div", { className: t, ref: e, children: [
729
748
  n.hero,
730
- /* @__PURE__ */ p.jsx(re, { items: n.inputs, factory: a, withoutWrapper: s })
749
+ /* @__PURE__ */ h.jsx(re, { items: n.inputs, factory: a, withoutWrapper: s })
731
750
  ] });
732
751
  });
733
- Ke.displayName = "RenderForm";
734
- function Tr(r) {
752
+ ze.displayName = "RenderForm";
753
+ function Sr(r) {
735
754
  let e = !0;
736
755
  return te(r, (n) => {
737
756
  e = e && (n === "" || ae(n) || F(n));
738
757
  }), e;
739
758
  }
740
- const Or = (r = "") => _e(r.split("_").join(" ")), ze = (r, e = 2) => {
759
+ const Or = (r = "") => _e(r.split("_").join(" ")), er = (r, e = 2) => {
741
760
  let n = !1;
742
761
  const t = () => {
743
762
  requestAnimationFrame(() => {
@@ -748,7 +767,7 @@ const Or = (r = "") => _e(r.split("_").join(" ")), ze = (r, e = 2) => {
748
767
  n = !0;
749
768
  };
750
769
  };
751
- function Sr(r) {
770
+ function jr(r) {
752
771
  const {
753
772
  field: { onBlur: e, ...n },
754
773
  ...t
@@ -757,45 +776,45 @@ function Sr(r) {
757
776
  ...t,
758
777
  field: {
759
778
  ...n,
760
- onBlur: ze(e)
779
+ onBlur: er(e)
761
780
  }
762
781
  };
763
782
  }
764
783
  export {
765
- ar as InputComponent,
784
+ ur as InputComponent,
766
785
  Ze as InputComponentRenderer,
767
- ue as InputFactory,
786
+ oe as InputFactory,
768
787
  Fe as InputOverrideError,
769
- Ke as RenderForm,
788
+ ze as RenderForm,
770
789
  re as RenderInputs,
771
790
  or as RootForm,
772
- ze as afterFrames,
791
+ er as afterFrames,
773
792
  pr as arrayToObjectOutputTransformer,
774
- mr as collectDefaultValues,
775
- lr as convertDataToFormModel,
776
- dr as convertFormModelToData,
793
+ hr as collectDefaultValues,
794
+ dr as convertDataToFormModel,
795
+ mr as convertFormModelToData,
777
796
  Or as generateReadableLabel,
778
- ur as getDefaultValuesFromFormDefinition,
779
- cr as getTemporaryPath,
797
+ ir as getDefaultValuesFromFormDefinition,
798
+ fr as getTemporaryPath,
780
799
  le as getTransformers,
781
800
  Ue as getValidationSchema,
782
- He as inputTransformValues,
783
- Tr as isChildrenEmpty,
784
- hr as objectToArrayInputTransformer,
785
- Qe as outputTransformValues,
786
- ir as overrideFormDefinition,
801
+ Qe as inputTransformValues,
802
+ Sr as isChildrenEmpty,
803
+ yr as objectToArrayInputTransformer,
804
+ Xe as outputTransformValues,
805
+ cr as overrideFormDefinition,
787
806
  C as processValidationParseResponse,
788
807
  $e as removeTemporaryFieldsValue,
789
808
  Er as shorthandArrayInputTransformer,
790
- Rr as shorthandArrayOutputTransformer,
791
- vr as shorthandObjectInputTransformer,
792
- _r as shorthandObjectOutputTransformer,
793
- yr as unsetEmptyArrayOutputTransformer,
794
- gr as unsetEmptyObjectOutputTransformer,
795
- br as unsetEmptyStringOutputTransformer,
796
- Xe as unsetHiddenInputsValues,
797
- Sr as useController,
809
+ Tr as shorthandArrayOutputTransformer,
810
+ _r as shorthandObjectInputTransformer,
811
+ Rr as shorthandObjectOutputTransformer,
812
+ gr as unsetEmptyArrayOutputTransformer,
813
+ br as unsetEmptyObjectOutputTransformer,
814
+ vr as unsetEmptyStringOutputTransformer,
815
+ Ye as unsetHiddenInputsValues,
816
+ jr as useController,
798
817
  Me as useRootFormContext,
799
- fr as useZodValidationResolver
818
+ lr as useZodValidationResolver
800
819
  };
801
820
  //# sourceMappingURL=index.js.map