@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/MenuList/MenuList.mjs
CHANGED
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { isFragment } from 'react-is';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
5
|
+
import { isItemFocusable } from '@mui/utils/useRovingTabIndex';
|
|
7
6
|
import ownerDocument from "../utils/ownerDocument.mjs";
|
|
8
|
-
import List from "../List/index.mjs";
|
|
9
7
|
import getActiveElement from "../utils/getActiveElement.mjs";
|
|
10
8
|
import getScrollbarSize from "../utils/getScrollbarSize.mjs";
|
|
9
|
+
import focusWithVisible from "../utils/focusWithVisible.mjs";
|
|
10
|
+
import useEventCallback from "../utils/useEventCallback.mjs";
|
|
11
11
|
import useForkRef from "../utils/useForkRef.mjs";
|
|
12
12
|
import useEnhancedEffect from "../utils/useEnhancedEffect.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { RovingTabIndexContext, useRovingTabIndexRoot } from "../utils/useRovingTabIndex.mjs";
|
|
14
|
+
import ownerWindow from "../utils/ownerWindow.mjs";
|
|
15
|
+
import List from "../List/index.mjs";
|
|
16
|
+
import { useSelectFocusSource } from "../Select/utils/index.mjs";
|
|
17
|
+
import { MenuListContext } from "./MenuListContext.mjs";
|
|
14
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
function getItemText(itemOrElement) {
|
|
20
|
+
const element = itemOrElement?.element ?? itemOrElement;
|
|
21
|
+
if (!element) {
|
|
22
|
+
return '';
|
|
18
23
|
}
|
|
19
|
-
|
|
24
|
+
if (itemOrElement?.textValue !== undefined) {
|
|
25
|
+
return itemOrElement.textValue;
|
|
26
|
+
}
|
|
27
|
+
let text = element.innerText;
|
|
20
28
|
if (text === undefined) {
|
|
21
29
|
// jsdom doesn't support innerText
|
|
22
|
-
text =
|
|
30
|
+
text = element.textContent;
|
|
23
31
|
}
|
|
32
|
+
return text ?? '';
|
|
33
|
+
}
|
|
34
|
+
function textCriteriaMatches(itemOrElement, textCriteria) {
|
|
35
|
+
if (textCriteria === undefined) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
let text = getItemText(itemOrElement);
|
|
24
39
|
text = text.trim().toLowerCase();
|
|
25
40
|
if (text.length === 0) {
|
|
26
41
|
return false;
|
|
@@ -30,20 +45,17 @@ function textCriteriaMatches(nextFocus, textCriteria) {
|
|
|
30
45
|
}
|
|
31
46
|
return text.startsWith(textCriteria.keys.join(''));
|
|
32
47
|
}
|
|
33
|
-
function
|
|
34
|
-
if (!textCriteriaMatches(
|
|
48
|
+
function isItemFocusableWithTextCriteria(item, criteria) {
|
|
49
|
+
if (!textCriteriaMatches(item, criteria)) {
|
|
35
50
|
return false;
|
|
36
51
|
}
|
|
37
|
-
return
|
|
52
|
+
return isItemFocusable(item);
|
|
38
53
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return !element.disabled && element.getAttribute('aria-disabled') !== 'true';
|
|
54
|
+
|
|
55
|
+
// Menu auto-focus is not always keyboard-driven. On open we often move focus to the
|
|
56
|
+
// active item programmatically so arrow-key navigation starts from the right place.
|
|
57
|
+
function focusInitialItem(element, focusSource) {
|
|
58
|
+
focusWithVisible(element, focusSource);
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
/**
|
|
@@ -57,8 +69,8 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
57
69
|
// private
|
|
58
70
|
// eslint-disable-next-line react/prop-types
|
|
59
71
|
actions,
|
|
60
|
-
autoFocus = false,
|
|
61
|
-
autoFocusItem = false,
|
|
72
|
+
autoFocus: autoFocusList = false,
|
|
73
|
+
autoFocusItem: autoFocusActiveItem = false,
|
|
62
74
|
children,
|
|
63
75
|
className,
|
|
64
76
|
disabledItemsFocusable = false,
|
|
@@ -68,17 +80,85 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
68
80
|
...other
|
|
69
81
|
} = props;
|
|
70
82
|
const listRef = React.useRef(null);
|
|
83
|
+
const hasFocusedInitialTargetRef = React.useRef(false);
|
|
84
|
+
// Escape hatch for <Menu variant="menu"> (items have no selection state). When opened with
|
|
85
|
+
// mouse/pointer, the initial focused item should still receive DOM focus, but ButtonBase
|
|
86
|
+
// should suppress its focus-visible state for that one initial handoff.
|
|
87
|
+
const [suppressInitialFocusVisible, setSuppressInitialFocusVisible] = React.useState(false);
|
|
88
|
+
// Current anchored <Menu>s cannot receive a `openInteractionType` signal from a trigger
|
|
89
|
+
// the API only receives `open` and `anchorEl`. When <MenuList> is used in <Select>, the
|
|
90
|
+
// internal <SelectInput> is able to achieve this via `useSelectFocusSource`.
|
|
91
|
+
const focusSource = useSelectFocusSource();
|
|
71
92
|
const textCriteriaRef = React.useRef({
|
|
72
93
|
keys: [],
|
|
73
94
|
repeating: true,
|
|
74
95
|
previousKeyMatched: true,
|
|
75
96
|
lastTime: null
|
|
76
97
|
});
|
|
77
|
-
|
|
78
|
-
if (
|
|
98
|
+
const getDefaultActiveItemId = React.useCallback(items => {
|
|
99
|
+
if (variant === 'selectedMenu') {
|
|
100
|
+
return items.find(item => item.selected && isItemFocusable(item))?.id ?? items.find(item => isItemFocusable(item))?.id ?? null;
|
|
101
|
+
}
|
|
102
|
+
return items.find(item => isItemFocusable(item))?.id ?? null;
|
|
103
|
+
}, [variant]);
|
|
104
|
+
const rovingContainer = useRovingTabIndexRoot({
|
|
105
|
+
activeItemId: undefined,
|
|
106
|
+
getDefaultActiveItemId,
|
|
107
|
+
orientation: 'vertical',
|
|
108
|
+
wrap: !disableListWrap
|
|
109
|
+
});
|
|
110
|
+
const {
|
|
111
|
+
activeItemId,
|
|
112
|
+
focusNext,
|
|
113
|
+
getActiveItem,
|
|
114
|
+
getContainerProps,
|
|
115
|
+
getItemMap
|
|
116
|
+
} = rovingContainer;
|
|
117
|
+
const focusInitialTarget = useEventCallback((force = false) => {
|
|
118
|
+
// `force` is used by the imperative action when `Menu` asks `MenuList` to restore its
|
|
119
|
+
// initial focus target after the popover finishes entering, even if this list already
|
|
120
|
+
// completed its normal one-time initial-focus path on an earlier render.
|
|
121
|
+
if (!listRef.current || !force && hasFocusedInitialTargetRef.current) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (autoFocusActiveItem) {
|
|
125
|
+
const activeItem = getActiveItem();
|
|
126
|
+
if (activeItem?.element) {
|
|
127
|
+
const hasSelectedItem = Array.from(getItemMap().values()).some(item => item.selected);
|
|
128
|
+
const shouldSuppressInitialFocusVisible = variant === 'menu' && hasSelectedItem && !activeItem.selected && focusSource == null;
|
|
129
|
+
setSuppressInitialFocusVisible(shouldSuppressInitialFocusVisible);
|
|
130
|
+
focusInitialItem(activeItem.element, focusSource);
|
|
131
|
+
hasFocusedInitialTargetRef.current = true;
|
|
132
|
+
return activeItem.element;
|
|
133
|
+
}
|
|
134
|
+
if (!autoFocusList) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Keep the list container focusable while waiting for items to register,
|
|
139
|
+
// or when there is no focusable item to move to.
|
|
140
|
+
setSuppressInitialFocusVisible(false);
|
|
79
141
|
listRef.current.focus();
|
|
142
|
+
return listRef.current;
|
|
80
143
|
}
|
|
81
|
-
|
|
144
|
+
if (!autoFocusList) {
|
|
145
|
+
setSuppressInitialFocusVisible(false);
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
setSuppressInitialFocusVisible(false);
|
|
149
|
+
listRef.current.focus();
|
|
150
|
+
hasFocusedInitialTargetRef.current = true;
|
|
151
|
+
return listRef.current;
|
|
152
|
+
});
|
|
153
|
+
useEnhancedEffect(() => {
|
|
154
|
+
if (!autoFocusList && !autoFocusActiveItem) {
|
|
155
|
+
hasFocusedInitialTargetRef.current = false;
|
|
156
|
+
setSuppressInitialFocusVisible(false);
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
focusInitialTarget();
|
|
160
|
+
return undefined;
|
|
161
|
+
}, [activeItemId, autoFocusActiveItem, autoFocusList, focusInitialTarget]);
|
|
82
162
|
React.useImperativeHandle(actions, () => ({
|
|
83
163
|
adjustStyleForScrollbar: (containerElement, {
|
|
84
164
|
direction
|
|
@@ -92,86 +172,35 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
92
172
|
listRef.current.style.width = `calc(100% + ${scrollbarSize})`;
|
|
93
173
|
}
|
|
94
174
|
return listRef.current;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* the index of the item should receive focus
|
|
100
|
-
* in a `variant="selectedMenu"` it's the first `selected` item
|
|
101
|
-
* otherwise it's the very first item.
|
|
102
|
-
*/
|
|
103
|
-
let activeItemIndex = -1;
|
|
104
|
-
// since we inject focus related props into children we have to do a lookahead
|
|
105
|
-
// to check if there is a `selected` item. We're looking for the last `selected`
|
|
106
|
-
// item and use the first valid item as a fallback
|
|
107
|
-
React.Children.forEach(children, (child, index) => {
|
|
108
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
109
|
-
if (activeItemIndex === index) {
|
|
110
|
-
activeItemIndex += 1;
|
|
111
|
-
if (activeItemIndex >= children.length) {
|
|
112
|
-
// there are no focusable items within the list.
|
|
113
|
-
activeItemIndex = -1;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
119
|
-
if (isFragment(child)) {
|
|
120
|
-
console.error(["MUI: The Menu component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (!child.props.disabled) {
|
|
124
|
-
if (variant === 'selectedMenu' && child.props.selected) {
|
|
125
|
-
activeItemIndex = index;
|
|
126
|
-
} else if (activeItemIndex === -1) {
|
|
127
|
-
activeItemIndex = index;
|
|
175
|
+
},
|
|
176
|
+
focusInitialTarget: () => {
|
|
177
|
+
if (!listRef.current) {
|
|
178
|
+
return null;
|
|
128
179
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (activeItemIndex >= children.length) {
|
|
133
|
-
// there are no focusable items within the list.
|
|
134
|
-
activeItemIndex = -1;
|
|
180
|
+
const currentFocus = getActiveElement(ownerDocument(listRef.current));
|
|
181
|
+
if (currentFocus && listRef.current.contains(currentFocus)) {
|
|
182
|
+
return currentFocus;
|
|
135
183
|
}
|
|
184
|
+
return focusInitialTarget(true);
|
|
136
185
|
}
|
|
137
|
-
});
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const rovingTabIndexContainerProps = getContainerProps();
|
|
149
|
-
const handleRef = useForkRef(listRef, rovingTabIndexContainerProps.ref, ref);
|
|
150
|
-
let focusableIndex = 0;
|
|
151
|
-
const items = React.Children.map(children, (child, index) => {
|
|
152
|
-
if (! /*#__PURE__*/React.isValidElement(child) || child.props.muiSkipListHighlight || child.type.muiSkipListHighlight) {
|
|
153
|
-
return child;
|
|
154
|
-
}
|
|
155
|
-
const rovingTabIndexItemProps = getItemProps(focusableIndex, child.ref);
|
|
156
|
-
const newChildProps = {
|
|
157
|
-
ref: rovingTabIndexItemProps.ref
|
|
158
|
-
};
|
|
159
|
-
if (child.props.tabIndex === undefined && variant === 'selectedMenu') {
|
|
160
|
-
newChildProps.tabIndex = rovingTabIndexItemProps.tabIndex;
|
|
186
|
+
}), [focusInitialTarget]);
|
|
187
|
+
const rovingContainerProps = getContainerProps();
|
|
188
|
+
const handleRef = useForkRef(listRef, rovingContainerProps.ref, ref);
|
|
189
|
+
const menuListContextValue = React.useMemo(() => ({
|
|
190
|
+
itemsFocusableWhenDisabled: disabledItemsFocusable,
|
|
191
|
+
suppressInitialFocusVisible,
|
|
192
|
+
variant
|
|
193
|
+
}), [disabledItemsFocusable, suppressInitialFocusVisible, variant]);
|
|
194
|
+
const handleKeyDown = useEventCallback(event => {
|
|
195
|
+
if (suppressInitialFocusVisible) {
|
|
196
|
+
setSuppressInitialFocusVisible(false);
|
|
161
197
|
}
|
|
162
|
-
if (index === activeItemIndex && autoFocusItem) {
|
|
163
|
-
newChildProps.autoFocus = true;
|
|
164
|
-
}
|
|
165
|
-
focusableIndex += 1;
|
|
166
|
-
return /*#__PURE__*/React.cloneElement(child, newChildProps);
|
|
167
|
-
});
|
|
168
|
-
const handleKeyDown = event => {
|
|
169
198
|
const isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
|
|
170
199
|
if (isModifierKeyPressed && onKeyDown) {
|
|
171
200
|
onKeyDown(event);
|
|
172
201
|
return;
|
|
173
202
|
}
|
|
174
|
-
|
|
203
|
+
rovingContainerProps.onKeyDown(event);
|
|
175
204
|
if (event.key.length === 1) {
|
|
176
205
|
const criteria = textCriteriaRef.current;
|
|
177
206
|
const lowerKey = event.key.toLowerCase();
|
|
@@ -190,7 +219,7 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
190
219
|
criteria.keys.push(lowerKey);
|
|
191
220
|
const currentFocus = getActiveElement(ownerDocument(listRef.current));
|
|
192
221
|
const keepFocusOnCurrent = currentFocus && !criteria.repeating && textCriteriaMatches(currentFocus, criteria);
|
|
193
|
-
if (criteria.previousKeyMatched && (keepFocusOnCurrent || focusNext(
|
|
222
|
+
if (criteria.previousKeyMatched && (keepFocusOnCurrent || focusNext(item => isItemFocusableWithTextCriteria(item, criteria)) != null)) {
|
|
194
223
|
event.preventDefault();
|
|
195
224
|
} else {
|
|
196
225
|
criteria.previousKeyMatched = false;
|
|
@@ -199,16 +228,22 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
|
|
|
199
228
|
if (onKeyDown) {
|
|
200
229
|
onKeyDown(event);
|
|
201
230
|
}
|
|
202
|
-
};
|
|
231
|
+
});
|
|
203
232
|
return /*#__PURE__*/_jsx(List, {
|
|
204
233
|
role: "menu",
|
|
205
234
|
ref: handleRef,
|
|
206
235
|
className: className,
|
|
207
236
|
onKeyDown: handleKeyDown,
|
|
208
|
-
onFocus:
|
|
237
|
+
onFocus: rovingContainerProps.onFocus,
|
|
209
238
|
tabIndex: -1,
|
|
210
239
|
...other,
|
|
211
|
-
children:
|
|
240
|
+
children: /*#__PURE__*/_jsx(MenuListContext.Provider, {
|
|
241
|
+
value: menuListContextValue,
|
|
242
|
+
children: /*#__PURE__*/_jsx(RovingTabIndexContext.Provider, {
|
|
243
|
+
value: rovingContainer,
|
|
244
|
+
children: children
|
|
245
|
+
})
|
|
246
|
+
})
|
|
212
247
|
});
|
|
213
248
|
});
|
|
214
249
|
process.env.NODE_ENV !== "production" ? MenuList.propTypes /* remove-proptypes */ = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @ignore - internal component.
|
|
4
|
+
*/
|
|
5
|
+
export interface MenuListContextValue {
|
|
6
|
+
itemsFocusableWhenDisabled: boolean;
|
|
7
|
+
suppressInitialFocusVisible: boolean;
|
|
8
|
+
variant: 'menu' | 'selectedMenu';
|
|
9
|
+
}
|
|
10
|
+
export declare const MenuListContext: React.Context<MenuListContextValue | undefined>;
|
|
11
|
+
export declare function useMenuListContext(): MenuListContextValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @ignore - internal component.
|
|
4
|
+
*/
|
|
5
|
+
export interface MenuListContextValue {
|
|
6
|
+
itemsFocusableWhenDisabled: boolean;
|
|
7
|
+
suppressInitialFocusVisible: boolean;
|
|
8
|
+
variant: 'menu' | 'selectedMenu';
|
|
9
|
+
}
|
|
10
|
+
export declare const MenuListContext: React.Context<MenuListContextValue | undefined>;
|
|
11
|
+
export declare function useMenuListContext(): MenuListContextValue;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.MenuListContext = void 0;
|
|
9
|
+
exports.useMenuListContext = useMenuListContext;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
/**
|
|
12
|
+
* @ignore - internal component.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const MenuListContext = exports.MenuListContext = /*#__PURE__*/React.createContext(undefined);
|
|
16
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
+
MenuListContext.displayName = 'MenuListContext';
|
|
18
|
+
}
|
|
19
|
+
function useMenuListContext() {
|
|
20
|
+
const context = React.useContext(MenuListContext);
|
|
21
|
+
if (context === undefined) {
|
|
22
|
+
throw new Error('MUI: MenuListContext is missing. MenuItems must be placed within Menu or MenuList.');
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @ignore - internal component.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const MenuListContext = /*#__PURE__*/React.createContext(undefined);
|
|
10
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
11
|
+
MenuListContext.displayName = 'MenuListContext';
|
|
12
|
+
}
|
|
13
|
+
export function useMenuListContext() {
|
|
14
|
+
const context = React.useContext(MenuListContext);
|
|
15
|
+
if (context === undefined) {
|
|
16
|
+
throw new Error('MUI: MenuListContext is missing. MenuItems must be placed within Menu or MenuList.');
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
package/Modal/Modal.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { OverrideProps } from '@mui/types';
|
|
|
4
4
|
import { SlotComponentProps } from "../utils/types.mjs";
|
|
5
5
|
import { PortalProps } from "../Portal/index.mjs";
|
|
6
6
|
import { Theme } from "../styles/index.mjs";
|
|
7
|
-
import Backdrop
|
|
7
|
+
import Backdrop from "../Backdrop/index.mjs";
|
|
8
8
|
import { OverridableComponent } from "../OverridableComponent/index.mjs";
|
|
9
9
|
import { ModalClasses } from "./modalClasses.mjs";
|
|
10
10
|
export interface ModalComponentsPropsOverrides {}
|
|
@@ -23,23 +23,6 @@ export interface ModalSlots {
|
|
|
23
23
|
backdrop?: React.ElementType | undefined;
|
|
24
24
|
}
|
|
25
25
|
export interface ModalOwnProps {
|
|
26
|
-
/**
|
|
27
|
-
* A backdrop component. This prop enables custom backdrop rendering.
|
|
28
|
-
* @deprecated Use `slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
|
|
29
|
-
* Use the `slots.backdrop` prop to make your application ready for the next version of Material UI.
|
|
30
|
-
* @default styled(Backdrop, {
|
|
31
|
-
* name: 'MuiModal',
|
|
32
|
-
* slot: 'Backdrop',
|
|
33
|
-
* })({
|
|
34
|
-
* zIndex: -1,
|
|
35
|
-
* })
|
|
36
|
-
*/
|
|
37
|
-
BackdropComponent?: React.ElementType<BackdropProps> | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Props applied to the [`Backdrop`](https://mui.com/material-ui/api/backdrop/) element.
|
|
40
|
-
* @deprecated Use `slotProps.backdrop` instead.
|
|
41
|
-
*/
|
|
42
|
-
BackdropProps?: Partial<BackdropProps> | undefined;
|
|
43
26
|
/**
|
|
44
27
|
* A single child content element.
|
|
45
28
|
*/
|
|
@@ -57,29 +40,6 @@ export interface ModalOwnProps {
|
|
|
57
40
|
* @default false
|
|
58
41
|
*/
|
|
59
42
|
closeAfterTransition?: boolean | undefined;
|
|
60
|
-
/**
|
|
61
|
-
* The components used for each slot inside.
|
|
62
|
-
*
|
|
63
|
-
* @deprecated Use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
64
|
-
*
|
|
65
|
-
* @default {}
|
|
66
|
-
*/
|
|
67
|
-
components?: {
|
|
68
|
-
Root?: React.ElementType | undefined;
|
|
69
|
-
Backdrop?: React.ElementType | undefined;
|
|
70
|
-
} | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* The extra props for the slot components.
|
|
73
|
-
* You can override the existing props or add new ones.
|
|
74
|
-
*
|
|
75
|
-
* @deprecated Use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
76
|
-
*
|
|
77
|
-
* @default {}
|
|
78
|
-
*/
|
|
79
|
-
componentsProps?: {
|
|
80
|
-
root?: SlotComponentProps<'div', ModalComponentsPropsOverrides, ModalOwnerState> | undefined;
|
|
81
|
-
backdrop?: SlotComponentProps<typeof Backdrop, ModalComponentsPropsOverrides, ModalOwnerState> | undefined;
|
|
82
|
-
} | undefined;
|
|
83
43
|
/**
|
|
84
44
|
* An HTML element or function that returns one.
|
|
85
45
|
* The `container` will have the portal children appended to it.
|
package/Modal/Modal.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { OverrideProps } from '@mui/types';
|
|
|
4
4
|
import { SlotComponentProps } from "../utils/types.js";
|
|
5
5
|
import { PortalProps } from "../Portal/index.js";
|
|
6
6
|
import { Theme } from "../styles/index.js";
|
|
7
|
-
import Backdrop
|
|
7
|
+
import Backdrop from "../Backdrop/index.js";
|
|
8
8
|
import { OverridableComponent } from "../OverridableComponent/index.js";
|
|
9
9
|
import { ModalClasses } from "./modalClasses.js";
|
|
10
10
|
export interface ModalComponentsPropsOverrides {}
|
|
@@ -23,23 +23,6 @@ export interface ModalSlots {
|
|
|
23
23
|
backdrop?: React.ElementType | undefined;
|
|
24
24
|
}
|
|
25
25
|
export interface ModalOwnProps {
|
|
26
|
-
/**
|
|
27
|
-
* A backdrop component. This prop enables custom backdrop rendering.
|
|
28
|
-
* @deprecated Use `slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
|
|
29
|
-
* Use the `slots.backdrop` prop to make your application ready for the next version of Material UI.
|
|
30
|
-
* @default styled(Backdrop, {
|
|
31
|
-
* name: 'MuiModal',
|
|
32
|
-
* slot: 'Backdrop',
|
|
33
|
-
* })({
|
|
34
|
-
* zIndex: -1,
|
|
35
|
-
* })
|
|
36
|
-
*/
|
|
37
|
-
BackdropComponent?: React.ElementType<BackdropProps> | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Props applied to the [`Backdrop`](https://mui.com/material-ui/api/backdrop/) element.
|
|
40
|
-
* @deprecated Use `slotProps.backdrop` instead.
|
|
41
|
-
*/
|
|
42
|
-
BackdropProps?: Partial<BackdropProps> | undefined;
|
|
43
26
|
/**
|
|
44
27
|
* A single child content element.
|
|
45
28
|
*/
|
|
@@ -57,29 +40,6 @@ export interface ModalOwnProps {
|
|
|
57
40
|
* @default false
|
|
58
41
|
*/
|
|
59
42
|
closeAfterTransition?: boolean | undefined;
|
|
60
|
-
/**
|
|
61
|
-
* The components used for each slot inside.
|
|
62
|
-
*
|
|
63
|
-
* @deprecated Use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
64
|
-
*
|
|
65
|
-
* @default {}
|
|
66
|
-
*/
|
|
67
|
-
components?: {
|
|
68
|
-
Root?: React.ElementType | undefined;
|
|
69
|
-
Backdrop?: React.ElementType | undefined;
|
|
70
|
-
} | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* The extra props for the slot components.
|
|
73
|
-
* You can override the existing props or add new ones.
|
|
74
|
-
*
|
|
75
|
-
* @deprecated Use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
76
|
-
*
|
|
77
|
-
* @default {}
|
|
78
|
-
*/
|
|
79
|
-
componentsProps?: {
|
|
80
|
-
root?: SlotComponentProps<'div', ModalComponentsPropsOverrides, ModalOwnerState> | undefined;
|
|
81
|
-
backdrop?: SlotComponentProps<typeof Backdrop, ModalComponentsPropsOverrides, ModalOwnerState> | undefined;
|
|
82
|
-
} | undefined;
|
|
83
43
|
/**
|
|
84
44
|
* An HTML element or function that returns one.
|
|
85
45
|
* The `container` will have the portal children appended to it.
|
package/Modal/Modal.js
CHANGED
|
@@ -88,16 +88,12 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
88
88
|
props: inProps
|
|
89
89
|
});
|
|
90
90
|
const {
|
|
91
|
-
BackdropComponent = ModalBackdrop,
|
|
92
|
-
BackdropProps,
|
|
93
91
|
classes: classesProp,
|
|
94
92
|
className,
|
|
95
93
|
closeAfterTransition = false,
|
|
96
94
|
children,
|
|
97
95
|
container,
|
|
98
96
|
component,
|
|
99
|
-
components = {},
|
|
100
|
-
componentsProps = {},
|
|
101
97
|
disableAutoFocus = false,
|
|
102
98
|
disableEnforceFocus = false,
|
|
103
99
|
disablePortal = false,
|
|
@@ -158,15 +154,8 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
158
154
|
childProps.onExited = onExited;
|
|
159
155
|
}
|
|
160
156
|
const externalForwardedProps = {
|
|
161
|
-
slots
|
|
162
|
-
|
|
163
|
-
backdrop: components.Backdrop,
|
|
164
|
-
...slots
|
|
165
|
-
},
|
|
166
|
-
slotProps: {
|
|
167
|
-
...componentsProps,
|
|
168
|
-
...slotProps
|
|
169
|
-
}
|
|
157
|
+
slots,
|
|
158
|
+
slotProps
|
|
170
159
|
};
|
|
171
160
|
const [RootSlot, rootProps] = (0, _useSlot.default)('root', {
|
|
172
161
|
ref,
|
|
@@ -181,11 +170,9 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
181
170
|
className: (0, _clsx.default)(className, classes?.root, !ownerState.open && ownerState.exited && classes?.hidden)
|
|
182
171
|
});
|
|
183
172
|
const [BackdropSlot, backdropProps] = (0, _useSlot.default)('backdrop', {
|
|
184
|
-
|
|
185
|
-
elementType: BackdropComponent,
|
|
173
|
+
elementType: ModalBackdrop,
|
|
186
174
|
externalForwardedProps,
|
|
187
175
|
shouldForwardComponentProp: true,
|
|
188
|
-
additionalProps: BackdropProps,
|
|
189
176
|
getSlotProps: otherHandlers => {
|
|
190
177
|
return getBackdropProps({
|
|
191
178
|
...otherHandlers,
|
|
@@ -196,7 +183,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
196
183
|
}
|
|
197
184
|
});
|
|
198
185
|
},
|
|
199
|
-
className:
|
|
186
|
+
className: classes?.backdrop,
|
|
200
187
|
ownerState
|
|
201
188
|
});
|
|
202
189
|
if (!keepMounted && !open && (!hasTransition || exited)) {
|
|
@@ -208,7 +195,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
208
195
|
disablePortal: disablePortal,
|
|
209
196
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(RootSlot, {
|
|
210
197
|
...rootProps,
|
|
211
|
-
children: [!hideBackdrop
|
|
198
|
+
children: [!hideBackdrop ? /*#__PURE__*/(0, _jsxRuntime.jsx)(BackdropSlot, {
|
|
212
199
|
...backdropProps
|
|
213
200
|
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Unstable_TrapFocus.default, {
|
|
214
201
|
disableEnforceFocus: disableEnforceFocus,
|
|
@@ -226,23 +213,6 @@ process.env.NODE_ENV !== "production" ? Modal.propTypes /* remove-proptypes */ =
|
|
|
226
213
|
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
227
214
|
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
228
215
|
// └─────────────────────────────────────────────────────────────────────┘
|
|
229
|
-
/**
|
|
230
|
-
* A backdrop component. This prop enables custom backdrop rendering.
|
|
231
|
-
* @deprecated Use `slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
|
|
232
|
-
* Use the `slots.backdrop` prop to make your application ready for the next version of Material UI.
|
|
233
|
-
* @default styled(Backdrop, {
|
|
234
|
-
* name: 'MuiModal',
|
|
235
|
-
* slot: 'Backdrop',
|
|
236
|
-
* })({
|
|
237
|
-
* zIndex: -1,
|
|
238
|
-
* })
|
|
239
|
-
*/
|
|
240
|
-
BackdropComponent: _propTypes.default.elementType,
|
|
241
|
-
/**
|
|
242
|
-
* Props applied to the [`Backdrop`](https://mui.com/material-ui/api/backdrop/) element.
|
|
243
|
-
* @deprecated Use `slotProps.backdrop` instead.
|
|
244
|
-
*/
|
|
245
|
-
BackdropProps: _propTypes.default.object,
|
|
246
216
|
/**
|
|
247
217
|
* A single child content element.
|
|
248
218
|
*/
|
|
@@ -265,29 +235,6 @@ process.env.NODE_ENV !== "production" ? Modal.propTypes /* remove-proptypes */ =
|
|
|
265
235
|
* Either a string to use a HTML element or a component.
|
|
266
236
|
*/
|
|
267
237
|
component: _propTypes.default.elementType,
|
|
268
|
-
/**
|
|
269
|
-
* The components used for each slot inside.
|
|
270
|
-
*
|
|
271
|
-
* @deprecated Use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
272
|
-
*
|
|
273
|
-
* @default {}
|
|
274
|
-
*/
|
|
275
|
-
components: _propTypes.default.shape({
|
|
276
|
-
Backdrop: _propTypes.default.elementType,
|
|
277
|
-
Root: _propTypes.default.elementType
|
|
278
|
-
}),
|
|
279
|
-
/**
|
|
280
|
-
* The extra props for the slot components.
|
|
281
|
-
* You can override the existing props or add new ones.
|
|
282
|
-
*
|
|
283
|
-
* @deprecated Use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
284
|
-
*
|
|
285
|
-
* @default {}
|
|
286
|
-
*/
|
|
287
|
-
componentsProps: _propTypes.default.shape({
|
|
288
|
-
backdrop: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
289
|
-
root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
|
290
|
-
}),
|
|
291
238
|
/**
|
|
292
239
|
* An HTML element or function that returns one.
|
|
293
240
|
* The `container` will have the portal children appended to it.
|