@harnessio/forms 0.0.8 → 0.0.10

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,21 +1,21 @@
1
- var Y = Object.defineProperty;
2
- var K = (r, e, n) => e in r ? Y(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var x = (r, e, n) => K(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { isEmpty as T, cloneDeep as C, set as b, get as g, isArray as E, isObject as L, merge as I, isUndefined as q, pick as X, unset as z, isNull as U, omitBy as W, isNil as ee, isString as re, forOwn as te, capitalize as ne } from "lodash-es";
5
- import se, { useMemo as Z, useRef as P, useEffect as O, useCallback as ae, forwardRef as ue } from "react";
6
- import { useFormContext as ie, useForm as oe, FormProvider as ce, appendErrors as fe } from "react-hook-form";
1
+ var K = Object.defineProperty;
2
+ var z = (r, e, n) => e in r ? K(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var P = (r, e, n) => z(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { isEmpty as R, cloneDeep as C, set as b, get as p, forOwn as L, isArray as S, isObject as U, merge as I, isUndefined as q, pick as ee, unset as re, isNull as W, omitBy as G, isNil as te, isString as ne, capitalize as se } from "lodash-es";
5
+ import ae, { useMemo as Z, useRef as x, useEffect as T, useCallback as ue, forwardRef as oe } from "react";
6
+ import { useFormContext as ie, useForm as ce, FormProvider as fe, appendErrors as de } from "react-hook-form";
7
7
  export * from "react-hook-form";
8
8
  import * as m from "zod";
9
- import { toNestErrors as de } from "@hookform/resolvers";
10
- class le extends Error {
9
+ import { toNestErrors as le } from "@hookform/resolvers";
10
+ class me extends Error {
11
11
  constructor(e) {
12
12
  super(`Input component '${e}' is already registered.`);
13
13
  }
14
14
  }
15
15
  class xe {
16
16
  constructor(e) {
17
- x(this, "componentBank");
18
- x(this, "allowOverride");
17
+ P(this, "componentBank");
18
+ P(this, "allowOverride");
19
19
  this.allowOverride = (e == null ? void 0 : e.allowOverride) ?? !1, this.componentBank = /* @__PURE__ */ new Map();
20
20
  }
21
21
  /**
@@ -26,23 +26,23 @@ class xe {
26
26
  */
27
27
  registerComponent(e) {
28
28
  if (!this.allowOverride && this.getComponent(e.internalType))
29
- throw new le(e.internalType);
29
+ throw new me(e.internalType);
30
30
  this.componentBank.set(e.internalType, e);
31
31
  }
32
32
  getComponent(e) {
33
- if (e && !T(e))
33
+ if (e && !R(e))
34
34
  return this.componentBank.get(e);
35
35
  }
36
36
  }
37
- var N = { exports: {} }, S = {};
37
+ var N = { exports: {} }, E = {};
38
38
  /*
39
39
  object-assign
40
40
  (c) Sindre Sorhus
41
41
  @license MIT
42
42
  */
43
- var k, $;
44
- function me() {
45
- if ($) return k;
43
+ var F, $;
44
+ function he() {
45
+ if ($) return F;
46
46
  $ = 1;
47
47
  var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
48
48
  function t(s) {
@@ -57,24 +57,24 @@ function me() {
57
57
  var s = new String("abc");
58
58
  if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
59
59
  return !1;
60
- for (var o = {}, u = 0; u < 10; u++)
61
- o["_" + String.fromCharCode(u)] = u;
62
- var c = Object.getOwnPropertyNames(o).map(function(i) {
63
- return o[i];
60
+ for (var i = {}, u = 0; u < 10; u++)
61
+ i["_" + String.fromCharCode(u)] = u;
62
+ var c = Object.getOwnPropertyNames(i).map(function(o) {
63
+ return i[o];
64
64
  });
65
65
  if (c.join("") !== "0123456789")
66
66
  return !1;
67
67
  var f = {};
68
- return "abcdefghijklmnopqrst".split("").forEach(function(i) {
69
- f[i] = i;
68
+ return "abcdefghijklmnopqrst".split("").forEach(function(o) {
69
+ f[o] = o;
70
70
  }), Object.keys(Object.assign({}, f)).join("") === "abcdefghijklmnopqrst";
71
71
  } catch {
72
72
  return !1;
73
73
  }
74
74
  }
75
- return k = a() ? Object.assign : function(s, o) {
76
- for (var u, c = t(s), f, i = 1; i < arguments.length; i++) {
77
- u = Object(arguments[i]);
75
+ return F = a() ? Object.assign : function(s, i) {
76
+ for (var u, c = t(s), f, o = 1; o < arguments.length; o++) {
77
+ u = Object(arguments[o]);
78
78
  for (var d in u)
79
79
  e.call(u, d) && (c[d] = u[d]);
80
80
  if (r) {
@@ -84,7 +84,7 @@ function me() {
84
84
  }
85
85
  }
86
86
  return c;
87
- }, k;
87
+ }, F;
88
88
  }
89
89
  /** @license React v17.0.2
90
90
  * react-jsx-runtime.production.min.js
@@ -95,29 +95,29 @@ function me() {
95
95
  * LICENSE file in the root directory of this source tree.
96
96
  */
97
97
  var M;
98
- function he() {
99
- if (M) return S;
100
- M = 1, me();
101
- var r = se, e = 60103;
102
- if (S.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
98
+ function ye() {
99
+ if (M) return E;
100
+ M = 1, he();
101
+ var r = ae, e = 60103;
102
+ if (E.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
103
103
  var n = Symbol.for;
104
- e = n("react.element"), S.Fragment = n("react.fragment");
104
+ e = n("react.element"), E.Fragment = n("react.fragment");
105
105
  }
106
106
  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 };
107
- function o(u, c, f) {
108
- var i, d = {}, l = null, h = null;
107
+ function i(u, c, f) {
108
+ var o, d = {}, l = null, h = null;
109
109
  f !== void 0 && (l = "" + f), c.key !== void 0 && (l = "" + c.key), c.ref !== void 0 && (h = c.ref);
110
- for (i in c) a.call(c, i) && !s.hasOwnProperty(i) && (d[i] = c[i]);
111
- if (u && u.defaultProps) for (i in c = u.defaultProps, c) d[i] === void 0 && (d[i] = c[i]);
110
+ for (o in c) a.call(c, o) && !s.hasOwnProperty(o) && (d[o] = c[o]);
111
+ if (u && u.defaultProps) for (o in c = u.defaultProps, c) d[o] === void 0 && (d[o] = c[o]);
112
112
  return { $$typeof: e, type: u, key: l, ref: h, props: d, _owner: t.current };
113
113
  }
114
- return S.jsx = o, S.jsxs = o, S;
114
+ return E.jsx = i, E.jsxs = i, E;
115
115
  }
116
116
  var B;
117
- function ye() {
118
- return B || (B = 1, N.exports = he()), N.exports;
117
+ function pe() {
118
+ return B || (B = 1, N.exports = ye()), N.exports;
119
119
  }
120
- var y = ye();
120
+ var y = pe();
121
121
  function ge({
122
122
  path: r,
123
123
  factory: e,
@@ -125,13 +125,13 @@ function ge({
125
125
  onChange: t,
126
126
  readonly: a,
127
127
  initialValues: s,
128
- input: o
128
+ input: i
129
129
  }) {
130
130
  const { formState: u, watch: c } = ie(), {
131
131
  metadata: f = {},
132
- fixedValues: i = {}
132
+ fixedValues: o = {}
133
133
  /*getValuesWithDependencies*/
134
- } = {}, d = e == null ? void 0 : e.getComponent(o.inputType), l = Z(
134
+ } = {}, d = e == null ? void 0 : e.getComponent(i.inputType), l = Z(
135
135
  () => ({
136
136
  path: r,
137
137
  initialValues: s,
@@ -139,31 +139,31 @@ function ge({
139
139
  onChange: t,
140
140
  factory: e,
141
141
  readonly: a,
142
- input: o
142
+ input: i
143
143
  }),
144
- [e, s, o, t, n, r, a, u.errors]
145
- ), h = c(), _ = C(h);
146
- i && Object.keys(i).forEach((p) => {
147
- const Q = i[p];
148
- b(_, p, Q);
144
+ [e, s, i, t, n, r, a, u.errors]
145
+ ), h = c(), v = C(h);
146
+ o && Object.keys(o).forEach((g) => {
147
+ const Y = o[g];
148
+ b(v, g, Y);
149
149
  });
150
- const v = !o.isVisible || (o == null ? void 0 : o.isVisible(_, f)), j = Z(() => v ? /* @__PURE__ */ y.jsxs(y.Fragment, { children: [
151
- o.before ? o.before : null,
150
+ const _ = !i.isVisible || (i == null ? void 0 : i.isVisible(v, f)), j = Z(() => _ ? /* @__PURE__ */ y.jsxs(y.Fragment, { children: [
151
+ i.before ? i.before : null,
152
152
  d == null ? void 0 : d.renderComponent(l),
153
- o.after ? o.after : null
154
- ] }) : null, [l, o.after, o.before, d, v, u.errors]);
155
- return d ? v ? j : null : /* @__PURE__ */ y.jsxs("p", { children: [
153
+ i.after ? i.after : null
154
+ ] }) : null, [l, i.after, i.before, d, _, u.errors]);
155
+ return d ? _ ? j : null : /* @__PURE__ */ y.jsxs("p", { children: [
156
156
  "Input component not found (internal type: ",
157
- o.inputType,
157
+ i.inputType,
158
158
  ")"
159
159
  ] });
160
160
  }
161
- class Pe {
161
+ class Ne {
162
162
  getType() {
163
163
  return this.internalType;
164
164
  }
165
165
  }
166
- function Ne(r) {
166
+ function Fe(r) {
167
167
  const {
168
168
  mode: e = "onSubmit",
169
169
  resolver: n,
@@ -171,7 +171,7 @@ function Ne(r) {
171
171
  shouldFocusError: a,
172
172
  // validateAfterFirstSubmit,
173
173
  onValuesChange: s,
174
- onValidationChange: o,
174
+ onValidationChange: i,
175
175
  onSubmit: u,
176
176
  // validate,
177
177
  // validateDebounceInterval,
@@ -180,18 +180,18 @@ function Ne(r) {
180
180
  children: c,
181
181
  // fixedValues
182
182
  autoFocusPath: f
183
- } = r, i = oe({
183
+ } = r, o = ce({
184
184
  mode: e ?? "onSubmit",
185
185
  reValidateMode: "onChange",
186
186
  defaultValues: t,
187
187
  shouldFocusError: a,
188
188
  resolver: n
189
- }), d = P(!1);
190
- O(() => {
191
- i.reset(t, {});
192
- }, [i.reset, t]), O(() => {
193
- const p = requestIdleCallback(() => {
194
- i.reset({}, {
189
+ }), d = x(!1);
190
+ T(() => {
191
+ o.reset(t, {});
192
+ }, [o.reset, t]), T(() => {
193
+ const g = requestIdleCallback(() => {
194
+ o.reset({}, {
195
195
  keepErrors: !0,
196
196
  keepDirty: !0,
197
197
  keepDirtyValues: !0,
@@ -204,41 +204,41 @@ function Ne(r) {
204
204
  keepSubmitCount: !0
205
205
  });
206
206
  });
207
- return () => cancelIdleCallback(p);
207
+ return () => cancelIdleCallback(g);
208
208
  }, []);
209
- const { getValues: l, handleSubmit: h } = i, _ = l(), v = P(!0);
210
- O(() => {
211
- if (v.current) {
212
- v.current = !1;
209
+ const { getValues: l, handleSubmit: h } = o, v = l(), _ = x(!0);
210
+ T(() => {
211
+ if (_.current) {
212
+ _.current = !1;
213
213
  return;
214
214
  }
215
- s == null || s({ ..._ }), d.current === !0 && i.trigger();
216
- }, [JSON.stringify(_)]);
217
- const j = P(!0);
218
- return O(() => {
215
+ s == null || s({ ...v }), d.current === !0 && o.trigger();
216
+ }, [JSON.stringify(v)]);
217
+ const j = x(!0);
218
+ return T(() => {
219
219
  if (j.current) {
220
220
  j.current = !1;
221
221
  return;
222
222
  }
223
- o == null || o({ isValid: i.formState.isValid, isSubmitted: i.formState.isSubmitted });
224
- }, [i.formState.isValid, i.formState.isSubmitted]), O(() => {
223
+ i == null || i({ isValid: o.formState.isValid, isSubmitted: o.formState.isSubmitted });
224
+ }, [o.formState.isValid, o.formState.isSubmitted]), T(() => {
225
225
  if (f)
226
226
  if ("requestIdleCallback" in window) {
227
- const p = requestIdleCallback(() => {
228
- i.setFocus(f);
227
+ const g = requestIdleCallback(() => {
228
+ o.setFocus(f);
229
229
  });
230
- return () => cancelIdleCallback(p);
230
+ return () => cancelIdleCallback(g);
231
231
  } else {
232
- const p = setTimeout(() => {
233
- i.setFocus(f);
232
+ const g = setTimeout(() => {
233
+ o.setFocus(f);
234
234
  }, 100);
235
- return () => clearTimeout(p);
235
+ return () => clearTimeout(g);
236
236
  }
237
- }, [i]), /* @__PURE__ */ y.jsx(ce, { ...i, children: typeof c == "function" ? c({
238
- ...i,
237
+ }, [o]), /* @__PURE__ */ y.jsx(fe, { ...o, children: typeof c == "function" ? c({
238
+ ...o,
239
239
  submitForm: async () => {
240
- u && (d.current = !0, h((p) => {
241
- u(p);
240
+ u && (d.current = !0, h((g) => {
241
+ u(g);
242
242
  })());
243
243
  }
244
244
  }) : c });
@@ -248,30 +248,37 @@ const ke = (r) => {
248
248
  const e = {};
249
249
  return (n = r == null ? void 0 : r.inputs) == null || n.forEach((t) => {
250
250
  var a;
251
- t.inputType === "group" && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
252
- typeof g(e, s.path) > "u" && b(e, s.path, s.default);
253
- })), typeof g(e, t.path) > "u" && b(e, t.path, t.default);
251
+ (t.inputType === "group" || t.inputType === "accordion") && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
252
+ typeof p(e, s.path) > "u" && b(e, s.path, s.default);
253
+ })), typeof p(e, t.path) > "u" && b(e, t.path, t.default);
254
254
  }), e;
255
255
  };
256
- function Fe(r, e) {
256
+ function Ae(r, e) {
257
257
  const n = r.inputs.map((t) => {
258
- const a = pe(e, t.path);
258
+ const a = be(e, t.path);
259
259
  return a || t;
260
260
  });
261
261
  return { ...r, inputs: n };
262
262
  }
263
- function pe(r, e) {
263
+ function be(r, e) {
264
264
  return r.inputs.find((n) => n.path === e);
265
265
  }
266
- const be = "Required field";
267
- function R(r) {
266
+ const H = "__temp_", De = (r) => H + r.split(".").join("__");
267
+ function Ze(r) {
268
+ const e = { ...r };
269
+ return L(e, (n, t) => {
270
+ t.startsWith(H) && delete e[t];
271
+ }), e;
272
+ }
273
+ const _e = "Required field";
274
+ function O(r) {
268
275
  const e = typeof r == "string" ? JSON.parse(r) : r;
269
276
  if (typeof e == "string")
270
277
  return e;
271
- if (E(e))
272
- return R(e[0]);
278
+ if (S(e))
279
+ return O(e[0]);
273
280
  const n = e;
274
- return L(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
281
+ return U(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
275
282
  }
276
283
  function ve(r, e, n) {
277
284
  let t = {};
@@ -286,32 +293,32 @@ function V(r, e, n) {
286
293
  return Object.keys(r).forEach((a) => {
287
294
  const {
288
295
  _requiredOnly: s,
289
- _schemaObj: o,
296
+ _schemaObj: i,
290
297
  _input: u,
291
298
  _isList: c,
292
299
  _isArrayItem: f,
293
- _schema: i
300
+ _schema: o
294
301
  /*...nestedSchemaObj*/
295
302
  } = r[a];
296
- if (c && o && u) {
297
- const d = m.array(m.object(V(o, e, n))).optional(), l = J(i, u, e, n, d);
303
+ if (c && i && u) {
304
+ const d = m.array(m.object(V(i, e, n))).optional(), l = J(o, u, e, n, d);
298
305
  t[a] = l;
299
306
  } else if (f && u) {
300
- const d = o != null && o.___array ? V({ ___array: o.___array }, e, n) : { ___array: m.any() }, l = m.array(d.___array).optional(), h = J(i, u, e, n, l);
307
+ const d = i != null && i.___array ? V({ ___array: i.___array }, e, n) : { ___array: m.any() }, l = m.array(d.___array).optional(), h = J(o, u, e, n, l);
301
308
  t[a] = h;
302
- } else if (i && u) {
303
- const d = _e(i, u, e, n);
309
+ } else if (o && u) {
310
+ const d = Ee(o, u, e, n);
304
311
  t[a] = d;
305
312
  } else s && u ? t[a] = A(u, n) : t[a] = m.object(V(r[a], e, n)).optional();
306
313
  }), t;
307
314
  }
308
- function _e(r, e, n, t) {
315
+ function Ee(r, e, n, t) {
309
316
  return m.any().optional().superRefine(async (a, s) => {
310
317
  var u, c;
311
318
  if (e.required && !(await A(e, t).safeParseAsync(a)).success)
312
319
  return s.addIssue({
313
320
  code: m.ZodIssueCode.custom,
314
- message: F(e, t)
321
+ message: k(e, t)
315
322
  }), m.NEVER;
316
323
  if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
317
324
  const f = (c = t == null ? void 0 : t.validationConfig) == null ? void 0 : c.globalValidation(a, e, t.metadata);
@@ -323,11 +330,11 @@ function _e(r, e, n, t) {
323
330
  if (!f.continue)
324
331
  return !0;
325
332
  }
326
- const o = G(r, n);
327
- if (o) {
328
- const f = await o.safeParseAsync(a);
333
+ const i = Q(r, n);
334
+ if (i) {
335
+ const f = await i.safeParseAsync(a);
329
336
  if (!f.success) {
330
- const i = R(f == null ? void 0 : f.error.message), d = i === "Required" ? F(e, t) : i;
337
+ const o = O(f == null ? void 0 : f.error.message), d = o === "Required" ? k(e, t) : o;
331
338
  s.addIssue({
332
339
  code: m.ZodIssueCode.custom,
333
340
  message: d
@@ -337,47 +344,47 @@ function _e(r, e, n, t) {
337
344
  });
338
345
  }
339
346
  function J(r, e, n, t, a) {
340
- return m.any().optional().superRefine(async (s, o) => {
341
- var i, d;
347
+ return m.any().optional().superRefine(async (s, i) => {
348
+ var o, d;
342
349
  const c = await A(e, t).safeParseAsync(s);
343
350
  if (e.required && !c.success) {
344
- const l = R(c.error.message);
345
- return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
351
+ const l = O(c.error.message);
352
+ return i.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
346
353
  }
347
354
  if (!e.required && !c.success)
348
355
  return m.NEVER;
349
- if ((i = t == null ? void 0 : t.validationConfig) != null && i.globalValidation) {
356
+ if ((o = t == null ? void 0 : t.validationConfig) != null && o.globalValidation) {
350
357
  const l = (d = t == null ? void 0 : t.validationConfig) == null ? void 0 : d.globalValidation(s, e, t.metadata);
351
358
  if (l.error)
352
- return o.addIssue({
359
+ return i.addIssue({
353
360
  code: m.ZodIssueCode.custom,
354
- message: R(l.error)
361
+ message: O(l.error)
355
362
  }), m.NEVER;
356
363
  if (!l.continue)
357
364
  return m.NEVER;
358
365
  }
359
- if (!E(s))
360
- return o.addIssue({
366
+ if (!S(s))
367
+ return i.addIssue({
361
368
  code: m.ZodIssueCode.custom,
362
369
  message: "'Value is not array'"
363
370
  }), m.NEVER;
364
- const f = G(r, n);
371
+ const f = Q(r, n);
365
372
  if (f) {
366
373
  const l = await f.safeParseAsync(s);
367
374
  if (!l.success)
368
- return o.addIssue({
375
+ return i.addIssue({
369
376
  code: m.ZodIssueCode.custom,
370
- message: R(l.error.message)
377
+ message: O(l.error.message)
371
378
  }), m.NEVER;
372
379
  }
373
380
  }).pipe(a ?? m.any());
374
381
  }
375
382
  function w(r, e, n, t, a) {
376
383
  e.forEach((s) => {
377
- var u, c, f, i, d;
378
- const o = n;
379
- if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
380
- const l = g(r, s.path);
384
+ var u, c, f, o, d;
385
+ const i = n;
386
+ if (!s.isVisible || (u = s.isVisible) != null && u.call(s, i, t == null ? void 0 : t.metadata)) {
387
+ const l = p(r, s.path);
381
388
  if ((c = s.validation) != null && c.schema ? b(
382
389
  r,
383
390
  s.path,
@@ -389,17 +396,17 @@ function w(r, e, n, t, a) {
389
396
  const h = {};
390
397
  w(
391
398
  h,
392
- s.inputConfig.inputs.map((v) => ({
393
- ...v,
394
- path: v.relativePath
399
+ s.inputConfig.inputs.map((_) => ({
400
+ ..._,
401
+ path: _.relativePath
395
402
  })),
396
403
  n,
397
404
  t
398
405
  );
399
- const _ = g(r, s.path);
400
- b(r, s.path, I(_, { _schemaObj: h, _isList: !0, _input: s }));
406
+ const v = p(r, s.path);
407
+ b(r, s.path, I(v, { _schemaObj: h, _isList: !0, _input: s }));
401
408
  }
402
- if (!((i = s.validation) != null && i.schema) && s.inputType === "array") {
409
+ if (!((o = s.validation) != null && o.schema) && s.inputType === "array") {
403
410
  const h = {};
404
411
  w(
405
412
  h,
@@ -420,37 +427,37 @@ function w(r, e, n, t, a) {
420
427
  }
421
428
  });
422
429
  }
423
- function F(r, e) {
430
+ function k(r, e) {
424
431
  var n, t, a;
425
- 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) ?? be;
432
+ 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) ?? _e;
426
433
  }
427
434
  function A(r, e) {
428
- var t, a, s, o, u, c;
435
+ var t, a, s, i, u, c;
429
436
  if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
430
- return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
437
+ return (i = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : i[r.inputType];
431
438
  if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
432
439
  return (c = e == null ? void 0 : e.validationConfig) == null ? void 0 : c.requiredSchema;
433
- const n = F(r, e);
434
- return m.any().optional().superRefine((f, i) => {
435
- typeof f == "object" && T(f) && i.addIssue({
440
+ const n = k(r, e);
441
+ return m.any().optional().superRefine((f, o) => {
442
+ typeof f == "object" && R(f) && o.addIssue({
436
443
  code: m.ZodIssueCode.custom,
437
444
  message: n
438
- }), (q(f) || f === "") && i.addIssue({
445
+ }), (q(f) || f === "") && o.addIssue({
439
446
  code: m.ZodIssueCode.custom,
440
447
  message: n
441
448
  });
442
449
  });
443
450
  }
444
- function G(r, e) {
451
+ function Q(r, e) {
445
452
  if (r instanceof m.ZodType)
446
453
  return r;
447
454
  if (typeof r == "function")
448
455
  return r(e);
449
456
  }
450
- const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Ee = (r, e) => {
457
+ const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Te = (r, e) => {
451
458
  const n = {};
452
459
  for (; r.length; ) {
453
- const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
460
+ const t = r[0], { code: a, message: s, path: i } = t, u = i.join(".");
454
461
  if (!n[u])
455
462
  if ("unionErrors" in t) {
456
463
  const c = t.unionErrors[0].errors[0];
@@ -463,7 +470,7 @@ const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Ee = (r, e) => {
463
470
  "unionErrors" in t && t.unionErrors.forEach((c) => c.errors.forEach((f) => r.push(f)));
464
471
  {
465
472
  const c = n[u].types, f = c && c[t.code];
466
- n[u] = fe(
473
+ n[u] = de(
467
474
  u,
468
475
  e,
469
476
  n,
@@ -475,8 +482,8 @@ const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Ee = (r, e) => {
475
482
  }
476
483
  return n;
477
484
  };
478
- function Ae(r, e) {
479
- return ae(
485
+ function $e(r, e) {
486
+ return ue(
480
487
  async (n, t, a) => {
481
488
  try {
482
489
  return await ve(r, n, e).parseAsync(n), {
@@ -488,7 +495,7 @@ function Ae(r, e) {
488
495
  if (Se(s))
489
496
  return {
490
497
  values: {},
491
- errors: de(Ee(s.errors, !0), a)
498
+ errors: le(Te(s.errors, !0), a)
492
499
  };
493
500
  throw s;
494
501
  }
@@ -496,51 +503,45 @@ function Ae(r, e) {
496
503
  [r]
497
504
  );
498
505
  }
499
- function De(r, e) {
506
+ function Me(r, e) {
500
507
  const n = C(r);
501
508
  return e.forEach((t) => {
502
- if (t.inputTransform) {
503
- const a = E(t.inputTransform) ? t.inputTransform : [t.inputTransform], s = g(n, t.path);
504
- a.forEach((o) => {
505
- const u = o(s, n);
506
- u && b(n, u.path ?? t.path, u.value);
507
- });
508
- }
509
+ t.inputTransform && (S(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
510
+ const i = p(n, t.path), u = s(i, n);
511
+ u && b(n, u.path ?? t.path, u.value);
512
+ });
509
513
  }), n;
510
514
  }
511
- function Ze(r, e) {
515
+ function Be(r, e) {
512
516
  const n = C(r);
513
517
  return e.forEach((t) => {
514
- if (t.outputTransform) {
515
- const a = E(t.outputTransform) ? t.outputTransform : [t.outputTransform], s = g(n, t.path);
516
- a.forEach((o) => {
517
- const u = o(s, n);
518
- u && b(n, u.path ?? t.path, u.value);
519
- });
520
- }
518
+ t.outputTransform && (S(t.outputTransform) ? t.outputTransform : [t.outputTransform]).forEach((s) => {
519
+ const i = p(n, t.path), u = s(i, n);
520
+ u && b(n, u.path ?? t.path, u.value);
521
+ });
521
522
  }), n;
522
523
  }
523
524
  function D(r) {
524
- return r.reduce((n, t) => t.inputType === "group" && t.inputs ? [...n, t, ...D(t.inputs)] : [...n, t], []);
525
+ return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...D(t.inputs)] : [...n, t], []);
525
526
  }
526
- function $e(r) {
527
+ function Je(r) {
527
528
  const n = D(r.inputs).reduce((t, a) => {
528
529
  const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
529
530
  return (a.inputTransform || a.outputTransform) && t.push({
530
- ...X(a, "path", "inputTransform", "outputTransform"),
531
+ ...ee(a, "path", "inputTransform", "outputTransform"),
531
532
  level: a.path.split(".").length,
532
533
  isPrimitive: s
533
534
  }), t;
534
535
  }, []);
535
536
  return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
536
537
  }
537
- function Me(r, e, n) {
538
+ function Le(r, e, n) {
538
539
  const t = D(r.inputs), a = C(e);
539
540
  return t.forEach((s) => {
540
- s.isVisible && !s.isVisible(e, n) && z(a, s.path);
541
+ s.isVisible && !s.isVisible(e, n) && re(a, s.path);
541
542
  }), a;
542
543
  }
543
- function Be() {
544
+ function Ue() {
544
545
  return function(r, e) {
545
546
  if (!(typeof r > "u"))
546
547
  return r ? {
@@ -548,7 +549,7 @@ function Be() {
548
549
  } : { value: r };
549
550
  };
550
551
  }
551
- function Je(r) {
552
+ function We(r) {
552
553
  return function(e, n) {
553
554
  if (typeof e > "u") return;
554
555
  if (!e) return { value: e };
@@ -558,43 +559,43 @@ function Je(r) {
558
559
  return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
559
560
  };
560
561
  }
561
- function Le() {
562
+ function Ge() {
562
563
  return function(r, e) {
563
564
  if (!(typeof r > "u"))
564
- return E(r) && T(r) ? { value: void 0 } : { value: r };
565
+ return S(r) && R(r) ? { value: void 0 } : { value: r };
565
566
  };
566
567
  }
567
- function Ue(r) {
568
+ function He(r) {
568
569
  return function(e, n) {
569
- const t = r ? g(n, r) : e;
570
+ const t = r ? p(n, r) : e;
570
571
  if (!(typeof t > "u")) {
571
- if (U(t)) return { value: void 0, path: r };
572
- if (L(t)) {
573
- const a = W(t, ee);
574
- if (T(a))
572
+ if (W(t)) return { value: void 0, path: r };
573
+ if (U(t)) {
574
+ const a = G(t, te);
575
+ if (R(a))
575
576
  return { value: void 0, path: r };
576
577
  }
577
578
  return { value: t, path: r };
578
579
  }
579
580
  };
580
581
  }
581
- function We() {
582
+ function Qe() {
582
583
  return function(r, e) {
583
584
  if (!(typeof r > "u"))
584
- return re(r) && T(r) ? { value: void 0 } : { value: r };
585
+ return ne(r) && R(r) ? { value: void 0 } : { value: r };
585
586
  };
586
587
  }
587
- function Ge(r) {
588
+ function Xe(r) {
588
589
  return function(e, n) {
589
- const t = g(n, r);
590
+ const t = p(n, r);
590
591
  return typeof t == "string" ? { value: t } : { value: e };
591
592
  };
592
593
  }
593
- function He(r) {
594
+ function Ye(r) {
594
595
  return function(e, n) {
595
596
  if (typeof e > "u") return;
596
597
  if (!e) return { value: e };
597
- const t = g(n, r);
598
+ const t = p(n, r);
598
599
  if (typeof t == "object") {
599
600
  const a = Oe(t);
600
601
  if (Object.getOwnPropertyNames(a).length === 1)
@@ -603,19 +604,19 @@ function He(r) {
603
604
  return { value: e };
604
605
  };
605
606
  }
606
- function Qe(r) {
607
+ function Ke(r) {
607
608
  return function(e, n) {
608
609
  if (typeof e > "u") return;
609
- const t = g(n, r);
610
+ const t = p(n, r);
610
611
  return typeof t == "string" ? { value: [t] } : { value: e };
611
612
  };
612
613
  }
613
- function Ye(r, e) {
614
+ function ze(r, e) {
614
615
  return function(n, t) {
615
616
  if (typeof n > "u") return;
616
617
  if (!n) return { value: n };
617
- const a = g(t, r);
618
- if (E(a)) {
618
+ const a = p(t, r);
619
+ if (S(a)) {
619
620
  if (a.length === 1)
620
621
  return { value: a[0], path: r };
621
622
  if (a.length === 0 && e != null && e.unsetIfEmpty)
@@ -624,66 +625,68 @@ function Ye(r, e) {
624
625
  return { value: n };
625
626
  };
626
627
  }
627
- function H(r) {
628
- return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !H(r[e])) : q(r);
628
+ function X(r) {
629
+ return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !X(r[e])) : q(r);
629
630
  }
630
631
  function Oe(r) {
631
- return W(r, (e) => typeof e == "object" ? H(e) : q(e));
632
+ return G(r, (e) => typeof e == "object" ? X(e) : q(e));
632
633
  }
633
634
  function Re({ input: r, factory: e }) {
634
635
  const { prefix: n = "" } = {};
635
636
  return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ge, { path: `${n}${r.path}`, factory: e, readonly: !1, input: r }) });
636
637
  }
637
- function Te(r) {
638
+ function je(r) {
638
639
  const { items: e, factory: n } = r;
639
640
  return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => {
640
641
  const a = `${t.inputType}_${t.path}_${t.label}`;
641
642
  return /* @__PURE__ */ y.jsx(Re, { input: t, factory: n }, a);
642
643
  }) });
643
644
  }
644
- const je = ue((r, e) => {
645
+ const Ie = oe((r, e) => {
645
646
  const { inputs: n, className: t, factory: a } = r;
646
647
  return /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
647
648
  n.hero,
648
- /* @__PURE__ */ y.jsx(Te, { items: n.inputs, factory: a })
649
+ /* @__PURE__ */ y.jsx(je, { items: n.inputs, factory: a })
649
650
  ] });
650
651
  });
651
- je.displayName = "RenderForm";
652
- function Ke(r) {
652
+ Ie.displayName = "RenderForm";
653
+ function er(r) {
653
654
  let e = !0;
654
- return te(r, (n) => {
655
- e = e && (n === "" || U(n) || q(n));
655
+ return L(r, (n) => {
656
+ e = e && (n === "" || W(n) || q(n));
656
657
  }), e;
657
658
  }
658
- const Xe = (r = "") => ne(r.split("_").join(" "));
659
+ const rr = (r = "") => se(r.split("_").join(" "));
659
660
  export {
660
- Pe as InputComponent,
661
+ Ne as InputComponent,
661
662
  ge as InputComponentRenderer,
662
663
  xe as InputFactory,
663
- le as InputOverrideError,
664
- je as RenderForm,
665
- Te as RenderInputs,
666
- Ne as RootForm,
664
+ me as InputOverrideError,
665
+ Ie as RenderForm,
666
+ je as RenderInputs,
667
+ Fe as RootForm,
667
668
  Re as Row,
668
- Je as arrayToObjectOutputTransformer,
669
- Xe as generateReadableLabel,
669
+ We as arrayToObjectOutputTransformer,
670
+ rr as generateReadableLabel,
670
671
  ke as getDefaultValuesFromFormDefinition,
671
- $e as getTransformers,
672
+ De as getTemporaryPath,
673
+ Je as getTransformers,
672
674
  ve as getValidationSchema,
673
- De as inputTransformValues,
674
- Ke as isChildrenEmpty,
675
- Be as objectToArrayInputTransformer,
676
- Ze as outputTransformValues,
677
- Fe as overrideFormDefinition,
678
- R as processValidationParseResponse,
679
- Qe as shorthandArrayInputTransformer,
680
- Ye as shorthandArrayOutputTransformer,
681
- Ge as shorthandObjectInputTransformer,
682
- He as shorthandObjectOutputTransformer,
683
- Le as unsetEmptyArrayOutputTransformer,
684
- Ue as unsetEmptyObjectOutputTransformer,
685
- We as unsetEmptyStringOutputTransformer,
686
- Me as unsetHiddenInputsValues,
687
- Ae as useZodValidationResolver
675
+ Me as inputTransformValues,
676
+ er as isChildrenEmpty,
677
+ Ue as objectToArrayInputTransformer,
678
+ Be as outputTransformValues,
679
+ Ae as overrideFormDefinition,
680
+ O as processValidationParseResponse,
681
+ Ze as removeTemporaryFieldsValue,
682
+ Ke as shorthandArrayInputTransformer,
683
+ ze as shorthandArrayOutputTransformer,
684
+ Xe as shorthandObjectInputTransformer,
685
+ Ye as shorthandObjectOutputTransformer,
686
+ Ge as unsetEmptyArrayOutputTransformer,
687
+ He as unsetEmptyObjectOutputTransformer,
688
+ Qe as unsetEmptyStringOutputTransformer,
689
+ Le as unsetHiddenInputsValues,
690
+ $e as useZodValidationResolver
688
691
  };
689
692
  //# sourceMappingURL=index.js.map