<commit_before>import React, { Component, PropTypes } from 'react'
// test

export default class Input extends Component {
  static contextTypes = {
    state: PropTypes.object,
    actions: PropTypes.object,
    handleInputChange: PropTypes.func
  };
  static defaultProps = {
    as: 'input',
    type: 'text',
    name: '',
    actionType: 'UPDATE_INPUT_VALUE'
  };
  render () {
    let { state } = this.context
    let { as, name, value, check, actionType, ...subProps } = this.props
    let Tag = as

    let path = check ? `${name}.value` : name

    if (value === undefined) {
      value = getValueByPath(state, path)
    }

    subProps.value = value
    subProps.name = name
    subProps.onChange = this.handleChange
    if (check) {
      subProps.onFocus = this.handleFocus
      subProps.onBlur = this.handleBlur
    }

    return <Tag {...subProps} />
  }
  getAction () {
    return this.context.actions[this.props.actionType]
  }
  setGlobalState (newState) {
    let CALL_ACTION = this.getAction()
    CALL_ACTION(newState)
  }
  handleChange = event => {
    let { state, handleInputChange } = this.context
    let { name, onChange, check } = this.props
    let currentValue = event.currentTarget.value
    let path = check ? `${name}.value` : name
    let oldValue = getValueByPath(state, path)
    let value = handleInputChange
      ? handleInputChange(path, currentValue, oldValue)
      : value
    let newState = setValueByPath(state, path, value)

    this.setGlobalState(newState)
    onChange && onChange(event)
  };
  handleFocus = event => {
    let { state } = this.context
    let { name, onFocus } = this.props
    let path = `${name}.isWarn`
    let isWarn = getValueByPath(state, path)
    if (!isWarn) {
      return
    }
    let newState = setValueByPath(state, path, false)

    this.setGlobalState(newState)
    onFocus && onFocus(event)
  };
  handleBlur = event => {
    let state = this.context.state
    let { name, onBlur, check } = this.props
    let pathOfValidState = `${name}.isValid`
    let pathOfWranState = `${name}.isWarn`

    let isValidValue = check(event.currentTarget.value)
    let newState = state
<commit_msg>fixed<commit_after>import React, { Component, PropTypes } from 'react'
// test

export default class Input extends Component {
  static contextTypes = {
    state: PropTypes.object,
    actions: PropTypes.object,
    handleInputChange: PropTypes.func
  };
  static defaultProps = {
    as: 'input',
    type: 'text',
    name: '',
    actionType: 'UPDATE_INPUT_VALUE'
  };
  render () {
    let { state } = this.context
    let { as, name, value, check, actionType, ...subProps } = this.props
    let Tag = as

    let path = check ? `${name}.value` : name

    if (value === undefined) {
      value = getValueByPath(state, path)
    }

    subProps.value = value
    subProps.name = name
    subProps.onChange = this.handleChange
    if (check) {
      subProps.onFocus = this.handleFocus
      subProps.onBlur = this.handleBlur
    }

    return <Tag {...subProps} />
  }
  getAction () {
    return this.context.actions[this.props.actionType]
  }
  setGlobalState (newState) {
    let CALL_ACTION = this.getAction()
    CALL_ACTION(newState)
  }
  handleChange = event => {
    let { state, handleInputChange } = this.context
    let { name, onChange, check } = this.props
    let currentValue = event.currentTarget.value
    let path = check ? `${name}.value` : name
    let oldValue = getValueByPath(state, path)
    let value = handleInputChange
      ? handleInputChange(path, currentValue, oldValue)
      : currentValue
    let newState = setValueByPath(state, path, value)

    this.setGlobalState(newState)
    onChange && onChange(event)
  };
  handleFocus = event => {
    let { state } = this.context
    let { name, onFocus } = this.props
    let path = `${name}.isWarn`
    let isWarn = getValueByPath(state, path)
    if (!isWarn) {
      return
    }
    let newState = setValueByPath(state, path, false)

    this.setGlobalState(newState)
    onFocus && onFocus(event)
  };
  handleBlur = event => {
    let state = this.context.state
    let { name, onBlur, check } = this.props
    let pathOfValidState = `${name}.isValid`
    let pathOfWranState = `${name}.isWarn`

    let isValidValue = check(event.currentTarget.value)
    let newState = state

{'fraction_non_alphanumeric': 0.11840589725869616, 'fraction_numerical': 0.0, 'mean_word_length': 2.8802502234137624, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2935589', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1375, 'n_words': 334}