@reformer/core 11.0.0-beta.3 → 11.0.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.d.ts +1 -1
- package/dist/behaviors.js +37 -37
- package/dist/create-model-Dxh9cfLp.js +97 -0
- package/dist/form/behaviors/collections.d.ts +50 -0
- package/dist/form/behaviors/context.d.ts +23 -0
- package/dist/form/behaviors/index.d.ts +28 -0
- package/dist/form/behaviors/internals.d.ts +26 -0
- package/dist/form/{behaviors-node.d.ts → behaviors/node.d.ts} +3 -3
- package/dist/form/behaviors/operators.d.ts +51 -0
- package/dist/form/behaviors/types.d.ts +17 -0
- package/dist/form/create-core-form.d.ts +3 -3
- package/dist/form/create-form.d.ts +12 -10
- package/dist/form/factories/node-factory.d.ts +17 -16
- package/dist/form/index.d.ts +10 -16
- package/dist/form/nodes/array-node.d.ts +3 -3
- package/dist/form/nodes/field-node.d.ts +6 -3
- package/dist/form/nodes/group-node.d.ts +7 -7
- package/dist/form/nodes/model-array-node.d.ts +3 -3
- package/dist/form/types/contracts.d.ts +9 -6
- package/dist/form/types/deep-schema.d.ts +5 -5
- package/dist/form/types/validation-schema.d.ts +1 -1
- package/dist/form/{validation-config.d.ts → validation/config.d.ts} +3 -3
- package/dist/form/validation/context.d.ts +27 -0
- package/dist/form/{error-handler.d.ts → validation/error-handler.d.ts} +1 -1
- package/dist/form/validation/index.d.ts +23 -28
- package/dist/form/validation/operators.d.ts +42 -0
- package/dist/form/validation/run.d.ts +45 -0
- package/dist/form/{validation-strategy.d.ts → validation/strategy.d.ts} +2 -2
- package/dist/form/validation/types.d.ts +28 -0
- package/dist/form/{validation/validators → validators}/date-utils.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/email.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/file-type.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/file-utils.d.ts +1 -1
- package/dist/form/{validation/validators → validators}/future-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/index.d.ts +7 -4
- package/dist/form/{validation/validators → validators}/integer.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/is-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/is-number.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-age.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-file-size.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-files.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max-length.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/max-total-file-size.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/max.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/min-age.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-file-size.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-files.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/min-length.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/min.d.ts +7 -8
- package/dist/form/{validation/validators → validators}/multiple-of.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/non-negative.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/non-zero.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/past-date.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/pattern.d.ts +7 -15
- package/dist/form/{validation/validators → validators}/phone.d.ts +6 -7
- package/dist/form/{validation/validators → validators}/required.d.ts +8 -13
- package/dist/form/{validation/validators → validators}/url.d.ts +8 -13
- package/dist/index.d.ts +7 -4
- package/dist/index.js +272 -94
- package/dist/{state/form-model.d.ts → model/create-model.d.ts} +0 -14
- package/dist/{state → model}/index.d.ts +10 -11
- package/dist/model/model-nodes.d.ts +60 -0
- package/dist/model/model-signals-proxy.d.ts +32 -0
- package/dist/model/model-value-proxy.d.ts +3 -0
- package/dist/{state → model}/safe-effect.d.ts +1 -1
- package/dist/model-signals-proxy-mV3WGdlO.js +233 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.js +21 -0
- package/dist/{form → platforms/react}/hooks/types.d.ts +1 -1
- package/dist/{form → platforms/react}/hooks/use-form-bundle.d.ts +1 -1
- package/dist/{form → platforms/react}/hooks/use-form-validation.d.ts +3 -3
- package/dist/{form → platforms/react}/hooks/useArrayLength.d.ts +1 -1
- package/dist/{form → platforms/react}/hooks/useFormControl.d.ts +3 -3
- package/dist/{form → platforms/react}/hooks/useFormControlValue.d.ts +2 -2
- package/dist/platforms/react/index.d.ts +23 -0
- package/dist/signals.d.ts +1 -1
- package/dist/strategy-DA3JwxsR.js +170 -0
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +10 -165
- package/dist/validators/email.d.ts +1 -1
- package/dist/validators/future-date.d.ts +1 -1
- package/dist/validators/integer.d.ts +1 -1
- package/dist/validators/is-date.d.ts +1 -1
- package/dist/validators/is-number.d.ts +1 -1
- package/dist/validators/max-age.d.ts +1 -1
- package/dist/validators/max-date.d.ts +1 -1
- package/dist/validators/max-length.d.ts +1 -1
- package/dist/validators/max.d.ts +1 -1
- package/dist/validators/min-age.d.ts +1 -1
- package/dist/validators/min-date.d.ts +1 -1
- package/dist/validators/min-length.d.ts +1 -1
- package/dist/validators/min.d.ts +1 -1
- package/dist/validators/multiple-of.d.ts +1 -1
- package/dist/validators/non-negative.d.ts +1 -1
- package/dist/validators/non-zero.d.ts +1 -1
- package/dist/validators/past-date.d.ts +1 -1
- package/dist/validators/pattern.d.ts +1 -1
- package/dist/validators/phone.d.ts +1 -1
- package/dist/validators/required.d.ts +1 -1
- package/dist/validators/url.d.ts +1 -1
- package/dist/validators.d.ts +1 -1
- package/docs/llms/02-quick-start.md +6 -6
- package/docs/llms/03-api-signatures.md +3 -3
- package/docs/llms/05-common-mistakes.md +1 -1
- package/docs/llms/09-formschema.md +11 -11
- package/docs/llms/10-arrays.md +4 -4
- package/docs/llms/14-extended-mistakes.md +1 -1
- package/docs/llms/15-project-structure.md +8 -7
- package/docs/llms/16-ui-components.md +6 -6
- package/docs/llms/17-nonexistent-api.md +2 -2
- package/docs/llms/29-async-preload.md +4 -4
- package/docs/llms/30-type-safety-recipes.md +1 -1
- package/llms-index.json +1 -0
- package/llms.txt +2102 -262
- package/package.json +5 -4
- package/dist/form/behaviors.d.ts +0 -133
- package/dist/form/validation-schema.d.ts +0 -106
- package/dist/form/validators.d.ts +0 -11
- package/dist/form-model-DhW2HZOB.js +0 -323
- package/dist/state.d.ts +0 -2
- package/dist/state.js +0 -21
- package/dist/subscription-manager-705bls97.js +0 -171
- /package/dist/{state → form/nodes}/subscription-manager.d.ts +0 -0
- /package/dist/{state → model}/behaviors-value.d.ts +0 -0
- /package/dist/{state → model}/derived-registry.d.ts +0 -0
- /package/dist/{state → model}/types.d.ts +0 -0
- /package/dist/{behaviors-node-DGEFMTQu.js → node-DGEFMTQu.js} +0 -0
- /package/dist/{form → platforms/react}/hooks/useSignalSubscription.d.ts +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { signal as A, effect as M } from "@preact/signals-core";
|
|
2
|
+
import { e as W } from "./create-model-Dxh9cfLp.js";
|
|
3
|
+
import { g as v } from "./signal-node-registry-tiwel-TV.js";
|
|
4
|
+
let g = null;
|
|
5
|
+
function E(e, n) {
|
|
6
|
+
const t = g;
|
|
7
|
+
g = e;
|
|
8
|
+
try {
|
|
9
|
+
return n();
|
|
10
|
+
} finally {
|
|
11
|
+
g = t;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function u(e) {
|
|
15
|
+
if (!g)
|
|
16
|
+
throw new Error(
|
|
17
|
+
`[@reformer/core/validation] "${e}" вызван вне схемы валидации — операторы валидации можно вызывать только внутри прогона validateModel(...) (напрямую или через apply/each).`
|
|
18
|
+
);
|
|
19
|
+
return g;
|
|
20
|
+
}
|
|
21
|
+
function m(e, n) {
|
|
22
|
+
let t = e.errors.get(n);
|
|
23
|
+
return t || e.errors.set(n, t = []), t;
|
|
24
|
+
}
|
|
25
|
+
const b = (e) => e.whenStack.every((n) => n());
|
|
26
|
+
function D(e, n) {
|
|
27
|
+
const t = u("validate"), r = m(t, e);
|
|
28
|
+
if (!b(t)) return;
|
|
29
|
+
const o = e.peek();
|
|
30
|
+
for (const a of n) {
|
|
31
|
+
const i = a(o, t.model, t.model);
|
|
32
|
+
i && r.push(i);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function N(e, n) {
|
|
36
|
+
const t = u("validateAsync"), r = m(t, e);
|
|
37
|
+
if (!b(t)) return;
|
|
38
|
+
const o = e.peek(), a = t.signal;
|
|
39
|
+
for (const i of n)
|
|
40
|
+
t.pending.push(
|
|
41
|
+
i(o, { signal: a }).then(
|
|
42
|
+
(s) => {
|
|
43
|
+
s && !a.aborted && r.push(s);
|
|
44
|
+
},
|
|
45
|
+
() => {
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function R(e, n) {
|
|
51
|
+
const t = u("validateWhen");
|
|
52
|
+
t.whenStack.push(e);
|
|
53
|
+
try {
|
|
54
|
+
n();
|
|
55
|
+
} finally {
|
|
56
|
+
t.whenStack.pop();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function _(e, n) {
|
|
60
|
+
const t = u("cross"), r = m(t, e);
|
|
61
|
+
if (!b(t)) return;
|
|
62
|
+
const o = n(t.model.get());
|
|
63
|
+
o && r.push(o);
|
|
64
|
+
}
|
|
65
|
+
function $(e, n) {
|
|
66
|
+
u("each");
|
|
67
|
+
const t = e.length;
|
|
68
|
+
for (let r = 0; r < t; r++) n(e.at(r));
|
|
69
|
+
}
|
|
70
|
+
function j(...e) {
|
|
71
|
+
const t = u("apply").model;
|
|
72
|
+
for (const r of e) r({ model: t });
|
|
73
|
+
}
|
|
74
|
+
function z(e) {
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
78
|
+
function L(e, n) {
|
|
79
|
+
let t = x.get(e);
|
|
80
|
+
t || x.set(e, t = /* @__PURE__ */ new WeakMap());
|
|
81
|
+
let r = t.get(n);
|
|
82
|
+
return r || t.set(n, r = { fields: /* @__PURE__ */ new Set(), ac: null }), r;
|
|
83
|
+
}
|
|
84
|
+
const P = (e) => {
|
|
85
|
+
for (const n of e.values()) for (const t of n) if (t.severity !== "warning") return !0;
|
|
86
|
+
return !1;
|
|
87
|
+
};
|
|
88
|
+
function T(e) {
|
|
89
|
+
return e.aborted ? Promise.resolve() : new Promise((n) => {
|
|
90
|
+
e.addEventListener("abort", () => n(), { once: !0 });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function C(e, n, t) {
|
|
94
|
+
const r = L(e, n);
|
|
95
|
+
r.ac?.abort();
|
|
96
|
+
const o = new AbortController();
|
|
97
|
+
r.ac = o;
|
|
98
|
+
const a = {
|
|
99
|
+
model: e,
|
|
100
|
+
errors: /* @__PURE__ */ new Map(),
|
|
101
|
+
pending: [],
|
|
102
|
+
whenStack: [],
|
|
103
|
+
signal: o.signal
|
|
104
|
+
};
|
|
105
|
+
if (E(a, () => n({ model: e })), a.pending.length && await Promise.race([Promise.all(a.pending), T(o.signal)]), o.signal.aborted) return !1;
|
|
106
|
+
const i = new Set(a.errors.keys());
|
|
107
|
+
for (const s of r.fields) i.has(s) || v(s)?.setErrors([]);
|
|
108
|
+
for (const s of i) v(s)?.setErrors(a.errors.get(s) ?? []);
|
|
109
|
+
if (t?.touch) for (const s of i) v(s)?.markAsTouched();
|
|
110
|
+
return r.fields = i, !P(a.errors);
|
|
111
|
+
}
|
|
112
|
+
function G(e, n, t = {}) {
|
|
113
|
+
const { strategy: r = "submit", debounce: o = 0, liveAfterSubmit: a = "change" } = t, i = A(!1);
|
|
114
|
+
let s = 0, y = !1, f, c;
|
|
115
|
+
const w = async (l) => {
|
|
116
|
+
s++, i.value = !0;
|
|
117
|
+
try {
|
|
118
|
+
return await C(e, n, { touch: l });
|
|
119
|
+
} finally {
|
|
120
|
+
--s === 0 && (i.value = !1);
|
|
121
|
+
}
|
|
122
|
+
}, p = () => {
|
|
123
|
+
w(!1);
|
|
124
|
+
}, F = () => {
|
|
125
|
+
if (!o) {
|
|
126
|
+
p();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
c && clearTimeout(c), c = setTimeout(p, o);
|
|
130
|
+
}, k = (l, d) => {
|
|
131
|
+
let S = !0;
|
|
132
|
+
return M(() => {
|
|
133
|
+
if (W(e, l), S) {
|
|
134
|
+
S = !1;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
r === "afterFirstSubmit" && !y || d();
|
|
138
|
+
});
|
|
139
|
+
}, h = {
|
|
140
|
+
async validate() {
|
|
141
|
+
return y = !0, w(!0);
|
|
142
|
+
},
|
|
143
|
+
start() {
|
|
144
|
+
if (f) return () => h.dispose();
|
|
145
|
+
const l = r === "afterFirstSubmit" ? a : r;
|
|
146
|
+
return l === "change" ? f = k((d) => void d.value, F) : l === "blur" && (f = k((d) => void v(d)?.touched.value, p)), () => h.dispose();
|
|
147
|
+
},
|
|
148
|
+
dispose() {
|
|
149
|
+
c && (clearTimeout(c), c = void 0), f?.(), f = void 0;
|
|
150
|
+
},
|
|
151
|
+
get isValidating() {
|
|
152
|
+
return i.value;
|
|
153
|
+
},
|
|
154
|
+
get validating() {
|
|
155
|
+
return i;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return h;
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
N as a,
|
|
162
|
+
R as b,
|
|
163
|
+
_ as c,
|
|
164
|
+
j as d,
|
|
165
|
+
$ as e,
|
|
166
|
+
z as f,
|
|
167
|
+
C as g,
|
|
168
|
+
G as h,
|
|
169
|
+
D as v
|
|
170
|
+
};
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './form/validation
|
|
1
|
+
export * from './form/validation/index'
|
|
2
2
|
export {}
|
package/dist/validation.js
CHANGED
|
@@ -1,167 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as E } from "./form-model-DhW2HZOB.js";
|
|
3
|
-
import { g as p } from "./signal-node-registry-tiwel-TV.js";
|
|
4
|
-
function B(e, n, t = {}) {
|
|
5
|
-
const { strategy: r = "submit", debounce: o = 0, liveAfterSubmit: i = "change" } = t, s = A(!1);
|
|
6
|
-
let a = 0, c = !1, d, l;
|
|
7
|
-
const w = async (u) => {
|
|
8
|
-
a++, s.value = !0;
|
|
9
|
-
try {
|
|
10
|
-
return await W(e, n, { touch: u });
|
|
11
|
-
} finally {
|
|
12
|
-
--a === 0 && (s.value = !1);
|
|
13
|
-
}
|
|
14
|
-
}, h = () => {
|
|
15
|
-
w(!1);
|
|
16
|
-
}, F = () => {
|
|
17
|
-
if (!o) {
|
|
18
|
-
h();
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
l && clearTimeout(l), l = setTimeout(h, o);
|
|
22
|
-
}, k = (u, g) => {
|
|
23
|
-
let S = !0;
|
|
24
|
-
return M(() => {
|
|
25
|
-
if (E(e, u), S) {
|
|
26
|
-
S = !1;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
r === "afterFirstSubmit" && !c || g();
|
|
30
|
-
});
|
|
31
|
-
}, m = {
|
|
32
|
-
async validate() {
|
|
33
|
-
return c = !0, w(!0);
|
|
34
|
-
},
|
|
35
|
-
start() {
|
|
36
|
-
if (d) return () => m.dispose();
|
|
37
|
-
const u = r === "afterFirstSubmit" ? i : r;
|
|
38
|
-
return u === "change" ? d = k((g) => void g.value, F) : u === "blur" && (d = k((g) => void p(g)?.touched.value, h)), () => m.dispose();
|
|
39
|
-
},
|
|
40
|
-
dispose() {
|
|
41
|
-
l && (clearTimeout(l), l = void 0), d?.(), d = void 0;
|
|
42
|
-
},
|
|
43
|
-
get isValidating() {
|
|
44
|
-
return s.value;
|
|
45
|
-
},
|
|
46
|
-
get validating() {
|
|
47
|
-
return s;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
return m;
|
|
51
|
-
}
|
|
52
|
-
let v = null;
|
|
53
|
-
function f(e) {
|
|
54
|
-
if (!v)
|
|
55
|
-
throw new Error(
|
|
56
|
-
`[@reformer/core/validation] "${e}" вызван вне схемы валидации — операторы валидации можно вызывать только внутри прогона validateModel(...) (напрямую или через apply/each).`
|
|
57
|
-
);
|
|
58
|
-
return v;
|
|
59
|
-
}
|
|
60
|
-
function b(e, n) {
|
|
61
|
-
let t = e.errors.get(n);
|
|
62
|
-
return t || e.errors.set(n, t = []), t;
|
|
63
|
-
}
|
|
64
|
-
const y = (e) => e.whenStack.every((n) => n());
|
|
65
|
-
function D(e, n) {
|
|
66
|
-
const t = f("validate"), r = b(t, e);
|
|
67
|
-
if (!y(t)) return;
|
|
68
|
-
const o = e.peek();
|
|
69
|
-
for (const i of n) {
|
|
70
|
-
const s = i(o, t.model, t.model);
|
|
71
|
-
s && r.push(s);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function N(e, n) {
|
|
75
|
-
const t = f("validateAsync"), r = b(t, e);
|
|
76
|
-
if (!y(t)) return;
|
|
77
|
-
const o = e.peek(), i = t.signal;
|
|
78
|
-
for (const s of n)
|
|
79
|
-
t.pending.push(
|
|
80
|
-
s(o, { signal: i }).then(
|
|
81
|
-
(a) => {
|
|
82
|
-
a && !i.aborted && r.push(a);
|
|
83
|
-
},
|
|
84
|
-
() => {
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
function R(e, n) {
|
|
90
|
-
const t = f("validateWhen");
|
|
91
|
-
t.whenStack.push(e);
|
|
92
|
-
try {
|
|
93
|
-
n();
|
|
94
|
-
} finally {
|
|
95
|
-
t.whenStack.pop();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function _(e, n) {
|
|
99
|
-
const t = f("cross"), r = b(t, e);
|
|
100
|
-
if (!y(t)) return;
|
|
101
|
-
const o = n(t.model.get());
|
|
102
|
-
o && r.push(o);
|
|
103
|
-
}
|
|
104
|
-
function $(e, n) {
|
|
105
|
-
f("each");
|
|
106
|
-
const t = e.length;
|
|
107
|
-
for (let r = 0; r < t; r++) n(e.at(r));
|
|
108
|
-
}
|
|
109
|
-
function j(...e) {
|
|
110
|
-
const t = f("apply").model;
|
|
111
|
-
for (const r of e) r({ model: t });
|
|
112
|
-
}
|
|
113
|
-
function z(e) {
|
|
114
|
-
return e;
|
|
115
|
-
}
|
|
116
|
-
const x = /* @__PURE__ */ new WeakMap();
|
|
117
|
-
function L(e, n) {
|
|
118
|
-
let t = x.get(e);
|
|
119
|
-
t || x.set(e, t = /* @__PURE__ */ new WeakMap());
|
|
120
|
-
let r = t.get(n);
|
|
121
|
-
return r || t.set(n, r = { fields: /* @__PURE__ */ new Set(), ac: null }), r;
|
|
122
|
-
}
|
|
123
|
-
const P = (e) => {
|
|
124
|
-
for (const n of e.values()) for (const t of n) if (t.severity !== "warning") return !0;
|
|
125
|
-
return !1;
|
|
126
|
-
};
|
|
127
|
-
function T(e) {
|
|
128
|
-
return e.aborted ? Promise.resolve() : new Promise((n) => {
|
|
129
|
-
e.addEventListener("abort", () => n(), { once: !0 });
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
async function W(e, n, t) {
|
|
133
|
-
const r = L(e, n);
|
|
134
|
-
r.ac?.abort();
|
|
135
|
-
const o = new AbortController();
|
|
136
|
-
r.ac = o;
|
|
137
|
-
const i = {
|
|
138
|
-
model: e,
|
|
139
|
-
errors: /* @__PURE__ */ new Map(),
|
|
140
|
-
pending: [],
|
|
141
|
-
whenStack: [],
|
|
142
|
-
signal: o.signal
|
|
143
|
-
}, s = v;
|
|
144
|
-
v = i;
|
|
145
|
-
try {
|
|
146
|
-
n({ model: e });
|
|
147
|
-
} finally {
|
|
148
|
-
v = s;
|
|
149
|
-
}
|
|
150
|
-
if (i.pending.length && await Promise.race([Promise.all(i.pending), T(o.signal)]), o.signal.aborted) return !1;
|
|
151
|
-
const a = new Set(i.errors.keys());
|
|
152
|
-
for (const c of r.fields) a.has(c) || p(c)?.setErrors([]);
|
|
153
|
-
for (const c of a) p(c)?.setErrors(i.errors.get(c) ?? []);
|
|
154
|
-
if (t?.touch) for (const c of a) p(c)?.markAsTouched();
|
|
155
|
-
return r.fields = a, !P(i.errors);
|
|
156
|
-
}
|
|
1
|
+
import { d as s, h as d, c as i, f as l, e as t, v as o, a as c, g as n, b as r } from "./strategy-DA3JwxsR.js";
|
|
157
2
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
3
|
+
s as apply,
|
|
4
|
+
d as createFormValidation,
|
|
5
|
+
i as cross,
|
|
6
|
+
l as defineValidationSchema,
|
|
7
|
+
t as each,
|
|
8
|
+
o as validate,
|
|
9
|
+
c as validateAsync,
|
|
10
|
+
n as validateModel,
|
|
11
|
+
r as validateWhen
|
|
167
12
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/email'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/future-date'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/integer'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/is-date'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/is-number'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max-age'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max-date'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max-length'
|
|
2
2
|
export {}
|
package/dist/validators/max.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/min-age'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/min-date'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/min-length'
|
|
2
2
|
export {}
|
package/dist/validators/min.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/min'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/multiple-of'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/non-negative'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/non-zero'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/past-date'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/pattern'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/phone'
|
|
2
2
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/required'
|
|
2
2
|
export {}
|
package/dist/validators/url.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/url'
|
|
2
2
|
export {}
|
package/dist/validators.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './form/validators'
|
|
1
|
+
export * from './form/validators/index'
|
|
2
2
|
export {}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { createCoreForm, createModel, useFormBundle, type FormProxy } from '@reformer/core';
|
|
19
19
|
import { defineValidationSchema, validate, validateModel } from '@reformer/core/validation';
|
|
20
20
|
import { required, email } from '@reformer/core/validators';
|
|
21
|
-
import { FormField,
|
|
21
|
+
import { FormField, InputField, Button } from '@reformer/ui-kit';
|
|
22
22
|
|
|
23
23
|
// 1. Define form type as `type` alias (not `interface` — see Recipe 2)
|
|
24
24
|
type ContactForm = {
|
|
@@ -34,12 +34,12 @@ const model = createModel<ContactForm>({ name: '', email: '' });
|
|
|
34
34
|
const schema = {
|
|
35
35
|
name: {
|
|
36
36
|
value: model.$.name,
|
|
37
|
-
component:
|
|
37
|
+
component: InputField,
|
|
38
38
|
componentProps: { label: 'Name', placeholder: 'Your name' },
|
|
39
39
|
},
|
|
40
40
|
email: {
|
|
41
41
|
value: model.$.email,
|
|
42
|
-
component:
|
|
42
|
+
component: InputField,
|
|
43
43
|
componentProps: { label: 'Email', type: 'email' },
|
|
44
44
|
},
|
|
45
45
|
};
|
|
@@ -113,13 +113,13 @@ const model = createModel<MyForm>({ properties: [] });
|
|
|
113
113
|
const propertyItem = (item: FormModel<PropertyItem>) => ({
|
|
114
114
|
type: {
|
|
115
115
|
value: item.$.type,
|
|
116
|
-
component:
|
|
116
|
+
component: SelectField,
|
|
117
117
|
componentProps: { label: 'Тип', options: [/* ... */] },
|
|
118
118
|
},
|
|
119
|
-
description: { value: item.$.description, component:
|
|
119
|
+
description: { value: item.$.description, component: TextareaField, componentProps: { label: 'Описание' } },
|
|
120
120
|
estimatedValue: {
|
|
121
121
|
value: item.$.estimatedValue,
|
|
122
|
-
component:
|
|
122
|
+
component: InputField,
|
|
123
123
|
componentProps: { label: 'Стоимость', type: 'number' },
|
|
124
124
|
},
|
|
125
125
|
});
|
|
@@ -72,9 +72,9 @@ const model = createModel<Loan>({ email: '', age: 0, amount: 0 });
|
|
|
72
72
|
const form = createForm({
|
|
73
73
|
model,
|
|
74
74
|
schema: {
|
|
75
|
-
email: { value: model.$.email, component:
|
|
76
|
-
age: { value: model.$.age, component:
|
|
77
|
-
amount: { value: model.$.amount, component:
|
|
75
|
+
email: { value: model.$.email, component: InputField },
|
|
76
|
+
age: { value: model.$.age, component: InputField },
|
|
77
|
+
amount: { value: model.$.amount, component: InputField },
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -93,7 +93,7 @@ computeFrom([model.$.price, model.$.quantity], model.$.total, (price, qty) => pr
|
|
|
93
93
|
```typescript
|
|
94
94
|
// ❌ WRONG - дерево { value, validators } и позиционная строка удалены
|
|
95
95
|
const schema = {
|
|
96
|
-
email: { value: model.$.email, component:
|
|
96
|
+
email: { value: model.$.email, component: InputField, validators: [required(), email()] },
|
|
97
97
|
};
|
|
98
98
|
validate(path.email, required(), 'Email is required'); // старая сигнатура validate() — удалена
|
|
99
99
|
|
|
@@ -10,7 +10,7 @@ layout-схеме НЕТ — правила живут в отдельной с
|
|
|
10
10
|
```typescript
|
|
11
11
|
{
|
|
12
12
|
value: model.$.fieldName, // сигнал модели (PathAwareSignal) — обязателен
|
|
13
|
-
component:
|
|
13
|
+
component: InputField, // React-компонент
|
|
14
14
|
componentProps?: object, // пропсы (label, placeholder, options, type, ...)
|
|
15
15
|
disabled?: boolean,
|
|
16
16
|
updateOn?: 'change' | 'blur' | 'submit',
|
|
@@ -28,7 +28,7 @@ layout-схеме НЕТ — правила живут в отдельной с
|
|
|
28
28
|
import { createModel, createForm } from '@reformer/core';
|
|
29
29
|
import { defineValidationSchema, validate } from '@reformer/core/validation';
|
|
30
30
|
import { required } from '@reformer/core/validators';
|
|
31
|
-
import {
|
|
31
|
+
import { InputField, SelectField, CheckboxField } from '@reformer/ui-kit';
|
|
32
32
|
|
|
33
33
|
const model = createModel<MyForm>({ name: '', age: null, agree: false, status: 'active' });
|
|
34
34
|
|
|
@@ -40,22 +40,22 @@ const myValidation = defineValidationSchema<MyForm>(({ model }) => {
|
|
|
40
40
|
const schema = {
|
|
41
41
|
name: {
|
|
42
42
|
value: model.$.name,
|
|
43
|
-
component:
|
|
43
|
+
component: InputField,
|
|
44
44
|
componentProps: { label: 'Name', placeholder: 'Enter name' },
|
|
45
45
|
},
|
|
46
46
|
age: {
|
|
47
47
|
value: model.$.age,
|
|
48
|
-
component:
|
|
48
|
+
component: InputField,
|
|
49
49
|
componentProps: { type: 'number', label: 'Age' },
|
|
50
50
|
},
|
|
51
51
|
agree: {
|
|
52
52
|
value: model.$.agree,
|
|
53
|
-
component:
|
|
53
|
+
component: CheckboxField,
|
|
54
54
|
componentProps: { label: 'I agree to terms' },
|
|
55
55
|
},
|
|
56
56
|
status: {
|
|
57
57
|
value: model.$.status,
|
|
58
|
-
component:
|
|
58
|
+
component: SelectField,
|
|
59
59
|
componentProps: {
|
|
60
60
|
label: 'Status',
|
|
61
61
|
options: [
|
|
@@ -79,9 +79,9 @@ const form = createForm<MyForm>({ model, schema });
|
|
|
79
79
|
import type { FormModel } from '@reformer/core';
|
|
80
80
|
|
|
81
81
|
const addressNodes = (m: FormModel<Address>) => ({
|
|
82
|
-
street: { value: m.$.street, component:
|
|
83
|
-
city: { value: m.$.city, component:
|
|
84
|
-
zip: { value: m.$.zip, component:
|
|
82
|
+
street: { value: m.$.street, component: InputField, componentProps: { label: 'Street' } },
|
|
83
|
+
city: { value: m.$.city, component: InputField, componentProps: { label: 'City' } },
|
|
84
|
+
zip: { value: m.$.zip, component: InputField, componentProps: { label: 'ZIP' } },
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
const schema = {
|
|
@@ -98,8 +98,8 @@ const schema = {
|
|
|
98
98
|
import type { FormModel } from '@reformer/core';
|
|
99
99
|
|
|
100
100
|
const itemSchema = (item: FormModel<Item>) => ({
|
|
101
|
-
id: { value: item.$.id, component:
|
|
102
|
-
name: { value: item.$.name, component:
|
|
101
|
+
id: { value: item.$.id, component: InputField, componentProps: { label: 'ID' } },
|
|
102
|
+
name: { value: item.$.name, component: InputField, componentProps: { label: 'Name' } },
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
const schema = {
|
package/docs/llms/10-arrays.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
```typescript
|
|
9
9
|
import { createModel, createForm, type FormModel } from '@reformer/core';
|
|
10
|
-
import {
|
|
10
|
+
import { InputField } from '@reformer/ui-kit';
|
|
11
11
|
|
|
12
12
|
type Item = { id: string; name: string; price: number };
|
|
13
13
|
type MyForm = { items: Item[] };
|
|
@@ -16,9 +16,9 @@ const model = createModel<MyForm>({ items: [] });
|
|
|
16
16
|
|
|
17
17
|
// под-схема одного элемента (item.$.field — сигнал под-модели)
|
|
18
18
|
const itemSchema = (item: FormModel<Item>) => ({
|
|
19
|
-
id: { value: item.$.id, component:
|
|
20
|
-
name: { value: item.$.name, component:
|
|
21
|
-
price: { value: item.$.price, component:
|
|
19
|
+
id: { value: item.$.id, component: InputField },
|
|
20
|
+
name: { value: item.$.name, component: InputField },
|
|
21
|
+
price: { value: item.$.price, component: InputField, componentProps: { type: 'number' } },
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const schema = {
|
|
@@ -71,7 +71,7 @@ import { revalidateWhen, type ValidationError } from '@reformer/core';
|
|
|
71
71
|
// ❌ старое (УДАЛЕНО): дерево { value, validators }, ModelValidator (value, scope, root), validateFormModel
|
|
72
72
|
const legacyRule: ModelValidator<number, unknown, Form> = (_value, _scope, root) =>
|
|
73
73
|
root.field1 > root.field2 ? { code: 'error', message: 'Invalid' } : null;
|
|
74
|
-
const legacySchema = { field1: { value: model.$.field1, component:
|
|
74
|
+
const legacySchema = { field1: { value: model.$.field1, component: InputField, validators: [legacyRule] } };
|
|
75
75
|
validateFormModel(model, legacySchema);
|
|
76
76
|
|
|
77
77
|
// ✅ новое: cross-правило — обычная функция над снапшотом (model.get()), не читает scope/root
|