@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.
Files changed (308) hide show
  1. package/Accordion/Accordion.d.mts +1 -1
  2. package/Accordion/Accordion.d.ts +1 -1
  3. package/AccordionSummary/AccordionSummary.js +1 -0
  4. package/AccordionSummary/AccordionSummary.mjs +1 -0
  5. package/Backdrop/Backdrop.d.mts +1 -1
  6. package/Backdrop/Backdrop.d.ts +1 -1
  7. package/BottomNavigationAction/BottomNavigationAction.js +1 -0
  8. package/BottomNavigationAction/BottomNavigationAction.mjs +1 -0
  9. package/Breadcrumbs/BreadcrumbCollapsed.js +5 -1
  10. package/Breadcrumbs/BreadcrumbCollapsed.mjs +5 -1
  11. package/Button/Button.js +1 -0
  12. package/Button/Button.mjs +1 -0
  13. package/ButtonBase/ButtonBase.d.mts +5 -0
  14. package/ButtonBase/ButtonBase.d.ts +5 -0
  15. package/ButtonBase/ButtonBase.js +84 -85
  16. package/ButtonBase/ButtonBase.mjs +84 -85
  17. package/ButtonBase/useButtonBase.d.mts +91 -0
  18. package/ButtonBase/useButtonBase.d.ts +91 -0
  19. package/ButtonBase/useButtonBase.js +174 -0
  20. package/ButtonBase/useButtonBase.mjs +167 -0
  21. package/ButtonGroup/ButtonGroup.js +1 -9
  22. package/ButtonGroup/ButtonGroup.mjs +1 -9
  23. package/ButtonGroup/buttonGroupClasses.d.mts +0 -68
  24. package/ButtonGroup/buttonGroupClasses.d.ts +0 -68
  25. package/ButtonGroup/buttonGroupClasses.js +1 -1
  26. package/ButtonGroup/buttonGroupClasses.mjs +1 -1
  27. package/CHANGELOG.md +119 -4
  28. package/CardActionArea/CardActionArea.js +1 -0
  29. package/CardActionArea/CardActionArea.mjs +1 -0
  30. package/CardHeader/CardHeader.d.mts +13 -21
  31. package/CardHeader/CardHeader.d.ts +13 -21
  32. package/CardHeader/CardHeader.js +3 -21
  33. package/CardHeader/CardHeader.mjs +3 -21
  34. package/Checkbox/Checkbox.js +1 -7
  35. package/Checkbox/Checkbox.mjs +1 -7
  36. package/Chip/Chip.d.mts +7 -0
  37. package/Chip/Chip.d.ts +7 -0
  38. package/Chip/Chip.js +66 -55
  39. package/Chip/Chip.mjs +66 -55
  40. package/Chip/chipClasses.d.mts +0 -104
  41. package/Chip/chipClasses.d.ts +0 -104
  42. package/Chip/chipClasses.js +1 -1
  43. package/Chip/chipClasses.mjs +1 -1
  44. package/Dialog/Dialog.d.mts +8 -22
  45. package/Dialog/Dialog.d.ts +8 -22
  46. package/Dialog/Dialog.js +43 -72
  47. package/Dialog/Dialog.mjs +43 -72
  48. package/Dialog/dialogClasses.d.mts +0 -8
  49. package/Dialog/dialogClasses.d.ts +0 -8
  50. package/Dialog/dialogClasses.js +1 -1
  51. package/Dialog/dialogClasses.mjs +1 -1
  52. package/Divider/Divider.js +2 -10
  53. package/Divider/Divider.mjs +2 -10
  54. package/Divider/dividerClasses.d.mts +0 -4
  55. package/Divider/dividerClasses.d.ts +0 -4
  56. package/Divider/dividerClasses.js +1 -1
  57. package/Divider/dividerClasses.mjs +1 -1
  58. package/Drawer/Drawer.d.mts +1 -13
  59. package/Drawer/Drawer.d.ts +1 -13
  60. package/Drawer/Drawer.js +6 -40
  61. package/Drawer/Drawer.mjs +6 -40
  62. package/Drawer/drawerClasses.d.mts +0 -32
  63. package/Drawer/drawerClasses.d.ts +0 -32
  64. package/Drawer/drawerClasses.js +1 -1
  65. package/Drawer/drawerClasses.mjs +1 -1
  66. package/Fab/Fab.js +1 -0
  67. package/Fab/Fab.mjs +1 -0
  68. package/FilledInput/FilledInput.js +4 -33
  69. package/FilledInput/FilledInput.mjs +4 -33
  70. package/Grid/Grid.d.mts +8 -3
  71. package/Grid/Grid.d.ts +8 -3
  72. package/Grid/Grid.js +8 -3
  73. package/Grid/Grid.mjs +8 -3
  74. package/Grid/gridClasses.js +1 -1
  75. package/Grid/gridClasses.mjs +1 -1
  76. package/IconButton/IconButton.js +1 -0
  77. package/IconButton/IconButton.mjs +1 -0
  78. package/ImageListItemBar/ImageListItemBar.js +4 -17
  79. package/ImageListItemBar/ImageListItemBar.mjs +4 -17
  80. package/ImageListItemBar/imageListItemBarClasses.d.mts +0 -16
  81. package/ImageListItemBar/imageListItemBarClasses.d.ts +0 -16
  82. package/ImageListItemBar/imageListItemBarClasses.js +1 -1
  83. package/ImageListItemBar/imageListItemBarClasses.mjs +1 -1
  84. package/Input/Input.js +4 -33
  85. package/Input/Input.mjs +4 -33
  86. package/Input/inputClasses.d.mts +0 -16
  87. package/Input/inputClasses.d.ts +0 -16
  88. package/InputAdornment/inputAdornmentClasses.d.mts +2 -2
  89. package/InputAdornment/inputAdornmentClasses.d.ts +2 -2
  90. package/InputBase/InputBase.d.mts +0 -27
  91. package/InputBase/InputBase.d.ts +0 -27
  92. package/InputBase/InputBase.js +6 -35
  93. package/InputBase/InputBase.mjs +6 -35
  94. package/InputBase/inputBaseClasses.d.mts +0 -20
  95. package/InputBase/inputBaseClasses.d.ts +0 -20
  96. package/InputBase/inputBaseClasses.js +1 -1
  97. package/InputBase/inputBaseClasses.mjs +1 -1
  98. package/InputLabel/InputLabel.js +1 -1
  99. package/InputLabel/InputLabel.mjs +1 -1
  100. package/LinearProgress/LinearProgress.js +6 -18
  101. package/LinearProgress/LinearProgress.mjs +6 -18
  102. package/LinearProgress/linearProgressClasses.d.mts +0 -36
  103. package/LinearProgress/linearProgressClasses.d.ts +0 -36
  104. package/LinearProgress/linearProgressClasses.js +1 -1
  105. package/LinearProgress/linearProgressClasses.mjs +1 -1
  106. package/Link/Link.d.mts +1 -1
  107. package/Link/Link.d.ts +1 -1
  108. package/ListItem/ListItem.d.mts +2 -36
  109. package/ListItem/ListItem.d.ts +2 -36
  110. package/ListItem/ListItem.js +27 -152
  111. package/ListItem/ListItem.mjs +27 -152
  112. package/ListItem/listItemClasses.d.mts +2 -4
  113. package/ListItem/listItemClasses.d.ts +2 -4
  114. package/ListItem/listItemClasses.js +1 -1
  115. package/ListItem/listItemClasses.mjs +1 -1
  116. package/ListItemButton/ListItemButton.d.mts +1 -2
  117. package/ListItemButton/ListItemButton.d.ts +1 -2
  118. package/ListItemButton/ListItemButton.js +2 -2
  119. package/ListItemButton/ListItemButton.mjs +2 -2
  120. package/ListItemIcon/ListItemIcon.js +1 -1
  121. package/ListItemIcon/ListItemIcon.mjs +1 -1
  122. package/ListItemSecondaryAction/ListItemSecondaryAction.d.mts +10 -6
  123. package/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +10 -6
  124. package/ListItemSecondaryAction/ListItemSecondaryAction.js +7 -2
  125. package/ListItemSecondaryAction/ListItemSecondaryAction.mjs +7 -2
  126. package/ListItemText/ListItemText.d.mts +12 -20
  127. package/ListItemText/ListItemText.d.ts +12 -20
  128. package/ListItemText/ListItemText.js +2 -20
  129. package/ListItemText/ListItemText.mjs +2 -20
  130. package/ListSubheader/ListSubheader.js +0 -3
  131. package/ListSubheader/ListSubheader.mjs +0 -3
  132. package/Menu/Menu.d.mts +1 -1
  133. package/Menu/Menu.d.ts +1 -1
  134. package/Menu/Menu.js +15 -32
  135. package/Menu/Menu.mjs +15 -32
  136. package/MenuItem/MenuItem.js +36 -26
  137. package/MenuItem/MenuItem.mjs +34 -26
  138. package/MenuList/MenuList.js +136 -101
  139. package/MenuList/MenuList.mjs +135 -100
  140. package/MenuList/MenuListContext.d.mts +11 -0
  141. package/MenuList/MenuListContext.d.ts +11 -0
  142. package/MenuList/MenuListContext.js +25 -0
  143. package/MenuList/MenuListContext.mjs +19 -0
  144. package/Modal/Modal.d.mts +1 -41
  145. package/Modal/Modal.d.ts +1 -41
  146. package/Modal/Modal.js +5 -58
  147. package/Modal/Modal.mjs +5 -58
  148. package/OutlinedInput/OutlinedInput.js +2 -14
  149. package/OutlinedInput/OutlinedInput.mjs +2 -14
  150. package/OutlinedInput/outlinedInputClasses.d.mts +0 -16
  151. package/OutlinedInput/outlinedInputClasses.d.ts +0 -16
  152. package/PaginationItem/PaginationItem.d.mts +5 -15
  153. package/PaginationItem/PaginationItem.d.ts +5 -15
  154. package/PaginationItem/PaginationItem.js +9 -24
  155. package/PaginationItem/PaginationItem.mjs +9 -24
  156. package/PaginationItem/paginationItemClasses.d.mts +0 -16
  157. package/PaginationItem/paginationItemClasses.d.ts +0 -16
  158. package/PaginationItem/paginationItemClasses.js +1 -1
  159. package/PaginationItem/paginationItemClasses.mjs +1 -1
  160. package/PigmentGrid/PigmentGrid.d.mts +1 -1
  161. package/PigmentGrid/PigmentGrid.d.ts +1 -1
  162. package/PigmentGrid/PigmentGrid.js +1 -1
  163. package/PigmentGrid/PigmentGrid.mjs +1 -1
  164. package/Popover/Popover.d.mts +1 -1
  165. package/Popover/Popover.d.ts +1 -1
  166. package/Popover/Popover.js +19 -7
  167. package/Popover/Popover.mjs +18 -6
  168. package/Radio/Radio.js +1 -13
  169. package/Radio/Radio.mjs +1 -13
  170. package/Rating/Rating.d.mts +0 -9
  171. package/Rating/Rating.d.ts +0 -9
  172. package/Rating/Rating.js +1 -17
  173. package/Rating/Rating.mjs +1 -17
  174. package/Select/SelectInput.js +2 -3
  175. package/Select/SelectInput.mjs +2 -3
  176. package/Select/selectClasses.d.mts +0 -12
  177. package/Select/selectClasses.d.ts +0 -12
  178. package/Select/selectClasses.js +1 -1
  179. package/Select/selectClasses.mjs +1 -1
  180. package/Slider/Slider.d.mts +0 -5
  181. package/Slider/Slider.d.ts +0 -5
  182. package/Slider/Slider.js +2 -8
  183. package/Slider/Slider.mjs +2 -8
  184. package/Slider/sliderClasses.d.mts +0 -28
  185. package/Slider/sliderClasses.d.ts +0 -28
  186. package/Slider/sliderClasses.js +1 -1
  187. package/Slider/sliderClasses.mjs +1 -1
  188. package/Snackbar/Snackbar.d.mts +1 -1
  189. package/Snackbar/Snackbar.d.ts +1 -1
  190. package/SpeedDial/SpeedDial.d.mts +1 -1
  191. package/SpeedDial/SpeedDial.d.ts +1 -1
  192. package/Stack/Stack.d.mts +2 -2
  193. package/Stack/Stack.d.ts +2 -2
  194. package/StepButton/StepButton.js +44 -14
  195. package/StepButton/StepButton.mjs +44 -14
  196. package/StepConnector/StepConnector.js +2 -8
  197. package/StepConnector/StepConnector.mjs +2 -8
  198. package/StepConnector/stepConnectorClasses.d.mts +0 -8
  199. package/StepConnector/stepConnectorClasses.d.ts +0 -8
  200. package/StepConnector/stepConnectorClasses.js +1 -1
  201. package/StepConnector/stepConnectorClasses.mjs +1 -1
  202. package/StepContent/StepContent.d.mts +2 -17
  203. package/StepContent/StepContent.d.ts +2 -17
  204. package/StepContent/StepContent.js +3 -22
  205. package/StepContent/StepContent.mjs +3 -22
  206. package/StepLabel/StepLabel.d.mts +0 -22
  207. package/StepLabel/StepLabel.d.ts +0 -22
  208. package/StepLabel/StepLabel.js +2 -31
  209. package/StepLabel/StepLabel.mjs +2 -31
  210. package/Stepper/Stepper.js +54 -22
  211. package/Stepper/Stepper.mjs +54 -22
  212. package/Stepper/StepperContext.d.mts +0 -5
  213. package/Stepper/StepperContext.d.ts +0 -5
  214. package/Stepper/StepperContext.js +1 -2
  215. package/Stepper/StepperContext.mjs +0 -1
  216. package/SvgIcon/createSvgIcon.d.mts +2 -0
  217. package/SvgIcon/createSvgIcon.d.ts +2 -0
  218. package/SvgIcon/createSvgIcon.js +31 -0
  219. package/SvgIcon/createSvgIcon.mjs +26 -0
  220. package/SvgIcon/index.d.mts +1 -0
  221. package/SvgIcon/index.d.ts +1 -0
  222. package/SvgIcon/index.js +8 -0
  223. package/SvgIcon/index.mjs +1 -0
  224. package/SwipeableDrawer/SwipeableDrawer.d.mts +0 -5
  225. package/SwipeableDrawer/SwipeableDrawer.d.ts +0 -5
  226. package/SwipeableDrawer/SwipeableDrawer.js +6 -37
  227. package/SwipeableDrawer/SwipeableDrawer.mjs +6 -37
  228. package/Switch/Switch.js +0 -11
  229. package/Switch/Switch.mjs +0 -11
  230. package/Tab/Tab.js +18 -4
  231. package/Tab/Tab.mjs +18 -4
  232. package/Tab/tabClasses.d.mts +0 -4
  233. package/Tab/tabClasses.d.ts +0 -4
  234. package/Tab/tabClasses.js +1 -1
  235. package/Tab/tabClasses.mjs +1 -1
  236. package/TabScrollButton/TabScrollButton.d.mts +1 -1
  237. package/TabScrollButton/TabScrollButton.d.ts +1 -1
  238. package/TabScrollButton/TabScrollButton.js +6 -2
  239. package/TabScrollButton/TabScrollButton.mjs +6 -2
  240. package/TablePagination/TablePagination.d.mts +0 -24
  241. package/TablePagination/TablePagination.d.ts +0 -24
  242. package/TablePagination/TablePagination.js +1 -29
  243. package/TablePagination/TablePagination.mjs +1 -29
  244. package/TablePaginationActions/TablePaginationActions.d.mts +0 -10
  245. package/TablePaginationActions/TablePaginationActions.d.ts +0 -10
  246. package/TablePaginationActions/TablePaginationActions.js +2 -14
  247. package/TablePaginationActions/TablePaginationActions.mjs +2 -14
  248. package/TableSortLabel/TableSortLabel.js +6 -8
  249. package/TableSortLabel/TableSortLabel.mjs +6 -8
  250. package/TableSortLabel/tableSortLabelClasses.d.mts +0 -8
  251. package/TableSortLabel/tableSortLabelClasses.d.ts +0 -8
  252. package/TableSortLabel/tableSortLabelClasses.js +1 -1
  253. package/TableSortLabel/tableSortLabelClasses.mjs +1 -1
  254. package/Tabs/Tabs.js +33 -24
  255. package/Tabs/Tabs.mjs +32 -23
  256. package/Tabs/tabsClasses.d.mts +0 -6
  257. package/Tabs/tabsClasses.d.ts +0 -6
  258. package/Tabs/tabsClasses.js +1 -1
  259. package/Tabs/tabsClasses.mjs +1 -1
  260. package/ToggleButton/ToggleButton.js +1 -0
  261. package/ToggleButton/ToggleButton.mjs +1 -0
  262. package/ToggleButtonGroup/ToggleButtonGroup.js +1 -4
  263. package/ToggleButtonGroup/ToggleButtonGroup.mjs +1 -4
  264. package/ToggleButtonGroup/toggleButtonGroupClasses.d.mts +0 -8
  265. package/ToggleButtonGroup/toggleButtonGroupClasses.d.ts +0 -8
  266. package/ToggleButtonGroup/toggleButtonGroupClasses.js +1 -1
  267. package/ToggleButtonGroup/toggleButtonGroupClasses.mjs +1 -1
  268. package/Tooltip/Tooltip.d.mts +1 -1
  269. package/Tooltip/Tooltip.d.ts +1 -1
  270. package/Typography/Typography.d.mts +3 -3
  271. package/Typography/Typography.d.ts +3 -3
  272. package/Typography/Typography.js +2 -24
  273. package/Typography/Typography.mjs +3 -25
  274. package/index.js +1 -1
  275. package/index.mjs +1 -1
  276. package/internal/SwitchBase.d.mts +2 -12
  277. package/internal/SwitchBase.d.ts +2 -12
  278. package/internal/SwitchBase.js +6 -17
  279. package/internal/SwitchBase.mjs +6 -17
  280. package/locale/psAF.js +1 -1
  281. package/locale/psAF.mjs +1 -1
  282. package/package.json +7 -7
  283. package/styles/createThemeWithVars.js +10 -9
  284. package/styles/createThemeWithVars.mjs +10 -9
  285. package/styles/stringifyTheme.js +1 -1
  286. package/styles/stringifyTheme.mjs +1 -1
  287. package/useAutocomplete/useAutocomplete.js +8 -0
  288. package/useAutocomplete/useAutocomplete.mjs +8 -0
  289. package/utils/createSvgIcon.d.mts +4 -2
  290. package/utils/createSvgIcon.d.ts +4 -2
  291. package/utils/createSvgIcon.js +6 -24
  292. package/utils/createSvgIcon.mjs +2 -24
  293. package/utils/focusWithVisible.js +24 -0
  294. package/utils/focusWithVisible.mjs +19 -0
  295. package/utils/index.d.mts +0 -1
  296. package/utils/index.d.ts +0 -1
  297. package/utils/index.js +0 -7
  298. package/utils/index.mjs +0 -1
  299. package/utils/useFocusableWhenDisabled.d.mts +30 -0
  300. package/utils/useFocusableWhenDisabled.d.ts +30 -0
  301. package/utils/useFocusableWhenDisabled.js +47 -0
  302. package/utils/useFocusableWhenDisabled.mjs +41 -0
  303. package/utils/useRovingTabIndex.d.mts +1 -2
  304. package/utils/useRovingTabIndex.d.ts +1 -2
  305. package/utils/useRovingTabIndex.js +25 -4
  306. package/utils/useRovingTabIndex.mjs +1 -2
  307. package/version/index.js +2 -2
  308. package/version/index.mjs +2 -2
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
+ import { OverridableComponent, OverrideProps } from "../OverridableComponent/index.mjs";
3
4
  import { Theme } from "../styles/index.mjs";
4
- import { InternalStandardProps as StandardProps } from "../internal/index.mjs";
5
5
  import { ListItemSecondaryActionClasses } from "./listItemSecondaryActionClasses.mjs";
6
- export interface ListItemSecondaryActionProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
6
+ export interface ListItemSecondaryActionOwnProps {
7
7
  /**
8
8
  * The content of the component, normally an `IconButton` or selection control.
9
9
  */
@@ -17,7 +17,10 @@ export interface ListItemSecondaryActionProps extends StandardProps<React.HTMLAt
17
17
  */
18
18
  sx?: SxProps<Theme> | undefined;
19
19
  }
20
-
20
+ export interface ListItemSecondaryActionTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'div'> {
21
+ props: AdditionalProps & ListItemSecondaryActionOwnProps;
22
+ defaultComponent: RootComponent;
23
+ }
21
24
  /**
22
25
  * Must be used as the last child of ListItem to function properly.
23
26
  *
@@ -28,10 +31,11 @@ export interface ListItemSecondaryActionProps extends StandardProps<React.HTMLAt
28
31
  * API:
29
32
  *
30
33
  * - [ListItemSecondaryAction API](https://next.mui.com/material-ui/api/list-item-secondary-action/)
31
- *
32
- * @deprecated Use the `secondaryAction` prop in the `ListItem` component instead. This component 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.
33
34
  */
34
- declare const ListItemSecondaryAction: ((props: ListItemSecondaryActionProps) => React.JSX.Element) & {
35
+ declare const ListItemSecondaryAction: OverridableComponent<ListItemSecondaryActionTypeMap> & {
35
36
  muiName: string;
36
37
  };
38
+ export type ListItemSecondaryActionProps<RootComponent extends React.ElementType = ListItemSecondaryActionTypeMap['defaultComponent'], AdditionalProps = {}> = OverrideProps<ListItemSecondaryActionTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
39
+ component?: React.ElementType | undefined;
40
+ };
37
41
  export default ListItemSecondaryAction;
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
+ import { OverridableComponent, OverrideProps } from "../OverridableComponent/index.js";
3
4
  import { Theme } from "../styles/index.js";
4
- import { InternalStandardProps as StandardProps } from "../internal/index.js";
5
5
  import { ListItemSecondaryActionClasses } from "./listItemSecondaryActionClasses.js";
6
- export interface ListItemSecondaryActionProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
6
+ export interface ListItemSecondaryActionOwnProps {
7
7
  /**
8
8
  * The content of the component, normally an `IconButton` or selection control.
9
9
  */
@@ -17,7 +17,10 @@ export interface ListItemSecondaryActionProps extends StandardProps<React.HTMLAt
17
17
  */
18
18
  sx?: SxProps<Theme> | undefined;
19
19
  }
20
-
20
+ export interface ListItemSecondaryActionTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'div'> {
21
+ props: AdditionalProps & ListItemSecondaryActionOwnProps;
22
+ defaultComponent: RootComponent;
23
+ }
21
24
  /**
22
25
  * Must be used as the last child of ListItem to function properly.
23
26
  *
@@ -28,10 +31,11 @@ export interface ListItemSecondaryActionProps extends StandardProps<React.HTMLAt
28
31
  * API:
29
32
  *
30
33
  * - [ListItemSecondaryAction API](https://next.mui.com/material-ui/api/list-item-secondary-action/)
31
- *
32
- * @deprecated Use the `secondaryAction` prop in the `ListItem` component instead. This component 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.
33
34
  */
34
- declare const ListItemSecondaryAction: ((props: ListItemSecondaryActionProps) => React.JSX.Element) & {
35
+ declare const ListItemSecondaryAction: OverridableComponent<ListItemSecondaryActionTypeMap> & {
35
36
  muiName: string;
36
37
  };
38
+ export type ListItemSecondaryActionProps<RootComponent extends React.ElementType = ListItemSecondaryActionTypeMap['defaultComponent'], AdditionalProps = {}> = OverrideProps<ListItemSecondaryActionTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
39
+ component?: React.ElementType | undefined;
40
+ };
37
41
  export default ListItemSecondaryAction;
@@ -52,8 +52,6 @@ const ListItemSecondaryActionRoot = (0, _zeroStyled.styled)('div', {
52
52
 
53
53
  /**
54
54
  * Must be used as the last child of ListItem to function properly.
55
- *
56
- * @deprecated Use the `secondaryAction` prop in the `ListItem` component instead. This component 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.
57
55
  */
58
56
  const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemSecondaryAction(inProps, ref) {
59
57
  const props = (0, _DefaultPropsProvider.useDefaultProps)({
@@ -62,6 +60,7 @@ const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemS
62
60
  });
63
61
  const {
64
62
  className,
63
+ component,
65
64
  ...other
66
65
  } = props;
67
66
  const context = React.useContext(_ListContext.default);
@@ -71,6 +70,7 @@ const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemS
71
70
  };
72
71
  const classes = useUtilityClasses(ownerState);
73
72
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ListItemSecondaryActionRoot, {
73
+ as: component,
74
74
  className: (0, _clsx.default)(classes.root, className),
75
75
  ownerState: ownerState,
76
76
  ref: ref,
@@ -94,6 +94,11 @@ process.env.NODE_ENV !== "production" ? ListItemSecondaryAction.propTypes /* rem
94
94
  * @ignore
95
95
  */
96
96
  className: _propTypes.default.string,
97
+ /**
98
+ * The component used for the root node.
99
+ * Either a string to use a HTML element or a component.
100
+ */
101
+ component: _propTypes.default.elementType,
97
102
  /**
98
103
  * The system prop that allows defining system overrides as well as additional CSS styles.
99
104
  */
@@ -45,8 +45,6 @@ const ListItemSecondaryActionRoot = styled('div', {
45
45
 
46
46
  /**
47
47
  * Must be used as the last child of ListItem to function properly.
48
- *
49
- * @deprecated Use the `secondaryAction` prop in the `ListItem` component instead. This component 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.
50
48
  */
51
49
  const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemSecondaryAction(inProps, ref) {
52
50
  const props = useDefaultProps({
@@ -55,6 +53,7 @@ const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemS
55
53
  });
56
54
  const {
57
55
  className,
56
+ component,
58
57
  ...other
59
58
  } = props;
60
59
  const context = React.useContext(ListContext);
@@ -64,6 +63,7 @@ const ListItemSecondaryAction = /*#__PURE__*/React.forwardRef(function ListItemS
64
63
  };
65
64
  const classes = useUtilityClasses(ownerState);
66
65
  return /*#__PURE__*/_jsx(ListItemSecondaryActionRoot, {
66
+ as: component,
67
67
  className: clsx(classes.root, className),
68
68
  ownerState: ownerState,
69
69
  ref: ref,
@@ -87,6 +87,11 @@ process.env.NODE_ENV !== "production" ? ListItemSecondaryAction.propTypes /* rem
87
87
  * @ignore
88
88
  */
89
89
  className: PropTypes.string,
90
+ /**
91
+ * The component used for the root node.
92
+ * Either a string to use a HTML element or a component.
93
+ */
94
+ component: PropTypes.elementType,
90
95
  /**
91
96
  * The system prop that allows defining system overrides as well as additional CSS styles.
92
97
  */
@@ -22,7 +22,7 @@ export interface ListItemTextSlots {
22
22
  */
23
23
  secondary?: React.ElementType | undefined;
24
24
  }
25
- export type ListItemTextSlotsAndSlotProps = CreateSlotsAndSlotProps<ListItemTextSlots, {
25
+ export type ListItemTextSlotsAndSlotProps<PrimaryTypographyComponent extends React.ElementType = React.ElementType<TypographyProps<'span'>>, SecondaryTypographyComponent extends React.ElementType = React.ElementType<TypographyProps<'p'>>> = CreateSlotsAndSlotProps<ListItemTextSlots, {
26
26
  /**
27
27
  * Props forwarded to the root slot.
28
28
  * By default, the available props are based on `div` element.
@@ -32,15 +32,23 @@ export type ListItemTextSlotsAndSlotProps = CreateSlotsAndSlotProps<ListItemText
32
32
  * Props forwarded to the primary slot (as long as disableTypography is not `true`)
33
33
  * By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component
34
34
  */
35
- primary: SlotProps<React.ElementType<TypographyProps>, {}, ListItemTextOwnerState>;
35
+ primary: TypographyProps<PrimaryTypographyComponent, {
36
+ component?: PrimaryTypographyComponent | undefined;
37
+ }> | ((ownerState: ListItemTextOwnerState) => TypographyProps<PrimaryTypographyComponent, {
38
+ component?: PrimaryTypographyComponent | undefined;
39
+ }>);
36
40
  /**
37
41
  * Props forwarded to the secondary slot (as long as disableTypography is not `true`)
38
42
  * By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component
39
43
  */
40
- secondary: SlotProps<React.ElementType<TypographyProps>, {}, ListItemTextOwnerState>;
44
+ secondary: TypographyProps<SecondaryTypographyComponent, {
45
+ component?: SecondaryTypographyComponent | undefined;
46
+ }> | ((ownerState: ListItemTextOwnerState) => TypographyProps<SecondaryTypographyComponent, {
47
+ component?: SecondaryTypographyComponent | undefined;
48
+ }>);
41
49
  }>;
42
50
  export interface ListItemTextOwnerState extends ListItemTextProps {}
43
- export interface ListItemTextProps<PrimaryTypographyComponent extends React.ElementType = 'span', SecondaryTypographyComponent extends React.ElementType = 'p'> extends StandardProps<React.HTMLAttributes<HTMLDivElement>>, ListItemTextSlotsAndSlotProps {
51
+ export interface ListItemTextProps<PrimaryTypographyComponent extends React.ElementType = 'span', SecondaryTypographyComponent extends React.ElementType = 'p'> extends StandardProps<React.HTMLAttributes<HTMLDivElement>>, ListItemTextSlotsAndSlotProps<PrimaryTypographyComponent, SecondaryTypographyComponent> {
44
52
  /**
45
53
  * Alias for the `primary` prop.
46
54
  */
@@ -67,26 +75,10 @@ export interface ListItemTextProps<PrimaryTypographyComponent extends React.Elem
67
75
  * The main content element.
68
76
  */
69
77
  primary?: React.ReactNode;
70
- /**
71
- * These props will be forwarded to the primary typography component
72
- * (as long as disableTypography is not `true`).
73
- * @deprecated Use `slotProps.primary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
74
- */
75
- primaryTypographyProps?: TypographyProps<PrimaryTypographyComponent, {
76
- component?: PrimaryTypographyComponent | undefined;
77
- }> | undefined;
78
78
  /**
79
79
  * The secondary content element.
80
80
  */
81
81
  secondary?: React.ReactNode;
82
- /**
83
- * These props will be forwarded to the secondary typography component
84
- * (as long as disableTypography is not `true`).
85
- * @deprecated Use `slotProps.secondary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
86
- */
87
- secondaryTypographyProps?: TypographyProps<SecondaryTypographyComponent, {
88
- component?: SecondaryTypographyComponent | undefined;
89
- }> | undefined;
90
82
  /**
91
83
  * The system prop that allows defining system overrides as well as additional CSS styles.
92
84
  */
@@ -22,7 +22,7 @@ export interface ListItemTextSlots {
22
22
  */
23
23
  secondary?: React.ElementType | undefined;
24
24
  }
25
- export type ListItemTextSlotsAndSlotProps = CreateSlotsAndSlotProps<ListItemTextSlots, {
25
+ export type ListItemTextSlotsAndSlotProps<PrimaryTypographyComponent extends React.ElementType = React.ElementType<TypographyProps<'span'>>, SecondaryTypographyComponent extends React.ElementType = React.ElementType<TypographyProps<'p'>>> = CreateSlotsAndSlotProps<ListItemTextSlots, {
26
26
  /**
27
27
  * Props forwarded to the root slot.
28
28
  * By default, the available props are based on `div` element.
@@ -32,15 +32,23 @@ export type ListItemTextSlotsAndSlotProps = CreateSlotsAndSlotProps<ListItemText
32
32
  * Props forwarded to the primary slot (as long as disableTypography is not `true`)
33
33
  * By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component
34
34
  */
35
- primary: SlotProps<React.ElementType<TypographyProps>, {}, ListItemTextOwnerState>;
35
+ primary: TypographyProps<PrimaryTypographyComponent, {
36
+ component?: PrimaryTypographyComponent | undefined;
37
+ }> | ((ownerState: ListItemTextOwnerState) => TypographyProps<PrimaryTypographyComponent, {
38
+ component?: PrimaryTypographyComponent | undefined;
39
+ }>);
36
40
  /**
37
41
  * Props forwarded to the secondary slot (as long as disableTypography is not `true`)
38
42
  * By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component
39
43
  */
40
- secondary: SlotProps<React.ElementType<TypographyProps>, {}, ListItemTextOwnerState>;
44
+ secondary: TypographyProps<SecondaryTypographyComponent, {
45
+ component?: SecondaryTypographyComponent | undefined;
46
+ }> | ((ownerState: ListItemTextOwnerState) => TypographyProps<SecondaryTypographyComponent, {
47
+ component?: SecondaryTypographyComponent | undefined;
48
+ }>);
41
49
  }>;
42
50
  export interface ListItemTextOwnerState extends ListItemTextProps {}
43
- export interface ListItemTextProps<PrimaryTypographyComponent extends React.ElementType = 'span', SecondaryTypographyComponent extends React.ElementType = 'p'> extends StandardProps<React.HTMLAttributes<HTMLDivElement>>, ListItemTextSlotsAndSlotProps {
51
+ export interface ListItemTextProps<PrimaryTypographyComponent extends React.ElementType = 'span', SecondaryTypographyComponent extends React.ElementType = 'p'> extends StandardProps<React.HTMLAttributes<HTMLDivElement>>, ListItemTextSlotsAndSlotProps<PrimaryTypographyComponent, SecondaryTypographyComponent> {
44
52
  /**
45
53
  * Alias for the `primary` prop.
46
54
  */
@@ -67,26 +75,10 @@ export interface ListItemTextProps<PrimaryTypographyComponent extends React.Elem
67
75
  * The main content element.
68
76
  */
69
77
  primary?: React.ReactNode;
70
- /**
71
- * These props will be forwarded to the primary typography component
72
- * (as long as disableTypography is not `true`).
73
- * @deprecated Use `slotProps.primary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
74
- */
75
- primaryTypographyProps?: TypographyProps<PrimaryTypographyComponent, {
76
- component?: PrimaryTypographyComponent | undefined;
77
- }> | undefined;
78
78
  /**
79
79
  * The secondary content element.
80
80
  */
81
81
  secondary?: React.ReactNode;
82
- /**
83
- * These props will be forwarded to the secondary typography component
84
- * (as long as disableTypography is not `true`).
85
- * @deprecated Use `slotProps.secondary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
86
- */
87
- secondaryTypographyProps?: TypographyProps<SecondaryTypographyComponent, {
88
- component?: SecondaryTypographyComponent | undefined;
89
- }> | undefined;
90
82
  /**
91
83
  * The system prop that allows defining system overrides as well as additional CSS styles.
92
84
  */
@@ -86,9 +86,7 @@ const ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(inProps
86
86
  disableTypography = false,
87
87
  inset = false,
88
88
  primary: primaryProp,
89
- primaryTypographyProps,
90
89
  secondary: secondaryProp,
91
- secondaryTypographyProps,
92
90
  slots = {},
93
91
  slotProps = {},
94
92
  ...other
@@ -109,11 +107,7 @@ const ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(inProps
109
107
  const classes = useUtilityClasses(ownerState);
110
108
  const externalForwardedProps = {
111
109
  slots,
112
- slotProps: {
113
- primary: primaryTypographyProps,
114
- secondary: secondaryTypographyProps,
115
- ...slotProps
116
- }
110
+ slotProps
117
111
  };
118
112
  const [RootSlot, rootSlotProps] = (0, _useSlot.default)('root', {
119
113
  className: (0, _clsx.default)(classes.root, className),
@@ -193,27 +187,15 @@ process.env.NODE_ENV !== "production" ? ListItemText.propTypes /* remove-proptyp
193
187
  * The main content element.
194
188
  */
195
189
  primary: _propTypes.default.node,
196
- /**
197
- * These props will be forwarded to the primary typography component
198
- * (as long as disableTypography is not `true`).
199
- * @deprecated Use `slotProps.primary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
200
- */
201
- primaryTypographyProps: _propTypes.default.object,
202
190
  /**
203
191
  * The secondary content element.
204
192
  */
205
193
  secondary: _propTypes.default.node,
206
- /**
207
- * These props will be forwarded to the secondary typography component
208
- * (as long as disableTypography is not `true`).
209
- * @deprecated Use `slotProps.secondary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
210
- */
211
- secondaryTypographyProps: _propTypes.default.object,
212
194
  /**
213
195
  * The props used for each slot inside.
214
196
  * @default {}
215
197
  */
216
- slotProps: _propTypes.default.shape({
198
+ slotProps: _propTypes.default /* @typescript-to-proptypes-ignore */.shape({
217
199
  primary: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
218
200
  root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
219
201
  secondary: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
@@ -79,9 +79,7 @@ const ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(inProps
79
79
  disableTypography = false,
80
80
  inset = false,
81
81
  primary: primaryProp,
82
- primaryTypographyProps,
83
82
  secondary: secondaryProp,
84
- secondaryTypographyProps,
85
83
  slots = {},
86
84
  slotProps = {},
87
85
  ...other
@@ -102,11 +100,7 @@ const ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(inProps
102
100
  const classes = useUtilityClasses(ownerState);
103
101
  const externalForwardedProps = {
104
102
  slots,
105
- slotProps: {
106
- primary: primaryTypographyProps,
107
- secondary: secondaryTypographyProps,
108
- ...slotProps
109
- }
103
+ slotProps
110
104
  };
111
105
  const [RootSlot, rootSlotProps] = useSlot('root', {
112
106
  className: clsx(classes.root, className),
@@ -186,27 +180,15 @@ process.env.NODE_ENV !== "production" ? ListItemText.propTypes /* remove-proptyp
186
180
  * The main content element.
187
181
  */
188
182
  primary: PropTypes.node,
189
- /**
190
- * These props will be forwarded to the primary typography component
191
- * (as long as disableTypography is not `true`).
192
- * @deprecated Use `slotProps.primary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
193
- */
194
- primaryTypographyProps: PropTypes.object,
195
183
  /**
196
184
  * The secondary content element.
197
185
  */
198
186
  secondary: PropTypes.node,
199
- /**
200
- * These props will be forwarded to the secondary typography component
201
- * (as long as disableTypography is not `true`).
202
- * @deprecated Use `slotProps.secondary` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
203
- */
204
- secondaryTypographyProps: PropTypes.object,
205
187
  /**
206
188
  * The props used for each slot inside.
207
189
  * @default {}
208
190
  */
209
- slotProps: PropTypes.shape({
191
+ slotProps: PropTypes /* @typescript-to-proptypes-ignore */.shape({
210
192
  primary: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
211
193
  root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
212
194
  secondary: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
@@ -121,9 +121,6 @@ const ListSubheader = /*#__PURE__*/React.forwardRef(function ListSubheader(inPro
121
121
  ...other
122
122
  });
123
123
  });
124
- if (ListSubheader) {
125
- ListSubheader.muiSkipListHighlight = true;
126
- }
127
124
  process.env.NODE_ENV !== "production" ? ListSubheader.propTypes /* remove-proptypes */ = {
128
125
  // ┌────────────────────────────── Warning ──────────────────────────────┐
129
126
  // │ These PropTypes are generated from the TypeScript type definitions. │
@@ -114,9 +114,6 @@ const ListSubheader = /*#__PURE__*/React.forwardRef(function ListSubheader(inPro
114
114
  ...other
115
115
  });
116
116
  });
117
- if (ListSubheader) {
118
- ListSubheader.muiSkipListHighlight = true;
119
- }
120
117
  process.env.NODE_ENV !== "production" ? ListSubheader.propTypes /* remove-proptypes */ = {
121
118
  // ┌────────────────────────────── Warning ──────────────────────────────┐
122
119
  // │ These PropTypes are generated from the TypeScript type definitions. │
package/Menu/Menu.d.mts CHANGED
@@ -64,7 +64,7 @@ export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<MenuSlots, {
64
64
  */
65
65
  transition: SlotComponentProps<
66
66
  // use SlotComponentProps because transition slot does not support `component` and `sx` prop
67
- React.ElementType, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
67
+ React.ElementType<TransitionProps>, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
68
68
  /**
69
69
  * Props forwarded to the backdrop slot.
70
70
  * By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
package/Menu/Menu.d.ts CHANGED
@@ -64,7 +64,7 @@ export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<MenuSlots, {
64
64
  */
65
65
  transition: SlotComponentProps<
66
66
  // use SlotComponentProps because transition slot does not support `component` and `sx` prop
67
- React.ElementType, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
67
+ React.ElementType<TransitionProps>, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
68
68
  /**
69
69
  * Props forwarded to the backdrop slot.
70
70
  * By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
package/Menu/Menu.js CHANGED
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
8
8
  });
9
9
  exports.default = exports.MenuPaper = void 0;
10
10
  var React = _interopRequireWildcard(require("react"));
11
- var _reactIs = require("react-is");
12
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
12
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
14
13
  var _HTMLElementType = _interopRequireDefault(require("@mui/utils/HTMLElementType"));
@@ -92,13 +91,17 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
92
91
  variant
93
92
  };
94
93
  const classes = useUtilityClasses(ownerState);
95
- const autoFocusItem = autoFocus && !disableAutoFocusItem && open;
94
+ const shouldManageInitialFocus = autoFocus && open; // `&& open` prevents a Menu with `keepMounted={true}` from accidentally stealing focus
95
+ const shouldAutoFocusActiveItem = shouldManageInitialFocus && !disableAutoFocusItem;
96
96
  const menuListActionsRef = React.useRef(null);
97
97
  const handleEntering = (element, _isAppearing) => {
98
98
  if (menuListActionsRef.current) {
99
99
  menuListActionsRef.current.adjustStyleForScrollbar(element, {
100
100
  direction: isRtl ? 'rtl' : 'ltr'
101
101
  });
102
+ if (shouldManageInitialFocus) {
103
+ menuListActionsRef.current.focusInitialTarget?.();
104
+ }
102
105
  }
103
106
  };
104
107
  const handleListKeyDown = event => {
@@ -109,33 +112,6 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
109
112
  }
110
113
  }
111
114
  };
112
-
113
- /**
114
- * the index of the item should receive focus
115
- * in a `variant="selectedMenu"` it's the first `selected` item
116
- * otherwise it's the very first item.
117
- */
118
- let activeItemIndex = -1;
119
- // since we inject focus related props into children we have to do a lookahead
120
- // to check if there is a `selected` item. We're looking for the last `selected`
121
- // item and use the first valid item as a fallback
122
- React.Children.map(children, (child, index) => {
123
- if (! /*#__PURE__*/React.isValidElement(child)) {
124
- return;
125
- }
126
- if (process.env.NODE_ENV !== 'production') {
127
- if ((0, _reactIs.isFragment)(child)) {
128
- console.error(["MUI: The Menu component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
129
- }
130
- }
131
- if (!child.props.disabled) {
132
- if (variant === 'selectedMenu' && child.props.selected) {
133
- activeItemIndex = index;
134
- } else if (activeItemIndex === -1) {
135
- activeItemIndex = index;
136
- }
137
- }
138
- });
139
115
  const externalForwardedProps = {
140
116
  slots,
141
117
  slotProps
@@ -168,7 +144,14 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
168
144
  ownerState
169
145
  });
170
146
  const resolvedTransitionProps = typeof slotProps.transition === 'function' ? slotProps.transition(ownerState) : slotProps.transition;
171
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuRoot, {
147
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuRoot
148
+ // `disableAutoFocus={autoFocus}` is NOT a mistake
149
+ // - `autoFocus` means `Menu` will control focus and move it into `MenuList` or an active `MenuItem`
150
+ // - `disableAutoFocus` means disable `MenuRoot`s underlying `Popover`'s autoFocus handling
151
+ // This prevents `MenuList` and `Popover` from fighting each other to control focus.
152
+ // (This has nothing to do with DOM `autoFocus`)
153
+ , {
154
+ disableAutoFocus: autoFocus,
172
155
  onClose: onClose,
173
156
  anchorOrigin: {
174
157
  vertical: 'bottom',
@@ -201,8 +184,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
201
184
  classes: PopoverClasses,
202
185
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ListSlot, {
203
186
  actions: menuListActionsRef,
204
- autoFocus: autoFocus && (activeItemIndex === -1 || disableAutoFocusItem),
205
- autoFocusItem: autoFocusItem,
187
+ autoFocus: shouldManageInitialFocus,
188
+ autoFocusItem: shouldAutoFocusActiveItem,
206
189
  variant: variant,
207
190
  ...listSlotProps,
208
191
  children: children
package/Menu/Menu.mjs CHANGED
@@ -1,7 +1,6 @@
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
5
  import composeClasses from '@mui/utils/composeClasses';
7
6
  import HTMLElementType from '@mui/utils/HTMLElementType';
@@ -85,13 +84,17 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
85
84
  variant
86
85
  };
87
86
  const classes = useUtilityClasses(ownerState);
88
- const autoFocusItem = autoFocus && !disableAutoFocusItem && open;
87
+ const shouldManageInitialFocus = autoFocus && open; // `&& open` prevents a Menu with `keepMounted={true}` from accidentally stealing focus
88
+ const shouldAutoFocusActiveItem = shouldManageInitialFocus && !disableAutoFocusItem;
89
89
  const menuListActionsRef = React.useRef(null);
90
90
  const handleEntering = (element, _isAppearing) => {
91
91
  if (menuListActionsRef.current) {
92
92
  menuListActionsRef.current.adjustStyleForScrollbar(element, {
93
93
  direction: isRtl ? 'rtl' : 'ltr'
94
94
  });
95
+ if (shouldManageInitialFocus) {
96
+ menuListActionsRef.current.focusInitialTarget?.();
97
+ }
95
98
  }
96
99
  };
97
100
  const handleListKeyDown = event => {
@@ -102,33 +105,6 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
102
105
  }
103
106
  }
104
107
  };
105
-
106
- /**
107
- * the index of the item should receive focus
108
- * in a `variant="selectedMenu"` it's the first `selected` item
109
- * otherwise it's the very first item.
110
- */
111
- let activeItemIndex = -1;
112
- // since we inject focus related props into children we have to do a lookahead
113
- // to check if there is a `selected` item. We're looking for the last `selected`
114
- // item and use the first valid item as a fallback
115
- React.Children.map(children, (child, index) => {
116
- if (! /*#__PURE__*/React.isValidElement(child)) {
117
- return;
118
- }
119
- if (process.env.NODE_ENV !== 'production') {
120
- if (isFragment(child)) {
121
- console.error(["MUI: The Menu component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
122
- }
123
- }
124
- if (!child.props.disabled) {
125
- if (variant === 'selectedMenu' && child.props.selected) {
126
- activeItemIndex = index;
127
- } else if (activeItemIndex === -1) {
128
- activeItemIndex = index;
129
- }
130
- }
131
- });
132
108
  const externalForwardedProps = {
133
109
  slots,
134
110
  slotProps
@@ -161,7 +137,14 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
161
137
  ownerState
162
138
  });
163
139
  const resolvedTransitionProps = typeof slotProps.transition === 'function' ? slotProps.transition(ownerState) : slotProps.transition;
164
- return /*#__PURE__*/_jsx(MenuRoot, {
140
+ return /*#__PURE__*/_jsx(MenuRoot
141
+ // `disableAutoFocus={autoFocus}` is NOT a mistake
142
+ // - `autoFocus` means `Menu` will control focus and move it into `MenuList` or an active `MenuItem`
143
+ // - `disableAutoFocus` means disable `MenuRoot`s underlying `Popover`'s autoFocus handling
144
+ // This prevents `MenuList` and `Popover` from fighting each other to control focus.
145
+ // (This has nothing to do with DOM `autoFocus`)
146
+ , {
147
+ disableAutoFocus: autoFocus,
165
148
  onClose: onClose,
166
149
  anchorOrigin: {
167
150
  vertical: 'bottom',
@@ -194,8 +177,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
194
177
  classes: PopoverClasses,
195
178
  children: /*#__PURE__*/_jsx(ListSlot, {
196
179
  actions: menuListActionsRef,
197
- autoFocus: autoFocus && (activeItemIndex === -1 || disableAutoFocusItem),
198
- autoFocusItem: autoFocusItem,
180
+ autoFocus: shouldManageInitialFocus,
181
+ autoFocusItem: shouldAutoFocusActiveItem,
199
182
  variant: variant,
200
183
  ...listSlotProps,
201
184
  children: children