<commit_before>import React from 'react';
import _Dropdown from 'react-toolbox/lib/dropdown';
import classNames from 'classnames';
import events from 'react-toolbox/lib/utils/events';
import Input from 'components/Input/Input';

export default class Dropdown extends _Dropdown {
  componentWillUpdate(nextProps, nextState) {
    if (!this.state.active && nextState.active) {
      events.addEventsToDocument({click: this.handleDocumentClick});
    }
  }

  render() {
    const styles = require('./styles.scss');
    const toolboxStyles = require('react-toolbox/lib/dropdown/style.scss');
    let inputStyles = require('components/Input/styles.scss');
    inputStyles = {
      ...inputStyles,
      inputWrapper: classNames(inputStyles.inputWrapper, styles.inputWrapper)
    };

    const {template, source, ...others} = this.props;
    const selected = this.getSelectedItem();
    const className = classNames(toolboxStyles.root, {
      [toolboxStyles.up]: this.state.up,
      [toolboxStyles.active]: this.state.active,
      [toolboxStyles.disabled]: this.props.disabled
    }, this.props.className);

    return (
      <div data-react-toolbox="dropdown" className={className}>
        <Input
          {...others}
          className={classNames(toolboxStyles.value, styles.value)}
          onMouseDown={this.handleMouseDown}
          readOnly
          type={template ? 'hidden' : null}
          value={selected && selected.label}
          styles={inputStyles}
        />
        {template ? this.renderTemplateValue(selected) : null}
        <ul className={classNames(toolboxStyles.values, styles.values)} ref="values">
          {source.map(this.renderValue.bind(this))}
        </ul>
      </div>
    );
  }
}
<commit_msg>Dropdown for react-toolbox 0.14.2 fixed<commit_after>import React from 'react';
import _Dropdown from 'react-toolbox/lib/dropdown';
import classNames from 'classnames';
import events from 'react-toolbox/lib/utils/events';
import Input from 'components/Input/Input';

export default class Dropdown extends _Dropdown {
  componentWillUpdate(nextProps, nextState) {
    if (!this.state.active && nextState.active) {
      events.addEventsToDocument({click: this.handleDocumentClick});
    }
  }

  getSelectedItem = () => {
    if (this.props.value) {
      for (const item of this.props.source) {
        if (item.value === this.props.value) return item;
      }
    } else {
      return this.props.source[0];
    }
  };

  render() {
    const styles = require('./styles.scss');
    const toolboxStyles = require('react-toolbox/lib/dropdown/style.scss');
    let inputStyles = require('components/Input/styles.scss');
    inputStyles = {
      ...inputStyles,
      inputWrapper: classNames(inputStyles.inputWrapper, styles.inputWrapper)
    };

    const {template, source, ...others} = this.props;
    const selected = this.getSelectedItem();
    const className = classNames(toolboxStyles.root, {
      [toolboxStyles.up]: this.state.up,
      [toolboxStyles.active]: this.state.active,
      [toolboxStyles.disabled]: this.props.disabled
    }, this.props.className);

    return (
      <div data-react-toolbox="dropdown" className={className}>
        <Input
          {...others}
          className={classNames(toolboxStyles.value, styles.value)}
          onMouseDown={this.handleMouseDown}
          readOnly
          type={template && selected ? 'hidden' : null}
          value={selected && selected.label}
          styles={inputStyles}
        />
        {template && selected ? this.renderTemplateValue(selected) : null}
        <ul className={classNames(toolboxStyles.values, styles.values)} ref="values">
          {source.map(this.renderValue.bind(this))}
        </ul>
      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.13352878464818763, 'fraction_numerical': 0.0013326226012793177, 'mean_word_length': 3.052915766738661, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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': '348002', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1090, 'n_words': 206}