import React, { useState } from "react"; import { Box, FormControl, TextField, Typography, useTheme } from "@mui/material"; import type { ChangeEvent, KeyboardEvent, FocusEvent } from "react"; import type { InputProps, SxProps, Theme } from "@mui/material"; interface CustomTextFieldProps { placeholder: string; value?: string; error?: string; emptyError?: boolean; onChange?: (event: ChangeEvent) => void; onKeyDown?: (event: KeyboardEvent) => void; onBlur?: (event: FocusEvent) => void; text?: string; maxLength?: number; sx?: SxProps; InputProps?: Partial; } export default function CustomTextField({ placeholder, value, onChange, onKeyDown, onBlur, text, sx, error, emptyError, InputProps, maxLength = 200, }: CustomTextFieldProps) { const theme = useTheme(); const [inputValue, setInputValue] = useState(value || ""); const [isInputActive, setIsInputActive] = useState(false); const handleInputChange = (event: React.ChangeEvent) => { const inputValue = event.target.value; setInputValue(inputValue); if (onChange) { onChange(event); } }; const handleInputFocus = () => { setIsInputActive(true); }; const handleInputBlur = (event: React.FocusEvent) => { setIsInputActive(false); if (onBlur) { onBlur(event); } }; return ( {isInputActive && inputValue.length >= maxLength - 7 && ( {inputValue.length} / {maxLength} )} ); }