"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker2"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireDefault(require("react"));
//日期选择器
var CommonDatePicker = /*#__PURE__*/function (_React$Component) {
  (0, _inheritsLoose2["default"])(CommonDatePicker, _React$Component);
  function CommonDatePicker(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    _this.change = function (val) {
      var onChange = _this.props.onChange;
      onChange && onChange(val);
    };
    _this.state = {
      inputValue: props.value || ''
    };
    return _this;
  }
  var _proto = CommonDatePicker.prototype;
  _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState, snapshot) {
    if (prevProps.value != this.props.value) {
      this.setState({
        inputValue: this.props.value || ''
      });
    }
  };
  _proto.render = function render() {
    var _this2 = this;
    var _this$props = this.props,
      showType = _this$props.showType,
      outputFormat = _this$props.outputFormat,
      defaultValue = _this$props.defaultValue,
      isDisabled = _this$props.isDisabled,
      placeholder = _this$props.placeholder,
      isPreview = _this$props.isPreview;
    return /*#__PURE__*/_react["default"].createElement(_datePicker["default"], {
      hasClear: true,
      format: outputFormat,
      showTime: showType == 'DateTime',
      outputFormat: outputFormat,
      value: this.state.inputValue,
      defaultValue: defaultValue,
      placeholder: placeholder,
      disabled: isDisabled,
      isPreview: isPreview,
      onChange: function onChange(e) {
        return _this2.change(e);
      }
    });
  };
  return CommonDatePicker;
}(_react["default"].Component);
CommonDatePicker.displayName = 'CommonDatePicker';
CommonDatePicker.defaultProps = {
  showType: 'Date',
  outputFormat: 'YYYY-MM-DD HH:mm:ss'
};
var _default = CommonDatePicker;
exports["default"] = _default;