import _DatePicker from "@alifd/next/es/date-picker2";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React from 'react';
//日期选择器
var CommonDatePicker = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(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.createElement(_DatePicker, {
      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.Component);
CommonDatePicker.displayName = 'CommonDatePicker';
CommonDatePicker.defaultProps = {
  showType: 'Date',
  outputFormat: 'YYYY-MM-DD HH:mm:ss'
};
export default CommonDatePicker;