import React, {ChangeEvent, useEffect, useRef} from "react"; interface TextAreaInputProps { value: string; setValue: (e: ChangeEvent) => void; placeholder: string; maxLength?: number; } export default function TextAreaInput( { value, setValue, placeholder, maxLength }: TextAreaInputProps) { const progressRef = useRef(null); useEffect(() => { if (progressRef.current && maxLength) { progressRef.current.style.width = `${getProgressPercentage()}%`; } }); function getProgressPercentage(): number { if (!maxLength) return 0; return Math.min((value.length / maxLength) * 100, 100); } function getStatusStyles(): { textColor: string; progressColor: string } | Record { if (!maxLength) return {}; const percentage = getProgressPercentage(); if (percentage >= 100) return { textColor: 'text-error', progressColor: 'bg-error' }; if (percentage >= 75) return { textColor: 'text-warning', progressColor: 'bg-warning' }; return { textColor: 'text-muted', progressColor: 'bg-primary' }; } const styles = getStatusStyles(); return (