@elliemae/ds-controlled-form 2.4.1 → 2.4.2-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/cjs/autocomplete/config/useAutocomplete.js +1 -3
  2. package/cjs/checkbox/ControlledCheckbox.js +49 -33
  3. package/cjs/checkbox/exported-related/data-test-ids.js +10 -0
  4. package/cjs/checkbox/exported-related/index.js +12 -0
  5. package/cjs/checkbox/exported-related/theming.js +13 -0
  6. package/cjs/checkbox/react-desc-prop-types.js +0 -1
  7. package/cjs/checkbox/styles.js +26 -15
  8. package/cjs/combobox/ComboBoxCTX.js +1 -1
  9. package/cjs/combobox/ComboboxDataTestids.js +1 -1
  10. package/cjs/combobox/config/useComboBox.js +6 -4
  11. package/cjs/combobox/index.js +5 -0
  12. package/cjs/combobox/parts/DropdownIndicator.js +2 -2
  13. package/cjs/combobox/parts/container/Container.js +5 -5
  14. package/cjs/combobox/parts/container/styled.js +13 -7
  15. package/cjs/combobox/parts/controls/Controls.js +14 -4
  16. package/cjs/combobox/parts/controls/styled.js +22 -13
  17. package/cjs/combobox/parts/controls-input/ControlsInput.js +1 -1
  18. package/cjs/combobox/parts/controls-input/styled.js +7 -3
  19. package/cjs/combobox/parts/controls-input/useControlsInput.js +3 -4
  20. package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
  21. package/cjs/combobox/parts/header-list/HeaderList.js +4 -3
  22. package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
  23. package/cjs/combobox/parts/menu-list/MenuList.js +5 -2
  24. package/cjs/combobox/parts/menu-list/styled.js +12 -7
  25. package/cjs/combobox/parts/menu-list/useItemRenderer.js +5 -4
  26. package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
  27. package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
  28. package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
  29. package/cjs/combobox/theming.js +13 -0
  30. package/cjs/combobox/utils/listHelper.js +2 -1
  31. package/cjs/date-time-picker/config/useChangeHandlers.js +8 -12
  32. package/cjs/date-time-picker/config/useControlledDateTimePicker.js +13 -9
  33. package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
  34. package/cjs/date-time-picker/config/useGetReferences.js +40 -19
  35. package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
  36. package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +12 -2
  37. package/cjs/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
  38. package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
  39. package/cjs/date-time-picker/parts/DateInputs/DDInput.js +8 -2
  40. package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
  41. package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -2
  42. package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
  43. package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +76 -95
  44. package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +31 -5
  45. package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
  46. package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -12
  47. package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -38
  48. package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
  49. package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
  50. package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
  51. package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
  52. package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +13 -7
  53. package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +14 -8
  54. package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +13 -7
  55. package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
  56. package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
  57. package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
  58. package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
  59. package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
  60. package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
  61. package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
  62. package/cjs/date-time-picker/utils/constants.js +0 -12
  63. package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
  64. package/cjs/index.js +16 -7
  65. package/cjs/input-group/InputGroup.js +69 -0
  66. package/cjs/input-group/InputGroupDataTestIds.js +12 -0
  67. package/cjs/input-group/index.js +12 -0
  68. package/cjs/input-group/react-desc-prop-types.js +14 -0
  69. package/cjs/input-group/styled.js +46 -0
  70. package/cjs/mask-hook/hooks/index.js +0 -1
  71. package/cjs/mask-hook/hooks/usePhoneMask.js +2 -2
  72. package/cjs/mask-hook/hooks/useRegExpMask.js +0 -1
  73. package/cjs/mask-hook/index.js +0 -1
  74. package/cjs/text-input/styled/borders.js +1 -1
  75. package/esm/autocomplete/config/useAutocomplete.js +3 -5
  76. package/esm/checkbox/ControlledCheckbox.js +52 -36
  77. package/esm/checkbox/exported-related/data-test-ids.js +6 -0
  78. package/esm/checkbox/exported-related/index.js +2 -0
  79. package/esm/checkbox/exported-related/theming.js +8 -0
  80. package/esm/checkbox/react-desc-prop-types.js +0 -1
  81. package/esm/checkbox/styles.js +25 -15
  82. package/esm/combobox/ComboBoxCTX.js +1 -1
  83. package/esm/combobox/ComboboxDataTestids.js +1 -1
  84. package/esm/combobox/config/useComboBox.js +8 -6
  85. package/esm/combobox/index.js +2 -0
  86. package/esm/combobox/parts/DropdownIndicator.js +2 -2
  87. package/esm/combobox/parts/container/Container.js +7 -7
  88. package/esm/combobox/parts/container/styled.js +13 -6
  89. package/esm/combobox/parts/controls/Controls.js +14 -4
  90. package/esm/combobox/parts/controls/styled.js +22 -13
  91. package/esm/combobox/parts/controls-input/ControlsInput.js +1 -1
  92. package/esm/combobox/parts/controls-input/styled.js +7 -3
  93. package/esm/combobox/parts/controls-input/useControlsInput.js +3 -4
  94. package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
  95. package/esm/combobox/parts/header-list/HeaderList.js +4 -3
  96. package/esm/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
  97. package/esm/combobox/parts/menu-list/MenuList.js +5 -2
  98. package/esm/combobox/parts/menu-list/styled.js +12 -7
  99. package/esm/combobox/parts/menu-list/useItemRenderer.js +5 -4
  100. package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
  101. package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
  102. package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
  103. package/esm/combobox/theming.js +8 -0
  104. package/esm/combobox/utils/listHelper.js +2 -1
  105. package/esm/date-range-picker/config/useRangePickerLogic.js +2 -2
  106. package/esm/date-time-picker/config/useChangeHandlers.js +8 -12
  107. package/esm/date-time-picker/config/useControlledDateTimePicker.js +13 -9
  108. package/esm/date-time-picker/config/useFocusTracker.js +132 -0
  109. package/esm/date-time-picker/config/useGetReferences.js +41 -20
  110. package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
  111. package/esm/date-time-picker/parts/ClearButton/ClearButton.js +12 -2
  112. package/esm/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
  113. package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
  114. package/esm/date-time-picker/parts/DateInputs/DDInput.js +8 -2
  115. package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
  116. package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -2
  117. package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
  118. package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +77 -96
  119. package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +32 -6
  120. package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
  121. package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +14 -14
  122. package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -39
  123. package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
  124. package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
  125. package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
  126. package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
  127. package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +14 -8
  128. package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +15 -9
  129. package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +14 -8
  130. package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
  131. package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
  132. package/esm/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
  133. package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
  134. package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
  135. package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
  136. package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
  137. package/esm/date-time-picker/utils/constants.js +1 -7
  138. package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
  139. package/esm/index.js +5 -1
  140. package/esm/input-group/InputGroup.js +59 -0
  141. package/esm/input-group/InputGroupDataTestIds.js +8 -0
  142. package/esm/input-group/index.js +2 -0
  143. package/esm/input-group/react-desc-prop-types.js +10 -0
  144. package/esm/input-group/styled.js +35 -0
  145. package/esm/mask-hook/hooks/index.js +1 -1
  146. package/esm/mask-hook/hooks/usePhoneMask.js +2 -2
  147. package/esm/mask-hook/hooks/useRegExpMask.js +1 -1
  148. package/esm/mask-hook/index.js +1 -1
  149. package/esm/text-input/styled/borders.js +1 -1
  150. package/esm/toggle/ControlledToggle.js +3 -3
  151. package/package.json +55 -19
  152. package/types/checkbox/exported-related/data-test-ids.d.ts +4 -0
  153. package/types/checkbox/exported-related/index.d.ts +2 -0
  154. package/types/checkbox/exported-related/theming.d.ts +6 -0
  155. package/types/checkbox/react-desc-prop-types.d.ts +3 -3
  156. package/types/checkbox/styles.d.ts +5 -5
  157. package/types/combobox/ComboboxDataTestids.d.ts +1 -1
  158. package/types/combobox/index.d.ts +2 -0
  159. package/types/combobox/parts/container/styled.d.ts +1 -2
  160. package/types/combobox/theming.d.ts +6 -0
  161. package/types/date-time-picker/config/useChangeHandlers.d.ts +3 -1
  162. package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +2 -5
  163. package/types/date-time-picker/config/useFocusTracker.d.ts +38 -0
  164. package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +6 -6
  165. package/types/date-time-picker/config/useGetReferences.d.ts +30 -36
  166. package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +3 -1
  167. package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
  168. package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
  169. package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
  170. package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +14 -0
  171. package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -2
  172. package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +19 -0
  173. package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +0 -6
  174. package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +14 -0
  175. package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
  176. package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
  177. package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
  178. package/types/date-time-picker/propTypes.d.ts +117 -0
  179. package/types/date-time-picker/sharedTypes.d.ts +1 -1
  180. package/types/date-time-picker/utils/constants.d.ts +0 -6
  181. package/types/index.d.ts +1 -0
  182. package/types/input-group/InputGroup.d.ts +5 -0
  183. package/types/input-group/InputGroupDataTestIds.d.ts +6 -0
  184. package/types/input-group/index.d.ts +2 -0
  185. package/types/input-group/react-desc-prop-types.d.ts +19 -0
  186. package/types/input-group/styled.d.ts +7 -0
  187. package/types/input-group/tests/DSInputGroup.test.d.ts +1 -0
  188. package/types/mask-hook/hooks/useRegExpMask.d.ts +0 -1
  189. package/types/text-input/config/useInputText.d.ts +5 -5
  190. package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -51
  191. package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -47
  192. package/types/combobox/parts/menu-list/useMenuListSetFocusOption.d.ts +0 -1
@@ -2,17 +2,23 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ require('core-js/modules/web.dom-collections.iterator.js');
5
6
  var React = require('react');
6
7
 
7
- /* eslint-disable complexity */
8
8
  const useGetReferences = _ref => {
9
9
  let {
10
10
  isWithDateInputs,
11
11
  isWithTimeInputs,
12
+ isDateSelector,
13
+ isTimeSelector,
14
+ isDateTimeSelector,
12
15
  withAnyPicker,
13
16
  withClearBtn
14
17
  } = _ref;
15
- // refs are used for "auto-advance" feature
18
+ // those 2 states are needed for focus tracking
19
+ const [firstSegment, setFirstSegment] = React.useState('');
20
+ const [lastSegment, setLastSegment] = React.useState(''); // refs are used for "auto-advance" feature
21
+
16
22
  const monthInputRef = React.useRef(null);
17
23
  const dayInputRef = React.useRef(null);
18
24
  const yearInputRef = React.useRef(null);
@@ -36,22 +42,38 @@ const useGetReferences = _ref => {
36
42
  const currMeridiemBtnRef = React.useRef(null);
37
43
  const nextMeridiemBtnRef = React.useRef(null);
38
44
  let firstSegmentRef = React.useRef(null);
39
- if (isWithDateInputs) firstSegmentRef = monthInputRef;else if (isWithTimeInputs) firstSegmentRef = hourInputRef;else if (withAnyPicker) firstSegmentRef = pickerButtonRef; // we need some non-ref to force refresh of the hooks dependencies when using firstSegmentRef
40
45
 
41
- const firstFragmentRefUpdateDeps = React.useMemo(() => ({
42
- isWithDateInputs,
43
- isWithTimeInputs,
44
- withAnyPicker
45
- }), [isWithDateInputs, isWithTimeInputs, withAnyPicker]);
46
+ if (isWithDateInputs) {
47
+ firstSegmentRef = monthInputRef;
48
+ if (firstSegment !== 'month-input') setFirstSegment('month-input');
49
+ } else if (isWithTimeInputs) {
50
+ firstSegmentRef = hourInputRef;
51
+ if (firstSegment !== 'hour-input') setFirstSegment('hour-input');
52
+ } else if (withAnyPicker) {
53
+ firstSegmentRef = pickerButtonRef;
54
+ if (isDateSelector && firstSegment !== 'date-picker-icon') setFirstSegment('date-picker-icon');
55
+ if (isTimeSelector && firstSegment !== 'time-picker-icon') setFirstSegment('time-picker-icon');
56
+ if (isDateTimeSelector && firstSegment !== 'datetime-picker-icon') setFirstSegment('datetime-picker-icon');
57
+ }
58
+
46
59
  let lastSegmentRef = React.useRef(null);
47
- if (withAnyPicker) lastSegmentRef = pickerButtonRef;else if (withClearBtn) lastSegmentRef = clearButtonRef;else if (isWithTimeInputs) lastSegmentRef = meridiemInputRef;else if (isWithDateInputs) lastSegmentRef = yearInputRef; // we need some non-ref to force refresh of the hooks dependencies when using lastSegmentRef
48
60
 
49
- const lastFragmentRefUpdateDeps = React.useMemo(() => ({
50
- withAnyPicker,
51
- withClearBtn,
52
- isWithTimeInputs,
53
- isWithDateInputs
54
- }), [isWithDateInputs, isWithTimeInputs, withAnyPicker, withClearBtn]);
61
+ if (withAnyPicker) {
62
+ lastSegmentRef = pickerButtonRef;
63
+ if (isDateSelector && lastSegment !== 'date-picker-icon') setLastSegment('date-picker-icon');
64
+ if (isTimeSelector && lastSegment !== 'time-picker-icon') setLastSegment('time-picker-icon');
65
+ if (isDateTimeSelector && lastSegment !== 'datetime-picker-icon') setLastSegment('datetime-picker-icon');
66
+ } else if (withClearBtn) {
67
+ lastSegmentRef = clearButtonRef;
68
+ if (lastSegment !== 'clear-btn') setLastSegment('clear-btn');
69
+ } else if (isWithTimeInputs) {
70
+ lastSegmentRef = meridiemInputRef;
71
+ if (lastSegment !== 'meridiem-input') setLastSegment('meridiem-input');
72
+ } else if (isWithDateInputs) {
73
+ lastSegmentRef = yearInputRef;
74
+ if (lastSegment !== 'year-input') setLastSegment('year-input');
75
+ }
76
+
55
77
  return React.useMemo(() => ({
56
78
  monthInputRef,
57
79
  dayInputRef,
@@ -77,10 +99,9 @@ const useGetReferences = _ref => {
77
99
  nextMeridiemBtnRef,
78
100
  firstSegmentRef,
79
101
  lastSegmentRef,
80
- firstFragmentRefUpdateDeps,
81
- lastFragmentRefUpdateDeps
82
- }), [firstFragmentRefUpdateDeps, lastFragmentRefUpdateDeps] // if we remove this last/first segment won't work
83
- );
102
+ firstSegment,
103
+ lastSegment
104
+ }), [firstSegment, lastSegment]);
84
105
  };
85
106
 
86
107
  exports.useGetReferences = useGetReferences;
@@ -24,8 +24,8 @@ const useGlobalKeyHandlers = _ref => {
24
24
  let {
25
25
  propsBasedOnType,
26
26
  changeHandlers,
27
- DOMRefs,
28
- flags
27
+ flags,
28
+ focusTrackers
29
29
  } = _ref;
30
30
  const {
31
31
  getIsOutOfRangeDay,
@@ -42,13 +42,13 @@ const useGlobalKeyHandlers = _ref => {
42
42
  handleChangeComposedDateTimeString,
43
43
  handleClearAll
44
44
  } = changeHandlers;
45
- const {
46
- lastSegmentRef,
47
- clearButtonRef
48
- } = DOMRefs;
49
45
  const {
50
46
  shouldPreserveClearableSpace
51
47
  } = flags;
48
+ const {
49
+ trackFocusClearBtn,
50
+ trackFocusLastSegment
51
+ } = focusTrackers;
52
52
  const onFillWithCurrentDateKeys = React.useCallback(function (e) {
53
53
  let metaInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
54
54
  isAutomaticFillTrigger: true
@@ -78,12 +78,8 @@ const useGlobalKeyHandlers = _ref => {
78
78
  appOnMinuteChange(minutes, e, metaInfo);
79
79
  appOnMeridiemChange(meridiem, e, metaInfo);
80
80
  handleChangeComposedDateTimeString(nowDateString, nowTimeString, finalMetaInfo);
81
- setTimeout(() => {
82
- var _clearButtonRef$curre, _lastSegmentRef$curre;
83
-
84
- if (shouldPreserveClearableSpace) (_clearButtonRef$curre = clearButtonRef.current) === null || _clearButtonRef$curre === void 0 ? void 0 : _clearButtonRef$curre.focus();else (_lastSegmentRef$curre = lastSegmentRef.current) === null || _lastSegmentRef$curre === void 0 ? void 0 : _lastSegmentRef$curre.focus();
85
- });
86
- }, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, clearButtonRef, getIsDisabledDay, getIsDisabledTime, getIsOutOfRangeDay, handleChangeComposedDateTimeString, lastSegmentRef, shouldPreserveClearableSpace]);
81
+ if (shouldPreserveClearableSpace) trackFocusClearBtn();else trackFocusLastSegment();
82
+ }, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, getIsDisabledDay, getIsDisabledTime, getIsOutOfRangeDay, handleChangeComposedDateTimeString, shouldPreserveClearableSpace, trackFocusClearBtn, trackFocusLastSegment]);
87
83
  const onGlobalKeyDown = React.useCallback(e => {
88
84
  const {
89
85
  key,
@@ -9,12 +9,13 @@ require('core-js/modules/esnext.async-iterator.for-each.js');
9
9
  require('core-js/modules/esnext.iterator.for-each.js');
10
10
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
11
  var _jsx = require('@babel/runtime/helpers/jsx');
12
- require('react');
12
+ var React = require('react');
13
13
  var dsIcons = require('@elliemae/ds-icons');
14
14
  var dsIcon = require('@elliemae/ds-icon');
15
15
  var DSButton = require('@elliemae/ds-button');
16
16
  var Styleds = require('../Styleds.js');
17
17
  var ControlledDateTimePickerDatatestid = require('../../ControlledDateTimePickerDatatestid.js');
18
+ var ControlledDateTimePickerCTX = require('../../ControlledDateTimePickerCTX.js');
18
19
  var useClearButton = require('./useClearButton.js');
19
20
  var jsxRuntime = require('react/jsx-runtime');
20
21
 
@@ -36,12 +37,21 @@ const ClearButton = () => {
36
37
  const styledsAttrs = {
37
38
  shouldDisplay: withClearBtn
38
39
  };
40
+ const {
41
+ latestInteractionRegion,
42
+ currFocusDescriber
43
+ } = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
39
44
  return /*#__PURE__*/jsxRuntime.jsx(Styleds.StyledClearButton, _objectSpread(_objectSpread({
40
45
  "aria-label": "clear selected date",
41
46
  buttonType: "icon",
42
47
  size: DSButton.BUTTON_SIZES.M,
43
48
  "data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.CLEAR_BUTTON,
44
- innerRef: clearButtonRef,
49
+ innerRef: DomElem => {
50
+ var _DomElem$focus;
51
+
52
+ clearButtonRef.current = DomElem;
53
+ if (latestInteractionRegion === 'clear-btn' && currFocusDescriber === 'clear-btn') DomElem === null || DomElem === void 0 ? void 0 : (_DomElem$focus = DomElem.focus) === null || _DomElem$focus === void 0 ? void 0 : _DomElem$focus.call(DomElem);
54
+ },
45
55
  onClick: onClearClick,
46
56
  onKeyDown: onClearButtonKeyDown
47
57
  }, styledsAttrs), {}, {
@@ -15,32 +15,21 @@ const useClearButton = () => {
15
15
  withAnyInputs,
16
16
  isWithTimeInputs,
17
17
  isWithDateInputs,
18
- isTimeSelector,
19
- hourInputRef,
20
- monthInputRef,
21
- pickerButtonRef,
22
- meridiemInputRef,
23
- yearInputRef,
24
- setLatestInteractionRegion
18
+ trackFocusFirstSegment,
19
+ trackFocusMeridiemInput,
20
+ trackFocusYearInput,
21
+ trackFocusPicker
25
22
  } = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
26
- const focusFirstRegion = React.useCallback(() => {
27
- var _hourInputRef$current, _hourInputRef$current2, _monthInputRef$curren, _monthInputRef$curren2;
28
-
29
- if (withAnyInputs) if (isTimeSelector) 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 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);
30
- }, [withAnyInputs, isTimeSelector, hourInputRef, monthInputRef]);
31
23
  const onClearClick = React.useCallback(e => {
32
24
  handleClearAll(e);
33
- setLatestInteractionRegion('clear-btn');
34
- focusFirstRegion();
35
- }, [focusFirstRegion, handleClearAll, setLatestInteractionRegion]);
25
+ trackFocusFirstSegment();
26
+ }, [handleClearAll, trackFocusFirstSegment]);
36
27
  const onHomeKeyDown = React.useCallback(() => {
37
- focusFirstRegion();
38
- }, [focusFirstRegion]);
28
+ trackFocusFirstSegment();
29
+ }, [trackFocusFirstSegment]);
39
30
  const onEndKeyDown = React.useCallback(() => {
40
- var _pickerButtonRef$curr, _pickerButtonRef$curr2;
41
-
42
- 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);
43
- }, [withAnyPicker, pickerButtonRef]);
31
+ if (withAnyPicker) trackFocusPicker();
32
+ }, [withAnyPicker, trackFocusPicker]);
44
33
  const onClearButtonKeyDown = React.useCallback(e => {
45
34
  const {
46
35
  key
@@ -53,11 +42,9 @@ const useClearButton = () => {
53
42
  if (key === 'End') onEndKeyDown();
54
43
 
55
44
  if (key === 'Backspace' && withAnyInputs) {
56
- var _meridiemInputRef$cur, _meridiemInputRef$cur2, _yearInputRef$current, _yearInputRef$current2;
57
-
58
- 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);
45
+ if (isWithTimeInputs) trackFocusMeridiemInput();else if (isWithDateInputs) trackFocusYearInput();
59
46
  }
60
- }, [isWithDateInputs, isWithTimeInputs, meridiemInputRef, onEndKeyDown, onHomeKeyDown, withAnyInputs, yearInputRef]);
47
+ }, [isWithDateInputs, isWithTimeInputs, onEndKeyDown, onHomeKeyDown, trackFocusMeridiemInput, trackFocusYearInput, withAnyInputs]);
61
48
  return React.useMemo(() => ({
62
49
  onClearClick,
63
50
  onClearButtonKeyDown,
@@ -41,13 +41,13 @@ const ControlledDateTimePickerContent = () => {
41
41
  hideTime,
42
42
  hideTimePicker,
43
43
  hideDateTimePicker,
44
- setLatestInteractionRegion,
45
44
  withAnyPicker,
46
45
  withAnyRightController,
47
46
  shouldPreserveClearableSpace,
48
47
  isControllerOnly,
49
48
  dataAttrs,
50
- onGlobalKeyDown
49
+ onGlobalKeyDown,
50
+ trackFocusResetter
51
51
  } = React__default["default"].useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
52
52
  const styledsAttrs = {
53
53
  justPicker: hideDate && hideTime,
@@ -55,9 +55,6 @@ const ControlledDateTimePickerContent = () => {
55
55
  hasError,
56
56
  isControllerOnly
57
57
  };
58
- const resetLatestInteraction = React__default["default"].useCallback(() => {
59
- setLatestInteractionRegion('');
60
- }, [setLatestInteractionRegion]);
61
58
  const mainCols = [];
62
59
  if (!hideDate) mainCols.push('auto');
63
60
  if (!hideTime) mainCols.push('auto');
@@ -70,9 +67,9 @@ const ControlledDateTimePickerContent = () => {
70
67
  cols: mainCols,
71
68
  gutter: "xxs",
72
69
  pr: hideDatePicker && hideTimePicker && hideDateTimePicker ? '2px' : undefined,
73
- onBlur: resetLatestInteraction,
74
70
  onKeyDown: onGlobalKeyDown,
75
- disabled: disabled
71
+ disabled: disabled,
72
+ onBlur: trackFocusResetter
76
73
  }, styledsAttrs), dataAttrs), {}, {
77
74
  children: [hideDate ? null : _DateInputs || (_DateInputs = /*#__PURE__*/_jsx__default["default"](DateInputs.DateInputs, {})), hideTime ? null : _TimeInputs || (_TimeInputs = /*#__PURE__*/_jsx__default["default"](TimeInputs.TimeInputs, {})), withAnyRightController ? /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
78
75
  cols: rightControlCols
@@ -29,7 +29,8 @@ const DDInput = /*#__PURE__*/React__default["default"].memo(_ref => {
29
29
  disabled,
30
30
  contextRef,
31
31
  placeholder,
32
- ariaCurrentValueForInputs
32
+ ariaCurrentValueForInputs,
33
+ isFocused
33
34
  } = _ref;
34
35
  const validateOnChange = React.useCallback(e => {
35
36
  var _e$target;
@@ -47,7 +48,12 @@ const DDInput = /*#__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": "day input field, ".concat(ariaCurrentValueForInputs),
53
59
  "data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.DATE_INPUTS.DAY,
@@ -43,7 +43,9 @@ const DateInputs = () => {
43
43
  monthInputRef,
44
44
  dayInputRef,
45
45
  yearInputRef,
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.largeInputWidth]
@@ -57,7 +59,8 @@ const DateInputs = () => {
57
59
  autoFocusMonthInput: autoFocusMonthInput,
58
60
  placeholder: "MM",
59
61
  ariaCurrentValueForInputs: ariaCurrentValueForInputs,
60
- disabled: disabled
62
+ disabled: disabled,
63
+ isFocused: latestInteractionRegion === 'date-inputs' && currFocusDescriber === 'month-input'
61
64
  })), _StyledSeparator || (_StyledSeparator = /*#__PURE__*/_jsx__default["default"](Styleds.StyledSeparator, {
62
65
  alignItems: "center"
63
66
  }, void 0, "/")), /*#__PURE__*/_jsx__default["default"](Styleds.StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx__default["default"](DDInput.DDInput, {
@@ -69,7 +72,8 @@ const DateInputs = () => {
69
72
  contextRef: dayInputRef,
70
73
  placeholder: "DD",
71
74
  ariaCurrentValueForInputs: ariaCurrentValueForInputs,
72
- disabled: disabled
75
+ disabled: disabled,
76
+ isFocused: latestInteractionRegion === 'date-inputs' && currFocusDescriber === 'day-input'
73
77
  })), _StyledSeparator2 || (_StyledSeparator2 = /*#__PURE__*/_jsx__default["default"](Styleds.StyledSeparator, {
74
78
  alignItems: "center"
75
79
  }, void 0, "/")), /*#__PURE__*/_jsx__default["default"](Styleds.StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx__default["default"](YYYYInput.YYYYInput, {
@@ -81,7 +85,8 @@ const DateInputs = () => {
81
85
  contextRef: yearInputRef,
82
86
  placeholder: "YYYY",
83
87
  ariaCurrentValueForInputs: ariaCurrentValueForInputs,
84
- disabled: disabled
88
+ disabled: disabled,
89
+ isFocused: latestInteractionRegion === 'date-inputs' && currFocusDescriber === 'year-input'
85
90
  })));
86
91
  };
87
92
 
@@ -30,7 +30,8 @@ const MMInput = /*#__PURE__*/React__default["default"].memo(_ref => {
30
30
  placeholder,
31
31
  contextRef,
32
32
  autoFocusMonthInput,
33
- ariaCurrentValueForInputs
33
+ ariaCurrentValueForInputs,
34
+ isFocused
34
35
  } = _ref;
35
36
  const validateOnChange = React.useCallback(e => {
36
37
  var _e$target;
@@ -49,7 +50,12 @@ const MMInput = /*#__PURE__*/React__default["default"].memo(_ref => {
49
50
  onFocus: onFocus,
50
51
  onKeyDown: onKeyDown,
51
52
  value: value,
52
- ref: contextRef,
53
+ ref: DomElem => {
54
+ var _DomElem$focus;
55
+
56
+ contextRef.current = DomElem;
57
+ if (isFocused) DomElem === null || DomElem === void 0 ? void 0 : (_DomElem$focus = DomElem.focus) === null || _DomElem$focus === void 0 ? void 0 : _DomElem$focus.call(DomElem);
58
+ },
53
59
  placeholder: placeholder,
54
60
  "aria-label": "month input field, ".concat(ariaCurrentValueForInputs),
55
61
  "data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.DATE_INPUTS.MONTH,
@@ -29,7 +29,8 @@ const YYYYInput = /*#__PURE__*/React__default["default"].memo(_ref => {
29
29
  disabled,
30
30
  placeholder,
31
31
  contextRef,
32
- ariaCurrentValueForInputs
32
+ ariaCurrentValueForInputs,
33
+ isFocused
33
34
  } = _ref;
34
35
  const validateOnChange = React.useCallback(e => {
35
36
  var _e$target;
@@ -47,7 +48,12 @@ const YYYYInput = /*#__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": "year input field, ".concat(ariaCurrentValueForInputs),
53
59
  "data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.DATE_INPUTS.YEAR,