/** * SearchHistoryDropdown Component * Liquid Glass design system compliant dropdown for search history * Features: frosted glass effect, rounded-2xl corners, smooth animations */ 'use client'; import { useEffect, useRef } from 'react'; import { Icons } from '@/components/ui/Icon'; import type { SearchHistoryItem } from '@/lib/store/search-history-store'; import { SearchHistoryEmptyState } from './SearchHistoryEmptyState'; import { SearchHistoryHeader } from './SearchHistoryHeader'; import { SearchHistoryListItem } from './SearchHistoryListItem'; interface SearchHistoryDropdownProps { isOpen: boolean; searchHistory: SearchHistoryItem[]; highlightedIndex: number; triggerRef: React.RefObject; onSelectItem: (query: string) => void; onRemoveItem: (query: string) => void; onClearAll: () => void; } export function SearchHistoryDropdown({ isOpen, searchHistory, highlightedIndex, triggerRef, onSelectItem, onRemoveItem, onClearAll, }: SearchHistoryDropdownProps) { const dropdownRef = useRef(null); // Scroll highlighted item into view useEffect(() => { if (highlightedIndex === -1 || !dropdownRef.current) return; const highlightedElement = dropdownRef.current.querySelector( `[data-index="${highlightedIndex}"]` ); if (highlightedElement) { highlightedElement.scrollIntoView({ block: 'nearest', behavior: 'smooth', }); } }, [highlightedIndex]); if (!isOpen || searchHistory.length === 0) { return null; } return (
{ // Prevent blur when clicking inside dropdown e.preventDefault(); }} > {/* Header with clear all button */} {/* Divider */}
{/* History items */}
{searchHistory.map((item, index) => ( ))}
); }