import { Divider, FormControl, type FormControlProps, FormHelperText, InputLabel, ListSubheader, MenuItem, Select, type SelectChangeEvent, type SelectProps, type Theme } from '@mui/material'; import { isNil, propEq } from 'ramda'; import { makeStyles } from 'tss-react/mui'; import { getNormalizedId } from '../../utils'; import Option from './Option'; const useStyles = makeStyles()((theme: Theme) => ({ compact: { fontSize: 'x-small', padding: theme.spacing(0.75) }, input: { fontSize: theme.typography.body1.fontSize }, noLabelInput: { padding: theme.spacing(1) }, select: { '& .MuiInputLabel-shrink~.MuiInputBase-root fieldset legend': { maxWidth: '100%' }, '& fieldset legend': { maxWidth: 0 } } })); export interface SelectEntry { color?: string; createOption?: string; disabled?: boolean; id: number | string; inputValue?: string; name: string; testId?: string; type?: 'header'; url?: string; } type Props = { ariaLabel?: string; compact?: boolean; dataTestId: string; error?: string; label?: string; onChange: (e: React.ChangeEvent) => void; options: Array; selectedOptionId: number | string; formControlProps?: FormControlProps; } & Omit; const SelectField = ({ dataTestId, options, onChange, selectedOptionId, label, error, fullWidth, ariaLabel, inputProps, compact = false, formControlProps, ...props }: Props): JSX.Element => { const { classes, cx } = useStyles(); const getOption = (id: unknown): SelectEntry => { return options.find(propEq(id, 'id')) as SelectEntry; }; const changeOption = (event: SelectChangeEvent): void => { if (!isNil(event.target.value)) { onChange(event as unknown as React.ChangeEvent); } }; return ( {label && {label}} {error && {error}} ); }; export default SelectField;