This commit is contained in:
2025-11-13 15:03:35 +01:00
parent 62e44b5375
commit eb20d0bc5e
4 changed files with 34 additions and 61 deletions
+1 -10
View File
@@ -190,16 +190,7 @@ const DocumentsRouteContent: React.FC = () => {
actions={header.actions}
/>
</div>
{(header.selectionLabel || header.floatingActions) ? (
<div className="panel-floating-region" aria-live="polite" aria-atomic="true">
<div className="panel-floating">
{header.selectionLabel ? (
<span className="panel-floating__label">{header.selectionLabel}</span>
) : null}
{header.floatingActions || null}
</div>
</div>
) : null}
{(header.floatingActions)}
</>
) : null}
<div className={bodyClass}>{surface.content}</div>
+2 -25
View File
@@ -1,30 +1,9 @@
import React, { ReactNode } from 'react';
import SelectionFloatingActions from '../documents/SelectionFloatingActions';
import { SelectionFloatingPanel } from '../documents/SelectionFloatingActions';
import { createDocumentsTableHeaderActions } from '../documents/DocumentsPanel';
import createWorkspaceSurfaceConfig from '../documents/workspaceHeader';
import DocumentViewerPanel from '../preview/DocumentViewerPanel';
import DesktopWorkspace from './DesktopWorkspace';
import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext';
type SelectionFloatingActionsBaseProps = Omit<React.ComponentProps<typeof SelectionFloatingActions>, 'selectionCount' | 'selectedDocumentIds' | 'selectedFolderIds'>;
const SelectionFloatingActionsWithSelection: React.FC<SelectionFloatingActionsBaseProps> = (props) => {
const { selectedDocumentIds, selectedFolderIds } = useWorkspaceSelectionContext();
const documentIds = Array.isArray(selectedDocumentIds) ? selectedDocumentIds : [];
const folderIds = Array.isArray(selectedFolderIds) ? selectedFolderIds : [];
const selectionCount = documentIds.length + folderIds.length;
if (selectionCount === 0) {
return null;
}
return (
<SelectionFloatingActions
selectionCount={selectionCount}
selectedDocumentIds={documentIds}
selectedFolderIds={folderIds}
{...props}
/>
);
};
type WorkspaceProps = Record<string, any>;
@@ -58,7 +37,6 @@ const createDesktopSurface = ({
viewMode,
onViewModeChange,
onDeleteSelection,
onClearSelection,
tags,
correspondents,
documentLookup,
@@ -88,7 +66,7 @@ const createDesktopSurface = ({
});
const floatingActions = (
<SelectionFloatingActionsWithSelection
<SelectionFloatingPanel
documentLookup={documentLookup}
tags={tags}
tagLookupById={tagLookupById}
@@ -99,7 +77,6 @@ const createDesktopSurface = ({
onBulkCorrespondentRemove={onBulkCorrespondentRemove}
onBulkReanalyze={onBulkReanalyze}
onDeleteSelection={onDeleteSelection}
onClearSelection={onClearSelection}
folderOptions={folderOptions}
onMoveDocumentsToFolder={onMoveDocumentsToFolder}
/>
@@ -11,6 +11,7 @@ import {
import SelectionAssignmentMenu, { SelectionAssignmentMenuItem } from './SelectionAssignmentMenu';
import SelectionSummary from './SelectionSummary';
import { api, useAppState } from '../app/appState';
import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext';
const ROOT_FOLDER_LABEL = 'Documents';
@@ -64,7 +65,7 @@ interface BulkCorrespondentRemoveArgs {
documentIds: DocumentId[];
}
interface SelectionFloatingActionsProps {
export interface SelectionFloatingActionsProps {
selectionCount?: number;
selectedDocumentIds?: SelectedIdList;
selectedFolderIds?: SelectedIdList;
@@ -616,4 +617,31 @@ const SelectionFloatingActions: React.FC<SelectionFloatingActionsProps> = ({
);
};
export type SelectionFloatingPanelProps = Omit<SelectionFloatingActionsProps, 'selectedDocumentIds' | 'selectedFolderIds' | 'selectionCount'>;
export const SelectionFloatingPanel: React.FC<SelectionFloatingPanelProps> = ({ onClearSelection, ...rest }) => {
const { selectedDocumentIds, selectedFolderIds, clearSelection } = useWorkspaceSelectionContext();
const documentIds = Array.isArray(selectedDocumentIds) ? selectedDocumentIds : [];
const folderIds = Array.isArray(selectedFolderIds) ? selectedFolderIds : [];
const selectionCount = documentIds.length + folderIds.length;
if (selectionCount === 0) {
return null;
}
const handleClear = onClearSelection || clearSelection;
return (
<div className="panel-floating-region" aria-live="polite" aria-atomic="true">
<div className="panel-floating">
<SelectionFloatingActions
selectionCount={selectionCount}
selectedDocumentIds={documentIds}
selectedFolderIds={folderIds}
onClearSelection={handleClear}
{...rest}
/>
</div>
</div>
);
};
export default SelectionFloatingActions;
@@ -1,30 +1,9 @@
import React, { ReactNode } from 'react';
import DocumentViewerPanel from '../../preview/DocumentViewerPanel';
import SelectionFloatingActions from '../SelectionFloatingActions';
import createWorkspaceSurfaceConfig from '../workspaceHeader';
import DocumentsPanel from './DocumentsPanel';
import { SelectionFloatingPanel } from '../SelectionFloatingActions';
import { createDocumentsTableHeaderActions } from './DocumentsToolbar';
import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext';
type SelectionFloatingActionsBaseProps = Omit<React.ComponentProps<typeof SelectionFloatingActions>, 'selectionCount' | 'selectedDocumentIds' | 'selectedFolderIds'>;
const SelectionFloatingActionsWithSelection: React.FC<SelectionFloatingActionsBaseProps> = (props) => {
const { selectedDocumentIds, selectedFolderIds } = useWorkspaceSelectionContext();
const documentIds = Array.isArray(selectedDocumentIds) ? selectedDocumentIds : [];
const folderIds = Array.isArray(selectedFolderIds) ? selectedFolderIds : [];
const selectionCount = documentIds.length + folderIds.length;
if (selectionCount === 0) {
return null;
}
return (
<SelectionFloatingActions
selectionCount={selectionCount}
selectedDocumentIds={documentIds}
selectedFolderIds={folderIds}
{...props}
/>
);
};
interface CreateDocumentsSurfaceArgs {
tableProps: Record<string, any>;
@@ -52,7 +31,6 @@ const createDocumentsSurface = ({
onSortFieldChange,
onSortDirectionToggle,
onDeleteSelection,
onClearSelection,
tags,
correspondents,
documentLookup,
@@ -88,7 +66,7 @@ const createDocumentsSurface = ({
});
const floatingActions = (
<SelectionFloatingActionsWithSelection
<SelectionFloatingPanel
documentLookup={documentLookup}
tags={tags}
tagLookupById={tagLookupById}
@@ -99,7 +77,6 @@ const createDocumentsSurface = ({
onBulkCorrespondentRemove={onBulkCorrespondentRemove}
onBulkReanalyze={onBulkReanalyze}
onDeleteSelection={onDeleteSelection}
onClearSelection={onClearSelection}
folderOptions={folderOptions}
onMoveDocumentsToFolder={onMoveDocumentsToFolder}
/>