@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
18 lines (17 loc) • 1.06 kB
JavaScript
"use client";
import { isSameMonth } from "../is-same-month/is-same-month.mjs";
import { isAfterMinDate } from "../is-after-min-date/is-after-min-date.mjs";
import { isBeforeMaxDate } from "../is-before-max-date/is-before-max-date.mjs";
import dayjs from "dayjs";
//#region packages/@mantine/dates/src/components/Month/get-date-in-tab-order/get-date-in-tab-order.ts
function getDateInTabOrder({ dates, minDate, maxDate, getDayProps, excludeDate, hideOutsideDates, month }) {
const enabledDates = dates.flat().filter((date) => isBeforeMaxDate(date, maxDate) && isAfterMinDate(date, minDate) && !excludeDate?.(date) && !getDayProps?.(date)?.disabled && (!hideOutsideDates || isSameMonth(date, month)));
const selectedDate = enabledDates.find((date) => getDayProps?.(date)?.selected);
if (selectedDate) return selectedDate;
const currentDate = enabledDates.find((date) => dayjs().isSame(date, "date"));
if (currentDate) return currentDate;
return enabledDates[0];
}
//#endregion
export { getDateInTabOrder };
//# sourceMappingURL=get-date-in-tab-order.mjs.map