@reformer/core 1.1.0 → 2.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.
- package/dist/behaviors-DzYL8kY_.js +499 -0
- package/dist/behaviors.d.ts +6 -2
- package/dist/behaviors.js +19 -227
- package/dist/core/behavior/behavior-context.d.ts +6 -2
- package/dist/core/behavior/create-field-path.d.ts +3 -16
- package/dist/core/nodes/group-node.d.ts +14 -193
- package/dist/core/types/form-context.d.ts +10 -4
- package/dist/core/utils/field-path.d.ts +48 -0
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/validation/core/validate-tree.d.ts +10 -4
- package/dist/core/validation/field-path.d.ts +3 -39
- package/dist/core/validation/validation-context.d.ts +23 -0
- package/dist/hooks/types.d.ts +328 -0
- package/dist/hooks/useFormControl.d.ts +13 -37
- package/dist/hooks/useFormControlValue.d.ts +167 -0
- package/dist/hooks/useSignalSubscription.d.ts +17 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +2886 -8
- package/dist/{create-field-path-CdPF3lIK.js → registry-helpers-BRxAr6nG.js} +133 -347
- package/dist/validators-gXoHPdqM.js +418 -0
- package/dist/validators.d.ts +6 -2
- package/dist/validators.js +29 -296
- package/llms.txt +1283 -22
- package/package.json +8 -4
- package/dist/core/behavior/behavior-applicator.d.ts +0 -71
- package/dist/core/behavior/behavior-applicator.js +0 -92
- package/dist/core/behavior/behavior-context.js +0 -38
- package/dist/core/behavior/behavior-registry.js +0 -198
- package/dist/core/behavior/behaviors/compute-from.js +0 -84
- package/dist/core/behavior/behaviors/copy-from.js +0 -64
- package/dist/core/behavior/behaviors/enable-when.js +0 -81
- package/dist/core/behavior/behaviors/index.js +0 -11
- package/dist/core/behavior/behaviors/reset-when.js +0 -63
- package/dist/core/behavior/behaviors/revalidate-when.js +0 -51
- package/dist/core/behavior/behaviors/sync-fields.js +0 -66
- package/dist/core/behavior/behaviors/transform-value.js +0 -110
- package/dist/core/behavior/behaviors/watch-field.js +0 -56
- package/dist/core/behavior/compose-behavior.js +0 -166
- package/dist/core/behavior/create-field-path.js +0 -69
- package/dist/core/behavior/index.js +0 -17
- package/dist/core/behavior/types.js +0 -7
- package/dist/core/context/form-context-impl.js +0 -37
- package/dist/core/factories/index.js +0 -6
- package/dist/core/factories/node-factory.js +0 -281
- package/dist/core/nodes/array-node.js +0 -534
- package/dist/core/nodes/field-node.js +0 -510
- package/dist/core/nodes/form-node.js +0 -343
- package/dist/core/nodes/group-node/field-registry.d.ts +0 -191
- package/dist/core/nodes/group-node/field-registry.js +0 -215
- package/dist/core/nodes/group-node/index.d.ts +0 -11
- package/dist/core/nodes/group-node/index.js +0 -11
- package/dist/core/nodes/group-node/proxy-builder.d.ts +0 -71
- package/dist/core/nodes/group-node/proxy-builder.js +0 -161
- package/dist/core/nodes/group-node/state-manager.d.ts +0 -184
- package/dist/core/nodes/group-node/state-manager.js +0 -265
- package/dist/core/nodes/group-node.js +0 -770
- package/dist/core/types/deep-schema.js +0 -11
- package/dist/core/types/field-path.js +0 -4
- package/dist/core/types/form-context.js +0 -25
- package/dist/core/types/group-node-proxy.js +0 -31
- package/dist/core/types/index.js +0 -4
- package/dist/core/types/validation-schema.js +0 -10
- package/dist/core/utils/create-form.js +0 -24
- package/dist/core/utils/debounce.js +0 -197
- package/dist/core/utils/error-handler.js +0 -226
- package/dist/core/utils/field-path-navigator.js +0 -374
- package/dist/core/utils/index.js +0 -14
- package/dist/core/utils/registry-helpers.js +0 -79
- package/dist/core/utils/registry-stack.js +0 -86
- package/dist/core/utils/resources.js +0 -69
- package/dist/core/utils/subscription-manager.js +0 -214
- package/dist/core/utils/type-guards.js +0 -169
- package/dist/core/validation/core/apply-when.js +0 -41
- package/dist/core/validation/core/apply.js +0 -38
- package/dist/core/validation/core/index.js +0 -8
- package/dist/core/validation/core/validate-async.js +0 -45
- package/dist/core/validation/core/validate-tree.js +0 -37
- package/dist/core/validation/core/validate.js +0 -38
- package/dist/core/validation/field-path.js +0 -147
- package/dist/core/validation/index.js +0 -33
- package/dist/core/validation/validate-form.js +0 -152
- package/dist/core/validation/validation-applicator.js +0 -217
- package/dist/core/validation/validation-context.js +0 -75
- package/dist/core/validation/validation-registry.js +0 -298
- package/dist/core/validation/validators/array-validators.js +0 -86
- package/dist/core/validation/validators/date.js +0 -117
- package/dist/core/validation/validators/email.js +0 -60
- package/dist/core/validation/validators/index.js +0 -14
- package/dist/core/validation/validators/max-length.js +0 -60
- package/dist/core/validation/validators/max.js +0 -60
- package/dist/core/validation/validators/min-length.js +0 -60
- package/dist/core/validation/validators/min.js +0 -60
- package/dist/core/validation/validators/number.js +0 -90
- package/dist/core/validation/validators/pattern.js +0 -62
- package/dist/core/validation/validators/phone.js +0 -58
- package/dist/core/validation/validators/required.js +0 -69
- package/dist/core/validation/validators/url.js +0 -55
- package/dist/hooks/useFormControl.js +0 -298
- package/dist/node-factory-D7DOnSSN.js +0 -3200
package/dist/validators.js
CHANGED
|
@@ -1,298 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { g as u, V as w } from "./create-field-path-CdPF3lIK.js";
|
|
4
|
-
function m(r, e, a) {
|
|
5
|
-
if (!r) return;
|
|
6
|
-
const t = g(r);
|
|
7
|
-
u().registerSync(t, e, a);
|
|
8
|
-
}
|
|
9
|
-
function D(r, e, a) {
|
|
10
|
-
const t = g(r);
|
|
11
|
-
u().registerAsync(t, e, a);
|
|
12
|
-
}
|
|
13
|
-
function b(r, e) {
|
|
14
|
-
u().registerTree(r, e);
|
|
15
|
-
}
|
|
16
|
-
function R(r, e) {
|
|
17
|
-
if (!Array.isArray(r) && !Array.isArray(e) && r && !("__key" in r) && !("__path" in r)) {
|
|
18
|
-
e(r);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const a = (Array.isArray(r) ? r : [r]).filter(
|
|
22
|
-
Boolean
|
|
23
|
-
), t = Array.isArray(e) ? e : [e];
|
|
24
|
-
for (const n of a) {
|
|
25
|
-
const s = o(n);
|
|
26
|
-
for (const c of t)
|
|
27
|
-
c(s);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function p(r, e, a) {
|
|
31
|
-
const t = g(r);
|
|
32
|
-
u().enterCondition(t, e);
|
|
33
|
-
try {
|
|
34
|
-
const n = f();
|
|
35
|
-
a(n);
|
|
36
|
-
} finally {
|
|
37
|
-
u().exitCondition();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function N(r, e) {
|
|
41
|
-
r && m(r, (a) => a == null || a === "" ? {
|
|
42
|
-
code: "required",
|
|
43
|
-
message: e?.message || "Поле обязательно для заполнения",
|
|
44
|
-
params: e?.params
|
|
45
|
-
} : typeof a == "boolean" && a !== !0 ? {
|
|
46
|
-
code: "required",
|
|
47
|
-
message: e?.message || "Поле обязательно для заполнения",
|
|
48
|
-
params: e?.params
|
|
49
|
-
} : null);
|
|
50
|
-
}
|
|
51
|
-
function L(r, e, a) {
|
|
52
|
-
r && m(r, (t) => t == null ? null : t < e ? {
|
|
53
|
-
code: "min",
|
|
54
|
-
message: a?.message || `Минимальное значение: ${e}`,
|
|
55
|
-
params: { min: e, actual: t, ...a?.params }
|
|
56
|
-
} : null);
|
|
57
|
-
}
|
|
58
|
-
function C(r, e, a) {
|
|
59
|
-
r && m(r, (t) => t == null ? null : t > e ? {
|
|
60
|
-
code: "max",
|
|
61
|
-
message: a?.message || `Максимальное значение: ${e}`,
|
|
62
|
-
params: { max: e, actual: t, ...a?.params }
|
|
63
|
-
} : null);
|
|
64
|
-
}
|
|
65
|
-
function _(r, e, a) {
|
|
66
|
-
r && m(r, (t) => t && t.length < e ? {
|
|
67
|
-
code: "minLength",
|
|
68
|
-
message: a?.message || `Минимальная длина: ${e} символов`,
|
|
69
|
-
params: { minLength: e, actualLength: t.length, ...a?.params }
|
|
70
|
-
} : null);
|
|
71
|
-
}
|
|
72
|
-
function T(r, e, a) {
|
|
73
|
-
r && m(r, (t) => t && t.length > e ? {
|
|
74
|
-
code: "maxLength",
|
|
75
|
-
message: a?.message || `Максимальная длина: ${e} символов`,
|
|
76
|
-
params: { maxLength: e, actualLength: t.length, ...a?.params }
|
|
77
|
-
} : null);
|
|
78
|
-
}
|
|
79
|
-
function V(r, e) {
|
|
80
|
-
if (!r) return;
|
|
81
|
-
const a = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
82
|
-
m(r, (t) => t ? a.test(t) ? null : {
|
|
83
|
-
code: "email",
|
|
84
|
-
message: e?.message || "Неверный формат email",
|
|
85
|
-
params: e?.params
|
|
86
|
-
} : null);
|
|
87
|
-
}
|
|
88
|
-
function q(r, e, a) {
|
|
89
|
-
r && m(r, (t) => t ? e.test(t) ? null : {
|
|
90
|
-
code: "pattern",
|
|
91
|
-
message: a?.message || "Значение не соответствует требуемому формату",
|
|
92
|
-
params: { pattern: e.source, ...a?.params }
|
|
93
|
-
} : null);
|
|
94
|
-
}
|
|
95
|
-
function z(r, e) {
|
|
96
|
-
if (!r) return;
|
|
97
|
-
const a = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/i, t = /^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/i;
|
|
98
|
-
m(r, (n) => n ? (e?.requireProtocol ? t : a).test(n) ? e?.allowedProtocols && e.allowedProtocols.length > 0 && !e.allowedProtocols.some(
|
|
99
|
-
(l) => n.toLowerCase().startsWith(`${l}://`)
|
|
100
|
-
) ? {
|
|
101
|
-
code: "url_protocol",
|
|
102
|
-
message: e?.message || `URL должен использовать один из протоколов: ${e.allowedProtocols.join(", ")}`,
|
|
103
|
-
params: { allowedProtocols: e.allowedProtocols, ...e?.params }
|
|
104
|
-
} : null : {
|
|
105
|
-
code: "url",
|
|
106
|
-
message: e?.message || "Неверный формат URL",
|
|
107
|
-
params: e?.params
|
|
108
|
-
} : null);
|
|
109
|
-
}
|
|
110
|
-
function I(r, e) {
|
|
111
|
-
if (!r) return;
|
|
112
|
-
const a = e?.format || "any", t = {
|
|
113
|
-
// Международный формат: +1234567890 или +1 234 567 8900
|
|
114
|
-
international: /^\+?[1-9]\d{1,14}$/,
|
|
115
|
-
// Российский формат: +7 (XXX) XXX-XX-XX, 8 (XXX) XXX-XX-XX, и вариации
|
|
116
|
-
ru: /^(\+7|7|8)?[\s\-]?\(?[489][0-9]{2}\)?[\s\-]?[0-9]{3}[\s\-]?[0-9]{2}[\s\-]?[0-9]{2}$/,
|
|
117
|
-
// US формат: (123) 456-7890, 123-456-7890, 1234567890
|
|
118
|
-
us: /^(\+?1)?[\s\-]?\(?[2-9]\d{2}\)?[\s\-]?\d{3}[\s\-]?\d{4}$/,
|
|
119
|
-
// Любой формат: минимум 10 цифр с возможными разделителями
|
|
120
|
-
any: /^[\+]?[(]?[0-9]{1,4}[)]?[-\s\.]?[(]?[0-9]{1,4}[)]?[-\s\.]?[0-9]{1,9}$/
|
|
121
|
-
};
|
|
122
|
-
m(r, (n) => {
|
|
123
|
-
if (!n)
|
|
124
|
-
return null;
|
|
125
|
-
if (!t[a].test(n)) {
|
|
126
|
-
const c = {
|
|
127
|
-
international: "Введите телефон в международном формате (например, +1234567890)",
|
|
128
|
-
ru: "Введите российский номер телефона (например, +7 900 123-45-67)",
|
|
129
|
-
us: "Введите американский номер телефона (например, (123) 456-7890)",
|
|
130
|
-
any: "Неверный формат телефона"
|
|
131
|
-
};
|
|
132
|
-
return {
|
|
133
|
-
code: "phone",
|
|
134
|
-
message: e?.message || c[a],
|
|
135
|
-
params: { format: a, ...e?.params }
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function P(r, e) {
|
|
142
|
-
r && m(r, (a) => a == null ? null : typeof a != "number" || isNaN(a) ? {
|
|
143
|
-
code: "number",
|
|
144
|
-
message: e?.message || "Значение должно быть числом",
|
|
145
|
-
params: e?.params
|
|
146
|
-
} : e?.integer && !Number.isInteger(a) ? {
|
|
147
|
-
code: "number_integer",
|
|
148
|
-
message: e?.message || "Значение должно быть целым числом",
|
|
149
|
-
params: e?.params
|
|
150
|
-
} : e?.min !== void 0 && a < e.min ? {
|
|
151
|
-
code: "number_min",
|
|
152
|
-
message: e?.message || `Значение должно быть не менее ${e.min}`,
|
|
153
|
-
params: { min: e.min, ...e?.params }
|
|
154
|
-
} : e?.max !== void 0 && a > e.max ? {
|
|
155
|
-
code: "number_max",
|
|
156
|
-
message: e?.message || `Значение должно быть не более ${e.max}`,
|
|
157
|
-
params: { max: e.max, ...e?.params }
|
|
158
|
-
} : e?.multipleOf !== void 0 && a % e.multipleOf !== 0 ? {
|
|
159
|
-
code: "number_multiple",
|
|
160
|
-
message: e?.message || `Значение должно быть кратно ${e.multipleOf}`,
|
|
161
|
-
params: { multipleOf: e.multipleOf, ...e?.params }
|
|
162
|
-
} : e?.allowNegative === !1 && a < 0 ? {
|
|
163
|
-
code: "number_negative",
|
|
164
|
-
message: e?.message || "Отрицательные числа не допускаются",
|
|
165
|
-
params: e?.params
|
|
166
|
-
} : e?.allowZero === !1 && a === 0 ? {
|
|
167
|
-
code: "number_zero",
|
|
168
|
-
message: e?.message || "Ноль не допускается",
|
|
169
|
-
params: e?.params
|
|
170
|
-
} : null);
|
|
171
|
-
}
|
|
172
|
-
function H(r, e) {
|
|
173
|
-
r && m(r, (a) => {
|
|
174
|
-
if (!a)
|
|
175
|
-
return null;
|
|
176
|
-
let t;
|
|
177
|
-
if (a instanceof Date)
|
|
178
|
-
t = a;
|
|
179
|
-
else if (typeof a == "string")
|
|
180
|
-
t = new Date(a);
|
|
181
|
-
else
|
|
182
|
-
return {
|
|
183
|
-
code: "date_invalid",
|
|
184
|
-
message: e?.message || "Неверный формат даты",
|
|
185
|
-
params: e?.params
|
|
186
|
-
};
|
|
187
|
-
if (isNaN(t.getTime()))
|
|
188
|
-
return {
|
|
189
|
-
code: "date_invalid",
|
|
190
|
-
message: e?.message || "Неверный формат даты",
|
|
191
|
-
params: e?.params
|
|
192
|
-
};
|
|
193
|
-
const n = /* @__PURE__ */ new Date();
|
|
194
|
-
if (n.setHours(0, 0, 0, 0), e?.minDate) {
|
|
195
|
-
const s = new Date(e.minDate);
|
|
196
|
-
if (s.setHours(0, 0, 0, 0), t < s)
|
|
197
|
-
return {
|
|
198
|
-
code: "date_min",
|
|
199
|
-
message: e?.message || `Дата должна быть не ранее ${s.toLocaleDateString()}`,
|
|
200
|
-
params: { minDate: e.minDate, ...e?.params }
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
if (e?.maxDate) {
|
|
204
|
-
const s = new Date(e.maxDate);
|
|
205
|
-
if (s.setHours(0, 0, 0, 0), t > s)
|
|
206
|
-
return {
|
|
207
|
-
code: "date_max",
|
|
208
|
-
message: e?.message || `Дата должна быть не позднее ${s.toLocaleDateString()}`,
|
|
209
|
-
params: { maxDate: e.maxDate, ...e?.params }
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
if (e?.noFuture && t > n)
|
|
213
|
-
return {
|
|
214
|
-
code: "date_future",
|
|
215
|
-
message: e?.message || "Дата не может быть в будущем",
|
|
216
|
-
params: e?.params
|
|
217
|
-
};
|
|
218
|
-
if (e?.noPast && t < n)
|
|
219
|
-
return {
|
|
220
|
-
code: "date_past",
|
|
221
|
-
message: e?.message || "Дата не может быть в прошлом",
|
|
222
|
-
params: e?.params
|
|
223
|
-
};
|
|
224
|
-
if (e?.minAge !== void 0 || e?.maxAge !== void 0) {
|
|
225
|
-
const s = Math.floor(
|
|
226
|
-
(n.getTime() - t.getTime()) / 315576e5
|
|
227
|
-
);
|
|
228
|
-
if (e?.minAge !== void 0 && s < e.minAge)
|
|
229
|
-
return {
|
|
230
|
-
code: "date_min_age",
|
|
231
|
-
message: e?.message || `Минимальный возраст: ${e.minAge} лет`,
|
|
232
|
-
params: { minAge: e.minAge, currentAge: s, ...e?.params }
|
|
233
|
-
};
|
|
234
|
-
if (e?.maxAge !== void 0 && s > e.maxAge)
|
|
235
|
-
return {
|
|
236
|
-
code: "date_max_age",
|
|
237
|
-
message: e?.message || `Максимальный возраст: ${e.maxAge} лет`,
|
|
238
|
-
params: { maxAge: e.maxAge, currentAge: s, ...e?.params }
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return null;
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function M(r, e) {
|
|
245
|
-
r && _(r, 1, {
|
|
246
|
-
message: e?.message || "Массив не должен быть пустым",
|
|
247
|
-
params: { minLength: 1, ...e?.params }
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
function W(r, e) {
|
|
251
|
-
if (!r) return;
|
|
252
|
-
const a = g(r);
|
|
253
|
-
u().registerArrayItemValidation(a, e);
|
|
254
|
-
}
|
|
255
|
-
function i(r) {
|
|
256
|
-
return r instanceof x ? [r] : r instanceof y ? Array.from(r.getAllFields()).flatMap(i) : r instanceof A ? r.map((e) => i(e)).flat() : [];
|
|
257
|
-
}
|
|
258
|
-
async function j(r, e) {
|
|
259
|
-
const a = new w();
|
|
260
|
-
a.beginRegistration();
|
|
261
|
-
let t = [], n = !1;
|
|
262
|
-
try {
|
|
263
|
-
const s = f();
|
|
264
|
-
e(s), t = a.getCurrentContext()?.getValidators() || [], a.cancelRegistration(), n = !0, r.clearErrors();
|
|
265
|
-
const l = i(r);
|
|
266
|
-
return await Promise.all(l.map((d) => d.validate())), t.length > 0 && await r.applyContextualValidators(t), r.valid.value;
|
|
267
|
-
} catch (s) {
|
|
268
|
-
throw n || a.cancelRegistration(), s;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
1
|
+
import { T as t, V as s, j as i, k as l, w as r, b as n, p as m, l as o, o as d, m as p, n as x, x as h, t as y, q as v, s as c, r as u, u as V, e as f, f as g, v as F, y as I, h as P } from "./validators-gXoHPdqM.js";
|
|
2
|
+
import { V as b, c as q, a as C, e as L, t as j } from "./registry-helpers-BRxAr6nG.js";
|
|
271
3
|
export {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
4
|
+
t as TreeValidationContextImpl,
|
|
5
|
+
s as ValidationContextImpl,
|
|
6
|
+
b as ValidationRegistry,
|
|
7
|
+
i as apply,
|
|
8
|
+
l as applyWhen,
|
|
9
|
+
q as createFieldPath,
|
|
10
|
+
r as date,
|
|
11
|
+
n as default,
|
|
12
|
+
m as email,
|
|
13
|
+
C as extractKey,
|
|
14
|
+
L as extractPath,
|
|
15
|
+
o as max,
|
|
16
|
+
d as maxLength,
|
|
17
|
+
p as min,
|
|
18
|
+
x as minLength,
|
|
19
|
+
h as notEmpty,
|
|
20
|
+
y as number,
|
|
21
|
+
v as pattern,
|
|
22
|
+
c as phone,
|
|
23
|
+
u as required,
|
|
24
|
+
j as toFieldPath,
|
|
25
|
+
V as url,
|
|
26
|
+
f as validate,
|
|
27
|
+
g as validateAsync,
|
|
28
|
+
F as validateForm,
|
|
29
|
+
I as validateItems,
|
|
30
|
+
P as validateTree
|
|
298
31
|
};
|