@reformer/core 1.1.0-beta.8 → 2.0.0-beta.10

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 (151) 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 +27 -20
  18. package/dist/core/behavior/behavior-context.d.ts +27 -13
  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 +42 -22
  33. package/dist/core/nodes/field-node.d.ts +51 -26
  34. package/dist/core/nodes/form-node.d.ts +18 -20
  35. package/dist/core/nodes/group-node.d.ts +37 -212
  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 +27 -27
  39. package/dist/core/types/{group-node-proxy.d.ts → form-proxy.d.ts} +12 -42
  40. package/dist/core/types/index.d.ts +52 -6
  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 +3 -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/{validation → utils}/field-path.d.ts +23 -6
  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 +10 -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 +53 -0
  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 +67 -28
  66. package/dist/core/validation/validation-registry.d.ts +11 -25
  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 +328 -0
  90. package/dist/hooks/useArrayLength.d.ts +31 -0
  91. package/dist/hooks/useFormControl.d.ts +15 -39
  92. package/dist/hooks/useFormControlValue.d.ts +167 -0
  93. package/dist/hooks/useHiddenCondition.d.ts +25 -0
  94. package/dist/hooks/useSignalSubscription.d.ts +17 -0
  95. package/dist/index-D25LsbRm.js +73 -0
  96. package/dist/index.d.ts +5 -1
  97. package/dist/index.js +1248 -1357
  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 +53 -28
  137. package/llms.txt +8069 -357
  138. package/package.json +87 -8
  139. package/dist/behaviors-BRaiR-UY.js +0 -528
  140. package/dist/core/behavior/behavior-applicator.d.ts +0 -71
  141. package/dist/core/behavior/create-field-path.d.ts +0 -20
  142. package/dist/core/context/form-context-impl.d.ts +0 -29
  143. package/dist/core/nodes/group-node/field-registry.d.ts +0 -191
  144. package/dist/core/nodes/group-node/index.d.ts +0 -11
  145. package/dist/core/nodes/group-node/proxy-builder.d.ts +0 -71
  146. package/dist/core/nodes/group-node/state-manager.d.ts +0 -184
  147. package/dist/core/utils/debounce.d.ts +0 -160
  148. package/dist/core/utils/resources.d.ts +0 -41
  149. package/dist/core/validation/validators/date.d.ts +0 -38
  150. package/dist/registry-helpers-BfCZcMkO.js +0 -426
  151. package/dist/validators-DjXtDVoE.js +0 -455
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reformer/core",
3
- "version": "1.1.0-beta.8",
3
+ "version": "2.0.0-beta.10",
4
4
  "description": "Reactive form state management library for React with signals-based architecture",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,13 +18,91 @@
18
18
  "./validators": {
19
19
  "types": "./dist/validators.d.ts",
20
20
  "import": "./dist/validators.js"
21
+ },
22
+ "./validators/required": {
23
+ "types": "./dist/validators/required.d.ts",
24
+ "import": "./dist/validators/required.js"
25
+ },
26
+ "./validators/email": {
27
+ "types": "./dist/validators/email.d.ts",
28
+ "import": "./dist/validators/email.js"
29
+ },
30
+ "./validators/min": {
31
+ "types": "./dist/validators/min.d.ts",
32
+ "import": "./dist/validators/min.js"
33
+ },
34
+ "./validators/max": {
35
+ "types": "./dist/validators/max.d.ts",
36
+ "import": "./dist/validators/max.js"
37
+ },
38
+ "./validators/min-length": {
39
+ "types": "./dist/validators/min-length.d.ts",
40
+ "import": "./dist/validators/min-length.js"
41
+ },
42
+ "./validators/max-length": {
43
+ "types": "./dist/validators/max-length.d.ts",
44
+ "import": "./dist/validators/max-length.js"
45
+ },
46
+ "./validators/pattern": {
47
+ "types": "./dist/validators/pattern.d.ts",
48
+ "import": "./dist/validators/pattern.js"
49
+ },
50
+ "./validators/url": {
51
+ "types": "./dist/validators/url.d.ts",
52
+ "import": "./dist/validators/url.js"
53
+ },
54
+ "./validators/phone": {
55
+ "types": "./dist/validators/phone.d.ts",
56
+ "import": "./dist/validators/phone.js"
57
+ },
58
+ "./validators/number": {
59
+ "types": "./dist/validators/number.d.ts",
60
+ "import": "./dist/validators/number.js"
61
+ },
62
+ "./validators/date": {
63
+ "types": "./dist/validators/date.d.ts",
64
+ "import": "./dist/validators/date.js"
65
+ },
66
+ "./behaviors/copy-from": {
67
+ "types": "./dist/behaviors/copy-from.d.ts",
68
+ "import": "./dist/behaviors/copy-from.js"
69
+ },
70
+ "./behaviors/enable-when": {
71
+ "types": "./dist/behaviors/enable-when.d.ts",
72
+ "import": "./dist/behaviors/enable-when.js"
73
+ },
74
+ "./behaviors/compute-from": {
75
+ "types": "./dist/behaviors/compute-from.d.ts",
76
+ "import": "./dist/behaviors/compute-from.js"
77
+ },
78
+ "./behaviors/watch-field": {
79
+ "types": "./dist/behaviors/watch-field.d.ts",
80
+ "import": "./dist/behaviors/watch-field.js"
81
+ },
82
+ "./behaviors/revalidate-when": {
83
+ "types": "./dist/behaviors/revalidate-when.d.ts",
84
+ "import": "./dist/behaviors/revalidate-when.js"
85
+ },
86
+ "./behaviors/sync-fields": {
87
+ "types": "./dist/behaviors/sync-fields.d.ts",
88
+ "import": "./dist/behaviors/sync-fields.js"
89
+ },
90
+ "./behaviors/reset-when": {
91
+ "types": "./dist/behaviors/reset-when.d.ts",
92
+ "import": "./dist/behaviors/reset-when.js"
93
+ },
94
+ "./behaviors/transform-value": {
95
+ "types": "./dist/behaviors/transform-value.d.ts",
96
+ "import": "./dist/behaviors/transform-value.js"
21
97
  }
22
98
  },
23
99
  "sideEffects": false,
24
100
  "scripts": {
25
- "build": "vite build && tsc -p tsconfig.json",
101
+ "generate:llms": "node ../../scripts/generate-llms-txt .",
102
+ "build": "npm run generate:llms && vite build",
103
+ "build:stackblitz": "vite build",
26
104
  "dev": "vite",
27
- "test": "vitest",
105
+ "test": "node ../../scripts/run-vitest.mjs",
28
106
  "test:watch": "vitest watch"
29
107
  },
30
108
  "keywords": [
@@ -63,18 +141,19 @@
63
141
  "LLMs.txt"
64
142
  ],
65
143
  "peerDependencies": {
66
- "react": "^18.0.0 || ^19.0.0",
67
- "react-dom": "^18.0.0 || ^19.0.0"
144
+ "@preact/signals-core": "^1.8.0",
145
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
146
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
68
147
  },
69
148
  "dependencies": {
70
- "@preact/signals-core": "^1.8.0",
71
- "uuid": "^13.0.0"
149
+ "use-sync-external-store": "^1.2.0"
72
150
  },
73
151
  "devDependencies": {
152
+ "@types/use-sync-external-store": "^0.0.6",
74
153
  "@types/node": "^24.10.1",
154
+ "tsx": "^4.19.2",
75
155
  "@types/react": "^19.2.7",
76
156
  "@types/react-dom": "^19.2.3",
77
- "@types/uuid": "^10.0.0",
78
157
  "@vitejs/plugin-react": "^5.1.0",
79
158
  "@vitest/utils": "^4.0.8",
80
159
  "react": "^19.2.1",
@@ -1,528 +0,0 @@
1
- import { a as S, b as I, B as L } from "./registry-helpers-BfCZcMkO.js";
2
- var z = Symbol.for("preact-signals");
3
- function N() {
4
- if (w > 1)
5
- w--;
6
- else {
7
- for (var e, t = !1; P !== void 0; ) {
8
- var i = P;
9
- for (P = void 0, V++; i !== void 0; ) {
10
- var n = i.o;
11
- if (i.o = void 0, i.f &= -3, !(8 & i.f) && A(i)) try {
12
- i.c();
13
- } catch (o) {
14
- t || (e = o, t = !0);
15
- }
16
- i = n;
17
- }
18
- }
19
- if (V = 0, w--, t) throw e;
20
- }
21
- }
22
- var r = void 0;
23
- function U(e) {
24
- var t = r;
25
- r = void 0;
26
- try {
27
- return e();
28
- } finally {
29
- r = t;
30
- }
31
- }
32
- var P = void 0, w = 0, V = 0, B = 0;
33
- function C(e) {
34
- if (r !== void 0) {
35
- var t = e.n;
36
- if (t === void 0 || t.t !== r)
37
- return t = { i: 0, S: e, p: r.s, n: void 0, t: r, e: void 0, x: void 0, r: t }, r.s !== void 0 && (r.s.n = t), r.s = t, e.n = t, 32 & r.f && e.S(t), t;
38
- if (t.i === -1)
39
- return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = r.s, t.n = void 0, r.s.n = t, r.s = t), t;
40
- }
41
- }
42
- function d(e, t) {
43
- this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.W = t?.watched, this.Z = t?.unwatched, this.name = t?.name;
44
- }
45
- d.prototype.brand = z;
46
- d.prototype.h = function() {
47
- return !0;
48
- };
49
- d.prototype.S = function(e) {
50
- var t = this, i = this.t;
51
- i !== e && e.e === void 0 && (e.x = i, this.t = e, i !== void 0 ? i.e = e : U(function() {
52
- var n;
53
- (n = t.W) == null || n.call(t);
54
- }));
55
- };
56
- d.prototype.U = function(e) {
57
- var t = this;
58
- if (this.t !== void 0) {
59
- var i = e.e, n = e.x;
60
- i !== void 0 && (i.x = n, e.e = void 0), n !== void 0 && (n.e = i, e.x = void 0), e === this.t && (this.t = n, n === void 0 && U(function() {
61
- var o;
62
- (o = t.Z) == null || o.call(t);
63
- }));
64
- }
65
- };
66
- d.prototype.subscribe = function(e) {
67
- var t = this;
68
- return y(function() {
69
- var i = t.value, n = r;
70
- r = void 0;
71
- try {
72
- e(i);
73
- } finally {
74
- r = n;
75
- }
76
- }, { name: "sub" });
77
- };
78
- d.prototype.valueOf = function() {
79
- return this.value;
80
- };
81
- d.prototype.toString = function() {
82
- return this.value + "";
83
- };
84
- d.prototype.toJSON = function() {
85
- return this.value;
86
- };
87
- d.prototype.peek = function() {
88
- var e = r;
89
- r = void 0;
90
- try {
91
- return this.value;
92
- } finally {
93
- r = e;
94
- }
95
- };
96
- Object.defineProperty(d.prototype, "value", { get: function() {
97
- var e = C(this);
98
- return e !== void 0 && (e.i = this.i), this.v;
99
- }, set: function(e) {
100
- if (e !== this.v) {
101
- if (V > 100) throw new Error("Cycle detected");
102
- this.v = e, this.i++, B++, w++;
103
- try {
104
- for (var t = this.t; t !== void 0; t = t.x) t.t.N();
105
- } finally {
106
- N();
107
- }
108
- }
109
- } });
110
- function ot(e, t) {
111
- return new d(e, t);
112
- }
113
- function A(e) {
114
- for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
115
- return !1;
116
- }
117
- function W(e) {
118
- for (var t = e.s; t !== void 0; t = t.n) {
119
- var i = t.S.n;
120
- if (i !== void 0 && (t.r = i), t.S.n = t, t.i = -1, t.n === void 0) {
121
- e.s = t;
122
- break;
123
- }
124
- }
125
- }
126
- function j(e) {
127
- for (var t = e.s, i = void 0; t !== void 0; ) {
128
- var n = t.p;
129
- t.i === -1 ? (t.S.U(t), n !== void 0 && (n.n = t.n), t.n !== void 0 && (t.n.p = n)) : i = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = n;
130
- }
131
- e.s = i;
132
- }
133
- function _(e, t) {
134
- d.call(this, void 0), this.x = e, this.s = void 0, this.g = B - 1, this.f = 4, this.W = t?.watched, this.Z = t?.unwatched, this.name = t?.name;
135
- }
136
- _.prototype = new d();
137
- _.prototype.h = function() {
138
- if (this.f &= -3, 1 & this.f) return !1;
139
- if ((36 & this.f) == 32 || (this.f &= -5, this.g === B)) return !0;
140
- if (this.g = B, this.f |= 1, this.i > 0 && !A(this))
141
- return this.f &= -2, !0;
142
- var e = r;
143
- try {
144
- W(this), r = this;
145
- var t = this.x();
146
- (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
147
- } catch (i) {
148
- this.v = i, this.f |= 16, this.i++;
149
- }
150
- return r = e, j(this), this.f &= -2, !0;
151
- };
152
- _.prototype.S = function(e) {
153
- if (this.t === void 0) {
154
- this.f |= 36;
155
- for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
156
- }
157
- d.prototype.S.call(this, e);
158
- };
159
- _.prototype.U = function(e) {
160
- if (this.t !== void 0 && (d.prototype.U.call(this, e), this.t === void 0)) {
161
- this.f &= -33;
162
- for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
163
- }
164
- };
165
- _.prototype.N = function() {
166
- if (!(2 & this.f)) {
167
- this.f |= 6;
168
- for (var e = this.t; e !== void 0; e = e.x) e.t.N();
169
- }
170
- };
171
- Object.defineProperty(_.prototype, "value", { get: function() {
172
- if (1 & this.f) throw new Error("Cycle detected");
173
- var e = C(this);
174
- if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
175
- return this.v;
176
- } });
177
- function rt(e, t) {
178
- return new _(e, t);
179
- }
180
- function k(e) {
181
- var t = e.u;
182
- if (e.u = void 0, typeof t == "function") {
183
- w++;
184
- var i = r;
185
- r = void 0;
186
- try {
187
- t();
188
- } catch (n) {
189
- throw e.f &= -2, e.f |= 8, E(e), n;
190
- } finally {
191
- r = i, N();
192
- }
193
- }
194
- }
195
- function E(e) {
196
- for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
197
- e.x = void 0, e.s = void 0, k(e);
198
- }
199
- function J(e) {
200
- if (r !== this) throw new Error("Out-of-order effect");
201
- j(this), r = e, this.f &= -2, 8 & this.f && E(this), N();
202
- }
203
- function x(e, t) {
204
- this.x = e, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32, this.name = t?.name;
205
- }
206
- x.prototype.c = function() {
207
- var e = this.S();
208
- try {
209
- if (8 & this.f || this.x === void 0) return;
210
- var t = this.x();
211
- typeof t == "function" && (this.u = t);
212
- } finally {
213
- e();
214
- }
215
- };
216
- x.prototype.S = function() {
217
- if (1 & this.f) throw new Error("Cycle detected");
218
- this.f |= 1, this.f &= -9, k(this), W(this), w++;
219
- var e = r;
220
- return r = this, J.bind(this, e);
221
- };
222
- x.prototype.N = function() {
223
- 2 & this.f || (this.f |= 2, this.o = P, P = this);
224
- };
225
- x.prototype.d = function() {
226
- this.f |= 8, 1 & this.f || E(this);
227
- };
228
- x.prototype.dispose = function() {
229
- this.d();
230
- };
231
- function y(e, t) {
232
- var i = new x(e, t);
233
- try {
234
- i.c();
235
- } catch (o) {
236
- throw i.d(), o;
237
- }
238
- var n = i.d.bind(i);
239
- return n[Symbol.dispose] = n, n;
240
- }
241
- function O() {
242
- return T("");
243
- }
244
- function T(e) {
245
- return new Proxy(
246
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
247
- {},
248
- {
249
- get(t, i) {
250
- if (i === "__path" || i === "__fieldPath")
251
- return e || i;
252
- if (i === "__key") {
253
- const f = e.split(".");
254
- return f[f.length - 1] || i;
255
- }
256
- const n = e ? `${e}.${i}` : i, o = {
257
- __path: n,
258
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
259
- __key: i,
260
- __formType: void 0,
261
- __fieldType: void 0
262
- };
263
- return new Proxy(o, {
264
- get(f, a) {
265
- if (a === "__path" || a === "__fieldPath")
266
- return n;
267
- if (a === "__key")
268
- return i;
269
- if (a === "__formType" || a === "__fieldType")
270
- return;
271
- const h = `${n}.${a}`;
272
- return T(h);
273
- }
274
- });
275
- }
276
- }
277
- );
278
- }
279
- function F(e, t, i) {
280
- const { debounce: n, immediate: o = !1 } = i || {}, f = (a, h, l) => {
281
- const u = a.getFieldByPath(e.__path);
282
- if (!u) return null;
283
- if (o) {
284
- const s = u.value.value;
285
- t(s, h);
286
- }
287
- return y(() => {
288
- const s = u.value.value;
289
- l(() => {
290
- t(s, h);
291
- });
292
- });
293
- };
294
- S().register(f, { debounce: n });
295
- }
296
- function q(e, t, i) {
297
- const { when: n, fields: o = "all", transform: f, debounce: a } = i || {};
298
- F(
299
- e,
300
- (h, l) => {
301
- if (n) {
302
- const c = l.form.getValue();
303
- if (!n(c)) return;
304
- }
305
- const u = f ? f(h) : h, s = l.form.getFieldByPath(t.__path);
306
- if (s)
307
- if (o === "all" || !o)
308
- s.setValue(u, { emitEvent: !1 });
309
- else {
310
- const c = {};
311
- o.forEach((v) => {
312
- h && typeof h == "object" && (c[v] = h[v]);
313
- }), "patchValue" in s && s.patchValue(c);
314
- }
315
- },
316
- { debounce: a }
317
- );
318
- }
319
- function $(e, t, i) {
320
- const { debounce: n, resetOnDisable: o = !1 } = i || {}, f = (a, h, l) => {
321
- const u = a.getFieldByPath(e.__path);
322
- return u ? y(() => {
323
- const s = a.value.value;
324
- l(() => {
325
- t(s) ? u.enable() : (u.disable(), o && u.reset());
326
- });
327
- }) : null;
328
- };
329
- S().register(f, { debounce: n });
330
- }
331
- function G(e, t, i) {
332
- $(e, (n) => !t(n), i);
333
- }
334
- function H(e, t, i, n) {
335
- const { debounce: o, condition: f } = n || {}, a = (h, l, u) => {
336
- const s = h.getFieldByPath(t.__path);
337
- if (!s) return null;
338
- const c = e.map((v) => h.getFieldByPath(v.__path)).filter((v) => v !== void 0);
339
- return c.length === 0 ? null : y(() => {
340
- const v = c.map((g) => g.value.value);
341
- u(() => {
342
- if (f) {
343
- const b = h.getValue();
344
- if (!f(b)) return;
345
- }
346
- const g = {};
347
- e.forEach((b, Z) => {
348
- const D = b.__path.split(".").pop() || b.__path;
349
- g[D] = v[Z];
350
- });
351
- const m = i(g);
352
- s.setValue(m, { emitEvent: !1 });
353
- });
354
- });
355
- };
356
- S().register(a, { debounce: o });
357
- }
358
- function K(e, t, i) {
359
- const { debounce: n } = i || {}, o = (f, a, h) => {
360
- const l = f.getFieldByPath(e.__path);
361
- if (!l) return null;
362
- const u = t.map((s) => f.getFieldByPath(s.__path)).filter((s) => s !== void 0);
363
- return u.length === 0 ? null : y(() => {
364
- u.forEach((s) => s.value.value), h(() => {
365
- l.validate();
366
- });
367
- });
368
- };
369
- S().register(o, { debounce: n });
370
- }
371
- function Q(e, t, i) {
372
- const { debounce: n, transform: o } = i || {}, f = (a, h, l) => {
373
- const u = a.getFieldByPath(e.__path), s = a.getFieldByPath(t.__path);
374
- if (!u || !s) return null;
375
- let c = !1;
376
- const v = y(() => {
377
- const m = u.value.value;
378
- c || l(() => {
379
- c = !0;
380
- const b = o ? o(m) : m;
381
- s.setValue(b, { emitEvent: !1 }), c = !1;
382
- });
383
- }), g = y(() => {
384
- const m = s.value.value;
385
- c || l(() => {
386
- c = !0, u.setValue(m, { emitEvent: !1 }), c = !1;
387
- });
388
- });
389
- return () => {
390
- v(), g();
391
- };
392
- };
393
- S().register(f, { debounce: n });
394
- }
395
- function X(e, t, i) {
396
- const { debounce: n, resetValue: o = null, onlyIfDirty: f = !1 } = i || {}, a = (h, l, u) => {
397
- const s = h.getFieldByPath(e.__path);
398
- return s ? y(() => {
399
- const c = h.value.value;
400
- u(() => {
401
- if (t(c)) {
402
- if (f && !s.dirty.value)
403
- return;
404
- s.setValue(o), s.markAsPristine(), s.markAsUntouched();
405
- }
406
- });
407
- }) : null;
408
- };
409
- S().register(a, { debounce: n });
410
- }
411
- function R(e, t, i) {
412
- const { onUserChangeOnly: n = !1, emitEvent: o = !0, debounce: f } = i || {};
413
- F(
414
- e,
415
- (a, h) => {
416
- const l = h.form.getFieldByPath(e.__path);
417
- if (!l || n && !l.touched.value)
418
- return;
419
- const u = t(a);
420
- u !== a && l.setValue(u, { emitEvent: o });
421
- },
422
- { debounce: f }
423
- );
424
- }
425
- function p(e, t) {
426
- return (i, n) => {
427
- R(i, e, { ...t, ...n });
428
- };
429
- }
430
- const Y = {
431
- /** Перевести в верхний регистр */
432
- toUpperCase: p((e) => e?.toUpperCase()),
433
- /** Перевести в нижний регистр */
434
- toLowerCase: p((e) => e?.toLowerCase()),
435
- /** Удалить пробелы с краев */
436
- trim: p((e) => e?.trim()),
437
- /** Удалить все пробелы */
438
- removeSpaces: p((e) => e?.replace(/\s/g, "")),
439
- /** Оставить только цифры */
440
- digitsOnly: p((e) => e?.replace(/\D/g, "")),
441
- /** Округлить число */
442
- round: p(
443
- (e) => typeof e == "number" ? Math.round(e) : e
444
- ),
445
- /** Округлить до 2 знаков после запятой */
446
- roundTo2: p(
447
- (e) => typeof e == "number" ? Math.round(e * 100) / 100 : e
448
- )
449
- };
450
- function M(e) {
451
- if (!e)
452
- return O();
453
- const t = e.__path;
454
- return tt(t);
455
- }
456
- function tt(e) {
457
- return new Proxy({}, {
458
- get(t, i) {
459
- return typeof i == "symbol" ? void 0 : {
460
- __path: e ? `${e}.${i}` : i,
461
- __key: i
462
- };
463
- }
464
- });
465
- }
466
- function et(e, t) {
467
- const i = (Array.isArray(e) ? e : [e]).filter(Boolean), n = Array.isArray(t) ? t : [t];
468
- for (const o of i) {
469
- const f = M(o);
470
- for (const a of n)
471
- a(f);
472
- }
473
- }
474
- function it(e, t, i) {
475
- if (!e) return;
476
- let n = !1;
477
- F(
478
- e,
479
- (o, f) => {
480
- if (!n && t(o)) {
481
- const a = O();
482
- i(a), n = !0;
483
- }
484
- },
485
- { immediate: !0 }
486
- );
487
- }
488
- const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
489
- __proto__: null,
490
- BehaviorContextImpl: I,
491
- BehaviorRegistry: L,
492
- apply: et,
493
- applyWhen: it,
494
- computeFrom: H,
495
- copyFrom: q,
496
- createFieldPath: O,
497
- createTransformer: p,
498
- disableWhen: G,
499
- enableWhen: $,
500
- resetWhen: X,
501
- revalidateWhen: K,
502
- syncFields: Q,
503
- toBehaviorFieldPath: M,
504
- transformValue: R,
505
- transformers: Y,
506
- watchField: F
507
- }, Symbol.toStringTag, { value: "Module" }));
508
- export {
509
- y as E,
510
- et as a,
511
- it as b,
512
- O as c,
513
- ot as d,
514
- q as e,
515
- $ as f,
516
- G as g,
517
- H as h,
518
- st as i,
519
- F as j,
520
- X as k,
521
- R as l,
522
- p as m,
523
- Y as n,
524
- K as r,
525
- Q as s,
526
- M as t,
527
- rt as w
528
- };