import { SelectHTMLAttributes, forwardRef } from 'react'; import { ChevronDown } from 'lucide-react'; interface SelectOption { value: string; label: string; disabled?: boolean; } interface SelectProps extends Omit, 'children'> { label?: string; error?: string; helperText?: string; options: SelectOption[]; placeholder?: string; } const Select = forwardRef(({ label, error, helperText, options, placeholder = 'เลือก...', className = '', id, ...props }, ref) => { const selectId = id || `select-${Math.random().toString(36).substr(2, 9)}`; return ( {label && ( {label} {props.required && *} )} {placeholder && ( {placeholder} )} {options.map(option => ( {option.label} ))} {error && ( {error} )} {helperText && !error && ( {helperText} )} ); }); Select.displayName = 'Select'; export default Select;
{error}
{helperText}