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