"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _react = _interopRequireWildcard(require("react"));

var _createReactClass = _interopRequireDefault(require("create-react-class"));

var _CalendarHeader = _interopRequireDefault(require("../calendar/CalendarHeader"));

var _DateTable = _interopRequireDefault(require("../date/DateTable"));

var _DateInput = _interopRequireDefault(require("../date/DateInput"));

var _index = require("../util/index");

var CalendarPart = (0, _createReactClass["default"])({
  displayName: "CalendarPart",
  render: function render() {
    var props = this.props;
    var prefixCls = props.prefixCls,
        value = props.value,
        hoverValue = props.hoverValue,
        selectedValue = props.selectedValue,
        mode = props.mode,
        direction = props.direction,
        locale = props.locale,
        format = props.format,
        placeholder = props.placeholder,
        disabledDate = props.disabledDate,
        timePicker = props.timePicker,
        disabledTime = props.disabledTime,
        timePickerDisabledTime = props.timePickerDisabledTime,
        showTimePicker = props.showTimePicker,
        onInputSelect = props.onInputSelect,
        enablePrev = props.enablePrev,
        enableNext = props.enableNext,
        clearIcon = props.clearIcon;
    var shouldShowTimePicker = showTimePicker && timePicker;
    var disabledTimeConfig = shouldShowTimePicker && disabledTime ? (0, _index.getTimeConfig)(selectedValue, disabledTime) : null;
    var rangeClassName = "".concat(prefixCls, "-range");
    var newProps = {
      locale: locale,
      value: value,
      prefixCls: prefixCls,
      showTimePicker: showTimePicker
    };
    var index = direction === 'left' ? 0 : 1;
    var timePickerEle = shouldShowTimePicker && /*#__PURE__*/(0, _react.cloneElement)(timePicker, (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
      showHour: true,
      showMinute: true,
      showSecond: true
    }, timePicker.props), disabledTimeConfig), timePickerDisabledTime), {}, {
      onChange: onInputSelect,
      defaultOpenValue: value,
      value: selectedValue[index]
    }));

    var dateInputElement = props.showDateInput && /*#__PURE__*/_react["default"].createElement(_DateInput["default"], {
      format: format,
      locale: locale,
      prefixCls: prefixCls,
      timePicker: timePicker,
      disabledDate: disabledDate,
      placeholder: placeholder,
      disabledTime: disabledTime,
      value: value,
      showClear: false,
      selectedValue: selectedValue[index],
      onChange: onInputSelect,
      clearIcon: clearIcon
    });

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(rangeClassName, "-part ").concat(rangeClassName, "-").concat(direction)
    }, dateInputElement, /*#__PURE__*/_react["default"].createElement("div", {
      style: {
        outline: 'none'
      }
    }, /*#__PURE__*/_react["default"].createElement(_CalendarHeader["default"], (0, _extends2["default"])({}, newProps, {
      mode: mode,
      enableNext: enableNext,
      enablePrev: enablePrev,
      onValueChange: props.onValueChange,
      onPanelChange: props.onPanelChange,
      disabledMonth: props.disabledMonth
    })), showTimePicker ? /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefixCls, "-time-picker")
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefixCls, "-time-picker-panel")
    }, timePickerEle)) : null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefixCls, "-body")
    }, /*#__PURE__*/_react["default"].createElement(_DateTable["default"], (0, _extends2["default"])({}, newProps, {
      hoverValue: hoverValue,
      selectedValue: selectedValue,
      dateRender: props.dateRender,
      onSelect: props.onSelect,
      onDayHover: props.onDayHover,
      disabledDate: disabledDate,
      showWeekNumber: props.showWeekNumber
    })))));
  }
});
var _default = CalendarPart;
exports["default"] = _default;
//# sourceMappingURL=CalendarPart.js.map
