import React from 'react'; import PropTypes from 'prop-types'; import FormErrors from '../formErrors'; import { FastField } from 'formik'; export const InputFormItemNotFast = (props) => { const { name, form, hint, size, password, placeholder, autoFocus, autoComplete, inputProps, errorMessage, required, } = props; const schemaField = props.schema ? props.schema[name] : undefined; const label = schemaField ? schemaField.label : ''; const sizeLabelClassName = { small: 'col-form-label-sm', large: 'col-form-label-lg', }[size] || ''; const sizeInputClassName = { small: 'form-control-sm', large: 'form-control-lg', }[size] || ''; return (
{!!label && ( )} { form.setFieldValue(name, event.target.value); form.setFieldTouched(name); }} value={(form.values && form.values[name]) || ''} placeholder={placeholder || undefined} autoFocus={autoFocus || undefined} autoComplete={autoComplete || undefined} className={`form-control ${sizeInputClassName} ${FormErrors.validateStatus( form, name, errorMessage, )}`} {...inputProps} />
{FormErrors.displayableError( form, name, errorMessage, )}
{!!hint && ( {hint} )}
); }; InputFormItemNotFast.defaultProps = { required: false, }; InputFormItemNotFast.propTypes = { form: PropTypes.object.isRequired, name: PropTypes.string.isRequired, required: PropTypes.bool, type: PropTypes.string, hint: PropTypes.string, autoFocus: PropTypes.bool, size: PropTypes.string, prefix: PropTypes.string, placeholder: PropTypes.string, errorMessage: PropTypes.string, inputProps: PropTypes.object, }; const InputFormItem = (props) => ( {({ form }) => ( )} ); export default InputFormItem;