2025-04-16 14:16:32 +08:00
|
|
|
import { createFormHook, createFormHookContexts } from '@tanstack/react-form'
|
2025-04-17 13:33:33 +08:00
|
|
|
import TextField from './components/field/text'
|
|
|
|
import NumberInputField from './components/field/number-input'
|
|
|
|
import CheckboxField from './components/field/checkbox'
|
|
|
|
import SelectField from './components/field/select'
|
2025-04-23 22:16:19 +08:00
|
|
|
import CustomSelectField from './components/field/custom-select'
|
2025-04-18 11:32:23 +08:00
|
|
|
import OptionsField from './components/field/options'
|
2025-04-25 18:13:52 +08:00
|
|
|
import Actions from './components/form/actions'
|
|
|
|
|
|
|
|
export type FormType = ReturnType<typeof useFormContext>
|
2025-04-16 14:16:32 +08:00
|
|
|
|
|
|
|
export const { fieldContext, useFieldContext, formContext, useFormContext }
|
|
|
|
= createFormHookContexts()
|
|
|
|
|
|
|
|
export const { useAppForm, withForm } = createFormHook({
|
|
|
|
fieldComponents: {
|
|
|
|
TextField,
|
2025-04-17 13:33:33 +08:00
|
|
|
NumberInputField,
|
2025-04-16 14:16:32 +08:00
|
|
|
CheckboxField,
|
|
|
|
SelectField,
|
2025-04-23 22:16:19 +08:00
|
|
|
CustomSelectField,
|
2025-04-18 11:32:23 +08:00
|
|
|
OptionsField,
|
2025-04-16 14:16:32 +08:00
|
|
|
},
|
|
|
|
formComponents: {
|
2025-04-25 18:13:52 +08:00
|
|
|
Actions,
|
2025-04-16 14:16:32 +08:00
|
|
|
},
|
|
|
|
fieldContext,
|
|
|
|
formContext,
|
|
|
|
})
|