<commit_before>import React from 'react'
import classNames from 'classnames'
import ErrorList from './ErrorList'

const FormField = props => {
  if (props.hidden) {
    return null
  }

  const fromGroupClass = classNames(
    'form-field',
    'form-group',
    {
      'mandatory': props.mandatory,
      'dirty': props.dirty,
      'has-error': props.error && props.touched
    }
  )

  const labelClass = classNames(
    'col-sm-3',
    'control-label',
    {
      'sr-only': !props.useLabel
    })

  const labelAlt = `${props.label} ${props.mandatory ? props.mandatoryTitle : ''}`

  const editableValueWrapperClass = classNames({
    'col-sm-9': props.useLabel,
    'col-sm-12': !props.useLabel
  })

  return (
    <div className={fromGroupClass}>
      <label className={labelClass} htmlFor={props.id} alt={labelAlt}>
        {props.label}
      </label>
      <div className={editableValueWrapperClass}>
        {props.children}
        {props.touched && props.error && <ErrorList error={props.error}/>}
      </div>
    </div>
  )
}

FormField.defaultProps = {
  useLabel: true,
  mandatoryTitle: 'is a mandatory field'
}

FormField.propTypes = {
  id: React.PropTypes.string,
  label: React.PropTypes.string,
  mandatory: React.PropTypes.bool,
  mandatoryTitle: React.PropTypes.string,
  children: React.PropTypes.node,
  hidden: React.PropTypes.bool,
  touched: React.PropTypes.bool,
  dirty: React.PropTypes.bool,
  useLabel: React.PropTypes.bool,
  error: React.PropTypes.objectOf(React.PropTypes.arrayOf(React.PropTypes.string))
}

export default FormField<commit_msg>refactor(tocco-ui): formField improvements<commit_after>import React from 'react'
import classNames from 'classnames'
import ErrorList from './ErrorList'

const FormField = props => {
  if (props.hidden) {
    return null
  }

  const fromGroupClass = classNames(
    'form-group',
    props.className,
    {
      'mandatory': props.mandatory,
      'dirty': props.dirty,
      'has-error': props.error && props.touched
    }
  )

  const labelClass = classNames(
    'col-sm-3',
    'control-label',
    {
      'sr-only': !props.useLabel
    })

  const labelAlt = `${props.label} ${props.mandatory ? props.mandatoryTitle : ''}`

  const editableValueWrapperClass = classNames({
    'col-sm-9': props.useLabel,
    'col-sm-12': !props.useLabel
  })

  return (
    <div className={fromGroupClass}>
      <label className={labelClass} htmlFor={props.id} alt={labelAlt}>
        {props.label}
      </label>
      <div className={editableValueWrapperClass}>
        {props.children}
        {props.touched && props.error && <ErrorList error={props.error}/>}
      </div>
    </div>
  )
}

FormField.defaultProps = {
  useLabel: true,
  mandatoryTitle: 'is a mandatory field'
}

FormField.propTypes = {
  id: React.PropTypes.string,
  label: React.PropTypes.string,
  mandatory: React.PropTypes.bool,
  mandatoryTitle: React.PropTypes.string,
  children: React.PropTypes.node,
  hidden: React.PropTypes.bool,
  touched: React.PropTypes.bool,
  dirty: React.PropTypes.bool,
  useLabel: React.PropTypes.bool,
  error: React.PropTypes.objectOf(React.PropTypes.arrayOf(React.PropTypes.string)),
  className: React.PropTypes.string
}

export default FormField
{'fraction_non_alphanumeric': 0.1383142945353504, 'fraction_numerical': 0.002469898116702686, 'mean_word_length': 3.3665768194070083, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '6020985', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1063, 'n_words': 203}