@elliemae/ds-controlled-form 2.4.2-rc.0 → 2.4.2-rc.12

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
@@ -35,7 +35,6 @@ const useAutocomplete = props => {
35
35
  const [focusOptionIdx, setCurrentOption] = React.useState('');
36
36
  const inputRef = React.useRef(null);
37
37
  const listRef = React.useRef(null);
38
- const selectedOptionsRef = React.useRef(null);
39
38
  const {
40
39
  options,
41
40
  filter
@@ -74,12 +73,11 @@ const useAutocomplete = props => {
74
73
  inputRef,
75
74
  listRef,
76
75
  focusOptionIdx,
77
- selectedOptionsRef,
78
76
  setCurrentOption,
79
77
  scrollOptionIntoView,
80
78
  setReferenceElement,
81
79
  setShowPopover
82
- }), [scrollOptionIntoView, propsWithDefault, virtualListHelpers, focusOptionIdx, showPopover, referenceElement, inputRef, selectedOptionsRef, listRef]);
80
+ }), [scrollOptionIntoView, propsWithDefault, virtualListHelpers, focusOptionIdx, showPopover, referenceElement, inputRef, listRef]);
83
81
  return ctx;
84
82
  };
85
83
 
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _jsx = require('@babel/runtime/helpers/jsx');
6
+ var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
7
+ require('core-js/modules/esnext.async-iterator.find.js');
8
+ require('core-js/modules/esnext.iterator.constructor.js');
9
+ require('core-js/modules/esnext.iterator.find.js');
10
+ var React = require('react');
11
+ var dsSystem = require('@elliemae/ds-system');
12
+ var AutocompleteCTX = require('../AutocompleteCTX.js');
13
+ var listHelper = require('../utils/listHelper.js');
14
+
15
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
+
17
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
18
+ var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
19
+
20
+ var _templateObject;
21
+ const isSeparator = el => (el === null || el === void 0 ? void 0 : el.type) === 'separator';
22
+ const StyledA11ySelectedValues = dsSystem.styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n width: 1px;\n height: 1px;\n position: absolute;\n clip: rect(1px, 1px, 1px, 1px);\n"])));
23
+ const A11yFocusedOption = () => {
24
+ const {
25
+ props: {
26
+ options
27
+ },
28
+ focusOptionIdx,
29
+ showPopover
30
+ } = React.useContext(AutocompleteCTX.AutocompleteContext);
31
+ return React.useMemo(() => {
32
+ const selectabledOptions = listHelper.getSelectableOptions(options);
33
+ const focusOption = options.find(option => !isSeparator(option) && option.dsId === focusOptionIdx);
34
+ const focusSelectableOptionIdx = selectabledOptions.findIndex(option => option.dsId === focusOptionIdx);
35
+ return /*#__PURE__*/_jsx__default["default"](StyledA11ySelectedValues, {
36
+ "aria-live": "polite"
37
+ }, void 0, !isSeparator(focusOption) && showPopover && focusOption && "option ".concat(focusOption.label, " focused.").concat(focusSelectableOptionIdx + 1, " of ").concat(selectabledOptions.length, "\n "));
38
+ }, [options, showPopover, focusOptionIdx]);
39
+ };
40
+
41
+ exports.A11yFocusedOption = A11yFocusedOption;
42
+ exports.StyledA11ySelectedValues = StyledA11ySelectedValues;
43
+ exports.isSeparator = isSeparator;
@@ -13,6 +13,7 @@ var styled = require('./styled.js');
13
13
  var MenuList = require('../menu-list/MenuList.js');
14
14
  var useKeyboardNavigation = require('./useKeyboardNavigation.js');
15
15
  var AutocompleteDataTestids = require('../../AutocompleteDataTestids.js');
16
+ var A11yFocusedOption = require('../A11yFocusedOption.js');
16
17
  var jsxRuntime = require('react/jsx-runtime');
17
18
 
18
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -20,10 +21,11 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
20
21
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
21
22
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
23
 
23
- var _StyledPopperWrapper;
24
+ var _A11yFocusedOption, _StyledPopperWrapper;
24
25
  const Container = () => {
25
26
  const {
26
27
  props: {
28
+ id,
27
29
  startPlacementPreference,
28
30
  children,
29
31
  filter,
@@ -32,6 +34,7 @@ const Container = () => {
32
34
  showPopover,
33
35
  setReferenceElement,
34
36
  setShowPopover,
37
+ focusOptionIdx,
35
38
  referenceElement
36
39
  } = React.useContext(AutocompleteCTX.AutocompleteContext);
37
40
  React.useEffect(() => {
@@ -47,32 +50,41 @@ const Container = () => {
47
50
  const handleCloseMenu = React.useCallback(() => {
48
51
  setShowPopover(false);
49
52
  }, [setShowPopover]);
50
- const input = React__default["default"].Children.only(children);
51
53
  const {
52
54
  onInputKeyDown
53
55
  } = useKeyboardNavigation.useKeyboardNavigation();
54
- return /*#__PURE__*/jsxRuntime.jsxs(styled.StyledContainerWithPopper, {
55
- ref: setReferenceElement,
56
- role: "combobox",
57
- "aria-autocomplete": "list",
58
- "aria-controls": "autocomplete-listbox",
59
- "aria-expanded": showPopover,
60
- onKeyDown: onInputKeyDown,
61
- "data-testid": AutocompleteDataTestids.AutocompleteDataTestid.CONTAINER,
62
- children: [input, filter && /*#__PURE__*/_jsx__default["default"](dsPopperjs.DSPopperJS, {
63
- customOffset: [0, 5],
64
- closeContextMenu: handleCloseMenu,
65
- referenceElement: referenceElement,
66
- showPopover: showPopover,
67
- startPlacementPreference: startPlacementPreference,
68
- placementOrderPreference: placementOrderPreference,
69
- withoutPortal: true,
70
- withoutArrow: true,
71
- withoutAnimation: true,
72
- zIndex: 10
73
- }, void 0, _StyledPopperWrapper || (_StyledPopperWrapper = /*#__PURE__*/_jsx__default["default"](styled.StyledPopperWrapper, {
74
- tabIndex: -1
75
- }, void 0, /*#__PURE__*/_jsx__default["default"](MenuList.MenuList, {}))))]
56
+ const input = React__default["default"].Children.only(children);
57
+ const childrenWithProps = /*#__PURE__*/React__default["default"].isValidElement(input) ? /*#__PURE__*/React__default["default"].cloneElement(input, {
58
+ 'aria-activedescendant': focusOptionIdx
59
+ }) : input;
60
+ const idList = React.useMemo(() => "".concat(id ? "".concat(id, "-") : '', "listbox"), [id]);
61
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
62
+ children: [_A11yFocusedOption || (_A11yFocusedOption = /*#__PURE__*/_jsx__default["default"](A11yFocusedOption.A11yFocusedOption, {})), /*#__PURE__*/jsxRuntime.jsxs(styled.StyledContainer, {
63
+ id: id,
64
+ ref: setReferenceElement,
65
+ role: "combobox",
66
+ "aria-autocomplete": "list",
67
+ "aria-controls": "autocomplete-listbox",
68
+ "aria-expanded": showPopover,
69
+ "aria-haspopup": "listbox",
70
+ "aria-owns": idList,
71
+ onKeyDown: onInputKeyDown,
72
+ "data-testid": AutocompleteDataTestids.AutocompleteDataTestid.CONTAINER,
73
+ children: [childrenWithProps, filter && /*#__PURE__*/_jsx__default["default"](dsPopperjs.DSPopperJS, {
74
+ customOffset: [0, 5],
75
+ closeContextMenu: handleCloseMenu,
76
+ referenceElement: referenceElement,
77
+ showPopover: showPopover,
78
+ startPlacementPreference: startPlacementPreference,
79
+ placementOrderPreference: placementOrderPreference,
80
+ withoutPortal: true,
81
+ withoutArrow: true,
82
+ withoutAnimation: true,
83
+ zIndex: 10
84
+ }, void 0, _StyledPopperWrapper || (_StyledPopperWrapper = /*#__PURE__*/_jsx__default["default"](styled.StyledPopperWrapper, {
85
+ tabIndex: -1
86
+ }, void 0, /*#__PURE__*/_jsx__default["default"](MenuList.MenuList, {}))))]
87
+ })]
76
88
  });
77
89
  };
78
90
 
@@ -8,12 +8,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
10
 
11
- const StyledContainerWithPopper = /*#__PURE__*/styled__default["default"].div.withConfig({
11
+ const StyledContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
12
12
  componentId: "sc-xupfk9-0"
13
13
  })(["width:100%;height:28px;position:relative;"]);
14
14
  const StyledPopperWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
15
15
  componentId: "sc-xupfk9-1"
16
16
  })(["background:#fff;overflow:auto;position:relative;"]);
17
17
 
18
- exports.StyledContainerWithPopper = StyledContainerWithPopper;
18
+ exports.StyledContainer = StyledContainer;
19
19
  exports.StyledPopperWrapper = StyledPopperWrapper;
@@ -17,7 +17,8 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
17
17
  const MenuList = () => {
18
18
  const {
19
19
  props: {
20
- options
20
+ options,
21
+ id
21
22
  },
22
23
  referenceElement,
23
24
  inputRef,
@@ -33,11 +34,12 @@ const MenuList = () => {
33
34
 
34
35
  (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
35
36
  }, [inputRef]);
37
+ const idList = React.useMemo(() => "".concat(id ? "".concat(id, "-") : '', "listbox"), [id]);
36
38
  return /*#__PURE__*/_jsx__default["default"](styled.StyledListWrapper, {
37
39
  tabIndex: -1,
38
40
  onMouseDown: e => e.preventDefault(),
39
41
  minWidth: referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.offsetWidth,
40
- id: "autocomplete-listbox",
42
+ id: idList,
41
43
  role: "listbox"
42
44
  }, void 0, options.length > 0 && /*#__PURE__*/jsxRuntime.jsx(styled.StyledVirtualListWrapper, {
43
45
  tabIndex: -1,
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -13,7 +13,7 @@ const isSelectedValueMultiple = value => Array.isArray(value);
13
13
  const findInCircularList = function (list, from, criteria) {
14
14
  let step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
15
15
 
16
- for (let i = (from + step + list.length) % list.length; i !== from; i = (i + step + list.length) % list.length) {
16
+ for (let i = (from + step + list.length) % list.length; i !== from && from > -1; i = (i + step + list.length) % list.length) {
17
17
  if (criteria(list[i])) return i;
18
18
  }
19
19
 
@@ -25,7 +25,7 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
25
25
  var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
26
26
  var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
27
27
 
28
- const _excluded = ["id", "disabled", "readOnly", "label", "aria-label", "aria-controls", "onKeyDown", "className"];
28
+ const _excluded = ["id", "disabled", "readOnly", "label", "aria-label", "aria-controls", "onKeyDown", "className", "onChange"];
29
29
 
30
30
  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; }
31
31
 
@@ -41,10 +41,8 @@ const DSControlledCheckbox = props => {
41
41
  hasError,
42
42
  innerRef,
43
43
  wrapLabel,
44
- tabIndex,
45
44
  ariaLabel: legacyAriaLabel,
46
- ariaControls: legacyAriaControls,
47
- 'data-testid': dataTestid = 'ds-checkbox-container'
45
+ ariaControls: legacyAriaControls
48
46
  } = propsWithDefault;
49
47
 
50
48
  const _useGetGlobalAttribut = dsPropsHelpers.useGetGlobalAttributes(propsWithDefault),
@@ -56,10 +54,12 @@ const DSControlledCheckbox = props => {
56
54
  'aria-label': ariaLabel,
57
55
  'aria-controls': ariaControls,
58
56
  onKeyDown: userOnKeyDown,
59
- className
57
+ className,
58
+ onChange
60
59
  } = _useGetGlobalAttribut,
61
60
  restGlobals = _objectWithoutProperties__default["default"](_useGetGlobalAttribut, _excluded);
62
61
 
62
+ const xstyledProps = dsPropsHelpers.useGetXstyledProps(propsWithDefault);
63
63
  const handleOnKeyDown = React.useCallback(e => {
64
64
  if (checkboxRef.current && e.key === 'Enter') {
65
65
  checkboxRef.current.click();
@@ -67,35 +67,51 @@ const DSControlledCheckbox = props => {
67
67
 
68
68
  if (userOnKeyDown) userOnKeyDown(e);
69
69
  }, [userOnKeyDown]);
70
- return /*#__PURE__*/_jsx__default["default"](styles.StyledContainer, {
71
- "data-testid": dataTestid,
70
+ return /*#__PURE__*/jsxRuntime.jsxs(styles.StyledContainer, _objectSpread(_objectSpread({
71
+ "data-testid": "ds-checkbox-container",
72
72
  className: className
73
- }, void 0, /*#__PURE__*/_jsx__default["default"](styles.StyledCheckBox, {
74
- checked: checked,
75
- hasError: hasError,
76
- disabled: disabled,
77
- readOnly: readOnly
78
- }, void 0, /*#__PURE__*/jsxRuntime.jsx(styles.StyledInput, _objectSpread(_objectSpread({}, restGlobals), {}, {
79
- "data-testid": "ds-checkbox",
80
- id: id,
81
- ref: ref => setMultipleRefs.setMultipleRefs([checkboxRef, innerRef])(ref),
82
- onKeyDown: handleOnKeyDown,
83
- type: "checkbox",
84
- checked: checked !== 'mixed' ? checked : undefined,
85
- "aria-label": ariaLabel || legacyAriaLabel || label,
86
- "aria-controls": ariaControls || legacyAriaControls,
87
- tabIndex: tabIndex,
88
- disabled: disabled,
89
- readOnly: readOnly
90
- }))), label && /*#__PURE__*/_jsx__default["default"](styles.StyledLabel, {
91
- htmlFor: id,
92
- disabled: disabled,
93
- readOnly: readOnly,
94
- checked: checked,
95
- "data-testid": "ds-checkbox-label"
96
- }, void 0, wrapLabel ? label : /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
97
- value: label
98
- })));
73
+ }, xstyledProps), {}, {
74
+ children: [/*#__PURE__*/_jsx__default["default"](styles.StyledCheckBox, {
75
+ checked: checked,
76
+ hasError: hasError,
77
+ disabled: disabled,
78
+ readOnly: readOnly
79
+ }, void 0, ariaControls || legacyAriaControls ? /*#__PURE__*/jsxRuntime.jsx(styles.StyledInputMixed, _objectSpread(_objectSpread({
80
+ role: "checkbox",
81
+ "data-testid": "ds-checkbox",
82
+ id: id,
83
+ ref: ref => setMultipleRefs.setMultipleRefs([checkboxRef, innerRef])(ref),
84
+ onKeyDown: handleOnKeyDown,
85
+ "aria-label": ariaLabel || legacyAriaLabel || label,
86
+ "aria-controls": ariaControls || legacyAriaControls,
87
+ disabled: disabled,
88
+ readOnly: readOnly,
89
+ onClick: onChange,
90
+ "aria-checked": checked
91
+ }, restGlobals), {}, {
92
+ tabIndex: 0
93
+ })) : /*#__PURE__*/jsxRuntime.jsx(styles.StyledInput, _objectSpread({
94
+ "data-testid": "ds-checkbox",
95
+ id: id,
96
+ ref: ref => setMultipleRefs.setMultipleRefs([checkboxRef, innerRef])(ref),
97
+ onKeyDown: handleOnKeyDown,
98
+ type: "checkbox",
99
+ checked: checked,
100
+ "aria-label": ariaLabel || legacyAriaLabel || label,
101
+ disabled: disabled,
102
+ readOnly: readOnly,
103
+ onChange: onChange
104
+ }, restGlobals))), label && /*#__PURE__*/_jsx__default["default"](styles.StyledLabel, {
105
+ htmlFor: id,
106
+ disabled: disabled,
107
+ readOnly: readOnly,
108
+ checked: checked,
109
+ "data-testid": "ds-checkbox-label",
110
+ wrapLabel: wrapLabel
111
+ }, void 0, wrapLabel ? /*#__PURE__*/_jsx__default["default"](styles.StyledWrapLabel, {}, void 0, label) : /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
112
+ value: label
113
+ }))]
114
+ }));
99
115
  };
100
116
 
101
117
  const DSControlledCheckboxWithSchema = dsPropsHelpers.describe(DSControlledCheckbox);
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const DSCheckboxDataTestIds = {
6
+ CONTAINER: 'ds-checkbox-container',
7
+ INPUT: 'ds-checkbox'
8
+ };
9
+
10
+ exports.DSCheckboxDataTestIds = DSCheckboxDataTestIds;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var dataTestIds = require('./data-test-ids.js');
6
+ var theming = require('./theming.js');
7
+
8
+
9
+
10
+ exports.DSCheckboxDataTestIds = dataTestIds.DSCheckboxDataTestIds;
11
+ exports.DSCheckboxName = theming.DSCheckboxName;
12
+ exports.DSCheckboxSlots = theming.DSCheckboxSlots;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const DSCheckboxName = 'ds-checkbox';
6
+ const DSCheckboxSlots = {
7
+ CONTAINER: 'root',
8
+ INPUT: 'input',
9
+ LABEL: 'label'
10
+ };
11
+
12
+ exports.DSCheckboxName = DSCheckboxName;
13
+ exports.DSCheckboxSlots = DSCheckboxSlots;
@@ -25,9 +25,9 @@ const defaultProps = {
25
25
  };
26
26
  const propTypes = _objectSpread(_objectSpread({}, dsPropsHelpers.globalAttributesPropTypes), {}, {
27
27
  label: dsPropsHelpers.PropTypes.string.description('Checkbox Label property. This label is also going to be used as an aria-label for screen readers.'),
28
- wrapLabel: dsPropsHelpers.PropTypes.bool.description('Whether to wrap or truncate label'),
29
28
  hasError: dsPropsHelpers.PropTypes.bool.description('Whether the checkbox has error or not.'),
30
- innerRef: dsPropsHelpers.PropTypes.oneOfType([dsPropsHelpers.PropTypes.func, dsPropsHelpers.PropTypes.object]).description('Checkbox input ref.')
29
+ innerRef: dsPropsHelpers.PropTypes.oneOfType([dsPropsHelpers.PropTypes.func, dsPropsHelpers.PropTypes.object]).description('Checkbox input ref.'),
30
+ wrapLabel: dsPropsHelpers.PropTypes.bool.description('Whether to wrap or truncate the label')
31
31
  });
32
32
 
33
33
  exports.defaultProps = defaultProps;
@@ -2,24 +2,26 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var styled = require('styled-components');
5
+ var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
6
+ var dsSystem = require('@elliemae/ds-system');
6
7
  var styleHelpers = require('./utils/styleHelpers.js');
8
+ var theming = require('./exported-related/theming.js');
7
9
 
8
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
11
 
10
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+ var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
11
13
 
12
- const StyledContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
13
- componentId: "sc-flv7d2-0"
14
- })(["display:inline-grid;grid-template-rows:min-content;grid-template-columns:", " auto;align-items:center;"], _ref => {
14
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
15
+ const StyledContainer = dsSystem.styled('div', {
16
+ name: theming.DSCheckboxName,
17
+ slot: theming.DSCheckboxSlots.CONTAINER
18
+ })(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n display: inline-grid;\n grid-template-rows: min-content;\n grid-template-columns: ", " auto;\n align-items: center;\n"])), _ref => {
15
19
  let {
16
20
  theme
17
21
  } = _ref;
18
22
  return theme.space.xs;
19
23
  });
20
- const StyledCheckBox = /*#__PURE__*/styled__default["default"].span.withConfig({
21
- componentId: "sc-flv7d2-1"
22
- })(["width:", ";height:", ";border:1px solid ", ";border-radius:2px;position:relative;background:", ";", " &:focus-within{", ";&:hover{", "}}&:hover{background:", ";", ";}"], _ref2 => {
24
+ const StyledCheckBox = dsSystem.styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n width: ", ";\n height: ", ";\n border: 1px solid ", ";\n border-radius: 2px;\n position: relative;\n background: ", ";\n ", "\n &:focus-within {\n ", ";\n &:hover {\n ", "\n }\n }\n &:hover {\n background: ", ";\n ", ";\n }\n"])), _ref2 => {
23
25
  let {
24
26
  theme
25
27
  } = _ref2;
@@ -82,16 +84,24 @@ const StyledCheckBox = /*#__PURE__*/styled__default["default"].span.withConfig({
82
84
  } = _ref10;
83
85
  return !hasError && !disabled && !readOnly ? " border: 1px solid ".concat(theme.colors.brand[600]) : undefined;
84
86
  });
85
- const StyledInput = /*#__PURE__*/styled__default["default"].input.withConfig({
86
- componentId: "sc-flv7d2-2"
87
- })(["&:hover{cursor:pointer;}&:disabled{cursor:not-allowed;}height:100%;position:absolute;top:0;left:0;opacity:0;"]);
88
- const StyledLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
89
- componentId: "sc-flv7d2-3"
90
- })(["&:hover{cursor:pointer;}padding-left:", ";color:", ";font-size:13px;line-height:13px;display:inherit;"], _ref11 => {
87
+ const checkboxStyles = dsSystem.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n &:hover {\n cursor: pointer;\n }\n &:disabled {\n cursor: not-allowed;\n }\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0;\n"])));
88
+ const StyledInput = dsSystem.styled('input', {
89
+ name: theming.DSCheckboxName,
90
+ slot: theming.DSCheckboxSlots.INPUT
91
+ })(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n ", "\n"])), checkboxStyles);
92
+ const StyledInputMixed = dsSystem.styled('div', {
93
+ name: theming.DSCheckboxName,
94
+ slot: theming.DSCheckboxSlots.INPUT
95
+ })(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral__default["default"](["\n ", "\n"])), checkboxStyles);
96
+ const StyledLabel = dsSystem.styled('label', {
97
+ name: theming.DSCheckboxName,
98
+ slot: theming.DSCheckboxSlots.LABEL
99
+ })(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral__default["default"](["\n &:hover {\n cursor: pointer;\n }\n ", ";\n\n color: ", ";\n font-size: 13px;\n line-height: 13px;\n display: inherit;\n"])), _ref11 => {
91
100
  let {
101
+ wrapLabel,
92
102
  theme
93
103
  } = _ref11;
94
- return theme.space.xxs;
104
+ return wrapLabel ? 'padding: 8px 0px 8px 8px;' : "padding-left: ".concat(theme.space.xxs);
95
105
  }, _ref12 => {
96
106
  let {
97
107
  theme,
@@ -101,8 +111,11 @@ const StyledLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
101
111
  } = _ref12;
102
112
  return disabled && checked !== true || readOnly ? theme.colors.neutral[500] : theme.colors.neutral[800];
103
113
  });
114
+ const StyledWrapLabel = dsSystem.styled('span')(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral__default["default"]([""])));
104
115
 
105
116
  exports.StyledCheckBox = StyledCheckBox;
106
117
  exports.StyledContainer = StyledContainer;
107
118
  exports.StyledInput = StyledInput;
119
+ exports.StyledInputMixed = StyledInputMixed;
108
120
  exports.StyledLabel = StyledLabel;
121
+ exports.StyledWrapLabel = StyledWrapLabel;
@@ -10,18 +10,20 @@ function noop() {}
10
10
  const defaultProps = {
11
11
  hasError: false,
12
12
  inline: false,
13
- withoutPortal: true,
13
+ withoutPortal: false,
14
14
  zIndex: 10,
15
15
  disabled: false,
16
16
  useMask: noop,
17
17
  innerRef: /*#__PURE__*/React.createRef(),
18
18
  startPlacementPreference: 'bottom-start',
19
- placementOrderPreference: ['bottom-start', 'bottom-end'] // override in useCombobox to avoid ref duplications when more than one cb is used
19
+ placementOrderPreference: ['bottom-start', 'bottom-end'],
20
+ noOptionsMessage: 'No Matches Found',
21
+ filteredOptions: [] // override in useCombobox to avoid ref duplications when more than one cb is used
20
22
 
21
23
  };
22
24
  const defaultContext = {
23
25
  props: defaultProps,
24
- showPopover: false,
26
+ menuState: false,
25
27
  hasFocus: false,
26
28
  referenceElement: null,
27
29
  inputValue: '',
@@ -40,7 +42,8 @@ const defaultContext = {
40
42
  setInputValue: noop,
41
43
  setReferenceElement: noop,
42
44
  setFocusOptionIdx: noop,
43
- setShowSelectedOptions: noop
45
+ setShowSelectedOptions: noop,
46
+ setMenuState: noop
44
47
  };
45
48
  /** Context for cross component communication */
46
49
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const ComboboxDataTestid = {
6
6
  MULTISELECT: {
7
- SELECT_ALL_CHECKBOX: 'combobox-select-all-checkbox',
7
+ HEADER_LIST: 'combobox-header-list',
8
8
  SHOW_SELECTED_OPTIONS_TOGGLE: 'combobox-selected-options-toggle'
9
9
  },
10
10
  CONTROLS_WRAPPER: 'combobox-controls-wrapper',
@@ -44,8 +44,18 @@ const useComboBox = props => {
44
44
  const toggleSelectionButtonRef = React.useRef(null);
45
45
  const pillGroupRef = React.useRef(null);
46
46
  const {
47
- selectedValues
48
- } = propsWithDefaults; // ---------------------------------------------------------------------------
47
+ selectedValues,
48
+ isMenuOpen,
49
+ onMenuChange
50
+ } = propsWithDefaults;
51
+ const menuState = React.useMemo(() => {
52
+ if (isMenuOpen !== undefined) return isMenuOpen;
53
+ return showPopover;
54
+ }, [showPopover, isMenuOpen]);
55
+ const setMenuState = React.useCallback((newState, reason, e) => {
56
+ if (onMenuChange !== undefined) onMenuChange(newState, reason, e);
57
+ setShowPopover(newState);
58
+ }, [onMenuChange]); // ---------------------------------------------------------------------------
49
59
  // Options with creatable option + filtered by selected
50
60
  // ---------------------------------------------------------------------------
51
61
 
@@ -74,17 +84,19 @@ const useComboBox = props => {
74
84
 
75
85
  const [focusOptionIdx, setFocusOptionIdx] = React.useState('');
76
86
  React.useEffect(() => {
77
- // we are updating the focus option only when we have focus on the input and
78
- // we are in the selected option view or we are typing to force first option always
87
+ // this code calculate the option to be focused when opening the menu
88
+ // when losing focus we remove the focused one
89
+ // when focus adquired again getFirstOption calculate the correct one
90
+ if (!hasFocus) setFocusOptionIdx('');
91
+
79
92
  if (hasFocus && (focusOptionIdx === '' || inputValue !== '' || showSelectedOptions)) {
80
93
  const focusedValue = listHelper.getFirstOption(correctOptions, selectedValues, inputValue);
81
94
  setFocusOptionIdx(focusedValue);
82
95
  scrollOptionIntoView(focusedValue, {
83
96
  align: 'center'
84
97
  });
85
- }
98
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
86
99
 
87
- if (!hasFocus) setFocusOptionIdx(''); // eslint-disable-next-line react-hooks/exhaustive-deps
88
100
  }, [showPopover, hasFocus, correctOptions, selectedValues, inputValue]);
89
101
  React.useEffect(() => {
90
102
  if (!showPopover) {
@@ -97,7 +109,7 @@ const useComboBox = props => {
97
109
  filteredOptions: correctOptions
98
110
  }),
99
111
  virtualListHelpers,
100
- showPopover,
112
+ menuState,
101
113
  referenceElement,
102
114
  listRef,
103
115
  focusOptionIdx,
@@ -106,6 +118,7 @@ const useComboBox = props => {
106
118
  selectAllCheckboxRef,
107
119
  inputValue,
108
120
  setInputValue,
121
+ setMenuState,
109
122
  hasFocus,
110
123
  toggleSelectionButtonRef,
111
124
  pillGroupRef,
@@ -117,7 +130,7 @@ const useComboBox = props => {
117
130
  scrollOptionIntoView,
118
131
  setReferenceElement,
119
132
  setShowPopover
120
- }), [scrollOptionIntoView, correctOptions, hasFocus, propsWithDefaults, virtualListHelpers, inputValue, focusOptionIdx, wrapperListRef, showSelectedOptions, showPopover, pillGroupRef, referenceElement, selectedOptionsRef, controlsWrapperRef, selectAllCheckboxRef, toggleSelectionButtonRef, listRef]);
133
+ }), [scrollOptionIntoView, setMenuState, correctOptions, hasFocus, propsWithDefaults, virtualListHelpers, inputValue, focusOptionIdx, wrapperListRef, showSelectedOptions, menuState, pillGroupRef, referenceElement, selectedOptionsRef, controlsWrapperRef, selectAllCheckboxRef, toggleSelectionButtonRef, listRef]);
121
134
  return ctx;
122
135
  };
123
136
 
@@ -3,9 +3,14 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ComboBox = require('./ComboBox.js');
6
+ var theming = require('./theming.js');
7
+ var ComboboxDataTestids = require('./ComboboxDataTestids.js');
6
8
 
7
9
 
8
10
 
9
11
  exports.DSComboBox = ComboBox.DSComboBox;
10
12
  exports.DSComboBoxV3 = ComboBox.DSComboBox;
11
13
  exports.DSComboBoxWithSchema = ComboBox.DSComboBoxWithSchema;
14
+ exports.DSComboBoxName = theming.DSComboBoxName;
15
+ exports.DSComboboxSlots = theming.DSComboboxSlots;
16
+ exports.ComboboxDataTestid = ComboboxDataTestids.ComboboxDataTestid;
@@ -19,22 +19,30 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
19
19
  const A11yFocusedOption = () => {
20
20
  const {
21
21
  props: {
22
- filteredOptions
22
+ filteredOptions,
23
+ selectedValues
23
24
  },
24
25
  focusOptionIdx,
25
- showPopover
26
+ menuState
26
27
  } = React.useContext(ComboBoxCTX.ComboBoxContext);
27
28
  const selectabledOptions = listHelper.getSelectableOptions(filteredOptions);
28
- const focusOption = filteredOptions.find(option => !sharedTypes.isSeparator(option) && option.dsId === focusOptionIdx);
29
+ const focusOption = filteredOptions.find(option => option.dsId === focusOptionIdx);
30
+ const isFocusOptionSelected = (focusOption === null || focusOption === void 0 ? void 0 : focusOption.type) === 'option' && listHelper.isSelected(selectedValues, focusOption);
29
31
  const focusSelectableOptionIdx = selectabledOptions.findIndex(option => option.dsId === focusOptionIdx);
32
+ const navigationContext = 'Use up and down to choose options,press enter to choose focused option, press Escape to excuse dropdown menu';
30
33
  return React.useMemo(() => {
31
- if (!sharedTypes.isSeparator(focusOption) && showPopover && focusOption) return /*#__PURE__*/_jsx__default["default"](styled.StyledA11ySelectedValues, {
34
+ if (!sharedTypes.isSeparator(focusOption) && menuState && focusOption && focusOption.type === 'option') return /*#__PURE__*/_jsx__default["default"](styled.StyledA11ySelectedValues, {
32
35
  "aria-live": "polite",
33
36
  "aria-atomic": "false",
34
37
  "aria-relevant": "additions text"
35
- }, void 0, "option ".concat(focusOption === null || focusOption === void 0 ? void 0 : focusOption.label, " focused.").concat(focusSelectableOptionIdx + 1, " of ").concat(selectabledOptions.length, " "));
38
+ }, menuState, "option ".concat(focusOption === null || focusOption === void 0 ? void 0 : focusOption.label, " ").concat(isFocusOptionSelected ? 'selected and ' : '', "focused .").concat(focusSelectableOptionIdx + 1, " of ").concat(selectabledOptions.length, ". ").concat(navigationContext, " "));
39
+ if ((focusOption === null || focusOption === void 0 ? void 0 : focusOption.type) === 'creatable') return /*#__PURE__*/_jsx__default["default"](styled.StyledA11ySelectedValues, {
40
+ "aria-live": "assertive",
41
+ "aria-atomic": "false",
42
+ "aria-relevant": "additions text"
43
+ }, menuState, "Press enter to Add: ".concat(focusOption === null || focusOption === void 0 ? void 0 : focusOption.label, ". ").concat(navigationContext));
36
44
  return null;
37
- }, [showPopover, focusOption, focusSelectableOptionIdx, selectabledOptions]);
45
+ }, [focusOption, menuState, isFocusOptionSelected, focusSelectableOptionIdx, selectabledOptions.length]);
38
46
  };
39
47
 
40
48
  exports.A11yFocusedOption = A11yFocusedOption;