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