UNPKG

@mantine/dates

Version:

Calendars, date and time pickers based on Mantine components

95 lines (94 loc) 3.75 kB
"use client"; const require_runtime = require("../../_virtual/_rolldown/runtime.cjs"); const require_handle_control_key_down = require("../../utils/handle-control-key-down/handle-control-key-down.cjs"); const require_MonthLevel = require("../MonthLevel/MonthLevel.cjs"); const require_LevelsGroup = require("../LevelsGroup/LevelsGroup.cjs"); let dayjs = require("dayjs"); dayjs = require_runtime.__toESM(dayjs); let react = require("react"); let react_jsx_runtime = require("react/jsx-runtime"); let _mantine_core = require("@mantine/core"); //#region packages/@mantine/dates/src/components/MonthLevelGroup/MonthLevelGroup.tsx const defaultProps = { numberOfColumns: 1 }; const MonthLevelGroup = (0, _mantine_core.factory)((_props) => { const { month, locale, firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, minDate, maxDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, __onDayClick, __onDayMouseEnter, withCellSpacing, highlightToday, withWeekNumbers, __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, headerControlsOrder, classNames, styles, unstyled, numberOfColumns, levelControlAriaLabel, monthLabelFormat, __staticSelector, __stopPropagation, size, static: isStatic, fullWidth, vars, attributes, ...others } = (0, _mantine_core.useProps)("MonthLevelGroup", defaultProps, _props); const daysRefs = (0, react.useRef)([]); const months = Array(numberOfColumns).fill(0).map((_, monthIndex) => { const currentMonth = (0, dayjs.default)(month).add(monthIndex, "months").format("YYYY-MM-DD"); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MonthLevel.MonthLevel, { month: currentMonth, withNext: monthIndex === numberOfColumns - 1, withPrevious: monthIndex === 0, monthLabelFormat, __stopPropagation, __onDayClick, __onDayMouseEnter, __onDayKeyDown: (event, payload) => require_handle_control_key_down.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, fullWidth, attributes }, monthIndex); }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LevelsGroup.LevelsGroup, { classNames, styles, __staticSelector: __staticSelector || "MonthLevelGroup", size, fullWidth, attributes, ...others, children: months }); }); MonthLevelGroup.classes = { ...require_LevelsGroup.LevelsGroup.classes, ...require_MonthLevel.MonthLevel.classes }; MonthLevelGroup.displayName = "@mantine/dates/MonthLevelGroup"; //#endregion exports.MonthLevelGroup = MonthLevelGroup; //# sourceMappingURL=MonthLevelGroup.cjs.map