import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso' import type { VaultEntry } from '../../types' import type { SortOption, SortDirection, SortConfig, RelationshipGroup } from '../../utils/noteListHelpers' import { PinnedCard } from './PinnedCard' import { RelationshipGroupSection } from './RelationshipGroupSection' import { TrashWarningBanner, EmptyMessage } from './TrashWarningBanner' function ListViewHeader({ isTrashView, expiredTrashCount }: { isTrashView: boolean; expiredTrashCount: number }) { return } function resolveEmptyText(isChangesView: boolean, changesError: string | null | undefined, isTrashView: boolean, isArchivedView: boolean, isInboxView: boolean, query: string): string { if (isChangesView && changesError) return `Failed to load changes: ${changesError}` if (isChangesView) return 'No pending changes' if (isTrashView) return 'Trash is empty' if (isArchivedView) return 'No archived notes' if (isInboxView) return query ? 'No matching notes' : 'All notes are organized' return query ? 'No matching notes' : 'No notes found' } export function EntityView({ entity, groups, query, collapsedGroups, sortPrefs, onToggleGroup, onSortChange, renderItem, typeEntryMap, onClickNote }: { entity: VaultEntry; groups: RelationshipGroup[]; query: string collapsedGroups: Set; sortPrefs: Record onToggleGroup: (label: string) => void; onSortChange: (label: string, opt: SortOption, dir: SortDirection) => void renderItem: (entry: VaultEntry) => React.ReactNode typeEntryMap: Record; onClickNote: (entry: VaultEntry, e: React.MouseEvent) => void }) { return (
{groups.length === 0 ? : groups.map((group) => ( onToggleGroup(group.label)} handleSortChange={onSortChange} renderItem={renderItem} /> )) }
) } export function ListView({ isTrashView, isArchivedView, isChangesView, isInboxView, changesError, expiredTrashCount, deletedCount = 0, searched, query, renderItem, virtuosoRef }: { isTrashView: boolean; isArchivedView?: boolean; isChangesView?: boolean; isInboxView?: boolean; changesError?: string | null; expiredTrashCount: number deletedCount?: number; searched: VaultEntry[]; query: string renderItem: (entry: VaultEntry) => React.ReactNode virtuosoRef?: React.RefObject }) { const emptyText = resolveEmptyText(!!isChangesView, changesError ?? null, isTrashView, !!isArchivedView, !!isInboxView, query) const hasHeader = isTrashView && expiredTrashCount > 0 const hasDeletedOnly = !!isChangesView && deletedCount > 0 && searched.length === 0 if (searched.length === 0 && !hasDeletedOnly) { return (
{hasHeader && }
) } if (hasDeletedOnly) { return
} return ( : undefined, }} itemContent={(_index, entry) => renderItem(entry)} /> ) }