@reformer/core 1.1.0-beta.4 → 1.1.0-beta.5
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.js +23 -22
- package/dist/core/validation/validate-form.js +6 -6
- package/dist/create-field-path-nXfTtl55.js +283 -0
- package/dist/{create-field-path-DcXDTWil.js → registry-helpers-BfCZcMkO.js} +63 -344
- package/dist/validation-context-cWXmh_Ho.js +156 -0
- package/dist/validators.js +6 -6
- package/llms.txt +414 -3
- package/package.json +1 -1
- package/dist/node-factory-DYXIgJmW.js +0 -3217
package/dist/behaviors.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { E as p, c as b } from "./create-field-path-nXfTtl55.js";
|
|
2
|
+
import { a as y } from "./registry-helpers-BfCZcMkO.js";
|
|
3
|
+
import { b as T, B as $ } from "./registry-helpers-BfCZcMkO.js";
|
|
3
4
|
function v(e, t, r) {
|
|
4
5
|
const { debounce: a, immediate: s = !1 } = r || {}, l = (u, i, c) => {
|
|
5
6
|
const o = u.getFieldByPath(e.__path);
|
|
@@ -17,7 +18,7 @@ function v(e, t, r) {
|
|
|
17
18
|
};
|
|
18
19
|
y().register(l, { debounce: a });
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function C(e, t, r) {
|
|
21
22
|
const { when: a, fields: s = "all", transform: l, debounce: u } = r || {};
|
|
22
23
|
v(
|
|
23
24
|
e,
|
|
@@ -52,10 +53,10 @@ function V(e, t, r) {
|
|
|
52
53
|
};
|
|
53
54
|
y().register(l, { debounce: a });
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function R(e, t, r) {
|
|
56
57
|
V(e, (a) => !t(a), r);
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function U(e, t, r, a) {
|
|
59
60
|
const { debounce: s, condition: l } = a || {}, u = (i, c, o) => {
|
|
60
61
|
const n = i.getFieldByPath(t.__path);
|
|
61
62
|
if (!n) return null;
|
|
@@ -79,7 +80,7 @@ function R(e, t, r, a) {
|
|
|
79
80
|
};
|
|
80
81
|
y().register(u, { debounce: s });
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function W(e, t, r) {
|
|
83
84
|
const { debounce: a } = r || {}, s = (l, u, i) => {
|
|
84
85
|
const c = l.getFieldByPath(e.__path);
|
|
85
86
|
if (!c) return null;
|
|
@@ -92,7 +93,7 @@ function U(e, t, r) {
|
|
|
92
93
|
};
|
|
93
94
|
y().register(s, { debounce: a });
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
+
function w(e, t, r) {
|
|
96
97
|
const { debounce: a, transform: s } = r || {}, l = (u, i, c) => {
|
|
97
98
|
const o = u.getFieldByPath(e.__path), n = u.getFieldByPath(t.__path);
|
|
98
99
|
if (!o || !n) return null;
|
|
@@ -116,7 +117,7 @@ function W(e, t, r) {
|
|
|
116
117
|
};
|
|
117
118
|
y().register(l, { debounce: a });
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
+
function O(e, t, r) {
|
|
120
121
|
const { debounce: a, resetValue: s = null, onlyIfDirty: l = !1 } = r || {}, u = (i, c, o) => {
|
|
121
122
|
const n = i.getFieldByPath(e.__path);
|
|
122
123
|
return n ? p(() => {
|
|
@@ -151,7 +152,7 @@ function h(e, t) {
|
|
|
151
152
|
F(r, e, { ...t, ...a });
|
|
152
153
|
};
|
|
153
154
|
}
|
|
154
|
-
const
|
|
155
|
+
const j = {
|
|
155
156
|
/** Перевести в верхний регистр */
|
|
156
157
|
toUpperCase: h((e) => e?.toUpperCase()),
|
|
157
158
|
/** Перевести в нижний регистр */
|
|
@@ -187,7 +188,7 @@ function E(e) {
|
|
|
187
188
|
}
|
|
188
189
|
});
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
+
function D(e, t) {
|
|
191
192
|
const r = (Array.isArray(e) ? e : [e]).filter(Boolean), a = Array.isArray(t) ? t : [t];
|
|
192
193
|
for (const s of r) {
|
|
193
194
|
const l = N(s);
|
|
@@ -195,7 +196,7 @@ function j(e, t) {
|
|
|
195
196
|
u(l);
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
function
|
|
199
|
+
function I(e, t, r) {
|
|
199
200
|
if (!e) return;
|
|
200
201
|
let a = !1;
|
|
201
202
|
v(
|
|
@@ -210,21 +211,21 @@ function D(e, t, r) {
|
|
|
210
211
|
);
|
|
211
212
|
}
|
|
212
213
|
export {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
T as BehaviorContextImpl,
|
|
215
|
+
$ as BehaviorRegistry,
|
|
216
|
+
D as apply,
|
|
217
|
+
I as applyWhen,
|
|
218
|
+
U as computeFrom,
|
|
219
|
+
C as copyFrom,
|
|
219
220
|
b as createFieldPath,
|
|
220
221
|
h as createTransformer,
|
|
221
|
-
|
|
222
|
+
R as disableWhen,
|
|
222
223
|
V as enableWhen,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
O as resetWhen,
|
|
225
|
+
W as revalidateWhen,
|
|
226
|
+
w as syncFields,
|
|
226
227
|
N as toBehaviorFieldPath,
|
|
227
228
|
F as transformValue,
|
|
228
|
-
|
|
229
|
+
j as transformers,
|
|
229
230
|
v as watchField
|
|
230
231
|
};
|
|
@@ -35,9 +35,7 @@
|
|
|
35
35
|
*
|
|
36
36
|
* @module validation
|
|
37
37
|
*/
|
|
38
|
-
import {
|
|
39
|
-
import { FieldNode } from '../nodes/field-node';
|
|
40
|
-
import { ArrayNode } from '../nodes/array-node';
|
|
38
|
+
import { isFieldNode, isGroupNode, isArrayNode } from '../utils/type-guards';
|
|
41
39
|
import { ValidationRegistry } from './validation-registry';
|
|
42
40
|
import { createFieldPath } from './field-path';
|
|
43
41
|
/**
|
|
@@ -51,13 +49,15 @@ import { createFieldPath } from './field-path';
|
|
|
51
49
|
* @returns Массив всех FieldNode в дереве
|
|
52
50
|
*/
|
|
53
51
|
function collectAllFieldNodes(node) {
|
|
54
|
-
|
|
52
|
+
// Используем duck-typing вместо instanceof для поддержки Proxy (GroupNodeWithControls)
|
|
53
|
+
// Proxy не проходит проверку instanceof, но type guards работают корректно
|
|
54
|
+
if (isFieldNode(node)) {
|
|
55
55
|
return [node];
|
|
56
56
|
}
|
|
57
|
-
if (node
|
|
57
|
+
if (isGroupNode(node)) {
|
|
58
58
|
return Array.from(node.getAllFields()).flatMap(collectAllFieldNodes);
|
|
59
59
|
}
|
|
60
|
-
if (node
|
|
60
|
+
if (isArrayNode(node)) {
|
|
61
61
|
// items приватный, используем публичный метод map()
|
|
62
62
|
return node.map((item) => collectAllFieldNodes(item)).flat();
|
|
63
63
|
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
var k = Symbol.for("preact-signals");
|
|
2
|
+
function y() {
|
|
3
|
+
if (v > 1)
|
|
4
|
+
v--;
|
|
5
|
+
else {
|
|
6
|
+
for (var t, i = !1; d !== void 0; ) {
|
|
7
|
+
var o = d;
|
|
8
|
+
for (d = void 0, l++; o !== void 0; ) {
|
|
9
|
+
var r = o.o;
|
|
10
|
+
if (o.o = void 0, o.f &= -3, !(8 & o.f) && S(o)) try {
|
|
11
|
+
o.c();
|
|
12
|
+
} catch (f) {
|
|
13
|
+
i || (t = f, i = !0);
|
|
14
|
+
}
|
|
15
|
+
o = r;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (l = 0, v--, i) throw t;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
var n = void 0;
|
|
22
|
+
function _(t) {
|
|
23
|
+
var i = n;
|
|
24
|
+
n = void 0;
|
|
25
|
+
try {
|
|
26
|
+
return t();
|
|
27
|
+
} finally {
|
|
28
|
+
n = i;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var d = void 0, v = 0, l = 0, a = 0;
|
|
32
|
+
function w(t) {
|
|
33
|
+
if (n !== void 0) {
|
|
34
|
+
var i = t.n;
|
|
35
|
+
if (i === void 0 || i.t !== n)
|
|
36
|
+
return i = { i: 0, S: t, p: n.s, n: void 0, t: n, e: void 0, x: void 0, r: i }, n.s !== void 0 && (n.s.n = i), n.s = i, t.n = i, 32 & n.f && t.S(i), i;
|
|
37
|
+
if (i.i === -1)
|
|
38
|
+
return i.i = 0, i.n !== void 0 && (i.n.p = i.p, i.p !== void 0 && (i.p.n = i.n), i.p = n.s, i.n = void 0, n.s.n = i, n.s = i), i;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function e(t, i) {
|
|
42
|
+
this.v = t, this.i = 0, this.n = void 0, this.t = void 0, this.W = i?.watched, this.Z = i?.unwatched, this.name = i?.name;
|
|
43
|
+
}
|
|
44
|
+
e.prototype.brand = k;
|
|
45
|
+
e.prototype.h = function() {
|
|
46
|
+
return !0;
|
|
47
|
+
};
|
|
48
|
+
e.prototype.S = function(t) {
|
|
49
|
+
var i = this, o = this.t;
|
|
50
|
+
o !== t && t.e === void 0 && (t.x = o, this.t = t, o !== void 0 ? o.e = t : _(function() {
|
|
51
|
+
var r;
|
|
52
|
+
(r = i.W) == null || r.call(i);
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
e.prototype.U = function(t) {
|
|
56
|
+
var i = this;
|
|
57
|
+
if (this.t !== void 0) {
|
|
58
|
+
var o = t.e, r = t.x;
|
|
59
|
+
o !== void 0 && (o.x = r, t.e = void 0), r !== void 0 && (r.e = o, t.x = void 0), t === this.t && (this.t = r, r === void 0 && _(function() {
|
|
60
|
+
var f;
|
|
61
|
+
(f = i.Z) == null || f.call(i);
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
e.prototype.subscribe = function(t) {
|
|
66
|
+
var i = this;
|
|
67
|
+
return N(function() {
|
|
68
|
+
var o = i.value, r = n;
|
|
69
|
+
n = void 0;
|
|
70
|
+
try {
|
|
71
|
+
t(o);
|
|
72
|
+
} finally {
|
|
73
|
+
n = r;
|
|
74
|
+
}
|
|
75
|
+
}, { name: "sub" });
|
|
76
|
+
};
|
|
77
|
+
e.prototype.valueOf = function() {
|
|
78
|
+
return this.value;
|
|
79
|
+
};
|
|
80
|
+
e.prototype.toString = function() {
|
|
81
|
+
return this.value + "";
|
|
82
|
+
};
|
|
83
|
+
e.prototype.toJSON = function() {
|
|
84
|
+
return this.value;
|
|
85
|
+
};
|
|
86
|
+
e.prototype.peek = function() {
|
|
87
|
+
var t = n;
|
|
88
|
+
n = void 0;
|
|
89
|
+
try {
|
|
90
|
+
return this.value;
|
|
91
|
+
} finally {
|
|
92
|
+
n = t;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
Object.defineProperty(e.prototype, "value", { get: function() {
|
|
96
|
+
var t = w(this);
|
|
97
|
+
return t !== void 0 && (t.i = this.i), this.v;
|
|
98
|
+
}, set: function(t) {
|
|
99
|
+
if (t !== this.v) {
|
|
100
|
+
if (l > 100) throw new Error("Cycle detected");
|
|
101
|
+
this.v = t, this.i++, a++, v++;
|
|
102
|
+
try {
|
|
103
|
+
for (var i = this.t; i !== void 0; i = i.x) i.t.N();
|
|
104
|
+
} finally {
|
|
105
|
+
y();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} });
|
|
109
|
+
function O(t, i) {
|
|
110
|
+
return new e(t, i);
|
|
111
|
+
}
|
|
112
|
+
function S(t) {
|
|
113
|
+
for (var i = t.s; i !== void 0; i = i.n) if (i.S.i !== i.i || !i.S.h() || i.S.i !== i.i) return !0;
|
|
114
|
+
return !1;
|
|
115
|
+
}
|
|
116
|
+
function x(t) {
|
|
117
|
+
for (var i = t.s; i !== void 0; i = i.n) {
|
|
118
|
+
var o = i.S.n;
|
|
119
|
+
if (o !== void 0 && (i.r = o), i.S.n = i, i.i = -1, i.n === void 0) {
|
|
120
|
+
t.s = i;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function g(t) {
|
|
126
|
+
for (var i = t.s, o = void 0; i !== void 0; ) {
|
|
127
|
+
var r = i.p;
|
|
128
|
+
i.i === -1 ? (i.S.U(i), r !== void 0 && (r.n = i.n), i.n !== void 0 && (i.n.p = r)) : o = i, i.S.n = i.r, i.r !== void 0 && (i.r = void 0), i = r;
|
|
129
|
+
}
|
|
130
|
+
t.s = o;
|
|
131
|
+
}
|
|
132
|
+
function s(t, i) {
|
|
133
|
+
e.call(this, void 0), this.x = t, this.s = void 0, this.g = a - 1, this.f = 4, this.W = i?.watched, this.Z = i?.unwatched, this.name = i?.name;
|
|
134
|
+
}
|
|
135
|
+
s.prototype = new e();
|
|
136
|
+
s.prototype.h = function() {
|
|
137
|
+
if (this.f &= -3, 1 & this.f) return !1;
|
|
138
|
+
if ((36 & this.f) == 32 || (this.f &= -5, this.g === a)) return !0;
|
|
139
|
+
if (this.g = a, this.f |= 1, this.i > 0 && !S(this))
|
|
140
|
+
return this.f &= -2, !0;
|
|
141
|
+
var t = n;
|
|
142
|
+
try {
|
|
143
|
+
x(this), n = this;
|
|
144
|
+
var i = this.x();
|
|
145
|
+
(16 & this.f || this.v !== i || this.i === 0) && (this.v = i, this.f &= -17, this.i++);
|
|
146
|
+
} catch (o) {
|
|
147
|
+
this.v = o, this.f |= 16, this.i++;
|
|
148
|
+
}
|
|
149
|
+
return n = t, g(this), this.f &= -2, !0;
|
|
150
|
+
};
|
|
151
|
+
s.prototype.S = function(t) {
|
|
152
|
+
if (this.t === void 0) {
|
|
153
|
+
this.f |= 36;
|
|
154
|
+
for (var i = this.s; i !== void 0; i = i.n) i.S.S(i);
|
|
155
|
+
}
|
|
156
|
+
e.prototype.S.call(this, t);
|
|
157
|
+
};
|
|
158
|
+
s.prototype.U = function(t) {
|
|
159
|
+
if (this.t !== void 0 && (e.prototype.U.call(this, t), this.t === void 0)) {
|
|
160
|
+
this.f &= -33;
|
|
161
|
+
for (var i = this.s; i !== void 0; i = i.n) i.S.U(i);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
s.prototype.N = function() {
|
|
165
|
+
if (!(2 & this.f)) {
|
|
166
|
+
this.f |= 6;
|
|
167
|
+
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
Object.defineProperty(s.prototype, "value", { get: function() {
|
|
171
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
172
|
+
var t = w(this);
|
|
173
|
+
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
|
|
174
|
+
return this.v;
|
|
175
|
+
} });
|
|
176
|
+
function T(t, i) {
|
|
177
|
+
return new s(t, i);
|
|
178
|
+
}
|
|
179
|
+
function b(t) {
|
|
180
|
+
var i = t.u;
|
|
181
|
+
if (t.u = void 0, typeof i == "function") {
|
|
182
|
+
v++;
|
|
183
|
+
var o = n;
|
|
184
|
+
n = void 0;
|
|
185
|
+
try {
|
|
186
|
+
i();
|
|
187
|
+
} catch (r) {
|
|
188
|
+
throw t.f &= -2, t.f |= 8, p(t), r;
|
|
189
|
+
} finally {
|
|
190
|
+
n = o, y();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function p(t) {
|
|
195
|
+
for (var i = t.s; i !== void 0; i = i.n) i.S.U(i);
|
|
196
|
+
t.x = void 0, t.s = void 0, b(t);
|
|
197
|
+
}
|
|
198
|
+
function E(t) {
|
|
199
|
+
if (n !== this) throw new Error("Out-of-order effect");
|
|
200
|
+
g(this), n = t, this.f &= -2, 8 & this.f && p(this), y();
|
|
201
|
+
}
|
|
202
|
+
function u(t, i) {
|
|
203
|
+
this.x = t, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32, this.name = i?.name;
|
|
204
|
+
}
|
|
205
|
+
u.prototype.c = function() {
|
|
206
|
+
var t = this.S();
|
|
207
|
+
try {
|
|
208
|
+
if (8 & this.f || this.x === void 0) return;
|
|
209
|
+
var i = this.x();
|
|
210
|
+
typeof i == "function" && (this.u = i);
|
|
211
|
+
} finally {
|
|
212
|
+
t();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
u.prototype.S = function() {
|
|
216
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
217
|
+
this.f |= 1, this.f &= -9, b(this), x(this), v++;
|
|
218
|
+
var t = n;
|
|
219
|
+
return n = this, E.bind(this, t);
|
|
220
|
+
};
|
|
221
|
+
u.prototype.N = function() {
|
|
222
|
+
2 & this.f || (this.f |= 2, this.o = d, d = this);
|
|
223
|
+
};
|
|
224
|
+
u.prototype.d = function() {
|
|
225
|
+
this.f |= 8, 1 & this.f || p(this);
|
|
226
|
+
};
|
|
227
|
+
u.prototype.dispose = function() {
|
|
228
|
+
this.d();
|
|
229
|
+
};
|
|
230
|
+
function N(t, i) {
|
|
231
|
+
var o = new u(t, i);
|
|
232
|
+
try {
|
|
233
|
+
o.c();
|
|
234
|
+
} catch (f) {
|
|
235
|
+
throw o.d(), f;
|
|
236
|
+
}
|
|
237
|
+
var r = o.d.bind(o);
|
|
238
|
+
return r[Symbol.dispose] = r, r;
|
|
239
|
+
}
|
|
240
|
+
function $() {
|
|
241
|
+
return m("");
|
|
242
|
+
}
|
|
243
|
+
function m(t) {
|
|
244
|
+
return new Proxy(
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
246
|
+
{},
|
|
247
|
+
{
|
|
248
|
+
get(i, o) {
|
|
249
|
+
if (o === "__path" || o === "__fieldPath")
|
|
250
|
+
return t || o;
|
|
251
|
+
if (o === "__key") {
|
|
252
|
+
const c = t.split(".");
|
|
253
|
+
return c[c.length - 1] || o;
|
|
254
|
+
}
|
|
255
|
+
const r = t ? `${t}.${o}` : o, f = {
|
|
256
|
+
__path: r,
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
+
__key: o,
|
|
259
|
+
__formType: void 0,
|
|
260
|
+
__fieldType: void 0
|
|
261
|
+
};
|
|
262
|
+
return new Proxy(f, {
|
|
263
|
+
get(c, h) {
|
|
264
|
+
if (h === "__path" || h === "__fieldPath")
|
|
265
|
+
return r;
|
|
266
|
+
if (h === "__key")
|
|
267
|
+
return o;
|
|
268
|
+
if (h === "__formType" || h === "__fieldType")
|
|
269
|
+
return;
|
|
270
|
+
const U = `${r}.${h}`;
|
|
271
|
+
return m(U);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
export {
|
|
279
|
+
N as E,
|
|
280
|
+
$ as c,
|
|
281
|
+
O as d,
|
|
282
|
+
T as w
|
|
283
|
+
};
|