react-day-picker 8.0.0-beta.36 → 8.0.0-beta.39

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 (634) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/{build → dist}/DayPicker.d.ts +0 -1
  3. package/dist/components/Button/Button.d.ts +7 -0
  4. package/{build → dist}/components/Button/index.d.ts +0 -0
  5. package/{build → dist}/components/Caption/Caption.d.ts +0 -1
  6. package/{build → dist}/components/Caption/index.d.ts +0 -0
  7. package/{build → dist}/components/CaptionLabel/CaptionLabel.d.ts +0 -1
  8. package/{build → dist}/components/CaptionLabel/index.d.ts +0 -0
  9. package/{build → dist}/components/Day/Day.d.ts +0 -1
  10. package/dist/components/Day/index.d.ts +1 -0
  11. package/{build → dist}/components/DayContent/DayContent.d.ts +3 -4
  12. package/{build → dist}/components/DayContent/index.d.ts +0 -0
  13. package/{build → dist}/components/Dropdown/Dropdown.d.ts +1 -1
  14. package/{build → dist}/components/Dropdown/index.d.ts +0 -0
  15. package/{build → dist}/components/Footer/Footer.d.ts +0 -1
  16. package/{build → dist}/components/Footer/index.d.ts +0 -0
  17. package/{build → dist}/components/Head/Head.d.ts +0 -1
  18. package/{build → dist}/components/Head/index.d.ts +0 -0
  19. package/{build → dist}/components/Head/utils/getWeekdays.d.ts +0 -0
  20. package/{build → dist}/components/Head/utils/index.d.ts +0 -0
  21. package/{build → dist}/components/IconDropdown/IconDropdown.d.ts +0 -1
  22. package/{build → dist}/components/IconDropdown/index.d.ts +0 -0
  23. package/{build → dist}/components/IconLeft/IconLeft.d.ts +0 -1
  24. package/{build → dist}/components/IconLeft/index.d.ts +0 -0
  25. package/{build → dist}/components/IconRight/IconRight.d.ts +0 -1
  26. package/{build → dist}/components/IconRight/index.d.ts +0 -0
  27. package/{build → dist}/components/Month/Month.d.ts +0 -1
  28. package/{build → dist}/components/Month/index.d.ts +0 -0
  29. package/{build → dist}/components/MonthsDropdown/MonthsDropdown.d.ts +1 -4
  30. package/{build → dist}/components/MonthsDropdown/index.d.ts +0 -0
  31. package/{build → dist}/components/Navigation/Navigation.d.ts +0 -0
  32. package/{build → dist}/components/Navigation/index.d.ts +0 -0
  33. package/dist/components/Root/Root.d.ts +2 -0
  34. package/{build → dist}/components/Root/index.d.ts +0 -0
  35. package/{build → dist}/components/Row/Row.d.ts +1 -4
  36. package/{build → dist}/components/Row/index.d.ts +0 -0
  37. package/{build → dist}/components/Table/Table.d.ts +2 -7
  38. package/{build → dist}/components/Table/index.d.ts +0 -0
  39. package/dist/components/Table/utils/daysToMonthWeeks.d.ts +8 -0
  40. package/dist/components/Table/utils/getMonthWeeks.d.ts +21 -0
  41. package/{build → dist}/components/WeekNumber/WeekNumber.d.ts +0 -1
  42. package/{build → dist}/components/WeekNumber/index.d.ts +0 -0
  43. package/{build → dist}/components/YearsDropdown/YearsDropdown.d.ts +0 -1
  44. package/{build → dist}/components/YearsDropdown/index.d.ts +0 -0
  45. package/{build → dist}/contexts/DayPicker/DayPickerContext.d.ts +9 -12
  46. package/{build → dist}/contexts/DayPicker/defaultClassNames.d.ts +0 -0
  47. package/dist/contexts/DayPicker/defaultContextValue.d.ts +6 -0
  48. package/{build → dist}/contexts/DayPicker/formatters/formatCaption.d.ts +0 -0
  49. package/{build → dist}/contexts/DayPicker/formatters/formatDay.d.ts +0 -0
  50. package/{build → dist}/contexts/DayPicker/formatters/formatMonthCaption.d.ts +0 -0
  51. package/{build → dist}/contexts/DayPicker/formatters/formatWeekNumber.d.ts +0 -0
  52. package/{build → dist}/contexts/DayPicker/formatters/formatWeekdayName.d.ts +0 -0
  53. package/{build → dist}/contexts/DayPicker/formatters/formatYearCaption.d.ts +0 -0
  54. package/{build → dist}/contexts/DayPicker/formatters/index.d.ts +0 -0
  55. package/{build → dist}/contexts/DayPicker/index.d.ts +0 -0
  56. package/{build → dist}/contexts/DayPicker/labels/index.d.ts +0 -0
  57. package/{build → dist}/contexts/DayPicker/labels/labelDay.d.ts +0 -0
  58. package/{build → dist}/contexts/DayPicker/labels/labelMonthDropdown.d.ts +0 -0
  59. package/{build → dist}/contexts/DayPicker/labels/labelNext.d.ts +0 -0
  60. package/{build → dist}/contexts/DayPicker/labels/labelPrevious.d.ts +0 -0
  61. package/{build → dist}/contexts/DayPicker/labels/labelWeekNumber.d.ts +0 -0
  62. package/{build → dist}/contexts/DayPicker/labels/labelWeekday.d.ts +0 -0
  63. package/{build → dist}/contexts/DayPicker/labels/labelYearDropdown.d.ts +0 -0
  64. package/{build → dist}/contexts/DayPicker/useDayPicker.d.ts +1 -1
  65. package/{build → dist}/contexts/DayPicker/utils/index.d.ts +0 -0
  66. package/{build → dist}/contexts/DayPicker/utils/parseFromToProps.d.ts +1 -4
  67. package/{build → dist}/contexts/Focus/FocusContext.d.ts +10 -10
  68. package/dist/contexts/Focus/index.d.ts +2 -0
  69. package/{build/contexts/Focus/useFocus.d.ts → dist/contexts/Focus/useFocusContext.d.ts} +1 -1
  70. package/dist/contexts/Focus/utils/getInitialFocusTarget.d.ts +3 -0
  71. package/{build → dist}/contexts/Modifiers/ModifiersContext.d.ts +2 -2
  72. package/dist/contexts/Modifiers/index.d.ts +2 -0
  73. package/dist/contexts/Modifiers/useModifiers.d.ts +6 -0
  74. package/dist/contexts/Modifiers/utils/getActiveModifiers.d.ts +7 -0
  75. package/dist/contexts/Modifiers/utils/getCustomModifiers.d.ts +3 -0
  76. package/{build → dist}/contexts/Modifiers/utils/getInternalModifiers.d.ts +0 -0
  77. package/{build/hooks/useDayModifiers → dist/contexts/Modifiers}/utils/isDateInRange.d.ts +1 -1
  78. package/dist/contexts/Modifiers/utils/isMatch.d.ts +19 -0
  79. package/dist/contexts/Modifiers/utils/matcherToArray.d.ts +3 -0
  80. package/{build → dist}/contexts/Navigation/NavigationContext.d.ts +9 -5
  81. package/{build → dist}/contexts/Navigation/index.d.ts +0 -0
  82. package/{build → dist}/contexts/Navigation/useNavigation.d.ts +0 -0
  83. package/{build → dist}/contexts/Navigation/useNavigationState.d.ts +0 -0
  84. package/{build → dist}/contexts/Navigation/utils/getDisplayMonths.d.ts +0 -0
  85. package/{build → dist}/contexts/Navigation/utils/getInitialMonth.d.ts +0 -0
  86. package/{build → dist}/contexts/Navigation/utils/getNextMonth.d.ts +0 -0
  87. package/{build → dist}/contexts/Navigation/utils/getPreviousMonth.d.ts +0 -0
  88. package/{build → dist}/contexts/RootProvider.d.ts +0 -0
  89. package/{build → dist}/contexts/SelectMultiple/SelectMultipleContext.d.ts +5 -5
  90. package/{build → dist}/contexts/SelectMultiple/index.d.ts +0 -0
  91. package/{build → dist}/contexts/SelectMultiple/useSelectMultiple.d.ts +0 -0
  92. package/{build → dist}/contexts/SelectRange/SelectRangeContext.d.ts +5 -5
  93. package/{build → dist}/contexts/SelectRange/index.d.ts +0 -0
  94. package/{build → dist}/contexts/SelectRange/useSelectRange.d.ts +0 -0
  95. package/{build → dist}/contexts/SelectRange/utils/addToRange.d.ts +0 -0
  96. package/{build → dist}/contexts/SelectSingle/SelectSingleContext.d.ts +0 -0
  97. package/{build → dist}/contexts/SelectSingle/index.d.ts +0 -0
  98. package/{build → dist}/contexts/SelectSingle/useSelectSingle.d.ts +0 -0
  99. package/dist/hooks/useActiveModifiers/index.d.ts +1 -0
  100. package/dist/hooks/useActiveModifiers/useActiveModifiers.d.ts +9 -0
  101. package/{build → dist}/hooks/useControlledValue/index.d.ts +0 -0
  102. package/{build → dist}/hooks/useControlledValue/useControlledValue.d.ts +0 -0
  103. package/dist/hooks/useDayEventHandlers/index.d.ts +1 -0
  104. package/dist/hooks/useDayEventHandlers/useDayEventHandlers.d.ts +28 -0
  105. package/dist/hooks/useDayRender/index.d.ts +1 -0
  106. package/dist/hooks/useDayRender/useDayRender.d.ts +39 -0
  107. package/dist/hooks/useDayRender/utils/getDayClassNames.d.ts +4 -0
  108. package/dist/hooks/useDayRender/utils/getDayStyle.d.ts +5 -0
  109. package/{build → dist}/hooks/useInput/index.d.ts +0 -0
  110. package/{build → dist}/hooks/useInput/useInput.d.ts +0 -0
  111. package/{build → dist}/hooks/useInput/utils/isValidDate.d.ts +0 -0
  112. package/dist/hooks/useSelectedDays/index.d.ts +1 -0
  113. package/dist/hooks/useSelectedDays/useSelectedDays.d.ts +8 -0
  114. package/{build → dist}/index.d.ts +3 -0
  115. package/dist/index.esm.js +2174 -0
  116. package/dist/index.esm.js.map +1 -0
  117. package/dist/index.js +2231 -38
  118. package/dist/index.js.map +1 -1
  119. package/dist/react-day-picker.min.js +1 -0
  120. package/{style.css → dist/style.css} +0 -0
  121. package/dist/style.css.d.ts +38 -0
  122. package/{build → dist}/types/DayPicker.d.ts +44 -36
  123. package/{build → dist}/types/DayPickerCustom.d.ts +0 -0
  124. package/{build → dist}/types/DayPickerMultiple.d.ts +0 -0
  125. package/{build → dist}/types/DayPickerRange.d.ts +0 -0
  126. package/{build → dist}/types/DayPickerSingle.d.ts +0 -0
  127. package/{build → dist}/types/EventHandlers.d.ts +9 -9
  128. package/{build → dist}/types/Formatters.d.ts +0 -0
  129. package/{build → dist}/types/Labels.d.ts +2 -2
  130. package/dist/types/Matchers.d.ts +84 -0
  131. package/{build → dist}/types/Modifiers.d.ts +25 -12
  132. package/{build → dist}/types/Styles.d.ts +1 -4
  133. package/package.json +40 -30
  134. package/build/DayPicker.js +0 -95
  135. package/build/DayPicker.js.map +0 -1
  136. package/build/components/Button/Button.d.ts +0 -7
  137. package/build/components/Button/Button.js +0 -20
  138. package/build/components/Button/Button.js.map +0 -1
  139. package/build/components/Button/index.js +0 -2
  140. package/build/components/Button/index.js.map +0 -1
  141. package/build/components/Caption/Caption.js +0 -62
  142. package/build/components/Caption/Caption.js.map +0 -1
  143. package/build/components/Caption/index.js +0 -2
  144. package/build/components/Caption/index.js.map +0 -1
  145. package/build/components/CaptionLabel/CaptionLabel.js +0 -8
  146. package/build/components/CaptionLabel/CaptionLabel.js.map +0 -1
  147. package/build/components/CaptionLabel/index.js +0 -2
  148. package/build/components/CaptionLabel/index.js.map +0 -1
  149. package/build/components/Day/Day.js +0 -21
  150. package/build/components/Day/Day.js.map +0 -1
  151. package/build/components/Day/hooks/index.d.ts +0 -1
  152. package/build/components/Day/hooks/index.js +0 -2
  153. package/build/components/Day/hooks/index.js.map +0 -1
  154. package/build/components/Day/hooks/useDay.d.ts +0 -60
  155. package/build/components/Day/hooks/useDay.js +0 -169
  156. package/build/components/Day/hooks/useDay.js.map +0 -1
  157. package/build/components/Day/hooks/useDayFocus.d.ts +0 -8
  158. package/build/components/Day/hooks/useDayFocus.js +0 -65
  159. package/build/components/Day/hooks/useDayFocus.js.map +0 -1
  160. package/build/components/Day/index.d.ts +0 -2
  161. package/build/components/Day/index.js +0 -3
  162. package/build/components/Day/index.js.map +0 -1
  163. package/build/components/DayContent/DayContent.js +0 -12
  164. package/build/components/DayContent/DayContent.js.map +0 -1
  165. package/build/components/DayContent/index.js +0 -2
  166. package/build/components/DayContent/index.js.map +0 -1
  167. package/build/components/Dropdown/Dropdown.js +0 -17
  168. package/build/components/Dropdown/Dropdown.js.map +0 -1
  169. package/build/components/Dropdown/index.js +0 -2
  170. package/build/components/Dropdown/index.js.map +0 -1
  171. package/build/components/Footer/Footer.js +0 -12
  172. package/build/components/Footer/Footer.js.map +0 -1
  173. package/build/components/Footer/index.js +0 -2
  174. package/build/components/Footer/index.js.map +0 -1
  175. package/build/components/Head/Head.js +0 -17
  176. package/build/components/Head/Head.js.map +0 -1
  177. package/build/components/Head/index.js +0 -2
  178. package/build/components/Head/index.js.map +0 -1
  179. package/build/components/Head/utils/getWeekdays.js +0 -15
  180. package/build/components/Head/utils/getWeekdays.js.map +0 -1
  181. package/build/components/Head/utils/index.js +0 -2
  182. package/build/components/Head/utils/index.js.map +0 -1
  183. package/build/components/IconDropdown/IconDropdown.js +0 -10
  184. package/build/components/IconDropdown/IconDropdown.js.map +0 -1
  185. package/build/components/IconDropdown/index.js +0 -2
  186. package/build/components/IconDropdown/index.js.map +0 -1
  187. package/build/components/IconLeft/IconLeft.js +0 -10
  188. package/build/components/IconLeft/IconLeft.js.map +0 -1
  189. package/build/components/IconLeft/index.js +0 -2
  190. package/build/components/IconLeft/index.js.map +0 -1
  191. package/build/components/IconRight/IconRight.js +0 -10
  192. package/build/components/IconRight/IconRight.js.map +0 -1
  193. package/build/components/IconRight/index.js +0 -2
  194. package/build/components/IconRight/index.js.map +0 -1
  195. package/build/components/Month/Month.js +0 -37
  196. package/build/components/Month/Month.js.map +0 -1
  197. package/build/components/Month/index.js +0 -2
  198. package/build/components/Month/index.js.map +0 -1
  199. package/build/components/MonthsDropdown/MonthsDropdown.js +0 -36
  200. package/build/components/MonthsDropdown/MonthsDropdown.js.map +0 -1
  201. package/build/components/MonthsDropdown/index.js +0 -2
  202. package/build/components/MonthsDropdown/index.js.map +0 -1
  203. package/build/components/Navigation/Navigation.js +0 -30
  204. package/build/components/Navigation/Navigation.js.map +0 -1
  205. package/build/components/Navigation/index.js +0 -2
  206. package/build/components/Navigation/index.js.map +0 -1
  207. package/build/components/Root/Root.d.ts +0 -6
  208. package/build/components/Root/Root.js +0 -32
  209. package/build/components/Root/Root.js.map +0 -1
  210. package/build/components/Root/index.js +0 -2
  211. package/build/components/Root/index.js.map +0 -1
  212. package/build/components/Row/Row.js +0 -19
  213. package/build/components/Row/Row.js.map +0 -1
  214. package/build/components/Row/index.js +0 -2
  215. package/build/components/Row/index.js.map +0 -1
  216. package/build/components/Table/Table.js +0 -15
  217. package/build/components/Table/Table.js.map +0 -1
  218. package/build/components/Table/index.js +0 -2
  219. package/build/components/Table/index.js.map +0 -1
  220. package/build/components/Table/utils/getOutsideEndDays.d.ts +0 -3
  221. package/build/components/Table/utils/getOutsideEndDays.js +0 -12
  222. package/build/components/Table/utils/getOutsideEndDays.js.map +0 -1
  223. package/build/components/Table/utils/getOutsideStartDays.d.ts +0 -4
  224. package/build/components/Table/utils/getOutsideStartDays.js +0 -12
  225. package/build/components/Table/utils/getOutsideStartDays.js.map +0 -1
  226. package/build/components/Table/utils/getWeeks.d.ts +0 -17
  227. package/build/components/Table/utils/getWeeks.js +0 -47
  228. package/build/components/Table/utils/getWeeks.js.map +0 -1
  229. package/build/components/WeekNumber/WeekNumber.js +0 -21
  230. package/build/components/WeekNumber/WeekNumber.js.map +0 -1
  231. package/build/components/WeekNumber/index.js +0 -2
  232. package/build/components/WeekNumber/index.js.map +0 -1
  233. package/build/components/YearsDropdown/YearsDropdown.js +0 -25
  234. package/build/components/YearsDropdown/YearsDropdown.js.map +0 -1
  235. package/build/components/YearsDropdown/index.js +0 -2
  236. package/build/components/YearsDropdown/index.js.map +0 -1
  237. package/build/contexts/DayPicker/DayPickerContext.js +0 -55
  238. package/build/contexts/DayPicker/DayPickerContext.js.map +0 -1
  239. package/build/contexts/DayPicker/defaultClassNames.js +0 -40
  240. package/build/contexts/DayPicker/defaultClassNames.js.map +0 -1
  241. package/build/contexts/DayPicker/formatters/formatCaption.js +0 -8
  242. package/build/contexts/DayPicker/formatters/formatCaption.js.map +0 -1
  243. package/build/contexts/DayPicker/formatters/formatDay.js +0 -8
  244. package/build/contexts/DayPicker/formatters/formatDay.js.map +0 -1
  245. package/build/contexts/DayPicker/formatters/formatMonthCaption.js +0 -8
  246. package/build/contexts/DayPicker/formatters/formatMonthCaption.js.map +0 -1
  247. package/build/contexts/DayPicker/formatters/formatWeekNumber.js +0 -7
  248. package/build/contexts/DayPicker/formatters/formatWeekNumber.js.map +0 -1
  249. package/build/contexts/DayPicker/formatters/formatWeekdayName.js +0 -8
  250. package/build/contexts/DayPicker/formatters/formatWeekdayName.js.map +0 -1
  251. package/build/contexts/DayPicker/formatters/formatYearCaption.js +0 -8
  252. package/build/contexts/DayPicker/formatters/formatYearCaption.js.map +0 -1
  253. package/build/contexts/DayPicker/formatters/index.js +0 -7
  254. package/build/contexts/DayPicker/formatters/index.js.map +0 -1
  255. package/build/contexts/DayPicker/index.js +0 -3
  256. package/build/contexts/DayPicker/index.js.map +0 -1
  257. package/build/contexts/DayPicker/labels/index.js +0 -8
  258. package/build/contexts/DayPicker/labels/index.js.map +0 -1
  259. package/build/contexts/DayPicker/labels/labelDay.js +0 -8
  260. package/build/contexts/DayPicker/labels/labelDay.js.map +0 -1
  261. package/build/contexts/DayPicker/labels/labelMonthDropdown.js +0 -7
  262. package/build/contexts/DayPicker/labels/labelMonthDropdown.js.map +0 -1
  263. package/build/contexts/DayPicker/labels/labelNext.js +0 -7
  264. package/build/contexts/DayPicker/labels/labelNext.js.map +0 -1
  265. package/build/contexts/DayPicker/labels/labelPrevious.js +0 -7
  266. package/build/contexts/DayPicker/labels/labelPrevious.js.map +0 -1
  267. package/build/contexts/DayPicker/labels/labelWeekNumber.js +0 -7
  268. package/build/contexts/DayPicker/labels/labelWeekNumber.js.map +0 -1
  269. package/build/contexts/DayPicker/labels/labelWeekday.js +0 -8
  270. package/build/contexts/DayPicker/labels/labelWeekday.js.map +0 -1
  271. package/build/contexts/DayPicker/labels/labelYearDropdown.js +0 -7
  272. package/build/contexts/DayPicker/labels/labelYearDropdown.js.map +0 -1
  273. package/build/contexts/DayPicker/useDayPicker.js +0 -16
  274. package/build/contexts/DayPicker/useDayPicker.js.map +0 -1
  275. package/build/contexts/DayPicker/utils/index.js +0 -2
  276. package/build/contexts/DayPicker/utils/index.js.map +0 -1
  277. package/build/contexts/DayPicker/utils/parseFromToProps.js +0 -26
  278. package/build/contexts/DayPicker/utils/parseFromToProps.js.map +0 -1
  279. package/build/contexts/Focus/FocusContext.js +0 -131
  280. package/build/contexts/Focus/FocusContext.js.map +0 -1
  281. package/build/contexts/Focus/getInitialFocusTarget.d.ts +0 -10
  282. package/build/contexts/Focus/getInitialFocusTarget.js +0 -44
  283. package/build/contexts/Focus/getInitialFocusTarget.js.map +0 -1
  284. package/build/contexts/Focus/index.d.ts +0 -2
  285. package/build/contexts/Focus/index.js +0 -3
  286. package/build/contexts/Focus/index.js.map +0 -1
  287. package/build/contexts/Focus/useFocus.js +0 -11
  288. package/build/contexts/Focus/useFocus.js.map +0 -1
  289. package/build/contexts/Modifiers/ModifiersContext.js +0 -20
  290. package/build/contexts/Modifiers/ModifiersContext.js.map +0 -1
  291. package/build/contexts/Modifiers/index.d.ts +0 -2
  292. package/build/contexts/Modifiers/index.js +0 -3
  293. package/build/contexts/Modifiers/index.js.map +0 -1
  294. package/build/contexts/Modifiers/useModifiers.d.ts +0 -3
  295. package/build/contexts/Modifiers/useModifiers.js +0 -11
  296. package/build/contexts/Modifiers/useModifiers.js.map +0 -1
  297. package/build/contexts/Modifiers/utils/getCustomModifiers.d.ts +0 -4
  298. package/build/contexts/Modifiers/utils/getCustomModifiers.js +0 -11
  299. package/build/contexts/Modifiers/utils/getCustomModifiers.js.map +0 -1
  300. package/build/contexts/Modifiers/utils/getInternalModifiers.js +0 -34
  301. package/build/contexts/Modifiers/utils/getInternalModifiers.js.map +0 -1
  302. package/build/contexts/Modifiers/utils/toMatcherArray.d.ts +0 -2
  303. package/build/contexts/Modifiers/utils/toMatcherArray.js +0 -12
  304. package/build/contexts/Modifiers/utils/toMatcherArray.js.map +0 -1
  305. package/build/contexts/Navigation/NavigationContext.js +0 -28
  306. package/build/contexts/Navigation/NavigationContext.js.map +0 -1
  307. package/build/contexts/Navigation/index.js +0 -3
  308. package/build/contexts/Navigation/index.js.map +0 -1
  309. package/build/contexts/Navigation/useNavigation.js +0 -11
  310. package/build/contexts/Navigation/useNavigation.js.map +0 -1
  311. package/build/contexts/Navigation/useNavigationState.js +0 -16
  312. package/build/contexts/Navigation/useNavigationState.js.map +0 -1
  313. package/build/contexts/Navigation/utils/getDisplayMonths.js +0 -20
  314. package/build/contexts/Navigation/utils/getDisplayMonths.js.map +0 -1
  315. package/build/contexts/Navigation/utils/getInitialMonth.js +0 -18
  316. package/build/contexts/Navigation/utils/getInitialMonth.js.map +0 -1
  317. package/build/contexts/Navigation/utils/getNextMonth.js +0 -29
  318. package/build/contexts/Navigation/utils/getNextMonth.js.map +0 -1
  319. package/build/contexts/Navigation/utils/getPreviousMonth.js +0 -30
  320. package/build/contexts/Navigation/utils/getPreviousMonth.js.map +0 -1
  321. package/build/contexts/RootProvider.js +0 -21
  322. package/build/contexts/RootProvider.js.map +0 -1
  323. package/build/contexts/SelectMultiple/SelectMultipleContext.js +0 -76
  324. package/build/contexts/SelectMultiple/SelectMultipleContext.js.map +0 -1
  325. package/build/contexts/SelectMultiple/index.js +0 -3
  326. package/build/contexts/SelectMultiple/index.js.map +0 -1
  327. package/build/contexts/SelectMultiple/useSelectMultiple.js +0 -11
  328. package/build/contexts/SelectMultiple/useSelectMultiple.js.map +0 -1
  329. package/build/contexts/SelectRange/SelectRangeContext.js +0 -117
  330. package/build/contexts/SelectRange/SelectRangeContext.js.map +0 -1
  331. package/build/contexts/SelectRange/index.js +0 -3
  332. package/build/contexts/SelectRange/index.js.map +0 -1
  333. package/build/contexts/SelectRange/useSelectRange.js +0 -11
  334. package/build/contexts/SelectRange/useSelectRange.js.map +0 -1
  335. package/build/contexts/SelectRange/utils/addToRange.js +0 -36
  336. package/build/contexts/SelectRange/utils/addToRange.js.map +0 -1
  337. package/build/contexts/SelectSingle/SelectSingleContext.js +0 -36
  338. package/build/contexts/SelectSingle/SelectSingleContext.js.map +0 -1
  339. package/build/contexts/SelectSingle/index.js +0 -3
  340. package/build/contexts/SelectSingle/index.js.map +0 -1
  341. package/build/contexts/SelectSingle/useSelectSingle.js +0 -11
  342. package/build/contexts/SelectSingle/useSelectSingle.js.map +0 -1
  343. package/build/hooks/useControlledValue/index.js +0 -2
  344. package/build/hooks/useControlledValue/index.js.map +0 -1
  345. package/build/hooks/useControlledValue/useControlledValue.js +0 -16
  346. package/build/hooks/useControlledValue/useControlledValue.js.map +0 -1
  347. package/build/hooks/useDayModifiers/index.d.ts +0 -1
  348. package/build/hooks/useDayModifiers/index.js +0 -2
  349. package/build/hooks/useDayModifiers/index.js.map +0 -1
  350. package/build/hooks/useDayModifiers/useDayModifiers.d.ts +0 -12
  351. package/build/hooks/useDayModifiers/useDayModifiers.js +0 -34
  352. package/build/hooks/useDayModifiers/useDayModifiers.js.map +0 -1
  353. package/build/hooks/useDayModifiers/utils/getModifierStatus.d.ts +0 -7
  354. package/build/hooks/useDayModifiers/utils/getModifierStatus.js +0 -19
  355. package/build/hooks/useDayModifiers/utils/getModifierStatus.js.map +0 -1
  356. package/build/hooks/useDayModifiers/utils/isDateInRange.js +0 -22
  357. package/build/hooks/useDayModifiers/utils/isDateInRange.js.map +0 -1
  358. package/build/hooks/useDayModifiers/utils/isMatch.d.ts +0 -5
  359. package/build/hooks/useDayModifiers/utils/isMatch.js +0 -49
  360. package/build/hooks/useDayModifiers/utils/isMatch.js.map +0 -1
  361. package/build/hooks/useInput/index.js +0 -2
  362. package/build/hooks/useInput/index.js.map +0 -1
  363. package/build/hooks/useInput/useInput.js +0 -98
  364. package/build/hooks/useInput/useInput.js.map +0 -1
  365. package/build/hooks/useInput/utils/isValidDate.js +0 -5
  366. package/build/hooks/useInput/utils/isValidDate.js.map +0 -1
  367. package/build/index.js +0 -35
  368. package/build/index.js.map +0 -1
  369. package/build/types/DayPicker.js +0 -2
  370. package/build/types/DayPicker.js.map +0 -1
  371. package/build/types/DayPickerCustom.js +0 -5
  372. package/build/types/DayPickerCustom.js.map +0 -1
  373. package/build/types/DayPickerMultiple.js +0 -5
  374. package/build/types/DayPickerMultiple.js.map +0 -1
  375. package/build/types/DayPickerRange.js +0 -5
  376. package/build/types/DayPickerRange.js.map +0 -1
  377. package/build/types/DayPickerSingle.js +0 -5
  378. package/build/types/DayPickerSingle.js.map +0 -1
  379. package/build/types/EventHandlers.js +0 -2
  380. package/build/types/EventHandlers.js.map +0 -1
  381. package/build/types/Formatters.js +0 -2
  382. package/build/types/Formatters.js.map +0 -1
  383. package/build/types/Labels.js +0 -2
  384. package/build/types/Labels.js.map +0 -1
  385. package/build/types/Matchers.d.ts +0 -34
  386. package/build/types/Matchers.js +0 -25
  387. package/build/types/Matchers.js.map +0 -1
  388. package/build/types/Modifiers.js +0 -19
  389. package/build/types/Modifiers.js.map +0 -1
  390. package/build/types/Styles.js +0 -2
  391. package/build/types/Styles.js.map +0 -1
  392. package/dist/DayPicker.js +0 -99
  393. package/dist/DayPicker.js.map +0 -1
  394. package/dist/components/Button/Button.js +0 -23
  395. package/dist/components/Button/Button.js.map +0 -1
  396. package/dist/components/Button/index.js +0 -5
  397. package/dist/components/Button/index.js.map +0 -1
  398. package/dist/components/Caption/Caption.js +0 -67
  399. package/dist/components/Caption/Caption.js.map +0 -1
  400. package/dist/components/Caption/index.js +0 -5
  401. package/dist/components/Caption/index.js.map +0 -1
  402. package/dist/components/CaptionLabel/CaptionLabel.js +0 -13
  403. package/dist/components/CaptionLabel/CaptionLabel.js.map +0 -1
  404. package/dist/components/CaptionLabel/index.js +0 -5
  405. package/dist/components/CaptionLabel/index.js.map +0 -1
  406. package/dist/components/Day/Day.js +0 -25
  407. package/dist/components/Day/Day.js.map +0 -1
  408. package/dist/components/Day/hooks/index.js +0 -5
  409. package/dist/components/Day/hooks/index.js.map +0 -1
  410. package/dist/components/Day/hooks/useDay.js +0 -173
  411. package/dist/components/Day/hooks/useDay.js.map +0 -1
  412. package/dist/components/Day/hooks/useDayFocus.js +0 -70
  413. package/dist/components/Day/hooks/useDayFocus.js.map +0 -1
  414. package/dist/components/Day/index.js +0 -6
  415. package/dist/components/Day/index.js.map +0 -1
  416. package/dist/components/DayContent/DayContent.js +0 -17
  417. package/dist/components/DayContent/DayContent.js.map +0 -1
  418. package/dist/components/DayContent/index.js +0 -5
  419. package/dist/components/DayContent/index.js.map +0 -1
  420. package/dist/components/Dropdown/Dropdown.js +0 -22
  421. package/dist/components/Dropdown/Dropdown.js.map +0 -1
  422. package/dist/components/Dropdown/index.js +0 -5
  423. package/dist/components/Dropdown/index.js.map +0 -1
  424. package/dist/components/Footer/Footer.js +0 -17
  425. package/dist/components/Footer/Footer.js.map +0 -1
  426. package/dist/components/Footer/index.js +0 -5
  427. package/dist/components/Footer/index.js.map +0 -1
  428. package/dist/components/Head/Head.js +0 -22
  429. package/dist/components/Head/Head.js.map +0 -1
  430. package/dist/components/Head/index.js +0 -5
  431. package/dist/components/Head/index.js.map +0 -1
  432. package/dist/components/Head/utils/getWeekdays.js +0 -19
  433. package/dist/components/Head/utils/getWeekdays.js.map +0 -1
  434. package/dist/components/Head/utils/index.js +0 -5
  435. package/dist/components/Head/utils/index.js.map +0 -1
  436. package/dist/components/IconDropdown/IconDropdown.js +0 -14
  437. package/dist/components/IconDropdown/IconDropdown.js.map +0 -1
  438. package/dist/components/IconDropdown/index.js +0 -5
  439. package/dist/components/IconDropdown/index.js.map +0 -1
  440. package/dist/components/IconLeft/IconLeft.js +0 -14
  441. package/dist/components/IconLeft/IconLeft.js.map +0 -1
  442. package/dist/components/IconLeft/index.js +0 -5
  443. package/dist/components/IconLeft/index.js.map +0 -1
  444. package/dist/components/IconRight/IconRight.js +0 -14
  445. package/dist/components/IconRight/IconRight.js.map +0 -1
  446. package/dist/components/IconRight/index.js +0 -5
  447. package/dist/components/IconRight/index.js.map +0 -1
  448. package/dist/components/Month/Month.js +0 -41
  449. package/dist/components/Month/Month.js.map +0 -1
  450. package/dist/components/Month/index.js +0 -5
  451. package/dist/components/Month/index.js.map +0 -1
  452. package/dist/components/MonthsDropdown/MonthsDropdown.js +0 -41
  453. package/dist/components/MonthsDropdown/MonthsDropdown.js.map +0 -1
  454. package/dist/components/MonthsDropdown/index.js +0 -5
  455. package/dist/components/MonthsDropdown/index.js.map +0 -1
  456. package/dist/components/Navigation/Navigation.js +0 -35
  457. package/dist/components/Navigation/Navigation.js.map +0 -1
  458. package/dist/components/Navigation/index.js +0 -5
  459. package/dist/components/Navigation/index.js.map +0 -1
  460. package/dist/components/Root/Root.js +0 -36
  461. package/dist/components/Root/Root.js.map +0 -1
  462. package/dist/components/Root/index.js +0 -5
  463. package/dist/components/Root/index.js.map +0 -1
  464. package/dist/components/Row/Row.js +0 -24
  465. package/dist/components/Row/Row.js.map +0 -1
  466. package/dist/components/Row/index.js +0 -5
  467. package/dist/components/Row/index.js.map +0 -1
  468. package/dist/components/Table/Table.js +0 -20
  469. package/dist/components/Table/Table.js.map +0 -1
  470. package/dist/components/Table/index.js +0 -5
  471. package/dist/components/Table/index.js.map +0 -1
  472. package/dist/components/Table/utils/getOutsideEndDays.js +0 -16
  473. package/dist/components/Table/utils/getOutsideEndDays.js.map +0 -1
  474. package/dist/components/Table/utils/getOutsideStartDays.js +0 -16
  475. package/dist/components/Table/utils/getOutsideStartDays.js.map +0 -1
  476. package/dist/components/Table/utils/getWeeks.js +0 -51
  477. package/dist/components/Table/utils/getWeeks.js.map +0 -1
  478. package/dist/components/WeekNumber/WeekNumber.js +0 -26
  479. package/dist/components/WeekNumber/WeekNumber.js.map +0 -1
  480. package/dist/components/WeekNumber/index.js +0 -5
  481. package/dist/components/WeekNumber/index.js.map +0 -1
  482. package/dist/components/YearsDropdown/YearsDropdown.js +0 -30
  483. package/dist/components/YearsDropdown/YearsDropdown.js.map +0 -1
  484. package/dist/components/YearsDropdown/index.js +0 -5
  485. package/dist/components/YearsDropdown/index.js.map +0 -1
  486. package/dist/contexts/DayPicker/DayPickerContext.js +0 -57
  487. package/dist/contexts/DayPicker/DayPickerContext.js.map +0 -1
  488. package/dist/contexts/DayPicker/DayPickerProvider.js +0 -49
  489. package/dist/contexts/DayPicker/DayPickerProvider.js.map +0 -1
  490. package/dist/contexts/DayPicker/defaultClassNames.js +0 -43
  491. package/dist/contexts/DayPicker/defaultClassNames.js.map +0 -1
  492. package/dist/contexts/DayPicker/defaultContextValues.js +0 -65
  493. package/dist/contexts/DayPicker/defaultContextValues.js.map +0 -1
  494. package/dist/contexts/DayPicker/formatters/formatCaption.js +0 -12
  495. package/dist/contexts/DayPicker/formatters/formatCaption.js.map +0 -1
  496. package/dist/contexts/DayPicker/formatters/formatDay.js +0 -12
  497. package/dist/contexts/DayPicker/formatters/formatDay.js.map +0 -1
  498. package/dist/contexts/DayPicker/formatters/formatMonthCaption.js +0 -12
  499. package/dist/contexts/DayPicker/formatters/formatMonthCaption.js.map +0 -1
  500. package/dist/contexts/DayPicker/formatters/formatWeekNumber.js +0 -11
  501. package/dist/contexts/DayPicker/formatters/formatWeekNumber.js.map +0 -1
  502. package/dist/contexts/DayPicker/formatters/formatWeekdayName.js +0 -12
  503. package/dist/contexts/DayPicker/formatters/formatWeekdayName.js.map +0 -1
  504. package/dist/contexts/DayPicker/formatters/formatYearCaption.js +0 -12
  505. package/dist/contexts/DayPicker/formatters/formatYearCaption.js.map +0 -1
  506. package/dist/contexts/DayPicker/formatters/index.js +0 -10
  507. package/dist/contexts/DayPicker/formatters/index.js.map +0 -1
  508. package/dist/contexts/DayPicker/index.js +0 -6
  509. package/dist/contexts/DayPicker/index.js.map +0 -1
  510. package/dist/contexts/DayPicker/labels/index.js +0 -11
  511. package/dist/contexts/DayPicker/labels/index.js.map +0 -1
  512. package/dist/contexts/DayPicker/labels/labelDay.js +0 -12
  513. package/dist/contexts/DayPicker/labels/labelDay.js.map +0 -1
  514. package/dist/contexts/DayPicker/labels/labelMonthDropdown.js +0 -11
  515. package/dist/contexts/DayPicker/labels/labelMonthDropdown.js.map +0 -1
  516. package/dist/contexts/DayPicker/labels/labelNext.js +0 -11
  517. package/dist/contexts/DayPicker/labels/labelNext.js.map +0 -1
  518. package/dist/contexts/DayPicker/labels/labelPrevious.js +0 -11
  519. package/dist/contexts/DayPicker/labels/labelPrevious.js.map +0 -1
  520. package/dist/contexts/DayPicker/labels/labelWeekNumber.js +0 -11
  521. package/dist/contexts/DayPicker/labels/labelWeekNumber.js.map +0 -1
  522. package/dist/contexts/DayPicker/labels/labelWeekday.js +0 -12
  523. package/dist/contexts/DayPicker/labels/labelWeekday.js.map +0 -1
  524. package/dist/contexts/DayPicker/labels/labelYearDropdown.js +0 -11
  525. package/dist/contexts/DayPicker/labels/labelYearDropdown.js.map +0 -1
  526. package/dist/contexts/DayPicker/useDayPicker.js +0 -21
  527. package/dist/contexts/DayPicker/useDayPicker.js.map +0 -1
  528. package/dist/contexts/DayPicker/utils/index.js +0 -5
  529. package/dist/contexts/DayPicker/utils/index.js.map +0 -1
  530. package/dist/contexts/DayPicker/utils/parseFromToProps.js +0 -30
  531. package/dist/contexts/DayPicker/utils/parseFromToProps.js.map +0 -1
  532. package/dist/contexts/Focus/FocusContext.js +0 -136
  533. package/dist/contexts/Focus/FocusContext.js.map +0 -1
  534. package/dist/contexts/Focus/getInitialFocusTarget.js +0 -48
  535. package/dist/contexts/Focus/getInitialFocusTarget.js.map +0 -1
  536. package/dist/contexts/Focus/index.js +0 -6
  537. package/dist/contexts/Focus/index.js.map +0 -1
  538. package/dist/contexts/Focus/useFocus.js +0 -16
  539. package/dist/contexts/Focus/useFocus.js.map +0 -1
  540. package/dist/contexts/Modifiers/ModifiersContext.js +0 -65
  541. package/dist/contexts/Modifiers/ModifiersContext.js.map +0 -1
  542. package/dist/contexts/Modifiers/index.js +0 -6
  543. package/dist/contexts/Modifiers/index.js.map +0 -1
  544. package/dist/contexts/Modifiers/useModifiers.js +0 -16
  545. package/dist/contexts/Modifiers/useModifiers.js.map +0 -1
  546. package/dist/contexts/Modifiers/utils/getCustomModifiers.js +0 -15
  547. package/dist/contexts/Modifiers/utils/getCustomModifiers.js.map +0 -1
  548. package/dist/contexts/Modifiers/utils/getInternalModifiers.js +0 -39
  549. package/dist/contexts/Modifiers/utils/getInternalModifiers.js.map +0 -1
  550. package/dist/contexts/Modifiers/utils/matcherToArray.js +0 -17
  551. package/dist/contexts/Modifiers/utils/matcherToArray.js.map +0 -1
  552. package/dist/contexts/Modifiers/utils/toMatcherArray.js +0 -16
  553. package/dist/contexts/Modifiers/utils/toMatcherArray.js.map +0 -1
  554. package/dist/contexts/Navigation/NavigationContext.js +0 -33
  555. package/dist/contexts/Navigation/NavigationContext.js.map +0 -1
  556. package/dist/contexts/Navigation/index.js +0 -6
  557. package/dist/contexts/Navigation/index.js.map +0 -1
  558. package/dist/contexts/Navigation/useNavigation.js +0 -16
  559. package/dist/contexts/Navigation/useNavigation.js.map +0 -1
  560. package/dist/contexts/Navigation/useNavigationState.js +0 -20
  561. package/dist/contexts/Navigation/useNavigationState.js.map +0 -1
  562. package/dist/contexts/Navigation/utils/getDisplayMonths.js +0 -24
  563. package/dist/contexts/Navigation/utils/getDisplayMonths.js.map +0 -1
  564. package/dist/contexts/Navigation/utils/getInitialMonth.js +0 -22
  565. package/dist/contexts/Navigation/utils/getInitialMonth.js.map +0 -1
  566. package/dist/contexts/Navigation/utils/getNextMonth.js +0 -33
  567. package/dist/contexts/Navigation/utils/getNextMonth.js.map +0 -1
  568. package/dist/contexts/Navigation/utils/getPreviousMonth.js +0 -34
  569. package/dist/contexts/Navigation/utils/getPreviousMonth.js.map +0 -1
  570. package/dist/contexts/RootProvider.js +0 -25
  571. package/dist/contexts/RootProvider.js.map +0 -1
  572. package/dist/contexts/SelectMultiple/SelectMultipleContext.js +0 -81
  573. package/dist/contexts/SelectMultiple/SelectMultipleContext.js.map +0 -1
  574. package/dist/contexts/SelectMultiple/index.js +0 -6
  575. package/dist/contexts/SelectMultiple/index.js.map +0 -1
  576. package/dist/contexts/SelectMultiple/useSelectMultiple.js +0 -16
  577. package/dist/contexts/SelectMultiple/useSelectMultiple.js.map +0 -1
  578. package/dist/contexts/SelectRange/SelectRangeContext.js +0 -123
  579. package/dist/contexts/SelectRange/SelectRangeContext.js.map +0 -1
  580. package/dist/contexts/SelectRange/index.js +0 -6
  581. package/dist/contexts/SelectRange/index.js.map +0 -1
  582. package/dist/contexts/SelectRange/useSelectRange.js +0 -16
  583. package/dist/contexts/SelectRange/useSelectRange.js.map +0 -1
  584. package/dist/contexts/SelectRange/utils/addToRange.js +0 -40
  585. package/dist/contexts/SelectRange/utils/addToRange.js.map +0 -1
  586. package/dist/contexts/SelectSingle/SelectSingleContext.js +0 -42
  587. package/dist/contexts/SelectSingle/SelectSingleContext.js.map +0 -1
  588. package/dist/contexts/SelectSingle/index.js +0 -6
  589. package/dist/contexts/SelectSingle/index.js.map +0 -1
  590. package/dist/contexts/SelectSingle/useSelectSingle.js +0 -16
  591. package/dist/contexts/SelectSingle/useSelectSingle.js.map +0 -1
  592. package/dist/hooks/useControlledValue/index.js +0 -5
  593. package/dist/hooks/useControlledValue/index.js.map +0 -1
  594. package/dist/hooks/useControlledValue/useControlledValue.js +0 -21
  595. package/dist/hooks/useControlledValue/useControlledValue.js.map +0 -1
  596. package/dist/hooks/useDayModifiers/index.js +0 -5
  597. package/dist/hooks/useDayModifiers/index.js.map +0 -1
  598. package/dist/hooks/useDayModifiers/useDayModifiers.js +0 -38
  599. package/dist/hooks/useDayModifiers/useDayModifiers.js.map +0 -1
  600. package/dist/hooks/useDayModifiers/utils/getModifierStatus.js +0 -23
  601. package/dist/hooks/useDayModifiers/utils/getModifierStatus.js.map +0 -1
  602. package/dist/hooks/useDayModifiers/utils/isDateInRange.js +0 -26
  603. package/dist/hooks/useDayModifiers/utils/isDateInRange.js.map +0 -1
  604. package/dist/hooks/useDayModifiers/utils/isMatch.js +0 -53
  605. package/dist/hooks/useDayModifiers/utils/isMatch.js.map +0 -1
  606. package/dist/hooks/useInput/index.js +0 -5
  607. package/dist/hooks/useInput/index.js.map +0 -1
  608. package/dist/hooks/useInput/useInput.js +0 -103
  609. package/dist/hooks/useInput/useInput.js.map +0 -1
  610. package/dist/hooks/useInput/utils/isValidDate.js +0 -9
  611. package/dist/hooks/useInput/utils/isValidDate.js.map +0 -1
  612. package/dist/types/DayPicker.js +0 -3
  613. package/dist/types/DayPicker.js.map +0 -1
  614. package/dist/types/DayPickerCustom.js +0 -9
  615. package/dist/types/DayPickerCustom.js.map +0 -1
  616. package/dist/types/DayPickerMultiple.js +0 -9
  617. package/dist/types/DayPickerMultiple.js.map +0 -1
  618. package/dist/types/DayPickerRange.js +0 -9
  619. package/dist/types/DayPickerRange.js.map +0 -1
  620. package/dist/types/DayPickerSingle.js +0 -9
  621. package/dist/types/DayPickerSingle.js.map +0 -1
  622. package/dist/types/EventHandlers.js +0 -3
  623. package/dist/types/EventHandlers.js.map +0 -1
  624. package/dist/types/Formatters.js +0 -3
  625. package/dist/types/Formatters.js.map +0 -1
  626. package/dist/types/Labels.js +0 -3
  627. package/dist/types/Labels.js.map +0 -1
  628. package/dist/types/Matchers.js +0 -33
  629. package/dist/types/Matchers.js.map +0 -1
  630. package/dist/types/Modifiers.js +0 -3
  631. package/dist/types/Modifiers.js.map +0 -1
  632. package/dist/types/Styles.js +0 -3
  633. package/dist/types/Styles.js.map +0 -1
  634. package/style.css.d.ts +0 -39
package/dist/index.js CHANGED
@@ -1,38 +1,2231 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- /* Note: this file is excluded from tsconfig.json and reintroduced in tsconfig.build.json for a better dev experience. */
5
- (0, tslib_1.__exportStar)(require("./DayPicker"), exports);
6
- (0, tslib_1.__exportStar)(require("./components/Button"), exports);
7
- (0, tslib_1.__exportStar)(require("./components/Caption"), exports);
8
- (0, tslib_1.__exportStar)(require("./components/CaptionLabel"), exports);
9
- (0, tslib_1.__exportStar)(require("./components/Day"), exports);
10
- (0, tslib_1.__exportStar)(require("./components/DayContent"), exports);
11
- (0, tslib_1.__exportStar)(require("./components/Dropdown"), exports);
12
- (0, tslib_1.__exportStar)(require("./components/Footer"), exports);
13
- (0, tslib_1.__exportStar)(require("./components/Head"), exports);
14
- (0, tslib_1.__exportStar)(require("./components/IconDropdown"), exports);
15
- (0, tslib_1.__exportStar)(require("./components/IconRight"), exports);
16
- (0, tslib_1.__exportStar)(require("./components/IconLeft"), exports);
17
- (0, tslib_1.__exportStar)(require("./components/Row"), exports);
18
- (0, tslib_1.__exportStar)(require("./components/WeekNumber"), exports);
19
- (0, tslib_1.__exportStar)(require("./hooks/useInput"), exports);
20
- (0, tslib_1.__exportStar)(require("./contexts/DayPicker"), exports);
21
- (0, tslib_1.__exportStar)(require("./contexts/Focus"), exports);
22
- (0, tslib_1.__exportStar)(require("./contexts/Navigation"), exports);
23
- (0, tslib_1.__exportStar)(require("./contexts/RootProvider"), exports);
24
- (0, tslib_1.__exportStar)(require("./contexts/SelectMultiple"), exports);
25
- (0, tslib_1.__exportStar)(require("./contexts/SelectRange"), exports);
26
- (0, tslib_1.__exportStar)(require("./contexts/SelectSingle"), exports);
27
- (0, tslib_1.__exportStar)(require("./types/DayPicker"), exports);
28
- (0, tslib_1.__exportStar)(require("./types/DayPickerCustom"), exports);
29
- (0, tslib_1.__exportStar)(require("./types/DayPickerMultiple"), exports);
30
- (0, tslib_1.__exportStar)(require("./types/DayPickerRange"), exports);
31
- (0, tslib_1.__exportStar)(require("./types/DayPickerSingle"), exports);
32
- (0, tslib_1.__exportStar)(require("./types/EventHandlers"), exports);
33
- (0, tslib_1.__exportStar)(require("./types/Formatters"), exports);
34
- (0, tslib_1.__exportStar)(require("./types/Labels"), exports);
35
- (0, tslib_1.__exportStar)(require("./types/Matchers"), exports);
36
- (0, tslib_1.__exportStar)(require("./types/Modifiers"), exports);
37
- (0, tslib_1.__exportStar)(require("./types/Styles"), exports);
38
- //# sourceMappingURL=index.js.map
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var dateFns = require('date-fns');
7
+ var enUS = require('date-fns/locale/en-US');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+ var enUS__default = /*#__PURE__*/_interopDefaultLegacy(enUS);
13
+
14
+ /*! *****************************************************************************
15
+ Copyright (c) Microsoft Corporation.
16
+
17
+ Permission to use, copy, modify, and/or distribute this software for any
18
+ purpose with or without fee is hereby granted.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
+ PERFORMANCE OF THIS SOFTWARE.
27
+ ***************************************************************************** */
28
+
29
+ var __assign = function() {
30
+ __assign = Object.assign || function __assign(t) {
31
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
32
+ s = arguments[i];
33
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34
+ }
35
+ return t;
36
+ };
37
+ return __assign.apply(this, arguments);
38
+ };
39
+
40
+ function __rest(s, e) {
41
+ var t = {};
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
+ t[p] = s[p];
44
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
+ t[p[i]] = s[p[i]];
48
+ }
49
+ return t;
50
+ }
51
+
52
+ function __spreadArray(to, from, pack) {
53
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
54
+ if (ar || !(i in from)) {
55
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
56
+ ar[i] = from[i];
57
+ }
58
+ }
59
+ return to.concat(ar || Array.prototype.slice.call(from));
60
+ }
61
+
62
+ function canUseDOM() {
63
+ return !!(typeof window !== "undefined" && window.document && window.document.createElement);
64
+ }
65
+
66
+ /**
67
+ * React currently throws a warning when using useLayoutEffect on the server. To
68
+ * get around it, we can conditionally useEffect on the server (no-op) and
69
+ * useLayoutEffect in the browser. We occasionally need useLayoutEffect to
70
+ * ensure we don't get a render flash for certain operations, but we may also
71
+ * need affected components to render on the server. One example is when setting
72
+ * a component's descendants to retrieve their index values.
73
+ *
74
+ * Important to note that using this hook as an escape hatch will break the
75
+ * eslint dependency warnings unless you rename the import to `useLayoutEffect`.
76
+ * Use sparingly only when the effect won't effect the rendered HTML to avoid
77
+ * any server/client mismatch.
78
+ *
79
+ * If a useLayoutEffect is needed and the result would create a mismatch, it's
80
+ * likely that the component in question shouldn't be rendered on the server at
81
+ * all, so a better approach would be to lazily render those in a parent
82
+ * component after client-side hydration.
83
+ *
84
+ * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
85
+ * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
86
+ *
87
+ * @param effect
88
+ * @param deps
89
+ */
90
+
91
+ var useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? React.useLayoutEffect : React.useEffect;
92
+
93
+ /*
94
+ * Welcome to @reach/auto-id!
95
+
96
+ * Let's see if we can make sense of why this hook exists and its
97
+ * implementation.
98
+ *
99
+ * Some background:
100
+ * 1. Accessibility APIs rely heavily on element IDs
101
+ * 2. Requiring developers to put IDs on every element in Reach UI is both
102
+ * cumbersome and error-prone
103
+ * 3. With a component model, we can generate IDs for them!
104
+ *
105
+ * Solution 1: Generate random IDs.
106
+ *
107
+ * This works great as long as you don't server render your app. When React (in
108
+ * the client) tries to reuse the markup from the server, the IDs won't match
109
+ * and React will then recreate the entire DOM tree.
110
+ *
111
+ * Solution 2: Increment an integer
112
+ *
113
+ * This sounds great. Since we're rendering the exact same tree on the server
114
+ * and client, we can increment a counter and get a deterministic result between
115
+ * client and server. Also, JS integers can go up to nine-quadrillion. I'm
116
+ * pretty sure the tab will be closed before an app never needs
117
+ * 10 quadrillion IDs!
118
+ *
119
+ * Problem solved, right?
120
+ *
121
+ * Ah, but there's a catch! React's concurrent rendering makes this approach
122
+ * non-deterministic. While the client and server will end up with the same
123
+ * elements in the end, depending on suspense boundaries (and possibly some user
124
+ * input during the initial render) the incrementing integers won't always match
125
+ * up.
126
+ *
127
+ * Solution 3: Don't use IDs at all on the server; patch after first render.
128
+ *
129
+ * What we've done here is solution 2 with some tricks. With this approach, the
130
+ * ID returned is an empty string on the first render. This way the server and
131
+ * client have the same markup no matter how wild the concurrent rendering may
132
+ * have gotten.
133
+ *
134
+ * After the render, we patch up the components with an incremented ID. This
135
+ * causes a double render on any components with `useId`. Shouldn't be a problem
136
+ * since the components using this hook should be small, and we're only updating
137
+ * the ID attribute on the DOM, nothing big is happening.
138
+ *
139
+ * It doesn't have to be an incremented number, though--we could do generate
140
+ * random strings instead, but incrementing a number is probably the cheapest
141
+ * thing we can do.
142
+ *
143
+ * Additionally, we only do this patchup on the very first client render ever.
144
+ * Any calls to `useId` that happen dynamically in the client will be
145
+ * populated immediately with a value. So, we only get the double render after
146
+ * server hydration and never again, SO BACK OFF ALRIGHT?
147
+ */
148
+ var serverHandoffComplete = false;
149
+ var id = 0;
150
+
151
+ var genId = function genId() {
152
+ return ++id;
153
+ };
154
+ /**
155
+ * useId
156
+ *
157
+ * Autogenerate IDs to facilitate WAI-ARIA and server rendering.
158
+ *
159
+ * Note: The returned ID will initially be `null` and will update after a
160
+ * component mounts. Users may need to supply their own ID if they need
161
+ * consistent values for SSR.
162
+ *
163
+ * @see Docs https://reach.tech/auto-id
164
+ */
165
+
166
+
167
+ function useId(idFromProps) {
168
+ /*
169
+ * If this instance isn't part of the initial render, we don't have to do the
170
+ * double render/patch-up dance. We can just generate the ID and return it.
171
+ */
172
+ var initialId = idFromProps || (serverHandoffComplete ? genId() : null);
173
+
174
+ var _React$useState = React.useState(initialId),
175
+ id = _React$useState[0],
176
+ setId = _React$useState[1];
177
+
178
+ useIsomorphicLayoutEffect(function () {
179
+ if (id === null) {
180
+ /*
181
+ * Patch the ID after render. We do this in `useLayoutEffect` to avoid any
182
+ * rendering flicker, though it'll make the first render slower (unlikely
183
+ * to matter, but you're welcome to measure your app and let us know if
184
+ * it's a problem).
185
+ */
186
+ setId(genId());
187
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
188
+
189
+ }, []);
190
+ React.useEffect(function () {
191
+ if (serverHandoffComplete === false) {
192
+ /*
193
+ * Flag all future uses of `useId` to skip the update dance. This is in
194
+ * `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
195
+ * accidentally bail out of the patch-up dance prematurely.
196
+ */
197
+ serverHandoffComplete = true;
198
+ }
199
+ }, []);
200
+ return id != null ? String(id) : undefined;
201
+ }
202
+
203
+ /**
204
+ * The name of the default CSS classes.
205
+ */
206
+ var defaultClassNames = {
207
+ root: 'rdp',
208
+ multiple_months: 'rdp-multiple_months',
209
+ with_weeknumber: 'rdp-with_weeknumber',
210
+ vhidden: 'rdp-vhidden',
211
+ button_reset: 'rdp-button_reset',
212
+ button: 'rdp-button',
213
+ caption: 'rdp-caption',
214
+ caption_start: 'rdp-caption_start',
215
+ caption_end: 'rdp-caption_end',
216
+ caption_between: 'rdp-caption_between',
217
+ caption_label: 'rdp-caption_label',
218
+ caption_dropdowns: 'rdp-caption_dropdowns',
219
+ dropdown: 'rdp-dropdown',
220
+ dropdown_month: 'rdp-dropdown_month',
221
+ dropdown_year: 'rdp-dropdown_year',
222
+ dropdown_icon: 'rdp-dropdown_icon',
223
+ months: 'rdp-months',
224
+ month: 'rdp-month',
225
+ table: 'rdp-table',
226
+ tbody: 'rdp-tbody',
227
+ tfoot: 'rdp-tfoot',
228
+ head: 'rdp-head',
229
+ head_row: 'rdp-head_row',
230
+ head_cell: 'rdp-head_cell',
231
+ nav: 'rdp-nav',
232
+ nav_button: 'rdp-nav_button',
233
+ nav_button_previous: 'rdp-nav_button_previous',
234
+ nav_button_next: 'rdp-nav_button_next',
235
+ nav_icon: 'rdp-nav_icon',
236
+ row: 'rdp-row',
237
+ weeknumber: 'rdp-weeknumber',
238
+ cell: 'rdp-cell',
239
+ day: 'rdp-day',
240
+ day_outside: 'rdp-day_outside'
241
+ };
242
+
243
+ /**
244
+ * The default formatter for the caption.
245
+ */
246
+ function formatCaption(month, options) {
247
+ return dateFns.format(month, 'LLLL y', options);
248
+ }
249
+
250
+ /**
251
+ * The default formatter for the Day button.
252
+ */
253
+ function formatDay(day, options) {
254
+ return dateFns.format(day, 'd', options);
255
+ }
256
+
257
+ /**
258
+ * The default formatter for the Month caption.
259
+ */
260
+ function formatMonthCaption(month, options) {
261
+ return dateFns.format(month, 'LLLL', options);
262
+ }
263
+
264
+ /**
265
+ * The default formatter for the week number.
266
+ */
267
+ function formatWeekNumber(weekNumber) {
268
+ return "".concat(weekNumber);
269
+ }
270
+
271
+ /**
272
+ * The default formatter for the name of the weekday.
273
+ */
274
+ function formatWeekdayName(weekday, options) {
275
+ return dateFns.format(weekday, 'cccccc', options);
276
+ }
277
+
278
+ /**
279
+ * The default formatter for the Year caption.
280
+ */
281
+ function formatYearCaption(year, options) {
282
+ return dateFns.format(year, 'yyyy', options);
283
+ }
284
+
285
+ var formatters = /*#__PURE__*/Object.freeze({
286
+ __proto__: null,
287
+ formatCaption: formatCaption,
288
+ formatDay: formatDay,
289
+ formatMonthCaption: formatMonthCaption,
290
+ formatWeekNumber: formatWeekNumber,
291
+ formatWeekdayName: formatWeekdayName,
292
+ formatYearCaption: formatYearCaption
293
+ });
294
+
295
+ /**
296
+ * The default ARIA label for the day button.
297
+ */
298
+ var labelDay = function (day, activeModifiers, options) {
299
+ return dateFns.format(day, 'do MMMM (EEEE)', options);
300
+ };
301
+
302
+ /**
303
+ * The default ARIA label for the WeekNumber element.
304
+ */
305
+ var labelMonthDropdown = function () {
306
+ return 'Month: ';
307
+ };
308
+
309
+ /**
310
+ * The default ARIA label for next month button in navigation
311
+ */
312
+ var labelNext = function () {
313
+ return 'Go to next month';
314
+ };
315
+
316
+ /**
317
+ * The default ARIA label for previous month button in navigation
318
+ */
319
+ var labelPrevious = function () {
320
+ return 'Go to previous month';
321
+ };
322
+
323
+ /**
324
+ * The default ARIA label for the Weekday element.
325
+ */
326
+ var labelWeekday = function (day, options) {
327
+ return dateFns.format(day, 'cccc', options);
328
+ };
329
+
330
+ /**
331
+ * The default ARIA label for the WeekNumber element.
332
+ */
333
+ var labelWeekNumber = function (n) {
334
+ return "Week n. ".concat(n);
335
+ };
336
+
337
+ /**
338
+ * The default ARIA label for the WeekNumber element.
339
+ */
340
+ var labelYearDropdown = function () {
341
+ return 'Year: ';
342
+ };
343
+
344
+ var labels = /*#__PURE__*/Object.freeze({
345
+ __proto__: null,
346
+ labelDay: labelDay,
347
+ labelMonthDropdown: labelMonthDropdown,
348
+ labelNext: labelNext,
349
+ labelPrevious: labelPrevious,
350
+ labelWeekday: labelWeekday,
351
+ labelWeekNumber: labelWeekNumber,
352
+ labelYearDropdown: labelYearDropdown
353
+ });
354
+
355
+ /**
356
+ * Returns the default values to use in the DayPickerContext, in case they are
357
+ * not passed down with the DayPicker initial props.
358
+ */
359
+ function getDefaultContextValue() {
360
+ var captionLayout = 'buttons';
361
+ var classNames = defaultClassNames;
362
+ var locale = enUS__default["default"];
363
+ var modifiersClassNames = {};
364
+ var modifierPrefix = 'rdp-day_';
365
+ var modifiers = {};
366
+ var numberOfMonths = 1;
367
+ var styles = {};
368
+ var today = new Date();
369
+ return {
370
+ captionLayout: captionLayout,
371
+ classNames: classNames,
372
+ formatters: formatters,
373
+ labels: labels,
374
+ locale: locale,
375
+ modifiersClassNames: modifiersClassNames,
376
+ modifierPrefix: modifierPrefix,
377
+ modifiers: modifiers,
378
+ numberOfMonths: numberOfMonths,
379
+ styles: styles,
380
+ today: today
381
+ };
382
+ }
383
+
384
+ /** Return the `fromDate` and `toDate` prop values values parsing the DayPicker props. */
385
+ function parseFromToProps(props) {
386
+ var fromYear = props.fromYear, toYear = props.toYear, fromMonth = props.fromMonth, toMonth = props.toMonth;
387
+ var fromDate = props.fromDate, toDate = props.toDate;
388
+ if (fromMonth) {
389
+ fromDate = dateFns.startOfMonth(fromMonth);
390
+ }
391
+ else if (fromYear) {
392
+ fromDate = new Date(fromYear, 0, 1);
393
+ }
394
+ if (toMonth) {
395
+ toDate = dateFns.startOfMonth(toMonth);
396
+ }
397
+ else if (toYear) {
398
+ toDate = new Date(toYear, 11, 31);
399
+ }
400
+ return {
401
+ fromDate: fromDate ? dateFns.startOfDay(fromDate) : undefined,
402
+ toDate: toDate ? dateFns.startOfDay(toDate) : undefined
403
+ };
404
+ }
405
+
406
+ /**
407
+ * The DayPicker Context shares the props passed to DayPicker within internal
408
+ * and custom components. It is used to set the default values and perform
409
+ * one-time calculations required to render the days.
410
+ *
411
+ * Developers may access this context from the [[useDayPicker]] hook when
412
+ * using custom components.
413
+ */
414
+ var DayPickerContext = React.createContext(undefined);
415
+ /**
416
+ * The provider for the [[DayPickerContext]], assigning the defaults from the
417
+ * initial DayPicker props.
418
+ */
419
+ function DayPickerProvider(props) {
420
+ var _a, _b, _c, _d, _e;
421
+ var initialProps = props.initialProps;
422
+ var defaults = getDefaultContextValue();
423
+ var locale = (_a = initialProps.locale) !== null && _a !== void 0 ? _a : defaults.locale;
424
+ var numberOfMonths = (_b = initialProps.numberOfMonths) !== null && _b !== void 0 ? _b : defaults.numberOfMonths;
425
+ var today = (_c = initialProps.today) !== null && _c !== void 0 ? _c : defaults.today;
426
+ var _f = parseFromToProps(initialProps), fromDate = _f.fromDate, toDate = _f.toDate;
427
+ var captionLayout = (_d = initialProps.captionLayout) !== null && _d !== void 0 ? _d : defaults.captionLayout;
428
+ if (captionLayout !== 'buttons' && (!fromDate || !toDate)) {
429
+ captionLayout = 'buttons';
430
+ }
431
+ // TODO: remove eslint disable, move to external utils
432
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
433
+ initialProps.toYear; initialProps.fromYear; initialProps.toMonth; initialProps.fromMonth; var contextProps = __rest(initialProps, ["toYear", "fromYear", "toMonth", "fromMonth"]);
434
+ var modifierPrefix = (_e = initialProps.modifierPrefix) !== null && _e !== void 0 ? _e : defaults.modifierPrefix;
435
+ var modifiers = __assign(__assign({}, defaults.modifiers), initialProps.modifiers);
436
+ var modifiersClassNames = __assign(__assign({}, defaults.modifiersClassNames), initialProps.modifiersClassNames);
437
+ var styles = __assign(__assign({}, defaults.styles), initialProps.styles);
438
+ var classNames = __assign(__assign({}, defaults.classNames), initialProps.classNames);
439
+ var formatters = __assign(__assign({}, defaults.formatters), initialProps.formatters);
440
+ var labels = __assign(__assign({}, defaults.labels), initialProps.labels);
441
+ var components = __assign(__assign({}, defaults.components), initialProps.components);
442
+ var context = __assign(__assign({}, contextProps), { captionLayout: captionLayout, fromDate: fromDate, toDate: toDate, today: today, locale: locale, modifiersClassNames: modifiersClassNames, modifierPrefix: modifierPrefix, modifiers: modifiers, numberOfMonths: numberOfMonths, styles: styles, classNames: classNames, formatters: formatters, labels: labels, components: components });
443
+ return (React__default["default"].createElement(DayPickerContext.Provider, { value: context }, props.children));
444
+ }
445
+
446
+ /**
447
+ * Hook to access the [[DayPickerContext]].
448
+ *
449
+ * To use this hook make sure to wrap the components with a one
450
+ * [[DayPickerProvider]].
451
+ */
452
+ function useDayPicker() {
453
+ var context = React.useContext(DayPickerContext);
454
+ if (!context) {
455
+ throw new Error("useDayPicker must be used within a DayPickerProvider.");
456
+ }
457
+ return context;
458
+ }
459
+
460
+ /** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
461
+ function CaptionLabel(props) {
462
+ var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, formatCaption = _a.formatters.formatCaption;
463
+ return (React__default["default"].createElement("h2", { className: classNames.caption_label, style: styles.caption_label, "aria-live": "polite", "aria-atomic": "true", id: props.id }, formatCaption(props.displayMonth, { locale: locale })));
464
+ }
465
+
466
+ /**
467
+ * Render the icon in the styled drop-down.
468
+ */
469
+ function IconDropdown(props) {
470
+ return (React__default["default"].createElement("svg", __assign({ width: "8px", height: "8px", viewBox: "0 0 120 120", "data-testid": "iconDropdown" }, props),
471
+ React__default["default"].createElement("path", { d: "M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z", fill: "currentColor", fillRule: "nonzero" })));
472
+ }
473
+
474
+ /**
475
+ * Render a styled select component – displaying a caption and a custom
476
+ * drop-down icon.
477
+ */
478
+ function Dropdown(props) {
479
+ var _a, _b;
480
+ var onChange = props.onChange, value = props.value, children = props.children, caption = props.caption, className = props.className, style = props.style;
481
+ var dayPicker = useDayPicker();
482
+ var IconDropdownComponent = (_b = (_a = dayPicker.components) === null || _a === void 0 ? void 0 : _a.IconDropdown) !== null && _b !== void 0 ? _b : IconDropdown;
483
+ return (React__default["default"].createElement("div", { className: className, style: style },
484
+ React__default["default"].createElement("span", { className: dayPicker.classNames.vhidden }, props['aria-label']),
485
+ React__default["default"].createElement("select", { "aria-label": props['aria-label'], className: dayPicker.classNames.dropdown, style: dayPicker.styles.dropdown, value: value, onChange: onChange }, children),
486
+ React__default["default"].createElement("div", { className: dayPicker.classNames.caption_label, style: dayPicker.styles.caption_label, "aria-hidden": "true" },
487
+ caption,
488
+ React__default["default"].createElement(IconDropdownComponent, { className: dayPicker.classNames.dropdown_icon, style: dayPicker.styles.dropdown_icon }))));
489
+ }
490
+
491
+ /** Render the dropdown to navigate between months. */
492
+ function MonthsDropdown(props) {
493
+ var _a;
494
+ var _b = useDayPicker(), fromDate = _b.fromDate, toDate = _b.toDate, styles = _b.styles, locale = _b.locale, formatMonthCaption = _b.formatters.formatMonthCaption, classNames = _b.classNames, components = _b.components, labelMonthDropdown = _b.labels.labelMonthDropdown;
495
+ // Dropdown should appear only when both from/toDate is set
496
+ if (!fromDate)
497
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
498
+ if (!toDate)
499
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
500
+ var dropdownMonths = [];
501
+ if (dateFns.isSameYear(fromDate, toDate)) {
502
+ // only display the months included in the range
503
+ var date = dateFns.startOfMonth(fromDate);
504
+ for (var month = fromDate.getMonth(); month <= toDate.getMonth(); month++) {
505
+ dropdownMonths.push(dateFns.setMonth(date, month));
506
+ }
507
+ }
508
+ else {
509
+ // display all the 12 months
510
+ var date = dateFns.startOfMonth(new Date()); // Any date should be OK, as we just need the year
511
+ for (var month = 0; month <= 11; month++) {
512
+ dropdownMonths.push(dateFns.setMonth(date, month));
513
+ }
514
+ }
515
+ var handleChange = function (e) {
516
+ var selectedMonth = Number(e.target.value);
517
+ var newMonth = dateFns.setMonth(dateFns.startOfMonth(props.displayMonth), selectedMonth);
518
+ props.onChange(newMonth);
519
+ };
520
+ var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
521
+ return (React__default["default"].createElement(DropdownComponent, { "aria-label": labelMonthDropdown(), className: classNames.dropdown_month, style: styles.dropdown_month, onChange: handleChange, value: props.displayMonth.getMonth(), caption: formatMonthCaption(props.displayMonth, { locale: locale }) }, dropdownMonths.map(function (m) { return (React__default["default"].createElement("option", { key: m.getMonth(), value: m.getMonth() }, formatMonthCaption(m, { locale: locale }))); })));
522
+ }
523
+
524
+ /**
525
+ * Render the "previous month" button in the navigation.
526
+ */
527
+ function IconLeft(props) {
528
+ return (React__default["default"].createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
529
+ React__default["default"].createElement("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" })));
530
+ }
531
+
532
+ /**
533
+ * Render the "next month" button in the navigation.
534
+ */
535
+ function IconRight(props) {
536
+ return (React__default["default"].createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
537
+ React__default["default"].createElement("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" })));
538
+ }
539
+
540
+ /**
541
+ * Render a button HTML element applying the reset class name.
542
+ */
543
+ var Button = React.forwardRef(function (props, ref) {
544
+ var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles;
545
+ var classNamesArr = [classNames.button_reset, classNames.button];
546
+ if (props.className) {
547
+ classNamesArr.push(props.className);
548
+ }
549
+ var className = classNamesArr.join(' ');
550
+ var style = __assign(__assign({}, styles.button_reset), styles.button);
551
+ if (props.style) {
552
+ Object.assign(style, props.style);
553
+ }
554
+ return (React__default["default"].createElement("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
555
+ });
556
+
557
+ /** A component rendering the navigation buttons or the drop-downs. */
558
+ function Navigation(props) {
559
+ var _a, _b;
560
+ var _c = useDayPicker(), dir = _c.dir, locale = _c.locale, classNames = _c.classNames, styles = _c.styles, _d = _c.labels, labelPrevious = _d.labelPrevious, labelNext = _d.labelNext, components = _c.components;
561
+ if (!props.nextMonth && !props.previousMonth) {
562
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
563
+ }
564
+ var previousLabel = labelPrevious(props.previousMonth, { locale: locale });
565
+ var previousClassName = [
566
+ classNames.nav_button,
567
+ classNames.nav_button_previous
568
+ ].join(' ');
569
+ var nextLabel = labelNext(props.nextMonth, { locale: locale });
570
+ var nextClassName = [
571
+ classNames.nav_button,
572
+ classNames.nav_button_next
573
+ ].join(' ');
574
+ var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
575
+ var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
576
+ return (React__default["default"].createElement("div", { className: classNames.nav, style: styles.nav },
577
+ !props.hidePrevious && (React__default["default"].createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React__default["default"].createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default["default"].createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
578
+ !props.hideNext && (React__default["default"].createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React__default["default"].createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default["default"].createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
579
+ }
580
+
581
+ /**
582
+ * Render a dropdown to change the year. Take in account the `nav.fromDate` and
583
+ * `toDate` from context.
584
+ */
585
+ function YearsDropdown(props) {
586
+ var _a;
587
+ var displayMonth = props.displayMonth;
588
+ var _b = useDayPicker(), fromDate = _b.fromDate, toDate = _b.toDate, locale = _b.locale, styles = _b.styles, classNames = _b.classNames, components = _b.components, formatYearCaption = _b.formatters.formatYearCaption, labelYearDropdown = _b.labels.labelYearDropdown;
589
+ var years = [];
590
+ // Dropdown should appear only when both from/toDate is set
591
+ if (!fromDate)
592
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
593
+ if (!toDate)
594
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
595
+ var fromYear = fromDate.getFullYear();
596
+ var toYear = toDate.getFullYear();
597
+ for (var year = fromYear; year <= toYear; year++) {
598
+ years.push(dateFns.setYear(dateFns.startOfYear(new Date()), year));
599
+ }
600
+ var handleChange = function (e) {
601
+ var newMonth = dateFns.setYear(dateFns.startOfMonth(displayMonth), Number(e.target.value));
602
+ props.onChange(newMonth);
603
+ };
604
+ var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
605
+ return (React__default["default"].createElement(DropdownComponent, { "aria-label": labelYearDropdown(), className: classNames.dropdown_month, style: styles.dropdown_month, onChange: handleChange, value: displayMonth.getFullYear(), caption: formatYearCaption(displayMonth, { locale: locale }) }, years.map(function (year) { return (React__default["default"].createElement("option", { key: year.getFullYear(), value: year.getFullYear() }, formatYearCaption(year, { locale: locale }))); })));
606
+ }
607
+
608
+ /**
609
+ * Helper hook for using controlled/uncontrolled values from a component props.
610
+ *
611
+ * When the value is not controlled, pass `undefined` as `controlledValue` and
612
+ * use the returned setter to update it.
613
+ *
614
+ * When the value is controlled, pass the controlled value as second
615
+ * argument, which will be always returned as `value`.
616
+ */
617
+ function useControlledValue(defaultValue, controlledValue) {
618
+ var _a = React.useState(defaultValue), uncontrolledValue = _a[0], setValue = _a[1];
619
+ var value = controlledValue === undefined ? uncontrolledValue : controlledValue;
620
+ return [value, setValue];
621
+ }
622
+
623
+ /** Return the initial month according to the given options. */
624
+ function getInitialMonth(context) {
625
+ var month = context.month, defaultMonth = context.defaultMonth, today = context.today;
626
+ var initialMonth = month || defaultMonth || today || new Date();
627
+ var toDate = context.toDate, fromDate = context.fromDate, _a = context.numberOfMonths, numberOfMonths = _a === void 0 ? 1 : _a;
628
+ // Fix the initialMonth if is after the to-date
629
+ if (toDate && dateFns.differenceInCalendarMonths(toDate, initialMonth) < 0) {
630
+ var offset = -1 * (numberOfMonths - 1);
631
+ initialMonth = dateFns.addMonths(toDate, offset);
632
+ }
633
+ // Fix the initialMonth if is before the from-date
634
+ if (fromDate && dateFns.differenceInCalendarMonths(initialMonth, fromDate) < 0) {
635
+ initialMonth = fromDate;
636
+ }
637
+ return dateFns.startOfMonth(initialMonth);
638
+ }
639
+
640
+ /** Controls the navigation state. */
641
+ function useNavigationState() {
642
+ var context = useDayPicker();
643
+ var initialMonth = getInitialMonth(context);
644
+ var _a = useControlledValue(initialMonth, context.month), month = _a[0], setMonth = _a[1];
645
+ var goToMonth = function (date) {
646
+ if (context.disableNavigation)
647
+ return;
648
+ setMonth(dateFns.startOfMonth(date));
649
+ };
650
+ return [month, goToMonth];
651
+ }
652
+
653
+ /**
654
+ * Return the months to display in the component according to the number of
655
+ * months and the from/to date.
656
+ */
657
+ function getDisplayMonths(month, _a) {
658
+ var reverseMonths = _a.reverseMonths, numberOfMonths = _a.numberOfMonths;
659
+ var start = dateFns.startOfMonth(month);
660
+ var end = dateFns.startOfMonth(dateFns.addMonths(start, numberOfMonths));
661
+ var monthsDiff = dateFns.differenceInCalendarMonths(end, start);
662
+ var months = [];
663
+ for (var i = 0; i < monthsDiff; i++) {
664
+ var nextMonth = dateFns.addMonths(start, i);
665
+ months.push(nextMonth);
666
+ }
667
+ if (reverseMonths)
668
+ months = months.reverse();
669
+ return months;
670
+ }
671
+
672
+ /**
673
+ * Returns the next month the user can navigate to according to the given
674
+ * options.
675
+ *
676
+ * Please note that the next month is not always the next calendar month:
677
+ *
678
+ * - if after the `toDate` range, is undefined;
679
+ * - if the navigation is paged, is the number of months displayed ahead.
680
+ *
681
+ */
682
+ function getNextMonth(startingMonth, options) {
683
+ if (options.disableNavigation) {
684
+ return undefined;
685
+ }
686
+ var toDate = options.toDate, pagedNavigation = options.pagedNavigation, _a = options.numberOfMonths, numberOfMonths = _a === void 0 ? 1 : _a;
687
+ var offset = pagedNavigation ? numberOfMonths : 1;
688
+ var month = dateFns.startOfMonth(startingMonth);
689
+ if (!toDate) {
690
+ return dateFns.addMonths(month, offset);
691
+ }
692
+ var monthsDiff = dateFns.differenceInCalendarMonths(toDate, startingMonth);
693
+ if (monthsDiff < numberOfMonths) {
694
+ return undefined;
695
+ }
696
+ // Jump forward as the number of months when paged navigation
697
+ return dateFns.addMonths(month, offset);
698
+ }
699
+
700
+ /**
701
+ * Returns the next previous the user can navigate to, according to the given
702
+ * options.
703
+ *
704
+ * Please note that the previous month is not always the previous calendar
705
+ * month:
706
+ *
707
+ * - if before the `fromDate` date, is `undefined`;
708
+ * - if the navigation is paged, is the number of months displayed before.
709
+ *
710
+ */
711
+ function getPreviousMonth(startingMonth, options) {
712
+ if (options.disableNavigation) {
713
+ return undefined;
714
+ }
715
+ var fromDate = options.fromDate, pagedNavigation = options.pagedNavigation, _a = options.numberOfMonths, numberOfMonths = _a === void 0 ? 1 : _a;
716
+ var offset = pagedNavigation ? numberOfMonths : 1;
717
+ var month = dateFns.startOfMonth(startingMonth);
718
+ if (!fromDate) {
719
+ return dateFns.addMonths(month, -offset);
720
+ }
721
+ var monthsDiff = dateFns.differenceInCalendarMonths(month, fromDate);
722
+ if (monthsDiff <= 0) {
723
+ return undefined;
724
+ }
725
+ // Jump back as the number of months when paged navigation
726
+ return dateFns.addMonths(month, -offset);
727
+ }
728
+
729
+ /**
730
+ * The Navigation context shares details about the months being navigated in DayPicker.
731
+ *
732
+ * Access this context from the [[useNavigation]] hook.
733
+ */
734
+ var NavigationContext = React.createContext(undefined);
735
+ /** Provides the values for the [[NavigationContext]]. */
736
+ function NavigationProvider(props) {
737
+ var dayPicker = useDayPicker();
738
+ var _a = useNavigationState(), currentMonth = _a[0], goToMonth = _a[1];
739
+ var displayMonths = getDisplayMonths(currentMonth, dayPicker);
740
+ var nextMonth = getNextMonth(currentMonth, dayPicker);
741
+ var previousMonth = getPreviousMonth(currentMonth, dayPicker);
742
+ var isDateDisplayed = function (date) {
743
+ return displayMonths.some(function (displayMonth) {
744
+ return dateFns.isSameMonth(date, displayMonth);
745
+ });
746
+ };
747
+ var goToDate = function (date, refDate) {
748
+ if (isDateDisplayed(date)) {
749
+ return;
750
+ }
751
+ if (refDate && dateFns.isBefore(date, refDate)) {
752
+ goToMonth(dateFns.addMonths(date, 1 + dayPicker.numberOfMonths * -1));
753
+ }
754
+ else {
755
+ goToMonth(date);
756
+ }
757
+ };
758
+ var value = {
759
+ currentMonth: currentMonth,
760
+ displayMonths: displayMonths,
761
+ goToMonth: goToMonth,
762
+ goToDate: goToDate,
763
+ previousMonth: previousMonth,
764
+ nextMonth: nextMonth,
765
+ isDateDisplayed: isDateDisplayed
766
+ };
767
+ return (React__default["default"].createElement(NavigationContext.Provider, { value: value }, props.children));
768
+ }
769
+
770
+ /** Hook to access the [[NavigationContext]]. */
771
+ function useNavigation() {
772
+ var context = React.useContext(NavigationContext);
773
+ if (!context) {
774
+ throw new Error('useNavigation must be used within a NavigationProvider');
775
+ }
776
+ return context;
777
+ }
778
+
779
+ /**
780
+ * Render the caption of a month, which includes title and navigation buttons.
781
+ * The caption has a different layout when setting the [[DayPickerProps.captionLayout]] prop.
782
+ */
783
+ function Caption(props) {
784
+ var _a;
785
+ var _b;
786
+ var _c = useDayPicker(), classNames = _c.classNames, numberOfMonths = _c.numberOfMonths, disableNavigation = _c.disableNavigation, styles = _c.styles, captionLayout = _c.captionLayout, onMonthChange = _c.onMonthChange, dir = _c.dir, components = _c.components;
787
+ var _d = useNavigation(), previousMonth = _d.previousMonth, nextMonth = _d.nextMonth, goToMonth = _d.goToMonth, displayMonths = _d.displayMonths;
788
+ var handlePreviousClick = function () {
789
+ if (!previousMonth)
790
+ return;
791
+ goToMonth(previousMonth);
792
+ onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(previousMonth);
793
+ };
794
+ var handleNextClick = function () {
795
+ if (!nextMonth)
796
+ return;
797
+ goToMonth(nextMonth);
798
+ onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(nextMonth);
799
+ };
800
+ var handleMonthChange = function (newMonth) {
801
+ goToMonth(newMonth);
802
+ onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(newMonth);
803
+ };
804
+ var displayIndex = displayMonths.findIndex(function (month) {
805
+ return dateFns.isSameMonth(props.displayMonth, month);
806
+ });
807
+ var isFirst = displayIndex === 0;
808
+ var isLast = displayIndex === displayMonths.length - 1;
809
+ if (dir === 'rtl') {
810
+ _a = [isFirst, isLast], isLast = _a[0], isFirst = _a[1];
811
+ }
812
+ var hideNext = numberOfMonths > 1 && (isFirst || !isLast);
813
+ var hidePrevious = numberOfMonths > 1 && (isLast || !isFirst);
814
+ var CaptionLabelComponent = (_b = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _b !== void 0 ? _b : CaptionLabel;
815
+ var captionLabel = (React__default["default"].createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
816
+ var captionContent;
817
+ if (disableNavigation) {
818
+ captionContent = captionLabel;
819
+ }
820
+ else if (captionLayout === 'dropdown') {
821
+ captionContent = (React__default["default"].createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
822
+ React__default["default"].createElement("div", { className: classNames.vhidden }, captionLabel),
823
+ React__default["default"].createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
824
+ React__default["default"].createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
825
+ }
826
+ else {
827
+ captionContent = (React__default["default"].createElement(React__default["default"].Fragment, null,
828
+ captionLabel,
829
+ React__default["default"].createElement(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })));
830
+ }
831
+ return (React__default["default"].createElement("div", { className: classNames.caption, style: styles.caption }, captionContent));
832
+ }
833
+
834
+ /** Render the Footer component (empty as default).*/
835
+ function Footer() {
836
+ var _a = useDayPicker(), footer = _a.footer, styles = _a.styles, tfoot = _a.classNames.tfoot;
837
+ if (!footer)
838
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
839
+ return (React__default["default"].createElement("tfoot", { className: tfoot, style: styles.tfoot },
840
+ React__default["default"].createElement("tr", null,
841
+ React__default["default"].createElement("td", { colSpan: 8 }, footer))));
842
+ }
843
+
844
+ /**
845
+ * Generate a series of 7 days, starting from the week, to use for formatting
846
+ * the weekday names (Monday, Tuesday, etc.).
847
+ */
848
+ function getWeekdays(locale) {
849
+ var start = dateFns.startOfWeek(new Date(), { locale: locale });
850
+ var days = [];
851
+ for (var i = 0; i < 7; i++) {
852
+ var day = dateFns.addDays(start, i);
853
+ days.push(day);
854
+ }
855
+ return days;
856
+ }
857
+
858
+ /**
859
+ * Render the Head component - i.e. the table head with the weekday names.
860
+ */
861
+ function Head() {
862
+ var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
863
+ var weekdays = getWeekdays(locale);
864
+ return (React__default["default"].createElement("thead", { style: styles.head, className: classNames.head },
865
+ React__default["default"].createElement("tr", { style: styles.head_row, className: classNames.head_row },
866
+ showWeekNumber && (React__default["default"].createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
867
+ weekdays.map(function (weekday, i) { return (React__default["default"].createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell },
868
+ React__default["default"].createElement("span", { "aria-hidden": true }, formatWeekdayName(weekday, { locale: locale })),
869
+ React__default["default"].createElement("span", { className: classNames.vhidden }, labelWeekday(weekday, { locale: locale })))); }))));
870
+ }
871
+
872
+ /**
873
+ * Render the content of the day cell.
874
+ */
875
+ function DayContent(props) {
876
+ var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, labelDay = _a.labels.labelDay, formatDay = _a.formatters.formatDay;
877
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
878
+ React__default["default"].createElement("span", { "aria-hidden": "true" }, formatDay(props.date, { locale: locale })),
879
+ React__default["default"].createElement("span", { className: classNames.vhidden, style: styles.vhidden }, labelDay(props.date, props.activeModifiers, { locale: locale }))));
880
+ }
881
+
882
+ /** Returns true when the props are of type [[DayPickerMultiple]]. */
883
+ function isDayPickerMultiple(props) {
884
+ return props.mode === 'multiple';
885
+ }
886
+
887
+ /**
888
+ * The SelectMultiple context shares details about the selected days when in
889
+ * multiple selection mode.
890
+ *
891
+ * Access this context from the [[useSelectMultiple]] hook.
892
+ */
893
+ var SelectMultipleContext = React.createContext(undefined);
894
+ /** Provides the values for the [[SelectMultipleContext]]. */
895
+ function SelectMultipleProvider(props) {
896
+ if (!isDayPickerMultiple(props.initialProps)) {
897
+ var emptyContextValue = {
898
+ selected: undefined,
899
+ modifiers: {
900
+ disabled: []
901
+ }
902
+ };
903
+ return (React__default["default"].createElement(SelectMultipleContext.Provider, { value: emptyContextValue }, props.children));
904
+ }
905
+ return (React__default["default"].createElement(SelectMultipleProviderInternal, { initialProps: props.initialProps, children: props.children }));
906
+ }
907
+ function SelectMultipleProviderInternal(_a) {
908
+ var initialProps = _a.initialProps, children = _a.children;
909
+ var selected = initialProps.selected, min = initialProps.min, max = initialProps.max;
910
+ var onDayClick = function (day, activeModifiers, e) {
911
+ var _a, _b;
912
+ (_a = initialProps.onDayClick) === null || _a === void 0 ? void 0 : _a.call(initialProps, day, activeModifiers, e);
913
+ var isMinSelected = Boolean(activeModifiers.selected && min && (selected === null || selected === void 0 ? void 0 : selected.length) === min);
914
+ if (isMinSelected) {
915
+ return;
916
+ }
917
+ var isMaxSelected = Boolean(!activeModifiers.selected && max && (selected === null || selected === void 0 ? void 0 : selected.length) === max);
918
+ if (isMaxSelected) {
919
+ return;
920
+ }
921
+ var selectedDays = selected ? __spreadArray([], selected, true) : [];
922
+ if (activeModifiers.selected) {
923
+ var index = selectedDays.findIndex(function (selectedDay) {
924
+ return dateFns.isSameDay(day, selectedDay);
925
+ });
926
+ selectedDays.splice(index, 1);
927
+ }
928
+ else {
929
+ selectedDays.push(day);
930
+ }
931
+ (_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, selectedDays, day, activeModifiers, e);
932
+ };
933
+ var modifiers = {
934
+ disabled: []
935
+ };
936
+ if (selected) {
937
+ modifiers.disabled.push(function (day) {
938
+ var isMaxSelected = max && selected.length > max - 1;
939
+ var isSelected = selected.some(function (selectedDay) {
940
+ return dateFns.isSameDay(selectedDay, day);
941
+ });
942
+ return Boolean(isMaxSelected && !isSelected);
943
+ });
944
+ }
945
+ var contextValue = {
946
+ selected: selected,
947
+ onDayClick: onDayClick,
948
+ modifiers: modifiers
949
+ };
950
+ return (React__default["default"].createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
951
+ }
952
+
953
+ /** Hook to access the [[SelectMultipleContext]]. */
954
+ function useSelectMultiple() {
955
+ var context = React.useContext(SelectMultipleContext);
956
+ if (!context) {
957
+ throw new Error('useSelectMultiple must be used within a SelectMultipleProvider');
958
+ }
959
+ return context;
960
+ }
961
+
962
+ /** Returns true when the props are of type [[DayPickerRange]]. */
963
+ function isDayPickerRange(props) {
964
+ return props.mode === 'range';
965
+ }
966
+
967
+ /**
968
+ * Add a day to an existing range.
969
+ *
970
+ * The returned range takes in account the `undefined` values and if the added
971
+ * day is already present in the range.
972
+ */
973
+ function addToRange(day, range) {
974
+ var _a = range || {}, from = _a.from, to = _a.to;
975
+ if (!from) {
976
+ return { from: day, to: day };
977
+ }
978
+ if (!to && dateFns.isSameDay(from, day)) {
979
+ return undefined;
980
+ }
981
+ if (!to && dateFns.isBefore(day, from)) {
982
+ return { from: day, to: from };
983
+ }
984
+ if (!to) {
985
+ return { from: from, to: day };
986
+ }
987
+ if (dateFns.isSameDay(to, day) && dateFns.isSameDay(from, day)) {
988
+ return undefined;
989
+ }
990
+ if (dateFns.isSameDay(to, day)) {
991
+ return { from: to, to: to };
992
+ }
993
+ if (dateFns.isSameDay(from, day)) {
994
+ return undefined;
995
+ }
996
+ if (dateFns.isAfter(from, day)) {
997
+ return { from: day, to: to };
998
+ }
999
+ return { from: from, to: day };
1000
+ }
1001
+
1002
+ /**
1003
+ * The SelectRange context shares details about the selected days when in
1004
+ * range selection mode.
1005
+ *
1006
+ * Access this context from the [[useSelectRange]] hook.
1007
+ */
1008
+ var SelectRangeContext = React.createContext(undefined);
1009
+ /** Provides the values for the [[SelectRangeProvider]]. */
1010
+ function SelectRangeProvider(props) {
1011
+ if (!isDayPickerRange(props.initialProps)) {
1012
+ var emptyContextValue = {
1013
+ selected: undefined,
1014
+ modifiers: {
1015
+ range_start: [],
1016
+ range_end: [],
1017
+ range_middle: [],
1018
+ disabled: []
1019
+ }
1020
+ };
1021
+ return (React__default["default"].createElement(SelectRangeContext.Provider, { value: emptyContextValue }, props.children));
1022
+ }
1023
+ return (React__default["default"].createElement(SelectRangeProviderInternal, { initialProps: props.initialProps, children: props.children }));
1024
+ }
1025
+ function SelectRangeProviderInternal(_a) {
1026
+ var initialProps = _a.initialProps, children = _a.children;
1027
+ var selected = initialProps.selected;
1028
+ var _b = selected || {}, selectedFrom = _b.from, selectedTo = _b.to;
1029
+ var min = initialProps.min;
1030
+ var max = initialProps.max;
1031
+ var onDayClick = function (day, activeModifiers, e) {
1032
+ var _a, _b;
1033
+ (_a = initialProps.onDayClick) === null || _a === void 0 ? void 0 : _a.call(initialProps, day, activeModifiers, e);
1034
+ var range = addToRange(day, selected);
1035
+ if ((min || max) &&
1036
+ selected &&
1037
+ (range === null || range === void 0 ? void 0 : range.to) &&
1038
+ range.from &&
1039
+ range.from !== range.to) {
1040
+ var diff = Math.abs(dateFns.differenceInCalendarDays(range === null || range === void 0 ? void 0 : range.to, range === null || range === void 0 ? void 0 : range.from));
1041
+ if ((min && diff < min) || (max && diff >= max)) {
1042
+ return;
1043
+ }
1044
+ }
1045
+ (_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, range, day, activeModifiers, e);
1046
+ };
1047
+ var modifiers = {
1048
+ range_start: [],
1049
+ range_end: [],
1050
+ range_middle: [],
1051
+ disabled: []
1052
+ };
1053
+ if (selectedFrom) {
1054
+ modifiers.range_start = [selectedFrom];
1055
+ if (!selectedTo) {
1056
+ modifiers.range_end = [selectedFrom];
1057
+ }
1058
+ else {
1059
+ modifiers.range_end = [selectedTo];
1060
+ modifiers.range_middle = [
1061
+ {
1062
+ after: selectedFrom,
1063
+ before: selectedTo
1064
+ }
1065
+ ];
1066
+ }
1067
+ }
1068
+ if (min && selectedFrom && selectedTo) {
1069
+ modifiers.disabled.push(function (date) {
1070
+ return ((dateFns.isBefore(date, selectedFrom) &&
1071
+ dateFns.differenceInCalendarDays(selectedFrom, date) < min) ||
1072
+ (dateFns.isAfter(date, selectedTo) &&
1073
+ dateFns.differenceInCalendarDays(date, selectedFrom) < min));
1074
+ });
1075
+ }
1076
+ if (max && selectedFrom && selectedTo) {
1077
+ modifiers.disabled.push(function (date) {
1078
+ return ((dateFns.isBefore(date, selectedFrom) &&
1079
+ dateFns.differenceInCalendarDays(selectedTo, date) >= max) ||
1080
+ (dateFns.isAfter(date, selectedTo) &&
1081
+ dateFns.differenceInCalendarDays(date, selectedFrom) >= max));
1082
+ });
1083
+ }
1084
+ return (React__default["default"].createElement(SelectRangeContext.Provider, { value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, children));
1085
+ }
1086
+
1087
+ /** Hook to access the [[SelectRangeContext]]. */
1088
+ function useSelectRange() {
1089
+ var context = React.useContext(SelectRangeContext);
1090
+ if (!context) {
1091
+ throw new Error('useSelectRange must be used within a SelectRangeProvider');
1092
+ }
1093
+ return context;
1094
+ }
1095
+
1096
+ /** Normalize to array a matcher input. */
1097
+ function matcherToArray(matcher) {
1098
+ if (Array.isArray(matcher)) {
1099
+ return matcher;
1100
+ }
1101
+ else if (matcher !== undefined) {
1102
+ return [matcher];
1103
+ }
1104
+ else {
1105
+ return [];
1106
+ }
1107
+ }
1108
+
1109
+ /** Create CustomModifiers from dayModifiers */
1110
+ function getCustomModifiers(dayModifiers) {
1111
+ var customModifiers = {};
1112
+ Object.entries(dayModifiers).forEach(function (_a) {
1113
+ var modifier = _a[0], matcher = _a[1];
1114
+ customModifiers[modifier] = matcherToArray(matcher);
1115
+ });
1116
+ return customModifiers;
1117
+ }
1118
+
1119
+ /** The name of the modifiers that are used internally by DayPicker. */
1120
+ exports.InternalModifier = void 0;
1121
+ (function (InternalModifier) {
1122
+ InternalModifier["Outside"] = "outside";
1123
+ /** Name of the modifier applied to the disabled days, using the `disabled` prop. */
1124
+ InternalModifier["Disabled"] = "disabled";
1125
+ /** Name of the modifier applied to the selected days using the `selected` prop). */
1126
+ InternalModifier["Selected"] = "selected";
1127
+ /** Name of the modifier applied to the hidden days using the `hidden` prop). */
1128
+ InternalModifier["Hidden"] = "hidden";
1129
+ /** Name of the modifier applied to the day specified using the `today` prop). */
1130
+ InternalModifier["Today"] = "today";
1131
+ /** The modifier applied to the day starting a selected range, when in range selection mode. */
1132
+ InternalModifier["RangeStart"] = "range_start";
1133
+ /** The modifier applied to the day ending a selected range, when in range selection mode. */
1134
+ InternalModifier["RangeEnd"] = "range_end";
1135
+ /** The modifier applied to the days between the start and the end of a selected range, when in range selection mode. */
1136
+ InternalModifier["RangeMiddle"] = "range_middle";
1137
+ })(exports.InternalModifier || (exports.InternalModifier = {}));
1138
+
1139
+ var Selected = exports.InternalModifier.Selected, Disabled = exports.InternalModifier.Disabled, Hidden = exports.InternalModifier.Hidden, Today = exports.InternalModifier.Today, RangeEnd = exports.InternalModifier.RangeEnd, RangeMiddle = exports.InternalModifier.RangeMiddle, RangeStart = exports.InternalModifier.RangeStart, Outside = exports.InternalModifier.Outside;
1140
+ /** Return the [[InternalModifiers]] from the DayPicker and select contexts. */
1141
+ function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
1142
+ var _a;
1143
+ var internalModifiers = (_a = {},
1144
+ _a[Selected] = matcherToArray(dayPicker.selected),
1145
+ _a[Disabled] = matcherToArray(dayPicker.disabled),
1146
+ _a[Hidden] = matcherToArray(dayPicker.hidden),
1147
+ _a[Today] = [dayPicker.today],
1148
+ _a[RangeEnd] = [],
1149
+ _a[RangeMiddle] = [],
1150
+ _a[RangeStart] = [],
1151
+ _a[Outside] = [],
1152
+ _a);
1153
+ if (dayPicker.fromDate) {
1154
+ internalModifiers[Disabled].push({ before: dayPicker.fromDate });
1155
+ }
1156
+ if (dayPicker.toDate) {
1157
+ internalModifiers[Disabled].push({ after: dayPicker.toDate });
1158
+ }
1159
+ if (isDayPickerMultiple(dayPicker)) {
1160
+ internalModifiers[Disabled] = internalModifiers[Disabled].concat(selectMultiple.modifiers[Disabled]);
1161
+ }
1162
+ else if (isDayPickerRange(dayPicker)) {
1163
+ internalModifiers[Disabled] = internalModifiers[Disabled].concat(selectRange.modifiers[Disabled]);
1164
+ internalModifiers[RangeStart] = selectRange.modifiers[RangeStart];
1165
+ internalModifiers[RangeMiddle] = selectRange.modifiers[RangeMiddle];
1166
+ internalModifiers[RangeEnd] = selectRange.modifiers[RangeEnd];
1167
+ }
1168
+ return internalModifiers;
1169
+ }
1170
+
1171
+ /** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use [[useModifiers]]. */
1172
+ var ModifiersContext = React.createContext(undefined);
1173
+ /** Provide the value for the [[ModifiersContext]]. */
1174
+ function ModifiersProvider(props) {
1175
+ var dayPicker = useDayPicker();
1176
+ var selectMultiple = useSelectMultiple();
1177
+ var selectRange = useSelectRange();
1178
+ var internalModifiers = getInternalModifiers(dayPicker, selectMultiple, selectRange);
1179
+ var customModifiers = getCustomModifiers(dayPicker.modifiers);
1180
+ var modifiers = __assign(__assign({}, internalModifiers), customModifiers);
1181
+ return (React__default["default"].createElement(ModifiersContext.Provider, { value: modifiers }, props.children));
1182
+ }
1183
+
1184
+ /**
1185
+ * Return the modifiers used by DayPicker.
1186
+ *
1187
+ * Requires to be wrapped into [[ModifiersProvider]]. */
1188
+ function useModifiers() {
1189
+ var context = React.useContext(ModifiersContext);
1190
+ if (!context) {
1191
+ throw new Error('useModifiers must be used within a ModifiersProvider');
1192
+ }
1193
+ return context;
1194
+ }
1195
+
1196
+ /** Returns true if `matcher` is of type [[DateInterval]]. */
1197
+ function isDateInterval(matcher) {
1198
+ return Boolean(matcher &&
1199
+ typeof matcher === 'object' &&
1200
+ 'before' in matcher &&
1201
+ 'after' in matcher);
1202
+ }
1203
+ /** Returns true if `value` is a [[DateRange]] type. */
1204
+ function isDateRange(value) {
1205
+ // TODO: Check if dates?!
1206
+ return Boolean(value && typeof value === 'object' && 'from' in value);
1207
+ }
1208
+ /** Returns true if `value` is of type [[DateAfter]]. */
1209
+ function isDateAfterType(value) {
1210
+ return Boolean(value && typeof value === 'object' && 'after' in value);
1211
+ }
1212
+ /** Returns true if `value` is of type [[DateBefore]]. */
1213
+ function isDateBeforeType(value) {
1214
+ return Boolean(value && typeof value === 'object' && 'before' in value);
1215
+ }
1216
+ /** Returns true if `value` is a [[DayOfWeek]] type. */
1217
+ function isDayOfWeekType(value) {
1218
+ return Boolean(value && typeof value === 'object' && 'dayOfWeek' in value);
1219
+ }
1220
+
1221
+ /** Return `true` whether `date` is inside `range`. */
1222
+ function isDateInRange(date, range) {
1223
+ var _a;
1224
+ var from = range.from, to = range.to;
1225
+ if (!from) {
1226
+ return false;
1227
+ }
1228
+ if (!to && dateFns.isSameDay(from, date)) {
1229
+ return true;
1230
+ }
1231
+ if (!to) {
1232
+ return false;
1233
+ }
1234
+ var isToBeforeFrom = dateFns.differenceInCalendarDays(to, from) < 0;
1235
+ if (to && isToBeforeFrom) {
1236
+ _a = [to, from], from = _a[0], to = _a[1];
1237
+ }
1238
+ return (dateFns.differenceInCalendarDays(date, from) >= 0 &&
1239
+ dateFns.differenceInCalendarDays(to, date) >= 0);
1240
+ }
1241
+
1242
+ /** Returns true if `value` is a Date type. */
1243
+ function isDateType(value) {
1244
+ return dateFns.isDate(value);
1245
+ }
1246
+ /** Returns true if `value` is an array of valid dates. */
1247
+ function isArrayOfDates(value) {
1248
+ return Array.isArray(value) && value.every(dateFns.isDate);
1249
+ }
1250
+ /**
1251
+ * Returns whether a day matches against at least one of the given Matchers.
1252
+ *
1253
+ * ```
1254
+ * const day = new Date(2022, 5, 19);
1255
+ * const matcher1: DateRange = {
1256
+ * from: new Date(2021, 12, 21),
1257
+ * to: new Date(2021, 12, 30)
1258
+ * }
1259
+ * const matcher2: DateRange = {
1260
+ * from: new Date(2022, 5, 1),
1261
+ * to: new Date(2022, 5, 23)
1262
+ * }
1263
+ *
1264
+ * const isMatch(day, [matcher1, matcher2]); // true, since day is in the matcher1 range.
1265
+ * ```
1266
+ * */
1267
+ function isMatch(day, matchers) {
1268
+ return matchers.some(function (matcher) {
1269
+ if (typeof matcher === 'boolean') {
1270
+ return matcher;
1271
+ }
1272
+ if (isDateType(matcher)) {
1273
+ return dateFns.isSameDay(day, matcher);
1274
+ }
1275
+ if (isArrayOfDates(matcher)) {
1276
+ return matcher.includes(day);
1277
+ }
1278
+ if (isDateRange(matcher)) {
1279
+ return isDateInRange(day, matcher);
1280
+ }
1281
+ if (isDayOfWeekType(matcher)) {
1282
+ return matcher.dayOfWeek.includes(day.getDay());
1283
+ }
1284
+ if (isDateInterval(matcher)) {
1285
+ var isBefore = dateFns.differenceInCalendarDays(matcher.before, day) > 0;
1286
+ var isAfter = dateFns.differenceInCalendarDays(day, matcher.after) > 0;
1287
+ return isBefore && isAfter;
1288
+ }
1289
+ if (isDateAfterType(matcher)) {
1290
+ return dateFns.differenceInCalendarDays(day, matcher.after) > 0;
1291
+ }
1292
+ if (isDateBeforeType(matcher)) {
1293
+ return dateFns.differenceInCalendarDays(matcher.before, day) > 0;
1294
+ }
1295
+ if (typeof matcher === 'function') {
1296
+ return matcher(day);
1297
+ }
1298
+ return false;
1299
+ });
1300
+ }
1301
+
1302
+ /** Return the active modifiers for the given day. */
1303
+ function getActiveModifiers(day,
1304
+ /** The modifiers to match for the given date. */
1305
+ modifiers,
1306
+ /** The month where the day is displayed, to add the "outside" modifiers. */
1307
+ displayMonth) {
1308
+ var matchedModifiers = Object.keys(modifiers).reduce(function (result, key) {
1309
+ var modifier = modifiers[key];
1310
+ if (isMatch(day, modifier)) {
1311
+ result.push(key);
1312
+ }
1313
+ return result;
1314
+ }, []);
1315
+ var activeModifiers = {};
1316
+ matchedModifiers.forEach(function (modifier) { return (activeModifiers[modifier] = true); });
1317
+ if (displayMonth && !dateFns.isSameMonth(day, displayMonth)) {
1318
+ activeModifiers.outside = true;
1319
+ }
1320
+ return activeModifiers;
1321
+ }
1322
+
1323
+ /** Returns the day that should be the target of the focus when DayPicker is rendered the first time. */
1324
+ function getInitialFocusTarget(displayMonths, modifiers) {
1325
+ var firstDayInMonth = dateFns.startOfMonth(displayMonths[0]);
1326
+ var lastDayInMonth = dateFns.endOfMonth(displayMonths[displayMonths.length - 1]);
1327
+ // TODO: cleanup code
1328
+ var firstFocusableDay;
1329
+ var today;
1330
+ var date = firstDayInMonth;
1331
+ while (date <= lastDayInMonth) {
1332
+ var activeModifiers = getActiveModifiers(date, modifiers);
1333
+ var isFocusable = !activeModifiers.disabled && !activeModifiers.hidden;
1334
+ if (!isFocusable) {
1335
+ date = dateFns.addDays(date, 1);
1336
+ continue;
1337
+ }
1338
+ if (activeModifiers.selected) {
1339
+ return date;
1340
+ }
1341
+ if (activeModifiers.today && !today) {
1342
+ today = date;
1343
+ }
1344
+ if (!firstFocusableDay) {
1345
+ firstFocusableDay = date;
1346
+ }
1347
+ date = dateFns.addDays(date, 1);
1348
+ }
1349
+ if (today) {
1350
+ return today;
1351
+ }
1352
+ else {
1353
+ return firstFocusableDay;
1354
+ }
1355
+ }
1356
+
1357
+ /**
1358
+ * The Focus context shares details about the focused day for the keyboard
1359
+ *
1360
+ * Access this context from the [[useFocus]] hook.
1361
+ */
1362
+ var FocusContext = React.createContext(undefined);
1363
+ /** The provider for the [[FocusContext]]. */
1364
+ function FocusProvider(props) {
1365
+ var navigation = useNavigation();
1366
+ var modifiers = useModifiers();
1367
+ var _a = React.useState(), focusedDay = _a[0], setFocusedDay = _a[1];
1368
+ var _b = React.useState(), lastFocused = _b[0], setLastFocused = _b[1];
1369
+ var initialFocusTarget = getInitialFocusTarget(navigation.displayMonths, modifiers);
1370
+ // TODO: cleanup and test obscure code below
1371
+ var focusTarget = (focusedDay !== null && focusedDay !== void 0 ? focusedDay : (lastFocused && navigation.isDateDisplayed(lastFocused)))
1372
+ ? lastFocused
1373
+ : initialFocusTarget;
1374
+ var blur = function () {
1375
+ setLastFocused(focusedDay);
1376
+ setFocusedDay(undefined);
1377
+ };
1378
+ var focus = function (date) {
1379
+ setFocusedDay(date);
1380
+ };
1381
+ var focusDayBefore = function () {
1382
+ if (!focusedDay)
1383
+ return;
1384
+ var before = dateFns.addDays(focusedDay, -1);
1385
+ focus(before);
1386
+ navigation.goToDate(before, focusedDay);
1387
+ };
1388
+ var focusDayAfter = function () {
1389
+ if (!focusedDay)
1390
+ return;
1391
+ var after = dateFns.addDays(focusedDay, 1);
1392
+ focus(after);
1393
+ navigation.goToDate(after, focusedDay);
1394
+ };
1395
+ var focusWeekBefore = function () {
1396
+ if (!focusedDay)
1397
+ return;
1398
+ var up = dateFns.addWeeks(focusedDay, -1);
1399
+ focus(up);
1400
+ navigation.goToDate(up, focusedDay);
1401
+ };
1402
+ var focusWeekAfter = function () {
1403
+ if (!focusedDay)
1404
+ return;
1405
+ var down = dateFns.addWeeks(focusedDay, 1);
1406
+ focus(down);
1407
+ navigation.goToDate(down, focusedDay);
1408
+ };
1409
+ var focusStartOfWeek = function () {
1410
+ if (!focusedDay)
1411
+ return;
1412
+ var dayToFocus = dateFns.startOfWeek(focusedDay);
1413
+ navigation.goToDate(dayToFocus, focusedDay);
1414
+ focus(dayToFocus);
1415
+ };
1416
+ var focusEndOfWeek = function () {
1417
+ if (!focusedDay)
1418
+ return;
1419
+ var dayToFocus = dateFns.endOfWeek(focusedDay);
1420
+ navigation.goToDate(dayToFocus, focusedDay);
1421
+ focus(dayToFocus);
1422
+ };
1423
+ var focusMonthBefore = function () {
1424
+ if (!focusedDay)
1425
+ return;
1426
+ var monthBefore = dateFns.addMonths(focusedDay, -1);
1427
+ navigation.goToDate(monthBefore, focusedDay);
1428
+ focus(monthBefore);
1429
+ };
1430
+ var focusMonthAfter = function () {
1431
+ if (!focusedDay)
1432
+ return;
1433
+ var monthAfter = dateFns.addMonths(focusedDay, 1);
1434
+ navigation.goToDate(monthAfter, focusedDay);
1435
+ focus(monthAfter);
1436
+ };
1437
+ var focusYearBefore = function () {
1438
+ if (!focusedDay)
1439
+ return;
1440
+ var yearBefore = dateFns.addYears(focusedDay, -1);
1441
+ navigation.goToDate(yearBefore, focusedDay);
1442
+ focus(yearBefore);
1443
+ };
1444
+ var focusYearAfter = function () {
1445
+ if (!focusedDay)
1446
+ return;
1447
+ var yearAfter = dateFns.addYears(focusedDay, 1);
1448
+ navigation.goToDate(yearAfter, focusedDay);
1449
+ focus(yearAfter);
1450
+ };
1451
+ var value = {
1452
+ focusedDay: focusedDay,
1453
+ focusTarget: focusTarget,
1454
+ blur: blur,
1455
+ focus: focus,
1456
+ focusDayAfter: focusDayAfter,
1457
+ focusDayBefore: focusDayBefore,
1458
+ focusWeekAfter: focusWeekAfter,
1459
+ focusWeekBefore: focusWeekBefore,
1460
+ focusMonthBefore: focusMonthBefore,
1461
+ focusMonthAfter: focusMonthAfter,
1462
+ focusYearBefore: focusYearBefore,
1463
+ focusYearAfter: focusYearAfter,
1464
+ focusStartOfWeek: focusStartOfWeek,
1465
+ focusEndOfWeek: focusEndOfWeek
1466
+ };
1467
+ return (React__default["default"].createElement(FocusContext.Provider, { value: value }, props.children));
1468
+ }
1469
+
1470
+ /** Hook to access the [[FocusContext]]. */
1471
+ function useFocusContext() {
1472
+ var context = React.useContext(FocusContext);
1473
+ if (!context) {
1474
+ throw new Error('useFocusContext must be used within a FocusProvider');
1475
+ }
1476
+ return context;
1477
+ }
1478
+
1479
+ /**
1480
+ * Return the active modifiers for the specified day.
1481
+ *
1482
+ * @param day
1483
+ * @param displayMonth The month where the date is displayed. If not the same as
1484
+ * `date`, the day is an "outside day".
1485
+ */
1486
+ function useActiveModifiers(day, displayMonth) {
1487
+ var modifiers = useModifiers();
1488
+ var activeModifiers = getActiveModifiers(day, modifiers, displayMonth);
1489
+ return activeModifiers;
1490
+ }
1491
+
1492
+ /** Returns true when the props are of type [[DayPickerSingle]]. */
1493
+ function isDayPickerSingle(props) {
1494
+ return props.mode === 'single';
1495
+ }
1496
+
1497
+ /**
1498
+ * The SelectSingle context shares details about the selected days when in
1499
+ * single selection mode.
1500
+ *
1501
+ * Access this context from the [[useSelectSingle]] hook.
1502
+ */
1503
+ var SelectSingleContext = React.createContext(undefined);
1504
+ /** Provides the values for the [[SelectSingleProvider]]. */
1505
+ function SelectSingleProvider(props) {
1506
+ if (!isDayPickerSingle(props.initialProps)) {
1507
+ var emptyContextValue = {
1508
+ selected: undefined
1509
+ };
1510
+ return (React__default["default"].createElement(SelectSingleContext.Provider, { value: emptyContextValue }, props.children));
1511
+ }
1512
+ return (React__default["default"].createElement(SelectSingleProviderInternal, { initialProps: props.initialProps, children: props.children }));
1513
+ }
1514
+ function SelectSingleProviderInternal(_a) {
1515
+ var initialProps = _a.initialProps, children = _a.children;
1516
+ var onDayClick = function (day, activeModifiers, e) {
1517
+ var _a, _b, _c;
1518
+ (_a = initialProps.onDayClick) === null || _a === void 0 ? void 0 : _a.call(initialProps, day, activeModifiers, e);
1519
+ if (activeModifiers.selected && !initialProps.required) {
1520
+ (_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, undefined, day, activeModifiers, e);
1521
+ return;
1522
+ }
1523
+ (_c = initialProps.onSelect) === null || _c === void 0 ? void 0 : _c.call(initialProps, day, day, activeModifiers, e);
1524
+ };
1525
+ var contextValue = {
1526
+ selected: initialProps.selected,
1527
+ onDayClick: onDayClick
1528
+ };
1529
+ return (React__default["default"].createElement(SelectSingleContext.Provider, { value: contextValue }, children));
1530
+ }
1531
+
1532
+ /** Hook to access the [[SelectSingleContext]]. */
1533
+ function useSelectSingle() {
1534
+ var context = React.useContext(SelectSingleContext);
1535
+ if (!context) {
1536
+ throw new Error('useSelectSingle must be used within a SelectSingleProvider');
1537
+ }
1538
+ return context;
1539
+ }
1540
+
1541
+ /**
1542
+ * This hook returns details about the content to render in the day cell.
1543
+ *
1544
+ *
1545
+ * When a day cell is rendered in the table, DayPicker can either:
1546
+ *
1547
+ * - render nothing: when the day is outside the month or has matched the
1548
+ * "hidden" modifier.
1549
+ * - render a button. When a selection mode is set, DayPicker renders a button
1550
+ * to allow the focus and the selection. In case of `custom` selection
1551
+ * mode, DayPicker expects a `onDayClick` prop to render a button.
1552
+ * - render a non-interactive element: when no selection mode is set, the day
1553
+ * cell shouldn’t respond to any interaction. DayPicker should render a `div`
1554
+ * or a `span`.
1555
+ *
1556
+ * ### Usage
1557
+ *
1558
+ * Use this hook to customize the behavior of the [[Day]] component. Create a
1559
+ * new `Day` component using this hook and pass it to the `components` prop.
1560
+ * The source of [[Day]] can be a good starting point.
1561
+ *
1562
+ */
1563
+ function useDayEventHandlers(date, activeModifiers) {
1564
+ var dayPicker = useDayPicker();
1565
+ var single = useSelectSingle();
1566
+ var multiple = useSelectMultiple();
1567
+ var range = useSelectRange();
1568
+ var _a = useFocusContext(), focusDayAfter = _a.focusDayAfter, focusDayBefore = _a.focusDayBefore, focusWeekAfter = _a.focusWeekAfter, focusWeekBefore = _a.focusWeekBefore, blur = _a.blur, focus = _a.focus, focusMonthBefore = _a.focusMonthBefore, focusMonthAfter = _a.focusMonthAfter, focusYearBefore = _a.focusYearBefore, focusYearAfter = _a.focusYearAfter, focusStartOfWeek = _a.focusStartOfWeek, focusEndOfWeek = _a.focusEndOfWeek;
1569
+ var onClick = function (e) {
1570
+ var _a, _b, _c, _d;
1571
+ if (isDayPickerSingle(dayPicker)) {
1572
+ (_a = single.onDayClick) === null || _a === void 0 ? void 0 : _a.call(single, date, activeModifiers, e);
1573
+ }
1574
+ else if (isDayPickerMultiple(dayPicker)) {
1575
+ (_b = multiple.onDayClick) === null || _b === void 0 ? void 0 : _b.call(multiple, date, activeModifiers, e);
1576
+ }
1577
+ else if (isDayPickerRange(dayPicker)) {
1578
+ (_c = range.onDayClick) === null || _c === void 0 ? void 0 : _c.call(range, date, activeModifiers, e);
1579
+ }
1580
+ (_d = dayPicker.onDayClick) === null || _d === void 0 ? void 0 : _d.call(dayPicker, date, activeModifiers, e);
1581
+ };
1582
+ var onFocus = function (e) {
1583
+ var _a;
1584
+ focus(date);
1585
+ (_a = dayPicker.onDayFocus) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1586
+ };
1587
+ var onBlur = function (e) {
1588
+ var _a;
1589
+ blur();
1590
+ (_a = dayPicker.onDayBlur) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1591
+ };
1592
+ var onMouseEnter = function (e) {
1593
+ var _a;
1594
+ (_a = dayPicker.onDayMouseEnter) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1595
+ };
1596
+ var onMouseLeave = function (e) {
1597
+ var _a;
1598
+ (_a = dayPicker.onDayMouseLeave) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1599
+ };
1600
+ var onTouchCancel = function (e) {
1601
+ var _a;
1602
+ (_a = dayPicker.onDayTouchCancel) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1603
+ };
1604
+ var onTouchEnd = function (e) {
1605
+ var _a;
1606
+ (_a = dayPicker.onDayTouchEnd) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1607
+ };
1608
+ var onTouchMove = function (e) {
1609
+ var _a;
1610
+ (_a = dayPicker.onDayTouchMove) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1611
+ };
1612
+ var onTouchStart = function (e) {
1613
+ var _a;
1614
+ (_a = dayPicker.onDayTouchStart) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1615
+ };
1616
+ var onKeyUp = function (e) {
1617
+ var _a;
1618
+ (_a = dayPicker.onDayKeyUp) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1619
+ };
1620
+ var onKeyDown = function (e) {
1621
+ var _a;
1622
+ switch (e.key) {
1623
+ case 'ArrowLeft':
1624
+ e.preventDefault();
1625
+ e.stopPropagation();
1626
+ dayPicker.dir === 'rtl' ? focusDayAfter() : focusDayBefore();
1627
+ break;
1628
+ case 'ArrowRight':
1629
+ e.preventDefault();
1630
+ e.stopPropagation();
1631
+ dayPicker.dir === 'rtl' ? focusDayBefore() : focusDayAfter();
1632
+ break;
1633
+ case 'ArrowDown':
1634
+ e.preventDefault();
1635
+ e.stopPropagation();
1636
+ focusWeekAfter();
1637
+ break;
1638
+ case 'ArrowUp':
1639
+ e.preventDefault();
1640
+ e.stopPropagation();
1641
+ focusWeekBefore();
1642
+ break;
1643
+ case 'PageUp':
1644
+ e.preventDefault();
1645
+ e.stopPropagation();
1646
+ e.shiftKey ? focusYearBefore() : focusMonthBefore();
1647
+ break;
1648
+ case 'PageDown':
1649
+ e.preventDefault();
1650
+ e.stopPropagation();
1651
+ e.shiftKey ? focusYearAfter() : focusMonthAfter();
1652
+ break;
1653
+ case 'Home':
1654
+ e.preventDefault();
1655
+ e.stopPropagation();
1656
+ focusStartOfWeek();
1657
+ break;
1658
+ case 'End':
1659
+ e.preventDefault();
1660
+ e.stopPropagation();
1661
+ focusEndOfWeek();
1662
+ break;
1663
+ }
1664
+ (_a = dayPicker.onDayKeyDown) === null || _a === void 0 ? void 0 : _a.call(dayPicker, date, activeModifiers, e);
1665
+ };
1666
+ var eventHandlers = {
1667
+ onClick: onClick,
1668
+ onFocus: onFocus,
1669
+ onBlur: onBlur,
1670
+ onKeyDown: onKeyDown,
1671
+ onKeyUp: onKeyUp,
1672
+ onMouseEnter: onMouseEnter,
1673
+ onMouseLeave: onMouseLeave,
1674
+ onTouchCancel: onTouchCancel,
1675
+ onTouchEnd: onTouchEnd,
1676
+ onTouchMove: onTouchMove,
1677
+ onTouchStart: onTouchStart
1678
+ };
1679
+ return eventHandlers;
1680
+ }
1681
+
1682
+ /**
1683
+ * Return the current selected days when DayPicker is in selection mode.
1684
+ *
1685
+ * Days selected by the custom selection mode are not returned.
1686
+ */
1687
+ function useSelectedDays() {
1688
+ var dayPicker = useDayPicker();
1689
+ var single = useSelectSingle();
1690
+ var multiple = useSelectMultiple();
1691
+ var range = useSelectRange();
1692
+ var selectedDays = isDayPickerSingle(dayPicker)
1693
+ ? single.selected
1694
+ : isDayPickerMultiple(dayPicker)
1695
+ ? multiple.selected
1696
+ : isDayPickerRange(dayPicker)
1697
+ ? range.selected
1698
+ : undefined;
1699
+ return selectedDays;
1700
+ }
1701
+
1702
+ /** Return the class names for the Day element, according to the given active modifiers. */
1703
+ function getDayClassNames(dayPicker, activeModifiers) {
1704
+ var classNames = [dayPicker.classNames.day];
1705
+ Object.keys(activeModifiers).forEach(function (modifier) {
1706
+ var customClassName = dayPicker.modifiersClassNames[modifier];
1707
+ if (customClassName) {
1708
+ classNames.push(customClassName);
1709
+ }
1710
+ else {
1711
+ classNames.push("".concat(dayPicker.modifierPrefix).concat(modifier));
1712
+ }
1713
+ });
1714
+ return classNames;
1715
+ }
1716
+
1717
+ /** Return the style for the Day element, according to the given active modifiers. */
1718
+ function getDayStyle(dayPicker, activeModifiers) {
1719
+ var style = __assign({}, dayPicker.styles.day);
1720
+ Object.keys(activeModifiers).forEach(function (modifier) {
1721
+ var _a;
1722
+ style = __assign(__assign({}, style), (_a = dayPicker.modifiersStyles) === null || _a === void 0 ? void 0 : _a[modifier]);
1723
+ });
1724
+ return style;
1725
+ }
1726
+
1727
+ /**
1728
+ * Return props and data used to render the [[Day]] component.
1729
+ *
1730
+ * Use this hook when creating a component to replace the built-in `Day`
1731
+ * component.
1732
+ *
1733
+ * Each Day in DayPicker should render one of the following, according to the return
1734
+ * value:
1735
+ *
1736
+ * - an empty `React.Fragment`, to render if `isHidden` is true
1737
+ * - a `button` element, when the day is interactive, e.g. is selectable
1738
+ * - a `div` element, whe the day is not interactive
1739
+ *
1740
+ * @param day The date to render
1741
+ * @param displayMonth The month where the date is displayed (if not the same as
1742
+ * `date`, it means it is an "outside" day)
1743
+ * @param buttonRef A ref to the button element that will be target of focus
1744
+ * when rendered (if required).
1745
+ */
1746
+ function useDayRender(day, displayMonth, buttonRef) {
1747
+ var _a;
1748
+ var _b, _c;
1749
+ var dayPicker = useDayPicker();
1750
+ var focusContext = useFocusContext();
1751
+ var activeModifiers = useActiveModifiers(day, displayMonth);
1752
+ var eventHandlers = useDayEventHandlers(day, activeModifiers);
1753
+ var selectedDays = useSelectedDays();
1754
+ var isButton = Boolean(dayPicker.mode || dayPicker.onDayClick);
1755
+ // Focus the button if the day is focused according to the focus context
1756
+ React.useEffect(function () {
1757
+ var _a;
1758
+ if (!focusContext.focusedDay)
1759
+ return;
1760
+ if (!isButton)
1761
+ return;
1762
+ if (dateFns.isSameDay(focusContext.focusedDay, day)) {
1763
+ (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1764
+ }
1765
+ }, [focusContext.focusedDay, day, buttonRef, isButton]);
1766
+ var className = getDayClassNames(dayPicker, activeModifiers).join(' ');
1767
+ var style = getDayStyle(dayPicker, activeModifiers);
1768
+ var isHidden = Boolean((activeModifiers.outside && !dayPicker.showOutsideDays) ||
1769
+ activeModifiers.hidden);
1770
+ var DayContentComponent = (_c = (_b = dayPicker.components) === null || _b === void 0 ? void 0 : _b.DayContent) !== null && _c !== void 0 ? _c : DayContent;
1771
+ var children = (React__default["default"].createElement(DayContentComponent, { date: day, displayMonth: displayMonth, activeModifiers: activeModifiers }));
1772
+ var divProps = {
1773
+ style: style,
1774
+ className: className,
1775
+ children: children
1776
+ };
1777
+ var isFocusTarget = Boolean(focusContext.focusTarget && dateFns.isSameDay(focusContext.focusTarget, day));
1778
+ var buttonProps = __assign(__assign(__assign({}, divProps), (_a = { disabled: activeModifiers.disabled }, _a['aria-pressed'] = activeModifiers.selected, _a.tabIndex = isFocusTarget ? 0 : -1, _a)), eventHandlers);
1779
+ var dayRender = {
1780
+ isButton: isButton,
1781
+ isHidden: isHidden,
1782
+ activeModifiers: activeModifiers,
1783
+ selectedDays: selectedDays,
1784
+ buttonProps: buttonProps,
1785
+ divProps: divProps
1786
+ };
1787
+ return dayRender;
1788
+ }
1789
+
1790
+ /**
1791
+ * The content of a day cell – as a button or span element according to its
1792
+ * modifiers.
1793
+ */
1794
+ function Day(props) {
1795
+ var buttonRef = React.useRef(null);
1796
+ var dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
1797
+ if (dayRender.isHidden) {
1798
+ return React__default["default"].createElement(React__default["default"].Fragment, null);
1799
+ }
1800
+ if (!dayRender.isButton) {
1801
+ return React__default["default"].createElement("div", __assign({}, dayRender.divProps));
1802
+ }
1803
+ return React__default["default"].createElement(Button, __assign({ ref: buttonRef }, dayRender.buttonProps));
1804
+ }
1805
+
1806
+ /**
1807
+ * Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it
1808
+ * renders a button, otherwise a span element.
1809
+ */
1810
+ function WeekNumber(props) {
1811
+ var weekNumber = props.number, dates = props.dates;
1812
+ var _a = useDayPicker(), onWeekNumberClick = _a.onWeekNumberClick, styles = _a.styles, classNames = _a.classNames, locale = _a.locale, labelWeekNumber = _a.labels.labelWeekNumber, formatWeekNumber = _a.formatters.formatWeekNumber;
1813
+ var content = formatWeekNumber(Number(weekNumber), { locale: locale });
1814
+ if (!onWeekNumberClick) {
1815
+ return (React__default["default"].createElement("span", { className: classNames.weeknumber, style: styles.weeknumber }, content));
1816
+ }
1817
+ var label = labelWeekNumber(Number(weekNumber), { locale: locale });
1818
+ var handleClick = function (e) {
1819
+ onWeekNumberClick(weekNumber, dates, e);
1820
+ };
1821
+ return (React__default["default"].createElement(Button, { "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, content));
1822
+ }
1823
+
1824
+ /** Render a row in the calendar, with the days and the week number. */
1825
+ function Row(props) {
1826
+ var _a, _b;
1827
+ var _c = useDayPicker(), styles = _c.styles, classNames = _c.classNames, showWeekNumber = _c.showWeekNumber, components = _c.components;
1828
+ var DayComponent = (_a = components === null || components === void 0 ? void 0 : components.Day) !== null && _a !== void 0 ? _a : Day;
1829
+ var WeeknumberComponent = (_b = components === null || components === void 0 ? void 0 : components.WeekNumber) !== null && _b !== void 0 ? _b : WeekNumber;
1830
+ var weekNumberCell;
1831
+ if (showWeekNumber) {
1832
+ weekNumberCell = (React__default["default"].createElement("td", { className: classNames.cell, style: styles.cell },
1833
+ React__default["default"].createElement(WeeknumberComponent, { number: props.weekNumber, dates: props.dates })));
1834
+ }
1835
+ return (React__default["default"].createElement("tr", { className: classNames.row, style: styles.row },
1836
+ weekNumberCell,
1837
+ props.dates.map(function (date) { return (React__default["default"].createElement("td", { className: classNames.cell, style: styles.cell, key: dateFns.getUnixTime(date) },
1838
+ React__default["default"].createElement(DayComponent, { displayMonth: props.displayMonth, date: date }))); })));
1839
+ }
1840
+
1841
+ /** Return the weeks between two dates. */
1842
+ function daysToMonthWeeks(fromDate, toDate, options) {
1843
+ var toWeek = dateFns.endOfWeek(toDate, options);
1844
+ var fromWeek = dateFns.startOfWeek(fromDate, options);
1845
+ var nOfDays = dateFns.differenceInCalendarDays(toWeek, fromWeek);
1846
+ var days = [];
1847
+ for (var i = 0; i <= nOfDays; i++) {
1848
+ days.push(dateFns.addDays(fromWeek, i));
1849
+ }
1850
+ var weeksInMonth = days.reduce(function (result, date) {
1851
+ var weekNumber = dateFns.getWeek(date, options);
1852
+ var existingWeek = result.find(function (value) { return value.weekNumber === weekNumber; });
1853
+ if (existingWeek) {
1854
+ existingWeek.dates.push(date);
1855
+ return result;
1856
+ }
1857
+ result.push({
1858
+ weekNumber: weekNumber,
1859
+ dates: [date]
1860
+ });
1861
+ return result;
1862
+ }, []);
1863
+ return weeksInMonth;
1864
+ }
1865
+
1866
+ /**
1867
+ * Return the weeks belonging to the given month, adding the "outside days" to
1868
+ * the first and last week.
1869
+ */
1870
+ function getMonthWeeks(
1871
+ /** The month to get the weeks from */
1872
+ month, options) {
1873
+ var weeksInMonth = daysToMonthWeeks(dateFns.startOfMonth(month), dateFns.endOfMonth(month), options);
1874
+ // Add extra weeks to the month, up to 6 weeks
1875
+ if (options === null || options === void 0 ? void 0 : options.useFixedWeeks) {
1876
+ var nrOfMonthWeeks = dateFns.getWeeksInMonth(month, options);
1877
+ if (nrOfMonthWeeks < 6) {
1878
+ var lastWeek = weeksInMonth[weeksInMonth.length - 1];
1879
+ var lastDate = lastWeek.dates[lastWeek.dates.length - 1];
1880
+ var toDate = dateFns.addWeeks(lastDate, 6 - nrOfMonthWeeks);
1881
+ var extraWeeks = daysToMonthWeeks(dateFns.addWeeks(lastDate, 1), toDate, options);
1882
+ weeksInMonth.push.apply(weeksInMonth, extraWeeks);
1883
+ }
1884
+ }
1885
+ return weeksInMonth;
1886
+ }
1887
+
1888
+ /** Render the table with the calendar. */
1889
+ function Table(props) {
1890
+ var _a, _b, _c;
1891
+ var _d = useDayPicker(), locale = _d.locale, classNames = _d.classNames, styles = _d.styles, hideHead = _d.hideHead, fixedWeeks = _d.fixedWeeks, components = _d.components;
1892
+ var weeks = getMonthWeeks(props.displayMonth, {
1893
+ useFixedWeeks: Boolean(fixedWeeks),
1894
+ locale: locale
1895
+ });
1896
+ var HeadComponent = (_a = components === null || components === void 0 ? void 0 : components.Head) !== null && _a !== void 0 ? _a : Head;
1897
+ var RowComponent = (_b = components === null || components === void 0 ? void 0 : components.Row) !== null && _b !== void 0 ? _b : Row;
1898
+ var FooterComponent = (_c = components === null || components === void 0 ? void 0 : components.Footer) !== null && _c !== void 0 ? _c : Footer;
1899
+ return (React__default["default"].createElement("table", { className: classNames.table, style: styles.table, role: "grid", "aria-labelledby": props['aria-labelledby'] },
1900
+ !hideHead && React__default["default"].createElement(HeadComponent, null),
1901
+ React__default["default"].createElement("tbody", { className: classNames.tbody, style: styles.tbody }, weeks.map(function (week) { return (React__default["default"].createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
1902
+ React__default["default"].createElement(FooterComponent, null)));
1903
+ }
1904
+
1905
+ /** Render a month. */
1906
+ function Month(props) {
1907
+ var _a;
1908
+ var _b;
1909
+ var dayPicker = useDayPicker();
1910
+ var dir = dayPicker.dir, classNames = dayPicker.classNames, styles = dayPicker.styles, components = dayPicker.components;
1911
+ var displayMonths = useNavigation().displayMonths;
1912
+ var captionId = useId();
1913
+ var className = [classNames.month];
1914
+ var style = styles.month;
1915
+ var isStart = props.displayIndex === 0;
1916
+ var isEnd = props.displayIndex === displayMonths.length - 1;
1917
+ var isCenter = !isStart && !isEnd;
1918
+ if (dir === 'rtl') {
1919
+ _a = [isStart, isEnd], isEnd = _a[0], isStart = _a[1];
1920
+ }
1921
+ if (isStart) {
1922
+ className.push(classNames.caption_start);
1923
+ style = __assign(__assign({}, style), styles.caption_start);
1924
+ }
1925
+ if (isEnd) {
1926
+ className.push(classNames.caption_end);
1927
+ style = __assign(__assign({}, style), styles.caption_end);
1928
+ }
1929
+ if (isCenter) {
1930
+ className.push(classNames.caption_between);
1931
+ style = __assign(__assign({}, style), styles.caption_between);
1932
+ }
1933
+ var CaptionComponent = (_b = components === null || components === void 0 ? void 0 : components.Caption) !== null && _b !== void 0 ? _b : Caption;
1934
+ return (React__default["default"].createElement("div", { key: props.displayIndex, className: className.join(' '), style: style },
1935
+ React__default["default"].createElement(CaptionComponent, { id: captionId, displayMonth: props.displayMonth }),
1936
+ React__default["default"].createElement(Table, { "aria-labelledby": captionId, displayMonth: props.displayMonth })));
1937
+ }
1938
+
1939
+ /** Render the container with the months according to the number of months to display. */
1940
+ function Root() {
1941
+ var _a;
1942
+ var dayPicker = useDayPicker();
1943
+ var focusContext = useFocusContext();
1944
+ var navigation = useNavigation();
1945
+ var _b = React.useState(false), hasInitialFocus = _b[0], setHasInitialFocus = _b[1];
1946
+ // Focus the focus target when initialFocus is passed in
1947
+ React.useEffect(function () {
1948
+ if (!dayPicker.initialFocus)
1949
+ return;
1950
+ if (!focusContext.focusTarget)
1951
+ return;
1952
+ if (hasInitialFocus)
1953
+ return;
1954
+ focusContext.focus(focusContext.focusTarget);
1955
+ setHasInitialFocus(true);
1956
+ }, [
1957
+ dayPicker.initialFocus,
1958
+ hasInitialFocus,
1959
+ focusContext.focus,
1960
+ focusContext.focusTarget,
1961
+ focusContext
1962
+ ]);
1963
+ // Apply classnames according to props
1964
+ var classNames = [(_a = dayPicker.className) !== null && _a !== void 0 ? _a : dayPicker.classNames.root];
1965
+ if (dayPicker.numberOfMonths > 1) {
1966
+ classNames.push(dayPicker.classNames.multiple_months);
1967
+ }
1968
+ if (dayPicker.showWeekNumber) {
1969
+ classNames.push(dayPicker.classNames.with_weeknumber);
1970
+ }
1971
+ var style = __assign(__assign({}, dayPicker.styles.root), dayPicker.style);
1972
+ return (React__default["default"].createElement("div", { className: classNames.join(' '), style: style, dir: dayPicker.dir },
1973
+ React__default["default"].createElement("div", { className: dayPicker.classNames.months, style: dayPicker.styles.months }, navigation.displayMonths.map(function (month, i) { return (React__default["default"].createElement(Month, { key: i, displayIndex: i, displayMonth: month })); }))));
1974
+ }
1975
+
1976
+ /** Provide the value for all the context providers. */
1977
+ function RootProvider(props) {
1978
+ var children = props.children, initialProps = __rest(props, ["children"]);
1979
+ return (React__default["default"].createElement(DayPickerProvider, { initialProps: initialProps },
1980
+ React__default["default"].createElement(NavigationProvider, null,
1981
+ React__default["default"].createElement(SelectSingleProvider, { initialProps: initialProps },
1982
+ React__default["default"].createElement(SelectMultipleProvider, { initialProps: initialProps },
1983
+ React__default["default"].createElement(SelectRangeProvider, { initialProps: initialProps },
1984
+ React__default["default"].createElement(ModifiersProvider, null,
1985
+ React__default["default"].createElement(FocusProvider, null, children))))))));
1986
+ }
1987
+
1988
+ /**
1989
+ * DayPicker render a date picker component to let users pick dates from a
1990
+ * calendar. See http://react-day-picker.js.org for updated documentation and
1991
+ * examples.
1992
+ *
1993
+ * ### Customization
1994
+ *
1995
+ * DayPicker offers different customization props. For example,
1996
+ *
1997
+ * - show multiple months using `numberOfMonths`
1998
+ * - display a dropdown to navigate the months via `captionLayout`
1999
+ * - display the week numbers with `showWeekNumbers`
2000
+ * - disable or hide days with `disabled` or `hidden`
2001
+ *
2002
+ * ### Controlling the months
2003
+ *
2004
+ * Change the initially displayed month using the `defaultMonth` prop. The
2005
+ * displayed months are controlled by DayPicker and stored in its internal
2006
+ * state. To control the months yourself, use `month` instead of `defaultMonth`
2007
+ * and use the `onMonthChange` event to set it.
2008
+ *
2009
+ * To limit the months the user can navigate to, use
2010
+ * `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.
2011
+ *
2012
+ * ### Selection modes
2013
+ *
2014
+ * DayPicker supports different selection mode that can be toggled using the
2015
+ * `mode` prop:
2016
+ *
2017
+ * - `mode="single"`: only one day can be selected. Use `required` to make the
2018
+ * selection required. Use the `onSelect` event handler to get the selected
2019
+ * days.
2020
+ * - `mode="multiple"`: users can select one or more days. Limit the amount of
2021
+ * days that can be selected with the `min` or the `max` props.
2022
+ * - `mode="range"`: users can select a range of days. Limit the amount of days
2023
+ * in the range with the `min` or the `max` props.
2024
+ * - `mode="custom"`: implement your own selection mode with `onDayClick`.
2025
+ *
2026
+ * These selection modes should cover the most common use cases. In case you
2027
+ * need a more refined way of selecting days, use `mode="custom"`. Use the
2028
+ * `selected` props and add the day event handlers to add/remove days from the
2029
+ * selection.
2030
+ *
2031
+ * ### Modifiers
2032
+ *
2033
+ * A _modifier_ represents different styles or states for the days displayed in
2034
+ * the calendar (like "selected" or "disabled"). Define custom modifiers using
2035
+ * the `modifiers` prop.
2036
+ *
2037
+ * ### Formatters and custom component
2038
+ *
2039
+ * You can customize how the content is displayed in the date picker by using
2040
+ * either the formatters or replacing the internal components.
2041
+ *
2042
+ * For the most common cases you want to use the `formatters` prop to change how
2043
+ * the content is formatted in the calendar. Use the `components` prop to
2044
+ * replace the internal components, like the navigation icons.
2045
+ *
2046
+ * ### Styling
2047
+ *
2048
+ * DayPicker comes with a default, basic style in `react-day-picker/style` – use
2049
+ * it as template for your own style.
2050
+ *
2051
+ * If you are using CSS modules, pass the imported styles object the
2052
+ * `classNames` props.
2053
+ *
2054
+ * You can also style the elements via inline-styles using the `styles` prop.
2055
+ *
2056
+ * ### Form fields
2057
+ *
2058
+ * If you need to bind the date picker to a form field, you can use the
2059
+ * `useInput` hooks for a basic behavior. See the `useInput` source as an
2060
+ * example to bind the date picker with form fields.
2061
+ *
2062
+ * ### Localization
2063
+ *
2064
+ * To localize DayPicker, import the locale from `date-fns` package and use the
2065
+ * `locale` prop.
2066
+ *
2067
+ * For example, to use Spanish locale:
2068
+ *
2069
+ * ```
2070
+ * import es from 'date-fns/locale/es';
2071
+ * <DayPicker locale={es} />
2072
+ * ```
2073
+ */
2074
+ function DayPicker(props) {
2075
+ return (React__default["default"].createElement(RootProvider, __assign({}, props),
2076
+ React__default["default"].createElement(Root, null)));
2077
+ }
2078
+
2079
+ /** @private */
2080
+ function isValidDate(day) {
2081
+ return !isNaN(day.getTime());
2082
+ }
2083
+
2084
+ /** Return props and setters for binding an input field to DayPicker. */
2085
+ function useInput(options) {
2086
+ if (options === void 0) { options = {}; }
2087
+ var _a = options.locale, locale = _a === void 0 ? enUS__default["default"] : _a, required = options.required, _b = options.format, format = _b === void 0 ? 'PP' : _b, defaultSelected = options.defaultSelected, _c = options.today, today = _c === void 0 ? new Date() : _c;
2088
+ var _d = parseFromToProps(options), fromDate = _d.fromDate, toDate = _d.toDate;
2089
+ // Shortcut to the DateFns functions
2090
+ var parseValue = function (value) { return dateFns.parse(value, format, today, { locale: locale }); };
2091
+ // Initialize states
2092
+ var _e = React.useState(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : today), month = _e[0], setMonth = _e[1];
2093
+ var _f = React.useState(defaultSelected), selectedDay = _f[0], setSelectedDay = _f[1];
2094
+ var defaultInputValue = defaultSelected
2095
+ ? dateFns.format(defaultSelected, format, { locale: locale })
2096
+ : '';
2097
+ var _g = React.useState(defaultInputValue), inputValue = _g[0], setInputValue = _g[1];
2098
+ var reset = function () {
2099
+ setSelectedDay(defaultSelected);
2100
+ setMonth(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : today);
2101
+ setInputValue(defaultInputValue !== null && defaultInputValue !== void 0 ? defaultInputValue : '');
2102
+ };
2103
+ var setSelected = function (date) {
2104
+ setSelectedDay(date);
2105
+ setMonth(date !== null && date !== void 0 ? date : today);
2106
+ setInputValue(date ? dateFns.format(date, format, { locale: locale }) : '');
2107
+ };
2108
+ var handleDayClick = function (day, _a) {
2109
+ var selected = _a.selected;
2110
+ if (!required && selected) {
2111
+ setSelectedDay(undefined);
2112
+ setInputValue('');
2113
+ return;
2114
+ }
2115
+ setSelectedDay(day);
2116
+ setInputValue(day ? dateFns.format(day, format, { locale: locale }) : '');
2117
+ };
2118
+ var handleMonthChange = function (month) {
2119
+ setMonth(month);
2120
+ };
2121
+ // When changing the input field, save its value in state and check if the
2122
+ // string is a valid date. If it is a valid day, set it as selected and update
2123
+ // the calendar’s month.
2124
+ var handleChange = function (e) {
2125
+ setInputValue(e.target.value);
2126
+ var day = parseValue(e.target.value);
2127
+ var isBefore = fromDate && dateFns.differenceInCalendarDays(fromDate, day) > 0;
2128
+ var isAfter = toDate && dateFns.differenceInCalendarDays(day, toDate) > 0;
2129
+ if (!isValidDate(day) || isBefore || isAfter) {
2130
+ setSelectedDay(undefined);
2131
+ return;
2132
+ }
2133
+ setSelectedDay(day);
2134
+ setMonth(day);
2135
+ };
2136
+ // Special case for _required_ fields: on blur, if the value of the input is not
2137
+ // a valid date, reset the calendar and the input value.
2138
+ var handleBlur = function (e) {
2139
+ var day = parseValue(e.target.value);
2140
+ if (!isValidDate(day)) {
2141
+ reset();
2142
+ }
2143
+ };
2144
+ // When focusing, make sure DayPicker visualizes the month of the date in the
2145
+ // input field.
2146
+ var handleFocus = function (e) {
2147
+ if (!e.target.value) {
2148
+ reset();
2149
+ return;
2150
+ }
2151
+ var day = parseValue(e.target.value);
2152
+ if (isValidDate(day)) {
2153
+ setMonth(day);
2154
+ }
2155
+ };
2156
+ var dayPickerProps = {
2157
+ mode: 'custom',
2158
+ month: month,
2159
+ onDayClick: handleDayClick,
2160
+ onMonthChange: handleMonthChange,
2161
+ selected: selectedDay,
2162
+ locale: locale,
2163
+ fromDate: options === null || options === void 0 ? void 0 : options.fromDate,
2164
+ toDate: options === null || options === void 0 ? void 0 : options.toDate,
2165
+ today: today
2166
+ };
2167
+ var inputProps = {
2168
+ onBlur: handleBlur,
2169
+ onChange: handleChange,
2170
+ onFocus: handleFocus,
2171
+ value: inputValue,
2172
+ placeholder: dateFns.format(new Date(), format, { locale: locale })
2173
+ };
2174
+ return { dayPickerProps: dayPickerProps, inputProps: inputProps, reset: reset, setSelected: setSelected };
2175
+ }
2176
+
2177
+ /** Returns true when the props are of type [[DayPickerCustom]]. */
2178
+ function isDayPickerCustom(props) {
2179
+ return props.mode === 'custom';
2180
+ }
2181
+
2182
+ exports.Button = Button;
2183
+ exports.Caption = Caption;
2184
+ exports.CaptionLabel = CaptionLabel;
2185
+ exports.Day = Day;
2186
+ exports.DayContent = DayContent;
2187
+ exports.DayPicker = DayPicker;
2188
+ exports.DayPickerContext = DayPickerContext;
2189
+ exports.DayPickerProvider = DayPickerProvider;
2190
+ exports.Dropdown = Dropdown;
2191
+ exports.FocusContext = FocusContext;
2192
+ exports.FocusProvider = FocusProvider;
2193
+ exports.Footer = Footer;
2194
+ exports.Head = Head;
2195
+ exports.IconDropdown = IconDropdown;
2196
+ exports.IconLeft = IconLeft;
2197
+ exports.IconRight = IconRight;
2198
+ exports.NavigationContext = NavigationContext;
2199
+ exports.NavigationProvider = NavigationProvider;
2200
+ exports.RootProvider = RootProvider;
2201
+ exports.Row = Row;
2202
+ exports.SelectMultipleContext = SelectMultipleContext;
2203
+ exports.SelectMultipleProvider = SelectMultipleProvider;
2204
+ exports.SelectMultipleProviderInternal = SelectMultipleProviderInternal;
2205
+ exports.SelectRangeContext = SelectRangeContext;
2206
+ exports.SelectRangeProvider = SelectRangeProvider;
2207
+ exports.SelectRangeProviderInternal = SelectRangeProviderInternal;
2208
+ exports.SelectSingleContext = SelectSingleContext;
2209
+ exports.SelectSingleProvider = SelectSingleProvider;
2210
+ exports.SelectSingleProviderInternal = SelectSingleProviderInternal;
2211
+ exports.WeekNumber = WeekNumber;
2212
+ exports.isDateAfterType = isDateAfterType;
2213
+ exports.isDateBeforeType = isDateBeforeType;
2214
+ exports.isDateInterval = isDateInterval;
2215
+ exports.isDateRange = isDateRange;
2216
+ exports.isDayOfWeekType = isDayOfWeekType;
2217
+ exports.isDayPickerCustom = isDayPickerCustom;
2218
+ exports.isDayPickerMultiple = isDayPickerMultiple;
2219
+ exports.isDayPickerRange = isDayPickerRange;
2220
+ exports.isDayPickerSingle = isDayPickerSingle;
2221
+ exports.isMatch = isMatch;
2222
+ exports.useActiveModifiers = useActiveModifiers;
2223
+ exports.useDayPicker = useDayPicker;
2224
+ exports.useDayRender = useDayRender;
2225
+ exports.useFocusContext = useFocusContext;
2226
+ exports.useInput = useInput;
2227
+ exports.useNavigation = useNavigation;
2228
+ exports.useSelectMultiple = useSelectMultiple;
2229
+ exports.useSelectRange = useSelectRange;
2230
+ exports.useSelectSingle = useSelectSingle;
2231
+ //# sourceMappingURL=index.js.map