How to use the react-dnd.DragSource function in react-dnd

To help you get started, we’ve selected a few react-dnd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github choerodon / choerodon-front-agile / agile / src / app / agile / containers / program / Board / BoardHome / components / BoardBody / IssueCard.js View on Github external
// console.log(source.boardFeatureId, boardFeatureId);
      if (source.id !== id) {
        props.moveCard(source, {
          index: props.index,
          sprintId: props.sprintId,
          projectId: props.projectId,
        });
      }
      return props;
    },
  },
  connect => ({
    connectDropTarget: connect.dropTarget(),
  }),
)(
  DragSource(
    'card',
    {
      beginDrag: props => ({
        id: props.issue.id,
        issue: props.issue,
        index: props.index,
        sprintId: props.sprintId,
        projectId: props.projectId,
      }),
      endDrag(props, monitor) {
        const source = monitor.getItem();
        const didDrop = monitor.didDrop();
        const result = monitor.getDropResult();
        if (result) {
          const {
            dropType, teamProjectId, sprintId, index,
github netlify / netlify-cms / packages / netlify-cms-core / src / components / UI / DragDrop.js View on Github external
export const DragSource = ({ namespace, ...props }) => {
  const DragComponent = ReactDNDDragSource(
    namespace,
    {
      // eslint-disable-next-line no-unused-vars
      beginDrag({ children, isDragging, connectDragComponent, ...ownProps }) {
        // We return the rest of the props as the ID of the element being dragged.
        return ownProps;
      },
    },
    connect => ({
      connectDragComponent: connect.dragSource(),
    }),
  )(({ children, connectDragComponent }) => children(connectDragComponent));

  return React.createElement(DragComponent, props, props.children);
};
DragSource.propTypes = {
github plotly / falcon / app / components / Settings / Preview / components / Box.react.js View on Github external
marginBottom: '0.5rem',
    cursor: 'move',
    float: 'left',
    fontSize: '12px',
    borderRadius: '10px'
};

const boxSource = {
    beginDrag(props) {
        return {
            name: props.name
        };
    }
};

@DragSource(props => props.type, boxSource, (connect, monitor) => ({
    connectDragSource: connect.dragSource(),
    isDragging: monitor.isDragging()
}))
export default class Box extends Component {
    constructor(props) {
        super(props);

        this.handleRemove = this.handleRemove.bind(this);
        this.handleClick = this.handleClick.bind(this);
    }

    static propTypes = {
        connectDragSource: PropTypes.func.isRequired,
        isDragging: PropTypes.bool.isRequired,
        name: PropTypes.string.isRequired,
        type: PropTypes.string.isRequired,
github artsmia / lume / app / components / ui / drag / Sortable.js View on Github external
alignItems: "center",
        border: "1px solid grey",
        boxSizing: "border-box",
        backgroundColor: (isDragging) ? 'grey' : 'white',
      }}
    >
      {(title) ? title : "Detail"}
    
  )
}



Sortable = DropTarget(ItemTypes.SORTABLE, targetSpec, targetCollect)(Sortable)

Sortable = DragSource(ItemTypes.SORTABLE, sourceSpec, sourceCollect)(Sortable)

export default Sortable
github decentraland / builder / src / components / AssetCard / AssetCard.tsx View on Github external
if (!asset.isDisabled) {
      onClick(asset)
    }
  }

  render() {
    const { isHorizontal, asset, connectDragSource, isDragging } = this.props
    return connectDragSource(
      <div data-asset-id="{asset.id}">
        {isHorizontal ?  : }
      </div>
    )
  }
}

export default DragSource(ASSET_TYPE, assetSource, collect)(AssetCard)
github artsmia / lume / app / components / cms / EditContentThumb / EditContentThumb.component.js View on Github external
monitor.getItem().index = hoverItem.index
  }
}

function dropCollect(connect, monitor) {
  return {
    connectDropTarget: connect.dropTarget()
  }
}

let Wrapped = EditContentThumb

Wrapped = DropTarget('content', dropSpec, dropCollect)(Wrapped)

Wrapped = DragSource('content', dragSpec, dragCollect)(Wrapped)

export default Wrapped
github stipsan / epic / client / components / Setup / Item.js View on Github external
}
  render() {
    const { type, isDragging, connectDragSource } = this.props
    
    return connectDragSource(<div>)
  }
}

export const ExtraLarge = DragSource(EXTRA_LARGE, itemSource, collect)(Item)
export const Large = DragSource(LARGE, itemSource, collect)(Item)
export const Medium1 = DragSource(MEDIUM_FIRST, itemSource, collect)(Item)
export const Medium2 = DragSource(MEDIUM_SECOND, itemSource, collect)(Item)
export const Small1 = DragSource(SMALL_FIRST, itemSource, collect)(Item)
export const Small2 = DragSource(SMALL_SECOND, itemSource, collect)(Item)
export const ExtraSmall1 = DragSource(EXTRA_SMALL_FIRST, itemSource, collect)(Item)
export const ExtraSmall2 = DragSource(EXTRA_SMALL_SECOND, itemSource, collect)(Item)</div>
github woodenconsulting / react-js-diagrams / demos / demo4 / components / DragWrapper.js View on Github external
import React from 'react';
import PropTypes from 'prop-types';
import { DragSource } from 'react-dnd';

const nodeSource = {
  beginDrag(props) {
    return props;
  }
};

@DragSource('node-source', nodeSource, (connect, monitor) => ({
  connectDragSource: connect.dragSource(),
  isDragging: monitor.isDragging(),
}))
export class DragWrapper extends React.Component {
  static propTypes = {
    connectDragSource: PropTypes.func.isRequired,
    isDragging: PropTypes.bool.isRequired,
    children: PropTypes.node
  };

  render() {
    const { isDragging, connectDragSource, children, style } = this.props;
    const opacity = isDragging ? 0.4 : 1;

    return (
      connectDragSource(
github cassiozen / react-simple-dnd / src / DragSource.js View on Github external
constructor(props) {
    super(props);

    const dragSourceSpec = {
      beginDrag({ children, isDragging, connectDragComponent, ...ownProps }) {
        props.onBeginDrag();
        return ownProps;
      },
      endDrag() {
        props.onEndDrag();
      }
    };

    this.DecoratedDragComponent = reactDndDragSource(props.type, dragSourceSpec, this.dragSourceCollect)(DragComponent);
  }