import { forwardRef, useId, type InputHTMLAttributes, type ReactNode } from 'react'; import { cn } from '../utils/cn'; interface Props extends InputHTMLAttributes { label?: string; hint?: string; error?: string; leftIcon?: ReactNode; rightIcon?: ReactNode; containerClassName?: string; } export const Input = forwardRef(function Input( { label, hint, error, leftIcon, rightIcon, className, containerClassName, id, required, ...rest }, ref, ) { const generatedId = useId(); const inputId = id || generatedId; const describedBy = error ? `${inputId}-error` : hint ? `${inputId}-hint` : undefined; return ( {label && ( {label} {required && ( * )} )} {leftIcon && ( {leftIcon} )} {rightIcon && ( {rightIcon} )} {hint && !error && ( {hint} )} {error && ( {error} )} ); });
{hint}
{error}