@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration
Version:
An optional Pragmatic drag and drop package that enables rapid migration from react-beautiful-dnd to Pragmatic drag and drop
53 lines (52 loc) • 1.52 kB
TypeScript
import type { DraggableId, DraggableLocation, MovementMode } from 'react-beautiful-dnd';
import type { DraggableDimensions } from '../hooks/use-captured-dimensions';
export type DragState = {
isDragging: false;
} | {
isDragging: true;
mode: MovementMode;
draggableDimensions: DraggableDimensions;
prevDestination: DraggableLocation | null;
restoreFocusTo: DraggableId | null;
draggableId: DraggableId;
type: string;
sourceLocation: DraggableLocation;
targetLocation: DraggableLocation | null;
/**
* This is used for positioning placeholders in virtual lists.
*/
draggableInitialOffsetInSourceDroppable: {
top: number;
left: number;
};
};
/**
* An abstraction that both pointer dragging and keyboard dragging can
* control state through.
*/
export type DragController = {
getDragState(): DragState;
startDrag(args: {
draggableId: string;
type: string;
getSourceLocation(): DraggableLocation;
sourceElement: HTMLElement;
mode: MovementMode;
}): void;
updateDrag(args: {
targetLocation: DraggableLocation | null;
}): void;
stopDrag(args: {
reason: 'CANCEL' | 'DROP';
}): void;
};
export type StartKeyboardDrag = (args: {
/**
* The event that caused `startKeyboardDrag()` to be called.
*/
event: KeyboardEvent;
draggableId: string;
type: string;
getSourceLocation(): DraggableLocation;
sourceElement: HTMLElement;
}) => void;