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