import {factory, Select as MantineSelect, type SelectFactory} from '@mantine/core';
import {readOnlyInputStyles} from '../ReadOnly/ReadOnlyInputStyles.js';

const ReadOnlySelect = MantineSelect.withProps({styles: readOnlyInputStyles});

export const Select = factory<SelectFactory>((props, ref) => {
    if (props.readOnly && !props.disabled) {
        return <ReadOnlySelect ref={ref} data-readonly {...props} />;
    }
    return <MantineSelect ref={ref} {...props} />;
});

Select.displayName = 'Select';
