import { formatDate } from '@transferwise/formatting';
import { PureComponent } from 'react';
import { injectIntl } from 'react-intl';
import messages from '../DateLookup.messages.mjs';
import DateHeader from '../dateHeader/DateHeader.mjs';
import MonthCalendarTable from './table/MonthCalendarTable.mjs';
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';

class MonthCalendar extends 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__*/jsxs(Fragment, {
      children: [/*#__PURE__*/jsx(DateHeader, {
        dateMode: formatMessage(messages.year),
        label: formatDate(new Date(viewYear, 0), locale, {
          year: 'numeric'
        }),
        onLabelClick: onLabelClick,
        onPreviousClick: this.selectPreviousYear,
        onNextClick: this.selectNextYear
      }), /*#__PURE__*/jsx(MonthCalendarTable, {
        selectedDate: selectedDate,
        min: min,
        max: max,
        viewYear: viewYear,
        placeholder: placeholder,
        onSelect: this.onMonthSelect
      })]
    });
  }
}
var MonthCalendar$1 = injectIntl(MonthCalendar);

export { MonthCalendar$1 as default };
//# sourceMappingURL=MonthCalendar.mjs.map
