@reformer/core 11.0.0-beta.8 → 11.0.0-beta.9

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 (224) hide show
  1. package/README.md +91 -73
  2. package/dist/behaviors-value-HA_Q03hc.js +108 -0
  3. package/dist/behaviors.js +370 -242
  4. package/dist/{create-model-BBRHhHwK.js → create-model-BvcbNPgL.js} +6 -6
  5. package/dist/date-utils-90-qZbse.js +43 -0
  6. package/dist/{en-CjAqn7h0.js → en-HP8XEych.js} +6 -3
  7. package/dist/form/aggregate-signals.d.ts +21 -63
  8. package/dist/form/behaviors/collections.d.ts +28 -7
  9. package/dist/form/behaviors/context.d.ts +19 -2
  10. package/dist/form/behaviors/index.d.ts +3 -3
  11. package/dist/form/behaviors/internals.d.ts +9 -2
  12. package/dist/form/behaviors/node.d.ts +25 -2
  13. package/dist/form/behaviors/operators.d.ts +17 -9
  14. package/dist/form/behaviors/schema-operators.d.ts +6 -4
  15. package/dist/form/behaviors/types.d.ts +12 -4
  16. package/dist/form/create-form.d.ts +47 -35
  17. package/dist/form/flow/flow.d.ts +87 -0
  18. package/dist/form/form-bundle.d.ts +45 -28
  19. package/dist/form/form-config-base.d.ts +46 -0
  20. package/dist/form/form-level.d.ts +121 -0
  21. package/dist/form/form-proxy-builder.d.ts +6 -22
  22. package/dist/form/index.d.ts +16 -21
  23. package/dist/form/nodes/form-array-node.d.ts +100 -0
  24. package/dist/form/nodes/form-control-node.d.ts +73 -0
  25. package/dist/form/nodes/form-group-node.d.ts +66 -0
  26. package/dist/form/nodes/node-kind.d.ts +29 -0
  27. package/dist/form/nodes/state/availability.d.ts +6 -0
  28. package/dist/form/nodes/state/component.d.ts +6 -0
  29. package/dist/form/nodes/state/index.d.ts +12 -0
  30. package/dist/form/nodes/state/interaction.d.ts +13 -0
  31. package/dist/form/nodes/state/issues.d.ts +9 -0
  32. package/dist/form/nodes/state/pending.d.ts +6 -0
  33. package/dist/form/schema/compile.d.ts +59 -0
  34. package/dist/form/schema/compiled.d.ts +143 -0
  35. package/dist/form/schema/row-key.d.ts +11 -0
  36. package/dist/form/schema-controller.d.ts +30 -14
  37. package/dist/form/signal-node-registry.d.ts +6 -7
  38. package/dist/form/submission.d.ts +93 -0
  39. package/dist/form/type-guards.d.ts +14 -73
  40. package/dist/form/types/contracts.d.ts +19 -92
  41. package/dist/form/types/field-config.d.ts +27 -0
  42. package/dist/form/types/index.d.ts +5 -57
  43. package/dist/form/types/nodes.d.ts +159 -0
  44. package/dist/form/types/schema-node.d.ts +139 -63
  45. package/dist/form/types/validation-schema.d.ts +23 -27
  46. package/dist/form/validation/context.d.ts +42 -7
  47. package/dist/form/validation/index.d.ts +9 -8
  48. package/dist/form/validation/operators.d.ts +22 -30
  49. package/dist/form/validation/run.d.ts +93 -18
  50. package/dist/form/validation/strategy.d.ts +41 -13
  51. package/dist/form/validation/types.d.ts +74 -20
  52. package/dist/form/validators/date-utils.d.ts +13 -1
  53. package/dist/form/validators/email.d.ts +8 -7
  54. package/dist/form/validators/file-type.d.ts +8 -7
  55. package/dist/form/validators/file-utils.d.ts +2 -1
  56. package/dist/form/validators/future-date.d.ts +8 -7
  57. package/dist/form/validators/index.d.ts +1 -1
  58. package/dist/form/validators/integer.d.ts +8 -7
  59. package/dist/form/validators/is-date.d.ts +11 -9
  60. package/dist/form/validators/is-number.d.ts +11 -9
  61. package/dist/form/validators/max-age.d.ts +13 -9
  62. package/dist/form/validators/max-date.d.ts +8 -7
  63. package/dist/form/validators/max-file-size.d.ts +8 -7
  64. package/dist/form/validators/max-files.d.ts +8 -7
  65. package/dist/form/validators/max-length.d.ts +14 -7
  66. package/dist/form/validators/max-total-file-size.d.ts +8 -7
  67. package/dist/form/validators/max.d.ts +10 -8
  68. package/dist/form/validators/min-age.d.ts +12 -9
  69. package/dist/form/validators/min-date.d.ts +8 -7
  70. package/dist/form/validators/min-file-size.d.ts +8 -7
  71. package/dist/form/validators/min-files.d.ts +11 -9
  72. package/dist/form/validators/min-length.d.ts +14 -7
  73. package/dist/form/validators/min.d.ts +10 -8
  74. package/dist/form/validators/multiple-of.d.ts +10 -8
  75. package/dist/form/validators/non-negative.d.ts +8 -7
  76. package/dist/form/validators/non-zero.d.ts +8 -7
  77. package/dist/form/validators/past-date.d.ts +8 -7
  78. package/dist/form/validators/pattern.d.ts +9 -8
  79. package/dist/form/validators/phone.d.ts +8 -7
  80. package/dist/form/validators/required.d.ts +11 -9
  81. package/dist/form/validators/url.d.ts +20 -13
  82. package/dist/form/validators/validation-issue.d.ts +8 -0
  83. package/dist/i18n/descriptor.d.ts +1 -1
  84. package/dist/i18n/en.json.d.ts +5 -1
  85. package/dist/i18n/locale-store.d.ts +7 -0
  86. package/dist/i18n/message-format.d.ts +24 -4
  87. package/dist/i18n/ru.json.d.ts +5 -1
  88. package/dist/i18n/translator.d.ts +11 -0
  89. package/dist/i18n/validation-message.d.ts +42 -7
  90. package/dist/i18n.d.ts +7 -12
  91. package/dist/i18n.js +66 -283
  92. package/dist/index.d.ts +16 -7
  93. package/dist/index.js +924 -2855
  94. package/dist/loader-BWkigpVe.js +52 -0
  95. package/dist/locale/en.js +1 -1
  96. package/dist/locale/en.json +4 -1
  97. package/dist/locale/ru.js +4 -1
  98. package/dist/locale/ru.json +4 -1
  99. package/dist/locale-CG54AU2Q.js +219 -0
  100. package/dist/locale.js +1 -1
  101. package/dist/model/behaviors-value.d.ts +24 -6
  102. package/dist/model/create-model.d.ts +2 -2
  103. package/dist/model/derived-registry.d.ts +1 -1
  104. package/dist/model/index.d.ts +11 -5
  105. package/dist/model/model-nodes.d.ts +79 -12
  106. package/dist/model/model-signals-proxy.d.ts +5 -6
  107. package/dist/model/model-value-proxy.d.ts +20 -15
  108. package/dist/model/safe-effect.d.ts +33 -1
  109. package/dist/model/types.d.ts +63 -13
  110. package/dist/model.js +20 -18
  111. package/dist/node-kind-C-r6ZMdo.js +15 -0
  112. package/dist/platforms/react/field-binding/field-adapter.d.ts +1 -1
  113. package/dist/platforms/react/field-binding/field-handle.d.ts +5 -2
  114. package/dist/platforms/react/form-bundle-context.d.ts +2 -2
  115. package/dist/platforms/react/hooks/types.d.ts +57 -38
  116. package/dist/platforms/react/hooks/use-form-bundle.d.ts +19 -4
  117. package/dist/platforms/react/hooks/use-form-flow.d.ts +40 -0
  118. package/dist/platforms/react/hooks/use-form-validation.d.ts +12 -6
  119. package/dist/platforms/react/hooks/useArrayLength.d.ts +6 -6
  120. package/dist/platforms/react/hooks/useFormControl.d.ts +7 -9
  121. package/dist/platforms/react/hooks/useFormControlValue.d.ts +18 -19
  122. package/dist/platforms/react/hooks/useSignalSubscription.d.ts +9 -1
  123. package/dist/platforms/react/i18n/context.d.ts +6 -1
  124. package/dist/platforms/react/i18n/hooks.d.ts +16 -10
  125. package/dist/platforms/react/i18n/provider.d.ts +9 -2
  126. package/dist/platforms/react/index.d.ts +6 -4
  127. package/dist/react.d.ts +22 -0
  128. package/dist/react.js +505 -0
  129. package/dist/runtime-token.d.ts +1 -2
  130. package/dist/safe-effect-BbtX3KuN.js +643 -0
  131. package/dist/schema-controller-CpiO2JoK.js +143 -0
  132. package/dist/signals.d.ts +15 -9
  133. package/dist/signals.js +11 -6
  134. package/dist/strategy-CoFSemuP.js +375 -0
  135. package/dist/type-guards-D-N_5Ddh.js +19 -0
  136. package/dist/validation-issue-B9mjI8jz.js +7 -0
  137. package/dist/validation-message-Ced9MGxs.js +194 -0
  138. package/dist/validation.js +9 -9
  139. package/dist/validators/email.js +5 -5
  140. package/dist/validators/future-date.js +8 -8
  141. package/dist/validators/integer.js +3 -3
  142. package/dist/validators/is-date.js +4 -4
  143. package/dist/validators/is-number.js +4 -4
  144. package/dist/validators/max-age.js +8 -9
  145. package/dist/validators/max-date.js +8 -8
  146. package/dist/validators/max-length.js +7 -7
  147. package/dist/validators/max.js +4 -4
  148. package/dist/validators/min-age.js +10 -8
  149. package/dist/validators/min-date.js +3 -3
  150. package/dist/validators/min-length.js +5 -5
  151. package/dist/validators/min.js +4 -4
  152. package/dist/validators/multiple-of.js +11 -7
  153. package/dist/validators/non-negative.js +3 -3
  154. package/dist/validators/non-zero.js +3 -3
  155. package/dist/validators/past-date.js +8 -8
  156. package/dist/validators/pattern.js +5 -5
  157. package/dist/validators/phone.js +11 -9
  158. package/dist/validators/required.js +2 -2
  159. package/dist/validators/url.js +48 -12
  160. package/dist/validators.js +17 -17
  161. package/docs/llms/01-api-reference.md +60 -34
  162. package/docs/llms/02-quick-start.md +111 -80
  163. package/docs/llms/03-api-signatures.md +368 -153
  164. package/docs/llms/04-common-patterns.md +58 -56
  165. package/docs/llms/05-common-mistakes.md +69 -44
  166. package/docs/llms/06-troubleshooting.md +14 -9
  167. package/docs/llms/07-complete-import.md +74 -43
  168. package/docs/llms/08-form-types.md +11 -4
  169. package/docs/llms/09-formschema.md +129 -81
  170. package/docs/llms/10-arrays.md +106 -75
  171. package/docs/llms/11-async-watchfield.md +2 -2
  172. package/docs/llms/13-multi-step.md +134 -63
  173. package/docs/llms/14-extended-mistakes.md +20 -17
  174. package/docs/llms/15-project-structure.md +221 -74
  175. package/docs/llms/16-ui-components.md +55 -42
  176. package/docs/llms/17-nonexistent-api.md +199 -32
  177. package/docs/llms/18-conditional-fields.md +66 -32
  178. package/docs/llms/19-reading-values.md +15 -3
  179. package/docs/llms/20-compute-vs-watch.md +16 -10
  180. package/docs/llms/21-array-operations.md +51 -27
  181. package/docs/llms/22-cycle-detection.md +1 -1
  182. package/docs/llms/23-copy-from.md +2 -2
  183. package/docs/llms/24-sync-fields.md +6 -5
  184. package/docs/llms/25-reset-when.md +14 -7
  185. package/docs/llms/26-transform-value.md +4 -4
  186. package/docs/llms/27-revalidate-when.md +16 -15
  187. package/docs/llms/28-submit-and-reset.md +276 -128
  188. package/docs/llms/29-async-preload.md +39 -29
  189. package/docs/llms/30-type-safety-recipes.md +105 -51
  190. package/docs/llms/31-async-validator-debounce.md +96 -53
  191. package/docs/llms/33-validation-strategy.md +177 -65
  192. package/docs/llms/34-i18n.md +69 -43
  193. package/docs/llms/35-unified-contract.md +100 -39
  194. package/docs/llms/36-issue-messages.md +284 -0
  195. package/docs/llms/37-compiled-schema.md +332 -0
  196. package/docs/llms/38-form-flow.md +397 -0
  197. package/llms-index.json +1 -1
  198. package/llms.txt +6084 -3420
  199. package/package.json +23 -4
  200. package/dist/behaviors-value-C7dSEhCc.js +0 -134
  201. package/dist/date-utils-dTT_x_Be.js +0 -31
  202. package/dist/form/create-core-form.d.ts +0 -72
  203. package/dist/form/factories/index.d.ts +0 -6
  204. package/dist/form/factories/node-factory.d.ts +0 -189
  205. package/dist/form/form-submitter.d.ts +0 -121
  206. package/dist/form/nodes/array-node.d.ts +0 -276
  207. package/dist/form/nodes/field-node.d.ts +0 -297
  208. package/dist/form/nodes/form-node.d.ts +0 -326
  209. package/dist/form/nodes/group-node.d.ts +0 -284
  210. package/dist/form/nodes/model-array-node.d.ts +0 -126
  211. package/dist/form/nodes/subscription-manager.d.ts +0 -180
  212. package/dist/form/status-machine.d.ts +0 -115
  213. package/dist/form/types/deep-schema.d.ts +0 -107
  214. package/dist/form/types/form-proxy.d.ts +0 -141
  215. package/dist/form/unique-id.d.ts +0 -45
  216. package/dist/form/validation/config.d.ts +0 -73
  217. package/dist/form/validation/error-handler.d.ts +0 -166
  218. package/dist/form/validators/validation-error.d.ts +0 -8
  219. package/dist/index-BrNkQj1y.js +0 -105
  220. package/dist/loader-Dv_Hl7JC.js +0 -216
  221. package/dist/model-value-proxy-caTmAiUd.js +0 -419
  222. package/dist/node-BeV_lV5i.js +0 -100
  223. package/dist/strategy-DgzELWno.js +0 -204
  224. package/dist/validation-error-B-U3RsV0.js +0 -11
package/dist/behaviors.js CHANGED
@@ -1,339 +1,467 @@
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";
1
+ import { effect as N, untracked as F } from "@preact/signals-core";
2
+ import { r as H, h as j, p as Q, i as P, c as V, u as I, o as b, m as O, n as A } from "./safe-effect-BbtX3KuN.js";
3
+ import { c as X } from "./schema-controller-CpiO2JoK.js";
4
+ import { a as Y, w as M, t as Z, r as ee, s as ne, b as oe } from "./behaviors-value-HA_Q03hc.js";
5
5
  import { g as v } from "./signal-node-registry-tiwel-TV.js";
6
- let m = null;
7
- function k(e) {
6
+ import { r as re } from "./node-kind-C-r6ZMdo.js";
7
+ let m = null, g = null;
8
+ function C(e, n) {
9
+ const o = g;
10
+ g = e;
11
+ try {
12
+ return n();
13
+ } finally {
14
+ g = o;
15
+ }
16
+ }
17
+ function D(e) {
18
+ for (const n of e.cleanups) n();
19
+ for (const n of e.deferred) n();
20
+ e.deferred.clear(), e.rollback?.();
21
+ }
22
+ function w(e) {
8
23
  if (!m)
9
24
  throw new Error(
10
25
  `[@reformer/core/behaviors] "${e}" вызван вне defineFormBehavior(...) — операторы поведения можно вызывать только внутри схемы.`
11
26
  );
12
27
  return m;
13
28
  }
14
- function a(e) {
15
- k("onDispose").cleanups.push(e);
29
+ function u(e) {
30
+ w("onDispose").cleanups.push(e);
16
31
  }
17
- function g(e) {
32
+ function p(e) {
33
+ w(e);
34
+ }
35
+ function k(e) {
18
36
  m?.cleanups.push(e);
19
37
  }
20
- function ie() {
21
- const e = k("getScope");
22
- return x(e);
38
+ function ve() {
39
+ const e = w("getScope");
40
+ return R(e);
41
+ }
42
+ function T(e = "getController") {
43
+ return w(e).controller;
23
44
  }
24
- function F(e = "getController") {
25
- return k(e).controller;
45
+ function G(e = "getFlow") {
46
+ return w(e).flow;
47
+ }
48
+ function te(e) {
49
+ if (e.schema) return e.schema;
50
+ const n = e.controller.scopeOf(e.model), o = n.__overrideMaps, r = /* @__PURE__ */ new Map(), c = (t) => {
51
+ let s = r.get(t);
52
+ return s || (s = { props: /* @__PURE__ */ new Map() }, r.set(t, s)), s;
53
+ };
54
+ return e.rollback = () => {
55
+ for (const [t, s] of r) {
56
+ const i = n.node(t);
57
+ s.hidden !== void 0 && o.hiddenOverrides.get(t) === s.hidden && i.resetHidden();
58
+ const f = o.propsOverrides.get(t);
59
+ if (f == null || s.props.size === 0) continue;
60
+ const a = Object.entries(f).filter(
61
+ ([h, l]) => !(s.props.has(h) && Object.is(s.props.get(h), l))
62
+ );
63
+ a.length !== Object.keys(f).length && (i.resetProps(), a.length > 0 && i.patchProps(Object.fromEntries(a)));
64
+ }
65
+ r.clear();
66
+ }, e.schema = {
67
+ ...n,
68
+ node(t) {
69
+ const s = n.node(t), i = {
70
+ ...s,
71
+ setHidden(f) {
72
+ return s.setHidden(f), c(t).hidden = f, i;
73
+ },
74
+ patchProps(f) {
75
+ s.patchProps(f);
76
+ const a = c(t);
77
+ for (const [h, l] of Object.entries(f)) a.props.set(h, l);
78
+ return i;
79
+ },
80
+ resetHidden() {
81
+ s.resetHidden();
82
+ const f = r.get(t);
83
+ return f && (f.hidden = void 0), i;
84
+ },
85
+ resetProps() {
86
+ return s.resetProps(), r.get(t)?.props.clear(), i;
87
+ }
88
+ };
89
+ return i;
90
+ }
91
+ }, e.schema;
26
92
  }
27
- const x = (e) => ({
93
+ const R = (e) => ({
28
94
  model: e.model,
29
95
  form: e.form,
30
- schema: e.controller.scopeOf(e.model)
96
+ schema: te(e),
97
+ flow: e.flow
31
98
  });
32
- function Q(e) {
99
+ function ce(e) {
33
100
  return {
34
- __run(t, n, o = U()) {
35
- const r = { cleanups: [], model: t, form: n, controller: o }, c = m;
36
- m = r;
101
+ __run(n, o, r = X(), c) {
102
+ const t = {
103
+ cleanups: [],
104
+ deferred: /* @__PURE__ */ new Set(),
105
+ model: n,
106
+ form: o,
107
+ controller: r,
108
+ flow: c
109
+ }, s = m;
110
+ m = t;
37
111
  try {
38
- e(x(r));
112
+ C(t.deferred, () => e(R(t)));
113
+ } catch (i) {
114
+ throw D(t), i;
39
115
  } finally {
40
- m = c;
116
+ m = s;
41
117
  }
42
- return () => {
43
- for (const s of r.cleanups) s();
44
- };
118
+ return () => D(t);
45
119
  }
46
120
  };
47
121
  }
48
- function p(e) {
49
- a(H(e));
122
+ function y(e) {
123
+ const n = w("effect"), o = n.deferred;
124
+ n.cleanups.push(N(() => C(o, e)));
50
125
  }
51
- function O(e) {
52
- $(e);
126
+ function B(e) {
127
+ const n = g ?? m?.deferred;
128
+ if (!n) {
129
+ H(e);
130
+ return;
131
+ }
132
+ const o = H(() => {
133
+ n.delete(o), C(n, e);
134
+ });
135
+ n.add(o);
53
136
  }
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) {
56
- const t = {};
57
- for (const n of Object.keys(e)) {
58
- const o = e[n];
59
- t[n] = y(o) ? o.value : j(o);
137
+ function L(e, n) {
138
+ const o = j();
139
+ return {
140
+ schedule(r) {
141
+ o.cancelAll(), o.schedule(() => {
142
+ F(e) ? r.enable() : (r.disable(), n?.resetOnDisable && re(r).resetToCreation());
143
+ });
144
+ },
145
+ cancel: () => o.cancelAll()
146
+ };
147
+ }
148
+ function se(e, n, o) {
149
+ const r = L(n, o), c = N(() => {
150
+ n();
151
+ const t = v(e);
152
+ t && r.schedule(t);
153
+ });
154
+ return () => {
155
+ c(), r.cancel();
156
+ };
157
+ }
158
+ const z = (e) => typeof e == "object" && e !== null && typeof e.peek == "function" && !P(e), E = (e) => z(e) || Q(e), U = (e) => Array.isArray(e) ? e : [e];
159
+ function W(e) {
160
+ const n = {};
161
+ for (const o of Object.keys(e)) {
162
+ const r = e[o];
163
+ n[o] = E(r) ? r.value : W(r);
60
164
  }
61
- return t;
165
+ return n;
62
166
  }
63
- function A(e, t) {
64
- for (const n of Object.keys(e)) {
65
- const o = e[n];
66
- y(o) ? o.value = t?.[n] : A(o, t?.[n] ?? {});
167
+ function q(e, n, o, r = "") {
168
+ if (n == null || typeof n != "object") {
169
+ o?.push(r === "" ? "(вся группа)" : r);
170
+ return;
171
+ }
172
+ for (const c of Object.keys(e)) {
173
+ const t = r === "" ? c : `${r}.${c}`;
174
+ if (!(c in n)) {
175
+ o?.push(t);
176
+ continue;
177
+ }
178
+ const s = e[c];
179
+ E(s) ? s.value = n[c] : q(s, n[c], o, t);
67
180
  }
68
181
  }
69
- function D(e) {
70
- return (t) => {
182
+ function x(e) {
183
+ return (n) => {
71
184
  try {
72
- t();
73
- } catch (n) {
74
- if (n instanceof Error && /cycle detected/i.test(n.message)) {
75
- const o = e.__path ?? "?";
185
+ n();
186
+ } catch (o) {
187
+ if (o instanceof Error && /cycle detected/i.test(o.message)) {
188
+ const r = e.__path ?? "?";
76
189
  throw new Error(
77
- `[@reformer/core/behaviors] compute("${o}"): расходящийся цикл пересчёта — взаимные compute/computeFrom без стабилизации. Проверьте зависимости или добавьте стабилизирующее условие (when) / разорвите цикл через peek.`
190
+ `[@reformer/core/behaviors] compute("${r}"): расходящийся цикл пересчёта — взаимные compute/computeFrom без стабилизации. Проверьте зависимости или добавьте стабилизирующее условие (when) / разорвите цикл через peek.`
78
191
  );
79
192
  }
80
- throw n;
193
+ throw o;
81
194
  }
82
195
  };
83
196
  }
84
- function ae(e, t, n) {
85
- E(e), a(() => S(e));
86
- const o = D(e);
87
- p(() => {
88
- if (n?.when && !n.when()) return;
89
- const r = t();
90
- e.peek() !== r && o(() => {
91
- e.value = r;
197
+ function ke(e, n, o) {
198
+ p("compute"), V(e), u(() => I(e));
199
+ const r = x(e);
200
+ y(() => {
201
+ if (o?.when && !o.when()) return;
202
+ const c = n();
203
+ e.peek() !== c && r(() => {
204
+ e.value = c;
92
205
  });
93
206
  });
94
207
  }
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);
100
- if (o?.when && !o.when(...c)) return;
101
- const s = n(...c);
102
- t.peek() !== s && r(() => {
103
- t.value = s;
208
+ function $e(e, n, o, r) {
209
+ p("computeFrom"), V(n), u(() => I(n));
210
+ const c = x(n);
211
+ y(() => {
212
+ const t = e.map((i) => i.value);
213
+ if (r?.when && !r.when(...t)) return;
214
+ const s = o(...t);
215
+ n.peek() !== s && c(() => {
216
+ n.value = s;
104
217
  });
105
218
  });
106
219
  }
107
- function le(e, t, n) {
108
- if (y(e) && y(t)) {
109
- a(P(e, t, n));
220
+ function ge(e, n, o) {
221
+ if (p("copyFrom"), E(e) && E(n)) {
222
+ u(Y(e, n, o));
110
223
  return;
111
224
  }
112
- const o = e, r = t;
113
- p(() => {
114
- const c = j(o);
115
- n?.when && !n.when() || O(() => A(r, c));
116
- });
117
- }
118
- function X(e, t, n) {
119
- let o;
120
- const r = (c) => {
121
- o?.abort(), o = new AbortController();
122
- const { signal: s } = o;
123
- $(() => t(c, { signal: s }));
225
+ const r = e, c = n, t = o?.when, s = o?.transform, i = j();
226
+ let f = !1;
227
+ y(() => {
228
+ W(r), i.cancelAll(), !(t && !t()) && i.schedule(() => {
229
+ if (t && !F(t)) return;
230
+ const a = F(() => W(r)), h = s ? s(a) : a, l = [];
231
+ q(c, h, l), l.length > 0 && !f && process.env.NODE_ENV !== "production" && (f = !0, console.warn(
232
+ `[@reformer/core/behaviors] copyFrom(…, "${c.__path ?? "?"}"): в значении нет полей цели ${l.map((d) => `«${d}»`).join(", ")} — они остались прежними. Для групп разной формы соберите значение цели целиком в \`transform\`.`
233
+ ));
234
+ });
235
+ }), u(() => i.cancelAll());
236
+ }
237
+ function ie(e, n, o) {
238
+ p("onChange");
239
+ let r;
240
+ const c = j(), t = (s) => {
241
+ r?.abort(), r = new AbortController();
242
+ const { signal: i } = r;
243
+ c.schedule(() => n(s, { signal: i }));
124
244
  };
125
- if (!n?.debounce)
126
- a(M(e, r, { immediate: n?.immediate }));
245
+ if (!o?.debounce)
246
+ u(M(e, t, { immediate: o?.immediate }));
127
247
  else {
128
- let c;
129
- const s = M(
248
+ let s;
249
+ const i = M(
130
250
  e,
131
- (i) => {
132
- c && clearTimeout(c), c = setTimeout(() => r(i), n.debounce);
251
+ (f) => {
252
+ r?.abort(), s && clearTimeout(s), s = setTimeout(() => t(f), o.debounce);
133
253
  },
134
- { immediate: n?.immediate }
254
+ { immediate: o?.immediate }
135
255
  );
136
- a(() => {
137
- c && clearTimeout(c), s();
256
+ u(() => {
257
+ s && clearTimeout(s), i();
138
258
  });
139
259
  }
140
- a(() => o?.abort());
260
+ u(() => {
261
+ c.cancelAll(), r?.abort();
262
+ });
141
263
  }
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);
264
+ function Ee(e, n, o) {
265
+ p("enableWhen"), J("enableWhen", e, n, o);
145
266
  }
146
- function ue(e, t, n) {
147
- Y(e, () => !t(), n);
267
+ function Oe(e, n, o) {
268
+ p("disableWhen"), J("disableWhen", e, () => !n(), o);
148
269
  }
149
- function Z(e, t, n) {
150
- const o = v(e);
151
- o && p(() => {
152
- const r = t();
153
- O(() => {
154
- r ? o.enable() : (o.disable(), n?.resetOnDisable && o.reset());
155
- });
156
- });
270
+ function fe(e, n) {
271
+ if (process.env.NODE_ENV === "production" || v(n)) return;
272
+ const o = n.__path ?? "?";
273
+ console.warn(
274
+ `[@reformer/core/behaviors] ${e}("${o}"): у поля нет ноды формы — правило ничего не сделает. Поле не описано в схеме формы, либо ручка взята из другой модели.`
275
+ );
276
+ }
277
+ function J(e, n, o, r) {
278
+ for (const c of U(n))
279
+ fe(e, c), z(c) ? u(se(c, o, r)) : le(c, o, r);
157
280
  }
158
- function de(e, t) {
159
- a(B(e, t));
281
+ function le(e, n, o) {
282
+ const r = v(e);
283
+ if (!r) return;
284
+ const c = L(n, o);
285
+ y(() => {
286
+ n(), c.schedule(r);
287
+ }), u(c.cancel);
160
288
  }
161
- function me(e, t, n) {
162
- a(T(e, t, n));
289
+ function _e(e, n) {
290
+ p("transformValue"), u(Z(e, n));
163
291
  }
164
- function pe(e, t, n) {
165
- a(L(e, t, n));
292
+ function Fe(e, n, ...o) {
293
+ p("resetWhen"), u(ee(e, n, ...o));
166
294
  }
167
- function he(e, t) {
168
- a(N(e, t));
295
+ function We(e, n, o) {
296
+ p("syncFields"), u(ne(e, n, o));
169
297
  }
170
- const I = (e) => e.__path ?? "?", R = (e) => void F(e);
171
- function ee(e) {
298
+ function Se(e, n) {
299
+ p("revalidateWhen"), u(oe(e, n));
300
+ }
301
+ const K = (e) => e.__path ?? "?";
302
+ function ae(e) {
303
+ return e == null ? String(e) : b(e) ? "массив" : A(e) ? "группа" : typeof e == "object" && typeof e.peek == "function" && !P(e) ? "поле-лист" : "не ручка модели";
304
+ }
305
+ function _(e, n, o) {
306
+ if (process.env.NODE_ENV === "production") return;
307
+ const c = (n !== null && typeof n == "object" ? b(n) ?? A(n) ?? n : void 0)?.__path, t = typeof c == "string" ? `("${c}")` : "", s = o === "массив" ? "нужен массив. Передайте ручку `model.$.<массив>` или фасад `model.<массив>`; группу подключают через `apply`." : "нужна группа. Передайте ручку `model.$.<группа>` или фасад `model.<группа>`; массив подключают через `applyEach`. Группа с начальным значением `null` под-модели не имеет — задайте ей объект.";
308
+ throw new Error(`[@reformer/core/behaviors] ${e}${t}: цель — ${ae(n)}, а ${s}`);
309
+ }
310
+ function ue(e) {
172
311
  return new Proxy(
173
312
  {},
174
313
  {
175
- get(t, n) {
176
- if (!(typeof n == "symbol" || n === "then"))
314
+ get(n, o) {
315
+ if (!(typeof o == "symbol" || o === "then"))
177
316
  throw new Error(
178
317
  `[@reformer/core/behaviors] applyEach: форма строки массива "${e}" недоступна (form.${String(
179
- n
180
- )}) — массив не материализован в схеме формы. Per-row node-операции (enableWhen/updateComponentProps/reset) требуют узла { array, item } в схеме; value-операции (row.$.*: compute/copyFrom/transformValue) работают и без материализации.`
318
+ o
319
+ )}) — массив не материализован в схеме формы. Per-row node-операции (enableWhen/updateComponentProps/reset) требуют узла { model, item } в схеме; value-операции (row.$.*: compute/copyFrom/transformValue) работают и без материализации.`
181
320
  );
182
321
  }
183
322
  }
184
323
  );
185
324
  }
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));
325
+ function de(e, n) {
326
+ const o = T("applyEach"), r = G("applyEach"), c = b(e);
327
+ if (!c) return _("applyEach", e, "массив");
328
+ const t = O(c), s = v(c), i = typeof s?.at == "function" ? s : void 0, f = /* @__PURE__ */ new Map();
329
+ y(() => {
330
+ const a = i ? i.length ?? 0 : t.length, h = /* @__PURE__ */ new Set();
331
+ for (let l = 0; l < a; l++) {
332
+ const d = t.at(l);
333
+ if (d != null && (h.add(d), !f.has(d))) {
334
+ const $ = i?.at?.(l) ?? ue(K(c));
335
+ f.set(d, n.__run(d, $, o, r));
197
336
  }
198
337
  }
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();
338
+ for (const [l, d] of f)
339
+ h.has(l) || (d(), f.delete(l));
340
+ }), u(() => {
341
+ for (const a of f.values()) a();
203
342
  f.clear();
204
343
  });
205
344
  }
206
- function w(e) {
345
+ function S(e) {
207
346
  if (e == null || typeof e != "object") return;
208
- const t = e;
209
- if (typeof t.at == "function" && typeof t.length == "number") {
210
- const n = t.length;
211
- for (let o = 0; o < n; o++) w(t.at(o));
347
+ const n = e;
348
+ if (typeof n.at == "function" && typeof n.length == "number") {
349
+ const o = n.length;
350
+ for (let r = 0; r < o; r++) S(n.at(r));
212
351
  return;
213
352
  }
214
- for (const n of Object.keys(e)) w(e[n]);
215
- }
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);
353
+ for (const o of Object.keys(e)) S(e[o]);
354
+ }
355
+ function je(e, n) {
356
+ p("exclusiveFlag");
357
+ const o = b(e);
358
+ if (!o) return _("exclusiveFlag", e, "массив");
359
+ const r = O(o), c = /* @__PURE__ */ new Set();
360
+ de(
361
+ o,
362
+ ce(({ model: t }) => {
363
+ n(t).peek() && (c.add(t), u(() => c.delete(t)), B(() => {
364
+ c.delete(t);
365
+ const s = n(t);
366
+ if (s.peek())
367
+ for (let i = 0; i < r.length; i++) {
368
+ const f = r.at(i);
369
+ if (f && f !== t && !c.has(f) && n(f).peek()) {
370
+ s.value = !1;
371
+ return;
372
+ }
373
+ }
374
+ })), ie(n(t), (s) => {
375
+ if (!(!s || !n(t).peek()))
376
+ for (let i = 0; i < r.length; i++) {
377
+ const f = r.at(i);
378
+ if (f && f !== t) {
379
+ const a = n(f);
380
+ a.peek() && (a.value = !1);
231
381
  }
232
382
  }
233
383
  });
234
384
  })
235
385
  );
236
386
  }
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);
387
+ function Ae(e, n) {
388
+ p("aggregateInto");
389
+ const o = b(e);
390
+ if (!o) return _("aggregateInto", e, "массив");
391
+ const r = O(o);
392
+ let c = !1, t = 0, s = !1;
393
+ y(() => {
394
+ S(r), !(c || s) && (c = !0, B(() => {
395
+ if (c = !1, s) return;
396
+ const i = n(r.toArray());
397
+ let f = !1;
398
+ for (const { index: a, patch: h } of i) {
399
+ const l = r.at(a);
400
+ if (l)
401
+ for (const [d, $] of Object.entries(h))
402
+ l[d] !== $ && (l[d] = $, f = !0);
253
403
  }
254
- if (c = i ? c + 1 : 0, c > 50)
255
- throw c = 0, new Error(
256
- `[@reformer/core/behaviors] aggregateInto("${I(n)}"): запись не сходится (>50 проходов) — derive должна быть идемпотентной на фикспоинте.`
404
+ if (t = f ? t + 1 : 0, t > 50)
405
+ throw s = !0, new Error(
406
+ `[@reformer/core/behaviors] aggregateInto("${K(o)}"): запись не сходится (>50 проходов) — derive должна быть идемпотентной на фикспоинте.`
257
407
  );
258
408
  }));
259
409
  });
260
410
  }
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));
411
+ function Ce(e, n) {
412
+ const o = T("apply"), r = G("apply");
413
+ for (const c of U(e)) {
414
+ const t = A(c);
415
+ if (!t) {
416
+ _("apply", c, "группа");
417
+ continue;
418
+ }
419
+ const s = O(t), i = v(t);
420
+ u(n.__run(s, i, o, r));
268
421
  }
269
422
  }
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
- });
423
+ function He(e, n) {
424
+ k(e.addHideCondition(n));
284
425
  }
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
- });
426
+ function Me(e, n, o) {
427
+ k(e.addEventHandler(n, o));
291
428
  }
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
- });
429
+ function De(e, n) {
430
+ k(e.addRenderEffect(n));
303
431
  }
304
- function ke(e, t) {
305
- t();
432
+ function Ne(e, n) {
433
+ n();
306
434
  }
307
- function Fe(e, t) {
308
- V(e, "onMount", t);
435
+ function Pe(e, n) {
436
+ k(e.addLifecycleHook("onMount", n));
309
437
  }
310
- function Oe(e, t) {
311
- V(e, "onUnmount", t);
438
+ function Ve(e, n) {
439
+ k(e.addLifecycleHook("onUnmount", n));
312
440
  }
313
441
  export {
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
442
+ Ae as aggregateInto,
443
+ Ce as apply,
444
+ de as applyEach,
445
+ ke as compute,
446
+ $e as computeFrom,
447
+ ge as copyFrom,
448
+ B as defer,
449
+ ce as defineFormBehavior,
450
+ Oe as disableWhen,
451
+ y as effect,
452
+ Ee as enableWhen,
453
+ je as exclusiveFlag,
454
+ ve as getScope,
455
+ He as hideWhen,
456
+ ie as onChange,
457
+ Me as onComponentEvent,
458
+ u as onDispose,
459
+ Ne as onInit,
460
+ Pe as onMount,
461
+ Ve as onUnmount,
462
+ De as renderEffect,
463
+ Fe as resetWhen,
464
+ Se as revalidateWhen,
465
+ We as syncFields,
466
+ _e as transformValue
339
467
  };