UNPKG

mui-rhf-integration

Version:

React Hook Form integration for MUI with strict TypeScript handling based on form context.

10 lines (9 loc) 664 B
import { SwitchProps } from '@mui/material'; import { ReactNode } from 'react'; import { Control, FieldPath, FieldValues } from 'react-hook-form'; export type RhfSwitchProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<SwitchProps, "checked" | "onChange" | "onBlur" | "value" | "ref"> & { control: Control<TFieldValues>; name: TName; }; declare const RhfSwitch: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, name, ...rest }: RhfSwitchProps<TFieldValues, TName>) => ReactNode; export default RhfSwitch;