<commit_before>import styles from '../styles/fields'

import React from 'react'
import { translate } from 'cozy-ui/react/helpers/i18n'
import withState from 'cozy-ui/react/helpers/withState'
import Field from './Field'

const Input = ({ t, name, type = 'text', placeholder = '', value, submitting, errors, onChange }) => (
  <input
    type={type}
    placeholder={placeholder}
    value={value}
    name={name}
    onBlur={e => onChange(name, e.target.type === 'checkbox' ? e.target.checked : e.target.value)}
    className={errors && errors.length !== 0 ? styles['error'] : ''}
    aria-busy={submitting}
  />
)

export default translate()(props => (
  <Field {...props}>
    <Input {...props} />
  </Field>
))

export const PasswordInput = translate()(
  withState({
    visible: false
  }, (setState) => ({
    toggleVisibility: () => {
      setState(state => ({ visible: !state.visible }))
    }
  }))(
    props => {
      const { t, name, value, onInput, toggleVisibility, visible, inError = false } = props
      return (
        <div className={styles['coz-form-group']}>
          <a
            onClick={toggleVisibility}
            className={styles['password-visibility']}
          >
            {visible ? t(`ProfileView.password.hide`) : t(`ProfileView.password.show`)}
          </a>
          <input
            type={visible ? 'text' : 'password'}
            placeholder={t(`ProfileView.${name}.placeholder`)}
            value={value}
            onInput={onInput}
            className={inError ? styles['error'] : ''}
            autocomplete={autocomplete || 'off'}
          />
        </div>
      )
    }
  )
)<commit_msg>[fix] declares missing autocomplete prop<commit_after>import styles from '../styles/fields'

import React from 'react'
import { translate } from 'cozy-ui/react/helpers/i18n'
import withState from 'cozy-ui/react/helpers/withState'
import Field from './Field'

const Input = ({ t, name, type = 'text', placeholder = '', value, submitting, errors, onChange }) => (
  <input
    type={type}
    placeholder={placeholder}
    value={value}
    name={name}
    onBlur={e => onChange(name, e.target.type === 'checkbox' ? e.target.checked : e.target.value)}
    className={errors && errors.length !== 0 ? styles['error'] : ''}
    aria-busy={submitting}
  />
)

export default translate()(props => (
  <Field {...props}>
    <Input {...props} />
  </Field>
))

export const PasswordInput = translate()(
  withState({
    visible: false
  }, (setState) => ({
    toggleVisibility: () => {
      setState(state => ({ visible: !state.visible }))
    }
  }))(
    props => {
      const { t, name, value, onInput, toggleVisibility, visible, autocomplete, inError = false } = props
      return (
        <div className={styles['coz-form-group']}>
          <a
            onClick={toggleVisibility}
            className={styles['password-visibility']}
          >
            {visible ? t(`ProfileView.password.hide`) : t(`ProfileView.password.show`)}
          </a>
          <input
            type={visible ? 'text' : 'password'}
            placeholder={t(`ProfileView.${name}.placeholder`)}
            value={value}
            onInput={onInput}
            className={inError ? styles['error'] : ''}
            autocomplete={autocomplete || 'off'}
          />
        </div>
      )
    }
  )
)
{'fraction_non_alphanumeric': 0.17020640143583607, 'fraction_numerical': 0.0017947950942267424, 'mean_word_length': 2.5274261603375527, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 35, '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': '3274483', 'n_tokens_mistral': 994, 'n_tokens_neox': 982, 'n_words': 205}