<commit_before>import React, { Component, PropTypes } from 'react';
import Const from './Const';

class TableColumn extends Component {

  constructor(props) {
    super(props);
  }
  /* eslint no-unused-vars: [0, { "args": "after-used" }] */
  shouldComponentUpdate(nextProps, nextState) {
    const { children } = this.props;
    let shouldUpdated = this.props.width !== nextProps.width
      || this.props.className !== nextProps.className
      || this.props.hidden !== nextProps.hidden
      || this.props.dataAlign !== nextProps.dataAlign
      || typeof children !== typeof nextProps.children
      || ('' + this.props.onEdit).toString() !== ('' + nextProps.onEdit).toString();

    if (shouldUpdated) {
      return shouldUpdated;
    }

    if (typeof children === 'object' && children !== null && children.props !== null) {
      if (children.props.type === 'checkbox' || children.props.type === 'radio') {
        shouldUpdated = shouldUpdated ||
          children.props.type !== nextProps.children.props.type ||
          children.props.checked !== nextProps.children.props.checked ||
          children.props.disabled !== nextProps.children.props.disabled;
      } else {
        shouldUpdated = true;
      }
    } else {
      shouldUpdated = shouldUpdated || children !== nextProps.children;
    }

    if (shouldUpdated) {
      return shouldUpdated;
    }

    if (!(this.props.cellEdit && nextProps.cellEdit)) {
      return false;
    } else {
      return shouldUpdated
        || this.props.cellEdit.mode !== nextProps.cellEdit.mode;
    }
  }

  handleCellEdit = e => {
    if (this.props.cellEdit.mode === Const.CELL_EDIT_DBCLICK) {
      if (document.selection && document.selection.empty) {
        document.selection.empty();
      } else if (window.getSelection) {
        const sel = window.getSelection();
        sel.removeAllRanges();
      }
    }
    this.props.onEdit(
      e.currentTarget.parentElement.rowIndex + 1,
      e.currentTarget.cellIndex,
      e);
  }

  render() {
    const {
      children
    } = this.props;
    const tdStyle = {
      textAlign: this.props.dataAlign,
      display: this.props.hidden ? 'none' : null
    };

    const opts = {};
    if (this.props.cellEdit) {
      if (this.props.cellEdit.mode === Const.CELL_EDIT_CLICK) {
        opts.onClick = this.handleCellEdit;
      } else if (this.props.cellEdit.mode === Const.CELL_EDIT_DBCLICK) {
        opts.onDoubleClick = this.handleCellEdit;
      }
    }
    return (
      <td style={ tdStyle }
          title={ this.props.columnTitle }
          className={ this.props.className }
          { ...opts }>
        { typeof children === 'boolean' ? children.toString() : children }
      </td>
    );
  }
}
TableColumn.propTypes = {
  dataAlign: PropTypes.string,
  hidden: PropTypes.bool,
  className: PropTypes.string,<commit_msg>improve for destructuring assignment<commit_after>import React, { Component, PropTypes } from 'react';
import Const from './Const';

class TableColumn extends Component {

  constructor(props) {
    super(props);
  }
  /* eslint no-unused-vars: [0, { "args": "after-used" }] */
  shouldComponentUpdate(nextProps, nextState) {
    const { children } = this.props;
    let shouldUpdated = this.props.width !== nextProps.width
      || this.props.className !== nextProps.className
      || this.props.hidden !== nextProps.hidden
      || this.props.dataAlign !== nextProps.dataAlign
      || typeof children !== typeof nextProps.children
      || ('' + this.props.onEdit).toString() !== ('' + nextProps.onEdit).toString();

    if (shouldUpdated) {
      return shouldUpdated;
    }

    if (typeof children === 'object' && children !== null && children.props !== null) {
      if (children.props.type === 'checkbox' || children.props.type === 'radio') {
        shouldUpdated = shouldUpdated ||
          children.props.type !== nextProps.children.props.type ||
          children.props.checked !== nextProps.children.props.checked ||
          children.props.disabled !== nextProps.children.props.disabled;
      } else {
        shouldUpdated = true;
      }
    } else {
      shouldUpdated = shouldUpdated || children !== nextProps.children;
    }

    if (shouldUpdated) {
      return shouldUpdated;
    }

    if (!(this.props.cellEdit && nextProps.cellEdit)) {
      return false;
    } else {
      return shouldUpdated
        || this.props.cellEdit.mode !== nextProps.cellEdit.mode;
    }
  }

  handleCellEdit = e => {
    if (this.props.cellEdit.mode === Const.CELL_EDIT_DBCLICK) {
      if (document.selection && document.selection.empty) {
        document.selection.empty();
      } else if (window.getSelection) {
        const sel = window.getSelection();
        sel.removeAllRanges();
      }
    }
    this.props.onEdit(
      e.currentTarget.parentElement.rowIndex + 1,
      e.currentTarget.cellIndex,
      e);
  }

  render() {
    const {
      children,
      columnTitle,
      className,
      dataAlign,
      hidden,
      cellEdit
    } = this.props;

    const tdStyle = {
      textAlign: dataAlign,
      display: hidden ? 'none' : null
    };

    const opts = {};
    
    if (cellEdit) {
      if (cellEdit.mode === Const.CELL_EDIT_CLICK) {
        opts.onClick = this.handleCellEdit;
      } else if (cellEdit.mode === Const.CELL_EDIT_DBCLICK) {
        opts.onDoubleClick = this.handleCellEdit;
      }
    }
    return (
      <td style={ tdStyle }
          title={ columnTitle }
          className={ className }
          { ...opts }>
        { typeof children === 'boolean' ? children.toString() : children }
      </td>
    );
  }
}
TableColumn.propTypes = {
  dataAlign: PropTypes.string,
  hidden: PropTypes.bool,
  className: PropTypes.string,
{'fraction_non_alphanumeric': 0.14012184508268058, 'fraction_numerical': 0.0006962576153176675, 'mean_word_length': 2.4803149606299213, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, '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': '2712989', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1671, 'n_words': 325}