import React from 'react';
import PropTypes from 'prop-types';
import { DatePicker } from 'components/Form';
import field from 'hocs/field';
import moment from 'moment';
import { isString, isObject, isFunction } from 'utils/fp';
import renderDate from 'utils/renderDate';

const buildInDefaultProps = {
	inputFilter(val) {
		if (!val) {
		} else if (isObject(val)) {
			return val;
		} else if (isString(val)) {
			return moment(val);
		}
	},
	outputFilter(val) {
		if (!val) {
		} else if (isFunction(val.toISOString)) {
			return val.toISOString();
		} else if (isString(val)) {
			return val;
		}
	},
};

function DatePickerField(props) {
	return (
		<DatePicker defaultValue={undefined} {...props} {...buildInDefaultProps} />
	);
}

/* eslint-disable react/prop-types */
DatePickerField.renderTable = function renderTable(
	{ format, dateFormat },
	{ value }
) {
	return <span>{renderDate(value, format, dateFormat)}</span>;
};

DatePickerField.propTypes = {
	format: PropTypes.string,
	dateFormat: PropTypes.string,
};

DatePickerField.defaultProp = {
	format: 'date',
};

export default field(DatePickerField);

@@ -324,35 +324,34 @@
 %09%09if (!val) 
-%7B%0A%09%09%7D else 
+return;%0A%09%09
 if (isObject
@@ -353,29 +353,24 @@
 bject(val)) 
-%7B%0A%09%09%09
 return val;%0A
@@ -367,31 +367,24 @@
 turn val;%0A%09%09
-%7D else 
 if (isString
@@ -386,29 +386,24 @@
 tring(val)) 
-%7B%0A%09%09%09
 return momen
@@ -410,20 +410,16 @@
 t(val);%0A
-%09%09%7D%0A
 %09%7D,%0A%09out
@@ -451,19 +451,18 @@
 al) 
-%7B%0A%09%09%7D else 
+return;%0A%09%09
 if (
@@ -490,21 +490,16 @@
 tring)) 
-%7B%0A%09%09%09
 return v
@@ -522,15 +522,8 @@
 ;%0A%09%09
-%7D else 
 if (
@@ -541,13 +541,8 @@
 l)) 
-%7B%0A%09%09%09
 retu
@@ -553,12 +553,8 @@
 al;%0A
-%09%09%7D%0A
 %09%7D,%0A
@@ -1001,16 +1001,17 @@
 aultProp
+s
  = %7B%0A%09fo

fix DatePicker defaultProps typo