<commit_before>import React from 'react';
import bem from 'js/bem';
import TextareaAutosize from 'react-autosize-textarea';
import './textBox.scss';

enum AvailableType {
  'text-multiline' = 'text-multiline',
  'text' = 'text',
  'email' = 'email',
  'password' = 'password',
  'url' = 'url',
}

const DefaultType = AvailableType.text;

type TextBoxProps = {
  type: AvailableType // one of AVAILABLE_TYPES, defaults to DEFAULT_TYPE
  value: string
  onChange: Function
  onBlur?: Function
  onKeyPress?: Function
  errors: string[]|string|boolean // for visual error indication and displaying error messages
  label?: string
  placeholder?: string
  description?: string
  readOnly?: boolean
  disabled?: boolean
  customModifiers?: string[]|string
};

/**
 * A text box generic component.
 */
class TextBox extends React.Component<TextBoxProps, void> {
  constructor(props: TextBoxProps){
    super(props);
  }

  /**
   * NOTE: I needed to set `| any` for `onChange`, `onBlur` and `onKeyPress`
   * types to stop TextareaAutosize complaining.
   */

  onChange(evt: React.ChangeEvent<HTMLInputElement> | any) {
    if (this.props.readOnly) {
      return;
    }
    this.props.onChange(evt.currentTarget.value);
  }

  onBlur(evt: React.FocusEvent<HTMLInputElement> | any) {
    if (typeof this.props.onBlur === 'function') {<commit_msg>fix type<commit_after>import React from 'react';
import bem from 'js/bem';
import TextareaAutosize from 'react-autosize-textarea';
import './textBox.scss';

enum AvailableType {
  'text-multiline' = 'text-multiline',
  'text' = 'text',
  'email' = 'email',
  'password' = 'password',
  'url' = 'url',
}

const DefaultType = AvailableType.text;

type TextBoxProps = {
  type: AvailableType // one of AVAILABLE_TYPES, defaults to DEFAULT_TYPE
  value: string
  onChange: Function
  onBlur?: Function
  onKeyPress?: Function
  errors: string[]|string|boolean // for visual error indication and displaying error messages
  label?: string
  placeholder?: string
  description?: string
  readOnly?: boolean
  disabled?: boolean
  customModifiers?: string[]|string
};

/**
 * A text box generic component.
 */
class TextBox extends React.Component<TextBoxProps, {}> {
  constructor(props: TextBoxProps){
    super(props);
  }

  /**
   * NOTE: I needed to set `| any` for `onChange`, `onBlur` and `onKeyPress`
   * types to stop TextareaAutosize complaining.
   */

  onChange(evt: React.ChangeEvent<HTMLInputElement> | any) {
    if (this.props.readOnly) {
      return;
    }
    this.props.onChange(evt.currentTarget.value);
  }

  onBlur(evt: React.FocusEvent<HTMLInputElement> | any) {
    if (typeof this.props.onBlur === 'function') {
{'fraction_non_alphanumeric': 0.1308411214953271, 'fraction_numerical': 0.0, 'mean_word_length': 4.068181818181818, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2962944', 'n_tokens_mistral': 856, 'n_tokens_neox': 853, 'n_words': 224}