<commit_before>'use strict';

import React, { Component, PropTypes, findDOMNode } from 'react';
import debounce from 'debounce';
import classnames from 'classnames';
import sectionIterator from './sectionIterator';

export default class Autosuggest extends Component { // eslint-disable-line no-shadow
  static propTypes = {
    suggestions: PropTypes.func.isRequired, // Function to get the suggestions
    suggestionRenderer: PropTypes.func,     // Function that renders a given suggestion (must be implemented when suggestions are objects)
    suggestionValue: PropTypes.func,        // Function that maps suggestion object to input value (must be implemented when suggestions are objects)
    showWhen: PropTypes.func,               // Function that determines whether to show suggestions or not
    onSuggestionSelected: PropTypes.func,   // This function is called when suggestion is selected via mouse click or Enter
    onSuggestionFocused: PropTypes.func,    // This function is called when suggestion is focused via mouse hover or Up/Down keys
    onSuggestionUnfocused: PropTypes.func,  // This function is called when suggestion is unfocused via mouse hover or Up/Down keys
    inputAttributes: PropTypes.object,      // Attributes to pass to the input field (e.g. { id: 'my-input', className: 'sweet autosuggest' })
    id: PropTypes.string,                   // Used in aria-* attributes. If multiple Autosuggest's are rendered on a page, they must have unique ids.
    scrollBar: PropTypes.bool,              // Should be set to true when the suggestions container can have a scroll bar
    disableCache: PropTypes.bool
  }

  static defaultProps = {
    showWhen: input => input.trim().length > 0,
    onSuggestionSelected: () => {},
    onSuggestionFocused: () => {},
    onSuggestionUnfocused: () => {},
    inputAttributes: {},
    id: '1',
    disableCache: false,
    scrollBar: false
  }

  constructor(props) {
    super();

    this.cache = {};
    this.state = {
      value: props.inputAttributes.value || '',
      suggestions: null,
      focusedSectionIndex: null,    // Used when multiple sections are displayed
      focusedSuggestionIndex: null, // Index within a section
      valueBeforeUpDown: null       // When user interacts using the Up and Down keys,
                                    // this field remembers input's value prior to
                                    // interaction in order to revert back if ESC hit.
                                    // See: http://www.w3.org/TR/wai-aria-practices/#autocomplete
    };<commit_msg>Updated inline documentation for component<commit_after>'use strict';

import React, { Component, PropTypes, findDOMNode } from 'react';
import debounce from 'debounce';
import classnames from 'classnames';
import sectionIterator from './sectionIterator';

export default class Autosuggest extends Component { // eslint-disable-line no-shadow
  static propTypes = {
    suggestions: PropTypes.func.isRequired, // Function to get the suggestions
    suggestionRenderer: PropTypes.func,     // Function that renders a given suggestion (must be implemented when suggestions are objects)
    suggestionValue: PropTypes.func,        // Function that maps suggestion object to input value (must be implemented when suggestions are objects)
    showWhen: PropTypes.func,               // Function that determines whether to show suggestions or not
    onSuggestionSelected: PropTypes.func,   // This function is called when suggestion is selected via mouse click or Enter
    onSuggestionFocused: PropTypes.func,    // This function is called when suggestion is focused via mouse hover or Up/Down keys
    onSuggestionUnfocused: PropTypes.func,  // This function is called when suggestion is unfocused via mouse hover or Up/Down keys
    inputAttributes: PropTypes.object,      // Attributes to pass to the input field (e.g. { id: 'my-input', className: 'sweet autosuggest' })
    id: PropTypes.string,                   // Used in aria-* attributes. If multiple Autosuggest's are rendered on a page, they must have unique ids.
    scrollBar: PropTypes.bool,              // Should be set to true when the suggestions container can have a scroll bar
    disableCache: PropTypes.bool            // Should be set to true when disabling the in-memory caching
  }

  static defaultProps = {
    showWhen: input => input.trim().length > 0,
    onSuggestionSelected: () => {},
    onSuggestionFocused: () => {},
    onSuggestionUnfocused: () => {},
    inputAttributes: {},
    id: '1',
    disableCache: false,
    scrollBar: false
  }

  constructor(props) {
    super();

    this.cache = {};
    this.state = {
      value: props.inputAttributes.value || '',
      suggestions: null,
      focusedSectionIndex: null,    // Used when multiple sections are displayed
      focusedSuggestionIndex: null, // Index within a section
      valueBeforeUpDown: null       // When user interacts using the Up and Down keys,
                                    // this field remembers input's value prior to
                                    // interaction in order to revert back if ESC hit.
                                    // See: http://www.w3.org/TR/wai-aria-practices/#autocomplete
    };
{'fraction_non_alphanumeric': 0.08352359208523592, 'fraction_numerical': 0.001141552511415525, 'mean_word_length': 2.7283687943262414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5767871', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1264, 'n_words': 508}