@qualtrics/ui-react 2.25.0 → 2.27.0

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 (170) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/__shared/cjs/{index-610a1e02.js → index-88aa3bce.js} +267 -256
  3. package/dist/__shared/cjs/{index-5b3b3406.js → index-e6893573.js} +23 -3
  4. package/dist/components/Accordion/Accordion2.js +3 -3
  5. package/dist/components/Button/Button.js +3 -3
  6. package/dist/components/Button/Button2.js +1 -1
  7. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  8. package/dist/components/Checkbox/Checkbox2.js +3 -3
  9. package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
  10. package/dist/components/ColorPicker/Alpha.js +1 -1
  11. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  12. package/dist/components/ColorPicker/Hue.js +1 -1
  13. package/dist/components/ColorPicker/Palette.js +1 -1
  14. package/dist/components/ColorPicker/Saturation.js +1 -1
  15. package/dist/components/Combobox/Combobox.js +3 -3
  16. package/dist/components/Combobox/Combobox2.js +3 -3
  17. package/dist/components/Combobox/ComboboxIcon.js +1 -1
  18. package/dist/components/Combobox/ComboboxInput.js +1 -1
  19. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  20. package/dist/components/Divider/Divider2.js +3 -3
  21. package/dist/components/Dropdown/Dropdown.js +4 -4
  22. package/dist/components/Dropdown/Dropdown2.js +3 -3
  23. package/dist/components/Dropdown/DropdownButton.js +6 -6
  24. package/dist/components/Dropdown/DropdownList.js +1 -1
  25. package/dist/components/Dropdown/DropdownOption.js +2 -2
  26. package/dist/components/Dropdown/DropdownSearch.js +2 -2
  27. package/dist/components/FilePicker/FilePicker.js +2 -2
  28. package/dist/components/FilePicker/FilePicker2.js +3 -3
  29. package/dist/components/FormField/Caption.js +3 -3
  30. package/dist/components/FormField/FormField2.js +3 -3
  31. package/dist/components/FormField/FormFieldContext.js +3 -3
  32. package/dist/components/FullScreenTakeover/FullScreenTakeover.js +2 -2
  33. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  34. package/dist/components/Icon/IconTypes.js +5 -0
  35. package/dist/components/IconButton/IconButton2.js +3 -3
  36. package/dist/components/InlineInput/InlineInput.js +7 -7
  37. package/dist/components/InlineInput/InlineInput2.js +3 -3
  38. package/dist/components/Input/Input2.js +3 -3
  39. package/dist/components/Input/InputField.js +2 -2
  40. package/dist/components/InputGroup/InputGroup2.js +3 -3
  41. package/dist/components/Label/Label2.js +3 -3
  42. package/dist/components/Link/Link2.js +3 -3
  43. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  44. package/dist/components/LogicEditor/LogicEditor.js +1 -1
  45. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  46. package/dist/components/Modal/Modal.js +6 -6
  47. package/dist/components/Modal/Modal2.js +3 -3
  48. package/dist/components/NewMenu/BaseMenu.js +3 -3
  49. package/dist/components/NewMenu/NewMenu.js +3 -3
  50. package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -2
  51. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +3 -3
  52. package/dist/components/NumberStepper/NumberStepper.js +2 -2
  53. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  54. package/dist/components/NumberStepper/NumberStepperDecrement.js +1 -1
  55. package/dist/components/NumberStepper/NumberStepperIncrement.js +1 -1
  56. package/dist/components/NumberStepper/NumberStepperInput.js +3 -3
  57. package/dist/components/PageLayout/PageLayout.js +3 -3
  58. package/dist/components/Pagination/Pagination.js +1 -1
  59. package/dist/components/Pagination/Pagination2.js +3 -3
  60. package/dist/components/Pagination/PaginationNextButton.js +3 -3
  61. package/dist/components/Pagination/PaginationPageInput.js +8 -8
  62. package/dist/components/Pagination/PaginationPreviousButton.js +3 -3
  63. package/dist/components/Popover/Popover.js +5 -5
  64. package/dist/components/Popover/Popover2.js +3 -3
  65. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  66. package/dist/components/QuickSearch/QuickSearchInput.js +4 -4
  67. package/dist/components/Radio/Radio2.js +3 -3
  68. package/dist/components/SearchInput/SearchInput.js +2 -2
  69. package/dist/components/SearchInput/SearchInput2.js +3 -3
  70. package/dist/components/SidebarNav/SidebarNav.js +1 -1
  71. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  72. package/dist/components/Slider/Slider2.js +3 -3
  73. package/dist/components/Switch/Switch2.js +3 -3
  74. package/dist/components/Table/Table2.js +3 -3
  75. package/dist/components/Tabs/Tabs2.js +3 -3
  76. package/dist/components/Tooltip/Tooltip2.js +3 -3
  77. package/dist/components/deprecated_ColorPicker/Alpha.js +2 -2
  78. package/dist/components/deprecated_ColorPicker/ColorPicker.js +1 -1
  79. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  80. package/dist/components/deprecated_ColorPicker/HexInput.js +1 -1
  81. package/dist/components/deprecated_ColorPicker/Hue.js +2 -2
  82. package/dist/components/deprecated_ColorPicker/Saturation.js +2 -2
  83. package/dist/components/deprecated_ColorPicker/Swatch.js +1 -1
  84. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  85. package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +1 -1
  86. package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +1 -1
  87. package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +3 -3
  88. package/dist/components/deprecated_Tabs/Tabs.js +3 -3
  89. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  90. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  91. package/dist/components/deprecated_Toolbar/ToolbarPanels.js +1 -1
  92. package/dist/components/deprecated_Toolbar/ToolbarTab.js +5 -5
  93. package/dist/components/deprecated_Toolbar/ToolbarTabs.js +3 -3
  94. package/dist/hooks/useControllableState/useControllableState.js +1 -1
  95. package/dist/hooks/useOverlay/useOverlay.js +2 -2
  96. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  97. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +1 -1
  98. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  99. package/dist/icons/Icon.js +3 -3
  100. package/dist/icons/components/AIChatbotIcon.js +6 -0
  101. package/dist/icons/components/LinesIcon.js +6 -0
  102. package/dist/icons/components/RobotConversationalIcon.js +6 -0
  103. package/dist/icons/components/ScatterPlotIcon.js +6 -0
  104. package/dist/icons/components/UnmoderatedUserTestingIcon.js +6 -0
  105. package/dist/icons/index.d.ts +10 -0
  106. package/dist/icons/index.es.js +5 -0
  107. package/dist/icons/index.js +6 -1
  108. package/dist/index.d.ts +11 -0
  109. package/dist/index.es.js +1 -1
  110. package/dist/index.js +3 -3
  111. package/dist/next/AdvancedTable/AdvancedTable.js +36 -8
  112. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  113. package/dist/next/AdvancedTable/AdvancedTableCell.js +4 -4
  114. package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +3 -3
  115. package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +2 -2
  116. package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -1
  117. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +3 -3
  118. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  119. package/dist/next/CollectionGrid/CollectionGrid.js +34 -0
  120. package/dist/next/CollectionGrid/CollectionGridItem.js +18 -0
  121. package/dist/next/CollectionGrid/index.js +2 -0
  122. package/dist/next/Combobox/Combobox.js +2 -0
  123. package/dist/next/Combobox/Combobox2.js +3 -3
  124. package/dist/next/Combobox/ComboboxInput.js +2 -0
  125. package/dist/next/Combobox/ComboboxOption.js +2 -0
  126. package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
  127. package/dist/next/Drawer/Drawer.js +2 -2
  128. package/dist/next/Drawer/Drawer2.js +3 -3
  129. package/dist/next/FilterAnchor/FilterAnchor.js +2 -2
  130. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  131. package/dist/next/Input/Input2.js +3 -3
  132. package/dist/next/LayoutGrid/LayoutGrid.js +38 -0
  133. package/dist/next/LayoutGrid/LayoutGridItem.js +23 -0
  134. package/dist/next/LayoutGrid/index.js +2 -0
  135. package/dist/next/Menu/Hooks/useFocusVirtualBoundary.js +41 -0
  136. package/dist/next/Menu/Hooks/useIsVirtualized.js +8 -0
  137. package/dist/next/Menu/Hooks/useMaskDimensions.js +59 -0
  138. package/dist/next/Menu/{useMutationObserver.js → Hooks/useMutationObserver.js} +1 -1
  139. package/dist/next/Menu/{usePaneSearch.js → Hooks/usePaneSearch.js} +61 -24
  140. package/dist/next/Menu/Menu.js +19 -24
  141. package/dist/next/Menu/Menu2.js +3 -3
  142. package/dist/next/Menu/MenuContext.js +5 -1
  143. package/dist/next/Menu/MenuItem.js +21 -14
  144. package/dist/next/Menu/MenuPane.js +73 -54
  145. package/dist/next/Menu/PaneChildren.js +47 -0
  146. package/dist/next/Menu/SubMenu.js +57 -39
  147. package/dist/next/PhoneNumberInput/PhoneNumberInput.js +1 -1
  148. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  149. package/dist/next/Select/Select.js +10 -6
  150. package/dist/next/Select/Select2.js +3 -3
  151. package/dist/next/Select/SubSelect.js +2 -2
  152. package/dist/next/SplitButton/SplitButton2.js +3 -3
  153. package/dist/next/Stack/Stack.js +1 -18
  154. package/dist/next/TimePicker/TimePicker2.js +3 -3
  155. package/dist/next/TimePicker/TimePickerIcon.js +1 -1
  156. package/dist/next/ToggleButton/styles.js +3 -3
  157. package/dist/next/index.d.ts +57 -3
  158. package/dist/next/index.es.js +6 -0
  159. package/dist/next/index.js +614 -268
  160. package/dist/translations-en.js +7 -1
  161. package/dist/utils/Flyout/Flyout2.js +3 -3
  162. package/dist/utils/GridChildrenWrapper/GridChildrenWrapper.js +30 -0
  163. package/dist/utils/GridChildrenWrapper/index.js +1 -0
  164. package/dist/utils/Popper/Popper.js +2 -2
  165. package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -1
  166. package/dist/utils/wrapEvent/wrapEvent.js +1 -1
  167. package/icons/package.json +3 -1
  168. package/next/package.json +4 -2
  169. package/package.json +5 -3
  170. /package/dist/next/Menu/{useCSSVariable.js → Hooks/useCSSVariable.js} +0 -0
@@ -1,23 +1,39 @@
1
- import React__default, { useState, useEffect, useRef, useCallback } from 'react';
1
+ import React__default, { useState, useMemo, useEffect, useRef, useCallback } from 'react';
2
2
  import classNames from 'classnames';
3
- import '../../hooks/index.js';
4
- import '../../utils/index.js';
5
- import { useMenuContext } from './MenuContext.js';
6
- import { KEYS, DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from './constants.js';
7
- import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
8
- import styles from './Menu2.js';
9
- import useControllableState from '../../hooks/useControllableState/useControllableState.js';
10
- import useTranslation from '../../utils/Translation/useTranslation.js';
11
- import useEventListener from '../../hooks/useEventListener/useEventListener.js';
3
+ import '../../../hooks/index.js';
4
+ import '../../../utils/index.js';
5
+ import { useMenuContext } from '../MenuContext.js';
6
+ import { KEYS, DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from '../constants.js';
7
+ import { DATA_TESTID_SUFFIXES } from '../../Select/constants.js';
8
+ import styles from '../Menu2.js';
9
+ import useSelectContext from '../../Select/SelectContext.js';
10
+ import useFocusVirtualBoundary from './useFocusVirtualBoundary.js';
11
+ import useControllableState from '../../../hooks/useControllableState/useControllableState.js';
12
+ import useTranslation from '../../../utils/Translation/useTranslation.js';
13
+ import useEventListener from '../../../hooks/useEventListener/useEventListener.js';
12
14
 
13
15
  // abstracts the logic required for searching by both `MenuPane` and `SubMenu`
14
16
  // creates a searchBarConfig, which maps to an instance of `MenuSearch`
15
17
  // returns values that are necessary for use within pane
16
- function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, animatedRight, menuParentDataTestId, id, flyoutRef) {
18
+ function usePaneSearch(_ref) {
17
19
  var _searchRef$current$qu, _searchRef$current;
18
- let withinSelect = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : undefined;
19
- let backButtonRef = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : undefined;
20
- let closeSubmenu = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : undefined;
20
+ let {
21
+ isSearchable,
22
+ externalSearchValue,
23
+ onSearchValueChange,
24
+ items,
25
+ animatedLeft,
26
+ animatedRight,
27
+ menuParentDataTestId,
28
+ id,
29
+ flyoutRef,
30
+ children,
31
+ isSearchFilteringDisabled,
32
+ backButtonRef,
33
+ closeSubmenu,
34
+ isVirtualized
35
+ } = _ref;
36
+ const withinSelect = useSelectContext(true) !== null;
21
37
  const [internalSearchValue, setSearchValue] = useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
22
38
  const [zeroSearchResults, setZeroSearchResults] = useState();
23
39
  const {
@@ -25,22 +41,34 @@ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, i
25
41
  } = useTranslation();
26
42
  const noMatchesText = translate('menu.noItemsToDisplay');
27
43
  const searchPlaceholder = translate('searchText');
44
+ const filteredChildren = useMemo(() => (Array.isArray(children) ? children : [children]).filter(_ref2 => {
45
+ var _props$label, _searchMatcher$toLowe;
46
+ let {
47
+ props
48
+ } = _ref2;
49
+ if (!props || !internalSearchValue || isSearchFilteringDisabled) {
50
+ return true;
51
+ }
52
+ const searchMatcher = (_props$label = props.label) !== null && _props$label !== void 0 ? _props$label : typeof props.children === 'string' ? props.children : undefined;
53
+ return searchMatcher === null || searchMatcher === void 0 || (_searchMatcher$toLowe = searchMatcher.toLowerCase) === null || _searchMatcher$toLowe === void 0 ? void 0 : _searchMatcher$toLowe.call(searchMatcher).includes(internalSearchValue.toLowerCase());
54
+ }), [internalSearchValue, children, isSearchFilteringDisabled]);
55
+ const focusVirtualBoundary = useFocusVirtualBoundary(items, backButtonRef);
28
56
  useEffect(() => setZeroSearchResults((items === null || items === void 0 ? void 0 : items.filter(item => item.element.current).length) === 0), [items, internalSearchValue]);
29
57
  const searchRef = useRef(null);
30
58
  const searchInput = (_searchRef$current$qu = (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.querySelector('input')) !== null && _searchRef$current$qu !== void 0 ? _searchRef$current$qu : null;
31
- const getFirstNonNullItem = () => {
59
+ const getFirstVisibleItem = () => {
32
60
  var _backButtonRef$curren, _items$find;
33
61
  return (_backButtonRef$curren = backButtonRef === null || backButtonRef === void 0 ? void 0 : backButtonRef.current) !== null && _backButtonRef$curren !== void 0 ? _backButtonRef$curren : (_items$find = items.find(item => item.element.current)) === null || _items$find === void 0 ? void 0 : _items$find.element.current;
34
62
  };
35
- const getLastNonNullItem = () => {
63
+ const getLastVisibleItem = () => {
36
64
  var _findLast$element$cur, _findLast;
37
65
  return (// our tsconfig does not target a recent enough version to use `Array.prototype.findLast`
38
66
  (_findLast$element$cur = (_findLast = items.findLast(item => item.element.current)) === null || _findLast === void 0 ? void 0 : _findLast.element.current) !== null && _findLast$element$cur !== void 0 ? _findLast$element$cur : backButtonRef === null || backButtonRef === void 0 ? void 0 : backButtonRef.current
39
67
  );
40
68
  };
41
69
  useEventListener(flyoutRef, 'keydown', e => {
42
- if (KEYS.NAVIGATE_UP.includes(e.key) && e.target === getFirstNonNullItem() || KEYS.NAVIGATE_DOWN.includes(e.key) && e.target === getLastNonNullItem()) {
43
- searchInput === null || searchInput === void 0 ? void 0 : searchInput.focus();
70
+ if (KEYS.NAVIGATE_UP.includes(e.key) && e.target === getFirstVisibleItem() || KEYS.NAVIGATE_DOWN.includes(e.key) && e.target === getLastVisibleItem()) {
71
+ searchInput === null || searchInput === void 0 || searchInput.focus();
44
72
  }
45
73
  }, {
46
74
  additionalDependencies: [flyoutRef.current],
@@ -51,17 +79,25 @@ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, i
51
79
  var _e$target;
52
80
  lastestKeyPressedInSearchInput.current = e.key;
53
81
  if ([...KEYS.NAVIGATE_DOWN, ...KEYS.NAVIGATE_TOP].includes(e.key)) {
54
- var _getFirstNonNullItem;
55
82
  // prevent scrolling
56
83
  e.preventDefault();
57
- (_getFirstNonNullItem = getFirstNonNullItem()) === null || _getFirstNonNullItem === void 0 ? void 0 : _getFirstNonNullItem.focus();
84
+ if (isVirtualized) {
85
+ focusVirtualBoundary('top');
86
+ } else {
87
+ var _getFirstVisibleItem;
88
+ (_getFirstVisibleItem = getFirstVisibleItem()) === null || _getFirstVisibleItem === void 0 || _getFirstVisibleItem.focus();
89
+ }
58
90
  } else if ([...KEYS.NAVIGATE_UP, ...KEYS.NAVIIGATE_BOTTOM].includes(e.key)) {
59
- var _getLastNonNullItem;
60
91
  // prevent scrolling
61
92
  e.preventDefault();
62
- (_getLastNonNullItem = getLastNonNullItem()) === null || _getLastNonNullItem === void 0 ? void 0 : _getLastNonNullItem.focus();
93
+ if (isVirtualized) {
94
+ focusVirtualBoundary('bottom');
95
+ } else {
96
+ var _getLastVisibleItem;
97
+ (_getLastVisibleItem = getLastVisibleItem()) === null || _getLastVisibleItem === void 0 || _getLastVisibleItem.focus();
98
+ }
63
99
  } else if (KEYS.CLOSE_SUBMENU.includes(e.key) && ((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.selectionStart) === 0) {
64
- closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
100
+ closeSubmenu === null || closeSubmenu === void 0 || closeSubmenu(e);
65
101
  } else if (KEYS.IGNORED_BY_SEARCH_INPUT.includes(e.key)) {
66
102
  e.preventDefault();
67
103
  }
@@ -126,7 +162,8 @@ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, i
126
162
  return {
127
163
  internalSearchValue,
128
164
  noSearchResultsNode,
129
- onInteractOutside
165
+ onInteractOutside,
166
+ filteredChildren
130
167
  };
131
168
  }
132
169
 
@@ -1,8 +1,10 @@
1
- import React__default, { useState, useRef, useMemo } from 'react';
1
+ import React__default, { useRef, useState, useMemo } from 'react';
2
2
  import { Root } from '@radix-ui/react-dropdown-menu';
3
+ import { ResizeObserver } from '@juggle/resize-observer';
3
4
  import { MenuContextProvider } from './MenuContext.js';
4
5
  import '../../hooks/index.js';
5
6
  import useControllableState from '../../hooks/useControllableState/useControllableState.js';
7
+ import useEventListener from '../../hooks/useEventListener/useEventListener.js';
6
8
 
7
9
  /* eslint-disable max-classes-per-file */
8
10
  const Menu = _ref => {
@@ -12,7 +14,8 @@ const Menu = _ref => {
12
14
  isOpen,
13
15
  onIsOpenChange,
14
16
  isDisabled,
15
- children
17
+ children,
18
+ isVirtualizationDisabled
16
19
  } = _ref;
17
20
  if (typeof process !== 'undefined' && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) === 'test' && window) {
18
21
  var _window$ResizeObserve, _window$PointerEvent;
@@ -20,6 +23,7 @@ const Menu = _ref => {
20
23
  window.PointerEvent = (_window$PointerEvent = window.PointerEvent) !== null && _window$PointerEvent !== void 0 ? _window$PointerEvent : PointerEvent;
21
24
  }
22
25
  const [open, setOpen] = useControllableState(isOpen, onIsOpenChange, isOpen);
26
+ const virtuoso = useRef(null);
23
27
  const [maskHeight, setMaskHeight] = useState(null);
24
28
  const [maskWidth, setMaskWidth] = useState(null);
25
29
  const [submenus, setSubmenus] = useState(new Set());
@@ -35,6 +39,16 @@ const Menu = _ref => {
35
39
  return clone;
36
40
  });
37
41
  };
42
+
43
+ // Virtuoso and Radix-Dropdown have conflicting ResizeObserver behavior
44
+ // according to the author of the error, this is not a problem https://stackoverflow.com/a/50387233/9487902
45
+ // the virtuoso library author recommends this approach for conflicting libraries https://virtuoso.dev/react-beautiful-dnd/
46
+ useEventListener(window, 'error', e => {
47
+ if (e.message === 'ResizeObserver loop completed with undelivered notifications.' || e.message === 'ResizeObserver loop limit exceeded') {
48
+ e.stopImmediatePropagation();
49
+ e.preventDefault();
50
+ }
51
+ });
38
52
  const openPaneDepth = useMemo(() => open ? submenus.size + 1 : 0, [submenus, open]);
39
53
  const [searchBarConfigs, setSearchBarConfigs] = useState([]);
40
54
  return /*#__PURE__*/React__default.createElement(MenuContextProvider, {
@@ -50,7 +64,9 @@ const Menu = _ref => {
50
64
  searchBarConfigs,
51
65
  setSearchBarConfigs,
52
66
  maskWidth,
53
- setMaskWidth
67
+ setMaskWidth,
68
+ virtuoso,
69
+ isVirtualizationDisabled
54
70
  }
55
71
  }, /*#__PURE__*/React__default.createElement(Root, {
56
72
  open: open,
@@ -59,27 +75,6 @@ const Menu = _ref => {
59
75
  }, children));
60
76
  };
61
77
 
62
- // https://github.com/radix-ui/primitives/issues/420#issuecomment-771615182
63
- class ResizeObserver {
64
- constructor(cb) {
65
- this.cb = cb;
66
- }
67
- observe() {
68
- this.cb([{
69
- borderBoxSize: {
70
- inlineSize: 0,
71
- blockSize: 0
72
- }
73
- }]);
74
- }
75
-
76
- // eslint-disable-next-line class-methods-use-this
77
- unobserve() {}
78
-
79
- // eslint-disable-next-line class-methods-use-this
80
- disconnect() {}
81
- }
82
-
83
78
  // https://github.com/radix-ui/primitives/issues/1220#issuecomment-1087465026
84
79
  class PointerEvent extends Event {
85
80
  constructor(type, props) {
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._OOjwY{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._OOjwY>._MJORL{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._OOjwY>._MJORL:hover:not([aria-disabled=true]){background-color:#f5f5f5}._OOjwY>._MJORL.focus-visible,._OOjwY>._MJORL:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._OOjwY>._MJORL+._9F5ii{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._OOjwY>._MJORL[data-state=open]+._9F5ii{transform:rotate(-180deg) translateY(50%)}._OOjwY>._MJORL[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._OOjwY>._MJORL[aria-disabled=true]+._9F5ii{fill:#515559;opacity:.4}._eyhD7>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;max-width:350px;min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:var(--mask-z-index)!important;width:var(--mask-width);height:var(--mask-height);transition:height .35s,width .35s}._eyhD7>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._beR38{margin:0;padding:4px 0;background:#fff;transition:margin-left .35s,opacity .35s,height .35s,width .35s;opacity:1;overflow:auto;max-width:350px;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:200px;max-height:350px}._beR38._OGYj7{margin-left:30px;opacity:0}._beR38._fEwts{margin-left:-30px}._36S-T{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._36S-T._qorZv{cursor:unset}._36S-T ._VwLua{fill:#32363a;margin-right:4px}._36S-T:focus,._36S-T:hover:not(._36S-T._qorZv){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._36S-T[aria-disabled=true]{cursor:not-allowed;opacity:.65}._36S-T._rREbu{padding-right:32px}._36S-T._rREbu ._9F5ii{position:absolute;height:100%;right:3px;fill:#515559}._36S-T._7Kqdd{pointer-events:none}._YbkmX{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._YbkmX._owA61{padding-top:49px}._3YM-n{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._ldYt-{position:absolute;background-color:#fff;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;overflow:hidden;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._ldYt-._fEwts{opacity:0}._ldYt-._fEwts>._Cbvl2{margin-left:-30px}._ldYt-._OGYj7{opacity:0}._ldYt-._OGYj7>._Cbvl2{margin-left:30px}._ldYt->._Cbvl2{transition:margin-left .35s;width:100%}._ldYt-._7Kqdd{pointer-events:none}body.keyboard-user ._36S-T:hover:not(:focus){background-color:#fff;box-shadow:none}";
4
- var styles = {"buttonContainer":"_OOjwY","button":"_MJORL","rightIcon":"_9F5ii","maskContainer":"_eyhD7","flyout":"_beR38","animatedRight":"_OGYj7","animatedLeft":"_fEwts","menuItem":"_36S-T","noItems":"_qorZv","backIcon":"_VwLua","subMenu":"_rREbu","unresponsive":"_7Kqdd","stickyBox":"_YbkmX","isSearchable":"_owA61","searchBoxesContainer":"_3YM-n","searchBox":"_ldYt-","searchInput":"_Cbvl2"};
5
- var stylesheet="._OOjwY{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._OOjwY>._MJORL{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._OOjwY>._MJORL:hover:not([aria-disabled=true]){background-color:#f5f5f5}._OOjwY>._MJORL.focus-visible,._OOjwY>._MJORL:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._OOjwY>._MJORL+._9F5ii{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._OOjwY>._MJORL[data-state=open]+._9F5ii{transform:rotate(-180deg) translateY(50%)}._OOjwY>._MJORL[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._OOjwY>._MJORL[aria-disabled=true]+._9F5ii{fill:#515559;opacity:.4}._eyhD7>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;max-width:350px;min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:var(--mask-z-index)!important;width:var(--mask-width);height:var(--mask-height);transition:height .35s,width .35s}._eyhD7>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._beR38{margin:0;padding:4px 0;background:#fff;transition:margin-left .35s,opacity .35s,height .35s,width .35s;opacity:1;overflow:auto;max-width:350px;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:200px;max-height:350px}._beR38._OGYj7{margin-left:30px;opacity:0}._beR38._fEwts{margin-left:-30px}._36S-T{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._36S-T._qorZv{cursor:unset}._36S-T ._VwLua{fill:#32363a;margin-right:4px}._36S-T:focus,._36S-T:hover:not(._36S-T._qorZv){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._36S-T[aria-disabled=true]{cursor:not-allowed;opacity:.65}._36S-T._rREbu{padding-right:32px}._36S-T._rREbu ._9F5ii{position:absolute;height:100%;right:3px;fill:#515559}._36S-T._7Kqdd{pointer-events:none}._YbkmX{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._YbkmX._owA61{padding-top:49px}._3YM-n{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._ldYt-{position:absolute;background-color:#fff;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;overflow:hidden;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._ldYt-._fEwts{opacity:0}._ldYt-._fEwts>._Cbvl2{margin-left:-30px}._ldYt-._OGYj7{opacity:0}._ldYt-._OGYj7>._Cbvl2{margin-left:30px}._ldYt->._Cbvl2{transition:margin-left .35s;width:100%}._ldYt-._7Kqdd{pointer-events:none}body.keyboard-user ._36S-T:hover:not(:focus){background-color:#fff;box-shadow:none}";
3
+ var css_248z = "._qPO2N{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._qPO2N>._LMM7F{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._qPO2N>._LMM7F:hover:not([aria-disabled=true]){background-color:#f5f5f5}._qPO2N>._LMM7F.focus-visible,._qPO2N>._LMM7F:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._qPO2N>._LMM7F+._CybpI{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._qPO2N>._LMM7F[data-state=open]+._CybpI{transform:rotate(-180deg) translateY(50%)}._qPO2N>._LMM7F[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._qPO2N>._LMM7F[aria-disabled=true]+._CybpI{fill:#515559;opacity:.4}._80Rak>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;max-width:350px;min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:var(--mask-z-index)!important;width:var(--mask-width);height:var(--mask-height);transition:height .35s,width .35s}._80Rak>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._xuYn0{margin:0;padding-bottom:var(--flyout-bottom-padding);background:#fff;transition:margin-left .35s,opacity .35s,height .35s,width .35s;opacity:1;max-width:350px;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:200px;max-height:var(--flyout-max-height)}._xuYn0 ._D3UnL{height:100%;overflow-y:scroll}._xuYn0._FSLAc{margin-left:30px;opacity:0}._xuYn0._gJcSW{margin-left:-30px}._RNpnr{position:relative;padding:10px 12px;display:flex;flex-direction:row;min-height:40px;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._RNpnr._pwzGH{cursor:unset}._RNpnr ._-eVgs{fill:#32363a;margin-right:4px}._RNpnr:focus,._RNpnr:hover:not(._RNpnr._pwzGH){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._RNpnr[aria-disabled=true]{cursor:not-allowed;opacity:.65}._RNpnr._-UxmZ{padding-right:32px}._RNpnr._-UxmZ ._CybpI{position:absolute;height:100%;right:3px;fill:#515559}._RNpnr._3kpmb{pointer-events:none}._dIe12{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._dIe12._1NM5g{padding-top:52px}._dHI1G{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._BbWig{position:absolute;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._BbWig._gJcSW{opacity:0}._BbWig._gJcSW>._iVw9p{margin-left:-30px}._BbWig._FSLAc{opacity:0}._BbWig._FSLAc>._iVw9p{margin-left:30px}._BbWig>._iVw9p{transition:margin-left .35s;width:100%}._BbWig._3kpmb{pointer-events:none}body.keyboard-user ._RNpnr:hover:not(:focus){background-color:#fff;box-shadow:none}";
4
+ var styles = {"buttonContainer":"_qPO2N","button":"_LMM7F","rightIcon":"_CybpI","maskContainer":"_80Rak","flyout":"_xuYn0","scrollContainer":"_D3UnL","animatedRight":"_FSLAc","animatedLeft":"_gJcSW","menuItem":"_RNpnr","noItems":"_pwzGH","backIcon":"_-eVgs","subMenu":"_-UxmZ","unresponsive":"_3kpmb","stickyBox":"_dIe12","isSearchable":"_1NM5g","searchBoxesContainer":"_dHI1G","searchBox":"_BbWig","searchInput":"_iVw9p"};
5
+ var stylesheet="._qPO2N{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._qPO2N>._LMM7F{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._qPO2N>._LMM7F:hover:not([aria-disabled=true]){background-color:#f5f5f5}._qPO2N>._LMM7F.focus-visible,._qPO2N>._LMM7F:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._qPO2N>._LMM7F+._CybpI{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._qPO2N>._LMM7F[data-state=open]+._CybpI{transform:rotate(-180deg) translateY(50%)}._qPO2N>._LMM7F[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._qPO2N>._LMM7F[aria-disabled=true]+._CybpI{fill:#515559;opacity:.4}._80Rak>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;max-width:350px;min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:var(--mask-z-index)!important;width:var(--mask-width);height:var(--mask-height);transition:height .35s,width .35s}._80Rak>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._xuYn0{margin:0;padding-bottom:var(--flyout-bottom-padding);background:#fff;transition:margin-left .35s,opacity .35s,height .35s,width .35s;opacity:1;max-width:350px;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:200px;max-height:var(--flyout-max-height)}._xuYn0 ._D3UnL{height:100%;overflow-y:scroll}._xuYn0._FSLAc{margin-left:30px;opacity:0}._xuYn0._gJcSW{margin-left:-30px}._RNpnr{position:relative;padding:10px 12px;display:flex;flex-direction:row;min-height:40px;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._RNpnr._pwzGH{cursor:unset}._RNpnr ._-eVgs{fill:#32363a;margin-right:4px}._RNpnr:focus,._RNpnr:hover:not(._RNpnr._pwzGH){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._RNpnr[aria-disabled=true]{cursor:not-allowed;opacity:.65}._RNpnr._-UxmZ{padding-right:32px}._RNpnr._-UxmZ ._CybpI{position:absolute;height:100%;right:3px;fill:#515559}._RNpnr._3kpmb{pointer-events:none}._dIe12{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._dIe12._1NM5g{padding-top:52px}._dHI1G{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._BbWig{position:absolute;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._BbWig._gJcSW{opacity:0}._BbWig._gJcSW>._iVw9p{margin-left:-30px}._BbWig._FSLAc{opacity:0}._BbWig._FSLAc>._iVw9p{margin-left:30px}._BbWig>._iVw9p{transition:margin-left .35s;width:100%}._BbWig._3kpmb{pointer-events:none}body.keyboard-user ._RNpnr:hover:not(:focus){background-color:#fff;box-shadow:none}";
6
6
  if(typeof process !== 'object' || !process.hasOwnProperty('env') || process.env.NODE_ENV !== 'test'){styleInject(css_248z);}
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -7,6 +7,10 @@ const {
7
7
  useContext: useMenuContext,
8
8
  Provider: MenuContextProvider
9
9
  } = createContextUtilities();
10
+ const {
11
+ useContext: useItemContext,
12
+ Provider: ItemContextProvider
13
+ } = createContextUtilities({});
10
14
  const {
11
15
  useContext: intermediaryUseMenuContext,
12
16
  Provider: IntermediaryMenuContextProvider
@@ -36,4 +40,4 @@ const usePaneContext = childItemRef => {
36
40
  };
37
41
  };
38
42
 
39
- export { MenuContextProvider, PaneContextProvider, useMenuContext, usePaneContext };
43
+ export { ItemContextProvider, MenuContextProvider, PaneContextProvider, useItemContext, useMenuContext, usePaneContext };
@@ -4,7 +4,7 @@ import { Item } from '@radix-ui/react-dropdown-menu';
4
4
  import classNames from 'classnames';
5
5
  import { useFocusVisible } from '@react-aria/interactions';
6
6
  import styles from './Menu2.js';
7
- import { usePaneContext } from './MenuContext.js';
7
+ import { usePaneContext, useItemContext } from './MenuContext.js';
8
8
  import '../../utils/index.js';
9
9
  import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
10
10
  import { DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1, KEYS } from './constants.js';
@@ -28,24 +28,25 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
28
28
  const itemRef = useRef(null);
29
29
  const {
30
30
  dataTestId: menuParentDataTestId,
31
- childIndex: index,
32
- searchValue,
33
- isSearchFilteringDisabled,
31
+ childIndex,
34
32
  isInteractive,
35
33
  closeSubmenu,
36
34
  flyoutRef,
37
- stickyBoxRef
35
+ stickyBoxRef,
36
+ focusVirtualBoundary,
37
+ isVirtualized: paneIsVirtualized,
38
+ maskIsReady
38
39
  } = usePaneContext(itemRef);
40
+ const {
41
+ virtualIndex
42
+ } = useItemContext();
43
+ const index = useMemo(() => virtualIndex !== null && virtualIndex !== void 0 ? virtualIndex : childIndex, [childIndex, virtualIndex]);
39
44
  const {
40
45
  isFocusVisible
41
46
  } = useFocusVisible({
42
47
  isTextInput: true
43
48
  });
44
49
  const dataTestId = getSubDataTestId(menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_ITEM : DATA_TESTID_SUFFIXES$1.MENU_ITEM), String(index));
45
- const isVisible = useMemo(() => {
46
- const searchMatcher = label !== null && label !== void 0 ? label : typeof children === 'string' ? children : undefined;
47
- return isSearchFilteringDisabled || !searchValue || (searchMatcher === null || searchMatcher === void 0 ? void 0 : searchMatcher.toLowerCase().includes(searchValue.toLowerCase()));
48
- }, [children, searchValue, label, isSearchFilteringDisabled]);
49
50
  const handleFocus = () => {
50
51
  if (itemRef.current && flyoutRef.current && isFocusVisible) {
51
52
  var _stickyBoxRef$current, _stickyBoxRef$current2;
@@ -58,7 +59,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
58
59
  }
59
60
  }
60
61
  };
61
- return isVisible ? /*#__PURE__*/React__default.createElement(Item, _extends({}, rest, {
62
+ return /*#__PURE__*/React__default.createElement(Item, _extends({}, rest, {
62
63
  asChild: asChild,
63
64
  "aria-disabled": isDisabled,
64
65
  className: classNames(className, styles.menuItem, {
@@ -72,7 +73,13 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
72
73
  return;
73
74
  }
74
75
  if (KEYS.CLOSE_SUBMENU.includes(e.key)) {
75
- closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
76
+ closeSubmenu === null || closeSubmenu === void 0 || closeSubmenu(e);
77
+ } else if (paneIsVirtualized && KEYS.NAVIGATE_TOP.includes(e.key)) {
78
+ e.preventDefault();
79
+ focusVirtualBoundary('top');
80
+ } else if (paneIsVirtualized && KEYS.NAVIIGATE_BOTTOM.includes(e.key)) {
81
+ e.preventDefault();
82
+ focusVirtualBoundary('bottom');
76
83
  }
77
84
  },
78
85
  onFocus: handleFocus
@@ -80,16 +87,16 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
80
87
  // other pointer and keyboard events still work, even when disabled
81
88
  ,
82
89
  onSelect: e => {
83
- if (isDisabled) {
90
+ if (isDisabled || maskIsReady === false) {
84
91
  e.preventDefault();
85
92
  return;
86
93
  }
87
94
  if (multiselect) {
88
95
  e.preventDefault();
89
96
  }
90
- onSelect === null || onSelect === void 0 ? void 0 : onSelect();
97
+ onSelect === null || onSelect === void 0 || onSelect();
91
98
  }
92
- }), (!children || typeof children === 'string') && label ? label : children) : null;
99
+ }), (!children || typeof children === 'string') && label ? label : children);
93
100
  });
94
101
  var MenuItem$1 = MenuItem;
95
102
 
@@ -1,6 +1,7 @@
1
1
  import _extends from '@babel/runtime-corejs3/helpers/extends';
2
- import React__default, { useState, useRef, useMemo, useEffect } from 'react';
2
+ import React__default, { useState, useRef, useMemo } from 'react';
3
3
  import { Portal, Content } from '@radix-ui/react-dropdown-menu';
4
+ import { useFocusVisible } from '@react-aria/interactions';
4
5
  import classNames from 'classnames';
5
6
  import styles from './Menu2.js';
6
7
  import { usePortalTarget } from '../../components/UIProvider/PortalTargetContext.js';
@@ -9,19 +10,24 @@ import '../../utils/index.js';
9
10
  import { DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from './constants.js';
10
11
  import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
11
12
  import MenuSearch from './MenuSearch.js';
12
- import usePaneSearch from './usePaneSearch.js';
13
+ import usePaneSearch from './Hooks/usePaneSearch.js';
13
14
  import '../../hooks/index.js';
14
- import useMutationObserver from './useMutationObserver.js';
15
+ import useMutationObserver from './Hooks/useMutationObserver.js';
15
16
  import useOverlay from '../../hooks/useOverlay/useOverlay.js';
16
- import useCSSVariable from './useCSSVariable.js';
17
+ import useCSSVariable from './Hooks/useCSSVariable.js';
17
18
  import useSelectContext from '../Select/SelectContext.js';
18
19
  import SelectedItems from '../Select/SelectedItems.js';
19
- import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
20
+ import PaneChildren from './PaneChildren.js';
21
+ import useFocusVirtualBoundary from './Hooks/useFocusVirtualBoundary.js';
22
+ import useIsVirtualized from './Hooks/useIsVirtualized.js';
23
+ import useMaskDimensions from './Hooks/useMaskDimensions.js';
20
24
  import useId from '../../hooks/useId/useId.js';
25
+ import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
26
+ import { useDidUpdate } from '../../hooks/useDidUpdate/useDidUpdate.js';
21
27
  import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
22
28
 
23
29
  const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
24
- var _flyoutRef$current$pa, _flyoutRef$current3, _flyoutRef$current4;
30
+ var _flyoutRef$current$pa, _flyoutRef$current, _flyoutRef$current2;
25
31
  let {
26
32
  placement,
27
33
  children,
@@ -30,7 +36,6 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
30
36
  onSearchValueChange,
31
37
  isSearchFilteringDisabled = false,
32
38
  className,
33
- style,
34
39
  zIndex = 1000,
35
40
  ...rest
36
41
  } = _ref;
@@ -48,56 +53,60 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
48
53
  var _placement$split, _placement$split2;
49
54
  return (_placement$split = placement === null || placement === void 0 || (_placement$split2 = placement.split) === null || _placement$split2 === void 0 ? void 0 : _placement$split2.call(placement, '-')) !== null && _placement$split !== void 0 ? _placement$split : [];
50
55
  }, [placement]);
56
+ const thisPanesDepth = 1;
57
+ const paneMaxHeight = 350;
58
+ const paneBottomPadding = 4;
59
+ const maskContainerId = useId();
60
+ const [transform, setTransform] = useState('');
61
+ const target = (_flyoutRef$current$pa = (_flyoutRef$current = flyoutRef.current) === null || _flyoutRef$current === void 0 ? void 0 : _flyoutRef$current.parentNode) !== null && _flyoutRef$current$pa !== void 0 ? _flyoutRef$current$pa : undefined;
51
62
  const {
52
63
  dataTestId: rootDataTestId,
53
64
  openPaneDepth,
54
- setMaskHeight,
55
65
  maskHeight,
56
66
  open,
57
67
  triggerRef,
58
68
  searchBarConfigs,
59
- setMaskWidth,
60
- maskWidth
69
+ maskWidth,
70
+ isVirtualizationDisabled
61
71
  } = useMenuContext();
62
- const thisPanesDepth = 1;
63
- const maskContainerId = 'maskContainer';
64
- useOverlay({
65
- isVisible: open,
66
- ignoreIds: [maskContainerId],
67
- opacity: 0
68
- });
72
+ const isVirtualized = useIsVirtualized(children, isVirtualizationDisabled);
69
73
  const animatedLeft = useMemo(() => openPaneDepth > thisPanesDepth, [openPaneDepth]);
70
74
  const dataTestId = getSubDataTestId(rootDataTestId, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE);
71
75
  const {
72
- internalSearchValue,
73
76
  noSearchResultsNode,
74
- onInteractOutside
75
- } = usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, false, dataTestId, useId(), flyoutRef, withinSelect);
76
- useEffect(() => {
77
- if (openPaneDepth === thisPanesDepth) {
78
- window.requestAnimationFrame(() => {
79
- var _flyoutRef$current, _flyoutRef$current2;
80
- if ((_flyoutRef$current = flyoutRef.current) !== null && _flyoutRef$current !== void 0 && _flyoutRef$current.clientHeight) {
81
- setMaskHeight(flyoutRef.current.clientHeight);
82
- }
83
- if ((_flyoutRef$current2 = flyoutRef.current) !== null && _flyoutRef$current2 !== void 0 && _flyoutRef$current2.clientWidth) {
84
- setMaskWidth(flyoutRef.current.clientWidth);
85
- }
86
- });
87
- } else if (openPaneDepth === 0) {
88
- setMaskHeight('auto');
89
- setMaskWidth('auto');
77
+ onInteractOutside,
78
+ filteredChildren
79
+ } = usePaneSearch({
80
+ isSearchable,
81
+ externalSearchValue,
82
+ onSearchValueChange,
83
+ items,
84
+ animatedLeft,
85
+ animatedRight: false,
86
+ menuParentDataTestId: dataTestId,
87
+ id: useId(),
88
+ flyoutRef,
89
+ children,
90
+ isSearchFilteringDisabled,
91
+ isVirtualized
92
+ });
93
+ const focusVirtualBoundary = useFocusVirtualBoundary(items);
94
+ const {
95
+ isFocusVisible
96
+ } = useFocusVisible();
97
+ const maskIsReady = useMaskDimensions(flyoutRef.current, animatedLeft, thisPanesDepth, children);
98
+ useDidUpdate(() => {
99
+ if (maskIsReady && isFocusVisible) {
100
+ items[0].element.current.focus();
90
101
  }
91
- }, [openPaneDepth, internalSearchValue, setMaskHeight, setMaskWidth]);
102
+ }, [maskIsReady]);
92
103
  const defaultSide = useMemo(() => {
93
104
  var _triggerRef$current;
94
105
  const rect = triggerRef === null || triggerRef === void 0 || (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getBoundingClientRect();
95
106
  if (!rect) {
96
107
  return 'bottom';
97
108
  }
98
-
99
- // hard coded in Menu.less
100
- let maxHeight = 350;
109
+ let maxHeight = paneMaxHeight;
101
110
  if (flyoutRef.current) {
102
111
  const computedString = window.getComputedStyle(flyoutRef.current).maxHeight.slice(0, -2);
103
112
  if (computedString !== '' && !Number.isNaN(+computedString)) {
@@ -117,8 +126,19 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
117
126
  // including `open` because the trigger location may change between openings
118
127
  // eslint-disable-next-line react-hooks/exhaustive-deps
119
128
  [open, triggerRef]);
120
- const [transform, setTransform] = useState('');
121
- const target = (_flyoutRef$current$pa = (_flyoutRef$current3 = flyoutRef.current) === null || _flyoutRef$current3 === void 0 ? void 0 : _flyoutRef$current3.parentNode) !== null && _flyoutRef$current$pa !== void 0 ? _flyoutRef$current$pa : undefined;
129
+
130
+ // We use the top-level Radix container as a mask. Radix does not expose this container to consumers, except through CSS.
131
+ // These hooks dynamically update the style of that container using CSS variables.
132
+ useCSSVariable('--mask-z-index', String(zIndex), [open]);
133
+ useCSSVariable('--mask-width', "".concat(maskWidth, "px"));
134
+ useCSSVariable('--mask-height', "".concat(maskHeight, "px"));
135
+ useCSSVariable('--flyout-max-height', "".concat(paneMaxHeight, "px"));
136
+ useCSSVariable('--flyout-bottom-padding', "".concat(paneBottomPadding, "px"));
137
+ useOverlay({
138
+ isVisible: open,
139
+ ignoreIds: [maskContainerId],
140
+ opacity: 0
141
+ });
122
142
  useMutationObserver(target, {
123
143
  attributes: true,
124
144
  attributeFilter: ['style']
@@ -126,29 +146,29 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
126
146
  var _style$transform, _style;
127
147
  return setTransform((_style$transform = target === null || target === void 0 || (_style = target.style) === null || _style === void 0 ? void 0 : _style.transform) !== null && _style$transform !== void 0 ? _style$transform : '');
128
148
  });
129
-
130
- // We use the top-level Radix container as a mask. Radix does not expose this container to consumers, except through CSS.
131
- // This hook is dynamically updating the style of that container using a CSS variable.
132
- useCSSVariable('--mask-z-index', String(zIndex), [open]);
133
- useCSSVariable('--mask-width', "".concat(maskWidth, "px"));
134
- useCSSVariable('--mask-height', "".concat(maskHeight, "px"));
135
149
  return /*#__PURE__*/React__default.createElement(PaneContextProvider, {
136
150
  items: items,
137
151
  setItems: setItems,
138
152
  value: {
139
153
  dataTestId,
140
- searchValue: internalSearchValue,
141
- isSearchFilteringDisabled,
142
154
  isInteractive: !animatedLeft,
143
155
  flyoutRef,
144
156
  stickyBoxRef,
145
- zIndex
157
+ zIndex,
158
+ focusVirtualBoundary,
159
+ isVirtualized,
160
+ maskIsReady
146
161
  }
147
162
  }, /*#__PURE__*/React__default.createElement(Portal, {
148
163
  container: portalTarget || undefined
149
164
  }, /*#__PURE__*/React__default.createElement("div", {
150
165
  className: styles.maskContainer,
151
- id: maskContainerId
166
+ id: maskContainerId,
167
+ style: {
168
+ // virtuoso and radix both do funny things with window.requestAnimationFrame that cause unpredictable resizing.
169
+ // this causes jitters. We need to wait until it's done resizing.
170
+ opacity: maskIsReady ? 1 : 0
171
+ }
152
172
  }, /*#__PURE__*/React__default.createElement(Content, _extends({}, rest, {
153
173
  onCloseAutoFocus: () => {
154
174
  var _triggerRef$current2;
@@ -163,8 +183,7 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
163
183
  className: classNames(className, {
164
184
  [styles.animatedLeft]: animatedLeft
165
185
  }, styles.flyout),
166
- onInteractOutside: onInteractOutside,
167
- style: style
186
+ onInteractOutside: onInteractOutside
168
187
  }), (isSearchable || multiselect && showSelectedItemsPane) && /*#__PURE__*/React__default.createElement("div", {
169
188
  className: classNames(styles.stickyBox, {
170
189
  [styles.isSearchable]: isSearchable
@@ -173,12 +192,12 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
173
192
  style: {
174
193
  zIndex
175
194
  }
176
- }, showSelectedItemsPane && multiselect && /*#__PURE__*/React__default.createElement(SelectedItems, null)), noSearchResultsNode, children), /*#__PURE__*/React__default.createElement("div", {
195
+ }, showSelectedItemsPane && multiselect && /*#__PURE__*/React__default.createElement(SelectedItems, null)), noSearchResultsNode, /*#__PURE__*/React__default.createElement(PaneChildren, null, filteredChildren)), /*#__PURE__*/React__default.createElement("div", {
177
196
  className: styles.searchBoxesContainer,
178
197
  style: {
179
198
  transform,
180
199
  zIndex: zIndex + openPaneDepth,
181
- width: (_flyoutRef$current4 = flyoutRef.current) === null || _flyoutRef$current4 === void 0 ? void 0 : _flyoutRef$current4.clientWidth
200
+ width: (_flyoutRef$current2 = flyoutRef.current) === null || _flyoutRef$current2 === void 0 ? void 0 : _flyoutRef$current2.clientWidth
182
201
  }
183
202
  }, searchBarConfigs.length ? searchBarConfigs.map(_ref2 => {
184
203
  let {
@@ -0,0 +1,47 @@
1
+ import React__default, { useRef } from 'react';
2
+ import { Virtuoso } from 'react-virtuoso';
3
+ import { useMenuContext, usePaneContext, ItemContextProvider } from './MenuContext.js';
4
+ import styles from './Menu2.js';
5
+ import useSelectContext from '../Select/SelectContext.js';
6
+
7
+ const PaneChildren = _ref => {
8
+ var _useSelectContext, _containerRef$current, _containerRef$current2;
9
+ let {
10
+ children
11
+ } = _ref;
12
+ const {
13
+ virtuoso
14
+ } = useMenuContext();
15
+ const {
16
+ multiselect,
17
+ showSelectedItemsPane
18
+ } = (_useSelectContext = useSelectContext(true)) !== null && _useSelectContext !== void 0 ? _useSelectContext : {};
19
+ const {
20
+ closeSubmenu: containedWithinSubpane,
21
+ isVirtualized
22
+ } = usePaneContext();
23
+ const containerRef = useRef(null);
24
+ return /*#__PURE__*/React__default.createElement("div", {
25
+ ref: containerRef,
26
+ className: styles.scrollContainer,
27
+ style: {
28
+ maxHeight: "calc(var(--flyout-max-height) -\n ".concat((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetTop, "px -\n var(--flyout-bottom-padding))")
29
+ }
30
+ }, isVirtualized ? /*#__PURE__*/React__default.createElement(Virtuoso, {
31
+ ref: virtuoso,
32
+ increaseViewportBy: 250,
33
+ customScrollParent: (_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 ? _containerRef$current2 : undefined,
34
+ data: Array.isArray(children) ? children : [children],
35
+ itemContent: (index, child) => ! /*#__PURE__*/React__default.isValidElement(child) ? null : /*#__PURE__*/React__default.createElement(ItemContextProvider, {
36
+ value: {
37
+ virtualIndex: index + (multiselect && showSelectedItemsPane && !containedWithinSubpane ? 1 : 0)
38
+ }
39
+ }, child)
40
+ }) : /*#__PURE__*/React__default.createElement(ItemContextProvider, {
41
+ value: {
42
+ virtualIndex: undefined
43
+ }
44
+ }, children));
45
+ };
46
+
47
+ export { PaneChildren as default };