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