From f77b6adb99b0f5624638d5dd82f9f03772fba46d Mon Sep 17 00:00:00 2001 From: David Arranz Date: Mon, 17 Jun 2024 12:42:44 +0200 Subject: [PATCH] . --- .../components/Forms/FormTextAreaField.tsx | 40 ++++------ client/src/components/Forms/FormTextField.tsx | 79 ++++++++----------- 2 files changed, 51 insertions(+), 68 deletions(-) diff --git a/client/src/components/Forms/FormTextAreaField.tsx b/client/src/components/Forms/FormTextAreaField.tsx index ab95f19..48085d5 100644 --- a/client/src/components/Forms/FormTextAreaField.tsx +++ b/client/src/components/Forms/FormTextAreaField.tsx @@ -8,27 +8,15 @@ import { FormMessage, Textarea, } from "@/ui"; +import * as React from "react"; -import { - FieldErrors, - FieldPath, - FieldValues, - UseControllerProps, -} from "react-hook-form"; +import { FieldErrors, FieldPath, FieldValues, UseControllerProps } from "react-hook-form"; import { FormLabel, FormLabelProps } from "./FormLabel"; -export const FormTextAreaField = < +export type FormTextAreaFieldProps< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, ->({ - label, - hint, - placeholder, - description, - autoSize, - className, - ...props -}: { + TName extends FieldPath = FieldPath +> = { autoSize?: boolean; placeholder?: string; description?: string; @@ -36,27 +24,33 @@ export const FormTextAreaField = < } & Partial & UseControllerProps & { errors?: FieldErrors; - }) => { + }; + +export const FormTextAreaField = React.forwardRef< + HTMLDivElement, + React.TextareaHTMLAttributes & FormTextAreaFieldProps +>(({ label, hint, placeholder, description, autoSize, className, ...props }, ref) => { return ( ( - + // eslint-disable-next-line @typescript-eslint/no-unused-vars + render={({ field, fieldState, formState }) => ( + {label && } {autoSize ? ( ) : (