import { Tooltip } from '@components/common/form/Tooltip.js'; import { getNestedError } from '@components/common/form/utils/getNestedError.js'; import { Field, FieldError, FieldLabel } from '@components/common/ui/Field.js'; import { Textarea } from '@components/common/ui/Textarea.js'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import React from 'react'; import { useFormContext, RegisterOptions, FieldPath, FieldValues, Controller } from 'react-hook-form'; interface TextareaFieldProps extends Omit, 'name'> { name: FieldPath; label?: string; error?: string; helperText?: string; required?: boolean; validation?: RegisterOptions; wrapperClassName?: string; } export function TextareaField({ name, label, error, helperText, wrapperClassName, required, validation, className, rows = 4, defaultValue, ...props }: TextareaFieldProps) { const { control, formState: { errors } } = useFormContext(); const fieldError = getNestedError(name, errors, error); const fieldId = `field-${name}`; const validationRules = { ...validation, ...(required && !validation?.required && { required: _('${field} is required', { field: label || name }) }) }; return ( {label && ( <> {label} {required && *} {helperText && } )} (