@qualtrics/ui-react 2.19.0 → 2.19.1

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 (261) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/__shared/cjs/{index-4e4cc354.js → index-384184bd.js} +994 -1872
  3. package/dist/__shared/cjs/{index-bf07471d.js → index-4a5425cc.js} +10 -7
  4. package/dist/components/Accordion/Accordion.js +1 -5
  5. package/dist/components/Accordion/Accordion2.js +3 -3
  6. package/dist/components/Accordion/AccordionHeader.js +4 -8
  7. package/dist/components/Accordion/AccordionPanel.js +3 -3
  8. package/dist/components/BreakpointSwitch/Breakpoint.js +0 -2
  9. package/dist/components/BreakpointSwitch/BreakpointSwitch.js +0 -3
  10. package/dist/components/Button/Button.js +3 -3
  11. package/dist/components/Button/Button2.js +2 -7
  12. package/dist/components/ButtonGroup/ButtonGroup.js +1 -2
  13. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  14. package/dist/components/Checkbox/Checkbox.js +11 -11
  15. package/dist/components/Checkbox/Checkbox2.js +3 -3
  16. package/dist/components/Checkbox/VisualCheckbox.js +1 -1
  17. package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
  18. package/dist/components/ColorPicker/Alpha.js +9 -30
  19. package/dist/components/ColorPicker/ColorPicker.js +33 -42
  20. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  21. package/dist/components/ColorPicker/ColorPickerFlyout.js +2 -1
  22. package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +20 -23
  23. package/dist/components/ColorPicker/Hue.js +2 -19
  24. package/dist/components/ColorPicker/Palette.js +7 -27
  25. package/dist/components/ColorPicker/Saturation.js +8 -29
  26. package/dist/components/ColorPicker/utils/calculateTargetId.js +10 -20
  27. package/dist/components/ColorPicker/utils/getMousePosition.js +4 -3
  28. package/dist/components/ColorPicker/utils/hexToHsv.js +0 -5
  29. package/dist/components/ColorPicker/utils/hexToRgbaString.js +2 -4
  30. package/dist/components/ColorPicker/utils/hsvToHex.js +0 -3
  31. package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
  32. package/dist/components/ColorPicker/utils/validateHex.js +12 -19
  33. package/dist/components/Combobox/Combobox.js +57 -127
  34. package/dist/components/Combobox/Combobox2.js +3 -3
  35. package/dist/components/Combobox/ComboboxHeader.js +1 -1
  36. package/dist/components/Combobox/ComboboxIcon.js +2 -4
  37. package/dist/components/Combobox/ComboboxInput.js +4 -5
  38. package/dist/components/Combobox/ComboboxList.js +2 -2
  39. package/dist/components/ConfigPane/ConfigPane.js +0 -7
  40. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  41. package/dist/components/Divider/Divider2.js +3 -3
  42. package/dist/components/Dropdown/ChildIndexContext/index.js +0 -1
  43. package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +34 -30
  44. package/dist/components/Dropdown/Dropdown.js +17 -68
  45. package/dist/components/Dropdown/Dropdown2.js +3 -3
  46. package/dist/components/Dropdown/DropdownButton.js +23 -33
  47. package/dist/components/Dropdown/DropdownHeader.js +2 -1
  48. package/dist/components/Dropdown/DropdownList.js +8 -7
  49. package/dist/components/Dropdown/DropdownOption.js +3 -10
  50. package/dist/components/Dropdown/DropdownSearch.js +6 -24
  51. package/dist/components/FilePicker/FilePicker.js +15 -26
  52. package/dist/components/FilePicker/FilePicker2.js +3 -3
  53. package/dist/components/FormField/Caption.js +3 -3
  54. package/dist/components/FormField/FormField.js +2 -2
  55. package/dist/components/FormField/FormField2.js +3 -3
  56. package/dist/components/FormField/FormFieldContext.js +3 -6
  57. package/dist/components/FormField/ReadOnlyText.js +2 -1
  58. package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -11
  59. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  60. package/dist/components/Icon/Icon.js +3 -6
  61. package/dist/components/Icon/IconTypes.js +1 -0
  62. package/dist/components/IconButton/IconButton.js +1 -6
  63. package/dist/components/IconButton/IconButton2.js +3 -3
  64. package/dist/components/InlineInput/InlineInput.js +16 -33
  65. package/dist/components/InlineInput/InlineInput2.js +3 -3
  66. package/dist/components/Input/Input.js +3 -2
  67. package/dist/components/Input/Input2.js +3 -3
  68. package/dist/components/Input/InputField.js +2 -5
  69. package/dist/components/InputGroup/InputGroup2.js +3 -3
  70. package/dist/components/InputGroup/InputGroupProvider.js +0 -2
  71. package/dist/components/Label/Label2.js +3 -3
  72. package/dist/components/Link/Link2.js +3 -3
  73. package/dist/components/LoadingSpinner/LoadingSpinner.js +1 -1
  74. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  75. package/dist/components/LogicEditor/ConditionContainer.js +0 -2
  76. package/dist/components/LogicEditor/ConditionSet.js +8 -25
  77. package/dist/components/LogicEditor/Controls.js +2 -2
  78. package/dist/components/LogicEditor/LogicEditor.js +3 -12
  79. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  80. package/dist/components/LogicEditor/utils.js +9 -34
  81. package/dist/components/Modal/Modal.js +22 -35
  82. package/dist/components/Modal/Modal2.js +3 -3
  83. package/dist/components/NewMenu/BaseMenu.js +43 -108
  84. package/dist/components/NewMenu/NewMenu.js +3 -3
  85. package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -3
  86. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +20 -32
  87. package/dist/components/NewMenu/parts/MenuItem.js +2 -3
  88. package/dist/components/NewMenu/parts/MenuSearchBox.js +2 -1
  89. package/dist/components/NumberStepper/NumberStepper.js +29 -44
  90. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  91. package/dist/components/NumberStepper/NumberStepperDecrement.js +6 -5
  92. package/dist/components/NumberStepper/NumberStepperIncrement.js +6 -5
  93. package/dist/components/NumberStepper/NumberStepperInput.js +10 -12
  94. package/dist/components/PageLayout/PageLayout.js +3 -3
  95. package/dist/components/Pagination/Pagination.js +10 -6
  96. package/dist/components/Pagination/Pagination2.js +3 -3
  97. package/dist/components/Pagination/PaginationNextButton.js +8 -8
  98. package/dist/components/Pagination/PaginationPageInput.js +17 -22
  99. package/dist/components/Pagination/PaginationPreviousButton.js +8 -8
  100. package/dist/components/Popover/Popover.js +9 -18
  101. package/dist/components/Popover/Popover2.js +3 -3
  102. package/dist/components/QuickSearch/QuickSearch.js +3 -5
  103. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  104. package/dist/components/QuickSearch/QuickSearchInput.js +6 -23
  105. package/dist/components/Radio/Radio.js +11 -13
  106. package/dist/components/Radio/Radio2.js +3 -3
  107. package/dist/components/SearchInput/SearchInput.js +5 -11
  108. package/dist/components/SearchInput/SearchInput2.js +3 -3
  109. package/dist/components/SidebarNav/ExpandCollapseButton.js +0 -2
  110. package/dist/components/SidebarNav/SidebarNav.js +5 -4
  111. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  112. package/dist/components/SidebarNav/SidebarNavLink.js +1 -4
  113. package/dist/components/Slider/RangeSlider.js +8 -22
  114. package/dist/components/Slider/Slider.js +7 -26
  115. package/dist/components/Slider/Slider2.js +3 -3
  116. package/dist/components/Slider/SliderButton.js +7 -9
  117. package/dist/components/Switch/Switch.js +11 -11
  118. package/dist/components/Switch/Switch2.js +3 -3
  119. package/dist/components/Table/Table2.js +3 -3
  120. package/dist/components/Tabs/Tab.js +3 -3
  121. package/dist/components/Tabs/TabContextProvider.js +1 -1
  122. package/dist/components/Tabs/TabList.js +9 -17
  123. package/dist/components/Tabs/TabPanel.js +3 -3
  124. package/dist/components/Tabs/TabPanels.js +0 -2
  125. package/dist/components/Tabs/Tabs2.js +3 -3
  126. package/dist/components/Tooltip/Tooltip.js +12 -41
  127. package/dist/components/Tooltip/Tooltip2.js +3 -3
  128. package/dist/components/UIProvider/PortalTargetContext.js +0 -1
  129. package/dist/components/UIProvider/UIProvider.js +2 -2
  130. package/dist/components/deprecated_ColorPicker/Alpha.js +4 -11
  131. package/dist/components/deprecated_ColorPicker/Color.js +9 -66
  132. package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -8
  133. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  134. package/dist/components/deprecated_ColorPicker/HexInput.js +1 -7
  135. package/dist/components/deprecated_ColorPicker/Hue.js +3 -10
  136. package/dist/components/deprecated_ColorPicker/Saturation.js +7 -14
  137. package/dist/components/deprecated_ColorPicker/Swatch.js +2 -6
  138. package/dist/components/deprecated_ColorPicker/useMouseDrag.js +0 -3
  139. package/dist/components/deprecated_NumberStepper/NumberStepper.js +14 -20
  140. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  141. package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +7 -6
  142. package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +7 -6
  143. package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +16 -17
  144. package/dist/components/deprecated_Tabs/Tabs.js +9 -25
  145. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  146. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  147. package/dist/components/deprecated_Toolbar/ToolbarPanel.js +3 -3
  148. package/dist/components/deprecated_Toolbar/ToolbarPanels.js +3 -17
  149. package/dist/components/deprecated_Toolbar/ToolbarTab.js +10 -26
  150. package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -18
  151. package/dist/hooks/useBreakpoints/useBreakpoints.js +3 -4
  152. package/dist/hooks/useClickOutside/useClickOutside.js +2 -7
  153. package/dist/hooks/useClickOutsidePortals/useClickOutsidePortals.js +3 -6
  154. package/dist/hooks/useControllableState/useControllableState.js +5 -10
  155. package/dist/hooks/useDidUpdate/useDidUpdate.js +2 -4
  156. package/dist/hooks/useEventCallback/useEventCallback.js +2 -1
  157. package/dist/hooks/useEventListener/useEventListener.js +1 -4
  158. package/dist/hooks/useFocusSequence/useFocusSequence.js +10 -17
  159. package/dist/hooks/useId/useId.js +1 -2
  160. package/dist/hooks/useIsFocused/useIsFocused.js +0 -1
  161. package/dist/hooks/useIsHovered/useIsHovered.js +0 -1
  162. package/dist/hooks/useIsTruncated/useIsTruncated.js +4 -3
  163. package/dist/hooks/useLatest/useLatest.js +0 -1
  164. package/dist/hooks/useMounted/useMounted.js +0 -1
  165. package/dist/hooks/useMouseDrag/useMouseDrag.js +0 -4
  166. package/dist/hooks/useOverlay/useOverlay.js +4 -10
  167. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  168. package/dist/hooks/usePrevious/usePrevious.js +0 -1
  169. package/dist/hooks/useResponsiveValue/useResponsiveValue.js +1 -4
  170. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +11 -16
  171. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  172. package/dist/icons/Icon.js +3 -3
  173. package/dist/icons/components/HeadsetIcon.js +6 -0
  174. package/dist/icons/components/PauseCircleIcon.js +1 -1
  175. package/dist/icons/createIconComponent.js +2 -3
  176. package/dist/icons/index.d.ts +2 -0
  177. package/dist/icons/index.es.js +1 -0
  178. package/dist/icons/index.js +2 -1
  179. package/dist/index.d.ts +1 -0
  180. package/dist/index.es.js +4 -3
  181. package/dist/index.js +6 -5
  182. package/dist/next/AdvancedTable/AdvancedTable.js +82 -188
  183. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  184. package/dist/next/AdvancedTable/AdvancedTableCell.js +4 -14
  185. package/dist/next/AdvancedTable/AdvancedTableCheckbox.js +0 -1
  186. package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +11 -41
  187. package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +8 -14
  188. package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +4 -6
  189. package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -4
  190. package/dist/next/AdvancedTable/AdvancedTableRowExpandButton.js +0 -1
  191. package/dist/next/AdvancedTable/AdvancedTableTypes.js +1 -3
  192. package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +8 -13
  193. package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
  194. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +5 -20
  195. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  196. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInputIconButton.js +1 -1
  197. package/dist/next/Combobox/Combobox2.js +3 -3
  198. package/dist/next/Combobox/ComboboxFlyout.js +3 -3
  199. package/dist/next/Combobox/ComboboxGroup.js +1 -1
  200. package/dist/next/Combobox/ComboboxInput.js +7 -20
  201. package/dist/next/Combobox/ComboboxOption.js +5 -6
  202. package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +4 -5
  203. package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +37 -54
  204. package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +4 -5
  205. package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +5 -3
  206. package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +10 -10
  207. package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +1 -6
  208. package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +6 -6
  209. package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +4 -6
  210. package/dist/next/Drawer/Drawer.js +5 -16
  211. package/dist/next/Drawer/Drawer2.js +3 -3
  212. package/dist/next/FilterAnchor/FilterAnchor.js +7 -5
  213. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  214. package/dist/next/Input/Input.js +5 -8
  215. package/dist/next/Input/Input2.js +3 -3
  216. package/dist/next/Menu/Menu.js +10 -23
  217. package/dist/next/Menu/Menu2.js +3 -3
  218. package/dist/next/Menu/MenuContext.js +0 -2
  219. package/dist/next/Menu/MenuItem.js +11 -15
  220. package/dist/next/Menu/MenuPane.js +11 -25
  221. package/dist/next/Menu/MenuSearch.js +15 -22
  222. package/dist/next/Menu/SubMenu.js +10 -27
  223. package/dist/next/Menu/usePaneSearch.js +2 -1
  224. package/dist/next/PhoneNumberInput/PhoneNumberInput.js +12 -19
  225. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  226. package/dist/next/SplitButton/SplitButton.js +6 -12
  227. package/dist/next/SplitButton/SplitButton2.js +3 -3
  228. package/dist/next/Stack/Stack.js +0 -3
  229. package/dist/next/TimePicker/TimeDropdown.js +4 -5
  230. package/dist/next/TimePicker/TimeInput.js +4 -5
  231. package/dist/next/TimePicker/TimePicker.js +12 -30
  232. package/dist/next/TimePicker/TimePicker2.js +3 -3
  233. package/dist/next/TimePicker/TimePickerIcon.js +1 -3
  234. package/dist/next/TimePicker/utils.js +12 -52
  235. package/dist/next/ToggleButton/ToggleButton.js +0 -5
  236. package/dist/next/ToggleButton/ToggleButtonGroup.js +2 -1
  237. package/dist/next/ToggleButton/styles.js +3 -3
  238. package/dist/next/index.js +376 -748
  239. package/dist/utils/Flyout/Flyout.js +4 -5
  240. package/dist/utils/Flyout/Flyout2.js +3 -3
  241. package/dist/utils/Popper/Popper.js +18 -25
  242. package/dist/utils/Portal/Portal.js +2 -1
  243. package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +4 -4
  244. package/dist/utils/Translation/Translate.js +0 -4
  245. package/dist/utils/Translation/TranslationProvider.js +0 -1
  246. package/dist/utils/Translation/containsComponentOrElement.js +1 -5
  247. package/dist/utils/Translation/insertPlaceholders.js +0 -1
  248. package/dist/utils/Translation/useTranslation.js +7 -14
  249. package/dist/utils/concatIds/concatIds.js +0 -1
  250. package/dist/utils/constants.js +2 -2
  251. package/dist/utils/createContextUtilities/createContextUtilities.js +0 -4
  252. package/dist/utils/filterChildren/filterChildren.js +8 -17
  253. package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -2
  254. package/dist/utils/keyboardUser/keyboardUser.js +0 -1
  255. package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -12
  256. package/dist/utils/mergeRefs/mergeRefs.js +1 -2
  257. package/dist/utils/wrapAround/wrapAround.js +1 -2
  258. package/dist/utils/wrapEvent/wrapEvent.js +2 -4
  259. package/icons/package.json +2 -1
  260. package/next/package.json +5 -1
  261. package/package.json +9 -4
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._1Mmld{border:none;height:1px;margin:0;flex-shrink:0;background-color:#e5e5e5}";
4
- var styles = {"divider":"_1Mmld"};
5
- var stylesheet="._1Mmld{border:none;height:1px;margin:0;flex-shrink:0;background-color:#e5e5e5}";
3
+ var css_248z = "._Bqwo6{border:none;height:1px;margin:0;flex-shrink:0;background-color:#e5e5e5}";
4
+ var styles = {"divider":"_Bqwo6"};
5
+ var stylesheet="._Bqwo6{border:none;height:1px;margin:0;flex-shrink:0;background-color:#e5e5e5}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -3,7 +3,6 @@ import { DescendantProvider, useDescendant } from './reach-descendants.js';
3
3
 
4
4
  const noop = param => {}; // eslint-disable-line @typescript-eslint/no-unused-vars
5
5
 
6
-
7
6
  const ChildIndexContext = /*#__PURE__*/createContext({
8
7
  descendants: [],
9
8
  registerDescendant: noop,
@@ -4,7 +4,6 @@ import usePrevious from '../../../hooks/usePrevious/usePrevious.js';
4
4
  import useSSRLayoutEffect from '../../../hooks/useSSRLayoutEffect/useSSRLayoutEffect.js';
5
5
 
6
6
  /* eslint-disable @typescript-eslint/no-shadow */
7
-
8
7
  /**
9
8
  * This hook registers our descendant by passing it into an array. We can then
10
9
  * search that array by to find its index when registering it in the component.
@@ -34,31 +33,32 @@ function useDescendant(descendant, context, indexProp) {
34
33
  registerDescendant,
35
34
  unregisterDescendant,
36
35
  descendants
37
- } = useContext(context); // This will initially return -1 because we haven't registered the descendant
36
+ } = useContext(context);
37
+
38
+ // This will initially return -1 because we haven't registered the descendant
38
39
  // on the first render. After we register, this will then return the correct
39
40
  // index on the following render and we will re-register descendants
40
41
  // so that everything is up-to-date before the user interacts with a
41
42
  // collection.
43
+ const index = indexProp ?? descendants.findIndex(item => item.element === descendant.element);
44
+ const previousDescendants = usePrevious(descendants);
42
45
 
43
- const index = indexProp !== null && indexProp !== void 0 ? indexProp : descendants.findIndex(item => item.element === descendant.element);
44
- const previousDescendants = usePrevious(descendants); // We also need to re-register descendants any time ANY of the other
46
+ // We also need to re-register descendants any time ANY of the other
45
47
  // descendants have changed. My brain was melting when I wrote this and it
46
48
  // feels a little off, but checking in render and using the result in the
47
49
  // effect's dependency array works well enough.
50
+ const someDescendantsHaveChanged = descendants.some((descendant, index) => descendant.element !== previousDescendants?.[index]?.element);
48
51
 
49
- const someDescendantsHaveChanged = descendants.some((descendant, index) => {
50
- var _previousDescendants$;
51
-
52
- return descendant.element !== (previousDescendants === null || previousDescendants === void 0 ? void 0 : (_previousDescendants$ = previousDescendants[index]) === null || _previousDescendants$ === void 0 ? void 0 : _previousDescendants$.element);
53
- }); // Prevent any flashing
54
-
52
+ // Prevent any flashing
55
53
  useSSRLayoutEffect(() => {
56
54
  if (!descendant.element) forceUpdate({});
57
- registerDescendant({ ...descendant,
55
+ registerDescendant({
56
+ ...descendant,
58
57
  index
59
58
  });
60
59
  return () => unregisterDescendant(descendant.element); // eslint-disable-next-line react-hooks/exhaustive-deps
61
- }, [registerDescendant, unregisterDescendant, index, someDescendantsHaveChanged, // eslint-disable-next-line react-hooks/exhaustive-deps
60
+ }, [registerDescendant, unregisterDescendant, index, someDescendantsHaveChanged,
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
62
  ...Object.values(descendant)]);
63
63
  return index;
64
64
  }
@@ -78,23 +78,23 @@ function DescendantProvider(_ref) {
78
78
  index: explicitIndex,
79
79
  ...rest
80
80
  } = _ref2;
81
-
82
81
  if (!element) {
83
82
  return;
84
- } // eslint-disable-next-line no-shadow
85
-
83
+ }
86
84
 
85
+ // eslint-disable-next-line no-shadow
87
86
  set(items => {
88
87
  let newItems;
89
-
90
88
  if (explicitIndex != null) {
91
- newItems = [...items, { ...rest,
89
+ newItems = [...items, {
90
+ ...rest,
92
91
  element,
93
92
  index: explicitIndex
94
93
  }];
95
94
  } else if (items.length === 0) {
96
95
  // If there are no items, register at index 0 and bail.
97
- newItems = [...items, { ...rest,
96
+ newItems = [...items, {
97
+ ...rest,
98
98
  element,
99
99
  index: 0
100
100
  }];
@@ -117,32 +117,35 @@ function DescendantProvider(_ref) {
117
117
  const index = items.findIndex(item => {
118
118
  if (!item.element || !element) {
119
119
  return false;
120
- } // Does this element's DOM node appear before another item in the
120
+ }
121
+ // Does this element's DOM node appear before another item in the
121
122
  // array in our DOM tree? If so, return true to grab the index at
122
123
  // this point in the array so we know where to insert the new
123
124
  // element.
124
-
125
-
126
- return Boolean( // eslint-disable-next-line no-bitwise
125
+ return Boolean(
126
+ // eslint-disable-next-line no-bitwise
127
127
  item.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING);
128
128
  });
129
- const newItem = { ...rest,
129
+ const newItem = {
130
+ ...rest,
130
131
  element,
131
132
  index
132
- }; // If an index is not found we will push the element to the end.
133
+ };
133
134
 
135
+ // If an index is not found we will push the element to the end.
134
136
  if (index === -1) {
135
137
  newItems = [...items, newItem];
136
138
  } else {
137
139
  newItems = [...items.slice(0, index), newItem, ...items.slice(index)];
138
140
  }
139
141
  }
140
-
141
- return newItems.map((item, index) => ({ ...item,
142
+ return newItems.map((item, index) => ({
143
+ ...item,
142
144
  index
143
145
  }));
144
146
  });
145
- }, // set is a state setter initialized by the useDescendants hook.
147
+ },
148
+ // set is a state setter initialized by the useDescendants hook.
146
149
  // We can safely ignore the lint warning here because it will not change
147
150
  // between renders.
148
151
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -150,11 +153,12 @@ function DescendantProvider(_ref) {
150
153
  const unregisterDescendant = useCallback(element => {
151
154
  if (!element) {
152
155
  return;
153
- } // eslint-disable-next-line no-shadow
154
-
156
+ }
155
157
 
158
+ // eslint-disable-next-line no-shadow
156
159
  set(items => items.filter(item => element !== item.element));
157
- }, // set is a state setter initialized by the useDescendants hook.
160
+ },
161
+ // set is a state setter initialized by the useDescendants hook.
158
162
  // We can safely ignore the lint warning here because it will not change
159
163
  // between renders.
160
164
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -13,8 +13,6 @@ import { useDidUpdate } from '../../hooks/useDidUpdate/useDidUpdate.js';
13
13
  import useClickOutside from '../../hooks/useClickOutside/useClickOutside.js';
14
14
 
15
15
  const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
16
- var _ref2, _dropdownButton$props, _dropdownButton$props2, _dropdownButton$props3, _dropdownList$props$i, _dropdownList$props;
17
-
18
16
  let {
19
17
  className,
20
18
  children,
@@ -49,24 +47,22 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
49
47
  const [searchHeight, setSearchHeight] = useState();
50
48
  React__default.Children.forEach(children, child => {
51
49
  if ( /*#__PURE__*/React__default.isValidElement(child)) {
52
- switch (child === null || child === void 0 ? void 0 : child.type) {
50
+ switch (child?.type) {
53
51
  case DropdownButton:
54
52
  dropdownButton = child;
55
53
  break;
56
-
57
54
  case DropdownList:
58
55
  dropdownList = child;
59
56
  break;
60
-
61
57
  default:
62
58
  break;
63
59
  }
64
60
  }
65
61
  });
66
62
  const containerId = useId(id);
67
- const buttonId = (_ref2 = (_dropdownButton$props = (_dropdownButton$props2 = dropdownButton.props.children) === null || _dropdownButton$props2 === void 0 ? void 0 : (_dropdownButton$props3 = _dropdownButton$props2.props) === null || _dropdownButton$props3 === void 0 ? void 0 : _dropdownButton$props3.id) !== null && _dropdownButton$props !== void 0 ? _dropdownButton$props : dropdownButton.props.id) !== null && _ref2 !== void 0 ? _ref2 : "".concat(containerId, "-button");
68
- const dialogId = (_dropdownList$props$i = (_dropdownList$props = dropdownList.props) === null || _dropdownList$props === void 0 ? void 0 : _dropdownList$props.id) !== null && _dropdownList$props$i !== void 0 ? _dropdownList$props$i : "".concat(containerId, "-list");
69
- const listboxId = "".concat(containerId, "-listbox");
63
+ const buttonId = dropdownButton.props.children?.props?.id ?? dropdownButton.props.id ?? `${containerId}-button`;
64
+ const dialogId = dropdownList.props?.id ?? `${containerId}-list`;
65
+ const listboxId = `${containerId}-listbox`;
70
66
  const [isOpen, setIsOpen] = useControllableState(false, onIsOpenChange, externalIsOpen);
71
67
  const [value, setValue] = useControllableState(defaultValue, onChange, externalValue);
72
68
  const [isKeyboardUser, setIsKeyboardUser] = useState(false);
@@ -83,41 +79,29 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
83
79
  setIsOpen(false);
84
80
  setHighlightedIndex(-1);
85
81
  }, [setIsOpen, setHighlightedIndex]);
86
-
87
82
  const findOptionAndHighlight = char => {
88
83
  const lowerCaseChar = char.toLowerCase();
89
84
  let index = -1;
90
85
  let currentIndex = (highlightedIndex + 1) % options.length; // start at next index
91
-
92
86
  let count = 0;
93
-
94
87
  while (count < options.length) {
95
- var _option$label;
96
-
97
88
  const option = options[currentIndex];
98
-
99
- if ((_option$label = option.label) !== null && _option$label !== void 0 && _option$label.toLowerCase().startsWith(lowerCaseChar)) {
89
+ if (option.label?.toLowerCase().startsWith(lowerCaseChar)) {
100
90
  index = currentIndex;
101
91
  break;
102
- } // increment currentIndex (wrap)
103
-
104
-
92
+ }
93
+ // increment currentIndex (wrap)
105
94
  currentIndex = (currentIndex + 1) % options.length;
106
95
  count += 1;
107
96
  }
108
-
109
97
  if (index !== -1) {
110
98
  setHighlightedIndex(index);
111
99
  }
112
100
  };
113
-
114
101
  const selectHighlightedItem = e => {
115
- var _option$handleSelect;
116
-
117
102
  const option = options[highlightedIndex];
118
- option === null || option === void 0 ? void 0 : (_option$handleSelect = option.handleSelect) === null || _option$handleSelect === void 0 ? void 0 : _option$handleSelect.call(option, e);
103
+ option?.handleSelect?.(e);
119
104
  };
120
-
121
105
  useClickOutside([buttonRef, listRef], handleClose);
122
106
  useEffect(() => {
123
107
  const newSelectedIndex = Math.max(options.findIndex(option => option.isSelected), 0);
@@ -128,29 +112,23 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
128
112
  setValue(prevValue => {
129
113
  const valueArray = prevValue || prevValue === 0 ? [].concat(prevValue) : [];
130
114
  const i = valueArray.findIndex(v => v === newValue);
131
-
132
115
  if (i !== -1) {
133
116
  valueArray.splice(i, 1);
134
117
  } else {
135
118
  valueArray.push(newValue);
136
119
  }
137
-
138
120
  return valueArray;
139
121
  });
140
122
  } else {
141
- var _buttonRef$current;
142
-
143
123
  setValue(newValue);
144
124
  handleClose();
145
- (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
125
+ buttonRef.current?.focus();
146
126
  }
147
127
  }, [isMultiSelect, handleClose, setValue]);
148
-
149
128
  const onKeyDownButton = e => {
150
129
  setIsKeyboardUser(true);
151
130
  let newHighlightedIndex;
152
131
  if (disabled) return;
153
-
154
132
  switch (e.key) {
155
133
  case 'Enter':
156
134
  case ' ':
@@ -158,134 +136,105 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
158
136
  setIsOpen(true);
159
137
  setHighlightedIndex(selectedIndex);
160
138
  e.preventDefault(); // prevent scroll
161
-
162
139
  break;
163
-
164
140
  case 'ArrowDown':
165
141
  // Open and focus first option. This will either be the search input, or the unfiltered first option.
166
142
  setIsOpen(true);
167
143
  setHighlightedIndex(0);
168
144
  e.preventDefault(); // prevent scroll
169
-
170
145
  break;
171
-
172
146
  case 'ArrowUp':
173
147
  // Open and focus last option
174
148
  setIsOpen(true);
175
149
  newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true);
176
-
177
150
  if (newHighlightedIndex !== -1) {
178
151
  setHighlightedIndex(newHighlightedIndex);
179
152
  }
180
-
181
153
  e.preventDefault(); // prevent scroll
182
-
183
154
  break;
184
-
185
155
  case 'Escape':
186
156
  case 'Tab':
187
157
  // close
188
158
  handleClose();
189
159
  break;
190
-
191
160
  default:
192
161
  break;
193
162
  }
194
163
  };
195
-
196
164
  const onKeyDownList = e => {
197
- var _buttonRef$current2, _buttonRef$current3;
198
-
199
165
  setIsKeyboardUser(true);
200
166
  let newHighlightedIndex;
201
167
  if (disabled) return;
202
-
203
168
  switch (e.key) {
204
169
  case 'Enter':
205
170
  case ' ':
206
171
  // select option
207
172
  selectHighlightedItem(e);
208
173
  e.preventDefault(); // prevent scroll/button click
209
-
210
174
  break;
211
-
212
175
  case 'ArrowDown':
213
176
  // highlight next option
214
177
  newHighlightedIndex = options.map(element => element.isVisible).indexOf(true, highlightedIndex + 1);
215
-
216
178
  if (newHighlightedIndex !== -1) {
217
179
  setHighlightedIndex(newHighlightedIndex);
218
180
  }
219
-
220
181
  if (newHighlightedIndex !== highlightedIndex) {
221
182
  e.preventDefault(); // prevent scroll
222
183
  }
223
184
 
224
185
  break;
225
-
226
186
  case 'ArrowUp':
227
187
  // highlight previous option
228
188
  newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true, Math.max(highlightedIndex - 1, 0));
229
-
230
189
  if (newHighlightedIndex !== -1) {
231
190
  setHighlightedIndex(newHighlightedIndex);
232
- } // scrolls first-item headers into view
233
-
191
+ }
234
192
 
193
+ // scrolls first-item headers into view
235
194
  if (newHighlightedIndex === 0 && listRef.current) {
236
195
  listRef.current.scrollTop = 0;
237
196
  }
238
-
239
197
  if (newHighlightedIndex !== highlightedIndex) {
240
198
  e.preventDefault(); // prevent scroll
241
199
  }
242
200
 
243
201
  break;
244
-
245
202
  case 'Escape':
246
203
  // close, focus button, and don't let event bubble up
247
204
  e.stopPropagation();
248
205
  handleClose();
249
- (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.focus();
206
+ buttonRef.current?.focus();
250
207
  break;
251
-
252
208
  case 'Tab':
253
209
  // close and focus next focusable element
254
210
  handleClose();
255
- (_buttonRef$current3 = buttonRef.current) === null || _buttonRef$current3 === void 0 ? void 0 : _buttonRef$current3.focus();
211
+ buttonRef.current?.focus();
256
212
  break;
257
-
258
213
  case 'PageUp':
259
214
  case 'Home':
260
215
  // highlight first option. This will either be the search input, or the unfiltered first option.
261
- setHighlightedIndex(0); // scrolls first-item headers into view
216
+ setHighlightedIndex(0);
262
217
 
218
+ // scrolls first-item headers into view
263
219
  if (listRef.current) {
264
220
  listRef.current.scrollTop = 0;
265
221
  }
266
-
267
222
  e.preventDefault(); // prevent scroll
268
-
269
223
  break;
270
-
271
224
  case 'PageDown':
272
225
  case 'End':
273
- newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true); // highlight last option
274
-
226
+ newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true);
227
+ // highlight last option
275
228
  if (newHighlightedIndex !== -1) {
276
229
  setHighlightedIndex(newHighlightedIndex);
277
230
  }
278
-
279
231
  e.preventDefault(); // prevent scroll
280
-
281
232
  break;
282
-
283
233
  default:
284
234
  findOptionAndHighlight(e.key);
285
235
  break;
286
236
  }
287
237
  };
288
-
289
238
  return /*#__PURE__*/React__default.createElement(DropdownContextProvider, {
290
239
  value: {
291
240
  value,
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._2Xq2N{max-width:100%;position:relative;display:inline-block}._1nEoJ{display:inline-flex;justify-content:space-between;align-items:center;background-color:#fafafa;border:1px solid #898989;border-radius:4px;height:36px;color:#515559;outline:none;cursor:pointer}._1nEoJ:hover:not([aria-disabled=true]){cursor:pointer;background-color:#f5f5f5}._1nEoJ:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa}._1nEoJ:disabled,._1nEoJ[aria-disabled=true]{color:#74777a;border-color:#e5e5e5;cursor:not-allowed}._1nEoJ._1w5lx{border-color:#b00}._1nEoJ._1w5lx:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000}._1nEoJ._Ij7NQ{min-width:120px;padding:0 4px 0 12px}._1nEoJ._2QhXF{margin-top:4px}._1nEoJ._396lo:not([aria-disabled=true]):not(:disabled){color:#32363a}._1nEoJ ._1nFmn{display:inline-flex;align-items:center;min-height:10px}._1nEoJ ._1nFmn._1Vhs6{line-height:20px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._1nEoJ ._3Dk6R{height:24px;width:24px;border-radius:4px;fill:#515559;flex-shrink:0;cursor:pointer}._1nEoJ ._3Dk6R._1bzH8{border-color:#e5e5e5;fill:#9d9fa1;opacity:.4;cursor:not-allowed}._1nEoJ ._3Dk6R._3RGxa{transform:rotate(-180deg)}._1zxPx[aria-disabled=true]{cursor:not-allowed;color:rgba(81,85,89,.65);fill:#9d9fa1}._dom5Y{position:-webkit-sticky;position:sticky;top:0;z-index:20;padding:4px 8px 8px!important;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;background-color:#fff!important}._jvudA{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._31kAH{fill:#515559}._noxhF{margin:2px 12px 2px 0}._noxhF._1ZdqK>svg{border-color:#0b6ed0}._W3l0C{width:100%}";
4
- var styles = {"container":"_2Xq2N","button":"_1nEoJ","invalid":"_1w5lx","hasText":"_Ij7NQ","labelled":"_2QhXF","selected":"_396lo","buttonLabel":"_1nFmn","isString":"_1Vhs6","icon":"_3Dk6R","disabled":"_1bzH8","open":"_3RGxa","option":"_1zxPx","search":"_dom5Y","emptyOption":"_jvudA","searchIcon":"_31kAH","checkbox":"_noxhF","highlighted":"_1ZdqK","searchInput":"_W3l0C"};
5
- var stylesheet="._2Xq2N{max-width:100%;position:relative;display:inline-block}._1nEoJ{display:inline-flex;justify-content:space-between;align-items:center;background-color:#fafafa;border:1px solid #898989;border-radius:4px;height:36px;color:#515559;outline:none;cursor:pointer}._1nEoJ:hover:not([aria-disabled=true]){cursor:pointer;background-color:#f5f5f5}._1nEoJ:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa}._1nEoJ:disabled,._1nEoJ[aria-disabled=true]{color:#74777a;border-color:#e5e5e5;cursor:not-allowed}._1nEoJ._1w5lx{border-color:#b00}._1nEoJ._1w5lx:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000}._1nEoJ._Ij7NQ{min-width:120px;padding:0 4px 0 12px}._1nEoJ._2QhXF{margin-top:4px}._1nEoJ._396lo:not([aria-disabled=true]):not(:disabled){color:#32363a}._1nEoJ ._1nFmn{display:inline-flex;align-items:center;min-height:10px}._1nEoJ ._1nFmn._1Vhs6{line-height:20px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._1nEoJ ._3Dk6R{height:24px;width:24px;border-radius:4px;fill:#515559;flex-shrink:0;cursor:pointer}._1nEoJ ._3Dk6R._1bzH8{border-color:#e5e5e5;fill:#9d9fa1;opacity:.4;cursor:not-allowed}._1nEoJ ._3Dk6R._3RGxa{transform:rotate(-180deg)}._1zxPx[aria-disabled=true]{cursor:not-allowed;color:rgba(81,85,89,.65);fill:#9d9fa1}._dom5Y{position:-webkit-sticky;position:sticky;top:0;z-index:20;padding:4px 8px 8px!important;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;background-color:#fff!important}._jvudA{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._31kAH{fill:#515559}._noxhF{margin:2px 12px 2px 0}._noxhF._1ZdqK>svg{border-color:#0b6ed0}._W3l0C{width:100%}";
3
+ var css_248z = "._hiv2a{max-width:100%;position:relative;display:inline-block}._5Ym5W{display:inline-flex;justify-content:space-between;align-items:center;background-color:#fafafa;border:1px solid #898989;border-radius:4px;height:36px;color:#515559;outline:none;cursor:pointer}._5Ym5W:hover:not([aria-disabled=true]){cursor:pointer;background-color:#f5f5f5}._5Ym5W:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa}._5Ym5W:disabled,._5Ym5W[aria-disabled=true]{color:#74777a;border-color:#e5e5e5;cursor:not-allowed}._5Ym5W._QVcbH{border-color:#b00}._5Ym5W._QVcbH:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000}._5Ym5W._vSoKd{min-width:120px;padding:0 4px 0 12px}._5Ym5W._csAvZ{margin-top:4px}._5Ym5W._zk3mq:not([aria-disabled=true]):not(:disabled){color:#32363a}._5Ym5W ._5mwEh{display:inline-flex;align-items:center;min-height:10px}._5Ym5W ._5mwEh._Oc-MT{line-height:20px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._5Ym5W ._Z0RPQ{height:24px;width:24px;border-radius:4px;fill:#515559;flex-shrink:0;cursor:pointer}._5Ym5W ._Z0RPQ._TEWRH{border-color:#e5e5e5;fill:#9d9fa1;opacity:.4;cursor:not-allowed}._5Ym5W ._Z0RPQ._rjvAN{transform:rotate(-180deg)}._5lMF-[aria-disabled=true]{cursor:not-allowed;color:rgba(81,85,89,.65);fill:#9d9fa1}._2YXi1{position:sticky;top:0;z-index:20;padding:4px 8px 8px!important;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;background-color:#fff!important}._CTuRo{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._XzebP{fill:#515559}._tYCdy{margin:2px 12px 2px 0}._tYCdy._LxnoL>svg{border-color:#0b6ed0}._s3Uv4{width:100%}";
4
+ var styles = {"container":"_hiv2a","button":"_5Ym5W","invalid":"_QVcbH","hasText":"_vSoKd","labelled":"_csAvZ","selected":"_zk3mq","buttonLabel":"_5mwEh","isString":"_Oc-MT","icon":"_Z0RPQ","disabled":"_TEWRH","open":"_rjvAN","option":"_5lMF-","search":"_2YXi1","emptyOption":"_CTuRo","searchIcon":"_XzebP","checkbox":"_tYCdy","highlighted":"_LxnoL","searchInput":"_s3Uv4"};
5
+ var stylesheet="._hiv2a{max-width:100%;position:relative;display:inline-block}._5Ym5W{display:inline-flex;justify-content:space-between;align-items:center;background-color:#fafafa;border:1px solid #898989;border-radius:4px;height:36px;color:#515559;outline:none;cursor:pointer}._5Ym5W:hover:not([aria-disabled=true]){cursor:pointer;background-color:#f5f5f5}._5Ym5W:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa}._5Ym5W:disabled,._5Ym5W[aria-disabled=true]{color:#74777a;border-color:#e5e5e5;cursor:not-allowed}._5Ym5W._QVcbH{border-color:#b00}._5Ym5W._QVcbH:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000}._5Ym5W._vSoKd{min-width:120px;padding:0 4px 0 12px}._5Ym5W._csAvZ{margin-top:4px}._5Ym5W._zk3mq:not([aria-disabled=true]):not(:disabled){color:#32363a}._5Ym5W ._5mwEh{display:inline-flex;align-items:center;min-height:10px}._5Ym5W ._5mwEh._Oc-MT{line-height:20px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._5Ym5W ._Z0RPQ{height:24px;width:24px;border-radius:4px;fill:#515559;flex-shrink:0;cursor:pointer}._5Ym5W ._Z0RPQ._TEWRH{border-color:#e5e5e5;fill:#9d9fa1;opacity:.4;cursor:not-allowed}._5Ym5W ._Z0RPQ._rjvAN{transform:rotate(-180deg)}._5lMF-[aria-disabled=true]{cursor:not-allowed;color:rgba(81,85,89,.65);fill:#9d9fa1}._2YXi1{position:sticky;top:0;z-index:20;padding:4px 8px 8px!important;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;background-color:#fff!important}._CTuRo{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._XzebP{fill:#515559}._tYCdy{margin:2px 12px 2px 0}._tYCdy._LxnoL>svg{border-color:#0b6ed0}._s3Uv4{width:100%}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -15,8 +15,6 @@ import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
15
15
  import ChevronDownIcon from '../../icons/components/ChevronDownIcon.js';
16
16
 
17
17
  const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
18
- var _ref2, _children$props$aria, _children$props, _ref3, _children$props$aria2, _children$props2, _ref4, _children$props$aria3, _children$props3, _children$props$tabIn, _children$props4, _children$props7, _children$props8;
19
-
20
18
  let {
21
19
  children,
22
20
  className,
@@ -54,7 +52,8 @@ const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
54
52
  ariaDescribedby: dropdownAriaDescribedby,
55
53
  dataTestId: contextDataTestId
56
54
  } = useDropdownContext();
57
- const [label, setLabel] = useControllableState(defaultLabel, // will get updated in effect
55
+ const [label, setLabel] = useControllableState(defaultLabel,
56
+ // will get updated in effect
58
57
  onLabelChange, externalLabel);
59
58
  const [isOptionSelected, setIsOptionSelected] = useState(false);
60
59
  const {
@@ -62,9 +61,9 @@ const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
62
61
  helperTextId: formFieldHelperTextId,
63
62
  errorTextId: formFieldErrorTextId
64
63
  } = useFormFieldControl();
65
- const ariaLabelledBy = (_ref2 = (_children$props$aria = children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props['aria-labelledby']) !== null && _children$props$aria !== void 0 ? _children$props$aria : externalAriaLabelledBy) !== null && _ref2 !== void 0 ? _ref2 : dropdownAriaLabelledBy ? "".concat(dropdownAriaLabelledBy, " ").concat(buttonId) : undefined;
66
- const ariaLabel = (_ref3 = (_children$props$aria2 = children === null || children === void 0 ? void 0 : (_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2['aria-label']) !== null && _children$props$aria2 !== void 0 ? _children$props$aria2 : externalAriaLabel) !== null && _ref3 !== void 0 ? _ref3 : dropdownAriaLabel && typeof label === 'string' ? "".concat(dropdownAriaLabel, " ").concat(label) : dropdownAriaLabel;
67
- const ariaDescribedby = concatIds((_ref4 = (_children$props$aria3 = children === null || children === void 0 ? void 0 : (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3['aria-describedby']) !== null && _children$props$aria3 !== void 0 ? _children$props$aria3 : externalAriaDescribedBy) !== null && _ref4 !== void 0 ? _ref4 : dropdownAriaDescribedby, formFieldHelperTextId, formFieldErrorTextId);
64
+ const ariaLabelledBy = children?.props?.['aria-labelledby'] ?? externalAriaLabelledBy ?? (dropdownAriaLabelledBy ? `${dropdownAriaLabelledBy} ${buttonId}` : undefined);
65
+ const ariaLabel = children?.props?.['aria-label'] ?? externalAriaLabel ?? (dropdownAriaLabel && typeof label === 'string' ? `${dropdownAriaLabel} ${label}` : dropdownAriaLabel);
66
+ const ariaDescribedby = concatIds(children?.props?.['aria-describedby'] ?? externalAriaDescribedBy ?? dropdownAriaDescribedby, formFieldHelperTextId, formFieldErrorTextId);
68
67
  useEffect(() => {
69
68
  const selectedLabels = [];
70
69
  options.forEach(option => {
@@ -76,34 +75,29 @@ const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
76
75
  setLabel(selectedLabels.length > 0 ? selectedLabels.join(', ') : defaultLabel);
77
76
  }, [setLabel, options, defaultLabel]);
78
77
  useEffect(() => {
79
- var _buttonRef$current;
80
-
81
- setMinWidth(buttonRef === null || buttonRef === void 0 ? void 0 : (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.offsetWidth);
78
+ setMinWidth(buttonRef?.current?.offsetWidth);
82
79
  });
83
80
  const isInvalid = isInvalidProp !== undefined ? isInvalidProp : dropdownIsInvalid;
84
-
85
81
  const handleClick = e => {
86
- if (disabled !== null && disabled !== void 0 ? disabled : dropdownAriaDisabled) return;
87
- onClick === null || onClick === void 0 ? void 0 : onClick(e); // Needed because some browsers don't focus on click
88
-
82
+ if (disabled ?? dropdownAriaDisabled) return;
83
+ onClick?.(e);
84
+ // Needed because some browsers don't focus on click
89
85
  e.currentTarget.focus();
90
86
  setIsOpen(currentIsOpen => {
91
87
  setHighlightedIndex(currentIsOpen ? -1 : selectedIndex);
92
88
  return !currentIsOpen;
93
89
  });
94
90
  };
95
-
96
91
  const handleKeyDown = e => {
97
- if (disabled !== null && disabled !== void 0 ? disabled : dropdownAriaDisabled) return;
98
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
92
+ if (disabled ?? dropdownAriaDisabled) return;
93
+ onKeyDown?.(e);
99
94
  onKeyDownButton(e);
100
95
  };
101
-
102
96
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children ? /*#__PURE__*/React__default.cloneElement(children, {
103
- ref: mergeRefs(ref, children === null || children === void 0 ? void 0 : children.ref, buttonRef, dropdownButtonRef),
97
+ ref: mergeRefs(ref, children?.ref, buttonRef, dropdownButtonRef),
104
98
  disabled: disabled || dropdownAriaDisabled,
105
99
  'aria-disabled': dropdownAriaDisabled,
106
- tabIndex: (_children$props$tabIn = (_children$props4 = children.props) === null || _children$props4 === void 0 ? void 0 : _children$props4.tabIndex) !== null && _children$props$tabIn !== void 0 ? _children$props$tabIn : 0,
100
+ tabIndex: children.props?.tabIndex ?? 0,
107
101
  role: 'button',
108
102
  'aria-expanded': isOpen,
109
103
  'aria-haspopup': 'listbox',
@@ -113,19 +107,15 @@ const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
113
107
  'aria-describedby': ariaDescribedby,
114
108
  id: buttonId,
115
109
  onFocus: e => {
116
- var _children$props5, _children$props5$onFo;
117
-
118
- (_children$props5 = children.props) === null || _children$props5 === void 0 ? void 0 : (_children$props5$onFo = _children$props5.onFocus) === null || _children$props5$onFo === void 0 ? void 0 : _children$props5$onFo.call(_children$props5, e);
119
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
110
+ children.props?.onFocus?.(e);
111
+ onFocus?.(e);
120
112
  },
121
113
  onBlur: e => {
122
- var _children$props6, _children$props6$onBl;
123
-
124
- (_children$props6 = children.props) === null || _children$props6 === void 0 ? void 0 : (_children$props6$onBl = _children$props6.onBlur) === null || _children$props6$onBl === void 0 ? void 0 : _children$props6$onBl.call(_children$props6, e);
125
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
114
+ children.props?.onBlur?.(e);
115
+ onBlur?.(e);
126
116
  },
127
- onKeyDown: wrapEvent((_children$props7 = children.props) === null || _children$props7 === void 0 ? void 0 : _children$props7.onKeyDown, handleKeyDown),
128
- onClick: wrapEvent((_children$props8 = children.props) === null || _children$props8 === void 0 ? void 0 : _children$props8.onClick, handleClick)
117
+ onKeyDown: wrapEvent(children.props?.onKeyDown, handleKeyDown),
118
+ onClick: wrapEvent(children.props?.onClick, handleClick)
129
119
  }) : /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
130
120
  ref: mergeRefs(ref, buttonRef, dropdownButtonRef),
131
121
  type: "button",
@@ -142,14 +132,14 @@ const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
142
132
  [styles.hasText]: !!label,
143
133
  [styles.invalid]: isInvalid,
144
134
  [styles.labelled]: hasFormLabel,
145
- [styles.selected]: externalLabel !== null && externalLabel !== void 0 ? externalLabel : isOptionSelected // defaultLabel has lighter text color
146
-
135
+ [styles.selected]: externalLabel ?? isOptionSelected // defaultLabel has lighter text color
147
136
  }),
137
+
148
138
  onFocus: onFocus,
149
139
  onBlur: onBlur,
150
140
  onKeyDown: handleKeyDown,
151
141
  onClick: handleClick,
152
- "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : getSubDataTestId(contextDataTestId, 'button')
142
+ "data-testid": dataTestId ?? getSubDataTestId(contextDataTestId, 'button')
153
143
  }), /*#__PURE__*/React__default.createElement("span", {
154
144
  className: classNames(styles.buttonLabel, {
155
145
  [styles.isString]: typeof label === 'string'
@@ -158,7 +148,7 @@ const DropdownButton = /*#__PURE__*/forwardRef((_ref, ref) => {
158
148
  size: "medium",
159
149
  className: classNames(styles.icon, {
160
150
  [styles.open]: isOpen,
161
- [styles.disabled]: disabled !== null && disabled !== void 0 ? disabled : dropdownAriaDisabled
151
+ [styles.disabled]: disabled ?? dropdownAriaDisabled
162
152
  }),
163
153
  "aria-hidden": "true"
164
154
  })));
@@ -11,7 +11,8 @@ const DropdownHeader = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
11
11
  children,
12
12
  ...rest
13
13
  } = _ref;
14
- const commonProps = { ...rest,
14
+ const commonProps = {
15
+ ...rest,
15
16
  ref
16
17
  };
17
18
  const {
@@ -47,10 +47,11 @@ const DropdownList = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
47
47
  translate
48
48
  } = useTranslation();
49
49
  const noMatchesText = useMemo(() => isSearchable && translate('noMatchesFound'), [isSearchable, translate]);
50
- const ariaLabelledby = externalAriaLabelledBy !== null && externalAriaLabelledBy !== void 0 ? externalAriaLabelledBy : ariaLabelledByFromContext;
51
- const ariaLabel = externalAriaLabel !== null && externalAriaLabel !== void 0 ? externalAriaLabel : ariaLabelFromContext;
50
+ const ariaLabelledby = externalAriaLabelledBy ?? ariaLabelledByFromContext;
51
+ const ariaLabel = externalAriaLabel ?? ariaLabelFromContext;
52
52
  const announceToScreenReader = useScreenReaderAnnouncement('assertive');
53
- const showNoResults = useMemo(() => options.filter(option => option.isVisible).length === 1, // 1 to include the search box entry
53
+ const showNoResults = useMemo(() => options.filter(option => option.isVisible).length === 1,
54
+ // 1 to include the search box entry
54
55
  [options]);
55
56
  useDidUpdate(() => {
56
57
  if (showNoResults && isSearchable) {
@@ -78,14 +79,14 @@ const DropdownList = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
78
79
  "aria-labelledby": ariaLabelledby,
79
80
  hidden: !isOpen,
80
81
  onKeyDown: e => {
81
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
82
+ onKeyDown?.(e);
82
83
  onKeyDownList(e);
83
84
  },
84
85
  style: {
85
86
  minWidth,
86
87
  ...style
87
88
  },
88
- "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : getSubDataTestId(contextDataTestId, 'flyout')
89
+ "data-testid": dataTestId ?? getSubDataTestId(contextDataTestId, 'flyout')
89
90
  }), isSearchable && /*#__PURE__*/React__default.createElement(DropdownSearch, null), /*#__PURE__*/React__default.createElement("div", {
90
91
  id: listboxId,
91
92
  role: "listbox",
@@ -93,10 +94,10 @@ const DropdownList = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
93
94
  "aria-label": ariaLabel,
94
95
  "aria-labelledby": ariaLabelledby
95
96
  }, children), isSearchable && showNoResults && /*#__PURE__*/React__default.createElement("div", {
96
- className: styles.emptyOption // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
97
+ className: styles.emptyOption
98
+ // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
97
99
  ,
98
100
  role: "option" // `aria-selected` is omitted because this option is not selectable
99
-
100
101
  }, noMatchesText))
101
102
  });
102
103
  });