@jfdevelops/react-multi-step-form 1.0.0-alpha.1 → 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
- function d(o, e, t = Error) {
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
- d(o.includes("step"), "Can't extract a valid step number since");
40
- const e = o.replace("step", "");
41
- return d(/^\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 d(
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 d(
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 d(
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 d(
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 ? (d(
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
- d(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 $e = [
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,121 +334,121 @@ 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)) {
419
- d(
341
+ for (const [n, i] of Object.entries(t)) {
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
- ), d(
423
- typeof a == "object",
424
- `The value for key ${n} must be an object. Was ${typeof a}`
345
+ ), h(
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
  );
451
- d(
374
+ h(
452
375
  typeof n == "object",
453
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`
454
- ), d(
377
+ ), h(
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];
460
- d(
381
+ for (const [i, p] of Object.entries(n)) {
382
+ const y = t[i];
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
- d(!!o, "The steps config must be defined", TypeError), d(
405
+ h(!!o, "The steps config must be defined", TypeError), h(
483
406
  typeof o == "object",
484
407
  `The steps config must be an object, was (${typeof o})`,
485
408
  TypeError
486
409
  );
487
410
  for (const [t, r] of Object.entries(o)) {
488
- d(
411
+ h(
489
412
  typeof t == "string",
490
413
  `Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
491
414
  TypeError
492
- ), d(
493
- fe.test(t),
415
+ ), h(
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", "");
503
- d(
424
+ validateFields: f
425
+ } = r, d = s.toString().replace("step", "");
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
- ), d(
430
+ ), h(
508
431
  typeof n == "object",
509
432
  "Fields must be an object",
510
433
  TypeError
511
- ), d(
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
- ), d(
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,31 +475,31 @@ 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,
565
488
  last: this.lastStep.step,
566
489
  value: this.stepNumbers,
567
490
  as: (n) => {
568
- if (d(
491
+ if (h(
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: ${$e.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.
@@ -640,11 +563,11 @@ class B extends le {
640
563
  }
641
564
  createStepUpdaterFnImpl(e, t, r) {
642
565
  const s = this.stepNumbers;
643
- d(
566
+ h(
644
567
  typeof e == "number",
645
568
  `Type of step must be a number, was ${typeof e}`,
646
569
  TypeError
647
- ), d(
570
+ ), h(
648
571
  s.includes(e),
649
572
  `The target step ${e} is not valid. Valid steps include "${s.join(
650
573
  ", "
@@ -652,28 +575,19 @@ class B extends le {
652
575
  );
653
576
  const n = `step${e}`;
654
577
  if (typeof t == "string") {
655
- d(this.value[n], `No data found for step ${e}`), d(
578
+ h(this.value[n], `No data found for step ${e}`), h(
656
579
  typeof this.value[n] == "object",
657
580
  `The values for step ${e} is not an object, was ${typeof this.value[n]}`
658
- ), d(
581
+ ), h(
659
582
  t in this.value[n],
660
583
  `The field ${t} is not a valid field. Valid fields include ${Object.keys(
661
584
  this.value[n]
662
585
  ).join(", ")}`
663
- ), d(
664
- typeof r == "object" || typeof r == "function",
665
- () => {
666
- let a = "";
667
- return typeof r != "object" && (a = "an object"), typeof r != "function" && (a = "a function"), `[${String(
668
- n
669
- )}-${t}]: The updater must be ${a}, was "${typeof r}"`;
670
- },
671
- TypeError
672
586
  ), this.value = {
673
587
  ...this.value,
674
588
  [n]: {
675
589
  ...this.value[n],
676
- [t]: Y(
590
+ [t]: Q(
677
591
  r,
678
592
  this.value[n][t]
679
593
  )
@@ -682,18 +596,18 @@ class B extends le {
682
596
  return;
683
597
  }
684
598
  if (typeof t == "object" || typeof t == "function") {
685
- const a = Y(
599
+ const i = Q(
686
600
  t,
687
601
  this.value[n]
688
602
  );
689
- d(
690
- typeof a == "object",
691
- `The updated data must be an object, was ${typeof a}`
603
+ h(
604
+ typeof i == "object",
605
+ `The updated data must be an object, was ${typeof i}`
692
606
  ), this.value = {
693
607
  ...this.value,
694
608
  [n]: {
695
609
  ...this.value[n],
696
- ...a
610
+ ...i
697
611
  }
698
612
  }, this.handlePostUpdate();
699
613
  return;
@@ -717,17 +631,17 @@ class B extends le {
717
631
  }
718
632
  createStepHelperFnImpl(e) {
719
633
  return (t, r) => {
720
- const s = R(
634
+ const s = N(
721
635
  this.value,
722
636
  e
723
637
  );
724
638
  if (typeof t == "function")
725
639
  return () => t({ ctx: s });
726
640
  if (typeof t == "object")
727
- return (n) => "validator" in t ? (d(
641
+ return (n) => "validator" in t ? (h(
728
642
  typeof n == "object",
729
643
  "An input is expected since you provided a validator"
730
- ), G(
644
+ ), fe(
731
645
  t.validator,
732
646
  n.data
733
647
  ), r({ ctx: s, ...n })) : r({ ctx: s });
@@ -759,10 +673,10 @@ class B extends le {
759
673
  return !1;
760
674
  const n = r[s];
761
675
  if (n === null || typeof n != "object" || !X(n, {
762
- defaultValue: (a) => a !== "undefined" && a !== null,
763
- label: (a) => typeof a == "string" || typeof a == "boolean" && !a,
764
- nameTransformCasing: U,
765
- 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
766
680
  }))
767
681
  return !1;
768
682
  }
@@ -770,13 +684,12 @@ class B extends le {
770
684
  },
771
685
  createHelperFn: (r) => typeof r == "function",
772
686
  update: (r) => typeof r == "function",
773
- nameTransformCasing: U,
687
+ nameTransformCasing: R,
774
688
  ...t?.optionalKeysToCheck
775
689
  });
776
690
  }
777
691
  }
778
- class Ee extends le {
779
- stepHelper;
692
+ class $e extends pe {
780
693
  defaultNameTransformationCasing;
781
694
  stepSchema;
782
695
  storage;
@@ -784,16 +697,13 @@ class Ee extends le {
784
697
  constructor(e) {
785
698
  super();
786
699
  const { steps: t, nameTransformCasing: r, storage: s } = e;
787
- this.defaultNameTransformationCasing = ce(
700
+ this.defaultNameTransformationCasing = le(
788
701
  r
789
- ), this.stepSchema = new B({
702
+ ), this.stepSchema = new G({
790
703
  steps: t,
791
704
  nameTransformCasing: this.defaultNameTransformationCasing
792
- }), this.stepHelper = new be(
793
- this.stepSchema.value,
794
- this.stepSchema.steps.value
795
- ), this.storage = new ue({
796
- key: s?.key ?? K,
705
+ }), this.storage = new ce({
706
+ key: s?.key ?? W,
797
707
  data: this.stepSchema.value,
798
708
  store: s?.store
799
709
  }), this.stepSchema.subscribe(() => {
@@ -830,14 +740,14 @@ class Ee extends le {
830
740
  });
831
741
  }
832
742
  }
833
- function Oe(o) {
743
+ function Ce(o) {
834
744
  function e(t) {
835
745
  const { children: r, name: s } = t;
836
746
  return r(o(s));
837
747
  }
838
748
  return e;
839
749
  }
840
- var O;
750
+ var $;
841
751
  ((o) => {
842
752
  o.DEFAULT_FORM_ALIAS = "Form";
843
753
  function e(r, s) {
@@ -855,21 +765,21 @@ var O;
855
765
  }
856
766
  o.isFormAvailable = e;
857
767
  function t(r) {
858
- return (s) => /* @__PURE__ */ me("form", { id: r, ...s });
768
+ return (s) => /* @__PURE__ */ ge("form", { id: r, ...s });
859
769
  }
860
770
  o.createDefaultForm = t;
861
- })(O || (O = {}));
862
- var H;
771
+ })($ || ($ = {}));
772
+ var U;
863
773
  ((o) => {
864
774
  o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
865
- })(H || (H = {}));
775
+ })(U || (U = {}));
866
776
  function je(o, e) {
867
- d(
777
+ h(
868
778
  e in o,
869
779
  `The target step ${e} is not a valid step key`
870
780
  );
871
781
  const t = o[e];
872
- d("fields" in t, `No "fields" were found for ${e}`);
782
+ h("fields" in t, `No "fields" were found for ${e}`);
873
783
  let r = {};
874
784
  for (const [s, n] of Object.entries(
875
785
  t.fields
@@ -880,19 +790,19 @@ function je(o, e) {
880
790
  };
881
791
  return r;
882
792
  }
883
- class Ce extends B {
793
+ class Ve extends G {
884
794
  // @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
885
795
  value;
886
796
  constructor(e) {
887
797
  const { form: t, ...r } = e;
888
- super(r), this.value = this.enrichValues(pe(this.original)), this.value = this.enrichValues(this.value, (s) => {
889
- 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;
890
800
  return {
891
801
  createComponent: this.createComponentForStep(
892
802
  [`step${s}`],
893
803
  {
894
804
  isStepSpecific: !0,
895
- defaultId: a,
805
+ defaultId: i,
896
806
  form: t
897
807
  }
898
808
  )
@@ -900,164 +810,196 @@ class Ce extends B {
900
810
  });
901
811
  }
902
812
  createFormComponent(e, t) {
903
- const { render: r, enabledForSteps: s = "all", id: n = t } = e, a = {
813
+ const { render: r, enabledForSteps: s = "all", id: n = t } = e, i = {
904
814
  id: n,
905
- steps: R(this.value, s)
815
+ steps: N(this.value, s)
906
816
  };
907
- return (c) => r(a, c);
817
+ return (p) => r(i, p);
908
818
  }
909
819
  createStepSpecificComponentImpl(e, t, r, s = {}) {
910
- return (n) => ((a) => {
911
- const c = {};
912
- for (const [l, u] of Object.entries(s))
913
- 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")
914
824
  try {
915
- const f = u();
916
- c[l] = f, typeof console < "u" && console.debug && console.debug(
917
- `[multi-step-form] Hook "${l}" called successfully`,
918
- { 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" }
919
829
  );
920
- } catch (f) {
921
- const i = f instanceof Error ? f.message : String(f);
830
+ } catch (a) {
831
+ const c = a instanceof Error ? a.message : String(a);
922
832
  throw new Error(
923
- `[multi-step-form] Error calling hook "${l}" in useFormInstance.render: ${i}
833
+ `[multi-step-form] Error calling hook "${u}" in useFormInstance.render: ${c}
924
834
 
925
835
  This usually means:
926
836
  1. The hook is being called outside of a React component
927
837
  2. The hook has invalid dependencies or configuration
928
838
  3. There's an error in your hook implementation
929
839
 
930
- Original error: ${i}`,
931
- { cause: f }
840
+ Original error: ${c}`,
841
+ { cause: a }
932
842
  );
933
843
  }
934
844
  else
935
- c[l] = u;
936
- const { defaultId: y, form: p } = t;
937
- if (p) {
845
+ p[u] = l;
846
+ const { defaultId: y, form: f } = t, { ctx: d } = r;
847
+ if (f) {
938
848
  const {
939
- alias: l = O.DEFAULT_FORM_ALIAS,
940
- ...u
941
- } = p, f = u.enabledForSteps ?? "all", [i] = e;
942
- d(
943
- this.steps.isValidStepKey(i),
944
- `[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.`
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.`
945
855
  );
946
- const m = Number.parseInt(i.replace("step", ""));
947
- d(
856
+ const m = Number.parseInt(c.replace("step", ""));
857
+ h(
948
858
  !Number.isNaN(m),
949
- `[${i}:"createComponent"]: an error occurred while extracting the number`
859
+ `[${c}:"createComponent"]: an error occurred while extracting the number`
950
860
  );
951
- const h = this.value[i];
952
- d(
953
- "fields" in h,
954
- `[${i}:createComponent]: unable to find the "fields" for the current step`
955
- ), d(
956
- typeof h.fields == "object",
957
- `[${i}:createComponent]: the "fields" property must be an object, was ${typeof h.fields}`
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}`
958
868
  );
959
- const b = Oe((g) => {
960
- d(typeof g == "string", () => {
961
- const L = new Intl.ListFormat("en", {
869
+ const _ = Ce((g) => {
870
+ h(typeof g == "string", () => {
871
+ const x = new Intl.ListFormat("en", {
962
872
  style: "long",
963
873
  type: "disjunction"
964
874
  });
965
- return `[${i}:Field]: the "name" prop must be a string and a valid field for ${i}. Available fields include ${L.format(
966
- Object.keys(h.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)
967
877
  )}`;
968
- }), d(
969
- g in h.fields,
970
- `[${i}:Field]: the field "${g}" doesn't exist for the current step`
878
+ }), h(
879
+ g in b.fields,
880
+ `[${c}:Field]: the field "${g}" doesn't exist for the current step`
971
881
  );
972
- const { fields: _, update: $ } = h, { defaultValue: T, label: S, nameTransformCasing: w, type: E } = _[g];
882
+ const { fields: O, update: T } = b, { defaultValue: S, label: v, nameTransformCasing: E, type: be } = O[g];
973
883
  return {
974
- defaultValue: T,
975
- label: S,
976
- nameTransformCasing: w,
977
- type: E,
884
+ defaultValue: S,
885
+ label: v,
886
+ nameTransformCasing: E,
887
+ type: be,
978
888
  name: g,
979
- onInputChange: (L) => (
889
+ onInputChange: (x) => (
980
890
  // TODO remove type assertions
981
- $(
891
+ T(
982
892
  "fields",
983
- (z) => ({
984
- ...z,
893
+ (P) => ({
894
+ ...P,
985
895
  [g]: {
986
- ...z[g],
987
- defaultValue: L
896
+ ...P[g],
897
+ defaultValue: x
988
898
  }
989
899
  })
990
900
  )
991
901
  )
992
902
  };
993
903
  });
994
- let v = {
995
- ctx: r,
904
+ let w = {
905
+ ctx: d,
996
906
  onInputChange: this.createStepUpdaterFn(m),
997
- Field: b,
998
- ...c
907
+ Field: _,
908
+ ...p
999
909
  };
1000
- return O.isFormAvailable(
910
+ return $.isFormAvailable(
1001
911
  e,
1002
- f
1003
- ) && (v = {
1004
- ...v,
1005
- [l]: this.createFormComponent(u, y)
1006
- }), n(v, a);
912
+ a
913
+ ) && (w = {
914
+ ...w,
915
+ [u]: this.createFormComponent(l, y)
916
+ }), n(w, i);
1007
917
  }
1008
918
  return n(
1009
919
  {
1010
- ctx: r,
1011
- [O.DEFAULT_FORM_ALIAS]: O.createDefaultForm(y)
920
+ ctx: d,
921
+ [$.DEFAULT_FORM_ALIAS]: $.createDefaultForm(y)
1012
922
  },
1013
- a
923
+ i
1014
924
  );
1015
925
  });
1016
926
  }
1017
927
  createStepSpecificComponentFactory(e, t, r) {
1018
- const s = this.createStepSpecificComponentImpl.bind(this), n = this.createDefaultValues.bind(this);
1019
- function a(c, y) {
1020
- function p() {
1021
- return d(
1022
- typeof c == "function",
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() {
934
+ return h(
935
+ typeof y == "function",
1023
936
  "The first argument must be a function"
1024
937
  ), s(
1025
938
  e,
1026
939
  t,
1027
- r
1028
- )(c);
940
+ d(void 0)
941
+ )(y);
1029
942
  }
1030
- if (typeof c == "object") {
1031
- const { useFormInstance: l } = c;
1032
- 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) {
1033
956
  const {
1034
- render: u,
1035
- alias: f = H.DEFAULT_FORM_INSTANCE_ALIAS
1036
- } = l;
1037
- d(
1038
- typeof y == "function",
1039
- "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)}`
1040
980
  );
1041
- const [i] = e, m = n(i), h = { ctx: r, defaultValues: m };
1042
- return s(e, t, r, {
1043
- [f]: () => u(h)
1044
- })(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);
1045
990
  }
1046
- return p();
991
+ return u();
1047
992
  }
1048
- return p();
993
+ return u();
1049
994
  }
1050
- return a;
995
+ return p;
1051
996
  }
1052
997
  createComponentImpl(e, t) {
1053
- const r = R(
998
+ const r = N(
1054
999
  this.value,
1055
1000
  e
1056
1001
  );
1057
- return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (s) => ((n) => s(
1058
- { ctx: r },
1059
- n
1060
- ));
1002
+ return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (s) => ((n) => s(r, n));
1061
1003
  }
1062
1004
  createComponentForStep(e, t) {
1063
1005
  return this.createComponentImpl(e, t);
@@ -1078,30 +1020,31 @@ Original error: ${i}`,
1078
1020
  return je(this.value, e);
1079
1021
  }
1080
1022
  }
1081
- class Ae extends Ee {
1023
+ class Ae extends $e {
1082
1024
  stepSchema;
1083
1025
  constructor(e) {
1084
- const { nameTransformCasing: t = P, storage: r, ...s } = e;
1026
+ const { nameTransformCasing: t = K, storage: r, ...s } = e;
1085
1027
  super({
1086
1028
  nameTransformCasing: t,
1087
1029
  storage: r,
1088
1030
  ...s
1089
- }), this.stepSchema = new Ce({
1031
+ }), this.stepSchema = new Ve({
1090
1032
  nameTransformCasing: t,
1091
1033
  ...s
1092
1034
  });
1093
1035
  }
1094
1036
  createComponent(e, t) {
1095
- const { stepData: r } = e, s = this.stepHelper.createCtx(
1037
+ const { stepData: r } = e, s = N(
1038
+ this.stepSchema.value,
1096
1039
  r
1097
1040
  );
1098
1041
  return ((n) => t({ ctx: s }, n));
1099
1042
  }
1100
1043
  }
1101
- function Me(o) {
1044
+ function Re(o) {
1102
1045
  return new Ae(o);
1103
1046
  }
1104
- var A = { exports: {} }, x = {}, N = { exports: {} }, D = {};
1047
+ var C = { exports: {} }, L = {}, j = { exports: {} }, D = {};
1105
1048
  /**
1106
1049
  * @license React
1107
1050
  * use-sync-external-store-shim.production.js
@@ -1115,42 +1058,42 @@ var te;
1115
1058
  function Ne() {
1116
1059
  if (te) return D;
1117
1060
  te = 1;
1118
- var o = I;
1119
- function e(u, f) {
1120
- 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;
1121
1064
  }
1122
- var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, s = o.useEffect, n = o.useLayoutEffect, a = o.useDebugValue;
1123
- function c(u, f) {
1124
- var i = f(), m = r({ inst: { value: i, getSnapshot: f } }), h = 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];
1125
1068
  return n(
1126
1069
  function() {
1127
- h.value = i, h.getSnapshot = f, y(h) && b({ inst: h });
1070
+ m.value = a, m.getSnapshot = l, y(m) && b({ inst: m });
1128
1071
  },
1129
- [u, i, f]
1072
+ [u, a, l]
1130
1073
  ), s(
1131
1074
  function() {
1132
- return y(h) && b({ inst: h }), u(function() {
1133
- y(h) && b({ inst: h });
1075
+ return y(m) && b({ inst: m }), u(function() {
1076
+ y(m) && b({ inst: m });
1134
1077
  });
1135
1078
  },
1136
1079
  [u]
1137
- ), a(i), i;
1080
+ ), i(a), a;
1138
1081
  }
1139
1082
  function y(u) {
1140
- var f = u.getSnapshot;
1083
+ var l = u.getSnapshot;
1141
1084
  u = u.value;
1142
1085
  try {
1143
- var i = f();
1144
- return !t(u, i);
1086
+ var a = l();
1087
+ return !t(u, a);
1145
1088
  } catch {
1146
1089
  return !0;
1147
1090
  }
1148
1091
  }
1149
- function p(u, f) {
1150
- return f();
1092
+ function f(u, l) {
1093
+ return l();
1151
1094
  }
1152
- var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? p : c;
1153
- 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;
1154
1097
  }
1155
1098
  var k = {};
1156
1099
  /**
@@ -1163,61 +1106,61 @@ var k = {};
1163
1106
  * LICENSE file in the root directory of this source tree.
1164
1107
  */
1165
1108
  var re;
1166
- function Ve() {
1109
+ function Fe() {
1167
1110
  return re || (re = 1, process.env.NODE_ENV !== "production" && (function() {
1168
- function o(i, m) {
1169
- 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;
1170
1113
  }
1171
- function e(i, m) {
1172
- l || s.startTransition === void 0 || (l = !0, console.error(
1114
+ function e(a, c) {
1115
+ d || s.startTransition === void 0 || (d = !0, console.error(
1173
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."
1174
1117
  ));
1175
- var h = m();
1118
+ var m = c();
1176
1119
  if (!u) {
1177
- var b = m();
1178
- n(h, b) || (console.error(
1120
+ var b = c();
1121
+ n(m, b) || (console.error(
1179
1122
  "The result of getSnapshot should be cached to avoid an infinite loop"
1180
1123
  ), u = !0);
1181
1124
  }
1182
- b = a({
1183
- inst: { value: h, getSnapshot: m }
1125
+ b = i({
1126
+ inst: { value: m, getSnapshot: c }
1184
1127
  });
1185
- var v = b[0].inst, g = b[1];
1128
+ var _ = b[0].inst, w = b[1];
1186
1129
  return y(
1187
1130
  function() {
1188
- v.value = h, v.getSnapshot = m, t(v) && g({ inst: v });
1131
+ _.value = m, _.getSnapshot = c, t(_) && w({ inst: _ });
1189
1132
  },
1190
- [i, h, m]
1191
- ), c(
1133
+ [a, m, c]
1134
+ ), p(
1192
1135
  function() {
1193
- return t(v) && g({ inst: v }), i(function() {
1194
- t(v) && g({ inst: v });
1136
+ return t(_) && w({ inst: _ }), a(function() {
1137
+ t(_) && w({ inst: _ });
1195
1138
  });
1196
1139
  },
1197
- [i]
1198
- ), p(h), h;
1140
+ [a]
1141
+ ), f(m), m;
1199
1142
  }
1200
- function t(i) {
1201
- var m = i.getSnapshot;
1202
- i = i.value;
1143
+ function t(a) {
1144
+ var c = a.getSnapshot;
1145
+ a = a.value;
1203
1146
  try {
1204
- var h = m();
1205
- return !n(i, h);
1147
+ var m = c();
1148
+ return !n(a, m);
1206
1149
  } catch {
1207
1150
  return !0;
1208
1151
  }
1209
1152
  }
1210
- function r(i, m) {
1211
- return m();
1153
+ function r(a, c) {
1154
+ return c();
1212
1155
  }
1213
1156
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1214
- 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;
1215
- 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());
1216
1159
  })()), k;
1217
1160
  }
1218
1161
  var ne;
1219
- function de() {
1220
- 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;
1221
1164
  }
1222
1165
  /**
1223
1166
  * @license React
@@ -1229,55 +1172,55 @@ function de() {
1229
1172
  * LICENSE file in the root directory of this source tree.
1230
1173
  */
1231
1174
  var se;
1232
- function Fe() {
1233
- if (se) return x;
1175
+ function xe() {
1176
+ if (se) return L;
1234
1177
  se = 1;
1235
- var o = I, e = de();
1236
- function t(p, l) {
1237
- return p === l && (p !== 0 || 1 / p === 1 / l) || p !== p && l !== l;
1238
- }
1239
- var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect, c = o.useMemo, y = o.useDebugValue;
1240
- return x.useSyncExternalStoreWithSelector = function(p, l, u, f, i) {
1241
- var m = n(null);
1242
- if (m.current === null) {
1243
- var h = { hasValue: !1, value: null };
1244
- m.current = h;
1245
- } else h = m.current;
1246
- 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(
1247
1190
  function() {
1248
- function v(S) {
1249
- if (!g) {
1250
- if (g = !0, _ = S, S = f(S), i !== void 0 && h.hasValue) {
1251
- var w = h.value;
1252
- if (i(w, S))
1253
- return $ = 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;
1254
1197
  }
1255
- return $ = S;
1198
+ return O = S;
1256
1199
  }
1257
- if (w = $, r(_, S)) return w;
1258
- var E = f(S);
1259
- return i !== void 0 && i(w, E) ? (_ = 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);
1260
1203
  }
1261
- var g = !1, _, $, T = u === void 0 ? null : u;
1204
+ var w = !1, g, O, T = u === void 0 ? null : u;
1262
1205
  return [
1263
1206
  function() {
1264
- return v(l());
1207
+ return _(d());
1265
1208
  },
1266
1209
  T === null ? void 0 : function() {
1267
- return v(T());
1210
+ return _(T());
1268
1211
  }
1269
1212
  ];
1270
1213
  },
1271
- [l, u, f, i]
1214
+ [d, u, l, a]
1272
1215
  );
1273
- var b = s(p, m[0], m[1]);
1274
- return a(
1216
+ var b = s(f, c[0], c[1]);
1217
+ return i(
1275
1218
  function() {
1276
- h.hasValue = !0, h.value = b;
1219
+ m.hasValue = !0, m.value = b;
1277
1220
  },
1278
1221
  [b]
1279
1222
  ), y(b), b;
1280
- }, x;
1223
+ }, L;
1281
1224
  }
1282
1225
  var M = {};
1283
1226
  /**
@@ -1292,62 +1235,62 @@ var M = {};
1292
1235
  var oe;
1293
1236
  function Ie() {
1294
1237
  return oe || (oe = 1, process.env.NODE_ENV !== "production" && (function() {
1295
- function o(p, l) {
1296
- 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;
1297
1240
  }
1298
1241
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1299
- 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;
1300
- M.useSyncExternalStoreWithSelector = function(p, l, u, f, i) {
1301
- var m = n(null);
1302
- if (m.current === null) {
1303
- var h = { hasValue: !1, value: null };
1304
- m.current = h;
1305
- } else h = m.current;
1306
- 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(
1307
1250
  function() {
1308
- function v(S) {
1309
- if (!g) {
1310
- if (g = !0, _ = S, S = f(S), i !== void 0 && h.hasValue) {
1311
- var w = h.value;
1312
- if (i(w, S))
1313
- return $ = 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;
1314
1257
  }
1315
- return $ = S;
1258
+ return O = S;
1316
1259
  }
1317
- if (w = $, r(_, S))
1318
- return w;
1319
- var E = f(S);
1320
- return i !== void 0 && i(w, E) ? (_ = 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);
1321
1264
  }
1322
- var g = !1, _, $, T = u === void 0 ? null : u;
1265
+ var w = !1, g, O, T = u === void 0 ? null : u;
1323
1266
  return [
1324
1267
  function() {
1325
- return v(l());
1268
+ return _(d());
1326
1269
  },
1327
1270
  T === null ? void 0 : function() {
1328
- return v(T());
1271
+ return _(T());
1329
1272
  }
1330
1273
  ];
1331
1274
  },
1332
- [l, u, f, i]
1275
+ [d, u, l, a]
1333
1276
  );
1334
- var b = s(p, m[0], m[1]);
1335
- return a(
1277
+ var b = s(f, c[0], c[1]);
1278
+ return i(
1336
1279
  function() {
1337
- h.hasValue = !0, h.value = b;
1280
+ m.hasValue = !0, m.value = b;
1338
1281
  },
1339
1282
  [b]
1340
1283
  ), y(b), b;
1341
1284
  }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1342
1285
  })()), M;
1343
1286
  }
1344
- var ae;
1287
+ var ie;
1345
1288
  function Le() {
1346
- 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;
1347
1290
  }
1348
- var xe = Le();
1349
- function W(o, e) {
1350
- d(
1291
+ var De = Le();
1292
+ function H(o, e) {
1293
+ h(
1351
1294
  typeof e == "string",
1352
1295
  `The target step must be a string, was ${typeof e}`
1353
1296
  );
@@ -1355,26 +1298,26 @@ function W(o, e) {
1355
1298
  type: "disjunction",
1356
1299
  style: "long"
1357
1300
  }).format(t("array.string.untyped"));
1358
- d(
1359
- fe.test(e),
1301
+ h(
1302
+ de.test(e),
1360
1303
  `The target step must match the following format: "step{number}". Available steps are ${n}`
1361
1304
  );
1362
- const a = Number.parseInt(e.replace("step", ""));
1363
- return d(
1364
- r(a),
1365
- `The step number "${a}" is not a valid step number. Valid step numbers include ${n}`,
1305
+ const i = Number.parseInt(e.replace("step", ""));
1306
+ return h(
1307
+ r(i),
1308
+ `The step number "${i}" is not a valid step number. Valid step numbers include ${n}`,
1366
1309
  TypeError
1367
- ), a;
1310
+ ), i;
1368
1311
  }
1369
- function he(o) {
1312
+ function ye(o) {
1370
1313
  function e(t) {
1371
- return xe.useSyncExternalStoreWithSelector(
1314
+ return De.useSyncExternalStoreWithSelector(
1372
1315
  o.subscribe,
1373
1316
  () => o.getSnapshot(),
1374
1317
  () => o.getSnapshot(),
1375
1318
  (r) => {
1376
1319
  if (typeof t == "object") {
1377
- const s = W(
1320
+ const s = H(
1378
1321
  r,
1379
1322
  t.targetStep
1380
1323
  );
@@ -1386,70 +1329,70 @@ function he(o) {
1386
1329
  }
1387
1330
  return e;
1388
1331
  }
1389
- function Re(o, e) {
1390
- const t = he(o);
1332
+ function Ue(o, e) {
1333
+ const t = ye(o);
1391
1334
  return typeof e == "object" || typeof e == "function" ? t(e) : t();
1392
1335
  }
1393
- function ie(o) {
1336
+ function ae(o) {
1394
1337
  return function(e) {
1395
1338
  return ((t) => e(o, t));
1396
1339
  };
1397
1340
  }
1398
- function Ue(o) {
1399
- const e = he(o);
1400
- function t(c) {
1401
- 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({
1402
1345
  targetStep: y
1403
- }), 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: [
1404
1347
  "No data found for step ",
1405
1348
  String(y)
1406
1349
  ] });
1407
- return l ? {
1350
+ return d ? {
1408
1351
  data: u,
1409
- NoCurrentData: f
1410
- } : B.hasData(u) ? {
1352
+ NoCurrentData: l
1353
+ } : G.hasData(u) ? {
1411
1354
  data: u,
1412
1355
  hasData: !0,
1413
- NoCurrentData: f
1356
+ NoCurrentData: l
1414
1357
  } : {
1415
1358
  data: void 0,
1416
1359
  hasData: !1,
1417
- NoCurrentData: f
1360
+ NoCurrentData: l
1418
1361
  };
1419
1362
  }
1420
- function r(c) {
1363
+ function r(p) {
1421
1364
  const y = e(
1422
1365
  (b) => b.stepSchema.steps.value.length
1423
1366
  ), {
1424
- targetStep: p,
1425
- maxProgressValue: l = 100,
1367
+ targetStep: f,
1368
+ maxProgressValue: d = 100,
1426
1369
  totalSteps: u = y,
1427
- progressTextTransformer: f
1428
- } = c, i = W(o, p), m = i / u * l, h = f ? n(
1429
- { targetStep: p, maxProgressValue: l, totalSteps: u },
1430
- f
1431
- ) : (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: [
1432
1375
  "Step ",
1433
- i,
1376
+ a,
1434
1377
  "/",
1435
1378
  u
1436
1379
  ] });
1437
1380
  return {
1438
- value: m,
1439
- maxProgressValue: l,
1440
- ProgressText: h
1381
+ value: c,
1382
+ maxProgressValue: d,
1383
+ ProgressText: m
1441
1384
  };
1442
1385
  }
1443
- function s(c) {
1444
- const p = e((u) => u.storage).get(), l = !!(p && typeof p == "object" && Object.keys(p).length > 0);
1445
- 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;
1446
1389
  }
1447
- function n(c, y) {
1448
- const p = o.getSnapshot().stepSchema.steps.value.length, { targetStep: l, maxProgressValue: u = 100, totalSteps: f = p } = c;
1449
- 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);
1450
1393
  }
1451
- function a(c, y) {
1452
- return W(o, c.targetStep), ie(c)(y);
1394
+ function i(p, y) {
1395
+ return H(o, p.targetStep), ae(p)(y);
1453
1396
  }
1454
1397
  return {
1455
1398
  // MultiStepFormContext: Context,
@@ -1458,16 +1401,16 @@ function Ue(o) {
1458
1401
  useProgress: r,
1459
1402
  useCanRestartForm: s,
1460
1403
  withProgressText: n,
1461
- withNoStepDataFound: a
1404
+ withNoStepDataFound: i
1462
1405
  };
1463
1406
  }
1464
1407
  export {
1465
1408
  Ae as MultiStepFormSchema,
1466
- Ce as MultiStepFormStepSchema,
1467
- H as StepSpecificComponent,
1409
+ Ve as MultiStepFormStepSchema,
1410
+ U as StepSpecificComponent,
1468
1411
  je as createDefaultValues,
1469
- Ue as createMultiStepFormContext,
1470
- Me as createMultiStepFormSchema,
1471
- Re as useMultiStepFormData
1412
+ He as createMultiStepFormContext,
1413
+ Re as createMultiStepFormSchema,
1414
+ Ue as useMultiStepFormData
1472
1415
  };
1473
1416
  //# sourceMappingURL=index.mjs.map