deno.land / x / netzo@0.5.16 / components / blocks / table / table-search.tsx

table-search.tsx
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 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" /> );}
netzo

Version Info

Tagged at
a year ago