"use client" /* eslint-disable no-restricted-syntax */ import type { ComponentPropsWithoutRef, ReactNode } from "react" import { type As, type MergeWithAs, type SwitchProps, Switch } from "@heroui/react" import type { Field } from "soda-tanstack-form" import { getFieldProps } from "../utils/getFieldProps" export type FormSwitchProps = MergeWithAs< ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef, SwitchProps, AsComponent > & { field: Field component?: ( props: MergeWithAs, ComponentPropsWithoutRef, SwitchProps, AsComponent>, ) => ReactNode } export function FormSwitch({ field, component: Switch2 = Switch, ...rest }: FormSwitchProps): ReactNode { return ( isSelected={field.state.value ?? false} onValueChange={field.handleChange as (value: boolean) => void} {...getFieldProps(field, true)} {...rest} /> ) }