mui-rhf-integration
Version:
React Hook Form integration for MUI with strict TypeScript handling based on form context.
10 lines (9 loc) • 826 B
TypeScript
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>, TContext = any, TTransformedValues = TFieldValues> = Omit<SwitchProps, "checked" | "onChange" | "onBlur" | "value" | "ref"> & {
control: Control<TFieldValues, TContext, TTransformedValues>;
name: TName;
};
declare const RhfSwitch: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TContext = any, TTransformedValues = TFieldValues>({ control, name, ...rest }: RhfSwitchProps<TFieldValues, TName, TContext, TTransformedValues>) => ReactNode;
export default RhfSwitch;