feat: Implement tag drag-and-drop functionality
This commit is contained in:
@@ -2,9 +2,11 @@ import React from 'react';
|
|||||||
import type { DocumentViewLogic } from '../logic/useDocumentViewLogic';
|
import type { DocumentViewLogic } from '../logic/useDocumentViewLogic';
|
||||||
import { useDocumentItemLogic } from '../logic/useDocumentItemLogic';
|
import { useDocumentItemLogic } from '../logic/useDocumentItemLogic';
|
||||||
import EntryShell from './EntryShell';
|
import EntryShell from './EntryShell';
|
||||||
|
import type { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
|
|
||||||
interface DocumentEntryProps {
|
interface DocumentEntryProps {
|
||||||
doc: any;
|
doc: any;
|
||||||
|
tagDragHandlers?: TagDragHandlers;
|
||||||
viewLogic: DocumentViewLogic;
|
viewLogic: DocumentViewLogic;
|
||||||
component: React.ElementType;
|
component: React.ElementType;
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -13,8 +15,8 @@ interface DocumentEntryProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DocumentEntry: React.FC<DocumentEntryProps> = (props) => {
|
const DocumentEntry: React.FC<DocumentEntryProps> = (props) => {
|
||||||
const { doc, component, className, role, children, viewLogic } = props;
|
const { doc, tagDragHandlers, component, className, role, children, viewLogic } = props;
|
||||||
const logic = useDocumentItemLogic({ doc, viewLogic });
|
const logic = useDocumentItemLogic({ doc, tagDragHandlers, viewLogic });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EntryShell
|
<EntryShell
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { getTagColorStyle } from '../../utils/colors';
|
import { getTagColorStyle } from '../../utils/colors';
|
||||||
import type { DocumentTag } from '../../types/documents';
|
import type { Document, DocumentTag } from '../../types/documents';
|
||||||
import type { Identifier } from '../../types/identifiers';
|
import type { Identifier } from '../../types/identifiers';
|
||||||
|
import type { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
|
|
||||||
interface DocumentTagsProps {
|
interface DocumentTagsProps {
|
||||||
tags: DocumentTag[];
|
tags: DocumentTag[];
|
||||||
tagLookupById?: Map<Identifier, DocumentTag> | null;
|
tagLookupById?: Map<Identifier, DocumentTag> | null;
|
||||||
onTagClick?: (tagId: Identifier) => void;
|
onTagClick?: (tagId: Identifier) => void;
|
||||||
docId: Identifier;
|
doc: Document;
|
||||||
onTagDragStart?: (event: React.DragEvent<HTMLElement>, tag: DocumentTag) => void;
|
tagDragHandlers?: TagDragHandlers;
|
||||||
onTagDragEnd?: (event: React.DragEvent<HTMLElement>) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentTags: React.FC<DocumentTagsProps> = ({
|
const DocumentTags: React.FC<DocumentTagsProps> = ({
|
||||||
tags,
|
tags,
|
||||||
tagLookupById,
|
tagLookupById,
|
||||||
onTagClick,
|
onTagClick,
|
||||||
docId,
|
doc,
|
||||||
onTagDragStart,
|
tagDragHandlers,
|
||||||
onTagDragEnd,
|
|
||||||
}) => {
|
}) => {
|
||||||
const sortedTags = useMemo(() => {
|
const sortedTags = useMemo(() => {
|
||||||
return [...tags].sort((a, b) => {
|
return [...tags].sort((a, b) => {
|
||||||
@@ -39,7 +38,7 @@ const DocumentTags: React.FC<DocumentTagsProps> = ({
|
|||||||
const style = getTagColorStyle(colorSource);
|
const style = getTagColorStyle(colorSource);
|
||||||
const tagId = tag?.id ?? null;
|
const tagId = tag?.id ?? null;
|
||||||
const clickable = tagId != null && typeof onTagClick === 'function';
|
const clickable = tagId != null && typeof onTagClick === 'function';
|
||||||
const key = tagId ?? `${docId}-tag-${index}`;
|
const key = tagId ?? `${doc.id}-tag-${index}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
@@ -53,17 +52,9 @@ const DocumentTags: React.FC<DocumentTagsProps> = ({
|
|||||||
if (tagId == null) return;
|
if (tagId == null) return;
|
||||||
onTagClick?.(tagId);
|
onTagClick?.(tagId);
|
||||||
} : undefined}
|
} : undefined}
|
||||||
draggable
|
draggable={!!tagId}
|
||||||
onDragStart={(event) => {
|
onDragStart={(event) => tagId && tagDragHandlers?.onTagDragStart(event, doc, tag)}
|
||||||
// Let the hook handle the data transfer and UI
|
onDragEnd={tagDragHandlers?.onTagDragEnd}
|
||||||
if (tagId && onTagDragStart) {
|
|
||||||
onTagDragStart(event, tag);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onDragEnd={(event) => {
|
|
||||||
// Let the hook handle the cleanup and logic
|
|
||||||
onTagDragEnd?.(event);
|
|
||||||
}}
|
|
||||||
onKeyDown={clickable ? (event) => {
|
onKeyDown={clickable ? (event) => {
|
||||||
if (event.key === 'Enter' || event.key === ' ') {
|
if (event.key === 'Enter' || event.key === ' ') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
@@ -12,20 +12,22 @@ import EntryCorrespondents from './EntryCorrespondents';
|
|||||||
import EntryTags from './EntryTags';
|
import EntryTags from './EntryTags';
|
||||||
import FolderEntry from './FolderEntry';
|
import FolderEntry from './FolderEntry';
|
||||||
import DocumentEntry from './DocumentEntry';
|
import DocumentEntry from './DocumentEntry';
|
||||||
|
import { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
|
|
||||||
interface DocumentsGridCardProps {
|
interface DocumentsGridCardProps {
|
||||||
entry: DocumentsListEntry;
|
entry: DocumentsListEntry;
|
||||||
viewLogic: DocumentViewLogic;
|
viewLogic: DocumentViewLogic;
|
||||||
iconSize?: number;
|
iconSize?: number;
|
||||||
|
tagDragHandlers?: TagDragHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentsGridCard: React.FC<DocumentsGridCardProps> = (props) => {
|
const DocumentsGridCard: React.FC<DocumentsGridCardProps> = (props) => {
|
||||||
const { entry, iconSize } = props;
|
const { entry, iconSize, tagDragHandlers } = props;
|
||||||
const { ensureAssetUrl, getDocumentAsset } = useDocumentsAssetContext();
|
const { ensureAssetUrl, getDocumentAsset } = useDocumentsAssetContext();
|
||||||
const { scrollRef, activeCorrespondentIdSet, tagLookupById } = useDocumentsViewStateContext();
|
const { scrollRef, activeCorrespondentIdSet, tagLookupById } = useDocumentsViewStateContext();
|
||||||
const {
|
const {
|
||||||
correspondents: { onClick: onCorrespondentClick },
|
correspondents: { onClick: onCorrespondentClick },
|
||||||
tags: { onClick: onTagClick, onDetach: onDocumentTagDetach }
|
tags: { onClick: onTagClick }
|
||||||
} = useDocumentsCommandContext();
|
} = useDocumentsCommandContext();
|
||||||
|
|
||||||
if (entry.type === 'folder') {
|
if (entry.type === 'folder') {
|
||||||
@@ -78,6 +80,7 @@ const DocumentsGridCard: React.FC<DocumentsGridCardProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<DocumentEntry
|
<DocumentEntry
|
||||||
doc={doc}
|
doc={doc}
|
||||||
|
tagDragHandlers={tagDragHandlers}
|
||||||
viewLogic={props.viewLogic}
|
viewLogic={props.viewLogic}
|
||||||
component="div"
|
component="div"
|
||||||
className="document-card document"
|
className="document-card document"
|
||||||
@@ -123,10 +126,8 @@ const DocumentsGridCard: React.FC<DocumentsGridCardProps> = (props) => {
|
|||||||
tags={doc.tags || []}
|
tags={doc.tags || []}
|
||||||
tagLookupById={tagLookupById}
|
tagLookupById={tagLookupById}
|
||||||
onTagClick={onTagClick}
|
onTagClick={onTagClick}
|
||||||
docId={doc.id}
|
doc={doc}
|
||||||
onDocumentTagDetach={onDocumentTagDetach}
|
tagDragHandlers={logic.handlers.tagDragHandlers}
|
||||||
onTagDragStart={logic.handlers.onTagDragStart}
|
|
||||||
onTagDragEnd={logic.handlers.onTagDragEnd}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,19 +14,22 @@ import EntryTags from './EntryTags';
|
|||||||
import FolderEntry from './FolderEntry';
|
import FolderEntry from './FolderEntry';
|
||||||
import DocumentEntry from './DocumentEntry';
|
import DocumentEntry from './DocumentEntry';
|
||||||
|
|
||||||
|
import { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
|
|
||||||
interface DocumentsListRowProps {
|
interface DocumentsListRowProps {
|
||||||
entry: DocumentsListEntry;
|
entry: DocumentsListEntry;
|
||||||
viewLogic: DocumentViewLogic;
|
viewLogic: DocumentViewLogic;
|
||||||
iconSize?: number;
|
iconSize?: number;
|
||||||
|
tagDragHandlers?: TagDragHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentsListRow: React.FC<DocumentsListRowProps> = (props) => {
|
const DocumentsListRow: React.FC<DocumentsListRowProps> = (props) => {
|
||||||
const { entry, iconSize } = props;
|
const { entry, iconSize, tagDragHandlers } = props;
|
||||||
const { ensureAssetUrl, getDocumentAsset } = useDocumentsAssetContext();
|
const { ensureAssetUrl, getDocumentAsset } = useDocumentsAssetContext();
|
||||||
const { scrollRef, activeCorrespondentIdSet, tagLookupById } = useDocumentsViewStateContext();
|
const { scrollRef, activeCorrespondentIdSet, tagLookupById } = useDocumentsViewStateContext();
|
||||||
const {
|
const {
|
||||||
correspondents: { onClick: onCorrespondentClick },
|
correspondents: { onClick: onCorrespondentClick },
|
||||||
tags: { onClick: onTagClick, onDetach: onDocumentTagDetach }
|
tags: { onClick: onTagClick }
|
||||||
} = useDocumentsCommandContext();
|
} = useDocumentsCommandContext();
|
||||||
|
|
||||||
if (entry.type === 'folder') {
|
if (entry.type === 'folder') {
|
||||||
@@ -88,6 +91,7 @@ const DocumentsListRow: React.FC<DocumentsListRowProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<DocumentEntry
|
<DocumentEntry
|
||||||
doc={doc}
|
doc={doc}
|
||||||
|
tagDragHandlers={tagDragHandlers}
|
||||||
viewLogic={props.viewLogic}
|
viewLogic={props.viewLogic}
|
||||||
component="tr"
|
component="tr"
|
||||||
className="document"
|
className="document"
|
||||||
@@ -137,10 +141,8 @@ const DocumentsListRow: React.FC<DocumentsListRowProps> = (props) => {
|
|||||||
tags={doc.tags || []}
|
tags={doc.tags || []}
|
||||||
tagLookupById={tagLookupById}
|
tagLookupById={tagLookupById}
|
||||||
onTagClick={onTagClick}
|
onTagClick={onTagClick}
|
||||||
docId={doc.id}
|
doc={doc}
|
||||||
onDocumentTagDetach={onDocumentTagDetach}
|
tagDragHandlers={logic.handlers.tagDragHandlers}
|
||||||
onTagDragStart={logic.handlers.onTagDragStart}
|
|
||||||
onTagDragEnd={logic.handlers.onTagDragEnd}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import DocumentTags from './DocumentTags';
|
import DocumentTags from './DocumentTags';
|
||||||
|
import type { Document, DocumentTag } from '../../types/documents';
|
||||||
|
import type { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
import type { Identifier } from '../../types/identifiers';
|
import type { Identifier } from '../../types/identifiers';
|
||||||
import type { DocumentTag } from '../../types/documents';
|
|
||||||
|
|
||||||
interface EntryTagsProps {
|
interface EntryTagsProps {
|
||||||
tags: DocumentTag[];
|
tags: DocumentTag[];
|
||||||
tagLookupById?: Map<Identifier, DocumentTag> | null;
|
tagLookupById?: Map<Identifier, DocumentTag> | null;
|
||||||
onTagClick?: (tagId: Identifier) => void;
|
onTagClick?: (tagId: Identifier) => void;
|
||||||
docId: Identifier;
|
doc: Document;
|
||||||
onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void;
|
tagDragHandlers?: TagDragHandlers;
|
||||||
onTagDragStart?: (event: React.DragEvent<HTMLElement>, tag: DocumentTag) => void;
|
|
||||||
onTagDragEnd?: (event: React.DragEvent<HTMLElement>) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const EntryTags: React.FC<EntryTagsProps> = (props) => {
|
const EntryTags: React.FC<EntryTagsProps> = (props) => {
|
||||||
@@ -23,10 +22,8 @@ const EntryTags: React.FC<EntryTagsProps> = (props) => {
|
|||||||
tags={props.tags}
|
tags={props.tags}
|
||||||
tagLookupById={props.tagLookupById}
|
tagLookupById={props.tagLookupById}
|
||||||
onTagClick={props.onTagClick}
|
onTagClick={props.onTagClick}
|
||||||
docId={props.docId}
|
doc={props.doc}
|
||||||
onDocumentTagDetach={props.onDocumentTagDetach}
|
tagDragHandlers={props.tagDragHandlers}
|
||||||
onTagDragStart={props.onTagDragStart}
|
|
||||||
onTagDragEnd={props.onTagDragEnd}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,13 +23,6 @@ interface DocumentsCommandContextValue {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
tags: {
|
tags: {
|
||||||
onDrag: {
|
|
||||||
start?: (event: DragEvent<HTMLElement>, doc: Document, tag: any) => void;
|
|
||||||
end?: (event: DragEvent<HTMLElement>) => void;
|
|
||||||
over?: (event: DragEvent<HTMLElement>, doc: Document) => void;
|
|
||||||
drop?: (event: DragEvent<HTMLElement>, doc: Document) => void;
|
|
||||||
leave?: (event: DragEvent<HTMLElement>, doc: Document) => void;
|
|
||||||
};
|
|
||||||
onAttach?: (documentId: Identifier, tagId: Identifier) => void;
|
onAttach?: (documentId: Identifier, tagId: Identifier) => void;
|
||||||
onDetach?: (documentId: Identifier, tagId: Identifier) => void;
|
onDetach?: (documentId: Identifier, tagId: Identifier) => void;
|
||||||
onClick?: (tagId: Identifier) => void;
|
onClick?: (tagId: Identifier) => void;
|
||||||
@@ -44,7 +37,7 @@ interface DocumentsCommandContextValue {
|
|||||||
export const DocumentsCommandContext = createContext<DocumentsCommandContextValue>({
|
export const DocumentsCommandContext = createContext<DocumentsCommandContextValue>({
|
||||||
folder: { onDrag: {} },
|
folder: { onDrag: {} },
|
||||||
document: { onDrag: {} },
|
document: { onDrag: {} },
|
||||||
tags: { onDrag: {} },
|
tags: {},
|
||||||
correspondents: {},
|
correspondents: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
import React, { type DragEvent } from 'react';
|
import React, { type DragEvent } from 'react';
|
||||||
import { createDocumentEntryKey } from '../../app/entryKey';
|
import { createDocumentEntryKey } from '../../app/entryKey';
|
||||||
import { useDocumentOpen } from '../../lib/context/DocumentOpenContext';
|
import { useDocumentOpen } from '../../lib/context/DocumentOpenContext';
|
||||||
import type { Document, DocumentTag } from '../../types/documents';
|
import type { Document } from '../../types/documents';
|
||||||
import { useDocumentsCommandContext } from '../context/DocumentsCommandContext';
|
import { useDocumentsCommandContext } from '../context/DocumentsCommandContext';
|
||||||
import { useDocumentsViewStateContext } from '../context/DocumentsViewStateContext';
|
import { useDocumentsViewStateContext } from '../context/DocumentsViewStateContext';
|
||||||
import type { DocumentViewLogic } from './useDocumentViewLogic';
|
import type { DocumentViewLogic } from './useDocumentViewLogic';
|
||||||
|
|
||||||
interface UseDocumentItemLogicProps {
|
import { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
|
|
||||||
|
interface UseDocumentItemLogicArgs {
|
||||||
doc: Document;
|
doc: Document;
|
||||||
viewLogic: DocumentViewLogic;
|
tagDragHandlers?: TagDragHandlers;
|
||||||
|
viewLogic: DocumentViewLogic; // Retained from original props
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDocumentItemLogic = (props: UseDocumentItemLogicProps) => {
|
export const useDocumentItemLogic = ({ doc, tagDragHandlers, viewLogic }: UseDocumentItemLogicArgs) => {
|
||||||
const { doc, viewLogic } = props;
|
|
||||||
const {
|
const {
|
||||||
draggingDocumentIdsSet
|
draggingDocumentIdsSet
|
||||||
} = useDocumentsViewStateContext();
|
} = useDocumentsViewStateContext();
|
||||||
@@ -22,15 +24,6 @@ export const useDocumentItemLogic = (props: UseDocumentItemLogicProps) => {
|
|||||||
onDrag: { start: onDocumentDragStart, end: onDocumentDragEnd },
|
onDrag: { start: onDocumentDragStart, end: onDocumentDragEnd },
|
||||||
onRename: onDocumentRename
|
onRename: onDocumentRename
|
||||||
},
|
},
|
||||||
tags: {
|
|
||||||
onDrag: {
|
|
||||||
start: onDocumentTagDragStart,
|
|
||||||
end: onDocumentTagDragEnd,
|
|
||||||
over: onDocumentTagDragOver,
|
|
||||||
leave: onDocumentTagDragLeave,
|
|
||||||
drop: onDocumentTagDrop,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
onEntryPointer
|
onEntryPointer
|
||||||
} = useDocumentsCommandContext();
|
} = useDocumentsCommandContext();
|
||||||
|
|
||||||
@@ -77,11 +70,10 @@ export const useDocumentItemLogic = (props: UseDocumentItemLogicProps) => {
|
|||||||
},
|
},
|
||||||
onDragStart: (event: DragEvent<HTMLElement>) => onDocumentDragStart?.(event, doc),
|
onDragStart: (event: DragEvent<HTMLElement>) => onDocumentDragStart?.(event, doc),
|
||||||
onDragEnd: (event: DragEvent<HTMLElement>) => onDocumentDragEnd?.(event),
|
onDragEnd: (event: DragEvent<HTMLElement>) => onDocumentDragEnd?.(event),
|
||||||
onDragOver: (event: DragEvent<HTMLElement>) => onDocumentTagDragOver?.(event, doc),
|
onDragOver: (event: DragEvent<HTMLElement>) => tagDragHandlers?.onTagDragOver(event, doc),
|
||||||
onDragLeave: (event: DragEvent<HTMLElement>) => onDocumentTagDragLeave?.(event, doc),
|
onDragLeave: (event: DragEvent<HTMLElement>) => tagDragHandlers?.onTagDragLeave(event, doc.id),
|
||||||
onTagDragStart: (event: DragEvent<HTMLElement>, tag: DocumentTag) => onDocumentTagDragStart?.(event, doc, tag),
|
onDrop: (event: DragEvent<HTMLElement>) => { tagDragHandlers?.onTagDrop(event, doc); },
|
||||||
onTagDragEnd: (event: DragEvent<HTMLElement>) => onDocumentTagDragEnd?.(event),
|
tagDragHandlers,
|
||||||
onDrop: (event: DragEvent<HTMLElement>) => { onDocumentTagDrop?.(event, doc); },
|
|
||||||
onRenameChange: setDocumentDraft,
|
onRenameChange: setDocumentDraft,
|
||||||
onRenameSubmit: () => submitDocumentEditing(doc),
|
onRenameSubmit: () => submitDocumentEditing(doc),
|
||||||
onRenameCancel: (event?: React.SyntheticEvent) => cancelDocumentEditing(event),
|
onRenameCancel: (event?: React.SyntheticEvent) => cancelDocumentEditing(event),
|
||||||
|
|||||||
@@ -48,8 +48,11 @@ interface DocumentsPanelProps extends DocumentsPanelInnerProps {
|
|||||||
selectionValue: WorkspaceSelectionValue;
|
selectionValue: WorkspaceSelectionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import type { TagDragHandlers } from '../interactions/useTagInteractions';
|
||||||
|
|
||||||
export interface DocumentsViewProps {
|
export interface DocumentsViewProps {
|
||||||
entries: DocumentsListEntry[];
|
entries: DocumentsListEntry[];
|
||||||
|
tagDragHandlers?: TagDragHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = (props) => {
|
const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = (props) => {
|
||||||
@@ -85,6 +88,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = (props) => {
|
|||||||
assetContextValue,
|
assetContextValue,
|
||||||
viewStateContextValue,
|
viewStateContextValue,
|
||||||
commandContextValue,
|
commandContextValue,
|
||||||
|
tagDragHandlers,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
hasDocumentEntries,
|
hasDocumentEntries,
|
||||||
} = useDocumentsContextValues(props);
|
} = useDocumentsContextValues(props);
|
||||||
@@ -242,6 +246,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = (props) => {
|
|||||||
const viewProps = {
|
const viewProps = {
|
||||||
entries,
|
entries,
|
||||||
viewId: currentFolderId,
|
viewId: currentFolderId,
|
||||||
|
tagDragHandlers,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [iconSizes] = useState({
|
const [iconSizes] = useState({
|
||||||
|
|||||||
@@ -184,13 +184,6 @@ export const useDocumentsContextValues = (props: DocumentsPanelInnerProps) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
onDrag: {
|
|
||||||
start: (e: any, d: any, t: any) => latestHandlersRef.current.tagDragHandlers.onTagDragStart(e, d, t),
|
|
||||||
end: (e: any) => latestHandlersRef.current.tagDragHandlers.onTagDragEnd(e),
|
|
||||||
over: (e: any, d: any) => latestHandlersRef.current.tagDragHandlers.onTagDragOver(e, d),
|
|
||||||
leave: (e: any, d: any) => latestHandlersRef.current.tagDragHandlers.onTagDragLeave(e, d.id),
|
|
||||||
drop: (e: any, d: any) => latestHandlersRef.current.tagDragHandlers.onTagDrop(e, d),
|
|
||||||
},
|
|
||||||
onAttach: (d: any, t: any) => latestPropsRef.current.onDocumentTagAttach?.(d, t),
|
onAttach: (d: any, t: any) => latestPropsRef.current.onDocumentTagAttach?.(d, t),
|
||||||
onDetach: (d: any, t: any) => latestPropsRef.current.onDocumentTagDetach?.(d, t),
|
onDetach: (d: any, t: any) => latestPropsRef.current.onDocumentTagDetach?.(d, t),
|
||||||
onClick: (t: any) => latestHandlersRef.current.toggleTagFilter(t),
|
onClick: (t: any) => latestHandlersRef.current.toggleTagFilter(t),
|
||||||
@@ -199,12 +192,13 @@ export const useDocumentsContextValues = (props: DocumentsPanelInnerProps) => {
|
|||||||
onClick: (c: any) => latestHandlersRef.current.toggleCorrespondentFilter(c),
|
onClick: (c: any) => latestHandlersRef.current.toggleCorrespondentFilter(c),
|
||||||
},
|
},
|
||||||
onEntryPointer: (entry: any, e: any) => latestPropsRef.current.onEntryPointer?.(entry, e),
|
onEntryPointer: (entry: any, e: any) => latestPropsRef.current.onEntryPointer?.(entry, e),
|
||||||
}), []); // Stable forever!
|
}), []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assetContextValue,
|
assetContextValue,
|
||||||
viewStateContextValue,
|
viewStateContextValue,
|
||||||
commandContextValue,
|
commandContextValue,
|
||||||
|
tagDragHandlers,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
hasDocumentEntries,
|
hasDocumentEntries,
|
||||||
isSearchLoading,
|
isSearchLoading,
|
||||||
|
|||||||
Reference in New Issue
Block a user