remix-validated-form 5.1.2 → 5.1.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,351 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
23
  ));
27
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
25
 
29
- // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js
30
- var require_use_sync_external_store_shim_production_min = __commonJS({
31
- "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js"(exports) {
32
- "use strict";
33
- var e = require("react");
34
- function h2(a2, b2) {
35
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
36
- }
37
- var k2 = "function" === typeof Object.is ? Object.is : h2;
38
- var l2 = e.useState;
39
- var m = e.useEffect;
40
- var n2 = e.useLayoutEffect;
41
- var p2 = e.useDebugValue;
42
- function q2(a2, b2) {
43
- var d2 = b2(), f2 = l2({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
44
- n2(function() {
45
- c2.value = d2;
46
- c2.getSnapshot = b2;
47
- r2(c2) && g2({ inst: c2 });
48
- }, [a2, d2, b2]);
49
- m(function() {
50
- r2(c2) && g2({ inst: c2 });
51
- return a2(function() {
52
- r2(c2) && g2({ inst: c2 });
53
- });
54
- }, [a2]);
55
- p2(d2);
56
- return d2;
57
- }
58
- function r2(a2) {
59
- var b2 = a2.getSnapshot;
60
- a2 = a2.value;
61
- try {
62
- var d2 = b2();
63
- return !k2(a2, d2);
64
- } catch (f2) {
65
- return true;
66
- }
67
- }
68
- function t2(a2, b2) {
69
- return b2();
70
- }
71
- var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2;
72
- exports.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u2;
73
- }
74
- });
75
-
76
- // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
77
- var require_use_sync_external_store_shim_development = __commonJS({
78
- "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
79
- "use strict";
80
- if (process.env.NODE_ENV !== "production") {
81
- (function() {
82
- "use strict";
83
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
84
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
85
- }
86
- var React3 = require("react");
87
- var ReactSharedInternals = React3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
88
- function error(format) {
89
- {
90
- {
91
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
92
- args[_key2 - 1] = arguments[_key2];
93
- }
94
- printWarning("error", format, args);
95
- }
96
- }
97
- }
98
- function printWarning(level, format, args) {
99
- {
100
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
101
- var stack = ReactDebugCurrentFrame.getStackAddendum();
102
- if (stack !== "") {
103
- format += "%s";
104
- args = args.concat([stack]);
105
- }
106
- var argsWithFormat = args.map(function(item) {
107
- return String(item);
108
- });
109
- argsWithFormat.unshift("Warning: " + format);
110
- Function.prototype.apply.call(console[level], console, argsWithFormat);
111
- }
112
- }
113
- function is(x2, y2) {
114
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
115
- }
116
- var objectIs = typeof Object.is === "function" ? Object.is : is;
117
- var useState3 = React3.useState, useEffect6 = React3.useEffect, useLayoutEffect2 = React3.useLayoutEffect, useDebugValue2 = React3.useDebugValue;
118
- var didWarnOld18Alpha = false;
119
- var didWarnUncachedGetSnapshot = false;
120
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
121
- {
122
- if (!didWarnOld18Alpha) {
123
- if (React3.startTransition !== void 0) {
124
- didWarnOld18Alpha = true;
125
- error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
126
- }
127
- }
128
- }
129
- var value = getSnapshot();
130
- {
131
- if (!didWarnUncachedGetSnapshot) {
132
- var cachedValue = getSnapshot();
133
- if (!objectIs(value, cachedValue)) {
134
- error("The result of getSnapshot should be cached to avoid an infinite loop");
135
- didWarnUncachedGetSnapshot = true;
136
- }
137
- }
138
- }
139
- var _useState = useState3({
140
- inst: {
141
- value,
142
- getSnapshot
143
- }
144
- }), inst = _useState[0].inst, forceUpdate = _useState[1];
145
- useLayoutEffect2(function() {
146
- inst.value = value;
147
- inst.getSnapshot = getSnapshot;
148
- if (checkIfSnapshotChanged(inst)) {
149
- forceUpdate({
150
- inst
151
- });
152
- }
153
- }, [subscribe, value, getSnapshot]);
154
- useEffect6(function() {
155
- if (checkIfSnapshotChanged(inst)) {
156
- forceUpdate({
157
- inst
158
- });
159
- }
160
- var handleStoreChange = function() {
161
- if (checkIfSnapshotChanged(inst)) {
162
- forceUpdate({
163
- inst
164
- });
165
- }
166
- };
167
- return subscribe(handleStoreChange);
168
- }, [subscribe]);
169
- useDebugValue2(value);
170
- return value;
171
- }
172
- function checkIfSnapshotChanged(inst) {
173
- var latestGetSnapshot = inst.getSnapshot;
174
- var prevValue = inst.value;
175
- try {
176
- var nextValue = latestGetSnapshot();
177
- return !objectIs(prevValue, nextValue);
178
- } catch (error2) {
179
- return true;
180
- }
181
- }
182
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
183
- return getSnapshot();
184
- }
185
- var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
186
- var isServerEnvironment = !canUseDOM;
187
- var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
188
- var useSyncExternalStore$2 = React3.useSyncExternalStore !== void 0 ? React3.useSyncExternalStore : shim;
189
- exports.useSyncExternalStore = useSyncExternalStore$2;
190
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
191
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
192
- }
193
- })();
194
- }
195
- }
196
- });
197
-
198
- // ../../node_modules/use-sync-external-store/shim/index.js
199
- var require_shim = __commonJS({
200
- "../../node_modules/use-sync-external-store/shim/index.js"(exports, module2) {
201
- "use strict";
202
- if (process.env.NODE_ENV === "production") {
203
- module2.exports = require_use_sync_external_store_shim_production_min();
204
- } else {
205
- module2.exports = require_use_sync_external_store_shim_development();
206
- }
207
- }
208
- });
209
-
210
- // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js
211
- var require_with_selector_production_min = __commonJS({
212
- "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js"(exports) {
213
- "use strict";
214
- var h2 = require("react");
215
- var n2 = require_shim();
216
- function p2(a2, b2) {
217
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
218
- }
219
- var q2 = "function" === typeof Object.is ? Object.is : p2;
220
- var r2 = n2.useSyncExternalStore;
221
- var t2 = h2.useRef;
222
- var u2 = h2.useEffect;
223
- var v2 = h2.useMemo;
224
- var w2 = h2.useDebugValue;
225
- exports.useSyncExternalStoreWithSelector = function(a2, b2, e, l2, g2) {
226
- var c2 = t2(null);
227
- if (null === c2.current) {
228
- var f2 = { hasValue: false, value: null };
229
- c2.current = f2;
230
- } else
231
- f2 = c2.current;
232
- c2 = v2(function() {
233
- function a3(a4) {
234
- if (!c3) {
235
- c3 = true;
236
- d3 = a4;
237
- a4 = l2(a4);
238
- if (void 0 !== g2 && f2.hasValue) {
239
- var b3 = f2.value;
240
- if (g2(b3, a4))
241
- return k2 = b3;
242
- }
243
- return k2 = a4;
244
- }
245
- b3 = k2;
246
- if (q2(d3, a4))
247
- return b3;
248
- var e2 = l2(a4);
249
- if (void 0 !== g2 && g2(b3, e2))
250
- return b3;
251
- d3 = a4;
252
- return k2 = e2;
253
- }
254
- var c3 = false, d3, k2, m = void 0 === e ? null : e;
255
- return [function() {
256
- return a3(b2());
257
- }, null === m ? void 0 : function() {
258
- return a3(m());
259
- }];
260
- }, [b2, e, l2, g2]);
261
- var d2 = r2(a2, c2[0], c2[1]);
262
- u2(function() {
263
- f2.hasValue = true;
264
- f2.value = d2;
265
- }, [d2]);
266
- w2(d2);
267
- return d2;
268
- };
269
- }
270
- });
271
-
272
- // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
273
- var require_with_selector_development = __commonJS({
274
- "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
275
- "use strict";
276
- if (process.env.NODE_ENV !== "production") {
277
- (function() {
278
- "use strict";
279
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
280
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
281
- }
282
- var React3 = require("react");
283
- var shim = require_shim();
284
- function is(x2, y2) {
285
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
286
- }
287
- var objectIs = typeof Object.is === "function" ? Object.is : is;
288
- var useSyncExternalStore = shim.useSyncExternalStore;
289
- var useRef6 = React3.useRef, useEffect6 = React3.useEffect, useMemo6 = React3.useMemo, useDebugValue2 = React3.useDebugValue;
290
- function useSyncExternalStoreWithSelector2(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
291
- var instRef = useRef6(null);
292
- var inst;
293
- if (instRef.current === null) {
294
- inst = {
295
- hasValue: false,
296
- value: null
297
- };
298
- instRef.current = inst;
299
- } else {
300
- inst = instRef.current;
301
- }
302
- var _useMemo = useMemo6(function() {
303
- var hasMemo = false;
304
- var memoizedSnapshot;
305
- var memoizedSelection;
306
- var memoizedSelector = function(nextSnapshot) {
307
- if (!hasMemo) {
308
- hasMemo = true;
309
- memoizedSnapshot = nextSnapshot;
310
- var _nextSelection = selector(nextSnapshot);
311
- if (isEqual !== void 0) {
312
- if (inst.hasValue) {
313
- var currentSelection = inst.value;
314
- if (isEqual(currentSelection, _nextSelection)) {
315
- memoizedSelection = currentSelection;
316
- return currentSelection;
317
- }
318
- }
319
- }
320
- memoizedSelection = _nextSelection;
321
- return _nextSelection;
322
- }
323
- var prevSnapshot = memoizedSnapshot;
324
- var prevSelection = memoizedSelection;
325
- if (objectIs(prevSnapshot, nextSnapshot)) {
326
- return prevSelection;
327
- }
328
- var nextSelection = selector(nextSnapshot);
329
- if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
330
- return prevSelection;
331
- }
332
- memoizedSnapshot = nextSnapshot;
333
- memoizedSelection = nextSelection;
334
- return nextSelection;
335
- };
336
- var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
337
- var getSnapshotWithSelector = function() {
338
- return memoizedSelector(getSnapshot());
339
- };
340
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
341
- return memoizedSelector(maybeGetServerSnapshot());
342
- };
343
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
344
- }, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
345
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
346
- useEffect6(function() {
347
- inst.hasValue = true;
348
- inst.value = value;
349
- }, [value]);
350
- useDebugValue2(value);
351
- return value;
352
- }
353
- exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector2;
354
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
355
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
356
- }
357
- })();
358
- }
359
- }
360
- });
361
-
362
- // ../../node_modules/use-sync-external-store/shim/with-selector.js
363
- var require_with_selector = __commonJS({
364
- "../../node_modules/use-sync-external-store/shim/with-selector.js"(exports, module2) {
365
- "use strict";
366
- if (process.env.NODE_ENV === "production") {
367
- module2.exports = require_with_selector_production_min();
368
- } else {
369
- module2.exports = require_with_selector_development();
370
- }
371
- }
372
- });
373
-
374
26
  // src/index.ts
375
27
  var src_exports = {};
376
28
  __export(src_exports, {
@@ -390,7 +42,7 @@ __export(src_exports, {
390
42
  module.exports = __toCommonJS(src_exports);
391
43
 
392
44
  // src/hooks.ts
393
- var import_react6 = require("react");
45
+ var import_react5 = require("react");
394
46
 
395
47
  // src/internal/getInputProps.ts
396
48
  var R = __toESM(require("remeda"));
@@ -476,8 +128,8 @@ var createGetInputProps = ({
476
128
  };
477
129
 
478
130
  // src/internal/hooks.ts
479
- var import_react3 = require("@remix-run/react");
480
- var import_react4 = require("react");
131
+ var import_react2 = require("@remix-run/react");
132
+ var import_react3 = require("react");
481
133
 
482
134
  // ../set-get/src/stringToPathArray.ts
483
135
  var stringToPathArray = (path) => {
@@ -485,7 +137,7 @@ var stringToPathArray = (path) => {
485
137
  return [];
486
138
  const match = path.match(/^\[(.+?)\](.*)$/) || path.match(/^\.?([^\.\[\]]+)(.*)$/);
487
139
  if (match) {
488
- const [_2, key, rest] = match;
140
+ const [_, key, rest] = match;
489
141
  return [/^\d+$/.test(key) ? Number(key) : key, ...stringToPathArray(rest)];
490
142
  }
491
143
  return [path];
@@ -500,10 +152,10 @@ function _setPathNormalized(object, path, value) {
500
152
  const leadingSegments = path.slice(0, -1);
501
153
  const lastSegment = path[path.length - 1];
502
154
  let obj = object;
503
- for (let i2 = 0; i2 < leadingSegments.length; i2++) {
504
- const segment = leadingSegments[i2];
155
+ for (let i = 0; i < leadingSegments.length; i++) {
156
+ const segment = leadingSegments[i];
505
157
  if (obj[segment] === void 0) {
506
- const nextSegment = (_a = leadingSegments[i2 + 1]) != null ? _a : lastSegment;
158
+ const nextSegment = (_a = leadingSegments[i + 1]) != null ? _a : lastSegment;
507
159
  obj[segment] = typeof nextSegment === "number" ? [] : {};
508
160
  }
509
161
  obj = obj[segment];
@@ -533,7 +185,7 @@ var InternalFormContext = (0, import_react.createContext)(null);
533
185
  // src/internal/hydratable.ts
534
186
  var serverData = (data) => ({
535
187
  hydrateTo: () => data,
536
- map: (fn2) => serverData(fn2(data))
188
+ map: (fn) => serverData(fn(data))
537
189
  });
538
190
  var hydratedData = () => ({
539
191
  hydrateTo: (hydratedData2) => hydratedData2,
@@ -548,459 +200,8 @@ var hydratable = {
548
200
 
549
201
  // src/internal/state/createFormStore.ts
550
202
  var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
551
-
552
- // ../../node_modules/zustand/esm/vanilla.mjs
553
- var import_meta = {};
554
- var createStoreImpl = (createState) => {
555
- let state;
556
- const listeners = /* @__PURE__ */ new Set();
557
- const setState = (partial, replace2) => {
558
- const nextState = typeof partial === "function" ? partial(state) : partial;
559
- if (!Object.is(nextState, state)) {
560
- const previousState = state;
561
- state = (replace2 != null ? replace2 : typeof nextState !== "object") ? nextState : Object.assign({}, state, nextState);
562
- listeners.forEach((listener) => listener(state, previousState));
563
- }
564
- };
565
- const getState = () => state;
566
- const subscribe = (listener) => {
567
- listeners.add(listener);
568
- return () => listeners.delete(listener);
569
- };
570
- const destroy = () => {
571
- if ((import_meta.env && import_meta.env.MODE) !== "production") {
572
- console.warn(
573
- "[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected."
574
- );
575
- }
576
- listeners.clear();
577
- };
578
- const api = { setState, getState, subscribe, destroy };
579
- state = createState(setState, getState, api);
580
- return api;
581
- };
582
- var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
583
-
584
- // ../../node_modules/zustand/esm/index.mjs
585
- var import_react2 = require("react");
586
- var import_with_selector = __toESM(require_with_selector(), 1);
587
- var import_meta2 = {};
588
- var { useSyncExternalStoreWithSelector } = import_with_selector.default;
589
- function useStore(api, selector = api.getState, equalityFn) {
590
- const slice = useSyncExternalStoreWithSelector(
591
- api.subscribe,
592
- api.getState,
593
- api.getServerState || api.getState,
594
- selector,
595
- equalityFn
596
- );
597
- (0, import_react2.useDebugValue)(slice);
598
- return slice;
599
- }
600
- var createImpl = (createState) => {
601
- if ((import_meta2.env && import_meta2.env.MODE) !== "production" && typeof createState !== "function") {
602
- console.warn(
603
- '[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.'
604
- );
605
- }
606
- const api = typeof createState === "function" ? createStore(createState) : createState;
607
- const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
608
- Object.assign(useBoundStore, api);
609
- return useBoundStore;
610
- };
611
- var create = (createState) => createState ? createImpl(createState) : createImpl;
612
-
613
- // ../../node_modules/immer/dist/immer.esm.mjs
614
- function n(n2) {
615
- for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e = 1; e < r2; e++)
616
- t2[e - 1] = arguments[e];
617
- if ("production" !== process.env.NODE_ENV) {
618
- var i2 = Y[n2], o2 = i2 ? "function" == typeof i2 ? i2.apply(null, t2) : i2 : "unknown error nr: " + n2;
619
- throw Error("[Immer] " + o2);
620
- }
621
- throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) {
622
- return "'" + n3 + "'";
623
- }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
624
- }
625
- function r(n2) {
626
- return !!n2 && !!n2[Q];
627
- }
628
- function t(n2) {
629
- var r2;
630
- return !!n2 && (function(n3) {
631
- if (!n3 || "object" != typeof n3)
632
- return false;
633
- var r3 = Object.getPrototypeOf(n3);
634
- if (null === r3)
635
- return true;
636
- var t2 = Object.hasOwnProperty.call(r3, "constructor") && r3.constructor;
637
- return t2 === Object || "function" == typeof t2 && Function.toString.call(t2) === Z;
638
- }(n2) || Array.isArray(n2) || !!n2[L] || !!(null === (r2 = n2.constructor) || void 0 === r2 ? void 0 : r2[L]) || s(n2) || v(n2));
639
- }
640
- function i(n2, r2, t2) {
641
- void 0 === t2 && (t2 = false), 0 === o(n2) ? (t2 ? Object.keys : nn)(n2).forEach(function(e) {
642
- t2 && "symbol" == typeof e || r2(e, n2[e], n2);
643
- }) : n2.forEach(function(t3, e) {
644
- return r2(e, t3, n2);
645
- });
646
- }
647
- function o(n2) {
648
- var r2 = n2[Q];
649
- return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v(n2) ? 3 : 0;
650
- }
651
- function u(n2, r2) {
652
- return 2 === o(n2) ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2);
653
- }
654
- function a(n2, r2) {
655
- return 2 === o(n2) ? n2.get(r2) : n2[r2];
656
- }
657
- function f(n2, r2, t2) {
658
- var e = o(n2);
659
- 2 === e ? n2.set(r2, t2) : 3 === e ? (n2.delete(r2), n2.add(t2)) : n2[r2] = t2;
660
- }
661
- function c(n2, r2) {
662
- return n2 === r2 ? 0 !== n2 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2;
663
- }
664
- function s(n2) {
665
- return X && n2 instanceof Map;
666
- }
667
- function v(n2) {
668
- return q && n2 instanceof Set;
669
- }
670
- function p(n2) {
671
- return n2.o || n2.t;
672
- }
673
- function l(n2) {
674
- if (Array.isArray(n2))
675
- return Array.prototype.slice.call(n2);
676
- var r2 = rn(n2);
677
- delete r2[Q];
678
- for (var t2 = nn(r2), e = 0; e < t2.length; e++) {
679
- var i2 = t2[e], o2 = r2[i2];
680
- false === o2.writable && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] });
681
- }
682
- return Object.create(Object.getPrototypeOf(n2), r2);
683
- }
684
- function d(n2, e) {
685
- return void 0 === e && (e = false), y(n2) || r(n2) || !t(n2) ? n2 : (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h), Object.freeze(n2), e && i(n2, function(n3, r2) {
686
- return d(r2, true);
687
- }, true), n2);
688
- }
689
- function h() {
690
- n(2);
691
- }
692
- function y(n2) {
693
- return null == n2 || "object" != typeof n2 || Object.isFrozen(n2);
694
- }
695
- function b(r2) {
696
- var t2 = tn[r2];
697
- return t2 || n(18, r2), t2;
698
- }
699
- function _() {
700
- return "production" === process.env.NODE_ENV || U || n(0), U;
701
- }
702
- function j(n2, r2) {
703
- r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2);
704
- }
705
- function O(n2) {
706
- g(n2), n2.p.forEach(S), n2.p = null;
707
- }
708
- function g(n2) {
709
- n2 === U && (U = n2.l);
710
- }
711
- function w(n2) {
712
- return U = { p: [], l: U, h: n2, m: true, _: 0 };
713
- }
714
- function S(n2) {
715
- var r2 = n2[Q];
716
- 0 === r2.i || 1 === r2.i ? r2.j() : r2.O = true;
717
- }
718
- function P(r2, e) {
719
- e._ = e.p.length;
720
- var i2 = e.p[0], o2 = void 0 !== r2 && r2 !== i2;
721
- return e.h.g || b("ES5").S(e, r2, o2), o2 ? (i2[Q].P && (O(e), n(4)), t(r2) && (r2 = M(e, r2), e.l || x(e, r2)), e.u && b("Patches").M(i2[Q].t, r2, e.u, e.s)) : r2 = M(e, i2, []), O(e), e.u && e.v(e.u, e.s), r2 !== H ? r2 : void 0;
722
- }
723
- function M(n2, r2, t2) {
724
- if (y(r2))
725
- return r2;
726
- var e = r2[Q];
727
- if (!e)
728
- return i(r2, function(i2, o3) {
729
- return A(n2, e, r2, i2, o3, t2);
730
- }, true), r2;
731
- if (e.A !== n2)
732
- return r2;
733
- if (!e.P)
734
- return x(n2, e.t, true), e.t;
735
- if (!e.I) {
736
- e.I = true, e.A._--;
737
- var o2 = 4 === e.i || 5 === e.i ? e.o = l(e.k) : e.o;
738
- i(3 === e.i ? new Set(o2) : o2, function(r3, i2) {
739
- return A(n2, e, o2, r3, i2, t2);
740
- }), x(n2, o2, false), t2 && n2.u && b("Patches").R(e, t2, n2.u, n2.s);
741
- }
742
- return e.o;
743
- }
744
- function A(e, i2, o2, a2, c2, s2) {
745
- if ("production" !== process.env.NODE_ENV && c2 === o2 && n(5), r(c2)) {
746
- var v2 = M(e, c2, s2 && i2 && 3 !== i2.i && !u(i2.D, a2) ? s2.concat(a2) : void 0);
747
- if (f(o2, a2, v2), !r(v2))
748
- return;
749
- e.m = false;
750
- }
751
- if (t(c2) && !y(c2)) {
752
- if (!e.h.F && e._ < 1)
753
- return;
754
- M(e, c2), i2 && i2.A.l || x(e, c2);
755
- }
756
- }
757
- function x(n2, r2, t2) {
758
- void 0 === t2 && (t2 = false), n2.h.F && n2.m && d(r2, t2);
759
- }
760
- function z(n2, r2) {
761
- var t2 = n2[Q];
762
- return (t2 ? p(t2) : n2)[r2];
763
- }
764
- function I(n2, r2) {
765
- if (r2 in n2)
766
- for (var t2 = Object.getPrototypeOf(n2); t2; ) {
767
- var e = Object.getOwnPropertyDescriptor(t2, r2);
768
- if (e)
769
- return e;
770
- t2 = Object.getPrototypeOf(t2);
771
- }
772
- }
773
- function k(n2) {
774
- n2.P || (n2.P = true, n2.l && k(n2.l));
775
- }
776
- function E(n2) {
777
- n2.o || (n2.o = l(n2.t));
778
- }
779
- function R2(n2, r2, t2) {
780
- var e = s(r2) ? b("MapSet").N(r2, t2) : v(r2) ? b("MapSet").T(r2, t2) : n2.g ? function(n3, r3) {
781
- var t3 = Array.isArray(n3), e2 = { i: t3 ? 1 : 0, A: r3 ? r3.A : _(), P: false, I: false, D: {}, l: r3, t: n3, k: null, o: null, j: null, C: false }, i2 = e2, o2 = en;
782
- t3 && (i2 = [e2], o2 = on);
783
- var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy;
784
- return e2.k = f2, e2.j = a2, f2;
785
- }(r2, t2) : b("ES5").J(r2, t2);
786
- return (t2 ? t2.A : _()).p.push(e), e;
787
- }
788
- function D(e) {
789
- return r(e) || n(22, e), function n2(r2) {
790
- if (!t(r2))
791
- return r2;
792
- var e2, u2 = r2[Q], c2 = o(r2);
793
- if (u2) {
794
- if (!u2.P && (u2.i < 4 || !b("ES5").K(u2)))
795
- return u2.t;
796
- u2.I = true, e2 = F(r2, c2), u2.I = false;
797
- } else
798
- e2 = F(r2, c2);
799
- return i(e2, function(r3, t2) {
800
- u2 && a(u2.t, r3) === t2 || f(e2, r3, n2(t2));
801
- }), 3 === c2 ? new Set(e2) : e2;
802
- }(e);
803
- }
804
- function F(n2, r2) {
805
- switch (r2) {
806
- case 2:
807
- return new Map(n2);
808
- case 3:
809
- return Array.from(n2);
810
- }
811
- return l(n2);
812
- }
813
- var G;
814
- var U;
815
- var W = "undefined" != typeof Symbol && "symbol" == typeof Symbol("x");
816
- var X = "undefined" != typeof Map;
817
- var q = "undefined" != typeof Set;
818
- var B = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect;
819
- var H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G);
820
- var L = W ? Symbol.for("immer-draftable") : "__$immer_draftable";
821
- var Q = W ? Symbol.for("immer-state") : "__$immer_state";
822
- var Y = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(n2) {
823
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n2;
824
- }, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(n2) {
825
- return "Cannot apply patch, path doesn't resolve: " + n2;
826
- }, 16: 'Sets cannot have "replace" patches.', 17: function(n2) {
827
- return "Unsupported patch operation: " + n2;
828
- }, 18: function(n2) {
829
- return "The plugin for '" + n2 + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n2 + "()` when initializing your application.";
830
- }, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(n2) {
831
- return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + n2 + "'";
832
- }, 22: function(n2) {
833
- return "'current' expects a draft, got: " + n2;
834
- }, 23: function(n2) {
835
- return "'original' expects a draft, got: " + n2;
836
- }, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" };
837
- var Z = "" + Object.prototype.constructor;
838
- var nn = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function(n2) {
839
- return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2));
840
- } : Object.getOwnPropertyNames;
841
- var rn = Object.getOwnPropertyDescriptors || function(n2) {
842
- var r2 = {};
843
- return nn(n2).forEach(function(t2) {
844
- r2[t2] = Object.getOwnPropertyDescriptor(n2, t2);
845
- }), r2;
846
- };
847
- var tn = {};
848
- var en = { get: function(n2, r2) {
849
- if (r2 === Q)
850
- return n2;
851
- var e = p(n2);
852
- if (!u(e, r2))
853
- return function(n3, r3, t2) {
854
- var e2, i3 = I(r3, t2);
855
- return i3 ? "value" in i3 ? i3.value : null === (e2 = i3.get) || void 0 === e2 ? void 0 : e2.call(n3.k) : void 0;
856
- }(n2, e, r2);
857
- var i2 = e[r2];
858
- return n2.I || !t(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = R2(n2.A.h, i2, n2)) : i2;
859
- }, has: function(n2, r2) {
860
- return r2 in p(n2);
861
- }, ownKeys: function(n2) {
862
- return Reflect.ownKeys(p(n2));
863
- }, set: function(n2, r2, t2) {
864
- var e = I(p(n2), r2);
865
- if (null == e ? void 0 : e.set)
866
- return e.set.call(n2.k, t2), true;
867
- if (!n2.P) {
868
- var i2 = z(p(n2), r2), o2 = null == i2 ? void 0 : i2[Q];
869
- if (o2 && o2.t === t2)
870
- return n2.o[r2] = t2, n2.D[r2] = false, true;
871
- if (c(t2, i2) && (void 0 !== t2 || u(n2.t, r2)))
872
- return true;
873
- E(n2), k(n2);
874
- }
875
- return n2.o[r2] === t2 && "number" != typeof t2 && (void 0 !== t2 || r2 in n2.o) || (n2.o[r2] = t2, n2.D[r2] = true, true);
876
- }, deleteProperty: function(n2, r2) {
877
- return void 0 !== z(n2.t, r2) || r2 in n2.t ? (n2.D[r2] = false, E(n2), k(n2)) : delete n2.D[r2], n2.o && delete n2.o[r2], true;
878
- }, getOwnPropertyDescriptor: function(n2, r2) {
879
- var t2 = p(n2), e = Reflect.getOwnPropertyDescriptor(t2, r2);
880
- return e ? { writable: true, configurable: 1 !== n2.i || "length" !== r2, enumerable: e.enumerable, value: t2[r2] } : e;
881
- }, defineProperty: function() {
882
- n(11);
883
- }, getPrototypeOf: function(n2) {
884
- return Object.getPrototypeOf(n2.t);
885
- }, setPrototypeOf: function() {
886
- n(12);
887
- } };
888
- var on = {};
889
- i(en, function(n2, r2) {
890
- on[n2] = function() {
891
- return arguments[0] = arguments[0][0], r2.apply(this, arguments);
892
- };
893
- }), on.deleteProperty = function(r2, t2) {
894
- return "production" !== process.env.NODE_ENV && isNaN(parseInt(t2)) && n(13), on.set.call(this, r2, t2, void 0);
895
- }, on.set = function(r2, t2, e) {
896
- return "production" !== process.env.NODE_ENV && "length" !== t2 && isNaN(parseInt(t2)) && n(14), en.set.call(this, r2[0], t2, e, r2[0]);
897
- };
898
- var un = function() {
899
- function e(r2) {
900
- var e2 = this;
901
- this.g = B, this.F = true, this.produce = function(r3, i3, o2) {
902
- if ("function" == typeof r3 && "function" != typeof i3) {
903
- var u2 = i3;
904
- i3 = r3;
905
- var a2 = e2;
906
- return function(n2) {
907
- var r4 = this;
908
- void 0 === n2 && (n2 = u2);
909
- for (var t2 = arguments.length, e3 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++)
910
- e3[o3 - 1] = arguments[o3];
911
- return a2.produce(n2, function(n3) {
912
- var t3;
913
- return (t3 = i3).call.apply(t3, [r4, n3].concat(e3));
914
- });
915
- };
916
- }
917
- var f2;
918
- if ("function" != typeof i3 && n(6), void 0 !== o2 && "function" != typeof o2 && n(7), t(r3)) {
919
- var c2 = w(e2), s2 = R2(e2, r3, void 0), v2 = true;
920
- try {
921
- f2 = i3(s2), v2 = false;
922
- } finally {
923
- v2 ? O(c2) : g(c2);
924
- }
925
- return "undefined" != typeof Promise && f2 instanceof Promise ? f2.then(function(n2) {
926
- return j(c2, o2), P(n2, c2);
927
- }, function(n2) {
928
- throw O(c2), n2;
929
- }) : (j(c2, o2), P(f2, c2));
930
- }
931
- if (!r3 || "object" != typeof r3) {
932
- if (void 0 === (f2 = i3(r3)) && (f2 = r3), f2 === H && (f2 = void 0), e2.F && d(f2, true), o2) {
933
- var p2 = [], l2 = [];
934
- b("Patches").M(r3, f2, p2, l2), o2(p2, l2);
935
- }
936
- return f2;
937
- }
938
- n(21, r3);
939
- }, this.produceWithPatches = function(n2, r3) {
940
- if ("function" == typeof n2)
941
- return function(r4) {
942
- for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++)
943
- i4[o3 - 1] = arguments[o3];
944
- return e2.produceWithPatches(r4, function(r5) {
945
- return n2.apply(void 0, [r5].concat(i4));
946
- });
947
- };
948
- var t2, i3, o2 = e2.produce(n2, r3, function(n3, r4) {
949
- t2 = n3, i3 = r4;
950
- });
951
- return "undefined" != typeof Promise && o2 instanceof Promise ? o2.then(function(n3) {
952
- return [n3, t2, i3];
953
- }) : [o2, t2, i3];
954
- }, "boolean" == typeof (null == r2 ? void 0 : r2.useProxies) && this.setUseProxies(r2.useProxies), "boolean" == typeof (null == r2 ? void 0 : r2.autoFreeze) && this.setAutoFreeze(r2.autoFreeze);
955
- }
956
- var i2 = e.prototype;
957
- return i2.createDraft = function(e2) {
958
- t(e2) || n(8), r(e2) && (e2 = D(e2));
959
- var i3 = w(this), o2 = R2(this, e2, void 0);
960
- return o2[Q].C = true, g(i3), o2;
961
- }, i2.finishDraft = function(r2, t2) {
962
- var e2 = r2 && r2[Q];
963
- "production" !== process.env.NODE_ENV && (e2 && e2.C || n(9), e2.I && n(10));
964
- var i3 = e2.A;
965
- return j(i3, t2), P(void 0, i3);
966
- }, i2.setAutoFreeze = function(n2) {
967
- this.F = n2;
968
- }, i2.setUseProxies = function(r2) {
969
- r2 && !B && n(20), this.g = r2;
970
- }, i2.applyPatches = function(n2, t2) {
971
- var e2;
972
- for (e2 = t2.length - 1; e2 >= 0; e2--) {
973
- var i3 = t2[e2];
974
- if (0 === i3.path.length && "replace" === i3.op) {
975
- n2 = i3.value;
976
- break;
977
- }
978
- }
979
- e2 > -1 && (t2 = t2.slice(e2 + 1));
980
- var o2 = b("Patches").$;
981
- return r(n2) ? o2(n2, t2) : this.produce(n2, function(n3) {
982
- return o2(n3, t2);
983
- });
984
- }, e;
985
- }();
986
- var an = new un();
987
- var fn = an.produce;
988
- var cn = an.produceWithPatches.bind(an);
989
- var sn = an.setAutoFreeze.bind(an);
990
- var vn = an.setUseProxies.bind(an);
991
- var pn = an.applyPatches.bind(an);
992
- var ln = an.createDraft.bind(an);
993
- var dn = an.finishDraft.bind(an);
994
-
995
- // ../../node_modules/zustand/esm/middleware/immer.mjs
996
- var immerImpl = (initializer) => (set, get2, store) => {
997
- store.setState = (updater, replace2, ...a2) => {
998
- const nextState = typeof updater === "function" ? fn(updater) : updater;
999
- return set(nextState, replace2, ...a2);
1000
- };
1001
- return initializer(store.setState, get2, store);
1002
- };
1003
- var immer = immerImpl;
203
+ var import_zustand = require("zustand");
204
+ var import_immer = require("zustand/middleware/immer");
1004
205
 
1005
206
  // src/internal/logic/requestSubmit.ts
1006
207
  var requestSubmit = (element, submitter) => {
@@ -1121,8 +322,8 @@ var insert = (array, index, value) => {
1121
322
  };
1122
323
  var insertEmpty = (array, index) => {
1123
324
  const tail = sparseSplice(array, index);
1124
- tail.forEach((item, i2) => {
1125
- sparseSplice(array, index + i2 + 1, 0, item);
325
+ tail.forEach((item, i) => {
326
+ sparseSplice(array, index + i + 1, 0, item);
1126
327
  });
1127
328
  };
1128
329
  var remove = (array, index) => {
@@ -1888,8 +1089,8 @@ var createFormState = (set, get2) => ({
1888
1089
  }
1889
1090
  }
1890
1091
  });
1891
- var useRootFormStore = create()(
1892
- immer((set, get2) => ({
1092
+ var useRootFormStore = (0, import_zustand.create)()(
1093
+ (0, import_immer.immer)((set, get2) => ({
1893
1094
  forms: {},
1894
1095
  form: (formId) => {
1895
1096
  var _a;
@@ -1920,7 +1121,7 @@ var useFormStore = (formId, selector) => {
1920
1121
 
1921
1122
  // src/internal/hooks.ts
1922
1123
  var useInternalFormContext = (formId, hookName) => {
1923
- const formContext = (0, import_react4.useContext)(InternalFormContext);
1124
+ const formContext = (0, import_react3.useContext)(InternalFormContext);
1924
1125
  if (formId)
1925
1126
  return { formId };
1926
1127
  if (formContext)
@@ -1935,7 +1136,7 @@ function useErrorResponseForForm({
1935
1136
  formId
1936
1137
  }) {
1937
1138
  var _a;
1938
- const actionData = (0, import_react3.useActionData)();
1139
+ const actionData = (0, import_react2.useActionData)();
1939
1140
  if (fetcher) {
1940
1141
  if ((_a = fetcher.data) == null ? void 0 : _a.fieldErrors)
1941
1142
  return fetcher.data;
@@ -1957,7 +1158,7 @@ var useFieldErrorsForForm = (context) => {
1957
1158
  var useDefaultValuesFromLoader = ({
1958
1159
  formId
1959
1160
  }) => {
1960
- const matches = (0, import_react3.useMatches)();
1161
+ const matches = (0, import_react2.useMatches)();
1961
1162
  if (typeof formId === "string") {
1962
1163
  const dataKey = formDefaultValuesKey(formId);
1963
1164
  const match = matches.reverse().find(
@@ -1988,14 +1189,14 @@ var useDefaultValuesForForm = (context) => {
1988
1189
  var useHasActiveFormSubmit = ({
1989
1190
  fetcher
1990
1191
  }) => {
1991
- let navigation = (0, import_react3.useNavigation)();
1192
+ let navigation = (0, import_react2.useNavigation)();
1992
1193
  const hasActiveSubmission = fetcher ? fetcher.state === "submitting" : navigation.state === "submitting" || navigation.state === "loading";
1993
1194
  return hasActiveSubmission;
1994
1195
  };
1995
1196
  var useFieldTouched = (field, { formId }) => {
1996
1197
  const touched = useFormStore(formId, (state) => state.touchedFields[field]);
1997
1198
  const setFieldTouched = useFormStore(formId, (state) => state.setTouched);
1998
- const setTouched = (0, import_react4.useCallback)(
1199
+ const setTouched = (0, import_react3.useCallback)(
1999
1200
  (touched2) => setFieldTouched(field, touched2),
2000
1201
  [field, setFieldTouched]
2001
1202
  );
@@ -2058,7 +1259,7 @@ var useFormSubactionProp = (formId) => useFormStore(formId, (state) => {
2058
1259
  var useFormValues = (formId) => useFormStore(formId, (state) => state.getValues);
2059
1260
 
2060
1261
  // src/internal/state/controlledFields.ts
2061
- var import_react5 = require("react");
1262
+ var import_react4 = require("react");
2062
1263
  var useControlledFieldValue = (context, field) => {
2063
1264
  const value = useFormStore(
2064
1265
  context.formId,
@@ -2076,7 +1277,7 @@ var useRegisterControlledField = (context, field) => {
2076
1277
  context.formId,
2077
1278
  (state) => state.controlledFields.valueUpdateResolvers[field]
2078
1279
  );
2079
- (0, import_react5.useEffect)(() => {
1280
+ (0, import_react4.useEffect)(() => {
2080
1281
  resolveUpdate == null ? void 0 : resolveUpdate();
2081
1282
  }, [resolveUpdate]);
2082
1283
  const register = useFormStore(
@@ -2087,7 +1288,7 @@ var useRegisterControlledField = (context, field) => {
2087
1288
  context.formId,
2088
1289
  (state) => state.controlledFields.unregister
2089
1290
  );
2090
- (0, import_react5.useEffect)(() => {
1291
+ (0, import_react4.useEffect)(() => {
2091
1292
  register(field);
2092
1293
  return () => unregister(field);
2093
1294
  }, [context.formId, field, register, unregister]);
@@ -2098,7 +1299,7 @@ var useControllableValue = (context, field) => {
2098
1299
  context.formId,
2099
1300
  (state) => state.controlledFields.setValue
2100
1301
  );
2101
- const setValue = (0, import_react5.useCallback)(
1302
+ const setValue = (0, import_react4.useCallback)(
2102
1303
  (value2) => setControlledFieldValue(field, value2),
2103
1304
  [field, setControlledFieldValue]
2104
1305
  );
@@ -2110,7 +1311,7 @@ var useUpdateControllableValue = (formId) => {
2110
1311
  formId,
2111
1312
  (state) => state.controlledFields.setValue
2112
1313
  );
2113
- return (0, import_react5.useCallback)(
1314
+ return (0, import_react4.useCallback)(
2114
1315
  (field, value) => setValue(field, value),
2115
1316
  [setValue]
2116
1317
  );
@@ -2135,11 +1336,11 @@ var useField = (name, options) => {
2135
1336
  const hasBeenSubmitted = useInternalHasBeenSubmitted(formContext.formId);
2136
1337
  const smartValidate = useSmartValidate(formContext.formId);
2137
1338
  const registerReceiveFocus = useRegisterReceiveFocus(formContext.formId);
2138
- (0, import_react6.useEffect)(() => {
1339
+ (0, import_react5.useEffect)(() => {
2139
1340
  if (handleReceiveFocus)
2140
1341
  return registerReceiveFocus(name, handleReceiveFocus);
2141
1342
  }, [handleReceiveFocus, name, registerReceiveFocus]);
2142
- const field = (0, import_react6.useMemo)(() => {
1343
+ const field = (0, import_react5.useMemo)(() => {
2143
1344
  const helpers = {
2144
1345
  error,
2145
1346
  clearError: () => clearError(name),
@@ -2199,12 +1400,12 @@ var setFormDefaults = (formId, defaultValues) => ({
2199
1400
  });
2200
1401
 
2201
1402
  // src/ValidatedForm.tsx
2202
- var import_react10 = require("@remix-run/react");
2203
- var import_react11 = require("react");
2204
- var R4 = __toESM(require("remeda"));
1403
+ var import_react9 = require("@remix-run/react");
1404
+ var import_react10 = require("react");
1405
+ var R3 = __toESM(require("remeda"));
2205
1406
 
2206
1407
  // src/internal/MultiValueMap.ts
2207
- var import_react7 = require("react");
1408
+ var import_react6 = require("react");
2208
1409
  var MultiValueMap = class {
2209
1410
  constructor() {
2210
1411
  this.dict = /* @__PURE__ */ new Map();
@@ -2238,8 +1439,8 @@ var MultiValueMap = class {
2238
1439
  }
2239
1440
  };
2240
1441
  var useMultiValueMap = () => {
2241
- const ref = (0, import_react7.useRef)(null);
2242
- return (0, import_react7.useCallback)(() => {
1442
+ const ref = (0, import_react6.useRef)(null);
1443
+ return (0, import_react6.useCallback)(() => {
2243
1444
  if (ref.current)
2244
1445
  return ref.current;
2245
1446
  ref.current = new MultiValueMap();
@@ -2248,10 +1449,10 @@ var useMultiValueMap = () => {
2248
1449
  };
2249
1450
 
2250
1451
  // src/internal/submissionCallbacks.ts
2251
- var import_react8 = require("react");
1452
+ var import_react7 = require("react");
2252
1453
  function useSubmitComplete(isSubmitting, callback) {
2253
- const isPending = (0, import_react8.useRef)(false);
2254
- (0, import_react8.useEffect)(() => {
1454
+ const isPending = (0, import_react7.useRef)(false);
1455
+ (0, import_react7.useEffect)(() => {
2255
1456
  if (isSubmitting) {
2256
1457
  isPending.current = true;
2257
1458
  }
@@ -2263,8 +1464,8 @@ function useSubmitComplete(isSubmitting, callback) {
2263
1464
  }
2264
1465
 
2265
1466
  // src/internal/util.ts
2266
- var import_react9 = require("react");
2267
- var R3 = __toESM(require("remeda"));
1467
+ var import_react8 = require("react");
1468
+ var R2 = __toESM(require("remeda"));
2268
1469
  var mergeRefs = (refs) => {
2269
1470
  return (value) => {
2270
1471
  refs.filter(Boolean).forEach((ref) => {
@@ -2276,11 +1477,11 @@ var mergeRefs = (refs) => {
2276
1477
  });
2277
1478
  };
2278
1479
  };
2279
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react9.useLayoutEffect : import_react9.useEffect;
1480
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react8.useLayoutEffect : import_react8.useEffect;
2280
1481
  var useDeepEqualsMemo = (item) => {
2281
- const ref = (0, import_react9.useRef)(item);
2282
- const areEqual = ref.current === item || R3.equals(ref.current, item);
2283
- (0, import_react9.useEffect)(() => {
1482
+ const ref = (0, import_react8.useRef)(item);
1483
+ const areEqual = ref.current === item || R2.equals(ref.current, item);
1484
+ (0, import_react8.useEffect)(() => {
2284
1485
  if (!areEqual) {
2285
1486
  ref.current = item;
2286
1487
  }
@@ -2302,7 +1503,7 @@ var focusFirstInvalidInput = (fieldErrors, customFocusHandlers, formElement) =>
2302
1503
  return input.name;
2303
1504
  return null;
2304
1505
  }).filter(nonNull).filter((name) => name in fieldErrors);
2305
- const uniqueNamesInOrder = R4.uniq(namesInOrder);
1506
+ const uniqueNamesInOrder = R3.uniq(namesInOrder);
2306
1507
  for (const fieldName of uniqueNamesInOrder) {
2307
1508
  if (customFocusHandlers.has(fieldName)) {
2308
1509
  customFocusHandlers.getAll(fieldName).forEach((handler) => {
@@ -2332,7 +1533,7 @@ var focusFirstInvalidInput = (fieldErrors, customFocusHandlers, formElement) =>
2332
1533
  }
2333
1534
  };
2334
1535
  var useFormId = (providedId) => {
2335
- const [symbolId] = (0, import_react11.useState)(() => Symbol("remix-validated-form-id"));
1536
+ const [symbolId] = (0, import_react10.useState)(() => Symbol("remix-validated-form-id"));
2336
1537
  return providedId != null ? providedId : symbolId;
2337
1538
  };
2338
1539
  var FormResetter = ({
@@ -2388,7 +1589,7 @@ function ValidatedForm({
2388
1589
  var _a;
2389
1590
  const formId = useFormId(id);
2390
1591
  const providedDefaultValues = useDeepEqualsMemo(unMemoizedDefaults);
2391
- const contextValue = (0, import_react11.useMemo)(
1592
+ const contextValue = (0, import_react10.useMemo)(
2392
1593
  () => ({
2393
1594
  formId,
2394
1595
  action,
@@ -2401,9 +1602,9 @@ function ValidatedForm({
2401
1602
  const backendError = useErrorResponseForForm(contextValue);
2402
1603
  const backendDefaultValues = useDefaultValuesFromLoader(contextValue);
2403
1604
  const hasActiveSubmission = useHasActiveFormSubmit(contextValue);
2404
- const formRef = (0, import_react11.useRef)(null);
2405
- const Form = (_a = fetcher == null ? void 0 : fetcher.Form) != null ? _a : import_react10.Form;
2406
- const submit = (0, import_react10.useSubmit)();
1605
+ const formRef = (0, import_react10.useRef)(null);
1606
+ const Form = (_a = fetcher == null ? void 0 : fetcher.Form) != null ? _a : import_react9.Form;
1607
+ const submit = (0, import_react9.useSubmit)();
2407
1608
  const setFieldErrors = useSetFieldErrors(formId);
2408
1609
  const setFieldError = useFormStore(formId, (state) => state.setFieldError);
2409
1610
  const reset = useFormStore(formId, (state) => state.reset);
@@ -2417,7 +1618,7 @@ function ValidatedForm({
2417
1618
  const cleanupForm = useRootFormStore((state) => state.cleanupForm);
2418
1619
  const registerForm = useRootFormStore((state) => state.registerForm);
2419
1620
  const customFocusHandlers = useMultiValueMap();
2420
- const registerReceiveFocus = (0, import_react11.useCallback)(
1621
+ const registerReceiveFocus = (0, import_react10.useCallback)(
2421
1622
  (fieldName, handler) => {
2422
1623
  customFocusHandlers().add(fieldName, handler);
2423
1624
  return () => {
@@ -2451,7 +1652,7 @@ function ValidatedForm({
2451
1652
  useIsomorphicLayoutEffect(() => {
2452
1653
  setFormElementInState(formRef.current);
2453
1654
  }, [setFormElementInState]);
2454
- (0, import_react11.useEffect)(() => {
1655
+ (0, import_react10.useEffect)(() => {
2455
1656
  var _a2;
2456
1657
  setFieldErrors((_a2 = backendError == null ? void 0 : backendError.fieldErrors) != null ? _a2 : {});
2457
1658
  if (!disableFocusOnError && (backendError == null ? void 0 : backendError.fieldErrors)) {
@@ -2549,7 +1750,7 @@ function ValidatedForm({
2549
1750
  }
2550
1751
 
2551
1752
  // src/validation/createValidator.ts
2552
- var R5 = __toESM(require("remeda"));
1753
+ var R4 = __toESM(require("remeda"));
2553
1754
 
2554
1755
  // src/internal/flatten.ts
2555
1756
  var objectFromPathEntries = (entries) => {
@@ -2567,7 +1768,7 @@ var preprocessFormData = (data) => {
2567
1768
  return objectFromPathEntries([...data.entries()]);
2568
1769
  return objectFromPathEntries(Object.entries(data));
2569
1770
  };
2570
- var omitInternalFields = (data) => R5.omit(data, [FORM_ID_FIELD]);
1771
+ var omitInternalFields = (data) => R4.omit(data, [FORM_ID_FIELD]);
2571
1772
  function createValidator(validator) {
2572
1773
  return {
2573
1774
  validate: async (value) => {
@@ -2597,10 +1798,10 @@ function createValidator(validator) {
2597
1798
  }
2598
1799
 
2599
1800
  // src/userFacingFormContext.ts
2600
- var import_react13 = require("react");
1801
+ var import_react12 = require("react");
2601
1802
 
2602
1803
  // src/unreleased/formStateHooks.ts
2603
- var import_react12 = require("react");
1804
+ var import_react11 = require("react");
2604
1805
  var useFormState = (formId) => {
2605
1806
  const formContext = useInternalFormContext(formId, "useFormState");
2606
1807
  const isSubmitting = useInternalIsSubmitting(formContext.formId);
@@ -2615,7 +1816,7 @@ var useFormState = (formId) => {
2615
1816
  const fieldErrorsFromState = useFieldErrors(formContext.formId);
2616
1817
  const fieldErrorsToUse = useFieldErrorsForForm(formContext);
2617
1818
  const hydratedFieldErrors = fieldErrorsToUse.hydrateTo(fieldErrorsFromState);
2618
- return (0, import_react12.useMemo)(
1819
+ return (0, import_react11.useMemo)(
2619
1820
  () => ({
2620
1821
  action,
2621
1822
  subaction,
@@ -2648,7 +1849,7 @@ var useFormHelpers = (formId) => {
2648
1849
  const reset = useResetFormElement(formContext.formId);
2649
1850
  const submit = useSubmitForm(formContext.formId);
2650
1851
  const getValues = useFormValues(formContext.formId);
2651
- return (0, import_react12.useMemo)(
1852
+ return (0, import_react11.useMemo)(
2652
1853
  () => ({
2653
1854
  setTouched,
2654
1855
  validateField: async (fieldName) => {
@@ -2693,7 +1894,7 @@ var useFormContext = (formId) => {
2693
1894
  getValues
2694
1895
  } = useFormHelpers(formId);
2695
1896
  const registerReceiveFocus = useRegisterReceiveFocus(context.formId);
2696
- const clearError = (0, import_react13.useCallback)(
1897
+ const clearError = (0, import_react12.useCallback)(
2697
1898
  (...names) => {
2698
1899
  names.forEach((name) => {
2699
1900
  internalClearError(name);
@@ -2701,7 +1902,7 @@ var useFormContext = (formId) => {
2701
1902
  },
2702
1903
  [internalClearError]
2703
1904
  );
2704
- return (0, import_react13.useMemo)(
1905
+ return (0, import_react12.useMemo)(
2705
1906
  () => ({
2706
1907
  ...state,
2707
1908
  setFieldTouched: setTouched,
@@ -2731,8 +1932,8 @@ var useFormContext = (formId) => {
2731
1932
 
2732
1933
  // src/internal/state/fieldArray.tsx
2733
1934
  var import_nanoid = require("nanoid");
1935
+ var import_react13 = require("react");
2734
1936
  var import_react14 = require("react");
2735
- var import_react15 = require("react");
2736
1937
  var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
2737
1938
  var import_jsx_runtime2 = require("react/jsx-runtime");
2738
1939
  var useInternalFieldArray = (context, field, validationBehavior) => {
@@ -2747,7 +1948,7 @@ var useInternalFieldArray = (context, field, validationBehavior) => {
2747
1948
  ...validationBehavior
2748
1949
  };
2749
1950
  const behavior = hasBeenSubmitted ? resolvedValidationBehavior.whenSubmitted : resolvedValidationBehavior.initial;
2750
- const maybeValidate = (0, import_react15.useCallback)(() => {
1951
+ const maybeValidate = (0, import_react14.useCallback)(() => {
2751
1952
  if (behavior === "onChange") {
2752
1953
  validateField({ alwaysIncludeErrorsFromFields: [field] });
2753
1954
  }
@@ -2760,12 +1961,12 @@ var useInternalFieldArray = (context, field, validationBehavior) => {
2760
1961
  context.formId,
2761
1962
  (state) => state.controlledFields.array
2762
1963
  );
2763
- const arrayValue = (0, import_react14.useMemo)(() => value != null ? value : [], [value]);
2764
- const keyRef = (0, import_react14.useRef)([]);
1964
+ const arrayValue = (0, import_react13.useMemo)(() => value != null ? value : [], [value]);
1965
+ const keyRef = (0, import_react13.useRef)([]);
2765
1966
  if (keyRef.current.length !== arrayValue.length) {
2766
1967
  keyRef.current = arrayValue.map(() => (0, import_nanoid.nanoid)());
2767
1968
  }
2768
- const helpers = (0, import_react14.useMemo)(
1969
+ const helpers = (0, import_react13.useMemo)(
2769
1970
  () => ({
2770
1971
  push: (item) => {
2771
1972
  arr.push(field, item);
@@ -2810,7 +2011,7 @@ var useInternalFieldArray = (context, field, validationBehavior) => {
2810
2011
  }),
2811
2012
  [arr, field, maybeValidate]
2812
2013
  );
2813
- const valueWithKeys = (0, import_react14.useMemo)(() => {
2014
+ const valueWithKeys = (0, import_react13.useMemo)(() => {
2814
2015
  const result = [];
2815
2016
  arrayValue.forEach((item, index) => {
2816
2017
  result[index] = {
@@ -2855,40 +2056,4 @@ function FieldArray({
2855
2056
  useUpdateControlledField,
2856
2057
  validationError
2857
2058
  });
2858
- /**
2859
- * @license React
2860
- * use-sync-external-store-shim.development.js
2861
- *
2862
- * Copyright (c) Facebook, Inc. and its affiliates.
2863
- *
2864
- * This source code is licensed under the MIT license found in the
2865
- * LICENSE file in the root directory of this source tree.
2866
- */
2867
- /**
2868
- * @license React
2869
- * use-sync-external-store-shim.production.min.js
2870
- *
2871
- * Copyright (c) Facebook, Inc. and its affiliates.
2872
- *
2873
- * This source code is licensed under the MIT license found in the
2874
- * LICENSE file in the root directory of this source tree.
2875
- */
2876
- /**
2877
- * @license React
2878
- * use-sync-external-store-shim/with-selector.development.js
2879
- *
2880
- * Copyright (c) Facebook, Inc. and its affiliates.
2881
- *
2882
- * This source code is licensed under the MIT license found in the
2883
- * LICENSE file in the root directory of this source tree.
2884
- */
2885
- /**
2886
- * @license React
2887
- * use-sync-external-store-shim/with-selector.production.min.js
2888
- *
2889
- * Copyright (c) Facebook, Inc. and its affiliates.
2890
- *
2891
- * This source code is licensed under the MIT license found in the
2892
- * LICENSE file in the root directory of this source tree.
2893
- */
2894
2059
  //# sourceMappingURL=index.cjs.js.map