@reformer/core 10.2.0 → 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 (285) 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 -27
  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 -91
  42. package/dist/form/types/field-config.d.ts +27 -0
  43. package/dist/form/types/index.d.ts +5 -91
  44. package/dist/form/types/nodes.d.ts +159 -0
  45. package/dist/form/types/schema-node.d.ts +148 -50
  46. package/dist/form/types/validation-schema.d.ts +24 -41
  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 +18 -6
  97. package/dist/index.js +932 -2779
  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 +60 -38
  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 +22 -0
  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 -5
  192. package/dist/validators.js +98 -154
  193. package/docs/llms/01-api-reference.md +89 -0
  194. package/docs/llms/02-quick-start.md +181 -0
  195. package/docs/llms/03-api-signatures.md +494 -0
  196. package/docs/llms/04-common-patterns.md +204 -0
  197. package/docs/llms/05-common-mistakes.md +192 -0
  198. package/docs/llms/06-troubleshooting.md +16 -0
  199. package/docs/llms/07-complete-import.md +130 -0
  200. package/docs/llms/08-form-types.md +54 -0
  201. package/docs/llms/09-formschema.md +191 -0
  202. package/docs/llms/10-arrays.md +241 -0
  203. package/docs/llms/11-async-watchfield.md +53 -0
  204. package/docs/llms/12-array-cleanup.md +31 -0
  205. package/docs/llms/13-multi-step.md +162 -0
  206. package/docs/llms/14-extended-mistakes.md +101 -0
  207. package/docs/llms/15-project-structure.md +279 -0
  208. package/docs/llms/16-ui-components.md +229 -0
  209. package/docs/llms/17-nonexistent-api.md +278 -0
  210. package/docs/llms/18-conditional-fields.md +222 -0
  211. package/docs/llms/19-reading-values.md +100 -0
  212. package/docs/llms/20-compute-vs-watch.md +153 -0
  213. package/docs/llms/21-array-operations.md +163 -0
  214. package/docs/llms/22-cycle-detection.md +86 -0
  215. package/docs/llms/23-copy-from.md +141 -0
  216. package/docs/llms/24-sync-fields.md +115 -0
  217. package/docs/llms/25-reset-when.md +122 -0
  218. package/docs/llms/26-transform-value.md +136 -0
  219. package/docs/llms/27-revalidate-when.md +133 -0
  220. package/docs/llms/28-submit-and-reset.md +409 -0
  221. package/docs/llms/29-async-preload.md +203 -0
  222. package/docs/llms/30-type-safety-recipes.md +213 -0
  223. package/docs/llms/31-async-validator-debounce.md +178 -0
  224. package/docs/llms/32-async-options-loading.md +108 -0
  225. package/docs/llms/33-validation-strategy.md +305 -0
  226. package/docs/llms/34-i18n.md +298 -0
  227. package/docs/llms/35-unified-contract.md +309 -0
  228. package/docs/llms/36-issue-messages.md +284 -0
  229. package/docs/llms/37-compiled-schema.md +332 -0
  230. package/docs/llms/38-form-flow.md +396 -0
  231. package/llms-index.json +1 -0
  232. package/llms.txt +10014 -3826
  233. package/package.json +77 -15
  234. package/dist/behaviors-node-DGEFMTQu.js +0 -18
  235. package/dist/behaviors-value-C7dSEhCc.js +0 -134
  236. package/dist/date-utils-dTT_x_Be.js +0 -31
  237. package/dist/derived-registry-CluZCQ7U.js +0 -16
  238. package/dist/form/behaviors.d.ts +0 -133
  239. package/dist/form/error-handler.d.ts +0 -166
  240. package/dist/form/factories/index.d.ts +0 -6
  241. package/dist/form/factories/node-factory.d.ts +0 -188
  242. package/dist/form/form-submitter.d.ts +0 -125
  243. package/dist/form/nodes/array-node.d.ts +0 -360
  244. package/dist/form/nodes/field-node.d.ts +0 -294
  245. package/dist/form/nodes/form-node.d.ts +0 -340
  246. package/dist/form/nodes/group-node.d.ts +0 -288
  247. package/dist/form/nodes/model-array-node.d.ts +0 -121
  248. package/dist/form/status-machine.d.ts +0 -153
  249. package/dist/form/types/deep-schema.d.ts +0 -116
  250. package/dist/form/types/form-proxy.d.ts +0 -141
  251. package/dist/form/unique-id.d.ts +0 -53
  252. package/dist/form/validation/validators/date-utils.d.ts +0 -30
  253. package/dist/form/validation/validators/email.d.ts +0 -23
  254. package/dist/form/validation/validators/future-date.d.ts +0 -23
  255. package/dist/form/validation/validators/integer.d.ts +0 -22
  256. package/dist/form/validation/validators/is-date.d.ts +0 -23
  257. package/dist/form/validation/validators/is-number.d.ts +0 -24
  258. package/dist/form/validation/validators/max-age.d.ts +0 -25
  259. package/dist/form/validation/validators/max-date.d.ts +0 -25
  260. package/dist/form/validation/validators/max-files.d.ts +0 -26
  261. package/dist/form/validation/validators/max-length.d.ts +0 -27
  262. package/dist/form/validation/validators/max-total-file-size.d.ts +0 -26
  263. package/dist/form/validation/validators/max.d.ts +0 -25
  264. package/dist/form/validation/validators/min-age.d.ts +0 -25
  265. package/dist/form/validation/validators/min-date.d.ts +0 -25
  266. package/dist/form/validation/validators/min-files.d.ts +0 -26
  267. package/dist/form/validation/validators/min-length.d.ts +0 -27
  268. package/dist/form/validation/validators/min.d.ts +0 -25
  269. package/dist/form/validation/validators/multiple-of.d.ts +0 -24
  270. package/dist/form/validation/validators/non-negative.d.ts +0 -22
  271. package/dist/form/validation/validators/non-zero.d.ts +0 -22
  272. package/dist/form/validation/validators/past-date.d.ts +0 -23
  273. package/dist/form/validation/validators/pattern.d.ts +0 -33
  274. package/dist/form/validation/validators/required.d.ts +0 -32
  275. package/dist/form/validation/validators/url.d.ts +0 -43
  276. package/dist/form/validation-schema.d.ts +0 -106
  277. package/dist/form/validation-strategy.d.ts +0 -55
  278. package/dist/form/validators.d.ts +0 -6
  279. package/dist/form-model-DYCzGGKF.js +0 -286
  280. package/dist/state/index.d.ts +0 -31
  281. package/dist/state/subscription-manager.d.ts +0 -180
  282. package/dist/state/types.d.ts +0 -144
  283. package/dist/state.d.ts +0 -2
  284. package/dist/state.js +0 -21
  285. package/dist/subscription-manager-705bls97.js +0 -171
@@ -0,0 +1,143 @@
1
+ import { signal as v } from "@preact/signals-core";
2
+ const h = /* @__PURE__ */ new WeakMap();
3
+ function y(t) {
4
+ let s = h.get(t);
5
+ return s || (s = { hide: /* @__PURE__ */ new Map(), events: /* @__PURE__ */ new Map(), hooks: /* @__PURE__ */ new Map() }, h.set(t, s)), s;
6
+ }
7
+ function a(t, s) {
8
+ const e = t.lastIndexOf(s);
9
+ return e !== -1 && t.splice(e, 1), t.length === 0;
10
+ }
11
+ function R() {
12
+ const t = /* @__PURE__ */ new Map();
13
+ return {
14
+ hiddenOverrides: /* @__PURE__ */ new Map(),
15
+ propsOverrides: /* @__PURE__ */ new Map(),
16
+ refRegistry: /* @__PURE__ */ new Map(),
17
+ conditionRegistry: /* @__PURE__ */ new Map(),
18
+ effectRegistry: [],
19
+ callbackRegistry: /* @__PURE__ */ new Map(),
20
+ lifecycleRegistry: /* @__PURE__ */ new Map(),
21
+ version: v(0),
22
+ versionFor(s) {
23
+ let e = t.get(s);
24
+ return e || (e = v(0), t.set(s, e)), e;
25
+ }
26
+ };
27
+ }
28
+ function w(t = R()) {
29
+ const s = (e) => {
30
+ t.version.value++, t.versionFor(e).value++;
31
+ };
32
+ return {
33
+ __overrideMaps: t,
34
+ addRenderEffect(e) {
35
+ return t.effectRegistry.push(e), () => {
36
+ const n = t.effectRegistry.indexOf(e);
37
+ n !== -1 && t.effectRegistry.splice(n, 1);
38
+ };
39
+ },
40
+ node: (e) => ({
41
+ setHidden(n) {
42
+ return t.hiddenOverrides.get(e) === n ? this : (t.hiddenOverrides.set(e, n), s(e), this);
43
+ },
44
+ resetHidden() {
45
+ return t.hiddenOverrides.delete(e) && s(e), this;
46
+ },
47
+ patchProps(n) {
48
+ const d = t.propsOverrides.get(e);
49
+ return d != null && Object.keys(n).every(
50
+ (i) => i in d && Object.is(d[i], n[i])
51
+ ) ? this : (t.propsOverrides.set(e, { ...d ?? {}, ...n }), s(e), this);
52
+ },
53
+ resetProps() {
54
+ return t.propsOverrides.delete(e) && s(e), this;
55
+ },
56
+ getRef() {
57
+ let n = t.refRegistry.get(e);
58
+ return n || (n = { current: null }, t.refRegistry.set(e, n)), n;
59
+ },
60
+ addHideCondition(n) {
61
+ const { hide: d } = y(t);
62
+ let r = d.get(e);
63
+ if (!r) {
64
+ const c = v([]);
65
+ r = c, d.set(e, c), t.conditionRegistry.set(e, () => c.value.some((f) => f()));
66
+ }
67
+ r.value = [...r.value, n];
68
+ const i = r;
69
+ return () => {
70
+ const c = [...i.value];
71
+ if (!a(c, n)) {
72
+ i.value = c;
73
+ return;
74
+ }
75
+ i.value = c, d.get(e) === i && (d.delete(e), t.conditionRegistry.delete(e));
76
+ };
77
+ },
78
+ addEventHandler(n, d) {
79
+ const { events: r } = y(t);
80
+ let i = r.get(e);
81
+ i || r.set(e, i = /* @__PURE__ */ new Map());
82
+ let c = i.get(n);
83
+ c || i.set(n, c = []), c.push(d);
84
+ let f = t.callbackRegistry.get(e);
85
+ f || t.callbackRegistry.set(e, f = /* @__PURE__ */ new Map()), f.set(n, d);
86
+ const o = c, u = i;
87
+ return () => {
88
+ const g = a(o, d), l = t.callbackRegistry.get(e);
89
+ if (!g) {
90
+ l?.set(n, o[o.length - 1]);
91
+ return;
92
+ }
93
+ u.delete(n), l?.delete(n), l?.size === 0 && t.callbackRegistry.delete(e), u.size === 0 && r.delete(e);
94
+ };
95
+ },
96
+ addLifecycleHook(n, d) {
97
+ const { hooks: r } = y(t);
98
+ let i = r.get(e);
99
+ i || r.set(e, i = /* @__PURE__ */ new Map());
100
+ let c = i.get(n);
101
+ c || i.set(n, c = []), c.push(d), t.lifecycleRegistry.set(e, {
102
+ ...t.lifecycleRegistry.get(e) ?? {},
103
+ [n]: d
104
+ });
105
+ const f = c, o = i;
106
+ return () => {
107
+ const u = a(f, d), g = { ...t.lifecycleRegistry.get(e) ?? {} };
108
+ u ? (o.delete(n), delete g[n]) : g[n] = f[f.length - 1], Object.keys(g).length === 0 ? t.lifecycleRegistry.delete(e) : t.lifecycleRegistry.set(e, g), o.size === 0 && r.delete(e);
109
+ };
110
+ },
111
+ __selector: e,
112
+ __overrideMaps: t
113
+ })
114
+ };
115
+ }
116
+ function O() {
117
+ const t = /* @__PURE__ */ new WeakMap();
118
+ return {
119
+ scopeOf(s) {
120
+ let e = t.get(s);
121
+ return e || (e = w(), t.set(s, e)), e;
122
+ }
123
+ };
124
+ }
125
+ function M(t, s) {
126
+ const e = [s];
127
+ for (let r = 0; r < e.length; r++)
128
+ for (const i of e[r].nodes.values())
129
+ s.model !== void 0 && i.kind === "part" && i.content.model === s.model && e.push(i.content);
130
+ const n = (r) => e.some((i) => i.nodes.get(r)?.selector === r);
131
+ return [.../* @__PURE__ */ new Set([
132
+ ...t.hiddenOverrides.keys(),
133
+ ...t.propsOverrides.keys(),
134
+ ...t.conditionRegistry.keys(),
135
+ ...t.callbackRegistry.keys(),
136
+ ...t.lifecycleRegistry.keys()
137
+ ])].filter((r) => !n(r));
138
+ }
139
+ export {
140
+ w as a,
141
+ O as c,
142
+ M as u
143
+ };
package/dist/signals.d.ts CHANGED
@@ -1,13 +1,19 @@
1
+ import { ReadonlySignal } from '@preact/signals-core';
2
+ export { signal, computed, effect, batch, untracked, Signal } from '@preact/signals-core';
3
+ export type { ReadonlySignal } from '@preact/signals-core';
1
4
  /**
2
- * Единая точка владения реактивным рантаймом @preact/signals-core.
5
+ * Значение — сигнал: результат `signal()` или `computed()`, в том числе созданный другой копией
6
+ * рантайма.
3
7
  *
4
- * Другие @reformer/* пакеты (например renderer-react) импортируют Signal и примитивы
5
- * ОТСЮДА (`@reformer/core/signals`), а НЕ напрямую из `@preact/signals-core`. Так
6
- * гарантируется одна копия рантайма и единая идентичность класса `Signal` через границы
7
- * пакетов — это критично для проверок вида `value instanceof Signal` над сигналами,
8
- * созданными внутри @reformer/core.
8
+ * Контейнерные узлы дерева `model.$` (группа, массив) тоже проходят проверку: это сигналы
9
+ * агрегированного значения. Лист от контейнера отличает `isModelContainerSignal`, а ручку, к
10
+ * которой можно привязать поле, — `isValueSignal` (оба — из `@reformer/core`).
9
11
  *
10
- * @module reformer/signals
12
+ * @example
13
+ * ```typescript
14
+ * isSignal(signal(1)); // true
15
+ * isSignal(computed(() => 1)); // true
16
+ * isSignal({ value: 1 }); // false
17
+ * ```
11
18
  */
12
- export { signal, computed, effect, batch, untracked, Signal } from '@preact/signals-core';
13
- export type { ReadonlySignal } from '@preact/signals-core';
19
+ export declare function isSignal(value: unknown): value is ReadonlySignal<unknown>;
package/dist/signals.js CHANGED
@@ -1,9 +1,14 @@
1
- import { Signal as a, batch as c, computed as f, effect as n, signal as o, untracked as r } from "@preact/signals-core";
1
+ import { Signal as e, batch as a, computed as f, effect as i, signal as l, untracked as p } from "@preact/signals-core";
2
+ const n = Symbol.for("preact-signals");
3
+ function o(t) {
4
+ return typeof t == "object" && t !== null && t.brand === n;
5
+ }
2
6
  export {
3
- a as Signal,
4
- c as batch,
7
+ e as Signal,
8
+ a as batch,
5
9
  f as computed,
6
- n as effect,
7
- o as signal,
8
- r as untracked
10
+ i as effect,
11
+ o as isSignal,
12
+ l as signal,
13
+ p as untracked
9
14
  };
@@ -0,0 +1,375 @@
1
+ import { batch as F, signal as X, effect as Y, untracked as Z } from "@preact/signals-core";
2
+ import { a as ee } from "./create-model-DPSG3I0O.js";
3
+ import { g as p } from "./signal-node-registry-tiwel-TV.js";
4
+ import { n as te, m as L, o as ne, f as oe } from "./safe-effect-BazLOv1g.js";
5
+ let k = null;
6
+ function B(e, n) {
7
+ const t = k;
8
+ k = e;
9
+ try {
10
+ return n();
11
+ } finally {
12
+ k = t;
13
+ }
14
+ }
15
+ function h(e) {
16
+ if (!k)
17
+ throw new Error(
18
+ `[@reformer/core/validation] "${e}" вызван вне схемы валидации — операторы валидации можно вызывать только внутри прогона validateModel(...) (напрямую или через apply/each).`
19
+ );
20
+ return k;
21
+ }
22
+ function W(e, n) {
23
+ let t = e.origins.get(n);
24
+ t || e.origins.set(n, t = /* @__PURE__ */ new Map());
25
+ let o = t.get(e.origin);
26
+ return o || t.set(e.origin, o = []), o;
27
+ }
28
+ function j(e, n, t) {
29
+ const o = e.origin;
30
+ e.origin = n, e.executed.add(n);
31
+ try {
32
+ t();
33
+ } finally {
34
+ e.origin = o;
35
+ }
36
+ }
37
+ const se = (e) => e.whenStack.every((n) => n());
38
+ function I(e, n) {
39
+ return se(e) ? (e.checked.add(n), !0) : !1;
40
+ }
41
+ function be(e, n) {
42
+ const t = h("validate"), o = W(t, e);
43
+ if (!I(t, e)) return;
44
+ const i = e.peek();
45
+ for (const s of n) {
46
+ const r = s(i);
47
+ r && o.push(r);
48
+ }
49
+ }
50
+ const _ = "ruleFailed";
51
+ function me(e, n) {
52
+ const t = h("validateAsync"), o = e, i = W(t, o);
53
+ if (!I(t, o)) return;
54
+ const s = e.peek(), r = t.signal;
55
+ t.asyncFields.add(o);
56
+ for (const a of n)
57
+ t.pending.push(
58
+ // Вызов внутри исполнителя промиса: синхронное исключение правила — такой же сбой.
59
+ new Promise((c) => c(a(s, { signal: r }))).then(
60
+ (c) => {
61
+ c && !r.aborted && i.push(c);
62
+ },
63
+ (c) => {
64
+ r.aborted || (t.failures.push({ handle: o, error: c }), i.some((u) => u.code === _) || i.push({ code: _ }));
65
+ }
66
+ )
67
+ );
68
+ }
69
+ function Oe(e, n) {
70
+ const t = h("validateWhen");
71
+ t.whenStack.push(e);
72
+ try {
73
+ n();
74
+ } finally {
75
+ t.whenStack.pop();
76
+ }
77
+ }
78
+ function ie(e, n, t) {
79
+ const o = h("cross"), i = W(o, n);
80
+ if (!I(o, n)) return;
81
+ const s = t(e.get());
82
+ s && i.push(s);
83
+ }
84
+ function V(e) {
85
+ return {
86
+ model: e,
87
+ cross: (n, t) => ie(e, n, t)
88
+ };
89
+ }
90
+ function C(e, n, t) {
91
+ const o = n, i = { ...e, model: o };
92
+ B(
93
+ i,
94
+ () => j(i, t, () => t(V(o)))
95
+ );
96
+ }
97
+ function re(e, n) {
98
+ const t = ne(n);
99
+ if (!t)
100
+ throw new TypeError(
101
+ `[@reformer/core/validation] ${e}: ожидался массив под-форм модели — \`model.$.<массив>\`. Массив примитивов — одно значение поля, его проверяют целиком: \`validate(model.$.<массив>, [...])\`.`
102
+ );
103
+ return L(t);
104
+ }
105
+ function Se(e, n) {
106
+ const t = h("applyEach"), o = re("applyEach", e), i = o.length;
107
+ for (let s = 0; s < i; s++) C(t, o.at(s), n);
108
+ }
109
+ function Ee(...e) {
110
+ const n = h("apply");
111
+ if (typeof e[0] == "function") {
112
+ for (const i of e)
113
+ j(n, i, () => i(V(n.model)));
114
+ return;
115
+ }
116
+ const [t, o] = e;
117
+ for (const i of Array.isArray(t) ? t : [t]) {
118
+ const s = te(i);
119
+ if (!s)
120
+ throw new TypeError(
121
+ "[@reformer/core/validation] apply: ожидалась группа модели — `model.$.<группа>`. Массив под-форм подключают через `applyEach`."
122
+ );
123
+ C(n, L(s), o);
124
+ }
125
+ }
126
+ function Me(e) {
127
+ return e;
128
+ }
129
+ const S = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), b = {}, $ = {}, U = /* @__PURE__ */ new WeakMap();
130
+ function ae(e) {
131
+ const n = /* @__PURE__ */ new Set(), t = [];
132
+ for (const o of e)
133
+ for (const i of o) {
134
+ const s = JSON.stringify([i.code, i.severity ?? null, i.params ?? null]);
135
+ n.has(s) || (n.add(s), t.push(i));
136
+ }
137
+ return t;
138
+ }
139
+ function M(e, n, t, o, i, s = !1) {
140
+ const r = E.get(e), a = n.ownIssues?.peek() ?? [], c = r !== void 0 && a === r.written, u = c ? r.byOrigin : /* @__PURE__ */ new Map();
141
+ if (!c && s && a.length > 0 && u.set($, a), u.delete(b), t === void 0) {
142
+ for (const l of [...u.keys()]) l !== $ && u.delete(l);
143
+ i !== void 0 && i.length > 0 && u.set(b, i);
144
+ } else {
145
+ for (const l of t.executed) u.delete(l);
146
+ o?.forEach((l, v) => {
147
+ l.length > 0 && u.set(v, l);
148
+ });
149
+ }
150
+ const f = u.size === 0 ? [] : ae(u.values());
151
+ n.setIssues(f), E.set(e, { byOrigin: u, written: n.ownIssues?.peek() ?? f });
152
+ }
153
+ function N(e, n, t, o) {
154
+ const i = p(e), s = t === void 0 ? void 0 : n?.origins.get(e);
155
+ if (i === void 0) {
156
+ if (s?.forEach((r, a) => {
157
+ const c = o.get(a) ?? [];
158
+ c.push(...r), o.set(a, c);
159
+ }), n === void 0 && t !== void 0) {
160
+ const r = o.get(b) ?? [];
161
+ r.push(...t), o.set(b, r);
162
+ }
163
+ return;
164
+ }
165
+ M(e, i, n, s, t);
166
+ }
167
+ function ce(e, n, t) {
168
+ if (e === void 0) return;
169
+ const o = p(e.$);
170
+ if (o !== void 0 && !(t.size === 0 && !E.has(o))) {
171
+ if (n === void 0) {
172
+ M(o, o, void 0, void 0, t.get(b) ?? [], !0);
173
+ return;
174
+ }
175
+ M(o, o, n, t, void 0, !0);
176
+ }
177
+ }
178
+ function ue(e, n) {
179
+ let t = S.get(e);
180
+ t || S.set(e, t = /* @__PURE__ */ new WeakMap());
181
+ let o = t.get(n);
182
+ return o || t.set(n, o = { fields: /* @__PURE__ */ new Set(), ac: null }), o;
183
+ }
184
+ const fe = (e) => {
185
+ for (const n of e.values()) for (const t of n) if (t.severity !== "warning") return !0;
186
+ return !1;
187
+ };
188
+ function le(e) {
189
+ return e.aborted ? Promise.resolve() : new Promise((n) => {
190
+ e.addEventListener("abort", () => n(), { once: !0 });
191
+ });
192
+ }
193
+ const P = (e) => e !== null && typeof e == "object" && p(e)?.disabled?.peek() === !0;
194
+ function D(e, n) {
195
+ if (n.__path === "") return P(n);
196
+ let t = e.$;
197
+ for (const o of n.__path.split("."))
198
+ if (t === null || typeof t != "object" || (t = t[o], P(t))) return !0;
199
+ return t !== n;
200
+ }
201
+ function de(e, n, t, o, i) {
202
+ for (const s of n.keys())
203
+ D(e, s) && (n.set(s, []), i.get(s)?.forEach((r, a, c) => c.set(a, [])), o.delete(s));
204
+ for (let s = t.length - 1; s >= 0; s--)
205
+ D(e, t[s].handle) && t.splice(s, 1);
206
+ }
207
+ function pe(e, n) {
208
+ S.get(e)?.get(n)?.ac?.abort();
209
+ }
210
+ let A = 0;
211
+ function q(e) {
212
+ A++;
213
+ try {
214
+ F(e);
215
+ } finally {
216
+ A--;
217
+ }
218
+ }
219
+ const ge = () => A > 0;
220
+ async function J(e, n, t, o = !1) {
221
+ const i = ue(e, n);
222
+ i.ac?.abort();
223
+ const s = new AbortController();
224
+ i.ac = s;
225
+ const r = [], a = {
226
+ model: e,
227
+ issues: /* @__PURE__ */ new Map(),
228
+ checked: /* @__PURE__ */ new Set(),
229
+ pending: [],
230
+ asyncFields: /* @__PURE__ */ new Set(),
231
+ failures: r,
232
+ whenStack: [],
233
+ signal: s.signal,
234
+ origin: n,
235
+ origins: /* @__PURE__ */ new Map(),
236
+ executed: /* @__PURE__ */ new Set([n])
237
+ };
238
+ B(a, () => n(V(e)));
239
+ const c = [];
240
+ if (t) {
241
+ for (const f of a.asyncFields) {
242
+ const l = p(f);
243
+ l && c.push(l);
244
+ }
245
+ for (const f of c) f.setPending(!0);
246
+ }
247
+ a.pending.length ? await Promise.race([Promise.all(a.pending), le(s.signal)]) : o && await oe();
248
+ for (const [f, l] of a.origins) a.issues.set(f, [...l.values()].flat());
249
+ o && de(e, a.issues, r, a.checked, a.origins);
250
+ const u = {
251
+ status: s.signal.aborted ? "cancelled" : r.length > 0 ? "error" : fe(a.issues) ? "invalid" : "valid",
252
+ issues: a.issues,
253
+ failures: r
254
+ };
255
+ return G.set(u, i), z.set(u, a.checked), H.set(u, { origins: a.origins, executed: a.executed }), U.set(u, e), {
256
+ result: u,
257
+ release: () => {
258
+ for (const f of c) f.setPending(!1);
259
+ }
260
+ };
261
+ }
262
+ async function Ae(e, n) {
263
+ return (await J(e, n, !1)).result;
264
+ }
265
+ function he(e, n) {
266
+ if (e.status === "cancelled") return;
267
+ const t = G.get(e), o = new Set(e.issues.keys()), i = z.get(e) ?? o, s = H.get(e), r = () => {
268
+ const a = /* @__PURE__ */ new Map();
269
+ if (t)
270
+ for (const c of t.fields)
271
+ o.has(c) || N(c, s, void 0, a);
272
+ for (const [c, u] of e.issues) N(c, s, u, a);
273
+ if (ce(U.get(e), s, a), n?.touch) for (const c of i) p(c)?.markAsTouched();
274
+ };
275
+ n?.touch ? q(r) : F(r), t && (t.fields = o);
276
+ }
277
+ async function K(e, n, t) {
278
+ const { result: o, release: i } = await J(e, n, !0, t?.skipDisabled), s = t?.touch ?? !1, r = () => {
279
+ he(o, { touch: s !== !1 }), s === "all" && (o.status === "invalid" || o.status === "error") && p(e.$)?.markAsTouched(), i();
280
+ };
281
+ return s !== !1 ? q(r) : F(r), o;
282
+ }
283
+ async function Fe(e, n, t) {
284
+ return (await K(e, n, t)).status === "valid";
285
+ }
286
+ function We(e, n, t = {}) {
287
+ const { strategy: o = "submit", debounce: i = 0, liveAfterSubmit: s = "change" } = t, r = X(!1);
288
+ let a = 0, c = !1, u, f;
289
+ const l = async (d) => {
290
+ a++, r.value = !0;
291
+ try {
292
+ return await K(e, n, { touch: d, skipDisabled: !0 });
293
+ } finally {
294
+ --a === 0 && (r.value = !1);
295
+ }
296
+ }, v = () => {
297
+ l(!1).catch((d) => {
298
+ process.env.NODE_ENV !== "production" && console.error(
299
+ "[@reformer/core/validation] живой прогон схемы завершился исключением",
300
+ d
301
+ );
302
+ });
303
+ }, Q = () => {
304
+ if (!i) {
305
+ v();
306
+ return;
307
+ }
308
+ f && clearTimeout(f), f = setTimeout(v, i);
309
+ }, x = (d, g, y) => {
310
+ let O = !0;
311
+ return Y(() => {
312
+ if (y?.(), ee(e, d), O) {
313
+ O = !1;
314
+ return;
315
+ }
316
+ o === "afterFirstSubmit" && !c || Z(g);
317
+ });
318
+ }, m = {
319
+ async validate() {
320
+ return (await m.run()).status === "valid";
321
+ },
322
+ run(d) {
323
+ return d?.submit && (c = !0), l(d?.touch ?? !0);
324
+ },
325
+ start() {
326
+ if (u) return () => m.dispose();
327
+ const d = o === "afterFirstSubmit" ? s : o;
328
+ if (d === "change")
329
+ u = x((g) => void g.value, Q);
330
+ else if (d === "blur") {
331
+ const g = /* @__PURE__ */ new WeakMap();
332
+ let y = !1;
333
+ u = x(
334
+ (O) => {
335
+ const w = p(O);
336
+ if (w === void 0) return;
337
+ const R = w.touches?.value ?? (w.touched.value ? 1 : 0), T = g.get(w);
338
+ T !== void 0 && R > T && (y = !0), g.set(w, R);
339
+ },
340
+ () => {
341
+ y && !ge() && v();
342
+ },
343
+ () => {
344
+ y = !1;
345
+ }
346
+ );
347
+ }
348
+ return () => m.dispose();
349
+ },
350
+ dispose() {
351
+ f && (clearTimeout(f), f = void 0), u?.(), u = void 0, pe(e, n);
352
+ },
353
+ get isValidating() {
354
+ return r.value;
355
+ },
356
+ get validating() {
357
+ return r;
358
+ }
359
+ };
360
+ return m;
361
+ }
362
+ export {
363
+ me as a,
364
+ Oe as b,
365
+ Ee as c,
366
+ Se as d,
367
+ Me as e,
368
+ he as f,
369
+ Fe as g,
370
+ We as h,
371
+ pe as i,
372
+ K as j,
373
+ Ae as r,
374
+ be as v
375
+ };
@@ -0,0 +1,19 @@
1
+ import { k as o } from "./node-kind-C-r6ZMdo.js";
2
+ function i(r) {
3
+ return o(r) !== void 0;
4
+ }
5
+ function t(r) {
6
+ return o(r) === "control";
7
+ }
8
+ function u(r) {
9
+ return o(r) === "group";
10
+ }
11
+ function a(r) {
12
+ return o(r) === "array";
13
+ }
14
+ export {
15
+ t as a,
16
+ u as b,
17
+ a as c,
18
+ i
19
+ };
@@ -0,0 +1,7 @@
1
+ function c(a, e, d) {
2
+ const r = d === void 0 ? e?.params : { ...d, ...e?.params };
3
+ return r === void 0 ? { code: e?.code ?? a } : { code: e?.code ?? a, params: r };
4
+ }
5
+ export {
6
+ c as v
7
+ };