import { createFormHook, createFormHookContexts } from "@tanstack/react-form";
import { DateField } from "./components/CalenderSelect";
import { CheckboxField } from "./components/CheckBox";
import { InputField } from "./components/InputField";
import { InputPasswordField } from "./components/InputPasswordField";
import { SelectField } from "./components/SelectField";
import { SubmitButton } from "./components/SubmitButton";

export const { fieldContext, useFieldContext, formContext, useFormContext } =
	createFormHookContexts();

export const { useAppForm } = createFormHook({
	fieldComponents: {
		InputField,
		InputPasswordField,
		SelectField,
		CheckboxField,
		DateField,
	},
	formComponents: { SubmitButton },
	fieldContext,
	formContext,
});
