@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,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _enzymeShallowEqual = _interopRequireDefault(require("enzyme-shallow-equal"));
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _readOnlyError2 = _interopRequireDefault(require("@babel/runtime/helpers/readOnlyError"));
|
|
11
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
var _reactMomentProptypes = _interopRequireDefault(require("react-moment-proptypes"));
|
|
16
|
+
var _airbnbPropTypes = require("airbnb-prop-types");
|
|
17
|
+
var _reactWithStyles = require("react-with-styles");
|
|
18
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
19
|
+
var _defaultPhrases = require("../defaultPhrases");
|
|
20
|
+
var _getPhrasePropTypes = _interopRequireDefault(require("../utils/getPhrasePropTypes"));
|
|
21
|
+
var _CalendarWeek = _interopRequireDefault(require("./CalendarWeek"));
|
|
22
|
+
var _CalendarDay = _interopRequireDefault(require("./CalendarDay"));
|
|
23
|
+
var _calculateDimension = _interopRequireDefault(require("../utils/calculateDimension"));
|
|
24
|
+
var _getCalendarMonthWeeks = _interopRequireDefault(require("../utils/getCalendarMonthWeeks"));
|
|
25
|
+
var _isSameDay = _interopRequireDefault(require("../utils/isSameDay"));
|
|
26
|
+
var _toISODateString = _interopRequireDefault(require("../utils/toISODateString"));
|
|
27
|
+
var _ModifiersShape = _interopRequireDefault(require("../shapes/ModifiersShape"));
|
|
28
|
+
var _ScrollableOrientationShape = _interopRequireDefault(require("../shapes/ScrollableOrientationShape"));
|
|
29
|
+
var _DayOfWeekShape = _interopRequireDefault(require("../shapes/DayOfWeekShape"));
|
|
30
|
+
var _constants = require("../constants");
|
|
31
|
+
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; }
|
|
32
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint react/no-array-index-key: 0 */
|
|
33
|
+
var propTypes = process.env.NODE_ENV !== "production" ? (0, _airbnbPropTypes.forbidExtraProps)(_objectSpread(_objectSpread({}, _reactWithStyles.withStylesPropTypes), {}, {
|
|
34
|
+
month: _reactMomentProptypes["default"].momentObj,
|
|
35
|
+
horizontalMonthPadding: _airbnbPropTypes.nonNegativeInteger,
|
|
36
|
+
isVisible: _propTypes["default"].bool,
|
|
37
|
+
enableOutsideDays: _propTypes["default"].bool,
|
|
38
|
+
modifiers: _propTypes["default"].objectOf(_ModifiersShape["default"]),
|
|
39
|
+
orientation: _ScrollableOrientationShape["default"],
|
|
40
|
+
daySize: _airbnbPropTypes.nonNegativeInteger,
|
|
41
|
+
onDayClick: _propTypes["default"].func,
|
|
42
|
+
onDayMouseEnter: _propTypes["default"].func,
|
|
43
|
+
onDayMouseLeave: _propTypes["default"].func,
|
|
44
|
+
onMonthSelect: _propTypes["default"].func,
|
|
45
|
+
onYearSelect: _propTypes["default"].func,
|
|
46
|
+
renderMonthText: (0, _airbnbPropTypes.mutuallyExclusiveProps)(_propTypes["default"].func, 'renderMonthText', 'renderMonthElement'),
|
|
47
|
+
renderCalendarDay: _propTypes["default"].func,
|
|
48
|
+
renderDayContents: _propTypes["default"].func,
|
|
49
|
+
renderMonthElement: (0, _airbnbPropTypes.mutuallyExclusiveProps)(_propTypes["default"].func, 'renderMonthText', 'renderMonthElement'),
|
|
50
|
+
firstDayOfWeek: _DayOfWeekShape["default"],
|
|
51
|
+
setMonthTitleHeight: _propTypes["default"].func,
|
|
52
|
+
verticalBorderSpacing: _airbnbPropTypes.nonNegativeInteger,
|
|
53
|
+
focusedDate: _reactMomentProptypes["default"].momentObj,
|
|
54
|
+
// indicates focusable day
|
|
55
|
+
isFocused: _propTypes["default"].bool,
|
|
56
|
+
// indicates whether or not to move focus to focusable day
|
|
57
|
+
|
|
58
|
+
// i18n
|
|
59
|
+
monthFormat: _propTypes["default"].string,
|
|
60
|
+
phrases: _propTypes["default"].shape((0, _getPhrasePropTypes["default"])(_defaultPhrases.CalendarDayPhrases)),
|
|
61
|
+
dayAriaLabelFormat: _propTypes["default"].string
|
|
62
|
+
})) : {};
|
|
63
|
+
var defaultProps = {
|
|
64
|
+
month: (0, _moment["default"])(),
|
|
65
|
+
horizontalMonthPadding: 13,
|
|
66
|
+
isVisible: true,
|
|
67
|
+
enableOutsideDays: false,
|
|
68
|
+
modifiers: {},
|
|
69
|
+
orientation: _constants.HORIZONTAL_ORIENTATION,
|
|
70
|
+
daySize: _constants.DAY_SIZE,
|
|
71
|
+
onDayClick: function onDayClick() {},
|
|
72
|
+
onDayMouseEnter: function onDayMouseEnter() {},
|
|
73
|
+
onDayMouseLeave: function onDayMouseLeave() {},
|
|
74
|
+
onMonthSelect: function onMonthSelect() {},
|
|
75
|
+
onYearSelect: function onYearSelect() {},
|
|
76
|
+
renderMonthText: null,
|
|
77
|
+
renderCalendarDay: function renderCalendarDay(props) {
|
|
78
|
+
return /*#__PURE__*/_react["default"].createElement(_CalendarDay["default"], props);
|
|
79
|
+
},
|
|
80
|
+
renderDayContents: null,
|
|
81
|
+
renderMonthElement: null,
|
|
82
|
+
firstDayOfWeek: null,
|
|
83
|
+
setMonthTitleHeight: null,
|
|
84
|
+
focusedDate: null,
|
|
85
|
+
isFocused: false,
|
|
86
|
+
// i18n
|
|
87
|
+
monthFormat: 'MMMM YYYY',
|
|
88
|
+
// english locale
|
|
89
|
+
phrases: _defaultPhrases.CalendarDayPhrases,
|
|
90
|
+
dayAriaLabelFormat: undefined,
|
|
91
|
+
verticalBorderSpacing: undefined
|
|
92
|
+
};
|
|
93
|
+
var CalendarMonth = /*#__PURE__*/function (_ref2, _ref) {
|
|
94
|
+
function CalendarMonth(props) {
|
|
95
|
+
var _this;
|
|
96
|
+
_this = _ref2.call(this, props) || this;
|
|
97
|
+
_this.state = {
|
|
98
|
+
month: props.month,
|
|
99
|
+
enableOutsideDays: props.enableOutsideDays,
|
|
100
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
101
|
+
weeks: (0, _getCalendarMonthWeeks["default"])(props.month, props.enableOutsideDays, props.firstDayOfWeek == null ? _moment["default"].localeData().firstDayOfWeek() : props.firstDayOfWeek)
|
|
102
|
+
};
|
|
103
|
+
_this.setCaptionRef = _this.setCaptionRef.bind(_this);
|
|
104
|
+
_this.setMonthTitleHeight = _this.setMonthTitleHeight.bind(_this);
|
|
105
|
+
return _this;
|
|
106
|
+
}
|
|
107
|
+
(0, _inheritsLoose2["default"])(CalendarMonth, _ref2);
|
|
108
|
+
var _proto = CalendarMonth.prototype;
|
|
109
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
110
|
+
return !(0, _enzymeShallowEqual["default"])(this.props, nextProps) || !(0, _enzymeShallowEqual["default"])(this.state, nextState);
|
|
111
|
+
};
|
|
112
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
113
|
+
this.queueSetMonthTitleHeight();
|
|
114
|
+
};
|
|
115
|
+
CalendarMonth.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
116
|
+
var month = props.month,
|
|
117
|
+
enableOutsideDays = props.enableOutsideDays,
|
|
118
|
+
firstDayOfWeek = props.firstDayOfWeek;
|
|
119
|
+
var prevMonth = state.month,
|
|
120
|
+
prevEnableOutsideDays = state.enableOutsideDays,
|
|
121
|
+
prevFirstDayOfWeek = state.firstDayOfWeek;
|
|
122
|
+
if (!month.isSame(prevMonth) || enableOutsideDays !== prevEnableOutsideDays || firstDayOfWeek !== prevFirstDayOfWeek) {
|
|
123
|
+
return {
|
|
124
|
+
month: month,
|
|
125
|
+
enableOutsideDays: enableOutsideDays,
|
|
126
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
127
|
+
weeks: (0, _getCalendarMonthWeeks["default"])(month, enableOutsideDays, firstDayOfWeek == null ? _moment["default"].localeData().firstDayOfWeek() : firstDayOfWeek)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
};
|
|
132
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
133
|
+
var setMonthTitleHeight = this.props.setMonthTitleHeight;
|
|
134
|
+
if (prevProps.setMonthTitleHeight === null && setMonthTitleHeight !== null) {
|
|
135
|
+
this.queueSetMonthTitleHeight();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
139
|
+
if (this.setMonthTitleHeightTimeout) {
|
|
140
|
+
clearTimeout(this.setMonthTitleHeightTimeout);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
_proto.setMonthTitleHeight = function setMonthTitleHeight() {
|
|
144
|
+
var setMonthTitleHeight = this.props.setMonthTitleHeight;
|
|
145
|
+
if (setMonthTitleHeight) {
|
|
146
|
+
var captionHeight = (0, _calculateDimension["default"])(this.captionRef, 'height', true, true);
|
|
147
|
+
setMonthTitleHeight(captionHeight);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
_proto.setCaptionRef = function setCaptionRef(ref) {
|
|
151
|
+
this.captionRef = ref;
|
|
152
|
+
};
|
|
153
|
+
_proto.queueSetMonthTitleHeight = function queueSetMonthTitleHeight() {
|
|
154
|
+
this.setMonthTitleHeightTimeout = window.setTimeout(this.setMonthTitleHeight, 0);
|
|
155
|
+
};
|
|
156
|
+
_proto.render = function render() {
|
|
157
|
+
var _this$props = this.props,
|
|
158
|
+
dayAriaLabelFormat = _this$props.dayAriaLabelFormat,
|
|
159
|
+
daySize = _this$props.daySize,
|
|
160
|
+
focusedDate = _this$props.focusedDate,
|
|
161
|
+
horizontalMonthPadding = _this$props.horizontalMonthPadding,
|
|
162
|
+
isFocused = _this$props.isFocused,
|
|
163
|
+
isVisible = _this$props.isVisible,
|
|
164
|
+
modifiers = _this$props.modifiers,
|
|
165
|
+
month = _this$props.month,
|
|
166
|
+
monthFormat = _this$props.monthFormat,
|
|
167
|
+
onDayClick = _this$props.onDayClick,
|
|
168
|
+
onDayMouseEnter = _this$props.onDayMouseEnter,
|
|
169
|
+
onDayMouseLeave = _this$props.onDayMouseLeave,
|
|
170
|
+
onMonthSelect = _this$props.onMonthSelect,
|
|
171
|
+
onYearSelect = _this$props.onYearSelect,
|
|
172
|
+
orientation = _this$props.orientation,
|
|
173
|
+
phrases = _this$props.phrases,
|
|
174
|
+
renderCalendarDay = _this$props.renderCalendarDay,
|
|
175
|
+
renderDayContents = _this$props.renderDayContents,
|
|
176
|
+
renderMonthElement = _this$props.renderMonthElement,
|
|
177
|
+
renderMonthText = _this$props.renderMonthText,
|
|
178
|
+
css = _this$props.css,
|
|
179
|
+
styles = _this$props.styles,
|
|
180
|
+
verticalBorderSpacing = _this$props.verticalBorderSpacing;
|
|
181
|
+
var weeks = this.state.weeks;
|
|
182
|
+
var monthTitle = renderMonthText ? renderMonthText(month) : month.format(monthFormat);
|
|
183
|
+
var verticalScrollable = orientation === _constants.VERTICAL_SCROLLABLE;
|
|
184
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, css(styles.CalendarMonth, {
|
|
185
|
+
padding: "0 ".concat(horizontalMonthPadding, "px")
|
|
186
|
+
}), {
|
|
187
|
+
"data-visible": isVisible
|
|
188
|
+
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
189
|
+
ref: this.setCaptionRef
|
|
190
|
+
}, css(styles.CalendarMonth_caption, verticalScrollable && styles.CalendarMonth_caption__verticalScrollable)), renderMonthElement ? renderMonthElement({
|
|
191
|
+
month: month,
|
|
192
|
+
onMonthSelect: onMonthSelect,
|
|
193
|
+
onYearSelect: onYearSelect,
|
|
194
|
+
isVisible: isVisible
|
|
195
|
+
}) : /*#__PURE__*/_react["default"].createElement("strong", null, monthTitle)), /*#__PURE__*/_react["default"].createElement("table", (0, _extends2["default"])({}, css(!verticalBorderSpacing && styles.CalendarMonth_table, verticalBorderSpacing && styles.CalendarMonth_verticalSpacing, verticalBorderSpacing && {
|
|
196
|
+
borderSpacing: "0px ".concat(verticalBorderSpacing, "px")
|
|
197
|
+
}), {
|
|
198
|
+
role: "presentation"
|
|
199
|
+
}), /*#__PURE__*/_react["default"].createElement("tbody", null, weeks.map(function (week, i) {
|
|
200
|
+
return /*#__PURE__*/_react["default"].createElement(_CalendarWeek["default"], {
|
|
201
|
+
key: i
|
|
202
|
+
}, week.map(function (day, dayOfWeek) {
|
|
203
|
+
return renderCalendarDay({
|
|
204
|
+
key: dayOfWeek,
|
|
205
|
+
day: day,
|
|
206
|
+
daySize: daySize,
|
|
207
|
+
isOutsideDay: !day || day.month() !== month.month(),
|
|
208
|
+
tabIndex: isVisible && (0, _isSameDay["default"])(day, focusedDate) ? 0 : -1,
|
|
209
|
+
isFocused: isFocused,
|
|
210
|
+
onDayMouseEnter: onDayMouseEnter,
|
|
211
|
+
onDayMouseLeave: onDayMouseLeave,
|
|
212
|
+
onDayClick: onDayClick,
|
|
213
|
+
renderDayContents: renderDayContents,
|
|
214
|
+
phrases: phrases,
|
|
215
|
+
modifiers: modifiers[(0, _toISODateString["default"])(day)],
|
|
216
|
+
ariaLabelFormat: dayAriaLabelFormat
|
|
217
|
+
});
|
|
218
|
+
}));
|
|
219
|
+
}))));
|
|
220
|
+
};
|
|
221
|
+
return CalendarMonth;
|
|
222
|
+
}(_react["default"].PureComponent || _react["default"].Component, !_react["default"].PureComponent && "shouldComponentUpdate");
|
|
223
|
+
CalendarMonth.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
224
|
+
CalendarMonth.defaultProps = defaultProps;
|
|
225
|
+
var _default = exports["default"] = (0, _reactWithStyles.withStyles)(function (_ref3) {
|
|
226
|
+
var _ref3$reactDates = _ref3.reactDates,
|
|
227
|
+
color = _ref3$reactDates.color,
|
|
228
|
+
font = _ref3$reactDates.font,
|
|
229
|
+
spacing = _ref3$reactDates.spacing;
|
|
230
|
+
return {
|
|
231
|
+
CalendarMonth: {
|
|
232
|
+
background: color.background,
|
|
233
|
+
textAlign: 'center',
|
|
234
|
+
verticalAlign: 'top',
|
|
235
|
+
userSelect: 'none'
|
|
236
|
+
},
|
|
237
|
+
CalendarMonth_table: {
|
|
238
|
+
borderCollapse: 'collapse',
|
|
239
|
+
borderSpacing: 0
|
|
240
|
+
},
|
|
241
|
+
CalendarMonth_verticalSpacing: {
|
|
242
|
+
borderCollapse: 'separate'
|
|
243
|
+
},
|
|
244
|
+
CalendarMonth_caption: {
|
|
245
|
+
color: color.text,
|
|
246
|
+
fontSize: font.captionSize,
|
|
247
|
+
textAlign: 'center',
|
|
248
|
+
paddingTop: spacing.captionPaddingTop,
|
|
249
|
+
paddingBottom: spacing.captionPaddingBottom,
|
|
250
|
+
captionSide: 'initial'
|
|
251
|
+
},
|
|
252
|
+
CalendarMonth_caption__verticalScrollable: {
|
|
253
|
+
paddingTop: 12,
|
|
254
|
+
paddingBottom: 7
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}, {
|
|
258
|
+
pureComponent: typeof _react["default"].PureComponent !== 'undefined'
|
|
259
|
+
})(CalendarMonth);
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _enzymeShallowEqual = _interopRequireDefault(require("enzyme-shallow-equal"));
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
11
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _reactMomentProptypes = _interopRequireDefault(require("react-moment-proptypes"));
|
|
15
|
+
var _airbnbPropTypes = require("airbnb-prop-types");
|
|
16
|
+
var _reactWithStyles = require("react-with-styles");
|
|
17
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
18
|
+
var _consolidatedEvents = require("consolidated-events");
|
|
19
|
+
var _defaultPhrases = require("../defaultPhrases");
|
|
20
|
+
var _getPhrasePropTypes = _interopRequireDefault(require("../utils/getPhrasePropTypes"));
|
|
21
|
+
var _noflip = _interopRequireDefault(require("../utils/noflip"));
|
|
22
|
+
var _CalendarMonth = _interopRequireDefault(require("./CalendarMonth"));
|
|
23
|
+
var _isTransitionEndSupported = _interopRequireDefault(require("../utils/isTransitionEndSupported"));
|
|
24
|
+
var _getTransformStyles = _interopRequireDefault(require("../utils/getTransformStyles"));
|
|
25
|
+
var _getCalendarMonthWidth = _interopRequireDefault(require("../utils/getCalendarMonthWidth"));
|
|
26
|
+
var _toISOMonthString = _interopRequireDefault(require("../utils/toISOMonthString"));
|
|
27
|
+
var _isPrevMonth = _interopRequireDefault(require("../utils/isPrevMonth"));
|
|
28
|
+
var _isNextMonth = _interopRequireDefault(require("../utils/isNextMonth"));
|
|
29
|
+
var _ModifiersShape = _interopRequireDefault(require("../shapes/ModifiersShape"));
|
|
30
|
+
var _ScrollableOrientationShape = _interopRequireDefault(require("../shapes/ScrollableOrientationShape"));
|
|
31
|
+
var _DayOfWeekShape = _interopRequireDefault(require("../shapes/DayOfWeekShape"));
|
|
32
|
+
var _constants = require("../constants");
|
|
33
|
+
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; }
|
|
34
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
35
|
+
var propTypes = process.env.NODE_ENV !== "production" ? (0, _airbnbPropTypes.forbidExtraProps)(_objectSpread(_objectSpread({}, _reactWithStyles.withStylesPropTypes), {}, {
|
|
36
|
+
enableOutsideDays: _propTypes["default"].bool,
|
|
37
|
+
firstVisibleMonthIndex: _propTypes["default"].number,
|
|
38
|
+
horizontalMonthPadding: _airbnbPropTypes.nonNegativeInteger,
|
|
39
|
+
initialMonth: _reactMomentProptypes["default"].momentObj,
|
|
40
|
+
isAnimating: _propTypes["default"].bool,
|
|
41
|
+
numberOfMonths: _propTypes["default"].number,
|
|
42
|
+
modifiers: _propTypes["default"].objectOf(_propTypes["default"].objectOf(_ModifiersShape["default"])),
|
|
43
|
+
orientation: _ScrollableOrientationShape["default"],
|
|
44
|
+
onDayClick: _propTypes["default"].func,
|
|
45
|
+
onDayMouseEnter: _propTypes["default"].func,
|
|
46
|
+
onDayMouseLeave: _propTypes["default"].func,
|
|
47
|
+
onMonthTransitionEnd: _propTypes["default"].func,
|
|
48
|
+
onMonthChange: _propTypes["default"].func,
|
|
49
|
+
onYearChange: _propTypes["default"].func,
|
|
50
|
+
renderMonthText: (0, _airbnbPropTypes.mutuallyExclusiveProps)(_propTypes["default"].func, 'renderMonthText', 'renderMonthElement'),
|
|
51
|
+
renderCalendarDay: _propTypes["default"].func,
|
|
52
|
+
renderDayContents: _propTypes["default"].func,
|
|
53
|
+
translationValue: _propTypes["default"].number,
|
|
54
|
+
renderMonthElement: (0, _airbnbPropTypes.mutuallyExclusiveProps)(_propTypes["default"].func, 'renderMonthText', 'renderMonthElement'),
|
|
55
|
+
daySize: _airbnbPropTypes.nonNegativeInteger,
|
|
56
|
+
focusedDate: _reactMomentProptypes["default"].momentObj,
|
|
57
|
+
// indicates focusable day
|
|
58
|
+
isFocused: _propTypes["default"].bool,
|
|
59
|
+
// indicates whether or not to move focus to focusable day
|
|
60
|
+
firstDayOfWeek: _DayOfWeekShape["default"],
|
|
61
|
+
setMonthTitleHeight: _propTypes["default"].func,
|
|
62
|
+
isRTL: _propTypes["default"].bool,
|
|
63
|
+
transitionDuration: _airbnbPropTypes.nonNegativeInteger,
|
|
64
|
+
verticalBorderSpacing: _airbnbPropTypes.nonNegativeInteger,
|
|
65
|
+
// i18n
|
|
66
|
+
monthFormat: _propTypes["default"].string,
|
|
67
|
+
phrases: _propTypes["default"].shape((0, _getPhrasePropTypes["default"])(_defaultPhrases.CalendarDayPhrases)),
|
|
68
|
+
dayAriaLabelFormat: _propTypes["default"].string
|
|
69
|
+
})) : {};
|
|
70
|
+
var defaultProps = {
|
|
71
|
+
enableOutsideDays: false,
|
|
72
|
+
firstVisibleMonthIndex: 0,
|
|
73
|
+
horizontalMonthPadding: 13,
|
|
74
|
+
initialMonth: (0, _moment["default"])(),
|
|
75
|
+
isAnimating: false,
|
|
76
|
+
numberOfMonths: 1,
|
|
77
|
+
modifiers: {},
|
|
78
|
+
orientation: _constants.HORIZONTAL_ORIENTATION,
|
|
79
|
+
onDayClick: function onDayClick() {},
|
|
80
|
+
onDayMouseEnter: function onDayMouseEnter() {},
|
|
81
|
+
onDayMouseLeave: function onDayMouseLeave() {},
|
|
82
|
+
onMonthChange: function onMonthChange() {},
|
|
83
|
+
onYearChange: function onYearChange() {},
|
|
84
|
+
onMonthTransitionEnd: function onMonthTransitionEnd() {},
|
|
85
|
+
renderMonthText: null,
|
|
86
|
+
renderCalendarDay: undefined,
|
|
87
|
+
renderDayContents: null,
|
|
88
|
+
translationValue: null,
|
|
89
|
+
renderMonthElement: null,
|
|
90
|
+
daySize: _constants.DAY_SIZE,
|
|
91
|
+
focusedDate: null,
|
|
92
|
+
isFocused: false,
|
|
93
|
+
firstDayOfWeek: null,
|
|
94
|
+
setMonthTitleHeight: null,
|
|
95
|
+
isRTL: false,
|
|
96
|
+
transitionDuration: 200,
|
|
97
|
+
verticalBorderSpacing: undefined,
|
|
98
|
+
// i18n
|
|
99
|
+
monthFormat: 'MMMM YYYY',
|
|
100
|
+
// english locale
|
|
101
|
+
phrases: _defaultPhrases.CalendarDayPhrases,
|
|
102
|
+
dayAriaLabelFormat: undefined
|
|
103
|
+
};
|
|
104
|
+
function getMonths(initialMonth, numberOfMonths, withoutTransitionMonths) {
|
|
105
|
+
var month = initialMonth.clone();
|
|
106
|
+
if (!withoutTransitionMonths) month = month.subtract(1, 'month');
|
|
107
|
+
var months = [];
|
|
108
|
+
for (var i = 0; i < (withoutTransitionMonths ? numberOfMonths : numberOfMonths + 2); i += 1) {
|
|
109
|
+
months.push(month);
|
|
110
|
+
month = month.clone().add(1, 'month');
|
|
111
|
+
}
|
|
112
|
+
return months;
|
|
113
|
+
}
|
|
114
|
+
var CalendarMonthGrid = /*#__PURE__*/function (_ref2, _ref) {
|
|
115
|
+
function CalendarMonthGrid(props) {
|
|
116
|
+
var _this;
|
|
117
|
+
_this = _ref2.call(this, props) || this;
|
|
118
|
+
var withoutTransitionMonths = props.orientation === _constants.VERTICAL_SCROLLABLE;
|
|
119
|
+
_this.state = {
|
|
120
|
+
months: getMonths(props.initialMonth, props.numberOfMonths, withoutTransitionMonths),
|
|
121
|
+
initialMonth: props.initialMonth,
|
|
122
|
+
numberOfMonths: props.numberOfMonths,
|
|
123
|
+
locale: _moment["default"].locale()
|
|
124
|
+
};
|
|
125
|
+
_this.isTransitionEndSupported = (0, _isTransitionEndSupported["default"])();
|
|
126
|
+
_this.onTransitionEnd = _this.onTransitionEnd.bind(_this);
|
|
127
|
+
_this.setContainerRef = _this.setContainerRef.bind(_this);
|
|
128
|
+
_this.onMonthSelect = _this.onMonthSelect.bind(_this);
|
|
129
|
+
_this.onYearSelect = _this.onYearSelect.bind(_this);
|
|
130
|
+
return _this;
|
|
131
|
+
}
|
|
132
|
+
(0, _inheritsLoose2["default"])(CalendarMonthGrid, _ref2);
|
|
133
|
+
var _proto = CalendarMonthGrid.prototype;
|
|
134
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
135
|
+
return !(0, _enzymeShallowEqual["default"])(this.props, nextProps) || !(0, _enzymeShallowEqual["default"])(this.state, nextState);
|
|
136
|
+
};
|
|
137
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
138
|
+
this.removeEventListener = (0, _consolidatedEvents.addEventListener)(this.container, 'transitionend', this.onTransitionEnd);
|
|
139
|
+
};
|
|
140
|
+
CalendarMonthGrid.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
141
|
+
var initialMonth = props.initialMonth,
|
|
142
|
+
numberOfMonths = props.numberOfMonths,
|
|
143
|
+
orientation = props.orientation;
|
|
144
|
+
var months = state.months,
|
|
145
|
+
prevInitialMonth = state.initialMonth,
|
|
146
|
+
prevNumberOfMonths = state.numberOfMonths,
|
|
147
|
+
prevLocale = state.locale;
|
|
148
|
+
var hasMonthChanged = !prevInitialMonth.isSame(initialMonth, 'month');
|
|
149
|
+
var hasNumberOfMonthsChanged = prevNumberOfMonths !== numberOfMonths;
|
|
150
|
+
var newMonths = months;
|
|
151
|
+
if (hasMonthChanged || hasNumberOfMonthsChanged) {
|
|
152
|
+
if (hasMonthChanged && !hasNumberOfMonthsChanged) {
|
|
153
|
+
if ((0, _isNextMonth["default"])(prevInitialMonth, initialMonth)) {
|
|
154
|
+
newMonths = months.slice(1);
|
|
155
|
+
newMonths.push(months[months.length - 1].clone().add(1, 'month'));
|
|
156
|
+
} else if ((0, _isPrevMonth["default"])(prevInitialMonth, initialMonth)) {
|
|
157
|
+
newMonths = months.slice(0, months.length - 1);
|
|
158
|
+
newMonths.unshift(months[0].clone().subtract(1, 'month'));
|
|
159
|
+
} else {
|
|
160
|
+
var withoutTransitionMonths = orientation === _constants.VERTICAL_SCROLLABLE;
|
|
161
|
+
newMonths = getMonths(initialMonth, numberOfMonths, withoutTransitionMonths);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (hasNumberOfMonthsChanged) {
|
|
165
|
+
var _withoutTransitionMonths = orientation === _constants.VERTICAL_SCROLLABLE;
|
|
166
|
+
newMonths = getMonths(initialMonth, numberOfMonths, _withoutTransitionMonths);
|
|
167
|
+
}
|
|
168
|
+
var momentLocale = _moment["default"].locale();
|
|
169
|
+
var locale = prevLocale;
|
|
170
|
+
if (locale !== momentLocale) {
|
|
171
|
+
locale = momentLocale;
|
|
172
|
+
newMonths = newMonths.map(function (m) {
|
|
173
|
+
return m.locale(locale);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
months: newMonths,
|
|
178
|
+
initialMonth: initialMonth,
|
|
179
|
+
numberOfMonths: numberOfMonths,
|
|
180
|
+
locale: locale
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
};
|
|
185
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
186
|
+
var _this$props = this.props,
|
|
187
|
+
isAnimating = _this$props.isAnimating,
|
|
188
|
+
transitionDuration = _this$props.transitionDuration,
|
|
189
|
+
onMonthTransitionEnd = _this$props.onMonthTransitionEnd;
|
|
190
|
+
|
|
191
|
+
// For IE9, immediately call onMonthTransitionEnd instead of
|
|
192
|
+
// waiting for the animation to complete. Similarly, if transitionDuration
|
|
193
|
+
// is set to 0, also immediately invoke the onMonthTransitionEnd callback
|
|
194
|
+
if ((!this.isTransitionEndSupported || !transitionDuration) && isAnimating) {
|
|
195
|
+
onMonthTransitionEnd();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
199
|
+
if (this.removeEventListener) this.removeEventListener();
|
|
200
|
+
};
|
|
201
|
+
_proto.onTransitionEnd = function onTransitionEnd() {
|
|
202
|
+
var onMonthTransitionEnd = this.props.onMonthTransitionEnd;
|
|
203
|
+
onMonthTransitionEnd();
|
|
204
|
+
};
|
|
205
|
+
_proto.onMonthSelect = function onMonthSelect(currentMonth, newMonthVal) {
|
|
206
|
+
var newMonth = currentMonth.clone();
|
|
207
|
+
var _this$props2 = this.props,
|
|
208
|
+
onMonthChange = _this$props2.onMonthChange,
|
|
209
|
+
orientation = _this$props2.orientation;
|
|
210
|
+
var months = this.state.months;
|
|
211
|
+
var withoutTransitionMonths = orientation === _constants.VERTICAL_SCROLLABLE;
|
|
212
|
+
var initialMonthSubtraction = months.indexOf(currentMonth);
|
|
213
|
+
if (!withoutTransitionMonths) {
|
|
214
|
+
initialMonthSubtraction -= 1;
|
|
215
|
+
}
|
|
216
|
+
newMonth.set('month', newMonthVal).subtract(initialMonthSubtraction, 'months');
|
|
217
|
+
onMonthChange(newMonth);
|
|
218
|
+
};
|
|
219
|
+
_proto.onYearSelect = function onYearSelect(currentMonth, newYearVal) {
|
|
220
|
+
var newMonth = currentMonth.clone();
|
|
221
|
+
var _this$props3 = this.props,
|
|
222
|
+
onYearChange = _this$props3.onYearChange,
|
|
223
|
+
orientation = _this$props3.orientation;
|
|
224
|
+
var months = this.state.months;
|
|
225
|
+
var withoutTransitionMonths = orientation === _constants.VERTICAL_SCROLLABLE;
|
|
226
|
+
var initialMonthSubtraction = months.indexOf(currentMonth);
|
|
227
|
+
if (!withoutTransitionMonths) {
|
|
228
|
+
initialMonthSubtraction -= 1;
|
|
229
|
+
}
|
|
230
|
+
newMonth.set('year', newYearVal).subtract(initialMonthSubtraction, 'months');
|
|
231
|
+
onYearChange(newMonth);
|
|
232
|
+
};
|
|
233
|
+
_proto.setContainerRef = function setContainerRef(ref) {
|
|
234
|
+
this.container = ref;
|
|
235
|
+
};
|
|
236
|
+
_proto.render = function render() {
|
|
237
|
+
var _this2 = this;
|
|
238
|
+
var _this$props4 = this.props,
|
|
239
|
+
enableOutsideDays = _this$props4.enableOutsideDays,
|
|
240
|
+
firstVisibleMonthIndex = _this$props4.firstVisibleMonthIndex,
|
|
241
|
+
horizontalMonthPadding = _this$props4.horizontalMonthPadding,
|
|
242
|
+
isAnimating = _this$props4.isAnimating,
|
|
243
|
+
modifiers = _this$props4.modifiers,
|
|
244
|
+
numberOfMonths = _this$props4.numberOfMonths,
|
|
245
|
+
monthFormat = _this$props4.monthFormat,
|
|
246
|
+
orientation = _this$props4.orientation,
|
|
247
|
+
translationValue = _this$props4.translationValue,
|
|
248
|
+
daySize = _this$props4.daySize,
|
|
249
|
+
onDayMouseEnter = _this$props4.onDayMouseEnter,
|
|
250
|
+
onDayMouseLeave = _this$props4.onDayMouseLeave,
|
|
251
|
+
onDayClick = _this$props4.onDayClick,
|
|
252
|
+
renderMonthText = _this$props4.renderMonthText,
|
|
253
|
+
renderCalendarDay = _this$props4.renderCalendarDay,
|
|
254
|
+
renderDayContents = _this$props4.renderDayContents,
|
|
255
|
+
renderMonthElement = _this$props4.renderMonthElement,
|
|
256
|
+
onMonthTransitionEnd = _this$props4.onMonthTransitionEnd,
|
|
257
|
+
firstDayOfWeek = _this$props4.firstDayOfWeek,
|
|
258
|
+
focusedDate = _this$props4.focusedDate,
|
|
259
|
+
isFocused = _this$props4.isFocused,
|
|
260
|
+
isRTL = _this$props4.isRTL,
|
|
261
|
+
css = _this$props4.css,
|
|
262
|
+
styles = _this$props4.styles,
|
|
263
|
+
phrases = _this$props4.phrases,
|
|
264
|
+
dayAriaLabelFormat = _this$props4.dayAriaLabelFormat,
|
|
265
|
+
transitionDuration = _this$props4.transitionDuration,
|
|
266
|
+
verticalBorderSpacing = _this$props4.verticalBorderSpacing,
|
|
267
|
+
setMonthTitleHeight = _this$props4.setMonthTitleHeight;
|
|
268
|
+
var months = this.state.months;
|
|
269
|
+
var isVertical = orientation === _constants.VERTICAL_ORIENTATION;
|
|
270
|
+
var isVerticalScrollable = orientation === _constants.VERTICAL_SCROLLABLE;
|
|
271
|
+
var isHorizontal = orientation === _constants.HORIZONTAL_ORIENTATION;
|
|
272
|
+
var calendarMonthWidth = (0, _getCalendarMonthWidth["default"])(daySize, horizontalMonthPadding);
|
|
273
|
+
var width = isVertical || isVerticalScrollable ? calendarMonthWidth : (numberOfMonths + 2) * calendarMonthWidth;
|
|
274
|
+
var transformType = isVertical || isVerticalScrollable ? 'translateY' : 'translateX';
|
|
275
|
+
var transformValue = "".concat(transformType, "(").concat(translationValue, "px)");
|
|
276
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, css(styles.CalendarMonthGrid, isHorizontal && styles.CalendarMonthGrid__horizontal, isVertical && styles.CalendarMonthGrid__vertical, isVerticalScrollable && styles.CalendarMonthGrid__vertical_scrollable, isAnimating && styles.CalendarMonthGrid__animating, isAnimating && transitionDuration && {
|
|
277
|
+
transition: "transform ".concat(transitionDuration, "ms ease-in-out 0.1s")
|
|
278
|
+
}, _objectSpread(_objectSpread({}, (0, _getTransformStyles["default"])(transformValue)), {}, {
|
|
279
|
+
width: width
|
|
280
|
+
})), {
|
|
281
|
+
ref: this.setContainerRef,
|
|
282
|
+
onTransitionEnd: onMonthTransitionEnd
|
|
283
|
+
}), months.map(function (month, i) {
|
|
284
|
+
var isVisible = i >= firstVisibleMonthIndex && i < firstVisibleMonthIndex + numberOfMonths;
|
|
285
|
+
var hideForAnimation = i === 0 && !isVisible;
|
|
286
|
+
var showForAnimation = i === 0 && isAnimating && isVisible;
|
|
287
|
+
var monthString = (0, _toISOMonthString["default"])(month);
|
|
288
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
289
|
+
key: monthString
|
|
290
|
+
}, css(isHorizontal && styles.CalendarMonthGrid_month__horizontal, hideForAnimation && styles.CalendarMonthGrid_month__hideForAnimation, showForAnimation && !isVertical && !isRTL && {
|
|
291
|
+
position: 'absolute',
|
|
292
|
+
left: -calendarMonthWidth
|
|
293
|
+
}, showForAnimation && !isVertical && isRTL && {
|
|
294
|
+
position: 'absolute',
|
|
295
|
+
right: 0
|
|
296
|
+
}, showForAnimation && isVertical && {
|
|
297
|
+
position: 'absolute',
|
|
298
|
+
top: -translationValue
|
|
299
|
+
}, !isVisible && !isAnimating && styles.CalendarMonthGrid_month__hidden)), /*#__PURE__*/_react["default"].createElement(_CalendarMonth["default"], {
|
|
300
|
+
month: month,
|
|
301
|
+
isVisible: isVisible,
|
|
302
|
+
enableOutsideDays: enableOutsideDays,
|
|
303
|
+
modifiers: modifiers[monthString],
|
|
304
|
+
monthFormat: monthFormat,
|
|
305
|
+
orientation: orientation,
|
|
306
|
+
onDayMouseEnter: onDayMouseEnter,
|
|
307
|
+
onDayMouseLeave: onDayMouseLeave,
|
|
308
|
+
onDayClick: onDayClick,
|
|
309
|
+
onMonthSelect: _this2.onMonthSelect,
|
|
310
|
+
onYearSelect: _this2.onYearSelect,
|
|
311
|
+
renderMonthText: renderMonthText,
|
|
312
|
+
renderCalendarDay: renderCalendarDay,
|
|
313
|
+
renderDayContents: renderDayContents,
|
|
314
|
+
renderMonthElement: renderMonthElement,
|
|
315
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
316
|
+
daySize: daySize,
|
|
317
|
+
focusedDate: isVisible ? focusedDate : null,
|
|
318
|
+
isFocused: isFocused,
|
|
319
|
+
phrases: phrases,
|
|
320
|
+
setMonthTitleHeight: setMonthTitleHeight,
|
|
321
|
+
dayAriaLabelFormat: dayAriaLabelFormat,
|
|
322
|
+
verticalBorderSpacing: verticalBorderSpacing,
|
|
323
|
+
horizontalMonthPadding: horizontalMonthPadding
|
|
324
|
+
}));
|
|
325
|
+
}));
|
|
326
|
+
};
|
|
327
|
+
return CalendarMonthGrid;
|
|
328
|
+
}(_react["default"].PureComponent || _react["default"].Component, !_react["default"].PureComponent && "shouldComponentUpdate");
|
|
329
|
+
CalendarMonthGrid.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
330
|
+
CalendarMonthGrid.defaultProps = defaultProps;
|
|
331
|
+
var _default = exports["default"] = (0, _reactWithStyles.withStyles)(function (_ref3) {
|
|
332
|
+
var _ref3$reactDates = _ref3.reactDates,
|
|
333
|
+
color = _ref3$reactDates.color,
|
|
334
|
+
spacing = _ref3$reactDates.spacing,
|
|
335
|
+
zIndex = _ref3$reactDates.zIndex;
|
|
336
|
+
return {
|
|
337
|
+
CalendarMonthGrid: {
|
|
338
|
+
background: color.background,
|
|
339
|
+
textAlign: (0, _noflip["default"])('left'),
|
|
340
|
+
zIndex: zIndex
|
|
341
|
+
},
|
|
342
|
+
CalendarMonthGrid__animating: {
|
|
343
|
+
zIndex: zIndex + 1
|
|
344
|
+
},
|
|
345
|
+
CalendarMonthGrid__horizontal: {
|
|
346
|
+
position: 'absolute',
|
|
347
|
+
left: (0, _noflip["default"])(spacing.dayPickerHorizontalPadding)
|
|
348
|
+
},
|
|
349
|
+
CalendarMonthGrid__vertical: {
|
|
350
|
+
margin: '0 auto'
|
|
351
|
+
},
|
|
352
|
+
CalendarMonthGrid__vertical_scrollable: {
|
|
353
|
+
margin: '0 auto'
|
|
354
|
+
},
|
|
355
|
+
CalendarMonthGrid_month__horizontal: {
|
|
356
|
+
display: 'inline-block',
|
|
357
|
+
verticalAlign: 'top',
|
|
358
|
+
minHeight: '100%'
|
|
359
|
+
},
|
|
360
|
+
CalendarMonthGrid_month__hideForAnimation: {
|
|
361
|
+
position: 'absolute',
|
|
362
|
+
zIndex: zIndex - 1,
|
|
363
|
+
opacity: 0,
|
|
364
|
+
pointerEvents: 'none'
|
|
365
|
+
},
|
|
366
|
+
CalendarMonthGrid_month__hidden: {
|
|
367
|
+
visibility: 'hidden'
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}, {
|
|
371
|
+
pureComponent: typeof _react["default"].PureComponent !== 'undefined'
|
|
372
|
+
})(CalendarMonthGrid);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = CalendarWeek;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _airbnbPropTypes = require("airbnb-prop-types");
|
|
11
|
+
var propTypes = process.env.NODE_ENV !== "production" ? (0, _airbnbPropTypes.forbidExtraProps)({
|
|
12
|
+
children: _propTypes["default"].node.isRequired
|
|
13
|
+
}) : {};
|
|
14
|
+
function CalendarWeek(_ref) {
|
|
15
|
+
var children = _ref.children;
|
|
16
|
+
return /*#__PURE__*/_react["default"].createElement("tr", null, children);
|
|
17
|
+
}
|
|
18
|
+
CalendarWeek.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var ChevronDown = function ChevronDown(props) {
|
|
10
|
+
return /*#__PURE__*/_react["default"].createElement("svg", props, /*#__PURE__*/_react["default"].createElement("path", {
|
|
11
|
+
d: "M968 289L514 741c-11 11-21 11-32 0L29 289c-4-5-6-11-6-16 0-13 10-23 23-23 6 0 11 2 15 7l437 436 438-436c4-5 9-7 16-7 6 0 11 2 16 7 9 10 9 21 0 32z"
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
ChevronDown.defaultProps = {
|
|
15
|
+
focusable: "false",
|
|
16
|
+
viewBox: "0 0 1000 1000"
|
|
17
|
+
};
|
|
18
|
+
var _default = exports["default"] = ChevronDown;
|