@mui/material 9.0.0-alpha.4 → 9.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion/Accordion.d.mts +1 -1
- package/Accordion/Accordion.d.ts +1 -1
- package/AccordionSummary/AccordionSummary.js +1 -0
- package/AccordionSummary/AccordionSummary.mjs +1 -0
- package/Backdrop/Backdrop.d.mts +1 -1
- package/Backdrop/Backdrop.d.ts +1 -1
- package/BottomNavigationAction/BottomNavigationAction.js +1 -0
- package/BottomNavigationAction/BottomNavigationAction.mjs +1 -0
- package/Breadcrumbs/BreadcrumbCollapsed.js +5 -1
- package/Breadcrumbs/BreadcrumbCollapsed.mjs +5 -1
- package/Button/Button.js +1 -0
- package/Button/Button.mjs +1 -0
- package/ButtonBase/ButtonBase.d.mts +5 -0
- package/ButtonBase/ButtonBase.d.ts +5 -0
- package/ButtonBase/ButtonBase.js +84 -85
- package/ButtonBase/ButtonBase.mjs +84 -85
- package/ButtonBase/useButtonBase.d.mts +91 -0
- package/ButtonBase/useButtonBase.d.ts +91 -0
- package/ButtonBase/useButtonBase.js +174 -0
- package/ButtonBase/useButtonBase.mjs +167 -0
- package/ButtonGroup/ButtonGroup.js +1 -9
- package/ButtonGroup/ButtonGroup.mjs +1 -9
- package/ButtonGroup/buttonGroupClasses.d.mts +0 -68
- package/ButtonGroup/buttonGroupClasses.d.ts +0 -68
- package/ButtonGroup/buttonGroupClasses.js +1 -1
- package/ButtonGroup/buttonGroupClasses.mjs +1 -1
- package/CHANGELOG.md +119 -4
- package/CardActionArea/CardActionArea.js +1 -0
- package/CardActionArea/CardActionArea.mjs +1 -0
- package/CardHeader/CardHeader.d.mts +13 -21
- package/CardHeader/CardHeader.d.ts +13 -21
- package/CardHeader/CardHeader.js +3 -21
- package/CardHeader/CardHeader.mjs +3 -21
- package/Checkbox/Checkbox.js +1 -7
- package/Checkbox/Checkbox.mjs +1 -7
- package/Chip/Chip.d.mts +7 -0
- package/Chip/Chip.d.ts +7 -0
- package/Chip/Chip.js +66 -55
- package/Chip/Chip.mjs +66 -55
- package/Chip/chipClasses.d.mts +0 -104
- package/Chip/chipClasses.d.ts +0 -104
- package/Chip/chipClasses.js +1 -1
- package/Chip/chipClasses.mjs +1 -1
- package/Dialog/Dialog.d.mts +8 -22
- package/Dialog/Dialog.d.ts +8 -22
- package/Dialog/Dialog.js +43 -72
- package/Dialog/Dialog.mjs +43 -72
- package/Dialog/dialogClasses.d.mts +0 -8
- package/Dialog/dialogClasses.d.ts +0 -8
- package/Dialog/dialogClasses.js +1 -1
- package/Dialog/dialogClasses.mjs +1 -1
- package/Divider/Divider.js +2 -10
- package/Divider/Divider.mjs +2 -10
- package/Divider/dividerClasses.d.mts +0 -4
- package/Divider/dividerClasses.d.ts +0 -4
- package/Divider/dividerClasses.js +1 -1
- package/Divider/dividerClasses.mjs +1 -1
- package/Drawer/Drawer.d.mts +1 -13
- package/Drawer/Drawer.d.ts +1 -13
- package/Drawer/Drawer.js +6 -40
- package/Drawer/Drawer.mjs +6 -40
- package/Drawer/drawerClasses.d.mts +0 -32
- package/Drawer/drawerClasses.d.ts +0 -32
- package/Drawer/drawerClasses.js +1 -1
- package/Drawer/drawerClasses.mjs +1 -1
- package/Fab/Fab.js +1 -0
- package/Fab/Fab.mjs +1 -0
- package/FilledInput/FilledInput.js +4 -33
- package/FilledInput/FilledInput.mjs +4 -33
- package/Grid/Grid.d.mts +8 -3
- package/Grid/Grid.d.ts +8 -3
- package/Grid/Grid.js +8 -3
- package/Grid/Grid.mjs +8 -3
- package/Grid/gridClasses.js +1 -1
- package/Grid/gridClasses.mjs +1 -1
- package/IconButton/IconButton.js +1 -0
- package/IconButton/IconButton.mjs +1 -0
- package/ImageListItemBar/ImageListItemBar.js +4 -17
- package/ImageListItemBar/ImageListItemBar.mjs +4 -17
- package/ImageListItemBar/imageListItemBarClasses.d.mts +0 -16
- package/ImageListItemBar/imageListItemBarClasses.d.ts +0 -16
- package/ImageListItemBar/imageListItemBarClasses.js +1 -1
- package/ImageListItemBar/imageListItemBarClasses.mjs +1 -1
- package/Input/Input.js +4 -33
- package/Input/Input.mjs +4 -33
- package/Input/inputClasses.d.mts +0 -16
- package/Input/inputClasses.d.ts +0 -16
- package/InputAdornment/inputAdornmentClasses.d.mts +2 -2
- package/InputAdornment/inputAdornmentClasses.d.ts +2 -2
- package/InputBase/InputBase.d.mts +0 -27
- package/InputBase/InputBase.d.ts +0 -27
- package/InputBase/InputBase.js +6 -35
- package/InputBase/InputBase.mjs +6 -35
- package/InputBase/inputBaseClasses.d.mts +0 -20
- package/InputBase/inputBaseClasses.d.ts +0 -20
- package/InputBase/inputBaseClasses.js +1 -1
- package/InputBase/inputBaseClasses.mjs +1 -1
- package/InputLabel/InputLabel.js +1 -1
- package/InputLabel/InputLabel.mjs +1 -1
- package/LinearProgress/LinearProgress.js +6 -18
- package/LinearProgress/LinearProgress.mjs +6 -18
- package/LinearProgress/linearProgressClasses.d.mts +0 -36
- package/LinearProgress/linearProgressClasses.d.ts +0 -36
- package/LinearProgress/linearProgressClasses.js +1 -1
- package/LinearProgress/linearProgressClasses.mjs +1 -1
- package/Link/Link.d.mts +1 -1
- package/Link/Link.d.ts +1 -1
- package/ListItem/ListItem.d.mts +2 -36
- package/ListItem/ListItem.d.ts +2 -36
- package/ListItem/ListItem.js +27 -152
- package/ListItem/ListItem.mjs +27 -152
- package/ListItem/listItemClasses.d.mts +2 -4
- package/ListItem/listItemClasses.d.ts +2 -4
- package/ListItem/listItemClasses.js +1 -1
- package/ListItem/listItemClasses.mjs +1 -1
- package/ListItemButton/ListItemButton.d.mts +1 -2
- package/ListItemButton/ListItemButton.d.ts +1 -2
- package/ListItemButton/ListItemButton.js +2 -2
- package/ListItemButton/ListItemButton.mjs +2 -2
- package/ListItemIcon/ListItemIcon.js +1 -1
- package/ListItemIcon/ListItemIcon.mjs +1 -1
- package/ListItemSecondaryAction/ListItemSecondaryAction.d.mts +10 -6
- package/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +10 -6
- package/ListItemSecondaryAction/ListItemSecondaryAction.js +7 -2
- package/ListItemSecondaryAction/ListItemSecondaryAction.mjs +7 -2
- package/ListItemText/ListItemText.d.mts +12 -20
- package/ListItemText/ListItemText.d.ts +12 -20
- package/ListItemText/ListItemText.js +2 -20
- package/ListItemText/ListItemText.mjs +2 -20
- package/ListSubheader/ListSubheader.js +0 -3
- package/ListSubheader/ListSubheader.mjs +0 -3
- package/Menu/Menu.d.mts +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/Menu/Menu.js +15 -32
- package/Menu/Menu.mjs +15 -32
- package/MenuItem/MenuItem.js +36 -26
- package/MenuItem/MenuItem.mjs +34 -26
- package/MenuList/MenuList.js +136 -101
- package/MenuList/MenuList.mjs +135 -100
- package/MenuList/MenuListContext.d.mts +11 -0
- package/MenuList/MenuListContext.d.ts +11 -0
- package/MenuList/MenuListContext.js +25 -0
- package/MenuList/MenuListContext.mjs +19 -0
- package/Modal/Modal.d.mts +1 -41
- package/Modal/Modal.d.ts +1 -41
- package/Modal/Modal.js +5 -58
- package/Modal/Modal.mjs +5 -58
- package/OutlinedInput/OutlinedInput.js +2 -14
- package/OutlinedInput/OutlinedInput.mjs +2 -14
- package/OutlinedInput/outlinedInputClasses.d.mts +0 -16
- package/OutlinedInput/outlinedInputClasses.d.ts +0 -16
- package/PaginationItem/PaginationItem.d.mts +5 -15
- package/PaginationItem/PaginationItem.d.ts +5 -15
- package/PaginationItem/PaginationItem.js +9 -24
- package/PaginationItem/PaginationItem.mjs +9 -24
- package/PaginationItem/paginationItemClasses.d.mts +0 -16
- package/PaginationItem/paginationItemClasses.d.ts +0 -16
- package/PaginationItem/paginationItemClasses.js +1 -1
- package/PaginationItem/paginationItemClasses.mjs +1 -1
- package/PigmentGrid/PigmentGrid.d.mts +1 -1
- package/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/PigmentGrid/PigmentGrid.js +1 -1
- package/PigmentGrid/PigmentGrid.mjs +1 -1
- package/Popover/Popover.d.mts +1 -1
- package/Popover/Popover.d.ts +1 -1
- package/Popover/Popover.js +19 -7
- package/Popover/Popover.mjs +18 -6
- package/Radio/Radio.js +1 -13
- package/Radio/Radio.mjs +1 -13
- package/Rating/Rating.d.mts +0 -9
- package/Rating/Rating.d.ts +0 -9
- package/Rating/Rating.js +1 -17
- package/Rating/Rating.mjs +1 -17
- package/Select/SelectInput.js +2 -3
- package/Select/SelectInput.mjs +2 -3
- package/Select/selectClasses.d.mts +0 -12
- package/Select/selectClasses.d.ts +0 -12
- package/Select/selectClasses.js +1 -1
- package/Select/selectClasses.mjs +1 -1
- package/Slider/Slider.d.mts +0 -5
- package/Slider/Slider.d.ts +0 -5
- package/Slider/Slider.js +2 -8
- package/Slider/Slider.mjs +2 -8
- package/Slider/sliderClasses.d.mts +0 -28
- package/Slider/sliderClasses.d.ts +0 -28
- package/Slider/sliderClasses.js +1 -1
- package/Slider/sliderClasses.mjs +1 -1
- package/Snackbar/Snackbar.d.mts +1 -1
- package/Snackbar/Snackbar.d.ts +1 -1
- package/SpeedDial/SpeedDial.d.mts +1 -1
- package/SpeedDial/SpeedDial.d.ts +1 -1
- package/Stack/Stack.d.mts +2 -2
- package/Stack/Stack.d.ts +2 -2
- package/StepButton/StepButton.js +44 -14
- package/StepButton/StepButton.mjs +44 -14
- package/StepConnector/StepConnector.js +2 -8
- package/StepConnector/StepConnector.mjs +2 -8
- package/StepConnector/stepConnectorClasses.d.mts +0 -8
- package/StepConnector/stepConnectorClasses.d.ts +0 -8
- package/StepConnector/stepConnectorClasses.js +1 -1
- package/StepConnector/stepConnectorClasses.mjs +1 -1
- package/StepContent/StepContent.d.mts +2 -17
- package/StepContent/StepContent.d.ts +2 -17
- package/StepContent/StepContent.js +3 -22
- package/StepContent/StepContent.mjs +3 -22
- package/StepLabel/StepLabel.d.mts +0 -22
- package/StepLabel/StepLabel.d.ts +0 -22
- package/StepLabel/StepLabel.js +2 -31
- package/StepLabel/StepLabel.mjs +2 -31
- package/Stepper/Stepper.js +54 -22
- package/Stepper/Stepper.mjs +54 -22
- package/Stepper/StepperContext.d.mts +0 -5
- package/Stepper/StepperContext.d.ts +0 -5
- package/Stepper/StepperContext.js +1 -2
- package/Stepper/StepperContext.mjs +0 -1
- package/SvgIcon/createSvgIcon.d.mts +2 -0
- package/SvgIcon/createSvgIcon.d.ts +2 -0
- package/SvgIcon/createSvgIcon.js +31 -0
- package/SvgIcon/createSvgIcon.mjs +26 -0
- package/SvgIcon/index.d.mts +1 -0
- package/SvgIcon/index.d.ts +1 -0
- package/SvgIcon/index.js +8 -0
- package/SvgIcon/index.mjs +1 -0
- package/SwipeableDrawer/SwipeableDrawer.d.mts +0 -5
- package/SwipeableDrawer/SwipeableDrawer.d.ts +0 -5
- package/SwipeableDrawer/SwipeableDrawer.js +6 -37
- package/SwipeableDrawer/SwipeableDrawer.mjs +6 -37
- package/Switch/Switch.js +0 -11
- package/Switch/Switch.mjs +0 -11
- package/Tab/Tab.js +18 -4
- package/Tab/Tab.mjs +18 -4
- package/Tab/tabClasses.d.mts +0 -4
- package/Tab/tabClasses.d.ts +0 -4
- package/Tab/tabClasses.js +1 -1
- package/Tab/tabClasses.mjs +1 -1
- package/TabScrollButton/TabScrollButton.d.mts +1 -1
- package/TabScrollButton/TabScrollButton.d.ts +1 -1
- package/TabScrollButton/TabScrollButton.js +6 -2
- package/TabScrollButton/TabScrollButton.mjs +6 -2
- package/TablePagination/TablePagination.d.mts +0 -24
- package/TablePagination/TablePagination.d.ts +0 -24
- package/TablePagination/TablePagination.js +1 -29
- package/TablePagination/TablePagination.mjs +1 -29
- package/TablePaginationActions/TablePaginationActions.d.mts +0 -10
- package/TablePaginationActions/TablePaginationActions.d.ts +0 -10
- package/TablePaginationActions/TablePaginationActions.js +2 -14
- package/TablePaginationActions/TablePaginationActions.mjs +2 -14
- package/TableSortLabel/TableSortLabel.js +6 -8
- package/TableSortLabel/TableSortLabel.mjs +6 -8
- package/TableSortLabel/tableSortLabelClasses.d.mts +0 -8
- package/TableSortLabel/tableSortLabelClasses.d.ts +0 -8
- package/TableSortLabel/tableSortLabelClasses.js +1 -1
- package/TableSortLabel/tableSortLabelClasses.mjs +1 -1
- package/Tabs/Tabs.js +33 -24
- package/Tabs/Tabs.mjs +32 -23
- package/Tabs/tabsClasses.d.mts +0 -6
- package/Tabs/tabsClasses.d.ts +0 -6
- package/Tabs/tabsClasses.js +1 -1
- package/Tabs/tabsClasses.mjs +1 -1
- package/ToggleButton/ToggleButton.js +1 -0
- package/ToggleButton/ToggleButton.mjs +1 -0
- package/ToggleButtonGroup/ToggleButtonGroup.js +1 -4
- package/ToggleButtonGroup/ToggleButtonGroup.mjs +1 -4
- package/ToggleButtonGroup/toggleButtonGroupClasses.d.mts +0 -8
- package/ToggleButtonGroup/toggleButtonGroupClasses.d.ts +0 -8
- package/ToggleButtonGroup/toggleButtonGroupClasses.js +1 -1
- package/ToggleButtonGroup/toggleButtonGroupClasses.mjs +1 -1
- package/Tooltip/Tooltip.d.mts +1 -1
- package/Tooltip/Tooltip.d.ts +1 -1
- package/Typography/Typography.d.mts +3 -3
- package/Typography/Typography.d.ts +3 -3
- package/Typography/Typography.js +2 -24
- package/Typography/Typography.mjs +3 -25
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internal/SwitchBase.d.mts +2 -12
- package/internal/SwitchBase.d.ts +2 -12
- package/internal/SwitchBase.js +6 -17
- package/internal/SwitchBase.mjs +6 -17
- package/locale/psAF.js +1 -1
- package/locale/psAF.mjs +1 -1
- package/package.json +7 -7
- package/styles/createThemeWithVars.js +10 -9
- package/styles/createThemeWithVars.mjs +10 -9
- package/styles/stringifyTheme.js +1 -1
- package/styles/stringifyTheme.mjs +1 -1
- package/useAutocomplete/useAutocomplete.js +8 -0
- package/useAutocomplete/useAutocomplete.mjs +8 -0
- package/utils/createSvgIcon.d.mts +4 -2
- package/utils/createSvgIcon.d.ts +4 -2
- package/utils/createSvgIcon.js +6 -24
- package/utils/createSvgIcon.mjs +2 -24
- package/utils/focusWithVisible.js +24 -0
- package/utils/focusWithVisible.mjs +19 -0
- package/utils/index.d.mts +0 -1
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -7
- package/utils/index.mjs +0 -1
- package/utils/useFocusableWhenDisabled.d.mts +30 -0
- package/utils/useFocusableWhenDisabled.d.ts +30 -0
- package/utils/useFocusableWhenDisabled.js +47 -0
- package/utils/useFocusableWhenDisabled.mjs +41 -0
- package/utils/useRovingTabIndex.d.mts +1 -2
- package/utils/useRovingTabIndex.d.ts +1 -2
- package/utils/useRovingTabIndex.js +25 -4
- package/utils/useRovingTabIndex.mjs +1 -2
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
package/MenuItem/MenuItem.js
CHANGED
|
@@ -18,30 +18,17 @@ var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
|
18
18
|
var _ListContext = _interopRequireDefault(require("../List/ListContext"));
|
|
19
19
|
var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
|
20
20
|
var _useEnhancedEffect = _interopRequireDefault(require("../utils/useEnhancedEffect"));
|
|
21
|
+
var _focusWithVisible = _interopRequireDefault(require("../utils/focusWithVisible"));
|
|
21
22
|
var _useForkRef = _interopRequireDefault(require("../utils/useForkRef"));
|
|
23
|
+
var _useId = _interopRequireDefault(require("../utils/useId"));
|
|
24
|
+
var _useRovingTabIndex = require("../utils/useRovingTabIndex");
|
|
22
25
|
var _Divider = require("../Divider");
|
|
23
26
|
var _ListItemIcon = require("../ListItemIcon");
|
|
24
27
|
var _ListItemText = require("../ListItemText");
|
|
28
|
+
var _MenuListContext = require("../MenuList/MenuListContext");
|
|
29
|
+
var _utils = require("../Select/utils");
|
|
25
30
|
var _menuItemClasses = _interopRequireWildcard(require("./menuItemClasses"));
|
|
26
|
-
var _Select = require("../Select");
|
|
27
31
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
/**
|
|
29
|
-
* If autoFocus is an object, it will attempt to call `element.focus()` with the options argument.
|
|
30
|
-
* If the browser doesn't support the options argument, it will fall back to a simple `element.focus()` call.
|
|
31
|
-
*/function focusWithVisible(element, focusSource) {
|
|
32
|
-
if (focusSource == null) {
|
|
33
|
-
element.focus();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
element.focus({
|
|
38
|
-
focusVisible: focusSource === 'keyboard'
|
|
39
|
-
});
|
|
40
|
-
} catch (error) {
|
|
41
|
-
// If the browser doesn't support the focus options argument, fall back to a simple focus call.
|
|
42
|
-
element.focus();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
32
|
const overridesResolver = (props, styles) => {
|
|
46
33
|
const {
|
|
47
34
|
ownerState
|
|
@@ -177,7 +164,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
177
164
|
name: 'MuiMenuItem'
|
|
178
165
|
});
|
|
179
166
|
const {
|
|
180
|
-
autoFocus = false,
|
|
167
|
+
autoFocus: shouldAutoFocusOnMount = false,
|
|
181
168
|
component = 'li',
|
|
182
169
|
dense = false,
|
|
183
170
|
divider = false,
|
|
@@ -188,23 +175,30 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
188
175
|
className,
|
|
189
176
|
...other
|
|
190
177
|
} = props;
|
|
191
|
-
const focusSource = (0,
|
|
178
|
+
const focusSource = (0, _utils.useSelectFocusSource)();
|
|
192
179
|
const context = React.useContext(_ListContext.default);
|
|
193
180
|
const childContext = React.useMemo(() => ({
|
|
194
181
|
dense: dense || context.dense || false,
|
|
195
182
|
disableGutters
|
|
196
183
|
}), [context.dense, dense, disableGutters]);
|
|
184
|
+
const menuListContext = (0, _MenuListContext.useMenuListContext)();
|
|
185
|
+
const rovingItemId = (0, _useId.default)();
|
|
186
|
+
// Escape hatch via ButtonBase for when an anchored <Menu> is opened with a pointer
|
|
187
|
+
// interaction on a trigger, the item should receive DOM focus but without focus visible
|
|
188
|
+
// styling. Current API does not allow a reliable `openInteractionType` for anchored menus.
|
|
189
|
+
const suppressFocusVisible = menuListContext.suppressInitialFocusVisible;
|
|
190
|
+
const itemsFocusableWhenDisabled = menuListContext.itemsFocusableWhenDisabled;
|
|
197
191
|
const menuItemRef = React.useRef(null);
|
|
198
192
|
(0, _useEnhancedEffect.default)(() => {
|
|
199
|
-
if (
|
|
193
|
+
if (shouldAutoFocusOnMount) {
|
|
200
194
|
if (menuItemRef.current) {
|
|
201
|
-
|
|
195
|
+
(0, _focusWithVisible.default)(menuItemRef.current, focusSource);
|
|
202
196
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
203
197
|
console.error('MUI: Unable to set focus to a MenuItem whose component has not been rendered.');
|
|
204
198
|
}
|
|
205
199
|
}
|
|
206
200
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
207
|
-
}, [
|
|
201
|
+
}, [shouldAutoFocusOnMount]);
|
|
208
202
|
const ownerState = {
|
|
209
203
|
...props,
|
|
210
204
|
dense: childContext.dense,
|
|
@@ -212,10 +206,23 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
212
206
|
disableGutters
|
|
213
207
|
};
|
|
214
208
|
const classes = useUtilityClasses(props);
|
|
215
|
-
const
|
|
209
|
+
const rovingItemProps = (0, _useRovingTabIndex.useRovingTabIndexItem)({
|
|
210
|
+
id: rovingItemId,
|
|
211
|
+
ref,
|
|
212
|
+
disabled: props.disabled,
|
|
213
|
+
focusableWhenDisabled: itemsFocusableWhenDisabled,
|
|
214
|
+
selected: props.selected
|
|
215
|
+
});
|
|
216
|
+
const handleRef = (0, _useForkRef.default)(menuItemRef, rovingItemProps.ref);
|
|
216
217
|
let tabIndex;
|
|
217
|
-
if (
|
|
218
|
-
tabIndex = tabIndexProp
|
|
218
|
+
if (tabIndexProp !== undefined) {
|
|
219
|
+
tabIndex = tabIndexProp;
|
|
220
|
+
} else if (menuListContext.variant === 'selectedMenu') {
|
|
221
|
+
tabIndex = rovingItemProps.tabIndex;
|
|
222
|
+
} else if (!props.disabled || itemsFocusableWhenDisabled) {
|
|
223
|
+
// In `menu` variant, registration still drives arrow-key navigation even
|
|
224
|
+
// though each item keeps `tabIndex={-1}`.
|
|
225
|
+
tabIndex = -1;
|
|
219
226
|
}
|
|
220
227
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListContext.default.Provider, {
|
|
221
228
|
value: childContext,
|
|
@@ -224,6 +231,9 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
224
231
|
role: role,
|
|
225
232
|
tabIndex: tabIndex,
|
|
226
233
|
component: component,
|
|
234
|
+
internalNativeButton: false,
|
|
235
|
+
focusableWhenDisabled: itemsFocusableWhenDisabled,
|
|
236
|
+
suppressFocusVisible: suppressFocusVisible,
|
|
227
237
|
focusVisibleClassName: (0, _clsx.default)(classes.focusVisible, focusVisibleClassName),
|
|
228
238
|
className: (0, _clsx.default)(classes.root, className),
|
|
229
239
|
...other,
|
package/MenuItem/MenuItem.mjs
CHANGED
|
@@ -11,32 +11,17 @@ import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
|
11
11
|
import ListContext from "../List/ListContext.mjs";
|
|
12
12
|
import ButtonBase from "../ButtonBase/index.mjs";
|
|
13
13
|
import useEnhancedEffect from "../utils/useEnhancedEffect.mjs";
|
|
14
|
+
import focusWithVisible from "../utils/focusWithVisible.mjs";
|
|
14
15
|
import useForkRef from "../utils/useForkRef.mjs";
|
|
16
|
+
import useId from "../utils/useId.mjs";
|
|
17
|
+
import { useRovingTabIndexItem } from "../utils/useRovingTabIndex.mjs";
|
|
15
18
|
import { dividerClasses } from "../Divider/index.mjs";
|
|
16
19
|
import { listItemIconClasses } from "../ListItemIcon/index.mjs";
|
|
17
20
|
import { listItemTextClasses } from "../ListItemText/index.mjs";
|
|
21
|
+
import { useMenuListContext } from "../MenuList/MenuListContext.mjs";
|
|
22
|
+
import { useSelectFocusSource } from "../Select/utils/index.mjs";
|
|
18
23
|
import menuItemClasses, { getMenuItemUtilityClass } from "./menuItemClasses.mjs";
|
|
19
|
-
import { useSelectFocusSource } from "../Select/index.mjs";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* If autoFocus is an object, it will attempt to call `element.focus()` with the options argument.
|
|
23
|
-
* If the browser doesn't support the options argument, it will fall back to a simple `element.focus()` call.
|
|
24
|
-
*/
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
function focusWithVisible(element, focusSource) {
|
|
27
|
-
if (focusSource == null) {
|
|
28
|
-
element.focus();
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
element.focus({
|
|
33
|
-
focusVisible: focusSource === 'keyboard'
|
|
34
|
-
});
|
|
35
|
-
} catch (error) {
|
|
36
|
-
// If the browser doesn't support the focus options argument, fall back to a simple focus call.
|
|
37
|
-
element.focus();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
25
|
export const overridesResolver = (props, styles) => {
|
|
41
26
|
const {
|
|
42
27
|
ownerState
|
|
@@ -171,7 +156,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
171
156
|
name: 'MuiMenuItem'
|
|
172
157
|
});
|
|
173
158
|
const {
|
|
174
|
-
autoFocus = false,
|
|
159
|
+
autoFocus: shouldAutoFocusOnMount = false,
|
|
175
160
|
component = 'li',
|
|
176
161
|
dense = false,
|
|
177
162
|
divider = false,
|
|
@@ -188,9 +173,16 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
188
173
|
dense: dense || context.dense || false,
|
|
189
174
|
disableGutters
|
|
190
175
|
}), [context.dense, dense, disableGutters]);
|
|
176
|
+
const menuListContext = useMenuListContext();
|
|
177
|
+
const rovingItemId = useId();
|
|
178
|
+
// Escape hatch via ButtonBase for when an anchored <Menu> is opened with a pointer
|
|
179
|
+
// interaction on a trigger, the item should receive DOM focus but without focus visible
|
|
180
|
+
// styling. Current API does not allow a reliable `openInteractionType` for anchored menus.
|
|
181
|
+
const suppressFocusVisible = menuListContext.suppressInitialFocusVisible;
|
|
182
|
+
const itemsFocusableWhenDisabled = menuListContext.itemsFocusableWhenDisabled;
|
|
191
183
|
const menuItemRef = React.useRef(null);
|
|
192
184
|
useEnhancedEffect(() => {
|
|
193
|
-
if (
|
|
185
|
+
if (shouldAutoFocusOnMount) {
|
|
194
186
|
if (menuItemRef.current) {
|
|
195
187
|
focusWithVisible(menuItemRef.current, focusSource);
|
|
196
188
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
@@ -198,7 +190,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
192
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
201
|
-
}, [
|
|
193
|
+
}, [shouldAutoFocusOnMount]);
|
|
202
194
|
const ownerState = {
|
|
203
195
|
...props,
|
|
204
196
|
dense: childContext.dense,
|
|
@@ -206,10 +198,23 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
206
198
|
disableGutters
|
|
207
199
|
};
|
|
208
200
|
const classes = useUtilityClasses(props);
|
|
209
|
-
const
|
|
201
|
+
const rovingItemProps = useRovingTabIndexItem({
|
|
202
|
+
id: rovingItemId,
|
|
203
|
+
ref,
|
|
204
|
+
disabled: props.disabled,
|
|
205
|
+
focusableWhenDisabled: itemsFocusableWhenDisabled,
|
|
206
|
+
selected: props.selected
|
|
207
|
+
});
|
|
208
|
+
const handleRef = useForkRef(menuItemRef, rovingItemProps.ref);
|
|
210
209
|
let tabIndex;
|
|
211
|
-
if (
|
|
212
|
-
tabIndex = tabIndexProp
|
|
210
|
+
if (tabIndexProp !== undefined) {
|
|
211
|
+
tabIndex = tabIndexProp;
|
|
212
|
+
} else if (menuListContext.variant === 'selectedMenu') {
|
|
213
|
+
tabIndex = rovingItemProps.tabIndex;
|
|
214
|
+
} else if (!props.disabled || itemsFocusableWhenDisabled) {
|
|
215
|
+
// In `menu` variant, registration still drives arrow-key navigation even
|
|
216
|
+
// though each item keeps `tabIndex={-1}`.
|
|
217
|
+
tabIndex = -1;
|
|
213
218
|
}
|
|
214
219
|
return /*#__PURE__*/_jsx(ListContext.Provider, {
|
|
215
220
|
value: childContext,
|
|
@@ -218,6 +223,9 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(inProps, ref) {
|
|
|
218
223
|
role: role,
|
|
219
224
|
tabIndex: tabIndex,
|
|
220
225
|
component: component,
|
|
226
|
+
internalNativeButton: false,
|
|
227
|
+
focusableWhenDisabled: itemsFocusableWhenDisabled,
|
|
228
|
+
suppressFocusVisible: suppressFocusVisible,
|
|
221
229
|
focusVisibleClassName: clsx(classes.focusVisible, focusVisibleClassName),
|
|
222
230
|
className: clsx(classes.root, className),
|
|
223
231
|
...other,
|
package/MenuList/MenuList.js
CHANGED
|
@@ -8,26 +8,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
});
|
|
9
9
|
exports.default = void 0;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _reactIs = require("react-is");
|
|
12
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
var _useRovingTabIndex =
|
|
12
|
+
var _useRovingTabIndex = require("@mui/utils/useRovingTabIndex");
|
|
14
13
|
var _ownerDocument = _interopRequireDefault(require("../utils/ownerDocument"));
|
|
15
|
-
var _List = _interopRequireDefault(require("../List"));
|
|
16
14
|
var _getActiveElement = _interopRequireDefault(require("../utils/getActiveElement"));
|
|
17
15
|
var _getScrollbarSize = _interopRequireDefault(require("../utils/getScrollbarSize"));
|
|
16
|
+
var _focusWithVisible = _interopRequireDefault(require("../utils/focusWithVisible"));
|
|
17
|
+
var _useEventCallback = _interopRequireDefault(require("../utils/useEventCallback"));
|
|
18
18
|
var _useForkRef = _interopRequireDefault(require("../utils/useForkRef"));
|
|
19
19
|
var _useEnhancedEffect = _interopRequireDefault(require("../utils/useEnhancedEffect"));
|
|
20
|
-
var
|
|
20
|
+
var _useRovingTabIndex2 = require("../utils/useRovingTabIndex");
|
|
21
|
+
var _ownerWindow = _interopRequireDefault(require("../utils/ownerWindow"));
|
|
22
|
+
var _List = _interopRequireDefault(require("../List"));
|
|
23
|
+
var _utils = require("../Select/utils");
|
|
24
|
+
var _MenuListContext = require("./MenuListContext");
|
|
21
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
function getItemText(itemOrElement) {
|
|
27
|
+
const element = itemOrElement?.element ?? itemOrElement;
|
|
28
|
+
if (!element) {
|
|
29
|
+
return '';
|
|
25
30
|
}
|
|
26
|
-
|
|
31
|
+
if (itemOrElement?.textValue !== undefined) {
|
|
32
|
+
return itemOrElement.textValue;
|
|
33
|
+
}
|
|
34
|
+
let text = element.innerText;
|
|
27
35
|
if (text === undefined) {
|
|
28
36
|
// jsdom doesn't support innerText
|
|
29
|
-
text =
|
|
37
|
+
text = element.textContent;
|
|
30
38
|
}
|
|
39
|
+
return text ?? '';
|
|
40
|
+
}
|
|
41
|
+
function textCriteriaMatches(itemOrElement, textCriteria) {
|
|
42
|
+
if (textCriteria === undefined) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
let text = getItemText(itemOrElement);
|
|
31
46
|
text = text.trim().toLowerCase();
|
|
32
47
|
if (text.length === 0) {
|
|
33
48
|
return false;
|
|
@@ -37,20 +52,17 @@ function textCriteriaMatches(nextFocus, textCriteria) {
|
|
|
37
52
|
}
|
|
38
53
|
return text.startsWith(textCriteria.keys.join(''));
|
|
39
54
|
}
|
|
40
|
-
function
|
|
41
|
-
if (!textCriteriaMatches(
|
|
55
|
+
function isItemFocusableWithTextCriteria(item, criteria) {
|
|
56
|
+
if (!textCriteriaMatches(item, criteria)) {
|
|
42
57
|
return false;
|
|
43
58
|
}
|
|
44
|
-
return
|
|
59
|
+
return (0, _useRovingTabIndex.isItemFocusable)(item);
|
|
45
60
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return !element.disabled && element.getAttribute('aria-disabled') !== 'true';
|
|
61
|
+
|
|
62
|
+
// Menu auto-focus is not always keyboard-driven. On open we often move focus to the
|
|
63
|
+
// active item programmatically so arrow-key navigation starts from the right place.
|
|
64
|
+
function focusInitialItem(element, focusSource) {
|
|
65
|
+
(0, _focusWithVisible.default)(element, focusSource);
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
/**
|
|
@@ -64,8 +76,8 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
64
76
|
// private
|
|
65
77
|
// eslint-disable-next-line react/prop-types
|
|
66
78
|
actions,
|
|
67
|
-
autoFocus = false,
|
|
68
|
-
autoFocusItem = false,
|
|
79
|
+
autoFocus: autoFocusList = false,
|
|
80
|
+
autoFocusItem: autoFocusActiveItem = false,
|
|
69
81
|
children,
|
|
70
82
|
className,
|
|
71
83
|
disabledItemsFocusable = false,
|
|
@@ -75,17 +87,85 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
75
87
|
...other
|
|
76
88
|
} = props;
|
|
77
89
|
const listRef = React.useRef(null);
|
|
90
|
+
const hasFocusedInitialTargetRef = React.useRef(false);
|
|
91
|
+
// Escape hatch for <Menu variant="menu"> (items have no selection state). When opened with
|
|
92
|
+
// mouse/pointer, the initial focused item should still receive DOM focus, but ButtonBase
|
|
93
|
+
// should suppress its focus-visible state for that one initial handoff.
|
|
94
|
+
const [suppressInitialFocusVisible, setSuppressInitialFocusVisible] = React.useState(false);
|
|
95
|
+
// Current anchored <Menu>s cannot receive a `openInteractionType` signal from a trigger
|
|
96
|
+
// the API only receives `open` and `anchorEl`. When <MenuList> is used in <Select>, the
|
|
97
|
+
// internal <SelectInput> is able to achieve this via `useSelectFocusSource`.
|
|
98
|
+
const focusSource = (0, _utils.useSelectFocusSource)();
|
|
78
99
|
const textCriteriaRef = React.useRef({
|
|
79
100
|
keys: [],
|
|
80
101
|
repeating: true,
|
|
81
102
|
previousKeyMatched: true,
|
|
82
103
|
lastTime: null
|
|
83
104
|
});
|
|
84
|
-
|
|
85
|
-
if (
|
|
105
|
+
const getDefaultActiveItemId = React.useCallback(items => {
|
|
106
|
+
if (variant === 'selectedMenu') {
|
|
107
|
+
return items.find(item => item.selected && (0, _useRovingTabIndex.isItemFocusable)(item))?.id ?? items.find(item => (0, _useRovingTabIndex.isItemFocusable)(item))?.id ?? null;
|
|
108
|
+
}
|
|
109
|
+
return items.find(item => (0, _useRovingTabIndex.isItemFocusable)(item))?.id ?? null;
|
|
110
|
+
}, [variant]);
|
|
111
|
+
const rovingContainer = (0, _useRovingTabIndex2.useRovingTabIndexRoot)({
|
|
112
|
+
activeItemId: undefined,
|
|
113
|
+
getDefaultActiveItemId,
|
|
114
|
+
orientation: 'vertical',
|
|
115
|
+
wrap: !disableListWrap
|
|
116
|
+
});
|
|
117
|
+
const {
|
|
118
|
+
activeItemId,
|
|
119
|
+
focusNext,
|
|
120
|
+
getActiveItem,
|
|
121
|
+
getContainerProps,
|
|
122
|
+
getItemMap
|
|
123
|
+
} = rovingContainer;
|
|
124
|
+
const focusInitialTarget = (0, _useEventCallback.default)((force = false) => {
|
|
125
|
+
// `force` is used by the imperative action when `Menu` asks `MenuList` to restore its
|
|
126
|
+
// initial focus target after the popover finishes entering, even if this list already
|
|
127
|
+
// completed its normal one-time initial-focus path on an earlier render.
|
|
128
|
+
if (!listRef.current || !force && hasFocusedInitialTargetRef.current) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (autoFocusActiveItem) {
|
|
132
|
+
const activeItem = getActiveItem();
|
|
133
|
+
if (activeItem?.element) {
|
|
134
|
+
const hasSelectedItem = Array.from(getItemMap().values()).some(item => item.selected);
|
|
135
|
+
const shouldSuppressInitialFocusVisible = variant === 'menu' && hasSelectedItem && !activeItem.selected && focusSource == null;
|
|
136
|
+
setSuppressInitialFocusVisible(shouldSuppressInitialFocusVisible);
|
|
137
|
+
focusInitialItem(activeItem.element, focusSource);
|
|
138
|
+
hasFocusedInitialTargetRef.current = true;
|
|
139
|
+
return activeItem.element;
|
|
140
|
+
}
|
|
141
|
+
if (!autoFocusList) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Keep the list container focusable while waiting for items to register,
|
|
146
|
+
// or when there is no focusable item to move to.
|
|
147
|
+
setSuppressInitialFocusVisible(false);
|
|
86
148
|
listRef.current.focus();
|
|
149
|
+
return listRef.current;
|
|
87
150
|
}
|
|
88
|
-
|
|
151
|
+
if (!autoFocusList) {
|
|
152
|
+
setSuppressInitialFocusVisible(false);
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
setSuppressInitialFocusVisible(false);
|
|
156
|
+
listRef.current.focus();
|
|
157
|
+
hasFocusedInitialTargetRef.current = true;
|
|
158
|
+
return listRef.current;
|
|
159
|
+
});
|
|
160
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
161
|
+
if (!autoFocusList && !autoFocusActiveItem) {
|
|
162
|
+
hasFocusedInitialTargetRef.current = false;
|
|
163
|
+
setSuppressInitialFocusVisible(false);
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
focusInitialTarget();
|
|
167
|
+
return undefined;
|
|
168
|
+
}, [activeItemId, autoFocusActiveItem, autoFocusList, focusInitialTarget]);
|
|
89
169
|
React.useImperativeHandle(actions, () => ({
|
|
90
170
|
adjustStyleForScrollbar: (containerElement, {
|
|
91
171
|
direction
|
|
@@ -94,91 +174,40 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
94
174
|
// of the menu.
|
|
95
175
|
const noExplicitWidth = !listRef.current.style.width;
|
|
96
176
|
if (containerElement.clientHeight < listRef.current.clientHeight && noExplicitWidth) {
|
|
97
|
-
const scrollbarSize = `${(0, _getScrollbarSize.default)((0,
|
|
177
|
+
const scrollbarSize = `${(0, _getScrollbarSize.default)((0, _ownerWindow.default)(containerElement))}px`;
|
|
98
178
|
listRef.current.style[direction === 'rtl' ? 'paddingLeft' : 'paddingRight'] = scrollbarSize;
|
|
99
179
|
listRef.current.style.width = `calc(100% + ${scrollbarSize})`;
|
|
100
180
|
}
|
|
101
181
|
return listRef.current;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* the index of the item should receive focus
|
|
107
|
-
* in a `variant="selectedMenu"` it's the first `selected` item
|
|
108
|
-
* otherwise it's the very first item.
|
|
109
|
-
*/
|
|
110
|
-
let activeItemIndex = -1;
|
|
111
|
-
// since we inject focus related props into children we have to do a lookahead
|
|
112
|
-
// to check if there is a `selected` item. We're looking for the last `selected`
|
|
113
|
-
// item and use the first valid item as a fallback
|
|
114
|
-
React.Children.forEach(children, (child, index) => {
|
|
115
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
116
|
-
if (activeItemIndex === index) {
|
|
117
|
-
activeItemIndex += 1;
|
|
118
|
-
if (activeItemIndex >= children.length) {
|
|
119
|
-
// there are no focusable items within the list.
|
|
120
|
-
activeItemIndex = -1;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
-
if ((0, _reactIs.isFragment)(child)) {
|
|
127
|
-
console.error(["MUI: The Menu component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (!child.props.disabled) {
|
|
131
|
-
if (variant === 'selectedMenu' && child.props.selected) {
|
|
132
|
-
activeItemIndex = index;
|
|
133
|
-
} else if (activeItemIndex === -1) {
|
|
134
|
-
activeItemIndex = index;
|
|
182
|
+
},
|
|
183
|
+
focusInitialTarget: () => {
|
|
184
|
+
if (!listRef.current) {
|
|
185
|
+
return null;
|
|
135
186
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (activeItemIndex >= children.length) {
|
|
140
|
-
// there are no focusable items within the list.
|
|
141
|
-
activeItemIndex = -1;
|
|
187
|
+
const currentFocus = (0, _getActiveElement.default)((0, _ownerDocument.default)(listRef.current));
|
|
188
|
+
if (currentFocus && listRef.current.contains(currentFocus)) {
|
|
189
|
+
return currentFocus;
|
|
142
190
|
}
|
|
191
|
+
return focusInitialTarget(true);
|
|
143
192
|
}
|
|
144
|
-
});
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const rovingTabIndexContainerProps = getContainerProps();
|
|
156
|
-
const handleRef = (0, _useForkRef.default)(listRef, rovingTabIndexContainerProps.ref, ref);
|
|
157
|
-
let focusableIndex = 0;
|
|
158
|
-
const items = React.Children.map(children, (child, index) => {
|
|
159
|
-
if (! /*#__PURE__*/React.isValidElement(child) || child.props.muiSkipListHighlight || child.type.muiSkipListHighlight) {
|
|
160
|
-
return child;
|
|
161
|
-
}
|
|
162
|
-
const rovingTabIndexItemProps = getItemProps(focusableIndex, child.ref);
|
|
163
|
-
const newChildProps = {
|
|
164
|
-
ref: rovingTabIndexItemProps.ref
|
|
165
|
-
};
|
|
166
|
-
if (child.props.tabIndex === undefined && variant === 'selectedMenu') {
|
|
167
|
-
newChildProps.tabIndex = rovingTabIndexItemProps.tabIndex;
|
|
193
|
+
}), [focusInitialTarget]);
|
|
194
|
+
const rovingContainerProps = getContainerProps();
|
|
195
|
+
const handleRef = (0, _useForkRef.default)(listRef, rovingContainerProps.ref, ref);
|
|
196
|
+
const menuListContextValue = React.useMemo(() => ({
|
|
197
|
+
itemsFocusableWhenDisabled: disabledItemsFocusable,
|
|
198
|
+
suppressInitialFocusVisible,
|
|
199
|
+
variant
|
|
200
|
+
}), [disabledItemsFocusable, suppressInitialFocusVisible, variant]);
|
|
201
|
+
const handleKeyDown = (0, _useEventCallback.default)(event => {
|
|
202
|
+
if (suppressInitialFocusVisible) {
|
|
203
|
+
setSuppressInitialFocusVisible(false);
|
|
168
204
|
}
|
|
169
|
-
if (index === activeItemIndex && autoFocusItem) {
|
|
170
|
-
newChildProps.autoFocus = true;
|
|
171
|
-
}
|
|
172
|
-
focusableIndex += 1;
|
|
173
|
-
return /*#__PURE__*/React.cloneElement(child, newChildProps);
|
|
174
|
-
});
|
|
175
|
-
const handleKeyDown = event => {
|
|
176
205
|
const isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
|
|
177
206
|
if (isModifierKeyPressed && onKeyDown) {
|
|
178
207
|
onKeyDown(event);
|
|
179
208
|
return;
|
|
180
209
|
}
|
|
181
|
-
|
|
210
|
+
rovingContainerProps.onKeyDown(event);
|
|
182
211
|
if (event.key.length === 1) {
|
|
183
212
|
const criteria = textCriteriaRef.current;
|
|
184
213
|
const lowerKey = event.key.toLowerCase();
|
|
@@ -197,7 +226,7 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
197
226
|
criteria.keys.push(lowerKey);
|
|
198
227
|
const currentFocus = (0, _getActiveElement.default)((0, _ownerDocument.default)(listRef.current));
|
|
199
228
|
const keepFocusOnCurrent = currentFocus && !criteria.repeating && textCriteriaMatches(currentFocus, criteria);
|
|
200
|
-
if (criteria.previousKeyMatched && (keepFocusOnCurrent || focusNext(
|
|
229
|
+
if (criteria.previousKeyMatched && (keepFocusOnCurrent || focusNext(item => isItemFocusableWithTextCriteria(item, criteria)) != null)) {
|
|
201
230
|
event.preventDefault();
|
|
202
231
|
} else {
|
|
203
232
|
criteria.previousKeyMatched = false;
|
|
@@ -206,16 +235,22 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
206
235
|
if (onKeyDown) {
|
|
207
236
|
onKeyDown(event);
|
|
208
237
|
}
|
|
209
|
-
};
|
|
238
|
+
});
|
|
210
239
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_List.default, {
|
|
211
240
|
role: "menu",
|
|
212
241
|
ref: handleRef,
|
|
213
242
|
className: className,
|
|
214
243
|
onKeyDown: handleKeyDown,
|
|
215
|
-
onFocus:
|
|
244
|
+
onFocus: rovingContainerProps.onFocus,
|
|
216
245
|
tabIndex: -1,
|
|
217
246
|
...other,
|
|
218
|
-
children:
|
|
247
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuListContext.MenuListContext.Provider, {
|
|
248
|
+
value: menuListContextValue,
|
|
249
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useRovingTabIndex2.RovingTabIndexContext.Provider, {
|
|
250
|
+
value: rovingContainer,
|
|
251
|
+
children: children
|
|
252
|
+
})
|
|
253
|
+
})
|
|
219
254
|
});
|
|
220
255
|
});
|
|
221
256
|
process.env.NODE_ENV !== "production" ? MenuList.propTypes /* remove-proptypes */ = {
|