How to use the react-dnd.DragDropContext 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 jacobp100 / hooks-test / src / App.js View on Github external
import React, { useReducer } from "react";
import { DragDropContext } from "react-dnd";
import HTML5Backend from "react-dnd-html5-backend";
import Button from "./Button";
import GraphView from "./GraphView";

const updater = (current, by) => Math.max(current + by, 0);

// This is really just to demonstrate there's no global state, and that you can
// have multiple graph views
export default DragDropContext(HTML5Backend)(() => {
  const [numGraphViews, incrementGraphViewBy] = useReducer(updater, 1);

  return (
    <>
      <button> incrementGraphViewBy(1)} title="Add Graph View" /&gt;
      </button><button> incrementGraphViewBy(-1)}
        title="Remove Graph View"
      /&gt;
      {Array.from({ length: numGraphViews }, (_, i) =&gt; (
        
      ))}
    
  );
});
</button>
github joshwcomeau / react-flip-move / examples / components / 3_Scrabble.jsx View on Github external
DropTarget,
  DragDropContext
}                                       from 'react-dnd';

import FlipMove from 'react-flip-move';
import Toggle from './Toggle.jsx';
import tiles from '../data/tiles.js';


const BOARD_WIDTH   = 11;
const BOARD_HEIGHT  = 7;
const SQUARE_SIZE   = 56;
const TILE_OFFSET   = 3;
const NUM_SQUARES   = BOARD_WIDTH * BOARD_HEIGHT;

@DragDropContext(HTML5Backend)
class Scrabble extends Component {
  constructor(props) {
    super(props);
    this.state = { tiles }

    this.updateDroppedTilePosition = this.updateDroppedTilePosition.bind(this);
    this.resetTiles = this.resetTiles.bind(this);
  }

  updateDroppedTilePosition({x, y}, tile) {
    // Normally, this would be done through a Redux action, but because this
    // is such a contrived example, I'm just passing the action down through
    // the child.

    // Create a copy of the state, find the newly-dropped tile.
    let stateTiles = this.state.tiles.slice();
github Opentrons / opentrons / protocol-designer / src / components / ProtocolEditor.js View on Github external
&gt;
            
            
            
            {/* TODO: Ian 2018-06-28 All main page modals will go here */}
            

            
          
        
      
    
  )
}

export default DragDropContext(MouseBackEnd)(ProtocolEditor)
github DefinitelyTyped / DefinitelyTyped / types / react-dnd-touch-backend / react-dnd-touch-backend-tests.ts View on Github external
import TouchBackend from "react-dnd-touch-backend";

const component = () => null;

const dndComponent = ReactDnd.DragDropContext(TouchBackend)(component);
const dndComponentMouseEvents = ReactDnd.DragDropContext(TouchBackend({enableMouseEvents: true}))(component);
const dndComponentDelayTouchStart = ReactDnd.DragDropContext(TouchBackend({delayTouchStart: 200}))(component);
const dndComponentDelayMouseStart = ReactDnd.DragDropContext(TouchBackend({enableMouseEvents: true, delayMouseStart: 100}));
const dndComponentKeyboardEvents = ReactDnd.DragDropContext(TouchBackend({enableKeyboardEvents: true}));
const dndComponentOldDelay = ReactDnd.DragDropContext(TouchBackend({delay: 300}));
const dndComponentAllCurrentEvents = ReactDnd.DragDropContext(TouchBackend(
    {enableKeyboardEvents: true, enableMouseEvents: true, delayMouseStart: 100, delayTouchStart: 200}));
const dndComponentWithScrollAngleRanges = ReactDnd.DragDropContext(TouchBackend(
    { scrollAngleRanges: [{ start: 0, end: 0 }, { start: 0 }, { end: 0 }] }));
const dndComponentWithTouchSlop = ReactDnd.DragDropContext(TouchBackend({ touchSlop: 0 }));
const dndComponentWithIgnoreContextMenu = ReactDnd.DragDropContext(TouchBackend({ ignoreContextMenu: true }));
github prakhar1989 / react-tags / lib / ReactTags.js View on Github external
) : null;

    return (
      <div>
        <div>
          {tagItems}
          {this.props.inline &amp;&amp; tagInput}
        </div>
        {!this.props.inline &amp;&amp; tagInput}
      </div>
    );
  }
}

module.exports = {
  WithContext: DragDropContext(HTML5Backend)(ReactTags),
  WithOutContext: ReactTags,
  KEYS: KEYS,
};
github ballerina-platform / ballerina-lang / composer / diagram / src / BallerinaDiagramWrapper.jsx View on Github external
* under the License.
 *
 */
import React from 'react';
import { DragDropContext } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
import PropTypes from 'prop-types';
import { Dimmer, Loader } from 'semantic-ui-react';
import DesignView from 'plugins/ballerina/views/design-view';
import TreeBuilder from 'plugins/ballerina/model/tree-builder';
import FragmentUtils from 'plugins/ballerina/utils/fragment-utils';
import '@ballerina/theme/default-theme/index.js/';
import './scss/themes/default.scss';
import '@ballerina/theme/font-ballerina';

const BallerinaDesignView = DragDropContext(HTML5Backend)(DesignView);

const TREE_MODIFIED = 'tree-modified';

/**
 * A wrapper component to wrap Editable Ballerina Diagram.
 */
class BallerinaDiagramWrapper extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            currentAST: undefined,
            editMode: true,
            diagramMode: 'action',
        };
        if (props.parseFragment) {
github polluxparis / zebulon-grid / src / demo / PivotGrid.demo-o.js View on Github external
<div> Column or row headers: </div>
          <div> Click: select children headers columns or rows.</div>
          <div>
            Collapse or expand button to hide or show children headers and
            recompute measures.
          </div>
          <div>
            Right and bottom handle drag and drop to resize rows or columns.
          </div>
        
      
    );
  }
}

export default DragDropContext(HTML5Backend)(PivotGridDemo);
github 5TechCenter / ReactCMS / client / src / containers / Admin / Appearance / EditMenus.js View on Github external
function mapStateToProps({ sites, info, posts, categories, pages }) {
  posts = _.omitBy( posts, item => ( item.status !== 'publish' ) );
  pages = _.omitBy( pages, item => ( item.status !== 'publish' ) );

  return {
    posts, categories, pages,
    site: sites[info.domain],
    collectionPrefix: info.collectionPrefix,
  };
}

export default reduxForm({
  form: 'EditMenu',
  validate
})(
  DragDropContext(HTML5Backend)(
    connect(mapStateToProps, { fetchPosts, editMenu, deleteMenu, openSnackbar, startSubmit, stopSubmit })(
      withStyles(styles)(EditMenus)
    )
  )
);
github IBM / carbon-addons-iot-react / src / components / Table / TableHead / ColumnHeaderRow / ColumnHeaderRow.jsx View on Github external
columnId={c.columnId}
                isHidden={c.isHidden}
                moveItem={(srcIndex, destIndex) =&gt; this.reorderColumn(srcIndex, destIndex)}
                onClick={() =&gt; this.toggleColumn(c.columnId)}&gt;
                {columns.find(i =&gt; c.columnId === i.id).name}
              
            ))}
          
        
      
    );
  }
}

export { ColumnHeaderRow as UnconnectedColumnHeaderRow };
export default DragDropContext(HTML5Backend)(ColumnHeaderRow);
github FlowCI / flow-web / src / views / Flows / Settings / Steps / steps.js View on Github external
this.setState({ end: hoverIndex })
  }

  render () {
    const { steps } = this.state
    return <div>
      
      {steps.map((p, i) =&gt; )}
      
    </div>
  }
}
export default DragDropContext(HTML5Backend)(
  connect(mapStateToProps, mapDispatchToProps)(
    autoCancel({ funcs: ['query'] })(FlowSteps)
  )
)