<commit_before>import React, { PropTypes } from 'react';
import Select, { propTypes as baseProps } from 'ihme-react-select';
import { assign } from 'lodash';

import { getWidestLabel } from './utils';

import style from './select.css';
import { menuWrapper } from './menu';

const singleSelectPropTypes = {
  /* width applied to outermost wrapper */
  width: PropTypes.number,

  /* width added to widest label (in px) */
  widthPad: PropTypes.number,
};

const defaultProps = {
  placeholder: 'Select...',
  widthPad: 50
};

export default class SingleSelect extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      menuWidth: getWidestLabel(props.options, props.labelKey, props.hierarchical) + props.widthPad
    };
  }

  componentWillReceiveProps(newProps) {
    if (newProps.options !== this.props.options ||
      newProps.labelKey !== this.props.labelKey ||
      newProps.hierarchical !== this.props.hierarchical) {
      this.setState({
        menuWidth: getWidestLabel(
          newProps.options,
          newProps.labelKey,
          newProps.hierarchical
        ) + newProps.widthPad
      });
    }
  }

  render() {
    const {
      menuContainerStyle,
      menuStyle,
      width,
      wrapperStyle,
    } = this.props;
    const { menuWidth } = this.state;

    return (
      <Select
        className={style.select}
        autofocus
        clearable
        searchable
        wrapperStyle={assign({}, { width: `${width}px` }, wrapperStyle)}
        menuRenderer={menuWrapper({ width: menuWidth })}
        menuStyle={assign({}, { overflow: 'hidden', width: `${menuWidth}px` }, menuStyle)}
        menuContainerStyle={assign({}, { width: `${menuWidth}px` }, menuContainerStyle)}
        autosize={false}
        {...this.props}
      />
    );
  }
}

SingleSelect.propTypes = assign({}, baseProps, singleSelectPropTypes);
SingleSelect.defaultProps = defaultProps;<commit_msg>single selects should not be clearable by default<commit_after>import React, { PropTypes } from 'react';
import Select, { propTypes as baseProps } from 'ihme-react-select';
import { assign } from 'lodash';

import { getWidestLabel } from './utils';

import style from './select.css';
import { menuWrapper } from './menu';

const singleSelectPropTypes = {
  /* width applied to outermost wrapper */
  width: PropTypes.number,

  /* width added to widest label (in px) */
  widthPad: PropTypes.number,
};

const defaultProps = {
  placeholder: 'Select...',
  widthPad: 50
};

export default class SingleSelect extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      menuWidth: getWidestLabel(props.options, props.labelKey, props.hierarchical) + props.widthPad
    };
  }

  componentWillReceiveProps(newProps) {
    if (newProps.options !== this.props.options ||
      newProps.labelKey !== this.props.labelKey ||
      newProps.hierarchical !== this.props.hierarchical) {
      this.setState({
        menuWidth: getWidestLabel(
          newProps.options,
          newProps.labelKey,
          newProps.hierarchical
        ) + newProps.widthPad
      });
    }
  }

  render() {
    const {
      menuContainerStyle,
      menuStyle,
      width,
      wrapperStyle,
    } = this.props;
    const { menuWidth } = this.state;

    return (
      <Select
        className={style.select}
        autofocus
        searchable
        wrapperStyle={assign({}, { width: `${width}px` }, wrapperStyle)}
        menuRenderer={menuWrapper({ width: menuWidth })}
        menuStyle={assign({}, { overflow: 'hidden', width: `${menuWidth}px` }, menuStyle)}
        menuContainerStyle={assign({}, { width: `${menuWidth}px` }, menuContainerStyle)}
        autosize={false}
        {...this.props}
      />
    );
  }
}

SingleSelect.propTypes = assign({}, baseProps, singleSelectPropTypes);
SingleSelect.defaultProps = defaultProps;
{'fraction_non_alphanumeric': 0.13206577595066804, 'fraction_numerical': 0.0010277492291880781, 'mean_word_length': 2.936299292214358, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1669753', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1147, 'n_words': 249}