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