import { ForwardedRef, forwardRef, ReactNode } from 'react'; import { Checkbox as MuiCheckbox, CheckboxProps as MuiCheckboxProps, FormControl, FormControlLabel, FormControlLabelProps, FormControlProps, FormHelperText, FormHelperTextProps } from '@mui/material'; import { useDefaultProps } from '../../hooks'; export type CheckBoxProps = Omit & { label?: string; required?: boolean; helperText?: ReactNode; value?: boolean; error?: boolean; disabled?: boolean; name?: string; slotProps?: { formControlLabel?: Omit; helperText?: FormHelperTextProps; formControl?: Omit; }; }; const Checkbox = forwardRef(function Checkbox(inProps: CheckBoxProps, ref: ForwardedRef) { const { label, required, helperText, onChange, onBlur, value, name, error, disabled, indeterminate, slotProps: { formControl: formControlProps, formControlLabel: formControlLabelProps, helperText: helperTextProps, ...checkboxSlotProps } = {}, ...checkboxProps } = useDefaultProps({ name: 'ReevolveCheckbox', props: inProps }); return ( } ref={ref} label={label} required={required} /> {helperText && {helperText}} ); }); declare module '@mui/material' { interface Components { ReevolveCheckbox?: { defaultProps?: Partial; }; } } export default Checkbox;