carbon-react
Version:
A library of reusable React components for easily building user interfaces.
31 lines (30 loc) • 1.06 kB
TypeScript
import React from "react";
import { Draggable, DropTarget } from "./data";
export interface DragDropProviderProps {
children: React.ReactNode;
/**
* Callback fired when an item is dropped.
*
* Provides data about the dragged item and the drop target (if any) as arguments.
*/
onDrop?: (args: {
dragged: Draggable;
target: DropTarget | null;
}) => void;
/**
* Callback fired when a dragged item leaves a drop target, or moves over a new one.
*
* Provides data about the dragged item and the drop target (if any) as arguments.
*/
onDropTargetChange?: (args: {
dragged: Draggable;
target: DropTarget | null;
}) => void;
}
type DragDropContextType = {
/** Identifier of the context instance. */
contextId: symbol;
};
declare function useDragDropContext(): DragDropContextType | null;
declare const DragDropProvider: ({ children, onDrop, onDropTargetChange, }: DragDropProviderProps) => React.JSX.Element;
export { DragDropProvider, useDragDropContext };