import React from "react"; import { Switch, SwitchProps } from "@headlessui/react"; import { Controller, FieldPath, FieldValues, useFormContext, } from "react-hook-form"; import { twMerge } from "tailwind-merge"; import { Prettify } from "@/types"; import { Field, GenericFieldProps } from "./Field"; type SwitchFieldProps< TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath = FieldPath, > = Prettify< GenericFieldProps & Omit, "name"> >; export const SwitchField = < TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath = FieldPath, >( props: SwitchFieldProps, ) => { const { name, control, label, disabled, className, labelClassName, childrenWrapperClassName, hideErrorMessage, ...rest } = props; const form = useFormContext(); return (
(
)} />
); };