<commit_before>const React = require('react');
const types = React.PropTypes;
const classnames = require('classnames');
const move = require('./move_helper');
import {mergeProps} from 'pui-react-helpers';
require('pui-css-lists');

function preventDefault(e) {
  e.preventDefault();
}

function childrenIndices(children) {
  return children.map((child, i) => i);
}

class DraggableList extends React.Component{
  constructor(props, context) {
    super(props, context);
    this.state = {
      itemIndices: childrenIndices(this.props.children),
      draggingId: null
    }
  }

  static propTypes = {
    onDragEnd: types.func,
    innerClassName: types.string
  };

  componentWillReceiveProps(nextProps) {
    if (nextProps.children) {
      this.setState({
        itemIndices: childrenIndices(nextProps.children),
        draggingId: null
      });
    }
  }

  dragStart = (draggingId, {dataTransfer}) => {
    dataTransfer.effectAllowed = 'move';
    try {
      dataTransfer.dropEffect = 'move';
      dataTransfer.setData('text/plain', '');
    } catch (err) {
      dataTransfer.setData('text', '');
    }
    setTimeout(() => this.setState({draggingId}), 0);
  };

  dragEnd = () => {
    this.setState({draggingId: null});
    this.props.onDragEnd && this.props.onDragEnd(this.state.itemIndices);
  };

  dragEnter = (e) => {
    var {draggingId, itemIndices} = this.state;
    try{
      var endDraggingId = Number(e.currentTarget.dataset.draggingId);
    }catch (err){
      var endDraggingId = Number(e.currentTarget.getAttribute('data-dragging-id'));
    }
    if (draggingId === null || Number.isNaN(endDraggingId)) return;

    var startIndex = itemIndices.indexOf(draggingId);
    var endIndex = itemIndices.indexOf(endDraggingId);
<commit_msg>chore(DraggableList): minor cleanup<commit_after>const React = require('react');
const types = React.PropTypes;
const classnames = require('classnames');
const move = require('./move_helper');
import {mergeProps} from 'pui-react-helpers';
require('pui-css-lists');

function preventDefault(e) {
  e.preventDefault();
}

function childrenIndices(children) {
  return children.map((child, i) => i);
}

class DraggableList extends React.Component{
  constructor(props, context) {
    super(props, context);
    this.state = {
      itemIndices: childrenIndices(props.children),
      draggingId: null
    }
  }

  static propTypes = {
    onDragEnd: types.func,
    innerClassName: types.string
  };

  componentWillReceiveProps(nextProps) {
    if (nextProps.children) {
      this.setState({
        itemIndices: childrenIndices(nextProps.children),
        draggingId: null
      });
    }
  }

  dragStart = (draggingId, {dataTransfer}) => {
    dataTransfer.effectAllowed = 'move';
    try {
      dataTransfer.dropEffect = 'move';
      dataTransfer.setData('text/plain', '');
    } catch (err) {
      dataTransfer.setData('text', '');
    }
    setTimeout(() => this.setState({draggingId}), 0);
  };

  dragEnd = () => {
    this.setState({draggingId: null});
    this.props.onDragEnd && this.props.onDragEnd(this.state.itemIndices);
  };

  dragEnter = (e) => {
    var {draggingId, itemIndices} = this.state;
    var endDraggingId = Number(e.currentTarget.getAttribute('data-dragging-id'));
    if (draggingId === null || Number.isNaN(endDraggingId)) return;

    var startIndex = itemIndices.indexOf(draggingId);
    var endIndex = itemIndices.indexOf(endDraggingId);

{'fraction_non_alphanumeric': 0.14563953488372092, 'fraction_numerical': 0.0005813953488372093, 'mean_word_length': 3.6816326530612247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7319516', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1090, 'n_words': 194}