@reformer/core 11.0.0-beta.6 → 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.
Files changed (113) hide show
  1. package/README.md +7 -3
  2. package/dist/behaviors.js +216 -179
  3. package/dist/create-model-BBRHhHwK.js +30 -0
  4. package/dist/en-CjAqn7h0.js +41 -0
  5. package/dist/form/behaviors/collections.d.ts +14 -1
  6. package/dist/form/behaviors/context.d.ts +18 -2
  7. package/dist/form/behaviors/index.d.ts +3 -1
  8. package/dist/form/behaviors/internals.d.ts +9 -1
  9. package/dist/form/behaviors/schema-operators.d.ts +76 -0
  10. package/dist/form/behaviors/types.d.ts +15 -3
  11. package/dist/form/create-core-form.d.ts +5 -3
  12. package/dist/form/create-form.d.ts +28 -53
  13. package/dist/form/form-bundle.d.ts +136 -0
  14. package/dist/form/index.d.ts +6 -1
  15. package/dist/form/nodes/field-node.d.ts +2 -2
  16. package/dist/form/nodes/group-node.d.ts +1 -1
  17. package/dist/form/nodes/model-array-node.d.ts +10 -5
  18. package/dist/form/schema-controller.d.ts +137 -0
  19. package/dist/form/schema-subtree.d.ts +28 -0
  20. package/dist/form/signal-node-registry.d.ts +22 -16
  21. package/dist/form/types/contracts.d.ts +6 -0
  22. package/dist/form/types/deep-schema.d.ts +2 -2
  23. package/dist/form/types/form-proxy.d.ts +1 -1
  24. package/dist/form/types/schema-node.d.ts +37 -12
  25. package/dist/form/types/validation-schema.d.ts +13 -1
  26. package/dist/form/validation/context.d.ts +6 -1
  27. package/dist/form/validation/index.d.ts +1 -1
  28. package/dist/form/validation/operators.d.ts +74 -7
  29. package/dist/form/validation/types.d.ts +2 -1
  30. package/dist/form/validators/validation-error.d.ts +8 -0
  31. package/dist/i18n/descriptor.d.ts +54 -0
  32. package/dist/i18n/en.json.d.ts +45 -0
  33. package/dist/i18n/loader.d.ts +71 -0
  34. package/dist/i18n/locale-store.d.ts +39 -0
  35. package/dist/i18n/locale.d.ts +90 -0
  36. package/dist/i18n/message-format.d.ts +116 -0
  37. package/dist/i18n/resolve-localized.d.ts +17 -0
  38. package/dist/i18n/ru.json.d.ts +45 -0
  39. package/dist/i18n/translator.d.ts +50 -0
  40. package/dist/i18n/validation-message.d.ts +18 -0
  41. package/dist/i18n.d.ts +31 -0
  42. package/dist/i18n.js +303 -0
  43. package/dist/index-BrNkQj1y.js +105 -0
  44. package/dist/index.js +737 -743
  45. package/dist/loader-Dv_Hl7JC.js +216 -0
  46. package/dist/locale/en.d.ts +2 -0
  47. package/dist/locale/en.js +5 -0
  48. package/dist/locale/en.json +42 -0
  49. package/dist/locale/index.d.ts +18 -0
  50. package/dist/locale/ru.d.ts +2 -0
  51. package/dist/locale/ru.js +41 -0
  52. package/dist/locale/ru.json +42 -0
  53. package/dist/locale.d.ts +2 -0
  54. package/dist/locale.js +9 -0
  55. package/dist/model/create-model.d.ts +17 -3
  56. package/dist/model/index.d.ts +8 -3
  57. package/dist/model/model-nodes.d.ts +67 -4
  58. package/dist/model/model-signals-proxy.d.ts +33 -1
  59. package/dist/model/model-value-proxy.d.ts +76 -0
  60. package/dist/model/types.d.ts +26 -9
  61. package/dist/model-value-proxy-caTmAiUd.js +419 -0
  62. package/dist/model.js +21 -17
  63. package/dist/node-BeV_lV5i.js +100 -0
  64. package/dist/platforms/react/form-bundle-context.d.ts +27 -0
  65. package/dist/platforms/react/hooks/types.d.ts +6 -3
  66. package/dist/platforms/react/hooks/useFormControlValue.d.ts +2 -1
  67. package/dist/platforms/react/i18n/context.d.ts +13 -0
  68. package/dist/platforms/react/i18n/hooks.d.ts +59 -0
  69. package/dist/platforms/react/i18n/provider.d.ts +52 -0
  70. package/dist/platforms/react/index.d.ts +1 -0
  71. package/dist/strategy-DgzELWno.js +204 -0
  72. package/dist/validation-error-B-U3RsV0.js +11 -0
  73. package/dist/validation.js +7 -6
  74. package/dist/validators/email.js +5 -8
  75. package/dist/validators/future-date.js +8 -11
  76. package/dist/validators/integer.js +4 -7
  77. package/dist/validators/is-date.js +5 -8
  78. package/dist/validators/is-number.js +4 -7
  79. package/dist/validators/max-age.js +8 -11
  80. package/dist/validators/max-date.js +8 -11
  81. package/dist/validators/max-length.js +5 -8
  82. package/dist/validators/max.js +4 -7
  83. package/dist/validators/min-age.js +8 -11
  84. package/dist/validators/min-date.js +8 -11
  85. package/dist/validators/min-length.js +5 -8
  86. package/dist/validators/min.js +4 -7
  87. package/dist/validators/multiple-of.js +5 -8
  88. package/dist/validators/non-negative.js +4 -7
  89. package/dist/validators/non-zero.js +4 -7
  90. package/dist/validators/past-date.js +8 -11
  91. package/dist/validators/pattern.js +5 -8
  92. package/dist/validators/phone.js +6 -9
  93. package/dist/validators/required.js +4 -7
  94. package/dist/validators/url.js +9 -14
  95. package/dist/validators.js +84 -106
  96. package/docs/llms/03-api-signatures.md +10 -4
  97. package/docs/llms/09-formschema.md +5 -5
  98. package/docs/llms/10-arrays.md +52 -3
  99. package/docs/llms/16-ui-components.md +2 -2
  100. package/docs/llms/18-conditional-fields.md +1 -1
  101. package/docs/llms/21-array-operations.md +26 -0
  102. package/docs/llms/28-submit-and-reset.md +3 -3
  103. package/docs/llms/29-async-preload.md +4 -4
  104. package/docs/llms/33-validation-strategy.md +2 -2
  105. package/docs/llms/34-i18n.md +272 -0
  106. package/docs/llms/35-unified-contract.md +246 -0
  107. package/llms-index.json +1 -1
  108. package/llms.txt +2746 -229
  109. package/package.json +22 -3
  110. package/dist/create-model-Dxh9cfLp.js +0 -97
  111. package/dist/model-signals-proxy-mV3WGdlO.js +0 -233
  112. package/dist/node-DGEFMTQu.js +0 -18
  113. package/dist/strategy-DA3JwxsR.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 `createForm({ model, schema })`
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
- createForm,
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(() => createForm<RegistrationForm>({ model, schema, behavior }), []);
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 j } from "@preact/signals-core";
2
- import { d as $, a as C, w as F, t as M, r as O, s as A, b as D } from "./behaviors-value-C7dSEhCc.js";
3
- import { i as G, m as k, u as x } from "./model-signals-proxy-mV3WGdlO.js";
4
- import { e as T } from "./node-DGEFMTQu.js";
5
- let p = null;
6
- function P(e) {
7
- if (!p)
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 p;
12
+ return m;
12
13
  }
13
- function s(e) {
14
- P("onDispose").cleanups.push(e);
14
+ function a(e) {
15
+ k("onDispose").cleanups.push(e);
15
16
  }
16
- function y() {
17
- const e = P("getScope");
18
- return { model: e.model, form: e.form };
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 I(e) {
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 o = { cleanups: [], model: t, form: n }, r = p;
24
- p = o;
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({ model: t, form: n });
38
+ e(x(r));
27
39
  } finally {
28
- p = r;
40
+ m = c;
29
41
  }
30
42
  return () => {
31
- for (const c of o.cleanups) c();
43
+ for (const s of r.cleanups) s();
32
44
  };
33
45
  }
34
46
  };
35
47
  }
36
- function h(e) {
37
- s(j(e));
48
+ function p(e) {
49
+ a(H(e));
38
50
  }
39
- function g(e) {
51
+ function O(e) {
40
52
  $(e);
41
53
  }
42
- const m = (e) => typeof e == "object" && e !== null && typeof e.peek == "function" && !G(e), B = (e) => Array.isArray(e) ? e : [e];
43
- function E(e) {
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] = m(o) ? o.value : E(o);
59
+ t[n] = y(o) ? o.value : j(o);
48
60
  }
49
61
  return t;
50
62
  }
51
- function W(e, t) {
63
+ function A(e, t) {
52
64
  for (const n of Object.keys(e)) {
53
65
  const o = e[n];
54
- m(o) ? o.value = t?.[n] : W(o, t?.[n] ?? {});
66
+ y(o) ? o.value = t?.[n] : A(o, t?.[n] ?? {});
55
67
  }
56
68
  }
57
- function S(e) {
69
+ function D(e) {
58
70
  return (t) => {
59
71
  try {
60
72
  t();
@@ -69,18 +81,10 @@ function S(e) {
69
81
  }
70
82
  };
71
83
  }
72
- function _(e, t) {
73
- return t.split(".").reduce((n, o) => n?.[o], e);
74
- }
75
- function R(e) {
76
- if (!e) return;
77
- const { form: t } = y();
78
- return t.getFieldByPath(e);
79
- }
80
- function X(e, t, n) {
81
- k(e), s(() => x(e));
82
- const o = S(e);
83
- h(() => {
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 X(e, t, n) {
88
92
  });
89
93
  });
90
94
  }
91
- function Y(e, t, n, o) {
92
- k(t), s(() => x(t));
93
- const r = S(t);
94
- h(() => {
95
- const c = e.map((f) => f.value);
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 i = n(...c);
98
- t.peek() !== i && r(() => {
99
- t.value = i;
101
+ const s = n(...c);
102
+ t.peek() !== s && r(() => {
103
+ t.value = s;
100
104
  });
101
105
  });
102
106
  }
103
- function Z(e, t, n) {
104
- if (m(e) && m(t)) {
105
- s(C(e, t, n));
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
- h(() => {
110
- const c = E(o);
111
- n?.when && !n.when() || g(() => W(r, c));
113
+ p(() => {
114
+ const c = j(o);
115
+ n?.when && !n.when() || O(() => A(r, c));
112
116
  });
113
117
  }
114
- function q(e, t, n) {
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: i } = o;
119
- $(() => t(c, { signal: i }));
122
+ const { signal: s } = o;
123
+ $(() => t(c, { signal: s }));
120
124
  };
121
125
  if (!n?.debounce)
122
- s(F(e, r, { immediate: n?.immediate }));
126
+ a(M(e, r, { immediate: n?.immediate }));
123
127
  else {
124
128
  let c;
125
- const i = F(
129
+ const s = M(
126
130
  e,
127
- (f) => {
128
- c && clearTimeout(c), c = setTimeout(() => r(f), n.debounce);
131
+ (i) => {
132
+ c && clearTimeout(c), c = setTimeout(() => r(i), n.debounce);
129
133
  },
130
134
  { immediate: n?.immediate }
131
135
  );
132
- s(() => {
133
- c && clearTimeout(c), i();
136
+ a(() => {
137
+ c && clearTimeout(c), s();
134
138
  });
135
139
  }
136
- s(() => o?.abort());
140
+ a(() => o?.abort());
137
141
  }
138
- function z(e, t, n) {
139
- for (const o of B(e))
140
- m(o) ? s(T(o, t, n)) : L(o, t, n);
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 ee(e, t, n) {
143
- z(e, () => !t(), n);
146
+ function ue(e, t, n) {
147
+ Y(e, () => !t(), n);
144
148
  }
145
- function L(e, t, n) {
146
- const o = R(e.__path);
147
- o && h(() => {
149
+ function Z(e, t, n) {
150
+ const o = v(e);
151
+ o && p(() => {
148
152
  const r = t();
149
- g(() => {
153
+ O(() => {
150
154
  r ? o.enable() : (o.disable(), n?.resetOnDisable && o.reset());
151
155
  });
152
156
  });
153
157
  }
154
- function ne(e, t) {
155
- s(M(e, t));
158
+ function de(e, t) {
159
+ a(B(e, t));
156
160
  }
157
- function te(e, t, n) {
158
- s(O(e, t, n));
161
+ function me(e, t, n) {
162
+ a(T(e, t, n));
159
163
  }
160
- function oe(e, t, n) {
161
- s(A(e, t, n));
164
+ function pe(e, t, n) {
165
+ a(L(e, t, n));
162
166
  }
163
- function re(e, t) {
164
- s(D(e, t));
167
+ function he(e, t) {
168
+ a(N(e, t));
165
169
  }
166
- function V(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 m(o) ? o.value : V(o);
176
- }
177
- }
178
- );
179
- }
180
- function N(e) {
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 N(e) {
192
183
  }
193
184
  );
194
185
  }
195
- function H(e, t) {
196
- const { model: n, form: o } = y(), r = e.__path;
197
- if (!r) return;
198
- const c = _(n, r);
199
- if (!c) return;
200
- const i = o.getFieldByPath(
201
- r
202
- ), f = i?.length, a = /* @__PURE__ */ new Map();
203
- h(() => {
204
- const d = f ? f.value : c.length, w = /* @__PURE__ */ new Set();
205
- for (let u = 0; u < d; u++) {
206
- const l = c.at(u);
207
- if (l != null && (w.add(l), !a.has(l))) {
208
- const b = i?.at?.(u) ?? N(r);
209
- a.set(l, t.__run(l, b));
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 [u, l] of a)
213
- w.has(u) || (l(), a.delete(u));
214
- }), s(() => {
215
- for (const d of a.values()) d();
216
- a.clear();
199
+ for (const [l, u] of f)
200
+ d.has(l) || (u(), f.delete(l));
201
+ }), a(() => {
202
+ for (const h of f.values()) h();
203
+ f.clear();
217
204
  });
218
205
  }
219
- function v(e) {
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++) v(t.at(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)) v(e[n]);
214
+ for (const n of Object.keys(e)) w(e[n]);
228
215
  }
229
- function ce(e, t) {
230
- const { model: n } = y(), o = e.__path;
231
- if (!o) return;
232
- const r = _(n, o);
233
- r && H(
234
- e,
235
- I(({ model: c }) => {
236
- q(t(c), (i) => {
237
- if (i)
238
- for (let f = 0; f < r.length; f++) {
239
- const a = r.at(f);
240
- if (a && a !== c) {
241
- const d = t(a);
242
- d.peek() && (d.value = !1);
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 ie(e, t) {
250
- const { model: n } = y(), o = e.__path;
251
- if (!o) return;
252
- const r = _(n, o);
253
- if (!r) return;
254
- let c = !1, i = 0;
255
- h(() => {
256
- v(r), !c && (c = !0, g(() => {
257
- c = !1;
258
- const f = t(r.toArray());
259
- let a = !1;
260
- for (const { index: d, patch: w } of f) {
261
- const u = r.at(d);
262
- if (u)
263
- for (const [l, b] of Object.entries(w))
264
- u[l] !== b && (u[l] = b, a = !0);
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 (i = a ? i + 1 : 0, i > 50)
267
- throw i = 0, new Error(
268
- `[@reformer/core/behaviors] aggregateInto("${o}"): запись не сходится (>50 проходов) — derive должна быть идемпотентной на фикспоинте.`
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 fe(e, t) {
274
- const { form: n } = y();
275
- for (const o of B(e)) {
276
- const r = o, c = r.__path;
277
- if (!c) continue;
278
- const i = n ? n.getFieldByPath(c) : void 0, f = i ? i.getProxy?.() ?? i : void 0;
279
- s(t.__run(V(r), f));
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
- ie as aggregateInto,
284
- fe as apply,
285
- H as applyEach,
286
- X as compute,
287
- Y as computeFrom,
288
- Z as copyFrom,
289
- g as defer,
290
- I as defineFormBehavior,
291
- ee as disableWhen,
292
- h as effect,
293
- z as enableWhen,
294
- ce as exclusiveFlag,
295
- y as getScope,
296
- q as onChange,
297
- s as onDispose,
298
- te as resetWhen,
299
- re as revalidateWhen,
300
- oe as syncFields,
301
- ne as transformValue
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,
330
+ a as onDispose,
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
+ };
@@ -0,0 +1,41 @@
1
+ const a = {
2
+ "format.fileSize.b": "{value} B",
3
+ "format.fileSize.kb": "{value} KB",
4
+ "format.fileSize.mb": "{value} MB",
5
+ "format.fileSize.gb": "{value} GB",
6
+ "format.fileSize.tb": "{value} TB",
7
+ "validation.required": "This field is required",
8
+ "validation.pattern": "Invalid format",
9
+ "validation.email": "Enter a valid email address",
10
+ "validation.url": "Enter a valid URL",
11
+ "validation.url_protocol": "The URL must use one of these protocols: {allowedProtocols}",
12
+ "validation.phone": "Enter a valid phone number",
13
+ "validation.min": "Must be at least {min}",
14
+ "validation.max": "Must be at most {max}",
15
+ "validation.minLength": "Enter at least {minLength, plural, one{# character} other{# characters}}",
16
+ "validation.maxLength": "Enter no more than {maxLength, plural, one{# character} other{# characters}}",
17
+ "validation.isNumber": "Enter a number",
18
+ "validation.integer": "Enter a whole number",
19
+ "validation.multipleOf": "Must be a multiple of {multipleOf}",
20
+ "validation.nonNegative": "Must not be negative",
21
+ "validation.nonZero": "Must not be zero",
22
+ "validation.date_invalid": "Enter a valid date",
23
+ "validation.date_min": "The date must not be earlier than {minDate}",
24
+ "validation.date_max": "The date must not be later than {maxDate}",
25
+ "validation.date_past": "The date must not be in the past",
26
+ "validation.date_future": "The date must not be in the future",
27
+ "validation.date_min_age": "Age must be at least {minAge}",
28
+ "validation.date_max_age": "Age must be at most {maxAge}",
29
+ "validation.fileType": "File {fileName} has a type that is not allowed. Allowed: {accept}",
30
+ "validation.maxFileSize": "File {fileName} is larger than {maxFileSize}",
31
+ "validation.minFileSize": "File {fileName} is smaller than {minFileSize}",
32
+ "validation.maxFiles": "No more than {maxFiles, plural, one{# file} other{# files}}",
33
+ "validation.minFiles": "At least {minFiles, plural, one{# file} other{# files}}",
34
+ "validation.maxTotalFileSize": "The total size of the files exceeds {maxTotalFileSize}",
35
+ "validation.fileExists": "File {fileName} has already been added",
36
+ "validation.uploadAborted": "Upload cancelled",
37
+ "validation.uploadFailed": "Failed to upload {fileName}"
38
+ };
39
+ export {
40
+ a as m
41
+ };
@@ -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;