@jfdevelops/react-multi-step-form 1.0.0-alpha.13 → 1.0.0-alpha.15
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/{types/field.d.ts → field.d.ts} +1 -1
- package/dist/{types/form-config.d.ts → form-config.d.ts} +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +316 -303
- package/dist/index.mjs.map +1 -1
- package/dist/{types/schema.d.ts → schema.d.ts} +1 -1
- package/dist/{types/step-schema.d.ts → step-schema.d.ts} +2 -2
- package/package.json +10 -7
- /package/dist/{types/create-context.d.ts → create-context.d.ts} +0 -0
- /package/dist/{types/hooks → hooks}/use-multi-step-form-data.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{types/utils.d.ts → utils.d.ts} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as Te, jsxs as ie } from "react/jsx-runtime";
|
|
2
2
|
import R from "react";
|
|
3
3
|
function M(o, e, t) {
|
|
4
|
-
const r = [], s = new Set(o), n = t ? t.format(o.map((
|
|
5
|
-
for (let
|
|
6
|
-
const S = e[
|
|
4
|
+
const r = [], s = new Set(o), n = t ? t.format(o.map((c) => `${c}`)) : `[${o.join(", ")}]`;
|
|
5
|
+
for (let c = 0; c < e.length; c++) {
|
|
6
|
+
const S = e[c];
|
|
7
7
|
s.has(S) || r.push(
|
|
8
|
-
`Extra element at index ${
|
|
8
|
+
`Extra element at index ${c}: "${S}" is not in ${n}`
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
|
-
return e.some((
|
|
11
|
+
return e.some((c) => s.has(c)) || r.push(
|
|
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
|
}
|
|
@@ -23,7 +23,7 @@ function ae(o) {
|
|
|
23
23
|
function Ae(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
28
|
const r = new Intl.ListFormat("en", {
|
|
29
29
|
style: "long",
|
|
@@ -33,9 +33,9 @@ function E(o, e, t = Error) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
function q(o) {
|
|
36
|
-
|
|
36
|
+
_(o.includes("step"), "Can't extract a valid step number since");
|
|
37
37
|
const e = o.replace("step", "");
|
|
38
|
-
return
|
|
38
|
+
return _(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
|
|
39
39
|
}
|
|
40
40
|
function ee(o) {
|
|
41
41
|
return function(e) {
|
|
@@ -48,12 +48,12 @@ function K(o, e) {
|
|
|
48
48
|
const s = q(r), { data: n } = ee(o)({
|
|
49
49
|
step: s
|
|
50
50
|
});
|
|
51
|
-
for (const [a,
|
|
52
|
-
typeof
|
|
51
|
+
for (const [a, c] of Object.entries(n))
|
|
52
|
+
typeof c == "function" && a !== "update" || (n[a] = c);
|
|
53
53
|
return t[r] = n, t;
|
|
54
54
|
}, {});
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function k(o, e) {
|
|
57
57
|
const t = new Intl.ListFormat("en", {
|
|
58
58
|
style: "long",
|
|
59
59
|
type: "disjunction"
|
|
@@ -75,7 +75,7 @@ function L(o, e) {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
if (Array.isArray(e))
|
|
78
|
-
return
|
|
78
|
+
return _(
|
|
79
79
|
e.every((n) => r.includes(n)),
|
|
80
80
|
() => {
|
|
81
81
|
const n = M(
|
|
@@ -94,7 +94,7 @@ function L(o, e) {
|
|
|
94
94
|
);
|
|
95
95
|
if (typeof e == "object") {
|
|
96
96
|
const n = Object.keys(e);
|
|
97
|
-
return
|
|
97
|
+
return _(
|
|
98
98
|
n.every((a) => r.includes(a)),
|
|
99
99
|
() => {
|
|
100
100
|
const a = M(
|
|
@@ -170,10 +170,10 @@ class te {
|
|
|
170
170
|
includeTimestamp: s = this.includeTimestamp,
|
|
171
171
|
prefix: n,
|
|
172
172
|
logLevelOptions: a
|
|
173
|
-
} = r ?? {},
|
|
173
|
+
} = r ?? {}, c = this.formatPrefix(n), S = this.wrapValue(
|
|
174
174
|
a?.wrapWith ?? "[]",
|
|
175
175
|
(a?.level ?? e).toUpperCase()
|
|
176
|
-
), g = `${
|
|
176
|
+
), g = `${c} ${S} ${t}`;
|
|
177
177
|
return s ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${g}` : g;
|
|
178
178
|
}
|
|
179
179
|
info(e, t) {
|
|
@@ -193,47 +193,53 @@ class te {
|
|
|
193
193
|
var V;
|
|
194
194
|
((o) => {
|
|
195
195
|
function e(i, l) {
|
|
196
|
-
return l.split(".").reduce((
|
|
197
|
-
}
|
|
198
|
-
function t(i, l,
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
for (let
|
|
202
|
-
const $ =
|
|
203
|
-
|
|
196
|
+
return l.split(".").reduce((h, u) => h?.[u], i);
|
|
197
|
+
}
|
|
198
|
+
function t(i, l, h) {
|
|
199
|
+
const u = l.split(".");
|
|
200
|
+
let d = i;
|
|
201
|
+
for (let E = 0; E < u.length; E++) {
|
|
202
|
+
const $ = u[E];
|
|
203
|
+
E === u.length - 1 ? d[$] !== void 0 && typeof d[$] == "object" && typeof h == "object" && h !== null ? Object.assign(d[$], h) : d[$] = h : ((typeof d[$] != "object" || d[$] === null) && (d[$] = {}), d = d[$]);
|
|
204
204
|
}
|
|
205
|
-
return
|
|
205
|
+
return d;
|
|
206
206
|
}
|
|
207
207
|
o.setBy = t;
|
|
208
|
-
function r(i) {
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
function r(...i) {
|
|
209
|
+
const l = [...i].sort(
|
|
210
|
+
(u, d) => d.split(".").length - u.split(".").length
|
|
211
|
+
), h = [];
|
|
212
|
+
for (const u of l)
|
|
213
|
+
h.some((E) => E.startsWith(u + ".")) || h.push(u);
|
|
214
|
+
return h.reverse();
|
|
215
|
+
}
|
|
216
|
+
o.normalizePaths = r;
|
|
211
217
|
function s(i, ...l) {
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
return e(i,
|
|
215
|
-
const
|
|
216
|
-
for (const
|
|
217
|
-
const
|
|
218
|
-
t(
|
|
218
|
+
const h = r(...l);
|
|
219
|
+
if (h.length === 1)
|
|
220
|
+
return e(i, h[0]);
|
|
221
|
+
const u = {};
|
|
222
|
+
for (const d of h) {
|
|
223
|
+
const E = e(i, d);
|
|
224
|
+
t(u, d, E);
|
|
219
225
|
}
|
|
220
|
-
return
|
|
226
|
+
return u;
|
|
221
227
|
}
|
|
222
228
|
o.pickBy = s;
|
|
223
229
|
function n(i) {
|
|
224
230
|
const l = [];
|
|
225
|
-
function
|
|
226
|
-
if (
|
|
231
|
+
function h(u, d = "") {
|
|
232
|
+
if (u == null || typeof u != "object" || Array.isArray(u))
|
|
227
233
|
return;
|
|
228
|
-
const
|
|
229
|
-
for (const $ of
|
|
230
|
-
const A =
|
|
234
|
+
const E = Object.keys(u);
|
|
235
|
+
for (const $ of E) {
|
|
236
|
+
const A = d ? `${d}.${$}` : $;
|
|
231
237
|
l.push(A);
|
|
232
|
-
const T =
|
|
233
|
-
T != null && typeof T == "object" && !Array.isArray(T) &&
|
|
238
|
+
const T = u[$];
|
|
239
|
+
T != null && typeof T == "object" && !Array.isArray(T) && h(T, A);
|
|
234
240
|
}
|
|
235
241
|
}
|
|
236
|
-
return
|
|
242
|
+
return h(i), l;
|
|
237
243
|
}
|
|
238
244
|
o.createDeep = n;
|
|
239
245
|
function a(i) {
|
|
@@ -241,124 +247,124 @@ var V;
|
|
|
241
247
|
if (Array.isArray(i)) return "Array";
|
|
242
248
|
const l = typeof i;
|
|
243
249
|
if (l !== "object") return l;
|
|
244
|
-
const
|
|
245
|
-
return
|
|
250
|
+
const h = i?.constructor?.name;
|
|
251
|
+
return h && h !== "Object" ? h : "object";
|
|
246
252
|
}
|
|
247
|
-
function
|
|
253
|
+
function c(i) {
|
|
248
254
|
if (!i) return [];
|
|
249
|
-
const l = [],
|
|
250
|
-
let
|
|
251
|
-
for (;
|
|
252
|
-
l.push(
|
|
255
|
+
const l = [], h = /[^.[\]]+|\[(\d+)\]/g;
|
|
256
|
+
let u;
|
|
257
|
+
for (; u = h.exec(i); )
|
|
258
|
+
l.push(u[1] ?? u[0]);
|
|
253
259
|
return l;
|
|
254
260
|
}
|
|
255
261
|
function S(i, l) {
|
|
256
262
|
if (!i) return;
|
|
257
263
|
if (typeof i == "function")
|
|
258
264
|
return i;
|
|
259
|
-
const
|
|
260
|
-
let
|
|
261
|
-
for (const
|
|
262
|
-
if (!
|
|
263
|
-
if (typeof
|
|
264
|
-
|
|
265
|
+
const h = c(l);
|
|
266
|
+
let u = i, d;
|
|
267
|
+
for (const E of h) {
|
|
268
|
+
if (!u) break;
|
|
269
|
+
if (typeof u == "function") {
|
|
270
|
+
d = u;
|
|
265
271
|
break;
|
|
266
272
|
}
|
|
267
|
-
if (
|
|
268
|
-
|
|
273
|
+
if (u = u[E], typeof u == "function") {
|
|
274
|
+
d = u;
|
|
269
275
|
break;
|
|
270
276
|
}
|
|
271
277
|
}
|
|
272
|
-
return
|
|
278
|
+
return d;
|
|
273
279
|
}
|
|
274
|
-
function g(i, l,
|
|
275
|
-
const
|
|
276
|
-
return
|
|
280
|
+
function g(i, l, h) {
|
|
281
|
+
const u = S(h, l);
|
|
282
|
+
return u ? u(i, l) : a(i);
|
|
277
283
|
}
|
|
278
284
|
function p(i) {
|
|
279
285
|
return typeof i == "object" && i !== null;
|
|
280
286
|
}
|
|
281
|
-
function f(i, l,
|
|
287
|
+
function f(i, l, h, u, d) {
|
|
282
288
|
if (i === l)
|
|
283
|
-
return
|
|
289
|
+
return u;
|
|
284
290
|
if (i === null || l === null || typeof i != "object" || typeof l != "object") {
|
|
285
|
-
const $ =
|
|
286
|
-
return typeof i != typeof l ? (
|
|
291
|
+
const $ = h || "(root)";
|
|
292
|
+
return typeof i != typeof l ? (u.push({
|
|
287
293
|
path: $,
|
|
288
|
-
expected: g(i, $,
|
|
294
|
+
expected: g(i, $, d.transformExpected),
|
|
289
295
|
actual: l,
|
|
290
296
|
reason: "type-mismatch"
|
|
291
|
-
}),
|
|
297
|
+
}), u) : (d.includeValueMismatch && u.push({
|
|
292
298
|
path: $,
|
|
293
|
-
expected: g(i, $,
|
|
299
|
+
expected: g(i, $, d.transformExpected),
|
|
294
300
|
actual: l,
|
|
295
301
|
reason: "value-mismatch"
|
|
296
|
-
}),
|
|
302
|
+
}), u);
|
|
297
303
|
}
|
|
298
304
|
if (Array.isArray(i) || Array.isArray(l)) {
|
|
299
305
|
if (!Array.isArray(i) || !Array.isArray(l)) {
|
|
300
|
-
const A =
|
|
301
|
-
return
|
|
306
|
+
const A = h || "(root)";
|
|
307
|
+
return u.push({
|
|
302
308
|
path: A,
|
|
303
|
-
expected: g(i, A,
|
|
309
|
+
expected: g(i, A, d.transformExpected),
|
|
304
310
|
actual: l,
|
|
305
311
|
reason: "type-mismatch"
|
|
306
|
-
}),
|
|
312
|
+
}), u;
|
|
307
313
|
}
|
|
308
314
|
const $ = i.length;
|
|
309
315
|
for (let A = 0; A < $; A++) {
|
|
310
|
-
const T = i[A], C = l[A], N =
|
|
311
|
-
f(T, C, N,
|
|
316
|
+
const T = i[A], C = l[A], N = h === "" ? `[${A}]` : `${h}[${A}]`;
|
|
317
|
+
f(T, C, N, u, d);
|
|
312
318
|
}
|
|
313
|
-
return
|
|
319
|
+
return u;
|
|
314
320
|
}
|
|
315
321
|
if (p(i) && p(l)) {
|
|
316
322
|
const $ = Object.keys(i), A = Object.keys(l);
|
|
317
323
|
for (const T of $) {
|
|
318
|
-
const C = i[T], N = l[T], F =
|
|
324
|
+
const C = i[T], N = l[T], F = h ? `${h}.${T}` : T;
|
|
319
325
|
if (!(T in l)) {
|
|
320
|
-
|
|
326
|
+
u.push({
|
|
321
327
|
path: F,
|
|
322
|
-
expected: g(C, F,
|
|
328
|
+
expected: g(C, F, d.transformExpected),
|
|
323
329
|
actual: void 0,
|
|
324
330
|
reason: "missing-key"
|
|
325
331
|
});
|
|
326
332
|
continue;
|
|
327
333
|
}
|
|
328
|
-
f(C, N, F,
|
|
334
|
+
f(C, N, F, u, d);
|
|
329
335
|
}
|
|
330
336
|
for (const T of A)
|
|
331
337
|
if (!(T in i)) {
|
|
332
|
-
const C =
|
|
333
|
-
|
|
338
|
+
const C = h ? `${h}.${T}` : T;
|
|
339
|
+
u.push({
|
|
334
340
|
path: C,
|
|
335
341
|
expected: void 0,
|
|
336
342
|
actual: l[T],
|
|
337
343
|
reason: "extra-key"
|
|
338
344
|
});
|
|
339
345
|
}
|
|
340
|
-
return
|
|
346
|
+
return u;
|
|
341
347
|
}
|
|
342
|
-
const
|
|
343
|
-
return typeof i != typeof l ?
|
|
344
|
-
path:
|
|
345
|
-
expected: g(i,
|
|
348
|
+
const E = h || "(root)";
|
|
349
|
+
return typeof i != typeof l ? u.push({
|
|
350
|
+
path: E,
|
|
351
|
+
expected: g(i, E, d.transformExpected),
|
|
346
352
|
actual: l,
|
|
347
353
|
reason: "type-mismatch"
|
|
348
|
-
}) :
|
|
349
|
-
path:
|
|
350
|
-
expected: g(i,
|
|
354
|
+
}) : d.includeValueMismatch && u.push({
|
|
355
|
+
path: E,
|
|
356
|
+
expected: g(i, E, d.transformExpected),
|
|
351
357
|
actual: l,
|
|
352
358
|
reason: "value-mismatch"
|
|
353
|
-
}),
|
|
359
|
+
}), u;
|
|
354
360
|
}
|
|
355
|
-
function v(i, l,
|
|
356
|
-
const
|
|
357
|
-
return f(
|
|
358
|
-
transformExpected:
|
|
361
|
+
function v(i, l, h, u) {
|
|
362
|
+
const d = s(i, ...l), E = [], $ = l.length === 1 ? l[0] : "";
|
|
363
|
+
return f(d, h, $, E, {
|
|
364
|
+
transformExpected: u?.transformExpected
|
|
359
365
|
}), {
|
|
360
|
-
ok:
|
|
361
|
-
mismatches:
|
|
366
|
+
ok: E.length === 0,
|
|
367
|
+
mismatches: E
|
|
362
368
|
};
|
|
363
369
|
}
|
|
364
370
|
o.equalsAtPaths = v;
|
|
@@ -389,12 +395,12 @@ var V;
|
|
|
389
395
|
if (i.ok || i.mismatches.length === 0)
|
|
390
396
|
return "No mismatches.";
|
|
391
397
|
const l = [];
|
|
392
|
-
for (const
|
|
398
|
+
for (const h of i.mismatches)
|
|
393
399
|
l.push(
|
|
394
400
|
`
|
|
395
|
-
● ${m(
|
|
396
|
-
` expected: ${y(
|
|
397
|
-
` actual: ${y(
|
|
401
|
+
● ${m(h)} at "${h.path}":`,
|
|
402
|
+
` expected: ${y(h.expected)}`,
|
|
403
|
+
` actual: ${y(h.actual)}`,
|
|
398
404
|
""
|
|
399
405
|
// blank line between entries
|
|
400
406
|
);
|
|
@@ -407,39 +413,39 @@ var V;
|
|
|
407
413
|
l !== "No mismatches." && console.error(l);
|
|
408
414
|
}
|
|
409
415
|
o.printMismatches = O;
|
|
410
|
-
function w(i, l,
|
|
411
|
-
const
|
|
412
|
-
function
|
|
413
|
-
const A =
|
|
414
|
-
if ($ ===
|
|
415
|
-
let P =
|
|
416
|
+
function w(i, l, h) {
|
|
417
|
+
const u = l.split(".");
|
|
418
|
+
function d(E, $) {
|
|
419
|
+
const A = u[$], T = Array.isArray(E) ? [...E] : { ...E };
|
|
420
|
+
if ($ === u.length - 1) {
|
|
421
|
+
let P = E && typeof E == "object" ? T : {};
|
|
416
422
|
return P = {
|
|
417
423
|
...P,
|
|
418
|
-
[A]:
|
|
424
|
+
[A]: h
|
|
419
425
|
}, P;
|
|
420
426
|
}
|
|
421
|
-
const C =
|
|
422
|
-
let F =
|
|
427
|
+
const C = E && typeof E == "object" ? E[A] : void 0, N = d(C ?? {}, $ + 1);
|
|
428
|
+
let F = E && typeof E == "object" ? T : {};
|
|
423
429
|
return F = {
|
|
424
430
|
...F,
|
|
425
431
|
[A]: N
|
|
426
432
|
}, F;
|
|
427
433
|
}
|
|
428
|
-
return
|
|
429
|
-
}
|
|
430
|
-
function j(i, l,
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
let
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
return
|
|
434
|
+
return d(i, 0);
|
|
435
|
+
}
|
|
436
|
+
function j(i, l, h) {
|
|
437
|
+
const u = r(...l);
|
|
438
|
+
if (u.length === 0) return i;
|
|
439
|
+
let d = i;
|
|
440
|
+
if (u.length === 1) {
|
|
441
|
+
const E = u[0];
|
|
442
|
+
return d = w(d, E, h), d;
|
|
437
443
|
}
|
|
438
|
-
for (const
|
|
439
|
-
const $ = e(
|
|
440
|
-
|
|
444
|
+
for (const E of u) {
|
|
445
|
+
const $ = e(h, E);
|
|
446
|
+
d = w(d, E, $);
|
|
441
447
|
}
|
|
442
|
-
return
|
|
448
|
+
return d;
|
|
443
449
|
}
|
|
444
450
|
o.updateAt = j;
|
|
445
451
|
})(V || (V = {}));
|
|
@@ -470,26 +476,26 @@ class re {
|
|
|
470
476
|
this.#t(this.enrichValues(e));
|
|
471
477
|
}
|
|
472
478
|
createStepUpdaterFnImpl(e) {
|
|
473
|
-
const { targetStep: t, updater: r, ctxData: s, fields: n = "all", debug: a } = e,
|
|
479
|
+
const { targetStep: t, updater: r, ctxData: s, fields: n = "all", debug: a } = e, c = new te({
|
|
474
480
|
debug: a,
|
|
475
481
|
prefix: (m) => `${m}:update${t}`
|
|
476
482
|
});
|
|
477
|
-
|
|
483
|
+
c.info(`${t} will be updated`), _(
|
|
478
484
|
be(this.value, t),
|
|
479
485
|
`[update]: The target step ${t} isn't a valid step. Please select a valid step`
|
|
480
486
|
);
|
|
481
487
|
const { [t]: S, ...g } = this.value;
|
|
482
|
-
let p = { ...this.value }, f =
|
|
488
|
+
let p = { ...this.value }, f = k(p, [t]);
|
|
483
489
|
if (s) {
|
|
484
|
-
|
|
490
|
+
_(
|
|
485
491
|
typeof s == "function",
|
|
486
492
|
'[update]: "ctxData" must be a function'
|
|
487
|
-
),
|
|
493
|
+
), c.info('Custom "ctx" will be used');
|
|
488
494
|
const m = s({ ctx: g });
|
|
489
|
-
|
|
495
|
+
_(
|
|
490
496
|
typeof m == "object" && Object.keys(m).length > 0,
|
|
491
497
|
'[update]: "ctxData" must return an object with keys'
|
|
492
|
-
),
|
|
498
|
+
), c.info(
|
|
493
499
|
`Custom "ctx" consists of the following keys: ${new Intl.ListFormat(
|
|
494
500
|
"en",
|
|
495
501
|
{
|
|
@@ -506,15 +512,15 @@ class re {
|
|
|
506
512
|
ctx: f,
|
|
507
513
|
update: this.createHelperFnInputUpdate([t])
|
|
508
514
|
});
|
|
509
|
-
if (
|
|
510
|
-
|
|
515
|
+
if (c.info(`The updated data is ${JSON.stringify(v, null, 2)}`), !n) {
|
|
516
|
+
_(
|
|
511
517
|
typeof v == "object",
|
|
512
518
|
'[update]: "updater" must be an object or a function that returns an object'
|
|
513
519
|
);
|
|
514
520
|
const m = Object.keys(this.value), b = Object.keys(v);
|
|
515
|
-
|
|
521
|
+
_(b.length === m.length, () => {
|
|
516
522
|
const i = m.filter(
|
|
517
|
-
(
|
|
523
|
+
(h) => !b.includes(h)
|
|
518
524
|
);
|
|
519
525
|
return `[update]: "updater" is missing keys ${new Intl.ListFormat("en", {
|
|
520
526
|
style: "long",
|
|
@@ -528,22 +534,22 @@ class re {
|
|
|
528
534
|
O,
|
|
529
535
|
v
|
|
530
536
|
);
|
|
531
|
-
|
|
537
|
+
_(
|
|
532
538
|
j && w.length === 0,
|
|
533
539
|
`[update]: found value mismatches in ${V.printMismatches({
|
|
534
540
|
mismatches: w,
|
|
535
541
|
ok: j
|
|
536
542
|
})}`
|
|
537
|
-
),
|
|
543
|
+
), c.info("The entire step will be updated"), p = {
|
|
538
544
|
...p,
|
|
539
545
|
[t]: V.updateAt(p, O, v)
|
|
540
|
-
}, this.handlePostUpdate(p),
|
|
546
|
+
}, this.handlePostUpdate(p), c.info(`The new value is: ${JSON.stringify(p, null, 2)}`);
|
|
541
547
|
return;
|
|
542
548
|
}
|
|
543
549
|
const y = V.createDeep(S);
|
|
544
550
|
if (Array.isArray(n)) {
|
|
545
551
|
const m = M(y, n);
|
|
546
|
-
|
|
552
|
+
_(
|
|
547
553
|
m.status === "success",
|
|
548
554
|
`[update]: Found errors with the provided fields
|
|
549
555
|
${m.status === "error" ? U(m.errors) : ""}`
|
|
@@ -553,13 +559,13 @@ ${m.status === "error" ? U(m.errors) : ""}`
|
|
|
553
559
|
n,
|
|
554
560
|
v
|
|
555
561
|
);
|
|
556
|
-
|
|
562
|
+
_(
|
|
557
563
|
O && b.length === 0,
|
|
558
564
|
`[update]: found value mismatches in ${V.printMismatches({
|
|
559
565
|
ok: O,
|
|
560
566
|
mismatches: b
|
|
561
567
|
})}`
|
|
562
|
-
),
|
|
568
|
+
), c.info(
|
|
563
569
|
`The following fields will be updated: ${new Intl.ListFormat("en", {
|
|
564
570
|
type: "conjunction",
|
|
565
571
|
style: "long"
|
|
@@ -567,7 +573,7 @@ ${m.status === "error" ? U(m.errors) : ""}`
|
|
|
567
573
|
), p = {
|
|
568
574
|
...p,
|
|
569
575
|
[t]: V.updateAt(S, n, v)
|
|
570
|
-
}, this.handlePostUpdate(p),
|
|
576
|
+
}, this.handlePostUpdate(p), c.info(`The new value is: ${JSON.stringify(p, null, 2)}`);
|
|
571
577
|
return;
|
|
572
578
|
}
|
|
573
579
|
if (typeof n == "object" && Object.keys(n).length > 0) {
|
|
@@ -575,7 +581,7 @@ ${m.status === "error" ? U(m.errors) : ""}`
|
|
|
575
581
|
y,
|
|
576
582
|
m
|
|
577
583
|
);
|
|
578
|
-
|
|
584
|
+
_(
|
|
579
585
|
b.status === "success",
|
|
580
586
|
`[update]: Found errors with the provided fields
|
|
581
587
|
${b.status === "error" ? U(b.errors) : ""}`
|
|
@@ -585,7 +591,7 @@ ${b.status === "error" ? U(b.errors) : ""}`
|
|
|
585
591
|
m,
|
|
586
592
|
v
|
|
587
593
|
);
|
|
588
|
-
|
|
594
|
+
_(
|
|
589
595
|
w && O.length === 0,
|
|
590
596
|
`[update]: found value mismatches in ${V.printMismatches({
|
|
591
597
|
ok: w,
|
|
@@ -598,15 +604,15 @@ ${b.status === "error" ? U(b.errors) : ""}`
|
|
|
598
604
|
m,
|
|
599
605
|
v
|
|
600
606
|
)
|
|
601
|
-
},
|
|
607
|
+
}, c.info(
|
|
602
608
|
`The following fields will be updated: ${new Intl.ListFormat("en", {
|
|
603
609
|
type: "conjunction",
|
|
604
610
|
style: "long"
|
|
605
611
|
}).format(Object.keys(n))}`
|
|
606
|
-
), this.handlePostUpdate(p),
|
|
612
|
+
), this.handlePostUpdate(p), c.info(`The new value is: ${JSON.stringify(p, null, 2)}`);
|
|
607
613
|
return;
|
|
608
614
|
}
|
|
609
|
-
throw
|
|
615
|
+
throw c.error('Unsupported value for the "fields" option'), new TypeError(
|
|
610
616
|
`[update]: property "fields" must be set to one of the following: "all", an array of deep paths to update, or an object of paths. Was ${typeof r}`,
|
|
611
617
|
{ cause: r }
|
|
612
618
|
);
|
|
@@ -620,7 +626,7 @@ ${b.status === "error" ? U(b.errors) : ""}`
|
|
|
620
626
|
return this.createStepUpdaterFnImpl(e);
|
|
621
627
|
}
|
|
622
628
|
createHelperFnInputUpdate(e) {
|
|
623
|
-
if (
|
|
629
|
+
if (x.isAll(e)) {
|
|
624
630
|
const r = ae(this.value).reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
|
|
625
631
|
return Object.assign(
|
|
626
632
|
this.update,
|
|
@@ -628,62 +634,69 @@ ${b.status === "error" ? U(b.errors) : ""}`
|
|
|
628
634
|
);
|
|
629
635
|
}
|
|
630
636
|
const t = Object.keys(this.value);
|
|
631
|
-
if (
|
|
637
|
+
if (x.isTuple(e, t)) {
|
|
632
638
|
const r = e.reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
|
|
633
639
|
return Object.assign(
|
|
634
640
|
this.update,
|
|
635
641
|
r
|
|
636
642
|
);
|
|
637
643
|
}
|
|
638
|
-
if (
|
|
644
|
+
if (x.isObject(e, t)) {
|
|
639
645
|
const r = ae(e).reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
|
|
640
646
|
return Object.assign(
|
|
641
647
|
this.update,
|
|
642
648
|
r
|
|
643
649
|
);
|
|
644
650
|
}
|
|
645
|
-
throw new TypeError(`[update]: ${
|
|
651
|
+
throw new TypeError(`[update]: ${x.CATCH_ALL_MESSAGE}`);
|
|
646
652
|
}
|
|
647
653
|
createStepHelperFn(e) {
|
|
648
654
|
return (t, r) => {
|
|
649
|
-
const s =
|
|
650
|
-
this.value,
|
|
651
|
-
e
|
|
652
|
-
), n = this.createHelperFnInputUpdate(
|
|
655
|
+
const s = this.createHelperFnInputUpdate(
|
|
653
656
|
e
|
|
654
657
|
);
|
|
655
658
|
if (typeof t == "function")
|
|
656
|
-
return () =>
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
659
|
+
return () => {
|
|
660
|
+
const n = k(
|
|
661
|
+
this.value,
|
|
662
|
+
e
|
|
663
|
+
);
|
|
664
|
+
return t({
|
|
665
|
+
ctx: n,
|
|
666
|
+
update: s
|
|
667
|
+
});
|
|
668
|
+
};
|
|
660
669
|
if (typeof t == "object")
|
|
661
|
-
return (
|
|
670
|
+
return (n) => {
|
|
671
|
+
const a = k(
|
|
672
|
+
this.value,
|
|
673
|
+
e
|
|
674
|
+
);
|
|
662
675
|
if ("validator" in t) {
|
|
663
|
-
|
|
664
|
-
typeof
|
|
676
|
+
_(
|
|
677
|
+
typeof n == "object",
|
|
665
678
|
"An input is expected since you provided a validator"
|
|
666
679
|
), Se(
|
|
667
680
|
t.validator,
|
|
668
|
-
|
|
681
|
+
n.data
|
|
669
682
|
);
|
|
670
|
-
let
|
|
683
|
+
let c = a;
|
|
671
684
|
if (t.ctxData) {
|
|
672
685
|
const S = e[0], { [S]: g, ...p } = this.value;
|
|
673
|
-
|
|
674
|
-
...
|
|
686
|
+
c = {
|
|
687
|
+
...c,
|
|
675
688
|
...t.ctxData({ ctx: p })
|
|
676
689
|
};
|
|
677
690
|
}
|
|
678
691
|
return r({
|
|
679
|
-
ctx:
|
|
680
|
-
update:
|
|
681
|
-
...
|
|
692
|
+
ctx: c,
|
|
693
|
+
update: s,
|
|
694
|
+
...n
|
|
682
695
|
});
|
|
683
696
|
}
|
|
684
697
|
return r({
|
|
685
|
-
ctx:
|
|
686
|
-
update:
|
|
698
|
+
ctx: a,
|
|
699
|
+
update: s
|
|
687
700
|
});
|
|
688
701
|
};
|
|
689
702
|
throw new Error(
|
|
@@ -694,14 +707,14 @@ ${b.status === "error" ? U(b.errors) : ""}`
|
|
|
694
707
|
enrichValues(e, t) {
|
|
695
708
|
let r = { ...e };
|
|
696
709
|
for (const [s, n] of Object.entries(r)) {
|
|
697
|
-
const [a] = [s],
|
|
710
|
+
const [a] = [s], c = Number.parseInt(
|
|
698
711
|
a.replace("step", "")
|
|
699
712
|
);
|
|
700
713
|
r[a] = {
|
|
701
714
|
...n,
|
|
702
715
|
update: this.createStepUpdaterFn(a),
|
|
703
716
|
createHelperFn: this.createStepHelperFn([a]),
|
|
704
|
-
...t?.(
|
|
717
|
+
...t?.(c)
|
|
705
718
|
};
|
|
706
719
|
}
|
|
707
720
|
return r;
|
|
@@ -710,12 +723,12 @@ ${b.status === "error" ? U(b.errors) : ""}`
|
|
|
710
723
|
var Y;
|
|
711
724
|
((o) => {
|
|
712
725
|
function e(t, r, s = "defaultValue") {
|
|
713
|
-
const [n, ...a] = t.split("."),
|
|
726
|
+
const [n, ...a] = t.split("."), c = `${n}.${s}`, S = a.length === 0 ? c : `${c}.${a.join(".")}`;
|
|
714
727
|
return V.pickBy(r, S);
|
|
715
728
|
}
|
|
716
729
|
o.resolvedDeepPath = e;
|
|
717
730
|
})(Y || (Y = {}));
|
|
718
|
-
var
|
|
731
|
+
var x;
|
|
719
732
|
((o) => {
|
|
720
733
|
o.CATCH_ALL_MESSAGE = 'The chosen steps must either be set to on of the following: "all", an array of steps (["step1", "step2", ...]), or an object containing the steps to chose ({ step1: true, step2: true, ...})';
|
|
721
734
|
function e(s) {
|
|
@@ -730,10 +743,10 @@ var k;
|
|
|
730
743
|
if (!s)
|
|
731
744
|
return !1;
|
|
732
745
|
const a = Object.keys(s);
|
|
733
|
-
return a.length === 0 || n && !a.every((
|
|
746
|
+
return a.length === 0 || n && !a.every((c) => n.includes(c)) ? !1 : Object.entries(s).every(([c, S]) => S === !0);
|
|
734
747
|
}
|
|
735
748
|
o.isObject = r;
|
|
736
|
-
})(
|
|
749
|
+
})(x || (x = {}));
|
|
737
750
|
const Ce = [
|
|
738
751
|
"sentence",
|
|
739
752
|
"title",
|
|
@@ -808,7 +821,7 @@ class Ee {
|
|
|
808
821
|
}), 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));
|
|
809
822
|
}
|
|
810
823
|
throwOnEmptyStore() {
|
|
811
|
-
this.throwWhenUndefined &&
|
|
824
|
+
this.throwWhenUndefined && _(this.store, () => this.shouldRunActions ? W : "No storage available");
|
|
812
825
|
}
|
|
813
826
|
resolveValue(e) {
|
|
814
827
|
if (typeof e == "object")
|
|
@@ -879,28 +892,28 @@ function le(o, e, t) {
|
|
|
879
892
|
function Ne(o) {
|
|
880
893
|
const e = {}, { fields: t, defaultCasing: r, validateFields: s } = o;
|
|
881
894
|
for (const [n, a] of Object.entries(t)) {
|
|
882
|
-
|
|
895
|
+
_(
|
|
883
896
|
typeof n == "string",
|
|
884
897
|
`Each key for the "fields" option must be a string. Key ${n} was a ${typeof n}`
|
|
885
|
-
),
|
|
898
|
+
), _(
|
|
886
899
|
typeof a == "object",
|
|
887
900
|
`The value for key ${n} must be an object. Was ${typeof a}`
|
|
888
901
|
);
|
|
889
902
|
const {
|
|
890
|
-
defaultValue:
|
|
903
|
+
defaultValue: c,
|
|
891
904
|
label: S,
|
|
892
905
|
nameTransformCasing: g,
|
|
893
906
|
type: p = ue
|
|
894
907
|
} = a;
|
|
895
908
|
if (s)
|
|
896
|
-
e[n] =
|
|
909
|
+
e[n] = c;
|
|
897
910
|
else {
|
|
898
911
|
const f = g ?? r;
|
|
899
912
|
e[n] = {
|
|
900
913
|
...e[n],
|
|
901
914
|
nameTransformCasing: f,
|
|
902
915
|
type: p,
|
|
903
|
-
defaultValue:
|
|
916
|
+
defaultValue: c,
|
|
904
917
|
label: le(S, n, f)
|
|
905
918
|
// TODO add more fields here
|
|
906
919
|
};
|
|
@@ -911,16 +924,16 @@ function Ne(o) {
|
|
|
911
924
|
s,
|
|
912
925
|
e
|
|
913
926
|
);
|
|
914
|
-
|
|
927
|
+
_(
|
|
915
928
|
typeof n == "object",
|
|
916
929
|
`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`
|
|
917
|
-
),
|
|
930
|
+
), _(
|
|
918
931
|
!!n,
|
|
919
932
|
"The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it"
|
|
920
933
|
);
|
|
921
|
-
for (const [a,
|
|
934
|
+
for (const [a, c] of Object.entries(n)) {
|
|
922
935
|
const S = t[a];
|
|
923
|
-
|
|
936
|
+
_(
|
|
924
937
|
S,
|
|
925
938
|
`No field found in the fields config for "${a}"`
|
|
926
939
|
);
|
|
@@ -933,7 +946,7 @@ function Ne(o) {
|
|
|
933
946
|
...e[a],
|
|
934
947
|
nameTransformCasing: v,
|
|
935
948
|
type: p,
|
|
936
|
-
defaultValue:
|
|
949
|
+
defaultValue: c,
|
|
937
950
|
label: le(g, a, v)
|
|
938
951
|
};
|
|
939
952
|
}
|
|
@@ -942,53 +955,53 @@ function Ne(o) {
|
|
|
942
955
|
}
|
|
943
956
|
function Oe(o) {
|
|
944
957
|
const e = {};
|
|
945
|
-
|
|
958
|
+
_(!!o, "The steps config must be defined", TypeError), _(
|
|
946
959
|
typeof o == "object",
|
|
947
960
|
`The steps config must be an object, was (${typeof o})`,
|
|
948
961
|
TypeError
|
|
949
962
|
);
|
|
950
963
|
for (const [t, r] of Object.entries(o)) {
|
|
951
|
-
|
|
964
|
+
_(
|
|
952
965
|
typeof t == "string",
|
|
953
966
|
`Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
|
|
954
967
|
TypeError
|
|
955
|
-
),
|
|
968
|
+
), _(
|
|
956
969
|
we.test(t),
|
|
957
970
|
`The key "${t}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`
|
|
958
971
|
);
|
|
959
972
|
const s = t, {
|
|
960
973
|
fields: n,
|
|
961
974
|
title: a,
|
|
962
|
-
nameTransformCasing:
|
|
975
|
+
nameTransformCasing: c = ne,
|
|
963
976
|
description: S,
|
|
964
977
|
validateFields: g
|
|
965
978
|
} = r, p = s.toString().replace("step", "");
|
|
966
|
-
|
|
979
|
+
_(
|
|
967
980
|
n,
|
|
968
981
|
`Missing fields for step ${p} (${String(s)})`,
|
|
969
982
|
TypeError
|
|
970
|
-
),
|
|
983
|
+
), _(
|
|
971
984
|
typeof n == "object",
|
|
972
985
|
"Fields must be an object",
|
|
973
986
|
TypeError
|
|
974
|
-
),
|
|
987
|
+
), _(
|
|
975
988
|
Object.keys(n).length > 0,
|
|
976
989
|
`The fields config for step ${p} (${String(
|
|
977
990
|
s
|
|
978
991
|
)}) is empty. Please add a field`
|
|
979
|
-
),
|
|
992
|
+
), _(
|
|
980
993
|
typeof n == "object",
|
|
981
994
|
`The "fields" property must be an object. Was ${typeof n}`
|
|
982
995
|
);
|
|
983
996
|
const f = Ne({
|
|
984
|
-
defaultCasing:
|
|
997
|
+
defaultCasing: c,
|
|
985
998
|
fields: n,
|
|
986
999
|
validateFields: g
|
|
987
1000
|
});
|
|
988
1001
|
e[s] = {
|
|
989
1002
|
...e[s],
|
|
990
1003
|
title: a,
|
|
991
|
-
nameTransformCasing:
|
|
1004
|
+
nameTransformCasing: c,
|
|
992
1005
|
// Only add the description if it's defined
|
|
993
1006
|
...typeof S == "string" ? { description: S } : {},
|
|
994
1007
|
fields: f
|
|
@@ -1033,7 +1046,7 @@ let oe = class extends _e {
|
|
|
1033
1046
|
last: this.lastStep.step,
|
|
1034
1047
|
value: this.stepNumbers,
|
|
1035
1048
|
as: (n) => {
|
|
1036
|
-
if (
|
|
1049
|
+
if (_(
|
|
1037
1050
|
typeof n == "string",
|
|
1038
1051
|
`The type of the target transformation type must be a string, was ${typeof n}`
|
|
1039
1052
|
), n === "string")
|
|
@@ -1130,8 +1143,8 @@ let oe = class extends _e {
|
|
|
1130
1143
|
return !1;
|
|
1131
1144
|
const n = r[s];
|
|
1132
1145
|
if (n === null || typeof n != "object" || !ce(n, {
|
|
1133
|
-
defaultValue: (
|
|
1134
|
-
label: (
|
|
1146
|
+
defaultValue: (c) => c !== "undefined" && c !== null,
|
|
1147
|
+
label: (c) => typeof c == "string" || typeof c == "boolean" && !c,
|
|
1135
1148
|
nameTransformCasing: X,
|
|
1136
1149
|
type: xe
|
|
1137
1150
|
}))
|
|
@@ -1156,7 +1169,7 @@ let oe = class extends _e {
|
|
|
1156
1169
|
const r = this.value[e], s = `Unable to get the value for "${String(
|
|
1157
1170
|
e
|
|
1158
1171
|
)}.fields.${String(t)}"`;
|
|
1159
|
-
|
|
1172
|
+
_("fields" in r, s), _(
|
|
1160
1173
|
typeof r.fields == "object",
|
|
1161
1174
|
`${s} because "fields" is not an object. This shouldn't be the case, so please open an issue`
|
|
1162
1175
|
);
|
|
@@ -1221,7 +1234,7 @@ function Ie(o) {
|
|
|
1221
1234
|
return r(n);
|
|
1222
1235
|
};
|
|
1223
1236
|
}
|
|
1224
|
-
var
|
|
1237
|
+
var L;
|
|
1225
1238
|
((o) => {
|
|
1226
1239
|
o.DEFAULT_FORM_ALIAS = "Form";
|
|
1227
1240
|
function e(r, s) {
|
|
@@ -1242,18 +1255,18 @@ var x;
|
|
|
1242
1255
|
return (s) => /* @__PURE__ */ Te("form", { id: r, ...s });
|
|
1243
1256
|
}
|
|
1244
1257
|
o.createDefaultForm = t;
|
|
1245
|
-
})(
|
|
1258
|
+
})(L || (L = {}));
|
|
1246
1259
|
var Z;
|
|
1247
1260
|
((o) => {
|
|
1248
1261
|
o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
|
|
1249
1262
|
})(Z || (Z = {}));
|
|
1250
1263
|
function Me(o, e) {
|
|
1251
|
-
|
|
1264
|
+
_(
|
|
1252
1265
|
e in o,
|
|
1253
1266
|
`The target step ${e} is not a valid step key`
|
|
1254
1267
|
);
|
|
1255
1268
|
const t = o[e];
|
|
1256
|
-
|
|
1269
|
+
_("fields" in t, `No "fields" were found for ${e}`);
|
|
1257
1270
|
let r = {};
|
|
1258
1271
|
for (const [s, n] of Object.entries(
|
|
1259
1272
|
t.fields
|
|
@@ -1274,13 +1287,13 @@ class Ue extends oe {
|
|
|
1274
1287
|
getValue: () => this.value,
|
|
1275
1288
|
setValue: (s) => this.handlePostUpdate(s)
|
|
1276
1289
|
}), this.sync(), this.value = this.#e.enrichValues(this.value, (s) => {
|
|
1277
|
-
const n = `step${s}`, a = [n],
|
|
1290
|
+
const n = `step${s}`, a = [n], c = t?.id ?? n, S = k(this.value, a);
|
|
1278
1291
|
return {
|
|
1279
1292
|
createComponent: this.createStepSpecificComponentFactory(
|
|
1280
1293
|
a,
|
|
1281
1294
|
{
|
|
1282
1295
|
isStepSpecific: !0,
|
|
1283
|
-
defaultId:
|
|
1296
|
+
defaultId: c,
|
|
1284
1297
|
form: t
|
|
1285
1298
|
},
|
|
1286
1299
|
S
|
|
@@ -1291,18 +1304,18 @@ class Ue extends oe {
|
|
|
1291
1304
|
createFormComponent(e, t) {
|
|
1292
1305
|
const { render: r, enabledForSteps: s = "all", id: n = t } = e, a = {
|
|
1293
1306
|
id: n,
|
|
1294
|
-
steps:
|
|
1307
|
+
steps: k(this.value, s)
|
|
1295
1308
|
};
|
|
1296
|
-
return (
|
|
1309
|
+
return (c) => r(a, c);
|
|
1297
1310
|
}
|
|
1298
1311
|
createStepSpecificComponentImpl(e, t, r, s = {}) {
|
|
1299
1312
|
return (n) => ((a) => {
|
|
1300
|
-
const
|
|
1313
|
+
const c = {};
|
|
1301
1314
|
for (const [w, j] of Object.entries(s))
|
|
1302
1315
|
if (typeof j == "function")
|
|
1303
1316
|
try {
|
|
1304
1317
|
const i = j();
|
|
1305
|
-
|
|
1318
|
+
c[w] = i;
|
|
1306
1319
|
} catch (i) {
|
|
1307
1320
|
const l = i instanceof Error ? i.message : String(i);
|
|
1308
1321
|
throw new Error(
|
|
@@ -1318,61 +1331,61 @@ Original error: ${l}`,
|
|
|
1318
1331
|
);
|
|
1319
1332
|
}
|
|
1320
1333
|
else
|
|
1321
|
-
|
|
1334
|
+
c[w] = j;
|
|
1322
1335
|
const { defaultId: S, form: g } = t, { ctx: p } = r, [f] = e;
|
|
1323
|
-
|
|
1336
|
+
_(
|
|
1324
1337
|
this.steps.isValidStepKey(f),
|
|
1325
1338
|
`[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.`
|
|
1326
1339
|
);
|
|
1327
1340
|
const v = Number.parseInt(f.replace("step", ""));
|
|
1328
|
-
|
|
1341
|
+
_(
|
|
1329
1342
|
!Number.isNaN(v),
|
|
1330
1343
|
`[${f}:"createComponent"]: an error occurred while extracting the number`
|
|
1331
1344
|
);
|
|
1332
1345
|
const y = this.value[f];
|
|
1333
|
-
|
|
1346
|
+
_(
|
|
1334
1347
|
"fields" in y,
|
|
1335
1348
|
`[${f}:createComponent]: unable to find the "fields" for the current step`
|
|
1336
|
-
),
|
|
1349
|
+
), _(
|
|
1337
1350
|
typeof y.fields == "object",
|
|
1338
1351
|
`[${f}:createComponent]: the "fields" property must be an object, was ${typeof y.fields}`
|
|
1339
1352
|
);
|
|
1340
1353
|
const m = this.#e.createStepUpdaterFn(f), b = Ie((w) => {
|
|
1341
|
-
|
|
1342
|
-
const
|
|
1354
|
+
_(typeof w == "string", () => {
|
|
1355
|
+
const u = new Intl.ListFormat("en", {
|
|
1343
1356
|
style: "long",
|
|
1344
1357
|
type: "disjunction"
|
|
1345
1358
|
});
|
|
1346
|
-
return `[${f}:Field]: the "name" prop must be a string and a valid field for ${f}. Available fields include ${
|
|
1359
|
+
return `[${f}:Field]: the "name" prop must be a string and a valid field for ${f}. Available fields include ${u.format(
|
|
1347
1360
|
Object.keys(y.fields)
|
|
1348
1361
|
)}`;
|
|
1349
|
-
}),
|
|
1362
|
+
}), _(
|
|
1350
1363
|
w in y.fields,
|
|
1351
1364
|
`[${f}:Field]: the field "${w}" doesn't exist for the current step`
|
|
1352
|
-
),
|
|
1365
|
+
), _(
|
|
1353
1366
|
"update" in y,
|
|
1354
1367
|
`[${f}:Field]: No "update" function was found`
|
|
1355
1368
|
);
|
|
1356
|
-
const j = this.getValue(f, w), { label: i, nameTransformCasing: l, type:
|
|
1369
|
+
const j = this.getValue(f, w), { label: i, nameTransformCasing: l, type: h } = y.fields[w];
|
|
1357
1370
|
return {
|
|
1358
1371
|
defaultValue: j,
|
|
1359
1372
|
label: i,
|
|
1360
1373
|
nameTransformCasing: l,
|
|
1361
|
-
type:
|
|
1374
|
+
type: h,
|
|
1362
1375
|
name: w,
|
|
1363
|
-
onInputChange: (
|
|
1364
|
-
let
|
|
1365
|
-
if (typeof
|
|
1366
|
-
const
|
|
1376
|
+
onInputChange: (u) => {
|
|
1377
|
+
let d;
|
|
1378
|
+
if (typeof u == "function") {
|
|
1379
|
+
const E = this.getValue(
|
|
1367
1380
|
f,
|
|
1368
1381
|
w
|
|
1369
1382
|
);
|
|
1370
|
-
|
|
1383
|
+
d = u(E);
|
|
1371
1384
|
} else
|
|
1372
|
-
|
|
1385
|
+
d = u;
|
|
1373
1386
|
this.update({
|
|
1374
1387
|
targetStep: f,
|
|
1375
|
-
updater:
|
|
1388
|
+
updater: d,
|
|
1376
1389
|
fields: [`fields.${w}.defaultValue`]
|
|
1377
1390
|
});
|
|
1378
1391
|
}
|
|
@@ -1382,14 +1395,14 @@ Original error: ${l}`,
|
|
|
1382
1395
|
ctx: p,
|
|
1383
1396
|
onInputChange: m,
|
|
1384
1397
|
Field: b,
|
|
1385
|
-
...
|
|
1398
|
+
...c
|
|
1386
1399
|
};
|
|
1387
1400
|
if (g) {
|
|
1388
1401
|
const {
|
|
1389
|
-
alias: w =
|
|
1402
|
+
alias: w = L.DEFAULT_FORM_ALIAS,
|
|
1390
1403
|
...j
|
|
1391
1404
|
} = g, i = j.enabledForSteps ?? "all";
|
|
1392
|
-
return
|
|
1405
|
+
return L.isFormAvailable(
|
|
1393
1406
|
e,
|
|
1394
1407
|
i
|
|
1395
1408
|
) && (O = {
|
|
@@ -1400,7 +1413,7 @@ Original error: ${l}`,
|
|
|
1400
1413
|
return n(
|
|
1401
1414
|
{
|
|
1402
1415
|
...O,
|
|
1403
|
-
[
|
|
1416
|
+
[L.DEFAULT_FORM_ALIAS]: L.createDefaultForm(S)
|
|
1404
1417
|
},
|
|
1405
1418
|
a
|
|
1406
1419
|
);
|
|
@@ -1409,13 +1422,13 @@ Original error: ${l}`,
|
|
|
1409
1422
|
createStepSpecificComponentFactory(e, t, r) {
|
|
1410
1423
|
const s = this.createStepSpecificComponentImpl.bind(this), n = this.createDefaultValues.bind(this);
|
|
1411
1424
|
debugger;
|
|
1412
|
-
const a = this.value,
|
|
1425
|
+
const a = this.value, c = e[0], S = this.#e.createStepUpdaterFn(c).bind(this.#e);
|
|
1413
1426
|
function g(p, f) {
|
|
1414
1427
|
function v(m) {
|
|
1415
1428
|
return m ? { ctx: { ...r, ...m } } : { ctx: r };
|
|
1416
1429
|
}
|
|
1417
1430
|
function y() {
|
|
1418
|
-
return
|
|
1431
|
+
return _(
|
|
1419
1432
|
typeof p == "function",
|
|
1420
1433
|
"The first argument must be a function"
|
|
1421
1434
|
), s(
|
|
@@ -1428,33 +1441,33 @@ Original error: ${l}`,
|
|
|
1428
1441
|
const { useFormInstance: m, ctxData: b, debug: O } = p, w = new te({
|
|
1429
1442
|
debug: O,
|
|
1430
1443
|
prefix(l) {
|
|
1431
|
-
return `${l}-${
|
|
1444
|
+
return `${l}-${c}-createComponent`;
|
|
1432
1445
|
}
|
|
1433
1446
|
});
|
|
1434
1447
|
w.info("First argument is an object");
|
|
1435
|
-
const { [
|
|
1436
|
-
if (
|
|
1448
|
+
const { [c]: j, ...i } = a;
|
|
1449
|
+
if (_(
|
|
1437
1450
|
typeof f == "function",
|
|
1438
1451
|
"The second argument must be a function"
|
|
1439
1452
|
), m) {
|
|
1440
1453
|
const {
|
|
1441
1454
|
render: l,
|
|
1442
|
-
alias:
|
|
1443
|
-
} = m, [
|
|
1455
|
+
alias: h = Z.DEFAULT_FORM_INSTANCE_ALIAS
|
|
1456
|
+
} = m, [u] = e, d = n(u), E = b ? {
|
|
1444
1457
|
...r,
|
|
1445
1458
|
...b({ ctx: i })
|
|
1446
|
-
} : r, $ = { ctx:
|
|
1459
|
+
} : r, $ = { ctx: E, defaultValues: d };
|
|
1447
1460
|
return s(
|
|
1448
1461
|
e,
|
|
1449
1462
|
t,
|
|
1450
|
-
|
|
1463
|
+
E,
|
|
1451
1464
|
{
|
|
1452
|
-
[
|
|
1465
|
+
[h]: () => l($)
|
|
1453
1466
|
}
|
|
1454
1467
|
)(f);
|
|
1455
1468
|
}
|
|
1456
1469
|
if (b) {
|
|
1457
|
-
w.info('Option "ctxData" is defined'),
|
|
1470
|
+
w.info('Option "ctxData" is defined'), _(
|
|
1458
1471
|
typeof b == "function",
|
|
1459
1472
|
'Option "ctxData" must be a function'
|
|
1460
1473
|
);
|
|
@@ -1462,14 +1475,14 @@ Original error: ${l}`,
|
|
|
1462
1475
|
w.info(
|
|
1463
1476
|
`Addition context is: ${JSON.stringify(l, null, 2)}`
|
|
1464
1477
|
);
|
|
1465
|
-
const
|
|
1478
|
+
const h = {
|
|
1466
1479
|
...r,
|
|
1467
1480
|
...l
|
|
1468
1481
|
};
|
|
1469
1482
|
return w.info(
|
|
1470
|
-
`Resolved context is: ${JSON.stringify(
|
|
1483
|
+
`Resolved context is: ${JSON.stringify(h, null, 2)}`
|
|
1471
1484
|
), s(e, t, {
|
|
1472
|
-
ctx:
|
|
1485
|
+
ctx: h,
|
|
1473
1486
|
update: S
|
|
1474
1487
|
})(f);
|
|
1475
1488
|
}
|
|
@@ -1487,7 +1500,7 @@ Original error: ${l}`,
|
|
|
1487
1500
|
* @returns The created component for the step.
|
|
1488
1501
|
*/
|
|
1489
1502
|
createComponent(e, t) {
|
|
1490
|
-
const { stepData: r } = e, s =
|
|
1503
|
+
const { stepData: r } = e, s = k(
|
|
1491
1504
|
this.value,
|
|
1492
1505
|
r
|
|
1493
1506
|
);
|
|
@@ -1511,7 +1524,7 @@ class Re extends De {
|
|
|
1511
1524
|
});
|
|
1512
1525
|
}
|
|
1513
1526
|
createComponent(e, t) {
|
|
1514
|
-
const { stepData: r } = e, s =
|
|
1527
|
+
const { stepData: r } = e, s = k(
|
|
1515
1528
|
this.stepSchema.value,
|
|
1516
1529
|
r
|
|
1517
1530
|
);
|
|
@@ -1546,7 +1559,7 @@ function Pe() {
|
|
|
1546
1559
|
return f === v && (f !== 0 || 1 / f === 1 / v) || f !== f && v !== v;
|
|
1547
1560
|
}
|
|
1548
1561
|
var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, s = o.useEffect, n = o.useLayoutEffect, a = o.useDebugValue;
|
|
1549
|
-
function
|
|
1562
|
+
function c(f, v) {
|
|
1550
1563
|
var y = v(), m = r({ inst: { value: y, getSnapshot: v } }), b = m[0].inst, O = m[1];
|
|
1551
1564
|
return n(
|
|
1552
1565
|
function() {
|
|
@@ -1575,10 +1588,10 @@ function Pe() {
|
|
|
1575
1588
|
function g(f, v) {
|
|
1576
1589
|
return v();
|
|
1577
1590
|
}
|
|
1578
|
-
var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? g :
|
|
1591
|
+
var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? g : c;
|
|
1579
1592
|
return B.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : p, B;
|
|
1580
1593
|
}
|
|
1581
|
-
var
|
|
1594
|
+
var z = {};
|
|
1582
1595
|
/**
|
|
1583
1596
|
* @license React
|
|
1584
1597
|
* use-sync-external-store-shim.development.js
|
|
@@ -1614,7 +1627,7 @@ function Ke() {
|
|
|
1614
1627
|
w.value = b, w.getSnapshot = m, t(w) && j({ inst: w });
|
|
1615
1628
|
},
|
|
1616
1629
|
[y, b, m]
|
|
1617
|
-
),
|
|
1630
|
+
), c(
|
|
1618
1631
|
function() {
|
|
1619
1632
|
return t(w) && j({ inst: w }), y(function() {
|
|
1620
1633
|
t(w) && j({ inst: w });
|
|
@@ -1637,9 +1650,9 @@ function Ke() {
|
|
|
1637
1650
|
return m();
|
|
1638
1651
|
}
|
|
1639
1652
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1640
|
-
var s = R, n = typeof Object.is == "function" ? Object.is : o, a = s.useState,
|
|
1641
|
-
|
|
1642
|
-
})()),
|
|
1653
|
+
var s = R, n = typeof Object.is == "function" ? Object.is : o, a = s.useState, c = s.useEffect, S = s.useLayoutEffect, g = s.useDebugValue, p = !1, f = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
1654
|
+
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());
|
|
1655
|
+
})()), z;
|
|
1643
1656
|
}
|
|
1644
1657
|
var de;
|
|
1645
1658
|
function $e() {
|
|
@@ -1662,35 +1675,35 @@ function Ge() {
|
|
|
1662
1675
|
function t(g, p) {
|
|
1663
1676
|
return g === p && (g !== 0 || 1 / g === 1 / p) || g !== g && p !== p;
|
|
1664
1677
|
}
|
|
1665
|
-
var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect,
|
|
1678
|
+
var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect, c = o.useMemo, S = o.useDebugValue;
|
|
1666
1679
|
return H.useSyncExternalStoreWithSelector = function(g, p, f, v, y) {
|
|
1667
1680
|
var m = n(null);
|
|
1668
1681
|
if (m.current === null) {
|
|
1669
1682
|
var b = { hasValue: !1, value: null };
|
|
1670
1683
|
m.current = b;
|
|
1671
1684
|
} else b = m.current;
|
|
1672
|
-
m =
|
|
1685
|
+
m = c(
|
|
1673
1686
|
function() {
|
|
1674
|
-
function w(
|
|
1687
|
+
function w(u) {
|
|
1675
1688
|
if (!j) {
|
|
1676
|
-
if (j = !0, i =
|
|
1677
|
-
var
|
|
1678
|
-
if (y(
|
|
1679
|
-
return l =
|
|
1689
|
+
if (j = !0, i = u, u = v(u), y !== void 0 && b.hasValue) {
|
|
1690
|
+
var d = b.value;
|
|
1691
|
+
if (y(d, u))
|
|
1692
|
+
return l = d;
|
|
1680
1693
|
}
|
|
1681
|
-
return l =
|
|
1694
|
+
return l = u;
|
|
1682
1695
|
}
|
|
1683
|
-
if (
|
|
1684
|
-
var
|
|
1685
|
-
return y !== void 0 && y(
|
|
1696
|
+
if (d = l, r(i, u)) return d;
|
|
1697
|
+
var E = v(u);
|
|
1698
|
+
return y !== void 0 && y(d, E) ? (i = u, d) : (i = u, l = E);
|
|
1686
1699
|
}
|
|
1687
|
-
var j = !1, i, l,
|
|
1700
|
+
var j = !1, i, l, h = f === void 0 ? null : f;
|
|
1688
1701
|
return [
|
|
1689
1702
|
function() {
|
|
1690
1703
|
return w(p());
|
|
1691
1704
|
},
|
|
1692
|
-
|
|
1693
|
-
return w(
|
|
1705
|
+
h === null ? void 0 : function() {
|
|
1706
|
+
return w(h());
|
|
1694
1707
|
}
|
|
1695
1708
|
];
|
|
1696
1709
|
},
|
|
@@ -1705,7 +1718,7 @@ function Ge() {
|
|
|
1705
1718
|
), S(O), O;
|
|
1706
1719
|
}, H;
|
|
1707
1720
|
}
|
|
1708
|
-
var
|
|
1721
|
+
var J = {};
|
|
1709
1722
|
/**
|
|
1710
1723
|
* @license React
|
|
1711
1724
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -1722,36 +1735,36 @@ function We() {
|
|
|
1722
1735
|
return g === p && (g !== 0 || 1 / g === 1 / p) || g !== g && p !== p;
|
|
1723
1736
|
}
|
|
1724
1737
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1725
|
-
var e = R, t = $e(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, a = e.useEffect,
|
|
1726
|
-
|
|
1738
|
+
var e = R, t = $e(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, a = e.useEffect, c = e.useMemo, S = e.useDebugValue;
|
|
1739
|
+
J.useSyncExternalStoreWithSelector = function(g, p, f, v, y) {
|
|
1727
1740
|
var m = n(null);
|
|
1728
1741
|
if (m.current === null) {
|
|
1729
1742
|
var b = { hasValue: !1, value: null };
|
|
1730
1743
|
m.current = b;
|
|
1731
1744
|
} else b = m.current;
|
|
1732
|
-
m =
|
|
1745
|
+
m = c(
|
|
1733
1746
|
function() {
|
|
1734
|
-
function w(
|
|
1747
|
+
function w(u) {
|
|
1735
1748
|
if (!j) {
|
|
1736
|
-
if (j = !0, i =
|
|
1737
|
-
var
|
|
1738
|
-
if (y(
|
|
1739
|
-
return l =
|
|
1749
|
+
if (j = !0, i = u, u = v(u), y !== void 0 && b.hasValue) {
|
|
1750
|
+
var d = b.value;
|
|
1751
|
+
if (y(d, u))
|
|
1752
|
+
return l = d;
|
|
1740
1753
|
}
|
|
1741
|
-
return l =
|
|
1754
|
+
return l = u;
|
|
1742
1755
|
}
|
|
1743
|
-
if (
|
|
1744
|
-
return
|
|
1745
|
-
var
|
|
1746
|
-
return y !== void 0 && y(
|
|
1756
|
+
if (d = l, r(i, u))
|
|
1757
|
+
return d;
|
|
1758
|
+
var E = v(u);
|
|
1759
|
+
return y !== void 0 && y(d, E) ? (i = u, d) : (i = u, l = E);
|
|
1747
1760
|
}
|
|
1748
|
-
var j = !1, i, l,
|
|
1761
|
+
var j = !1, i, l, h = f === void 0 ? null : f;
|
|
1749
1762
|
return [
|
|
1750
1763
|
function() {
|
|
1751
1764
|
return w(p());
|
|
1752
1765
|
},
|
|
1753
|
-
|
|
1754
|
-
return w(
|
|
1766
|
+
h === null ? void 0 : function() {
|
|
1767
|
+
return w(h());
|
|
1755
1768
|
}
|
|
1756
1769
|
];
|
|
1757
1770
|
},
|
|
@@ -1765,7 +1778,7 @@ function We() {
|
|
|
1765
1778
|
[O]
|
|
1766
1779
|
), S(O), O;
|
|
1767
1780
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1768
|
-
})()),
|
|
1781
|
+
})()), J;
|
|
1769
1782
|
}
|
|
1770
1783
|
var ye;
|
|
1771
1784
|
function He() {
|
|
@@ -1773,7 +1786,7 @@ function He() {
|
|
|
1773
1786
|
}
|
|
1774
1787
|
var Be = He();
|
|
1775
1788
|
function Q(o, e) {
|
|
1776
|
-
|
|
1789
|
+
_(
|
|
1777
1790
|
typeof e == "string",
|
|
1778
1791
|
`The target step must be a string, was ${typeof e}`
|
|
1779
1792
|
);
|
|
@@ -1781,12 +1794,12 @@ function Q(o, e) {
|
|
|
1781
1794
|
type: "disjunction",
|
|
1782
1795
|
style: "long"
|
|
1783
1796
|
}).format(t("array.string.untyped"));
|
|
1784
|
-
|
|
1797
|
+
_(
|
|
1785
1798
|
we.test(e),
|
|
1786
1799
|
`The target step must match the following format: "step{number}". Available steps are ${n}`
|
|
1787
1800
|
);
|
|
1788
1801
|
const a = Number.parseInt(e.replace("step", ""));
|
|
1789
|
-
return
|
|
1802
|
+
return _(
|
|
1790
1803
|
r(a),
|
|
1791
1804
|
`The step number "${a}" is not a valid step number. Valid step numbers include ${n}`,
|
|
1792
1805
|
TypeError
|
|
@@ -1823,8 +1836,8 @@ function ge(o) {
|
|
|
1823
1836
|
}
|
|
1824
1837
|
function Qe(o) {
|
|
1825
1838
|
const e = je(o);
|
|
1826
|
-
function t(
|
|
1827
|
-
const { targetStep: S, notFoundMessage: g, isDataGuaranteed: p } =
|
|
1839
|
+
function t(c) {
|
|
1840
|
+
const { targetStep: S, notFoundMessage: g, isDataGuaranteed: p } = c, f = e({
|
|
1828
1841
|
targetStep: S
|
|
1829
1842
|
}), v = g ? a({ targetStep: S }, g) : (y) => /* @__PURE__ */ ie("div", { ...y, children: [
|
|
1830
1843
|
"No data found for step ",
|
|
@@ -1843,7 +1856,7 @@ function Qe(o) {
|
|
|
1843
1856
|
NoCurrentData: v
|
|
1844
1857
|
};
|
|
1845
1858
|
}
|
|
1846
|
-
function r(
|
|
1859
|
+
function r(c) {
|
|
1847
1860
|
const S = e(
|
|
1848
1861
|
(O) => O.stepSchema.steps.value.length
|
|
1849
1862
|
), {
|
|
@@ -1851,7 +1864,7 @@ function Qe(o) {
|
|
|
1851
1864
|
maxProgressValue: p = 100,
|
|
1852
1865
|
totalSteps: f = S,
|
|
1853
1866
|
progressTextTransformer: v
|
|
1854
|
-
} =
|
|
1867
|
+
} = c, y = Q(o, g), m = y / f * p, b = v ? n(
|
|
1855
1868
|
{ targetStep: g, maxProgressValue: p, totalSteps: f },
|
|
1856
1869
|
v
|
|
1857
1870
|
) : (O) => /* @__PURE__ */ ie("div", { ...O, children: [
|
|
@@ -1866,16 +1879,16 @@ function Qe(o) {
|
|
|
1866
1879
|
ProgressText: b
|
|
1867
1880
|
};
|
|
1868
1881
|
}
|
|
1869
|
-
function s(
|
|
1882
|
+
function s(c) {
|
|
1870
1883
|
const g = e((f) => f.storage).get(), p = !!(g && typeof g == "object" && Object.keys(g).length > 0);
|
|
1871
|
-
return
|
|
1884
|
+
return c ? c(p) : p;
|
|
1872
1885
|
}
|
|
1873
|
-
function n(
|
|
1874
|
-
const g = o.getSnapshot().stepSchema.steps.value.length, { targetStep: p, maxProgressValue: f = 100, totalSteps: v = g } =
|
|
1886
|
+
function n(c, S) {
|
|
1887
|
+
const g = o.getSnapshot().stepSchema.steps.value.length, { targetStep: p, maxProgressValue: f = 100, totalSteps: v = g } = c;
|
|
1875
1888
|
return ge({ targetStep: p, maxProgressValue: f, totalSteps: v })(S);
|
|
1876
1889
|
}
|
|
1877
|
-
function a(
|
|
1878
|
-
return Q(o,
|
|
1890
|
+
function a(c, S) {
|
|
1891
|
+
return Q(o, c.targetStep), ge(c)(S);
|
|
1879
1892
|
}
|
|
1880
1893
|
return {
|
|
1881
1894
|
// MultiStepFormContext: Context,
|