@elliemae/ds-controlled-form 2.4.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 (231) hide show
  1. package/cjs/autocomplete/config/useAutocomplete.js +1 -3
  2. package/cjs/autocomplete/parts/A11yFocusedOption.js +43 -0
  3. package/cjs/autocomplete/parts/container/Container.js +36 -24
  4. package/cjs/autocomplete/parts/container/styled.js +2 -2
  5. package/cjs/autocomplete/parts/menu-list/MenuList.js +4 -2
  6. package/cjs/autocomplete/parts/styled.js +2 -0
  7. package/cjs/autocomplete/utils/listHelper.js +1 -1
  8. package/cjs/checkbox/ControlledCheckbox.js +49 -33
  9. package/cjs/checkbox/exported-related/data-test-ids.js +10 -0
  10. package/cjs/checkbox/exported-related/index.js +12 -0
  11. package/cjs/checkbox/exported-related/theming.js +13 -0
  12. package/cjs/checkbox/react-desc-prop-types.js +2 -2
  13. package/cjs/checkbox/styles.js +28 -15
  14. package/cjs/combobox/ComboBoxCTX.js +7 -4
  15. package/cjs/combobox/ComboboxDataTestids.js +1 -1
  16. package/cjs/combobox/config/useComboBox.js +21 -8
  17. package/cjs/combobox/index.js +5 -0
  18. package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
  19. package/cjs/combobox/parts/A11ySelectedValues.js +0 -2
  20. package/cjs/combobox/parts/DropdownIndicator.js +4 -4
  21. package/cjs/combobox/parts/container/Container.js +14 -17
  22. package/cjs/combobox/parts/container/styled.js +13 -7
  23. package/cjs/combobox/parts/controls/Controls.js +22 -14
  24. package/cjs/combobox/parts/controls/styled.js +22 -13
  25. package/cjs/combobox/parts/controls/useOnPillsNavigation.js +3 -3
  26. package/cjs/combobox/parts/controls-input/ControlsInput.js +3 -3
  27. package/cjs/combobox/parts/controls-input/styled.js +7 -3
  28. package/cjs/combobox/parts/controls-input/useControlsInput.js +5 -5
  29. package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +37 -29
  30. package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +6 -6
  31. package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
  32. package/cjs/combobox/parts/header-list/HeaderList.js +4 -3
  33. package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +11 -7
  34. package/cjs/combobox/parts/menu-list/MenuList.js +10 -5
  35. package/cjs/combobox/parts/menu-list/styled.js +16 -9
  36. package/cjs/combobox/parts/menu-list/useItemRenderer.js +17 -15
  37. package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
  38. package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
  39. package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
  40. package/cjs/combobox/react-desc-prop-types.js +3 -2
  41. package/cjs/combobox/theming.js +13 -0
  42. package/cjs/combobox/utils/listHelper.js +12 -1
  43. package/cjs/date-time-picker/config/useChangeHandlers.js +8 -12
  44. package/cjs/date-time-picker/config/useControlledDateTimePicker.js +13 -9
  45. package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
  46. package/cjs/date-time-picker/config/useGetReferences.js +40 -19
  47. package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
  48. package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +12 -2
  49. package/cjs/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
  50. package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
  51. package/cjs/date-time-picker/parts/DateInputs/DDInput.js +8 -2
  52. package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
  53. package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -2
  54. package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
  55. package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +76 -95
  56. package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +31 -5
  57. package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
  58. package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -12
  59. package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -38
  60. package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
  61. package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
  62. package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
  63. package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
  64. package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +13 -7
  65. package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +14 -8
  66. package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +13 -7
  67. package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
  68. package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
  69. package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
  70. package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
  71. package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
  72. package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
  73. package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
  74. package/cjs/date-time-picker/utils/constants.js +0 -12
  75. package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
  76. package/cjs/index.js +16 -7
  77. package/cjs/input-group/InputGroup.js +70 -0
  78. package/cjs/input-group/InputGroupDataTestIds.js +12 -0
  79. package/cjs/input-group/exported-related/data-test-ids.js +12 -0
  80. package/cjs/input-group/exported-related/index.js +12 -0
  81. package/cjs/input-group/exported-related/theming.js +13 -0
  82. package/cjs/input-group/index.js +12 -0
  83. package/cjs/input-group/react-desc-prop-types.js +14 -0
  84. package/cjs/input-group/styled.js +47 -0
  85. package/cjs/mask-hook/hooks/index.js +0 -1
  86. package/cjs/mask-hook/hooks/usePhoneMask.js +2 -2
  87. package/cjs/mask-hook/hooks/useRegExpMask.js +0 -1
  88. package/cjs/mask-hook/index.js +0 -1
  89. package/cjs/text-input/styled/borders.js +1 -1
  90. package/esm/autocomplete/config/useAutocomplete.js +1 -3
  91. package/esm/autocomplete/parts/A11yFocusedOption.js +32 -0
  92. package/esm/autocomplete/parts/container/Container.js +39 -27
  93. package/esm/autocomplete/parts/container/styled.js +2 -2
  94. package/esm/autocomplete/parts/menu-list/MenuList.js +5 -3
  95. package/esm/autocomplete/parts/styled.js +1 -0
  96. package/esm/autocomplete/utils/listHelper.js +1 -1
  97. package/esm/checkbox/ControlledCheckbox.js +52 -36
  98. package/esm/checkbox/exported-related/data-test-ids.js +6 -0
  99. package/esm/checkbox/exported-related/index.js +2 -0
  100. package/esm/checkbox/exported-related/theming.js +8 -0
  101. package/esm/checkbox/react-desc-prop-types.js +2 -2
  102. package/esm/checkbox/styles.js +26 -15
  103. package/esm/combobox/ComboBoxCTX.js +7 -4
  104. package/esm/combobox/ComboboxDataTestids.js +1 -1
  105. package/esm/combobox/config/useComboBox.js +22 -9
  106. package/esm/combobox/index.js +2 -0
  107. package/esm/combobox/parts/A11yFocusedOption.js +15 -7
  108. package/esm/combobox/parts/A11ySelectedValues.js +0 -2
  109. package/esm/combobox/parts/DropdownIndicator.js +4 -4
  110. package/esm/combobox/parts/container/Container.js +16 -19
  111. package/esm/combobox/parts/container/styled.js +13 -6
  112. package/esm/combobox/parts/controls/Controls.js +22 -14
  113. package/esm/combobox/parts/controls/styled.js +22 -13
  114. package/esm/combobox/parts/controls/useOnPillsNavigation.js +3 -3
  115. package/esm/combobox/parts/controls-input/ControlsInput.js +3 -3
  116. package/esm/combobox/parts/controls-input/styled.js +7 -3
  117. package/esm/combobox/parts/controls-input/useControlsInput.js +5 -5
  118. package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +38 -30
  119. package/esm/combobox/parts/controls-input/useMaskedOnChange.js +6 -6
  120. package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
  121. package/esm/combobox/parts/header-list/HeaderList.js +4 -3
  122. package/esm/combobox/parts/header-list/useHeaderListHandlers.js +11 -7
  123. package/esm/combobox/parts/menu-list/MenuList.js +10 -5
  124. package/esm/combobox/parts/menu-list/styled.js +16 -10
  125. package/esm/combobox/parts/menu-list/useItemRenderer.js +19 -17
  126. package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
  127. package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
  128. package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
  129. package/esm/combobox/react-desc-prop-types.js +3 -2
  130. package/esm/combobox/theming.js +8 -0
  131. package/esm/combobox/utils/listHelper.js +12 -2
  132. package/esm/date-time-picker/config/useChangeHandlers.js +8 -12
  133. package/esm/date-time-picker/config/useControlledDateTimePicker.js +13 -9
  134. package/esm/date-time-picker/config/useFocusTracker.js +132 -0
  135. package/esm/date-time-picker/config/useGetReferences.js +41 -20
  136. package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
  137. package/esm/date-time-picker/parts/ClearButton/ClearButton.js +12 -2
  138. package/esm/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
  139. package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
  140. package/esm/date-time-picker/parts/DateInputs/DDInput.js +8 -2
  141. package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
  142. package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -2
  143. package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
  144. package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +77 -96
  145. package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +32 -6
  146. package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
  147. package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -12
  148. package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -39
  149. package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
  150. package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
  151. package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
  152. package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
  153. package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +14 -8
  154. package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +15 -9
  155. package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +14 -8
  156. package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
  157. package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
  158. package/esm/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
  159. package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
  160. package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
  161. package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
  162. package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
  163. package/esm/date-time-picker/utils/constants.js +1 -7
  164. package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
  165. package/esm/index.js +5 -1
  166. package/esm/input-group/InputGroup.js +60 -0
  167. package/esm/input-group/InputGroupDataTestIds.js +8 -0
  168. package/esm/input-group/exported-related/data-test-ids.js +8 -0
  169. package/esm/input-group/exported-related/index.js +2 -0
  170. package/esm/input-group/exported-related/theming.js +8 -0
  171. package/esm/input-group/index.js +2 -0
  172. package/esm/input-group/react-desc-prop-types.js +10 -0
  173. package/esm/input-group/styled.js +36 -0
  174. package/esm/mask-hook/hooks/index.js +1 -1
  175. package/esm/mask-hook/hooks/usePhoneMask.js +2 -2
  176. package/esm/mask-hook/hooks/useRegExpMask.js +1 -1
  177. package/esm/mask-hook/index.js +1 -1
  178. package/esm/text-input/styled/borders.js +1 -1
  179. package/package.json +75 -19
  180. package/types/autocomplete/parts/A11yFocusedOption.d.ts +5 -0
  181. package/types/autocomplete/parts/container/styled.d.ts +1 -1
  182. package/types/autocomplete/parts/styled.d.ts +0 -0
  183. package/types/autocomplete/utils/listHelper.d.ts +5 -5
  184. package/types/checkbox/exported-related/data-test-ids.d.ts +4 -0
  185. package/types/checkbox/exported-related/index.d.ts +2 -0
  186. package/types/checkbox/exported-related/theming.d.ts +6 -0
  187. package/types/checkbox/react-desc-prop-types.d.ts +4 -4
  188. package/types/checkbox/styles.d.ts +6 -5
  189. package/types/combobox/ComboboxDataTestids.d.ts +1 -1
  190. package/types/combobox/index.d.ts +2 -0
  191. package/types/combobox/parts/container/styled.d.ts +1 -2
  192. package/types/combobox/parts/menu-list/styled.d.ts +1 -0
  193. package/types/combobox/react-desc-prop-types.d.ts +8 -6
  194. package/types/combobox/sharedTypes.d.ts +3 -2
  195. package/types/combobox/theming.d.ts +6 -0
  196. package/types/combobox/utils/listHelper.d.ts +1 -0
  197. package/types/date-time-picker/config/useChangeHandlers.d.ts +3 -1
  198. package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +2 -5
  199. package/types/date-time-picker/config/useFocusTracker.d.ts +38 -0
  200. package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +6 -6
  201. package/types/date-time-picker/config/useGetReferences.d.ts +30 -36
  202. package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +3 -1
  203. package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
  204. package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
  205. package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
  206. package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +14 -0
  207. package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -2
  208. package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +19 -0
  209. package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +0 -6
  210. package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +14 -0
  211. package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
  212. package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
  213. package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
  214. package/types/date-time-picker/propTypes.d.ts +117 -0
  215. package/types/date-time-picker/sharedTypes.d.ts +1 -1
  216. package/types/date-time-picker/utils/constants.d.ts +0 -6
  217. package/types/index.d.ts +1 -0
  218. package/types/input-group/InputGroup.d.ts +5 -0
  219. package/types/input-group/InputGroupDataTestIds.d.ts +6 -0
  220. package/types/input-group/exported-related/data-test-ids.d.ts +6 -0
  221. package/types/input-group/exported-related/index.d.ts +2 -0
  222. package/types/input-group/exported-related/theming.d.ts +6 -0
  223. package/types/input-group/index.d.ts +2 -0
  224. package/types/input-group/react-desc-prop-types.d.ts +19 -0
  225. package/types/input-group/styled.d.ts +4 -0
  226. package/types/input-group/tests/DSInputGroup.test.d.ts +1 -0
  227. package/types/mask-hook/hooks/useRegExpMask.d.ts +0 -1
  228. package/types/text-input/config/useInputText.d.ts +6 -6
  229. package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -51
  230. package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -47
  231. package/types/combobox/parts/menu-list/useMenuListSetFocusOption.d.ts +0 -1
@@ -8,7 +8,7 @@ import { useContext, useCallback, useMemo } from 'react';
8
8
  import { ControlledDateTimePickerContext } from '../../ControlledDateTimePickerCTX.js';
9
9
  import { getFormattedDateString, prependStringWithPlaceHolders, fillStringWithPlaceHolders } from '../../utils/stringHelpers.js';
10
10
  import { getValidationDateStringMetaInfo } from '../../utils/dateHelpers.js';
11
- import { homeEndArrowUpDownDashSlashesKeys, homeEndArrowUpDownSpaceKeys, defaultMetaInfo } from '../../utils/constants.js';
11
+ import { defaultMetaInfo } from '../../utils/constants.js';
12
12
 
13
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
14
 
@@ -27,34 +27,27 @@ const useDateInputs = () => {
27
27
  day,
28
28
  year,
29
29
  hideTime,
30
- monthInputRef,
31
- dayInputRef,
32
- yearInputRef,
33
- hourInputRef,
34
- meridiemInputRef,
35
- clearButtonRef,
36
- pickerButtonRef,
37
30
  handleChangeComposedDateString,
38
- setLatestInteractionRegion,
39
31
  withClearBtn,
40
32
  withAnyPicker,
41
33
  withAnyRightController,
42
34
  autoFocusMonthInput,
43
- lastSegmentRef
35
+ trackFocusResetter,
36
+ trackFocusFirstSegment,
37
+ trackFocusLastSegment,
38
+ trackFocusDayInput,
39
+ trackFocusMonthInput,
40
+ trackFocusYearInput,
41
+ trackFocusHourInput,
42
+ trackFocusClearBtn,
43
+ trackFocusPicker
44
44
  } = useContext(ControlledDateTimePickerContext);
45
45
  const onHomeKeyDown = useCallback(() => {
46
- var _monthInputRef$curren, _monthInputRef$curren2;
47
-
48
- 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);
49
- }, [monthInputRef]);
46
+ trackFocusFirstSegment();
47
+ }, [trackFocusFirstSegment]);
50
48
  const onEndKeyDown = useCallback(() => {
51
- var _pickerButtonRef$curr, _pickerButtonRef$curr2, _clearButtonRef$curre, _clearButtonRef$curre2, _meridiemInputRef$cur, _meridiemInputRef$cur2, _yearInputRef$current, _yearInputRef$current2;
52
-
53
- if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr = pickerButtonRef.current) === null || _pickerButtonRef$curr === void 0 ? void 0 : (_pickerButtonRef$curr2 = _pickerButtonRef$curr.focus) === null || _pickerButtonRef$curr2 === void 0 ? void 0 : _pickerButtonRef$curr2.call(_pickerButtonRef$curr);else if (withClearBtn) clearButtonRef === null || clearButtonRef === void 0 ? void 0 : (_clearButtonRef$curre = clearButtonRef.current) === null || _clearButtonRef$curre === void 0 ? void 0 : (_clearButtonRef$curre2 = _clearButtonRef$curre.focus) === null || _clearButtonRef$curre2 === void 0 ? void 0 : _clearButtonRef$curre2.call(_clearButtonRef$curre);else if (!hideTime) 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);
54
- }, [withAnyPicker, pickerButtonRef, withClearBtn, clearButtonRef, hideTime, meridiemInputRef, yearInputRef]);
55
- const setLatestInteractionRegionDateInputs = useCallback(() => {
56
- setLatestInteractionRegion('date-inputs');
57
- }, [setLatestInteractionRegion]);
49
+ trackFocusLastSegment();
50
+ }, [trackFocusLastSegment]);
58
51
  const handleChangeMonth = useCallback(function (newMonth, e) {
59
52
  let metaInfo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultMetaInfo;
60
53
  const newDateString = getFormattedDateString({
@@ -71,29 +64,27 @@ const useDateInputs = () => {
71
64
  handleChangeComposedDateString(newDateString, finalMetaInfo);
72
65
  }, [day, year, getIsOutOfRangeDay, getIsDisabledDay, appOnMonthChange, handleChangeComposedDateString]);
73
66
  const onMonthFocus = useCallback(() => {
74
- setLatestInteractionRegionDateInputs();
75
- }, [setLatestInteractionRegionDateInputs]);
67
+ trackFocusMonthInput();
68
+ }, [trackFocusMonthInput]);
76
69
  const onMonthChange = useCallback(e => {
77
- var _e$target, _dayInputRef$current, _dayInputRef$current$;
70
+ var _e$target;
78
71
 
79
72
  let newMonth = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value; // converts months 2~9 to 02~09
80
73
 
81
74
  if (Number.parseInt(newMonth, 10) > 1) newMonth = prependStringWithPlaceHolders(newMonth, 2);
82
75
  handleChangeMonth(newMonth, e); // auto-advance functionality:
83
76
 
84
- if (newMonth.length === 2) dayInputRef === null || dayInputRef === void 0 ? void 0 : (_dayInputRef$current = dayInputRef.current) === null || _dayInputRef$current === void 0 ? void 0 : (_dayInputRef$current$ = _dayInputRef$current.focus) === null || _dayInputRef$current$ === void 0 ? void 0 : _dayInputRef$current$.call(_dayInputRef$current);
85
- }, [dayInputRef, handleChangeMonth]);
77
+ if (newMonth.length === 2) trackFocusDayInput();
78
+ }, [handleChangeMonth, trackFocusDayInput]);
86
79
  const onMonthKeyDown = useCallback(e => {
87
- var _lastSegmentRef$curre, _lastSegmentRef$curre2;
88
-
89
80
  const {
90
81
  key,
91
82
  ctrlKey,
92
83
  metaKey
93
84
  } = e;
94
85
  const monthStringConvertedToInteger = Number.parseInt(month, 10);
95
- if (homeEndArrowUpDownDashSlashesKeys.includes(key)) e.preventDefault();
96
- if (homeEndArrowUpDownDashSlashesKeys.includes(key)) e.stopPropagation();
86
+ if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.preventDefault();
87
+ if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.stopPropagation();
97
88
  if (key === 'Home') onHomeKeyDown();
98
89
  if (key === 'End') onEndKeyDown();
99
90
 
@@ -106,17 +97,15 @@ const useDateInputs = () => {
106
97
  }
107
98
 
108
99
  if (!Number.isNaN(monthStringConvertedToInteger) && (key === '-' || key === '/' || key === '\\')) {
109
- var _dayInputRef$current2, _dayInputRef$current3;
110
-
111
100
  const newMonth = prependStringWithPlaceHolders("".concat(monthStringConvertedToInteger), 2);
112
101
  handleChangeMonth(newMonth, e); // auto-advance functionality:
113
102
 
114
- if (newMonth.length === 2) dayInputRef === null || dayInputRef === void 0 ? void 0 : (_dayInputRef$current2 = dayInputRef.current) === null || _dayInputRef$current2 === void 0 ? void 0 : (_dayInputRef$current3 = _dayInputRef$current2.focus) === null || _dayInputRef$current3 === void 0 ? void 0 : _dayInputRef$current3.call(_dayInputRef$current2);
103
+ if (newMonth.length === 2) trackFocusDayInput();
115
104
  } // focus last fragment on fill with now
116
105
 
117
106
 
118
- if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre = lastSegmentRef.current) === null || _lastSegmentRef$curre === void 0 ? void 0 : (_lastSegmentRef$curre2 = _lastSegmentRef$curre.focus) === null || _lastSegmentRef$curre2 === void 0 ? void 0 : _lastSegmentRef$curre2.call(_lastSegmentRef$curre);
119
- }, [month, onHomeKeyDown, onEndKeyDown, lastSegmentRef, handleChangeMonth, dayInputRef]);
107
+ if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
108
+ }, [month, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusDayInput, handleChangeMonth]);
120
109
  const onMonthBlur = useCallback(e => {
121
110
  var _e$target2;
122
111
 
@@ -143,29 +132,27 @@ const useDateInputs = () => {
143
132
  handleChangeComposedDateString(newDateString, finalMetaInfo);
144
133
  }, [month, year, getIsOutOfRangeDay, getIsDisabledDay, appOnDayChange, handleChangeComposedDateString]);
145
134
  const onDayFocus = useCallback(() => {
146
- setLatestInteractionRegionDateInputs();
147
- }, [setLatestInteractionRegionDateInputs]);
135
+ trackFocusDayInput();
136
+ }, [trackFocusDayInput]);
148
137
  const onDayChange = useCallback(e => {
149
- var _e$target3, _yearInputRef$current3, _yearInputRef$current4;
138
+ var _e$target3;
150
139
 
151
140
  let newDay = e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.value; // converts days 4~9 to 04~09
152
141
 
153
142
  if (Number.parseInt(newDay, 10) > 3) newDay = prependStringWithPlaceHolders(newDay, 2);
154
143
  handleChangeDay(newDay, e); // auto-advance functionality:
155
144
 
156
- if (newDay.length === 2) yearInputRef === null || yearInputRef === void 0 ? void 0 : (_yearInputRef$current3 = yearInputRef.current) === null || _yearInputRef$current3 === void 0 ? void 0 : (_yearInputRef$current4 = _yearInputRef$current3.focus) === null || _yearInputRef$current4 === void 0 ? void 0 : _yearInputRef$current4.call(_yearInputRef$current3);
157
- }, [handleChangeDay, yearInputRef]);
145
+ if (newDay.length === 2) trackFocusYearInput();
146
+ }, [handleChangeDay, trackFocusYearInput]);
158
147
  const onDayKeyDown = useCallback(e => {
159
- var _lastSegmentRef$curre3, _lastSegmentRef$curre4;
160
-
161
148
  const {
162
149
  key,
163
150
  ctrlKey,
164
151
  metaKey
165
152
  } = e;
166
153
  const dayStringConvertedToInteger = Number.parseInt(day, 10);
167
- if (homeEndArrowUpDownDashSlashesKeys.includes(key)) e.preventDefault();
168
- if (homeEndArrowUpDownDashSlashesKeys.includes(key)) e.stopPropagation();
154
+ if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.preventDefault();
155
+ if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.stopPropagation();
169
156
  if (key === 'Home') onHomeKeyDown();
170
157
  if (key === 'End') onEndKeyDown();
171
158
 
@@ -178,24 +165,20 @@ const useDateInputs = () => {
178
165
  }
179
166
 
180
167
  if (!Number.isNaN(dayStringConvertedToInteger) && (key === '-' || key === '/' || key === '\\')) {
181
- var _yearInputRef$current5, _yearInputRef$current6;
182
-
183
168
  const newDay = prependStringWithPlaceHolders("".concat(dayStringConvertedToInteger), 2);
184
169
  handleChangeDay(newDay, e); // auto-advance functionality:
185
170
 
186
- if (newDay.length === 2) yearInputRef === null || yearInputRef === void 0 ? void 0 : (_yearInputRef$current5 = yearInputRef.current) === null || _yearInputRef$current5 === void 0 ? void 0 : (_yearInputRef$current6 = _yearInputRef$current5.focus) === null || _yearInputRef$current6 === void 0 ? void 0 : _yearInputRef$current6.call(_yearInputRef$current5);
171
+ if (newDay.length === 2) trackFocusYearInput();
187
172
  } // regressive backspace functionality
188
173
 
189
174
 
190
175
  if (key === 'Backspace' && (day === null || day === void 0 ? void 0 : day.length) === 0) {
191
- var _monthInputRef$curren3, _monthInputRef$curren4;
192
-
193
- monthInputRef === null || monthInputRef === void 0 ? void 0 : (_monthInputRef$curren3 = monthInputRef.current) === null || _monthInputRef$curren3 === void 0 ? void 0 : (_monthInputRef$curren4 = _monthInputRef$curren3.focus) === null || _monthInputRef$curren4 === void 0 ? void 0 : _monthInputRef$curren4.call(_monthInputRef$curren3);
176
+ trackFocusMonthInput();
194
177
  } // focus last fragment on fill with now
195
178
 
196
179
 
197
- if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre3 = lastSegmentRef.current) === null || _lastSegmentRef$curre3 === void 0 ? void 0 : (_lastSegmentRef$curre4 = _lastSegmentRef$curre3.focus) === null || _lastSegmentRef$curre4 === void 0 ? void 0 : _lastSegmentRef$curre4.call(_lastSegmentRef$curre3);
198
- }, [day, onHomeKeyDown, onEndKeyDown, lastSegmentRef, handleChangeDay, yearInputRef, monthInputRef]);
180
+ if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
181
+ }, [day, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, handleChangeDay, trackFocusYearInput, trackFocusMonthInput]);
199
182
  const onDayBlur = useCallback(e => {
200
183
  var _e$target4;
201
184
 
@@ -222,8 +205,8 @@ const useDateInputs = () => {
222
205
  handleChangeComposedDateString(newDateString, finalMetaInfo);
223
206
  }, [month, day, getIsOutOfRangeDay, getIsDisabledDay, appOnYearChange, handleChangeComposedDateString]);
224
207
  const onYearFocus = useCallback(() => {
225
- setLatestInteractionRegionDateInputs();
226
- }, [setLatestInteractionRegionDateInputs]);
208
+ trackFocusYearInput();
209
+ }, [trackFocusYearInput]);
227
210
  const onYearChange = useCallback(e => {
228
211
  var _e$target5;
229
212
 
@@ -231,70 +214,68 @@ const useDateInputs = () => {
231
214
  handleChangeYear(newYear, e); // auto-advance functionality:
232
215
 
233
216
  if (newYear.length === 4) {
234
- var _hourInputRef$current, _hourInputRef$current2;
235
-
236
- 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);else if (withAnyRightController) {
237
- var _clearButtonRef$curre3, _clearButtonRef$curre4, _pickerButtonRef$curr3, _pickerButtonRef$curr4;
238
-
239
- if (withClearBtn) (_clearButtonRef$curre3 = clearButtonRef.current) === null || _clearButtonRef$curre3 === void 0 ? void 0 : (_clearButtonRef$curre4 = _clearButtonRef$curre3.focus) === null || _clearButtonRef$curre4 === void 0 ? void 0 : _clearButtonRef$curre4.call(_clearButtonRef$curre3);else if (withAnyPicker) 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); // pending approval from Seda, check which one should be focused first...
217
+ if (!hideTime) trackFocusHourInput();else if (withAnyRightController) {
218
+ if (withClearBtn) trackFocusClearBtn();else if (withAnyPicker) trackFocusPicker(); // pending approval from Seda, check which one should be focused first...
240
219
  }
241
220
  }
242
- }, [handleChangeYear, hideTime, hourInputRef, withAnyRightController, withAnyPicker, pickerButtonRef, withClearBtn, clearButtonRef]);
221
+ }, [handleChangeYear, hideTime, trackFocusHourInput, withAnyRightController, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker]);
243
222
  const onYearKeyDown = useCallback(e => {
244
- var _lastSegmentRef$curre5, _lastSegmentRef$curre6;
245
-
246
223
  const {
247
224
  key,
248
225
  ctrlKey,
249
226
  metaKey
250
227
  } = e;
228
+ /* ****** New year value calculator logic ********* */
229
+
251
230
  const yearStringConvertedToInteger = Number.parseInt(year, 10);
252
- if (homeEndArrowUpDownSpaceKeys.includes(key)) e.preventDefault();
253
- if (homeEndArrowUpDownSpaceKeys.includes(key)) e.stopPropagation();
254
- if (key === 'Home') onHomeKeyDown();
255
- if (key === 'End') onEndKeyDown();
231
+ const yearInteger = Number.isNaN(yearStringConvertedToInteger) ? 0 : yearStringConvertedToInteger;
232
+ let newYear = yearInteger !== 0 ? fillStringWithPlaceHolders("".concat(yearInteger), 4, '0') : '';
256
233
 
257
234
  if (key === 'ArrowUp' || key === 'ArrowDown') {
258
- const yearInteger = Number.isNaN(yearStringConvertedToInteger) ? 0 : yearStringConvertedToInteger;
259
- let newYear;
260
- if (key === 'ArrowUp') newYear = yearInteger + 1 <= 9999 ? yearInteger + 1 : yearInteger;else newYear = yearInteger - 1 > 0 ? yearInteger - 1 : 1;
261
- newYear = prependStringWithPlaceHolders("".concat(newYear), 4);
262
- handleChangeYear(newYear, e);
235
+ let newYearInteger;
236
+ if (key === 'ArrowUp') newYearInteger = yearInteger + 1 <= 9999 ? yearInteger + 1 : yearInteger;else newYearInteger = yearInteger - 1 > 0 ? yearInteger - 1 : 1;
237
+ newYear = prependStringWithPlaceHolders("".concat(newYearInteger), 4);
263
238
  }
264
239
 
265
- if (!Number.isNaN(yearStringConvertedToInteger) && key === ' ') {
266
- const newYear = prependStringWithPlaceHolders("".concat(yearStringConvertedToInteger), 4);
267
- handleChangeYear(newYear, e); // auto-advance functionality:
240
+ const isAutomaticFillTrigger = newYear !== year && ['Tab', ' '].includes(key);
241
+ const metainfo = {
242
+ isAutomaticFillTrigger
243
+ };
244
+ /* ************* new year apply logic ************* */
245
+ // tab/spacebar applies auto-fill
246
+ // arrows up/down applies increment/decrement
268
247
 
269
- if (newYear.length === 4) {
270
- var _hourInputRef$current3, _hourInputRef$current4;
248
+ if (key === 'ArrowUp' || key === 'ArrowDown' || isAutomaticFillTrigger) {
249
+ handleChangeYear(newYear, e, metainfo);
250
+ }
251
+ /* ************* focus tracking logic ************* */
271
252
 
272
- if (!hideTime) hourInputRef === null || hourInputRef === void 0 ? void 0 : (_hourInputRef$current3 = hourInputRef.current) === null || _hourInputRef$current3 === void 0 ? void 0 : (_hourInputRef$current4 = _hourInputRef$current3.focus) === null || _hourInputRef$current4 === void 0 ? void 0 : _hourInputRef$current4.call(_hourInputRef$current3);else if (withAnyRightController) {
273
- var _clearButtonRef$curre5, _clearButtonRef$curre6, _pickerButtonRef$curr5, _pickerButtonRef$curr6;
274
253
 
275
- if (withClearBtn) (_clearButtonRef$curre5 = clearButtonRef.current) === null || _clearButtonRef$curre5 === void 0 ? void 0 : (_clearButtonRef$curre6 = _clearButtonRef$curre5.focus) === null || _clearButtonRef$curre6 === void 0 ? void 0 : _clearButtonRef$curre6.call(_clearButtonRef$curre5);else if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr5 = pickerButtonRef.current) === null || _pickerButtonRef$curr5 === void 0 ? void 0 : (_pickerButtonRef$curr6 = _pickerButtonRef$curr5.focus) === null || _pickerButtonRef$curr6 === void 0 ? void 0 : _pickerButtonRef$curr6.call(_pickerButtonRef$curr5); // pending approval from Seda, check which one should be focused first...
276
- }
277
- }
278
- } // regressive backspace functionality
254
+ let trackNextFocus = trackFocusResetter; // if nothing after, we reset internal focus tracker to avoid re-render unexpected focus shift
279
255
 
256
+ if (!hideTime) trackNextFocus = trackFocusHourInput;else if (withClearBtn) trackNextFocus = trackFocusClearBtn;else if (withAnyPicker) trackNextFocus = trackFocusPicker;
257
+ if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.preventDefault();
258
+ if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.stopPropagation();
259
+ if (key === 'Home') onHomeKeyDown();
260
+ if (key === 'End') onEndKeyDown();
261
+ /* ************** auto-advance logic ************** */
280
262
 
281
- if (key === 'Backspace' && (year === null || year === void 0 ? void 0 : year.length) === 0) {
282
- var _dayInputRef$current4, _dayInputRef$current5;
263
+ if (key === ' ') {
264
+ // auto-advance functionality:
265
+ trackNextFocus();
266
+ }
267
+ /* ********** regressive backspace logic ********** */
283
268
 
284
- dayInputRef === null || dayInputRef === void 0 ? void 0 : (_dayInputRef$current4 = dayInputRef.current) === null || _dayInputRef$current4 === void 0 ? void 0 : (_dayInputRef$current5 = _dayInputRef$current4.focus) === null || _dayInputRef$current5 === void 0 ? void 0 : _dayInputRef$current5.call(_dayInputRef$current4);
285
- } // focus last fragment on fill with now
286
269
 
270
+ if (key === 'Backspace' && (year === null || year === void 0 ? void 0 : year.length) === 0) {
271
+ trackFocusDayInput();
272
+ } // focus last fragment on fill with now
287
273
 
288
- if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre5 = lastSegmentRef.current) === null || _lastSegmentRef$curre5 === void 0 ? void 0 : (_lastSegmentRef$curre6 = _lastSegmentRef$curre5.focus) === null || _lastSegmentRef$curre6 === void 0 ? void 0 : _lastSegmentRef$curre6.call(_lastSegmentRef$curre5);
289
- }, [year, onHomeKeyDown, onEndKeyDown, lastSegmentRef, handleChangeYear, hideTime, hourInputRef, withAnyRightController, withClearBtn, clearButtonRef, withAnyPicker, pickerButtonRef, dayInputRef]);
290
- const onYearBlur = useCallback(e => {
291
- var _e$target6;
292
274
 
293
- const newYear = e === null || e === void 0 ? void 0 : (_e$target6 = e.target) === null || _e$target6 === void 0 ? void 0 : _e$target6.value;
294
- if (newYear.length > 0 && newYear.length < 4) handleChangeYear(fillStringWithPlaceHolders(newYear, 4, '0'), e, {
295
- isAutomaticFillTrigger: true
296
- });
297
- }, [handleChangeYear]);
275
+ if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
276
+ }, [year, trackFocusResetter, hideTime, trackFocusHourInput, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusDayInput, handleChangeYear]);
277
+ const onYearBlur = useCallback(() => {// this was used before, now that we have a wrapping onBlur resetting the focus tracker, this is unused;
278
+ }, []);
298
279
  return useMemo(() => ({
299
280
  month,
300
281
  day,
@@ -1,5 +1,5 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import { useMemo, useContext } from 'react';
2
+ import { useMemo, useContext, useCallback } from 'react';
3
3
  import { BUTTON_SIZES } from '@elliemae/ds-button';
4
4
  import { ChevronDoubleLeft, ChevronLeft, ChevronRight, ChevronDoubleRight } from '@elliemae/ds-icons';
5
5
  import { ControlledDateTimePickerDatatestid } from '../../../ControlledDateTimePickerDatatestid.js';
@@ -41,14 +41,40 @@ const CalendarHead = () => {
41
41
  prevYearBtnRef,
42
42
  prevMonthBtnRef,
43
43
  nextMonthBtnRef,
44
- nextYearBtnRef
44
+ nextYearBtnRef,
45
+ latestInteractionRegion,
46
+ currFocusDescriber
45
47
  } = useContext(ControlledDateTimePickerContext);
48
+ const handlePrevYearRef = useCallback(ButtonDomNode => {
49
+ var _ButtonDomNode$focus;
50
+
51
+ prevYearBtnRef.current = ButtonDomNode;
52
+ if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-prev-year') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
53
+ }, [currFocusDescriber, latestInteractionRegion, prevYearBtnRef]);
54
+ const handlePrevMonthRef = useCallback(ButtonDomNode => {
55
+ var _ButtonDomNode$focus2;
56
+
57
+ prevMonthBtnRef.current = ButtonDomNode;
58
+ if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-prev-month') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus2 = ButtonDomNode.focus) === null || _ButtonDomNode$focus2 === void 0 ? void 0 : _ButtonDomNode$focus2.call(ButtonDomNode);
59
+ }, [currFocusDescriber, latestInteractionRegion, prevMonthBtnRef]);
60
+ const handleNextMonthRef = useCallback(ButtonDomNode => {
61
+ var _ButtonDomNode$focus3;
62
+
63
+ nextMonthBtnRef.current = ButtonDomNode;
64
+ if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-next-month') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus3 = ButtonDomNode.focus) === null || _ButtonDomNode$focus3 === void 0 ? void 0 : _ButtonDomNode$focus3.call(ButtonDomNode);
65
+ }, [currFocusDescriber, latestInteractionRegion, nextMonthBtnRef]);
66
+ const handleNextYearRef = useCallback(ButtonDomNode => {
67
+ var _ButtonDomNode$focus4;
68
+
69
+ nextYearBtnRef.current = ButtonDomNode;
70
+ if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-next-year') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus4 = ButtonDomNode.focus) === null || _ButtonDomNode$focus4 === void 0 ? void 0 : _ButtonDomNode$focus4.call(ButtonDomNode);
71
+ }, [currFocusDescriber, latestInteractionRegion, nextYearBtnRef]);
46
72
  return /*#__PURE__*/_jsx(StyledHeader, {}, void 0, /*#__PURE__*/_jsx(StyledHeaderButton, {
47
73
  "aria-label": "previous year",
48
74
  buttonType: "raw",
49
75
  size: BUTTON_SIZES.M,
50
76
  onClick: handlePrevYear,
51
- innerRef: prevYearBtnRef,
77
+ innerRef: handlePrevYearRef,
52
78
  onKeyDown: handlePrevYearKeyDown,
53
79
  onFocus: onPrevYearFocus,
54
80
  tabIndex: isControllerOnly ? -1 : 1,
@@ -63,7 +89,7 @@ const CalendarHead = () => {
63
89
  buttonType: "raw",
64
90
  size: BUTTON_SIZES.M,
65
91
  onClick: handlePrevMonth,
66
- innerRef: prevMonthBtnRef,
92
+ innerRef: handlePrevMonthRef,
67
93
  onKeyDown: handlePrevMonthKeyDown,
68
94
  onFocus: onPrevMonthFocus,
69
95
  "data-testid": ControlledDateTimePickerDatatestid.CALENDAR.PREV_MONTH // this is a tabstop for when the calendar is open
@@ -75,7 +101,7 @@ const CalendarHead = () => {
75
101
  buttonType: "raw",
76
102
  size: BUTTON_SIZES.M,
77
103
  onClick: handleNextMonth,
78
- innerRef: nextMonthBtnRef,
104
+ innerRef: handleNextMonthRef,
79
105
  onKeyDown: handleNextMonthKeyDown,
80
106
  onFocus: onNextMonthFocus,
81
107
  "data-testid": ControlledDateTimePickerDatatestid.CALENDAR.NEXT_MONTH
@@ -86,7 +112,7 @@ const CalendarHead = () => {
86
112
  buttonType: "raw",
87
113
  size: BUTTON_SIZES.M,
88
114
  onClick: handleNextYear,
89
- innerRef: nextYearBtnRef,
115
+ innerRef: handleNextYearRef,
90
116
  onKeyDown: handleNextYearKeyDown,
91
117
  onFocus: onNextYearFocus,
92
118
  "data-testid": ControlledDateTimePickerDatatestid.CALENDAR.NEXT_YEAR
@@ -49,15 +49,14 @@ const Day = _ref => {
49
49
  appOnDayChange,
50
50
  appOnYearChange,
51
51
  latestInteractionRegion,
52
- setLatestInteractionRegion,
53
- isWithTimeWheelToo
52
+ isWithTimeWheelToo,
53
+ trackFocusCalendarMetafocusedDay
54
54
  } = useContext(ControlledDateTimePickerContext);
55
55
  const {
56
56
  focusedDay,
57
57
  handleDayOnKeyDown,
58
58
  handleFocusMetaDayByDay,
59
- closeCalendar,
60
- tryToFocusCurrentlyDataIsFocusedDay
59
+ closeCalendar
61
60
  } = useContext(CalendarContext);
62
61
  const isFocusedMetaDay = focusedDay !== null && focusedDay !== void 0 && focusedDay.day ? compareTwoDatesDayEquality(metaDay === null || metaDay === void 0 ? void 0 : metaDay.day, focusedDay === null || focusedDay === void 0 ? void 0 : focusedDay.day) : false;
63
62
  const isSelected = useMemo(() => {
@@ -72,7 +71,6 @@ const Day = _ref => {
72
71
  const isDayInRange = !isStartRangeDay && !isEndRangeDay && getIsDayInRange(metaDay.dayAsString);
73
72
  const handleOnDayClick = useCallback(e => {
74
73
  handleFocusMetaDayByDay(day);
75
- tryToFocusCurrentlyDataIsFocusedDay();
76
74
 
77
75
  if (!isDisabled && !isOutOfRange) {
78
76
  const newDateString = getDateStringFromDay(day);
@@ -90,13 +88,21 @@ const Day = _ref => {
90
88
  if (dayNumber) appOnDayChange("".concat(dayNumber), e, metaInfo);
91
89
  appOnYearChange("".concat(year), e, metaInfo);
92
90
  handleChangeComposedDateString(newDateString, metaInfo);
93
- setLatestInteractionRegion('calendar-days');
91
+ trackFocusCalendarMetafocusedDay();
94
92
  if (!isWithTimeWheelToo && !preventCloseOnSelection) closeCalendar();
95
93
  }
96
- }, [isDisabled, isOutOfRange, day, appOnMonthChange, appOnDayChange, appOnYearChange, handleChangeComposedDateString, handleFocusMetaDayByDay, tryToFocusCurrentlyDataIsFocusedDay, setLatestInteractionRegion, isWithTimeWheelToo, preventCloseOnSelection, closeCalendar]);
94
+ }, [handleFocusMetaDayByDay, day, isDisabled, isOutOfRange, appOnMonthChange, appOnDayChange, appOnYearChange, handleChangeComposedDateString, trackFocusCalendarMetafocusedDay, isWithTimeWheelToo, preventCloseOnSelection, closeCalendar]);
95
+ const handleInnerRef = useCallback(ButtonDomNode => {
96
+ window.requestAnimationFrame(() => {
97
+ var _ButtonDomNode$focus;
98
+
99
+ dayBtnRef.current = ButtonDomNode;
100
+ if (isFocused) ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
101
+ });
102
+ }, [dayBtnRef, isFocused]);
97
103
  const handleOnDayFocus = useCallback(() => {
98
- setLatestInteractionRegion('calendar-days');
99
- }, [setLatestInteractionRegion]);
104
+ trackFocusCalendarMetafocusedDay('calendar-days');
105
+ }, [trackFocusCalendarMetafocusedDay]);
100
106
  const dayClassModifiers = useMemo(() => "dayWrapper ".concat(isSelected ? 'selectedDay ' : '').concat(isDisabled ? 'disabledDay ' : '').concat(isOutOfRange ? 'outOfRangeDay ' : '').concat(isFocused ? 'focusedDay ' : '').concat(isStartRangeDay ? 'startRangeDay ' : '').concat(isDayInRange ? 'inRangeDay ' : '').concat(isEndRangeDay ? 'endRangeDay ' : '').concat(isCurrMonthDay ? '' : 'notCurrentMonth'), [isSelected, isDisabled, isOutOfRange, isFocused, isStartRangeDay, isDayInRange, isEndRangeDay, isCurrMonthDay]);
101
107
  let dataTestid = ControlledDateTimePickerDatatestid.CALENDAR.DAY;
102
108
  if (isSelected) dataTestid = ControlledDateTimePickerDatatestid.CALENDAR.SELECTED_DAY;
@@ -124,7 +130,7 @@ const Day = _ref => {
124
130
  onKeyDown: e => {
125
131
  handleDayOnKeyDown(e, metaDay);
126
132
  },
127
- innerRef: dayBtnRef,
133
+ innerRef: handleInnerRef,
128
134
  tabIndex: isSelected ? 0 : -1,
129
135
  "data-isfocused": isFocused,
130
136
  "data-testid": dataTestid
@@ -17,24 +17,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
17
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
18
  const useConfigCalendarCTX = () => {
19
19
  const {
20
- setLatestInteractionRegion
20
+ trackFocusCalendarPrevYear,
21
+ trackFocusCalendarNextYear,
22
+ trackFocusCalendarPrevMonth,
23
+ trackFocusCalendarNextMonth
21
24
  } = useContext(ControlledDateTimePickerContext);
22
25
  const [showCalendar, setShowCalendar] = useState(false);
23
- const setLatestInteractionRegionCalendarHead = useCallback(() => {
24
- setLatestInteractionRegion('calendar-head');
25
- }, [setLatestInteractionRegion]);
26
26
  const onPrevYearFocus = useCallback(() => {
27
- setLatestInteractionRegionCalendarHead();
28
- }, [setLatestInteractionRegionCalendarHead]);
27
+ trackFocusCalendarPrevYear();
28
+ }, [trackFocusCalendarPrevYear]);
29
29
  const onPrevMonthFocus = useCallback(() => {
30
- setLatestInteractionRegionCalendarHead();
31
- }, [setLatestInteractionRegionCalendarHead]);
30
+ trackFocusCalendarPrevMonth();
31
+ }, [trackFocusCalendarPrevMonth]);
32
32
  const onNextMonthFocus = useCallback(() => {
33
- setLatestInteractionRegionCalendarHead();
34
- }, [setLatestInteractionRegionCalendarHead]);
33
+ trackFocusCalendarNextMonth();
34
+ }, [trackFocusCalendarNextMonth]);
35
35
  const onNextYearFocus = useCallback(() => {
36
- setLatestInteractionRegionCalendarHead();
37
- }, [setLatestInteractionRegionCalendarHead]);
36
+ trackFocusCalendarNextYear();
37
+ }, [trackFocusCalendarNextYear]);
38
38
  const currentDisplayedMonthLogic = useCurrentDisplayedMonthYearLogic();
39
39
  const focusLogic = useFocusLogic({
40
40
  currentDisplayedMonthLogic,
@@ -2,32 +2,14 @@ import 'core-js/modules/web.dom-collections.iterator.js';
2
2
  import 'core-js/modules/esnext.async-iterator.find.js';
3
3
  import 'core-js/modules/esnext.iterator.constructor.js';
4
4
  import 'core-js/modules/esnext.iterator.find.js';
5
- import { useContext, useState, useMemo, useCallback, useLayoutEffect } from 'react';
6
- import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
5
+ import { useState, useMemo, useCallback } from 'react';
7
6
  import { compareTwoDatesDayEquality } from '../../../utils/dateHelpers.js';
8
7
  import { useGetStartingFocusedDay } from '../../../utils/hooks/useGetStartingFocusedDay.js';
9
8
 
10
- // eslint-disable-next-line max-params
11
- const loopWhileWaiting = function (cb) {
12
- let shortcircuit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => false;
13
- let timePerTry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
14
- let maxTries = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5;
15
- let ab = maxTries;
16
- const inter = setInterval(() => {
17
- cb();
18
- if (shortcircuit() || ab === 0) clearInterval(inter);
19
- ab -= 1;
20
- }, timePerTry);
21
- };
22
-
23
9
  const useFocusLogic = _ref => {
24
10
  let {
25
- currentDisplayedMonthLogic,
26
- showCalendar
11
+ currentDisplayedMonthLogic
27
12
  } = _ref;
28
- const {
29
- calendarDaysWrapperRef
30
- } = useContext(ControlledDateTimePickerContext);
31
13
  const {
32
14
  daysArray
33
15
  } = currentDisplayedMonthLogic;
@@ -59,23 +41,6 @@ const useFocusLogic = _ref => {
59
41
  });
60
42
  return newFocusedDay;
61
43
  }, [daysArray, startFocusedDate, metadayToFocus]);
62
- const tryToFocusCurrentlyDataIsFocusedDay = useCallback(function () {
63
- let wrapperDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (calendarDaysWrapperRef === null || calendarDaysWrapperRef === void 0 ? void 0 : calendarDaysWrapperRef.current) || document;
64
- let shortcircuit = false;
65
- loopWhileWaiting(() => {
66
- const domElem = wrapperDOM === null || wrapperDOM === void 0 ? void 0 : wrapperDOM.querySelector('[data-isfocused="true"]');
67
-
68
- if (domElem) {
69
- var _domElem$focus;
70
-
71
- domElem === null || domElem === void 0 ? void 0 : (_domElem$focus = domElem.focus) === null || _domElem$focus === void 0 ? void 0 : _domElem$focus.call(domElem);
72
- shortcircuit = true;
73
- }
74
- }, () => shortcircuit);
75
- }, [calendarDaysWrapperRef]);
76
- useLayoutEffect(() => {
77
- if (showCalendar) tryToFocusCurrentlyDataIsFocusedDay(calendarDaysWrapperRef === null || calendarDaysWrapperRef === void 0 ? void 0 : calendarDaysWrapperRef.current);
78
- }, [calendarDaysWrapperRef, focusedDay, showCalendar, tryToFocusCurrentlyDataIsFocusedDay]);
79
44
  const handleFocusMetaDay = useCallback(metaDayToFocus => {
80
45
  // if focusedDay is inside current daysArray we set Focused day
81
46
  const newFocusedMetaDay = daysArray.find(_ref5 => {
@@ -101,11 +66,10 @@ const useFocusLogic = _ref => {
101
66
  }, []);
102
67
  return useMemo(() => ({
103
68
  focusedDay,
104
- tryToFocusCurrentlyDataIsFocusedDay,
105
69
  resetFocusedDayToStartDate,
106
70
  handleFocusMetaDay,
107
71
  handleFocusMetaDayByDay
108
- }), [focusedDay, tryToFocusCurrentlyDataIsFocusedDay, resetFocusedDayToStartDate, handleFocusMetaDay, handleFocusMetaDayByDay]);
72
+ }), [focusedDay, resetFocusedDayToStartDate, handleFocusMetaDay, handleFocusMetaDayByDay]);
109
73
  };
110
74
 
111
75
  export { useFocusLogic };