import * as tslib_1 from "tslib";
import React, { useState, useEffect } from 'react';
import { DatePicker } from 'antd';
import moment from 'moment';
var TdDateRender = function (props) {
    var validator = props.validator;
    var _a = useState(props.value), value = _a[0], setValue = _a[1];
    useEffect(function () {
        setValue(props.value);
    }, [props.value]);
    function onChange(inputValue, date) {
        if (validator && !validator(inputValue)) {
            return;
        }
        setValue(inputValue);
        props.onChange && props.onChange(inputValue, date);
    }
    return (React.createElement(DatePicker, tslib_1.__assign({}, (value && { value: moment(value) }), { style: tslib_1.__assign({ width: 100 }, props.style), onChange: function (date, str) {
            onChange(str, date);
        } })));
};
export default TdDateRender;
//# sourceMappingURL=index.js.map