"use client" import { forwardRef } from "react" import { Text, TextField } from "react-aria-components" import { Controller, useFormContext } from "react-hook-form" import { useIntl, type IntlShape } from "react-intl" import { cx } from "class-variance-authority" import { Error } from "../ErrorMessage/Error" import { mergeRefs } from "../utils/mergeRefs" import { TextArea } from "../../TextArea" import styles from "./textarea.module.css" import type { FormTextAreaProps } from "./textarea" import { MaterialIcon, MaterialIconProps } from "../../Icons/MaterialIcon" const defaultErrorFormatter = ( _intl: IntlShape, errorMessage?: string ): string => errorMessage ?? "" export const FormTextArea = forwardRef( function FormTextArea( { className = "", description = "", descriptionIcon = "info" as MaterialIconProps["icon"], disabled = false, errorFormatter, hideError, label, name, placeholder, readOnly = false, registerOptions = {}, ...props }, ref ) { const intl = useIntl() const { control } = useFormContext() const formatErrorMessage = errorFormatter ?? defaultErrorFormatter return ( { const isDisabled = disabled || field.disabled const hasError = fieldState.invalid && !hideError const showDescription = description && !fieldState.error return (