@jfdevelops/react-multi-step-form 1.0.0-alpha.10 → 1.0.0-alpha.13

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.mjs CHANGED
@@ -197,12 +197,12 @@ var V;
197
197
  }
198
198
  function t(i, l, d) {
199
199
  const c = l.split(".");
200
- let m = i;
200
+ let h = i;
201
201
  for (let _ = 0; _ < c.length; _++) {
202
202
  const $ = c[_];
203
- _ === c.length - 1 ? m[$] !== void 0 && typeof m[$] == "object" && typeof d == "object" && d !== null ? Object.assign(m[$], d) : m[$] = d : ((typeof m[$] != "object" || m[$] === null) && (m[$] = {}), m = m[$]);
203
+ _ === c.length - 1 ? h[$] !== void 0 && typeof h[$] == "object" && typeof d == "object" && d !== null ? Object.assign(h[$], d) : h[$] = d : ((typeof h[$] != "object" || h[$] === null) && (h[$] = {}), h = h[$]);
204
204
  }
205
- return m;
205
+ return h;
206
206
  }
207
207
  o.setBy = t;
208
208
  function r(i) {
@@ -213,21 +213,21 @@ var V;
213
213
  if (d.length === 1)
214
214
  return e(i, d[0]);
215
215
  const c = {};
216
- for (const m of d) {
217
- const _ = e(i, m);
218
- t(c, m, _);
216
+ for (const h of d) {
217
+ const _ = e(i, h);
218
+ t(c, h, _);
219
219
  }
220
220
  return c;
221
221
  }
222
222
  o.pickBy = s;
223
223
  function n(i) {
224
224
  const l = [];
225
- function d(c, m = "") {
225
+ function d(c, h = "") {
226
226
  if (c == null || typeof c != "object" || Array.isArray(c))
227
227
  return;
228
228
  const _ = Object.keys(c);
229
229
  for (const $ of _) {
230
- const A = m ? `${m}.${$}` : $;
230
+ const A = h ? `${h}.${$}` : $;
231
231
  l.push(A);
232
232
  const T = c[$];
233
233
  T != null && typeof T == "object" && !Array.isArray(T) && d(T, A);
@@ -257,19 +257,19 @@ var V;
257
257
  if (typeof i == "function")
258
258
  return i;
259
259
  const d = u(l);
260
- let c = i, m;
260
+ let c = i, h;
261
261
  for (const _ of d) {
262
262
  if (!c) break;
263
263
  if (typeof c == "function") {
264
- m = c;
264
+ h = c;
265
265
  break;
266
266
  }
267
267
  if (c = c[_], typeof c == "function") {
268
- m = c;
268
+ h = c;
269
269
  break;
270
270
  }
271
271
  }
272
- return m;
272
+ return h;
273
273
  }
274
274
  function g(i, l, d) {
275
275
  const c = S(d, l);
@@ -278,19 +278,19 @@ var V;
278
278
  function p(i) {
279
279
  return typeof i == "object" && i !== null;
280
280
  }
281
- function f(i, l, d, c, m) {
281
+ function f(i, l, d, c, h) {
282
282
  if (i === l)
283
283
  return c;
284
284
  if (i === null || l === null || typeof i != "object" || typeof l != "object") {
285
285
  const $ = d || "(root)";
286
286
  return typeof i != typeof l ? (c.push({
287
287
  path: $,
288
- expected: g(i, $, m.transformExpected),
288
+ expected: g(i, $, h.transformExpected),
289
289
  actual: l,
290
290
  reason: "type-mismatch"
291
- }), c) : (m.includeValueMismatch && c.push({
291
+ }), c) : (h.includeValueMismatch && c.push({
292
292
  path: $,
293
- expected: g(i, $, m.transformExpected),
293
+ expected: g(i, $, h.transformExpected),
294
294
  actual: l,
295
295
  reason: "value-mismatch"
296
296
  }), c);
@@ -300,7 +300,7 @@ var V;
300
300
  const A = d || "(root)";
301
301
  return c.push({
302
302
  path: A,
303
- expected: g(i, A, m.transformExpected),
303
+ expected: g(i, A, h.transformExpected),
304
304
  actual: l,
305
305
  reason: "type-mismatch"
306
306
  }), c;
@@ -308,7 +308,7 @@ var V;
308
308
  const $ = i.length;
309
309
  for (let A = 0; A < $; A++) {
310
310
  const T = i[A], C = l[A], N = d === "" ? `[${A}]` : `${d}[${A}]`;
311
- f(T, C, N, c, m);
311
+ f(T, C, N, c, h);
312
312
  }
313
313
  return c;
314
314
  }
@@ -319,13 +319,13 @@ var V;
319
319
  if (!(T in l)) {
320
320
  c.push({
321
321
  path: F,
322
- expected: g(C, F, m.transformExpected),
322
+ expected: g(C, F, h.transformExpected),
323
323
  actual: void 0,
324
324
  reason: "missing-key"
325
325
  });
326
326
  continue;
327
327
  }
328
- f(C, N, F, c, m);
328
+ f(C, N, F, c, h);
329
329
  }
330
330
  for (const T of A)
331
331
  if (!(T in i)) {
@@ -342,19 +342,19 @@ var V;
342
342
  const _ = d || "(root)";
343
343
  return typeof i != typeof l ? c.push({
344
344
  path: _,
345
- expected: g(i, _, m.transformExpected),
345
+ expected: g(i, _, h.transformExpected),
346
346
  actual: l,
347
347
  reason: "type-mismatch"
348
- }) : m.includeValueMismatch && c.push({
348
+ }) : h.includeValueMismatch && c.push({
349
349
  path: _,
350
- expected: g(i, _, m.transformExpected),
350
+ expected: g(i, _, h.transformExpected),
351
351
  actual: l,
352
352
  reason: "value-mismatch"
353
353
  }), c;
354
354
  }
355
355
  function v(i, l, d, c) {
356
- const m = s(i, ...l), _ = [], $ = l.length === 1 ? l[0] : "";
357
- return f(m, d, $, _, {
356
+ const h = s(i, ...l), _ = [], $ = l.length === 1 ? l[0] : "";
357
+ return f(h, d, $, _, {
358
358
  transformExpected: c?.transformExpected
359
359
  }), {
360
360
  ok: _.length === 0,
@@ -371,7 +371,7 @@ var V;
371
371
  return String(i);
372
372
  }
373
373
  }
374
- function h(i) {
374
+ function m(i) {
375
375
  switch (i.reason) {
376
376
  case "missing-key":
377
377
  return "Missing key";
@@ -392,7 +392,7 @@ var V;
392
392
  for (const d of i.mismatches)
393
393
  l.push(
394
394
  `
395
- ● ${h(d)} at "${d.path}":`,
395
+ ● ${m(d)} at "${d.path}":`,
396
396
  ` expected: ${y(d.expected)}`,
397
397
  ` actual: ${y(d.actual)}`,
398
398
  ""
@@ -409,7 +409,7 @@ var V;
409
409
  o.printMismatches = O;
410
410
  function w(i, l, d) {
411
411
  const c = l.split(".");
412
- function m(_, $) {
412
+ function h(_, $) {
413
413
  const A = c[$], T = Array.isArray(_) ? [..._] : { ..._ };
414
414
  if ($ === c.length - 1) {
415
415
  let P = _ && typeof _ == "object" ? T : {};
@@ -418,28 +418,28 @@ var V;
418
418
  [A]: d
419
419
  }, P;
420
420
  }
421
- const C = _ && typeof _ == "object" ? _[A] : void 0, N = m(C ?? {}, $ + 1);
421
+ const C = _ && typeof _ == "object" ? _[A] : void 0, N = h(C ?? {}, $ + 1);
422
422
  let F = _ && typeof _ == "object" ? T : {};
423
423
  return F = {
424
424
  ...F,
425
425
  [A]: N
426
426
  }, F;
427
427
  }
428
- return m(i, 0);
428
+ return h(i, 0);
429
429
  }
430
430
  function j(i, l, d) {
431
431
  const c = r(l);
432
432
  if (c.length === 0) return i;
433
- let m = i;
433
+ let h = i;
434
434
  if (c.length === 1) {
435
435
  const _ = c[0];
436
- return m = w(m, _, d), m;
436
+ return h = w(h, _, d), h;
437
437
  }
438
438
  for (const _ of c) {
439
439
  const $ = e(d, _);
440
- m = w(m, _, $);
440
+ h = w(h, _, $);
441
441
  }
442
- return m;
442
+ return h;
443
443
  }
444
444
  o.updateAt = j;
445
445
  })(V || (V = {}));
@@ -472,7 +472,7 @@ class re {
472
472
  createStepUpdaterFnImpl(e) {
473
473
  const { targetStep: t, updater: r, ctxData: s, fields: n = "all", debug: a } = e, u = new te({
474
474
  debug: a,
475
- prefix: (h) => `${h}:update${t}`
475
+ prefix: (m) => `${m}:update${t}`
476
476
  });
477
477
  u.info(`${t} will be updated`), E(
478
478
  be(this.value, t),
@@ -485,9 +485,9 @@ class re {
485
485
  typeof s == "function",
486
486
  '[update]: "ctxData" must be a function'
487
487
  ), u.info('Custom "ctx" will be used');
488
- const h = s({ ctx: g });
488
+ const m = s({ ctx: g });
489
489
  E(
490
- typeof h == "object" && Object.keys(h).length > 0,
490
+ typeof m == "object" && Object.keys(m).length > 0,
491
491
  '[update]: "ctxData" must return an object with keys'
492
492
  ), u.info(
493
493
  `Custom "ctx" consists of the following keys: ${new Intl.ListFormat(
@@ -496,10 +496,10 @@ class re {
496
496
  style: "long",
497
497
  type: "conjunction"
498
498
  }
499
- ).format(Object.keys(h))}`
499
+ ).format(Object.keys(m))}`
500
500
  ), f = {
501
501
  ...f,
502
- ...h
502
+ ...m
503
503
  };
504
504
  }
505
505
  const v = Ve(r, {
@@ -511,9 +511,9 @@ class re {
511
511
  typeof v == "object",
512
512
  '[update]: "updater" must be an object or a function that returns an object'
513
513
  );
514
- const h = Object.keys(this.value), b = Object.keys(v);
515
- E(b.length === h.length, () => {
516
- const i = h.filter(
514
+ const m = Object.keys(this.value), b = Object.keys(v);
515
+ E(b.length === m.length, () => {
516
+ const i = m.filter(
517
517
  (d) => !b.includes(d)
518
518
  );
519
519
  return `[update]: "updater" is missing keys ${new Intl.ListFormat("en", {
@@ -542,11 +542,11 @@ class re {
542
542
  }
543
543
  const y = V.createDeep(S);
544
544
  if (Array.isArray(n)) {
545
- const h = M(y, n);
545
+ const m = M(y, n);
546
546
  E(
547
- h.status === "success",
547
+ m.status === "success",
548
548
  `[update]: Found errors with the provided fields
549
- ${h.status === "error" ? U(h.errors) : ""}`
549
+ ${m.status === "error" ? U(m.errors) : ""}`
550
550
  );
551
551
  const { mismatches: b, ok: O } = V.equalsAtPaths(
552
552
  S,
@@ -571,9 +571,9 @@ ${h.status === "error" ? U(h.errors) : ""}`
571
571
  return;
572
572
  }
573
573
  if (typeof n == "object" && Object.keys(n).length > 0) {
574
- const h = V.createDeep(n), b = M(
574
+ const m = V.createDeep(n), b = M(
575
575
  y,
576
- h
576
+ m
577
577
  );
578
578
  E(
579
579
  b.status === "success",
@@ -582,7 +582,7 @@ ${b.status === "error" ? U(b.errors) : ""}`
582
582
  );
583
583
  const { mismatches: O, ok: w } = V.equalsAtPaths(
584
584
  S,
585
- h,
585
+ m,
586
586
  v
587
587
  );
588
588
  E(
@@ -595,7 +595,7 @@ ${b.status === "error" ? U(b.errors) : ""}`
595
595
  ...p,
596
596
  [t]: V.updateAt(
597
597
  S,
598
- h,
598
+ m,
599
599
  v
600
600
  )
601
601
  }, u.info(
@@ -1337,7 +1337,7 @@ Original error: ${l}`,
1337
1337
  typeof y.fields == "object",
1338
1338
  `[${f}:createComponent]: the "fields" property must be an object, was ${typeof y.fields}`
1339
1339
  );
1340
- const h = this.#e.createStepUpdaterFn(f), b = Ie((w) => {
1340
+ const m = this.#e.createStepUpdaterFn(f), b = Ie((w) => {
1341
1341
  E(typeof w == "string", () => {
1342
1342
  const c = new Intl.ListFormat("en", {
1343
1343
  style: "long",
@@ -1361,10 +1361,18 @@ Original error: ${l}`,
1361
1361
  type: d,
1362
1362
  name: w,
1363
1363
  onInputChange: (c) => {
1364
- const m = typeof c == "function" ? c(j) : c;
1364
+ let h;
1365
+ if (typeof c == "function") {
1366
+ const _ = this.getValue(
1367
+ f,
1368
+ w
1369
+ );
1370
+ h = c(_);
1371
+ } else
1372
+ h = c;
1365
1373
  this.update({
1366
1374
  targetStep: f,
1367
- updater: m,
1375
+ updater: h,
1368
1376
  fields: [`fields.${w}.defaultValue`]
1369
1377
  });
1370
1378
  }
@@ -1372,7 +1380,7 @@ Original error: ${l}`,
1372
1380
  });
1373
1381
  let O = {
1374
1382
  ctx: p,
1375
- onInputChange: h,
1383
+ onInputChange: m,
1376
1384
  Field: b,
1377
1385
  ...u
1378
1386
  };
@@ -1403,8 +1411,8 @@ Original error: ${l}`,
1403
1411
  debugger;
1404
1412
  const a = this.value, u = e[0], S = this.#e.createStepUpdaterFn(u).bind(this.#e);
1405
1413
  function g(p, f) {
1406
- function v(h) {
1407
- return h ? { ctx: { ...r, ...h } } : { ctx: r };
1414
+ function v(m) {
1415
+ return m ? { ctx: { ...r, ...m } } : { ctx: r };
1408
1416
  }
1409
1417
  function y() {
1410
1418
  return E(
@@ -1417,7 +1425,7 @@ Original error: ${l}`,
1417
1425
  )(p);
1418
1426
  }
1419
1427
  if (typeof p == "object") {
1420
- const { useFormInstance: h, ctxData: b, debug: O } = p, w = new te({
1428
+ const { useFormInstance: m, ctxData: b, debug: O } = p, w = new te({
1421
1429
  debug: O,
1422
1430
  prefix(l) {
1423
1431
  return `${l}-${u}-createComponent`;
@@ -1428,14 +1436,14 @@ Original error: ${l}`,
1428
1436
  if (E(
1429
1437
  typeof f == "function",
1430
1438
  "The second argument must be a function"
1431
- ), h) {
1439
+ ), m) {
1432
1440
  const {
1433
1441
  render: l,
1434
1442
  alias: d = Z.DEFAULT_FORM_INSTANCE_ALIAS
1435
- } = h, [c] = e, m = n(c), _ = b ? {
1443
+ } = m, [c] = e, h = n(c), _ = b ? {
1436
1444
  ...r,
1437
1445
  ...b({ ctx: i })
1438
- } : r, $ = { ctx: _, defaultValues: m };
1446
+ } : r, $ = { ctx: _, defaultValues: h };
1439
1447
  return s(
1440
1448
  e,
1441
1449
  t,
@@ -1539,7 +1547,7 @@ function Pe() {
1539
1547
  }
1540
1548
  var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, s = o.useEffect, n = o.useLayoutEffect, a = o.useDebugValue;
1541
1549
  function u(f, v) {
1542
- var y = v(), h = r({ inst: { value: y, getSnapshot: v } }), b = h[0].inst, O = h[1];
1550
+ var y = v(), m = r({ inst: { value: y, getSnapshot: v } }), b = m[0].inst, O = m[1];
1543
1551
  return n(
1544
1552
  function() {
1545
1553
  b.value = y, b.getSnapshot = v, S(b) && O({ inst: b });
@@ -1583,29 +1591,29 @@ var J = {};
1583
1591
  var pe;
1584
1592
  function Ke() {
1585
1593
  return pe || (pe = 1, process.env.NODE_ENV !== "production" && (function() {
1586
- function o(y, h) {
1587
- return y === h && (y !== 0 || 1 / y === 1 / h) || y !== y && h !== h;
1594
+ function o(y, m) {
1595
+ return y === m && (y !== 0 || 1 / y === 1 / m) || y !== y && m !== m;
1588
1596
  }
1589
- function e(y, h) {
1597
+ function e(y, m) {
1590
1598
  p || s.startTransition === void 0 || (p = !0, console.error(
1591
1599
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
1592
1600
  ));
1593
- var b = h();
1601
+ var b = m();
1594
1602
  if (!f) {
1595
- var O = h();
1603
+ var O = m();
1596
1604
  n(b, O) || (console.error(
1597
1605
  "The result of getSnapshot should be cached to avoid an infinite loop"
1598
1606
  ), f = !0);
1599
1607
  }
1600
1608
  O = a({
1601
- inst: { value: b, getSnapshot: h }
1609
+ inst: { value: b, getSnapshot: m }
1602
1610
  });
1603
1611
  var w = O[0].inst, j = O[1];
1604
1612
  return S(
1605
1613
  function() {
1606
- w.value = b, w.getSnapshot = h, t(w) && j({ inst: w });
1614
+ w.value = b, w.getSnapshot = m, t(w) && j({ inst: w });
1607
1615
  },
1608
- [y, b, h]
1616
+ [y, b, m]
1609
1617
  ), u(
1610
1618
  function() {
1611
1619
  return t(w) && j({ inst: w }), y(function() {
@@ -1616,17 +1624,17 @@ function Ke() {
1616
1624
  ), g(b), b;
1617
1625
  }
1618
1626
  function t(y) {
1619
- var h = y.getSnapshot;
1627
+ var m = y.getSnapshot;
1620
1628
  y = y.value;
1621
1629
  try {
1622
- var b = h();
1630
+ var b = m();
1623
1631
  return !n(y, b);
1624
1632
  } catch {
1625
1633
  return !0;
1626
1634
  }
1627
1635
  }
1628
- function r(y, h) {
1629
- return h();
1636
+ function r(y, m) {
1637
+ return m();
1630
1638
  }
1631
1639
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1632
1640
  var s = R, n = typeof Object.is == "function" ? Object.is : o, a = s.useState, u = s.useEffect, S = s.useLayoutEffect, g = s.useDebugValue, p = !1, f = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
@@ -1656,25 +1664,25 @@ function Ge() {
1656
1664
  }
1657
1665
  var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect, u = o.useMemo, S = o.useDebugValue;
1658
1666
  return H.useSyncExternalStoreWithSelector = function(g, p, f, v, y) {
1659
- var h = n(null);
1660
- if (h.current === null) {
1667
+ var m = n(null);
1668
+ if (m.current === null) {
1661
1669
  var b = { hasValue: !1, value: null };
1662
- h.current = b;
1663
- } else b = h.current;
1664
- h = u(
1670
+ m.current = b;
1671
+ } else b = m.current;
1672
+ m = u(
1665
1673
  function() {
1666
1674
  function w(c) {
1667
1675
  if (!j) {
1668
1676
  if (j = !0, i = c, c = v(c), y !== void 0 && b.hasValue) {
1669
- var m = b.value;
1670
- if (y(m, c))
1671
- return l = m;
1677
+ var h = b.value;
1678
+ if (y(h, c))
1679
+ return l = h;
1672
1680
  }
1673
1681
  return l = c;
1674
1682
  }
1675
- if (m = l, r(i, c)) return m;
1683
+ if (h = l, r(i, c)) return h;
1676
1684
  var _ = v(c);
1677
- return y !== void 0 && y(m, _) ? (i = c, m) : (i = c, l = _);
1685
+ return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
1678
1686
  }
1679
1687
  var j = !1, i, l, d = f === void 0 ? null : f;
1680
1688
  return [
@@ -1688,7 +1696,7 @@ function Ge() {
1688
1696
  },
1689
1697
  [p, f, v, y]
1690
1698
  );
1691
- var O = s(g, h[0], h[1]);
1699
+ var O = s(g, m[0], m[1]);
1692
1700
  return a(
1693
1701
  function() {
1694
1702
  b.hasValue = !0, b.value = O;
@@ -1716,26 +1724,26 @@ function We() {
1716
1724
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1717
1725
  var e = R, t = $e(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, a = e.useEffect, u = e.useMemo, S = e.useDebugValue;
1718
1726
  z.useSyncExternalStoreWithSelector = function(g, p, f, v, y) {
1719
- var h = n(null);
1720
- if (h.current === null) {
1727
+ var m = n(null);
1728
+ if (m.current === null) {
1721
1729
  var b = { hasValue: !1, value: null };
1722
- h.current = b;
1723
- } else b = h.current;
1724
- h = u(
1730
+ m.current = b;
1731
+ } else b = m.current;
1732
+ m = u(
1725
1733
  function() {
1726
1734
  function w(c) {
1727
1735
  if (!j) {
1728
1736
  if (j = !0, i = c, c = v(c), y !== void 0 && b.hasValue) {
1729
- var m = b.value;
1730
- if (y(m, c))
1731
- return l = m;
1737
+ var h = b.value;
1738
+ if (y(h, c))
1739
+ return l = h;
1732
1740
  }
1733
1741
  return l = c;
1734
1742
  }
1735
- if (m = l, r(i, c))
1736
- return m;
1743
+ if (h = l, r(i, c))
1744
+ return h;
1737
1745
  var _ = v(c);
1738
- return y !== void 0 && y(m, _) ? (i = c, m) : (i = c, l = _);
1746
+ return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
1739
1747
  }
1740
1748
  var j = !1, i, l, d = f === void 0 ? null : f;
1741
1749
  return [
@@ -1749,7 +1757,7 @@ function We() {
1749
1757
  },
1750
1758
  [p, f, v, y]
1751
1759
  );
1752
- var O = s(g, h[0], h[1]);
1760
+ var O = s(g, m[0], m[1]);
1753
1761
  return a(
1754
1762
  function() {
1755
1763
  b.hasValue = !0, b.value = O;
@@ -1843,7 +1851,7 @@ function Qe(o) {
1843
1851
  maxProgressValue: p = 100,
1844
1852
  totalSteps: f = S,
1845
1853
  progressTextTransformer: v
1846
- } = u, y = Q(o, g), h = y / f * p, b = v ? n(
1854
+ } = u, y = Q(o, g), m = y / f * p, b = v ? n(
1847
1855
  { targetStep: g, maxProgressValue: p, totalSteps: f },
1848
1856
  v
1849
1857
  ) : (O) => /* @__PURE__ */ ie("div", { ...O, children: [
@@ -1853,7 +1861,7 @@ function Qe(o) {
1853
1861
  f
1854
1862
  ] });
1855
1863
  return {
1856
- value: h,
1864
+ value: m,
1857
1865
  maxProgressValue: p,
1858
1866
  ProgressText: b
1859
1867
  };