@reformer/core 11.0.0-beta.1 → 11.0.0-beta.2
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/behaviors.js +134 -134
- package/dist/form-model-DhW2HZOB.js +323 -0
- package/dist/index.js +47 -47
- package/dist/state/form-model.d.ts +14 -0
- package/dist/state/index.d.ts +2 -1
- package/dist/state/types.d.ts +39 -11
- package/dist/state.js +18 -18
- package/dist/validation.js +1 -1
- package/docs/llms/19-reading-values.md +30 -1
- package/docs/llms/20-compute-vs-watch.md +9 -0
- package/llms.txt +104 -5
- package/package.json +1 -1
- package/dist/derived-registry-CluZCQ7U.js +0 -16
- package/dist/form-model-DYCzGGKF.js +0 -286
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { batch as k, signal as _, computed as O } from "@preact/signals-core";
|
|
2
|
+
const h = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function F(e) {
|
|
4
|
+
h.set(e, (h.get(e) ?? 0) + 1);
|
|
5
|
+
}
|
|
6
|
+
function K(e) {
|
|
7
|
+
const t = h.get(e);
|
|
8
|
+
t !== void 0 && (t <= 1 ? h.delete(e) : h.set(e, t - 1));
|
|
9
|
+
}
|
|
10
|
+
function P(e) {
|
|
11
|
+
return h.has(e);
|
|
12
|
+
}
|
|
13
|
+
const p = (e) => !(e === null || typeof e != "object" || Array.isArray(e) || e instanceof Date || typeof Blob < "u" && e instanceof Blob || typeof File < "u" && e instanceof File), c = (e, t) => e === "" ? String(t) : `${e}.${t}`, m = (e) => /^\d+$/.test(e), l = (e) => {
|
|
14
|
+
if (Array.isArray(e)) return e.map(l);
|
|
15
|
+
if (p(e)) {
|
|
16
|
+
const t = {};
|
|
17
|
+
for (const i of Object.keys(e)) t[i] = l(e[i]);
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}, g = (e, t) => {
|
|
22
|
+
if (e === t) return !0;
|
|
23
|
+
if (Array.isArray(e) && Array.isArray(t))
|
|
24
|
+
return e.length !== t.length ? !1 : e.every((i, r) => g(i, t[r]));
|
|
25
|
+
if (p(e) && p(t)) {
|
|
26
|
+
const i = Object.keys(e), r = Object.keys(t);
|
|
27
|
+
return i.length !== r.length ? !1 : i.every((n) => g(e[n], t[n]));
|
|
28
|
+
}
|
|
29
|
+
return !1;
|
|
30
|
+
};
|
|
31
|
+
class j {
|
|
32
|
+
constructor(t, i) {
|
|
33
|
+
this.path = i;
|
|
34
|
+
const r = _(t);
|
|
35
|
+
r.__path = i, this.signal = r, this.initial = l(t);
|
|
36
|
+
}
|
|
37
|
+
kind = "leaf";
|
|
38
|
+
signal;
|
|
39
|
+
initial;
|
|
40
|
+
rebase(t) {
|
|
41
|
+
this.path = t, this.signal.__path = t;
|
|
42
|
+
}
|
|
43
|
+
/** Реактивное чтение (внутри effect/computed создаёт зависимость). */
|
|
44
|
+
read() {
|
|
45
|
+
return this.signal.value;
|
|
46
|
+
}
|
|
47
|
+
/** Нереактивный снимок. */
|
|
48
|
+
peek() {
|
|
49
|
+
return this.signal.peek();
|
|
50
|
+
}
|
|
51
|
+
set(t) {
|
|
52
|
+
this.signal.value = t;
|
|
53
|
+
}
|
|
54
|
+
resetToInitial() {
|
|
55
|
+
this.signal.value = l(this.initial);
|
|
56
|
+
}
|
|
57
|
+
captureInitial() {
|
|
58
|
+
this.initial = l(this.signal.peek());
|
|
59
|
+
}
|
|
60
|
+
dirty() {
|
|
61
|
+
return !g(this.signal.peek(), this.initial);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class x {
|
|
65
|
+
constructor(t, i) {
|
|
66
|
+
this.path = i;
|
|
67
|
+
for (const r of Object.keys(t))
|
|
68
|
+
this.children.set(r, d(t[r], c(i, r)));
|
|
69
|
+
}
|
|
70
|
+
kind = "group";
|
|
71
|
+
children = /* @__PURE__ */ new Map();
|
|
72
|
+
rebase(t) {
|
|
73
|
+
this.path = t;
|
|
74
|
+
for (const [i, r] of this.children) r.rebase(c(t, i));
|
|
75
|
+
}
|
|
76
|
+
/** Реактивное чтение поддерева (внутри effect/computed подписывает на все листья группы). */
|
|
77
|
+
read() {
|
|
78
|
+
const t = {};
|
|
79
|
+
for (const [i, r] of this.children) t[i] = r.read();
|
|
80
|
+
return t;
|
|
81
|
+
}
|
|
82
|
+
peek() {
|
|
83
|
+
const t = {};
|
|
84
|
+
for (const [i, r] of this.children) t[i] = r.peek();
|
|
85
|
+
return t;
|
|
86
|
+
}
|
|
87
|
+
set(t) {
|
|
88
|
+
if (t == null || typeof t != "object") return;
|
|
89
|
+
const i = t;
|
|
90
|
+
k(() => {
|
|
91
|
+
for (const [r, n] of this.children)
|
|
92
|
+
r in i && (n.kind === "leaf" && P(n.signal) || n.set(i[r]));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
resetToInitial() {
|
|
96
|
+
k(() => {
|
|
97
|
+
for (const t of this.children.values()) t.resetToInitial();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
captureInitial() {
|
|
101
|
+
for (const t of this.children.values()) t.captureInitial();
|
|
102
|
+
}
|
|
103
|
+
dirty() {
|
|
104
|
+
for (const t of this.children.values()) if (t.dirty()) return !0;
|
|
105
|
+
return !1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
class N {
|
|
109
|
+
constructor(t, i) {
|
|
110
|
+
this.path = i, this.items = _(t.map((r, n) => d(r, c(i, n)))), this.initial = l(t);
|
|
111
|
+
}
|
|
112
|
+
kind = "array";
|
|
113
|
+
items;
|
|
114
|
+
initial;
|
|
115
|
+
rebase(t) {
|
|
116
|
+
this.path = t, this.items.peek().forEach((i, r) => i.rebase(c(t, r)));
|
|
117
|
+
}
|
|
118
|
+
reindex() {
|
|
119
|
+
this.items.peek().forEach((t, i) => t.rebase(c(this.path, i)));
|
|
120
|
+
}
|
|
121
|
+
push(t) {
|
|
122
|
+
const i = this.items.peek();
|
|
123
|
+
this.items.value = [...i, d(t, c(this.path, i.length))];
|
|
124
|
+
}
|
|
125
|
+
insertAt(t, i) {
|
|
126
|
+
const r = [...this.items.peek()];
|
|
127
|
+
r.splice(t, 0, d(i, c(this.path, t))), this.items.value = r, this.reindex();
|
|
128
|
+
}
|
|
129
|
+
removeAt(t) {
|
|
130
|
+
const i = [...this.items.peek()];
|
|
131
|
+
i.splice(t, 1), this.items.value = i, this.reindex();
|
|
132
|
+
}
|
|
133
|
+
move(t, i) {
|
|
134
|
+
const r = [...this.items.peek()], [n] = r.splice(t, 1);
|
|
135
|
+
n && r.splice(i, 0, n), this.items.value = r, this.reindex();
|
|
136
|
+
}
|
|
137
|
+
swap(t, i) {
|
|
138
|
+
const r = [...this.items.peek()];
|
|
139
|
+
t < 0 || i < 0 || t >= r.length || i >= r.length || t === i || ([r[t], r[i]] = [r[i], r[t]], this.items.value = r, this.reindex());
|
|
140
|
+
}
|
|
141
|
+
clear() {
|
|
142
|
+
this.items.value = [];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Реактивное чтение массива. Читаем `items.value` (а не `.peek()`) — внутри effect/computed это
|
|
146
|
+
* подписка на СОСТАВ массива, поэтому push/removeAt/move ретригерят наравне с правкой элемента.
|
|
147
|
+
*/
|
|
148
|
+
read() {
|
|
149
|
+
return this.items.value.map((t) => t.read());
|
|
150
|
+
}
|
|
151
|
+
peek() {
|
|
152
|
+
return this.items.peek().map((t) => t.peek());
|
|
153
|
+
}
|
|
154
|
+
set(t) {
|
|
155
|
+
const i = Array.isArray(t) ? t : [];
|
|
156
|
+
this.items.value = i.map((r, n) => d(r, c(this.path, n)));
|
|
157
|
+
}
|
|
158
|
+
resetToInitial() {
|
|
159
|
+
this.set(l(this.initial));
|
|
160
|
+
}
|
|
161
|
+
captureInitial() {
|
|
162
|
+
this.initial = l(this.peek());
|
|
163
|
+
}
|
|
164
|
+
dirty() {
|
|
165
|
+
return !g(this.peek(), this.initial);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function d(e, t) {
|
|
169
|
+
return Array.isArray(e) ? new N(e, t) : p(e) ? new x(e, t) : new j(e, t);
|
|
170
|
+
}
|
|
171
|
+
function f(e) {
|
|
172
|
+
if (e)
|
|
173
|
+
return e.kind === "group" ? S(e) : e.kind === "array" ? E(e) : e.read();
|
|
174
|
+
}
|
|
175
|
+
function E(e) {
|
|
176
|
+
const t = {
|
|
177
|
+
get length() {
|
|
178
|
+
return e.items.value.length;
|
|
179
|
+
},
|
|
180
|
+
push: (i) => e.push(i),
|
|
181
|
+
insertAt: (i, r) => e.insertAt(i, r),
|
|
182
|
+
removeAt: (i) => e.removeAt(i),
|
|
183
|
+
move: (i, r) => e.move(i, r),
|
|
184
|
+
swap: (i, r) => e.swap(i, r),
|
|
185
|
+
clear: () => e.clear(),
|
|
186
|
+
at: (i) => f(e.items.value[i]),
|
|
187
|
+
map: (i) => e.items.value.map((r, n) => i(f(r), n)),
|
|
188
|
+
forEach: (i) => e.items.value.forEach((r, n) => i(f(r), n)),
|
|
189
|
+
toArray: () => e.peek(),
|
|
190
|
+
[Symbol.iterator]: function* () {
|
|
191
|
+
const i = e.items.value;
|
|
192
|
+
for (let r = 0; r < i.length; r++) yield f(i[r]);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
return new Proxy(t, {
|
|
196
|
+
get: (i, r, n) => r === "__path" ? e.path : typeof r == "string" && m(r) ? f(e.items.value[Number(r)]) : Reflect.get(i, r, n),
|
|
197
|
+
has: (i, r) => typeof r == "string" && m(r) ? Number(r) < e.items.value.length : Reflect.has(i, r)
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const A = /* @__PURE__ */ new WeakMap();
|
|
201
|
+
function M(e) {
|
|
202
|
+
const t = O(() => e.read());
|
|
203
|
+
return {
|
|
204
|
+
get value() {
|
|
205
|
+
return t.value;
|
|
206
|
+
},
|
|
207
|
+
peek: () => t.peek(),
|
|
208
|
+
subscribe: (i) => t.subscribe(i),
|
|
209
|
+
valueOf: () => t.value,
|
|
210
|
+
toString: () => String(t.value),
|
|
211
|
+
toJSON: () => t.value,
|
|
212
|
+
brand: t.brand
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function I(e) {
|
|
216
|
+
if (e.kind === "leaf") return e.signal;
|
|
217
|
+
const t = A.get(e);
|
|
218
|
+
if (t) return t;
|
|
219
|
+
const i = M(e), r = e.kind === "group", n = (o) => r ? e.children.get(o) : m(o) ? e.items.value[Number(o)] : void 0, s = r ? {} : {
|
|
220
|
+
get length() {
|
|
221
|
+
return e.items.value.length;
|
|
222
|
+
}
|
|
223
|
+
}, u = new Proxy(s, {
|
|
224
|
+
get: (o, a, D) => {
|
|
225
|
+
if (a === "__path") return e.path;
|
|
226
|
+
if (a === "__kind") return e.kind;
|
|
227
|
+
if (typeof a != "string") return Reflect.get(i, a, i);
|
|
228
|
+
const v = n(a);
|
|
229
|
+
return v ? I(v) : !r && Reflect.has(o, a) ? Reflect.get(o, a, D) : Reflect.get(i, a, i);
|
|
230
|
+
},
|
|
231
|
+
has: (o, a) => typeof a == "string" && (n(a) !== void 0 || !r && Reflect.has(o, a)),
|
|
232
|
+
ownKeys: () => r ? [...e.children.keys()] : Reflect.ownKeys(s),
|
|
233
|
+
getOwnPropertyDescriptor: (o, a) => typeof a == "string" && n(a) ? { enumerable: !0, configurable: !0 } : r ? void 0 : Reflect.getOwnPropertyDescriptor(o, a)
|
|
234
|
+
});
|
|
235
|
+
return A.set(e, u), u;
|
|
236
|
+
}
|
|
237
|
+
function W(e) {
|
|
238
|
+
if (e == null || typeof e != "object") return !1;
|
|
239
|
+
const t = e.__kind;
|
|
240
|
+
return t === "group" || t === "array";
|
|
241
|
+
}
|
|
242
|
+
function T(e, t) {
|
|
243
|
+
if (!t) return;
|
|
244
|
+
let i = e;
|
|
245
|
+
for (const r of t.split(".")) {
|
|
246
|
+
if (!i) return;
|
|
247
|
+
if (i.kind === "group") i = i.children.get(r);
|
|
248
|
+
else if (i.kind === "array") i = i.items.peek()[Number(r)];
|
|
249
|
+
else return;
|
|
250
|
+
}
|
|
251
|
+
return i && i.kind === "leaf" ? i.signal : void 0;
|
|
252
|
+
}
|
|
253
|
+
const b = /* @__PURE__ */ new Set([
|
|
254
|
+
"$",
|
|
255
|
+
"get",
|
|
256
|
+
"set",
|
|
257
|
+
"patch",
|
|
258
|
+
"isDirty",
|
|
259
|
+
"reset",
|
|
260
|
+
"captureInitial",
|
|
261
|
+
"signalAt"
|
|
262
|
+
]), w = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap();
|
|
263
|
+
function S(e) {
|
|
264
|
+
const t = w.get(e);
|
|
265
|
+
if (t) return t;
|
|
266
|
+
const i = {
|
|
267
|
+
$: I(e),
|
|
268
|
+
get: () => e.peek(),
|
|
269
|
+
set: (n) => e.set(n),
|
|
270
|
+
patch: (n) => e.set(n),
|
|
271
|
+
isDirty: () => e.dirty(),
|
|
272
|
+
reset: () => e.resetToInitial(),
|
|
273
|
+
captureInitial: () => e.captureInitial(),
|
|
274
|
+
signalAt: (n) => T(e, n)
|
|
275
|
+
}, r = new Proxy(
|
|
276
|
+
{},
|
|
277
|
+
{
|
|
278
|
+
get: (n, s) => {
|
|
279
|
+
if (s === "__path") return e.path;
|
|
280
|
+
if (typeof s != "string") return;
|
|
281
|
+
const u = e.children.get(s);
|
|
282
|
+
if (u) return f(u);
|
|
283
|
+
if (b.has(s)) return i[s];
|
|
284
|
+
},
|
|
285
|
+
set: (n, s, u) => {
|
|
286
|
+
if (typeof s != "string") return !1;
|
|
287
|
+
const o = e.children.get(s);
|
|
288
|
+
return o ? (o.set(u), !0) : !1;
|
|
289
|
+
},
|
|
290
|
+
has: (n, s) => typeof s == "string" && (e.children.has(s) || b.has(s)),
|
|
291
|
+
ownKeys: () => [...e.children.keys()],
|
|
292
|
+
getOwnPropertyDescriptor: (n, s) => typeof s == "string" && e.children.has(s) ? { enumerable: !0, configurable: !0 } : void 0
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
return w.set(e, r), R.set(r, e), r;
|
|
296
|
+
}
|
|
297
|
+
function y(e, t) {
|
|
298
|
+
if (e.kind === "leaf") {
|
|
299
|
+
t(e.signal);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (e.kind === "group") {
|
|
303
|
+
for (const i of e.children.values()) y(i, t);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
for (const i of e.items.value) y(i, t);
|
|
307
|
+
}
|
|
308
|
+
function B(e, t) {
|
|
309
|
+
const i = R.get(e);
|
|
310
|
+
i && y(i, t);
|
|
311
|
+
}
|
|
312
|
+
function C(e) {
|
|
313
|
+
const t = new x(e, "");
|
|
314
|
+
return S(t);
|
|
315
|
+
}
|
|
316
|
+
export {
|
|
317
|
+
P as a,
|
|
318
|
+
C as c,
|
|
319
|
+
B as e,
|
|
320
|
+
W as i,
|
|
321
|
+
F as m,
|
|
322
|
+
K as u
|
|
323
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import {
|
|
4
|
-
import { m as Ye, u as Qe } from "./derived-registry-CluZCQ7U.js";
|
|
1
|
+
import { a as $ } from "./form-model-DhW2HZOB.js";
|
|
2
|
+
import { c as Le, i as Re, m as $e, u as Ge } from "./form-model-DhW2HZOB.js";
|
|
3
|
+
import { c as Ue, a as Be, r as We, b as qe, d as Ke, e as He, f as ze, s as Je, t as Ye, w as Qe } from "./behaviors-value-C7dSEhCc.js";
|
|
5
4
|
import { S as I } from "./subscription-manager-705bls97.js";
|
|
6
5
|
import { signal as g, computed as f, effect as _, batch as X, Signal as G } from "@preact/signals-core";
|
|
7
6
|
import { r as Z } from "./signal-node-registry-tiwel-TV.js";
|
|
@@ -288,7 +287,7 @@ let re = 0;
|
|
|
288
287
|
function N(i) {
|
|
289
288
|
return `${i}-${++re}`;
|
|
290
289
|
}
|
|
291
|
-
var
|
|
290
|
+
var S = /* @__PURE__ */ ((i) => (i.THROW = "throw", i.LOG = "log", i.CONVERT = "convert", i))(S || {});
|
|
292
291
|
class k {
|
|
293
292
|
static handle(e, t, s = "throw") {
|
|
294
293
|
const r = this.extractMessage(e);
|
|
@@ -716,7 +715,7 @@ class ne extends M {
|
|
|
716
715
|
return k.handle(
|
|
717
716
|
u,
|
|
718
717
|
"FieldNode AsyncValidator",
|
|
719
|
-
|
|
718
|
+
S.CONVERT
|
|
720
719
|
);
|
|
721
720
|
}
|
|
722
721
|
})
|
|
@@ -1080,7 +1079,7 @@ function le(i) {
|
|
|
1080
1079
|
}
|
|
1081
1080
|
return e;
|
|
1082
1081
|
}
|
|
1083
|
-
class
|
|
1082
|
+
class A extends M {
|
|
1084
1083
|
// ============================================================================
|
|
1085
1084
|
// Приватные поля
|
|
1086
1085
|
// ============================================================================
|
|
@@ -1365,7 +1364,7 @@ class S extends M {
|
|
|
1365
1364
|
return;
|
|
1366
1365
|
let s = this;
|
|
1367
1366
|
for (const r of t) {
|
|
1368
|
-
if (!(s instanceof
|
|
1367
|
+
if (!(s instanceof A) || (s = s.getField(r.key), !s)) return;
|
|
1369
1368
|
if (r.index !== void 0)
|
|
1370
1369
|
if ("at" in s && "length" in s && typeof s.at == "function") {
|
|
1371
1370
|
const n = s.at(r.index);
|
|
@@ -1567,7 +1566,7 @@ class B extends M {
|
|
|
1567
1566
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1568
1567
|
),
|
|
1569
1568
|
"ArrayNode.removeAt",
|
|
1570
|
-
|
|
1569
|
+
S.LOG
|
|
1571
1570
|
);
|
|
1572
1571
|
return;
|
|
1573
1572
|
}
|
|
@@ -1586,7 +1585,7 @@ class B extends M {
|
|
|
1586
1585
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1587
1586
|
),
|
|
1588
1587
|
"ArrayNode.insert",
|
|
1589
|
-
|
|
1588
|
+
S.LOG
|
|
1590
1589
|
);
|
|
1591
1590
|
return;
|
|
1592
1591
|
}
|
|
@@ -1615,7 +1614,7 @@ class B extends M {
|
|
|
1615
1614
|
k.handle(
|
|
1616
1615
|
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${s})`),
|
|
1617
1616
|
"ArrayNode.move",
|
|
1618
|
-
|
|
1617
|
+
S.LOG
|
|
1619
1618
|
);
|
|
1620
1619
|
return;
|
|
1621
1620
|
}
|
|
@@ -1643,7 +1642,7 @@ class B extends M {
|
|
|
1643
1642
|
k.handle(
|
|
1644
1643
|
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${s})`),
|
|
1645
1644
|
"ArrayNode.swap",
|
|
1646
|
-
|
|
1645
|
+
S.LOG
|
|
1647
1646
|
);
|
|
1648
1647
|
return;
|
|
1649
1648
|
}
|
|
@@ -1681,7 +1680,7 @@ class B extends M {
|
|
|
1681
1680
|
}
|
|
1682
1681
|
setValue(e, t) {
|
|
1683
1682
|
this.clear(), e.forEach((s) => this.push(s)), t?.emitEvent !== !1 && this.validate().catch((s) => {
|
|
1684
|
-
k.handle(s, "ArrayNode.setValue",
|
|
1683
|
+
k.handle(s, "ArrayNode.setValue", S.LOG);
|
|
1685
1684
|
});
|
|
1686
1685
|
}
|
|
1687
1686
|
patchValue(e) {
|
|
@@ -1839,7 +1838,7 @@ class B extends M {
|
|
|
1839
1838
|
*/
|
|
1840
1839
|
createItem(e) {
|
|
1841
1840
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
1842
|
-
const t = new
|
|
1841
|
+
const t = new A(this.itemSchema);
|
|
1843
1842
|
return e && t.patchValue(e), t;
|
|
1844
1843
|
}
|
|
1845
1844
|
throw new Error(
|
|
@@ -1974,7 +1973,7 @@ class ue {
|
|
|
1974
1973
|
e.initialItems
|
|
1975
1974
|
);
|
|
1976
1975
|
if (this.isGroupConfig(e))
|
|
1977
|
-
return new
|
|
1976
|
+
return new A(e);
|
|
1978
1977
|
throw new Error(
|
|
1979
1978
|
`NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
|
|
1980
1979
|
e
|
|
@@ -2343,7 +2342,7 @@ function Y(i, e, t) {
|
|
|
2343
2342
|
function Q(i) {
|
|
2344
2343
|
const { model: e, schema: t, behavior: s } = i, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2345
2344
|
t !== void 0 && D(t, r, n);
|
|
2346
|
-
const a = J(e, e.get(), "", r), l = new
|
|
2345
|
+
const a = J(e, e.get(), "", r), l = new A(a), d = e.get();
|
|
2347
2346
|
for (const [o, m] of Object.entries(d)) {
|
|
2348
2347
|
if (!Array.isArray(m)) continue;
|
|
2349
2348
|
const c = n.get(o);
|
|
@@ -2358,35 +2357,35 @@ function Q(i) {
|
|
|
2358
2357
|
if (m && c) {
|
|
2359
2358
|
Z(m, c);
|
|
2360
2359
|
const h = o.lastIndexOf("."), p = h === -1 ? l : l.getFieldByPath(o.slice(0, h));
|
|
2361
|
-
p instanceof
|
|
2360
|
+
p instanceof A && p.registerFieldSignal(c, m);
|
|
2362
2361
|
}
|
|
2363
2362
|
}
|
|
2364
2363
|
return s && l.attachBehaviorCleanup(s.__run(e, u)), u;
|
|
2365
2364
|
}
|
|
2366
2365
|
const ce = (i) => i != null && typeof i == "object" && "model" in i && typeof i.model?.signalAt == "function";
|
|
2367
2366
|
function Ne(i) {
|
|
2368
|
-
return ce(i) ? Q(i) : new
|
|
2367
|
+
return ce(i) ? Q(i) : new A(i).getProxy();
|
|
2369
2368
|
}
|
|
2370
|
-
function
|
|
2369
|
+
function C(i) {
|
|
2371
2370
|
return i == null ? !1 : typeof i == "object" && "value" in i && "setValue" in i && "getValue" in i && "validate" in i;
|
|
2372
2371
|
}
|
|
2373
2372
|
function he(i) {
|
|
2374
|
-
return
|
|
2373
|
+
return C(i) && "validators" in i && "asyncValidators" in i && // FieldNode имеет markAsTouched метод
|
|
2375
2374
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2376
2375
|
typeof i.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2377
2376
|
!("fields" in i) && !("items" in i);
|
|
2378
2377
|
}
|
|
2379
2378
|
function fe(i) {
|
|
2380
|
-
return
|
|
2379
|
+
return C(i) && "getFieldByPath" in i && "fields" in i && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2381
2380
|
!("items" in i) && !("push" in i) && !("removeAt" in i);
|
|
2382
2381
|
}
|
|
2383
2382
|
function ve(i) {
|
|
2384
|
-
return
|
|
2383
|
+
return C(i) && "items" in i && "length" in i && "push" in i && "removeAt" in i && "at" in i && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2385
2384
|
typeof i.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2386
2385
|
typeof i.removeAt == "function";
|
|
2387
2386
|
}
|
|
2388
2387
|
function Fe(i) {
|
|
2389
|
-
return he(i) ? "FieldNode" : fe(i) ? "GroupNode" : ve(i) ? "ArrayNode" :
|
|
2388
|
+
return he(i) ? "FieldNode" : fe(i) ? "GroupNode" : ve(i) ? "ArrayNode" : C(i) ? "FormNode" : "Unknown";
|
|
2390
2389
|
}
|
|
2391
2390
|
var F = { exports: {} }, P = {};
|
|
2392
2391
|
var W;
|
|
@@ -2488,7 +2487,7 @@ var K;
|
|
|
2488
2487
|
function ye() {
|
|
2489
2488
|
return K || (K = 1, process.env.NODE_ENV === "production" ? F.exports = me() : F.exports = pe()), F.exports;
|
|
2490
2489
|
}
|
|
2491
|
-
var
|
|
2490
|
+
var x = ye();
|
|
2492
2491
|
function ge(i, e) {
|
|
2493
2492
|
if (i === e) return !0;
|
|
2494
2493
|
if (i.length !== e.length) return !1;
|
|
@@ -2546,7 +2545,7 @@ function R(i, e, t, s) {
|
|
|
2546
2545
|
v[h] = m[h];
|
|
2547
2546
|
return v.__snapshot = l.current(m), v.__snapshot;
|
|
2548
2547
|
}, [s]);
|
|
2549
|
-
return
|
|
2548
|
+
return x.useSyncExternalStore(d, u, u);
|
|
2550
2549
|
}
|
|
2551
2550
|
function Ee(i) {
|
|
2552
2551
|
const e = {
|
|
@@ -2646,7 +2645,7 @@ function Me(i) {
|
|
|
2646
2645
|
const e = i && "length" in i && "map" in i;
|
|
2647
2646
|
return i ? e ? be(i) : Ee(i) : _e();
|
|
2648
2647
|
}
|
|
2649
|
-
function
|
|
2648
|
+
function Ce(i) {
|
|
2650
2649
|
const e = V({ value: i.value.value }), t = b(
|
|
2651
2650
|
(r) => {
|
|
2652
2651
|
let n = !0;
|
|
@@ -2663,9 +2662,9 @@ function xe(i) {
|
|
|
2663
2662
|
const r = i.value.value;
|
|
2664
2663
|
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
2665
2664
|
}, [i]);
|
|
2666
|
-
return
|
|
2665
|
+
return x.useSyncExternalStore(t, s, s);
|
|
2667
2666
|
}
|
|
2668
|
-
function
|
|
2667
|
+
function xe(i) {
|
|
2669
2668
|
const e = V({ length: i.length.value }), t = b(
|
|
2670
2669
|
(r) => {
|
|
2671
2670
|
let n = !0;
|
|
@@ -2682,7 +2681,7 @@ function Ce(i) {
|
|
|
2682
2681
|
const r = i.length.value;
|
|
2683
2682
|
return e.current.length === r ? e.current.length : (e.current.length = r, r);
|
|
2684
2683
|
}, [i]);
|
|
2685
|
-
return
|
|
2684
|
+
return x.useSyncExternalStore(t, s, s);
|
|
2686
2685
|
}
|
|
2687
2686
|
function Pe(i) {
|
|
2688
2687
|
const { model: e, schema: t, strategy: s, debounce: r, liveAfterSubmit: n } = i, a = ee(
|
|
@@ -2690,7 +2689,7 @@ function Pe(i) {
|
|
|
2690
2689
|
[e, t, s, r, n]
|
|
2691
2690
|
);
|
|
2692
2691
|
te(() => a.start(), [a]);
|
|
2693
|
-
const l =
|
|
2692
|
+
const l = x.useSyncExternalStore(
|
|
2694
2693
|
b((u) => a.validating.subscribe(u), [a]),
|
|
2695
2694
|
() => a.validating.peek(),
|
|
2696
2695
|
() => !1
|
|
@@ -2702,17 +2701,17 @@ const Te = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
|
2702
2701
|
export {
|
|
2703
2702
|
B as ArrayNode,
|
|
2704
2703
|
Te as CORE_RUNTIME_TOKEN,
|
|
2705
|
-
|
|
2704
|
+
S as ErrorStrategy,
|
|
2706
2705
|
ne as FieldNode,
|
|
2707
2706
|
k as FormErrorHandler,
|
|
2708
2707
|
M as FormNode,
|
|
2709
2708
|
oe as FormSubmitter,
|
|
2710
|
-
|
|
2709
|
+
A as GroupNode,
|
|
2711
2710
|
de as ModelArrayNode,
|
|
2712
2711
|
ue as NodeFactory,
|
|
2713
2712
|
I as SubscriptionManager,
|
|
2714
|
-
|
|
2715
|
-
|
|
2713
|
+
Ue as computeFrom,
|
|
2714
|
+
Be as copyFrom,
|
|
2716
2715
|
Ne as createForm,
|
|
2717
2716
|
Q as createFormFromModel,
|
|
2718
2717
|
Le as createModel,
|
|
@@ -2723,21 +2722,22 @@ export {
|
|
|
2723
2722
|
ve as isArrayNode,
|
|
2724
2723
|
$ as isDerived,
|
|
2725
2724
|
he as isFieldNode,
|
|
2726
|
-
|
|
2725
|
+
C as isFormNode,
|
|
2727
2726
|
fe as isGroupNode,
|
|
2728
|
-
|
|
2727
|
+
Re as isModelContainerSignal,
|
|
2728
|
+
$e as markDerived,
|
|
2729
2729
|
Z as registerSignalNode,
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2730
|
+
We as resetWhen,
|
|
2731
|
+
qe as revalidateWhen,
|
|
2732
|
+
Ke as runOutsideEffect,
|
|
2733
|
+
He as safeCallback,
|
|
2734
|
+
ze as safeDebouncedCallback,
|
|
2735
|
+
Je as syncFields,
|
|
2736
|
+
Ye as transformValue,
|
|
2737
|
+
Ge as unmarkDerived,
|
|
2738
|
+
xe as useArrayLength,
|
|
2739
2739
|
Me as useFormControl,
|
|
2740
|
-
|
|
2740
|
+
Ce as useFormControlValue,
|
|
2741
2741
|
Pe as useFormValidation,
|
|
2742
|
-
|
|
2742
|
+
Qe as watchField
|
|
2743
2743
|
};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { FormModel, PathAwareSignal } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Узел дерева `model.$` — контейнер (группа/массив), а не лист?
|
|
4
|
+
*
|
|
5
|
+
* Контейнерный узел структурно совместим с `ReadonlySignal` (`peek`/`value`/`subscribe`), поэтому
|
|
6
|
+
* duck-typing «есть `peek` ⇒ это лист» на нём даёт ложное срабатывание. Этот guard — надёжный
|
|
7
|
+
* способ различить: обходчикам дерева нужно спускаться в контейнер, а не читать его целиком.
|
|
8
|
+
*
|
|
9
|
+
* @group Model
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const isLeaf = (v: unknown) => isSignalLike(v) && !isModelContainerSignal(v);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function isModelContainerSignal(value: unknown): boolean;
|
|
2
16
|
/**
|
|
3
17
|
* Обойти ВСЕ листовые сигналы модели (включая элементы массивов), вызвав `visit` на каждом.
|
|
4
18
|
*
|
package/dist/state/index.d.ts
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
* @module state
|
|
24
24
|
*/
|
|
25
25
|
export { createModel } from './form-model';
|
|
26
|
-
export type { FormModel, ModelArray, ModelObject, ModelValue, ModelSignals, ModelApi, PathAwareSignal, } from './types';
|
|
26
|
+
export type { FormModel, ModelArray, ModelArraySignals, ModelGroupSignals, ModelObject, ModelValue, ModelSignals, ModelApi, PathAwareSignal, } from './types';
|
|
27
|
+
export { isModelContainerSignal } from './form-model';
|
|
27
28
|
export { computeFrom, copyFrom, watchField, transformValue, resetWhen, syncFields, revalidateWhen, } from './behaviors-value';
|
|
28
29
|
export type { BehaviorCleanup } from './behaviors-value';
|
|
29
30
|
export { markDerived, isDerived, unmarkDerived } from './derived-registry';
|