import type { Control, FieldPath, FieldValues, RegisterOptions } from 'react-hook-form';

/**
 * What every `Rhf*` field wrapper in this folder takes to bind itself to one form field.
 *
 * `control` is optional on purpose: a form that wraps its subtree in `FormProvider` never has to
 * thread it through, and one that doesn't (a small local form, a field rendered outside the
 * provider) can still pass it explicitly.
 */
export interface RhfFieldProps<TFieldValues extends FieldValues> {
  /** Dot-path of the field in the form's value shape — type-checked against it. */
  name: FieldPath<TFieldValues>;
  /** Falls back to the enclosing `FormProvider`'s control when omitted. */
  control?: Control<TFieldValues>;
  /** Validation rules, colocated with the field they govern rather than in the submit handler. */
  rules?: Omit<RegisterOptions<TFieldValues>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
}
