@jfdevelops/react-multi-step-form 1.0.0-alpha.6 → 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 +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +158 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
1
|
+
import { jsx as Ae, jsxs as se } from "react/jsx-runtime";
|
|
2
|
+
import G from "react";
|
|
3
|
+
function U(o, e, t) {
|
|
4
4
|
const r = [], s = new Set(o), n = t ? t.format(o.map((u) => `${u}`)) : `[${o.join(", ")}]`;
|
|
5
5
|
for (let u = 0; u < e.length; u++) {
|
|
6
6
|
const b = e[u];
|
|
@@ -17,19 +17,19 @@ 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
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
|
-
function
|
|
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
35
|
return w(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
|
|
@@ -40,9 +40,9 @@ 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
|
-
const s =
|
|
45
|
+
const s = M(r), { data: n } = K(o)({
|
|
46
46
|
step: s
|
|
47
47
|
});
|
|
48
48
|
for (const [a, u] of Object.entries(n))
|
|
@@ -63,14 +63,14 @@ function N(o, e) {
|
|
|
63
63
|
n = {
|
|
64
64
|
...n,
|
|
65
65
|
[a]: K(o)({
|
|
66
|
-
step:
|
|
66
|
+
step: M(a)
|
|
67
67
|
})
|
|
68
68
|
};
|
|
69
69
|
return Object.fromEntries(
|
|
70
70
|
r.map((a) => [
|
|
71
71
|
a,
|
|
72
72
|
K(o)({
|
|
73
|
-
step:
|
|
73
|
+
step: M(a)
|
|
74
74
|
})
|
|
75
75
|
])
|
|
76
76
|
);
|
|
@@ -79,9 +79,9 @@ function N(o, e) {
|
|
|
79
79
|
return w(
|
|
80
80
|
e.every((n) => r.includes(n)),
|
|
81
81
|
() => {
|
|
82
|
-
const n =
|
|
82
|
+
const n = U(
|
|
83
83
|
e,
|
|
84
|
-
r.map((a) =>
|
|
84
|
+
r.map((a) => M(a)),
|
|
85
85
|
t
|
|
86
86
|
);
|
|
87
87
|
return n.status === "error" ? `${s()}. See errors:
|
|
@@ -89,7 +89,7 @@ function N(o, e) {
|
|
|
89
89
|
n.errors
|
|
90
90
|
)}` : s();
|
|
91
91
|
}
|
|
92
|
-
),
|
|
92
|
+
), ie(
|
|
93
93
|
o,
|
|
94
94
|
e
|
|
95
95
|
);
|
|
@@ -98,7 +98,7 @@ function N(o, e) {
|
|
|
98
98
|
return w(
|
|
99
99
|
n.every((a) => r.includes(a)),
|
|
100
100
|
() => {
|
|
101
|
-
const a =
|
|
101
|
+
const a = U(
|
|
102
102
|
n,
|
|
103
103
|
r,
|
|
104
104
|
t
|
|
@@ -108,30 +108,30 @@ 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
|
-
const
|
|
122
|
-
class
|
|
121
|
+
const H = "MultiStepFormSchema";
|
|
122
|
+
class Q {
|
|
123
123
|
debug;
|
|
124
|
-
prefix =
|
|
124
|
+
prefix = H;
|
|
125
125
|
includeTimestamp = !1;
|
|
126
126
|
throwOnError = !1;
|
|
127
127
|
constructor(e) {
|
|
128
128
|
if (this.debug = e?.debug ?? !1, this.debug && e?.debug) {
|
|
129
129
|
const {
|
|
130
130
|
includeTimestamp: t = !1,
|
|
131
|
-
prefix: r =
|
|
131
|
+
prefix: r = H,
|
|
132
132
|
throwOnError: s = !1
|
|
133
133
|
} = e;
|
|
134
|
-
this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(
|
|
134
|
+
this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(H), this.throwOnError = s;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
wrapValue(e, t) {
|
|
@@ -228,10 +228,10 @@ var C;
|
|
|
228
228
|
return;
|
|
229
229
|
const _ = Object.keys(c);
|
|
230
230
|
for (const $ of _) {
|
|
231
|
-
const
|
|
232
|
-
l.push(
|
|
233
|
-
const
|
|
234
|
-
|
|
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;
|
|
@@ -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,13 +347,13 @@ 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
|
}
|
|
@@ -430,24 +430,24 @@ var C;
|
|
|
430
430
|
function O(i, l, d) {
|
|
431
431
|
const c = l.split(".");
|
|
432
432
|
function h(_, $) {
|
|
433
|
-
const
|
|
433
|
+
const T = c[$], j = Array.isArray(_) ? [..._] : { ..._ };
|
|
434
434
|
if ($ === c.length - 1) {
|
|
435
|
-
let
|
|
436
|
-
return
|
|
437
|
-
...
|
|
438
|
-
[
|
|
439
|
-
},
|
|
435
|
+
let P = _ && typeof _ == "object" ? j : {};
|
|
436
|
+
return P = {
|
|
437
|
+
...P,
|
|
438
|
+
[T]: d
|
|
439
|
+
}, P;
|
|
440
440
|
}
|
|
441
|
-
const k = _ && typeof _ == "object" ? _[
|
|
442
|
-
let V = _ && typeof _ == "object" ?
|
|
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;
|
|
@@ -461,7 +461,7 @@ var C;
|
|
|
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,7 +490,7 @@ 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
|
});
|
|
@@ -522,7 +522,7 @@ 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
|
});
|
|
@@ -543,16 +543,16 @@ class Q {
|
|
|
543
543
|
i
|
|
544
544
|
)}`;
|
|
545
545
|
});
|
|
546
|
-
const E = C.createDeep(this.value), { mismatches: O, ok:
|
|
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
551
|
w(
|
|
552
|
-
|
|
552
|
+
A && O.length === 0,
|
|
553
553
|
`[update]: found value mismatches in ${C.printMismatches({
|
|
554
554
|
mismatches: O,
|
|
555
|
-
ok:
|
|
555
|
+
ok: A
|
|
556
556
|
})}`
|
|
557
557
|
), u.info("The entire step will be updated"), p = {
|
|
558
558
|
...p,
|
|
@@ -562,7 +562,7 @@ class Q {
|
|
|
562
562
|
}
|
|
563
563
|
const y = C.createDeep(b);
|
|
564
564
|
if (Array.isArray(n)) {
|
|
565
|
-
const m =
|
|
565
|
+
const m = U(y, n);
|
|
566
566
|
w(
|
|
567
567
|
m.status === "success",
|
|
568
568
|
`[update]: Found errors with the provided fields
|
|
@@ -591,7 +591,7 @@ ${m.status === "error" ? R(m.errors) : ""}`
|
|
|
591
591
|
return;
|
|
592
592
|
}
|
|
593
593
|
if (typeof n == "object" && Object.keys(n).length > 0) {
|
|
594
|
-
const m = C.createDeep(n), g =
|
|
594
|
+
const m = C.createDeep(n), g = U(
|
|
595
595
|
y,
|
|
596
596
|
m
|
|
597
597
|
);
|
|
@@ -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
|
|
@@ -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,26 +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
815
|
throwWhenUndefined;
|
|
816
816
|
constructor(e) {
|
|
817
817
|
const { key: t, data: r, store: s, throwWhenUndefined: n = !1 } = e;
|
|
818
|
-
this.log = new
|
|
819
|
-
prefix:
|
|
820
|
-
}), this.key = t, this.data = r, this.throwWhenUndefined = n, s ? (this.store = s, this.
|
|
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));
|
|
821
821
|
}
|
|
822
822
|
throwOnEmptyStore() {
|
|
823
|
-
this.throwWhenUndefined && w(this.store, () => this.
|
|
823
|
+
this.throwWhenUndefined && w(this.store, () => this.shouldRunActions ? W : "No storage available");
|
|
824
824
|
}
|
|
825
825
|
resolveValue(e) {
|
|
826
826
|
if (typeof e == "object")
|
|
@@ -836,16 +836,18 @@ class ve {
|
|
|
836
836
|
return this.store.getItem(this.key) !== null;
|
|
837
837
|
}
|
|
838
838
|
get() {
|
|
839
|
-
this.throwOnEmptyStore()
|
|
839
|
+
if (this.throwOnEmptyStore(), !this.shouldRunActions)
|
|
840
|
+
return;
|
|
840
841
|
const e = this.store.getItem(this.key);
|
|
841
842
|
if (e)
|
|
842
843
|
return JSON.parse(e);
|
|
843
844
|
}
|
|
844
845
|
remove() {
|
|
845
|
-
this.throwOnEmptyStore(), this.store.removeItem(this.key);
|
|
846
|
+
this.throwOnEmptyStore(), this.shouldRunActions && this.store.removeItem(this.key);
|
|
846
847
|
}
|
|
847
848
|
add(e) {
|
|
848
|
-
this.throwOnEmptyStore()
|
|
849
|
+
if (this.throwOnEmptyStore(), !this.shouldRunActions)
|
|
850
|
+
return;
|
|
849
851
|
const t = JSON.stringify(this.resolveValue(e));
|
|
850
852
|
this.store.setItem(this.key, t);
|
|
851
853
|
}
|
|
@@ -900,7 +902,7 @@ function Le(o) {
|
|
|
900
902
|
defaultValue: u,
|
|
901
903
|
label: b,
|
|
902
904
|
nameTransformCasing: S,
|
|
903
|
-
type: p =
|
|
905
|
+
type: p = ae
|
|
904
906
|
} = a;
|
|
905
907
|
if (s)
|
|
906
908
|
e[n] = u;
|
|
@@ -936,7 +938,7 @@ function Le(o) {
|
|
|
936
938
|
);
|
|
937
939
|
const {
|
|
938
940
|
label: S,
|
|
939
|
-
type: p =
|
|
941
|
+
type: p = ae,
|
|
940
942
|
nameTransformCasing: f
|
|
941
943
|
} = b, v = f ?? r;
|
|
942
944
|
e[a] = {
|
|
@@ -969,7 +971,7 @@ function _e(o) {
|
|
|
969
971
|
const s = t, {
|
|
970
972
|
fields: n,
|
|
971
973
|
title: a,
|
|
972
|
-
nameTransformCasing: u =
|
|
974
|
+
nameTransformCasing: u = te,
|
|
973
975
|
description: b,
|
|
974
976
|
validateFields: S
|
|
975
977
|
} = r, p = s.toString().replace("step", "");
|
|
@@ -1006,7 +1008,7 @@ function _e(o) {
|
|
|
1006
1008
|
}
|
|
1007
1009
|
return e;
|
|
1008
1010
|
}
|
|
1009
|
-
let
|
|
1011
|
+
let ne = class extends Ee {
|
|
1010
1012
|
/**
|
|
1011
1013
|
* The original config before any validation or transformations have been applied.
|
|
1012
1014
|
*/
|
|
@@ -1030,10 +1032,10 @@ let re = class extends Ee {
|
|
|
1030
1032
|
r
|
|
1031
1033
|
), this.original = t, this.value = _e(this.original), this.storage = new ve({
|
|
1032
1034
|
data: this.value,
|
|
1033
|
-
key: s?.key ??
|
|
1035
|
+
key: s?.key ?? re,
|
|
1034
1036
|
store: s?.store,
|
|
1035
1037
|
throwWhenUndefined: s?.throwWhenUndefined ?? !1
|
|
1036
|
-
}), this.#e = new
|
|
1038
|
+
}), this.#e = new ee({
|
|
1037
1039
|
getValue: () => this.value,
|
|
1038
1040
|
setValue: (n) => this.handlePostUpdate(n)
|
|
1039
1041
|
}), this.value = this.#e.enrichValues(this.value), this.stepNumbers = Object.keys(this.value).map(
|
|
@@ -1136,7 +1138,7 @@ let re = class extends Ee {
|
|
|
1136
1138
|
if (n === null || typeof n != "object" || !ue(n, {
|
|
1137
1139
|
defaultValue: (u) => u !== "undefined" && u !== null,
|
|
1138
1140
|
label: (u) => typeof u == "string" || typeof u == "boolean" && !u,
|
|
1139
|
-
nameTransformCasing:
|
|
1141
|
+
nameTransformCasing: Y,
|
|
1140
1142
|
type: Ve
|
|
1141
1143
|
}))
|
|
1142
1144
|
return !1;
|
|
@@ -1146,7 +1148,7 @@ let re = class extends Ee {
|
|
|
1146
1148
|
createHelperFn: (r) => typeof r == "function",
|
|
1147
1149
|
// update: (v): v is GetCurrentStep<resolvedStep, stepNumbers>['update'] =>
|
|
1148
1150
|
// typeof v === 'function',
|
|
1149
|
-
nameTransformCasing:
|
|
1151
|
+
nameTransformCasing: Y,
|
|
1150
1152
|
...t?.optionalKeysToCheck
|
|
1151
1153
|
});
|
|
1152
1154
|
}
|
|
@@ -1160,11 +1162,11 @@ let re = class extends Ee {
|
|
|
1160
1162
|
const { steps: t, nameTransformCasing: r, storage: s } = e;
|
|
1161
1163
|
this.defaultNameTransformationCasing = be(
|
|
1162
1164
|
r
|
|
1163
|
-
), this.stepSchema = new
|
|
1165
|
+
), this.stepSchema = new ne({
|
|
1164
1166
|
steps: t,
|
|
1165
1167
|
nameTransformCasing: this.defaultNameTransformationCasing
|
|
1166
1168
|
}), this.storage = new ve({
|
|
1167
|
-
key: s?.key ??
|
|
1169
|
+
key: s?.key ?? re,
|
|
1168
1170
|
data: this.stepSchema.value,
|
|
1169
1171
|
store: s?.store,
|
|
1170
1172
|
throwWhenUndefined: s?.throwWhenUndefined ?? !1
|
|
@@ -1227,14 +1229,14 @@ var L;
|
|
|
1227
1229
|
}
|
|
1228
1230
|
o.isFormAvailable = e;
|
|
1229
1231
|
function t(r) {
|
|
1230
|
-
return (s) => /* @__PURE__ */
|
|
1232
|
+
return (s) => /* @__PURE__ */ Ae("form", { id: r, ...s });
|
|
1231
1233
|
}
|
|
1232
1234
|
o.createDefaultForm = t;
|
|
1233
1235
|
})(L || (L = {}));
|
|
1234
|
-
var
|
|
1236
|
+
var X;
|
|
1235
1237
|
((o) => {
|
|
1236
1238
|
o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
|
|
1237
|
-
})(
|
|
1239
|
+
})(X || (X = {}));
|
|
1238
1240
|
function De(o, e) {
|
|
1239
1241
|
w(
|
|
1240
1242
|
e in o,
|
|
@@ -1252,13 +1254,13 @@ function De(o, e) {
|
|
|
1252
1254
|
};
|
|
1253
1255
|
return r;
|
|
1254
1256
|
}
|
|
1255
|
-
class
|
|
1257
|
+
class Me extends ne {
|
|
1256
1258
|
// @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
|
|
1257
1259
|
value;
|
|
1258
1260
|
#e;
|
|
1259
1261
|
constructor(e) {
|
|
1260
1262
|
const { form: t, ...r } = e;
|
|
1261
|
-
super(r), this.value = _e(this.original), this.#e = new
|
|
1263
|
+
super(r), this.value = _e(this.original), this.#e = new ee({
|
|
1262
1264
|
getValue: () => this.value,
|
|
1263
1265
|
setValue: (s) => this.handlePostUpdate(s)
|
|
1264
1266
|
}), this.sync(), this.value = this.#e.enrichValues(this.value, (s) => {
|
|
@@ -1289,13 +1291,13 @@ class Ue extends re {
|
|
|
1289
1291
|
for (const [E, O] of Object.entries(s))
|
|
1290
1292
|
if (typeof O == "function")
|
|
1291
1293
|
try {
|
|
1292
|
-
const
|
|
1293
|
-
u[E] =
|
|
1294
|
+
const A = O();
|
|
1295
|
+
u[E] = A, typeof console < "u" && console.debug && console.debug(
|
|
1294
1296
|
`[multi-step-form] Hook "${E}" called successfully`,
|
|
1295
|
-
{ result:
|
|
1297
|
+
{ result: A === void 0 ? "defined" : "undefined" }
|
|
1296
1298
|
);
|
|
1297
|
-
} catch (
|
|
1298
|
-
const i =
|
|
1299
|
+
} catch (A) {
|
|
1300
|
+
const i = A instanceof Error ? A.message : String(A);
|
|
1299
1301
|
throw new Error(
|
|
1300
1302
|
`[multi-step-form] Error calling hook "${E}" in useFormInstance.render: ${i}
|
|
1301
1303
|
|
|
@@ -1305,7 +1307,7 @@ This usually means:
|
|
|
1305
1307
|
3. There's an error in your hook implementation
|
|
1306
1308
|
|
|
1307
1309
|
Original error: ${i}`,
|
|
1308
|
-
{ cause:
|
|
1310
|
+
{ cause: A }
|
|
1309
1311
|
);
|
|
1310
1312
|
}
|
|
1311
1313
|
else
|
|
@@ -1344,7 +1346,7 @@ Original error: ${i}`,
|
|
|
1344
1346
|
"update" in y,
|
|
1345
1347
|
`[${f}:Field]: No "update" function was found`
|
|
1346
1348
|
);
|
|
1347
|
-
const { fields: O, update:
|
|
1349
|
+
const { fields: O, update: A } = y, { defaultValue: i, label: l, nameTransformCasing: d, type: c } = O[E];
|
|
1348
1350
|
return {
|
|
1349
1351
|
defaultValue: i,
|
|
1350
1352
|
label: l,
|
|
@@ -1353,7 +1355,7 @@ Original error: ${i}`,
|
|
|
1353
1355
|
name: E,
|
|
1354
1356
|
onInputChange: (h) => (
|
|
1355
1357
|
// TODO remove type assertions
|
|
1356
|
-
|
|
1358
|
+
A({
|
|
1357
1359
|
fields: [`fields.${E}.defaultValue`],
|
|
1358
1360
|
updater: h
|
|
1359
1361
|
})
|
|
@@ -1370,10 +1372,10 @@ Original error: ${i}`,
|
|
|
1370
1372
|
const {
|
|
1371
1373
|
alias: E = L.DEFAULT_FORM_ALIAS,
|
|
1372
1374
|
...O
|
|
1373
|
-
} = S,
|
|
1375
|
+
} = S, A = O.enabledForSteps ?? "all";
|
|
1374
1376
|
return L.isFormAvailable(
|
|
1375
1377
|
e,
|
|
1376
|
-
|
|
1378
|
+
A
|
|
1377
1379
|
) && (g = {
|
|
1378
1380
|
...g,
|
|
1379
1381
|
[E]: this.createFormComponent(O, b)
|
|
@@ -1407,21 +1409,21 @@ Original error: ${i}`,
|
|
|
1407
1409
|
)(p);
|
|
1408
1410
|
}
|
|
1409
1411
|
if (typeof p == "object") {
|
|
1410
|
-
const { useFormInstance: m, ctxData: g, debug: E } = p, O = new
|
|
1412
|
+
const { useFormInstance: m, ctxData: g, debug: E } = p, O = new Q({
|
|
1411
1413
|
debug: E,
|
|
1412
1414
|
prefix(l) {
|
|
1413
1415
|
return `${l}-${u}-createComponent`;
|
|
1414
1416
|
}
|
|
1415
1417
|
});
|
|
1416
1418
|
O.info("First argument is an object");
|
|
1417
|
-
const { [u]:
|
|
1419
|
+
const { [u]: A, ...i } = a;
|
|
1418
1420
|
if (w(
|
|
1419
1421
|
typeof f == "function",
|
|
1420
1422
|
"The second argument must be a function"
|
|
1421
1423
|
), m) {
|
|
1422
1424
|
const {
|
|
1423
1425
|
render: l,
|
|
1424
|
-
alias: d =
|
|
1426
|
+
alias: d = X.DEFAULT_FORM_INSTANCE_ALIAS
|
|
1425
1427
|
} = m, [c] = e, h = n(c), _ = g ? {
|
|
1426
1428
|
...r,
|
|
1427
1429
|
...g({ ctx: i })
|
|
@@ -1479,19 +1481,19 @@ Original error: ${i}`,
|
|
|
1479
1481
|
return De(this.value, e);
|
|
1480
1482
|
}
|
|
1481
1483
|
}
|
|
1482
|
-
class
|
|
1484
|
+
class Ue extends Ne {
|
|
1483
1485
|
stepSchema;
|
|
1484
1486
|
#e;
|
|
1485
1487
|
constructor(e) {
|
|
1486
|
-
const { nameTransformCasing: t =
|
|
1488
|
+
const { nameTransformCasing: t = te, storage: r, ...s } = e;
|
|
1487
1489
|
super({
|
|
1488
1490
|
nameTransformCasing: t,
|
|
1489
1491
|
storage: r,
|
|
1490
1492
|
...s
|
|
1491
|
-
}), this.stepSchema = new
|
|
1493
|
+
}), this.stepSchema = new Me({
|
|
1492
1494
|
nameTransformCasing: t,
|
|
1493
1495
|
...s
|
|
1494
|
-
}), this.#e = new
|
|
1496
|
+
}), this.#e = new ee({
|
|
1495
1497
|
getValue: () => this.stepSchema.value,
|
|
1496
1498
|
setValue: (n) => {
|
|
1497
1499
|
this.stepSchema.value = { ...n }, this.storage.add(n), this.notify();
|
|
@@ -1513,9 +1515,9 @@ class Me extends Ne {
|
|
|
1513
1515
|
}
|
|
1514
1516
|
}
|
|
1515
1517
|
function Ye(o) {
|
|
1516
|
-
return new
|
|
1518
|
+
return new Ue(o);
|
|
1517
1519
|
}
|
|
1518
|
-
var I = { exports: {} },
|
|
1520
|
+
var I = { exports: {} }, B = {}, D = { exports: {} }, J = {};
|
|
1519
1521
|
/**
|
|
1520
1522
|
* @license React
|
|
1521
1523
|
* use-sync-external-store-shim.production.js
|
|
@@ -1527,9 +1529,9 @@ var I = { exports: {} }, H = {}, D = { exports: {} }, B = {};
|
|
|
1527
1529
|
*/
|
|
1528
1530
|
var le;
|
|
1529
1531
|
function Re() {
|
|
1530
|
-
if (le) return
|
|
1532
|
+
if (le) return J;
|
|
1531
1533
|
le = 1;
|
|
1532
|
-
var o =
|
|
1534
|
+
var o = G;
|
|
1533
1535
|
function e(f, v) {
|
|
1534
1536
|
return f === v && (f !== 0 || 1 / f === 1 / v) || f !== f && v !== v;
|
|
1535
1537
|
}
|
|
@@ -1564,9 +1566,9 @@ function Re() {
|
|
|
1564
1566
|
return v();
|
|
1565
1567
|
}
|
|
1566
1568
|
var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? S : u;
|
|
1567
|
-
return
|
|
1569
|
+
return J.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : p, J;
|
|
1568
1570
|
}
|
|
1569
|
-
var
|
|
1571
|
+
var z = {};
|
|
1570
1572
|
/**
|
|
1571
1573
|
* @license React
|
|
1572
1574
|
* use-sync-external-store-shim.development.js
|
|
@@ -1596,16 +1598,16 @@ function Ke() {
|
|
|
1596
1598
|
E = a({
|
|
1597
1599
|
inst: { value: g, getSnapshot: m }
|
|
1598
1600
|
});
|
|
1599
|
-
var O = E[0].inst,
|
|
1601
|
+
var O = E[0].inst, A = E[1];
|
|
1600
1602
|
return b(
|
|
1601
1603
|
function() {
|
|
1602
|
-
O.value = g, O.getSnapshot = m, t(O) &&
|
|
1604
|
+
O.value = g, O.getSnapshot = m, t(O) && A({ inst: O });
|
|
1603
1605
|
},
|
|
1604
1606
|
[y, g, m]
|
|
1605
1607
|
), u(
|
|
1606
1608
|
function() {
|
|
1607
|
-
return t(O) &&
|
|
1608
|
-
t(O) &&
|
|
1609
|
+
return t(O) && A({ inst: O }), y(function() {
|
|
1610
|
+
t(O) && A({ inst: O });
|
|
1609
1611
|
});
|
|
1610
1612
|
},
|
|
1611
1613
|
[y]
|
|
@@ -1625,9 +1627,9 @@ function Ke() {
|
|
|
1625
1627
|
return m();
|
|
1626
1628
|
}
|
|
1627
1629
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1628
|
-
var s =
|
|
1629
|
-
|
|
1630
|
-
})()),
|
|
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;
|
|
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;
|
|
1631
1633
|
}
|
|
1632
1634
|
var pe;
|
|
1633
1635
|
function Oe() {
|
|
@@ -1643,15 +1645,15 @@ function Oe() {
|
|
|
1643
1645
|
* LICENSE file in the root directory of this source tree.
|
|
1644
1646
|
*/
|
|
1645
1647
|
var de;
|
|
1646
|
-
function
|
|
1647
|
-
if (de) return
|
|
1648
|
+
function Ge() {
|
|
1649
|
+
if (de) return B;
|
|
1648
1650
|
de = 1;
|
|
1649
|
-
var o =
|
|
1651
|
+
var o = G, e = Oe();
|
|
1650
1652
|
function t(S, p) {
|
|
1651
1653
|
return S === p && (S !== 0 || 1 / S === 1 / p) || S !== S && p !== p;
|
|
1652
1654
|
}
|
|
1653
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;
|
|
1654
|
-
return
|
|
1656
|
+
return B.useSyncExternalStoreWithSelector = function(S, p, f, v, y) {
|
|
1655
1657
|
var m = n(null);
|
|
1656
1658
|
if (m.current === null) {
|
|
1657
1659
|
var g = { hasValue: !1, value: null };
|
|
@@ -1660,8 +1662,8 @@ function We() {
|
|
|
1660
1662
|
m = u(
|
|
1661
1663
|
function() {
|
|
1662
1664
|
function O(c) {
|
|
1663
|
-
if (!
|
|
1664
|
-
if (
|
|
1665
|
+
if (!A) {
|
|
1666
|
+
if (A = !0, i = c, c = v(c), y !== void 0 && g.hasValue) {
|
|
1665
1667
|
var h = g.value;
|
|
1666
1668
|
if (y(h, c))
|
|
1667
1669
|
return l = h;
|
|
@@ -1672,7 +1674,7 @@ function We() {
|
|
|
1672
1674
|
var _ = v(c);
|
|
1673
1675
|
return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
|
|
1674
1676
|
}
|
|
1675
|
-
var
|
|
1677
|
+
var A = !1, i, l, d = f === void 0 ? null : f;
|
|
1676
1678
|
return [
|
|
1677
1679
|
function() {
|
|
1678
1680
|
return O(p());
|
|
@@ -1691,9 +1693,9 @@ function We() {
|
|
|
1691
1693
|
},
|
|
1692
1694
|
[E]
|
|
1693
1695
|
), b(E), E;
|
|
1694
|
-
},
|
|
1696
|
+
}, B;
|
|
1695
1697
|
}
|
|
1696
|
-
var
|
|
1698
|
+
var q = {};
|
|
1697
1699
|
/**
|
|
1698
1700
|
* @license React
|
|
1699
1701
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -1704,14 +1706,14 @@ var z = {};
|
|
|
1704
1706
|
* LICENSE file in the root directory of this source tree.
|
|
1705
1707
|
*/
|
|
1706
1708
|
var he;
|
|
1707
|
-
function
|
|
1709
|
+
function Pe() {
|
|
1708
1710
|
return he || (he = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
1709
1711
|
function o(S, p) {
|
|
1710
1712
|
return S === p && (S !== 0 || 1 / S === 1 / p) || S !== S && p !== p;
|
|
1711
1713
|
}
|
|
1712
1714
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1713
|
-
var e =
|
|
1714
|
-
|
|
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) {
|
|
1715
1717
|
var m = n(null);
|
|
1716
1718
|
if (m.current === null) {
|
|
1717
1719
|
var g = { hasValue: !1, value: null };
|
|
@@ -1720,8 +1722,8 @@ function Ge() {
|
|
|
1720
1722
|
m = u(
|
|
1721
1723
|
function() {
|
|
1722
1724
|
function O(c) {
|
|
1723
|
-
if (!
|
|
1724
|
-
if (
|
|
1725
|
+
if (!A) {
|
|
1726
|
+
if (A = !0, i = c, c = v(c), y !== void 0 && g.hasValue) {
|
|
1725
1727
|
var h = g.value;
|
|
1726
1728
|
if (y(h, c))
|
|
1727
1729
|
return l = h;
|
|
@@ -1733,7 +1735,7 @@ function Ge() {
|
|
|
1733
1735
|
var _ = v(c);
|
|
1734
1736
|
return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
|
|
1735
1737
|
}
|
|
1736
|
-
var
|
|
1738
|
+
var A = !1, i, l, d = f === void 0 ? null : f;
|
|
1737
1739
|
return [
|
|
1738
1740
|
function() {
|
|
1739
1741
|
return O(p());
|
|
@@ -1753,14 +1755,14 @@ function Ge() {
|
|
|
1753
1755
|
[E]
|
|
1754
1756
|
), b(E), E;
|
|
1755
1757
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1756
|
-
})()),
|
|
1758
|
+
})()), q;
|
|
1757
1759
|
}
|
|
1758
1760
|
var me;
|
|
1759
|
-
function
|
|
1760
|
-
return me || (me = 1, process.env.NODE_ENV === "production" ? I.exports =
|
|
1761
|
+
function He() {
|
|
1762
|
+
return me || (me = 1, process.env.NODE_ENV === "production" ? I.exports = Ge() : I.exports = Pe()), I.exports;
|
|
1761
1763
|
}
|
|
1762
|
-
var
|
|
1763
|
-
function
|
|
1764
|
+
var We = He();
|
|
1765
|
+
function Z(o, e) {
|
|
1764
1766
|
w(
|
|
1765
1767
|
typeof e == "string",
|
|
1766
1768
|
`The target step must be a string, was ${typeof e}`
|
|
@@ -1782,13 +1784,13 @@ function X(o, e) {
|
|
|
1782
1784
|
}
|
|
1783
1785
|
function $e(o) {
|
|
1784
1786
|
function e(t) {
|
|
1785
|
-
return
|
|
1787
|
+
return We.useSyncExternalStoreWithSelector(
|
|
1786
1788
|
o.subscribe,
|
|
1787
1789
|
() => o.getSnapshot(),
|
|
1788
1790
|
() => o.getSnapshot(),
|
|
1789
1791
|
(r) => {
|
|
1790
1792
|
if (typeof t == "object") {
|
|
1791
|
-
const s =
|
|
1793
|
+
const s = Z(
|
|
1792
1794
|
r,
|
|
1793
1795
|
t.targetStep
|
|
1794
1796
|
);
|
|
@@ -1814,14 +1816,14 @@ function Ze(o) {
|
|
|
1814
1816
|
function t(u) {
|
|
1815
1817
|
const { targetStep: b, notFoundMessage: S, isDataGuaranteed: p } = u, f = e({
|
|
1816
1818
|
targetStep: b
|
|
1817
|
-
}), v = S ? a({ targetStep: b }, S) : (y) => /* @__PURE__ */
|
|
1819
|
+
}), v = S ? a({ targetStep: b }, S) : (y) => /* @__PURE__ */ se("div", { ...y, children: [
|
|
1818
1820
|
"No data found for step ",
|
|
1819
1821
|
String(b)
|
|
1820
1822
|
] });
|
|
1821
1823
|
return p ? {
|
|
1822
1824
|
data: f,
|
|
1823
1825
|
NoCurrentData: v
|
|
1824
|
-
} :
|
|
1826
|
+
} : ne.hasData(f) ? {
|
|
1825
1827
|
data: f,
|
|
1826
1828
|
hasData: !0,
|
|
1827
1829
|
NoCurrentData: v
|
|
@@ -1839,10 +1841,10 @@ function Ze(o) {
|
|
|
1839
1841
|
maxProgressValue: p = 100,
|
|
1840
1842
|
totalSteps: f = b,
|
|
1841
1843
|
progressTextTransformer: v
|
|
1842
|
-
} = u, y =
|
|
1844
|
+
} = u, y = Z(o, S), m = y / f * p, g = v ? n(
|
|
1843
1845
|
{ targetStep: S, maxProgressValue: p, totalSteps: f },
|
|
1844
1846
|
v
|
|
1845
|
-
) : (E) => /* @__PURE__ */
|
|
1847
|
+
) : (E) => /* @__PURE__ */ se("div", { ...E, children: [
|
|
1846
1848
|
"Step ",
|
|
1847
1849
|
y,
|
|
1848
1850
|
"/",
|
|
@@ -1863,7 +1865,7 @@ function Ze(o) {
|
|
|
1863
1865
|
return ye({ targetStep: p, maxProgressValue: f, totalSteps: v })(b);
|
|
1864
1866
|
}
|
|
1865
1867
|
function a(u, b) {
|
|
1866
|
-
return
|
|
1868
|
+
return Z(o, u.targetStep), ye(u)(b);
|
|
1867
1869
|
}
|
|
1868
1870
|
return {
|
|
1869
1871
|
// MultiStepFormContext: Context,
|
|
@@ -1876,9 +1878,9 @@ function Ze(o) {
|
|
|
1876
1878
|
};
|
|
1877
1879
|
}
|
|
1878
1880
|
export {
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1881
|
+
Ue as MultiStepFormSchema,
|
|
1882
|
+
Me as MultiStepFormStepSchema,
|
|
1883
|
+
X as StepSpecificComponent,
|
|
1882
1884
|
De as createDefaultValues,
|
|
1883
1885
|
Ze as createMultiStepFormContext,
|
|
1884
1886
|
Ye as createMultiStepFormSchema,
|