import _extends from "@babel/runtime/helpers/extends";
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import React, { cloneElement } from 'react';
import createReactClass from 'create-react-class';
import CalendarHeader from '../calendar/CalendarHeader';
import DateTable from '../date/DateTable';
import DateInput from '../date/DateInput';
import { getTimeConfig } from '../util/index';
var CalendarPart = createReactClass({
  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 ? 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__*/cloneElement(timePicker, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
      showHour: true,
      showMinute: true,
      showSecond: true
    }, timePicker.props), disabledTimeConfig), timePickerDisabledTime), {}, {
      onChange: onInputSelect,
      defaultOpenValue: value,
      value: selectedValue[index]
    }));
    var dateInputElement = props.showDateInput && /*#__PURE__*/React.createElement(DateInput, {
      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.createElement("div", {
      className: "".concat(rangeClassName, "-part ").concat(rangeClassName, "-").concat(direction)
    }, dateInputElement, /*#__PURE__*/React.createElement("div", {
      style: {
        outline: 'none'
      }
    }, /*#__PURE__*/React.createElement(CalendarHeader, _extends({}, newProps, {
      mode: mode,
      enableNext: enableNext,
      enablePrev: enablePrev,
      onValueChange: props.onValueChange,
      onPanelChange: props.onPanelChange,
      disabledMonth: props.disabledMonth
    })), showTimePicker ? /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-time-picker")
    }, /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-time-picker-panel")
    }, timePickerEle)) : null, /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-body")
    }, /*#__PURE__*/React.createElement(DateTable, _extends({}, newProps, {
      hoverValue: hoverValue,
      selectedValue: selectedValue,
      dateRender: props.dateRender,
      onSelect: props.onSelect,
      onDayHover: props.onDayHover,
      disabledDate: disabledDate,
      showWeekNumber: props.showWeekNumber
    })))));
  }
});
export default CalendarPart;
//# sourceMappingURL=CalendarPart.js.map
