import { Show, createSignal, createUniqueId } from "solid-js"; import { IconSearch, IconX } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { cn } from "@/lib/cn"; import { useT } from "@/stores/preferences-context"; export type DataTableSearchProps = { value: string; onChange: (value: string) => void; placeholder?: string; /** * What this particular box actually matches on, in the user's words. Shown * under the field while it has focus — a placeholder alone never says * whether a name, a code or a description is the thing to type. Keep it * honest: it must list what the filter really reads, nothing more. */ hint?: string; /** Optional styling for the focused hint, e.g. a wider panel search hint. */ hintClass?: string; onKeyDown?: (event: KeyboardEvent) => void; class?: string; }; /** Rounded search field: leading icon, conditional clear (X) button, Escape to * empty it, and an optional on-focus hint naming the fields it searches. */ export function DataTableSearch(props: DataTableSearchProps) { const t = useT(); const [focused, setFocused] = createSignal(false); const hintId = createUniqueId(); return (
{props.hint}