deno.land / x / netzo@0.5.16 / components / blocks / table / table-search.tsx
12345678910111213141516171819202122232425262728293031323334import type { JSX } from "preact";import { Input } from "../../input.tsx";import { cn } from "../../utils.ts";import { type Table } from "./table.tsx";
export type TableSearch = { column: string; placeholder?: string;};
export function TableSearch<TData = unknown>({ className, table,}: JSX.IntrinsicElements["input"] & { table: Table<TData> }) { if (!table.options?.initialState?.search) { console.error(`Missing "search" property in table.options.initialState`); return null; }
const { column, placeholder } = table.options.initialState ?.search as TableSearch;
return ( <Input type="search" placeholder={placeholder} value={table.getColumn(column)?.getFilterValue() as string ?? ""} onChange={(e) => table.getColumn(column)?.setFilterValue(e.target.value)} className={cn("h-8 w-[150px] lg:w-[250px]", className)} autocomplete="off" /> );}
Version Info