react-day-picker 8.0.7 → 8.1.0

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 (104) 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/Modifiers/ModifiersContext.d.ts +2 -2
  20. package/dist/contexts/Modifiers/useModifiers.d.ts +4 -1
  21. package/dist/contexts/Modifiers/utils/getInternalModifiers.d.ts +1 -1
  22. package/dist/contexts/Navigation/NavigationContext.d.ts +9 -10
  23. package/dist/contexts/Navigation/useNavigation.d.ts +6 -1
  24. package/dist/contexts/RootProvider.d.ts +1 -1
  25. package/dist/contexts/SelectMultiple/SelectMultipleContext.d.ts +3 -3
  26. package/dist/contexts/SelectMultiple/useSelectMultiple.d.ts +5 -1
  27. package/dist/contexts/SelectRange/SelectRangeContext.d.ts +3 -3
  28. package/dist/contexts/SelectRange/useSelectRange.d.ts +5 -1
  29. package/dist/contexts/SelectSingle/SelectSingleContext.d.ts +3 -3
  30. package/dist/contexts/SelectSingle/useSelectSingle.d.ts +5 -1
  31. package/dist/hooks/useActiveModifiers/useActiveModifiers.d.ts +9 -3
  32. package/dist/hooks/useDayEventHandlers/useDayEventHandlers.d.ts +2 -2
  33. package/dist/hooks/useDayRender/useDayRender.d.ts +9 -16
  34. package/dist/hooks/useId/index.d.ts +1 -0
  35. package/dist/hooks/useId/useId.d.ts +19 -0
  36. package/dist/hooks/useInput/useInput.d.ts +5 -5
  37. package/dist/hooks/useSelectedDays/useSelectedDays.d.ts +4 -2
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.esm.js +346 -297
  40. package/dist/index.esm.js.map +1 -1
  41. package/dist/index.js +275 -207
  42. package/dist/index.js.map +1 -1
  43. package/dist/react-day-picker.min.js +1 -1
  44. package/dist/style.css +13 -19
  45. package/dist/style.module.css +13 -19
  46. package/dist/types/DayPickerBase.d.ts +29 -13
  47. package/dist/types/DayPickerDefault.d.ts +4 -4
  48. package/dist/types/DayPickerMultiple.d.ts +2 -2
  49. package/dist/types/DayPickerRange.d.ts +2 -2
  50. package/dist/types/DayPickerSingle.d.ts +2 -2
  51. package/dist/types/Labels.d.ts +1 -1
  52. package/dist/types/Matchers.d.ts +10 -10
  53. package/dist/types/Modifiers.d.ts +3 -5
  54. package/package.json +20 -24
  55. package/src/DayPicker.tsx +13 -10
  56. package/src/components/Button/Button.tsx +1 -1
  57. package/src/components/Caption/Caption.tsx +2 -2
  58. package/src/components/CaptionLabel/CaptionLabel.tsx +1 -1
  59. package/src/components/Day/Day.tsx +1 -1
  60. package/src/components/DayContent/DayContent.tsx +1 -1
  61. package/src/components/Dropdown/Dropdown.tsx +1 -1
  62. package/src/components/Month/Month.tsx +2 -3
  63. package/src/components/MonthsDropdown/MonthsDropdown.tsx +1 -1
  64. package/src/components/Navigation/Navigation.test.tsx +6 -6
  65. package/src/components/Navigation/Navigation.tsx +3 -3
  66. package/src/components/Row/Row.tsx +1 -1
  67. package/src/components/Table/Table.tsx +1 -1
  68. package/src/components/WeekNumber/WeekNumber.test.tsx +2 -4
  69. package/src/components/WeekNumber/WeekNumber.tsx +1 -1
  70. package/src/components/YearsDropdown/YearsDropdown.tsx +1 -1
  71. package/src/contexts/DayPicker/DayPickerContext.tsx +5 -6
  72. package/src/contexts/DayPicker/useDayPicker.ts +3 -3
  73. package/src/contexts/Focus/FocusContext.tsx +9 -5
  74. package/src/contexts/Focus/useFocusContext.ts +6 -1
  75. package/src/contexts/Modifiers/ModifiersContext.tsx +2 -2
  76. package/src/contexts/Modifiers/useModifiers.ts +4 -1
  77. package/src/contexts/Modifiers/utils/getInternalModifiers.ts +1 -1
  78. package/src/contexts/Navigation/NavigationContext.tsx +9 -10
  79. package/src/contexts/Navigation/useNavigation.ts +6 -1
  80. package/src/contexts/RootProvider.tsx +1 -1
  81. package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +3 -3
  82. package/src/contexts/SelectMultiple/useSelectMultiple.ts +5 -1
  83. package/src/contexts/SelectRange/SelectRangeContext.tsx +3 -3
  84. package/src/contexts/SelectRange/useSelectRange.ts +5 -1
  85. package/src/contexts/SelectSingle/SelectSingleContext.tsx +3 -3
  86. package/src/contexts/SelectSingle/useSelectSingle.ts +5 -1
  87. package/src/hooks/useActiveModifiers/useActiveModifiers.tsx +7 -2
  88. package/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx +2 -2
  89. package/src/hooks/useDayRender/useDayRender.test.tsx +1 -1
  90. package/src/hooks/useDayRender/useDayRender.tsx +6 -16
  91. package/src/hooks/useId/index.ts +1 -0
  92. package/src/hooks/useId/useId.ts +168 -0
  93. package/src/hooks/useInput/useInput.ts +5 -5
  94. package/src/hooks/useSelectedDays/useSelectedDays.ts +4 -2
  95. package/src/index.ts +1 -0
  96. package/src/style.css +13 -19
  97. package/src/types/DayPickerBase.ts +29 -13
  98. package/src/types/DayPickerDefault.ts +4 -4
  99. package/src/types/DayPickerMultiple.ts +2 -2
  100. package/src/types/DayPickerRange.ts +2 -2
  101. package/src/types/DayPickerSingle.ts +2 -2
  102. package/src/types/Labels.ts +1 -1
  103. package/src/types/Matchers.ts +10 -10
  104. package/src/types/Modifiers.ts +3 -5
package/dist/index.js CHANGED
@@ -32,7 +32,26 @@ var parse = require('date-fns/parse');
32
32
 
33
33
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
34
34
 
35
+ function _interopNamespace(e) {
36
+ if (e && e.__esModule) return e;
37
+ var n = Object.create(null);
38
+ if (e) {
39
+ Object.keys(e).forEach(function (k) {
40
+ if (k !== 'default') {
41
+ var d = Object.getOwnPropertyDescriptor(e, k);
42
+ Object.defineProperty(n, k, d.get ? d : {
43
+ enumerable: true,
44
+ get: function () { return e[k]; }
45
+ });
46
+ }
47
+ });
48
+ }
49
+ n["default"] = e;
50
+ return Object.freeze(n);
51
+ }
52
+
35
53
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
54
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
55
  var enUS__default = /*#__PURE__*/_interopDefaultLegacy(enUS);
37
56
  var format__default = /*#__PURE__*/_interopDefaultLegacy(format);
38
57
  var endOfMonth__default = /*#__PURE__*/_interopDefaultLegacy(endOfMonth);
@@ -60,7 +79,7 @@ var getWeeksInMonth__default = /*#__PURE__*/_interopDefaultLegacy(getWeeksInMont
60
79
  var getWeek__default = /*#__PURE__*/_interopDefaultLegacy(getWeek);
61
80
  var parse__default = /*#__PURE__*/_interopDefaultLegacy(parse);
62
81
 
63
- /*! *****************************************************************************
82
+ /******************************************************************************
64
83
  Copyright (c) Microsoft Corporation.
65
84
 
66
85
  Permission to use, copy, modify, and/or distribute this software for any
@@ -108,147 +127,6 @@ function __spreadArray(to, from, pack) {
108
127
  return to.concat(ar || Array.prototype.slice.call(from));
109
128
  }
110
129
 
111
- function canUseDOM() {
112
- return !!(typeof window !== "undefined" && window.document && window.document.createElement);
113
- }
114
-
115
- /**
116
- * React currently throws a warning when using useLayoutEffect on the server. To
117
- * get around it, we can conditionally useEffect on the server (no-op) and
118
- * useLayoutEffect in the browser. We occasionally need useLayoutEffect to
119
- * ensure we don't get a render flash for certain operations, but we may also
120
- * need affected components to render on the server. One example is when setting
121
- * a component's descendants to retrieve their index values.
122
- *
123
- * Important to note that using this hook as an escape hatch will break the
124
- * eslint dependency warnings unless you rename the import to `useLayoutEffect`.
125
- * Use sparingly only when the effect won't effect the rendered HTML to avoid
126
- * any server/client mismatch.
127
- *
128
- * If a useLayoutEffect is needed and the result would create a mismatch, it's
129
- * likely that the component in question shouldn't be rendered on the server at
130
- * all, so a better approach would be to lazily render those in a parent
131
- * component after client-side hydration.
132
- *
133
- * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
134
- * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
135
- *
136
- * @param effect
137
- * @param deps
138
- */
139
-
140
- var useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? React.useLayoutEffect : React.useEffect;
141
-
142
- /*
143
- * Welcome to @reach/auto-id!
144
-
145
- * Let's see if we can make sense of why this hook exists and its
146
- * implementation.
147
- *
148
- * Some background:
149
- * 1. Accessibility APIs rely heavily on element IDs
150
- * 2. Requiring developers to put IDs on every element in Reach UI is both
151
- * cumbersome and error-prone
152
- * 3. With a component model, we can generate IDs for them!
153
- *
154
- * Solution 1: Generate random IDs.
155
- *
156
- * This works great as long as you don't server render your app. When React (in
157
- * the client) tries to reuse the markup from the server, the IDs won't match
158
- * and React will then recreate the entire DOM tree.
159
- *
160
- * Solution 2: Increment an integer
161
- *
162
- * This sounds great. Since we're rendering the exact same tree on the server
163
- * and client, we can increment a counter and get a deterministic result between
164
- * client and server. Also, JS integers can go up to nine-quadrillion. I'm
165
- * pretty sure the tab will be closed before an app never needs
166
- * 10 quadrillion IDs!
167
- *
168
- * Problem solved, right?
169
- *
170
- * Ah, but there's a catch! React's concurrent rendering makes this approach
171
- * non-deterministic. While the client and server will end up with the same
172
- * elements in the end, depending on suspense boundaries (and possibly some user
173
- * input during the initial render) the incrementing integers won't always match
174
- * up.
175
- *
176
- * Solution 3: Don't use IDs at all on the server; patch after first render.
177
- *
178
- * What we've done here is solution 2 with some tricks. With this approach, the
179
- * ID returned is an empty string on the first render. This way the server and
180
- * client have the same markup no matter how wild the concurrent rendering may
181
- * have gotten.
182
- *
183
- * After the render, we patch up the components with an incremented ID. This
184
- * causes a double render on any components with `useId`. Shouldn't be a problem
185
- * since the components using this hook should be small, and we're only updating
186
- * the ID attribute on the DOM, nothing big is happening.
187
- *
188
- * It doesn't have to be an incremented number, though--we could do generate
189
- * random strings instead, but incrementing a number is probably the cheapest
190
- * thing we can do.
191
- *
192
- * Additionally, we only do this patchup on the very first client render ever.
193
- * Any calls to `useId` that happen dynamically in the client will be
194
- * populated immediately with a value. So, we only get the double render after
195
- * server hydration and never again, SO BACK OFF ALRIGHT?
196
- */
197
- var serverHandoffComplete = false;
198
- var id = 0;
199
-
200
- var genId = function genId() {
201
- return ++id;
202
- };
203
- /**
204
- * useId
205
- *
206
- * Autogenerate IDs to facilitate WAI-ARIA and server rendering.
207
- *
208
- * Note: The returned ID will initially be `null` and will update after a
209
- * component mounts. Users may need to supply their own ID if they need
210
- * consistent values for SSR.
211
- *
212
- * @see Docs https://reach.tech/auto-id
213
- */
214
-
215
-
216
- function useId(idFromProps) {
217
- /*
218
- * If this instance isn't part of the initial render, we don't have to do the
219
- * double render/patch-up dance. We can just generate the ID and return it.
220
- */
221
- var initialId = idFromProps || (serverHandoffComplete ? genId() : null);
222
-
223
- var _React$useState = React.useState(initialId),
224
- id = _React$useState[0],
225
- setId = _React$useState[1];
226
-
227
- useIsomorphicLayoutEffect(function () {
228
- if (id === null) {
229
- /*
230
- * Patch the ID after render. We do this in `useLayoutEffect` to avoid any
231
- * rendering flicker, though it'll make the first render slower (unlikely
232
- * to matter, but you're welcome to measure your app and let us know if
233
- * it's a problem).
234
- */
235
- setId(genId());
236
- } // eslint-disable-next-line react-hooks/exhaustive-deps
237
-
238
- }, []);
239
- React.useEffect(function () {
240
- if (serverHandoffComplete === false) {
241
- /*
242
- * Flag all future uses of `useId` to skip the update dance. This is in
243
- * `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
244
- * accidentally bail out of the patch-up dance prematurely.
245
- */
246
- serverHandoffComplete = true;
247
- }
248
- }, []);
249
- return id != null ? String(id) : undefined;
250
- }
251
-
252
130
  /**
253
131
  * The name of the default CSS classes.
254
132
  */
@@ -459,16 +337,15 @@ function parseFromToProps(props) {
459
337
  }
460
338
 
461
339
  /**
462
- * The DayPicker Context shares the props passed to DayPicker within internal
340
+ * The DayPicker context shares the props passed to DayPicker within internal
463
341
  * and custom components. It is used to set the default values and perform
464
342
  * one-time calculations required to render the days.
465
343
  *
466
- * Developers may access this context from the [[useDayPicker]] hook when
467
- * using custom components.
344
+ * Access to this context from the {@link useDayPicker} hook.
468
345
  */
469
346
  var DayPickerContext = React.createContext(undefined);
470
347
  /**
471
- * The provider for the [[DayPickerContext]], assigning the defaults from the
348
+ * The provider for the {@link DayPickerContext}, assigning the defaults from the
472
349
  * initial DayPicker props.
473
350
  */
474
351
  function DayPickerProvider(props) {
@@ -535,10 +412,10 @@ function DayPickerProvider(props) {
535
412
  }
536
413
 
537
414
  /**
538
- * Hook to access the [[DayPickerContext]].
415
+ * Hook to access the {@link DayPickerContextValue}.
539
416
  *
540
- * To use this hook make sure to wrap the components with a one
541
- * [[DayPickerProvider]].
417
+ * Use the DayPicker context to access to the props passed to DayPicker inside
418
+ * internal or custom components.
542
419
  */
543
420
  function useDayPicker() {
544
421
  var context = React.useContext(DayPickerContext);
@@ -761,12 +638,11 @@ function getPreviousMonth(startingMonth, options) {
761
638
  }
762
639
 
763
640
  /**
764
- * The Navigation context shares details about the months being navigated in DayPicker.
765
- *
766
- * Access this context from the [[useNavigation]] hook.
641
+ * The Navigation context shares details and methods to navigate the months in DayPicker.
642
+ * Access this context from the {@link useNavigation} hook.
767
643
  */
768
644
  var NavigationContext = React.createContext(undefined);
769
- /** Provides the values for the [[NavigationContext]]. */
645
+ /** Provides the values for the {@link NavigationContext}. */
770
646
  function NavigationProvider(props) {
771
647
  var dayPicker = useDayPicker();
772
648
  var _a = useNavigationState(), currentMonth = _a[0], goToMonth = _a[1];
@@ -801,7 +677,12 @@ function NavigationProvider(props) {
801
677
  return (React__default["default"].createElement(NavigationContext.Provider, { value: value }, props.children));
802
678
  }
803
679
 
804
- /** Hook to access the [[NavigationContext]]. */
680
+ /**
681
+ * Hook to access the {@link NavigationContextValue}. Use this hook to navigate
682
+ * between months or years in DayPicker.
683
+ *
684
+ * This hook is meant to be used inside internal or custom components.
685
+ */
805
686
  function useNavigation() {
806
687
  var context = React.useContext(NavigationContext);
807
688
  if (!context) {
@@ -882,8 +763,8 @@ function Navigation(props) {
882
763
  var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
883
764
  var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
884
765
  return (React__default["default"].createElement("div", { className: classNames.nav, style: styles.nav },
885
- !props.hidePrevious && (React__default["default"].createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, "aria-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 })))),
886
- !props.hideNext && (React__default["default"].createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, "aria-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 }))))));
766
+ !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 })))),
767
+ !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 }))))));
887
768
  }
888
769
 
889
770
  /**
@@ -925,7 +806,7 @@ function CaptionNavigation(props) {
925
806
 
926
807
  /**
927
808
  * Render the caption of a month. The caption has a different layout when
928
- * setting the [[DayPickerProps.captionLayout]] prop.
809
+ * setting the {@link DayPickerBase.captionLayout} prop.
929
810
  */
930
811
  function Caption(props) {
931
812
  var _a;
@@ -994,7 +875,7 @@ function DayContent(props) {
994
875
  React__default["default"].createElement("span", { className: classNames.vhidden, style: styles.vhidden }, labelDay(props.date, props.activeModifiers, { locale: locale }))));
995
876
  }
996
877
 
997
- /** Returns true when the props are of type [[DayPickerMultiple]]. */
878
+ /** Returns true when the props are of type {@link DayPickerMultipleProps}. */
998
879
  function isDayPickerMultiple(props) {
999
880
  return props.mode === 'multiple';
1000
881
  }
@@ -1003,10 +884,10 @@ function isDayPickerMultiple(props) {
1003
884
  * The SelectMultiple context shares details about the selected days when in
1004
885
  * multiple selection mode.
1005
886
  *
1006
- * Access this context from the [[useSelectMultiple]] hook.
887
+ * Access this context from the {@link useSelectMultiple} hook.
1007
888
  */
1008
889
  var SelectMultipleContext = React.createContext(undefined);
1009
- /** Provides the values for the [[SelectMultipleContext]]. */
890
+ /** Provides the values for the {@link SelectMultipleContext}. */
1010
891
  function SelectMultipleProvider(props) {
1011
892
  if (!isDayPickerMultiple(props.initialProps)) {
1012
893
  var emptyContextValue = {
@@ -1065,7 +946,11 @@ function SelectMultipleProviderInternal(_a) {
1065
946
  return (React__default["default"].createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
1066
947
  }
1067
948
 
1068
- /** Hook to access the [[SelectMultipleContext]]. */
949
+ /**
950
+ * Hook to access the {@link SelectMultipleContextValue}.
951
+ *
952
+ * This hook is meant to be used inside internal or custom components.
953
+ */
1069
954
  function useSelectMultiple() {
1070
955
  var context = React.useContext(SelectMultipleContext);
1071
956
  if (!context) {
@@ -1074,7 +959,7 @@ function useSelectMultiple() {
1074
959
  return context;
1075
960
  }
1076
961
 
1077
- /** Returns true when the props are of type [[DayPickerRange]]. */
962
+ /** Returns true when the props are of type {@link DayPickerRangeProps}. */
1078
963
  function isDayPickerRange(props) {
1079
964
  return props.mode === 'range';
1080
965
  }
@@ -1118,10 +1003,10 @@ function addToRange(day, range) {
1118
1003
  * The SelectRange context shares details about the selected days when in
1119
1004
  * range selection mode.
1120
1005
  *
1121
- * Access this context from the [[useSelectRange]] hook.
1006
+ * Access this context from the {@link useSelectRange} hook.
1122
1007
  */
1123
1008
  var SelectRangeContext = React.createContext(undefined);
1124
- /** Provides the values for the [[SelectRangeProvider]]. */
1009
+ /** Provides the values for the {@link SelectRangeProvider}. */
1125
1010
  function SelectRangeProvider(props) {
1126
1011
  if (!isDayPickerRange(props.initialProps)) {
1127
1012
  var emptyContextValue = {
@@ -1199,7 +1084,11 @@ function SelectRangeProviderInternal(_a) {
1199
1084
  return (React__default["default"].createElement(SelectRangeContext.Provider, { value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, children));
1200
1085
  }
1201
1086
 
1202
- /** Hook to access the [[SelectRangeContext]]. */
1087
+ /**
1088
+ * Hook to access the {@link SelectRangeContextValue}.
1089
+ *
1090
+ * This hook is meant to be used inside internal or custom components.
1091
+ */
1203
1092
  function useSelectRange() {
1204
1093
  var context = React.useContext(SelectRangeContext);
1205
1094
  if (!context) {
@@ -1252,7 +1141,7 @@ exports.InternalModifier = void 0;
1252
1141
  })(exports.InternalModifier || (exports.InternalModifier = {}));
1253
1142
 
1254
1143
  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;
1255
- /** Return the [[InternalModifiers]] from the DayPicker and select contexts. */
1144
+ /** Return the {@link InternalModifiers} from the DayPicker and select contexts. */
1256
1145
  function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
1257
1146
  var _a;
1258
1147
  var internalModifiers = (_a = {},
@@ -1283,9 +1172,9 @@ function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
1283
1172
  return internalModifiers;
1284
1173
  }
1285
1174
 
1286
- /** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use [[useModifiers]]. */
1175
+ /** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use {@link useModifiers}. */
1287
1176
  var ModifiersContext = React.createContext(undefined);
1288
- /** Provide the value for the [[ModifiersContext]]. */
1177
+ /** Provide the value for the {@link ModifiersContext}. */
1289
1178
  function ModifiersProvider(props) {
1290
1179
  var dayPicker = useDayPicker();
1291
1180
  var selectMultiple = useSelectMultiple();
@@ -1299,7 +1188,10 @@ function ModifiersProvider(props) {
1299
1188
  /**
1300
1189
  * Return the modifiers used by DayPicker.
1301
1190
  *
1302
- * Requires to be wrapped into [[ModifiersProvider]]. */
1191
+ * This hook is meant to be used inside internal or custom components.
1192
+ * Requires to be wrapped into {@link ModifiersProvider}.
1193
+ *
1194
+ */
1303
1195
  function useModifiers() {
1304
1196
  var context = React.useContext(ModifiersContext);
1305
1197
  if (!context) {
@@ -1308,26 +1200,26 @@ function useModifiers() {
1308
1200
  return context;
1309
1201
  }
1310
1202
 
1311
- /** Returns true if `matcher` is of type [[DateInterval]]. */
1203
+ /** Returns true if `matcher` is of type {@link DateInterval}. */
1312
1204
  function isDateInterval(matcher) {
1313
1205
  return Boolean(matcher &&
1314
1206
  typeof matcher === 'object' &&
1315
1207
  'before' in matcher &&
1316
1208
  'after' in matcher);
1317
1209
  }
1318
- /** Returns true if `value` is a [[DateRange]] type. */
1210
+ /** Returns true if `value` is a {@link DateRange} type. */
1319
1211
  function isDateRange(value) {
1320
1212
  return Boolean(value && typeof value === 'object' && 'from' in value);
1321
1213
  }
1322
- /** Returns true if `value` is of type [[DateAfter]]. */
1214
+ /** Returns true if `value` is of type {@link DateAfter}. */
1323
1215
  function isDateAfterType(value) {
1324
1216
  return Boolean(value && typeof value === 'object' && 'after' in value);
1325
1217
  }
1326
- /** Returns true if `value` is of type [[DateBefore]]. */
1218
+ /** Returns true if `value` is of type {@link DateBefore}. */
1327
1219
  function isDateBeforeType(value) {
1328
1220
  return Boolean(value && typeof value === 'object' && 'before' in value);
1329
1221
  }
1330
- /** Returns true if `value` is a [[DayOfWeek]] type. */
1222
+ /** Returns true if `value` is a {@link DayOfWeek} type. */
1331
1223
  function isDayOfWeekType(value) {
1332
1224
  return Boolean(value && typeof value === 'object' && 'dayOfWeek' in value);
1333
1225
  }
@@ -1471,16 +1363,17 @@ function getInitialFocusTarget(displayMonths, modifiers) {
1471
1363
  /**
1472
1364
  * The Focus context shares details about the focused day for the keyboard
1473
1365
  *
1474
- * Access this context from the [[useFocus]] hook.
1366
+ * Access this context from the {@link useFocusContext} hook.
1475
1367
  */
1476
1368
  var FocusContext = React.createContext(undefined);
1477
- /** The provider for the [[FocusContext]]. */
1369
+ /** The provider for the {@link FocusContext}. */
1478
1370
  function FocusProvider(props) {
1479
1371
  var navigation = useNavigation();
1480
1372
  var modifiers = useModifiers();
1481
1373
  var _a = React.useState(), focusedDay = _a[0], setFocusedDay = _a[1];
1482
1374
  var _b = React.useState(), lastFocused = _b[0], setLastFocused = _b[1];
1483
1375
  var initialFocusTarget = getInitialFocusTarget(navigation.displayMonths, modifiers);
1376
+ var weekStartsOn = useDayPicker().weekStartsOn;
1484
1377
  // TODO: cleanup and test obscure code below
1485
1378
  var focusTarget = (focusedDay !== null && focusedDay !== void 0 ? focusedDay : (lastFocused && navigation.isDateDisplayed(lastFocused)))
1486
1379
  ? lastFocused
@@ -1523,14 +1416,14 @@ function FocusProvider(props) {
1523
1416
  var focusStartOfWeek = function () {
1524
1417
  if (!focusedDay)
1525
1418
  return;
1526
- var dayToFocus = startOfWeek__default["default"](focusedDay);
1419
+ var dayToFocus = startOfWeek__default["default"](focusedDay, { weekStartsOn: weekStartsOn });
1527
1420
  navigation.goToDate(dayToFocus, focusedDay);
1528
1421
  focus(dayToFocus);
1529
1422
  };
1530
1423
  var focusEndOfWeek = function () {
1531
1424
  if (!focusedDay)
1532
1425
  return;
1533
- var dayToFocus = endOfWeek__default["default"](focusedDay);
1426
+ var dayToFocus = endOfWeek__default["default"](focusedDay, { weekStartsOn: weekStartsOn });
1534
1427
  navigation.goToDate(dayToFocus, focusedDay);
1535
1428
  focus(dayToFocus);
1536
1429
  };
@@ -1581,7 +1474,12 @@ function FocusProvider(props) {
1581
1474
  return (React__default["default"].createElement(FocusContext.Provider, { value: value }, props.children));
1582
1475
  }
1583
1476
 
1584
- /** Hook to access the [[FocusContext]]. */
1477
+ /**
1478
+ * Hook to access the {@link FocusContextValue}. Use this hook to handle the
1479
+ * focus state of the elements.
1480
+ *
1481
+ * This hook is meant to be used inside internal or custom components.
1482
+ */
1585
1483
  function useFocusContext() {
1586
1484
  var context = React.useContext(FocusContext);
1587
1485
  if (!context) {
@@ -1593,17 +1491,23 @@ function useFocusContext() {
1593
1491
  /**
1594
1492
  * Return the active modifiers for the specified day.
1595
1493
  *
1494
+ * This hook is meant to be used inside internal or custom components.
1495
+ *
1596
1496
  * @param day
1597
- * @param displayMonth The month where the date is displayed. If not the same as
1598
- * `date`, the day is an "outside day".
1497
+ * @param displayMonth
1498
+ */
1499
+ function useActiveModifiers(day,
1500
+ /**
1501
+ * The month where the date is displayed. If not the same as `date`, the day
1502
+ * is an "outside day".
1599
1503
  */
1600
- function useActiveModifiers(day, displayMonth) {
1504
+ displayMonth) {
1601
1505
  var modifiers = useModifiers();
1602
1506
  var activeModifiers = getActiveModifiers(day, modifiers, displayMonth);
1603
1507
  return activeModifiers;
1604
1508
  }
1605
1509
 
1606
- /** Returns true when the props are of type [[DayPickerSingle]]. */
1510
+ /** Returns true when the props are of type {@link DayPickerSingleProps}. */
1607
1511
  function isDayPickerSingle(props) {
1608
1512
  return props.mode === 'single';
1609
1513
  }
@@ -1612,10 +1516,10 @@ function isDayPickerSingle(props) {
1612
1516
  * The SelectSingle context shares details about the selected days when in
1613
1517
  * single selection mode.
1614
1518
  *
1615
- * Access this context from the [[useSelectSingle]] hook.
1519
+ * Access this context from the {@link useSelectSingle} hook.
1616
1520
  */
1617
1521
  var SelectSingleContext = React.createContext(undefined);
1618
- /** Provides the values for the [[SelectSingleProvider]]. */
1522
+ /** Provides the values for the {@link SelectSingleProvider}. */
1619
1523
  function SelectSingleProvider(props) {
1620
1524
  if (!isDayPickerSingle(props.initialProps)) {
1621
1525
  var emptyContextValue = {
@@ -1643,7 +1547,11 @@ function SelectSingleProviderInternal(_a) {
1643
1547
  return (React__default["default"].createElement(SelectSingleContext.Provider, { value: contextValue }, children));
1644
1548
  }
1645
1549
 
1646
- /** Hook to access the [[SelectSingleContext]]. */
1550
+ /**
1551
+ * Hook to access the {@link SelectSingleContextValue}.
1552
+ *
1553
+ * This hook is meant to be used inside internal or custom components.
1554
+ */
1647
1555
  function useSelectSingle() {
1648
1556
  var context = React.useContext(SelectSingleContext);
1649
1557
  if (!context) {
@@ -1667,9 +1575,9 @@ function useSelectSingle() {
1667
1575
  *
1668
1576
  * ### Usage
1669
1577
  *
1670
- * Use this hook to customize the behavior of the [[Day]] component. Create a
1578
+ * Use this hook to customize the behavior of the {@link Day} component. Create a
1671
1579
  * new `Day` component using this hook and pass it to the `components` prop.
1672
- * The source of [[Day]] can be a good starting point.
1580
+ * The source of {@link Day} can be a good starting point.
1673
1581
  *
1674
1582
  */
1675
1583
  function useDayEventHandlers(date, activeModifiers) {
@@ -1792,9 +1700,11 @@ function useDayEventHandlers(date, activeModifiers) {
1792
1700
  }
1793
1701
 
1794
1702
  /**
1795
- * Return the current selected days when DayPicker is in selection mode.
1703
+ * Return the current selected days when DayPicker is in selection mode. Days
1704
+ * selected by the custom selection mode are not returned.
1705
+ *
1706
+ * This hook is meant to be used inside internal or custom components.
1796
1707
  *
1797
- * Days selected by the custom selection mode are not returned.
1798
1708
  */
1799
1709
  function useSelectedDays() {
1800
1710
  var dayPicker = useDayPicker();
@@ -1849,25 +1759,18 @@ function getDayStyle(dayPicker, activeModifiers) {
1849
1759
  }
1850
1760
 
1851
1761
  /**
1852
- * Return props and data used to render the [[Day]] component.
1762
+ * Return props and data used to render the {@link Day} component.
1853
1763
  *
1854
1764
  * Use this hook when creating a component to replace the built-in `Day`
1855
1765
  * component.
1856
- *
1857
- * Each Day in DayPicker should render one of the following, according to the return
1858
- * value:
1859
- *
1860
- * - an empty `React.Fragment`, to render if `isHidden` is true
1861
- * - a `button` element, when the day is interactive, e.g. is selectable
1862
- * - a `div` element, whe the day is not interactive
1863
- *
1864
- * @param day The date to render
1865
- * @param displayMonth The month where the date is displayed (if not the same as
1866
- * `date`, it means it is an "outside" day)
1867
- * @param buttonRef A ref to the button element that will be target of focus
1868
- * when rendered (if required).
1869
1766
  */
1870
- function useDayRender(day, displayMonth, buttonRef) {
1767
+ function useDayRender(
1768
+ /** The date to render. */
1769
+ day,
1770
+ /** The month where the date is displayed (if not the same as `date`, it means it is an "outside" day). */
1771
+ displayMonth,
1772
+ /** A ref to the button element that will be target of focus when rendered (if required). */
1773
+ buttonRef) {
1871
1774
  var _a;
1872
1775
  var _b, _c;
1873
1776
  var dayPicker = useDayPicker();
@@ -1907,7 +1810,7 @@ function useDayRender(day, displayMonth, buttonRef) {
1907
1810
  children: children
1908
1811
  };
1909
1812
  var isFocusTarget = Boolean(focusContext.focusTarget && isSameDay__default["default"](focusContext.focusTarget, day));
1910
- var buttonProps = __assign(__assign(__assign({}, divProps), (_a = {}, _a['aria-disabled'] = activeModifiers.disabled, _a['aria-pressed'] = activeModifiers.selected, _a.tabIndex = isFocusTarget ? 0 : -1, _a)), eventHandlers);
1813
+ var buttonProps = __assign(__assign(__assign({}, divProps), (_a = { disabled: activeModifiers.disabled }, _a['aria-pressed'] = activeModifiers.selected, _a.tabIndex = isFocusTarget ? 0 : -1, _a)), eventHandlers);
1911
1814
  var dayRender = {
1912
1815
  isButton: isButton,
1913
1816
  isHidden: isHidden,
@@ -2035,6 +1938,83 @@ function Table(props) {
2035
1938
  React__default["default"].createElement(FooterComponent, null)));
2036
1939
  }
2037
1940
 
1941
+ /*
1942
+ The MIT License (MIT)
1943
+
1944
+ Copyright (c) 2018-present, React Training LLC
1945
+
1946
+ 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:
1947
+
1948
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1949
+
1950
+ 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.
1951
+ */
1952
+ function canUseDOM() {
1953
+ return !!(typeof window !== 'undefined' &&
1954
+ window.document &&
1955
+ window.document.createElement);
1956
+ }
1957
+ /**
1958
+ * React currently throws a warning when using useLayoutEffect on the server. To
1959
+ * get around it, we can conditionally useEffect on the server (no-op) and
1960
+ * useLayoutEffect in the browser. We occasionally need useLayoutEffect to
1961
+ * ensure we don't get a render flash for certain operations, but we may also
1962
+ * need affected components to render on the server. One example is when setting
1963
+ * a component's descendants to retrieve their index values.
1964
+ *
1965
+ * Important to note that using this hook as an escape hatch will break the
1966
+ * eslint dependency warnings unless you rename the import to `useLayoutEffect`.
1967
+ * Use sparingly only when the effect won't effect the rendered HTML to avoid
1968
+ * any server/client mismatch.
1969
+ *
1970
+ * If a useLayoutEffect is needed and the result would create a mismatch, it's
1971
+ * likely that the component in question shouldn't be rendered on the server at
1972
+ * all, so a better approach would be to lazily render those in a parent
1973
+ * component after client-side hydration.
1974
+ *
1975
+ * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
1976
+ * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
1977
+ *
1978
+ * @param effect
1979
+ * @param deps
1980
+ */
1981
+ var useIsomorphicLayoutEffect = canUseDOM()
1982
+ ? React__namespace.useLayoutEffect
1983
+ : React__namespace.useEffect;
1984
+ var serverHandoffComplete = false;
1985
+ var id = 0;
1986
+ function genId() {
1987
+ return "react-day-picker-".concat(++id);
1988
+ }
1989
+ function useId(providedId) {
1990
+ // TODO: Remove error flag when updating internal deps to React 18. None of
1991
+ // our tricks will play well with concurrent rendering anyway.
1992
+ var _a;
1993
+ // If this instance isn't part of the initial render, we don't have to do the
1994
+ // double render/patch-up dance. We can just generate the ID and return it.
1995
+ var initialId = providedId !== null && providedId !== void 0 ? providedId : (serverHandoffComplete ? genId() : null);
1996
+ var _b = React__namespace.useState(initialId), id = _b[0], setId = _b[1];
1997
+ useIsomorphicLayoutEffect(function () {
1998
+ if (id === null) {
1999
+ // Patch the ID after render. We do this in `useLayoutEffect` to avoid any
2000
+ // rendering flicker, though it'll make the first render slower (unlikely
2001
+ // to matter, but you're welcome to measure your app and let us know if
2002
+ // it's a problem).
2003
+ setId(genId());
2004
+ }
2005
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2006
+ }, []);
2007
+ React__namespace.useEffect(function () {
2008
+ if (serverHandoffComplete === false) {
2009
+ // Flag all future uses of `useId` to skip the update dance. This is in
2010
+ // `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
2011
+ // accidentally bail out of the patch-up dance prematurely.
2012
+ serverHandoffComplete = true;
2013
+ }
2014
+ }, []);
2015
+ return (_a = providedId !== null && providedId !== void 0 ? providedId : id) !== null && _a !== void 0 ? _a : undefined;
2016
+ }
2017
+
2038
2018
  /** Render a month. */
2039
2019
  function Month(props) {
2040
2020
  var _a;
@@ -2118,6 +2098,93 @@ function RootProvider(props) {
2118
2098
  React__default["default"].createElement(FocusProvider, null, children))))))));
2119
2099
  }
2120
2100
 
2101
+ /**
2102
+ * DayPicker render a date picker component to let users pick dates from a
2103
+ * calendar. See http://react-day-picker.js.org for updated documentation and
2104
+ * examples.
2105
+ *
2106
+ * ### Customization
2107
+ *
2108
+ * DayPicker offers different customization props. For example,
2109
+ *
2110
+ * - show multiple months using `numberOfMonths`
2111
+ * - display a dropdown to navigate the months via `captionLayout`
2112
+ * - display the week numbers with `showWeekNumbers`
2113
+ * - disable or hide days with `disabled` or `hidden`
2114
+ *
2115
+ * ### Controlling the months
2116
+ *
2117
+ * Change the initially displayed month using the `defaultMonth` prop. The
2118
+ * displayed months are controlled by DayPicker and stored in its internal
2119
+ * state. To control the months yourself, use `month` instead of `defaultMonth`
2120
+ * and use the `onMonthChange` event to set it.
2121
+ *
2122
+ * To limit the months the user can navigate to, use
2123
+ * `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.
2124
+ *
2125
+ * ### Selection modes
2126
+ *
2127
+ * DayPicker supports different selection mode that can be toggled using the
2128
+ * `mode` prop:
2129
+ *
2130
+ * - `mode="single"`: only one day can be selected. Use `required` to make the
2131
+ * selection required. Use the `onSelect` event handler to get the selected
2132
+ * days.
2133
+ * - `mode="multiple"`: users can select one or more days. Limit the amount of
2134
+ * days that can be selected with the `min` or the `max` props.
2135
+ * - `mode="range"`: users can select a range of days. Limit the amount of days
2136
+ * in the range with the `min` or the `max` props.
2137
+ * - `mode="default"` (default): the built-in selections are disabled. Implement
2138
+ * your own selection mode with `onDayClick`.
2139
+ *
2140
+ * The selection modes should cover the most common use cases. In case you
2141
+ * need a more refined way of selecting days, use `mode="default"`. Use the
2142
+ * `selected` props and add the day event handlers to add/remove days from the
2143
+ * selection.
2144
+ *
2145
+ * ### Modifiers
2146
+ *
2147
+ * A _modifier_ represents different styles or states for the days displayed in
2148
+ * the calendar (like "selected" or "disabled"). Define custom modifiers using
2149
+ * the `modifiers` prop.
2150
+ *
2151
+ * ### Formatters and custom component
2152
+ *
2153
+ * You can customize how the content is displayed in the date picker by using
2154
+ * either the formatters or replacing the internal components.
2155
+ *
2156
+ * For the most common cases you want to use the `formatters` prop to change how
2157
+ * the content is formatted in the calendar. Use the `components` prop to
2158
+ * replace the internal components, like the navigation icons.
2159
+ *
2160
+ * ### Styling
2161
+ *
2162
+ * DayPicker comes with a default, basic style in `react-day-picker/style` – use
2163
+ * it as template for your own style.
2164
+ *
2165
+ * If you are using CSS modules, pass the imported styles object the
2166
+ * `classNames` props.
2167
+ *
2168
+ * You can also style the elements via inline-styles using the `styles` prop.
2169
+ *
2170
+ * ### Form fields
2171
+ *
2172
+ * If you need to bind the date picker to a form field, you can use the
2173
+ * `useInput` hooks for a basic behavior. See the `useInput` source as an
2174
+ * example to bind the date picker with form fields.
2175
+ *
2176
+ * ### Localization
2177
+ *
2178
+ * To localize DayPicker, import the locale from `date-fns` package and use the
2179
+ * `locale` prop.
2180
+ *
2181
+ * For example, to use Spanish locale:
2182
+ *
2183
+ * ```
2184
+ * import es from 'date-fns/locale/es';
2185
+ * <DayPicker locale={es} />
2186
+ * ```
2187
+ */
2121
2188
  function DayPicker(props) {
2122
2189
  return (React__default["default"].createElement(RootProvider, __assign({}, props),
2123
2190
  React__default["default"].createElement(Root, null)));
@@ -2220,7 +2287,7 @@ function useInput(options) {
2220
2287
  return { dayPickerProps: dayPickerProps, inputProps: inputProps, reset: reset, setSelected: setSelected };
2221
2288
  }
2222
2289
 
2223
- /** Returns true when the props are of type [[DayPickerDefault]]. */
2290
+ /** Returns true when the props are of type {@link DayPickerDefaultProps}. */
2224
2291
  function isDayPickerDefault(props) {
2225
2292
  return props.mode === undefined || props.mode === 'default';
2226
2293
  }
@@ -2257,6 +2324,7 @@ exports.SelectSingleContext = SelectSingleContext;
2257
2324
  exports.SelectSingleProvider = SelectSingleProvider;
2258
2325
  exports.SelectSingleProviderInternal = SelectSingleProviderInternal;
2259
2326
  exports.WeekNumber = WeekNumber;
2327
+ exports.addToRange = addToRange;
2260
2328
  exports.isDateAfterType = isDateAfterType;
2261
2329
  exports.isDateBeforeType = isDateBeforeType;
2262
2330
  exports.isDateInterval = isDateInterval;