@formisch/solid 0.1.1 → 0.3.0

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/index.d.ts CHANGED
@@ -78,15 +78,15 @@ type ValidationMode = "initial" | "touch" | "input" | "change" | "blur" | "submi
78
78
  interface FormConfig<TSchema extends Schema = Schema> {
79
79
  readonly schema: TSchema;
80
80
  readonly initialInput?: DeepPartial<v.InferInput<TSchema>> | undefined;
81
- readonly validateOn?: ValidationMode | undefined;
82
- readonly revalidateOn?: Exclude<ValidationMode, "initial"> | undefined;
81
+ readonly validate?: ValidationMode | undefined;
82
+ readonly revalidate?: Exclude<ValidationMode, "initial"> | undefined;
83
83
  }
84
84
  interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObjectStore {
85
85
  element?: HTMLFormElement;
86
86
  validators: number;
87
- validateOn: ValidationMode;
88
- revalidateOn: Exclude<ValidationMode, "initial">;
89
- validate: (input: unknown) => Promise<v.SafeParseResult<TSchema>>;
87
+ validate: ValidationMode;
88
+ revalidate: Exclude<ValidationMode, "initial">;
89
+ parse: (input: unknown) => Promise<v.SafeParseResult<TSchema>>;
90
90
  isSubmitting: Signal<boolean>;
91
91
  isSubmitted: Signal<boolean>;
92
92
  isValidating: Signal<boolean>;
@@ -94,7 +94,7 @@ interface InternalFormStore<TSchema extends Schema = Schema> extends InternalObj
94
94
  interface BaseFormStore<TSchema extends Schema = Schema> {
95
95
  [INTERNAL]: InternalFormStore<TSchema>;
96
96
  }
97
- type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<void>;
97
+ type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: SubmitEvent) => MaybePromise<unknown>;
98
98
  //#endregion
99
99
  //#region src/types/path.d.ts
100
100
  /**
@@ -124,16 +124,16 @@ type MergeUnion<T> = { [K in KeyOf<T>]: T extends Record<K, infer V> ? V : never
124
124
  /**
125
125
  * Lazily evaluate only the first valid path segment based on the given value.
126
126
  */
127
- type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends KeyOf<TValue>, ...infer TPathRest extends Path] ? LazyPath<MergeUnion<TValue>[TFirstKey], TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOf<TValue>> extends false ? readonly [...TValidPath, KeyOf<TValue>] : TValidPath;
127
+ type LazyPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValidPath : TPathToCheck extends readonly [infer TFirstKey extends KeyOf<TValue>, ...infer TPathRest extends Path] ? LazyPath<Required<MergeUnion<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOf<TValue>> extends false ? readonly [...TValidPath, KeyOf<TValue>] : TValidPath;
128
128
  /**
129
129
  * Returns the path if valid, otherwise the first possible valid path based on
130
130
  * the given value.
131
131
  */
132
- type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<TValue, TPath> ? TPath : LazyPath<TValue, TPath>;
132
+ type ValidPath<TValue, TPath extends RequiredPath> = TPath extends LazyPath<Required<TValue>, TPath> ? TPath : LazyPath<Required<TValue>, TPath>;
133
133
  /**
134
134
  * Extracts the value type at the given path.
135
135
  */
136
- type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends KeyOf<TValue> ? PathValue<MergeUnion<TValue>[TKey], TRest> : unknown : TValue;
136
+ type PathValue<TValue, TPath extends Path> = TPath extends readonly [infer TKey, ...infer TRest extends Path] ? TKey extends KeyOf<Required<TValue>> ? PathValue<MergeUnion<Required<TValue>>[TKey], TRest> : unknown : TValue;
137
137
  /**
138
138
  * Checks if a value is an array or contains one.
139
139
  */
@@ -141,16 +141,16 @@ type IsOrHasArray<TValue> = IsAny<TValue> extends true ? false : TValue extends
141
141
  /**
142
142
  * Extracts the exact keys of a tuple, array or object that contain arrays.
143
143
  */
144
- type KeyOfArrayPath<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? IsOrHasArray<TItem> extends true ? number : never : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? IsOrHasArray<TValue[TKey]> extends true ? TIndex : never : never }[number] : TValue extends Record<string, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<TValue[TKey]> extends true ? TKey : never }[keyof TValue] & PathKey : never;
144
+ type KeyOfArrayPath<TValue> = IsAny<TValue> extends true ? never : TValue extends readonly (infer TItem)[] ? number extends TValue["length"] ? IsOrHasArray<TItem> extends true ? number : never : { [TKey in keyof TValue]: TKey extends `${infer TIndex extends number}` ? IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TIndex : never : never }[number] : TValue extends Record<string, unknown> ? { [TKey in keyof TValue]: IsOrHasArray<NonNullable<TValue[TKey]>> extends true ? TKey : never }[keyof TValue] & PathKey : never;
145
145
  /**
146
146
  * Lazily evaluate only the first valid array path segment based on the given value.
147
147
  */
148
- type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath, KeyOfArrayPath<TValue>] : TPathToCheck extends readonly [infer TFirstKey extends KeyOfArrayPath<TValue>, ...infer TPathRest extends Path] ? LazyArrayPath<MergeUnion<TValue>[TFirstKey], TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOfArrayPath<TValue>> extends false ? readonly [...TValidPath, KeyOfArrayPath<TValue>] : never;
148
+ type LazyArrayPath<TValue, TPathToCheck extends Path, TValidPath extends Path = readonly []> = TPathToCheck extends readonly [] ? TValue extends readonly unknown[] ? TValidPath : readonly [...TValidPath, KeyOfArrayPath<TValue>] : TPathToCheck extends readonly [infer TFirstKey extends KeyOfArrayPath<TValue>, ...infer TPathRest extends Path] ? LazyArrayPath<Required<MergeUnion<TValue>[TFirstKey]>, TPathRest, readonly [...TValidPath, TFirstKey]> : IsNever<KeyOfArrayPath<TValue>> extends false ? readonly [...TValidPath, KeyOfArrayPath<TValue>] : never;
149
149
  /**
150
150
  * Returns the path if valid, otherwise the first possible valid array path based on
151
151
  * the given value.
152
152
  */
153
- type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<TValue, TPath> ? TPath : LazyArrayPath<TValue, TPath>;
153
+ type ValidArrayPath<TValue, TPath extends RequiredPath> = TPath extends LazyArrayPath<Required<TValue>, TPath> ? TPath : LazyArrayPath<Required<TValue>, TPath>;
154
154
  //#endregion
155
155
  //#region src/array/copyItemState/copyItemState.d.ts
156
156
  /**
@@ -194,6 +194,9 @@ interface GetFieldInputConfig<TSchema extends Schema, TFieldPath extends Require
194
194
  declare function getInput<TSchema extends Schema>(form: BaseFormStore<TSchema>): PartialValues<v.InferInput<TSchema>>;
195
195
  declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPath | undefined = undefined>(form: BaseFormStore<TSchema>, config: TFieldPath extends RequiredPath ? GetFieldInputConfig<TSchema, TFieldPath> : GetFormInputConfig): PartialValues<TFieldPath extends RequiredPath ? PathValue<v.InferInput<TSchema>, TFieldPath> : v.InferInput<TSchema>>;
196
196
  //#endregion
197
+ //#region src/handleSubmit/handleSubmit.d.ts
198
+ declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): (event: SubmitEvent) => void;
199
+ //#endregion
197
200
  //#region src/insert/insert.d.ts
198
201
  interface InsertConfig<TSchema extends Schema, TFieldArrayPath extends RequiredPath> {
199
202
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
@@ -346,7 +349,7 @@ type MaybeGetter<TValue> = TValue | (() => TValue);
346
349
  interface FieldProps<TSchema extends Schema = Schema, TFieldPath extends RequiredPath = RequiredPath> {
347
350
  readonly of: FormStore<TSchema>;
348
351
  readonly path: ValidPath<v.InferInput<TSchema>, TFieldPath>;
349
- readonly render: (store: FieldStore<TSchema, TFieldPath>) => JSX.Element;
352
+ readonly children: (store: FieldStore<TSchema, TFieldPath>) => JSX.Element;
350
353
  }
351
354
  /**
352
355
  * Headless form field that provides reactive properties and state.
@@ -360,7 +363,7 @@ declare function Field<TSchema extends Schema, TFieldPath extends RequiredPath>(
360
363
  interface FieldArrayProps<TSchema extends Schema = Schema, TFieldArrayPath extends RequiredPath = RequiredPath> {
361
364
  readonly of: FormStore<TSchema>;
362
365
  readonly path: ValidArrayPath<v.InferInput<TSchema>, TFieldArrayPath>;
363
- readonly render: (store: FieldArrayStore<TSchema, TFieldArrayPath>) => JSX.Element;
366
+ readonly children: (store: FieldArrayStore<TSchema, TFieldArrayPath>) => JSX.Element;
364
367
  }
365
368
  /**
366
369
  * Headless field array that provides reactive properties and state.
@@ -390,4 +393,4 @@ interface UseFieldArrayConfig<TSchema extends Schema = Schema, TFieldArrayPath e
390
393
  }
391
394
  declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends RequiredPath>(form: MaybeGetter<FormStore<TSchema>>, config: MaybeGetter<UseFieldArrayConfig<TSchema, TFieldArrayPath>>): FieldArrayStore<TSchema, TFieldArrayPath>;
392
395
  //#endregion
393
- export { Field, FieldArray, FieldArrayProps, FieldArrayStore, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MaybeGetter, MoveConfig, RemoveConfig, ReplaceConfig, ResetFieldConfig, ResetFormConfig, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, SwapConfig, UseFieldArrayConfig, UseFieldConfig, ValidateFormConfig, createForm, focus, getAllErrors, getErrors, getInput, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };
396
+ export { Field, FieldArray, FieldArrayProps, FieldArrayStore, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MaybeGetter, MoveConfig, RemoveConfig, ReplaceConfig, ResetFieldConfig, ResetFormConfig, SetFieldErrorsConfig, SetFieldInputConfig, SetFormErrorsConfig, SetFormInputConfig, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, ValidateFormConfig, createForm, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };
package/dist/index.js CHANGED
@@ -106,6 +106,7 @@ function copyItemState(fromInternalFieldStore, toInternalFieldStore) {
106
106
  }
107
107
  function resetItemState(internalFieldStore, initialInput) {
108
108
  batch(() => {
109
+ internalFieldStore.errors.value = null;
109
110
  if (internalFieldStore.kind === "array") {
110
111
  internalFieldStore.isTouched.value = false;
111
112
  internalFieldStore.isDirty.value = false;
@@ -262,6 +263,7 @@ function setFieldInput(internalFieldStore, input) {
262
263
  } else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) setFieldInput(internalFieldStore.children[key], input[key]);
263
264
  else {
264
265
  internalFieldStore.input.value = input;
266
+ internalFieldStore.isTouched.value = true;
265
267
  const startInput = untrack(() => internalFieldStore.startInput.value);
266
268
  internalFieldStore.isDirty.value = startInput !== input && (startInput !== void 0 || input !== "" && !Number.isNaN(input));
267
269
  }
@@ -290,12 +292,12 @@ function walkFieldStore(internalFieldStore, callback) {
290
292
  if (internalFieldStore.kind === "array") for (let index = 0; index < untrack(() => internalFieldStore.items.value).length; index++) walkFieldStore(internalFieldStore.children[index], callback);
291
293
  else if (internalFieldStore.kind === "object") for (const key in internalFieldStore.children) walkFieldStore(internalFieldStore.children[key], callback);
292
294
  }
293
- function createFormStore(config, validate2) {
295
+ function createFormStore(config, parse) {
294
296
  const store = {};
295
297
  initializeFieldStore(store, config.schema, config.initialInput, []);
296
- store.validateOn = config.validateOn ?? "submit";
297
- store.revalidateOn = config.revalidateOn ?? "input";
298
- store.validate = validate2;
298
+ store.validate = config.validate ?? "submit";
299
+ store.revalidate = config.revalidate ?? "input";
300
+ store.parse = parse;
299
301
  store.isSubmitting = createSignal(false);
300
302
  store.isSubmitted = createSignal(false);
301
303
  store.isValidating = createSignal(false);
@@ -304,7 +306,7 @@ function createFormStore(config, validate2) {
304
306
  async function validateFormInput(internalFormStore, config) {
305
307
  internalFormStore.validators++;
306
308
  internalFormStore.isValidating.value = true;
307
- const result = await internalFormStore.validate(untrack(() => getFieldInput(internalFormStore)));
309
+ const result = await internalFormStore.parse(untrack(() => getFieldInput(internalFormStore)));
308
310
  let rootErrors;
309
311
  let nestedErrors;
310
312
  if (result.issues) {
@@ -344,7 +346,7 @@ async function validateFormInput(internalFormStore, config) {
344
346
  return result;
345
347
  }
346
348
  function validateIfRequired(internalFormStore, internalFieldStore, validationModes) {
347
- if (validationModes === (internalFormStore.validateOn === "initial" || (internalFormStore.validateOn === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidateOn : internalFormStore.validateOn)) validateFormInput(internalFormStore);
349
+ if (validationModes === (internalFormStore.validate === "initial" || (internalFormStore.validate === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidate : internalFormStore.validate)) validateFormInput(internalFormStore);
348
350
  }
349
351
  var INTERNAL = "~internal";
350
352
 
@@ -367,6 +369,22 @@ function getErrors(form, config) {
367
369
  function getInput(form, config) {
368
370
  return getFieldInput(config?.path ? getFieldStore(form[INTERNAL], config.path) : form[INTERNAL]);
369
371
  }
372
+ function handleSubmit(form, handler) {
373
+ return async (event) => {
374
+ event.preventDefault();
375
+ const internalFormStore = form[INTERNAL];
376
+ internalFormStore.isSubmitted.value = true;
377
+ internalFormStore.isSubmitting.value = true;
378
+ try {
379
+ const result = await validateFormInput(internalFormStore, { shouldFocus: true });
380
+ if (result.success) await handler(result.output, event);
381
+ } catch (error) {
382
+ internalFormStore.errors.value = [error instanceof Error ? error.message : "An unknown error has occurred."];
383
+ } finally {
384
+ internalFormStore.isSubmitting.value = false;
385
+ }
386
+ };
387
+ }
370
388
  function insert(form, config) {
371
389
  const internalFormStore = form[INTERNAL];
372
390
  const internalArrayStore = getFieldStore(internalFormStore, config.path);
@@ -458,7 +476,7 @@ function reset(form, config) {
458
476
  });
459
477
  if (!config?.path) {
460
478
  if (!config?.keepSubmitted) internalFormStore.isSubmitted.value = false;
461
- if (internalFormStore.validateOn === "initial") validateFormInput(internalFormStore);
479
+ if (internalFormStore.validate === "initial") validateFormInput(internalFormStore);
462
480
  }
463
481
  });
464
482
  });
@@ -470,7 +488,6 @@ function setInput(form, config) {
470
488
  batch(() => {
471
489
  const internalFormStore = form[INTERNAL];
472
490
  const internalFieldStore = config.path ? getFieldStore(internalFormStore, config.path) : internalFormStore;
473
- setFieldBool(internalFieldStore, "isTouched", true);
474
491
  setFieldInput(internalFieldStore, config.input);
475
492
  validateIfRequired(internalFormStore, internalFieldStore, "input");
476
493
  });
@@ -502,6 +519,15 @@ function createForm(config) {
502
519
  config,
503
520
  async (input) => v.safeParseAsync(config.schema, input)
504
521
  );
522
+ const getIsTouched = createMemo(
523
+ () => getFieldBool(internalFormStore, "isTouched")
524
+ );
525
+ const getIsDirty = createMemo(
526
+ () => getFieldBool(internalFormStore, "isDirty")
527
+ );
528
+ const getIsValid = createMemo(
529
+ () => !getFieldBool(internalFormStore, "errors")
530
+ );
505
531
  const form = {
506
532
  [INTERNAL]: internalFormStore,
507
533
  get isSubmitting() {
@@ -514,19 +540,19 @@ function createForm(config) {
514
540
  return internalFormStore.isValidating.value;
515
541
  },
516
542
  get isTouched() {
517
- return getFieldBool(internalFormStore, "isTouched");
543
+ return getIsTouched();
518
544
  },
519
545
  get isDirty() {
520
- return getFieldBool(internalFormStore, "isDirty");
546
+ return getIsDirty();
521
547
  },
522
548
  get isValid() {
523
- return !getFieldBool(internalFormStore, "errors");
549
+ return getIsValid();
524
550
  },
525
551
  get errors() {
526
552
  return internalFormStore.errors.value;
527
553
  }
528
554
  };
529
- if (config.validateOn === "initial") {
555
+ if (config.validate === "initial") {
530
556
  validateFormInput(form[INTERNAL]);
531
557
  }
532
558
  return form;
@@ -546,24 +572,34 @@ function useField(form, config) {
546
572
  const getInternalFieldStore = createMemo(
547
573
  () => getFieldStore(getInternalFormStore(), unwrap(config).path)
548
574
  );
575
+ const getInput2 = createMemo(() => getFieldInput(getInternalFieldStore()));
576
+ const getIsTouched = createMemo(
577
+ () => getFieldBool(getInternalFieldStore(), "isTouched")
578
+ );
579
+ const getIsDirty = createMemo(
580
+ () => getFieldBool(getInternalFieldStore(), "isDirty")
581
+ );
582
+ const getIsValid = createMemo(
583
+ () => !getFieldBool(getInternalFieldStore(), "errors")
584
+ );
549
585
  return {
550
586
  get path() {
551
587
  return unwrap(config).path;
552
588
  },
553
589
  get input() {
554
- return getFieldInput(getInternalFieldStore());
590
+ return getInput2();
555
591
  },
556
592
  get errors() {
557
593
  return getInternalFieldStore().errors.value;
558
594
  },
559
595
  get isTouched() {
560
- return getFieldBool(getInternalFieldStore(), "isTouched");
596
+ return getIsTouched();
561
597
  },
562
598
  get isDirty() {
563
- return getFieldBool(getInternalFieldStore(), "isDirty");
599
+ return getIsDirty();
564
600
  },
565
601
  get isValid() {
566
- return !getFieldBool(getInternalFieldStore(), "errors");
602
+ return getIsValid();
567
603
  },
568
604
  props: {
569
605
  get name() {
@@ -590,11 +626,10 @@ function useField(form, config) {
590
626
  },
591
627
  onInput(event) {
592
628
  const internalFieldStore = getInternalFieldStore();
593
- const nextValue = getElementInput(
594
- event.currentTarget,
595
- internalFieldStore
629
+ setFieldInput(
630
+ internalFieldStore,
631
+ getElementInput(event.currentTarget, internalFieldStore)
596
632
  );
597
- setFieldInput(internalFieldStore, nextValue);
598
633
  validateIfRequired(getInternalFormStore(), internalFieldStore, "input");
599
634
  },
600
635
  onChange() {
@@ -621,6 +656,15 @@ function useFieldArray(form, config) {
621
656
  unwrap(config).path
622
657
  )
623
658
  );
659
+ const getIsTouched = createMemo(
660
+ () => getFieldBool(getInternalFieldStore(), "isTouched")
661
+ );
662
+ const getIsDirty = createMemo(
663
+ () => getFieldBool(getInternalFieldStore(), "isDirty")
664
+ );
665
+ const getIsValid = createMemo(
666
+ () => !getFieldBool(getInternalFieldStore(), "errors")
667
+ );
624
668
  return {
625
669
  get path() {
626
670
  return unwrap(config).path;
@@ -632,33 +676,29 @@ function useFieldArray(form, config) {
632
676
  return getInternalFieldStore().errors.value;
633
677
  },
634
678
  get isTouched() {
635
- return getFieldBool(getInternalFieldStore(), "isTouched");
679
+ return getIsTouched();
636
680
  },
637
681
  get isDirty() {
638
- return getFieldBool(getInternalFieldStore(), "isDirty");
682
+ return getIsDirty();
639
683
  },
640
684
  get isValid() {
641
- return !getFieldBool(getInternalFieldStore(), "errors");
685
+ return getIsValid();
642
686
  }
643
687
  };
644
688
  }
645
689
 
646
690
  // src/components/Field/Field.tsx
647
691
  function Field(props) {
648
- const field = useField(() => props.of, {
649
- get path() {
650
- return props.path;
651
- }
652
- });
653
- return memo(() => props.render(field));
692
+ const field = useField(() => props.of, () => ({
693
+ path: props.path
694
+ }));
695
+ return memo(() => props.children(field));
654
696
  }
655
697
  function FieldArray(props) {
656
- const field = useFieldArray(() => props.of, {
657
- get path() {
658
- return props.path;
659
- }
660
- });
661
- return memo(() => props.render(field));
698
+ const field = useFieldArray(() => props.of, () => ({
699
+ path: props.path
700
+ }));
701
+ return memo(() => props.children(field));
662
702
  }
663
703
  var _tmpl$ = /* @__PURE__ */ template(`<form>`);
664
704
  function Form(props) {
@@ -670,27 +710,10 @@ function Form(props) {
670
710
  }, _el$);
671
711
  spread(_el$, mergeProps(other, {
672
712
  "novalidate": true,
673
- "onSubmit": async (event) => {
674
- event.preventDefault();
675
- const internalFormStore = props.of[INTERNAL];
676
- internalFormStore.isSubmitted.value = true;
677
- internalFormStore.isSubmitting.value = true;
678
- try {
679
- const result = await validateFormInput(internalFormStore, {
680
- shouldFocus: true
681
- });
682
- if (result.success) {
683
- await props.onSubmit(result.output, event);
684
- }
685
- } catch (error) {
686
- internalFormStore.errors.value = [error instanceof Error ? error.message : "An unknown error has occurred."];
687
- } finally {
688
- internalFormStore.isSubmitting.value = false;
689
- }
690
- }
713
+ "onSubmit": (event) => handleSubmit(props.of, props.onSubmit)(event)
691
714
  }), false, false);
692
715
  return _el$;
693
716
  })();
694
717
  }
695
718
 
696
- export { Field, FieldArray, Form, createForm, focus, getAllErrors, getErrors, getInput, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };
719
+ export { Field, FieldArray, Form, createForm, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, validate };