UNPKG

@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

19 lines (18 loc) 1.07 kB
import { type ReactNode, type ChangeEvent } from 'react'; import { type FieldValues, type Path, type Control, type RegisterOptions } from 'react-hook-form'; import { type SwitchProps } from '@mui/material/Switch'; import type { FormControlLabelProps, FormHelperTextProps } from '../../types'; export type RHFSwitchProps<T extends FieldValues> = { fieldName: Path<T>; control: Control<T>; registerOptions?: RegisterOptions<T, Path<T>>; onValueChange?: (isChecked: boolean, event: ChangeEvent<HTMLInputElement>) => void; label?: ReactNode; formControlLabelProps?: FormControlLabelProps; helperText?: ReactNode; errorMessage?: ReactNode; hideErrorMessage?: boolean; formHelperTextProps?: FormHelperTextProps; } & Omit<SwitchProps, 'name'>; declare const RHFSwitch: <T extends FieldValues>({ fieldName, control, registerOptions, onValueChange, label, formControlLabelProps, helperText, errorMessage, hideErrorMessage, formHelperTextProps, ...rest }: RHFSwitchProps<T>) => import("react/jsx-runtime").JSX.Element; export default RHFSwitch;