@ladg/rhfmui
Version:
The integration of MUI components with React hook form.
40 lines • 1.89 kB
TypeScript
import { CheckboxProps } from '@mui/material/Checkbox';
import { FormControlProps } from '@mui/material/FormControl';
import { FormControlLabelProps } from '@mui/material/FormControlLabel';
import { FormGroupProps } from '@mui/material/FormGroup';
import { FormLabelProps } from '@mui/material/FormLabel';
import { JSX } from 'react';
import { RegisterOptions, UseFormReturn } from 'react-hook-form';
/**
* IMP Note:
* 1. do not use defaultChecked. This will cause this error=> (Styled(input) contains an input of type checkbox with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props.)
*/
type CheckboxGroupOptions = {
id: string;
optionLabel: string;
value: string;
isDisabled?: boolean;
dataObject?: {
[x: string]: any;
};
};
type RHFMuiCheckboxGroupProps = {
rhfinstance: UseFormReturn<any>;
rhf_rules?: Omit<RegisterOptions<any, any>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
name: string;
label: string;
options: CheckboxGroupOptions[];
required?: boolean;
orientation?: 'vertical' | 'horizontal';
labelPlacement?: 'end' | 'bottom' | 'top' | 'start';
permanentMessage?: string | (() => JSX.Element);
onChangeExtraHandler?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
formControlLabelProps?: Omit<FormControlLabelProps, 'label' | 'control'>;
checkboxProps?: CheckboxProps;
formGroupProps?: FormGroupProps;
formControlProps?: FormControlProps;
formLabelProps?: Omit<FormLabelProps, 'children'>;
};
export declare const RHFMuiCheckboxGroup: React.FC<RHFMuiCheckboxGroupProps>;
export {};
//# sourceMappingURL=RHFMuiCheckboxGroup.d.ts.map