import React, { useState, useMemo } from 'react'; import { Search, Check, X } from 'lucide-react'; import { cn } from '../lib/utils'; interface ColumnFilterPopoverProps { uniqueValues: string[]; selectedValues: string[]; onToggle: (val: string) => void; onSelectAll: (vals: string[]) => void; onClear: () => void; onClose: () => void; title?: string; className?: string; } export function ColumnFilterPopover({ uniqueValues, selectedValues, onToggle, onSelectAll, onClear, onClose, title, className }: ColumnFilterPopoverProps) { const [search, setSearch] = useState(''); const filteredValues = useMemo(() => { return uniqueValues.filter(v => String(v || '').toLowerCase().includes(search.toLowerCase()) ); }, [uniqueValues, search]); const isAllSelected = selectedValues.length === uniqueValues.length && uniqueValues.length > 0; return (
e.stopPropagation()} > {title &&
{title}
}
setSearch(e.target.value)} className="w-full bg-slate-900 border border-slate-700 rounded p-1.5 pl-8 pr-7 text-xs text-white focus:outline-none focus:border-blue-500" autoFocus /> {search && ( )}
{filteredValues.map(val => (
onToggle(val)} onKeyDown={(e) => { if (e.key === ' ' || e.key === 'Enter') { e.preventDefault(); onToggle(val); } }} className="flex items-center gap-2 p-1.5 hover:bg-slate-700/50 rounded cursor-pointer group" >
{selectedValues.includes(val) && }
{val || '(Empty)'}
))} {filteredValues.length === 0 && (
No values found
)}
); }