@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
649 lines (645 loc) • 24.5 kB
JavaScript
"use client";
import { createContext as createContext$1 } from "../../utils/context.js";
import { runKeyAction, visuallyHiddenAttributes } from "../../utils/dom.js";
import { useUpdateEffect } from "../../utils/effect.js";
import { mergeRefs } from "../../utils/ref.js";
import { utils_exports } from "../../utils/index.js";
import { useSplitProps } from "../../core/components/props.js";
import { useControllableState } from "../../hooks/use-controllable-state/index.js";
import { createDescendants } from "../../hooks/use-descendants/index.js";
import { useI18n } from "../../providers/i18n-provider/i18n-provider.js";
import { useDateTimeFormat } from "../format/use-format-date-time.js";
import { useCallback, useMemo, useRef } from "react";
import dayjs from "dayjs";
//#region src/components/calendar/use-calendar.ts
const DEFAULT_HOLIDAYS = [];
const DEFAULT_WEEKEND_DAYS = [0, 6];
const DEFAULT_FIRST_DAY_OF_WEEK = "sunday";
const DEFAULT_MAX_DATE = /* @__PURE__ */ new Date("2099-12-31");
const DEFAULT_MIN_DATE = /* @__PURE__ */ new Date("1900-01-01");
const getStartOfWeek = (date, startDayOfWeek) => dayjs(date).subtract(startDayOfWeek === "monday" ? 1 : 0, "day").startOf("week").add(startDayOfWeek === "monday" ? 1 : 0, "day").toDate();
const getEndOfWeek = (date, startDayOfWeek) => dayjs(date).subtract(startDayOfWeek === "monday" ? 1 : 0, "day").endOf("week").add(startDayOfWeek === "monday" ? 1 : 0, "day").toDate();
const getWeekdays = (startDayOfWeek, format) => {
let weekdays = [];
const date = getStartOfWeek(/* @__PURE__ */ new Date(), startDayOfWeek);
for (let i = 0; i < 7; i += 1) {
const label = format(date);
const value = date.getDay();
weekdays = [...weekdays, {
label,
value
}];
date.setDate(date.getDate() + 1);
}
return weekdays;
};
const getMonthDays = (date, startDayOfWeek, format) => {
const currentMonth = date.getMonth();
const startOfMonth = new Date(date.getFullYear(), currentMonth, 1);
const endOfMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0);
const startDate = getStartOfWeek(startOfMonth, startDayOfWeek);
const endDate = getEndOfWeek(endOfMonth, startDayOfWeek);
const weeks = [];
while (startDate <= endDate) {
const days = [];
for (let i = 0; i < 7; i += 1) {
const value = new Date(startDate);
const label = format(value);
days.push({
label,
value
});
startDate.setDate(startDate.getDate() + 1);
}
weeks.push(days);
}
return weeks;
};
const isSameYear = (date, comparison) => date instanceof Date && comparison instanceof Date && dayjs(date).isSame(comparison, "year");
const isSameMonth = (date, comparison) => date instanceof Date && comparison instanceof Date && dayjs(date).isSame(comparison, "month");
const isSameDate = (date, comparison) => date instanceof Date && comparison instanceof Date && dayjs(date).isSame(comparison, "date");
const isAfterDate = (value, date) => date instanceof Date && dayjs(value).isAfter(date, "date");
const isBeforeDate = (value, date) => date instanceof Date && dayjs(value).isBefore(date, "date");
const isSameAfterDate = (value, date) => date instanceof Date && (dayjs(date).isSame(value, "date") || dayjs(value).isAfter(date, "date"));
const isSameBeforeDate = (value, date) => date instanceof Date && (dayjs(date).isSame(value, "date") || dayjs(value).isBefore(date, "date"));
const isAfterMonth = (value, date) => date instanceof Date && dayjs(value).isAfter(date, "month");
const isBeforeMonth = (value, date) => date instanceof Date && dayjs(value).isBefore(date, "month");
const isSameAfterMonth = (value, date) => date instanceof Date && (dayjs(date).isSame(value, "month") || dayjs(value).isAfter(date, "month"));
const isSameBeforeMonth = (value, date) => date instanceof Date && (dayjs(date).isSame(value, "month") || dayjs(value).isBefore(date, "month"));
const isAfterYear = (value, date) => date instanceof Date && dayjs(value).isAfter(date, "year");
const isBeforeYear = (value, date) => date instanceof Date && dayjs(value).isBefore(date, "year");
const isSameAfterYear = (value, date) => date instanceof Date && (dayjs(date).isSame(value, "year") || dayjs(value).isAfter(date, "year"));
const isSameBeforeYear = (value, date) => date instanceof Date && (dayjs(date).isSame(value, "year") || dayjs(value).isBefore(date, "year"));
const isIncludeDates = (comparison, dates) => dates.some((date) => dayjs(date).isSame(comparison, "date"));
const isInRange = (date, minDate, maxDate) => {
const hasMinDate = minDate instanceof Date;
const hasMaxDate = maxDate instanceof Date;
if (!hasMaxDate && !hasMinDate) return false;
const minInRange = hasMinDate ? isAfterDate(date, minDate) : false;
return (hasMaxDate ? isBeforeDate(date, maxDate) : false) && minInRange;
};
const sortDates = (dates, type = "asc") => {
if (type === "asc") return dates.sort((a, b) => dayjs(a).isAfter(b, "date") ? 1 : -1);
else return dates.sort((a, b) => dayjs(a).isBefore(b, "date") ? 1 : -1);
};
const updateMaybeDateValue = (value, max) => (prev) => {
if ((0, utils_exports.isArray)(prev)) if (isIncludeDates(value, prev)) return prev.filter((prevValue) => !isSameDate(prevValue, value));
else if (!(0, utils_exports.isNumber)(max) || prev.length < max) return [...prev, value];
else return prev;
else if ((0, utils_exports.isObject)(prev) && !(0, utils_exports.isDate)(prev)) {
const { end, start } = prev;
if (start && end || !start) return {
end: void 0,
start: value
};
else if (isSameDate(start, value)) return {
end: void 0,
start: void 0
};
else if (isBeforeDate(value, start)) return {
end: start,
start: value
};
else return {
end: value,
start
};
} else if (isSameDate(prev, value)) return;
else return value;
};
const getAdjustedMonth = (value, month) => {
if ((0, utils_exports.isDate)(value)) {
if (!isSameMonth(value, month)) month = dayjs(value).set("date", 1).toDate();
} else if ((0, utils_exports.isArray)(value)) {
const lastValue = value.at(-1);
if (lastValue && !isSameMonth(lastValue, month)) month = dayjs(lastValue).set("date", 1).toDate();
} else if ((0, utils_exports.isObject)(value)) {
if (value.end) month = dayjs(value.end).set("date", 1).toDate();
else if (value.start) month = dayjs(value.start).set("date", 1).toDate();
}
return month;
};
const { DescendantsContext: CalendarDescendantsContext, useDescendant: useCalendarDescendant, useDescendants: useCalendarDescendants } = createDescendants();
const [CalendarContext, useCalendarContext] = createContext$1({ name: "CalendarContext" });
const useCalendar = ({ defaultMonth = /* @__PURE__ */ new Date(), multiple = false, range = false, defaultValue = range ? {
end: void 0,
start: void 0
} : multiple ? [] : void 0, disabled = false, excludeDate, format = {}, holidays = DEFAULT_HOLIDAYS, locale: localeProp, max, maxDate = DEFAULT_MAX_DATE, minDate = DEFAULT_MIN_DATE, month: monthProp, startDayOfWeek = DEFAULT_FIRST_DAY_OF_WEEK, today = true, value: valueProp, weekendDays = DEFAULT_WEEKEND_DAYS, onChange: onChangeProp, onChangeMonth: onChangeMonthProp,...rest } = {}) => {
if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate;
const { locale: defaultLocale, t } = useI18n("calendar");
const locale = localeProp ?? defaultLocale;
const dateTimeFormat = useDateTimeFormat({ locale });
const yearFormat = useCallback((value$1) => {
if (format.year === null) return value$1.getFullYear().toString();
else return dateTimeFormat(value$1, { year: format.year ?? "numeric" });
}, [dateTimeFormat, format.year]);
const monthFormat = useCallback((value$1) => {
if (format.month === null) return (value$1.getMonth() + 1).toString();
else return dateTimeFormat(value$1, { month: format.month ?? "short" });
}, [dateTimeFormat, format.month]);
const weekdayFormat = useCallback((value$1) => {
return dateTimeFormat(value$1, { weekday: format.weekday ?? "short" });
}, [dateTimeFormat, format.weekday]);
const dayFormat = useCallback((value$1) => {
if (format.day) return dateTimeFormat(value$1, { day: format.day });
else return value$1.getDate().toString();
}, [dateTimeFormat, format.day]);
const descendants = useCalendarDescendants();
const monthRef = useRef(null);
const [value, setValue] = useControllableState({
defaultValue,
value: valueProp,
onChange: onChangeProp
});
const [month, setMonth] = useControllableState({
defaultValue: () => {
if (dayjs(minDate).isAfter(dayjs(defaultMonth))) defaultMonth = dayjs(minDate).set("date", 1).toDate();
if (valueProp) defaultMonth = getAdjustedMonth(valueProp, defaultMonth);
else if (defaultValue) defaultMonth = getAdjustedMonth(defaultValue, defaultMonth);
return defaultMonth;
},
value: monthProp,
onChange: onChangeMonthProp
});
const { endOfMonth, startOfMonth } = useMemo(() => {
const startOfMonth$1 = dayjs(month).startOf("month").toDate();
return {
endOfMonth: dayjs(month).endOf("month").toDate(),
startOfMonth: startOfMonth$1
};
}, [month]);
const weekdays = useMemo(() => getWeekdays(startDayOfWeek, weekdayFormat), [startDayOfWeek, weekdayFormat]);
const monthDays = useMemo(() => getMonthDays(month, startDayOfWeek, dayFormat), [
month,
startDayOfWeek,
dayFormat
]);
const yearItems = useMemo(() => {
const minYear = dayjs(minDate).year();
const maxYear = dayjs(maxDate).year();
const yearItems$1 = [];
for (let year = minYear; year <= maxYear; year++) {
const label = yearFormat(dayjs().set("year", year).toDate());
const value$1 = year.toString();
yearItems$1.push({
label,
value: value$1
});
}
return yearItems$1;
}, [
maxDate,
minDate,
yearFormat
]);
const monthItems = useMemo(() => {
const monthItems$1 = [];
const date = dayjs(month).toDate();
for (let month$1 = 0; month$1 < 12; month$1++) {
date.setMonth(month$1);
if (isAfterMonth(date, maxDate)) continue;
if (isBeforeMonth(date, minDate)) continue;
const label = monthFormat(dayjs().set("month", month$1).toDate());
const value$1 = month$1.toString();
monthItems$1.push({
label,
value: value$1
});
}
return monthItems$1;
}, [
month,
maxDate,
minDate,
monthFormat
]);
const onChange = useCallback((value$1) => {
if (isBeforeDate(value$1, minDate)) return;
if (isAfterDate(value$1, maxDate)) return;
setValue((prev) => updateMaybeDateValue(value$1, max)(prev));
}, [
max,
maxDate,
minDate,
setValue
]);
const onMonthChange = useCallback((month$1) => {
if (isAfterMonth(month$1, maxDate)) setMonth(dayjs(maxDate).set("date", 1).toDate());
else if (isBeforeMonth(month$1, minDate)) setMonth(dayjs(minDate).set("date", 1).toDate());
else setMonth((prev) => {
if (isSameMonth(prev, month$1)) return prev;
return month$1;
});
}, [
maxDate,
minDate,
setMonth
]);
const onPrevMonth = useCallback(() => {
setMonth((prev) => {
if (isSameMonth(prev, minDate)) return prev;
return dayjs(prev).subtract(1, "month").toDate();
});
}, [minDate, setMonth]);
const onNextMonth = useCallback(() => {
setMonth((prev) => {
if (isSameMonth(prev, maxDate)) return prev;
return dayjs(prev).add(1, "month").toDate();
});
}, [maxDate, setMonth]);
const onFocus = useCallback(() => {
let index = null;
let descendant;
if (value) {
if ((0, utils_exports.isDate)(value)) {
if (isSameMonth(month, /* @__PURE__ */ new Date())) index = (/* @__PURE__ */ new Date()).getDate() - 1;
} else if ((0, utils_exports.isArray)(value)) {
const firstValue = value[0];
if (firstValue && isSameMonth(month, firstValue)) index = firstValue.getDate() - 1;
} else if ((0, utils_exports.isObject)(value)) {
if (value.start && isSameMonth(month, value.start)) index = value.start.getDate() - 1;
else if (value.end && isSameMonth(month, value.end)) index = value.end.getDate() - 1;
}
} else if (isSameMonth(month, /* @__PURE__ */ new Date())) index = (/* @__PURE__ */ new Date()).getDate() - 1;
descendant = descendants.value(index);
if (!descendant) descendant = descendants.enabledFirstValue();
if (!descendant) return;
descendant.node.focus();
descendant.node.tabIndex = 0;
if (monthRef.current) monthRef.current.tabIndex = -1;
}, [
descendants,
month,
value
]);
const onBlur = useCallback((ev) => {
if ((0, utils_exports.contains)(monthRef.current, ev.relatedTarget)) return;
if (monthRef.current) monthRef.current.tabIndex = 0;
}, []);
useUpdateEffect(() => {
setMonth((prev) => getAdjustedMonth(value, prev));
}, [value]);
const getRootProps = useCallback((props = {}) => ({
"data-disabled": (0, utils_exports.dataAttr)(disabled),
...rest,
...props
}), [disabled, rest]);
const getNavigationProps = useCallback((props = {}) => ({
"data-disabled": (0, utils_exports.dataAttr)(disabled),
...props
}), [disabled]);
const getYearSelectProps = useCallback((props = {}) => ({
"aria-label": t("Choose the year"),
disabled,
value: dayjs(month).get("year").toString(),
...props,
onChange: (0, utils_exports.handlerAll)(props.onChange, (value$1) => onMonthChange(dayjs(month).set("year", parseInt(value$1)).toDate()))
}), [
disabled,
month,
onMonthChange,
t
]);
const getMonthSelectProps = useCallback((props = {}) => ({
"aria-label": t("Choose the month"),
disabled,
value: dayjs(month).get("month").toString(),
...props,
onChange: (0, utils_exports.handlerAll)(props.onChange, (value$1) => onMonthChange(dayjs(month).set("month", parseInt(value$1)).toDate()))
}), [
disabled,
month,
onMonthChange,
t
]);
const getStatusProps = useCallback((props = {}) => ({
style: visuallyHiddenAttributes.style,
"aria-live": "polite",
children: dateTimeFormat(dayjs(month).toDate(), {
month: "long",
year: "numeric"
}),
role: "status",
...props
}), [dateTimeFormat, month]);
const getMonthProps = useCallback(({ ref,...props } = {}) => ({
ref: mergeRefs(ref, monthRef),
"aria-label": dateTimeFormat(dayjs(month).toDate(), {
month: "long",
year: "numeric"
}),
"aria-multiselectable": (0, utils_exports.ariaAttr)(multiple || range),
"data-disabled": (0, utils_exports.dataAttr)(disabled),
role: "grid",
tabIndex: disabled ? -1 : 0,
...props,
onBlur: (0, utils_exports.handlerAll)(props.onBlur, onBlur),
onFocus: (0, utils_exports.handlerAll)(props.onFocus, onFocus)
}), [
dateTimeFormat,
disabled,
month,
multiple,
onBlur,
onFocus,
range
]);
const getWeekdayProps = useCallback(({ value: value$1,...props }) => ({
"data-disabled": (0, utils_exports.dataAttr)(disabled),
"data-value": value$1.toString(),
abbr: dateTimeFormat(dayjs().set("day", value$1).toDate(), { weekday: "long" }),
...props
}), [dateTimeFormat, disabled]);
const getButtonProps = useCallback((props) => ({
type: "button",
"data-disabled": (0, utils_exports.dataAttr)(disabled),
...props
}), [disabled]);
const getPrevButtonProps = useCallback((props = {}) => getButtonProps({
"aria-label": t("Go to the previous month"),
disabled: isSameBeforeMonth(month, minDate),
...props,
onClick: (0, utils_exports.handlerAll)(props.onClick, onPrevMonth)
}), [
getButtonProps,
minDate,
month,
onPrevMonth,
t
]);
const getNextButtonProps = useCallback((props = {}) => getButtonProps({
"aria-label": t("Go to the next month"),
disabled: isSameAfterMonth(month, maxDate),
...props,
onClick: (0, utils_exports.handlerAll)(props.onClick, onNextMonth)
}), [
getButtonProps,
maxDate,
month,
onNextMonth,
t
]);
return {
descendants,
disabled,
endOfMonth,
excludeDate,
holidays,
locale,
max,
maxDate,
minDate,
month,
monthDays,
monthItems,
multiple,
range,
startDayOfWeek,
startOfMonth,
today,
value,
weekdays,
weekendDays,
yearItems,
getMonthProps,
getMonthSelectProps,
getNavigationProps,
getNextButtonProps,
getPrevButtonProps,
getRootProps,
getStatusProps,
getWeekdayProps,
getYearSelectProps,
onChange,
onMonthChange,
onNextMonth,
onPrevMonth
};
};
const useCalendarDay = ({ value,...rest }) => {
const { t } = useI18n("calendar");
const { disabled: rootDisabled, excludeDate, holidays, locale, max, maxDate, minDate, month, startDayOfWeek, today: highlightToday, value: selectedValue, weekendDays, onChange, onMonthChange, onNextMonth, onPrevMonth } = useCalendarContext();
const dateTimeFormat = useDateTimeFormat({ locale });
const cellRef = useRef(null);
const outside = useMemo(() => !isSameMonth(month, value), [month, value]);
const holiday = useMemo(() => holidays.some((holiday$1) => isSameDate(holiday$1, value)), [holidays, value]);
const weekend = useMemo(() => weekendDays.includes(value.getDay()), [weekendDays, value]);
const today = useMemo(() => highlightToday && isSameDate(value, /* @__PURE__ */ new Date()), [highlightToday, value]);
const selected = useMemo(() => {
if ((0, utils_exports.isDate)(selectedValue)) return isSameDate(selectedValue, value);
else if ((0, utils_exports.isArray)(selectedValue)) return selectedValue.some((selectedValue$1) => isSameDate(selectedValue$1, value));
else if ((0, utils_exports.isObject)(selectedValue)) return isSameDate(selectedValue.start, value) || isSameDate(selectedValue.end, value);
}, [selectedValue, value]);
const disabled = useMemo(() => {
if (rootDisabled) return true;
if (isAfterDate(value, maxDate)) return true;
if (isBeforeDate(value, minDate)) return true;
if (excludeDate?.(value)) return true;
if ((0, utils_exports.isArray)(selectedValue) && (0, utils_exports.isNumber)(max) && selectedValue.length >= max && !isIncludeDates(value, selectedValue)) return true;
return false;
}, [
excludeDate,
max,
maxDate,
minDate,
rootDisabled,
selectedValue,
value
]);
const between = useMemo(() => {
if ((0, utils_exports.isDate)(selectedValue) || (0, utils_exports.isArray)(selectedValue)) return false;
return isInRange(value, selectedValue?.start, selectedValue?.end);
}, [selectedValue, value]);
const startValue = useMemo(() => {
if ((0, utils_exports.isDate)(selectedValue) || (0, utils_exports.isArray)(selectedValue)) return false;
const { end, start } = selectedValue ?? {};
return start && end && isSameDate(value, start);
}, [selectedValue, value]);
const endValue = useMemo(() => {
if ((0, utils_exports.isDate)(selectedValue) || (0, utils_exports.isArray)(selectedValue)) return false;
const { end, start } = selectedValue ?? {};
return start && end && isSameDate(value, end);
}, [selectedValue, value]);
const { descendants, register } = useCalendarDescendant({ disabled });
const onFocusDescendant = useCallback((descendant) => {
if (!descendant) return;
descendant.node.focus();
descendant.node.tabIndex = 0;
}, []);
const onBlur = useCallback(() => {
if (cellRef.current) cellRef.current.tabIndex = -1;
}, []);
const onClick = useCallback(() => {
if (disabled) return;
onChange(value);
}, [
disabled,
onChange,
value
]);
const onPrevDate = useCallback(() => {
const descendant = descendants.enabledPrevValue(cellRef.current, false);
if (descendant) onFocusDescendant(descendant);
else if (!isSameBeforeDate(value, minDate)) {
onPrevMonth();
setTimeout(() => onFocusDescendant(descendants.enabledLastValue()));
}
}, [
descendants,
minDate,
onFocusDescendant,
onPrevMonth,
value
]);
const onNextDate = useCallback(() => {
const descendant = descendants.enabledNextValue(cellRef.current, false);
if (descendant) onFocusDescendant(descendant);
else if (!isSameAfterDate(value, maxDate)) {
onNextMonth();
setTimeout(() => onFocusDescendant(descendants.enabledFirstValue()));
}
}, [
descendants,
maxDate,
onFocusDescendant,
onNextMonth,
value
]);
const onPrevTraverseDate = useCallback((date) => {
onMonthChange(dayjs(date).set("date", 1).toDate());
setTimeout(() => {
const descendant = isBeforeDate(date, minDate) ? descendants.enabledFirstValue() : descendants.value(date.getDate() - 1);
if (!descendant) return;
if (descendant.disabled) onFocusDescendant(descendants.enabledNextValue(descendant, false));
else onFocusDescendant(descendant);
});
}, [
descendants,
minDate,
onFocusDescendant,
onMonthChange
]);
const onNextTraverseDate = useCallback((date) => {
onMonthChange(dayjs(date).set("date", 1).toDate());
setTimeout(() => {
const descendant = isAfterDate(date, maxDate) ? descendants.enabledLastValue() : descendants.value(date.getDate() - 1);
if (!descendant) return;
if (descendant.disabled) onFocusDescendant(descendants.enabledPrevValue(descendant, false));
else onFocusDescendant(descendant);
});
}, [
descendants,
maxDate,
onFocusDescendant,
onMonthChange
]);
const onKeyDown = useCallback((ev) => {
runKeyAction(ev, {
ArrowDown: () => onNextTraverseDate(dayjs(value).add(1, "week").toDate()),
ArrowLeft: onPrevDate,
ArrowRight: onNextDate,
ArrowUp: () => onPrevTraverseDate(dayjs(value).subtract(1, "week").toDate()),
End: () => onNextTraverseDate(getEndOfWeek(value, startDayOfWeek)),
Enter: onClick,
Home: () => onPrevTraverseDate(getStartOfWeek(value, startDayOfWeek)),
PageDown: (ev$1) => {
if (ev$1.shiftKey) onNextTraverseDate(dayjs(value).add(1, "year").toDate());
else onNextTraverseDate(dayjs(value).add(1, "month").toDate());
},
PageUp: (ev$1) => {
if (ev$1.shiftKey) onPrevTraverseDate(dayjs(value).subtract(1, "year").toDate());
else onPrevTraverseDate(dayjs(value).subtract(1, "month").toDate());
},
Space: onClick
});
}, [
onClick,
onNextDate,
onNextTraverseDate,
onPrevDate,
onPrevTraverseDate,
startDayOfWeek,
value
]);
return {
outside,
getDayProps: useCallback(({ ref, "aria-label": ariaLabel,...props } = {}) => {
if (!ariaLabel) {
ariaLabel = dateTimeFormat(dayjs(value).toDate(), {
day: "numeric",
month: "long",
weekday: "long",
year: "numeric"
});
if (today) ariaLabel = `${t("Today")}, ${ariaLabel}`;
}
return {
"aria-disabled": (0, utils_exports.ariaAttr)(disabled),
"aria-label": ariaLabel,
"aria-selected": (0, utils_exports.ariaAttr)(selected),
"data-between": (0, utils_exports.dataAttr)(between),
"data-disabled": (0, utils_exports.dataAttr)(disabled),
"data-end": (0, utils_exports.dataAttr)(endValue),
"data-holiday": (0, utils_exports.dataAttr)(holiday),
"data-outside": (0, utils_exports.dataAttr)(outside),
"data-selected": (0, utils_exports.dataAttr)(selected),
"data-start": (0, utils_exports.dataAttr)(startValue),
"data-today": (0, utils_exports.dataAttr)(today),
"data-value": dayjs(value).format("YYYY-MM-DD"),
"data-weekend": (0, utils_exports.dataAttr)(weekend),
tabIndex: -1,
...rest,
...props,
ref: mergeRefs(ref, cellRef, outside ? null : register),
onBlur: (0, utils_exports.handlerAll)(props.onBlur, onBlur),
onClick: (0, utils_exports.handlerAll)(props.onClick, onClick),
onFocus: (0, utils_exports.handlerAll)(props.onFocus, (ev) => ev.preventDefault()),
onKeyDown: (0, utils_exports.handlerAll)(props.onKeyDown, onKeyDown)
};
}, [
between,
dateTimeFormat,
disabled,
endValue,
holiday,
onBlur,
onClick,
onKeyDown,
outside,
register,
rest,
selected,
startValue,
t,
today,
value,
weekend
])
};
};
const calendarProps = [
"defaultMonth",
"defaultValue",
"disabled",
"excludeDate",
"format",
"holidays",
"locale",
"max",
"maxDate",
"minDate",
"month",
"range",
"startDayOfWeek",
"today",
"value",
"weekendDays",
"onChange",
"onChangeMonth"
];
const useCalendarProps = (props, omitKeys) => {
return useSplitProps(props, calendarProps.filter((key) => !omitKeys?.includes(key)));
};
//#endregion
export { CalendarContext, CalendarDescendantsContext, DEFAULT_FIRST_DAY_OF_WEEK, DEFAULT_HOLIDAYS, DEFAULT_MAX_DATE, DEFAULT_MIN_DATE, DEFAULT_WEEKEND_DAYS, getAdjustedMonth, getEndOfWeek, getMonthDays, getStartOfWeek, getWeekdays, isAfterDate, isAfterMonth, isAfterYear, isBeforeDate, isBeforeMonth, isBeforeYear, isInRange, isIncludeDates, isSameAfterDate, isSameAfterMonth, isSameAfterYear, isSameBeforeDate, isSameBeforeMonth, isSameBeforeYear, isSameDate, isSameMonth, isSameYear, sortDates, updateMaybeDateValue, useCalendar, useCalendarContext, useCalendarDay, useCalendarDescendant, useCalendarDescendants, useCalendarProps };
//# sourceMappingURL=use-calendar.js.map