@formisch/solid 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.js CHANGED
@@ -4,6 +4,7 @@ import { memo, template, use, spread, mergeProps } from 'solid-js/web';
4
4
 
5
5
  // ../../packages/core/dist/index.solid.js
6
6
  var framework = "solid";
7
+ // @__NO_SIDE_EFFECTS__
7
8
  function createSignal(initialValue) {
8
9
  const [getSignal, setSignal] = createSignal$1(initialValue);
9
10
  return {
@@ -27,9 +28,9 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
27
28
  const initialElements = [];
28
29
  internalFieldStore.initialElements = initialElements;
29
30
  internalFieldStore.elements = initialElements;
30
- internalFieldStore.errors = createSignal(null);
31
- internalFieldStore.isTouched = createSignal(false);
32
- internalFieldStore.isDirty = createSignal(false);
31
+ internalFieldStore.errors = /* @__PURE__ */ createSignal(null);
32
+ internalFieldStore.isTouched = /* @__PURE__ */ createSignal(false);
33
+ internalFieldStore.isDirty = /* @__PURE__ */ createSignal(false);
33
34
  if (schema.type === "array" || schema.type === "loose_tuple" || schema.type === "strict_tuple" || schema.type === "tuple") {
34
35
  if (internalFieldStore.kind && internalFieldStore.kind !== "array") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "array"`);
35
36
  internalFieldStore.kind = "array";
@@ -49,13 +50,13 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
49
50
  path.pop();
50
51
  }
51
52
  const arrayInput = nullish && initialInput == null ? initialInput : true;
52
- internalFieldStore.initialInput = createSignal(arrayInput);
53
- internalFieldStore.startInput = createSignal(arrayInput);
54
- internalFieldStore.input = createSignal(arrayInput);
53
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal(arrayInput);
54
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal(arrayInput);
55
+ internalFieldStore.input = /* @__PURE__ */ createSignal(arrayInput);
55
56
  const initialItems = internalFieldStore.children.map(createUniqueId);
56
- internalFieldStore.initialItems = createSignal(initialItems);
57
- internalFieldStore.startItems = createSignal(initialItems);
58
- internalFieldStore.items = createSignal(initialItems);
57
+ internalFieldStore.initialItems = /* @__PURE__ */ createSignal(initialItems);
58
+ internalFieldStore.startItems = /* @__PURE__ */ createSignal(initialItems);
59
+ internalFieldStore.items = /* @__PURE__ */ createSignal(initialItems);
59
60
  }
60
61
  } else if (schema.type === "loose_object" || schema.type === "object" || schema.type === "strict_object") {
61
62
  if (internalFieldStore.kind && internalFieldStore.kind !== "object") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "object"`);
@@ -69,16 +70,16 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
69
70
  path.pop();
70
71
  }
71
72
  const objectInput = nullish && initialInput == null ? initialInput : true;
72
- internalFieldStore.initialInput = createSignal(objectInput);
73
- internalFieldStore.startInput = createSignal(objectInput);
74
- internalFieldStore.input = createSignal(objectInput);
73
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal(objectInput);
74
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal(objectInput);
75
+ internalFieldStore.input = /* @__PURE__ */ createSignal(objectInput);
75
76
  }
76
77
  } else {
77
78
  internalFieldStore.kind = "value";
78
79
  if (internalFieldStore.kind === "value") {
79
- internalFieldStore.initialInput = createSignal(initialInput);
80
- internalFieldStore.startInput = createSignal(initialInput);
81
- internalFieldStore.input = createSignal(initialInput);
80
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal(initialInput);
81
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal(initialInput);
82
+ internalFieldStore.input = /* @__PURE__ */ createSignal(initialInput);
82
83
  }
83
84
  }
84
85
  }
@@ -190,11 +191,12 @@ function swapItemState(firstInternalFieldStore, secondInternalFieldStore) {
190
191
  });
191
192
  });
192
193
  }
194
+ // @__NO_SIDE_EFFECTS__
193
195
  function getFieldInput(internalFieldStore) {
194
196
  if (internalFieldStore.kind === "array") {
195
197
  if (internalFieldStore.input.value) {
196
198
  const value = [];
197
- for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = getFieldInput(internalFieldStore.children[index]);
199
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
198
200
  return value;
199
201
  }
200
202
  return internalFieldStore.input.value;
@@ -202,13 +204,14 @@ function getFieldInput(internalFieldStore) {
202
204
  if (internalFieldStore.kind === "object") {
203
205
  if (internalFieldStore.input.value) {
204
206
  const value = {};
205
- for (const key in internalFieldStore.children) value[key] = getFieldInput(internalFieldStore.children[key]);
207
+ for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
206
208
  return value;
207
209
  }
208
210
  return internalFieldStore.input.value;
209
211
  }
210
212
  return internalFieldStore.input.value;
211
213
  }
214
+ // @__NO_SIDE_EFFECTS__
212
215
  function getElementInput(element, internalFieldStore) {
213
216
  if (element.options && element.multiple) return [...element.options].filter((option) => option.selected && !option.disabled).map((option) => option.value);
214
217
  if (element.type === "checkbox") {
@@ -217,7 +220,7 @@ function getElementInput(element, internalFieldStore) {
217
220
  return element.checked;
218
221
  }
219
222
  if (element.type === "radio") {
220
- const prevValue = untrack(() => getFieldInput(internalFieldStore));
223
+ const prevValue = untrack(() => /* @__PURE__ */ getFieldInput(internalFieldStore));
221
224
  if (element.checked) return [...prevValue, element.value];
222
225
  return prevValue.filter((value) => value !== element.value);
223
226
  }
@@ -227,18 +230,20 @@ function getElementInput(element, internalFieldStore) {
227
230
  }
228
231
  return element.value;
229
232
  }
233
+ // @__NO_SIDE_EFFECTS__
230
234
  function getFieldBool(internalFieldStore, type) {
231
235
  if (internalFieldStore[type].value) return true;
232
236
  if (internalFieldStore.kind === "array") {
233
- for (let index = 0; index < internalFieldStore.items.value.length; index++) if (getFieldBool(internalFieldStore.children[index], type)) return true;
237
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
234
238
  return false;
235
239
  }
236
240
  if (internalFieldStore.kind == "object") {
237
- for (const key in internalFieldStore.children) if (getFieldBool(internalFieldStore.children[key], type)) return true;
241
+ for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
238
242
  return false;
239
243
  }
240
244
  return false;
241
245
  }
246
+ // @__NO_SIDE_EFFECTS__
242
247
  function getFieldStore(internalFormStore, path) {
243
248
  let internalFieldStore = internalFormStore;
244
249
  for (const key of path) internalFieldStore = internalFieldStore.children[key];
@@ -271,7 +276,7 @@ function setNestedInput(internalFieldStore, input) {
271
276
  }
272
277
  internalFieldStore.items.value = [...items, ...arrayInput.slice(items.length).map(createUniqueId)];
273
278
  }
274
- for (let index = 0; index < items.length; index++) setNestedInput(internalFieldStore.children[index], arrayInput[index]);
279
+ for (let index = 0; index < arrayInput.length; index++) setNestedInput(internalFieldStore.children[index], arrayInput[index]);
275
280
  internalFieldStore.input.value = input == null ? input : true;
276
281
  internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== items.length;
277
282
  } else if (internalFieldStore.kind === "object") {
@@ -326,18 +331,19 @@ function walkFieldStore(internalFieldStore, callback) {
326
331
  function createFormStore(config, parse) {
327
332
  const store = {};
328
333
  initializeFieldStore(store, config.schema, config.initialInput, []);
334
+ store.validators = 0;
329
335
  store.validate = config.validate ?? "submit";
330
336
  store.revalidate = config.revalidate ?? "input";
331
337
  store.parse = parse;
332
- store.isSubmitting = createSignal(false);
333
- store.isSubmitted = createSignal(false);
334
- store.isValidating = createSignal(false);
338
+ store.isSubmitting = /* @__PURE__ */ createSignal(false);
339
+ store.isSubmitted = /* @__PURE__ */ createSignal(false);
340
+ store.isValidating = /* @__PURE__ */ createSignal(false);
335
341
  return store;
336
342
  }
337
343
  async function validateFormInput(internalFormStore, config) {
338
344
  internalFormStore.validators++;
339
345
  internalFormStore.isValidating.value = true;
340
- const result = await internalFormStore.parse(untrack(() => getFieldInput(internalFormStore)));
346
+ const result = await internalFormStore.parse(untrack(() => /* @__PURE__ */ getFieldInput(internalFormStore)));
341
347
  let rootErrors;
342
348
  let nestedErrors;
343
349
  if (result.issues) {
@@ -377,14 +383,15 @@ async function validateFormInput(internalFormStore, config) {
377
383
  return result;
378
384
  }
379
385
  function validateIfRequired(internalFormStore, internalFieldStore, validationMode) {
380
- if (validationMode === (internalFormStore.validate === "initial" || (internalFormStore.validate === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidate : internalFormStore.validate)) validateFormInput(internalFormStore);
386
+ if (validationMode === (internalFormStore.validate === "initial" || (internalFormStore.validate === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => /* @__PURE__ */ getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidate : internalFormStore.validate)) validateFormInput(internalFormStore);
381
387
  }
382
388
  var INTERNAL = "~internal";
383
389
 
384
390
  // ../../packages/methods/dist/index.solid.js
385
- function focus(config) {
386
- getFieldStore(config.form[INTERNAL], config.path).elements[0]?.focus();
391
+ function focus(form, config) {
392
+ getFieldStore(form[INTERNAL], config.path).elements[0]?.focus();
387
393
  }
394
+ // @__NO_SIDE_EFFECTS__
388
395
  function getAllErrors(form) {
389
396
  let allErrors = null;
390
397
  walkFieldStore(form[INTERNAL], (internalFieldStore) => {
@@ -394,12 +401,15 @@ function getAllErrors(form) {
394
401
  });
395
402
  return allErrors;
396
403
  }
404
+ // @__NO_SIDE_EFFECTS__
397
405
  function getErrors(form, config) {
398
406
  return (config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]).errors.value;
399
407
  }
408
+ // @__NO_SIDE_EFFECTS__
400
409
  function getInput(form, config) {
401
410
  return getFieldInput(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]);
402
411
  }
412
+ // @__NO_SIDE_EFFECTS__
403
413
  function handleSubmit(form, handler) {
404
414
  return async (event) => {
405
415
  event.preventDefault();
@@ -453,10 +463,10 @@ function move(form, config) {
453
463
  internalArrayStore.items.value = newItems;
454
464
  const tempInternalFieldStore = {};
455
465
  initializeFieldStore(tempInternalFieldStore, internalArrayStore.schema.item, void 0, []);
456
- copyItemState(internalArrayStore.children[config.from < config.to ? config.from : config.to], tempInternalFieldStore);
466
+ copyItemState(internalArrayStore.children[config.from], tempInternalFieldStore);
457
467
  if (config.from < config.to) for (let index = config.from; index < config.to; index++) copyItemState(internalArrayStore.children[index + 1], internalArrayStore.children[index]);
458
468
  else for (let index = config.from; index > config.to; index--) copyItemState(internalArrayStore.children[index - 1], internalArrayStore.children[index]);
459
- copyItemState(tempInternalFieldStore, internalArrayStore.children[config.from < config.to ? config.to : config.from]);
469
+ copyItemState(tempInternalFieldStore, internalArrayStore.children[config.to]);
460
470
  internalArrayStore.isTouched.value = true;
461
471
  internalArrayStore.isDirty.value = internalArrayStore.startItems.value.join() !== newItems.join();
462
472
  validateIfRequired(internalFormStore, internalArrayStore, "input");
@@ -553,6 +563,7 @@ function swap(form, config) {
553
563
  function validate(form, config) {
554
564
  return validateFormInput(form[INTERNAL], config);
555
565
  }
566
+ // @__NO_SIDE_EFFECTS__
556
567
  function createForm(config) {
557
568
  const internalFormStore = createFormStore(
558
569
  config,
@@ -606,6 +617,7 @@ function unwrap(value) {
606
617
  }
607
618
 
608
619
  // src/primitives/useField/useField.ts
620
+ // @__NO_SIDE_EFFECTS__
609
621
  function useField(form, config) {
610
622
  const getPath = createMemo(() => unwrap(config).path);
611
623
  const getInternalFormStore = createMemo(() => unwrap(form)[INTERNAL]);
@@ -690,6 +702,7 @@ function useField(form, config) {
690
702
  }
691
703
  };
692
704
  }
705
+ // @__NO_SIDE_EFFECTS__
693
706
  function useFieldArray(form, config) {
694
707
  const getInternalFieldStore = createMemo(
695
708
  () => getFieldStore(
@@ -729,12 +742,14 @@ function useFieldArray(form, config) {
729
742
  }
730
743
 
731
744
  // src/components/Field/Field.tsx
745
+ // @__NO_SIDE_EFFECTS__
732
746
  function Field(props) {
733
747
  const field = useField(() => props.of, () => ({
734
748
  path: props.path
735
749
  }));
736
750
  return memo(() => props.children(field));
737
751
  }
752
+ // @__NO_SIDE_EFFECTS__
738
753
  function FieldArray(props) {
739
754
  const field = useFieldArray(() => props.of, () => ({
740
755
  path: props.path
@@ -742,6 +757,7 @@ function FieldArray(props) {
742
757
  return memo(() => props.children(field));
743
758
  }
744
759
  var _tmpl$ = /* @__PURE__ */ template(`<form>`);
760
+ // @__NO_SIDE_EFFECTS__
745
761
  function Form(props) {
746
762
  const [, other] = splitProps(props, ["of", "onSubmit"]);
747
763
  return (() => {
package/dist/dev.jsx CHANGED
@@ -2,6 +2,7 @@
2
2
  import * as v from "valibot";
3
3
  import { batch, createSignal as createSignal$1, createUniqueId as createId, untrack } from "solid-js";
4
4
  var framework = "solid";
5
+ // @__NO_SIDE_EFFECTS__
5
6
  function createSignal(initialValue) {
6
7
  const [getSignal, setSignal] = createSignal$1(initialValue);
7
8
  return {
@@ -25,9 +26,9 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
25
26
  const initialElements = [];
26
27
  internalFieldStore.initialElements = initialElements;
27
28
  internalFieldStore.elements = initialElements;
28
- internalFieldStore.errors = createSignal(null);
29
- internalFieldStore.isTouched = createSignal(false);
30
- internalFieldStore.isDirty = createSignal(false);
29
+ internalFieldStore.errors = /* @__PURE__ */ createSignal(null);
30
+ internalFieldStore.isTouched = /* @__PURE__ */ createSignal(false);
31
+ internalFieldStore.isDirty = /* @__PURE__ */ createSignal(false);
31
32
  if (schema.type === "array" || schema.type === "loose_tuple" || schema.type === "strict_tuple" || schema.type === "tuple") {
32
33
  if (internalFieldStore.kind && internalFieldStore.kind !== "array") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "array"`);
33
34
  internalFieldStore.kind = "array";
@@ -47,13 +48,13 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
47
48
  path.pop();
48
49
  }
49
50
  const arrayInput = nullish && initialInput == null ? initialInput : true;
50
- internalFieldStore.initialInput = createSignal(arrayInput);
51
- internalFieldStore.startInput = createSignal(arrayInput);
52
- internalFieldStore.input = createSignal(arrayInput);
51
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal(arrayInput);
52
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal(arrayInput);
53
+ internalFieldStore.input = /* @__PURE__ */ createSignal(arrayInput);
53
54
  const initialItems = internalFieldStore.children.map(createId);
54
- internalFieldStore.initialItems = createSignal(initialItems);
55
- internalFieldStore.startItems = createSignal(initialItems);
56
- internalFieldStore.items = createSignal(initialItems);
55
+ internalFieldStore.initialItems = /* @__PURE__ */ createSignal(initialItems);
56
+ internalFieldStore.startItems = /* @__PURE__ */ createSignal(initialItems);
57
+ internalFieldStore.items = /* @__PURE__ */ createSignal(initialItems);
57
58
  }
58
59
  } else if (schema.type === "loose_object" || schema.type === "object" || schema.type === "strict_object") {
59
60
  if (internalFieldStore.kind && internalFieldStore.kind !== "object") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "object"`);
@@ -67,16 +68,16 @@ function initializeFieldStore(internalFieldStore, schema, initialInput, path, nu
67
68
  path.pop();
68
69
  }
69
70
  const objectInput = nullish && initialInput == null ? initialInput : true;
70
- internalFieldStore.initialInput = createSignal(objectInput);
71
- internalFieldStore.startInput = createSignal(objectInput);
72
- internalFieldStore.input = createSignal(objectInput);
71
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal(objectInput);
72
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal(objectInput);
73
+ internalFieldStore.input = /* @__PURE__ */ createSignal(objectInput);
73
74
  }
74
75
  } else {
75
76
  internalFieldStore.kind = "value";
76
77
  if (internalFieldStore.kind === "value") {
77
- internalFieldStore.initialInput = createSignal(initialInput);
78
- internalFieldStore.startInput = createSignal(initialInput);
79
- internalFieldStore.input = createSignal(initialInput);
78
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal(initialInput);
79
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal(initialInput);
80
+ internalFieldStore.input = /* @__PURE__ */ createSignal(initialInput);
80
81
  }
81
82
  }
82
83
  }
@@ -188,11 +189,12 @@ function swapItemState(firstInternalFieldStore, secondInternalFieldStore) {
188
189
  });
189
190
  });
190
191
  }
192
+ // @__NO_SIDE_EFFECTS__
191
193
  function getFieldInput(internalFieldStore) {
192
194
  if (internalFieldStore.kind === "array") {
193
195
  if (internalFieldStore.input.value) {
194
196
  const value = [];
195
- for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = getFieldInput(internalFieldStore.children[index]);
197
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
196
198
  return value;
197
199
  }
198
200
  return internalFieldStore.input.value;
@@ -200,13 +202,14 @@ function getFieldInput(internalFieldStore) {
200
202
  if (internalFieldStore.kind === "object") {
201
203
  if (internalFieldStore.input.value) {
202
204
  const value = {};
203
- for (const key in internalFieldStore.children) value[key] = getFieldInput(internalFieldStore.children[key]);
205
+ for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
204
206
  return value;
205
207
  }
206
208
  return internalFieldStore.input.value;
207
209
  }
208
210
  return internalFieldStore.input.value;
209
211
  }
212
+ // @__NO_SIDE_EFFECTS__
210
213
  function getElementInput(element, internalFieldStore) {
211
214
  if (element.options && element.multiple) return [...element.options].filter((option) => option.selected && !option.disabled).map((option) => option.value);
212
215
  if (element.type === "checkbox") {
@@ -215,7 +218,7 @@ function getElementInput(element, internalFieldStore) {
215
218
  return element.checked;
216
219
  }
217
220
  if (element.type === "radio") {
218
- const prevValue = untrack(() => getFieldInput(internalFieldStore));
221
+ const prevValue = untrack(() => /* @__PURE__ */ getFieldInput(internalFieldStore));
219
222
  if (element.checked) return [...prevValue, element.value];
220
223
  return prevValue.filter((value) => value !== element.value);
221
224
  }
@@ -225,18 +228,20 @@ function getElementInput(element, internalFieldStore) {
225
228
  }
226
229
  return element.value;
227
230
  }
231
+ // @__NO_SIDE_EFFECTS__
228
232
  function getFieldBool(internalFieldStore, type) {
229
233
  if (internalFieldStore[type].value) return true;
230
234
  if (internalFieldStore.kind === "array") {
231
- for (let index = 0; index < internalFieldStore.items.value.length; index++) if (getFieldBool(internalFieldStore.children[index], type)) return true;
235
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[index], type)) return true;
232
236
  return false;
233
237
  }
234
238
  if (internalFieldStore.kind == "object") {
235
- for (const key in internalFieldStore.children) if (getFieldBool(internalFieldStore.children[key], type)) return true;
239
+ for (const key in internalFieldStore.children) if (/* @__PURE__ */ getFieldBool(internalFieldStore.children[key], type)) return true;
236
240
  return false;
237
241
  }
238
242
  return false;
239
243
  }
244
+ // @__NO_SIDE_EFFECTS__
240
245
  function getFieldStore(internalFormStore, path) {
241
246
  let internalFieldStore = internalFormStore;
242
247
  for (const key of path) internalFieldStore = internalFieldStore.children[key];
@@ -269,7 +274,7 @@ function setNestedInput(internalFieldStore, input) {
269
274
  }
270
275
  internalFieldStore.items.value = [...items, ...arrayInput.slice(items.length).map(createId)];
271
276
  }
272
- for (let index = 0; index < items.length; index++) setNestedInput(internalFieldStore.children[index], arrayInput[index]);
277
+ for (let index = 0; index < arrayInput.length; index++) setNestedInput(internalFieldStore.children[index], arrayInput[index]);
273
278
  internalFieldStore.input.value = input == null ? input : true;
274
279
  internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== items.length;
275
280
  } else if (internalFieldStore.kind === "object") {
@@ -324,18 +329,19 @@ function walkFieldStore(internalFieldStore, callback) {
324
329
  function createFormStore(config, parse) {
325
330
  const store = {};
326
331
  initializeFieldStore(store, config.schema, config.initialInput, []);
332
+ store.validators = 0;
327
333
  store.validate = config.validate ?? "submit";
328
334
  store.revalidate = config.revalidate ?? "input";
329
335
  store.parse = parse;
330
- store.isSubmitting = createSignal(false);
331
- store.isSubmitted = createSignal(false);
332
- store.isValidating = createSignal(false);
336
+ store.isSubmitting = /* @__PURE__ */ createSignal(false);
337
+ store.isSubmitted = /* @__PURE__ */ createSignal(false);
338
+ store.isValidating = /* @__PURE__ */ createSignal(false);
333
339
  return store;
334
340
  }
335
341
  async function validateFormInput(internalFormStore, config) {
336
342
  internalFormStore.validators++;
337
343
  internalFormStore.isValidating.value = true;
338
- const result = await internalFormStore.parse(untrack(() => getFieldInput(internalFormStore)));
344
+ const result = await internalFormStore.parse(untrack(() => /* @__PURE__ */ getFieldInput(internalFormStore)));
339
345
  let rootErrors;
340
346
  let nestedErrors;
341
347
  if (result.issues) {
@@ -375,14 +381,15 @@ async function validateFormInput(internalFormStore, config) {
375
381
  return result;
376
382
  }
377
383
  function validateIfRequired(internalFormStore, internalFieldStore, validationMode) {
378
- if (validationMode === (internalFormStore.validate === "initial" || (internalFormStore.validate === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidate : internalFormStore.validate)) validateFormInput(internalFormStore);
384
+ if (validationMode === (internalFormStore.validate === "initial" || (internalFormStore.validate === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => /* @__PURE__ */ getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidate : internalFormStore.validate)) validateFormInput(internalFormStore);
379
385
  }
380
386
  var INTERNAL = "~internal";
381
387
 
382
388
  // ../../packages/methods/dist/index.solid.js
383
- function focus(config) {
384
- getFieldStore(config.form[INTERNAL], config.path).elements[0]?.focus();
389
+ function focus(form, config) {
390
+ getFieldStore(form[INTERNAL], config.path).elements[0]?.focus();
385
391
  }
392
+ // @__NO_SIDE_EFFECTS__
386
393
  function getAllErrors(form) {
387
394
  let allErrors = null;
388
395
  walkFieldStore(form[INTERNAL], (internalFieldStore) => {
@@ -392,12 +399,15 @@ function getAllErrors(form) {
392
399
  });
393
400
  return allErrors;
394
401
  }
402
+ // @__NO_SIDE_EFFECTS__
395
403
  function getErrors(form, config) {
396
404
  return (config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]).errors.value;
397
405
  }
406
+ // @__NO_SIDE_EFFECTS__
398
407
  function getInput(form, config) {
399
408
  return getFieldInput(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]);
400
409
  }
410
+ // @__NO_SIDE_EFFECTS__
401
411
  function handleSubmit(form, handler) {
402
412
  return async (event) => {
403
413
  event.preventDefault();
@@ -451,10 +461,10 @@ function move(form, config) {
451
461
  internalArrayStore.items.value = newItems;
452
462
  const tempInternalFieldStore = {};
453
463
  initializeFieldStore(tempInternalFieldStore, internalArrayStore.schema.item, void 0, []);
454
- copyItemState(internalArrayStore.children[config.from < config.to ? config.from : config.to], tempInternalFieldStore);
464
+ copyItemState(internalArrayStore.children[config.from], tempInternalFieldStore);
455
465
  if (config.from < config.to) for (let index = config.from; index < config.to; index++) copyItemState(internalArrayStore.children[index + 1], internalArrayStore.children[index]);
456
466
  else for (let index = config.from; index > config.to; index--) copyItemState(internalArrayStore.children[index - 1], internalArrayStore.children[index]);
457
- copyItemState(tempInternalFieldStore, internalArrayStore.children[config.from < config.to ? config.to : config.from]);
467
+ copyItemState(tempInternalFieldStore, internalArrayStore.children[config.to]);
458
468
  internalArrayStore.isTouched.value = true;
459
469
  internalArrayStore.isDirty.value = internalArrayStore.startItems.value.join() !== newItems.join();
460
470
  validateIfRequired(internalFormStore, internalArrayStore, "input");
@@ -555,6 +565,7 @@ function validate(form, config) {
555
565
  // src/primitives/createForm/createForm.ts
556
566
  import { createMemo } from "solid-js";
557
567
  import * as v2 from "valibot";
568
+ // @__NO_SIDE_EFFECTS__
558
569
  function createForm(config) {
559
570
  const internalFormStore = createFormStore(
560
571
  config,
@@ -611,6 +622,7 @@ function unwrap(value) {
611
622
  }
612
623
 
613
624
  // src/primitives/useField/useField.ts
625
+ // @__NO_SIDE_EFFECTS__
614
626
  function useField(form, config) {
615
627
  const getPath = createMemo2(() => unwrap(config).path);
616
628
  const getInternalFormStore = createMemo2(() => unwrap(form)[INTERNAL]);
@@ -698,6 +710,7 @@ function useField(form, config) {
698
710
 
699
711
  // src/primitives/useFieldArray/useFieldArray.ts
700
712
  import { createMemo as createMemo3 } from "solid-js";
713
+ // @__NO_SIDE_EFFECTS__
701
714
  function useFieldArray(form, config) {
702
715
  const getInternalFieldStore = createMemo3(
703
716
  () => getFieldStore(
@@ -737,6 +750,7 @@ function useFieldArray(form, config) {
737
750
  }
738
751
 
739
752
  // src/components/Field/Field.tsx
753
+ // @__NO_SIDE_EFFECTS__
740
754
  function Field(props) {
741
755
  const field = useField(
742
756
  () => props.of,
@@ -746,6 +760,7 @@ function Field(props) {
746
760
  }
747
761
 
748
762
  // src/components/FieldArray/FieldArray.tsx
763
+ // @__NO_SIDE_EFFECTS__
749
764
  function FieldArray(props) {
750
765
  const field = useFieldArray(
751
766
  () => props.of,
@@ -756,6 +771,7 @@ function FieldArray(props) {
756
771
 
757
772
  // src/components/Form/Form.tsx
758
773
  import { splitProps } from "solid-js";
774
+ // @__NO_SIDE_EFFECTS__
759
775
  function Form(props) {
760
776
  const [, other] = splitProps(props, ["of", "onSubmit"]);
761
777
  return <form