@jfdevelops/react-multi-step-form 1.0.0-alpha.3 → 1.0.0-alpha.4
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 +13 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1048 -648
- package/dist/index.mjs.map +1 -1
- package/dist/types/step-schema.d.ts +6 -8
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
1
|
+
import { jsx as $e, jsxs as te } from "react/jsx-runtime";
|
|
2
|
+
import W from "react";
|
|
3
|
+
function _e(o, ...e) {
|
|
4
4
|
return () => String.raw({ raw: o }, ...e);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function j(o, e, t = Error) {
|
|
7
7
|
if (!o) {
|
|
8
|
-
const r = typeof e == "function" ? e() :
|
|
8
|
+
const r = typeof e == "function" ? e() : _e`${e}`();
|
|
9
9
|
throw new t(r);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
class
|
|
12
|
+
const G = "MultiStepFormSchema";
|
|
13
|
+
class me {
|
|
14
14
|
debug;
|
|
15
|
-
prefix =
|
|
15
|
+
prefix = G;
|
|
16
16
|
includeTimestamp = !1;
|
|
17
17
|
throwOnError = !1;
|
|
18
18
|
constructor(e) {
|
|
19
19
|
if (this.debug = e?.debug ?? !1, this.debug && e?.debug) {
|
|
20
20
|
const {
|
|
21
21
|
includeTimestamp: t = !1,
|
|
22
|
-
prefix: r =
|
|
23
|
-
throwOnError:
|
|
22
|
+
prefix: r = G,
|
|
23
|
+
throwOnError: n = !1
|
|
24
24
|
} = e;
|
|
25
|
-
this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(
|
|
25
|
+
this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(G), this.throwOnError = n;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
wrapValue(e, t) {
|
|
@@ -39,34 +39,34 @@ class ue {
|
|
|
39
39
|
formatPrefix(e) {
|
|
40
40
|
if (!e)
|
|
41
41
|
return this.prefix;
|
|
42
|
-
const { action: t, value: r, wrapWith:
|
|
42
|
+
const { action: t, value: r, wrapWith: n } = e;
|
|
43
43
|
if (t === "replace")
|
|
44
|
-
return this.wrapValue(
|
|
45
|
-
const { delimiter:
|
|
44
|
+
return this.wrapValue(n ?? "[]", r);
|
|
45
|
+
const { delimiter: s } = e;
|
|
46
46
|
return t === "append" ? `${this.wrapValue(
|
|
47
|
-
|
|
47
|
+
n?.originalPrefix ?? "[]",
|
|
48
48
|
this.prefix
|
|
49
|
-
)}${
|
|
50
|
-
|
|
49
|
+
)}${s}${this.wrapValue(
|
|
50
|
+
n?.addedPrefix ?? "[]",
|
|
51
51
|
r
|
|
52
52
|
)}`.trim() : t === "prepend" ? `${this.wrapValue(
|
|
53
|
-
|
|
53
|
+
n?.addedPrefix ?? "[]",
|
|
54
54
|
r
|
|
55
|
-
)}${
|
|
56
|
-
|
|
55
|
+
)}${s}${this.wrapValue(
|
|
56
|
+
n?.originalPrefix ?? "[]",
|
|
57
57
|
this.prefix
|
|
58
58
|
)}`.trim() : this.prefix;
|
|
59
59
|
}
|
|
60
60
|
formatMessage(e, t, r) {
|
|
61
61
|
const {
|
|
62
|
-
includeTimestamp:
|
|
63
|
-
prefix:
|
|
62
|
+
includeTimestamp: n = this.includeTimestamp,
|
|
63
|
+
prefix: s,
|
|
64
64
|
logLevelOptions: i
|
|
65
|
-
} = r ?? {},
|
|
65
|
+
} = r ?? {}, y = this.formatPrefix(s), b = this.wrapValue(
|
|
66
66
|
i?.wrapWith ?? "[]",
|
|
67
67
|
(i?.level ?? e).toUpperCase()
|
|
68
|
-
), f = `${
|
|
69
|
-
return
|
|
68
|
+
), f = `${y} ${b} ${t}`;
|
|
69
|
+
return n ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${f}` : f;
|
|
70
70
|
}
|
|
71
71
|
info(e, t) {
|
|
72
72
|
this.debug && console.info(this.formatMessage("info", e, t));
|
|
@@ -82,21 +82,21 @@ class ue {
|
|
|
82
82
|
throw new Error(r);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const
|
|
86
|
-
class
|
|
85
|
+
const re = '"window" in undefined. No storage is available', Q = "MultiStepForm";
|
|
86
|
+
class ye {
|
|
87
87
|
key;
|
|
88
88
|
store;
|
|
89
89
|
data;
|
|
90
90
|
log;
|
|
91
91
|
isWindowUndefined;
|
|
92
92
|
constructor(e) {
|
|
93
|
-
const { key: t, data: r, store:
|
|
94
|
-
this.log = new
|
|
95
|
-
prefix:
|
|
96
|
-
}), this.key = t, this.data = r,
|
|
93
|
+
const { key: t, data: r, store: n } = e;
|
|
94
|
+
this.log = new me({
|
|
95
|
+
prefix: Q
|
|
96
|
+
}), this.key = t, this.data = r, n ? (this.store = n, this.isWindowUndefined = !1) : typeof window < "u" ? (this.store = window.localStorage, this.isWindowUndefined = !1) : (this.isWindowUndefined = !0, this.log.warn(re));
|
|
97
97
|
}
|
|
98
98
|
throwOnEmptyStore() {
|
|
99
|
-
|
|
99
|
+
j(this.store, () => this.isWindowUndefined ? re : "No storage available");
|
|
100
100
|
}
|
|
101
101
|
resolveValue(e) {
|
|
102
102
|
if (typeof e == "object")
|
|
@@ -126,7 +126,7 @@ class ce {
|
|
|
126
126
|
this.store.setItem(this.key, t);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
129
|
+
const we = [
|
|
130
130
|
"sentence",
|
|
131
131
|
"title",
|
|
132
132
|
"camel",
|
|
@@ -137,8 +137,8 @@ const ve = [
|
|
|
137
137
|
"screaming-snake",
|
|
138
138
|
"flat",
|
|
139
139
|
"kebab"
|
|
140
|
-
],
|
|
141
|
-
function
|
|
140
|
+
], X = "title";
|
|
141
|
+
function Te(o, e) {
|
|
142
142
|
const t = o.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).map((r) => r.toLowerCase());
|
|
143
143
|
switch (e) {
|
|
144
144
|
case "sentence":
|
|
@@ -165,13 +165,13 @@ function _e(o, e) {
|
|
|
165
165
|
return o;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
return typeof o != "string" ? !1 :
|
|
168
|
+
function J(o) {
|
|
169
|
+
return typeof o != "string" ? !1 : we.includes(o);
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
171
|
+
function ge(o, e = X) {
|
|
172
|
+
return J(o) ? o : e;
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const Ae = [
|
|
175
175
|
"string",
|
|
176
176
|
"string.phone",
|
|
177
177
|
"string.email",
|
|
@@ -181,11 +181,303 @@ const we = [
|
|
|
181
181
|
"date",
|
|
182
182
|
"dateTime",
|
|
183
183
|
"boolean.switch"
|
|
184
|
-
],
|
|
185
|
-
function
|
|
186
|
-
return typeof o == "string" &&
|
|
184
|
+
], ne = "string";
|
|
185
|
+
function Ce(o) {
|
|
186
|
+
return typeof o == "string" && Ae.includes(o);
|
|
187
|
+
}
|
|
188
|
+
function U(o, e, t) {
|
|
189
|
+
const r = [], n = new Set(o), s = t ? t.format(o.map((i) => `${i}`)) : `[${o.join(", ")}]`;
|
|
190
|
+
for (let i = 0; i < e.length; i++) {
|
|
191
|
+
const y = e[i];
|
|
192
|
+
n.has(y) || r.push(
|
|
193
|
+
`Extra element at index ${i}: "${y}" is not in ${s}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
return e.some((i) => n.has(i)) || r.push(
|
|
197
|
+
`Array must contain at least one valid element from ${s}`
|
|
198
|
+
), r.length > 0 ? { status: "error", errors: r } : { status: "success" };
|
|
187
199
|
}
|
|
188
|
-
function
|
|
200
|
+
function R(o, e) {
|
|
201
|
+
const t = (r, n) => `❌ ${n + 1}. ${r}`;
|
|
202
|
+
return o.map((r, n) => t(r, n)).join(`
|
|
203
|
+
`);
|
|
204
|
+
}
|
|
205
|
+
function se(o) {
|
|
206
|
+
return Object.keys(o);
|
|
207
|
+
}
|
|
208
|
+
var C;
|
|
209
|
+
((o) => {
|
|
210
|
+
function e(a, l) {
|
|
211
|
+
return l.split(".").reduce((h, u) => h?.[u], a);
|
|
212
|
+
}
|
|
213
|
+
function t(a, l, h) {
|
|
214
|
+
const u = l.split(".");
|
|
215
|
+
let d = a;
|
|
216
|
+
for (let E = 0; E < u.length; E++) {
|
|
217
|
+
const _ = u[E];
|
|
218
|
+
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[_]);
|
|
219
|
+
}
|
|
220
|
+
return d;
|
|
221
|
+
}
|
|
222
|
+
o.setBy = t;
|
|
223
|
+
function r(a) {
|
|
224
|
+
return a.filter((l) => !a.some((h) => h !== l && l.startsWith(h + ".")));
|
|
225
|
+
}
|
|
226
|
+
function n(a, ...l) {
|
|
227
|
+
const h = r(l);
|
|
228
|
+
if (h.length === 1)
|
|
229
|
+
return e(a, h[0]);
|
|
230
|
+
const u = {};
|
|
231
|
+
for (const d of h) {
|
|
232
|
+
const E = e(a, d);
|
|
233
|
+
t(u, d, E);
|
|
234
|
+
}
|
|
235
|
+
return u;
|
|
236
|
+
}
|
|
237
|
+
o.pickBy = n;
|
|
238
|
+
function s(a) {
|
|
239
|
+
const l = [];
|
|
240
|
+
function h(u, d = "") {
|
|
241
|
+
if (u == null || typeof u != "object" || Array.isArray(u))
|
|
242
|
+
return;
|
|
243
|
+
const E = Object.keys(u);
|
|
244
|
+
for (const _ of E) {
|
|
245
|
+
const T = d ? `${d}.${_}` : _;
|
|
246
|
+
l.push(T);
|
|
247
|
+
const A = u[_];
|
|
248
|
+
A != null && typeof A == "object" && !Array.isArray(A) && h(A, T);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return h(a), l;
|
|
252
|
+
}
|
|
253
|
+
o.createDeep = s;
|
|
254
|
+
function i(a) {
|
|
255
|
+
if (a === null) return "null";
|
|
256
|
+
if (Array.isArray(a)) return "Array";
|
|
257
|
+
const l = typeof a;
|
|
258
|
+
if (l !== "object") return l;
|
|
259
|
+
const h = a?.constructor?.name;
|
|
260
|
+
return h && h !== "Object" ? h : "object";
|
|
261
|
+
}
|
|
262
|
+
function y(a) {
|
|
263
|
+
if (!a) return [];
|
|
264
|
+
const l = [], h = /[^.[\]]+|\[(\d+)\]/g;
|
|
265
|
+
let u;
|
|
266
|
+
for (; u = h.exec(a); )
|
|
267
|
+
l.push(u[1] ?? u[0]);
|
|
268
|
+
return l;
|
|
269
|
+
}
|
|
270
|
+
function b(a, l) {
|
|
271
|
+
if (!a) return;
|
|
272
|
+
if (typeof a == "function")
|
|
273
|
+
return a;
|
|
274
|
+
const h = y(l);
|
|
275
|
+
let u = a, d;
|
|
276
|
+
for (const E of h) {
|
|
277
|
+
if (!u) break;
|
|
278
|
+
if (typeof u == "function") {
|
|
279
|
+
d = u;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
if (u = u[E], typeof u == "function") {
|
|
283
|
+
d = u;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return d;
|
|
288
|
+
}
|
|
289
|
+
function f(a, l, h) {
|
|
290
|
+
const u = b(h, l);
|
|
291
|
+
return u ? u(a, l) : i(a);
|
|
292
|
+
}
|
|
293
|
+
function g(a) {
|
|
294
|
+
return typeof a == "object" && a !== null;
|
|
295
|
+
}
|
|
296
|
+
function c(a, l, h, u, d) {
|
|
297
|
+
if (a === l)
|
|
298
|
+
return u;
|
|
299
|
+
if (a === null || l === null || typeof a != "object" || typeof l != "object") {
|
|
300
|
+
const _ = h || "(root)";
|
|
301
|
+
return typeof a != typeof l ? (u.push({
|
|
302
|
+
path: _,
|
|
303
|
+
expected: f(a, _, d.transformExpected),
|
|
304
|
+
actual: l,
|
|
305
|
+
reason: "type-mismatch"
|
|
306
|
+
}), u) : (d.includeValueMismatch && u.push({
|
|
307
|
+
path: _,
|
|
308
|
+
expected: f(a, _, d.transformExpected),
|
|
309
|
+
actual: l,
|
|
310
|
+
reason: "value-mismatch"
|
|
311
|
+
}), u);
|
|
312
|
+
}
|
|
313
|
+
if (Array.isArray(a) || Array.isArray(l)) {
|
|
314
|
+
if (!Array.isArray(a) || !Array.isArray(l)) {
|
|
315
|
+
const T = h || "(root)";
|
|
316
|
+
return u.push({
|
|
317
|
+
path: T,
|
|
318
|
+
expected: f(a, T, d.transformExpected),
|
|
319
|
+
actual: l,
|
|
320
|
+
reason: "type-mismatch"
|
|
321
|
+
}), u;
|
|
322
|
+
}
|
|
323
|
+
const _ = a.length;
|
|
324
|
+
for (let T = 0; T < _; T++) {
|
|
325
|
+
const A = a[T], x = l[T], k = h === "" ? `[${T}]` : `${h}[${T}]`;
|
|
326
|
+
if (T >= l.length) {
|
|
327
|
+
u.push({
|
|
328
|
+
path: k,
|
|
329
|
+
expected: f(A, k, d.transformExpected),
|
|
330
|
+
actual: void 0,
|
|
331
|
+
reason: "missing-key"
|
|
332
|
+
});
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
c(A, x, k, u, d);
|
|
336
|
+
}
|
|
337
|
+
if (l.length > a.length)
|
|
338
|
+
for (let T = a.length; T < l.length; T++) {
|
|
339
|
+
const A = h === "" ? `[${T}]` : `${h}[${T}]`;
|
|
340
|
+
u.push({
|
|
341
|
+
path: A,
|
|
342
|
+
expected: void 0,
|
|
343
|
+
actual: l[T],
|
|
344
|
+
reason: "extra-key"
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return u;
|
|
348
|
+
}
|
|
349
|
+
if (g(a) && g(l)) {
|
|
350
|
+
const _ = Object.keys(a), T = Object.keys(l);
|
|
351
|
+
for (const A of _) {
|
|
352
|
+
const x = a[A], k = l[A], F = h ? `${h}.${A}` : A;
|
|
353
|
+
if (!(A in l)) {
|
|
354
|
+
u.push({
|
|
355
|
+
path: F,
|
|
356
|
+
expected: f(x, F, d.transformExpected),
|
|
357
|
+
actual: void 0,
|
|
358
|
+
reason: "missing-key"
|
|
359
|
+
});
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
c(x, k, F, u, d);
|
|
363
|
+
}
|
|
364
|
+
for (const A of T)
|
|
365
|
+
if (!(A in a)) {
|
|
366
|
+
const x = h ? `${h}.${A}` : A;
|
|
367
|
+
u.push({
|
|
368
|
+
path: x,
|
|
369
|
+
expected: void 0,
|
|
370
|
+
actual: l[A],
|
|
371
|
+
reason: "extra-key"
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
return u;
|
|
375
|
+
}
|
|
376
|
+
const E = h || "(root)";
|
|
377
|
+
return typeof a != typeof l ? u.push({
|
|
378
|
+
path: E,
|
|
379
|
+
expected: f(a, E, d.transformExpected),
|
|
380
|
+
actual: l,
|
|
381
|
+
reason: "type-mismatch"
|
|
382
|
+
}) : d.includeValueMismatch && u.push({
|
|
383
|
+
path: E,
|
|
384
|
+
expected: f(a, E, d.transformExpected),
|
|
385
|
+
actual: l,
|
|
386
|
+
reason: "value-mismatch"
|
|
387
|
+
}), u;
|
|
388
|
+
}
|
|
389
|
+
function m(a, l, h, u) {
|
|
390
|
+
const d = n(a, ...l), E = [], _ = l.length === 1 ? l[0] : "";
|
|
391
|
+
return c(d, h, _, E, {
|
|
392
|
+
transformExpected: u?.transformExpected
|
|
393
|
+
}), {
|
|
394
|
+
ok: E.length === 0,
|
|
395
|
+
mismatches: E
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
o.equalsAtPaths = m;
|
|
399
|
+
function p(a) {
|
|
400
|
+
if (a === void 0) return "undefined";
|
|
401
|
+
if (typeof a == "string") return JSON.stringify(a);
|
|
402
|
+
try {
|
|
403
|
+
return JSON.stringify(a, null, 2);
|
|
404
|
+
} catch {
|
|
405
|
+
return String(a);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function v(a) {
|
|
409
|
+
switch (a.reason) {
|
|
410
|
+
case "missing-key":
|
|
411
|
+
return "Missing key";
|
|
412
|
+
case "extra-key":
|
|
413
|
+
return "Extra key";
|
|
414
|
+
case "type-mismatch":
|
|
415
|
+
return "Type mismatch";
|
|
416
|
+
case "value-mismatch":
|
|
417
|
+
return "Value mismatch";
|
|
418
|
+
default:
|
|
419
|
+
return a.reason;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function S(a) {
|
|
423
|
+
if (a.ok || a.mismatches.length === 0)
|
|
424
|
+
return "No mismatches.";
|
|
425
|
+
const l = [];
|
|
426
|
+
for (const h of a.mismatches)
|
|
427
|
+
l.push(
|
|
428
|
+
`
|
|
429
|
+
● ${v(h)} at "${h.path}":`,
|
|
430
|
+
` expected: ${p(h.expected)}`,
|
|
431
|
+
` actual: ${p(h.actual)}`,
|
|
432
|
+
""
|
|
433
|
+
// blank line between entries
|
|
434
|
+
);
|
|
435
|
+
return l.at(-1) === "" && l.pop(), l.join(`
|
|
436
|
+
`);
|
|
437
|
+
}
|
|
438
|
+
o.formatMismatches = S;
|
|
439
|
+
function O(a) {
|
|
440
|
+
const l = S(a);
|
|
441
|
+
l !== "No mismatches." && console.error(l);
|
|
442
|
+
}
|
|
443
|
+
o.printMismatches = O;
|
|
444
|
+
function $(a, l, h) {
|
|
445
|
+
const u = l.split(".");
|
|
446
|
+
function d(E, _) {
|
|
447
|
+
const T = u[_], A = Array.isArray(E) ? [...E] : { ...E };
|
|
448
|
+
if (_ === u.length - 1) {
|
|
449
|
+
let P = E && typeof E == "object" ? A : {};
|
|
450
|
+
return P = {
|
|
451
|
+
...P,
|
|
452
|
+
[T]: h
|
|
453
|
+
}, P;
|
|
454
|
+
}
|
|
455
|
+
const x = E && typeof E == "object" ? E[T] : void 0, k = d(x ?? {}, _ + 1);
|
|
456
|
+
let F = E && typeof E == "object" ? A : {};
|
|
457
|
+
return F = {
|
|
458
|
+
...F,
|
|
459
|
+
[T]: k
|
|
460
|
+
}, F;
|
|
461
|
+
}
|
|
462
|
+
return d(a, 0);
|
|
463
|
+
}
|
|
464
|
+
function w(a, l, h) {
|
|
465
|
+
const u = r(l);
|
|
466
|
+
if (u.length === 0) return a;
|
|
467
|
+
let d = a;
|
|
468
|
+
if (u.length === 1) {
|
|
469
|
+
const E = u[0];
|
|
470
|
+
return d = $(d, E, h), d;
|
|
471
|
+
}
|
|
472
|
+
for (const E of u) {
|
|
473
|
+
const _ = e(h, E);
|
|
474
|
+
d = $(d, E, _);
|
|
475
|
+
}
|
|
476
|
+
return d;
|
|
477
|
+
}
|
|
478
|
+
o.updateAt = w;
|
|
479
|
+
})(C || (C = {}));
|
|
480
|
+
function be(o, e) {
|
|
189
481
|
const t = o["~standard"].validate(e);
|
|
190
482
|
if (t instanceof Promise)
|
|
191
483
|
throw new TypeError("Schema validation must be synchronous", {
|
|
@@ -195,7 +487,7 @@ function fe(o, e) {
|
|
|
195
487
|
throw new Error(JSON.stringify(t.issues, null, 2));
|
|
196
488
|
return t.value;
|
|
197
489
|
}
|
|
198
|
-
class
|
|
490
|
+
class Se {
|
|
199
491
|
listeners = /* @__PURE__ */ new Set();
|
|
200
492
|
constructor() {
|
|
201
493
|
this.subscribe = this.subscribe.bind(this);
|
|
@@ -213,250 +505,253 @@ class pe {
|
|
|
213
505
|
onUnsubscribe() {
|
|
214
506
|
}
|
|
215
507
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
508
|
+
var V;
|
|
509
|
+
((o) => {
|
|
510
|
+
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, ...})';
|
|
511
|
+
function e(n) {
|
|
512
|
+
return !!(n && typeof n == "string" && n === "all");
|
|
513
|
+
}
|
|
514
|
+
o.isAll = e;
|
|
515
|
+
function t(n, s) {
|
|
516
|
+
return Array.isArray(n) ? s ? n.every((i) => s.includes(i)) : !0 : !1;
|
|
517
|
+
}
|
|
518
|
+
o.isTuple = t;
|
|
519
|
+
function r(n, s) {
|
|
520
|
+
if (!n)
|
|
521
|
+
return !1;
|
|
522
|
+
const i = Object.keys(n);
|
|
523
|
+
return i.length === 0 || s && !i.every((y) => s.includes(y)) ? !1 : Object.entries(n).every(([y, b]) => b === !0);
|
|
524
|
+
}
|
|
525
|
+
o.isObject = r;
|
|
526
|
+
})(V || (V = {}));
|
|
527
|
+
function M(o) {
|
|
528
|
+
j(o.includes("step"), "Can't extract a valid step number since");
|
|
234
529
|
const e = o.replace("step", "");
|
|
235
|
-
return
|
|
530
|
+
return j(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
|
|
236
531
|
}
|
|
237
|
-
function
|
|
532
|
+
function H(o) {
|
|
238
533
|
return function(e) {
|
|
239
|
-
const { step: t } = e, r = `step${t}`,
|
|
240
|
-
return { step: t, data:
|
|
534
|
+
const { step: t } = e, r = `step${t}`, n = o[r];
|
|
535
|
+
return { step: t, data: n };
|
|
241
536
|
};
|
|
242
537
|
}
|
|
243
|
-
function
|
|
538
|
+
function oe(o, e) {
|
|
244
539
|
return e.reduce((t, r) => {
|
|
245
|
-
const
|
|
246
|
-
step:
|
|
540
|
+
const n = M(r), { data: s } = H(o)({
|
|
541
|
+
step: n
|
|
247
542
|
});
|
|
248
|
-
for (const [i,
|
|
249
|
-
typeof
|
|
250
|
-
return t[r] =
|
|
543
|
+
for (const [i, y] of Object.entries(s))
|
|
544
|
+
typeof y == "function" && i !== "update" || (s[i] = y);
|
|
545
|
+
return t[r] = s, t;
|
|
251
546
|
}, {});
|
|
252
547
|
}
|
|
253
|
-
function
|
|
548
|
+
function I(o, e) {
|
|
254
549
|
const t = new Intl.ListFormat("en", {
|
|
255
550
|
style: "long",
|
|
256
551
|
type: "disjunction"
|
|
257
|
-
}), r = Object.keys(o),
|
|
552
|
+
}), r = Object.keys(o), n = () => `"stepData" must be set to an array of available steps (${t.format(
|
|
258
553
|
r
|
|
259
554
|
)})`;
|
|
260
555
|
if (e === "all") {
|
|
261
|
-
let
|
|
556
|
+
let s = {};
|
|
262
557
|
for (const i of r)
|
|
263
|
-
|
|
264
|
-
...
|
|
265
|
-
[i]:
|
|
266
|
-
step:
|
|
558
|
+
s = {
|
|
559
|
+
...s,
|
|
560
|
+
[i]: H(o)({
|
|
561
|
+
step: M(i)
|
|
267
562
|
})
|
|
268
563
|
};
|
|
269
564
|
return Object.fromEntries(
|
|
270
565
|
r.map((i) => [
|
|
271
566
|
i,
|
|
272
|
-
|
|
273
|
-
step:
|
|
567
|
+
H(o)({
|
|
568
|
+
step: M(i)
|
|
274
569
|
})
|
|
275
570
|
])
|
|
276
571
|
);
|
|
277
572
|
}
|
|
278
573
|
if (Array.isArray(e))
|
|
279
|
-
return
|
|
280
|
-
e.every((
|
|
574
|
+
return j(
|
|
575
|
+
e.every((s) => r.includes(s)),
|
|
281
576
|
() => {
|
|
282
|
-
const
|
|
577
|
+
const s = U(
|
|
283
578
|
e,
|
|
284
|
-
r.map((i) =>
|
|
579
|
+
r.map((i) => M(i)),
|
|
285
580
|
t
|
|
286
581
|
);
|
|
287
|
-
return
|
|
288
|
-
${
|
|
289
|
-
|
|
290
|
-
)}` :
|
|
582
|
+
return s.status === "error" ? `${n()}. See errors:
|
|
583
|
+
${R(
|
|
584
|
+
s.errors
|
|
585
|
+
)}` : n();
|
|
291
586
|
}
|
|
292
|
-
),
|
|
587
|
+
), oe(
|
|
293
588
|
o,
|
|
294
589
|
e
|
|
295
590
|
);
|
|
296
591
|
if (typeof e == "object") {
|
|
297
|
-
const
|
|
298
|
-
return
|
|
299
|
-
|
|
592
|
+
const s = Object.keys(e);
|
|
593
|
+
return j(
|
|
594
|
+
s.every((i) => r.includes(i)),
|
|
300
595
|
() => {
|
|
301
|
-
const i =
|
|
302
|
-
|
|
596
|
+
const i = U(
|
|
597
|
+
s,
|
|
303
598
|
r,
|
|
304
599
|
t
|
|
305
600
|
);
|
|
306
|
-
return i.status === "error" ? `${
|
|
307
|
-
${
|
|
601
|
+
return i.status === "error" ? `${n()}. See errors:
|
|
602
|
+
${R(
|
|
308
603
|
i.errors
|
|
309
|
-
)}` :
|
|
604
|
+
)}` : n();
|
|
310
605
|
}
|
|
311
|
-
),
|
|
606
|
+
), oe(
|
|
312
607
|
o,
|
|
313
|
-
|
|
608
|
+
s
|
|
314
609
|
);
|
|
315
610
|
}
|
|
316
|
-
throw new Error(`${
|
|
611
|
+
throw new Error(`${n()} OR to "all"`);
|
|
317
612
|
}
|
|
318
|
-
function
|
|
613
|
+
function xe(o, e) {
|
|
319
614
|
return typeof o == "function" ? o(e) : o;
|
|
320
615
|
}
|
|
321
|
-
const
|
|
616
|
+
const ke = [
|
|
322
617
|
"string",
|
|
323
618
|
"number",
|
|
324
619
|
"array.string",
|
|
325
620
|
"array.string.untyped"
|
|
326
|
-
],
|
|
327
|
-
function
|
|
621
|
+
], ve = /^step\d+$/i;
|
|
622
|
+
function ae(o, e) {
|
|
328
623
|
if (typeof o != "object" || o === null) return !1;
|
|
329
624
|
for (const t of Object.keys(e)) {
|
|
330
625
|
if (!(t in o)) return !1;
|
|
331
|
-
const r = e[t],
|
|
332
|
-
if (!r(
|
|
626
|
+
const r = e[t], n = o[t];
|
|
627
|
+
if (!r(n)) return !1;
|
|
333
628
|
}
|
|
334
629
|
return !0;
|
|
335
630
|
}
|
|
336
|
-
function
|
|
337
|
-
return o ??
|
|
631
|
+
function ie(o, e, t) {
|
|
632
|
+
return o ?? Te(e, t);
|
|
338
633
|
}
|
|
339
|
-
function
|
|
340
|
-
const e = {}, { fields: t, defaultCasing: r, validateFields:
|
|
341
|
-
for (const [
|
|
342
|
-
|
|
343
|
-
typeof
|
|
344
|
-
`Each key for the "fields" option must be a string. Key ${
|
|
345
|
-
),
|
|
634
|
+
function Fe(o) {
|
|
635
|
+
const e = {}, { fields: t, defaultCasing: r, validateFields: n } = o;
|
|
636
|
+
for (const [s, i] of Object.entries(t)) {
|
|
637
|
+
j(
|
|
638
|
+
typeof s == "string",
|
|
639
|
+
`Each key for the "fields" option must be a string. Key ${s} was a ${typeof s}`
|
|
640
|
+
), j(
|
|
346
641
|
typeof i == "object",
|
|
347
|
-
`The value for key ${
|
|
642
|
+
`The value for key ${s} must be an object. Was ${typeof i}`
|
|
348
643
|
);
|
|
349
644
|
const {
|
|
350
|
-
defaultValue:
|
|
351
|
-
label:
|
|
645
|
+
defaultValue: y,
|
|
646
|
+
label: b,
|
|
352
647
|
nameTransformCasing: f,
|
|
353
|
-
type:
|
|
648
|
+
type: g = ne
|
|
354
649
|
} = i;
|
|
355
|
-
if (
|
|
356
|
-
e[
|
|
650
|
+
if (n)
|
|
651
|
+
e[s] = y;
|
|
357
652
|
else {
|
|
358
|
-
const
|
|
359
|
-
e[
|
|
360
|
-
...e[
|
|
361
|
-
nameTransformCasing:
|
|
362
|
-
type:
|
|
363
|
-
defaultValue:
|
|
364
|
-
label:
|
|
653
|
+
const c = f ?? r;
|
|
654
|
+
e[s] = {
|
|
655
|
+
...e[s],
|
|
656
|
+
nameTransformCasing: c,
|
|
657
|
+
type: g,
|
|
658
|
+
defaultValue: y,
|
|
659
|
+
label: ie(b, s, c)
|
|
365
660
|
// TODO add more fields here
|
|
366
661
|
};
|
|
367
662
|
}
|
|
368
663
|
}
|
|
369
|
-
if (
|
|
370
|
-
const
|
|
371
|
-
|
|
664
|
+
if (n) {
|
|
665
|
+
const s = be(
|
|
666
|
+
n,
|
|
372
667
|
e
|
|
373
668
|
);
|
|
374
|
-
|
|
375
|
-
typeof
|
|
376
|
-
`The result of the validated fields must be an object, was (${typeof
|
|
377
|
-
),
|
|
378
|
-
!!
|
|
669
|
+
j(
|
|
670
|
+
typeof s == "object",
|
|
671
|
+
`The result of the validated fields must be an object, was (${typeof s}). This is probably an internal error, so open up an issue about it`
|
|
672
|
+
), j(
|
|
673
|
+
!!s,
|
|
379
674
|
"The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it"
|
|
380
675
|
);
|
|
381
|
-
for (const [i,
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
676
|
+
for (const [i, y] of Object.entries(s)) {
|
|
677
|
+
const b = t[i];
|
|
678
|
+
j(
|
|
679
|
+
b,
|
|
385
680
|
`No field found in the fields config for "${i}"`
|
|
386
681
|
);
|
|
387
682
|
const {
|
|
388
683
|
label: f,
|
|
389
|
-
type:
|
|
390
|
-
nameTransformCasing:
|
|
391
|
-
} =
|
|
684
|
+
type: g = ne,
|
|
685
|
+
nameTransformCasing: c
|
|
686
|
+
} = b, m = c ?? r;
|
|
392
687
|
e[i] = {
|
|
393
688
|
...e[i],
|
|
394
|
-
nameTransformCasing:
|
|
395
|
-
type:
|
|
396
|
-
defaultValue:
|
|
397
|
-
label:
|
|
689
|
+
nameTransformCasing: m,
|
|
690
|
+
type: g,
|
|
691
|
+
defaultValue: y,
|
|
692
|
+
label: ie(f, i, m)
|
|
398
693
|
};
|
|
399
694
|
}
|
|
400
695
|
}
|
|
401
696
|
return e;
|
|
402
697
|
}
|
|
403
|
-
function
|
|
698
|
+
function Oe(o) {
|
|
404
699
|
const e = {};
|
|
405
|
-
|
|
700
|
+
j(!!o, "The steps config must be defined", TypeError), j(
|
|
406
701
|
typeof o == "object",
|
|
407
702
|
`The steps config must be an object, was (${typeof o})`,
|
|
408
703
|
TypeError
|
|
409
704
|
);
|
|
410
705
|
for (const [t, r] of Object.entries(o)) {
|
|
411
|
-
|
|
706
|
+
j(
|
|
412
707
|
typeof t == "string",
|
|
413
708
|
`Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
|
|
414
709
|
TypeError
|
|
415
|
-
),
|
|
416
|
-
|
|
710
|
+
), j(
|
|
711
|
+
ve.test(t),
|
|
417
712
|
`The key "${t}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`
|
|
418
713
|
);
|
|
419
|
-
const
|
|
420
|
-
fields:
|
|
714
|
+
const n = t, {
|
|
715
|
+
fields: s,
|
|
421
716
|
title: i,
|
|
422
|
-
nameTransformCasing:
|
|
423
|
-
description:
|
|
717
|
+
nameTransformCasing: y = X,
|
|
718
|
+
description: b,
|
|
424
719
|
validateFields: f
|
|
425
|
-
} = r,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
`Missing fields for step ${
|
|
720
|
+
} = r, g = n.toString().replace("step", "");
|
|
721
|
+
j(
|
|
722
|
+
s,
|
|
723
|
+
`Missing fields for step ${g} (${String(n)})`,
|
|
429
724
|
TypeError
|
|
430
|
-
),
|
|
431
|
-
typeof
|
|
725
|
+
), j(
|
|
726
|
+
typeof s == "object",
|
|
432
727
|
"Fields must be an object",
|
|
433
728
|
TypeError
|
|
434
|
-
),
|
|
435
|
-
Object.keys(
|
|
436
|
-
`The fields config for step ${
|
|
437
|
-
|
|
729
|
+
), j(
|
|
730
|
+
Object.keys(s).length > 0,
|
|
731
|
+
`The fields config for step ${g} (${String(
|
|
732
|
+
n
|
|
438
733
|
)}) is empty. Please add a field`
|
|
439
|
-
),
|
|
440
|
-
typeof
|
|
441
|
-
`The "fields" property must be an object. Was ${typeof
|
|
734
|
+
), j(
|
|
735
|
+
typeof s == "object",
|
|
736
|
+
`The "fields" property must be an object. Was ${typeof s}`
|
|
442
737
|
);
|
|
443
|
-
const
|
|
444
|
-
defaultCasing:
|
|
445
|
-
fields:
|
|
738
|
+
const c = Fe({
|
|
739
|
+
defaultCasing: y,
|
|
740
|
+
fields: s,
|
|
446
741
|
validateFields: f
|
|
447
742
|
});
|
|
448
|
-
e[
|
|
449
|
-
...e[
|
|
743
|
+
e[n] = {
|
|
744
|
+
...e[n],
|
|
450
745
|
title: i,
|
|
451
|
-
nameTransformCasing:
|
|
746
|
+
nameTransformCasing: y,
|
|
452
747
|
// Only add the description if it's defined
|
|
453
|
-
...typeof
|
|
454
|
-
fields:
|
|
748
|
+
...typeof b == "string" ? { description: b } : {},
|
|
749
|
+
fields: c
|
|
455
750
|
};
|
|
456
751
|
}
|
|
457
752
|
return e;
|
|
458
753
|
}
|
|
459
|
-
class
|
|
754
|
+
class ee extends Se {
|
|
460
755
|
/**
|
|
461
756
|
* The original config before any validation or transformations have been applied.
|
|
462
757
|
*/
|
|
@@ -474,37 +769,37 @@ class G extends pe {
|
|
|
474
769
|
storage;
|
|
475
770
|
constructor(e) {
|
|
476
771
|
super();
|
|
477
|
-
const { steps: t, nameTransformCasing: r, storage:
|
|
478
|
-
this.defaultNameTransformationCasing =
|
|
772
|
+
const { steps: t, nameTransformCasing: r, storage: n } = e;
|
|
773
|
+
this.defaultNameTransformationCasing = ge(
|
|
479
774
|
r
|
|
480
|
-
), this.original = t, this.value = this.enrichValues(
|
|
481
|
-
(
|
|
482
|
-
), this.storage = new
|
|
775
|
+
), this.original = t, this.value = this.enrichValues(Oe(this.original)), this.stepNumbers = Object.keys(this.value).map(
|
|
776
|
+
(s) => Number.parseInt(s.replace("step", ""))
|
|
777
|
+
), this.storage = new ye({
|
|
483
778
|
data: this.value,
|
|
484
|
-
key:
|
|
485
|
-
store:
|
|
779
|
+
key: n?.key ?? Q,
|
|
780
|
+
store: n?.store
|
|
486
781
|
}), this.firstStep = this.first(), this.lastStep = this.last(), this.steps = {
|
|
487
782
|
first: this.firstStep.step,
|
|
488
783
|
last: this.lastStep.step,
|
|
489
784
|
value: this.stepNumbers,
|
|
490
|
-
as: (
|
|
491
|
-
if (
|
|
492
|
-
typeof
|
|
493
|
-
`The type of the target transformation type must be a string, was ${typeof
|
|
494
|
-
),
|
|
785
|
+
as: (s) => {
|
|
786
|
+
if (j(
|
|
787
|
+
typeof s == "string",
|
|
788
|
+
`The type of the target transformation type must be a string, was ${typeof s}`
|
|
789
|
+
), s === "string")
|
|
495
790
|
return this.stepNumbers.map((i) => `'${i}'`).join(" | ");
|
|
496
|
-
if (
|
|
791
|
+
if (s === "number")
|
|
497
792
|
return this.stepNumbers.join(" | ");
|
|
498
|
-
if (
|
|
793
|
+
if (s.includes("array.string"))
|
|
499
794
|
return this.stepNumbers.map((i) => `${i}`);
|
|
500
795
|
throw new Error(
|
|
501
|
-
`Transformation type "${
|
|
796
|
+
`Transformation type "${s}" is not supported. Available transformations include: ${ke.map(
|
|
502
797
|
(i) => `"${i}"`
|
|
503
798
|
).join(", ")}`
|
|
504
799
|
);
|
|
505
800
|
},
|
|
506
|
-
isValidStepNumber: (
|
|
507
|
-
isValidStepKey: (
|
|
801
|
+
isValidStepNumber: (s) => this.stepNumbers.includes(s),
|
|
802
|
+
isValidStepKey: (s) => Object.keys(this.value).includes(s)
|
|
508
803
|
};
|
|
509
804
|
}
|
|
510
805
|
getSnapshot() {
|
|
@@ -520,15 +815,15 @@ class G extends pe {
|
|
|
520
815
|
});
|
|
521
816
|
}
|
|
522
817
|
enrichValues(e, t) {
|
|
523
|
-
for (const [r,
|
|
524
|
-
const
|
|
818
|
+
for (const [r, n] of Object.entries(e)) {
|
|
819
|
+
const s = Number.parseInt(r.replace("step", ""));
|
|
525
820
|
e = {
|
|
526
821
|
...e,
|
|
527
822
|
[r]: {
|
|
528
|
-
...
|
|
529
|
-
update: this.createStepUpdaterFn(
|
|
530
|
-
createHelperFn: this.createStepHelperFn(
|
|
531
|
-
...t?.(
|
|
823
|
+
...n,
|
|
824
|
+
update: this.createStepUpdaterFn(r),
|
|
825
|
+
createHelperFn: this.createStepHelperFn(s),
|
|
826
|
+
...t?.(s)
|
|
532
827
|
}
|
|
533
828
|
};
|
|
534
829
|
}
|
|
@@ -540,7 +835,7 @@ class G extends pe {
|
|
|
540
835
|
* @returns The step data for the target step.
|
|
541
836
|
*/
|
|
542
837
|
get(e) {
|
|
543
|
-
return
|
|
838
|
+
return H(this.value)(e);
|
|
544
839
|
}
|
|
545
840
|
/**
|
|
546
841
|
* Gets the data for the first step.
|
|
@@ -561,90 +856,197 @@ class G extends pe {
|
|
|
561
856
|
handlePostUpdate() {
|
|
562
857
|
this.storage.add(this.value), this.notify();
|
|
563
858
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
)}
|
|
859
|
+
createHelperFnInputUpdate(e) {
|
|
860
|
+
if (V.isAll(e)) {
|
|
861
|
+
const r = se(this.value).reduce((n, s) => (n[s] = this.createStepUpdaterFn(s), n), {});
|
|
862
|
+
return Object.assign(
|
|
863
|
+
this.update,
|
|
864
|
+
r
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
const t = Object.keys(this.value);
|
|
868
|
+
if (V.isTuple(e, t)) {
|
|
869
|
+
const r = e.reduce((n, s) => (n[s] = this.createStepUpdaterFn(s), n), {});
|
|
870
|
+
return Object.assign(
|
|
871
|
+
this.update,
|
|
872
|
+
r
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
if (V.isObject(e, t)) {
|
|
876
|
+
const r = se(e).reduce((n, s) => (n[s] = this.createStepUpdaterFn(s), n), {});
|
|
877
|
+
return Object.assign(
|
|
878
|
+
this.update,
|
|
879
|
+
r
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
throw new TypeError(`[update]: ${V.CATCH_ALL_MESSAGE}`);
|
|
883
|
+
}
|
|
884
|
+
createStepUpdaterFnImpl(e) {
|
|
885
|
+
const { targetStep: t, updater: r, ctxData: n, fields: s = "all" } = e;
|
|
886
|
+
j(
|
|
887
|
+
this.steps.isValidStepKey(t),
|
|
888
|
+
`[update]: The target step ${t} isn't a valid step. Please select a valid step`
|
|
575
889
|
);
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
).
|
|
890
|
+
const { [t]: i, ...y } = this.value;
|
|
891
|
+
let b = I(this.value, [t]);
|
|
892
|
+
if (n) {
|
|
893
|
+
j(
|
|
894
|
+
typeof n == "function",
|
|
895
|
+
'[update]: "ctxData" must be a function'
|
|
896
|
+
);
|
|
897
|
+
const c = n({ ctx: y });
|
|
898
|
+
j(
|
|
899
|
+
typeof c == "object" && Object.keys(c).length > 0,
|
|
900
|
+
'[update]: "ctxData" must return an object with keys'
|
|
901
|
+
), b = {
|
|
902
|
+
...b,
|
|
903
|
+
...c
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
const f = xe(r, {
|
|
907
|
+
ctx: b,
|
|
908
|
+
update: this.createHelperFnInputUpdate([t])
|
|
909
|
+
});
|
|
910
|
+
if (!s) {
|
|
911
|
+
j(
|
|
912
|
+
typeof f == "object",
|
|
913
|
+
'[update]: "updater" must be an object or a function that returns an object'
|
|
914
|
+
);
|
|
915
|
+
const c = Object.keys(this.value), m = Object.keys(f);
|
|
916
|
+
j(m.length === c.length, () => {
|
|
917
|
+
const O = c.filter(
|
|
918
|
+
($) => !m.includes($)
|
|
919
|
+
);
|
|
920
|
+
return `[update]: "updater" is missing keys ${new Intl.ListFormat("en", {
|
|
921
|
+
style: "long",
|
|
922
|
+
type: "conjunction"
|
|
923
|
+
}).format(
|
|
924
|
+
O
|
|
925
|
+
)}`;
|
|
926
|
+
});
|
|
927
|
+
const p = C.createDeep(this.value), { mismatches: v, ok: S } = C.equalsAtPaths(
|
|
928
|
+
this.value,
|
|
929
|
+
p,
|
|
930
|
+
f
|
|
931
|
+
);
|
|
932
|
+
j(
|
|
933
|
+
S && v.length === 0,
|
|
934
|
+
`[update]: found value mismatches in ${C.printMismatches({
|
|
935
|
+
mismatches: v,
|
|
936
|
+
ok: S
|
|
937
|
+
})}`
|
|
586
938
|
), this.value = {
|
|
587
939
|
...this.value,
|
|
588
|
-
[
|
|
589
|
-
...this.value[n],
|
|
590
|
-
[t]: Q(
|
|
591
|
-
r,
|
|
592
|
-
this.value[n][t]
|
|
593
|
-
)
|
|
594
|
-
}
|
|
940
|
+
[t]: C.updateAt(this.value, p, f)
|
|
595
941
|
}, this.handlePostUpdate();
|
|
596
942
|
return;
|
|
597
943
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
944
|
+
const g = C.createDeep(i);
|
|
945
|
+
if (Array.isArray(s)) {
|
|
946
|
+
const c = U(g, s);
|
|
947
|
+
j(
|
|
948
|
+
c.status === "success",
|
|
949
|
+
`[update]: Found errors with the provided fields
|
|
950
|
+
${c.status === "error" ? R(c.errors) : ""}`
|
|
602
951
|
);
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
952
|
+
const { mismatches: m, ok: p } = C.equalsAtPaths(
|
|
953
|
+
i,
|
|
954
|
+
s,
|
|
955
|
+
f
|
|
956
|
+
);
|
|
957
|
+
j(
|
|
958
|
+
p && m.length === 0,
|
|
959
|
+
`[update]: found value mismatches in ${C.printMismatches({
|
|
960
|
+
ok: p,
|
|
961
|
+
mismatches: m
|
|
962
|
+
})}`
|
|
606
963
|
), this.value = {
|
|
607
964
|
...this.value,
|
|
608
|
-
[
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
965
|
+
[t]: C.updateAt(i, s, f)
|
|
966
|
+
}, this.handlePostUpdate();
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
if (typeof s == "object" && Object.keys(s).length > 0) {
|
|
970
|
+
const c = C.createDeep(s), m = U(
|
|
971
|
+
g,
|
|
972
|
+
c
|
|
973
|
+
);
|
|
974
|
+
j(
|
|
975
|
+
m.status === "success",
|
|
976
|
+
`[update]: Found errors with the provided fields
|
|
977
|
+
${m.status === "error" ? R(m.errors) : ""}`
|
|
978
|
+
);
|
|
979
|
+
const { mismatches: p, ok: v } = C.equalsAtPaths(
|
|
980
|
+
i,
|
|
981
|
+
c,
|
|
982
|
+
f
|
|
983
|
+
);
|
|
984
|
+
j(
|
|
985
|
+
v && p.length === 0,
|
|
986
|
+
`[update]: found value mismatches in ${C.printMismatches({
|
|
987
|
+
ok: v,
|
|
988
|
+
mismatches: p
|
|
989
|
+
})}`
|
|
990
|
+
), this.value = {
|
|
991
|
+
...this.value,
|
|
992
|
+
[t]: C.updateAt(
|
|
993
|
+
i,
|
|
994
|
+
c,
|
|
995
|
+
f
|
|
996
|
+
)
|
|
612
997
|
}, this.handlePostUpdate();
|
|
613
998
|
return;
|
|
614
999
|
}
|
|
615
1000
|
throw new TypeError(
|
|
616
|
-
`
|
|
617
|
-
{ cause:
|
|
1001
|
+
`[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}`,
|
|
1002
|
+
{ cause: r }
|
|
618
1003
|
);
|
|
619
1004
|
}
|
|
620
1005
|
createStepUpdaterFn(e) {
|
|
621
|
-
return (t
|
|
622
|
-
this.createStepUpdaterFnImpl(
|
|
623
|
-
e,
|
|
624
|
-
t,
|
|
625
|
-
r
|
|
626
|
-
);
|
|
1006
|
+
return (t) => {
|
|
1007
|
+
this.createStepUpdaterFnImpl({ targetStep: e, ...t });
|
|
627
1008
|
};
|
|
628
1009
|
}
|
|
629
|
-
update(e
|
|
630
|
-
this.createStepUpdaterFnImpl(e
|
|
1010
|
+
update(e) {
|
|
1011
|
+
this.createStepUpdaterFnImpl(e);
|
|
631
1012
|
}
|
|
632
1013
|
createStepHelperFnImpl(e) {
|
|
633
1014
|
return (t, r) => {
|
|
634
|
-
const
|
|
1015
|
+
const n = I(
|
|
635
1016
|
this.value,
|
|
636
1017
|
e
|
|
637
1018
|
);
|
|
638
1019
|
if (typeof t == "function")
|
|
639
|
-
return () => t({
|
|
1020
|
+
return () => t({
|
|
1021
|
+
ctx: n,
|
|
1022
|
+
update: this.createHelperFnInputUpdate(e)
|
|
1023
|
+
});
|
|
640
1024
|
if (typeof t == "object")
|
|
641
|
-
return (
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
1025
|
+
return (s) => {
|
|
1026
|
+
if ("validator" in t) {
|
|
1027
|
+
j(
|
|
1028
|
+
typeof s == "object",
|
|
1029
|
+
"An input is expected since you provided a validator"
|
|
1030
|
+
), be(
|
|
1031
|
+
t.validator,
|
|
1032
|
+
s.data
|
|
1033
|
+
);
|
|
1034
|
+
let i = n;
|
|
1035
|
+
if (t.ctxData) {
|
|
1036
|
+
const y = e[0], { [y]: b, ...f } = this.value;
|
|
1037
|
+
i = {
|
|
1038
|
+
...i,
|
|
1039
|
+
...t.ctxData({ ctx: f })
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
return r({
|
|
1043
|
+
ctx: i,
|
|
1044
|
+
update: this.createHelperFnInputUpdate(e),
|
|
1045
|
+
...s
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
return r({ ctx: n, update: this.createHelperFnInputUpdate(e) });
|
|
1049
|
+
};
|
|
648
1050
|
throw new Error(
|
|
649
1051
|
`The first argument must be a function or an object, (was ${typeof t})`
|
|
650
1052
|
);
|
|
@@ -655,57 +1057,58 @@ class G extends pe {
|
|
|
655
1057
|
}
|
|
656
1058
|
// Implementation
|
|
657
1059
|
createHelperFn(e, t) {
|
|
658
|
-
const { stepData: r, ...
|
|
659
|
-
return this.createStepHelperFnImpl(r)(
|
|
1060
|
+
const { stepData: r, ...n } = e;
|
|
1061
|
+
return this.createStepHelperFnImpl(r)(n, t);
|
|
660
1062
|
}
|
|
661
1063
|
/**
|
|
662
1064
|
* Validates that a given object is the proper shape for step data.
|
|
663
1065
|
* @param value
|
|
664
1066
|
*/
|
|
665
1067
|
static hasData(e, t) {
|
|
666
|
-
return e === null || typeof e != "object" ? !1 :
|
|
1068
|
+
return e === null || typeof e != "object" ? !1 : ae(e, {
|
|
667
1069
|
title: (r) => typeof r == "string",
|
|
668
1070
|
fields: (r) => {
|
|
669
1071
|
if (r === null || typeof r != "object")
|
|
670
1072
|
return !1;
|
|
671
|
-
for (const
|
|
672
|
-
if (typeof
|
|
1073
|
+
for (const n of Object.keys(r)) {
|
|
1074
|
+
if (typeof n != "string" || !(n in r))
|
|
673
1075
|
return !1;
|
|
674
|
-
const
|
|
675
|
-
if (
|
|
1076
|
+
const s = r[n];
|
|
1077
|
+
if (s === null || typeof s != "object" || !ae(s, {
|
|
676
1078
|
defaultValue: (i) => i !== "undefined" && i !== null,
|
|
677
1079
|
label: (i) => typeof i == "string" || typeof i == "boolean" && !i,
|
|
678
|
-
nameTransformCasing:
|
|
679
|
-
type:
|
|
1080
|
+
nameTransformCasing: J,
|
|
1081
|
+
type: Ce
|
|
680
1082
|
}))
|
|
681
1083
|
return !1;
|
|
682
1084
|
}
|
|
683
1085
|
return !0;
|
|
684
1086
|
},
|
|
685
1087
|
createHelperFn: (r) => typeof r == "function",
|
|
686
|
-
update: (
|
|
687
|
-
|
|
1088
|
+
// update: (v): v is GetCurrentStep<resolvedStep, stepNumbers>['update'] =>
|
|
1089
|
+
// typeof v === 'function',
|
|
1090
|
+
nameTransformCasing: J,
|
|
688
1091
|
...t?.optionalKeysToCheck
|
|
689
1092
|
});
|
|
690
1093
|
}
|
|
691
1094
|
}
|
|
692
|
-
class
|
|
1095
|
+
class Ve extends Se {
|
|
693
1096
|
defaultNameTransformationCasing;
|
|
694
1097
|
stepSchema;
|
|
695
1098
|
storage;
|
|
696
1099
|
mountCount = 0;
|
|
697
1100
|
constructor(e) {
|
|
698
1101
|
super();
|
|
699
|
-
const { steps: t, nameTransformCasing: r, storage:
|
|
700
|
-
this.defaultNameTransformationCasing =
|
|
1102
|
+
const { steps: t, nameTransformCasing: r, storage: n } = e;
|
|
1103
|
+
this.defaultNameTransformationCasing = ge(
|
|
701
1104
|
r
|
|
702
|
-
), this.stepSchema = new
|
|
1105
|
+
), this.stepSchema = new ee({
|
|
703
1106
|
steps: t,
|
|
704
1107
|
nameTransformCasing: this.defaultNameTransformationCasing
|
|
705
|
-
}), this.storage = new
|
|
706
|
-
key:
|
|
1108
|
+
}), this.storage = new ye({
|
|
1109
|
+
key: n?.key ?? Q,
|
|
707
1110
|
data: this.stepSchema.value,
|
|
708
|
-
store:
|
|
1111
|
+
store: n?.store
|
|
709
1112
|
}), this.stepSchema.subscribe(() => {
|
|
710
1113
|
this.notify();
|
|
711
1114
|
});
|
|
@@ -740,66 +1143,66 @@ class $e extends pe {
|
|
|
740
1143
|
});
|
|
741
1144
|
}
|
|
742
1145
|
}
|
|
743
|
-
function
|
|
1146
|
+
function Ne(o) {
|
|
744
1147
|
function e(t) {
|
|
745
|
-
const { children: r, name:
|
|
746
|
-
return r(o(
|
|
1148
|
+
const { children: r, name: n } = t;
|
|
1149
|
+
return r(o(n));
|
|
747
1150
|
}
|
|
748
1151
|
return e;
|
|
749
1152
|
}
|
|
750
|
-
var
|
|
1153
|
+
var N;
|
|
751
1154
|
((o) => {
|
|
752
1155
|
o.DEFAULT_FORM_ALIAS = "Form";
|
|
753
|
-
function e(r,
|
|
1156
|
+
function e(r, n) {
|
|
754
1157
|
if (Array.isArray(r)) {
|
|
755
|
-
if (
|
|
1158
|
+
if (n === "all")
|
|
756
1159
|
return !0;
|
|
757
|
-
if (typeof
|
|
758
|
-
return Object.keys(
|
|
759
|
-
(
|
|
1160
|
+
if (typeof n == "object" && !Array.isArray(n))
|
|
1161
|
+
return Object.keys(n).some(
|
|
1162
|
+
(s) => r.includes(s)
|
|
760
1163
|
);
|
|
761
|
-
if (Array.isArray(
|
|
762
|
-
return
|
|
1164
|
+
if (Array.isArray(n))
|
|
1165
|
+
return n.some((s) => r.includes(s));
|
|
763
1166
|
}
|
|
764
1167
|
return !1;
|
|
765
1168
|
}
|
|
766
1169
|
o.isFormAvailable = e;
|
|
767
1170
|
function t(r) {
|
|
768
|
-
return (
|
|
1171
|
+
return (n) => /* @__PURE__ */ $e("form", { id: r, ...n });
|
|
769
1172
|
}
|
|
770
1173
|
o.createDefaultForm = t;
|
|
771
|
-
})(
|
|
772
|
-
var
|
|
1174
|
+
})(N || (N = {}));
|
|
1175
|
+
var Y;
|
|
773
1176
|
((o) => {
|
|
774
1177
|
o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
|
|
775
|
-
})(
|
|
776
|
-
function
|
|
777
|
-
|
|
1178
|
+
})(Y || (Y = {}));
|
|
1179
|
+
function Ie(o, e) {
|
|
1180
|
+
j(
|
|
778
1181
|
e in o,
|
|
779
1182
|
`The target step ${e} is not a valid step key`
|
|
780
1183
|
);
|
|
781
1184
|
const t = o[e];
|
|
782
|
-
|
|
1185
|
+
j("fields" in t, `No "fields" were found for ${e}`);
|
|
783
1186
|
let r = {};
|
|
784
|
-
for (const [
|
|
1187
|
+
for (const [n, s] of Object.entries(
|
|
785
1188
|
t.fields
|
|
786
1189
|
))
|
|
787
1190
|
r = {
|
|
788
1191
|
...r,
|
|
789
|
-
[
|
|
1192
|
+
[n]: s.defaultValue
|
|
790
1193
|
};
|
|
791
1194
|
return r;
|
|
792
1195
|
}
|
|
793
|
-
class
|
|
1196
|
+
class De extends ee {
|
|
794
1197
|
// @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
|
|
795
1198
|
value;
|
|
796
1199
|
constructor(e) {
|
|
797
1200
|
const { form: t, ...r } = e;
|
|
798
|
-
super(r), this.value = this.enrichValues(
|
|
799
|
-
const
|
|
1201
|
+
super(r), this.value = this.enrichValues(Oe(this.original)), this.value = this.enrichValues(this.value, (n) => {
|
|
1202
|
+
const s = `step${n}`, i = t?.id ?? s;
|
|
800
1203
|
return {
|
|
801
1204
|
createComponent: this.createComponentForStep(
|
|
802
|
-
[`step${
|
|
1205
|
+
[`step${n}`],
|
|
803
1206
|
{
|
|
804
1207
|
isStepSpecific: !0,
|
|
805
1208
|
defaultId: i,
|
|
@@ -810,196 +1213,193 @@ class Ve extends G {
|
|
|
810
1213
|
});
|
|
811
1214
|
}
|
|
812
1215
|
createFormComponent(e, t) {
|
|
813
|
-
const { render: r, enabledForSteps:
|
|
814
|
-
id:
|
|
815
|
-
steps:
|
|
1216
|
+
const { render: r, enabledForSteps: n = "all", id: s = t } = e, i = {
|
|
1217
|
+
id: s,
|
|
1218
|
+
steps: I(this.value, n)
|
|
816
1219
|
};
|
|
817
|
-
return (
|
|
1220
|
+
return (y) => r(i, y);
|
|
818
1221
|
}
|
|
819
|
-
createStepSpecificComponentImpl(e, t, r,
|
|
820
|
-
return (
|
|
821
|
-
const
|
|
822
|
-
for (const [
|
|
823
|
-
if (typeof
|
|
1222
|
+
createStepSpecificComponentImpl(e, t, r, n = {}) {
|
|
1223
|
+
return (s) => ((i) => {
|
|
1224
|
+
const y = {};
|
|
1225
|
+
for (const [O, $] of Object.entries(n))
|
|
1226
|
+
if (typeof $ == "function")
|
|
824
1227
|
try {
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
`[multi-step-form] Hook "${
|
|
828
|
-
{ result:
|
|
1228
|
+
const w = $();
|
|
1229
|
+
y[O] = w, typeof console < "u" && console.debug && console.debug(
|
|
1230
|
+
`[multi-step-form] Hook "${O}" called successfully`,
|
|
1231
|
+
{ result: w !== void 0 ? "defined" : "undefined" }
|
|
829
1232
|
);
|
|
830
|
-
} catch (
|
|
831
|
-
const
|
|
1233
|
+
} catch (w) {
|
|
1234
|
+
const a = w instanceof Error ? w.message : String(w);
|
|
832
1235
|
throw new Error(
|
|
833
|
-
`[multi-step-form] Error calling hook "${
|
|
1236
|
+
`[multi-step-form] Error calling hook "${O}" in useFormInstance.render: ${a}
|
|
834
1237
|
|
|
835
1238
|
This usually means:
|
|
836
1239
|
1. The hook is being called outside of a React component
|
|
837
1240
|
2. The hook has invalid dependencies or configuration
|
|
838
1241
|
3. There's an error in your hook implementation
|
|
839
1242
|
|
|
840
|
-
Original error: ${
|
|
841
|
-
{ cause:
|
|
1243
|
+
Original error: ${a}`,
|
|
1244
|
+
{ cause: w }
|
|
842
1245
|
);
|
|
843
1246
|
}
|
|
844
1247
|
else
|
|
845
|
-
|
|
846
|
-
const { defaultId:
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1248
|
+
y[O] = $;
|
|
1249
|
+
const { defaultId: b, form: f } = t, { ctx: g } = r, [c] = e;
|
|
1250
|
+
j(
|
|
1251
|
+
this.steps.isValidStepKey(c),
|
|
1252
|
+
`[createComponent]: the target step ${c} is invalid. Note, this error shouldn't appear as the target step should always be valid. If you see this error, please open an issue.`
|
|
1253
|
+
);
|
|
1254
|
+
const m = Number.parseInt(c.replace("step", ""));
|
|
1255
|
+
j(
|
|
1256
|
+
!Number.isNaN(m),
|
|
1257
|
+
`[${c}:"createComponent"]: an error occurred while extracting the number`
|
|
1258
|
+
);
|
|
1259
|
+
const p = this.value[c];
|
|
1260
|
+
j(
|
|
1261
|
+
"fields" in p,
|
|
1262
|
+
`[${c}:createComponent]: unable to find the "fields" for the current step`
|
|
1263
|
+
), j(
|
|
1264
|
+
typeof p.fields == "object",
|
|
1265
|
+
`[${c}:createComponent]: the "fields" property must be an object, was ${typeof p.fields}`
|
|
1266
|
+
);
|
|
1267
|
+
const v = Ne((O) => {
|
|
1268
|
+
j(typeof O == "string", () => {
|
|
1269
|
+
const d = new Intl.ListFormat("en", {
|
|
1270
|
+
style: "long",
|
|
1271
|
+
type: "disjunction"
|
|
1272
|
+
});
|
|
1273
|
+
return `[${c}:Field]: the "name" prop must be a string and a valid field for ${c}. Available fields include ${d.format(
|
|
1274
|
+
Object.keys(p.fields)
|
|
1275
|
+
)}`;
|
|
1276
|
+
}), j(
|
|
1277
|
+
O in p.fields,
|
|
1278
|
+
`[${c}:Field]: the field "${O}" doesn't exist for the current step`
|
|
1279
|
+
), j(
|
|
1280
|
+
"update" in p,
|
|
1281
|
+
`[${c}:Field]: No "update" function was found`
|
|
868
1282
|
);
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
return {
|
|
884
|
-
defaultValue: S,
|
|
885
|
-
label: v,
|
|
886
|
-
nameTransformCasing: E,
|
|
887
|
-
type: be,
|
|
888
|
-
name: g,
|
|
889
|
-
onInputChange: (x) => (
|
|
890
|
-
// TODO remove type assertions
|
|
891
|
-
T(
|
|
892
|
-
"fields",
|
|
893
|
-
(P) => ({
|
|
894
|
-
...P,
|
|
895
|
-
[g]: {
|
|
896
|
-
...P[g],
|
|
897
|
-
defaultValue: x
|
|
898
|
-
}
|
|
899
|
-
})
|
|
900
|
-
)
|
|
901
|
-
)
|
|
902
|
-
};
|
|
903
|
-
});
|
|
904
|
-
let w = {
|
|
905
|
-
ctx: d,
|
|
906
|
-
onInputChange: this.createStepUpdaterFn(m),
|
|
907
|
-
Field: _,
|
|
908
|
-
...p
|
|
1283
|
+
const { fields: $, update: w } = p, { defaultValue: a, label: l, nameTransformCasing: h, type: u } = $[O];
|
|
1284
|
+
return {
|
|
1285
|
+
defaultValue: a,
|
|
1286
|
+
label: l,
|
|
1287
|
+
nameTransformCasing: h,
|
|
1288
|
+
type: u,
|
|
1289
|
+
name: O,
|
|
1290
|
+
onInputChange: (d) => (
|
|
1291
|
+
// TODO remove type assertions
|
|
1292
|
+
w({
|
|
1293
|
+
fields: [`fields.${O}.defaultValue`],
|
|
1294
|
+
updater: d
|
|
1295
|
+
})
|
|
1296
|
+
)
|
|
909
1297
|
};
|
|
910
|
-
|
|
1298
|
+
});
|
|
1299
|
+
let S = {
|
|
1300
|
+
ctx: g,
|
|
1301
|
+
onInputChange: this.createStepUpdaterFn(c),
|
|
1302
|
+
Field: v,
|
|
1303
|
+
...y
|
|
1304
|
+
};
|
|
1305
|
+
if (f) {
|
|
1306
|
+
const {
|
|
1307
|
+
alias: O = N.DEFAULT_FORM_ALIAS,
|
|
1308
|
+
...$
|
|
1309
|
+
} = f, w = $.enabledForSteps ?? "all";
|
|
1310
|
+
return N.isFormAvailable(
|
|
911
1311
|
e,
|
|
912
|
-
|
|
913
|
-
) && (
|
|
914
|
-
...
|
|
915
|
-
[
|
|
916
|
-
}),
|
|
1312
|
+
w
|
|
1313
|
+
) && (S = {
|
|
1314
|
+
...S,
|
|
1315
|
+
[O]: this.createFormComponent($, b)
|
|
1316
|
+
}), s(S, i);
|
|
917
1317
|
}
|
|
918
|
-
return
|
|
1318
|
+
return s(
|
|
919
1319
|
{
|
|
920
|
-
|
|
921
|
-
[
|
|
1320
|
+
...S,
|
|
1321
|
+
[N.DEFAULT_FORM_ALIAS]: N.createDefaultForm(b)
|
|
922
1322
|
},
|
|
923
1323
|
i
|
|
924
1324
|
);
|
|
925
1325
|
});
|
|
926
1326
|
}
|
|
927
1327
|
createStepSpecificComponentFactory(e, t, r) {
|
|
928
|
-
const
|
|
929
|
-
function
|
|
930
|
-
function
|
|
931
|
-
return
|
|
1328
|
+
const n = this.createStepSpecificComponentImpl.bind(this), s = this.createDefaultValues.bind(this), i = this.value;
|
|
1329
|
+
function y(b, f) {
|
|
1330
|
+
function g(m) {
|
|
1331
|
+
return m ? { ctx: { ...r, ...m } } : { ctx: r };
|
|
932
1332
|
}
|
|
933
|
-
function
|
|
934
|
-
return
|
|
935
|
-
typeof
|
|
1333
|
+
function c() {
|
|
1334
|
+
return j(
|
|
1335
|
+
typeof b == "function",
|
|
936
1336
|
"The first argument must be a function"
|
|
937
|
-
),
|
|
1337
|
+
), n(
|
|
938
1338
|
e,
|
|
939
1339
|
t,
|
|
940
|
-
|
|
941
|
-
)(
|
|
1340
|
+
g(void 0)
|
|
1341
|
+
)(b);
|
|
942
1342
|
}
|
|
943
|
-
if (typeof
|
|
944
|
-
const { useFormInstance:
|
|
945
|
-
debug:
|
|
946
|
-
prefix(
|
|
947
|
-
return `${
|
|
1343
|
+
if (typeof b == "object") {
|
|
1344
|
+
const { useFormInstance: m, ctxData: p, debug: v } = b, S = e[0], O = new me({
|
|
1345
|
+
debug: v,
|
|
1346
|
+
prefix(a) {
|
|
1347
|
+
return `${a}-${String(S)}-createComponent`;
|
|
948
1348
|
}
|
|
949
1349
|
});
|
|
950
|
-
|
|
951
|
-
const { [
|
|
952
|
-
if (
|
|
1350
|
+
O.info("First argument is an object");
|
|
1351
|
+
const { [S]: $, ...w } = i;
|
|
1352
|
+
if (j(
|
|
953
1353
|
typeof f == "function",
|
|
954
1354
|
"The second argument must be a function"
|
|
955
|
-
),
|
|
1355
|
+
), m) {
|
|
956
1356
|
const {
|
|
957
|
-
render:
|
|
958
|
-
alias:
|
|
959
|
-
} =
|
|
1357
|
+
render: a,
|
|
1358
|
+
alias: l = Y.DEFAULT_FORM_INSTANCE_ALIAS
|
|
1359
|
+
} = m, [h] = e, u = s(h), d = p ? {
|
|
960
1360
|
...r,
|
|
961
|
-
...
|
|
962
|
-
} : r, E = { ctx:
|
|
963
|
-
return
|
|
1361
|
+
...p({ ctx: w })
|
|
1362
|
+
} : r, E = { ctx: d, defaultValues: u };
|
|
1363
|
+
return n(
|
|
964
1364
|
e,
|
|
965
1365
|
t,
|
|
966
|
-
|
|
1366
|
+
d,
|
|
967
1367
|
{
|
|
968
|
-
[
|
|
1368
|
+
[l]: () => a(E)
|
|
969
1369
|
}
|
|
970
1370
|
)(f);
|
|
971
1371
|
}
|
|
972
|
-
if (
|
|
973
|
-
|
|
974
|
-
typeof
|
|
1372
|
+
if (p) {
|
|
1373
|
+
O.info('Option "ctxData" is defined'), j(
|
|
1374
|
+
typeof p == "function",
|
|
975
1375
|
'Option "ctxData" must be a function'
|
|
976
1376
|
);
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
`Addition context is: ${JSON.stringify(
|
|
1377
|
+
const a = p({ ctx: w });
|
|
1378
|
+
O.info(
|
|
1379
|
+
`Addition context is: ${JSON.stringify(a, null, 2)}`
|
|
980
1380
|
);
|
|
981
|
-
const
|
|
1381
|
+
const l = {
|
|
982
1382
|
...r,
|
|
983
|
-
...
|
|
1383
|
+
...a
|
|
984
1384
|
};
|
|
985
|
-
return
|
|
986
|
-
`Resolved context is: ${JSON.stringify(
|
|
987
|
-
),
|
|
988
|
-
ctx:
|
|
1385
|
+
return O.info(
|
|
1386
|
+
`Resolved context is: ${JSON.stringify(l, null, 2)}`
|
|
1387
|
+
), n(e, t, {
|
|
1388
|
+
ctx: l
|
|
989
1389
|
})(f);
|
|
990
1390
|
}
|
|
991
|
-
return
|
|
1391
|
+
return c();
|
|
992
1392
|
}
|
|
993
|
-
return
|
|
1393
|
+
return c();
|
|
994
1394
|
}
|
|
995
|
-
return
|
|
1395
|
+
return y;
|
|
996
1396
|
}
|
|
997
1397
|
createComponentImpl(e, t) {
|
|
998
|
-
const r =
|
|
1398
|
+
const r = I(
|
|
999
1399
|
this.value,
|
|
1000
1400
|
e
|
|
1001
1401
|
);
|
|
1002
|
-
return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (
|
|
1402
|
+
return t.isStepSpecific ? this.createStepSpecificComponentFactory(e, t, r) : (n) => ((s) => n(r, s));
|
|
1003
1403
|
}
|
|
1004
1404
|
createComponentForStep(e, t) {
|
|
1005
1405
|
return this.createComponentImpl(e, t);
|
|
@@ -1017,34 +1417,34 @@ Original error: ${c}`,
|
|
|
1017
1417
|
})(t);
|
|
1018
1418
|
}
|
|
1019
1419
|
createDefaultValues(e) {
|
|
1020
|
-
return
|
|
1420
|
+
return Ie(this.value, e);
|
|
1021
1421
|
}
|
|
1022
1422
|
}
|
|
1023
|
-
class
|
|
1423
|
+
class Le extends Ve {
|
|
1024
1424
|
stepSchema;
|
|
1025
1425
|
constructor(e) {
|
|
1026
|
-
const { nameTransformCasing: t =
|
|
1426
|
+
const { nameTransformCasing: t = X, storage: r, ...n } = e;
|
|
1027
1427
|
super({
|
|
1028
1428
|
nameTransformCasing: t,
|
|
1029
1429
|
storage: r,
|
|
1030
|
-
...
|
|
1031
|
-
}), this.stepSchema = new
|
|
1430
|
+
...n
|
|
1431
|
+
}), this.stepSchema = new De({
|
|
1032
1432
|
nameTransformCasing: t,
|
|
1033
|
-
...
|
|
1433
|
+
...n
|
|
1034
1434
|
});
|
|
1035
1435
|
}
|
|
1036
1436
|
createComponent(e, t) {
|
|
1037
|
-
const { stepData: r } = e,
|
|
1437
|
+
const { stepData: r } = e, n = I(
|
|
1038
1438
|
this.stepSchema.value,
|
|
1039
1439
|
r
|
|
1040
1440
|
);
|
|
1041
|
-
return ((
|
|
1441
|
+
return ((s) => t({ ctx: n }, s));
|
|
1042
1442
|
}
|
|
1043
1443
|
}
|
|
1044
|
-
function
|
|
1045
|
-
return new
|
|
1444
|
+
function Be(o) {
|
|
1445
|
+
return new Le(o);
|
|
1046
1446
|
}
|
|
1047
|
-
var
|
|
1447
|
+
var D = { exports: {} }, K = {}, L = { exports: {} }, B = {};
|
|
1048
1448
|
/**
|
|
1049
1449
|
* @license React
|
|
1050
1450
|
* use-sync-external-store-shim.production.js
|
|
@@ -1054,48 +1454,48 @@ var C = { exports: {} }, L = {}, j = { exports: {} }, D = {};
|
|
|
1054
1454
|
* This source code is licensed under the MIT license found in the
|
|
1055
1455
|
* LICENSE file in the root directory of this source tree.
|
|
1056
1456
|
*/
|
|
1057
|
-
var
|
|
1058
|
-
function
|
|
1059
|
-
if (
|
|
1060
|
-
|
|
1061
|
-
var o =
|
|
1062
|
-
function e(
|
|
1063
|
-
return
|
|
1064
|
-
}
|
|
1065
|
-
var t = typeof Object.is == "function" ? Object.is : e, r = o.useState,
|
|
1066
|
-
function
|
|
1067
|
-
var
|
|
1068
|
-
return
|
|
1457
|
+
var ue;
|
|
1458
|
+
function Me() {
|
|
1459
|
+
if (ue) return B;
|
|
1460
|
+
ue = 1;
|
|
1461
|
+
var o = W;
|
|
1462
|
+
function e(c, m) {
|
|
1463
|
+
return c === m && (c !== 0 || 1 / c === 1 / m) || c !== c && m !== m;
|
|
1464
|
+
}
|
|
1465
|
+
var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, n = o.useEffect, s = o.useLayoutEffect, i = o.useDebugValue;
|
|
1466
|
+
function y(c, m) {
|
|
1467
|
+
var p = m(), v = r({ inst: { value: p, getSnapshot: m } }), S = v[0].inst, O = v[1];
|
|
1468
|
+
return s(
|
|
1069
1469
|
function() {
|
|
1070
|
-
|
|
1470
|
+
S.value = p, S.getSnapshot = m, b(S) && O({ inst: S });
|
|
1071
1471
|
},
|
|
1072
|
-
[
|
|
1073
|
-
),
|
|
1472
|
+
[c, p, m]
|
|
1473
|
+
), n(
|
|
1074
1474
|
function() {
|
|
1075
|
-
return
|
|
1076
|
-
|
|
1475
|
+
return b(S) && O({ inst: S }), c(function() {
|
|
1476
|
+
b(S) && O({ inst: S });
|
|
1077
1477
|
});
|
|
1078
1478
|
},
|
|
1079
|
-
[
|
|
1080
|
-
), i(
|
|
1479
|
+
[c]
|
|
1480
|
+
), i(p), p;
|
|
1081
1481
|
}
|
|
1082
|
-
function
|
|
1083
|
-
var
|
|
1084
|
-
|
|
1482
|
+
function b(c) {
|
|
1483
|
+
var m = c.getSnapshot;
|
|
1484
|
+
c = c.value;
|
|
1085
1485
|
try {
|
|
1086
|
-
var
|
|
1087
|
-
return !t(
|
|
1486
|
+
var p = m();
|
|
1487
|
+
return !t(c, p);
|
|
1088
1488
|
} catch {
|
|
1089
1489
|
return !0;
|
|
1090
1490
|
}
|
|
1091
1491
|
}
|
|
1092
|
-
function f(
|
|
1093
|
-
return
|
|
1492
|
+
function f(c, m) {
|
|
1493
|
+
return m();
|
|
1094
1494
|
}
|
|
1095
|
-
var
|
|
1096
|
-
return
|
|
1495
|
+
var g = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : y;
|
|
1496
|
+
return B.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : g, B;
|
|
1097
1497
|
}
|
|
1098
|
-
var
|
|
1498
|
+
var q = {};
|
|
1099
1499
|
/**
|
|
1100
1500
|
* @license React
|
|
1101
1501
|
* use-sync-external-store-shim.development.js
|
|
@@ -1105,62 +1505,62 @@ var k = {};
|
|
|
1105
1505
|
* This source code is licensed under the MIT license found in the
|
|
1106
1506
|
* LICENSE file in the root directory of this source tree.
|
|
1107
1507
|
*/
|
|
1108
|
-
var
|
|
1109
|
-
function
|
|
1110
|
-
return
|
|
1111
|
-
function o(
|
|
1112
|
-
return
|
|
1508
|
+
var ce;
|
|
1509
|
+
function Ue() {
|
|
1510
|
+
return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
1511
|
+
function o(p, v) {
|
|
1512
|
+
return p === v && (p !== 0 || 1 / p === 1 / v) || p !== p && v !== v;
|
|
1113
1513
|
}
|
|
1114
|
-
function e(
|
|
1115
|
-
|
|
1514
|
+
function e(p, v) {
|
|
1515
|
+
g || n.startTransition === void 0 || (g = !0, console.error(
|
|
1116
1516
|
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
1117
1517
|
));
|
|
1118
|
-
var
|
|
1119
|
-
if (!
|
|
1120
|
-
var
|
|
1121
|
-
|
|
1518
|
+
var S = v();
|
|
1519
|
+
if (!c) {
|
|
1520
|
+
var O = v();
|
|
1521
|
+
s(S, O) || (console.error(
|
|
1122
1522
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
1123
|
-
),
|
|
1523
|
+
), c = !0);
|
|
1124
1524
|
}
|
|
1125
|
-
|
|
1126
|
-
inst: { value:
|
|
1525
|
+
O = i({
|
|
1526
|
+
inst: { value: S, getSnapshot: v }
|
|
1127
1527
|
});
|
|
1128
|
-
var
|
|
1129
|
-
return
|
|
1528
|
+
var $ = O[0].inst, w = O[1];
|
|
1529
|
+
return b(
|
|
1130
1530
|
function() {
|
|
1131
|
-
|
|
1531
|
+
$.value = S, $.getSnapshot = v, t($) && w({ inst: $ });
|
|
1132
1532
|
},
|
|
1133
|
-
[
|
|
1134
|
-
),
|
|
1533
|
+
[p, S, v]
|
|
1534
|
+
), y(
|
|
1135
1535
|
function() {
|
|
1136
|
-
return t(
|
|
1137
|
-
t(
|
|
1536
|
+
return t($) && w({ inst: $ }), p(function() {
|
|
1537
|
+
t($) && w({ inst: $ });
|
|
1138
1538
|
});
|
|
1139
1539
|
},
|
|
1140
|
-
[
|
|
1141
|
-
), f(
|
|
1540
|
+
[p]
|
|
1541
|
+
), f(S), S;
|
|
1142
1542
|
}
|
|
1143
|
-
function t(
|
|
1144
|
-
var
|
|
1145
|
-
|
|
1543
|
+
function t(p) {
|
|
1544
|
+
var v = p.getSnapshot;
|
|
1545
|
+
p = p.value;
|
|
1146
1546
|
try {
|
|
1147
|
-
var
|
|
1148
|
-
return !
|
|
1547
|
+
var S = v();
|
|
1548
|
+
return !s(p, S);
|
|
1149
1549
|
} catch {
|
|
1150
1550
|
return !0;
|
|
1151
1551
|
}
|
|
1152
1552
|
}
|
|
1153
|
-
function r(
|
|
1154
|
-
return
|
|
1553
|
+
function r(p, v) {
|
|
1554
|
+
return v();
|
|
1155
1555
|
}
|
|
1156
1556
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1157
|
-
var
|
|
1158
|
-
|
|
1159
|
-
})()),
|
|
1557
|
+
var n = W, s = typeof Object.is == "function" ? Object.is : o, i = n.useState, y = n.useEffect, b = n.useLayoutEffect, f = n.useDebugValue, g = !1, c = !1, m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
|
|
1558
|
+
q.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1559
|
+
})()), q;
|
|
1160
1560
|
}
|
|
1161
|
-
var
|
|
1162
|
-
function
|
|
1163
|
-
return
|
|
1561
|
+
var le;
|
|
1562
|
+
function je() {
|
|
1563
|
+
return le || (le = 1, process.env.NODE_ENV === "production" ? L.exports = Me() : L.exports = Ue()), L.exports;
|
|
1164
1564
|
}
|
|
1165
1565
|
/**
|
|
1166
1566
|
* @license React
|
|
@@ -1171,58 +1571,58 @@ function me() {
|
|
|
1171
1571
|
* This source code is licensed under the MIT license found in the
|
|
1172
1572
|
* LICENSE file in the root directory of this source tree.
|
|
1173
1573
|
*/
|
|
1174
|
-
var
|
|
1175
|
-
function
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
1178
|
-
var o =
|
|
1179
|
-
function t(f,
|
|
1180
|
-
return f ===
|
|
1181
|
-
}
|
|
1182
|
-
var r = typeof Object.is == "function" ? Object.is : t,
|
|
1183
|
-
return
|
|
1184
|
-
var
|
|
1185
|
-
if (
|
|
1186
|
-
var
|
|
1187
|
-
|
|
1188
|
-
} else
|
|
1189
|
-
|
|
1574
|
+
var fe;
|
|
1575
|
+
function Re() {
|
|
1576
|
+
if (fe) return K;
|
|
1577
|
+
fe = 1;
|
|
1578
|
+
var o = W, e = je();
|
|
1579
|
+
function t(f, g) {
|
|
1580
|
+
return f === g && (f !== 0 || 1 / f === 1 / g) || f !== f && g !== g;
|
|
1581
|
+
}
|
|
1582
|
+
var r = typeof Object.is == "function" ? Object.is : t, n = e.useSyncExternalStore, s = o.useRef, i = o.useEffect, y = o.useMemo, b = o.useDebugValue;
|
|
1583
|
+
return K.useSyncExternalStoreWithSelector = function(f, g, c, m, p) {
|
|
1584
|
+
var v = s(null);
|
|
1585
|
+
if (v.current === null) {
|
|
1586
|
+
var S = { hasValue: !1, value: null };
|
|
1587
|
+
v.current = S;
|
|
1588
|
+
} else S = v.current;
|
|
1589
|
+
v = y(
|
|
1190
1590
|
function() {
|
|
1191
|
-
function
|
|
1591
|
+
function $(u) {
|
|
1192
1592
|
if (!w) {
|
|
1193
|
-
if (w = !0,
|
|
1194
|
-
var
|
|
1195
|
-
if (
|
|
1196
|
-
return
|
|
1593
|
+
if (w = !0, a = u, u = m(u), p !== void 0 && S.hasValue) {
|
|
1594
|
+
var d = S.value;
|
|
1595
|
+
if (p(d, u))
|
|
1596
|
+
return l = d;
|
|
1197
1597
|
}
|
|
1198
|
-
return
|
|
1598
|
+
return l = u;
|
|
1199
1599
|
}
|
|
1200
|
-
if (
|
|
1201
|
-
var E =
|
|
1202
|
-
return
|
|
1600
|
+
if (d = l, r(a, u)) return d;
|
|
1601
|
+
var E = m(u);
|
|
1602
|
+
return p !== void 0 && p(d, E) ? (a = u, d) : (a = u, l = E);
|
|
1203
1603
|
}
|
|
1204
|
-
var w = !1,
|
|
1604
|
+
var w = !1, a, l, h = c === void 0 ? null : c;
|
|
1205
1605
|
return [
|
|
1206
1606
|
function() {
|
|
1207
|
-
return
|
|
1607
|
+
return $(g());
|
|
1208
1608
|
},
|
|
1209
|
-
|
|
1210
|
-
return
|
|
1609
|
+
h === null ? void 0 : function() {
|
|
1610
|
+
return $(h());
|
|
1211
1611
|
}
|
|
1212
1612
|
];
|
|
1213
1613
|
},
|
|
1214
|
-
[
|
|
1614
|
+
[g, c, m, p]
|
|
1215
1615
|
);
|
|
1216
|
-
var
|
|
1616
|
+
var O = n(f, v[0], v[1]);
|
|
1217
1617
|
return i(
|
|
1218
1618
|
function() {
|
|
1219
|
-
|
|
1619
|
+
S.hasValue = !0, S.value = O;
|
|
1220
1620
|
},
|
|
1221
|
-
[
|
|
1222
|
-
),
|
|
1223
|
-
},
|
|
1621
|
+
[O]
|
|
1622
|
+
), b(O), O;
|
|
1623
|
+
}, K;
|
|
1224
1624
|
}
|
|
1225
|
-
var
|
|
1625
|
+
var z = {};
|
|
1226
1626
|
/**
|
|
1227
1627
|
* @license React
|
|
1228
1628
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -1232,96 +1632,96 @@ var M = {};
|
|
|
1232
1632
|
* This source code is licensed under the MIT license found in the
|
|
1233
1633
|
* LICENSE file in the root directory of this source tree.
|
|
1234
1634
|
*/
|
|
1235
|
-
var
|
|
1236
|
-
function
|
|
1237
|
-
return
|
|
1238
|
-
function o(f,
|
|
1239
|
-
return f ===
|
|
1635
|
+
var pe;
|
|
1636
|
+
function He() {
|
|
1637
|
+
return pe || (pe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
1638
|
+
function o(f, g) {
|
|
1639
|
+
return f === g && (f !== 0 || 1 / f === 1 / g) || f !== f && g !== g;
|
|
1240
1640
|
}
|
|
1241
1641
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
1242
|
-
var e =
|
|
1243
|
-
|
|
1244
|
-
var
|
|
1245
|
-
if (
|
|
1246
|
-
var
|
|
1247
|
-
|
|
1248
|
-
} else
|
|
1249
|
-
|
|
1642
|
+
var e = W, t = je(), r = typeof Object.is == "function" ? Object.is : o, n = t.useSyncExternalStore, s = e.useRef, i = e.useEffect, y = e.useMemo, b = e.useDebugValue;
|
|
1643
|
+
z.useSyncExternalStoreWithSelector = function(f, g, c, m, p) {
|
|
1644
|
+
var v = s(null);
|
|
1645
|
+
if (v.current === null) {
|
|
1646
|
+
var S = { hasValue: !1, value: null };
|
|
1647
|
+
v.current = S;
|
|
1648
|
+
} else S = v.current;
|
|
1649
|
+
v = y(
|
|
1250
1650
|
function() {
|
|
1251
|
-
function
|
|
1651
|
+
function $(u) {
|
|
1252
1652
|
if (!w) {
|
|
1253
|
-
if (w = !0,
|
|
1254
|
-
var
|
|
1255
|
-
if (
|
|
1256
|
-
return
|
|
1653
|
+
if (w = !0, a = u, u = m(u), p !== void 0 && S.hasValue) {
|
|
1654
|
+
var d = S.value;
|
|
1655
|
+
if (p(d, u))
|
|
1656
|
+
return l = d;
|
|
1257
1657
|
}
|
|
1258
|
-
return
|
|
1658
|
+
return l = u;
|
|
1259
1659
|
}
|
|
1260
|
-
if (
|
|
1261
|
-
return
|
|
1262
|
-
var E =
|
|
1263
|
-
return
|
|
1660
|
+
if (d = l, r(a, u))
|
|
1661
|
+
return d;
|
|
1662
|
+
var E = m(u);
|
|
1663
|
+
return p !== void 0 && p(d, E) ? (a = u, d) : (a = u, l = E);
|
|
1264
1664
|
}
|
|
1265
|
-
var w = !1,
|
|
1665
|
+
var w = !1, a, l, h = c === void 0 ? null : c;
|
|
1266
1666
|
return [
|
|
1267
1667
|
function() {
|
|
1268
|
-
return
|
|
1668
|
+
return $(g());
|
|
1269
1669
|
},
|
|
1270
|
-
|
|
1271
|
-
return
|
|
1670
|
+
h === null ? void 0 : function() {
|
|
1671
|
+
return $(h());
|
|
1272
1672
|
}
|
|
1273
1673
|
];
|
|
1274
1674
|
},
|
|
1275
|
-
[
|
|
1675
|
+
[g, c, m, p]
|
|
1276
1676
|
);
|
|
1277
|
-
var
|
|
1677
|
+
var O = n(f, v[0], v[1]);
|
|
1278
1678
|
return i(
|
|
1279
1679
|
function() {
|
|
1280
|
-
|
|
1680
|
+
S.hasValue = !0, S.value = O;
|
|
1281
1681
|
},
|
|
1282
|
-
[
|
|
1283
|
-
),
|
|
1682
|
+
[O]
|
|
1683
|
+
), b(O), O;
|
|
1284
1684
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1285
|
-
})()),
|
|
1685
|
+
})()), z;
|
|
1286
1686
|
}
|
|
1287
|
-
var
|
|
1288
|
-
function
|
|
1289
|
-
return
|
|
1687
|
+
var de;
|
|
1688
|
+
function We() {
|
|
1689
|
+
return de || (de = 1, process.env.NODE_ENV === "production" ? D.exports = Re() : D.exports = He()), D.exports;
|
|
1290
1690
|
}
|
|
1291
|
-
var
|
|
1292
|
-
function
|
|
1293
|
-
|
|
1691
|
+
var Pe = We();
|
|
1692
|
+
function Z(o, e) {
|
|
1693
|
+
j(
|
|
1294
1694
|
typeof e == "string",
|
|
1295
1695
|
`The target step must be a string, was ${typeof e}`
|
|
1296
1696
|
);
|
|
1297
|
-
const { as: t, isValidStepNumber: r } = o.stepSchema.steps,
|
|
1697
|
+
const { as: t, isValidStepNumber: r } = o.stepSchema.steps, s = new Intl.ListFormat("en", {
|
|
1298
1698
|
type: "disjunction",
|
|
1299
1699
|
style: "long"
|
|
1300
1700
|
}).format(t("array.string.untyped"));
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
`The target step must match the following format: "step{number}". Available steps are ${
|
|
1701
|
+
j(
|
|
1702
|
+
ve.test(e),
|
|
1703
|
+
`The target step must match the following format: "step{number}". Available steps are ${s}`
|
|
1304
1704
|
);
|
|
1305
1705
|
const i = Number.parseInt(e.replace("step", ""));
|
|
1306
|
-
return
|
|
1706
|
+
return j(
|
|
1307
1707
|
r(i),
|
|
1308
|
-
`The step number "${i}" is not a valid step number. Valid step numbers include ${
|
|
1708
|
+
`The step number "${i}" is not a valid step number. Valid step numbers include ${s}`,
|
|
1309
1709
|
TypeError
|
|
1310
1710
|
), i;
|
|
1311
1711
|
}
|
|
1312
|
-
function
|
|
1712
|
+
function Ee(o) {
|
|
1313
1713
|
function e(t) {
|
|
1314
|
-
return
|
|
1714
|
+
return Pe.useSyncExternalStoreWithSelector(
|
|
1315
1715
|
o.subscribe,
|
|
1316
1716
|
() => o.getSnapshot(),
|
|
1317
1717
|
() => o.getSnapshot(),
|
|
1318
1718
|
(r) => {
|
|
1319
1719
|
if (typeof t == "object") {
|
|
1320
|
-
const
|
|
1720
|
+
const n = Z(
|
|
1321
1721
|
r,
|
|
1322
1722
|
t.targetStep
|
|
1323
1723
|
);
|
|
1324
|
-
return r.stepSchema.get({ step:
|
|
1724
|
+
return r.stepSchema.get({ step: n }).data;
|
|
1325
1725
|
}
|
|
1326
1726
|
return typeof t == "function" ? t(r) : r;
|
|
1327
1727
|
}
|
|
@@ -1329,88 +1729,88 @@ function ye(o) {
|
|
|
1329
1729
|
}
|
|
1330
1730
|
return e;
|
|
1331
1731
|
}
|
|
1332
|
-
function
|
|
1333
|
-
const t =
|
|
1732
|
+
function qe(o, e) {
|
|
1733
|
+
const t = Ee(o);
|
|
1334
1734
|
return typeof e == "object" || typeof e == "function" ? t(e) : t();
|
|
1335
1735
|
}
|
|
1336
|
-
function
|
|
1736
|
+
function he(o) {
|
|
1337
1737
|
return function(e) {
|
|
1338
1738
|
return ((t) => e(o, t));
|
|
1339
1739
|
};
|
|
1340
1740
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const e =
|
|
1343
|
-
function t(
|
|
1344
|
-
const { targetStep:
|
|
1345
|
-
targetStep:
|
|
1346
|
-
}),
|
|
1741
|
+
function ze(o) {
|
|
1742
|
+
const e = Ee(o);
|
|
1743
|
+
function t(y) {
|
|
1744
|
+
const { targetStep: b, notFoundMessage: f, isDataGuaranteed: g } = y, c = e({
|
|
1745
|
+
targetStep: b
|
|
1746
|
+
}), m = f ? i({ targetStep: b }, f) : (p) => /* @__PURE__ */ te("div", { ...p, children: [
|
|
1347
1747
|
"No data found for step ",
|
|
1348
|
-
String(
|
|
1748
|
+
String(b)
|
|
1349
1749
|
] });
|
|
1350
|
-
return
|
|
1351
|
-
data:
|
|
1352
|
-
NoCurrentData:
|
|
1353
|
-
} :
|
|
1354
|
-
data:
|
|
1750
|
+
return g ? {
|
|
1751
|
+
data: c,
|
|
1752
|
+
NoCurrentData: m
|
|
1753
|
+
} : ee.hasData(c) ? {
|
|
1754
|
+
data: c,
|
|
1355
1755
|
hasData: !0,
|
|
1356
|
-
NoCurrentData:
|
|
1756
|
+
NoCurrentData: m
|
|
1357
1757
|
} : {
|
|
1358
1758
|
data: void 0,
|
|
1359
1759
|
hasData: !1,
|
|
1360
|
-
NoCurrentData:
|
|
1760
|
+
NoCurrentData: m
|
|
1361
1761
|
};
|
|
1362
1762
|
}
|
|
1363
|
-
function r(
|
|
1364
|
-
const
|
|
1365
|
-
(
|
|
1763
|
+
function r(y) {
|
|
1764
|
+
const b = e(
|
|
1765
|
+
(O) => O.stepSchema.steps.value.length
|
|
1366
1766
|
), {
|
|
1367
1767
|
targetStep: f,
|
|
1368
|
-
maxProgressValue:
|
|
1369
|
-
totalSteps:
|
|
1370
|
-
progressTextTransformer:
|
|
1371
|
-
} =
|
|
1372
|
-
{ targetStep: f, maxProgressValue:
|
|
1373
|
-
|
|
1374
|
-
) : (
|
|
1768
|
+
maxProgressValue: g = 100,
|
|
1769
|
+
totalSteps: c = b,
|
|
1770
|
+
progressTextTransformer: m
|
|
1771
|
+
} = y, p = Z(o, f), v = p / c * g, S = m ? s(
|
|
1772
|
+
{ targetStep: f, maxProgressValue: g, totalSteps: c },
|
|
1773
|
+
m
|
|
1774
|
+
) : (O) => /* @__PURE__ */ te("div", { ...O, children: [
|
|
1375
1775
|
"Step ",
|
|
1376
|
-
|
|
1776
|
+
p,
|
|
1377
1777
|
"/",
|
|
1378
|
-
|
|
1778
|
+
c
|
|
1379
1779
|
] });
|
|
1380
1780
|
return {
|
|
1381
|
-
value:
|
|
1382
|
-
maxProgressValue:
|
|
1383
|
-
ProgressText:
|
|
1781
|
+
value: v,
|
|
1782
|
+
maxProgressValue: g,
|
|
1783
|
+
ProgressText: S
|
|
1384
1784
|
};
|
|
1385
1785
|
}
|
|
1386
|
-
function
|
|
1387
|
-
const f = e((
|
|
1388
|
-
return
|
|
1786
|
+
function n(y) {
|
|
1787
|
+
const f = e((c) => c.storage).get(), g = !!(f && typeof f == "object" && Object.keys(f).length > 0);
|
|
1788
|
+
return y ? y(g) : g;
|
|
1389
1789
|
}
|
|
1390
|
-
function
|
|
1391
|
-
const f = o.getSnapshot().stepSchema.steps.value.length, { targetStep:
|
|
1392
|
-
return
|
|
1790
|
+
function s(y, b) {
|
|
1791
|
+
const f = o.getSnapshot().stepSchema.steps.value.length, { targetStep: g, maxProgressValue: c = 100, totalSteps: m = f } = y;
|
|
1792
|
+
return he({ targetStep: g, maxProgressValue: c, totalSteps: m })(b);
|
|
1393
1793
|
}
|
|
1394
|
-
function i(
|
|
1395
|
-
return
|
|
1794
|
+
function i(y, b) {
|
|
1795
|
+
return Z(o, y.targetStep), he(y)(b);
|
|
1396
1796
|
}
|
|
1397
1797
|
return {
|
|
1398
1798
|
// MultiStepFormContext: Context,
|
|
1399
1799
|
useMultiStepFormData: e,
|
|
1400
1800
|
useCurrentStepData: t,
|
|
1401
1801
|
useProgress: r,
|
|
1402
|
-
useCanRestartForm:
|
|
1403
|
-
withProgressText:
|
|
1802
|
+
useCanRestartForm: n,
|
|
1803
|
+
withProgressText: s,
|
|
1404
1804
|
withNoStepDataFound: i
|
|
1405
1805
|
};
|
|
1406
1806
|
}
|
|
1407
1807
|
export {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1808
|
+
Le as MultiStepFormSchema,
|
|
1809
|
+
De as MultiStepFormStepSchema,
|
|
1810
|
+
Y as StepSpecificComponent,
|
|
1811
|
+
Ie as createDefaultValues,
|
|
1812
|
+
ze as createMultiStepFormContext,
|
|
1813
|
+
Be as createMultiStepFormSchema,
|
|
1814
|
+
qe as useMultiStepFormData
|
|
1415
1815
|
};
|
|
1416
1816
|
//# sourceMappingURL=index.mjs.map
|