import { useVirtualizer } from '@tanstack/react-virtual'
import { Tooltip } from './Tooltip'
import { CloseIcon } from './icons'
import { FolderRow } from './folderPicker/FolderRow'
import { StagedFoldersPanel } from './folderPicker/StagedFoldersPanel'
import { StatusLine } from './folderPicker/StatusLine'
import { normalizePath } from './folderPicker/pathUtils'
import { useFolderPicker } from './folderPicker/useFolderPicker'
export function FolderPickerModal() {
const folderPicker = useFolderPicker()
const virtualizer = useVirtualizer({
count: folderPicker.entries.length,
getScrollElement: () => folderPicker.scrollRef.current,
estimateSize: () => 48,
overscan: 8,
})
if (!folderPicker.folderPickerOpen) return null
return (
folderPicker.setFolderPickerOpen(false)}
>
event.stopPropagation()}
>
Add media folders
Choose folders from any location, then add them together.
{folderPicker.addressEditing ? (
) : (
)}
{folderPicker.error ? (
{folderPicker.error}
) : null}
{folderPicker.loading ? (
Loading folders...
) : folderPicker.entries.length === 0 ? (
No folders found here.
) : (
{virtualizer.getVirtualItems().map((virtualItem) => {
const entry = folderPicker.entries[virtualItem.index]
const normalized = normalizePath(entry.path)
return (
folderPicker.togglePath(entry.path)}
onNavigate={() => folderPicker.setCurrentPath(entry.path)}
/>
)
})}
)}
)
}