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