"use client"; import { cn } from "@/lib/utils"; import type { SortDir } from "./use-table-controls"; // ─── Search bar ────────────────────────────────────────────────────────────── interface TableSearchProps { value: string; onChange: (v: string) => void; placeholder?: string; } export function TableSearch({ value, onChange, placeholder = "Search…" }: TableSearchProps) { return (
onChange(e.target.value)} placeholder={placeholder} className="h-9 w-64 rounded-lg border border-neutral-300 bg-white pl-9 pr-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20" />
); } // ─── Filter chips ──────────────────────────────────────────────────────────── interface FilterChipsProps { chips: string[]; active: string[]; onToggle: (chip: string) => void; } export function FilterChips({ chips, active, onToggle }: FilterChipsProps) { return (
{chips.map((chip) => { const isActive = active.includes(chip); return ( ); })}
); } // ─── TableControls wrapper ──────────────────────────────────────────────────── interface TableControlsProps { search: string; onSearch: (v: string) => void; searchPlaceholder?: string; chips: string[]; activeFilters: string[]; onToggleFilter: (chip: string) => void; } export function TableControls({ search, onSearch, searchPlaceholder, chips, activeFilters, onToggleFilter, }: TableControlsProps) { return (
{chips.length > 0 && ( )}
); } // ─── Sortable column header ─────────────────────────────────────────────────── interface SortableThProps extends React.ThHTMLAttributes { sortKey: string; activeSortKey: string | null; sortDir: SortDir; onSort: (key: string) => void; } export function SortableTh({ sortKey, activeSortKey, sortDir, onSort, children, className, ...rest }: SortableThProps) { const isActive = activeSortKey === sortKey; return ( onSort(sortKey)} > {children} {isActive ? (sortDir === "asc" ? "↑" : "↓") : "⇅"} ); }