@harnessio/forms 0.0.7 → 0.0.9

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