@reformer/core 1.0.0-beta.3

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 (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/behaviors.d.ts +2 -0
  4. package/dist/behaviors.js +230 -0
  5. package/dist/core/behavior/behavior-applicator.d.ts +71 -0
  6. package/dist/core/behavior/behavior-applicator.js +92 -0
  7. package/dist/core/behavior/behavior-context.d.ts +29 -0
  8. package/dist/core/behavior/behavior-context.js +38 -0
  9. package/dist/core/behavior/behavior-registry.d.ts +97 -0
  10. package/dist/core/behavior/behavior-registry.js +198 -0
  11. package/dist/core/behavior/behaviors/compute-from.d.ts +41 -0
  12. package/dist/core/behavior/behaviors/compute-from.js +84 -0
  13. package/dist/core/behavior/behaviors/copy-from.d.ts +31 -0
  14. package/dist/core/behavior/behaviors/copy-from.js +64 -0
  15. package/dist/core/behavior/behaviors/enable-when.d.ts +49 -0
  16. package/dist/core/behavior/behaviors/enable-when.js +81 -0
  17. package/dist/core/behavior/behaviors/index.d.ts +11 -0
  18. package/dist/core/behavior/behaviors/index.js +11 -0
  19. package/dist/core/behavior/behaviors/reset-when.d.ts +51 -0
  20. package/dist/core/behavior/behaviors/reset-when.js +63 -0
  21. package/dist/core/behavior/behaviors/revalidate-when.d.ts +30 -0
  22. package/dist/core/behavior/behaviors/revalidate-when.js +51 -0
  23. package/dist/core/behavior/behaviors/sync-fields.d.ts +28 -0
  24. package/dist/core/behavior/behaviors/sync-fields.js +66 -0
  25. package/dist/core/behavior/behaviors/transform-value.d.ts +120 -0
  26. package/dist/core/behavior/behaviors/transform-value.js +110 -0
  27. package/dist/core/behavior/behaviors/watch-field.d.ts +35 -0
  28. package/dist/core/behavior/behaviors/watch-field.js +56 -0
  29. package/dist/core/behavior/compose-behavior.d.ts +106 -0
  30. package/dist/core/behavior/compose-behavior.js +166 -0
  31. package/dist/core/behavior/create-field-path.d.ts +20 -0
  32. package/dist/core/behavior/create-field-path.js +69 -0
  33. package/dist/core/behavior/index.d.ts +12 -0
  34. package/dist/core/behavior/index.js +17 -0
  35. package/dist/core/behavior/types.d.ts +152 -0
  36. package/dist/core/behavior/types.js +7 -0
  37. package/dist/core/context/form-context-impl.d.ts +29 -0
  38. package/dist/core/context/form-context-impl.js +37 -0
  39. package/dist/core/factories/index.d.ts +6 -0
  40. package/dist/core/factories/index.js +6 -0
  41. package/dist/core/factories/node-factory.d.ts +209 -0
  42. package/dist/core/factories/node-factory.js +281 -0
  43. package/dist/core/nodes/array-node.d.ts +308 -0
  44. package/dist/core/nodes/array-node.js +534 -0
  45. package/dist/core/nodes/field-node.d.ts +269 -0
  46. package/dist/core/nodes/field-node.js +510 -0
  47. package/dist/core/nodes/form-node.d.ts +342 -0
  48. package/dist/core/nodes/form-node.js +343 -0
  49. package/dist/core/nodes/group-node/field-registry.d.ts +191 -0
  50. package/dist/core/nodes/group-node/field-registry.js +215 -0
  51. package/dist/core/nodes/group-node/index.d.ts +11 -0
  52. package/dist/core/nodes/group-node/index.js +11 -0
  53. package/dist/core/nodes/group-node/proxy-builder.d.ts +71 -0
  54. package/dist/core/nodes/group-node/proxy-builder.js +161 -0
  55. package/dist/core/nodes/group-node/state-manager.d.ts +184 -0
  56. package/dist/core/nodes/group-node/state-manager.js +265 -0
  57. package/dist/core/nodes/group-node.d.ts +494 -0
  58. package/dist/core/nodes/group-node.js +770 -0
  59. package/dist/core/types/deep-schema.d.ts +78 -0
  60. package/dist/core/types/deep-schema.js +11 -0
  61. package/dist/core/types/field-path.d.ts +42 -0
  62. package/dist/core/types/field-path.js +4 -0
  63. package/dist/core/types/form-context.d.ts +83 -0
  64. package/dist/core/types/form-context.js +25 -0
  65. package/dist/core/types/group-node-proxy.d.ts +135 -0
  66. package/dist/core/types/group-node-proxy.js +31 -0
  67. package/dist/core/types/index.d.ts +163 -0
  68. package/dist/core/types/index.js +4 -0
  69. package/dist/core/types/validation-schema.d.ts +104 -0
  70. package/dist/core/types/validation-schema.js +10 -0
  71. package/dist/core/utils/create-form.d.ts +61 -0
  72. package/dist/core/utils/create-form.js +24 -0
  73. package/dist/core/utils/debounce.d.ts +160 -0
  74. package/dist/core/utils/debounce.js +197 -0
  75. package/dist/core/utils/error-handler.d.ts +180 -0
  76. package/dist/core/utils/error-handler.js +226 -0
  77. package/dist/core/utils/field-path-navigator.d.ts +240 -0
  78. package/dist/core/utils/field-path-navigator.js +374 -0
  79. package/dist/core/utils/index.d.ts +14 -0
  80. package/dist/core/utils/index.js +14 -0
  81. package/dist/core/utils/registry-helpers.d.ts +50 -0
  82. package/dist/core/utils/registry-helpers.js +79 -0
  83. package/dist/core/utils/registry-stack.d.ts +69 -0
  84. package/dist/core/utils/registry-stack.js +86 -0
  85. package/dist/core/utils/resources.d.ts +41 -0
  86. package/dist/core/utils/resources.js +69 -0
  87. package/dist/core/utils/subscription-manager.d.ts +180 -0
  88. package/dist/core/utils/subscription-manager.js +214 -0
  89. package/dist/core/utils/type-guards.d.ts +116 -0
  90. package/dist/core/utils/type-guards.js +169 -0
  91. package/dist/core/validation/core/apply-when.d.ts +28 -0
  92. package/dist/core/validation/core/apply-when.js +41 -0
  93. package/dist/core/validation/core/apply.d.ts +63 -0
  94. package/dist/core/validation/core/apply.js +38 -0
  95. package/dist/core/validation/core/index.d.ts +8 -0
  96. package/dist/core/validation/core/index.js +8 -0
  97. package/dist/core/validation/core/validate-async.d.ts +42 -0
  98. package/dist/core/validation/core/validate-async.js +45 -0
  99. package/dist/core/validation/core/validate-tree.d.ts +35 -0
  100. package/dist/core/validation/core/validate-tree.js +37 -0
  101. package/dist/core/validation/core/validate.d.ts +32 -0
  102. package/dist/core/validation/core/validate.js +38 -0
  103. package/dist/core/validation/field-path.d.ts +43 -0
  104. package/dist/core/validation/field-path.js +147 -0
  105. package/dist/core/validation/index.d.ts +21 -0
  106. package/dist/core/validation/index.js +33 -0
  107. package/dist/core/validation/validate-form.d.ts +85 -0
  108. package/dist/core/validation/validate-form.js +152 -0
  109. package/dist/core/validation/validation-applicator.d.ts +89 -0
  110. package/dist/core/validation/validation-applicator.js +217 -0
  111. package/dist/core/validation/validation-context.d.ts +47 -0
  112. package/dist/core/validation/validation-context.js +75 -0
  113. package/dist/core/validation/validation-registry.d.ts +156 -0
  114. package/dist/core/validation/validation-registry.js +298 -0
  115. package/dist/core/validation/validators/array-validators.d.ts +63 -0
  116. package/dist/core/validation/validators/array-validators.js +86 -0
  117. package/dist/core/validation/validators/date.d.ts +38 -0
  118. package/dist/core/validation/validators/date.js +117 -0
  119. package/dist/core/validation/validators/email.d.ts +44 -0
  120. package/dist/core/validation/validators/email.js +60 -0
  121. package/dist/core/validation/validators/index.d.ts +14 -0
  122. package/dist/core/validation/validators/index.js +14 -0
  123. package/dist/core/validation/validators/max-length.d.ts +45 -0
  124. package/dist/core/validation/validators/max-length.js +60 -0
  125. package/dist/core/validation/validators/max.d.ts +45 -0
  126. package/dist/core/validation/validators/max.js +60 -0
  127. package/dist/core/validation/validators/min-length.d.ts +45 -0
  128. package/dist/core/validation/validators/min-length.js +60 -0
  129. package/dist/core/validation/validators/min.d.ts +45 -0
  130. package/dist/core/validation/validators/min.js +60 -0
  131. package/dist/core/validation/validators/number.d.ts +38 -0
  132. package/dist/core/validation/validators/number.js +90 -0
  133. package/dist/core/validation/validators/pattern.d.ts +47 -0
  134. package/dist/core/validation/validators/pattern.js +62 -0
  135. package/dist/core/validation/validators/phone.d.ts +34 -0
  136. package/dist/core/validation/validators/phone.js +58 -0
  137. package/dist/core/validation/validators/required.d.ts +48 -0
  138. package/dist/core/validation/validators/required.js +69 -0
  139. package/dist/core/validation/validators/url.d.ts +29 -0
  140. package/dist/core/validation/validators/url.js +55 -0
  141. package/dist/create-field-path-CdPF3lIK.js +704 -0
  142. package/dist/hooks/useFormControl.d.ts +48 -0
  143. package/dist/hooks/useFormControl.js +298 -0
  144. package/dist/index.d.ts +10 -0
  145. package/dist/index.js +8 -0
  146. package/dist/node-factory-D7DOnSSN.js +3200 -0
  147. package/dist/validators.d.ts +2 -0
  148. package/dist/validators.js +298 -0
  149. package/llms.txt +847 -0
  150. package/package.json +86 -0
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Композиция behavior схем
3
+ *
4
+ * Предоставляет функции для переиспользования behavior схем:
5
+ * - toBehaviorFieldPath: преобразование FieldPath во вложенный путь
6
+ * - apply: применение схемы к полям
7
+ * - applyWhen: условное применение схемы
8
+ *
9
+ * Аналог toFieldPath и applyWhen из validation API.
10
+ */
11
+ import { createFieldPath } from './create-field-path';
12
+ import { watchField } from './behaviors/watch-field';
13
+ // ============================================================================
14
+ // toBehaviorFieldPath - Преобразование FieldPath во вложенный путь
15
+ // ============================================================================
16
+ /**
17
+ * Преобразовать FieldPath во вложенный путь для композиции behavior схем
18
+ *
19
+ * Аналог toFieldPath из validation API.
20
+ *
21
+ * @param fieldPath - Поле для преобразования
22
+ * @returns Вложенный FieldPath
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // address-behavior.ts
27
+ * export const addressBehavior = (path: FieldPath<Address>) => {
28
+ * watchField(path.country, async (country, ctx) => {
29
+ * const regions = await fetchRegions(country);
30
+ * ctx.updateComponentProps(path.region, { options: regions });
31
+ * });
32
+ * };
33
+ *
34
+ * // user-behavior.ts
35
+ * export const userBehavior = (path: FieldPath<User>) => {
36
+ * // Композиция: применяем addressBehavior к вложенному полю
37
+ * addressBehavior(toBehaviorFieldPath(path.address));
38
+ * };
39
+ * ```
40
+ */
41
+ export function toBehaviorFieldPath(fieldPath) {
42
+ if (!fieldPath) {
43
+ return createFieldPath();
44
+ }
45
+ const basePath = fieldPath.__path;
46
+ return createNestedBehaviorFieldPath(basePath);
47
+ }
48
+ /**
49
+ * Создать вложенный FieldPath с базовым префиксом
50
+ * @private
51
+ */
52
+ function createNestedBehaviorFieldPath(basePath) {
53
+ return new Proxy({}, {
54
+ get(_target, prop) {
55
+ if (typeof prop === 'symbol')
56
+ return undefined;
57
+ const fullPath = basePath ? `${basePath}.${prop}` : prop;
58
+ return {
59
+ __path: fullPath,
60
+ __key: prop,
61
+ };
62
+ },
63
+ });
64
+ }
65
+ // ============================================================================
66
+ // apply - Применение behavior схемы к полям
67
+ // ============================================================================
68
+ /**
69
+ * Применить behavior схему к вложенному полю или полям
70
+ *
71
+ * Поддерживает:
72
+ * - Одно поле или массив полей
73
+ * - Одну схему или массив схем
74
+ * - Все комбинации (поле + схема, поле + схемы, поля + схема, поля + схемы)
75
+ *
76
+ * @param fields - Одно поле или массив полей
77
+ * @param behaviors - Одна схема или массив схем
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // Одна схема к одному полю
82
+ * apply(path.registrationAddress, addressBehavior);
83
+ *
84
+ * // Одна схема к нескольким полям
85
+ * apply([path.registrationAddress, path.residenceAddress], addressBehavior);
86
+ *
87
+ * // Несколько схем к одному полю
88
+ * apply(path.properties, [propertyBehavior, arrayBehavior]);
89
+ *
90
+ * // Несколько схем к нескольким полям
91
+ * apply(
92
+ * [path.registrationAddress, path.residenceAddress],
93
+ * [addressBehavior, validationBehavior]
94
+ * );
95
+ * ```
96
+ */
97
+ export function apply(fields, behaviors) {
98
+ // Нормализуем inputs в массивы
99
+ const fieldArray = (Array.isArray(fields) ? fields : [fields]).filter(Boolean);
100
+ const behaviorArray = Array.isArray(behaviors) ? behaviors : [behaviors];
101
+ // Применяем все схемы ко всем полям
102
+ for (const field of fieldArray) {
103
+ const nestedPath = toBehaviorFieldPath(field);
104
+ for (const behavior of behaviorArray) {
105
+ behavior(nestedPath);
106
+ }
107
+ }
108
+ }
109
+ // ============================================================================
110
+ // applyWhen - Условное применение behavior схемы
111
+ // ============================================================================
112
+ /**
113
+ * Условное применение behavior схем (аналог applyWhen из validation API)
114
+ *
115
+ * ⚠️ ВАЖНО: Эта функция НЕ создаёт новые behaviors при каждом изменении условия!
116
+ * Вместо этого behaviors регистрируются ОДИН РАЗ при первом вызове и затем
117
+ * просто не выполняются, если условие не выполнено.
118
+ *
119
+ * Это отличается от старой реализации, которая создавала утечку памяти,
120
+ * регистрируя behaviors при каждом изменении conditionField.
121
+ *
122
+ * @param conditionField - Поле для проверки условия
123
+ * @param condition - Функция проверки условия
124
+ * @param callback - Callback для применения behavior схем
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Применить addressBehavior только когда sameAsRegistration === false
129
+ * applyWhen(
130
+ * path.sameAsRegistration,
131
+ * (value) => value === false,
132
+ * (path) => {
133
+ * apply(path.residenceAddress, addressBehavior);
134
+ * }
135
+ * );
136
+ *
137
+ * // Или с прямым использованием path
138
+ * applyWhen(
139
+ * path.hasProperty,
140
+ * (value) => value === true,
141
+ * (path) => {
142
+ * apply(path.properties, propertyBehavior);
143
+ * // Можно применить несколько схем
144
+ * apply([path.properties, path.items], arrayBehavior);
145
+ * }
146
+ * );
147
+ * ```
148
+ */
149
+ export function applyWhen(conditionField, condition, callback) {
150
+ if (!conditionField)
151
+ return;
152
+ // ИСПРАВЛЕНО: Регистрируем behaviors только ОДИН РАЗ
153
+ // вне watchField callback, чтобы избежать утечки памяти
154
+ let hasRegistered = false;
155
+ watchField(conditionField, (value, _ctx) => {
156
+ // Регистрируем behaviors только при первом срабатывании
157
+ // когда условие выполнено
158
+ if (!hasRegistered && condition(value)) {
159
+ const fieldPath = createFieldPath();
160
+ callback(fieldPath);
161
+ hasRegistered = true;
162
+ }
163
+ // TODO: В будущем можно добавить поддержку деактивации behaviors
164
+ // при изменении условия, но это требует изменений в BehaviorRegistry
165
+ }, { immediate: true });
166
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Создание типизированного FieldPath для Behavior Schema
3
+ * Аналогично createFieldPath из validators
4
+ */
5
+ import type { FieldPath } from '../types';
6
+ /**
7
+ * Создать типизированный путь к полям формы
8
+ * Используется для декларативного описания behavior схем
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const schema: BehaviorSchemaFn<MyForm> = (path) => {
13
+ * // path.email, path.address.city и т.д. - типизированы
14
+ * copyFrom(path.residenceAddress, path.registrationAddress, {
15
+ * when: (form) => form.sameAsRegistration
16
+ * });
17
+ * };
18
+ * ```
19
+ */
20
+ export declare function createFieldPath<T>(): FieldPath<T>;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Создание типизированного FieldPath для Behavior Schema
3
+ * Аналогично createFieldPath из validators
4
+ */
5
+ /**
6
+ * Создать типизированный путь к полям формы
7
+ * Используется для декларативного описания behavior схем
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const schema: BehaviorSchemaFn<MyForm> = (path) => {
12
+ * // path.email, path.address.city и т.д. - типизированы
13
+ * copyFrom(path.residenceAddress, path.registrationAddress, {
14
+ * when: (form) => form.sameAsRegistration
15
+ * });
16
+ * };
17
+ * ```
18
+ */
19
+ export function createFieldPath() {
20
+ return createFieldPathProxy('');
21
+ }
22
+ /**
23
+ * Создать Proxy для вложенного доступа к полям
24
+ * @private
25
+ */
26
+ function createFieldPathProxy(currentPath) {
27
+ return new Proxy(
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ {}, {
30
+ get(__target, prop) {
31
+ // Поддержка обоих вариантов для обратной совместимости
32
+ if (prop === '__path' || prop === '__fieldPath') {
33
+ return currentPath || prop;
34
+ }
35
+ if (prop === '__key') {
36
+ const parts = currentPath.split('.');
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ return (parts[parts.length - 1] || prop);
39
+ }
40
+ const newPath = currentPath ? `${currentPath}.${prop}` : prop;
41
+ // Создаем объект FieldPathNode с вложенным Proxy
42
+ const node = {
43
+ __path: newPath,
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ __key: prop,
46
+ __formType: undefined,
47
+ __fieldType: undefined,
48
+ };
49
+ // Возвращаем Proxy, который поддерживает дальнейшую вложенность
50
+ return new Proxy(node, {
51
+ get(_target, nestedProp) {
52
+ // Поддержка обоих вариантов для обратной совместимости
53
+ if (nestedProp === '__path' || nestedProp === '__fieldPath') {
54
+ return newPath;
55
+ }
56
+ if (nestedProp === '__key') {
57
+ return prop;
58
+ }
59
+ if (nestedProp === '__formType' || nestedProp === '__fieldType') {
60
+ return undefined;
61
+ }
62
+ // Для вложенных свойств создаем новый Proxy
63
+ const nestedPath = `${newPath}.${nestedProp}`;
64
+ return createFieldPathProxy(nestedPath);
65
+ },
66
+ });
67
+ },
68
+ });
69
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Behavior Schema API - Декларативное описание реактивного поведения форм
3
+ *
4
+ * @group Behaviors
5
+ * @module behaviors
6
+ */
7
+ export type { BehaviorSchemaFn, BehaviorContext, BehaviorHandlerFn, BehaviorOptions, CopyFromOptions, EnableWhenOptions, ComputeFromOptions, WatchFieldOptions, RevalidateWhenOptions, SyncFieldsOptions, } from './types';
8
+ export * from './behaviors';
9
+ export { apply, applyWhen, toBehaviorFieldPath } from './compose-behavior';
10
+ export { BehaviorRegistry } from './behavior-registry';
11
+ export { BehaviorContextImpl } from './behavior-context';
12
+ export { createFieldPath } from './create-field-path';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Behavior Schema API - Декларативное описание реактивного поведения форм
3
+ *
4
+ * @group Behaviors
5
+ * @module behaviors
6
+ */
7
+ // Функции для декларативного описания поведения
8
+ // Behaviors
9
+ export * from './behaviors';
10
+ // Композиция behavior схем (аналог toFieldPath из validation API)
11
+ export { apply, applyWhen, toBehaviorFieldPath } from './compose-behavior';
12
+ // Вспомогательные классы и функции
13
+ // Примечание: BehaviorRegistry (глобальный singleton) был удален в пользу
14
+ // локальных экземпляров BehaviorRegistry в каждом GroupNode
15
+ export { BehaviorRegistry } from './behavior-registry';
16
+ export { BehaviorContextImpl } from './behavior-context';
17
+ export { createFieldPath } from './create-field-path';
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Типы и интерфейсы для Behavior Schema API
3
+ *
4
+ * @group Behaviors
5
+ * @category Behavior Types
6
+ */
7
+ import { GroupNode } from '../nodes/group-node';
8
+ import type { FieldPath } from '../types/field-path';
9
+ import type { FormContext } from '../types/form-context';
10
+ /**
11
+ * Тип функции behavior схемы
12
+ * Принимает FieldPath и описывает поведение формы
13
+ *
14
+ * @group Behaviors
15
+ * @category Behavior Types
16
+ */
17
+ export type BehaviorSchemaFn<T> = (path: FieldPath<T>) => void;
18
+ /**
19
+ * Контекст для behavior callback функций
20
+ * Алиас для FormContext
21
+ *
22
+ * @group Behaviors
23
+ * @category Behavior Types
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * watchField(path.country, async (country, ctx) => {
28
+ * // Прямой типизированный доступ к полям
29
+ * const cities = await fetchCities(country);
30
+ * ctx.form.city.updateComponentProps({ options: cities });
31
+ *
32
+ * // Безопасная установка значения (без циклов)
33
+ * ctx.setFieldValue('city', null);
34
+ * });
35
+ * ```
36
+ */
37
+ export type BehaviorContext<TForm> = FormContext<TForm>;
38
+ /**
39
+ * Функция-handler для behavior
40
+ *
41
+ * Создает effect подписку для реактивного поведения формы.
42
+ *
43
+ * @group Behaviors
44
+ * @category Behavior Types
45
+ *
46
+ * @template TForm - Тип формы
47
+ * @param form - Корневой узел формы (GroupNode)
48
+ * @param context - Контекст для работы с формой
49
+ * @param withDebounce - Функция-обертка для debounce
50
+ * @returns Функция cleanup для отписки от effect или null
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const handler: BehaviorHandlerFn<MyForm> = (form, context, withDebounce) => {
55
+ * const sourceNode = form.getFieldByPath('email');
56
+ *
57
+ * return effect(() => {
58
+ * const value = sourceNode.value.value;
59
+ * withDebounce(() => {
60
+ * // Логика behavior
61
+ * });
62
+ * });
63
+ * };
64
+ * ```
65
+ */
66
+ export type BehaviorHandlerFn<TForm> = (form: GroupNode<TForm>, context: BehaviorContext<TForm>, withDebounce: (callback: () => void) => void) => (() => void) | null;
67
+ /**
68
+ * Общие опции для behavior
69
+ *
70
+ * @group Behaviors
71
+ * @category Behavior Types
72
+ */
73
+ export interface BehaviorOptions {
74
+ /** Debounce в миллисекундах */
75
+ debounce?: number;
76
+ }
77
+ /**
78
+ * Опции для copyFrom
79
+ *
80
+ * @group Behaviors
81
+ * @category Behavior Types
82
+ */
83
+ export interface CopyFromOptions<TSource, TForm = unknown> {
84
+ /** Условие копирования */
85
+ when?: (form: TForm) => boolean;
86
+ /** Какие поля копировать (для групп) */
87
+ fields?: (keyof TSource)[] | 'all';
88
+ /** Трансформация значения */
89
+ transform?: (value: TSource) => unknown;
90
+ /** Debounce в мс */
91
+ debounce?: number;
92
+ }
93
+ /**
94
+ * Опции для enableWhen/disableWhen
95
+ *
96
+ * @group Behaviors
97
+ * @category Behavior Types
98
+ */
99
+ export interface EnableWhenOptions {
100
+ /** Сбросить значение при disable */
101
+ resetOnDisable?: boolean;
102
+ /** Debounce в мс */
103
+ debounce?: number;
104
+ }
105
+ /**
106
+ * Опции для computeFrom
107
+ *
108
+ * @group Behaviors
109
+ * @category Behavior Types
110
+ */
111
+ export interface ComputeFromOptions<TForm> {
112
+ /** Когда вычислять */
113
+ trigger?: 'change' | 'blur';
114
+ /** Debounce в мс */
115
+ debounce?: number;
116
+ /** Условие применения */
117
+ condition?: (form: TForm) => boolean;
118
+ }
119
+ /**
120
+ * Опции для watchField
121
+ *
122
+ * @group Behaviors
123
+ * @category Behavior Types
124
+ */
125
+ export interface WatchFieldOptions {
126
+ /** Debounce в мс */
127
+ debounce?: number;
128
+ /** Вызвать сразу при инициализации */
129
+ immediate?: boolean;
130
+ }
131
+ /**
132
+ * Опции для revalidateWhen
133
+ *
134
+ * @group Behaviors
135
+ * @category Behavior Types
136
+ */
137
+ export interface RevalidateWhenOptions {
138
+ /** Debounce в мс */
139
+ debounce?: number;
140
+ }
141
+ /**
142
+ * Опции для syncFields
143
+ *
144
+ * @group Behaviors
145
+ * @category Behavior Types
146
+ */
147
+ export interface SyncFieldsOptions<T> {
148
+ /** Трансформация значения */
149
+ transform?: (value: T) => T;
150
+ /** Debounce в мс */
151
+ debounce?: number;
152
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Типы и интерфейсы для Behavior Schema API
3
+ *
4
+ * @group Behaviors
5
+ * @category Behavior Types
6
+ */
7
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Реализация единого FormContext
3
+ *
4
+ * Используется как базовая реализация для behavior и validation контекстов
5
+ */
6
+ import type { GroupNode } from '../nodes/group-node';
7
+ import type { FormContext } from '../types/form-context';
8
+ import type { GroupNodeWithControls } from '../types/group-node-proxy';
9
+ /**
10
+ * Базовая реализация FormContext
11
+ *
12
+ * Предоставляет:
13
+ * - `form` - типизированный Proxy-доступ к форме
14
+ * - `setFieldValue` - безопасная установка значения (emitEvent: false)
15
+ */
16
+ export declare class FormContextImpl<TForm> implements FormContext<TForm> {
17
+ /**
18
+ * Форма с типизированным Proxy-доступом к полям
19
+ */
20
+ readonly form: GroupNodeWithControls<TForm>;
21
+ protected readonly _groupNode: GroupNode<TForm>;
22
+ constructor(groupNode: GroupNode<TForm>);
23
+ /**
24
+ * Безопасно установить значение поля по строковому пути
25
+ *
26
+ * Автоматически использует emitEvent: false для предотвращения циклов
27
+ */
28
+ setFieldValue(path: string, value: unknown): void;
29
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Реализация единого FormContext
3
+ *
4
+ * Используется как базовая реализация для behavior и validation контекстов
5
+ */
6
+ /**
7
+ * Базовая реализация FormContext
8
+ *
9
+ * Предоставляет:
10
+ * - `form` - типизированный Proxy-доступ к форме
11
+ * - `setFieldValue` - безопасная установка значения (emitEvent: false)
12
+ */
13
+ export class FormContextImpl {
14
+ /**
15
+ * Форма с типизированным Proxy-доступом к полям
16
+ */
17
+ form;
18
+ _groupNode;
19
+ constructor(groupNode) {
20
+ this._groupNode = groupNode;
21
+ // Используем _proxyInstance если доступен, иначе fallback
22
+ this.form = (groupNode
23
+ ._proxyInstance || groupNode.getProxy());
24
+ }
25
+ /**
26
+ * Безопасно установить значение поля по строковому пути
27
+ *
28
+ * Автоматически использует emitEvent: false для предотвращения циклов
29
+ */
30
+ setFieldValue(path, value) {
31
+ const node = this._groupNode.getFieldByPath(path);
32
+ if (node) {
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ node.setValue(value, { emitEvent: false });
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Фабрики для создания узлов формы
3
+ *
4
+ * Централизованное место для всех фабрик и builder-паттернов.
5
+ */
6
+ export { NodeFactory } from './node-factory';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Фабрики для создания узлов формы
3
+ *
4
+ * Централизованное место для всех фабрик и builder-паттернов.
5
+ */
6
+ export { NodeFactory } from './node-factory';