<commit_before>import React from 'react';

export default class OutsideClick extends React.Component {
  /**
   * @class OutsideClick keeps track of clicks outside of the component. This is used for Dialogs, select boxes, etc.
   * @author <NAME> <<EMAIL>>
   */
  constructor(props) {
    super(props)

    // Ensure the right context
    this.handleBodyClick = this.handleBodyClick.bind(this);
  }

  /**
   * Bind to the body so we can check for clicks outside of the component
   */
  componentDidMount() {
    document.body.addEventListener('click', this.handleBodyClick);
  }

  /**
   * Clean up
   */
  componentWillUnmount() {
    document.body.removeEventListener('click', this.handleBodyClick);
  }

  /**
   * Handle clicks outside of the component. Goes up the tree until it finds itself or runs out of parents.
   * @param     {Event}    event
   */
  handleBodyClick(event) {
    var source = event.target;
    var el = React.findDOMNode(this);

    // Search up the tree for the component node
    while (source.parentNode) {
      if (source === el) {
        return;
      } else {
        source = source.parentNode;
      }
    }

    this.props.onClick(event);
  }

  /**
   * Render the react component
   * @return    {React}
   */
  render() {
    return (
      <this.props.tag
        className={this.props.className}
      >
        {this.props.children}
      </this.props.tag>
    );
  }
}<commit_msg>minor formatting and linting tweaks<commit_after>import React from 'react';

export default class OutsideClick extends React.Component {
  /**
   * @class OutsideClick keeps track of clicks outside of the component. This is used for Dialogs, select boxes, etc.
   * @author <NAME> <<EMAIL>>
   */
  constructor(props) {
    super(props);

    // Ensure the right context
    this.handleBodyClick = this.handleBodyClick.bind(this);
  }

  /**
   * Bind to the body so we can check for clicks outside of the component
   */
  componentDidMount() {
    document.body.addEventListener('click', this.handleBodyClick);
  }

  /**
   * Clean up
   */
  componentWillUnmount() {
    document.body.removeEventListener('click', this.handleBodyClick);
  }

  /**
   * Handle clicks outside of the component. Goes up the tree until it finds itself or runs out of parents.
   * @param     {Event}    event
   */
  handleBodyClick(event) {
    let source = event.target;
    let el = React.findDOMNode(this);

    // Search up the tree for the component node
    while (source.parentNode) {
      if (source === el) {
        return;
      } else {
        source = source.parentNode;
      }
    }

    this.props.onClick(event);
  }

  /**
   * Render the react component
   * @return    {React}
   */
  render() {
    return (
      <this.props.tag
        className={this.props.className} >
        {this.props.children}
      </this.props.tag>
    );
  }
}
{'fraction_non_alphanumeric': 0.11505039972193257, 'fraction_numerical': 0.0, 'mean_word_length': 2.471652593486128, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5858725', 'n_tokens_mistral': 866, 'n_tokens_neox': 852, 'n_words': 244}