function onDayClick(day, e) {
if (e) e.preventDefault();
if (this.isBlocked(day)) return;
var _props2 = this.props,
onDateChange = _props2.onDateChange,
keepOpenOnDateSelect = _props2.keepOpenOnDateSelect,
onFocusChange = _props2.onFocusChange,
onClose = _props2.onClose;
if (!keepOpenOnDateSelect) {
onFocusChange({ focused: false });
function onDayMouseEnter(day) {
if (this.isTouchDevice) return;
hoverDate = _state.hoverDate,
visibleDays = _state.visibleDays;
var modifiers = this.deleteModifier({}, hoverDate, 'hovered');
modifiers = this.addModifier(modifiers, day, 'hovered');
visibleDays: (0, _object2['default'])({}, visibleDays, modifiers)
function onDayMouseLeave() {
var _state2 = this.state,
hoverDate = _state2.hoverDate,
visibleDays = _state2.visibleDays;
if (this.isTouchDevice || !hoverDate) return;
var modifiers = this.deleteModifier({}, hoverDate, 'hovered');
visibleDays: (0, _object2['default'])({}, visibleDays, modifiers)
function onPrevMonthClick() {
var _props3 = this.props,
onPrevMonthClick = _props3.onPrevMonthClick,
numberOfMonths = _props3.numberOfMonths,
enableOutsideDays = _props3.enableOutsideDays;
var _state3 = this.state,
currentMonth = _state3.currentMonth,
visibleDays = _state3.visibleDays;
Object.keys(visibleDays).sort().slice(0, numberOfMonths + 1).forEach(function (month) {
newVisibleDays[month] = visibleDays[month];
var prevMonth = currentMonth.clone().subtract(1, 'month');
var prevMonthVisibleDays = (0, _getVisibleDays2['default'])(prevMonth, 1, enableOutsideDays);
visibleDays: (0, _object2['default'])({}, newVisibleDays, this.getModifiers(prevMonthVisibleDays))
onPrevMonthClick(prevMonth.clone());
function onNextMonthClick() {
var _props4 = this.props,
onNextMonthClick = _props4.onNextMonthClick,
numberOfMonths = _props4.numberOfMonths,
enableOutsideDays = _props4.enableOutsideDays;
var _state4 = this.state,
currentMonth = _state4.currentMonth,
visibleDays = _state4.visibleDays;
Object.keys(visibleDays).sort().slice(1).forEach(function (month) {
newVisibleDays[month] = visibleDays[month];
var nextMonth = currentMonth.clone().add(numberOfMonths, 'month');
var nextMonthVisibleDays = (0, _getVisibleDays2['default'])(nextMonth, 1, enableOutsideDays);
var newCurrentMonth = currentMonth.clone().add(1, 'month');
currentMonth: newCurrentMonth,
visibleDays: (0, _object2['default'])({}, newVisibleDays, this.getModifiers(nextMonthVisibleDays))
onNextMonthClick(newCurrentMonth.clone());
function onMonthChange(newMonth) {
var _props5 = this.props,
numberOfMonths = _props5.numberOfMonths,
enableOutsideDays = _props5.enableOutsideDays,
orientation = _props5.orientation;
var withoutTransitionMonths = orientation === _constants.VERTICAL_SCROLLABLE;
var newVisibleDays = (0, _getVisibleDays2['default'])(newMonth, numberOfMonths, enableOutsideDays, withoutTransitionMonths);
currentMonth: newMonth.clone(),
visibleDays: this.getModifiers(newVisibleDays)
function onYearChange(newMonth) {
var _props6 = this.props,
numberOfMonths = _props6.numberOfMonths,
enableOutsideDays = _props6.enableOutsideDays,
orientation = _props6.orientation;
var withoutTransitionMonths = orientation === _constants.VERTICAL_SCROLLABLE;
var newVisibleDays = (0, _getVisibleDays2['default'])(newMonth, numberOfMonths, enableOutsideDays, withoutTransitionMonths);
currentMonth: newMonth.clone(),
visibleDays: this.getModifiers(newVisibleDays)
key: 'getFirstFocusableDay',
function getFirstFocusableDay(newMonth) {
var _props7 = this.props,
numberOfMonths = _props7.numberOfMonths;
var focusedDate = newMonth.clone().startOf('month');
focusedDate = date.clone();
if (this.isBlocked(focusedDate)) {
var lastVisibleDay = newMonth.clone().add(numberOfMonths - 1, 'months').endOf('month');
var currentDay = focusedDate.clone();
while (!(0, _isAfterDay2['default'])(currentDay, lastVisibleDay)) {
currentDay = currentDay.clone().add(1, 'day');
var viableDays = days.filter(function (day) {
return !_this3.isBlocked(day) && (0, _isAfterDay2['default'])(day, focusedDate);
if (viableDays.length > 0) {
var _viableDays = _slicedToArray(viableDays, 1);
focusedDate = _viableDays[0];
return getFirstFocusableDay;
function getModifiers(visibleDays) {
Object.keys(visibleDays).forEach(function (month) {
visibleDays[month].forEach(function (day) {
modifiers[month][(0, _toISODateString2['default'])(day)] = _this4.getModifiersForDay(day);
key: 'getModifiersForDay',
function getModifiersForDay(day) {
return new Set(Object.keys(this.modifiers).filter(function (modifier) {
return _this5.modifiers[modifier](day);
return getModifiersForDay;
key: 'getStateForNewMonth',
function getStateForNewMonth(nextProps) {
var initialVisibleMonth = nextProps.initialVisibleMonth,
numberOfMonths = nextProps.numberOfMonths,
enableOutsideDays = nextProps.enableOutsideDays;
var initialVisibleMonthThunk = initialVisibleMonth || (date ? function () {
var currentMonth = initialVisibleMonthThunk();
var visibleDays = this.getModifiers((0, _getVisibleDays2['default'])(currentMonth, numberOfMonths, enableOutsideDays));
return { currentMonth: currentMonth, visibleDays: visibleDays };
return getStateForNewMonth;
function addModifier(updatedDays, day, modifier) {
var _props8 = this.props,
numberOfVisibleMonths = _props8.numberOfMonths,
enableOutsideDays = _props8.enableOutsideDays,
orientation = _props8.orientation;
var _state5 = this.state,
firstVisibleMonth = _state5.currentMonth,
visibleDays = _state5.visibleDays;
var currentMonth = firstVisibleMonth;
var numberOfMonths = numberOfVisibleMonths;
if (orientation === _constants.VERTICAL_SCROLLABLE) {
numberOfMonths = Object.keys(visibleDays).length;
currentMonth = currentMonth.clone().subtract(1, 'month');
if (!day || !(0, _isDayVisible2['default'])(day, currentMonth, numberOfMonths, enableOutsideDays)) {
var iso = (0, _toISODateString2['default'])(day);
var updatedDaysAfterAddition = (0, _object2['default'])({}, updatedDays);
var monthsToUpdate = Object.keys(visibleDays).filter(function (monthKey) {
return Object.keys(visibleDays[monthKey]).indexOf(iso) > -1;
updatedDaysAfterAddition = monthsToUpdate.reduce(function (days, monthIso) {
var month = updatedDays[monthIso] || visibleDays[monthIso];
var modifiers = new Set(month[iso]);
return (0, _object2['default'])({}, days, _defineProperty({}, monthIso, (0, _object2['default'])({}, month, _defineProperty({}, iso, modifiers))));
}, updatedDaysAfterAddition);
var monthIso = (0, _toISOMonthString2['default'])(day);
var month = updatedDays[monthIso] || visibleDays[monthIso];
var modifiers = new Set(month[iso]);
updatedDaysAfterAddition = (0, _object2['default'])({}, updatedDaysAfterAddition, _defineProperty({}, monthIso, (0, _object2['default'])({}, month, _defineProperty({}, iso, modifiers))));
return updatedDaysAfterAddition;
function deleteModifier(updatedDays, day, modifier) {
var _props9 = this.props,
numberOfVisibleMonths = _props9.numberOfMonths,
enableOutsideDays = _props9.enableOutsideDays,
orientation = _props9.orientation;
var _state6 = this.state,
firstVisibleMonth = _state6.currentMonth,
visibleDays = _state6.visibleDays;
var currentMonth = firstVisibleMonth;
var numberOfMonths = numberOfVisibleMonths;
if (orientation === _constants.VERTICAL_SCROLLABLE) {
numberOfMonths = Object.keys(visibleDays).length;
currentMonth = currentMonth.clone().subtract(1, 'month');
if (!day || !(0, _isDayVisible2['default'])(day, currentMonth, numberOfMonths, enableOutsideDays)) {
var iso = (0, _toISODateString2['default'])(day);
var updatedDaysAfterDeletion = (0, _object2['default'])({}, updatedDays);
var monthsToUpdate = Object.keys(visibleDays).filter(function (monthKey) {
return Object.keys(visibleDays[monthKey]).indexOf(iso) > -1;
updatedDaysAfterDeletion = monthsToUpdate.reduce(function (days, monthIso) {
var month = updatedDays[monthIso] || visibleDays[monthIso];
var modifiers = new Set(month[iso]);
modifiers['delete'](modifier);
return (0, _object2['default'])({}, days, _defineProperty({}, monthIso, (0, _object2['default'])({}, month, _defineProperty({}, iso, modifiers))));
}, updatedDaysAfterDeletion);
var monthIso = (0, _toISOMonthString2['default'])(day);
var month = updatedDays[monthIso] || visibleDays[monthIso];
var modifiers = new Set(month[iso]);
modifiers['delete'](modifier);
updatedDaysAfterDeletion = (0, _object2['default'])({}, updatedDaysAfterDeletion, _defineProperty({}, monthIso, (0, _object2['default'])({}, month, _defineProperty({}, iso, modifiers))));
return updatedDaysAfterDeletion;
function isBlocked(day) {
var _props10 = this.props,
isDayBlocked = _props10.isDayBlocked,
isOutsideRange = _props10.isOutsideRange;
return isDayBlocked(day) || isOutsideRange(day);
function isHovered(day) {
var _ref = this.state || {},
hoverDate = _ref.hoverDate;
return (0, _isSameDay2['default'])(day, hoverDate);
function isSelected(day) {
var date = this.props.date;
return (0, _isSameDay2['default'])(day, date);
return (0, _isSameDay2['default'])(day, this.today);
function isFirstDayOfWeek(day) {
var firstDayOfWeek = this.props.firstDayOfWeek;
return day.day() === (firstDayOfWeek || _moment2['default'].localeData().firstDayOfWeek());
function isLastDayOfWeek(day) {
var firstDayOfWeek = this.props.firstDayOfWeek;
return day.day() === ((firstDayOfWeek || _moment2['default'].localeData().firstDayOfWeek()) + 6) % 7;
var _props11 = this.props,
numberOfMonths = _props11.numberOfMonths,
orientation = _props11.orientation,
monthFormat = _props11.monthFormat,
renderMonthText = _props11.renderMonthText,
navPrev = _props11.navPrev,
navNext = _props11.navNext,
onOutsideClick = _props11.onOutsideClick,
withPortal = _props11.withPortal,
focused = _props11.focused,
enableOutsideDays = _props11.enableOutsideDays,
hideKeyboardShortcutsPanel = _props11.hideKeyboardShortcutsPanel,
daySize = _props11.daySize,
firstDayOfWeek = _props11.firstDayOfWeek,
renderCalendarDay = _props11.renderCalendarDay,
renderDayContents = _props11.renderDayContents,
renderCalendarInfo = _props11.renderCalendarInfo,
renderMonthElement = _props11.renderMonthElement,
calendarInfoPosition = _props11.calendarInfoPosition,
isFocused = _props11.isFocused,
phrases = _props11.phrases,
dayAriaLabelFormat = _props11.dayAriaLabelFormat,
onBlur = _props11.onBlur,
showKeyboardShortcuts = _props11.showKeyboardShortcuts,
weekDayFormat = _props11.weekDayFormat,
verticalHeight = _props11.verticalHeight,
noBorder = _props11.noBorder,
transitionDuration = _props11.transitionDuration,
verticalBorderSpacing = _props11.verticalBorderSpacing,
horizontalMonthPadding = _props11.horizontalMonthPadding;
var _state7 = this.state,
currentMonth = _state7.currentMonth,
visibleDays = _state7.visibleDays;
return _react2['default'].createElement(_DayPicker2['default'], {
orientation: orientation,
enableOutsideDays: enableOutsideDays,
numberOfMonths: numberOfMonths,
onDayClick: this.onDayClick,
onDayMouseEnter: this.onDayMouseEnter,
onDayMouseLeave: this.onDayMouseLeave,
onPrevMonthClick: this.onPrevMonthClick,
onNextMonthClick: this.onNextMonthClick,
onMonthChange: this.onMonthChange,
onYearChange: this.onYearChange,
monthFormat: monthFormat,
hideKeyboardShortcutsPanel: hideKeyboardShortcutsPanel,
initialVisibleMonth: function () {
function initialVisibleMonth() {
return initialVisibleMonth;
firstDayOfWeek: firstDayOfWeek,
onOutsideClick: onOutsideClick,