@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,321 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _readOnlyError from "@babel/runtime/helpers/esm/readOnlyError";
|
|
3
|
+
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
import shallowEqual from "enzyme-shallow-equal";
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import momentPropTypes from 'react-moment-proptypes';
|
|
11
|
+
import { forbidExtraProps, nonNegativeInteger } from 'airbnb-prop-types';
|
|
12
|
+
import { withStyles, withStylesPropTypes } from 'react-with-styles';
|
|
13
|
+
import moment from 'moment';
|
|
14
|
+
import raf from 'raf';
|
|
15
|
+
import { CalendarDayPhrases } from '../defaultPhrases';
|
|
16
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
17
|
+
import getCalendarDaySettings from '../utils/getCalendarDaySettings';
|
|
18
|
+
import ModifiersShape from '../shapes/ModifiersShape';
|
|
19
|
+
import { DAY_SIZE } from '../constants';
|
|
20
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectSpread(_objectSpread({}, withStylesPropTypes), {}, {
|
|
21
|
+
day: momentPropTypes.momentObj,
|
|
22
|
+
daySize: nonNegativeInteger,
|
|
23
|
+
isOutsideDay: PropTypes.bool,
|
|
24
|
+
modifiers: ModifiersShape,
|
|
25
|
+
isFocused: PropTypes.bool,
|
|
26
|
+
tabIndex: PropTypes.oneOf([0, -1]),
|
|
27
|
+
onDayClick: PropTypes.func,
|
|
28
|
+
onDayMouseEnter: PropTypes.func,
|
|
29
|
+
onDayMouseLeave: PropTypes.func,
|
|
30
|
+
renderDayContents: PropTypes.func,
|
|
31
|
+
ariaLabelFormat: PropTypes.string,
|
|
32
|
+
// internationalization
|
|
33
|
+
phrases: PropTypes.shape(getPhrasePropTypes(CalendarDayPhrases))
|
|
34
|
+
})) : {};
|
|
35
|
+
var defaultProps = {
|
|
36
|
+
day: moment(),
|
|
37
|
+
daySize: DAY_SIZE,
|
|
38
|
+
isOutsideDay: false,
|
|
39
|
+
modifiers: new Set(),
|
|
40
|
+
isFocused: false,
|
|
41
|
+
tabIndex: -1,
|
|
42
|
+
onDayClick: function onDayClick() {},
|
|
43
|
+
onDayMouseEnter: function onDayMouseEnter() {},
|
|
44
|
+
onDayMouseLeave: function onDayMouseLeave() {},
|
|
45
|
+
renderDayContents: null,
|
|
46
|
+
ariaLabelFormat: 'dddd, LL',
|
|
47
|
+
// internationalization
|
|
48
|
+
phrases: CalendarDayPhrases
|
|
49
|
+
};
|
|
50
|
+
var CalendarDay = /*#__PURE__*/function (_ref2, _ref) {
|
|
51
|
+
function CalendarDay() {
|
|
52
|
+
var _this;
|
|
53
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
54
|
+
args[_key] = arguments[_key];
|
|
55
|
+
}
|
|
56
|
+
_this = _ref2.call.apply(_ref2, [this].concat(args)) || this;
|
|
57
|
+
_this.setButtonRef = _this.setButtonRef.bind(_this);
|
|
58
|
+
return _this;
|
|
59
|
+
}
|
|
60
|
+
_inheritsLoose(CalendarDay, _ref2);
|
|
61
|
+
var _proto = CalendarDay.prototype;
|
|
62
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
63
|
+
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
64
|
+
};
|
|
65
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
66
|
+
var _this2 = this;
|
|
67
|
+
var _this$props = this.props,
|
|
68
|
+
isFocused = _this$props.isFocused,
|
|
69
|
+
tabIndex = _this$props.tabIndex;
|
|
70
|
+
if (tabIndex === 0) {
|
|
71
|
+
if (isFocused || tabIndex !== prevProps.tabIndex) {
|
|
72
|
+
raf(function () {
|
|
73
|
+
if (_this2.buttonRef) {
|
|
74
|
+
_this2.buttonRef.focus();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
_proto.onDayClick = function onDayClick(day, e) {
|
|
81
|
+
var onDayClick = this.props.onDayClick;
|
|
82
|
+
onDayClick(day, e);
|
|
83
|
+
};
|
|
84
|
+
_proto.onDayMouseEnter = function onDayMouseEnter(day, e) {
|
|
85
|
+
var onDayMouseEnter = this.props.onDayMouseEnter;
|
|
86
|
+
onDayMouseEnter(day, e);
|
|
87
|
+
};
|
|
88
|
+
_proto.onDayMouseLeave = function onDayMouseLeave(day, e) {
|
|
89
|
+
var onDayMouseLeave = this.props.onDayMouseLeave;
|
|
90
|
+
onDayMouseLeave(day, e);
|
|
91
|
+
};
|
|
92
|
+
_proto.onKeyDown = function onKeyDown(day, e) {
|
|
93
|
+
var onDayClick = this.props.onDayClick;
|
|
94
|
+
var key = e.key;
|
|
95
|
+
if (key === 'Enter' || key === ' ') {
|
|
96
|
+
onDayClick(day, e);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
_proto.setButtonRef = function setButtonRef(ref) {
|
|
100
|
+
this.buttonRef = ref;
|
|
101
|
+
};
|
|
102
|
+
_proto.render = function render() {
|
|
103
|
+
var _this3 = this;
|
|
104
|
+
var _this$props2 = this.props,
|
|
105
|
+
day = _this$props2.day,
|
|
106
|
+
ariaLabelFormat = _this$props2.ariaLabelFormat,
|
|
107
|
+
daySize = _this$props2.daySize,
|
|
108
|
+
isOutsideDay = _this$props2.isOutsideDay,
|
|
109
|
+
modifiers = _this$props2.modifiers,
|
|
110
|
+
renderDayContents = _this$props2.renderDayContents,
|
|
111
|
+
tabIndex = _this$props2.tabIndex,
|
|
112
|
+
css = _this$props2.css,
|
|
113
|
+
styles = _this$props2.styles,
|
|
114
|
+
phrases = _this$props2.phrases;
|
|
115
|
+
|
|
116
|
+
// empty placeholder cell (no day to render); nothing to label
|
|
117
|
+
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
118
|
+
if (!day) return /*#__PURE__*/React.createElement("td", null);
|
|
119
|
+
var _getCalendarDaySettin = getCalendarDaySettings(day, ariaLabelFormat, daySize, modifiers, phrases),
|
|
120
|
+
daySizeStyles = _getCalendarDaySettin.daySizeStyles,
|
|
121
|
+
useDefaultCursor = _getCalendarDaySettin.useDefaultCursor,
|
|
122
|
+
selected = _getCalendarDaySettin.selected,
|
|
123
|
+
hoveredSpan = _getCalendarDaySettin.hoveredSpan,
|
|
124
|
+
isOutsideRange = _getCalendarDaySettin.isOutsideRange,
|
|
125
|
+
ariaLabel = _getCalendarDaySettin.ariaLabel;
|
|
126
|
+
return /*#__PURE__*/React.createElement("td", _extends({}, css(styles.CalendarDay, useDefaultCursor && styles.CalendarDay__defaultCursor, styles.CalendarDay__default, isOutsideDay && styles.CalendarDay__outside, modifiers.has('today') && styles.CalendarDay__today, modifiers.has('first-day-of-week') && styles.CalendarDay__firstDayOfWeek, modifiers.has('last-day-of-week') && styles.CalendarDay__lastDayOfWeek, modifiers.has('hovered-offset') && styles.CalendarDay__hovered_offset, modifiers.has('hovered-start-first-possible-end') && styles.CalendarDay__hovered_start_first_possible_end, modifiers.has('hovered-start-blocked-minimum-nights') && styles.CalendarDay__hovered_start_blocked_min_nights, modifiers.has('highlighted-calendar') && styles.CalendarDay__highlighted_calendar, modifiers.has('blocked-minimum-nights') && styles.CalendarDay__blocked_minimum_nights, modifiers.has('blocked-calendar') && styles.CalendarDay__blocked_calendar, hoveredSpan && styles.CalendarDay__hovered_span, modifiers.has('after-hovered-start') && styles.CalendarDay__after_hovered_start, modifiers.has('selected-span') && styles.CalendarDay__selected_span, modifiers.has('selected-start') && styles.CalendarDay__selected_start, modifiers.has('selected-end') && styles.CalendarDay__selected_end, selected && !modifiers.has('selected-span') && styles.CalendarDay__selected, modifiers.has('before-hovered-end') && styles.CalendarDay__before_hovered_end, modifiers.has('no-selected-start-before-selected-end') && styles.CalendarDay__no_selected_start_before_selected_end, modifiers.has('selected-start-in-hovered-span') && styles.CalendarDay__selected_start_in_hovered_span, modifiers.has('selected-end-in-hovered-span') && styles.CalendarDay__selected_end_in_hovered_span, modifiers.has('selected-start-no-selected-end') && styles.CalendarDay__selected_start_no_selected_end, modifiers.has('selected-end-no-selected-start') && styles.CalendarDay__selected_end_no_selected_start, isOutsideRange && styles.CalendarDay__blocked_out_of_range, daySizeStyles), {
|
|
127
|
+
role: "button" // eslint-disable-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
128
|
+
,
|
|
129
|
+
ref: this.setButtonRef,
|
|
130
|
+
"aria-disabled": modifiers.has('blocked')
|
|
131
|
+
}, modifiers.has('today') ? {
|
|
132
|
+
'aria-current': 'date'
|
|
133
|
+
} : {}, {
|
|
134
|
+
"aria-label": ariaLabel,
|
|
135
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
136
|
+
_this3.onDayMouseEnter(day, e);
|
|
137
|
+
},
|
|
138
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
139
|
+
_this3.onDayMouseLeave(day, e);
|
|
140
|
+
},
|
|
141
|
+
onMouseUp: function onMouseUp(e) {
|
|
142
|
+
e.currentTarget.blur();
|
|
143
|
+
},
|
|
144
|
+
onClick: function onClick(e) {
|
|
145
|
+
_this3.onDayClick(day, e);
|
|
146
|
+
},
|
|
147
|
+
onKeyDown: function onKeyDown(e) {
|
|
148
|
+
_this3.onKeyDown(day, e);
|
|
149
|
+
},
|
|
150
|
+
tabIndex: tabIndex
|
|
151
|
+
}), renderDayContents ? renderDayContents(day, modifiers) : day.format('D'));
|
|
152
|
+
};
|
|
153
|
+
return CalendarDay;
|
|
154
|
+
}(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
|
|
155
|
+
CalendarDay.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
156
|
+
CalendarDay.defaultProps = defaultProps;
|
|
157
|
+
export { CalendarDay as PureCalendarDay };
|
|
158
|
+
export default withStyles(function (_ref3) {
|
|
159
|
+
var _ref3$reactDates = _ref3.reactDates,
|
|
160
|
+
color = _ref3$reactDates.color,
|
|
161
|
+
font = _ref3$reactDates.font;
|
|
162
|
+
return {
|
|
163
|
+
CalendarDay: {
|
|
164
|
+
boxSizing: 'border-box',
|
|
165
|
+
cursor: 'pointer',
|
|
166
|
+
fontSize: font.size,
|
|
167
|
+
textAlign: 'center',
|
|
168
|
+
':active': {
|
|
169
|
+
outline: 0
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
CalendarDay__defaultCursor: {
|
|
173
|
+
cursor: 'default'
|
|
174
|
+
},
|
|
175
|
+
CalendarDay__default: {
|
|
176
|
+
border: "1px solid ".concat(color.core.borderLight),
|
|
177
|
+
color: color.text,
|
|
178
|
+
background: color.background,
|
|
179
|
+
':hover': {
|
|
180
|
+
background: color.core.borderLight,
|
|
181
|
+
border: "1px solid ".concat(color.core.borderLight),
|
|
182
|
+
color: 'inherit'
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
CalendarDay__hovered_offset: {
|
|
186
|
+
background: color.core.borderBright,
|
|
187
|
+
border: "1px double ".concat(color.core.borderLight),
|
|
188
|
+
color: 'inherit'
|
|
189
|
+
},
|
|
190
|
+
CalendarDay__outside: {
|
|
191
|
+
border: 0,
|
|
192
|
+
background: color.outside.backgroundColor,
|
|
193
|
+
color: color.outside.color,
|
|
194
|
+
':hover': {
|
|
195
|
+
border: 0
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
CalendarDay__blocked_minimum_nights: {
|
|
199
|
+
background: color.minimumNights.backgroundColor,
|
|
200
|
+
border: "1px solid ".concat(color.minimumNights.borderColor),
|
|
201
|
+
color: color.minimumNights.color,
|
|
202
|
+
':hover': {
|
|
203
|
+
background: color.minimumNights.backgroundColor_hover,
|
|
204
|
+
color: color.minimumNights.color_active
|
|
205
|
+
},
|
|
206
|
+
':active': {
|
|
207
|
+
background: color.minimumNights.backgroundColor_active,
|
|
208
|
+
color: color.minimumNights.color_active
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
CalendarDay__highlighted_calendar: {
|
|
212
|
+
background: color.highlighted.backgroundColor,
|
|
213
|
+
color: color.highlighted.color,
|
|
214
|
+
':hover': {
|
|
215
|
+
background: color.highlighted.backgroundColor_hover,
|
|
216
|
+
color: color.highlighted.color_active
|
|
217
|
+
},
|
|
218
|
+
':active': {
|
|
219
|
+
background: color.highlighted.backgroundColor_active,
|
|
220
|
+
color: color.highlighted.color_active
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
CalendarDay__selected_span: {
|
|
224
|
+
background: color.selectedSpan.backgroundColor,
|
|
225
|
+
border: "1px double ".concat(color.selectedSpan.borderColor),
|
|
226
|
+
color: color.selectedSpan.color,
|
|
227
|
+
':hover': {
|
|
228
|
+
background: color.selectedSpan.backgroundColor_hover,
|
|
229
|
+
border: "1px double ".concat(color.selectedSpan.borderColor),
|
|
230
|
+
color: color.selectedSpan.color_active
|
|
231
|
+
},
|
|
232
|
+
':active': {
|
|
233
|
+
background: color.selectedSpan.backgroundColor_active,
|
|
234
|
+
border: "1px double ".concat(color.selectedSpan.borderColor),
|
|
235
|
+
color: color.selectedSpan.color_active
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
CalendarDay__selected: {
|
|
239
|
+
background: color.selected.backgroundColor,
|
|
240
|
+
border: "1px double ".concat(color.selected.borderColor),
|
|
241
|
+
color: color.selected.color,
|
|
242
|
+
':hover': {
|
|
243
|
+
background: color.selected.backgroundColor_hover,
|
|
244
|
+
border: "1px double ".concat(color.selected.borderColor),
|
|
245
|
+
color: color.selected.color_active
|
|
246
|
+
},
|
|
247
|
+
':active': {
|
|
248
|
+
background: color.selected.backgroundColor_active,
|
|
249
|
+
border: "1px double ".concat(color.selected.borderColor),
|
|
250
|
+
color: color.selected.color_active
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
CalendarDay__hovered_span: {
|
|
254
|
+
background: color.hoveredSpan.backgroundColor,
|
|
255
|
+
border: "1px double ".concat(color.hoveredSpan.borderColor),
|
|
256
|
+
color: color.hoveredSpan.color,
|
|
257
|
+
':hover': {
|
|
258
|
+
background: color.hoveredSpan.backgroundColor_hover,
|
|
259
|
+
border: "1px double ".concat(color.hoveredSpan.borderColor),
|
|
260
|
+
color: color.hoveredSpan.color_active
|
|
261
|
+
},
|
|
262
|
+
':active': {
|
|
263
|
+
background: color.hoveredSpan.backgroundColor_active,
|
|
264
|
+
border: "1px double ".concat(color.hoveredSpan.borderColor),
|
|
265
|
+
color: color.hoveredSpan.color_active
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
CalendarDay__blocked_calendar: {
|
|
269
|
+
background: color.blocked_calendar.backgroundColor,
|
|
270
|
+
border: "1px solid ".concat(color.blocked_calendar.borderColor),
|
|
271
|
+
color: color.blocked_calendar.color,
|
|
272
|
+
':hover': {
|
|
273
|
+
background: color.blocked_calendar.backgroundColor_hover,
|
|
274
|
+
border: "1px solid ".concat(color.blocked_calendar.borderColor),
|
|
275
|
+
color: color.blocked_calendar.color_active
|
|
276
|
+
},
|
|
277
|
+
':active': {
|
|
278
|
+
background: color.blocked_calendar.backgroundColor_active,
|
|
279
|
+
border: "1px solid ".concat(color.blocked_calendar.borderColor),
|
|
280
|
+
color: color.blocked_calendar.color_active
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
CalendarDay__blocked_out_of_range: {
|
|
284
|
+
background: color.blocked_out_of_range.backgroundColor,
|
|
285
|
+
border: "1px solid ".concat(color.blocked_out_of_range.borderColor),
|
|
286
|
+
color: color.blocked_out_of_range.color,
|
|
287
|
+
':hover': {
|
|
288
|
+
background: color.blocked_out_of_range.backgroundColor_hover,
|
|
289
|
+
border: "1px solid ".concat(color.blocked_out_of_range.borderColor),
|
|
290
|
+
color: color.blocked_out_of_range.color_active
|
|
291
|
+
},
|
|
292
|
+
':active': {
|
|
293
|
+
background: color.blocked_out_of_range.backgroundColor_active,
|
|
294
|
+
border: "1px solid ".concat(color.blocked_out_of_range.borderColor),
|
|
295
|
+
color: color.blocked_out_of_range.color_active
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
CalendarDay__hovered_start_first_possible_end: {
|
|
299
|
+
background: color.core.borderLighter,
|
|
300
|
+
border: "1px double ".concat(color.core.borderLighter)
|
|
301
|
+
},
|
|
302
|
+
CalendarDay__hovered_start_blocked_min_nights: {
|
|
303
|
+
background: color.core.borderLighter,
|
|
304
|
+
border: "1px double ".concat(color.core.borderLight)
|
|
305
|
+
},
|
|
306
|
+
CalendarDay__selected_start: {},
|
|
307
|
+
CalendarDay__selected_end: {},
|
|
308
|
+
CalendarDay__today: {},
|
|
309
|
+
CalendarDay__firstDayOfWeek: {},
|
|
310
|
+
CalendarDay__lastDayOfWeek: {},
|
|
311
|
+
CalendarDay__after_hovered_start: {},
|
|
312
|
+
CalendarDay__before_hovered_end: {},
|
|
313
|
+
CalendarDay__no_selected_start_before_selected_end: {},
|
|
314
|
+
CalendarDay__selected_start_in_hovered_span: {},
|
|
315
|
+
CalendarDay__selected_end_in_hovered_span: {},
|
|
316
|
+
CalendarDay__selected_start_no_selected_end: {},
|
|
317
|
+
CalendarDay__selected_end_no_selected_start: {}
|
|
318
|
+
};
|
|
319
|
+
}, {
|
|
320
|
+
pureComponent: typeof React.PureComponent !== 'undefined'
|
|
321
|
+
})(CalendarDay);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
var CalendarIcon = function CalendarIcon(props) {
|
|
3
|
+
return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("path", {
|
|
4
|
+
d: "m107 1393h241v-241h-241zm295 0h268v-241h-268zm-295-295h241v-268h-241zm295 0h268v-268h-268zm-295-321h241v-241h-241zm616 616h268v-241h-268zm-321-616h268v-241h-268zm643 616h241v-241h-241zm-322-295h268v-268h-268zm-294-723v-241c0-7-3-14-8-19-6-5-12-8-19-8h-54c-7 0-13 3-19 8-5 5-8 12-8 19v241c0 7 3 14 8 19 6 5 12 8 19 8h54c7 0 13-3 19-8 5-5 8-12 8-19zm616 723h241v-268h-241zm-322-321h268v-241h-268zm322 0h241v-241h-241zm27-402v-241c0-7-3-14-8-19-6-5-12-8-19-8h-54c-7 0-13 3-19 8-5 5-8 12-8 19v241c0 7 3 14 8 19 6 5 12 8 19 8h54c7 0 13-3 19-8 5-5 8-12 8-19zm321-54v1072c0 29-11 54-32 75s-46 32-75 32h-1179c-29 0-54-11-75-32s-32-46-32-75v-1072c0-29 11-54 32-75s46-32 75-32h107v-80c0-37 13-68 40-95s57-39 94-39h54c37 0 68 13 95 39 26 26 39 58 39 95v80h321v-80c0-37 13-69 40-95 26-26 57-39 94-39h54c37 0 68 13 94 39s40 58 40 95v80h107c29 0 54 11 75 32s32 46 32 75z"
|
|
5
|
+
}));
|
|
6
|
+
};
|
|
7
|
+
CalendarIcon.defaultProps = {
|
|
8
|
+
focusable: "false",
|
|
9
|
+
viewBox: "0 0 1393.1 1500"
|
|
10
|
+
};
|
|
11
|
+
export default CalendarIcon;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _readOnlyError from "@babel/runtime/helpers/esm/readOnlyError";
|
|
3
|
+
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
import shallowEqual from "enzyme-shallow-equal";
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
/* eslint react/no-array-index-key: 0 */
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import momentPropTypes from 'react-moment-proptypes';
|
|
13
|
+
import { forbidExtraProps, mutuallyExclusiveProps, nonNegativeInteger } from 'airbnb-prop-types';
|
|
14
|
+
import { withStyles, withStylesPropTypes } from 'react-with-styles';
|
|
15
|
+
import moment from 'moment';
|
|
16
|
+
import { CalendarDayPhrases } from '../defaultPhrases';
|
|
17
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
18
|
+
import CalendarWeek from './CalendarWeek';
|
|
19
|
+
import CalendarDay from './CalendarDay';
|
|
20
|
+
import calculateDimension from '../utils/calculateDimension';
|
|
21
|
+
import getCalendarMonthWeeks from '../utils/getCalendarMonthWeeks';
|
|
22
|
+
import isSameDay from '../utils/isSameDay';
|
|
23
|
+
import toISODateString from '../utils/toISODateString';
|
|
24
|
+
import ModifiersShape from '../shapes/ModifiersShape';
|
|
25
|
+
import ScrollableOrientationShape from '../shapes/ScrollableOrientationShape';
|
|
26
|
+
import DayOfWeekShape from '../shapes/DayOfWeekShape';
|
|
27
|
+
import { HORIZONTAL_ORIENTATION, VERTICAL_SCROLLABLE, DAY_SIZE } from '../constants';
|
|
28
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectSpread(_objectSpread({}, withStylesPropTypes), {}, {
|
|
29
|
+
month: momentPropTypes.momentObj,
|
|
30
|
+
horizontalMonthPadding: nonNegativeInteger,
|
|
31
|
+
isVisible: PropTypes.bool,
|
|
32
|
+
enableOutsideDays: PropTypes.bool,
|
|
33
|
+
modifiers: PropTypes.objectOf(ModifiersShape),
|
|
34
|
+
orientation: ScrollableOrientationShape,
|
|
35
|
+
daySize: nonNegativeInteger,
|
|
36
|
+
onDayClick: PropTypes.func,
|
|
37
|
+
onDayMouseEnter: PropTypes.func,
|
|
38
|
+
onDayMouseLeave: PropTypes.func,
|
|
39
|
+
onMonthSelect: PropTypes.func,
|
|
40
|
+
onYearSelect: PropTypes.func,
|
|
41
|
+
renderMonthText: mutuallyExclusiveProps(PropTypes.func, 'renderMonthText', 'renderMonthElement'),
|
|
42
|
+
renderCalendarDay: PropTypes.func,
|
|
43
|
+
renderDayContents: PropTypes.func,
|
|
44
|
+
renderMonthElement: mutuallyExclusiveProps(PropTypes.func, 'renderMonthText', 'renderMonthElement'),
|
|
45
|
+
firstDayOfWeek: DayOfWeekShape,
|
|
46
|
+
setMonthTitleHeight: PropTypes.func,
|
|
47
|
+
verticalBorderSpacing: nonNegativeInteger,
|
|
48
|
+
focusedDate: momentPropTypes.momentObj,
|
|
49
|
+
// indicates focusable day
|
|
50
|
+
isFocused: PropTypes.bool,
|
|
51
|
+
// indicates whether or not to move focus to focusable day
|
|
52
|
+
|
|
53
|
+
// i18n
|
|
54
|
+
monthFormat: PropTypes.string,
|
|
55
|
+
phrases: PropTypes.shape(getPhrasePropTypes(CalendarDayPhrases)),
|
|
56
|
+
dayAriaLabelFormat: PropTypes.string
|
|
57
|
+
})) : {};
|
|
58
|
+
var defaultProps = {
|
|
59
|
+
month: moment(),
|
|
60
|
+
horizontalMonthPadding: 13,
|
|
61
|
+
isVisible: true,
|
|
62
|
+
enableOutsideDays: false,
|
|
63
|
+
modifiers: {},
|
|
64
|
+
orientation: HORIZONTAL_ORIENTATION,
|
|
65
|
+
daySize: DAY_SIZE,
|
|
66
|
+
onDayClick: function onDayClick() {},
|
|
67
|
+
onDayMouseEnter: function onDayMouseEnter() {},
|
|
68
|
+
onDayMouseLeave: function onDayMouseLeave() {},
|
|
69
|
+
onMonthSelect: function onMonthSelect() {},
|
|
70
|
+
onYearSelect: function onYearSelect() {},
|
|
71
|
+
renderMonthText: null,
|
|
72
|
+
renderCalendarDay: function renderCalendarDay(props) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(CalendarDay, props);
|
|
74
|
+
},
|
|
75
|
+
renderDayContents: null,
|
|
76
|
+
renderMonthElement: null,
|
|
77
|
+
firstDayOfWeek: null,
|
|
78
|
+
setMonthTitleHeight: null,
|
|
79
|
+
focusedDate: null,
|
|
80
|
+
isFocused: false,
|
|
81
|
+
// i18n
|
|
82
|
+
monthFormat: 'MMMM YYYY',
|
|
83
|
+
// english locale
|
|
84
|
+
phrases: CalendarDayPhrases,
|
|
85
|
+
dayAriaLabelFormat: undefined,
|
|
86
|
+
verticalBorderSpacing: undefined
|
|
87
|
+
};
|
|
88
|
+
var CalendarMonth = /*#__PURE__*/function (_ref2, _ref) {
|
|
89
|
+
function CalendarMonth(props) {
|
|
90
|
+
var _this;
|
|
91
|
+
_this = _ref2.call(this, props) || this;
|
|
92
|
+
_this.state = {
|
|
93
|
+
month: props.month,
|
|
94
|
+
enableOutsideDays: props.enableOutsideDays,
|
|
95
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
96
|
+
weeks: getCalendarMonthWeeks(props.month, props.enableOutsideDays, props.firstDayOfWeek == null ? moment.localeData().firstDayOfWeek() : props.firstDayOfWeek)
|
|
97
|
+
};
|
|
98
|
+
_this.setCaptionRef = _this.setCaptionRef.bind(_this);
|
|
99
|
+
_this.setMonthTitleHeight = _this.setMonthTitleHeight.bind(_this);
|
|
100
|
+
return _this;
|
|
101
|
+
}
|
|
102
|
+
_inheritsLoose(CalendarMonth, _ref2);
|
|
103
|
+
var _proto = CalendarMonth.prototype;
|
|
104
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
105
|
+
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
106
|
+
};
|
|
107
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
108
|
+
this.queueSetMonthTitleHeight();
|
|
109
|
+
};
|
|
110
|
+
CalendarMonth.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
111
|
+
var month = props.month,
|
|
112
|
+
enableOutsideDays = props.enableOutsideDays,
|
|
113
|
+
firstDayOfWeek = props.firstDayOfWeek;
|
|
114
|
+
var prevMonth = state.month,
|
|
115
|
+
prevEnableOutsideDays = state.enableOutsideDays,
|
|
116
|
+
prevFirstDayOfWeek = state.firstDayOfWeek;
|
|
117
|
+
if (!month.isSame(prevMonth) || enableOutsideDays !== prevEnableOutsideDays || firstDayOfWeek !== prevFirstDayOfWeek) {
|
|
118
|
+
return {
|
|
119
|
+
month: month,
|
|
120
|
+
enableOutsideDays: enableOutsideDays,
|
|
121
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
122
|
+
weeks: getCalendarMonthWeeks(month, enableOutsideDays, firstDayOfWeek == null ? moment.localeData().firstDayOfWeek() : firstDayOfWeek)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
};
|
|
127
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
128
|
+
var setMonthTitleHeight = this.props.setMonthTitleHeight;
|
|
129
|
+
if (prevProps.setMonthTitleHeight === null && setMonthTitleHeight !== null) {
|
|
130
|
+
this.queueSetMonthTitleHeight();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
134
|
+
if (this.setMonthTitleHeightTimeout) {
|
|
135
|
+
clearTimeout(this.setMonthTitleHeightTimeout);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
_proto.setMonthTitleHeight = function setMonthTitleHeight() {
|
|
139
|
+
var setMonthTitleHeight = this.props.setMonthTitleHeight;
|
|
140
|
+
if (setMonthTitleHeight) {
|
|
141
|
+
var captionHeight = calculateDimension(this.captionRef, 'height', true, true);
|
|
142
|
+
setMonthTitleHeight(captionHeight);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
_proto.setCaptionRef = function setCaptionRef(ref) {
|
|
146
|
+
this.captionRef = ref;
|
|
147
|
+
};
|
|
148
|
+
_proto.queueSetMonthTitleHeight = function queueSetMonthTitleHeight() {
|
|
149
|
+
this.setMonthTitleHeightTimeout = window.setTimeout(this.setMonthTitleHeight, 0);
|
|
150
|
+
};
|
|
151
|
+
_proto.render = function render() {
|
|
152
|
+
var _this$props = this.props,
|
|
153
|
+
dayAriaLabelFormat = _this$props.dayAriaLabelFormat,
|
|
154
|
+
daySize = _this$props.daySize,
|
|
155
|
+
focusedDate = _this$props.focusedDate,
|
|
156
|
+
horizontalMonthPadding = _this$props.horizontalMonthPadding,
|
|
157
|
+
isFocused = _this$props.isFocused,
|
|
158
|
+
isVisible = _this$props.isVisible,
|
|
159
|
+
modifiers = _this$props.modifiers,
|
|
160
|
+
month = _this$props.month,
|
|
161
|
+
monthFormat = _this$props.monthFormat,
|
|
162
|
+
onDayClick = _this$props.onDayClick,
|
|
163
|
+
onDayMouseEnter = _this$props.onDayMouseEnter,
|
|
164
|
+
onDayMouseLeave = _this$props.onDayMouseLeave,
|
|
165
|
+
onMonthSelect = _this$props.onMonthSelect,
|
|
166
|
+
onYearSelect = _this$props.onYearSelect,
|
|
167
|
+
orientation = _this$props.orientation,
|
|
168
|
+
phrases = _this$props.phrases,
|
|
169
|
+
renderCalendarDay = _this$props.renderCalendarDay,
|
|
170
|
+
renderDayContents = _this$props.renderDayContents,
|
|
171
|
+
renderMonthElement = _this$props.renderMonthElement,
|
|
172
|
+
renderMonthText = _this$props.renderMonthText,
|
|
173
|
+
css = _this$props.css,
|
|
174
|
+
styles = _this$props.styles,
|
|
175
|
+
verticalBorderSpacing = _this$props.verticalBorderSpacing;
|
|
176
|
+
var weeks = this.state.weeks;
|
|
177
|
+
var monthTitle = renderMonthText ? renderMonthText(month) : month.format(monthFormat);
|
|
178
|
+
var verticalScrollable = orientation === VERTICAL_SCROLLABLE;
|
|
179
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, css(styles.CalendarMonth, {
|
|
180
|
+
padding: "0 ".concat(horizontalMonthPadding, "px")
|
|
181
|
+
}), {
|
|
182
|
+
"data-visible": isVisible
|
|
183
|
+
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
184
|
+
ref: this.setCaptionRef
|
|
185
|
+
}, css(styles.CalendarMonth_caption, verticalScrollable && styles.CalendarMonth_caption__verticalScrollable)), renderMonthElement ? renderMonthElement({
|
|
186
|
+
month: month,
|
|
187
|
+
onMonthSelect: onMonthSelect,
|
|
188
|
+
onYearSelect: onYearSelect,
|
|
189
|
+
isVisible: isVisible
|
|
190
|
+
}) : /*#__PURE__*/React.createElement("strong", null, monthTitle)), /*#__PURE__*/React.createElement("table", _extends({}, css(!verticalBorderSpacing && styles.CalendarMonth_table, verticalBorderSpacing && styles.CalendarMonth_verticalSpacing, verticalBorderSpacing && {
|
|
191
|
+
borderSpacing: "0px ".concat(verticalBorderSpacing, "px")
|
|
192
|
+
}), {
|
|
193
|
+
role: "presentation"
|
|
194
|
+
}), /*#__PURE__*/React.createElement("tbody", null, weeks.map(function (week, i) {
|
|
195
|
+
return /*#__PURE__*/React.createElement(CalendarWeek, {
|
|
196
|
+
key: i
|
|
197
|
+
}, week.map(function (day, dayOfWeek) {
|
|
198
|
+
return renderCalendarDay({
|
|
199
|
+
key: dayOfWeek,
|
|
200
|
+
day: day,
|
|
201
|
+
daySize: daySize,
|
|
202
|
+
isOutsideDay: !day || day.month() !== month.month(),
|
|
203
|
+
tabIndex: isVisible && isSameDay(day, focusedDate) ? 0 : -1,
|
|
204
|
+
isFocused: isFocused,
|
|
205
|
+
onDayMouseEnter: onDayMouseEnter,
|
|
206
|
+
onDayMouseLeave: onDayMouseLeave,
|
|
207
|
+
onDayClick: onDayClick,
|
|
208
|
+
renderDayContents: renderDayContents,
|
|
209
|
+
phrases: phrases,
|
|
210
|
+
modifiers: modifiers[toISODateString(day)],
|
|
211
|
+
ariaLabelFormat: dayAriaLabelFormat
|
|
212
|
+
});
|
|
213
|
+
}));
|
|
214
|
+
}))));
|
|
215
|
+
};
|
|
216
|
+
return CalendarMonth;
|
|
217
|
+
}(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
|
|
218
|
+
CalendarMonth.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
219
|
+
CalendarMonth.defaultProps = defaultProps;
|
|
220
|
+
export default withStyles(function (_ref3) {
|
|
221
|
+
var _ref3$reactDates = _ref3.reactDates,
|
|
222
|
+
color = _ref3$reactDates.color,
|
|
223
|
+
font = _ref3$reactDates.font,
|
|
224
|
+
spacing = _ref3$reactDates.spacing;
|
|
225
|
+
return {
|
|
226
|
+
CalendarMonth: {
|
|
227
|
+
background: color.background,
|
|
228
|
+
textAlign: 'center',
|
|
229
|
+
verticalAlign: 'top',
|
|
230
|
+
userSelect: 'none'
|
|
231
|
+
},
|
|
232
|
+
CalendarMonth_table: {
|
|
233
|
+
borderCollapse: 'collapse',
|
|
234
|
+
borderSpacing: 0
|
|
235
|
+
},
|
|
236
|
+
CalendarMonth_verticalSpacing: {
|
|
237
|
+
borderCollapse: 'separate'
|
|
238
|
+
},
|
|
239
|
+
CalendarMonth_caption: {
|
|
240
|
+
color: color.text,
|
|
241
|
+
fontSize: font.captionSize,
|
|
242
|
+
textAlign: 'center',
|
|
243
|
+
paddingTop: spacing.captionPaddingTop,
|
|
244
|
+
paddingBottom: spacing.captionPaddingBottom,
|
|
245
|
+
captionSide: 'initial'
|
|
246
|
+
},
|
|
247
|
+
CalendarMonth_caption__verticalScrollable: {
|
|
248
|
+
paddingTop: 12,
|
|
249
|
+
paddingBottom: 7
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}, {
|
|
253
|
+
pureComponent: typeof React.PureComponent !== 'undefined'
|
|
254
|
+
})(CalendarMonth);
|