ngx-bootstrap
Version:
Native Angular Bootstrap Components
30 lines • 1.64 kB
JavaScript
import { isSameMonth } from '../../chronos/utils/date-getters';
import { isMonthDisabled, isYearDisabled } from '../utils/bs-calendar-utils';
import { shiftDate } from '../../chronos/utils/date-setters';
export function flagMonthsCalendar(monthCalendar, options) {
monthCalendar.months.forEach(function (months, rowIndex) {
months.forEach(function (month, monthIndex) {
var isHovered = isSameMonth(month.date, options.hoveredMonth);
var isDisabled = options.isDisabled ||
isMonthDisabled(month.date, options.minDate, options.maxDate);
var newMonth = Object.assign(/*{},*/ month, {
isHovered: isHovered,
isDisabled: isDisabled
});
if (month.isHovered !== newMonth.isHovered ||
month.isDisabled !== newMonth.isDisabled) {
monthCalendar.months[rowIndex][monthIndex] = newMonth;
}
});
});
// todo: add check for linked calendars
monthCalendar.hideLeftArrow =
options.monthIndex > 0 && options.monthIndex !== options.displayMonths;
monthCalendar.hideRightArrow =
options.monthIndex < options.displayMonths &&
options.monthIndex + 1 !== options.displayMonths;
monthCalendar.disableLeftArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: -1 }), options.minDate, options.maxDate);
monthCalendar.disableRightArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: 1 }), options.minDate, options.maxDate);
return monthCalendar;
}
//# sourceMappingURL=flag-months-calendar.js.map