import { forwardRef, useId } from "react"; import { Controller, FieldValues, Path } from "react-hook-form"; import { useFormReturn } from "~/hooks/useForm"; import { cn } from "~/lib/utils"; import FormField, { FormFieldProps } from "./form-field"; export type BaseInputProps = React.InputHTMLAttributes & FormFieldProps & { inputClassName?: string; }; const BaseInput = forwardRef( ({ className, inputClassName, type, label, error, ...props }, ref) => { const id = useId(); const input = ( ); if (label || error) { return ( ); } return input; } ); BaseInput.displayName = "BaseInput"; type InputProps = Omit< BaseInputProps, "form" | "name" > & { form?: useFormReturn; name?: Path; }; const Input = (props: InputProps) => { const { form, ...restProps } = props; if (form && props.name) { return ( ( )} /> ); } return ; }; export { BaseInput }; export default Input;