@reformer/core 11.0.0-beta.1 → 11.0.0-beta.10

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 (283) hide show
  1. package/README.md +90 -68
  2. package/dist/behaviors-value-D05z3my6.js +109 -0
  3. package/dist/behaviors.d.ts +1 -1
  4. package/dist/behaviors.js +376 -211
  5. package/dist/create-model-DPSG3I0O.js +30 -0
  6. package/dist/date-utils-90-qZbse.js +43 -0
  7. package/dist/en-HP8XEych.js +44 -0
  8. package/dist/form/aggregate-signals.d.ts +21 -63
  9. package/dist/form/behaviors/collections.d.ts +84 -0
  10. package/dist/form/behaviors/context.d.ts +56 -0
  11. package/dist/form/behaviors/index.d.ts +30 -0
  12. package/dist/form/behaviors/internals.d.ts +41 -0
  13. package/dist/form/{behaviors-node.d.ts → behaviors/node.d.ts} +28 -5
  14. package/dist/form/behaviors/operators.d.ts +59 -0
  15. package/dist/form/behaviors/schema-operators.d.ts +83 -0
  16. package/dist/form/behaviors/types.d.ts +37 -0
  17. package/dist/form/create-form.d.ts +59 -70
  18. package/dist/form/flow/flow.d.ts +87 -0
  19. package/dist/form/form-bundle.d.ts +153 -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 +23 -24
  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 +159 -0
  37. package/dist/form/schema-subtree.d.ts +28 -0
  38. package/dist/form/signal-node-registry.d.ts +27 -22
  39. package/dist/form/submission.d.ts +93 -0
  40. package/dist/form/type-guards.d.ts +14 -73
  41. package/dist/form/types/contracts.d.ts +21 -85
  42. package/dist/form/types/field-config.d.ts +27 -0
  43. package/dist/form/types/index.d.ts +5 -57
  44. package/dist/form/types/nodes.d.ts +159 -0
  45. package/dist/form/types/schema-node.d.ts +147 -46
  46. package/dist/form/types/validation-schema.d.ts +25 -17
  47. package/dist/form/validation/context.d.ts +67 -0
  48. package/dist/form/validation/index.d.ts +24 -28
  49. package/dist/form/validation/operators.d.ts +101 -0
  50. package/dist/form/validation/run.d.ts +120 -0
  51. package/dist/form/validation/strategy.d.ts +89 -0
  52. package/dist/form/validation/types.d.ts +83 -0
  53. package/dist/form/validators/date-utils.d.ts +42 -0
  54. package/dist/form/validators/email.d.ts +23 -0
  55. package/dist/form/{validation/validators → validators}/file-type.d.ts +10 -10
  56. package/dist/form/{validation/validators → validators}/file-utils.d.ts +3 -2
  57. package/dist/form/validators/future-date.d.ts +23 -0
  58. package/dist/form/{validation/validators → validators}/index.d.ts +7 -4
  59. package/dist/form/validators/integer.d.ts +22 -0
  60. package/dist/form/validators/is-date.d.ts +24 -0
  61. package/dist/form/validators/is-number.d.ts +25 -0
  62. package/dist/form/validators/max-age.d.ts +28 -0
  63. package/dist/form/validators/max-date.d.ts +25 -0
  64. package/dist/form/{validation/validators → validators}/max-file-size.d.ts +10 -10
  65. package/dist/form/validators/max-files.d.ts +26 -0
  66. package/dist/form/validators/max-length.d.ts +33 -0
  67. package/dist/form/validators/max-total-file-size.d.ts +26 -0
  68. package/dist/form/validators/max.d.ts +26 -0
  69. package/dist/form/validators/min-age.d.ts +27 -0
  70. package/dist/form/validators/min-date.d.ts +25 -0
  71. package/dist/form/{validation/validators → validators}/min-file-size.d.ts +10 -10
  72. package/dist/form/validators/min-files.d.ts +27 -0
  73. package/dist/form/validators/min-length.d.ts +33 -0
  74. package/dist/form/validators/min.d.ts +26 -0
  75. package/dist/form/validators/multiple-of.d.ts +25 -0
  76. package/dist/form/validators/non-negative.d.ts +22 -0
  77. package/dist/form/validators/non-zero.d.ts +22 -0
  78. package/dist/form/validators/past-date.d.ts +23 -0
  79. package/dist/form/validators/pattern.d.ts +26 -0
  80. package/dist/form/{validation/validators → validators}/phone.d.ts +11 -11
  81. package/dist/form/validators/required.d.ts +29 -0
  82. package/dist/form/validators/url.d.ts +45 -0
  83. package/dist/form/validators/validation-issue.d.ts +8 -0
  84. package/dist/i18n/descriptor.d.ts +54 -0
  85. package/dist/i18n/en.json.d.ts +49 -0
  86. package/dist/i18n/loader.d.ts +71 -0
  87. package/dist/i18n/locale-store.d.ts +46 -0
  88. package/dist/i18n/locale.d.ts +90 -0
  89. package/dist/i18n/message-format.d.ts +136 -0
  90. package/dist/i18n/resolve-localized.d.ts +17 -0
  91. package/dist/i18n/ru.json.d.ts +49 -0
  92. package/dist/i18n/translator.d.ts +61 -0
  93. package/dist/i18n/validation-message.d.ts +53 -0
  94. package/dist/i18n.d.ts +26 -0
  95. package/dist/i18n.js +86 -0
  96. package/dist/index.d.ts +17 -5
  97. package/dist/index.js +942 -2601
  98. package/dist/loader-BWkigpVe.js +52 -0
  99. package/dist/locale/en.d.ts +2 -0
  100. package/dist/locale/en.js +5 -0
  101. package/dist/locale/en.json +45 -0
  102. package/dist/locale/index.d.ts +18 -0
  103. package/dist/locale/ru.d.ts +2 -0
  104. package/dist/locale/ru.js +44 -0
  105. package/dist/locale/ru.json +45 -0
  106. package/dist/locale-CG54AU2Q.js +219 -0
  107. package/dist/locale.d.ts +2 -0
  108. package/dist/locale.js +9 -0
  109. package/dist/{state → model}/behaviors-value.d.ts +24 -6
  110. package/dist/{state/form-model.d.ts → model/create-model.d.ts} +18 -4
  111. package/dist/{state → model}/derived-registry.d.ts +1 -1
  112. package/dist/model/index.d.ts +42 -0
  113. package/dist/model/model-nodes.d.ts +190 -0
  114. package/dist/model/model-signals-proxy.d.ts +63 -0
  115. package/dist/model/model-value-proxy.d.ts +84 -0
  116. package/dist/{state → model}/safe-effect.d.ts +50 -2
  117. package/dist/model/types.d.ts +239 -0
  118. package/dist/model.d.ts +2 -0
  119. package/dist/model.js +27 -0
  120. package/dist/node-kind-C-r6ZMdo.js +15 -0
  121. package/dist/platforms/react/field-binding/field-adapter.d.ts +87 -0
  122. package/dist/platforms/react/field-binding/field-handle.d.ts +53 -0
  123. package/dist/platforms/react/form-bundle-context.d.ts +27 -0
  124. package/dist/{form → platforms/react}/hooks/types.d.ts +58 -36
  125. package/dist/platforms/react/hooks/use-form-bundle.d.ts +41 -0
  126. package/dist/platforms/react/hooks/use-form-flow.d.ts +40 -0
  127. package/dist/{form → platforms/react}/hooks/use-form-validation.d.ts +13 -7
  128. package/dist/{form → platforms/react}/hooks/useArrayLength.d.ts +6 -6
  129. package/dist/{form → platforms/react}/hooks/useFormControl.d.ts +7 -9
  130. package/dist/{form → platforms/react}/hooks/useFormControlValue.d.ts +18 -18
  131. package/dist/{form → platforms/react}/hooks/useSignalSubscription.d.ts +9 -1
  132. package/dist/platforms/react/i18n/context.d.ts +18 -0
  133. package/dist/platforms/react/i18n/hooks.d.ts +65 -0
  134. package/dist/platforms/react/i18n/provider.d.ts +59 -0
  135. package/dist/platforms/react/index.d.ts +30 -0
  136. package/dist/react.d.ts +22 -0
  137. package/dist/react.js +505 -0
  138. package/dist/runtime-token.d.ts +1 -2
  139. package/dist/safe-effect-BazLOv1g.js +669 -0
  140. package/dist/schema-controller-CpiO2JoK.js +143 -0
  141. package/dist/signals.d.ts +15 -9
  142. package/dist/signals.js +11 -6
  143. package/dist/strategy-DzvnsWLh.js +375 -0
  144. package/dist/type-guards-D-N_5Ddh.js +19 -0
  145. package/dist/validation-issue-B9mjI8jz.js +7 -0
  146. package/dist/validation-message-Ced9MGxs.js +194 -0
  147. package/dist/validation.d.ts +1 -1
  148. package/dist/validation.js +11 -165
  149. package/dist/validators/email.d.ts +1 -1
  150. package/dist/validators/email.js +5 -8
  151. package/dist/validators/future-date.d.ts +1 -1
  152. package/dist/validators/future-date.js +10 -13
  153. package/dist/validators/integer.d.ts +1 -1
  154. package/dist/validators/integer.js +4 -7
  155. package/dist/validators/is-date.d.ts +1 -1
  156. package/dist/validators/is-date.js +5 -8
  157. package/dist/validators/is-number.d.ts +1 -1
  158. package/dist/validators/is-number.js +4 -7
  159. package/dist/validators/max-age.d.ts +1 -1
  160. package/dist/validators/max-age.js +8 -12
  161. package/dist/validators/max-date.d.ts +1 -1
  162. package/dist/validators/max-date.js +10 -13
  163. package/dist/validators/max-length.d.ts +1 -1
  164. package/dist/validators/max-length.js +7 -10
  165. package/dist/validators/max.d.ts +1 -1
  166. package/dist/validators/max.js +4 -7
  167. package/dist/validators/min-age.d.ts +1 -1
  168. package/dist/validators/min-age.js +10 -11
  169. package/dist/validators/min-date.d.ts +1 -1
  170. package/dist/validators/min-date.js +8 -11
  171. package/dist/validators/min-length.d.ts +1 -1
  172. package/dist/validators/min-length.js +4 -7
  173. package/dist/validators/min.d.ts +1 -1
  174. package/dist/validators/min.js +4 -7
  175. package/dist/validators/multiple-of.d.ts +1 -1
  176. package/dist/validators/multiple-of.js +11 -10
  177. package/dist/validators/non-negative.d.ts +1 -1
  178. package/dist/validators/non-negative.js +2 -5
  179. package/dist/validators/non-zero.d.ts +1 -1
  180. package/dist/validators/non-zero.js +4 -7
  181. package/dist/validators/past-date.d.ts +1 -1
  182. package/dist/validators/past-date.js +10 -13
  183. package/dist/validators/pattern.d.ts +1 -1
  184. package/dist/validators/pattern.js +5 -8
  185. package/dist/validators/phone.d.ts +1 -1
  186. package/dist/validators/phone.js +10 -11
  187. package/dist/validators/required.d.ts +1 -1
  188. package/dist/validators/required.js +4 -7
  189. package/dist/validators/url.d.ts +1 -1
  190. package/dist/validators/url.js +48 -17
  191. package/dist/validators.d.ts +1 -1
  192. package/dist/validators.js +86 -108
  193. package/docs/llms/01-api-reference.md +60 -34
  194. package/docs/llms/02-quick-start.md +112 -74
  195. package/docs/llms/03-api-signatures.md +369 -148
  196. package/docs/llms/04-common-patterns.md +58 -56
  197. package/docs/llms/05-common-mistakes.md +69 -44
  198. package/docs/llms/06-troubleshooting.md +14 -9
  199. package/docs/llms/07-complete-import.md +74 -43
  200. package/docs/llms/08-form-types.md +11 -4
  201. package/docs/llms/09-formschema.md +132 -84
  202. package/docs/llms/10-arrays.md +141 -61
  203. package/docs/llms/11-async-watchfield.md +2 -2
  204. package/docs/llms/13-multi-step.md +134 -63
  205. package/docs/llms/14-extended-mistakes.md +20 -17
  206. package/docs/llms/15-project-structure.md +224 -70
  207. package/docs/llms/16-ui-components.md +86 -46
  208. package/docs/llms/17-nonexistent-api.md +217 -32
  209. package/docs/llms/18-conditional-fields.md +71 -32
  210. package/docs/llms/19-reading-values.md +45 -4
  211. package/docs/llms/20-compute-vs-watch.md +25 -10
  212. package/docs/llms/21-array-operations.md +76 -26
  213. package/docs/llms/22-cycle-detection.md +1 -1
  214. package/docs/llms/23-copy-from.md +2 -2
  215. package/docs/llms/24-sync-fields.md +6 -5
  216. package/docs/llms/25-reset-when.md +14 -7
  217. package/docs/llms/26-transform-value.md +4 -4
  218. package/docs/llms/27-revalidate-when.md +16 -15
  219. package/docs/llms/28-submit-and-reset.md +278 -128
  220. package/docs/llms/29-async-preload.md +41 -31
  221. package/docs/llms/30-type-safety-recipes.md +105 -51
  222. package/docs/llms/31-async-validator-debounce.md +96 -53
  223. package/docs/llms/33-validation-strategy.md +178 -66
  224. package/docs/llms/34-i18n.md +298 -0
  225. package/docs/llms/35-unified-contract.md +309 -0
  226. package/docs/llms/36-issue-messages.md +284 -0
  227. package/docs/llms/37-compiled-schema.md +332 -0
  228. package/docs/llms/38-form-flow.md +396 -0
  229. package/llms-index.json +1 -0
  230. package/llms.txt +10690 -3089
  231. package/package.json +48 -9
  232. package/dist/behaviors-node-DGEFMTQu.js +0 -18
  233. package/dist/behaviors-value-C7dSEhCc.js +0 -134
  234. package/dist/date-utils-dTT_x_Be.js +0 -31
  235. package/dist/derived-registry-CluZCQ7U.js +0 -16
  236. package/dist/form/behaviors.d.ts +0 -133
  237. package/dist/form/error-handler.d.ts +0 -166
  238. package/dist/form/factories/index.d.ts +0 -6
  239. package/dist/form/factories/node-factory.d.ts +0 -188
  240. package/dist/form/form-submitter.d.ts +0 -121
  241. package/dist/form/nodes/array-node.d.ts +0 -276
  242. package/dist/form/nodes/field-node.d.ts +0 -294
  243. package/dist/form/nodes/form-node.d.ts +0 -326
  244. package/dist/form/nodes/group-node.d.ts +0 -284
  245. package/dist/form/nodes/model-array-node.d.ts +0 -121
  246. package/dist/form/status-machine.d.ts +0 -115
  247. package/dist/form/types/deep-schema.d.ts +0 -107
  248. package/dist/form/types/form-proxy.d.ts +0 -141
  249. package/dist/form/unique-id.d.ts +0 -45
  250. package/dist/form/validation/validators/date-utils.d.ts +0 -30
  251. package/dist/form/validation/validators/email.d.ts +0 -23
  252. package/dist/form/validation/validators/future-date.d.ts +0 -23
  253. package/dist/form/validation/validators/integer.d.ts +0 -22
  254. package/dist/form/validation/validators/is-date.d.ts +0 -23
  255. package/dist/form/validation/validators/is-number.d.ts +0 -24
  256. package/dist/form/validation/validators/max-age.d.ts +0 -25
  257. package/dist/form/validation/validators/max-date.d.ts +0 -25
  258. package/dist/form/validation/validators/max-files.d.ts +0 -26
  259. package/dist/form/validation/validators/max-length.d.ts +0 -27
  260. package/dist/form/validation/validators/max-total-file-size.d.ts +0 -26
  261. package/dist/form/validation/validators/max.d.ts +0 -25
  262. package/dist/form/validation/validators/min-age.d.ts +0 -25
  263. package/dist/form/validation/validators/min-date.d.ts +0 -25
  264. package/dist/form/validation/validators/min-files.d.ts +0 -26
  265. package/dist/form/validation/validators/min-length.d.ts +0 -27
  266. package/dist/form/validation/validators/min.d.ts +0 -25
  267. package/dist/form/validation/validators/multiple-of.d.ts +0 -24
  268. package/dist/form/validation/validators/non-negative.d.ts +0 -22
  269. package/dist/form/validation/validators/non-zero.d.ts +0 -22
  270. package/dist/form/validation/validators/past-date.d.ts +0 -23
  271. package/dist/form/validation/validators/pattern.d.ts +0 -33
  272. package/dist/form/validation/validators/required.d.ts +0 -32
  273. package/dist/form/validation/validators/url.d.ts +0 -43
  274. package/dist/form/validation-schema.d.ts +0 -106
  275. package/dist/form/validation-strategy.d.ts +0 -55
  276. package/dist/form/validators.d.ts +0 -11
  277. package/dist/form-model-DYCzGGKF.js +0 -286
  278. package/dist/state/index.d.ts +0 -31
  279. package/dist/state/subscription-manager.d.ts +0 -180
  280. package/dist/state/types.d.ts +0 -144
  281. package/dist/state.d.ts +0 -2
  282. package/dist/state.js +0 -21
  283. package/dist/subscription-manager-705bls97.js +0 -171
package/dist/behaviors.js CHANGED
@@ -1,302 +1,467 @@
1
- import { effect as O } from "@preact/signals-core";
2
- import { d as $, a as S, w as F, t as A, r as C, s as D, b as M } from "./behaviors-value-C7dSEhCc.js";
3
- import { m as k, u as x } from "./derived-registry-CluZCQ7U.js";
4
- import { e as G } from "./behaviors-node-DGEFMTQu.js";
5
- let p = null;
6
- function P(e) {
7
- if (!p)
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-BazLOv1g.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-D05z3my6.js";
5
+ import { g as v } from "./signal-node-registry-tiwel-TV.js";
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) {
23
+ if (!m)
8
24
  throw new Error(
9
25
  `[@reformer/core/behaviors] "${e}" вызван вне defineFormBehavior(...) — операторы поведения можно вызывать только внутри схемы.`
10
26
  );
11
- return p;
27
+ return m;
28
+ }
29
+ function u(e) {
30
+ w("onDispose").cleanups.push(e);
31
+ }
32
+ function p(e) {
33
+ w(e);
34
+ }
35
+ function k(e) {
36
+ m?.cleanups.push(e);
37
+ }
38
+ function ve() {
39
+ const e = w("getScope");
40
+ return R(e);
12
41
  }
13
- function s(e) {
14
- P("onDispose").cleanups.push(e);
42
+ function T(e = "getController") {
43
+ return w(e).controller;
15
44
  }
16
- function y() {
17
- const e = P("getScope");
18
- return { model: e.model, form: e.form };
45
+ function G(e = "getFlow") {
46
+ return w(e).flow;
19
47
  }
20
- function T(e) {
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;
92
+ }
93
+ const R = (e) => ({
94
+ model: e.model,
95
+ form: e.form,
96
+ schema: te(e),
97
+ flow: e.flow
98
+ });
99
+ function ce(e) {
21
100
  return {
22
- __run(n, t) {
23
- const o = { cleanups: [], model: n, form: t }, r = p;
24
- p = o;
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;
25
111
  try {
26
- e({ model: n, form: t });
112
+ C(t.deferred, () => e(R(t)));
113
+ } catch (i) {
114
+ throw D(t), i;
27
115
  } finally {
28
- p = r;
116
+ m = s;
29
117
  }
30
- return () => {
31
- for (const c of o.cleanups) c();
32
- };
118
+ return () => D(t);
33
119
  }
34
120
  };
35
121
  }
36
- function h(e) {
37
- s(O(e));
122
+ function y(e) {
123
+ const n = w("effect"), o = n.deferred;
124
+ n.cleanups.push(N(() => C(o, e)));
38
125
  }
39
- function _(e) {
40
- $(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);
41
136
  }
42
- const m = (e) => typeof e == "object" && e !== null && typeof e.peek == "function", B = (e) => Array.isArray(e) ? e : [e];
43
- function E(e) {
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) {
44
160
  const n = {};
45
- for (const t of Object.keys(e)) {
46
- const o = e[t];
47
- n[t] = m(o) ? o.value : E(o);
161
+ for (const o of Object.keys(e)) {
162
+ const r = e[o];
163
+ n[o] = E(r) ? r.value : W(r);
48
164
  }
49
165
  return n;
50
166
  }
51
- function W(e, n) {
52
- for (const t of Object.keys(e)) {
53
- const o = e[t];
54
- m(o) ? o.value = n?.[t] : W(o, n?.[t] ?? {});
167
+ function q(e, n, o, r = "") {
168
+ if (n == null || typeof n != "object") {
169
+ o?.push(r === "" ? "(вся группа)" : r);
170
+ return;
55
171
  }
56
- }
57
- function I(e) {
58
- if (!e) return;
59
- const { form: n } = y();
60
- return n.getFieldByPath(e);
61
- }
62
- function V(e) {
63
- return new Proxy(
64
- {},
65
- {
66
- get: (n, t) => {
67
- if (t === "$") return e;
68
- if (typeof t != "string") return;
69
- const o = e[t];
70
- if (o != null)
71
- return m(o) ? o.value : V(o);
72
- }
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;
73
177
  }
74
- );
178
+ const s = e[c];
179
+ E(s) ? s.value = n[c] : q(s, n[c], o, t);
180
+ }
75
181
  }
76
- function j(e) {
182
+ function x(e) {
77
183
  return (n) => {
78
184
  try {
79
185
  n();
80
- } catch (t) {
81
- if (t instanceof Error && /cycle detected/i.test(t.message)) {
82
- const o = e.__path ?? "?";
186
+ } catch (o) {
187
+ if (o instanceof Error && /cycle detected/i.test(o.message)) {
188
+ const r = e.__path ?? "?";
83
189
  throw new Error(
84
- `[@reformer/core/behaviors] compute("${o}"): расходящийся цикл пересчёта — взаимные compute/computeFrom без стабилизации. Проверьте зависимости или добавьте стабилизирующее условие (when) / разорвите цикл через peek.`
190
+ `[@reformer/core/behaviors] compute("${r}"): расходящийся цикл пересчёта — взаимные compute/computeFrom без стабилизации. Проверьте зависимости или добавьте стабилизирующее условие (when) / разорвите цикл через peek.`
85
191
  );
86
192
  }
87
- throw t;
193
+ throw o;
88
194
  }
89
195
  };
90
196
  }
91
- function U(e, n, t) {
92
- k(e), s(() => x(e));
93
- const o = j(e);
94
- h(() => {
95
- if (t?.when && !t.when()) return;
96
- const r = n();
97
- e.peek() !== r && o(() => {
98
- 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;
99
205
  });
100
206
  });
101
207
  }
102
- function X(e, n, t, o) {
103
- k(n), s(() => x(n));
104
- const r = j(n);
105
- h(() => {
106
- const c = e.map((f) => f.value);
107
- if (o?.when && !o.when(...c)) return;
108
- const i = t(...c);
109
- n.peek() !== i && r(() => {
110
- n.value = i;
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;
111
217
  });
112
218
  });
113
219
  }
114
- function Y(e, n, t) {
115
- if (m(e) && m(n)) {
116
- s(S(e, n, t));
220
+ function ge(e, n, o) {
221
+ if (p("copyFrom"), E(e) && E(n)) {
222
+ u(Y(e, n, o));
117
223
  return;
118
224
  }
119
- const o = e, r = n;
120
- h(() => {
121
- const c = E(o);
122
- t?.when && !t.when() || _(() => W(r, c));
123
- });
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());
124
236
  }
125
- function R(e, n, t) {
126
- let o;
127
- const r = (c) => {
128
- o?.abort(), o = new AbortController();
129
- const { signal: i } = o;
130
- $(() => n(c, { signal: i }));
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 }));
131
244
  };
132
- if (!t?.debounce)
133
- s(F(e, r, { immediate: t?.immediate }));
245
+ if (!o?.debounce)
246
+ u(M(e, t, { immediate: o?.immediate }));
134
247
  else {
135
- let c;
136
- const i = F(
248
+ let s;
249
+ const i = M(
137
250
  e,
138
251
  (f) => {
139
- c && clearTimeout(c), c = setTimeout(() => r(f), t.debounce);
252
+ r?.abort(), s && clearTimeout(s), s = setTimeout(() => t(f), o.debounce);
140
253
  },
141
- { immediate: t?.immediate }
254
+ { immediate: o?.immediate }
142
255
  );
143
- s(() => {
144
- c && clearTimeout(c), i();
256
+ u(() => {
257
+ s && clearTimeout(s), i();
145
258
  });
146
259
  }
147
- s(() => o?.abort());
260
+ u(() => {
261
+ c.cancelAll(), r?.abort();
262
+ });
148
263
  }
149
- function q(e, n, t) {
150
- for (const o of B(e))
151
- m(o) ? s(G(o, n, t)) : z(o, n, t);
264
+ function Ee(e, n, o) {
265
+ p("enableWhen"), J("enableWhen", e, n, o);
152
266
  }
153
- function Z(e, n, t) {
154
- q(e, () => !n(), t);
267
+ function Oe(e, n, o) {
268
+ p("disableWhen"), J("disableWhen", e, () => !n(), o);
155
269
  }
156
- function z(e, n, t) {
157
- const o = I(e.__path);
158
- o && h(() => {
159
- const r = n();
160
- _(() => {
161
- r ? o.enable() : (o.disable(), t?.resetOnDisable && o.reset());
162
- });
163
- });
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);
280
+ }
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);
164
288
  }
165
- function ee(e, n) {
166
- s(A(e, n));
289
+ function _e(e, n) {
290
+ p("transformValue"), u(Z(e, n));
167
291
  }
168
- function te(e, n, t) {
169
- s(C(e, n, t));
292
+ function Fe(e, n, ...o) {
293
+ p("resetWhen"), u(ee(e, n, ...o));
170
294
  }
171
- function ne(e, n, t) {
172
- s(D(e, n, t));
295
+ function We(e, n, o) {
296
+ p("syncFields"), u(ne(e, n, o));
173
297
  }
174
- function oe(e, n) {
175
- s(M(e, n));
298
+ function Se(e, n) {
299
+ p("revalidateWhen"), u(oe(e, n));
176
300
  }
177
- function g(e, n) {
178
- return n.split(".").reduce((t, o) => t?.[o], e);
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) ? "поле-лист" : "не ручка модели";
179
304
  }
180
- function N(e) {
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) {
181
311
  return new Proxy(
182
312
  {},
183
313
  {
184
- get(n, t) {
185
- if (!(typeof t == "symbol" || t === "then"))
314
+ get(n, o) {
315
+ if (!(typeof o == "symbol" || o === "then"))
186
316
  throw new Error(
187
317
  `[@reformer/core/behaviors] applyEach: форма строки массива "${e}" недоступна (form.${String(
188
- t
189
- )}) — массив не материализован в схеме формы. 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) работают и без материализации.`
190
320
  );
191
321
  }
192
322
  }
193
323
  );
194
324
  }
195
- function H(e, n) {
196
- const { model: t, form: o } = y(), r = e.__path;
197
- if (!r) return;
198
- const c = g(t, r);
199
- if (!c) return;
200
- const i = o.getFieldByPath(
201
- r
202
- ), f = i?.length, u = /* @__PURE__ */ new Map();
203
- h(() => {
204
- const d = f ? f.value : c.length, w = /* @__PURE__ */ new Set();
205
- for (let a = 0; a < d; a++) {
206
- const l = c.at(a);
207
- if (l != null && (w.add(l), !u.has(l))) {
208
- const b = i?.at?.(a) ?? N(r);
209
- u.set(l, n.__run(l, b));
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));
210
336
  }
211
337
  }
212
- for (const [a, l] of u)
213
- w.has(a) || (l(), u.delete(a));
214
- }), s(() => {
215
- for (const d of u.values()) d();
216
- u.clear();
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();
342
+ f.clear();
217
343
  });
218
344
  }
219
- function v(e) {
345
+ function S(e) {
220
346
  if (e == null || typeof e != "object") return;
221
347
  const n = e;
222
348
  if (typeof n.at == "function" && typeof n.length == "number") {
223
- const t = n.length;
224
- for (let o = 0; o < t; o++) v(n.at(o));
349
+ const o = n.length;
350
+ for (let r = 0; r < o; r++) S(n.at(r));
225
351
  return;
226
352
  }
227
- for (const t of Object.keys(e)) v(e[t]);
228
- }
229
- function re(e, n) {
230
- const { model: t } = y(), o = e.__path;
231
- if (!o) return;
232
- const r = g(t, o);
233
- r && H(
234
- e,
235
- T(({ model: c }) => {
236
- R(n(c), (i) => {
237
- if (i)
238
- for (let f = 0; f < r.length; f++) {
239
- const u = r.at(f);
240
- if (u && u !== c) {
241
- const d = n(u);
242
- d.peek() && (d.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);
243
381
  }
244
382
  }
245
383
  });
246
384
  })
247
385
  );
248
386
  }
249
- function ce(e, n) {
250
- const { model: t } = y(), o = e.__path;
251
- if (!o) return;
252
- const r = g(t, o);
253
- if (!r) return;
254
- let c = !1, i = 0;
255
- h(() => {
256
- v(r), !c && (c = !0, _(() => {
257
- c = !1;
258
- const f = n(r.toArray());
259
- let u = !1;
260
- for (const { index: d, patch: w } of f) {
261
- const a = r.at(d);
262
- if (a)
263
- for (const [l, b] of Object.entries(w))
264
- a[l] !== b && (a[l] = b, u = !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);
265
403
  }
266
- if (i = u ? i + 1 : 0, i > 50)
267
- throw i = 0, new Error(
268
- `[@reformer/core/behaviors] aggregateInto("${o}"): запись не сходится (>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 должна быть идемпотентной на фикспоинте.`
269
407
  );
270
408
  }));
271
409
  });
272
410
  }
273
- function ie(e, n) {
274
- const { form: t } = y();
275
- for (const o of B(e)) {
276
- const r = o, c = r.__path;
277
- if (!c) continue;
278
- const i = t ? t.getFieldByPath(c) : void 0, f = i ? i.getProxy?.() ?? i : void 0;
279
- s(n.__run(V(r), f));
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));
280
421
  }
281
422
  }
423
+ function He(e, n) {
424
+ k(e.addHideCondition(n));
425
+ }
426
+ function Me(e, n, o) {
427
+ k(e.addEventHandler(n, o));
428
+ }
429
+ function De(e, n) {
430
+ k(e.addRenderEffect(n));
431
+ }
432
+ function Ne(e, n) {
433
+ n();
434
+ }
435
+ function Pe(e, n) {
436
+ k(e.addLifecycleHook("onMount", n));
437
+ }
438
+ function Ve(e, n) {
439
+ k(e.addLifecycleHook("onUnmount", n));
440
+ }
282
441
  export {
283
- ce as aggregateInto,
284
- ie as apply,
285
- H as applyEach,
286
- U as compute,
287
- X as computeFrom,
288
- Y as copyFrom,
289
- _ as defer,
290
- T as defineFormBehavior,
291
- Z as disableWhen,
292
- h as effect,
293
- q as enableWhen,
294
- re as exclusiveFlag,
295
- y as getScope,
296
- R as onChange,
297
- s as onDispose,
298
- te as resetWhen,
299
- oe as revalidateWhen,
300
- ne as syncFields,
301
- ee 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
302
467
  };