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} actions={header.actions}
/> />
</div> </div>
{(header.selectionLabel || header.floatingActions) ? ( {(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}
</> </>
) : null} ) : null}
<div className={bodyClass}>{surface.content}</div> <div className={bodyClass}>{surface.content}</div>
+2 -25
View File
@@ -1,30 +1,9 @@
import React, { ReactNode } from 'react'; import React, { ReactNode } from 'react';
import SelectionFloatingActions from '../documents/SelectionFloatingActions'; import { SelectionFloatingPanel } from '../documents/SelectionFloatingActions';
import { createDocumentsTableHeaderActions } from '../documents/DocumentsPanel'; import { createDocumentsTableHeaderActions } from '../documents/DocumentsPanel';
import createWorkspaceSurfaceConfig from '../documents/workspaceHeader'; import createWorkspaceSurfaceConfig from '../documents/workspaceHeader';
import DocumentViewerPanel from '../preview/DocumentViewerPanel'; import DocumentViewerPanel from '../preview/DocumentViewerPanel';
import DesktopWorkspace from './DesktopWorkspace'; 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>; type WorkspaceProps = Record<string, any>;
@@ -58,7 +37,6 @@ const createDesktopSurface = ({
viewMode, viewMode,
onViewModeChange, onViewModeChange,
onDeleteSelection, onDeleteSelection,
onClearSelection,
tags, tags,
correspondents, correspondents,
documentLookup, documentLookup,
@@ -88,7 +66,7 @@ const createDesktopSurface = ({
}); });
const floatingActions = ( const floatingActions = (
<SelectionFloatingActionsWithSelection <SelectionFloatingPanel
documentLookup={documentLookup} documentLookup={documentLookup}
tags={tags} tags={tags}
tagLookupById={tagLookupById} tagLookupById={tagLookupById}
@@ -99,7 +77,6 @@ const createDesktopSurface = ({
onBulkCorrespondentRemove={onBulkCorrespondentRemove} onBulkCorrespondentRemove={onBulkCorrespondentRemove}
onBulkReanalyze={onBulkReanalyze} onBulkReanalyze={onBulkReanalyze}
onDeleteSelection={onDeleteSelection} onDeleteSelection={onDeleteSelection}
onClearSelection={onClearSelection}
folderOptions={folderOptions} folderOptions={folderOptions}
onMoveDocumentsToFolder={onMoveDocumentsToFolder} onMoveDocumentsToFolder={onMoveDocumentsToFolder}
/> />
@@ -11,6 +11,7 @@ import {
import SelectionAssignmentMenu, { SelectionAssignmentMenuItem } from './SelectionAssignmentMenu'; import SelectionAssignmentMenu, { SelectionAssignmentMenuItem } from './SelectionAssignmentMenu';
import SelectionSummary from './SelectionSummary'; import SelectionSummary from './SelectionSummary';
import { api, useAppState } from '../app/appState'; import { api, useAppState } from '../app/appState';
import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext';
const ROOT_FOLDER_LABEL = 'Documents'; const ROOT_FOLDER_LABEL = 'Documents';
@@ -64,7 +65,7 @@ interface BulkCorrespondentRemoveArgs {
documentIds: DocumentId[]; documentIds: DocumentId[];
} }
interface SelectionFloatingActionsProps { export interface SelectionFloatingActionsProps {
selectionCount?: number; selectionCount?: number;
selectedDocumentIds?: SelectedIdList; selectedDocumentIds?: SelectedIdList;
selectedFolderIds?: 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; export default SelectionFloatingActions;
@@ -1,30 +1,9 @@
import React, { ReactNode } from 'react'; import React, { ReactNode } from 'react';
import DocumentViewerPanel from '../../preview/DocumentViewerPanel'; import DocumentViewerPanel from '../../preview/DocumentViewerPanel';
import SelectionFloatingActions from '../SelectionFloatingActions';
import createWorkspaceSurfaceConfig from '../workspaceHeader'; import createWorkspaceSurfaceConfig from '../workspaceHeader';
import DocumentsPanel from './DocumentsPanel'; import DocumentsPanel from './DocumentsPanel';
import { SelectionFloatingPanel } from '../SelectionFloatingActions';
import { createDocumentsTableHeaderActions } from './DocumentsToolbar'; 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 { interface CreateDocumentsSurfaceArgs {
tableProps: Record<string, any>; tableProps: Record<string, any>;
@@ -52,7 +31,6 @@ const createDocumentsSurface = ({
onSortFieldChange, onSortFieldChange,
onSortDirectionToggle, onSortDirectionToggle,
onDeleteSelection, onDeleteSelection,
onClearSelection,
tags, tags,
correspondents, correspondents,
documentLookup, documentLookup,
@@ -88,7 +66,7 @@ const createDocumentsSurface = ({
}); });
const floatingActions = ( const floatingActions = (
<SelectionFloatingActionsWithSelection <SelectionFloatingPanel
documentLookup={documentLookup} documentLookup={documentLookup}
tags={tags} tags={tags}
tagLookupById={tagLookupById} tagLookupById={tagLookupById}
@@ -99,7 +77,6 @@ const createDocumentsSurface = ({
onBulkCorrespondentRemove={onBulkCorrespondentRemove} onBulkCorrespondentRemove={onBulkCorrespondentRemove}
onBulkReanalyze={onBulkReanalyze} onBulkReanalyze={onBulkReanalyze}
onDeleteSelection={onDeleteSelection} onDeleteSelection={onDeleteSelection}
onClearSelection={onClearSelection}
folderOptions={folderOptions} folderOptions={folderOptions}
onMoveDocumentsToFolder={onMoveDocumentsToFolder} onMoveDocumentsToFolder={onMoveDocumentsToFolder}
/> />