@d1os/simple-wizard 1.0.0
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/README.md +283 -0
- package/dist/components/content.d.ts +5 -0
- package/dist/components/content.d.ts.map +1 -0
- package/dist/context.d.ts +22 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/simple-wizard.cjs +2 -0
- package/dist/simple-wizard.cjs.map +1 -0
- package/dist/simple-wizard.js +855 -0
- package/dist/simple-wizard.js.map +1 -0
- package/dist/store.d.ts +27 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/wizard.d.ts +10 -0
- package/dist/wizard.d.ts.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
import { jsx as R, jsxs as ue } from "react/jsx-runtime";
|
|
2
|
+
import b, { createContext as fe, useContext as le, useRef as de, useEffect as _e, useMemo as pe, Children as ye, isValidElement as he } from "react";
|
|
3
|
+
const H = (e) => {
|
|
4
|
+
let t;
|
|
5
|
+
const r = /* @__PURE__ */ new Set(), n = (o, l) => {
|
|
6
|
+
const p = typeof o == "function" ? o(t) : o;
|
|
7
|
+
if (!Object.is(p, t)) {
|
|
8
|
+
const x = t;
|
|
9
|
+
t = l ?? (typeof p != "object" || p === null) ? p : Object.assign({}, t, p), r.forEach((G) => G(t, x));
|
|
10
|
+
}
|
|
11
|
+
}, i = () => t, a = { setState: n, getState: i, getInitialState: () => s, subscribe: (o) => (r.add(o), () => r.delete(o)) }, s = t = e(n, i, a);
|
|
12
|
+
return a;
|
|
13
|
+
}, me = ((e) => e ? H(e) : H), Se = (e) => e;
|
|
14
|
+
function be(e, t = Se) {
|
|
15
|
+
const r = b.useSyncExternalStore(
|
|
16
|
+
e.subscribe,
|
|
17
|
+
b.useCallback(() => t(e.getState()), [e, t]),
|
|
18
|
+
b.useCallback(() => t(e.getInitialState()), [e, t])
|
|
19
|
+
);
|
|
20
|
+
return b.useDebugValue(r), r;
|
|
21
|
+
}
|
|
22
|
+
var re = Symbol.for("immer-nothing"), J = Symbol.for("immer-draftable"), f = Symbol.for("immer-state"), ge = process.env.NODE_ENV !== "production" ? [
|
|
23
|
+
// All error codes, starting by 0:
|
|
24
|
+
function(e) {
|
|
25
|
+
return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`;
|
|
26
|
+
},
|
|
27
|
+
function(e) {
|
|
28
|
+
return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`;
|
|
29
|
+
},
|
|
30
|
+
"This object has been frozen and should not be mutated",
|
|
31
|
+
function(e) {
|
|
32
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e;
|
|
33
|
+
},
|
|
34
|
+
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
35
|
+
"Immer forbids circular references",
|
|
36
|
+
"The first or second argument to `produce` must be a function",
|
|
37
|
+
"The third argument to `produce` must be a function or undefined",
|
|
38
|
+
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
39
|
+
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
40
|
+
function(e) {
|
|
41
|
+
return `'current' expects a draft, got: ${e}`;
|
|
42
|
+
},
|
|
43
|
+
"Object.defineProperty() cannot be used on an Immer draft",
|
|
44
|
+
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
45
|
+
"Immer only supports deleting array indices",
|
|
46
|
+
"Immer only supports setting array indices and the 'length' property",
|
|
47
|
+
function(e) {
|
|
48
|
+
return `'original' expects a draft, got: ${e}`;
|
|
49
|
+
}
|
|
50
|
+
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
51
|
+
// See Patches.ts for additional errors
|
|
52
|
+
] : [];
|
|
53
|
+
function _(e, ...t) {
|
|
54
|
+
if (process.env.NODE_ENV !== "production") {
|
|
55
|
+
const r = ge[e], n = typeof r == "function" ? r.apply(null, t) : r;
|
|
56
|
+
throw new Error(`[Immer] ${n}`);
|
|
57
|
+
}
|
|
58
|
+
throw new Error(
|
|
59
|
+
`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
var g = Object.getPrototypeOf;
|
|
63
|
+
function S(e) {
|
|
64
|
+
return !!e && !!e[f];
|
|
65
|
+
}
|
|
66
|
+
function h(e) {
|
|
67
|
+
var t;
|
|
68
|
+
return e ? ne(e) || Array.isArray(e) || !!e[J] || !!((t = e.constructor) != null && t[J]) || O(e) || N(e) : !1;
|
|
69
|
+
}
|
|
70
|
+
var Pe = Object.prototype.constructor.toString(), X = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
function ne(e) {
|
|
72
|
+
if (!e || typeof e != "object")
|
|
73
|
+
return !1;
|
|
74
|
+
const t = Object.getPrototypeOf(e);
|
|
75
|
+
if (t === null || t === Object.prototype)
|
|
76
|
+
return !0;
|
|
77
|
+
const r = Object.hasOwnProperty.call(t, "constructor") && t.constructor;
|
|
78
|
+
if (r === Object)
|
|
79
|
+
return !0;
|
|
80
|
+
if (typeof r != "function")
|
|
81
|
+
return !1;
|
|
82
|
+
let n = X.get(r);
|
|
83
|
+
return n === void 0 && (n = Function.toString.call(r), X.set(r, n)), n === Pe;
|
|
84
|
+
}
|
|
85
|
+
function P(e, t, r = !0) {
|
|
86
|
+
A(e) === 0 ? (r ? Reflect.ownKeys(e) : Object.keys(e)).forEach((i) => {
|
|
87
|
+
t(i, e[i], e);
|
|
88
|
+
}) : e.forEach((n, i) => t(i, n, e));
|
|
89
|
+
}
|
|
90
|
+
function A(e) {
|
|
91
|
+
const t = e[f];
|
|
92
|
+
return t ? t.type_ : Array.isArray(e) ? 1 : O(e) ? 2 : N(e) ? 3 : 0;
|
|
93
|
+
}
|
|
94
|
+
function T(e, t) {
|
|
95
|
+
return A(e) === 2 ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
|
|
96
|
+
}
|
|
97
|
+
function ie(e, t, r) {
|
|
98
|
+
const n = A(e);
|
|
99
|
+
n === 2 ? e.set(t, r) : n === 3 ? e.add(r) : e[t] = r;
|
|
100
|
+
}
|
|
101
|
+
function we(e, t) {
|
|
102
|
+
return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
|
|
103
|
+
}
|
|
104
|
+
function O(e) {
|
|
105
|
+
return e instanceof Map;
|
|
106
|
+
}
|
|
107
|
+
function N(e) {
|
|
108
|
+
return e instanceof Set;
|
|
109
|
+
}
|
|
110
|
+
function d(e) {
|
|
111
|
+
return e.copy_ || e.base_;
|
|
112
|
+
}
|
|
113
|
+
function W(e, t) {
|
|
114
|
+
if (O(e))
|
|
115
|
+
return new Map(e);
|
|
116
|
+
if (N(e))
|
|
117
|
+
return new Set(e);
|
|
118
|
+
if (Array.isArray(e))
|
|
119
|
+
return Array.prototype.slice.call(e);
|
|
120
|
+
const r = ne(e);
|
|
121
|
+
if (t === !0 || t === "class_only" && !r) {
|
|
122
|
+
const n = Object.getOwnPropertyDescriptors(e);
|
|
123
|
+
delete n[f];
|
|
124
|
+
let i = Reflect.ownKeys(n);
|
|
125
|
+
for (let c = 0; c < i.length; c++) {
|
|
126
|
+
const u = i[c], a = n[u];
|
|
127
|
+
a.writable === !1 && (a.writable = !0, a.configurable = !0), (a.get || a.set) && (n[u] = {
|
|
128
|
+
configurable: !0,
|
|
129
|
+
writable: !0,
|
|
130
|
+
// could live with !!desc.set as well here...
|
|
131
|
+
enumerable: a.enumerable,
|
|
132
|
+
value: e[u]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return Object.create(g(e), n);
|
|
136
|
+
} else {
|
|
137
|
+
const n = g(e);
|
|
138
|
+
if (n !== null && r)
|
|
139
|
+
return { ...e };
|
|
140
|
+
const i = Object.create(n);
|
|
141
|
+
return Object.assign(i, e);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function K(e, t = !1) {
|
|
145
|
+
return F(e) || S(e) || !h(e) || (A(e) > 1 && Object.defineProperties(e, {
|
|
146
|
+
set: E,
|
|
147
|
+
add: E,
|
|
148
|
+
clear: E,
|
|
149
|
+
delete: E
|
|
150
|
+
}), Object.freeze(e), t && Object.values(e).forEach((r) => K(r, !0))), e;
|
|
151
|
+
}
|
|
152
|
+
function ve() {
|
|
153
|
+
_(2);
|
|
154
|
+
}
|
|
155
|
+
var E = {
|
|
156
|
+
value: ve
|
|
157
|
+
};
|
|
158
|
+
function F(e) {
|
|
159
|
+
return e === null || typeof e != "object" ? !0 : Object.isFrozen(e);
|
|
160
|
+
}
|
|
161
|
+
var U = {};
|
|
162
|
+
function m(e) {
|
|
163
|
+
const t = U[e];
|
|
164
|
+
return t || _(0, e), t;
|
|
165
|
+
}
|
|
166
|
+
function ze(e, t) {
|
|
167
|
+
U[e] || (U[e] = t);
|
|
168
|
+
}
|
|
169
|
+
var w;
|
|
170
|
+
function I() {
|
|
171
|
+
return w;
|
|
172
|
+
}
|
|
173
|
+
function Oe(e, t) {
|
|
174
|
+
return {
|
|
175
|
+
drafts_: [],
|
|
176
|
+
parent_: e,
|
|
177
|
+
immer_: t,
|
|
178
|
+
// Whenever the modified draft contains a draft from another scope, we
|
|
179
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
180
|
+
canAutoFreeze_: !0,
|
|
181
|
+
unfinalizedDrafts_: 0
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function q(e, t) {
|
|
185
|
+
t && (m("Patches"), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
|
|
186
|
+
}
|
|
187
|
+
function L(e) {
|
|
188
|
+
$(e), e.drafts_.forEach(xe), e.drafts_ = null;
|
|
189
|
+
}
|
|
190
|
+
function $(e) {
|
|
191
|
+
e === w && (w = e.parent_);
|
|
192
|
+
}
|
|
193
|
+
function Q(e) {
|
|
194
|
+
return w = Oe(w, e);
|
|
195
|
+
}
|
|
196
|
+
function xe(e) {
|
|
197
|
+
const t = e[f];
|
|
198
|
+
t.type_ === 0 || t.type_ === 1 ? t.revoke_() : t.revoked_ = !0;
|
|
199
|
+
}
|
|
200
|
+
function Y(e, t) {
|
|
201
|
+
t.unfinalizedDrafts_ = t.drafts_.length;
|
|
202
|
+
const r = t.drafts_[0];
|
|
203
|
+
return e !== void 0 && e !== r ? (r[f].modified_ && (L(t), _(4)), h(e) && (e = D(t, e), t.parent_ || M(t, e)), t.patches_ && m("Patches").generateReplacementPatches_(
|
|
204
|
+
r[f].base_,
|
|
205
|
+
e,
|
|
206
|
+
t.patches_,
|
|
207
|
+
t.inversePatches_
|
|
208
|
+
)) : e = D(t, r, []), L(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_), e !== re ? e : void 0;
|
|
209
|
+
}
|
|
210
|
+
function D(e, t, r) {
|
|
211
|
+
if (F(t))
|
|
212
|
+
return t;
|
|
213
|
+
const n = e.immer_.shouldUseStrictIteration(), i = t[f];
|
|
214
|
+
if (!i)
|
|
215
|
+
return P(
|
|
216
|
+
t,
|
|
217
|
+
(c, u) => Z(e, i, t, c, u, r),
|
|
218
|
+
n
|
|
219
|
+
), t;
|
|
220
|
+
if (i.scope_ !== e)
|
|
221
|
+
return t;
|
|
222
|
+
if (!i.modified_)
|
|
223
|
+
return M(e, i.base_, !0), i.base_;
|
|
224
|
+
if (!i.finalized_) {
|
|
225
|
+
i.finalized_ = !0, i.scope_.unfinalizedDrafts_--;
|
|
226
|
+
const c = i.copy_;
|
|
227
|
+
let u = c, a = !1;
|
|
228
|
+
i.type_ === 3 && (u = new Set(c), c.clear(), a = !0), P(
|
|
229
|
+
u,
|
|
230
|
+
(s, o) => Z(
|
|
231
|
+
e,
|
|
232
|
+
i,
|
|
233
|
+
c,
|
|
234
|
+
s,
|
|
235
|
+
o,
|
|
236
|
+
r,
|
|
237
|
+
a
|
|
238
|
+
),
|
|
239
|
+
n
|
|
240
|
+
), M(e, c, !1), r && e.patches_ && m("Patches").generatePatches_(
|
|
241
|
+
i,
|
|
242
|
+
r,
|
|
243
|
+
e.patches_,
|
|
244
|
+
e.inversePatches_
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
return i.copy_;
|
|
248
|
+
}
|
|
249
|
+
function Z(e, t, r, n, i, c, u) {
|
|
250
|
+
if (i == null || typeof i != "object" && !u)
|
|
251
|
+
return;
|
|
252
|
+
const a = F(i);
|
|
253
|
+
if (!(a && !u)) {
|
|
254
|
+
if (process.env.NODE_ENV !== "production" && i === r && _(5), S(i)) {
|
|
255
|
+
const s = c && t && t.type_ !== 3 && // Set objects are atomic since they have no keys.
|
|
256
|
+
!T(t.assigned_, n) ? c.concat(n) : void 0, o = D(e, i, s);
|
|
257
|
+
if (ie(r, n, o), S(o))
|
|
258
|
+
e.canAutoFreeze_ = !1;
|
|
259
|
+
else
|
|
260
|
+
return;
|
|
261
|
+
} else u && r.add(i);
|
|
262
|
+
if (h(i) && !a) {
|
|
263
|
+
if (!e.immer_.autoFreeze_ && e.unfinalizedDrafts_ < 1 || t && t.base_ && t.base_[n] === i && a)
|
|
264
|
+
return;
|
|
265
|
+
D(e, i), (!t || !t.scope_.parent_) && typeof n != "symbol" && (O(r) ? r.has(n) : Object.prototype.propertyIsEnumerable.call(r, n)) && M(e, i);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function M(e, t, r = !1) {
|
|
270
|
+
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && K(t, r);
|
|
271
|
+
}
|
|
272
|
+
function Ee(e, t) {
|
|
273
|
+
const r = Array.isArray(e), n = {
|
|
274
|
+
type_: r ? 1 : 0,
|
|
275
|
+
// Track which produce call this is associated with.
|
|
276
|
+
scope_: t ? t.scope_ : I(),
|
|
277
|
+
// True for both shallow and deep changes.
|
|
278
|
+
modified_: !1,
|
|
279
|
+
// Used during finalization.
|
|
280
|
+
finalized_: !1,
|
|
281
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
282
|
+
assigned_: {},
|
|
283
|
+
// The parent draft state.
|
|
284
|
+
parent_: t,
|
|
285
|
+
// The base state.
|
|
286
|
+
base_: e,
|
|
287
|
+
// The base proxy.
|
|
288
|
+
draft_: null,
|
|
289
|
+
// set below
|
|
290
|
+
// The base copy with any updated values.
|
|
291
|
+
copy_: null,
|
|
292
|
+
// Called by the `produce` function.
|
|
293
|
+
revoke_: null,
|
|
294
|
+
isManual_: !1
|
|
295
|
+
};
|
|
296
|
+
let i = n, c = B;
|
|
297
|
+
r && (i = [n], c = v);
|
|
298
|
+
const { revoke: u, proxy: a } = Proxy.revocable(i, c);
|
|
299
|
+
return n.draft_ = a, n.revoke_ = u, a;
|
|
300
|
+
}
|
|
301
|
+
var B = {
|
|
302
|
+
get(e, t) {
|
|
303
|
+
if (t === f)
|
|
304
|
+
return e;
|
|
305
|
+
const r = d(e);
|
|
306
|
+
if (!T(r, t))
|
|
307
|
+
return Ce(e, r, t);
|
|
308
|
+
const n = r[t];
|
|
309
|
+
return e.finalized_ || !h(n) ? n : n === j(e.base_, t) ? (k(e), e.copy_[t] = z(n, e)) : n;
|
|
310
|
+
},
|
|
311
|
+
has(e, t) {
|
|
312
|
+
return t in d(e);
|
|
313
|
+
},
|
|
314
|
+
ownKeys(e) {
|
|
315
|
+
return Reflect.ownKeys(d(e));
|
|
316
|
+
},
|
|
317
|
+
set(e, t, r) {
|
|
318
|
+
const n = se(d(e), t);
|
|
319
|
+
if (n != null && n.set)
|
|
320
|
+
return n.set.call(e.draft_, r), !0;
|
|
321
|
+
if (!e.modified_) {
|
|
322
|
+
const i = j(d(e), t), c = i == null ? void 0 : i[f];
|
|
323
|
+
if (c && c.base_ === r)
|
|
324
|
+
return e.copy_[t] = r, e.assigned_[t] = !1, !0;
|
|
325
|
+
if (we(r, i) && (r !== void 0 || T(e.base_, t)))
|
|
326
|
+
return !0;
|
|
327
|
+
k(e), y(e);
|
|
328
|
+
}
|
|
329
|
+
return e.copy_[t] === r && // special case: handle new props with value 'undefined'
|
|
330
|
+
(r !== void 0 || t in e.copy_) || // special case: NaN
|
|
331
|
+
Number.isNaN(r) && Number.isNaN(e.copy_[t]) || (e.copy_[t] = r, e.assigned_[t] = !0), !0;
|
|
332
|
+
},
|
|
333
|
+
deleteProperty(e, t) {
|
|
334
|
+
return j(e.base_, t) !== void 0 || t in e.base_ ? (e.assigned_[t] = !1, k(e), y(e)) : delete e.assigned_[t], e.copy_ && delete e.copy_[t], !0;
|
|
335
|
+
},
|
|
336
|
+
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
337
|
+
// the same guarantee in ES5 mode.
|
|
338
|
+
getOwnPropertyDescriptor(e, t) {
|
|
339
|
+
const r = d(e), n = Reflect.getOwnPropertyDescriptor(r, t);
|
|
340
|
+
return n && {
|
|
341
|
+
writable: !0,
|
|
342
|
+
configurable: e.type_ !== 1 || t !== "length",
|
|
343
|
+
enumerable: n.enumerable,
|
|
344
|
+
value: r[t]
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
defineProperty() {
|
|
348
|
+
_(11);
|
|
349
|
+
},
|
|
350
|
+
getPrototypeOf(e) {
|
|
351
|
+
return g(e.base_);
|
|
352
|
+
},
|
|
353
|
+
setPrototypeOf() {
|
|
354
|
+
_(12);
|
|
355
|
+
}
|
|
356
|
+
}, v = {};
|
|
357
|
+
P(B, (e, t) => {
|
|
358
|
+
v[e] = function() {
|
|
359
|
+
return arguments[0] = arguments[0][0], t.apply(this, arguments);
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
v.deleteProperty = function(e, t) {
|
|
363
|
+
return process.env.NODE_ENV !== "production" && isNaN(parseInt(t)) && _(13), v.set.call(this, e, t, void 0);
|
|
364
|
+
};
|
|
365
|
+
v.set = function(e, t, r) {
|
|
366
|
+
return process.env.NODE_ENV !== "production" && t !== "length" && isNaN(parseInt(t)) && _(14), B.set.call(this, e[0], t, r, e[0]);
|
|
367
|
+
};
|
|
368
|
+
function j(e, t) {
|
|
369
|
+
const r = e[f];
|
|
370
|
+
return (r ? d(r) : e)[t];
|
|
371
|
+
}
|
|
372
|
+
function Ce(e, t, r) {
|
|
373
|
+
var i;
|
|
374
|
+
const n = se(t, r);
|
|
375
|
+
return n ? "value" in n ? n.value : (
|
|
376
|
+
// This is a very special case, if the prop is a getter defined by the
|
|
377
|
+
// prototype, we should invoke it with the draft as context!
|
|
378
|
+
(i = n.get) == null ? void 0 : i.call(e.draft_)
|
|
379
|
+
) : void 0;
|
|
380
|
+
}
|
|
381
|
+
function se(e, t) {
|
|
382
|
+
if (!(t in e))
|
|
383
|
+
return;
|
|
384
|
+
let r = g(e);
|
|
385
|
+
for (; r; ) {
|
|
386
|
+
const n = Object.getOwnPropertyDescriptor(r, t);
|
|
387
|
+
if (n)
|
|
388
|
+
return n;
|
|
389
|
+
r = g(r);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function y(e) {
|
|
393
|
+
e.modified_ || (e.modified_ = !0, e.parent_ && y(e.parent_));
|
|
394
|
+
}
|
|
395
|
+
function k(e) {
|
|
396
|
+
e.copy_ || (e.copy_ = W(
|
|
397
|
+
e.base_,
|
|
398
|
+
e.scope_.immer_.useStrictShallowCopy_
|
|
399
|
+
));
|
|
400
|
+
}
|
|
401
|
+
var Ie = class {
|
|
402
|
+
constructor(e) {
|
|
403
|
+
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !0, this.produce = (t, r, n) => {
|
|
404
|
+
if (typeof t == "function" && typeof r != "function") {
|
|
405
|
+
const c = r;
|
|
406
|
+
r = t;
|
|
407
|
+
const u = this;
|
|
408
|
+
return function(s = c, ...o) {
|
|
409
|
+
return u.produce(s, (l) => r.call(this, l, ...o));
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
typeof r != "function" && _(6), n !== void 0 && typeof n != "function" && _(7);
|
|
413
|
+
let i;
|
|
414
|
+
if (h(t)) {
|
|
415
|
+
const c = Q(this), u = z(t, void 0);
|
|
416
|
+
let a = !0;
|
|
417
|
+
try {
|
|
418
|
+
i = r(u), a = !1;
|
|
419
|
+
} finally {
|
|
420
|
+
a ? L(c) : $(c);
|
|
421
|
+
}
|
|
422
|
+
return q(c, n), Y(i, c);
|
|
423
|
+
} else if (!t || typeof t != "object") {
|
|
424
|
+
if (i = r(t), i === void 0 && (i = t), i === re && (i = void 0), this.autoFreeze_ && K(i, !0), n) {
|
|
425
|
+
const c = [], u = [];
|
|
426
|
+
m("Patches").generateReplacementPatches_(t, i, c, u), n(c, u);
|
|
427
|
+
}
|
|
428
|
+
return i;
|
|
429
|
+
} else
|
|
430
|
+
_(1, t);
|
|
431
|
+
}, this.produceWithPatches = (t, r) => {
|
|
432
|
+
if (typeof t == "function")
|
|
433
|
+
return (u, ...a) => this.produceWithPatches(u, (s) => t(s, ...a));
|
|
434
|
+
let n, i;
|
|
435
|
+
return [this.produce(t, r, (u, a) => {
|
|
436
|
+
n = u, i = a;
|
|
437
|
+
}), n, i];
|
|
438
|
+
}, typeof (e == null ? void 0 : e.autoFreeze) == "boolean" && this.setAutoFreeze(e.autoFreeze), typeof (e == null ? void 0 : e.useStrictShallowCopy) == "boolean" && this.setUseStrictShallowCopy(e.useStrictShallowCopy), typeof (e == null ? void 0 : e.useStrictIteration) == "boolean" && this.setUseStrictIteration(e.useStrictIteration);
|
|
439
|
+
}
|
|
440
|
+
createDraft(e) {
|
|
441
|
+
h(e) || _(8), S(e) && (e = De(e));
|
|
442
|
+
const t = Q(this), r = z(e, void 0);
|
|
443
|
+
return r[f].isManual_ = !0, $(t), r;
|
|
444
|
+
}
|
|
445
|
+
finishDraft(e, t) {
|
|
446
|
+
const r = e && e[f];
|
|
447
|
+
(!r || !r.isManual_) && _(9);
|
|
448
|
+
const { scope_: n } = r;
|
|
449
|
+
return q(n, t), Y(void 0, n);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
453
|
+
*
|
|
454
|
+
* By default, auto-freezing is enabled.
|
|
455
|
+
*/
|
|
456
|
+
setAutoFreeze(e) {
|
|
457
|
+
this.autoFreeze_ = e;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Pass true to enable strict shallow copy.
|
|
461
|
+
*
|
|
462
|
+
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
463
|
+
*/
|
|
464
|
+
setUseStrictShallowCopy(e) {
|
|
465
|
+
this.useStrictShallowCopy_ = e;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Pass false to use faster iteration that skips non-enumerable properties
|
|
469
|
+
* but still handles symbols for compatibility.
|
|
470
|
+
*
|
|
471
|
+
* By default, strict iteration is enabled (includes all own properties).
|
|
472
|
+
*/
|
|
473
|
+
setUseStrictIteration(e) {
|
|
474
|
+
this.useStrictIteration_ = e;
|
|
475
|
+
}
|
|
476
|
+
shouldUseStrictIteration() {
|
|
477
|
+
return this.useStrictIteration_;
|
|
478
|
+
}
|
|
479
|
+
applyPatches(e, t) {
|
|
480
|
+
let r;
|
|
481
|
+
for (r = t.length - 1; r >= 0; r--) {
|
|
482
|
+
const i = t[r];
|
|
483
|
+
if (i.path.length === 0 && i.op === "replace") {
|
|
484
|
+
e = i.value;
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
r > -1 && (t = t.slice(r + 1));
|
|
489
|
+
const n = m("Patches").applyPatches_;
|
|
490
|
+
return S(e) ? n(e, t) : this.produce(
|
|
491
|
+
e,
|
|
492
|
+
(i) => n(i, t)
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
function z(e, t) {
|
|
497
|
+
const r = O(e) ? m("MapSet").proxyMap_(e, t) : N(e) ? m("MapSet").proxySet_(e, t) : Ee(e, t);
|
|
498
|
+
return (t ? t.scope_ : I()).drafts_.push(r), r;
|
|
499
|
+
}
|
|
500
|
+
function De(e) {
|
|
501
|
+
return S(e) || _(10, e), oe(e);
|
|
502
|
+
}
|
|
503
|
+
function oe(e) {
|
|
504
|
+
if (!h(e) || F(e))
|
|
505
|
+
return e;
|
|
506
|
+
const t = e[f];
|
|
507
|
+
let r, n = !0;
|
|
508
|
+
if (t) {
|
|
509
|
+
if (!t.modified_)
|
|
510
|
+
return t.base_;
|
|
511
|
+
t.finalized_ = !0, r = W(e, t.scope_.immer_.useStrictShallowCopy_), n = t.scope_.immer_.shouldUseStrictIteration();
|
|
512
|
+
} else
|
|
513
|
+
r = W(e, !0);
|
|
514
|
+
return P(
|
|
515
|
+
r,
|
|
516
|
+
(i, c) => {
|
|
517
|
+
ie(r, i, oe(c));
|
|
518
|
+
},
|
|
519
|
+
n
|
|
520
|
+
), t && (t.finalized_ = !1), r;
|
|
521
|
+
}
|
|
522
|
+
function Me() {
|
|
523
|
+
class e extends Map {
|
|
524
|
+
constructor(s, o) {
|
|
525
|
+
super(), this[f] = {
|
|
526
|
+
type_: 2,
|
|
527
|
+
parent_: o,
|
|
528
|
+
scope_: o ? o.scope_ : I(),
|
|
529
|
+
modified_: !1,
|
|
530
|
+
finalized_: !1,
|
|
531
|
+
copy_: void 0,
|
|
532
|
+
assigned_: void 0,
|
|
533
|
+
base_: s,
|
|
534
|
+
draft_: this,
|
|
535
|
+
isManual_: !1,
|
|
536
|
+
revoked_: !1
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
get size() {
|
|
540
|
+
return d(this[f]).size;
|
|
541
|
+
}
|
|
542
|
+
has(s) {
|
|
543
|
+
return d(this[f]).has(s);
|
|
544
|
+
}
|
|
545
|
+
set(s, o) {
|
|
546
|
+
const l = this[f];
|
|
547
|
+
return u(l), (!d(l).has(s) || d(l).get(s) !== o) && (r(l), y(l), l.assigned_.set(s, !0), l.copy_.set(s, o), l.assigned_.set(s, !0)), this;
|
|
548
|
+
}
|
|
549
|
+
delete(s) {
|
|
550
|
+
if (!this.has(s))
|
|
551
|
+
return !1;
|
|
552
|
+
const o = this[f];
|
|
553
|
+
return u(o), r(o), y(o), o.base_.has(s) ? o.assigned_.set(s, !1) : o.assigned_.delete(s), o.copy_.delete(s), !0;
|
|
554
|
+
}
|
|
555
|
+
clear() {
|
|
556
|
+
const s = this[f];
|
|
557
|
+
u(s), d(s).size && (r(s), y(s), s.assigned_ = /* @__PURE__ */ new Map(), P(s.base_, (o) => {
|
|
558
|
+
s.assigned_.set(o, !1);
|
|
559
|
+
}), s.copy_.clear());
|
|
560
|
+
}
|
|
561
|
+
forEach(s, o) {
|
|
562
|
+
const l = this[f];
|
|
563
|
+
d(l).forEach((p, x, G) => {
|
|
564
|
+
s.call(o, this.get(x), x, this);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
get(s) {
|
|
568
|
+
const o = this[f];
|
|
569
|
+
u(o);
|
|
570
|
+
const l = d(o).get(s);
|
|
571
|
+
if (o.finalized_ || !h(l) || l !== o.base_.get(s))
|
|
572
|
+
return l;
|
|
573
|
+
const p = z(l, o);
|
|
574
|
+
return r(o), o.copy_.set(s, p), p;
|
|
575
|
+
}
|
|
576
|
+
keys() {
|
|
577
|
+
return d(this[f]).keys();
|
|
578
|
+
}
|
|
579
|
+
values() {
|
|
580
|
+
const s = this.keys();
|
|
581
|
+
return {
|
|
582
|
+
[Symbol.iterator]: () => this.values(),
|
|
583
|
+
next: () => {
|
|
584
|
+
const o = s.next();
|
|
585
|
+
return o.done ? o : {
|
|
586
|
+
done: !1,
|
|
587
|
+
value: this.get(o.value)
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
entries() {
|
|
593
|
+
const s = this.keys();
|
|
594
|
+
return {
|
|
595
|
+
[Symbol.iterator]: () => this.entries(),
|
|
596
|
+
next: () => {
|
|
597
|
+
const o = s.next();
|
|
598
|
+
if (o.done)
|
|
599
|
+
return o;
|
|
600
|
+
const l = this.get(o.value);
|
|
601
|
+
return {
|
|
602
|
+
done: !1,
|
|
603
|
+
value: [o.value, l]
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
[Symbol.iterator]() {
|
|
609
|
+
return this.entries();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function t(a, s) {
|
|
613
|
+
return new e(a, s);
|
|
614
|
+
}
|
|
615
|
+
function r(a) {
|
|
616
|
+
a.copy_ || (a.assigned_ = /* @__PURE__ */ new Map(), a.copy_ = new Map(a.base_));
|
|
617
|
+
}
|
|
618
|
+
class n extends Set {
|
|
619
|
+
constructor(s, o) {
|
|
620
|
+
super(), this[f] = {
|
|
621
|
+
type_: 3,
|
|
622
|
+
parent_: o,
|
|
623
|
+
scope_: o ? o.scope_ : I(),
|
|
624
|
+
modified_: !1,
|
|
625
|
+
finalized_: !1,
|
|
626
|
+
copy_: void 0,
|
|
627
|
+
base_: s,
|
|
628
|
+
draft_: this,
|
|
629
|
+
drafts_: /* @__PURE__ */ new Map(),
|
|
630
|
+
revoked_: !1,
|
|
631
|
+
isManual_: !1
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
get size() {
|
|
635
|
+
return d(this[f]).size;
|
|
636
|
+
}
|
|
637
|
+
has(s) {
|
|
638
|
+
const o = this[f];
|
|
639
|
+
return u(o), o.copy_ ? !!(o.copy_.has(s) || o.drafts_.has(s) && o.copy_.has(o.drafts_.get(s))) : o.base_.has(s);
|
|
640
|
+
}
|
|
641
|
+
add(s) {
|
|
642
|
+
const o = this[f];
|
|
643
|
+
return u(o), this.has(s) || (c(o), y(o), o.copy_.add(s)), this;
|
|
644
|
+
}
|
|
645
|
+
delete(s) {
|
|
646
|
+
if (!this.has(s))
|
|
647
|
+
return !1;
|
|
648
|
+
const o = this[f];
|
|
649
|
+
return u(o), c(o), y(o), o.copy_.delete(s) || (o.drafts_.has(s) ? o.copy_.delete(o.drafts_.get(s)) : (
|
|
650
|
+
/* istanbul ignore next */
|
|
651
|
+
!1
|
|
652
|
+
));
|
|
653
|
+
}
|
|
654
|
+
clear() {
|
|
655
|
+
const s = this[f];
|
|
656
|
+
u(s), d(s).size && (c(s), y(s), s.copy_.clear());
|
|
657
|
+
}
|
|
658
|
+
values() {
|
|
659
|
+
const s = this[f];
|
|
660
|
+
return u(s), c(s), s.copy_.values();
|
|
661
|
+
}
|
|
662
|
+
entries() {
|
|
663
|
+
const s = this[f];
|
|
664
|
+
return u(s), c(s), s.copy_.entries();
|
|
665
|
+
}
|
|
666
|
+
keys() {
|
|
667
|
+
return this.values();
|
|
668
|
+
}
|
|
669
|
+
[Symbol.iterator]() {
|
|
670
|
+
return this.values();
|
|
671
|
+
}
|
|
672
|
+
forEach(s, o) {
|
|
673
|
+
const l = this.values();
|
|
674
|
+
let p = l.next();
|
|
675
|
+
for (; !p.done; )
|
|
676
|
+
s.call(o, p.value, p.value, this), p = l.next();
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function i(a, s) {
|
|
680
|
+
return new n(a, s);
|
|
681
|
+
}
|
|
682
|
+
function c(a) {
|
|
683
|
+
a.copy_ || (a.copy_ = /* @__PURE__ */ new Set(), a.base_.forEach((s) => {
|
|
684
|
+
if (h(s)) {
|
|
685
|
+
const o = z(s, a);
|
|
686
|
+
a.drafts_.set(s, o), a.copy_.add(o);
|
|
687
|
+
} else
|
|
688
|
+
a.copy_.add(s);
|
|
689
|
+
}));
|
|
690
|
+
}
|
|
691
|
+
function u(a) {
|
|
692
|
+
a.revoked_ && _(3, JSON.stringify(d(a)));
|
|
693
|
+
}
|
|
694
|
+
ze("MapSet", { proxyMap_: t, proxySet_: i });
|
|
695
|
+
}
|
|
696
|
+
var Ae = new Ie(), Ne = Ae.produce;
|
|
697
|
+
const Fe = (e) => (t, r, n) => (n.setState = (i, c, ...u) => {
|
|
698
|
+
const a = typeof i == "function" ? Ne(i) : i;
|
|
699
|
+
return t(a, c, ...u);
|
|
700
|
+
}, e(n.setState, r, n)), je = Fe, C = () => {
|
|
701
|
+
};
|
|
702
|
+
function ke(e) {
|
|
703
|
+
return e instanceof Promise;
|
|
704
|
+
}
|
|
705
|
+
const Re = (e, t) => ({
|
|
706
|
+
activeStep: 0,
|
|
707
|
+
stepCount: 0,
|
|
708
|
+
isLoading: !1,
|
|
709
|
+
nextButtonLabel: "Next",
|
|
710
|
+
previousButtonLabel: "Back",
|
|
711
|
+
isNextButtonDisabled: !1,
|
|
712
|
+
stepAction: C,
|
|
713
|
+
nextStep: (r = 1) => {
|
|
714
|
+
const n = t();
|
|
715
|
+
if (n.activeStep < n.stepCount - r) {
|
|
716
|
+
const i = n.stepAction();
|
|
717
|
+
ke(i) ? (e({ isLoading: !0 }), i.then(() => {
|
|
718
|
+
e((c) => {
|
|
719
|
+
c.activeStep += r, c.stepAction = C;
|
|
720
|
+
});
|
|
721
|
+
}).catch((c) => {
|
|
722
|
+
console.error("Error in stepAction:", c);
|
|
723
|
+
}).finally(() => {
|
|
724
|
+
e({ isLoading: !1 });
|
|
725
|
+
})) : e((c) => {
|
|
726
|
+
c.activeStep += r, c.stepAction = C;
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
previousStep: (r = 1) => e((n) => {
|
|
731
|
+
n.activeStep - r >= 0 && (n.stepAction = C, n.activeStep -= r);
|
|
732
|
+
}),
|
|
733
|
+
setStepAction: (r) => {
|
|
734
|
+
e((n) => {
|
|
735
|
+
n.stepAction = r;
|
|
736
|
+
});
|
|
737
|
+
},
|
|
738
|
+
setIsLoading: (r) => e({ isLoading: r }),
|
|
739
|
+
setActiveStep: (r) => e({ activeStep: r }),
|
|
740
|
+
setStepCount: (r) => e({ stepCount: r }),
|
|
741
|
+
setNextButtonLabel: (r) => e({ nextButtonLabel: r }),
|
|
742
|
+
setPreviousButtonLabel: (r) => e({ previousButtonLabel: r }),
|
|
743
|
+
setNextButtonDisabled: (r) => e({ isNextButtonDisabled: r })
|
|
744
|
+
}), Te = (e = {}) => me(
|
|
745
|
+
je((...t) => ({
|
|
746
|
+
...Re(...t),
|
|
747
|
+
...e
|
|
748
|
+
}))
|
|
749
|
+
), V = (e) => Symbol.iterator in e, ee = (e) => (
|
|
750
|
+
// HACK: avoid checking entries type
|
|
751
|
+
"entries" in e
|
|
752
|
+
), te = (e, t) => {
|
|
753
|
+
const r = e instanceof Map ? e : new Map(e.entries()), n = t instanceof Map ? t : new Map(t.entries());
|
|
754
|
+
if (r.size !== n.size)
|
|
755
|
+
return !1;
|
|
756
|
+
for (const [i, c] of r)
|
|
757
|
+
if (!n.has(i) || !Object.is(c, n.get(i)))
|
|
758
|
+
return !1;
|
|
759
|
+
return !0;
|
|
760
|
+
}, We = (e, t) => {
|
|
761
|
+
const r = e[Symbol.iterator](), n = t[Symbol.iterator]();
|
|
762
|
+
let i = r.next(), c = n.next();
|
|
763
|
+
for (; !i.done && !c.done; ) {
|
|
764
|
+
if (!Object.is(i.value, c.value))
|
|
765
|
+
return !1;
|
|
766
|
+
i = r.next(), c = n.next();
|
|
767
|
+
}
|
|
768
|
+
return !!i.done && !!c.done;
|
|
769
|
+
};
|
|
770
|
+
function Ue(e, t) {
|
|
771
|
+
return Object.is(e, t) ? !0 : typeof e != "object" || e === null || typeof t != "object" || t === null || Object.getPrototypeOf(e) !== Object.getPrototypeOf(t) ? !1 : V(e) && V(t) ? ee(e) && ee(t) ? te(e, t) : We(e, t) : te(
|
|
772
|
+
{ entries: () => Object.entries(e) },
|
|
773
|
+
{ entries: () => Object.entries(t) }
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
function Le(e) {
|
|
777
|
+
const t = b.useRef(void 0);
|
|
778
|
+
return (r) => {
|
|
779
|
+
const n = e(r);
|
|
780
|
+
return Ue(t.current, n) ? t.current : t.current = n;
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
const ce = fe(void 0), $e = ({
|
|
784
|
+
children: e,
|
|
785
|
+
config: t
|
|
786
|
+
}) => {
|
|
787
|
+
const r = de();
|
|
788
|
+
return r.current || (r.current = Te(t)), /* @__PURE__ */ R(ce.Provider, { value: r.current, children: e });
|
|
789
|
+
}, ae = (e) => {
|
|
790
|
+
const t = le(ce);
|
|
791
|
+
if (!t)
|
|
792
|
+
throw new Error("useWizard must be used within a WizardProvider");
|
|
793
|
+
return be(
|
|
794
|
+
t,
|
|
795
|
+
Le((r) => {
|
|
796
|
+
const n = {
|
|
797
|
+
...r,
|
|
798
|
+
isFirstStep: r.activeStep === 0,
|
|
799
|
+
isLastStep: r.activeStep >= r.stepCount - 1
|
|
800
|
+
};
|
|
801
|
+
return e(n);
|
|
802
|
+
})
|
|
803
|
+
);
|
|
804
|
+
}, Ke = ({ stepCount: e }) => {
|
|
805
|
+
const { currentStepCount: t, setStepCount: r, activeStep: n, setActiveStep: i } = ae((c) => ({
|
|
806
|
+
currentStepCount: c.stepCount,
|
|
807
|
+
setStepCount: c.setStepCount,
|
|
808
|
+
activeStep: c.activeStep,
|
|
809
|
+
setActiveStep: c.setActiveStep
|
|
810
|
+
}));
|
|
811
|
+
return _e(() => {
|
|
812
|
+
e !== t && (r(e), n >= e && i(Math.max(0, e - 1)));
|
|
813
|
+
}, [e, t, r, n, i]), null;
|
|
814
|
+
}, Be = ({ steps: e }) => {
|
|
815
|
+
const { activeStep: t } = ae(
|
|
816
|
+
(r) => ({
|
|
817
|
+
activeStep: r.activeStep
|
|
818
|
+
})
|
|
819
|
+
);
|
|
820
|
+
return e[t] ?? null;
|
|
821
|
+
};
|
|
822
|
+
Me();
|
|
823
|
+
function Je({
|
|
824
|
+
header: e = null,
|
|
825
|
+
footer: t = null,
|
|
826
|
+
children: r,
|
|
827
|
+
startAtEnd: n = !1,
|
|
828
|
+
initialStep: i = 0
|
|
829
|
+
}) {
|
|
830
|
+
const c = pe(() => ye.toArray(r).filter((a) => {
|
|
831
|
+
var s;
|
|
832
|
+
return !(a === null || he(a) && ((s = a.props) != null && s.skip));
|
|
833
|
+
}), [r]), u = c.length;
|
|
834
|
+
return /* @__PURE__ */ ue(
|
|
835
|
+
$e,
|
|
836
|
+
{
|
|
837
|
+
config: {
|
|
838
|
+
activeStep: n ? u - 1 : i,
|
|
839
|
+
stepCount: u
|
|
840
|
+
},
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ R(Ke, { stepCount: u }),
|
|
843
|
+
e,
|
|
844
|
+
/* @__PURE__ */ R(Be, { steps: c }),
|
|
845
|
+
t
|
|
846
|
+
]
|
|
847
|
+
}
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
export {
|
|
851
|
+
Je as Wizard,
|
|
852
|
+
ce as WizardContext,
|
|
853
|
+
ae as useWizard
|
|
854
|
+
};
|
|
855
|
+
//# sourceMappingURL=simple-wizard.js.map
|