@qualtrics/ui-react 2.18.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 (267) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/__shared/cjs/{index-00992312.js → index-384184bd.js} +994 -1872
  3. package/dist/__shared/cjs/{index-615ed9b2.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/HStack.js +11 -0
  229. package/dist/next/Stack/Stack.js +95 -0
  230. package/dist/next/Stack/StackItem.js +37 -0
  231. package/dist/next/Stack/VStack.js +11 -0
  232. package/dist/next/Stack/index.js +3 -0
  233. package/dist/next/TimePicker/TimeDropdown.js +4 -5
  234. package/dist/next/TimePicker/TimeInput.js +4 -5
  235. package/dist/next/TimePicker/TimePicker.js +12 -30
  236. package/dist/next/TimePicker/TimePicker2.js +3 -3
  237. package/dist/next/TimePicker/TimePickerIcon.js +1 -3
  238. package/dist/next/TimePicker/utils.js +12 -52
  239. package/dist/next/ToggleButton/ToggleButton.js +0 -5
  240. package/dist/next/ToggleButton/ToggleButtonGroup.js +2 -1
  241. package/dist/next/ToggleButton/styles.js +3 -3
  242. package/dist/next/index.d.ts +82 -4
  243. package/dist/next/index.es.js +4 -0
  244. package/dist/next/index.js +514 -745
  245. package/dist/utils/Flyout/Flyout.js +4 -5
  246. package/dist/utils/Flyout/Flyout2.js +3 -3
  247. package/dist/utils/Popper/Popper.js +18 -25
  248. package/dist/utils/Portal/Portal.js +2 -1
  249. package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +4 -4
  250. package/dist/utils/Translation/Translate.js +0 -4
  251. package/dist/utils/Translation/TranslationProvider.js +0 -1
  252. package/dist/utils/Translation/containsComponentOrElement.js +1 -5
  253. package/dist/utils/Translation/insertPlaceholders.js +0 -1
  254. package/dist/utils/Translation/useTranslation.js +7 -14
  255. package/dist/utils/concatIds/concatIds.js +0 -1
  256. package/dist/utils/constants.js +2 -2
  257. package/dist/utils/createContextUtilities/createContextUtilities.js +0 -4
  258. package/dist/utils/filterChildren/filterChildren.js +8 -17
  259. package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -2
  260. package/dist/utils/keyboardUser/keyboardUser.js +0 -1
  261. package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -12
  262. package/dist/utils/mergeRefs/mergeRefs.js +1 -2
  263. package/dist/utils/wrapAround/wrapAround.js +1 -2
  264. package/dist/utils/wrapEvent/wrapEvent.js +2 -4
  265. package/icons/package.json +3 -2
  266. package/next/package.json +6 -2
  267. package/package.json +10 -5
@@ -35,81 +35,66 @@ const CollapsibleSearchInput = /*#__PURE__*/forwardRef((_ref, ref) => {
35
35
  'data-testid': dataTestId
36
36
  } = _ref;
37
37
  const [externalIsExpanded, setExternalIsExpanded] = useControllableState(defaultIsExpanded, onIsExpandedChange, isExpanded);
38
- const [internalExpandedState, setInternalExpandedState] = useState(externalIsExpanded ? expandedStates.EXPANDED : expandedStates.COLLAPSED); // Set to true when either the `SearchInput` or the `IconButton` has focus
38
+ const [internalExpandedState, setInternalExpandedState] = useState(externalIsExpanded ? expandedStates.EXPANDED : expandedStates.COLLAPSED);
39
39
 
40
+ // Set to true when either the `SearchInput` or the `IconButton` has focus
40
41
  const [isComponentFocused, setIsComponentFocused] = useState(false);
41
42
  const containerRef = useRef(null);
42
43
  const iconButtonRef = useRef(null);
43
44
  const searchInputRef = useRef(null);
44
-
45
45
  const handleContainerFocus = () => {
46
46
  setIsComponentFocused(true);
47
47
  };
48
-
49
48
  const handleContainerBlur = e => {
50
49
  // The blur handler is triggered on the container when the focus moves between child elements, so the below check confirms that the blur is actually focus moving away from the composite component (i.e. no child has focus)
51
50
  if (!e.currentTarget.contains(e.relatedTarget)) {
52
51
  setIsComponentFocused(false);
53
-
54
52
  if (searchInputRef.current && !searchInputRef.current.value) {
55
53
  setExternalIsExpanded(false);
56
54
  }
57
55
  }
58
56
  };
59
-
60
57
  const handleContainerTransitionEnd = () => {
61
58
  setInternalExpandedState(currentInternalExpandedState => {
62
59
  switch (currentInternalExpandedState) {
63
60
  case expandedStates.EXPANDING:
64
61
  return expandedStates.EXPANDED;
65
-
66
62
  case expandedStates.COLLAPSING:
67
63
  return expandedStates.COLLAPSED;
68
-
69
64
  default:
70
65
  return currentInternalExpandedState;
71
66
  }
72
67
  });
73
68
  };
74
-
75
69
  const handleIconButtonClick = () => {
76
- var _iconButtonRef$curren;
77
-
78
- (_iconButtonRef$curren = iconButtonRef.current) === null || _iconButtonRef$curren === void 0 ? void 0 : _iconButtonRef$curren.focus();
70
+ iconButtonRef.current?.focus();
79
71
  setExternalIsExpanded(true);
80
72
  };
81
-
82
73
  useDidUpdate(() => {
83
74
  setInternalExpandedState(currentInternalExpandedState => {
84
75
  if (externalIsExpanded && currentInternalExpandedState !== expandedStates.EXPANDED) {
85
76
  return expandedStates.EXPANDING;
86
77
  }
87
-
88
78
  if (currentInternalExpandedState !== expandedStates.COLLAPSED) {
89
79
  return expandedStates.COLLAPSING;
90
80
  }
91
-
92
81
  return currentInternalExpandedState;
93
82
  });
94
83
  }, [externalIsExpanded]);
95
84
  useEffect(() => {
96
- var _searchInputRef$curre, _iconButtonRef$curren2;
97
-
98
85
  if (isComponentFocused) {
99
86
  switch (internalExpandedState) {
100
87
  case expandedStates.EXPANDING:
101
- (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 ? void 0 : _searchInputRef$curre.focus();
88
+ searchInputRef.current?.focus();
102
89
  break;
103
-
104
90
  case expandedStates.COLLAPSED:
105
91
  /*
106
92
  * Handles use-case when user clicks on search input to enter text and the component is collapsed while focus is still on the search input.
107
93
  * This will show the focus ring on the icon button and allow the tooltip to appear.
108
94
  */
109
95
  setIsKeyboardUser(true);
110
- (_iconButtonRef$curren2 = iconButtonRef.current) === null || _iconButtonRef$curren2 === void 0 ? void 0 : _iconButtonRef$curren2.focus();
96
+ iconButtonRef.current?.focus();
111
97
  break;
112
-
113
98
  default:
114
99
  }
115
100
  }
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._3fl6H{display:inline-block;width:36px;transition:width .25s ease-out}._9j8Sr{width:100%}._2jEwz>input{padding-right:0!important}._3_kex>svg{fill:#515559}";
4
- var styles = {"collapsibleSearchInput":"_3fl6H","searchInput":"_9j8Sr","searchInputCollapsed":"_2jEwz","iconButton":"_3_kex"};
5
- var stylesheet="._3fl6H{display:inline-block;width:36px;transition:width .25s ease-out}._9j8Sr{width:100%}._2jEwz>input{padding-right:0!important}._3_kex>svg{fill:#515559}";
3
+ var css_248z = "._a--Sb{display:inline-block;width:36px;transition:width .25s ease-out}._9zyFU{width:100%}._9WaFz>input{padding-right:0!important}._USWmA>svg{fill:#515559}";
4
+ var styles = {"collapsibleSearchInput":"_a--Sb","searchInput":"_9zyFU","searchInputCollapsed":"_9WaFz","iconButton":"_USWmA"};
5
+ var stylesheet="._a--Sb{display:inline-block;width:36px;transition:width .25s ease-out}._9zyFU{width:100%}._9WaFz>input{padding-right:0!important}._USWmA>svg{fill:#515559}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -21,7 +21,7 @@ const CollapsibleSearchInputIconButton = /*#__PURE__*/forwardRef((_ref, ref) =>
21
21
  return /*#__PURE__*/React__default.createElement(IconButton, _extends({}, rest, {
22
22
  className: styles.iconButton,
23
23
  "aria-label": label,
24
- tooltipContent: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : label,
24
+ tooltipContent: tooltipContent ?? label,
25
25
  tooltipPlacement: tooltipPlacement,
26
26
  ref: ref
27
27
  }), /*#__PURE__*/React__default.createElement(SearchIcon, null));
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._2zb9Y :after{background-color:#515559!important}._2IA56>input:focus{box-shadow:none!important;border:1px solid #898989!important}._3SWYe{max-width:500px;padding:4px 0;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._3SWYe ._3WqmM ._RXIKL{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._3SWYe ._3WqmM:first-child ._1BAK1{display:none}._3SWYe ._1v19M{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._3SWYe ._1v19M:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3SWYe ._1v19M:hover._1_WF2{background-color:#e4effa}._3SWYe ._1v19M._1_WF2{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3SWYe ._1v19M:active:not(._1_WF2){background-color:#e8e9e9}";
4
- var styles = {"loadingSpinner":"_2zb9Y","ignoreFocusStyle":"_2IA56","flyout":"_3SWYe","group":"_3WqmM","header":"_RXIKL","divider":"_1BAK1","option":"_1v19M","selected":"_1_WF2"};
5
- var stylesheet="._2zb9Y :after{background-color:#515559!important}._2IA56>input:focus{box-shadow:none!important;border:1px solid #898989!important}._3SWYe{max-width:500px;padding:4px 0;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._3SWYe ._3WqmM ._RXIKL{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._3SWYe ._3WqmM:first-child ._1BAK1{display:none}._3SWYe ._1v19M{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._3SWYe ._1v19M:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3SWYe ._1v19M:hover._1_WF2{background-color:#e4effa}._3SWYe ._1v19M._1_WF2{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3SWYe ._1v19M:active:not(._1_WF2){background-color:#e8e9e9}";
3
+ var css_248z = "._izwLE :after{background-color:#515559!important}._Xo90l>input:focus{box-shadow:none!important;border:1px solid #898989!important}._fxxtl{max-width:500px;padding:4px 0;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._fxxtl ._OAeXr ._GNlMw{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._fxxtl ._OAeXr:first-child ._x-8a5{display:none}._fxxtl ._FhuBg{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._fxxtl ._FhuBg:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:hover._L-S0B{background-color:#e4effa}._fxxtl ._FhuBg._L-S0B{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:active:not(._L-S0B){background-color:#e8e9e9}";
4
+ var styles = {"loadingSpinner":"_izwLE","ignoreFocusStyle":"_Xo90l","flyout":"_fxxtl","group":"_OAeXr","header":"_GNlMw","divider":"_x-8a5","option":"_FhuBg","selected":"_L-S0B"};
5
+ var stylesheet="._izwLE :after{background-color:#515559!important}._Xo90l>input:focus{box-shadow:none!important;border:1px solid #898989!important}._fxxtl{max-width:500px;padding:4px 0;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._fxxtl ._OAeXr ._GNlMw{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._fxxtl ._OAeXr:first-child ._x-8a5{display:none}._fxxtl ._FhuBg{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._fxxtl ._FhuBg:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:hover._L-S0B{background-color:#e4effa}._fxxtl ._FhuBg._L-S0B{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:active:not(._L-S0B){background-color:#e8e9e9}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -32,17 +32,17 @@ const ComboboxFlyout = _ref => {
32
32
  name: 'offset',
33
33
  options: {
34
34
  offset: [-FOCUS_RING_WIDTH, FLYOUT_POPPER_OFFSET[1]] // The -FOCUS_RING_WIDTH skidding accounts for the box-shadow focus ring on the left side of the anchor
35
-
36
35
  }
37
36
  }],
37
+
38
38
  anchorNode: inputRef.current,
39
39
  popper: /*#__PURE__*/React__default.createElement("div", {
40
40
  role: "listbox",
41
41
  id: flyoutId,
42
42
  className: styles.flyout,
43
43
  style: flyoutDimensions,
44
- "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : rootAriaLabel,
45
- "aria-labelledby": ariaLabelledBy !== null && ariaLabelledBy !== void 0 ? ariaLabelledBy : rootAriaLabelledBy,
44
+ "aria-label": ariaLabel ?? rootAriaLabel,
45
+ "aria-labelledby": ariaLabelledBy ?? rootAriaLabelledBy,
46
46
  "aria-describedby": ariaDescribedBy,
47
47
  "data-testid": getSubDataTestId(rootDataTestId, 'flyout'),
48
48
  ref: flyoutRef
@@ -41,7 +41,7 @@ function ComboboxGroup(_ref) {
41
41
  className: styles.group,
42
42
  "aria-labelledby": headerElementId,
43
43
  "aria-describedby": ariaDescribedBy,
44
- "data-testid": getSubDataTestId(rootDataTestId, "group-".concat(label))
44
+ "data-testid": getSubDataTestId(rootDataTestId, `group-${label}`)
45
45
  }, /*#__PURE__*/React__default.createElement(Divider, {
46
46
  className: styles.divider
47
47
  }), /*#__PURE__*/React__default.createElement("div", {
@@ -47,39 +47,38 @@ const ComboboxInput = /*#__PURE__*/forwardRef((_ref, ref) => {
47
47
  hoveredOption,
48
48
  setHoveredOption
49
49
  } = useComboboxContext();
50
+
50
51
  /*
51
52
  * Creates a variation of selection follows focus.
52
53
  * The selected option label is not actually committed just by using arrow navigation, but the label does become the value of the input.
53
54
  */
54
-
55
55
  useEffect(() => {
56
56
  if (activeDescendantElement) {
57
57
  setRawInputValue(activeDescendantElement.innerHTML); // In a future version of Combobox, if we decide to allow custom children inside of `ComboboxOption`s, we can pass the `ComboboxOption`'s `label` to a `data-*` attribute and then access that attribute's value here instead of `innerHTML`.
58
58
  }
59
- }, [activeDescendantElement, setRawInputValue]); // Handles the case when looping flyout focus ends up focusing the input (the input is included in the focus loop)
59
+ }, [activeDescendantElement, setRawInputValue]);
60
60
 
61
+ // Handles the case when looping flyout focus ends up focusing the input (the input is included in the focus loop)
61
62
  useEffect(() => {
62
63
  if (!activeDescendantElement && rawInputValue !== committedInputValue) {
63
64
  setRawInputValue(committedInputValue);
64
65
  }
65
66
  }, [activeDescendantElement, rawInputValue, committedInputValue, setRawInputValue]);
66
-
67
67
  const commitCurrentRawInputValueAndCloseFlyout = () => {
68
68
  setCommittedInputValue(rawInputValue);
69
69
  setIsOpen(false);
70
70
  setHoveredOption(null);
71
71
  };
72
-
73
72
  const handleKeyDown = e => {
74
73
  switch (e.key) {
75
74
  case 'Escape':
76
75
  if (isOpen) {
77
76
  e.stopPropagation(); // Prevents event from closing modals or popovers
78
77
 
79
- if (committedInputValue !== '' && // An empty string is not considered to be a committed input value when escape is pressed
78
+ if (committedInputValue !== '' &&
79
+ // An empty string is not considered to be a committed input value when escape is pressed
80
80
  rawInputValue !== committedInputValue) {
81
81
  setRawInputValue(committedInputValue); // If a value was previously committed, revert back to that value
82
-
83
82
  focusInput();
84
83
  } else {
85
84
  commitCurrentRawInputValueAndCloseFlyout(); // If no value was previously committed, commit the current raw value
@@ -87,41 +86,29 @@ const ComboboxInput = /*#__PURE__*/forwardRef((_ref, ref) => {
87
86
  }
88
87
 
89
88
  break;
90
-
91
89
  case 'ArrowUp':
92
90
  e.preventDefault(); // Prevents cursor movement inside of input
93
-
94
91
  focusPrevious();
95
92
  break;
96
-
97
93
  case 'ArrowDown':
98
94
  e.preventDefault(); // Prevents cursor movement inside of input
99
-
100
95
  focusNext();
101
96
  break;
102
-
103
97
  case 'PageUp':
104
98
  e.preventDefault(); // Prevents page scroll
105
-
106
99
  focusFirst();
107
100
  break;
108
-
109
101
  case 'PageDown':
110
102
  e.preventDefault(); // Prevents page scroll
111
-
112
103
  focusLast();
113
104
  break;
114
-
115
105
  case 'Enter':
116
106
  e.preventDefault(); // Prevents form submission
117
-
118
107
  commitCurrentRawInputValueAndCloseFlyout();
119
108
  break;
120
-
121
109
  default:
122
110
  }
123
111
  };
124
-
125
112
  return /*#__PURE__*/React__default.createElement(Input, {
126
113
  role: "combobox",
127
114
  className: classNames(className, {
@@ -152,8 +139,8 @@ const ComboboxInput = /*#__PURE__*/forwardRef((_ref, ref) => {
152
139
  onBlur: () => {
153
140
  commitCurrentRawInputValueAndCloseFlyout();
154
141
  },
155
- "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : rootAriaLabel,
156
- "aria-labelledby": ariaLabelledBy !== null && ariaLabelledBy !== void 0 ? ariaLabelledBy : rootAriaLabelledBy,
142
+ "aria-label": ariaLabel ?? rootAriaLabel,
143
+ "aria-labelledby": ariaLabelledBy ?? rootAriaLabelledBy,
157
144
  "aria-describedby": ariaDescribedBy,
158
145
  "data-testid": getSubDataTestId(rootDataTestId, 'input'),
159
146
  "aria-expanded": isOpen,
@@ -30,28 +30,27 @@ function ComboboxOption(_ref) {
30
30
  deregisterOption: deregisterGroupOption
31
31
  } = useComboboxGroupContext();
32
32
  const lowercaseTrimmedCommittedInputValue = committedInputValue.trim().toLowerCase();
33
- const doesLabelMatchInputFilter = label.toLowerCase().startsWith(lowercaseTrimmedCommittedInputValue); // Handles registration and deregistration of the option
33
+ const doesLabelMatchInputFilter = label.toLowerCase().startsWith(lowercaseTrimmedCommittedInputValue);
34
34
 
35
+ // Handles registration and deregistration of the option
35
36
  useEffect(() => {
36
37
  const containerElement = containerElementRef.current;
37
-
38
38
  if (containerElement && doesLabelMatchInputFilter) {
39
39
  registerListOption(containerElement);
40
40
  registerGroupOption(containerElement);
41
41
  }
42
-
43
42
  return () => {
44
43
  if (containerElement) {
45
44
  deregisterListOption(containerElement);
46
45
  deregisterGroupOption(containerElement);
47
46
  }
48
47
  };
49
- }, [doesLabelMatchInputFilter, registerListOption, registerGroupOption, deregisterListOption, deregisterGroupOption]); // Doesn't render the option if its label doesn't match the input filter
48
+ }, [doesLabelMatchInputFilter, registerListOption, registerGroupOption, deregisterListOption, deregisterGroupOption]);
50
49
 
50
+ // Doesn't render the option if its label doesn't match the input filter
51
51
  if (!doesLabelMatchInputFilter) {
52
52
  return null;
53
53
  }
54
-
55
54
  const isOptionSelected = activeDescendantElement === containerElementRef.current;
56
55
  return /*#__PURE__*/React__default.createElement("div", {
57
56
  role: "option",
@@ -69,7 +68,7 @@ function ComboboxOption(_ref) {
69
68
  onMouseDown: e => e.preventDefault() // Prevents the input from getting blurred
70
69
  ,
71
70
  "aria-selected": isOptionSelected,
72
- "data-testid": getSubDataTestId(rootDataTestId, "option-".concat(label)),
71
+ "data-testid": getSubDataTestId(rootDataTestId, `option-${label}`),
73
72
  ref: containerElementRef
74
73
  }, label);
75
74
  }
@@ -3,33 +3,32 @@ import '../../utils/index.js';
3
3
  import { insertOption, deleteOption } from '../../utils/nodeRegistration/nodeRegistration.js';
4
4
 
5
5
  /* eslint-disable consistent-return */
6
+
6
7
  /**
7
8
  * Used to keep track of registered combobox options inside of a combobox group. Registered combobox options should be those that are part of the filtered list based on the input value.
8
9
  * @returns An object containing the list of filtered options inside of the group and functions for registering/deregistering a combobox option.
9
10
  */
10
-
11
11
  function useComboboxFilteredGroup() {
12
12
  const filteredOptionsRef = useRef([]);
13
+
13
14
  /**
14
15
  * Registers the element as an option in the filtered list.
15
16
  * @param option - The element to register.
16
17
  */
17
-
18
18
  const registerOption = useCallback(option => {
19
19
  // NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
20
20
  if (!option) {
21
21
  // eslint-disable-next-line no-console
22
- console.warn("[".concat(useComboboxFilteredGroup.name, "] registerOption called without any parameters! Pass in \"option\" as parameter."));
22
+ console.warn(`[${useComboboxFilteredGroup.name}] registerOption called without any parameters! Pass in "option" as parameter.`);
23
23
  return;
24
24
  }
25
-
26
25
  insertOption(option, filteredOptionsRef.current);
27
26
  }, []);
27
+
28
28
  /**
29
29
  * Deregisters the option, which means that the option is no longer in the filtered list.
30
30
  * @param option - The element to deregister.
31
31
  */
32
-
33
32
  const deregisterOption = useCallback(option => {
34
33
  // NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
35
34
  deleteOption(option, filteredOptionsRef.current, useComboboxFilteredGroup.name);
@@ -5,6 +5,7 @@ import useLatest from '../../../../hooks/useLatest/useLatest.js';
5
5
  import { insertOption, deleteOption } from '../../utils/nodeRegistration/nodeRegistration.js';
6
6
 
7
7
  /* eslint-disable @typescript-eslint/no-use-before-define */
8
+
8
9
  /**
9
10
  * A list of utilities to manage focus inside of a combobox. The input element is included in the focus loop.
10
11
  * @param isOpen - Inidicates if the flyout is open.
@@ -15,55 +16,51 @@ import { insertOption, deleteOption } from '../../utils/nodeRegistration/nodeReg
15
16
  * @param isDisabled - Indicates if the input is disabled.
16
17
  * @returns - A group of utils to register/deregister options in the flyout, handle focus management, and access the filtered options and current active descendant element.
17
18
  */
18
-
19
- function useComboboxFocusSequence(isOpen, setIsOpen, inputRef, isLoading, committedInputValue, // Don't use this parameter internally. Instead, use the internal `didCommittedInputValueChange` state
19
+ function useComboboxFocusSequence(isOpen, setIsOpen, inputRef, isLoading, committedInputValue,
20
+ // Don't use this parameter internally. Instead, use the internal `didCommittedInputValueChange` state
20
21
  isDisabled) {
21
22
  const [activeDescendant, setActiveDescendant] = useState(); // In a future version of `Combobox`, if we continue not to allow custom children inside of `ComboboxOption`s, we can remove `aria-activedescendant` and instead just let the screen reader read the new input value (e.g. see Google search box)
22
23
 
23
24
  const activeDescendantRef = useLatest(activeDescendant); // Used to prevent returned `useCallback` functions from being re-created
24
-
25
25
  const latestFocusFunctionNameRef = useRef(); // Used to call the correct focus function after the flyout opens (if the flyout is currently closed)
26
-
27
26
  const filteredOptionsRef = useRef([]); // The list of `ComboboxOption`s that match the filter based on the input value
28
27
 
29
28
  const [didCommittedInputValueChange, setDidCommittedInputValueChange] = useState(false);
29
+
30
30
  /*
31
31
  * Triggers a re-render so that we can get the list of filtered options.
32
32
  * The re-render is necessary because we need the `ComboboxOption`s to render and register themselves before running any logic on the list of filtered options.
33
33
  */
34
-
35
34
  useEffect(() => {
36
35
  setDidCommittedInputValueChange(true);
37
36
  }, [committedInputValue // Use of this variable is allowed here because it triggers the necessary re-render
38
37
  ]);
38
+
39
39
  /**
40
40
  * Opens the flyout, which will cause an effect to call the original focus function again to focus the correct `ComboboxOption`.
41
41
  * @param focusFunctionName - The name of the function that called this function (i.e. `myFunction.name`). Make sure that the function has the `name` property set on it.
42
42
  */
43
-
44
43
  const openFlyoutAndFocus = useCallback(focusFunctionName => {
45
44
  latestFocusFunctionNameRef.current = focusFunctionName;
46
45
  setIsOpen(true);
47
46
  }, [setIsOpen]);
47
+
48
48
  /**
49
49
  * Points `aria-activedescendant` to the passed in element and updates the `activeDescendantElement` state.
50
50
  * @param descendantElement - The element to be marked as the active descendant element.
51
51
  */
52
-
53
52
  const focusDescendant = useCallback((descendantElement, index) => {
54
- var _inputRef$current;
55
-
56
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setAttribute('aria-activedescendant', descendantElement.id);
53
+ inputRef.current?.setAttribute('aria-activedescendant', descendantElement.id);
57
54
  setActiveDescendant({
58
55
  element: descendantElement,
59
56
  index
60
57
  });
61
58
  }, [inputRef]);
59
+
62
60
  /**
63
61
  * Moves screen reader focus back to the input.
64
62
  * This does not call `focus()` on the input because the input will always have DOM focus when the combobox is being used.
65
63
  */
66
-
67
64
  const focusInput = useCallback(() => {
68
65
  /*
69
66
  * This check is necessary because it's expected that this function will sometimes be called when `inputRef.current` is `null`.
@@ -75,48 +72,44 @@ isDisabled) {
75
72
  setActiveDescendant(undefined);
76
73
  }
77
74
  }, [inputRef]);
75
+
78
76
  /**
79
77
  * Registers the `ComboboxOption` element as an option in the filtered list.
80
78
  * @param option - The element to register.
81
79
  */
82
-
83
80
  const registerOption = useCallback(option => {
84
81
  // NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
85
82
  if (!option) {
86
83
  // eslint-disable-next-line no-console
87
- console.error("[".concat(useComboboxFocusSequence.name, "] registerOption called without any parameters! Pass in a 'ComboboxOption' via the \"option\" parameter."));
84
+ console.error(`[${useComboboxFocusSequence.name}] registerOption called without any parameters! Pass in a 'ComboboxOption' via the "option" parameter.`);
88
85
  } else {
89
86
  insertOption(option, filteredOptionsRef.current);
90
87
  }
91
88
  }, []);
89
+
92
90
  /**
93
91
  * Deregisters the `ComboboxOption` element, which means that the option is no longer in the filtered list.
94
92
  * @param option - The element to deregister.
95
93
  */
96
-
97
94
  const deregisterOption = useCallback(option => {
98
95
  // NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
99
96
  if (!option) {
100
97
  // eslint-disable-next-line no-console
101
- console.error("[".concat(useComboboxFocusSequence.name, "] deregisterOption called without any parameters! Pass in a 'ComboboxOption' via the \"option\" parameter."));
98
+ console.error(`[${useComboboxFocusSequence.name}] deregisterOption called without any parameters! Pass in a 'ComboboxOption' via the "option" parameter.`);
102
99
  } else {
103
- var _activeDescendantRef$;
104
-
105
100
  deleteOption(option, filteredOptionsRef.current, useComboboxFocusSequence.name);
106
-
107
- if (option === ((_activeDescendantRef$ = activeDescendantRef.current) === null || _activeDescendantRef$ === void 0 ? void 0 : _activeDescendantRef$.element)) {
101
+ if (option === activeDescendantRef.current?.element) {
108
102
  setActiveDescendant(undefined);
109
103
  }
110
-
111
104
  if (filteredOptionsRef.current.length === 0) {
112
105
  focusInput();
113
106
  }
114
107
  }
115
108
  }, [activeDescendantRef, focusInput]);
109
+
116
110
  /**
117
111
  * Focuses the first option in the `ComboboxFlyout`.
118
112
  */
119
-
120
113
  const focusFirst = useCallback(function focusFirst() {
121
114
  if (!isOpen) {
122
115
  openFlyoutAndFocus(focusFirst.name);
@@ -126,10 +119,10 @@ isDisabled) {
126
119
  logNoOptionsToFocusError(focusFirst.name);
127
120
  }
128
121
  }, [isOpen, openFlyoutAndFocus, focusDescendant]);
122
+
129
123
  /**
130
124
  * Focuses the last option in the `ComboboxFlyout`.
131
125
  */
132
-
133
126
  const focusLast = useCallback(function focusLast() {
134
127
  if (!isOpen) {
135
128
  openFlyoutAndFocus(focusLast.name);
@@ -139,18 +132,15 @@ isDisabled) {
139
132
  logNoOptionsToFocusError(focusLast.name);
140
133
  }
141
134
  }, [isOpen, openFlyoutAndFocus, focusDescendant]);
135
+
142
136
  /**
143
137
  * Focuses the next option in the `ComboboxFlyout`. If the last option in the `ComboboxFlyout` is currently focused, the input will be focused.
144
138
  */
145
-
146
139
  const focusNext = useCallback(function focusNext() {
147
140
  if (!isOpen) {
148
141
  openFlyoutAndFocus(focusNext.name);
149
142
  } else {
150
- var _activeDescendantRef$2;
151
-
152
- const currentFocusedNodeIndex = (_activeDescendantRef$2 = activeDescendantRef.current) === null || _activeDescendantRef$2 === void 0 ? void 0 : _activeDescendantRef$2.index;
153
-
143
+ const currentFocusedNodeIndex = activeDescendantRef.current?.index;
154
144
  if (currentFocusedNodeIndex === filteredOptionsRef.current.length - 1) {
155
145
  focusInput();
156
146
  } else if (currentFocusedNodeIndex === undefined) {
@@ -163,18 +153,15 @@ isDisabled) {
163
153
  }
164
154
  }
165
155
  }, [isOpen, openFlyoutAndFocus, activeDescendantRef, focusInput, focusFirst, focusDescendant]);
156
+
166
157
  /**
167
158
  * Focuses the previous option in the list. If the first option in the list is currently focused, the input will be focused.
168
159
  */
169
-
170
160
  const focusPrevious = useCallback(function focusPrevious() {
171
161
  if (!isOpen) {
172
162
  openFlyoutAndFocus(focusPrevious.name);
173
163
  } else {
174
- var _activeDescendantRef$3;
175
-
176
- const currentFocusedNodeIndex = (_activeDescendantRef$3 = activeDescendantRef.current) === null || _activeDescendantRef$3 === void 0 ? void 0 : _activeDescendantRef$3.index;
177
-
164
+ const currentFocusedNodeIndex = activeDescendantRef.current?.index;
178
165
  if (currentFocusedNodeIndex === 0) {
179
166
  focusInput();
180
167
  } else if (currentFocusedNodeIndex === undefined) {
@@ -186,67 +173,68 @@ isDisabled) {
186
173
  logNoOptionsToFocusError(focusPrevious.name);
187
174
  }
188
175
  }
189
- }, [isOpen, openFlyoutAndFocus, activeDescendantRef, focusInput, focusLast, focusDescendant]); // If the flyout is currently open and there are no filtered options, the flyout is closed
176
+ }, [isOpen, openFlyoutAndFocus, activeDescendantRef, focusInput, focusLast, focusDescendant]);
190
177
 
178
+ // If the flyout is currently open and there are no filtered options, the flyout is closed
191
179
  useEffect(() => {
192
180
  if (isOpen && filteredOptionsRef.current.length === 0) {
193
181
  setIsOpen(false);
194
182
  }
195
- }, [isOpen, setIsOpen]); // If the flyout was opened in order to focus an option, and filtered options exist, calls the proper focus function
183
+ }, [isOpen, setIsOpen]);
196
184
 
185
+ // If the flyout was opened in order to focus an option, and filtered options exist, calls the proper focus function
197
186
  useEffect(() => {
198
187
  if (isOpen && filteredOptionsRef.current.length > 0) {
199
188
  switch (latestFocusFunctionNameRef.current) {
200
189
  case focusFirst.name:
201
190
  focusFirst();
202
191
  break;
203
-
204
192
  case focusLast.name:
205
193
  focusLast();
206
194
  break;
207
-
208
195
  case focusPrevious.name:
209
196
  focusPrevious();
210
197
  break;
211
-
212
198
  case focusNext.name:
213
199
  focusNext();
214
200
  break;
215
-
216
201
  default:
217
202
  }
218
203
  }
219
-
220
204
  latestFocusFunctionNameRef.current = undefined;
221
- }, [isOpen, focusFirst, focusLast, focusPrevious, focusNext]); // If the committed input value changes and there are no filtered options, the flyout is closed
205
+ }, [isOpen, focusFirst, focusLast, focusPrevious, focusNext]);
222
206
 
207
+ // If the committed input value changes and there are no filtered options, the flyout is closed
223
208
  useEffect(() => {
224
209
  if (filteredOptionsRef.current.length === 0) {
225
210
  setIsOpen(false);
226
211
  }
227
-
228
212
  setDidCommittedInputValueChange(false); // Since the committed input value change was caught in this effect, the state needs to be reset to `false`
229
213
  }, [setIsOpen, didCommittedInputValueChange // This dependency is needed in order to listen for a change to the committed input value
230
- ]); // If options are loaded and there are no filtered options, the flyout is closed
214
+ ]);
231
215
 
216
+ // If options are loaded and there are no filtered options, the flyout is closed
232
217
  useEffect(() => {
233
218
  if (!isLoading && filteredOptionsRef.current.length === 0) {
234
219
  setIsOpen(false);
235
220
  }
236
- }, [isLoading, setIsOpen]); // Focuses the input when new options are loaded
221
+ }, [isLoading, setIsOpen]);
237
222
 
223
+ // Focuses the input when new options are loaded
238
224
  useEffect(() => {
239
225
  if (!isLoading) {
240
226
  focusInput();
241
227
  }
242
- }, [isLoading, focusInput]); // Focuses the input when the flyout closes
228
+ }, [isLoading, focusInput]);
243
229
 
230
+ // Focuses the input when the flyout closes
244
231
  useEffect(() => {
245
232
  if (!isOpen) {
246
233
  focusInput();
247
234
  }
248
- }, [isOpen, focusInput]); // Closes the flyout when the input becomes disabled
235
+ }, [isOpen, focusInput]);
249
236
 
237
+ // Closes the flyout when the input becomes disabled
250
238
  useEffect(() => {
251
239
  if (isDisabled) {
252
240
  setIsOpen(false);
@@ -260,43 +248,38 @@ isDisabled) {
260
248
  focusLast,
261
249
  focusNext,
262
250
  focusPrevious,
263
- activeDescendantElement: activeDescendant === null || activeDescendant === void 0 ? void 0 : activeDescendant.element,
251
+ activeDescendantElement: activeDescendant?.element,
264
252
  filteredOptionsRef
265
253
  };
266
254
  }
267
-
268
255
  function logNoOptionsToFocusError(functionName) {
269
256
  // eslint-disable-next-line no-console
270
- console.error("[".concat(useComboboxFocusSequence.name, "] Invalid call to '").concat(functionName, "'. There are no registered nodes to focus."));
257
+ console.error(`[${useComboboxFocusSequence.name}] Invalid call to '${functionName}'. There are no registered nodes to focus.`);
271
258
  }
259
+
272
260
  /**
273
261
  * Gets the index of the next `ComboboxOption` in the filtered options list.
274
262
  * @param currentIndex - The index of the currently selected `ComboboxOption`.
275
263
  * @param numFilteredOptions - The number of filtered options in the list.
276
264
  * @returns The index of the next `ComboboxOption` in the filtered options list (wraps to create looping focus).
277
265
  */
278
-
279
-
280
266
  function getNextIndex(currentIndex, numFilteredOptions) {
281
267
  if (currentIndex === undefined || currentIndex === -1) {
282
268
  return -1;
283
269
  }
284
-
285
270
  return (currentIndex + 1) % numFilteredOptions;
286
271
  }
272
+
287
273
  /**
288
274
  * Gets the index of the previous `ComboboxOption` in the filtered options list.
289
275
  * @param currentIndex - The index of the currently selected `ComboboxOption`.
290
276
  * @param numFilteredOptions - The number of filtered options in the list.
291
277
  * @returns The index of the previous `ComboboxOption` in the filtered options list (wraps to create looping focus).
292
278
  */
293
-
294
-
295
279
  function getPreviousIndex(currentIndex, numFilteredOptions) {
296
280
  if (currentIndex === undefined || currentIndex === -1) {
297
281
  return -1;
298
282
  }
299
-
300
283
  return (currentIndex + numFilteredOptions - 1) % numFilteredOptions;
301
284
  }
302
285