react-day-picker 9.1.4 → 9.2.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 (293) hide show
  1. package/dist/cjs/DayPicker.js +33 -28
  2. package/dist/cjs/DayPicker.js.map +1 -1
  3. package/dist/cjs/classes/CalendarDay.d.ts +2 -4
  4. package/dist/cjs/classes/CalendarDay.js +2 -4
  5. package/dist/cjs/classes/CalendarDay.js.map +1 -1
  6. package/dist/cjs/classes/DateLib.d.ts +268 -0
  7. package/dist/cjs/classes/DateLib.js +360 -0
  8. package/dist/cjs/classes/DateLib.js.map +1 -0
  9. package/dist/cjs/classes/index.d.ts +1 -0
  10. package/dist/cjs/classes/index.js +1 -0
  11. package/dist/cjs/classes/index.js.map +1 -1
  12. package/dist/cjs/formatters/formatCaption.d.ts +2 -4
  13. package/dist/cjs/formatters/formatCaption.js +3 -5
  14. package/dist/cjs/formatters/formatCaption.js.map +1 -1
  15. package/dist/cjs/formatters/formatDay.d.ts +2 -4
  16. package/dist/cjs/formatters/formatDay.js +3 -5
  17. package/dist/cjs/formatters/formatDay.js.map +1 -1
  18. package/dist/cjs/formatters/formatMonthDropdown.d.ts +1 -1
  19. package/dist/cjs/formatters/formatMonthDropdown.js +2 -2
  20. package/dist/cjs/formatters/formatMonthDropdown.js.map +1 -1
  21. package/dist/cjs/formatters/formatWeekdayName.d.ts +2 -4
  22. package/dist/cjs/formatters/formatWeekdayName.js +3 -5
  23. package/dist/cjs/formatters/formatWeekdayName.js.map +1 -1
  24. package/dist/cjs/helpers/getDates.d.ts +3 -2
  25. package/dist/cjs/helpers/getDates.js +3 -9
  26. package/dist/cjs/helpers/getDates.js.map +1 -1
  27. package/dist/cjs/helpers/getDisplayMonths.d.ts +1 -1
  28. package/dist/cjs/helpers/getFocusableDate.d.ts +2 -2
  29. package/dist/cjs/helpers/getFocusableDate.js +3 -5
  30. package/dist/cjs/helpers/getFocusableDate.js.map +1 -1
  31. package/dist/cjs/helpers/getInitialMonth.d.ts +2 -1
  32. package/dist/cjs/helpers/getInitialMonth.js.map +1 -1
  33. package/dist/cjs/helpers/getMonthOptions.d.ts +2 -2
  34. package/dist/cjs/helpers/getMonthOptions.js +2 -2
  35. package/dist/cjs/helpers/getMonthOptions.js.map +1 -1
  36. package/dist/cjs/helpers/getMonths.d.ts +2 -2
  37. package/dist/cjs/helpers/getMonths.js +3 -15
  38. package/dist/cjs/helpers/getMonths.js.map +1 -1
  39. package/dist/cjs/helpers/getNavMonth.d.ts +2 -2
  40. package/dist/cjs/helpers/getNavMonth.js.map +1 -1
  41. package/dist/cjs/helpers/getNextFocus.d.ts +2 -2
  42. package/dist/cjs/helpers/getNextFocus.js.map +1 -1
  43. package/dist/cjs/helpers/getNextMonth.d.ts +1 -1
  44. package/dist/cjs/helpers/getPreviousMonth.d.ts +1 -1
  45. package/dist/cjs/helpers/getWeekdays.d.ts +5 -7
  46. package/dist/cjs/helpers/getWeekdays.js +5 -8
  47. package/dist/cjs/helpers/getWeekdays.js.map +1 -1
  48. package/dist/cjs/helpers/getYearOptions.d.ts +1 -1
  49. package/dist/cjs/index.d.ts +1 -2
  50. package/dist/cjs/index.js +3 -4
  51. package/dist/cjs/index.js.map +1 -1
  52. package/dist/cjs/labels/labelDayButton.d.ts +2 -4
  53. package/dist/cjs/labels/labelDayButton.js +3 -5
  54. package/dist/cjs/labels/labelDayButton.js.map +1 -1
  55. package/dist/cjs/labels/labelGrid.d.ts +2 -4
  56. package/dist/cjs/labels/labelGrid.js +3 -5
  57. package/dist/cjs/labels/labelGrid.js.map +1 -1
  58. package/dist/cjs/labels/labelGridcell.d.ts +2 -5
  59. package/dist/cjs/labels/labelGridcell.js +3 -5
  60. package/dist/cjs/labels/labelGridcell.js.map +1 -1
  61. package/dist/cjs/labels/labelMonthDropdown.d.ts +2 -2
  62. package/dist/cjs/labels/labelMonthDropdown.js.map +1 -1
  63. package/dist/cjs/labels/labelWeekNumber.d.ts +2 -2
  64. package/dist/cjs/labels/labelWeekNumber.js.map +1 -1
  65. package/dist/cjs/labels/labelWeekNumberHeader.d.ts +2 -2
  66. package/dist/cjs/labels/labelWeekNumberHeader.js.map +1 -1
  67. package/dist/cjs/labels/labelWeekday.d.ts +2 -4
  68. package/dist/cjs/labels/labelWeekday.js +3 -5
  69. package/dist/cjs/labels/labelWeekday.js.map +1 -1
  70. package/dist/cjs/labels/labelYearDropdown.d.ts +2 -2
  71. package/dist/cjs/labels/labelYearDropdown.js.map +1 -1
  72. package/dist/cjs/selection/useMulti.d.ts +1 -1
  73. package/dist/cjs/selection/useMulti.js.map +1 -1
  74. package/dist/cjs/selection/useRange.d.ts +1 -1
  75. package/dist/cjs/selection/useRange.js +2 -1
  76. package/dist/cjs/selection/useRange.js.map +1 -1
  77. package/dist/cjs/selection/useSingle.d.ts +1 -1
  78. package/dist/cjs/selection/useSingle.js.map +1 -1
  79. package/dist/cjs/types/props.d.ts +4 -4
  80. package/dist/cjs/useCalendar.d.ts +2 -3
  81. package/dist/cjs/useCalendar.js.map +1 -1
  82. package/dist/cjs/useFocus.d.ts +1 -2
  83. package/dist/cjs/useFocus.js.map +1 -1
  84. package/dist/cjs/useGetModifiers.d.ts +1 -2
  85. package/dist/cjs/useGetModifiers.js.map +1 -1
  86. package/dist/cjs/useSelection.d.ts +1 -1
  87. package/dist/cjs/utils/addToRange.d.ts +1 -1
  88. package/dist/cjs/utils/addToRange.js +2 -2
  89. package/dist/cjs/utils/addToRange.js.map +1 -1
  90. package/dist/cjs/utils/dateMatchModifiers.d.ts +1 -1
  91. package/dist/cjs/utils/dateMatchModifiers.js +2 -2
  92. package/dist/cjs/utils/dateMatchModifiers.js.map +1 -1
  93. package/dist/cjs/utils/rangeIncludesDate.d.ts +1 -4
  94. package/dist/cjs/utils/rangeIncludesDate.js +3 -5
  95. package/dist/cjs/utils/rangeIncludesDate.js.map +1 -1
  96. package/dist/cjs/utils/typeguards.d.ts +1 -1
  97. package/dist/esm/DayPicker.js +33 -28
  98. package/dist/esm/DayPicker.js.map +1 -1
  99. package/dist/esm/classes/CalendarDay.d.ts +2 -4
  100. package/dist/esm/classes/CalendarDay.js +2 -4
  101. package/dist/esm/classes/CalendarDay.js.map +1 -1
  102. package/dist/esm/classes/DateLib.d.ts +268 -0
  103. package/dist/esm/classes/DateLib.js +355 -0
  104. package/dist/esm/classes/DateLib.js.map +1 -0
  105. package/dist/esm/classes/index.d.ts +1 -0
  106. package/dist/esm/classes/index.js +1 -0
  107. package/dist/esm/classes/index.js.map +1 -1
  108. package/dist/esm/formatters/formatCaption.d.ts +2 -4
  109. package/dist/esm/formatters/formatCaption.js +3 -5
  110. package/dist/esm/formatters/formatCaption.js.map +1 -1
  111. package/dist/esm/formatters/formatDay.d.ts +2 -4
  112. package/dist/esm/formatters/formatDay.js +3 -5
  113. package/dist/esm/formatters/formatDay.js.map +1 -1
  114. package/dist/esm/formatters/formatMonthDropdown.d.ts +1 -1
  115. package/dist/esm/formatters/formatMonthDropdown.js +2 -2
  116. package/dist/esm/formatters/formatMonthDropdown.js.map +1 -1
  117. package/dist/esm/formatters/formatWeekdayName.d.ts +2 -4
  118. package/dist/esm/formatters/formatWeekdayName.js +3 -5
  119. package/dist/esm/formatters/formatWeekdayName.js.map +1 -1
  120. package/dist/esm/helpers/getDates.d.ts +3 -2
  121. package/dist/esm/helpers/getDates.js +3 -9
  122. package/dist/esm/helpers/getDates.js.map +1 -1
  123. package/dist/esm/helpers/getDisplayMonths.d.ts +1 -1
  124. package/dist/esm/helpers/getFocusableDate.d.ts +2 -2
  125. package/dist/esm/helpers/getFocusableDate.js +3 -5
  126. package/dist/esm/helpers/getFocusableDate.js.map +1 -1
  127. package/dist/esm/helpers/getInitialMonth.d.ts +2 -1
  128. package/dist/esm/helpers/getInitialMonth.js.map +1 -1
  129. package/dist/esm/helpers/getMonthOptions.d.ts +2 -2
  130. package/dist/esm/helpers/getMonthOptions.js +2 -2
  131. package/dist/esm/helpers/getMonthOptions.js.map +1 -1
  132. package/dist/esm/helpers/getMonths.d.ts +2 -2
  133. package/dist/esm/helpers/getMonths.js +3 -15
  134. package/dist/esm/helpers/getMonths.js.map +1 -1
  135. package/dist/esm/helpers/getNavMonth.d.ts +2 -2
  136. package/dist/esm/helpers/getNavMonth.js.map +1 -1
  137. package/dist/esm/helpers/getNextFocus.d.ts +2 -2
  138. package/dist/esm/helpers/getNextFocus.js.map +1 -1
  139. package/dist/esm/helpers/getNextMonth.d.ts +1 -1
  140. package/dist/esm/helpers/getPreviousMonth.d.ts +1 -1
  141. package/dist/esm/helpers/getWeekdays.d.ts +5 -7
  142. package/dist/esm/helpers/getWeekdays.js +5 -8
  143. package/dist/esm/helpers/getWeekdays.js.map +1 -1
  144. package/dist/esm/helpers/getYearOptions.d.ts +1 -1
  145. package/dist/esm/index.d.ts +1 -2
  146. package/dist/esm/index.js +1 -2
  147. package/dist/esm/index.js.map +1 -1
  148. package/dist/esm/labels/labelDayButton.d.ts +2 -4
  149. package/dist/esm/labels/labelDayButton.js +3 -5
  150. package/dist/esm/labels/labelDayButton.js.map +1 -1
  151. package/dist/esm/labels/labelGrid.d.ts +2 -4
  152. package/dist/esm/labels/labelGrid.js +3 -5
  153. package/dist/esm/labels/labelGrid.js.map +1 -1
  154. package/dist/esm/labels/labelGridcell.d.ts +2 -5
  155. package/dist/esm/labels/labelGridcell.js +3 -5
  156. package/dist/esm/labels/labelGridcell.js.map +1 -1
  157. package/dist/esm/labels/labelMonthDropdown.d.ts +2 -2
  158. package/dist/esm/labels/labelMonthDropdown.js.map +1 -1
  159. package/dist/esm/labels/labelWeekNumber.d.ts +2 -2
  160. package/dist/esm/labels/labelWeekNumber.js.map +1 -1
  161. package/dist/esm/labels/labelWeekNumberHeader.d.ts +2 -2
  162. package/dist/esm/labels/labelWeekNumberHeader.js.map +1 -1
  163. package/dist/esm/labels/labelWeekday.d.ts +2 -4
  164. package/dist/esm/labels/labelWeekday.js +3 -5
  165. package/dist/esm/labels/labelWeekday.js.map +1 -1
  166. package/dist/esm/labels/labelYearDropdown.d.ts +2 -2
  167. package/dist/esm/labels/labelYearDropdown.js.map +1 -1
  168. package/dist/esm/selection/useMulti.d.ts +1 -1
  169. package/dist/esm/selection/useMulti.js.map +1 -1
  170. package/dist/esm/selection/useRange.d.ts +1 -1
  171. package/dist/esm/selection/useRange.js +2 -1
  172. package/dist/esm/selection/useRange.js.map +1 -1
  173. package/dist/esm/selection/useSingle.d.ts +1 -1
  174. package/dist/esm/selection/useSingle.js.map +1 -1
  175. package/dist/esm/types/props.d.ts +4 -4
  176. package/dist/esm/useCalendar.d.ts +2 -3
  177. package/dist/esm/useCalendar.js.map +1 -1
  178. package/dist/esm/useFocus.d.ts +1 -2
  179. package/dist/esm/useFocus.js.map +1 -1
  180. package/dist/esm/useGetModifiers.d.ts +1 -2
  181. package/dist/esm/useGetModifiers.js.map +1 -1
  182. package/dist/esm/useSelection.d.ts +1 -1
  183. package/dist/esm/utils/addToRange.d.ts +1 -1
  184. package/dist/esm/utils/addToRange.js +1 -1
  185. package/dist/esm/utils/addToRange.js.map +1 -1
  186. package/dist/esm/utils/dateMatchModifiers.d.ts +1 -1
  187. package/dist/esm/utils/dateMatchModifiers.js +1 -1
  188. package/dist/esm/utils/dateMatchModifiers.js.map +1 -1
  189. package/dist/esm/utils/rangeIncludesDate.d.ts +1 -4
  190. package/dist/esm/utils/rangeIncludesDate.js +2 -4
  191. package/dist/esm/utils/rangeIncludesDate.js.map +1 -1
  192. package/dist/esm/utils/typeguards.d.ts +1 -1
  193. package/examples/Formatters.tsx +2 -2
  194. package/examples/NumberingSystem.tsx +5 -2
  195. package/examples/Range.test.tsx +8 -0
  196. package/examples/Range.tsx +13 -8
  197. package/examples/TestCase2511.test.tsx +14 -0
  198. package/examples/TestCase2511.tsx +19 -0
  199. package/examples/__snapshots__/Range.test.tsx.snap +1253 -1239
  200. package/examples/index.ts +1 -0
  201. package/package.json +78 -35
  202. package/src/DayPicker.tsx +44 -52
  203. package/src/classes/CalendarDay.ts +1 -3
  204. package/src/classes/DateLib.ts +478 -0
  205. package/src/classes/index.ts +1 -0
  206. package/src/formatters/formatCaption.test.ts +12 -4
  207. package/src/formatters/formatCaption.ts +4 -9
  208. package/src/formatters/formatDay.ts +4 -6
  209. package/src/formatters/formatMonthDropdown.ts +3 -3
  210. package/src/formatters/formatWeekdayName.ts +4 -6
  211. package/src/helpers/getDates.test.ts +29 -20
  212. package/src/helpers/getDates.ts +6 -14
  213. package/src/helpers/getDisplayMonths.test.ts +4 -4
  214. package/src/helpers/getDisplayMonths.ts +1 -1
  215. package/src/helpers/getFocusableDate.ts +5 -8
  216. package/src/helpers/getFormatters.test.ts +9 -5
  217. package/src/helpers/getInitialMonth.test.ts +7 -6
  218. package/src/helpers/getInitialMonth.ts +2 -1
  219. package/src/helpers/getMonthOptions.test.ts +3 -4
  220. package/src/helpers/getMonthOptions.ts +2 -3
  221. package/src/helpers/getMonths.test.ts +7 -10
  222. package/src/helpers/getMonths.ts +5 -26
  223. package/src/helpers/getNavMonth.test.ts +9 -9
  224. package/src/helpers/getNavMonth.ts +1 -2
  225. package/src/helpers/getNextFocus.test.tsx +11 -12
  226. package/src/helpers/getNextFocus.tsx +2 -8
  227. package/src/helpers/getNextMonth.test.ts +9 -8
  228. package/src/helpers/getNextMonth.ts +1 -1
  229. package/src/helpers/getPossibleFocusDate.test.ts +6 -5
  230. package/src/helpers/getPreviousMonth.test.ts +7 -7
  231. package/src/helpers/getPreviousMonth.ts +1 -1
  232. package/src/helpers/getWeekdays.test.ts +8 -4
  233. package/src/helpers/getWeekdays.ts +6 -10
  234. package/src/helpers/getYearOptions.test.ts +4 -4
  235. package/src/helpers/getYearOptions.ts +1 -1
  236. package/src/index.ts +1 -3
  237. package/src/labels/labelDayButton.ts +4 -6
  238. package/src/labels/labelGrid.ts +4 -6
  239. package/src/labels/labelGridcell.ts +4 -7
  240. package/src/labels/labelMonthDropdown.ts +2 -2
  241. package/src/labels/labelWeekNumber.ts +2 -2
  242. package/src/labels/labelWeekNumberHeader.ts +2 -2
  243. package/src/labels/labelWeekday.ts +4 -6
  244. package/src/labels/labelYearDropdown.ts +2 -2
  245. package/src/selection/useMulti.test.tsx +3 -3
  246. package/src/selection/useMulti.tsx +1 -1
  247. package/src/selection/useRange.test.tsx +8 -8
  248. package/src/selection/useRange.tsx +5 -2
  249. package/src/selection/useSingle.test.tsx +3 -3
  250. package/src/selection/useSingle.tsx +1 -1
  251. package/{style.css → src/style.css} +2 -2
  252. package/src/style.module.css.d.ts +29 -0
  253. package/src/types/props.ts +4 -4
  254. package/src/useCalendar.ts +2 -3
  255. package/src/useFocus.ts +1 -2
  256. package/src/useGetModifiers.tsx +1 -2
  257. package/src/useSelection.ts +1 -1
  258. package/src/utils/addToRange.ts +1 -1
  259. package/src/utils/dateMatchModifiers.test.ts +21 -13
  260. package/src/utils/dateMatchModifiers.ts +1 -1
  261. package/src/utils/rangeIncludesDate.ts +2 -3
  262. package/src/utils/typeguards.test.ts +5 -5
  263. package/src/utils/typeguards.ts +1 -1
  264. package/website/docs/upgrading.mdx +1 -1
  265. package/dist/cjs/helpers/getDateLib.d.ts +0 -3
  266. package/dist/cjs/helpers/getDateLib.js +0 -11
  267. package/dist/cjs/helpers/getDateLib.js.map +0 -1
  268. package/dist/cjs/lib/dateLib.d.ts +0 -138
  269. package/dist/cjs/lib/dateLib.js +0 -68
  270. package/dist/cjs/lib/dateLib.js.map +0 -1
  271. package/dist/cjs/lib/index.d.ts +0 -2
  272. package/dist/cjs/lib/index.js +0 -21
  273. package/dist/cjs/lib/index.js.map +0 -1
  274. package/dist/cjs/lib/locales.d.ts +0 -1
  275. package/dist/cjs/lib/locales.js +0 -6
  276. package/dist/cjs/lib/locales.js.map +0 -1
  277. package/dist/esm/helpers/getDateLib.d.ts +0 -3
  278. package/dist/esm/helpers/getDateLib.js +0 -8
  279. package/dist/esm/helpers/getDateLib.js.map +0 -1
  280. package/dist/esm/lib/dateLib.d.ts +0 -138
  281. package/dist/esm/lib/dateLib.js +0 -65
  282. package/dist/esm/lib/dateLib.js.map +0 -1
  283. package/dist/esm/lib/index.d.ts +0 -2
  284. package/dist/esm/lib/index.js +0 -3
  285. package/dist/esm/lib/index.js.map +0 -1
  286. package/dist/esm/lib/locales.d.ts +0 -1
  287. package/dist/esm/lib/locales.js +0 -2
  288. package/dist/esm/lib/locales.js.map +0 -1
  289. package/src/helpers/getDateLib.ts +0 -9
  290. package/src/lib/dateLib.ts +0 -175
  291. package/src/lib/index.ts +0 -2
  292. package/src/lib/locales.ts +0 -1
  293. /package/{style.module.css → src/style.module.css} +0 -0
@@ -0,0 +1,268 @@
1
+ import { EndOfWeekOptions, FormatOptions as DateFnsFormatOptions, StartOfWeekOptions, addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, getWeek, isAfter, isBefore, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear } from "date-fns";
2
+ import type { Locale } from "date-fns/locale";
3
+ export type { Locale } from "date-fns/locale";
4
+ export type { Month as DateFnsMonth } from "date-fns";
5
+ /** @deprecated Use {@link DateLibOptions} instead. */
6
+ export type FormatOptions = DateLibOptions;
7
+ /** @deprecated Use {@link DateLibOptions} instead. */
8
+ export type LabelOptions = DateLibOptions;
9
+ /**
10
+ * The options for the `DateLib` class.
11
+ *
12
+ * Extends `date-fns` [format](https://date-fns.org/docs/format),
13
+ * [startOfWeek](https://date-fns.org/docs/startOfWeek) and
14
+ * [endOfWeek](https://date-fns.org/docs/endOfWeek) options.
15
+ *
16
+ * @since 9.2.0
17
+ */
18
+ export interface DateLibOptions extends DateFnsFormatOptions, StartOfWeekOptions, EndOfWeekOptions {
19
+ /** A constructor for the `Date` object. */
20
+ Date?: typeof Date;
21
+ /** A locale to use for formatting dates. */
22
+ locale?: Locale;
23
+ }
24
+ /**
25
+ * A wrapper class around [date-fns](http://date-fns.org) sharing the same
26
+ * options. Methods of this class can be overridden using the
27
+ * {@link PropsBase.dateLib} prop.
28
+ *
29
+ * @since 9.2.0
30
+ * @example
31
+ * const dateLib = new DateLib({ locale: es });
32
+ * const newDate = dateLib.addDays(new Date(), 5);
33
+ */
34
+ export declare class DateLib {
35
+ /** The options for the date library. */
36
+ readonly options: DateLibOptions;
37
+ /** Overrides for the date library functions. */
38
+ readonly overrides?: Partial<typeof DateLib.prototype>;
39
+ /**
40
+ * Creates an instance of DateLib.
41
+ *
42
+ * @param options The options for the date library.
43
+ * @param overrides Overrides for the date library functions.
44
+ */
45
+ constructor(options?: DateLibOptions, overrides?: Partial<typeof DateLib.prototype>);
46
+ /** Reference to the built-in Date constructor. */
47
+ Date: typeof Date;
48
+ /**
49
+ * Adds the specified number of days to the given date.
50
+ *
51
+ * @param date The date to add days to.
52
+ * @param amount The number of days to add.
53
+ * @returns The new date with the days added.
54
+ */
55
+ addDays: typeof addDays;
56
+ /**
57
+ * Adds the specified number of months to the given date.
58
+ *
59
+ * @param date The date to add months to.
60
+ * @param amount The number of months to add.
61
+ * @returns The new date with the months added.
62
+ */
63
+ addMonths: typeof addMonths;
64
+ /**
65
+ * Adds the specified number of weeks to the given date.
66
+ *
67
+ * @param date The date to add weeks to.
68
+ * @param amount The number of weeks to add.
69
+ * @returns The new date with the weeks added.
70
+ */
71
+ addWeeks: typeof addWeeks;
72
+ /**
73
+ * Adds the specified number of years to the given date.
74
+ *
75
+ * @param date The date to add years to.
76
+ * @param amount The number of years to add.
77
+ * @returns The new date with the years added.
78
+ */
79
+ addYears: typeof addYears;
80
+ /**
81
+ * Returns the number of calendar days between the given dates.
82
+ *
83
+ * @param dateLeft The later date.
84
+ * @param dateRight The earlier date.
85
+ * @returns The number of calendar days between the dates.
86
+ */
87
+ differenceInCalendarDays: typeof differenceInCalendarDays;
88
+ /**
89
+ * Returns the number of calendar months between the given dates.
90
+ *
91
+ * @param dateLeft The later date.
92
+ * @param dateRight The earlier date.
93
+ * @returns The number of calendar months between the dates.
94
+ */
95
+ differenceInCalendarMonths: typeof differenceInCalendarMonths;
96
+ /**
97
+ * Returns the end of the ISO week for the given date.
98
+ *
99
+ * @param date The original date.
100
+ * @returns The end of the ISO week.
101
+ */
102
+ endOfISOWeek: typeof endOfISOWeek;
103
+ /**
104
+ * Returns the end of the month for the given date.
105
+ *
106
+ * @param date The original date.
107
+ * @returns The end of the month.
108
+ */
109
+ endOfMonth: typeof endOfMonth;
110
+ /**
111
+ * Returns the end of the week for the given date.
112
+ *
113
+ * @param date The original date.
114
+ * @returns The end of the week.
115
+ */
116
+ endOfWeek: typeof endOfWeek;
117
+ /**
118
+ * Returns the end of the year for the given date.
119
+ *
120
+ * @param date The original date.
121
+ * @returns The end of the year.
122
+ */
123
+ endOfYear: typeof endOfYear;
124
+ /**
125
+ * Formats the given date using the specified format string.
126
+ *
127
+ * @param date The date to format.
128
+ * @param formatStr The format string.
129
+ * @returns The formatted date string.
130
+ */
131
+ format: typeof format;
132
+ /**
133
+ * Returns the ISO week number for the given date.
134
+ *
135
+ * @param date The date to get the ISO week number for.
136
+ * @returns The ISO week number.
137
+ */
138
+ getISOWeek: typeof getISOWeek;
139
+ /**
140
+ * Returns the local week number for the given date.
141
+ *
142
+ * @param date The date to get the week number for.
143
+ * @returns The week number.
144
+ */
145
+ getWeek: typeof getWeek;
146
+ /**
147
+ * Checks if the first date is after the second date.
148
+ *
149
+ * @param date The date to compare.
150
+ * @param dateToCompare The date to compare with.
151
+ * @returns True if the first date is after the second date.
152
+ */
153
+ isAfter: typeof isAfter;
154
+ /**
155
+ * Checks if the first date is before the second date.
156
+ *
157
+ * @param date The date to compare.
158
+ * @param dateToCompare The date to compare with.
159
+ * @returns True if the first date is before the second date.
160
+ */
161
+ isBefore: typeof isBefore;
162
+ /**
163
+ * Checks if the given value is a Date object.
164
+ *
165
+ * @param value The value to check.
166
+ * @returns True if the value is a Date object.
167
+ */
168
+ isDate: (value: unknown) => value is Date;
169
+ /**
170
+ * Checks if the given dates are on the same day.
171
+ *
172
+ * @param dateLeft The first date to compare.
173
+ * @param dateRight The second date to compare.
174
+ * @returns True if the dates are on the same day.
175
+ */
176
+ isSameDay: typeof isSameDay;
177
+ /**
178
+ * Checks if the given dates are in the same month.
179
+ *
180
+ * @param dateLeft The first date to compare.
181
+ * @param dateRight The second date to compare.
182
+ * @returns True if the dates are in the same month.
183
+ */
184
+ isSameMonth: typeof isSameMonth;
185
+ /**
186
+ * Checks if the given dates are in the same year.
187
+ *
188
+ * @param dateLeft The first date to compare.
189
+ * @param dateRight The second date to compare.
190
+ * @returns True if the dates are in the same year.
191
+ */
192
+ isSameYear: typeof isSameYear;
193
+ /**
194
+ * Returns the latest date in the given array of dates.
195
+ *
196
+ * @param dates The array of dates to compare.
197
+ * @returns The latest date.
198
+ */
199
+ max: typeof max;
200
+ /**
201
+ * Returns the earliest date in the given array of dates.
202
+ *
203
+ * @param dates The array of dates to compare.
204
+ * @returns The earliest date.
205
+ */
206
+ min: typeof min;
207
+ /**
208
+ * Sets the month of the given date.
209
+ *
210
+ * @param date The date to set the month on.
211
+ * @param month The month to set (0-11).
212
+ * @returns The new date with the month set.
213
+ */
214
+ setMonth: typeof setMonth;
215
+ /**
216
+ * Sets the year of the given date.
217
+ *
218
+ * @param date The date to set the year on.
219
+ * @param year The year to set.
220
+ * @returns The new date with the year set.
221
+ */
222
+ setYear: typeof setYear;
223
+ /**
224
+ * Returns the start of the day for the given date.
225
+ *
226
+ * @param date The original date.
227
+ * @returns The start of the day.
228
+ */
229
+ startOfDay: typeof startOfDay;
230
+ /**
231
+ * Returns the start of the ISO week for the given date.
232
+ *
233
+ * @param date The original date.
234
+ * @returns The start of the ISO week.
235
+ */
236
+ startOfISOWeek: typeof startOfISOWeek;
237
+ /**
238
+ * Returns the start of the month for the given date.
239
+ *
240
+ * @param date The original date.
241
+ * @returns The start of the month.
242
+ */
243
+ startOfMonth: typeof startOfMonth;
244
+ /**
245
+ * Returns the start of the week for the given date.
246
+ *
247
+ * @param date The original date.
248
+ * @returns The start of the week.
249
+ */
250
+ startOfWeek: typeof startOfWeek;
251
+ /**
252
+ * Returns the start of the year for the given date.
253
+ *
254
+ * @param date The original date.
255
+ * @returns The start of the year.
256
+ */
257
+ startOfYear: typeof startOfYear;
258
+ }
259
+ /** The default locale (English). */
260
+ export { enUS as defaultLocale } from "date-fns/locale/en-US";
261
+ /**
262
+ * The default date library with English locale.
263
+ *
264
+ * @since 9.2.0
265
+ */
266
+ export declare const defaultDateLib: DateLib;
267
+ /** @deprecated Use `defaultDateLib`. */
268
+ export declare const dateLib: DateLib;
@@ -0,0 +1,355 @@
1
+ import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, getWeek, isAfter, isBefore, isDate, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear } from "date-fns";
2
+ import { enUS } from "date-fns/locale";
3
+ /**
4
+ * A wrapper class around [date-fns](http://date-fns.org) sharing the same
5
+ * options. Methods of this class can be overridden using the
6
+ * {@link PropsBase.dateLib} prop.
7
+ *
8
+ * @since 9.2.0
9
+ * @example
10
+ * const dateLib = new DateLib({ locale: es });
11
+ * const newDate = dateLib.addDays(new Date(), 5);
12
+ */
13
+ export class DateLib {
14
+ /**
15
+ * Creates an instance of DateLib.
16
+ *
17
+ * @param options The options for the date library.
18
+ * @param overrides Overrides for the date library functions.
19
+ */
20
+ constructor(options, overrides) {
21
+ /** Reference to the built-in Date constructor. */
22
+ this.Date = Date;
23
+ /**
24
+ * Adds the specified number of days to the given date.
25
+ *
26
+ * @param date The date to add days to.
27
+ * @param amount The number of days to add.
28
+ * @returns The new date with the days added.
29
+ */
30
+ this.addDays = (date, amount) => {
31
+ return this.overrides?.addDays
32
+ ? this.overrides.addDays(date, amount)
33
+ : addDays(date, amount);
34
+ };
35
+ /**
36
+ * Adds the specified number of months to the given date.
37
+ *
38
+ * @param date The date to add months to.
39
+ * @param amount The number of months to add.
40
+ * @returns The new date with the months added.
41
+ */
42
+ this.addMonths = (date, amount) => {
43
+ return this.overrides?.addMonths
44
+ ? this.overrides.addMonths(date, amount)
45
+ : addMonths(date, amount);
46
+ };
47
+ /**
48
+ * Adds the specified number of weeks to the given date.
49
+ *
50
+ * @param date The date to add weeks to.
51
+ * @param amount The number of weeks to add.
52
+ * @returns The new date with the weeks added.
53
+ */
54
+ this.addWeeks = (date, amount) => {
55
+ return this.overrides?.addWeeks
56
+ ? this.overrides.addWeeks(date, amount)
57
+ : addWeeks(date, amount);
58
+ };
59
+ /**
60
+ * Adds the specified number of years to the given date.
61
+ *
62
+ * @param date The date to add years to.
63
+ * @param amount The number of years to add.
64
+ * @returns The new date with the years added.
65
+ */
66
+ this.addYears = (date, amount) => {
67
+ return this.overrides?.addYears
68
+ ? this.overrides.addYears(date, amount)
69
+ : addYears(date, amount);
70
+ };
71
+ /**
72
+ * Returns the number of calendar days between the given dates.
73
+ *
74
+ * @param dateLeft The later date.
75
+ * @param dateRight The earlier date.
76
+ * @returns The number of calendar days between the dates.
77
+ */
78
+ this.differenceInCalendarDays = (dateLeft, dateRight) => {
79
+ return this.overrides?.differenceInCalendarDays
80
+ ? this.overrides.differenceInCalendarDays(dateLeft, dateRight)
81
+ : differenceInCalendarDays(dateLeft, dateRight);
82
+ };
83
+ /**
84
+ * Returns the number of calendar months between the given dates.
85
+ *
86
+ * @param dateLeft The later date.
87
+ * @param dateRight The earlier date.
88
+ * @returns The number of calendar months between the dates.
89
+ */
90
+ this.differenceInCalendarMonths = (dateLeft, dateRight) => {
91
+ return this.overrides?.differenceInCalendarMonths
92
+ ? this.overrides.differenceInCalendarMonths(dateLeft, dateRight)
93
+ : differenceInCalendarMonths(dateLeft, dateRight);
94
+ };
95
+ /**
96
+ * Returns the end of the ISO week for the given date.
97
+ *
98
+ * @param date The original date.
99
+ * @returns The end of the ISO week.
100
+ */
101
+ this.endOfISOWeek = (date) => {
102
+ return this.overrides?.endOfISOWeek
103
+ ? this.overrides.endOfISOWeek(date)
104
+ : endOfISOWeek(date);
105
+ };
106
+ /**
107
+ * Returns the end of the month for the given date.
108
+ *
109
+ * @param date The original date.
110
+ * @returns The end of the month.
111
+ */
112
+ this.endOfMonth = (date) => {
113
+ return this.overrides?.endOfMonth
114
+ ? this.overrides.endOfMonth(date)
115
+ : endOfMonth(date);
116
+ };
117
+ /**
118
+ * Returns the end of the week for the given date.
119
+ *
120
+ * @param date The original date.
121
+ * @returns The end of the week.
122
+ */
123
+ this.endOfWeek = (date) => {
124
+ return this.overrides?.endOfWeek
125
+ ? this.overrides.endOfWeek(date, this.options)
126
+ : endOfWeek(date, this.options);
127
+ };
128
+ /**
129
+ * Returns the end of the year for the given date.
130
+ *
131
+ * @param date The original date.
132
+ * @returns The end of the year.
133
+ */
134
+ this.endOfYear = (date) => {
135
+ return this.overrides?.endOfYear
136
+ ? this.overrides.endOfYear(date)
137
+ : endOfYear(date);
138
+ };
139
+ /**
140
+ * Formats the given date using the specified format string.
141
+ *
142
+ * @param date The date to format.
143
+ * @param formatStr The format string.
144
+ * @returns The formatted date string.
145
+ */
146
+ this.format = (date, formatStr) => {
147
+ return this.overrides?.format
148
+ ? this.overrides.format(date, formatStr, this.options)
149
+ : format(date, formatStr, this.options);
150
+ };
151
+ /**
152
+ * Returns the ISO week number for the given date.
153
+ *
154
+ * @param date The date to get the ISO week number for.
155
+ * @returns The ISO week number.
156
+ */
157
+ this.getISOWeek = (date) => {
158
+ return this.overrides?.getISOWeek
159
+ ? this.overrides.getISOWeek(date)
160
+ : getISOWeek(date);
161
+ };
162
+ /**
163
+ * Returns the local week number for the given date.
164
+ *
165
+ * @param date The date to get the week number for.
166
+ * @returns The week number.
167
+ */
168
+ this.getWeek = (date) => {
169
+ return this.overrides?.getWeek
170
+ ? this.overrides.getWeek(date, this.options)
171
+ : getWeek(date, this.options);
172
+ };
173
+ /**
174
+ * Checks if the first date is after the second date.
175
+ *
176
+ * @param date The date to compare.
177
+ * @param dateToCompare The date to compare with.
178
+ * @returns True if the first date is after the second date.
179
+ */
180
+ this.isAfter = (date, dateToCompare) => {
181
+ return this.overrides?.isAfter
182
+ ? this.overrides.isAfter(date, dateToCompare)
183
+ : isAfter(date, dateToCompare);
184
+ };
185
+ /**
186
+ * Checks if the first date is before the second date.
187
+ *
188
+ * @param date The date to compare.
189
+ * @param dateToCompare The date to compare with.
190
+ * @returns True if the first date is before the second date.
191
+ */
192
+ this.isBefore = (date, dateToCompare) => {
193
+ return this.overrides?.isBefore
194
+ ? this.overrides.isBefore(date, dateToCompare)
195
+ : isBefore(date, dateToCompare);
196
+ };
197
+ /**
198
+ * Checks if the given value is a Date object.
199
+ *
200
+ * @param value The value to check.
201
+ * @returns True if the value is a Date object.
202
+ */
203
+ this.isDate = (value) => {
204
+ return this.overrides?.isDate
205
+ ? this.overrides.isDate(value)
206
+ : isDate(value);
207
+ };
208
+ /**
209
+ * Checks if the given dates are on the same day.
210
+ *
211
+ * @param dateLeft The first date to compare.
212
+ * @param dateRight The second date to compare.
213
+ * @returns True if the dates are on the same day.
214
+ */
215
+ this.isSameDay = (dateLeft, dateRight) => {
216
+ return this.overrides?.isSameDay
217
+ ? this.overrides.isSameDay(dateLeft, dateRight)
218
+ : isSameDay(dateLeft, dateRight);
219
+ };
220
+ /**
221
+ * Checks if the given dates are in the same month.
222
+ *
223
+ * @param dateLeft The first date to compare.
224
+ * @param dateRight The second date to compare.
225
+ * @returns True if the dates are in the same month.
226
+ */
227
+ this.isSameMonth = (dateLeft, dateRight) => {
228
+ return this.overrides?.isSameMonth
229
+ ? this.overrides.isSameMonth(dateLeft, dateRight)
230
+ : isSameMonth(dateLeft, dateRight);
231
+ };
232
+ /**
233
+ * Checks if the given dates are in the same year.
234
+ *
235
+ * @param dateLeft The first date to compare.
236
+ * @param dateRight The second date to compare.
237
+ * @returns True if the dates are in the same year.
238
+ */
239
+ this.isSameYear = (dateLeft, dateRight) => {
240
+ return this.overrides?.isSameYear
241
+ ? this.overrides.isSameYear(dateLeft, dateRight)
242
+ : isSameYear(dateLeft, dateRight);
243
+ };
244
+ /**
245
+ * Returns the latest date in the given array of dates.
246
+ *
247
+ * @param dates The array of dates to compare.
248
+ * @returns The latest date.
249
+ */
250
+ this.max = (dates) => {
251
+ return this.overrides?.max ? this.overrides.max(dates) : max(dates);
252
+ };
253
+ /**
254
+ * Returns the earliest date in the given array of dates.
255
+ *
256
+ * @param dates The array of dates to compare.
257
+ * @returns The earliest date.
258
+ */
259
+ this.min = (dates) => {
260
+ return this.overrides?.min ? this.overrides.min(dates) : min(dates);
261
+ };
262
+ /**
263
+ * Sets the month of the given date.
264
+ *
265
+ * @param date The date to set the month on.
266
+ * @param month The month to set (0-11).
267
+ * @returns The new date with the month set.
268
+ */
269
+ this.setMonth = (date, month) => {
270
+ return this.overrides?.setMonth
271
+ ? this.overrides.setMonth(date, month)
272
+ : setMonth(date, month);
273
+ };
274
+ /**
275
+ * Sets the year of the given date.
276
+ *
277
+ * @param date The date to set the year on.
278
+ * @param year The year to set.
279
+ * @returns The new date with the year set.
280
+ */
281
+ this.setYear = (date, year) => {
282
+ return this.overrides?.setYear
283
+ ? this.overrides.setYear(date, year)
284
+ : setYear(date, year);
285
+ };
286
+ /**
287
+ * Returns the start of the day for the given date.
288
+ *
289
+ * @param date The original date.
290
+ * @returns The start of the day.
291
+ */
292
+ this.startOfDay = (date) => {
293
+ return this.overrides?.startOfDay
294
+ ? this.overrides.startOfDay(date)
295
+ : startOfDay(date);
296
+ };
297
+ /**
298
+ * Returns the start of the ISO week for the given date.
299
+ *
300
+ * @param date The original date.
301
+ * @returns The start of the ISO week.
302
+ */
303
+ this.startOfISOWeek = (date) => {
304
+ return this.overrides?.startOfISOWeek
305
+ ? this.overrides.startOfISOWeek(date)
306
+ : startOfISOWeek(date);
307
+ };
308
+ /**
309
+ * Returns the start of the month for the given date.
310
+ *
311
+ * @param date The original date.
312
+ * @returns The start of the month.
313
+ */
314
+ this.startOfMonth = (date) => {
315
+ return this.overrides?.startOfMonth
316
+ ? this.overrides.startOfMonth(date)
317
+ : startOfMonth(date);
318
+ };
319
+ /**
320
+ * Returns the start of the week for the given date.
321
+ *
322
+ * @param date The original date.
323
+ * @returns The start of the week.
324
+ */
325
+ this.startOfWeek = (date) => {
326
+ return this.overrides?.startOfWeek
327
+ ? this.overrides.startOfWeek(date, this.options)
328
+ : startOfWeek(date, this.options);
329
+ };
330
+ /**
331
+ * Returns the start of the year for the given date.
332
+ *
333
+ * @param date The original date.
334
+ * @returns The start of the year.
335
+ */
336
+ this.startOfYear = (date) => {
337
+ return this.overrides?.startOfYear
338
+ ? this.overrides.startOfYear(date)
339
+ : startOfYear(date);
340
+ };
341
+ this.options = { locale: enUS, ...options };
342
+ this.overrides = overrides;
343
+ }
344
+ }
345
+ /** The default locale (English). */
346
+ export { enUS as defaultLocale } from "date-fns/locale/en-US";
347
+ /**
348
+ * The default date library with English locale.
349
+ *
350
+ * @since 9.2.0
351
+ */
352
+ export const defaultDateLib = new DateLib();
353
+ /** @deprecated Use `defaultDateLib`. */
354
+ export const dateLib = defaultDateLib;
355
+ //# sourceMappingURL=DateLib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateLib.js","sourceRoot":"","sources":["../../../src/classes/DateLib.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,wBAAwB,EACxB,0BAA0B,EAC1B,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,MAAM,EACN,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,UAAU,EACV,GAAG,EACH,GAAG,EACH,QAAQ,EACR,OAAO,EACP,UAAU,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AA6BvC;;;;;;;;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I,CAAC,SAAS,EAAE,WAAW;gBAChC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;gBAClC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QArXA,IAAI,CAAC,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAoXF;AACD,oCAAoC;AACpC,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE,CAAC;AAE5C,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./CalendarDay.js";
2
2
  export * from "./CalendarMonth.js";
3
3
  export * from "./CalendarWeek.js";
4
+ export * from "./DateLib.js";
@@ -1,4 +1,5 @@
1
1
  export * from "./CalendarDay.js";
2
2
  export * from "./CalendarMonth.js";
3
3
  export * from "./CalendarWeek.js";
4
+ export * from "./DateLib.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormatOptions, type DateLib } from "../lib/index.js";
1
+ import { DateLib, type DateLibOptions } from "../classes/DateLib.js";
2
2
  /**
3
3
  * Format the caption of the month.
4
4
  *
@@ -6,9 +6,7 @@ import { FormatOptions, type DateLib } from "../lib/index.js";
6
6
  * @group Formatters
7
7
  * @see https://daypicker.dev/docs/translation#custom-formatters
8
8
  */
9
- export declare function formatCaption(month: Date, options?: FormatOptions,
10
- /** @ignore */
11
- dateLib?: DateLib): string;
9
+ export declare function formatCaption(month: Date, options?: DateLibOptions, dateLib?: DateLib): string;
12
10
  /**
13
11
  * @private
14
12
  * @deprecated Use {@link formatCaption} instead.
@@ -1,4 +1,4 @@
1
- import { dateLib as defaultDateLib } from "../lib/index.js";
1
+ import { DateLib } from "../classes/DateLib.js";
2
2
  /**
3
3
  * Format the caption of the month.
4
4
  *
@@ -6,10 +6,8 @@ import { dateLib as defaultDateLib } from "../lib/index.js";
6
6
  * @group Formatters
7
7
  * @see https://daypicker.dev/docs/translation#custom-formatters
8
8
  */
9
- export function formatCaption(month, options,
10
- /** @ignore */
11
- dateLib = defaultDateLib) {
12
- return dateLib.format(month, "LLLL y", options);
9
+ export function formatCaption(month, options, dateLib) {
10
+ return (dateLib ?? new DateLib(options)).format(month, "LLLL y");
13
11
  }
14
12
  /**
15
13
  * @private