@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,364 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import shallowEqual from "enzyme-shallow-equal";
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { forbidExtraProps } from 'airbnb-prop-types';
|
|
10
|
+
import { withStyles, withStylesPropTypes } from 'react-with-styles';
|
|
11
|
+
import { DayPickerKeyboardShortcutsPhrases } from '../defaultPhrases';
|
|
12
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
13
|
+
import KeyboardShortcutRow from './KeyboardShortcutRow';
|
|
14
|
+
import CloseButton from './CloseButton';
|
|
15
|
+
export var TOP_LEFT = 'top-left';
|
|
16
|
+
export var TOP_RIGHT = 'top-right';
|
|
17
|
+
export var BOTTOM_RIGHT = 'bottom-right';
|
|
18
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectSpread(_objectSpread({}, withStylesPropTypes), {}, {
|
|
19
|
+
block: PropTypes.bool,
|
|
20
|
+
// TODO: rename button location to be direction-agnostic
|
|
21
|
+
buttonLocation: PropTypes.oneOf([TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT]),
|
|
22
|
+
showKeyboardShortcutsPanel: PropTypes.bool,
|
|
23
|
+
openKeyboardShortcutsPanel: PropTypes.func,
|
|
24
|
+
closeKeyboardShortcutsPanel: PropTypes.func,
|
|
25
|
+
phrases: PropTypes.shape(getPhrasePropTypes(DayPickerKeyboardShortcutsPhrases)),
|
|
26
|
+
renderKeyboardShortcutsButton: PropTypes.func,
|
|
27
|
+
renderKeyboardShortcutsPanel: PropTypes.func
|
|
28
|
+
})) : {};
|
|
29
|
+
var defaultProps = {
|
|
30
|
+
block: false,
|
|
31
|
+
buttonLocation: BOTTOM_RIGHT,
|
|
32
|
+
showKeyboardShortcutsPanel: false,
|
|
33
|
+
openKeyboardShortcutsPanel: function openKeyboardShortcutsPanel() {},
|
|
34
|
+
closeKeyboardShortcutsPanel: function closeKeyboardShortcutsPanel() {},
|
|
35
|
+
phrases: DayPickerKeyboardShortcutsPhrases,
|
|
36
|
+
renderKeyboardShortcutsButton: undefined,
|
|
37
|
+
renderKeyboardShortcutsPanel: undefined
|
|
38
|
+
};
|
|
39
|
+
function getKeyboardShortcuts(phrases) {
|
|
40
|
+
return [{
|
|
41
|
+
unicode: '↵',
|
|
42
|
+
label: phrases.enterKey,
|
|
43
|
+
action: phrases.selectFocusedDate
|
|
44
|
+
}, {
|
|
45
|
+
unicode: '←/→',
|
|
46
|
+
label: phrases.leftArrowRightArrow,
|
|
47
|
+
action: phrases.moveFocusByOneDay
|
|
48
|
+
}, {
|
|
49
|
+
unicode: '↑/↓',
|
|
50
|
+
label: phrases.upArrowDownArrow,
|
|
51
|
+
action: phrases.moveFocusByOneWeek
|
|
52
|
+
}, {
|
|
53
|
+
unicode: 'PgUp/PgDn',
|
|
54
|
+
label: phrases.pageUpPageDown,
|
|
55
|
+
action: phrases.moveFocusByOneMonth
|
|
56
|
+
}, {
|
|
57
|
+
unicode: 'Home/End',
|
|
58
|
+
label: phrases.homeEnd,
|
|
59
|
+
action: phrases.moveFocustoStartAndEndOfWeek
|
|
60
|
+
}, {
|
|
61
|
+
unicode: 'Esc',
|
|
62
|
+
label: phrases.escape,
|
|
63
|
+
action: phrases.returnFocusToInput
|
|
64
|
+
}, {
|
|
65
|
+
unicode: '?',
|
|
66
|
+
label: phrases.questionMark,
|
|
67
|
+
action: phrases.openThisPanel
|
|
68
|
+
}];
|
|
69
|
+
}
|
|
70
|
+
var DayPickerKeyboardShortcuts = /*#__PURE__*/function (_ref2, _ref) {
|
|
71
|
+
function DayPickerKeyboardShortcuts() {
|
|
72
|
+
var _this;
|
|
73
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
74
|
+
args[_key] = arguments[_key];
|
|
75
|
+
}
|
|
76
|
+
_this = _ref2.call.apply(_ref2, [this].concat(args)) || this;
|
|
77
|
+
var phrases = _this.props.phrases;
|
|
78
|
+
_this.state = {
|
|
79
|
+
phrases: phrases,
|
|
80
|
+
keyboardShortcuts: getKeyboardShortcuts(phrases)
|
|
81
|
+
};
|
|
82
|
+
_this.onShowKeyboardShortcutsButtonClick = _this.onShowKeyboardShortcutsButtonClick.bind(_this);
|
|
83
|
+
_this.setShowKeyboardShortcutsButtonRef = _this.setShowKeyboardShortcutsButtonRef.bind(_this);
|
|
84
|
+
_this.setHideKeyboardShortcutsButtonRef = _this.setHideKeyboardShortcutsButtonRef.bind(_this);
|
|
85
|
+
_this.handleFocus = _this.handleFocus.bind(_this);
|
|
86
|
+
_this.onKeyDown = _this.onKeyDown.bind(_this);
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
_inheritsLoose(DayPickerKeyboardShortcuts, _ref2);
|
|
90
|
+
var _proto = DayPickerKeyboardShortcuts.prototype;
|
|
91
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
92
|
+
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
93
|
+
};
|
|
94
|
+
DayPickerKeyboardShortcuts.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
95
|
+
if (props.phrases !== state.phrases) {
|
|
96
|
+
return {
|
|
97
|
+
phrases: props.phrases,
|
|
98
|
+
keyboardShortcuts: getKeyboardShortcuts(props.phrases)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
};
|
|
103
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
104
|
+
this.handleFocus();
|
|
105
|
+
};
|
|
106
|
+
_proto.handleFocus = function handleFocus() {
|
|
107
|
+
if (this.hideKeyboardShortcutsButton) {
|
|
108
|
+
// automatically move focus into the dialog by moving
|
|
109
|
+
// to the only interactive element, the hide button
|
|
110
|
+
this.hideKeyboardShortcutsButton.focus();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
_proto.onKeyDown = function onKeyDown(e) {
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
var closeKeyboardShortcutsPanel = this.props.closeKeyboardShortcutsPanel;
|
|
116
|
+
// Because the close button is the only focusable element inside of the panel, this
|
|
117
|
+
// amounts to a very basic focus trap. The user can exit the panel by "pressing" the
|
|
118
|
+
// close button or hitting escape
|
|
119
|
+
switch (e.key) {
|
|
120
|
+
case 'Escape':
|
|
121
|
+
closeKeyboardShortcutsPanel();
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
// do nothing - this allows the up and down arrows continue their
|
|
125
|
+
// default behavior of scrolling the content of the Keyboard Shortcuts Panel
|
|
126
|
+
// which is needed when only a single month is shown for instance.
|
|
127
|
+
case 'ArrowUp':
|
|
128
|
+
case 'ArrowDown':
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
// completely block the rest of the keys that have functionality outside of this panel
|
|
132
|
+
case 'Tab':
|
|
133
|
+
case 'Home':
|
|
134
|
+
case 'End':
|
|
135
|
+
case 'PageUp':
|
|
136
|
+
case 'PageDown':
|
|
137
|
+
case 'ArrowLeft':
|
|
138
|
+
case 'ArrowRight':
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
_proto.onShowKeyboardShortcutsButtonClick = function onShowKeyboardShortcutsButtonClick() {
|
|
146
|
+
var _this2 = this;
|
|
147
|
+
var openKeyboardShortcutsPanel = this.props.openKeyboardShortcutsPanel;
|
|
148
|
+
|
|
149
|
+
// we want to return focus to this button after closing the keyboard shortcuts panel
|
|
150
|
+
openKeyboardShortcutsPanel(function () {
|
|
151
|
+
_this2.showKeyboardShortcutsButton.focus();
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
_proto.setShowKeyboardShortcutsButtonRef = function setShowKeyboardShortcutsButtonRef(ref) {
|
|
155
|
+
this.showKeyboardShortcutsButton = ref;
|
|
156
|
+
};
|
|
157
|
+
_proto.setHideKeyboardShortcutsButtonRef = function setHideKeyboardShortcutsButtonRef(ref) {
|
|
158
|
+
this.hideKeyboardShortcutsButton = ref;
|
|
159
|
+
};
|
|
160
|
+
_proto.render = function render() {
|
|
161
|
+
var _this$props = this.props,
|
|
162
|
+
block = _this$props.block,
|
|
163
|
+
buttonLocation = _this$props.buttonLocation,
|
|
164
|
+
showKeyboardShortcutsPanel = _this$props.showKeyboardShortcutsPanel,
|
|
165
|
+
closeKeyboardShortcutsPanel = _this$props.closeKeyboardShortcutsPanel,
|
|
166
|
+
css = _this$props.css,
|
|
167
|
+
styles = _this$props.styles,
|
|
168
|
+
phrases = _this$props.phrases,
|
|
169
|
+
renderKeyboardShortcutsButton = _this$props.renderKeyboardShortcutsButton,
|
|
170
|
+
renderKeyboardShortcutsPanel = _this$props.renderKeyboardShortcutsPanel;
|
|
171
|
+
var keyboardShortcuts = this.state.keyboardShortcuts;
|
|
172
|
+
var toggleButtonText = showKeyboardShortcutsPanel ? phrases.hideKeyboardShortcutsPanel : phrases.showKeyboardShortcutsPanel;
|
|
173
|
+
var bottomRight = buttonLocation === BOTTOM_RIGHT;
|
|
174
|
+
var topRight = buttonLocation === TOP_RIGHT;
|
|
175
|
+
var topLeft = buttonLocation === TOP_LEFT;
|
|
176
|
+
return /*#__PURE__*/React.createElement("div", null, renderKeyboardShortcutsButton && renderKeyboardShortcutsButton({
|
|
177
|
+
// passing in context-specific props
|
|
178
|
+
ref: this.setShowKeyboardShortcutsButtonRef,
|
|
179
|
+
onClick: this.onShowKeyboardShortcutsButtonClick,
|
|
180
|
+
ariaLabel: toggleButtonText
|
|
181
|
+
}), !renderKeyboardShortcutsButton && /*#__PURE__*/React.createElement("button", _extends({
|
|
182
|
+
ref: this.setShowKeyboardShortcutsButtonRef
|
|
183
|
+
}, css(styles.DayPickerKeyboardShortcuts_buttonReset, styles.DayPickerKeyboardShortcuts_show, bottomRight && styles.DayPickerKeyboardShortcuts_show__bottomRight, topRight && styles.DayPickerKeyboardShortcuts_show__topRight, topLeft && styles.DayPickerKeyboardShortcuts_show__topLeft), {
|
|
184
|
+
type: "button",
|
|
185
|
+
"aria-label": toggleButtonText,
|
|
186
|
+
onClick: this.onShowKeyboardShortcutsButtonClick,
|
|
187
|
+
onMouseUp: function onMouseUp(e) {
|
|
188
|
+
e.currentTarget.blur();
|
|
189
|
+
}
|
|
190
|
+
}), /*#__PURE__*/React.createElement("span", css(styles.DayPickerKeyboardShortcuts_showSpan, bottomRight && styles.DayPickerKeyboardShortcuts_showSpan__bottomRight, topRight && styles.DayPickerKeyboardShortcuts_showSpan__topRight, topLeft && styles.DayPickerKeyboardShortcuts_showSpan__topLeft), "?")), showKeyboardShortcutsPanel && (renderKeyboardShortcutsPanel ? renderKeyboardShortcutsPanel({
|
|
191
|
+
closeButtonAriaLabel: phrases.hideKeyboardShortcutsPanel,
|
|
192
|
+
keyboardShortcuts: keyboardShortcuts,
|
|
193
|
+
onCloseButtonClick: closeKeyboardShortcutsPanel,
|
|
194
|
+
onKeyDown: this.onKeyDown,
|
|
195
|
+
title: phrases.keyboardShortcuts
|
|
196
|
+
}) : /*#__PURE__*/React.createElement("div", _extends({}, css(styles.DayPickerKeyboardShortcuts_panel), {
|
|
197
|
+
role: "dialog",
|
|
198
|
+
"aria-labelledby": "DayPickerKeyboardShortcuts_title",
|
|
199
|
+
"aria-describedby": "DayPickerKeyboardShortcuts_description"
|
|
200
|
+
}), /*#__PURE__*/React.createElement("div", _extends({}, css(styles.DayPickerKeyboardShortcuts_title), {
|
|
201
|
+
id: "DayPickerKeyboardShortcuts_title"
|
|
202
|
+
}), phrases.keyboardShortcuts), /*#__PURE__*/React.createElement("button", _extends({
|
|
203
|
+
ref: this.setHideKeyboardShortcutsButtonRef
|
|
204
|
+
}, css(styles.DayPickerKeyboardShortcuts_buttonReset, styles.DayPickerKeyboardShortcuts_close), {
|
|
205
|
+
type: "button",
|
|
206
|
+
tabIndex: "0",
|
|
207
|
+
"aria-label": phrases.hideKeyboardShortcutsPanel,
|
|
208
|
+
onClick: closeKeyboardShortcutsPanel,
|
|
209
|
+
onKeyDown: this.onKeyDown
|
|
210
|
+
}), /*#__PURE__*/React.createElement(CloseButton, css(styles.DayPickerKeyboardShortcuts_closeSvg))), /*#__PURE__*/React.createElement("ul", _extends({}, css(styles.DayPickerKeyboardShortcuts_list), {
|
|
211
|
+
id: "DayPickerKeyboardShortcuts_description"
|
|
212
|
+
}), keyboardShortcuts.map(function (_ref3) {
|
|
213
|
+
var unicode = _ref3.unicode,
|
|
214
|
+
label = _ref3.label,
|
|
215
|
+
action = _ref3.action;
|
|
216
|
+
return /*#__PURE__*/React.createElement(KeyboardShortcutRow, {
|
|
217
|
+
key: label,
|
|
218
|
+
unicode: unicode,
|
|
219
|
+
label: label,
|
|
220
|
+
action: action,
|
|
221
|
+
block: block
|
|
222
|
+
});
|
|
223
|
+
})))));
|
|
224
|
+
};
|
|
225
|
+
return DayPickerKeyboardShortcuts;
|
|
226
|
+
}(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
|
|
227
|
+
DayPickerKeyboardShortcuts.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
228
|
+
DayPickerKeyboardShortcuts.defaultProps = defaultProps;
|
|
229
|
+
export default withStyles(function (_ref4) {
|
|
230
|
+
var _ref4$reactDates = _ref4.reactDates,
|
|
231
|
+
color = _ref4$reactDates.color,
|
|
232
|
+
font = _ref4$reactDates.font,
|
|
233
|
+
zIndex = _ref4$reactDates.zIndex;
|
|
234
|
+
return {
|
|
235
|
+
DayPickerKeyboardShortcuts_buttonReset: {
|
|
236
|
+
background: 'none',
|
|
237
|
+
border: 0,
|
|
238
|
+
borderRadius: 0,
|
|
239
|
+
color: 'inherit',
|
|
240
|
+
font: 'inherit',
|
|
241
|
+
lineHeight: 'normal',
|
|
242
|
+
overflow: 'visible',
|
|
243
|
+
padding: 0,
|
|
244
|
+
cursor: 'pointer',
|
|
245
|
+
fontSize: font.size,
|
|
246
|
+
':active': {
|
|
247
|
+
outline: 'none'
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
DayPickerKeyboardShortcuts_show: {
|
|
251
|
+
width: 33,
|
|
252
|
+
height: 26,
|
|
253
|
+
position: 'absolute',
|
|
254
|
+
zIndex: zIndex + 2,
|
|
255
|
+
'::before': {
|
|
256
|
+
content: '""',
|
|
257
|
+
display: 'block',
|
|
258
|
+
position: 'absolute'
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
DayPickerKeyboardShortcuts_show__bottomRight: {
|
|
262
|
+
bottom: 0,
|
|
263
|
+
right: 0,
|
|
264
|
+
'::before': {
|
|
265
|
+
borderTop: '26px solid transparent',
|
|
266
|
+
borderRight: "33px solid ".concat(color.core.primary),
|
|
267
|
+
bottom: 0,
|
|
268
|
+
right: 0
|
|
269
|
+
},
|
|
270
|
+
':hover::before': {
|
|
271
|
+
borderRight: "33px solid ".concat(color.core.primary_dark)
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
DayPickerKeyboardShortcuts_show__topRight: {
|
|
275
|
+
top: 0,
|
|
276
|
+
right: 0,
|
|
277
|
+
'::before': {
|
|
278
|
+
borderBottom: '26px solid transparent',
|
|
279
|
+
borderRight: "33px solid ".concat(color.core.primary),
|
|
280
|
+
top: 0,
|
|
281
|
+
right: 0
|
|
282
|
+
},
|
|
283
|
+
':hover::before': {
|
|
284
|
+
borderRight: "33px solid ".concat(color.core.primary_dark)
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
DayPickerKeyboardShortcuts_show__topLeft: {
|
|
288
|
+
top: 0,
|
|
289
|
+
left: 0,
|
|
290
|
+
'::before': {
|
|
291
|
+
borderBottom: '26px solid transparent',
|
|
292
|
+
borderLeft: "33px solid ".concat(color.core.primary),
|
|
293
|
+
top: 0,
|
|
294
|
+
left: 0
|
|
295
|
+
},
|
|
296
|
+
':hover::before': {
|
|
297
|
+
borderLeft: "33px solid ".concat(color.core.primary_dark)
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
DayPickerKeyboardShortcuts_showSpan: {
|
|
301
|
+
color: color.core.white,
|
|
302
|
+
position: 'absolute'
|
|
303
|
+
},
|
|
304
|
+
DayPickerKeyboardShortcuts_showSpan__bottomRight: {
|
|
305
|
+
bottom: 0,
|
|
306
|
+
right: 5
|
|
307
|
+
},
|
|
308
|
+
DayPickerKeyboardShortcuts_showSpan__topRight: {
|
|
309
|
+
top: 1,
|
|
310
|
+
right: 5
|
|
311
|
+
},
|
|
312
|
+
DayPickerKeyboardShortcuts_showSpan__topLeft: {
|
|
313
|
+
top: 1,
|
|
314
|
+
left: 5
|
|
315
|
+
},
|
|
316
|
+
DayPickerKeyboardShortcuts_panel: {
|
|
317
|
+
overflow: 'auto',
|
|
318
|
+
background: color.background,
|
|
319
|
+
border: "1px solid ".concat(color.core.border),
|
|
320
|
+
borderRadius: 2,
|
|
321
|
+
position: 'absolute',
|
|
322
|
+
top: 0,
|
|
323
|
+
bottom: 0,
|
|
324
|
+
right: 0,
|
|
325
|
+
left: 0,
|
|
326
|
+
zIndex: zIndex + 2,
|
|
327
|
+
padding: 22,
|
|
328
|
+
margin: 33,
|
|
329
|
+
textAlign: 'left' // TODO: investigate use of text-align throughout the library
|
|
330
|
+
},
|
|
331
|
+
DayPickerKeyboardShortcuts_title: {
|
|
332
|
+
fontSize: 16,
|
|
333
|
+
fontWeight: 'bold',
|
|
334
|
+
margin: 0
|
|
335
|
+
},
|
|
336
|
+
DayPickerKeyboardShortcuts_list: {
|
|
337
|
+
listStyle: 'none',
|
|
338
|
+
padding: 0,
|
|
339
|
+
fontSize: font.size
|
|
340
|
+
},
|
|
341
|
+
DayPickerKeyboardShortcuts_close: {
|
|
342
|
+
position: 'absolute',
|
|
343
|
+
right: 22,
|
|
344
|
+
top: 22,
|
|
345
|
+
zIndex: zIndex + 2,
|
|
346
|
+
':active': {
|
|
347
|
+
outline: 'none'
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
DayPickerKeyboardShortcuts_closeSvg: {
|
|
351
|
+
height: 15,
|
|
352
|
+
width: 15,
|
|
353
|
+
fill: color.core.grayLighter,
|
|
354
|
+
':hover': {
|
|
355
|
+
fill: color.core.grayLight
|
|
356
|
+
},
|
|
357
|
+
':focus': {
|
|
358
|
+
fill: color.core.grayLight
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}, {
|
|
363
|
+
pureComponent: typeof React.PureComponent !== 'undefined'
|
|
364
|
+
})(DayPickerKeyboardShortcuts);
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
import shallowEqual from "enzyme-shallow-equal";
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { forbidExtraProps } from 'airbnb-prop-types';
|
|
11
|
+
import { withStyles, withStylesPropTypes } from 'react-with-styles';
|
|
12
|
+
import { DayPickerNavigationPhrases } from '../defaultPhrases';
|
|
13
|
+
import getPhrasePropTypes from '../utils/getPhrasePropTypes';
|
|
14
|
+
import noflip from '../utils/noflip';
|
|
15
|
+
import LeftArrow from './LeftArrow';
|
|
16
|
+
import RightArrow from './RightArrow';
|
|
17
|
+
import ChevronUp from './ChevronUp';
|
|
18
|
+
import ChevronDown from './ChevronDown';
|
|
19
|
+
import NavPositionShape from '../shapes/NavPositionShape';
|
|
20
|
+
import ScrollableOrientationShape from '../shapes/ScrollableOrientationShape';
|
|
21
|
+
import { HORIZONTAL_ORIENTATION, NAV_POSITION_BOTTOM, NAV_POSITION_TOP, VERTICAL_SCROLLABLE } from '../constants';
|
|
22
|
+
var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectSpread(_objectSpread({}, withStylesPropTypes), {}, {
|
|
23
|
+
disablePrev: PropTypes.bool,
|
|
24
|
+
disableNext: PropTypes.bool,
|
|
25
|
+
inlineStyles: PropTypes.object,
|
|
26
|
+
isRTL: PropTypes.bool,
|
|
27
|
+
navPosition: NavPositionShape,
|
|
28
|
+
navPrev: PropTypes.node,
|
|
29
|
+
navNext: PropTypes.node,
|
|
30
|
+
orientation: ScrollableOrientationShape,
|
|
31
|
+
onPrevMonthClick: PropTypes.func,
|
|
32
|
+
onNextMonthClick: PropTypes.func,
|
|
33
|
+
// internationalization
|
|
34
|
+
phrases: PropTypes.shape(getPhrasePropTypes(DayPickerNavigationPhrases)),
|
|
35
|
+
renderNavPrevButton: PropTypes.func,
|
|
36
|
+
renderNavNextButton: PropTypes.func,
|
|
37
|
+
showNavPrevButton: PropTypes.bool,
|
|
38
|
+
showNavNextButton: PropTypes.bool
|
|
39
|
+
})) : {};
|
|
40
|
+
var defaultProps = {
|
|
41
|
+
disablePrev: false,
|
|
42
|
+
disableNext: false,
|
|
43
|
+
inlineStyles: null,
|
|
44
|
+
isRTL: false,
|
|
45
|
+
navPosition: NAV_POSITION_TOP,
|
|
46
|
+
navPrev: null,
|
|
47
|
+
navNext: null,
|
|
48
|
+
orientation: HORIZONTAL_ORIENTATION,
|
|
49
|
+
onPrevMonthClick: function onPrevMonthClick() {},
|
|
50
|
+
onNextMonthClick: function onNextMonthClick() {},
|
|
51
|
+
// internationalization
|
|
52
|
+
phrases: DayPickerNavigationPhrases,
|
|
53
|
+
renderNavPrevButton: null,
|
|
54
|
+
renderNavNextButton: null,
|
|
55
|
+
showNavPrevButton: true,
|
|
56
|
+
showNavNextButton: true
|
|
57
|
+
};
|
|
58
|
+
var DayPickerNavigation = /*#__PURE__*/function (_ref2, _ref) {
|
|
59
|
+
function DayPickerNavigation() {
|
|
60
|
+
return _ref2.apply(this, arguments) || this;
|
|
61
|
+
}
|
|
62
|
+
_inheritsLoose(DayPickerNavigation, _ref2);
|
|
63
|
+
var _proto = DayPickerNavigation.prototype;
|
|
64
|
+
_proto[_ref] = function (nextProps, nextState) {
|
|
65
|
+
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
66
|
+
};
|
|
67
|
+
_proto.render = function render() {
|
|
68
|
+
var _this$props = this.props,
|
|
69
|
+
inlineStyles = _this$props.inlineStyles,
|
|
70
|
+
isRTL = _this$props.isRTL,
|
|
71
|
+
disablePrev = _this$props.disablePrev,
|
|
72
|
+
disableNext = _this$props.disableNext,
|
|
73
|
+
navPosition = _this$props.navPosition,
|
|
74
|
+
navPrev = _this$props.navPrev,
|
|
75
|
+
navNext = _this$props.navNext,
|
|
76
|
+
onPrevMonthClick = _this$props.onPrevMonthClick,
|
|
77
|
+
onNextMonthClick = _this$props.onNextMonthClick,
|
|
78
|
+
orientation = _this$props.orientation,
|
|
79
|
+
phrases = _this$props.phrases,
|
|
80
|
+
renderNavPrevButton = _this$props.renderNavPrevButton,
|
|
81
|
+
renderNavNextButton = _this$props.renderNavNextButton,
|
|
82
|
+
showNavPrevButton = _this$props.showNavPrevButton,
|
|
83
|
+
showNavNextButton = _this$props.showNavNextButton,
|
|
84
|
+
css = _this$props.css,
|
|
85
|
+
styles = _this$props.styles;
|
|
86
|
+
if (!showNavNextButton && !showNavPrevButton) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
var isHorizontal = orientation === HORIZONTAL_ORIENTATION;
|
|
90
|
+
var isVertical = orientation !== HORIZONTAL_ORIENTATION;
|
|
91
|
+
var isVerticalScrollable = orientation === VERTICAL_SCROLLABLE;
|
|
92
|
+
var isBottomNavPosition = navPosition === NAV_POSITION_BOTTOM;
|
|
93
|
+
var hasInlineStyles = !!inlineStyles;
|
|
94
|
+
var navPrevIcon = navPrev;
|
|
95
|
+
var navNextIcon = navNext;
|
|
96
|
+
var isDefaultNavPrev = false;
|
|
97
|
+
var isDefaultNavNext = false;
|
|
98
|
+
var navPrevTabIndex = {};
|
|
99
|
+
var navNextTabIndex = {};
|
|
100
|
+
if (!navPrevIcon && !renderNavPrevButton && showNavPrevButton) {
|
|
101
|
+
navPrevTabIndex = {
|
|
102
|
+
tabIndex: '0'
|
|
103
|
+
};
|
|
104
|
+
isDefaultNavPrev = true;
|
|
105
|
+
var Icon = isVertical ? ChevronUp : LeftArrow;
|
|
106
|
+
if (isRTL && !isVertical) {
|
|
107
|
+
Icon = RightArrow;
|
|
108
|
+
}
|
|
109
|
+
navPrevIcon = /*#__PURE__*/React.createElement(Icon, css(isHorizontal && styles.DayPickerNavigation_svg__horizontal, isVertical && styles.DayPickerNavigation_svg__vertical, disablePrev && styles.DayPickerNavigation_svg__disabled));
|
|
110
|
+
}
|
|
111
|
+
if (!navNextIcon && !renderNavNextButton && showNavNextButton) {
|
|
112
|
+
navNextTabIndex = {
|
|
113
|
+
tabIndex: '0'
|
|
114
|
+
};
|
|
115
|
+
isDefaultNavNext = true;
|
|
116
|
+
var _Icon = isVertical ? ChevronDown : RightArrow;
|
|
117
|
+
if (isRTL && !isVertical) {
|
|
118
|
+
_Icon = LeftArrow;
|
|
119
|
+
}
|
|
120
|
+
navNextIcon = /*#__PURE__*/React.createElement(_Icon, css(isHorizontal && styles.DayPickerNavigation_svg__horizontal, isVertical && styles.DayPickerNavigation_svg__vertical, disableNext && styles.DayPickerNavigation_svg__disabled));
|
|
121
|
+
}
|
|
122
|
+
var isDefaultNav = isDefaultNavNext || isDefaultNavPrev;
|
|
123
|
+
return /*#__PURE__*/React.createElement("div", css.apply(void 0, [styles.DayPickerNavigation, isHorizontal && styles.DayPickerNavigation__horizontal].concat(_toConsumableArray(isVertical ? [styles.DayPickerNavigation__vertical, isDefaultNav && styles.DayPickerNavigation__verticalDefault] : []), _toConsumableArray(isVerticalScrollable ? [styles.DayPickerNavigation__verticalScrollable, isDefaultNav && styles.DayPickerNavigation__verticalScrollableDefault, showNavPrevButton && styles.DayPickerNavigation__verticalScrollable_prevNav] : []), _toConsumableArray(isBottomNavPosition ? [styles.DayPickerNavigation__bottom, isDefaultNav && styles.DayPickerNavigation__bottomDefault] : []), [hasInlineStyles && inlineStyles])), showNavPrevButton && (renderNavPrevButton ? renderNavPrevButton({
|
|
124
|
+
ariaLabel: phrases.jumpToPrevMonth,
|
|
125
|
+
disabled: disablePrev,
|
|
126
|
+
onClick: disablePrev ? undefined : onPrevMonthClick,
|
|
127
|
+
onKeyUp: disablePrev ? undefined : function (e) {
|
|
128
|
+
var key = e.key;
|
|
129
|
+
if (key === 'Enter' || key === ' ') {
|
|
130
|
+
onPrevMonthClick(e);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
onMouseUp: disablePrev ? undefined : function (e) {
|
|
134
|
+
e.currentTarget.blur();
|
|
135
|
+
}
|
|
136
|
+
}) : /*#__PURE__*/React.createElement("div", _extends({
|
|
137
|
+
// eslint-disable-line jsx-a11y/interactive-supports-focus
|
|
138
|
+
role: "button"
|
|
139
|
+
}, navPrevTabIndex, css.apply(void 0, [styles.DayPickerNavigation_button, isDefaultNavPrev && styles.DayPickerNavigation_button__default, disablePrev && styles.DayPickerNavigation_button__disabled].concat(_toConsumableArray(isHorizontal ? [styles.DayPickerNavigation_button__horizontal].concat(_toConsumableArray(isDefaultNavPrev ? [styles.DayPickerNavigation_button__horizontalDefault, isBottomNavPosition && styles.DayPickerNavigation_bottomButton__horizontalDefault, !isRTL && styles.DayPickerNavigation_leftButton__horizontalDefault, isRTL && styles.DayPickerNavigation_rightButton__horizontalDefault] : [])) : []), _toConsumableArray(isVertical ? [styles.DayPickerNavigation_button__vertical].concat(_toConsumableArray(isDefaultNavPrev ? [styles.DayPickerNavigation_button__verticalDefault, styles.DayPickerNavigation_prevButton__verticalDefault, isVerticalScrollable && styles.DayPickerNavigation_prevButton__verticalScrollableDefault] : [])) : []))), {
|
|
140
|
+
"aria-disabled": disablePrev ? true : undefined,
|
|
141
|
+
"aria-label": phrases.jumpToPrevMonth,
|
|
142
|
+
onClick: disablePrev ? undefined : onPrevMonthClick,
|
|
143
|
+
onKeyUp: disablePrev ? undefined : function (e) {
|
|
144
|
+
var key = e.key;
|
|
145
|
+
if (key === 'Enter' || key === ' ') {
|
|
146
|
+
onPrevMonthClick(e);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
onMouseUp: disablePrev ? undefined : function (e) {
|
|
150
|
+
e.currentTarget.blur();
|
|
151
|
+
}
|
|
152
|
+
}), navPrevIcon)), showNavNextButton && (renderNavNextButton ? renderNavNextButton({
|
|
153
|
+
ariaLabel: phrases.jumpToNextMonth,
|
|
154
|
+
disabled: disableNext,
|
|
155
|
+
onClick: disableNext ? undefined : onNextMonthClick,
|
|
156
|
+
onKeyUp: disableNext ? undefined : function (e) {
|
|
157
|
+
var key = e.key;
|
|
158
|
+
if (key === 'Enter' || key === ' ') {
|
|
159
|
+
onNextMonthClick(e);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
onMouseUp: disableNext ? undefined : function (e) {
|
|
163
|
+
e.currentTarget.blur();
|
|
164
|
+
}
|
|
165
|
+
}) : /*#__PURE__*/React.createElement("div", _extends({
|
|
166
|
+
// eslint-disable-line jsx-a11y/interactive-supports-focus
|
|
167
|
+
role: "button"
|
|
168
|
+
}, navNextTabIndex, css.apply(void 0, [styles.DayPickerNavigation_button, isDefaultNavNext && styles.DayPickerNavigation_button__default, disableNext && styles.DayPickerNavigation_button__disabled].concat(_toConsumableArray(isHorizontal ? [styles.DayPickerNavigation_button__horizontal].concat(_toConsumableArray(isDefaultNavNext ? [styles.DayPickerNavigation_button__horizontalDefault, isBottomNavPosition && styles.DayPickerNavigation_bottomButton__horizontalDefault, isRTL && styles.DayPickerNavigation_leftButton__horizontalDefault, !isRTL && styles.DayPickerNavigation_rightButton__horizontalDefault] : [])) : []), _toConsumableArray(isVertical ? [styles.DayPickerNavigation_button__vertical].concat(_toConsumableArray(isDefaultNavNext ? [styles.DayPickerNavigation_button__verticalDefault, styles.DayPickerNavigation_nextButton__verticalDefault, isVerticalScrollable && styles.DayPickerNavigation_nextButton__verticalScrollableDefault] : [])) : []))), {
|
|
169
|
+
"aria-disabled": disableNext ? true : undefined,
|
|
170
|
+
"aria-label": phrases.jumpToNextMonth,
|
|
171
|
+
onClick: disableNext ? undefined : onNextMonthClick,
|
|
172
|
+
onKeyUp: disableNext ? undefined : function (e) {
|
|
173
|
+
var key = e.key;
|
|
174
|
+
if (key === 'Enter' || key === ' ') {
|
|
175
|
+
onNextMonthClick(e);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
onMouseUp: disableNext ? undefined : function (e) {
|
|
179
|
+
e.currentTarget.blur();
|
|
180
|
+
}
|
|
181
|
+
}), navNextIcon)));
|
|
182
|
+
};
|
|
183
|
+
return DayPickerNavigation;
|
|
184
|
+
}(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
|
|
185
|
+
DayPickerNavigation.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
186
|
+
DayPickerNavigation.defaultProps = defaultProps;
|
|
187
|
+
export default withStyles(function (_ref3) {
|
|
188
|
+
var _ref3$reactDates = _ref3.reactDates,
|
|
189
|
+
color = _ref3$reactDates.color,
|
|
190
|
+
zIndex = _ref3$reactDates.zIndex;
|
|
191
|
+
return {
|
|
192
|
+
DayPickerNavigation: {
|
|
193
|
+
position: 'relative',
|
|
194
|
+
zIndex: zIndex + 2
|
|
195
|
+
},
|
|
196
|
+
DayPickerNavigation__horizontal: {
|
|
197
|
+
height: 0
|
|
198
|
+
},
|
|
199
|
+
DayPickerNavigation__vertical: {},
|
|
200
|
+
DayPickerNavigation__verticalScrollable: {},
|
|
201
|
+
DayPickerNavigation__verticalScrollable_prevNav: {
|
|
202
|
+
zIndex: zIndex + 1 // zIndex + 2 causes the button to show on top of the day of week headers
|
|
203
|
+
},
|
|
204
|
+
DayPickerNavigation__verticalDefault: {
|
|
205
|
+
position: 'absolute',
|
|
206
|
+
width: '100%',
|
|
207
|
+
height: 52,
|
|
208
|
+
bottom: 0,
|
|
209
|
+
left: noflip(0)
|
|
210
|
+
},
|
|
211
|
+
DayPickerNavigation__verticalScrollableDefault: {
|
|
212
|
+
position: 'relative'
|
|
213
|
+
},
|
|
214
|
+
DayPickerNavigation__bottom: {
|
|
215
|
+
height: 'auto'
|
|
216
|
+
},
|
|
217
|
+
DayPickerNavigation__bottomDefault: {
|
|
218
|
+
display: 'flex',
|
|
219
|
+
justifyContent: 'space-between'
|
|
220
|
+
},
|
|
221
|
+
DayPickerNavigation_button: {
|
|
222
|
+
cursor: 'pointer',
|
|
223
|
+
userSelect: 'none',
|
|
224
|
+
border: 0,
|
|
225
|
+
padding: 0,
|
|
226
|
+
margin: 0
|
|
227
|
+
},
|
|
228
|
+
DayPickerNavigation_button__default: {
|
|
229
|
+
border: "1px solid ".concat(color.core.borderLight),
|
|
230
|
+
backgroundColor: color.background,
|
|
231
|
+
color: color.placeholderText,
|
|
232
|
+
':focus': {
|
|
233
|
+
border: "1px solid ".concat(color.core.borderMedium)
|
|
234
|
+
},
|
|
235
|
+
':hover': {
|
|
236
|
+
border: "1px solid ".concat(color.core.borderMedium)
|
|
237
|
+
},
|
|
238
|
+
':active': {
|
|
239
|
+
background: color.backgroundDark
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
DayPickerNavigation_button__disabled: {
|
|
243
|
+
cursor: 'default',
|
|
244
|
+
border: "1px solid ".concat(color.disabled),
|
|
245
|
+
':focus': {
|
|
246
|
+
border: "1px solid ".concat(color.disabled)
|
|
247
|
+
},
|
|
248
|
+
':hover': {
|
|
249
|
+
border: "1px solid ".concat(color.disabled)
|
|
250
|
+
},
|
|
251
|
+
':active': {
|
|
252
|
+
background: 'none'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
DayPickerNavigation_button__horizontal: {},
|
|
256
|
+
DayPickerNavigation_button__horizontalDefault: {
|
|
257
|
+
position: 'absolute',
|
|
258
|
+
top: 18,
|
|
259
|
+
lineHeight: 0.78,
|
|
260
|
+
borderRadius: 3,
|
|
261
|
+
padding: '6px 9px'
|
|
262
|
+
},
|
|
263
|
+
DayPickerNavigation_bottomButton__horizontalDefault: {
|
|
264
|
+
position: 'static',
|
|
265
|
+
marginLeft: 22,
|
|
266
|
+
marginRight: 22,
|
|
267
|
+
marginBottom: 30,
|
|
268
|
+
marginTop: -10
|
|
269
|
+
},
|
|
270
|
+
DayPickerNavigation_leftButton__horizontalDefault: {
|
|
271
|
+
left: noflip(22)
|
|
272
|
+
},
|
|
273
|
+
DayPickerNavigation_rightButton__horizontalDefault: {
|
|
274
|
+
right: noflip(22)
|
|
275
|
+
},
|
|
276
|
+
DayPickerNavigation_button__vertical: {},
|
|
277
|
+
DayPickerNavigation_button__verticalDefault: {
|
|
278
|
+
padding: 5,
|
|
279
|
+
background: color.background,
|
|
280
|
+
boxShadow: noflip('0 0 5px 2px rgba(0, 0, 0, 0.1)'),
|
|
281
|
+
position: 'relative',
|
|
282
|
+
display: 'inline-block',
|
|
283
|
+
textAlign: 'center',
|
|
284
|
+
height: '100%',
|
|
285
|
+
width: '50%'
|
|
286
|
+
},
|
|
287
|
+
DayPickerNavigation_prevButton__verticalDefault: {},
|
|
288
|
+
DayPickerNavigation_nextButton__verticalDefault: {
|
|
289
|
+
borderLeft: noflip(0)
|
|
290
|
+
},
|
|
291
|
+
DayPickerNavigation_nextButton__verticalScrollableDefault: {
|
|
292
|
+
width: '100%'
|
|
293
|
+
},
|
|
294
|
+
DayPickerNavigation_prevButton__verticalScrollableDefault: {
|
|
295
|
+
width: '100%'
|
|
296
|
+
},
|
|
297
|
+
DayPickerNavigation_svg__horizontal: {
|
|
298
|
+
height: 19,
|
|
299
|
+
width: 19,
|
|
300
|
+
fill: color.core.grayLight,
|
|
301
|
+
display: 'block'
|
|
302
|
+
},
|
|
303
|
+
DayPickerNavigation_svg__vertical: {
|
|
304
|
+
height: 42,
|
|
305
|
+
width: 42,
|
|
306
|
+
fill: color.text
|
|
307
|
+
},
|
|
308
|
+
DayPickerNavigation_svg__disabled: {
|
|
309
|
+
fill: color.disabled
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}, {
|
|
313
|
+
pureComponent: typeof React.PureComponent !== 'undefined'
|
|
314
|
+
})(DayPickerNavigation);
|