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