import _DatePicker from "@alifd/next/es/date-picker";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
var _excluded = ["nextTablePrefix", "value", "onChange", "rules", "name"];
import React from "react";
import Moment from "moment";
import BaseTableField from "./baseTableField";
var DateField = /*#__PURE__*/function (_BaseTableField) {
  _inheritsLoose(DateField, _BaseTableField);
  function DateField() {
    return _BaseTableField.apply(this, arguments) || this;
  }
  var _proto = DateField.prototype;
  _proto.convertValueToSet = function convertValueToSet(value) {
    return value ? Moment(value) : value;
  };
  _proto.dataChangeHandler = function dataChangeHandler(value) {
    var onChange = this.props.onChange;
    onChange && onChange(value ? value.toDate().getTime() : value);
  };
  _proto.renderField = function renderField() {
    var field = this.field;
    var _this$props = this.props,
      nextTablePrefix = _this$props.nextTablePrefix,
      value = _this$props.value,
      onChange = _this$props.onChange,
      rules = _this$props.rules,
      name = _this$props.name,
      rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
    return /*#__PURE__*/React.createElement(_DatePicker, _extends({
      className: nextTablePrefix + "date-picker"
    }, field.init(name, {
      rules: rules
    }, rest)));
  };
  return DateField;
}(BaseTableField);
export { DateField as default };