<commit_before>/**
 * Popup
 */

import React, { Component, PropTypes } from 'react';
import Search from './components/Search';
import Option from './components/Option';
import { KEY_EN, KEY_UP, KEY_DOWN } from './constants';
import isArray from 'zent-utils/lodash/isArray';

class Popup extends Component {

  constructor(props) {
    super(props);

    this.state = {
      data: [],
      keyCode: '',
      keyword: ''
    };
    this.sourceData = props.data;
    this.searchFilterHandler = this.searchFilterHandler.bind(this);
    this.optionChangedHandler = this.optionChangedHandler.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    this.sourceData = nextProps.data;
    if (nextProps.keyCode === KEY_EN && this.state.keyCode === nextProps.keyCode) {
      return;
    }
    this.updateCurrentId(nextProps.keyCode, nextProps.keyword);
    if (nextProps.keyword === null) {
      this.setState({
        keyCode: nextProps.keyCode,
        data: nextProps.data
      });
    } else {
      this.setState({
        keyCode: nextProps.keyCode,
        data: nextProps.data,
        keyword: nextProps.keyword
      });
    }
  }

  optionChangedHandler(ev, cid) {
    this.setState({
      keyword: ''
    });
    this.props.onBlur();
    this.props.onChange(ev, this.sourceData.filter(item => item.cid === cid)[0]);
  }

  searchFilterHandler(keyword) {
    let {
      filter,
      onAsyncFilter
    } = this.props;

    if (typeof onAsyncFilter === 'function') {<commit_msg>feat: update<commit_after>/**
 * Popup
 */

import React, { Component, PropTypes } from 'react';
import Search from './components/Search';
import Option from './components/Option';
import { KEY_EN, KEY_UP, KEY_DOWN } from './constants';
import isArray from 'zent-utils/lodash/isArray';

class Popup extends Component {

  constructor(props) {
    super(props);

    this.state = {
      data: [],
      keyCode: '',
      keyword: ''
    };
    this.sourceData = props.data;
    this.searchFilterHandler = this.searchFilterHandler.bind(this);
    this.optionChangedHandler = this.optionChangedHandler.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    this.sourceData = nextProps.data;
    if (nextProps.keyCode === KEY_EN && this.state.keyCode === nextProps.keyCode) {
      return;
    }
    this.updateCurrentId(nextProps.keyCode, nextProps.keyword);
    if (nextProps.keyword === null) {
      this.setState({
        keyCode: nextProps.keyCode,
        data: nextProps.data
      });
    } else {
      this.setState({
        keyCode: nextProps.keyCode,
        data: nextProps.data,
        keyword: nextProps.keyword
      });
    }
  }

  optionChangedHandler(ev, cid) {
    this.setState({
      keyword: ''
    });
    this.props.onBlur();
    this.props.onChange(ev, this.props.data.filter(item => item.cid === cid)[0]);
  }

  searchFilterHandler(keyword) {
    let {
      filter,
      onAsyncFilter
    } = this.props;

    if (typeof onAsyncFilter === 'function') {
{'fraction_non_alphanumeric': 0.1386006026113157, 'fraction_numerical': 0.0006695681285570807, 'mean_word_length': 2.825864276568502, 'pattern_counts': {'":': 0, '<': 3, '<?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': '908138', 'n_tokens_mistral': 928, 'n_tokens_neox': 925, 'n_words': 175}