react-day-picker 9.14.0 → 10.0.0-next.1

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 (91) hide show
  1. package/dist/cjs/DayPicker.js +84 -82
  2. package/dist/cjs/UI.d.ts +2 -239
  3. package/dist/cjs/UI.js +2 -2
  4. package/dist/cjs/classes/DateLib.d.ts +0 -21
  5. package/dist/cjs/classes/DateLib.js +3 -13
  6. package/dist/cjs/components/Chevron.js +1 -3
  7. package/dist/cjs/components/Dropdown.d.ts +0 -11
  8. package/dist/cjs/components/Dropdown.js +3 -1
  9. package/dist/cjs/components/NextMonthButton.js +1 -3
  10. package/dist/cjs/components/PreviousMonthButton.js +1 -3
  11. package/dist/cjs/components/custom-components.d.ts +0 -1
  12. package/dist/cjs/components/custom-components.js +0 -1
  13. package/dist/cjs/formatters/formatCaption.d.ts +0 -6
  14. package/dist/cjs/formatters/formatCaption.js +0 -7
  15. package/dist/cjs/formatters/formatWeekNumber.d.ts +1 -1
  16. package/dist/cjs/formatters/formatYearDropdown.d.ts +0 -6
  17. package/dist/cjs/formatters/formatYearDropdown.js +0 -7
  18. package/dist/cjs/helpers/getFormatters.d.ts +0 -2
  19. package/dist/cjs/helpers/getFormatters.js +0 -7
  20. package/dist/cjs/helpers/getInitialMonth.d.ts +1 -1
  21. package/dist/cjs/helpers/getNavMonth.d.ts +1 -1
  22. package/dist/cjs/helpers/getNavMonth.js +1 -21
  23. package/dist/cjs/hijri/index.js +2 -8
  24. package/dist/cjs/labels/labelDayButton.d.ts +0 -5
  25. package/dist/cjs/labels/labelDayButton.js +0 -6
  26. package/dist/cjs/labels/labelGrid.d.ts +0 -5
  27. package/dist/cjs/labels/labelGrid.js +0 -6
  28. package/dist/cjs/types/index.d.ts +0 -1
  29. package/dist/cjs/types/index.js +0 -1
  30. package/dist/cjs/types/props.d.ts +3 -97
  31. package/dist/cjs/types/shared.d.ts +1 -45
  32. package/dist/cjs/useAnimation.js +1 -2
  33. package/dist/cjs/useCalendar.d.ts +1 -1
  34. package/dist/cjs/utils/dateMatchModifiers.d.ts +0 -5
  35. package/dist/cjs/utils/dateMatchModifiers.js +0 -6
  36. package/dist/cjs/utils/rangeIncludesDate.d.ts +1 -6
  37. package/dist/cjs/utils/rangeIncludesDate.js +0 -7
  38. package/dist/cjs/utils/rangeOverlaps.d.ts +1 -1
  39. package/dist/esm/DayPicker.js +84 -82
  40. package/dist/esm/UI.d.ts +2 -239
  41. package/dist/esm/UI.js +2 -2
  42. package/dist/esm/classes/DateLib.d.ts +0 -21
  43. package/dist/esm/classes/DateLib.js +2 -12
  44. package/dist/esm/components/Chevron.js +1 -3
  45. package/dist/esm/components/Dropdown.d.ts +0 -11
  46. package/dist/esm/components/Dropdown.js +3 -1
  47. package/dist/esm/components/NextMonthButton.js +1 -3
  48. package/dist/esm/components/PreviousMonthButton.js +1 -3
  49. package/dist/esm/components/custom-components.d.ts +0 -1
  50. package/dist/esm/components/custom-components.js +0 -1
  51. package/dist/esm/formatters/formatCaption.d.ts +0 -6
  52. package/dist/esm/formatters/formatCaption.js +0 -6
  53. package/dist/esm/formatters/formatWeekNumber.d.ts +1 -1
  54. package/dist/esm/formatters/formatYearDropdown.d.ts +0 -6
  55. package/dist/esm/formatters/formatYearDropdown.js +0 -6
  56. package/dist/esm/helpers/getFormatters.d.ts +0 -2
  57. package/dist/esm/helpers/getFormatters.js +0 -7
  58. package/dist/esm/helpers/getInitialMonth.d.ts +1 -1
  59. package/dist/esm/helpers/getNavMonth.d.ts +1 -1
  60. package/dist/esm/helpers/getNavMonth.js +1 -21
  61. package/dist/esm/hijri/index.js +2 -8
  62. package/dist/esm/labels/labelDayButton.d.ts +0 -5
  63. package/dist/esm/labels/labelDayButton.js +0 -5
  64. package/dist/esm/labels/labelGrid.d.ts +0 -5
  65. package/dist/esm/labels/labelGrid.js +0 -5
  66. package/dist/esm/types/index.d.ts +0 -1
  67. package/dist/esm/types/index.js +0 -1
  68. package/dist/esm/types/props.d.ts +3 -97
  69. package/dist/esm/types/shared.d.ts +1 -45
  70. package/dist/esm/useAnimation.js +1 -2
  71. package/dist/esm/useCalendar.d.ts +1 -1
  72. package/dist/esm/utils/dateMatchModifiers.d.ts +0 -5
  73. package/dist/esm/utils/dateMatchModifiers.js +0 -5
  74. package/dist/esm/utils/rangeIncludesDate.d.ts +1 -6
  75. package/dist/esm/utils/rangeIncludesDate.js +0 -5
  76. package/dist/esm/utils/rangeOverlaps.d.ts +1 -1
  77. package/package.json +13 -25
  78. package/dist/cjs/components/Button.d.ts +0 -9
  79. package/dist/cjs/components/Button.js +0 -16
  80. package/dist/cjs/jalali.d.ts +0 -2
  81. package/dist/cjs/jalali.js +0 -18
  82. package/dist/cjs/types/deprecated.d.ts +0 -180
  83. package/dist/cjs/types/deprecated.js +0 -26
  84. package/dist/esm/components/Button.d.ts +0 -9
  85. package/dist/esm/components/Button.js +0 -10
  86. package/dist/esm/jalali.d.ts +0 -2
  87. package/dist/esm/jalali.js +0 -2
  88. package/dist/esm/types/deprecated.d.ts +0 -180
  89. package/dist/esm/types/deprecated.js +0 -23
  90. package/jalali.d.ts +0 -1
  91. package/jalali.js +0 -3
@@ -128,8 +128,12 @@ export function DayPicker(initialProps) {
128
128
  props.labels,
129
129
  props.classNames,
130
130
  ]);
131
- if (!props.today) {
132
- props = { ...props, today: dateLib.today() };
131
+ if (!props.today || props.navLayout === undefined) {
132
+ props = {
133
+ ...props,
134
+ today: props.today ?? dateLib.today(),
135
+ navLayout: props.navLayout ?? "after",
136
+ };
133
137
  }
134
138
  const { captionLayout, mode, navLayout, numberOfMonths = 1, onDayBlur, onDayClick, onDayFocus, onDayKeyDown, onDayMouseEnter, onDayMouseLeave, onNextClick, onPrevClick, showWeekNumber, styles, } = props;
135
139
  const { formatCaption, formatDay, formatMonthDropdown, formatWeekNumber, formatWeekNumberHeader, formatWeekdayName, formatYearDropdown, } = formatters;
@@ -244,85 +248,83 @@ export function DayPicker(initialProps) {
244
248
  };
245
249
  return (React.createElement(dayPickerContext.Provider, { value: contextValue },
246
250
  React.createElement(components.Root, { rootRef: props.animate ? rootElRef : undefined, className: className, style: style, dir: props.dir, id: props.id, lang: props.lang ?? locale.code, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
247
- React.createElement(components.Months, { className: classNames[UI.Months], style: styles?.[UI.Months] },
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
- months.map((calendarMonth, displayIndex) => {
250
- return (React.createElement(components.Month, { "data-animated-month": props.animate ? "true" : undefined, className: classNames[UI.Month], style: styles?.[UI.Month],
251
- // biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
252
- key: displayIndex, displayIndex: displayIndex, calendarMonth: calendarMonth },
253
- navLayout === "around" &&
254
- !props.hideNavigation &&
255
- displayIndex === 0 && (React.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : undefined },
256
- React.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" }))),
257
- 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
- (() => {
259
- const monthControl = captionLayout === "dropdown" ||
260
- captionLayout === "dropdown-months" ? (React.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI.MonthsDropdown], "aria-label": labelMonthDropdown(), classNames: classNames, components: components, 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)));
261
- const yearControl = captionLayout === "dropdown" ||
262
- captionLayout === "dropdown-years" ? (React.createElement(components.YearsDropdown, { key: "year", className: classNames[UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), classNames: classNames, components: components, 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)));
263
- const controls = dateLib.getMonthYearOrder() === "year-first"
264
- ? [yearControl, monthControl]
265
- : [monthControl, yearControl];
266
- return controls;
267
- })(),
268
- React.createElement("span", { role: "status", "aria-live": "polite", style: {
269
- border: 0,
270
- clip: "rect(0 0 0 0)",
271
- height: "1px",
272
- margin: "-1px",
273
- overflow: "hidden",
274
- padding: 0,
275
- position: "absolute",
276
- width: "1px",
277
- whiteSpace: "nowrap",
278
- wordWrap: "normal",
279
- } }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))) : (React.createElement(components.CaptionLabel, { className: classNames[UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))),
280
- navLayout === "around" &&
281
- !props.hideNavigation &&
282
- displayIndex === numberOfMonths - 1 && (React.createElement(components.NextMonthButton, { type: "button", className: classNames[UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : undefined },
283
- React.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, className: classNames[UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" }))),
284
- displayIndex === numberOfMonths - 1 &&
285
- navLayout === "after" &&
286
- !props.hideNavigation && (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 })),
287
- React.createElement(components.MonthGrid, { role: "grid", "aria-multiselectable": mode === "multiple" || mode === "range", "aria-label": labelGrid(calendarMonth.date, dateLib.options, dateLib) ||
288
- undefined, className: classNames[UI.MonthGrid], style: styles?.[UI.MonthGrid] },
289
- !props.hideWeekdays && (React.createElement(components.Weekdays, { "data-animated-weekdays": props.animate ? "true" : undefined, className: classNames[UI.Weekdays], style: styles?.[UI.Weekdays] },
290
- showWeekNumber && (React.createElement(components.WeekNumberHeader, { "aria-label": labelWeekNumberHeader(dateLib.options), className: classNames[UI.WeekNumberHeader], style: styles?.[UI.WeekNumberHeader], scope: "col" }, formatWeekNumberHeader())),
291
- weekdays.map((weekday) => (React.createElement(components.Weekday, { "aria-label": labelWeekday(weekday, dateLib.options, dateLib), className: classNames[UI.Weekday], key: String(weekday), style: styles?.[UI.Weekday], scope: "col" }, formatWeekdayName(weekday, dateLib.options, dateLib)))))),
292
- React.createElement(components.Weeks, { "data-animated-weeks": props.animate ? "true" : undefined, className: classNames[UI.Weeks], style: styles?.[UI.Weeks] }, calendarMonth.weeks.map((week) => {
293
- return (React.createElement(components.Week, { className: classNames[UI.Week], key: week.weekNumber, style: styles?.[UI.Week], week: week },
294
- showWeekNumber && (React.createElement(components.WeekNumber, { week: week, style: styles?.[UI.WeekNumber], "aria-label": labelWeekNumber(week.weekNumber, {
295
- locale,
296
- }), className: classNames[UI.WeekNumber], scope: "row", role: "rowheader" }, formatWeekNumber(week.weekNumber, dateLib))),
297
- week.days.map((day) => {
298
- const { date } = day;
299
- const modifiers = getModifiers(day);
300
- modifiers[DayFlag.focused] =
301
- !modifiers.hidden &&
302
- Boolean(focused?.isEqualTo(day));
303
- modifiers[SelectionState.selected] =
304
- isSelected?.(date) || modifiers.selected;
305
- if (isDateRange(selectedValue)) {
306
- // add range modifiers
307
- const { from, to } = selectedValue;
308
- modifiers[SelectionState.range_start] = Boolean(from && to && dateLib.isSameDay(date, from));
309
- modifiers[SelectionState.range_end] = Boolean(from && to && dateLib.isSameDay(date, to));
310
- modifiers[SelectionState.range_middle] =
311
- rangeIncludesDate(selectedValue, date, true, dateLib);
312
- }
313
- const style = getStyleForModifiers(modifiers, styles, props.modifiersStyles);
314
- const className = getClassNamesForModifiers(modifiers, classNames, props.modifiersClassNames);
315
- const ariaLabel = !isInteractive && !modifiers.hidden
316
- ? labelGridcell(date, modifiers, dateLib.options, dateLib)
317
- : undefined;
318
- return (React.createElement(components.Day, { key: `${day.isoDate}_${day.displayMonthId}`, day: day, modifiers: modifiers, className: className.join(" "), style: style, role: "gridcell", "aria-selected": modifiers.selected || undefined, "aria-label": ariaLabel, "data-day": day.isoDate, "data-month": day.outside ? day.dateMonthId : undefined, "data-selected": modifiers.selected || undefined, "data-disabled": modifiers.disabled || undefined, "data-hidden": modifiers.hidden || undefined, "data-outside": day.outside || undefined, "data-focused": modifiers.focused || undefined, "data-today": modifiers.today || undefined }, !modifiers.hidden && isInteractive ? (React.createElement(components.DayButton, { className: classNames[UI.DayButton], style: styles?.[UI.DayButton], type: "button", day: day, modifiers: modifiers, disabled: (!modifiers.focused &&
319
- modifiers.disabled) ||
320
- undefined, "aria-disabled": (modifiers.focused &&
321
- modifiers.disabled) ||
322
- undefined, tabIndex: isFocusTarget(day) ? 0 : -1, "aria-label": labelDayButton(date, modifiers, dateLib.options, dateLib), onClick: handleDayClick(day, modifiers), onBlur: handleDayBlur(day, modifiers), onFocus: handleDayFocus(day, modifiers), onKeyDown: handleDayKeyDown(day, modifiers), onMouseEnter: handleDayMouseEnter(day, modifiers), onMouseLeave: handleDayMouseLeave(day, modifiers) }, formatDay(date, dateLib.options, dateLib))) : (!modifiers.hidden &&
323
- formatDay(day.date, dateLib.options, dateLib))));
324
- })));
325
- })))));
326
- })),
251
+ React.createElement(components.Months, { className: classNames[UI.Months], style: styles?.[UI.Months] }, months.map((calendarMonth, displayIndex) => {
252
+ return (React.createElement(components.Month, { "data-animated-month": props.animate ? "true" : undefined, className: classNames[UI.Month], style: styles?.[UI.Month],
253
+ // biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
254
+ key: displayIndex, displayIndex: displayIndex, calendarMonth: calendarMonth },
255
+ navLayout === "around" &&
256
+ !props.hideNavigation &&
257
+ displayIndex === 0 && (React.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : undefined },
258
+ React.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" }))),
259
+ 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] },
260
+ (() => {
261
+ const monthControl = captionLayout === "dropdown" ||
262
+ 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
+ const yearControl = captionLayout === "dropdown" ||
264
+ 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
+ const controls = dateLib.getMonthYearOrder() === "year-first"
266
+ ? [yearControl, monthControl]
267
+ : [monthControl, yearControl];
268
+ return controls;
269
+ })(),
270
+ React.createElement("span", { role: "status", "aria-live": "polite", style: {
271
+ border: 0,
272
+ clip: "rect(0 0 0 0)",
273
+ height: "1px",
274
+ margin: "-1px",
275
+ overflow: "hidden",
276
+ padding: 0,
277
+ position: "absolute",
278
+ width: "1px",
279
+ whiteSpace: "nowrap",
280
+ wordWrap: "normal",
281
+ } }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))) : (React.createElement(components.CaptionLabel, { className: classNames[UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))),
282
+ navLayout === "around" &&
283
+ !props.hideNavigation &&
284
+ displayIndex === numberOfMonths - 1 && (React.createElement(components.NextMonthButton, { type: "button", className: classNames[UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : undefined },
285
+ React.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, className: classNames[UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" }))),
286
+ displayIndex === numberOfMonths - 1 &&
287
+ navLayout === "after" &&
288
+ !props.hideNavigation && (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 })),
289
+ React.createElement(components.MonthGrid, { role: "grid", "aria-multiselectable": mode === "multiple" || mode === "range", "aria-label": labelGrid(calendarMonth.date, dateLib.options, dateLib) ||
290
+ undefined, className: classNames[UI.MonthGrid], style: styles?.[UI.MonthGrid] },
291
+ !props.hideWeekdays && (React.createElement(components.Weekdays, { "data-animated-weekdays": props.animate ? "true" : undefined, className: classNames[UI.Weekdays], style: styles?.[UI.Weekdays] },
292
+ showWeekNumber && (React.createElement(components.WeekNumberHeader, { "aria-label": labelWeekNumberHeader(dateLib.options), className: classNames[UI.WeekNumberHeader], style: styles?.[UI.WeekNumberHeader], scope: "col" }, formatWeekNumberHeader())),
293
+ weekdays.map((weekday) => (React.createElement(components.Weekday, { "aria-label": labelWeekday(weekday, dateLib.options, dateLib), className: classNames[UI.Weekday], key: String(weekday), style: styles?.[UI.Weekday], scope: "col" }, formatWeekdayName(weekday, dateLib.options, dateLib)))))),
294
+ React.createElement(components.Weeks, { "data-animated-weeks": props.animate ? "true" : undefined, className: classNames[UI.Weeks], style: styles?.[UI.Weeks] }, calendarMonth.weeks.map((week) => {
295
+ return (React.createElement(components.Week, { className: classNames[UI.Week], key: week.weekNumber, style: styles?.[UI.Week], week: week },
296
+ showWeekNumber && (React.createElement(components.WeekNumber, { week: week, style: styles?.[UI.WeekNumber], "aria-label": labelWeekNumber(week.weekNumber, {
297
+ locale,
298
+ }), className: classNames[UI.WeekNumber], scope: "row", role: "rowheader" }, formatWeekNumber(week.weekNumber, dateLib))),
299
+ week.days.map((day) => {
300
+ const { date } = day;
301
+ const modifiers = getModifiers(day);
302
+ modifiers[DayFlag.focused] =
303
+ !modifiers.hidden &&
304
+ Boolean(focused?.isEqualTo(day));
305
+ modifiers[SelectionState.selected] =
306
+ isSelected?.(date) || modifiers.selected;
307
+ if (isDateRange(selectedValue)) {
308
+ // add range modifiers
309
+ const { from, to } = selectedValue;
310
+ modifiers[SelectionState.range_start] = Boolean(from && to && dateLib.isSameDay(date, from));
311
+ modifiers[SelectionState.range_end] = Boolean(from && to && dateLib.isSameDay(date, to));
312
+ modifiers[SelectionState.range_middle] =
313
+ rangeIncludesDate(selectedValue, date, true, dateLib);
314
+ }
315
+ const style = getStyleForModifiers(modifiers, styles, props.modifiersStyles);
316
+ const className = getClassNamesForModifiers(modifiers, classNames, props.modifiersClassNames);
317
+ const ariaLabel = !isInteractive && !modifiers.hidden
318
+ ? labelGridcell(date, modifiers, dateLib.options, dateLib)
319
+ : undefined;
320
+ return (React.createElement(components.Day, { key: `${day.isoDate}_${day.displayMonthId}`, day: day, modifiers: modifiers, className: className.join(" "), style: style, role: "gridcell", "aria-selected": modifiers.selected || undefined, "aria-label": ariaLabel, "data-day": day.isoDate, "data-month": day.outside ? day.dateMonthId : undefined, "data-selected": modifiers.selected || undefined, "data-disabled": modifiers.disabled || undefined, "data-hidden": modifiers.hidden || undefined, "data-outside": day.outside || undefined, "data-focused": modifiers.focused || undefined, "data-today": modifiers.today || undefined }, !modifiers.hidden && isInteractive ? (React.createElement(components.DayButton, { className: classNames[UI.DayButton], style: styles?.[UI.DayButton], type: "button", day: day, modifiers: modifiers, disabled: (!modifiers.focused &&
321
+ modifiers.disabled) ||
322
+ undefined, "aria-disabled": (modifiers.focused &&
323
+ modifiers.disabled) ||
324
+ undefined, tabIndex: isFocusTarget(day) ? 0 : -1, "aria-label": labelDayButton(date, modifiers, dateLib.options, dateLib), onClick: handleDayClick(day, modifiers), onBlur: handleDayBlur(day, modifiers), onFocus: handleDayFocus(day, modifiers), onKeyDown: handleDayKeyDown(day, modifiers), onMouseEnter: handleDayMouseEnter(day, modifiers), onMouseLeave: handleDayMouseLeave(day, modifiers) }, formatDay(date, dateLib.options, dateLib))) : (!modifiers.hidden &&
325
+ formatDay(day.date, dateLib.options, dateLib))));
326
+ })));
327
+ })))));
328
+ })),
327
329
  props.footer && (React.createElement(components.Footer, { className: classNames[UI.Footer], style: styles?.[UI.Footer], role: "status", "aria-live": "polite" }, props.footer)))));
328
330
  }
package/dist/esm/UI.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { CSSProperties } from "react";
2
1
  /**
3
2
  * Enum representing the UI elements composing DayPicker. These elements are
4
3
  * mapped to {@link CustomComponents}, {@link ClassNames}, and {@link Styles}.
@@ -80,8 +79,8 @@ export declare enum DayFlag {
80
79
  today = "today"
81
80
  }
82
81
  /**
83
- * Enum representing selection states that can be applied to the
84
- * {@link UI | UI.Day} element in selection mode.
82
+ * Enum representing selection states that can be applied to the {@link UI | UI.Day}
83
+ * element in selection mode.
85
84
  */
86
85
  export declare enum SelectionState {
87
86
  /** The day is at the end of a selected range. */
@@ -115,239 +114,3 @@ export declare enum Animation {
115
114
  /** The exiting caption when it disappears before the entering month. */
116
115
  caption_before_exit = "caption_before_exit"
117
116
  }
118
- /**
119
- * Deprecated UI elements and flags from previous versions of DayPicker.
120
- *
121
- * These elements are kept for backward compatibility and to assist in
122
- * transitioning to the new {@link UI} elements.
123
- *
124
- * @deprecated
125
- * @since 9.0.1
126
- * @template T - The type of the deprecated UI element (e.g., CSS class or
127
- * style).
128
- * @see https://daypicker.dev/upgrading
129
- * @see https://daypicker.dev/docs/styling
130
- */
131
- export type DeprecatedUI<T extends CSSProperties | string> = {
132
- /**
133
- * This element was applied to the style of any button in DayPicker and it is
134
- * replaced by {@link UI | UI.PreviousMonthButton} and
135
- * {@link UI | UI.NextMonthButton}.
136
- *
137
- * @deprecated
138
- */
139
- button: T;
140
- /**
141
- * This element was resetting the style of any button in DayPicker and it is
142
- * replaced by {@link UI | UI.PreviousMonthButton} and
143
- * {@link UI | UI.NextMonthButton}.
144
- *
145
- * @deprecated
146
- */
147
- button_reset: T;
148
- /**
149
- * This element has been renamed to {@link UI | UI.MonthCaption}.
150
- *
151
- * @deprecated
152
- */
153
- caption: T;
154
- /**
155
- * This element has been removed. Captions are styled via
156
- * {@link UI | UI.MonthCaption}.
157
- *
158
- * @deprecated
159
- */
160
- caption_between: T;
161
- /**
162
- * This element has been renamed to {@link UI | UI.Dropdowns}.
163
- *
164
- * @deprecated
165
- */
166
- caption_dropdowns: T;
167
- /**
168
- * This element has been removed. Captions are styled via
169
- * {@link UI | UI.MonthCaption}.
170
- *
171
- * @deprecated
172
- */
173
- caption_end: T;
174
- /**
175
- * This element has been removed.
176
- *
177
- * @deprecated
178
- */
179
- caption_start: T;
180
- /**
181
- * This element has been renamed to {@link UI | UI.Day}.
182
- *
183
- * @deprecated
184
- */
185
- cell: T;
186
- /**
187
- * This element has been renamed to {@link DayFlag | DayFlag.disabled}.
188
- *
189
- * @deprecated
190
- */
191
- day_disabled: T;
192
- /**
193
- * This element has been renamed to {@link DayFlag | DayFlag.hidden}.
194
- *
195
- * @deprecated
196
- */
197
- day_hidden: T;
198
- /**
199
- * This element has been renamed to {@link DayFlag | DayFlag.outside}.
200
- *
201
- * @deprecated
202
- */
203
- day_outside: T;
204
- /**
205
- * This element has been renamed to
206
- * {@link SelectionState | SelectionState.range_end}.
207
- *
208
- * @deprecated
209
- */
210
- day_range_end: T;
211
- /**
212
- * This element has been renamed to
213
- * {@link SelectionState | SelectionState.range_middle}.
214
- *
215
- * @deprecated
216
- */
217
- day_range_middle: T;
218
- /**
219
- * This element has been renamed to
220
- * {@link SelectionState | SelectionState.range_start}.
221
- *
222
- * @deprecated
223
- */
224
- day_range_start: T;
225
- /**
226
- * This element has been renamed to
227
- * {@link SelectionState | SelectionState.selected}.
228
- *
229
- * @deprecated
230
- */
231
- day_selected: T;
232
- /**
233
- * This element has been renamed to {@link DayFlag | DayFlag.today}.
234
- *
235
- * @deprecated
236
- */
237
- day_today: T;
238
- /**
239
- * This element has been removed. The dropdown icon is now
240
- * {@link UI | UI.Chevron} inside a {@link UI | UI.CaptionLabel}.
241
- *
242
- * @deprecated
243
- */
244
- dropdown_icon: T;
245
- /**
246
- * This element has been renamed to {@link UI | UI.MonthsDropdown}.
247
- *
248
- * @deprecated
249
- */
250
- dropdown_month: T;
251
- /**
252
- * This element has been renamed to {@link UI | UI.YearsDropdown}.
253
- *
254
- * @deprecated
255
- */
256
- dropdown_year: T;
257
- /**
258
- * This element has been removed.
259
- *
260
- * @deprecated
261
- */
262
- head: T;
263
- /**
264
- * This element has been renamed to {@link UI | UI.Weekday}.
265
- *
266
- * @deprecated
267
- */
268
- head_cell: T;
269
- /**
270
- * This element has been renamed to {@link UI | UI.Weekdays}.
271
- *
272
- * @deprecated
273
- */
274
- head_row: T;
275
- /**
276
- * This flag has been removed. Use `data-multiple-months` in your CSS
277
- * selectors.
278
- *
279
- * @deprecated
280
- */
281
- multiple_months: T;
282
- /**
283
- * This element has been removed. To style the navigation buttons, use
284
- * {@link UI | UI.PreviousMonthButton} and {@link UI | UI.NextMonthButton}.
285
- *
286
- * @deprecated
287
- */
288
- nav_button: T;
289
- /**
290
- * This element has been renamed to {@link UI | UI.NextMonthButton}.
291
- *
292
- * @deprecated
293
- */
294
- nav_button_next: T;
295
- /**
296
- * This element has been renamed to {@link UI | UI.PreviousMonthButton}.
297
- *
298
- * @deprecated
299
- */
300
- nav_button_previous: T;
301
- /**
302
- * This element has been removed. The dropdown icon is now
303
- * {@link UI | UI.Chevron} inside a {@link UI | UI.NextMonthButton} or a
304
- * {@link UI | UI.PreviousMonthButton}.
305
- *
306
- * @deprecated
307
- */
308
- nav_icon: T;
309
- /**
310
- * This element has been renamed to {@link UI | UI.Week}.
311
- *
312
- * @deprecated
313
- */
314
- row: T;
315
- /**
316
- * This element has been renamed to {@link UI | UI.MonthGrid}.
317
- *
318
- * @deprecated
319
- */
320
- table: T;
321
- /**
322
- * This element has been renamed to {@link UI | UI.Weeks}.
323
- *
324
- * @deprecated
325
- */
326
- tbody: T;
327
- /**
328
- * This element has been removed. The {@link UI | UI.Footer} is now a single
329
- * element below the months.
330
- *
331
- * @deprecated
332
- */
333
- tfoot: T;
334
- /**
335
- * This flag has been removed. There are no "visually hidden" elements in
336
- * DayPicker 9.
337
- *
338
- * @deprecated
339
- */
340
- vhidden: T;
341
- /**
342
- * This element has been renamed. Use {@link UI | UI.WeekNumber} instead.
343
- *
344
- * @deprecated
345
- */
346
- weeknumber: T;
347
- /**
348
- * This flag has been removed. Use `data-week-numbers` in your CSS.
349
- *
350
- * @deprecated
351
- */
352
- with_weeknumber: T;
353
- };
package/dist/esm/UI.js CHANGED
@@ -81,8 +81,8 @@ export var DayFlag;
81
81
  DayFlag["today"] = "today";
82
82
  })(DayFlag || (DayFlag = {}));
83
83
  /**
84
- * Enum representing selection states that can be applied to the
85
- * {@link UI | UI.Day} element in selection mode.
84
+ * Enum representing selection states that can be applied to the {@link UI | UI.Day}
85
+ * element in selection mode.
86
86
  */
87
87
  export var SelectionState;
88
88
  (function (SelectionState) {
@@ -20,16 +20,6 @@ export interface DayPickerLocale extends DateFnsLocale {
20
20
  labels?: DayPickerLocaleLabels;
21
21
  }
22
22
  export type Locale = DayPickerLocale;
23
- /**
24
- * @ignore
25
- * @deprecated Use {@link DateLibOptions} instead.
26
- */
27
- export type FormatOptions = DateLibOptions;
28
- /**
29
- * @ignore
30
- * @deprecated Use {@link DateLibOptions} instead.
31
- */
32
- export type LabelOptions = DateLibOptions;
33
23
  /** Indicates the preferred ordering of month and year for localized labels. */
34
24
  export type MonthYearOrder = "month-first" | "year-first";
35
25
  /**
@@ -116,12 +106,6 @@ export declare class DateLib {
116
106
  */
117
107
  formatMonthYear(date: Date): string;
118
108
  private static readonly yearFirstLocales;
119
- /**
120
- * Reference to the built-in Date constructor.
121
- *
122
- * @deprecated Use `newDate()` or `today()`.
123
- */
124
- Date: typeof Date;
125
109
  /**
126
110
  * Creates a new `Date` object representing today's date.
127
111
  *
@@ -400,8 +384,3 @@ export { enUS as defaultLocale } from "../locale/en-US.js";
400
384
  * @since 9.2.0
401
385
  */
402
386
  export declare const defaultDateLib: DateLib;
403
- /**
404
- * @ignore
405
- * @deprecated Use `defaultDateLib`.
406
- */
407
- export declare const dateLib: DateLib;
@@ -20,12 +20,6 @@ export class DateLib {
20
20
  * @param overrides Custom overrides for the date library functions.
21
21
  */
22
22
  constructor(options, overrides) {
23
- /**
24
- * Reference to the built-in Date constructor.
25
- *
26
- * @deprecated Use `newDate()` or `today()`.
27
- */
28
- this.Date = Date;
29
23
  /**
30
24
  * Creates a new `Date` object representing today's date.
31
25
  *
@@ -39,7 +33,8 @@ export class DateLib {
39
33
  if (this.options.timeZone) {
40
34
  return TZDate.tz(this.options.timeZone);
41
35
  }
42
- return new this.Date();
36
+ const DateCtor = this.options.Date ?? Date;
37
+ return new DateCtor();
43
38
  };
44
39
  /**
45
40
  * Creates a new `Date` object with the specified year, month, and day.
@@ -569,8 +564,3 @@ export { enUS as defaultLocale } from "../locale/en-US.js";
569
564
  * @since 9.2.0
570
565
  */
571
566
  export const defaultDateLib = new DateLib();
572
- /**
573
- * @ignore
574
- * @deprecated Use `defaultDateLib`.
575
- */
576
- export const dateLib = defaultDateLib;
@@ -7,9 +7,7 @@ import React from "react";
7
7
  */
8
8
  export function Chevron(props) {
9
9
  const { size = 24, orientation = "left", className } = props;
10
- return (
11
- // biome-ignore lint/a11y/noSvgWithoutTitle: handled by the parent component
12
- React.createElement("svg", { className: className, width: size, height: size, viewBox: "0 0 24 24" },
10
+ return (React.createElement("svg", { className: className, width: size, height: size, viewBox: "0 0 24 24" },
13
11
  orientation === "up" && (React.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" })),
14
12
  orientation === "down" && (React.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" })),
15
13
  orientation === "left" && (React.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" })),
@@ -1,5 +1,4 @@
1
1
  import React, { type SelectHTMLAttributes } from "react";
2
- import type { ClassNames, CustomComponents } from "../types/index.js";
3
2
  /** An option to use in the dropdown. Maps to the `<option>` HTML element. */
4
3
  export type DropdownOption = {
5
4
  /** The value of the option. */
@@ -16,16 +15,6 @@ export type DropdownOption = {
16
15
  * @see https://daypicker.dev/guides/custom-components
17
16
  */
18
17
  export declare function Dropdown(props: {
19
- /**
20
- * @deprecated Use {@link useDayPicker} hook to get the list of internal
21
- * components.
22
- */
23
- components: CustomComponents;
24
- /**
25
- * @deprecated Use {@link useDayPicker} hook to get the list of internal
26
- * class names.
27
- */
28
- classNames: ClassNames;
29
18
  /** The options to display in the dropdown. */
30
19
  options?: DropdownOption[] | undefined;
31
20
  } & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">): React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { UI } from "../UI.js";
3
+ import { useDayPicker } from "../useDayPicker.js";
3
4
  /**
4
5
  * Render a dropdown component for navigation in the calendar.
5
6
  *
@@ -7,7 +8,8 @@ import { UI } from "../UI.js";
7
8
  * @see https://daypicker.dev/guides/custom-components
8
9
  */
9
10
  export function Dropdown(props) {
10
- const { options, className, components, classNames, ...selectProps } = props;
11
+ const { options, className, ...selectProps } = props;
12
+ const { classNames, components } = useDayPicker();
11
13
  const cssClassSelect = [classNames[UI.Dropdown], className].join(" ");
12
14
  const selectedOption = options?.find(({ value }) => value === selectProps.value);
13
15
  return (React.createElement("span", { "data-disabled": selectProps.disabled, className: classNames[UI.DropdownRoot] },
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { useDayPicker } from "../useDayPicker.js";
3
2
  /**
4
3
  * Render the button to navigate to the next month in the calendar.
5
4
  *
@@ -7,6 +6,5 @@ import { useDayPicker } from "../useDayPicker.js";
7
6
  * @see https://daypicker.dev/guides/custom-components
8
7
  */
9
8
  export function NextMonthButton(props) {
10
- const { components } = useDayPicker();
11
- return React.createElement(components.Button, { ...props });
9
+ return React.createElement("button", { ...props });
12
10
  }
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { useDayPicker } from "../useDayPicker.js";
3
2
  /**
4
3
  * Render the button to navigate to the previous month in the calendar.
5
4
  *
@@ -7,6 +6,5 @@ import { useDayPicker } from "../useDayPicker.js";
7
6
  * @see https://daypicker.dev/guides/custom-components
8
7
  */
9
8
  export function PreviousMonthButton(props) {
10
- const { components } = useDayPicker();
11
- return React.createElement(components.Button, { ...props });
9
+ return React.createElement("button", { ...props });
12
10
  }
@@ -1,4 +1,3 @@
1
- export * from "./Button.js";
2
1
  export * from "./CaptionLabel.js";
3
2
  export * from "./Chevron.js";
4
3
  export * from "./Day.js";
@@ -1,4 +1,3 @@
1
- export * from "./Button.js";
2
1
  export * from "./CaptionLabel.js";
3
2
  export * from "./Chevron.js";
4
3
  export * from "./Day.js";