@hot-updater/console 0.33.0 → 0.33.2

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 (63) hide show
  1. package/.output/nitro.json +3 -3
  2. package/.output/public/assets/dist-DJX53faP.js +3 -0
  3. package/.output/public/assets/index-CCUspZZV.js +10 -0
  4. package/.output/public/assets/routes-D0t6y5Fr.js +54 -0
  5. package/.output/public/assets/styles-C0q26dS-.css +2 -0
  6. package/.output/server/{__tanstack-start-server-fn-resolver-ySzPUDlM.mjs → __23tanstack-start-server-fn-resolver-B12pVvhf.mjs} +32 -39
  7. package/.output/server/_chunks/ssr-renderer.mjs +14 -3
  8. package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +7 -7
  9. package/.output/server/_libs/@radix-ui/react-alert-dialog+[...].mjs +142 -93
  10. package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +32 -11
  11. package/.output/server/_libs/@radix-ui/react-select+[...].mjs +130 -95
  12. package/.output/server/_libs/@tanstack/form-core+[...].mjs +1138 -306
  13. package/.output/server/_libs/@tanstack/react-form+[...].mjs +156 -24
  14. package/.output/server/_libs/@tanstack/react-router+[...].mjs +2658 -1395
  15. package/.output/server/_libs/@tanstack/react-table+[...].mjs +1 -1
  16. package/.output/server/_libs/dayjs.mjs +6 -6
  17. package/.output/server/_libs/h3+rou3+srvx.mjs +30 -42
  18. package/.output/server/_libs/lucide-react.mjs +8 -8
  19. package/.output/server/_libs/next-themes.mjs +1 -1
  20. package/.output/server/_libs/radix-ui__number.mjs +1 -1
  21. package/.output/server/_libs/radix-ui__react-arrow.mjs +2 -2
  22. package/.output/server/_libs/radix-ui__react-collection.mjs +2 -2
  23. package/.output/server/_libs/radix-ui__react-direction.mjs +2 -2
  24. package/.output/server/_libs/radix-ui__react-label.mjs +2 -2
  25. package/.output/server/_libs/radix-ui__react-separator.mjs +2 -2
  26. package/.output/server/_libs/radix-ui__react-slider.mjs +103 -44
  27. package/.output/server/_libs/radix-ui__react-switch.mjs +88 -49
  28. package/.output/server/_libs/radix-ui__react-tooltip.mjs +6 -4
  29. package/.output/server/_libs/semver.mjs +97 -52
  30. package/.output/server/_libs/sonner.mjs +1 -1
  31. package/.output/server/_libs/tailwind-merge.mjs +51 -3
  32. package/.output/server/_libs/tanstack__history.mjs +28 -8
  33. package/.output/server/_libs/tanstack__query-core.mjs +200 -174
  34. package/.output/server/_libs/tanstack__react-query.mjs +14 -13
  35. package/.output/server/_ssr/{api-rpc-Bwustks9.mjs → api-rpc-ORImfBFu.mjs} +18 -18
  36. package/.output/server/_ssr/{config.server-xu3W-WAK.mjs → config.server-BSS366KT.mjs} +2 -2
  37. package/.output/server/_ssr/{createServerFn-CdeRXnVy.mjs → createServerFn-DzU0k62V.mjs} +129 -90
  38. package/.output/server/_ssr/{deleteBundle-CXxwjwEZ.mjs → deleteBundle-CuujBAH8.mjs} +2 -2
  39. package/.output/server/_ssr/{dist-CRiLZLfa.mjs → dist-KboydRVk.mjs} +1 -1
  40. package/.output/server/_ssr/empty-plugin-adapters-B4HCzgmM.mjs +5 -0
  41. package/.output/server/_ssr/{getBundleChildren-DFqZ6XMp.mjs → getBundleChildren-CVtSiH5t.mjs} +2 -2
  42. package/.output/server/_ssr/{router-1tw3jh6y.mjs → router-DmdnzGpe.mjs} +7 -8
  43. package/.output/server/_ssr/{routes-D5CmWxI7.mjs → routes-Be7gDfJS.mjs} +36 -39
  44. package/.output/server/_ssr/{sidebar-CgbtXkE2.mjs → sidebar-Cv_H0_Jv.mjs} +5 -5
  45. package/.output/server/_ssr/ssr.mjs +4222 -3153
  46. package/.output/server/_ssr/start-D4SBEASt.mjs +4 -0
  47. package/.output/server/_ssr/{storageProfile-wICk5nZZ.mjs → storageProfile-FVkjPoGb.mjs} +1 -1
  48. package/.output/server/_tanstack-start-manifest_v-BroBMdSR.mjs +20 -0
  49. package/.output/server/index.mjs +128 -172
  50. package/package.json +12 -9
  51. package/.output/public/assets/BaseTanStackRouterDevtoolsPanel-Bmws3ikM-q5p5qKUx.js +0 -486
  52. package/.output/public/assets/FloatingTanStackRouterDevtools-B7vy70jP-Bzs2Gthe.js +0 -1
  53. package/.output/public/assets/clsx-CbprLf2V.js +0 -1
  54. package/.output/public/assets/dist-BzU1qUss.js +0 -9
  55. package/.output/public/assets/main-CmNeAg9B.js +0 -10
  56. package/.output/public/assets/preload-helper-C5ST2IKa.js +0 -1
  57. package/.output/public/assets/routes-wJZuGodi.js +0 -54
  58. package/.output/public/assets/styles-DEbMLh52.css +0 -2
  59. package/.output/server/_libs/hookable.mjs +0 -41
  60. package/.output/server/_libs/tanstack__router-core.mjs +0 -6
  61. package/.output/server/_libs/unctx.mjs +0 -82
  62. package/.output/server/_ssr/start-CoRKunFF.mjs +0 -4
  63. package/.output/server/_tanstack-start-manifest_v-AftZl081.mjs +0 -22
@@ -1,24 +1,25 @@
1
1
  import { t as EventClient } from "./devtools-event-client+[...].mjs";
2
- //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/alien.js
3
- var ReactiveFlags = /* @__PURE__ */ ((ReactiveFlags2) => {
4
- ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
5
- ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
6
- ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
7
- ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
8
- ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
9
- ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
10
- ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
11
- return ReactiveFlags2;
12
- })(ReactiveFlags || {});
2
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.11.0/node_modules/@tanstack/store/dist/alien.js
3
+ var ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
4
+ ReactiveFlags[ReactiveFlags["None"] = 0] = "None";
5
+ ReactiveFlags[ReactiveFlags["Mutable"] = 1] = "Mutable";
6
+ ReactiveFlags[ReactiveFlags["Watching"] = 2] = "Watching";
7
+ ReactiveFlags[ReactiveFlags["RecursedCheck"] = 4] = "RecursedCheck";
8
+ ReactiveFlags[ReactiveFlags["Recursed"] = 8] = "Recursed";
9
+ ReactiveFlags[ReactiveFlags["Dirty"] = 16] = "Dirty";
10
+ ReactiveFlags[ReactiveFlags["Pending"] = 32] = "Pending";
11
+ return ReactiveFlags;
12
+ }({});
13
+ /* @__NO_SIDE_EFFECTS__ */
13
14
  function createReactiveSystem({ update, notify, unwatched }) {
14
15
  return {
15
- link: link2,
16
- unlink: unlink2,
17
- propagate: propagate2,
18
- checkDirty: checkDirty2,
19
- shallowPropagate: shallowPropagate2
16
+ link,
17
+ unlink,
18
+ propagate,
19
+ checkDirty,
20
+ shallowPropagate
20
21
  };
21
- function link2(dep, sub, version) {
22
+ function link(dep, sub, version) {
22
23
  const prevDep = sub.depsTail;
23
24
  if (prevDep !== void 0 && prevDep.dep === dep) return;
24
25
  const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
@@ -44,12 +45,12 @@ function createReactiveSystem({ update, notify, unwatched }) {
44
45
  if (prevSub !== void 0) prevSub.nextSub = newLink;
45
46
  else dep.subs = newLink;
46
47
  }
47
- function unlink2(link3, sub = link3.sub) {
48
- const dep = link3.dep;
49
- const prevDep = link3.prevDep;
50
- const nextDep = link3.nextDep;
51
- const nextSub = link3.nextSub;
52
- const prevSub = link3.prevSub;
48
+ function unlink(link, sub = link.sub) {
49
+ const dep = link.dep;
50
+ const prevDep = link.prevDep;
51
+ const nextDep = link.nextDep;
52
+ const nextSub = link.nextSub;
53
+ const prevSub = link.prevSub;
53
54
  if (nextDep !== void 0) nextDep.prevDep = prevDep;
54
55
  else sub.depsTail = prevDep;
55
56
  if (prevDep !== void 0) prevDep.nextDep = nextDep;
@@ -60,24 +61,24 @@ function createReactiveSystem({ update, notify, unwatched }) {
60
61
  else if ((dep.subs = nextSub) === void 0) unwatched(dep);
61
62
  return nextDep;
62
63
  }
63
- function propagate2(link3) {
64
- let next = link3.nextSub;
64
+ function propagate(link) {
65
+ let next = link.nextSub;
65
66
  let stack;
66
67
  top: do {
67
- const sub = link3.sub;
68
+ const sub = link.sub;
68
69
  let flags = sub.flags;
69
- if (!(flags & 60)) sub.flags = flags | 32;
70
- else if (!(flags & 12)) flags = 0;
71
- else if (!(flags & 4)) sub.flags = flags & -9 | 32;
72
- else if (!(flags & 48) && isValidLink(link3, sub)) {
73
- sub.flags = flags | 40;
74
- flags &= 1;
75
- } else flags = 0;
76
- if (flags & 2) notify(sub);
77
- if (flags & 1) {
70
+ if (!(flags & (ReactiveFlags.RecursedCheck | ReactiveFlags.Recursed | ReactiveFlags.Dirty | ReactiveFlags.Pending))) sub.flags = flags | ReactiveFlags.Pending;
71
+ else if (!(flags & (ReactiveFlags.RecursedCheck | ReactiveFlags.Recursed))) flags = ReactiveFlags.None;
72
+ else if (!(flags & ReactiveFlags.RecursedCheck)) sub.flags = flags & ~ReactiveFlags.Recursed | ReactiveFlags.Pending;
73
+ else if (!(flags & (ReactiveFlags.Dirty | ReactiveFlags.Pending)) && isValidLink(link, sub)) {
74
+ sub.flags = flags | (ReactiveFlags.Recursed | ReactiveFlags.Pending);
75
+ flags &= ReactiveFlags.Mutable;
76
+ } else flags = ReactiveFlags.None;
77
+ if (flags & ReactiveFlags.Watching) notify(sub);
78
+ if (flags & ReactiveFlags.Mutable) {
78
79
  const subSubs = sub.subs;
79
80
  if (subSubs !== void 0) {
80
- const nextSub = (link3 = subSubs).nextSub;
81
+ const nextSub = (link = subSubs).nextSub;
81
82
  if (nextSub !== void 0) {
82
83
  stack = {
83
84
  value: next,
@@ -88,49 +89,49 @@ function createReactiveSystem({ update, notify, unwatched }) {
88
89
  continue;
89
90
  }
90
91
  }
91
- if ((link3 = next) !== void 0) {
92
- next = link3.nextSub;
92
+ if ((link = next) !== void 0) {
93
+ next = link.nextSub;
93
94
  continue;
94
95
  }
95
96
  while (stack !== void 0) {
96
- link3 = stack.value;
97
+ link = stack.value;
97
98
  stack = stack.prev;
98
- if (link3 !== void 0) {
99
- next = link3.nextSub;
99
+ if (link !== void 0) {
100
+ next = link.nextSub;
100
101
  continue top;
101
102
  }
102
103
  }
103
104
  break;
104
105
  } while (true);
105
106
  }
106
- function checkDirty2(link3, sub) {
107
+ function checkDirty(link, sub) {
107
108
  let stack;
108
109
  let checkDepth = 0;
109
110
  let dirty = false;
110
111
  top: do {
111
- const dep = link3.dep;
112
+ const dep = link.dep;
112
113
  const flags = dep.flags;
113
- if (sub.flags & 16) dirty = true;
114
- else if ((flags & 17) === 17) {
114
+ if (sub.flags & ReactiveFlags.Dirty) dirty = true;
115
+ else if ((flags & (ReactiveFlags.Mutable | ReactiveFlags.Dirty)) === (ReactiveFlags.Mutable | ReactiveFlags.Dirty)) {
115
116
  if (update(dep)) {
116
117
  const subs = dep.subs;
117
- if (subs.nextSub !== void 0) shallowPropagate2(subs);
118
+ if (subs.nextSub !== void 0) shallowPropagate(subs);
118
119
  dirty = true;
119
120
  }
120
- } else if ((flags & 33) === 33) {
121
- if (link3.nextSub !== void 0 || link3.prevSub !== void 0) stack = {
122
- value: link3,
121
+ } else if ((flags & (ReactiveFlags.Mutable | ReactiveFlags.Pending)) === (ReactiveFlags.Mutable | ReactiveFlags.Pending)) {
122
+ if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
123
+ value: link,
123
124
  prev: stack
124
125
  };
125
- link3 = dep.deps;
126
+ link = dep.deps;
126
127
  sub = dep;
127
128
  ++checkDepth;
128
129
  continue;
129
130
  }
130
131
  if (!dirty) {
131
- const nextDep = link3.nextDep;
132
+ const nextDep = link.nextDep;
132
133
  if (nextDep !== void 0) {
133
- link3 = nextDep;
134
+ link = nextDep;
134
135
  continue;
135
136
  }
136
137
  }
@@ -138,148 +139,48 @@ function createReactiveSystem({ update, notify, unwatched }) {
138
139
  const firstSub = sub.subs;
139
140
  const hasMultipleSubs = firstSub.nextSub !== void 0;
140
141
  if (hasMultipleSubs) {
141
- link3 = stack.value;
142
+ link = stack.value;
142
143
  stack = stack.prev;
143
- } else link3 = firstSub;
144
+ } else link = firstSub;
144
145
  if (dirty) {
145
146
  if (update(sub)) {
146
- if (hasMultipleSubs) shallowPropagate2(firstSub);
147
- sub = link3.sub;
147
+ if (hasMultipleSubs) shallowPropagate(firstSub);
148
+ sub = link.sub;
148
149
  continue;
149
150
  }
150
151
  dirty = false;
151
- } else sub.flags &= -33;
152
- sub = link3.sub;
153
- const nextDep = link3.nextDep;
152
+ } else sub.flags &= ~ReactiveFlags.Pending;
153
+ sub = link.sub;
154
+ const nextDep = link.nextDep;
154
155
  if (nextDep !== void 0) {
155
- link3 = nextDep;
156
+ link = nextDep;
156
157
  continue top;
157
158
  }
158
159
  }
159
160
  return dirty;
160
161
  } while (true);
161
162
  }
162
- function shallowPropagate2(link3) {
163
+ function shallowPropagate(link) {
163
164
  do {
164
- const sub = link3.sub;
165
+ const sub = link.sub;
165
166
  const flags = sub.flags;
166
- if ((flags & 48) === 32) {
167
- sub.flags = flags | 16;
168
- if ((flags & 6) === 2) notify(sub);
167
+ if ((flags & (ReactiveFlags.Pending | ReactiveFlags.Dirty)) === ReactiveFlags.Pending) {
168
+ sub.flags = flags | ReactiveFlags.Dirty;
169
+ if ((flags & (ReactiveFlags.Watching | ReactiveFlags.RecursedCheck)) === ReactiveFlags.Watching) notify(sub);
169
170
  }
170
- } while ((link3 = link3.nextSub) !== void 0);
171
+ } while ((link = link.nextSub) !== void 0);
171
172
  }
172
173
  function isValidLink(checkLink, sub) {
173
- let link3 = sub.depsTail;
174
- while (link3 !== void 0) {
175
- if (link3 === checkLink) return true;
176
- link3 = link3.prevDep;
174
+ let link = sub.depsTail;
175
+ while (link !== void 0) {
176
+ if (link === checkLink) return true;
177
+ link = link.prevDep;
177
178
  }
178
179
  return false;
179
180
  }
180
181
  }
181
- var batchDepth = 0;
182
- var notifyIndex$1 = 0;
183
- var queuedLength = 0;
184
- var queued = [];
185
- var { link: link$1, unlink: unlink$1, propagate: propagate$1, checkDirty: checkDirty$1, shallowPropagate: shallowPropagate$1 } = createReactiveSystem({
186
- update(node) {
187
- if (node.depsTail !== void 0) return updateComputed(node);
188
- else return updateSignal(node);
189
- },
190
- notify(effect2) {
191
- let insertIndex = queuedLength;
192
- let firstInsertedIndex = insertIndex;
193
- do {
194
- queued[insertIndex++] = effect2;
195
- effect2.flags &= -3;
196
- effect2 = effect2.subs?.sub;
197
- if (effect2 === void 0 || !(effect2.flags & 2)) break;
198
- } while (true);
199
- queuedLength = insertIndex;
200
- while (firstInsertedIndex < --insertIndex) {
201
- const left = queued[firstInsertedIndex];
202
- queued[firstInsertedIndex++] = queued[insertIndex];
203
- queued[insertIndex] = left;
204
- }
205
- },
206
- unwatched(node) {
207
- if (!(node.flags & 1)) effectScopeOper.call(node);
208
- else if (node.depsTail !== void 0) {
209
- node.depsTail = void 0;
210
- node.flags = 17;
211
- purgeDeps$1(node);
212
- }
213
- }
214
- });
215
- function getBatchDepth() {
216
- return batchDepth;
217
- }
218
- function startBatch() {
219
- ++batchDepth;
220
- }
221
- function endBatch() {
222
- if (!--batchDepth) flush$1();
223
- }
224
- function updateComputed(c) {
225
- c.depsTail = void 0;
226
- c.flags = 5;
227
- try {
228
- const oldValue = c.value;
229
- return oldValue !== (c.value = c.getter(oldValue));
230
- } finally {
231
- c.flags &= -5;
232
- purgeDeps$1(c);
233
- }
234
- }
235
- function updateSignal(s) {
236
- s.flags = 1;
237
- return s.currentValue !== (s.currentValue = s.pendingValue);
238
- }
239
- function run(e) {
240
- const flags = e.flags;
241
- if (flags & 16 || flags & 32 && checkDirty$1(e.deps, e)) {
242
- e.depsTail = void 0;
243
- e.flags = 6;
244
- try {
245
- e.fn();
246
- } finally {
247
- e.flags &= -5;
248
- purgeDeps$1(e);
249
- }
250
- } else e.flags = 2;
251
- }
252
- function flush$1() {
253
- try {
254
- while (notifyIndex$1 < queuedLength) {
255
- const effect2 = queued[notifyIndex$1];
256
- queued[notifyIndex$1++] = void 0;
257
- run(effect2);
258
- }
259
- } finally {
260
- while (notifyIndex$1 < queuedLength) {
261
- const effect2 = queued[notifyIndex$1];
262
- queued[notifyIndex$1++] = void 0;
263
- effect2.flags |= 10;
264
- }
265
- notifyIndex$1 = 0;
266
- queuedLength = 0;
267
- }
268
- }
269
- function effectScopeOper() {
270
- this.depsTail = void 0;
271
- this.flags = 0;
272
- purgeDeps$1(this);
273
- const sub = this.subs;
274
- if (sub !== void 0) unlink$1(sub);
275
- }
276
- function purgeDeps$1(sub) {
277
- const depsTail = sub.depsTail;
278
- let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
279
- while (dep !== void 0) dep = unlink$1(dep, sub);
280
- }
281
182
  //#endregion
282
- //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/atom.js
183
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.11.0/node_modules/@tanstack/store/dist/atom.js
283
184
  function toObserver(nextHandler, errorHandler, completionHandler) {
284
185
  const isObserver = typeof nextHandler === "object";
285
186
  const self = isObserver ? nextHandler : void 0;
@@ -291,13 +192,13 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
291
192
  }
292
193
  var queuedEffects = [];
293
194
  var cycle = 0;
294
- var { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSystem({
195
+ var { link, unlink, propagate, checkDirty, shallowPropagate } = /* @__PURE__ */ createReactiveSystem({
295
196
  update(atom) {
296
197
  return atom._update();
297
198
  },
298
- notify(effect2) {
299
- queuedEffects[queuedEffectsLength++] = effect2;
300
- effect2.flags &= ~ReactiveFlags.Watching;
199
+ notify(effect) {
200
+ queuedEffects[queuedEffectsLength++] = effect;
201
+ effect.flags &= ~ReactiveFlags.Watching;
301
202
  },
302
203
  unwatched(atom) {
303
204
  if (atom.depsTail !== void 0) {
@@ -310,17 +211,26 @@ var { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSy
310
211
  var notifyIndex = 0;
311
212
  var queuedEffectsLength = 0;
312
213
  var activeSub;
214
+ var batchDepth = 0;
215
+ function batch(fn) {
216
+ try {
217
+ ++batchDepth;
218
+ fn();
219
+ } finally {
220
+ if (!--batchDepth) flush();
221
+ }
222
+ }
313
223
  function purgeDeps(sub) {
314
224
  const depsTail = sub.depsTail;
315
225
  let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
316
226
  while (dep !== void 0) dep = unlink(dep, sub);
317
227
  }
318
228
  function flush() {
319
- if (getBatchDepth() > 0) return;
229
+ if (batchDepth > 0) return;
320
230
  while (notifyIndex < queuedEffectsLength) {
321
- const effect2 = queuedEffects[notifyIndex];
231
+ const effect = queuedEffects[notifyIndex];
322
232
  queuedEffects[notifyIndex++] = void 0;
323
- effect2.notify();
233
+ effect.notify();
324
234
  }
325
235
  notifyIndex = 0;
326
236
  queuedEffectsLength = 0;
@@ -388,8 +298,8 @@ function createAtom(valueOrFn, options) {
388
298
  if (activeSub !== void 0) link(atom, activeSub, cycle);
389
299
  return atom._snapshot;
390
300
  };
391
- } else atom.set = function(valueOrFn2) {
392
- if (atom._update(valueOrFn2)) {
301
+ } else atom.set = function(valueOrFn) {
302
+ if (atom._update(valueOrFn)) {
393
303
  const subs = atom.subs;
394
304
  if (subs !== void 0) {
395
305
  propagate(subs);
@@ -436,10 +346,14 @@ function effect(fn) {
436
346
  return effectObj;
437
347
  }
438
348
  //#endregion
439
- //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/store.js
349
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.11.0/node_modules/@tanstack/store/dist/store.js
440
350
  var Store = class {
441
- constructor(valueOrFn) {
351
+ constructor(valueOrFn, actionsFactory) {
442
352
  this.atom = createAtom(valueOrFn);
353
+ this.get = this.get.bind(this);
354
+ this.setState = this.setState.bind(this);
355
+ this.subscribe = this.subscribe.bind(this);
356
+ if (actionsFactory) this.actions = actionsFactory(this);
443
357
  }
444
358
  setState(updater) {
445
359
  this.atom.set(updater);
@@ -468,22 +382,12 @@ var ReadonlyStore = class {
468
382
  return this.atom.subscribe(toObserver(observerOrFn));
469
383
  }
470
384
  };
471
- function createStore(valueOrFn) {
385
+ function createStore(valueOrFn, actions) {
472
386
  if (typeof valueOrFn === "function") return new ReadonlyStore(valueOrFn);
387
+ if (actions) return new Store(valueOrFn, actions);
473
388
  return new Store(valueOrFn);
474
389
  }
475
390
  //#endregion
476
- //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/batch.js
477
- function batch(fn) {
478
- try {
479
- startBatch();
480
- fn();
481
- } finally {
482
- endBatch();
483
- flush();
484
- }
485
- }
486
- //#endregion
487
391
  //#region ../../node_modules/.pnpm/@tanstack+pacer-lite@0.1.1/node_modules/@tanstack/pacer-lite/dist/lite-throttler.js
488
392
  /**
489
393
  * A lightweight class that creates a throttled function.
@@ -606,7 +510,7 @@ function liteThrottle(fn, options) {
606
510
  return new LiteThrottler(fn, options).maybeExecute;
607
511
  }
608
512
  //#endregion
609
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/EventClient.js
513
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/EventClient.js
610
514
  var FormEventClient = class extends EventClient {
611
515
  constructor() {
612
516
  super({
@@ -617,7 +521,7 @@ var FormEventClient = class extends EventClient {
617
521
  };
618
522
  var formEventClient = new FormEventClient();
619
523
  //#endregion
620
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/utils.js
524
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/utils.js
621
525
  function functionalUpdate(updater, input) {
622
526
  return typeof updater === "function" ? updater(input) : updater;
623
527
  }
@@ -686,25 +590,39 @@ function deleteBy(obj, _path) {
686
590
  }
687
591
  return doDelete(obj);
688
592
  }
689
- var reLineOfOnlyDigits = /^(\d+)$/gm;
690
- var reDigitsBetweenDots = /\.(\d+)(?=\.)/gm;
691
- var reStartWithDigitThenDot = /^(\d+)\./gm;
692
- var reDotWithDigitsToEnd = /\.(\d+$)/gm;
693
- var reMultipleDots = /\.{2,}/gm;
694
- var intPrefix = "__int__";
695
- var intReplace = `${intPrefix}$1`;
593
+ var CC_DOT = 46;
594
+ var CC_OPEN = 91;
595
+ var CC_CLOSE = 93;
596
+ var CC_ZERO = 48;
597
+ var CC_NINE = 57;
696
598
  function makePathArray(str) {
697
599
  if (Array.isArray(str)) return [...str];
698
600
  if (typeof str !== "string") throw new Error("Path must be a string.");
699
- return str.replace(/(^\[)|]/gm, "").replace(/\[/g, ".").replace(reLineOfOnlyDigits, intReplace).replace(reDigitsBetweenDots, `.${intReplace}.`).replace(reStartWithDigitThenDot, `${intReplace}.`).replace(reDotWithDigitsToEnd, `.${intReplace}`).replace(reMultipleDots, ".").split(".").map((d) => {
700
- if (d.startsWith(intPrefix)) {
701
- const numStr = d.substring(7);
702
- const num = parseInt(numStr, 10);
703
- if (String(num) === numStr) return num;
704
- return numStr;
705
- }
706
- return d;
707
- });
601
+ const len = str.length;
602
+ const result = [];
603
+ let segStart = len > 0 && str.charCodeAt(0) === CC_OPEN ? 1 : 0;
604
+ let allDigits = true;
605
+ let prev = -1;
606
+ for (let i = segStart; i <= len; i++) {
607
+ const char = i < len ? str.charCodeAt(i) : -1;
608
+ if (i === len || char === CC_DOT || char === CC_OPEN || char === CC_CLOSE) {
609
+ const segLen = i - segStart;
610
+ if (segLen > 0) {
611
+ const treatAsNumber = allDigits && (segLen === 1 || str.charCodeAt(segStart) !== CC_ZERO);
612
+ const seg = str.slice(segStart, i);
613
+ if (treatAsNumber) {
614
+ const num = parseInt(seg, 10);
615
+ if (segLen <= 15 || String(num) === seg) result.push(num);
616
+ else result.push(seg);
617
+ } else result.push(seg);
618
+ } else if (prev !== CC_CLOSE && !(prev === -1 && char === CC_CLOSE) && !(prev === char && (char === CC_DOT || char === CC_OPEN))) result.push("");
619
+ segStart = i + 1;
620
+ allDigits = true;
621
+ } else if (char < CC_ZERO || char > CC_NINE) allDigits = false;
622
+ prev = char;
623
+ }
624
+ if (!result.length) result.push("");
625
+ return result;
708
626
  }
709
627
  function isNonEmptyArray(obj) {
710
628
  return !(Array.isArray(obj) && obj.length === 0);
@@ -720,9 +638,11 @@ function getSyncValidatorArray(cause, options) {
720
638
  };
721
639
  return options.validationLogic({
722
640
  form: options.form,
641
+ group: options.group,
723
642
  validators: options.validators,
724
643
  event: {
725
644
  type: cause,
645
+ fieldName: options.fieldName,
726
646
  async: false
727
647
  },
728
648
  runValidation
@@ -760,9 +680,11 @@ function getAsyncValidatorArray(cause, options) {
760
680
  };
761
681
  return options.validationLogic({
762
682
  form: options.form,
683
+ group: options.group,
763
684
  validators: options.validators,
764
685
  event: {
765
686
  type: cause,
687
+ fieldName: options.fieldName,
766
688
  async: true
767
689
  },
768
690
  runValidation
@@ -788,6 +710,7 @@ function evaluate(objA, objB) {
788
710
  const keysA = Object.keys(objA);
789
711
  const keysB = Object.keys(objB);
790
712
  if (keysA.length !== keysB.length) return false;
713
+ if (keysA.length === 0 && !Array.isArray(objA) && !Array.isArray(objB) && (Object.getPrototypeOf(objA) !== Object.prototype || Object.getPrototypeOf(objB) !== Object.prototype)) return false;
791
714
  for (const key of keysA) if (!keysB.includes(key) || !evaluate(objA[key], objB[key])) return false;
792
715
  return true;
793
716
  }
@@ -885,8 +808,11 @@ function deepCopy(obj) {
885
808
  for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) copy[key] = deepCopy(obj[key]);
886
809
  return copy;
887
810
  }
811
+ function isFieldInGroup(groupName, fieldName) {
812
+ return fieldName === groupName || fieldName.startsWith(`${groupName}.`) || fieldName.startsWith(`${groupName}[`);
813
+ }
888
814
  //#endregion
889
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js
815
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js
890
816
  var defaultValidationLogic = (props) => {
891
817
  if (!props.validators) return props.runValidation({
892
818
  validators: [],
@@ -943,7 +869,7 @@ var defaultValidationLogic = (props) => {
943
869
  }
944
870
  };
945
871
  //#endregion
946
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js
872
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js
947
873
  function prefixSchemaToErrors(issues, formValue) {
948
874
  const schema = /* @__PURE__ */ new Map();
949
875
  for (const issue of issues) {
@@ -988,7 +914,7 @@ var standardSchemaValidators = {
988
914
  };
989
915
  var isStandardSchemaValidator = (validator) => !!validator && "~standard" in validator;
990
916
  //#endregion
991
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/metaHelper.js
917
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/metaHelper.js
992
918
  var defaultFieldMeta = {
993
919
  isValidating: false,
994
920
  isTouched: false,
@@ -999,10 +925,19 @@ var defaultFieldMeta = {
999
925
  isDefaultValue: true,
1000
926
  errors: [],
1001
927
  errorMap: {},
1002
- errorSourceMap: {}
928
+ errorSourceMap: {},
929
+ _arrayVersion: 0
1003
930
  };
1004
931
  function metaHelper(formApi) {
932
+ function bumpArrayVersion(field) {
933
+ const currentMeta = formApi.getFieldMeta(field) ?? defaultFieldMeta;
934
+ formApi.setFieldMeta(field, {
935
+ ...currentMeta,
936
+ _arrayVersion: (currentMeta._arrayVersion || 0) + 1
937
+ });
938
+ }
1005
939
  function handleArrayMove(field, fromIndex, toIndex) {
940
+ bumpArrayVersion(field);
1006
941
  const affectedFields = getAffectedFields(field, fromIndex, "move", toIndex);
1007
942
  const startIndex = Math.min(fromIndex, toIndex);
1008
943
  const endIndex = Math.max(fromIndex, toIndex);
@@ -1019,9 +954,11 @@ function metaHelper(formApi) {
1019
954
  });
1020
955
  }
1021
956
  function handleArrayRemove(field, index) {
957
+ bumpArrayVersion(field);
1022
958
  shiftMeta(getAffectedFields(field, index, "remove"), "up");
1023
959
  }
1024
960
  function handleArraySwap(field, index, secondIndex) {
961
+ bumpArrayVersion(field);
1025
962
  getAffectedFields(field, index, "swap", secondIndex).forEach((fieldKey) => {
1026
963
  if (!fieldKey.toString().startsWith(getFieldPath(field, index))) return;
1027
964
  const swappedKey = fieldKey.toString().replace(getFieldPath(field, index), getFieldPath(field, secondIndex));
@@ -1031,6 +968,7 @@ function metaHelper(formApi) {
1031
968
  });
1032
969
  }
1033
970
  function handleArrayInsert(field, insertIndex) {
971
+ bumpArrayVersion(field);
1034
972
  const affectedFields = getAffectedFields(field, insertIndex, "insert");
1035
973
  shiftMeta(affectedFields, "down");
1036
974
  affectedFields.forEach((fieldKey) => {
@@ -1076,6 +1014,7 @@ function metaHelper(formApi) {
1076
1014
  }
1077
1015
  const getEmptyFieldMeta = () => defaultFieldMeta;
1078
1016
  return {
1017
+ bumpArrayVersion,
1079
1018
  handleArrayMove,
1080
1019
  handleArrayRemove,
1081
1020
  handleArraySwap,
@@ -1083,12 +1022,13 @@ function metaHelper(formApi) {
1083
1022
  };
1084
1023
  }
1085
1024
  //#endregion
1086
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/FormApi.js
1025
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/FormApi.js
1087
1026
  function getDefaultFormState(defaultState) {
1088
1027
  return {
1089
1028
  values: defaultState.values ?? {},
1090
1029
  errorMap: defaultState.errorMap ?? {},
1091
1030
  fieldMetaBase: defaultState.fieldMetaBase ?? {},
1031
+ formGroupStateBase: defaultState.formGroupStateBase ?? {},
1092
1032
  isSubmitted: defaultState.isSubmitted ?? false,
1093
1033
  isSubmitting: defaultState.isSubmitting ?? false,
1094
1034
  isValidating: defaultState.isValidating ?? false,
@@ -1111,6 +1051,7 @@ var FormApi = class {
1111
1051
  constructor(opts) {
1112
1052
  this.options = {};
1113
1053
  this.fieldInfo = {};
1054
+ this.formGroupApis = /* @__PURE__ */ new Set();
1114
1055
  this.mount = () => {
1115
1056
  const cleanupDevtoolBroadcast = this.store.subscribe(() => {
1116
1057
  throttleFormState(this);
@@ -1160,6 +1101,10 @@ var FormApi = class {
1160
1101
  batch(() => {
1161
1102
  this.baseStore.setState(() => getDefaultFormState(Object.assign({}, this.state, shouldUpdateState ? options.defaultState : {}, shouldUpdateValues ? { values: options.defaultValues } : {})));
1162
1103
  });
1104
+ if (shouldUpdateValues) {
1105
+ const helper = metaHelper(this);
1106
+ for (const fieldKey of Object.keys(this.fieldInfo)) if (Array.isArray(this.getFieldValue(fieldKey))) helper.bumpArrayVersion(fieldKey);
1107
+ }
1163
1108
  formEventClient.emit("form-api", {
1164
1109
  id: this._formId,
1165
1110
  state: this.store.state,
@@ -1173,11 +1118,17 @@ var FormApi = class {
1173
1118
  ...this.options,
1174
1119
  defaultValues: values
1175
1120
  };
1176
- this.baseStore.setState(() => getDefaultFormState({
1177
- ...this.options.defaultState,
1178
- values: values ?? this.options.defaultValues ?? this.options.defaultState?.values,
1179
- fieldMetaBase
1180
- }));
1121
+ this.baseStore.setState(() => {
1122
+ let nextValues = values ?? this.options.defaultValues ?? this.options.defaultState?.values;
1123
+ if (!values) Object.values(this.fieldInfo).forEach((fieldInfo) => {
1124
+ if (fieldInfo.instance && fieldInfo.instance.options.defaultValue !== void 0) nextValues = setBy(nextValues, fieldInfo.instance.name, fieldInfo.instance.options.defaultValue);
1125
+ });
1126
+ return getDefaultFormState({
1127
+ ...this.options.defaultState,
1128
+ values: nextValues,
1129
+ fieldMetaBase
1130
+ });
1131
+ });
1181
1132
  };
1182
1133
  this.validateAllFields = async (cause) => {
1183
1134
  const fieldValidationPromises = [];
@@ -1185,8 +1136,11 @@ var FormApi = class {
1185
1136
  Object.values(this.fieldInfo).forEach((field) => {
1186
1137
  if (!field.instance) return;
1187
1138
  const fieldInstance = field.instance;
1188
- fieldValidationPromises.push(Promise.resolve().then(() => fieldInstance.validate(cause, { skipFormValidation: true })));
1189
- if (!field.instance.state.meta.isTouched) field.instance.setMeta((prev) => ({
1139
+ fieldValidationPromises.push(Promise.resolve().then(() => fieldInstance.validate(cause, {
1140
+ skipFormValidation: true,
1141
+ skipGroupValidation: true
1142
+ })));
1143
+ if (!field.instance.store.state.meta.isTouched) field.instance.setMeta((prev) => ({
1190
1144
  ...prev,
1191
1145
  isTouched: true
1192
1146
  }));
@@ -1217,16 +1171,17 @@ var FormApi = class {
1217
1171
  return this.getFieldMeta(field)?.errors ?? [];
1218
1172
  });
1219
1173
  }
1220
- if (!fieldInstance.state.meta.isTouched) fieldInstance.setMeta((prev) => ({
1174
+ if (!fieldInstance.store.state.meta.isTouched) fieldInstance.setMeta((prev) => ({
1221
1175
  ...prev,
1222
1176
  isTouched: true
1223
1177
  }));
1224
1178
  return fieldInstance.validate(cause);
1225
1179
  };
1226
- this.validateSync = (cause) => {
1180
+ this.validateSync = (cause, validateOpts) => {
1227
1181
  const validates = getSyncValidatorArray(cause, {
1228
1182
  ...this.options,
1229
1183
  form: this,
1184
+ group: validateOpts?.group,
1230
1185
  validationLogic: this.options.validationLogic || defaultValidationLogic
1231
1186
  });
1232
1187
  let hasErrored = false;
@@ -1234,7 +1189,7 @@ var FormApi = class {
1234
1189
  batch(() => {
1235
1190
  for (const validateObj of validates) {
1236
1191
  if (!validateObj.validate) continue;
1237
- const { formError, fieldErrors } = normalizeError$1(this.runValidator({
1192
+ const { formError, fieldErrors } = normalizeError$2(this.runValidator({
1238
1193
  validate: validateObj.validate,
1239
1194
  value: {
1240
1195
  value: this.state.values,
@@ -1243,8 +1198,9 @@ var FormApi = class {
1243
1198
  },
1244
1199
  type: "validate"
1245
1200
  }));
1246
- const errorMapKey = getErrorMapKey$1(validateObj.cause);
1247
- const allFieldsToProcess = /* @__PURE__ */ new Set([...Object.keys(this.state.fieldMeta), ...Object.keys(fieldErrors || {})]);
1201
+ const errorMapKey = getErrorMapKey$2(validateObj.cause);
1202
+ let allFieldsToProcess = /* @__PURE__ */ new Set([...Object.keys(this.state.fieldMeta), ...Object.keys(fieldErrors || {})]);
1203
+ if (validateOpts?.filterFieldNames) allFieldsToProcess = new Set([...allFieldsToProcess].filter(validateOpts.filterFieldNames));
1248
1204
  for (const field of allFieldsToProcess) {
1249
1205
  if (this.baseStore.state.fieldMetaBase[field] === void 0 && !fieldErrors?.[field]) continue;
1250
1206
  const { errorMap: currentErrorMap, errorSourceMap: currentErrorMapSource } = this.getFieldMeta(field) ?? defaultFieldMeta;
@@ -1270,16 +1226,19 @@ var FormApi = class {
1270
1226
  }
1271
1227
  }));
1272
1228
  }
1273
- if (this.state.errorMap?.[errorMapKey] !== formError) this.baseStore.setState((prev) => ({
1274
- ...prev,
1275
- errorMap: {
1276
- ...prev.errorMap,
1277
- [errorMapKey]: formError
1278
- }
1279
- }));
1229
+ if (!validateOpts?.dontUpdateFormErrorMap) {
1230
+ if (this.state.errorMap?.[errorMapKey] !== formError) this.baseStore.setState((prev) => ({
1231
+ ...prev,
1232
+ errorMap: {
1233
+ ...prev.errorMap,
1234
+ [errorMapKey]: formError
1235
+ }
1236
+ }));
1237
+ }
1280
1238
  if (formError || fieldErrors) hasErrored = true;
1281
1239
  }
1282
- const submitErrKey = getErrorMapKey$1("submit");
1240
+ if (validateOpts?.dontUpdateFormErrorMap) return;
1241
+ const submitErrKey = getErrorMapKey$2("submit");
1283
1242
  if (this.state.errorMap?.[submitErrKey] && cause !== "submit" && !hasErrored) this.baseStore.setState((prev) => ({
1284
1243
  ...prev,
1285
1244
  errorMap: {
@@ -1287,7 +1246,7 @@ var FormApi = class {
1287
1246
  [submitErrKey]: void 0
1288
1247
  }
1289
1248
  }));
1290
- const serverErrKey = getErrorMapKey$1("server");
1249
+ const serverErrKey = getErrorMapKey$2("server");
1291
1250
  if (this.state.errorMap?.[serverErrKey] && cause !== "server" && !hasErrored) this.baseStore.setState((prev) => ({
1292
1251
  ...prev,
1293
1252
  errorMap: {
@@ -1301,10 +1260,11 @@ var FormApi = class {
1301
1260
  fieldsErrorMap: currentValidationErrorMap
1302
1261
  };
1303
1262
  };
1304
- this.validateAsync = async (cause) => {
1263
+ this.validateAsync = async (cause, validateOpts) => {
1305
1264
  const validates = getAsyncValidatorArray(cause, {
1306
1265
  ...this.options,
1307
1266
  form: this,
1267
+ group: validateOpts?.group,
1308
1268
  validationLogic: this.options.validationLogic || defaultValidationLogic
1309
1269
  });
1310
1270
  if (!this.state.isFormValidating) this.baseStore.setState((prev) => ({
@@ -1315,7 +1275,7 @@ var FormApi = class {
1315
1275
  let fieldErrorsFromFormValidators;
1316
1276
  for (const validateObj of validates) {
1317
1277
  if (!validateObj.validate) continue;
1318
- const key = getErrorMapKey$1(validateObj.cause);
1278
+ const key = getErrorMapKey$2(validateObj.cause);
1319
1279
  this.state.validationMetaMap[key]?.lastAbortController.abort();
1320
1280
  const controller = new AbortController();
1321
1281
  this.state.validationMetaMap[key] = { lastAbortController: controller };
@@ -1344,13 +1304,15 @@ var FormApi = class {
1344
1304
  } catch (e) {
1345
1305
  rawError = e;
1346
1306
  }
1347
- const { formError, fieldErrors: fieldErrorsFromNormalizeError } = normalizeError$1(rawError);
1307
+ const { formError, fieldErrors: fieldErrorsFromNormalizeError } = normalizeError$2(rawError);
1348
1308
  if (fieldErrorsFromNormalizeError) fieldErrorsFromFormValidators = fieldErrorsFromFormValidators ? {
1349
1309
  ...fieldErrorsFromFormValidators,
1350
1310
  ...fieldErrorsFromNormalizeError
1351
1311
  } : fieldErrorsFromNormalizeError;
1352
- const errorMapKey = getErrorMapKey$1(validateObj.cause);
1353
- for (const field of Object.keys(this.state.fieldMeta)) {
1312
+ const errorMapKey = getErrorMapKey$2(validateObj.cause);
1313
+ let fields = Object.keys(this.state.fieldMeta);
1314
+ if (validateOpts?.filterFieldNames) fields = fields.filter(validateOpts.filterFieldNames);
1315
+ for (const field of fields) {
1354
1316
  if (this.baseStore.state.fieldMetaBase[field] === void 0) continue;
1355
1317
  const fieldMeta = this.getFieldMeta(field);
1356
1318
  if (!fieldMeta) continue;
@@ -1373,7 +1335,7 @@ var FormApi = class {
1373
1335
  }
1374
1336
  }));
1375
1337
  }
1376
- this.baseStore.setState((prev) => ({
1338
+ if (!validateOpts?.dontUpdateFormErrorMap) this.baseStore.setState((prev) => ({
1377
1339
  ...prev,
1378
1340
  errorMap: {
1379
1341
  ...prev.errorMap,
@@ -1404,10 +1366,10 @@ var FormApi = class {
1404
1366
  }));
1405
1367
  return fieldsErrorMap;
1406
1368
  };
1407
- this.validate = (cause) => {
1408
- const { hasErrored, fieldsErrorMap } = this.validateSync(cause);
1369
+ this.validate = (cause, validateOpts) => {
1370
+ const { hasErrored, fieldsErrorMap } = this.validateSync(cause, validateOpts);
1409
1371
  if (hasErrored && !this.options.asyncAlways) return fieldsErrorMap;
1410
- return this.validateAsync(cause);
1372
+ return this.validateAsync(cause, validateOpts);
1411
1373
  };
1412
1374
  this._handleSubmit = async (submitMeta) => {
1413
1375
  this.baseStore.setState((old) => ({
@@ -1419,7 +1381,7 @@ var FormApi = class {
1419
1381
  batch(() => {
1420
1382
  Object.values(this.fieldInfo).forEach((field) => {
1421
1383
  if (!field.instance) return;
1422
- if (!field.instance.state.meta.isTouched) field.instance.setMeta((prev) => ({
1384
+ if (!field.instance.store.state.meta.isTouched) field.instance.setMeta((prev) => ({
1423
1385
  ...prev,
1424
1386
  isTouched: true
1425
1387
  }));
@@ -1480,10 +1442,7 @@ var FormApi = class {
1480
1442
  }
1481
1443
  batch(() => {
1482
1444
  Object.values(this.fieldInfo).forEach((field) => {
1483
- field.instance?.options.listeners?.onSubmit?.({
1484
- value: field.instance.state.value,
1485
- fieldApi: field.instance
1486
- });
1445
+ field.instance?.triggerOnSubmitListener();
1487
1446
  });
1488
1447
  });
1489
1448
  this.options.listeners?.onSubmit?.({
@@ -1529,6 +1488,9 @@ var FormApi = class {
1529
1488
  this.getFieldMeta = (field) => {
1530
1489
  return this.state.fieldMeta[field];
1531
1490
  };
1491
+ this.getFormGroupMeta = (name) => {
1492
+ return this.formGroupMetaDerived.state[name];
1493
+ };
1532
1494
  this.getFieldInfo = (field) => {
1533
1495
  return this.fieldInfo[field] ||= {
1534
1496
  instance: null,
@@ -1601,6 +1563,7 @@ var FormApi = class {
1601
1563
  };
1602
1564
  this.pushFieldValue = (field, value, options) => {
1603
1565
  this.setFieldValue(field, (prev) => [...Array.isArray(prev) ? prev : [], value], options);
1566
+ metaHelper(this).bumpArrayVersion(field);
1604
1567
  };
1605
1568
  this.insertFieldValue = async (field, index, value, options) => {
1606
1569
  this.setFieldValue(field, (prev) => {
@@ -1619,6 +1582,7 @@ var FormApi = class {
1619
1582
  this.setFieldValue(field, (prev) => {
1620
1583
  return prev.map((d, i) => i === index ? value : d);
1621
1584
  }, mergeOpts(options, { dontValidate: true }));
1585
+ metaHelper(this).bumpArrayVersion(field);
1622
1586
  if (!(options?.dontValidate ?? false)) {
1623
1587
  await this.validateField(field, "change");
1624
1588
  await this.validateArrayFieldsStartingFrom(field, index, "change");
@@ -1670,6 +1634,7 @@ var FormApi = class {
1670
1634
  const fieldValue = this.getFieldValue(field);
1671
1635
  const lastIndex = Array.isArray(fieldValue) ? Math.max(fieldValue.length - 1, 0) : null;
1672
1636
  this.setFieldValue(field, [], mergeOpts(options, { dontValidate: true }));
1637
+ metaHelper(this).bumpArrayVersion(field);
1673
1638
  if (lastIndex !== null) for (let i = 0; i <= lastIndex; i++) {
1674
1639
  const fieldKey = `${field}[${i}]`;
1675
1640
  this.deleteField(fieldKey);
@@ -1678,13 +1643,16 @@ var FormApi = class {
1678
1643
  };
1679
1644
  this.resetField = (field) => {
1680
1645
  this.baseStore.setState((prev) => {
1646
+ const fieldDefault = this.getFieldInfo(field).instance?.options.defaultValue;
1647
+ const formDefault = getBy(this.options.defaultValues, field);
1648
+ const targetValue = fieldDefault ?? formDefault;
1681
1649
  return {
1682
1650
  ...prev,
1683
1651
  fieldMetaBase: {
1684
1652
  ...prev.fieldMetaBase,
1685
1653
  [field]: defaultFieldMeta
1686
1654
  },
1687
- values: this.options.defaultValues ? setBy(prev.values, field, getBy(this.options.defaultValues, field)) : prev.values
1655
+ values: targetValue !== void 0 ? setBy(prev.values, field, targetValue) : prev.values
1688
1656
  };
1689
1657
  });
1690
1658
  };
@@ -1693,7 +1661,7 @@ var FormApi = class {
1693
1661
  Object.entries(errorMap).forEach(([key, value]) => {
1694
1662
  const errorMapKey = key;
1695
1663
  if (isGlobalFormValidationError(value)) {
1696
- const { formError, fieldErrors } = normalizeError$1(value);
1664
+ const { formError, fieldErrors } = normalizeError$2(value);
1697
1665
  for (const fieldName of Object.keys(this.fieldInfo)) {
1698
1666
  if (!this.getFieldMeta(fieldName)) continue;
1699
1667
  this.setFieldMeta(fieldName, (prev) => ({
@@ -1777,6 +1745,7 @@ var FormApi = class {
1777
1745
  isValidating: false,
1778
1746
  isBlurred: false,
1779
1747
  isDirty: false,
1748
+ _arrayVersion: 0,
1780
1749
  ...existingFieldMeta ?? {},
1781
1750
  errorSourceMap: {
1782
1751
  ...existingFieldMeta?.["errorSourceMap"] ?? {},
@@ -1809,7 +1778,7 @@ var FormApi = class {
1809
1778
  }
1810
1779
  const isFieldValid = !isNonEmptyArray(fieldErrors);
1811
1780
  const isFieldPristine = !currBaseMeta.isDirty;
1812
- const isDefaultValue = evaluate(curFieldVal, getBy(this.options.defaultValues, fieldName)) || evaluate(curFieldVal, this.getFieldInfo(fieldName)?.instance?.options.defaultValue);
1781
+ const isDefaultValue = evaluate(curFieldVal, this.getFieldInfo(fieldName)?.instance?.options.defaultValue ?? getBy(this.options.defaultValues, fieldName));
1813
1782
  if (prevFieldInfo && prevFieldInfo.isPristine === isFieldPristine && prevFieldInfo.isValid === isFieldValid && prevFieldInfo.isDefaultValue === isDefaultValue && prevFieldInfo.errors === fieldErrors && currBaseMeta === prevBaseMeta) {
1814
1783
  fieldMeta[fieldName] = prevFieldInfo;
1815
1784
  originalMetaCount++;
@@ -1828,6 +1797,90 @@ var FormApi = class {
1828
1797
  prevBaseStore = this.baseStore.get();
1829
1798
  return fieldMeta;
1830
1799
  });
1800
+ this.formGroupMetaDerived = createStore((prevVal) => {
1801
+ const currBaseStore = this.baseStore.get();
1802
+ const currFieldMeta = this.fieldMetaDerived.get();
1803
+ const result = {};
1804
+ for (const group of this.formGroupApis) {
1805
+ const groupName = group.name;
1806
+ const lifecycle = currBaseStore.formGroupStateBase[groupName] ?? {
1807
+ isSubmitted: false,
1808
+ isSubmitting: false,
1809
+ isValidating: false,
1810
+ submissionAttempts: 0,
1811
+ isSubmitSuccessful: false
1812
+ };
1813
+ const ownFieldMeta = currFieldMeta[groupName];
1814
+ let isFieldsValidating = false;
1815
+ let isFieldsValid = true;
1816
+ let aggIsTouched = false;
1817
+ let aggIsBlurred = false;
1818
+ let aggIsDefaultValue = true;
1819
+ let aggIsDirty = false;
1820
+ for (const fieldName in currFieldMeta) {
1821
+ if (fieldName === groupName) continue;
1822
+ if (!isFieldInGroup(groupName, fieldName)) continue;
1823
+ const m = currFieldMeta[fieldName];
1824
+ if (!m) continue;
1825
+ if (m.isValidating) isFieldsValidating = true;
1826
+ if (!m.isValid) isFieldsValid = false;
1827
+ if (m.isTouched) aggIsTouched = true;
1828
+ if (m.isBlurred) aggIsBlurred = true;
1829
+ if (!m.isDefaultValue) aggIsDefaultValue = false;
1830
+ if (m.isDirty) aggIsDirty = true;
1831
+ }
1832
+ const isPristine = !aggIsDirty;
1833
+ const isValidating = !!isFieldsValidating || lifecycle.isValidating;
1834
+ const errorMap = ownFieldMeta?.errorMap ?? {};
1835
+ const errorSourceMap = ownFieldMeta?.errorSourceMap ?? {};
1836
+ const hasOnMountError = Boolean(errorMap.onMount || Object.entries(currFieldMeta).some(([fieldName, field]) => field && fieldName !== groupName && isFieldInGroup(groupName, fieldName) && field.errorMap.onMount));
1837
+ const prevGroupMeta = prevVal?.[groupName];
1838
+ let errors = prevGroupMeta?.errors ?? [];
1839
+ if (!prevGroupMeta || prevGroupMeta.__srcErrorMap !== errorMap) errors = Object.values(errorMap).reduce((acc, curr) => {
1840
+ if (curr === void 0) return acc;
1841
+ if (curr && typeof curr === "object" && "fields" in curr) {
1842
+ const groupErr = curr.group;
1843
+ if (groupErr !== void 0) acc.push(groupErr);
1844
+ return acc;
1845
+ }
1846
+ acc.push(curr);
1847
+ return acc;
1848
+ }, []);
1849
+ const isGroupValid = errors.length === 0;
1850
+ const isValid = isFieldsValid && isGroupValid;
1851
+ const submitInvalid = group.options.canSubmitWhenInvalid ?? false;
1852
+ const canSubmit = lifecycle.submissionAttempts === 0 && !aggIsTouched && !hasOnMountError || !isValidating && !lifecycle.isSubmitting && isValid || submitInvalid;
1853
+ if (prevGroupMeta && prevGroupMeta.errorMap === errorMap && prevGroupMeta.errorSourceMap === errorSourceMap && prevGroupMeta.errors === errors && prevGroupMeta.isFieldsValidating === isFieldsValidating && prevGroupMeta.isFieldsValid === isFieldsValid && prevGroupMeta.isGroupValid === isGroupValid && prevGroupMeta.isValid === isValid && prevGroupMeta.canSubmit === canSubmit && prevGroupMeta.isTouched === aggIsTouched && prevGroupMeta.isBlurred === aggIsBlurred && prevGroupMeta.isPristine === isPristine && prevGroupMeta.isDefaultValue === aggIsDefaultValue && prevGroupMeta.isDirty === aggIsDirty && prevGroupMeta.isValidating === isValidating && prevGroupMeta.isSubmitting === lifecycle.isSubmitting && prevGroupMeta.isSubmitted === lifecycle.isSubmitted && prevGroupMeta.submissionAttempts === lifecycle.submissionAttempts && prevGroupMeta.isSubmitSuccessful === lifecycle.isSubmitSuccessful) {
1854
+ result[groupName] = prevGroupMeta;
1855
+ continue;
1856
+ }
1857
+ const meta = {
1858
+ ...lifecycle,
1859
+ errorMap,
1860
+ errorSourceMap,
1861
+ _arrayVersion: ownFieldMeta?._arrayVersion ?? 0,
1862
+ isTouched: aggIsTouched,
1863
+ isBlurred: aggIsBlurred,
1864
+ isDirty: aggIsDirty,
1865
+ isPristine,
1866
+ isDefaultValue: aggIsDefaultValue,
1867
+ isValid,
1868
+ errors,
1869
+ isValidating,
1870
+ isFieldsValidating,
1871
+ isFieldsValid,
1872
+ isGroupValid,
1873
+ canSubmit
1874
+ };
1875
+ Object.defineProperty(meta, "__srcErrorMap", {
1876
+ value: errorMap,
1877
+ enumerable: false,
1878
+ configurable: true
1879
+ });
1880
+ result[groupName] = meta;
1881
+ }
1882
+ return result;
1883
+ });
1831
1884
  let prevBaseStoreForStore = void 0;
1832
1885
  this.store = createStore((prevVal) => {
1833
1886
  const currBaseStore = this.baseStore.get();
@@ -1902,17 +1955,17 @@ var FormApi = class {
1902
1955
  return this._handleSubmit(submitMeta);
1903
1956
  }
1904
1957
  };
1905
- function normalizeError$1(rawError) {
1958
+ function normalizeError$2(rawError) {
1906
1959
  if (rawError) {
1907
1960
  if (isGlobalFormValidationError(rawError)) return {
1908
- formError: normalizeError$1(rawError.form).formError,
1961
+ formError: normalizeError$2(rawError.form).formError,
1909
1962
  fieldErrors: rawError.fields
1910
1963
  };
1911
1964
  return { formError: rawError };
1912
1965
  }
1913
1966
  return { formError: void 0 };
1914
1967
  }
1915
- function getErrorMapKey$1(cause) {
1968
+ function getErrorMapKey$2(cause) {
1916
1969
  switch (cause) {
1917
1970
  case "submit": return "onSubmit";
1918
1971
  case "blur": return "onBlur";
@@ -1923,8 +1976,8 @@ function getErrorMapKey$1(cause) {
1923
1976
  }
1924
1977
  }
1925
1978
  //#endregion
1926
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/FieldApi.js
1927
- var FieldApi = class {
1979
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/FieldApi.js
1980
+ var FieldApi = class FieldApi {
1928
1981
  /**
1929
1982
  * Initializes a new `FieldApi` instance.
1930
1983
  */
@@ -1962,7 +2015,48 @@ var FieldApi = class {
1962
2015
  value: this.state.value,
1963
2016
  fieldApi: this
1964
2017
  });
1965
- return () => {};
2018
+ return () => {
2019
+ for (const [key, timeout] of Object.entries(this.timeoutIds.validations)) if (timeout) {
2020
+ clearTimeout(timeout);
2021
+ this.timeoutIds.validations[key] = null;
2022
+ }
2023
+ for (const [key, timeout] of Object.entries(this.timeoutIds.listeners)) if (timeout) {
2024
+ clearTimeout(timeout);
2025
+ this.timeoutIds.listeners[key] = null;
2026
+ }
2027
+ for (const [key, timeout] of Object.entries(this.timeoutIds.formListeners)) if (timeout) {
2028
+ clearTimeout(timeout);
2029
+ this.timeoutIds.formListeners[key] = null;
2030
+ }
2031
+ const fieldInfo = this.form.fieldInfo[this.name];
2032
+ if (!fieldInfo) return;
2033
+ if (fieldInfo.instance !== this) return;
2034
+ for (const [key, validationMeta] of Object.entries(fieldInfo.validationMetaMap)) {
2035
+ validationMeta?.lastAbortController.abort();
2036
+ fieldInfo.validationMetaMap[key] = void 0;
2037
+ }
2038
+ this.form.baseStore.setState((prev) => ({
2039
+ ...prev,
2040
+ fieldMetaBase: {
2041
+ ...prev.fieldMetaBase,
2042
+ [this.name]: {
2043
+ ...defaultFieldMeta,
2044
+ isTouched: prev.fieldMetaBase[this.name]?.isTouched ?? defaultFieldMeta.isTouched,
2045
+ isBlurred: prev.fieldMetaBase[this.name]?.isBlurred ?? defaultFieldMeta.isBlurred,
2046
+ isDirty: prev.fieldMetaBase[this.name]?.isDirty ?? defaultFieldMeta.isDirty
2047
+ }
2048
+ }
2049
+ }));
2050
+ fieldInfo.instance = null;
2051
+ this.options.listeners?.onUnmount?.({
2052
+ value: this.state.value,
2053
+ fieldApi: this
2054
+ });
2055
+ this.form.options.listeners?.onFieldUnmount?.({
2056
+ formApi: this.form,
2057
+ fieldApi: this
2058
+ });
2059
+ };
1966
2060
  };
1967
2061
  this.update = (opts2) => {
1968
2062
  this.options = opts2;
@@ -2023,6 +2117,7 @@ var FieldApi = class {
2023
2117
  const linkedFields = [];
2024
2118
  for (const field of fields) {
2025
2119
  if (!field.instance) continue;
2120
+ if (!(field.instance instanceof FieldApi)) continue;
2026
2121
  const { onChangeListenTo, onBlurListenTo } = field.instance.options.validators || {};
2027
2122
  if (cause === "change" && onChangeListenTo?.includes(this.name)) linkedFields.push(field.instance);
2028
2123
  if (cause === "blur" && onBlurListenTo?.includes(this.name)) linkedFields.push(field.instance);
@@ -2033,12 +2128,14 @@ var FieldApi = class {
2033
2128
  const validates = getSyncValidatorArray(cause, {
2034
2129
  ...this.options,
2035
2130
  form: this.form,
2131
+ fieldName: this.name,
2036
2132
  validationLogic: this.form.options.validationLogic || defaultValidationLogic
2037
2133
  });
2038
2134
  const linkedFieldValidates = this.getLinkedFields(cause).reduce((acc, field) => {
2039
2135
  const fieldValidates = getSyncValidatorArray(cause, {
2040
2136
  ...field.options,
2041
2137
  form: field.form,
2138
+ fieldName: field.name,
2042
2139
  validationLogic: field.form.options.validationLogic || defaultValidationLogic
2043
2140
  });
2044
2141
  fieldValidates.forEach((validate) => {
@@ -2049,8 +2146,8 @@ var FieldApi = class {
2049
2146
  let hasErrored = false;
2050
2147
  batch(() => {
2051
2148
  const validateFieldFn = (field, validateObj) => {
2052
- const errorMapKey = getErrorMapKey(validateObj.cause);
2053
- const fieldLevelError = validateObj.validate ? normalizeError(field.runValidator({
2149
+ const errorMapKey = getErrorMapKey$1(validateObj.cause);
2150
+ const fieldLevelError = validateObj.validate ? normalizeError$1(field.runValidator({
2054
2151
  validate: validateObj.validate,
2055
2152
  value: {
2056
2153
  value: field.store.state.value,
@@ -2083,7 +2180,7 @@ var FieldApi = class {
2083
2180
  validateFieldFn(fieldValitateObj.field, fieldValitateObj);
2084
2181
  }
2085
2182
  });
2086
- const submitErrKey = getErrorMapKey("submit");
2183
+ const submitErrKey = getErrorMapKey$1("submit");
2087
2184
  if (this.state.meta.errorMap?.[submitErrKey] && cause !== "submit" && !hasErrored) this.setMeta((prev) => ({
2088
2185
  ...prev,
2089
2186
  errorMap: {
@@ -2101,6 +2198,7 @@ var FieldApi = class {
2101
2198
  const validates = getAsyncValidatorArray(cause, {
2102
2199
  ...this.options,
2103
2200
  form: this.form,
2201
+ fieldName: this.name,
2104
2202
  validationLogic: this.form.options.validationLogic || defaultValidationLogic
2105
2203
  });
2106
2204
  const asyncFormValidationResults = await formValidationResultPromise;
@@ -2109,6 +2207,7 @@ var FieldApi = class {
2109
2207
  const fieldValidates = getAsyncValidatorArray(cause, {
2110
2208
  ...field.options,
2111
2209
  form: field.form,
2210
+ fieldName: field.name,
2112
2211
  validationLogic: field.form.options.validationLogic || defaultValidationLogic
2113
2212
  });
2114
2213
  fieldValidates.forEach((validate) => {
@@ -2130,16 +2229,17 @@ var FieldApi = class {
2130
2229
  }));
2131
2230
  }
2132
2231
  const validateFieldAsyncFn = (field, validateObj, promises) => {
2133
- const errorMapKey = getErrorMapKey(validateObj.cause);
2134
- field.getInfo().validationMetaMap[errorMapKey]?.lastAbortController.abort();
2232
+ const errorMapKey = getErrorMapKey$1(validateObj.cause);
2233
+ const fieldInfo = field.getInfo();
2234
+ fieldInfo.validationMetaMap[errorMapKey]?.lastAbortController.abort();
2135
2235
  const controller = new AbortController();
2136
- this.getInfo().validationMetaMap[errorMapKey] = { lastAbortController: controller };
2236
+ fieldInfo.validationMetaMap[errorMapKey] = { lastAbortController: controller };
2137
2237
  promises.push(new Promise(async (resolve) => {
2138
2238
  let rawError;
2139
2239
  try {
2140
2240
  rawError = await new Promise((rawResolve, rawReject) => {
2141
- if (this.timeoutIds.validations[validateObj.cause]) clearTimeout(this.timeoutIds.validations[validateObj.cause]);
2142
- this.timeoutIds.validations[validateObj.cause] = setTimeout(async () => {
2241
+ if (field.timeoutIds.validations[validateObj.cause]) clearTimeout(field.timeoutIds.validations[validateObj.cause]);
2242
+ field.timeoutIds.validations[validateObj.cause] = setTimeout(async () => {
2143
2243
  if (controller.signal.aborted) return rawResolve(void 0);
2144
2244
  try {
2145
2245
  rawResolve(await this.runValidator({
@@ -2161,12 +2261,13 @@ var FieldApi = class {
2161
2261
  rawError = e;
2162
2262
  }
2163
2263
  if (controller.signal.aborted) return resolve(void 0);
2164
- const fieldLevelError = normalizeError(rawError);
2165
- const formLevelError = asyncFormValidationResults[this.name]?.[errorMapKey];
2264
+ const fieldLevelError = normalizeError$1(rawError);
2265
+ const formLevelError = asyncFormValidationResults[field.name]?.[errorMapKey];
2166
2266
  const { newErrorValue, newSource } = determineFieldLevelErrorSourceAndValue({
2167
2267
  formLevelError,
2168
2268
  fieldLevelError
2169
2269
  });
2270
+ if (field.getInfo().instance !== field) return resolve(void 0);
2170
2271
  field.setMeta((prev) => {
2171
2272
  return {
2172
2273
  ...prev,
@@ -2210,14 +2311,44 @@ var FieldApi = class {
2210
2311
  };
2211
2312
  this.validate = (cause, opts2) => {
2212
2313
  if (!this.state.meta.isTouched) return [];
2213
- const { fieldsErrorMap } = opts2?.skipFormValidation ? { fieldsErrorMap: {} } : this.form.validateSync(cause);
2214
- const { hasErrored } = this.validateSync(cause, fieldsErrorMap[this.name] ?? {});
2314
+ const encompassingGroups = opts2?.skipGroupValidation ? [] : Array.from(this.form.formGroupApis).filter((group) => this.name.startsWith(group.name));
2315
+ let fieldsErrorMap = (opts2?.skipFormValidation ? { fieldsErrorMap: {} } : this.form.validateSync(cause)).fieldsErrorMap[this.name] ?? {};
2316
+ if (!opts2?.skipFormValidation) for (const group of encompassingGroups) {
2317
+ if (group.state.meta.submissionAttempts === 0) continue;
2318
+ const { fieldsErrorMap: groupFormErrors } = this.form.validateSync(cause, {
2319
+ group,
2320
+ dontUpdateFormErrorMap: true,
2321
+ filterFieldNames: (fieldName) => isFieldInGroup(group.name, fieldName)
2322
+ });
2323
+ fieldsErrorMap = {
2324
+ ...fieldsErrorMap,
2325
+ ...groupFormErrors[this.name] ?? {}
2326
+ };
2327
+ }
2328
+ const { hasErrored } = this.validateSync(cause, fieldsErrorMap);
2329
+ const groupHasErroredWeakMap = /* @__PURE__ */ new WeakMap();
2330
+ for (const group of encompassingGroups) {
2331
+ const { hasErrored: groupHasErrored } = group.validateSync(cause, {}, { skipRelatedFieldValidation: true });
2332
+ groupHasErroredWeakMap.set(group, groupHasErrored);
2333
+ }
2215
2334
  if (hasErrored && !this.options.asyncAlways) {
2216
- this.getInfo().validationMetaMap[getErrorMapKey(cause)]?.lastAbortController.abort();
2217
- return this.state.meta.errors;
2335
+ this.getInfo().validationMetaMap[getErrorMapKey$1(cause)]?.lastAbortController.abort();
2336
+ const groupErrors = [];
2337
+ for (const group of encompassingGroups) {
2338
+ group.getInfo().validationMetaMap[getErrorMapKey$1(cause)]?.lastAbortController.abort();
2339
+ groupErrors.push(group.state.meta.errors);
2340
+ }
2341
+ return [...this.state.meta.errors, ...groupErrors.flat()];
2218
2342
  }
2219
2343
  const formValidationResultPromise = opts2?.skipFormValidation ? Promise.resolve({}) : this.form.validateAsync(cause);
2220
- return this.validateAsync(cause, formValidationResultPromise);
2344
+ const fieldAsyncResults = this.validateAsync(cause, formValidationResultPromise);
2345
+ const groupAsyncResults = [];
2346
+ for (const group of encompassingGroups) {
2347
+ if (groupHasErroredWeakMap.get(group) && !group.options.asyncAlways) continue;
2348
+ groupAsyncResults.push(group.validateAsync(cause, formValidationResultPromise, { skipRelatedFieldValidation: true }));
2349
+ }
2350
+ if (groupAsyncResults.length === 0) return fieldAsyncResults;
2351
+ return Promise.all([fieldAsyncResults, ...groupAsyncResults]).then((results) => results.flat());
2221
2352
  };
2222
2353
  this.handleChange = (updater) => {
2223
2354
  this.setValue(updater);
@@ -2255,6 +2386,34 @@ var FieldApi = class {
2255
2386
  validationSource: "field"
2256
2387
  }, schema);
2257
2388
  };
2389
+ this.triggerOnBlurListener = () => {
2390
+ const formDebounceMs = this.form.options.listeners?.onBlurDebounceMs;
2391
+ if (formDebounceMs && formDebounceMs > 0) {
2392
+ if (this.timeoutIds.formListeners.blur) clearTimeout(this.timeoutIds.formListeners.blur);
2393
+ this.timeoutIds.formListeners.blur = setTimeout(() => {
2394
+ this.form.options.listeners?.onBlur?.({
2395
+ formApi: this.form,
2396
+ fieldApi: this
2397
+ });
2398
+ }, formDebounceMs);
2399
+ } else this.form.options.listeners?.onBlur?.({
2400
+ formApi: this.form,
2401
+ fieldApi: this
2402
+ });
2403
+ const fieldDebounceMs = this.options.listeners?.onBlurDebounceMs;
2404
+ if (fieldDebounceMs && fieldDebounceMs > 0) {
2405
+ if (this.timeoutIds.listeners.blur) clearTimeout(this.timeoutIds.listeners.blur);
2406
+ this.timeoutIds.listeners.blur = setTimeout(() => {
2407
+ this.options.listeners?.onBlur?.({
2408
+ value: this.state.value,
2409
+ fieldApi: this
2410
+ });
2411
+ }, fieldDebounceMs);
2412
+ } else this.options.listeners?.onBlur?.({
2413
+ value: this.state.value,
2414
+ fieldApi: this
2415
+ });
2416
+ };
2258
2417
  this.triggerOnChangeListener = () => {
2259
2418
  const formDebounceMs = this.form.options.listeners?.onChangeDebounceMs;
2260
2419
  if (formDebounceMs && formDebounceMs > 0) {
@@ -2282,6 +2441,13 @@ var FieldApi = class {
2282
2441
  value: this.state.value,
2283
2442
  fieldApi: this
2284
2443
  });
2444
+ for (const group of this.form.formGroupApis) if (isFieldInGroup(group.name, this.name)) group.triggerOnChangeListener();
2445
+ };
2446
+ this.triggerOnSubmitListener = () => {
2447
+ this.options.listeners?.onSubmit?.({
2448
+ value: this.state.value,
2449
+ fieldApi: this
2450
+ });
2285
2451
  };
2286
2452
  this.form = opts.form;
2287
2453
  this.name = opts.name;
@@ -2319,37 +2485,702 @@ var FieldApi = class {
2319
2485
  if (isStandardSchemaValidator(props.validate)) return standardSchemaValidators[props.type](props.value, props.validate);
2320
2486
  return props.validate(props.value);
2321
2487
  }
2322
- triggerOnBlurListener() {
2323
- const formDebounceMs = this.form.options.listeners?.onBlurDebounceMs;
2324
- if (formDebounceMs && formDebounceMs > 0) {
2325
- if (this.timeoutIds.formListeners.blur) clearTimeout(this.timeoutIds.formListeners.blur);
2326
- this.timeoutIds.formListeners.blur = setTimeout(() => {
2327
- this.form.options.listeners?.onBlur?.({
2328
- formApi: this.form,
2329
- fieldApi: this
2488
+ };
2489
+ function normalizeError$1(rawError) {
2490
+ if (rawError) return rawError;
2491
+ }
2492
+ function getErrorMapKey$1(cause) {
2493
+ switch (cause) {
2494
+ case "submit": return "onSubmit";
2495
+ case "blur": return "onBlur";
2496
+ case "mount": return "onMount";
2497
+ case "server": return "onServer";
2498
+ case "dynamic": return "onDynamic";
2499
+ default: return "onChange";
2500
+ }
2501
+ }
2502
+ //#endregion
2503
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/FormGroupApi.js
2504
+ function getDefaultFormGroupState(defaultState) {
2505
+ return {
2506
+ isSubmitted: defaultState.isSubmitted ?? false,
2507
+ isSubmitting: defaultState.isSubmitting ?? false,
2508
+ isValidating: defaultState.isValidating ?? false,
2509
+ submissionAttempts: defaultState.submissionAttempts ?? 0,
2510
+ isSubmitSuccessful: defaultState.isSubmitSuccessful ?? false
2511
+ };
2512
+ }
2513
+ function getDefaultFormGroupMeta(defaultMeta) {
2514
+ return {
2515
+ ...defaultFieldMeta,
2516
+ ...defaultMeta,
2517
+ errors: [],
2518
+ isPristine: true,
2519
+ isValid: true,
2520
+ isDefaultValue: true,
2521
+ isFieldsValidating: false,
2522
+ isFieldsValid: true,
2523
+ isGroupValid: true,
2524
+ canSubmit: true,
2525
+ isSubmitting: false,
2526
+ isSubmitted: false,
2527
+ isValidating: false,
2528
+ submissionAttempts: 0,
2529
+ isSubmitSuccessful: false
2530
+ };
2531
+ }
2532
+ var FormGroupApi = class FormGroupApi {
2533
+ constructor(opts) {
2534
+ this.options = {};
2535
+ this.setFormGroupState = (updater) => {
2536
+ this.form.baseStore.setState((prev) => {
2537
+ const prevGroupState = prev.formGroupStateBase[this.name] ?? getDefaultFormGroupState({});
2538
+ return {
2539
+ ...prev,
2540
+ formGroupStateBase: {
2541
+ ...prev.formGroupStateBase,
2542
+ [this.name]: updater(prevGroupState)
2543
+ }
2544
+ };
2545
+ });
2546
+ };
2547
+ this._lastDistributedFieldNames = {};
2548
+ this.update = (opts2) => {
2549
+ this.options = opts2;
2550
+ this.name = opts2.name;
2551
+ if (!this.state.meta.isTouched && this.options.defaultValue !== void 0) {
2552
+ if (!evaluate(this.form.getFieldValue(this.name), opts2.defaultValue)) this.form.setFieldValue(this.name, opts2.defaultValue, {
2553
+ dontUpdateMeta: true,
2554
+ dontValidate: true,
2555
+ dontRunListeners: true
2330
2556
  });
2331
- }, formDebounceMs);
2332
- } else this.form.options.listeners?.onBlur?.({
2333
- formApi: this.form,
2334
- fieldApi: this
2335
- });
2336
- const fieldDebounceMs = this.options.listeners?.onBlurDebounceMs;
2337
- if (fieldDebounceMs && fieldDebounceMs > 0) {
2338
- if (this.timeoutIds.listeners.blur) clearTimeout(this.timeoutIds.listeners.blur);
2339
- this.timeoutIds.listeners.blur = setTimeout(() => {
2340
- this.options.listeners?.onBlur?.({
2557
+ }
2558
+ if (!this.form.getFieldMeta(this.name)) this.form.setFieldMeta(this.name, {
2559
+ ...defaultFieldMeta,
2560
+ ...this.options.defaultMeta
2561
+ });
2562
+ };
2563
+ this.mount = () => {
2564
+ this.update(this.options);
2565
+ this.form.formGroupApis.add(this);
2566
+ this.fieldInfo.instance = this;
2567
+ this.form.baseStore.setState((prev) => ({
2568
+ ...prev,
2569
+ formGroupStateBase: {
2570
+ ...prev.formGroupStateBase,
2571
+ [this.name]: prev.formGroupStateBase[this.name] ?? getDefaultFormGroupState({ ...this.options.defaultState })
2572
+ }
2573
+ }));
2574
+ const { onMount } = this.options.validators || {};
2575
+ if (onMount) {
2576
+ const rawError = this.runValidator({
2577
+ validate: onMount,
2578
+ value: {
2579
+ value: this.state.value,
2580
+ groupApi: this,
2581
+ validationSource: "form"
2582
+ },
2583
+ type: "validate"
2584
+ });
2585
+ let groupOwnRawError = rawError;
2586
+ let groupFieldErrors = void 0;
2587
+ if (isGlobalGroupValidationError(rawError)) {
2588
+ groupOwnRawError = rawError.group;
2589
+ groupFieldErrors = rawError.fields;
2590
+ }
2591
+ const error = normalizeError(groupOwnRawError);
2592
+ if (error) this.setMeta((prev) => ({
2593
+ ...prev,
2594
+ errorMap: {
2595
+ ...prev.errorMap,
2596
+ onMount: error
2597
+ },
2598
+ errorSourceMap: {
2599
+ ...prev.errorSourceMap,
2600
+ onMount: "field"
2601
+ }
2602
+ }));
2603
+ this.distributeFieldErrors("onMount", groupFieldErrors);
2604
+ }
2605
+ this.options.listeners?.onMount?.({
2606
+ value: this.state.value,
2607
+ groupApi: this
2608
+ });
2609
+ return () => {
2610
+ for (const [key, timeout] of Object.entries(this.timeoutIds.validations)) if (timeout) {
2611
+ clearTimeout(timeout);
2612
+ this.timeoutIds.validations[key] = null;
2613
+ }
2614
+ for (const [key, timeout] of Object.entries(this.timeoutIds.listeners)) if (timeout) {
2615
+ clearTimeout(timeout);
2616
+ this.timeoutIds.listeners[key] = null;
2617
+ }
2618
+ for (const [key, timeout] of Object.entries(this.timeoutIds.formListeners)) if (timeout) {
2619
+ clearTimeout(timeout);
2620
+ this.timeoutIds.formListeners[key] = null;
2621
+ }
2622
+ if (this.fieldInfo.instance !== this) return;
2623
+ for (const [key, validationMeta] of Object.entries(this.fieldInfo.validationMetaMap)) {
2624
+ validationMeta?.lastAbortController.abort();
2625
+ this.fieldInfo.validationMetaMap[key] = void 0;
2626
+ }
2627
+ this.form.formGroupApis.delete(this);
2628
+ this.form.baseStore.setState((prev) => ({
2629
+ ...prev,
2630
+ formGroupStateBase: {
2631
+ ...prev.formGroupStateBase,
2632
+ [this.name]: getDefaultFormGroupState({})
2633
+ }
2634
+ }));
2635
+ this.fieldInfo.instance = null;
2636
+ this.options.listeners?.onUnmount?.({
2341
2637
  value: this.state.value,
2342
- fieldApi: this
2638
+ groupApi: this
2343
2639
  });
2344
- }, fieldDebounceMs);
2345
- } else this.options.listeners?.onBlur?.({
2346
- value: this.state.value,
2347
- fieldApi: this
2348
- });
2349
- }
2350
- };
2351
- function normalizeError(rawError) {
2352
- if (rawError) return rawError;
2640
+ };
2641
+ };
2642
+ this.setValue = (updater, options) => {
2643
+ this.form.setFieldValue(this.name, updater, mergeOpts(options, {
2644
+ dontRunListeners: true,
2645
+ dontValidate: true
2646
+ }));
2647
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2648
+ if (!options?.dontValidate) this.validate("change");
2649
+ };
2650
+ this.getMeta = () => this.store.state.meta;
2651
+ this.setMeta = (updater) => this.form.setFieldMeta(this.name, updater);
2652
+ this.getInfo = () => this.fieldInfo;
2653
+ this.getRelatedFields = () => {
2654
+ const fields = Object.values(this.form.fieldInfo);
2655
+ const relatedFields = [];
2656
+ for (const field of fields) {
2657
+ if (!field.instance) continue;
2658
+ if (!(field.instance instanceof FieldApi)) continue;
2659
+ if (field.instance.name.startsWith(this.name)) relatedFields.push(field.instance);
2660
+ }
2661
+ return relatedFields;
2662
+ };
2663
+ this.getRelatedFieldMetasDerived = () => {
2664
+ const fields = Object.entries(this.form.fieldMetaDerived.state);
2665
+ const relatedFieldMetas = [];
2666
+ for (const [fieldName, fieldMeta] of fields) {
2667
+ if (fieldName === this.name) continue;
2668
+ if (isFieldInGroup(this.name, fieldName)) relatedFieldMetas.push({
2669
+ ...fieldMeta,
2670
+ name: fieldName
2671
+ });
2672
+ }
2673
+ return relatedFieldMetas;
2674
+ };
2675
+ this.buildChildFieldName = (relativeName) => {
2676
+ if (relativeName === "") return this.name;
2677
+ if (relativeName.startsWith("[")) return `${this.name}${relativeName}`;
2678
+ return `${this.name}.${relativeName}`;
2679
+ };
2680
+ this.distributeFieldErrors = (errorMapKey, fieldErrors) => {
2681
+ const previousNames = this._lastDistributedFieldNames[errorMapKey] ?? /* @__PURE__ */ new Set();
2682
+ const currentNames = /* @__PURE__ */ new Set();
2683
+ if (fieldErrors) for (const [relativeName, err] of Object.entries(fieldErrors)) {
2684
+ if (err === void 0 || err === null || err === false) continue;
2685
+ currentNames.add(this.buildChildFieldName(relativeName));
2686
+ }
2687
+ const allNames = /* @__PURE__ */ new Set([...previousNames, ...currentNames]);
2688
+ let hasErrored = false;
2689
+ for (const fullName of allNames) {
2690
+ const relativeName = fullName.startsWith(this.name + "[") ? fullName.slice(this.name.length) : fullName.slice(this.name.length + 1);
2691
+ const newFormValidatorError = fieldErrors?.[relativeName];
2692
+ const fieldMeta = this.form.getFieldMeta(fullName);
2693
+ if (!fieldMeta && !newFormValidatorError) continue;
2694
+ const previousErrorValue = fieldMeta?.errorMap[errorMapKey];
2695
+ const { newErrorValue, newSource } = determineFormLevelErrorSourceAndValue({
2696
+ newFormValidatorError,
2697
+ isPreviousErrorFromFormValidator: fieldMeta?.errorSourceMap[errorMapKey] === "form",
2698
+ previousErrorValue
2699
+ });
2700
+ if (newErrorValue) hasErrored = true;
2701
+ if (previousErrorValue === newErrorValue && fieldMeta?.errorSourceMap[errorMapKey] === newSource) continue;
2702
+ this.form.setFieldMeta(fullName, (prev) => ({
2703
+ ...prev,
2704
+ errorMap: {
2705
+ ...prev.errorMap,
2706
+ [errorMapKey]: newErrorValue
2707
+ },
2708
+ errorSourceMap: {
2709
+ ...prev.errorSourceMap,
2710
+ [errorMapKey]: newSource
2711
+ }
2712
+ }));
2713
+ }
2714
+ this._lastDistributedFieldNames[errorMapKey] = currentNames;
2715
+ return hasErrored;
2716
+ };
2717
+ this.validateSync = (cause, errorFromForm, opts2 = {}) => {
2718
+ const validates = getSyncValidatorArray(cause, {
2719
+ ...this.options,
2720
+ form: this.form,
2721
+ group: this,
2722
+ validationLogic: this.options.validationLogic || this.form.options.validationLogic || defaultValidationLogic
2723
+ });
2724
+ const relatedFieldValidates = (opts2.skipRelatedFieldValidation ? [] : this.getRelatedFields()).reduce((acc, field) => {
2725
+ const fieldValidates = getSyncValidatorArray(cause, {
2726
+ ...field.options,
2727
+ form: field.form,
2728
+ validationLogic: field.form.options.validationLogic || defaultValidationLogic
2729
+ });
2730
+ fieldValidates.forEach((validate) => {
2731
+ validate.field = field;
2732
+ });
2733
+ return acc.concat(fieldValidates);
2734
+ }, []);
2735
+ let hasErrored = false;
2736
+ batch(() => {
2737
+ const validateFieldOrGroupFn = (fieldOrGroup, validateObj) => {
2738
+ const errorMapKey = getErrorMapKey(validateObj.cause);
2739
+ const isGroup = fieldOrGroup === this;
2740
+ let rawError = void 0;
2741
+ if (validateObj.validate) rawError = fieldOrGroup.runValidator({
2742
+ validate: validateObj.validate,
2743
+ value: {
2744
+ value: fieldOrGroup.store.state.value,
2745
+ validationSource: isGroup ? "form" : "field",
2746
+ ...fieldOrGroup instanceof FormGroupApi ? { groupApi: fieldOrGroup } : { fieldApi: fieldOrGroup }
2747
+ },
2748
+ type: "validate"
2749
+ });
2750
+ let groupOwnRawError = rawError;
2751
+ let groupFieldErrors = void 0;
2752
+ if (isGroup && isGlobalGroupValidationError(rawError)) {
2753
+ groupOwnRawError = rawError.group;
2754
+ groupFieldErrors = rawError.fields;
2755
+ }
2756
+ const fieldLevelError = normalizeError(groupOwnRawError);
2757
+ const formLevelError = errorFromForm[errorMapKey];
2758
+ const { newErrorValue, newSource } = determineFieldLevelErrorSourceAndValue({
2759
+ formLevelError,
2760
+ fieldLevelError
2761
+ });
2762
+ if (fieldOrGroup.state.meta.errorMap?.[errorMapKey] !== newErrorValue) fieldOrGroup.setMeta((prev) => ({
2763
+ ...prev,
2764
+ errorMap: {
2765
+ ...prev.errorMap,
2766
+ [errorMapKey]: newErrorValue
2767
+ },
2768
+ errorSourceMap: {
2769
+ ...prev.errorSourceMap,
2770
+ [errorMapKey]: newSource
2771
+ }
2772
+ }));
2773
+ if (newErrorValue) hasErrored = true;
2774
+ if (isGroup) {
2775
+ if (this.distributeFieldErrors(errorMapKey, groupFieldErrors)) hasErrored = true;
2776
+ }
2777
+ };
2778
+ for (const validateObj of validates) validateFieldOrGroupFn(this, validateObj);
2779
+ for (const fieldValidateObj of relatedFieldValidates) {
2780
+ if (!fieldValidateObj.validate) continue;
2781
+ validateFieldOrGroupFn(fieldValidateObj.field, fieldValidateObj);
2782
+ }
2783
+ });
2784
+ const submitErrKey = getErrorMapKey("submit");
2785
+ if (this.state.meta.errorMap?.[submitErrKey] && cause !== "submit" && !hasErrored) this.setMeta((prev) => ({
2786
+ ...prev,
2787
+ errorMap: {
2788
+ ...prev.errorMap,
2789
+ [submitErrKey]: void 0
2790
+ },
2791
+ errorSourceMap: {
2792
+ ...prev.errorSourceMap,
2793
+ [submitErrKey]: void 0
2794
+ }
2795
+ }));
2796
+ return { hasErrored };
2797
+ };
2798
+ this.validateAsync = async (cause, formValidationResultPromise, opts2 = {}) => {
2799
+ const validates = getAsyncValidatorArray(cause, {
2800
+ ...this.options,
2801
+ form: this.form,
2802
+ group: this,
2803
+ validationLogic: this.options.validationLogic || this.form.options.validationLogic || defaultValidationLogic
2804
+ });
2805
+ const asyncFormValidationResults = await formValidationResultPromise;
2806
+ const relatedFields = opts2.skipRelatedFieldValidation ? [] : this.getRelatedFields();
2807
+ const relatedFieldValidates = relatedFields.reduce((acc, field) => {
2808
+ const fieldValidates = getAsyncValidatorArray(cause, {
2809
+ ...field.options,
2810
+ form: field.form,
2811
+ validationLogic: field.form.options.validationLogic || defaultValidationLogic
2812
+ });
2813
+ fieldValidates.forEach((validate) => {
2814
+ validate.field = field;
2815
+ });
2816
+ return acc.concat(fieldValidates);
2817
+ }, []);
2818
+ const validatesPromises = [];
2819
+ const linkedPromises = [];
2820
+ const hasAsyncValidators = validates.some((v) => v.validate) || relatedFieldValidates.some((v) => v.validate);
2821
+ if (hasAsyncValidators) {
2822
+ if (!this.state.meta.isValidating) this.setMeta((prev) => ({
2823
+ ...prev,
2824
+ isValidating: true
2825
+ }));
2826
+ for (const linkedField of relatedFields) linkedField.setMeta((prev) => ({
2827
+ ...prev,
2828
+ isValidating: true
2829
+ }));
2830
+ }
2831
+ const validateFieldOrGroupAsyncFn = (fieldOrGroup, validateObj, promises) => {
2832
+ const errorMapKey = getErrorMapKey(validateObj.cause);
2833
+ const fieldInfo = fieldOrGroup.getInfo();
2834
+ fieldInfo.validationMetaMap[errorMapKey]?.lastAbortController.abort();
2835
+ const controller = new AbortController();
2836
+ fieldInfo.validationMetaMap[errorMapKey] = { lastAbortController: controller };
2837
+ const isGroup = fieldOrGroup === this;
2838
+ promises.push(new Promise(async (resolve) => {
2839
+ let rawError;
2840
+ try {
2841
+ rawError = await new Promise((rawResolve, rawReject) => {
2842
+ if (fieldOrGroup.timeoutIds.validations[validateObj.cause]) clearTimeout(fieldOrGroup.timeoutIds.validations[validateObj.cause]);
2843
+ fieldOrGroup.timeoutIds.validations[validateObj.cause] = setTimeout(async () => {
2844
+ if (controller.signal.aborted) return rawResolve(void 0);
2845
+ try {
2846
+ rawResolve(await this.runValidator({
2847
+ validate: validateObj.validate,
2848
+ value: {
2849
+ value: fieldOrGroup.store.state.value,
2850
+ signal: controller.signal,
2851
+ validationSource: isGroup ? "form" : "field",
2852
+ ...fieldOrGroup instanceof FormGroupApi ? { groupApi: fieldOrGroup } : { fieldApi: fieldOrGroup }
2853
+ },
2854
+ type: "validateAsync"
2855
+ }));
2856
+ } catch (e) {
2857
+ rawReject(e);
2858
+ }
2859
+ }, validateObj.debounceMs);
2860
+ });
2861
+ } catch (e) {
2862
+ rawError = e;
2863
+ }
2864
+ if (controller.signal.aborted) return resolve(void 0);
2865
+ let groupOwnRawError = rawError;
2866
+ let groupFieldErrors = void 0;
2867
+ if (isGroup && isGlobalGroupValidationError(rawError)) {
2868
+ groupOwnRawError = rawError.group;
2869
+ groupFieldErrors = rawError.fields;
2870
+ }
2871
+ const fieldLevelError = normalizeError(groupOwnRawError);
2872
+ const formLevelError = asyncFormValidationResults[fieldOrGroup.name]?.[errorMapKey];
2873
+ const { newErrorValue, newSource } = determineFieldLevelErrorSourceAndValue({
2874
+ formLevelError,
2875
+ fieldLevelError
2876
+ });
2877
+ if (fieldOrGroup.getInfo().instance !== fieldOrGroup) return resolve(void 0);
2878
+ fieldOrGroup.setMeta((prev) => {
2879
+ return {
2880
+ ...prev,
2881
+ errorMap: {
2882
+ ...prev?.errorMap,
2883
+ [errorMapKey]: newErrorValue
2884
+ },
2885
+ errorSourceMap: {
2886
+ ...prev.errorSourceMap,
2887
+ [errorMapKey]: newSource
2888
+ }
2889
+ };
2890
+ });
2891
+ if (isGroup) this.distributeFieldErrors(errorMapKey, groupFieldErrors);
2892
+ resolve(newErrorValue);
2893
+ }));
2894
+ };
2895
+ for (const validateObj of validates) {
2896
+ if (!validateObj.validate) continue;
2897
+ validateFieldOrGroupAsyncFn(this, validateObj, validatesPromises);
2898
+ }
2899
+ for (const fieldValitateObj of relatedFieldValidates) {
2900
+ if (!fieldValitateObj.validate) continue;
2901
+ validateFieldOrGroupAsyncFn(fieldValitateObj.field, fieldValitateObj, linkedPromises);
2902
+ }
2903
+ let results = [];
2904
+ if (validatesPromises.length || linkedPromises.length) {
2905
+ results = await Promise.all(validatesPromises);
2906
+ await Promise.all(linkedPromises);
2907
+ }
2908
+ if (hasAsyncValidators) {
2909
+ this.setMeta((prev) => ({
2910
+ ...prev,
2911
+ isValidating: false
2912
+ }));
2913
+ for (const linkedField of relatedFields) linkedField.setMeta((prev) => ({
2914
+ ...prev,
2915
+ isValidating: false
2916
+ }));
2917
+ }
2918
+ return results.filter(Boolean);
2919
+ };
2920
+ this.validateAllFields = async (cause) => {
2921
+ const fieldValidationPromises = [];
2922
+ batch(() => {
2923
+ Object.values(this.getRelatedFields()).forEach((fieldInstance) => {
2924
+ fieldValidationPromises.push(Promise.resolve().then(() => fieldInstance.validate(cause, {
2925
+ skipFormValidation: true,
2926
+ skipGroupValidation: true
2927
+ })));
2928
+ if (!fieldInstance.store.state.meta.isTouched) fieldInstance.setMeta((prev) => ({
2929
+ ...prev,
2930
+ isTouched: true
2931
+ }));
2932
+ });
2933
+ });
2934
+ return (await Promise.all(fieldValidationPromises)).flat();
2935
+ };
2936
+ this.validateArrayFieldsStartingFrom = (field, index, cause) => {
2937
+ return this.form.validateArrayFieldsStartingFrom(field, index, cause);
2938
+ };
2939
+ this.validateField = (field, cause) => {
2940
+ return this.form.validateField(field, cause);
2941
+ };
2942
+ this.getFieldValue = (field) => {
2943
+ return this.form.getFieldValue(field);
2944
+ };
2945
+ this.getFieldMeta = (field) => {
2946
+ return this.form.getFieldMeta(field);
2947
+ };
2948
+ this.setFieldMeta = (field, updater) => {
2949
+ return this.form.setFieldMeta(field, updater);
2950
+ };
2951
+ this.setFieldValue = (field, value) => {
2952
+ return this.form.setFieldValue(field, value);
2953
+ };
2954
+ this.deleteField = (field) => {
2955
+ return this.form.deleteField(field);
2956
+ };
2957
+ this.pushFieldValue = (field, value) => {
2958
+ return this.form.pushFieldValue(field, value);
2959
+ };
2960
+ this.insertFieldValue = (field, index, value) => {
2961
+ return this.form.insertFieldValue(field, index, value);
2962
+ };
2963
+ this.replaceFieldValue = (field, index, value) => {
2964
+ return this.form.replaceFieldValue(field, index, value);
2965
+ };
2966
+ this.swapFieldValues = (field, index1, index2) => {
2967
+ return this.form.swapFieldValues(field, index1, index2);
2968
+ };
2969
+ this.moveFieldValues = (field, fromIndex, toIndex) => {
2970
+ return this.form.moveFieldValues(field, fromIndex, toIndex);
2971
+ };
2972
+ this.clearFieldValues = (field) => {
2973
+ return this.form.clearFieldValues(field);
2974
+ };
2975
+ this.resetField = (field) => {
2976
+ return this.form.resetField(field);
2977
+ };
2978
+ this.removeFieldValue = (field, index) => {
2979
+ return this.form.removeFieldValue(field, index);
2980
+ };
2981
+ this.areRelatedFieldsValid = () => {
2982
+ return Object.values(this.getRelatedFields()).every((field) => field.state.meta.isValid);
2983
+ };
2984
+ this.validate = (cause, opts2) => {
2985
+ const { fieldsErrorMap } = opts2?.skipFormValidation ? { fieldsErrorMap: {} } : this.form.validateSync(cause, {
2986
+ dontUpdateFormErrorMap: true,
2987
+ filterFieldNames: (fieldName) => isFieldInGroup(this.name, fieldName)
2988
+ });
2989
+ const { hasErrored } = this.validateSync(cause, fieldsErrorMap[this.name] ?? {}, { skipRelatedFieldValidation: opts2?.skipRelatedFieldValidation });
2990
+ if (hasErrored && !this.options.asyncAlways) {
2991
+ this.getInfo().validationMetaMap[getErrorMapKey(cause)]?.lastAbortController.abort();
2992
+ return this.state.meta.errors;
2993
+ }
2994
+ const formValidationResultPromise = opts2?.skipFormValidation ? Promise.resolve({}) : this.form.validateAsync(cause, {
2995
+ dontUpdateFormErrorMap: true,
2996
+ filterFieldNames: (fieldName) => isFieldInGroup(this.name, fieldName)
2997
+ });
2998
+ return this.validateAsync(cause, formValidationResultPromise, { skipRelatedFieldValidation: opts2?.skipRelatedFieldValidation });
2999
+ };
3000
+ this.triggerOnChangeListener = () => {
3001
+ const formDebounceMs = this.form.options.listeners?.onChangeGroupDebounceMs;
3002
+ if (formDebounceMs && formDebounceMs > 0) {
3003
+ if (this.timeoutIds.formListeners.change) clearTimeout(this.timeoutIds.formListeners.change);
3004
+ this.timeoutIds.formListeners.change = setTimeout(() => {
3005
+ this.form.options.listeners?.onChangeGroup?.({
3006
+ formApi: this.form,
3007
+ groupApi: this
3008
+ });
3009
+ }, formDebounceMs);
3010
+ } else this.form.options.listeners?.onChangeGroup?.({
3011
+ formApi: this.form,
3012
+ groupApi: this
3013
+ });
3014
+ const fieldDebounceMs = this.options.listeners?.onChangeDebounceMs;
3015
+ if (fieldDebounceMs && fieldDebounceMs > 0) {
3016
+ if (this.timeoutIds.listeners.change) clearTimeout(this.timeoutIds.listeners.change);
3017
+ this.timeoutIds.listeners.change = setTimeout(() => {
3018
+ this.options.listeners?.onChange?.({
3019
+ value: this.state.value,
3020
+ groupApi: this
3021
+ });
3022
+ }, fieldDebounceMs);
3023
+ } else this.options.listeners?.onChange?.({
3024
+ value: this.state.value,
3025
+ groupApi: this
3026
+ });
3027
+ };
3028
+ this.triggerOnSubmitListener = () => {
3029
+ this.options.listeners?.onSubmit?.({
3030
+ value: this.state.value,
3031
+ groupApi: this
3032
+ });
3033
+ };
3034
+ this._handleSubmit = async (submitMeta) => {
3035
+ this.setFormGroupState((old) => ({
3036
+ ...old,
3037
+ isSubmitted: false,
3038
+ submissionAttempts: old.submissionAttempts + 1,
3039
+ isSubmitSuccessful: false
3040
+ }));
3041
+ batch(() => {
3042
+ Object.values(this.getRelatedFields()).forEach((field) => {
3043
+ if (!field.state.meta.isTouched) field.setMeta((prev) => ({
3044
+ ...prev,
3045
+ isTouched: true
3046
+ }));
3047
+ });
3048
+ });
3049
+ const submitMetaArg = submitMeta ?? this.options.onSubmitMeta;
3050
+ this.setFormGroupState((d) => ({
3051
+ ...d,
3052
+ isSubmitting: true
3053
+ }));
3054
+ const done = () => {
3055
+ this.setFormGroupState((prev) => ({
3056
+ ...prev,
3057
+ isSubmitting: false
3058
+ }));
3059
+ };
3060
+ await this.validateAllFields("submit");
3061
+ if (!this.areRelatedFieldsValid()) {
3062
+ done();
3063
+ this.options.onGroupSubmitInvalid?.({
3064
+ value: this.state.value,
3065
+ groupApi: this,
3066
+ meta: submitMetaArg
3067
+ });
3068
+ return;
3069
+ }
3070
+ await this.validate("submit", { skipRelatedFieldValidation: true });
3071
+ if (!this.areRelatedFieldsValid() || !this.state.meta.isValid) {
3072
+ done();
3073
+ this.options.onGroupSubmitInvalid?.({
3074
+ value: this.state.value,
3075
+ groupApi: this,
3076
+ meta: submitMetaArg
3077
+ });
3078
+ return;
3079
+ }
3080
+ batch(() => {
3081
+ Object.values(this.getRelatedFields()).forEach((field) => {
3082
+ field.options.listeners?.onGroupSubmit?.({
3083
+ value: field.state.value,
3084
+ fieldApi: field
3085
+ });
3086
+ });
3087
+ });
3088
+ this.options.listeners?.onSubmit?.({
3089
+ groupApi: this,
3090
+ value: this.state.value
3091
+ });
3092
+ try {
3093
+ await this.options.onGroupSubmit?.({
3094
+ value: this.state.value,
3095
+ groupApi: this,
3096
+ meta: submitMetaArg
3097
+ });
3098
+ batch(() => {
3099
+ this.setFormGroupState((prev) => ({
3100
+ ...prev,
3101
+ isSubmitted: true,
3102
+ isSubmitSuccessful: true
3103
+ }));
3104
+ done();
3105
+ });
3106
+ } catch (err) {
3107
+ this.setFormGroupState((prev) => ({
3108
+ ...prev,
3109
+ isSubmitSuccessful: false
3110
+ }));
3111
+ done();
3112
+ throw err;
3113
+ }
3114
+ };
3115
+ this.form = opts.form;
3116
+ this.name = opts.name;
3117
+ this.options = opts;
3118
+ this.timeoutIds = {
3119
+ validations: {},
3120
+ listeners: {},
3121
+ formListeners: {}
3122
+ };
3123
+ this.fieldInfo = {
3124
+ instance: null,
3125
+ validationMetaMap: {
3126
+ onChange: void 0,
3127
+ onBlur: void 0,
3128
+ onSubmit: void 0,
3129
+ onMount: void 0,
3130
+ onServer: void 0,
3131
+ onDynamic: void 0
3132
+ }
3133
+ };
3134
+ this.store = createStore((prevVal) => {
3135
+ this.form.formGroupMetaDerived.get();
3136
+ this.form.baseStore.get();
3137
+ const meta = this.form.getFormGroupMeta(this.name) ?? getDefaultFormGroupMeta(opts.defaultMeta);
3138
+ let value = this.form.getFieldValue(this.name);
3139
+ if (!meta.isTouched && value === void 0 && this.options.defaultValue !== void 0 && !evaluate(value, this.options.defaultValue)) value = this.options.defaultValue;
3140
+ if (prevVal && prevVal.value === value && prevVal.meta === meta) return prevVal;
3141
+ return {
3142
+ value,
3143
+ meta
3144
+ };
3145
+ });
3146
+ this.handleSubmit = this.handleSubmit.bind(this);
3147
+ }
3148
+ /**
3149
+ * The current field state.
3150
+ */
3151
+ get state() {
3152
+ return this.store.state;
3153
+ }
3154
+ /**
3155
+ * @private
3156
+ */
3157
+ runValidator(props) {
3158
+ if (isStandardSchemaValidator(props.validate)) {
3159
+ const result = standardSchemaValidators[props.type](props.value, props.validate);
3160
+ if (props.type === "validate") return remapStandardSchemaResultForGroup(result);
3161
+ return result.then(remapStandardSchemaResultForGroup);
3162
+ }
3163
+ return props.validate(props.value);
3164
+ }
3165
+ handleSubmit(submitMeta) {
3166
+ return this._handleSubmit(submitMeta);
3167
+ }
3168
+ };
3169
+ function normalizeError(rawError) {
3170
+ if (rawError) return rawError;
3171
+ }
3172
+ function isGlobalGroupValidationError(error) {
3173
+ return !!error && typeof error === "object" && "fields" in error;
3174
+ }
3175
+ function remapStandardSchemaResultForGroup(result) {
3176
+ if (!result || typeof result !== "object") return result;
3177
+ if (!("form" in result) && !("fields" in result)) return result;
3178
+ const { form, fields, ...rest } = result;
3179
+ return {
3180
+ ...rest,
3181
+ group: form,
3182
+ fields
3183
+ };
2353
3184
  }
2354
3185
  function getErrorMapKey(cause) {
2355
3186
  switch (cause) {
@@ -2362,7 +3193,7 @@ function getErrorMapKey(cause) {
2362
3193
  }
2363
3194
  }
2364
3195
  //#endregion
2365
- //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/transform.js
3196
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.33.0/node_modules/@tanstack/form-core/dist/esm/transform.js
2366
3197
  function mergeAndUpdate(form, fn) {
2367
3198
  if (!fn) return;
2368
3199
  const newObj = Object.assign({}, form, { state: deepCopy(form.state) });
@@ -2373,6 +3204,7 @@ function mergeAndUpdate(form, fn) {
2373
3204
  values: null,
2374
3205
  validationMetaMap: null,
2375
3206
  fieldMetaBase: null,
3207
+ formGroupStateBase: null,
2376
3208
  isSubmitting: null,
2377
3209
  isSubmitted: null,
2378
3210
  isValidating: null,
@@ -2393,4 +3225,4 @@ function mergeAndUpdate(form, fn) {
2393
3225
  return newObj;
2394
3226
  }
2395
3227
  //#endregion
2396
- export { uuid as a, functionalUpdate as i, FieldApi as n, batch as o, FormApi as r, createStore as s, mergeAndUpdate as t };
3228
+ export { functionalUpdate as a, FormApi as i, FormGroupApi as n, uuid as o, FieldApi as r, mergeAndUpdate as t };