@reformer/core 10.2.0 → 11.0.0-beta.2

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 (63) hide show
  1. package/dist/behaviors.js +134 -134
  2. package/dist/form/form-submitter.d.ts +0 -4
  3. package/dist/form/hooks/types.d.ts +3 -3
  4. package/dist/form/index.d.ts +0 -3
  5. package/dist/form/nodes/array-node.d.ts +0 -84
  6. package/dist/form/nodes/form-node.d.ts +0 -14
  7. package/dist/form/nodes/group-node.d.ts +0 -4
  8. package/dist/form/status-machine.d.ts +0 -38
  9. package/dist/form/types/contracts.d.ts +0 -6
  10. package/dist/form/types/deep-schema.d.ts +0 -9
  11. package/dist/form/types/index.d.ts +4 -38
  12. package/dist/form/types/schema-node.d.ts +13 -16
  13. package/dist/form/types/validation-schema.d.ts +0 -25
  14. package/dist/form/unique-id.d.ts +3 -11
  15. package/dist/form/validators.d.ts +8 -3
  16. package/dist/form-model-DhW2HZOB.js +323 -0
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +448 -636
  19. package/dist/runtime-token.d.ts +23 -0
  20. package/dist/state/form-model.d.ts +14 -0
  21. package/dist/state/index.d.ts +2 -1
  22. package/dist/state/types.d.ts +39 -11
  23. package/dist/state.js +18 -18
  24. package/dist/validation.js +1 -1
  25. package/dist/validators.d.ts +0 -4
  26. package/dist/validators.js +88 -122
  27. package/docs/llms/01-api-reference.md +63 -0
  28. package/docs/llms/02-quick-start.md +143 -0
  29. package/docs/llms/03-api-signatures.md +273 -0
  30. package/docs/llms/04-common-patterns.md +202 -0
  31. package/docs/llms/05-common-mistakes.md +167 -0
  32. package/docs/llms/06-troubleshooting.md +11 -0
  33. package/docs/llms/07-complete-import.md +99 -0
  34. package/docs/llms/08-form-types.md +47 -0
  35. package/docs/llms/09-formschema.md +143 -0
  36. package/docs/llms/10-arrays.md +161 -0
  37. package/docs/llms/11-async-watchfield.md +53 -0
  38. package/docs/llms/12-array-cleanup.md +31 -0
  39. package/docs/llms/13-multi-step.md +91 -0
  40. package/docs/llms/14-extended-mistakes.md +98 -0
  41. package/docs/llms/15-project-structure.md +125 -0
  42. package/docs/llms/16-ui-components.md +189 -0
  43. package/docs/llms/17-nonexistent-api.md +93 -0
  44. package/docs/llms/18-conditional-fields.md +183 -0
  45. package/docs/llms/19-reading-values.md +88 -0
  46. package/docs/llms/20-compute-vs-watch.md +147 -0
  47. package/docs/llms/21-array-operations.md +113 -0
  48. package/docs/llms/22-cycle-detection.md +86 -0
  49. package/docs/llms/23-copy-from.md +141 -0
  50. package/docs/llms/24-sync-fields.md +114 -0
  51. package/docs/llms/25-reset-when.md +115 -0
  52. package/docs/llms/26-transform-value.md +136 -0
  53. package/docs/llms/27-revalidate-when.md +132 -0
  54. package/docs/llms/28-submit-and-reset.md +259 -0
  55. package/docs/llms/29-async-preload.md +193 -0
  56. package/docs/llms/30-type-safety-recipes.md +159 -0
  57. package/docs/llms/31-async-validator-debounce.md +135 -0
  58. package/docs/llms/32-async-options-loading.md +108 -0
  59. package/docs/llms/33-validation-strategy.md +193 -0
  60. package/llms.txt +219 -1533
  61. package/package.json +33 -10
  62. package/dist/derived-registry-CluZCQ7U.js +0 -16
  63. package/dist/form-model-DYCzGGKF.js +0 -286
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reformer/core",
3
- "version": "10.2.0",
3
+ "version": "11.0.0-beta.2",
4
4
  "description": "Reactive form state management library for React with signals-based architecture",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -87,9 +87,33 @@
87
87
  "types": "./dist/validators/non-zero.d.ts",
88
88
  "import": "./dist/validators/non-zero.js"
89
89
  },
90
- "./validators/date": {
91
- "types": "./dist/validators/date.d.ts",
92
- "import": "./dist/validators/date.js"
90
+ "./validators/is-date": {
91
+ "types": "./dist/validators/is-date.d.ts",
92
+ "import": "./dist/validators/is-date.js"
93
+ },
94
+ "./validators/min-date": {
95
+ "types": "./dist/validators/min-date.d.ts",
96
+ "import": "./dist/validators/min-date.js"
97
+ },
98
+ "./validators/max-date": {
99
+ "types": "./dist/validators/max-date.d.ts",
100
+ "import": "./dist/validators/max-date.js"
101
+ },
102
+ "./validators/past-date": {
103
+ "types": "./dist/validators/past-date.d.ts",
104
+ "import": "./dist/validators/past-date.js"
105
+ },
106
+ "./validators/future-date": {
107
+ "types": "./dist/validators/future-date.d.ts",
108
+ "import": "./dist/validators/future-date.js"
109
+ },
110
+ "./validators/min-age": {
111
+ "types": "./dist/validators/min-age.d.ts",
112
+ "import": "./dist/validators/min-age.js"
113
+ },
114
+ "./validators/max-age": {
115
+ "types": "./dist/validators/max-age.d.ts",
116
+ "import": "./dist/validators/max-age.js"
93
117
  }
94
118
  },
95
119
  "sideEffects": false,
@@ -99,7 +123,8 @@
99
123
  "build:stackblitz": "vite build",
100
124
  "dev": "vite",
101
125
  "test": "node ../../scripts/run-vitest.mjs",
102
- "test:watch": "vitest watch"
126
+ "test:watch": "vitest watch",
127
+ "coverage": "vitest run --coverage"
103
128
  },
104
129
  "keywords": [
105
130
  "react",
@@ -134,7 +159,8 @@
134
159
  "dist",
135
160
  "README.md",
136
161
  "LICENSE",
137
- "llms.txt"
162
+ "llms.txt",
163
+ "docs/llms"
138
164
  ],
139
165
  "peerDependencies": {
140
166
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -149,11 +175,8 @@
149
175
  "@types/node": "^24.10.1",
150
176
  "tsx": "^4.19.2",
151
177
  "@types/react": "^19.2.7",
152
- "@types/react-dom": "^19.2.3",
153
- "@vitejs/plugin-react": "^5.1.0",
154
- "@vitest/utils": "^4.0.8",
178
+ "@vitest/coverage-v8": "~4.0.15",
155
179
  "react": "^19.2.1",
156
- "react-dom": "^19.2.1",
157
180
  "typescript": "^5.9.3",
158
181
  "vite": "^7.2.2",
159
182
  "vite-plugin-dts": "^4.5.4",
@@ -1,16 +0,0 @@
1
- const t = /* @__PURE__ */ new WeakMap();
2
- function n(e) {
3
- t.set(e, (t.get(e) ?? 0) + 1);
4
- }
5
- function i(e) {
6
- const r = t.get(e);
7
- r !== void 0 && (r <= 1 ? t.delete(e) : t.set(e, r - 1));
8
- }
9
- function o(e) {
10
- return t.has(e);
11
- }
12
- export {
13
- o as i,
14
- n as m,
15
- i as u
16
- };
@@ -1,286 +0,0 @@
1
- import { signal as k } from "@preact/signals-core";
2
- import { i as b } from "./derived-registry-CluZCQ7U.js";
3
- const h = (e) => !(e === null || typeof e != "object" || Array.isArray(e) || e instanceof Date || typeof Blob < "u" && e instanceof Blob || typeof File < "u" && e instanceof File), a = (e, i) => e === "" ? String(i) : `${e}.${i}`, p = (e) => /^\d+$/.test(e), o = (e) => {
4
- if (Array.isArray(e)) return e.map(o);
5
- if (h(e)) {
6
- const i = {};
7
- for (const t of Object.keys(e)) i[t] = o(e[t]);
8
- return i;
9
- }
10
- return e;
11
- }, u = (e, i) => {
12
- if (e === i) return !0;
13
- if (Array.isArray(e) && Array.isArray(i))
14
- return e.length !== i.length ? !1 : e.every((t, r) => u(t, i[r]));
15
- if (h(e) && h(i)) {
16
- const t = Object.keys(e), r = Object.keys(i);
17
- return t.length !== r.length ? !1 : t.every((n) => u(e[n], i[n]));
18
- }
19
- return !1;
20
- };
21
- class x {
22
- constructor(i, t) {
23
- this.path = t;
24
- const r = k(i);
25
- r.__path = t, this.signal = r, this.initial = o(i);
26
- }
27
- kind = "leaf";
28
- signal;
29
- initial;
30
- rebase(i) {
31
- this.path = i, this.signal.__path = i;
32
- }
33
- /** Реактивное чтение (внутри effect/computed создаёт зависимость). */
34
- read() {
35
- return this.signal.value;
36
- }
37
- /** Нереактивный снимок. */
38
- peek() {
39
- return this.signal.peek();
40
- }
41
- set(i) {
42
- this.signal.value = i;
43
- }
44
- resetToInitial() {
45
- this.signal.value = o(this.initial);
46
- }
47
- captureInitial() {
48
- this.initial = o(this.signal.peek());
49
- }
50
- dirty() {
51
- return !u(this.signal.peek(), this.initial);
52
- }
53
- }
54
- class A {
55
- constructor(i, t) {
56
- this.path = t;
57
- for (const r of Object.keys(i))
58
- this.children.set(r, c(i[r], a(t, r)));
59
- }
60
- kind = "group";
61
- children = /* @__PURE__ */ new Map();
62
- rebase(i) {
63
- this.path = i;
64
- for (const [t, r] of this.children) r.rebase(a(i, t));
65
- }
66
- peek() {
67
- const i = {};
68
- for (const [t, r] of this.children) i[t] = r.peek();
69
- return i;
70
- }
71
- set(i) {
72
- if (i == null || typeof i != "object") return;
73
- const t = i;
74
- for (const [r, n] of this.children)
75
- r in t && (n.kind === "leaf" && b(n.signal) || n.set(t[r]));
76
- }
77
- resetToInitial() {
78
- for (const i of this.children.values()) i.resetToInitial();
79
- }
80
- captureInitial() {
81
- for (const i of this.children.values()) i.captureInitial();
82
- }
83
- dirty() {
84
- for (const i of this.children.values()) if (i.dirty()) return !0;
85
- return !1;
86
- }
87
- }
88
- class I {
89
- constructor(i, t) {
90
- this.path = t, this.items = k(i.map((r, n) => c(r, a(t, n)))), this.initial = o(i);
91
- }
92
- kind = "array";
93
- items;
94
- initial;
95
- rebase(i) {
96
- this.path = i, this.items.peek().forEach((t, r) => t.rebase(a(i, r)));
97
- }
98
- reindex() {
99
- this.items.peek().forEach((i, t) => i.rebase(a(this.path, t)));
100
- }
101
- push(i) {
102
- const t = this.items.peek();
103
- this.items.value = [...t, c(i, a(this.path, t.length))];
104
- }
105
- insertAt(i, t) {
106
- const r = [...this.items.peek()];
107
- r.splice(i, 0, c(t, a(this.path, i))), this.items.value = r, this.reindex();
108
- }
109
- removeAt(i) {
110
- const t = [...this.items.peek()];
111
- t.splice(i, 1), this.items.value = t, this.reindex();
112
- }
113
- move(i, t) {
114
- const r = [...this.items.peek()], [n] = r.splice(i, 1);
115
- n && r.splice(t, 0, n), this.items.value = r, this.reindex();
116
- }
117
- swap(i, t) {
118
- const r = [...this.items.peek()];
119
- i < 0 || t < 0 || i >= r.length || t >= r.length || i === t || ([r[i], r[t]] = [r[t], r[i]], this.items.value = r, this.reindex());
120
- }
121
- clear() {
122
- this.items.value = [];
123
- }
124
- peek() {
125
- return this.items.peek().map((i) => i.peek());
126
- }
127
- set(i) {
128
- const t = Array.isArray(i) ? i : [];
129
- this.items.value = t.map((r, n) => c(r, a(this.path, n)));
130
- }
131
- resetToInitial() {
132
- this.set(o(this.initial));
133
- }
134
- captureInitial() {
135
- this.initial = o(this.peek());
136
- }
137
- dirty() {
138
- return !u(this.peek(), this.initial);
139
- }
140
- }
141
- function c(e, i) {
142
- return Array.isArray(e) ? new I(e, i) : h(e) ? new A(e, i) : new x(e, i);
143
- }
144
- function l(e) {
145
- if (e)
146
- return e.kind === "group" ? _(e) : e.kind === "array" ? P(e) : e.read();
147
- }
148
- function P(e) {
149
- const i = {
150
- get length() {
151
- return e.items.value.length;
152
- },
153
- push: (t) => e.push(t),
154
- insertAt: (t, r) => e.insertAt(t, r),
155
- removeAt: (t) => e.removeAt(t),
156
- move: (t, r) => e.move(t, r),
157
- swap: (t, r) => e.swap(t, r),
158
- clear: () => e.clear(),
159
- at: (t) => l(e.items.value[t]),
160
- map: (t) => e.items.value.map((r, n) => t(l(r), n)),
161
- forEach: (t) => e.items.value.forEach((r, n) => t(l(r), n)),
162
- toArray: () => e.peek(),
163
- [Symbol.iterator]: function* () {
164
- const t = e.items.value;
165
- for (let r = 0; r < t.length; r++) yield l(t[r]);
166
- }
167
- };
168
- return new Proxy(i, {
169
- get: (t, r, n) => r === "__path" ? e.path : typeof r == "string" && p(r) ? l(e.items.value[Number(r)]) : Reflect.get(t, r, n),
170
- has: (t, r) => typeof r == "string" && p(r) ? Number(r) < e.items.value.length : Reflect.has(t, r)
171
- });
172
- }
173
- function d(e) {
174
- if (e.kind === "leaf") return e.signal;
175
- if (e.kind === "group")
176
- return new Proxy(
177
- {},
178
- {
179
- get: (t, r) => {
180
- if (r === "__path") return e.path;
181
- if (typeof r != "string") return;
182
- const n = e.children.get(r);
183
- return n ? d(n) : void 0;
184
- },
185
- has: (t, r) => typeof r == "string" && e.children.has(r),
186
- ownKeys: () => [...e.children.keys()],
187
- getOwnPropertyDescriptor: (t, r) => typeof r == "string" && e.children.has(r) ? { enumerable: !0, configurable: !0 } : void 0
188
- }
189
- );
190
- const i = e;
191
- return new Proxy(
192
- {
193
- get length() {
194
- return i.items.value.length;
195
- }
196
- },
197
- {
198
- get: (t, r, n) => {
199
- if (r === "__path") return i.path;
200
- if (typeof r == "string" && p(r)) {
201
- const s = i.items.value[Number(r)];
202
- return s ? d(s) : void 0;
203
- }
204
- return Reflect.get(t, r, n);
205
- }
206
- }
207
- );
208
- }
209
- function j(e, i) {
210
- if (!i) return;
211
- let t = e;
212
- for (const r of i.split(".")) {
213
- if (!t) return;
214
- if (t.kind === "group") t = t.children.get(r);
215
- else if (t.kind === "array") t = t.items.peek()[Number(r)];
216
- else return;
217
- }
218
- return t && t.kind === "leaf" ? t.signal : void 0;
219
- }
220
- const y = /* @__PURE__ */ new Set([
221
- "$",
222
- "get",
223
- "set",
224
- "patch",
225
- "isDirty",
226
- "reset",
227
- "captureInitial",
228
- "signalAt"
229
- ]), v = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap();
230
- function _(e) {
231
- const i = v.get(e);
232
- if (i) return i;
233
- const t = {
234
- $: d(e),
235
- get: () => e.peek(),
236
- set: (n) => e.set(n),
237
- patch: (n) => e.set(n),
238
- isDirty: () => e.dirty(),
239
- reset: () => e.resetToInitial(),
240
- captureInitial: () => e.captureInitial(),
241
- signalAt: (n) => j(e, n)
242
- }, r = new Proxy(
243
- {},
244
- {
245
- get: (n, s) => {
246
- if (s === "__path") return e.path;
247
- if (typeof s != "string") return;
248
- const f = e.children.get(s);
249
- if (f) return l(f);
250
- if (y.has(s)) return t[s];
251
- },
252
- set: (n, s, f) => {
253
- if (typeof s != "string") return !1;
254
- const g = e.children.get(s);
255
- return g ? (g.set(f), !0) : !1;
256
- },
257
- has: (n, s) => typeof s == "string" && (e.children.has(s) || y.has(s)),
258
- ownKeys: () => [...e.children.keys()],
259
- getOwnPropertyDescriptor: (n, s) => typeof s == "string" && e.children.has(s) ? { enumerable: !0, configurable: !0 } : void 0
260
- }
261
- );
262
- return v.set(e, r), w.set(r, e), r;
263
- }
264
- function m(e, i) {
265
- if (e.kind === "leaf") {
266
- i(e.signal);
267
- return;
268
- }
269
- if (e.kind === "group") {
270
- for (const t of e.children.values()) m(t, i);
271
- return;
272
- }
273
- for (const t of e.items.value) m(t, i);
274
- }
275
- function D(e, i) {
276
- const t = w.get(e);
277
- t && m(t, i);
278
- }
279
- function O(e) {
280
- const i = new A(e, "");
281
- return _(i);
282
- }
283
- export {
284
- O as c,
285
- D as e
286
- };