react-day-picker 9.6.2 → 9.6.3

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 (177) hide show
  1. package/dist/cjs/DayPicker.js +14 -2
  2. package/dist/cjs/DayPicker.js.map +1 -1
  3. package/dist/cjs/classes/DateLib.js +4 -4
  4. package/dist/cjs/classes/DateLib.js.map +1 -1
  5. package/dist/esm/DayPicker.js +14 -2
  6. package/dist/esm/DayPicker.js.map +1 -1
  7. package/dist/esm/classes/DateLib.js +1 -1
  8. package/dist/esm/classes/DateLib.js.map +1 -1
  9. package/package.json +2 -4
  10. package/src/.eslintignore +1 -0
  11. package/src/.eslintrc.cjs +27 -0
  12. package/src/DayPicker.test.tsx +199 -0
  13. package/src/DayPicker.tsx +629 -0
  14. package/src/UI.ts +365 -0
  15. package/src/classes/CalendarDay.test.ts +17 -0
  16. package/src/classes/CalendarDay.ts +61 -0
  17. package/src/classes/CalendarMonth.test.ts +28 -0
  18. package/src/classes/CalendarMonth.ts +15 -0
  19. package/src/classes/CalendarWeek.test.ts +21 -0
  20. package/src/classes/CalendarWeek.ts +13 -0
  21. package/src/classes/DateLib.ts +615 -0
  22. package/src/classes/index.ts +4 -0
  23. package/src/components/Button.tsx +13 -0
  24. package/src/components/CaptionLabel.tsx +13 -0
  25. package/src/components/Chevron.tsx +42 -0
  26. package/src/components/Day.tsx +28 -0
  27. package/src/components/DayButton.tsx +29 -0
  28. package/src/components/Dropdown.tsx +71 -0
  29. package/src/components/DropdownNav.tsx +13 -0
  30. package/src/components/Footer.tsx +13 -0
  31. package/src/components/Month.tsx +24 -0
  32. package/src/components/MonthCaption.tsx +23 -0
  33. package/src/components/MonthGrid.tsx +13 -0
  34. package/src/components/Months.tsx +13 -0
  35. package/src/components/MonthsDropdown.tsx +16 -0
  36. package/src/components/Nav.tsx +90 -0
  37. package/src/components/NextMonthButton.tsx +18 -0
  38. package/src/components/Option.tsx +13 -0
  39. package/src/components/PreviousMonthButton.tsx +20 -0
  40. package/src/components/Root.tsx +19 -0
  41. package/src/components/Select.tsx +13 -0
  42. package/src/components/Week.tsx +20 -0
  43. package/src/components/WeekNumber.tsx +21 -0
  44. package/src/components/WeekNumberHeader.tsx +15 -0
  45. package/src/components/Weekday.tsx +13 -0
  46. package/src/components/Weekdays.tsx +17 -0
  47. package/src/components/Weeks.tsx +13 -0
  48. package/src/components/YearsDropdown.tsx +16 -0
  49. package/src/components/custom-components.tsx +26 -0
  50. package/src/formatters/formatCaption.test.ts +27 -0
  51. package/src/formatters/formatCaption.ts +23 -0
  52. package/src/formatters/formatDay.test.ts +7 -0
  53. package/src/formatters/formatDay.ts +16 -0
  54. package/src/formatters/formatMonthDropdown.test.ts +19 -0
  55. package/src/formatters/formatMonthDropdown.ts +15 -0
  56. package/src/formatters/formatWeekNumber.test.ts +5 -0
  57. package/src/formatters/formatWeekNumber.ts +13 -0
  58. package/src/formatters/formatWeekNumberHeader.ts +10 -0
  59. package/src/formatters/formatWeekdayName.test.ts +15 -0
  60. package/src/formatters/formatWeekdayName.ts +16 -0
  61. package/src/formatters/formatYearDropdown.test.ts +7 -0
  62. package/src/formatters/formatYearDropdown.ts +21 -0
  63. package/src/formatters/index.ts +7 -0
  64. package/src/helpers/broadcastCalendar.test.ts +43 -0
  65. package/src/helpers/calculateFocusTarget.ts +51 -0
  66. package/src/helpers/endOfBroadcastWeek.test.ts +25 -0
  67. package/src/helpers/endOfBroadcastWeek.ts +16 -0
  68. package/src/helpers/getBroadcastWeeksInMonth.test.ts +23 -0
  69. package/src/helpers/getBroadcastWeeksInMonth.ts +31 -0
  70. package/src/helpers/getClassNamesForModifiers.ts +26 -0
  71. package/src/helpers/getComponents.ts +11 -0
  72. package/src/helpers/getDataAttributes.test.tsx +48 -0
  73. package/src/helpers/getDataAttributes.tsx +21 -0
  74. package/src/helpers/getDates.test.ts +190 -0
  75. package/src/helpers/getDates.ts +64 -0
  76. package/src/helpers/getDays.test.ts +30 -0
  77. package/src/helpers/getDays.ts +16 -0
  78. package/src/helpers/getDefaultClassNames.test.ts +47 -0
  79. package/src/helpers/getDefaultClassNames.ts +33 -0
  80. package/src/helpers/getDisplayMonths.test.ts +44 -0
  81. package/src/helpers/getDisplayMonths.ts +20 -0
  82. package/src/helpers/getFocusableDate.ts +59 -0
  83. package/src/helpers/getFormatters.test.ts +48 -0
  84. package/src/helpers/getFormatters.ts +19 -0
  85. package/src/helpers/getInitialMonth.test.ts +79 -0
  86. package/src/helpers/getInitialMonth.ts +41 -0
  87. package/src/helpers/getLabels.ts +10 -0
  88. package/src/helpers/getMonthOptions.test.ts +226 -0
  89. package/src/helpers/getMonthOptions.ts +37 -0
  90. package/src/helpers/getMonths.test.ts +88 -0
  91. package/src/helpers/getMonths.ts +90 -0
  92. package/src/helpers/getNavMonth.test.ts +253 -0
  93. package/src/helpers/getNavMonth.ts +70 -0
  94. package/src/helpers/getNextFocus.test.tsx +99 -0
  95. package/src/helpers/getNextFocus.tsx +67 -0
  96. package/src/helpers/getNextMonth.test.ts +101 -0
  97. package/src/helpers/getNextMonth.ts +45 -0
  98. package/src/helpers/getPossibleFocusDate.test.ts +144 -0
  99. package/src/helpers/getPreviousMonth.test.ts +77 -0
  100. package/src/helpers/getPreviousMonth.ts +40 -0
  101. package/src/helpers/getStyleForModifiers.test.ts +92 -0
  102. package/src/helpers/getStyleForModifiers.ts +21 -0
  103. package/src/helpers/getWeekdays.test.ts +44 -0
  104. package/src/helpers/getWeekdays.ts +29 -0
  105. package/src/helpers/getWeeks.test.ts +30 -0
  106. package/src/helpers/getWeeks.ts +9 -0
  107. package/src/helpers/getYearOptions.test.ts +46 -0
  108. package/src/helpers/getYearOptions.ts +34 -0
  109. package/src/helpers/index.ts +2 -0
  110. package/src/helpers/startOfBroadcastWeek.test.ts +24 -0
  111. package/src/helpers/startOfBroadcastWeek.ts +19 -0
  112. package/src/helpers/useControlledValue.test.ts +45 -0
  113. package/src/helpers/useControlledValue.ts +33 -0
  114. package/src/index.ts +15 -0
  115. package/src/jalali.tsx +2 -0
  116. package/src/labels/index.ts +12 -0
  117. package/src/labels/labelDayButton.test.ts +41 -0
  118. package/src/labels/labelDayButton.ts +31 -0
  119. package/src/labels/labelGrid.test.ts +7 -0
  120. package/src/labels/labelGrid.ts +23 -0
  121. package/src/labels/labelGridcell.test.ts +7 -0
  122. package/src/labels/labelGridcell.ts +22 -0
  123. package/src/labels/labelMonthDropdown.test.ts +5 -0
  124. package/src/labels/labelMonthDropdown.ts +12 -0
  125. package/src/labels/labelNav.test.ts +5 -0
  126. package/src/labels/labelNav.ts +10 -0
  127. package/src/labels/labelNext.test.ts +5 -0
  128. package/src/labels/labelNext.ts +13 -0
  129. package/src/labels/labelPrevious.test.ts +5 -0
  130. package/src/labels/labelPrevious.ts +13 -0
  131. package/src/labels/labelWeekNumber.test.ts +5 -0
  132. package/src/labels/labelWeekNumber.ts +15 -0
  133. package/src/labels/labelWeekNumberHeader.test.ts +5 -0
  134. package/src/labels/labelWeekNumberHeader.ts +12 -0
  135. package/src/labels/labelWeekday.test.ts +15 -0
  136. package/src/labels/labelWeekday.ts +16 -0
  137. package/src/labels/labelYearDropdown.test.ts +5 -0
  138. package/src/labels/labelYearDropdown.ts +12 -0
  139. package/src/locale.ts +1 -0
  140. package/src/persian.tsx +86 -0
  141. package/src/selection/useMulti.test.tsx +41 -0
  142. package/src/selection/useMulti.tsx +74 -0
  143. package/src/selection/useRange.test.tsx +154 -0
  144. package/src/selection/useRange.tsx +73 -0
  145. package/src/selection/useSingle.test.tsx +38 -0
  146. package/src/selection/useSingle.tsx +69 -0
  147. package/src/types/deprecated.ts +230 -0
  148. package/src/types/index.ts +4 -0
  149. package/src/types/props.test.tsx +71 -0
  150. package/src/types/props.ts +675 -0
  151. package/src/types/selection.ts +57 -0
  152. package/src/types/shared.ts +442 -0
  153. package/src/useAnimation.test.tsx +134 -0
  154. package/src/useAnimation.ts +203 -0
  155. package/src/useCalendar.ts +178 -0
  156. package/src/useDayPicker.test.tsx +142 -0
  157. package/src/useDayPicker.ts +93 -0
  158. package/src/useFocus.ts +87 -0
  159. package/src/useGetModifiers.test.tsx +154 -0
  160. package/src/useGetModifiers.tsx +122 -0
  161. package/src/useSelection.ts +26 -0
  162. package/src/utc.tsx +10 -0
  163. package/src/utils/addToRange.test.ts +117 -0
  164. package/src/utils/addToRange.ts +87 -0
  165. package/src/utils/dateMatchModifiers.test.ts +120 -0
  166. package/src/utils/dateMatchModifiers.ts +88 -0
  167. package/src/utils/index.ts +7 -0
  168. package/src/utils/rangeContainsDayOfWeek.test.ts +48 -0
  169. package/src/utils/rangeContainsDayOfWeek.ts +35 -0
  170. package/src/utils/rangeContainsModifiers.test.ts +230 -0
  171. package/src/utils/rangeContainsModifiers.ts +125 -0
  172. package/src/utils/rangeIncludesDate.test.ts +46 -0
  173. package/src/utils/rangeIncludesDate.ts +43 -0
  174. package/src/utils/rangeOverlaps.test.ts +60 -0
  175. package/src/utils/rangeOverlaps.ts +22 -0
  176. package/src/utils/typeguards.test.ts +83 -0
  177. package/src/utils/typeguards.ts +70 -0
@@ -0,0 +1,675 @@
1
+ import React from "react";
2
+
3
+ import type { DeprecatedUI } from "../UI.js";
4
+ import type { Locale, DateLib } from "../classes/DateLib.js";
5
+
6
+ import type {
7
+ ClassNames,
8
+ ModifiersClassNames,
9
+ Styles,
10
+ ModifiersStyles,
11
+ CustomComponents,
12
+ Matcher,
13
+ Labels,
14
+ Formatters,
15
+ MonthChangeEventHandler,
16
+ DayEventHandler,
17
+ Modifiers,
18
+ DateRange,
19
+ Mode,
20
+ Numerals
21
+ } from "./shared.js";
22
+
23
+ /**
24
+ * The props for the `<DayPicker />` component.
25
+ *
26
+ * @group DayPicker
27
+ */
28
+ export type DayPickerProps = PropsBase &
29
+ (
30
+ | PropsSingle
31
+ | PropsSingleRequired
32
+ | PropsMulti
33
+ | PropsMultiRequired
34
+ | PropsRange
35
+ | PropsRangeRequired
36
+ | { mode?: undefined; required?: undefined }
37
+ );
38
+
39
+ /**
40
+ * Props for customizing the calendar, handling localization, and managing
41
+ * events. These exclude the selection mode props.
42
+ *
43
+ * @group DayPicker
44
+ * @see https://daypicker.dev/api/interfaces/PropsBase
45
+ */
46
+ export interface PropsBase {
47
+ /**
48
+ * Enable the selection of a single day, multiple days, or a range of days.
49
+ *
50
+ * @see https://daypicker.dev/docs/selection-modes
51
+ */
52
+ mode?: Mode | undefined;
53
+ /**
54
+ * Whether the selection is required.
55
+ *
56
+ * @see https://daypicker.dev/docs/selection-modes
57
+ */
58
+ required?: boolean | undefined;
59
+
60
+ /** Class name to add to the root element. */
61
+ className?: string;
62
+ /**
63
+ * Change the class names used by DayPicker.
64
+ *
65
+ * Use this prop when you need to change the default class names — for
66
+ * example, when importing the style via CSS modules or when using a CSS
67
+ * framework.
68
+ *
69
+ * @see https://daypicker.dev/docs/styling
70
+ */
71
+ classNames?: Partial<ClassNames> & Partial<DeprecatedUI<string>>;
72
+ /**
73
+ * Change the class name for the day matching the `modifiers`.
74
+ *
75
+ * @see https://daypicker.dev/guides/custom-modifiers
76
+ */
77
+ modifiersClassNames?: ModifiersClassNames;
78
+ /** Style to apply to the root element. */
79
+ style?: React.CSSProperties;
80
+ /**
81
+ * Change the inline styles of the HTML elements.
82
+ *
83
+ * @see https://daypicker.dev/docs/styling
84
+ */
85
+ styles?: Partial<Styles> & Partial<DeprecatedUI<React.CSSProperties>>;
86
+ /**
87
+ * Change the class name for the day matching the {@link modifiers}.
88
+ *
89
+ * @see https://daypicker.dev/guides/custom-modifiers
90
+ */
91
+ modifiersStyles?: ModifiersStyles;
92
+ /** A unique id to add to the root element. */
93
+ id?: string;
94
+ /**
95
+ * The initial month to show in the calendar.
96
+ *
97
+ * Use this prop to let DayPicker control the current month. If you need to
98
+ * set the month programmatically, use {@link month} and {@link onMonthChange}.
99
+ *
100
+ * @defaultValue The current month
101
+ * @see https://daypicker.dev/docs/navigation
102
+ */
103
+ defaultMonth?: Date;
104
+ /**
105
+ * The month displayed in the calendar.
106
+ *
107
+ * As opposed to `defaultMonth`, use this prop with `onMonthChange` to change
108
+ * the month programmatically.
109
+ *
110
+ * @see https://daypicker.dev/docs/navigation
111
+ */
112
+ month?: Date;
113
+ /**
114
+ * The number of displayed months.
115
+ *
116
+ * @defaultValue 1
117
+ * @see https://daypicker.dev/docs/customization#multiplemonths
118
+ */
119
+ numberOfMonths?: number;
120
+ /**
121
+ * The earliest month to start the month navigation.
122
+ *
123
+ * @since 9.0.0
124
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
125
+ */
126
+ startMonth?: Date | undefined;
127
+ /**
128
+ * @private
129
+ * @deprecated This prop has been removed. Use `hidden={{ before: date }}`
130
+ * instead.
131
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
132
+ */
133
+ fromDate?: Date | undefined;
134
+ /**
135
+ * @private
136
+ * @deprecated This prop has been renamed to `startMonth`.
137
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
138
+ */
139
+ fromMonth?: Date | undefined;
140
+ /**
141
+ * @private
142
+ * @deprecated Use `startMonth` instead. E.g. `startMonth={new Date(year,
143
+ * 0)}`.
144
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
145
+ */
146
+ fromYear?: number | undefined;
147
+
148
+ /**
149
+ * The latest month to end the month navigation.
150
+ *
151
+ * @since 9.0.0
152
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
153
+ */
154
+ endMonth?: Date;
155
+ /**
156
+ * @private
157
+ * @deprecated This prop has been removed. Use `hidden={{ after: date }}`
158
+ * instead.
159
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
160
+ */
161
+ toDate?: Date;
162
+ /**
163
+ * @private
164
+ * @deprecated This prop has been renamed to `endMonth`.
165
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
166
+ */
167
+ toMonth?: Date;
168
+ /**
169
+ * @private
170
+ * @deprecated Use `endMonth` instead. E.g. `endMonth={new Date(year, 0)}`.
171
+ * @see https://daypicker.dev/docs/navigation#start-and-end-dates
172
+ */
173
+ toYear?: number;
174
+
175
+ /**
176
+ * Paginate the month navigation displaying the `numberOfMonths` at a time.
177
+ *
178
+ * @see https://daypicker.dev/docs/customization#multiplemonths
179
+ */
180
+ pagedNavigation?: boolean;
181
+ /**
182
+ * Render the months in reversed order (when {@link numberOfMonths} is set) to
183
+ * display the most recent month first.
184
+ *
185
+ * @see https://daypicker.dev/docs/customization#multiplemonths
186
+ */
187
+ reverseMonths?: boolean;
188
+ /**
189
+ * Hide the navigation buttons. This prop won't disable the navigation: to
190
+ * disable the navigation, use {@link disableNavigation}.
191
+ *
192
+ * @since 9.0.0
193
+ * @see https://daypicker.dev/docs/navigation#hidenavigation
194
+ */
195
+ hideNavigation?: boolean;
196
+ /**
197
+ * Disable the navigation between months. This prop won't hide the navigation:
198
+ * to hide the navigation, use {@link hideNavigation}.
199
+ *
200
+ * @see https://daypicker.dev/docs/navigation#disablenavigation
201
+ */
202
+ disableNavigation?: boolean;
203
+ /**
204
+ * Show dropdowns to navigate between months or years.
205
+ *
206
+ * - `true`: display the dropdowns for both month and year
207
+ * - `label`: display the month and the year as a label. Change the label with
208
+ * the `formatCaption` formatter.
209
+ * - `month`: display only the dropdown for the months
210
+ * - `year`: display only the dropdown for the years
211
+ *
212
+ * **Note:** showing the dropdown will set the start/end months
213
+ * {@link startMonth} to 100 years ago, and {@link endMonth} to the end of the
214
+ * current year.
215
+ *
216
+ * @see https://daypicker.dev/docs/customization#caption-layouts
217
+ */
218
+ captionLayout?: "label" | "dropdown" | "dropdown-months" | "dropdown-years";
219
+ /**
220
+ * Display always 6 weeks per each month, regardless of the month’s number of
221
+ * weeks. Weeks will be filled with the days from the next month.
222
+ *
223
+ * @see https://daypicker.dev/docs/customization#fixed-weeks
224
+ */
225
+ fixedWeeks?: boolean;
226
+ /**
227
+ * Hide the row displaying the weekday row header.
228
+ *
229
+ * @since 9.0.0
230
+ */
231
+ hideWeekdays?: boolean;
232
+ /**
233
+ * Show the outside days (days falling in the next or the previous month).
234
+ *
235
+ * **Note:** when a {@link broadcastCalendar} is set, this prop defaults to
236
+ * true.
237
+ *
238
+ * @see https://daypicker.dev/docs/customization#outside-days
239
+ */
240
+ showOutsideDays?: boolean;
241
+ /**
242
+ * Show the week numbers column. Weeks are numbered according to the local
243
+ * week index.
244
+ *
245
+ * @see https://daypicker.dev/docs/customization#showweeknumber
246
+ */
247
+ showWeekNumber?: boolean;
248
+ /**
249
+ * Animate navigating between months.
250
+ *
251
+ * @since 9.6.0
252
+ * @see https://daypicker.dev/docs/navigation#animate
253
+ */
254
+ animate?: boolean;
255
+ /**
256
+ * Display the weeks in the month following the broadcast calendar. Setting
257
+ * this prop will ignore {@link weekStartsOn} (always Monday) and
258
+ * {@link showOutsideDays} will default to true.
259
+ *
260
+ * @since 9.4.0
261
+ * @see https://daypicker.dev/docs/localization#broadcast-calendar
262
+ * @see https://en.wikipedia.org/wiki/Broadcast_calendar
263
+ */
264
+ broadcastCalendar?: boolean;
265
+ /**
266
+ * Use ISO week dates instead of the locale setting. Setting this prop will
267
+ * ignore `weekStartsOn` and `firstWeekContainsDate`.
268
+ *
269
+ * @see https://daypicker.dev/docs/localization#iso-week-dates
270
+ * @see https://en.wikipedia.org/wiki/ISO_week_date
271
+ */
272
+ ISOWeek?: boolean;
273
+ /**
274
+ * The time zone (IANA or UTC offset) to use in the calendar (experimental).
275
+ * See
276
+ * [Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
277
+ * for the possible values.
278
+ *
279
+ * Time zones are supported by the `TZDate` object by the
280
+ * [@date-fns/tz](https://github.com/date-fns/tz) package. Please refer to the
281
+ * package documentation for more information.
282
+ *
283
+ * @since 9.1.1
284
+ * @experimental
285
+ * @see https://daypicker.dev/docs/time-zone
286
+ */
287
+ timeZone?: string | undefined;
288
+ /**
289
+ * Change the components used for rendering the calendar elements.
290
+ *
291
+ * @see https://daypicker.dev/guides/custom-components
292
+ */
293
+ components?: Partial<CustomComponents>;
294
+ /**
295
+ * Add a footer to the calendar, acting as a live region.
296
+ *
297
+ * Use this prop to communicate the calendar's status to screen readers.
298
+ * Prefer strings over complex UI elements.
299
+ *
300
+ * @see https://daypicker.dev/guides/accessibility#footer
301
+ */
302
+ footer?: React.ReactNode | string;
303
+ /**
304
+ * When a selection mode is set, DayPicker will focus the first selected day
305
+ * (if set) or today's date (if not disabled).
306
+ *
307
+ * Use this prop when you need to focus DayPicker after a user action, for
308
+ * improved accessibility.
309
+ *
310
+ * @see https://daypicker.dev/guides/accessibility#autofocus
311
+ */
312
+ autoFocus?: boolean;
313
+ /**
314
+ * @private
315
+ * @deprecated This prop will be removed. Use {@link autoFocus} instead.
316
+ */
317
+ initialFocus?: boolean;
318
+ /**
319
+ * Apply the `disabled` modifier to the matching days.
320
+ *
321
+ * @see https://daypicker.dev/docs/selection-modes#disabling-dates
322
+ */
323
+ disabled?: Matcher | Matcher[] | undefined;
324
+ /**
325
+ * Apply the `hidden` modifier to the matching days. Will hide them from the
326
+ * calendar.
327
+ *
328
+ * @see https://daypicker.dev/guides/custom-modifiers#hidden-modifier
329
+ */
330
+ hidden?: Matcher | Matcher[] | undefined;
331
+ /**
332
+ * The today’s date. Default is the current date. This date will get the
333
+ * `today` modifier to style the day.
334
+ *
335
+ * @see https://daypicker.dev/guides/custom-modifiers#today-modifier
336
+ */
337
+ today?: Date;
338
+ /**
339
+ * Add modifiers to the matching days.
340
+ *
341
+ * @see https://daypicker.dev/guides/custom-modifiers
342
+ */
343
+ modifiers?: Record<string, Matcher | Matcher[] | undefined> | undefined;
344
+ /**
345
+ * Labels creators to override the defaults. Use this prop to customize the
346
+ * aria-label attributes in DayPicker.
347
+ *
348
+ * @see https://daypicker.dev/docs/translation#aria-labels
349
+ */
350
+ labels?: Partial<Labels>;
351
+ /**
352
+ * Formatters used to format dates to strings. Use this prop to override the
353
+ * default functions.
354
+ *
355
+ * @see https://daypicker.dev/docs/translation#custom-formatters
356
+ */
357
+ formatters?: Partial<Formatters>;
358
+ /**
359
+ * The text direction of the calendar. Use `ltr` for left-to-right (default)
360
+ * or `rtl` for right-to-left.
361
+ *
362
+ * @see https://daypicker.dev/docs/translation#rtl-text-direction
363
+ */
364
+ dir?: HTMLDivElement["dir"];
365
+ /**
366
+ * The aria-label attribute to add to the container element.
367
+ *
368
+ * @since 9.4.1
369
+ * @see https://daypicker.dev/guides/accessibility
370
+ */
371
+ ["aria-label"]?: string;
372
+ /**
373
+ * The role attribute to add to the container element.
374
+ *
375
+ * @since 9.4.1
376
+ * @see https://daypicker.dev/guides/accessibility
377
+ */
378
+ role?: "application" | "dialog" | undefined;
379
+ /**
380
+ * A cryptographic nonce ("number used once") which can be used by Content
381
+ * Security Policy for the inline `style` attributes.
382
+ */
383
+ nonce?: HTMLDivElement["nonce"];
384
+ /** Add a `title` attribute to the container element. */
385
+ title?: HTMLDivElement["title"];
386
+ /** Add the language tag to the container element. */
387
+ lang?: HTMLDivElement["lang"];
388
+ /**
389
+ * The locale object used to localize dates. Pass a locale from
390
+ * `react-day-picker/locale` to localize the calendar.
391
+ *
392
+ * @example
393
+ * import { es } from "react-day-picker/locale";
394
+ * <DayPicker locale={es} />
395
+ *
396
+ * @defaultValue enUS - The English locale default of `date-fns`.
397
+ * @see https://daypicker.dev/docs/localization
398
+ * @see https://github.com/date-fns/date-fns/tree/main/src/locale for a list of the supported locales
399
+ */
400
+ locale?: Partial<Locale> | undefined;
401
+ /**
402
+ * The numeral system to use when formatting dates.
403
+ *
404
+ * - `latn`: Latin (Western Arabic)
405
+ * - `arab`: Arabic-Indic
406
+ * - `arabext`: Eastern Arabic-Indic (Persian)
407
+ * - `deva`: Devanagari
408
+ * - `beng`: Bengali
409
+ * - `guru`: Gurmukhi
410
+ * - `gujr`: Gujarati
411
+ * - `orya`: Oriya
412
+ * - `tamldec`: Tamil
413
+ * - `telu`: Telugu
414
+ * - `knda`: Kannada
415
+ * - `mlym`: Malayalam
416
+ *
417
+ * @defaultValue `latn` Latin (Western Arabic)
418
+ * @see https://daypicker.dev/docs/translation#numeral-systems
419
+ */
420
+ numerals?: Numerals | undefined;
421
+ /**
422
+ * The index of the first day of the week (0 - Sunday). Overrides the locale's
423
+ * one.
424
+ *
425
+ * @see https://daypicker.dev/docs/localization#first-date-of-the-week
426
+ */
427
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
428
+ /**
429
+ * The day of January, which is always in the first week of the year.
430
+ *
431
+ * @see https://daypicker.dev/docs/localization#first-week-contains-date
432
+ */
433
+ firstWeekContainsDate?: 1 | 4;
434
+ /**
435
+ * Enable `DD` and `DDDD` for week year tokens when formatting or parsing
436
+ * dates.
437
+ *
438
+ * @see https://date-fns.org/docs/Unicode-Tokens
439
+ */
440
+ useAdditionalWeekYearTokens?: boolean | undefined;
441
+ /**
442
+ * Enable `YY` and `YYYY` for day of year tokens when formatting or parsing
443
+ * dates.
444
+ *
445
+ * @see https://date-fns.org/docs/Unicode-Tokens
446
+ */
447
+ useAdditionalDayOfYearTokens?: boolean | undefined;
448
+
449
+ /**
450
+ * Event fired when the user navigates between months.
451
+ *
452
+ * @see https://daypicker.dev/docs/navigation#onmonthchange
453
+ */
454
+ onMonthChange?: MonthChangeEventHandler;
455
+
456
+ /**
457
+ * Event handler when the next month button is clicked.
458
+ *
459
+ * @see https://daypicker.dev/docs/navigation
460
+ */
461
+ onNextClick?: MonthChangeEventHandler;
462
+ /**
463
+ * Event handler when the previous month button is clicked.
464
+ *
465
+ * @see https://daypicker.dev/docs/navigation
466
+ */
467
+ onPrevClick?: MonthChangeEventHandler;
468
+ /**
469
+ * Event handler when a week number is clicked.
470
+ *
471
+ * @private
472
+ * @deprecated Use a custom `WeekNumber` component instead.
473
+ * @see https://daypicker.dev/docs/customization#showweeknumber
474
+ */
475
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
476
+ onWeekNumberClick?: any;
477
+
478
+ /** Event handler when a day is clicked. */
479
+ onDayClick?: DayEventHandler<React.MouseEvent>;
480
+ /** Event handler when a day is focused. */
481
+ onDayFocus?: DayEventHandler<React.FocusEvent>;
482
+ /** Event handler when a day is blurred. */
483
+ onDayBlur?: DayEventHandler<React.FocusEvent>;
484
+ /** Event handler when a key is pressed on a day. */
485
+ onDayKeyDown?: DayEventHandler<React.KeyboardEvent>;
486
+ /** Event handler when the mouse enters a day. */
487
+ onDayMouseEnter?: DayEventHandler<React.MouseEvent>;
488
+ /** Event handler when the mouse leaves a day. */
489
+ onDayMouseLeave?: DayEventHandler<React.MouseEvent>;
490
+
491
+ /**
492
+ * Replace the default date library with a custom one. Experimental: not
493
+ * guaranteed to be stable (may not respect semver).
494
+ *
495
+ * @since 9.0.0
496
+ * @experimental
497
+ */
498
+ dateLib?: Partial<typeof DateLib.prototype> | undefined;
499
+
500
+ /**
501
+ * @private
502
+ * @deprecated Use a custom `DayButton` component instead.
503
+ */
504
+ onDayKeyUp?: DayEventHandler<React.KeyboardEvent>;
505
+ /**
506
+ * @private
507
+ * @deprecated Use a custom `DayButton` component instead.
508
+ */
509
+ onDayKeyPress?: DayEventHandler<React.KeyboardEvent>;
510
+ /**
511
+ * @private
512
+ * @deprecated Use a custom `DayButton` component instead.
513
+ */
514
+ onDayPointerEnter?: DayEventHandler<React.PointerEvent>;
515
+ /**
516
+ * @private
517
+ * @deprecated Use a custom `DayButton` component instead.
518
+ */
519
+ onDayPointerLeave?: DayEventHandler<React.PointerEvent>;
520
+ /**
521
+ * @private
522
+ * @deprecated Use a custom `DayButton` component instead.
523
+ */
524
+ onDayTouchCancel?: DayEventHandler<React.TouchEvent>;
525
+ /**
526
+ * @private
527
+ * @deprecated Use a custom `DayButton` component instead.
528
+ */
529
+ onDayTouchEnd?: DayEventHandler<React.TouchEvent>;
530
+ /**
531
+ * @private
532
+ * @deprecated Use a custom `DayButton` component instead.
533
+ */
534
+ onDayTouchMove?: DayEventHandler<React.TouchEvent>;
535
+ /**
536
+ * @private
537
+ * @deprecated Use a custom `DayButton` component instead.
538
+ */
539
+ onDayTouchStart?: DayEventHandler<React.TouchEvent>;
540
+ }
541
+
542
+ /**
543
+ * Shared handler type for `onSelect` callback when a selection mode is set.
544
+ *
545
+ * @template T - The type of the selected item.
546
+ * @callback OnSelectHandler
547
+ * @param {T} selected - The selected item after the event.
548
+ * @param {Date} triggerDate - The date when the event was triggered.
549
+ * @param {Modifiers} modifiers - The modifiers associated with the event.
550
+ * @param {React.MouseEvent | React.KeyboardEvent} e - The event object.
551
+ */
552
+ export type OnSelectHandler<T> = (
553
+ selected: T,
554
+ triggerDate: Date,
555
+ modifiers: Modifiers,
556
+ e: React.MouseEvent | React.KeyboardEvent
557
+ ) => void;
558
+
559
+ /**
560
+ * The props when the single selection is required.
561
+ *
562
+ * @group DayPicker
563
+ * @see https://daypicker.dev/docs/selection-modes#single-mode
564
+ */
565
+ export interface PropsSingleRequired {
566
+ mode: "single";
567
+ required: true;
568
+ /** The selected date. */
569
+ selected: Date | undefined;
570
+ /** Event handler when a day is selected. */
571
+ onSelect?: OnSelectHandler<Date>;
572
+ }
573
+
574
+ /**
575
+ * The props when the single selection is optional.
576
+ *
577
+ * @group DayPicker
578
+ * @see https://daypicker.dev/docs/selection-modes#single-mode
579
+ */
580
+ export interface PropsSingle {
581
+ mode: "single";
582
+ required?: false | undefined;
583
+ /** The selected date. */
584
+ selected?: Date | undefined;
585
+ /** Event handler when a day is selected. */
586
+ onSelect?: OnSelectHandler<Date | undefined>;
587
+ }
588
+
589
+ /**
590
+ * The props when the multiple selection is required.
591
+ *
592
+ * @group DayPicker
593
+ * @see https://daypicker.dev/docs/selection-modes#multiple-mode
594
+ */
595
+ export interface PropsMultiRequired {
596
+ mode: "multiple";
597
+ required: true;
598
+ /** The selected dates. */
599
+ selected: Date[] | undefined;
600
+ /** Event handler when days are selected. */
601
+ onSelect?: OnSelectHandler<Date[]>;
602
+ /** The minimum number of selectable days. */
603
+ min?: number;
604
+ /** The maximum number of selectable days. */
605
+ max?: number;
606
+ }
607
+
608
+ /**
609
+ * The props when the multiple selection is optional.
610
+ *
611
+ * @group DayPicker
612
+ * @see https://daypicker.dev/docs/selection-modes#multiple-mode
613
+ */
614
+ export interface PropsMulti {
615
+ mode: "multiple";
616
+ required?: false | undefined;
617
+ /** The selected dates. */
618
+ selected?: Date[] | undefined;
619
+ /** Event handler when days are selected. */
620
+ onSelect?: OnSelectHandler<Date[] | undefined>;
621
+ /** The minimum number of selectable days. */
622
+ min?: number;
623
+ /** The maximum number of selectable days. */
624
+ max?: number;
625
+ }
626
+ /**
627
+ * The props when the range selection is required.
628
+ *
629
+ * @group DayPicker
630
+ * @see https://daypicker.dev/docs/selection-modes#range-mode
631
+ */
632
+ export interface PropsRangeRequired {
633
+ mode: "range";
634
+ required: true;
635
+ disabled?: Matcher | Matcher[] | undefined;
636
+ /**
637
+ * When `true`, the range will reset when including a disabled day.
638
+ *
639
+ * @since V9.0.2
640
+ */
641
+ excludeDisabled?: boolean | undefined;
642
+ /** The selected range. */
643
+ selected: DateRange | undefined;
644
+ /** Event handler when a range is selected. */
645
+ onSelect?: OnSelectHandler<DateRange>;
646
+ /** The minimum number of days to include in the range. */
647
+ min?: number;
648
+ /** The maximum number of days to include in the range. */
649
+ max?: number;
650
+ }
651
+ /**
652
+ * The props when the range selection is optional.
653
+ *
654
+ * @group DayPicker
655
+ * @see https://daypicker.dev/docs/selection-modes#range-mode
656
+ */
657
+ export interface PropsRange {
658
+ mode: "range";
659
+ required?: false | undefined;
660
+ disabled?: Matcher | Matcher[] | undefined;
661
+ /**
662
+ * When `true`, the range will reset when including a disabled day.
663
+ *
664
+ * @since V9.0.2
665
+ */
666
+ excludeDisabled?: boolean | undefined;
667
+ /** The selected range. */
668
+ selected?: DateRange | undefined;
669
+ /** Event handler when the selection changes. */
670
+ onSelect?: OnSelectHandler<DateRange | undefined>;
671
+ /** The minimum number of days to include in the range. */
672
+ min?: number;
673
+ /** The maximum number of days to include in the range. */
674
+ max?: number;
675
+ }