"use client"; import { Search, X } from "lucide-react"; import { forwardRef, type InputHTMLAttributes, type ReactNode } from "react"; import { cn } from "./cn"; export interface SearchInputProps extends Omit, "size" | "onChange"> { value: string; onChange: (v: string) => void; onClear?: () => void; size?: "sm" | "md" | "lg"; trailing?: ReactNode; wrapperClassName?: string; loading?: boolean; } export const SearchInput = forwardRef(function SearchInput({ value, onChange, onClear, size = "md", trailing, className, wrapperClassName, loading, ...rest }, ref) { const h = size === "lg" ? "h-12 text-[15px]" : size === "sm" ? "h-10 text-[13px] sm:h-9" : "h-10 text-[14px]"; return (
onChange(e.target.value)} autoComplete="off" spellCheck={false} className={cn("h-full min-w-0 flex-1 bg-transparent px-2.5 outline-none placeholder:text-ink-4", className)} {...rest} /> {value && ( )} {trailing &&
{trailing}
}
); });