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

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,223 +1,29 @@
1
- import { jsx as me, jsxs as q } from "react/jsx-runtime";
2
- import I from "react";
3
- function V(o, e, t) {
4
- const r = [], s = new Set(o), n = t ? t.format(o.map((a) => `${a}`)) : `[${o.join(", ")}]`;
5
- for (let a = 0; a < e.length; a++) {
6
- const c = e[a];
7
- s.has(c) || r.push(
8
- `Extra element at index ${a}: "${c}" is not in ${n}`
9
- );
10
- }
11
- return e.some((a) => s.has(a)) || r.push(
12
- `Array must contain at least one valid element from ${n}`
13
- ), r.length > 0 ? { status: "error", errors: r } : { status: "success" };
14
- }
15
- function F(o) {
16
- return o.map((e, t) => `❌ ${t + 1}. ${e}`).join(`
17
- `);
18
- }
19
- function ye(o, ...e) {
1
+ import { jsx as ge, jsxs as B } from "react/jsx-runtime";
2
+ import F from "react";
3
+ function Se(o, ...e) {
20
4
  return () => String.raw({ raw: o }, ...e);
21
5
  }
22
6
  function h(o, e, t = Error) {
23
7
  if (!o) {
24
- const r = typeof e == "function" ? e() : ye`${e}`();
8
+ const r = typeof e == "function" ? e() : Se`${e}`();
25
9
  throw new t(r);
26
10
  }
27
11
  }
28
- function G(o, e) {
29
- const t = o["~standard"].validate(e);
30
- if (t instanceof Promise)
31
- throw new TypeError("Schema validation must be synchronous", {
32
- cause: o
33
- });
34
- if (t.issues)
35
- throw new Error(JSON.stringify(t.issues, null, 2));
36
- return t.value;
37
- }
38
- function C(o) {
39
- h(o.includes("step"), "Can't extract a valid step number since");
40
- const e = o.replace("step", "");
41
- return h(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
42
- }
43
- function j(o) {
44
- return function(e) {
45
- const { step: t } = e, r = `step${t}`, s = o[r];
46
- return { step: t, data: s };
47
- };
48
- }
49
- function J(o, e) {
50
- return e.reduce((t, r) => {
51
- const s = C(r), { data: n } = j(o)({
52
- step: s
53
- });
54
- for (const [a, c] of Object.entries(n))
55
- typeof c == "function" && a !== "update" || (n[a] = c);
56
- return t[r] = n, t;
57
- }, {});
58
- }
59
- function R(o, e) {
60
- const t = new Intl.ListFormat("en", {
61
- style: "long",
62
- type: "disjunction"
63
- }), r = Object.keys(o), s = () => `"stepData" must be set to an array of available steps (${t.format(
64
- r
65
- )})`;
66
- if (e === "all") {
67
- let n = {};
68
- for (const a of r)
69
- n = {
70
- ...n,
71
- [a]: j(o)({
72
- step: C(a)
73
- })
74
- };
75
- return Object.fromEntries(
76
- r.map((a) => [
77
- a,
78
- j(o)({
79
- step: C(a)
80
- })
81
- ])
82
- );
83
- }
84
- if (Array.isArray(e))
85
- return h(
86
- e.every((n) => r.includes(n)),
87
- () => {
88
- const n = V(
89
- e,
90
- r.map((a) => C(a)),
91
- t
92
- );
93
- return n.status === "error" ? `${s()}. See errors:
94
- ${F(
95
- n.errors
96
- )}` : s();
97
- }
98
- ), J(
99
- o,
100
- e
101
- );
102
- if (typeof e == "object") {
103
- const n = Object.keys(e);
104
- return h(
105
- n.every((a) => r.includes(a)),
106
- () => {
107
- const a = V(
108
- n,
109
- r,
110
- t
111
- );
112
- return a.status === "error" ? `${s()}. See errors:
113
- ${F(
114
- a.errors
115
- )}` : s();
116
- }
117
- ), J(
118
- o,
119
- n
120
- );
121
- }
122
- throw new Error(`${s()} OR to "all"`);
123
- }
124
- function Y(o, e) {
125
- return typeof o == "function" ? o(e) : o;
126
- }
127
- class be {
128
- values;
129
- stepNumbers;
130
- constructor(e, t) {
131
- this.stepNumbers = t, this.values = e;
132
- }
133
- createCtxHelper(e) {
134
- return e.reduce((t, r) => {
135
- const s = C(r), { data: n } = j(this.values)({
136
- step: s
137
- });
138
- for (const [a, c] of Object.entries(n))
139
- typeof c == "function" && a !== "update" || (n[a] = c);
140
- return t[r] = n, t;
141
- }, {});
142
- }
143
- createCtx(e) {
144
- const t = new Intl.ListFormat("en", {
145
- style: "long",
146
- type: "disjunction"
147
- }), r = this.stepNumbers.map(
148
- (n) => `step${n}`
149
- ), s = () => `"stepData" must be set to an array of available steps (${t.format(
150
- r
151
- )})`;
152
- if (e === "all")
153
- return this.stepNumbers.reduce((n, a) => {
154
- const c = `step${a}`;
155
- return n[c] = j(this.values)({
156
- step: a
157
- }).data, n;
158
- }, {});
159
- if (Array.isArray(e))
160
- return h(
161
- e.every(
162
- (n) => r.includes(n)
163
- ),
164
- () => {
165
- const n = V(
166
- e,
167
- this.stepNumbers,
168
- t
169
- );
170
- return n.status === "error" ? `${s()}. See errors:
171
- ${F(
172
- n.errors
173
- )}` : s();
174
- }
175
- ), this.createCtxHelper(e);
176
- if (typeof e == "object") {
177
- const n = Object.keys(e);
178
- return h(
179
- n.every((a) => r.includes(a)),
180
- () => {
181
- const a = V(
182
- n,
183
- r,
184
- t
185
- );
186
- return a.status === "error" ? `${s()}. See errors:
187
- ${F(
188
- a.errors
189
- )}` : s();
190
- }
191
- ), this.createCtxHelper(n);
192
- }
193
- throw new Error(`${s()} OR to "all"`);
194
- }
195
- createStepHelperFnImpl(e) {
196
- return (t, r) => {
197
- const s = this.createCtx(e);
198
- if (typeof t == "function")
199
- return () => t({ ctx: s });
200
- if (typeof t == "object")
201
- return (n) => "validator" in t ? (h(
202
- typeof n == "object",
203
- "An input is expected since you provided a validator"
204
- ), G(
205
- t.validator,
206
- n.data
207
- ), r({ ctx: s, ...n })) : r({ ctx: s });
208
- throw new Error(
209
- `The first argument must be a function or an object, (was ${typeof t})`
210
- );
211
- };
212
- }
213
- }
214
- class Se {
215
- prefix;
216
- includeTimestamp;
217
- throwOnError;
12
+ const I = "MultiStepFormSchema";
13
+ class ue {
14
+ debug;
15
+ prefix = I;
16
+ includeTimestamp = !1;
17
+ throwOnError = !1;
218
18
  constructor(e) {
219
- const { includeTimestamp: t, prefix: r, throwOnError: s } = e ?? {};
220
- this.prefix = r ?? "MultiStepFormSchema", this.includeTimestamp = t ?? !1, this.throwOnError = s ?? !1;
19
+ if (this.debug = e?.debug ?? !1, this.debug && e?.debug) {
20
+ const {
21
+ includeTimestamp: t = !1,
22
+ prefix: r = I,
23
+ throwOnError: s = !1
24
+ } = e;
25
+ this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(I), this.throwOnError = s;
26
+ }
221
27
  }
222
28
  wrapValue(e, t) {
223
29
  if (e === "[]")
@@ -255,27 +61,29 @@ class Se {
255
61
  const {
256
62
  includeTimestamp: s = this.includeTimestamp,
257
63
  prefix: n,
258
- logLevelOptions: a
259
- } = r ?? {}, c = this.formatPrefix(n), y = this.wrapValue(
260
- a?.wrapWith ?? "[]",
261
- (a?.level ?? e).toUpperCase()
262
- ), p = `${c} ${y} ${t}`;
263
- return s ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${p}` : p;
64
+ logLevelOptions: i
65
+ } = r ?? {}, p = this.formatPrefix(n), y = this.wrapValue(
66
+ i?.wrapWith ?? "[]",
67
+ (i?.level ?? e).toUpperCase()
68
+ ), f = `${p} ${y} ${t}`;
69
+ return s ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${f}` : f;
264
70
  }
265
71
  info(e, t) {
266
- console.info(this.formatMessage("info", e, t));
72
+ this.debug && console.info(this.formatMessage("info", e, t));
267
73
  }
268
74
  warn(e, t) {
269
- console.warn(this.formatMessage("warn", e, t));
75
+ this.debug && console.warn(this.formatMessage("warn", e, t));
270
76
  }
271
77
  error(e, t) {
78
+ if (!this.debug)
79
+ return;
272
80
  const r = this.formatMessage("error", e, t);
273
81
  if (console.error(r), t?.throw ?? this.throwOnError)
274
82
  throw new Error(r);
275
83
  }
276
84
  }
277
- const Z = '"window" in undefined. No storage is available', K = "MultiStepForm";
278
- class ue {
85
+ const z = '"window" in undefined. No storage is available', W = "MultiStepForm";
86
+ class ce {
279
87
  key;
280
88
  store;
281
89
  data;
@@ -283,12 +91,12 @@ class ue {
283
91
  isWindowUndefined;
284
92
  constructor(e) {
285
93
  const { key: t, data: r, store: s } = e;
286
- this.log = new Se({
287
- prefix: K
288
- }), 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));
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));
289
97
  }
290
98
  throwOnEmptyStore() {
291
- h(this.store, () => this.isWindowUndefined ? Z : "No storage available");
99
+ h(this.store, () => this.isWindowUndefined ? z : "No storage available");
292
100
  }
293
101
  resolveValue(e) {
294
102
  if (typeof e == "object")
@@ -329,8 +137,8 @@ const ve = [
329
137
  "screaming-snake",
330
138
  "flat",
331
139
  "kebab"
332
- ], P = "title";
333
- function ge(o, e) {
140
+ ], K = "title";
141
+ function _e(o, e) {
334
142
  const t = o.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).map((r) => r.toLowerCase());
335
143
  switch (e) {
336
144
  case "sentence":
@@ -357,11 +165,11 @@ function ge(o, e) {
357
165
  return o;
358
166
  }
359
167
  }
360
- function U(o) {
168
+ function R(o) {
361
169
  return typeof o != "string" ? !1 : ve.includes(o);
362
170
  }
363
- function ce(o, e = P) {
364
- return U(o) ? o : e;
171
+ function le(o, e = K) {
172
+ return R(o) ? o : e;
365
173
  }
366
174
  const we = [
367
175
  "string",
@@ -373,11 +181,21 @@ const we = [
373
181
  "date",
374
182
  "dateTime",
375
183
  "boolean.switch"
376
- ], Q = "string";
377
- function _e(o) {
184
+ ], q = "string";
185
+ function Oe(o) {
378
186
  return typeof o == "string" && we.includes(o);
379
187
  }
380
- class le {
188
+ function fe(o, e) {
189
+ const t = o["~standard"].validate(e);
190
+ if (t instanceof Promise)
191
+ throw new TypeError("Schema validation must be synchronous", {
192
+ cause: o
193
+ });
194
+ if (t.issues)
195
+ throw new Error(JSON.stringify(t.issues, null, 2));
196
+ return t.value;
197
+ }
198
+ class pe {
381
199
  listeners = /* @__PURE__ */ new Set();
382
200
  constructor() {
383
201
  this.subscribe = this.subscribe.bind(this);
@@ -395,12 +213,117 @@ class le {
395
213
  onUnsubscribe() {
396
214
  }
397
215
  }
398
- const Ee = [
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");
234
+ const e = o.replace("step", "");
235
+ return h(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
236
+ }
237
+ function A(o) {
238
+ return function(e) {
239
+ const { step: t } = e, r = `step${t}`, s = o[r];
240
+ return { step: t, data: s };
241
+ };
242
+ }
243
+ function Z(o, e) {
244
+ return e.reduce((t, r) => {
245
+ const s = V(r), { data: n } = A(o)({
246
+ step: s
247
+ });
248
+ for (const [i, p] of Object.entries(n))
249
+ typeof p == "function" && i !== "update" || (n[i] = p);
250
+ return t[r] = n, t;
251
+ }, {});
252
+ }
253
+ function N(o, e) {
254
+ const t = new Intl.ListFormat("en", {
255
+ style: "long",
256
+ type: "disjunction"
257
+ }), r = Object.keys(o), s = () => `"stepData" must be set to an array of available steps (${t.format(
258
+ r
259
+ )})`;
260
+ if (e === "all") {
261
+ let n = {};
262
+ for (const i of r)
263
+ n = {
264
+ ...n,
265
+ [i]: A(o)({
266
+ step: V(i)
267
+ })
268
+ };
269
+ return Object.fromEntries(
270
+ r.map((i) => [
271
+ i,
272
+ A(o)({
273
+ step: V(i)
274
+ })
275
+ ])
276
+ );
277
+ }
278
+ if (Array.isArray(e))
279
+ return h(
280
+ e.every((n) => r.includes(n)),
281
+ () => {
282
+ const n = J(
283
+ e,
284
+ r.map((i) => V(i)),
285
+ t
286
+ );
287
+ return n.status === "error" ? `${s()}. See errors:
288
+ ${Y(
289
+ n.errors
290
+ )}` : s();
291
+ }
292
+ ), Z(
293
+ o,
294
+ e
295
+ );
296
+ if (typeof e == "object") {
297
+ const n = Object.keys(e);
298
+ return h(
299
+ n.every((i) => r.includes(i)),
300
+ () => {
301
+ const i = J(
302
+ n,
303
+ r,
304
+ t
305
+ );
306
+ return i.status === "error" ? `${s()}. See errors:
307
+ ${Y(
308
+ i.errors
309
+ )}` : s();
310
+ }
311
+ ), Z(
312
+ o,
313
+ n
314
+ );
315
+ }
316
+ throw new Error(`${s()} OR to "all"`);
317
+ }
318
+ function Q(o, e) {
319
+ return typeof o == "function" ? o(e) : o;
320
+ }
321
+ const Te = [
399
322
  "string",
400
323
  "number",
401
324
  "array.string",
402
325
  "array.string.untyped"
403
- ], fe = /^step\d+$/i;
326
+ ], de = /^step\d+$/i;
404
327
  function X(o, e) {
405
328
  if (typeof o != "object" || o === null) return !1;
406
329
  for (const t of Object.keys(e)) {
@@ -411,40 +334,40 @@ function X(o, e) {
411
334
  return !0;
412
335
  }
413
336
  function ee(o, e, t) {
414
- return o ?? ge(e, t);
337
+ return o ?? _e(e, t);
415
338
  }
416
- function Te(o) {
339
+ function Ee(o) {
417
340
  const e = {}, { fields: t, defaultCasing: r, validateFields: s } = o;
418
- for (const [n, a] of Object.entries(t)) {
341
+ for (const [n, i] of Object.entries(t)) {
419
342
  h(
420
343
  typeof n == "string",
421
344
  `Each key for the "fields" option must be a string. Key ${n} was a ${typeof n}`
422
345
  ), h(
423
- typeof a == "object",
424
- `The value for key ${n} must be an object. Was ${typeof a}`
346
+ typeof i == "object",
347
+ `The value for key ${n} must be an object. Was ${typeof i}`
425
348
  );
426
349
  const {
427
- defaultValue: c,
350
+ defaultValue: p,
428
351
  label: y,
429
- nameTransformCasing: p,
430
- type: l = Q
431
- } = a;
352
+ nameTransformCasing: f,
353
+ type: d = q
354
+ } = i;
432
355
  if (s)
433
- e[n] = c;
356
+ e[n] = p;
434
357
  else {
435
- const u = p ?? r;
358
+ const u = f ?? r;
436
359
  e[n] = {
437
360
  ...e[n],
438
361
  nameTransformCasing: u,
439
- type: l,
440
- defaultValue: c,
362
+ type: d,
363
+ defaultValue: p,
441
364
  label: ee(y, n, u)
442
365
  // TODO add more fields here
443
366
  };
444
367
  }
445
368
  }
446
369
  if (s) {
447
- const n = G(
370
+ const n = fe(
448
371
  s,
449
372
  e
450
373
  );
@@ -455,29 +378,29 @@ function Te(o) {
455
378
  !!n,
456
379
  "The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it"
457
380
  );
458
- for (const [a, c] of Object.entries(n)) {
459
- const y = t[a];
381
+ for (const [i, p] of Object.entries(n)) {
382
+ const y = t[i];
460
383
  h(
461
384
  y,
462
- `No field found in the fields config for "${a}"`
385
+ `No field found in the fields config for "${i}"`
463
386
  );
464
387
  const {
465
- label: p,
466
- type: l = Q,
388
+ label: f,
389
+ type: d = q,
467
390
  nameTransformCasing: u
468
- } = y, f = u ?? r;
469
- e[a] = {
470
- ...e[a],
471
- nameTransformCasing: f,
472
- type: l,
473
- defaultValue: c,
474
- label: ee(p, a, f)
391
+ } = y, l = u ?? r;
392
+ e[i] = {
393
+ ...e[i],
394
+ nameTransformCasing: l,
395
+ type: d,
396
+ defaultValue: p,
397
+ label: ee(f, i, l)
475
398
  };
476
399
  }
477
400
  }
478
401
  return e;
479
402
  }
480
- function pe(o) {
403
+ function he(o) {
481
404
  const e = {};
482
405
  h(!!o, "The steps config must be defined", TypeError), h(
483
406
  typeof o == "object",
@@ -490,19 +413,19 @@ function pe(o) {
490
413
  `Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
491
414
  TypeError
492
415
  ), h(
493
- fe.test(t),
416
+ de.test(t),
494
417
  `The key "${t}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`
495
418
  );
496
419
  const s = t, {
497
420
  fields: n,
498
- title: a,
499
- nameTransformCasing: c = P,
421
+ title: i,
422
+ nameTransformCasing: p = K,
500
423
  description: y,
501
- validateFields: p
502
- } = r, l = s.toString().replace("step", "");
424
+ validateFields: f
425
+ } = r, d = s.toString().replace("step", "");
503
426
  h(
504
427
  n,
505
- `Missing fields for step ${l} (${String(s)})`,
428
+ `Missing fields for step ${d} (${String(s)})`,
506
429
  TypeError
507
430
  ), h(
508
431
  typeof n == "object",
@@ -510,22 +433,22 @@ function pe(o) {
510
433
  TypeError
511
434
  ), h(
512
435
  Object.keys(n).length > 0,
513
- `The fields config for step ${l} (${String(
436
+ `The fields config for step ${d} (${String(
514
437
  s
515
438
  )}) is empty. Please add a field`
516
439
  ), h(
517
440
  typeof n == "object",
518
441
  `The "fields" property must be an object. Was ${typeof n}`
519
442
  );
520
- const u = Te({
521
- defaultCasing: c,
443
+ const u = Ee({
444
+ defaultCasing: p,
522
445
  fields: n,
523
- validateFields: p
446
+ validateFields: f
524
447
  });
525
448
  e[s] = {
526
449
  ...e[s],
527
- title: a,
528
- nameTransformCasing: c,
450
+ title: i,
451
+ nameTransformCasing: p,
529
452
  // Only add the description if it's defined
530
453
  ...typeof y == "string" ? { description: y } : {},
531
454
  fields: u
@@ -533,7 +456,7 @@ function pe(o) {
533
456
  }
534
457
  return e;
535
458
  }
536
- class B extends le {
459
+ class G extends pe {
537
460
  /**
538
461
  * The original config before any validation or transformations have been applied.
539
462
  */
@@ -552,13 +475,13 @@ class B extends le {
552
475
  constructor(e) {
553
476
  super();
554
477
  const { steps: t, nameTransformCasing: r, storage: s } = e;
555
- this.defaultNameTransformationCasing = ce(
478
+ this.defaultNameTransformationCasing = le(
556
479
  r
557
- ), this.original = t, this.value = this.enrichValues(pe(this.original)), this.stepNumbers = Object.keys(this.value).map(
480
+ ), this.original = t, this.value = this.enrichValues(he(this.original)), this.stepNumbers = Object.keys(this.value).map(
558
481
  (n) => Number.parseInt(n.replace("step", ""))
559
- ), this.storage = new ue({
482
+ ), this.storage = new ce({
560
483
  data: this.value,
561
- key: s?.key ?? K,
484
+ key: s?.key ?? W,
562
485
  store: s?.store
563
486
  }), this.firstStep = this.first(), this.lastStep = this.last(), this.steps = {
564
487
  first: this.firstStep.step,
@@ -569,14 +492,14 @@ class B extends le {
569
492
  typeof n == "string",
570
493
  `The type of the target transformation type must be a string, was ${typeof n}`
571
494
  ), n === "string")
572
- return this.stepNumbers.map((a) => `'${a}'`).join(" | ");
495
+ return this.stepNumbers.map((i) => `'${i}'`).join(" | ");
573
496
  if (n === "number")
574
497
  return this.stepNumbers.join(" | ");
575
498
  if (n.includes("array.string"))
576
- return this.stepNumbers.map((a) => `${a}`);
499
+ return this.stepNumbers.map((i) => `${i}`);
577
500
  throw new Error(
578
- `Transformation type "${n}" is not supported. Available transformations include: ${Ee.map(
579
- (a) => `"${a}"`
501
+ `Transformation type "${n}" is not supported. Available transformations include: ${Te.map(
502
+ (i) => `"${i}"`
580
503
  ).join(", ")}`
581
504
  );
582
505
  },
@@ -617,7 +540,7 @@ class B extends le {
617
540
  * @returns The step data for the target step.
618
541
  */
619
542
  get(e) {
620
- return j(this.value)(e);
543
+ return A(this.value)(e);
621
544
  }
622
545
  /**
623
546
  * Gets the data for the first step.
@@ -664,7 +587,7 @@ class B extends le {
664
587
  ...this.value,
665
588
  [n]: {
666
589
  ...this.value[n],
667
- [t]: Y(
590
+ [t]: Q(
668
591
  r,
669
592
  this.value[n][t]
670
593
  )
@@ -673,18 +596,18 @@ class B extends le {
673
596
  return;
674
597
  }
675
598
  if (typeof t == "object" || typeof t == "function") {
676
- const a = Y(
599
+ const i = Q(
677
600
  t,
678
601
  this.value[n]
679
602
  );
680
603
  h(
681
- typeof a == "object",
682
- `The updated data must be an object, was ${typeof a}`
604
+ typeof i == "object",
605
+ `The updated data must be an object, was ${typeof i}`
683
606
  ), this.value = {
684
607
  ...this.value,
685
608
  [n]: {
686
609
  ...this.value[n],
687
- ...a
610
+ ...i
688
611
  }
689
612
  }, this.handlePostUpdate();
690
613
  return;
@@ -708,7 +631,7 @@ class B extends le {
708
631
  }
709
632
  createStepHelperFnImpl(e) {
710
633
  return (t, r) => {
711
- const s = R(
634
+ const s = N(
712
635
  this.value,
713
636
  e
714
637
  );
@@ -718,7 +641,7 @@ class B extends le {
718
641
  return (n) => "validator" in t ? (h(
719
642
  typeof n == "object",
720
643
  "An input is expected since you provided a validator"
721
- ), G(
644
+ ), fe(
722
645
  t.validator,
723
646
  n.data
724
647
  ), r({ ctx: s, ...n })) : r({ ctx: s });
@@ -750,10 +673,10 @@ class B extends le {
750
673
  return !1;
751
674
  const n = r[s];
752
675
  if (n === null || typeof n != "object" || !X(n, {
753
- defaultValue: (a) => a !== "undefined" && a !== null,
754
- label: (a) => typeof a == "string" || typeof a == "boolean" && !a,
755
- nameTransformCasing: U,
756
- type: _e
676
+ defaultValue: (i) => i !== "undefined" && i !== null,
677
+ label: (i) => typeof i == "string" || typeof i == "boolean" && !i,
678
+ nameTransformCasing: R,
679
+ type: Oe
757
680
  }))
758
681
  return !1;
759
682
  }
@@ -761,13 +684,12 @@ class B extends le {
761
684
  },
762
685
  createHelperFn: (r) => typeof r == "function",
763
686
  update: (r) => typeof r == "function",
764
- nameTransformCasing: U,
687
+ nameTransformCasing: R,
765
688
  ...t?.optionalKeysToCheck
766
689
  });
767
690
  }
768
691
  }
769
- class $e extends le {
770
- stepHelper;
692
+ class $e extends pe {
771
693
  defaultNameTransformationCasing;
772
694
  stepSchema;
773
695
  storage;
@@ -775,16 +697,13 @@ class $e extends le {
775
697
  constructor(e) {
776
698
  super();
777
699
  const { steps: t, nameTransformCasing: r, storage: s } = e;
778
- this.defaultNameTransformationCasing = ce(
700
+ this.defaultNameTransformationCasing = le(
779
701
  r
780
- ), this.stepSchema = new B({
702
+ ), this.stepSchema = new G({
781
703
  steps: t,
782
704
  nameTransformCasing: this.defaultNameTransformationCasing
783
- }), this.stepHelper = new be(
784
- this.stepSchema.value,
785
- this.stepSchema.steps.value
786
- ), this.storage = new ue({
787
- key: s?.key ?? K,
705
+ }), this.storage = new ce({
706
+ key: s?.key ?? W,
788
707
  data: this.stepSchema.value,
789
708
  store: s?.store
790
709
  }), this.stepSchema.subscribe(() => {
@@ -821,14 +740,14 @@ class $e extends le {
821
740
  });
822
741
  }
823
742
  }
824
- function Oe(o) {
743
+ function Ce(o) {
825
744
  function e(t) {
826
745
  const { children: r, name: s } = t;
827
746
  return r(o(s));
828
747
  }
829
748
  return e;
830
749
  }
831
- var O;
750
+ var $;
832
751
  ((o) => {
833
752
  o.DEFAULT_FORM_ALIAS = "Form";
834
753
  function e(r, s) {
@@ -846,14 +765,14 @@ var O;
846
765
  }
847
766
  o.isFormAvailable = e;
848
767
  function t(r) {
849
- return (s) => /* @__PURE__ */ me("form", { id: r, ...s });
768
+ return (s) => /* @__PURE__ */ ge("form", { id: r, ...s });
850
769
  }
851
770
  o.createDefaultForm = t;
852
- })(O || (O = {}));
853
- var H;
771
+ })($ || ($ = {}));
772
+ var U;
854
773
  ((o) => {
855
774
  o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
856
- })(H || (H = {}));
775
+ })(U || (U = {}));
857
776
  function je(o, e) {
858
777
  h(
859
778
  e in o,
@@ -871,19 +790,19 @@ function je(o, e) {
871
790
  };
872
791
  return r;
873
792
  }
874
- class Ce extends B {
793
+ class Ve extends G {
875
794
  // @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
876
795
  value;
877
796
  constructor(e) {
878
797
  const { form: t, ...r } = e;
879
- super(r), this.value = this.enrichValues(pe(this.original)), this.value = this.enrichValues(this.value, (s) => {
880
- const n = `step${s}`, a = t?.id ?? n;
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;
881
800
  return {
882
801
  createComponent: this.createComponentForStep(
883
802
  [`step${s}`],
884
803
  {
885
804
  isStepSpecific: !0,
886
- defaultId: a,
805
+ defaultId: i,
887
806
  form: t
888
807
  }
889
808
  )
@@ -891,164 +810,196 @@ class Ce extends B {
891
810
  });
892
811
  }
893
812
  createFormComponent(e, t) {
894
- const { render: r, enabledForSteps: s = "all", id: n = t } = e, a = {
813
+ const { render: r, enabledForSteps: s = "all", id: n = t } = e, i = {
895
814
  id: n,
896
- steps: R(this.value, s)
815
+ steps: N(this.value, s)
897
816
  };
898
- return (c) => r(a, c);
817
+ return (p) => r(i, p);
899
818
  }
900
819
  createStepSpecificComponentImpl(e, t, r, s = {}) {
901
- return (n) => ((a) => {
902
- const c = {};
903
- for (const [l, u] of Object.entries(s))
904
- if (typeof u == "function")
820
+ return (n) => ((i) => {
821
+ const p = {};
822
+ for (const [u, l] of Object.entries(s))
823
+ if (typeof l == "function")
905
824
  try {
906
- const f = u();
907
- c[l] = f, typeof console < "u" && console.debug && console.debug(
908
- `[multi-step-form] Hook "${l}" called successfully`,
909
- { result: f !== void 0 ? "defined" : "undefined" }
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" }
910
829
  );
911
- } catch (f) {
912
- const i = f instanceof Error ? f.message : String(f);
830
+ } catch (a) {
831
+ const c = a instanceof Error ? a.message : String(a);
913
832
  throw new Error(
914
- `[multi-step-form] Error calling hook "${l}" in useFormInstance.render: ${i}
833
+ `[multi-step-form] Error calling hook "${u}" in useFormInstance.render: ${c}
915
834
 
916
835
  This usually means:
917
836
  1. The hook is being called outside of a React component
918
837
  2. The hook has invalid dependencies or configuration
919
838
  3. There's an error in your hook implementation
920
839
 
921
- Original error: ${i}`,
922
- { cause: f }
840
+ Original error: ${c}`,
841
+ { cause: a }
923
842
  );
924
843
  }
925
844
  else
926
- c[l] = u;
927
- const { defaultId: y, form: p } = t;
928
- if (p) {
845
+ p[u] = l;
846
+ const { defaultId: y, form: f } = t, { ctx: d } = r;
847
+ if (f) {
929
848
  const {
930
- alias: l = O.DEFAULT_FORM_ALIAS,
931
- ...u
932
- } = p, f = u.enabledForSteps ?? "all", [i] = e;
849
+ alias: u = $.DEFAULT_FORM_ALIAS,
850
+ ...l
851
+ } = f, a = l.enabledForSteps ?? "all", [c] = e;
933
852
  h(
934
- this.steps.isValidStepKey(i),
935
- `[createComponent]: the target step ${i} 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.`
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.`
936
855
  );
937
- const m = Number.parseInt(i.replace("step", ""));
856
+ const m = Number.parseInt(c.replace("step", ""));
938
857
  h(
939
858
  !Number.isNaN(m),
940
- `[${i}:"createComponent"]: an error occurred while extracting the number`
859
+ `[${c}:"createComponent"]: an error occurred while extracting the number`
941
860
  );
942
- const d = this.value[i];
861
+ const b = this.value[c];
943
862
  h(
944
- "fields" in d,
945
- `[${i}:createComponent]: unable to find the "fields" for the current step`
863
+ "fields" in b,
864
+ `[${c}:createComponent]: unable to find the "fields" for the current step`
946
865
  ), h(
947
- typeof d.fields == "object",
948
- `[${i}:createComponent]: the "fields" property must be an object, was ${typeof d.fields}`
866
+ typeof b.fields == "object",
867
+ `[${c}:createComponent]: the "fields" property must be an object, was ${typeof b.fields}`
949
868
  );
950
- const b = Oe((g) => {
869
+ const _ = Ce((g) => {
951
870
  h(typeof g == "string", () => {
952
- const L = new Intl.ListFormat("en", {
871
+ const x = new Intl.ListFormat("en", {
953
872
  style: "long",
954
873
  type: "disjunction"
955
874
  });
956
- return `[${i}:Field]: the "name" prop must be a string and a valid field for ${i}. Available fields include ${L.format(
957
- Object.keys(d.fields)
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)
958
877
  )}`;
959
878
  }), h(
960
- g in d.fields,
961
- `[${i}:Field]: the field "${g}" doesn't exist for the current step`
879
+ g in b.fields,
880
+ `[${c}:Field]: the field "${g}" doesn't exist for the current step`
962
881
  );
963
- const { fields: _, update: E } = d, { defaultValue: T, label: S, nameTransformCasing: w, type: $ } = _[g];
882
+ const { fields: O, update: T } = b, { defaultValue: S, label: v, nameTransformCasing: E, type: be } = O[g];
964
883
  return {
965
- defaultValue: T,
966
- label: S,
967
- nameTransformCasing: w,
968
- type: $,
884
+ defaultValue: S,
885
+ label: v,
886
+ nameTransformCasing: E,
887
+ type: be,
969
888
  name: g,
970
- onInputChange: (L) => (
889
+ onInputChange: (x) => (
971
890
  // TODO remove type assertions
972
- E(
891
+ T(
973
892
  "fields",
974
- (z) => ({
975
- ...z,
893
+ (P) => ({
894
+ ...P,
976
895
  [g]: {
977
- ...z[g],
978
- defaultValue: L
896
+ ...P[g],
897
+ defaultValue: x
979
898
  }
980
899
  })
981
900
  )
982
901
  )
983
902
  };
984
903
  });
985
- let v = {
986
- ctx: r,
904
+ let w = {
905
+ ctx: d,
987
906
  onInputChange: this.createStepUpdaterFn(m),
988
- Field: b,
989
- ...c
907
+ Field: _,
908
+ ...p
990
909
  };
991
- return O.isFormAvailable(
910
+ return $.isFormAvailable(
992
911
  e,
993
- f
994
- ) && (v = {
995
- ...v,
996
- [l]: this.createFormComponent(u, y)
997
- }), n(v, a);
912
+ a
913
+ ) && (w = {
914
+ ...w,
915
+ [u]: this.createFormComponent(l, y)
916
+ }), n(w, i);
998
917
  }
999
918
  return n(
1000
919
  {
1001
- ctx: r,
1002
- [O.DEFAULT_FORM_ALIAS]: O.createDefaultForm(y)
920
+ ctx: d,
921
+ [$.DEFAULT_FORM_ALIAS]: $.createDefaultForm(y)
1003
922
  },
1004
- a
923
+ i
1005
924
  );
1006
925
  });
1007
926
  }
1008
927
  createStepSpecificComponentFactory(e, t, r) {
1009
- const s = this.createStepSpecificComponentImpl.bind(this), n = this.createDefaultValues.bind(this);
1010
- function a(c, y) {
1011
- function p() {
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 };
932
+ }
933
+ function u() {
1012
934
  return h(
1013
- typeof c == "function",
935
+ typeof y == "function",
1014
936
  "The first argument must be a function"
1015
937
  ), s(
1016
938
  e,
1017
939
  t,
1018
- r
1019
- )(c);
940
+ d(void 0)
941
+ )(y);
1020
942
  }
1021
- if (typeof c == "object") {
1022
- const { useFormInstance: l } = c;
1023
- if (l) {
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`;
948
+ }
949
+ });
950
+ b.info("First argument is an object");
951
+ const { [m]: _, ...w } = i;
952
+ if (h(
953
+ typeof f == "function",
954
+ "The second argument must be a function"
955
+ ), l) {
1024
956
  const {
1025
- render: u,
1026
- alias: f = H.DEFAULT_FORM_INSTANCE_ALIAS
1027
- } = l;
1028
- h(
1029
- typeof y == "function",
1030
- "The second argument must be a function"
957
+ render: g,
958
+ alias: O = U.DEFAULT_FORM_INSTANCE_ALIAS
959
+ } = l, [T] = e, S = n(T), v = a ? {
960
+ ...r,
961
+ ...a({ ctx: w })
962
+ } : r, E = { ctx: v, defaultValues: S };
963
+ return s(
964
+ e,
965
+ t,
966
+ v,
967
+ {
968
+ [O]: () => g(E)
969
+ }
970
+ )(f);
971
+ }
972
+ if (a) {
973
+ b.info('Option "ctxData" is defined'), h(
974
+ typeof a == "function",
975
+ 'Option "ctxData" must be a function'
976
+ );
977
+ const g = a({ ctx: w });
978
+ b.info(
979
+ `Addition context is: ${JSON.stringify(g, null, 2)}`
1031
980
  );
1032
- const [i] = e, m = n(i), d = { ctx: r, defaultValues: m };
1033
- return s(e, t, r, {
1034
- [f]: () => u(d)
1035
- })(y);
981
+ const O = {
982
+ ...r,
983
+ ...g
984
+ };
985
+ return b.info(
986
+ `Resolved context is: ${JSON.stringify(O, null, 2)}`
987
+ ), s(e, t, {
988
+ ctx: O
989
+ })(f);
1036
990
  }
1037
- return p();
991
+ return u();
1038
992
  }
1039
- return p();
993
+ return u();
1040
994
  }
1041
- return a;
995
+ return p;
1042
996
  }
1043
997
  createComponentImpl(e, t) {
1044
- const r = R(
998
+ const r = N(
1045
999
  this.value,
1046
1000
  e
1047
1001
  );
1048
- return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (s) => ((n) => s(
1049
- { ctx: r },
1050
- n
1051
- ));
1002
+ return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (s) => ((n) => s(r, n));
1052
1003
  }
1053
1004
  createComponentForStep(e, t) {
1054
1005
  return this.createComponentImpl(e, t);
@@ -1072,27 +1023,28 @@ Original error: ${i}`,
1072
1023
  class Ae extends $e {
1073
1024
  stepSchema;
1074
1025
  constructor(e) {
1075
- const { nameTransformCasing: t = P, storage: r, ...s } = e;
1026
+ const { nameTransformCasing: t = K, storage: r, ...s } = e;
1076
1027
  super({
1077
1028
  nameTransformCasing: t,
1078
1029
  storage: r,
1079
1030
  ...s
1080
- }), this.stepSchema = new Ce({
1031
+ }), this.stepSchema = new Ve({
1081
1032
  nameTransformCasing: t,
1082
1033
  ...s
1083
1034
  });
1084
1035
  }
1085
1036
  createComponent(e, t) {
1086
- const { stepData: r } = e, s = this.stepHelper.createCtx(
1037
+ const { stepData: r } = e, s = N(
1038
+ this.stepSchema.value,
1087
1039
  r
1088
1040
  );
1089
1041
  return ((n) => t({ ctx: s }, n));
1090
1042
  }
1091
1043
  }
1092
- function Me(o) {
1044
+ function Re(o) {
1093
1045
  return new Ae(o);
1094
1046
  }
1095
- var A = { exports: {} }, x = {}, N = { exports: {} }, D = {};
1047
+ var C = { exports: {} }, L = {}, j = { exports: {} }, D = {};
1096
1048
  /**
1097
1049
  * @license React
1098
1050
  * use-sync-external-store-shim.production.js
@@ -1106,42 +1058,42 @@ var te;
1106
1058
  function Ne() {
1107
1059
  if (te) return D;
1108
1060
  te = 1;
1109
- var o = I;
1110
- function e(u, f) {
1111
- return u === f && (u !== 0 || 1 / u === 1 / f) || u !== u && f !== f;
1061
+ var o = F;
1062
+ function e(u, l) {
1063
+ return u === l && (u !== 0 || 1 / u === 1 / l) || u !== u && l !== l;
1112
1064
  }
1113
- var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, s = o.useEffect, n = o.useLayoutEffect, a = o.useDebugValue;
1114
- function c(u, f) {
1115
- var i = f(), m = r({ inst: { value: i, getSnapshot: f } }), d = m[0].inst, b = m[1];
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];
1116
1068
  return n(
1117
1069
  function() {
1118
- d.value = i, d.getSnapshot = f, y(d) && b({ inst: d });
1070
+ m.value = a, m.getSnapshot = l, y(m) && b({ inst: m });
1119
1071
  },
1120
- [u, i, f]
1072
+ [u, a, l]
1121
1073
  ), s(
1122
1074
  function() {
1123
- return y(d) && b({ inst: d }), u(function() {
1124
- y(d) && b({ inst: d });
1075
+ return y(m) && b({ inst: m }), u(function() {
1076
+ y(m) && b({ inst: m });
1125
1077
  });
1126
1078
  },
1127
1079
  [u]
1128
- ), a(i), i;
1080
+ ), i(a), a;
1129
1081
  }
1130
1082
  function y(u) {
1131
- var f = u.getSnapshot;
1083
+ var l = u.getSnapshot;
1132
1084
  u = u.value;
1133
1085
  try {
1134
- var i = f();
1135
- return !t(u, i);
1086
+ var a = l();
1087
+ return !t(u, a);
1136
1088
  } catch {
1137
1089
  return !0;
1138
1090
  }
1139
1091
  }
1140
- function p(u, f) {
1141
- return f();
1092
+ function f(u, l) {
1093
+ return l();
1142
1094
  }
1143
- var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? p : c;
1144
- return D.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : l, D;
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;
1145
1097
  }
1146
1098
  var k = {};
1147
1099
  /**
@@ -1154,61 +1106,61 @@ var k = {};
1154
1106
  * LICENSE file in the root directory of this source tree.
1155
1107
  */
1156
1108
  var re;
1157
- function Ve() {
1109
+ function Fe() {
1158
1110
  return re || (re = 1, process.env.NODE_ENV !== "production" && (function() {
1159
- function o(i, m) {
1160
- return i === m && (i !== 0 || 1 / i === 1 / m) || i !== i && m !== m;
1111
+ function o(a, c) {
1112
+ return a === c && (a !== 0 || 1 / a === 1 / c) || a !== a && c !== c;
1161
1113
  }
1162
- function e(i, m) {
1163
- l || s.startTransition === void 0 || (l = !0, console.error(
1114
+ function e(a, c) {
1115
+ d || s.startTransition === void 0 || (d = !0, console.error(
1164
1116
  "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."
1165
1117
  ));
1166
- var d = m();
1118
+ var m = c();
1167
1119
  if (!u) {
1168
- var b = m();
1169
- n(d, b) || (console.error(
1120
+ var b = c();
1121
+ n(m, b) || (console.error(
1170
1122
  "The result of getSnapshot should be cached to avoid an infinite loop"
1171
1123
  ), u = !0);
1172
1124
  }
1173
- b = a({
1174
- inst: { value: d, getSnapshot: m }
1125
+ b = i({
1126
+ inst: { value: m, getSnapshot: c }
1175
1127
  });
1176
- var v = b[0].inst, g = b[1];
1128
+ var _ = b[0].inst, w = b[1];
1177
1129
  return y(
1178
1130
  function() {
1179
- v.value = d, v.getSnapshot = m, t(v) && g({ inst: v });
1131
+ _.value = m, _.getSnapshot = c, t(_) && w({ inst: _ });
1180
1132
  },
1181
- [i, d, m]
1182
- ), c(
1133
+ [a, m, c]
1134
+ ), p(
1183
1135
  function() {
1184
- return t(v) && g({ inst: v }), i(function() {
1185
- t(v) && g({ inst: v });
1136
+ return t(_) && w({ inst: _ }), a(function() {
1137
+ t(_) && w({ inst: _ });
1186
1138
  });
1187
1139
  },
1188
- [i]
1189
- ), p(d), d;
1140
+ [a]
1141
+ ), f(m), m;
1190
1142
  }
1191
- function t(i) {
1192
- var m = i.getSnapshot;
1193
- i = i.value;
1143
+ function t(a) {
1144
+ var c = a.getSnapshot;
1145
+ a = a.value;
1194
1146
  try {
1195
- var d = m();
1196
- return !n(i, d);
1147
+ var m = c();
1148
+ return !n(a, m);
1197
1149
  } catch {
1198
1150
  return !0;
1199
1151
  }
1200
1152
  }
1201
- function r(i, m) {
1202
- return m();
1153
+ function r(a, c) {
1154
+ return c();
1203
1155
  }
1204
1156
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1205
- var s = I, n = typeof Object.is == "function" ? Object.is : o, a = s.useState, c = s.useEffect, y = s.useLayoutEffect, p = s.useDebugValue, l = !1, u = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
1206
- k.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(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());
1207
1159
  })()), k;
1208
1160
  }
1209
1161
  var ne;
1210
- function de() {
1211
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? N.exports = Ne() : N.exports = Ve()), N.exports;
1162
+ function me() {
1163
+ return ne || (ne = 1, process.env.NODE_ENV === "production" ? j.exports = Ne() : j.exports = Fe()), j.exports;
1212
1164
  }
1213
1165
  /**
1214
1166
  * @license React
@@ -1220,55 +1172,55 @@ function de() {
1220
1172
  * LICENSE file in the root directory of this source tree.
1221
1173
  */
1222
1174
  var se;
1223
- function Fe() {
1224
- if (se) return x;
1175
+ function xe() {
1176
+ if (se) return L;
1225
1177
  se = 1;
1226
- var o = I, e = de();
1227
- function t(p, l) {
1228
- return p === l && (p !== 0 || 1 / p === 1 / l) || p !== p && l !== l;
1229
- }
1230
- var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect, c = o.useMemo, y = o.useDebugValue;
1231
- return x.useSyncExternalStoreWithSelector = function(p, l, u, f, i) {
1232
- var m = n(null);
1233
- if (m.current === null) {
1234
- var d = { hasValue: !1, value: null };
1235
- m.current = d;
1236
- } else d = m.current;
1237
- m = c(
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(
1238
1190
  function() {
1239
- function v(S) {
1240
- if (!g) {
1241
- if (g = !0, _ = S, S = f(S), i !== void 0 && d.hasValue) {
1242
- var w = d.value;
1243
- if (i(w, S))
1244
- return E = w;
1191
+ function _(S) {
1192
+ 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;
1245
1197
  }
1246
- return E = S;
1198
+ return O = S;
1247
1199
  }
1248
- if (w = E, r(_, S)) return w;
1249
- var $ = f(S);
1250
- return i !== void 0 && i(w, $) ? (_ = S, w) : (_ = S, E = $);
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);
1251
1203
  }
1252
- var g = !1, _, E, T = u === void 0 ? null : u;
1204
+ var w = !1, g, O, T = u === void 0 ? null : u;
1253
1205
  return [
1254
1206
  function() {
1255
- return v(l());
1207
+ return _(d());
1256
1208
  },
1257
1209
  T === null ? void 0 : function() {
1258
- return v(T());
1210
+ return _(T());
1259
1211
  }
1260
1212
  ];
1261
1213
  },
1262
- [l, u, f, i]
1214
+ [d, u, l, a]
1263
1215
  );
1264
- var b = s(p, m[0], m[1]);
1265
- return a(
1216
+ var b = s(f, c[0], c[1]);
1217
+ return i(
1266
1218
  function() {
1267
- d.hasValue = !0, d.value = b;
1219
+ m.hasValue = !0, m.value = b;
1268
1220
  },
1269
1221
  [b]
1270
1222
  ), y(b), b;
1271
- }, x;
1223
+ }, L;
1272
1224
  }
1273
1225
  var M = {};
1274
1226
  /**
@@ -1283,61 +1235,61 @@ var M = {};
1283
1235
  var oe;
1284
1236
  function Ie() {
1285
1237
  return oe || (oe = 1, process.env.NODE_ENV !== "production" && (function() {
1286
- function o(p, l) {
1287
- return p === l && (p !== 0 || 1 / p === 1 / l) || p !== p && l !== l;
1238
+ function o(f, d) {
1239
+ return f === d && (f !== 0 || 1 / f === 1 / d) || f !== f && d !== d;
1288
1240
  }
1289
1241
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1290
- var e = I, t = de(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, a = e.useEffect, c = e.useMemo, y = e.useDebugValue;
1291
- M.useSyncExternalStoreWithSelector = function(p, l, u, f, i) {
1292
- var m = n(null);
1293
- if (m.current === null) {
1294
- var d = { hasValue: !1, value: null };
1295
- m.current = d;
1296
- } else d = m.current;
1297
- m = c(
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(
1298
1250
  function() {
1299
- function v(S) {
1300
- if (!g) {
1301
- if (g = !0, _ = S, S = f(S), i !== void 0 && d.hasValue) {
1302
- var w = d.value;
1303
- if (i(w, S))
1304
- return E = w;
1251
+ function _(S) {
1252
+ 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;
1305
1257
  }
1306
- return E = S;
1258
+ return O = S;
1307
1259
  }
1308
- if (w = E, r(_, S))
1309
- return w;
1310
- var $ = f(S);
1311
- return i !== void 0 && i(w, $) ? (_ = S, w) : (_ = S, E = $);
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);
1312
1264
  }
1313
- var g = !1, _, E, T = u === void 0 ? null : u;
1265
+ var w = !1, g, O, T = u === void 0 ? null : u;
1314
1266
  return [
1315
1267
  function() {
1316
- return v(l());
1268
+ return _(d());
1317
1269
  },
1318
1270
  T === null ? void 0 : function() {
1319
- return v(T());
1271
+ return _(T());
1320
1272
  }
1321
1273
  ];
1322
1274
  },
1323
- [l, u, f, i]
1275
+ [d, u, l, a]
1324
1276
  );
1325
- var b = s(p, m[0], m[1]);
1326
- return a(
1277
+ var b = s(f, c[0], c[1]);
1278
+ return i(
1327
1279
  function() {
1328
- d.hasValue = !0, d.value = b;
1280
+ m.hasValue = !0, m.value = b;
1329
1281
  },
1330
1282
  [b]
1331
1283
  ), y(b), b;
1332
1284
  }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1333
1285
  })()), M;
1334
1286
  }
1335
- var ae;
1287
+ var ie;
1336
1288
  function Le() {
1337
- return ae || (ae = 1, process.env.NODE_ENV === "production" ? A.exports = Fe() : A.exports = Ie()), A.exports;
1289
+ return ie || (ie = 1, process.env.NODE_ENV === "production" ? C.exports = xe() : C.exports = Ie()), C.exports;
1338
1290
  }
1339
- var xe = Le();
1340
- function W(o, e) {
1291
+ var De = Le();
1292
+ function H(o, e) {
1341
1293
  h(
1342
1294
  typeof e == "string",
1343
1295
  `The target step must be a string, was ${typeof e}`
@@ -1347,25 +1299,25 @@ function W(o, e) {
1347
1299
  style: "long"
1348
1300
  }).format(t("array.string.untyped"));
1349
1301
  h(
1350
- fe.test(e),
1302
+ de.test(e),
1351
1303
  `The target step must match the following format: "step{number}". Available steps are ${n}`
1352
1304
  );
1353
- const a = Number.parseInt(e.replace("step", ""));
1305
+ const i = Number.parseInt(e.replace("step", ""));
1354
1306
  return h(
1355
- r(a),
1356
- `The step number "${a}" is not a valid step number. Valid step numbers include ${n}`,
1307
+ r(i),
1308
+ `The step number "${i}" is not a valid step number. Valid step numbers include ${n}`,
1357
1309
  TypeError
1358
- ), a;
1310
+ ), i;
1359
1311
  }
1360
- function he(o) {
1312
+ function ye(o) {
1361
1313
  function e(t) {
1362
- return xe.useSyncExternalStoreWithSelector(
1314
+ return De.useSyncExternalStoreWithSelector(
1363
1315
  o.subscribe,
1364
1316
  () => o.getSnapshot(),
1365
1317
  () => o.getSnapshot(),
1366
1318
  (r) => {
1367
1319
  if (typeof t == "object") {
1368
- const s = W(
1320
+ const s = H(
1369
1321
  r,
1370
1322
  t.targetStep
1371
1323
  );
@@ -1377,70 +1329,70 @@ function he(o) {
1377
1329
  }
1378
1330
  return e;
1379
1331
  }
1380
- function Re(o, e) {
1381
- const t = he(o);
1332
+ function Ue(o, e) {
1333
+ const t = ye(o);
1382
1334
  return typeof e == "object" || typeof e == "function" ? t(e) : t();
1383
1335
  }
1384
- function ie(o) {
1336
+ function ae(o) {
1385
1337
  return function(e) {
1386
1338
  return ((t) => e(o, t));
1387
1339
  };
1388
1340
  }
1389
- function Ue(o) {
1390
- const e = he(o);
1391
- function t(c) {
1392
- const { targetStep: y, notFoundMessage: p, isDataGuaranteed: l } = c, u = e({
1341
+ function He(o) {
1342
+ const e = ye(o);
1343
+ function t(p) {
1344
+ const { targetStep: y, notFoundMessage: f, isDataGuaranteed: d } = p, u = e({
1393
1345
  targetStep: y
1394
- }), f = p ? a({ targetStep: y }, p) : (i) => /* @__PURE__ */ q("div", { ...i, children: [
1346
+ }), l = f ? i({ targetStep: y }, f) : (a) => /* @__PURE__ */ B("div", { ...a, children: [
1395
1347
  "No data found for step ",
1396
1348
  String(y)
1397
1349
  ] });
1398
- return l ? {
1350
+ return d ? {
1399
1351
  data: u,
1400
- NoCurrentData: f
1401
- } : B.hasData(u) ? {
1352
+ NoCurrentData: l
1353
+ } : G.hasData(u) ? {
1402
1354
  data: u,
1403
1355
  hasData: !0,
1404
- NoCurrentData: f
1356
+ NoCurrentData: l
1405
1357
  } : {
1406
1358
  data: void 0,
1407
1359
  hasData: !1,
1408
- NoCurrentData: f
1360
+ NoCurrentData: l
1409
1361
  };
1410
1362
  }
1411
- function r(c) {
1363
+ function r(p) {
1412
1364
  const y = e(
1413
1365
  (b) => b.stepSchema.steps.value.length
1414
1366
  ), {
1415
- targetStep: p,
1416
- maxProgressValue: l = 100,
1367
+ targetStep: f,
1368
+ maxProgressValue: d = 100,
1417
1369
  totalSteps: u = y,
1418
- progressTextTransformer: f
1419
- } = c, i = W(o, p), m = i / u * l, d = f ? n(
1420
- { targetStep: p, maxProgressValue: l, totalSteps: u },
1421
- f
1422
- ) : (b) => /* @__PURE__ */ q("div", { ...b, children: [
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: [
1423
1375
  "Step ",
1424
- i,
1376
+ a,
1425
1377
  "/",
1426
1378
  u
1427
1379
  ] });
1428
1380
  return {
1429
- value: m,
1430
- maxProgressValue: l,
1431
- ProgressText: d
1381
+ value: c,
1382
+ maxProgressValue: d,
1383
+ ProgressText: m
1432
1384
  };
1433
1385
  }
1434
- function s(c) {
1435
- const p = e((u) => u.storage).get(), l = !!(p && typeof p == "object" && Object.keys(p).length > 0);
1436
- return c ? c(l) : l;
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;
1437
1389
  }
1438
- function n(c, y) {
1439
- const p = o.getSnapshot().stepSchema.steps.value.length, { targetStep: l, maxProgressValue: u = 100, totalSteps: f = p } = c;
1440
- return ie({ targetStep: l, maxProgressValue: u, totalSteps: f })(y);
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);
1441
1393
  }
1442
- function a(c, y) {
1443
- return W(o, c.targetStep), ie(c)(y);
1394
+ function i(p, y) {
1395
+ return H(o, p.targetStep), ae(p)(y);
1444
1396
  }
1445
1397
  return {
1446
1398
  // MultiStepFormContext: Context,
@@ -1449,16 +1401,16 @@ function Ue(o) {
1449
1401
  useProgress: r,
1450
1402
  useCanRestartForm: s,
1451
1403
  withProgressText: n,
1452
- withNoStepDataFound: a
1404
+ withNoStepDataFound: i
1453
1405
  };
1454
1406
  }
1455
1407
  export {
1456
1408
  Ae as MultiStepFormSchema,
1457
- Ce as MultiStepFormStepSchema,
1458
- H as StepSpecificComponent,
1409
+ Ve as MultiStepFormStepSchema,
1410
+ U as StepSpecificComponent,
1459
1411
  je as createDefaultValues,
1460
- Ue as createMultiStepFormContext,
1461
- Me as createMultiStepFormSchema,
1462
- Re as useMultiStepFormData
1412
+ He as createMultiStepFormContext,
1413
+ Re as createMultiStepFormSchema,
1414
+ Ue as useMultiStepFormData
1463
1415
  };
1464
1416
  //# sourceMappingURL=index.mjs.map