import * as React from 'react'; import { cn } from '@/lib/utils'; import { Search } from 'lucide-react'; export interface InputProps extends React.InputHTMLAttributes {} const Input = React.forwardRef( ({ className, type, ...props }, ref) => { return ( ); }, ); Input.displayName = 'Input'; export interface ExpandedInputProps extends Omit { prefix?: React.ReactNode; suffix?: React.ReactNode; } const ExpandedInput = ({ suffix, prefix, className, ...props }: ExpandedInputProps) => { return (
{prefix} {suffix}
); }; const SearchInput = (props: InputProps) => { return ( } {...props} > ); }; type Value = string | readonly string[] | number | undefined; export const InnerBlurInput = React.forwardRef< HTMLInputElement, InputProps & { value: Value; onChange(value: Value): void } >(({ value, onChange, ...props }, ref) => { const [val, setVal] = React.useState(); const handleChange: React.ChangeEventHandler = React.useCallback((e) => { setVal(e.target.value); }, []); const handleBlur: React.FocusEventHandler = React.useCallback( (e) => { onChange?.(e.target.value); }, [onChange], ); React.useEffect(() => { setVal(value); }, [value]); return ( ); }); export const BlurInput = React.memo(InnerBlurInput); export { ExpandedInput, Input, SearchInput };