import * as React from 'react';
import RSForm, {
  FormComponentProps,
  FormExport
} from '@redshank/form';
import { Box } from '../Box';
import { FieldValues } from 'react-hook-form';

export * from '@redshank/form';

const Form = (<TFieldValues extends FieldValues = FieldValues>({
  Component = Box,
  ...props
}: FormComponentProps<TFieldValues>) => {
  return <RSForm Component={Component} {...props} />;
}) as FormExport;

Form.Item = RSForm.Item;
Form.useForm = RSForm.useForm;
Form.useFieldArray = RSForm.useFieldArray;
Form.useFormContext = RSForm.useFormContext;
Form.useWatch = RSForm.useWatch;
Form.useController = RSForm.useController;
Form.useFormState = RSForm.useFormState;

export { Form };
