UNPKG

2.12 kBTypeScriptView Raw
1import type { CalendarWeek, CalendarDay, CalendarMonth } from "./classes/index.js";
2import type { DayPickerProps } from "./types/props.js";
3import type { DateLib } from "./types/shared.js";
4/**
5 * Return the calendar object to work with the calendar in custom components.
6 *
7 * @see https://daypicker.dev/guides/custom-components
8 */
9export interface Calendar {
10 /**
11 * All the days displayed in the calendar. As opposite from
12 * {@link CalendarContext.dates}, it may return duplicated dates when shown
13 * outside the month.
14 */
15 days: CalendarDay[];
16 /** The months displayed in the calendar. */
17 weeks: CalendarWeek[];
18 /** The months displayed in the calendar. */
19 months: CalendarMonth[];
20 /** The next month to display. */
21 nextMonth: Date | undefined;
22 /** The previous month to display. */
23 previousMonth: Date | undefined;
24 /**
25 * The month where the navigation starts. `undefined` if the calendar can be
26 * navigated indefinitely to the past.
27 */
28 navStart: Date | undefined;
29 /**
30 * The month where the navigation ends. `undefined` if the calendar can be
31 * navigated indefinitely to the past.
32 */
33 navEnd: Date | undefined;
34 /** Navigate to the specified month. Will fire the `onMonthChange` callback. */
35 goToMonth: (month: Date) => void;
36 /**
37 * Navigate to the specified date. If the second parameter (refDate) is
38 * provided and the date is before the refDate, then the month is set to one
39 * month before the date.
40 *
41 * @param day - The date to navigate to.
42 * @param dateToCompare - Optional. If `date` is before `dateToCompare`, the
43 * month is set to one month before the date.
44 */
45 goToDay: (day: CalendarDay) => void;
46}
47/** @private */
48export declare function useCalendar(props: Pick<DayPickerProps, "captionLayout" | "endMonth" | "startMonth" | "today" | "fixedWeeks" | "ISOWeek" | "weekStartsOn" | "numberOfMonths" | "disableNavigation" | "onMonthChange" | "month" | "defaultMonth" | "fromMonth" | "fromYear" | "toMonth" | "toYear">, dateLib: DateLib): Calendar;