@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
20 lines (19 loc) • 850 B
JavaScript
"use client";
import { isMonthDisabled } from "../is-month-disabled/is-month-disabled.mjs";
import dayjs from "dayjs";
//#region packages/@mantine/dates/src/components/MonthsList/get-month-in-tab-order/get-month-in-tab-order.ts
function getMonthInTabOrder({ months, minDate, maxDate, getMonthControlProps }) {
const enabledMonths = months.flat().filter((month) => !isMonthDisabled({
month,
minDate,
maxDate
}) && !getMonthControlProps?.(month)?.disabled);
const selectedMonth = enabledMonths.find((month) => getMonthControlProps?.(month)?.selected);
if (selectedMonth) return selectedMonth;
const currentMonth = enabledMonths.find((month) => dayjs().isSame(month, "month"));
if (currentMonth) return currentMonth;
return enabledMonths[0];
}
//#endregion
export { getMonthInTabOrder };
//# sourceMappingURL=get-month-in-tab-order.mjs.map