@elliemae/ds-controlled-form 2.4.2-rc.1 → 2.4.2-rc.11
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/cjs/autocomplete/parts/A11yFocusedOption.js +43 -0
- package/cjs/autocomplete/parts/container/Container.js +36 -24
- package/cjs/autocomplete/parts/container/styled.js +2 -2
- package/cjs/autocomplete/parts/menu-list/MenuList.js +4 -2
- package/cjs/autocomplete/parts/styled.js +2 -0
- package/cjs/autocomplete/utils/listHelper.js +1 -1
- package/cjs/checkbox/ControlledCheckbox.js +1 -1
- package/cjs/checkbox/react-desc-prop-types.js +2 -1
- package/cjs/checkbox/styles.js +4 -2
- package/cjs/combobox/ComboBoxCTX.js +6 -3
- package/cjs/combobox/config/useComboBox.js +15 -4
- package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
- package/cjs/combobox/parts/A11ySelectedValues.js +0 -2
- package/cjs/combobox/parts/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/container/Container.js +10 -13
- package/cjs/combobox/parts/controls/Controls.js +16 -18
- package/cjs/combobox/parts/controls/useOnPillsNavigation.js +3 -3
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/cjs/combobox/parts/controls-input/useControlsInput.js +3 -2
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +16 -23
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +6 -6
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +3 -3
- package/cjs/combobox/parts/menu-list/MenuList.js +7 -5
- package/cjs/combobox/parts/menu-list/styled.js +5 -3
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +16 -15
- package/cjs/combobox/react-desc-prop-types.js +3 -2
- package/cjs/combobox/utils/listHelper.js +10 -0
- package/cjs/date-time-picker/config/useChangeHandlers.js +8 -12
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +13 -9
- package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
- package/cjs/date-time-picker/config/useGetReferences.js +40 -19
- package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +12 -2
- package/cjs/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
- package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
- package/cjs/date-time-picker/parts/DateInputs/DDInput.js +8 -2
- package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -2
- package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +76 -95
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +31 -5
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -12
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -38
- package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +13 -7
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +14 -8
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +13 -7
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
- package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
- package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
- package/cjs/date-time-picker/utils/constants.js +0 -12
- package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/cjs/input-group/InputGroup.js +8 -7
- package/cjs/input-group/exported-related/data-test-ids.js +12 -0
- package/cjs/input-group/exported-related/index.js +12 -0
- package/cjs/input-group/exported-related/theming.js +13 -0
- package/cjs/input-group/styled.js +21 -20
- package/esm/autocomplete/parts/A11yFocusedOption.js +32 -0
- package/esm/autocomplete/parts/container/Container.js +39 -27
- package/esm/autocomplete/parts/container/styled.js +2 -2
- package/esm/autocomplete/parts/menu-list/MenuList.js +5 -3
- package/esm/autocomplete/parts/styled.js +1 -0
- package/esm/autocomplete/utils/listHelper.js +1 -1
- package/esm/checkbox/ControlledCheckbox.js +2 -2
- package/esm/checkbox/react-desc-prop-types.js +2 -1
- package/esm/checkbox/styles.js +4 -3
- package/esm/combobox/ComboBoxCTX.js +6 -3
- package/esm/combobox/config/useComboBox.js +16 -5
- package/esm/combobox/parts/A11yFocusedOption.js +15 -7
- package/esm/combobox/parts/A11ySelectedValues.js +0 -2
- package/esm/combobox/parts/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/container/Container.js +10 -13
- package/esm/combobox/parts/controls/Controls.js +16 -18
- package/esm/combobox/parts/controls/useOnPillsNavigation.js +3 -3
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/esm/combobox/parts/controls-input/useControlsInput.js +3 -2
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +17 -24
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +6 -6
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +3 -3
- package/esm/combobox/parts/menu-list/MenuList.js +7 -5
- package/esm/combobox/parts/menu-list/styled.js +5 -4
- package/esm/combobox/parts/menu-list/useItemRenderer.js +18 -17
- package/esm/combobox/react-desc-prop-types.js +3 -2
- package/esm/combobox/utils/listHelper.js +10 -1
- package/esm/date-time-picker/config/useChangeHandlers.js +8 -12
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +13 -9
- package/esm/date-time-picker/config/useFocusTracker.js +132 -0
- package/esm/date-time-picker/config/useGetReferences.js +41 -20
- package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +12 -2
- package/esm/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
- package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
- package/esm/date-time-picker/parts/DateInputs/DDInput.js +8 -2
- package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -2
- package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +77 -96
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +32 -6
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -12
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -39
- package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +14 -8
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +15 -9
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +14 -8
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
- package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
- package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
- package/esm/date-time-picker/utils/constants.js +1 -7
- package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/esm/input-group/InputGroup.js +5 -4
- package/esm/input-group/exported-related/data-test-ids.js +8 -0
- package/esm/input-group/exported-related/index.js +2 -0
- package/esm/input-group/exported-related/theming.js +8 -0
- package/esm/input-group/styled.js +18 -17
- package/package.json +39 -15
- package/types/autocomplete/parts/A11yFocusedOption.d.ts +5 -0
- package/types/autocomplete/parts/container/styled.d.ts +1 -1
- package/types/autocomplete/parts/styled.d.ts +0 -0
- package/types/autocomplete/utils/listHelper.d.ts +5 -5
- package/types/checkbox/react-desc-prop-types.d.ts +1 -1
- package/types/checkbox/styles.d.ts +1 -0
- package/types/combobox/parts/menu-list/styled.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +8 -6
- package/types/combobox/sharedTypes.d.ts +3 -2
- package/types/combobox/utils/listHelper.d.ts +1 -0
- package/types/date-time-picker/config/useChangeHandlers.d.ts +3 -1
- package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +2 -5
- package/types/date-time-picker/config/useFocusTracker.d.ts +38 -0
- package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +6 -6
- package/types/date-time-picker/config/useGetReferences.d.ts +30 -36
- package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +3 -1
- package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
- package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
- package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
- package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +14 -0
- package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -2
- package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +19 -0
- package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +0 -6
- package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +14 -0
- package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
- package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
- package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
- package/types/date-time-picker/propTypes.d.ts +117 -0
- package/types/date-time-picker/sharedTypes.d.ts +1 -1
- package/types/date-time-picker/utils/constants.d.ts +0 -6
- package/types/input-group/exported-related/data-test-ids.d.ts +6 -0
- package/types/input-group/exported-related/index.d.ts +2 -0
- package/types/input-group/exported-related/theming.d.ts +6 -0
- package/types/input-group/styled.d.ts +4 -7
- package/types/text-input/config/useInputText.d.ts +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useContext, useCallback, useMemo } from 'react';
|
|
2
2
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
3
|
-
import { homeEndKeys, homeEndAllArrowKeys } from '../../../utils/constants.js';
|
|
4
3
|
|
|
5
4
|
/* eslint-disable @typescript-eslint/indent */
|
|
6
5
|
const useKeyboardHandlers = _ref => {
|
|
@@ -20,59 +19,42 @@ const useKeyboardHandlers = _ref => {
|
|
|
20
19
|
isWithDateInputs,
|
|
21
20
|
isWithCalendarToo,
|
|
22
21
|
isControllerOnly,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
prevHourBtnRef,
|
|
31
|
-
currHourBtnRef,
|
|
32
|
-
nextHourBtnRef,
|
|
33
|
-
prevMinutesBtnRef,
|
|
34
|
-
currMinutesBtnRef,
|
|
35
|
-
nextMinutesBtnRef,
|
|
36
|
-
prevMeridiemBtnRef,
|
|
37
|
-
currMeridiemBtnRef,
|
|
38
|
-
nextMeridiemBtnRef
|
|
22
|
+
trackFocusCalendarPrevMonth,
|
|
23
|
+
trackFocusTimewheelCurrHour,
|
|
24
|
+
trackFocusTimewheelCurrMinute,
|
|
25
|
+
trackFocusTimewheelCurrMeridiem,
|
|
26
|
+
trackFocusFirstSegment,
|
|
27
|
+
trackFocusMeridiemInput,
|
|
28
|
+
trackFocusYearInput
|
|
39
29
|
} = useContext(ControlledDateTimePickerContext);
|
|
40
30
|
const onHomeKeyDownInsideTimeWheel = useCallback(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (isWithCalendarToo) prevMonthBtnRef === null || prevMonthBtnRef === void 0 ? void 0 : (_prevMonthBtnRef$curr = prevMonthBtnRef.current) === null || _prevMonthBtnRef$curr === void 0 ? void 0 : (_prevMonthBtnRef$curr2 = _prevMonthBtnRef$curr.focus) === null || _prevMonthBtnRef$curr2 === void 0 ? void 0 : _prevMonthBtnRef$curr2.call(_prevMonthBtnRef$curr);else currHourBtnRef === null || currHourBtnRef === void 0 ? void 0 : (_currHourBtnRef$curre = currHourBtnRef.current) === null || _currHourBtnRef$curre === void 0 ? void 0 : (_currHourBtnRef$curre2 = _currHourBtnRef$curre.focus) === null || _currHourBtnRef$curre2 === void 0 ? void 0 : _currHourBtnRef$curre2.call(_currHourBtnRef$curre);
|
|
44
|
-
}, [currHourBtnRef, isWithCalendarToo, prevMonthBtnRef]);
|
|
31
|
+
if (isWithCalendarToo) trackFocusCalendarPrevMonth();else trackFocusTimewheelCurrHour();
|
|
32
|
+
}, [isWithCalendarToo, trackFocusCalendarPrevMonth, trackFocusTimewheelCurrHour]);
|
|
45
33
|
const onEndKeyDownInsideTimeWheel = useCallback(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
currMeridiemBtnRef === null || currMeridiemBtnRef === void 0 ? void 0 : (_currMeridiemBtnRef$c = currMeridiemBtnRef.current) === null || _currMeridiemBtnRef$c === void 0 ? void 0 : (_currMeridiemBtnRef$c2 = _currMeridiemBtnRef$c.focus) === null || _currMeridiemBtnRef$c2 === void 0 ? void 0 : _currMeridiemBtnRef$c2.call(_currMeridiemBtnRef$c);
|
|
49
|
-
}, [currMeridiemBtnRef]);
|
|
34
|
+
trackFocusTimewheelCurrMeridiem();
|
|
35
|
+
}, [trackFocusTimewheelCurrMeridiem]);
|
|
50
36
|
const onHomeKeyDownTriggerIcon = useCallback(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!hideDate) monthInputRef === null || monthInputRef === void 0 ? void 0 : (_monthInputRef$curren = monthInputRef.current) === null || _monthInputRef$curren === void 0 ? void 0 : (_monthInputRef$curren2 = _monthInputRef$curren.focus) === null || _monthInputRef$curren2 === void 0 ? void 0 : _monthInputRef$curren2.call(_monthInputRef$curren);else if (!hideTime) hourInputRef === null || hourInputRef === void 0 ? void 0 : (_hourInputRef$current = hourInputRef.current) === null || _hourInputRef$current === void 0 ? void 0 : (_hourInputRef$current2 = _hourInputRef$current.focus) === null || _hourInputRef$current2 === void 0 ? void 0 : _hourInputRef$current2.call(_hourInputRef$current);
|
|
54
|
-
}, [hideDate, hideTime, monthInputRef, hourInputRef]);
|
|
37
|
+
trackFocusFirstSegment();
|
|
38
|
+
}, [trackFocusFirstSegment]);
|
|
55
39
|
const handlePickerIconKeyDown = useCallback(e => {
|
|
56
40
|
const {
|
|
57
41
|
key
|
|
58
42
|
} = e;
|
|
59
|
-
if (
|
|
60
|
-
if (
|
|
43
|
+
if (['Home', 'End'].includes(key)) e.preventDefault();
|
|
44
|
+
if (['Home', 'End'].includes(key)) e.stopPropagation();
|
|
61
45
|
if (key === 'Home') onHomeKeyDownTriggerIcon();
|
|
62
46
|
|
|
63
47
|
if (key === 'Backspace' && withAnyInputs) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (isWithTimeInputs) meridiemInputRef === null || meridiemInputRef === void 0 ? void 0 : (_meridiemInputRef$cur = meridiemInputRef.current) === null || _meridiemInputRef$cur === void 0 ? void 0 : (_meridiemInputRef$cur2 = _meridiemInputRef$cur.focus) === null || _meridiemInputRef$cur2 === void 0 ? void 0 : _meridiemInputRef$cur2.call(_meridiemInputRef$cur);else if (isWithDateInputs) yearInputRef === null || yearInputRef === void 0 ? void 0 : (_yearInputRef$current = yearInputRef.current) === null || _yearInputRef$current === void 0 ? void 0 : (_yearInputRef$current2 = _yearInputRef$current.focus) === null || _yearInputRef$current2 === void 0 ? void 0 : _yearInputRef$current2.call(_yearInputRef$current);
|
|
48
|
+
if (isWithTimeInputs) trackFocusMeridiemInput();else if (isWithDateInputs) trackFocusYearInput();
|
|
67
49
|
}
|
|
68
|
-
}, [isWithDateInputs, isWithTimeInputs,
|
|
50
|
+
}, [isWithDateInputs, isWithTimeInputs, onHomeKeyDownTriggerIcon, trackFocusMeridiemInput, trackFocusYearInput, withAnyInputs]);
|
|
69
51
|
const handleCurrHourOnKeyDown = useCallback(e => {
|
|
70
52
|
const {
|
|
71
53
|
key,
|
|
72
54
|
shiftKey
|
|
73
55
|
} = e;
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
56
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.preventDefault();
|
|
57
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.stopPropagation();
|
|
76
58
|
let didTriggerHourChange = false;
|
|
77
59
|
|
|
78
60
|
if (key === 'ArrowUp') {
|
|
@@ -86,33 +68,25 @@ const useKeyboardHandlers = _ref => {
|
|
|
86
68
|
}
|
|
87
69
|
|
|
88
70
|
if (key === 'ArrowRight') {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
currMinutesBtnRef === null || currMinutesBtnRef === void 0 ? void 0 : (_currMinutesBtnRef$cu = currMinutesBtnRef.current) === null || _currMinutesBtnRef$cu === void 0 ? void 0 : (_currMinutesBtnRef$cu2 = _currMinutesBtnRef$cu.focus) === null || _currMinutesBtnRef$cu2 === void 0 ? void 0 : _currMinutesBtnRef$cu2.call(_currMinutesBtnRef$cu);
|
|
71
|
+
trackFocusTimewheelCurrMinute();
|
|
92
72
|
}
|
|
93
73
|
|
|
94
74
|
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
95
75
|
if (key === 'End') onEndKeyDownInsideTimeWheel(); // ensure the focus is in the correct button after up/down arrow
|
|
96
76
|
|
|
97
|
-
if (didTriggerHourChange)
|
|
98
|
-
var _currHourBtnRef$curre3, _currHourBtnRef$curre4;
|
|
99
|
-
|
|
100
|
-
return currHourBtnRef === null || currHourBtnRef === void 0 ? void 0 : (_currHourBtnRef$curre3 = currHourBtnRef.current) === null || _currHourBtnRef$curre3 === void 0 ? void 0 : (_currHourBtnRef$curre4 = _currHourBtnRef$curre3.focus) === null || _currHourBtnRef$curre4 === void 0 ? void 0 : _currHourBtnRef$curre4.call(_currHourBtnRef$curre3);
|
|
101
|
-
}); // TAB CYCLE IMPLEMENTATION
|
|
77
|
+
if (didTriggerHourChange) trackFocusTimewheelCurrHour(); // TAB CYCLE IMPLEMENTATION
|
|
102
78
|
|
|
103
79
|
if (!isControllerOnly) if (key === 'Tab' && shiftKey && !isWithCalendarToo) {
|
|
104
|
-
var _currMeridiemBtnRef$c3, _currMeridiemBtnRef$c4;
|
|
105
|
-
|
|
106
80
|
e.preventDefault();
|
|
107
|
-
|
|
81
|
+
trackFocusTimewheelCurrMeridiem();
|
|
108
82
|
}
|
|
109
|
-
}, [
|
|
83
|
+
}, [handleNextHour, handlePrevHour, isControllerOnly, isWithCalendarToo, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel, trackFocusTimewheelCurrHour, trackFocusTimewheelCurrMeridiem, trackFocusTimewheelCurrMinute]);
|
|
110
84
|
const handleCurrMinutesOnKeyDown = useCallback(e => {
|
|
111
85
|
const {
|
|
112
86
|
key
|
|
113
87
|
} = e;
|
|
114
|
-
if (
|
|
115
|
-
if (
|
|
88
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.preventDefault();
|
|
89
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.stopPropagation();
|
|
116
90
|
let didTriggerMinuteChange = false;
|
|
117
91
|
|
|
118
92
|
if (key === 'ArrowUp') {
|
|
@@ -126,33 +100,25 @@ const useKeyboardHandlers = _ref => {
|
|
|
126
100
|
}
|
|
127
101
|
|
|
128
102
|
if (key === 'ArrowLeft') {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
currHourBtnRef === null || currHourBtnRef === void 0 ? void 0 : (_currHourBtnRef$curre5 = currHourBtnRef.current) === null || _currHourBtnRef$curre5 === void 0 ? void 0 : (_currHourBtnRef$curre6 = _currHourBtnRef$curre5.focus) === null || _currHourBtnRef$curre6 === void 0 ? void 0 : _currHourBtnRef$curre6.call(_currHourBtnRef$curre5);
|
|
103
|
+
trackFocusTimewheelCurrHour();
|
|
132
104
|
}
|
|
133
105
|
|
|
134
106
|
if (key === 'ArrowRight') {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
currMeridiemBtnRef === null || currMeridiemBtnRef === void 0 ? void 0 : (_currMeridiemBtnRef$c5 = currMeridiemBtnRef.current) === null || _currMeridiemBtnRef$c5 === void 0 ? void 0 : (_currMeridiemBtnRef$c6 = _currMeridiemBtnRef$c5.focus) === null || _currMeridiemBtnRef$c6 === void 0 ? void 0 : _currMeridiemBtnRef$c6.call(_currMeridiemBtnRef$c5);
|
|
107
|
+
trackFocusTimewheelCurrMeridiem();
|
|
138
108
|
}
|
|
139
109
|
|
|
140
110
|
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
141
111
|
if (key === 'End') onEndKeyDownInsideTimeWheel(); // ensure the focus is in the correct button after up/down arrow
|
|
142
112
|
|
|
143
|
-
if (didTriggerMinuteChange)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return currMinutesBtnRef === null || currMinutesBtnRef === void 0 ? void 0 : (_currMinutesBtnRef$cu3 = currMinutesBtnRef.current) === null || _currMinutesBtnRef$cu3 === void 0 ? void 0 : (_currMinutesBtnRef$cu4 = _currMinutesBtnRef$cu3.focus) === null || _currMinutesBtnRef$cu4 === void 0 ? void 0 : _currMinutesBtnRef$cu4.call(_currMinutesBtnRef$cu3);
|
|
147
|
-
});
|
|
148
|
-
}, [onHomeKeyDownInsideTimeWheel, onEndKeyDownInsideTimeWheel, handlePrevMinute, handleNextMinute, currHourBtnRef, currMeridiemBtnRef, currMinutesBtnRef]);
|
|
113
|
+
if (didTriggerMinuteChange) trackFocusTimewheelCurrMinute();
|
|
114
|
+
}, [onHomeKeyDownInsideTimeWheel, onEndKeyDownInsideTimeWheel, handlePrevMinute, handleNextMinute, trackFocusTimewheelCurrHour, trackFocusTimewheelCurrMeridiem, trackFocusTimewheelCurrMinute]);
|
|
149
115
|
const handleCurrMeridiemOnKeyDown = useCallback(e => {
|
|
150
116
|
const {
|
|
151
117
|
key,
|
|
152
118
|
shiftKey
|
|
153
119
|
} = e;
|
|
154
|
-
if (
|
|
155
|
-
if (
|
|
120
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.preventDefault();
|
|
121
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.stopPropagation();
|
|
156
122
|
let didTriggerMeridiemChange = false;
|
|
157
123
|
|
|
158
124
|
if (key === 'ArrowUp') {
|
|
@@ -166,185 +132,25 @@ const useKeyboardHandlers = _ref => {
|
|
|
166
132
|
}
|
|
167
133
|
|
|
168
134
|
if (key === 'ArrowLeft') {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// currSecondsBtnRef?.current?.focus?.();
|
|
172
|
-
currMinutesBtnRef === null || currMinutesBtnRef === void 0 ? void 0 : (_currMinutesBtnRef$cu5 = currMinutesBtnRef.current) === null || _currMinutesBtnRef$cu5 === void 0 ? void 0 : (_currMinutesBtnRef$cu6 = _currMinutesBtnRef$cu5.focus) === null || _currMinutesBtnRef$cu6 === void 0 ? void 0 : _currMinutesBtnRef$cu6.call(_currMinutesBtnRef$cu5);
|
|
135
|
+
trackFocusTimewheelCurrMinute();
|
|
173
136
|
}
|
|
174
137
|
|
|
175
138
|
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
176
139
|
if (key === 'End') onEndKeyDownInsideTimeWheel(); // ensure the focus is in the correct button after up/down arrow
|
|
177
140
|
|
|
178
|
-
if (didTriggerMeridiemChange)
|
|
179
|
-
var _currMeridiemBtnRef$c7, _currMeridiemBtnRef$c8;
|
|
180
|
-
|
|
181
|
-
return currMeridiemBtnRef === null || currMeridiemBtnRef === void 0 ? void 0 : (_currMeridiemBtnRef$c7 = currMeridiemBtnRef.current) === null || _currMeridiemBtnRef$c7 === void 0 ? void 0 : (_currMeridiemBtnRef$c8 = _currMeridiemBtnRef$c7.focus) === null || _currMeridiemBtnRef$c8 === void 0 ? void 0 : _currMeridiemBtnRef$c8.call(_currMeridiemBtnRef$c7);
|
|
182
|
-
}); // TAB CYCLE IMPLEMENTATION
|
|
141
|
+
if (didTriggerMeridiemChange) trackFocusTimewheelCurrMeridiem(); // TAB CYCLE IMPLEMENTATION
|
|
183
142
|
|
|
184
143
|
if (!isControllerOnly) if (key === 'Tab' && !shiftKey) {
|
|
185
|
-
var _prevMonthBtnRef$curr3, _prevMonthBtnRef$curr4, _currHourBtnRef$curre7, _currHourBtnRef$curre8;
|
|
186
|
-
|
|
187
144
|
e.preventDefault();
|
|
188
|
-
if (isWithCalendarToo)
|
|
189
|
-
}
|
|
190
|
-
}, [currHourBtnRef, currMeridiemBtnRef, currMinutesBtnRef, handleTimeWheelBtnChangeMeridiem, isControllerOnly, isWithCalendarToo, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel, prevMonthBtnRef]);
|
|
191
|
-
const handlePrevHourBtnOnKeyDown = useCallback(e => {
|
|
192
|
-
const {
|
|
193
|
-
key
|
|
194
|
-
} = e;
|
|
195
|
-
if (homeEndAllArrowKeys.includes(key)) e.preventDefault();
|
|
196
|
-
if (homeEndAllArrowKeys.includes(key)) e.stopPropagation();
|
|
197
|
-
|
|
198
|
-
if (key === 'ArrowRight') {
|
|
199
|
-
var _prevMinutesBtnRef$cu, _prevMinutesBtnRef$cu2;
|
|
200
|
-
|
|
201
|
-
prevMinutesBtnRef === null || prevMinutesBtnRef === void 0 ? void 0 : (_prevMinutesBtnRef$cu = prevMinutesBtnRef.current) === null || _prevMinutesBtnRef$cu === void 0 ? void 0 : (_prevMinutesBtnRef$cu2 = _prevMinutesBtnRef$cu.focus) === null || _prevMinutesBtnRef$cu2 === void 0 ? void 0 : _prevMinutesBtnRef$cu2.call(_prevMinutesBtnRef$cu);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (key === 'ArrowDown') {
|
|
205
|
-
var _currHourBtnRef$curre9, _currHourBtnRef$curre10;
|
|
206
|
-
|
|
207
|
-
currHourBtnRef === null || currHourBtnRef === void 0 ? void 0 : (_currHourBtnRef$curre9 = currHourBtnRef.current) === null || _currHourBtnRef$curre9 === void 0 ? void 0 : (_currHourBtnRef$curre10 = _currHourBtnRef$curre9.focus) === null || _currHourBtnRef$curre10 === void 0 ? void 0 : _currHourBtnRef$curre10.call(_currHourBtnRef$curre9);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
211
|
-
if (key === 'End') onEndKeyDownInsideTimeWheel();
|
|
212
|
-
}, [currHourBtnRef, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel, prevMinutesBtnRef]);
|
|
213
|
-
const handlePrevMinuteBtnOnKeyDown = useCallback(e => {
|
|
214
|
-
const {
|
|
215
|
-
key
|
|
216
|
-
} = e;
|
|
217
|
-
if (homeEndAllArrowKeys.includes(key)) e.preventDefault();
|
|
218
|
-
if (homeEndAllArrowKeys.includes(key)) e.stopPropagation();
|
|
219
|
-
|
|
220
|
-
if (key === 'ArrowRight') {
|
|
221
|
-
var _prevMeridiemBtnRef$c, _prevMeridiemBtnRef$c2;
|
|
222
|
-
|
|
223
|
-
// prevSecondsBtnRef?.current?.focus?.();
|
|
224
|
-
prevMeridiemBtnRef === null || prevMeridiemBtnRef === void 0 ? void 0 : (_prevMeridiemBtnRef$c = prevMeridiemBtnRef.current) === null || _prevMeridiemBtnRef$c === void 0 ? void 0 : (_prevMeridiemBtnRef$c2 = _prevMeridiemBtnRef$c.focus) === null || _prevMeridiemBtnRef$c2 === void 0 ? void 0 : _prevMeridiemBtnRef$c2.call(_prevMeridiemBtnRef$c);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (key === 'ArrowLeft') {
|
|
228
|
-
var _prevHourBtnRef$curre, _prevHourBtnRef$curre2;
|
|
229
|
-
|
|
230
|
-
prevHourBtnRef === null || prevHourBtnRef === void 0 ? void 0 : (_prevHourBtnRef$curre = prevHourBtnRef.current) === null || _prevHourBtnRef$curre === void 0 ? void 0 : (_prevHourBtnRef$curre2 = _prevHourBtnRef$curre.focus) === null || _prevHourBtnRef$curre2 === void 0 ? void 0 : _prevHourBtnRef$curre2.call(_prevHourBtnRef$curre);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (key === 'ArrowDown') {
|
|
234
|
-
var _currMinutesBtnRef$cu7, _currMinutesBtnRef$cu8;
|
|
235
|
-
|
|
236
|
-
currMinutesBtnRef === null || currMinutesBtnRef === void 0 ? void 0 : (_currMinutesBtnRef$cu7 = currMinutesBtnRef.current) === null || _currMinutesBtnRef$cu7 === void 0 ? void 0 : (_currMinutesBtnRef$cu8 = _currMinutesBtnRef$cu7.focus) === null || _currMinutesBtnRef$cu8 === void 0 ? void 0 : _currMinutesBtnRef$cu8.call(_currMinutesBtnRef$cu7);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
240
|
-
if (key === 'End') onEndKeyDownInsideTimeWheel();
|
|
241
|
-
}, [currMinutesBtnRef, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel, prevHourBtnRef, prevMeridiemBtnRef]);
|
|
242
|
-
const handlePrevMeridiemBtnOnKeyDown = useCallback(e => {
|
|
243
|
-
const {
|
|
244
|
-
key
|
|
245
|
-
} = e;
|
|
246
|
-
if (homeEndAllArrowKeys.includes(key)) e.preventDefault();
|
|
247
|
-
if (homeEndAllArrowKeys.includes(key)) e.stopPropagation();
|
|
248
|
-
|
|
249
|
-
if (key === 'ArrowLeft') {
|
|
250
|
-
var _prevMinutesBtnRef$cu3, _prevMinutesBtnRef$cu4;
|
|
251
|
-
|
|
252
|
-
prevMinutesBtnRef === null || prevMinutesBtnRef === void 0 ? void 0 : (_prevMinutesBtnRef$cu3 = prevMinutesBtnRef.current) === null || _prevMinutesBtnRef$cu3 === void 0 ? void 0 : (_prevMinutesBtnRef$cu4 = _prevMinutesBtnRef$cu3.focus) === null || _prevMinutesBtnRef$cu4 === void 0 ? void 0 : _prevMinutesBtnRef$cu4.call(_prevMinutesBtnRef$cu3);
|
|
145
|
+
if (isWithCalendarToo) trackFocusCalendarPrevMonth();else trackFocusTimewheelCurrHour();
|
|
253
146
|
}
|
|
254
|
-
|
|
255
|
-
if (key === 'ArrowDown') {
|
|
256
|
-
var _currMeridiemBtnRef$c9, _currMeridiemBtnRef$c10;
|
|
257
|
-
|
|
258
|
-
currMeridiemBtnRef === null || currMeridiemBtnRef === void 0 ? void 0 : (_currMeridiemBtnRef$c9 = currMeridiemBtnRef.current) === null || _currMeridiemBtnRef$c9 === void 0 ? void 0 : (_currMeridiemBtnRef$c10 = _currMeridiemBtnRef$c9.focus) === null || _currMeridiemBtnRef$c10 === void 0 ? void 0 : _currMeridiemBtnRef$c10.call(_currMeridiemBtnRef$c9);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
262
|
-
if (key === 'End') onEndKeyDownInsideTimeWheel();
|
|
263
|
-
}, [currMeridiemBtnRef, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel, prevMinutesBtnRef]);
|
|
264
|
-
const handleNextHourBtnOnKeyDown = useCallback(e => {
|
|
265
|
-
const {
|
|
266
|
-
key
|
|
267
|
-
} = e;
|
|
268
|
-
if (homeEndAllArrowKeys.includes(key)) e.preventDefault();
|
|
269
|
-
if (homeEndAllArrowKeys.includes(key)) e.stopPropagation();
|
|
270
|
-
|
|
271
|
-
if (key === 'ArrowRight') {
|
|
272
|
-
var _nextMinutesBtnRef$cu, _nextMinutesBtnRef$cu2;
|
|
273
|
-
|
|
274
|
-
nextMinutesBtnRef === null || nextMinutesBtnRef === void 0 ? void 0 : (_nextMinutesBtnRef$cu = nextMinutesBtnRef.current) === null || _nextMinutesBtnRef$cu === void 0 ? void 0 : (_nextMinutesBtnRef$cu2 = _nextMinutesBtnRef$cu.focus) === null || _nextMinutesBtnRef$cu2 === void 0 ? void 0 : _nextMinutesBtnRef$cu2.call(_nextMinutesBtnRef$cu);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (key === 'ArrowUp') {
|
|
278
|
-
var _currHourBtnRef$curre11, _currHourBtnRef$curre12;
|
|
279
|
-
|
|
280
|
-
currHourBtnRef === null || currHourBtnRef === void 0 ? void 0 : (_currHourBtnRef$curre11 = currHourBtnRef.current) === null || _currHourBtnRef$curre11 === void 0 ? void 0 : (_currHourBtnRef$curre12 = _currHourBtnRef$curre11.focus) === null || _currHourBtnRef$curre12 === void 0 ? void 0 : _currHourBtnRef$curre12.call(_currHourBtnRef$curre11);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
284
|
-
if (key === 'End') onEndKeyDownInsideTimeWheel();
|
|
285
|
-
}, [currHourBtnRef, nextMinutesBtnRef, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel]);
|
|
286
|
-
const handleNextMinuteBtnOnKeyDown = useCallback(e => {
|
|
287
|
-
const {
|
|
288
|
-
key
|
|
289
|
-
} = e;
|
|
290
|
-
if (homeEndAllArrowKeys.includes(key)) e.preventDefault();
|
|
291
|
-
if (homeEndAllArrowKeys.includes(key)) e.stopPropagation();
|
|
292
|
-
|
|
293
|
-
if (key === 'ArrowRight') {
|
|
294
|
-
var _nextMeridiemBtnRef$c, _nextMeridiemBtnRef$c2;
|
|
295
|
-
|
|
296
|
-
nextMeridiemBtnRef === null || nextMeridiemBtnRef === void 0 ? void 0 : (_nextMeridiemBtnRef$c = nextMeridiemBtnRef.current) === null || _nextMeridiemBtnRef$c === void 0 ? void 0 : (_nextMeridiemBtnRef$c2 = _nextMeridiemBtnRef$c.focus) === null || _nextMeridiemBtnRef$c2 === void 0 ? void 0 : _nextMeridiemBtnRef$c2.call(_nextMeridiemBtnRef$c);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (key === 'ArrowLeft') {
|
|
300
|
-
var _nextHourBtnRef$curre, _nextHourBtnRef$curre2;
|
|
301
|
-
|
|
302
|
-
nextHourBtnRef === null || nextHourBtnRef === void 0 ? void 0 : (_nextHourBtnRef$curre = nextHourBtnRef.current) === null || _nextHourBtnRef$curre === void 0 ? void 0 : (_nextHourBtnRef$curre2 = _nextHourBtnRef$curre.focus) === null || _nextHourBtnRef$curre2 === void 0 ? void 0 : _nextHourBtnRef$curre2.call(_nextHourBtnRef$curre);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (key === 'ArrowUp') {
|
|
306
|
-
var _currMinutesBtnRef$cu9, _currMinutesBtnRef$cu10;
|
|
307
|
-
|
|
308
|
-
currMinutesBtnRef === null || currMinutesBtnRef === void 0 ? void 0 : (_currMinutesBtnRef$cu9 = currMinutesBtnRef.current) === null || _currMinutesBtnRef$cu9 === void 0 ? void 0 : (_currMinutesBtnRef$cu10 = _currMinutesBtnRef$cu9.focus) === null || _currMinutesBtnRef$cu10 === void 0 ? void 0 : _currMinutesBtnRef$cu10.call(_currMinutesBtnRef$cu9);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
312
|
-
if (key === 'End') onEndKeyDownInsideTimeWheel();
|
|
313
|
-
}, [currMinutesBtnRef, nextHourBtnRef, nextMeridiemBtnRef, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel]);
|
|
314
|
-
const handleNextMeridiemBtnOnKeyDown = useCallback(e => {
|
|
315
|
-
const {
|
|
316
|
-
key
|
|
317
|
-
} = e;
|
|
318
|
-
if (homeEndAllArrowKeys.includes(key)) e.preventDefault();
|
|
319
|
-
if (homeEndAllArrowKeys.includes(key)) e.stopPropagation();
|
|
320
|
-
|
|
321
|
-
if (key === 'ArrowLeft') {
|
|
322
|
-
var _nextMinutesBtnRef$cu3, _nextMinutesBtnRef$cu4;
|
|
323
|
-
|
|
324
|
-
nextMinutesBtnRef === null || nextMinutesBtnRef === void 0 ? void 0 : (_nextMinutesBtnRef$cu3 = nextMinutesBtnRef.current) === null || _nextMinutesBtnRef$cu3 === void 0 ? void 0 : (_nextMinutesBtnRef$cu4 = _nextMinutesBtnRef$cu3.focus) === null || _nextMinutesBtnRef$cu4 === void 0 ? void 0 : _nextMinutesBtnRef$cu4.call(_nextMinutesBtnRef$cu3);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (key === 'ArrowUp') {
|
|
328
|
-
var _currMeridiemBtnRef$c11, _currMeridiemBtnRef$c12;
|
|
329
|
-
|
|
330
|
-
currMeridiemBtnRef === null || currMeridiemBtnRef === void 0 ? void 0 : (_currMeridiemBtnRef$c11 = currMeridiemBtnRef.current) === null || _currMeridiemBtnRef$c11 === void 0 ? void 0 : (_currMeridiemBtnRef$c12 = _currMeridiemBtnRef$c11.focus) === null || _currMeridiemBtnRef$c12 === void 0 ? void 0 : _currMeridiemBtnRef$c12.call(_currMeridiemBtnRef$c11);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (key === 'Home') onHomeKeyDownInsideTimeWheel();
|
|
334
|
-
if (key === 'End') onEndKeyDownInsideTimeWheel();
|
|
335
|
-
}, [currMeridiemBtnRef, nextMinutesBtnRef, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel]);
|
|
147
|
+
}, [handleTimeWheelBtnChangeMeridiem, isControllerOnly, isWithCalendarToo, onEndKeyDownInsideTimeWheel, onHomeKeyDownInsideTimeWheel, trackFocusCalendarPrevMonth, trackFocusTimewheelCurrHour, trackFocusTimewheelCurrMeridiem, trackFocusTimewheelCurrMinute]);
|
|
336
148
|
return useMemo(() => ({
|
|
337
|
-
handlePrevHourBtnOnKeyDown,
|
|
338
149
|
handleCurrHourOnKeyDown,
|
|
339
|
-
handleNextHourBtnOnKeyDown,
|
|
340
|
-
handlePrevMinuteBtnOnKeyDown,
|
|
341
150
|
handleCurrMinutesOnKeyDown,
|
|
342
|
-
handleNextMinuteBtnOnKeyDown,
|
|
343
|
-
handlePrevMeridiemBtnOnKeyDown,
|
|
344
151
|
handleCurrMeridiemOnKeyDown,
|
|
345
|
-
handleNextMeridiemBtnOnKeyDown,
|
|
346
152
|
handlePickerIconKeyDown
|
|
347
|
-
}), [handleCurrHourOnKeyDown, handleCurrMeridiemOnKeyDown, handleCurrMinutesOnKeyDown,
|
|
153
|
+
}), [handleCurrHourOnKeyDown, handleCurrMeridiemOnKeyDown, handleCurrMinutesOnKeyDown, handlePickerIconKeyDown]);
|
|
348
154
|
};
|
|
349
155
|
|
|
350
156
|
export { useKeyboardHandlers };
|
|
@@ -11,8 +11,11 @@ const usePopperTriggerLogic = () => {
|
|
|
11
11
|
onPickerClose,
|
|
12
12
|
onPickerOpen
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
isWithCalendarToo,
|
|
15
|
+
trackFocusTimewheelCurrHour,
|
|
16
|
+
trackFocusPicker,
|
|
17
|
+
latestInteractionRegion,
|
|
18
|
+
currFocusDescriber
|
|
16
19
|
} = useContext(ControlledDateTimePickerContext);
|
|
17
20
|
const [showTimePicker, setShowTimePicker] = useState(false);
|
|
18
21
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
@@ -34,16 +37,12 @@ const usePopperTriggerLogic = () => {
|
|
|
34
37
|
setShowTimePicker(oldShowCalendar => {
|
|
35
38
|
if (!oldShowCalendar) {
|
|
36
39
|
onPickerOpen();
|
|
37
|
-
if (!isWithCalendarToo)
|
|
38
|
-
var _currHourBtnRef$curre, _currHourBtnRef$curre2;
|
|
39
|
-
|
|
40
|
-
return currHourBtnRef === null || currHourBtnRef === void 0 ? void 0 : (_currHourBtnRef$curre = currHourBtnRef.current) === null || _currHourBtnRef$curre === void 0 ? void 0 : (_currHourBtnRef$curre2 = _currHourBtnRef$curre.focus) === null || _currHourBtnRef$curre2 === void 0 ? void 0 : _currHourBtnRef$curre2.call(_currHourBtnRef$curre);
|
|
41
|
-
});
|
|
40
|
+
if (!isWithCalendarToo) trackFocusTimewheelCurrHour();
|
|
42
41
|
} else onPickerClose();
|
|
43
42
|
|
|
44
43
|
return !oldShowCalendar;
|
|
45
44
|
});
|
|
46
|
-
}, [
|
|
45
|
+
}, [isWithCalendarToo, onPickerClose, onPickerOpen, trackFocusTimewheelCurrHour]);
|
|
47
46
|
useOnClickOutside(popperElement, e => {
|
|
48
47
|
var _pickerButtonRef$curr, _pickerButtonRef$curr2;
|
|
49
48
|
|
|
@@ -52,19 +51,18 @@ const usePopperTriggerLogic = () => {
|
|
|
52
51
|
const handleSetTriggerRef = useCallback(newRef => {
|
|
53
52
|
pickerButtonRef.current = newRef;
|
|
54
53
|
setReferenceElement(newRef);
|
|
55
|
-
|
|
54
|
+
if (latestInteractionRegion === 'picker-icon' && currFocusDescriber === 'time-picker-icon') newRef === null || newRef === void 0 ? void 0 : newRef.focus();
|
|
55
|
+
}, [currFocusDescriber, latestInteractionRegion, pickerButtonRef]);
|
|
56
56
|
const handleMenuWrapperKeyDown = useCallback(e => {
|
|
57
57
|
const {
|
|
58
58
|
key
|
|
59
59
|
} = e;
|
|
60
60
|
|
|
61
61
|
if (key === 'Escape') {
|
|
62
|
-
var _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
63
|
-
|
|
64
62
|
closeTimePicker();
|
|
65
|
-
|
|
63
|
+
trackFocusPicker();
|
|
66
64
|
}
|
|
67
|
-
}, [closeTimePicker,
|
|
65
|
+
}, [closeTimePicker, trackFocusPicker]);
|
|
68
66
|
return useMemo(() => ({
|
|
69
67
|
showTimePicker,
|
|
70
68
|
setShowTimePicker,
|
|
@@ -22,7 +22,8 @@ const HHInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
22
22
|
placeholder,
|
|
23
23
|
ariaCurrentValueForInputs,
|
|
24
24
|
contextRef,
|
|
25
|
-
autoFocusHourInput
|
|
25
|
+
autoFocusHourInput,
|
|
26
|
+
isFocused
|
|
26
27
|
} = _ref;
|
|
27
28
|
const validateOnChange = useCallback(e => {
|
|
28
29
|
if (isInvalidHour(e.target.value)) {
|
|
@@ -39,7 +40,12 @@ const HHInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
39
40
|
onFocus: onFocus,
|
|
40
41
|
onKeyDown: onKeyDown,
|
|
41
42
|
value: value,
|
|
42
|
-
ref:
|
|
43
|
+
ref: DomElem => {
|
|
44
|
+
var _DomElem$focus;
|
|
45
|
+
|
|
46
|
+
contextRef.current = DomElem;
|
|
47
|
+
if (isFocused) DomElem === null || DomElem === void 0 ? void 0 : (_DomElem$focus = DomElem.focus) === null || _DomElem$focus === void 0 ? void 0 : _DomElem$focus.call(DomElem);
|
|
48
|
+
},
|
|
43
49
|
placeholder: placeholder,
|
|
44
50
|
"aria-label": "hours input field ".concat(ariaCurrentValueForInputs),
|
|
45
51
|
"data-testid": ControlledDateTimePickerDatatestid.TIME_INPUTS.HOUR,
|
|
@@ -25,7 +25,8 @@ const MeridiemInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
25
25
|
disabled,
|
|
26
26
|
placeholder,
|
|
27
27
|
ariaCurrentValueForInputs,
|
|
28
|
-
contextRef
|
|
28
|
+
contextRef,
|
|
29
|
+
isFocused
|
|
29
30
|
} = _ref;
|
|
30
31
|
const validateOnChange = useCallback(e => {
|
|
31
32
|
var _e$target;
|
|
@@ -43,7 +44,12 @@ const MeridiemInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
43
44
|
onFocus: onFocus,
|
|
44
45
|
onKeyDown: onKeyDown,
|
|
45
46
|
value: value,
|
|
46
|
-
ref:
|
|
47
|
+
ref: DomElem => {
|
|
48
|
+
var _DomElem$focus;
|
|
49
|
+
|
|
50
|
+
contextRef.current = DomElem;
|
|
51
|
+
if (isFocused) DomElem === null || DomElem === void 0 ? void 0 : (_DomElem$focus = DomElem.focus) === null || _DomElem$focus === void 0 ? void 0 : _DomElem$focus.call(DomElem);
|
|
52
|
+
},
|
|
47
53
|
placeholder: placeholder,
|
|
48
54
|
"aria-label": "meridiem input field ".concat(ariaCurrentValueForInputs),
|
|
49
55
|
"data-testid": ControlledDateTimePickerDatatestid.TIME_INPUTS.MERIDIEM,
|
|
@@ -21,7 +21,8 @@ const MinutesInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
21
21
|
disabled,
|
|
22
22
|
placeholder,
|
|
23
23
|
ariaCurrentValueForInputs,
|
|
24
|
-
contextRef
|
|
24
|
+
contextRef,
|
|
25
|
+
isFocused
|
|
25
26
|
} = _ref;
|
|
26
27
|
const validateOnChange = useCallback(e => {
|
|
27
28
|
var _e$target;
|
|
@@ -39,7 +40,12 @@ const MinutesInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
39
40
|
onFocus: onFocus,
|
|
40
41
|
onKeyDown: onKeyDown,
|
|
41
42
|
value: value,
|
|
42
|
-
ref:
|
|
43
|
+
ref: DomElem => {
|
|
44
|
+
var _DomElem$focus;
|
|
45
|
+
|
|
46
|
+
contextRef.current = DomElem;
|
|
47
|
+
if (isFocused) DomElem === null || DomElem === void 0 ? void 0 : (_DomElem$focus = DomElem.focus) === null || _DomElem$focus === void 0 ? void 0 : _DomElem$focus.call(DomElem);
|
|
48
|
+
},
|
|
43
49
|
placeholder: placeholder,
|
|
44
50
|
"aria-label": "minutes input field ".concat(ariaCurrentValueForInputs),
|
|
45
51
|
"data-testid": ControlledDateTimePickerDatatestid.TIME_INPUTS.MINUTE,
|
|
@@ -35,7 +35,9 @@ const TimeInputs = () => {
|
|
|
35
35
|
hourInputRef,
|
|
36
36
|
minutesInputRef,
|
|
37
37
|
meridiemInputRef,
|
|
38
|
-
ariaCurrentValueForInputs
|
|
38
|
+
ariaCurrentValueForInputs,
|
|
39
|
+
latestInteractionRegion,
|
|
40
|
+
currFocusDescriber
|
|
39
41
|
} = useContext(ControlledDateTimePickerContext);
|
|
40
42
|
return /*#__PURE__*/_jsx(Grid, {
|
|
41
43
|
cols: [fixedValues.smallInputWidth, fixedValues.separatorWidth, fixedValues.smallInputWidth, fixedValues.separatorWidth, fixedValues.smallInputWidth]
|
|
@@ -49,29 +51,32 @@ const TimeInputs = () => {
|
|
|
49
51
|
placeholder: "HH",
|
|
50
52
|
ariaCurrentValueForInputs: ariaCurrentValueForInputs,
|
|
51
53
|
autoFocusHourInput: autoFocusHourInput,
|
|
52
|
-
disabled: disabled
|
|
54
|
+
disabled: disabled,
|
|
55
|
+
isFocused: latestInteractionRegion === 'time-inputs' && currFocusDescriber === 'hour-input'
|
|
53
56
|
})), _StyledColonSeparator || (_StyledColonSeparator = /*#__PURE__*/_jsx(StyledColonSeparator, {
|
|
54
57
|
alignItems: "center"
|
|
55
58
|
}, void 0, ":")), /*#__PURE__*/_jsx(StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx(MinutesInput, {
|
|
56
59
|
value: minutes,
|
|
57
60
|
onChange: onMinutesChange,
|
|
58
61
|
onBlur: onMinutesBlur,
|
|
59
|
-
onFocus:
|
|
62
|
+
onFocus: onMinutesFocus,
|
|
60
63
|
onKeyDown: onMinutesKeyDown,
|
|
61
64
|
contextRef: minutesInputRef,
|
|
62
65
|
placeholder: "MM",
|
|
63
66
|
ariaCurrentValueForInputs: ariaCurrentValueForInputs,
|
|
64
|
-
disabled: disabled
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
isFocused: latestInteractionRegion === 'time-inputs' && currFocusDescriber === 'minute-input'
|
|
65
69
|
})), _StyledSeparator || (_StyledSeparator = /*#__PURE__*/_jsx(StyledSeparator, {}, void 0, " ")), /*#__PURE__*/_jsx(StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx(MeridiemInput, {
|
|
66
70
|
value: meridiem,
|
|
67
71
|
onChange: onMeridiemChange,
|
|
68
72
|
onBlur: onMeridiemBlur,
|
|
69
|
-
onFocus:
|
|
73
|
+
onFocus: onMeridiemFocus,
|
|
70
74
|
onKeyDown: onMeridiemKeyDown,
|
|
71
75
|
contextRef: meridiemInputRef,
|
|
72
76
|
placeholder: "AM",
|
|
73
77
|
ariaCurrentValueForInputs: ariaCurrentValueForInputs,
|
|
74
|
-
disabled: disabled
|
|
78
|
+
disabled: disabled,
|
|
79
|
+
isFocused: latestInteractionRegion === 'time-inputs' && currFocusDescriber === 'meridiem-input'
|
|
75
80
|
})));
|
|
76
81
|
};
|
|
77
82
|
|