25 lines
1.8 KiB
JavaScript
25 lines
1.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.CalendarMonthHeaderRow = void 0;
|
|
var React = require("react");
|
|
var utilities_1 = require("@fluentui/utilities");
|
|
var date_time_utilities_1 = require("@fluentui/date-time-utilities");
|
|
var CalendarMonthHeaderRow = function (props) {
|
|
var showWeekNumbers = props.showWeekNumbers, strings = props.strings, firstDayOfWeek = props.firstDayOfWeek, allFocusable = props.allFocusable, weeksToShow = props.weeksToShow, weeks = props.weeks, classNames = props.classNames;
|
|
var dayLabels = strings.shortDays.slice();
|
|
var firstOfMonthIndex = (0, utilities_1.findIndex)(weeks[1], function (day) { return day.originalDate.getDate() === 1; });
|
|
if (weeksToShow === 1 && firstOfMonthIndex >= 0) {
|
|
// if we only show one week, replace the header with short month name
|
|
var firstOfMonthIndexOffset = (firstOfMonthIndex + firstDayOfWeek) % date_time_utilities_1.DAYS_IN_WEEK;
|
|
dayLabels[firstOfMonthIndexOffset] = strings.shortMonths[weeks[1][firstOfMonthIndex].originalDate.getMonth()];
|
|
}
|
|
return (React.createElement("tr", null,
|
|
showWeekNumbers && React.createElement("th", { className: classNames.dayCell }),
|
|
dayLabels.map(function (val, index) {
|
|
var i = (index + firstDayOfWeek) % date_time_utilities_1.DAYS_IN_WEEK;
|
|
var label = strings.days[i];
|
|
return (React.createElement("th", { className: (0, 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]));
|
|
})));
|
|
};
|
|
exports.CalendarMonthHeaderRow = CalendarMonthHeaderRow;
|
|
//# sourceMappingURL=CalendarMonthHeaderRow.js.map
|