import React, { ChangeEvent, useState } from "react"; import { useUpdateEffect } from "react-use"; import { HiInformationCircle } from "react-icons/hi"; interface Props { value: string; onChange: (value: string) => void; placeholder?: string; tooltip?: string; label?: string; onlyAlphaNumeric?: boolean; } export const TextInput: React.FC = ({ value: initialValue, onChange, placeholder, tooltip, onlyAlphaNumeric = true, label, }) => { const [value, setValue] = useState(initialValue); const handleInputChange = (event: ChangeEvent) => { const newValue = event.target.value; // Only allow numbers or strings if (onlyAlphaNumeric && /^[0-9a-zA-Z]*$/.test(newValue)) { return setValue(newValue); } setValue(newValue); }; useUpdateEffect(() => onChange(value), [value]); return (
{tooltip && (
{tooltip}
)}
); };