@elliemae/ds-controlled-form 2.4.2-rc.1 → 2.4.2-rc.13

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 (272) hide show
  1. package/cjs/autocomplete/config/useAutocomplete.js +0 -1
  2. package/cjs/autocomplete/parts/A11yFocusedOption.js +46 -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/container/useKeyboardNavigation.js +2 -2
  6. package/cjs/autocomplete/parts/menu-list/MenuList.js +6 -6
  7. package/cjs/autocomplete/parts/menu-list/styled.js +2 -2
  8. package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
  9. package/cjs/autocomplete/parts/styled.js +2 -0
  10. package/cjs/autocomplete/utils/listHelper.js +1 -1
  11. package/cjs/checkbox/ControlledCheckbox.js +1 -1
  12. package/cjs/checkbox/config/useValidateProps.js +6 -3
  13. package/cjs/checkbox/react-desc-prop-types.js +2 -1
  14. package/cjs/checkbox/styles.js +73 -27
  15. package/cjs/checkbox/utils/styleHelpers.js +20 -2
  16. package/cjs/combobox/ComboBoxCTX.js +6 -3
  17. package/cjs/combobox/config/useComboBox.js +16 -6
  18. package/cjs/combobox/config/useCorrectOptions.js +1 -2
  19. package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
  20. package/cjs/combobox/parts/A11ySelectedValues.js +2 -4
  21. package/cjs/combobox/parts/DropdownIndicator.js +15 -7
  22. package/cjs/combobox/parts/container/Container.js +11 -14
  23. package/cjs/combobox/parts/container/styled.js +11 -10
  24. package/cjs/combobox/parts/controls/Controls.js +19 -27
  25. package/cjs/combobox/parts/controls/styled.js +54 -22
  26. package/cjs/combobox/parts/controls/useOnPillsNavigation.js +7 -15
  27. package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -2
  28. package/cjs/combobox/parts/controls-input/styled.js +41 -11
  29. package/cjs/combobox/parts/controls-input/useControlsInput.js +4 -7
  30. package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +19 -28
  31. package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
  32. package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
  33. package/cjs/combobox/parts/header-list/HeaderList.js +1 -1
  34. package/cjs/combobox/parts/header-list/styled.js +39 -10
  35. package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
  36. package/cjs/combobox/parts/menu-list/MenuList.js +8 -6
  37. package/cjs/combobox/parts/menu-list/styled.js +38 -20
  38. package/cjs/combobox/parts/menu-list/useItemRenderer.js +18 -17
  39. package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
  40. package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
  41. package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
  42. package/cjs/combobox/parts/styled.js +6 -7
  43. package/cjs/combobox/react-desc-prop-types.js +3 -2
  44. package/cjs/combobox/sharedTypes.js +2 -2
  45. package/cjs/combobox/utils/listHelper.js +14 -9
  46. package/cjs/date-range-picker/config/useRangePickerLogic.js +4 -8
  47. package/cjs/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
  48. package/cjs/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
  49. package/cjs/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
  50. package/cjs/date-time-picker/config/useChangeHandlers.js +11 -15
  51. package/cjs/date-time-picker/config/useControlledDateTimePicker.js +14 -10
  52. package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
  53. package/cjs/date-time-picker/config/useGetDestructuredValues.js +6 -6
  54. package/cjs/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
  55. package/cjs/date-time-picker/config/useGetReferences.js +39 -18
  56. package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
  57. package/cjs/date-time-picker/config/useRelevantValueFromProps.js +1 -1
  58. package/cjs/date-time-picker/config/useValidateProps.js +42 -11
  59. package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +10 -2
  60. package/cjs/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
  61. package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
  62. package/cjs/date-time-picker/parts/DateInputs/DDInput.js +8 -6
  63. package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
  64. package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -6
  65. package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -6
  66. package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +84 -113
  67. package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
  68. package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +25 -7
  69. package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
  70. package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +21 -17
  71. package/cjs/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -15
  72. package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +13 -14
  73. package/cjs/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
  74. package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -39
  75. package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
  76. package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -29
  77. package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +2 -1
  78. package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +19 -27
  79. package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +15 -11
  80. package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +17 -13
  81. package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +15 -11
  82. package/cjs/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
  83. package/cjs/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -15
  84. package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +1 -1
  85. package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
  86. package/cjs/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
  87. package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
  88. package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -17
  89. package/cjs/date-time-picker/parts/Styleds.js +12 -6
  90. package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +7 -3
  91. package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -7
  92. package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -6
  93. package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
  94. package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +55 -97
  95. package/cjs/date-time-picker/utils/constants.js +0 -12
  96. package/cjs/date-time-picker/utils/dateHelpers.js +17 -34
  97. package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
  98. package/cjs/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
  99. package/cjs/date-time-picker/utils/stringHelpers.js +5 -11
  100. package/cjs/input-group/InputGroup.js +8 -7
  101. package/cjs/input-group/exported-related/data-test-ids.js +12 -0
  102. package/cjs/input-group/exported-related/index.js +12 -0
  103. package/cjs/input-group/exported-related/theming.js +13 -0
  104. package/cjs/input-group/styled.js +90 -23
  105. package/cjs/large-text-input/DSControlledLargeTextInput.js +1 -1
  106. package/cjs/large-text-input/styles.js +27 -13
  107. package/cjs/mask-hook/hooks/useNumberMask.js +1 -5
  108. package/cjs/mask-hook/hooks/usePhoneMask.js +1 -4
  109. package/cjs/mask-hook/hooks/useRegExpMask.js +4 -7
  110. package/cjs/mask-hook/hooks/useSSNMask.js +1 -4
  111. package/cjs/mask-hook/hooks/useZipCodeMask.js +1 -4
  112. package/cjs/mask-hook/utils/addSpecialCharacters.js +0 -1
  113. package/cjs/mask-hook/utils/flatStringArray.js +0 -1
  114. package/cjs/text-input/config/useInputText.js +0 -1
  115. package/cjs/text-input/styled/borders.js +18 -11
  116. package/cjs/text-input/styled/components.js +49 -10
  117. package/cjs/toggle/ControlledToggle.js +2 -3
  118. package/cjs/toggle/styles.js +7 -5
  119. package/esm/autocomplete/config/useAutocomplete.js +0 -1
  120. package/esm/autocomplete/parts/A11yFocusedOption.js +36 -0
  121. package/esm/autocomplete/parts/container/Container.js +39 -27
  122. package/esm/autocomplete/parts/container/styled.js +2 -2
  123. package/esm/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
  124. package/esm/autocomplete/parts/menu-list/MenuList.js +7 -7
  125. package/esm/autocomplete/parts/menu-list/styled.js +2 -2
  126. package/esm/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
  127. package/esm/autocomplete/parts/styled.js +1 -0
  128. package/esm/autocomplete/utils/listHelper.js +1 -1
  129. package/esm/checkbox/ControlledCheckbox.js +2 -2
  130. package/esm/checkbox/config/useValidateProps.js +6 -3
  131. package/esm/checkbox/react-desc-prop-types.js +2 -1
  132. package/esm/checkbox/styles.js +73 -24
  133. package/esm/checkbox/utils/styleHelpers.js +20 -2
  134. package/esm/combobox/ComboBoxCTX.js +6 -3
  135. package/esm/combobox/config/useComboBox.js +16 -6
  136. package/esm/combobox/config/useCorrectOptions.js +1 -2
  137. package/esm/combobox/parts/A11yFocusedOption.js +15 -7
  138. package/esm/combobox/parts/A11ySelectedValues.js +2 -4
  139. package/esm/combobox/parts/DropdownIndicator.js +15 -6
  140. package/esm/combobox/parts/container/Container.js +11 -14
  141. package/esm/combobox/parts/container/styled.js +11 -6
  142. package/esm/combobox/parts/controls/Controls.js +19 -27
  143. package/esm/combobox/parts/controls/styled.js +54 -18
  144. package/esm/combobox/parts/controls/useOnPillsNavigation.js +7 -15
  145. package/esm/combobox/parts/controls-input/ControlsInput.js +2 -2
  146. package/esm/combobox/parts/controls-input/styled.js +41 -7
  147. package/esm/combobox/parts/controls-input/useControlsInput.js +4 -7
  148. package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +20 -29
  149. package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
  150. package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
  151. package/esm/combobox/parts/header-list/HeaderList.js +1 -1
  152. package/esm/combobox/parts/header-list/styled.js +40 -7
  153. package/esm/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
  154. package/esm/combobox/parts/menu-list/MenuList.js +8 -6
  155. package/esm/combobox/parts/menu-list/styled.js +38 -17
  156. package/esm/combobox/parts/menu-list/useItemRenderer.js +20 -19
  157. package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
  158. package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
  159. package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
  160. package/esm/combobox/parts/styled.js +6 -3
  161. package/esm/combobox/react-desc-prop-types.js +3 -2
  162. package/esm/combobox/sharedTypes.js +2 -2
  163. package/esm/combobox/utils/listHelper.js +14 -10
  164. package/esm/date-range-picker/config/useRangePickerLogic.js +3 -7
  165. package/esm/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
  166. package/esm/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
  167. package/esm/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
  168. package/esm/date-time-picker/config/useChangeHandlers.js +11 -15
  169. package/esm/date-time-picker/config/useControlledDateTimePicker.js +14 -10
  170. package/esm/date-time-picker/config/useFocusTracker.js +132 -0
  171. package/esm/date-time-picker/config/useGetDestructuredValues.js +6 -6
  172. package/esm/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
  173. package/esm/date-time-picker/config/useGetReferences.js +40 -19
  174. package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
  175. package/esm/date-time-picker/config/useRelevantValueFromProps.js +1 -1
  176. package/esm/date-time-picker/config/useValidateProps.js +42 -11
  177. package/esm/date-time-picker/parts/ClearButton/ClearButton.js +10 -2
  178. package/esm/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
  179. package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
  180. package/esm/date-time-picker/parts/DateInputs/DDInput.js +8 -6
  181. package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
  182. package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -6
  183. package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -6
  184. package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +85 -114
  185. package/esm/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
  186. package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +26 -8
  187. package/esm/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
  188. package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +21 -17
  189. package/esm/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -14
  190. package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -13
  191. package/esm/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
  192. package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -40
  193. package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
  194. package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -29
  195. package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +2 -1
  196. package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +19 -27
  197. package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +16 -12
  198. package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +18 -14
  199. package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +16 -12
  200. package/esm/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
  201. package/esm/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -14
  202. package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +1 -1
  203. package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
  204. package/esm/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
  205. package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
  206. package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -17
  207. package/esm/date-time-picker/parts/Styleds.js +12 -6
  208. package/esm/date-time-picker/parts/TimeInputs/HHInput.js +7 -3
  209. package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -7
  210. package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -6
  211. package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
  212. package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +55 -97
  213. package/esm/date-time-picker/utils/constants.js +1 -7
  214. package/esm/date-time-picker/utils/dateHelpers.js +17 -34
  215. package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
  216. package/esm/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
  217. package/esm/date-time-picker/utils/stringHelpers.js +5 -11
  218. package/esm/input-group/InputGroup.js +5 -4
  219. package/esm/input-group/exported-related/data-test-ids.js +8 -0
  220. package/esm/input-group/exported-related/index.js +2 -0
  221. package/esm/input-group/exported-related/theming.js +8 -0
  222. package/esm/input-group/styled.js +89 -18
  223. package/esm/large-text-input/DSControlledLargeTextInput.js +1 -1
  224. package/esm/large-text-input/styles.js +27 -9
  225. package/esm/mask-hook/hooks/useNumberMask.js +1 -5
  226. package/esm/mask-hook/hooks/usePhoneMask.js +1 -4
  227. package/esm/mask-hook/hooks/useRegExpMask.js +4 -7
  228. package/esm/mask-hook/hooks/useSSNMask.js +1 -4
  229. package/esm/mask-hook/hooks/useZipCodeMask.js +1 -4
  230. package/esm/mask-hook/utils/addSpecialCharacters.js +0 -1
  231. package/esm/mask-hook/utils/flatStringArray.js +0 -1
  232. package/esm/text-input/config/useInputText.js +0 -1
  233. package/esm/text-input/styled/borders.js +18 -7
  234. package/esm/text-input/styled/components.js +49 -6
  235. package/esm/toggle/ControlledToggle.js +0 -1
  236. package/esm/toggle/styles.js +7 -5
  237. package/package.json +39 -15
  238. package/types/autocomplete/parts/A11yFocusedOption.d.ts +5 -0
  239. package/types/autocomplete/parts/container/styled.d.ts +1 -1
  240. package/types/autocomplete/parts/styled.d.ts +0 -0
  241. package/types/autocomplete/utils/listHelper.d.ts +5 -5
  242. package/types/checkbox/react-desc-prop-types.d.ts +1 -1
  243. package/types/checkbox/styles.d.ts +1 -0
  244. package/types/combobox/parts/menu-list/styled.d.ts +1 -0
  245. package/types/combobox/react-desc-prop-types.d.ts +8 -6
  246. package/types/combobox/sharedTypes.d.ts +3 -2
  247. package/types/combobox/utils/listHelper.d.ts +1 -0
  248. package/types/date-time-picker/config/useChangeHandlers.d.ts +3 -1
  249. package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +2 -5
  250. package/types/date-time-picker/config/useFocusTracker.d.ts +38 -0
  251. package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +6 -6
  252. package/types/date-time-picker/config/useGetReferences.d.ts +30 -36
  253. package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +3 -1
  254. package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
  255. package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
  256. package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
  257. package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +14 -0
  258. package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -2
  259. package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +19 -0
  260. package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +0 -6
  261. package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +14 -0
  262. package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
  263. package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
  264. package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
  265. package/types/date-time-picker/propTypes.d.ts +117 -0
  266. package/types/date-time-picker/sharedTypes.d.ts +1 -1
  267. package/types/date-time-picker/utils/constants.d.ts +0 -6
  268. package/types/input-group/exported-related/data-test-ids.d.ts +6 -0
  269. package/types/input-group/exported-related/index.d.ts +2 -0
  270. package/types/input-group/exported-related/theming.d.ts +6 -0
  271. package/types/input-group/styled.d.ts +4 -7
  272. package/types/text-input/config/useInputText.d.ts +4 -4
@@ -1,5 +1,4 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
3
2
  import { useContext, useMemo, useCallback } from 'react';
4
3
  import { styled } from '@elliemae/ds-system';
5
4
  import { DSButtonV2 } from '@elliemae/ds-button';
@@ -7,20 +6,30 @@ import { ChevronSmallDown } from '@elliemae/ds-icons';
7
6
  import { ComboBoxContext } from '../ComboBoxCTX.js';
8
7
  import { ComboboxDataTestid } from '../ComboboxDataTestids.js';
9
8
 
10
- var _templateObject;
11
- const StyledDropDownButton = styled(DSButtonV2)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &:focus::after {\n border: none;\n }\n &:hover:not(:disabled) {\n background-color: transparent;\n }\n\n & svg {\n fill: ", ";\n }\n"])), _ref => {
9
+ const StyledDropDownButton = styled(DSButtonV2)`
10
+ &:focus::after {
11
+ border: none;
12
+ }
13
+ &:hover:not(:disabled) {
14
+ background-color: transparent;
15
+ }
16
+
17
+ & svg {
18
+ fill: ${_ref => {
12
19
  let {
13
20
  theme,
14
21
  disabled
15
22
  } = _ref;
16
23
  return disabled ? theme.colors.neutral['400'] : theme.colors.brand['700'];
17
- });
24
+ }};
25
+ }
26
+ `;
18
27
  const DropdownIndicator = () => {
19
28
  const {
20
29
  props: {
21
30
  disabled
22
31
  },
23
- showPopover
32
+ menuState
24
33
  } = useContext(ComboBoxContext);
25
34
  const colorButton = useMemo(() => disabled ? ['neutral', 400] : ['brand-primary', 700], [disabled]);
26
35
  const handleOnClick = useCallback(e => {
@@ -32,7 +41,7 @@ const DropdownIndicator = () => {
32
41
  "aria-controls": "combo-listbox",
33
42
  "aria-labelledby": "combo-label",
34
43
  disabled: disabled,
35
- "aria-expanded": showPopover,
44
+ "aria-expanded": menuState,
36
45
  "aria-haspopup": "listbox",
37
46
  "aria-hidden": true,
38
47
  buttonType: "icon",
@@ -28,15 +28,13 @@ const Container = () => {
28
28
 
29
29
  const {
30
30
  props,
31
- setShowPopover,
32
- showPopover,
31
+ setMenuState,
32
+ menuState,
33
33
  setReferenceElement,
34
34
  referenceElement
35
35
  } = useContext(ComboBoxContext);
36
36
  const {
37
37
  inline,
38
- onMenuOpen,
39
- onMenuClose,
40
38
  innerRef,
41
39
  startPlacementPreference,
42
40
  placementOrderPreference,
@@ -52,20 +50,19 @@ const Container = () => {
52
50
  e.preventDefault();
53
51
  }, []);
54
52
  const handleCloseMenu = useCallback(() => {
55
- setShowPopover(false);
56
- if (innerRef !== null && innerRef !== void 0 && innerRef.current) innerRef.current.blur();
57
- }, [innerRef, setShowPopover]);
53
+ setMenuState(false, 'blur');
54
+ if (innerRef?.current) innerRef.current.blur();
55
+ }, [innerRef, setMenuState]);
58
56
  useEffect(() => {
59
- const closeMenuOnWindowBlur = () => setShowPopover(false);
57
+ const closeMenuOnWindowBlur = () => {
58
+ setMenuState(false, 'blur');
59
+ };
60
60
 
61
61
  window.addEventListener('blur', closeMenuOnWindowBlur);
62
62
  return () => {
63
63
  window.removeEventListener('blur', closeMenuOnWindowBlur);
64
64
  };
65
- }, [setShowPopover]);
66
- useEffect(() => {
67
- if (onMenuOpen && showPopover) onMenuOpen();else if (onMenuClose && !showPopover) onMenuClose();
68
- }, [showPopover, onMenuOpen, onMenuClose]);
65
+ }, [setMenuState]);
69
66
  return useMemo(() => /*#__PURE__*/jsx(StyledContainer, _objectSpread(_objectSpread(_objectSpread({
70
67
  "data-testid": ComboboxDataTestid.CONTAINER,
71
68
  ref: setReferenceElement
@@ -76,7 +73,7 @@ const Container = () => {
76
73
  children: [_Controls2 || (_Controls2 = /*#__PURE__*/_jsx(Controls, {})), /*#__PURE__*/_jsx(DSPopperJS, {
77
74
  customOffset: [0, 5],
78
75
  referenceElement: referenceElement,
79
- showPopover: showPopover,
76
+ showPopover: menuState,
80
77
  closeContextMenu: handleCloseMenu,
81
78
  startPlacementPreference: startPlacementPreference,
82
79
  placementOrderPreference: placementOrderPreference,
@@ -89,7 +86,7 @@ const Container = () => {
89
86
  onMouseDown: handleMouseDown
90
87
  }, void 0, _MenuList2 || (_MenuList2 = /*#__PURE__*/_jsx(MenuList, {})))))]
91
88
  })
92
- })), [inline, setReferenceElement, globalsAttrs, referenceElement, showPopover, xStyledProps, handleCloseMenu, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex, handleMouseDown]);
89
+ })), [inline, setReferenceElement, globalsAttrs, referenceElement, menuState, xStyledProps, handleCloseMenu, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex, handleMouseDown]);
93
90
  };
94
91
 
95
92
  export { Container };
@@ -1,22 +1,27 @@
1
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
1
  import { styled } from '@elliemae/ds-system';
3
2
  import { DSComboBoxName, DSComboboxSlots } from '../../theming.js';
4
3
 
5
- var _templateObject, _templateObject2;
6
4
  const StyledContainer = styled('div', {
7
5
  name: DSComboBoxName,
8
6
  slot: DSComboboxSlots.CONTAINER
9
- })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n cursor: ", ";\n"])), _ref => {
7
+ })`
8
+ position: relative;
9
+ cursor: ${_ref => {
10
10
  let {
11
11
  disabled
12
12
  } = _ref;
13
13
  return disabled ? 'not-allowed' : 'default';
14
- });
15
- const StyledPopperWrapper = styled('div')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n cursor: ", ";\n overflow: auto;\n"])), _ref2 => {
14
+ }};
15
+ `;
16
+ const StyledPopperWrapper = styled('div')`
17
+ position: relative;
18
+ cursor: ${_ref2 => {
16
19
  let {
17
20
  disabled
18
21
  } = _ref2;
19
22
  return disabled ? 'not-allowed' : 'default';
20
- });
23
+ }};
24
+ overflow: auto;
25
+ `;
21
26
 
22
27
  export { StyledContainer, StyledPopperWrapper };
@@ -4,6 +4,7 @@ import { DropdownIndicator } from '../DropdownIndicator.js';
4
4
  import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
5
5
  import { ComboBoxContext } from '../../ComboBoxCTX.js';
6
6
  import { StyledControlsWrapper, StyledSelection, StyledHeaderActionsWrapper, StyleHeaderActionsSeparator } from './styled.js';
7
+ import { scrollIfNeeded } from '../../utils/listHelper.js';
7
8
  import { MultiSelectedValuesContainer } from '../multi-selected-values-container/MultiSelectedValuesContainer.js';
8
9
  import { ControlsInput } from '../controls-input/ControlsInput.js';
9
10
  import { useOnPillsNavigation } from './useOnPillsNavigation.js';
@@ -12,7 +13,7 @@ import { A11ySelectedValues } from '../A11ySelectedValues.js';
12
13
  import { RemovableSelectedValuePill } from '../multi-selected-values-container/RemovableSelectedValuePill.js';
13
14
  import { jsxs } from 'react/jsx-runtime';
14
15
 
15
- var _A11ySelectedValues, _A11yFocusedOption, _MultiSelectedValuesC, _ControlsInput, _DropdownIndicator;
16
+ var _A11ySelectedValues, _MultiSelectedValuesC, _A11yFocusedOption, _ControlsInput, _DropdownIndicator;
16
17
  const Controls = () => {
17
18
  const {
18
19
  props: {
@@ -24,50 +25,41 @@ const Controls = () => {
24
25
  innerRef
25
26
  },
26
27
  selectedOptionsRef,
27
- setShowPopover,
28
+ setMenuState,
28
29
  setFocusOptionIdx,
29
30
  hasFocus,
30
31
  listRef,
31
32
  focusOptionIdx,
32
- showPopover,
33
+ menuState,
33
34
  controlsWrapperRef
34
35
  } = useContext(ComboBoxContext);
35
36
  const handleOnClick = useCallback(() => {
36
- var _innerRef$current2;
37
-
38
37
  if (disabled) return;
39
38
 
40
- if (hasFocus && showPopover && !inline) {
41
- var _innerRef$current;
42
-
43
- setShowPopover(false);
39
+ if (hasFocus && menuState && !inline) {
40
+ setMenuState(false);
44
41
  setFocusOptionIdx('');
45
- (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.blur();
42
+ innerRef.current?.blur();
46
43
  return;
47
44
  }
48
45
 
49
- (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
50
- setShowPopover(true);
46
+ innerRef.current?.focus();
47
+ setMenuState(true);
51
48
  window.requestAnimationFrame(() => {
52
- if (listRef.current && window.scrollY < listRef.current.scrollHeight) {
53
- window.scrollTo({
54
- top: listRef.current.scrollHeight,
55
- behavior: 'smooth'
56
- });
57
- }
49
+ window.requestAnimationFrame(() => {
50
+ if (listRef.current) scrollIfNeeded(listRef.current);
51
+ });
58
52
  }); // eslint-disable-next-line react-hooks/exhaustive-deps
59
- }, [disabled, listRef, hasFocus, showPopover, inline, innerRef, setShowPopover, focusOptionIdx]); // this callback prevent to toggle the menu when clicking or removing pills
53
+ }, [disabled, listRef, hasFocus, menuState, inline, innerRef, setMenuState, focusOptionIdx]); // this callback prevent to toggle the menu when clicking or removing pills
60
54
 
61
55
  const handleOnPillsClick = useCallback(e => {
62
- if (showPopover || disabled) {
56
+ if (menuState || disabled) {
63
57
  e.stopPropagation();
64
58
  } else {
65
- var _innerRef$current3;
66
-
67
- (_innerRef$current3 = innerRef.current) === null || _innerRef$current3 === void 0 ? void 0 : _innerRef$current3.focus();
68
- setShowPopover(true);
59
+ innerRef.current?.focus();
60
+ setMenuState(true);
69
61
  }
70
- }, [showPopover, innerRef, disabled, setShowPopover]); // callback to prevent onBlur on the input when clicking in all the wrapper
62
+ }, [menuState, innerRef, disabled, setMenuState]); // callback to prevent onBlur on the input when clicking in all the wrapper
71
63
 
72
64
  const handleOnMouseDown = useCallback(e => {
73
65
  if (document.activeElement === innerRef.current || inline) {
@@ -92,12 +84,12 @@ const Controls = () => {
92
84
  children: [!inline && /*#__PURE__*/jsxs(StyledSelection, {
93
85
  ref: selectedOptionsRef,
94
86
  onClick: handleOnPillsClick,
95
- children: [_A11ySelectedValues || (_A11ySelectedValues = /*#__PURE__*/_jsx(A11ySelectedValues, {})), _A11yFocusedOption || (_A11yFocusedOption = /*#__PURE__*/_jsx(A11yFocusedOption, {})), Array.isArray(selectedValues) ? _MultiSelectedValuesC || (_MultiSelectedValuesC = /*#__PURE__*/_jsx(MultiSelectedValuesContainer, {})) : /*#__PURE__*/_jsx("div", {
87
+ children: [_A11ySelectedValues || (_A11ySelectedValues = /*#__PURE__*/_jsx(A11ySelectedValues, {})), Array.isArray(selectedValues) ? _MultiSelectedValuesC || (_MultiSelectedValuesC = /*#__PURE__*/_jsx(MultiSelectedValuesContainer, {})) : /*#__PURE__*/_jsx("div", {
96
88
  "data-testid": ComboboxDataTestid.SELECTED_VALUES
97
89
  }, void 0, selectedValues && /*#__PURE__*/_jsx(RemovableSelectedValuePill, {
98
90
  pill: selectedValues
99
91
  }))]
100
- }), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx(ControlsInput, {})), !inline && /*#__PURE__*/_jsx(StyledHeaderActionsWrapper, {
92
+ }), _A11yFocusedOption || (_A11yFocusedOption = /*#__PURE__*/_jsx(A11yFocusedOption, {})), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx(ControlsInput, {})), !inline && /*#__PURE__*/_jsx(StyledHeaderActionsWrapper, {
101
93
  justifyContent: "center",
102
94
  cols: ['min-content', 'min-content']
103
95
  }, void 0, /*#__PURE__*/_jsx(StyleHeaderActionsSeparator, {
@@ -1,58 +1,94 @@
1
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
1
  import { css, styled } from '@elliemae/ds-system';
3
2
  import { Grid } from '@elliemae/ds-grid';
4
3
  import { DSComboBoxName, DSComboboxSlots } from '../../theming.js';
5
4
 
6
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
7
- const normalBorder = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n"])), _ref => {
5
+ const normalBorder = css`
6
+ border: 1px solid ${_ref => {
8
7
  let {
9
8
  hasError,
10
9
  theme
11
10
  } = _ref;
12
11
  return hasError ? theme.colors.danger[900] : theme.colors.neutral[400];
13
- });
14
- const focusBorder = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n outline: 2px solid ", ";\n outline-offset: -2px;\n"])), _ref2 => {
12
+ }};
13
+ `;
14
+ const focusBorder = css`
15
+ outline: 2px solid ${_ref2 => {
15
16
  let {
16
17
  theme
17
18
  } = _ref2;
18
19
  return theme.colors.brand[700];
19
- });
20
- const hoverBorder = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n"])), _ref3 => {
20
+ }};
21
+ outline-offset: -2px;
22
+ `;
23
+ const hoverBorder = css`
24
+ border: 1px solid ${_ref3 => {
21
25
  let {
22
26
  theme
23
27
  } = _ref3;
24
28
  return theme.colors.brand[700];
25
- });
29
+ }};
30
+ `;
26
31
  const StyledControlsWrapper = styled(Grid, {
27
32
  name: DSComboBoxName,
28
33
  slot: DSComboboxSlots.INPUT_WRAPPER
29
- })(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background: ", ";\n position: relative;\n border-radius: 2px;\n min-width: ", ";\n align-items: center;\n align-content: center;\n height: 28px;\n padding-left: 8px;\n margin: ", ";\n ", "\n &:hover {\n ", "\n }\n &:focus-within {\n ", "\n }\n"])), _ref4 => {
34
+ })`
35
+ background: ${_ref4 => {
30
36
  let {
31
37
  disabled,
32
38
  theme
33
39
  } = _ref4;
34
40
  return disabled ? theme.colors.neutral['080'] : '#ffffff';
35
- }, _ref5 => {
41
+ }};
42
+ position: relative;
43
+ border-radius: 2px;
44
+ min-width: ${_ref5 => {
36
45
  let {
37
46
  minWidth,
38
47
  inline
39
48
  } = _ref5;
40
- return inline || !minWidth ? '' : "".concat(minWidth, "px");
41
- }, _ref6 => {
49
+ return inline || !minWidth ? '' : `${minWidth}px`;
50
+ }};
51
+ align-items: center;
52
+ align-content: center;
53
+ height: 28px;
54
+ padding-left: 8px;
55
+ margin: ${_ref6 => {
42
56
  let {
43
57
  inline
44
58
  } = _ref6;
45
59
  return inline ? '10px 16px' : '';
46
- }, normalBorder, hoverBorder, focusBorder);
47
- const StyledSelection = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 13px;\n margin-right: 3px;\n display: flex;\n"])));
48
- const StyledHeaderActionsWrapper = styled(Grid)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n height: 100%;\n .em-ds-button--text:focus::after {\n border: none;\n }\n"])));
49
- const StyleDropdownIndicator = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral([""])));
50
- const StyleHeaderActionsSeparator = styled.span(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n align-self: stretch;\n margin: 4px 0px;\n width: 1px;\n background-color: ", ";\n"])), _ref7 => {
60
+ }};
61
+ ${normalBorder}
62
+ &:hover {
63
+ ${hoverBorder}
64
+ }
65
+ &:focus-within {
66
+ ${focusBorder}
67
+ }
68
+ `;
69
+ const StyledSelection = styled.div`
70
+ font-size: 13px;
71
+ margin-right: 3px;
72
+ display: flex;
73
+ `;
74
+ const StyledHeaderActionsWrapper = styled(Grid)`
75
+ height: 100%;
76
+ .em-ds-button--text:focus::after {
77
+ border: none;
78
+ }
79
+ `;
80
+ const StyleDropdownIndicator = styled.div``;
81
+ const StyleHeaderActionsSeparator = styled.span`
82
+ align-self: stretch;
83
+ margin: 4px 0px;
84
+ width: 1px;
85
+ background-color: ${_ref7 => {
51
86
  let {
52
87
  theme,
53
88
  disabled
54
89
  } = _ref7;
55
90
  return disabled ? theme.colors.neutral['400'] : theme.colors.neutral['500'];
56
- });
91
+ }};
92
+ `;
57
93
 
58
94
  export { StyleDropdownIndicator, StyleHeaderActionsSeparator, StyledControlsWrapper, StyledHeaderActionsWrapper, StyledSelection };
@@ -9,7 +9,7 @@ const useOnPillsNavigation = () => {
9
9
  },
10
10
  inputValue,
11
11
  hasFocus,
12
- setShowPopover,
12
+ setMenuState,
13
13
  selectedOptionsRef
14
14
  } = useContext(ComboBoxContext); // todo: constant must be defined on pills component
15
15
 
@@ -17,33 +17,25 @@ const useOnPillsNavigation = () => {
17
17
  const onKeyDownPills = useCallback(e => {
18
18
  if ((e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'ArrowUp' || e.key === 'ArrowDown') && inputValue === '') {
19
19
  if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
20
- var _innerRef$current;
21
-
22
- (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
23
- setShowPopover(true);
20
+ innerRef.current?.focus();
21
+ setMenuState(true, 'open', e);
24
22
  return;
25
23
  }
26
24
 
27
25
  if (e.key === 'ArrowLeft') {
28
- var _selectedOptionsRef$c;
29
-
30
- const removablePills = (_selectedOptionsRef$c = selectedOptionsRef.current) === null || _selectedOptionsRef$c === void 0 ? void 0 : _selectedOptionsRef$c.querySelectorAll(REMOVABLE_PILL_SELECTOR);
26
+ const removablePills = selectedOptionsRef.current?.querySelectorAll(REMOVABLE_PILL_SELECTOR);
31
27
 
32
28
  if (hasFocus && removablePills) {
33
- var _removablePills;
34
-
35
- (_removablePills = removablePills[removablePills.length - 1]) === null || _removablePills === void 0 ? void 0 : _removablePills.focus();
29
+ removablePills[removablePills.length - 1]?.focus();
36
30
  }
37
31
  }
38
32
 
39
33
  if (e.key === 'ArrowRight') {
40
- var _innerRef$current2;
41
-
42
34
  e.preventDefault();
43
- (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
35
+ innerRef.current?.focus();
44
36
  }
45
37
  }
46
- }, [inputValue, hasFocus, innerRef, selectedOptionsRef, setShowPopover]);
38
+ }, [inputValue, innerRef, setMenuState, selectedOptionsRef, hasFocus]);
47
39
  return {
48
40
  onKeyDownPills
49
41
  };
@@ -19,7 +19,7 @@ const ControlsInput = () => {
19
19
  },
20
20
  focusOptionIdx,
21
21
  inputValue,
22
- showPopover
22
+ menuState
23
23
  } = useContext(ComboBoxContext);
24
24
  const {
25
25
  onInputKeyDown
@@ -44,7 +44,7 @@ const ControlsInput = () => {
44
44
  placeholder: placeholder,
45
45
  "aria-controls": "combo-listbox",
46
46
  "aria-activedescendant": focusOptionIdx,
47
- "aria-expanded": showPopover,
47
+ "aria-expanded": menuState,
48
48
  "aria-haspopup": "listbox",
49
49
  "aria-describedby": "combobox-selected-items",
50
50
  role: "combobox",
@@ -1,19 +1,53 @@
1
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
1
  import { styled } from '@elliemae/ds-system';
3
2
  import { DSComboBoxName, DSComboboxSlots } from '../../theming.js';
4
3
 
5
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
4
  const StyledInput = styled('input', {
7
5
  name: DSComboBoxName,
8
6
  slot: DSComboboxSlots.INPUT
9
- })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ", ";\n &:focus {\n outline: none;\n }\n ", "\n &::placeholder {\n color: transparent;\n }\n"])), props => props.theme.colors.neutral[700], _ref => {
7
+ })`
8
+ font-size: 13px;
9
+ line-height: 13px;
10
+ border: none;
11
+ padding: 0;
12
+ outline: none;
13
+ color: ${props => props.theme.colors.neutral[700]};
14
+ &:focus {
15
+ outline: none;
16
+ }
17
+ ${_ref => {
10
18
  let {
11
19
  withoutCaret
12
20
  } = _ref;
13
21
  return withoutCaret && 'caret-color: transparent;';
14
- });
15
- const StyledInputPlaceHolder = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-style: italic;\n color: ", ";\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n font-size: 13px;\n & span::after {\n content: '';\n padding: 1px;\n }\n"])), props => props.theme.colors.neutral[500]);
16
- const StyledInputWidthReference = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n visibility: hidden;\n position: absolute;\n top: -9999px;\n"])));
17
- const StyledInputWrapper = styled('div')(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n align-items: center;\n display: flex;\n"])));
22
+ }}
23
+ &::placeholder {
24
+ color: transparent;
25
+ }
26
+ `;
27
+ const StyledInputPlaceHolder = styled.div`
28
+ font-style: italic;
29
+ color: ${props => props.theme.colors.neutral[500]};
30
+ position: absolute;
31
+ display: flex;
32
+ align-items: center;
33
+ width: 100%;
34
+ user-select: none;
35
+ height: 28px;
36
+ font-size: 13px;
37
+ & span::after {
38
+ content: '';
39
+ padding: 1px;
40
+ }
41
+ `;
42
+ const StyledInputWidthReference = styled.span`
43
+ visibility: hidden;
44
+ position: absolute;
45
+ top: -9999px;
46
+ `;
47
+ const StyledInputWrapper = styled('div')`
48
+ position: relative;
49
+ align-items: center;
50
+ display: flex;
51
+ `;
18
52
 
19
53
  export { StyledInput, StyledInputPlaceHolder, StyledInputWidthReference, StyledInputWrapper };
@@ -1,5 +1,3 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import 'core-js/modules/es.string.replace.js';
3
1
  import { useContext, useState, useRef, useEffect, useCallback, useMemo } from 'react';
4
2
  import { useMaskedOnChange } from './useMaskedOnChange.js';
5
3
  import { ComboBoxContext } from '../../ComboBoxCTX.js';
@@ -15,6 +13,7 @@ const useControlsInput = () => {
15
13
  },
16
14
  setHasFocus,
17
15
  inputValue,
16
+ setMenuState,
18
17
  setInputValue
19
18
  } = useContext(ComboBoxContext);
20
19
  const [width, setWidth] = useState(1); // use span reference to calculate the real width for the input
@@ -23,18 +22,16 @@ const useControlsInput = () => {
23
22
  const showPlaceholder = !inputValue && isSelectedValueEmpty(selectedValues) ? placeholder : null;
24
23
  const spanReferenceText = inputValue.replace(/\s/g, '\u00a0');
25
24
  useEffect(() => {
26
- var _spanReference$curren;
27
-
28
- setWidth((_spanReference$curren = spanReference.current) !== null && _spanReference$curren !== void 0 && _spanReference$curren.offsetWidth ? spanReference.current.offsetWidth + 2 : 1);
25
+ setWidth(spanReference.current?.offsetWidth ? spanReference.current.offsetWidth + 2 : 1);
29
26
  }, [inputValue]); // if we se an input mask we configure inside here the proper mask
30
27
  // or a stardard combobox onchange event
31
28
 
32
29
  const handleOnChange = useMaskedOnChange();
33
30
  const handleOnBlur = useCallback(() => {
34
31
  setInputValue('');
35
- if (onFilter) onFilter(allOptions, inputValue);
32
+ if (onFilter) onFilter(allOptions);
36
33
  setHasFocus(false);
37
- }, [setInputValue, onFilter, allOptions, inputValue, setHasFocus]);
34
+ }, [setInputValue, onFilter, allOptions, setHasFocus]);
38
35
  const handleOnFocus = useCallback(() => {
39
36
  setHasFocus(true);
40
37
  }, [setHasFocus]);
@@ -5,7 +5,7 @@ import 'core-js/modules/esnext.async-iterator.filter.js';
5
5
  import 'core-js/modules/esnext.iterator.filter.js';
6
6
  import { useContext, useCallback } from 'react';
7
7
  import { ComboBoxContext } from '../../ComboBoxCTX.js';
8
- import { getOptions, getSuggestedValueOnChange, findInCircularList, getLastValueSelected } from '../../utils/listHelper.js';
8
+ import { getOptions, scrollIfNeeded, getSuggestedValueOnChange, findInCircularList, getLastValueSelected } from '../../utils/listHelper.js';
9
9
  import { MENU_OPTION_TYPES, INTERNAL_MENU_OPTION_TYPES } from '../../constants.js';
10
10
 
11
11
  const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type) && !opt.disabled;
@@ -26,12 +26,12 @@ const useKeyboardNavigation = () => {
26
26
  withoutPortal
27
27
  },
28
28
  inputValue,
29
- showPopover,
29
+ menuState,
30
30
  focusOptionIdx,
31
31
  listRef,
32
32
  selectAllCheckboxRef,
33
33
  toggleSelectionButtonRef,
34
- setShowPopover,
34
+ setMenuState,
35
35
  setInputValue,
36
36
  scrollOptionIntoView,
37
37
  setFocusOptionIdx
@@ -44,17 +44,12 @@ const useKeyboardNavigation = () => {
44
44
  // =============================================================================
45
45
  // CUSTOM KEYS
46
46
  // =============================================================================
47
- if (onKeyDown && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === MENU_OPTION_TYPES.OPTION) onKeyDown(e, currentItem);
47
+ if (onKeyDown && currentItem?.type === MENU_OPTION_TYPES.OPTION) onKeyDown(e, currentItem);
48
48
 
49
- if (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) {
50
- setShowPopover(true);
49
+ if ((['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) && !menuState) {
50
+ setMenuState(true);
51
51
  window.requestAnimationFrame(() => {
52
- if (listRef.current && window.scrollY < listRef.current.offsetHeight) {
53
- window.scrollTo({
54
- top: listRef.current.offsetHeight,
55
- behavior: 'smooth'
56
- });
57
- }
52
+ if (listRef.current) scrollIfNeeded(listRef.current);
58
53
  });
59
54
  } // =============================================================================
60
55
  // ESCAPE
@@ -69,13 +64,13 @@ const useKeyboardNavigation = () => {
69
64
  setInputValue('');
70
65
  }
71
66
 
72
- if (!inline) setShowPopover(false);
67
+ if (!inline) setMenuState(false, 'close', e);
73
68
  } // =============================================================================
74
69
  // ENTER KEY TO CREATE ELEMENTS
75
70
  // =============================================================================
76
71
 
77
72
 
78
- if (e.key === 'Enter' && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
73
+ if (e.key === 'Enter' && currentItem?.type === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
79
74
  onCreate(inputValue); // blank active item to force search last one
80
75
 
81
76
  setFocusOptionIdx('');
@@ -91,12 +86,12 @@ const useKeyboardNavigation = () => {
91
86
  e.preventDefault();
92
87
  e.stopPropagation();
93
88
 
94
- if (focusOptionIdx !== '' && (showPopover || inline) && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
89
+ if (focusOptionIdx !== '' && (menuState || inline) && currentItem?.type === MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
95
90
  if (onFilter) onFilter(allOptions, '');
96
91
  setInputValue('');
97
92
 
98
93
  if (!multiple) {
99
- setShowPopover(false);
94
+ setMenuState(false, 'selectOption', e);
100
95
  }
101
96
 
102
97
  onChange(getSuggestedValueOnChange(currentItem, selectedValues), currentItem, e);
@@ -104,7 +99,7 @@ const useKeyboardNavigation = () => {
104
99
  }
105
100
 
106
101
  if (e.key === 'Enter' && e.altKey) {
107
- setShowPopover(false);
102
+ setMenuState(false, 'selectOption', e);
108
103
  }
109
104
 
110
105
  if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {
@@ -118,7 +113,7 @@ const useKeyboardNavigation = () => {
118
113
  e.preventDefault();
119
114
  e.stopPropagation();
120
115
 
121
- if ((showPopover || inline) && selectableOptions.length) {
116
+ if ((menuState || inline) && selectableOptions.length) {
122
117
  const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);
123
118
 
124
119
  if (nextItemIndexIndex > -1) {
@@ -135,12 +130,12 @@ const useKeyboardNavigation = () => {
135
130
  const prevItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
136
131
 
137
132
  if (prevItemIndex > -1) {
138
- if (showPopover || inline) {
133
+ if (menuState || inline) {
139
134
  setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
140
135
  scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
141
136
  } else {
142
137
  // open menu and search last item to focused
143
- setShowPopover(true);
138
+ setMenuState(true, 'open', e);
144
139
  const lastItemIndex = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
145
140
  setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
146
141
  setTimeout(() => {
@@ -163,22 +158,18 @@ const useKeyboardNavigation = () => {
163
158
  if (onFilter) onFilter(allOptions, inputValue);
164
159
  }
165
160
 
166
- if (e.key === 'Tab' && !inline && !withoutPortal) {
167
- var _selectAllCheckboxRef;
168
-
169
- const element = (_selectAllCheckboxRef = selectAllCheckboxRef.current) !== null && _selectAllCheckboxRef !== void 0 ? _selectAllCheckboxRef : toggleSelectionButtonRef.current;
161
+ if (e.key === 'Tab' && !inline && menuState) {
162
+ const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;
170
163
 
171
164
  if (element) {
172
165
  e.preventDefault();
173
166
  element.focus();
167
+ } else {
168
+ setMenuState(false, 'blur', e);
174
169
  }
175
170
  }
176
-
177
- if (e.key === 'Tab' && !multiple && showPopover) {
178
- setShowPopover(false);
179
- }
180
171
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
181
- [onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, listRef, focusOptionIdx, showPopover, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
172
+ [onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setMenuState, onCancel, onFilter, setInputValue, listRef, focusOptionIdx, menuState, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
182
173
  return {
183
174
  onInputKeyDown
184
175
  };