'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var formatting = require('@transferwise/formatting');
var React = require('react');
var reactIntl = require('react-intl');
var DateLookup_messages = require('../DateLookup.messages.js');
var DateHeader = require('../dateHeader/DateHeader.js');
var MonthCalendarTable = require('./table/MonthCalendarTable.js');
var jsxRuntime = require('react/jsx-runtime');

let MonthCalendar$1 = class MonthCalendar extends React.PureComponent {
  onMonthSelect = month => {
    this.props.onViewDateUpdate({
      month
    });
    this.props.onSelect();
  };
  selectPreviousYear = () => {
    this.props.onViewDateUpdate({
      year: this.props.viewYear - 1
    });
  };
  selectNextYear = () => {
    this.props.onViewDateUpdate({
      year: this.props.viewYear + 1
    });
  };
  render() {
    const {
      selectedDate,
      min,
      max,
      viewYear,
      intl: {
        locale,
        formatMessage
      },
      placeholder,
      onLabelClick
    } = this.props;
    return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
      children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader.default, {
        dateMode: formatMessage(DateLookup_messages.default.year),
        label: formatting.formatDate(new Date(viewYear, 0), locale, {
          year: 'numeric'
        }),
        onLabelClick: onLabelClick,
        onPreviousClick: this.selectPreviousYear,
        onNextClick: this.selectNextYear
      }), /*#__PURE__*/jsxRuntime.jsx(MonthCalendarTable.default, {
        selectedDate: selectedDate,
        min: min,
        max: max,
        viewYear: viewYear,
        placeholder: placeholder,
        onSelect: this.onMonthSelect
      })]
    });
  }
};
var MonthCalendar = reactIntl.injectIntl(MonthCalendar$1);

exports.default = MonthCalendar;
//# sourceMappingURL=MonthCalendar.js.map
