UNPKG

1.86 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.CalendarMonthHeaderRow = void 0;
4var React = require("react");
5var utilities_1 = require("@fluentui/utilities");
6var date_time_utilities_1 = require("@fluentui/date-time-utilities");
7var CalendarMonthHeaderRow = function (props) {
8 var showWeekNumbers = props.showWeekNumbers, strings = props.strings, firstDayOfWeek = props.firstDayOfWeek, allFocusable = props.allFocusable, weeksToShow = props.weeksToShow, weeks = props.weeks, classNames = props.classNames;
9 var dayLabels = strings.shortDays.slice();
10 var firstOfMonthIndex = utilities_1.findIndex(weeks[1], function (day) { return day.originalDate.getDate() === 1; });
11 if (weeksToShow === 1 && firstOfMonthIndex >= 0) {
12 // if we only show one week, replace the header with short month name
13 var firstOfMonthIndexOffset = (firstOfMonthIndex + firstDayOfWeek) % date_time_utilities_1.DAYS_IN_WEEK;
14 dayLabels[firstOfMonthIndexOffset] = strings.shortMonths[weeks[1][firstOfMonthIndex].originalDate.getMonth()];
15 }
16 return (React.createElement("tr", null,
17 showWeekNumbers && React.createElement("th", { className: classNames.dayCell }),
18 dayLabels.map(function (val, index) {
19 var i = (index + firstDayOfWeek) % date_time_utilities_1.DAYS_IN_WEEK;
20 var label = index === firstOfMonthIndex ? strings.days[i] + ' ' + dayLabels[i] : strings.days[i];
21 return (React.createElement("th", { className: utilities_1.css(classNames.dayCell, classNames.weekDayLabelCell), scope: "col", key: dayLabels[i] + ' ' + index, title: label, "aria-label": label, "data-is-focusable": allFocusable ? true : undefined }, dayLabels[i]));
22 })));
23};
24exports.CalendarMonthHeaderRow = CalendarMonthHeaderRow;
25//# sourceMappingURL=CalendarMonthHeaderRow.js.map
\No newline at end of file