import React, { PropTypes, Component } from 'react'
import ReactDOM from 'react-dom'
import classnames from 'classnames'
import { Key } from '../../utils.js'
import Filt from '../../filt/filt'
import FilterDocs from './FilterDocs'
export default class FilterInput extends Component {
static contextTypes = {
returnFocus: React.PropTypes.func,
}
constructor(props, context) {
super(props, context)
// Consider both focus and mouseover for showing/hiding the tooltip,
// because onBlur of the input is triggered before the click on the tooltip
// finalized, hiding the tooltip just as the user clicks on it.
this.state = { value: this.props.value, focus: false, mousefocus: false }
this.onChange = this.onChange.bind(this)
this.onFocus = this.onFocus.bind(this)
this.onBlur = this.onBlur.bind(this)
this.onKeyDown = this.onKeyDown.bind(this)
this.onMouseEnter = this.onMouseEnter.bind(this)
this.onMouseLeave = this.onMouseLeave.bind(this)
}
componentWillReceiveProps(nextProps) {
this.setState({ value: nextProps.value })
}
isValid(filt) {
try {
const str = filt == null ? this.state.value : filt
if (str) {
Filt.parse(str)
}
return true
} catch (e) {
return false
}
}
getDesc() {
if (!this.state.value) {
return