clean
This commit is contained in:
@@ -7,6 +7,7 @@ import { isTagTransferEvent } from '../tagTransfer';
|
||||
import PreviewZoomOverlay from '../../detail/PreviewZoomOverlay';
|
||||
import { useAssetNavigator } from '../../hooks/useAssetNavigator';
|
||||
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
||||
import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext';
|
||||
|
||||
const DEFAULT_GRID_ICON_SIZE = 144;
|
||||
|
||||
@@ -37,19 +38,14 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
onFolderDragEnd,
|
||||
draggedFolderId,
|
||||
onFolderRename,
|
||||
selectedFolderIds = [],
|
||||
selectedDocumentIds = [],
|
||||
focusedRowKey,
|
||||
draggingDocumentIds = [],
|
||||
onDocumentDragStart,
|
||||
onDocumentDragEnd,
|
||||
onDocumentRename,
|
||||
onEntryPointer = null,
|
||||
onEntrySelection = null,
|
||||
onInspectDocument = null,
|
||||
tagLookupById,
|
||||
activeCorrespondentIds = [],
|
||||
onFocusedRowChange,
|
||||
ensureAssetUrl = null,
|
||||
getDocumentAsset = defaultGetDocumentAsset,
|
||||
onTagClick,
|
||||
@@ -58,10 +54,15 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
onDocumentTagDrop,
|
||||
viewMode = 'list',
|
||||
onViewModeChange,
|
||||
onClearSelection,
|
||||
selectedEntries = [],
|
||||
showHeader = true,
|
||||
}) => {
|
||||
const {
|
||||
selectedEntries,
|
||||
focusedRowKey,
|
||||
setFocusedRowKey,
|
||||
handleEntrySelection,
|
||||
clearSelection,
|
||||
} = useWorkspaceSelectionContext();
|
||||
const showingSearchResults = searchResults !== null;
|
||||
const rows = showingSearchResults ? searchResults : documents;
|
||||
|
||||
@@ -89,9 +90,9 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
const changed = previous.type !== nextContext.type
|
||||
|| previous.marker !== nextContext.marker;
|
||||
if (changed) {
|
||||
onClearSelection?.();
|
||||
clearSelection();
|
||||
}
|
||||
}, [showingSearchResults, currentFolderId, searchResults, onClearSelection]);
|
||||
}, [showingSearchResults, currentFolderId, searchResults, clearSelection]);
|
||||
|
||||
const entries = useMemo(() => {
|
||||
const list = [];
|
||||
@@ -112,14 +113,6 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
return list;
|
||||
}, [showingSearchResults, subfolders, rows]);
|
||||
|
||||
const selectedSet = useMemo(
|
||||
() => new Set(selectedDocumentIds),
|
||||
[selectedDocumentIds],
|
||||
);
|
||||
const selectedFolderSet = useMemo(
|
||||
() => new Set(selectedFolderIds || []),
|
||||
[selectedFolderIds],
|
||||
);
|
||||
const draggingSet = useMemo(
|
||||
() => new Set(draggingDocumentIds || []),
|
||||
[draggingDocumentIds],
|
||||
@@ -271,12 +264,12 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
onFocusedRowChange?.(resolvedKey);
|
||||
setFocusedRowKey(resolvedKey);
|
||||
}, [
|
||||
focusedRowKey,
|
||||
navigableRowKeys,
|
||||
navigableRows,
|
||||
onFocusedRowChange,
|
||||
setFocusedRowKey,
|
||||
selectedEntries,
|
||||
]);
|
||||
|
||||
@@ -320,7 +313,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
|
||||
if (key === 'Enter' || key === ' ' || key === 'Space' || key === 'Spacebar') {
|
||||
if (activeRow) {
|
||||
onEntrySelection?.(activeRow.key, event);
|
||||
handleEntrySelection(activeRow.key, event);
|
||||
if (activeRow.type === EntryType.folder) {
|
||||
onFolderSelect?.(activeRow.id);
|
||||
} else {
|
||||
@@ -353,8 +346,8 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
onFocusedRowChange?.(targetRow.key);
|
||||
onEntrySelection?.(targetRow.key, {
|
||||
setFocusedRowKey(targetRow.key);
|
||||
handleEntrySelection(targetRow.key, {
|
||||
shiftKey,
|
||||
preventDefault: () => {},
|
||||
});
|
||||
@@ -364,11 +357,11 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
getEntryByKey,
|
||||
navigableRowKeys,
|
||||
navigableRows,
|
||||
onEntrySelection,
|
||||
onFocusedRowChange,
|
||||
onFolderSelect,
|
||||
selectedEntries,
|
||||
handleDocumentPreviewZoom,
|
||||
handleEntrySelection,
|
||||
setFocusedRowKey,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -529,10 +522,10 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
&& scrollRef.current
|
||||
) {
|
||||
scrollRef.current.focus({ preventScroll: true });
|
||||
onFocusedRowChange?.(`folder:${folder.id}`);
|
||||
setFocusedRowKey(`folder:${folder.id}`);
|
||||
}
|
||||
},
|
||||
[onEntryPointer, onFocusedRowChange],
|
||||
[onEntryPointer, setFocusedRowKey],
|
||||
);
|
||||
|
||||
const handleDocumentDragStartLocal = useCallback(
|
||||
@@ -666,7 +659,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
}}
|
||||
onClick={(event) => {
|
||||
if (event.target === event.currentTarget) {
|
||||
onClearSelection?.();
|
||||
clearSelection();
|
||||
}
|
||||
}}
|
||||
aria-activedescendant={isGridView ? undefined : activeDescendantId}
|
||||
@@ -674,8 +667,6 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
{isGridView ? (
|
||||
<DocumentsGrid
|
||||
entries={entries}
|
||||
selectedDocumentIdsSet={selectedSet}
|
||||
selectedFolderIdsSet={selectedFolderSet}
|
||||
draggingDocumentIdsSet={draggingSet}
|
||||
draggedFolderId={draggedFolderId}
|
||||
onFolderClick={handleFolderClick}
|
||||
@@ -700,7 +691,6 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
scrollRef={scrollRef}
|
||||
onCorrespondentClick={onCorrespondentClick}
|
||||
activeCorrespondentIdSet={activeCorrespondentIdSet}
|
||||
onClearSelection={onClearSelection}
|
||||
onDocumentRename={onDocumentRename}
|
||||
onFolderRename={onFolderRename}
|
||||
/>
|
||||
@@ -708,8 +698,6 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
<DocumentsList
|
||||
entries={entries}
|
||||
focusedRowKey={focusedRowKey}
|
||||
selectedDocumentIdsSet={selectedSet}
|
||||
selectedFolderIdsSet={selectedFolderSet}
|
||||
draggingDocumentIdsSet={draggingSet}
|
||||
draggedFolderId={draggedFolderId}
|
||||
ensureAssetUrl={ensureAssetUrl}
|
||||
@@ -735,7 +723,6 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
onCorrespondentClick={onCorrespondentClick}
|
||||
activeCorrespondentIdSet={activeCorrespondentIdSet}
|
||||
scrollRef={scrollRef}
|
||||
onClearSelection={onClearSelection}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user