@jfdevelops/react-multi-step-form 1.0.0-alpha.3 → 1.0.0-alpha.4

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
@@ -1,28 +1,28 @@
1
- import { jsx as ge, jsxs as B } from "react/jsx-runtime";
2
- import F from "react";
3
- function Se(o, ...e) {
1
+ import { jsx as $e, jsxs as te } from "react/jsx-runtime";
2
+ import W from "react";
3
+ function _e(o, ...e) {
4
4
  return () => String.raw({ raw: o }, ...e);
5
5
  }
6
- function h(o, e, t = Error) {
6
+ function j(o, e, t = Error) {
7
7
  if (!o) {
8
- const r = typeof e == "function" ? e() : Se`${e}`();
8
+ const r = typeof e == "function" ? e() : _e`${e}`();
9
9
  throw new t(r);
10
10
  }
11
11
  }
12
- const I = "MultiStepFormSchema";
13
- class ue {
12
+ const G = "MultiStepFormSchema";
13
+ class me {
14
14
  debug;
15
- prefix = I;
15
+ prefix = G;
16
16
  includeTimestamp = !1;
17
17
  throwOnError = !1;
18
18
  constructor(e) {
19
19
  if (this.debug = e?.debug ?? !1, this.debug && e?.debug) {
20
20
  const {
21
21
  includeTimestamp: t = !1,
22
- prefix: r = I,
23
- throwOnError: s = !1
22
+ prefix: r = G,
23
+ throwOnError: n = !1
24
24
  } = e;
25
- this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(I), this.throwOnError = s;
25
+ this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(G), this.throwOnError = n;
26
26
  }
27
27
  }
28
28
  wrapValue(e, t) {
@@ -39,34 +39,34 @@ class ue {
39
39
  formatPrefix(e) {
40
40
  if (!e)
41
41
  return this.prefix;
42
- const { action: t, value: r, wrapWith: s } = e;
42
+ const { action: t, value: r, wrapWith: n } = e;
43
43
  if (t === "replace")
44
- return this.wrapValue(s ?? "[]", r);
45
- const { delimiter: n } = e;
44
+ return this.wrapValue(n ?? "[]", r);
45
+ const { delimiter: s } = e;
46
46
  return t === "append" ? `${this.wrapValue(
47
- s?.originalPrefix ?? "[]",
47
+ n?.originalPrefix ?? "[]",
48
48
  this.prefix
49
- )}${n}${this.wrapValue(
50
- s?.addedPrefix ?? "[]",
49
+ )}${s}${this.wrapValue(
50
+ n?.addedPrefix ?? "[]",
51
51
  r
52
52
  )}`.trim() : t === "prepend" ? `${this.wrapValue(
53
- s?.addedPrefix ?? "[]",
53
+ n?.addedPrefix ?? "[]",
54
54
  r
55
- )}${n}${this.wrapValue(
56
- s?.originalPrefix ?? "[]",
55
+ )}${s}${this.wrapValue(
56
+ n?.originalPrefix ?? "[]",
57
57
  this.prefix
58
58
  )}`.trim() : this.prefix;
59
59
  }
60
60
  formatMessage(e, t, r) {
61
61
  const {
62
- includeTimestamp: s = this.includeTimestamp,
63
- prefix: n,
62
+ includeTimestamp: n = this.includeTimestamp,
63
+ prefix: s,
64
64
  logLevelOptions: i
65
- } = r ?? {}, p = this.formatPrefix(n), y = this.wrapValue(
65
+ } = r ?? {}, y = this.formatPrefix(s), b = this.wrapValue(
66
66
  i?.wrapWith ?? "[]",
67
67
  (i?.level ?? e).toUpperCase()
68
- ), f = `${p} ${y} ${t}`;
69
- return s ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${f}` : f;
68
+ ), f = `${y} ${b} ${t}`;
69
+ return n ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${f}` : f;
70
70
  }
71
71
  info(e, t) {
72
72
  this.debug && console.info(this.formatMessage("info", e, t));
@@ -82,21 +82,21 @@ class ue {
82
82
  throw new Error(r);
83
83
  }
84
84
  }
85
- const z = '"window" in undefined. No storage is available', W = "MultiStepForm";
86
- class ce {
85
+ const re = '"window" in undefined. No storage is available', Q = "MultiStepForm";
86
+ class ye {
87
87
  key;
88
88
  store;
89
89
  data;
90
90
  log;
91
91
  isWindowUndefined;
92
92
  constructor(e) {
93
- const { key: t, data: r, store: s } = e;
94
- this.log = new ue({
95
- prefix: W
96
- }), this.key = t, this.data = r, s ? (this.store = s, this.isWindowUndefined = !1) : typeof window < "u" ? (this.store = window.localStorage, this.isWindowUndefined = !1) : (this.isWindowUndefined = !0, this.log.warn(z));
93
+ const { key: t, data: r, store: n } = e;
94
+ this.log = new me({
95
+ prefix: Q
96
+ }), this.key = t, this.data = r, n ? (this.store = n, this.isWindowUndefined = !1) : typeof window < "u" ? (this.store = window.localStorage, this.isWindowUndefined = !1) : (this.isWindowUndefined = !0, this.log.warn(re));
97
97
  }
98
98
  throwOnEmptyStore() {
99
- h(this.store, () => this.isWindowUndefined ? z : "No storage available");
99
+ j(this.store, () => this.isWindowUndefined ? re : "No storage available");
100
100
  }
101
101
  resolveValue(e) {
102
102
  if (typeof e == "object")
@@ -126,7 +126,7 @@ class ce {
126
126
  this.store.setItem(this.key, t);
127
127
  }
128
128
  }
129
- const ve = [
129
+ const we = [
130
130
  "sentence",
131
131
  "title",
132
132
  "camel",
@@ -137,8 +137,8 @@ const ve = [
137
137
  "screaming-snake",
138
138
  "flat",
139
139
  "kebab"
140
- ], K = "title";
141
- function _e(o, e) {
140
+ ], X = "title";
141
+ function Te(o, e) {
142
142
  const t = o.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).map((r) => r.toLowerCase());
143
143
  switch (e) {
144
144
  case "sentence":
@@ -165,13 +165,13 @@ function _e(o, e) {
165
165
  return o;
166
166
  }
167
167
  }
168
- function R(o) {
169
- return typeof o != "string" ? !1 : ve.includes(o);
168
+ function J(o) {
169
+ return typeof o != "string" ? !1 : we.includes(o);
170
170
  }
171
- function le(o, e = K) {
172
- return R(o) ? o : e;
171
+ function ge(o, e = X) {
172
+ return J(o) ? o : e;
173
173
  }
174
- const we = [
174
+ const Ae = [
175
175
  "string",
176
176
  "string.phone",
177
177
  "string.email",
@@ -181,11 +181,303 @@ const we = [
181
181
  "date",
182
182
  "dateTime",
183
183
  "boolean.switch"
184
- ], q = "string";
185
- function Oe(o) {
186
- return typeof o == "string" && we.includes(o);
184
+ ], ne = "string";
185
+ function Ce(o) {
186
+ return typeof o == "string" && Ae.includes(o);
187
+ }
188
+ function U(o, e, t) {
189
+ const r = [], n = new Set(o), s = t ? t.format(o.map((i) => `${i}`)) : `[${o.join(", ")}]`;
190
+ for (let i = 0; i < e.length; i++) {
191
+ const y = e[i];
192
+ n.has(y) || r.push(
193
+ `Extra element at index ${i}: "${y}" is not in ${s}`
194
+ );
195
+ }
196
+ return e.some((i) => n.has(i)) || r.push(
197
+ `Array must contain at least one valid element from ${s}`
198
+ ), r.length > 0 ? { status: "error", errors: r } : { status: "success" };
187
199
  }
188
- function fe(o, e) {
200
+ function R(o, e) {
201
+ const t = (r, n) => `❌ ${n + 1}. ${r}`;
202
+ return o.map((r, n) => t(r, n)).join(`
203
+ `);
204
+ }
205
+ function se(o) {
206
+ return Object.keys(o);
207
+ }
208
+ var C;
209
+ ((o) => {
210
+ function e(a, l) {
211
+ return l.split(".").reduce((h, u) => h?.[u], a);
212
+ }
213
+ function t(a, l, h) {
214
+ const u = l.split(".");
215
+ let d = a;
216
+ for (let E = 0; E < u.length; E++) {
217
+ const _ = u[E];
218
+ E === u.length - 1 ? d[_] !== void 0 && typeof d[_] == "object" && typeof h == "object" && h !== null ? Object.assign(d[_], h) : d[_] = h : ((typeof d[_] != "object" || d[_] === null) && (d[_] = {}), d = d[_]);
219
+ }
220
+ return d;
221
+ }
222
+ o.setBy = t;
223
+ function r(a) {
224
+ return a.filter((l) => !a.some((h) => h !== l && l.startsWith(h + ".")));
225
+ }
226
+ function n(a, ...l) {
227
+ const h = r(l);
228
+ if (h.length === 1)
229
+ return e(a, h[0]);
230
+ const u = {};
231
+ for (const d of h) {
232
+ const E = e(a, d);
233
+ t(u, d, E);
234
+ }
235
+ return u;
236
+ }
237
+ o.pickBy = n;
238
+ function s(a) {
239
+ const l = [];
240
+ function h(u, d = "") {
241
+ if (u == null || typeof u != "object" || Array.isArray(u))
242
+ return;
243
+ const E = Object.keys(u);
244
+ for (const _ of E) {
245
+ const T = d ? `${d}.${_}` : _;
246
+ l.push(T);
247
+ const A = u[_];
248
+ A != null && typeof A == "object" && !Array.isArray(A) && h(A, T);
249
+ }
250
+ }
251
+ return h(a), l;
252
+ }
253
+ o.createDeep = s;
254
+ function i(a) {
255
+ if (a === null) return "null";
256
+ if (Array.isArray(a)) return "Array";
257
+ const l = typeof a;
258
+ if (l !== "object") return l;
259
+ const h = a?.constructor?.name;
260
+ return h && h !== "Object" ? h : "object";
261
+ }
262
+ function y(a) {
263
+ if (!a) return [];
264
+ const l = [], h = /[^.[\]]+|\[(\d+)\]/g;
265
+ let u;
266
+ for (; u = h.exec(a); )
267
+ l.push(u[1] ?? u[0]);
268
+ return l;
269
+ }
270
+ function b(a, l) {
271
+ if (!a) return;
272
+ if (typeof a == "function")
273
+ return a;
274
+ const h = y(l);
275
+ let u = a, d;
276
+ for (const E of h) {
277
+ if (!u) break;
278
+ if (typeof u == "function") {
279
+ d = u;
280
+ break;
281
+ }
282
+ if (u = u[E], typeof u == "function") {
283
+ d = u;
284
+ break;
285
+ }
286
+ }
287
+ return d;
288
+ }
289
+ function f(a, l, h) {
290
+ const u = b(h, l);
291
+ return u ? u(a, l) : i(a);
292
+ }
293
+ function g(a) {
294
+ return typeof a == "object" && a !== null;
295
+ }
296
+ function c(a, l, h, u, d) {
297
+ if (a === l)
298
+ return u;
299
+ if (a === null || l === null || typeof a != "object" || typeof l != "object") {
300
+ const _ = h || "(root)";
301
+ return typeof a != typeof l ? (u.push({
302
+ path: _,
303
+ expected: f(a, _, d.transformExpected),
304
+ actual: l,
305
+ reason: "type-mismatch"
306
+ }), u) : (d.includeValueMismatch && u.push({
307
+ path: _,
308
+ expected: f(a, _, d.transformExpected),
309
+ actual: l,
310
+ reason: "value-mismatch"
311
+ }), u);
312
+ }
313
+ if (Array.isArray(a) || Array.isArray(l)) {
314
+ if (!Array.isArray(a) || !Array.isArray(l)) {
315
+ const T = h || "(root)";
316
+ return u.push({
317
+ path: T,
318
+ expected: f(a, T, d.transformExpected),
319
+ actual: l,
320
+ reason: "type-mismatch"
321
+ }), u;
322
+ }
323
+ const _ = a.length;
324
+ for (let T = 0; T < _; T++) {
325
+ const A = a[T], x = l[T], k = h === "" ? `[${T}]` : `${h}[${T}]`;
326
+ if (T >= l.length) {
327
+ u.push({
328
+ path: k,
329
+ expected: f(A, k, d.transformExpected),
330
+ actual: void 0,
331
+ reason: "missing-key"
332
+ });
333
+ continue;
334
+ }
335
+ c(A, x, k, u, d);
336
+ }
337
+ if (l.length > a.length)
338
+ for (let T = a.length; T < l.length; T++) {
339
+ const A = h === "" ? `[${T}]` : `${h}[${T}]`;
340
+ u.push({
341
+ path: A,
342
+ expected: void 0,
343
+ actual: l[T],
344
+ reason: "extra-key"
345
+ });
346
+ }
347
+ return u;
348
+ }
349
+ if (g(a) && g(l)) {
350
+ const _ = Object.keys(a), T = Object.keys(l);
351
+ for (const A of _) {
352
+ const x = a[A], k = l[A], F = h ? `${h}.${A}` : A;
353
+ if (!(A in l)) {
354
+ u.push({
355
+ path: F,
356
+ expected: f(x, F, d.transformExpected),
357
+ actual: void 0,
358
+ reason: "missing-key"
359
+ });
360
+ continue;
361
+ }
362
+ c(x, k, F, u, d);
363
+ }
364
+ for (const A of T)
365
+ if (!(A in a)) {
366
+ const x = h ? `${h}.${A}` : A;
367
+ u.push({
368
+ path: x,
369
+ expected: void 0,
370
+ actual: l[A],
371
+ reason: "extra-key"
372
+ });
373
+ }
374
+ return u;
375
+ }
376
+ const E = h || "(root)";
377
+ return typeof a != typeof l ? u.push({
378
+ path: E,
379
+ expected: f(a, E, d.transformExpected),
380
+ actual: l,
381
+ reason: "type-mismatch"
382
+ }) : d.includeValueMismatch && u.push({
383
+ path: E,
384
+ expected: f(a, E, d.transformExpected),
385
+ actual: l,
386
+ reason: "value-mismatch"
387
+ }), u;
388
+ }
389
+ function m(a, l, h, u) {
390
+ const d = n(a, ...l), E = [], _ = l.length === 1 ? l[0] : "";
391
+ return c(d, h, _, E, {
392
+ transformExpected: u?.transformExpected
393
+ }), {
394
+ ok: E.length === 0,
395
+ mismatches: E
396
+ };
397
+ }
398
+ o.equalsAtPaths = m;
399
+ function p(a) {
400
+ if (a === void 0) return "undefined";
401
+ if (typeof a == "string") return JSON.stringify(a);
402
+ try {
403
+ return JSON.stringify(a, null, 2);
404
+ } catch {
405
+ return String(a);
406
+ }
407
+ }
408
+ function v(a) {
409
+ switch (a.reason) {
410
+ case "missing-key":
411
+ return "Missing key";
412
+ case "extra-key":
413
+ return "Extra key";
414
+ case "type-mismatch":
415
+ return "Type mismatch";
416
+ case "value-mismatch":
417
+ return "Value mismatch";
418
+ default:
419
+ return a.reason;
420
+ }
421
+ }
422
+ function S(a) {
423
+ if (a.ok || a.mismatches.length === 0)
424
+ return "No mismatches.";
425
+ const l = [];
426
+ for (const h of a.mismatches)
427
+ l.push(
428
+ `
429
+ ● ${v(h)} at "${h.path}":`,
430
+ ` expected: ${p(h.expected)}`,
431
+ ` actual: ${p(h.actual)}`,
432
+ ""
433
+ // blank line between entries
434
+ );
435
+ return l.at(-1) === "" && l.pop(), l.join(`
436
+ `);
437
+ }
438
+ o.formatMismatches = S;
439
+ function O(a) {
440
+ const l = S(a);
441
+ l !== "No mismatches." && console.error(l);
442
+ }
443
+ o.printMismatches = O;
444
+ function $(a, l, h) {
445
+ const u = l.split(".");
446
+ function d(E, _) {
447
+ const T = u[_], A = Array.isArray(E) ? [...E] : { ...E };
448
+ if (_ === u.length - 1) {
449
+ let P = E && typeof E == "object" ? A : {};
450
+ return P = {
451
+ ...P,
452
+ [T]: h
453
+ }, P;
454
+ }
455
+ const x = E && typeof E == "object" ? E[T] : void 0, k = d(x ?? {}, _ + 1);
456
+ let F = E && typeof E == "object" ? A : {};
457
+ return F = {
458
+ ...F,
459
+ [T]: k
460
+ }, F;
461
+ }
462
+ return d(a, 0);
463
+ }
464
+ function w(a, l, h) {
465
+ const u = r(l);
466
+ if (u.length === 0) return a;
467
+ let d = a;
468
+ if (u.length === 1) {
469
+ const E = u[0];
470
+ return d = $(d, E, h), d;
471
+ }
472
+ for (const E of u) {
473
+ const _ = e(h, E);
474
+ d = $(d, E, _);
475
+ }
476
+ return d;
477
+ }
478
+ o.updateAt = w;
479
+ })(C || (C = {}));
480
+ function be(o, e) {
189
481
  const t = o["~standard"].validate(e);
190
482
  if (t instanceof Promise)
191
483
  throw new TypeError("Schema validation must be synchronous", {
@@ -195,7 +487,7 @@ function fe(o, e) {
195
487
  throw new Error(JSON.stringify(t.issues, null, 2));
196
488
  return t.value;
197
489
  }
198
- class pe {
490
+ class Se {
199
491
  listeners = /* @__PURE__ */ new Set();
200
492
  constructor() {
201
493
  this.subscribe = this.subscribe.bind(this);
@@ -213,250 +505,253 @@ class pe {
213
505
  onUnsubscribe() {
214
506
  }
215
507
  }
216
- function J(o, e, t) {
217
- const r = [], s = new Set(o), n = t ? t.format(o.map((i) => `${i}`)) : `[${o.join(", ")}]`;
218
- for (let i = 0; i < e.length; i++) {
219
- const p = e[i];
220
- s.has(p) || r.push(
221
- `Extra element at index ${i}: "${p}" is not in ${n}`
222
- );
223
- }
224
- return e.some((i) => s.has(i)) || r.push(
225
- `Array must contain at least one valid element from ${n}`
226
- ), r.length > 0 ? { status: "error", errors: r } : { status: "success" };
227
- }
228
- function Y(o) {
229
- return o.map((e, t) => `❌ ${t + 1}. ${e}`).join(`
230
- `);
231
- }
232
- function V(o) {
233
- h(o.includes("step"), "Can't extract a valid step number since");
508
+ var V;
509
+ ((o) => {
510
+ o.CATCH_ALL_MESSAGE = 'The chosen steps must either be set to on of the following: "all", an array of steps (["step1", "step2", ...]), or an object containing the steps to chose ({ step1: true, step2: true, ...})';
511
+ function e(n) {
512
+ return !!(n && typeof n == "string" && n === "all");
513
+ }
514
+ o.isAll = e;
515
+ function t(n, s) {
516
+ return Array.isArray(n) ? s ? n.every((i) => s.includes(i)) : !0 : !1;
517
+ }
518
+ o.isTuple = t;
519
+ function r(n, s) {
520
+ if (!n)
521
+ return !1;
522
+ const i = Object.keys(n);
523
+ return i.length === 0 || s && !i.every((y) => s.includes(y)) ? !1 : Object.entries(n).every(([y, b]) => b === !0);
524
+ }
525
+ o.isObject = r;
526
+ })(V || (V = {}));
527
+ function M(o) {
528
+ j(o.includes("step"), "Can't extract a valid step number since");
234
529
  const e = o.replace("step", "");
235
- return h(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
530
+ return j(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
236
531
  }
237
- function A(o) {
532
+ function H(o) {
238
533
  return function(e) {
239
- const { step: t } = e, r = `step${t}`, s = o[r];
240
- return { step: t, data: s };
534
+ const { step: t } = e, r = `step${t}`, n = o[r];
535
+ return { step: t, data: n };
241
536
  };
242
537
  }
243
- function Z(o, e) {
538
+ function oe(o, e) {
244
539
  return e.reduce((t, r) => {
245
- const s = V(r), { data: n } = A(o)({
246
- step: s
540
+ const n = M(r), { data: s } = H(o)({
541
+ step: n
247
542
  });
248
- for (const [i, p] of Object.entries(n))
249
- typeof p == "function" && i !== "update" || (n[i] = p);
250
- return t[r] = n, t;
543
+ for (const [i, y] of Object.entries(s))
544
+ typeof y == "function" && i !== "update" || (s[i] = y);
545
+ return t[r] = s, t;
251
546
  }, {});
252
547
  }
253
- function N(o, e) {
548
+ function I(o, e) {
254
549
  const t = new Intl.ListFormat("en", {
255
550
  style: "long",
256
551
  type: "disjunction"
257
- }), r = Object.keys(o), s = () => `"stepData" must be set to an array of available steps (${t.format(
552
+ }), r = Object.keys(o), n = () => `"stepData" must be set to an array of available steps (${t.format(
258
553
  r
259
554
  )})`;
260
555
  if (e === "all") {
261
- let n = {};
556
+ let s = {};
262
557
  for (const i of r)
263
- n = {
264
- ...n,
265
- [i]: A(o)({
266
- step: V(i)
558
+ s = {
559
+ ...s,
560
+ [i]: H(o)({
561
+ step: M(i)
267
562
  })
268
563
  };
269
564
  return Object.fromEntries(
270
565
  r.map((i) => [
271
566
  i,
272
- A(o)({
273
- step: V(i)
567
+ H(o)({
568
+ step: M(i)
274
569
  })
275
570
  ])
276
571
  );
277
572
  }
278
573
  if (Array.isArray(e))
279
- return h(
280
- e.every((n) => r.includes(n)),
574
+ return j(
575
+ e.every((s) => r.includes(s)),
281
576
  () => {
282
- const n = J(
577
+ const s = U(
283
578
  e,
284
- r.map((i) => V(i)),
579
+ r.map((i) => M(i)),
285
580
  t
286
581
  );
287
- return n.status === "error" ? `${s()}. See errors:
288
- ${Y(
289
- n.errors
290
- )}` : s();
582
+ return s.status === "error" ? `${n()}. See errors:
583
+ ${R(
584
+ s.errors
585
+ )}` : n();
291
586
  }
292
- ), Z(
587
+ ), oe(
293
588
  o,
294
589
  e
295
590
  );
296
591
  if (typeof e == "object") {
297
- const n = Object.keys(e);
298
- return h(
299
- n.every((i) => r.includes(i)),
592
+ const s = Object.keys(e);
593
+ return j(
594
+ s.every((i) => r.includes(i)),
300
595
  () => {
301
- const i = J(
302
- n,
596
+ const i = U(
597
+ s,
303
598
  r,
304
599
  t
305
600
  );
306
- return i.status === "error" ? `${s()}. See errors:
307
- ${Y(
601
+ return i.status === "error" ? `${n()}. See errors:
602
+ ${R(
308
603
  i.errors
309
- )}` : s();
604
+ )}` : n();
310
605
  }
311
- ), Z(
606
+ ), oe(
312
607
  o,
313
- n
608
+ s
314
609
  );
315
610
  }
316
- throw new Error(`${s()} OR to "all"`);
611
+ throw new Error(`${n()} OR to "all"`);
317
612
  }
318
- function Q(o, e) {
613
+ function xe(o, e) {
319
614
  return typeof o == "function" ? o(e) : o;
320
615
  }
321
- const Te = [
616
+ const ke = [
322
617
  "string",
323
618
  "number",
324
619
  "array.string",
325
620
  "array.string.untyped"
326
- ], de = /^step\d+$/i;
327
- function X(o, e) {
621
+ ], ve = /^step\d+$/i;
622
+ function ae(o, e) {
328
623
  if (typeof o != "object" || o === null) return !1;
329
624
  for (const t of Object.keys(e)) {
330
625
  if (!(t in o)) return !1;
331
- const r = e[t], s = o[t];
332
- if (!r(s)) return !1;
626
+ const r = e[t], n = o[t];
627
+ if (!r(n)) return !1;
333
628
  }
334
629
  return !0;
335
630
  }
336
- function ee(o, e, t) {
337
- return o ?? _e(e, t);
631
+ function ie(o, e, t) {
632
+ return o ?? Te(e, t);
338
633
  }
339
- function Ee(o) {
340
- const e = {}, { fields: t, defaultCasing: r, validateFields: s } = o;
341
- for (const [n, i] of Object.entries(t)) {
342
- h(
343
- typeof n == "string",
344
- `Each key for the "fields" option must be a string. Key ${n} was a ${typeof n}`
345
- ), h(
634
+ function Fe(o) {
635
+ const e = {}, { fields: t, defaultCasing: r, validateFields: n } = o;
636
+ for (const [s, i] of Object.entries(t)) {
637
+ j(
638
+ typeof s == "string",
639
+ `Each key for the "fields" option must be a string. Key ${s} was a ${typeof s}`
640
+ ), j(
346
641
  typeof i == "object",
347
- `The value for key ${n} must be an object. Was ${typeof i}`
642
+ `The value for key ${s} must be an object. Was ${typeof i}`
348
643
  );
349
644
  const {
350
- defaultValue: p,
351
- label: y,
645
+ defaultValue: y,
646
+ label: b,
352
647
  nameTransformCasing: f,
353
- type: d = q
648
+ type: g = ne
354
649
  } = i;
355
- if (s)
356
- e[n] = p;
650
+ if (n)
651
+ e[s] = y;
357
652
  else {
358
- const u = f ?? r;
359
- e[n] = {
360
- ...e[n],
361
- nameTransformCasing: u,
362
- type: d,
363
- defaultValue: p,
364
- label: ee(y, n, u)
653
+ const c = f ?? r;
654
+ e[s] = {
655
+ ...e[s],
656
+ nameTransformCasing: c,
657
+ type: g,
658
+ defaultValue: y,
659
+ label: ie(b, s, c)
365
660
  // TODO add more fields here
366
661
  };
367
662
  }
368
663
  }
369
- if (s) {
370
- const n = fe(
371
- s,
664
+ if (n) {
665
+ const s = be(
666
+ n,
372
667
  e
373
668
  );
374
- h(
375
- typeof n == "object",
376
- `The result of the validated fields must be an object, was (${typeof n}). This is probably an internal error, so open up an issue about it`
377
- ), h(
378
- !!n,
669
+ j(
670
+ typeof s == "object",
671
+ `The result of the validated fields must be an object, was (${typeof s}). This is probably an internal error, so open up an issue about it`
672
+ ), j(
673
+ !!s,
379
674
  "The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it"
380
675
  );
381
- for (const [i, p] of Object.entries(n)) {
382
- const y = t[i];
383
- h(
384
- y,
676
+ for (const [i, y] of Object.entries(s)) {
677
+ const b = t[i];
678
+ j(
679
+ b,
385
680
  `No field found in the fields config for "${i}"`
386
681
  );
387
682
  const {
388
683
  label: f,
389
- type: d = q,
390
- nameTransformCasing: u
391
- } = y, l = u ?? r;
684
+ type: g = ne,
685
+ nameTransformCasing: c
686
+ } = b, m = c ?? r;
392
687
  e[i] = {
393
688
  ...e[i],
394
- nameTransformCasing: l,
395
- type: d,
396
- defaultValue: p,
397
- label: ee(f, i, l)
689
+ nameTransformCasing: m,
690
+ type: g,
691
+ defaultValue: y,
692
+ label: ie(f, i, m)
398
693
  };
399
694
  }
400
695
  }
401
696
  return e;
402
697
  }
403
- function he(o) {
698
+ function Oe(o) {
404
699
  const e = {};
405
- h(!!o, "The steps config must be defined", TypeError), h(
700
+ j(!!o, "The steps config must be defined", TypeError), j(
406
701
  typeof o == "object",
407
702
  `The steps config must be an object, was (${typeof o})`,
408
703
  TypeError
409
704
  );
410
705
  for (const [t, r] of Object.entries(o)) {
411
- h(
706
+ j(
412
707
  typeof t == "string",
413
708
  `Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
414
709
  TypeError
415
- ), h(
416
- de.test(t),
710
+ ), j(
711
+ ve.test(t),
417
712
  `The key "${t}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`
418
713
  );
419
- const s = t, {
420
- fields: n,
714
+ const n = t, {
715
+ fields: s,
421
716
  title: i,
422
- nameTransformCasing: p = K,
423
- description: y,
717
+ nameTransformCasing: y = X,
718
+ description: b,
424
719
  validateFields: f
425
- } = r, d = s.toString().replace("step", "");
426
- h(
427
- n,
428
- `Missing fields for step ${d} (${String(s)})`,
720
+ } = r, g = n.toString().replace("step", "");
721
+ j(
722
+ s,
723
+ `Missing fields for step ${g} (${String(n)})`,
429
724
  TypeError
430
- ), h(
431
- typeof n == "object",
725
+ ), j(
726
+ typeof s == "object",
432
727
  "Fields must be an object",
433
728
  TypeError
434
- ), h(
435
- Object.keys(n).length > 0,
436
- `The fields config for step ${d} (${String(
437
- s
729
+ ), j(
730
+ Object.keys(s).length > 0,
731
+ `The fields config for step ${g} (${String(
732
+ n
438
733
  )}) is empty. Please add a field`
439
- ), h(
440
- typeof n == "object",
441
- `The "fields" property must be an object. Was ${typeof n}`
734
+ ), j(
735
+ typeof s == "object",
736
+ `The "fields" property must be an object. Was ${typeof s}`
442
737
  );
443
- const u = Ee({
444
- defaultCasing: p,
445
- fields: n,
738
+ const c = Fe({
739
+ defaultCasing: y,
740
+ fields: s,
446
741
  validateFields: f
447
742
  });
448
- e[s] = {
449
- ...e[s],
743
+ e[n] = {
744
+ ...e[n],
450
745
  title: i,
451
- nameTransformCasing: p,
746
+ nameTransformCasing: y,
452
747
  // Only add the description if it's defined
453
- ...typeof y == "string" ? { description: y } : {},
454
- fields: u
748
+ ...typeof b == "string" ? { description: b } : {},
749
+ fields: c
455
750
  };
456
751
  }
457
752
  return e;
458
753
  }
459
- class G extends pe {
754
+ class ee extends Se {
460
755
  /**
461
756
  * The original config before any validation or transformations have been applied.
462
757
  */
@@ -474,37 +769,37 @@ class G extends pe {
474
769
  storage;
475
770
  constructor(e) {
476
771
  super();
477
- const { steps: t, nameTransformCasing: r, storage: s } = e;
478
- this.defaultNameTransformationCasing = le(
772
+ const { steps: t, nameTransformCasing: r, storage: n } = e;
773
+ this.defaultNameTransformationCasing = ge(
479
774
  r
480
- ), this.original = t, this.value = this.enrichValues(he(this.original)), this.stepNumbers = Object.keys(this.value).map(
481
- (n) => Number.parseInt(n.replace("step", ""))
482
- ), this.storage = new ce({
775
+ ), this.original = t, this.value = this.enrichValues(Oe(this.original)), this.stepNumbers = Object.keys(this.value).map(
776
+ (s) => Number.parseInt(s.replace("step", ""))
777
+ ), this.storage = new ye({
483
778
  data: this.value,
484
- key: s?.key ?? W,
485
- store: s?.store
779
+ key: n?.key ?? Q,
780
+ store: n?.store
486
781
  }), this.firstStep = this.first(), this.lastStep = this.last(), this.steps = {
487
782
  first: this.firstStep.step,
488
783
  last: this.lastStep.step,
489
784
  value: this.stepNumbers,
490
- as: (n) => {
491
- if (h(
492
- typeof n == "string",
493
- `The type of the target transformation type must be a string, was ${typeof n}`
494
- ), n === "string")
785
+ as: (s) => {
786
+ if (j(
787
+ typeof s == "string",
788
+ `The type of the target transformation type must be a string, was ${typeof s}`
789
+ ), s === "string")
495
790
  return this.stepNumbers.map((i) => `'${i}'`).join(" | ");
496
- if (n === "number")
791
+ if (s === "number")
497
792
  return this.stepNumbers.join(" | ");
498
- if (n.includes("array.string"))
793
+ if (s.includes("array.string"))
499
794
  return this.stepNumbers.map((i) => `${i}`);
500
795
  throw new Error(
501
- `Transformation type "${n}" is not supported. Available transformations include: ${Te.map(
796
+ `Transformation type "${s}" is not supported. Available transformations include: ${ke.map(
502
797
  (i) => `"${i}"`
503
798
  ).join(", ")}`
504
799
  );
505
800
  },
506
- isValidStepNumber: (n) => this.stepNumbers.includes(n),
507
- isValidStepKey: (n) => Object.keys(this.value).includes(n)
801
+ isValidStepNumber: (s) => this.stepNumbers.includes(s),
802
+ isValidStepKey: (s) => Object.keys(this.value).includes(s)
508
803
  };
509
804
  }
510
805
  getSnapshot() {
@@ -520,15 +815,15 @@ class G extends pe {
520
815
  });
521
816
  }
522
817
  enrichValues(e, t) {
523
- for (const [r, s] of Object.entries(e)) {
524
- const n = Number.parseInt(r.replace("step", ""));
818
+ for (const [r, n] of Object.entries(e)) {
819
+ const s = Number.parseInt(r.replace("step", ""));
525
820
  e = {
526
821
  ...e,
527
822
  [r]: {
528
- ...s,
529
- update: this.createStepUpdaterFn(n),
530
- createHelperFn: this.createStepHelperFn(n),
531
- ...t?.(n)
823
+ ...n,
824
+ update: this.createStepUpdaterFn(r),
825
+ createHelperFn: this.createStepHelperFn(s),
826
+ ...t?.(s)
532
827
  }
533
828
  };
534
829
  }
@@ -540,7 +835,7 @@ class G extends pe {
540
835
  * @returns The step data for the target step.
541
836
  */
542
837
  get(e) {
543
- return A(this.value)(e);
838
+ return H(this.value)(e);
544
839
  }
545
840
  /**
546
841
  * Gets the data for the first step.
@@ -561,90 +856,197 @@ class G extends pe {
561
856
  handlePostUpdate() {
562
857
  this.storage.add(this.value), this.notify();
563
858
  }
564
- createStepUpdaterFnImpl(e, t, r) {
565
- const s = this.stepNumbers;
566
- h(
567
- typeof e == "number",
568
- `Type of step must be a number, was ${typeof e}`,
569
- TypeError
570
- ), h(
571
- s.includes(e),
572
- `The target step ${e} is not valid. Valid steps include "${s.join(
573
- ", "
574
- )}"`
859
+ createHelperFnInputUpdate(e) {
860
+ if (V.isAll(e)) {
861
+ const r = se(this.value).reduce((n, s) => (n[s] = this.createStepUpdaterFn(s), n), {});
862
+ return Object.assign(
863
+ this.update,
864
+ r
865
+ );
866
+ }
867
+ const t = Object.keys(this.value);
868
+ if (V.isTuple(e, t)) {
869
+ const r = e.reduce((n, s) => (n[s] = this.createStepUpdaterFn(s), n), {});
870
+ return Object.assign(
871
+ this.update,
872
+ r
873
+ );
874
+ }
875
+ if (V.isObject(e, t)) {
876
+ const r = se(e).reduce((n, s) => (n[s] = this.createStepUpdaterFn(s), n), {});
877
+ return Object.assign(
878
+ this.update,
879
+ r
880
+ );
881
+ }
882
+ throw new TypeError(`[update]: ${V.CATCH_ALL_MESSAGE}`);
883
+ }
884
+ createStepUpdaterFnImpl(e) {
885
+ const { targetStep: t, updater: r, ctxData: n, fields: s = "all" } = e;
886
+ j(
887
+ this.steps.isValidStepKey(t),
888
+ `[update]: The target step ${t} isn't a valid step. Please select a valid step`
575
889
  );
576
- const n = `step${e}`;
577
- if (typeof t == "string") {
578
- h(this.value[n], `No data found for step ${e}`), h(
579
- typeof this.value[n] == "object",
580
- `The values for step ${e} is not an object, was ${typeof this.value[n]}`
581
- ), h(
582
- t in this.value[n],
583
- `The field ${t} is not a valid field. Valid fields include ${Object.keys(
584
- this.value[n]
585
- ).join(", ")}`
890
+ const { [t]: i, ...y } = this.value;
891
+ let b = I(this.value, [t]);
892
+ if (n) {
893
+ j(
894
+ typeof n == "function",
895
+ '[update]: "ctxData" must be a function'
896
+ );
897
+ const c = n({ ctx: y });
898
+ j(
899
+ typeof c == "object" && Object.keys(c).length > 0,
900
+ '[update]: "ctxData" must return an object with keys'
901
+ ), b = {
902
+ ...b,
903
+ ...c
904
+ };
905
+ }
906
+ const f = xe(r, {
907
+ ctx: b,
908
+ update: this.createHelperFnInputUpdate([t])
909
+ });
910
+ if (!s) {
911
+ j(
912
+ typeof f == "object",
913
+ '[update]: "updater" must be an object or a function that returns an object'
914
+ );
915
+ const c = Object.keys(this.value), m = Object.keys(f);
916
+ j(m.length === c.length, () => {
917
+ const O = c.filter(
918
+ ($) => !m.includes($)
919
+ );
920
+ return `[update]: "updater" is missing keys ${new Intl.ListFormat("en", {
921
+ style: "long",
922
+ type: "conjunction"
923
+ }).format(
924
+ O
925
+ )}`;
926
+ });
927
+ const p = C.createDeep(this.value), { mismatches: v, ok: S } = C.equalsAtPaths(
928
+ this.value,
929
+ p,
930
+ f
931
+ );
932
+ j(
933
+ S && v.length === 0,
934
+ `[update]: found value mismatches in ${C.printMismatches({
935
+ mismatches: v,
936
+ ok: S
937
+ })}`
586
938
  ), this.value = {
587
939
  ...this.value,
588
- [n]: {
589
- ...this.value[n],
590
- [t]: Q(
591
- r,
592
- this.value[n][t]
593
- )
594
- }
940
+ [t]: C.updateAt(this.value, p, f)
595
941
  }, this.handlePostUpdate();
596
942
  return;
597
943
  }
598
- if (typeof t == "object" || typeof t == "function") {
599
- const i = Q(
600
- t,
601
- this.value[n]
944
+ const g = C.createDeep(i);
945
+ if (Array.isArray(s)) {
946
+ const c = U(g, s);
947
+ j(
948
+ c.status === "success",
949
+ `[update]: Found errors with the provided fields
950
+ ${c.status === "error" ? R(c.errors) : ""}`
602
951
  );
603
- h(
604
- typeof i == "object",
605
- `The updated data must be an object, was ${typeof i}`
952
+ const { mismatches: m, ok: p } = C.equalsAtPaths(
953
+ i,
954
+ s,
955
+ f
956
+ );
957
+ j(
958
+ p && m.length === 0,
959
+ `[update]: found value mismatches in ${C.printMismatches({
960
+ ok: p,
961
+ mismatches: m
962
+ })}`
606
963
  ), this.value = {
607
964
  ...this.value,
608
- [n]: {
609
- ...this.value[n],
610
- ...i
611
- }
965
+ [t]: C.updateAt(i, s, f)
966
+ }, this.handlePostUpdate();
967
+ return;
968
+ }
969
+ if (typeof s == "object" && Object.keys(s).length > 0) {
970
+ const c = C.createDeep(s), m = U(
971
+ g,
972
+ c
973
+ );
974
+ j(
975
+ m.status === "success",
976
+ `[update]: Found errors with the provided fields
977
+ ${m.status === "error" ? R(m.errors) : ""}`
978
+ );
979
+ const { mismatches: p, ok: v } = C.equalsAtPaths(
980
+ i,
981
+ c,
982
+ f
983
+ );
984
+ j(
985
+ v && p.length === 0,
986
+ `[update]: found value mismatches in ${C.printMismatches({
987
+ ok: v,
988
+ mismatches: p
989
+ })}`
990
+ ), this.value = {
991
+ ...this.value,
992
+ [t]: C.updateAt(
993
+ i,
994
+ c,
995
+ f
996
+ )
612
997
  }, this.handlePostUpdate();
613
998
  return;
614
999
  }
615
1000
  throw new TypeError(
616
- `The second parameter must be one of the following: a specific field to update (string), an object with the updated data, or a function that returns the updated data. It was ${typeof t}`,
617
- { cause: t }
1001
+ `[update]: property "fields" must be set to one of the following: "all", an array of deep paths to update, or an object of paths. Was ${typeof r}`,
1002
+ { cause: r }
618
1003
  );
619
1004
  }
620
1005
  createStepUpdaterFn(e) {
621
- return (t, r) => {
622
- this.createStepUpdaterFnImpl(
623
- e,
624
- t,
625
- r
626
- );
1006
+ return (t) => {
1007
+ this.createStepUpdaterFnImpl({ targetStep: e, ...t });
627
1008
  };
628
1009
  }
629
- update(e, t, r) {
630
- this.createStepUpdaterFnImpl(e, t, r);
1010
+ update(e) {
1011
+ this.createStepUpdaterFnImpl(e);
631
1012
  }
632
1013
  createStepHelperFnImpl(e) {
633
1014
  return (t, r) => {
634
- const s = N(
1015
+ const n = I(
635
1016
  this.value,
636
1017
  e
637
1018
  );
638
1019
  if (typeof t == "function")
639
- return () => t({ ctx: s });
1020
+ return () => t({
1021
+ ctx: n,
1022
+ update: this.createHelperFnInputUpdate(e)
1023
+ });
640
1024
  if (typeof t == "object")
641
- return (n) => "validator" in t ? (h(
642
- typeof n == "object",
643
- "An input is expected since you provided a validator"
644
- ), fe(
645
- t.validator,
646
- n.data
647
- ), r({ ctx: s, ...n })) : r({ ctx: s });
1025
+ return (s) => {
1026
+ if ("validator" in t) {
1027
+ j(
1028
+ typeof s == "object",
1029
+ "An input is expected since you provided a validator"
1030
+ ), be(
1031
+ t.validator,
1032
+ s.data
1033
+ );
1034
+ let i = n;
1035
+ if (t.ctxData) {
1036
+ const y = e[0], { [y]: b, ...f } = this.value;
1037
+ i = {
1038
+ ...i,
1039
+ ...t.ctxData({ ctx: f })
1040
+ };
1041
+ }
1042
+ return r({
1043
+ ctx: i,
1044
+ update: this.createHelperFnInputUpdate(e),
1045
+ ...s
1046
+ });
1047
+ }
1048
+ return r({ ctx: n, update: this.createHelperFnInputUpdate(e) });
1049
+ };
648
1050
  throw new Error(
649
1051
  `The first argument must be a function or an object, (was ${typeof t})`
650
1052
  );
@@ -655,57 +1057,58 @@ class G extends pe {
655
1057
  }
656
1058
  // Implementation
657
1059
  createHelperFn(e, t) {
658
- const { stepData: r, ...s } = e;
659
- return this.createStepHelperFnImpl(r)(s, t);
1060
+ const { stepData: r, ...n } = e;
1061
+ return this.createStepHelperFnImpl(r)(n, t);
660
1062
  }
661
1063
  /**
662
1064
  * Validates that a given object is the proper shape for step data.
663
1065
  * @param value
664
1066
  */
665
1067
  static hasData(e, t) {
666
- return e === null || typeof e != "object" ? !1 : X(e, {
1068
+ return e === null || typeof e != "object" ? !1 : ae(e, {
667
1069
  title: (r) => typeof r == "string",
668
1070
  fields: (r) => {
669
1071
  if (r === null || typeof r != "object")
670
1072
  return !1;
671
- for (const s of Object.keys(r)) {
672
- if (typeof s != "string" || !(s in r))
1073
+ for (const n of Object.keys(r)) {
1074
+ if (typeof n != "string" || !(n in r))
673
1075
  return !1;
674
- const n = r[s];
675
- if (n === null || typeof n != "object" || !X(n, {
1076
+ const s = r[n];
1077
+ if (s === null || typeof s != "object" || !ae(s, {
676
1078
  defaultValue: (i) => i !== "undefined" && i !== null,
677
1079
  label: (i) => typeof i == "string" || typeof i == "boolean" && !i,
678
- nameTransformCasing: R,
679
- type: Oe
1080
+ nameTransformCasing: J,
1081
+ type: Ce
680
1082
  }))
681
1083
  return !1;
682
1084
  }
683
1085
  return !0;
684
1086
  },
685
1087
  createHelperFn: (r) => typeof r == "function",
686
- update: (r) => typeof r == "function",
687
- nameTransformCasing: R,
1088
+ // update: (v): v is GetCurrentStep<resolvedStep, stepNumbers>['update'] =>
1089
+ // typeof v === 'function',
1090
+ nameTransformCasing: J,
688
1091
  ...t?.optionalKeysToCheck
689
1092
  });
690
1093
  }
691
1094
  }
692
- class $e extends pe {
1095
+ class Ve extends Se {
693
1096
  defaultNameTransformationCasing;
694
1097
  stepSchema;
695
1098
  storage;
696
1099
  mountCount = 0;
697
1100
  constructor(e) {
698
1101
  super();
699
- const { steps: t, nameTransformCasing: r, storage: s } = e;
700
- this.defaultNameTransformationCasing = le(
1102
+ const { steps: t, nameTransformCasing: r, storage: n } = e;
1103
+ this.defaultNameTransformationCasing = ge(
701
1104
  r
702
- ), this.stepSchema = new G({
1105
+ ), this.stepSchema = new ee({
703
1106
  steps: t,
704
1107
  nameTransformCasing: this.defaultNameTransformationCasing
705
- }), this.storage = new ce({
706
- key: s?.key ?? W,
1108
+ }), this.storage = new ye({
1109
+ key: n?.key ?? Q,
707
1110
  data: this.stepSchema.value,
708
- store: s?.store
1111
+ store: n?.store
709
1112
  }), this.stepSchema.subscribe(() => {
710
1113
  this.notify();
711
1114
  });
@@ -740,66 +1143,66 @@ class $e extends pe {
740
1143
  });
741
1144
  }
742
1145
  }
743
- function Ce(o) {
1146
+ function Ne(o) {
744
1147
  function e(t) {
745
- const { children: r, name: s } = t;
746
- return r(o(s));
1148
+ const { children: r, name: n } = t;
1149
+ return r(o(n));
747
1150
  }
748
1151
  return e;
749
1152
  }
750
- var $;
1153
+ var N;
751
1154
  ((o) => {
752
1155
  o.DEFAULT_FORM_ALIAS = "Form";
753
- function e(r, s) {
1156
+ function e(r, n) {
754
1157
  if (Array.isArray(r)) {
755
- if (s === "all")
1158
+ if (n === "all")
756
1159
  return !0;
757
- if (typeof s == "object" && !Array.isArray(s))
758
- return Object.keys(s).some(
759
- (n) => r.includes(n)
1160
+ if (typeof n == "object" && !Array.isArray(n))
1161
+ return Object.keys(n).some(
1162
+ (s) => r.includes(s)
760
1163
  );
761
- if (Array.isArray(s))
762
- return s.some((n) => r.includes(n));
1164
+ if (Array.isArray(n))
1165
+ return n.some((s) => r.includes(s));
763
1166
  }
764
1167
  return !1;
765
1168
  }
766
1169
  o.isFormAvailable = e;
767
1170
  function t(r) {
768
- return (s) => /* @__PURE__ */ ge("form", { id: r, ...s });
1171
+ return (n) => /* @__PURE__ */ $e("form", { id: r, ...n });
769
1172
  }
770
1173
  o.createDefaultForm = t;
771
- })($ || ($ = {}));
772
- var U;
1174
+ })(N || (N = {}));
1175
+ var Y;
773
1176
  ((o) => {
774
1177
  o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
775
- })(U || (U = {}));
776
- function je(o, e) {
777
- h(
1178
+ })(Y || (Y = {}));
1179
+ function Ie(o, e) {
1180
+ j(
778
1181
  e in o,
779
1182
  `The target step ${e} is not a valid step key`
780
1183
  );
781
1184
  const t = o[e];
782
- h("fields" in t, `No "fields" were found for ${e}`);
1185
+ j("fields" in t, `No "fields" were found for ${e}`);
783
1186
  let r = {};
784
- for (const [s, n] of Object.entries(
1187
+ for (const [n, s] of Object.entries(
785
1188
  t.fields
786
1189
  ))
787
1190
  r = {
788
1191
  ...r,
789
- [s]: n.defaultValue
1192
+ [n]: s.defaultValue
790
1193
  };
791
1194
  return r;
792
1195
  }
793
- class Ve extends G {
1196
+ class De extends ee {
794
1197
  // @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
795
1198
  value;
796
1199
  constructor(e) {
797
1200
  const { form: t, ...r } = e;
798
- super(r), this.value = this.enrichValues(he(this.original)), this.value = this.enrichValues(this.value, (s) => {
799
- const n = `step${s}`, i = t?.id ?? n;
1201
+ super(r), this.value = this.enrichValues(Oe(this.original)), this.value = this.enrichValues(this.value, (n) => {
1202
+ const s = `step${n}`, i = t?.id ?? s;
800
1203
  return {
801
1204
  createComponent: this.createComponentForStep(
802
- [`step${s}`],
1205
+ [`step${n}`],
803
1206
  {
804
1207
  isStepSpecific: !0,
805
1208
  defaultId: i,
@@ -810,196 +1213,193 @@ class Ve extends G {
810
1213
  });
811
1214
  }
812
1215
  createFormComponent(e, t) {
813
- const { render: r, enabledForSteps: s = "all", id: n = t } = e, i = {
814
- id: n,
815
- steps: N(this.value, s)
1216
+ const { render: r, enabledForSteps: n = "all", id: s = t } = e, i = {
1217
+ id: s,
1218
+ steps: I(this.value, n)
816
1219
  };
817
- return (p) => r(i, p);
1220
+ return (y) => r(i, y);
818
1221
  }
819
- createStepSpecificComponentImpl(e, t, r, s = {}) {
820
- return (n) => ((i) => {
821
- const p = {};
822
- for (const [u, l] of Object.entries(s))
823
- if (typeof l == "function")
1222
+ createStepSpecificComponentImpl(e, t, r, n = {}) {
1223
+ return (s) => ((i) => {
1224
+ const y = {};
1225
+ for (const [O, $] of Object.entries(n))
1226
+ if (typeof $ == "function")
824
1227
  try {
825
- const a = l();
826
- p[u] = a, typeof console < "u" && console.debug && console.debug(
827
- `[multi-step-form] Hook "${u}" called successfully`,
828
- { result: a !== void 0 ? "defined" : "undefined" }
1228
+ const w = $();
1229
+ y[O] = w, typeof console < "u" && console.debug && console.debug(
1230
+ `[multi-step-form] Hook "${O}" called successfully`,
1231
+ { result: w !== void 0 ? "defined" : "undefined" }
829
1232
  );
830
- } catch (a) {
831
- const c = a instanceof Error ? a.message : String(a);
1233
+ } catch (w) {
1234
+ const a = w instanceof Error ? w.message : String(w);
832
1235
  throw new Error(
833
- `[multi-step-form] Error calling hook "${u}" in useFormInstance.render: ${c}
1236
+ `[multi-step-form] Error calling hook "${O}" in useFormInstance.render: ${a}
834
1237
 
835
1238
  This usually means:
836
1239
  1. The hook is being called outside of a React component
837
1240
  2. The hook has invalid dependencies or configuration
838
1241
  3. There's an error in your hook implementation
839
1242
 
840
- Original error: ${c}`,
841
- { cause: a }
1243
+ Original error: ${a}`,
1244
+ { cause: w }
842
1245
  );
843
1246
  }
844
1247
  else
845
- p[u] = l;
846
- const { defaultId: y, form: f } = t, { ctx: d } = r;
847
- if (f) {
848
- const {
849
- alias: u = $.DEFAULT_FORM_ALIAS,
850
- ...l
851
- } = f, a = l.enabledForSteps ?? "all", [c] = e;
852
- h(
853
- this.steps.isValidStepKey(c),
854
- `[createComponent]: the target step ${c} is invalid. Note, this error shouldn't appear as the target step should always be valid. If you see this error, please open an issue.`
855
- );
856
- const m = Number.parseInt(c.replace("step", ""));
857
- h(
858
- !Number.isNaN(m),
859
- `[${c}:"createComponent"]: an error occurred while extracting the number`
860
- );
861
- const b = this.value[c];
862
- h(
863
- "fields" in b,
864
- `[${c}:createComponent]: unable to find the "fields" for the current step`
865
- ), h(
866
- typeof b.fields == "object",
867
- `[${c}:createComponent]: the "fields" property must be an object, was ${typeof b.fields}`
1248
+ y[O] = $;
1249
+ const { defaultId: b, form: f } = t, { ctx: g } = r, [c] = e;
1250
+ j(
1251
+ this.steps.isValidStepKey(c),
1252
+ `[createComponent]: the target step ${c} is invalid. Note, this error shouldn't appear as the target step should always be valid. If you see this error, please open an issue.`
1253
+ );
1254
+ const m = Number.parseInt(c.replace("step", ""));
1255
+ j(
1256
+ !Number.isNaN(m),
1257
+ `[${c}:"createComponent"]: an error occurred while extracting the number`
1258
+ );
1259
+ const p = this.value[c];
1260
+ j(
1261
+ "fields" in p,
1262
+ `[${c}:createComponent]: unable to find the "fields" for the current step`
1263
+ ), j(
1264
+ typeof p.fields == "object",
1265
+ `[${c}:createComponent]: the "fields" property must be an object, was ${typeof p.fields}`
1266
+ );
1267
+ const v = Ne((O) => {
1268
+ j(typeof O == "string", () => {
1269
+ const d = new Intl.ListFormat("en", {
1270
+ style: "long",
1271
+ type: "disjunction"
1272
+ });
1273
+ return `[${c}:Field]: the "name" prop must be a string and a valid field for ${c}. Available fields include ${d.format(
1274
+ Object.keys(p.fields)
1275
+ )}`;
1276
+ }), j(
1277
+ O in p.fields,
1278
+ `[${c}:Field]: the field "${O}" doesn't exist for the current step`
1279
+ ), j(
1280
+ "update" in p,
1281
+ `[${c}:Field]: No "update" function was found`
868
1282
  );
869
- const _ = Ce((g) => {
870
- h(typeof g == "string", () => {
871
- const x = new Intl.ListFormat("en", {
872
- style: "long",
873
- type: "disjunction"
874
- });
875
- return `[${c}:Field]: the "name" prop must be a string and a valid field for ${c}. Available fields include ${x.format(
876
- Object.keys(b.fields)
877
- )}`;
878
- }), h(
879
- g in b.fields,
880
- `[${c}:Field]: the field "${g}" doesn't exist for the current step`
881
- );
882
- const { fields: O, update: T } = b, { defaultValue: S, label: v, nameTransformCasing: E, type: be } = O[g];
883
- return {
884
- defaultValue: S,
885
- label: v,
886
- nameTransformCasing: E,
887
- type: be,
888
- name: g,
889
- onInputChange: (x) => (
890
- // TODO remove type assertions
891
- T(
892
- "fields",
893
- (P) => ({
894
- ...P,
895
- [g]: {
896
- ...P[g],
897
- defaultValue: x
898
- }
899
- })
900
- )
901
- )
902
- };
903
- });
904
- let w = {
905
- ctx: d,
906
- onInputChange: this.createStepUpdaterFn(m),
907
- Field: _,
908
- ...p
1283
+ const { fields: $, update: w } = p, { defaultValue: a, label: l, nameTransformCasing: h, type: u } = $[O];
1284
+ return {
1285
+ defaultValue: a,
1286
+ label: l,
1287
+ nameTransformCasing: h,
1288
+ type: u,
1289
+ name: O,
1290
+ onInputChange: (d) => (
1291
+ // TODO remove type assertions
1292
+ w({
1293
+ fields: [`fields.${O}.defaultValue`],
1294
+ updater: d
1295
+ })
1296
+ )
909
1297
  };
910
- return $.isFormAvailable(
1298
+ });
1299
+ let S = {
1300
+ ctx: g,
1301
+ onInputChange: this.createStepUpdaterFn(c),
1302
+ Field: v,
1303
+ ...y
1304
+ };
1305
+ if (f) {
1306
+ const {
1307
+ alias: O = N.DEFAULT_FORM_ALIAS,
1308
+ ...$
1309
+ } = f, w = $.enabledForSteps ?? "all";
1310
+ return N.isFormAvailable(
911
1311
  e,
912
- a
913
- ) && (w = {
914
- ...w,
915
- [u]: this.createFormComponent(l, y)
916
- }), n(w, i);
1312
+ w
1313
+ ) && (S = {
1314
+ ...S,
1315
+ [O]: this.createFormComponent($, b)
1316
+ }), s(S, i);
917
1317
  }
918
- return n(
1318
+ return s(
919
1319
  {
920
- ctx: d,
921
- [$.DEFAULT_FORM_ALIAS]: $.createDefaultForm(y)
1320
+ ...S,
1321
+ [N.DEFAULT_FORM_ALIAS]: N.createDefaultForm(b)
922
1322
  },
923
1323
  i
924
1324
  );
925
1325
  });
926
1326
  }
927
1327
  createStepSpecificComponentFactory(e, t, r) {
928
- const s = this.createStepSpecificComponentImpl.bind(this), n = this.createDefaultValues.bind(this), i = this.value;
929
- function p(y, f) {
930
- function d(l) {
931
- return l ? { ctx: { ...r, ...l } } : { ctx: r };
1328
+ const n = this.createStepSpecificComponentImpl.bind(this), s = this.createDefaultValues.bind(this), i = this.value;
1329
+ function y(b, f) {
1330
+ function g(m) {
1331
+ return m ? { ctx: { ...r, ...m } } : { ctx: r };
932
1332
  }
933
- function u() {
934
- return h(
935
- typeof y == "function",
1333
+ function c() {
1334
+ return j(
1335
+ typeof b == "function",
936
1336
  "The first argument must be a function"
937
- ), s(
1337
+ ), n(
938
1338
  e,
939
1339
  t,
940
- d(void 0)
941
- )(y);
1340
+ g(void 0)
1341
+ )(b);
942
1342
  }
943
- if (typeof y == "object") {
944
- const { useFormInstance: l, ctxData: a, debug: c } = y, m = e[0], b = new ue({
945
- debug: c,
946
- prefix(g) {
947
- return `${g}-${String(m)}-createComponent`;
1343
+ if (typeof b == "object") {
1344
+ const { useFormInstance: m, ctxData: p, debug: v } = b, S = e[0], O = new me({
1345
+ debug: v,
1346
+ prefix(a) {
1347
+ return `${a}-${String(S)}-createComponent`;
948
1348
  }
949
1349
  });
950
- b.info("First argument is an object");
951
- const { [m]: _, ...w } = i;
952
- if (h(
1350
+ O.info("First argument is an object");
1351
+ const { [S]: $, ...w } = i;
1352
+ if (j(
953
1353
  typeof f == "function",
954
1354
  "The second argument must be a function"
955
- ), l) {
1355
+ ), m) {
956
1356
  const {
957
- render: g,
958
- alias: O = U.DEFAULT_FORM_INSTANCE_ALIAS
959
- } = l, [T] = e, S = n(T), v = a ? {
1357
+ render: a,
1358
+ alias: l = Y.DEFAULT_FORM_INSTANCE_ALIAS
1359
+ } = m, [h] = e, u = s(h), d = p ? {
960
1360
  ...r,
961
- ...a({ ctx: w })
962
- } : r, E = { ctx: v, defaultValues: S };
963
- return s(
1361
+ ...p({ ctx: w })
1362
+ } : r, E = { ctx: d, defaultValues: u };
1363
+ return n(
964
1364
  e,
965
1365
  t,
966
- v,
1366
+ d,
967
1367
  {
968
- [O]: () => g(E)
1368
+ [l]: () => a(E)
969
1369
  }
970
1370
  )(f);
971
1371
  }
972
- if (a) {
973
- b.info('Option "ctxData" is defined'), h(
974
- typeof a == "function",
1372
+ if (p) {
1373
+ O.info('Option "ctxData" is defined'), j(
1374
+ typeof p == "function",
975
1375
  'Option "ctxData" must be a function'
976
1376
  );
977
- const g = a({ ctx: w });
978
- b.info(
979
- `Addition context is: ${JSON.stringify(g, null, 2)}`
1377
+ const a = p({ ctx: w });
1378
+ O.info(
1379
+ `Addition context is: ${JSON.stringify(a, null, 2)}`
980
1380
  );
981
- const O = {
1381
+ const l = {
982
1382
  ...r,
983
- ...g
1383
+ ...a
984
1384
  };
985
- return b.info(
986
- `Resolved context is: ${JSON.stringify(O, null, 2)}`
987
- ), s(e, t, {
988
- ctx: O
1385
+ return O.info(
1386
+ `Resolved context is: ${JSON.stringify(l, null, 2)}`
1387
+ ), n(e, t, {
1388
+ ctx: l
989
1389
  })(f);
990
1390
  }
991
- return u();
1391
+ return c();
992
1392
  }
993
- return u();
1393
+ return c();
994
1394
  }
995
- return p;
1395
+ return y;
996
1396
  }
997
1397
  createComponentImpl(e, t) {
998
- const r = N(
1398
+ const r = I(
999
1399
  this.value,
1000
1400
  e
1001
1401
  );
1002
- return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (s) => ((n) => s(r, n));
1402
+ return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (n) => ((s) => n(r, s));
1003
1403
  }
1004
1404
  createComponentForStep(e, t) {
1005
1405
  return this.createComponentImpl(e, t);
@@ -1017,34 +1417,34 @@ Original error: ${c}`,
1017
1417
  })(t);
1018
1418
  }
1019
1419
  createDefaultValues(e) {
1020
- return je(this.value, e);
1420
+ return Ie(this.value, e);
1021
1421
  }
1022
1422
  }
1023
- class Ae extends $e {
1423
+ class Le extends Ve {
1024
1424
  stepSchema;
1025
1425
  constructor(e) {
1026
- const { nameTransformCasing: t = K, storage: r, ...s } = e;
1426
+ const { nameTransformCasing: t = X, storage: r, ...n } = e;
1027
1427
  super({
1028
1428
  nameTransformCasing: t,
1029
1429
  storage: r,
1030
- ...s
1031
- }), this.stepSchema = new Ve({
1430
+ ...n
1431
+ }), this.stepSchema = new De({
1032
1432
  nameTransformCasing: t,
1033
- ...s
1433
+ ...n
1034
1434
  });
1035
1435
  }
1036
1436
  createComponent(e, t) {
1037
- const { stepData: r } = e, s = N(
1437
+ const { stepData: r } = e, n = I(
1038
1438
  this.stepSchema.value,
1039
1439
  r
1040
1440
  );
1041
- return ((n) => t({ ctx: s }, n));
1441
+ return ((s) => t({ ctx: n }, s));
1042
1442
  }
1043
1443
  }
1044
- function Re(o) {
1045
- return new Ae(o);
1444
+ function Be(o) {
1445
+ return new Le(o);
1046
1446
  }
1047
- var C = { exports: {} }, L = {}, j = { exports: {} }, D = {};
1447
+ var D = { exports: {} }, K = {}, L = { exports: {} }, B = {};
1048
1448
  /**
1049
1449
  * @license React
1050
1450
  * use-sync-external-store-shim.production.js
@@ -1054,48 +1454,48 @@ var C = { exports: {} }, L = {}, j = { exports: {} }, D = {};
1054
1454
  * This source code is licensed under the MIT license found in the
1055
1455
  * LICENSE file in the root directory of this source tree.
1056
1456
  */
1057
- var te;
1058
- function Ne() {
1059
- if (te) return D;
1060
- te = 1;
1061
- var o = F;
1062
- function e(u, l) {
1063
- return u === l && (u !== 0 || 1 / u === 1 / l) || u !== u && l !== l;
1064
- }
1065
- var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, s = o.useEffect, n = o.useLayoutEffect, i = o.useDebugValue;
1066
- function p(u, l) {
1067
- var a = l(), c = r({ inst: { value: a, getSnapshot: l } }), m = c[0].inst, b = c[1];
1068
- return n(
1457
+ var ue;
1458
+ function Me() {
1459
+ if (ue) return B;
1460
+ ue = 1;
1461
+ var o = W;
1462
+ function e(c, m) {
1463
+ return c === m && (c !== 0 || 1 / c === 1 / m) || c !== c && m !== m;
1464
+ }
1465
+ var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, n = o.useEffect, s = o.useLayoutEffect, i = o.useDebugValue;
1466
+ function y(c, m) {
1467
+ var p = m(), v = r({ inst: { value: p, getSnapshot: m } }), S = v[0].inst, O = v[1];
1468
+ return s(
1069
1469
  function() {
1070
- m.value = a, m.getSnapshot = l, y(m) && b({ inst: m });
1470
+ S.value = p, S.getSnapshot = m, b(S) && O({ inst: S });
1071
1471
  },
1072
- [u, a, l]
1073
- ), s(
1472
+ [c, p, m]
1473
+ ), n(
1074
1474
  function() {
1075
- return y(m) && b({ inst: m }), u(function() {
1076
- y(m) && b({ inst: m });
1475
+ return b(S) && O({ inst: S }), c(function() {
1476
+ b(S) && O({ inst: S });
1077
1477
  });
1078
1478
  },
1079
- [u]
1080
- ), i(a), a;
1479
+ [c]
1480
+ ), i(p), p;
1081
1481
  }
1082
- function y(u) {
1083
- var l = u.getSnapshot;
1084
- u = u.value;
1482
+ function b(c) {
1483
+ var m = c.getSnapshot;
1484
+ c = c.value;
1085
1485
  try {
1086
- var a = l();
1087
- return !t(u, a);
1486
+ var p = m();
1487
+ return !t(c, p);
1088
1488
  } catch {
1089
1489
  return !0;
1090
1490
  }
1091
1491
  }
1092
- function f(u, l) {
1093
- return l();
1492
+ function f(c, m) {
1493
+ return m();
1094
1494
  }
1095
- var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : p;
1096
- return D.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : d, D;
1495
+ var g = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : y;
1496
+ return B.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : g, B;
1097
1497
  }
1098
- var k = {};
1498
+ var q = {};
1099
1499
  /**
1100
1500
  * @license React
1101
1501
  * use-sync-external-store-shim.development.js
@@ -1105,62 +1505,62 @@ var k = {};
1105
1505
  * This source code is licensed under the MIT license found in the
1106
1506
  * LICENSE file in the root directory of this source tree.
1107
1507
  */
1108
- var re;
1109
- function Fe() {
1110
- return re || (re = 1, process.env.NODE_ENV !== "production" && (function() {
1111
- function o(a, c) {
1112
- return a === c && (a !== 0 || 1 / a === 1 / c) || a !== a && c !== c;
1508
+ var ce;
1509
+ function Ue() {
1510
+ return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
1511
+ function o(p, v) {
1512
+ return p === v && (p !== 0 || 1 / p === 1 / v) || p !== p && v !== v;
1113
1513
  }
1114
- function e(a, c) {
1115
- d || s.startTransition === void 0 || (d = !0, console.error(
1514
+ function e(p, v) {
1515
+ g || n.startTransition === void 0 || (g = !0, console.error(
1116
1516
  "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."
1117
1517
  ));
1118
- var m = c();
1119
- if (!u) {
1120
- var b = c();
1121
- n(m, b) || (console.error(
1518
+ var S = v();
1519
+ if (!c) {
1520
+ var O = v();
1521
+ s(S, O) || (console.error(
1122
1522
  "The result of getSnapshot should be cached to avoid an infinite loop"
1123
- ), u = !0);
1523
+ ), c = !0);
1124
1524
  }
1125
- b = i({
1126
- inst: { value: m, getSnapshot: c }
1525
+ O = i({
1526
+ inst: { value: S, getSnapshot: v }
1127
1527
  });
1128
- var _ = b[0].inst, w = b[1];
1129
- return y(
1528
+ var $ = O[0].inst, w = O[1];
1529
+ return b(
1130
1530
  function() {
1131
- _.value = m, _.getSnapshot = c, t(_) && w({ inst: _ });
1531
+ $.value = S, $.getSnapshot = v, t($) && w({ inst: $ });
1132
1532
  },
1133
- [a, m, c]
1134
- ), p(
1533
+ [p, S, v]
1534
+ ), y(
1135
1535
  function() {
1136
- return t(_) && w({ inst: _ }), a(function() {
1137
- t(_) && w({ inst: _ });
1536
+ return t($) && w({ inst: $ }), p(function() {
1537
+ t($) && w({ inst: $ });
1138
1538
  });
1139
1539
  },
1140
- [a]
1141
- ), f(m), m;
1540
+ [p]
1541
+ ), f(S), S;
1142
1542
  }
1143
- function t(a) {
1144
- var c = a.getSnapshot;
1145
- a = a.value;
1543
+ function t(p) {
1544
+ var v = p.getSnapshot;
1545
+ p = p.value;
1146
1546
  try {
1147
- var m = c();
1148
- return !n(a, m);
1547
+ var S = v();
1548
+ return !s(p, S);
1149
1549
  } catch {
1150
1550
  return !0;
1151
1551
  }
1152
1552
  }
1153
- function r(a, c) {
1154
- return c();
1553
+ function r(p, v) {
1554
+ return v();
1155
1555
  }
1156
1556
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1157
- var s = F, n = typeof Object.is == "function" ? Object.is : o, i = s.useState, p = s.useEffect, y = s.useLayoutEffect, f = s.useDebugValue, d = !1, u = !1, l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
1158
- k.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : l, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1159
- })()), k;
1557
+ var n = W, s = typeof Object.is == "function" ? Object.is : o, i = n.useState, y = n.useEffect, b = n.useLayoutEffect, f = n.useDebugValue, g = !1, c = !1, m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
1558
+ q.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1559
+ })()), q;
1160
1560
  }
1161
- var ne;
1162
- function me() {
1163
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? j.exports = Ne() : j.exports = Fe()), j.exports;
1561
+ var le;
1562
+ function je() {
1563
+ return le || (le = 1, process.env.NODE_ENV === "production" ? L.exports = Me() : L.exports = Ue()), L.exports;
1164
1564
  }
1165
1565
  /**
1166
1566
  * @license React
@@ -1171,58 +1571,58 @@ function me() {
1171
1571
  * This source code is licensed under the MIT license found in the
1172
1572
  * LICENSE file in the root directory of this source tree.
1173
1573
  */
1174
- var se;
1175
- function xe() {
1176
- if (se) return L;
1177
- se = 1;
1178
- var o = F, e = me();
1179
- function t(f, d) {
1180
- return f === d && (f !== 0 || 1 / f === 1 / d) || f !== f && d !== d;
1181
- }
1182
- var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, i = o.useEffect, p = o.useMemo, y = o.useDebugValue;
1183
- return L.useSyncExternalStoreWithSelector = function(f, d, u, l, a) {
1184
- var c = n(null);
1185
- if (c.current === null) {
1186
- var m = { hasValue: !1, value: null };
1187
- c.current = m;
1188
- } else m = c.current;
1189
- c = p(
1574
+ var fe;
1575
+ function Re() {
1576
+ if (fe) return K;
1577
+ fe = 1;
1578
+ var o = W, e = je();
1579
+ function t(f, g) {
1580
+ return f === g && (f !== 0 || 1 / f === 1 / g) || f !== f && g !== g;
1581
+ }
1582
+ var r = typeof Object.is == "function" ? Object.is : t, n = e.useSyncExternalStore, s = o.useRef, i = o.useEffect, y = o.useMemo, b = o.useDebugValue;
1583
+ return K.useSyncExternalStoreWithSelector = function(f, g, c, m, p) {
1584
+ var v = s(null);
1585
+ if (v.current === null) {
1586
+ var S = { hasValue: !1, value: null };
1587
+ v.current = S;
1588
+ } else S = v.current;
1589
+ v = y(
1190
1590
  function() {
1191
- function _(S) {
1591
+ function $(u) {
1192
1592
  if (!w) {
1193
- if (w = !0, g = S, S = l(S), a !== void 0 && m.hasValue) {
1194
- var v = m.value;
1195
- if (a(v, S))
1196
- return O = v;
1593
+ if (w = !0, a = u, u = m(u), p !== void 0 && S.hasValue) {
1594
+ var d = S.value;
1595
+ if (p(d, u))
1596
+ return l = d;
1197
1597
  }
1198
- return O = S;
1598
+ return l = u;
1199
1599
  }
1200
- if (v = O, r(g, S)) return v;
1201
- var E = l(S);
1202
- return a !== void 0 && a(v, E) ? (g = S, v) : (g = S, O = E);
1600
+ if (d = l, r(a, u)) return d;
1601
+ var E = m(u);
1602
+ return p !== void 0 && p(d, E) ? (a = u, d) : (a = u, l = E);
1203
1603
  }
1204
- var w = !1, g, O, T = u === void 0 ? null : u;
1604
+ var w = !1, a, l, h = c === void 0 ? null : c;
1205
1605
  return [
1206
1606
  function() {
1207
- return _(d());
1607
+ return $(g());
1208
1608
  },
1209
- T === null ? void 0 : function() {
1210
- return _(T());
1609
+ h === null ? void 0 : function() {
1610
+ return $(h());
1211
1611
  }
1212
1612
  ];
1213
1613
  },
1214
- [d, u, l, a]
1614
+ [g, c, m, p]
1215
1615
  );
1216
- var b = s(f, c[0], c[1]);
1616
+ var O = n(f, v[0], v[1]);
1217
1617
  return i(
1218
1618
  function() {
1219
- m.hasValue = !0, m.value = b;
1619
+ S.hasValue = !0, S.value = O;
1220
1620
  },
1221
- [b]
1222
- ), y(b), b;
1223
- }, L;
1621
+ [O]
1622
+ ), b(O), O;
1623
+ }, K;
1224
1624
  }
1225
- var M = {};
1625
+ var z = {};
1226
1626
  /**
1227
1627
  * @license React
1228
1628
  * use-sync-external-store-shim/with-selector.development.js
@@ -1232,96 +1632,96 @@ var M = {};
1232
1632
  * This source code is licensed under the MIT license found in the
1233
1633
  * LICENSE file in the root directory of this source tree.
1234
1634
  */
1235
- var oe;
1236
- function Ie() {
1237
- return oe || (oe = 1, process.env.NODE_ENV !== "production" && (function() {
1238
- function o(f, d) {
1239
- return f === d && (f !== 0 || 1 / f === 1 / d) || f !== f && d !== d;
1635
+ var pe;
1636
+ function He() {
1637
+ return pe || (pe = 1, process.env.NODE_ENV !== "production" && (function() {
1638
+ function o(f, g) {
1639
+ return f === g && (f !== 0 || 1 / f === 1 / g) || f !== f && g !== g;
1240
1640
  }
1241
1641
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1242
- var e = F, t = me(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, i = e.useEffect, p = e.useMemo, y = e.useDebugValue;
1243
- M.useSyncExternalStoreWithSelector = function(f, d, u, l, a) {
1244
- var c = n(null);
1245
- if (c.current === null) {
1246
- var m = { hasValue: !1, value: null };
1247
- c.current = m;
1248
- } else m = c.current;
1249
- c = p(
1642
+ var e = W, t = je(), r = typeof Object.is == "function" ? Object.is : o, n = t.useSyncExternalStore, s = e.useRef, i = e.useEffect, y = e.useMemo, b = e.useDebugValue;
1643
+ z.useSyncExternalStoreWithSelector = function(f, g, c, m, p) {
1644
+ var v = s(null);
1645
+ if (v.current === null) {
1646
+ var S = { hasValue: !1, value: null };
1647
+ v.current = S;
1648
+ } else S = v.current;
1649
+ v = y(
1250
1650
  function() {
1251
- function _(S) {
1651
+ function $(u) {
1252
1652
  if (!w) {
1253
- if (w = !0, g = S, S = l(S), a !== void 0 && m.hasValue) {
1254
- var v = m.value;
1255
- if (a(v, S))
1256
- return O = v;
1653
+ if (w = !0, a = u, u = m(u), p !== void 0 && S.hasValue) {
1654
+ var d = S.value;
1655
+ if (p(d, u))
1656
+ return l = d;
1257
1657
  }
1258
- return O = S;
1658
+ return l = u;
1259
1659
  }
1260
- if (v = O, r(g, S))
1261
- return v;
1262
- var E = l(S);
1263
- return a !== void 0 && a(v, E) ? (g = S, v) : (g = S, O = E);
1660
+ if (d = l, r(a, u))
1661
+ return d;
1662
+ var E = m(u);
1663
+ return p !== void 0 && p(d, E) ? (a = u, d) : (a = u, l = E);
1264
1664
  }
1265
- var w = !1, g, O, T = u === void 0 ? null : u;
1665
+ var w = !1, a, l, h = c === void 0 ? null : c;
1266
1666
  return [
1267
1667
  function() {
1268
- return _(d());
1668
+ return $(g());
1269
1669
  },
1270
- T === null ? void 0 : function() {
1271
- return _(T());
1670
+ h === null ? void 0 : function() {
1671
+ return $(h());
1272
1672
  }
1273
1673
  ];
1274
1674
  },
1275
- [d, u, l, a]
1675
+ [g, c, m, p]
1276
1676
  );
1277
- var b = s(f, c[0], c[1]);
1677
+ var O = n(f, v[0], v[1]);
1278
1678
  return i(
1279
1679
  function() {
1280
- m.hasValue = !0, m.value = b;
1680
+ S.hasValue = !0, S.value = O;
1281
1681
  },
1282
- [b]
1283
- ), y(b), b;
1682
+ [O]
1683
+ ), b(O), O;
1284
1684
  }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1285
- })()), M;
1685
+ })()), z;
1286
1686
  }
1287
- var ie;
1288
- function Le() {
1289
- return ie || (ie = 1, process.env.NODE_ENV === "production" ? C.exports = xe() : C.exports = Ie()), C.exports;
1687
+ var de;
1688
+ function We() {
1689
+ return de || (de = 1, process.env.NODE_ENV === "production" ? D.exports = Re() : D.exports = He()), D.exports;
1290
1690
  }
1291
- var De = Le();
1292
- function H(o, e) {
1293
- h(
1691
+ var Pe = We();
1692
+ function Z(o, e) {
1693
+ j(
1294
1694
  typeof e == "string",
1295
1695
  `The target step must be a string, was ${typeof e}`
1296
1696
  );
1297
- const { as: t, isValidStepNumber: r } = o.stepSchema.steps, n = new Intl.ListFormat("en", {
1697
+ const { as: t, isValidStepNumber: r } = o.stepSchema.steps, s = new Intl.ListFormat("en", {
1298
1698
  type: "disjunction",
1299
1699
  style: "long"
1300
1700
  }).format(t("array.string.untyped"));
1301
- h(
1302
- de.test(e),
1303
- `The target step must match the following format: "step{number}". Available steps are ${n}`
1701
+ j(
1702
+ ve.test(e),
1703
+ `The target step must match the following format: "step{number}". Available steps are ${s}`
1304
1704
  );
1305
1705
  const i = Number.parseInt(e.replace("step", ""));
1306
- return h(
1706
+ return j(
1307
1707
  r(i),
1308
- `The step number "${i}" is not a valid step number. Valid step numbers include ${n}`,
1708
+ `The step number "${i}" is not a valid step number. Valid step numbers include ${s}`,
1309
1709
  TypeError
1310
1710
  ), i;
1311
1711
  }
1312
- function ye(o) {
1712
+ function Ee(o) {
1313
1713
  function e(t) {
1314
- return De.useSyncExternalStoreWithSelector(
1714
+ return Pe.useSyncExternalStoreWithSelector(
1315
1715
  o.subscribe,
1316
1716
  () => o.getSnapshot(),
1317
1717
  () => o.getSnapshot(),
1318
1718
  (r) => {
1319
1719
  if (typeof t == "object") {
1320
- const s = H(
1720
+ const n = Z(
1321
1721
  r,
1322
1722
  t.targetStep
1323
1723
  );
1324
- return r.stepSchema.get({ step: s }).data;
1724
+ return r.stepSchema.get({ step: n }).data;
1325
1725
  }
1326
1726
  return typeof t == "function" ? t(r) : r;
1327
1727
  }
@@ -1329,88 +1729,88 @@ function ye(o) {
1329
1729
  }
1330
1730
  return e;
1331
1731
  }
1332
- function Ue(o, e) {
1333
- const t = ye(o);
1732
+ function qe(o, e) {
1733
+ const t = Ee(o);
1334
1734
  return typeof e == "object" || typeof e == "function" ? t(e) : t();
1335
1735
  }
1336
- function ae(o) {
1736
+ function he(o) {
1337
1737
  return function(e) {
1338
1738
  return ((t) => e(o, t));
1339
1739
  };
1340
1740
  }
1341
- function He(o) {
1342
- const e = ye(o);
1343
- function t(p) {
1344
- const { targetStep: y, notFoundMessage: f, isDataGuaranteed: d } = p, u = e({
1345
- targetStep: y
1346
- }), l = f ? i({ targetStep: y }, f) : (a) => /* @__PURE__ */ B("div", { ...a, children: [
1741
+ function ze(o) {
1742
+ const e = Ee(o);
1743
+ function t(y) {
1744
+ const { targetStep: b, notFoundMessage: f, isDataGuaranteed: g } = y, c = e({
1745
+ targetStep: b
1746
+ }), m = f ? i({ targetStep: b }, f) : (p) => /* @__PURE__ */ te("div", { ...p, children: [
1347
1747
  "No data found for step ",
1348
- String(y)
1748
+ String(b)
1349
1749
  ] });
1350
- return d ? {
1351
- data: u,
1352
- NoCurrentData: l
1353
- } : G.hasData(u) ? {
1354
- data: u,
1750
+ return g ? {
1751
+ data: c,
1752
+ NoCurrentData: m
1753
+ } : ee.hasData(c) ? {
1754
+ data: c,
1355
1755
  hasData: !0,
1356
- NoCurrentData: l
1756
+ NoCurrentData: m
1357
1757
  } : {
1358
1758
  data: void 0,
1359
1759
  hasData: !1,
1360
- NoCurrentData: l
1760
+ NoCurrentData: m
1361
1761
  };
1362
1762
  }
1363
- function r(p) {
1364
- const y = e(
1365
- (b) => b.stepSchema.steps.value.length
1763
+ function r(y) {
1764
+ const b = e(
1765
+ (O) => O.stepSchema.steps.value.length
1366
1766
  ), {
1367
1767
  targetStep: f,
1368
- maxProgressValue: d = 100,
1369
- totalSteps: u = y,
1370
- progressTextTransformer: l
1371
- } = p, a = H(o, f), c = a / u * d, m = l ? n(
1372
- { targetStep: f, maxProgressValue: d, totalSteps: u },
1373
- l
1374
- ) : (b) => /* @__PURE__ */ B("div", { ...b, children: [
1768
+ maxProgressValue: g = 100,
1769
+ totalSteps: c = b,
1770
+ progressTextTransformer: m
1771
+ } = y, p = Z(o, f), v = p / c * g, S = m ? s(
1772
+ { targetStep: f, maxProgressValue: g, totalSteps: c },
1773
+ m
1774
+ ) : (O) => /* @__PURE__ */ te("div", { ...O, children: [
1375
1775
  "Step ",
1376
- a,
1776
+ p,
1377
1777
  "/",
1378
- u
1778
+ c
1379
1779
  ] });
1380
1780
  return {
1381
- value: c,
1382
- maxProgressValue: d,
1383
- ProgressText: m
1781
+ value: v,
1782
+ maxProgressValue: g,
1783
+ ProgressText: S
1384
1784
  };
1385
1785
  }
1386
- function s(p) {
1387
- const f = e((u) => u.storage).get(), d = !!(f && typeof f == "object" && Object.keys(f).length > 0);
1388
- return p ? p(d) : d;
1786
+ function n(y) {
1787
+ const f = e((c) => c.storage).get(), g = !!(f && typeof f == "object" && Object.keys(f).length > 0);
1788
+ return y ? y(g) : g;
1389
1789
  }
1390
- function n(p, y) {
1391
- const f = o.getSnapshot().stepSchema.steps.value.length, { targetStep: d, maxProgressValue: u = 100, totalSteps: l = f } = p;
1392
- return ae({ targetStep: d, maxProgressValue: u, totalSteps: l })(y);
1790
+ function s(y, b) {
1791
+ const f = o.getSnapshot().stepSchema.steps.value.length, { targetStep: g, maxProgressValue: c = 100, totalSteps: m = f } = y;
1792
+ return he({ targetStep: g, maxProgressValue: c, totalSteps: m })(b);
1393
1793
  }
1394
- function i(p, y) {
1395
- return H(o, p.targetStep), ae(p)(y);
1794
+ function i(y, b) {
1795
+ return Z(o, y.targetStep), he(y)(b);
1396
1796
  }
1397
1797
  return {
1398
1798
  // MultiStepFormContext: Context,
1399
1799
  useMultiStepFormData: e,
1400
1800
  useCurrentStepData: t,
1401
1801
  useProgress: r,
1402
- useCanRestartForm: s,
1403
- withProgressText: n,
1802
+ useCanRestartForm: n,
1803
+ withProgressText: s,
1404
1804
  withNoStepDataFound: i
1405
1805
  };
1406
1806
  }
1407
1807
  export {
1408
- Ae as MultiStepFormSchema,
1409
- Ve as MultiStepFormStepSchema,
1410
- U as StepSpecificComponent,
1411
- je as createDefaultValues,
1412
- He as createMultiStepFormContext,
1413
- Re as createMultiStepFormSchema,
1414
- Ue as useMultiStepFormData
1808
+ Le as MultiStepFormSchema,
1809
+ De as MultiStepFormStepSchema,
1810
+ Y as StepSpecificComponent,
1811
+ Ie as createDefaultValues,
1812
+ ze as createMultiStepFormContext,
1813
+ Be as createMultiStepFormSchema,
1814
+ qe as useMultiStepFormData
1415
1815
  };
1416
1816
  //# sourceMappingURL=index.mjs.map