@reformer/core 9.0.0 → 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.
Files changed (105) hide show
  1. package/README.md +52 -57
  2. package/dist/behaviors-node-BMOI2JJF.js +26 -0
  3. package/dist/behaviors-value-lCpqicfa.js +148 -0
  4. package/dist/behaviors.d.ts +2 -133
  5. package/dist/behaviors.js +148 -147
  6. package/dist/{core/utils → form}/aggregate-signals.d.ts +2 -2
  7. package/dist/form/behaviors-node.d.ts +55 -0
  8. package/dist/form/behaviors.d.ts +133 -0
  9. package/dist/{core/utils → form}/create-form.d.ts +5 -4
  10. package/dist/{core/utils → form}/error-handler.d.ts +1 -1
  11. package/dist/{core → form}/factories/node-factory.d.ts +1 -1
  12. package/dist/{core/utils → form}/form-proxy-builder.d.ts +2 -2
  13. package/dist/{core/utils → form}/form-submitter.d.ts +6 -1
  14. package/dist/{hooks → form/hooks}/types.d.ts +31 -1
  15. package/dist/{hooks → form/hooks}/useArrayLength.d.ts +1 -1
  16. package/dist/{hooks → form/hooks}/useFormControl.d.ts +3 -3
  17. package/dist/{hooks → form/hooks}/useFormControlValue.d.ts +2 -2
  18. package/dist/{hooks → form/hooks}/useSignalSubscription.d.ts +8 -1
  19. package/dist/form/index.d.ts +36 -0
  20. package/dist/{core → form}/nodes/array-node.d.ts +1 -1
  21. package/dist/{core → form}/nodes/field-node.d.ts +1 -1
  22. package/dist/{core → form}/nodes/form-node.d.ts +1 -1
  23. package/dist/{core → form}/nodes/group-node.d.ts +34 -4
  24. package/dist/{core → form}/nodes/model-array-node.d.ts +10 -3
  25. package/dist/{core/utils → form}/signal-node-registry.d.ts +1 -1
  26. package/dist/{core/utils → form}/status-machine.d.ts +1 -1
  27. package/dist/{core/utils → form}/type-guards.d.ts +5 -5
  28. package/dist/{core/types/index.d.ts → form/types/contracts.d.ts} +11 -90
  29. package/dist/{core → form}/types/deep-schema.d.ts +23 -1
  30. package/dist/{core → form}/types/form-proxy.d.ts +26 -1
  31. package/dist/form/types/index.d.ts +91 -0
  32. package/dist/{core → form}/types/schema-node.d.ts +1 -1
  33. package/dist/{core → form}/types/validation-schema.d.ts +19 -9
  34. package/dist/{core/model/validate-model.d.ts → form/validate-model-core.d.ts} +25 -25
  35. package/dist/form/validate-model.d.ts +27 -0
  36. package/dist/{core → form}/validation/validators/required.d.ts +2 -1
  37. package/dist/form/validators.d.ts +6 -0
  38. package/dist/form-model-C8Fi83k4.js +439 -0
  39. package/dist/index.d.ts +11 -16
  40. package/dist/index.js +666 -1011
  41. package/dist/{core/model/behaviors.d.ts → state/behaviors-value.d.ts} +0 -38
  42. package/dist/{core/utils → state}/derived-registry.d.ts +29 -0
  43. package/dist/state/form-model.d.ts +26 -0
  44. package/dist/state/index.d.ts +31 -0
  45. package/dist/state/safe-effect.d.ts +93 -0
  46. package/dist/{core/model → state}/types.d.ts +14 -11
  47. package/dist/state.d.ts +2 -0
  48. package/dist/state.js +19 -0
  49. package/dist/validators/email.d.ts +1 -1
  50. package/dist/validators/future-date.d.ts +1 -1
  51. package/dist/validators/integer.d.ts +1 -1
  52. package/dist/validators/is-date.d.ts +1 -1
  53. package/dist/validators/is-number.d.ts +1 -1
  54. package/dist/validators/max-age.d.ts +1 -1
  55. package/dist/validators/max-date.d.ts +1 -1
  56. package/dist/validators/max-length.d.ts +1 -1
  57. package/dist/validators/max.d.ts +1 -1
  58. package/dist/validators/min-age.d.ts +1 -1
  59. package/dist/validators/min-date.d.ts +1 -1
  60. package/dist/validators/min-length.d.ts +1 -1
  61. package/dist/validators/min.d.ts +1 -1
  62. package/dist/validators/multiple-of.d.ts +1 -1
  63. package/dist/validators/non-negative.d.ts +1 -1
  64. package/dist/validators/non-zero.d.ts +1 -1
  65. package/dist/validators/past-date.d.ts +1 -1
  66. package/dist/validators/pattern.d.ts +1 -1
  67. package/dist/validators/pattern.js +7 -6
  68. package/dist/validators/phone.d.ts +1 -1
  69. package/dist/validators/required.d.ts +1 -1
  70. package/dist/validators/required.js +5 -9
  71. package/dist/validators/url.d.ts +1 -1
  72. package/dist/validators.d.ts +6 -6
  73. package/llms.txt +307 -166
  74. package/package.json +5 -1
  75. package/dist/behaviors-O9a1Djj9.js +0 -147
  76. package/dist/core/model/form-model.d.ts +0 -18
  77. package/dist/core/model/index.d.ts +0 -12
  78. package/dist/core/utils/index.d.ts +0 -18
  79. package/dist/core/utils/safe-effect.d.ts +0 -73
  80. /package/dist/{core → form}/factories/index.d.ts +0 -0
  81. /package/dist/{core/utils → form}/unique-id.d.ts +0 -0
  82. /package/dist/{core → form}/validation/index.d.ts +0 -0
  83. /package/dist/{core → form}/validation/validators/date-utils.d.ts +0 -0
  84. /package/dist/{core → form}/validation/validators/email.d.ts +0 -0
  85. /package/dist/{core → form}/validation/validators/future-date.d.ts +0 -0
  86. /package/dist/{core → form}/validation/validators/index.d.ts +0 -0
  87. /package/dist/{core → form}/validation/validators/integer.d.ts +0 -0
  88. /package/dist/{core → form}/validation/validators/is-date.d.ts +0 -0
  89. /package/dist/{core → form}/validation/validators/is-number.d.ts +0 -0
  90. /package/dist/{core → form}/validation/validators/max-age.d.ts +0 -0
  91. /package/dist/{core → form}/validation/validators/max-date.d.ts +0 -0
  92. /package/dist/{core → form}/validation/validators/max-length.d.ts +0 -0
  93. /package/dist/{core → form}/validation/validators/max.d.ts +0 -0
  94. /package/dist/{core → form}/validation/validators/min-age.d.ts +0 -0
  95. /package/dist/{core → form}/validation/validators/min-date.d.ts +0 -0
  96. /package/dist/{core → form}/validation/validators/min-length.d.ts +0 -0
  97. /package/dist/{core → form}/validation/validators/min.d.ts +0 -0
  98. /package/dist/{core → form}/validation/validators/multiple-of.d.ts +0 -0
  99. /package/dist/{core → form}/validation/validators/non-negative.d.ts +0 -0
  100. /package/dist/{core → form}/validation/validators/non-zero.d.ts +0 -0
  101. /package/dist/{core → form}/validation/validators/past-date.d.ts +0 -0
  102. /package/dist/{core → form}/validation/validators/pattern.d.ts +0 -0
  103. /package/dist/{core → form}/validation/validators/phone.d.ts +0 -0
  104. /package/dist/{core → form}/validation/validators/url.d.ts +0 -0
  105. /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.0.0",
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,147 +0,0 @@
1
- import { effect as u } from "@preact/signals-core";
2
- const o = /* @__PURE__ */ new WeakSet();
3
- function h(e) {
4
- o.add(e);
5
- }
6
- function p(e) {
7
- return o.has(e);
8
- }
9
- const d = /* @__PURE__ */ new WeakMap();
10
- function y(e, n) {
11
- d.set(e, n);
12
- }
13
- function v(e) {
14
- return d.get(e);
15
- }
16
- function b(e) {
17
- return (...n) => {
18
- queueMicrotask(() => e(...n));
19
- };
20
- }
21
- function s(e) {
22
- queueMicrotask(e);
23
- }
24
- function w(e, n) {
25
- return () => {
26
- n(() => {
27
- queueMicrotask(e);
28
- });
29
- };
30
- }
31
- function W(e, n, r, a) {
32
- return u(() => {
33
- const t = e.map((f) => f.value);
34
- if (a?.when && !a.when(...t)) return;
35
- const l = r(...t);
36
- n.peek() !== l && (n.value = l);
37
- });
38
- }
39
- function x(e, n, r) {
40
- return u(() => {
41
- const a = e.value;
42
- if (r?.when && !r.when()) return;
43
- const t = r?.transform ? r.transform(a) : a;
44
- n.peek() !== t && (n.value = t);
45
- });
46
- }
47
- function F(e, n, r) {
48
- let a = !0;
49
- return u(() => {
50
- const t = e.value;
51
- a && (a = !1, !r?.immediate) || n(t);
52
- });
53
- }
54
- function k(e, n, r) {
55
- return u(() => {
56
- const a = n(), t = v(e);
57
- t && s(() => {
58
- a ? t.enable() : (t.disable(), r?.resetOnDisable && t.reset());
59
- });
60
- });
61
- }
62
- function g(e, n, r) {
63
- return k(e, () => !n(), r);
64
- }
65
- function D(e, n) {
66
- let r = !1;
67
- return u(() => {
68
- const a = e.value;
69
- r || s(() => {
70
- const t = n(a);
71
- if (e.peek() !== t) {
72
- r = !0;
73
- try {
74
- e.value = t;
75
- } finally {
76
- r = !1;
77
- }
78
- }
79
- });
80
- });
81
- }
82
- function M(e, n, r) {
83
- const a = r?.resetValue ?? null;
84
- return u(() => {
85
- const t = n();
86
- s(() => {
87
- t && e.peek() !== a && (e.value = a);
88
- });
89
- });
90
- }
91
- function q(e, n, r) {
92
- const a = r?.transform;
93
- let t = !1;
94
- const l = u(() => {
95
- const i = e.value;
96
- t || s(() => {
97
- t = !0;
98
- try {
99
- const c = a ? a(i) : i;
100
- n.peek() !== c && (n.value = c);
101
- } finally {
102
- t = !1;
103
- }
104
- });
105
- }), f = u(() => {
106
- const i = n.value;
107
- t || s(() => {
108
- t = !0;
109
- try {
110
- e.peek() !== i && (e.value = i);
111
- } finally {
112
- t = !1;
113
- }
114
- });
115
- });
116
- return () => {
117
- l(), f();
118
- };
119
- }
120
- function S(e, n) {
121
- let r = !0;
122
- return u(() => {
123
- if (e.forEach((a) => a.value), r) {
124
- r = !1;
125
- return;
126
- }
127
- s(() => n());
128
- });
129
- }
130
- export {
131
- M as a,
132
- S as b,
133
- x as c,
134
- y as d,
135
- k as e,
136
- b as f,
137
- v as g,
138
- w as h,
139
- p as i,
140
- W as j,
141
- g as k,
142
- h as m,
143
- s as r,
144
- q as s,
145
- D as t,
146
- F as w
147
- };
@@ -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 } 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';
@@ -1,73 +0,0 @@
1
- /**
2
- * Утилиты для безопасной работы с сигналами в effect контексте
3
- *
4
- * Эти утилиты решают проблему "Cycle detected" в @preact/signals-core,
5
- * которая возникает при модификации сигналов внутри effect.
6
- *
7
- * @group Utils
8
- * @module utils/safe-effect
9
- */
10
- /**
11
- * Создает callback, который выполняется вне контекста effect
12
- *
13
- * Использует queueMicrotask для отложенного выполнения,
14
- * что позволяет модифицировать сигналы без вызова "Cycle detected"
15
- *
16
- * @param callback - Функция для выполнения
17
- * @returns Обёрнутая функция, безопасная для вызова внутри effect
18
- *
19
- * @example
20
- * ```typescript
21
- * // Вместо:
22
- * effect(() => {
23
- * queueMicrotask(() => {
24
- * callback(value, context);
25
- * });
26
- * });
27
- *
28
- * // Используем:
29
- * effect(() => {
30
- * safeCallback(callback)(value, context);
31
- * });
32
- * ```
33
- */
34
- export declare function safeCallback<TArgs extends unknown[]>(callback: (...args: TArgs) => void | Promise<void>): (...args: TArgs) => void;
35
- /**
36
- * Выполняет функцию вне контекста effect
37
- *
38
- * Более простой вариант для одиночного вызова
39
- *
40
- * @param fn - Функция для выполнения
41
- *
42
- * @example
43
- * ```typescript
44
- * effect(() => {
45
- * const value = signal.value;
46
- * runOutsideEffect(() => {
47
- * otherSignal.value = transform(value);
48
- * });
49
- * });
50
- * ```
51
- */
52
- export declare function runOutsideEffect(fn: () => void | Promise<void>): void;
53
- /**
54
- * Создает версию callback с поддержкой debounce, безопасную для effect
55
- *
56
- * Комбинирует debounce логику с выходом из effect контекста
57
- *
58
- * @param callback - Функция для выполнения
59
- * @param withDebounce - Функция debounce обёртки из BehaviorRegistry
60
- * @returns Обёрнутая функция
61
- *
62
- * @example
63
- * ```typescript
64
- * return effect(() => {
65
- * const value = node.value.value;
66
- * safeDebouncedCallback(
67
- * () => callback(value, context),
68
- * withDebounce
69
- * )();
70
- * });
71
- * ```
72
- */
73
- export declare function safeDebouncedCallback(callback: () => void | Promise<void>, withDebounce: (fn: () => void) => void): () => void;
File without changes
File without changes
File without changes