@reformer/core 1.1.0-beta.7 → 1.1.0-beta.8
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-BRaiR-UY.js +528 -0
- package/dist/behaviors.d.ts +6 -2
- package/dist/behaviors.js +18 -227
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3380 -10
- package/dist/validators-DjXtDVoE.js +455 -0
- package/dist/validators.d.ts +6 -2
- package/dist/validators.js +29 -281
- package/package.json +1 -1
- package/dist/core/behavior/behavior-applicator.js +0 -92
- package/dist/core/behavior/behavior-context.js +0 -43
- 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.js +0 -215
- package/dist/core/nodes/group-node/index.js +0 -11
- package/dist/core/nodes/group-node/proxy-builder.js +0 -161
- 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 -43
- 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/create-field-path-nXfTtl55.js +0 -283
- package/dist/hooks/useFormControl.js +0 -298
- package/dist/validation-context-cWXmh_Ho.js +0 -156
|
@@ -0,0 +1,528 @@
|
|
|
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
|
+
};
|
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';
|