react-day-picker 8.0.7 → 8.1.2

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 (115) hide show
  1. package/dist/DayPicker.d.ts +2 -5
  2. package/dist/components/Button/Button.d.ts +2 -2
  3. package/dist/components/Caption/Caption.d.ts +2 -2
  4. package/dist/components/CaptionLabel/CaptionLabel.d.ts +1 -1
  5. package/dist/components/Day/Day.d.ts +1 -1
  6. package/dist/components/DayContent/DayContent.d.ts +1 -1
  7. package/dist/components/Dropdown/Dropdown.d.ts +1 -1
  8. package/dist/components/Month/Month.d.ts +1 -1
  9. package/dist/components/MonthsDropdown/MonthsDropdown.d.ts +1 -1
  10. package/dist/components/Navigation/Navigation.d.ts +1 -1
  11. package/dist/components/Row/Row.d.ts +1 -1
  12. package/dist/components/Table/Table.d.ts +1 -1
  13. package/dist/components/WeekNumber/WeekNumber.d.ts +1 -1
  14. package/dist/components/YearsDropdown/YearsDropdown.d.ts +1 -1
  15. package/dist/contexts/DayPicker/DayPickerContext.d.ts +5 -6
  16. package/dist/contexts/DayPicker/useDayPicker.d.ts +3 -3
  17. package/dist/contexts/Focus/FocusContext.d.ts +3 -3
  18. package/dist/contexts/Focus/useFocusContext.d.ts +6 -1
  19. package/dist/contexts/Focus/utils/getNextFocus.d.ts +9 -0
  20. package/dist/contexts/Modifiers/ModifiersContext.d.ts +2 -2
  21. package/dist/contexts/Modifiers/useModifiers.d.ts +4 -1
  22. package/dist/contexts/Modifiers/utils/getInternalModifiers.d.ts +1 -1
  23. package/dist/contexts/Navigation/NavigationContext.d.ts +9 -10
  24. package/dist/contexts/Navigation/useNavigation.d.ts +6 -1
  25. package/dist/contexts/RootProvider.d.ts +1 -1
  26. package/dist/contexts/SelectMultiple/SelectMultipleContext.d.ts +3 -3
  27. package/dist/contexts/SelectMultiple/useSelectMultiple.d.ts +5 -1
  28. package/dist/contexts/SelectRange/SelectRangeContext.d.ts +3 -3
  29. package/dist/contexts/SelectRange/useSelectRange.d.ts +5 -1
  30. package/dist/contexts/SelectSingle/SelectSingleContext.d.ts +3 -3
  31. package/dist/contexts/SelectSingle/useSelectSingle.d.ts +5 -1
  32. package/dist/hooks/useActiveModifiers/useActiveModifiers.d.ts +9 -3
  33. package/dist/hooks/useDayEventHandlers/useDayEventHandlers.d.ts +2 -2
  34. package/dist/hooks/useDayRender/useDayRender.d.ts +9 -16
  35. package/dist/hooks/useId/index.d.ts +1 -0
  36. package/dist/hooks/useId/useId.d.ts +19 -0
  37. package/dist/hooks/useInput/useInput.d.ts +5 -5
  38. package/dist/hooks/useSelectedDays/useSelectedDays.d.ts +4 -2
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.esm.js +417 -391
  41. package/dist/index.esm.js.map +1 -1
  42. package/dist/index.js +351 -304
  43. package/dist/index.js.map +1 -1
  44. package/dist/react-day-picker.min.js +1 -1
  45. package/dist/style.css +13 -19
  46. package/dist/style.module.css +13 -19
  47. package/dist/types/DayPickerBase.d.ts +30 -14
  48. package/dist/types/DayPickerDefault.d.ts +4 -4
  49. package/dist/types/DayPickerMultiple.d.ts +2 -2
  50. package/dist/types/DayPickerRange.d.ts +2 -2
  51. package/dist/types/DayPickerSingle.d.ts +2 -2
  52. package/dist/types/Labels.d.ts +1 -1
  53. package/dist/types/Matchers.d.ts +10 -10
  54. package/dist/types/Modifiers.d.ts +3 -5
  55. package/package.json +20 -24
  56. package/src/DayPicker.tsx +13 -10
  57. package/src/components/Button/Button.tsx +1 -1
  58. package/src/components/Caption/Caption.tsx +2 -2
  59. package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +1 -2
  60. package/src/components/CaptionLabel/CaptionLabel.tsx +1 -1
  61. package/src/components/CaptionNavigation/CaptionNavigation.tsx +1 -3
  62. package/src/components/Day/Day.tsx +1 -1
  63. package/src/components/DayContent/DayContent.tsx +1 -1
  64. package/src/components/Dropdown/Dropdown.tsx +1 -1
  65. package/src/components/Month/Month.tsx +2 -3
  66. package/src/components/MonthsDropdown/MonthsDropdown.tsx +1 -1
  67. package/src/components/Navigation/Navigation.test.tsx +6 -6
  68. package/src/components/Navigation/Navigation.tsx +3 -3
  69. package/src/components/Root/Root.test.tsx +1 -1
  70. package/src/components/Root/Root.tsx +1 -1
  71. package/src/components/Row/Row.tsx +1 -1
  72. package/src/components/Table/Table.tsx +1 -1
  73. package/src/components/WeekNumber/WeekNumber.test.tsx +2 -4
  74. package/src/components/WeekNumber/WeekNumber.tsx +1 -1
  75. package/src/components/YearsDropdown/YearsDropdown.tsx +1 -1
  76. package/src/contexts/DayPicker/DayPickerContext.tsx +21 -10
  77. package/src/contexts/DayPicker/useDayPicker.test.ts +13 -1
  78. package/src/contexts/DayPicker/useDayPicker.ts +3 -3
  79. package/src/contexts/Focus/FocusContext.tsx +33 -85
  80. package/src/contexts/Focus/useFocusContext.ts +6 -1
  81. package/src/contexts/Focus/utils/getNextFocus.test.tsx +239 -0
  82. package/src/contexts/Focus/utils/getNextFocus.tsx +67 -0
  83. package/src/contexts/Modifiers/ModifiersContext.tsx +2 -2
  84. package/src/contexts/Modifiers/useModifiers.ts +4 -1
  85. package/src/contexts/Modifiers/utils/getInternalModifiers.ts +1 -1
  86. package/src/contexts/Navigation/NavigationContext.tsx +9 -10
  87. package/src/contexts/Navigation/useNavigation.test.ts +5 -1
  88. package/src/contexts/Navigation/useNavigation.ts +6 -1
  89. package/src/contexts/Navigation/useNavigationState.test.ts +6 -2
  90. package/src/contexts/Navigation/useNavigationState.ts +3 -1
  91. package/src/contexts/RootProvider.tsx +1 -1
  92. package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +3 -3
  93. package/src/contexts/SelectMultiple/useSelectMultiple.ts +5 -1
  94. package/src/contexts/SelectRange/SelectRangeContext.tsx +3 -3
  95. package/src/contexts/SelectRange/useSelectRange.ts +5 -1
  96. package/src/contexts/SelectSingle/SelectSingleContext.tsx +3 -3
  97. package/src/contexts/SelectSingle/useSelectSingle.ts +5 -1
  98. package/src/hooks/useActiveModifiers/useActiveModifiers.tsx +7 -2
  99. package/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx +2 -2
  100. package/src/hooks/useDayRender/useDayRender.test.tsx +1 -1
  101. package/src/hooks/useDayRender/useDayRender.tsx +6 -16
  102. package/src/hooks/useId/index.ts +1 -0
  103. package/src/hooks/useId/useId.ts +168 -0
  104. package/src/hooks/useInput/useInput.ts +5 -5
  105. package/src/hooks/useSelectedDays/useSelectedDays.ts +4 -2
  106. package/src/index.ts +1 -0
  107. package/src/style.css +13 -19
  108. package/src/types/DayPickerBase.ts +30 -14
  109. package/src/types/DayPickerDefault.ts +4 -4
  110. package/src/types/DayPickerMultiple.ts +2 -2
  111. package/src/types/DayPickerRange.ts +2 -2
  112. package/src/types/DayPickerSingle.ts +2 -2
  113. package/src/types/Labels.ts +1 -1
  114. package/src/types/Matchers.ts +10 -10
  115. package/src/types/Modifiers.ts +3 -5
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
- import React, { useLayoutEffect, useEffect, useState, createContext, useContext, forwardRef, useRef } from 'react';
1
+ import * as React from 'react';
2
+ import React__default, { createContext, useContext, useState, forwardRef, useEffect, useRef } from 'react';
2
3
  import enUS from 'date-fns/locale/en-US';
3
4
  import format from 'date-fns/format';
4
5
  import endOfMonth from 'date-fns/endOfMonth';
@@ -16,17 +17,19 @@ import addDays from 'date-fns/addDays';
16
17
  import startOfWeek from 'date-fns/startOfWeek';
17
18
  import getUnixTime from 'date-fns/getUnixTime';
18
19
  import isSameDay from 'date-fns/isSameDay';
19
- import addWeeks from 'date-fns/addWeeks';
20
- import addYears from 'date-fns/addYears';
21
- import endOfWeek from 'date-fns/endOfWeek';
22
20
  import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
23
21
  import isAfter from 'date-fns/isAfter';
24
22
  import isDate from 'date-fns/isDate';
23
+ import addWeeks from 'date-fns/addWeeks';
24
+ import addYears from 'date-fns/addYears';
25
+ import endOfWeek from 'date-fns/endOfWeek';
26
+ import max from 'date-fns/max';
27
+ import min from 'date-fns/min';
25
28
  import getWeeksInMonth from 'date-fns/getWeeksInMonth';
26
29
  import getWeek from 'date-fns/getWeek';
27
30
  import parse from 'date-fns/parse';
28
31
 
29
- /*! *****************************************************************************
32
+ /******************************************************************************
30
33
  Copyright (c) Microsoft Corporation.
31
34
 
32
35
  Permission to use, copy, modify, and/or distribute this software for any
@@ -74,145 +77,19 @@ function __spreadArray(to, from, pack) {
74
77
  return to.concat(ar || Array.prototype.slice.call(from));
75
78
  }
76
79
 
77
- function canUseDOM() {
78
- return !!(typeof window !== "undefined" && window.document && window.document.createElement);
80
+ /** Returns true when the props are of type {@link DayPickerMultipleProps}. */
81
+ function isDayPickerMultiple(props) {
82
+ return props.mode === 'multiple';
79
83
  }
80
84
 
81
- /**
82
- * React currently throws a warning when using useLayoutEffect on the server. To
83
- * get around it, we can conditionally useEffect on the server (no-op) and
84
- * useLayoutEffect in the browser. We occasionally need useLayoutEffect to
85
- * ensure we don't get a render flash for certain operations, but we may also
86
- * need affected components to render on the server. One example is when setting
87
- * a component's descendants to retrieve their index values.
88
- *
89
- * Important to note that using this hook as an escape hatch will break the
90
- * eslint dependency warnings unless you rename the import to `useLayoutEffect`.
91
- * Use sparingly only when the effect won't effect the rendered HTML to avoid
92
- * any server/client mismatch.
93
- *
94
- * If a useLayoutEffect is needed and the result would create a mismatch, it's
95
- * likely that the component in question shouldn't be rendered on the server at
96
- * all, so a better approach would be to lazily render those in a parent
97
- * component after client-side hydration.
98
- *
99
- * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
100
- * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
101
- *
102
- * @param effect
103
- * @param deps
104
- */
105
-
106
- var useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? useLayoutEffect : useEffect;
107
-
108
- /*
109
- * Welcome to @reach/auto-id!
110
-
111
- * Let's see if we can make sense of why this hook exists and its
112
- * implementation.
113
- *
114
- * Some background:
115
- * 1. Accessibility APIs rely heavily on element IDs
116
- * 2. Requiring developers to put IDs on every element in Reach UI is both
117
- * cumbersome and error-prone
118
- * 3. With a component model, we can generate IDs for them!
119
- *
120
- * Solution 1: Generate random IDs.
121
- *
122
- * This works great as long as you don't server render your app. When React (in
123
- * the client) tries to reuse the markup from the server, the IDs won't match
124
- * and React will then recreate the entire DOM tree.
125
- *
126
- * Solution 2: Increment an integer
127
- *
128
- * This sounds great. Since we're rendering the exact same tree on the server
129
- * and client, we can increment a counter and get a deterministic result between
130
- * client and server. Also, JS integers can go up to nine-quadrillion. I'm
131
- * pretty sure the tab will be closed before an app never needs
132
- * 10 quadrillion IDs!
133
- *
134
- * Problem solved, right?
135
- *
136
- * Ah, but there's a catch! React's concurrent rendering makes this approach
137
- * non-deterministic. While the client and server will end up with the same
138
- * elements in the end, depending on suspense boundaries (and possibly some user
139
- * input during the initial render) the incrementing integers won't always match
140
- * up.
141
- *
142
- * Solution 3: Don't use IDs at all on the server; patch after first render.
143
- *
144
- * What we've done here is solution 2 with some tricks. With this approach, the
145
- * ID returned is an empty string on the first render. This way the server and
146
- * client have the same markup no matter how wild the concurrent rendering may
147
- * have gotten.
148
- *
149
- * After the render, we patch up the components with an incremented ID. This
150
- * causes a double render on any components with `useId`. Shouldn't be a problem
151
- * since the components using this hook should be small, and we're only updating
152
- * the ID attribute on the DOM, nothing big is happening.
153
- *
154
- * It doesn't have to be an incremented number, though--we could do generate
155
- * random strings instead, but incrementing a number is probably the cheapest
156
- * thing we can do.
157
- *
158
- * Additionally, we only do this patchup on the very first client render ever.
159
- * Any calls to `useId` that happen dynamically in the client will be
160
- * populated immediately with a value. So, we only get the double render after
161
- * server hydration and never again, SO BACK OFF ALRIGHT?
162
- */
163
- var serverHandoffComplete = false;
164
- var id = 0;
165
-
166
- var genId = function genId() {
167
- return ++id;
168
- };
169
- /**
170
- * useId
171
- *
172
- * Autogenerate IDs to facilitate WAI-ARIA and server rendering.
173
- *
174
- * Note: The returned ID will initially be `null` and will update after a
175
- * component mounts. Users may need to supply their own ID if they need
176
- * consistent values for SSR.
177
- *
178
- * @see Docs https://reach.tech/auto-id
179
- */
180
-
85
+ /** Returns true when the props are of type {@link DayPickerRangeProps}. */
86
+ function isDayPickerRange(props) {
87
+ return props.mode === 'range';
88
+ }
181
89
 
182
- function useId(idFromProps) {
183
- /*
184
- * If this instance isn't part of the initial render, we don't have to do the
185
- * double render/patch-up dance. We can just generate the ID and return it.
186
- */
187
- var initialId = idFromProps || (serverHandoffComplete ? genId() : null);
188
-
189
- var _React$useState = useState(initialId),
190
- id = _React$useState[0],
191
- setId = _React$useState[1];
192
-
193
- useIsomorphicLayoutEffect(function () {
194
- if (id === null) {
195
- /*
196
- * Patch the ID after render. We do this in `useLayoutEffect` to avoid any
197
- * rendering flicker, though it'll make the first render slower (unlikely
198
- * to matter, but you're welcome to measure your app and let us know if
199
- * it's a problem).
200
- */
201
- setId(genId());
202
- } // eslint-disable-next-line react-hooks/exhaustive-deps
203
-
204
- }, []);
205
- useEffect(function () {
206
- if (serverHandoffComplete === false) {
207
- /*
208
- * Flag all future uses of `useId` to skip the update dance. This is in
209
- * `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
210
- * accidentally bail out of the patch-up dance prematurely.
211
- */
212
- serverHandoffComplete = true;
213
- }
214
- }, []);
215
- return id != null ? String(id) : undefined;
90
+ /** Returns true when the props are of type {@link DayPickerSingleProps}. */
91
+ function isDayPickerSingle(props) {
92
+ return props.mode === 'single';
216
93
  }
217
94
 
218
95
  /**
@@ -425,16 +302,15 @@ function parseFromToProps(props) {
425
302
  }
426
303
 
427
304
  /**
428
- * The DayPicker Context shares the props passed to DayPicker within internal
305
+ * The DayPicker context shares the props passed to DayPicker within internal
429
306
  * and custom components. It is used to set the default values and perform
430
307
  * one-time calculations required to render the days.
431
308
  *
432
- * Developers may access this context from the [[useDayPicker]] hook when
433
- * using custom components.
309
+ * Access to this context from the {@link useDayPicker} hook.
434
310
  */
435
311
  var DayPickerContext = createContext(undefined);
436
312
  /**
437
- * The provider for the [[DayPickerContext]], assigning the defaults from the
313
+ * The provider for the {@link DayPickerContext}, assigning the defaults from the
438
314
  * initial DayPicker props.
439
315
  */
440
316
  function DayPickerProvider(props) {
@@ -446,6 +322,12 @@ function DayPickerProvider(props) {
446
322
  if (captionLayout !== 'buttons' && (!fromDate || !toDate)) {
447
323
  captionLayout = 'buttons';
448
324
  }
325
+ var onSelect;
326
+ if (isDayPickerSingle(initialProps) ||
327
+ isDayPickerMultiple(initialProps) ||
328
+ isDayPickerRange(initialProps)) {
329
+ onSelect = initialProps.onSelect;
330
+ }
449
331
  var value = {
450
332
  captionLayout: captionLayout,
451
333
  className: initialProps.className,
@@ -485,6 +367,7 @@ function DayPickerProvider(props) {
485
367
  onMonthChange: initialProps.onMonthChange,
486
368
  onNextClick: initialProps.onNextClick,
487
369
  onPrevClick: initialProps.onPrevClick,
370
+ onSelect: onSelect,
488
371
  onWeekNumberClick: initialProps.onWeekNumberClick,
489
372
  pagedNavigation: initialProps.pagedNavigation,
490
373
  reverseMonths: initialProps.reverseMonths,
@@ -497,14 +380,14 @@ function DayPickerProvider(props) {
497
380
  today: (_d = initialProps.today) !== null && _d !== void 0 ? _d : defaults.today,
498
381
  weekStartsOn: initialProps.weekStartsOn
499
382
  };
500
- return (React.createElement(DayPickerContext.Provider, { value: value }, props.children));
383
+ return (React__default.createElement(DayPickerContext.Provider, { value: value }, props.children));
501
384
  }
502
385
 
503
386
  /**
504
- * Hook to access the [[DayPickerContext]].
387
+ * Hook to access the {@link DayPickerContextValue}.
505
388
  *
506
- * To use this hook make sure to wrap the components with a one
507
- * [[DayPickerProvider]].
389
+ * Use the DayPicker context to access to the props passed to DayPicker inside
390
+ * internal or custom components.
508
391
  */
509
392
  function useDayPicker() {
510
393
  var context = useContext(DayPickerContext);
@@ -517,15 +400,15 @@ function useDayPicker() {
517
400
  /** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
518
401
  function CaptionLabel(props) {
519
402
  var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, formatCaption = _a.formatters.formatCaption;
520
- return (React.createElement("h2", { className: classNames.caption_label, style: styles.caption_label, "aria-live": "polite", "aria-atomic": "true", id: props.id }, formatCaption(props.displayMonth, { locale: locale })));
403
+ return (React__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 })));
521
404
  }
522
405
 
523
406
  /**
524
407
  * Render the icon in the styled drop-down.
525
408
  */
526
409
  function IconDropdown(props) {
527
- return (React.createElement("svg", __assign({ width: "8px", height: "8px", viewBox: "0 0 120 120", "data-testid": "iconDropdown" }, props),
528
- React.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" })));
410
+ return (React__default.createElement("svg", __assign({ width: "8px", height: "8px", viewBox: "0 0 120 120", "data-testid": "iconDropdown" }, props),
411
+ React__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" })));
529
412
  }
530
413
 
531
414
  /**
@@ -537,12 +420,12 @@ function Dropdown(props) {
537
420
  var onChange = props.onChange, value = props.value, children = props.children, caption = props.caption, className = props.className, style = props.style;
538
421
  var dayPicker = useDayPicker();
539
422
  var IconDropdownComponent = (_b = (_a = dayPicker.components) === null || _a === void 0 ? void 0 : _a.IconDropdown) !== null && _b !== void 0 ? _b : IconDropdown;
540
- return (React.createElement("div", { className: className, style: style },
541
- React.createElement("span", { className: dayPicker.classNames.vhidden }, props['aria-label']),
542
- React.createElement("select", { "aria-label": props['aria-label'], className: dayPicker.classNames.dropdown, style: dayPicker.styles.dropdown, value: value, onChange: onChange }, children),
543
- React.createElement("div", { className: dayPicker.classNames.caption_label, style: dayPicker.styles.caption_label, "aria-hidden": "true" },
423
+ return (React__default.createElement("div", { className: className, style: style },
424
+ React__default.createElement("span", { className: dayPicker.classNames.vhidden }, props['aria-label']),
425
+ React__default.createElement("select", { "aria-label": props['aria-label'], className: dayPicker.classNames.dropdown, style: dayPicker.styles.dropdown, value: value, onChange: onChange }, children),
426
+ React__default.createElement("div", { className: dayPicker.classNames.caption_label, style: dayPicker.styles.caption_label, "aria-hidden": "true" },
544
427
  caption,
545
- React.createElement(IconDropdownComponent, { className: dayPicker.classNames.dropdown_icon, style: dayPicker.styles.dropdown_icon }))));
428
+ React__default.createElement(IconDropdownComponent, { className: dayPicker.classNames.dropdown_icon, style: dayPicker.styles.dropdown_icon }))));
546
429
  }
547
430
 
548
431
  /** Render the dropdown to navigate between months. */
@@ -551,9 +434,9 @@ function MonthsDropdown(props) {
551
434
  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;
552
435
  // Dropdown should appear only when both from/toDate is set
553
436
  if (!fromDate)
554
- return React.createElement(React.Fragment, null);
437
+ return React__default.createElement(React__default.Fragment, null);
555
438
  if (!toDate)
556
- return React.createElement(React.Fragment, null);
439
+ return React__default.createElement(React__default.Fragment, null);
557
440
  var dropdownMonths = [];
558
441
  if (isSameYear(fromDate, toDate)) {
559
442
  // only display the months included in the range
@@ -575,7 +458,7 @@ function MonthsDropdown(props) {
575
458
  props.onChange(newMonth);
576
459
  };
577
460
  var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
578
- return (React.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.createElement("option", { key: m.getMonth(), value: m.getMonth() }, formatMonthCaption(m, { locale: locale }))); })));
461
+ return (React__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.createElement("option", { key: m.getMonth(), value: m.getMonth() }, formatMonthCaption(m, { locale: locale }))); })));
579
462
  }
580
463
 
581
464
  /**
@@ -589,9 +472,9 @@ function YearsDropdown(props) {
589
472
  var years = [];
590
473
  // Dropdown should appear only when both from/toDate is set
591
474
  if (!fromDate)
592
- return React.createElement(React.Fragment, null);
475
+ return React__default.createElement(React__default.Fragment, null);
593
476
  if (!toDate)
594
- return React.createElement(React.Fragment, null);
477
+ return React__default.createElement(React__default.Fragment, null);
595
478
  var fromYear = fromDate.getFullYear();
596
479
  var toYear = toDate.getFullYear();
597
480
  for (var year = fromYear; year <= toYear; year++) {
@@ -602,7 +485,7 @@ function YearsDropdown(props) {
602
485
  props.onChange(newMonth);
603
486
  };
604
487
  var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
605
- return (React.createElement(DropdownComponent, { "aria-label": labelYearDropdown(), className: classNames.dropdown_year, style: styles.dropdown_year, onChange: handleChange, value: displayMonth.getFullYear(), caption: formatYearCaption(displayMonth, { locale: locale }) }, years.map(function (year) { return (React.createElement("option", { key: year.getFullYear(), value: year.getFullYear() }, formatYearCaption(year, { locale: locale }))); })));
488
+ return (React__default.createElement(DropdownComponent, { "aria-label": labelYearDropdown(), className: classNames.dropdown_year, style: styles.dropdown_year, onChange: handleChange, value: displayMonth.getFullYear(), caption: formatYearCaption(displayMonth, { locale: locale }) }, years.map(function (year) { return (React__default.createElement("option", { key: year.getFullYear(), value: year.getFullYear() }, formatYearCaption(year, { locale: locale }))); })));
606
489
  }
607
490
 
608
491
  /**
@@ -643,9 +526,12 @@ function useNavigationState() {
643
526
  var initialMonth = getInitialMonth(context);
644
527
  var _a = useControlledValue(initialMonth, context.month), month = _a[0], setMonth = _a[1];
645
528
  var goToMonth = function (date) {
529
+ var _a;
646
530
  if (context.disableNavigation)
647
531
  return;
648
- setMonth(startOfMonth(date));
532
+ var month = startOfMonth(date);
533
+ setMonth(month);
534
+ (_a = context.onMonthChange) === null || _a === void 0 ? void 0 : _a.call(context, month);
649
535
  };
650
536
  return [month, goToMonth];
651
537
  }
@@ -727,12 +613,11 @@ function getPreviousMonth(startingMonth, options) {
727
613
  }
728
614
 
729
615
  /**
730
- * The Navigation context shares details about the months being navigated in DayPicker.
731
- *
732
- * Access this context from the [[useNavigation]] hook.
616
+ * The Navigation context shares details and methods to navigate the months in DayPicker.
617
+ * Access this context from the {@link useNavigation} hook.
733
618
  */
734
619
  var NavigationContext = createContext(undefined);
735
- /** Provides the values for the [[NavigationContext]]. */
620
+ /** Provides the values for the {@link NavigationContext}. */
736
621
  function NavigationProvider(props) {
737
622
  var dayPicker = useDayPicker();
738
623
  var _a = useNavigationState(), currentMonth = _a[0], goToMonth = _a[1];
@@ -764,10 +649,15 @@ function NavigationProvider(props) {
764
649
  nextMonth: nextMonth,
765
650
  isDateDisplayed: isDateDisplayed
766
651
  };
767
- return (React.createElement(NavigationContext.Provider, { value: value }, props.children));
652
+ return (React__default.createElement(NavigationContext.Provider, { value: value }, props.children));
768
653
  }
769
654
 
770
- /** Hook to access the [[NavigationContext]]. */
655
+ /**
656
+ * Hook to access the {@link NavigationContextValue}. Use this hook to navigate
657
+ * between months or years in DayPicker.
658
+ *
659
+ * This hook is meant to be used inside internal or custom components.
660
+ */
771
661
  function useNavigation() {
772
662
  var context = useContext(NavigationContext);
773
663
  if (!context) {
@@ -781,34 +671,33 @@ function useNavigation() {
781
671
  */
782
672
  function CaptionDropdowns(props) {
783
673
  var _a;
784
- var _b = useDayPicker(), classNames = _b.classNames, styles = _b.styles, onMonthChange = _b.onMonthChange, components = _b.components;
674
+ var _b = useDayPicker(), classNames = _b.classNames, styles = _b.styles, components = _b.components;
785
675
  var goToMonth = useNavigation().goToMonth;
786
676
  var handleMonthChange = function (newMonth) {
787
677
  goToMonth(newMonth);
788
- onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(newMonth);
789
678
  };
790
679
  var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
791
- var captionLabel = (React.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
792
- return (React.createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
793
- React.createElement("div", { className: classNames.vhidden }, captionLabel),
794
- React.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
795
- React.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
680
+ var captionLabel = (React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
681
+ return (React__default.createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
682
+ React__default.createElement("div", { className: classNames.vhidden }, captionLabel),
683
+ React__default.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
684
+ React__default.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
796
685
  }
797
686
 
798
687
  /**
799
688
  * Render the "previous month" button in the navigation.
800
689
  */
801
690
  function IconLeft(props) {
802
- return (React.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
803
- React.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" })));
691
+ return (React__default.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
692
+ React__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" })));
804
693
  }
805
694
 
806
695
  /**
807
696
  * Render the "next month" button in the navigation.
808
697
  */
809
698
  function IconRight(props) {
810
- return (React.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
811
- React.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" })));
699
+ return (React__default.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
700
+ React__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" })));
812
701
  }
813
702
 
814
703
  /**
@@ -825,7 +714,7 @@ var Button = forwardRef(function (props, ref) {
825
714
  if (props.style) {
826
715
  Object.assign(style, props.style);
827
716
  }
828
- return (React.createElement("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
717
+ return (React__default.createElement("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
829
718
  });
830
719
 
831
720
  /** A component rendering the navigation buttons or the drop-downs. */
@@ -833,7 +722,7 @@ function Navigation(props) {
833
722
  var _a, _b;
834
723
  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;
835
724
  if (!props.nextMonth && !props.previousMonth) {
836
- return React.createElement(React.Fragment, null);
725
+ return React__default.createElement(React__default.Fragment, null);
837
726
  }
838
727
  var previousLabel = labelPrevious(props.previousMonth, { locale: locale });
839
728
  var previousClassName = [
@@ -847,9 +736,9 @@ function Navigation(props) {
847
736
  ].join(' ');
848
737
  var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
849
738
  var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
850
- return (React.createElement("div", { className: classNames.nav, style: styles.nav },
851
- !props.hidePrevious && (React.createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, "aria-disabled": !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
852
- !props.hideNext && (React.createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, "aria-disabled": !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
739
+ return (React__default.createElement("div", { className: classNames.nav, style: styles.nav },
740
+ !props.hidePrevious && (React__default.createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React__default.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
741
+ !props.hideNext && (React__default.createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React__default.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
853
742
  }
854
743
 
855
744
  /**
@@ -858,7 +747,7 @@ function Navigation(props) {
858
747
  function CaptionNavigation(props) {
859
748
  var _a;
860
749
  var _b;
861
- var _c = useDayPicker(), numberOfMonths = _c.numberOfMonths, onMonthChange = _c.onMonthChange, dir = _c.dir, components = _c.components;
750
+ var _c = useDayPicker(), numberOfMonths = _c.numberOfMonths, dir = _c.dir, components = _c.components;
862
751
  var _d = useNavigation(), previousMonth = _d.previousMonth, nextMonth = _d.nextMonth, goToMonth = _d.goToMonth, displayMonths = _d.displayMonths;
863
752
  var displayIndex = displayMonths.findIndex(function (month) {
864
753
  return isSameMonth(props.displayMonth, month);
@@ -874,24 +763,22 @@ function CaptionNavigation(props) {
874
763
  if (!previousMonth)
875
764
  return;
876
765
  goToMonth(previousMonth);
877
- onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(previousMonth);
878
766
  };
879
767
  var handleNextClick = function () {
880
768
  if (!nextMonth)
881
769
  return;
882
770
  goToMonth(nextMonth);
883
- onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(nextMonth);
884
771
  };
885
772
  var CaptionLabelComponent = (_b = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _b !== void 0 ? _b : CaptionLabel;
886
- var captionLabel = (React.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
887
- return (React.createElement(React.Fragment, null,
773
+ var captionLabel = (React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
774
+ return (React__default.createElement(React__default.Fragment, null,
888
775
  captionLabel,
889
- React.createElement(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })));
776
+ React__default.createElement(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })));
890
777
  }
891
778
 
892
779
  /**
893
780
  * Render the caption of a month. The caption has a different layout when
894
- * setting the [[DayPickerProps.captionLayout]] prop.
781
+ * setting the {@link DayPickerBase.captionLayout} prop.
895
782
  */
896
783
  function Caption(props) {
897
784
  var _a;
@@ -899,25 +786,25 @@ function Caption(props) {
899
786
  var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
900
787
  var caption;
901
788
  if (disableNavigation) {
902
- caption = (React.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
789
+ caption = (React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
903
790
  }
904
791
  else if (captionLayout === 'dropdown') {
905
- caption = (React.createElement(CaptionDropdowns, { displayMonth: props.displayMonth, id: props.id }));
792
+ caption = (React__default.createElement(CaptionDropdowns, { displayMonth: props.displayMonth, id: props.id }));
906
793
  }
907
794
  else {
908
- caption = (React.createElement(CaptionNavigation, { displayMonth: props.displayMonth, id: props.id }));
795
+ caption = (React__default.createElement(CaptionNavigation, { displayMonth: props.displayMonth, id: props.id }));
909
796
  }
910
- return (React.createElement("div", { className: classNames.caption, style: styles.caption }, caption));
797
+ return (React__default.createElement("div", { className: classNames.caption, style: styles.caption }, caption));
911
798
  }
912
799
 
913
800
  /** Render the Footer component (empty as default).*/
914
801
  function Footer() {
915
802
  var _a = useDayPicker(), footer = _a.footer, styles = _a.styles, tfoot = _a.classNames.tfoot;
916
803
  if (!footer)
917
- return React.createElement(React.Fragment, null);
918
- return (React.createElement("tfoot", { className: tfoot, style: styles.tfoot },
919
- React.createElement("tr", null,
920
- React.createElement("td", { colSpan: 8 }, footer))));
804
+ return React__default.createElement(React__default.Fragment, null);
805
+ return (React__default.createElement("tfoot", { className: tfoot, style: styles.tfoot },
806
+ React__default.createElement("tr", null,
807
+ React__default.createElement("td", { colSpan: 8 }, footer))));
921
808
  }
922
809
 
923
810
  /**
@@ -942,12 +829,12 @@ weekStartsOn) {
942
829
  function Head() {
943
830
  var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, weekStartsOn = _a.weekStartsOn, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
944
831
  var weekdays = getWeekdays(locale, weekStartsOn);
945
- return (React.createElement("thead", { style: styles.head, className: classNames.head },
946
- React.createElement("tr", { style: styles.head_row, className: classNames.head_row },
947
- showWeekNumber && (React.createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
948
- weekdays.map(function (weekday, i) { return (React.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell },
949
- React.createElement("span", { "aria-hidden": true }, formatWeekdayName(weekday, { locale: locale })),
950
- React.createElement("span", { className: classNames.vhidden }, labelWeekday(weekday, { locale: locale })))); }))));
832
+ return (React__default.createElement("thead", { style: styles.head, className: classNames.head },
833
+ React__default.createElement("tr", { style: styles.head_row, className: classNames.head_row },
834
+ showWeekNumber && (React__default.createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
835
+ weekdays.map(function (weekday, i) { return (React__default.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell },
836
+ React__default.createElement("span", { "aria-hidden": true }, formatWeekdayName(weekday, { locale: locale })),
837
+ React__default.createElement("span", { className: classNames.vhidden }, labelWeekday(weekday, { locale: locale })))); }))));
951
838
  }
952
839
 
953
840
  /**
@@ -955,24 +842,19 @@ function Head() {
955
842
  */
956
843
  function DayContent(props) {
957
844
  var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, labelDay = _a.labels.labelDay, formatDay = _a.formatters.formatDay;
958
- return (React.createElement(React.Fragment, null,
959
- React.createElement("span", { "aria-hidden": "true" }, formatDay(props.date, { locale: locale })),
960
- React.createElement("span", { className: classNames.vhidden, style: styles.vhidden }, labelDay(props.date, props.activeModifiers, { locale: locale }))));
961
- }
962
-
963
- /** Returns true when the props are of type [[DayPickerMultiple]]. */
964
- function isDayPickerMultiple(props) {
965
- return props.mode === 'multiple';
845
+ return (React__default.createElement(React__default.Fragment, null,
846
+ React__default.createElement("span", { "aria-hidden": "true" }, formatDay(props.date, { locale: locale })),
847
+ React__default.createElement("span", { className: classNames.vhidden, style: styles.vhidden }, labelDay(props.date, props.activeModifiers, { locale: locale }))));
966
848
  }
967
849
 
968
850
  /**
969
851
  * The SelectMultiple context shares details about the selected days when in
970
852
  * multiple selection mode.
971
853
  *
972
- * Access this context from the [[useSelectMultiple]] hook.
854
+ * Access this context from the {@link useSelectMultiple} hook.
973
855
  */
974
856
  var SelectMultipleContext = createContext(undefined);
975
- /** Provides the values for the [[SelectMultipleContext]]. */
857
+ /** Provides the values for the {@link SelectMultipleContext}. */
976
858
  function SelectMultipleProvider(props) {
977
859
  if (!isDayPickerMultiple(props.initialProps)) {
978
860
  var emptyContextValue = {
@@ -981,9 +863,9 @@ function SelectMultipleProvider(props) {
981
863
  disabled: []
982
864
  }
983
865
  };
984
- return (React.createElement(SelectMultipleContext.Provider, { value: emptyContextValue }, props.children));
866
+ return (React__default.createElement(SelectMultipleContext.Provider, { value: emptyContextValue }, props.children));
985
867
  }
986
- return (React.createElement(SelectMultipleProviderInternal, { initialProps: props.initialProps, children: props.children }));
868
+ return (React__default.createElement(SelectMultipleProviderInternal, { initialProps: props.initialProps, children: props.children }));
987
869
  }
988
870
  function SelectMultipleProviderInternal(_a) {
989
871
  var initialProps = _a.initialProps, children = _a.children;
@@ -1028,10 +910,14 @@ function SelectMultipleProviderInternal(_a) {
1028
910
  onDayClick: onDayClick,
1029
911
  modifiers: modifiers
1030
912
  };
1031
- return (React.createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
913
+ return (React__default.createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
1032
914
  }
1033
915
 
1034
- /** Hook to access the [[SelectMultipleContext]]. */
916
+ /**
917
+ * Hook to access the {@link SelectMultipleContextValue}.
918
+ *
919
+ * This hook is meant to be used inside internal or custom components.
920
+ */
1035
921
  function useSelectMultiple() {
1036
922
  var context = useContext(SelectMultipleContext);
1037
923
  if (!context) {
@@ -1040,11 +926,6 @@ function useSelectMultiple() {
1040
926
  return context;
1041
927
  }
1042
928
 
1043
- /** Returns true when the props are of type [[DayPickerRange]]. */
1044
- function isDayPickerRange(props) {
1045
- return props.mode === 'range';
1046
- }
1047
-
1048
929
  /**
1049
930
  * Add a day to an existing range.
1050
931
  *
@@ -1084,10 +965,10 @@ function addToRange(day, range) {
1084
965
  * The SelectRange context shares details about the selected days when in
1085
966
  * range selection mode.
1086
967
  *
1087
- * Access this context from the [[useSelectRange]] hook.
968
+ * Access this context from the {@link useSelectRange} hook.
1088
969
  */
1089
970
  var SelectRangeContext = createContext(undefined);
1090
- /** Provides the values for the [[SelectRangeProvider]]. */
971
+ /** Provides the values for the {@link SelectRangeProvider}. */
1091
972
  function SelectRangeProvider(props) {
1092
973
  if (!isDayPickerRange(props.initialProps)) {
1093
974
  var emptyContextValue = {
@@ -1099,9 +980,9 @@ function SelectRangeProvider(props) {
1099
980
  disabled: []
1100
981
  }
1101
982
  };
1102
- return (React.createElement(SelectRangeContext.Provider, { value: emptyContextValue }, props.children));
983
+ return (React__default.createElement(SelectRangeContext.Provider, { value: emptyContextValue }, props.children));
1103
984
  }
1104
- return (React.createElement(SelectRangeProviderInternal, { initialProps: props.initialProps, children: props.children }));
985
+ return (React__default.createElement(SelectRangeProviderInternal, { initialProps: props.initialProps, children: props.children }));
1105
986
  }
1106
987
  function SelectRangeProviderInternal(_a) {
1107
988
  var initialProps = _a.initialProps, children = _a.children;
@@ -1162,10 +1043,14 @@ function SelectRangeProviderInternal(_a) {
1162
1043
  differenceInCalendarDays(date, selectedFrom) >= max));
1163
1044
  });
1164
1045
  }
1165
- return (React.createElement(SelectRangeContext.Provider, { value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, children));
1046
+ return (React__default.createElement(SelectRangeContext.Provider, { value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, children));
1166
1047
  }
1167
1048
 
1168
- /** Hook to access the [[SelectRangeContext]]. */
1049
+ /**
1050
+ * Hook to access the {@link SelectRangeContextValue}.
1051
+ *
1052
+ * This hook is meant to be used inside internal or custom components.
1053
+ */
1169
1054
  function useSelectRange() {
1170
1055
  var context = useContext(SelectRangeContext);
1171
1056
  if (!context) {
@@ -1218,7 +1103,7 @@ var InternalModifier;
1218
1103
  })(InternalModifier || (InternalModifier = {}));
1219
1104
 
1220
1105
  var Selected = InternalModifier.Selected, Disabled = InternalModifier.Disabled, Hidden = InternalModifier.Hidden, Today = InternalModifier.Today, RangeEnd = InternalModifier.RangeEnd, RangeMiddle = InternalModifier.RangeMiddle, RangeStart = InternalModifier.RangeStart, Outside = InternalModifier.Outside;
1221
- /** Return the [[InternalModifiers]] from the DayPicker and select contexts. */
1106
+ /** Return the {@link InternalModifiers} from the DayPicker and select contexts. */
1222
1107
  function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
1223
1108
  var _a;
1224
1109
  var internalModifiers = (_a = {},
@@ -1249,9 +1134,9 @@ function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
1249
1134
  return internalModifiers;
1250
1135
  }
1251
1136
 
1252
- /** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use [[useModifiers]]. */
1137
+ /** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use {@link useModifiers}. */
1253
1138
  var ModifiersContext = createContext(undefined);
1254
- /** Provide the value for the [[ModifiersContext]]. */
1139
+ /** Provide the value for the {@link ModifiersContext}. */
1255
1140
  function ModifiersProvider(props) {
1256
1141
  var dayPicker = useDayPicker();
1257
1142
  var selectMultiple = useSelectMultiple();
@@ -1259,13 +1144,16 @@ function ModifiersProvider(props) {
1259
1144
  var internalModifiers = getInternalModifiers(dayPicker, selectMultiple, selectRange);
1260
1145
  var customModifiers = getCustomModifiers(dayPicker.modifiers);
1261
1146
  var modifiers = __assign(__assign({}, internalModifiers), customModifiers);
1262
- return (React.createElement(ModifiersContext.Provider, { value: modifiers }, props.children));
1147
+ return (React__default.createElement(ModifiersContext.Provider, { value: modifiers }, props.children));
1263
1148
  }
1264
1149
 
1265
1150
  /**
1266
1151
  * Return the modifiers used by DayPicker.
1267
1152
  *
1268
- * Requires to be wrapped into [[ModifiersProvider]]. */
1153
+ * This hook is meant to be used inside internal or custom components.
1154
+ * Requires to be wrapped into {@link ModifiersProvider}.
1155
+ *
1156
+ */
1269
1157
  function useModifiers() {
1270
1158
  var context = useContext(ModifiersContext);
1271
1159
  if (!context) {
@@ -1274,26 +1162,26 @@ function useModifiers() {
1274
1162
  return context;
1275
1163
  }
1276
1164
 
1277
- /** Returns true if `matcher` is of type [[DateInterval]]. */
1165
+ /** Returns true if `matcher` is of type {@link DateInterval}. */
1278
1166
  function isDateInterval(matcher) {
1279
1167
  return Boolean(matcher &&
1280
1168
  typeof matcher === 'object' &&
1281
1169
  'before' in matcher &&
1282
1170
  'after' in matcher);
1283
1171
  }
1284
- /** Returns true if `value` is a [[DateRange]] type. */
1172
+ /** Returns true if `value` is a {@link DateRange} type. */
1285
1173
  function isDateRange(value) {
1286
1174
  return Boolean(value && typeof value === 'object' && 'from' in value);
1287
1175
  }
1288
- /** Returns true if `value` is of type [[DateAfter]]. */
1176
+ /** Returns true if `value` is of type {@link DateAfter}. */
1289
1177
  function isDateAfterType(value) {
1290
1178
  return Boolean(value && typeof value === 'object' && 'after' in value);
1291
1179
  }
1292
- /** Returns true if `value` is of type [[DateBefore]]. */
1180
+ /** Returns true if `value` is of type {@link DateBefore}. */
1293
1181
  function isDateBeforeType(value) {
1294
1182
  return Boolean(value && typeof value === 'object' && 'before' in value);
1295
1183
  }
1296
- /** Returns true if `value` is a [[DayOfWeek]] type. */
1184
+ /** Returns true if `value` is a {@link DayOfWeek} type. */
1297
1185
  function isDayOfWeekType(value) {
1298
1186
  return Boolean(value && typeof value === 'object' && 'dayOfWeek' in value);
1299
1187
  }
@@ -1434,13 +1322,43 @@ function getInitialFocusTarget(displayMonths, modifiers) {
1434
1322
  }
1435
1323
  }
1436
1324
 
1325
+ /** Return the next date to be focused. */
1326
+ function getNextFocus(
1327
+ /** The day that is focused. */
1328
+ focusedDay, moveBy, direction, options, modifiers) {
1329
+ var weekStartsOn = options.weekStartsOn, fromDate = options.fromDate, toDate = options.toDate, locale = options.locale;
1330
+ var moveFns = {
1331
+ day: addDays,
1332
+ week: addWeeks,
1333
+ month: addMonths,
1334
+ year: addYears,
1335
+ startOfWeek: function (date) { return startOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn }); },
1336
+ endOfWeek: function (date) { return endOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn }); }
1337
+ };
1338
+ var newFocusedDay = moveFns[moveBy](focusedDay, direction === 'after' ? 1 : -1);
1339
+ if (direction === 'before' && fromDate) {
1340
+ newFocusedDay = max([fromDate, newFocusedDay]);
1341
+ }
1342
+ else if (direction === 'after' && toDate) {
1343
+ newFocusedDay = min([toDate, newFocusedDay]);
1344
+ }
1345
+ if (modifiers) {
1346
+ var activeModifiers = getActiveModifiers(newFocusedDay, modifiers);
1347
+ var isFocusable = !activeModifiers.disabled && !activeModifiers.hidden;
1348
+ if (!isFocusable) {
1349
+ return getNextFocus(newFocusedDay, moveBy, direction, options, modifiers);
1350
+ }
1351
+ }
1352
+ return newFocusedDay;
1353
+ }
1354
+
1437
1355
  /**
1438
1356
  * The Focus context shares details about the focused day for the keyboard
1439
1357
  *
1440
- * Access this context from the [[useFocus]] hook.
1358
+ * Access this context from the {@link useFocusContext} hook.
1441
1359
  */
1442
1360
  var FocusContext = createContext(undefined);
1443
- /** The provider for the [[FocusContext]]. */
1361
+ /** The provider for the {@link FocusContext}. */
1444
1362
  function FocusProvider(props) {
1445
1363
  var navigation = useNavigation();
1446
1364
  var modifiers = useModifiers();
@@ -1458,96 +1376,41 @@ function FocusProvider(props) {
1458
1376
  var focus = function (date) {
1459
1377
  setFocusedDay(date);
1460
1378
  };
1461
- var focusDayBefore = function () {
1462
- if (!focusedDay)
1463
- return;
1464
- var before = addDays(focusedDay, -1);
1465
- focus(before);
1466
- navigation.goToDate(before, focusedDay);
1467
- };
1468
- var focusDayAfter = function () {
1469
- if (!focusedDay)
1470
- return;
1471
- var after = addDays(focusedDay, 1);
1472
- focus(after);
1473
- navigation.goToDate(after, focusedDay);
1474
- };
1475
- var focusWeekBefore = function () {
1476
- if (!focusedDay)
1477
- return;
1478
- var up = addWeeks(focusedDay, -1);
1479
- focus(up);
1480
- navigation.goToDate(up, focusedDay);
1481
- };
1482
- var focusWeekAfter = function () {
1483
- if (!focusedDay)
1484
- return;
1485
- var down = addWeeks(focusedDay, 1);
1486
- focus(down);
1487
- navigation.goToDate(down, focusedDay);
1488
- };
1489
- var focusStartOfWeek = function () {
1490
- if (!focusedDay)
1491
- return;
1492
- var dayToFocus = startOfWeek(focusedDay);
1493
- navigation.goToDate(dayToFocus, focusedDay);
1494
- focus(dayToFocus);
1495
- };
1496
- var focusEndOfWeek = function () {
1497
- if (!focusedDay)
1498
- return;
1499
- var dayToFocus = endOfWeek(focusedDay);
1500
- navigation.goToDate(dayToFocus, focusedDay);
1501
- focus(dayToFocus);
1502
- };
1503
- var focusMonthBefore = function () {
1504
- if (!focusedDay)
1505
- return;
1506
- var monthBefore = addMonths(focusedDay, -1);
1507
- navigation.goToDate(monthBefore, focusedDay);
1508
- focus(monthBefore);
1509
- };
1510
- var focusMonthAfter = function () {
1511
- if (!focusedDay)
1512
- return;
1513
- var monthAfter = addMonths(focusedDay, 1);
1514
- navigation.goToDate(monthAfter, focusedDay);
1515
- focus(monthAfter);
1516
- };
1517
- var focusYearBefore = function () {
1518
- if (!focusedDay)
1519
- return;
1520
- var yearBefore = addYears(focusedDay, -1);
1521
- navigation.goToDate(yearBefore, focusedDay);
1522
- focus(yearBefore);
1523
- };
1524
- var focusYearAfter = function () {
1379
+ var dayPicker = useDayPicker();
1380
+ var moveFocus = function (moveBy, direction) {
1525
1381
  if (!focusedDay)
1526
1382
  return;
1527
- var yearAfter = addYears(focusedDay, 1);
1528
- navigation.goToDate(yearAfter, focusedDay);
1529
- focus(yearAfter);
1383
+ var nextFocused = getNextFocus(focusedDay, moveBy, direction, dayPicker, modifiers);
1384
+ if (isSameDay(focusedDay, nextFocused))
1385
+ return undefined;
1386
+ navigation.goToDate(nextFocused, focusedDay);
1387
+ focus(nextFocused);
1530
1388
  };
1531
1389
  var value = {
1532
1390
  focusedDay: focusedDay,
1533
1391
  focusTarget: focusTarget,
1534
1392
  blur: blur,
1535
1393
  focus: focus,
1536
- focusDayAfter: focusDayAfter,
1537
- focusDayBefore: focusDayBefore,
1538
- focusWeekAfter: focusWeekAfter,
1539
- focusWeekBefore: focusWeekBefore,
1540
- focusMonthBefore: focusMonthBefore,
1541
- focusMonthAfter: focusMonthAfter,
1542
- focusYearBefore: focusYearBefore,
1543
- focusYearAfter: focusYearAfter,
1544
- focusStartOfWeek: focusStartOfWeek,
1545
- focusEndOfWeek: focusEndOfWeek
1394
+ focusDayAfter: function () { return moveFocus('day', 'after'); },
1395
+ focusDayBefore: function () { return moveFocus('day', 'before'); },
1396
+ focusWeekAfter: function () { return moveFocus('week', 'after'); },
1397
+ focusWeekBefore: function () { return moveFocus('week', 'before'); },
1398
+ focusMonthBefore: function () { return moveFocus('month', 'before'); },
1399
+ focusMonthAfter: function () { return moveFocus('month', 'after'); },
1400
+ focusYearBefore: function () { return moveFocus('year', 'before'); },
1401
+ focusYearAfter: function () { return moveFocus('year', 'after'); },
1402
+ focusStartOfWeek: function () { return moveFocus('startOfWeek', 'before'); },
1403
+ focusEndOfWeek: function () { return moveFocus('endOfWeek', 'after'); }
1546
1404
  };
1547
- return (React.createElement(FocusContext.Provider, { value: value }, props.children));
1405
+ return (React__default.createElement(FocusContext.Provider, { value: value }, props.children));
1548
1406
  }
1549
1407
 
1550
- /** Hook to access the [[FocusContext]]. */
1408
+ /**
1409
+ * Hook to access the {@link FocusContextValue}. Use this hook to handle the
1410
+ * focus state of the elements.
1411
+ *
1412
+ * This hook is meant to be used inside internal or custom components.
1413
+ */
1551
1414
  function useFocusContext() {
1552
1415
  var context = useContext(FocusContext);
1553
1416
  if (!context) {
@@ -1559,37 +1422,38 @@ function useFocusContext() {
1559
1422
  /**
1560
1423
  * Return the active modifiers for the specified day.
1561
1424
  *
1425
+ * This hook is meant to be used inside internal or custom components.
1426
+ *
1562
1427
  * @param day
1563
- * @param displayMonth The month where the date is displayed. If not the same as
1564
- * `date`, the day is an "outside day".
1428
+ * @param displayMonth
1429
+ */
1430
+ function useActiveModifiers(day,
1431
+ /**
1432
+ * The month where the date is displayed. If not the same as `date`, the day
1433
+ * is an "outside day".
1565
1434
  */
1566
- function useActiveModifiers(day, displayMonth) {
1435
+ displayMonth) {
1567
1436
  var modifiers = useModifiers();
1568
1437
  var activeModifiers = getActiveModifiers(day, modifiers, displayMonth);
1569
1438
  return activeModifiers;
1570
1439
  }
1571
1440
 
1572
- /** Returns true when the props are of type [[DayPickerSingle]]. */
1573
- function isDayPickerSingle(props) {
1574
- return props.mode === 'single';
1575
- }
1576
-
1577
1441
  /**
1578
1442
  * The SelectSingle context shares details about the selected days when in
1579
1443
  * single selection mode.
1580
1444
  *
1581
- * Access this context from the [[useSelectSingle]] hook.
1445
+ * Access this context from the {@link useSelectSingle} hook.
1582
1446
  */
1583
1447
  var SelectSingleContext = createContext(undefined);
1584
- /** Provides the values for the [[SelectSingleProvider]]. */
1448
+ /** Provides the values for the {@link SelectSingleProvider}. */
1585
1449
  function SelectSingleProvider(props) {
1586
1450
  if (!isDayPickerSingle(props.initialProps)) {
1587
1451
  var emptyContextValue = {
1588
1452
  selected: undefined
1589
1453
  };
1590
- return (React.createElement(SelectSingleContext.Provider, { value: emptyContextValue }, props.children));
1454
+ return (React__default.createElement(SelectSingleContext.Provider, { value: emptyContextValue }, props.children));
1591
1455
  }
1592
- return (React.createElement(SelectSingleProviderInternal, { initialProps: props.initialProps, children: props.children }));
1456
+ return (React__default.createElement(SelectSingleProviderInternal, { initialProps: props.initialProps, children: props.children }));
1593
1457
  }
1594
1458
  function SelectSingleProviderInternal(_a) {
1595
1459
  var initialProps = _a.initialProps, children = _a.children;
@@ -1606,10 +1470,14 @@ function SelectSingleProviderInternal(_a) {
1606
1470
  selected: initialProps.selected,
1607
1471
  onDayClick: onDayClick
1608
1472
  };
1609
- return (React.createElement(SelectSingleContext.Provider, { value: contextValue }, children));
1473
+ return (React__default.createElement(SelectSingleContext.Provider, { value: contextValue }, children));
1610
1474
  }
1611
1475
 
1612
- /** Hook to access the [[SelectSingleContext]]. */
1476
+ /**
1477
+ * Hook to access the {@link SelectSingleContextValue}.
1478
+ *
1479
+ * This hook is meant to be used inside internal or custom components.
1480
+ */
1613
1481
  function useSelectSingle() {
1614
1482
  var context = useContext(SelectSingleContext);
1615
1483
  if (!context) {
@@ -1633,9 +1501,9 @@ function useSelectSingle() {
1633
1501
  *
1634
1502
  * ### Usage
1635
1503
  *
1636
- * Use this hook to customize the behavior of the [[Day]] component. Create a
1504
+ * Use this hook to customize the behavior of the {@link Day} component. Create a
1637
1505
  * new `Day` component using this hook and pass it to the `components` prop.
1638
- * The source of [[Day]] can be a good starting point.
1506
+ * The source of {@link Day} can be a good starting point.
1639
1507
  *
1640
1508
  */
1641
1509
  function useDayEventHandlers(date, activeModifiers) {
@@ -1758,9 +1626,11 @@ function useDayEventHandlers(date, activeModifiers) {
1758
1626
  }
1759
1627
 
1760
1628
  /**
1761
- * Return the current selected days when DayPicker is in selection mode.
1629
+ * Return the current selected days when DayPicker is in selection mode. Days
1630
+ * selected by the custom selection mode are not returned.
1631
+ *
1632
+ * This hook is meant to be used inside internal or custom components.
1762
1633
  *
1763
- * Days selected by the custom selection mode are not returned.
1764
1634
  */
1765
1635
  function useSelectedDays() {
1766
1636
  var dayPicker = useDayPicker();
@@ -1815,25 +1685,18 @@ function getDayStyle(dayPicker, activeModifiers) {
1815
1685
  }
1816
1686
 
1817
1687
  /**
1818
- * Return props and data used to render the [[Day]] component.
1688
+ * Return props and data used to render the {@link Day} component.
1819
1689
  *
1820
1690
  * Use this hook when creating a component to replace the built-in `Day`
1821
1691
  * component.
1822
- *
1823
- * Each Day in DayPicker should render one of the following, according to the return
1824
- * value:
1825
- *
1826
- * - an empty `React.Fragment`, to render if `isHidden` is true
1827
- * - a `button` element, when the day is interactive, e.g. is selectable
1828
- * - a `div` element, whe the day is not interactive
1829
- *
1830
- * @param day The date to render
1831
- * @param displayMonth The month where the date is displayed (if not the same as
1832
- * `date`, it means it is an "outside" day)
1833
- * @param buttonRef A ref to the button element that will be target of focus
1834
- * when rendered (if required).
1835
1692
  */
1836
- function useDayRender(day, displayMonth, buttonRef) {
1693
+ function useDayRender(
1694
+ /** The date to render. */
1695
+ day,
1696
+ /** The month where the date is displayed (if not the same as `date`, it means it is an "outside" day). */
1697
+ displayMonth,
1698
+ /** A ref to the button element that will be target of focus when rendered (if required). */
1699
+ buttonRef) {
1837
1700
  var _a;
1838
1701
  var _b, _c;
1839
1702
  var dayPicker = useDayPicker();
@@ -1866,14 +1729,14 @@ function useDayRender(day, displayMonth, buttonRef) {
1866
1729
  var isHidden = Boolean((activeModifiers.outside && !dayPicker.showOutsideDays) ||
1867
1730
  activeModifiers.hidden);
1868
1731
  var DayContentComponent = (_c = (_b = dayPicker.components) === null || _b === void 0 ? void 0 : _b.DayContent) !== null && _c !== void 0 ? _c : DayContent;
1869
- var children = (React.createElement(DayContentComponent, { date: day, displayMonth: displayMonth, activeModifiers: activeModifiers }));
1732
+ var children = (React__default.createElement(DayContentComponent, { date: day, displayMonth: displayMonth, activeModifiers: activeModifiers }));
1870
1733
  var divProps = {
1871
1734
  style: style,
1872
1735
  className: className,
1873
1736
  children: children
1874
1737
  };
1875
1738
  var isFocusTarget = Boolean(focusContext.focusTarget && isSameDay(focusContext.focusTarget, day));
1876
- var buttonProps = __assign(__assign(__assign({}, divProps), (_a = {}, _a['aria-disabled'] = activeModifiers.disabled, _a['aria-pressed'] = activeModifiers.selected, _a.tabIndex = isFocusTarget ? 0 : -1, _a)), eventHandlers);
1739
+ var buttonProps = __assign(__assign(__assign({}, divProps), (_a = { disabled: activeModifiers.disabled }, _a['aria-pressed'] = activeModifiers.selected, _a.tabIndex = isFocusTarget ? 0 : -1, _a)), eventHandlers);
1877
1740
  var dayRender = {
1878
1741
  isButton: isButton,
1879
1742
  isHidden: isHidden,
@@ -1893,12 +1756,12 @@ function Day(props) {
1893
1756
  var buttonRef = useRef(null);
1894
1757
  var dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
1895
1758
  if (dayRender.isHidden) {
1896
- return React.createElement(React.Fragment, null);
1759
+ return React__default.createElement(React__default.Fragment, null);
1897
1760
  }
1898
1761
  if (!dayRender.isButton) {
1899
- return React.createElement("div", __assign({}, dayRender.divProps));
1762
+ return React__default.createElement("div", __assign({}, dayRender.divProps));
1900
1763
  }
1901
- return React.createElement(Button, __assign({ ref: buttonRef }, dayRender.buttonProps));
1764
+ return React__default.createElement(Button, __assign({ ref: buttonRef }, dayRender.buttonProps));
1902
1765
  }
1903
1766
 
1904
1767
  /**
@@ -1910,13 +1773,13 @@ function WeekNumber(props) {
1910
1773
  var _a = useDayPicker(), onWeekNumberClick = _a.onWeekNumberClick, styles = _a.styles, classNames = _a.classNames, locale = _a.locale, labelWeekNumber = _a.labels.labelWeekNumber, formatWeekNumber = _a.formatters.formatWeekNumber;
1911
1774
  var content = formatWeekNumber(Number(weekNumber), { locale: locale });
1912
1775
  if (!onWeekNumberClick) {
1913
- return (React.createElement("span", { className: classNames.weeknumber, style: styles.weeknumber }, content));
1776
+ return (React__default.createElement("span", { className: classNames.weeknumber, style: styles.weeknumber }, content));
1914
1777
  }
1915
1778
  var label = labelWeekNumber(Number(weekNumber), { locale: locale });
1916
1779
  var handleClick = function (e) {
1917
1780
  onWeekNumberClick(weekNumber, dates, e);
1918
1781
  };
1919
- return (React.createElement(Button, { "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, content));
1782
+ return (React__default.createElement(Button, { "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, content));
1920
1783
  }
1921
1784
 
1922
1785
  /** Render a row in the calendar, with the days and the week number. */
@@ -1927,13 +1790,13 @@ function Row(props) {
1927
1790
  var WeeknumberComponent = (_b = components === null || components === void 0 ? void 0 : components.WeekNumber) !== null && _b !== void 0 ? _b : WeekNumber;
1928
1791
  var weekNumberCell;
1929
1792
  if (showWeekNumber) {
1930
- weekNumberCell = (React.createElement("td", { className: classNames.cell, style: styles.cell },
1931
- React.createElement(WeeknumberComponent, { number: props.weekNumber, dates: props.dates })));
1793
+ weekNumberCell = (React__default.createElement("td", { className: classNames.cell, style: styles.cell },
1794
+ React__default.createElement(WeeknumberComponent, { number: props.weekNumber, dates: props.dates })));
1932
1795
  }
1933
- return (React.createElement("tr", { className: classNames.row, style: styles.row },
1796
+ return (React__default.createElement("tr", { className: classNames.row, style: styles.row },
1934
1797
  weekNumberCell,
1935
- props.dates.map(function (date) { return (React.createElement("td", { className: classNames.cell, style: styles.cell, key: getUnixTime(date) },
1936
- React.createElement(DayComponent, { displayMonth: props.displayMonth, date: date }))); })));
1798
+ props.dates.map(function (date) { return (React__default.createElement("td", { className: classNames.cell, style: styles.cell, key: getUnixTime(date) },
1799
+ React__default.createElement(DayComponent, { displayMonth: props.displayMonth, date: date }))); })));
1937
1800
  }
1938
1801
 
1939
1802
  /** Return the weeks between two dates. */
@@ -1995,10 +1858,87 @@ function Table(props) {
1995
1858
  var HeadComponent = (_a = components === null || components === void 0 ? void 0 : components.Head) !== null && _a !== void 0 ? _a : Head;
1996
1859
  var RowComponent = (_b = components === null || components === void 0 ? void 0 : components.Row) !== null && _b !== void 0 ? _b : Row;
1997
1860
  var FooterComponent = (_c = components === null || components === void 0 ? void 0 : components.Footer) !== null && _c !== void 0 ? _c : Footer;
1998
- return (React.createElement("table", { className: classNames.table, style: styles.table, role: "grid", "aria-labelledby": props['aria-labelledby'] },
1999
- !hideHead && React.createElement(HeadComponent, null),
2000
- React.createElement("tbody", { className: classNames.tbody, style: styles.tbody }, weeks.map(function (week) { return (React.createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
2001
- React.createElement(FooterComponent, null)));
1861
+ return (React__default.createElement("table", { className: classNames.table, style: styles.table, role: "grid", "aria-labelledby": props['aria-labelledby'] },
1862
+ !hideHead && React__default.createElement(HeadComponent, null),
1863
+ React__default.createElement("tbody", { className: classNames.tbody, style: styles.tbody }, weeks.map(function (week) { return (React__default.createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
1864
+ React__default.createElement(FooterComponent, null)));
1865
+ }
1866
+
1867
+ /*
1868
+ The MIT License (MIT)
1869
+
1870
+ Copyright (c) 2018-present, React Training LLC
1871
+
1872
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1873
+
1874
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1875
+
1876
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1877
+ */
1878
+ function canUseDOM() {
1879
+ return !!(typeof window !== 'undefined' &&
1880
+ window.document &&
1881
+ window.document.createElement);
1882
+ }
1883
+ /**
1884
+ * React currently throws a warning when using useLayoutEffect on the server. To
1885
+ * get around it, we can conditionally useEffect on the server (no-op) and
1886
+ * useLayoutEffect in the browser. We occasionally need useLayoutEffect to
1887
+ * ensure we don't get a render flash for certain operations, but we may also
1888
+ * need affected components to render on the server. One example is when setting
1889
+ * a component's descendants to retrieve their index values.
1890
+ *
1891
+ * Important to note that using this hook as an escape hatch will break the
1892
+ * eslint dependency warnings unless you rename the import to `useLayoutEffect`.
1893
+ * Use sparingly only when the effect won't effect the rendered HTML to avoid
1894
+ * any server/client mismatch.
1895
+ *
1896
+ * If a useLayoutEffect is needed and the result would create a mismatch, it's
1897
+ * likely that the component in question shouldn't be rendered on the server at
1898
+ * all, so a better approach would be to lazily render those in a parent
1899
+ * component after client-side hydration.
1900
+ *
1901
+ * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
1902
+ * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
1903
+ *
1904
+ * @param effect
1905
+ * @param deps
1906
+ */
1907
+ var useIsomorphicLayoutEffect = canUseDOM()
1908
+ ? React.useLayoutEffect
1909
+ : React.useEffect;
1910
+ var serverHandoffComplete = false;
1911
+ var id = 0;
1912
+ function genId() {
1913
+ return "react-day-picker-".concat(++id);
1914
+ }
1915
+ function useId(providedId) {
1916
+ // TODO: Remove error flag when updating internal deps to React 18. None of
1917
+ // our tricks will play well with concurrent rendering anyway.
1918
+ var _a;
1919
+ // If this instance isn't part of the initial render, we don't have to do the
1920
+ // double render/patch-up dance. We can just generate the ID and return it.
1921
+ var initialId = providedId !== null && providedId !== void 0 ? providedId : (serverHandoffComplete ? genId() : null);
1922
+ var _b = React.useState(initialId), id = _b[0], setId = _b[1];
1923
+ useIsomorphicLayoutEffect(function () {
1924
+ if (id === null) {
1925
+ // Patch the ID after render. We do this in `useLayoutEffect` to avoid any
1926
+ // rendering flicker, though it'll make the first render slower (unlikely
1927
+ // to matter, but you're welcome to measure your app and let us know if
1928
+ // it's a problem).
1929
+ setId(genId());
1930
+ }
1931
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1932
+ }, []);
1933
+ React.useEffect(function () {
1934
+ if (serverHandoffComplete === false) {
1935
+ // Flag all future uses of `useId` to skip the update dance. This is in
1936
+ // `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
1937
+ // accidentally bail out of the patch-up dance prematurely.
1938
+ serverHandoffComplete = true;
1939
+ }
1940
+ }, []);
1941
+ return (_a = providedId !== null && providedId !== void 0 ? providedId : id) !== null && _a !== void 0 ? _a : undefined;
2002
1942
  }
2003
1943
 
2004
1944
  /** Render a month. */
@@ -2030,18 +1970,17 @@ function Month(props) {
2030
1970
  style = __assign(__assign({}, style), styles.caption_between);
2031
1971
  }
2032
1972
  var CaptionComponent = (_b = components === null || components === void 0 ? void 0 : components.Caption) !== null && _b !== void 0 ? _b : Caption;
2033
- return (React.createElement("div", { key: props.displayIndex, className: className.join(' '), style: style },
2034
- React.createElement(CaptionComponent, { id: captionId, displayMonth: props.displayMonth }),
2035
- React.createElement(Table, { "aria-labelledby": captionId, displayMonth: props.displayMonth })));
1973
+ return (React__default.createElement("div", { key: props.displayIndex, className: className.join(' '), style: style },
1974
+ React__default.createElement(CaptionComponent, { id: captionId, displayMonth: props.displayMonth }),
1975
+ React__default.createElement(Table, { "aria-labelledby": captionId, displayMonth: props.displayMonth })));
2036
1976
  }
2037
1977
 
2038
1978
  /** Render the container with the months according to the number of months to display. */
2039
1979
  function Root() {
2040
- var _a;
2041
1980
  var dayPicker = useDayPicker();
2042
1981
  var focusContext = useFocusContext();
2043
1982
  var navigation = useNavigation();
2044
- var _b = useState(false), hasInitialFocus = _b[0], setHasInitialFocus = _b[1];
1983
+ var _a = useState(false), hasInitialFocus = _a[0], setHasInitialFocus = _a[1];
2045
1984
  // Focus the focus target when initialFocus is passed in
2046
1985
  useEffect(function () {
2047
1986
  if (!dayPicker.initialFocus)
@@ -2060,7 +1999,7 @@ function Root() {
2060
1999
  focusContext
2061
2000
  ]);
2062
2001
  // Apply classnames according to props
2063
- var classNames = [(_a = dayPicker.className) !== null && _a !== void 0 ? _a : dayPicker.classNames.root];
2002
+ var classNames = [dayPicker.classNames.root, dayPicker.className];
2064
2003
  if (dayPicker.numberOfMonths > 1) {
2065
2004
  classNames.push(dayPicker.classNames.multiple_months);
2066
2005
  }
@@ -2068,25 +2007,112 @@ function Root() {
2068
2007
  classNames.push(dayPicker.classNames.with_weeknumber);
2069
2008
  }
2070
2009
  var style = __assign(__assign({}, dayPicker.styles.root), dayPicker.style);
2071
- return (React.createElement("div", { className: classNames.join(' '), style: style, dir: dayPicker.dir },
2072
- React.createElement("div", { className: dayPicker.classNames.months, style: dayPicker.styles.months }, navigation.displayMonths.map(function (month, i) { return (React.createElement(Month, { key: i, displayIndex: i, displayMonth: month })); }))));
2010
+ return (React__default.createElement("div", { className: classNames.join(' '), style: style, dir: dayPicker.dir },
2011
+ React__default.createElement("div", { className: dayPicker.classNames.months, style: dayPicker.styles.months }, navigation.displayMonths.map(function (month, i) { return (React__default.createElement(Month, { key: i, displayIndex: i, displayMonth: month })); }))));
2073
2012
  }
2074
2013
 
2075
2014
  /** Provide the value for all the context providers. */
2076
2015
  function RootProvider(props) {
2077
2016
  var children = props.children, initialProps = __rest(props, ["children"]);
2078
- return (React.createElement(DayPickerProvider, { initialProps: initialProps },
2079
- React.createElement(NavigationProvider, null,
2080
- React.createElement(SelectSingleProvider, { initialProps: initialProps },
2081
- React.createElement(SelectMultipleProvider, { initialProps: initialProps },
2082
- React.createElement(SelectRangeProvider, { initialProps: initialProps },
2083
- React.createElement(ModifiersProvider, null,
2084
- React.createElement(FocusProvider, null, children))))))));
2017
+ return (React__default.createElement(DayPickerProvider, { initialProps: initialProps },
2018
+ React__default.createElement(NavigationProvider, null,
2019
+ React__default.createElement(SelectSingleProvider, { initialProps: initialProps },
2020
+ React__default.createElement(SelectMultipleProvider, { initialProps: initialProps },
2021
+ React__default.createElement(SelectRangeProvider, { initialProps: initialProps },
2022
+ React__default.createElement(ModifiersProvider, null,
2023
+ React__default.createElement(FocusProvider, null, children))))))));
2085
2024
  }
2086
2025
 
2026
+ /**
2027
+ * DayPicker render a date picker component to let users pick dates from a
2028
+ * calendar. See http://react-day-picker.js.org for updated documentation and
2029
+ * examples.
2030
+ *
2031
+ * ### Customization
2032
+ *
2033
+ * DayPicker offers different customization props. For example,
2034
+ *
2035
+ * - show multiple months using `numberOfMonths`
2036
+ * - display a dropdown to navigate the months via `captionLayout`
2037
+ * - display the week numbers with `showWeekNumbers`
2038
+ * - disable or hide days with `disabled` or `hidden`
2039
+ *
2040
+ * ### Controlling the months
2041
+ *
2042
+ * Change the initially displayed month using the `defaultMonth` prop. The
2043
+ * displayed months are controlled by DayPicker and stored in its internal
2044
+ * state. To control the months yourself, use `month` instead of `defaultMonth`
2045
+ * and use the `onMonthChange` event to set it.
2046
+ *
2047
+ * To limit the months the user can navigate to, use
2048
+ * `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.
2049
+ *
2050
+ * ### Selection modes
2051
+ *
2052
+ * DayPicker supports different selection mode that can be toggled using the
2053
+ * `mode` prop:
2054
+ *
2055
+ * - `mode="single"`: only one day can be selected. Use `required` to make the
2056
+ * selection required. Use the `onSelect` event handler to get the selected
2057
+ * days.
2058
+ * - `mode="multiple"`: users can select one or more days. Limit the amount of
2059
+ * days that can be selected with the `min` or the `max` props.
2060
+ * - `mode="range"`: users can select a range of days. Limit the amount of days
2061
+ * in the range with the `min` or the `max` props.
2062
+ * - `mode="default"` (default): the built-in selections are disabled. Implement
2063
+ * your own selection mode with `onDayClick`.
2064
+ *
2065
+ * The selection modes should cover the most common use cases. In case you
2066
+ * need a more refined way of selecting days, use `mode="default"`. Use the
2067
+ * `selected` props and add the day event handlers to add/remove days from the
2068
+ * selection.
2069
+ *
2070
+ * ### Modifiers
2071
+ *
2072
+ * A _modifier_ represents different styles or states for the days displayed in
2073
+ * the calendar (like "selected" or "disabled"). Define custom modifiers using
2074
+ * the `modifiers` prop.
2075
+ *
2076
+ * ### Formatters and custom component
2077
+ *
2078
+ * You can customize how the content is displayed in the date picker by using
2079
+ * either the formatters or replacing the internal components.
2080
+ *
2081
+ * For the most common cases you want to use the `formatters` prop to change how
2082
+ * the content is formatted in the calendar. Use the `components` prop to
2083
+ * replace the internal components, like the navigation icons.
2084
+ *
2085
+ * ### Styling
2086
+ *
2087
+ * DayPicker comes with a default, basic style in `react-day-picker/style` – use
2088
+ * it as template for your own style.
2089
+ *
2090
+ * If you are using CSS modules, pass the imported styles object the
2091
+ * `classNames` props.
2092
+ *
2093
+ * You can also style the elements via inline-styles using the `styles` prop.
2094
+ *
2095
+ * ### Form fields
2096
+ *
2097
+ * If you need to bind the date picker to a form field, you can use the
2098
+ * `useInput` hooks for a basic behavior. See the `useInput` source as an
2099
+ * example to bind the date picker with form fields.
2100
+ *
2101
+ * ### Localization
2102
+ *
2103
+ * To localize DayPicker, import the locale from `date-fns` package and use the
2104
+ * `locale` prop.
2105
+ *
2106
+ * For example, to use Spanish locale:
2107
+ *
2108
+ * ```
2109
+ * import es from 'date-fns/locale/es';
2110
+ * <DayPicker locale={es} />
2111
+ * ```
2112
+ */
2087
2113
  function DayPicker(props) {
2088
- return (React.createElement(RootProvider, __assign({}, props),
2089
- React.createElement(Root, null)));
2114
+ return (React__default.createElement(RootProvider, __assign({}, props),
2115
+ React__default.createElement(Root, null)));
2090
2116
  }
2091
2117
 
2092
2118
  /** @private */
@@ -2186,10 +2212,10 @@ function useInput(options) {
2186
2212
  return { dayPickerProps: dayPickerProps, inputProps: inputProps, reset: reset, setSelected: setSelected };
2187
2213
  }
2188
2214
 
2189
- /** Returns true when the props are of type [[DayPickerDefault]]. */
2215
+ /** Returns true when the props are of type {@link DayPickerDefaultProps}. */
2190
2216
  function isDayPickerDefault(props) {
2191
2217
  return props.mode === undefined || props.mode === 'default';
2192
2218
  }
2193
2219
 
2194
- export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
2220
+ export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, addToRange, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
2195
2221
  //# sourceMappingURL=index.esm.js.map