feat(search): add search history functionality with dropdown and persistence

- Implement SearchHistoryDropdown component for displaying recent searches
- Add useSearchHistory hook for managing search history in localStorage
- Integrate search history into SearchOverlay for user convenience
- Update GridToolbar to support filter presets
- Enhance SearchOverlay with close button and history display
This commit is contained in:
2026-02-15 13:52:36 +02:00
parent 6226193ab5
commit 9ec2e73640
42 changed files with 2026 additions and 780 deletions

View File

@@ -4,7 +4,7 @@ import type { Virtualizer } from '@tanstack/react-virtual'
import { createSyncStore } from '@warkypublic/zustandsyncstore'
import type { DataAdapter, GriddyColumn, GriddyProps, GriddyUIState, GroupingConfig, InfiniteScrollConfig, PaginationConfig, SearchConfig, SelectionConfig } from './types'
import type { AdvancedSearchConfig, DataAdapter, GriddyColumn, GriddyProps, GriddyUIState, GroupingConfig, InfiniteScrollConfig, PaginationConfig, SearchConfig, SelectionConfig } from './types'
// ─── Store State ─────────────────────────────────────────────────────────────
@@ -18,24 +18,30 @@ export interface GriddyStoreState extends GriddyUIState {
// ─── Internal refs (set imperatively) ───
_table: null | Table<any>
_virtualizer: null | Virtualizer<HTMLDivElement, Element>
advancedSearch?: AdvancedSearchConfig
className?: string
columnFilters?: ColumnFiltersState
columns?: GriddyColumn<any>[]
columnPinning?: ColumnPinningState
onColumnPinningChange?: (pinning: ColumnPinningState) => void
data?: any[]
// ─── Error State ───
error: Error | null
exportFilename?: string
dataAdapter?: DataAdapter<any>
dataCount?: number
filterPresets?: boolean
getRowId?: (row: any, index: number) => string
grouping?: GroupingConfig
height?: number | string
infiniteScroll?: InfiniteScrollConfig
isLoading?: boolean
keyboardNavigation?: boolean
manualFiltering?: boolean
manualSorting?: boolean
onColumnFiltersChange?: (filters: ColumnFiltersState) => void
onEditCommit?: (rowId: string, columnId: string, value: unknown) => Promise<void> | void
onError?: (error: Error) => void
onRowSelectionChange?: (selection: RowSelectionState) => void
onSortingChange?: (sorting: SortingState) => void
overscan?: number
@@ -46,6 +52,7 @@ export interface GriddyStoreState extends GriddyUIState {
search?: SearchConfig
selection?: SelectionConfig
setError: (error: Error | null) => void
showToolbar?: boolean
setScrollRef: (el: HTMLDivElement | null) => void
// ─── Internal ref setters ───
@@ -69,6 +76,7 @@ export const { Provider: GriddyProvider, useStore: useGriddyStore } = createSync
_table: null,
_virtualizer: null,
error: null,
focusedColumnId: null,
// ─── Focus State ───
focusedRowIndex: null,
@@ -92,6 +100,7 @@ export const { Provider: GriddyProvider, useStore: useGriddyStore } = createSync
},
moveFocusToStart: () => set({ focusedRowIndex: 0 }),
setEditing: (editing) => set({ isEditing: editing }),
setError: (error) => set({ error }),
setFocusedColumn: (id) => set({ focusedColumnId: id }),
// ─── Actions ───
setFocusedRow: (index) => set({ focusedRowIndex: index }),