@reformer/core 1.1.0-beta.6 → 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
package/dist/behaviors.js
CHANGED
|
@@ -1,231 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { b as T, B as $ } from "./registry-helpers-BfCZcMkO.js";
|
|
4
|
-
function v(e, t, r) {
|
|
5
|
-
const { debounce: a, immediate: s = !1 } = r || {}, l = (u, i, c) => {
|
|
6
|
-
const o = u.getFieldByPath(e.__path);
|
|
7
|
-
if (!o) return null;
|
|
8
|
-
if (s) {
|
|
9
|
-
const n = o.value.value;
|
|
10
|
-
t(n, i);
|
|
11
|
-
}
|
|
12
|
-
return p(() => {
|
|
13
|
-
const n = o.value.value;
|
|
14
|
-
c(() => {
|
|
15
|
-
t(n, i);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
y().register(l, { debounce: a });
|
|
20
|
-
}
|
|
21
|
-
function C(e, t, r) {
|
|
22
|
-
const { when: a, fields: s = "all", transform: l, debounce: u } = r || {};
|
|
23
|
-
v(
|
|
24
|
-
e,
|
|
25
|
-
(i, c) => {
|
|
26
|
-
if (a) {
|
|
27
|
-
const f = c.form.getValue();
|
|
28
|
-
if (!a(f)) return;
|
|
29
|
-
}
|
|
30
|
-
const o = l ? l(i) : i, n = c.form.getFieldByPath(t.__path);
|
|
31
|
-
if (n)
|
|
32
|
-
if (s === "all" || !s)
|
|
33
|
-
n.setValue(o, { emitEvent: !1 });
|
|
34
|
-
else {
|
|
35
|
-
const f = {};
|
|
36
|
-
s.forEach((d) => {
|
|
37
|
-
i && typeof i == "object" && (f[d] = i[d]);
|
|
38
|
-
}), "patchValue" in n && n.patchValue(f);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{ debounce: u }
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
function V(e, t, r) {
|
|
45
|
-
const { debounce: a, resetOnDisable: s = !1 } = r || {}, l = (u, i, c) => {
|
|
46
|
-
const o = u.getFieldByPath(e.__path);
|
|
47
|
-
return o ? p(() => {
|
|
48
|
-
const n = u.value.value;
|
|
49
|
-
c(() => {
|
|
50
|
-
t(n) ? o.enable() : (o.disable(), s && o.reset());
|
|
51
|
-
});
|
|
52
|
-
}) : null;
|
|
53
|
-
};
|
|
54
|
-
y().register(l, { debounce: a });
|
|
55
|
-
}
|
|
56
|
-
function R(e, t, r) {
|
|
57
|
-
V(e, (a) => !t(a), r);
|
|
58
|
-
}
|
|
59
|
-
function U(e, t, r, a) {
|
|
60
|
-
const { debounce: s, condition: l } = a || {}, u = (i, c, o) => {
|
|
61
|
-
const n = i.getFieldByPath(t.__path);
|
|
62
|
-
if (!n) return null;
|
|
63
|
-
const f = e.map((d) => i.getFieldByPath(d.__path)).filter((d) => d !== void 0);
|
|
64
|
-
return f.length === 0 ? null : p(() => {
|
|
65
|
-
const d = f.map((g) => g.value.value);
|
|
66
|
-
o(() => {
|
|
67
|
-
if (l) {
|
|
68
|
-
const m = i.getValue();
|
|
69
|
-
if (!l(m)) return;
|
|
70
|
-
}
|
|
71
|
-
const g = {};
|
|
72
|
-
e.forEach((m, P) => {
|
|
73
|
-
const B = m.__path.split(".").pop() || m.__path;
|
|
74
|
-
g[B] = d[P];
|
|
75
|
-
});
|
|
76
|
-
const _ = r(g);
|
|
77
|
-
n.setValue(_, { emitEvent: !1 });
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
y().register(u, { debounce: s });
|
|
82
|
-
}
|
|
83
|
-
function W(e, t, r) {
|
|
84
|
-
const { debounce: a } = r || {}, s = (l, u, i) => {
|
|
85
|
-
const c = l.getFieldByPath(e.__path);
|
|
86
|
-
if (!c) return null;
|
|
87
|
-
const o = t.map((n) => l.getFieldByPath(n.__path)).filter((n) => n !== void 0);
|
|
88
|
-
return o.length === 0 ? null : p(() => {
|
|
89
|
-
o.forEach((n) => n.value.value), i(() => {
|
|
90
|
-
c.validate();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
y().register(s, { debounce: a });
|
|
95
|
-
}
|
|
96
|
-
function w(e, t, r) {
|
|
97
|
-
const { debounce: a, transform: s } = r || {}, l = (u, i, c) => {
|
|
98
|
-
const o = u.getFieldByPath(e.__path), n = u.getFieldByPath(t.__path);
|
|
99
|
-
if (!o || !n) return null;
|
|
100
|
-
let f = !1;
|
|
101
|
-
const d = p(() => {
|
|
102
|
-
const _ = o.value.value;
|
|
103
|
-
f || c(() => {
|
|
104
|
-
f = !0;
|
|
105
|
-
const m = s ? s(_) : _;
|
|
106
|
-
n.setValue(m, { emitEvent: !1 }), f = !1;
|
|
107
|
-
});
|
|
108
|
-
}), g = p(() => {
|
|
109
|
-
const _ = n.value.value;
|
|
110
|
-
f || c(() => {
|
|
111
|
-
f = !0, o.setValue(_, { emitEvent: !1 }), f = !1;
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
return () => {
|
|
115
|
-
d(), g();
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
y().register(l, { debounce: a });
|
|
119
|
-
}
|
|
120
|
-
function O(e, t, r) {
|
|
121
|
-
const { debounce: a, resetValue: s = null, onlyIfDirty: l = !1 } = r || {}, u = (i, c, o) => {
|
|
122
|
-
const n = i.getFieldByPath(e.__path);
|
|
123
|
-
return n ? p(() => {
|
|
124
|
-
const f = i.value.value;
|
|
125
|
-
o(() => {
|
|
126
|
-
if (t(f)) {
|
|
127
|
-
if (l && !n.dirty.value)
|
|
128
|
-
return;
|
|
129
|
-
n.setValue(s), n.markAsPristine(), n.markAsUntouched();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}) : null;
|
|
133
|
-
};
|
|
134
|
-
y().register(u, { debounce: a });
|
|
135
|
-
}
|
|
136
|
-
function F(e, t, r) {
|
|
137
|
-
const { onUserChangeOnly: a = !1, emitEvent: s = !0, debounce: l } = r || {};
|
|
138
|
-
v(
|
|
139
|
-
e,
|
|
140
|
-
(u, i) => {
|
|
141
|
-
const c = i.form.getFieldByPath(e.__path);
|
|
142
|
-
if (!c || a && !c.touched.value)
|
|
143
|
-
return;
|
|
144
|
-
const o = t(u);
|
|
145
|
-
o !== u && c.setValue(o, { emitEvent: s });
|
|
146
|
-
},
|
|
147
|
-
{ debounce: l }
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
function h(e, t) {
|
|
151
|
-
return (r, a) => {
|
|
152
|
-
F(r, e, { ...t, ...a });
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
const j = {
|
|
156
|
-
/** Перевести в верхний регистр */
|
|
157
|
-
toUpperCase: h((e) => e?.toUpperCase()),
|
|
158
|
-
/** Перевести в нижний регистр */
|
|
159
|
-
toLowerCase: h((e) => e?.toLowerCase()),
|
|
160
|
-
/** Удалить пробелы с краев */
|
|
161
|
-
trim: h((e) => e?.trim()),
|
|
162
|
-
/** Удалить все пробелы */
|
|
163
|
-
removeSpaces: h((e) => e?.replace(/\s/g, "")),
|
|
164
|
-
/** Оставить только цифры */
|
|
165
|
-
digitsOnly: h((e) => e?.replace(/\D/g, "")),
|
|
166
|
-
/** Округлить число */
|
|
167
|
-
round: h(
|
|
168
|
-
(e) => typeof e == "number" ? Math.round(e) : e
|
|
169
|
-
),
|
|
170
|
-
/** Округлить до 2 знаков после запятой */
|
|
171
|
-
roundTo2: h(
|
|
172
|
-
(e) => typeof e == "number" ? Math.round(e * 100) / 100 : e
|
|
173
|
-
)
|
|
174
|
-
};
|
|
175
|
-
function N(e) {
|
|
176
|
-
if (!e)
|
|
177
|
-
return b();
|
|
178
|
-
const t = e.__path;
|
|
179
|
-
return E(t);
|
|
180
|
-
}
|
|
181
|
-
function E(e) {
|
|
182
|
-
return new Proxy({}, {
|
|
183
|
-
get(t, r) {
|
|
184
|
-
return typeof r == "symbol" ? void 0 : {
|
|
185
|
-
__path: e ? `${e}.${r}` : r,
|
|
186
|
-
__key: r
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
function D(e, t) {
|
|
192
|
-
const r = (Array.isArray(e) ? e : [e]).filter(Boolean), a = Array.isArray(t) ? t : [t];
|
|
193
|
-
for (const s of r) {
|
|
194
|
-
const l = N(s);
|
|
195
|
-
for (const u of a)
|
|
196
|
-
u(l);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function I(e, t, r) {
|
|
200
|
-
if (!e) return;
|
|
201
|
-
let a = !1;
|
|
202
|
-
v(
|
|
203
|
-
e,
|
|
204
|
-
(s, l) => {
|
|
205
|
-
if (!a && t(s)) {
|
|
206
|
-
const u = b();
|
|
207
|
-
r(u), a = !0;
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
{ immediate: !0 }
|
|
211
|
-
);
|
|
212
|
-
}
|
|
1
|
+
import { a as s, b as r, h as t, e as o, c as l, m as h, i as n, g as i, f as m, k as p, r as c, s as d, t as f, l as F, n as y, j as W } from "./behaviors-BRaiR-UY.js";
|
|
2
|
+
import { b as v, B } from "./registry-helpers-BfCZcMkO.js";
|
|
213
3
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
4
|
+
v as BehaviorContextImpl,
|
|
5
|
+
B as BehaviorRegistry,
|
|
6
|
+
s as apply,
|
|
7
|
+
r as applyWhen,
|
|
8
|
+
t as computeFrom,
|
|
9
|
+
o as copyFrom,
|
|
10
|
+
l as createFieldPath,
|
|
221
11
|
h as createTransformer,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
12
|
+
n as default,
|
|
13
|
+
i as disableWhen,
|
|
14
|
+
m as enableWhen,
|
|
15
|
+
p as resetWhen,
|
|
16
|
+
c as revalidateWhen,
|
|
17
|
+
d as syncFields,
|
|
18
|
+
f as toBehaviorFieldPath,
|
|
228
19
|
F as transformValue,
|
|
229
|
-
|
|
230
|
-
|
|
20
|
+
y as transformers,
|
|
21
|
+
W as watchField
|
|
231
22
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export type { SetValueOptions } from './core/nodes/form-node';
|
|
|
9
9
|
export { useFormControl, useFormControlValue } from './hooks/useFormControl';
|
|
10
10
|
export type { BehaviorSchemaFn } from './core/behavior/types';
|
|
11
11
|
export { validateForm } from './core/validation/validate-form';
|
|
12
|
+
export * as behaviors from './core/behavior';
|
|
13
|
+
export * as validators from './core/validation';
|