@mui/material 9.0.0-alpha.4 → 9.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/ButtonGroup/ButtonGroup.js +1 -9
  2. package/ButtonGroup/ButtonGroup.mjs +1 -9
  3. package/ButtonGroup/buttonGroupClasses.d.mts +0 -68
  4. package/ButtonGroup/buttonGroupClasses.d.ts +0 -68
  5. package/ButtonGroup/buttonGroupClasses.js +1 -1
  6. package/ButtonGroup/buttonGroupClasses.mjs +1 -1
  7. package/CHANGELOG.md +71 -4
  8. package/CardHeader/CardHeader.d.mts +13 -21
  9. package/CardHeader/CardHeader.d.ts +13 -21
  10. package/CardHeader/CardHeader.js +3 -21
  11. package/CardHeader/CardHeader.mjs +3 -21
  12. package/Checkbox/Checkbox.js +1 -7
  13. package/Checkbox/Checkbox.mjs +1 -7
  14. package/Chip/Chip.js +48 -54
  15. package/Chip/Chip.mjs +48 -54
  16. package/Chip/chipClasses.d.mts +0 -104
  17. package/Chip/chipClasses.d.ts +0 -104
  18. package/Chip/chipClasses.js +1 -1
  19. package/Chip/chipClasses.mjs +1 -1
  20. package/Dialog/Dialog.d.mts +0 -21
  21. package/Dialog/Dialog.d.ts +0 -21
  22. package/Dialog/Dialog.js +36 -73
  23. package/Dialog/Dialog.mjs +36 -73
  24. package/Dialog/dialogClasses.d.mts +0 -8
  25. package/Dialog/dialogClasses.d.ts +0 -8
  26. package/Dialog/dialogClasses.js +1 -1
  27. package/Dialog/dialogClasses.mjs +1 -1
  28. package/Divider/Divider.js +2 -2
  29. package/Divider/Divider.mjs +2 -2
  30. package/Divider/dividerClasses.d.mts +0 -4
  31. package/Divider/dividerClasses.d.ts +0 -4
  32. package/Divider/dividerClasses.js +1 -1
  33. package/Divider/dividerClasses.mjs +1 -1
  34. package/Drawer/Drawer.d.mts +0 -12
  35. package/Drawer/Drawer.d.ts +0 -12
  36. package/Drawer/Drawer.js +6 -40
  37. package/Drawer/Drawer.mjs +6 -40
  38. package/Drawer/drawerClasses.d.mts +0 -32
  39. package/Drawer/drawerClasses.d.ts +0 -32
  40. package/Drawer/drawerClasses.js +1 -1
  41. package/Drawer/drawerClasses.mjs +1 -1
  42. package/FilledInput/FilledInput.js +3 -32
  43. package/FilledInput/FilledInput.mjs +3 -32
  44. package/ImageListItemBar/ImageListItemBar.js +4 -17
  45. package/ImageListItemBar/ImageListItemBar.mjs +4 -17
  46. package/ImageListItemBar/imageListItemBarClasses.d.mts +0 -16
  47. package/ImageListItemBar/imageListItemBarClasses.d.ts +0 -16
  48. package/ImageListItemBar/imageListItemBarClasses.js +1 -1
  49. package/ImageListItemBar/imageListItemBarClasses.mjs +1 -1
  50. package/Input/Input.js +3 -32
  51. package/Input/Input.mjs +3 -32
  52. package/Input/inputClasses.d.mts +0 -16
  53. package/Input/inputClasses.d.ts +0 -16
  54. package/InputBase/InputBase.d.mts +0 -27
  55. package/InputBase/InputBase.d.ts +0 -27
  56. package/InputBase/InputBase.js +6 -35
  57. package/InputBase/InputBase.mjs +6 -35
  58. package/InputBase/inputBaseClasses.d.mts +0 -20
  59. package/InputBase/inputBaseClasses.d.ts +0 -20
  60. package/InputBase/inputBaseClasses.js +1 -1
  61. package/InputBase/inputBaseClasses.mjs +1 -1
  62. package/InputLabel/InputLabel.js +1 -1
  63. package/InputLabel/InputLabel.mjs +1 -1
  64. package/LinearProgress/LinearProgress.js +6 -18
  65. package/LinearProgress/LinearProgress.mjs +6 -18
  66. package/LinearProgress/linearProgressClasses.d.mts +0 -36
  67. package/LinearProgress/linearProgressClasses.d.ts +0 -36
  68. package/LinearProgress/linearProgressClasses.js +1 -1
  69. package/LinearProgress/linearProgressClasses.mjs +1 -1
  70. package/Link/Link.d.mts +1 -1
  71. package/Link/Link.d.ts +1 -1
  72. package/ListItem/ListItem.d.mts +2 -36
  73. package/ListItem/ListItem.d.ts +2 -36
  74. package/ListItem/ListItem.js +27 -152
  75. package/ListItem/ListItem.mjs +27 -152
  76. package/ListItem/listItemClasses.d.mts +2 -4
  77. package/ListItem/listItemClasses.d.ts +2 -4
  78. package/ListItem/listItemClasses.js +1 -1
  79. package/ListItem/listItemClasses.mjs +1 -1
  80. package/ListItemButton/ListItemButton.d.mts +1 -2
  81. package/ListItemButton/ListItemButton.d.ts +1 -2
  82. package/ListItemButton/ListItemButton.js +1 -2
  83. package/ListItemButton/ListItemButton.mjs +1 -2
  84. package/ListItemSecondaryAction/ListItemSecondaryAction.d.mts +10 -6
  85. package/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +10 -6
  86. package/ListItemSecondaryAction/ListItemSecondaryAction.js +7 -2
  87. package/ListItemSecondaryAction/ListItemSecondaryAction.mjs +7 -2
  88. package/ListItemText/ListItemText.d.mts +12 -20
  89. package/ListItemText/ListItemText.d.ts +12 -20
  90. package/ListItemText/ListItemText.js +2 -20
  91. package/ListItemText/ListItemText.mjs +2 -20
  92. package/Modal/Modal.d.mts +1 -41
  93. package/Modal/Modal.d.ts +1 -41
  94. package/Modal/Modal.js +5 -58
  95. package/Modal/Modal.mjs +5 -58
  96. package/OutlinedInput/OutlinedInput.js +2 -14
  97. package/OutlinedInput/OutlinedInput.mjs +2 -14
  98. package/OutlinedInput/outlinedInputClasses.d.mts +0 -16
  99. package/OutlinedInput/outlinedInputClasses.d.ts +0 -16
  100. package/PaginationItem/PaginationItem.d.mts +0 -15
  101. package/PaginationItem/PaginationItem.d.ts +0 -15
  102. package/PaginationItem/PaginationItem.js +3 -24
  103. package/PaginationItem/PaginationItem.mjs +3 -24
  104. package/PaginationItem/paginationItemClasses.d.mts +0 -16
  105. package/PaginationItem/paginationItemClasses.d.ts +0 -16
  106. package/PaginationItem/paginationItemClasses.js +1 -1
  107. package/PaginationItem/paginationItemClasses.mjs +1 -1
  108. package/Radio/Radio.js +1 -13
  109. package/Radio/Radio.mjs +1 -13
  110. package/Rating/Rating.d.mts +0 -9
  111. package/Rating/Rating.d.ts +0 -9
  112. package/Rating/Rating.js +1 -17
  113. package/Rating/Rating.mjs +1 -17
  114. package/Select/SelectInput.js +2 -3
  115. package/Select/SelectInput.mjs +2 -3
  116. package/Select/selectClasses.d.mts +0 -12
  117. package/Select/selectClasses.d.ts +0 -12
  118. package/Select/selectClasses.js +1 -1
  119. package/Select/selectClasses.mjs +1 -1
  120. package/Slider/Slider.d.mts +0 -5
  121. package/Slider/Slider.d.ts +0 -5
  122. package/Slider/Slider.js +2 -8
  123. package/Slider/Slider.mjs +2 -8
  124. package/Slider/sliderClasses.d.mts +0 -28
  125. package/Slider/sliderClasses.d.ts +0 -28
  126. package/Slider/sliderClasses.js +1 -1
  127. package/Slider/sliderClasses.mjs +1 -1
  128. package/Stack/Stack.d.mts +2 -2
  129. package/Stack/Stack.d.ts +2 -2
  130. package/StepConnector/StepConnector.js +2 -8
  131. package/StepConnector/StepConnector.mjs +2 -8
  132. package/StepConnector/stepConnectorClasses.d.mts +0 -8
  133. package/StepConnector/stepConnectorClasses.d.ts +0 -8
  134. package/StepConnector/stepConnectorClasses.js +1 -1
  135. package/StepConnector/stepConnectorClasses.mjs +1 -1
  136. package/StepContent/StepContent.d.mts +1 -16
  137. package/StepContent/StepContent.d.ts +1 -16
  138. package/StepContent/StepContent.js +3 -22
  139. package/StepContent/StepContent.mjs +3 -22
  140. package/StepLabel/StepLabel.d.mts +0 -22
  141. package/StepLabel/StepLabel.d.ts +0 -22
  142. package/StepLabel/StepLabel.js +2 -31
  143. package/StepLabel/StepLabel.mjs +2 -31
  144. package/SvgIcon/createSvgIcon.d.mts +2 -0
  145. package/SvgIcon/createSvgIcon.d.ts +2 -0
  146. package/SvgIcon/createSvgIcon.js +31 -0
  147. package/SvgIcon/createSvgIcon.mjs +26 -0
  148. package/SvgIcon/index.d.mts +1 -0
  149. package/SvgIcon/index.d.ts +1 -0
  150. package/SvgIcon/index.js +8 -0
  151. package/SvgIcon/index.mjs +1 -0
  152. package/SwipeableDrawer/SwipeableDrawer.d.mts +0 -5
  153. package/SwipeableDrawer/SwipeableDrawer.d.ts +0 -5
  154. package/SwipeableDrawer/SwipeableDrawer.js +6 -37
  155. package/SwipeableDrawer/SwipeableDrawer.mjs +6 -37
  156. package/Switch/Switch.js +0 -11
  157. package/Switch/Switch.mjs +0 -11
  158. package/Tab/Tab.js +1 -3
  159. package/Tab/Tab.mjs +1 -3
  160. package/Tab/tabClasses.d.mts +0 -4
  161. package/Tab/tabClasses.d.ts +0 -4
  162. package/Tab/tabClasses.js +1 -1
  163. package/Tab/tabClasses.mjs +1 -1
  164. package/TablePagination/TablePagination.d.mts +0 -24
  165. package/TablePagination/TablePagination.d.ts +0 -24
  166. package/TablePagination/TablePagination.js +1 -29
  167. package/TablePagination/TablePagination.mjs +1 -29
  168. package/TablePaginationActions/TablePaginationActions.d.mts +0 -10
  169. package/TablePaginationActions/TablePaginationActions.d.ts +0 -10
  170. package/TablePaginationActions/TablePaginationActions.js +2 -14
  171. package/TablePaginationActions/TablePaginationActions.mjs +2 -14
  172. package/TableSortLabel/TableSortLabel.js +2 -7
  173. package/TableSortLabel/TableSortLabel.mjs +2 -7
  174. package/TableSortLabel/tableSortLabelClasses.d.mts +0 -8
  175. package/TableSortLabel/tableSortLabelClasses.d.ts +0 -8
  176. package/TableSortLabel/tableSortLabelClasses.js +1 -1
  177. package/TableSortLabel/tableSortLabelClasses.mjs +1 -1
  178. package/Tabs/Tabs.js +3 -3
  179. package/Tabs/Tabs.mjs +3 -3
  180. package/Tabs/tabsClasses.d.mts +0 -6
  181. package/Tabs/tabsClasses.d.ts +0 -6
  182. package/Tabs/tabsClasses.js +1 -1
  183. package/Tabs/tabsClasses.mjs +1 -1
  184. package/ToggleButtonGroup/ToggleButtonGroup.js +1 -4
  185. package/ToggleButtonGroup/ToggleButtonGroup.mjs +1 -4
  186. package/ToggleButtonGroup/toggleButtonGroupClasses.d.mts +0 -8
  187. package/ToggleButtonGroup/toggleButtonGroupClasses.d.ts +0 -8
  188. package/ToggleButtonGroup/toggleButtonGroupClasses.js +1 -1
  189. package/ToggleButtonGroup/toggleButtonGroupClasses.mjs +1 -1
  190. package/Typography/Typography.d.mts +3 -3
  191. package/Typography/Typography.d.ts +3 -3
  192. package/Typography/Typography.js +2 -24
  193. package/Typography/Typography.mjs +3 -25
  194. package/index.js +1 -1
  195. package/index.mjs +1 -1
  196. package/internal/SwitchBase.d.mts +0 -10
  197. package/internal/SwitchBase.d.ts +0 -10
  198. package/internal/SwitchBase.js +1 -16
  199. package/internal/SwitchBase.mjs +1 -16
  200. package/package.json +7 -7
  201. package/styles/createThemeWithVars.js +1 -0
  202. package/styles/createThemeWithVars.mjs +1 -0
  203. package/styles/stringifyTheme.js +1 -1
  204. package/styles/stringifyTheme.mjs +1 -1
  205. package/utils/createSvgIcon.d.mts +4 -2
  206. package/utils/createSvgIcon.d.ts +4 -2
  207. package/utils/createSvgIcon.js +6 -24
  208. package/utils/createSvgIcon.mjs +2 -24
  209. package/version/index.js +2 -2
  210. package/version/index.mjs +2 -2
@@ -11,14 +11,9 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _clsx = _interopRequireDefault(require("clsx"));
13
13
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
14
- var _elementTypeAcceptingRef = _interopRequireDefault(require("@mui/utils/elementTypeAcceptingRef"));
15
- var _chainPropTypes = _interopRequireDefault(require("@mui/utils/chainPropTypes"));
16
- var _isHostComponent = _interopRequireDefault(require("@mui/utils/isHostComponent"));
17
14
  var _zeroStyled = require("../zero-styled");
18
15
  var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
19
16
  var _DefaultPropsProvider = require("../DefaultPropsProvider");
20
- var _isMuiElement = _interopRequireDefault(require("../utils/isMuiElement"));
21
- var _useForkRef = _interopRequireDefault(require("../utils/useForkRef"));
22
17
  var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
23
18
  var _ListContext = _interopRequireDefault(require("../List/ListContext"));
24
19
  var _listItemClasses = require("./listItemClasses");
@@ -29,7 +24,7 @@ const overridesResolver = (props, styles) => {
29
24
  const {
30
25
  ownerState
31
26
  } = props;
32
- return [styles.root, ownerState.dense && styles.dense, ownerState.alignItems === 'flex-start' && styles.alignItemsFlexStart, ownerState.divider && styles.divider, !ownerState.disableGutters && styles.gutters, !ownerState.disablePadding && styles.padding, ownerState.hasSecondaryAction && styles.secondaryAction];
27
+ return [styles.root, ownerState.dense && styles.dense, ownerState.alignItems === 'flex-start' && styles.alignItemsFlexStart, ownerState.divider && styles.divider, !ownerState.disableGutters && styles.gutters, !ownerState.disablePadding && styles.padding];
33
28
  };
34
29
  exports.overridesResolver = overridesResolver;
35
30
  const useUtilityClasses = ownerState => {
@@ -39,12 +34,10 @@ const useUtilityClasses = ownerState => {
39
34
  dense,
40
35
  disableGutters,
41
36
  disablePadding,
42
- divider,
43
- hasSecondaryAction
37
+ divider
44
38
  } = ownerState;
45
39
  const slots = {
46
- root: ['root', dense && 'dense', !disableGutters && 'gutters', !disablePadding && 'padding', divider && 'divider', alignItems === 'flex-start' && 'alignItemsFlexStart', hasSecondaryAction && 'secondaryAction'],
47
- container: ['container'],
40
+ root: ['root', dense && 'dense', !disableGutters && 'gutters', !disablePadding && 'padding', divider && 'divider', alignItems === 'flex-start' && 'alignItemsFlexStart'],
48
41
  secondaryAction: ['secondaryAction']
49
42
  };
50
43
  return (0, _composeClasses.default)(slots, _listItemClasses.getListItemUtilityClass, classes);
@@ -138,27 +131,13 @@ const ListItemRoot = exports.ListItemRoot = (0, _zeroStyled.styled)('div', {
138
131
  }
139
132
  }
140
133
  }
141
- }, {
142
- props: ({
143
- ownerState
144
- }) => ownerState.hasSecondaryAction,
145
- style: {
146
- // Add some space to avoid collision as `ListItemSecondaryAction`
147
- // is absolutely positioned.
148
- paddingRight: 48
149
- }
150
134
  }]
151
135
  })));
152
- const ListItemContainer = (0, _zeroStyled.styled)('li', {
136
+ const StyledListItemSecondaryAction = (0, _zeroStyled.styled)(_ListItemSecondaryAction.default, {
153
137
  name: 'MuiListItem',
154
- slot: 'Container'
155
- })({
156
- position: 'relative'
157
- });
158
-
159
- /**
160
- * Uses an additional container component if `ListItemSecondaryAction` is the last child.
161
- */
138
+ slot: 'secondaryAction',
139
+ overridesResolver: (props, styles) => styles.secondaryAction
140
+ })({});
162
141
  const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
163
142
  const props = (0, _DefaultPropsProvider.useDefaultProps)({
164
143
  props: inProps,
@@ -168,14 +147,7 @@ const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
168
147
  alignItems = 'center',
169
148
  children: childrenProp,
170
149
  className,
171
- component: componentProp,
172
- components = {},
173
- componentsProps = {},
174
- ContainerComponent = 'li',
175
- ContainerProps: {
176
- className: ContainerClassName,
177
- ...ContainerProps
178
- } = {},
150
+ component: componentProp = 'li',
179
151
  dense = false,
180
152
  disableGutters = false,
181
153
  disablePadding = false,
@@ -191,11 +163,6 @@ const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
191
163
  alignItems,
192
164
  disableGutters
193
165
  }), [alignItems, context.dense, dense, disableGutters]);
194
- const listItemRef = React.useRef(null);
195
- const children = React.Children.toArray(childrenProp);
196
-
197
- // v4 implementation, deprecated in v6, will be removed in a future major release
198
- const hasSecondaryAction = children.length && (0, _isMuiElement.default)(children[children.length - 1], ['ListItemSecondaryAction']);
199
166
  const ownerState = {
200
167
  ...props,
201
168
  alignItems,
@@ -203,78 +170,36 @@ const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
203
170
  disableGutters,
204
171
  disablePadding,
205
172
  divider,
206
- hasSecondaryAction
173
+ secondaryAction
207
174
  };
208
175
  const classes = useUtilityClasses(ownerState);
209
- const handleRef = (0, _useForkRef.default)(listItemRef, ref);
210
176
  const externalForwardedProps = {
211
177
  slots,
212
178
  slotProps
213
179
  };
180
+ const [RootSlot, rootSlotProps] = (0, _useSlot.default)('root', {
181
+ ref,
182
+ elementType: ListItemRoot,
183
+ externalForwardedProps: {
184
+ component: componentProp,
185
+ ...externalForwardedProps,
186
+ ...other
187
+ },
188
+ ownerState,
189
+ className: (0, _clsx.default)(classes.root, className)
190
+ });
214
191
  const [SecondaryActionSlot, secondaryActionSlotProps] = (0, _useSlot.default)('secondaryAction', {
215
- elementType: _ListItemSecondaryAction.default,
192
+ elementType: StyledListItemSecondaryAction,
193
+ shouldForwardComponentProp: true,
216
194
  externalForwardedProps,
217
195
  ownerState,
218
196
  className: classes.secondaryAction
219
197
  });
220
- const Root = slots.root || components.Root || ListItemRoot;
221
- const rootProps = slotProps.root || componentsProps.root || {};
222
- const componentProps = {
223
- className: (0, _clsx.default)(classes.root, rootProps.className, className),
224
- ...other
225
- };
226
- let Component = componentProp || 'li';
227
-
228
- // v4 implementation, deprecated in v6, will be removed in a future major release
229
- if (hasSecondaryAction) {
230
- // Use div by default.
231
- Component = !componentProps.component && !componentProp ? 'div' : Component;
232
-
233
- // Avoid nesting of li > li.
234
- if (ContainerComponent === 'li') {
235
- if (Component === 'li') {
236
- Component = 'div';
237
- } else if (componentProps.component === 'li') {
238
- componentProps.component = 'div';
239
- }
240
- }
241
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListContext.default.Provider, {
242
- value: childContext,
243
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ListItemContainer, {
244
- as: ContainerComponent,
245
- className: (0, _clsx.default)(classes.container, ContainerClassName),
246
- ref: handleRef,
247
- ownerState: ownerState,
248
- ...ContainerProps,
249
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
250
- ...rootProps,
251
- ...(!(0, _isHostComponent.default)(Root) && {
252
- as: Component,
253
- ownerState: {
254
- ...ownerState,
255
- ...rootProps.ownerState
256
- }
257
- }),
258
- ...componentProps,
259
- children: children
260
- }), children.pop()]
261
- })
262
- });
263
- }
264
198
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListContext.default.Provider, {
265
199
  value: childContext,
266
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Root, {
267
- ...rootProps,
268
- as: Component,
269
- ref: handleRef,
270
- ...(!(0, _isHostComponent.default)(Root) && {
271
- ownerState: {
272
- ...ownerState,
273
- ...rootProps.ownerState
274
- }
275
- }),
276
- ...componentProps,
277
- children: [children, secondaryAction && /*#__PURE__*/(0, _jsxRuntime.jsx)(SecondaryActionSlot, {
200
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(RootSlot, {
201
+ ...rootSlotProps,
202
+ children: [childrenProp, secondaryAction && /*#__PURE__*/(0, _jsxRuntime.jsx)(SecondaryActionSlot, {
278
203
  ...secondaryActionSlotProps,
279
204
  children: secondaryAction
280
205
  })]
@@ -292,28 +217,9 @@ process.env.NODE_ENV !== "production" ? ListItem.propTypes /* remove-proptypes *
292
217
  */
293
218
  alignItems: _propTypes.default.oneOf(['center', 'flex-start']),
294
219
  /**
295
- * The content of the component if a `ListItemSecondaryAction` is used it must
296
- * be the last child.
220
+ * The content of the component.
297
221
  */
298
- children: (0, _chainPropTypes.default)(_propTypes.default.node, props => {
299
- const children = React.Children.toArray(props.children);
300
-
301
- // React.Children.toArray(props.children).findLastIndex(isListItemSecondaryAction)
302
- let secondaryActionIndex = -1;
303
- for (let i = children.length - 1; i >= 0; i -= 1) {
304
- const child = children[i];
305
- if ((0, _isMuiElement.default)(child, ['ListItemSecondaryAction'])) {
306
- secondaryActionIndex = i;
307
- break;
308
- }
309
- }
310
-
311
- // is ListItemSecondaryAction the last child of ListItem
312
- if (secondaryActionIndex !== -1 && secondaryActionIndex !== children.length - 1) {
313
- return new Error('MUI: You used an element after ListItemSecondaryAction. ' + 'For ListItem to detect that it has a secondary action ' + 'you must pass it as the last child to ListItem.');
314
- }
315
- return null;
316
- }),
222
+ children: _propTypes.default.node,
317
223
  /**
318
224
  * Override or extend the styles applied to the component.
319
225
  */
@@ -327,37 +233,6 @@ process.env.NODE_ENV !== "production" ? ListItem.propTypes /* remove-proptypes *
327
233
  * Either a string to use a HTML element or a component.
328
234
  */
329
235
  component: _propTypes.default.elementType,
330
- /**
331
- * The components used for each slot inside.
332
- *
333
- * @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.
334
- * @default {}
335
- */
336
- components: _propTypes.default.shape({
337
- Root: _propTypes.default.elementType
338
- }),
339
- /**
340
- * The extra props for the slot components.
341
- * You can override the existing props or add new ones.
342
- *
343
- * @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.
344
- * @default {}
345
- */
346
- componentsProps: _propTypes.default.shape({
347
- root: _propTypes.default.object
348
- }),
349
- /**
350
- * The container component used when a `ListItemSecondaryAction` is the last child.
351
- * @default 'li'
352
- * @deprecated Use the `component` or `slots.root` 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.
353
- */
354
- ContainerComponent: _elementTypeAcceptingRef.default,
355
- /**
356
- * Props applied to the container component if used.
357
- * @default {}
358
- * @deprecated Use the `slotProps.root` 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.
359
- */
360
- ContainerProps: _propTypes.default.object,
361
236
  /**
362
237
  * If `true`, compact vertical padding designed for keyboard and mouse input is used.
363
238
  * The prop defaults to the value inherited from the parent List component.
@@ -4,14 +4,9 @@ import * as React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import clsx from 'clsx';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
- import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
8
- import chainPropTypes from '@mui/utils/chainPropTypes';
9
- import isHostComponent from '@mui/utils/isHostComponent';
10
7
  import { styled } from "../zero-styled/index.mjs";
11
8
  import memoTheme from "../utils/memoTheme.mjs";
12
9
  import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
13
- import isMuiElement from "../utils/isMuiElement.mjs";
14
- import useForkRef from "../utils/useForkRef.mjs";
15
10
  import useSlot from "../utils/useSlot.mjs";
16
11
  import ListContext from "../List/ListContext.mjs";
17
12
  import { getListItemUtilityClass } from "./listItemClasses.mjs";
@@ -22,7 +17,7 @@ export const overridesResolver = (props, styles) => {
22
17
  const {
23
18
  ownerState
24
19
  } = props;
25
- return [styles.root, ownerState.dense && styles.dense, ownerState.alignItems === 'flex-start' && styles.alignItemsFlexStart, ownerState.divider && styles.divider, !ownerState.disableGutters && styles.gutters, !ownerState.disablePadding && styles.padding, ownerState.hasSecondaryAction && styles.secondaryAction];
20
+ return [styles.root, ownerState.dense && styles.dense, ownerState.alignItems === 'flex-start' && styles.alignItemsFlexStart, ownerState.divider && styles.divider, !ownerState.disableGutters && styles.gutters, !ownerState.disablePadding && styles.padding];
26
21
  };
27
22
  const useUtilityClasses = ownerState => {
28
23
  const {
@@ -31,12 +26,10 @@ const useUtilityClasses = ownerState => {
31
26
  dense,
32
27
  disableGutters,
33
28
  disablePadding,
34
- divider,
35
- hasSecondaryAction
29
+ divider
36
30
  } = ownerState;
37
31
  const slots = {
38
- root: ['root', dense && 'dense', !disableGutters && 'gutters', !disablePadding && 'padding', divider && 'divider', alignItems === 'flex-start' && 'alignItemsFlexStart', hasSecondaryAction && 'secondaryAction'],
39
- container: ['container'],
32
+ root: ['root', dense && 'dense', !disableGutters && 'gutters', !disablePadding && 'padding', divider && 'divider', alignItems === 'flex-start' && 'alignItemsFlexStart'],
40
33
  secondaryAction: ['secondaryAction']
41
34
  };
42
35
  return composeClasses(slots, getListItemUtilityClass, classes);
@@ -130,27 +123,13 @@ export const ListItemRoot = styled('div', {
130
123
  }
131
124
  }
132
125
  }
133
- }, {
134
- props: ({
135
- ownerState
136
- }) => ownerState.hasSecondaryAction,
137
- style: {
138
- // Add some space to avoid collision as `ListItemSecondaryAction`
139
- // is absolutely positioned.
140
- paddingRight: 48
141
- }
142
126
  }]
143
127
  })));
144
- const ListItemContainer = styled('li', {
128
+ const StyledListItemSecondaryAction = styled(ListItemSecondaryAction, {
145
129
  name: 'MuiListItem',
146
- slot: 'Container'
147
- })({
148
- position: 'relative'
149
- });
150
-
151
- /**
152
- * Uses an additional container component if `ListItemSecondaryAction` is the last child.
153
- */
130
+ slot: 'secondaryAction',
131
+ overridesResolver: (props, styles) => styles.secondaryAction
132
+ })({});
154
133
  const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
155
134
  const props = useDefaultProps({
156
135
  props: inProps,
@@ -160,14 +139,7 @@ const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
160
139
  alignItems = 'center',
161
140
  children: childrenProp,
162
141
  className,
163
- component: componentProp,
164
- components = {},
165
- componentsProps = {},
166
- ContainerComponent = 'li',
167
- ContainerProps: {
168
- className: ContainerClassName,
169
- ...ContainerProps
170
- } = {},
142
+ component: componentProp = 'li',
171
143
  dense = false,
172
144
  disableGutters = false,
173
145
  disablePadding = false,
@@ -183,11 +155,6 @@ const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
183
155
  alignItems,
184
156
  disableGutters
185
157
  }), [alignItems, context.dense, dense, disableGutters]);
186
- const listItemRef = React.useRef(null);
187
- const children = React.Children.toArray(childrenProp);
188
-
189
- // v4 implementation, deprecated in v6, will be removed in a future major release
190
- const hasSecondaryAction = children.length && isMuiElement(children[children.length - 1], ['ListItemSecondaryAction']);
191
158
  const ownerState = {
192
159
  ...props,
193
160
  alignItems,
@@ -195,78 +162,36 @@ const ListItem = /*#__PURE__*/React.forwardRef(function ListItem(inProps, ref) {
195
162
  disableGutters,
196
163
  disablePadding,
197
164
  divider,
198
- hasSecondaryAction
165
+ secondaryAction
199
166
  };
200
167
  const classes = useUtilityClasses(ownerState);
201
- const handleRef = useForkRef(listItemRef, ref);
202
168
  const externalForwardedProps = {
203
169
  slots,
204
170
  slotProps
205
171
  };
172
+ const [RootSlot, rootSlotProps] = useSlot('root', {
173
+ ref,
174
+ elementType: ListItemRoot,
175
+ externalForwardedProps: {
176
+ component: componentProp,
177
+ ...externalForwardedProps,
178
+ ...other
179
+ },
180
+ ownerState,
181
+ className: clsx(classes.root, className)
182
+ });
206
183
  const [SecondaryActionSlot, secondaryActionSlotProps] = useSlot('secondaryAction', {
207
- elementType: ListItemSecondaryAction,
184
+ elementType: StyledListItemSecondaryAction,
185
+ shouldForwardComponentProp: true,
208
186
  externalForwardedProps,
209
187
  ownerState,
210
188
  className: classes.secondaryAction
211
189
  });
212
- const Root = slots.root || components.Root || ListItemRoot;
213
- const rootProps = slotProps.root || componentsProps.root || {};
214
- const componentProps = {
215
- className: clsx(classes.root, rootProps.className, className),
216
- ...other
217
- };
218
- let Component = componentProp || 'li';
219
-
220
- // v4 implementation, deprecated in v6, will be removed in a future major release
221
- if (hasSecondaryAction) {
222
- // Use div by default.
223
- Component = !componentProps.component && !componentProp ? 'div' : Component;
224
-
225
- // Avoid nesting of li > li.
226
- if (ContainerComponent === 'li') {
227
- if (Component === 'li') {
228
- Component = 'div';
229
- } else if (componentProps.component === 'li') {
230
- componentProps.component = 'div';
231
- }
232
- }
233
- return /*#__PURE__*/_jsx(ListContext.Provider, {
234
- value: childContext,
235
- children: /*#__PURE__*/_jsxs(ListItemContainer, {
236
- as: ContainerComponent,
237
- className: clsx(classes.container, ContainerClassName),
238
- ref: handleRef,
239
- ownerState: ownerState,
240
- ...ContainerProps,
241
- children: [/*#__PURE__*/_jsx(Root, {
242
- ...rootProps,
243
- ...(!isHostComponent(Root) && {
244
- as: Component,
245
- ownerState: {
246
- ...ownerState,
247
- ...rootProps.ownerState
248
- }
249
- }),
250
- ...componentProps,
251
- children: children
252
- }), children.pop()]
253
- })
254
- });
255
- }
256
190
  return /*#__PURE__*/_jsx(ListContext.Provider, {
257
191
  value: childContext,
258
- children: /*#__PURE__*/_jsxs(Root, {
259
- ...rootProps,
260
- as: Component,
261
- ref: handleRef,
262
- ...(!isHostComponent(Root) && {
263
- ownerState: {
264
- ...ownerState,
265
- ...rootProps.ownerState
266
- }
267
- }),
268
- ...componentProps,
269
- children: [children, secondaryAction && /*#__PURE__*/_jsx(SecondaryActionSlot, {
192
+ children: /*#__PURE__*/_jsxs(RootSlot, {
193
+ ...rootSlotProps,
194
+ children: [childrenProp, secondaryAction && /*#__PURE__*/_jsx(SecondaryActionSlot, {
270
195
  ...secondaryActionSlotProps,
271
196
  children: secondaryAction
272
197
  })]
@@ -284,28 +209,9 @@ process.env.NODE_ENV !== "production" ? ListItem.propTypes /* remove-proptypes *
284
209
  */
285
210
  alignItems: PropTypes.oneOf(['center', 'flex-start']),
286
211
  /**
287
- * The content of the component if a `ListItemSecondaryAction` is used it must
288
- * be the last child.
212
+ * The content of the component.
289
213
  */
290
- children: chainPropTypes(PropTypes.node, props => {
291
- const children = React.Children.toArray(props.children);
292
-
293
- // React.Children.toArray(props.children).findLastIndex(isListItemSecondaryAction)
294
- let secondaryActionIndex = -1;
295
- for (let i = children.length - 1; i >= 0; i -= 1) {
296
- const child = children[i];
297
- if (isMuiElement(child, ['ListItemSecondaryAction'])) {
298
- secondaryActionIndex = i;
299
- break;
300
- }
301
- }
302
-
303
- // is ListItemSecondaryAction the last child of ListItem
304
- if (secondaryActionIndex !== -1 && secondaryActionIndex !== children.length - 1) {
305
- return new Error('MUI: You used an element after ListItemSecondaryAction. ' + 'For ListItem to detect that it has a secondary action ' + 'you must pass it as the last child to ListItem.');
306
- }
307
- return null;
308
- }),
214
+ children: PropTypes.node,
309
215
  /**
310
216
  * Override or extend the styles applied to the component.
311
217
  */
@@ -319,37 +225,6 @@ process.env.NODE_ENV !== "production" ? ListItem.propTypes /* remove-proptypes *
319
225
  * Either a string to use a HTML element or a component.
320
226
  */
321
227
  component: PropTypes.elementType,
322
- /**
323
- * The components used for each slot inside.
324
- *
325
- * @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.
326
- * @default {}
327
- */
328
- components: PropTypes.shape({
329
- Root: PropTypes.elementType
330
- }),
331
- /**
332
- * The extra props for the slot components.
333
- * You can override the existing props or add new ones.
334
- *
335
- * @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.
336
- * @default {}
337
- */
338
- componentsProps: PropTypes.shape({
339
- root: PropTypes.object
340
- }),
341
- /**
342
- * The container component used when a `ListItemSecondaryAction` is the last child.
343
- * @default 'li'
344
- * @deprecated Use the `component` or `slots.root` 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.
345
- */
346
- ContainerComponent: elementTypeAcceptingRef,
347
- /**
348
- * Props applied to the container component if used.
349
- * @default {}
350
- * @deprecated Use the `slotProps.root` 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.
351
- */
352
- ContainerProps: PropTypes.object,
353
228
  /**
354
229
  * If `true`, compact vertical padding designed for keyboard and mouse input is used.
355
230
  * The prop defaults to the value inherited from the parent List component.
@@ -1,8 +1,6 @@
1
1
  export interface ListItemClasses {
2
- /** Styles applied to the (normally root) `component` element. May be wrapped by a `container`. */
2
+ /** Styles applied to the root element. */
3
3
  root: string;
4
- /** Styles applied to the container element if `children` includes `ListItemSecondaryAction`. */
5
- container: string;
6
4
  /** Styles applied to the component element if dense. */
7
5
  dense: string;
8
6
  /** Styles applied to the component element if `alignItems="flex-start"`. */
@@ -13,7 +11,7 @@ export interface ListItemClasses {
13
11
  gutters: string;
14
12
  /** Styles applied to the root element unless `disablePadding={true}`. */
15
13
  padding: string;
16
- /** Styles applied to the component element if `children` includes `ListItemSecondaryAction`. */
14
+ /** Styles applied to the secondary action element. */
17
15
  secondaryAction: string;
18
16
  }
19
17
  export type ListItemClassKey = keyof ListItemClasses;
@@ -1,8 +1,6 @@
1
1
  export interface ListItemClasses {
2
- /** Styles applied to the (normally root) `component` element. May be wrapped by a `container`. */
2
+ /** Styles applied to the root element. */
3
3
  root: string;
4
- /** Styles applied to the container element if `children` includes `ListItemSecondaryAction`. */
5
- container: string;
6
4
  /** Styles applied to the component element if dense. */
7
5
  dense: string;
8
6
  /** Styles applied to the component element if `alignItems="flex-start"`. */
@@ -13,7 +11,7 @@ export interface ListItemClasses {
13
11
  gutters: string;
14
12
  /** Styles applied to the root element unless `disablePadding={true}`. */
15
13
  padding: string;
16
- /** Styles applied to the component element if `children` includes `ListItemSecondaryAction`. */
14
+ /** Styles applied to the secondary action element. */
17
15
  secondaryAction: string;
18
16
  }
19
17
  export type ListItemClassKey = keyof ListItemClasses;
@@ -11,5 +11,5 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
11
11
  function getListItemUtilityClass(slot) {
12
12
  return (0, _generateUtilityClass.default)('MuiListItem', slot);
13
13
  }
14
- const listItemClasses = (0, _generateUtilityClasses.default)('MuiListItem', ['root', 'container', 'dense', 'alignItemsFlexStart', 'divider', 'gutters', 'padding', 'secondaryAction']);
14
+ const listItemClasses = (0, _generateUtilityClasses.default)('MuiListItem', ['root', 'dense', 'alignItemsFlexStart', 'divider', 'gutters', 'padding', 'secondaryAction']);
15
15
  var _default = exports.default = listItemClasses;
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
3
  export function getListItemUtilityClass(slot) {
4
4
  return generateUtilityClass('MuiListItem', slot);
5
5
  }
6
- const listItemClasses = generateUtilityClasses('MuiListItem', ['root', 'container', 'dense', 'alignItemsFlexStart', 'divider', 'gutters', 'padding', 'secondaryAction']);
6
+ const listItemClasses = generateUtilityClasses('MuiListItem', ['root', 'dense', 'alignItemsFlexStart', 'divider', 'gutters', 'padding', 'secondaryAction']);
7
7
  export default listItemClasses;
@@ -22,8 +22,7 @@ export interface ListItemButtonBaseProps {
22
22
  */
23
23
  autoFocus?: boolean | undefined;
24
24
  /**
25
- * The content of the component if a `ListItemSecondaryAction` is used it must
26
- * be the last child.
25
+ * The content of the component.
27
26
  */
28
27
  children?: React.ReactNode;
29
28
  /**
@@ -22,8 +22,7 @@ export interface ListItemButtonBaseProps {
22
22
  */
23
23
  autoFocus?: boolean | undefined;
24
24
  /**
25
- * The content of the component if a `ListItemSecondaryAction` is used it must
26
- * be the last child.
25
+ * The content of the component.
27
26
  */
28
27
  children?: React.ReactNode;
29
28
  /**
@@ -207,8 +207,7 @@ process.env.NODE_ENV !== "production" ? ListItemButton.propTypes /* remove-propt
207
207
  */
208
208
  autoFocus: _propTypes.default.bool,
209
209
  /**
210
- * The content of the component if a `ListItemSecondaryAction` is used it must
211
- * be the last child.
210
+ * The content of the component.
212
211
  */
213
212
  children: _propTypes.default.node,
214
213
  /**
@@ -199,8 +199,7 @@ process.env.NODE_ENV !== "production" ? ListItemButton.propTypes /* remove-propt
199
199
  */
200
200
  autoFocus: PropTypes.bool,
201
201
  /**
202
- * The content of the component if a `ListItemSecondaryAction` is used it must
203
- * be the last child.
202
+ * The content of the component.
204
203
  */
205
204
  children: PropTypes.node,
206
205
  /**
@@ -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;