react-day-picker 10.0.0-next.6 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/cjs/DayPicker.js +9 -6
  2. package/dist/cjs/classes/DateLib.d.ts +1 -0
  3. package/dist/cjs/components/CaptionLabel.d.ts +1 -0
  4. package/dist/cjs/components/Chevron.d.ts +1 -0
  5. package/dist/cjs/components/Day.d.ts +1 -0
  6. package/dist/cjs/components/DayButton.d.ts +1 -0
  7. package/dist/cjs/components/Dropdown.d.ts +1 -0
  8. package/dist/cjs/components/DropdownNav.d.ts +1 -0
  9. package/dist/cjs/components/Footer.d.ts +1 -0
  10. package/dist/cjs/components/Month.d.ts +1 -0
  11. package/dist/cjs/components/MonthCaption.d.ts +1 -0
  12. package/dist/cjs/components/MonthGrid.d.ts +1 -0
  13. package/dist/cjs/components/Months.d.ts +1 -0
  14. package/dist/cjs/components/Nav.d.ts +1 -0
  15. package/dist/cjs/components/NextMonthButton.d.ts +1 -0
  16. package/dist/cjs/components/Option.d.ts +1 -0
  17. package/dist/cjs/components/PreviousMonthButton.d.ts +1 -0
  18. package/dist/cjs/components/Root.d.ts +1 -0
  19. package/dist/cjs/components/Select.d.ts +1 -0
  20. package/dist/cjs/components/Week.d.ts +1 -0
  21. package/dist/cjs/components/WeekNumber.d.ts +1 -0
  22. package/dist/cjs/components/WeekNumberHeader.d.ts +1 -0
  23. package/dist/cjs/components/Weekday.d.ts +1 -0
  24. package/dist/cjs/components/Weekdays.d.ts +1 -0
  25. package/dist/cjs/components/Weeks.d.ts +1 -0
  26. package/dist/cjs/types/selection.d.ts +7 -0
  27. package/dist/esm/DayPicker.js +9 -6
  28. package/dist/esm/classes/DateLib.d.ts +1 -0
  29. package/dist/esm/components/CaptionLabel.d.ts +1 -0
  30. package/dist/esm/components/Chevron.d.ts +1 -0
  31. package/dist/esm/components/Day.d.ts +1 -0
  32. package/dist/esm/components/DayButton.d.ts +1 -0
  33. package/dist/esm/components/Dropdown.d.ts +1 -0
  34. package/dist/esm/components/DropdownNav.d.ts +1 -0
  35. package/dist/esm/components/Footer.d.ts +1 -0
  36. package/dist/esm/components/Month.d.ts +1 -0
  37. package/dist/esm/components/MonthCaption.d.ts +1 -0
  38. package/dist/esm/components/MonthGrid.d.ts +1 -0
  39. package/dist/esm/components/Months.d.ts +1 -0
  40. package/dist/esm/components/Nav.d.ts +1 -0
  41. package/dist/esm/components/NextMonthButton.d.ts +1 -0
  42. package/dist/esm/components/Option.d.ts +1 -0
  43. package/dist/esm/components/PreviousMonthButton.d.ts +1 -0
  44. package/dist/esm/components/Root.d.ts +1 -0
  45. package/dist/esm/components/Select.d.ts +1 -0
  46. package/dist/esm/components/Week.d.ts +1 -0
  47. package/dist/esm/components/WeekNumber.d.ts +1 -0
  48. package/dist/esm/components/WeekNumberHeader.d.ts +1 -0
  49. package/dist/esm/components/Weekday.d.ts +1 -0
  50. package/dist/esm/components/Weekdays.d.ts +1 -0
  51. package/dist/esm/components/Weeks.d.ts +1 -0
  52. package/dist/esm/types/selection.d.ts +7 -0
  53. package/package.json +1 -1
@@ -238,15 +238,15 @@ function DayPicker(initialProps) {
238
238
  const handleDayMouseLeave = (0, react_1.useCallback)((day, modifiers) => (e) => {
239
239
  onDayMouseLeave?.(day.date, modifiers, e);
240
240
  }, [onDayMouseLeave]);
241
- const handleMonthChange = (0, react_1.useCallback)((date) => (e) => {
241
+ const handleMonthChange = (0, react_1.useCallback)((date, monthOffset) => (e) => {
242
242
  const selectedMonth = Number(e.target.value);
243
243
  const month = dateLib.setMonth(dateLib.startOfMonth(date), selectedMonth);
244
- goToMonth(month);
244
+ goToMonth(dateLib.addMonths(month, -monthOffset));
245
245
  }, [dateLib, goToMonth]);
246
- const handleYearChange = (0, react_1.useCallback)((date) => (e) => {
246
+ const handleYearChange = (0, react_1.useCallback)((date, monthOffset) => (e) => {
247
247
  const selectedYear = Number(e.target.value);
248
248
  const month = dateLib.setYear(dateLib.startOfMonth(date), selectedYear);
249
- goToMonth(month);
249
+ goToMonth(dateLib.addMonths(month, -monthOffset));
250
250
  }, [dateLib, goToMonth]);
251
251
  const { className, style } = (0, react_1.useMemo)(() => ({
252
252
  className: [classNames[UI_js_1.UI.Root], props.className]
@@ -283,6 +283,9 @@ function DayPicker(initialProps) {
283
283
  react_1.default.createElement(components.Months, { className: classNames[UI_js_1.UI.Months], style: styles?.[UI_js_1.UI.Months] },
284
284
  !props.hideNavigation && !navLayout && (react_1.default.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.Nav], style: styles?.[UI_js_1.UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
285
285
  months.map((calendarMonth, displayIndex) => {
286
+ const monthOffset = props.reverseMonths
287
+ ? months.length - 1 - displayIndex
288
+ : displayIndex;
286
289
  return (react_1.default.createElement(components.Month, { "data-animated-month": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.Month], style: styles?.[UI_js_1.UI.Month],
287
290
  // biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
288
291
  key: displayIndex, displayIndex: displayIndex, calendarMonth: calendarMonth },
@@ -293,9 +296,9 @@ function DayPicker(initialProps) {
293
296
  react_1.default.createElement(components.MonthCaption, { "data-animated-caption": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.MonthCaption], style: styles?.[UI_js_1.UI.MonthCaption], calendarMonth: calendarMonth, displayIndex: displayIndex }, captionLayout?.startsWith("dropdown") ? (react_1.default.createElement(components.DropdownNav, { className: classNames[UI_js_1.UI.Dropdowns], style: styles?.[UI_js_1.UI.Dropdowns] },
294
297
  (() => {
295
298
  const monthControl = captionLayout === "dropdown" ||
296
- captionLayout === "dropdown-months" ? (react_1.default.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI_js_1.UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: (0, getMonthOptions_js_1.getMonthOptions)(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: styles?.[UI_js_1.UI.Dropdown], value: dateLib.getMonth(calendarMonth.date) })) : (react_1.default.createElement("span", { key: "month" }, formatMonthDropdown(calendarMonth.date, dateLib)));
299
+ captionLayout === "dropdown-months" ? (react_1.default.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI_js_1.UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date, monthOffset), options: (0, getMonthOptions_js_1.getMonthOptions)(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: styles?.[UI_js_1.UI.Dropdown], value: dateLib.getMonth(calendarMonth.date) })) : (react_1.default.createElement("span", { key: "month" }, formatMonthDropdown(calendarMonth.date, dateLib)));
297
300
  const yearControl = captionLayout === "dropdown" ||
298
- captionLayout === "dropdown-years" ? (react_1.default.createElement(components.YearsDropdown, { key: "year", className: classNames[UI_js_1.UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: (0, getYearOptions_js_1.getYearOptions)(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: styles?.[UI_js_1.UI.Dropdown], value: dateLib.getYear(calendarMonth.date) })) : (react_1.default.createElement("span", { key: "year" }, formatYearDropdown(calendarMonth.date, dateLib)));
301
+ captionLayout === "dropdown-years" ? (react_1.default.createElement(components.YearsDropdown, { key: "year", className: classNames[UI_js_1.UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date, monthOffset), options: (0, getYearOptions_js_1.getYearOptions)(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: styles?.[UI_js_1.UI.Dropdown], value: dateLib.getYear(calendarMonth.date) })) : (react_1.default.createElement("span", { key: "year" }, formatYearDropdown(calendarMonth.date, dateLib)));
299
302
  const controls = dateLib.getMonthYearOrder() === "year-first"
300
303
  ? [yearControl, monthControl]
301
304
  : [monthControl, yearControl];
@@ -19,6 +19,7 @@ export interface DayPickerLocale extends DateFnsLocale {
19
19
  /** Localized DayPicker-specific labels. */
20
20
  labels?: DayPickerLocaleLabels;
21
21
  }
22
+ /** Alias for the locale shape accepted by DayPicker APIs. */
22
23
  export type Locale = DayPickerLocale;
23
24
  /** Indicates the preferred ordering of month and year for localized labels. */
24
25
  export type MonthYearOrder = "month-first" | "year-first";
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function CaptionLabel(props: HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link CaptionLabel} component. */
9
10
  export type CaptionLabelProps = Parameters<typeof CaptionLabel>[0];
@@ -18,4 +18,5 @@ export declare function Chevron(props: {
18
18
  /** The orientation of the chevron. */
19
19
  orientation?: "up" | "down" | "left" | "right";
20
20
  }): React.JSX.Element;
21
+ /** Props accepted by the {@link Chevron} component. */
21
22
  export type ChevronProps = Parameters<typeof Chevron>[0];
@@ -17,4 +17,5 @@ export declare function Day(props: {
17
17
  /** The modifiers to apply to the day. */
18
18
  modifiers: Modifiers;
19
19
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
20
+ /** Props accepted by the {@link Day} component. */
20
21
  export type DayProps = Parameters<typeof Day>[0];
@@ -13,4 +13,5 @@ export declare function DayButton(props: {
13
13
  /** The modifiers to apply to the day. */
14
14
  modifiers: Modifiers;
15
15
  } & ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
16
+ /** Props accepted by the {@link DayButton} component. */
16
17
  export type DayButtonProps = Parameters<typeof DayButton>[0];
@@ -18,4 +18,5 @@ export declare function Dropdown(props: {
18
18
  /** The options to display in the dropdown. */
19
19
  options?: DropdownOption[] | undefined;
20
20
  } & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">): React.JSX.Element;
21
+ /** Props accepted by the {@link Dropdown} component. */
21
22
  export type DropdownProps = Parameters<typeof Dropdown>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function DropdownNav(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link DropdownNav} component. */
9
10
  export type DropdownNavProps = Parameters<typeof DropdownNav>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Footer(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Footer} component. */
9
10
  export type FooterProps = Parameters<typeof Footer>[0];
@@ -13,4 +13,5 @@ export declare function Month(props: {
13
13
  /** The index of the month being displayed. */
14
14
  displayIndex: number;
15
15
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
16
+ /** Props accepted by the {@link Month} component. */
16
17
  export type MonthProps = Parameters<typeof Month>[0];
@@ -12,4 +12,5 @@ export declare function MonthCaption(props: {
12
12
  /** The index of the month being displayed. */
13
13
  displayIndex: number;
14
14
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
15
+ /** Props accepted by the {@link MonthCaption} component. */
15
16
  export type MonthCaptionProps = Parameters<typeof MonthCaption>[0];
@@ -6,4 +6,5 @@ import React, { type TableHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function MonthGrid(props: TableHTMLAttributes<HTMLTableElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link MonthGrid} component. */
9
10
  export type MonthGridProps = Parameters<typeof MonthGrid>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Months(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Months} component. */
9
10
  export type MonthsProps = Parameters<typeof Months>[0];
@@ -15,4 +15,5 @@ export declare function Nav(props: {
15
15
  /** The date of the next month, if available. */
16
16
  nextMonth?: Date | undefined;
17
17
  } & HTMLAttributes<HTMLElement>): React.JSX.Element;
18
+ /** Props accepted by the {@link Nav} component. */
18
19
  export type NavProps = Parameters<typeof Nav>[0];
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function NextMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link NextMonthButton} component. */
9
10
  export type NextMonthButtonProps = Parameters<typeof NextMonthButton>[0];
@@ -6,4 +6,5 @@ import React, { type OptionHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Option(props: OptionHTMLAttributes<HTMLOptionElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Option} component. */
9
10
  export type OptionProps = Parameters<typeof Option>[0];
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function PreviousMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link PreviousMonthButton} component. */
9
10
  export type PreviousMonthButtonProps = Parameters<typeof PreviousMonthButton>[0];
@@ -9,4 +9,5 @@ export declare function Root(props: {
9
9
  /** Ref for the root element, used when `animate` is `true`. */
10
10
  rootRef?: Ref<HTMLDivElement>;
11
11
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
12
+ /** Props accepted by the {@link Root} component. */
12
13
  export type RootProps = Parameters<typeof Root>[0];
@@ -6,4 +6,5 @@ import React, { type SelectHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Select(props: SelectHTMLAttributes<HTMLSelectElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Select} component. */
9
10
  export type SelectProps = Parameters<typeof Select>[0];
@@ -10,4 +10,5 @@ export declare function Week(props: {
10
10
  /** The week to render. */
11
11
  week: CalendarWeek;
12
12
  } & HTMLAttributes<HTMLTableRowElement>): React.JSX.Element;
13
+ /** Props accepted by the {@link Week} component. */
13
14
  export type WeekProps = Parameters<typeof Week>[0];
@@ -10,4 +10,5 @@ export declare function WeekNumber(props: {
10
10
  /** The week to display. */
11
11
  week: CalendarWeek;
12
12
  } & ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
13
+ /** Props accepted by the {@link WeekNumber} component. */
13
14
  export type WeekNumberProps = Parameters<typeof WeekNumber>[0];
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function WeekNumberHeader(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link WeekNumberHeader} component. */
9
10
  export type WeekNumberHeaderProps = Parameters<typeof WeekNumberHeader>[0];
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Weekday(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Weekday} component. */
9
10
  export type WeekdayProps = Parameters<typeof Weekday>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Weekdays(props: HTMLAttributes<HTMLTableRowElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Weekdays} component. */
9
10
  export type WeekdaysProps = Parameters<typeof Weekdays>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Weeks(props: HTMLAttributes<HTMLTableSectionElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Weeks} component. */
9
10
  export type WeeksProps = Parameters<typeof Weeks>[0];
@@ -1,5 +1,6 @@
1
1
  import type { DayPickerProps } from "./props.js";
2
2
  import type { DateRange, Mode, Modifiers } from "./shared.js";
3
+ /** Selection state and helpers for the active selection mode. */
3
4
  export type Selection<T extends DayPickerProps> = {
4
5
  /** The selected date(s). */
5
6
  selected: SelectedValue<T> | undefined;
@@ -8,12 +9,15 @@ export type Selection<T extends DayPickerProps> = {
8
9
  /** Whether the given date is selected. */
9
10
  isSelected: (date: Date) => boolean;
10
11
  };
12
+ /** Selected value for single selection mode, respecting required selections. */
11
13
  export type SelectedSingle<T extends {
12
14
  required?: boolean;
13
15
  }> = T["required"] extends true ? Date : Date | undefined;
16
+ /** Selected value for multiple selection mode, respecting required selections. */
14
17
  export type SelectedMulti<T extends {
15
18
  required?: boolean;
16
19
  }> = T["required"] extends true ? Date[] : Date[] | undefined;
20
+ /** Selected value for range selection mode, respecting required selections. */
17
21
  export type SelectedRange<T extends {
18
22
  required?: boolean;
19
23
  }> = T["required"] extends true ? DateRange : DateRange | undefined;
@@ -46,12 +50,15 @@ export type SelectedValue<T> = T extends {
46
50
  mode: "range";
47
51
  required?: boolean;
48
52
  } ? SelectedRange<T> : undefined;
53
+ /** Selection handler for single selection mode. */
49
54
  export type SelectHandlerSingle<T extends {
50
55
  required?: boolean | undefined;
51
56
  }> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date : Date | undefined;
57
+ /** Selection handler for multiple selection mode. */
52
58
  export type SelectHandlerMulti<T extends {
53
59
  required?: boolean | undefined;
54
60
  }> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date[] : Date[] | undefined;
61
+ /** Selection handler for range selection mode. */
55
62
  export type SelectHandlerRange<T extends {
56
63
  required?: boolean | undefined;
57
64
  }> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? DateRange : DateRange | undefined;
@@ -202,15 +202,15 @@ export function DayPicker(initialProps) {
202
202
  const handleDayMouseLeave = useCallback((day, modifiers) => (e) => {
203
203
  onDayMouseLeave?.(day.date, modifiers, e);
204
204
  }, [onDayMouseLeave]);
205
- const handleMonthChange = useCallback((date) => (e) => {
205
+ const handleMonthChange = useCallback((date, monthOffset) => (e) => {
206
206
  const selectedMonth = Number(e.target.value);
207
207
  const month = dateLib.setMonth(dateLib.startOfMonth(date), selectedMonth);
208
- goToMonth(month);
208
+ goToMonth(dateLib.addMonths(month, -monthOffset));
209
209
  }, [dateLib, goToMonth]);
210
- const handleYearChange = useCallback((date) => (e) => {
210
+ const handleYearChange = useCallback((date, monthOffset) => (e) => {
211
211
  const selectedYear = Number(e.target.value);
212
212
  const month = dateLib.setYear(dateLib.startOfMonth(date), selectedYear);
213
- goToMonth(month);
213
+ goToMonth(dateLib.addMonths(month, -monthOffset));
214
214
  }, [dateLib, goToMonth]);
215
215
  const { className, style } = useMemo(() => ({
216
216
  className: [classNames[UI.Root], props.className]
@@ -247,6 +247,9 @@ export function DayPicker(initialProps) {
247
247
  React.createElement(components.Months, { className: classNames[UI.Months], style: styles?.[UI.Months] },
248
248
  !props.hideNavigation && !navLayout && (React.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI.Nav], style: styles?.[UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
249
249
  months.map((calendarMonth, displayIndex) => {
250
+ const monthOffset = props.reverseMonths
251
+ ? months.length - 1 - displayIndex
252
+ : displayIndex;
250
253
  return (React.createElement(components.Month, { "data-animated-month": props.animate ? "true" : undefined, className: classNames[UI.Month], style: styles?.[UI.Month],
251
254
  // biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
252
255
  key: displayIndex, displayIndex: displayIndex, calendarMonth: calendarMonth },
@@ -257,9 +260,9 @@ export function DayPicker(initialProps) {
257
260
  React.createElement(components.MonthCaption, { "data-animated-caption": props.animate ? "true" : undefined, className: classNames[UI.MonthCaption], style: styles?.[UI.MonthCaption], calendarMonth: calendarMonth, displayIndex: displayIndex }, captionLayout?.startsWith("dropdown") ? (React.createElement(components.DropdownNav, { className: classNames[UI.Dropdowns], style: styles?.[UI.Dropdowns] },
258
261
  (() => {
259
262
  const monthControl = captionLayout === "dropdown" ||
260
- captionLayout === "dropdown-months" ? (React.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: getMonthOptions(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: styles?.[UI.Dropdown], value: dateLib.getMonth(calendarMonth.date) })) : (React.createElement("span", { key: "month" }, formatMonthDropdown(calendarMonth.date, dateLib)));
263
+ captionLayout === "dropdown-months" ? (React.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date, monthOffset), options: getMonthOptions(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: styles?.[UI.Dropdown], value: dateLib.getMonth(calendarMonth.date) })) : (React.createElement("span", { key: "month" }, formatMonthDropdown(calendarMonth.date, dateLib)));
261
264
  const yearControl = captionLayout === "dropdown" ||
262
- captionLayout === "dropdown-years" ? (React.createElement(components.YearsDropdown, { key: "year", className: classNames[UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: getYearOptions(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: styles?.[UI.Dropdown], value: dateLib.getYear(calendarMonth.date) })) : (React.createElement("span", { key: "year" }, formatYearDropdown(calendarMonth.date, dateLib)));
265
+ captionLayout === "dropdown-years" ? (React.createElement(components.YearsDropdown, { key: "year", className: classNames[UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date, monthOffset), options: getYearOptions(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: styles?.[UI.Dropdown], value: dateLib.getYear(calendarMonth.date) })) : (React.createElement("span", { key: "year" }, formatYearDropdown(calendarMonth.date, dateLib)));
263
266
  const controls = dateLib.getMonthYearOrder() === "year-first"
264
267
  ? [yearControl, monthControl]
265
268
  : [monthControl, yearControl];
@@ -19,6 +19,7 @@ export interface DayPickerLocale extends DateFnsLocale {
19
19
  /** Localized DayPicker-specific labels. */
20
20
  labels?: DayPickerLocaleLabels;
21
21
  }
22
+ /** Alias for the locale shape accepted by DayPicker APIs. */
22
23
  export type Locale = DayPickerLocale;
23
24
  /** Indicates the preferred ordering of month and year for localized labels. */
24
25
  export type MonthYearOrder = "month-first" | "year-first";
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function CaptionLabel(props: HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link CaptionLabel} component. */
9
10
  export type CaptionLabelProps = Parameters<typeof CaptionLabel>[0];
@@ -18,4 +18,5 @@ export declare function Chevron(props: {
18
18
  /** The orientation of the chevron. */
19
19
  orientation?: "up" | "down" | "left" | "right";
20
20
  }): React.JSX.Element;
21
+ /** Props accepted by the {@link Chevron} component. */
21
22
  export type ChevronProps = Parameters<typeof Chevron>[0];
@@ -17,4 +17,5 @@ export declare function Day(props: {
17
17
  /** The modifiers to apply to the day. */
18
18
  modifiers: Modifiers;
19
19
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
20
+ /** Props accepted by the {@link Day} component. */
20
21
  export type DayProps = Parameters<typeof Day>[0];
@@ -13,4 +13,5 @@ export declare function DayButton(props: {
13
13
  /** The modifiers to apply to the day. */
14
14
  modifiers: Modifiers;
15
15
  } & ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
16
+ /** Props accepted by the {@link DayButton} component. */
16
17
  export type DayButtonProps = Parameters<typeof DayButton>[0];
@@ -18,4 +18,5 @@ export declare function Dropdown(props: {
18
18
  /** The options to display in the dropdown. */
19
19
  options?: DropdownOption[] | undefined;
20
20
  } & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">): React.JSX.Element;
21
+ /** Props accepted by the {@link Dropdown} component. */
21
22
  export type DropdownProps = Parameters<typeof Dropdown>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function DropdownNav(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link DropdownNav} component. */
9
10
  export type DropdownNavProps = Parameters<typeof DropdownNav>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Footer(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Footer} component. */
9
10
  export type FooterProps = Parameters<typeof Footer>[0];
@@ -13,4 +13,5 @@ export declare function Month(props: {
13
13
  /** The index of the month being displayed. */
14
14
  displayIndex: number;
15
15
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
16
+ /** Props accepted by the {@link Month} component. */
16
17
  export type MonthProps = Parameters<typeof Month>[0];
@@ -12,4 +12,5 @@ export declare function MonthCaption(props: {
12
12
  /** The index of the month being displayed. */
13
13
  displayIndex: number;
14
14
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
15
+ /** Props accepted by the {@link MonthCaption} component. */
15
16
  export type MonthCaptionProps = Parameters<typeof MonthCaption>[0];
@@ -6,4 +6,5 @@ import React, { type TableHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function MonthGrid(props: TableHTMLAttributes<HTMLTableElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link MonthGrid} component. */
9
10
  export type MonthGridProps = Parameters<typeof MonthGrid>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Months(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Months} component. */
9
10
  export type MonthsProps = Parameters<typeof Months>[0];
@@ -15,4 +15,5 @@ export declare function Nav(props: {
15
15
  /** The date of the next month, if available. */
16
16
  nextMonth?: Date | undefined;
17
17
  } & HTMLAttributes<HTMLElement>): React.JSX.Element;
18
+ /** Props accepted by the {@link Nav} component. */
18
19
  export type NavProps = Parameters<typeof Nav>[0];
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function NextMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link NextMonthButton} component. */
9
10
  export type NextMonthButtonProps = Parameters<typeof NextMonthButton>[0];
@@ -6,4 +6,5 @@ import React, { type OptionHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Option(props: OptionHTMLAttributes<HTMLOptionElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Option} component. */
9
10
  export type OptionProps = Parameters<typeof Option>[0];
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function PreviousMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link PreviousMonthButton} component. */
9
10
  export type PreviousMonthButtonProps = Parameters<typeof PreviousMonthButton>[0];
@@ -9,4 +9,5 @@ export declare function Root(props: {
9
9
  /** Ref for the root element, used when `animate` is `true`. */
10
10
  rootRef?: Ref<HTMLDivElement>;
11
11
  } & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
12
+ /** Props accepted by the {@link Root} component. */
12
13
  export type RootProps = Parameters<typeof Root>[0];
@@ -6,4 +6,5 @@ import React, { type SelectHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Select(props: SelectHTMLAttributes<HTMLSelectElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Select} component. */
9
10
  export type SelectProps = Parameters<typeof Select>[0];
@@ -10,4 +10,5 @@ export declare function Week(props: {
10
10
  /** The week to render. */
11
11
  week: CalendarWeek;
12
12
  } & HTMLAttributes<HTMLTableRowElement>): React.JSX.Element;
13
+ /** Props accepted by the {@link Week} component. */
13
14
  export type WeekProps = Parameters<typeof Week>[0];
@@ -10,4 +10,5 @@ export declare function WeekNumber(props: {
10
10
  /** The week to display. */
11
11
  week: CalendarWeek;
12
12
  } & ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
13
+ /** Props accepted by the {@link WeekNumber} component. */
13
14
  export type WeekNumberProps = Parameters<typeof WeekNumber>[0];
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function WeekNumberHeader(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link WeekNumberHeader} component. */
9
10
  export type WeekNumberHeaderProps = Parameters<typeof WeekNumberHeader>[0];
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Weekday(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Weekday} component. */
9
10
  export type WeekdayProps = Parameters<typeof Weekday>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Weekdays(props: HTMLAttributes<HTMLTableRowElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Weekdays} component. */
9
10
  export type WeekdaysProps = Parameters<typeof Weekdays>[0];
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
6
6
  * @see https://daypicker.dev/guides/custom-components
7
7
  */
8
8
  export declare function Weeks(props: HTMLAttributes<HTMLTableSectionElement>): React.JSX.Element;
9
+ /** Props accepted by the {@link Weeks} component. */
9
10
  export type WeeksProps = Parameters<typeof Weeks>[0];
@@ -1,5 +1,6 @@
1
1
  import type { DayPickerProps } from "./props.js";
2
2
  import type { DateRange, Mode, Modifiers } from "./shared.js";
3
+ /** Selection state and helpers for the active selection mode. */
3
4
  export type Selection<T extends DayPickerProps> = {
4
5
  /** The selected date(s). */
5
6
  selected: SelectedValue<T> | undefined;
@@ -8,12 +9,15 @@ export type Selection<T extends DayPickerProps> = {
8
9
  /** Whether the given date is selected. */
9
10
  isSelected: (date: Date) => boolean;
10
11
  };
12
+ /** Selected value for single selection mode, respecting required selections. */
11
13
  export type SelectedSingle<T extends {
12
14
  required?: boolean;
13
15
  }> = T["required"] extends true ? Date : Date | undefined;
16
+ /** Selected value for multiple selection mode, respecting required selections. */
14
17
  export type SelectedMulti<T extends {
15
18
  required?: boolean;
16
19
  }> = T["required"] extends true ? Date[] : Date[] | undefined;
20
+ /** Selected value for range selection mode, respecting required selections. */
17
21
  export type SelectedRange<T extends {
18
22
  required?: boolean;
19
23
  }> = T["required"] extends true ? DateRange : DateRange | undefined;
@@ -46,12 +50,15 @@ export type SelectedValue<T> = T extends {
46
50
  mode: "range";
47
51
  required?: boolean;
48
52
  } ? SelectedRange<T> : undefined;
53
+ /** Selection handler for single selection mode. */
49
54
  export type SelectHandlerSingle<T extends {
50
55
  required?: boolean | undefined;
51
56
  }> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date : Date | undefined;
57
+ /** Selection handler for multiple selection mode. */
52
58
  export type SelectHandlerMulti<T extends {
53
59
  required?: boolean | undefined;
54
60
  }> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date[] : Date[] | undefined;
61
+ /** Selection handler for range selection mode. */
55
62
  export type SelectHandlerRange<T extends {
56
63
  required?: boolean | undefined;
57
64
  }> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? DateRange : DateRange | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-day-picker",
3
- "version": "10.0.0-next.6",
3
+ "version": "10.0.0",
4
4
  "description": "Customizable Date Picker for React",
5
5
  "author": "Giampaolo Bellavite <io@gpbl.dev>",
6
6
  "homepage": "https://daypicker.dev",