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