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