@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
86 lines (85 loc) • 3.44 kB
JavaScript
"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_YearLevel = require("../YearLevel/YearLevel.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/YearLevelGroup/YearLevelGroup.tsx
const defaultProps = { numberOfColumns: 1 };
const YearLevelGroup = (0, _mantine_core.factory)((_props) => {
const { year, locale, minDate, maxDate, monthsListFormat, getMonthControlProps, __onControlClick, __onControlMouseEnter, withCellSpacing, __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, headerControlsOrder, classNames, styles, unstyled, __staticSelector, __stopPropagation, numberOfColumns, levelControlAriaLabel, yearLabelFormat, size, fullWidth, vars, attributes, ...others } = (0, _mantine_core.useProps)("YearLevelGroup", defaultProps, _props);
const controlsRef = (0, react.useRef)([]);
const years = Array(numberOfColumns).fill(0).map((_, yearIndex) => {
const currentYear = (0, dayjs.default)(year).add(yearIndex, "years").format("YYYY-MM-DD");
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_YearLevel.YearLevel, {
size,
monthsListFormat,
year: currentYear,
withNext: yearIndex === numberOfColumns - 1,
withPrevious: yearIndex === 0,
yearLabelFormat,
__stopPropagation,
__onControlClick,
__onControlMouseEnter,
__onControlKeyDown: (event, payload) => require_handle_control_key_down.handleControlKeyDown({
levelIndex: yearIndex,
rowIndex: payload.rowIndex,
cellIndex: payload.cellIndex,
event,
controlsRef
}),
__getControlRef: (rowIndex, cellIndex, node) => {
if (!Array.isArray(controlsRef.current[yearIndex])) controlsRef.current[yearIndex] = [];
if (!Array.isArray(controlsRef.current[yearIndex][rowIndex])) controlsRef.current[yearIndex][rowIndex] = [];
controlsRef.current[yearIndex][rowIndex][cellIndex] = node;
},
levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentYear) : levelControlAriaLabel,
locale,
minDate,
maxDate,
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled,
previousDisabled,
hasNextLevel,
getMonthControlProps,
classNames,
styles,
unstyled,
__staticSelector: __staticSelector || "YearLevelGroup",
withCellSpacing,
headerControlsOrder,
fullWidth,
attributes
}, yearIndex);
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LevelsGroup.LevelsGroup, {
classNames,
styles,
__staticSelector: __staticSelector || "YearLevelGroup",
size,
unstyled,
fullWidth,
attributes,
...others,
children: years
});
});
YearLevelGroup.classes = {
...require_YearLevel.YearLevel.classes,
...require_LevelsGroup.LevelsGroup.classes
};
YearLevelGroup.displayName = "@mantine/dates/YearLevelGroup";
//#endregion
exports.YearLevelGroup = YearLevelGroup;
//# sourceMappingURL=YearLevelGroup.cjs.map