"use strict";

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

exports.__esModule = true;
exports.DayRangePicker = void 0;

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

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

var _lodash = _interopRequireDefault(require("lodash"));

require("react-dates/initialize");

var _FormGroup2 = require("../FormGroup");

var _DayRangePickerControl = require("../DateTimePicker/DayRangePickerControl");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _datePickerHelpers = require("./datePickerHelpers");

var DayRangePicker =
/*#__PURE__*/
function (_FormGroup) {
  (0, _inheritsLoose2.default)(DayRangePicker, _FormGroup);

  function DayRangePicker() {
    return _FormGroup.apply(this, arguments) || this;
  }

  var _proto = DayRangePicker.prototype;

  _proto.filterGroupProps = function filterGroupProps(props) {
    return _lodash.default.omit(props, ['ranges', 'startDate', 'endDate', 'valueFormatter', 'maxDate', 'dayPickerProps', 'numberOfMonths', 'inputProps', 'minDate', 'locale']);
  };

  _proto.renderInput = function renderInput(hasError) {
    var ariaDescProps = this.getAriaDescProps(hasError);
    var _this$props = this.props,
        startDate = _this$props.startDate,
        endDate = _this$props.endDate;
    return _react.default.createElement(_DayRangePickerControl.DayRangePickerControl, (0, _extends2.default)({
      startDate: startDate,
      endDate: endDate
    }, this.getSafeProps(this.props), {
      ref: "control",
      hasFormGroupContainer: true
    }, ariaDescProps));
  };

  return DayRangePicker;
}(_FormGroup2.FormGroup);

exports.DayRangePicker = DayRangePicker;
(0, _defineProperty2.default)(DayRangePicker, "propTypes", Object.assign({}, _FormGroup2.FormGroup.propTypes, {
  startDate: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
  endDate: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
  valueFormatter: _propTypes.default.func,
  onChange: _propTypes.default.func,
  numberOfMonths: _propTypes.default.number,
  dayPickerProps: _propTypes.default.object,
  inputProps: _propTypes.default.object,
  ranges: _propTypes.default.object,
  maxDate: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
  minDate: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object])
}));
(0, _defineProperty2.default)(DayRangePicker, "defaultProps", Object.assign({}, _FormGroup2.FormGroup.defaultProps, {
  startDate: null,
  endDate: null,
  testAutomationId: 'datePicker',
  valueFormatter: _datePickerHelpers.dateRangePickerValueFormatter,
  dayPickerProps: {},
  numberOfMonths: 2,
  inputProps: {},
  ranges: null,
  maxDate: null,
  minDate: null
}));