@reformer/core 11.0.0-beta.7 → 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 (226) hide show
  1. package/README.md +90 -68
  2. package/dist/behaviors-value-HA_Q03hc.js +108 -0
  3. package/dist/behaviors.js +382 -217
  4. package/dist/create-model-BvcbNPgL.js +30 -0
  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 +42 -8
  9. package/dist/form/behaviors/context.d.ts +37 -4
  10. package/dist/form/behaviors/index.d.ts +6 -4
  11. package/dist/form/behaviors/internals.d.ts +9 -3
  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 +78 -0
  15. package/dist/form/behaviors/types.d.ts +25 -5
  16. package/dist/form/create-form.d.ts +57 -70
  17. package/dist/form/flow/flow.d.ts +87 -0
  18. package/dist/form/form-bundle.d.ts +153 -0
  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 +20 -20
  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 +153 -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 +19 -92
  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 +23 -27
  47. package/dist/form/validation/context.d.ts +46 -6
  48. package/dist/form/validation/index.d.ts +9 -8
  49. package/dist/form/validation/operators.d.ts +71 -17
  50. package/dist/form/validation/run.d.ts +93 -18
  51. package/dist/form/validation/strategy.d.ts +41 -13
  52. package/dist/form/validation/types.d.ts +74 -19
  53. package/dist/form/validators/date-utils.d.ts +13 -1
  54. package/dist/form/validators/email.d.ts +8 -7
  55. package/dist/form/validators/file-type.d.ts +8 -7
  56. package/dist/form/validators/file-utils.d.ts +2 -1
  57. package/dist/form/validators/future-date.d.ts +8 -7
  58. package/dist/form/validators/index.d.ts +1 -1
  59. package/dist/form/validators/integer.d.ts +8 -7
  60. package/dist/form/validators/is-date.d.ts +11 -9
  61. package/dist/form/validators/is-number.d.ts +11 -9
  62. package/dist/form/validators/max-age.d.ts +13 -9
  63. package/dist/form/validators/max-date.d.ts +8 -7
  64. package/dist/form/validators/max-file-size.d.ts +8 -7
  65. package/dist/form/validators/max-files.d.ts +8 -7
  66. package/dist/form/validators/max-length.d.ts +14 -7
  67. package/dist/form/validators/max-total-file-size.d.ts +8 -7
  68. package/dist/form/validators/max.d.ts +10 -8
  69. package/dist/form/validators/min-age.d.ts +12 -9
  70. package/dist/form/validators/min-date.d.ts +8 -7
  71. package/dist/form/validators/min-file-size.d.ts +8 -7
  72. package/dist/form/validators/min-files.d.ts +11 -9
  73. package/dist/form/validators/min-length.d.ts +14 -7
  74. package/dist/form/validators/min.d.ts +10 -8
  75. package/dist/form/validators/multiple-of.d.ts +10 -8
  76. package/dist/form/validators/non-negative.d.ts +8 -7
  77. package/dist/form/validators/non-zero.d.ts +8 -7
  78. package/dist/form/validators/past-date.d.ts +8 -7
  79. package/dist/form/validators/pattern.d.ts +9 -8
  80. package/dist/form/validators/phone.d.ts +8 -7
  81. package/dist/form/validators/required.d.ts +11 -9
  82. package/dist/form/validators/url.d.ts +20 -13
  83. package/dist/form/validators/validation-issue.d.ts +8 -0
  84. package/dist/i18n/descriptor.d.ts +1 -1
  85. package/dist/i18n/en.json.d.ts +5 -1
  86. package/dist/i18n/locale-store.d.ts +7 -0
  87. package/dist/i18n/message-format.d.ts +24 -4
  88. package/dist/i18n/ru.json.d.ts +5 -1
  89. package/dist/i18n/translator.d.ts +11 -0
  90. package/dist/i18n/validation-message.d.ts +42 -7
  91. package/dist/i18n.d.ts +7 -12
  92. package/dist/i18n.js +66 -283
  93. package/dist/index.d.ts +16 -7
  94. package/dist/index.js +958 -2798
  95. package/dist/loader-BWkigpVe.js +52 -0
  96. package/dist/locale/en.js +1 -1
  97. package/dist/locale/en.json +4 -1
  98. package/dist/locale/ru.js +4 -1
  99. package/dist/locale/ru.json +4 -1
  100. package/dist/locale-CG54AU2Q.js +219 -0
  101. package/dist/locale.js +1 -1
  102. package/dist/model/behaviors-value.d.ts +24 -6
  103. package/dist/model/create-model.d.ts +2 -2
  104. package/dist/model/derived-registry.d.ts +1 -1
  105. package/dist/model/index.d.ts +16 -5
  106. package/dist/model/model-nodes.d.ts +138 -8
  107. package/dist/model/model-signals-proxy.d.ts +11 -5
  108. package/dist/model/model-value-proxy.d.ts +84 -3
  109. package/dist/model/safe-effect.d.ts +33 -1
  110. package/dist/model/types.d.ts +70 -17
  111. package/dist/model.js +21 -17
  112. package/dist/node-kind-C-r6ZMdo.js +15 -0
  113. package/dist/platforms/react/field-binding/field-adapter.d.ts +1 -1
  114. package/dist/platforms/react/field-binding/field-handle.d.ts +5 -2
  115. package/dist/platforms/react/form-bundle-context.d.ts +27 -0
  116. package/dist/platforms/react/hooks/types.d.ts +57 -38
  117. package/dist/platforms/react/hooks/use-form-bundle.d.ts +19 -4
  118. package/dist/platforms/react/hooks/use-form-flow.d.ts +40 -0
  119. package/dist/platforms/react/hooks/use-form-validation.d.ts +12 -6
  120. package/dist/platforms/react/hooks/useArrayLength.d.ts +6 -6
  121. package/dist/platforms/react/hooks/useFormControl.d.ts +7 -9
  122. package/dist/platforms/react/hooks/useFormControlValue.d.ts +18 -19
  123. package/dist/platforms/react/hooks/useSignalSubscription.d.ts +9 -1
  124. package/dist/platforms/react/i18n/context.d.ts +6 -1
  125. package/dist/platforms/react/i18n/hooks.d.ts +16 -10
  126. package/dist/platforms/react/i18n/provider.d.ts +9 -2
  127. package/dist/platforms/react/index.d.ts +7 -4
  128. package/dist/react.d.ts +22 -0
  129. package/dist/react.js +505 -0
  130. package/dist/runtime-token.d.ts +1 -2
  131. package/dist/safe-effect-BbtX3KuN.js +643 -0
  132. package/dist/schema-controller-CpiO2JoK.js +143 -0
  133. package/dist/signals.d.ts +15 -9
  134. package/dist/signals.js +11 -6
  135. package/dist/strategy-CoFSemuP.js +375 -0
  136. package/dist/type-guards-D-N_5Ddh.js +19 -0
  137. package/dist/validation-issue-B9mjI8jz.js +7 -0
  138. package/dist/validation-message-Ced9MGxs.js +194 -0
  139. package/dist/validation.js +9 -8
  140. package/dist/validators/email.js +5 -5
  141. package/dist/validators/future-date.js +8 -8
  142. package/dist/validators/integer.js +3 -3
  143. package/dist/validators/is-date.js +4 -4
  144. package/dist/validators/is-number.js +4 -4
  145. package/dist/validators/max-age.js +8 -9
  146. package/dist/validators/max-date.js +8 -8
  147. package/dist/validators/max-length.js +7 -7
  148. package/dist/validators/max.js +4 -4
  149. package/dist/validators/min-age.js +10 -8
  150. package/dist/validators/min-date.js +3 -3
  151. package/dist/validators/min-length.js +5 -5
  152. package/dist/validators/min.js +4 -4
  153. package/dist/validators/multiple-of.js +11 -7
  154. package/dist/validators/non-negative.js +3 -3
  155. package/dist/validators/non-zero.js +3 -3
  156. package/dist/validators/past-date.js +8 -8
  157. package/dist/validators/pattern.js +5 -5
  158. package/dist/validators/phone.js +11 -9
  159. package/dist/validators/required.js +2 -2
  160. package/dist/validators/url.js +48 -12
  161. package/dist/validators.js +17 -17
  162. package/docs/llms/01-api-reference.md +60 -34
  163. package/docs/llms/02-quick-start.md +111 -80
  164. package/docs/llms/03-api-signatures.md +368 -153
  165. package/docs/llms/04-common-patterns.md +58 -56
  166. package/docs/llms/05-common-mistakes.md +69 -44
  167. package/docs/llms/06-troubleshooting.md +14 -9
  168. package/docs/llms/07-complete-import.md +74 -43
  169. package/docs/llms/08-form-types.md +11 -4
  170. package/docs/llms/09-formschema.md +131 -83
  171. package/docs/llms/10-arrays.md +119 -69
  172. package/docs/llms/11-async-watchfield.md +2 -2
  173. package/docs/llms/13-multi-step.md +134 -63
  174. package/docs/llms/14-extended-mistakes.md +20 -17
  175. package/docs/llms/15-project-structure.md +221 -74
  176. package/docs/llms/16-ui-components.md +55 -42
  177. package/docs/llms/17-nonexistent-api.md +199 -32
  178. package/docs/llms/18-conditional-fields.md +66 -32
  179. package/docs/llms/19-reading-values.md +15 -3
  180. package/docs/llms/20-compute-vs-watch.md +16 -10
  181. package/docs/llms/21-array-operations.md +76 -26
  182. package/docs/llms/22-cycle-detection.md +1 -1
  183. package/docs/llms/23-copy-from.md +2 -2
  184. package/docs/llms/24-sync-fields.md +6 -5
  185. package/docs/llms/25-reset-when.md +14 -7
  186. package/docs/llms/26-transform-value.md +4 -4
  187. package/docs/llms/27-revalidate-when.md +16 -15
  188. package/docs/llms/28-submit-and-reset.md +276 -128
  189. package/docs/llms/29-async-preload.md +40 -30
  190. package/docs/llms/30-type-safety-recipes.md +105 -51
  191. package/docs/llms/31-async-validator-debounce.md +96 -53
  192. package/docs/llms/33-validation-strategy.md +178 -66
  193. package/docs/llms/34-i18n.md +69 -43
  194. package/docs/llms/35-unified-contract.md +307 -0
  195. package/docs/llms/36-issue-messages.md +284 -0
  196. package/docs/llms/37-compiled-schema.md +332 -0
  197. package/docs/llms/38-form-flow.md +397 -0
  198. package/llms-index.json +1 -1
  199. package/llms.txt +6968 -3278
  200. package/package.json +23 -4
  201. package/dist/behaviors-value-C7dSEhCc.js +0 -134
  202. package/dist/create-model-B8U-COv-.js +0 -103
  203. package/dist/date-utils-dTT_x_Be.js +0 -31
  204. package/dist/form/create-core-form.d.ts +0 -70
  205. package/dist/form/factories/index.d.ts +0 -6
  206. package/dist/form/factories/node-factory.d.ts +0 -189
  207. package/dist/form/form-submitter.d.ts +0 -121
  208. package/dist/form/nodes/array-node.d.ts +0 -276
  209. package/dist/form/nodes/field-node.d.ts +0 -297
  210. package/dist/form/nodes/form-node.d.ts +0 -326
  211. package/dist/form/nodes/group-node.d.ts +0 -284
  212. package/dist/form/nodes/model-array-node.d.ts +0 -121
  213. package/dist/form/nodes/subscription-manager.d.ts +0 -180
  214. package/dist/form/status-machine.d.ts +0 -115
  215. package/dist/form/types/deep-schema.d.ts +0 -107
  216. package/dist/form/types/form-proxy.d.ts +0 -141
  217. package/dist/form/unique-id.d.ts +0 -45
  218. package/dist/form/validation/config.d.ts +0 -73
  219. package/dist/form/validation/error-handler.d.ts +0 -166
  220. package/dist/form/validators/validation-error.d.ts +0 -8
  221. package/dist/index-BrNkQj1y.js +0 -105
  222. package/dist/loader-Dv_Hl7JC.js +0 -216
  223. package/dist/model-signals-proxy-2vqS243J.js +0 -250
  224. package/dist/node-DGEFMTQu.js +0 -18
  225. package/dist/strategy-BXS_gBfz.js +0 -170
  226. package/dist/validation-error-B-U3RsV0.js +0 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reformer/core",
3
- "version": "11.0.0-beta.7",
4
- "description": "Reactive form state management library for React with signals-based architecture",
3
+ "version": "11.0.0-beta.9",
4
+ "description": "Reactive form state management on signals: a UI-agnostic core with React bindings in @reformer/core/react",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -19,6 +19,10 @@
19
19
  "types": "./dist/i18n.d.ts",
20
20
  "import": "./dist/i18n.js"
21
21
  },
22
+ "./react": {
23
+ "types": "./dist/react.d.ts",
24
+ "import": "./dist/react.js"
25
+ },
22
26
  "./locale": {
23
27
  "types": "./dist/locale.d.ts",
24
28
  "import": "./dist/locale.js"
@@ -142,7 +146,8 @@
142
146
  "dev": "vite",
143
147
  "test": "node ../../scripts/run-vitest.mjs",
144
148
  "test:watch": "vitest watch",
145
- "coverage": "vitest run --coverage"
149
+ "coverage": "node ../../scripts/run-vitest.mjs --coverage && node ../../scripts/check-coverage-per-file.mjs",
150
+ "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.tests.json"
146
151
  },
147
152
  "keywords": [
148
153
  "react",
@@ -185,17 +190,31 @@
185
190
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
186
191
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
187
192
  },
193
+ "peerDependenciesMeta": {
194
+ "react": {
195
+ "optional": true
196
+ },
197
+ "react-dom": {
198
+ "optional": true
199
+ }
200
+ },
188
201
  "dependencies": {
189
202
  "@preact/signals-core": "^1.8.0",
190
203
  "use-sync-external-store": "^1.2.0"
191
204
  },
192
205
  "devDependencies": {
206
+ "@testing-library/dom": "^10.4.2",
207
+ "@testing-library/react": "^16.3.3",
193
208
  "@types/node": "^24.10.1",
194
209
  "@types/react": "^19.2.7",
210
+ "@types/react-dom": "^19.3.0",
195
211
  "@types/use-sync-external-store": "^0.0.6",
196
- "@vitest/coverage-v8": "~4.0.15",
212
+ "@vitest/coverage-v8": "4.0.15",
213
+ "fast-check": "^4.10.2",
214
+ "happy-dom": "^20.14.6",
197
215
  "intl-messageformat": "^12.1.2",
198
216
  "react": "^19.2.1",
217
+ "react-dom": "^19.2.1",
199
218
  "tsx": "^4.19.2",
200
219
  "typescript": "^5.9.3",
201
220
  "vite": "^7.2.2",
@@ -1,134 +0,0 @@
1
- import { effect as f } from "@preact/signals-core";
2
- const d = "runOutsideEffect";
3
- function i(e, n) {
4
- process.env.NODE_ENV !== "production" && console.error(`[${n}]`, e);
5
- }
6
- function m(e) {
7
- return typeof e == "object" && e !== null && typeof e.then == "function";
8
- }
9
- function v(e, n) {
10
- try {
11
- const t = e();
12
- m(t) && t.then(void 0, (r) => i(r, n));
13
- } catch (t) {
14
- i(t, n);
15
- }
16
- }
17
- function y(e) {
18
- return (...n) => {
19
- a(() => e(...n));
20
- };
21
- }
22
- function a(e) {
23
- let n = !1;
24
- return queueMicrotask(() => {
25
- n || v(e, d);
26
- }), () => {
27
- n = !0;
28
- };
29
- }
30
- function h(e, n) {
31
- return () => {
32
- n(() => v(e, "safeDebouncedCallback"));
33
- };
34
- }
35
- function k(e, n, t, r) {
36
- return f(() => {
37
- const u = e.map((c) => c.value);
38
- if (r?.when && !r.when(...u)) return;
39
- const s = t(...u);
40
- n.peek() !== s && (n.value = s);
41
- });
42
- }
43
- function E(e, n, t) {
44
- return f(() => {
45
- const r = e.value;
46
- if (t?.when && !t.when()) return;
47
- const u = t?.transform ? t.transform(r) : r;
48
- n.peek() !== u && (n.value = u);
49
- });
50
- }
51
- function w(e, n, t) {
52
- let r = !0;
53
- return f(() => {
54
- const u = e.value;
55
- r && (r = !1, !t?.immediate) || n(u);
56
- });
57
- }
58
- function b(e, n) {
59
- let t = !1;
60
- return f(() => {
61
- const r = e.value;
62
- t || a(() => {
63
- const u = n(r);
64
- if (e.peek() !== u) {
65
- t = !0;
66
- try {
67
- e.value = u;
68
- } finally {
69
- t = !1;
70
- }
71
- }
72
- });
73
- });
74
- }
75
- function D(e, n, t) {
76
- const r = t?.resetValue ?? null;
77
- return f(() => {
78
- const u = n();
79
- a(() => {
80
- u && e.peek() !== r && (e.value = r);
81
- });
82
- });
83
- }
84
- function F(e, n, t) {
85
- const r = t?.transform;
86
- let u = !1;
87
- const s = f(() => {
88
- const l = e.value;
89
- u || a(() => {
90
- u = !0;
91
- try {
92
- const o = r ? r(l) : l;
93
- n.peek() !== o && (n.value = o);
94
- } finally {
95
- u = !1;
96
- }
97
- });
98
- }), c = f(() => {
99
- const l = n.value;
100
- u || a(() => {
101
- u = !0;
102
- try {
103
- e.peek() !== l && (e.value = l);
104
- } finally {
105
- u = !1;
106
- }
107
- });
108
- });
109
- return () => {
110
- s(), c();
111
- };
112
- }
113
- function x(e, n) {
114
- let t = !0;
115
- return f(() => {
116
- if (e.forEach((r) => r.value), t) {
117
- t = !1;
118
- return;
119
- }
120
- a(() => n());
121
- });
122
- }
123
- export {
124
- E as a,
125
- x as b,
126
- k as c,
127
- a as d,
128
- y as e,
129
- h as f,
130
- D as r,
131
- F as s,
132
- b as t,
133
- w
134
- };
@@ -1,103 +0,0 @@
1
- import { s as p, r as g, c as u, G as v } from "./model-signals-proxy-2vqS243J.js";
2
- function r(t) {
3
- if (t)
4
- return t.kind === "group" ? d(t) : t.kind === "array" ? w(t) : t.read();
5
- }
6
- function w(t) {
7
- const i = {
8
- get length() {
9
- return t.items.value.length;
10
- },
11
- push: (e) => t.push(e),
12
- insertAt: (e, n) => t.insertAt(e, n),
13
- removeAt: (e) => t.removeAt(e),
14
- move: (e, n) => t.move(e, n),
15
- swap: (e, n) => t.swap(e, n),
16
- clear: () => t.clear(),
17
- at: (e) => r(t.items.value[e]),
18
- map: (e) => t.items.value.map((n, s) => e(r(n), s)),
19
- forEach: (e) => t.items.value.forEach((n, s) => e(r(n), s)),
20
- toArray: () => t.peek(),
21
- [Symbol.iterator]: function* () {
22
- const e = t.items.value;
23
- for (let n = 0; n < e.length; n++) yield r(e[n]);
24
- }
25
- };
26
- return new Proxy(i, {
27
- get: (e, n, s) => n === "__path" ? t.path : typeof n == "string" && u(n) ? r(t.items.value[Number(n)]) : Reflect.get(e, n, s),
28
- has: (e, n) => typeof n == "string" && u(n) ? Number(n) < t.items.value.length : Reflect.has(e, n)
29
- });
30
- }
31
- const h = /* @__PURE__ */ new Set([
32
- "$",
33
- "get",
34
- "set",
35
- "patch",
36
- "isDirty",
37
- "reset",
38
- "captureInitial",
39
- "signalAt"
40
- ]), m = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap();
41
- function d(t) {
42
- const i = m.get(t);
43
- if (i) return i;
44
- const e = {
45
- $: p(t),
46
- get: () => t.peek(),
47
- set: (s) => t.set(s),
48
- patch: (s) => t.set(s),
49
- isDirty: () => t.dirty(),
50
- reset: () => t.resetToInitial(),
51
- captureInitial: () => t.captureInitial(),
52
- signalAt: (s) => g(t, s)
53
- }, n = new Proxy(
54
- {},
55
- {
56
- get: (s, a) => {
57
- if (a === "__path") return t.path;
58
- if (typeof a != "string") return;
59
- const c = t.children.get(a);
60
- if (c) return r(c);
61
- if (h.has(a)) return e[a];
62
- },
63
- set: (s, a, c) => {
64
- if (typeof a != "string") return !1;
65
- const f = t.children.get(a);
66
- return f ? (f.set(c), !0) : !1;
67
- },
68
- has: (s, a) => typeof a == "string" && (t.children.has(a) || h.has(a)),
69
- ownKeys: () => [...t.children.keys()],
70
- getOwnPropertyDescriptor: (s, a) => typeof a == "string" && t.children.has(a) ? { enumerable: !0, configurable: !0 } : void 0
71
- }
72
- );
73
- return m.set(t, n), o.set(n, t), n;
74
- }
75
- function l(t, i, e) {
76
- if (t.kind === "leaf") {
77
- i(t.signal);
78
- return;
79
- }
80
- if (t.kind === "group") {
81
- for (const n of t.children.values()) l(n, i, e);
82
- return;
83
- }
84
- e && i(p(t));
85
- for (const n of t.items.value) l(n, i, e);
86
- }
87
- function x(t, i) {
88
- const e = o.get(t);
89
- e && l(e, i, !1);
90
- }
91
- function y(t, i) {
92
- const e = o.get(t);
93
- e && l(e, i, !0);
94
- }
95
- function A(t) {
96
- const i = new v(t, "");
97
- return d(i);
98
- }
99
- export {
100
- y as a,
101
- A as c,
102
- x as e
103
- };
@@ -1,31 +0,0 @@
1
- function i(t) {
2
- if (t == null || t === "")
3
- return null;
4
- if (t instanceof Date)
5
- return isNaN(t.getTime()) ? null : t;
6
- if (typeof t == "string") {
7
- const n = new Date(t);
8
- return isNaN(n.getTime()) ? null : n;
9
- }
10
- return null;
11
- }
12
- function s() {
13
- const t = /* @__PURE__ */ new Date();
14
- return t.setHours(0, 0, 0, 0), t;
15
- }
16
- function a(t) {
17
- const n = new Date(t);
18
- return n.setHours(0, 0, 0, 0), n;
19
- }
20
- function c(t) {
21
- const n = s(), e = a(t);
22
- let r = n.getFullYear() - e.getFullYear();
23
- const o = n.getMonth() - e.getMonth();
24
- return (o < 0 || o === 0 && n.getDate() < e.getDate()) && (r -= 1), r;
25
- }
26
- export {
27
- c,
28
- s as g,
29
- a as n,
30
- i as p
31
- };
@@ -1,70 +0,0 @@
1
- import { FormModel } from '../model/types';
2
- import { FormSchemaNode } from './types/schema-node';
3
- import { FormBehavior } from './behaviors';
4
- import { FormProxy } from './types/index';
5
- import { FormValidation, FormValidationBundle } from './validation/config';
6
- import { ValidationSchema } from './validation';
7
- /**
8
- * Общая часть конфига всех фабрик формы.
9
- *
10
- * @typeParam T - Форма данных модели.
11
- * @typeParam B - Бандл конкретной фабрики (его получает {@link CreateFormConfigBase.setup}).
12
- */
13
- export interface CreateFormConfigBase<T, B> {
14
- /** Начальные значения — из них создаётся модель. Взаимоисключимо с `model`. */
15
- initial?: T;
16
- /** Готовая модель (если создана отдельной фабрикой). Приоритетнее `initial`. */
17
- model?: FormModel<T>;
18
- /** Декларативное поведение модели (compute/copyFrom/enableWhen/onChange). */
19
- behavior?: FormBehavior<T>;
20
- /** Правила валидации: готовая схема либо {@link FormValidation} со стратегией и шагами. */
21
- validation?: FormValidation<T> | ValidationSchema<T>;
22
- /**
23
- * Правка модели ДО сборки формы. Нужна там, где значение обязано существовать к моменту
24
- * построения нод — например, массив, наполняемый из вычислений (реактивные `onChange` на
25
- * инициализации не срабатывают).
26
- */
27
- seed?: (model: FormModel<T>) => void;
28
- /**
29
- * Донастройка ПОСЛЕ сборки. Единственное место для правок, которые обязаны идти следом за
30
- * `createForm`: поле, чьё значение уже массив, ноды не получает (см. `buildModelConfig`),
31
- * поэтому такой префилл выполняется здесь.
32
- */
33
- setup?: (bundle: B) => void;
34
- }
35
- /** Результат {@link createCoreForm}: модель, форма и (если заданы правила) собранная валидация. */
36
- export interface CoreForm<T> {
37
- model: FormModel<T>;
38
- form: FormProxy<T>;
39
- validation?: FormValidationBundle<T>;
40
- }
41
- /** Конфиг {@link createCoreForm}. */
42
- export interface CreateCoreFormConfig<T> extends CreateFormConfigBase<T, CoreForm<T>> {
43
- /**
44
- * Билдер схемы формы. Именно функция, а не готовое дерево: листья схемы держат сами сигналы
45
- * модели (`value: model.$.email`), поэтому построить дерево до модели нечем.
46
- */
47
- schema?: (model: FormModel<T>) => FormSchemaNode;
48
- }
49
- /**
50
- * Собрать модель, форму и валидацию за один проход.
51
- *
52
- * @typeParam T - Форма данных модели.
53
- * @param config - {@link CreateCoreFormConfig}: (`initial` | `model`) + опц. `schema`, `behavior`,
54
- * `validation`, `seed`, `setup`.
55
- * @returns {@link CoreForm}` <T>` — `{ model, form, validation? }`.
56
- *
57
- * @example
58
- * ```tsx
59
- * const credit = useFormBundle(() =>
60
- * createCoreForm<CreditForm>({
61
- * model: createCreditModel(),
62
- * schema: buildCreditSchema,
63
- * behavior: creditBehavior,
64
- * validation: { steps: { loan: loanRules, confirm: null }, extras: crossRules },
65
- * })
66
- * );
67
- * return <FormWizard form={credit.form} config={credit.validation} steps={STEPS} />;
68
- * ```
69
- */
70
- export declare function createCoreForm<T extends object>(config: CreateCoreFormConfig<T>): CoreForm<T>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Фабрики для создания узлов формы
3
- *
4
- * Централизованное место для всех фабрик и builder-паттернов.
5
- */
6
- export { NodeFactory } from './node-factory';
@@ -1,189 +0,0 @@
1
- import { FormNode } from '../nodes/form-node';
2
- import { ConfigWithSchema, ConfigWithValue, UnknownRecord } from '../types/index';
3
- /**
4
- * Фабрика для создания узлов формы.
5
- *
6
- * Определяет тип конфига и создаёт соответствующий узел (FieldNode, GroupNode, ArrayNode).
7
- * Используется внутри `getReformerForm`/`group`/`array` — явно вызывать обычно не нужно.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { NodeFactory } from '@reformer/core';
12
- *
13
- * const factory = new NodeFactory();
14
- * const node = factory.createNode({ value: '', component: Input }); // → FieldNode<string>
15
- * ```
16
- */
17
- export declare class NodeFactory {
18
- /**
19
- * Создает узел формы на основе конфигурации
20
- *
21
- * ✅ ОБНОВЛЕНО: Теперь поддерживает массивы напрямую
22
- *
23
- * Автоматически определяет тип узла:
24
- * - FieldNode: имеет value и component
25
- * - ArrayNode: массив [schema, ...items] или { schema, initialItems }
26
- * - GroupNode: объект без value, component, schema
27
- *
28
- * @param config Конфигурация узла
29
- * @returns Экземпляр FieldNode, GroupNode или ArrayNode
30
- * @throws Error если конфиг не соответствует ни одному типу
31
- *
32
- * @example
33
- * ```typescript
34
- * const factory = new NodeFactory();
35
- *
36
- * Конфиг node-level (не layout-схема M1, где `validators` уже нет).
37
- * // FieldNode
38
- * const field = factory.createNode({
39
- * value: 'test@mail.com',
40
- * component: Input,
41
- * validators: [required, email]
42
- * });
43
- *
44
- * // GroupNode
45
- * const group = factory.createNode({
46
- * email: { value: '', component: Input },
47
- * password: { value: '', component: Input }
48
- * });
49
- *
50
- * // ArrayNode (объект)
51
- * const array = factory.createNode({
52
- * schema: { title: { value: '', component: Input } },
53
- * initialItems: [{ title: 'Item 1' }]
54
- * });
55
- *
56
- * // ArrayNode (массив) - новый формат
57
- * const array2 = factory.createNode([
58
- * { title: { value: '', component: Input } }, // schema
59
- * { title: 'Item 1' }, // initial item 1
60
- * { title: 'Item 2' } // initial item 2
61
- * ]);
62
- * ```
63
- */
64
- createNode(config: unknown): FormNode<unknown>;
65
- /**
66
- * Создать ArrayNode из массива [schema, ...initialItems]
67
- *
68
- * ✅ НОВОЕ: Извлечено из GroupNode для централизации логики
69
- *
70
- * Формат: [itemSchema, ...initialItems]
71
- * - Первый элемент - схема элемента массива
72
- * - Остальные элементы - начальные значения
73
- *
74
- * @param config Массив с схемой и начальными элементами
75
- * @returns ArrayNode
76
- *
77
- * @example
78
- * ```typescript
79
- * const factory = new NodeFactory();
80
- *
81
- * // Массив с начальными элементами
82
- * const array = factory.createArrayNodeFromArray([
83
- * { title: { value: '', component: Input } }, // schema
84
- * { title: 'Item 1' }, // initial value
85
- * { title: 'Item 2' } // initial value
86
- * ]);
87
- * ```
88
- * @private
89
- */
90
- private createArrayNodeFromArray;
91
- /**
92
- * Извлечь значения из схемы (рекурсивно)
93
- *
94
- * ✅ НОВОЕ: Извлечено из GroupNode для централизации логики
95
- *
96
- * Преобразует схему формы в объект со значениями:
97
- * - `{ name: { value: 'John', component: Input } } → { name: 'John' }`
98
- * - Поддерживает вложенные группы
99
- * - Поддерживает массивы
100
- *
101
- * @param schema Схема формы
102
- * @returns Объект со значениями полей
103
- *
104
- * @example
105
- * ```typescript
106
- * const factory = new NodeFactory();
107
- *
108
- * const schema = {
109
- * name: { value: 'John', component: Input },
110
- * age: { value: 30, component: Input },
111
- * address: {
112
- * city: { value: 'Moscow', component: Input }
113
- * }
114
- * };
115
- *
116
- * factory.extractValues(schema);
117
- * // { name: 'John', age: 30, address: { city: 'Moscow' } }
118
- * ```
119
- */
120
- extractValues(schema: unknown): unknown;
121
- /**
122
- * Проверяет, является ли конфиг конфигурацией поля (FieldConfig)
123
- *
124
- * FieldConfig имеет обязательные свойства:
125
- * - value: начальное значение поля
126
- * - component: React-компонент для отображения
127
- *
128
- * @param config Проверяемая конфигурация
129
- * @returns true если config является FieldConfig
130
- *
131
- * @example
132
- * ```typescript
133
- * const factory = new NodeFactory();
134
- *
135
- * factory.isFieldConfig({ value: '', component: Input }); // true
136
- * factory.isFieldConfig({ email: { value: '' } }); // false
137
- * factory.isFieldConfig(null); // false
138
- * ```
139
- */
140
- isFieldConfig(config: unknown): config is ConfigWithValue;
141
- /**
142
- * Проверяет, является ли конфиг конфигурацией массива (ArrayConfig)
143
- *
144
- * ArrayConfig имеет обязательное свойство:
145
- * - schema: схема для элементов массива
146
- *
147
- * И НЕ имеет:
148
- * - value (отличие от FieldConfig)
149
- *
150
- * @param config Проверяемая конфигурация
151
- * @returns true если config является ArrayConfig
152
- *
153
- * @example
154
- * ```typescript
155
- * const factory = new NodeFactory();
156
- *
157
- * factory.isArrayConfig({ schema: {}, initialItems: [] }); // true
158
- * factory.isArrayConfig({ value: '', component: Input }); // false
159
- * factory.isArrayConfig({ email: { value: '' } }); // false
160
- * ```
161
- */
162
- isArrayConfig(config: unknown): config is ConfigWithSchema;
163
- /**
164
- * Проверяет, является ли конфиг конфигурацией группы (GroupConfig)
165
- *
166
- * GroupConfig - это объект, который:
167
- * - НЕ является FieldConfig (нет value/component)
168
- * - НЕ является ArrayConfig (нет schema)
169
- * - Содержит вложенные конфиги полей/групп/массивов
170
- *
171
- * @param config Проверяемая конфигурация
172
- * @returns true если config является GroupConfig
173
- *
174
- * @example
175
- * ```typescript
176
- * const factory = new NodeFactory();
177
- *
178
- * factory.isGroupConfig({
179
- * email: { value: '', component: Input },
180
- * password: { value: '', component: Input }
181
- * }); // true
182
- *
183
- * factory.isGroupConfig({ value: '', component: Input }); // false
184
- * factory.isGroupConfig({ schema: {} }); // false
185
- * factory.isGroupConfig(null); // false
186
- * ```
187
- */
188
- isGroupConfig(config: unknown): config is UnknownRecord;
189
- }