import React 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"; type TextAreaFieldProps< TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath = FieldPath, > = Prettify< GenericFieldProps & Omit, "ref" | "name"> & { handleChanged?: (props: { name: string }) => void; startIcon?: React.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, startIcon, handleChanged, required, disabled, ...rest } = props; const form = useFormContext(); const { formState: { errors }, } = form; const hasError = !!get(errors, name)?.message; return (
(
{startIcon && (
{startIcon}
)}