All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.components.DragDrop.DragDrop.tsx Maven / Gradle / Ivy

Go to download

This library provides a set of common React components for use with the PatternFly reference implementation.

The newest version!
import * as React from 'react';

export interface DraggableItemPosition {
  /** Parent droppableId */
  droppableId: string;
  /** Index of item in parent Droppable */
  index: number;
}

export const DragDropContext = React.createContext({
  onDrag: (_source: DraggableItemPosition) => true as boolean,
  onDragMove: (_source: DraggableItemPosition, _dest?: DraggableItemPosition) => {},
  onDrop: (_source: DraggableItemPosition, _dest?: DraggableItemPosition) => false as boolean
});

interface DragDropProps {
  /** Potentially Droppable and Draggable children */
  children?: React.ReactNode;
  /** Callback for drag event. Return true to allow drag, false to disallow. */
  onDrag?: (source: DraggableItemPosition) => boolean;
  /** Callback on mouse move while dragging. */
  onDragMove?: (source: DraggableItemPosition, dest?: DraggableItemPosition) => void;
  /** Callback for drop event. Return true to allow drop, false to disallow. */
  onDrop?: (source: DraggableItemPosition, dest?: DraggableItemPosition) => boolean;
}

export const DragDrop: React.FunctionComponent = ({
  children,
  onDrag = () => true,
  onDragMove = () => {},
  onDrop = () => false
}: DragDropProps) => (
  {children}
);
DragDrop.displayName = 'DragDrop';




© 2015 - 2024 Weber Informatics LLC | Privacy Policy