import React, { useState } from "react"; import RenameInput from "./RenameInput"; type InputWithDropDownProps = { label: string; value: string; options?: string[]; // Array of dropdown options activeOption?: string; // The currently active dropdown option onClick?: () => void; onChange: (newValue: string) => void; editableLabel?: boolean; }; const InputWithDropDown: React.FC = ({ label, value, options, activeOption, onClick, onChange, editableLabel = false, }) => { const separatedWords = label .split(/(?=[A-Z])/) .map((word) => word.trim()) .toString(); const [openDropdown, setOpenDropdown] = useState(false); return (
{editableLabel ? ( ) : ( )}
{ onChange(e.target.value); }} /> {activeOption && (
{ setOpenDropdown(true); }} >
{activeOption}
{options && openDropdown && (
{options.map((option, index) => (
{option}
))}
)}
)}
); }; export default InputWithDropDown;