<commit_before>import React, {PropTypes} from 'react';
import OnClickOutside from 'shared/components/OnClickOutside';
import classNames from 'classnames';
import _ from 'lodash';

const {func, arrayOf, string} = PropTypes;
const MultiSelectDropdown = React.createClass({
  propTypes: {
    onApply: func.isRequired,
    items: arrayOf(PropTypes.string.isRequired).isRequired,
    selectedItems: arrayOf(string.isRequired).isRequired,
  },

  getInitialState() {
    return {
      isOpen: false,
      localSelectedItems: this.props.selectedItems,
    };
  },

  componentWillReceiveProps(nextProps) {
    if (!_.isEqual(this.state.localSelectedItems, nextProps.selectedItems)) {
      this.setState({
        localSelectedItems: nextProps.selectedItems,
      });
    }
  },

  handleClickOutside() {
    this.setState({isOpen: false});
  },

  toggleMenu(e) {
    e.stopPropagation();
    this.setState({isOpen: !this.state.isOpen});
  },

  onSelect(item, e) {
    e.stopPropagation();

    const {localSelectedItems} = this.state;

    let nextItems;
    if (this.isSelected(item)) {
      nextItems = localSelectedItems.filter((i) => i !== item);
    } else {
      nextItems = localSelectedItems.concat(item);
    }

    this.setState({localSelectedItems: nextItems});
  },

  isSelected(item) {
    return this.state.localSelectedItems.indexOf(item) > -1;
  },

  onApplyFunctions(e) {
    e.stopPropagation();

    this.setState({isOpen: false});
    this.props.onApply(this.state.localSelectedItems);
  },

  render() {
    const {localSelectedItems} = this.state;
    const {isOpen} = this.state;

    const labelText = isOpen ? "0 Selected" : "Apply Function";

    return (
      <div className={classNames('dropdown multi-select-dropdown', {open: isOpen})}>
        <div onClick={this.toggleMenu} className="btn btn-xs btn-info dropdown-toggle" type="button">
          <span className="multi-select-dropdown__label"><commit_msg>Removing white space<commit_after>import React, {PropTypes} from 'react';
import OnClickOutside from 'shared/components/OnClickOutside';
import classNames from 'classnames';
import _ from 'lodash';

const {func, arrayOf, string} = PropTypes;
const MultiSelectDropdown = React.createClass({
  propTypes: {
    onApply: func.isRequired,
    items: arrayOf(PropTypes.string.isRequired).isRequired,
    selectedItems: arrayOf(string.isRequired).isRequired,
  },

  getInitialState() {
    return {
      isOpen: false,
      localSelectedItems: this.props.selectedItems,
    };
  },

  componentWillReceiveProps(nextProps) {
    if (!_.isEqual(this.state.localSelectedItems, nextProps.selectedItems)) {
      this.setState({
        localSelectedItems: nextProps.selectedItems,
      });
    }
  },

  handleClickOutside() {
    this.setState({isOpen: false});
  },

  toggleMenu(e) {
    e.stopPropagation();
    this.setState({isOpen: !this.state.isOpen});
  },

  onSelect(item, e) {
    e.stopPropagation();

    const {localSelectedItems} = this.state;

    let nextItems;
    if (this.isSelected(item)) {
      nextItems = localSelectedItems.filter((i) => i !== item);
    } else {
      nextItems = localSelectedItems.concat(item);
    }

    this.setState({localSelectedItems: nextItems});
  },

  isSelected(item) {
    return this.state.localSelectedItems.indexOf(item) > -1;
  },

  onApplyFunctions(e) {
    e.stopPropagation();

    this.setState({isOpen: false});
    this.props.onApply(this.state.localSelectedItems);
  },

  render() {
    const {localSelectedItems} = this.state;
    const {isOpen} = this.state;
    const labelText = isOpen ? "0 Selected" : "Apply Function";

    return (
      <div className={classNames('dropdown multi-select-dropdown', {open: isOpen})}>
        <div onClick={this.toggleMenu} className="btn btn-xs btn-info dropdown-toggle" type="button">
          <span className="multi-select-dropdown__label">
{'fraction_non_alphanumeric': 0.13624678663239073, 'fraction_numerical': 0.0010282776349614395, 'mean_word_length': 3.699275362318841, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6981830', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1188, 'n_words': 217}