@qualtrics/ui-react 2.25.0 → 2.26.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.
- package/CHANGELOG.md +8 -0
- package/dist/__shared/cjs/{index-5b3b3406.js → index-ae6df097.js} +3 -3
- package/dist/__shared/cjs/{index-610a1e02.js → index-dc6f69ac.js} +262 -256
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button2.js +1 -1
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/Alpha.js +1 -1
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/Hue.js +1 -1
- package/dist/components/ColorPicker/Palette.js +1 -1
- package/dist/components/ColorPicker/Saturation.js +1 -1
- package/dist/components/Combobox/Combobox.js +3 -3
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxIcon.js +1 -1
- package/dist/components/Combobox/ComboboxInput.js +1 -1
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown.js +4 -4
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +6 -6
- package/dist/components/Dropdown/DropdownList.js +1 -1
- package/dist/components/Dropdown/DropdownOption.js +2 -2
- package/dist/components/Dropdown/DropdownSearch.js +2 -2
- package/dist/components/FilePicker/FilePicker.js +2 -2
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FormField/FormFieldContext.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover.js +2 -2
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput.js +7 -7
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/Input/InputField.js +2 -2
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/LogicEditor.js +1 -1
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal.js +6 -6
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +3 -3
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -2
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +3 -3
- package/dist/components/NumberStepper/NumberStepper.js +2 -2
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/NumberStepper/NumberStepperDecrement.js +1 -1
- package/dist/components/NumberStepper/NumberStepperIncrement.js +1 -1
- package/dist/components/NumberStepper/NumberStepperInput.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination.js +1 -1
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +3 -3
- package/dist/components/Pagination/PaginationPageInput.js +8 -8
- package/dist/components/Pagination/PaginationPreviousButton.js +3 -3
- package/dist/components/Popover/Popover.js +5 -5
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/QuickSearch/QuickSearchInput.js +4 -4
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput.js +2 -2
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav.js +1 -1
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/Alpha.js +2 -2
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +1 -1
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_ColorPicker/HexInput.js +1 -1
- package/dist/components/deprecated_ColorPicker/Hue.js +2 -2
- package/dist/components/deprecated_ColorPicker/Saturation.js +2 -2
- package/dist/components/deprecated_ColorPicker/Swatch.js +1 -1
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +1 -1
- package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +1 -1
- package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/components/deprecated_Toolbar/ToolbarPanels.js +1 -1
- package/dist/components/deprecated_Toolbar/ToolbarTab.js +5 -5
- package/dist/components/deprecated_Toolbar/ToolbarTabs.js +3 -3
- package/dist/hooks/useControllableState/useControllableState.js +1 -1
- package/dist/hooks/useOverlay/useOverlay.js +2 -2
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +1 -1
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.es.js +1 -1
- package/dist/index.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTable.js +8 -6
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableCell.js +4 -4
- package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +2 -2
- package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox.js +2 -0
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxInput.js +2 -0
- package/dist/next/Combobox/ComboboxOption.js +2 -0
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
- package/dist/next/Drawer/Drawer.js +2 -2
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor.js +2 -2
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Hooks/useFocusVirtualBoundary.js +41 -0
- package/dist/next/Menu/Hooks/useIsVirtualized.js +8 -0
- package/dist/next/Menu/Hooks/useMaskDimensions.js +59 -0
- package/dist/next/Menu/{useMutationObserver.js → Hooks/useMutationObserver.js} +1 -1
- package/dist/next/Menu/{usePaneSearch.js → Hooks/usePaneSearch.js} +61 -24
- package/dist/next/Menu/Menu.js +19 -24
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuContext.js +5 -1
- package/dist/next/Menu/MenuItem.js +21 -14
- package/dist/next/Menu/MenuPane.js +73 -54
- package/dist/next/Menu/PaneChildren.js +47 -0
- package/dist/next/Menu/SubMenu.js +57 -39
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select.js +10 -6
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/Select/SubSelect.js +2 -2
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/TimePicker/TimePickerIcon.js +1 -1
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +17 -3
- package/dist/next/index.js +424 -212
- package/dist/translations-en.js +7 -1
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/Popper/Popper.js +2 -2
- package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -1
- package/dist/utils/wrapEvent/wrapEvent.js +1 -1
- package/icons/package.json +2 -0
- package/next/package.json +3 -1
- package/package.json +4 -2
- /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 '
|
|
4
|
-
import '
|
|
5
|
-
import { useMenuContext } from '
|
|
6
|
-
import { KEYS, DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from '
|
|
7
|
-
import { DATA_TESTID_SUFFIXES } from '
|
|
8
|
-
import styles from '
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
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(
|
|
18
|
+
function usePaneSearch(_ref) {
|
|
17
19
|
var _searchRef$current$qu, _searchRef$current;
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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
|
|
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 ===
|
|
43
|
-
searchInput === null || searchInput === void 0
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
package/dist/next/Menu/Menu.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React__default, {
|
|
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) {
|
package/dist/next/Menu/Menu2.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".
|
|
4
|
-
var styles = {"buttonContainer":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._P-1qk{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._P-1qk>._avlWI{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}._P-1qk>._avlWI:hover:not([aria-disabled=true]){background-color:#f5f5f5}._P-1qk>._avlWI.focus-visible,._P-1qk>._avlWI:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._P-1qk>._avlWI+._08qYC{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._P-1qk>._avlWI[data-state=open]+._08qYC{transform:rotate(-180deg) translateY(50%)}._P-1qk>._avlWI[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._P-1qk>._avlWI[aria-disabled=true]+._08qYC{fill:#515559;opacity:.4}._gZOPA>[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}._gZOPA>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._-nrnj{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)}._-nrnj ._sDfyk{height:100%;overflow-y:scroll}._-nrnj._zgTUU{margin-left:30px;opacity:0}._-nrnj._lOy6Z{margin-left:-30px}._TTaMv{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%}._TTaMv._cWSdL{cursor:unset}._TTaMv ._5244S{fill:#32363a;margin-right:4px}._TTaMv:focus,._TTaMv:hover:not(._TTaMv._cWSdL){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._TTaMv[aria-disabled=true]{cursor:not-allowed;opacity:.65}._TTaMv._al2zZ{padding-right:32px}._TTaMv._al2zZ ._08qYC{position:absolute;height:100%;right:3px;fill:#515559}._TTaMv._GIP-N{pointer-events:none}._5WkZQ{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._5WkZQ._eQooQ{padding-top:52px}._uUO-O{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._wQQjr{position:absolute;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._wQQjr._lOy6Z{opacity:0}._wQQjr._lOy6Z>._9og9E{margin-left:-30px}._wQQjr._zgTUU{opacity:0}._wQQjr._zgTUU>._9og9E{margin-left:30px}._wQQjr>._9og9E{transition:margin-left .35s;width:100%}._wQQjr._GIP-N{pointer-events:none}body.keyboard-user ._TTaMv:hover:not(:focus){background-color:#fff;box-shadow:none}";
|
|
4
|
+
var styles = {"buttonContainer":"_P-1qk","button":"_avlWI","rightIcon":"_08qYC","maskContainer":"_gZOPA","flyout":"_-nrnj","scrollContainer":"_sDfyk","animatedRight":"_zgTUU","animatedLeft":"_lOy6Z","menuItem":"_TTaMv","noItems":"_cWSdL","backIcon":"_5244S","subMenu":"_al2zZ","unresponsive":"_GIP-N","stickyBox":"_5WkZQ","isSearchable":"_eQooQ","searchBoxesContainer":"_uUO-O","searchBox":"_wQQjr","searchInput":"_9og9E"};
|
|
5
|
+
var stylesheet="._P-1qk{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._P-1qk>._avlWI{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}._P-1qk>._avlWI:hover:not([aria-disabled=true]){background-color:#f5f5f5}._P-1qk>._avlWI.focus-visible,._P-1qk>._avlWI:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._P-1qk>._avlWI+._08qYC{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._P-1qk>._avlWI[data-state=open]+._08qYC{transform:rotate(-180deg) translateY(50%)}._P-1qk>._avlWI[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._P-1qk>._avlWI[aria-disabled=true]+._08qYC{fill:#515559;opacity:.4}._gZOPA>[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}._gZOPA>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._-nrnj{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)}._-nrnj ._sDfyk{height:100%;overflow-y:scroll}._-nrnj._zgTUU{margin-left:30px;opacity:0}._-nrnj._lOy6Z{margin-left:-30px}._TTaMv{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%}._TTaMv._cWSdL{cursor:unset}._TTaMv ._5244S{fill:#32363a;margin-right:4px}._TTaMv:focus,._TTaMv:hover:not(._TTaMv._cWSdL){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._TTaMv[aria-disabled=true]{cursor:not-allowed;opacity:.65}._TTaMv._al2zZ{padding-right:32px}._TTaMv._al2zZ ._08qYC{position:absolute;height:100%;right:3px;fill:#515559}._TTaMv._GIP-N{pointer-events:none}._5WkZQ{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._5WkZQ._eQooQ{padding-top:52px}._uUO-O{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._wQQjr{position:absolute;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._wQQjr._lOy6Z{opacity:0}._wQQjr._lOy6Z>._9og9E{margin-left:-30px}._wQQjr._zgTUU{opacity:0}._wQQjr._zgTUU>._9og9E{margin-left:30px}._wQQjr>._9og9E{transition:margin-left .35s;width:100%}._wQQjr._GIP-N{pointer-events:none}body.keyboard-user ._TTaMv: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
|
|
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
|
|
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
|
|
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
|
|
97
|
+
onSelect === null || onSelect === void 0 || onSelect();
|
|
91
98
|
}
|
|
92
|
-
}), (!children || typeof children === 'string') && label ? label : children)
|
|
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
|
|
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
|
|
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$
|
|
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
|
-
|
|
60
|
-
|
|
69
|
+
maskWidth,
|
|
70
|
+
isVirtualizationDisabled
|
|
61
71
|
} = useMenuContext();
|
|
62
|
-
const
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
}, [
|
|
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
|
-
|
|
121
|
-
|
|
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,
|
|
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$
|
|
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 };
|