@elliemae/ds-controlled-form 2.4.1 → 2.4.2-rc.3
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/config/useAutocomplete.js +1 -3
- package/cjs/checkbox/ControlledCheckbox.js +49 -33
- package/cjs/checkbox/exported-related/data-test-ids.js +10 -0
- package/cjs/checkbox/exported-related/index.js +12 -0
- package/cjs/checkbox/exported-related/theming.js +13 -0
- package/cjs/checkbox/react-desc-prop-types.js +0 -1
- package/cjs/checkbox/styles.js +26 -15
- package/cjs/combobox/ComboBoxCTX.js +1 -1
- package/cjs/combobox/ComboboxDataTestids.js +1 -1
- package/cjs/combobox/config/useComboBox.js +6 -4
- package/cjs/combobox/index.js +5 -0
- package/cjs/combobox/parts/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/container/Container.js +5 -5
- package/cjs/combobox/parts/container/styled.js +13 -7
- package/cjs/combobox/parts/controls/Controls.js +14 -4
- package/cjs/combobox/parts/controls/styled.js +22 -13
- package/cjs/combobox/parts/controls-input/ControlsInput.js +1 -1
- package/cjs/combobox/parts/controls-input/styled.js +7 -3
- package/cjs/combobox/parts/controls-input/useControlsInput.js +3 -4
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
- package/cjs/combobox/parts/header-list/HeaderList.js +4 -3
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
- package/cjs/combobox/parts/menu-list/MenuList.js +5 -2
- package/cjs/combobox/parts/menu-list/styled.js +12 -7
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +5 -4
- package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
- package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
- package/cjs/combobox/theming.js +13 -0
- package/cjs/combobox/utils/listHelper.js +2 -1
- 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/index.js +16 -7
- package/cjs/input-group/InputGroup.js +69 -0
- package/cjs/input-group/InputGroupDataTestIds.js +12 -0
- package/cjs/input-group/index.js +12 -0
- package/cjs/input-group/react-desc-prop-types.js +14 -0
- package/cjs/input-group/styled.js +46 -0
- package/cjs/mask-hook/hooks/index.js +0 -1
- package/cjs/mask-hook/hooks/usePhoneMask.js +2 -2
- package/cjs/mask-hook/hooks/useRegExpMask.js +0 -1
- package/cjs/mask-hook/index.js +0 -1
- package/cjs/text-input/styled/borders.js +1 -1
- package/esm/autocomplete/config/useAutocomplete.js +3 -5
- package/esm/checkbox/ControlledCheckbox.js +52 -36
- package/esm/checkbox/exported-related/data-test-ids.js +6 -0
- package/esm/checkbox/exported-related/index.js +2 -0
- package/esm/checkbox/exported-related/theming.js +8 -0
- package/esm/checkbox/react-desc-prop-types.js +0 -1
- package/esm/checkbox/styles.js +25 -15
- package/esm/combobox/ComboBoxCTX.js +1 -1
- package/esm/combobox/ComboboxDataTestids.js +1 -1
- package/esm/combobox/config/useComboBox.js +8 -6
- package/esm/combobox/index.js +2 -0
- package/esm/combobox/parts/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/container/Container.js +7 -7
- package/esm/combobox/parts/container/styled.js +13 -6
- package/esm/combobox/parts/controls/Controls.js +14 -4
- package/esm/combobox/parts/controls/styled.js +22 -13
- package/esm/combobox/parts/controls-input/ControlsInput.js +1 -1
- package/esm/combobox/parts/controls-input/styled.js +7 -3
- package/esm/combobox/parts/controls-input/useControlsInput.js +3 -4
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
- package/esm/combobox/parts/header-list/HeaderList.js +4 -3
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
- package/esm/combobox/parts/menu-list/MenuList.js +5 -2
- package/esm/combobox/parts/menu-list/styled.js +12 -7
- package/esm/combobox/parts/menu-list/useItemRenderer.js +5 -4
- package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
- package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
- package/esm/combobox/theming.js +8 -0
- package/esm/combobox/utils/listHelper.js +2 -1
- package/esm/date-range-picker/config/useRangePickerLogic.js +2 -2
- 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 +14 -14
- 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/index.js +5 -1
- package/esm/input-group/InputGroup.js +59 -0
- package/esm/input-group/InputGroupDataTestIds.js +8 -0
- package/esm/input-group/index.js +2 -0
- package/esm/input-group/react-desc-prop-types.js +10 -0
- package/esm/input-group/styled.js +35 -0
- package/esm/mask-hook/hooks/index.js +1 -1
- package/esm/mask-hook/hooks/usePhoneMask.js +2 -2
- package/esm/mask-hook/hooks/useRegExpMask.js +1 -1
- package/esm/mask-hook/index.js +1 -1
- package/esm/text-input/styled/borders.js +1 -1
- package/esm/toggle/ControlledToggle.js +3 -3
- package/package.json +55 -19
- package/types/checkbox/exported-related/data-test-ids.d.ts +4 -0
- package/types/checkbox/exported-related/index.d.ts +2 -0
- package/types/checkbox/exported-related/theming.d.ts +6 -0
- package/types/checkbox/react-desc-prop-types.d.ts +3 -3
- package/types/checkbox/styles.d.ts +5 -5
- package/types/combobox/ComboboxDataTestids.d.ts +1 -1
- package/types/combobox/index.d.ts +2 -0
- package/types/combobox/parts/container/styled.d.ts +1 -2
- package/types/combobox/theming.d.ts +6 -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/index.d.ts +1 -0
- package/types/input-group/InputGroup.d.ts +5 -0
- package/types/input-group/InputGroupDataTestIds.d.ts +6 -0
- package/types/input-group/index.d.ts +2 -0
- package/types/input-group/react-desc-prop-types.d.ts +19 -0
- package/types/input-group/styled.d.ts +7 -0
- package/types/input-group/tests/DSInputGroup.test.d.ts +1 -0
- package/types/mask-hook/hooks/useRegExpMask.d.ts +0 -1
- package/types/text-input/config/useInputText.d.ts +5 -5
- package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -51
- package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -47
- package/types/combobox/parts/menu-list/useMenuListSetFocusOption.d.ts +0 -1
|
@@ -4,7 +4,6 @@ import 'core-js/modules/esnext.iterator.find.js';
|
|
|
4
4
|
import { useContext, useCallback, useMemo } from 'react';
|
|
5
5
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
6
6
|
import { sumValuesToDate } from '../../../utils/dateHelpers.js';
|
|
7
|
-
import { homeEndKeys, homeEndAllArrowKeys } from '../../../utils/constants.js';
|
|
8
7
|
|
|
9
8
|
const useKeyboardHandlers = _ref => {
|
|
10
9
|
let {
|
|
@@ -12,29 +11,26 @@ const useKeyboardHandlers = _ref => {
|
|
|
12
11
|
focusLogic
|
|
13
12
|
} = _ref;
|
|
14
13
|
const {
|
|
15
|
-
hideDate,
|
|
16
|
-
hideTime,
|
|
17
|
-
monthInputRef,
|
|
18
|
-
hourInputRef,
|
|
19
|
-
prevYearBtnRef,
|
|
20
|
-
prevMonthBtnRef,
|
|
21
|
-
nextMonthBtnRef,
|
|
22
|
-
nextYearBtnRef,
|
|
23
|
-
currMeridiemBtnRef,
|
|
24
14
|
isControllerOnly,
|
|
25
15
|
isWithTimeWheelToo,
|
|
26
|
-
setLatestInteractionRegion,
|
|
27
16
|
withAnyInputs,
|
|
28
17
|
isWithTimeInputs,
|
|
29
|
-
meridiemInputRef,
|
|
30
18
|
isWithDateInputs,
|
|
31
|
-
|
|
19
|
+
trackFocusFirstSegment,
|
|
20
|
+
trackFocusMeridiemInput,
|
|
21
|
+
trackFocusYearInput,
|
|
22
|
+
trackFocusCalendarPrevMonth,
|
|
23
|
+
trackFocusCalendarNextMonth,
|
|
24
|
+
trackFocusCalendarNextYear,
|
|
25
|
+
trackFocusCalendarPrevYear,
|
|
26
|
+
trackFocusTimewheelCurrMeridiem,
|
|
27
|
+
trackFocusCalendarMetafocusedDay
|
|
32
28
|
} = useContext(ControlledDateTimePickerContext);
|
|
33
29
|
const {
|
|
34
30
|
focusedDay,
|
|
35
31
|
handleFocusMetaDay,
|
|
36
|
-
handleFocusMetaDayByDay
|
|
37
|
-
|
|
32
|
+
handleFocusMetaDayByDay // tryToFocusCurrentlyDataIsFocusedDay
|
|
33
|
+
|
|
38
34
|
} = focusLogic;
|
|
39
35
|
const {
|
|
40
36
|
daysArray,
|
|
@@ -42,8 +38,6 @@ const useKeyboardHandlers = _ref => {
|
|
|
42
38
|
handleNextMonth
|
|
43
39
|
} = currentDisplayedMonthLogic;
|
|
44
40
|
const tryToFocusDayRegion = useCallback(() => {
|
|
45
|
-
setLatestInteractionRegion('calendar-days');
|
|
46
|
-
|
|
47
41
|
if (!focusedDay) {
|
|
48
42
|
const newFocusDay = daysArray.find(_ref2 => {
|
|
49
43
|
let {
|
|
@@ -51,42 +45,32 @@ const useKeyboardHandlers = _ref => {
|
|
|
51
45
|
} = _ref2;
|
|
52
46
|
return isCurrMonthDay;
|
|
53
47
|
});
|
|
54
|
-
if (newFocusDay)
|
|
55
|
-
handleFocusMetaDay(newFocusDay);
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
tryToFocusCurrentlyDataIsFocusedDay();
|
|
48
|
+
if (newFocusDay) handleFocusMetaDay(newFocusDay);
|
|
59
49
|
}
|
|
60
|
-
}, [daysArray, focusedDay, handleFocusMetaDay, setLatestInteractionRegion, tryToFocusCurrentlyDataIsFocusedDay]);
|
|
61
|
-
const onHomeKeyDownInsideCalendar = useCallback(() => {
|
|
62
|
-
var _prevMonthBtnRef$curr, _prevMonthBtnRef$curr2;
|
|
63
50
|
|
|
64
|
-
|
|
65
|
-
}, [
|
|
51
|
+
trackFocusCalendarMetafocusedDay();
|
|
52
|
+
}, [daysArray, focusedDay, handleFocusMetaDay, trackFocusCalendarMetafocusedDay]);
|
|
53
|
+
const onHomeKeyDownInsideCalendar = useCallback(() => {
|
|
54
|
+
trackFocusCalendarPrevMonth();
|
|
55
|
+
}, [trackFocusCalendarPrevMonth]);
|
|
66
56
|
const onEndKeyDownInsideCalendar = useCallback(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (isWithTimeWheelToo) 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);else tryToFocusDayRegion();
|
|
70
|
-
}, [currMeridiemBtnRef, isWithTimeWheelToo, tryToFocusDayRegion]);
|
|
57
|
+
if (isWithTimeWheelToo) trackFocusTimewheelCurrMeridiem();else tryToFocusDayRegion();
|
|
58
|
+
}, [isWithTimeWheelToo, trackFocusTimewheelCurrMeridiem, tryToFocusDayRegion]);
|
|
71
59
|
const onHomeKeyDownTriggerIcon = useCallback(() => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
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);
|
|
75
|
-
}, [hideDate, hideTime, monthInputRef, hourInputRef]);
|
|
60
|
+
trackFocusFirstSegment();
|
|
61
|
+
}, [trackFocusFirstSegment]);
|
|
76
62
|
const handlePickerIconKeyDown = useCallback(e => {
|
|
77
63
|
const {
|
|
78
64
|
key
|
|
79
65
|
} = e;
|
|
80
|
-
if (
|
|
81
|
-
if (
|
|
66
|
+
if (['Home', 'End'].includes(key)) e.preventDefault();
|
|
67
|
+
if (['Home', 'End'].includes(key)) e.stopPropagation();
|
|
82
68
|
if (key === 'Home') onHomeKeyDownTriggerIcon();
|
|
83
69
|
|
|
84
70
|
if (key === 'Backspace' && withAnyInputs) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
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);
|
|
71
|
+
if (isWithTimeInputs) trackFocusMeridiemInput();else if (isWithDateInputs) trackFocusYearInput();
|
|
88
72
|
}
|
|
89
|
-
}, [isWithDateInputs, isWithTimeInputs,
|
|
73
|
+
}, [isWithDateInputs, isWithTimeInputs, onHomeKeyDownTriggerIcon, trackFocusMeridiemInput, trackFocusYearInput, withAnyInputs]);
|
|
90
74
|
const handleDayOnKeyDown = useCallback((e, metaDay) => {
|
|
91
75
|
let newFocusedDayDate;
|
|
92
76
|
const {
|
|
@@ -96,8 +80,8 @@ const useKeyboardHandlers = _ref => {
|
|
|
96
80
|
key,
|
|
97
81
|
shiftKey
|
|
98
82
|
} = e;
|
|
99
|
-
if (
|
|
100
|
-
if (
|
|
83
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.preventDefault();
|
|
84
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.stopPropagation();
|
|
101
85
|
if (key === 'ArrowUp') newFocusedDayDate = sumValuesToDate(day, {
|
|
102
86
|
daysToSum: -7
|
|
103
87
|
});
|
|
@@ -127,21 +111,18 @@ const useKeyboardHandlers = _ref => {
|
|
|
127
111
|
|
|
128
112
|
if (newFocusedDayDate) {
|
|
129
113
|
handleFocusMetaDayByDay(newFocusedDayDate);
|
|
130
|
-
setTimeout(tryToFocusCurrentlyDataIsFocusedDay);
|
|
131
114
|
}
|
|
132
115
|
|
|
133
116
|
if (key === 'Home') onHomeKeyDownInsideCalendar();
|
|
134
117
|
if (key === 'End') onEndKeyDownInsideCalendar(); // TAB CYCLE IMPLEMENTATION
|
|
135
118
|
|
|
136
119
|
if (key === 'Tab' && !shiftKey && isControllerOnly === false && !isWithTimeWheelToo) {
|
|
137
|
-
var _prevMonthBtnRef$curr3, _prevMonthBtnRef$curr4;
|
|
138
|
-
|
|
139
120
|
// MUST prevent default since this is a custom focus switch
|
|
140
121
|
// NOT preventing the default event will cause unexpected result
|
|
141
122
|
e.preventDefault();
|
|
142
|
-
|
|
123
|
+
trackFocusCalendarPrevMonth();
|
|
143
124
|
}
|
|
144
|
-
}, [daysArray, handleFocusMetaDayByDay, handleNextMonth, handlePrevMonth, isControllerOnly, isWithTimeWheelToo, onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar,
|
|
125
|
+
}, [daysArray, handleFocusMetaDayByDay, handleNextMonth, handlePrevMonth, isControllerOnly, isWithTimeWheelToo, onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarPrevMonth]);
|
|
145
126
|
const handlePrevYearKeyDown = useCallback(e => {
|
|
146
127
|
const {
|
|
147
128
|
key,
|
|
@@ -152,13 +133,9 @@ const useKeyboardHandlers = _ref => {
|
|
|
152
133
|
e.preventDefault();
|
|
153
134
|
|
|
154
135
|
if (shiftKey) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
(_nextMonthBtnRef$curr = nextMonthBtnRef.current) === null || _nextMonthBtnRef$curr === void 0 ? void 0 : _nextMonthBtnRef$curr.focus();
|
|
136
|
+
trackFocusCalendarNextMonth();
|
|
158
137
|
} else {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
(_nextYearBtnRef$curre = nextYearBtnRef.current) === null || _nextYearBtnRef$curre === void 0 ? void 0 : _nextYearBtnRef$curre.focus();
|
|
138
|
+
trackFocusCalendarNextYear();
|
|
162
139
|
}
|
|
163
140
|
}
|
|
164
141
|
|
|
@@ -171,7 +148,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
171
148
|
onEndKeyDownInsideCalendar();
|
|
172
149
|
e.preventDefault();
|
|
173
150
|
}
|
|
174
|
-
}, [
|
|
151
|
+
}, [onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarNextMonth, trackFocusCalendarNextYear]);
|
|
175
152
|
const handlePrevMonthKeyDown = useCallback(e => {
|
|
176
153
|
const {
|
|
177
154
|
key,
|
|
@@ -182,16 +159,12 @@ const useKeyboardHandlers = _ref => {
|
|
|
182
159
|
if (shiftKey) {
|
|
183
160
|
// TAB CYCLE IMPLEMENTATION
|
|
184
161
|
if (!isControllerOnly) {
|
|
185
|
-
var _currMeridiemBtnRef$c3, _currMeridiemBtnRef$c4;
|
|
186
|
-
|
|
187
162
|
e.preventDefault();
|
|
188
|
-
if (isWithTimeWheelToo)
|
|
163
|
+
if (isWithTimeWheelToo) trackFocusTimewheelCurrMeridiem();else tryToFocusDayRegion();
|
|
189
164
|
}
|
|
190
165
|
} else {
|
|
191
|
-
var _nextMonthBtnRef$curr2;
|
|
192
|
-
|
|
193
166
|
e.preventDefault();
|
|
194
|
-
(
|
|
167
|
+
trackFocusCalendarNextMonth();
|
|
195
168
|
}
|
|
196
169
|
}
|
|
197
170
|
|
|
@@ -204,7 +177,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
204
177
|
onEndKeyDownInsideCalendar();
|
|
205
178
|
e.preventDefault();
|
|
206
179
|
}
|
|
207
|
-
}, [
|
|
180
|
+
}, [isControllerOnly, isWithTimeWheelToo, onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarNextMonth, trackFocusTimewheelCurrMeridiem, tryToFocusDayRegion]);
|
|
208
181
|
const handleNextMonthKeyDown = useCallback(e => {
|
|
209
182
|
const {
|
|
210
183
|
key,
|
|
@@ -215,13 +188,9 @@ const useKeyboardHandlers = _ref => {
|
|
|
215
188
|
e.preventDefault();
|
|
216
189
|
|
|
217
190
|
if (shiftKey) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
(_prevMonthBtnRef$curr5 = prevMonthBtnRef.current) === null || _prevMonthBtnRef$curr5 === void 0 ? void 0 : _prevMonthBtnRef$curr5.focus();
|
|
191
|
+
trackFocusCalendarPrevMonth();
|
|
221
192
|
} else {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
(_prevYearBtnRef$curre = prevYearBtnRef.current) === null || _prevYearBtnRef$curre === void 0 ? void 0 : _prevYearBtnRef$curre.focus();
|
|
193
|
+
trackFocusCalendarPrevYear();
|
|
225
194
|
}
|
|
226
195
|
}
|
|
227
196
|
|
|
@@ -234,7 +203,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
234
203
|
onEndKeyDownInsideCalendar();
|
|
235
204
|
e.preventDefault();
|
|
236
205
|
}
|
|
237
|
-
}, [onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar,
|
|
206
|
+
}, [onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarPrevMonth, trackFocusCalendarPrevYear]);
|
|
238
207
|
const handleNextYearKeyDown = useCallback(e => {
|
|
239
208
|
const {
|
|
240
209
|
key,
|
|
@@ -245,9 +214,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
245
214
|
e.preventDefault();
|
|
246
215
|
|
|
247
216
|
if (shiftKey) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
prevYearBtnRef === null || prevYearBtnRef === void 0 ? void 0 : (_prevYearBtnRef$curre2 = prevYearBtnRef.current) === null || _prevYearBtnRef$curre2 === void 0 ? void 0 : (_prevYearBtnRef$curre3 = _prevYearBtnRef$curre2.focus) === null || _prevYearBtnRef$curre3 === void 0 ? void 0 : _prevYearBtnRef$curre3.call(_prevYearBtnRef$curre2);
|
|
217
|
+
trackFocusCalendarPrevYear();
|
|
251
218
|
}
|
|
252
219
|
|
|
253
220
|
if (!shiftKey) tryToFocusDayRegion();
|
|
@@ -262,7 +229,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
262
229
|
onEndKeyDownInsideCalendar();
|
|
263
230
|
e.preventDefault();
|
|
264
231
|
}
|
|
265
|
-
}, [tryToFocusDayRegion,
|
|
232
|
+
}, [tryToFocusDayRegion, trackFocusCalendarPrevYear, onHomeKeyDownInsideCalendar, onEndKeyDownInsideCalendar]);
|
|
266
233
|
return useMemo(() => ({
|
|
267
234
|
handleDayOnKeyDown,
|
|
268
235
|
handlePrevYearKeyDown,
|
|
@@ -12,16 +12,19 @@ const usePopperTriggerLogic = _ref => {
|
|
|
12
12
|
} = _ref;
|
|
13
13
|
const {
|
|
14
14
|
focusedDay,
|
|
15
|
-
resetFocusedDayToStartDate
|
|
16
|
-
tryToFocusCurrentlyDataIsFocusedDay
|
|
15
|
+
resetFocusedDayToStartDate
|
|
17
16
|
} = focusLogic;
|
|
18
17
|
const {
|
|
19
18
|
props: {
|
|
20
19
|
onPickerOpen,
|
|
21
20
|
onPickerClose
|
|
22
21
|
},
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
pickerButtonRef,
|
|
23
|
+
trackFocusCalendarMetafocusedDay,
|
|
24
|
+
trackFocusCalendarPrevMonth,
|
|
25
|
+
trackFocusPicker,
|
|
26
|
+
latestInteractionRegion,
|
|
27
|
+
currFocusDescriber
|
|
25
28
|
} = useContext(ControlledDateTimePickerContext);
|
|
26
29
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
27
30
|
const [popperElement, setPopperElement] = useState(null);
|
|
@@ -37,29 +40,18 @@ const usePopperTriggerLogic = _ref => {
|
|
|
37
40
|
|
|
38
41
|
const handleOnPickerOpen = useCallback(() => {
|
|
39
42
|
onPickerOpen();
|
|
40
|
-
|
|
41
|
-
}, [onPickerOpen, tryToFocusCurrentlyDataIsFocusedDay]);
|
|
43
|
+
}, [onPickerOpen]);
|
|
42
44
|
const openCalendar = useCallback(() => {
|
|
43
|
-
if (focusedDay)
|
|
44
|
-
var _focusedDay$dayBtnRef, _focusedDay$dayBtnRef2, _focusedDay$dayBtnRef3;
|
|
45
|
-
|
|
46
|
-
return focusedDay === null || focusedDay === void 0 ? void 0 : (_focusedDay$dayBtnRef = focusedDay.dayBtnRef) === null || _focusedDay$dayBtnRef === void 0 ? void 0 : (_focusedDay$dayBtnRef2 = _focusedDay$dayBtnRef.current) === null || _focusedDay$dayBtnRef2 === void 0 ? void 0 : (_focusedDay$dayBtnRef3 = _focusedDay$dayBtnRef2.focus) === null || _focusedDay$dayBtnRef3 === void 0 ? void 0 : _focusedDay$dayBtnRef3.call(_focusedDay$dayBtnRef2);
|
|
47
|
-
}, 100);else setTimeout(() => {
|
|
48
|
-
var _prevMonthBtnRef$curr, _prevMonthBtnRef$curr2;
|
|
49
|
-
|
|
50
|
-
return 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);
|
|
51
|
-
}, 100);
|
|
45
|
+
if (focusedDay) trackFocusCalendarMetafocusedDay();else trackFocusCalendarPrevMonth();
|
|
52
46
|
setShowCalendar(true);
|
|
53
47
|
handleOnPickerOpen();
|
|
54
|
-
}, [focusedDay, handleOnPickerOpen,
|
|
48
|
+
}, [focusedDay, handleOnPickerOpen, setShowCalendar, trackFocusCalendarMetafocusedDay, trackFocusCalendarPrevMonth]);
|
|
55
49
|
const closeCalendar = useCallback(() => {
|
|
56
|
-
var _pickerButtonRef$curr, _pickerButtonRef$curr2;
|
|
57
|
-
|
|
58
50
|
setShowCalendar(false);
|
|
59
51
|
onPickerClose();
|
|
60
52
|
resetFocusedDayToStartDate();
|
|
61
|
-
|
|
62
|
-
}, [setShowCalendar, onPickerClose, resetFocusedDayToStartDate,
|
|
53
|
+
trackFocusPicker();
|
|
54
|
+
}, [setShowCalendar, onPickerClose, resetFocusedDayToStartDate, trackFocusPicker]);
|
|
63
55
|
const handleToggleCalendar = useCallback(() => {
|
|
64
56
|
const isOpening = !showCalendar;
|
|
65
57
|
if (isOpening) openCalendar();else closeCalendar();
|
|
@@ -67,23 +59,22 @@ const usePopperTriggerLogic = _ref => {
|
|
|
67
59
|
const handleSetTriggerRef = useCallback(newRef => {
|
|
68
60
|
pickerButtonRef.current = newRef;
|
|
69
61
|
setReferenceElement(newRef);
|
|
70
|
-
|
|
62
|
+
if (latestInteractionRegion === 'picker-icon' && currFocusDescriber === 'date-picker-icon') newRef === null || newRef === void 0 ? void 0 : newRef.focus();
|
|
63
|
+
}, [currFocusDescriber, latestInteractionRegion, pickerButtonRef]);
|
|
71
64
|
const handleMenuWrapperKeyDown = useCallback(e => {
|
|
72
65
|
const {
|
|
73
66
|
key
|
|
74
67
|
} = e;
|
|
75
68
|
|
|
76
69
|
if (key === 'Escape') {
|
|
77
|
-
var _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
78
|
-
|
|
79
70
|
closeCalendar();
|
|
80
|
-
|
|
71
|
+
trackFocusPicker();
|
|
81
72
|
}
|
|
82
|
-
}, [closeCalendar,
|
|
73
|
+
}, [closeCalendar, trackFocusPicker]);
|
|
83
74
|
useOnClickOutside(popperElement, e => {
|
|
84
|
-
var _pickerButtonRef$
|
|
75
|
+
var _pickerButtonRef$curr, _pickerButtonRef$curr2;
|
|
85
76
|
|
|
86
|
-
if (e.target instanceof Element && !(pickerButtonRef !== null && pickerButtonRef !== void 0 && (_pickerButtonRef$
|
|
77
|
+
if (e.target instanceof Element && !(pickerButtonRef !== null && pickerButtonRef !== void 0 && (_pickerButtonRef$curr = pickerButtonRef.current) !== null && _pickerButtonRef$curr !== void 0 && (_pickerButtonRef$curr2 = _pickerButtonRef$curr.contains) !== null && _pickerButtonRef$curr2 !== void 0 && _pickerButtonRef$curr2.call(_pickerButtonRef$curr, e === null || e === void 0 ? void 0 : e.target))) closeCalendar();
|
|
87
78
|
});
|
|
88
79
|
return useMemo(() => ({
|
|
89
80
|
closeCalendar,
|
package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js
CHANGED
|
@@ -21,6 +21,7 @@ const CalendarWithTimeWheelIconTrigger = () => {
|
|
|
21
21
|
return useMemo(() => /*#__PURE__*/_jsx(StyledIconTriggerButton, {
|
|
22
22
|
"aria-label": "date time picker context menu trigger, ".concat(ariaCurrentValueForInputs),
|
|
23
23
|
buttonType: "icon",
|
|
24
|
+
type: "button",
|
|
24
25
|
size: BUTTON_SIZES.M,
|
|
25
26
|
innerRef: handleSetTriggerRef,
|
|
26
27
|
onClick: handleToggleCalendarWithTimeWheel,
|
|
@@ -6,7 +6,6 @@ import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePick
|
|
|
6
6
|
import { useOnClickOutside } from '../../../utils/hooks/useOnClickOutside.js';
|
|
7
7
|
import { CalendarContext } from '../Calendar/CalendarContext.js';
|
|
8
8
|
import { TimeWheelContext } from '../TimeWheel/TimeWheelContext.js';
|
|
9
|
-
import { homeEndKeys } from '../../../utils/constants.js';
|
|
10
9
|
|
|
11
10
|
const useConfigCalendarWithTimeWheelCTX = () => {
|
|
12
11
|
const {
|
|
@@ -17,15 +16,15 @@ const useConfigCalendarWithTimeWheelCTX = () => {
|
|
|
17
16
|
onPickerClose,
|
|
18
17
|
disabled
|
|
19
18
|
},
|
|
20
|
-
hideDate,
|
|
21
|
-
hideTime,
|
|
22
|
-
monthInputRef,
|
|
23
|
-
hourInputRef,
|
|
24
19
|
withAnyInputs,
|
|
25
20
|
isWithTimeInputs,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
ariaCurrentValueForInputs,
|
|
22
|
+
trackFocusFirstSegment,
|
|
23
|
+
trackFocusMeridiemInput,
|
|
24
|
+
trackFocusYearInput,
|
|
25
|
+
trackFocusPicker,
|
|
26
|
+
latestInteractionRegion,
|
|
27
|
+
currFocusDescriber
|
|
29
28
|
} = useContext(ControlledDateTimePickerContext);
|
|
30
29
|
const {
|
|
31
30
|
handleToggleCalendar
|
|
@@ -35,24 +34,20 @@ const useConfigCalendarWithTimeWheelCTX = () => {
|
|
|
35
34
|
} = useContext(TimeWheelContext);
|
|
36
35
|
const [showCalendarWithTimeWheel, setShowCalendarWithTimeWheel] = useState(false);
|
|
37
36
|
const onHomeKeyDown = useCallback(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
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);
|
|
41
|
-
}, [hideDate, hideTime, monthInputRef, hourInputRef]);
|
|
37
|
+
trackFocusFirstSegment();
|
|
38
|
+
}, [trackFocusFirstSegment]);
|
|
42
39
|
const handlePickerIconKeyDown = useCallback(e => {
|
|
43
40
|
const {
|
|
44
41
|
key
|
|
45
42
|
} = e;
|
|
46
|
-
if (
|
|
47
|
-
if (
|
|
43
|
+
if (['Home', 'End'].includes(key)) e.preventDefault();
|
|
44
|
+
if (['Home', 'End'].includes(key)) e.stopPropagation();
|
|
48
45
|
if (key === 'Home') onHomeKeyDown();
|
|
49
46
|
|
|
50
47
|
if (key === 'Backspace' && withAnyInputs) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
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 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 trackFocusYearInput();
|
|
54
49
|
}
|
|
55
|
-
}, [isWithTimeInputs,
|
|
50
|
+
}, [isWithTimeInputs, onHomeKeyDown, trackFocusMeridiemInput, trackFocusYearInput, withAnyInputs]);
|
|
56
51
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
57
52
|
const [popperElement, setPopperElement] = useState(null);
|
|
58
53
|
const [arrowElement, setArrowElement] = useState(null);
|
|
@@ -87,19 +82,18 @@ const useConfigCalendarWithTimeWheelCTX = () => {
|
|
|
87
82
|
const handleSetTriggerRef = useCallback(newRef => {
|
|
88
83
|
pickerButtonRef.current = newRef;
|
|
89
84
|
setReferenceElement(newRef);
|
|
90
|
-
|
|
85
|
+
if (latestInteractionRegion === 'picker-icon' && currFocusDescriber === 'datetime-picker-icon') newRef === null || newRef === void 0 ? void 0 : newRef.focus();
|
|
86
|
+
}, [currFocusDescriber, latestInteractionRegion, pickerButtonRef]);
|
|
91
87
|
const handleMenuWrapperKeyDown = useCallback(e => {
|
|
92
88
|
const {
|
|
93
89
|
key
|
|
94
90
|
} = e;
|
|
95
91
|
|
|
96
92
|
if (key === 'Escape') {
|
|
97
|
-
var _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
98
|
-
|
|
99
93
|
closeCalendar();
|
|
100
|
-
|
|
94
|
+
trackFocusPicker();
|
|
101
95
|
}
|
|
102
|
-
}, [closeCalendar,
|
|
96
|
+
}, [closeCalendar, trackFocusPicker]);
|
|
103
97
|
const isControllerOnly = useMemo(() => type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.CONTROLLER_ONLY, [type]);
|
|
104
98
|
return useMemo(() => ({
|
|
105
99
|
showCalendarWithTimeWheel,
|
|
@@ -7,7 +7,7 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
7
7
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
8
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
9
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
-
import { useContext } from 'react';
|
|
10
|
+
import { useContext, useCallback } from 'react';
|
|
11
11
|
import { ChevronSmallUp, ChevronSmallDown } from '@elliemae/ds-icons';
|
|
12
12
|
import { ControlledDateTimePickerDatatestid } from '../../../ControlledDateTimePickerDatatestid.js';
|
|
13
13
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
@@ -30,9 +30,7 @@ const HoursList = () => {
|
|
|
30
30
|
handlePrevHour,
|
|
31
31
|
handleNextHour,
|
|
32
32
|
handleTimeWheelBtnChangeHours,
|
|
33
|
-
|
|
34
|
-
handleCurrHourOnKeyDown,
|
|
35
|
-
handleNextHourBtnOnKeyDown
|
|
33
|
+
handleCurrHourOnKeyDown
|
|
36
34
|
} = useContext(TimeWheelContext);
|
|
37
35
|
const {
|
|
38
36
|
prevHourBtnRef,
|
|
@@ -40,14 +38,23 @@ const HoursList = () => {
|
|
|
40
38
|
nextHourBtnRef,
|
|
41
39
|
getIsDisabledTime,
|
|
42
40
|
autoFocusHourTimeWheel,
|
|
43
|
-
hours
|
|
41
|
+
hours,
|
|
42
|
+
latestInteractionRegion,
|
|
43
|
+
currFocusDescriber
|
|
44
44
|
} = useContext(ControlledDateTimePickerContext);
|
|
45
|
+
const handleCurrYearRef = useCallback(ButtonDomNode => {
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
var _ButtonDomNode$focus;
|
|
48
|
+
|
|
49
|
+
currHourBtnRef.current = ButtonDomNode;
|
|
50
|
+
if (latestInteractionRegion === 'timewheel' && currFocusDescriber === 'timewheel-curr-hour') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
|
|
51
|
+
});
|
|
52
|
+
}, [currFocusDescriber, latestInteractionRegion, currHourBtnRef]);
|
|
45
53
|
return /*#__PURE__*/_jsx(StyledWheelList, {}, void 0, /*#__PURE__*/_jsx(StyledWheelListItem, {}, void 0, /*#__PURE__*/_jsx(StyledWheelChangeTimeBtn, {
|
|
46
54
|
"aria-label": "subtract one hour",
|
|
47
55
|
buttonType: "raw",
|
|
48
56
|
size: "m",
|
|
49
57
|
onClick: handlePrevHour,
|
|
50
|
-
onKeyDown: handlePrevHourBtnOnKeyDown,
|
|
51
58
|
innerRef: prevHourBtnRef,
|
|
52
59
|
"data-testid": ControlledDateTimePickerDatatestid.TIMEWHEEL.PREV_HOUR,
|
|
53
60
|
tabIndex: -1
|
|
@@ -61,7 +68,7 @@ const HoursList = () => {
|
|
|
61
68
|
const tabIndex = isCurrentListItem ? 0 : -1;
|
|
62
69
|
const btnProps = {
|
|
63
70
|
onKeyDown: isCurrentListItem ? handleCurrHourOnKeyDown : undefined,
|
|
64
|
-
innerRef: isCurrentListItem ?
|
|
71
|
+
innerRef: isCurrentListItem ? handleCurrYearRef : undefined
|
|
65
72
|
};
|
|
66
73
|
const styleProps = {
|
|
67
74
|
isCurrentListItem,
|
|
@@ -92,7 +99,6 @@ const HoursList = () => {
|
|
|
92
99
|
buttonType: "raw",
|
|
93
100
|
size: "m",
|
|
94
101
|
onClick: handleNextHour,
|
|
95
|
-
onKeyDown: handleNextHourBtnOnKeyDown,
|
|
96
102
|
innerRef: nextHourBtnRef,
|
|
97
103
|
tabIndex: -1,
|
|
98
104
|
"data-testid": ControlledDateTimePickerDatatestid.TIMEWHEEL.NEXT_HOUR
|
|
@@ -5,7 +5,7 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
-
import { useContext } from 'react';
|
|
8
|
+
import { useContext, useCallback } from 'react';
|
|
9
9
|
import { ChevronSmallUp, ChevronSmallDown } from '@elliemae/ds-icons';
|
|
10
10
|
import { ControlledDateTimePickerDatatestid } from '../../../ControlledDateTimePickerDatatestid.js';
|
|
11
11
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
@@ -22,9 +22,7 @@ const MeridiemList = () => {
|
|
|
22
22
|
const {
|
|
23
23
|
currMeridiem,
|
|
24
24
|
handleTimeWheelBtnChangeMeridiem,
|
|
25
|
-
|
|
26
|
-
handleCurrMeridiemOnKeyDown,
|
|
27
|
-
handleNextMeridiemBtnOnKeyDown
|
|
25
|
+
handleCurrMeridiemOnKeyDown
|
|
28
26
|
} = useContext(TimeWheelContext);
|
|
29
27
|
const {
|
|
30
28
|
prevMeridiemBtnRef,
|
|
@@ -32,7 +30,9 @@ const MeridiemList = () => {
|
|
|
32
30
|
nextMeridiemBtnRef,
|
|
33
31
|
getIsDisabledTime,
|
|
34
32
|
hours,
|
|
35
|
-
minutes
|
|
33
|
+
minutes,
|
|
34
|
+
latestInteractionRegion,
|
|
35
|
+
currFocusDescriber
|
|
36
36
|
} = useContext(ControlledDateTimePickerContext);
|
|
37
37
|
const isAmCurrent = !currMeridiem || currMeridiem === 'AM';
|
|
38
38
|
const isPmCurrent = currMeridiem === 'PM';
|
|
@@ -55,6 +55,14 @@ const MeridiemList = () => {
|
|
|
55
55
|
const styledPropsNextMeridiem = {
|
|
56
56
|
isDisabled: isDisabledPm
|
|
57
57
|
};
|
|
58
|
+
const handleCurrMeridiemRef = useCallback(ButtonDomNode => {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
var _ButtonDomNode$focus;
|
|
61
|
+
|
|
62
|
+
currMeridiemBtnRef.current = ButtonDomNode;
|
|
63
|
+
if (latestInteractionRegion === 'timewheel' && currFocusDescriber === 'timewheel-curr-meridiem') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
|
|
64
|
+
});
|
|
65
|
+
}, [currFocusDescriber, latestInteractionRegion, currMeridiemBtnRef]);
|
|
58
66
|
return /*#__PURE__*/_jsx(StyledWheelList, {}, void 0, /*#__PURE__*/_jsx(StyledWheelListItem, {}, void 0, /*#__PURE__*/jsx(StyledWheelChangeTimeBtn, _objectSpread(_objectSpread({}, styledPropsPrevMeridiem), {}, {
|
|
59
67
|
"aria-label": "set am meridiem",
|
|
60
68
|
"aria-disabled": isDisabledAm,
|
|
@@ -62,7 +70,6 @@ const MeridiemList = () => {
|
|
|
62
70
|
buttonType: "raw",
|
|
63
71
|
size: "m",
|
|
64
72
|
onClick: e => handleTimeWheelBtnChangeMeridiem('AM', e),
|
|
65
|
-
onKeyDown: handlePrevMeridiemBtnOnKeyDown,
|
|
66
73
|
innerRef: prevMeridiemBtnRef,
|
|
67
74
|
tabIndex: -1,
|
|
68
75
|
children: _ChevronSmallUp || (_ChevronSmallUp = /*#__PURE__*/_jsx(ChevronSmallUp, {}))
|
|
@@ -77,7 +84,7 @@ const MeridiemList = () => {
|
|
|
77
84
|
size: "m",
|
|
78
85
|
onClick: e => handleTimeWheelBtnChangeMeridiem('AM', e),
|
|
79
86
|
onKeyDown: isAmCurrent ? handleCurrMeridiemOnKeyDown : undefined,
|
|
80
|
-
innerRef: isAmCurrent ?
|
|
87
|
+
innerRef: isAmCurrent ? handleCurrMeridiemRef : undefined,
|
|
81
88
|
tabIndex: isAmCurrent ? 0 : -1,
|
|
82
89
|
role: "spinbutton",
|
|
83
90
|
"aria-valuemax": 1,
|
|
@@ -96,7 +103,7 @@ const MeridiemList = () => {
|
|
|
96
103
|
size: "m",
|
|
97
104
|
onClick: e => handleTimeWheelBtnChangeMeridiem('PM', e),
|
|
98
105
|
onKeyDown: isPmCurrent ? handleCurrMeridiemOnKeyDown : undefined,
|
|
99
|
-
innerRef: isPmCurrent ?
|
|
106
|
+
innerRef: isPmCurrent ? handleCurrMeridiemRef : undefined,
|
|
100
107
|
tabIndex: isPmCurrent ? 0 : -1,
|
|
101
108
|
role: "spinbutton",
|
|
102
109
|
"aria-valuemax": 1,
|
|
@@ -111,7 +118,6 @@ const MeridiemList = () => {
|
|
|
111
118
|
buttonType: "raw",
|
|
112
119
|
size: "m",
|
|
113
120
|
onClick: e => handleTimeWheelBtnChangeMeridiem('PM', e),
|
|
114
|
-
onKeyDown: handleNextMeridiemBtnOnKeyDown,
|
|
115
121
|
innerRef: nextMeridiemBtnRef,
|
|
116
122
|
tabIndex: -1,
|
|
117
123
|
children: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx(ChevronSmallDown, {}))
|
|
@@ -7,7 +7,7 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
7
7
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
8
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
9
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
-
import { useContext } from 'react';
|
|
10
|
+
import { useContext, useCallback } from 'react';
|
|
11
11
|
import { ChevronSmallUp, ChevronSmallDown } from '@elliemae/ds-icons';
|
|
12
12
|
import { ControlledDateTimePickerDatatestid } from '../../../ControlledDateTimePickerDatatestid.js';
|
|
13
13
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
@@ -30,23 +30,30 @@ const MinutesList = () => {
|
|
|
30
30
|
handlePrevMinute,
|
|
31
31
|
handleNextMinute,
|
|
32
32
|
handleTimeWheelBtnChangeMinutes,
|
|
33
|
-
|
|
34
|
-
handleCurrMinutesOnKeyDown,
|
|
35
|
-
handleNextMinuteBtnOnKeyDown
|
|
33
|
+
handleCurrMinutesOnKeyDown
|
|
36
34
|
} = useContext(TimeWheelContext);
|
|
37
35
|
const {
|
|
38
36
|
prevMinutesBtnRef,
|
|
39
37
|
currMinutesBtnRef,
|
|
40
38
|
nextMinutesBtnRef,
|
|
41
39
|
getIsDisabledTime,
|
|
42
|
-
minutes
|
|
40
|
+
minutes,
|
|
41
|
+
currFocusDescriber,
|
|
42
|
+
latestInteractionRegion
|
|
43
43
|
} = useContext(ControlledDateTimePickerContext);
|
|
44
|
+
const handleCurrMeridiemRef = useCallback(ButtonDomNode => {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
var _ButtonDomNode$focus;
|
|
47
|
+
|
|
48
|
+
currMinutesBtnRef.current = ButtonDomNode;
|
|
49
|
+
if (latestInteractionRegion === 'timewheel' && currFocusDescriber === 'timewheel-curr-minute') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
|
|
50
|
+
});
|
|
51
|
+
}, [currFocusDescriber, latestInteractionRegion, currMinutesBtnRef]);
|
|
44
52
|
return /*#__PURE__*/_jsx(StyledWheelList, {}, void 0, /*#__PURE__*/_jsx(StyledWheelListItem, {}, void 0, /*#__PURE__*/_jsx(StyledWheelChangeTimeBtn, {
|
|
45
53
|
"aria-label": "subtract one minute",
|
|
46
54
|
buttonType: "raw",
|
|
47
55
|
size: "m",
|
|
48
56
|
onClick: handlePrevMinute,
|
|
49
|
-
onKeyDown: handlePrevMinuteBtnOnKeyDown,
|
|
50
57
|
innerRef: prevMinutesBtnRef,
|
|
51
58
|
tabIndex: -1,
|
|
52
59
|
"data-testid": ControlledDateTimePickerDatatestid.TIMEWHEEL.PREV_MINUTE
|
|
@@ -60,7 +67,7 @@ const MinutesList = () => {
|
|
|
60
67
|
const tabIndex = isCurrentListItem ? 0 : -1;
|
|
61
68
|
const btnProps = {
|
|
62
69
|
onKeyDown: isCurrentListItem ? handleCurrMinutesOnKeyDown : undefined,
|
|
63
|
-
innerRef: isCurrentListItem ?
|
|
70
|
+
innerRef: isCurrentListItem ? handleCurrMeridiemRef : undefined
|
|
64
71
|
};
|
|
65
72
|
const styledProps = {
|
|
66
73
|
isCurrentListItem,
|
|
@@ -91,7 +98,6 @@ const MinutesList = () => {
|
|
|
91
98
|
buttonType: "raw",
|
|
92
99
|
size: "m",
|
|
93
100
|
onClick: handleNextMinute,
|
|
94
|
-
onKeyDown: handleNextMinuteBtnOnKeyDown,
|
|
95
101
|
innerRef: nextMinutesBtnRef,
|
|
96
102
|
"data-testid": ControlledDateTimePickerDatatestid.TIMEWHEEL.NEXT_MINUTE,
|
|
97
103
|
tabIndex: -1
|