import React, { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode, } from 'react'; import InputError from '../slimer/InputError'; import { FieldNamesType, FieldValidationMethodType } from '../../types'; import { toLowerCaseWithSpaces } from '../utils/toLowerCaseWithSpaces'; export interface HookFormTextAreaProps { /** * The aria-describedby HTML attribute for the field. */ ariaDescribedby?: string; /** * The autocomplete HTML attribute for the field. */ autoComplete?: string; /** * Should the field be auto-corrected? */ autoCorrect?: 'on' | 'off'; /** * Should the field be disabled? */ disabled?: boolean; /** * The error message for the field as a string. */ error?: string; /** * The id of the field. */ id: string; /** * A string of Tailwind classes to apply to the `textarea` tag. */ inputTheme?: string; /** * A string of Tailwind classes to apply to the `label` tag. */ labelTheme?: string; /** * The name of the field. The name must match a key in the `validationSchema` object. */ name: FieldNamesType; /** * The onBlur event handler for the field. */ onBlur?: (e: FocusEvent) => void; /** * The onChange event handler for the field. */ onChange?: (e: ChangeEvent) => void; /** * The onFocus event handler for the field. */ onFocus?: (e: FocusEvent) => void; /** * The onKeyDown event handler for the field. */ onKeyDown?: (e: KeyboardEvent) => void; /** * The onKeyUp event handler for the field. */ onKeyUp?: (e: KeyboardEvent) => void; /** * Should the optional subtext be displayed? */ optional?: boolean; /** * The placeholder text to display in the field. */ placeholder?: string; /** * The register function from the `useForm` hook. * @see https://react-hook-form.com/docs/useform/register */ register: Function; /** * Should the field be required? */ required?: boolean; /** * The number of rows to display in the textarea. */ rows?: number; /** * Run input value through this function before validation. Only valid on text inputs. */ // setValueAs?: RegisterOptions['setValueAs']; /** * Should the field be spell-checked? */ spellCheck?: boolean; /** * A string of Tailwind classes to apply to the `div` tag wrapping the component. */ theme?: string; /** * The title of the field. */ title: string | ReactNode; /** * Our custom validation strategy for the field. `all` will use zod validation, `requiredOnly` will only check if the field is required, `none` will skip validation. */ validation?: FieldValidationMethodType; } /** * This is only to be consumed inside the HookForm component. You should not need to use this component directly. Did you mean to use `