@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.
Files changed (99) hide show
  1. package/dist/behaviors-DzYL8kY_.js +499 -0
  2. package/dist/behaviors.d.ts +6 -2
  3. package/dist/behaviors.js +19 -227
  4. package/dist/core/behavior/behavior-context.d.ts +6 -2
  5. package/dist/core/behavior/create-field-path.d.ts +3 -16
  6. package/dist/core/nodes/group-node.d.ts +14 -193
  7. package/dist/core/types/form-context.d.ts +10 -4
  8. package/dist/core/utils/field-path.d.ts +48 -0
  9. package/dist/core/utils/index.d.ts +1 -0
  10. package/dist/core/validation/core/validate-tree.d.ts +10 -4
  11. package/dist/core/validation/field-path.d.ts +3 -39
  12. package/dist/core/validation/validation-context.d.ts +23 -0
  13. package/dist/hooks/types.d.ts +328 -0
  14. package/dist/hooks/useFormControl.d.ts +13 -37
  15. package/dist/hooks/useFormControlValue.d.ts +167 -0
  16. package/dist/hooks/useSignalSubscription.d.ts +17 -0
  17. package/dist/index.d.ts +6 -1
  18. package/dist/index.js +2886 -8
  19. package/dist/{create-field-path-CdPF3lIK.js → registry-helpers-BRxAr6nG.js} +133 -347
  20. package/dist/validators-gXoHPdqM.js +418 -0
  21. package/dist/validators.d.ts +6 -2
  22. package/dist/validators.js +29 -296
  23. package/llms.txt +1283 -22
  24. package/package.json +8 -4
  25. package/dist/core/behavior/behavior-applicator.d.ts +0 -71
  26. package/dist/core/behavior/behavior-applicator.js +0 -92
  27. package/dist/core/behavior/behavior-context.js +0 -38
  28. package/dist/core/behavior/behavior-registry.js +0 -198
  29. package/dist/core/behavior/behaviors/compute-from.js +0 -84
  30. package/dist/core/behavior/behaviors/copy-from.js +0 -64
  31. package/dist/core/behavior/behaviors/enable-when.js +0 -81
  32. package/dist/core/behavior/behaviors/index.js +0 -11
  33. package/dist/core/behavior/behaviors/reset-when.js +0 -63
  34. package/dist/core/behavior/behaviors/revalidate-when.js +0 -51
  35. package/dist/core/behavior/behaviors/sync-fields.js +0 -66
  36. package/dist/core/behavior/behaviors/transform-value.js +0 -110
  37. package/dist/core/behavior/behaviors/watch-field.js +0 -56
  38. package/dist/core/behavior/compose-behavior.js +0 -166
  39. package/dist/core/behavior/create-field-path.js +0 -69
  40. package/dist/core/behavior/index.js +0 -17
  41. package/dist/core/behavior/types.js +0 -7
  42. package/dist/core/context/form-context-impl.js +0 -37
  43. package/dist/core/factories/index.js +0 -6
  44. package/dist/core/factories/node-factory.js +0 -281
  45. package/dist/core/nodes/array-node.js +0 -534
  46. package/dist/core/nodes/field-node.js +0 -510
  47. package/dist/core/nodes/form-node.js +0 -343
  48. package/dist/core/nodes/group-node/field-registry.d.ts +0 -191
  49. package/dist/core/nodes/group-node/field-registry.js +0 -215
  50. package/dist/core/nodes/group-node/index.d.ts +0 -11
  51. package/dist/core/nodes/group-node/index.js +0 -11
  52. package/dist/core/nodes/group-node/proxy-builder.d.ts +0 -71
  53. package/dist/core/nodes/group-node/proxy-builder.js +0 -161
  54. package/dist/core/nodes/group-node/state-manager.d.ts +0 -184
  55. package/dist/core/nodes/group-node/state-manager.js +0 -265
  56. package/dist/core/nodes/group-node.js +0 -770
  57. package/dist/core/types/deep-schema.js +0 -11
  58. package/dist/core/types/field-path.js +0 -4
  59. package/dist/core/types/form-context.js +0 -25
  60. package/dist/core/types/group-node-proxy.js +0 -31
  61. package/dist/core/types/index.js +0 -4
  62. package/dist/core/types/validation-schema.js +0 -10
  63. package/dist/core/utils/create-form.js +0 -24
  64. package/dist/core/utils/debounce.js +0 -197
  65. package/dist/core/utils/error-handler.js +0 -226
  66. package/dist/core/utils/field-path-navigator.js +0 -374
  67. package/dist/core/utils/index.js +0 -14
  68. package/dist/core/utils/registry-helpers.js +0 -79
  69. package/dist/core/utils/registry-stack.js +0 -86
  70. package/dist/core/utils/resources.js +0 -69
  71. package/dist/core/utils/subscription-manager.js +0 -214
  72. package/dist/core/utils/type-guards.js +0 -169
  73. package/dist/core/validation/core/apply-when.js +0 -41
  74. package/dist/core/validation/core/apply.js +0 -38
  75. package/dist/core/validation/core/index.js +0 -8
  76. package/dist/core/validation/core/validate-async.js +0 -45
  77. package/dist/core/validation/core/validate-tree.js +0 -37
  78. package/dist/core/validation/core/validate.js +0 -38
  79. package/dist/core/validation/field-path.js +0 -147
  80. package/dist/core/validation/index.js +0 -33
  81. package/dist/core/validation/validate-form.js +0 -152
  82. package/dist/core/validation/validation-applicator.js +0 -217
  83. package/dist/core/validation/validation-context.js +0 -75
  84. package/dist/core/validation/validation-registry.js +0 -298
  85. package/dist/core/validation/validators/array-validators.js +0 -86
  86. package/dist/core/validation/validators/date.js +0 -117
  87. package/dist/core/validation/validators/email.js +0 -60
  88. package/dist/core/validation/validators/index.js +0 -14
  89. package/dist/core/validation/validators/max-length.js +0 -60
  90. package/dist/core/validation/validators/max.js +0 -60
  91. package/dist/core/validation/validators/min-length.js +0 -60
  92. package/dist/core/validation/validators/min.js +0 -60
  93. package/dist/core/validation/validators/number.js +0 -90
  94. package/dist/core/validation/validators/pattern.js +0 -62
  95. package/dist/core/validation/validators/phone.js +0 -58
  96. package/dist/core/validation/validators/required.js +0 -69
  97. package/dist/core/validation/validators/url.js +0 -55
  98. package/dist/hooks/useFormControl.js +0 -298
  99. package/dist/node-factory-D7DOnSSN.js +0 -3200
@@ -1,298 +1,31 @@
1
- import { h as g, t as o, j as f, a as x, G as y, A } from "./node-factory-D7DOnSSN.js";
2
- import { T as G, V as U, k as B } from "./node-factory-D7DOnSSN.js";
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
- G as TreeValidationContextImpl,
273
- U as ValidationContextImpl,
274
- w as ValidationRegistry,
275
- R as apply,
276
- p as applyWhen,
277
- f as createFieldPath,
278
- H as date,
279
- V as email,
280
- B as extractKey,
281
- g as extractPath,
282
- C as max,
283
- T as maxLength,
284
- L as min,
285
- _ as minLength,
286
- M as notEmpty,
287
- P as number,
288
- q as pattern,
289
- I as phone,
290
- N as required,
291
- o as toFieldPath,
292
- z as url,
293
- m as validate,
294
- D as validateAsync,
295
- j as validateForm,
296
- W as validateItems,
297
- b as validateTree
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
  };