import React from 'react'; import DocumentViewerPanel from '../../preview/DocumentViewerPanel'; import SelectionFloatingActions from '../SelectionFloatingActions'; import createWorkspaceSurfaceConfig from '../workspaceHeader'; import DocumentsPanel from './DocumentsPanel'; import { createDocumentsTableHeaderActions } from './DocumentsToolbar'; const createDocumentsSurface = ({ tableProps, parentBreadcrumb, onNavigateParent, renderSidebarToggle, detailProps, detailOpen = false, }) => { const { currentFolderName, breadcrumbs, searchResults, isFilterActive, viewMode, onViewModeChange, onRefresh, sortField, sortDirection, onSortFieldChange, onSortDirectionToggle, selectedDocumentIds, selectedFolderIds, onDeleteSelection, onClearSelection, tags, correspondents, documentLookup, tagLookupById, onBulkTagAdd, onBulkTagRemove, onBulkCorrespondentAdd, onBulkCorrespondentRemove, onBulkReanalyze, folderOptions, onMoveDocumentsToFolder, searchIncludeDescendants, onToggleSearchIncludeDescendants, onInspectDocument, } = tableProps; const title = Array.isArray(searchResults) ? 'Search results' : currentFolderName; const subtitle = Array.isArray(searchResults) ? `${searchResults.length} matching document${searchResults.length === 1 ? '' : 's'}` : null; const documentSelectionCount = Array.isArray(selectedDocumentIds) ? selectedDocumentIds.length : 0; const folderSelectionCount = Array.isArray(selectedFolderIds) ? selectedFolderIds.length : 0; const selectionCount = documentSelectionCount + folderSelectionCount; const actions = createDocumentsTableHeaderActions({ viewMode, onViewModeChange, onRefresh, sortField, onSortFieldChange, sortDirection, onSortDirectionToggle, isFilterActive, includeDescendants: searchIncludeDescendants, onToggleIncludeDescendants: onToggleSearchIncludeDescendants, }); const floatingActions = selectionCount > 0 ? ( ) : null; const sidebarToggle = renderSidebarToggle ? renderSidebarToggle() : null; const detail = detailOpen && detailProps ? (() => { const { onClose, onOpenPreview, ...restDetailProps } = detailProps; return ( ); })() : null; return createWorkspaceSurfaceConfig({ key: 'documents', variant: 'documents', title, subtitle, sidebarToggle, parentBreadcrumb, onNavigateParent, actions, breadcrumbs, selectionLabel: null, floatingActions, content: ( ), detail, }); }; export default createDocumentsSurface;