mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 15:07:54 -04:00
* locations dnd * fix icon * reduce navigate timeout * fix types * another * fix drag overlay count * Update pnpm-lock.yaml * merge * ephemeral support and other improvements * merge * Tag dnd * merge * type * merge * remove offset * update dnd logic to not depend on drag source * handle allowed types if parent isn't available * saved searches dnd navigation * well * rendering * Update pnpm-lock.yaml * types * remove width * Temporary solution * merge * @dnd-kit/utilities * Update pnpm-lock.yaml * explorer path dnd * remove unused drag hook * fix dnd on LayeredFileIcon --------- Co-authored-by: Brendan Allan <brendonovich@outlook.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import clsx from 'clsx';
|
|
import { createContext, HTMLAttributes, useContext, useMemo } from 'react';
|
|
|
|
import { useExplorerDroppable, UseExplorerDroppableProps } from './useExplorerDroppable';
|
|
|
|
const ExplorerDroppableContext = createContext<{ isDroppable: boolean } | null>(null);
|
|
|
|
export const useExplorerDroppableContext = () => {
|
|
const ctx = useContext(ExplorerDroppableContext);
|
|
|
|
if (ctx === null) throw new Error('ExplorerDroppableContext.Provider not found!');
|
|
|
|
return ctx;
|
|
};
|
|
|
|
/**
|
|
* Wrapper for explorer droppable items until dnd-kit solvers their re-rendering issues
|
|
* https://github.com/clauderic/dnd-kit/issues/1194#issuecomment-1696704815
|
|
*/
|
|
export const ExplorerDroppable = ({
|
|
droppable,
|
|
children,
|
|
...props
|
|
}: HTMLAttributes<HTMLDivElement> & { droppable: UseExplorerDroppableProps }) => {
|
|
const { isDroppable, className, setDroppableRef } = useExplorerDroppable(droppable);
|
|
|
|
const context = useMemo(() => ({ isDroppable }), [isDroppable]);
|
|
|
|
return (
|
|
<ExplorerDroppableContext.Provider value={context}>
|
|
<div {...props} ref={setDroppableRef} className={clsx(props.className, className)}>
|
|
{children}
|
|
</div>
|
|
</ExplorerDroppableContext.Provider>
|
|
);
|
|
};
|