import { forwardRef, useId, type InputHTMLAttributes, type ReactNode } from 'react'; import { cn } from '@/utils/classNames'; export interface InputProps extends Omit, 'size'> { readonly label?: string; readonly hideLabel?: boolean; readonly hint?: string; readonly error?: string; readonly leftIcon?: ReactNode; readonly rightSlot?: ReactNode; readonly containerClassName?: string; readonly inputSize?: 'sm' | 'md' | 'lg'; } const sizeClasses = { sm: 'h-9 rounded-xl px-3 text-sm', md: 'h-11 rounded-2xl px-4 text-sm', lg: 'h-12 rounded-2xl px-4 text-base' } as const; export const Input = forwardRef(function Input( { className, containerClassName, error, hideLabel = false, hint, id, inputSize = 'md', label, leftIcon, rightSlot, type = 'text', ...props }, ref, ) { const generatedId = useId(); const inputId = id ?? generatedId; const hintId = hint ? `${inputId}-hint` : undefined; const errorId = error ? `${inputId}-error` : undefined; const describedBy = [hintId, errorId, props['aria-describedby']].filter(Boolean).join(' '); return ( {label ? ( {label} ) : null} {leftIcon ? ( {leftIcon} ) : null} {rightSlot ? ( {rightSlot} ) : null} {hint ? ( {hint} ) : null} {error ? ( {error} ) : null} ); });
{hint}
{error}