@nish1896/rhf-mui-components
Version:
A suite of 20+ reusable Material UI components for React Hook Form to minimize your time and effort in creating and styling forms
28 lines (27 loc) • 1.55 kB
TypeScript
import { type ReactNode, type ChangeEvent } from 'react';
import { type FieldValues, type Path, type Control, type RegisterOptions } from 'react-hook-form';
import { type RadioGroupProps } from '@mui/material/RadioGroup';
import type { FormLabelProps, FormControlLabelProps, FormHelperTextProps, StrObjOption, RadioProps } from '../../types';
type RadioGroupInputProps = Omit<RadioGroupProps, 'name' | 'value' | 'onChange'>;
export type RHFRadioGroupProps<T extends FieldValues> = {
fieldName: Path<T>;
control: Control<T>;
registerOptions?: RegisterOptions<T, Path<T>>;
options: StrObjOption[];
labelKey?: string;
valueKey?: string;
onValueChange?: (selectedValue: string, event: ChangeEvent<HTMLInputElement>) => void;
disabled?: boolean;
label?: ReactNode;
showLabelAboveFormField?: boolean;
formLabelProps?: FormLabelProps;
radioProps?: RadioProps;
formControlLabelProps?: FormControlLabelProps;
helperText?: ReactNode;
required?: boolean;
errorMessage?: ReactNode;
hideErrorMessage?: boolean;
formHelperTextProps?: FormHelperTextProps;
} & RadioGroupInputProps;
declare const RHFRadioGroup: <T extends FieldValues>({ fieldName, control, registerOptions, options, labelKey, valueKey, onValueChange, disabled, label, showLabelAboveFormField, formLabelProps, radioProps, formControlLabelProps, required, helperText, errorMessage, hideErrorMessage, formHelperTextProps, ...rest }: RHFRadioGroupProps<T>) => import("react/jsx-runtime").JSX.Element;
export default RHFRadioGroup;