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