import { forwardRef } from "react" import { cn } from "~/lib/utils" import { FieldLabel } from "./FieldLabel" type InputProps = { label?: string addon?: string prefix?: string isBlock?: boolean error?: string help?: React.ReactNode multiline?: TMultiline } & React.ComponentPropsWithRef export const Input = forwardRef(function Input< TMultiline extends boolean = false, >( { label, addon, prefix, className, isBlock, error, help, multiline, ...inputProps }: InputProps, ref: TMultiline extends true ? React.ForwardedRef : React.ForwardedRef, ) { const hasAddon = !!addon const hasPrefix = !!prefix const Component = (multiline ? "textarea" : "input") as any return (
{label && }
{prefix && ( {prefix} )} {addon && ( {addon} )}
{error &&
{error}
} {help && !error && (
{help}
)}
) }) as ( props: InputProps, ) => JSX.Element