@jfdevelops/react-multi-step-form 1.0.0-alpha.5 → 1.0.0-alpha.7
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.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +233 -228
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as Ae, jsxs as se } from "react/jsx-runtime";
|
|
2
2
|
import G from "react";
|
|
3
3
|
function U(o, e, t) {
|
|
4
4
|
const r = [], s = new Set(o), n = t ? t.format(o.map((u) => `${u}`)) : `[${o.join(", ")}]`;
|
|
@@ -17,22 +17,22 @@ function R(o, e) {
|
|
|
17
17
|
return o.map((r, s) => t(r, s)).join(`
|
|
18
18
|
`);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function oe(o) {
|
|
21
21
|
return Object.keys(o);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function Te(o, ...e) {
|
|
24
24
|
return () => String.raw({ raw: o }, ...e);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function w(o, e, t = Error) {
|
|
27
27
|
if (!o) {
|
|
28
|
-
const r = typeof e == "function" ? e() :
|
|
28
|
+
const r = typeof e == "function" ? e() : Te`${e}`();
|
|
29
29
|
throw new t(r);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function M(o) {
|
|
33
|
-
|
|
33
|
+
w(o.includes("step"), "Can't extract a valid step number since");
|
|
34
34
|
const e = o.replace("step", "");
|
|
35
|
-
return
|
|
35
|
+
return w(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
|
|
36
36
|
}
|
|
37
37
|
function K(o) {
|
|
38
38
|
return function(e) {
|
|
@@ -40,7 +40,7 @@ function K(o) {
|
|
|
40
40
|
return { step: t, data: s };
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ie(o, e) {
|
|
44
44
|
return e.reduce((t, r) => {
|
|
45
45
|
const s = M(r), { data: n } = K(o)({
|
|
46
46
|
step: s
|
|
@@ -76,7 +76,7 @@ function N(o, e) {
|
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
if (Array.isArray(e))
|
|
79
|
-
return
|
|
79
|
+
return w(
|
|
80
80
|
e.every((n) => r.includes(n)),
|
|
81
81
|
() => {
|
|
82
82
|
const n = U(
|
|
@@ -89,13 +89,13 @@ function N(o, e) {
|
|
|
89
89
|
n.errors
|
|
90
90
|
)}` : s();
|
|
91
91
|
}
|
|
92
|
-
),
|
|
92
|
+
), ie(
|
|
93
93
|
o,
|
|
94
94
|
e
|
|
95
95
|
);
|
|
96
96
|
if (typeof e == "object") {
|
|
97
97
|
const n = Object.keys(e);
|
|
98
|
-
return
|
|
98
|
+
return w(
|
|
99
99
|
n.every((a) => r.includes(a)),
|
|
100
100
|
() => {
|
|
101
101
|
const a = U(
|
|
@@ -108,18 +108,18 @@ function N(o, e) {
|
|
|
108
108
|
a.errors
|
|
109
109
|
)}` : s();
|
|
110
110
|
}
|
|
111
|
-
),
|
|
111
|
+
), ie(
|
|
112
112
|
o,
|
|
113
113
|
n
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
throw new Error(`${s()} OR to "all"`);
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function je(o, e) {
|
|
119
119
|
return typeof o == "function" ? o(e) : o;
|
|
120
120
|
}
|
|
121
121
|
const H = "MultiStepFormSchema";
|
|
122
|
-
class
|
|
122
|
+
class Q {
|
|
123
123
|
debug;
|
|
124
124
|
prefix = H;
|
|
125
125
|
includeTimestamp = !1;
|
|
@@ -199,9 +199,9 @@ var C;
|
|
|
199
199
|
function t(i, l, d) {
|
|
200
200
|
const c = l.split(".");
|
|
201
201
|
let h = i;
|
|
202
|
-
for (let
|
|
203
|
-
const $ = c[
|
|
204
|
-
|
|
202
|
+
for (let _ = 0; _ < c.length; _++) {
|
|
203
|
+
const $ = c[_];
|
|
204
|
+
_ === c.length - 1 ? h[$] !== void 0 && typeof h[$] == "object" && typeof d == "object" && d !== null ? Object.assign(h[$], d) : h[$] = d : ((typeof h[$] != "object" || h[$] === null) && (h[$] = {}), h = h[$]);
|
|
205
205
|
}
|
|
206
206
|
return h;
|
|
207
207
|
}
|
|
@@ -215,8 +215,8 @@ var C;
|
|
|
215
215
|
return e(i, d[0]);
|
|
216
216
|
const c = {};
|
|
217
217
|
for (const h of d) {
|
|
218
|
-
const
|
|
219
|
-
t(c, h,
|
|
218
|
+
const _ = e(i, h);
|
|
219
|
+
t(c, h, _);
|
|
220
220
|
}
|
|
221
221
|
return c;
|
|
222
222
|
}
|
|
@@ -226,12 +226,12 @@ var C;
|
|
|
226
226
|
function d(c, h = "") {
|
|
227
227
|
if (c == null || typeof c != "object" || Array.isArray(c))
|
|
228
228
|
return;
|
|
229
|
-
const
|
|
230
|
-
for (const $ of
|
|
231
|
-
const
|
|
232
|
-
l.push(
|
|
233
|
-
const
|
|
234
|
-
|
|
229
|
+
const _ = Object.keys(c);
|
|
230
|
+
for (const $ of _) {
|
|
231
|
+
const T = h ? `${h}.${$}` : $;
|
|
232
|
+
l.push(T);
|
|
233
|
+
const j = c[$];
|
|
234
|
+
j != null && typeof j == "object" && !Array.isArray(j) && d(j, T);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
return d(i), l;
|
|
@@ -259,13 +259,13 @@ var C;
|
|
|
259
259
|
return i;
|
|
260
260
|
const d = u(l);
|
|
261
261
|
let c = i, h;
|
|
262
|
-
for (const
|
|
262
|
+
for (const _ of d) {
|
|
263
263
|
if (!c) break;
|
|
264
264
|
if (typeof c == "function") {
|
|
265
265
|
h = c;
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
|
-
if (c = c[
|
|
268
|
+
if (c = c[_], typeof c == "function") {
|
|
269
269
|
h = c;
|
|
270
270
|
break;
|
|
271
271
|
}
|
|
@@ -298,45 +298,45 @@ var C;
|
|
|
298
298
|
}
|
|
299
299
|
if (Array.isArray(i) || Array.isArray(l)) {
|
|
300
300
|
if (!Array.isArray(i) || !Array.isArray(l)) {
|
|
301
|
-
const
|
|
301
|
+
const T = d || "(root)";
|
|
302
302
|
return c.push({
|
|
303
|
-
path:
|
|
304
|
-
expected: S(i,
|
|
303
|
+
path: T,
|
|
304
|
+
expected: S(i, T, h.transformExpected),
|
|
305
305
|
actual: l,
|
|
306
306
|
reason: "type-mismatch"
|
|
307
307
|
}), c;
|
|
308
308
|
}
|
|
309
309
|
const $ = i.length;
|
|
310
|
-
for (let
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
310
|
+
for (let T = 0; T < $; T++) {
|
|
311
|
+
const j = i[T], k = l[T], F = d === "" ? `[${T}]` : `${d}[${T}]`;
|
|
312
|
+
if (T >= l.length) {
|
|
313
313
|
c.push({
|
|
314
314
|
path: F,
|
|
315
|
-
expected: S(
|
|
315
|
+
expected: S(j, F, h.transformExpected),
|
|
316
316
|
actual: void 0,
|
|
317
317
|
reason: "missing-key"
|
|
318
318
|
});
|
|
319
319
|
continue;
|
|
320
320
|
}
|
|
321
|
-
f(
|
|
321
|
+
f(j, k, F, c, h);
|
|
322
322
|
}
|
|
323
323
|
if (l.length > i.length)
|
|
324
|
-
for (let
|
|
325
|
-
const
|
|
324
|
+
for (let T = i.length; T < l.length; T++) {
|
|
325
|
+
const j = d === "" ? `[${T}]` : `${d}[${T}]`;
|
|
326
326
|
c.push({
|
|
327
|
-
path:
|
|
327
|
+
path: j,
|
|
328
328
|
expected: void 0,
|
|
329
|
-
actual: l[
|
|
329
|
+
actual: l[T],
|
|
330
330
|
reason: "extra-key"
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
return c;
|
|
334
334
|
}
|
|
335
335
|
if (p(i) && p(l)) {
|
|
336
|
-
const $ = Object.keys(i),
|
|
337
|
-
for (const
|
|
338
|
-
const k = i[
|
|
339
|
-
if (!(
|
|
336
|
+
const $ = Object.keys(i), T = Object.keys(l);
|
|
337
|
+
for (const j of $) {
|
|
338
|
+
const k = i[j], F = l[j], V = d ? `${d}.${j}` : j;
|
|
339
|
+
if (!(j in l)) {
|
|
340
340
|
c.push({
|
|
341
341
|
path: V,
|
|
342
342
|
expected: S(k, V, h.transformExpected),
|
|
@@ -347,38 +347,38 @@ var C;
|
|
|
347
347
|
}
|
|
348
348
|
f(k, F, V, c, h);
|
|
349
349
|
}
|
|
350
|
-
for (const
|
|
351
|
-
if (!(
|
|
352
|
-
const k = d ? `${d}.${
|
|
350
|
+
for (const j of T)
|
|
351
|
+
if (!(j in i)) {
|
|
352
|
+
const k = d ? `${d}.${j}` : j;
|
|
353
353
|
c.push({
|
|
354
354
|
path: k,
|
|
355
355
|
expected: void 0,
|
|
356
|
-
actual: l[
|
|
356
|
+
actual: l[j],
|
|
357
357
|
reason: "extra-key"
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
return c;
|
|
361
361
|
}
|
|
362
|
-
const
|
|
362
|
+
const _ = d || "(root)";
|
|
363
363
|
return typeof i != typeof l ? c.push({
|
|
364
|
-
path:
|
|
365
|
-
expected: S(i,
|
|
364
|
+
path: _,
|
|
365
|
+
expected: S(i, _, h.transformExpected),
|
|
366
366
|
actual: l,
|
|
367
367
|
reason: "type-mismatch"
|
|
368
368
|
}) : h.includeValueMismatch && c.push({
|
|
369
|
-
path:
|
|
370
|
-
expected: S(i,
|
|
369
|
+
path: _,
|
|
370
|
+
expected: S(i, _, h.transformExpected),
|
|
371
371
|
actual: l,
|
|
372
372
|
reason: "value-mismatch"
|
|
373
373
|
}), c;
|
|
374
374
|
}
|
|
375
375
|
function v(i, l, d, c) {
|
|
376
|
-
const h = s(i, ...l),
|
|
377
|
-
return f(h, d, $,
|
|
376
|
+
const h = s(i, ...l), _ = [], $ = l.length === 1 ? l[0] : "";
|
|
377
|
+
return f(h, d, $, _, {
|
|
378
378
|
transformExpected: c?.transformExpected
|
|
379
379
|
}), {
|
|
380
|
-
ok:
|
|
381
|
-
mismatches:
|
|
380
|
+
ok: _.length === 0,
|
|
381
|
+
mismatches: _
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
o.equalsAtPaths = v;
|
|
@@ -427,41 +427,41 @@ var C;
|
|
|
427
427
|
l !== "No mismatches." && console.error(l);
|
|
428
428
|
}
|
|
429
429
|
o.printMismatches = E;
|
|
430
|
-
function
|
|
430
|
+
function O(i, l, d) {
|
|
431
431
|
const c = l.split(".");
|
|
432
|
-
function h(
|
|
433
|
-
const
|
|
432
|
+
function h(_, $) {
|
|
433
|
+
const T = c[$], j = Array.isArray(_) ? [..._] : { ..._ };
|
|
434
434
|
if ($ === c.length - 1) {
|
|
435
|
-
let P =
|
|
435
|
+
let P = _ && typeof _ == "object" ? j : {};
|
|
436
436
|
return P = {
|
|
437
437
|
...P,
|
|
438
|
-
[
|
|
438
|
+
[T]: d
|
|
439
439
|
}, P;
|
|
440
440
|
}
|
|
441
|
-
const k =
|
|
442
|
-
let V =
|
|
441
|
+
const k = _ && typeof _ == "object" ? _[T] : void 0, F = h(k ?? {}, $ + 1);
|
|
442
|
+
let V = _ && typeof _ == "object" ? j : {};
|
|
443
443
|
return V = {
|
|
444
444
|
...V,
|
|
445
|
-
[
|
|
445
|
+
[T]: F
|
|
446
446
|
}, V;
|
|
447
447
|
}
|
|
448
448
|
return h(i, 0);
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function A(i, l, d) {
|
|
451
451
|
const c = r(l);
|
|
452
452
|
if (c.length === 0) return i;
|
|
453
453
|
let h = i;
|
|
454
454
|
if (c.length === 1) {
|
|
455
|
-
const
|
|
456
|
-
return h =
|
|
455
|
+
const _ = c[0];
|
|
456
|
+
return h = O(h, _, d), h;
|
|
457
457
|
}
|
|
458
|
-
for (const
|
|
459
|
-
const $ = e(d,
|
|
460
|
-
h =
|
|
458
|
+
for (const _ of c) {
|
|
459
|
+
const $ = e(d, _);
|
|
460
|
+
h = O(h, _, $);
|
|
461
461
|
}
|
|
462
462
|
return h;
|
|
463
463
|
}
|
|
464
|
-
o.updateAt =
|
|
464
|
+
o.updateAt = A;
|
|
465
465
|
})(C || (C = {}));
|
|
466
466
|
function ge(o, e) {
|
|
467
467
|
const t = o["~standard"].validate(e);
|
|
@@ -476,7 +476,7 @@ function ge(o, e) {
|
|
|
476
476
|
function Se(o, e) {
|
|
477
477
|
return Object.keys(o).includes(e);
|
|
478
478
|
}
|
|
479
|
-
class
|
|
479
|
+
class ee {
|
|
480
480
|
#e;
|
|
481
481
|
#t;
|
|
482
482
|
get value() {
|
|
@@ -490,23 +490,23 @@ class Q {
|
|
|
490
490
|
this.#t(this.enrichValues(e));
|
|
491
491
|
}
|
|
492
492
|
createStepUpdaterFnImpl(e) {
|
|
493
|
-
const { targetStep: t, updater: r, ctxData: s, fields: n = "all", debug: a } = e, u = new
|
|
493
|
+
const { targetStep: t, updater: r, ctxData: s, fields: n = "all", debug: a } = e, u = new Q({
|
|
494
494
|
debug: a,
|
|
495
495
|
prefix: (m) => `${m}:update${t}`
|
|
496
496
|
});
|
|
497
|
-
u.info(`${t} will be updated`),
|
|
497
|
+
u.info(`${t} will be updated`), w(
|
|
498
498
|
Se(this.value, t),
|
|
499
499
|
`[update]: The target step ${t} isn't a valid step. Please select a valid step`
|
|
500
500
|
);
|
|
501
501
|
const { [t]: b, ...S } = this.value;
|
|
502
502
|
let p = { ...this.value }, f = N(p, [t]);
|
|
503
503
|
if (s) {
|
|
504
|
-
|
|
504
|
+
w(
|
|
505
505
|
typeof s == "function",
|
|
506
506
|
'[update]: "ctxData" must be a function'
|
|
507
507
|
), u.info('Custom "ctx" will be used');
|
|
508
508
|
const m = s({ ctx: S });
|
|
509
|
-
|
|
509
|
+
w(
|
|
510
510
|
typeof m == "object" && Object.keys(m).length > 0,
|
|
511
511
|
'[update]: "ctxData" must return an object with keys'
|
|
512
512
|
), u.info(
|
|
@@ -522,17 +522,17 @@ class Q {
|
|
|
522
522
|
...m
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
|
-
const v =
|
|
525
|
+
const v = je(r, {
|
|
526
526
|
ctx: f,
|
|
527
527
|
update: this.createHelperFnInputUpdate([t])
|
|
528
528
|
});
|
|
529
529
|
if (u.info(`The updated data is ${JSON.stringify(v, null, 2)}`), !n) {
|
|
530
|
-
|
|
530
|
+
w(
|
|
531
531
|
typeof v == "object",
|
|
532
532
|
'[update]: "updater" must be an object or a function that returns an object'
|
|
533
533
|
);
|
|
534
534
|
const m = Object.keys(this.value), g = Object.keys(v);
|
|
535
|
-
|
|
535
|
+
w(g.length === m.length, () => {
|
|
536
536
|
const i = m.filter(
|
|
537
537
|
(d) => !g.includes(d)
|
|
538
538
|
);
|
|
@@ -543,16 +543,16 @@ class Q {
|
|
|
543
543
|
i
|
|
544
544
|
)}`;
|
|
545
545
|
});
|
|
546
|
-
const E = C.createDeep(this.value), { mismatches:
|
|
546
|
+
const E = C.createDeep(this.value), { mismatches: O, ok: A } = C.equalsAtPaths(
|
|
547
547
|
this.value,
|
|
548
548
|
E,
|
|
549
549
|
v
|
|
550
550
|
);
|
|
551
|
-
|
|
552
|
-
|
|
551
|
+
w(
|
|
552
|
+
A && O.length === 0,
|
|
553
553
|
`[update]: found value mismatches in ${C.printMismatches({
|
|
554
|
-
mismatches:
|
|
555
|
-
ok:
|
|
554
|
+
mismatches: O,
|
|
555
|
+
ok: A
|
|
556
556
|
})}`
|
|
557
557
|
), u.info("The entire step will be updated"), p = {
|
|
558
558
|
...p,
|
|
@@ -563,7 +563,7 @@ class Q {
|
|
|
563
563
|
const y = C.createDeep(b);
|
|
564
564
|
if (Array.isArray(n)) {
|
|
565
565
|
const m = U(y, n);
|
|
566
|
-
|
|
566
|
+
w(
|
|
567
567
|
m.status === "success",
|
|
568
568
|
`[update]: Found errors with the provided fields
|
|
569
569
|
${m.status === "error" ? R(m.errors) : ""}`
|
|
@@ -573,7 +573,7 @@ ${m.status === "error" ? R(m.errors) : ""}`
|
|
|
573
573
|
n,
|
|
574
574
|
v
|
|
575
575
|
);
|
|
576
|
-
|
|
576
|
+
w(
|
|
577
577
|
E && g.length === 0,
|
|
578
578
|
`[update]: found value mismatches in ${C.printMismatches({
|
|
579
579
|
ok: E,
|
|
@@ -595,20 +595,20 @@ ${m.status === "error" ? R(m.errors) : ""}`
|
|
|
595
595
|
y,
|
|
596
596
|
m
|
|
597
597
|
);
|
|
598
|
-
|
|
598
|
+
w(
|
|
599
599
|
g.status === "success",
|
|
600
600
|
`[update]: Found errors with the provided fields
|
|
601
601
|
${g.status === "error" ? R(g.errors) : ""}`
|
|
602
602
|
);
|
|
603
|
-
const { mismatches: E, ok:
|
|
603
|
+
const { mismatches: E, ok: O } = C.equalsAtPaths(
|
|
604
604
|
b,
|
|
605
605
|
m,
|
|
606
606
|
v
|
|
607
607
|
);
|
|
608
|
-
|
|
609
|
-
|
|
608
|
+
w(
|
|
609
|
+
O && E.length === 0,
|
|
610
610
|
`[update]: found value mismatches in ${C.printMismatches({
|
|
611
|
-
ok:
|
|
611
|
+
ok: O,
|
|
612
612
|
mismatches: E
|
|
613
613
|
})}`
|
|
614
614
|
), p = {
|
|
@@ -641,7 +641,7 @@ ${g.status === "error" ? R(g.errors) : ""}`
|
|
|
641
641
|
}
|
|
642
642
|
createHelperFnInputUpdate(e) {
|
|
643
643
|
if (x.isAll(e)) {
|
|
644
|
-
const r =
|
|
644
|
+
const r = oe(this.value).reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
|
|
645
645
|
return Object.assign(
|
|
646
646
|
this.update,
|
|
647
647
|
r
|
|
@@ -656,7 +656,7 @@ ${g.status === "error" ? R(g.errors) : ""}`
|
|
|
656
656
|
);
|
|
657
657
|
}
|
|
658
658
|
if (x.isObject(e, t)) {
|
|
659
|
-
const r =
|
|
659
|
+
const r = oe(e).reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
|
|
660
660
|
return Object.assign(
|
|
661
661
|
this.update,
|
|
662
662
|
r
|
|
@@ -680,7 +680,7 @@ ${g.status === "error" ? R(g.errors) : ""}`
|
|
|
680
680
|
if (typeof t == "object")
|
|
681
681
|
return (a) => {
|
|
682
682
|
if ("validator" in t) {
|
|
683
|
-
|
|
683
|
+
w(
|
|
684
684
|
typeof a == "object",
|
|
685
685
|
"An input is expected since you provided a validator"
|
|
686
686
|
), ge(
|
|
@@ -757,7 +757,7 @@ const Ce = [
|
|
|
757
757
|
"screaming-snake",
|
|
758
758
|
"flat",
|
|
759
759
|
"kebab"
|
|
760
|
-
],
|
|
760
|
+
], te = "title";
|
|
761
761
|
function ke(o, e) {
|
|
762
762
|
const t = o.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).map((r) => r.toLowerCase());
|
|
763
763
|
switch (e) {
|
|
@@ -785,11 +785,11 @@ function ke(o, e) {
|
|
|
785
785
|
return o;
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
|
-
function
|
|
788
|
+
function Y(o) {
|
|
789
789
|
return typeof o != "string" ? !1 : Ce.includes(o);
|
|
790
790
|
}
|
|
791
|
-
function be(o, e =
|
|
792
|
-
return
|
|
791
|
+
function be(o, e = te) {
|
|
792
|
+
return Y(o) ? o : e;
|
|
793
793
|
}
|
|
794
794
|
const Fe = [
|
|
795
795
|
"string",
|
|
@@ -801,25 +801,26 @@ const Fe = [
|
|
|
801
801
|
"date",
|
|
802
802
|
"dateTime",
|
|
803
803
|
"boolean.switch"
|
|
804
|
-
],
|
|
804
|
+
], ae = "string";
|
|
805
805
|
function Ve(o) {
|
|
806
806
|
return typeof o == "string" && Fe.includes(o);
|
|
807
807
|
}
|
|
808
|
-
const
|
|
808
|
+
const W = '"window" in undefined. No storage is available', re = "MultiStepForm";
|
|
809
809
|
class ve {
|
|
810
810
|
key;
|
|
811
811
|
store;
|
|
812
812
|
data;
|
|
813
813
|
log;
|
|
814
|
-
|
|
814
|
+
shouldRunActions;
|
|
815
|
+
throwWhenUndefined;
|
|
815
816
|
constructor(e) {
|
|
816
|
-
const { key: t, data: r, store: s } = e;
|
|
817
|
-
this.log = new
|
|
818
|
-
prefix:
|
|
819
|
-
}), this.key = t, this.data = r, s ? (this.store = s, this.
|
|
817
|
+
const { key: t, data: r, store: s, throwWhenUndefined: n = !1 } = e;
|
|
818
|
+
this.log = new Q({
|
|
819
|
+
prefix: re
|
|
820
|
+
}), this.key = t, this.data = r, this.throwWhenUndefined = n, s ? (this.store = s, this.shouldRunActions = !0, typeof window > "u" && (this.shouldRunActions = !1, this.log.warn(W))) : typeof window < "u" ? (this.store = window.localStorage, this.shouldRunActions = !0) : (this.shouldRunActions = !1, this.log.warn(W));
|
|
820
821
|
}
|
|
821
822
|
throwOnEmptyStore() {
|
|
822
|
-
|
|
823
|
+
this.throwWhenUndefined && w(this.store, () => this.shouldRunActions ? W : "No storage available");
|
|
823
824
|
}
|
|
824
825
|
resolveValue(e) {
|
|
825
826
|
if (typeof e == "object")
|
|
@@ -835,16 +836,18 @@ class ve {
|
|
|
835
836
|
return this.store.getItem(this.key) !== null;
|
|
836
837
|
}
|
|
837
838
|
get() {
|
|
838
|
-
this.throwOnEmptyStore()
|
|
839
|
+
if (this.throwOnEmptyStore(), !this.shouldRunActions)
|
|
840
|
+
return;
|
|
839
841
|
const e = this.store.getItem(this.key);
|
|
840
842
|
if (e)
|
|
841
843
|
return JSON.parse(e);
|
|
842
844
|
}
|
|
843
845
|
remove() {
|
|
844
|
-
this.throwOnEmptyStore(), this.store.removeItem(this.key);
|
|
846
|
+
this.throwOnEmptyStore(), this.shouldRunActions && this.store.removeItem(this.key);
|
|
845
847
|
}
|
|
846
848
|
add(e) {
|
|
847
|
-
this.throwOnEmptyStore()
|
|
849
|
+
if (this.throwOnEmptyStore(), !this.shouldRunActions)
|
|
850
|
+
return;
|
|
848
851
|
const t = JSON.stringify(this.resolveValue(e));
|
|
849
852
|
this.store.setItem(this.key, t);
|
|
850
853
|
}
|
|
@@ -872,7 +875,7 @@ const xe = [
|
|
|
872
875
|
"number",
|
|
873
876
|
"array.string",
|
|
874
877
|
"array.string.untyped"
|
|
875
|
-
],
|
|
878
|
+
], we = /^step\d+$/i;
|
|
876
879
|
function ue(o, e) {
|
|
877
880
|
if (typeof o != "object" || o === null) return !1;
|
|
878
881
|
for (const t of Object.keys(e)) {
|
|
@@ -888,10 +891,10 @@ function ce(o, e, t) {
|
|
|
888
891
|
function Le(o) {
|
|
889
892
|
const e = {}, { fields: t, defaultCasing: r, validateFields: s } = o;
|
|
890
893
|
for (const [n, a] of Object.entries(t)) {
|
|
891
|
-
|
|
894
|
+
w(
|
|
892
895
|
typeof n == "string",
|
|
893
896
|
`Each key for the "fields" option must be a string. Key ${n} was a ${typeof n}`
|
|
894
|
-
),
|
|
897
|
+
), w(
|
|
895
898
|
typeof a == "object",
|
|
896
899
|
`The value for key ${n} must be an object. Was ${typeof a}`
|
|
897
900
|
);
|
|
@@ -899,7 +902,7 @@ function Le(o) {
|
|
|
899
902
|
defaultValue: u,
|
|
900
903
|
label: b,
|
|
901
904
|
nameTransformCasing: S,
|
|
902
|
-
type: p =
|
|
905
|
+
type: p = ae
|
|
903
906
|
} = a;
|
|
904
907
|
if (s)
|
|
905
908
|
e[n] = u;
|
|
@@ -920,22 +923,22 @@ function Le(o) {
|
|
|
920
923
|
s,
|
|
921
924
|
e
|
|
922
925
|
);
|
|
923
|
-
|
|
926
|
+
w(
|
|
924
927
|
typeof n == "object",
|
|
925
928
|
`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`
|
|
926
|
-
),
|
|
929
|
+
), w(
|
|
927
930
|
!!n,
|
|
928
931
|
"The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it"
|
|
929
932
|
);
|
|
930
933
|
for (const [a, u] of Object.entries(n)) {
|
|
931
934
|
const b = t[a];
|
|
932
|
-
|
|
935
|
+
w(
|
|
933
936
|
b,
|
|
934
937
|
`No field found in the fields config for "${a}"`
|
|
935
938
|
);
|
|
936
939
|
const {
|
|
937
940
|
label: S,
|
|
938
|
-
type: p =
|
|
941
|
+
type: p = ae,
|
|
939
942
|
nameTransformCasing: f
|
|
940
943
|
} = b, v = f ?? r;
|
|
941
944
|
e[a] = {
|
|
@@ -949,43 +952,43 @@ function Le(o) {
|
|
|
949
952
|
}
|
|
950
953
|
return e;
|
|
951
954
|
}
|
|
952
|
-
function
|
|
955
|
+
function _e(o) {
|
|
953
956
|
const e = {};
|
|
954
|
-
|
|
957
|
+
w(!!o, "The steps config must be defined", TypeError), w(
|
|
955
958
|
typeof o == "object",
|
|
956
959
|
`The steps config must be an object, was (${typeof o})`,
|
|
957
960
|
TypeError
|
|
958
961
|
);
|
|
959
962
|
for (const [t, r] of Object.entries(o)) {
|
|
960
|
-
|
|
963
|
+
w(
|
|
961
964
|
typeof t == "string",
|
|
962
965
|
`Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
|
|
963
966
|
TypeError
|
|
964
|
-
),
|
|
965
|
-
|
|
967
|
+
), w(
|
|
968
|
+
we.test(t),
|
|
966
969
|
`The key "${t}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`
|
|
967
970
|
);
|
|
968
971
|
const s = t, {
|
|
969
972
|
fields: n,
|
|
970
973
|
title: a,
|
|
971
|
-
nameTransformCasing: u =
|
|
974
|
+
nameTransformCasing: u = te,
|
|
972
975
|
description: b,
|
|
973
976
|
validateFields: S
|
|
974
977
|
} = r, p = s.toString().replace("step", "");
|
|
975
|
-
|
|
978
|
+
w(
|
|
976
979
|
n,
|
|
977
980
|
`Missing fields for step ${p} (${String(s)})`,
|
|
978
981
|
TypeError
|
|
979
|
-
),
|
|
982
|
+
), w(
|
|
980
983
|
typeof n == "object",
|
|
981
984
|
"Fields must be an object",
|
|
982
985
|
TypeError
|
|
983
|
-
),
|
|
986
|
+
), w(
|
|
984
987
|
Object.keys(n).length > 0,
|
|
985
988
|
`The fields config for step ${p} (${String(
|
|
986
989
|
s
|
|
987
990
|
)}) is empty. Please add a field`
|
|
988
|
-
),
|
|
991
|
+
), w(
|
|
989
992
|
typeof n == "object",
|
|
990
993
|
`The "fields" property must be an object. Was ${typeof n}`
|
|
991
994
|
);
|
|
@@ -1005,7 +1008,7 @@ function Oe(o) {
|
|
|
1005
1008
|
}
|
|
1006
1009
|
return e;
|
|
1007
1010
|
}
|
|
1008
|
-
let
|
|
1011
|
+
let ne = class extends Ee {
|
|
1009
1012
|
/**
|
|
1010
1013
|
* The original config before any validation or transformations have been applied.
|
|
1011
1014
|
*/
|
|
@@ -1027,11 +1030,12 @@ let re = class extends Ee {
|
|
|
1027
1030
|
const { steps: t, nameTransformCasing: r, storage: s } = e;
|
|
1028
1031
|
this.defaultNameTransformationCasing = be(
|
|
1029
1032
|
r
|
|
1030
|
-
), this.original = t, this.value =
|
|
1033
|
+
), this.original = t, this.value = _e(this.original), this.storage = new ve({
|
|
1031
1034
|
data: this.value,
|
|
1032
|
-
key: s?.key ??
|
|
1033
|
-
store: s?.store
|
|
1034
|
-
|
|
1035
|
+
key: s?.key ?? re,
|
|
1036
|
+
store: s?.store,
|
|
1037
|
+
throwWhenUndefined: s?.throwWhenUndefined ?? !1
|
|
1038
|
+
}), this.#e = new ee({
|
|
1035
1039
|
getValue: () => this.value,
|
|
1036
1040
|
setValue: (n) => this.handlePostUpdate(n)
|
|
1037
1041
|
}), this.value = this.#e.enrichValues(this.value), this.stepNumbers = Object.keys(this.value).map(
|
|
@@ -1041,7 +1045,7 @@ let re = class extends Ee {
|
|
|
1041
1045
|
last: this.lastStep.step,
|
|
1042
1046
|
value: this.stepNumbers,
|
|
1043
1047
|
as: (n) => {
|
|
1044
|
-
if (
|
|
1048
|
+
if (w(
|
|
1045
1049
|
typeof n == "string",
|
|
1046
1050
|
`The type of the target transformation type must be a string, was ${typeof n}`
|
|
1047
1051
|
), n === "string")
|
|
@@ -1134,7 +1138,7 @@ let re = class extends Ee {
|
|
|
1134
1138
|
if (n === null || typeof n != "object" || !ue(n, {
|
|
1135
1139
|
defaultValue: (u) => u !== "undefined" && u !== null,
|
|
1136
1140
|
label: (u) => typeof u == "string" || typeof u == "boolean" && !u,
|
|
1137
|
-
nameTransformCasing:
|
|
1141
|
+
nameTransformCasing: Y,
|
|
1138
1142
|
type: Ve
|
|
1139
1143
|
}))
|
|
1140
1144
|
return !1;
|
|
@@ -1144,7 +1148,7 @@ let re = class extends Ee {
|
|
|
1144
1148
|
createHelperFn: (r) => typeof r == "function",
|
|
1145
1149
|
// update: (v): v is GetCurrentStep<resolvedStep, stepNumbers>['update'] =>
|
|
1146
1150
|
// typeof v === 'function',
|
|
1147
|
-
nameTransformCasing:
|
|
1151
|
+
nameTransformCasing: Y,
|
|
1148
1152
|
...t?.optionalKeysToCheck
|
|
1149
1153
|
});
|
|
1150
1154
|
}
|
|
@@ -1158,13 +1162,14 @@ let re = class extends Ee {
|
|
|
1158
1162
|
const { steps: t, nameTransformCasing: r, storage: s } = e;
|
|
1159
1163
|
this.defaultNameTransformationCasing = be(
|
|
1160
1164
|
r
|
|
1161
|
-
), this.stepSchema = new
|
|
1165
|
+
), this.stepSchema = new ne({
|
|
1162
1166
|
steps: t,
|
|
1163
1167
|
nameTransformCasing: this.defaultNameTransformationCasing
|
|
1164
1168
|
}), this.storage = new ve({
|
|
1165
|
-
key: s?.key ??
|
|
1169
|
+
key: s?.key ?? re,
|
|
1166
1170
|
data: this.stepSchema.value,
|
|
1167
|
-
store: s?.store
|
|
1171
|
+
store: s?.store,
|
|
1172
|
+
throwWhenUndefined: s?.throwWhenUndefined ?? !1
|
|
1168
1173
|
}), this.stepSchema.subscribe(() => {
|
|
1169
1174
|
this.notify();
|
|
1170
1175
|
});
|
|
@@ -1224,21 +1229,21 @@ var L;
|
|
|
1224
1229
|
}
|
|
1225
1230
|
o.isFormAvailable = e;
|
|
1226
1231
|
function t(r) {
|
|
1227
|
-
return (s) => /* @__PURE__ */
|
|
1232
|
+
return (s) => /* @__PURE__ */ Ae("form", { id: r, ...s });
|
|
1228
1233
|
}
|
|
1229
1234
|
o.createDefaultForm = t;
|
|
1230
1235
|
})(L || (L = {}));
|
|
1231
|
-
var
|
|
1236
|
+
var X;
|
|
1232
1237
|
((o) => {
|
|
1233
1238
|
o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
|
|
1234
|
-
})(
|
|
1239
|
+
})(X || (X = {}));
|
|
1235
1240
|
function De(o, e) {
|
|
1236
|
-
|
|
1241
|
+
w(
|
|
1237
1242
|
e in o,
|
|
1238
1243
|
`The target step ${e} is not a valid step key`
|
|
1239
1244
|
);
|
|
1240
1245
|
const t = o[e];
|
|
1241
|
-
|
|
1246
|
+
w("fields" in t, `No "fields" were found for ${e}`);
|
|
1242
1247
|
let r = {};
|
|
1243
1248
|
for (const [s, n] of Object.entries(
|
|
1244
1249
|
t.fields
|
|
@@ -1249,13 +1254,13 @@ function De(o, e) {
|
|
|
1249
1254
|
};
|
|
1250
1255
|
return r;
|
|
1251
1256
|
}
|
|
1252
|
-
class Me extends
|
|
1257
|
+
class Me extends ne {
|
|
1253
1258
|
// @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
|
|
1254
1259
|
value;
|
|
1255
1260
|
#e;
|
|
1256
1261
|
constructor(e) {
|
|
1257
1262
|
const { form: t, ...r } = e;
|
|
1258
|
-
super(r), this.value =
|
|
1263
|
+
super(r), this.value = _e(this.original), this.#e = new ee({
|
|
1259
1264
|
getValue: () => this.value,
|
|
1260
1265
|
setValue: (s) => this.handlePostUpdate(s)
|
|
1261
1266
|
}), this.sync(), this.value = this.#e.enrichValues(this.value, (s) => {
|
|
@@ -1283,16 +1288,16 @@ class Me extends re {
|
|
|
1283
1288
|
createStepSpecificComponentImpl(e, t, r, s = {}) {
|
|
1284
1289
|
return (n) => ((a) => {
|
|
1285
1290
|
const u = {};
|
|
1286
|
-
for (const [E,
|
|
1287
|
-
if (typeof
|
|
1291
|
+
for (const [E, O] of Object.entries(s))
|
|
1292
|
+
if (typeof O == "function")
|
|
1288
1293
|
try {
|
|
1289
|
-
const
|
|
1290
|
-
u[E] =
|
|
1294
|
+
const A = O();
|
|
1295
|
+
u[E] = A, typeof console < "u" && console.debug && console.debug(
|
|
1291
1296
|
`[multi-step-form] Hook "${E}" called successfully`,
|
|
1292
|
-
{ result:
|
|
1297
|
+
{ result: A === void 0 ? "defined" : "undefined" }
|
|
1293
1298
|
);
|
|
1294
|
-
} catch (
|
|
1295
|
-
const i =
|
|
1299
|
+
} catch (A) {
|
|
1300
|
+
const i = A instanceof Error ? A.message : String(A);
|
|
1296
1301
|
throw new Error(
|
|
1297
1302
|
`[multi-step-form] Error calling hook "${E}" in useFormInstance.render: ${i}
|
|
1298
1303
|
|
|
@@ -1302,31 +1307,31 @@ This usually means:
|
|
|
1302
1307
|
3. There's an error in your hook implementation
|
|
1303
1308
|
|
|
1304
1309
|
Original error: ${i}`,
|
|
1305
|
-
{ cause:
|
|
1310
|
+
{ cause: A }
|
|
1306
1311
|
);
|
|
1307
1312
|
}
|
|
1308
1313
|
else
|
|
1309
|
-
u[E] =
|
|
1314
|
+
u[E] = O;
|
|
1310
1315
|
const { defaultId: b, form: S } = t, { ctx: p } = r, [f] = e;
|
|
1311
|
-
|
|
1316
|
+
w(
|
|
1312
1317
|
this.steps.isValidStepKey(f),
|
|
1313
1318
|
`[createComponent]: the target step ${f} 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.`
|
|
1314
1319
|
);
|
|
1315
1320
|
const v = Number.parseInt(f.replace("step", ""));
|
|
1316
|
-
|
|
1321
|
+
w(
|
|
1317
1322
|
!Number.isNaN(v),
|
|
1318
1323
|
`[${f}:"createComponent"]: an error occurred while extracting the number`
|
|
1319
1324
|
);
|
|
1320
1325
|
const y = this.value[f];
|
|
1321
|
-
|
|
1326
|
+
w(
|
|
1322
1327
|
"fields" in y,
|
|
1323
1328
|
`[${f}:createComponent]: unable to find the "fields" for the current step`
|
|
1324
|
-
),
|
|
1329
|
+
), w(
|
|
1325
1330
|
typeof y.fields == "object",
|
|
1326
1331
|
`[${f}:createComponent]: the "fields" property must be an object, was ${typeof y.fields}`
|
|
1327
1332
|
);
|
|
1328
1333
|
const m = Ie((E) => {
|
|
1329
|
-
|
|
1334
|
+
w(typeof E == "string", () => {
|
|
1330
1335
|
const h = new Intl.ListFormat("en", {
|
|
1331
1336
|
style: "long",
|
|
1332
1337
|
type: "disjunction"
|
|
@@ -1334,14 +1339,14 @@ Original error: ${i}`,
|
|
|
1334
1339
|
return `[${f}:Field]: the "name" prop must be a string and a valid field for ${f}. Available fields include ${h.format(
|
|
1335
1340
|
Object.keys(y.fields)
|
|
1336
1341
|
)}`;
|
|
1337
|
-
}),
|
|
1342
|
+
}), w(
|
|
1338
1343
|
E in y.fields,
|
|
1339
1344
|
`[${f}:Field]: the field "${E}" doesn't exist for the current step`
|
|
1340
|
-
),
|
|
1345
|
+
), w(
|
|
1341
1346
|
"update" in y,
|
|
1342
1347
|
`[${f}:Field]: No "update" function was found`
|
|
1343
1348
|
);
|
|
1344
|
-
const { fields:
|
|
1349
|
+
const { fields: O, update: A } = y, { defaultValue: i, label: l, nameTransformCasing: d, type: c } = O[E];
|
|
1345
1350
|
return {
|
|
1346
1351
|
defaultValue: i,
|
|
1347
1352
|
label: l,
|
|
@@ -1350,7 +1355,7 @@ Original error: ${i}`,
|
|
|
1350
1355
|
name: E,
|
|
1351
1356
|
onInputChange: (h) => (
|
|
1352
1357
|
// TODO remove type assertions
|
|
1353
|
-
|
|
1358
|
+
A({
|
|
1354
1359
|
fields: [`fields.${E}.defaultValue`],
|
|
1355
1360
|
updater: h
|
|
1356
1361
|
})
|
|
@@ -1366,14 +1371,14 @@ Original error: ${i}`,
|
|
|
1366
1371
|
if (S) {
|
|
1367
1372
|
const {
|
|
1368
1373
|
alias: E = L.DEFAULT_FORM_ALIAS,
|
|
1369
|
-
...
|
|
1370
|
-
} = S,
|
|
1374
|
+
...O
|
|
1375
|
+
} = S, A = O.enabledForSteps ?? "all";
|
|
1371
1376
|
return L.isFormAvailable(
|
|
1372
1377
|
e,
|
|
1373
|
-
|
|
1378
|
+
A
|
|
1374
1379
|
) && (g = {
|
|
1375
1380
|
...g,
|
|
1376
|
-
[E]: this.createFormComponent(
|
|
1381
|
+
[E]: this.createFormComponent(O, b)
|
|
1377
1382
|
}), n(g, a);
|
|
1378
1383
|
}
|
|
1379
1384
|
return n(
|
|
@@ -1394,7 +1399,7 @@ Original error: ${i}`,
|
|
|
1394
1399
|
return m ? { ctx: { ...r, ...m } } : { ctx: r };
|
|
1395
1400
|
}
|
|
1396
1401
|
function y() {
|
|
1397
|
-
return
|
|
1402
|
+
return w(
|
|
1398
1403
|
typeof p == "function",
|
|
1399
1404
|
"The first argument must be a function"
|
|
1400
1405
|
), s(
|
|
@@ -1404,48 +1409,48 @@ Original error: ${i}`,
|
|
|
1404
1409
|
)(p);
|
|
1405
1410
|
}
|
|
1406
1411
|
if (typeof p == "object") {
|
|
1407
|
-
const { useFormInstance: m, ctxData: g, debug: E } = p,
|
|
1412
|
+
const { useFormInstance: m, ctxData: g, debug: E } = p, O = new Q({
|
|
1408
1413
|
debug: E,
|
|
1409
1414
|
prefix(l) {
|
|
1410
1415
|
return `${l}-${u}-createComponent`;
|
|
1411
1416
|
}
|
|
1412
1417
|
});
|
|
1413
|
-
|
|
1414
|
-
const { [u]:
|
|
1415
|
-
if (
|
|
1418
|
+
O.info("First argument is an object");
|
|
1419
|
+
const { [u]: A, ...i } = a;
|
|
1420
|
+
if (w(
|
|
1416
1421
|
typeof f == "function",
|
|
1417
1422
|
"The second argument must be a function"
|
|
1418
1423
|
), m) {
|
|
1419
1424
|
const {
|
|
1420
1425
|
render: l,
|
|
1421
|
-
alias: d =
|
|
1422
|
-
} = m, [c] = e, h = n(c),
|
|
1426
|
+
alias: d = X.DEFAULT_FORM_INSTANCE_ALIAS
|
|
1427
|
+
} = m, [c] = e, h = n(c), _ = g ? {
|
|
1423
1428
|
...r,
|
|
1424
1429
|
...g({ ctx: i })
|
|
1425
|
-
} : r, $ = { ctx:
|
|
1430
|
+
} : r, $ = { ctx: _, defaultValues: h };
|
|
1426
1431
|
return s(
|
|
1427
1432
|
e,
|
|
1428
1433
|
t,
|
|
1429
|
-
|
|
1434
|
+
_,
|
|
1430
1435
|
{
|
|
1431
1436
|
[d]: () => l($)
|
|
1432
1437
|
}
|
|
1433
1438
|
)(f);
|
|
1434
1439
|
}
|
|
1435
1440
|
if (g) {
|
|
1436
|
-
|
|
1441
|
+
O.info('Option "ctxData" is defined'), w(
|
|
1437
1442
|
typeof g == "function",
|
|
1438
1443
|
'Option "ctxData" must be a function'
|
|
1439
1444
|
);
|
|
1440
1445
|
const l = g({ ctx: i });
|
|
1441
|
-
|
|
1446
|
+
O.info(
|
|
1442
1447
|
`Addition context is: ${JSON.stringify(l, null, 2)}`
|
|
1443
1448
|
);
|
|
1444
1449
|
const d = {
|
|
1445
1450
|
...r,
|
|
1446
1451
|
...l
|
|
1447
1452
|
};
|
|
1448
|
-
return
|
|
1453
|
+
return O.info(
|
|
1449
1454
|
`Resolved context is: ${JSON.stringify(d, null, 2)}`
|
|
1450
1455
|
), s(e, t, {
|
|
1451
1456
|
ctx: d,
|
|
@@ -1480,7 +1485,7 @@ class Ue extends Ne {
|
|
|
1480
1485
|
stepSchema;
|
|
1481
1486
|
#e;
|
|
1482
1487
|
constructor(e) {
|
|
1483
|
-
const { nameTransformCasing: t =
|
|
1488
|
+
const { nameTransformCasing: t = te, storage: r, ...s } = e;
|
|
1484
1489
|
super({
|
|
1485
1490
|
nameTransformCasing: t,
|
|
1486
1491
|
storage: r,
|
|
@@ -1488,7 +1493,7 @@ class Ue extends Ne {
|
|
|
1488
1493
|
}), this.stepSchema = new Me({
|
|
1489
1494
|
nameTransformCasing: t,
|
|
1490
1495
|
...s
|
|
1491
|
-
}), this.#e = new
|
|
1496
|
+
}), this.#e = new ee({
|
|
1492
1497
|
getValue: () => this.stepSchema.value,
|
|
1493
1498
|
setValue: (n) => {
|
|
1494
1499
|
this.stepSchema.value = { ...n }, this.storage.add(n), this.notify();
|
|
@@ -1512,7 +1517,7 @@ class Ue extends Ne {
|
|
|
1512
1517
|
function Ye(o) {
|
|
1513
1518
|
return new Ue(o);
|
|
1514
1519
|
}
|
|
1515
|
-
var I = { exports: {} },
|
|
1520
|
+
var I = { exports: {} }, B = {}, D = { exports: {} }, J = {};
|
|
1516
1521
|
/**
|
|
1517
1522
|
* @license React
|
|
1518
1523
|
* use-sync-external-store-shim.production.js
|
|
@@ -1524,7 +1529,7 @@ var I = { exports: {} }, W = {}, D = { exports: {} }, B = {};
|
|
|
1524
1529
|
*/
|
|
1525
1530
|
var le;
|
|
1526
1531
|
function Re() {
|
|
1527
|
-
if (le) return
|
|
1532
|
+
if (le) return J;
|
|
1528
1533
|
le = 1;
|
|
1529
1534
|
var o = G;
|
|
1530
1535
|
function e(f, v) {
|
|
@@ -1561,9 +1566,9 @@ function Re() {
|
|
|
1561
1566
|
return v();
|
|
1562
1567
|
}
|
|
1563
1568
|
var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? S : u;
|
|
1564
|
-
return
|
|
1569
|
+
return J.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : p, J;
|
|
1565
1570
|
}
|
|
1566
|
-
var
|
|
1571
|
+
var z = {};
|
|
1567
1572
|
/**
|
|
1568
1573
|
* @license React
|
|
1569
1574
|
* use-sync-external-store-shim.development.js
|
|
@@ -1593,16 +1598,16 @@ function Ke() {
|
|
|
1593
1598
|
E = a({
|
|
1594
1599
|
inst: { value: g, getSnapshot: m }
|
|
1595
1600
|
});
|
|
1596
|
-
var
|
|
1601
|
+
var O = E[0].inst, A = E[1];
|
|
1597
1602
|
return b(
|
|
1598
1603
|
function() {
|
|
1599
|
-
|
|
1604
|
+
O.value = g, O.getSnapshot = m, t(O) && A({ inst: O });
|
|
1600
1605
|
},
|
|
1601
1606
|
[y, g, m]
|
|
1602
1607
|
), u(
|
|
1603
1608
|
function() {
|
|
1604
|
-
return t(
|
|
1605
|
-
t(
|
|
1609
|
+
return t(O) && A({ inst: O }), y(function() {
|
|
1610
|
+
t(O) && A({ inst: O });
|
|
1606
1611
|
});
|
|
1607
1612
|
},
|
|
1608
1613
|
[y]
|
|
@@ -1623,11 +1628,11 @@ function Ke() {
|
|
|
1623
1628
|
}
|
|
1624
1629
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1625
1630
|
var s = G, n = typeof Object.is == "function" ? Object.is : o, a = s.useState, u = s.useEffect, b = s.useLayoutEffect, S = s.useDebugValue, p = !1, f = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
1626
|
-
|
|
1627
|
-
})()),
|
|
1631
|
+
z.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1632
|
+
})()), z;
|
|
1628
1633
|
}
|
|
1629
1634
|
var pe;
|
|
1630
|
-
function
|
|
1635
|
+
function Oe() {
|
|
1631
1636
|
return pe || (pe = 1, process.env.NODE_ENV === "production" ? D.exports = Re() : D.exports = Ke()), D.exports;
|
|
1632
1637
|
}
|
|
1633
1638
|
/**
|
|
@@ -1641,14 +1646,14 @@ function we() {
|
|
|
1641
1646
|
*/
|
|
1642
1647
|
var de;
|
|
1643
1648
|
function Ge() {
|
|
1644
|
-
if (de) return
|
|
1649
|
+
if (de) return B;
|
|
1645
1650
|
de = 1;
|
|
1646
|
-
var o = G, e =
|
|
1651
|
+
var o = G, e = Oe();
|
|
1647
1652
|
function t(S, p) {
|
|
1648
1653
|
return S === p && (S !== 0 || 1 / S === 1 / p) || S !== S && p !== p;
|
|
1649
1654
|
}
|
|
1650
1655
|
var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect, u = o.useMemo, b = o.useDebugValue;
|
|
1651
|
-
return
|
|
1656
|
+
return B.useSyncExternalStoreWithSelector = function(S, p, f, v, y) {
|
|
1652
1657
|
var m = n(null);
|
|
1653
1658
|
if (m.current === null) {
|
|
1654
1659
|
var g = { hasValue: !1, value: null };
|
|
@@ -1656,9 +1661,9 @@ function Ge() {
|
|
|
1656
1661
|
} else g = m.current;
|
|
1657
1662
|
m = u(
|
|
1658
1663
|
function() {
|
|
1659
|
-
function
|
|
1660
|
-
if (!
|
|
1661
|
-
if (
|
|
1664
|
+
function O(c) {
|
|
1665
|
+
if (!A) {
|
|
1666
|
+
if (A = !0, i = c, c = v(c), y !== void 0 && g.hasValue) {
|
|
1662
1667
|
var h = g.value;
|
|
1663
1668
|
if (y(h, c))
|
|
1664
1669
|
return l = h;
|
|
@@ -1666,16 +1671,16 @@ function Ge() {
|
|
|
1666
1671
|
return l = c;
|
|
1667
1672
|
}
|
|
1668
1673
|
if (h = l, r(i, c)) return h;
|
|
1669
|
-
var
|
|
1670
|
-
return y !== void 0 && y(h,
|
|
1674
|
+
var _ = v(c);
|
|
1675
|
+
return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
|
|
1671
1676
|
}
|
|
1672
|
-
var
|
|
1677
|
+
var A = !1, i, l, d = f === void 0 ? null : f;
|
|
1673
1678
|
return [
|
|
1674
1679
|
function() {
|
|
1675
|
-
return
|
|
1680
|
+
return O(p());
|
|
1676
1681
|
},
|
|
1677
1682
|
d === null ? void 0 : function() {
|
|
1678
|
-
return
|
|
1683
|
+
return O(d());
|
|
1679
1684
|
}
|
|
1680
1685
|
];
|
|
1681
1686
|
},
|
|
@@ -1688,9 +1693,9 @@ function Ge() {
|
|
|
1688
1693
|
},
|
|
1689
1694
|
[E]
|
|
1690
1695
|
), b(E), E;
|
|
1691
|
-
},
|
|
1696
|
+
}, B;
|
|
1692
1697
|
}
|
|
1693
|
-
var
|
|
1698
|
+
var q = {};
|
|
1694
1699
|
/**
|
|
1695
1700
|
* @license React
|
|
1696
1701
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -1707,8 +1712,8 @@ function Pe() {
|
|
|
1707
1712
|
return S === p && (S !== 0 || 1 / S === 1 / p) || S !== S && p !== p;
|
|
1708
1713
|
}
|
|
1709
1714
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1710
|
-
var e = G, t =
|
|
1711
|
-
|
|
1715
|
+
var e = G, t = Oe(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, a = e.useEffect, u = e.useMemo, b = e.useDebugValue;
|
|
1716
|
+
q.useSyncExternalStoreWithSelector = function(S, p, f, v, y) {
|
|
1712
1717
|
var m = n(null);
|
|
1713
1718
|
if (m.current === null) {
|
|
1714
1719
|
var g = { hasValue: !1, value: null };
|
|
@@ -1716,9 +1721,9 @@ function Pe() {
|
|
|
1716
1721
|
} else g = m.current;
|
|
1717
1722
|
m = u(
|
|
1718
1723
|
function() {
|
|
1719
|
-
function
|
|
1720
|
-
if (!
|
|
1721
|
-
if (
|
|
1724
|
+
function O(c) {
|
|
1725
|
+
if (!A) {
|
|
1726
|
+
if (A = !0, i = c, c = v(c), y !== void 0 && g.hasValue) {
|
|
1722
1727
|
var h = g.value;
|
|
1723
1728
|
if (y(h, c))
|
|
1724
1729
|
return l = h;
|
|
@@ -1727,16 +1732,16 @@ function Pe() {
|
|
|
1727
1732
|
}
|
|
1728
1733
|
if (h = l, r(i, c))
|
|
1729
1734
|
return h;
|
|
1730
|
-
var
|
|
1731
|
-
return y !== void 0 && y(h,
|
|
1735
|
+
var _ = v(c);
|
|
1736
|
+
return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
|
|
1732
1737
|
}
|
|
1733
|
-
var
|
|
1738
|
+
var A = !1, i, l, d = f === void 0 ? null : f;
|
|
1734
1739
|
return [
|
|
1735
1740
|
function() {
|
|
1736
|
-
return
|
|
1741
|
+
return O(p());
|
|
1737
1742
|
},
|
|
1738
1743
|
d === null ? void 0 : function() {
|
|
1739
|
-
return
|
|
1744
|
+
return O(d());
|
|
1740
1745
|
}
|
|
1741
1746
|
];
|
|
1742
1747
|
},
|
|
@@ -1750,15 +1755,15 @@ function Pe() {
|
|
|
1750
1755
|
[E]
|
|
1751
1756
|
), b(E), E;
|
|
1752
1757
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1753
|
-
})()),
|
|
1758
|
+
})()), q;
|
|
1754
1759
|
}
|
|
1755
1760
|
var me;
|
|
1756
1761
|
function He() {
|
|
1757
1762
|
return me || (me = 1, process.env.NODE_ENV === "production" ? I.exports = Ge() : I.exports = Pe()), I.exports;
|
|
1758
1763
|
}
|
|
1759
1764
|
var We = He();
|
|
1760
|
-
function
|
|
1761
|
-
|
|
1765
|
+
function Z(o, e) {
|
|
1766
|
+
w(
|
|
1762
1767
|
typeof e == "string",
|
|
1763
1768
|
`The target step must be a string, was ${typeof e}`
|
|
1764
1769
|
);
|
|
@@ -1766,12 +1771,12 @@ function X(o, e) {
|
|
|
1766
1771
|
type: "disjunction",
|
|
1767
1772
|
style: "long"
|
|
1768
1773
|
}).format(t("array.string.untyped"));
|
|
1769
|
-
|
|
1770
|
-
|
|
1774
|
+
w(
|
|
1775
|
+
we.test(e),
|
|
1771
1776
|
`The target step must match the following format: "step{number}". Available steps are ${n}`
|
|
1772
1777
|
);
|
|
1773
1778
|
const a = Number.parseInt(e.replace("step", ""));
|
|
1774
|
-
return
|
|
1779
|
+
return w(
|
|
1775
1780
|
r(a),
|
|
1776
1781
|
`The step number "${a}" is not a valid step number. Valid step numbers include ${n}`,
|
|
1777
1782
|
TypeError
|
|
@@ -1785,7 +1790,7 @@ function $e(o) {
|
|
|
1785
1790
|
() => o.getSnapshot(),
|
|
1786
1791
|
(r) => {
|
|
1787
1792
|
if (typeof t == "object") {
|
|
1788
|
-
const s =
|
|
1793
|
+
const s = Z(
|
|
1789
1794
|
r,
|
|
1790
1795
|
t.targetStep
|
|
1791
1796
|
);
|
|
@@ -1811,14 +1816,14 @@ function Ze(o) {
|
|
|
1811
1816
|
function t(u) {
|
|
1812
1817
|
const { targetStep: b, notFoundMessage: S, isDataGuaranteed: p } = u, f = e({
|
|
1813
1818
|
targetStep: b
|
|
1814
|
-
}), v = S ? a({ targetStep: b }, S) : (y) => /* @__PURE__ */
|
|
1819
|
+
}), v = S ? a({ targetStep: b }, S) : (y) => /* @__PURE__ */ se("div", { ...y, children: [
|
|
1815
1820
|
"No data found for step ",
|
|
1816
1821
|
String(b)
|
|
1817
1822
|
] });
|
|
1818
1823
|
return p ? {
|
|
1819
1824
|
data: f,
|
|
1820
1825
|
NoCurrentData: v
|
|
1821
|
-
} :
|
|
1826
|
+
} : ne.hasData(f) ? {
|
|
1822
1827
|
data: f,
|
|
1823
1828
|
hasData: !0,
|
|
1824
1829
|
NoCurrentData: v
|
|
@@ -1836,10 +1841,10 @@ function Ze(o) {
|
|
|
1836
1841
|
maxProgressValue: p = 100,
|
|
1837
1842
|
totalSteps: f = b,
|
|
1838
1843
|
progressTextTransformer: v
|
|
1839
|
-
} = u, y =
|
|
1844
|
+
} = u, y = Z(o, S), m = y / f * p, g = v ? n(
|
|
1840
1845
|
{ targetStep: S, maxProgressValue: p, totalSteps: f },
|
|
1841
1846
|
v
|
|
1842
|
-
) : (E) => /* @__PURE__ */
|
|
1847
|
+
) : (E) => /* @__PURE__ */ se("div", { ...E, children: [
|
|
1843
1848
|
"Step ",
|
|
1844
1849
|
y,
|
|
1845
1850
|
"/",
|
|
@@ -1860,7 +1865,7 @@ function Ze(o) {
|
|
|
1860
1865
|
return ye({ targetStep: p, maxProgressValue: f, totalSteps: v })(b);
|
|
1861
1866
|
}
|
|
1862
1867
|
function a(u, b) {
|
|
1863
|
-
return
|
|
1868
|
+
return Z(o, u.targetStep), ye(u)(b);
|
|
1864
1869
|
}
|
|
1865
1870
|
return {
|
|
1866
1871
|
// MultiStepFormContext: Context,
|
|
@@ -1875,7 +1880,7 @@ function Ze(o) {
|
|
|
1875
1880
|
export {
|
|
1876
1881
|
Ue as MultiStepFormSchema,
|
|
1877
1882
|
Me as MultiStepFormStepSchema,
|
|
1878
|
-
|
|
1883
|
+
X as StepSpecificComponent,
|
|
1879
1884
|
De as createDefaultValues,
|
|
1880
1885
|
Ze as createMultiStepFormContext,
|
|
1881
1886
|
Ye as createMultiStepFormSchema,
|