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