import clsx from 'clsx' import { ComponentPropsWithoutRef } from 'react' import { FieldPathValue, FieldValues, Path, UseFormRegister, Validate, } from 'react-hook-form' import { useTranslation } from 'react-i18next' export interface TextInputProps< FV extends FieldValues, FieldName extends Path, > extends Omit, 'required'> { fieldName?: FieldName register?: UseFormRegister validation?: Validate>[] error?: any required?: boolean ghost?: boolean } /** * @param fieldName - the field name for the value that this will contain. * @param register - the register function returned by `useForm`. * @param error - any errors that have occured during validation of this * input. * @param validation - a list of functions that, when given the current value * of this field, return true if the value is valid and an * error message otherwise. */ export const TextInput = >({ fieldName, register, error, validation, className, required, ghost, type = 'text', ...rest }: TextInputProps) => { const { t } = useTranslation() const validate = validation?.reduce( (a, v) => ({ ...a, [v.toString()]: v }), {} ) return ( ) }