@goodie-forms/core 1.1.5-alpha → 1.2.0-alpha
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/LICENSE +426 -426
- package/dist/field/FieldPath.d.ts +32 -0
- package/dist/field/FieldPath.d.ts.map +1 -0
- package/dist/field/FieldPathBuilder.d.ts +25 -0
- package/dist/field/FieldPathBuilder.d.ts.map +1 -0
- package/dist/field/Reconcile.d.ts +9 -0
- package/dist/field/Reconcile.d.ts.map +1 -0
- package/dist/form/FormController.d.ts +35 -39
- package/dist/form/FormController.d.ts.map +1 -1
- package/dist/form/FormField.d.ts +12 -10
- package/dist/form/FormField.d.ts.map +1 -1
- package/dist/form/NonullFormField.d.ts +3 -4
- package/dist/form/NonullFormField.d.ts.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +615 -881
- package/dist/index.js.map +1 -1
- package/dist/validation/CustomValidation.d.ts +10 -0
- package/dist/validation/CustomValidation.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/field/FieldPath.ts +292 -0
- package/src/field/FieldPathBuilder.ts +132 -0
- package/src/field/Reconcile.ts +99 -0
- package/src/form/FormController.ts +342 -310
- package/src/form/FormField.ts +200 -202
- package/src/form/NonullFormField.ts +15 -21
- package/src/index.ts +12 -5
- package/src/types/DeepPartial.ts +7 -7
- package/src/types/Mixin.ts +2 -2
- package/src/utils/ensureImmerability.ts +30 -30
- package/src/utils/getId.ts +5 -5
- package/src/utils/removeBy.ts +11 -11
- package/src/{form → validation}/CustomValidation.ts +52 -52
- package/tsconfig.json +8 -7
- package/vite.config.ts +18 -18
- package/dist/form/CustomValidation.d.ts +0 -10
- package/dist/form/CustomValidation.d.ts.map +0 -1
- package/dist/form/Field.d.ts +0 -31
- package/dist/form/Field.d.ts.map +0 -1
- package/src/form/Field.ts +0 -334
package/dist/index.js
CHANGED
|
@@ -1,137 +1,177 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h;
|
|
2
2
|
((t) => {
|
|
3
|
-
function e(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return r.getTime() === c.getTime();
|
|
18
|
-
if (r instanceof RegExp && c instanceof RegExp)
|
|
19
|
-
return r.source === c.source && r.flags === c.flags;
|
|
20
|
-
if (r instanceof Map && c instanceof Map) {
|
|
21
|
-
if (r.size !== c.size) return !1;
|
|
22
|
-
for (const [y, V] of r)
|
|
23
|
-
if (!c.has(y) || !e(V, c.get(y))) return !1;
|
|
24
|
-
return !0;
|
|
25
|
-
}
|
|
26
|
-
if (r instanceof Set && c instanceof Set) {
|
|
27
|
-
if (r.size !== c.size) return !1;
|
|
28
|
-
for (const y of r)
|
|
29
|
-
if (!c.has(y)) return !1;
|
|
30
|
-
return !0;
|
|
31
|
-
}
|
|
32
|
-
if (Object.getPrototypeOf(r) !== Object.getPrototypeOf(c))
|
|
33
|
-
return !1;
|
|
34
|
-
const _ = Object.keys(r), g = Object.keys(c);
|
|
35
|
-
if (_.length !== g.length) return !1;
|
|
36
|
-
for (const y of _)
|
|
37
|
-
if (!Object.prototype.hasOwnProperty.call(c, y) || !e(r[y], c[y])) return !1;
|
|
38
|
-
return !0;
|
|
39
|
-
}
|
|
40
|
-
t.deepEqual = e;
|
|
41
|
-
function n(r, c, l, _) {
|
|
42
|
-
const g = [], y = [], V = [];
|
|
43
|
-
for (const D of c)
|
|
44
|
-
r.some((O) => l(O, D)) ? (_?.(D) ?? !0) && V.push(D) : (_?.(D) ?? !0) && g.push(D);
|
|
45
|
-
for (const D of r)
|
|
46
|
-
c.some((O) => l(D, O)) || (_?.(D) ?? !0) && y.push(D);
|
|
47
|
-
return { added: g, removed: y, unchanged: V };
|
|
48
|
-
}
|
|
49
|
-
t.diff = n;
|
|
50
|
-
function i(r) {
|
|
51
|
-
const c = [];
|
|
3
|
+
function e(c) {
|
|
4
|
+
return c.join(".");
|
|
5
|
+
}
|
|
6
|
+
t.toCanonicalPath = e;
|
|
7
|
+
function i(c) {
|
|
8
|
+
const a = r(c);
|
|
9
|
+
let l = "";
|
|
10
|
+
for (const y of a)
|
|
11
|
+
typeof y == "number" ? l += `[${y}]` : (l.length > 0 && (l += "."), l += y.toString());
|
|
12
|
+
return l;
|
|
13
|
+
}
|
|
14
|
+
t.toStringPath = i;
|
|
15
|
+
function n(c) {
|
|
16
|
+
const a = [];
|
|
52
17
|
let l = 0;
|
|
53
|
-
for (; l <
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
18
|
+
for (; l < c.length; ) {
|
|
19
|
+
const y = c[l];
|
|
20
|
+
if (y === ".") {
|
|
56
21
|
l++;
|
|
57
22
|
continue;
|
|
58
23
|
}
|
|
59
|
-
if (
|
|
24
|
+
if (y === "[") {
|
|
60
25
|
l++;
|
|
61
|
-
let
|
|
62
|
-
for (; l <
|
|
63
|
-
|
|
64
|
-
if (l++, !
|
|
65
|
-
throw new Error(`Invalid array index in path: ${
|
|
66
|
-
|
|
26
|
+
let S = "";
|
|
27
|
+
for (; l < c.length && c[l] !== "]"; )
|
|
28
|
+
S += c[l], l++;
|
|
29
|
+
if (l++, !S || !/^\d+$/.test(S))
|
|
30
|
+
throw new Error(`Invalid array index in path: ${c}`);
|
|
31
|
+
a.push(Number(S));
|
|
67
32
|
continue;
|
|
68
33
|
}
|
|
69
|
-
let
|
|
70
|
-
for (; l <
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return c;
|
|
75
|
-
}
|
|
76
|
-
t.parsePathFragments = i;
|
|
77
|
-
function o(r) {
|
|
78
|
-
let c = "";
|
|
79
|
-
for (const l of r) {
|
|
80
|
-
const _ = typeof l == "object" && "key" in l ? l.key : l;
|
|
81
|
-
typeof _ == "number" ? c += `[${_}]` : (c.length > 0 && (c += "."), c += _.toString());
|
|
34
|
+
let v = "";
|
|
35
|
+
for (; l < c.length && /[^\.\[]/.test(c[l]); )
|
|
36
|
+
v += c[l], l++;
|
|
37
|
+
v && a.push(v);
|
|
82
38
|
}
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
t.
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
39
|
+
return a;
|
|
40
|
+
}
|
|
41
|
+
t.fromStringPath = n;
|
|
42
|
+
function r(c) {
|
|
43
|
+
return c?.map((a) => {
|
|
44
|
+
if (typeof a == "string" || typeof a == "number" || typeof a == "symbol") return a;
|
|
45
|
+
if (typeof a == "object" && "key" in a)
|
|
46
|
+
return typeof a == "string" || typeof a == "number" || typeof a == "symbol" ? a : a.key;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
t.normalize = r;
|
|
50
|
+
function s(c, a) {
|
|
51
|
+
if (c === a) return !0;
|
|
52
|
+
if (c == null || a == null || c.length !== a.length) return !1;
|
|
53
|
+
for (let l = 0; l < c.length; l++)
|
|
54
|
+
if (c[l] !== a[l]) return !1;
|
|
55
|
+
return !0;
|
|
56
|
+
}
|
|
57
|
+
t.equals = s;
|
|
58
|
+
function o(c, a) {
|
|
59
|
+
if (c.length >= a.length) return !1;
|
|
60
|
+
for (let l = 0; l < c.length; l++)
|
|
61
|
+
if (c[l] !== a[l])
|
|
91
62
|
return !1;
|
|
92
63
|
return !0;
|
|
93
64
|
}
|
|
94
|
-
t.isDescendant =
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
65
|
+
t.isDescendant = o;
|
|
66
|
+
function f(c, a) {
|
|
67
|
+
let l = c;
|
|
68
|
+
for (const y of a) {
|
|
69
|
+
if (l == null) return;
|
|
70
|
+
l = l[y];
|
|
71
|
+
}
|
|
72
|
+
return l;
|
|
73
|
+
}
|
|
74
|
+
t.getValue = f;
|
|
75
|
+
function d(c, a, l) {
|
|
76
|
+
return t.modifyValue(c, a, () => l);
|
|
77
|
+
}
|
|
78
|
+
t.setValue = d;
|
|
79
|
+
function u(c, a, l) {
|
|
80
|
+
let y = c;
|
|
81
|
+
for (let A = 0; A < a.length - 1; A++) {
|
|
82
|
+
const Q = a[A], Ot = a[A + 1];
|
|
83
|
+
y[Q] == null && (y[Q] = typeof Ot == "number" ? [] : {}), y = y[Q];
|
|
84
|
+
}
|
|
85
|
+
const v = a[a.length - 1], S = y[v], ht = l(S);
|
|
86
|
+
ht !== void 0 && (y[v] = ht);
|
|
87
|
+
}
|
|
88
|
+
t.modifyValue = u;
|
|
89
|
+
function _(c, a) {
|
|
90
|
+
let l = c;
|
|
91
|
+
for (let v = 0; v < a.length - 1; v++) {
|
|
92
|
+
const S = a[v];
|
|
93
|
+
if (l[S] == null) return;
|
|
94
|
+
l = l[S];
|
|
95
|
+
}
|
|
96
|
+
const y = a[a.length - 1];
|
|
97
|
+
delete l[y];
|
|
98
|
+
}
|
|
99
|
+
t.deleteValue = _;
|
|
100
|
+
})(h || (h = {}));
|
|
101
|
+
const _t = /* @__PURE__ */ Symbol("PathResolver");
|
|
102
|
+
class et {
|
|
103
|
+
static wrap(e) {
|
|
104
|
+
return new Proxy(e, {
|
|
105
|
+
get(i, n, r) {
|
|
106
|
+
if (n === _t) return e;
|
|
107
|
+
const s = typeof n == "string" && /^\d+$/.test(n) ? Number(n) : n;
|
|
108
|
+
return et.wrap([
|
|
109
|
+
...e,
|
|
110
|
+
s
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
fromStringPath(e) {
|
|
116
|
+
return h.fromStringPath(
|
|
117
|
+
e
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
fromProxy(e) {
|
|
121
|
+
return e(et.wrap([]))[_t];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
var V;
|
|
125
|
+
((t) => {
|
|
126
|
+
function e(n, r, s) {
|
|
127
|
+
if (n === r) return !0;
|
|
128
|
+
if (n === null || r === null || typeof n != "object" || typeof r != "object") return !1;
|
|
129
|
+
if (Array.isArray(n)) {
|
|
130
|
+
if (!Array.isArray(r) || n.length !== r.length) return !1;
|
|
131
|
+
for (let d = 0; d < n.length; d++)
|
|
132
|
+
if (!e(n[d], r[d])) return !1;
|
|
133
|
+
return !0;
|
|
134
|
+
}
|
|
135
|
+
if (s != null) {
|
|
136
|
+
const d = s(n, r);
|
|
137
|
+
if (d !== void 0) return d;
|
|
102
138
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let g = r;
|
|
113
|
-
for (let O = 0; O < _.length - 1; O++) {
|
|
114
|
-
const f = _[O], S = _[O + 1];
|
|
115
|
-
g[f] == null && (g[f] = typeof S == "number" ? [] : {}), g = g[f];
|
|
139
|
+
if (n instanceof Date && r instanceof Date)
|
|
140
|
+
return n.getTime() === r.getTime();
|
|
141
|
+
if (n instanceof RegExp && r instanceof RegExp)
|
|
142
|
+
return n.source === r.source && n.flags === r.flags;
|
|
143
|
+
if (n instanceof Map && r instanceof Map) {
|
|
144
|
+
if (n.size !== r.size) return !1;
|
|
145
|
+
for (const [d, u] of n)
|
|
146
|
+
if (!r.has(d) || !e(u, r.get(d))) return !1;
|
|
147
|
+
return !0;
|
|
116
148
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const l = i(c);
|
|
123
|
-
let _ = r;
|
|
124
|
-
for (let y = 0; y < l.length - 1; y++) {
|
|
125
|
-
const V = l[y];
|
|
126
|
-
if (_[V] == null) return;
|
|
127
|
-
_ = _[V];
|
|
149
|
+
if (n instanceof Set && r instanceof Set) {
|
|
150
|
+
if (n.size !== r.size) return !1;
|
|
151
|
+
for (const d of n)
|
|
152
|
+
if (!r.has(d)) return !1;
|
|
153
|
+
return !0;
|
|
128
154
|
}
|
|
129
|
-
|
|
130
|
-
|
|
155
|
+
if (Object.getPrototypeOf(n) !== Object.getPrototypeOf(r))
|
|
156
|
+
return !1;
|
|
157
|
+
const o = Object.keys(n), f = Object.keys(r);
|
|
158
|
+
if (o.length !== f.length) return !1;
|
|
159
|
+
for (const d of o)
|
|
160
|
+
if (!Object.prototype.hasOwnProperty.call(r, d) || !e(n[d], r[d])) return !1;
|
|
161
|
+
return !0;
|
|
131
162
|
}
|
|
132
|
-
t.
|
|
133
|
-
|
|
134
|
-
|
|
163
|
+
t.deepEqual = e;
|
|
164
|
+
function i(n, r, s, o) {
|
|
165
|
+
const f = [], d = [], u = [];
|
|
166
|
+
for (const _ of r)
|
|
167
|
+
n.some((c) => s(c, _)) ? (o?.(_) ?? !0) && u.push(_) : (o?.(_) ?? !0) && f.push(_);
|
|
168
|
+
for (const _ of n)
|
|
169
|
+
r.some((c) => s(_, c)) || (o?.(_) ?? !0) && d.push(_);
|
|
170
|
+
return { added: f, removed: d, unchanged: u };
|
|
171
|
+
}
|
|
172
|
+
t.diff = i;
|
|
173
|
+
})(V || (V = {}));
|
|
174
|
+
var Dt = /* @__PURE__ */ Symbol.for("immer-nothing"), x = /* @__PURE__ */ Symbol.for("immer-draftable"), m = /* @__PURE__ */ Symbol.for("immer-state"), At = process.env.NODE_ENV !== "production" ? [
|
|
135
175
|
// All error codes, starting by 0:
|
|
136
176
|
function(t) {
|
|
137
177
|
return `The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`;
|
|
@@ -162,125 +202,118 @@ var zt = /* @__PURE__ */ Symbol.for("immer-nothing"), J = /* @__PURE__ */ Symbol
|
|
|
162
202
|
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
163
203
|
// See Patches.ts for additional errors
|
|
164
204
|
] : [];
|
|
165
|
-
function
|
|
205
|
+
function g(t, ...e) {
|
|
166
206
|
if (process.env.NODE_ENV !== "production") {
|
|
167
|
-
const
|
|
168
|
-
throw new Error(`[Immer] ${
|
|
207
|
+
const i = At[t], n = b(i) ? i.apply(null, e) : i;
|
|
208
|
+
throw new Error(`[Immer] ${n}`);
|
|
169
209
|
}
|
|
170
210
|
throw new Error(
|
|
171
211
|
`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`
|
|
172
212
|
);
|
|
173
213
|
}
|
|
174
|
-
var
|
|
175
|
-
function
|
|
176
|
-
return t ?
|
|
214
|
+
var p = Object, F = p.getPrototypeOf, U = "constructor", W = "prototype", it = "configurable", j = "enumerable", M = "writable", k = "value", w = (t) => !!t && !!t[m];
|
|
215
|
+
function D(t) {
|
|
216
|
+
return t ? wt(t) || K(t) || !!t[x] || !!t[U]?.[x] || H(t) || Y(t) : !1;
|
|
177
217
|
}
|
|
178
|
-
var
|
|
179
|
-
function
|
|
180
|
-
if (!t || !
|
|
218
|
+
var Tt = p[W][U].toString(), yt = /* @__PURE__ */ new WeakMap();
|
|
219
|
+
function wt(t) {
|
|
220
|
+
if (!t || !ft(t))
|
|
181
221
|
return !1;
|
|
182
|
-
const e =
|
|
183
|
-
if (e === null || e ===
|
|
222
|
+
const e = F(t);
|
|
223
|
+
if (e === null || e === p[W])
|
|
184
224
|
return !0;
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
225
|
+
const i = p.hasOwnProperty.call(e, U) && e[U];
|
|
226
|
+
if (i === Object)
|
|
187
227
|
return !0;
|
|
188
|
-
if (!
|
|
228
|
+
if (!b(i))
|
|
189
229
|
return !1;
|
|
190
|
-
let
|
|
191
|
-
return
|
|
230
|
+
let n = yt.get(i);
|
|
231
|
+
return n === void 0 && (n = Function.toString.call(i), yt.set(i, n)), n === Tt;
|
|
192
232
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
e(
|
|
196
|
-
}) : t.forEach((
|
|
233
|
+
function G(t, e, i = !0) {
|
|
234
|
+
O(t) === 0 ? (i ? Reflect.ownKeys(t) : p.keys(t)).forEach((r) => {
|
|
235
|
+
e(r, t[r], t);
|
|
236
|
+
}) : t.forEach((n, r) => e(r, n, t));
|
|
197
237
|
}
|
|
198
|
-
function
|
|
199
|
-
const e = t[
|
|
200
|
-
return e ? e.type_ :
|
|
238
|
+
function O(t) {
|
|
239
|
+
const e = t[m];
|
|
240
|
+
return e ? e.type_ : K(t) ? 1 : H(t) ? 2 : Y(t) ? 3 : 0;
|
|
201
241
|
}
|
|
202
|
-
var
|
|
242
|
+
var mt = (t, e, i = O(t)) => i === 2 ? t.has(e) : p[W].hasOwnProperty.call(t, e), nt = (t, e, i = O(t)) => (
|
|
203
243
|
// @ts-ignore
|
|
204
|
-
|
|
205
|
-
),
|
|
206
|
-
|
|
244
|
+
i === 2 ? t.get(e) : t[e]
|
|
245
|
+
), q = (t, e, i, n = O(t)) => {
|
|
246
|
+
n === 2 ? t.set(e, i) : n === 3 ? t.add(i) : t[e] = i;
|
|
207
247
|
};
|
|
208
|
-
function
|
|
248
|
+
function Mt(t, e) {
|
|
209
249
|
return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
|
|
210
250
|
}
|
|
211
|
-
var
|
|
212
|
-
function
|
|
251
|
+
var K = Array.isArray, H = (t) => t instanceof Map, Y = (t) => t instanceof Set, ft = (t) => typeof t == "object", b = (t) => typeof t == "function", Z = (t) => typeof t == "boolean";
|
|
252
|
+
function Nt(t) {
|
|
213
253
|
const e = +t;
|
|
214
254
|
return Number.isInteger(e) && String(e) === t;
|
|
215
255
|
}
|
|
216
|
-
var
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}, wt = (t) => t.modified_ ? t.copy_ : t.base_;
|
|
220
|
-
function gt(t, e) {
|
|
221
|
-
if (ot(t))
|
|
256
|
+
var P = (t) => t.copy_ || t.base_, ct = (t) => t.modified_ ? t.copy_ : t.base_;
|
|
257
|
+
function rt(t, e) {
|
|
258
|
+
if (H(t))
|
|
222
259
|
return new Map(t);
|
|
223
|
-
if (
|
|
260
|
+
if (Y(t))
|
|
224
261
|
return new Set(t);
|
|
225
|
-
if (
|
|
226
|
-
return Array[
|
|
227
|
-
const
|
|
228
|
-
if (e === !0 || e === "class_only" && !
|
|
229
|
-
const
|
|
230
|
-
delete
|
|
231
|
-
let
|
|
232
|
-
for (let
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
[
|
|
236
|
-
[
|
|
262
|
+
if (K(t))
|
|
263
|
+
return Array[W].slice.call(t);
|
|
264
|
+
const i = wt(t);
|
|
265
|
+
if (e === !0 || e === "class_only" && !i) {
|
|
266
|
+
const n = p.getOwnPropertyDescriptors(t);
|
|
267
|
+
delete n[m];
|
|
268
|
+
let r = Reflect.ownKeys(n);
|
|
269
|
+
for (let s = 0; s < r.length; s++) {
|
|
270
|
+
const o = r[s], f = n[o];
|
|
271
|
+
f[M] === !1 && (f[M] = !0, f[it] = !0), (f.get || f.set) && (n[o] = {
|
|
272
|
+
[it]: !0,
|
|
273
|
+
[M]: !0,
|
|
237
274
|
// could live with !!desc.set as well here...
|
|
238
|
-
[
|
|
239
|
-
[
|
|
275
|
+
[j]: f[j],
|
|
276
|
+
[k]: t[o]
|
|
240
277
|
});
|
|
241
278
|
}
|
|
242
|
-
return
|
|
279
|
+
return p.create(F(t), n);
|
|
243
280
|
} else {
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
281
|
+
const n = F(t);
|
|
282
|
+
if (n !== null && i)
|
|
246
283
|
return { ...t };
|
|
247
|
-
const
|
|
248
|
-
return
|
|
284
|
+
const r = p.create(n);
|
|
285
|
+
return p.assign(r, t);
|
|
249
286
|
}
|
|
250
287
|
}
|
|
251
|
-
function
|
|
252
|
-
return
|
|
253
|
-
set:
|
|
254
|
-
add:
|
|
255
|
-
clear:
|
|
256
|
-
delete:
|
|
257
|
-
}),
|
|
288
|
+
function dt(t, e = !1) {
|
|
289
|
+
return X(t) || w(t) || !D(t) || (O(t) > 1 && p.defineProperties(t, {
|
|
290
|
+
set: T,
|
|
291
|
+
add: T,
|
|
292
|
+
clear: T,
|
|
293
|
+
delete: T
|
|
294
|
+
}), p.freeze(t), e && G(
|
|
258
295
|
t,
|
|
259
|
-
(
|
|
260
|
-
|
|
296
|
+
(i, n) => {
|
|
297
|
+
dt(n, !0);
|
|
261
298
|
},
|
|
262
299
|
!1
|
|
263
300
|
)), t;
|
|
264
301
|
}
|
|
265
|
-
function
|
|
266
|
-
|
|
302
|
+
function Rt() {
|
|
303
|
+
g(2);
|
|
267
304
|
}
|
|
268
|
-
var
|
|
269
|
-
[
|
|
305
|
+
var T = {
|
|
306
|
+
[k]: Rt
|
|
270
307
|
};
|
|
271
|
-
function
|
|
272
|
-
return t === null || !
|
|
273
|
-
}
|
|
274
|
-
var L = "MapSet", mt = "Patches", St = "ArrayMethods", tt = {};
|
|
275
|
-
function N(t) {
|
|
276
|
-
const e = tt[t];
|
|
277
|
-
return e || E(0, t), e;
|
|
308
|
+
function X(t) {
|
|
309
|
+
return t === null || !ft(t) ? !0 : p.isFrozen(t);
|
|
278
310
|
}
|
|
279
|
-
var
|
|
280
|
-
function
|
|
281
|
-
|
|
311
|
+
var B = "MapSet", st = "Patches", gt = "ArrayMethods", bt = {};
|
|
312
|
+
function E(t) {
|
|
313
|
+
const e = bt[t];
|
|
314
|
+
return e || g(0, t), e;
|
|
282
315
|
}
|
|
283
|
-
var
|
|
316
|
+
var pt = (t) => !!bt[t], C, Et = () => C, xt = (t, e) => ({
|
|
284
317
|
drafts_: [],
|
|
285
318
|
parent_: t,
|
|
286
319
|
immer_: e,
|
|
@@ -290,137 +323,137 @@ var B, et = () => B, Wt = (t, e) => ({
|
|
|
290
323
|
unfinalizedDrafts_: 0,
|
|
291
324
|
handledSet_: /* @__PURE__ */ new Set(),
|
|
292
325
|
processedForPatches_: /* @__PURE__ */ new Set(),
|
|
293
|
-
mapSetPlugin_:
|
|
294
|
-
arrayMethodsPlugin_:
|
|
326
|
+
mapSetPlugin_: pt(B) ? E(B) : void 0,
|
|
327
|
+
arrayMethodsPlugin_: pt(gt) ? E(gt) : void 0
|
|
295
328
|
});
|
|
296
|
-
function
|
|
297
|
-
e && (t.patchPlugin_ =
|
|
329
|
+
function vt(t, e) {
|
|
330
|
+
e && (t.patchPlugin_ = E(st), t.patches_ = [], t.inversePatches_ = [], t.patchListener_ = e);
|
|
298
331
|
}
|
|
299
|
-
function
|
|
300
|
-
|
|
332
|
+
function ot(t) {
|
|
333
|
+
at(t), t.drafts_.forEach(Ut), t.drafts_ = null;
|
|
301
334
|
}
|
|
302
|
-
function
|
|
303
|
-
t ===
|
|
335
|
+
function at(t) {
|
|
336
|
+
t === C && (C = t.parent_);
|
|
304
337
|
}
|
|
305
|
-
var
|
|
306
|
-
function
|
|
307
|
-
const e = t[
|
|
338
|
+
var St = (t) => C = xt(C, t);
|
|
339
|
+
function Ut(t) {
|
|
340
|
+
const e = t[m];
|
|
308
341
|
e.type_ === 0 || e.type_ === 1 ? e.revoke_() : e.revoked_ = !0;
|
|
309
342
|
}
|
|
310
|
-
function
|
|
343
|
+
function Pt(t, e) {
|
|
311
344
|
e.unfinalizedDrafts_ = e.drafts_.length;
|
|
312
|
-
const
|
|
313
|
-
if (t !== void 0 && t !==
|
|
314
|
-
|
|
315
|
-
const { patchPlugin_:
|
|
316
|
-
|
|
317
|
-
|
|
345
|
+
const i = e.drafts_[0];
|
|
346
|
+
if (t !== void 0 && t !== i) {
|
|
347
|
+
i[m].modified_ && (ot(e), g(4)), D(t) && (t = Vt(e, t));
|
|
348
|
+
const { patchPlugin_: r } = e;
|
|
349
|
+
r && r.generateReplacementPatches_(
|
|
350
|
+
i[m].base_,
|
|
318
351
|
t,
|
|
319
352
|
e
|
|
320
353
|
);
|
|
321
354
|
} else
|
|
322
|
-
t =
|
|
323
|
-
return
|
|
355
|
+
t = Vt(e, i);
|
|
356
|
+
return jt(e, t, !0), ot(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== Dt ? t : void 0;
|
|
324
357
|
}
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
358
|
+
function Vt(t, e) {
|
|
359
|
+
if (X(e))
|
|
327
360
|
return e;
|
|
328
|
-
const
|
|
329
|
-
if (!
|
|
330
|
-
return
|
|
331
|
-
if (!
|
|
361
|
+
const i = e[m];
|
|
362
|
+
if (!i)
|
|
363
|
+
return $(e, t.handledSet_, t);
|
|
364
|
+
if (!J(i, t))
|
|
332
365
|
return e;
|
|
333
|
-
if (!
|
|
334
|
-
return
|
|
335
|
-
if (!
|
|
336
|
-
const { callbacks_:
|
|
337
|
-
if (
|
|
338
|
-
for (;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
return
|
|
366
|
+
if (!i.modified_)
|
|
367
|
+
return i.base_;
|
|
368
|
+
if (!i.finalized_) {
|
|
369
|
+
const { callbacks_: n } = i;
|
|
370
|
+
if (n)
|
|
371
|
+
for (; n.length > 0; )
|
|
372
|
+
n.pop()(t);
|
|
373
|
+
kt(i, t);
|
|
374
|
+
}
|
|
375
|
+
return i.copy_;
|
|
343
376
|
}
|
|
344
|
-
function
|
|
345
|
-
!t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ &&
|
|
377
|
+
function jt(t, e, i = !1) {
|
|
378
|
+
!t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && dt(e, i);
|
|
346
379
|
}
|
|
347
|
-
function
|
|
380
|
+
function Ft(t) {
|
|
348
381
|
t.finalized_ = !0, t.scope_.unfinalizedDrafts_--;
|
|
349
382
|
}
|
|
350
|
-
var
|
|
351
|
-
function
|
|
352
|
-
const
|
|
353
|
-
if (
|
|
354
|
-
|
|
383
|
+
var J = (t, e) => t.scope_ === e, qt = [];
|
|
384
|
+
function zt(t, e, i, n) {
|
|
385
|
+
const r = P(t), s = t.type_;
|
|
386
|
+
if (n !== void 0 && nt(r, n, s) === e) {
|
|
387
|
+
q(r, n, i, s);
|
|
355
388
|
return;
|
|
356
389
|
}
|
|
357
390
|
if (!t.draftLocations_) {
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
const
|
|
362
|
-
|
|
391
|
+
const f = t.draftLocations_ = /* @__PURE__ */ new Map();
|
|
392
|
+
G(r, (d, u) => {
|
|
393
|
+
if (w(u)) {
|
|
394
|
+
const _ = f.get(u) || [];
|
|
395
|
+
_.push(d), f.set(u, _);
|
|
363
396
|
}
|
|
364
397
|
});
|
|
365
398
|
}
|
|
366
|
-
const
|
|
367
|
-
for (const
|
|
368
|
-
|
|
399
|
+
const o = t.draftLocations_.get(e) ?? qt;
|
|
400
|
+
for (const f of o)
|
|
401
|
+
q(r, f, i, s);
|
|
369
402
|
}
|
|
370
|
-
function
|
|
371
|
-
t.callbacks_.push(function(
|
|
372
|
-
const
|
|
373
|
-
if (!
|
|
403
|
+
function Bt(t, e, i) {
|
|
404
|
+
t.callbacks_.push(function(r) {
|
|
405
|
+
const s = e;
|
|
406
|
+
if (!s || !J(s, r))
|
|
374
407
|
return;
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
408
|
+
r.mapSetPlugin_?.fixSetContents(s);
|
|
409
|
+
const o = ct(s);
|
|
410
|
+
zt(t, s.draft_ ?? s, o, i), kt(s, r);
|
|
378
411
|
});
|
|
379
412
|
}
|
|
380
|
-
function
|
|
413
|
+
function kt(t, e) {
|
|
381
414
|
if (t.modified_ && !t.finalized_ && (t.type_ === 3 || t.type_ === 1 && t.allIndicesReassigned_ || (t.assigned_?.size ?? 0) > 0)) {
|
|
382
|
-
const { patchPlugin_:
|
|
383
|
-
if (
|
|
384
|
-
const
|
|
385
|
-
|
|
415
|
+
const { patchPlugin_: n } = e;
|
|
416
|
+
if (n) {
|
|
417
|
+
const r = n.getPath(t);
|
|
418
|
+
r && n.generatePatches_(t, r, e);
|
|
386
419
|
}
|
|
387
|
-
|
|
420
|
+
Ft(t);
|
|
388
421
|
}
|
|
389
422
|
}
|
|
390
|
-
function
|
|
391
|
-
const { scope_:
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const
|
|
397
|
-
|
|
423
|
+
function $t(t, e, i) {
|
|
424
|
+
const { scope_: n } = t;
|
|
425
|
+
if (w(i)) {
|
|
426
|
+
const r = i[m];
|
|
427
|
+
J(r, n) && r.callbacks_.push(function() {
|
|
428
|
+
N(t);
|
|
429
|
+
const o = ct(r);
|
|
430
|
+
zt(t, i, o, e);
|
|
398
431
|
});
|
|
399
|
-
} else
|
|
400
|
-
const
|
|
401
|
-
t.type_ === 3 ?
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
432
|
+
} else D(i) && t.callbacks_.push(function() {
|
|
433
|
+
const s = P(t);
|
|
434
|
+
t.type_ === 3 ? s.has(i) && $(i, n.handledSet_, n) : nt(s, e, t.type_) === i && n.drafts_.length > 1 && (t.assigned_.get(e) ?? !1) === !0 && t.copy_ && $(
|
|
435
|
+
nt(t.copy_, e, t.type_),
|
|
436
|
+
n.handledSet_,
|
|
437
|
+
n
|
|
405
438
|
);
|
|
406
439
|
});
|
|
407
440
|
}
|
|
408
|
-
function
|
|
409
|
-
return !
|
|
410
|
-
if (
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
414
|
-
|
|
441
|
+
function $(t, e, i) {
|
|
442
|
+
return !i.immer_.autoFreeze_ && i.unfinalizedDrafts_ < 1 || w(t) || e.has(t) || !D(t) || X(t) || (e.add(t), G(t, (n, r) => {
|
|
443
|
+
if (w(r)) {
|
|
444
|
+
const s = r[m];
|
|
445
|
+
if (J(s, i)) {
|
|
446
|
+
const o = ct(s);
|
|
447
|
+
q(t, n, o, t.type_), Ft(s);
|
|
415
448
|
}
|
|
416
|
-
} else
|
|
449
|
+
} else D(r) && $(r, e, i);
|
|
417
450
|
})), t;
|
|
418
451
|
}
|
|
419
|
-
function
|
|
420
|
-
const
|
|
421
|
-
type_:
|
|
452
|
+
function Lt(t, e) {
|
|
453
|
+
const i = K(t), n = {
|
|
454
|
+
type_: i ? 1 : 0,
|
|
422
455
|
// Track which produce call this is associated with.
|
|
423
|
-
scope_: e ? e.scope_ :
|
|
456
|
+
scope_: e ? e.scope_ : Et(),
|
|
424
457
|
// True for both shallow and deep changes.
|
|
425
458
|
modified_: !1,
|
|
426
459
|
// Used during finalization.
|
|
@@ -443,177 +476,177 @@ function Xt(t, e) {
|
|
|
443
476
|
// `callbacks` actually gets assigned in `createProxy`
|
|
444
477
|
callbacks_: void 0
|
|
445
478
|
};
|
|
446
|
-
let
|
|
447
|
-
|
|
448
|
-
const { revoke:
|
|
449
|
-
return
|
|
479
|
+
let r = n, s = L;
|
|
480
|
+
i && (r = [n], s = I);
|
|
481
|
+
const { revoke: o, proxy: f } = Proxy.revocable(r, s);
|
|
482
|
+
return n.draft_ = f, n.revoke_ = o, [f, n];
|
|
450
483
|
}
|
|
451
|
-
var
|
|
484
|
+
var L = {
|
|
452
485
|
get(t, e) {
|
|
453
|
-
if (e ===
|
|
486
|
+
if (e === m)
|
|
454
487
|
return t;
|
|
455
|
-
let
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
return
|
|
459
|
-
const
|
|
460
|
-
if (!
|
|
461
|
-
return
|
|
462
|
-
const
|
|
463
|
-
if (t.finalized_ || !
|
|
488
|
+
let i = t.scope_.arrayMethodsPlugin_;
|
|
489
|
+
const n = t.type_ === 1 && typeof e == "string";
|
|
490
|
+
if (n && i?.isArrayOperationMethod(e))
|
|
491
|
+
return i.createMethodInterceptor(t, e);
|
|
492
|
+
const r = P(t);
|
|
493
|
+
if (!mt(r, e, t.type_))
|
|
494
|
+
return Wt(t, r, e);
|
|
495
|
+
const s = r[e];
|
|
496
|
+
if (t.finalized_ || !D(s) || n && t.operationMethod && i?.isMutatingArrayMethod(
|
|
464
497
|
t.operationMethod
|
|
465
|
-
) &&
|
|
466
|
-
return
|
|
467
|
-
if (
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
return t.copy_[
|
|
498
|
+
) && Nt(e))
|
|
499
|
+
return s;
|
|
500
|
+
if (s === tt(t.base_, e)) {
|
|
501
|
+
N(t);
|
|
502
|
+
const o = t.type_ === 1 ? +e : e, f = ut(t.scope_, s, t, o);
|
|
503
|
+
return t.copy_[o] = f;
|
|
471
504
|
}
|
|
472
|
-
return
|
|
505
|
+
return s;
|
|
473
506
|
},
|
|
474
507
|
has(t, e) {
|
|
475
|
-
return e in
|
|
508
|
+
return e in P(t);
|
|
476
509
|
},
|
|
477
510
|
ownKeys(t) {
|
|
478
|
-
return Reflect.ownKeys(
|
|
511
|
+
return Reflect.ownKeys(P(t));
|
|
479
512
|
},
|
|
480
|
-
set(t, e,
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
return
|
|
513
|
+
set(t, e, i) {
|
|
514
|
+
const n = Ct(P(t), e);
|
|
515
|
+
if (n?.set)
|
|
516
|
+
return n.set.call(t.draft_, i), !0;
|
|
484
517
|
if (!t.modified_) {
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
return t.copy_[e] =
|
|
488
|
-
if (
|
|
518
|
+
const r = tt(P(t), e), s = r?.[m];
|
|
519
|
+
if (s && s.base_ === i)
|
|
520
|
+
return t.copy_[e] = i, t.assigned_.set(e, !1), !0;
|
|
521
|
+
if (Mt(i, r) && (i !== void 0 || mt(t.base_, e, t.type_)))
|
|
489
522
|
return !0;
|
|
490
|
-
|
|
523
|
+
N(t), lt(t);
|
|
491
524
|
}
|
|
492
|
-
return t.copy_[e] ===
|
|
493
|
-
(
|
|
494
|
-
Number.isNaN(
|
|
525
|
+
return t.copy_[e] === i && // special case: handle new props with value 'undefined'
|
|
526
|
+
(i !== void 0 || e in t.copy_) || // special case: NaN
|
|
527
|
+
Number.isNaN(i) && Number.isNaN(t.copy_[e]) || (t.copy_[e] = i, t.assigned_.set(e, !0), $t(t, e, i)), !0;
|
|
495
528
|
},
|
|
496
529
|
deleteProperty(t, e) {
|
|
497
|
-
return
|
|
530
|
+
return N(t), tt(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_.set(e, !1), lt(t)) : t.assigned_.delete(e), t.copy_ && delete t.copy_[e], !0;
|
|
498
531
|
},
|
|
499
532
|
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
500
533
|
// the same guarantee in ES5 mode.
|
|
501
534
|
getOwnPropertyDescriptor(t, e) {
|
|
502
|
-
const
|
|
503
|
-
return
|
|
504
|
-
[
|
|
505
|
-
[
|
|
506
|
-
[
|
|
507
|
-
[
|
|
535
|
+
const i = P(t), n = Reflect.getOwnPropertyDescriptor(i, e);
|
|
536
|
+
return n && {
|
|
537
|
+
[M]: !0,
|
|
538
|
+
[it]: t.type_ !== 1 || e !== "length",
|
|
539
|
+
[j]: n[j],
|
|
540
|
+
[k]: i[e]
|
|
508
541
|
};
|
|
509
542
|
},
|
|
510
543
|
defineProperty() {
|
|
511
|
-
|
|
544
|
+
g(11);
|
|
512
545
|
},
|
|
513
546
|
getPrototypeOf(t) {
|
|
514
|
-
return
|
|
547
|
+
return F(t.base_);
|
|
515
548
|
},
|
|
516
549
|
setPrototypeOf() {
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
},
|
|
520
|
-
for (let t in
|
|
521
|
-
let e =
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
return
|
|
550
|
+
g(12);
|
|
551
|
+
}
|
|
552
|
+
}, I = {};
|
|
553
|
+
for (let t in L) {
|
|
554
|
+
let e = L[t];
|
|
555
|
+
I[t] = function() {
|
|
556
|
+
const i = arguments;
|
|
557
|
+
return i[0] = i[0][0], e.apply(this, i);
|
|
525
558
|
};
|
|
526
559
|
}
|
|
527
|
-
|
|
528
|
-
return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) &&
|
|
560
|
+
I.deleteProperty = function(t, e) {
|
|
561
|
+
return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && g(13), I.set.call(this, t, e, void 0);
|
|
529
562
|
};
|
|
530
|
-
|
|
531
|
-
return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) &&
|
|
563
|
+
I.set = function(t, e, i) {
|
|
564
|
+
return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) && g(14), L.set.call(this, t[0], e, i, t[0]);
|
|
532
565
|
};
|
|
533
|
-
function
|
|
534
|
-
const
|
|
535
|
-
return (
|
|
566
|
+
function tt(t, e) {
|
|
567
|
+
const i = t[m];
|
|
568
|
+
return (i ? P(i) : t)[e];
|
|
536
569
|
}
|
|
537
|
-
function
|
|
538
|
-
const
|
|
539
|
-
return
|
|
570
|
+
function Wt(t, e, i) {
|
|
571
|
+
const n = Ct(e, i);
|
|
572
|
+
return n ? k in n ? n[k] : (
|
|
540
573
|
// This is a very special case, if the prop is a getter defined by the
|
|
541
574
|
// prototype, we should invoke it with the draft as context!
|
|
542
|
-
|
|
575
|
+
n.get?.call(t.draft_)
|
|
543
576
|
) : void 0;
|
|
544
577
|
}
|
|
545
|
-
function
|
|
578
|
+
function Ct(t, e) {
|
|
546
579
|
if (!(e in t))
|
|
547
580
|
return;
|
|
548
|
-
let
|
|
549
|
-
for (;
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
552
|
-
return
|
|
553
|
-
|
|
581
|
+
let i = F(t);
|
|
582
|
+
for (; i; ) {
|
|
583
|
+
const n = Object.getOwnPropertyDescriptor(i, e);
|
|
584
|
+
if (n)
|
|
585
|
+
return n;
|
|
586
|
+
i = F(i);
|
|
554
587
|
}
|
|
555
588
|
}
|
|
556
|
-
function
|
|
557
|
-
t.modified_ || (t.modified_ = !0, t.parent_ &&
|
|
589
|
+
function lt(t) {
|
|
590
|
+
t.modified_ || (t.modified_ = !0, t.parent_ && lt(t.parent_));
|
|
558
591
|
}
|
|
559
|
-
function
|
|
560
|
-
t.copy_ || (t.assigned_ = /* @__PURE__ */ new Map(), t.copy_ =
|
|
592
|
+
function N(t) {
|
|
593
|
+
t.copy_ || (t.assigned_ = /* @__PURE__ */ new Map(), t.copy_ = rt(
|
|
561
594
|
t.base_,
|
|
562
595
|
t.scope_.immer_.useStrictShallowCopy_
|
|
563
596
|
));
|
|
564
597
|
}
|
|
565
|
-
var
|
|
598
|
+
var Gt = class {
|
|
566
599
|
constructor(t) {
|
|
567
|
-
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1, this.produce = (e,
|
|
568
|
-
if (
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
return function(d =
|
|
573
|
-
return
|
|
600
|
+
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1, this.produce = (e, i, n) => {
|
|
601
|
+
if (b(e) && !b(i)) {
|
|
602
|
+
const s = i;
|
|
603
|
+
i = e;
|
|
604
|
+
const o = this;
|
|
605
|
+
return function(d = s, ...u) {
|
|
606
|
+
return o.produce(d, (_) => i.call(this, _, ...u));
|
|
574
607
|
};
|
|
575
608
|
}
|
|
576
|
-
|
|
577
|
-
let
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
let
|
|
609
|
+
b(i) || g(6), n !== void 0 && !b(n) && g(7);
|
|
610
|
+
let r;
|
|
611
|
+
if (D(e)) {
|
|
612
|
+
const s = St(this), o = ut(s, e, void 0);
|
|
613
|
+
let f = !0;
|
|
581
614
|
try {
|
|
582
|
-
|
|
615
|
+
r = i(o), f = !1;
|
|
583
616
|
} finally {
|
|
584
|
-
|
|
617
|
+
f ? ot(s) : at(s);
|
|
585
618
|
}
|
|
586
|
-
return
|
|
587
|
-
} else if (!e || !
|
|
588
|
-
if (
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
patches_:
|
|
592
|
-
inversePatches_:
|
|
593
|
-
}),
|
|
619
|
+
return vt(s, n), Pt(r, s);
|
|
620
|
+
} else if (!e || !ft(e)) {
|
|
621
|
+
if (r = i(e), r === void 0 && (r = e), r === Dt && (r = void 0), this.autoFreeze_ && dt(r, !0), n) {
|
|
622
|
+
const s = [], o = [];
|
|
623
|
+
E(st).generateReplacementPatches_(e, r, {
|
|
624
|
+
patches_: s,
|
|
625
|
+
inversePatches_: o
|
|
626
|
+
}), n(s, o);
|
|
594
627
|
}
|
|
595
|
-
return
|
|
628
|
+
return r;
|
|
596
629
|
} else
|
|
597
|
-
|
|
598
|
-
}, this.produceWithPatches = (e,
|
|
599
|
-
if (
|
|
600
|
-
return (
|
|
601
|
-
let
|
|
602
|
-
return [this.produce(e,
|
|
603
|
-
|
|
604
|
-
}),
|
|
605
|
-
},
|
|
630
|
+
g(1, e);
|
|
631
|
+
}, this.produceWithPatches = (e, i) => {
|
|
632
|
+
if (b(e))
|
|
633
|
+
return (o, ...f) => this.produceWithPatches(o, (d) => e(d, ...f));
|
|
634
|
+
let n, r;
|
|
635
|
+
return [this.produce(e, i, (o, f) => {
|
|
636
|
+
n = o, r = f;
|
|
637
|
+
}), n, r];
|
|
638
|
+
}, Z(t?.autoFreeze) && this.setAutoFreeze(t.autoFreeze), Z(t?.useStrictShallowCopy) && this.setUseStrictShallowCopy(t.useStrictShallowCopy), Z(t?.useStrictIteration) && this.setUseStrictIteration(t.useStrictIteration);
|
|
606
639
|
}
|
|
607
640
|
createDraft(t) {
|
|
608
|
-
|
|
609
|
-
const e =
|
|
610
|
-
return
|
|
641
|
+
D(t) || g(8), w(t) && (t = Kt(t));
|
|
642
|
+
const e = St(this), i = ut(e, t, void 0);
|
|
643
|
+
return i[m].isManual_ = !0, at(e), i;
|
|
611
644
|
}
|
|
612
645
|
finishDraft(t, e) {
|
|
613
|
-
const
|
|
614
|
-
(!
|
|
615
|
-
const { scope_:
|
|
616
|
-
return
|
|
646
|
+
const i = t && t[m];
|
|
647
|
+
(!i || !i.isManual_) && g(9);
|
|
648
|
+
const { scope_: n } = i;
|
|
649
|
+
return vt(n, e), Pt(void 0, n);
|
|
617
650
|
}
|
|
618
651
|
/**
|
|
619
652
|
* Pass true to automatically freeze all copies created by Immer.
|
|
@@ -644,390 +677,98 @@ var te = class {
|
|
|
644
677
|
return this.useStrictIteration_;
|
|
645
678
|
}
|
|
646
679
|
applyPatches(t, e) {
|
|
647
|
-
let
|
|
648
|
-
for (
|
|
649
|
-
const
|
|
650
|
-
if (
|
|
651
|
-
t =
|
|
680
|
+
let i;
|
|
681
|
+
for (i = e.length - 1; i >= 0; i--) {
|
|
682
|
+
const r = e[i];
|
|
683
|
+
if (r.path.length === 0 && r.op === "replace") {
|
|
684
|
+
t = r.value;
|
|
652
685
|
break;
|
|
653
686
|
}
|
|
654
687
|
}
|
|
655
|
-
|
|
656
|
-
const
|
|
657
|
-
return
|
|
688
|
+
i > -1 && (e = e.slice(i + 1));
|
|
689
|
+
const n = E(st).applyPatches_;
|
|
690
|
+
return w(t) ? n(t, e) : this.produce(
|
|
658
691
|
t,
|
|
659
|
-
(
|
|
692
|
+
(r) => n(r, e)
|
|
660
693
|
);
|
|
661
694
|
}
|
|
662
695
|
};
|
|
663
|
-
function
|
|
664
|
-
const [
|
|
665
|
-
return (
|
|
666
|
-
d.mapSetPlugin_?.fixSetContents(
|
|
667
|
-
const { patchPlugin_:
|
|
668
|
-
|
|
669
|
-
}),
|
|
696
|
+
function ut(t, e, i, n) {
|
|
697
|
+
const [r, s] = H(e) ? E(B).proxyMap_(e, i) : Y(e) ? E(B).proxySet_(e, i) : Lt(e, i);
|
|
698
|
+
return (i?.scope_ ?? Et()).drafts_.push(r), s.callbacks_ = i?.callbacks_ ?? [], s.key_ = n, i && n !== void 0 ? Bt(i, s, n) : s.callbacks_.push(function(d) {
|
|
699
|
+
d.mapSetPlugin_?.fixSetContents(s);
|
|
700
|
+
const { patchPlugin_: u } = d;
|
|
701
|
+
s.modified_ && u && u.generatePatches_(s, [], d);
|
|
702
|
+
}), r;
|
|
670
703
|
}
|
|
671
|
-
function
|
|
672
|
-
return
|
|
704
|
+
function Kt(t) {
|
|
705
|
+
return w(t) || g(10, t), It(t);
|
|
673
706
|
}
|
|
674
|
-
function
|
|
675
|
-
if (!
|
|
707
|
+
function It(t) {
|
|
708
|
+
if (!D(t) || X(t))
|
|
676
709
|
return t;
|
|
677
|
-
const e = t[
|
|
678
|
-
let
|
|
710
|
+
const e = t[m];
|
|
711
|
+
let i, n = !0;
|
|
679
712
|
if (e) {
|
|
680
713
|
if (!e.modified_)
|
|
681
714
|
return e.base_;
|
|
682
|
-
e.finalized_ = !0,
|
|
715
|
+
e.finalized_ = !0, i = rt(t, e.scope_.immer_.useStrictShallowCopy_), n = e.scope_.immer_.shouldUseStrictIteration();
|
|
683
716
|
} else
|
|
684
|
-
|
|
685
|
-
return
|
|
686
|
-
|
|
687
|
-
(
|
|
688
|
-
|
|
717
|
+
i = rt(t, !0);
|
|
718
|
+
return G(
|
|
719
|
+
i,
|
|
720
|
+
(r, s) => {
|
|
721
|
+
q(i, r, It(s));
|
|
689
722
|
},
|
|
690
|
-
|
|
691
|
-
), e && (e.finalized_ = !1),
|
|
723
|
+
n
|
|
724
|
+
), e && (e.finalized_ = !1), i;
|
|
692
725
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
assigned_: void 0,
|
|
704
|
-
base_: s,
|
|
705
|
-
draft_: this,
|
|
706
|
-
isManual_: !1,
|
|
707
|
-
revoked_: !1,
|
|
708
|
-
callbacks_: []
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
get size() {
|
|
712
|
-
return v(this[p]).size;
|
|
713
|
-
}
|
|
714
|
-
has(s) {
|
|
715
|
-
return v(this[p]).has(s);
|
|
716
|
-
}
|
|
717
|
-
set(s, r) {
|
|
718
|
-
const c = this[p];
|
|
719
|
-
return u(c), (!v(c).has(s) || v(c).get(s) !== r) && (n(c), I(c), c.assigned_.set(s, !0), c.copy_.set(s, r), c.assigned_.set(s, !0), Dt(c, s, r)), this;
|
|
720
|
-
}
|
|
721
|
-
delete(s) {
|
|
722
|
-
if (!this.has(s))
|
|
723
|
-
return !1;
|
|
724
|
-
const r = this[p];
|
|
725
|
-
return u(r), n(r), I(r), r.base_.has(s) ? r.assigned_.set(s, !1) : r.assigned_.delete(s), r.copy_.delete(s), !0;
|
|
726
|
-
}
|
|
727
|
-
clear() {
|
|
728
|
-
const s = this[p];
|
|
729
|
-
u(s), v(s).size && (n(s), I(s), s.assigned_ = /* @__PURE__ */ new Map(), q(s.base_, (r) => {
|
|
730
|
-
s.assigned_.set(r, !1);
|
|
731
|
-
}), s.copy_.clear());
|
|
732
|
-
}
|
|
733
|
-
forEach(s, r) {
|
|
734
|
-
const c = this[p];
|
|
735
|
-
v(c).forEach((l, _, g) => {
|
|
736
|
-
s.call(r, this.get(_), _, this);
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
get(s) {
|
|
740
|
-
const r = this[p];
|
|
741
|
-
u(r);
|
|
742
|
-
const c = v(r).get(s);
|
|
743
|
-
if (r.finalized_ || !b(c) || c !== r.base_.get(s))
|
|
744
|
-
return c;
|
|
745
|
-
const l = $(r.scope_, c, r, s);
|
|
746
|
-
return n(r), r.copy_.set(s, l), l;
|
|
747
|
-
}
|
|
748
|
-
keys() {
|
|
749
|
-
return v(this[p]).keys();
|
|
750
|
-
}
|
|
751
|
-
values() {
|
|
752
|
-
const s = this.keys();
|
|
753
|
-
return {
|
|
754
|
-
[Symbol.iterator]: () => this.values(),
|
|
755
|
-
next: () => {
|
|
756
|
-
const r = s.next();
|
|
757
|
-
return r.done ? r : {
|
|
758
|
-
done: !1,
|
|
759
|
-
value: this.get(r.value)
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
}
|
|
764
|
-
entries() {
|
|
765
|
-
const s = this.keys();
|
|
766
|
-
return {
|
|
767
|
-
[Symbol.iterator]: () => this.entries(),
|
|
768
|
-
next: () => {
|
|
769
|
-
const r = s.next();
|
|
770
|
-
if (r.done)
|
|
771
|
-
return r;
|
|
772
|
-
const c = this.get(r.value);
|
|
773
|
-
return {
|
|
774
|
-
done: !1,
|
|
775
|
-
value: [r.value, c]
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
[Symbol.iterator]() {
|
|
781
|
-
return this.entries();
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
function e(d, s) {
|
|
785
|
-
const r = new t(d, s);
|
|
786
|
-
return [r, r[p]];
|
|
787
|
-
}
|
|
788
|
-
function n(d) {
|
|
789
|
-
d.copy_ || (d.assigned_ = /* @__PURE__ */ new Map(), d.copy_ = new Map(d.base_));
|
|
790
|
-
}
|
|
791
|
-
class i extends Set {
|
|
792
|
-
constructor(s, r) {
|
|
793
|
-
super(), this[p] = {
|
|
794
|
-
type_: 3,
|
|
795
|
-
parent_: r,
|
|
796
|
-
scope_: r ? r.scope_ : et(),
|
|
797
|
-
modified_: !1,
|
|
798
|
-
finalized_: !1,
|
|
799
|
-
copy_: void 0,
|
|
800
|
-
base_: s,
|
|
801
|
-
draft_: this,
|
|
802
|
-
drafts_: /* @__PURE__ */ new Map(),
|
|
803
|
-
revoked_: !1,
|
|
804
|
-
isManual_: !1,
|
|
805
|
-
assigned_: void 0,
|
|
806
|
-
callbacks_: []
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
get size() {
|
|
810
|
-
return v(this[p]).size;
|
|
811
|
-
}
|
|
812
|
-
has(s) {
|
|
813
|
-
const r = this[p];
|
|
814
|
-
return u(r), r.copy_ ? !!(r.copy_.has(s) || r.drafts_.has(s) && r.copy_.has(r.drafts_.get(s))) : r.base_.has(s);
|
|
815
|
-
}
|
|
816
|
-
add(s) {
|
|
817
|
-
const r = this[p];
|
|
818
|
-
return u(r), this.has(s) || (a(r), I(r), r.copy_.add(s), Dt(r, s, s)), this;
|
|
819
|
-
}
|
|
820
|
-
delete(s) {
|
|
821
|
-
if (!this.has(s))
|
|
822
|
-
return !1;
|
|
823
|
-
const r = this[p];
|
|
824
|
-
return u(r), a(r), I(r), r.copy_.delete(s) || (r.drafts_.has(s) ? r.copy_.delete(r.drafts_.get(s)) : (
|
|
825
|
-
/* istanbul ignore next */
|
|
826
|
-
!1
|
|
827
|
-
));
|
|
828
|
-
}
|
|
829
|
-
clear() {
|
|
830
|
-
const s = this[p];
|
|
831
|
-
u(s), v(s).size && (a(s), I(s), s.copy_.clear());
|
|
832
|
-
}
|
|
833
|
-
values() {
|
|
834
|
-
const s = this[p];
|
|
835
|
-
return u(s), a(s), s.copy_.values();
|
|
836
|
-
}
|
|
837
|
-
entries() {
|
|
838
|
-
const s = this[p];
|
|
839
|
-
return u(s), a(s), s.copy_.entries();
|
|
840
|
-
}
|
|
841
|
-
keys() {
|
|
842
|
-
return this.values();
|
|
843
|
-
}
|
|
844
|
-
[Symbol.iterator]() {
|
|
845
|
-
return this.values();
|
|
846
|
-
}
|
|
847
|
-
forEach(s, r) {
|
|
848
|
-
const c = this.values();
|
|
849
|
-
let l = c.next();
|
|
850
|
-
for (; !l.done; )
|
|
851
|
-
s.call(r, l.value, l.value, this), l = c.next();
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
function o(d, s) {
|
|
855
|
-
const r = new i(d, s);
|
|
856
|
-
return [r, r[p]];
|
|
857
|
-
}
|
|
858
|
-
function a(d) {
|
|
859
|
-
d.copy_ || (d.copy_ = /* @__PURE__ */ new Set(), d.base_.forEach((s) => {
|
|
860
|
-
if (b(s)) {
|
|
861
|
-
const r = $(d.scope_, s, d, s);
|
|
862
|
-
d.drafts_.set(s, r), d.copy_.add(r);
|
|
863
|
-
} else
|
|
864
|
-
d.copy_.add(s);
|
|
865
|
-
}));
|
|
866
|
-
}
|
|
867
|
-
function u(d) {
|
|
868
|
-
d.revoked_ && E(3, JSON.stringify(v(d)));
|
|
869
|
-
}
|
|
870
|
-
function h(d) {
|
|
871
|
-
if (d.type_ === 3 && d.copy_) {
|
|
872
|
-
const s = new Set(d.copy_);
|
|
873
|
-
d.copy_.clear(), s.forEach((r) => {
|
|
874
|
-
d.copy_.add(qt(r));
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
Ct(L, { proxyMap_: e, proxySet_: o, fixSetContents: h });
|
|
879
|
-
}
|
|
880
|
-
function ie() {
|
|
881
|
-
const t = /* @__PURE__ */ new Set(["shift", "unshift"]), e = /* @__PURE__ */ new Set(["push", "pop"]), n = /* @__PURE__ */ new Set([
|
|
882
|
-
...e,
|
|
883
|
-
...t
|
|
884
|
-
]), i = /* @__PURE__ */ new Set(["reverse", "sort"]), o = /* @__PURE__ */ new Set([
|
|
885
|
-
...n,
|
|
886
|
-
...i,
|
|
887
|
-
"splice"
|
|
888
|
-
]), a = /* @__PURE__ */ new Set(["find", "findLast"]), u = /* @__PURE__ */ new Set([
|
|
889
|
-
"filter",
|
|
890
|
-
"slice",
|
|
891
|
-
"concat",
|
|
892
|
-
"flat",
|
|
893
|
-
...a,
|
|
894
|
-
"findIndex",
|
|
895
|
-
"findLastIndex",
|
|
896
|
-
"some",
|
|
897
|
-
"every",
|
|
898
|
-
"indexOf",
|
|
899
|
-
"lastIndexOf",
|
|
900
|
-
"includes",
|
|
901
|
-
"join",
|
|
902
|
-
"toString",
|
|
903
|
-
"toLocaleString"
|
|
904
|
-
]);
|
|
905
|
-
function h(f) {
|
|
906
|
-
return o.has(f);
|
|
907
|
-
}
|
|
908
|
-
function d(f) {
|
|
909
|
-
return u.has(f);
|
|
910
|
-
}
|
|
911
|
-
function s(f) {
|
|
912
|
-
return h(f) || d(f);
|
|
913
|
-
}
|
|
914
|
-
function r(f, S) {
|
|
915
|
-
f.operationMethod = S;
|
|
916
|
-
}
|
|
917
|
-
function c(f) {
|
|
918
|
-
f.operationMethod = void 0;
|
|
919
|
-
}
|
|
920
|
-
function l(f, S, M = !0) {
|
|
921
|
-
U(f);
|
|
922
|
-
const P = S();
|
|
923
|
-
return I(f), M && f.assigned_.set("length", !0), P;
|
|
924
|
-
}
|
|
925
|
-
function _(f) {
|
|
926
|
-
f.allIndicesReassigned_ = !0;
|
|
927
|
-
}
|
|
928
|
-
function g(f, S) {
|
|
929
|
-
return f < 0 ? Math.max(S + f, 0) : Math.min(f, S);
|
|
930
|
-
}
|
|
931
|
-
function y(f, S, M) {
|
|
932
|
-
return l(f, () => {
|
|
933
|
-
const P = f.copy_[S](...M);
|
|
934
|
-
return t.has(S) && _(f), n.has(S) ? P : f.draft_;
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
function V(f, S, M) {
|
|
938
|
-
return l(
|
|
939
|
-
f,
|
|
940
|
-
() => (f.copy_[S](...M), _(f), f.draft_),
|
|
941
|
-
!1
|
|
942
|
-
);
|
|
943
|
-
}
|
|
944
|
-
function D(f, S) {
|
|
945
|
-
return function(...P) {
|
|
946
|
-
const w = S;
|
|
947
|
-
r(f, w);
|
|
948
|
-
try {
|
|
949
|
-
if (h(w)) {
|
|
950
|
-
if (n.has(w))
|
|
951
|
-
return y(f, w, P);
|
|
952
|
-
if (i.has(w))
|
|
953
|
-
return V(f, w, P);
|
|
954
|
-
if (w === "splice") {
|
|
955
|
-
const T = l(
|
|
956
|
-
f,
|
|
957
|
-
() => f.copy_.splice(...P)
|
|
958
|
-
);
|
|
959
|
-
return _(f), T;
|
|
960
|
-
}
|
|
961
|
-
} else
|
|
962
|
-
return O(f, w, P);
|
|
963
|
-
} finally {
|
|
964
|
-
c(f);
|
|
965
|
-
}
|
|
726
|
+
var Ht = new Gt(), z = Ht.produce;
|
|
727
|
+
let Yt = () => ({
|
|
728
|
+
emit(t, ...e) {
|
|
729
|
+
for (let i = this.events[t] || [], n = 0, r = i.length; n < r; n++)
|
|
730
|
+
i[n](...e);
|
|
731
|
+
},
|
|
732
|
+
events: {},
|
|
733
|
+
on(t, e) {
|
|
734
|
+
return (this.events[t] ||= []).push(e), () => {
|
|
735
|
+
this.events[t] = this.events[t]?.filter((i) => e !== i);
|
|
966
736
|
};
|
|
967
737
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
if (S === "filter") {
|
|
971
|
-
const w = M[0], T = [];
|
|
972
|
-
for (let z = 0; z < P.length; z++)
|
|
973
|
-
w(P[z], z, P) && T.push(f.draft_[z]);
|
|
974
|
-
return T;
|
|
975
|
-
}
|
|
976
|
-
if (a.has(S)) {
|
|
977
|
-
const w = M[0], T = S === "find", z = T ? 1 : -1, ft = T ? 0 : P.length - 1;
|
|
978
|
-
for (let A = ft; A >= 0 && A < P.length; A += z)
|
|
979
|
-
if (w(P[A], A, P))
|
|
980
|
-
return f.draft_[A];
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
if (S === "slice") {
|
|
984
|
-
const w = M[0] ?? 0, T = M[1] ?? P.length, z = g(w, P.length), ft = g(T, P.length), A = [];
|
|
985
|
-
for (let dt = z; dt < ft; dt++)
|
|
986
|
-
A.push(f.draft_[dt]);
|
|
987
|
-
return A;
|
|
988
|
-
}
|
|
989
|
-
return P[S](...M);
|
|
990
|
-
}
|
|
991
|
-
Ct(St, {
|
|
992
|
-
createMethodInterceptor: D,
|
|
993
|
-
isArrayOperationMethod: s,
|
|
994
|
-
isMutatingArrayMethod: h
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
|
-
var re = new te(), R = re.produce;
|
|
998
|
-
function Y(t) {
|
|
738
|
+
});
|
|
739
|
+
function R(t) {
|
|
999
740
|
if (typeof t != "object" || t === null) return;
|
|
1000
741
|
const e = Object.getPrototypeOf(t);
|
|
1001
742
|
if (e === Object.prototype || e === null) return;
|
|
1002
|
-
const
|
|
1003
|
-
typeof
|
|
743
|
+
const i = e.constructor;
|
|
744
|
+
typeof i == "function" && (t instanceof Date || t instanceof RegExp || t instanceof Map || t instanceof Set || t instanceof WeakMap || t instanceof WeakSet || ArrayBuffer.isView(t) || i[x] !== !0 && (i[x] = !0));
|
|
1004
745
|
}
|
|
1005
|
-
let
|
|
1006
|
-
function
|
|
1007
|
-
return
|
|
746
|
+
let Xt = 0;
|
|
747
|
+
function Jt() {
|
|
748
|
+
return Xt++;
|
|
1008
749
|
}
|
|
1009
|
-
class
|
|
1010
|
-
constructor(e,
|
|
1011
|
-
this.controller = e, this.path =
|
|
750
|
+
class Qt {
|
|
751
|
+
constructor(e, i, n) {
|
|
752
|
+
this.controller = e, this.path = i, this.id = Jt(), this._isTouched = !1, this._isDirty = !1, n?.isTouched && this._setTouched(!0), n?.isDirty && this._setDirty(!0);
|
|
753
|
+
}
|
|
754
|
+
get canonicalPath() {
|
|
755
|
+
return h.toCanonicalPath(this.path);
|
|
756
|
+
}
|
|
757
|
+
get stringPath() {
|
|
758
|
+
return h.toStringPath(this.path);
|
|
1012
759
|
}
|
|
1013
760
|
get value() {
|
|
1014
|
-
return
|
|
1015
|
-
this.controller._data,
|
|
1016
|
-
this.path
|
|
1017
|
-
);
|
|
761
|
+
return h.getValue(this.controller._data, this.path);
|
|
1018
762
|
}
|
|
1019
763
|
get initialValue() {
|
|
1020
|
-
return
|
|
1021
|
-
this.controller._initialData,
|
|
1022
|
-
this.path
|
|
1023
|
-
);
|
|
764
|
+
return h.getValue(this.controller._initialData, this.path);
|
|
1024
765
|
}
|
|
1025
766
|
get boundElement() {
|
|
1026
767
|
return this.target;
|
|
1027
768
|
}
|
|
1028
769
|
get issues() {
|
|
1029
770
|
return this.controller._issues.filter(
|
|
1030
|
-
(e) =>
|
|
771
|
+
(e) => h.equals(h.normalize(e.path), this.path)
|
|
1031
772
|
);
|
|
1032
773
|
}
|
|
1033
774
|
get isTouched() {
|
|
@@ -1040,68 +781,68 @@ class ae {
|
|
|
1040
781
|
return this.issues.length === 0;
|
|
1041
782
|
}
|
|
1042
783
|
_setTouched(e) {
|
|
1043
|
-
const
|
|
1044
|
-
if (this._isTouched = e,
|
|
1045
|
-
const
|
|
1046
|
-
for (let
|
|
1047
|
-
const
|
|
1048
|
-
|
|
784
|
+
const i = this._isTouched !== e;
|
|
785
|
+
if (this._isTouched = e, i) {
|
|
786
|
+
const n = this.controller.getAscendantFields(this.path);
|
|
787
|
+
for (let r = n.length - 1; r >= 0; r--) {
|
|
788
|
+
const s = n[r];
|
|
789
|
+
s != null && this.controller.events.emit("fieldTouchUpdated", s.path);
|
|
1049
790
|
}
|
|
1050
791
|
}
|
|
1051
792
|
}
|
|
1052
793
|
_setDirty(e) {
|
|
1053
|
-
const
|
|
1054
|
-
if (this._isDirty = e,
|
|
1055
|
-
const
|
|
1056
|
-
for (let
|
|
1057
|
-
const
|
|
1058
|
-
|
|
794
|
+
const i = this._isDirty !== e;
|
|
795
|
+
if (this._isDirty = e, i) {
|
|
796
|
+
const n = this.controller.getAscendantFields(this.path);
|
|
797
|
+
for (let r = n.length - 1; r >= 0; r--) {
|
|
798
|
+
const s = n[r];
|
|
799
|
+
s != null && this.controller.events.emit("fieldDirtyUpdated", s.path);
|
|
1059
800
|
}
|
|
1060
801
|
}
|
|
1061
802
|
}
|
|
1062
803
|
bindElement(e) {
|
|
1063
|
-
e != null ? this.controller.events.emit("elementBound", this.path, e) : this.controller.events.emit("elementUnbound", this.path)
|
|
1064
|
-
}
|
|
1065
|
-
setValue(e,
|
|
1066
|
-
return this.modifyValue(() => e,
|
|
1067
|
-
}
|
|
1068
|
-
modifyValue(e,
|
|
1069
|
-
(
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
|
|
804
|
+
this.target = e, e != null ? this.controller.events.emit("elementBound", this.path, e) : this.controller.events.emit("elementUnbound", this.path);
|
|
805
|
+
}
|
|
806
|
+
setValue(e, i) {
|
|
807
|
+
return this.modifyValue(() => e, i);
|
|
808
|
+
}
|
|
809
|
+
modifyValue(e, i) {
|
|
810
|
+
(i?.shouldTouch == null || i?.shouldTouch) && this.touch();
|
|
811
|
+
const n = this.controller.getAscendantFields(this.path), r = n.map((u) => u?.initialValue);
|
|
812
|
+
r.forEach((u) => R(u));
|
|
813
|
+
const s = n.map((u) => u?.value);
|
|
814
|
+
s.forEach((u) => R(u)), this.controller._data = z(this.controller._data, (u) => {
|
|
815
|
+
h.modifyValue(u, this.path, (_) => e(_));
|
|
1075
816
|
});
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
const
|
|
1079
|
-
if (typeof
|
|
1080
|
-
const c =
|
|
1081
|
-
if (c ===
|
|
1082
|
-
return this.controller.equalityComparators?.[c]?.(
|
|
817
|
+
const o = n.map((u) => u?.value);
|
|
818
|
+
o.forEach((u) => R(u));
|
|
819
|
+
const f = (u, _) => {
|
|
820
|
+
if (typeof u != "object" || typeof _ != "object") return;
|
|
821
|
+
const c = u.constructor, a = _.constructor;
|
|
822
|
+
if (c === a)
|
|
823
|
+
return this.controller.equalityComparators?.[c]?.(u, _);
|
|
1083
824
|
};
|
|
1084
|
-
if (!
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
825
|
+
if (!V.deepEqual(
|
|
826
|
+
s[s.length - 1],
|
|
827
|
+
o[o.length - 1],
|
|
828
|
+
f
|
|
1088
829
|
))
|
|
1089
|
-
for (let
|
|
1090
|
-
const
|
|
830
|
+
for (let u = n.length - 1; u >= 0; u--) {
|
|
831
|
+
const _ = n[u];
|
|
1091
832
|
this.controller.events.emit(
|
|
1092
833
|
"valueChanged",
|
|
1093
|
-
|
|
1094
|
-
u
|
|
1095
|
-
|
|
834
|
+
_.path,
|
|
835
|
+
o[u],
|
|
836
|
+
s[u]
|
|
1096
837
|
);
|
|
1097
838
|
}
|
|
1098
|
-
if (
|
|
1099
|
-
const
|
|
839
|
+
if (i?.shouldMarkDirty == null || i?.shouldMarkDirty) {
|
|
840
|
+
const u = !V.deepEqual(
|
|
841
|
+
r[r.length - 1],
|
|
1100
842
|
o[o.length - 1],
|
|
1101
|
-
|
|
1102
|
-
h
|
|
843
|
+
f
|
|
1103
844
|
);
|
|
1104
|
-
this._setDirty(
|
|
845
|
+
this._setDirty(u);
|
|
1105
846
|
}
|
|
1106
847
|
}
|
|
1107
848
|
reset() {
|
|
@@ -1122,29 +863,15 @@ class ae {
|
|
|
1122
863
|
}), this.target?.scrollIntoView(), this.target?.focus();
|
|
1123
864
|
}
|
|
1124
865
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
events: {},
|
|
1131
|
-
on(t, e) {
|
|
1132
|
-
return (this.events[t] ||= []).push(e), () => {
|
|
1133
|
-
this.events[t] = this.events[t]?.filter((n) => e !== n);
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
function le(t, e) {
|
|
1138
|
-
let n = [];
|
|
1139
|
-
for (let i = t.length - 1; i >= 0; i--)
|
|
1140
|
-
e(t[i]) && n.push(i);
|
|
1141
|
-
n.forEach((i) => t.splice(i, 1));
|
|
866
|
+
function Zt(t, e) {
|
|
867
|
+
let i = [];
|
|
868
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
869
|
+
e(t[n]) && i.push(n);
|
|
870
|
+
i.forEach((n) => t.splice(n, 1));
|
|
1142
871
|
}
|
|
1143
|
-
|
|
1144
|
-
ie();
|
|
1145
|
-
class ue {
|
|
872
|
+
class te {
|
|
1146
873
|
constructor(e) {
|
|
1147
|
-
this._isValidating = !1, this._isSubmitting = !1, this._fields = /* @__PURE__ */ new Map(), this._issues = [], this.events =
|
|
874
|
+
this._isValidating = !1, this._isSubmitting = !1, this._fields = /* @__PURE__ */ new Map(), this._issues = [], this.events = Yt(), this.validationSchema = e.validationSchema, this.equalityComparators = e.equalityComparators, this._initialData = e.initialData ?? {}, this._data = z(this._initialData, () => {
|
|
1148
875
|
});
|
|
1149
876
|
}
|
|
1150
877
|
get isDirty() {
|
|
@@ -1167,67 +894,66 @@ class ue {
|
|
|
1167
894
|
setSubmitting(e) {
|
|
1168
895
|
this._isSubmitting !== e && (this._isSubmitting = e, this.events.emit("submissionStatusChange", e));
|
|
1169
896
|
}
|
|
1170
|
-
_unsafeSetFieldValue(e,
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
})), this._data =
|
|
1174
|
-
|
|
897
|
+
_unsafeSetFieldValue(e, i, n) {
|
|
898
|
+
R(i), n?.updateInitialValue === !0 && (this._initialData = z(this._initialData, (r) => {
|
|
899
|
+
h.setValue(r, e, i);
|
|
900
|
+
})), this._data = z(this._data, (r) => {
|
|
901
|
+
h.setValue(r, e, i);
|
|
1175
902
|
});
|
|
1176
903
|
}
|
|
1177
904
|
// TODO: Rename to "register" ??
|
|
1178
|
-
bindField(e,
|
|
1179
|
-
let
|
|
1180
|
-
|
|
1181
|
-
updateInitialValue:
|
|
1182
|
-
}),
|
|
1183
|
-
const
|
|
1184
|
-
isDirty: !
|
|
905
|
+
bindField(e, i) {
|
|
906
|
+
let n = h.getValue(this._data, e);
|
|
907
|
+
n == null && i?.defaultValue != null && (this._unsafeSetFieldValue(e, i.defaultValue, {
|
|
908
|
+
updateInitialValue: i.overrideInitialValue
|
|
909
|
+
}), n = h.getValue(this._data, e));
|
|
910
|
+
const r = h.getValue(this._initialData, e), s = new Qt(this, e, {
|
|
911
|
+
isDirty: !V.deepEqual(n, r)
|
|
1185
912
|
});
|
|
1186
|
-
return
|
|
913
|
+
return i?.domElement != null && s.bindElement(i.domElement), this._fields.set(s.stringPath, s), this.events.emit("fieldBound", s.path), s;
|
|
1187
914
|
}
|
|
1188
915
|
unbindField(e) {
|
|
1189
|
-
|
|
916
|
+
const i = h.toStringPath(e);
|
|
917
|
+
this._fields.delete(i), this.events.emit("fieldUnbound", e);
|
|
1190
918
|
}
|
|
1191
919
|
// TODO: Add an option to keep dirty/touched fields as they are
|
|
1192
920
|
reset(e) {
|
|
1193
921
|
this._data = this._initialData, this._issues = [];
|
|
1194
|
-
for (const
|
|
1195
|
-
|
|
1196
|
-
e != null && (this._initialData = e, this._data =
|
|
922
|
+
for (const i of this._fields.values())
|
|
923
|
+
i.reset();
|
|
924
|
+
e != null && (this._initialData = e, this._data = z(this._initialData, () => {
|
|
1197
925
|
}));
|
|
1198
926
|
}
|
|
1199
927
|
getAscendantFields(e) {
|
|
1200
|
-
|
|
1201
|
-
return n.map((o, a) => m.parsePath(
|
|
1202
|
-
n.slice(0, a + 1)
|
|
1203
|
-
)).map((o) => this.getField(o)).filter((o) => !!o);
|
|
928
|
+
return e.map((n, r) => e.slice(0, r + 1)).map((n) => this.getField(n)).filter((n) => !!n);
|
|
1204
929
|
}
|
|
1205
930
|
getField(e) {
|
|
1206
|
-
|
|
931
|
+
const i = h.toStringPath(e);
|
|
932
|
+
return this._fields.get(i);
|
|
1207
933
|
}
|
|
1208
934
|
clearFieldIssues(e) {
|
|
1209
|
-
this._issues = this._issues.filter((
|
|
935
|
+
this._issues = this._issues.filter((i) => !h.equals(h.normalize(i.path), e));
|
|
1210
936
|
}
|
|
1211
|
-
async applyValidation(e,
|
|
1212
|
-
const
|
|
937
|
+
async applyValidation(e, i) {
|
|
938
|
+
const n = V.diff(
|
|
1213
939
|
this._issues,
|
|
1214
940
|
e.issues ?? [],
|
|
1215
|
-
|
|
1216
|
-
(
|
|
1217
|
-
if (
|
|
1218
|
-
const
|
|
1219
|
-
return
|
|
941
|
+
V.deepEqual,
|
|
942
|
+
(r) => {
|
|
943
|
+
if (r.path == null) return !1;
|
|
944
|
+
const s = h.normalize(r.path);
|
|
945
|
+
return h.equals(s, i) || h.isDescendant(i, s);
|
|
1220
946
|
}
|
|
1221
947
|
);
|
|
1222
|
-
|
|
948
|
+
Zt(this._issues, (r) => n.removed.includes(r)), n.added.forEach((r) => this._issues.push(r)), (n.added.length !== 0 || n.removed.length !== 0) && this.events.emit("fieldIssuesUpdated", i);
|
|
1223
949
|
}
|
|
1224
950
|
async validateField(e) {
|
|
1225
951
|
if (this._isValidating || this.validationSchema == null) return;
|
|
1226
952
|
this.setValidating(!0), this.getField(e) == null && this.bindField(e);
|
|
1227
|
-
const
|
|
953
|
+
const i = await this.validationSchema["~standard"].validate(
|
|
1228
954
|
this._data
|
|
1229
955
|
);
|
|
1230
|
-
this.events.emit("validationTriggered", e), this.applyValidation(
|
|
956
|
+
this.events.emit("validationTriggered", e), this.applyValidation(i, e), this.setValidating(!1);
|
|
1231
957
|
}
|
|
1232
958
|
async validateForm() {
|
|
1233
959
|
if (this._isValidating || this.validationSchema == null) return;
|
|
@@ -1235,49 +961,55 @@ class ue {
|
|
|
1235
961
|
const e = await this.validationSchema["~standard"].validate(
|
|
1236
962
|
this._data
|
|
1237
963
|
);
|
|
1238
|
-
for (const
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
964
|
+
for (const n of this._fields.keys()) {
|
|
965
|
+
const r = h.fromStringPath(n);
|
|
966
|
+
this.events.emit("validationTriggered", r), this.applyValidation(e, r);
|
|
967
|
+
}
|
|
968
|
+
V.diff(
|
|
969
|
+
this._issues,
|
|
970
|
+
e.issues ?? [],
|
|
971
|
+
V.deepEqual
|
|
972
|
+
).added.forEach((n) => this._issues.push(n)), this.setValidating(!1);
|
|
973
|
+
}
|
|
974
|
+
createSubmitHandler(e, i) {
|
|
975
|
+
return async (n) => {
|
|
976
|
+
if (n?.preventDefault(), this._isValidating || this._isSubmitting) return;
|
|
977
|
+
const r = new AbortController();
|
|
1246
978
|
if (await this.validateForm(), this._issues.length === 0) {
|
|
1247
|
-
this.setSubmitting(!0), await e?.(this._data,
|
|
979
|
+
this.setSubmitting(!0), await e?.(this._data, n, r.signal), this.setSubmitting(!1);
|
|
1248
980
|
return;
|
|
1249
981
|
}
|
|
1250
|
-
for (const
|
|
1251
|
-
if (
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1254
|
-
|
|
982
|
+
for (const s of this._issues) {
|
|
983
|
+
if (s.path == null) continue;
|
|
984
|
+
const o = h.normalize(s.path), f = this.getField(o);
|
|
985
|
+
if (f != null && f.boundElement != null) {
|
|
986
|
+
f.focus();
|
|
1255
987
|
break;
|
|
1256
988
|
}
|
|
1257
989
|
}
|
|
1258
|
-
await
|
|
990
|
+
await i?.(this._issues, n, r.signal), this.setSubmitting(!1);
|
|
1259
991
|
};
|
|
1260
992
|
}
|
|
1261
993
|
}
|
|
1262
|
-
function
|
|
994
|
+
function ee(t) {
|
|
1263
995
|
return {
|
|
1264
996
|
"~standard": {
|
|
1265
997
|
version: 1,
|
|
1266
998
|
vendor: "goodie-forms/custom",
|
|
1267
999
|
validate: async (e) => {
|
|
1268
1000
|
try {
|
|
1269
|
-
const
|
|
1270
|
-
return
|
|
1271
|
-
issues:
|
|
1272
|
-
path:
|
|
1273
|
-
message:
|
|
1001
|
+
const i = await t(e);
|
|
1002
|
+
return i == null ? { value: e } : {
|
|
1003
|
+
issues: i.map((n) => ({
|
|
1004
|
+
path: h.fromStringPath(n.path),
|
|
1005
|
+
message: n.message
|
|
1274
1006
|
}))
|
|
1275
1007
|
};
|
|
1276
|
-
} catch (
|
|
1008
|
+
} catch (i) {
|
|
1277
1009
|
return {
|
|
1278
1010
|
issues: [
|
|
1279
1011
|
{
|
|
1280
|
-
message:
|
|
1012
|
+
message: i instanceof Error ? i.message : "Unknown error"
|
|
1281
1013
|
}
|
|
1282
1014
|
]
|
|
1283
1015
|
};
|
|
@@ -1287,9 +1019,11 @@ function fe(t) {
|
|
|
1287
1019
|
};
|
|
1288
1020
|
}
|
|
1289
1021
|
export {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1022
|
+
h as FieldPath,
|
|
1023
|
+
et as FieldPathBuilder,
|
|
1024
|
+
te as FormController,
|
|
1025
|
+
Qt as FormField,
|
|
1026
|
+
V as Reconsile,
|
|
1027
|
+
ee as customValidation
|
|
1294
1028
|
};
|
|
1295
1029
|
//# sourceMappingURL=index.js.map
|