'use client' import type { ComponentProps } from 'react' import { type FieldPath, type FieldValues, useFormContext } from 'react-hook-form' import { FormattedInput } from '@/components/FormattedInput' interface FormInputProps< TFieldValues extends FieldValues, TFieldName extends FieldPath, > extends ComponentProps<'input'> { name: TFieldName format?: (value: string) => string sanitize?: (value: string) => string } export const FormInput = < TFieldValues extends FieldValues, TFieldName extends FieldPath, >({ name, format, sanitize, ...props }: FormInputProps) => { const { onChange, onBlur, ...registerResult } = useFormContext().register( name, sanitize ? { setValueAs: sanitize } : undefined, ) return ( ) }