import React, { PropTypes, Component } from 'react'; import Formsy from 'formsy-react'; import FRC from 'formsy-react-components'; import { intlShape } from 'react-intl'; import DateTime from './DateTime.jsx'; // import Utils from './utils.js'; const Checkbox = FRC.Checkbox; // const CheckboxGroup = FRC.CheckboxGroup; const Input = FRC.Input; const RadioGroup = FRC.RadioGroup; const Select = FRC.Select; const Textarea = FRC.Textarea; class FormComponent extends Component { constructor(props) { super(props); this.handleBlur = this.handleBlur.bind(this); } handleBlur() { // see https://facebook.github.io/react/docs/more-about-refs.html if (this.formControl !== null) { this.props.updateCurrentValues({[this.props.name]: this.formControl.getValue()}); } } renderComponent() { // see https://facebook.github.io/react/warnings/unknown-prop.html const { control, group, updateCurrentValues, document, beforeComponent, afterComponent, ...rest } = this.props; // eslint-disable-line const base = this.props.control === "function" ? this.props : rest; const properties = { ...base, onBlur: this.handleBlur, ref: (ref) => this.formControl = ref }; // if control is a React component, use it if (typeof this.props.control === "function") { return } else { // else pick a predefined component switch (this.props.control) { case "text": return ; case "textarea": return