/**
 * TextField component
 *
 * Generated by coz on 2016-10-14,
 * from a template provided by apeman-asset-templates.
 *
 * @function TextField
 */
'use strict'

import React from 'react'
import defineDebug from 'debug'
import {
  ApField,
  ApFieldLabel, ApFieldValue,
  ApText
} from 'apeman-react-basic'
const debug = defineDebug('project:fragment:text-field')

/** @lends TextField */
const TextField = ({
  id,
  name,
  label,
  value,
  rows = 1,
  placeholder,
  onBlur,
  onUpdate
}) => (
  <ApField className='text-field'>
    <ApFieldLabel htmlFor={ id }>
      { label }
    </ApFieldLabel>
    <ApFieldValue>
      <ApText id={ id }
              value={ value }
              name={ name }
              rows={ rows }
              placeholder={ placeholder }
              onBlur={ onBlur }
              onChange={ (e) => onUpdate({ [name]: e.target.value }) }
      />
    </ApFieldValue>
  </ApField>
)

export default TextField
