@birdnet/advanced-react-dates 0.0.0-stage → 1.0.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 (267) hide show
  1. package/.babelrc +67 -0
  2. package/.eslintrc +66 -0
  3. package/.nvmrc +1 -0
  4. package/.nyc_output/4d8efcd220c2aec1f2b4ffd49d875001.json +1 -0
  5. package/.nyc_output/66d34779498a5d49bcf9d757dfc7fdb5.json +1 -0
  6. package/.nyc_output/8ca7e04140934515928bc7d4ae476b73.json +1 -0
  7. package/.nyc_output/afc270bb597bfc50e690436959c2ae54.json +1 -0
  8. package/.nycrc +19 -0
  9. package/.travis.yml +13 -0
  10. package/CHANGELOG.md +665 -0
  11. package/CLAUDE.md +56 -0
  12. package/INTHEWILD.md +9 -0
  13. package/LICENSE +21 -0
  14. package/README.md +421 -2
  15. package/constants.js +2 -0
  16. package/esm/components/CalendarDay.js +321 -0
  17. package/esm/components/CalendarIcon.js +11 -0
  18. package/esm/components/CalendarMonth.js +254 -0
  19. package/esm/components/CalendarMonthGrid.js +365 -0
  20. package/esm/components/CalendarWeek.js +11 -0
  21. package/esm/components/ChevronDown.js +11 -0
  22. package/esm/components/ChevronUp.js +11 -0
  23. package/esm/components/CloseButton.js +12 -0
  24. package/esm/components/CustomizableCalendarDay.js +341 -0
  25. package/esm/components/DateInput.js +344 -0
  26. package/esm/components/DateRangePicker.js +647 -0
  27. package/esm/components/DateRangePickerInput.js +341 -0
  28. package/esm/components/DateRangePickerInputController.js +348 -0
  29. package/esm/components/DayPicker.js +1167 -0
  30. package/esm/components/DayPickerKeyboardShortcuts.js +364 -0
  31. package/esm/components/DayPickerNavigation.js +314 -0
  32. package/esm/components/DayPickerRangeController.js +1202 -0
  33. package/esm/components/DayPickerSingleDateController.js +690 -0
  34. package/esm/components/KeyboardShortcutRow.js +69 -0
  35. package/esm/components/LeftArrow.js +11 -0
  36. package/esm/components/RightArrow.js +11 -0
  37. package/esm/components/SingleDatePicker.js +605 -0
  38. package/esm/components/SingleDatePickerInput.js +264 -0
  39. package/esm/components/SingleDatePickerInputController.js +260 -0
  40. package/esm/constants.js +28 -0
  41. package/esm/defaultPhrases.js +225 -0
  42. package/esm/index.js +20 -0
  43. package/esm/initialize.js +2 -0
  44. package/esm/shapes/AnchorDirectionShape.js +3 -0
  45. package/esm/shapes/CalendarInfoPositionShape.js +3 -0
  46. package/esm/shapes/DateRangePickerShape.js +101 -0
  47. package/esm/shapes/DayOfWeekShape.js +3 -0
  48. package/esm/shapes/DisabledShape.js +3 -0
  49. package/esm/shapes/FocusedInputShape.js +3 -0
  50. package/esm/shapes/IconPositionShape.js +3 -0
  51. package/esm/shapes/ModifiersShape.js +18 -0
  52. package/esm/shapes/NavPositionShape.js +3 -0
  53. package/esm/shapes/OpenDirectionShape.js +3 -0
  54. package/esm/shapes/OrientationShape.js +3 -0
  55. package/esm/shapes/ScrollableOrientationShape.js +3 -0
  56. package/esm/shapes/SingleDatePickerShape.js +90 -0
  57. package/esm/theme/DefaultTheme.js +176 -0
  58. package/esm/utils/calculateDimension.js +28 -0
  59. package/esm/utils/disableScroll.js +67 -0
  60. package/esm/utils/getActiveElement.js +3 -0
  61. package/esm/utils/getCalendarDaySettings.js +48 -0
  62. package/esm/utils/getCalendarMonthWeeks.js +37 -0
  63. package/esm/utils/getCalendarMonthWidth.js +4 -0
  64. package/esm/utils/getDetachedContainerStyles.js +36 -0
  65. package/esm/utils/getInputHeight.js +42 -0
  66. package/esm/utils/getNumberOfCalendarMonthWeeks.js +11 -0
  67. package/esm/utils/getPhrase.js +7 -0
  68. package/esm/utils/getPhrasePropTypes.js +9 -0
  69. package/esm/utils/getPooledMoment.js +8 -0
  70. package/esm/utils/getPreviousMonthMemoLast.js +9 -0
  71. package/esm/utils/getResponsiveContainerStyles.js +8 -0
  72. package/esm/utils/getSelectedDateOffset.js +8 -0
  73. package/esm/utils/getTransformStyles.js +8 -0
  74. package/esm/utils/getVisibleDays.js +42 -0
  75. package/esm/utils/isAfterDay.js +7 -0
  76. package/esm/utils/isBeforeDay.js +13 -0
  77. package/esm/utils/isDayVisible.js +38 -0
  78. package/esm/utils/isInclusivelyAfterDay.js +6 -0
  79. package/esm/utils/isInclusivelyBeforeDay.js +6 -0
  80. package/esm/utils/isNextDay.js +7 -0
  81. package/esm/utils/isNextMonth.js +6 -0
  82. package/esm/utils/isPrevMonth.js +6 -0
  83. package/esm/utils/isPreviousDay.js +7 -0
  84. package/esm/utils/isSameDay.js +7 -0
  85. package/esm/utils/isSameMonth.js +7 -0
  86. package/esm/utils/isTransitionEndSupported.js +3 -0
  87. package/esm/utils/modifiers.js +94 -0
  88. package/esm/utils/noflip.js +10 -0
  89. package/esm/utils/registerCSSInterfaceWithDefaultTheme.js +5 -0
  90. package/esm/utils/registerInterfaceWithDefaultTheme.js +6 -0
  91. package/esm/utils/toISODateString.js +12 -0
  92. package/esm/utils/toISOMonthString.js +12 -0
  93. package/esm/utils/toLocalizedDateString.js +8 -0
  94. package/esm/utils/toMomentObject.js +7 -0
  95. package/index.js +2 -0
  96. package/initialize.js +2 -0
  97. package/karma.conf.js +82 -0
  98. package/lib/components/CalendarDay.js +327 -0
  99. package/lib/components/CalendarIcon.js +18 -0
  100. package/lib/components/CalendarMonth.js +259 -0
  101. package/lib/components/CalendarMonthGrid.js +372 -0
  102. package/lib/components/CalendarWeek.js +18 -0
  103. package/lib/components/ChevronDown.js +18 -0
  104. package/lib/components/ChevronUp.js +18 -0
  105. package/lib/components/CloseButton.js +19 -0
  106. package/lib/components/CustomizableCalendarDay.js +347 -0
  107. package/lib/components/DateInput.js +351 -0
  108. package/lib/components/DateRangePicker.js +653 -0
  109. package/lib/components/DateRangePickerInput.js +348 -0
  110. package/lib/components/DateRangePickerInputController.js +354 -0
  111. package/lib/components/DayPicker.js +1175 -0
  112. package/lib/components/DayPickerKeyboardShortcuts.js +371 -0
  113. package/lib/components/DayPickerNavigation.js +321 -0
  114. package/lib/components/DayPickerRangeController.js +1208 -0
  115. package/lib/components/DayPickerSingleDateController.js +695 -0
  116. package/lib/components/KeyboardShortcutRow.js +76 -0
  117. package/lib/components/LeftArrow.js +18 -0
  118. package/lib/components/RightArrow.js +18 -0
  119. package/lib/components/SingleDatePicker.js +611 -0
  120. package/lib/components/SingleDatePickerInput.js +271 -0
  121. package/lib/components/SingleDatePickerInputController.js +266 -0
  122. package/lib/constants.js +34 -0
  123. package/lib/css/_datepicker.css +886 -0
  124. package/lib/defaultPhrases.js +231 -0
  125. package/lib/index.js +146 -0
  126. package/lib/initialize.js +5 -0
  127. package/lib/shapes/AnchorDirectionShape.js +10 -0
  128. package/lib/shapes/CalendarInfoPositionShape.js +10 -0
  129. package/lib/shapes/DateRangePickerShape.js +108 -0
  130. package/lib/shapes/DayOfWeekShape.js +10 -0
  131. package/lib/shapes/DisabledShape.js +10 -0
  132. package/lib/shapes/FocusedInputShape.js +10 -0
  133. package/lib/shapes/IconPositionShape.js +10 -0
  134. package/lib/shapes/ModifiersShape.js +25 -0
  135. package/lib/shapes/NavPositionShape.js +10 -0
  136. package/lib/shapes/OpenDirectionShape.js +10 -0
  137. package/lib/shapes/OrientationShape.js +10 -0
  138. package/lib/shapes/ScrollableOrientationShape.js +10 -0
  139. package/lib/shapes/SingleDatePickerShape.js +97 -0
  140. package/lib/theme/DefaultTheme.js +182 -0
  141. package/lib/utils/calculateDimension.js +34 -0
  142. package/lib/utils/disableScroll.js +75 -0
  143. package/lib/utils/getActiveElement.js +9 -0
  144. package/lib/utils/getCalendarDaySettings.js +55 -0
  145. package/lib/utils/getCalendarMonthWeeks.js +44 -0
  146. package/lib/utils/getCalendarMonthWidth.js +10 -0
  147. package/lib/utils/getDetachedContainerStyles.js +41 -0
  148. package/lib/utils/getInputHeight.js +48 -0
  149. package/lib/utils/getNumberOfCalendarMonthWeeks.js +18 -0
  150. package/lib/utils/getPhrase.js +13 -0
  151. package/lib/utils/getPhrasePropTypes.js +16 -0
  152. package/lib/utils/getPooledMoment.js +15 -0
  153. package/lib/utils/getPreviousMonthMemoLast.js +15 -0
  154. package/lib/utils/getResponsiveContainerStyles.js +15 -0
  155. package/lib/utils/getSelectedDateOffset.js +14 -0
  156. package/lib/utils/getTransformStyles.js +14 -0
  157. package/lib/utils/getVisibleDays.js +49 -0
  158. package/lib/utils/isAfterDay.js +14 -0
  159. package/lib/utils/isBeforeDay.js +20 -0
  160. package/lib/utils/isDayVisible.js +45 -0
  161. package/lib/utils/isInclusivelyAfterDay.js +13 -0
  162. package/lib/utils/isInclusivelyBeforeDay.js +13 -0
  163. package/lib/utils/isNextDay.js +14 -0
  164. package/lib/utils/isNextMonth.js +13 -0
  165. package/lib/utils/isPrevMonth.js +13 -0
  166. package/lib/utils/isPreviousDay.js +14 -0
  167. package/lib/utils/isSameDay.js +14 -0
  168. package/lib/utils/isSameMonth.js +14 -0
  169. package/lib/utils/isTransitionEndSupported.js +9 -0
  170. package/lib/utils/modifiers.js +102 -0
  171. package/lib/utils/noflip.js +16 -0
  172. package/lib/utils/registerCSSInterfaceWithDefaultTheme.js +12 -0
  173. package/lib/utils/registerInterfaceWithDefaultTheme.js +13 -0
  174. package/lib/utils/toISODateString.js +19 -0
  175. package/lib/utils/toISOMonthString.js +19 -0
  176. package/lib/utils/toLocalizedDateString.js +15 -0
  177. package/lib/utils/toMomentObject.js +14 -0
  178. package/package.json +141 -4
  179. package/scripts/.eslintrc +7 -0
  180. package/scripts/buildCSS.js +37 -0
  181. package/scripts/pure-component-fallback.js +70 -0
  182. package/scripts/renderAllComponents.jsx +25 -0
  183. package/src/components/CalendarDay.jsx +366 -0
  184. package/src/components/CalendarIcon.jsx +3 -0
  185. package/src/components/CalendarMonth.jsx +300 -0
  186. package/src/components/CalendarMonthGrid.jsx +427 -0
  187. package/src/components/CalendarWeek.jsx +17 -0
  188. package/src/components/ChevronDown.jsx +3 -0
  189. package/src/components/ChevronUp.jsx +3 -0
  190. package/src/components/CloseButton.jsx +3 -0
  191. package/src/components/CustomizableCalendarDay.jsx +382 -0
  192. package/src/components/DateInput.jsx +401 -0
  193. package/src/components/DateRangePicker.jsx +777 -0
  194. package/src/components/DateRangePickerInput.jsx +434 -0
  195. package/src/components/DateRangePickerInputController.jsx +379 -0
  196. package/src/components/DayPicker.jsx +1407 -0
  197. package/src/components/DayPickerKeyboardShortcuts.jsx +443 -0
  198. package/src/components/DayPickerNavigation.jsx +445 -0
  199. package/src/components/DayPickerRangeController.jsx +1409 -0
  200. package/src/components/DayPickerSingleDateController.jsx +769 -0
  201. package/src/components/KeyboardShortcutRow.jsx +93 -0
  202. package/src/components/LeftArrow.jsx +3 -0
  203. package/src/components/RightArrow.jsx +3 -0
  204. package/src/components/SingleDatePicker.jsx +731 -0
  205. package/src/components/SingleDatePickerInput.jsx +329 -0
  206. package/src/components/SingleDatePickerInputController.jsx +280 -0
  207. package/src/constants.js +37 -0
  208. package/src/defaultPhrases.js +215 -0
  209. package/src/index.js +20 -0
  210. package/src/initialize.js +3 -0
  211. package/src/shapes/AnchorDirectionShape.js +8 -0
  212. package/src/shapes/CalendarInfoPositionShape.js +15 -0
  213. package/src/shapes/DateRangePickerShape.js +111 -0
  214. package/src/shapes/DayOfWeekShape.js +5 -0
  215. package/src/shapes/DisabledShape.js +5 -0
  216. package/src/shapes/FocusedInputShape.js +8 -0
  217. package/src/shapes/IconPositionShape.js +8 -0
  218. package/src/shapes/ModifiersShape.js +20 -0
  219. package/src/shapes/NavPositionShape.js +8 -0
  220. package/src/shapes/OpenDirectionShape.js +8 -0
  221. package/src/shapes/OrientationShape.js +8 -0
  222. package/src/shapes/ScrollableOrientationShape.js +13 -0
  223. package/src/shapes/SingleDatePickerShape.js +100 -0
  224. package/src/svg/arrow-left.svg +1 -0
  225. package/src/svg/arrow-right.svg +1 -0
  226. package/src/svg/calendar.svg +1 -0
  227. package/src/svg/chevron-down.svg +1 -0
  228. package/src/svg/chevron-up.svg +1 -0
  229. package/src/svg/close.svg +1 -0
  230. package/src/theme/DefaultTheme.js +196 -0
  231. package/src/utils/calculateDimension.js +32 -0
  232. package/src/utils/disableScroll.js +65 -0
  233. package/src/utils/getActiveElement.js +3 -0
  234. package/src/utils/getCalendarDaySettings.js +61 -0
  235. package/src/utils/getCalendarMonthWeeks.js +49 -0
  236. package/src/utils/getCalendarMonthWidth.js +3 -0
  237. package/src/utils/getDetachedContainerStyles.js +39 -0
  238. package/src/utils/getInputHeight.js +67 -0
  239. package/src/utils/getNumberOfCalendarMonthWeeks.js +15 -0
  240. package/src/utils/getPhrase.jsx +9 -0
  241. package/src/utils/getPhrasePropTypes.js +9 -0
  242. package/src/utils/getPooledMoment.js +10 -0
  243. package/src/utils/getPreviousMonthMemoLast.js +11 -0
  244. package/src/utils/getResponsiveContainerStyles.js +18 -0
  245. package/src/utils/getSelectedDateOffset.js +6 -0
  246. package/src/utils/getTransformStyles.js +8 -0
  247. package/src/utils/getVisibleDays.js +54 -0
  248. package/src/utils/isAfterDay.js +9 -0
  249. package/src/utils/isBeforeDay.js +18 -0
  250. package/src/utils/isDayVisible.js +57 -0
  251. package/src/utils/isInclusivelyAfterDay.js +8 -0
  252. package/src/utils/isInclusivelyBeforeDay.js +8 -0
  253. package/src/utils/isNextDay.js +9 -0
  254. package/src/utils/isNextMonth.js +8 -0
  255. package/src/utils/isPrevMonth.js +8 -0
  256. package/src/utils/isPreviousDay.js +9 -0
  257. package/src/utils/isSameDay.js +10 -0
  258. package/src/utils/isSameMonth.js +9 -0
  259. package/src/utils/isTransitionEndSupported.js +3 -0
  260. package/src/utils/modifiers.js +116 -0
  261. package/src/utils/noflip.js +11 -0
  262. package/src/utils/registerCSSInterfaceWithDefaultTheme.js +7 -0
  263. package/src/utils/registerInterfaceWithDefaultTheme.js +7 -0
  264. package/src/utils/toISODateString.js +14 -0
  265. package/src/utils/toISOMonthString.js +14 -0
  266. package/src/utils/toLocalizedDateString.js +12 -0
  267. package/src/utils/toMomentObject.js +12 -0
@@ -0,0 +1,1175 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.defaultProps = exports["default"] = exports.PureDayPicker = void 0;
9
+ var _enzymeShallowEqual = _interopRequireDefault(require("enzyme-shallow-equal"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+ var _airbnbPropTypes = require("airbnb-prop-types");
17
+ var _reactWithStyles = require("react-with-styles");
18
+ var _moment = _interopRequireDefault(require("moment"));
19
+ var _throttle = _interopRequireDefault(require("lodash/throttle"));
20
+ var _isTouchDevice = _interopRequireDefault(require("is-touch-device"));
21
+ var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
22
+ var _defaultPhrases = require("../defaultPhrases");
23
+ var _getPhrasePropTypes = _interopRequireDefault(require("../utils/getPhrasePropTypes"));
24
+ var _noflip = _interopRequireDefault(require("../utils/noflip"));
25
+ var _CalendarMonthGrid = _interopRequireDefault(require("./CalendarMonthGrid"));
26
+ var _DayPickerNavigation = _interopRequireDefault(require("./DayPickerNavigation"));
27
+ var _DayPickerKeyboardShortcuts = _interopRequireWildcard(require("./DayPickerKeyboardShortcuts"));
28
+ var _getNumberOfCalendarMonthWeeks = _interopRequireDefault(require("../utils/getNumberOfCalendarMonthWeeks"));
29
+ var _getCalendarMonthWidth = _interopRequireDefault(require("../utils/getCalendarMonthWidth"));
30
+ var _calculateDimension = _interopRequireDefault(require("../utils/calculateDimension"));
31
+ var _getActiveElement = _interopRequireDefault(require("../utils/getActiveElement"));
32
+ var _isDayVisible = _interopRequireDefault(require("../utils/isDayVisible"));
33
+ var _isSameMonth = _interopRequireDefault(require("../utils/isSameMonth"));
34
+ var _ModifiersShape = _interopRequireDefault(require("../shapes/ModifiersShape"));
35
+ var _NavPositionShape = _interopRequireDefault(require("../shapes/NavPositionShape"));
36
+ var _ScrollableOrientationShape = _interopRequireDefault(require("../shapes/ScrollableOrientationShape"));
37
+ var _DayOfWeekShape = _interopRequireDefault(require("../shapes/DayOfWeekShape"));
38
+ var _CalendarInfoPositionShape = _interopRequireDefault(require("../shapes/CalendarInfoPositionShape"));
39
+ var _constants = require("../constants");
40
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
41
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
42
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
43
+ var MONTH_PADDING = 23;
44
+ var PREV_TRANSITION = 'prev';
45
+ var NEXT_TRANSITION = 'next';
46
+ var MONTH_SELECTION_TRANSITION = 'month_selection';
47
+ var YEAR_SELECTION_TRANSITION = 'year_selection';
48
+ var PREV_NAV = 'prev_nav';
49
+ var NEXT_NAV = 'next_nav';
50
+ var propTypes = process.env.NODE_ENV !== "production" ? (0, _airbnbPropTypes.forbidExtraProps)(_objectSpread(_objectSpread({}, _reactWithStyles.withStylesPropTypes), {}, {
51
+ // calendar presentation props
52
+ enableOutsideDays: _propTypes["default"].bool,
53
+ numberOfMonths: _propTypes["default"].number,
54
+ orientation: _ScrollableOrientationShape["default"],
55
+ withPortal: _propTypes["default"].bool,
56
+ onOutsideClick: _propTypes["default"].func,
57
+ hidden: _propTypes["default"].bool,
58
+ initialVisibleMonth: _propTypes["default"].func,
59
+ firstDayOfWeek: _DayOfWeekShape["default"],
60
+ renderCalendarInfo: _propTypes["default"].func,
61
+ calendarInfoPosition: _CalendarInfoPositionShape["default"],
62
+ hideKeyboardShortcutsPanel: _propTypes["default"].bool,
63
+ daySize: _airbnbPropTypes.nonNegativeInteger,
64
+ isRTL: _propTypes["default"].bool,
65
+ verticalHeight: _airbnbPropTypes.nonNegativeInteger,
66
+ noBorder: _propTypes["default"].bool,
67
+ transitionDuration: _airbnbPropTypes.nonNegativeInteger,
68
+ verticalBorderSpacing: _airbnbPropTypes.nonNegativeInteger,
69
+ horizontalMonthPadding: _airbnbPropTypes.nonNegativeInteger,
70
+ renderKeyboardShortcutsButton: _propTypes["default"].func,
71
+ renderKeyboardShortcutsPanel: _propTypes["default"].func,
72
+ // navigation props
73
+ dayPickerNavigationInlineStyles: _propTypes["default"].object,
74
+ disablePrev: _propTypes["default"].bool,
75
+ disableNext: _propTypes["default"].bool,
76
+ navPosition: _NavPositionShape["default"],
77
+ navPrev: _propTypes["default"].node,
78
+ navNext: _propTypes["default"].node,
79
+ renderNavPrevButton: _propTypes["default"].func,
80
+ renderNavNextButton: _propTypes["default"].func,
81
+ noNavButtons: _propTypes["default"].bool,
82
+ noNavNextButton: _propTypes["default"].bool,
83
+ noNavPrevButton: _propTypes["default"].bool,
84
+ onPrevMonthClick: _propTypes["default"].func,
85
+ onNextMonthClick: _propTypes["default"].func,
86
+ onMonthChange: _propTypes["default"].func,
87
+ onYearChange: _propTypes["default"].func,
88
+ onGetNextScrollableMonths: _propTypes["default"].func,
89
+ // VERTICAL_SCROLLABLE daypickers only
90
+ onGetPrevScrollableMonths: _propTypes["default"].func,
91
+ // VERTICAL_SCROLLABLE daypickers only
92
+
93
+ // month props
94
+ renderMonthText: (0, _airbnbPropTypes.mutuallyExclusiveProps)(_propTypes["default"].func, 'renderMonthText', 'renderMonthElement'),
95
+ renderMonthElement: (0, _airbnbPropTypes.mutuallyExclusiveProps)(_propTypes["default"].func, 'renderMonthText', 'renderMonthElement'),
96
+ renderWeekHeaderElement: _propTypes["default"].func,
97
+ // day props
98
+ modifiers: _propTypes["default"].objectOf(_propTypes["default"].objectOf(_ModifiersShape["default"])),
99
+ renderCalendarDay: _propTypes["default"].func,
100
+ renderDayContents: _propTypes["default"].func,
101
+ onDayClick: _propTypes["default"].func,
102
+ onDayMouseEnter: _propTypes["default"].func,
103
+ onDayMouseLeave: _propTypes["default"].func,
104
+ // accessibility props
105
+ isFocused: _propTypes["default"].bool,
106
+ getFirstFocusableDay: _propTypes["default"].func,
107
+ onBlur: _propTypes["default"].func,
108
+ showKeyboardShortcuts: _propTypes["default"].bool,
109
+ onTab: _propTypes["default"].func,
110
+ onShiftTab: _propTypes["default"].func,
111
+ // internationalization
112
+ monthFormat: _propTypes["default"].string,
113
+ weekDayFormat: _propTypes["default"].string,
114
+ phrases: _propTypes["default"].shape((0, _getPhrasePropTypes["default"])(_defaultPhrases.DayPickerPhrases)),
115
+ dayAriaLabelFormat: _propTypes["default"].string
116
+ })) : {};
117
+ var defaultProps = exports.defaultProps = {
118
+ // calendar presentation props
119
+ enableOutsideDays: false,
120
+ numberOfMonths: 2,
121
+ orientation: _constants.HORIZONTAL_ORIENTATION,
122
+ withPortal: false,
123
+ onOutsideClick: function onOutsideClick() {},
124
+ hidden: false,
125
+ initialVisibleMonth: function initialVisibleMonth() {
126
+ return (0, _moment["default"])();
127
+ },
128
+ firstDayOfWeek: null,
129
+ renderCalendarInfo: null,
130
+ calendarInfoPosition: _constants.INFO_POSITION_BOTTOM,
131
+ hideKeyboardShortcutsPanel: false,
132
+ daySize: _constants.DAY_SIZE,
133
+ isRTL: false,
134
+ verticalHeight: null,
135
+ noBorder: false,
136
+ transitionDuration: undefined,
137
+ verticalBorderSpacing: undefined,
138
+ horizontalMonthPadding: 13,
139
+ renderKeyboardShortcutsButton: undefined,
140
+ renderKeyboardShortcutsPanel: undefined,
141
+ // navigation props
142
+ dayPickerNavigationInlineStyles: null,
143
+ disablePrev: false,
144
+ disableNext: false,
145
+ navPosition: _constants.NAV_POSITION_TOP,
146
+ navPrev: null,
147
+ navNext: null,
148
+ renderNavPrevButton: null,
149
+ renderNavNextButton: null,
150
+ noNavButtons: false,
151
+ noNavNextButton: false,
152
+ noNavPrevButton: false,
153
+ onPrevMonthClick: function onPrevMonthClick() {},
154
+ onNextMonthClick: function onNextMonthClick() {},
155
+ onMonthChange: function onMonthChange() {},
156
+ onYearChange: function onYearChange() {},
157
+ onGetNextScrollableMonths: function onGetNextScrollableMonths() {},
158
+ onGetPrevScrollableMonths: function onGetPrevScrollableMonths() {},
159
+ // month props
160
+ renderMonthText: null,
161
+ renderMonthElement: null,
162
+ renderWeekHeaderElement: null,
163
+ // day props
164
+ modifiers: {},
165
+ renderCalendarDay: undefined,
166
+ renderDayContents: null,
167
+ onDayClick: function onDayClick() {},
168
+ onDayMouseEnter: function onDayMouseEnter() {},
169
+ onDayMouseLeave: function onDayMouseLeave() {},
170
+ // accessibility props
171
+ isFocused: false,
172
+ getFirstFocusableDay: null,
173
+ onBlur: function onBlur() {},
174
+ showKeyboardShortcuts: false,
175
+ onTab: function onTab() {},
176
+ onShiftTab: function onShiftTab() {},
177
+ // internationalization
178
+ monthFormat: 'MMMM YYYY',
179
+ weekDayFormat: 'dd',
180
+ phrases: _defaultPhrases.DayPickerPhrases,
181
+ dayAriaLabelFormat: undefined
182
+ };
183
+ var DayPicker = exports.PureDayPicker = /*#__PURE__*/function (_ref2, _ref) {
184
+ function DayPicker(props) {
185
+ var _this;
186
+ _this = _ref2.call(this, props) || this;
187
+ var currentMonth = props.hidden ? (0, _moment["default"])() : props.initialVisibleMonth();
188
+ var focusedDate = currentMonth.clone().startOf('month').hour(12);
189
+ if (props.getFirstFocusableDay) {
190
+ focusedDate = props.getFirstFocusableDay(currentMonth);
191
+ }
192
+ var horizontalMonthPadding = props.horizontalMonthPadding;
193
+ var translationValue = props.isRTL && _this.isHorizontal() ? -(0, _getCalendarMonthWidth["default"])(props.daySize, horizontalMonthPadding) : 0;
194
+ _this.hasSetInitialVisibleMonth = !props.hidden;
195
+ _this.state = {
196
+ currentMonth: currentMonth,
197
+ monthTransition: null,
198
+ translationValue: translationValue,
199
+ scrollableMonthMultiple: 1,
200
+ calendarMonthWidth: (0, _getCalendarMonthWidth["default"])(props.daySize, horizontalMonthPadding),
201
+ focusedDate: !props.hidden || props.isFocused ? focusedDate : null,
202
+ nextFocusedDate: null,
203
+ showKeyboardShortcuts: props.showKeyboardShortcuts,
204
+ onKeyboardShortcutsPanelClose: function onKeyboardShortcutsPanelClose() {},
205
+ isTouchDevice: (0, _isTouchDevice["default"])(),
206
+ withMouseInteractions: true,
207
+ calendarInfoWidth: 0,
208
+ monthTitleHeight: null,
209
+ hasSetHeight: false
210
+ };
211
+ _this.setCalendarMonthWeeks(currentMonth);
212
+ _this.calendarMonthGridHeight = 0;
213
+ _this.setCalendarInfoWidthTimeout = null;
214
+ _this.setCalendarMonthGridHeightTimeout = null;
215
+ _this.onKeyDown = _this.onKeyDown.bind(_this);
216
+ _this.throttledKeyDown = (0, _throttle["default"])(_this.onFinalKeyDown, 200, {
217
+ trailing: false
218
+ });
219
+ _this.onPrevMonthClick = _this.onPrevMonthClick.bind(_this);
220
+ _this.onPrevMonthTransition = _this.onPrevMonthTransition.bind(_this);
221
+ _this.onNextMonthClick = _this.onNextMonthClick.bind(_this);
222
+ _this.onNextMonthTransition = _this.onNextMonthTransition.bind(_this);
223
+ _this.onMonthChange = _this.onMonthChange.bind(_this);
224
+ _this.onYearChange = _this.onYearChange.bind(_this);
225
+ _this.getNextScrollableMonths = _this.getNextScrollableMonths.bind(_this);
226
+ _this.getPrevScrollableMonths = _this.getPrevScrollableMonths.bind(_this);
227
+ _this.updateStateAfterMonthTransition = _this.updateStateAfterMonthTransition.bind(_this);
228
+ _this.openKeyboardShortcutsPanel = _this.openKeyboardShortcutsPanel.bind(_this);
229
+ _this.closeKeyboardShortcutsPanel = _this.closeKeyboardShortcutsPanel.bind(_this);
230
+ _this.setCalendarInfoRef = _this.setCalendarInfoRef.bind(_this);
231
+ _this.setContainerRef = _this.setContainerRef.bind(_this);
232
+ _this.setTransitionContainerRef = _this.setTransitionContainerRef.bind(_this);
233
+ _this.setMonthTitleHeight = _this.setMonthTitleHeight.bind(_this);
234
+ return _this;
235
+ }
236
+ (0, _inheritsLoose2["default"])(DayPicker, _ref2);
237
+ var _proto = DayPicker.prototype;
238
+ _proto[_ref] = function (nextProps, nextState) {
239
+ return !(0, _enzymeShallowEqual["default"])(this.props, nextProps) || !(0, _enzymeShallowEqual["default"])(this.state, nextState);
240
+ };
241
+ _proto.componentDidMount = function componentDidMount() {
242
+ var currentMonth = this.state.currentMonth;
243
+ var calendarInfoWidth = this.calendarInfo ? (0, _calculateDimension["default"])(this.calendarInfo, 'width', true, true) : 0;
244
+ this.setState({
245
+ isTouchDevice: (0, _isTouchDevice["default"])(),
246
+ calendarInfoWidth: calendarInfoWidth
247
+ });
248
+ this.setCalendarMonthWeeks(currentMonth);
249
+ };
250
+ _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps, prevState) {
251
+ var orientation = this.props.orientation;
252
+ var currentMonth = this.state.currentMonth;
253
+
254
+ // Capture the scroll position before the DOM is updated so that, when previous
255
+ // months are rendered above the current month, we can restore scroll afterwards
256
+ // (in componentDidUpdate) and keep the previous current month in view. This used
257
+ // to live in componentWillReceiveProps; getSnapshotBeforeUpdate is the supported
258
+ // place to read layout right before a commit.
259
+ if (orientation === _constants.VERTICAL_SCROLLABLE && this.transitionContainer && !(0, _isSameMonth["default"])(prevState.currentMonth, currentMonth)) {
260
+ return this.transitionContainer.scrollHeight - this.transitionContainer.scrollTop;
261
+ }
262
+ return null;
263
+ };
264
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState, snapshot) {
265
+ var _this2 = this;
266
+ var _this$props = this.props,
267
+ hidden = _this$props.hidden,
268
+ isFocused = _this$props.isFocused,
269
+ showKeyboardShortcuts = _this$props.showKeyboardShortcuts,
270
+ onBlur = _this$props.onBlur,
271
+ orientation = _this$props.orientation,
272
+ renderMonthText = _this$props.renderMonthText,
273
+ horizontalMonthPadding = _this$props.horizontalMonthPadding,
274
+ daySize = _this$props.daySize,
275
+ numberOfMonths = _this$props.numberOfMonths,
276
+ transitionDuration = _this$props.transitionDuration,
277
+ initialVisibleMonth = _this$props.initialVisibleMonth;
278
+ var _this$state = this.state,
279
+ currentMonth = _this$state.currentMonth,
280
+ focusedDate = _this$state.focusedDate,
281
+ monthTitleHeight = _this$state.monthTitleHeight;
282
+
283
+ // ----- migrated from componentWillReceiveProps -----
284
+ // Only re-sync the visible month in response to a props change (a new props
285
+ // object from the parent), never on our own setState-driven updates, otherwise
286
+ // internal state changes (e.g. hover) would call initialVisibleMonth() and could
287
+ // snap the calendar back to that month.
288
+ if (prevProps !== this.props && !hidden) {
289
+ if (!this.hasSetInitialVisibleMonth) {
290
+ this.hasSetInitialVisibleMonth = true;
291
+ this.setState({
292
+ currentMonth: initialVisibleMonth()
293
+ });
294
+ } else {
295
+ var newDate = initialVisibleMonth();
296
+ if (!(0, _isDayVisible["default"])(newDate, currentMonth, numberOfMonths)) {
297
+ this.onMonthChange(newDate);
298
+ }
299
+ }
300
+ }
301
+ if (daySize !== prevProps.daySize) {
302
+ this.setState({
303
+ calendarMonthWidth: (0, _getCalendarMonthWidth["default"])(daySize, horizontalMonthPadding)
304
+ });
305
+ }
306
+
307
+ // Track the focusedDate that this update produces so the container-focus check
308
+ // below sees the same value componentWillReceiveProps used to set before render.
309
+ var focusedDateAfterUpdate = focusedDate;
310
+ if (isFocused !== prevProps.isFocused) {
311
+ if (isFocused) {
312
+ var newFocusedDate = this.getFocusedDay(currentMonth);
313
+ var onKeyboardShortcutsPanelClose = this.state.onKeyboardShortcutsPanelClose;
314
+ if (showKeyboardShortcuts) {
315
+ // the ? shortcut came from the input and we should return input there once it is close
316
+ onKeyboardShortcutsPanelClose = onBlur;
317
+ }
318
+ this.setState({
319
+ showKeyboardShortcuts: showKeyboardShortcuts,
320
+ onKeyboardShortcutsPanelClose: onKeyboardShortcutsPanelClose,
321
+ focusedDate: newFocusedDate,
322
+ withMouseInteractions: false
323
+ });
324
+ focusedDateAfterUpdate = newFocusedDate;
325
+ } else {
326
+ this.setState({
327
+ focusedDate: null
328
+ });
329
+ focusedDateAfterUpdate = null;
330
+ }
331
+ }
332
+ if (renderMonthText !== null && prevProps.renderMonthText !== null && renderMonthText(currentMonth) !== prevProps.renderMonthText(currentMonth)) {
333
+ this.setState({
334
+ monthTitleHeight: null
335
+ });
336
+ }
337
+
338
+ // ----- migrated from componentWillUpdate -----
339
+ // Calculating the dimensions triggers a DOM repaint which breaks the CSS
340
+ // transition. The setTimeout waits until the transition ends.
341
+ if (this.calendarInfo) {
342
+ this.setCalendarInfoWidthTimeout = setTimeout(function () {
343
+ var calendarInfoWidth = _this2.state.calendarInfoWidth;
344
+ var calendarInfoPanelWidth = (0, _calculateDimension["default"])(_this2.calendarInfo, 'width', true, true);
345
+ if (calendarInfoWidth !== calendarInfoPanelWidth) {
346
+ _this2.setState({
347
+ calendarInfoWidth: calendarInfoPanelWidth
348
+ });
349
+ }
350
+ }, transitionDuration);
351
+ }
352
+
353
+ // ----- existing componentDidUpdate behaviour -----
354
+ var shouldAdjustHeight = false;
355
+ if (numberOfMonths !== prevProps.numberOfMonths) {
356
+ this.setCalendarMonthWeeks(currentMonth);
357
+ shouldAdjustHeight = true;
358
+ }
359
+ if (this.isHorizontal() && (orientation !== prevProps.orientation || daySize !== prevProps.daySize)) {
360
+ shouldAdjustHeight = true;
361
+ }
362
+ if (shouldAdjustHeight) {
363
+ var visibleCalendarWeeks = this.calendarMonthWeeks.slice(1, numberOfMonths + 1);
364
+ var calendarMonthWeeksHeight = Math.max.apply(Math, [0].concat((0, _toConsumableArray2["default"])(visibleCalendarWeeks))) * (daySize - 1);
365
+ var newMonthHeight = monthTitleHeight + calendarMonthWeeksHeight + 1;
366
+ this.adjustDayPickerHeight(newMonthHeight);
367
+ }
368
+ if (!prevProps.isFocused && isFocused && !focusedDateAfterUpdate) {
369
+ this.container.focus();
370
+ }
371
+
372
+ // If orientation is VERTICAL_SCROLLABLE and currentMonth has changed adjust scrollTop so the
373
+ // new months rendered above the current month don't push the current month out of view.
374
+ if (orientation === _constants.VERTICAL_SCROLLABLE && snapshot != null && this.transitionContainer) {
375
+ this.transitionContainer.scrollTop = this.transitionContainer.scrollHeight - snapshot;
376
+ }
377
+ };
378
+ _proto.componentWillUnmount = function componentWillUnmount() {
379
+ clearTimeout(this.setCalendarInfoWidthTimeout);
380
+ clearTimeout(this.setCalendarMonthGridHeightTimeout);
381
+ };
382
+ _proto.onKeyDown = function onKeyDown(e) {
383
+ e.stopPropagation();
384
+ if (!_constants.MODIFIER_KEY_NAMES.has(e.key)) {
385
+ this.throttledKeyDown(e);
386
+ }
387
+ };
388
+ _proto.onFinalKeyDown = function onFinalKeyDown(e) {
389
+ this.setState({
390
+ withMouseInteractions: false
391
+ });
392
+ var _this$props2 = this.props,
393
+ onBlur = _this$props2.onBlur,
394
+ onTab = _this$props2.onTab,
395
+ onShiftTab = _this$props2.onShiftTab,
396
+ isRTL = _this$props2.isRTL;
397
+ var _this$state2 = this.state,
398
+ focusedDate = _this$state2.focusedDate,
399
+ showKeyboardShortcuts = _this$state2.showKeyboardShortcuts;
400
+ if (!focusedDate) return;
401
+ var newFocusedDate = focusedDate.clone();
402
+ var didTransitionMonth = false;
403
+
404
+ // focus might be anywhere when the keyboard shortcuts panel is opened so we want to
405
+ // return it to wherever it was before when the panel was opened
406
+ var activeElement = (0, _getActiveElement["default"])();
407
+ var onKeyboardShortcutsPanelClose = function onKeyboardShortcutsPanelClose() {
408
+ if (activeElement) activeElement.focus();
409
+ };
410
+ switch (e.key) {
411
+ case 'ArrowUp':
412
+ e.preventDefault();
413
+ newFocusedDate.subtract(1, 'week');
414
+ didTransitionMonth = this.maybeTransitionPrevMonth(newFocusedDate);
415
+ break;
416
+ case 'ArrowLeft':
417
+ e.preventDefault();
418
+ if (isRTL) {
419
+ newFocusedDate.add(1, 'day');
420
+ didTransitionMonth = this.maybeTransitionNextMonth(newFocusedDate);
421
+ } else {
422
+ newFocusedDate.subtract(1, 'day');
423
+ didTransitionMonth = this.maybeTransitionPrevMonth(newFocusedDate);
424
+ }
425
+ break;
426
+ case 'Home':
427
+ e.preventDefault();
428
+ newFocusedDate.startOf('week').hour(12);
429
+ didTransitionMonth = this.maybeTransitionPrevMonth(newFocusedDate);
430
+ break;
431
+ case 'PageUp':
432
+ e.preventDefault();
433
+ newFocusedDate.subtract(1, 'month');
434
+ didTransitionMonth = this.maybeTransitionPrevMonth(newFocusedDate);
435
+ break;
436
+ case 'ArrowDown':
437
+ e.preventDefault();
438
+ newFocusedDate.add(1, 'week');
439
+ didTransitionMonth = this.maybeTransitionNextMonth(newFocusedDate);
440
+ break;
441
+ case 'ArrowRight':
442
+ e.preventDefault();
443
+ if (isRTL) {
444
+ newFocusedDate.subtract(1, 'day');
445
+ didTransitionMonth = this.maybeTransitionPrevMonth(newFocusedDate);
446
+ } else {
447
+ newFocusedDate.add(1, 'day');
448
+ didTransitionMonth = this.maybeTransitionNextMonth(newFocusedDate);
449
+ }
450
+ break;
451
+ case 'End':
452
+ e.preventDefault();
453
+ newFocusedDate.endOf('week');
454
+ didTransitionMonth = this.maybeTransitionNextMonth(newFocusedDate);
455
+ break;
456
+ case 'PageDown':
457
+ e.preventDefault();
458
+ newFocusedDate.add(1, 'month');
459
+ didTransitionMonth = this.maybeTransitionNextMonth(newFocusedDate);
460
+ break;
461
+ case '?':
462
+ this.openKeyboardShortcutsPanel(onKeyboardShortcutsPanelClose);
463
+ break;
464
+ case 'Escape':
465
+ if (showKeyboardShortcuts) {
466
+ this.closeKeyboardShortcutsPanel();
467
+ } else {
468
+ onBlur(e);
469
+ }
470
+ break;
471
+ case 'Tab':
472
+ if (e.shiftKey) {
473
+ onShiftTab();
474
+ } else {
475
+ onTab(e);
476
+ }
477
+ break;
478
+ default:
479
+ break;
480
+ }
481
+
482
+ // If there was a month transition, do not update the focused date until the transition has
483
+ // completed. Otherwise, attempting to focus on a DOM node may interrupt the CSS animation. If
484
+ // didTransitionMonth is true, the focusedDate gets updated in #updateStateAfterMonthTransition
485
+ if (!didTransitionMonth) {
486
+ this.setState({
487
+ focusedDate: newFocusedDate
488
+ });
489
+ }
490
+ };
491
+ _proto.onPrevMonthClick = function onPrevMonthClick(e) {
492
+ if (e) e.preventDefault();
493
+ this.onPrevMonthTransition();
494
+ };
495
+ _proto.onPrevMonthTransition = function onPrevMonthTransition(nextFocusedDate) {
496
+ var _this$props3 = this.props,
497
+ daySize = _this$props3.daySize,
498
+ isRTL = _this$props3.isRTL,
499
+ numberOfMonths = _this$props3.numberOfMonths;
500
+ var _this$state3 = this.state,
501
+ calendarMonthWidth = _this$state3.calendarMonthWidth,
502
+ monthTitleHeight = _this$state3.monthTitleHeight;
503
+ var translationValue;
504
+ if (this.isVertical()) {
505
+ var calendarMonthWeeksHeight = this.calendarMonthWeeks[0] * (daySize - 1);
506
+ translationValue = monthTitleHeight + calendarMonthWeeksHeight + 1;
507
+ } else if (this.isHorizontal()) {
508
+ translationValue = calendarMonthWidth;
509
+ if (isRTL) {
510
+ translationValue = -2 * calendarMonthWidth;
511
+ }
512
+ var visibleCalendarWeeks = this.calendarMonthWeeks.slice(0, numberOfMonths);
513
+ var _calendarMonthWeeksHeight = Math.max.apply(Math, [0].concat((0, _toConsumableArray2["default"])(visibleCalendarWeeks))) * (daySize - 1);
514
+ var newMonthHeight = monthTitleHeight + _calendarMonthWeeksHeight + 1;
515
+ this.adjustDayPickerHeight(newMonthHeight);
516
+ }
517
+ this.setState({
518
+ monthTransition: PREV_TRANSITION,
519
+ translationValue: translationValue,
520
+ focusedDate: null,
521
+ nextFocusedDate: nextFocusedDate
522
+ });
523
+ };
524
+ _proto.onMonthChange = function onMonthChange(currentMonth) {
525
+ this.setCalendarMonthWeeks(currentMonth);
526
+ this.calculateAndSetDayPickerHeight();
527
+
528
+ // Translation value is a hack to force an invisible transition that
529
+ // properly rerenders the CalendarMonthGrid
530
+ this.setState({
531
+ monthTransition: MONTH_SELECTION_TRANSITION,
532
+ translationValue: 0.00001,
533
+ focusedDate: null,
534
+ nextFocusedDate: currentMonth,
535
+ currentMonth: currentMonth
536
+ });
537
+ };
538
+ _proto.onYearChange = function onYearChange(currentMonth) {
539
+ this.setCalendarMonthWeeks(currentMonth);
540
+ this.calculateAndSetDayPickerHeight();
541
+
542
+ // Translation value is a hack to force an invisible transition that
543
+ // properly rerenders the CalendarMonthGrid
544
+ this.setState({
545
+ monthTransition: YEAR_SELECTION_TRANSITION,
546
+ translationValue: 0.0001,
547
+ focusedDate: null,
548
+ nextFocusedDate: currentMonth,
549
+ currentMonth: currentMonth
550
+ });
551
+ };
552
+ _proto.onNextMonthClick = function onNextMonthClick(e) {
553
+ if (e) e.preventDefault();
554
+ this.onNextMonthTransition();
555
+ };
556
+ _proto.onNextMonthTransition = function onNextMonthTransition(nextFocusedDate) {
557
+ var _this$props4 = this.props,
558
+ isRTL = _this$props4.isRTL,
559
+ numberOfMonths = _this$props4.numberOfMonths,
560
+ daySize = _this$props4.daySize;
561
+ var _this$state4 = this.state,
562
+ calendarMonthWidth = _this$state4.calendarMonthWidth,
563
+ monthTitleHeight = _this$state4.monthTitleHeight;
564
+ var translationValue;
565
+ if (this.isVertical()) {
566
+ var firstVisibleMonthWeeks = this.calendarMonthWeeks[1];
567
+ var calendarMonthWeeksHeight = firstVisibleMonthWeeks * (daySize - 1);
568
+ translationValue = -(monthTitleHeight + calendarMonthWeeksHeight + 1);
569
+ }
570
+ if (this.isHorizontal()) {
571
+ translationValue = -calendarMonthWidth;
572
+ if (isRTL) {
573
+ translationValue = 0;
574
+ }
575
+ var visibleCalendarWeeks = this.calendarMonthWeeks.slice(2, numberOfMonths + 2);
576
+ var _calendarMonthWeeksHeight2 = Math.max.apply(Math, [0].concat((0, _toConsumableArray2["default"])(visibleCalendarWeeks))) * (daySize - 1);
577
+ var newMonthHeight = monthTitleHeight + _calendarMonthWeeksHeight2 + 1;
578
+ this.adjustDayPickerHeight(newMonthHeight);
579
+ }
580
+ this.setState({
581
+ monthTransition: NEXT_TRANSITION,
582
+ translationValue: translationValue,
583
+ focusedDate: null,
584
+ nextFocusedDate: nextFocusedDate
585
+ });
586
+ };
587
+ _proto.getFirstDayOfWeek = function getFirstDayOfWeek() {
588
+ var firstDayOfWeek = this.props.firstDayOfWeek;
589
+ if (firstDayOfWeek == null) {
590
+ return _moment["default"].localeData().firstDayOfWeek();
591
+ }
592
+ return firstDayOfWeek;
593
+ };
594
+ _proto.getWeekHeaders = function getWeekHeaders() {
595
+ var weekDayFormat = this.props.weekDayFormat;
596
+ var currentMonth = this.state.currentMonth;
597
+ var firstDayOfWeek = this.getFirstDayOfWeek();
598
+ var weekHeaders = [];
599
+ for (var i = 0; i < 7; i += 1) {
600
+ weekHeaders.push(currentMonth.clone().day((i + firstDayOfWeek) % 7).format(weekDayFormat));
601
+ }
602
+ return weekHeaders;
603
+ };
604
+ _proto.getFirstVisibleIndex = function getFirstVisibleIndex() {
605
+ var orientation = this.props.orientation;
606
+ var monthTransition = this.state.monthTransition;
607
+ if (orientation === _constants.VERTICAL_SCROLLABLE) return 0;
608
+ var firstVisibleMonthIndex = 1;
609
+ if (monthTransition === PREV_TRANSITION) {
610
+ firstVisibleMonthIndex -= 1;
611
+ } else if (monthTransition === NEXT_TRANSITION) {
612
+ firstVisibleMonthIndex += 1;
613
+ }
614
+ return firstVisibleMonthIndex;
615
+ };
616
+ _proto.getFocusedDay = function getFocusedDay(newMonth) {
617
+ var _this$props5 = this.props,
618
+ getFirstFocusableDay = _this$props5.getFirstFocusableDay,
619
+ numberOfMonths = _this$props5.numberOfMonths;
620
+ var focusedDate;
621
+ if (getFirstFocusableDay) {
622
+ focusedDate = getFirstFocusableDay(newMonth);
623
+ }
624
+ if (newMonth && (!focusedDate || !(0, _isDayVisible["default"])(focusedDate, newMonth, numberOfMonths))) {
625
+ focusedDate = newMonth.clone().startOf('month').hour(12);
626
+ }
627
+ return focusedDate;
628
+ };
629
+ _proto.setMonthTitleHeight = function setMonthTitleHeight(monthTitleHeight) {
630
+ var _this3 = this;
631
+ this.setState({
632
+ monthTitleHeight: monthTitleHeight
633
+ }, function () {
634
+ _this3.calculateAndSetDayPickerHeight();
635
+ });
636
+ };
637
+ _proto.setCalendarMonthWeeks = function setCalendarMonthWeeks(currentMonth) {
638
+ var numberOfMonths = this.props.numberOfMonths;
639
+ this.calendarMonthWeeks = [];
640
+ var month = currentMonth.clone().subtract(1, 'months');
641
+ var firstDayOfWeek = this.getFirstDayOfWeek();
642
+ for (var i = 0; i < numberOfMonths + 2; i += 1) {
643
+ var numberOfWeeks = (0, _getNumberOfCalendarMonthWeeks["default"])(month, firstDayOfWeek);
644
+ this.calendarMonthWeeks.push(numberOfWeeks);
645
+ month = month.add(1, 'months');
646
+ }
647
+ };
648
+ _proto.setContainerRef = function setContainerRef(ref) {
649
+ this.container = ref;
650
+ };
651
+ _proto.setCalendarInfoRef = function setCalendarInfoRef(ref) {
652
+ this.calendarInfo = ref;
653
+ };
654
+ _proto.setTransitionContainerRef = function setTransitionContainerRef(ref) {
655
+ this.transitionContainer = ref;
656
+ };
657
+ _proto.getNextScrollableMonths = function getNextScrollableMonths(e) {
658
+ var onGetNextScrollableMonths = this.props.onGetNextScrollableMonths;
659
+ if (e) e.preventDefault();
660
+ if (onGetNextScrollableMonths) onGetNextScrollableMonths(e);
661
+ this.setState(function (_ref3) {
662
+ var scrollableMonthMultiple = _ref3.scrollableMonthMultiple;
663
+ return {
664
+ scrollableMonthMultiple: scrollableMonthMultiple + 1
665
+ };
666
+ });
667
+ };
668
+ _proto.getPrevScrollableMonths = function getPrevScrollableMonths(e) {
669
+ var _this$props6 = this.props,
670
+ numberOfMonths = _this$props6.numberOfMonths,
671
+ onGetPrevScrollableMonths = _this$props6.onGetPrevScrollableMonths;
672
+ if (e) e.preventDefault();
673
+ if (onGetPrevScrollableMonths) onGetPrevScrollableMonths(e);
674
+ this.setState(function (_ref4) {
675
+ var currentMonth = _ref4.currentMonth,
676
+ scrollableMonthMultiple = _ref4.scrollableMonthMultiple;
677
+ return {
678
+ currentMonth: currentMonth.clone().subtract(numberOfMonths, 'month'),
679
+ scrollableMonthMultiple: scrollableMonthMultiple + 1
680
+ };
681
+ });
682
+ };
683
+ _proto.maybeTransitionNextMonth = function maybeTransitionNextMonth(newFocusedDate) {
684
+ var numberOfMonths = this.props.numberOfMonths;
685
+ var _this$state5 = this.state,
686
+ currentMonth = _this$state5.currentMonth,
687
+ focusedDate = _this$state5.focusedDate;
688
+ var newFocusedDateMonth = newFocusedDate.month();
689
+ var focusedDateMonth = focusedDate.month();
690
+ var isNewFocusedDateVisible = (0, _isDayVisible["default"])(newFocusedDate, currentMonth, numberOfMonths);
691
+ if (newFocusedDateMonth !== focusedDateMonth && !isNewFocusedDateVisible) {
692
+ this.onNextMonthTransition(newFocusedDate);
693
+ return true;
694
+ }
695
+ return false;
696
+ };
697
+ _proto.maybeTransitionPrevMonth = function maybeTransitionPrevMonth(newFocusedDate) {
698
+ var numberOfMonths = this.props.numberOfMonths;
699
+ var _this$state6 = this.state,
700
+ currentMonth = _this$state6.currentMonth,
701
+ focusedDate = _this$state6.focusedDate;
702
+ var newFocusedDateMonth = newFocusedDate.month();
703
+ var focusedDateMonth = focusedDate.month();
704
+ var isNewFocusedDateVisible = (0, _isDayVisible["default"])(newFocusedDate, currentMonth, numberOfMonths);
705
+ if (newFocusedDateMonth !== focusedDateMonth && !isNewFocusedDateVisible) {
706
+ this.onPrevMonthTransition(newFocusedDate);
707
+ return true;
708
+ }
709
+ return false;
710
+ };
711
+ _proto.isHorizontal = function isHorizontal() {
712
+ var orientation = this.props.orientation;
713
+ return orientation === _constants.HORIZONTAL_ORIENTATION;
714
+ };
715
+ _proto.isVertical = function isVertical() {
716
+ var orientation = this.props.orientation;
717
+ return orientation === _constants.VERTICAL_ORIENTATION || orientation === _constants.VERTICAL_SCROLLABLE;
718
+ };
719
+ _proto.updateStateAfterMonthTransition = function updateStateAfterMonthTransition() {
720
+ var _this4 = this;
721
+ var _this$props7 = this.props,
722
+ onPrevMonthClick = _this$props7.onPrevMonthClick,
723
+ onNextMonthClick = _this$props7.onNextMonthClick,
724
+ numberOfMonths = _this$props7.numberOfMonths,
725
+ onMonthChange = _this$props7.onMonthChange,
726
+ onYearChange = _this$props7.onYearChange,
727
+ isRTL = _this$props7.isRTL;
728
+ var _this$state7 = this.state,
729
+ currentMonth = _this$state7.currentMonth,
730
+ monthTransition = _this$state7.monthTransition,
731
+ focusedDate = _this$state7.focusedDate,
732
+ nextFocusedDate = _this$state7.nextFocusedDate,
733
+ withMouseInteractions = _this$state7.withMouseInteractions,
734
+ calendarMonthWidth = _this$state7.calendarMonthWidth;
735
+ if (!monthTransition) return;
736
+ var newMonth = currentMonth.clone();
737
+ var firstDayOfWeek = this.getFirstDayOfWeek();
738
+ if (monthTransition === PREV_TRANSITION) {
739
+ newMonth.subtract(1, 'month');
740
+ if (onPrevMonthClick) onPrevMonthClick(newMonth);
741
+ var newInvisibleMonth = newMonth.clone().subtract(1, 'month');
742
+ var numberOfWeeks = (0, _getNumberOfCalendarMonthWeeks["default"])(newInvisibleMonth, firstDayOfWeek);
743
+ this.calendarMonthWeeks = [numberOfWeeks].concat((0, _toConsumableArray2["default"])(this.calendarMonthWeeks.slice(0, -1)));
744
+ } else if (monthTransition === NEXT_TRANSITION) {
745
+ newMonth.add(1, 'month');
746
+ if (onNextMonthClick) onNextMonthClick(newMonth);
747
+ var _newInvisibleMonth = newMonth.clone().add(numberOfMonths, 'month');
748
+ var _numberOfWeeks = (0, _getNumberOfCalendarMonthWeeks["default"])(_newInvisibleMonth, firstDayOfWeek);
749
+ this.calendarMonthWeeks = [].concat((0, _toConsumableArray2["default"])(this.calendarMonthWeeks.slice(1)), [_numberOfWeeks]);
750
+ } else if (monthTransition === MONTH_SELECTION_TRANSITION) {
751
+ if (onMonthChange) onMonthChange(newMonth);
752
+ } else if (monthTransition === YEAR_SELECTION_TRANSITION) {
753
+ if (onYearChange) onYearChange(newMonth);
754
+ }
755
+ var newFocusedDate = null;
756
+ if (nextFocusedDate) {
757
+ newFocusedDate = nextFocusedDate;
758
+ } else if (!focusedDate && !withMouseInteractions) {
759
+ newFocusedDate = this.getFocusedDay(newMonth);
760
+ }
761
+ this.setState({
762
+ currentMonth: newMonth,
763
+ monthTransition: null,
764
+ translationValue: isRTL && this.isHorizontal() ? -calendarMonthWidth : 0,
765
+ nextFocusedDate: null,
766
+ focusedDate: newFocusedDate
767
+ }, function () {
768
+ // we don't want to focus on the relevant calendar day after a month transition
769
+ // if the user is navigating around using a mouse
770
+ if (withMouseInteractions) {
771
+ var activeElement = (0, _getActiveElement["default"])();
772
+ if (activeElement && activeElement !== document.body && _this4.container.contains(activeElement) && activeElement.blur) {
773
+ activeElement.blur();
774
+ }
775
+ }
776
+ });
777
+ };
778
+ _proto.adjustDayPickerHeight = function adjustDayPickerHeight(newMonthHeight) {
779
+ var _this5 = this;
780
+ var monthHeight = newMonthHeight + MONTH_PADDING;
781
+ if (monthHeight !== this.calendarMonthGridHeight) {
782
+ this.transitionContainer.style.height = "".concat(monthHeight, "px");
783
+ if (!this.calendarMonthGridHeight) {
784
+ this.setCalendarMonthGridHeightTimeout = setTimeout(function () {
785
+ _this5.setState({
786
+ hasSetHeight: true
787
+ });
788
+ }, 0);
789
+ }
790
+ this.calendarMonthGridHeight = monthHeight;
791
+ }
792
+ };
793
+ _proto.calculateAndSetDayPickerHeight = function calculateAndSetDayPickerHeight() {
794
+ var _this$props8 = this.props,
795
+ daySize = _this$props8.daySize,
796
+ numberOfMonths = _this$props8.numberOfMonths;
797
+ var monthTitleHeight = this.state.monthTitleHeight;
798
+ var visibleCalendarWeeks = this.calendarMonthWeeks.slice(1, numberOfMonths + 1);
799
+ var calendarMonthWeeksHeight = Math.max.apply(Math, [0].concat((0, _toConsumableArray2["default"])(visibleCalendarWeeks))) * (daySize - 1);
800
+ var newMonthHeight = monthTitleHeight + calendarMonthWeeksHeight + 1;
801
+ if (this.isHorizontal()) {
802
+ this.adjustDayPickerHeight(newMonthHeight);
803
+ }
804
+ };
805
+ _proto.openKeyboardShortcutsPanel = function openKeyboardShortcutsPanel(onCloseCallBack) {
806
+ this.setState({
807
+ showKeyboardShortcuts: true,
808
+ onKeyboardShortcutsPanelClose: onCloseCallBack
809
+ });
810
+ };
811
+ _proto.closeKeyboardShortcutsPanel = function closeKeyboardShortcutsPanel() {
812
+ var onKeyboardShortcutsPanelClose = this.state.onKeyboardShortcutsPanelClose;
813
+ if (onKeyboardShortcutsPanelClose) {
814
+ onKeyboardShortcutsPanelClose();
815
+ }
816
+ this.setState({
817
+ onKeyboardShortcutsPanelClose: null,
818
+ showKeyboardShortcuts: false
819
+ });
820
+ };
821
+ _proto.renderNavigation = function renderNavigation(navDirection) {
822
+ var _this$props9 = this.props,
823
+ dayPickerNavigationInlineStyles = _this$props9.dayPickerNavigationInlineStyles,
824
+ disablePrev = _this$props9.disablePrev,
825
+ disableNext = _this$props9.disableNext,
826
+ navPosition = _this$props9.navPosition,
827
+ navPrev = _this$props9.navPrev,
828
+ navNext = _this$props9.navNext,
829
+ noNavButtons = _this$props9.noNavButtons,
830
+ noNavNextButton = _this$props9.noNavNextButton,
831
+ noNavPrevButton = _this$props9.noNavPrevButton,
832
+ orientation = _this$props9.orientation,
833
+ phrases = _this$props9.phrases,
834
+ renderNavPrevButton = _this$props9.renderNavPrevButton,
835
+ renderNavNextButton = _this$props9.renderNavNextButton,
836
+ isRTL = _this$props9.isRTL;
837
+ if (noNavButtons) {
838
+ return null;
839
+ }
840
+ var onPrevMonthClick = orientation === _constants.VERTICAL_SCROLLABLE ? this.getPrevScrollableMonths : this.onPrevMonthClick;
841
+ var onNextMonthClick = orientation === _constants.VERTICAL_SCROLLABLE ? this.getNextScrollableMonths : this.onNextMonthClick;
842
+ return /*#__PURE__*/_react["default"].createElement(_DayPickerNavigation["default"], {
843
+ disablePrev: disablePrev,
844
+ disableNext: disableNext,
845
+ inlineStyles: dayPickerNavigationInlineStyles,
846
+ onPrevMonthClick: onPrevMonthClick,
847
+ onNextMonthClick: onNextMonthClick,
848
+ navPosition: navPosition,
849
+ navPrev: navPrev,
850
+ navNext: navNext,
851
+ renderNavPrevButton: renderNavPrevButton,
852
+ renderNavNextButton: renderNavNextButton,
853
+ orientation: orientation,
854
+ phrases: phrases,
855
+ isRTL: isRTL,
856
+ showNavNextButton: !(noNavNextButton || orientation === _constants.VERTICAL_SCROLLABLE && navDirection === PREV_NAV),
857
+ showNavPrevButton: !(noNavPrevButton || orientation === _constants.VERTICAL_SCROLLABLE && navDirection === NEXT_NAV)
858
+ });
859
+ };
860
+ _proto.renderWeekHeader = function renderWeekHeader(index) {
861
+ var _this$props0 = this.props,
862
+ daySize = _this$props0.daySize,
863
+ horizontalMonthPadding = _this$props0.horizontalMonthPadding,
864
+ orientation = _this$props0.orientation,
865
+ renderWeekHeaderElement = _this$props0.renderWeekHeaderElement,
866
+ css = _this$props0.css,
867
+ styles = _this$props0.styles;
868
+ var calendarMonthWidth = this.state.calendarMonthWidth;
869
+ var verticalScrollable = orientation === _constants.VERTICAL_SCROLLABLE;
870
+ var horizontalStyle = {
871
+ left: index * calendarMonthWidth
872
+ };
873
+ var verticalStyle = {
874
+ marginLeft: -calendarMonthWidth / 2
875
+ };
876
+ var weekHeaderStyle = {}; // no styles applied to the vertical-scrollable orientation
877
+ if (this.isHorizontal()) {
878
+ weekHeaderStyle = horizontalStyle;
879
+ } else if (this.isVertical() && !verticalScrollable) {
880
+ weekHeaderStyle = verticalStyle;
881
+ }
882
+ var weekHeaders = this.getWeekHeaders();
883
+ var header = weekHeaders.map(function (day) {
884
+ return /*#__PURE__*/_react["default"].createElement("li", (0, _extends2["default"])({
885
+ key: day
886
+ }, css(styles.DayPicker_weekHeader_li, {
887
+ width: daySize
888
+ })), renderWeekHeaderElement ? renderWeekHeaderElement(day) : /*#__PURE__*/_react["default"].createElement("small", null, day));
889
+ });
890
+ return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, css(styles.DayPicker_weekHeader, this.isVertical() && styles.DayPicker_weekHeader__vertical, verticalScrollable && styles.DayPicker_weekHeader__verticalScrollable, weekHeaderStyle, {
891
+ padding: "0 ".concat(horizontalMonthPadding, "px")
892
+ }), {
893
+ key: "week-".concat(index)
894
+ }), /*#__PURE__*/_react["default"].createElement("ul", css(styles.DayPicker_weekHeader_ul), header));
895
+ };
896
+ _proto.render = function render() {
897
+ var _this6 = this;
898
+ var _this$state8 = this.state,
899
+ calendarMonthWidth = _this$state8.calendarMonthWidth,
900
+ currentMonth = _this$state8.currentMonth,
901
+ monthTransition = _this$state8.monthTransition,
902
+ translationValue = _this$state8.translationValue,
903
+ scrollableMonthMultiple = _this$state8.scrollableMonthMultiple,
904
+ focusedDate = _this$state8.focusedDate,
905
+ showKeyboardShortcuts = _this$state8.showKeyboardShortcuts,
906
+ isTouch = _this$state8.isTouchDevice,
907
+ hasSetHeight = _this$state8.hasSetHeight,
908
+ calendarInfoWidth = _this$state8.calendarInfoWidth,
909
+ monthTitleHeight = _this$state8.monthTitleHeight;
910
+ var _this$props1 = this.props,
911
+ enableOutsideDays = _this$props1.enableOutsideDays,
912
+ numberOfMonths = _this$props1.numberOfMonths,
913
+ orientation = _this$props1.orientation,
914
+ modifiers = _this$props1.modifiers,
915
+ withPortal = _this$props1.withPortal,
916
+ onDayClick = _this$props1.onDayClick,
917
+ onDayMouseEnter = _this$props1.onDayMouseEnter,
918
+ onDayMouseLeave = _this$props1.onDayMouseLeave,
919
+ firstDayOfWeek = _this$props1.firstDayOfWeek,
920
+ renderMonthText = _this$props1.renderMonthText,
921
+ renderCalendarDay = _this$props1.renderCalendarDay,
922
+ renderDayContents = _this$props1.renderDayContents,
923
+ renderCalendarInfo = _this$props1.renderCalendarInfo,
924
+ renderMonthElement = _this$props1.renderMonthElement,
925
+ renderKeyboardShortcutsButton = _this$props1.renderKeyboardShortcutsButton,
926
+ renderKeyboardShortcutsPanel = _this$props1.renderKeyboardShortcutsPanel,
927
+ calendarInfoPosition = _this$props1.calendarInfoPosition,
928
+ hideKeyboardShortcutsPanel = _this$props1.hideKeyboardShortcutsPanel,
929
+ onOutsideClick = _this$props1.onOutsideClick,
930
+ monthFormat = _this$props1.monthFormat,
931
+ daySize = _this$props1.daySize,
932
+ isFocused = _this$props1.isFocused,
933
+ isRTL = _this$props1.isRTL,
934
+ css = _this$props1.css,
935
+ styles = _this$props1.styles,
936
+ theme = _this$props1.theme,
937
+ phrases = _this$props1.phrases,
938
+ verticalHeight = _this$props1.verticalHeight,
939
+ dayAriaLabelFormat = _this$props1.dayAriaLabelFormat,
940
+ noBorder = _this$props1.noBorder,
941
+ transitionDuration = _this$props1.transitionDuration,
942
+ verticalBorderSpacing = _this$props1.verticalBorderSpacing,
943
+ horizontalMonthPadding = _this$props1.horizontalMonthPadding,
944
+ navPosition = _this$props1.navPosition;
945
+ var dayPickerHorizontalPadding = theme.reactDates.spacing.dayPickerHorizontalPadding;
946
+ var isHorizontal = this.isHorizontal();
947
+ var numOfWeekHeaders = this.isVertical() ? 1 : numberOfMonths;
948
+ var weekHeaders = [];
949
+ for (var i = 0; i < numOfWeekHeaders; i += 1) {
950
+ weekHeaders.push(this.renderWeekHeader(i));
951
+ }
952
+ var verticalScrollable = orientation === _constants.VERTICAL_SCROLLABLE;
953
+ var height;
954
+ if (isHorizontal) {
955
+ height = this.calendarMonthGridHeight;
956
+ } else if (this.isVertical() && !verticalScrollable && !withPortal) {
957
+ // If the user doesn't set a desired height,
958
+ // we default back to this kind of made-up value that generally looks good
959
+ height = verticalHeight || 1.75 * calendarMonthWidth;
960
+ }
961
+ var isCalendarMonthGridAnimating = monthTransition !== null;
962
+ var shouldFocusDate = !isCalendarMonthGridAnimating && isFocused;
963
+ var keyboardShortcutButtonLocation = _DayPickerKeyboardShortcuts.BOTTOM_RIGHT;
964
+ if (this.isVertical()) {
965
+ keyboardShortcutButtonLocation = withPortal ? _DayPickerKeyboardShortcuts.TOP_LEFT : _DayPickerKeyboardShortcuts.TOP_RIGHT;
966
+ }
967
+ var shouldAnimateHeight = isHorizontal && hasSetHeight;
968
+ var calendarInfoPositionTop = calendarInfoPosition === _constants.INFO_POSITION_TOP;
969
+ var calendarInfoPositionBottom = calendarInfoPosition === _constants.INFO_POSITION_BOTTOM;
970
+ var calendarInfoPositionBefore = calendarInfoPosition === _constants.INFO_POSITION_BEFORE;
971
+ var calendarInfoPositionAfter = calendarInfoPosition === _constants.INFO_POSITION_AFTER;
972
+ var calendarInfoIsInline = calendarInfoPositionBefore || calendarInfoPositionAfter;
973
+ var calendarInfo = renderCalendarInfo && /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
974
+ ref: this.setCalendarInfoRef
975
+ }, css(calendarInfoIsInline && styles.DayPicker_calendarInfo__horizontal)), renderCalendarInfo());
976
+ var calendarInfoPanelWidth = renderCalendarInfo && calendarInfoIsInline ? calendarInfoWidth : 0;
977
+ var firstVisibleMonthIndex = this.getFirstVisibleIndex();
978
+ var wrapperHorizontalWidth = calendarMonthWidth * numberOfMonths + 2 * dayPickerHorizontalPadding;
979
+ // Adding `1px` because of whitespace between 2 inline-block
980
+ var fullHorizontalWidth = wrapperHorizontalWidth + calendarInfoPanelWidth + 1;
981
+ var transitionContainerStyle = {
982
+ width: isHorizontal && wrapperHorizontalWidth,
983
+ height: height
984
+ };
985
+ var dayPickerWrapperStyle = {
986
+ width: isHorizontal && wrapperHorizontalWidth
987
+ };
988
+ var dayPickerStyle = {
989
+ width: isHorizontal && fullHorizontalWidth,
990
+ // These values are to center the datepicker (approximately) on the page
991
+ marginLeft: isHorizontal && withPortal ? -fullHorizontalWidth / 2 : null,
992
+ marginTop: isHorizontal && withPortal ? -calendarMonthWidth / 2 : null
993
+ };
994
+ return /*#__PURE__*/_react["default"].createElement("div", css(styles.DayPicker, isHorizontal && styles.DayPicker__horizontal, verticalScrollable && styles.DayPicker__verticalScrollable, isHorizontal && withPortal && styles.DayPicker_portal__horizontal, this.isVertical() && withPortal && styles.DayPicker_portal__vertical, dayPickerStyle, !monthTitleHeight && styles.DayPicker__hidden, !noBorder && styles.DayPicker__withBorder), /*#__PURE__*/_react["default"].createElement(_reactOutsideClickHandler["default"], {
995
+ onOutsideClick: onOutsideClick
996
+ }, (calendarInfoPositionTop || calendarInfoPositionBefore) && calendarInfo, /*#__PURE__*/_react["default"].createElement("div", css(dayPickerWrapperStyle, calendarInfoIsInline && isHorizontal && styles.DayPicker_wrapper__horizontal), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, css(styles.DayPicker_weekHeaders, isHorizontal && styles.DayPicker_weekHeaders__horizontal), {
997
+ "aria-hidden": "true",
998
+ role: "presentation"
999
+ }), weekHeaders), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, css(styles.DayPicker_focusRegion), {
1000
+ ref: this.setContainerRef,
1001
+ onClick: function onClick(e) {
1002
+ e.stopPropagation();
1003
+ },
1004
+ onKeyDown: this.onKeyDown,
1005
+ onMouseUp: function onMouseUp() {
1006
+ _this6.setState({
1007
+ withMouseInteractions: true
1008
+ });
1009
+ },
1010
+ tabIndex: -1,
1011
+ role: "application",
1012
+ "aria-roledescription": phrases.roleDescription,
1013
+ "aria-label": phrases.calendarLabel
1014
+ }), !verticalScrollable && navPosition === _constants.NAV_POSITION_TOP && this.renderNavigation(), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, css(styles.DayPicker_transitionContainer, shouldAnimateHeight && styles.DayPicker_transitionContainer__horizontal, this.isVertical() && styles.DayPicker_transitionContainer__vertical, verticalScrollable && styles.DayPicker_transitionContainer__verticalScrollable, transitionContainerStyle), {
1015
+ ref: this.setTransitionContainerRef
1016
+ }), verticalScrollable && this.renderNavigation(PREV_NAV), /*#__PURE__*/_react["default"].createElement(_CalendarMonthGrid["default"], {
1017
+ setMonthTitleHeight: !monthTitleHeight ? this.setMonthTitleHeight : undefined,
1018
+ translationValue: translationValue,
1019
+ enableOutsideDays: enableOutsideDays,
1020
+ firstVisibleMonthIndex: firstVisibleMonthIndex,
1021
+ initialMonth: currentMonth,
1022
+ isAnimating: isCalendarMonthGridAnimating,
1023
+ modifiers: modifiers,
1024
+ orientation: orientation,
1025
+ numberOfMonths: numberOfMonths * scrollableMonthMultiple,
1026
+ onDayClick: onDayClick,
1027
+ onDayMouseEnter: onDayMouseEnter,
1028
+ onDayMouseLeave: onDayMouseLeave,
1029
+ onMonthChange: this.onMonthChange,
1030
+ onYearChange: this.onYearChange,
1031
+ renderMonthText: renderMonthText,
1032
+ renderCalendarDay: renderCalendarDay,
1033
+ renderDayContents: renderDayContents,
1034
+ renderMonthElement: renderMonthElement,
1035
+ onMonthTransitionEnd: this.updateStateAfterMonthTransition,
1036
+ monthFormat: monthFormat,
1037
+ daySize: daySize,
1038
+ firstDayOfWeek: firstDayOfWeek,
1039
+ isFocused: shouldFocusDate,
1040
+ focusedDate: focusedDate,
1041
+ phrases: phrases,
1042
+ isRTL: isRTL,
1043
+ dayAriaLabelFormat: dayAriaLabelFormat,
1044
+ transitionDuration: transitionDuration,
1045
+ verticalBorderSpacing: verticalBorderSpacing,
1046
+ horizontalMonthPadding: horizontalMonthPadding
1047
+ }), verticalScrollable && this.renderNavigation(NEXT_NAV)), !verticalScrollable && navPosition === _constants.NAV_POSITION_BOTTOM && this.renderNavigation(), !isTouch && !hideKeyboardShortcutsPanel && /*#__PURE__*/_react["default"].createElement(_DayPickerKeyboardShortcuts["default"], {
1048
+ block: this.isVertical() && !withPortal,
1049
+ buttonLocation: keyboardShortcutButtonLocation,
1050
+ showKeyboardShortcutsPanel: showKeyboardShortcuts,
1051
+ openKeyboardShortcutsPanel: this.openKeyboardShortcutsPanel,
1052
+ closeKeyboardShortcutsPanel: this.closeKeyboardShortcutsPanel,
1053
+ phrases: phrases,
1054
+ renderKeyboardShortcutsButton: renderKeyboardShortcutsButton,
1055
+ renderKeyboardShortcutsPanel: renderKeyboardShortcutsPanel
1056
+ }))), (calendarInfoPositionBottom || calendarInfoPositionAfter) && calendarInfo));
1057
+ };
1058
+ return DayPicker;
1059
+ }(_react["default"].PureComponent || _react["default"].Component, !_react["default"].PureComponent && "shouldComponentUpdate");
1060
+ DayPicker.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
1061
+ DayPicker.defaultProps = defaultProps;
1062
+ var _default = exports["default"] = (0, _reactWithStyles.withStyles)(function (_ref5) {
1063
+ var _ref5$reactDates = _ref5.reactDates,
1064
+ color = _ref5$reactDates.color,
1065
+ font = _ref5$reactDates.font,
1066
+ noScrollBarOnVerticalScrollable = _ref5$reactDates.noScrollBarOnVerticalScrollable,
1067
+ spacing = _ref5$reactDates.spacing,
1068
+ zIndex = _ref5$reactDates.zIndex;
1069
+ return {
1070
+ DayPicker: {
1071
+ background: color.background,
1072
+ position: 'relative',
1073
+ textAlign: (0, _noflip["default"])('left')
1074
+ },
1075
+ DayPicker__horizontal: {
1076
+ background: color.background
1077
+ },
1078
+ DayPicker__verticalScrollable: {
1079
+ height: '100%'
1080
+ },
1081
+ DayPicker__hidden: {
1082
+ visibility: 'hidden'
1083
+ },
1084
+ DayPicker__withBorder: {
1085
+ boxShadow: (0, _noflip["default"])('0 2px 6px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.07)'),
1086
+ borderRadius: 3
1087
+ },
1088
+ DayPicker_portal__horizontal: {
1089
+ boxShadow: 'none',
1090
+ position: 'absolute',
1091
+ left: (0, _noflip["default"])('50%'),
1092
+ top: '50%'
1093
+ },
1094
+ DayPicker_portal__vertical: {
1095
+ position: 'initial'
1096
+ },
1097
+ DayPicker_focusRegion: {
1098
+ outline: 'none'
1099
+ },
1100
+ DayPicker_calendarInfo__horizontal: {
1101
+ display: 'inline-block',
1102
+ verticalAlign: 'top'
1103
+ },
1104
+ DayPicker_wrapper__horizontal: {
1105
+ display: 'inline-block',
1106
+ verticalAlign: 'top'
1107
+ },
1108
+ DayPicker_weekHeaders: {
1109
+ position: 'relative'
1110
+ },
1111
+ DayPicker_weekHeaders__horizontal: {
1112
+ marginLeft: (0, _noflip["default"])(spacing.dayPickerHorizontalPadding)
1113
+ },
1114
+ DayPicker_weekHeader: {
1115
+ color: color.placeholderText,
1116
+ position: 'absolute',
1117
+ top: 62,
1118
+ zIndex: zIndex + 2,
1119
+ textAlign: (0, _noflip["default"])('left')
1120
+ },
1121
+ DayPicker_weekHeader__vertical: {
1122
+ left: (0, _noflip["default"])('50%')
1123
+ },
1124
+ DayPicker_weekHeader__verticalScrollable: {
1125
+ top: 0,
1126
+ display: 'table-row',
1127
+ borderBottom: "1px solid ".concat(color.core.border),
1128
+ background: color.background,
1129
+ marginLeft: (0, _noflip["default"])(0),
1130
+ left: (0, _noflip["default"])(0),
1131
+ width: '100%',
1132
+ textAlign: 'center'
1133
+ },
1134
+ DayPicker_weekHeader_ul: {
1135
+ listStyle: 'none',
1136
+ margin: '1px 0',
1137
+ paddingLeft: (0, _noflip["default"])(0),
1138
+ paddingRight: (0, _noflip["default"])(0),
1139
+ fontSize: font.size
1140
+ },
1141
+ DayPicker_weekHeader_li: {
1142
+ display: 'inline-block',
1143
+ textAlign: 'center'
1144
+ },
1145
+ DayPicker_transitionContainer: {
1146
+ position: 'relative',
1147
+ overflow: 'hidden',
1148
+ borderRadius: 3
1149
+ },
1150
+ DayPicker_transitionContainer__horizontal: {
1151
+ transition: 'height 0.2s ease-in-out'
1152
+ },
1153
+ DayPicker_transitionContainer__vertical: {
1154
+ width: '100%'
1155
+ },
1156
+ DayPicker_transitionContainer__verticalScrollable: _objectSpread({
1157
+ paddingTop: 20,
1158
+ height: '100%',
1159
+ position: 'absolute',
1160
+ top: 0,
1161
+ bottom: 0,
1162
+ right: (0, _noflip["default"])(0),
1163
+ left: (0, _noflip["default"])(0),
1164
+ overflowY: 'scroll'
1165
+ }, noScrollBarOnVerticalScrollable && {
1166
+ '-webkitOverflowScrolling': 'touch',
1167
+ '::-webkit-scrollbar': {
1168
+ '-webkit-appearance': 'none',
1169
+ display: 'none'
1170
+ }
1171
+ })
1172
+ };
1173
+ }, {
1174
+ pureComponent: typeof _react["default"].PureComponent !== 'undefined'
1175
+ })(DayPicker);