@reformer/core 2.0.0-beta.7 → 2.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 (147) hide show
  1. package/dist/behaviors/compute-from.d.ts +2 -0
  2. package/dist/behaviors/compute-from.js +31 -0
  3. package/dist/behaviors/copy-from.d.ts +2 -0
  4. package/dist/behaviors/copy-from.js +29 -0
  5. package/dist/behaviors/enable-when.d.ts +2 -0
  6. package/dist/behaviors/enable-when.js +25 -0
  7. package/dist/behaviors/reset-when.d.ts +2 -0
  8. package/dist/behaviors/reset-when.js +24 -0
  9. package/dist/behaviors/revalidate-when.d.ts +2 -0
  10. package/dist/behaviors/revalidate-when.js +18 -0
  11. package/dist/behaviors/sync-fields.d.ts +2 -0
  12. package/dist/behaviors/sync-fields.js +41 -0
  13. package/dist/behaviors/transform-value.d.ts +2 -0
  14. package/dist/behaviors/transform-value.js +45 -0
  15. package/dist/behaviors/watch-field.d.ts +2 -0
  16. package/dist/behaviors/watch-field.js +21 -0
  17. package/dist/behaviors.js +26 -19
  18. package/dist/core/behavior/behavior-context.d.ts +26 -12
  19. package/dist/core/behavior/behavior-registry.d.ts +15 -27
  20. package/dist/core/behavior/behaviors/compute-from.d.ts +50 -21
  21. package/dist/core/behavior/behaviors/copy-from.d.ts +39 -14
  22. package/dist/core/behavior/behaviors/enable-when.d.ts +88 -19
  23. package/dist/core/behavior/behaviors/reset-when.d.ts +31 -18
  24. package/dist/core/behavior/behaviors/revalidate-when.d.ts +40 -17
  25. package/dist/core/behavior/behaviors/sync-fields.d.ts +34 -14
  26. package/dist/core/behavior/behaviors/transform-value.d.ts +116 -44
  27. package/dist/core/behavior/behaviors/watch-field.d.ts +66 -21
  28. package/dist/core/behavior/compose-behavior.d.ts +2 -12
  29. package/dist/core/behavior/index.d.ts +0 -1
  30. package/dist/core/behavior/types.d.ts +2 -8
  31. package/dist/core/factories/node-factory.d.ts +6 -29
  32. package/dist/core/nodes/array-node.d.ts +11 -15
  33. package/dist/core/nodes/field-node.d.ts +43 -24
  34. package/dist/core/nodes/form-node.d.ts +18 -20
  35. package/dist/core/nodes/group-node.d.ts +25 -21
  36. package/dist/core/types/deep-schema.d.ts +2 -12
  37. package/dist/core/types/field-path.d.ts +1 -1
  38. package/dist/core/types/form-context.d.ts +26 -26
  39. package/dist/core/types/form-proxy.d.ts +1 -31
  40. package/dist/core/types/index.d.ts +16 -4
  41. package/dist/core/types/validation-schema.d.ts +3 -12
  42. package/dist/core/utils/abstract-registry.d.ts +74 -0
  43. package/dist/core/utils/aggregate-signals.d.ts +71 -0
  44. package/dist/core/utils/create-form.d.ts +1 -20
  45. package/dist/core/utils/error-handler.d.ts +1 -18
  46. package/dist/core/utils/field-path-navigator.d.ts +1 -1
  47. package/dist/core/utils/field-path.d.ts +23 -11
  48. package/dist/core/utils/form-observer.d.ts +176 -0
  49. package/dist/core/utils/form-proxy-builder.d.ts +25 -0
  50. package/dist/core/utils/form-submitter.d.ts +121 -0
  51. package/dist/core/utils/index.d.ts +8 -2
  52. package/dist/core/utils/registry-helpers.d.ts +0 -7
  53. package/dist/core/utils/safe-effect.d.ts +73 -0
  54. package/dist/core/utils/status-machine.d.ts +153 -0
  55. package/dist/core/utils/type-guards.d.ts +5 -23
  56. package/dist/core/utils/unique-id.d.ts +34 -7
  57. package/dist/core/validation/core/apply-when.d.ts +3 -9
  58. package/dist/core/validation/core/apply.d.ts +2 -13
  59. package/dist/core/validation/core/validate-async.d.ts +2 -8
  60. package/dist/core/validation/core/validate-tree.d.ts +0 -6
  61. package/dist/core/validation/core/validate.d.ts +1 -7
  62. package/dist/core/validation/index.d.ts +8 -2
  63. package/dist/core/validation/validate-form.d.ts +1 -38
  64. package/dist/core/validation/validation-applicator.d.ts +2 -21
  65. package/dist/core/validation/validation-context.d.ts +38 -14
  66. package/dist/core/validation/validation-registry.d.ts +11 -20
  67. package/dist/core/validation/validators/array-validators.d.ts +2 -12
  68. package/dist/core/validation/validators/date-utils.d.ts +26 -0
  69. package/dist/core/validation/validators/email.d.ts +2 -9
  70. package/dist/core/validation/validators/future-date.d.ts +35 -0
  71. package/dist/core/validation/validators/index.d.ts +7 -1
  72. package/dist/core/validation/validators/is-date.d.ts +36 -0
  73. package/dist/core/validation/validators/max-age.d.ts +36 -0
  74. package/dist/core/validation/validators/max-date.d.ts +36 -0
  75. package/dist/core/validation/validators/max-length.d.ts +3 -10
  76. package/dist/core/validation/validators/max.d.ts +3 -10
  77. package/dist/core/validation/validators/min-age.d.ts +36 -0
  78. package/dist/core/validation/validators/min-date.d.ts +36 -0
  79. package/dist/core/validation/validators/min-length.d.ts +3 -10
  80. package/dist/core/validation/validators/min.d.ts +3 -10
  81. package/dist/core/validation/validators/number.d.ts +2 -9
  82. package/dist/core/validation/validators/past-date.d.ts +35 -0
  83. package/dist/core/validation/validators/pattern.d.ts +2 -9
  84. package/dist/core/validation/validators/phone.d.ts +2 -9
  85. package/dist/core/validation/validators/required.d.ts +2 -9
  86. package/dist/core/validation/validators/url.d.ts +2 -9
  87. package/dist/date-utils-xUWFslTj.js +29 -0
  88. package/dist/field-path-DuKdGcIE.js +66 -0
  89. package/dist/hooks/types.d.ts +1 -1
  90. package/dist/hooks/useArrayLength.d.ts +31 -0
  91. package/dist/hooks/useFormControl.d.ts +4 -4
  92. package/dist/hooks/useFormControlValue.d.ts +2 -2
  93. package/dist/hooks/useHiddenCondition.d.ts +25 -0
  94. package/dist/hooks/useSignalSubscription.d.ts +1 -1
  95. package/dist/index-D25LsbRm.js +73 -0
  96. package/dist/index.d.ts +2 -0
  97. package/dist/index.js +1031 -714
  98. package/dist/registry-helpers-Bv_BJ1s-.js +615 -0
  99. package/dist/safe-effect-Dh8uw81c.js +20 -0
  100. package/dist/validate-C3XiA_zf.js +10 -0
  101. package/dist/validators/email.d.ts +2 -0
  102. package/dist/validators/email.js +13 -0
  103. package/dist/validators/future-date.d.ts +2 -0
  104. package/dist/validators/future-date.js +20 -0
  105. package/dist/validators/is-date.d.ts +2 -0
  106. package/dist/validators/is-date.js +12 -0
  107. package/dist/validators/max-age.d.ts +2 -0
  108. package/dist/validators/max-age.js +20 -0
  109. package/dist/validators/max-date.d.ts +2 -0
  110. package/dist/validators/max-date.js +20 -0
  111. package/dist/validators/max-length.d.ts +2 -0
  112. package/dist/validators/max-length.js +11 -0
  113. package/dist/validators/max.d.ts +2 -0
  114. package/dist/validators/max.js +11 -0
  115. package/dist/validators/min-age.d.ts +2 -0
  116. package/dist/validators/min-age.js +20 -0
  117. package/dist/validators/min-date.d.ts +2 -0
  118. package/dist/validators/min-date.js +20 -0
  119. package/dist/validators/min-length.d.ts +2 -0
  120. package/dist/validators/min-length.js +11 -0
  121. package/dist/validators/min.d.ts +2 -0
  122. package/dist/validators/min.js +11 -0
  123. package/dist/validators/number.d.ts +2 -0
  124. package/dist/validators/number.js +35 -0
  125. package/dist/validators/past-date.d.ts +2 -0
  126. package/dist/validators/past-date.js +20 -0
  127. package/dist/validators/pattern.d.ts +2 -0
  128. package/dist/validators/pattern.js +11 -0
  129. package/dist/validators/phone.d.ts +2 -0
  130. package/dist/validators/phone.js +35 -0
  131. package/dist/validators/required.d.ts +2 -0
  132. package/dist/validators/required.js +15 -0
  133. package/dist/validators/url.d.ts +2 -0
  134. package/dist/validators/url.js +19 -0
  135. package/dist/validators-BGsNOgT1.js +207 -0
  136. package/dist/validators.js +54 -29
  137. package/llms.txt +7878 -311
  138. package/package.json +83 -9
  139. package/dist/behaviors-DyPzh2-X.js +0 -508
  140. package/dist/core/behavior/create-field-path.d.ts +0 -7
  141. package/dist/core/context/form-context-impl.d.ts +0 -29
  142. package/dist/core/utils/debounce.d.ts +0 -160
  143. package/dist/core/utils/resources.d.ts +0 -41
  144. package/dist/core/validation/field-path.d.ts +0 -7
  145. package/dist/core/validation/validators/date.d.ts +0 -38
  146. package/dist/registry-helpers--8-OogF8.js +0 -477
  147. package/dist/validators-CWdzevnC.js +0 -397
@@ -1,477 +0,0 @@
1
- function v() {
2
- return h("");
3
- }
4
- function h(i) {
5
- return new Proxy({}, {
6
- get(t, e) {
7
- if (typeof e == "symbol")
8
- return;
9
- if (e === "__path" || e === "__fieldPath")
10
- return i || e;
11
- if (e === "__key") {
12
- const a = i.split(".");
13
- return a[a.length - 1] || e;
14
- }
15
- if (e === "then" || e === "catch" || e === "finally" || e === "constructor" || e === "toString" || e === "valueOf" || e === "toJSON")
16
- return;
17
- const r = i ? `${i}.${e}` : e, s = {
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- __key: e,
20
- __path: r,
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- __formType: void 0,
23
- __fieldType: void 0
24
- };
25
- return new Proxy(s, {
26
- get(a, n) {
27
- if (typeof n != "symbol") {
28
- if (n === "__path" || n === "__fieldPath") return r;
29
- if (n === "__key") return e;
30
- if (n !== "__formType" && n !== "__fieldType" && !(n === "then" || n === "catch" || n === "finally" || n === "constructor" || n === "toString" || n === "valueOf" || n === "toJSON"))
31
- return h(`${r}.${n}`);
32
- }
33
- }
34
- });
35
- }
36
- });
37
- }
38
- function y(i) {
39
- if (typeof i == "string")
40
- return i;
41
- if (i && typeof i == "object") {
42
- const t = i.__path;
43
- if (typeof t == "string")
44
- return t;
45
- }
46
- throw new Error("Invalid field path node: " + JSON.stringify(i));
47
- }
48
- function C(i) {
49
- const t = y(i);
50
- return h(t);
51
- }
52
- function S(i) {
53
- if (i && typeof i == "object" && "__key" in i)
54
- return i.__key;
55
- if (typeof i == "string") {
56
- const t = i.split(".");
57
- return t[t.length - 1];
58
- }
59
- throw new Error("Invalid field path node");
60
- }
61
- class g {
62
- stack = [];
63
- /**
64
- * Добавить элемент в стек
65
- * @param item - Элемент для добавления
66
- */
67
- push(t) {
68
- this.stack.push(t);
69
- }
70
- /**
71
- * Извлечь элемент из стека
72
- * @returns Извлеченный элемент или undefined если стек пуст
73
- */
74
- pop() {
75
- return this.stack.pop();
76
- }
77
- /**
78
- * Получить текущий элемент (вершину стека) без извлечения
79
- * @returns Текущий элемент или null если стек пуст
80
- */
81
- getCurrent() {
82
- return this.stack.length > 0 ? this.stack[this.stack.length - 1] : null;
83
- }
84
- /**
85
- * Извлечь элемент из стека с проверкой
86
- * Выводит предупреждение в DEV режиме если извлеченный элемент не совпадает с ожидаемым
87
- *
88
- * @param expected - Ожидаемый элемент
89
- * @param name - Имя реестра для отладки (например, 'ValidationRegistry')
90
- */
91
- verify(t, e) {
92
- this.pop();
93
- }
94
- /**
95
- * Получить длину стека
96
- * @returns Количество элементов в стеке
97
- */
98
- get length() {
99
- return this.stack.length;
100
- }
101
- /**
102
- * Проверить, пуст ли стек
103
- * @returns true если стек пуст
104
- */
105
- isEmpty() {
106
- return this.stack.length === 0;
107
- }
108
- /**
109
- * Очистить стек
110
- */
111
- clear() {
112
- this.stack = [];
113
- }
114
- }
115
- class x {
116
- validators = [];
117
- conditionStack = [];
118
- /**
119
- * Добавить валидатор в контекст
120
- */
121
- addValidator(t) {
122
- if (this.conditionStack.length > 0) {
123
- const e = this.conditionStack[this.conditionStack.length - 1];
124
- t.condition = e;
125
- }
126
- this.validators.push(t);
127
- }
128
- /**
129
- * Войти в условный блок
130
- */
131
- enterCondition(t, e) {
132
- this.conditionStack.push({ fieldPath: t, conditionFn: e });
133
- }
134
- /**
135
- * Выйти из условного блока
136
- */
137
- exitCondition() {
138
- this.conditionStack.pop();
139
- }
140
- /**
141
- * Получить все зарегистрированные валидаторы
142
- */
143
- getValidators() {
144
- return this.validators;
145
- }
146
- }
147
- class o {
148
- /**
149
- * Global stack активных реестров
150
- * Используется для изоляции форм друг от друга
151
- */
152
- static registryStack = new g();
153
- contextStack = [];
154
- validators = [];
155
- /**
156
- * Получить текущий активный реестр из global stack
157
- *
158
- * @returns Текущий активный реестр или null
159
- *
160
- * @example
161
- * ```typescript
162
- * // В schema-validators.ts
163
- * export function required(...) {
164
- * const registry = ValidationRegistry.getCurrent();
165
- * if (registry) {
166
- * registry.registerSync(...);
167
- * }
168
- * }
169
- * ```
170
- */
171
- static getCurrent() {
172
- return o.registryStack.getCurrent();
173
- }
174
- /**
175
- * Начать регистрацию валидаторов для формы
176
- *
177
- * Помещает this в global stack для изоляции форм
178
- */
179
- beginRegistration() {
180
- const t = new x();
181
- return this.contextStack.push(t), o.registryStack.push(this), t;
182
- }
183
- /**
184
- * Завершить регистрацию и применить валидаторы к GroupNode
185
- *
186
- * Извлекает this из global stack
187
- *
188
- * Сохраняет валидаторы в локальном состоянии (this.validators) вместо глобального WeakMap.
189
- */
190
- endRegistration(t) {
191
- const e = this.contextStack.pop();
192
- if (!e)
193
- throw new Error("No active registration context");
194
- o.registryStack.verify(this, "ValidationRegistry"), this.validators = e.getValidators(), this.applyArrayItemValidators(t, this.validators);
195
- }
196
- /**
197
- * Отменить регистрацию без применения валидаторов
198
- * Используется для временной валидации (например, в validateForm)
199
- *
200
- * Извлекает this из global stack
201
- */
202
- cancelRegistration() {
203
- if (!this.contextStack.pop())
204
- throw new Error("No active registration context to cancel");
205
- o.registryStack.verify(this, "ValidationRegistry");
206
- }
207
- /**
208
- * Получить текущий контекст регистрации
209
- */
210
- getCurrentContext() {
211
- return this.contextStack[this.contextStack.length - 1];
212
- }
213
- /**
214
- * Зарегистрировать синхронный валидатор
215
- */
216
- registerSync(t, e, r) {
217
- const s = this.getCurrentContext();
218
- if (!s)
219
- throw new Error("Validators can only be registered inside a validation schema function");
220
- s.addValidator({
221
- fieldPath: t,
222
- type: "sync",
223
- validator: e,
224
- options: r
225
- });
226
- }
227
- /**
228
- * Зарегистрировать асинхронный валидатор
229
- */
230
- registerAsync(t, e, r) {
231
- const s = this.getCurrentContext();
232
- if (!s)
233
- throw new Error("Validators can only be registered inside a validation schema function");
234
- s.addValidator({
235
- fieldPath: t,
236
- type: "async",
237
- validator: e,
238
- options: r
239
- });
240
- }
241
- /**
242
- * Зарегистрировать tree валидатор
243
- */
244
- registerTree(t, e) {
245
- const r = this.getCurrentContext();
246
- if (!r)
247
- throw new Error("Validators can only be registered inside a validation schema function");
248
- r.addValidator({
249
- fieldPath: e?.targetField || "__tree__",
250
- type: "tree",
251
- validator: t,
252
- options: e
253
- });
254
- }
255
- /**
256
- * Войти в условный блок
257
- */
258
- enterCondition(t, e) {
259
- const r = this.getCurrentContext();
260
- if (!r)
261
- throw new Error("Conditions can only be used inside a validation schema function");
262
- r.enterCondition(t, e);
263
- }
264
- /**
265
- * Выйти из условного блока
266
- */
267
- exitCondition() {
268
- const t = this.getCurrentContext();
269
- if (!t)
270
- throw new Error("No active condition");
271
- t.exitCondition();
272
- }
273
- /**
274
- * Зарегистрировать validation schema для элементов массива
275
- *
276
- * Используется функцией validateItems() для регистрации схемы валидации,
277
- * которая будет применяться к каждому элементу ArrayNode.
278
- *
279
- * @param fieldPath - Путь к ArrayNode полю
280
- * @param itemSchemaFn - Validation schema для элемента массива
281
- */
282
- registerArrayItemValidation(t, e) {
283
- const r = this.getCurrentContext();
284
- if (!r)
285
- throw new Error(
286
- "Array item validators can only be registered inside a validation schema function"
287
- );
288
- r.addValidator({
289
- fieldPath: t,
290
- type: "array-items",
291
- validator: e,
292
- options: {}
293
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
294
- });
295
- }
296
- /**
297
- * Получить зарегистрированные валидаторы для этого реестра
298
- *
299
- * Возвращает локальный массив валидаторов (без аргумента form).
300
- */
301
- getValidators() {
302
- return this.validators;
303
- }
304
- /**
305
- * Применить array-items validators к ArrayNode элементам
306
- * @private
307
- */
308
- applyArrayItemValidators(t, e) {
309
- const r = e.filter((s) => s.type === "array-items");
310
- if (r.length !== 0)
311
- for (const s of r) {
312
- const a = t[s.fieldPath.split(".")[0]];
313
- if (a && "applyValidationSchema" in a) {
314
- const n = s.validator;
315
- a.applyValidationSchema(n);
316
- }
317
- }
318
- }
319
- }
320
- class k {
321
- /**
322
- * Форма с типизированным Proxy-доступом к полям
323
- */
324
- form;
325
- _form;
326
- constructor(t) {
327
- this._form = t;
328
- const e = t._proxyInstance || t;
329
- this.form = e;
330
- }
331
- /**
332
- * Безопасно установить значение поля по строковому пути или FieldPath
333
- *
334
- * Автоматически использует emitEvent: false для предотвращения циклов
335
- *
336
- * @param path - Строковый путь к полю или FieldPath объект
337
- * @param value - Новое значение
338
- */
339
- setFieldValue(t, e) {
340
- const r = typeof t == "string" ? t : t.toString(), s = this._form.getFieldByPath(r);
341
- s && s.setValue(e, { emitEvent: !1 });
342
- }
343
- }
344
- class c {
345
- /**
346
- * Stack активных контекстов регистрации
347
- * Используется для изоляции форм друг от друга
348
- */
349
- static contextStack = new g();
350
- registrations = [];
351
- isRegistering = !1;
352
- /**
353
- * Получить текущий активный реестр из context stack
354
- *
355
- * @returns Текущий активный реестр или null
356
- *
357
- * @example
358
- * ```typescript
359
- * // В schema-behaviors.ts
360
- * export function copyFrom(...) {
361
- * const registry = BehaviorRegistry.getCurrent();
362
- * if (registry) {
363
- * registry.register({ ... });
364
- * }
365
- * }
366
- * ```
367
- */
368
- static getCurrent() {
369
- return c.contextStack.getCurrent();
370
- }
371
- /**
372
- * Начать регистрацию behaviors
373
- * Вызывается перед применением схемы
374
- *
375
- * Помещает this в context stack для изоляции форм
376
- */
377
- beginRegistration() {
378
- this.isRegistering = !0, this.registrations = [], c.contextStack.push(this);
379
- }
380
- /**
381
- * Зарегистрировать behavior handler
382
- * Вызывается функциями из schema-behaviors.ts
383
- *
384
- * @param handler - BehaviorHandlerFn функция
385
- * @param options - Опции behavior (debounce)
386
- *
387
- * @example
388
- * ```typescript
389
- * const handler = createCopyBehavior(target, source, { when: ... });
390
- * registry.register(handler, { debounce: 300 });
391
- * ```
392
- */
393
- register(t, e) {
394
- this.isRegistering && this.registrations.push({
395
- // Type assertion безопасен: handler будет вызван с правильным типом формы в createEffect
396
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
397
- handler: t,
398
- debounce: e?.debounce
399
- });
400
- }
401
- /**
402
- * Завершить регистрацию и применить behaviors к форме
403
- * Создает effect подписки для всех зарегистрированных behaviors
404
- *
405
- * Извлекает this из context stack
406
- *
407
- * @param form - GroupNode формы
408
- * @returns Количество зарегистрированных behaviors и функция cleanup
409
- */
410
- endRegistration(t) {
411
- this.isRegistering = !1, c.contextStack.verify(this, "BehaviorRegistry");
412
- const e = new k(t), r = [];
413
- for (const a of this.registrations) {
414
- const n = this.createEffect(a, t, e);
415
- n && r.push(n);
416
- }
417
- const s = () => {
418
- r.forEach((a) => a());
419
- };
420
- return {
421
- count: this.registrations.length,
422
- cleanup: s
423
- };
424
- }
425
- /**
426
- * Создать effect подписку для behavior
427
- * @private
428
- */
429
- createEffect(t, e, r) {
430
- const { handler: s, debounce: a = 0 } = t;
431
- let n = null;
432
- const f = (u) => {
433
- a > 0 ? (n && clearTimeout(n), n = setTimeout(u, a)) : u();
434
- }, d = () => {
435
- n && (clearTimeout(n), n = null);
436
- }, l = s(e, r, f);
437
- return l ? () => {
438
- d(), l && l();
439
- } : null;
440
- }
441
- }
442
- function _() {
443
- const i = o.getCurrent();
444
- return i || {
445
- registerSync: () => {
446
- },
447
- registerAsync: () => {
448
- },
449
- registerTree: () => {
450
- },
451
- enterCondition: () => {
452
- },
453
- exitCondition: () => {
454
- },
455
- registerArrayItemValidation: () => {
456
- }
457
- };
458
- }
459
- function m() {
460
- const i = c.getCurrent();
461
- return i || {
462
- register: () => {
463
- }
464
- };
465
- }
466
- export {
467
- c as B,
468
- g as R,
469
- o as V,
470
- S as a,
471
- m as b,
472
- v as c,
473
- k as d,
474
- y as e,
475
- _ as g,
476
- C as t
477
- };