import type {HTMLProps, ReactNode} from 'react' import { get } from "lodash"; import { Controller, FieldPath, FieldValues, useFormContext, } from "react-hook-form"; import { twMerge } from "tailwind-merge"; import { Prettify } from "@/types"; import { Field, GenericFieldProps } from "./Field"; import { inputVariants } from "./Input"; type TextAreaFieldProps< TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath = FieldPath, > = Prettify< GenericFieldProps & Omit, "ref" | "name"> & { handleChanged?: (props: { name: string }) => void; startIcon?: ReactNode; required?: boolean; } >; export const TextAreaField = < TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath = FieldPath, >( props: TextAreaFieldProps, ) => { const { name, control, label, className, labelClassName, childrenWrapperClassName, hideErrorMessage = false, required, disabled, ...rest } = props; const form = useFormContext(); const { formState: { errors }, } = form; const hasError = !!get(errors, name)?.message; return ( ( { field.onChange(e); }} value={field.value} /> )} /> ); };