import { LabeledInput, LabeledInputProps } from '@/components/ra-inputs/LabeledInput';
import { styled } from '@mui/material/styles';
import { SelectInput as RaSelectInput, SelectInputProps as RaSelectInputProps } from 'react-admin';

const StyledSelectInput = styled(RaSelectInput, { slot: 'Root' })(({ label }) => ({
  '& legend': {
    width: label === false || label === null ? 0 : 'auto'
  }
}));
type SelectInputProps = LabeledInputProps & RaSelectInputProps;
function SelectInput(props: SelectInputProps): JSX.Element {
  return (
    <LabeledInput {...props}>
      <StyledSelectInput />
    </LabeledInput>
  );
}

export { SelectInput };
