hide range and selections outside currentMonth

This commit is contained in:
Sergio Crisostomo 2018-02-08 11:45:51 +01:00
parent 65ce6cedcb
commit a781ad1a11

View file

@ -73,14 +73,15 @@
return this.calendar(tableYear, tableMonth, (cell) => { return this.calendar(tableYear, tableMonth, (cell) => {
const time = cell.date && clearHours(cell.date); const time = cell.date && clearHours(cell.date);
const dateIsInCurrentMonth = cell.date && tableMonth === cell.date.getMonth();
return { return {
...cell, ...cell,
type: time === today ? 'today' : cell.type, type: time === today ? 'today' : cell.type,
selected: selectedDays.includes(time), selected: dateIsInCurrentMonth && selectedDays.includes(time),
disabled: (cell.date && disabledTestFn) && disabledTestFn(new Date(time)), disabled: (cell.date && disabledTestFn) && disabledTestFn(new Date(time)),
range: isRange && isInRange(time, rangeStart, rangeEnd), range: dateIsInCurrentMonth && isRange && isInRange(time, rangeStart, rangeEnd),
start: isRange && time === minDay, start: dateIsInCurrentMonth && isRange && time === minDay,
end: isRange && time === maxDay end: dateIsInCurrentMonth && isRange && time === maxDay
}; };
}).cells.slice(this.showWeekNumbers ? 8 : 0); }).cells.slice(this.showWeekNumbers ? 8 : 0);
} }