cleanup
This commit is contained in:
@@ -14,7 +14,7 @@ interface WorkspaceSelectionOptions {
|
|||||||
isDocumentRowKey?: (key: RowKey | SelectionEntry) => boolean;
|
isDocumentRowKey?: (key: RowKey | SelectionEntry) => boolean;
|
||||||
isFolderRowKey?: (key: RowKey | SelectionEntry) => boolean;
|
isFolderRowKey?: (key: RowKey | SelectionEntry) => boolean;
|
||||||
getRowId?: (key: RowKey | SelectionEntry) => string | number | null;
|
getRowId?: (key: RowKey | SelectionEntry) => string | number | null;
|
||||||
onInspectDocument?: (id: string | number) => void;
|
onDocumentActivate?: (id: string | number) => void;
|
||||||
onInspectFolder?: (id: string | number) => void;
|
onInspectFolder?: (id: string | number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ export const useWorkspaceSelection = ({
|
|||||||
isDocumentRowKey = () => false,
|
isDocumentRowKey = () => false,
|
||||||
isFolderRowKey = () => false,
|
isFolderRowKey = () => false,
|
||||||
getRowId = () => null,
|
getRowId = () => null,
|
||||||
onInspectDocument = identity,
|
onDocumentActivate = identity,
|
||||||
onInspectFolder = identity,
|
onInspectFolder = identity,
|
||||||
}: WorkspaceSelectionOptions = {}) => {
|
}: WorkspaceSelectionOptions = {}) => {
|
||||||
const selection = useDocumentSelection({
|
const selection = useDocumentSelection({
|
||||||
@@ -88,9 +88,9 @@ export const useWorkspaceSelection = ({
|
|||||||
const inspectDocument = useCallback(
|
const inspectDocument = useCallback(
|
||||||
(documentId?: string | number | null) => {
|
(documentId?: string | number | null) => {
|
||||||
if (!documentId) return;
|
if (!documentId) return;
|
||||||
onInspectDocument(documentId);
|
onDocumentActivate(documentId);
|
||||||
},
|
},
|
||||||
[onInspectDocument],
|
[onDocumentActivate],
|
||||||
);
|
);
|
||||||
|
|
||||||
const inspectFolder = useCallback(
|
const inspectFolder = useCallback(
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ interface DesktopDocumentCardProps {
|
|||||||
getDocumentAsset?: (...args: any[]) => unknown;
|
getDocumentAsset?: (...args: any[]) => unknown;
|
||||||
handleNavigatorSnapshot?: (...args: any[]) => void;
|
handleNavigatorSnapshot?: (...args: any[]) => void;
|
||||||
cardPointerHandlers?: React.HTMLAttributes<HTMLDivElement>;
|
cardPointerHandlers?: React.HTMLAttributes<HTMLDivElement>;
|
||||||
onInspectDocument?: (id: string | number) => void;
|
onDocumentActivate?: (id: string | number) => void;
|
||||||
onTagDragEnter?: (event: React.DragEvent<HTMLDivElement>, docId: string | number) => void;
|
onTagDragEnter?: (event: React.DragEvent<HTMLDivElement>, docId: string | number) => void;
|
||||||
onTagDragOver?: (event: React.DragEvent<HTMLDivElement>, docId: string | number) => void;
|
onTagDragOver?: (event: React.DragEvent<HTMLDivElement>, docId: string | number) => void;
|
||||||
onTagDragLeave?: (event: React.DragEvent<HTMLDivElement>, docId: string | number) => void;
|
onTagDragLeave?: (event: React.DragEvent<HTMLDivElement>, docId: string | number) => void;
|
||||||
@@ -57,7 +57,7 @@ const DesktopDocumentCard: React.FC<DesktopDocumentCardProps> = ({
|
|||||||
getDocumentAsset,
|
getDocumentAsset,
|
||||||
handleNavigatorSnapshot,
|
handleNavigatorSnapshot,
|
||||||
cardPointerHandlers,
|
cardPointerHandlers,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
onTagDragEnter,
|
onTagDragEnter,
|
||||||
onTagDragOver,
|
onTagDragOver,
|
||||||
onTagDragLeave,
|
onTagDragLeave,
|
||||||
@@ -117,7 +117,7 @@ const DesktopDocumentCard: React.FC<DesktopDocumentCardProps> = ({
|
|||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Enter' || event.key === ' ') {
|
if (event.key === 'Enter' || event.key === ' ') {
|
||||||
preventAll(event);
|
preventAll(event);
|
||||||
onInspectDocument?.(doc.id);
|
onDocumentActivate?.(doc.id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import usePreviewMetadata from './hooks/usePreviewMetadata';
|
|||||||
import '../styles/workspace/workspace-layout.css';
|
import '../styles/workspace/workspace-layout.css';
|
||||||
import '../styles/workspace/workspace-items.css';
|
import '../styles/workspace/workspace-items.css';
|
||||||
import '../styles/workspace/workspace-cards.css';
|
import '../styles/workspace/workspace-cards.css';
|
||||||
|
import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext';
|
||||||
|
|
||||||
type Identifier = string | number;
|
type Identifier = string | number;
|
||||||
|
|
||||||
@@ -118,17 +119,13 @@ type WorkspaceSnapshotState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface DesktopWorkspaceProps {
|
interface DesktopWorkspaceProps {
|
||||||
documents?: DeskDocument[];
|
entries?: DeskDocument[];
|
||||||
onInspectDocument?: (...args: unknown[]) => void;
|
onDocumentActivate?: (...args: unknown[]) => void;
|
||||||
onEntryPointer?: (...args: unknown[]) => void;
|
onDocumentClick?: (...args: unknown[]) => void;
|
||||||
onDocumentStackSelect?: (docIds: Identifier[]) => void;
|
onDocumentTagDrop?: (...args: unknown[]) => void;
|
||||||
onPromoteSelection?: (...args: unknown[]) => void;
|
|
||||||
onAssignTagToDocument?: (...args: unknown[]) => void;
|
|
||||||
ensureAssetUrl?: EnsureAssetUrl;
|
ensureAssetUrl?: EnsureAssetUrl;
|
||||||
getDocumentAsset?: GetAsset;
|
getDocumentAsset?: GetAsset;
|
||||||
activeTagIds?: Array<Identifier | null>;
|
activeTagFilters?: Array<Identifier | null>;
|
||||||
selectedDocumentIds?: Identifier[];
|
|
||||||
onClearSelection?: () => void;
|
|
||||||
tenantId?: Identifier | null;
|
tenantId?: Identifier | null;
|
||||||
viewId?: string | null;
|
viewId?: string | null;
|
||||||
}
|
}
|
||||||
@@ -167,12 +164,12 @@ interface DesktopWorkspaceViewProps {
|
|||||||
overlayOriginRect: DOMRect | null;
|
overlayOriginRect: DOMRect | null;
|
||||||
overlayOriginTransform: OverlayOriginTransform | null;
|
overlayOriginTransform: OverlayOriginTransform | null;
|
||||||
overlayDocument: DeskDocument | null;
|
overlayDocument: DeskDocument | null;
|
||||||
onEntryPointer?: DesktopWorkspaceProps['onEntryPointer'];
|
onDocumentClick?: DesktopWorkspaceProps['onDocumentClick'];
|
||||||
onDocumentStackSelect?: DesktopWorkspaceProps['onDocumentStackSelect'];
|
onDocumentStackSelect?: (docIds: Identifier[], event?: PointerEvent | MouseEvent | null) => void;
|
||||||
onPromoteSelection?: DesktopWorkspaceProps['onPromoteSelection'];
|
onPromoteSelection?: (docId: Identifier | null) => void;
|
||||||
selectedDocumentIds: Identifier[];
|
|
||||||
onClearSelection?: DesktopWorkspaceProps['onClearSelection'];
|
|
||||||
documentLookup: Map<string, DeskDocument>;
|
documentLookup: Map<string, DeskDocument>;
|
||||||
|
selectedDocumentIds: Identifier[];
|
||||||
|
onClearSelection: () => void;
|
||||||
resolveBaseMetrics: (doc: DeskDocument | null, cardWidth: number, cardHeight: number) => {
|
resolveBaseMetrics: (doc: DeskDocument | null, cardWidth: number, cardHeight: number) => {
|
||||||
baseWidth: number;
|
baseWidth: number;
|
||||||
baseHeight: number;
|
baseHeight: number;
|
||||||
@@ -184,7 +181,7 @@ interface DesktopWorkspaceViewProps {
|
|||||||
openOverlayForDoc: (docId: Identifier | null, originInfo?: OverlayOriginHint | null) => void;
|
openOverlayForDoc: (docId: Identifier | null, originInfo?: OverlayOriginHint | null) => void;
|
||||||
recalcVisibleDocIds: () => void;
|
recalcVisibleDocIds: () => void;
|
||||||
dragSettings: DragSettings;
|
dragSettings: DragSettings;
|
||||||
onInspectDocument?: DesktopWorkspaceProps['onInspectDocument'];
|
onDocumentActivate?: DesktopWorkspaceProps['onDocumentActivate'];
|
||||||
markLayoutDirty: () => void;
|
markLayoutDirty: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,23 +190,60 @@ const DEBUG_FOCUS = false;
|
|||||||
const defaultGetDocumentAsset: GetAsset = () => null;
|
const defaultGetDocumentAsset: GetAsset = () => null;
|
||||||
|
|
||||||
const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||||
documents = [],
|
entries = [],
|
||||||
onInspectDocument = null,
|
onDocumentActivate = null,
|
||||||
onEntryPointer = null,
|
onDocumentClick = null,
|
||||||
onDocumentStackSelect = null,
|
onDocumentTagDrop = null,
|
||||||
onPromoteSelection = null,
|
|
||||||
onAssignTagToDocument = null,
|
|
||||||
ensureAssetUrl = null,
|
ensureAssetUrl = null,
|
||||||
getDocumentAsset = defaultGetDocumentAsset,
|
getDocumentAsset = defaultGetDocumentAsset,
|
||||||
activeTagIds = [],
|
activeTagFilters = [],
|
||||||
selectedDocumentIds = [],
|
|
||||||
onClearSelection = null,
|
|
||||||
tenantId = null,
|
tenantId = null,
|
||||||
viewId = 'default',
|
viewId = 'default',
|
||||||
documentLinks,
|
documentLinks,
|
||||||
ensureDownloadUrl,
|
ensureDownloadUrl,
|
||||||
}) => {
|
}) => {
|
||||||
const items = useMemo<DeskDocument[]>(() => documents, [documents]);
|
const {
|
||||||
|
selectedDocumentIds,
|
||||||
|
clearSelection,
|
||||||
|
handleEntrySelection,
|
||||||
|
promoteSelectionOrder,
|
||||||
|
} = useWorkspaceSelectionContext();
|
||||||
|
const items = useMemo<DeskDocument[]>(
|
||||||
|
() => (Array.isArray(entries) ? entries.filter((doc): doc is DeskDocument => Boolean(doc)) : []),
|
||||||
|
[entries],
|
||||||
|
);
|
||||||
|
|
||||||
|
const getDocRowKey = useCallback((id: Identifier | null) => (id != null ? `document:${id}` : null), []);
|
||||||
|
|
||||||
|
const handleStackSelect = useCallback(
|
||||||
|
(docIds: Identifier[], event?: PointerEvent | MouseEvent | null) => {
|
||||||
|
if (!Array.isArray(docIds) || docIds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const syntheticEvent = event || ({
|
||||||
|
metaKey: true,
|
||||||
|
ctrlKey: true,
|
||||||
|
preventDefault: () => {},
|
||||||
|
} as unknown as PointerEvent);
|
||||||
|
docIds.forEach((id) => {
|
||||||
|
const key = getDocRowKey(id);
|
||||||
|
if (key) {
|
||||||
|
handleEntrySelection(key, syntheticEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[getDocRowKey, handleEntrySelection],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePromoteSelection = useCallback(
|
||||||
|
(docId: Identifier | null) => {
|
||||||
|
const key = getDocRowKey(docId);
|
||||||
|
if (key && promoteSelectionOrder) {
|
||||||
|
promoteSelectionOrder(key);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[getDocRowKey, promoteSelectionOrder],
|
||||||
|
);
|
||||||
|
|
||||||
const allowLayoutPersistence = Boolean(tenantId && viewId && viewId.startsWith('folder:'));
|
const allowLayoutPersistence = Boolean(tenantId && viewId && viewId.startsWith('folder:'));
|
||||||
const documentLinkMap = documentLinks instanceof Map ? documentLinks : null;
|
const documentLinkMap = documentLinks instanceof Map ? documentLinks : null;
|
||||||
@@ -380,17 +414,17 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
[applySnapshotDimensions],
|
[applySnapshotDimensions],
|
||||||
);
|
);
|
||||||
const activeTagSet = useMemo<Set<string>>(() => {
|
const activeTagSet = useMemo<Set<string>>(() => {
|
||||||
if (!Array.isArray(activeTagIds) || activeTagIds.length === 0) {
|
if (!Array.isArray(activeTagFilters) || activeTagFilters.length === 0) {
|
||||||
return new Set();
|
return new Set();
|
||||||
}
|
}
|
||||||
const set = new Set<string>();
|
const set = new Set<string>();
|
||||||
activeTagIds.forEach((id) => {
|
activeTagFilters.forEach((id) => {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
set.add(String(id));
|
set.add(String(id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return set;
|
return set;
|
||||||
}, [activeTagIds]);
|
}, [activeTagFilters]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
@@ -480,7 +514,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
|
|
||||||
const tagInteractions = useDeskTagInteractions({
|
const tagInteractions = useDeskTagInteractions({
|
||||||
engine,
|
engine,
|
||||||
onAssignTagToDocument,
|
onAssignTagToDocument: onDocumentTagDrop,
|
||||||
requestCanvasFocus,
|
requestCanvasFocus,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -782,11 +816,11 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
overlayOriginRect,
|
overlayOriginRect,
|
||||||
overlayOriginTransform,
|
overlayOriginTransform,
|
||||||
overlayDocument,
|
overlayDocument,
|
||||||
onEntryPointer,
|
onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect: handleStackSelect,
|
||||||
onPromoteSelection,
|
onPromoteSelection: handlePromoteSelection,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
onClearSelection,
|
onClearSelection: clearSelection,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
resolveBaseMetrics,
|
resolveBaseMetrics,
|
||||||
bringToFront,
|
bringToFront,
|
||||||
@@ -795,7 +829,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
openOverlayForDoc,
|
openOverlayForDoc,
|
||||||
recalcVisibleDocIds,
|
recalcVisibleDocIds,
|
||||||
dragSettings,
|
dragSettings,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
markLayoutDirty,
|
markLayoutDirty,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
@@ -827,10 +861,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
items,
|
items,
|
||||||
layoutRef,
|
layoutRef,
|
||||||
layoutSnapshot,
|
layoutSnapshot,
|
||||||
onClearSelection,
|
onDocumentClick,
|
||||||
onDocumentStackSelect,
|
|
||||||
onEntryPointer,
|
|
||||||
onPromoteSelection,
|
|
||||||
openOverlayForDoc,
|
openOverlayForDoc,
|
||||||
overlayDisplay,
|
overlayDisplay,
|
||||||
overlayOriginRect,
|
overlayOriginRect,
|
||||||
@@ -843,7 +874,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
resolveBaseMetrics,
|
resolveBaseMetrics,
|
||||||
setDraggingId,
|
setDraggingId,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
markLayoutDirty,
|
markLayoutDirty,
|
||||||
tagDropTargetId,
|
tagDropTargetId,
|
||||||
visibleDocIds,
|
visibleDocIds,
|
||||||
@@ -885,7 +916,7 @@ function DesktopWorkspaceView({
|
|||||||
overlayOriginRect,
|
overlayOriginRect,
|
||||||
overlayOriginTransform,
|
overlayOriginTransform,
|
||||||
overlayDocument,
|
overlayDocument,
|
||||||
onEntryPointer,
|
onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
onPromoteSelection,
|
onPromoteSelection,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
@@ -898,7 +929,7 @@ function DesktopWorkspaceView({
|
|||||||
openOverlayForDoc,
|
openOverlayForDoc,
|
||||||
recalcVisibleDocIds,
|
recalcVisibleDocIds,
|
||||||
dragSettings,
|
dragSettings,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
markLayoutDirty,
|
markLayoutDirty,
|
||||||
dragTransformsRef,
|
dragTransformsRef,
|
||||||
}: DesktopWorkspaceViewProps) {
|
}: DesktopWorkspaceViewProps) {
|
||||||
@@ -918,8 +949,7 @@ function DesktopWorkspaceView({
|
|||||||
recalcVisibleDocIds,
|
recalcVisibleDocIds,
|
||||||
settings: dragSettings,
|
settings: dragSettings,
|
||||||
containerRef,
|
containerRef,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
onDocumentStackSelect,
|
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
markLayoutDirty,
|
markLayoutDirty,
|
||||||
}) as {
|
}) as {
|
||||||
@@ -939,10 +969,10 @@ function DesktopWorkspaceView({
|
|||||||
handlePointerMove,
|
handlePointerMove,
|
||||||
handlePointerUp,
|
handlePointerUp,
|
||||||
handlePointerCancel,
|
handlePointerCancel,
|
||||||
onEntryPointer,
|
onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
onPromoteSelection,
|
onPromoteSelection,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
openOverlayForDoc,
|
openOverlayForDoc,
|
||||||
}) as {
|
}) as {
|
||||||
@@ -967,7 +997,7 @@ function DesktopWorkspaceView({
|
|||||||
<>
|
<>
|
||||||
<div className="desk-shell" onPointerDown={(event) => {
|
<div className="desk-shell" onPointerDown={(event) => {
|
||||||
if (event.target === event.currentTarget) {
|
if (event.target === event.currentTarget) {
|
||||||
onClearSelection?.();
|
onClearSelection();
|
||||||
}
|
}
|
||||||
focusShell();
|
focusShell();
|
||||||
}}
|
}}
|
||||||
@@ -982,7 +1012,7 @@ function DesktopWorkspaceView({
|
|||||||
onDrop={handleCanvasDrop}
|
onDrop={handleCanvasDrop}
|
||||||
onPointerDown={(event) => {
|
onPointerDown={(event) => {
|
||||||
if (event.target === event.currentTarget) {
|
if (event.target === event.currentTarget) {
|
||||||
onClearSelection?.();
|
onClearSelection();
|
||||||
}
|
}
|
||||||
focusShell();
|
focusShell();
|
||||||
}}
|
}}
|
||||||
@@ -1073,7 +1103,7 @@ function DesktopWorkspaceView({
|
|||||||
getDocumentAsset={getDocumentAsset}
|
getDocumentAsset={getDocumentAsset}
|
||||||
handleNavigatorSnapshot={handleNavigatorSnapshot}
|
handleNavigatorSnapshot={handleNavigatorSnapshot}
|
||||||
cardPointerHandlers={cardPointerHandlers}
|
cardPointerHandlers={cardPointerHandlers}
|
||||||
onInspectDocument={onInspectDocument}
|
onDocumentActivate={onDocumentActivate}
|
||||||
onTagDragEnter={handleTagDragEnterDoc}
|
onTagDragEnter={handleTagDragEnterDoc}
|
||||||
onTagDragOver={handleTagDragOverDoc}
|
onTagDragOver={handleTagDragOverDoc}
|
||||||
onTagDragLeave={handleTagDragLeaveDoc}
|
onTagDragLeave={handleTagDragLeaveDoc}
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ export const useDeskPointer = ({
|
|||||||
handlePointerMove,
|
handlePointerMove,
|
||||||
handlePointerUp,
|
handlePointerUp,
|
||||||
handlePointerCancel,
|
handlePointerCancel,
|
||||||
onEntryPointer,
|
onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
onPromoteSelection,
|
onPromoteSelection,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
openOverlayForDoc = null,
|
openOverlayForDoc = null,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -249,7 +249,7 @@ export const useDeskPointer = ({
|
|||||||
applyClickPlanImmediately({
|
applyClickPlanImmediately({
|
||||||
intent,
|
intent,
|
||||||
event,
|
event,
|
||||||
onEntryPointer,
|
onEntryPointer: onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ export const useDeskPointer = ({
|
|||||||
[
|
[
|
||||||
handlePointerDown,
|
handlePointerDown,
|
||||||
onPromoteSelection,
|
onPromoteSelection,
|
||||||
onEntryPointer,
|
onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
resolveStackDocIds,
|
resolveStackDocIds,
|
||||||
resetLongPressState,
|
resetLongPressState,
|
||||||
@@ -308,7 +308,7 @@ export const useDeskPointer = ({
|
|||||||
finalizeClickSelection({
|
finalizeClickSelection({
|
||||||
intent: pointerState,
|
intent: pointerState,
|
||||||
event,
|
event,
|
||||||
onEntryPointer,
|
onEntryPointer: onDocumentClick,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ export const useDeskPointer = ({
|
|||||||
const stillSelected = Array.isArray(selectedDocumentIds)
|
const stillSelected = Array.isArray(selectedDocumentIds)
|
||||||
&& selectedDocumentIds.includes(doc.id);
|
&& selectedDocumentIds.includes(doc.id);
|
||||||
if (isPrimaryRelease && stillSelected) {
|
if (isPrimaryRelease && stillSelected) {
|
||||||
safeInvoke(onInspectDocument, doc.id);
|
safeInvoke(onDocumentActivate, doc.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,9 +335,9 @@ export const useDeskPointer = ({
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
handlePointerUp,
|
handlePointerUp,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
onEntryPointer,
|
onDocumentClick,
|
||||||
resetLongPressState,
|
resetLongPressState,
|
||||||
selectedDocumentIds,
|
selectedDocumentIds,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ interface UseDocumentDragOptions {
|
|||||||
recalcVisibleDocIds: () => void;
|
recalcVisibleDocIds: () => void;
|
||||||
settings?: DragSettings;
|
settings?: DragSettings;
|
||||||
containerRef?: RefObject<HTMLElement>;
|
containerRef?: RefObject<HTMLElement>;
|
||||||
onInspectDocument?: (docId: Identifier | null, event?: PointerEvent | ReactPointerEvent) => void;
|
onDocumentActivate?: (docId: Identifier | null, event?: PointerEvent | ReactPointerEvent) => void;
|
||||||
onDocumentStackSelect?: (
|
onDocumentStackSelect?: (
|
||||||
docIds: Identifier[],
|
docIds: Identifier[],
|
||||||
event: PointerEvent | ReactPointerEvent,
|
event: PointerEvent | ReactPointerEvent,
|
||||||
@@ -212,7 +212,7 @@ const useDocumentDrag = (options: UseDocumentDragOptions) => {
|
|||||||
recalcVisibleDocIds,
|
recalcVisibleDocIds,
|
||||||
settings,
|
settings,
|
||||||
containerRef: providedContainerRef,
|
containerRef: providedContainerRef,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
onDocumentStackSelect,
|
onDocumentStackSelect,
|
||||||
selectedDocumentIds = [],
|
selectedDocumentIds = [],
|
||||||
markLayoutDirty,
|
markLayoutDirty,
|
||||||
@@ -246,7 +246,7 @@ const useDocumentDrag = (options: UseDocumentDragOptions) => {
|
|||||||
openOverlayForDoc?.(data.docId, data.originInfo);
|
openOverlayForDoc?.(data.docId, data.originInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onInspectDocument?.(data.docId, event);
|
onDocumentActivate?.(data.docId, event);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const dragStateRef = useRef<DragStateInternal | null>(null);
|
const dragStateRef = useRef<DragStateInternal | null>(null);
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ export type DocumentEventHandler = (document: DocumentLike, event: MouseEvent<HT
|
|||||||
|
|
||||||
export interface DocumentsListProps {
|
export interface DocumentsListProps {
|
||||||
entries: DocumentsListEntry[];
|
entries: DocumentsListEntry[];
|
||||||
focusedRowKey?: string | null;
|
|
||||||
draggingDocumentIdsSet?: Set<Identifier> | null;
|
draggingDocumentIdsSet?: Set<Identifier> | null;
|
||||||
draggedFolderId?: Identifier | 'root' | null;
|
draggedFolderId?: Identifier | 'root' | null;
|
||||||
ensureAssetUrl?: (...args: any[]) => unknown;
|
ensureAssetUrl?: (...args: any[]) => unknown;
|
||||||
@@ -91,7 +90,6 @@ export interface DocumentsListProps {
|
|||||||
|
|
||||||
const DocumentsList: React.FC<DocumentsListProps> = ({
|
const DocumentsList: React.FC<DocumentsListProps> = ({
|
||||||
entries,
|
entries,
|
||||||
focusedRowKey,
|
|
||||||
draggingDocumentIdsSet,
|
draggingDocumentIdsSet,
|
||||||
draggedFolderId,
|
draggedFolderId,
|
||||||
ensureAssetUrl,
|
ensureAssetUrl,
|
||||||
@@ -185,7 +183,6 @@ const DocumentsList: React.FC<DocumentsListProps> = ({
|
|||||||
const canDragFolder = folder.id !== 'root';
|
const canDragFolder = folder.id !== 'root';
|
||||||
const isDraggingFolder = draggedFolderId === folder.id;
|
const isDraggingFolder = draggedFolderId === folder.id;
|
||||||
const isSelectedFolder = selectedFolderIdsSet?.has(folder.id);
|
const isSelectedFolder = selectedFolderIdsSet?.has(folder.id);
|
||||||
const rowKey = `folder:${folder.id}`;
|
|
||||||
const canRenameFolder = Boolean(onFolderRename) && folder.id !== 'root';
|
const canRenameFolder = Boolean(onFolderRename) && folder.id !== 'root';
|
||||||
const isFolderEditing = editingFolderId === folder.id;
|
const isFolderEditing = editingFolderId === folder.id;
|
||||||
const folderDraftValue = isFolderEditing ? folderDraft : folder.name;
|
const folderDraftValue = isFolderEditing ? folderDraft : folder.name;
|
||||||
@@ -198,9 +195,7 @@ const DocumentsList: React.FC<DocumentsListProps> = ({
|
|||||||
return (
|
return (
|
||||||
<tr
|
<tr
|
||||||
key={entry.key}
|
key={entry.key}
|
||||||
className={`folder${isDraggingFolder ? ' is-dragging' : ''}${
|
className={`folder${isDraggingFolder ? ' is-dragging' : ''}${isSelectedFolder ? ' selected' : ''}`}
|
||||||
focusedRowKey === rowKey ? ' focused' : ''
|
|
||||||
}${isSelectedFolder ? ' selected' : ''}`}
|
|
||||||
id={`folder-row-${folder.id}`}
|
id={`folder-row-${folder.id}`}
|
||||||
onClick={(event) => onFolderClick?.(folder, event)}
|
onClick={(event) => onFolderClick?.(folder, event)}
|
||||||
onDoubleClick={(event) => {
|
onDoubleClick={(event) => {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export interface UseDocumentsPanelPropsArgs {
|
|||||||
clearDocumentSelection?: () => void;
|
clearDocumentSelection?: () => void;
|
||||||
handleDeleteSelection?: () => void;
|
handleDeleteSelection?: () => void;
|
||||||
handleEntryPointerCore?: (...args: unknown[]) => void;
|
handleEntryPointerCore?: (...args: unknown[]) => void;
|
||||||
inspectDocument?: (docId: Identifier | null, metadata?: unknown) => void;
|
onDocumentActivate?: (docId: Identifier | null, metadata?: unknown) => void;
|
||||||
tags?: unknown[];
|
tags?: unknown[];
|
||||||
correspondents?: unknown[];
|
correspondents?: unknown[];
|
||||||
documentLookup?: unknown;
|
documentLookup?: unknown;
|
||||||
@@ -107,7 +107,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
handleDocumentsViewModeChange,
|
handleDocumentsViewModeChange,
|
||||||
handleDeleteSelection,
|
handleDeleteSelection,
|
||||||
handleEntryPointerCore,
|
handleEntryPointerCore,
|
||||||
inspectDocument,
|
onDocumentActivate,
|
||||||
tags,
|
tags,
|
||||||
correspondents,
|
correspondents,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
@@ -159,7 +159,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
onViewModeChange: handleDocumentsViewModeChange,
|
onViewModeChange: handleDocumentsViewModeChange,
|
||||||
onDeleteSelection: handleDeleteSelection,
|
onDeleteSelection: handleDeleteSelection,
|
||||||
onEntryPointer: handleEntryPointerCore,
|
onEntryPointer: handleEntryPointerCore,
|
||||||
onInspectDocument: inspectDocument,
|
onDocumentActivate,
|
||||||
tags,
|
tags,
|
||||||
correspondents,
|
correspondents,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
@@ -206,7 +206,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
handleFolderDragEnd,
|
handleFolderDragEnd,
|
||||||
handleFolderDragStart,
|
handleFolderDragStart,
|
||||||
handleFolderRename,
|
handleFolderRename,
|
||||||
inspectDocument,
|
onDocumentActivate,
|
||||||
moveDocumentsToFolder,
|
moveDocumentsToFolder,
|
||||||
openDocumentPreview,
|
openDocumentPreview,
|
||||||
refreshCurrentFolder,
|
refreshCurrentFolder,
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
onDocumentDragEnd,
|
onDocumentDragEnd,
|
||||||
onDocumentRename,
|
onDocumentRename,
|
||||||
onEntryPointer = null,
|
onEntryPointer = null,
|
||||||
onInspectDocument = null,
|
onDocumentActivate = null,
|
||||||
tagLookupById,
|
tagLookupById,
|
||||||
activeCorrespondentIds = [],
|
activeCorrespondentIds = [],
|
||||||
ensureAssetUrl = null,
|
ensureAssetUrl = null,
|
||||||
@@ -368,9 +368,9 @@ type ZoomSource = { url: string; alt?: string | null; mimeType?: string | null }
|
|||||||
handleDocumentPreviewZoom(doc);
|
handleDocumentPreviewZoom(doc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onInspectDocument?.(doc.id);
|
onDocumentActivate?.(doc.id);
|
||||||
},
|
},
|
||||||
[handleDocumentPreviewZoom, onInspectDocument],
|
[handleDocumentPreviewZoom, onDocumentActivate],
|
||||||
);
|
);
|
||||||
|
|
||||||
const navigableRows = useMemo(
|
const navigableRows = useMemo(
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ interface UseEntryPointerOptions {
|
|||||||
resolveDocumentRowKey?: (id: string | number) => string | null;
|
resolveDocumentRowKey?: (id: string | number) => string | null;
|
||||||
resolveFolderRowKey?: (id: string | number) => string | null;
|
resolveFolderRowKey?: (id: string | number) => string | null;
|
||||||
onSelectEntry?: (entry: WorkspaceEntry, event?: PointerEventLike | null, metadata?: EntryPointerMetadata) => void;
|
onSelectEntry?: (entry: WorkspaceEntry, event?: PointerEventLike | null, metadata?: EntryPointerMetadata) => void;
|
||||||
onInspectDocument?: (id: string | number, metadata?: EntryPointerMetadata) => void;
|
onDocumentActivate?: (id: string | number, metadata?: EntryPointerMetadata) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntryPointerMetadata {
|
export interface EntryPointerMetadata {
|
||||||
@@ -44,7 +44,7 @@ export const useEntryPointer = ({
|
|||||||
resolveDocumentRowKey,
|
resolveDocumentRowKey,
|
||||||
resolveFolderRowKey,
|
resolveFolderRowKey,
|
||||||
onSelectEntry,
|
onSelectEntry,
|
||||||
onInspectDocument,
|
onDocumentActivate,
|
||||||
}: UseEntryPointerOptions) =>
|
}: UseEntryPointerOptions) =>
|
||||||
useCallback(
|
useCallback(
|
||||||
(entry?: WorkspaceEntry | null, event?: PointerEventLike | null) => {
|
(entry?: WorkspaceEntry | null, event?: PointerEventLike | null) => {
|
||||||
@@ -70,10 +70,10 @@ export const useEntryPointer = ({
|
|||||||
onSelectEntry?.(entry, event, metadata);
|
onSelectEntry?.(entry, event, metadata);
|
||||||
|
|
||||||
if (type === 'document' && !modifierClick && primaryClick) {
|
if (type === 'document' && !modifierClick && primaryClick) {
|
||||||
onInspectDocument?.(id, metadata);
|
onDocumentActivate?.(id, metadata);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[resolveDocumentRowKey, resolveFolderRowKey, onSelectEntry, onInspectDocument],
|
[resolveDocumentRowKey, resolveFolderRowKey, onSelectEntry, onDocumentActivate],
|
||||||
);
|
);
|
||||||
|
|
||||||
export default useEntryPointer;
|
export default useEntryPointer;
|
||||||
|
|||||||
@@ -1420,17 +1420,15 @@ const useDocumentsWorkspace = ({
|
|||||||
|
|
||||||
const deskWorkspaceProps = useMemo(
|
const deskWorkspaceProps = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
documents: viewDocuments,
|
entries: viewDocuments,
|
||||||
onInspectDocument: inspectDocumentForDesk,
|
onDocumentActivate: inspectDocumentForDesk,
|
||||||
onEntryPointer: handleEntryPointerCore,
|
onDocumentClick: handleEntryPointerCore,
|
||||||
onDocumentStackSelect: handleDeskDocumentStackSelect,
|
onDocumentStackSelect: handleDeskDocumentStackSelect,
|
||||||
onPromoteSelection: promoteSelectionOrder,
|
onPromoteSelection: promoteSelectionOrder,
|
||||||
onAssignTagToDocument: handleDocumentTagDrop,
|
onDocumentTagDrop: handleDocumentTagDrop,
|
||||||
ensureAssetUrl,
|
ensureAssetUrl,
|
||||||
getDocumentAsset,
|
getDocumentAsset,
|
||||||
activeTagIds: activeTagFilters,
|
activeTagFilters,
|
||||||
selectedDocumentIds,
|
|
||||||
onClearSelection: clearDocumentSelection,
|
|
||||||
tenantId: currentTenantId,
|
tenantId: currentTenantId,
|
||||||
viewId: deskViewId,
|
viewId: deskViewId,
|
||||||
documentLinks,
|
documentLinks,
|
||||||
@@ -1446,8 +1444,6 @@ const useDocumentsWorkspace = ({
|
|||||||
ensureAssetUrl,
|
ensureAssetUrl,
|
||||||
getDocumentAsset,
|
getDocumentAsset,
|
||||||
activeTagFilters,
|
activeTagFilters,
|
||||||
selectedDocumentIds,
|
|
||||||
clearDocumentSelection,
|
|
||||||
currentTenantId,
|
currentTenantId,
|
||||||
deskViewId,
|
deskViewId,
|
||||||
documentLinks,
|
documentLinks,
|
||||||
@@ -1487,7 +1483,7 @@ const useDocumentsWorkspace = ({
|
|||||||
clearDocumentSelection,
|
clearDocumentSelection,
|
||||||
handleDeleteSelection,
|
handleDeleteSelection,
|
||||||
handleEntryPointerCore,
|
handleEntryPointerCore,
|
||||||
inspectDocument,
|
onDocumentActivate: inspectDocument,
|
||||||
tags,
|
tags,
|
||||||
correspondents,
|
correspondents,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
|
|||||||
Reference in New Issue
Block a user