@reformer/core 11.0.0-beta.6 → 11.0.0-beta.7

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.
Files changed (76) hide show
  1. package/dist/behaviors.js +124 -124
  2. package/dist/create-model-B8U-COv-.js +103 -0
  3. package/dist/en-CjAqn7h0.js +41 -0
  4. package/dist/form/behaviors/internals.d.ts +9 -0
  5. package/dist/form/types/contracts.d.ts +6 -0
  6. package/dist/form/types/validation-schema.d.ts +13 -1
  7. package/dist/form/validation/operators.d.ts +6 -1
  8. package/dist/form/validators/validation-error.d.ts +8 -0
  9. package/dist/i18n/descriptor.d.ts +54 -0
  10. package/dist/i18n/en.json.d.ts +45 -0
  11. package/dist/i18n/loader.d.ts +71 -0
  12. package/dist/i18n/locale-store.d.ts +39 -0
  13. package/dist/i18n/locale.d.ts +90 -0
  14. package/dist/i18n/message-format.d.ts +116 -0
  15. package/dist/i18n/resolve-localized.d.ts +17 -0
  16. package/dist/i18n/ru.json.d.ts +45 -0
  17. package/dist/i18n/translator.d.ts +50 -0
  18. package/dist/i18n/validation-message.d.ts +18 -0
  19. package/dist/i18n.d.ts +31 -0
  20. package/dist/i18n.js +303 -0
  21. package/dist/index-BrNkQj1y.js +105 -0
  22. package/dist/index.js +639 -736
  23. package/dist/loader-Dv_Hl7JC.js +216 -0
  24. package/dist/locale/en.d.ts +2 -0
  25. package/dist/locale/en.js +5 -0
  26. package/dist/locale/en.json +42 -0
  27. package/dist/locale/index.d.ts +18 -0
  28. package/dist/locale/ru.d.ts +2 -0
  29. package/dist/locale/ru.js +41 -0
  30. package/dist/locale/ru.json +42 -0
  31. package/dist/locale.d.ts +2 -0
  32. package/dist/locale.js +9 -0
  33. package/dist/model/create-model.d.ts +17 -3
  34. package/dist/model/index.d.ts +3 -3
  35. package/dist/model/model-signals-proxy.d.ts +25 -0
  36. package/dist/model/types.d.ts +19 -5
  37. package/dist/model-signals-proxy-2vqS243J.js +250 -0
  38. package/dist/model.js +18 -16
  39. package/dist/platforms/react/hooks/types.d.ts +6 -3
  40. package/dist/platforms/react/hooks/useFormControlValue.d.ts +2 -1
  41. package/dist/platforms/react/i18n/context.d.ts +13 -0
  42. package/dist/platforms/react/i18n/hooks.d.ts +59 -0
  43. package/dist/platforms/react/i18n/provider.d.ts +52 -0
  44. package/dist/{strategy-DA3JwxsR.js → strategy-BXS_gBfz.js} +7 -7
  45. package/dist/validation-error-B-U3RsV0.js +11 -0
  46. package/dist/validation.js +1 -1
  47. package/dist/validators/email.js +5 -8
  48. package/dist/validators/future-date.js +8 -11
  49. package/dist/validators/integer.js +4 -7
  50. package/dist/validators/is-date.js +5 -8
  51. package/dist/validators/is-number.js +4 -7
  52. package/dist/validators/max-age.js +8 -11
  53. package/dist/validators/max-date.js +8 -11
  54. package/dist/validators/max-length.js +5 -8
  55. package/dist/validators/max.js +4 -7
  56. package/dist/validators/min-age.js +8 -11
  57. package/dist/validators/min-date.js +8 -11
  58. package/dist/validators/min-length.js +5 -8
  59. package/dist/validators/min.js +4 -7
  60. package/dist/validators/multiple-of.js +5 -8
  61. package/dist/validators/non-negative.js +4 -7
  62. package/dist/validators/non-zero.js +4 -7
  63. package/dist/validators/past-date.js +8 -11
  64. package/dist/validators/pattern.js +5 -8
  65. package/dist/validators/phone.js +6 -9
  66. package/dist/validators/required.js +4 -7
  67. package/dist/validators/url.js +9 -14
  68. package/dist/validators.js +84 -106
  69. package/docs/llms/03-api-signatures.md +6 -0
  70. package/docs/llms/10-arrays.md +30 -0
  71. package/docs/llms/34-i18n.md +272 -0
  72. package/llms-index.json +1 -1
  73. package/llms.txt +1589 -98
  74. package/package.json +22 -3
  75. package/dist/create-model-Dxh9cfLp.js +0 -97
  76. package/dist/model-signals-proxy-mV3WGdlO.js +0 -233
package/dist/i18n.js ADDED
@@ -0,0 +1,303 @@
1
+ import { h as b, f as T, p as U, D as V } from "./loader-Dv_Hl7JC.js";
2
+ import { M as Oe, b as he, a as Fe, c as Ae, e as Ie, d as _e, m as $e, v as Te } from "./loader-Dv_Hl7JC.js";
3
+ import { m as D } from "./en-CjAqn7h0.js";
4
+ import { Signal as P } from "@preact/signals-core";
5
+ import { createContext as G, createElement as g, useMemo as p, useRef as K, useEffect as k, Fragment as x, useContext as M } from "react";
6
+ import { s as W } from "./index-BrNkQj1y.js";
7
+ function q(e, t, n = {}) {
8
+ const r = /* @__PURE__ */ new Set(), o = e.peek?.(t);
9
+ let a = {
10
+ lang: t,
11
+ locale: o ?? null,
12
+ pending: o === void 0,
13
+ error: void 0
14
+ }, c = null, i = o === void 0 ? null : t;
15
+ const f = (s) => {
16
+ a = s;
17
+ for (const u of [...r]) u();
18
+ };
19
+ return {
20
+ getState: () => a,
21
+ subscribe(s) {
22
+ return r.add(s), () => {
23
+ r.delete(s);
24
+ };
25
+ },
26
+ setLang(s) {
27
+ if (c === s) return;
28
+ if (i === s) {
29
+ c = null, (a.lang !== s || a.pending || a.error !== void 0) && f({ ...a, lang: s, pending: !1, error: void 0 });
30
+ return;
31
+ }
32
+ const u = e.peek?.(s);
33
+ if (u !== void 0) {
34
+ c = null, i = s, f({ lang: s, locale: u, pending: !1, error: void 0 });
35
+ return;
36
+ }
37
+ c = s, f({ ...a, lang: s, pending: !0, error: void 0 }), e(s).then(
38
+ (l) => {
39
+ c === s && (c = null, i = s, f({ lang: s, locale: l, pending: !1, error: void 0 }));
40
+ },
41
+ (l) => {
42
+ c === s && (c = null, f({ ...a, pending: !1, error: l }), n.onError?.(l, s));
43
+ }
44
+ );
45
+ }
46
+ };
47
+ }
48
+ const w = "en", N = { onMissingArgument: (e) => `{${e}}` }, L = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new WeakMap();
49
+ function C() {
50
+ return process.env.NODE_ENV !== "production";
51
+ }
52
+ function j(e, t) {
53
+ try {
54
+ if (typeof e != "string") throw new TypeError("сообщение не является строкой");
55
+ return U(e);
56
+ } catch (n) {
57
+ return C() && console.error(
58
+ `[@reformer/core/i18n] ${t}: ${n instanceof Error ? n.message : String(n)}`
59
+ ), null;
60
+ }
61
+ }
62
+ function B(e, t, n) {
63
+ if (!b(e, t)) return;
64
+ let r = L.get(e);
65
+ r === void 0 && L.set(e, r = /* @__PURE__ */ new Map());
66
+ let o = r.get(t);
67
+ return o === void 0 && (o = j(e[t], `локаль «${n}», ключ «${t}»`), r.set(t, o)), o;
68
+ }
69
+ function S(e, t, n, r) {
70
+ const o = B(e, n, t);
71
+ if (o != null)
72
+ return T(o, r ?? {}, t, N);
73
+ }
74
+ function Z(e, t, n, r) {
75
+ return S(e.messages, e.code, n, r) ?? S(t, w, n, r) ?? n;
76
+ }
77
+ function J(e, t) {
78
+ let n = O.get(e);
79
+ return n === void 0 && (n = j(e, `defaultMessage «${e}»`), O.set(e, n)), n === null ? void 0 : T(n, t ?? {}, w, N);
80
+ }
81
+ const F = ["b", "kb", "mb", "gb", "tb"], X = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
82
+ function A(e, t, n, r) {
83
+ const o = n === void 0 ? t : `${t}|${JSON.stringify(n)}`;
84
+ let a = e.get(o);
85
+ return a === void 0 && e.set(o, a = r()), a;
86
+ }
87
+ const I = /* @__PURE__ */ new WeakMap();
88
+ function v(e) {
89
+ const t = I.get(e);
90
+ if (t !== void 0) return t;
91
+ const { code: n, messages: r } = e, o = (i, f) => A(X, n, f, () => new Intl.NumberFormat(n, f)).format(i), a = (i, f, s) => {
92
+ const u = S(r, n, i, f);
93
+ if (u !== void 0) return u;
94
+ if (s !== void 0) {
95
+ const d = J(s, f);
96
+ if (d !== void 0) return d;
97
+ }
98
+ const l = S(D, w, i, f);
99
+ if (l !== void 0) return l;
100
+ if (C()) {
101
+ let d = h.get(r);
102
+ d === void 0 && h.set(r, d = /* @__PURE__ */ new Set()), d.has(i) || (d.add(i), console.warn(
103
+ `[@reformer/core/i18n] ключа «${i}» нет в локали «${n}», и defaultMessage не задан — показан сам ключ`
104
+ ));
105
+ }
106
+ return i;
107
+ }, c = {
108
+ locale: e,
109
+ code: n,
110
+ has: (i) => b(r, i),
111
+ t: a,
112
+ number: o,
113
+ date: (i, f) => A(Y, n, f, () => new Intl.DateTimeFormat(n, f)).format(
114
+ i
115
+ ),
116
+ fileSize: (i) => {
117
+ if (!Number.isFinite(i) || i < 0) return "";
118
+ let f = i, s = 0;
119
+ for (; f >= 1024 && s < F.length - 1; )
120
+ f /= 1024, s += 1;
121
+ const u = o(f, { maximumFractionDigits: s === 0 ? 0 : 1, useGrouping: !1 });
122
+ return a(`format.fileSize.${F[s]}`, { value: u });
123
+ }
124
+ };
125
+ return I.set(e, c), c;
126
+ }
127
+ const H = "invalid", Q = /* @__PURE__ */ new Set([
128
+ "maxFileSize",
129
+ "minFileSize",
130
+ "actualSize",
131
+ "maxTotalFileSize",
132
+ "actualTotal"
133
+ ]), _ = /* @__PURE__ */ new Map();
134
+ function ee(e, t) {
135
+ const n = t.map(String);
136
+ let r = _.get(e);
137
+ if (r === void 0) {
138
+ try {
139
+ r = new Intl.ListFormat(e, { style: "short", type: "unit" });
140
+ } catch {
141
+ r = null;
142
+ }
143
+ _.set(e, r);
144
+ }
145
+ return r === null ? n.join(", ") : r.format(n);
146
+ }
147
+ function $(e, t) {
148
+ if (e === void 0) return;
149
+ const n = {};
150
+ for (const r of Object.keys(e)) {
151
+ const o = e[r];
152
+ o instanceof Date ? n[r] = t.date(o, { dateStyle: "medium" }) : Array.isArray(o) ? n[r] = ee(t.code, o) : typeof o == "number" && Q.has(r) ? n[r] = t.fileSize(o) : n[r] = o;
153
+ }
154
+ return n;
155
+ }
156
+ function te(e, t) {
157
+ if (e.messageKey !== void 0 && t.has(e.messageKey))
158
+ return t.t(e.messageKey, $(e.params, t));
159
+ if (typeof e.message == "string" && e.message !== "" && e.message !== H)
160
+ return e.message;
161
+ const n = `validation.${e.code}`;
162
+ return t.has(n) || b(D, n) ? t.t(n, $(e.params, t)) : e.code;
163
+ }
164
+ const z = Symbol.for("reformer.i18n.message");
165
+ function ne(e, t, n) {
166
+ return Object.freeze({
167
+ [z]: !0,
168
+ key: e,
169
+ ...t === void 0 ? {} : { values: t },
170
+ ...n === void 0 ? {} : { defaultMessage: n }
171
+ });
172
+ }
173
+ function re(e) {
174
+ return e !== null && typeof e == "object" && e[z] === !0;
175
+ }
176
+ function Se(e) {
177
+ return { msg: (t, n) => ne(t, n, e[t]) };
178
+ }
179
+ function oe(e) {
180
+ const t = Object.getPrototypeOf(e);
181
+ return t === Object.prototype || t === null;
182
+ }
183
+ function se(e) {
184
+ if (e instanceof P) return !0;
185
+ const t = e;
186
+ return t.$$typeof !== void 0 || t.__path !== void 0 || t.__kind !== void 0;
187
+ }
188
+ function ie(e) {
189
+ if (e === void 0) return;
190
+ const t = {};
191
+ for (const n of Object.keys(e)) {
192
+ const r = e[n];
193
+ t[n] = r instanceof P ? r.value : r;
194
+ }
195
+ return t;
196
+ }
197
+ function E(e, t, n) {
198
+ if (e === null || typeof e != "object") return e;
199
+ if (re(e))
200
+ return t.t(e.key, ie(e.values), e.defaultMessage);
201
+ if (se(e) || n.has(e)) return e;
202
+ if (Array.isArray(e)) {
203
+ n.add(e);
204
+ let o = !1;
205
+ const a = e.map((c) => {
206
+ const i = E(c, t, n);
207
+ return i !== c && (o = !0), i;
208
+ });
209
+ return n.delete(e), o ? a : e;
210
+ }
211
+ if (!oe(e)) return e;
212
+ n.add(e);
213
+ let r;
214
+ for (const o of Object.keys(e)) {
215
+ const a = e[o], c = E(a, t, n);
216
+ c !== a && (r ??= { ...e }, r[o] = c);
217
+ }
218
+ return n.delete(e), r ?? e;
219
+ }
220
+ function ve(e, t) {
221
+ return E(e, t, /* @__PURE__ */ new Set());
222
+ }
223
+ const ae = "ReformerI18nContext";
224
+ function y(e, t, n) {
225
+ return { ...e, pending: t, error: n };
226
+ }
227
+ const ce = y(v(V), !1, void 0), m = G(ce);
228
+ m.displayName = ae;
229
+ function fe({ locale: e, children: t }) {
230
+ const n = p(() => y(v(e), !1, void 0), [e]);
231
+ return g(m.Provider, { value: n }, t);
232
+ }
233
+ function ue({
234
+ lang: e,
235
+ load: t,
236
+ fallback: n,
237
+ onError: r,
238
+ children: o
239
+ }) {
240
+ const a = K(r);
241
+ a.current = r;
242
+ const c = p(
243
+ () => q(t, e, {
244
+ onError: (d, R) => a.current?.(d, R)
245
+ }),
246
+ [t]
247
+ );
248
+ k(() => {
249
+ c.setLang(e);
250
+ }, [c, e]);
251
+ const i = W.useSyncExternalStore(c.subscribe, c.getState, c.getState), { locale: f, pending: s, error: u } = i, l = p(
252
+ () => f === null ? null : y(v(f), s, u),
253
+ [f, s, u]
254
+ );
255
+ return l === null ? n === void 0 ? null : g(x, null, n) : g(m.Provider, { value: l }, o);
256
+ }
257
+ function Ee(e) {
258
+ return "locale" in e ? g(fe, e) : g(ue, e);
259
+ }
260
+ function be() {
261
+ return M(m);
262
+ }
263
+ function Me(e) {
264
+ const { locale: t } = M(m);
265
+ return p(
266
+ () => (n, r) => Z(t, e, n, r),
267
+ [t, e]
268
+ );
269
+ }
270
+ function we() {
271
+ const { locale: e } = M(m);
272
+ return p(() => {
273
+ const t = v(e);
274
+ return (n) => te(n, t);
275
+ }, [e]);
276
+ }
277
+ export {
278
+ V as DEFAULT_LOCALE,
279
+ ae as I18N_CONTEXT_MARKER,
280
+ Ee as I18nProvider,
281
+ z as MESSAGE_DESCRIPTOR,
282
+ Oe as MessageSyntaxError,
283
+ he as bundledLocaleSource,
284
+ v as createI18n,
285
+ Fe as createLocaleLoader,
286
+ q as createLocaleStore,
287
+ Ae as createMessageFormatter,
288
+ Se as defineMessages,
289
+ Ie as extendLocale,
290
+ _e as fetchMessages,
291
+ T as formatPattern,
292
+ re as isMessageDescriptor,
293
+ $e as messageArguments,
294
+ ne as msg,
295
+ U as parseMessage,
296
+ ve as resolveLocalized,
297
+ te as resolveValidationError,
298
+ Z as translateBuiltin,
299
+ be as useI18n,
300
+ Me as useMessages,
301
+ we as useValidationMessage,
302
+ Te as validateLocale
303
+ };
@@ -0,0 +1,105 @@
1
+ import T from "react";
2
+ var l = { exports: {} }, y = {};
3
+ var L;
4
+ function A() {
5
+ if (L) return y;
6
+ L = 1;
7
+ var i = T;
8
+ function _(t, o) {
9
+ return t === o && (t !== 0 || 1 / t === 1 / o) || t !== t && o !== o;
10
+ }
11
+ var c = typeof Object.is == "function" ? Object.is : _, p = i.useState, u = i.useEffect, S = i.useLayoutEffect, E = i.useDebugValue;
12
+ function O(t, o) {
13
+ var e = o(), r = p({ inst: { value: e, getSnapshot: o } }), n = r[0].inst, a = r[1];
14
+ return S(
15
+ function() {
16
+ n.value = e, n.getSnapshot = o, f(n) && a({ inst: n });
17
+ },
18
+ [t, e, o]
19
+ ), u(
20
+ function() {
21
+ return f(n) && a({ inst: n }), t(function() {
22
+ f(n) && a({ inst: n });
23
+ });
24
+ },
25
+ [t]
26
+ ), E(e), e;
27
+ }
28
+ function f(t) {
29
+ var o = t.getSnapshot;
30
+ t = t.value;
31
+ try {
32
+ var e = o();
33
+ return !c(t, e);
34
+ } catch {
35
+ return !0;
36
+ }
37
+ }
38
+ function v(t, o) {
39
+ return o();
40
+ }
41
+ var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? v : O;
42
+ return y.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : d, y;
43
+ }
44
+ var m = {};
45
+ var x;
46
+ function g() {
47
+ return x || (x = 1, process.env.NODE_ENV !== "production" && (function() {
48
+ function i(e, r) {
49
+ return e === r && (e !== 0 || 1 / e === 1 / r) || e !== e && r !== r;
50
+ }
51
+ function _(e, r) {
52
+ d || u.startTransition === void 0 || (d = !0, console.error(
53
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
54
+ ));
55
+ var n = r();
56
+ if (!t) {
57
+ var a = r();
58
+ S(n, a) || (console.error(
59
+ "The result of getSnapshot should be cached to avoid an infinite loop"
60
+ ), t = !0);
61
+ }
62
+ a = E({
63
+ inst: { value: n, getSnapshot: r }
64
+ });
65
+ var s = a[0].inst, h = a[1];
66
+ return f(
67
+ function() {
68
+ s.value = n, s.getSnapshot = r, c(s) && h({ inst: s });
69
+ },
70
+ [e, n, r]
71
+ ), O(
72
+ function() {
73
+ return c(s) && h({ inst: s }), e(function() {
74
+ c(s) && h({ inst: s });
75
+ });
76
+ },
77
+ [e]
78
+ ), v(n), n;
79
+ }
80
+ function c(e) {
81
+ var r = e.getSnapshot;
82
+ e = e.value;
83
+ try {
84
+ var n = r();
85
+ return !S(e, n);
86
+ } catch {
87
+ return !0;
88
+ }
89
+ }
90
+ function p(e, r) {
91
+ return r();
92
+ }
93
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
94
+ var u = T, S = typeof Object.is == "function" ? Object.is : i, E = u.useState, O = u.useEffect, f = u.useLayoutEffect, v = u.useDebugValue, d = !1, t = !1, o = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? p : _;
95
+ m.useSyncExternalStore = u.useSyncExternalStore !== void 0 ? u.useSyncExternalStore : o, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
96
+ })()), m;
97
+ }
98
+ var w;
99
+ function D() {
100
+ return w || (w = 1, process.env.NODE_ENV === "production" ? l.exports = A() : l.exports = g()), l.exports;
101
+ }
102
+ var G = D();
103
+ export {
104
+ G as s
105
+ };