{"size": 1151, "ext": "js", "max_stars_repo_path": "src/components/SelectSearchInput.js", "max_stars_repo_name": "RusinovAnton/react-select2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/SelectSearchInput.js", "max_issues_repo_name": "RusinovAnton/react-select2", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/SelectSearchInput.js", "max_forks_repo_name": "RusinovAnton/react-select2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.0731707317, "max_line_length": 109, "alphanum_fraction": 0.6350999131}
import React, { PropTypes } from 'react'
import { stopPropagation } from '../utils/events'


export const inArray = (item, array) => array.indexOf(item) !== -1
const allowedKeysArray = ['Escape']

const SelectSearchInput = ({ onClick, onKeyDown, isPending, ...props }, // eslint-disable-line no-unused-vars
  { cssClassNameSelector }) => {
  const filterKeyDowns = e => {
    if (inArray(e.key, allowedKeysArray)) {
      onKeyDown(e)
    }
  }

  return (
    <span className={`${cssClassNameSelector}__search`}>
      <input className={`${cssClassNameSelector}__search-field`}
             autoFocus
             autoComplete='off'
             autoCorrect='off'
             autoCapitalize='off'
             spellCheck='false'
             onKeyDown={ stopPropagation(filterKeyDowns) }
             onClick={ stopPropagation() }
             {...props}/>
      {/* { isPending && <span className={`${cssClassNameSelector}__loader`}/> } */}
    </span>
  )
}

SelectSearchInput.propTypes = {
  isPending: PropTypes.bool.isRequired,
}

SelectSearchInput.contextTypes = {
  cssClassNameSelector: PropTypes.string,
}

export default SelectSearchInput
