@reformer/core 9.0.0-beta.2 → 9.1.0
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.
- package/dist/behaviors-node-BMOI2JJF.js +26 -0
- package/dist/behaviors-value-lCpqicfa.js +148 -0
- package/dist/behaviors.d.ts +2 -133
- package/dist/behaviors.js +29 -28
- package/dist/{core/utils → form}/aggregate-signals.d.ts +2 -2
- package/dist/form/behaviors-node.d.ts +55 -0
- package/dist/form/behaviors.d.ts +133 -0
- package/dist/{core/utils → form}/create-form.d.ts +5 -4
- package/dist/{core/utils → form}/error-handler.d.ts +1 -1
- package/dist/{core → form}/factories/node-factory.d.ts +1 -1
- package/dist/{core/utils → form}/form-proxy-builder.d.ts +2 -2
- package/dist/{hooks → form/hooks}/types.d.ts +1 -1
- package/dist/{hooks → form/hooks}/useArrayLength.d.ts +1 -1
- package/dist/{hooks → form/hooks}/useFormControl.d.ts +3 -3
- package/dist/{hooks → form/hooks}/useFormControlValue.d.ts +2 -2
- package/dist/form/index.d.ts +36 -0
- package/dist/{core → form}/nodes/array-node.d.ts +1 -1
- package/dist/{core → form}/nodes/field-node.d.ts +1 -1
- package/dist/{core → form}/nodes/form-node.d.ts +1 -1
- package/dist/{core → form}/nodes/group-node.d.ts +2 -2
- package/dist/{core → form}/nodes/model-array-node.d.ts +2 -2
- package/dist/{core/utils → form}/signal-node-registry.d.ts +1 -1
- package/dist/{core/utils → form}/status-machine.d.ts +1 -1
- package/dist/{core/utils → form}/type-guards.d.ts +5 -5
- package/dist/{core/types/index.d.ts → form/types/contracts.d.ts} +11 -90
- package/dist/form/types/index.d.ts +91 -0
- package/dist/{core → form}/types/schema-node.d.ts +1 -1
- package/dist/{core → form}/types/validation-schema.d.ts +1 -1
- package/dist/{core/model/validate-model.d.ts → form/validate-model-core.d.ts} +25 -25
- package/dist/form/validate-model.d.ts +27 -0
- package/dist/form/validators.d.ts +6 -0
- package/dist/form-model-C8Fi83k4.js +439 -0
- package/dist/index.d.ts +11 -16
- package/dist/index.js +663 -1016
- package/dist/{core/model/behaviors.d.ts → state/behaviors-value.d.ts} +0 -53
- package/dist/state/form-model.d.ts +26 -0
- package/dist/state/index.d.ts +31 -0
- package/dist/{core/utils → state}/safe-effect.d.ts +4 -4
- package/dist/{core/model → state}/types.d.ts +14 -11
- package/dist/state.d.ts +2 -0
- package/dist/state.js +19 -0
- package/dist/validators/email.d.ts +1 -1
- package/dist/validators/future-date.d.ts +1 -1
- package/dist/validators/integer.d.ts +1 -1
- package/dist/validators/is-date.d.ts +1 -1
- package/dist/validators/is-number.d.ts +1 -1
- package/dist/validators/max-age.d.ts +1 -1
- package/dist/validators/max-date.d.ts +1 -1
- package/dist/validators/max-length.d.ts +1 -1
- package/dist/validators/max.d.ts +1 -1
- package/dist/validators/min-age.d.ts +1 -1
- package/dist/validators/min-date.d.ts +1 -1
- package/dist/validators/min-length.d.ts +1 -1
- package/dist/validators/min.d.ts +1 -1
- package/dist/validators/multiple-of.d.ts +1 -1
- package/dist/validators/non-negative.d.ts +1 -1
- package/dist/validators/non-zero.d.ts +1 -1
- package/dist/validators/past-date.d.ts +1 -1
- package/dist/validators/pattern.d.ts +1 -1
- package/dist/validators/phone.d.ts +1 -1
- package/dist/validators/required.d.ts +1 -1
- package/dist/validators/url.d.ts +1 -1
- package/dist/validators.d.ts +6 -6
- package/llms.txt +161 -147
- package/package.json +5 -1
- package/dist/behaviors-Br4Im38V.js +0 -263
- package/dist/core/model/form-model.d.ts +0 -18
- package/dist/core/model/index.d.ts +0 -12
- package/dist/core/utils/index.d.ts +0 -18
- /package/dist/{core → form}/factories/index.d.ts +0 -0
- /package/dist/{core/utils → form}/form-submitter.d.ts +0 -0
- /package/dist/{hooks → form/hooks}/useSignalSubscription.d.ts +0 -0
- /package/dist/{core → form}/types/deep-schema.d.ts +0 -0
- /package/dist/{core → form}/types/form-proxy.d.ts +0 -0
- /package/dist/{core/utils → form}/unique-id.d.ts +0 -0
- /package/dist/{core → form}/validation/index.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/date-utils.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/email.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/future-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/index.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/integer.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/is-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/is-number.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max-age.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max-length.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/max.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min-age.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min-length.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/min.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/multiple-of.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/non-negative.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/non-zero.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/past-date.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/pattern.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/phone.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/required.d.ts +0 -0
- /package/dist/{core → form}/validation/validators/url.d.ts +0 -0
- /package/dist/{core/utils → state}/derived-registry.d.ts +0 -0
- /package/dist/{core/utils → state}/subscription-manager.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reformer/core",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Reactive form state management library for React with signals-based architecture",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"types": "./dist/signals.d.ts",
|
|
16
16
|
"import": "./dist/signals.js"
|
|
17
17
|
},
|
|
18
|
+
"./state": {
|
|
19
|
+
"types": "./dist/state.d.ts",
|
|
20
|
+
"import": "./dist/state.js"
|
|
21
|
+
},
|
|
18
22
|
"./behaviors": {
|
|
19
23
|
"types": "./dist/behaviors.d.ts",
|
|
20
24
|
"import": "./dist/behaviors.js"
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { effect as a } from "@preact/signals-core";
|
|
2
|
-
var l = /* @__PURE__ */ ((n) => (n.THROW = "throw", n.LOG = "log", n.CONVERT = "convert", n))(l || {});
|
|
3
|
-
class m {
|
|
4
|
-
static handle(e, t, r = "throw") {
|
|
5
|
-
const s = this.extractMessage(e);
|
|
6
|
-
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), r) {
|
|
7
|
-
case "throw":
|
|
8
|
-
throw e;
|
|
9
|
-
case "log":
|
|
10
|
-
return;
|
|
11
|
-
case "convert":
|
|
12
|
-
return {
|
|
13
|
-
code: "validator_error",
|
|
14
|
-
message: s,
|
|
15
|
-
params: { field: t }
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Извлечь сообщение из ошибки
|
|
21
|
-
*
|
|
22
|
-
* Обрабатывает различные типы ошибок:
|
|
23
|
-
* - Error объекты → error.message
|
|
24
|
-
* - Строки → возвращает как есть
|
|
25
|
-
* - Объекты с message → извлекает message
|
|
26
|
-
* - Другое → String(error)
|
|
27
|
-
*
|
|
28
|
-
* @param error Ошибка для извлечения сообщения
|
|
29
|
-
* @returns Сообщение ошибки
|
|
30
|
-
* @private
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* FormErrorHandler.extractMessage(new Error('Test'));
|
|
35
|
-
* // 'Test'
|
|
36
|
-
*
|
|
37
|
-
* FormErrorHandler.extractMessage('String error');
|
|
38
|
-
* // 'String error'
|
|
39
|
-
*
|
|
40
|
-
* FormErrorHandler.extractMessage({ message: 'Object error' });
|
|
41
|
-
* // 'Object error'
|
|
42
|
-
*
|
|
43
|
-
* FormErrorHandler.extractMessage(null);
|
|
44
|
-
* // 'null'
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
static extractMessage(e) {
|
|
48
|
-
return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e ? String(e.message) : String(e);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Создать ValidationError с заданными параметрами
|
|
52
|
-
*
|
|
53
|
-
* Утилитная функция для создания ValidationError объектов
|
|
54
|
-
*
|
|
55
|
-
* @param code Код ошибки
|
|
56
|
-
* @param message Сообщение ошибки
|
|
57
|
-
* @param field Поле (опционально)
|
|
58
|
-
* @returns ValidationError объект
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* const error = FormErrorHandler.createValidationError(
|
|
63
|
-
* 'required',
|
|
64
|
-
* 'This field is required',
|
|
65
|
-
* 'email'
|
|
66
|
-
* );
|
|
67
|
-
* // { code: 'required', message: 'This field is required', field: 'email' }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
static createValidationError(e, t, r) {
|
|
71
|
-
return {
|
|
72
|
-
code: e,
|
|
73
|
-
message: t,
|
|
74
|
-
params: r ? { field: r } : void 0
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Проверить, является ли объект ValidationError
|
|
79
|
-
*
|
|
80
|
-
* Type guard для ValidationError
|
|
81
|
-
*
|
|
82
|
-
* @param value Значение для проверки
|
|
83
|
-
* @returns true если value является ValidationError
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* if (FormErrorHandler.isValidationError(result)) {
|
|
88
|
-
* console.log(result.code); // OK, типобезопасно
|
|
89
|
-
* }
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
static isValidationError(e) {
|
|
93
|
-
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const u = /* @__PURE__ */ new WeakMap();
|
|
97
|
-
function w(n) {
|
|
98
|
-
u.set(n, (u.get(n) ?? 0) + 1);
|
|
99
|
-
}
|
|
100
|
-
function E(n) {
|
|
101
|
-
const e = u.get(n);
|
|
102
|
-
e !== void 0 && (e <= 1 ? u.delete(n) : u.set(n, e - 1));
|
|
103
|
-
}
|
|
104
|
-
function O(n) {
|
|
105
|
-
return u.has(n);
|
|
106
|
-
}
|
|
107
|
-
const h = /* @__PURE__ */ new WeakMap();
|
|
108
|
-
function D(n, e) {
|
|
109
|
-
h.set(n, e);
|
|
110
|
-
}
|
|
111
|
-
function p(n) {
|
|
112
|
-
return h.get(n);
|
|
113
|
-
}
|
|
114
|
-
const y = "runOutsideEffect";
|
|
115
|
-
function g(n) {
|
|
116
|
-
return typeof n == "object" && n !== null && typeof n.then == "function";
|
|
117
|
-
}
|
|
118
|
-
function v(n, e) {
|
|
119
|
-
try {
|
|
120
|
-
const t = n();
|
|
121
|
-
g(t) && t.then(void 0, (r) => m.handle(r, e, l.LOG));
|
|
122
|
-
} catch (t) {
|
|
123
|
-
m.handle(t, e, l.LOG);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function F(n) {
|
|
127
|
-
return (...e) => {
|
|
128
|
-
i(() => n(...e));
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
function i(n) {
|
|
132
|
-
let e = !1;
|
|
133
|
-
return queueMicrotask(() => {
|
|
134
|
-
e || v(n, y);
|
|
135
|
-
}), () => {
|
|
136
|
-
e = !0;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function V(n, e) {
|
|
140
|
-
return () => {
|
|
141
|
-
e(() => v(n, "safeDebouncedCallback"));
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function W(n, e, t, r) {
|
|
145
|
-
return a(() => {
|
|
146
|
-
const s = n.map((f) => f.value);
|
|
147
|
-
if (r?.when && !r.when(...s)) return;
|
|
148
|
-
const o = t(...s);
|
|
149
|
-
e.peek() !== o && (e.value = o);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function N(n, e, t) {
|
|
153
|
-
return a(() => {
|
|
154
|
-
const r = n.value;
|
|
155
|
-
if (t?.when && !t.when()) return;
|
|
156
|
-
const s = t?.transform ? t.transform(r) : r;
|
|
157
|
-
e.peek() !== s && (e.value = s);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function x(n, e, t) {
|
|
161
|
-
let r = !0;
|
|
162
|
-
return a(() => {
|
|
163
|
-
const s = n.value;
|
|
164
|
-
r && (r = !1, !t?.immediate) || e(s);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function k(n, e, t) {
|
|
168
|
-
return a(() => {
|
|
169
|
-
const r = e(), s = p(n);
|
|
170
|
-
s && i(() => {
|
|
171
|
-
r ? s.enable() : (s.disable(), t?.resetOnDisable && s.reset());
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function C(n, e, t) {
|
|
176
|
-
return k(n, () => !e(), t);
|
|
177
|
-
}
|
|
178
|
-
function M(n, e) {
|
|
179
|
-
let t = !1;
|
|
180
|
-
return a(() => {
|
|
181
|
-
const r = n.value;
|
|
182
|
-
t || i(() => {
|
|
183
|
-
const s = e(r);
|
|
184
|
-
if (n.peek() !== s) {
|
|
185
|
-
t = !0;
|
|
186
|
-
try {
|
|
187
|
-
n.value = s;
|
|
188
|
-
} finally {
|
|
189
|
-
t = !1;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function j(n, e, t) {
|
|
196
|
-
const r = t?.resetValue ?? null;
|
|
197
|
-
return a(() => {
|
|
198
|
-
const s = e();
|
|
199
|
-
i(() => {
|
|
200
|
-
s && n.peek() !== r && (n.value = r);
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
function L(n, e, t) {
|
|
205
|
-
const r = t?.transform;
|
|
206
|
-
let s = !1;
|
|
207
|
-
const o = a(() => {
|
|
208
|
-
const c = n.value;
|
|
209
|
-
s || i(() => {
|
|
210
|
-
s = !0;
|
|
211
|
-
try {
|
|
212
|
-
const d = r ? r(c) : c;
|
|
213
|
-
e.peek() !== d && (e.value = d);
|
|
214
|
-
} finally {
|
|
215
|
-
s = !1;
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}), f = a(() => {
|
|
219
|
-
const c = e.value;
|
|
220
|
-
s || i(() => {
|
|
221
|
-
s = !0;
|
|
222
|
-
try {
|
|
223
|
-
n.peek() !== c && (n.value = c);
|
|
224
|
-
} finally {
|
|
225
|
-
s = !1;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
return () => {
|
|
230
|
-
o(), f();
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
function T(n, e) {
|
|
234
|
-
let t = !0;
|
|
235
|
-
return a(() => {
|
|
236
|
-
if (n.forEach((r) => r.value), t) {
|
|
237
|
-
t = !1;
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
i(() => e());
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
export {
|
|
244
|
-
l as E,
|
|
245
|
-
m as F,
|
|
246
|
-
j as a,
|
|
247
|
-
T as b,
|
|
248
|
-
N as c,
|
|
249
|
-
D as d,
|
|
250
|
-
k as e,
|
|
251
|
-
F as f,
|
|
252
|
-
p as g,
|
|
253
|
-
V as h,
|
|
254
|
-
O as i,
|
|
255
|
-
W as j,
|
|
256
|
-
C as k,
|
|
257
|
-
w as m,
|
|
258
|
-
i as r,
|
|
259
|
-
L as s,
|
|
260
|
-
M as t,
|
|
261
|
-
E as u,
|
|
262
|
-
x as w
|
|
263
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FormModel } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Создать реактивную модель данных формы (слой M1).
|
|
4
|
-
*
|
|
5
|
-
* @group Model
|
|
6
|
-
* @param initial Начальные значения (объект). Определяют форму данных и initial-снимок.
|
|
7
|
-
* @returns {@link FormModel} с value-доступом, `$`-сигналами и API (get/set/patch/isDirty/reset/signalAt).
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const model = createModel<{ email: string; tags: string[] }>({ email: '', tags: [] });
|
|
12
|
-
* model.email = 'a@b.c';
|
|
13
|
-
* model.$.email.value; // 'a@b.c' (сигнал)
|
|
14
|
-
* model.tags.push('x');
|
|
15
|
-
* model.get(); // { email: 'a@b.c', tags: ['x'] }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function createModel<T extends object>(initial: T): FormModel<T>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Слой данных FormModel (M1) — публичные экспорты.
|
|
3
|
-
*
|
|
4
|
-
* @group Model
|
|
5
|
-
* @module core/model
|
|
6
|
-
*/
|
|
7
|
-
export { createModel } from './form-model';
|
|
8
|
-
export { validateModel, validateModelSync, validateFormModel } from './validate-model';
|
|
9
|
-
export type { ModelValidator, ModelValidationResult } from './validate-model';
|
|
10
|
-
export { computeFrom, copyFrom, watchField, enableWhen, disableWhen, transformValue, resetWhen, syncFields, revalidateWhen, } from './behaviors';
|
|
11
|
-
export type { BehaviorCleanup } from './behaviors';
|
|
12
|
-
export type { FormModel, ModelArray, ModelObject, ModelValue, ModelSignals, ModelApi, PathAwareSignal, } from './types';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Утилиты для работы с формами
|
|
3
|
-
*
|
|
4
|
-
* Централизованные вспомогательные классы и функции.
|
|
5
|
-
*/
|
|
6
|
-
export { SubscriptionManager } from './subscription-manager';
|
|
7
|
-
export { isFormNode, isFieldNode, isGroupNode, isArrayNode, getNodeType } from './type-guards';
|
|
8
|
-
export { FormErrorHandler, ErrorStrategy } from './error-handler';
|
|
9
|
-
export { createForm, createFormFromModel } from './create-form';
|
|
10
|
-
export type { CreateFormFromModelArgs } from './create-form';
|
|
11
|
-
export { registerSignalNode, getNodeForSignal } from './signal-node-registry';
|
|
12
|
-
export { markDerived, isDerived, unmarkDerived } from './derived-registry';
|
|
13
|
-
export { uniqueId } from './unique-id';
|
|
14
|
-
export { safeCallback, runOutsideEffect, safeDebouncedCallback } from './safe-effect';
|
|
15
|
-
export { FormSubmitter } from './form-submitter';
|
|
16
|
-
export type { SubmittableForm, SubmitOptions, SubmitResult } from './form-submitter';
|
|
17
|
-
export { FormStatusMachine } from './status-machine';
|
|
18
|
-
export type { StatusEvent } from './status-machine';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|