@mui/material 6.4.5 → 6.4.6

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 (73) hide show
  1. package/Accordion/Accordion.d.ts +14 -12
  2. package/Alert/Alert.d.ts +3 -15
  3. package/Backdrop/Backdrop.d.ts +14 -12
  4. package/CHANGELOG.md +38 -0
  5. package/CardHeader/CardHeader.d.ts +4 -20
  6. package/Checkbox/Checkbox.d.ts +45 -9
  7. package/Checkbox/Checkbox.js +51 -21
  8. package/Dialog/Dialog.d.ts +4 -4
  9. package/Drawer/Drawer.d.ts +92 -1
  10. package/Drawer/Drawer.js +108 -36
  11. package/InputBase/inputBaseClasses.d.ts +15 -6
  12. package/Menu/Menu.d.ts +88 -1
  13. package/Menu/Menu.js +58 -19
  14. package/Modal/Modal.js +9 -10
  15. package/Popover/Popover.d.ts +60 -6
  16. package/Popover/Popover.js +78 -51
  17. package/Radio/Radio.d.ts +45 -1
  18. package/Radio/Radio.js +59 -16
  19. package/Select/SelectInput.js +8 -8
  20. package/Snackbar/Snackbar.d.ts +79 -2
  21. package/Snackbar/Snackbar.js +110 -32
  22. package/SpeedDial/SpeedDial.d.ts +8 -6
  23. package/SpeedDialAction/SpeedDialAction.d.ts +82 -1
  24. package/SpeedDialAction/SpeedDialAction.js +108 -30
  25. package/StepContent/StepContent.d.ts +2 -2
  26. package/SwipeableDrawer/SwipeableDrawer.d.ts +28 -2
  27. package/SwipeableDrawer/SwipeableDrawer.js +60 -13
  28. package/Switch/Switch.js +2 -0
  29. package/Tabs/Tabs.d.ts +129 -29
  30. package/Tabs/Tabs.js +120 -52
  31. package/Tabs/tabsClasses.d.ts +4 -0
  32. package/Tabs/tabsClasses.js +1 -1
  33. package/Tooltip/Tooltip.d.ts +20 -12
  34. package/index.js +1 -1
  35. package/internal/SwitchBase.d.ts +35 -1
  36. package/internal/SwitchBase.js +84 -30
  37. package/modern/Checkbox/Checkbox.js +51 -21
  38. package/modern/Drawer/Drawer.js +108 -36
  39. package/modern/Menu/Menu.js +58 -19
  40. package/modern/Modal/Modal.js +9 -10
  41. package/modern/Popover/Popover.js +78 -51
  42. package/modern/Radio/Radio.js +59 -16
  43. package/modern/Select/SelectInput.js +8 -8
  44. package/modern/Snackbar/Snackbar.js +110 -32
  45. package/modern/SpeedDialAction/SpeedDialAction.js +108 -30
  46. package/modern/SwipeableDrawer/SwipeableDrawer.js +60 -13
  47. package/modern/Switch/Switch.js +2 -0
  48. package/modern/Tabs/Tabs.js +120 -52
  49. package/modern/Tabs/tabsClasses.js +1 -1
  50. package/modern/index.js +1 -1
  51. package/modern/internal/SwitchBase.js +84 -30
  52. package/modern/styles/createThemeNoVars.js +7 -2
  53. package/modern/version/index.js +2 -2
  54. package/node/Checkbox/Checkbox.js +51 -21
  55. package/node/Drawer/Drawer.js +108 -36
  56. package/node/Menu/Menu.js +58 -19
  57. package/node/Modal/Modal.js +9 -10
  58. package/node/Popover/Popover.js +78 -51
  59. package/node/Radio/Radio.js +59 -16
  60. package/node/Select/SelectInput.js +8 -8
  61. package/node/Snackbar/Snackbar.js +110 -32
  62. package/node/SpeedDialAction/SpeedDialAction.js +108 -30
  63. package/node/SwipeableDrawer/SwipeableDrawer.js +60 -13
  64. package/node/Switch/Switch.js +2 -0
  65. package/node/Tabs/Tabs.js +120 -52
  66. package/node/Tabs/tabsClasses.js +1 -1
  67. package/node/index.js +1 -1
  68. package/node/internal/SwitchBase.js +84 -30
  69. package/node/styles/createThemeNoVars.js +7 -2
  70. package/node/version/index.js +2 -2
  71. package/package.json +6 -6
  72. package/styles/createThemeNoVars.js +7 -2
  73. package/version/index.js +2 -2
package/Drawer/Drawer.js CHANGED
@@ -15,6 +15,8 @@ import { styled, useTheme } from "../zero-styled/index.js";
15
15
  import memoTheme from "../utils/memoTheme.js";
16
16
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
17
17
  import { getDrawerUtilityClass } from "./drawerClasses.js";
18
+ import useSlot from "../utils/useSlot.js";
19
+ import { mergeSlotProps } from "../utils/index.js";
18
20
  import { jsx as _jsx } from "react/jsx-runtime";
19
21
  const overridesResolver = (props, styles) => {
20
22
  const {
@@ -194,9 +196,11 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(inProps, ref) {
194
196
  PaperProps = {},
195
197
  SlideProps,
196
198
  // eslint-disable-next-line react/prop-types
197
- TransitionComponent = Slide,
199
+ TransitionComponent,
198
200
  transitionDuration = defaultTransitionDuration,
199
201
  variant = 'temporary',
202
+ slots = {},
203
+ slotProps = {},
200
204
  ...other
201
205
  } = props;
202
206
 
@@ -220,56 +224,100 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(inProps, ref) {
220
224
  ...other
221
225
  };
222
226
  const classes = useUtilityClasses(ownerState);
223
- const drawer = /*#__PURE__*/_jsx(DrawerPaper, {
224
- elevation: variant === 'temporary' ? elevation : 0,
225
- square: true,
226
- ...PaperProps,
227
+ const externalForwardedProps = {
228
+ slots: {
229
+ transition: TransitionComponent,
230
+ ...slots
231
+ },
232
+ slotProps: {
233
+ paper: PaperProps,
234
+ transition: SlideProps,
235
+ ...slotProps,
236
+ backdrop: mergeSlotProps(slotProps.backdrop || {
237
+ ...BackdropProps,
238
+ ...BackdropPropsProp
239
+ }, {
240
+ transitionDuration
241
+ })
242
+ }
243
+ };
244
+ const [RootSlot, rootSlotProps] = useSlot('root', {
245
+ ref,
246
+ elementType: DrawerRoot,
247
+ className: clsx(classes.root, classes.modal, className),
248
+ shouldForwardComponentProp: true,
249
+ ownerState,
250
+ externalForwardedProps: {
251
+ ...externalForwardedProps,
252
+ ...other,
253
+ ...ModalProps
254
+ },
255
+ additionalProps: {
256
+ open,
257
+ onClose,
258
+ hideBackdrop,
259
+ slots: {
260
+ backdrop: externalForwardedProps.slots.backdrop
261
+ },
262
+ slotProps: {
263
+ backdrop: externalForwardedProps.slotProps.backdrop
264
+ }
265
+ }
266
+ });
267
+ const [PaperSlot, paperSlotProps] = useSlot('paper', {
268
+ elementType: DrawerPaper,
269
+ shouldForwardComponentProp: true,
227
270
  className: clsx(classes.paper, PaperProps.className),
228
- ownerState: ownerState,
271
+ ownerState,
272
+ externalForwardedProps,
273
+ additionalProps: {
274
+ elevation: variant === 'temporary' ? elevation : 0,
275
+ square: true
276
+ }
277
+ });
278
+ const [DockedSlot, dockedSlotProps] = useSlot('docked', {
279
+ elementType: DrawerDockedRoot,
280
+ ref,
281
+ className: clsx(classes.root, classes.docked, className),
282
+ ownerState,
283
+ externalForwardedProps,
284
+ additionalProps: other // pass `other` here because `DockedSlot` is also a root slot for some variants
285
+ });
286
+ const [TransitionSlot, transitionSlotProps] = useSlot('transition', {
287
+ elementType: Slide,
288
+ ownerState,
289
+ externalForwardedProps,
290
+ additionalProps: {
291
+ in: open,
292
+ direction: oppositeDirection[anchorInvariant],
293
+ timeout: transitionDuration,
294
+ appear: mounted.current
295
+ }
296
+ });
297
+ const drawer = /*#__PURE__*/_jsx(PaperSlot, {
298
+ ...paperSlotProps,
229
299
  children: children
230
300
  });
231
301
  if (variant === 'permanent') {
232
- return /*#__PURE__*/_jsx(DrawerDockedRoot, {
233
- className: clsx(classes.root, classes.docked, className),
234
- ownerState: ownerState,
235
- ref: ref,
236
- ...other,
302
+ return /*#__PURE__*/_jsx(DockedSlot, {
303
+ ...dockedSlotProps,
237
304
  children: drawer
238
305
  });
239
306
  }
240
- const slidingDrawer = /*#__PURE__*/_jsx(TransitionComponent, {
241
- in: open,
242
- direction: oppositeDirection[anchorInvariant],
243
- timeout: transitionDuration,
244
- appear: mounted.current,
245
- ...SlideProps,
307
+ const slidingDrawer = /*#__PURE__*/_jsx(TransitionSlot, {
308
+ ...transitionSlotProps,
246
309
  children: drawer
247
310
  });
248
311
  if (variant === 'persistent') {
249
- return /*#__PURE__*/_jsx(DrawerDockedRoot, {
250
- className: clsx(classes.root, classes.docked, className),
251
- ownerState: ownerState,
252
- ref: ref,
253
- ...other,
312
+ return /*#__PURE__*/_jsx(DockedSlot, {
313
+ ...dockedSlotProps,
254
314
  children: slidingDrawer
255
315
  });
256
316
  }
257
317
 
258
318
  // variant === temporary
259
- return /*#__PURE__*/_jsx(DrawerRoot, {
260
- BackdropProps: {
261
- ...BackdropProps,
262
- ...BackdropPropsProp,
263
- transitionDuration
264
- },
265
- className: clsx(classes.root, classes.modal, className),
266
- open: open,
267
- ownerState: ownerState,
268
- onClose: onClose,
269
- hideBackdrop: hideBackdrop,
270
- ref: ref,
271
- ...other,
272
- ...ModalProps,
319
+ return /*#__PURE__*/_jsx(RootSlot, {
320
+ ...rootSlotProps,
273
321
  children: slidingDrawer
274
322
  });
275
323
  });
@@ -329,13 +377,37 @@ process.env.NODE_ENV !== "production" ? Drawer.propTypes /* remove-proptypes */
329
377
  open: PropTypes.bool,
330
378
  /**
331
379
  * Props applied to the [`Paper`](https://mui.com/material-ui/api/paper/) element.
380
+ * @deprecated use the `slotProps.paper` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
332
381
  * @default {}
333
382
  */
334
383
  PaperProps: PropTypes.object,
335
384
  /**
336
385
  * Props applied to the [`Slide`](https://mui.com/material-ui/api/slide/) element.
386
+ * @deprecated use the `slotProps.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
337
387
  */
338
388
  SlideProps: PropTypes.object,
389
+ /**
390
+ * The props used for each slot inside.
391
+ * @default {}
392
+ */
393
+ slotProps: PropTypes.shape({
394
+ backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
395
+ docked: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
396
+ paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
397
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
398
+ transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
399
+ }),
400
+ /**
401
+ * The components used for each slot inside.
402
+ * @default {}
403
+ */
404
+ slots: PropTypes.shape({
405
+ backdrop: PropTypes.elementType,
406
+ docked: PropTypes.elementType,
407
+ paper: PropTypes.elementType,
408
+ root: PropTypes.elementType,
409
+ transition: PropTypes.elementType
410
+ }),
339
411
  /**
340
412
  * The system prop that allows defining system overrides as well as additional CSS styles.
341
413
  */
@@ -27,17 +27,26 @@ export interface InputBaseClasses {
27
27
  readOnly: string;
28
28
  /** Styles applied to the input element. */
29
29
  input: string;
30
- /** Styles applied to the input element if `size="small"`. */
30
+ /** Styles applied to the input element if `size="small"`.
31
+ * @deprecated Combine the [.MuiInputBase-input](/material-ui/api/input-base/#inputbase-classes-input) and [.MuiInputBase-sizeSmall](/material-ui/api/input-base/#inputbase-classes-sizeSmall) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
32
+ */
31
33
  inputSizeSmall: string;
32
- /** Styles applied to the input element if `multiline={true}`. */
34
+ /** Styles applied to the input element if `multiline={true}`.
35
+ * @deprecated Combine the [.MuiInputBase-input](/material-ui/api/input-base/#inputbase-classes-input) and [.MuiInputBase-multiline](/material-ui/api/input-base/#inputbase-classes-multiline) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
36
+ */
33
37
  inputMultiline: string;
34
- /** Styles applied to the input element if `type="search"`. */
35
38
  inputTypeSearch: string;
36
- /** Styles applied to the input element if `startAdornment` is provided. */
39
+ /** Styles applied to the input element if `startAdornment` is provided.
40
+ * @deprecated Combine the [.MuiInputBase-input](/material-ui/api/input-base/#inputbase-classes-input) and [.MuiInputBase-adornedStart](/material-ui/api/input-base/#inputbase-classes-adornedStart) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
41
+ */
37
42
  inputAdornedStart: string;
38
- /** Styles applied to the input element if `endAdornment` is provided. */
43
+ /** Styles applied to the input element if `endAdornment` is provided.
44
+ * @deprecated Combine the [.MuiInputBase-input](/material-ui/api/input-base/#inputbase-classes-input) and [.MuiInputBase-adornedEnd](/material-ui/api/input-base/#inputbase-classes-adornedEnd) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
45
+ */
39
46
  inputAdornedEnd: string;
40
- /** Styles applied to the input element if `hiddenLabel={true}`. */
47
+ /** Styles applied to the input element if `hiddenLabel={true}`.
48
+ * @deprecated Combine the [.MuiInputBase-input](/material-ui/api/input-base/#inputbase-classes-input) and [.MuiInputBase-hiddenLabel](/material-ui/api/input-base/#inputbase-classes-hiddenLabel) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
49
+ */
41
50
  inputHiddenLabel: string;
42
51
  }
43
52
  export type InputBaseClassKey = keyof InputBaseClasses;
package/Menu/Menu.d.ts CHANGED
@@ -4,11 +4,94 @@ import { InternalStandardProps as StandardProps } from '..';
4
4
  import { PaperProps } from '../Paper';
5
5
  import { PopoverProps } from '../Popover';
6
6
  import { MenuListProps } from '../MenuList';
7
+ import { ModalProps } from '../Modal';
8
+ import { BackdropProps } from '../Backdrop';
7
9
  import { Theme } from '../styles';
8
10
  import { TransitionProps } from '../transitions/transition';
9
11
  import { MenuClasses } from './menuClasses';
12
+ import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from '../utils/types';
10
13
 
11
- export interface MenuProps extends StandardProps<PopoverProps> {
14
+ export interface MenuRootSlotPropsOverrides {}
15
+
16
+ export interface MenuPaperSlotPropsOverrides {}
17
+
18
+ export interface MenuTransitionSlotPropsOverrides {}
19
+
20
+ export interface MenuListSlotPropsOverrides {}
21
+
22
+ export interface MenuBackdropSlotPropsOverrides {}
23
+
24
+ export interface MenuSlots {
25
+ /**
26
+ * The component used for the popper.
27
+ * @default Modal
28
+ */
29
+ root: React.ElementType;
30
+ /**
31
+ * The component used for the paper.
32
+ * @default Paper
33
+ */
34
+ paper: React.ElementType;
35
+ /**
36
+ * The component used for the list.
37
+ * @default MenuList
38
+ */
39
+ list: React.ElementType;
40
+ /**
41
+ * The component used for the transition slot.
42
+ * @default Grow
43
+ */
44
+ transition: React.ElementType;
45
+ /**
46
+ * The component used for the backdrop slot.
47
+ * @default Backdrop
48
+ */
49
+ backdrop: React.ElementType;
50
+ }
51
+
52
+ export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<
53
+ MenuSlots,
54
+ {
55
+ /**
56
+ * Props forwarded to the root slot.
57
+ * By default, the avaible props are based on the [Popover](https://mui.com/material-ui/api/popover/#props) component.
58
+ */
59
+ root: SlotProps<React.ElementType<ModalProps>, MenuRootSlotPropsOverrides, MenuOwnerState>;
60
+ /**
61
+ * Props forwarded to the paper slot.
62
+ * By default, the avaible props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
63
+ */
64
+ paper: SlotProps<React.ElementType<PaperProps>, MenuPaperSlotPropsOverrides, MenuOwnerState>;
65
+ /**
66
+ * Props forwarded to the list slot.
67
+ * By default, the avaible props are based on the [MenuList](https://mui.com/material-ui/api/menu-list/#props) component.
68
+ */
69
+ list: SlotProps<React.ElementType<MenuListProps>, MenuListSlotPropsOverrides, MenuOwnerState>;
70
+ /**
71
+ * Props forwarded to the transition slot.
72
+ * By default, the avaible props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
73
+ */
74
+ transition: SlotComponentProps<
75
+ // use SlotComponentProps because transition slot does not support `component` and `sx` prop
76
+ React.ElementType,
77
+ TransitionProps & MenuTransitionSlotPropsOverrides,
78
+ MenuOwnerState
79
+ >;
80
+ /**
81
+ * Props forwarded to the backdrop slot.
82
+ * By default, the avaible props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
83
+ */
84
+ backdrop: SlotProps<
85
+ React.ElementType<BackdropProps>,
86
+ MenuBackdropSlotPropsOverrides,
87
+ MenuOwnerState
88
+ >;
89
+ }
90
+ >;
91
+
92
+ export interface MenuProps
93
+ extends StandardProps<Omit<PopoverProps, 'slots' | 'slotProps'>>,
94
+ MenuSlotsAndSlotProps {
12
95
  /**
13
96
  * An HTML element, or a function that returns one.
14
97
  * It's used to set the position of the menu.
@@ -40,6 +123,7 @@ export interface MenuProps extends StandardProps<PopoverProps> {
40
123
  disableAutoFocusItem?: boolean;
41
124
  /**
42
125
  * Props applied to the [`MenuList`](https://mui.com/material-ui/api/menu-list/) element.
126
+ * @deprecated use the `slotProps.list` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
43
127
  * @default {}
44
128
  */
45
129
  MenuListProps?: Partial<MenuListProps>;
@@ -70,6 +154,7 @@ export interface MenuProps extends StandardProps<PopoverProps> {
70
154
  /**
71
155
  * Props applied to the transition element.
72
156
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
157
+ * @deprecated use the `slotProps.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
73
158
  * @default {}
74
159
  */
75
160
  TransitionProps?: TransitionProps;
@@ -80,6 +165,8 @@ export interface MenuProps extends StandardProps<PopoverProps> {
80
165
  variant?: 'menu' | 'selectedMenu';
81
166
  }
82
167
 
168
+ export interface MenuOwnerState extends Omit<MenuProps, 'slots' | 'slotProps'> {}
169
+
83
170
  export declare const MenuPaper: React.FC<PaperProps>;
84
171
 
85
172
  /**
package/Menu/Menu.js CHANGED
@@ -14,6 +14,7 @@ import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
14
14
  import { styled } from "../zero-styled/index.js";
15
15
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
16
16
  import { getMenuUtilityClass } from "./menuClasses.js";
17
+ import useSlot from "../utils/useSlot.js";
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  const RTL_ORIGIN = {
19
20
  vertical: 'top',
@@ -145,20 +146,43 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
145
146
  }
146
147
  }
147
148
  });
148
- const PaperSlot = slots.paper ?? MenuPaper;
149
- const paperExternalSlotProps = slotProps.paper ?? PaperProps;
149
+ const externalForwardedProps = {
150
+ slots,
151
+ slotProps: {
152
+ list: MenuListProps,
153
+ transition: TransitionProps,
154
+ paper: PaperProps,
155
+ ...slotProps
156
+ }
157
+ };
150
158
  const rootSlotProps = useSlotProps({
151
159
  elementType: slots.root,
152
160
  externalSlotProps: slotProps.root,
153
161
  ownerState,
154
162
  className: [classes.root, className]
155
163
  });
156
- const paperSlotProps = useSlotProps({
157
- elementType: PaperSlot,
158
- externalSlotProps: paperExternalSlotProps,
159
- ownerState,
160
- className: classes.paper
164
+ const [PaperSlot, paperSlotProps] = useSlot('paper', {
165
+ className: classes.paper,
166
+ elementType: MenuPaper,
167
+ externalForwardedProps,
168
+ shouldForwardComponentProp: true,
169
+ ownerState
170
+ });
171
+ const [ListSlot, listSlotProps] = useSlot('list', {
172
+ className: clsx(classes.list, MenuListProps.className),
173
+ elementType: MenuMenuList,
174
+ shouldForwardComponentProp: true,
175
+ externalForwardedProps,
176
+ getSlotProps: handlers => ({
177
+ ...handlers,
178
+ onKeyDown: event => {
179
+ handleListKeyDown(event);
180
+ handlers.onKeyDown?.(event);
181
+ }
182
+ }),
183
+ ownerState
161
184
  });
185
+ const resolvedTransitionProps = typeof externalForwardedProps.slotProps.transition === 'function' ? externalForwardedProps.slotProps.transition(ownerState) : externalForwardedProps.slotProps.transition;
162
186
  return /*#__PURE__*/_jsx(MenuRoot, {
163
187
  onClose: onClose,
164
188
  anchorOrigin: {
@@ -167,31 +191,38 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
167
191
  },
168
192
  transformOrigin: isRtl ? RTL_ORIGIN : LTR_ORIGIN,
169
193
  slots: {
194
+ root: slots.root,
170
195
  paper: PaperSlot,
171
- root: slots.root
196
+ backdrop: slots.backdrop,
197
+ ...(slots.transition && {
198
+ // TODO: pass `slots.transition` directly once `TransitionComponent` is removed from Popover
199
+ transition: slots.transition
200
+ })
172
201
  },
173
202
  slotProps: {
174
203
  root: rootSlotProps,
175
- paper: paperSlotProps
204
+ paper: paperSlotProps,
205
+ backdrop: typeof slotProps.backdrop === 'function' ? slotProps.backdrop(ownerState) : slotProps.backdrop,
206
+ transition: {
207
+ ...resolvedTransitionProps,
208
+ onEntering: (...args) => {
209
+ handleEntering(...args);
210
+ resolvedTransitionProps?.onEntering?.(...args);
211
+ }
212
+ }
176
213
  },
177
214
  open: open,
178
215
  ref: ref,
179
216
  transitionDuration: transitionDuration,
180
- TransitionProps: {
181
- onEntering: handleEntering,
182
- ...TransitionProps
183
- },
184
217
  ownerState: ownerState,
185
218
  ...other,
186
219
  classes: PopoverClasses,
187
- children: /*#__PURE__*/_jsx(MenuMenuList, {
188
- onKeyDown: handleListKeyDown,
220
+ children: /*#__PURE__*/_jsx(ListSlot, {
189
221
  actions: menuListActionsRef,
190
222
  autoFocus: autoFocus && (activeItemIndex === -1 || disableAutoFocusItem),
191
223
  autoFocusItem: autoFocusItem,
192
224
  variant: variant,
193
- ...MenuListProps,
194
- className: clsx(classes.list, MenuListProps.className),
225
+ ...listSlotProps,
195
226
  children: children
196
227
  })
197
228
  });
@@ -236,6 +267,7 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
236
267
  disableAutoFocusItem: PropTypes.bool,
237
268
  /**
238
269
  * Props applied to the [`MenuList`](https://mui.com/material-ui/api/menu-list/) element.
270
+ * @deprecated use the `slotProps.list` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
239
271
  * @default {}
240
272
  */
241
273
  MenuListProps: PropTypes.object,
@@ -263,16 +295,22 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
263
295
  * @default {}
264
296
  */
265
297
  slotProps: PropTypes.shape({
298
+ backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
299
+ list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
266
300
  paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
267
- root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
301
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
302
+ transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
268
303
  }),
269
304
  /**
270
305
  * The components used for each slot inside.
271
306
  * @default {}
272
307
  */
273
308
  slots: PropTypes.shape({
309
+ backdrop: PropTypes.elementType,
310
+ list: PropTypes.elementType,
274
311
  paper: PropTypes.elementType,
275
- root: PropTypes.elementType
312
+ root: PropTypes.elementType,
313
+ transition: PropTypes.elementType
276
314
  }),
277
315
  /**
278
316
  * The system prop that allows defining system overrides as well as additional CSS styles.
@@ -290,6 +328,7 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
290
328
  /**
291
329
  * Props applied to the transition element.
292
330
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
331
+ * @deprecated use the `slotProps.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
293
332
  * @default {}
294
333
  */
295
334
  TransitionProps: PropTypes.object,
package/Modal/Modal.js CHANGED
@@ -15,7 +15,6 @@ import Backdrop from "../Backdrop/index.js";
15
15
  import useModal from "./useModal.js";
16
16
  import { getModalUtilityClass } from "./modalClasses.js";
17
17
  import useSlot from "../utils/useSlot.js";
18
- import { useForkRef } from "../utils/index.js";
19
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
19
  const useUtilityClasses = ownerState => {
21
20
  const {
@@ -158,7 +157,6 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
158
157
  childProps.onExited = onExited;
159
158
  }
160
159
  const externalForwardedProps = {
161
- ...other,
162
160
  slots: {
163
161
  root: components.Root,
164
162
  backdrop: components.Backdrop,
@@ -170,19 +168,22 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
170
168
  }
171
169
  };
172
170
  const [RootSlot, rootProps] = useSlot('root', {
171
+ ref,
173
172
  elementType: ModalRoot,
174
- externalForwardedProps,
175
- getSlotProps: getRootProps,
176
- additionalProps: {
177
- ref,
178
- as: component
173
+ externalForwardedProps: {
174
+ ...externalForwardedProps,
175
+ ...other,
176
+ component
179
177
  },
178
+ getSlotProps: getRootProps,
180
179
  ownerState,
181
180
  className: clsx(className, classes?.root, !ownerState.open && ownerState.exited && classes?.hidden)
182
181
  });
183
182
  const [BackdropSlot, backdropProps] = useSlot('backdrop', {
183
+ ref: BackdropProps?.ref,
184
184
  elementType: BackdropComponent,
185
185
  externalForwardedProps,
186
+ shouldForwardComponentProp: true,
186
187
  additionalProps: BackdropProps,
187
188
  getSlotProps: otherHandlers => {
188
189
  return getBackdropProps({
@@ -200,7 +201,6 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
200
201
  className: clsx(BackdropProps?.className, classes?.backdrop),
201
202
  ownerState
202
203
  });
203
- const backdropRef = useForkRef(BackdropProps?.ref, backdropProps.ref);
204
204
  if (!keepMounted && !open && (!hasTransition || exited)) {
205
205
  return null;
206
206
  }
@@ -211,8 +211,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
211
211
  children: /*#__PURE__*/_jsxs(RootSlot, {
212
212
  ...rootProps,
213
213
  children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/_jsx(BackdropSlot, {
214
- ...backdropProps,
215
- ref: backdropRef
214
+ ...backdropProps
216
215
  }) : null, /*#__PURE__*/_jsx(FocusTrap, {
217
216
  disableEnforceFocus: disableEnforceFocus,
218
217
  disableAutoFocus: disableAutoFocus,
@@ -1,23 +1,74 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
+ import { SlotComponentProps } from '@mui/utils';
3
4
  import { BackdropProps, InternalStandardProps as StandardProps } from '..';
4
5
  import Paper, { PaperProps } from '../Paper';
5
- import Modal, { ModalOwnerState, ModalProps } from '../Modal';
6
+ import Modal, { ModalProps } from '../Modal';
6
7
  import { Theme } from '../styles';
7
8
  import { TransitionProps } from '../transitions/transition';
8
9
  import { PopoverClasses } from './popoverClasses';
9
10
  import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
10
11
 
11
12
  export interface PopoverSlots {
13
+ /**
14
+ * The component used for the root slot.
15
+ * @default Modal
16
+ */
12
17
  root: React.ElementType;
18
+ /**
19
+ * The component used for the paper slot.
20
+ * @default Paper
21
+ */
13
22
  paper: React.ElementType;
23
+ /**
24
+ * The component used for the transition slot.
25
+ * @default Grow
26
+ */
27
+ transition: React.ElementType;
28
+ /**
29
+ * The component used for the backdrop slot.
30
+ * @default Backdrop
31
+ */
32
+ backdrop: React.ElementType;
14
33
  }
15
34
 
35
+ export interface PopoverRootSlotPropsOverrides {}
36
+ export interface PopoverPaperSlotPropsOverrides {}
37
+ export interface PopoverTransitionSlotPropsOverrides {}
38
+ export interface PopoverBackdropSlotPropsOverrides {}
39
+
16
40
  export type PopoverSlotsAndSlotProps = CreateSlotsAndSlotProps<
17
41
  PopoverSlots,
18
42
  {
19
- root: SlotProps<typeof Modal, {}, ModalOwnerState>;
20
- paper: SlotProps<typeof Paper, {}, {}>;
43
+ /**
44
+ * Props forwarded to the root slot.
45
+ * By default, the avaible props are based on the [Modal](https://mui.com/material-ui/api/modal/#props) component.
46
+ */
47
+ root: SlotProps<typeof Modal, PopoverRootSlotPropsOverrides, PopoverOwnerState>;
48
+ /**
49
+ * Props forwarded to the paper slot.
50
+ * By default, the avaible props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
51
+ */
52
+ paper: SlotProps<typeof Paper, PopoverPaperSlotPropsOverrides, PopoverOwnerState>;
53
+ /**
54
+ * Props forwarded to the transition slot.
55
+ * By default, the avaible props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
56
+ */
57
+ transition: SlotComponentProps<
58
+ // use SlotComponentProps because transition slot does not support `component` and `sx` prop
59
+ React.ElementType,
60
+ TransitionProps & PopoverTransitionSlotPropsOverrides,
61
+ PopoverOwnerState
62
+ >;
63
+ /**
64
+ * Props forwarded to the backdrop slot.
65
+ * By default, the avaible props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
66
+ */
67
+ backdrop: SlotProps<
68
+ React.ElementType<BackdropProps>,
69
+ PopoverBackdropSlotPropsOverrides,
70
+ PopoverOwnerState
71
+ >;
21
72
  }
22
73
  >;
23
74
 
@@ -87,8 +138,7 @@ export interface PopoverProps
87
138
  anchorReference?: PopoverReference;
88
139
  /**
89
140
  * A backdrop component. This prop enables custom backdrop rendering.
90
- * @deprecated Use `slotProps.root.slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
91
- * Use the `slotProps.root.slots.backdrop` prop to make your application ready for the next version of Material UI.
141
+ * @deprecated Use `slots.backdrop` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
92
142
  * @default styled(Backdrop, {
93
143
  * name: 'MuiModal',
94
144
  * slot: 'Backdrop',
@@ -102,7 +152,7 @@ export interface PopoverProps
102
152
  BackdropComponent?: React.ElementType<BackdropProps>;
103
153
  /**
104
154
  * Props applied to the [`Backdrop`](/material-ui/api/backdrop/) element.
105
- * @deprecated Use `slotProps.root.slotProps.backdrop` instead.
155
+ * @deprecated Use `slotProps.backdrop` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
106
156
  */
107
157
  BackdropProps?: Partial<BackdropProps>;
108
158
  /**
@@ -166,6 +216,7 @@ export interface PopoverProps
166
216
  /**
167
217
  * The component used for the transition.
168
218
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
219
+ * @deprecated use the `slots.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
169
220
  * @default Grow
170
221
  */
171
222
  TransitionComponent?: React.JSXElementConstructor<
@@ -179,11 +230,14 @@ export interface PopoverProps
179
230
  /**
180
231
  * Props applied to the transition element.
181
232
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
233
+ * @deprecated use the `slotProps.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
182
234
  * @default {}
183
235
  */
184
236
  TransitionProps?: TransitionProps;
185
237
  }
186
238
 
239
+ export interface PopoverOwnerState extends Omit<PopoverProps, 'slots' | 'slotProps'> {}
240
+
187
241
  export interface PopoverActions {
188
242
  updatePosition(): void;
189
243
  }