import { useFormContext, Controller } from 'react-hook-form'; // @mui import TextField from '@mui/material/TextField'; import Autocomplete, { AutocompleteProps } from '@mui/material/Autocomplete'; // ---------------------------------------------------------------------- interface Props< T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, > extends AutocompleteProps { name: string; label?: string; placeholder?: string; helperText?: React.ReactNode; } export default function RHFAutocomplete< T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, >({ name, label, placeholder, helperText, ...other }: Omit, 'renderInput'>) { const { control, setValue } = useFormContext(); return ( ( setValue(name, newValue, { shouldValidate: true })} renderInput={(params) => ( )} {...other} /> )} /> ); }