@formisch/react 0.3.0 → 0.4.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 +20 -5
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -289,9 +289,13 @@ interface BaseFormStore<TSchema extends Schema = Schema> {
|
|
|
289
289
|
//#endregion
|
|
290
290
|
//#region src/types/form.react.d.ts
|
|
291
291
|
/**
|
|
292
|
-
* Submit handler type
|
|
292
|
+
* Submit handler type.
|
|
293
293
|
*/
|
|
294
|
-
type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema
|
|
294
|
+
type SubmitHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>) => MaybePromise<unknown>;
|
|
295
|
+
/**
|
|
296
|
+
* Submit event handler type.
|
|
297
|
+
*/
|
|
298
|
+
type SubmitEventHandler<TSchema extends Schema> = (output: v.InferOutput<TSchema>, event: FormEvent<HTMLFormElement>) => MaybePromise<unknown>;
|
|
295
299
|
//#endregion
|
|
296
300
|
//#region src/types/path.d.ts
|
|
297
301
|
/**
|
|
@@ -475,6 +479,17 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
|
|
|
475
479
|
//#endregion
|
|
476
480
|
//#region src/handleSubmit/handleSubmit.react.d.ts
|
|
477
481
|
/**
|
|
482
|
+
* Creates a submit event handler for the form that validates the form input,
|
|
483
|
+
* and calls the provided handler if validation succeeds. This is designed to
|
|
484
|
+
* be used with the form's onsubmit event.
|
|
485
|
+
*
|
|
486
|
+
* @param form The form store to handle submission for.
|
|
487
|
+
* @param handler The submit handler function called with validated output if validation succeeds.
|
|
488
|
+
*
|
|
489
|
+
* @returns A submit event handler function to attach to the form element.
|
|
490
|
+
*/
|
|
491
|
+
declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitHandler<TSchema>): () => Promise<void>;
|
|
492
|
+
/**
|
|
478
493
|
* Creates a submit event handler for the form that prevents default browser
|
|
479
494
|
* submission, validates the form input, and calls the provided handler if
|
|
480
495
|
* validation succeeds. This is designed to be used with the form's onsubmit event.
|
|
@@ -484,7 +499,7 @@ declare function getInput<TSchema extends Schema, TFieldPath extends RequiredPat
|
|
|
484
499
|
*
|
|
485
500
|
* @returns A submit event handler function to attach to the form element.
|
|
486
501
|
*/
|
|
487
|
-
declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler:
|
|
502
|
+
declare function handleSubmit<TSchema extends Schema>(form: BaseFormStore<TSchema>, handler: SubmitEventHandler<TSchema>): (event: FormEvent<HTMLFormElement>) => Promise<void>;
|
|
488
503
|
//#endregion
|
|
489
504
|
//#region src/insert/insert.d.ts
|
|
490
505
|
/**
|
|
@@ -1014,7 +1029,7 @@ type FormProps<TSchema extends Schema = Schema> = Omit<FormHTMLAttributes<HTMLFo
|
|
|
1014
1029
|
/**
|
|
1015
1030
|
* The submit handler called when the form is submitted and validation succeeds.
|
|
1016
1031
|
*/
|
|
1017
|
-
readonly onSubmit: SubmitHandler<TSchema>;
|
|
1032
|
+
readonly onSubmit: SubmitHandler<TSchema> | SubmitEventHandler<TSchema>;
|
|
1018
1033
|
};
|
|
1019
1034
|
/**
|
|
1020
1035
|
* Form component that manages form submission and applies internal state.
|
|
@@ -1077,4 +1092,4 @@ declare function useFieldArray<TSchema extends Schema, TFieldArrayPath extends R
|
|
|
1077
1092
|
*/
|
|
1078
1093
|
declare function useForm<TSchema extends Schema>(config: FormConfig<TSchema>): FormStore<TSchema>;
|
|
1079
1094
|
//#endregion
|
|
1080
|
-
export { type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, type SetFieldInputConfig, SetFormErrorsConfig, type SetFormInputConfig, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
|
|
1095
|
+
export { type DeepPartial, Field, FieldArray, FieldArrayProps, FieldArrayStore, type FieldElement, FieldElementProps, FieldProps, FieldStore, FocusFieldConfig, Form, type FormConfig, FormProps, FormStore, GetFieldErrorsConfig, GetFieldInputConfig, GetFormErrorsConfig, GetFormInputConfig, InsertConfig, MoveConfig, type PartialValues, type PathValue, RemoveConfig, ReplaceConfig, type RequiredPath, ResetFieldConfig, ResetFormConfig, type Schema, SetFieldErrorsConfig, type SetFieldInputConfig, SetFormErrorsConfig, type SetFormInputConfig, type SubmitEventHandler, type SubmitHandler, SwapConfig, UseFieldArrayConfig, UseFieldConfig, type ValidArrayPath, type ValidPath, ValidateFormConfig, type ValidationMode, focus, getAllErrors, getErrors, getInput, handleSubmit, insert, move, remove, replace, reset, setErrors, setInput, submit, swap, useField, useFieldArray, useForm, validate };
|
package/dist/index.js
CHANGED
|
@@ -661,7 +661,7 @@ function getInput(form, config) {
|
|
|
661
661
|
/* @__NO_SIDE_EFFECTS__ */
|
|
662
662
|
function handleSubmit$1(form, handler) {
|
|
663
663
|
return async (event) => {
|
|
664
|
-
event
|
|
664
|
+
event?.preventDefault();
|
|
665
665
|
const internalFormStore = form[INTERNAL];
|
|
666
666
|
internalFormStore.isSubmitted.value = true;
|
|
667
667
|
internalFormStore.isSubmitting.value = true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formisch/react",
|
|
3
3
|
"description": "The modular and type-safe form library for React",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fabian Hiller",
|
|
7
7
|
"homepage": "https://formisch.dev",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsdown": "^0.16.8",
|
|
47
47
|
"typescript": "~5.9.3",
|
|
48
48
|
"vite": "^7.2.4",
|
|
49
|
-
"@formisch/core": "0.
|
|
50
|
-
"@formisch/
|
|
51
|
-
"@formisch/
|
|
49
|
+
"@formisch/core": "0.6.0",
|
|
50
|
+
"@formisch/methods": "0.7.0",
|
|
51
|
+
"@formisch/eslint-config": "0.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|