import { TextareaHTMLAttributes, forwardRef } from 'react'; import { getFormInputClasses, defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils'; interface TextareaProps extends Omit, 'className'> { className?: string; config?: Partial; label?: string; error?: string; helperText?: string; fullWidth?: boolean; resize?: 'none' | 'vertical' | 'horizontal' | 'both'; } export const Textarea = forwardRef(({ className = '', config = {}, label, error, helperText, fullWidth = true, resize = 'vertical', id, ...props }, ref) => { const layoutConfig = { ...defaultLayoutConfig, ...config }; const inputClasses = getFormInputClasses(!!error); const fullWidthClass = fullWidth ? 'w-full' : ''; const resizeClass = { none: 'resize-none', vertical: 'resize-y', horizontal: 'resize-x', both: 'resize', }[resize]; const inputId = id || `textarea-${Math.random().toString(36).substr(2, 9)}`; return ( {label && ( {label} )} {error && ( {error} )} {helperText && !error && ( {helperText} )} ); }); Textarea.displayName = 'Textarea';
{error}
{helperText}