"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireDefault(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _baseTableField = _interopRequireDefault(require("./baseTableField"));
var _excluded = ["nextTablePrefix", "value", "onChange", "rules", "name"];
var DateField = /*#__PURE__*/function (_BaseTableField) {
  (0, _inheritsLoose2["default"])(DateField, _BaseTableField);
  function DateField() {
    return _BaseTableField.apply(this, arguments) || this;
  }
  var _proto = DateField.prototype;
  _proto.convertValueToSet = function convertValueToSet(value) {
    return value ? (0, _moment["default"])(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 = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
    return /*#__PURE__*/_react["default"].createElement(_datePicker["default"], (0, _extends2["default"])({
      className: nextTablePrefix + "date-picker"
    }, field.init(name, {
      rules: rules
    }, rest)));
  };
  return DateField;
}(_baseTableField["default"]);
exports["default"] = DateField;