@reformer/core 11.0.0-beta.7 → 11.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/behaviors.js +211 -174
- package/dist/create-model-BBRHhHwK.js +30 -0
- package/dist/form/behaviors/collections.d.ts +14 -1
- package/dist/form/behaviors/context.d.ts +18 -2
- package/dist/form/behaviors/index.d.ts +3 -1
- package/dist/form/behaviors/internals.d.ts +0 -1
- package/dist/form/behaviors/schema-operators.d.ts +76 -0
- package/dist/form/behaviors/types.d.ts +15 -3
- package/dist/form/create-core-form.d.ts +5 -3
- package/dist/form/create-form.d.ts +28 -53
- package/dist/form/form-bundle.d.ts +136 -0
- package/dist/form/index.d.ts +6 -1
- package/dist/form/nodes/field-node.d.ts +2 -2
- package/dist/form/nodes/group-node.d.ts +1 -1
- package/dist/form/nodes/model-array-node.d.ts +10 -5
- package/dist/form/schema-controller.d.ts +137 -0
- package/dist/form/schema-subtree.d.ts +28 -0
- package/dist/form/signal-node-registry.d.ts +22 -16
- package/dist/form/types/deep-schema.d.ts +2 -2
- package/dist/form/types/form-proxy.d.ts +1 -1
- package/dist/form/types/schema-node.d.ts +37 -12
- package/dist/form/validation/context.d.ts +6 -1
- package/dist/form/validation/index.d.ts +1 -1
- package/dist/form/validation/operators.d.ts +70 -8
- package/dist/form/validation/types.d.ts +2 -1
- package/dist/index.js +345 -254
- package/dist/model/index.d.ts +5 -0
- package/dist/model/model-nodes.d.ts +67 -4
- package/dist/model/model-signals-proxy.d.ts +8 -1
- package/dist/model/model-value-proxy.d.ts +76 -0
- package/dist/model/types.d.ts +7 -4
- package/dist/model-value-proxy-caTmAiUd.js +419 -0
- package/dist/model.js +19 -17
- package/dist/node-BeV_lV5i.js +100 -0
- package/dist/platforms/react/form-bundle-context.d.ts +27 -0
- package/dist/platforms/react/index.d.ts +1 -0
- package/dist/strategy-DgzELWno.js +204 -0
- package/dist/validation.js +7 -6
- package/docs/llms/03-api-signatures.md +4 -4
- package/docs/llms/09-formschema.md +5 -5
- package/docs/llms/10-arrays.md +23 -4
- package/docs/llms/16-ui-components.md +2 -2
- package/docs/llms/18-conditional-fields.md +1 -1
- package/docs/llms/21-array-operations.md +26 -0
- package/docs/llms/28-submit-and-reset.md +3 -3
- package/docs/llms/29-async-preload.md +4 -4
- package/docs/llms/33-validation-strategy.md +2 -2
- package/docs/llms/35-unified-contract.md +246 -0
- package/llms-index.json +1 -1
- package/llms.txt +1148 -122
- package/package.json +1 -1
- package/dist/create-model-B8U-COv-.js +0 -103
- package/dist/model-signals-proxy-2vqS243J.js +0 -250
- package/dist/node-DGEFMTQu.js +0 -18
- package/dist/strategy-BXS_gBfz.js +0 -170
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ npm install @reformer/core@beta # Active development is underway, so you can try
|
|
|
31
31
|
## Quick Start
|
|
32
32
|
|
|
33
33
|
ReFormer is built around the **M1 architecture**: a reactive `FormModel` owns the values, a layout
|
|
34
|
-
schema binds field config (component / props) to the model's signals, and `
|
|
34
|
+
schema binds field config (component / props) to the model's signals, and `createFormFromModel({ model, schema })`
|
|
35
35
|
wires them into a typed form. Validation is a **separate** ambient contract — `defineValidationSchema`,
|
|
36
36
|
run on demand by `validateModel(model, schema)` — so the layout schema carries no validators.
|
|
37
37
|
|
|
@@ -39,7 +39,8 @@ run on demand by `validateModel(model, schema)` — so the layout schema carries
|
|
|
39
39
|
import { useMemo } from 'react';
|
|
40
40
|
import {
|
|
41
41
|
createModel,
|
|
42
|
-
|
|
42
|
+
createFormFromModel,
|
|
43
|
+
createLegacyForm,
|
|
43
44
|
useFormControl,
|
|
44
45
|
type FieldNode,
|
|
45
46
|
type ValidationError,
|
|
@@ -121,7 +122,10 @@ const behavior = defineFormBehavior<RegistrationForm>(({ model, form }) => {
|
|
|
121
122
|
|
|
122
123
|
// 6. Registration form component
|
|
123
124
|
function RegistrationFormExample() {
|
|
124
|
-
const form = useMemo(
|
|
125
|
+
const form = useMemo(
|
|
126
|
+
() => createFormFromModel<RegistrationForm>({ model, schema, behavior }),
|
|
127
|
+
[]
|
|
128
|
+
);
|
|
125
129
|
|
|
126
130
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
127
131
|
e.preventDefault();
|
package/dist/behaviors.js
CHANGED
|
@@ -1,60 +1,72 @@
|
|
|
1
|
-
import { effect as
|
|
2
|
-
import { d as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { effect as H } from "@preact/signals-core";
|
|
2
|
+
import { d as $, a as P, w as M, t as B, r as T, s as L, b as N } from "./behaviors-value-C7dSEhCc.js";
|
|
3
|
+
import { c as U, e as q } from "./node-BeV_lV5i.js";
|
|
4
|
+
import { j as z, i as J, c as E, u as S, h as b, m as _, g as K } from "./model-value-proxy-caTmAiUd.js";
|
|
5
|
+
import { g as v } from "./signal-node-registry-tiwel-TV.js";
|
|
6
|
+
let m = null;
|
|
7
|
+
function k(e) {
|
|
8
|
+
if (!m)
|
|
8
9
|
throw new Error(
|
|
9
10
|
`[@reformer/core/behaviors] "${e}" вызван вне defineFormBehavior(...) — операторы поведения можно вызывать только внутри схемы.`
|
|
10
11
|
);
|
|
11
|
-
return
|
|
12
|
+
return m;
|
|
12
13
|
}
|
|
13
14
|
function a(e) {
|
|
14
|
-
|
|
15
|
+
k("onDispose").cleanups.push(e);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
function g(e) {
|
|
18
|
+
m?.cleanups.push(e);
|
|
19
|
+
}
|
|
20
|
+
function ie() {
|
|
21
|
+
const e = k("getScope");
|
|
22
|
+
return x(e);
|
|
19
23
|
}
|
|
20
|
-
function
|
|
24
|
+
function F(e = "getController") {
|
|
25
|
+
return k(e).controller;
|
|
26
|
+
}
|
|
27
|
+
const x = (e) => ({
|
|
28
|
+
model: e.model,
|
|
29
|
+
form: e.form,
|
|
30
|
+
schema: e.controller.scopeOf(e.model)
|
|
31
|
+
});
|
|
32
|
+
function Q(e) {
|
|
21
33
|
return {
|
|
22
|
-
__run(t, n) {
|
|
23
|
-
const
|
|
24
|
-
|
|
34
|
+
__run(t, n, o = U()) {
|
|
35
|
+
const r = { cleanups: [], model: t, form: n, controller: o }, c = m;
|
|
36
|
+
m = r;
|
|
25
37
|
try {
|
|
26
|
-
e(
|
|
38
|
+
e(x(r));
|
|
27
39
|
} finally {
|
|
28
|
-
|
|
40
|
+
m = c;
|
|
29
41
|
}
|
|
30
42
|
return () => {
|
|
31
|
-
for (const
|
|
43
|
+
for (const s of r.cleanups) s();
|
|
32
44
|
};
|
|
33
45
|
}
|
|
34
46
|
};
|
|
35
47
|
}
|
|
36
|
-
function
|
|
37
|
-
a(
|
|
48
|
+
function p(e) {
|
|
49
|
+
a(H(e));
|
|
38
50
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
51
|
+
function O(e) {
|
|
52
|
+
$(e);
|
|
41
53
|
}
|
|
42
|
-
const
|
|
43
|
-
function
|
|
54
|
+
const C = (e) => typeof e == "object" && e !== null && typeof e.peek == "function" && !J(e), y = (e) => C(e) || z(e), W = (e) => Array.isArray(e) ? e : [e];
|
|
55
|
+
function j(e) {
|
|
44
56
|
const t = {};
|
|
45
57
|
for (const n of Object.keys(e)) {
|
|
46
58
|
const o = e[n];
|
|
47
|
-
t[n] =
|
|
59
|
+
t[n] = y(o) ? o.value : j(o);
|
|
48
60
|
}
|
|
49
61
|
return t;
|
|
50
62
|
}
|
|
51
|
-
function
|
|
63
|
+
function A(e, t) {
|
|
52
64
|
for (const n of Object.keys(e)) {
|
|
53
65
|
const o = e[n];
|
|
54
|
-
|
|
66
|
+
y(o) ? o.value = t?.[n] : A(o, t?.[n] ?? {});
|
|
55
67
|
}
|
|
56
68
|
}
|
|
57
|
-
function
|
|
69
|
+
function D(e) {
|
|
58
70
|
return (t) => {
|
|
59
71
|
try {
|
|
60
72
|
t();
|
|
@@ -69,18 +81,10 @@ function W(e) {
|
|
|
69
81
|
}
|
|
70
82
|
};
|
|
71
83
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (!e) return;
|
|
77
|
-
const { form: t } = p();
|
|
78
|
-
return t.getFieldByPath(e);
|
|
79
|
-
}
|
|
80
|
-
function Z(e, t, n) {
|
|
81
|
-
x(e), a(() => P(e));
|
|
82
|
-
const o = W(e);
|
|
83
|
-
m(() => {
|
|
84
|
+
function ae(e, t, n) {
|
|
85
|
+
E(e), a(() => S(e));
|
|
86
|
+
const o = D(e);
|
|
87
|
+
p(() => {
|
|
84
88
|
if (n?.when && !n.when()) return;
|
|
85
89
|
const r = t();
|
|
86
90
|
e.peek() !== r && o(() => {
|
|
@@ -88,96 +92,83 @@ function Z(e, t, n) {
|
|
|
88
92
|
});
|
|
89
93
|
});
|
|
90
94
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
const r =
|
|
94
|
-
|
|
95
|
-
const c = e.map((
|
|
95
|
+
function fe(e, t, n, o) {
|
|
96
|
+
E(t), a(() => S(t));
|
|
97
|
+
const r = D(t);
|
|
98
|
+
p(() => {
|
|
99
|
+
const c = e.map((i) => i.value);
|
|
96
100
|
if (o?.when && !o.when(...c)) return;
|
|
97
|
-
const
|
|
98
|
-
t.peek() !==
|
|
99
|
-
t.value =
|
|
101
|
+
const s = n(...c);
|
|
102
|
+
t.peek() !== s && r(() => {
|
|
103
|
+
t.value = s;
|
|
100
104
|
});
|
|
101
105
|
});
|
|
102
106
|
}
|
|
103
|
-
function
|
|
104
|
-
if (
|
|
105
|
-
a(
|
|
107
|
+
function le(e, t, n) {
|
|
108
|
+
if (y(e) && y(t)) {
|
|
109
|
+
a(P(e, t, n));
|
|
106
110
|
return;
|
|
107
111
|
}
|
|
108
112
|
const o = e, r = t;
|
|
109
|
-
|
|
110
|
-
const c =
|
|
111
|
-
n?.when && !n.when() ||
|
|
113
|
+
p(() => {
|
|
114
|
+
const c = j(o);
|
|
115
|
+
n?.when && !n.when() || O(() => A(r, c));
|
|
112
116
|
});
|
|
113
117
|
}
|
|
114
|
-
function
|
|
118
|
+
function X(e, t, n) {
|
|
115
119
|
let o;
|
|
116
120
|
const r = (c) => {
|
|
117
121
|
o?.abort(), o = new AbortController();
|
|
118
|
-
const { signal:
|
|
119
|
-
|
|
122
|
+
const { signal: s } = o;
|
|
123
|
+
$(() => t(c, { signal: s }));
|
|
120
124
|
};
|
|
121
125
|
if (!n?.debounce)
|
|
122
|
-
a(
|
|
126
|
+
a(M(e, r, { immediate: n?.immediate }));
|
|
123
127
|
else {
|
|
124
128
|
let c;
|
|
125
|
-
const
|
|
129
|
+
const s = M(
|
|
126
130
|
e,
|
|
127
|
-
(
|
|
128
|
-
c && clearTimeout(c), c = setTimeout(() => r(
|
|
131
|
+
(i) => {
|
|
132
|
+
c && clearTimeout(c), c = setTimeout(() => r(i), n.debounce);
|
|
129
133
|
},
|
|
130
134
|
{ immediate: n?.immediate }
|
|
131
135
|
);
|
|
132
136
|
a(() => {
|
|
133
|
-
c && clearTimeout(c),
|
|
137
|
+
c && clearTimeout(c), s();
|
|
134
138
|
});
|
|
135
139
|
}
|
|
136
140
|
a(() => o?.abort());
|
|
137
141
|
}
|
|
138
|
-
function
|
|
139
|
-
for (const o of
|
|
140
|
-
|
|
142
|
+
function Y(e, t, n) {
|
|
143
|
+
for (const o of W(e))
|
|
144
|
+
C(o) ? a(q(o, t, n)) : Z(o, t, n);
|
|
141
145
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
146
|
+
function ue(e, t, n) {
|
|
147
|
+
Y(e, () => !t(), n);
|
|
144
148
|
}
|
|
145
|
-
function
|
|
146
|
-
const o =
|
|
147
|
-
o &&
|
|
149
|
+
function Z(e, t, n) {
|
|
150
|
+
const o = v(e);
|
|
151
|
+
o && p(() => {
|
|
148
152
|
const r = t();
|
|
149
|
-
|
|
153
|
+
O(() => {
|
|
150
154
|
r ? o.enable() : (o.disable(), n?.resetOnDisable && o.reset());
|
|
151
155
|
});
|
|
152
156
|
});
|
|
153
157
|
}
|
|
154
|
-
function
|
|
155
|
-
a(
|
|
158
|
+
function de(e, t) {
|
|
159
|
+
a(B(e, t));
|
|
156
160
|
}
|
|
157
|
-
function
|
|
158
|
-
a(
|
|
161
|
+
function me(e, t, n) {
|
|
162
|
+
a(T(e, t, n));
|
|
159
163
|
}
|
|
160
|
-
function
|
|
161
|
-
a(
|
|
164
|
+
function pe(e, t, n) {
|
|
165
|
+
a(L(e, t, n));
|
|
162
166
|
}
|
|
163
|
-
function
|
|
164
|
-
a(
|
|
165
|
-
}
|
|
166
|
-
function M(e) {
|
|
167
|
-
return new Proxy(
|
|
168
|
-
{},
|
|
169
|
-
{
|
|
170
|
-
get: (t, n) => {
|
|
171
|
-
if (n === "$") return e;
|
|
172
|
-
if (typeof n != "string") return;
|
|
173
|
-
const o = e[n];
|
|
174
|
-
if (o != null)
|
|
175
|
-
return _(o) ? o.value : M(o);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
);
|
|
167
|
+
function he(e, t) {
|
|
168
|
+
a(N(e, t));
|
|
179
169
|
}
|
|
180
|
-
|
|
170
|
+
const I = (e) => e.__path ?? "?", R = (e) => void F(e);
|
|
171
|
+
function ee(e) {
|
|
181
172
|
return new Proxy(
|
|
182
173
|
{},
|
|
183
174
|
{
|
|
@@ -192,111 +183,157 @@ function J(e) {
|
|
|
192
183
|
}
|
|
193
184
|
);
|
|
194
185
|
}
|
|
195
|
-
function
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
198
|
-
const c =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const l = c.at(u);
|
|
207
|
-
if (l != null && (y.add(l), !f.has(l))) {
|
|
208
|
-
const w = i?.at?.(u) ?? J(r);
|
|
209
|
-
f.set(l, t.__run(l, w));
|
|
186
|
+
function te(e, t) {
|
|
187
|
+
const n = F("applyEach"), o = b(e);
|
|
188
|
+
if (!o) return;
|
|
189
|
+
const r = _(o), c = v(o), s = typeof c?.at == "function" ? c : void 0, i = s?.length, f = /* @__PURE__ */ new Map();
|
|
190
|
+
p(() => {
|
|
191
|
+
const h = i ? i.value : r.length, d = /* @__PURE__ */ new Set();
|
|
192
|
+
for (let l = 0; l < h; l++) {
|
|
193
|
+
const u = r.at(l);
|
|
194
|
+
if (u != null && (d.add(u), !f.has(u))) {
|
|
195
|
+
const G = s?.at?.(l) ?? ee(I(o));
|
|
196
|
+
f.set(u, t.__run(u, G, n));
|
|
210
197
|
}
|
|
211
198
|
}
|
|
212
|
-
for (const [
|
|
213
|
-
|
|
199
|
+
for (const [l, u] of f)
|
|
200
|
+
d.has(l) || (u(), f.delete(l));
|
|
214
201
|
}), a(() => {
|
|
215
|
-
for (const
|
|
202
|
+
for (const h of f.values()) h();
|
|
216
203
|
f.clear();
|
|
217
204
|
});
|
|
218
205
|
}
|
|
219
|
-
function
|
|
206
|
+
function w(e) {
|
|
220
207
|
if (e == null || typeof e != "object") return;
|
|
221
208
|
const t = e;
|
|
222
209
|
if (typeof t.at == "function" && typeof t.length == "number") {
|
|
223
210
|
const n = t.length;
|
|
224
|
-
for (let o = 0; o < n; o++)
|
|
211
|
+
for (let o = 0; o < n; o++) w(t.at(o));
|
|
225
212
|
return;
|
|
226
213
|
}
|
|
227
|
-
for (const n of Object.keys(e))
|
|
214
|
+
for (const n of Object.keys(e)) w(e[n]);
|
|
228
215
|
}
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
216
|
+
function ye(e, t) {
|
|
217
|
+
R("exclusiveFlag");
|
|
218
|
+
const n = b(e);
|
|
219
|
+
if (!n) return;
|
|
220
|
+
const o = _(n);
|
|
221
|
+
te(
|
|
222
|
+
n,
|
|
223
|
+
Q(({ model: r }) => {
|
|
224
|
+
X(t(r), (c) => {
|
|
225
|
+
if (c)
|
|
226
|
+
for (let s = 0; s < o.length; s++) {
|
|
227
|
+
const i = o.at(s);
|
|
228
|
+
if (i && i !== r) {
|
|
229
|
+
const f = t(i);
|
|
230
|
+
f.peek() && (f.value = !1);
|
|
243
231
|
}
|
|
244
232
|
}
|
|
245
233
|
});
|
|
246
234
|
})
|
|
247
235
|
);
|
|
248
236
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
let
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const s = t(
|
|
259
|
-
let
|
|
260
|
-
for (const { index:
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
263
|
-
for (const [l,
|
|
264
|
-
|
|
237
|
+
function _e(e, t) {
|
|
238
|
+
R("aggregateInto");
|
|
239
|
+
const n = b(e);
|
|
240
|
+
if (!n) return;
|
|
241
|
+
const o = _(n);
|
|
242
|
+
let r = !1, c = 0;
|
|
243
|
+
p(() => {
|
|
244
|
+
w(o), !r && (r = !0, O(() => {
|
|
245
|
+
r = !1;
|
|
246
|
+
const s = t(o.toArray());
|
|
247
|
+
let i = !1;
|
|
248
|
+
for (const { index: f, patch: h } of s) {
|
|
249
|
+
const d = o.at(f);
|
|
250
|
+
if (d)
|
|
251
|
+
for (const [l, u] of Object.entries(h))
|
|
252
|
+
d[l] !== u && (d[l] = u, i = !0);
|
|
265
253
|
}
|
|
266
|
-
if (
|
|
267
|
-
throw
|
|
268
|
-
`[@reformer/core/behaviors] aggregateInto("${
|
|
254
|
+
if (c = i ? c + 1 : 0, c > 50)
|
|
255
|
+
throw c = 0, new Error(
|
|
256
|
+
`[@reformer/core/behaviors] aggregateInto("${I(n)}"): запись не сходится (>50 проходов) — derive должна быть идемпотентной на фикспоинте.`
|
|
269
257
|
);
|
|
270
258
|
}));
|
|
271
259
|
});
|
|
272
260
|
}
|
|
273
|
-
function
|
|
274
|
-
const
|
|
275
|
-
for (const o of
|
|
276
|
-
const r = o
|
|
277
|
-
if (!
|
|
278
|
-
const
|
|
279
|
-
a(t.__run(
|
|
261
|
+
function ge(e, t) {
|
|
262
|
+
const n = F("apply");
|
|
263
|
+
for (const o of W(e)) {
|
|
264
|
+
const r = K(o);
|
|
265
|
+
if (!r) continue;
|
|
266
|
+
const c = _(r), s = v(r), i = s ? s.getProxy?.() ?? s : void 0;
|
|
267
|
+
a(t.__run(c, i, n));
|
|
280
268
|
}
|
|
281
269
|
}
|
|
270
|
+
function we(e, t) {
|
|
271
|
+
const { conditionRegistry: n } = e.__overrideMaps;
|
|
272
|
+
n.set(e.__selector, t), g(() => {
|
|
273
|
+
n.get(e.__selector) === t && n.delete(e.__selector);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function be(e, t, n) {
|
|
277
|
+
const { callbackRegistry: o } = e.__overrideMaps;
|
|
278
|
+
let r = o.get(e.__selector);
|
|
279
|
+
r || (r = /* @__PURE__ */ new Map(), o.set(e.__selector, r)), r.set(t, n);
|
|
280
|
+
const c = r;
|
|
281
|
+
g(() => {
|
|
282
|
+
c.get(t) === n && c.delete(t);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function ve(e, t) {
|
|
286
|
+
const { effectRegistry: n } = e.__overrideMaps;
|
|
287
|
+
n.push(t), g(() => {
|
|
288
|
+
const o = n.indexOf(t);
|
|
289
|
+
o !== -1 && n.splice(o, 1);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function V(e, t, n) {
|
|
293
|
+
const { lifecycleRegistry: o } = e.__overrideMaps;
|
|
294
|
+
o.set(e.__selector, {
|
|
295
|
+
...o.get(e.__selector) ?? {},
|
|
296
|
+
[t]: n
|
|
297
|
+
}), g(() => {
|
|
298
|
+
const r = o.get(e.__selector);
|
|
299
|
+
if (r?.[t] !== n) return;
|
|
300
|
+
const c = { ...r };
|
|
301
|
+
delete c[t], Object.keys(c).length === 0 ? o.delete(e.__selector) : o.set(e.__selector, c);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function ke(e, t) {
|
|
305
|
+
t();
|
|
306
|
+
}
|
|
307
|
+
function Fe(e, t) {
|
|
308
|
+
V(e, "onMount", t);
|
|
309
|
+
}
|
|
310
|
+
function Oe(e, t) {
|
|
311
|
+
V(e, "onUnmount", t);
|
|
312
|
+
}
|
|
282
313
|
export {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
314
|
+
_e as aggregateInto,
|
|
315
|
+
ge as apply,
|
|
316
|
+
te as applyEach,
|
|
317
|
+
ae as compute,
|
|
318
|
+
fe as computeFrom,
|
|
319
|
+
le as copyFrom,
|
|
320
|
+
O as defer,
|
|
321
|
+
Q as defineFormBehavior,
|
|
322
|
+
ue as disableWhen,
|
|
323
|
+
p as effect,
|
|
324
|
+
Y as enableWhen,
|
|
325
|
+
ye as exclusiveFlag,
|
|
326
|
+
ie as getScope,
|
|
327
|
+
we as hideWhen,
|
|
328
|
+
X as onChange,
|
|
329
|
+
be as onComponentEvent,
|
|
297
330
|
a as onDispose,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
331
|
+
ke as onInit,
|
|
332
|
+
Fe as onMount,
|
|
333
|
+
Oe as onUnmount,
|
|
334
|
+
ve as renderEffect,
|
|
335
|
+
me as resetWhen,
|
|
336
|
+
he as revalidateWhen,
|
|
337
|
+
pe as syncFields,
|
|
338
|
+
de as transformValue
|
|
302
339
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { G as f, e as c, r as t, s } from "./model-value-proxy-caTmAiUd.js";
|
|
2
|
+
function n(o, e, a) {
|
|
3
|
+
if (o.kind === "leaf") {
|
|
4
|
+
e(o.signal);
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (o.kind === "group") {
|
|
8
|
+
for (const r of o.children.values()) n(r, e, a);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
a && e(s(o));
|
|
12
|
+
for (const r of o.items.value) n(r, e, a);
|
|
13
|
+
}
|
|
14
|
+
function u(o, e) {
|
|
15
|
+
const a = t.get(o);
|
|
16
|
+
a && n(a, e, !1);
|
|
17
|
+
}
|
|
18
|
+
function i(o, e) {
|
|
19
|
+
const a = t.get(o);
|
|
20
|
+
a && n(a, e, !0);
|
|
21
|
+
}
|
|
22
|
+
function g(o) {
|
|
23
|
+
const e = new f(o, "");
|
|
24
|
+
return c(e);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
i as a,
|
|
28
|
+
g as c,
|
|
29
|
+
u as e
|
|
30
|
+
};
|
|
@@ -12,10 +12,14 @@ import { FormBehavior } from './types';
|
|
|
12
12
|
* рендерится, а её сигналы зарегистрированы (`enableWhen` резолвит ноду). Без материализации доступ
|
|
13
13
|
* к `form.*` бросит понятную ошибку (см. {@link unmaterializedRowForm}).
|
|
14
14
|
*
|
|
15
|
+
* Работает на любой глубине: массив в корне, в группе и в строке другого массива — в схеме строки
|
|
16
|
+
* можно снова вызвать `applyEach`.
|
|
17
|
+
*
|
|
15
18
|
* @example
|
|
16
19
|
* applyEach(model.$.items, defineFormBehavior<Item>(({ model: row, form }) => {
|
|
17
20
|
* compute(row.$.lineTotal, () => row.qty * row.price); // value-op — всегда
|
|
18
21
|
* enableWhen(row.$.discount, () => row.qty > 10); // node-op — нужна материализация массива
|
|
22
|
+
* applyEach(row.$.phones, phoneBehavior); // массив внутри строки
|
|
19
23
|
* }));
|
|
20
24
|
*/
|
|
21
25
|
export declare function applyEach<TItem>(array: object, itemSchema: FormBehavior<TItem>): void;
|
|
@@ -46,5 +50,14 @@ export declare function aggregateInto<TItem>(array: object, derive: (rows: TItem
|
|
|
46
50
|
index: number;
|
|
47
51
|
patch: Partial<TItem>;
|
|
48
52
|
}>): void;
|
|
49
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Применить под-схему к одному или нескольким полям-группам (переиспользование).
|
|
55
|
+
*
|
|
56
|
+
* Под-схема получает scope группы: `model` — настоящая под-модель (`model.$.field`, чтение и
|
|
57
|
+
* запись значений, `get`/`set`/`patch`), `form` — нода группы. Цель — ручка группы
|
|
58
|
+
* (`model.$.address`); работает и в корневой схеме, и в схеме строки массива.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* apply([model.$.registrationAddress, model.$.residenceAddress], addressBehavior);
|
|
62
|
+
*/
|
|
50
63
|
export declare function apply<TField>(targets: object | object[], subSchema: FormBehavior<TField>): void;
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import { BehaviorCleanup } from '../../index';
|
|
2
|
+
import { SchemaController } from '../schema-controller';
|
|
2
3
|
import { BehaviorScope, FormBehavior } from './types';
|
|
3
4
|
/** Зарегистрировать произвольную отписку в активной схеме. */
|
|
4
5
|
export declare function onDispose(cleanup: BehaviorCleanup): void;
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Зарегистрировать отписку, если оператор вызван внутри схемы поведения; вне схемы — ничего.
|
|
8
|
+
* Для операторов, которые работают и сами по себе (правила узлов схемы).
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function onDisposeIfActive(cleanup: BehaviorCleanup): void;
|
|
13
|
+
/** Текущая область ({ model, form, schema }) активной схемы (escape hatch для кросс-операторов). */
|
|
6
14
|
export declare function getScope<T>(): BehaviorScope<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Схема-контроллер сборки, в которой идёт активная схема: под-схемы (`apply`, `applyEach`)
|
|
17
|
+
* получают через него область своей под-модели.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function getController(op?: string): SchemaController;
|
|
7
22
|
/**
|
|
8
23
|
* Описать поведение формы декларативно. Возвращает {@link FormBehavior} для `createForm({ behavior })`.
|
|
9
24
|
*
|
|
10
25
|
* @example
|
|
11
26
|
* ```ts
|
|
12
|
-
* export const myBehavior = defineFormBehavior<MyForm>(({ model, form }) => {
|
|
27
|
+
* export const myBehavior = defineFormBehavior<MyForm>(({ model, form, schema }) => {
|
|
13
28
|
* compute(model.$.total, () => model.price * model.qty);
|
|
14
29
|
* enableWhen([model.$.city], () => Boolean(model.country));
|
|
15
30
|
* onChange(model.$.country, async (c) => form.city.updateComponentProps({ options: await load(c) }));
|
|
31
|
+
* hideWhen(schema.node('delivery'), () => model.country === '');
|
|
16
32
|
* });
|
|
17
33
|
* ```
|
|
18
34
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Декларативный контракт схемы поведения формы — `@reformer/core/behaviors`.
|
|
3
3
|
*
|
|
4
4
|
* Свободные операторы (`compute`/`copyFrom`/`enableWhen`/`onChange`/…) вызываются внутри
|
|
5
|
-
* `defineFormBehavior(({ model, form }) => { … })` и САМИ регистрируют свои отписки в ambient-стоке —
|
|
5
|
+
* `defineFormBehavior(({ model, form, schema }) => { … })` и САМИ регистрируют свои отписки в ambient-стоке —
|
|
6
6
|
* автор схемы не видит ни массива `cleanups`, ни `.push`, ни вызовов через точку. Жизненным циклом
|
|
7
7
|
* владеет форма (`createForm({ behavior })`). Операторы — тонкие обёртки над примитивами слоя данных
|
|
8
8
|
* ({@link module:model/behaviors-value}); пользовательские операторы пишутся так же и неотличимы от встроенных.
|
|
@@ -26,3 +26,5 @@ export type { Signal, ReadonlySignal, BehaviorCleanup } from './types';
|
|
|
26
26
|
export { onDispose, getScope, defineFormBehavior, effect, defer } from './context';
|
|
27
27
|
export { compute, computeFrom, copyFrom, onChange, enableWhen, disableWhen, transformValue, resetWhen, syncFields, revalidateWhen, } from './operators';
|
|
28
28
|
export { applyEach, exclusiveFlag, aggregateInto, apply } from './collections';
|
|
29
|
+
export { hideWhen, onComponentEvent, renderEffect, onInit, onMount, onUnmount, } from './schema-operators';
|
|
30
|
+
export type { SchemaScope, SchemaNodeControl } from '../schema-controller';
|
|
@@ -32,4 +32,3 @@ export declare function writeGroup(g: GroupSignals, val: Record<string, unknown>
|
|
|
32
32
|
* синхронные мутации цикла не порождают → не затрагиваются.
|
|
33
33
|
*/
|
|
34
34
|
export declare function makeCycleGuard(target: Signal<unknown>): (write: () => void) => void;
|
|
35
|
-
export declare function getByPath(root: unknown, path: string): any;
|