import * as React from 'react'; import { Search, XCircle } from 'lucide-react'; import { Input } from './input'; import { cn } from '../../lib/utils'; type InputProps = React.ComponentProps; export type SearchInputProps = Omit & { value: string; onValueChange: (value: string) => void; /** Size: sm (h-9), default (h-10), lg (h-11) */ size?: 'sm' | 'default' | 'lg'; }; const SearchInput = React.forwardRef( ( { value, onValueChange, placeholder, 'aria-label': ariaLabel, className, size = 'default', ...props }, ref ) => { const sizeClasses = { sm: 'h-9 pl-9 pr-9', default: 'h-10 pl-10 pr-10', lg: 'h-11 pl-11 pr-11 text-base', }; const iconSizes = { sm: 'h-4 w-4', default: 'h-4 w-4', lg: 'h-5 w-5', }; const hasValue = value.length > 0; return (
onValueChange(e.target.value)} placeholder={placeholder} aria-label={ariaLabel} className={cn(sizeClasses[size])} {...props} /> {hasValue && ( )}
); } ); SearchInput.displayName = 'SearchInput'; export { SearchInput };