@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,341 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forbidExtraProps, nonNegativeInteger } from 'airbnb-prop-types';
|
|
8
|
+
import { withStyles, withStylesPropTypes } from 'react-with-styles';
|
|
9
|
+
import { DateRangePickerInputPhrases } from '../defaultPhrases';
|
|
10
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
11
|
+
import noflip from '../utils/noflip';
|
|
12
|
+
import openDirectionShape from '../shapes/OpenDirectionShape';
|
|
13
|
+
import DateInput from './DateInput';
|
|
14
|
+
import IconPositionShape from '../shapes/IconPositionShape';
|
|
15
|
+
import DisabledShape from '../shapes/DisabledShape';
|
|
16
|
+
import RightArrow from './RightArrow';
|
|
17
|
+
import LeftArrow from './LeftArrow';
|
|
18
|
+
import CloseButton from './CloseButton';
|
|
19
|
+
import CalendarIcon from './CalendarIcon';
|
|
20
|
+
import { START_DATE, END_DATE, ICON_BEFORE_POSITION, ICON_AFTER_POSITION, OPEN_DOWN } from '../constants';
|
|
21
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectSpread(_objectSpread({}, withStylesPropTypes), {}, {
|
|
22
|
+
children: PropTypes.node,
|
|
23
|
+
startDateId: PropTypes.string,
|
|
24
|
+
startDatePlaceholderText: PropTypes.string,
|
|
25
|
+
startDateAriaLabel: PropTypes.string,
|
|
26
|
+
startDateTitleText: PropTypes.string,
|
|
27
|
+
screenReaderMessage: PropTypes.string,
|
|
28
|
+
endDateId: PropTypes.string,
|
|
29
|
+
endDatePlaceholderText: PropTypes.string,
|
|
30
|
+
endDateAriaLabel: PropTypes.string,
|
|
31
|
+
endDateTitleText: PropTypes.string,
|
|
32
|
+
onStartDateFocus: PropTypes.func,
|
|
33
|
+
onEndDateFocus: PropTypes.func,
|
|
34
|
+
onStartDateChange: PropTypes.func,
|
|
35
|
+
onEndDateChange: PropTypes.func,
|
|
36
|
+
onStartDateShiftTab: PropTypes.func,
|
|
37
|
+
onEndDateTab: PropTypes.func,
|
|
38
|
+
onClearDates: PropTypes.func,
|
|
39
|
+
onKeyDownArrowDown: PropTypes.func,
|
|
40
|
+
onKeyDownQuestionMark: PropTypes.func,
|
|
41
|
+
startDate: PropTypes.string,
|
|
42
|
+
endDate: PropTypes.string,
|
|
43
|
+
isStartDateFocused: PropTypes.bool,
|
|
44
|
+
isEndDateFocused: PropTypes.bool,
|
|
45
|
+
showClearDates: PropTypes.bool,
|
|
46
|
+
disabled: DisabledShape,
|
|
47
|
+
required: PropTypes.bool,
|
|
48
|
+
readOnly: PropTypes.bool,
|
|
49
|
+
openDirection: openDirectionShape,
|
|
50
|
+
showCaret: PropTypes.bool,
|
|
51
|
+
showDefaultInputIcon: PropTypes.bool,
|
|
52
|
+
inputIconPosition: IconPositionShape,
|
|
53
|
+
customInputIcon: PropTypes.node,
|
|
54
|
+
customArrowIcon: PropTypes.node,
|
|
55
|
+
customCloseIcon: PropTypes.node,
|
|
56
|
+
noBorder: PropTypes.bool,
|
|
57
|
+
block: PropTypes.bool,
|
|
58
|
+
small: PropTypes.bool,
|
|
59
|
+
regular: PropTypes.bool,
|
|
60
|
+
verticalSpacing: nonNegativeInteger,
|
|
61
|
+
autoComplete: PropTypes.string,
|
|
62
|
+
// accessibility
|
|
63
|
+
isFocused: PropTypes.bool,
|
|
64
|
+
// describes actual DOM focus
|
|
65
|
+
|
|
66
|
+
// i18n
|
|
67
|
+
phrases: PropTypes.shape(getPhrasePropTypes(DateRangePickerInputPhrases)),
|
|
68
|
+
isRTL: PropTypes.bool
|
|
69
|
+
})) : {};
|
|
70
|
+
var defaultProps = {
|
|
71
|
+
children: null,
|
|
72
|
+
startDateId: START_DATE,
|
|
73
|
+
endDateId: END_DATE,
|
|
74
|
+
startDatePlaceholderText: 'Start Date',
|
|
75
|
+
endDatePlaceholderText: 'End Date',
|
|
76
|
+
startDateAriaLabel: undefined,
|
|
77
|
+
endDateAriaLabel: undefined,
|
|
78
|
+
startDateTitleText: undefined,
|
|
79
|
+
endDateTitleText: undefined,
|
|
80
|
+
screenReaderMessage: '',
|
|
81
|
+
autoComplete: 'off',
|
|
82
|
+
onStartDateFocus: function onStartDateFocus() {},
|
|
83
|
+
onEndDateFocus: function onEndDateFocus() {},
|
|
84
|
+
onStartDateChange: function onStartDateChange() {},
|
|
85
|
+
onEndDateChange: function onEndDateChange() {},
|
|
86
|
+
onStartDateShiftTab: function onStartDateShiftTab() {},
|
|
87
|
+
onEndDateTab: function onEndDateTab() {},
|
|
88
|
+
onClearDates: function onClearDates() {},
|
|
89
|
+
onKeyDownArrowDown: function onKeyDownArrowDown() {},
|
|
90
|
+
onKeyDownQuestionMark: function onKeyDownQuestionMark() {},
|
|
91
|
+
startDate: '',
|
|
92
|
+
endDate: '',
|
|
93
|
+
isStartDateFocused: false,
|
|
94
|
+
isEndDateFocused: false,
|
|
95
|
+
showClearDates: false,
|
|
96
|
+
disabled: false,
|
|
97
|
+
required: false,
|
|
98
|
+
readOnly: false,
|
|
99
|
+
openDirection: OPEN_DOWN,
|
|
100
|
+
showCaret: false,
|
|
101
|
+
showDefaultInputIcon: false,
|
|
102
|
+
inputIconPosition: ICON_BEFORE_POSITION,
|
|
103
|
+
customInputIcon: null,
|
|
104
|
+
customArrowIcon: null,
|
|
105
|
+
customCloseIcon: null,
|
|
106
|
+
noBorder: false,
|
|
107
|
+
block: false,
|
|
108
|
+
small: false,
|
|
109
|
+
regular: false,
|
|
110
|
+
verticalSpacing: undefined,
|
|
111
|
+
// accessibility
|
|
112
|
+
isFocused: false,
|
|
113
|
+
// i18n
|
|
114
|
+
phrases: DateRangePickerInputPhrases,
|
|
115
|
+
isRTL: false
|
|
116
|
+
};
|
|
117
|
+
function DateRangePickerInput(_ref) {
|
|
118
|
+
var children = _ref.children,
|
|
119
|
+
startDate = _ref.startDate,
|
|
120
|
+
startDateId = _ref.startDateId,
|
|
121
|
+
startDatePlaceholderText = _ref.startDatePlaceholderText,
|
|
122
|
+
screenReaderMessage = _ref.screenReaderMessage,
|
|
123
|
+
isStartDateFocused = _ref.isStartDateFocused,
|
|
124
|
+
onStartDateChange = _ref.onStartDateChange,
|
|
125
|
+
onStartDateFocus = _ref.onStartDateFocus,
|
|
126
|
+
onStartDateShiftTab = _ref.onStartDateShiftTab,
|
|
127
|
+
startDateAriaLabel = _ref.startDateAriaLabel,
|
|
128
|
+
startDateTitleText = _ref.startDateTitleText,
|
|
129
|
+
endDate = _ref.endDate,
|
|
130
|
+
endDateId = _ref.endDateId,
|
|
131
|
+
endDatePlaceholderText = _ref.endDatePlaceholderText,
|
|
132
|
+
isEndDateFocused = _ref.isEndDateFocused,
|
|
133
|
+
onEndDateChange = _ref.onEndDateChange,
|
|
134
|
+
onEndDateFocus = _ref.onEndDateFocus,
|
|
135
|
+
onEndDateTab = _ref.onEndDateTab,
|
|
136
|
+
endDateAriaLabel = _ref.endDateAriaLabel,
|
|
137
|
+
endDateTitleText = _ref.endDateTitleText,
|
|
138
|
+
onKeyDownArrowDown = _ref.onKeyDownArrowDown,
|
|
139
|
+
onKeyDownQuestionMark = _ref.onKeyDownQuestionMark,
|
|
140
|
+
onClearDates = _ref.onClearDates,
|
|
141
|
+
showClearDates = _ref.showClearDates,
|
|
142
|
+
disabled = _ref.disabled,
|
|
143
|
+
required = _ref.required,
|
|
144
|
+
readOnly = _ref.readOnly,
|
|
145
|
+
autoComplete = _ref.autoComplete,
|
|
146
|
+
showCaret = _ref.showCaret,
|
|
147
|
+
openDirection = _ref.openDirection,
|
|
148
|
+
showDefaultInputIcon = _ref.showDefaultInputIcon,
|
|
149
|
+
inputIconPosition = _ref.inputIconPosition,
|
|
150
|
+
customInputIcon = _ref.customInputIcon,
|
|
151
|
+
customArrowIcon = _ref.customArrowIcon,
|
|
152
|
+
customCloseIcon = _ref.customCloseIcon,
|
|
153
|
+
isFocused = _ref.isFocused,
|
|
154
|
+
phrases = _ref.phrases,
|
|
155
|
+
isRTL = _ref.isRTL,
|
|
156
|
+
noBorder = _ref.noBorder,
|
|
157
|
+
block = _ref.block,
|
|
158
|
+
verticalSpacing = _ref.verticalSpacing,
|
|
159
|
+
small = _ref.small,
|
|
160
|
+
regular = _ref.regular,
|
|
161
|
+
css = _ref.css,
|
|
162
|
+
styles = _ref.styles;
|
|
163
|
+
var calendarIcon = customInputIcon || /*#__PURE__*/React.createElement(CalendarIcon, css(styles.DateRangePickerInput_calendarIcon_svg));
|
|
164
|
+
var arrowIcon = /*#__PURE__*/React.createElement(RightArrow, css(styles.DateRangePickerInput_arrow_svg));
|
|
165
|
+
if (isRTL) arrowIcon = /*#__PURE__*/React.createElement(LeftArrow, css(styles.DateRangePickerInput_arrow_svg));
|
|
166
|
+
if (small) arrowIcon = '-';
|
|
167
|
+
if (customArrowIcon) arrowIcon = customArrowIcon;
|
|
168
|
+
var closeIcon = customCloseIcon || /*#__PURE__*/React.createElement(CloseButton, css(styles.DateRangePickerInput_clearDates_svg, small && styles.DateRangePickerInput_clearDates_svg__small));
|
|
169
|
+
var screenReaderStartDateText = screenReaderMessage || phrases.keyboardForwardNavigationInstructions;
|
|
170
|
+
var screenReaderEndDateText = screenReaderMessage || phrases.keyboardBackwardNavigationInstructions;
|
|
171
|
+
var inputIcon = (showDefaultInputIcon || customInputIcon !== null) && /*#__PURE__*/React.createElement("button", _extends({}, css(styles.DateRangePickerInput_calendarIcon), {
|
|
172
|
+
type: "button",
|
|
173
|
+
disabled: disabled,
|
|
174
|
+
"aria-label": phrases.focusStartDate,
|
|
175
|
+
onClick: onKeyDownArrowDown
|
|
176
|
+
}), calendarIcon);
|
|
177
|
+
var startDateDisabled = disabled === START_DATE || disabled === true;
|
|
178
|
+
var endDateDisabled = disabled === END_DATE || disabled === true;
|
|
179
|
+
return /*#__PURE__*/React.createElement("div", css(styles.DateRangePickerInput, disabled && styles.DateRangePickerInput__disabled, isRTL && styles.DateRangePickerInput__rtl, !noBorder && styles.DateRangePickerInput__withBorder, block && styles.DateRangePickerInput__block, showClearDates && styles.DateRangePickerInput__showClearDates), inputIconPosition === ICON_BEFORE_POSITION && inputIcon, /*#__PURE__*/React.createElement(DateInput, {
|
|
180
|
+
id: startDateId,
|
|
181
|
+
placeholder: startDatePlaceholderText,
|
|
182
|
+
ariaLabel: startDateAriaLabel,
|
|
183
|
+
autoComplete: autoComplete,
|
|
184
|
+
titleText: startDateTitleText,
|
|
185
|
+
displayValue: startDate,
|
|
186
|
+
screenReaderMessage: screenReaderStartDateText,
|
|
187
|
+
focused: isStartDateFocused,
|
|
188
|
+
isFocused: isFocused,
|
|
189
|
+
disabled: startDateDisabled,
|
|
190
|
+
required: required,
|
|
191
|
+
readOnly: readOnly,
|
|
192
|
+
showCaret: showCaret,
|
|
193
|
+
openDirection: openDirection,
|
|
194
|
+
onChange: onStartDateChange,
|
|
195
|
+
onFocus: onStartDateFocus,
|
|
196
|
+
onKeyDownShiftTab: onStartDateShiftTab,
|
|
197
|
+
onKeyDownArrowDown: onKeyDownArrowDown,
|
|
198
|
+
onKeyDownQuestionMark: onKeyDownQuestionMark,
|
|
199
|
+
verticalSpacing: verticalSpacing,
|
|
200
|
+
small: small,
|
|
201
|
+
regular: regular
|
|
202
|
+
}), !isEndDateFocused && children, /*#__PURE__*/React.createElement("div", _extends({}, css(styles.DateRangePickerInput_arrow), {
|
|
203
|
+
"aria-hidden": "true",
|
|
204
|
+
role: "presentation"
|
|
205
|
+
}), arrowIcon), /*#__PURE__*/React.createElement(DateInput, {
|
|
206
|
+
id: endDateId,
|
|
207
|
+
placeholder: endDatePlaceholderText,
|
|
208
|
+
ariaLabel: endDateAriaLabel,
|
|
209
|
+
autoComplete: autoComplete,
|
|
210
|
+
titleText: endDateTitleText,
|
|
211
|
+
displayValue: endDate,
|
|
212
|
+
screenReaderMessage: screenReaderEndDateText,
|
|
213
|
+
focused: isEndDateFocused,
|
|
214
|
+
isFocused: isFocused,
|
|
215
|
+
disabled: endDateDisabled,
|
|
216
|
+
required: required,
|
|
217
|
+
readOnly: readOnly,
|
|
218
|
+
showCaret: showCaret,
|
|
219
|
+
openDirection: openDirection,
|
|
220
|
+
onChange: onEndDateChange,
|
|
221
|
+
onFocus: onEndDateFocus,
|
|
222
|
+
onKeyDownArrowDown: onKeyDownArrowDown,
|
|
223
|
+
onKeyDownQuestionMark: onKeyDownQuestionMark,
|
|
224
|
+
onKeyDownTab: onEndDateTab,
|
|
225
|
+
verticalSpacing: verticalSpacing,
|
|
226
|
+
small: small,
|
|
227
|
+
regular: regular
|
|
228
|
+
}), isEndDateFocused && children, showClearDates && /*#__PURE__*/React.createElement("button", _extends({
|
|
229
|
+
type: "button",
|
|
230
|
+
"aria-label": phrases.clearDates
|
|
231
|
+
}, css(styles.DateRangePickerInput_clearDates, small && styles.DateRangePickerInput_clearDates__small, !customCloseIcon && styles.DateRangePickerInput_clearDates_default, !(startDate || endDate) && styles.DateRangePickerInput_clearDates__hide), {
|
|
232
|
+
onClick: onClearDates,
|
|
233
|
+
disabled: disabled
|
|
234
|
+
}), closeIcon), inputIconPosition === ICON_AFTER_POSITION && inputIcon);
|
|
235
|
+
}
|
|
236
|
+
DateRangePickerInput.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
237
|
+
DateRangePickerInput.defaultProps = defaultProps;
|
|
238
|
+
export default withStyles(function (_ref2) {
|
|
239
|
+
var _ref2$reactDates = _ref2.reactDates,
|
|
240
|
+
border = _ref2$reactDates.border,
|
|
241
|
+
color = _ref2$reactDates.color,
|
|
242
|
+
sizing = _ref2$reactDates.sizing;
|
|
243
|
+
return {
|
|
244
|
+
DateRangePickerInput: {
|
|
245
|
+
backgroundColor: color.background,
|
|
246
|
+
display: 'inline-block'
|
|
247
|
+
},
|
|
248
|
+
DateRangePickerInput__disabled: {
|
|
249
|
+
background: color.disabled
|
|
250
|
+
},
|
|
251
|
+
DateRangePickerInput__withBorder: {
|
|
252
|
+
borderColor: color.border,
|
|
253
|
+
borderWidth: border.pickerInput.borderWidth,
|
|
254
|
+
borderStyle: border.pickerInput.borderStyle,
|
|
255
|
+
borderRadius: border.pickerInput.borderRadius
|
|
256
|
+
},
|
|
257
|
+
DateRangePickerInput__rtl: {
|
|
258
|
+
direction: noflip('rtl')
|
|
259
|
+
},
|
|
260
|
+
DateRangePickerInput__block: {
|
|
261
|
+
display: 'block'
|
|
262
|
+
},
|
|
263
|
+
DateRangePickerInput__showClearDates: {
|
|
264
|
+
paddingRight: 30 // TODO: should be noflip wrapped and handled by an isRTL prop
|
|
265
|
+
},
|
|
266
|
+
DateRangePickerInput_arrow: {
|
|
267
|
+
display: 'inline-block',
|
|
268
|
+
verticalAlign: 'middle',
|
|
269
|
+
color: color.text
|
|
270
|
+
},
|
|
271
|
+
DateRangePickerInput_arrow_svg: {
|
|
272
|
+
verticalAlign: 'middle',
|
|
273
|
+
fill: color.text,
|
|
274
|
+
height: sizing.arrowWidth,
|
|
275
|
+
width: sizing.arrowWidth
|
|
276
|
+
},
|
|
277
|
+
DateRangePickerInput_clearDates: {
|
|
278
|
+
background: 'none',
|
|
279
|
+
border: 0,
|
|
280
|
+
color: 'inherit',
|
|
281
|
+
font: 'inherit',
|
|
282
|
+
lineHeight: 'normal',
|
|
283
|
+
overflow: 'visible',
|
|
284
|
+
cursor: 'pointer',
|
|
285
|
+
padding: 10,
|
|
286
|
+
margin: '0 10px 0 5px',
|
|
287
|
+
// TODO: should be noflip wrapped and handled by an isRTL prop
|
|
288
|
+
position: 'absolute',
|
|
289
|
+
right: 0,
|
|
290
|
+
// TODO: should be noflip wrapped and handled by an isRTL prop
|
|
291
|
+
top: '50%',
|
|
292
|
+
transform: 'translateY(-50%)'
|
|
293
|
+
},
|
|
294
|
+
DateRangePickerInput_clearDates__small: {
|
|
295
|
+
padding: 6
|
|
296
|
+
},
|
|
297
|
+
DateRangePickerInput_clearDates_default: {
|
|
298
|
+
':focus': {
|
|
299
|
+
background: color.core.border,
|
|
300
|
+
borderRadius: '50%'
|
|
301
|
+
},
|
|
302
|
+
':hover': {
|
|
303
|
+
background: color.core.border,
|
|
304
|
+
borderRadius: '50%'
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
DateRangePickerInput_clearDates__hide: {
|
|
308
|
+
visibility: 'hidden'
|
|
309
|
+
},
|
|
310
|
+
DateRangePickerInput_clearDates_svg: {
|
|
311
|
+
fill: color.core.grayLight,
|
|
312
|
+
height: 12,
|
|
313
|
+
width: 15,
|
|
314
|
+
verticalAlign: 'middle'
|
|
315
|
+
},
|
|
316
|
+
DateRangePickerInput_clearDates_svg__small: {
|
|
317
|
+
height: 9
|
|
318
|
+
},
|
|
319
|
+
DateRangePickerInput_calendarIcon: {
|
|
320
|
+
background: 'none',
|
|
321
|
+
border: 0,
|
|
322
|
+
color: 'inherit',
|
|
323
|
+
font: 'inherit',
|
|
324
|
+
lineHeight: 'normal',
|
|
325
|
+
overflow: 'visible',
|
|
326
|
+
cursor: 'pointer',
|
|
327
|
+
display: 'inline-block',
|
|
328
|
+
verticalAlign: 'middle',
|
|
329
|
+
padding: 10,
|
|
330
|
+
margin: '0 5px 0 10px' // TODO: should be noflip wrapped and handled by an isRTL prop
|
|
331
|
+
},
|
|
332
|
+
DateRangePickerInput_calendarIcon_svg: {
|
|
333
|
+
fill: color.core.grayLight,
|
|
334
|
+
height: 15,
|
|
335
|
+
width: 14,
|
|
336
|
+
verticalAlign: 'middle'
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
}, {
|
|
340
|
+
pureComponent: typeof React.PureComponent !== 'undefined'
|
|
341
|
+
})(DateRangePickerInput);
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
2
|
+
import shallowEqual from "enzyme-shallow-equal";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import momentPropTypes from 'react-moment-proptypes';
|
|
7
|
+
import { forbidExtraProps, nonNegativeInteger } from 'airbnb-prop-types';
|
|
8
|
+
import openDirectionShape from '../shapes/OpenDirectionShape';
|
|
9
|
+
import { DateRangePickerInputPhrases } from '../defaultPhrases';
|
|
10
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
11
|
+
import DateRangePickerInput from './DateRangePickerInput';
|
|
12
|
+
import IconPositionShape from '../shapes/IconPositionShape';
|
|
13
|
+
import DisabledShape from '../shapes/DisabledShape';
|
|
14
|
+
import toMomentObject from '../utils/toMomentObject';
|
|
15
|
+
import toLocalizedDateString from '../utils/toLocalizedDateString';
|
|
16
|
+
import isInclusivelyAfterDay from '../utils/isInclusivelyAfterDay';
|
|
17
|
+
import isBeforeDay from '../utils/isBeforeDay';
|
|
18
|
+
import { START_DATE, END_DATE, ICON_BEFORE_POSITION, OPEN_DOWN } from '../constants';
|
|
19
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps({
|
|
20
|
+
children: PropTypes.node,
|
|
21
|
+
startDate: momentPropTypes.momentObj,
|
|
22
|
+
startDateId: PropTypes.string,
|
|
23
|
+
startDatePlaceholderText: PropTypes.string,
|
|
24
|
+
isStartDateFocused: PropTypes.bool,
|
|
25
|
+
startDateAriaLabel: PropTypes.string,
|
|
26
|
+
startDateTitleText: PropTypes.string,
|
|
27
|
+
endDate: momentPropTypes.momentObj,
|
|
28
|
+
endDateId: PropTypes.string,
|
|
29
|
+
endDatePlaceholderText: PropTypes.string,
|
|
30
|
+
isEndDateFocused: PropTypes.bool,
|
|
31
|
+
endDateAriaLabel: PropTypes.string,
|
|
32
|
+
endDateTitleText: PropTypes.string,
|
|
33
|
+
screenReaderMessage: PropTypes.string,
|
|
34
|
+
showClearDates: PropTypes.bool,
|
|
35
|
+
showCaret: PropTypes.bool,
|
|
36
|
+
showDefaultInputIcon: PropTypes.bool,
|
|
37
|
+
inputIconPosition: IconPositionShape,
|
|
38
|
+
disabled: DisabledShape,
|
|
39
|
+
required: PropTypes.bool,
|
|
40
|
+
readOnly: PropTypes.bool,
|
|
41
|
+
openDirection: openDirectionShape,
|
|
42
|
+
noBorder: PropTypes.bool,
|
|
43
|
+
block: PropTypes.bool,
|
|
44
|
+
small: PropTypes.bool,
|
|
45
|
+
regular: PropTypes.bool,
|
|
46
|
+
verticalSpacing: nonNegativeInteger,
|
|
47
|
+
autoComplete: PropTypes.string,
|
|
48
|
+
keepOpenOnDateSelect: PropTypes.bool,
|
|
49
|
+
reopenPickerOnClearDates: PropTypes.bool,
|
|
50
|
+
withFullScreenPortal: PropTypes.bool,
|
|
51
|
+
minimumNights: nonNegativeInteger,
|
|
52
|
+
isOutsideRange: PropTypes.func,
|
|
53
|
+
isDayBlocked: PropTypes.func,
|
|
54
|
+
displayFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
55
|
+
onFocusChange: PropTypes.func,
|
|
56
|
+
onClose: PropTypes.func,
|
|
57
|
+
onDatesChange: PropTypes.func,
|
|
58
|
+
onKeyDownArrowDown: PropTypes.func,
|
|
59
|
+
onKeyDownQuestionMark: PropTypes.func,
|
|
60
|
+
customInputIcon: PropTypes.node,
|
|
61
|
+
customArrowIcon: PropTypes.node,
|
|
62
|
+
customCloseIcon: PropTypes.node,
|
|
63
|
+
// accessibility
|
|
64
|
+
isFocused: PropTypes.bool,
|
|
65
|
+
// i18n
|
|
66
|
+
phrases: PropTypes.shape(getPhrasePropTypes(DateRangePickerInputPhrases)),
|
|
67
|
+
isRTL: PropTypes.bool
|
|
68
|
+
}) : {};
|
|
69
|
+
var defaultProps = {
|
|
70
|
+
children: null,
|
|
71
|
+
startDate: null,
|
|
72
|
+
startDateId: START_DATE,
|
|
73
|
+
startDatePlaceholderText: 'Start Date',
|
|
74
|
+
isStartDateFocused: false,
|
|
75
|
+
startDateAriaLabel: undefined,
|
|
76
|
+
startDateTitleText: undefined,
|
|
77
|
+
endDate: null,
|
|
78
|
+
endDateId: END_DATE,
|
|
79
|
+
endDatePlaceholderText: 'End Date',
|
|
80
|
+
isEndDateFocused: false,
|
|
81
|
+
endDateAriaLabel: undefined,
|
|
82
|
+
endDateTitleText: undefined,
|
|
83
|
+
screenReaderMessage: '',
|
|
84
|
+
showClearDates: false,
|
|
85
|
+
showCaret: false,
|
|
86
|
+
showDefaultInputIcon: false,
|
|
87
|
+
inputIconPosition: ICON_BEFORE_POSITION,
|
|
88
|
+
disabled: false,
|
|
89
|
+
required: false,
|
|
90
|
+
readOnly: false,
|
|
91
|
+
openDirection: OPEN_DOWN,
|
|
92
|
+
noBorder: false,
|
|
93
|
+
block: false,
|
|
94
|
+
small: false,
|
|
95
|
+
regular: false,
|
|
96
|
+
verticalSpacing: undefined,
|
|
97
|
+
autoComplete: 'off',
|
|
98
|
+
keepOpenOnDateSelect: false,
|
|
99
|
+
reopenPickerOnClearDates: false,
|
|
100
|
+
withFullScreenPortal: false,
|
|
101
|
+
minimumNights: 1,
|
|
102
|
+
isOutsideRange: function isOutsideRange(day) {
|
|
103
|
+
return !isInclusivelyAfterDay(day, moment());
|
|
104
|
+
},
|
|
105
|
+
isDayBlocked: function isDayBlocked() {
|
|
106
|
+
return false;
|
|
107
|
+
},
|
|
108
|
+
displayFormat: function displayFormat() {
|
|
109
|
+
return moment.localeData().longDateFormat('L');
|
|
110
|
+
},
|
|
111
|
+
onFocusChange: function onFocusChange() {},
|
|
112
|
+
onClose: function onClose() {},
|
|
113
|
+
onDatesChange: function onDatesChange() {},
|
|
114
|
+
onKeyDownArrowDown: function onKeyDownArrowDown() {},
|
|
115
|
+
onKeyDownQuestionMark: function onKeyDownQuestionMark() {},
|
|
116
|
+
customInputIcon: null,
|
|
117
|
+
customArrowIcon: null,
|
|
118
|
+
customCloseIcon: null,
|
|
119
|
+
// accessibility
|
|
120
|
+
isFocused: false,
|
|
121
|
+
// i18n
|
|
122
|
+
phrases: DateRangePickerInputPhrases,
|
|
123
|
+
isRTL: false
|
|
124
|
+
};
|
|
125
|
+
var DateRangePickerInputController = /*#__PURE__*/function (_ref2, _ref) {
|
|
126
|
+
function DateRangePickerInputController(props) {
|
|
127
|
+
var _this;
|
|
128
|
+
_this = _ref2.call(this, props) || this;
|
|
129
|
+
_this.onClearFocus = _this.onClearFocus.bind(_this);
|
|
130
|
+
_this.onStartDateChange = _this.onStartDateChange.bind(_this);
|
|
131
|
+
_this.onStartDateFocus = _this.onStartDateFocus.bind(_this);
|
|
132
|
+
_this.onEndDateChange = _this.onEndDateChange.bind(_this);
|
|
133
|
+
_this.onEndDateFocus = _this.onEndDateFocus.bind(_this);
|
|
134
|
+
_this.clearDates = _this.clearDates.bind(_this);
|
|
135
|
+
return _this;
|
|
136
|
+
}
|
|
137
|
+
_inheritsLoose(DateRangePickerInputController, _ref2);
|
|
138
|
+
var _proto = DateRangePickerInputController.prototype;
|
|
139
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
140
|
+
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
141
|
+
};
|
|
142
|
+
_proto.onClearFocus = function onClearFocus() {
|
|
143
|
+
var _this$props = this.props,
|
|
144
|
+
onFocusChange = _this$props.onFocusChange,
|
|
145
|
+
onClose = _this$props.onClose,
|
|
146
|
+
startDate = _this$props.startDate,
|
|
147
|
+
endDate = _this$props.endDate;
|
|
148
|
+
onFocusChange(null);
|
|
149
|
+
onClose({
|
|
150
|
+
startDate: startDate,
|
|
151
|
+
endDate: endDate
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
_proto.onEndDateChange = function onEndDateChange(endDateString) {
|
|
155
|
+
var _this$props2 = this.props,
|
|
156
|
+
startDate = _this$props2.startDate,
|
|
157
|
+
isOutsideRange = _this$props2.isOutsideRange,
|
|
158
|
+
isDayBlocked = _this$props2.isDayBlocked,
|
|
159
|
+
minimumNights = _this$props2.minimumNights,
|
|
160
|
+
keepOpenOnDateSelect = _this$props2.keepOpenOnDateSelect,
|
|
161
|
+
onDatesChange = _this$props2.onDatesChange,
|
|
162
|
+
onClose = _this$props2.onClose,
|
|
163
|
+
onFocusChange = _this$props2.onFocusChange;
|
|
164
|
+
var endDate = toMomentObject(endDateString, this.getDisplayFormat());
|
|
165
|
+
var isEndDateValid = endDate && !isOutsideRange(endDate) && !isDayBlocked(endDate) && !(startDate && isBeforeDay(endDate, startDate.clone().add(minimumNights, 'days')));
|
|
166
|
+
if (isEndDateValid) {
|
|
167
|
+
onDatesChange({
|
|
168
|
+
startDate: startDate,
|
|
169
|
+
endDate: endDate
|
|
170
|
+
});
|
|
171
|
+
if (!keepOpenOnDateSelect) {
|
|
172
|
+
onFocusChange(null);
|
|
173
|
+
onClose({
|
|
174
|
+
startDate: startDate,
|
|
175
|
+
endDate: endDate
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
onDatesChange({
|
|
180
|
+
startDate: startDate,
|
|
181
|
+
endDate: null
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
_proto.onEndDateFocus = function onEndDateFocus() {
|
|
186
|
+
var _this$props3 = this.props,
|
|
187
|
+
startDate = _this$props3.startDate,
|
|
188
|
+
onFocusChange = _this$props3.onFocusChange,
|
|
189
|
+
withFullScreenPortal = _this$props3.withFullScreenPortal,
|
|
190
|
+
disabled = _this$props3.disabled;
|
|
191
|
+
if (!startDate && withFullScreenPortal && (!disabled || disabled === END_DATE)) {
|
|
192
|
+
// When the datepicker is full screen, we never want to focus the end date first
|
|
193
|
+
// because there's no indication that that is the case once the datepicker is open and it
|
|
194
|
+
// might confuse the user
|
|
195
|
+
onFocusChange(START_DATE);
|
|
196
|
+
} else if (!disabled || disabled === START_DATE) {
|
|
197
|
+
onFocusChange(END_DATE);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
_proto.onStartDateChange = function onStartDateChange(startDateString) {
|
|
201
|
+
var endDate = this.props.endDate;
|
|
202
|
+
var _this$props4 = this.props,
|
|
203
|
+
isOutsideRange = _this$props4.isOutsideRange,
|
|
204
|
+
isDayBlocked = _this$props4.isDayBlocked,
|
|
205
|
+
minimumNights = _this$props4.minimumNights,
|
|
206
|
+
onDatesChange = _this$props4.onDatesChange,
|
|
207
|
+
onFocusChange = _this$props4.onFocusChange,
|
|
208
|
+
disabled = _this$props4.disabled;
|
|
209
|
+
var startDate = toMomentObject(startDateString, this.getDisplayFormat());
|
|
210
|
+
var isEndDateBeforeStartDate = startDate && isBeforeDay(endDate, startDate.clone().add(minimumNights, 'days'));
|
|
211
|
+
var isStartDateValid = startDate && !isOutsideRange(startDate) && !isDayBlocked(startDate) && !(disabled === END_DATE && isEndDateBeforeStartDate);
|
|
212
|
+
if (isStartDateValid) {
|
|
213
|
+
if (isEndDateBeforeStartDate) {
|
|
214
|
+
endDate = null;
|
|
215
|
+
}
|
|
216
|
+
onDatesChange({
|
|
217
|
+
startDate: startDate,
|
|
218
|
+
endDate: endDate
|
|
219
|
+
});
|
|
220
|
+
onFocusChange(END_DATE);
|
|
221
|
+
} else {
|
|
222
|
+
onDatesChange({
|
|
223
|
+
startDate: null,
|
|
224
|
+
endDate: endDate
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
_proto.onStartDateFocus = function onStartDateFocus() {
|
|
229
|
+
var _this$props5 = this.props,
|
|
230
|
+
disabled = _this$props5.disabled,
|
|
231
|
+
onFocusChange = _this$props5.onFocusChange;
|
|
232
|
+
if (!disabled || disabled === END_DATE) {
|
|
233
|
+
onFocusChange(START_DATE);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
_proto.getDisplayFormat = function getDisplayFormat() {
|
|
237
|
+
var displayFormat = this.props.displayFormat;
|
|
238
|
+
return typeof displayFormat === 'string' ? displayFormat : displayFormat();
|
|
239
|
+
};
|
|
240
|
+
_proto.getDateString = function getDateString(date) {
|
|
241
|
+
var displayFormat = this.getDisplayFormat();
|
|
242
|
+
if (date && displayFormat) {
|
|
243
|
+
return date && date.format(displayFormat);
|
|
244
|
+
}
|
|
245
|
+
return toLocalizedDateString(date);
|
|
246
|
+
};
|
|
247
|
+
_proto.clearDates = function clearDates() {
|
|
248
|
+
var _this$props6 = this.props,
|
|
249
|
+
onDatesChange = _this$props6.onDatesChange,
|
|
250
|
+
reopenPickerOnClearDates = _this$props6.reopenPickerOnClearDates,
|
|
251
|
+
onFocusChange = _this$props6.onFocusChange;
|
|
252
|
+
onDatesChange({
|
|
253
|
+
startDate: null,
|
|
254
|
+
endDate: null
|
|
255
|
+
});
|
|
256
|
+
if (reopenPickerOnClearDates) {
|
|
257
|
+
onFocusChange(START_DATE);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
_proto.render = function render() {
|
|
261
|
+
var _this$props7 = this.props,
|
|
262
|
+
children = _this$props7.children,
|
|
263
|
+
startDate = _this$props7.startDate,
|
|
264
|
+
startDateId = _this$props7.startDateId,
|
|
265
|
+
startDatePlaceholderText = _this$props7.startDatePlaceholderText,
|
|
266
|
+
isStartDateFocused = _this$props7.isStartDateFocused,
|
|
267
|
+
startDateAriaLabel = _this$props7.startDateAriaLabel,
|
|
268
|
+
startDateTitleText = _this$props7.startDateTitleText,
|
|
269
|
+
endDate = _this$props7.endDate,
|
|
270
|
+
endDateId = _this$props7.endDateId,
|
|
271
|
+
endDatePlaceholderText = _this$props7.endDatePlaceholderText,
|
|
272
|
+
endDateAriaLabel = _this$props7.endDateAriaLabel,
|
|
273
|
+
endDateTitleText = _this$props7.endDateTitleText,
|
|
274
|
+
isEndDateFocused = _this$props7.isEndDateFocused,
|
|
275
|
+
screenReaderMessage = _this$props7.screenReaderMessage,
|
|
276
|
+
showClearDates = _this$props7.showClearDates,
|
|
277
|
+
showCaret = _this$props7.showCaret,
|
|
278
|
+
showDefaultInputIcon = _this$props7.showDefaultInputIcon,
|
|
279
|
+
inputIconPosition = _this$props7.inputIconPosition,
|
|
280
|
+
customInputIcon = _this$props7.customInputIcon,
|
|
281
|
+
customArrowIcon = _this$props7.customArrowIcon,
|
|
282
|
+
customCloseIcon = _this$props7.customCloseIcon,
|
|
283
|
+
disabled = _this$props7.disabled,
|
|
284
|
+
required = _this$props7.required,
|
|
285
|
+
readOnly = _this$props7.readOnly,
|
|
286
|
+
openDirection = _this$props7.openDirection,
|
|
287
|
+
isFocused = _this$props7.isFocused,
|
|
288
|
+
phrases = _this$props7.phrases,
|
|
289
|
+
onKeyDownArrowDown = _this$props7.onKeyDownArrowDown,
|
|
290
|
+
onKeyDownQuestionMark = _this$props7.onKeyDownQuestionMark,
|
|
291
|
+
isRTL = _this$props7.isRTL,
|
|
292
|
+
noBorder = _this$props7.noBorder,
|
|
293
|
+
block = _this$props7.block,
|
|
294
|
+
small = _this$props7.small,
|
|
295
|
+
regular = _this$props7.regular,
|
|
296
|
+
verticalSpacing = _this$props7.verticalSpacing,
|
|
297
|
+
autoComplete = _this$props7.autoComplete;
|
|
298
|
+
var startDateString = this.getDateString(startDate);
|
|
299
|
+
var endDateString = this.getDateString(endDate);
|
|
300
|
+
return /*#__PURE__*/React.createElement(DateRangePickerInput, {
|
|
301
|
+
startDate: startDateString,
|
|
302
|
+
startDateId: startDateId,
|
|
303
|
+
startDatePlaceholderText: startDatePlaceholderText,
|
|
304
|
+
isStartDateFocused: isStartDateFocused,
|
|
305
|
+
startDateAriaLabel: startDateAriaLabel,
|
|
306
|
+
startDateTitleText: startDateTitleText,
|
|
307
|
+
endDate: endDateString,
|
|
308
|
+
endDateId: endDateId,
|
|
309
|
+
endDatePlaceholderText: endDatePlaceholderText,
|
|
310
|
+
isEndDateFocused: isEndDateFocused,
|
|
311
|
+
endDateAriaLabel: endDateAriaLabel,
|
|
312
|
+
endDateTitleText: endDateTitleText,
|
|
313
|
+
isFocused: isFocused,
|
|
314
|
+
disabled: disabled,
|
|
315
|
+
required: required,
|
|
316
|
+
readOnly: readOnly,
|
|
317
|
+
openDirection: openDirection,
|
|
318
|
+
showCaret: showCaret,
|
|
319
|
+
showDefaultInputIcon: showDefaultInputIcon,
|
|
320
|
+
inputIconPosition: inputIconPosition,
|
|
321
|
+
customInputIcon: customInputIcon,
|
|
322
|
+
customArrowIcon: customArrowIcon,
|
|
323
|
+
customCloseIcon: customCloseIcon,
|
|
324
|
+
phrases: phrases,
|
|
325
|
+
onStartDateChange: this.onStartDateChange,
|
|
326
|
+
onStartDateFocus: this.onStartDateFocus,
|
|
327
|
+
onStartDateShiftTab: this.onClearFocus,
|
|
328
|
+
onEndDateChange: this.onEndDateChange,
|
|
329
|
+
onEndDateFocus: this.onEndDateFocus,
|
|
330
|
+
showClearDates: showClearDates,
|
|
331
|
+
onClearDates: this.clearDates,
|
|
332
|
+
screenReaderMessage: screenReaderMessage,
|
|
333
|
+
onKeyDownArrowDown: onKeyDownArrowDown,
|
|
334
|
+
onKeyDownQuestionMark: onKeyDownQuestionMark,
|
|
335
|
+
isRTL: isRTL,
|
|
336
|
+
noBorder: noBorder,
|
|
337
|
+
block: block,
|
|
338
|
+
small: small,
|
|
339
|
+
regular: regular,
|
|
340
|
+
verticalSpacing: verticalSpacing,
|
|
341
|
+
autoComplete: autoComplete
|
|
342
|
+
}, children);
|
|
343
|
+
};
|
|
344
|
+
return DateRangePickerInputController;
|
|
345
|
+
}(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
|
|
346
|
+
export { DateRangePickerInputController as default };
|
|
347
|
+
DateRangePickerInputController.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
348
|
+
DateRangePickerInputController.defaultProps = defaultProps;
|