<commit_before>import React from 'react'
import { findDOMNode } from 'react-dom'

import { changeEvent } from "../controllers/values";
import { resultsEvent } from "../controllers/pipeline";

const RIGHT_ARROW_KEYCODE = 39
const TAB_KEYCODE = 9
const RETURN_KEYCODE = 13

class AutocompleteInput extends React.Component {
  constructor(props) {
    super(props)
    this.setText = this.setText.bind(this);
    this.valuesUpdated = this.valuesUpdated.bind(this);
    this.getState = this.getState.bind(this);
    this.state = {
      ...this.getState(),
      qParam: props.qParam || "q",
      qOverrideParam: props.qOverrideParam || "q.override",
    };
  }

  getState() {
    const text = this.props.values.get()[this.state.qParam] || "";
    const responseValues = this.props.pipeline.getResponseValues();
    const completion = responseValues ? (responseValues[this.state.qParam] || "") : "";
    return { text, completion };
  }

  componentDidMount() {
    if (this.props.focus) {
      findDOMNode(this.refs.searchInput).focus()
    }

    this.removeValuesListener = this.props.values.listen(changeEvent, this.valuesUpdated);
    this.removeResultsListener = this.props.pipeline.listen(resultsEvent, this.valuesUpdated);
  }

  componentWillUnmount() {
    this.removeValuesListener();
    this.removeResultsListener();
  }

  valuesUpdated() {
    this.setState(this.getState())
  }

  setText(text, override = false) {
    const textValues = {
      [this.state.qParam] : text,
      [this.state.qOverrideParam]: override ? "true" : undefined,
    };
    this.props.values.set(textValues);
    if (textValues[this.state.qParam]) {
      this.props.pipeline.search();
    } else {
      this.props.pipeline.clearResults();
      this.props.pipeline.emitTrackingReset();<commit_msg>pipeline: allow specifying params on autocompleteinput<commit_after>import React from 'react'
import { findDOMNode } from 'react-dom'

import { changeEvent } from "../controllers/values";
import { resultsEvent } from "../controllers/pipeline";

const RIGHT_ARROW_KEYCODE = 39
const TAB_KEYCODE = 9
const RETURN_KEYCODE = 13

class AutocompleteInput extends React.Component {
  constructor(props) {
    super(props)
    this.setText = this.setText.bind(this);
    this.valuesUpdated = this.valuesUpdated.bind(this);
    this.getState = this.getState.bind(this);
    const qParam = props.qParam || "q";
    const qOverrideParam = props.qOverrideParam || "q.override";
    this.state = {
      ...this.getState(props.values, props.pipeline, qParam),
      qParam,
      qOverrideParam,
    };
  }

  getState(values, pipeline, qParam) {
    const text = values.get()[qParam] || "";
    const responseValues = pipeline.getResponseValues();
    const completion = responseValues ? (responseValues[qParam] || "") : "";
    return { text, completion };
  }

  componentDidMount() {
    if (this.props.focus) {
      findDOMNode(this.refs.searchInput).focus()
    }

    this.removeValuesListener = this.props.values.listen(changeEvent, this.valuesUpdated);
    this.removeResultsListener = this.props.pipeline.listen(resultsEvent, this.valuesUpdated);
  }

  componentWillUnmount() {
    this.removeValuesListener();
    this.removeResultsListener();
  }

  valuesUpdated() {
    this.setState(this.getState(this.props.values, this.props.pipeline, this.state.qParam));
  }

  setText(text, override = false) {
    const textValues = {
      [this.state.qParam] : text,
      [this.state.qOverrideParam]: override ? "true" : undefined,
    };
    this.props.values.set(textValues);
    if (textValues[this.state.qParam]) {
      this.props.pipeline.search();
    } else {
      this.props.pipeline.clearResults();
      this.props.pipeline.emitTrackingReset();
{'fraction_non_alphanumeric': 0.1362543414373497, 'fraction_numerical': 0.0026716537536735237, 'mean_word_length': 3.6108374384236455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5916793', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1130, 'n_words': 198}