import FormHelperText from "@mui/material/FormHelperText"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; import FormControl from "@mui/material/FormControl"; import Select from "@mui/material/Select"; import { prettyName } from "utils/formatting"; import { ReactNode } from "react"; export type Props = { current?: T; options: readonly T[]; onChange: (n: T) => void; label: string; id?: string; className?: string; prettyOptionLabels?: boolean; getKey?: (n: T) => string; placeholder?: any; title?: string; helperText?: string; endAdornment?: ReactNode; }; export function InputList({ current, options, onChange, label, id, className, prettyOptionLabels, getKey = String, placeholder, title, helperText, endAdornment, }: Props) { const invalidCurrent = current && !options.map(getKey).includes(getKey(current)); return ( {label} {invalidCurrent ? `'${current}' is not a valid selection` : helperText} ); }