@reformer/core 10.2.0 → 11.0.0-beta.10
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/README.md +90 -68
- package/dist/behaviors-value-D05z3my6.js +109 -0
- package/dist/behaviors.d.ts +1 -1
- package/dist/behaviors.js +376 -211
- package/dist/create-model-DPSG3I0O.js +30 -0
- package/dist/date-utils-90-qZbse.js +43 -0
- package/dist/en-HP8XEych.js +44 -0
- package/dist/form/aggregate-signals.d.ts +21 -63
- package/dist/form/behaviors/collections.d.ts +84 -0
- package/dist/form/behaviors/context.d.ts +56 -0
- package/dist/form/behaviors/index.d.ts +30 -0
- package/dist/form/behaviors/internals.d.ts +41 -0
- package/dist/form/{behaviors-node.d.ts → behaviors/node.d.ts} +28 -5
- package/dist/form/behaviors/operators.d.ts +59 -0
- package/dist/form/behaviors/schema-operators.d.ts +83 -0
- package/dist/form/behaviors/types.d.ts +37 -0
- package/dist/form/create-form.d.ts +59 -70
- package/dist/form/flow/flow.d.ts +87 -0
- package/dist/form/form-bundle.d.ts +153 -0
- package/dist/form/form-level.d.ts +121 -0
- package/dist/form/form-proxy-builder.d.ts +6 -22
- package/dist/form/index.d.ts +23 -27
- package/dist/form/nodes/form-array-node.d.ts +100 -0
- package/dist/form/nodes/form-control-node.d.ts +73 -0
- package/dist/form/nodes/form-group-node.d.ts +66 -0
- package/dist/form/nodes/node-kind.d.ts +29 -0
- package/dist/form/nodes/state/availability.d.ts +6 -0
- package/dist/form/nodes/state/component.d.ts +6 -0
- package/dist/form/nodes/state/index.d.ts +12 -0
- package/dist/form/nodes/state/interaction.d.ts +13 -0
- package/dist/form/nodes/state/issues.d.ts +9 -0
- package/dist/form/nodes/state/pending.d.ts +6 -0
- package/dist/form/schema/compile.d.ts +59 -0
- package/dist/form/schema/compiled.d.ts +143 -0
- package/dist/form/schema/row-key.d.ts +11 -0
- package/dist/form/schema-controller.d.ts +159 -0
- package/dist/form/schema-subtree.d.ts +28 -0
- package/dist/form/signal-node-registry.d.ts +27 -22
- package/dist/form/submission.d.ts +93 -0
- package/dist/form/type-guards.d.ts +14 -73
- package/dist/form/types/contracts.d.ts +21 -91
- package/dist/form/types/field-config.d.ts +27 -0
- package/dist/form/types/index.d.ts +5 -91
- package/dist/form/types/nodes.d.ts +159 -0
- package/dist/form/types/schema-node.d.ts +148 -50
- package/dist/form/types/validation-schema.d.ts +24 -41
- package/dist/form/validation/context.d.ts +67 -0
- package/dist/form/validation/index.d.ts +24 -28
- package/dist/form/validation/operators.d.ts +101 -0
- package/dist/form/validation/run.d.ts +120 -0
- package/dist/form/validation/strategy.d.ts +89 -0
- package/dist/form/validation/types.d.ts +83 -0
- package/dist/form/validators/date-utils.d.ts +42 -0
- package/dist/form/validators/email.d.ts +23 -0
- package/dist/form/{validation/validators → validators}/file-type.d.ts +10 -10
- package/dist/form/{validation/validators → validators}/file-utils.d.ts +3 -2
- package/dist/form/validators/future-date.d.ts +23 -0
- package/dist/form/{validation/validators → validators}/index.d.ts +7 -4
- package/dist/form/validators/integer.d.ts +22 -0
- package/dist/form/validators/is-date.d.ts +24 -0
- package/dist/form/validators/is-number.d.ts +25 -0
- package/dist/form/validators/max-age.d.ts +28 -0
- package/dist/form/validators/max-date.d.ts +25 -0
- package/dist/form/{validation/validators → validators}/max-file-size.d.ts +10 -10
- package/dist/form/validators/max-files.d.ts +26 -0
- package/dist/form/validators/max-length.d.ts +33 -0
- package/dist/form/validators/max-total-file-size.d.ts +26 -0
- package/dist/form/validators/max.d.ts +26 -0
- package/dist/form/validators/min-age.d.ts +27 -0
- package/dist/form/validators/min-date.d.ts +25 -0
- package/dist/form/{validation/validators → validators}/min-file-size.d.ts +10 -10
- package/dist/form/validators/min-files.d.ts +27 -0
- package/dist/form/validators/min-length.d.ts +33 -0
- package/dist/form/validators/min.d.ts +26 -0
- package/dist/form/validators/multiple-of.d.ts +25 -0
- package/dist/form/validators/non-negative.d.ts +22 -0
- package/dist/form/validators/non-zero.d.ts +22 -0
- package/dist/form/validators/past-date.d.ts +23 -0
- package/dist/form/validators/pattern.d.ts +26 -0
- package/dist/form/{validation/validators → validators}/phone.d.ts +11 -11
- package/dist/form/validators/required.d.ts +29 -0
- package/dist/form/validators/url.d.ts +45 -0
- package/dist/form/validators/validation-issue.d.ts +8 -0
- package/dist/i18n/descriptor.d.ts +54 -0
- package/dist/i18n/en.json.d.ts +49 -0
- package/dist/i18n/loader.d.ts +71 -0
- package/dist/i18n/locale-store.d.ts +46 -0
- package/dist/i18n/locale.d.ts +90 -0
- package/dist/i18n/message-format.d.ts +136 -0
- package/dist/i18n/resolve-localized.d.ts +17 -0
- package/dist/i18n/ru.json.d.ts +49 -0
- package/dist/i18n/translator.d.ts +61 -0
- package/dist/i18n/validation-message.d.ts +53 -0
- package/dist/i18n.d.ts +26 -0
- package/dist/i18n.js +86 -0
- package/dist/index.d.ts +18 -6
- package/dist/index.js +932 -2779
- package/dist/loader-BWkigpVe.js +52 -0
- package/dist/locale/en.d.ts +2 -0
- package/dist/locale/en.js +5 -0
- package/dist/locale/en.json +45 -0
- package/dist/locale/index.d.ts +18 -0
- package/dist/locale/ru.d.ts +2 -0
- package/dist/locale/ru.js +44 -0
- package/dist/locale/ru.json +45 -0
- package/dist/locale-CG54AU2Q.js +219 -0
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +9 -0
- package/dist/{state → model}/behaviors-value.d.ts +24 -6
- package/dist/{state/form-model.d.ts → model/create-model.d.ts} +18 -4
- package/dist/{state → model}/derived-registry.d.ts +1 -1
- package/dist/model/index.d.ts +42 -0
- package/dist/model/model-nodes.d.ts +190 -0
- package/dist/model/model-signals-proxy.d.ts +63 -0
- package/dist/model/model-value-proxy.d.ts +84 -0
- package/dist/{state → model}/safe-effect.d.ts +50 -2
- package/dist/model/types.d.ts +239 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.js +27 -0
- package/dist/node-kind-C-r6ZMdo.js +15 -0
- package/dist/platforms/react/field-binding/field-adapter.d.ts +87 -0
- package/dist/platforms/react/field-binding/field-handle.d.ts +53 -0
- package/dist/platforms/react/form-bundle-context.d.ts +27 -0
- package/dist/{form → platforms/react}/hooks/types.d.ts +60 -38
- package/dist/platforms/react/hooks/use-form-bundle.d.ts +41 -0
- package/dist/platforms/react/hooks/use-form-flow.d.ts +40 -0
- package/dist/{form → platforms/react}/hooks/use-form-validation.d.ts +13 -7
- package/dist/{form → platforms/react}/hooks/useArrayLength.d.ts +6 -6
- package/dist/{form → platforms/react}/hooks/useFormControl.d.ts +7 -9
- package/dist/{form → platforms/react}/hooks/useFormControlValue.d.ts +18 -18
- package/dist/{form → platforms/react}/hooks/useSignalSubscription.d.ts +9 -1
- package/dist/platforms/react/i18n/context.d.ts +18 -0
- package/dist/platforms/react/i18n/hooks.d.ts +65 -0
- package/dist/platforms/react/i18n/provider.d.ts +59 -0
- package/dist/platforms/react/index.d.ts +30 -0
- package/dist/react.d.ts +22 -0
- package/dist/react.js +505 -0
- package/dist/runtime-token.d.ts +22 -0
- package/dist/safe-effect-BazLOv1g.js +669 -0
- package/dist/schema-controller-CpiO2JoK.js +143 -0
- package/dist/signals.d.ts +15 -9
- package/dist/signals.js +11 -6
- package/dist/strategy-DzvnsWLh.js +375 -0
- package/dist/type-guards-D-N_5Ddh.js +19 -0
- package/dist/validation-issue-B9mjI8jz.js +7 -0
- package/dist/validation-message-Ced9MGxs.js +194 -0
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +11 -165
- package/dist/validators/email.d.ts +1 -1
- package/dist/validators/email.js +5 -8
- package/dist/validators/future-date.d.ts +1 -1
- package/dist/validators/future-date.js +10 -13
- package/dist/validators/integer.d.ts +1 -1
- package/dist/validators/integer.js +4 -7
- package/dist/validators/is-date.d.ts +1 -1
- package/dist/validators/is-date.js +5 -8
- package/dist/validators/is-number.d.ts +1 -1
- package/dist/validators/is-number.js +4 -7
- package/dist/validators/max-age.d.ts +1 -1
- package/dist/validators/max-age.js +8 -12
- package/dist/validators/max-date.d.ts +1 -1
- package/dist/validators/max-date.js +10 -13
- package/dist/validators/max-length.d.ts +1 -1
- package/dist/validators/max-length.js +7 -10
- package/dist/validators/max.d.ts +1 -1
- package/dist/validators/max.js +4 -7
- package/dist/validators/min-age.d.ts +1 -1
- package/dist/validators/min-age.js +10 -11
- package/dist/validators/min-date.d.ts +1 -1
- package/dist/validators/min-date.js +8 -11
- package/dist/validators/min-length.d.ts +1 -1
- package/dist/validators/min-length.js +4 -7
- package/dist/validators/min.d.ts +1 -1
- package/dist/validators/min.js +4 -7
- package/dist/validators/multiple-of.d.ts +1 -1
- package/dist/validators/multiple-of.js +11 -10
- package/dist/validators/non-negative.d.ts +1 -1
- package/dist/validators/non-negative.js +2 -5
- package/dist/validators/non-zero.d.ts +1 -1
- package/dist/validators/non-zero.js +4 -7
- package/dist/validators/past-date.d.ts +1 -1
- package/dist/validators/past-date.js +10 -13
- package/dist/validators/pattern.d.ts +1 -1
- package/dist/validators/pattern.js +5 -8
- package/dist/validators/phone.d.ts +1 -1
- package/dist/validators/phone.js +10 -11
- package/dist/validators/required.d.ts +1 -1
- package/dist/validators/required.js +4 -7
- package/dist/validators/url.d.ts +1 -1
- package/dist/validators/url.js +48 -17
- package/dist/validators.d.ts +1 -5
- package/dist/validators.js +98 -154
- package/docs/llms/01-api-reference.md +89 -0
- package/docs/llms/02-quick-start.md +181 -0
- package/docs/llms/03-api-signatures.md +494 -0
- package/docs/llms/04-common-patterns.md +204 -0
- package/docs/llms/05-common-mistakes.md +192 -0
- package/docs/llms/06-troubleshooting.md +16 -0
- package/docs/llms/07-complete-import.md +130 -0
- package/docs/llms/08-form-types.md +54 -0
- package/docs/llms/09-formschema.md +191 -0
- package/docs/llms/10-arrays.md +241 -0
- package/docs/llms/11-async-watchfield.md +53 -0
- package/docs/llms/12-array-cleanup.md +31 -0
- package/docs/llms/13-multi-step.md +162 -0
- package/docs/llms/14-extended-mistakes.md +101 -0
- package/docs/llms/15-project-structure.md +279 -0
- package/docs/llms/16-ui-components.md +229 -0
- package/docs/llms/17-nonexistent-api.md +278 -0
- package/docs/llms/18-conditional-fields.md +222 -0
- package/docs/llms/19-reading-values.md +100 -0
- package/docs/llms/20-compute-vs-watch.md +153 -0
- package/docs/llms/21-array-operations.md +163 -0
- package/docs/llms/22-cycle-detection.md +86 -0
- package/docs/llms/23-copy-from.md +141 -0
- package/docs/llms/24-sync-fields.md +115 -0
- package/docs/llms/25-reset-when.md +122 -0
- package/docs/llms/26-transform-value.md +136 -0
- package/docs/llms/27-revalidate-when.md +133 -0
- package/docs/llms/28-submit-and-reset.md +409 -0
- package/docs/llms/29-async-preload.md +203 -0
- package/docs/llms/30-type-safety-recipes.md +213 -0
- package/docs/llms/31-async-validator-debounce.md +178 -0
- package/docs/llms/32-async-options-loading.md +108 -0
- package/docs/llms/33-validation-strategy.md +305 -0
- package/docs/llms/34-i18n.md +298 -0
- package/docs/llms/35-unified-contract.md +309 -0
- package/docs/llms/36-issue-messages.md +284 -0
- package/docs/llms/37-compiled-schema.md +332 -0
- package/docs/llms/38-form-flow.md +396 -0
- package/llms-index.json +1 -0
- package/llms.txt +10014 -3826
- package/package.json +77 -15
- package/dist/behaviors-node-DGEFMTQu.js +0 -18
- package/dist/behaviors-value-C7dSEhCc.js +0 -134
- package/dist/date-utils-dTT_x_Be.js +0 -31
- package/dist/derived-registry-CluZCQ7U.js +0 -16
- package/dist/form/behaviors.d.ts +0 -133
- package/dist/form/error-handler.d.ts +0 -166
- package/dist/form/factories/index.d.ts +0 -6
- package/dist/form/factories/node-factory.d.ts +0 -188
- package/dist/form/form-submitter.d.ts +0 -125
- package/dist/form/nodes/array-node.d.ts +0 -360
- package/dist/form/nodes/field-node.d.ts +0 -294
- package/dist/form/nodes/form-node.d.ts +0 -340
- package/dist/form/nodes/group-node.d.ts +0 -288
- package/dist/form/nodes/model-array-node.d.ts +0 -121
- package/dist/form/status-machine.d.ts +0 -153
- package/dist/form/types/deep-schema.d.ts +0 -116
- package/dist/form/types/form-proxy.d.ts +0 -141
- package/dist/form/unique-id.d.ts +0 -53
- package/dist/form/validation/validators/date-utils.d.ts +0 -30
- package/dist/form/validation/validators/email.d.ts +0 -23
- package/dist/form/validation/validators/future-date.d.ts +0 -23
- package/dist/form/validation/validators/integer.d.ts +0 -22
- package/dist/form/validation/validators/is-date.d.ts +0 -23
- package/dist/form/validation/validators/is-number.d.ts +0 -24
- package/dist/form/validation/validators/max-age.d.ts +0 -25
- package/dist/form/validation/validators/max-date.d.ts +0 -25
- package/dist/form/validation/validators/max-files.d.ts +0 -26
- package/dist/form/validation/validators/max-length.d.ts +0 -27
- package/dist/form/validation/validators/max-total-file-size.d.ts +0 -26
- package/dist/form/validation/validators/max.d.ts +0 -25
- package/dist/form/validation/validators/min-age.d.ts +0 -25
- package/dist/form/validation/validators/min-date.d.ts +0 -25
- package/dist/form/validation/validators/min-files.d.ts +0 -26
- package/dist/form/validation/validators/min-length.d.ts +0 -27
- package/dist/form/validation/validators/min.d.ts +0 -25
- package/dist/form/validation/validators/multiple-of.d.ts +0 -24
- package/dist/form/validation/validators/non-negative.d.ts +0 -22
- package/dist/form/validation/validators/non-zero.d.ts +0 -22
- package/dist/form/validation/validators/past-date.d.ts +0 -23
- package/dist/form/validation/validators/pattern.d.ts +0 -33
- package/dist/form/validation/validators/required.d.ts +0 -32
- package/dist/form/validation/validators/url.d.ts +0 -43
- package/dist/form/validation-schema.d.ts +0 -106
- package/dist/form/validation-strategy.d.ts +0 -55
- package/dist/form/validators.d.ts +0 -6
- package/dist/form-model-DYCzGGKF.js +0 -286
- package/dist/state/index.d.ts +0 -31
- package/dist/state/subscription-manager.d.ts +0 -180
- package/dist/state/types.d.ts +0 -144
- package/dist/state.d.ts +0 -2
- package/dist/state.js +0 -21
- package/dist/subscription-manager-705bls97.js +0 -171
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { m as $ } from "./en-HP8XEych.js";
|
|
2
|
+
import { h as p, i as g, f as E, p as D, t as L } from "./locale-CG54AU2Q.js";
|
|
3
|
+
function R(t, n, e = {}) {
|
|
4
|
+
const r = /* @__PURE__ */ new Set(), o = t.peek?.(n);
|
|
5
|
+
let a = {
|
|
6
|
+
lang: n,
|
|
7
|
+
locale: o ?? e.previous ?? null,
|
|
8
|
+
pending: o === void 0,
|
|
9
|
+
error: void 0
|
|
10
|
+
}, u = null, s = o === void 0 ? null : n;
|
|
11
|
+
const f = (i) => {
|
|
12
|
+
a = i;
|
|
13
|
+
for (const l of [...r]) l();
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
getState: () => a,
|
|
17
|
+
subscribe(i) {
|
|
18
|
+
return r.add(i), () => {
|
|
19
|
+
r.delete(i);
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
setLang(i) {
|
|
23
|
+
if (u === i) return;
|
|
24
|
+
if (s === i) {
|
|
25
|
+
u = null, (a.lang !== i || a.pending || a.error !== void 0) && f({ ...a, lang: i, pending: !1, error: void 0 });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const l = t.peek?.(i);
|
|
29
|
+
if (l !== void 0) {
|
|
30
|
+
u = null, s = i, f({ lang: i, locale: l, pending: !1, error: void 0 });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
c(i);
|
|
34
|
+
},
|
|
35
|
+
retry() {
|
|
36
|
+
a.error === void 0 || u !== null || c(a.lang);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function c(i) {
|
|
40
|
+
u = i, f({ ...a, lang: i, pending: !0, error: void 0 }), t(i).then(
|
|
41
|
+
(l) => {
|
|
42
|
+
u === i && (u = null, s = i, f({ lang: i, locale: l, pending: !1, error: void 0 }));
|
|
43
|
+
},
|
|
44
|
+
(l) => {
|
|
45
|
+
u === i && (u = null, f({ ...a, pending: !1, error: l }), e.onError?.(l, i));
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const v = "en", N = { onMissingArgument: (t) => `{${t}}` }, w = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function T() {
|
|
52
|
+
return process.env.NODE_ENV !== "production";
|
|
53
|
+
}
|
|
54
|
+
function z(t, n) {
|
|
55
|
+
try {
|
|
56
|
+
if (typeof t != "string") throw new TypeError("сообщение не является строкой");
|
|
57
|
+
return D(t);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
return T() && console.error(
|
|
60
|
+
`[@reformer/core/i18n] ${n}: ${e instanceof Error ? e.message : String(e)}`
|
|
61
|
+
), null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function A(t, n, e) {
|
|
65
|
+
if (!p(t, n)) return;
|
|
66
|
+
let r = w.get(t);
|
|
67
|
+
r === void 0 && w.set(t, r = /* @__PURE__ */ new Map());
|
|
68
|
+
let o = r.get(n);
|
|
69
|
+
return o === void 0 && (o = z(t[n], `локаль «${e}», ключ «${n}»`), r.set(n, o)), o;
|
|
70
|
+
}
|
|
71
|
+
function m(t, n, e, r) {
|
|
72
|
+
const o = A(t, e, n);
|
|
73
|
+
if (o != null)
|
|
74
|
+
return E(o, r ?? {}, n, N);
|
|
75
|
+
}
|
|
76
|
+
function _(t, n, e, r) {
|
|
77
|
+
if (typeof t[e] == "string")
|
|
78
|
+
return m(t, n, e, r);
|
|
79
|
+
}
|
|
80
|
+
function U(t, n, e, r) {
|
|
81
|
+
return m(t.messages, t.code, e, r) ?? m(n, v, e, r) ?? e;
|
|
82
|
+
}
|
|
83
|
+
function P(t, n) {
|
|
84
|
+
let e = S.get(t);
|
|
85
|
+
return e === void 0 && (e = z(t, `defaultMessage «${t}»`), S.set(t, e)), e === null ? void 0 : E(e, n ?? {}, v, N);
|
|
86
|
+
}
|
|
87
|
+
const M = ["b", "kb", "mb", "gb", "tb"], y = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
|
|
88
|
+
function F(t, n, e, r) {
|
|
89
|
+
const o = e === void 0 ? n : `${n}|${JSON.stringify(e)}`;
|
|
90
|
+
let a = t.get(o);
|
|
91
|
+
return a === void 0 && t.set(o, a = r()), a;
|
|
92
|
+
}
|
|
93
|
+
const b = /* @__PURE__ */ new WeakMap();
|
|
94
|
+
function Z(t) {
|
|
95
|
+
const n = b.get(t);
|
|
96
|
+
if (n !== void 0) return n;
|
|
97
|
+
const { code: e, messages: r } = t, o = (s, f) => F(
|
|
98
|
+
y,
|
|
99
|
+
e,
|
|
100
|
+
f,
|
|
101
|
+
() => new Intl.NumberFormat(g(e), f)
|
|
102
|
+
).format(s), a = (s, f, c) => {
|
|
103
|
+
const i = m(r, e, s, f);
|
|
104
|
+
if (i !== void 0) return i;
|
|
105
|
+
if (c !== void 0) {
|
|
106
|
+
const d = P(c, f);
|
|
107
|
+
if (d !== void 0) return d;
|
|
108
|
+
}
|
|
109
|
+
const l = m($, v, s, f);
|
|
110
|
+
if (l !== void 0) return l;
|
|
111
|
+
if (T()) {
|
|
112
|
+
let d = h.get(r);
|
|
113
|
+
d === void 0 && h.set(r, d = /* @__PURE__ */ new Set()), d.has(s) || (d.add(s), console.warn(
|
|
114
|
+
`[@reformer/core/i18n] ключа «${s}» нет в локали «${e}», и defaultMessage не задан — показан сам ключ`
|
|
115
|
+
));
|
|
116
|
+
}
|
|
117
|
+
return s;
|
|
118
|
+
}, u = {
|
|
119
|
+
locale: t,
|
|
120
|
+
code: e,
|
|
121
|
+
has: (s) => p(r, s),
|
|
122
|
+
t: a,
|
|
123
|
+
number: o,
|
|
124
|
+
date: (s, f) => F(
|
|
125
|
+
j,
|
|
126
|
+
e,
|
|
127
|
+
f,
|
|
128
|
+
() => new Intl.DateTimeFormat(g(e), f)
|
|
129
|
+
).format(s),
|
|
130
|
+
fileSize: (s) => {
|
|
131
|
+
if (!Number.isFinite(s) || s < 0) return "";
|
|
132
|
+
let f = s, c = 0;
|
|
133
|
+
for (; f >= 1024 && c < M.length - 1; )
|
|
134
|
+
f /= 1024, c += 1;
|
|
135
|
+
const i = o(f, { maximumFractionDigits: c === 0 ? 0 : 1, useGrouping: !1 });
|
|
136
|
+
return a(`format.fileSize.${M[c]}`, { value: i });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return b.set(t, u), u;
|
|
140
|
+
}
|
|
141
|
+
function G(t) {
|
|
142
|
+
return t;
|
|
143
|
+
}
|
|
144
|
+
const C = /* @__PURE__ */ new Set([
|
|
145
|
+
"maxFileSize",
|
|
146
|
+
"minFileSize",
|
|
147
|
+
"actualSize",
|
|
148
|
+
"maxTotalFileSize",
|
|
149
|
+
"actualTotal"
|
|
150
|
+
]), I = /* @__PURE__ */ new Map();
|
|
151
|
+
function W(t, n) {
|
|
152
|
+
const e = n.map(L);
|
|
153
|
+
let r = I.get(t);
|
|
154
|
+
if (r === void 0) {
|
|
155
|
+
try {
|
|
156
|
+
r = new Intl.ListFormat(g(t), { style: "narrow", type: "conjunction" });
|
|
157
|
+
} catch {
|
|
158
|
+
r = null;
|
|
159
|
+
}
|
|
160
|
+
I.set(t, r);
|
|
161
|
+
}
|
|
162
|
+
return r === null ? e.join(", ") : r.format(e);
|
|
163
|
+
}
|
|
164
|
+
function O(t, n) {
|
|
165
|
+
if (t === void 0) return;
|
|
166
|
+
const e = {};
|
|
167
|
+
for (const r of Object.keys(t)) {
|
|
168
|
+
const o = t[r];
|
|
169
|
+
o instanceof Date ? e[r] = n.date(o, { dateStyle: "medium" }) : Array.isArray(o) ? e[r] = W(n.code, o) : typeof o == "number" && C.has(r) ? e[r] = n.fileSize(o) : e[r] = o;
|
|
170
|
+
}
|
|
171
|
+
return e;
|
|
172
|
+
}
|
|
173
|
+
function J(t, n, e) {
|
|
174
|
+
if (e !== void 0 && p(e, t.code)) {
|
|
175
|
+
const o = e[t.code];
|
|
176
|
+
if (typeof o == "function") return o(t.params ?? {}, n);
|
|
177
|
+
const a = _(
|
|
178
|
+
e,
|
|
179
|
+
n.code,
|
|
180
|
+
t.code,
|
|
181
|
+
O(t.params, n)
|
|
182
|
+
);
|
|
183
|
+
if (a !== void 0) return a;
|
|
184
|
+
}
|
|
185
|
+
const r = `validation.${t.code}`;
|
|
186
|
+
return n.has(r) || p($, r) ? n.t(r, O(t.params, n)) : t.code;
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
Z as a,
|
|
190
|
+
R as c,
|
|
191
|
+
G as d,
|
|
192
|
+
J as r,
|
|
193
|
+
U as t
|
|
194
|
+
};
|
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,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as L } from "./form-model-DYCzGGKF.js";
|
|
3
|
-
import { g as p } from "./signal-node-registry-tiwel-TV.js";
|
|
4
|
-
let v = null;
|
|
5
|
-
function f(e) {
|
|
6
|
-
if (!v)
|
|
7
|
-
throw new Error(
|
|
8
|
-
`[@reformer/core/validation] "${e}" вызван вне схемы валидации — операторы валидации можно вызывать только внутри прогона validateModel(...) (напрямую или через apply/each).`
|
|
9
|
-
);
|
|
10
|
-
return v;
|
|
11
|
-
}
|
|
12
|
-
function b(e, r) {
|
|
13
|
-
let t = e.errors.get(r);
|
|
14
|
-
return t || e.errors.set(r, t = []), t;
|
|
15
|
-
}
|
|
16
|
-
const y = (e) => e.whenStack.every((r) => r());
|
|
17
|
-
function D(e, r) {
|
|
18
|
-
const t = f("validate"), n = b(t, e);
|
|
19
|
-
if (!y(t)) return;
|
|
20
|
-
const o = e.peek();
|
|
21
|
-
for (const i of r) {
|
|
22
|
-
const s = i(o, t.model, t.model);
|
|
23
|
-
s && n.push(s);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function N(e, r) {
|
|
27
|
-
const t = f("validateAsync"), n = b(t, e);
|
|
28
|
-
if (!y(t)) return;
|
|
29
|
-
const o = e.peek(), i = t.signal;
|
|
30
|
-
for (const s of r)
|
|
31
|
-
t.pending.push(
|
|
32
|
-
s(o, { signal: i }).then(
|
|
33
|
-
(a) => {
|
|
34
|
-
a && !i.aborted && n.push(a);
|
|
35
|
-
},
|
|
36
|
-
() => {
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
function R(e, r) {
|
|
42
|
-
const t = f("validateWhen");
|
|
43
|
-
t.whenStack.push(e);
|
|
44
|
-
try {
|
|
45
|
-
r();
|
|
46
|
-
} finally {
|
|
47
|
-
t.whenStack.pop();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function _(e, r) {
|
|
51
|
-
const t = f("cross"), n = b(t, e);
|
|
52
|
-
if (!y(t)) return;
|
|
53
|
-
const o = r(t.model.get());
|
|
54
|
-
o && n.push(o);
|
|
55
|
-
}
|
|
56
|
-
function $(e, r) {
|
|
57
|
-
f("each");
|
|
58
|
-
const t = e.length;
|
|
59
|
-
for (let n = 0; n < t; n++) r(e.at(n));
|
|
60
|
-
}
|
|
61
|
-
function j(...e) {
|
|
62
|
-
const t = f("apply").model;
|
|
63
|
-
for (const n of e) n({ model: t });
|
|
64
|
-
}
|
|
65
|
-
function z(e) {
|
|
66
|
-
return e;
|
|
67
|
-
}
|
|
68
|
-
const F = /* @__PURE__ */ new WeakMap();
|
|
69
|
-
function P(e, r) {
|
|
70
|
-
let t = F.get(e);
|
|
71
|
-
t || F.set(e, t = /* @__PURE__ */ new WeakMap());
|
|
72
|
-
let n = t.get(r);
|
|
73
|
-
return n || t.set(r, n = { fields: /* @__PURE__ */ new Set(), ac: null }), n;
|
|
74
|
-
}
|
|
75
|
-
const T = (e) => {
|
|
76
|
-
for (const r of e.values()) for (const t of r) if (t.severity !== "warning") return !0;
|
|
77
|
-
return !1;
|
|
78
|
-
};
|
|
79
|
-
function W(e) {
|
|
80
|
-
return e.aborted ? Promise.resolve() : new Promise((r) => {
|
|
81
|
-
e.addEventListener("abort", () => r(), { once: !0 });
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
async function V(e, r, t) {
|
|
85
|
-
const n = P(e, r);
|
|
86
|
-
n.ac?.abort();
|
|
87
|
-
const o = new AbortController();
|
|
88
|
-
n.ac = o;
|
|
89
|
-
const i = {
|
|
90
|
-
model: e,
|
|
91
|
-
errors: /* @__PURE__ */ new Map(),
|
|
92
|
-
pending: [],
|
|
93
|
-
whenStack: [],
|
|
94
|
-
signal: o.signal
|
|
95
|
-
}, s = v;
|
|
96
|
-
v = i;
|
|
97
|
-
try {
|
|
98
|
-
r({ model: e });
|
|
99
|
-
} finally {
|
|
100
|
-
v = s;
|
|
101
|
-
}
|
|
102
|
-
if (i.pending.length && await Promise.race([Promise.all(i.pending), W(o.signal)]), o.signal.aborted) return !1;
|
|
103
|
-
const a = new Set(i.errors.keys());
|
|
104
|
-
for (const c of n.fields) a.has(c) || p(c)?.setErrors([]);
|
|
105
|
-
for (const c of a) p(c)?.setErrors(i.errors.get(c) ?? []);
|
|
106
|
-
if (t?.touch) for (const c of a) p(c)?.markAsTouched();
|
|
107
|
-
return n.fields = a, !T(i.errors);
|
|
108
|
-
}
|
|
109
|
-
function G(e, r, t = {}) {
|
|
110
|
-
const { strategy: n = "submit", debounce: o = 0, liveAfterSubmit: i = "change" } = t, s = M(!1);
|
|
111
|
-
let a = 0, c = !1, w = !1, d, l;
|
|
112
|
-
const k = async (u) => {
|
|
113
|
-
a++, s.value = !0;
|
|
114
|
-
try {
|
|
115
|
-
return await V(e, r, { touch: u });
|
|
116
|
-
} finally {
|
|
117
|
-
--a === 0 && (s.value = !1);
|
|
118
|
-
}
|
|
119
|
-
}, h = () => {
|
|
120
|
-
k(!1);
|
|
121
|
-
}, A = () => {
|
|
122
|
-
if (!o) {
|
|
123
|
-
h();
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
l && clearTimeout(l), l = setTimeout(h, o);
|
|
127
|
-
}, S = (u, g) => {
|
|
128
|
-
let x = !0;
|
|
129
|
-
return E(() => {
|
|
130
|
-
if (L(e, u), x) {
|
|
131
|
-
x = !1;
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
n === "afterFirstSubmit" && !c || g();
|
|
135
|
-
});
|
|
136
|
-
}, m = {
|
|
137
|
-
async validate() {
|
|
138
|
-
return c = !0, k(!0);
|
|
139
|
-
},
|
|
140
|
-
start() {
|
|
141
|
-
if (w || d) return () => m.dispose();
|
|
142
|
-
const u = n === "afterFirstSubmit" ? i : n;
|
|
143
|
-
return u === "change" ? d = S((g) => void g.value, A) : u === "blur" && (d = S((g) => void p(g)?.touched.value, h)), () => m.dispose();
|
|
144
|
-
},
|
|
145
|
-
dispose() {
|
|
146
|
-
w = !0, l && (clearTimeout(l), l = void 0), d?.(), d = void 0;
|
|
147
|
-
},
|
|
148
|
-
get isValidating() {
|
|
149
|
-
return s.value;
|
|
150
|
-
},
|
|
151
|
-
get validating() {
|
|
152
|
-
return s;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
return m;
|
|
156
|
-
}
|
|
1
|
+
import { c as i, d as l, f as s, h as d, e as t, r as n, v as o, a as p, g as r, b as v } from "./strategy-DzvnsWLh.js";
|
|
157
2
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
3
|
+
i as apply,
|
|
4
|
+
l as applyEach,
|
|
5
|
+
s as applyValidationResult,
|
|
6
|
+
d as createFormValidation,
|
|
7
|
+
t as defineValidation,
|
|
8
|
+
n as runValidation,
|
|
9
|
+
o as validate,
|
|
10
|
+
p as validateAsync,
|
|
11
|
+
r as validateModel,
|
|
12
|
+
v as validateWhen
|
|
167
13
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/email'
|
|
2
2
|
export {}
|
package/dist/validators/email.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
message: e?.message ?? "invalid",
|
|
6
|
-
params: e?.params
|
|
7
|
-
} : null;
|
|
1
|
+
import { v as n } from "../validation-issue-B9mjI8jz.js";
|
|
2
|
+
const e = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3
|
+
function s(t) {
|
|
4
|
+
return (r) => r ? e.test(r) ? null : n("email", t) : null;
|
|
8
5
|
}
|
|
9
6
|
export {
|
|
10
|
-
|
|
7
|
+
s as email
|
|
11
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/future-date'
|
|
2
2
|
export {}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { p as o, n as s, g as u } from "../date-utils-90-qZbse.js";
|
|
2
|
+
import { v as i } from "../validation-issue-B9mjI8jz.js";
|
|
3
|
+
function f(n) {
|
|
4
|
+
return (t) => {
|
|
5
|
+
if (t == null || t === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const r = o(t);
|
|
8
|
+
if (r === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_past",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: a?.params
|
|
14
|
-
} : null;
|
|
10
|
+
const a = s(r), e = u();
|
|
11
|
+
return a < e ? i("date_past", n) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
f as futureDate
|
|
19
16
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/integer'
|
|
2
2
|
export {}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: e?.message ?? "invalid",
|
|
5
|
-
params: e?.params
|
|
6
|
-
};
|
|
1
|
+
import { v as t } from "../validation-issue-B9mjI8jz.js";
|
|
2
|
+
function i(n) {
|
|
3
|
+
return (r) => r == null || typeof r != "number" || isNaN(r) || Number.isInteger(r) ? null : t("integer", n);
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
i as integer
|
|
10
7
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/is-date'
|
|
2
2
|
export {}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
message: e?.message ?? "invalid",
|
|
6
|
-
params: e?.params
|
|
7
|
-
} : null;
|
|
1
|
+
import { p as t } from "../date-utils-90-qZbse.js";
|
|
2
|
+
import { v as i } from "../validation-issue-B9mjI8jz.js";
|
|
3
|
+
function a(n) {
|
|
4
|
+
return (r) => r == null || r === "" ? null : t(r) === null ? i("date_invalid", n) : null;
|
|
8
5
|
}
|
|
9
6
|
export {
|
|
10
|
-
|
|
7
|
+
a as isDate
|
|
11
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/is-number'
|
|
2
2
|
export {}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: e?.message ?? "invalid",
|
|
5
|
-
params: e?.params
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as n } from "../validation-issue-B9mjI8jz.js";
|
|
2
|
+
function u(i) {
|
|
3
|
+
return (r) => r == null || r === "" ? null : typeof r != "number" || !Number.isFinite(r) ? n("isNumber", i) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
u as isNumber
|
|
10
7
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max-age'
|
|
2
2
|
export {}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
1
|
+
import { p as i, i as a, c as l } from "../date-utils-90-qZbse.js";
|
|
2
|
+
import { v as s } from "../validation-issue-B9mjI8jz.js";
|
|
3
|
+
function f(n, u) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return t > e ? {
|
|
11
|
-
code: "date_max_age",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: { maxAge: e, currentAge: t, ...a?.params }
|
|
14
|
-
} : null;
|
|
7
|
+
const t = i(r);
|
|
8
|
+
if (t === null || a(t)) return null;
|
|
9
|
+
const e = l(t);
|
|
10
|
+
return e > n ? s("date_max_age", u, { maxAge: n, currentAge: e }) : null;
|
|
15
11
|
};
|
|
16
12
|
}
|
|
17
13
|
export {
|
|
18
|
-
|
|
14
|
+
f as maxAge
|
|
19
15
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max-date'
|
|
2
2
|
export {}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { p as l, n as a } from "../date-utils-90-qZbse.js";
|
|
2
|
+
import { v as s } from "../validation-issue-B9mjI8jz.js";
|
|
3
|
+
function d(r, o) {
|
|
4
|
+
return (n) => {
|
|
5
|
+
if (n == null || n === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = l(n);
|
|
8
|
+
if (t === null)
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
code: "date_max",
|
|
12
|
-
message: a?.message ?? "invalid",
|
|
13
|
-
params: { maxDate: n, ...a?.params }
|
|
14
|
-
} : null;
|
|
10
|
+
const e = a(t), i = a(r);
|
|
11
|
+
return e > i ? s("date_max", o, { maxDate: r }) : null;
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
15
|
+
d as maxDate
|
|
19
16
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max-length'
|
|
2
2
|
export {}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { v as u } from "../validation-issue-B9mjI8jz.js";
|
|
2
|
+
function a(r, e) {
|
|
3
|
+
return (t) => {
|
|
4
|
+
if (t == null || t === "")
|
|
4
5
|
return null;
|
|
5
|
-
const
|
|
6
|
-
return typeof
|
|
7
|
-
code: "maxLength",
|
|
8
|
-
message: t?.message ?? "invalid",
|
|
9
|
-
params: { maxLength: r, actualLength: e, ...t?.params }
|
|
10
|
-
} : null;
|
|
6
|
+
const n = t.length;
|
|
7
|
+
return typeof n != "number" ? null : n > r ? Array.isArray(t) ? u("maxItems", e, { maxLength: r, actualLength: n }) : u("maxLength", e, { maxLength: r, actualLength: n }) : null;
|
|
11
8
|
};
|
|
12
9
|
}
|
|
13
10
|
export {
|
|
14
|
-
|
|
11
|
+
a as maxLength
|
|
15
12
|
};
|
package/dist/validators/max.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/max'
|
|
2
2
|
export {}
|
package/dist/validators/max.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message: a?.message ?? "invalid",
|
|
5
|
-
params: { max: n, actual: r, ...a?.params }
|
|
6
|
-
} : null;
|
|
1
|
+
import { v as i } from "../validation-issue-B9mjI8jz.js";
|
|
2
|
+
function m(n, t) {
|
|
3
|
+
return (r) => typeof r != "number" || Number.isNaN(r) ? null : r > n ? i("max", t, { max: n, actual: r }) : null;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
m as max
|
|
10
7
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/min-age'
|
|
2
2
|
export {}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { p as s, c as
|
|
2
|
-
|
|
1
|
+
import { p as a, i as s, c as f } from "../date-utils-90-qZbse.js";
|
|
2
|
+
import { v as u } from "../validation-issue-B9mjI8jz.js";
|
|
3
|
+
function c(t, e) {
|
|
3
4
|
return (r) => {
|
|
4
5
|
if (r == null || r === "")
|
|
5
6
|
return null;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const n = a(r);
|
|
8
|
+
if (n === null)
|
|
8
9
|
return null;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
params: { minAge: e, currentAge: t, ...n?.params }
|
|
14
|
-
} : null;
|
|
10
|
+
if (s(n))
|
|
11
|
+
return u("date_future", e, { minAge: t });
|
|
12
|
+
const i = f(n);
|
|
13
|
+
return i < t ? u("date_min_age", e, { minAge: t, currentAge: i }) : null;
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
16
|
export {
|
|
18
|
-
|
|
17
|
+
c as minAge
|
|
19
18
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '../form/
|
|
1
|
+
export * from '../form/validators/min-date'
|
|
2
2
|
export {}
|