feat: export getFormDataObject and FormProps interface

This commit is contained in:
divlo 2021-06-17 19:26:13 +02:00
parent 7ac46825ee
commit c90742b200

View File

@ -10,15 +10,15 @@ export type HandleForm = (
formElement: HTMLFormElement
) => void | Promise<void>
interface ReactFormProps
export interface ReactFormProps
extends Omit<React.HTMLProps<HTMLFormElement>, 'onSubmit' | 'onChange'> {}
interface FormProps extends ReactFormProps {
export interface FormProps extends ReactFormProps {
onSubmit?: HandleForm
onChange?: HandleForm
}
const getFormDataObject = (formElement: HTMLFormElement): FormDataObject => {
export const getFormDataObject = (formElement: HTMLFormElement): FormDataObject => {
return Object.fromEntries<FormDataEntryValue>(new FormData(formElement))
}