import { SelectHTMLAttributes, forwardRef } from 'react'; import { getFormInputClasses, defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils'; interface SelectOption { value: string; label: string; disabled?: boolean; } interface SelectProps extends Omit, 'className'> { className?: string; config?: Partial; label?: string; error?: string; helperText?: string; fullWidth?: boolean; options: SelectOption[]; placeholder?: string; } export const Select = forwardRef(({ className = '', config = {}, label, error, helperText, fullWidth = true, options, placeholder, id, ...props }, ref) => { const layoutConfig = { ...defaultLayoutConfig, ...config }; const inputClasses = getFormInputClasses(!!error); const fullWidthClass = fullWidth ? 'w-full' : ''; const inputId = id || `select-${Math.random().toString(36).substr(2, 9)}`; return ( {label && ( {label} )} {placeholder && ( {placeholder} )} {options.map((option) => ( {option.label} ))} {/* Custom dropdown arrow */} {error && ( {error} )} {helperText && !error && ( {helperText} )} ); }); Select.displayName = 'Select';
{error}
{helperText}