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