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