@reformer/core 11.0.0-beta.6 → 11.0.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.
Files changed (113) hide show
  1. package/README.md +7 -3
  2. package/dist/behaviors.js +216 -179
  3. package/dist/create-model-BBRHhHwK.js +30 -0
  4. package/dist/en-CjAqn7h0.js +41 -0
  5. package/dist/form/behaviors/collections.d.ts +14 -1
  6. package/dist/form/behaviors/context.d.ts +18 -2
  7. package/dist/form/behaviors/index.d.ts +3 -1
  8. package/dist/form/behaviors/internals.d.ts +9 -1
  9. package/dist/form/behaviors/schema-operators.d.ts +76 -0
  10. package/dist/form/behaviors/types.d.ts +15 -3
  11. package/dist/form/create-core-form.d.ts +5 -3
  12. package/dist/form/create-form.d.ts +28 -53
  13. package/dist/form/form-bundle.d.ts +136 -0
  14. package/dist/form/index.d.ts +6 -1
  15. package/dist/form/nodes/field-node.d.ts +2 -2
  16. package/dist/form/nodes/group-node.d.ts +1 -1
  17. package/dist/form/nodes/model-array-node.d.ts +10 -5
  18. package/dist/form/schema-controller.d.ts +137 -0
  19. package/dist/form/schema-subtree.d.ts +28 -0
  20. package/dist/form/signal-node-registry.d.ts +22 -16
  21. package/dist/form/types/contracts.d.ts +6 -0
  22. package/dist/form/types/deep-schema.d.ts +2 -2
  23. package/dist/form/types/form-proxy.d.ts +1 -1
  24. package/dist/form/types/schema-node.d.ts +37 -12
  25. package/dist/form/types/validation-schema.d.ts +13 -1
  26. package/dist/form/validation/context.d.ts +6 -1
  27. package/dist/form/validation/index.d.ts +1 -1
  28. package/dist/form/validation/operators.d.ts +74 -7
  29. package/dist/form/validation/types.d.ts +2 -1
  30. package/dist/form/validators/validation-error.d.ts +8 -0
  31. package/dist/i18n/descriptor.d.ts +54 -0
  32. package/dist/i18n/en.json.d.ts +45 -0
  33. package/dist/i18n/loader.d.ts +71 -0
  34. package/dist/i18n/locale-store.d.ts +39 -0
  35. package/dist/i18n/locale.d.ts +90 -0
  36. package/dist/i18n/message-format.d.ts +116 -0
  37. package/dist/i18n/resolve-localized.d.ts +17 -0
  38. package/dist/i18n/ru.json.d.ts +45 -0
  39. package/dist/i18n/translator.d.ts +50 -0
  40. package/dist/i18n/validation-message.d.ts +18 -0
  41. package/dist/i18n.d.ts +31 -0
  42. package/dist/i18n.js +303 -0
  43. package/dist/index-BrNkQj1y.js +105 -0
  44. package/dist/index.js +737 -743
  45. package/dist/loader-Dv_Hl7JC.js +216 -0
  46. package/dist/locale/en.d.ts +2 -0
  47. package/dist/locale/en.js +5 -0
  48. package/dist/locale/en.json +42 -0
  49. package/dist/locale/index.d.ts +18 -0
  50. package/dist/locale/ru.d.ts +2 -0
  51. package/dist/locale/ru.js +41 -0
  52. package/dist/locale/ru.json +42 -0
  53. package/dist/locale.d.ts +2 -0
  54. package/dist/locale.js +9 -0
  55. package/dist/model/create-model.d.ts +17 -3
  56. package/dist/model/index.d.ts +8 -3
  57. package/dist/model/model-nodes.d.ts +67 -4
  58. package/dist/model/model-signals-proxy.d.ts +33 -1
  59. package/dist/model/model-value-proxy.d.ts +76 -0
  60. package/dist/model/types.d.ts +26 -9
  61. package/dist/model-value-proxy-caTmAiUd.js +419 -0
  62. package/dist/model.js +21 -17
  63. package/dist/node-BeV_lV5i.js +100 -0
  64. package/dist/platforms/react/form-bundle-context.d.ts +27 -0
  65. package/dist/platforms/react/hooks/types.d.ts +6 -3
  66. package/dist/platforms/react/hooks/useFormControlValue.d.ts +2 -1
  67. package/dist/platforms/react/i18n/context.d.ts +13 -0
  68. package/dist/platforms/react/i18n/hooks.d.ts +59 -0
  69. package/dist/platforms/react/i18n/provider.d.ts +52 -0
  70. package/dist/platforms/react/index.d.ts +1 -0
  71. package/dist/strategy-DgzELWno.js +204 -0
  72. package/dist/validation-error-B-U3RsV0.js +11 -0
  73. package/dist/validation.js +7 -6
  74. package/dist/validators/email.js +5 -8
  75. package/dist/validators/future-date.js +8 -11
  76. package/dist/validators/integer.js +4 -7
  77. package/dist/validators/is-date.js +5 -8
  78. package/dist/validators/is-number.js +4 -7
  79. package/dist/validators/max-age.js +8 -11
  80. package/dist/validators/max-date.js +8 -11
  81. package/dist/validators/max-length.js +5 -8
  82. package/dist/validators/max.js +4 -7
  83. package/dist/validators/min-age.js +8 -11
  84. package/dist/validators/min-date.js +8 -11
  85. package/dist/validators/min-length.js +5 -8
  86. package/dist/validators/min.js +4 -7
  87. package/dist/validators/multiple-of.js +5 -8
  88. package/dist/validators/non-negative.js +4 -7
  89. package/dist/validators/non-zero.js +4 -7
  90. package/dist/validators/past-date.js +8 -11
  91. package/dist/validators/pattern.js +5 -8
  92. package/dist/validators/phone.js +6 -9
  93. package/dist/validators/required.js +4 -7
  94. package/dist/validators/url.js +9 -14
  95. package/dist/validators.js +84 -106
  96. package/docs/llms/03-api-signatures.md +10 -4
  97. package/docs/llms/09-formschema.md +5 -5
  98. package/docs/llms/10-arrays.md +52 -3
  99. package/docs/llms/16-ui-components.md +2 -2
  100. package/docs/llms/18-conditional-fields.md +1 -1
  101. package/docs/llms/21-array-operations.md +26 -0
  102. package/docs/llms/28-submit-and-reset.md +3 -3
  103. package/docs/llms/29-async-preload.md +4 -4
  104. package/docs/llms/33-validation-strategy.md +2 -2
  105. package/docs/llms/34-i18n.md +272 -0
  106. package/docs/llms/35-unified-contract.md +246 -0
  107. package/llms-index.json +1 -1
  108. package/llms.txt +2746 -229
  109. package/package.json +22 -3
  110. package/dist/create-model-Dxh9cfLp.js +0 -97
  111. package/dist/model-signals-proxy-mV3WGdlO.js +0 -233
  112. package/dist/node-DGEFMTQu.js +0 -18
  113. package/dist/strategy-DA3JwxsR.js +0 -170
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reformer/core",
3
- "version": "11.0.0-beta.6",
3
+ "version": "11.0.0-beta.8",
4
4
  "description": "Reactive form state management library for React with signals-based architecture",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,6 +15,24 @@
15
15
  "types": "./dist/signals.d.ts",
16
16
  "import": "./dist/signals.js"
17
17
  },
18
+ "./i18n": {
19
+ "types": "./dist/i18n.d.ts",
20
+ "import": "./dist/i18n.js"
21
+ },
22
+ "./locale": {
23
+ "types": "./dist/locale.d.ts",
24
+ "import": "./dist/locale.js"
25
+ },
26
+ "./locale/en": {
27
+ "types": "./dist/locale/en.d.ts",
28
+ "import": "./dist/locale/en.js"
29
+ },
30
+ "./locale/ru": {
31
+ "types": "./dist/locale/ru.d.ts",
32
+ "import": "./dist/locale/ru.js"
33
+ },
34
+ "./locale/en.json": "./dist/locale/en.json",
35
+ "./locale/ru.json": "./dist/locale/ru.json",
18
36
  "./model": {
19
37
  "types": "./dist/model.d.ts",
20
38
  "import": "./dist/model.js"
@@ -172,12 +190,13 @@
172
190
  "use-sync-external-store": "^1.2.0"
173
191
  },
174
192
  "devDependencies": {
175
- "@types/use-sync-external-store": "^0.0.6",
176
193
  "@types/node": "^24.10.1",
177
- "tsx": "^4.19.2",
178
194
  "@types/react": "^19.2.7",
195
+ "@types/use-sync-external-store": "^0.0.6",
179
196
  "@vitest/coverage-v8": "~4.0.15",
197
+ "intl-messageformat": "^12.1.2",
180
198
  "react": "^19.2.1",
199
+ "tsx": "^4.19.2",
181
200
  "typescript": "^5.9.3",
182
201
  "vite": "^7.2.2",
183
202
  "vite-plugin-dts": "^4.5.4",
@@ -1,97 +0,0 @@
1
- import { s as p, r as v, b as f, G as g } from "./model-signals-proxy-mV3WGdlO.js";
2
- function a(t) {
3
- if (t)
4
- return t.kind === "group" ? d(t) : t.kind === "array" ? w(t) : t.read();
5
- }
6
- function w(t) {
7
- const s = {
8
- get length() {
9
- return t.items.value.length;
10
- },
11
- push: (e) => t.push(e),
12
- insertAt: (e, n) => t.insertAt(e, n),
13
- removeAt: (e) => t.removeAt(e),
14
- move: (e, n) => t.move(e, n),
15
- swap: (e, n) => t.swap(e, n),
16
- clear: () => t.clear(),
17
- at: (e) => a(t.items.value[e]),
18
- map: (e) => t.items.value.map((n, i) => e(a(n), i)),
19
- forEach: (e) => t.items.value.forEach((n, i) => e(a(n), i)),
20
- toArray: () => t.peek(),
21
- [Symbol.iterator]: function* () {
22
- const e = t.items.value;
23
- for (let n = 0; n < e.length; n++) yield a(e[n]);
24
- }
25
- };
26
- return new Proxy(s, {
27
- get: (e, n, i) => n === "__path" ? t.path : typeof n == "string" && f(n) ? a(t.items.value[Number(n)]) : Reflect.get(e, n, i),
28
- has: (e, n) => typeof n == "string" && f(n) ? Number(n) < t.items.value.length : Reflect.has(e, n)
29
- });
30
- }
31
- const u = /* @__PURE__ */ new Set([
32
- "$",
33
- "get",
34
- "set",
35
- "patch",
36
- "isDirty",
37
- "reset",
38
- "captureInitial",
39
- "signalAt"
40
- ]), h = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap();
41
- function d(t) {
42
- const s = h.get(t);
43
- if (s) return s;
44
- const e = {
45
- $: p(t),
46
- get: () => t.peek(),
47
- set: (i) => t.set(i),
48
- patch: (i) => t.set(i),
49
- isDirty: () => t.dirty(),
50
- reset: () => t.resetToInitial(),
51
- captureInitial: () => t.captureInitial(),
52
- signalAt: (i) => v(t, i)
53
- }, n = new Proxy(
54
- {},
55
- {
56
- get: (i, r) => {
57
- if (r === "__path") return t.path;
58
- if (typeof r != "string") return;
59
- const c = t.children.get(r);
60
- if (c) return a(c);
61
- if (u.has(r)) return e[r];
62
- },
63
- set: (i, r, c) => {
64
- if (typeof r != "string") return !1;
65
- const o = t.children.get(r);
66
- return o ? (o.set(c), !0) : !1;
67
- },
68
- has: (i, r) => typeof r == "string" && (t.children.has(r) || u.has(r)),
69
- ownKeys: () => [...t.children.keys()],
70
- getOwnPropertyDescriptor: (i, r) => typeof r == "string" && t.children.has(r) ? { enumerable: !0, configurable: !0 } : void 0
71
- }
72
- );
73
- return h.set(t, n), m.set(n, t), n;
74
- }
75
- function l(t, s) {
76
- if (t.kind === "leaf") {
77
- s(t.signal);
78
- return;
79
- }
80
- if (t.kind === "group") {
81
- for (const e of t.children.values()) l(e, s);
82
- return;
83
- }
84
- for (const e of t.items.value) l(e, s);
85
- }
86
- function A(t, s) {
87
- const e = m.get(t);
88
- e && l(e, s);
89
- }
90
- function _(t) {
91
- const s = new g(t, "");
92
- return d(s);
93
- }
94
- export {
95
- _ as c,
96
- A as e
97
- };
@@ -1,233 +0,0 @@
1
- import { batch as m, signal as y, computed as b } from "@preact/signals-core";
2
- const c = /* @__PURE__ */ new WeakMap();
3
- function R(t) {
4
- c.set(t, (c.get(t) ?? 0) + 1);
5
- }
6
- function S(t) {
7
- const e = c.get(t);
8
- e !== void 0 && (e <= 1 ? c.delete(t) : c.set(t, e - 1));
9
- }
10
- function A(t) {
11
- return c.has(t);
12
- }
13
- const f = (t) => !(t === null || typeof t != "object" || Array.isArray(t) || t instanceof Date || typeof Blob < "u" && t instanceof Blob || typeof File < "u" && t instanceof File), o = (t, e) => t === "" ? String(e) : `${t}.${e}`, w = (t) => /^\d+$/.test(t), l = (t) => {
14
- if (Array.isArray(t)) return t.map(l);
15
- if (f(t)) {
16
- const e = {};
17
- for (const i of Object.keys(t)) e[i] = l(t[i]);
18
- return e;
19
- }
20
- return t;
21
- }, h = (t, e) => {
22
- if (t === e) return !0;
23
- if (Array.isArray(t) && Array.isArray(e))
24
- return t.length !== e.length ? !1 : t.every((i, r) => h(i, e[r]));
25
- if (f(t) && f(e)) {
26
- const i = Object.keys(t), r = Object.keys(e);
27
- return i.length !== r.length ? !1 : i.every((s) => h(t[s], e[s]));
28
- }
29
- return !1;
30
- };
31
- class _ {
32
- constructor(e, i) {
33
- this.path = i;
34
- const r = y(e);
35
- r.__path = i, this.signal = r, this.initial = l(e);
36
- }
37
- kind = "leaf";
38
- signal;
39
- initial;
40
- rebase(e) {
41
- this.path = e, this.signal.__path = e;
42
- }
43
- /** Реактивное чтение (внутри effect/computed создаёт зависимость). */
44
- read() {
45
- return this.signal.value;
46
- }
47
- /** Нереактивный снимок. */
48
- peek() {
49
- return this.signal.peek();
50
- }
51
- set(e) {
52
- this.signal.value = e;
53
- }
54
- resetToInitial() {
55
- this.signal.value = l(this.initial);
56
- }
57
- captureInitial() {
58
- this.initial = l(this.signal.peek());
59
- }
60
- dirty() {
61
- return !h(this.signal.peek(), this.initial);
62
- }
63
- }
64
- class j {
65
- constructor(e, i) {
66
- this.path = i;
67
- for (const r of Object.keys(e))
68
- this.children.set(r, u(e[r], o(i, r)));
69
- }
70
- kind = "group";
71
- children = /* @__PURE__ */ new Map();
72
- rebase(e) {
73
- this.path = e;
74
- for (const [i, r] of this.children) r.rebase(o(e, i));
75
- }
76
- /** Реактивное чтение поддерева (внутри effect/computed подписывает на все листья группы). */
77
- read() {
78
- const e = {};
79
- for (const [i, r] of this.children) e[i] = r.read();
80
- return e;
81
- }
82
- peek() {
83
- const e = {};
84
- for (const [i, r] of this.children) e[i] = r.peek();
85
- return e;
86
- }
87
- set(e) {
88
- if (e == null || typeof e != "object") return;
89
- const i = e;
90
- m(() => {
91
- for (const [r, s] of this.children)
92
- r in i && (s.kind === "leaf" && A(s.signal) || s.set(i[r]));
93
- });
94
- }
95
- resetToInitial() {
96
- m(() => {
97
- for (const e of this.children.values()) e.resetToInitial();
98
- });
99
- }
100
- captureInitial() {
101
- for (const e of this.children.values()) e.captureInitial();
102
- }
103
- dirty() {
104
- for (const e of this.children.values()) if (e.dirty()) return !0;
105
- return !1;
106
- }
107
- }
108
- class x {
109
- constructor(e, i) {
110
- this.path = i, this.items = y(e.map((r, s) => u(r, o(i, s)))), this.initial = l(e);
111
- }
112
- kind = "array";
113
- items;
114
- initial;
115
- rebase(e) {
116
- this.path = e, this.items.peek().forEach((i, r) => i.rebase(o(e, r)));
117
- }
118
- reindex() {
119
- this.items.peek().forEach((e, i) => e.rebase(o(this.path, i)));
120
- }
121
- push(e) {
122
- const i = this.items.peek();
123
- this.items.value = [...i, u(e, o(this.path, i.length))];
124
- }
125
- insertAt(e, i) {
126
- const r = [...this.items.peek()];
127
- r.splice(e, 0, u(i, o(this.path, e))), this.items.value = r, this.reindex();
128
- }
129
- removeAt(e) {
130
- const i = [...this.items.peek()];
131
- i.splice(e, 1), this.items.value = i, this.reindex();
132
- }
133
- move(e, i) {
134
- const r = [...this.items.peek()], [s] = r.splice(e, 1);
135
- s && r.splice(i, 0, s), this.items.value = r, this.reindex();
136
- }
137
- swap(e, i) {
138
- const r = [...this.items.peek()];
139
- e < 0 || i < 0 || e >= r.length || i >= r.length || e === i || ([r[e], r[i]] = [r[i], r[e]], this.items.value = r, this.reindex());
140
- }
141
- clear() {
142
- this.items.value = [];
143
- }
144
- /**
145
- * Реактивное чтение массива. Читаем `items.value` (а не `.peek()`) — внутри effect/computed это
146
- * подписка на СОСТАВ массива, поэтому push/removeAt/move ретригерят наравне с правкой элемента.
147
- */
148
- read() {
149
- return this.items.value.map((e) => e.read());
150
- }
151
- peek() {
152
- return this.items.peek().map((e) => e.peek());
153
- }
154
- set(e) {
155
- const i = Array.isArray(e) ? e : [];
156
- this.items.value = i.map((r, s) => u(r, o(this.path, s)));
157
- }
158
- resetToInitial() {
159
- this.set(l(this.initial));
160
- }
161
- captureInitial() {
162
- this.initial = l(this.peek());
163
- }
164
- dirty() {
165
- return !h(this.peek(), this.initial);
166
- }
167
- }
168
- function u(t, e) {
169
- return Array.isArray(t) ? new x(t, e) : f(t) ? new j(t, e) : new _(t, e);
170
- }
171
- const k = /* @__PURE__ */ new WeakMap();
172
- function I(t) {
173
- const e = b(() => t.read());
174
- return {
175
- get value() {
176
- return e.value;
177
- },
178
- peek: () => e.peek(),
179
- subscribe: (i) => e.subscribe(i),
180
- valueOf: () => e.value,
181
- toString: () => String(e.value),
182
- toJSON: () => e.value,
183
- brand: e.brand
184
- };
185
- }
186
- function O(t) {
187
- if (t.kind === "leaf") return t.signal;
188
- const e = k.get(t);
189
- if (e) return e;
190
- const i = I(t), r = t.kind === "group", s = (a) => r ? t.children.get(a) : w(a) ? t.items.value[Number(a)] : void 0, d = r ? {} : {
191
- get length() {
192
- return t.items.value.length;
193
- }
194
- }, p = new Proxy(d, {
195
- get: (a, n, v) => {
196
- if (n === "__path") return t.path;
197
- if (n === "__kind") return t.kind;
198
- if (typeof n != "string") return Reflect.get(i, n, i);
199
- const g = s(n);
200
- return g ? O(g) : !r && Reflect.has(a, n) ? Reflect.get(a, n, v) : Reflect.get(i, n, i);
201
- },
202
- has: (a, n) => typeof n == "string" && (s(n) !== void 0 || !r && Reflect.has(a, n)),
203
- ownKeys: () => r ? [...t.children.keys()] : Reflect.ownKeys(d),
204
- getOwnPropertyDescriptor: (a, n) => typeof n == "string" && s(n) ? { enumerable: !0, configurable: !0 } : r ? void 0 : Reflect.getOwnPropertyDescriptor(a, n)
205
- });
206
- return k.set(t, p), p;
207
- }
208
- function D(t) {
209
- if (t == null || typeof t != "object") return !1;
210
- const e = t.__kind;
211
- return e === "group" || e === "array";
212
- }
213
- function P(t, e) {
214
- if (!e) return;
215
- let i = t;
216
- for (const r of e.split(".")) {
217
- if (!i) return;
218
- if (i.kind === "group") i = i.children.get(r);
219
- else if (i.kind === "array") i = i.items.peek()[Number(r)];
220
- else return;
221
- }
222
- return i && i.kind === "leaf" ? i.signal : void 0;
223
- }
224
- export {
225
- j as G,
226
- A as a,
227
- w as b,
228
- D as i,
229
- R as m,
230
- P as r,
231
- O as s,
232
- S as u
233
- };
@@ -1,18 +0,0 @@
1
- import { effect as i } from "@preact/signals-core";
2
- import { g as s } from "./signal-node-registry-tiwel-TV.js";
3
- import { d as f } from "./behaviors-value-C7dSEhCc.js";
4
- function a(n, r, t) {
5
- return i(() => {
6
- const o = r(), e = s(n);
7
- e && f(() => {
8
- o ? e.enable() : (e.disable(), t?.resetOnDisable && e.reset());
9
- });
10
- });
11
- }
12
- function b(n, r, t) {
13
- return a(n, () => !r(), t);
14
- }
15
- export {
16
- b as d,
17
- a as e
18
- };
@@ -1,170 +0,0 @@
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
- };