Behive Tech Registry

form-provider

v0.1.2

The single place `react-hook-form` is imported directly in this repo. Everything else should import form state/control from here instead of `react-hook-form` — that keeps the underlying library swappable from one spot later.

pnpm add @behivetech/forms.form-provider

Edit the code and the preview updates as you type. Every registry export is in scope — Controller, Form, FormProvider, useController, useForm, useFormContext, useFormState, useWatch from this package, plus React hooks and every other component in the registry.

Playground
interface DemoValues {
  email: string;
}

const BasicFormProvider = () => {
  const methods = useForm<DemoValues>({ defaultValues: { email: "" } });
  const { register, handleSubmit } = methods;

  return (
    <FormProvider methods={methods}>
      <form onSubmit={handleSubmit((values) => console.log(values))}>
        <FormField label="Email" htmlFor="email">
          <TextField id="email" {...register("email")} />
        </FormField>
      </form>
    </FormProvider>
  );
};

render(<BasicFormProvider />);