@mui/material 6.4.5 → 6.4.7

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 (80) 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 +58 -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 +61 -16
  19. package/Rating/Rating.d.ts +59 -1
  20. package/Rating/Rating.js +131 -45
  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/Checkbox/Checkbox.js +51 -21
  40. package/modern/Drawer/Drawer.js +108 -36
  41. package/modern/Menu/Menu.js +58 -19
  42. package/modern/Modal/Modal.js +9 -10
  43. package/modern/Popover/Popover.js +78 -51
  44. package/modern/Radio/Radio.js +61 -16
  45. package/modern/Rating/Rating.js +131 -45
  46. package/modern/Select/SelectInput.js +8 -8
  47. package/modern/Snackbar/Snackbar.js +110 -32
  48. package/modern/SpeedDialAction/SpeedDialAction.js +108 -30
  49. package/modern/SwipeableDrawer/SwipeableDrawer.js +60 -13
  50. package/modern/Switch/Switch.js +2 -0
  51. package/modern/Tabs/Tabs.js +120 -52
  52. package/modern/Tabs/tabsClasses.js +1 -1
  53. package/modern/index.js +1 -1
  54. package/modern/internal/SwitchBase.js +84 -30
  55. package/modern/styles/createThemeNoVars.js +7 -2
  56. package/modern/version/index.js +2 -2
  57. package/node/Checkbox/Checkbox.js +51 -21
  58. package/node/Drawer/Drawer.js +108 -36
  59. package/node/Menu/Menu.js +58 -19
  60. package/node/Modal/Modal.js +9 -10
  61. package/node/Popover/Popover.js +78 -51
  62. package/node/Radio/Radio.js +61 -16
  63. package/node/Rating/Rating.js +132 -46
  64. package/node/Select/SelectInput.js +8 -8
  65. package/node/Snackbar/Snackbar.js +110 -32
  66. package/node/SpeedDialAction/SpeedDialAction.js +108 -30
  67. package/node/SwipeableDrawer/SwipeableDrawer.js +60 -13
  68. package/node/Switch/Switch.js +2 -0
  69. package/node/Tabs/Tabs.js +120 -52
  70. package/node/Tabs/tabsClasses.js +1 -1
  71. package/node/index.js +1 -1
  72. package/node/internal/SwitchBase.js +84 -30
  73. package/node/styles/createThemeNoVars.js +7 -2
  74. package/node/version/index.js +2 -2
  75. package/package.json +5 -5
  76. package/styles/ThemeProvider.d.ts +6 -0
  77. package/styles/ThemeProviderWithVars.d.ts +1 -0
  78. package/styles/createThemeNoVars.js +7 -2
  79. package/styles/index.d.ts +1 -0
  80. package/version/index.js +2 -2
package/Rating/Rating.js CHANGED
@@ -17,7 +17,9 @@ import memoTheme from "../utils/memoTheme.js";
17
17
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
18
18
  import slotShouldForwardProp from "../styles/slotShouldForwardProp.js";
19
19
  import ratingClasses, { getRatingUtilityClass } from "./ratingClasses.js";
20
+ import useSlot from "../utils/useSlot.js";
20
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ import { createElement as _createElement } from "react";
21
23
  function getDecimalPrecision(num) {
22
24
  const decimalPart = num.toString().split('.')[1];
23
25
  return decimalPart ? decimalPart.length : 0;
@@ -220,7 +222,9 @@ function RatingItem(props) {
220
222
  readOnly,
221
223
  ownerState,
222
224
  ratingValue,
223
- ratingValueRounded
225
+ ratingValueRounded,
226
+ slots = {},
227
+ slotProps = {}
224
228
  } = props;
225
229
  const isFilled = highlightSelectedOnly ? itemValue === ratingValue : itemValue <= ratingValue;
226
230
  const isHovered = itemValue <= hover;
@@ -232,10 +236,14 @@ function RatingItem(props) {
232
236
  // Update to const id = useId(); when React 17 support is dropped.
233
237
  // More details: https://github.com/mui/material-ui/issues/40997
234
238
  const id = `${name}-${useId()}`;
235
- const container = /*#__PURE__*/_jsx(RatingIcon, {
236
- as: IconContainerComponent,
237
- value: itemValue,
239
+ const externalForwardedProps = {
240
+ slots,
241
+ slotProps
242
+ };
243
+ const [IconSlot, iconSlotProps] = useSlot('icon', {
244
+ elementType: RatingIcon,
238
245
  className: clsx(classes.icon, isFilled ? classes.iconFilled : classes.iconEmpty, isHovered && classes.iconHover, isFocused && classes.iconFocus, isActive && classes.iconActive),
246
+ externalForwardedProps,
239
247
  ownerState: {
240
248
  ...ownerState,
241
249
  iconEmpty: !isFilled,
@@ -244,6 +252,29 @@ function RatingItem(props) {
244
252
  iconFocus: isFocused,
245
253
  iconActive: isActive
246
254
  },
255
+ additionalProps: {
256
+ value: itemValue
257
+ },
258
+ internalForwardedProps: {
259
+ // TODO: remove this in v7 because `IconContainerComponent` is deprecated
260
+ // only forward if `slots.icon` is NOT provided
261
+ as: IconContainerComponent
262
+ }
263
+ });
264
+ const [LabelSlot, labelSlotProps] = useSlot('label', {
265
+ elementType: RatingLabel,
266
+ externalForwardedProps,
267
+ ownerState: {
268
+ ...ownerState,
269
+ emptyValueFocused: undefined
270
+ },
271
+ additionalProps: {
272
+ style: labelProps?.style,
273
+ htmlFor: id
274
+ }
275
+ });
276
+ const container = /*#__PURE__*/_jsx(IconSlot, {
277
+ ...iconSlotProps,
247
278
  children: emptyIcon && !isFilled ? emptyIcon : icon
248
279
  });
249
280
  if (readOnly) {
@@ -253,13 +284,8 @@ function RatingItem(props) {
253
284
  });
254
285
  }
255
286
  return /*#__PURE__*/_jsxs(React.Fragment, {
256
- children: [/*#__PURE__*/_jsxs(RatingLabel, {
257
- ownerState: {
258
- ...ownerState,
259
- emptyValueFocused: undefined
260
- },
261
- htmlFor: id,
262
- ...labelProps,
287
+ children: [/*#__PURE__*/_jsxs(LabelSlot, {
288
+ ...labelSlotProps,
263
289
  children: [container, /*#__PURE__*/_jsx("span", {
264
290
  className: classes.visuallyHidden,
265
291
  children: getLabelText(itemValue)
@@ -300,7 +326,9 @@ process.env.NODE_ENV !== "production" ? RatingItem.propTypes = {
300
326
  ownerState: PropTypes.object.isRequired,
301
327
  ratingValue: PropTypes.number,
302
328
  ratingValueRounded: PropTypes.number,
303
- readOnly: PropTypes.bool.isRequired
329
+ readOnly: PropTypes.bool.isRequired,
330
+ slotProps: PropTypes.object,
331
+ slots: PropTypes.object
304
332
  } : void 0;
305
333
  const defaultIcon = /*#__PURE__*/_jsx(Star, {
306
334
  fontSize: "inherit"
@@ -337,6 +365,8 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
337
365
  readOnly = false,
338
366
  size = 'medium',
339
367
  value: valueProp,
368
+ slots = {},
369
+ slotProps = {},
340
370
  ...other
341
371
  } = props;
342
372
  const name = useId(nameProp);
@@ -474,16 +504,50 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
474
504
  size
475
505
  };
476
506
  const classes = useUtilityClasses(ownerState);
477
- return /*#__PURE__*/_jsxs(RatingRoot, {
478
- as: component,
507
+ const externalForwardedProps = {
508
+ slots,
509
+ slotProps
510
+ };
511
+ const [RootSlot, rootSlotProps] = useSlot('root', {
479
512
  ref: handleRef,
480
- onMouseMove: handleMouseMove,
481
- onMouseLeave: handleMouseLeave,
482
- className: clsx(classes.root, className, readOnly && 'MuiRating-readOnly'),
483
- ownerState: ownerState,
484
- role: readOnly ? 'img' : null,
485
- "aria-label": readOnly ? getLabelText(value) : null,
486
- ...other,
513
+ className: clsx(classes.root, className),
514
+ elementType: RatingRoot,
515
+ externalForwardedProps: {
516
+ ...externalForwardedProps,
517
+ ...other,
518
+ component
519
+ },
520
+ getSlotProps: handlers => ({
521
+ ...handlers,
522
+ onMouseMove: event => {
523
+ handleMouseMove(event);
524
+ handlers.onMouseMove?.(event);
525
+ },
526
+ onMouseLeave: event => {
527
+ handleMouseLeave(event);
528
+ handlers.onMouseLeave?.(event);
529
+ }
530
+ }),
531
+ ownerState,
532
+ additionalProps: {
533
+ role: readOnly ? 'img' : null,
534
+ 'aria-label': readOnly ? getLabelText(value) : null
535
+ }
536
+ });
537
+ const [LabelSlot, labelSlotProps] = useSlot('label', {
538
+ className: clsx(classes.label, classes.labelEmptyValue),
539
+ elementType: RatingLabel,
540
+ externalForwardedProps,
541
+ ownerState
542
+ });
543
+ const [DecimalSlot, decimalSlotProps] = useSlot('decimal', {
544
+ className: classes.decimal,
545
+ elementType: RatingDecimal,
546
+ externalForwardedProps,
547
+ ownerState
548
+ });
549
+ return /*#__PURE__*/_jsxs(RootSlot, {
550
+ ...rootSlotProps,
487
551
  children: [Array.from(new Array(max)).map((_, index) => {
488
552
  const itemValue = index + 1;
489
553
  const ratingItemProps = {
@@ -504,41 +568,42 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
504
568
  ratingValue: value,
505
569
  ratingValueRounded: valueRounded,
506
570
  readOnly,
507
- ownerState
571
+ ownerState,
572
+ slots,
573
+ slotProps
508
574
  };
509
575
  const isActive = itemValue === Math.ceil(value) && (hover !== -1 || focus !== -1);
510
576
  if (precision < 1) {
511
577
  const items = Array.from(new Array(1 / precision));
512
- return /*#__PURE__*/_jsx(RatingDecimal, {
513
- className: clsx(classes.decimal, isActive && classes.iconActive),
514
- ownerState: ownerState,
515
- iconActive: isActive,
516
- children: items.map(($, indexDecimal) => {
517
- const itemDecimalValue = roundValueToPrecision(itemValue - 1 + (indexDecimal + 1) * precision, precision);
518
- return /*#__PURE__*/_jsx(RatingItem, {
519
- ...ratingItemProps,
520
- // The icon is already displayed as active
521
- isActive: false,
522
- itemValue: itemDecimalValue,
523
- labelProps: {
524
- style: items.length - 1 === indexDecimal ? {} : {
525
- width: itemDecimalValue === value ? `${(indexDecimal + 1) * precision * 100}%` : '0%',
526
- overflow: 'hidden',
527
- position: 'absolute'
528
- }
578
+ return /*#__PURE__*/_createElement(DecimalSlot, {
579
+ ...decimalSlotProps,
580
+ key: itemValue,
581
+ className: clsx(decimalSlotProps.className, isActive && classes.iconActive),
582
+ iconActive: isActive
583
+ }, items.map(($, indexDecimal) => {
584
+ const itemDecimalValue = roundValueToPrecision(itemValue - 1 + (indexDecimal + 1) * precision, precision);
585
+ return /*#__PURE__*/_jsx(RatingItem, {
586
+ ...ratingItemProps,
587
+ // The icon is already displayed as active
588
+ isActive: false,
589
+ itemValue: itemDecimalValue,
590
+ labelProps: {
591
+ style: items.length - 1 === indexDecimal ? {} : {
592
+ width: itemDecimalValue === value ? `${(indexDecimal + 1) * precision * 100}%` : '0%',
593
+ overflow: 'hidden',
594
+ position: 'absolute'
529
595
  }
530
- }, itemDecimalValue);
531
- })
532
- }, itemValue);
596
+ }
597
+ }, itemDecimalValue);
598
+ }));
533
599
  }
534
600
  return /*#__PURE__*/_jsx(RatingItem, {
535
601
  ...ratingItemProps,
536
602
  isActive: isActive,
537
603
  itemValue: itemValue
538
604
  }, itemValue);
539
- }), !readOnly && !disabled && /*#__PURE__*/_jsxs(RatingLabel, {
540
- className: clsx(classes.label, classes.labelEmptyValue),
541
- ownerState: ownerState,
605
+ }), !readOnly && !disabled && /*#__PURE__*/_jsxs(LabelSlot, {
606
+ ...labelSlotProps,
542
607
  children: [/*#__PURE__*/_jsx("input", {
543
608
  className: classes.visuallyHidden,
544
609
  value: "",
@@ -622,6 +687,7 @@ process.env.NODE_ENV !== "production" ? Rating.propTypes /* remove-proptypes */
622
687
  icon: PropTypes.node,
623
688
  /**
624
689
  * The component containing the icon.
690
+ * @deprecated Use `slotProps.icon.component` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
625
691
  * @default function IconContainer(props) {
626
692
  * const { value, ...other } = props;
627
693
  * return <span {...other} />;
@@ -679,6 +745,26 @@ process.env.NODE_ENV !== "production" ? Rating.propTypes /* remove-proptypes */
679
745
  * @default 'medium'
680
746
  */
681
747
  size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
748
+ /**
749
+ * The props used for each slot inside.
750
+ * @default {}
751
+ */
752
+ slotProps: PropTypes.shape({
753
+ decimal: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
754
+ icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
755
+ label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
756
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
757
+ }),
758
+ /**
759
+ * The components used for each slot inside.
760
+ * @default {}
761
+ */
762
+ slots: PropTypes.shape({
763
+ decimal: PropTypes.elementType,
764
+ icon: PropTypes.elementType,
765
+ label: PropTypes.elementType,
766
+ root: PropTypes.elementType
767
+ }),
682
768
  /**
683
769
  * The system prop that allows defining system overrides as well as additional CSS styles.
684
770
  */
@@ -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: {
@@ -1,11 +1,80 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
- import { ClickAwayListenerProps } from '../ClickAwayListener';
3
+ import ClickAwayListener, { ClickAwayListenerProps } from '../ClickAwayListener';
4
4
  import { Theme } from '../styles';
5
5
  import { InternalStandardProps as StandardProps } from '..';
6
6
  import { SnackbarContentProps } from '../SnackbarContent';
7
7
  import { TransitionProps } from '../transitions/transition';
8
8
  import { SnackbarClasses } from './snackbarClasses';
9
+ import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from '../utils/types';
10
+
11
+ export interface SnackbarSlots {
12
+ /**
13
+ * The component that renders the root slot.
14
+ * @default 'div'
15
+ */
16
+ root: React.ElementType;
17
+ /**
18
+ * The component that renders the content slot.
19
+ * @default SnackbarContent
20
+ */
21
+ content: React.ElementType;
22
+ /**
23
+ * The component that renders the clickAwayListener slot.
24
+ * @default ClickAwayListener
25
+ */
26
+ clickAwayListener: React.ElementType;
27
+ /**
28
+ * The component that renders the transition.
29
+ * [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
30
+ * @default Grow
31
+ */
32
+ transition: React.ElementType;
33
+ }
34
+
35
+ export interface SnackbarRootSlotPropsOverrides {}
36
+ export interface SnackbarContentSlotPropsOverrides {}
37
+ export interface SnackbarClickAwayListenerSlotPropsOverrides {}
38
+
39
+ export interface SnackbarTransitionSlotPropsOverrides {}
40
+
41
+ export type SnackbarSlotsAndSlotProps = CreateSlotsAndSlotProps<
42
+ SnackbarSlots,
43
+ {
44
+ /**
45
+ * Props forwarded to the root slot.
46
+ * By default, the avaible props are based on the div element.
47
+ */
48
+ root: SlotProps<'div', SnackbarRootSlotPropsOverrides, SnackbarOwnerState>;
49
+ /**
50
+ * Props forwarded to the content slot.
51
+ * By default, the avaible props are based on the [SnackbarContent](https://mui.com/material-ui/api/snackbar-content/#props) component.
52
+ */
53
+ content: SlotProps<
54
+ React.ElementType<SnackbarContentProps>,
55
+ SnackbarContentSlotPropsOverrides,
56
+ SnackbarOwnerState
57
+ >;
58
+ /**
59
+ * Props forwarded to the clickAwayListener slot.
60
+ * By default, the avaible props are based on the [ClickAwayListener](https://mui.com/material-ui/api/click-away-listener/#props) component.
61
+ */
62
+ clickAwayListener: SlotComponentProps<
63
+ typeof ClickAwayListener,
64
+ SnackbarClickAwayListenerSlotPropsOverrides,
65
+ SnackbarOwnerState
66
+ >;
67
+ /**
68
+ * Props applied to the transition element.
69
+ * By default, the element is based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
70
+ */
71
+ transition: SlotComponentProps<
72
+ React.ElementType,
73
+ TransitionProps & SnackbarTransitionSlotPropsOverrides,
74
+ SnackbarOwnerState
75
+ >;
76
+ }
77
+ >;
9
78
 
10
79
  export interface SnackbarOrigin {
11
80
  vertical: 'top' | 'bottom';
@@ -14,7 +83,9 @@ export interface SnackbarOrigin {
14
83
 
15
84
  export type SnackbarCloseReason = 'timeout' | 'clickaway' | 'escapeKeyDown';
16
85
 
17
- export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
86
+ export interface SnackbarProps
87
+ extends Omit<StandardProps<React.HTMLAttributes<HTMLDivElement>>, 'slots' | 'slotProps'>,
88
+ SnackbarSlotsAndSlotProps {
18
89
  /**
19
90
  * The action to display. It renders after the message, at the end of the snackbar.
20
91
  */
@@ -44,10 +115,12 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
44
115
  classes?: Partial<SnackbarClasses>;
45
116
  /**
46
117
  * Props applied to the `ClickAwayListener` element.
118
+ * @deprecated Use `slotProps.clickAwayListener` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
47
119
  */
48
120
  ClickAwayListenerProps?: Partial<ClickAwayListenerProps>;
49
121
  /**
50
122
  * Props applied to the [`SnackbarContent`](https://mui.com/material-ui/api/snackbar-content/) element.
123
+ * @deprecated Use `slotProps.content` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
51
124
  */
52
125
  ContentProps?: Partial<SnackbarContentProps>;
53
126
  /**
@@ -95,6 +168,7 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
95
168
  /**
96
169
  * The component used for the transition.
97
170
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
171
+ * @deprecated Use `slots.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
98
172
  * @default Grow
99
173
  */
100
174
  TransitionComponent?: React.JSXElementConstructor<
@@ -112,6 +186,7 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
112
186
  /**
113
187
  * Props applied to the transition element.
114
188
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
189
+ * @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
115
190
  * @default {}
116
191
  */
117
192
  TransitionProps?: TransitionProps;
@@ -128,3 +203,5 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
128
203
  * - [Snackbar API](https://mui.com/material-ui/api/snackbar/)
129
204
  */
130
205
  export default function Snackbar(props: SnackbarProps): React.JSX.Element;
206
+
207
+ export interface SnackbarOwnerState extends Omit<SnackbarProps, 'slots' | 'slotProps'> {}
@@ -3,7 +3,6 @@
3
3
  import * as React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import composeClasses from '@mui/utils/composeClasses';
6
- import useSlotProps from '@mui/utils/useSlotProps';
7
6
  import useSnackbar from "./useSnackbar.js";
8
7
  import ClickAwayListener from "../ClickAwayListener/index.js";
9
8
  import { styled, useTheme } from "../zero-styled/index.js";
@@ -13,6 +12,7 @@ import capitalize from "../utils/capitalize.js";
13
12
  import Grow from "../Grow/index.js";
14
13
  import SnackbarContent from "../SnackbarContent/index.js";
15
14
  import { getSnackbarUtilityClass } from "./snackbarClasses.js";
15
+ import useSlot from "../utils/useSlot.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  const useUtilityClasses = ownerState => {
18
18
  const {
@@ -120,8 +120,8 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
120
120
  autoHideDuration = null,
121
121
  children,
122
122
  className,
123
- ClickAwayListenerProps,
124
- ContentProps,
123
+ ClickAwayListenerProps: ClickAwayListenerPropsProp,
124
+ ContentProps: ContentPropsProp,
125
125
  disableWindowBlurListener = false,
126
126
  message,
127
127
  onBlur,
@@ -131,12 +131,14 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
131
131
  onMouseLeave,
132
132
  open,
133
133
  resumeHideDuration,
134
- TransitionComponent = Grow,
134
+ slots = {},
135
+ slotProps = {},
136
+ TransitionComponent: TransitionComponentProp,
135
137
  transitionDuration = defaultTransitionDuration,
136
138
  TransitionProps: {
137
139
  onEnter,
138
140
  onExited,
139
- ...TransitionProps
141
+ ...TransitionPropsProp
140
142
  } = {},
141
143
  ...other
142
144
  } = props;
@@ -148,7 +150,7 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
148
150
  },
149
151
  autoHideDuration,
150
152
  disableWindowBlurListener,
151
- TransitionComponent,
153
+ TransitionComponent: TransitionComponentProp,
152
154
  transitionDuration
153
155
  };
154
156
  const classes = useUtilityClasses(ownerState);
@@ -159,16 +161,6 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
159
161
  ...ownerState
160
162
  });
161
163
  const [exited, setExited] = React.useState(true);
162
- const rootProps = useSlotProps({
163
- elementType: SnackbarRoot,
164
- getSlotProps: getRootProps,
165
- externalForwardedProps: other,
166
- ownerState,
167
- additionalProps: {
168
- ref
169
- },
170
- className: [classes.root, className]
171
- });
172
164
  const handleExited = node => {
173
165
  setExited(true);
174
166
  if (onExited) {
@@ -181,28 +173,84 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
181
173
  onEnter(node, isAppearing);
182
174
  }
183
175
  };
176
+ const externalForwardedProps = {
177
+ slots: {
178
+ transition: TransitionComponentProp,
179
+ ...slots
180
+ },
181
+ slotProps: {
182
+ content: ContentPropsProp,
183
+ clickAwayListener: ClickAwayListenerPropsProp,
184
+ transition: TransitionPropsProp,
185
+ ...slotProps
186
+ }
187
+ };
188
+ const [Root, rootProps] = useSlot('root', {
189
+ ref,
190
+ className: [classes.root, className],
191
+ elementType: SnackbarRoot,
192
+ getSlotProps: getRootProps,
193
+ externalForwardedProps: {
194
+ ...externalForwardedProps,
195
+ ...other
196
+ },
197
+ ownerState
198
+ });
199
+ const [ClickAwaySlot, clickAwayListenerProps] = useSlot('clickAwayListener', {
200
+ elementType: ClickAwayListener,
201
+ externalForwardedProps,
202
+ getSlotProps: handlers => ({
203
+ onClickAway: (...params) => {
204
+ handlers.onClickAway?.(...params);
205
+ onClickAway(...params);
206
+ }
207
+ }),
208
+ ownerState
209
+ });
210
+ const [ContentSlot, contentSlotProps] = useSlot('content', {
211
+ elementType: SnackbarContent,
212
+ shouldForwardComponentProp: true,
213
+ externalForwardedProps,
214
+ additionalProps: {
215
+ message,
216
+ action
217
+ },
218
+ ownerState
219
+ });
220
+ const [TransitionSlot, transitionProps] = useSlot('transition', {
221
+ elementType: Grow,
222
+ externalForwardedProps,
223
+ getSlotProps: handlers => ({
224
+ onEnter: (...params) => {
225
+ handlers.onEnter?.(...params);
226
+ handleEnter(...params);
227
+ },
228
+ onExited: (...params) => {
229
+ handlers.onExited?.(...params);
230
+ handleExited(...params);
231
+ }
232
+ }),
233
+ additionalProps: {
234
+ appear: true,
235
+ in: open,
236
+ timeout: transitionDuration,
237
+ direction: vertical === 'top' ? 'down' : 'up'
238
+ },
239
+ ownerState
240
+ });
184
241
 
185
242
  // So we only render active snackbars.
186
243
  if (!open && exited) {
187
244
  return null;
188
245
  }
189
- return /*#__PURE__*/_jsx(ClickAwayListener, {
190
- onClickAway: onClickAway,
191
- ...ClickAwayListenerProps,
192
- children: /*#__PURE__*/_jsx(SnackbarRoot, {
246
+ return /*#__PURE__*/_jsx(ClickAwaySlot, {
247
+ ...clickAwayListenerProps,
248
+ children: /*#__PURE__*/_jsx(Root, {
193
249
  ...rootProps,
194
- children: /*#__PURE__*/_jsx(TransitionComponent, {
195
- appear: true,
196
- in: open,
197
- timeout: transitionDuration,
198
- direction: vertical === 'top' ? 'down' : 'up',
199
- onEnter: handleEnter,
200
- onExited: handleExited,
201
- ...TransitionProps,
202
- children: children || /*#__PURE__*/_jsx(SnackbarContent, {
203
- message: message,
204
- action: action,
205
- ...ContentProps
250
+ children: /*#__PURE__*/_jsx(TransitionSlot, {
251
+ ...transitionProps,
252
+ children: children || /*#__PURE__*/_jsx(ContentSlot, {
253
+ ...contentSlotProps
206
254
  })
207
255
  })
208
256
  })
@@ -249,10 +297,12 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
249
297
  className: PropTypes.string,
250
298
  /**
251
299
  * Props applied to the `ClickAwayListener` element.
300
+ * @deprecated Use `slotProps.clickAwayListener` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
252
301
  */
253
302
  ClickAwayListenerProps: PropTypes.object,
254
303
  /**
255
304
  * Props applied to the [`SnackbarContent`](https://mui.com/material-ui/api/snackbar-content/) element.
305
+ * @deprecated Use `slotProps.content` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
256
306
  */
257
307
  ContentProps: PropTypes.object,
258
308
  /**
@@ -309,6 +359,32 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
309
359
  * we default to `autoHideDuration / 2` ms.
310
360
  */
311
361
  resumeHideDuration: PropTypes.number,
362
+ /**
363
+ * The props used for each slot inside.
364
+ * @default {}
365
+ */
366
+ slotProps: PropTypes.shape({
367
+ clickAwayListener: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
368
+ children: PropTypes.element.isRequired,
369
+ disableReactTree: PropTypes.bool,
370
+ mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
371
+ onClickAway: PropTypes.func,
372
+ touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
373
+ })]),
374
+ content: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
375
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
376
+ transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
377
+ }),
378
+ /**
379
+ * The components used for each slot inside.
380
+ * @default {}
381
+ */
382
+ slots: PropTypes.shape({
383
+ clickAwayListener: PropTypes.elementType,
384
+ content: PropTypes.elementType,
385
+ root: PropTypes.elementType,
386
+ transition: PropTypes.elementType
387
+ }),
312
388
  /**
313
389
  * The system prop that allows defining system overrides as well as additional CSS styles.
314
390
  */
@@ -316,6 +392,7 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
316
392
  /**
317
393
  * The component used for the transition.
318
394
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
395
+ * @deprecated Use `slots.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
319
396
  * @default Grow
320
397
  */
321
398
  TransitionComponent: PropTypes.elementType,
@@ -335,6 +412,7 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
335
412
  /**
336
413
  * Props applied to the transition element.
337
414
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
415
+ * @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
338
416
  * @default {}
339
417
  */
340
418
  TransitionProps: PropTypes.object
@@ -5,7 +5,7 @@ import { InternalStandardProps as StandardProps } from '..';
5
5
  import { FabProps } from '../Fab';
6
6
  import { TransitionProps } from '../transitions';
7
7
  import { SpeedDialClasses } from './speedDialClasses';
8
- import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
8
+ import { CreateSlotsAndSlotProps, SlotComponentProps } from '../utils/types';
9
9
 
10
10
  export type CloseReason = 'toggle' | 'blur' | 'mouseLeave' | 'escapeKeyDown';
11
11
  export type OpenReason = 'toggle' | 'focus' | 'mouseEnter';
@@ -14,17 +14,19 @@ export interface SpeedDialSlots {
14
14
  /**
15
15
  * The component that renders the transition.
16
16
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
17
- * @default {}
17
+ * @default Zoom
18
18
  */
19
- transition: React.JSXElementConstructor<
20
- TransitionProps & { children: React.ReactElement<unknown, any> }
21
- >;
19
+ transition: React.ElementType;
22
20
  }
23
21
 
24
22
  export type SpeedDialSlotsAndSlotProps = CreateSlotsAndSlotProps<
25
23
  SpeedDialSlots,
26
24
  {
27
- transition: SlotProps<React.JSXElementConstructor<TransitionProps>, {}, SpeedDialOwnerState>;
25
+ /**
26
+ * Props forwarded to the transition slot.
27
+ * By default, the avaible props are based on the [Zoom](https://mui.com/material-ui/api/zoom/#props) component.
28
+ */
29
+ transition: SlotComponentProps<React.ElementType, TransitionProps, SpeedDialOwnerState>;
28
30
  }
29
31
  >;
30
32