import React, { PropTypes, Component } from 'react';

export default class AlgoliaInput extends Component {
  static propTypes = {
    client: PropTypes.object.isRequired,
    index: PropTypes.string.isRequired,
    options: PropTypes.object,
    onResults: PropTypes.func.isRequired,
    onError: PropTypes.func,
    className: PropTypes.string
  }
  static defaultProps = {
    options: {}
  }
  constructor(...args) {
    super(...args);
    this.onKeyUp = ::this.onKeyUp;
  }
  componentDidMount() {
    this.index = this.props.client.initIndex(this.props.index);
  }
  onKeyUp(e) {
    if (e.target.value) {
      this.index.search(e.target.value, this.props.options, (err, content) => {
        if (err && this.props.onError) {
          this.props.onError(err);
        }
        if (content) {
          this.props.onResults(content);
        }
      });
    }
  }
  render() {
    return (
      <div>
        <input onKeyUp={ this.onKeyUp } type='text' className={ this.props.className || 'algolia-react-input' } />
      </div>
    );
  }

};

@@ -307,16 +307,79 @@
 s.func,%0A
+    onEmptyField: PropTypes.func, // when user empty the field%0A
     clas
@@ -919,16 +919,90 @@
     %7D);%0A
+    %7D else if (this.props.onEmptyField)%7B%0A      this.props.onEmptyField();%0A
     %7D%0A  

add props.onEmptyField