@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,690 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _readOnlyError from "@babel/runtime/helpers/esm/readOnlyError";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
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 momentPropTypes from 'react-moment-proptypes';
|
|
11
|
+
import { forbidExtraProps, mutuallyExclusiveProps, nonNegativeInteger } from 'airbnb-prop-types';
|
|
12
|
+
import moment from 'moment';
|
|
13
|
+
import values from 'object.values';
|
|
14
|
+
import isTouchDevice from 'is-touch-device';
|
|
15
|
+
import { DayPickerPhrases } from '../defaultPhrases';
|
|
16
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
17
|
+
import isSameDay from '../utils/isSameDay';
|
|
18
|
+
import isAfterDay from '../utils/isAfterDay';
|
|
19
|
+
import isDayVisible from '../utils/isDayVisible';
|
|
20
|
+
import getVisibleDays from '../utils/getVisibleDays';
|
|
21
|
+
import toISODateString from '../utils/toISODateString';
|
|
22
|
+
import { addModifier as _addModifier, deleteModifier as _deleteModifier } from '../utils/modifiers';
|
|
23
|
+
import ScrollableOrientationShape from '../shapes/ScrollableOrientationShape';
|
|
24
|
+
import DayOfWeekShape from '../shapes/DayOfWeekShape';
|
|
25
|
+
import CalendarInfoPositionShape from '../shapes/CalendarInfoPositionShape';
|
|
26
|
+
import NavPositionShape from '../shapes/NavPositionShape';
|
|
27
|
+
import { HORIZONTAL_ORIENTATION, VERTICAL_SCROLLABLE, DAY_SIZE, INFO_POSITION_BOTTOM, NAV_POSITION_TOP } from '../constants';
|
|
28
|
+
import DayPicker from './DayPicker';
|
|
29
|
+
import getPooledMoment from '../utils/getPooledMoment';
|
|
30
|
+
|
|
31
|
+
// Default value of the date property. Represents the state
|
|
32
|
+
// when there is no date selected.
|
|
33
|
+
// TODO: use null
|
|
34
|
+
var DATE_UNSET_VALUE = undefined;
|
|
35
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps({
|
|
36
|
+
date: momentPropTypes.momentObj,
|
|
37
|
+
minDate: momentPropTypes.momentObj,
|
|
38
|
+
maxDate: momentPropTypes.momentObj,
|
|
39
|
+
onDateChange: PropTypes.func,
|
|
40
|
+
allowUnselect: PropTypes.bool,
|
|
41
|
+
focused: PropTypes.bool,
|
|
42
|
+
onFocusChange: PropTypes.func,
|
|
43
|
+
onClose: PropTypes.func,
|
|
44
|
+
keepOpenOnDateSelect: PropTypes.bool,
|
|
45
|
+
isOutsideRange: PropTypes.func,
|
|
46
|
+
isDayBlocked: PropTypes.func,
|
|
47
|
+
isDayHighlighted: PropTypes.func,
|
|
48
|
+
// DayPicker props
|
|
49
|
+
renderMonthText: mutuallyExclusiveProps(PropTypes.func, 'renderMonthText', 'renderMonthElement'),
|
|
50
|
+
renderMonthElement: mutuallyExclusiveProps(PropTypes.func, 'renderMonthText', 'renderMonthElement'),
|
|
51
|
+
renderWeekHeaderElement: PropTypes.func,
|
|
52
|
+
enableOutsideDays: PropTypes.bool,
|
|
53
|
+
numberOfMonths: PropTypes.number,
|
|
54
|
+
orientation: ScrollableOrientationShape,
|
|
55
|
+
withPortal: PropTypes.bool,
|
|
56
|
+
initialVisibleMonth: PropTypes.func,
|
|
57
|
+
firstDayOfWeek: DayOfWeekShape,
|
|
58
|
+
hideKeyboardShortcutsPanel: PropTypes.bool,
|
|
59
|
+
daySize: nonNegativeInteger,
|
|
60
|
+
verticalHeight: nonNegativeInteger,
|
|
61
|
+
noBorder: PropTypes.bool,
|
|
62
|
+
verticalBorderSpacing: nonNegativeInteger,
|
|
63
|
+
transitionDuration: nonNegativeInteger,
|
|
64
|
+
horizontalMonthPadding: nonNegativeInteger,
|
|
65
|
+
dayPickerNavigationInlineStyles: PropTypes.object,
|
|
66
|
+
navPosition: NavPositionShape,
|
|
67
|
+
navPrev: PropTypes.node,
|
|
68
|
+
navNext: PropTypes.node,
|
|
69
|
+
renderNavPrevButton: PropTypes.func,
|
|
70
|
+
renderNavNextButton: PropTypes.func,
|
|
71
|
+
noNavButtons: PropTypes.bool,
|
|
72
|
+
noNavNextButton: PropTypes.bool,
|
|
73
|
+
noNavPrevButton: PropTypes.bool,
|
|
74
|
+
onPrevMonthClick: PropTypes.func,
|
|
75
|
+
onNextMonthClick: PropTypes.func,
|
|
76
|
+
onOutsideClick: PropTypes.func,
|
|
77
|
+
renderCalendarDay: PropTypes.func,
|
|
78
|
+
renderDayContents: PropTypes.func,
|
|
79
|
+
renderCalendarInfo: PropTypes.func,
|
|
80
|
+
calendarInfoPosition: CalendarInfoPositionShape,
|
|
81
|
+
// accessibility
|
|
82
|
+
onBlur: PropTypes.func,
|
|
83
|
+
isFocused: PropTypes.bool,
|
|
84
|
+
showKeyboardShortcuts: PropTypes.bool,
|
|
85
|
+
onTab: PropTypes.func,
|
|
86
|
+
onShiftTab: PropTypes.func,
|
|
87
|
+
// i18n
|
|
88
|
+
monthFormat: PropTypes.string,
|
|
89
|
+
weekDayFormat: PropTypes.string,
|
|
90
|
+
phrases: PropTypes.shape(getPhrasePropTypes(DayPickerPhrases)),
|
|
91
|
+
dayAriaLabelFormat: PropTypes.string,
|
|
92
|
+
isRTL: PropTypes.bool
|
|
93
|
+
}) : {};
|
|
94
|
+
var defaultProps = {
|
|
95
|
+
date: DATE_UNSET_VALUE,
|
|
96
|
+
minDate: null,
|
|
97
|
+
maxDate: null,
|
|
98
|
+
onDateChange: function onDateChange() {},
|
|
99
|
+
allowUnselect: false,
|
|
100
|
+
focused: false,
|
|
101
|
+
onFocusChange: function onFocusChange() {},
|
|
102
|
+
onClose: function onClose() {},
|
|
103
|
+
keepOpenOnDateSelect: false,
|
|
104
|
+
isOutsideRange: function isOutsideRange() {},
|
|
105
|
+
isDayBlocked: function isDayBlocked() {},
|
|
106
|
+
isDayHighlighted: function isDayHighlighted() {},
|
|
107
|
+
// DayPicker props
|
|
108
|
+
renderMonthText: null,
|
|
109
|
+
renderWeekHeaderElement: null,
|
|
110
|
+
enableOutsideDays: false,
|
|
111
|
+
numberOfMonths: 1,
|
|
112
|
+
orientation: HORIZONTAL_ORIENTATION,
|
|
113
|
+
withPortal: false,
|
|
114
|
+
hideKeyboardShortcutsPanel: false,
|
|
115
|
+
initialVisibleMonth: null,
|
|
116
|
+
firstDayOfWeek: null,
|
|
117
|
+
daySize: DAY_SIZE,
|
|
118
|
+
verticalHeight: null,
|
|
119
|
+
noBorder: false,
|
|
120
|
+
verticalBorderSpacing: undefined,
|
|
121
|
+
transitionDuration: undefined,
|
|
122
|
+
horizontalMonthPadding: 13,
|
|
123
|
+
dayPickerNavigationInlineStyles: null,
|
|
124
|
+
navPosition: NAV_POSITION_TOP,
|
|
125
|
+
navPrev: null,
|
|
126
|
+
navNext: null,
|
|
127
|
+
renderNavPrevButton: null,
|
|
128
|
+
renderNavNextButton: null,
|
|
129
|
+
noNavButtons: false,
|
|
130
|
+
noNavNextButton: false,
|
|
131
|
+
noNavPrevButton: false,
|
|
132
|
+
onPrevMonthClick: function onPrevMonthClick() {},
|
|
133
|
+
onNextMonthClick: function onNextMonthClick() {},
|
|
134
|
+
onOutsideClick: function onOutsideClick() {},
|
|
135
|
+
renderCalendarDay: undefined,
|
|
136
|
+
renderDayContents: null,
|
|
137
|
+
renderCalendarInfo: null,
|
|
138
|
+
renderMonthElement: null,
|
|
139
|
+
calendarInfoPosition: INFO_POSITION_BOTTOM,
|
|
140
|
+
// accessibility
|
|
141
|
+
onBlur: function onBlur() {},
|
|
142
|
+
isFocused: false,
|
|
143
|
+
showKeyboardShortcuts: false,
|
|
144
|
+
onTab: function onTab() {},
|
|
145
|
+
onShiftTab: function onShiftTab() {},
|
|
146
|
+
// i18n
|
|
147
|
+
monthFormat: 'MMMM YYYY',
|
|
148
|
+
weekDayFormat: 'dd',
|
|
149
|
+
phrases: DayPickerPhrases,
|
|
150
|
+
dayAriaLabelFormat: undefined,
|
|
151
|
+
isRTL: false
|
|
152
|
+
};
|
|
153
|
+
var DayPickerSingleDateController = /*#__PURE__*/function (_ref2, _ref) {
|
|
154
|
+
function DayPickerSingleDateController(props) {
|
|
155
|
+
var _this;
|
|
156
|
+
_this = _ref2.call(this, props) || this;
|
|
157
|
+
_this.isTouchDevice = false;
|
|
158
|
+
_this.today = moment();
|
|
159
|
+
_this.modifiers = {
|
|
160
|
+
today: function today(day) {
|
|
161
|
+
return _this.isToday(day);
|
|
162
|
+
},
|
|
163
|
+
blocked: function blocked(day) {
|
|
164
|
+
return _this.isBlocked(day);
|
|
165
|
+
},
|
|
166
|
+
'blocked-calendar': function blockedCalendar(day) {
|
|
167
|
+
return props.isDayBlocked(day);
|
|
168
|
+
},
|
|
169
|
+
'blocked-out-of-range': function blockedOutOfRange(day) {
|
|
170
|
+
return props.isOutsideRange(day);
|
|
171
|
+
},
|
|
172
|
+
'highlighted-calendar': function highlightedCalendar(day) {
|
|
173
|
+
return props.isDayHighlighted(day);
|
|
174
|
+
},
|
|
175
|
+
valid: function valid(day) {
|
|
176
|
+
return !_this.isBlocked(day);
|
|
177
|
+
},
|
|
178
|
+
hovered: function hovered(day) {
|
|
179
|
+
return _this.isHovered(day);
|
|
180
|
+
},
|
|
181
|
+
selected: function selected(day) {
|
|
182
|
+
return _this.isSelected(day);
|
|
183
|
+
},
|
|
184
|
+
'first-day-of-week': function firstDayOfWeek(day) {
|
|
185
|
+
return _this.isFirstDayOfWeek(day);
|
|
186
|
+
},
|
|
187
|
+
'last-day-of-week': function lastDayOfWeek(day) {
|
|
188
|
+
return _this.isLastDayOfWeek(day);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var _this$getStateForNewM = _this.getStateForNewMonth(props),
|
|
192
|
+
currentMonth = _this$getStateForNewM.currentMonth,
|
|
193
|
+
visibleDays = _this$getStateForNewM.visibleDays;
|
|
194
|
+
_this.state = {
|
|
195
|
+
hoverDate: null,
|
|
196
|
+
currentMonth: currentMonth,
|
|
197
|
+
visibleDays: visibleDays,
|
|
198
|
+
disablePrev: _this.shouldDisableMonthNavigation(props.minDate, currentMonth),
|
|
199
|
+
disableNext: _this.shouldDisableMonthNavigation(props.maxDate, currentMonth)
|
|
200
|
+
};
|
|
201
|
+
_this.onDayMouseEnter = _this.onDayMouseEnter.bind(_this);
|
|
202
|
+
_this.onDayMouseLeave = _this.onDayMouseLeave.bind(_this);
|
|
203
|
+
_this.onDayClick = _this.onDayClick.bind(_this);
|
|
204
|
+
_this.onPrevMonthClick = _this.onPrevMonthClick.bind(_this);
|
|
205
|
+
_this.onNextMonthClick = _this.onNextMonthClick.bind(_this);
|
|
206
|
+
_this.onMonthChange = _this.onMonthChange.bind(_this);
|
|
207
|
+
_this.onYearChange = _this.onYearChange.bind(_this);
|
|
208
|
+
_this.onGetNextScrollableMonths = _this.onGetNextScrollableMonths.bind(_this);
|
|
209
|
+
_this.onGetPrevScrollableMonths = _this.onGetPrevScrollableMonths.bind(_this);
|
|
210
|
+
_this.getFirstFocusableDay = _this.getFirstFocusableDay.bind(_this);
|
|
211
|
+
return _this;
|
|
212
|
+
}
|
|
213
|
+
_inheritsLoose(DayPickerSingleDateController, _ref2);
|
|
214
|
+
var _proto = DayPickerSingleDateController.prototype;
|
|
215
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
216
|
+
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
217
|
+
};
|
|
218
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
219
|
+
this.isTouchDevice = isTouchDevice();
|
|
220
|
+
};
|
|
221
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
222
|
+
var _this2 = this;
|
|
223
|
+
var _this$props = this.props,
|
|
224
|
+
date = _this$props.date,
|
|
225
|
+
focused = _this$props.focused,
|
|
226
|
+
isOutsideRange = _this$props.isOutsideRange,
|
|
227
|
+
isDayBlocked = _this$props.isDayBlocked,
|
|
228
|
+
isDayHighlighted = _this$props.isDayHighlighted,
|
|
229
|
+
initialVisibleMonth = _this$props.initialVisibleMonth,
|
|
230
|
+
numberOfMonths = _this$props.numberOfMonths,
|
|
231
|
+
enableOutsideDays = _this$props.enableOutsideDays;
|
|
232
|
+
var prevIsOutsideRange = prevProps.isOutsideRange,
|
|
233
|
+
prevIsDayBlocked = prevProps.isDayBlocked,
|
|
234
|
+
prevIsDayHighlighted = prevProps.isDayHighlighted,
|
|
235
|
+
prevNumberOfMonths = prevProps.numberOfMonths,
|
|
236
|
+
prevEnableOutsideDays = prevProps.enableOutsideDays,
|
|
237
|
+
prevInitialVisibleMonth = prevProps.initialVisibleMonth,
|
|
238
|
+
prevFocused = prevProps.focused,
|
|
239
|
+
prevDate = prevProps.date;
|
|
240
|
+
var visibleDays = this.state.visibleDays;
|
|
241
|
+
var recomputeOutsideRange = false;
|
|
242
|
+
var recomputeDayBlocked = false;
|
|
243
|
+
var recomputeDayHighlighted = false;
|
|
244
|
+
if (isOutsideRange !== prevIsOutsideRange) {
|
|
245
|
+
this.modifiers['blocked-out-of-range'] = function (day) {
|
|
246
|
+
return isOutsideRange(day);
|
|
247
|
+
};
|
|
248
|
+
recomputeOutsideRange = true;
|
|
249
|
+
}
|
|
250
|
+
if (isDayBlocked !== prevIsDayBlocked) {
|
|
251
|
+
this.modifiers['blocked-calendar'] = function (day) {
|
|
252
|
+
return isDayBlocked(day);
|
|
253
|
+
};
|
|
254
|
+
recomputeDayBlocked = true;
|
|
255
|
+
}
|
|
256
|
+
if (isDayHighlighted !== prevIsDayHighlighted) {
|
|
257
|
+
this.modifiers['highlighted-calendar'] = function (day) {
|
|
258
|
+
return isDayHighlighted(day);
|
|
259
|
+
};
|
|
260
|
+
recomputeDayHighlighted = true;
|
|
261
|
+
}
|
|
262
|
+
var recomputePropModifiers = recomputeOutsideRange || recomputeDayBlocked || recomputeDayHighlighted;
|
|
263
|
+
var prevCurrentMonth = this.state.currentMonth;
|
|
264
|
+
if (numberOfMonths !== prevNumberOfMonths || enableOutsideDays !== prevEnableOutsideDays || initialVisibleMonth !== prevInitialVisibleMonth && !prevFocused && focused || prevDate && prevDate.diff(date) && !isDayVisible(date, prevCurrentMonth, numberOfMonths)) {
|
|
265
|
+
var newMonthState = this.getStateForNewMonth(this.props);
|
|
266
|
+
var currentMonth = newMonthState.currentMonth;
|
|
267
|
+
visibleDays = newMonthState.visibleDays;
|
|
268
|
+
this.setState({
|
|
269
|
+
currentMonth: currentMonth,
|
|
270
|
+
visibleDays: visibleDays
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
var didDateChange = date !== prevDate;
|
|
274
|
+
var didFocusChange = focused !== prevFocused;
|
|
275
|
+
var modifiers = {};
|
|
276
|
+
if (didDateChange) {
|
|
277
|
+
modifiers = this.deleteModifier(modifiers, prevDate, 'selected');
|
|
278
|
+
modifiers = this.addModifier(modifiers, date, 'selected');
|
|
279
|
+
}
|
|
280
|
+
if (didFocusChange || recomputePropModifiers) {
|
|
281
|
+
values(visibleDays).forEach(function (days) {
|
|
282
|
+
Object.keys(days).forEach(function (day) {
|
|
283
|
+
var momentObj = getPooledMoment(day);
|
|
284
|
+
if (_this2.isBlocked(momentObj)) {
|
|
285
|
+
modifiers = _this2.addModifier(modifiers, momentObj, 'blocked');
|
|
286
|
+
} else {
|
|
287
|
+
modifiers = _this2.deleteModifier(modifiers, momentObj, 'blocked');
|
|
288
|
+
}
|
|
289
|
+
if (didFocusChange || recomputeOutsideRange) {
|
|
290
|
+
if (isOutsideRange(momentObj)) {
|
|
291
|
+
modifiers = _this2.addModifier(modifiers, momentObj, 'blocked-out-of-range');
|
|
292
|
+
} else {
|
|
293
|
+
modifiers = _this2.deleteModifier(modifiers, momentObj, 'blocked-out-of-range');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (didFocusChange || recomputeDayBlocked) {
|
|
297
|
+
if (isDayBlocked(momentObj)) {
|
|
298
|
+
modifiers = _this2.addModifier(modifiers, momentObj, 'blocked-calendar');
|
|
299
|
+
} else {
|
|
300
|
+
modifiers = _this2.deleteModifier(modifiers, momentObj, 'blocked-calendar');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (didFocusChange || recomputeDayHighlighted) {
|
|
304
|
+
if (isDayHighlighted(momentObj)) {
|
|
305
|
+
modifiers = _this2.addModifier(modifiers, momentObj, 'highlighted-calendar');
|
|
306
|
+
} else {
|
|
307
|
+
modifiers = _this2.deleteModifier(modifiers, momentObj, 'highlighted-calendar');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
var today = moment();
|
|
314
|
+
if (!isSameDay(this.today, today)) {
|
|
315
|
+
modifiers = this.deleteModifier(modifiers, this.today, 'today');
|
|
316
|
+
modifiers = this.addModifier(modifiers, today, 'today');
|
|
317
|
+
this.today = today;
|
|
318
|
+
}
|
|
319
|
+
if (Object.keys(modifiers).length > 0) {
|
|
320
|
+
this.setState({
|
|
321
|
+
visibleDays: _objectSpread(_objectSpread({}, visibleDays), modifiers)
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
_proto.onDayClick = function onDayClick(day, e) {
|
|
326
|
+
if (e) e.preventDefault();
|
|
327
|
+
if (this.isBlocked(day)) return;
|
|
328
|
+
var _this$props2 = this.props,
|
|
329
|
+
allowUnselect = _this$props2.allowUnselect,
|
|
330
|
+
onDateChange = _this$props2.onDateChange,
|
|
331
|
+
keepOpenOnDateSelect = _this$props2.keepOpenOnDateSelect,
|
|
332
|
+
onFocusChange = _this$props2.onFocusChange,
|
|
333
|
+
onClose = _this$props2.onClose;
|
|
334
|
+
var clickedDay = allowUnselect && this.isSelected(day) ? DATE_UNSET_VALUE : day;
|
|
335
|
+
onDateChange(clickedDay);
|
|
336
|
+
if (!keepOpenOnDateSelect) {
|
|
337
|
+
onFocusChange({
|
|
338
|
+
focused: false
|
|
339
|
+
});
|
|
340
|
+
onClose({
|
|
341
|
+
date: clickedDay
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
_proto.onDayMouseEnter = function onDayMouseEnter(day) {
|
|
346
|
+
if (this.isTouchDevice) return;
|
|
347
|
+
var _this$state = this.state,
|
|
348
|
+
hoverDate = _this$state.hoverDate,
|
|
349
|
+
visibleDays = _this$state.visibleDays;
|
|
350
|
+
var modifiers = this.deleteModifier({}, hoverDate, 'hovered');
|
|
351
|
+
modifiers = this.addModifier(modifiers, day, 'hovered');
|
|
352
|
+
this.setState({
|
|
353
|
+
hoverDate: day,
|
|
354
|
+
visibleDays: _objectSpread(_objectSpread({}, visibleDays), modifiers)
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
_proto.onDayMouseLeave = function onDayMouseLeave() {
|
|
358
|
+
var _this$state2 = this.state,
|
|
359
|
+
hoverDate = _this$state2.hoverDate,
|
|
360
|
+
visibleDays = _this$state2.visibleDays;
|
|
361
|
+
if (this.isTouchDevice || !hoverDate) return;
|
|
362
|
+
var modifiers = this.deleteModifier({}, hoverDate, 'hovered');
|
|
363
|
+
this.setState({
|
|
364
|
+
hoverDate: null,
|
|
365
|
+
visibleDays: _objectSpread(_objectSpread({}, visibleDays), modifiers)
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
_proto.onPrevMonthClick = function onPrevMonthClick() {
|
|
369
|
+
var _this$props3 = this.props,
|
|
370
|
+
enableOutsideDays = _this$props3.enableOutsideDays,
|
|
371
|
+
maxDate = _this$props3.maxDate,
|
|
372
|
+
minDate = _this$props3.minDate,
|
|
373
|
+
numberOfMonths = _this$props3.numberOfMonths,
|
|
374
|
+
onPrevMonthClick = _this$props3.onPrevMonthClick;
|
|
375
|
+
var _this$state3 = this.state,
|
|
376
|
+
currentMonth = _this$state3.currentMonth,
|
|
377
|
+
visibleDays = _this$state3.visibleDays;
|
|
378
|
+
var newVisibleDays = {};
|
|
379
|
+
Object.keys(visibleDays).sort().slice(0, numberOfMonths + 1).forEach(function (month) {
|
|
380
|
+
newVisibleDays[month] = visibleDays[month];
|
|
381
|
+
});
|
|
382
|
+
var prevMonth = currentMonth.clone().subtract(1, 'month');
|
|
383
|
+
var prevMonthVisibleDays = getVisibleDays(prevMonth, 1, enableOutsideDays);
|
|
384
|
+
var newCurrentMonth = currentMonth.clone().subtract(1, 'month');
|
|
385
|
+
this.setState({
|
|
386
|
+
currentMonth: prevMonth,
|
|
387
|
+
disablePrev: this.shouldDisableMonthNavigation(minDate, newCurrentMonth),
|
|
388
|
+
disableNext: this.shouldDisableMonthNavigation(maxDate, newCurrentMonth),
|
|
389
|
+
visibleDays: _objectSpread(_objectSpread({}, newVisibleDays), this.getModifiers(prevMonthVisibleDays))
|
|
390
|
+
}, function () {
|
|
391
|
+
onPrevMonthClick(prevMonth.clone());
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
_proto.onNextMonthClick = function onNextMonthClick() {
|
|
395
|
+
var _this$props4 = this.props,
|
|
396
|
+
enableOutsideDays = _this$props4.enableOutsideDays,
|
|
397
|
+
maxDate = _this$props4.maxDate,
|
|
398
|
+
minDate = _this$props4.minDate,
|
|
399
|
+
numberOfMonths = _this$props4.numberOfMonths,
|
|
400
|
+
onNextMonthClick = _this$props4.onNextMonthClick;
|
|
401
|
+
var _this$state4 = this.state,
|
|
402
|
+
currentMonth = _this$state4.currentMonth,
|
|
403
|
+
visibleDays = _this$state4.visibleDays;
|
|
404
|
+
var newVisibleDays = {};
|
|
405
|
+
Object.keys(visibleDays).sort().slice(1).forEach(function (month) {
|
|
406
|
+
newVisibleDays[month] = visibleDays[month];
|
|
407
|
+
});
|
|
408
|
+
var nextMonth = currentMonth.clone().add(numberOfMonths, 'month');
|
|
409
|
+
var nextMonthVisibleDays = getVisibleDays(nextMonth, 1, enableOutsideDays);
|
|
410
|
+
var newCurrentMonth = currentMonth.clone().add(1, 'month');
|
|
411
|
+
this.setState({
|
|
412
|
+
currentMonth: newCurrentMonth,
|
|
413
|
+
disablePrev: this.shouldDisableMonthNavigation(minDate, newCurrentMonth),
|
|
414
|
+
disableNext: this.shouldDisableMonthNavigation(maxDate, newCurrentMonth),
|
|
415
|
+
visibleDays: _objectSpread(_objectSpread({}, newVisibleDays), this.getModifiers(nextMonthVisibleDays))
|
|
416
|
+
}, function () {
|
|
417
|
+
onNextMonthClick(newCurrentMonth.clone());
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
_proto.onMonthChange = function onMonthChange(newMonth) {
|
|
421
|
+
var _this$props5 = this.props,
|
|
422
|
+
numberOfMonths = _this$props5.numberOfMonths,
|
|
423
|
+
enableOutsideDays = _this$props5.enableOutsideDays,
|
|
424
|
+
orientation = _this$props5.orientation;
|
|
425
|
+
var withoutTransitionMonths = orientation === VERTICAL_SCROLLABLE;
|
|
426
|
+
var newVisibleDays = getVisibleDays(newMonth, numberOfMonths, enableOutsideDays, withoutTransitionMonths);
|
|
427
|
+
this.setState({
|
|
428
|
+
currentMonth: newMonth.clone(),
|
|
429
|
+
visibleDays: this.getModifiers(newVisibleDays)
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
_proto.onYearChange = function onYearChange(newMonth) {
|
|
433
|
+
var _this$props6 = this.props,
|
|
434
|
+
numberOfMonths = _this$props6.numberOfMonths,
|
|
435
|
+
enableOutsideDays = _this$props6.enableOutsideDays,
|
|
436
|
+
orientation = _this$props6.orientation;
|
|
437
|
+
var withoutTransitionMonths = orientation === VERTICAL_SCROLLABLE;
|
|
438
|
+
var newVisibleDays = getVisibleDays(newMonth, numberOfMonths, enableOutsideDays, withoutTransitionMonths);
|
|
439
|
+
this.setState({
|
|
440
|
+
currentMonth: newMonth.clone(),
|
|
441
|
+
visibleDays: this.getModifiers(newVisibleDays)
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
_proto.onGetNextScrollableMonths = function onGetNextScrollableMonths() {
|
|
445
|
+
var _this$props7 = this.props,
|
|
446
|
+
numberOfMonths = _this$props7.numberOfMonths,
|
|
447
|
+
enableOutsideDays = _this$props7.enableOutsideDays;
|
|
448
|
+
var _this$state5 = this.state,
|
|
449
|
+
currentMonth = _this$state5.currentMonth,
|
|
450
|
+
visibleDays = _this$state5.visibleDays;
|
|
451
|
+
var numberOfVisibleMonths = Object.keys(visibleDays).length;
|
|
452
|
+
var nextMonth = currentMonth.clone().add(numberOfVisibleMonths, 'month');
|
|
453
|
+
var newVisibleDays = getVisibleDays(nextMonth, numberOfMonths, enableOutsideDays, true);
|
|
454
|
+
this.setState({
|
|
455
|
+
visibleDays: _objectSpread(_objectSpread({}, visibleDays), this.getModifiers(newVisibleDays))
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
_proto.onGetPrevScrollableMonths = function onGetPrevScrollableMonths() {
|
|
459
|
+
var _this$props8 = this.props,
|
|
460
|
+
numberOfMonths = _this$props8.numberOfMonths,
|
|
461
|
+
enableOutsideDays = _this$props8.enableOutsideDays;
|
|
462
|
+
var _this$state6 = this.state,
|
|
463
|
+
currentMonth = _this$state6.currentMonth,
|
|
464
|
+
visibleDays = _this$state6.visibleDays;
|
|
465
|
+
var firstPreviousMonth = currentMonth.clone().subtract(numberOfMonths, 'month');
|
|
466
|
+
var newVisibleDays = getVisibleDays(firstPreviousMonth, numberOfMonths, enableOutsideDays, true);
|
|
467
|
+
this.setState({
|
|
468
|
+
currentMonth: firstPreviousMonth.clone(),
|
|
469
|
+
visibleDays: _objectSpread(_objectSpread({}, visibleDays), this.getModifiers(newVisibleDays))
|
|
470
|
+
});
|
|
471
|
+
};
|
|
472
|
+
_proto.getFirstDayOfWeek = function getFirstDayOfWeek() {
|
|
473
|
+
var firstDayOfWeek = this.props.firstDayOfWeek;
|
|
474
|
+
if (firstDayOfWeek == null) {
|
|
475
|
+
return moment.localeData().firstDayOfWeek();
|
|
476
|
+
}
|
|
477
|
+
return firstDayOfWeek;
|
|
478
|
+
};
|
|
479
|
+
_proto.getFirstFocusableDay = function getFirstFocusableDay(newMonth) {
|
|
480
|
+
var _this3 = this;
|
|
481
|
+
var _this$props9 = this.props,
|
|
482
|
+
date = _this$props9.date,
|
|
483
|
+
numberOfMonths = _this$props9.numberOfMonths;
|
|
484
|
+
var focusedDate = newMonth.clone().startOf('month').hour(12);
|
|
485
|
+
if (date) {
|
|
486
|
+
focusedDate = date.clone();
|
|
487
|
+
}
|
|
488
|
+
if (this.isBlocked(focusedDate)) {
|
|
489
|
+
var days = [];
|
|
490
|
+
var lastVisibleDay = newMonth.clone().add(numberOfMonths - 1, 'months').endOf('month');
|
|
491
|
+
var currentDay = focusedDate.clone();
|
|
492
|
+
while (!isAfterDay(currentDay, lastVisibleDay)) {
|
|
493
|
+
currentDay = currentDay.clone().add(1, 'day');
|
|
494
|
+
days.push(currentDay);
|
|
495
|
+
}
|
|
496
|
+
var viableDays = days.filter(function (day) {
|
|
497
|
+
return !_this3.isBlocked(day) && isAfterDay(day, focusedDate);
|
|
498
|
+
});
|
|
499
|
+
if (viableDays.length > 0) {
|
|
500
|
+
var _viableDays = _slicedToArray(viableDays, 1);
|
|
501
|
+
focusedDate = _viableDays[0];
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return focusedDate;
|
|
505
|
+
};
|
|
506
|
+
_proto.getModifiers = function getModifiers(visibleDays) {
|
|
507
|
+
var _this4 = this;
|
|
508
|
+
var modifiers = {};
|
|
509
|
+
Object.keys(visibleDays).forEach(function (month) {
|
|
510
|
+
modifiers[month] = {};
|
|
511
|
+
visibleDays[month].forEach(function (day) {
|
|
512
|
+
modifiers[month][toISODateString(day)] = _this4.getModifiersForDay(day);
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
return modifiers;
|
|
516
|
+
};
|
|
517
|
+
_proto.getModifiersForDay = function getModifiersForDay(day) {
|
|
518
|
+
var _this5 = this;
|
|
519
|
+
return new Set(Object.keys(this.modifiers).filter(function (modifier) {
|
|
520
|
+
return _this5.modifiers[modifier](day);
|
|
521
|
+
}));
|
|
522
|
+
};
|
|
523
|
+
_proto.getStateForNewMonth = function getStateForNewMonth(nextProps) {
|
|
524
|
+
var _this6 = this;
|
|
525
|
+
var initialVisibleMonth = nextProps.initialVisibleMonth,
|
|
526
|
+
date = nextProps.date,
|
|
527
|
+
numberOfMonths = nextProps.numberOfMonths,
|
|
528
|
+
orientation = nextProps.orientation,
|
|
529
|
+
enableOutsideDays = nextProps.enableOutsideDays;
|
|
530
|
+
var initialVisibleMonthThunk = initialVisibleMonth || (date ? function () {
|
|
531
|
+
return date;
|
|
532
|
+
} : function () {
|
|
533
|
+
return _this6.today;
|
|
534
|
+
});
|
|
535
|
+
var currentMonth = initialVisibleMonthThunk();
|
|
536
|
+
var withoutTransitionMonths = orientation === VERTICAL_SCROLLABLE;
|
|
537
|
+
var visibleDays = this.getModifiers(getVisibleDays(currentMonth, numberOfMonths, enableOutsideDays, withoutTransitionMonths));
|
|
538
|
+
return {
|
|
539
|
+
currentMonth: currentMonth,
|
|
540
|
+
visibleDays: visibleDays
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
_proto.shouldDisableMonthNavigation = function shouldDisableMonthNavigation(date, visibleMonth) {
|
|
544
|
+
if (!date) return false;
|
|
545
|
+
var _this$props0 = this.props,
|
|
546
|
+
numberOfMonths = _this$props0.numberOfMonths,
|
|
547
|
+
enableOutsideDays = _this$props0.enableOutsideDays;
|
|
548
|
+
return isDayVisible(date, visibleMonth, numberOfMonths, enableOutsideDays);
|
|
549
|
+
};
|
|
550
|
+
_proto.addModifier = function addModifier(updatedDays, day, modifier) {
|
|
551
|
+
return _addModifier(updatedDays, day, modifier, this.props, this.state);
|
|
552
|
+
};
|
|
553
|
+
_proto.deleteModifier = function deleteModifier(updatedDays, day, modifier) {
|
|
554
|
+
return _deleteModifier(updatedDays, day, modifier, this.props, this.state);
|
|
555
|
+
};
|
|
556
|
+
_proto.isBlocked = function isBlocked(day) {
|
|
557
|
+
var _this$props1 = this.props,
|
|
558
|
+
isDayBlocked = _this$props1.isDayBlocked,
|
|
559
|
+
isOutsideRange = _this$props1.isOutsideRange;
|
|
560
|
+
return isDayBlocked(day) || isOutsideRange(day);
|
|
561
|
+
};
|
|
562
|
+
_proto.isHovered = function isHovered(day) {
|
|
563
|
+
var _ref3 = this.state || {},
|
|
564
|
+
hoverDate = _ref3.hoverDate;
|
|
565
|
+
return isSameDay(day, hoverDate);
|
|
566
|
+
};
|
|
567
|
+
_proto.isSelected = function isSelected(day) {
|
|
568
|
+
var date = this.props.date;
|
|
569
|
+
return isSameDay(day, date);
|
|
570
|
+
};
|
|
571
|
+
_proto.isToday = function isToday(day) {
|
|
572
|
+
return isSameDay(day, this.today);
|
|
573
|
+
};
|
|
574
|
+
_proto.isFirstDayOfWeek = function isFirstDayOfWeek(day) {
|
|
575
|
+
return day.day() === this.getFirstDayOfWeek();
|
|
576
|
+
};
|
|
577
|
+
_proto.isLastDayOfWeek = function isLastDayOfWeek(day) {
|
|
578
|
+
return day.day() === (this.getFirstDayOfWeek() + 6) % 7;
|
|
579
|
+
};
|
|
580
|
+
_proto.render = function render() {
|
|
581
|
+
var _this$props10 = this.props,
|
|
582
|
+
numberOfMonths = _this$props10.numberOfMonths,
|
|
583
|
+
orientation = _this$props10.orientation,
|
|
584
|
+
monthFormat = _this$props10.monthFormat,
|
|
585
|
+
renderMonthText = _this$props10.renderMonthText,
|
|
586
|
+
renderWeekHeaderElement = _this$props10.renderWeekHeaderElement,
|
|
587
|
+
dayPickerNavigationInlineStyles = _this$props10.dayPickerNavigationInlineStyles,
|
|
588
|
+
navPosition = _this$props10.navPosition,
|
|
589
|
+
navPrev = _this$props10.navPrev,
|
|
590
|
+
navNext = _this$props10.navNext,
|
|
591
|
+
renderNavPrevButton = _this$props10.renderNavPrevButton,
|
|
592
|
+
renderNavNextButton = _this$props10.renderNavNextButton,
|
|
593
|
+
noNavButtons = _this$props10.noNavButtons,
|
|
594
|
+
noNavPrevButton = _this$props10.noNavPrevButton,
|
|
595
|
+
noNavNextButton = _this$props10.noNavNextButton,
|
|
596
|
+
onOutsideClick = _this$props10.onOutsideClick,
|
|
597
|
+
onShiftTab = _this$props10.onShiftTab,
|
|
598
|
+
onTab = _this$props10.onTab,
|
|
599
|
+
withPortal = _this$props10.withPortal,
|
|
600
|
+
focused = _this$props10.focused,
|
|
601
|
+
enableOutsideDays = _this$props10.enableOutsideDays,
|
|
602
|
+
hideKeyboardShortcutsPanel = _this$props10.hideKeyboardShortcutsPanel,
|
|
603
|
+
daySize = _this$props10.daySize,
|
|
604
|
+
firstDayOfWeek = _this$props10.firstDayOfWeek,
|
|
605
|
+
renderCalendarDay = _this$props10.renderCalendarDay,
|
|
606
|
+
renderDayContents = _this$props10.renderDayContents,
|
|
607
|
+
renderCalendarInfo = _this$props10.renderCalendarInfo,
|
|
608
|
+
renderMonthElement = _this$props10.renderMonthElement,
|
|
609
|
+
calendarInfoPosition = _this$props10.calendarInfoPosition,
|
|
610
|
+
isFocused = _this$props10.isFocused,
|
|
611
|
+
isRTL = _this$props10.isRTL,
|
|
612
|
+
phrases = _this$props10.phrases,
|
|
613
|
+
dayAriaLabelFormat = _this$props10.dayAriaLabelFormat,
|
|
614
|
+
onBlur = _this$props10.onBlur,
|
|
615
|
+
showKeyboardShortcuts = _this$props10.showKeyboardShortcuts,
|
|
616
|
+
weekDayFormat = _this$props10.weekDayFormat,
|
|
617
|
+
verticalHeight = _this$props10.verticalHeight,
|
|
618
|
+
noBorder = _this$props10.noBorder,
|
|
619
|
+
transitionDuration = _this$props10.transitionDuration,
|
|
620
|
+
verticalBorderSpacing = _this$props10.verticalBorderSpacing,
|
|
621
|
+
horizontalMonthPadding = _this$props10.horizontalMonthPadding;
|
|
622
|
+
var _this$state7 = this.state,
|
|
623
|
+
currentMonth = _this$state7.currentMonth,
|
|
624
|
+
disableNext = _this$state7.disableNext,
|
|
625
|
+
disablePrev = _this$state7.disablePrev,
|
|
626
|
+
visibleDays = _this$state7.visibleDays;
|
|
627
|
+
return /*#__PURE__*/React.createElement(DayPicker, {
|
|
628
|
+
orientation: orientation,
|
|
629
|
+
enableOutsideDays: enableOutsideDays,
|
|
630
|
+
modifiers: visibleDays,
|
|
631
|
+
numberOfMonths: numberOfMonths,
|
|
632
|
+
onDayClick: this.onDayClick,
|
|
633
|
+
onDayMouseEnter: this.onDayMouseEnter,
|
|
634
|
+
onDayMouseLeave: this.onDayMouseLeave,
|
|
635
|
+
onPrevMonthClick: this.onPrevMonthClick,
|
|
636
|
+
onNextMonthClick: this.onNextMonthClick,
|
|
637
|
+
onMonthChange: this.onMonthChange,
|
|
638
|
+
onYearChange: this.onYearChange,
|
|
639
|
+
onGetNextScrollableMonths: this.onGetNextScrollableMonths,
|
|
640
|
+
onGetPrevScrollableMonths: this.onGetPrevScrollableMonths,
|
|
641
|
+
monthFormat: monthFormat,
|
|
642
|
+
withPortal: withPortal,
|
|
643
|
+
hidden: !focused,
|
|
644
|
+
hideKeyboardShortcutsPanel: hideKeyboardShortcutsPanel,
|
|
645
|
+
initialVisibleMonth: function initialVisibleMonth() {
|
|
646
|
+
return currentMonth;
|
|
647
|
+
},
|
|
648
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
649
|
+
onOutsideClick: onOutsideClick,
|
|
650
|
+
dayPickerNavigationInlineStyles: dayPickerNavigationInlineStyles,
|
|
651
|
+
navPosition: navPosition,
|
|
652
|
+
disablePrev: disablePrev,
|
|
653
|
+
disableNext: disableNext,
|
|
654
|
+
navPrev: navPrev,
|
|
655
|
+
navNext: navNext,
|
|
656
|
+
renderNavPrevButton: renderNavPrevButton,
|
|
657
|
+
renderNavNextButton: renderNavNextButton,
|
|
658
|
+
noNavButtons: noNavButtons,
|
|
659
|
+
noNavNextButton: noNavNextButton,
|
|
660
|
+
noNavPrevButton: noNavPrevButton,
|
|
661
|
+
renderMonthText: renderMonthText,
|
|
662
|
+
renderWeekHeaderElement: renderWeekHeaderElement,
|
|
663
|
+
renderCalendarDay: renderCalendarDay,
|
|
664
|
+
renderDayContents: renderDayContents,
|
|
665
|
+
renderCalendarInfo: renderCalendarInfo,
|
|
666
|
+
renderMonthElement: renderMonthElement,
|
|
667
|
+
calendarInfoPosition: calendarInfoPosition,
|
|
668
|
+
isFocused: isFocused,
|
|
669
|
+
getFirstFocusableDay: this.getFirstFocusableDay,
|
|
670
|
+
onBlur: onBlur,
|
|
671
|
+
onTab: onTab,
|
|
672
|
+
onShiftTab: onShiftTab,
|
|
673
|
+
phrases: phrases,
|
|
674
|
+
daySize: daySize,
|
|
675
|
+
isRTL: isRTL,
|
|
676
|
+
showKeyboardShortcuts: showKeyboardShortcuts,
|
|
677
|
+
weekDayFormat: weekDayFormat,
|
|
678
|
+
dayAriaLabelFormat: dayAriaLabelFormat,
|
|
679
|
+
verticalHeight: verticalHeight,
|
|
680
|
+
noBorder: noBorder,
|
|
681
|
+
transitionDuration: transitionDuration,
|
|
682
|
+
verticalBorderSpacing: verticalBorderSpacing,
|
|
683
|
+
horizontalMonthPadding: horizontalMonthPadding
|
|
684
|
+
});
|
|
685
|
+
};
|
|
686
|
+
return DayPickerSingleDateController;
|
|
687
|
+
}(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
|
|
688
|
+
export { DayPickerSingleDateController as default };
|
|
689
|
+
DayPickerSingleDateController.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
690
|
+
DayPickerSingleDateController.defaultProps = defaultProps;
|