import { RecursiveArrayOfIds } from "@granity/helpers"; import { createContext, FC, ReactNode } from "react"; import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; import { OnDrop, OnMove } from "./types"; type ProviderProps = { itemsDictionaryIds: RecursiveArrayOfIds; onDrop: OnDrop; onMove?: OnMove; children?: ReactNode; }; type DndContextModel = { itemsDictionaryIds: RecursiveArrayOfIds; onDrop: OnDrop; onMove?: OnMove; }; const defaultValue: DndContextModel = { itemsDictionaryIds: [], onDrop: () => {}, }; export const DndContext = createContext(defaultValue); export type DraggingStatus = { draggingDirection: "upward" | "downward"; draggingType: "canMoveNext" | "canMovePrev" | "canCombine"; }; const DndContextProvider: FC = ({ itemsDictionaryIds, onDrop, onMove, children, }) => { const providerValue: DndContextModel = { itemsDictionaryIds, onDrop, onMove, }; return ( {children} ); }; export default DndContextProvider;