UNPKG

@mantine/dates

Version:

Calendars, date and time pickers based on Mantine components

84 lines (83 loc) 3.46 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_DecadeLevel = require("../DecadeLevel/DecadeLevel.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/DecadeLevelGroup/DecadeLevelGroup.tsx const defaultProps = { numberOfColumns: 1 }; const DecadeLevelGroup = (0, _mantine_core.factory)((_props) => { const { decade, locale, minDate, maxDate, yearsListFormat, getYearControlProps, __onControlClick, __onControlMouseEnter, withCellSpacing, __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, nextDisabled, previousDisabled, headerControlsOrder, classNames, styles, unstyled, __staticSelector, __stopPropagation, numberOfColumns, levelControlAriaLabel, decadeLabelFormat, size, fullWidth, vars, attributes, ...others } = (0, _mantine_core.useProps)("DecadeLevelGroup", defaultProps, _props); const controlsRef = (0, react.useRef)([]); const decades = Array(numberOfColumns).fill(0).map((_, decadeIndex) => { const currentDecade = (0, dayjs.default)(decade).add(decadeIndex * 10, "years").format("YYYY-MM-DD"); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DecadeLevel.DecadeLevel, { size, yearsListFormat, decade: currentDecade, withNext: decadeIndex === numberOfColumns - 1, withPrevious: decadeIndex === 0, decadeLabelFormat, __onControlClick, __onControlMouseEnter, __onControlKeyDown: (event, payload) => require_handle_control_key_down.handleControlKeyDown({ levelIndex: decadeIndex, rowIndex: payload.rowIndex, cellIndex: payload.cellIndex, event, controlsRef }), __getControlRef: (rowIndex, cellIndex, node) => { if (!Array.isArray(controlsRef.current[decadeIndex])) controlsRef.current[decadeIndex] = []; if (!Array.isArray(controlsRef.current[decadeIndex][rowIndex])) controlsRef.current[decadeIndex][rowIndex] = []; controlsRef.current[decadeIndex][rowIndex][cellIndex] = node; }, levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentDecade) : levelControlAriaLabel, locale, minDate, maxDate, __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, nextDisabled, previousDisabled, getYearControlProps, __staticSelector: __staticSelector || "DecadeLevelGroup", classNames, styles, unstyled, withCellSpacing, headerControlsOrder, fullWidth, attributes }, decadeIndex); }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LevelsGroup.LevelsGroup, { classNames, styles, __staticSelector: __staticSelector || "DecadeLevelGroup", size, unstyled, fullWidth, attributes, ...others, children: decades }); }); DecadeLevelGroup.classes = { ...require_LevelsGroup.LevelsGroup.classes, ...require_DecadeLevel.DecadeLevel.classes }; DecadeLevelGroup.displayName = "@mantine/dates/DecadeLevelGroup"; //#endregion exports.DecadeLevelGroup = DecadeLevelGroup; //# sourceMappingURL=DecadeLevelGroup.cjs.map