@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
156 lines (150 loc) • 4.21 kB
JavaScript
'use client';
;
var jsxRuntime = require('react/jsx-runtime');
var dayjs = require('dayjs');
var react = require('react');
var core = require('@mantine/core');
var handleControlKeyDown = require('../../utils/handle-control-key-down/handle-control-key-down.cjs');
var LevelsGroup = require('../LevelsGroup/LevelsGroup.cjs');
var MonthLevel = require('../MonthLevel/MonthLevel.cjs');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
const defaultProps = {
numberOfColumns: 1
};
const MonthLevelGroup = core.factory((_props, ref) => {
const props = core.useProps("MonthLevelGroup", defaultProps, _props);
const {
// Month settings
month,
locale,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
__onDayClick,
__onDayMouseEnter,
withCellSpacing,
highlightToday,
withWeekNumbers,
// CalendarHeader settings
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled,
previousDisabled,
hasNextLevel,
headerControlsOrder,
// Other settings
classNames,
styles,
unstyled,
numberOfColumns,
levelControlAriaLabel,
monthLabelFormat,
__staticSelector,
__stopPropagation,
size,
static: isStatic,
vars,
attributes,
...others
} = props;
const daysRefs = react.useRef([]);
const months = Array(numberOfColumns).fill(0).map((_, monthIndex) => {
const currentMonth = dayjs__default.default(month).add(monthIndex, "months").format("YYYY-MM-DD");
return /* @__PURE__ */ jsxRuntime.jsx(
MonthLevel.MonthLevel,
{
month: currentMonth,
withNext: monthIndex === numberOfColumns - 1,
withPrevious: monthIndex === 0,
monthLabelFormat,
__stopPropagation,
__onDayClick,
__onDayMouseEnter,
__onDayKeyDown: (event, payload) => handleControlKeyDown.handleControlKeyDown({
levelIndex: monthIndex,
rowIndex: payload.rowIndex,
cellIndex: payload.cellIndex,
event,
controlsRef: daysRefs
}),
__getDayRef: (rowIndex, cellIndex, node) => {
if (!Array.isArray(daysRefs.current[monthIndex])) {
daysRefs.current[monthIndex] = [];
}
if (!Array.isArray(daysRefs.current[monthIndex][rowIndex])) {
daysRefs.current[monthIndex][rowIndex] = [];
}
daysRefs.current[monthIndex][rowIndex][cellIndex] = node;
},
levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentMonth) : levelControlAriaLabel,
locale,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled,
previousDisabled,
hasNextLevel,
classNames,
styles,
unstyled,
__staticSelector: __staticSelector || "MonthLevelGroup",
size,
static: isStatic,
withCellSpacing,
highlightToday,
withWeekNumbers,
headerControlsOrder,
attributes
},
monthIndex
);
});
return /* @__PURE__ */ jsxRuntime.jsx(
LevelsGroup.LevelsGroup,
{
classNames,
styles,
__staticSelector: __staticSelector || "MonthLevelGroup",
ref,
size,
attributes,
...others,
children: months
}
);
});
MonthLevelGroup.classes = { ...LevelsGroup.LevelsGroup.classes, ...MonthLevel.MonthLevel.classes };
MonthLevelGroup.displayName = "@mantine/dates/MonthLevelGroup";
exports.MonthLevelGroup = MonthLevelGroup;
//# sourceMappingURL=MonthLevelGroup.cjs.map