import React from "react"; import { Switch, SwitchProps } from "@mantine/core"; import { useController, FieldValues, UseControllerProps, } from "react-hook-form"; import RHFSwitchGroup from "./RHFSwitchGroup"; type Props = SwitchProps & { name: UseControllerProps["name"]; rules?: UseControllerProps["rules"]; defaultValue?: UseControllerProps["defaultValue"]; }; function RHFSwitch(props: Props) { const { name, rules, defaultValue, ...others } = props; const { field, fieldState: { error }, } = useController({ name, rules }); return ( ); } RHFSwitch.Group = RHFSwitchGroup; export default RHFSwitch; export const createSwitchField = () => { const Field = (props: Props) => ; return Field; };