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 { Searchable } from "./components/Searchable";
import { SelectField } from "./components/SelectField";
import { SubmitButton } from "./components/SubmitButton";
import { TextArea } from "./components/TextArea";

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

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