@mui/material 6.4.4 → 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 (82) 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/Button/Button.js +3 -3
  5. package/CHANGELOG.md +63 -0
  6. package/CardHeader/CardHeader.d.ts +4 -20
  7. package/Checkbox/Checkbox.d.ts +45 -9
  8. package/Checkbox/Checkbox.js +51 -21
  9. package/Dialog/Dialog.d.ts +4 -4
  10. package/Drawer/Drawer.d.ts +92 -1
  11. package/Drawer/Drawer.js +108 -36
  12. package/IconButton/IconButton.js +3 -3
  13. package/InputBase/inputBaseClasses.d.ts +15 -6
  14. package/Menu/Menu.d.ts +88 -1
  15. package/Menu/Menu.js +58 -19
  16. package/Modal/Modal.js +9 -10
  17. package/Popover/Popover.d.ts +60 -6
  18. package/Popover/Popover.js +78 -51
  19. package/Radio/Radio.d.ts +45 -1
  20. package/Radio/Radio.js +59 -16
  21. package/Select/SelectInput.js +8 -8
  22. package/Snackbar/Snackbar.d.ts +79 -2
  23. package/Snackbar/Snackbar.js +110 -32
  24. package/SpeedDial/SpeedDial.d.ts +8 -6
  25. package/SpeedDialAction/SpeedDialAction.d.ts +82 -1
  26. package/SpeedDialAction/SpeedDialAction.js +108 -30
  27. package/StepContent/StepContent.d.ts +2 -2
  28. package/SwipeableDrawer/SwipeableDrawer.d.ts +28 -2
  29. package/SwipeableDrawer/SwipeableDrawer.js +60 -13
  30. package/Switch/Switch.js +2 -0
  31. package/Tabs/Tabs.d.ts +129 -29
  32. package/Tabs/Tabs.js +120 -52
  33. package/Tabs/tabsClasses.d.ts +4 -0
  34. package/Tabs/tabsClasses.js +1 -1
  35. package/Tooltip/Tooltip.d.ts +20 -12
  36. package/index.js +1 -1
  37. package/internal/SwitchBase.d.ts +35 -1
  38. package/internal/SwitchBase.js +84 -30
  39. package/modern/Button/Button.js +3 -3
  40. package/modern/Checkbox/Checkbox.js +51 -21
  41. package/modern/Drawer/Drawer.js +108 -36
  42. package/modern/IconButton/IconButton.js +3 -3
  43. package/modern/Menu/Menu.js +58 -19
  44. package/modern/Modal/Modal.js +9 -10
  45. package/modern/Popover/Popover.js +78 -51
  46. package/modern/Radio/Radio.js +59 -16
  47. package/modern/Select/SelectInput.js +8 -8
  48. package/modern/Snackbar/Snackbar.js +110 -32
  49. package/modern/SpeedDialAction/SpeedDialAction.js +108 -30
  50. package/modern/SwipeableDrawer/SwipeableDrawer.js +60 -13
  51. package/modern/Switch/Switch.js +2 -0
  52. package/modern/Tabs/Tabs.js +120 -52
  53. package/modern/Tabs/tabsClasses.js +1 -1
  54. package/modern/index.js +1 -1
  55. package/modern/internal/SwitchBase.js +84 -30
  56. package/modern/styles/createThemeNoVars.js +7 -2
  57. package/modern/useAutocomplete/useAutocomplete.js +0 -1
  58. package/modern/version/index.js +2 -2
  59. package/node/Button/Button.js +3 -3
  60. package/node/Checkbox/Checkbox.js +51 -21
  61. package/node/Drawer/Drawer.js +108 -36
  62. package/node/IconButton/IconButton.js +3 -3
  63. package/node/Menu/Menu.js +58 -19
  64. package/node/Modal/Modal.js +9 -10
  65. package/node/Popover/Popover.js +78 -51
  66. package/node/Radio/Radio.js +59 -16
  67. package/node/Select/SelectInput.js +8 -8
  68. package/node/Snackbar/Snackbar.js +110 -32
  69. package/node/SpeedDialAction/SpeedDialAction.js +108 -30
  70. package/node/SwipeableDrawer/SwipeableDrawer.js +60 -13
  71. package/node/Switch/Switch.js +2 -0
  72. package/node/Tabs/Tabs.js +120 -52
  73. package/node/Tabs/tabsClasses.js +1 -1
  74. package/node/index.js +1 -1
  75. package/node/internal/SwitchBase.js +84 -30
  76. package/node/styles/createThemeNoVars.js +7 -2
  77. package/node/useAutocomplete/useAutocomplete.js +0 -1
  78. package/node/version/index.js +2 -2
  79. package/package.json +5 -5
  80. package/styles/createThemeNoVars.js +7 -2
  81. package/useAutocomplete/useAutocomplete.js +0 -1
  82. package/version/index.js +2 -2
@@ -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
  }
@@ -15,12 +15,12 @@ import { useDefaultProps } from "../DefaultPropsProvider/index.js";
15
15
  import debounce from "../utils/debounce.js";
16
16
  import ownerDocument from "../utils/ownerDocument.js";
17
17
  import ownerWindow from "../utils/ownerWindow.js";
18
- import useForkRef from "../utils/useForkRef.js";
19
18
  import Grow from "../Grow/index.js";
20
19
  import Modal from "../Modal/index.js";
21
20
  import PaperBase from "../Paper/index.js";
22
21
  import { getPopoverUtilityClass } from "./popoverClasses.js";
23
22
  import useSlot from "../utils/useSlot.js";
23
+ import { mergeSlotProps } from "../utils/index.js";
24
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
25
  export function getOffsetTop(rect, vertical) {
26
26
  let offset = 0;
@@ -103,22 +103,21 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
103
103
  marginThreshold = 16,
104
104
  open,
105
105
  PaperProps: PaperPropsProp = {},
106
+ // TODO: remove in v7
106
107
  slots = {},
107
108
  slotProps = {},
108
109
  transformOrigin = {
109
110
  vertical: 'top',
110
111
  horizontal: 'left'
111
112
  },
112
- TransitionComponent = Grow,
113
+ TransitionComponent,
114
+ // TODO: remove in v7
113
115
  transitionDuration: transitionDurationProp = 'auto',
114
- TransitionProps: {
115
- onEntering,
116
- ...TransitionProps
117
- } = {},
116
+ TransitionProps = {},
117
+ // TODO: remove in v7
118
118
  disableScrollLock = false,
119
119
  ...other
120
120
  } = props;
121
- const externalPaperSlotProps = slotProps?.paper ?? PaperPropsProp;
122
121
  const paperRef = React.useRef();
123
122
  const ownerState = {
124
123
  ...props,
@@ -126,7 +125,6 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
126
125
  anchorReference,
127
126
  elevation,
128
127
  marginThreshold,
129
- externalPaperSlotProps,
130
128
  transformOrigin,
131
129
  TransitionComponent,
132
130
  transitionDuration: transitionDurationProp,
@@ -255,10 +253,7 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
255
253
  }
256
254
  return () => window.removeEventListener('scroll', setPositioningStyles);
257
255
  }, [anchorEl, disableScrollLock, setPositioningStyles]);
258
- const handleEntering = (element, isAppearing) => {
259
- if (onEntering) {
260
- onEntering(element, isAppearing);
261
- }
256
+ const handleEntering = () => {
262
257
  setPositioningStyles();
263
258
  };
264
259
  const handleExited = () => {
@@ -289,45 +284,65 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
289
284
  };
290
285
  }, [anchorEl, open, setPositioningStyles]);
291
286
  let transitionDuration = transitionDurationProp;
292
- if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
293
- transitionDuration = undefined;
294
- }
295
-
296
- // If the container prop is provided, use that
297
- // If the anchorEl prop is provided, use its parent body element as the container
298
- // If neither are provided let the Modal take care of choosing the container
299
- const container = containerProp || (anchorEl ? ownerDocument(resolveAnchorEl(anchorEl)).body : undefined);
300
287
  const externalForwardedProps = {
301
- slots,
288
+ slots: {
289
+ transition: TransitionComponent,
290
+ ...slots
291
+ },
302
292
  slotProps: {
303
- ...slotProps,
304
- paper: externalPaperSlotProps
293
+ transition: TransitionProps,
294
+ paper: PaperPropsProp,
295
+ ...slotProps
305
296
  }
306
297
  };
307
- const [PaperSlot, paperProps] = useSlot('paper', {
308
- elementType: PopoverPaper,
298
+ const [TransitionSlot, transitionSlotProps] = useSlot('transition', {
299
+ elementType: Grow,
309
300
  externalForwardedProps,
310
- additionalProps: {
311
- elevation,
312
- className: clsx(classes.paper, externalPaperSlotProps?.className),
313
- style: isPositioned ? externalPaperSlotProps.style : {
314
- ...externalPaperSlotProps.style,
315
- opacity: 0
301
+ ownerState,
302
+ getSlotProps: handlers => ({
303
+ ...handlers,
304
+ onEntering: (element, isAppearing) => {
305
+ handlers.onEntering?.(element, isAppearing);
306
+ handleEntering();
307
+ },
308
+ onExited: element => {
309
+ handlers.onExited?.(element);
310
+ handleExited();
316
311
  }
317
- },
318
- ownerState
312
+ }),
313
+ additionalProps: {
314
+ appear: true,
315
+ in: open
316
+ }
319
317
  });
318
+ if (transitionDurationProp === 'auto' && !TransitionSlot.muiSupportAuto) {
319
+ transitionDuration = undefined;
320
+ }
321
+
322
+ // If the container prop is provided, use that
323
+ // If the anchorEl prop is provided, use its parent body element as the container
324
+ // If neither are provided let the Modal take care of choosing the container
325
+ const container = containerProp || (anchorEl ? ownerDocument(resolveAnchorEl(anchorEl)).body : undefined);
320
326
  const [RootSlot, {
327
+ slots: rootSlotsProp,
321
328
  slotProps: rootSlotPropsProp,
322
329
  ...rootProps
323
330
  }] = useSlot('root', {
331
+ ref,
324
332
  elementType: PopoverRoot,
325
- externalForwardedProps,
333
+ externalForwardedProps: {
334
+ ...externalForwardedProps,
335
+ ...other
336
+ },
337
+ shouldForwardComponentProp: true,
326
338
  additionalProps: {
339
+ slots: {
340
+ backdrop: slots.backdrop
341
+ },
327
342
  slotProps: {
328
- backdrop: {
343
+ backdrop: mergeSlotProps(typeof slotProps.backdrop === 'function' ? slotProps.backdrop(ownerState) : slotProps.backdrop, {
329
344
  invisible: true
330
- }
345
+ })
331
346
  },
332
347
  container,
333
348
  open
@@ -335,25 +350,32 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
335
350
  ownerState,
336
351
  className: clsx(classes.root, className)
337
352
  });
338
- const handlePaperRef = useForkRef(paperRef, paperProps.ref);
353
+ const [PaperSlot, paperProps] = useSlot('paper', {
354
+ ref: paperRef,
355
+ className: classes.paper,
356
+ elementType: PopoverPaper,
357
+ externalForwardedProps,
358
+ shouldForwardComponentProp: true,
359
+ additionalProps: {
360
+ elevation,
361
+ style: isPositioned ? undefined : {
362
+ opacity: 0
363
+ }
364
+ },
365
+ ownerState
366
+ });
339
367
  return /*#__PURE__*/_jsx(RootSlot, {
340
368
  ...rootProps,
341
369
  ...(!isHostComponent(RootSlot) && {
370
+ slots: rootSlotsProp,
342
371
  slotProps: rootSlotPropsProp,
343
372
  disableScrollLock
344
373
  }),
345
- ...other,
346
- ref: ref,
347
- children: /*#__PURE__*/_jsx(TransitionComponent, {
348
- appear: true,
349
- in: open,
350
- onEntering: handleEntering,
351
- onExited: handleExited,
374
+ children: /*#__PURE__*/_jsx(TransitionSlot, {
375
+ ...transitionSlotProps,
352
376
  timeout: transitionDuration,
353
- ...TransitionProps,
354
377
  children: /*#__PURE__*/_jsx(PaperSlot, {
355
378
  ...paperProps,
356
- ref: handlePaperRef,
357
379
  children: children
358
380
  })
359
381
  })
@@ -421,8 +443,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
421
443
  anchorReference: PropTypes.oneOf(['anchorEl', 'anchorPosition', 'none']),
422
444
  /**
423
445
  * A backdrop component. This prop enables custom backdrop rendering.
424
- * @deprecated Use `slotProps.root.slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
425
- * Use the `slotProps.root.slots.backdrop` prop to make your application ready for the next version of Material UI.
446
+ * @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.
426
447
  * @default styled(Backdrop, {
427
448
  * name: 'MuiModal',
428
449
  * slot: 'Backdrop',
@@ -436,7 +457,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
436
457
  BackdropComponent: PropTypes.elementType,
437
458
  /**
438
459
  * Props applied to the [`Backdrop`](/material-ui/api/backdrop/) element.
439
- * @deprecated Use `slotProps.root.slotProps.backdrop` instead.
460
+ * @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.
440
461
  */
441
462
  BackdropProps: PropTypes.object,
442
463
  /**
@@ -500,16 +521,20 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
500
521
  * @default {}
501
522
  */
502
523
  slotProps: PropTypes.shape({
524
+ backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
503
525
  paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
504
- root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
526
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
527
+ transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
505
528
  }),
506
529
  /**
507
530
  * The components used for each slot inside.
508
531
  * @default {}
509
532
  */
510
533
  slots: PropTypes.shape({
534
+ backdrop: PropTypes.elementType,
511
535
  paper: PropTypes.elementType,
512
- root: PropTypes.elementType
536
+ root: PropTypes.elementType,
537
+ transition: PropTypes.elementType
513
538
  }),
514
539
  /**
515
540
  * The system prop that allows defining system overrides as well as additional CSS styles.
@@ -534,6 +559,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
534
559
  /**
535
560
  * The component used for the transition.
536
561
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
562
+ * @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.
537
563
  * @default Grow
538
564
  */
539
565
  TransitionComponent: PropTypes.elementType,
@@ -549,6 +575,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
549
575
  /**
550
576
  * Props applied to the transition element.
551
577
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
578
+ * @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.
552
579
  * @default {}
553
580
  */
554
581
  TransitionProps: PropTypes.object
package/Radio/Radio.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
3
  import { OverridableStringUnion } from '@mui/types';
4
4
  import { InternalStandardProps as StandardProps, Theme } from '..';
5
+ import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
5
6
  import { SwitchBaseProps } from '../internal/SwitchBase';
6
7
  import { RadioClasses } from './radioClasses';
7
8
 
@@ -9,8 +10,49 @@ export interface RadioPropsSizeOverrides {}
9
10
 
10
11
  export interface RadioPropsColorOverrides {}
11
12
 
13
+ export interface RadioRootSlotPropsOverrides {}
14
+
15
+ export interface RadioInputSlotPropsOverrides {}
16
+
17
+ export interface RadioSlots {
18
+ /**
19
+ * The component that renders the root slot.
20
+ * @default SwitchBase
21
+ */
22
+ root: React.ElementType;
23
+ /**
24
+ * The component that renders the input slot.
25
+ * @default SwitchBase's input
26
+ */
27
+ input: React.ElementType;
28
+ }
29
+
30
+ export type RadioSlotsAndSlotProps = CreateSlotsAndSlotProps<
31
+ RadioSlots,
32
+ {
33
+ /**
34
+ * Props forwarded to the root slot.
35
+ * By default, the avaible props are based on the span element.
36
+ */
37
+ root: SlotProps<
38
+ React.ElementType<SwitchBaseProps>,
39
+ RadioRootSlotPropsOverrides,
40
+ RadioOwnerState
41
+ >;
42
+ /**
43
+ * Props forwarded to the input slot.
44
+ * By default, the avaible props are based on the input element.
45
+ */
46
+ input: SlotProps<'input', RadioInputSlotPropsOverrides, RadioOwnerState>;
47
+ }
48
+ >;
49
+
12
50
  export interface RadioProps
13
- extends StandardProps<SwitchBaseProps, 'checkedIcon' | 'color' | 'icon' | 'type'> {
51
+ extends StandardProps<
52
+ SwitchBaseProps,
53
+ 'checkedIcon' | 'color' | 'icon' | 'type' | 'slots' | 'slotProps'
54
+ >,
55
+ RadioSlotsAndSlotProps {
14
56
  /**
15
57
  * The icon to display when the component is checked.
16
58
  * @default <RadioButtonIcon checked />
@@ -51,6 +93,8 @@ export interface RadioProps
51
93
  sx?: SxProps<Theme>;
52
94
  }
53
95
 
96
+ export interface RadioOwnerState extends Omit<RadioProps, 'slots' | 'slotProps'> {}
97
+
54
98
  /**
55
99
  *
56
100
  * Demos:
package/Radio/Radio.js CHANGED
@@ -17,6 +17,7 @@ import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
17
17
  import { styled } from "../zero-styled/index.js";
18
18
  import memoTheme from "../utils/memoTheme.js";
19
19
  import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
20
+ import useSlot from "../utils/useSlot.js";
20
21
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
21
22
  import { jsx as _jsx } from "react/jsx-runtime";
22
23
  const useUtilityClasses = ownerState => {
@@ -125,6 +126,8 @@ const Radio = /*#__PURE__*/React.forwardRef(function Radio(inProps, ref) {
125
126
  className,
126
127
  disabled: disabledProp,
127
128
  disableRipple = false,
129
+ slots = {},
130
+ slotProps = {},
128
131
  ...other
129
132
  } = props;
130
133
  const muiFormControl = useFormControl();
@@ -155,23 +158,45 @@ const Radio = /*#__PURE__*/React.forwardRef(function Radio(inProps, ref) {
155
158
  name = radioGroup.name;
156
159
  }
157
160
  }
158
- return /*#__PURE__*/_jsx(RadioRoot, {
159
- type: "radio",
160
- icon: /*#__PURE__*/React.cloneElement(icon, {
161
- fontSize: defaultIcon.props.fontSize ?? size
162
- }),
163
- checkedIcon: /*#__PURE__*/React.cloneElement(checkedIcon, {
164
- fontSize: defaultCheckedIcon.props.fontSize ?? size
165
- }),
166
- disabled: disabled,
167
- ownerState: ownerState,
168
- classes: classes,
169
- name: name,
170
- checked: checked,
171
- onChange: onChange,
172
- ref: ref,
161
+ const [RootSlot, rootSlotProps] = useSlot('root', {
162
+ ref,
163
+ elementType: RadioRoot,
173
164
  className: clsx(classes.root, className),
174
- ...other
165
+ shouldForwardComponentProp: true,
166
+ externalForwardedProps: {
167
+ slots,
168
+ slotProps,
169
+ ...other
170
+ },
171
+ getSlotProps: handlers => ({
172
+ ...handlers,
173
+ onChange: (event, ...args) => {
174
+ handlers.onChange?.(event, ...args);
175
+ onChange(event, ...args);
176
+ }
177
+ }),
178
+ ownerState,
179
+ additionalProps: {
180
+ type: 'radio',
181
+ icon: /*#__PURE__*/React.cloneElement(icon, {
182
+ fontSize: icon.props.fontSize ?? size
183
+ }),
184
+ checkedIcon: /*#__PURE__*/React.cloneElement(checkedIcon, {
185
+ fontSize: checkedIcon.props.fontSize ?? size
186
+ }),
187
+ disabled,
188
+ name,
189
+ checked,
190
+ slots,
191
+ slotProps: {
192
+ // Do not forward `slotProps.root` again because it's already handled by the `RootSlot` in this file.
193
+ input: typeof slotProps.input === 'function' ? slotProps.input(ownerState) : slotProps.input
194
+ }
195
+ }
196
+ });
197
+ return /*#__PURE__*/_jsx(RootSlot, {
198
+ ...rootSlotProps,
199
+ classes: classes
175
200
  });
176
201
  });
177
202
  process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ = {
@@ -223,10 +248,12 @@ process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ =
223
248
  id: PropTypes.string,
224
249
  /**
225
250
  * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
251
+ * @deprecated Use `slotProps.input` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
226
252
  */
227
253
  inputProps: PropTypes.object,
228
254
  /**
229
255
  * Pass a ref to the `input` element.
256
+ * @deprecated Use `slotProps.input.ref` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
230
257
  */
231
258
  inputRef: refType,
232
259
  /**
@@ -252,6 +279,22 @@ process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ =
252
279
  * @default 'medium'
253
280
  */
254
281
  size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
282
+ /**
283
+ * The props used for each slot inside.
284
+ * @default {}
285
+ */
286
+ slotProps: PropTypes.shape({
287
+ input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
288
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
289
+ }),
290
+ /**
291
+ * The components used for each slot inside.
292
+ * @default {}
293
+ */
294
+ slots: PropTypes.shape({
295
+ input: PropTypes.elementType,
296
+ root: PropTypes.elementType
297
+ }),
255
298
  /**
256
299
  * The system prop that allows defining system overrides as well as additional CSS styles.
257
300
  */
@@ -500,16 +500,16 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
500
500
  horizontal: 'center'
501
501
  },
502
502
  ...MenuProps,
503
- MenuListProps: {
504
- 'aria-labelledby': labelId,
505
- role: 'listbox',
506
- 'aria-multiselectable': multiple ? 'true' : undefined,
507
- disableListWrap: true,
508
- id: listboxId,
509
- ...MenuProps.MenuListProps
510
- },
511
503
  slotProps: {
512
504
  ...MenuProps.slotProps,
505
+ list: {
506
+ 'aria-labelledby': labelId,
507
+ role: 'listbox',
508
+ 'aria-multiselectable': multiple ? 'true' : undefined,
509
+ disableListWrap: true,
510
+ id: listboxId,
511
+ ...MenuProps.MenuListProps
512
+ },
513
513
  paper: {
514
514
  ...paperProps,
515
515
  style: {