@mui/material 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/Alert/Alert.d.ts +69 -0
  2. package/Alert/Alert.js +53 -21
  3. package/AppBar/AppBar.d.ts +1 -1
  4. package/AppBar/AppBar.js +1 -1
  5. package/Autocomplete/Autocomplete.d.ts +1 -1
  6. package/Autocomplete/Autocomplete.js +35 -48
  7. package/Button/Button.d.ts +18 -0
  8. package/Button/Button.js +233 -15
  9. package/Button/buttonClasses.d.ts +14 -0
  10. package/Button/buttonClasses.js +1 -1
  11. package/CHANGELOG.md +85 -0
  12. package/CardHeader/CardHeader.d.ts +114 -1
  13. package/CardHeader/CardHeader.js +99 -32
  14. package/CircularProgress/CircularProgress.js +2 -2
  15. package/IconButton/IconButton.d.ts +12 -0
  16. package/IconButton/IconButton.js +69 -7
  17. package/IconButton/iconButtonClasses.d.ts +4 -0
  18. package/IconButton/iconButtonClasses.js +1 -1
  19. package/LinearProgress/LinearProgress.js +4 -4
  20. package/LinearProgress/linearProgressClasses.d.ts +31 -9
  21. package/LinearProgress/linearProgressClasses.js +1 -1
  22. package/Link/getTextDecoration.js +3 -2
  23. package/Select/Select.js +10 -1
  24. package/Select/SelectInput.js +1 -1
  25. package/Select/selectClasses.d.ts +9 -3
  26. package/Slider/useSlider.js +5 -2
  27. package/StepLabel/StepLabel.d.ts +1 -1
  28. package/TableSortLabel/TableSortLabel.d.ts +43 -1
  29. package/TableSortLabel/TableSortLabel.js +40 -7
  30. package/Tooltip/Tooltip.d.ts +1 -1
  31. package/Tooltip/Tooltip.js +1 -1
  32. package/index.js +1 -1
  33. package/modern/Alert/Alert.js +53 -21
  34. package/modern/AppBar/AppBar.js +1 -1
  35. package/modern/Autocomplete/Autocomplete.js +35 -48
  36. package/modern/Button/Button.js +233 -15
  37. package/modern/Button/buttonClasses.js +1 -1
  38. package/modern/CardHeader/CardHeader.js +99 -32
  39. package/modern/CircularProgress/CircularProgress.js +2 -2
  40. package/modern/IconButton/IconButton.js +69 -7
  41. package/modern/IconButton/iconButtonClasses.js +1 -1
  42. package/modern/LinearProgress/LinearProgress.js +4 -4
  43. package/modern/LinearProgress/linearProgressClasses.js +1 -1
  44. package/modern/Link/getTextDecoration.js +3 -2
  45. package/modern/Select/Select.js +10 -1
  46. package/modern/Select/SelectInput.js +1 -1
  47. package/modern/Slider/useSlider.js +5 -2
  48. package/modern/TableSortLabel/TableSortLabel.js +40 -7
  49. package/modern/Tooltip/Tooltip.js +1 -1
  50. package/modern/index.js +1 -1
  51. package/modern/utils/index.js +1 -0
  52. package/modern/utils/mergeSlotProps.js +43 -0
  53. package/modern/utils/useSlot.js +5 -1
  54. package/modern/version/index.js +2 -2
  55. package/node/Alert/Alert.js +53 -21
  56. package/node/AppBar/AppBar.js +1 -1
  57. package/node/Autocomplete/Autocomplete.js +35 -48
  58. package/node/Button/Button.js +233 -15
  59. package/node/Button/buttonClasses.js +1 -1
  60. package/node/CardHeader/CardHeader.js +99 -32
  61. package/node/CircularProgress/CircularProgress.js +2 -2
  62. package/node/IconButton/IconButton.js +68 -6
  63. package/node/IconButton/iconButtonClasses.js +1 -1
  64. package/node/LinearProgress/LinearProgress.js +4 -4
  65. package/node/LinearProgress/linearProgressClasses.js +1 -1
  66. package/node/Link/getTextDecoration.js +3 -2
  67. package/node/Select/Select.js +10 -1
  68. package/node/Select/SelectInput.js +1 -1
  69. package/node/Slider/useSlider.js +5 -2
  70. package/node/TableSortLabel/TableSortLabel.js +40 -7
  71. package/node/Tooltip/Tooltip.js +1 -1
  72. package/node/index.js +1 -1
  73. package/node/utils/index.js +7 -0
  74. package/node/utils/mergeSlotProps.js +50 -0
  75. package/node/utils/useSlot.js +5 -1
  76. package/node/version/index.js +2 -2
  77. package/package.json +6 -6
  78. package/utils/index.d.ts +1 -0
  79. package/utils/index.js +1 -0
  80. package/utils/mergeSlotProps.d.ts +2 -0
  81. package/utils/mergeSlotProps.js +43 -0
  82. package/utils/useSlot.d.ts +8 -0
  83. package/utils/useSlot.js +5 -1
  84. package/version/index.js +2 -2
package/Alert/Alert.d.ts CHANGED
@@ -10,10 +10,39 @@ export type AlertColor = 'success' | 'info' | 'warning' | 'error';
10
10
 
11
11
  export interface AlertPropsVariantOverrides {}
12
12
  export interface AlertPropsColorOverrides {}
13
+
14
+ export interface AlertRootSlotPropsOverrides {}
15
+
16
+ export interface AlertIconSlotPropsOverrides {}
17
+
18
+ export interface AlertMessageSlotPropsOverrides {}
19
+
20
+ export interface AlertActionSlotPropsOverrides {}
21
+
13
22
  export interface AlertCloseButtonSlotPropsOverrides {}
14
23
  export interface AlertCloseIconSlotPropsOverrides {}
15
24
 
16
25
  export interface AlertSlots {
26
+ /**
27
+ * The component that renders the root slot.
28
+ * @default Paper
29
+ */
30
+ root: React.ElementType;
31
+ /**
32
+ * The component that renders the icon slot.
33
+ * @default div
34
+ */
35
+ icon: React.ElementType;
36
+ /**
37
+ * The component that renders the message slot.
38
+ * @default div
39
+ */
40
+ message: React.ElementType;
41
+ /**
42
+ * The component that renders the action slot.
43
+ * @default div
44
+ */
45
+ action: React.ElementType;
17
46
  /**
18
47
  * The component that renders the close button.
19
48
  * @default IconButton
@@ -29,11 +58,51 @@ export interface AlertSlots {
29
58
  export type AlertSlotsAndSlotProps = CreateSlotsAndSlotProps<
30
59
  AlertSlots,
31
60
  {
61
+ /**
62
+ * Props forwarded to the root slot.
63
+ * By default, the avaible props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
64
+ */
65
+ root: SlotProps<React.ElementType<PaperProps>, AlertRootSlotPropsOverrides, AlertOwnerState>;
66
+ /**
67
+ * Props forwarded to the icon slot.
68
+ * By default, the avaible props are based on a div element.
69
+ */
70
+ icon: SlotProps<
71
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
72
+ AlertIconSlotPropsOverrides,
73
+ AlertOwnerState
74
+ >;
75
+ /**
76
+ * Props forwarded to the message slot.
77
+ * By default, the avaible props are based on a div element.
78
+ */
79
+ message: SlotProps<
80
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
81
+ AlertMessageSlotPropsOverrides,
82
+ AlertOwnerState
83
+ >;
84
+ /**
85
+ * Props forwarded to the action slot.
86
+ * By default, the avaible props are based on a div element.
87
+ */
88
+ action: SlotProps<
89
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
90
+ AlertActionSlotPropsOverrides,
91
+ AlertOwnerState
92
+ >;
93
+ /**
94
+ * Props forwarded to the closeButton slot.
95
+ * By default, the avaible props are based on the [IconButton](https://mui.com/material-ui/api/icon-button/#props) component.
96
+ */
32
97
  closeButton: SlotProps<
33
98
  React.ElementType<IconButtonProps>,
34
99
  AlertCloseButtonSlotPropsOverrides,
35
100
  AlertOwnerState
36
101
  >;
102
+ /**
103
+ * Props forwarded to the closeIcon slot.
104
+ * By default, the avaible props are based on the [SvgIcon](https://mui.com/material-ui/api/svg-icon/#props) component.
105
+ */
37
106
  closeIcon: SlotProps<
38
107
  React.ElementType<SvgIconProps>,
39
108
  AlertCloseIconSlotPropsOverrides,
package/Alert/Alert.js CHANGED
@@ -187,6 +187,39 @@ const Alert = /*#__PURE__*/React.forwardRef(function Alert(inProps, ref) {
187
187
  ...slotProps
188
188
  }
189
189
  };
190
+ const [RootSlot, rootSlotProps] = useSlot('root', {
191
+ ref,
192
+ shouldForwardComponentProp: true,
193
+ className: clsx(classes.root, className),
194
+ elementType: AlertRoot,
195
+ externalForwardedProps: {
196
+ ...externalForwardedProps,
197
+ ...other
198
+ },
199
+ ownerState,
200
+ additionalProps: {
201
+ role,
202
+ elevation: 0
203
+ }
204
+ });
205
+ const [IconSlot, iconSlotProps] = useSlot('icon', {
206
+ className: classes.icon,
207
+ elementType: AlertIcon,
208
+ externalForwardedProps,
209
+ ownerState
210
+ });
211
+ const [MessageSlot, messageSlotProps] = useSlot('message', {
212
+ className: classes.message,
213
+ elementType: AlertMessage,
214
+ externalForwardedProps,
215
+ ownerState
216
+ });
217
+ const [ActionSlot, actionSlotProps] = useSlot('action', {
218
+ className: classes.action,
219
+ elementType: AlertAction,
220
+ externalForwardedProps,
221
+ ownerState
222
+ });
190
223
  const [CloseButtonSlot, closeButtonProps] = useSlot('closeButton', {
191
224
  elementType: IconButton,
192
225
  externalForwardedProps,
@@ -197,28 +230,19 @@ const Alert = /*#__PURE__*/React.forwardRef(function Alert(inProps, ref) {
197
230
  externalForwardedProps,
198
231
  ownerState
199
232
  });
200
- return /*#__PURE__*/_jsxs(AlertRoot, {
201
- role: role,
202
- elevation: 0,
203
- ownerState: ownerState,
204
- className: clsx(classes.root, className),
205
- ref: ref,
206
- ...other,
207
- children: [icon !== false ? /*#__PURE__*/_jsx(AlertIcon, {
208
- ownerState: ownerState,
209
- className: classes.icon,
233
+ return /*#__PURE__*/_jsxs(RootSlot, {
234
+ ...rootSlotProps,
235
+ children: [icon !== false ? /*#__PURE__*/_jsx(IconSlot, {
236
+ ...iconSlotProps,
210
237
  children: icon || iconMapping[severity] || defaultIconMapping[severity]
211
- }) : null, /*#__PURE__*/_jsx(AlertMessage, {
212
- ownerState: ownerState,
213
- className: classes.message,
238
+ }) : null, /*#__PURE__*/_jsx(MessageSlot, {
239
+ ...messageSlotProps,
214
240
  children: children
215
- }), action != null ? /*#__PURE__*/_jsx(AlertAction, {
216
- ownerState: ownerState,
217
- className: classes.action,
241
+ }), action != null ? /*#__PURE__*/_jsx(ActionSlot, {
242
+ ...actionSlotProps,
218
243
  children: action
219
- }) : null, action == null && onClose ? /*#__PURE__*/_jsx(AlertAction, {
220
- ownerState: ownerState,
221
- className: classes.action,
244
+ }) : null, action == null && onClose ? /*#__PURE__*/_jsx(ActionSlot, {
245
+ ...actionSlotProps,
222
246
  children: /*#__PURE__*/_jsx(CloseButtonSlot, {
223
247
  size: "small",
224
248
  "aria-label": closeText,
@@ -330,16 +354,24 @@ process.env.NODE_ENV !== "production" ? Alert.propTypes /* remove-proptypes */ =
330
354
  * @default {}
331
355
  */
332
356
  slotProps: PropTypes.shape({
357
+ action: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
333
358
  closeButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
334
- closeIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
359
+ closeIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
360
+ icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
361
+ message: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
362
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
335
363
  }),
336
364
  /**
337
365
  * The components used for each slot inside.
338
366
  * @default {}
339
367
  */
340
368
  slots: PropTypes.shape({
369
+ action: PropTypes.elementType,
341
370
  closeButton: PropTypes.elementType,
342
- closeIcon: PropTypes.elementType
371
+ closeIcon: PropTypes.elementType,
372
+ icon: PropTypes.elementType,
373
+ message: PropTypes.elementType,
374
+ root: PropTypes.elementType
343
375
  }),
344
376
  /**
345
377
  * The system prop that allows defining system overrides as well as additional CSS styles.
@@ -30,7 +30,7 @@ export interface AppBarOwnProps {
30
30
  enableColorOnDark?: boolean;
31
31
  /**
32
32
  * The positioning type. The behavior of the different options is described
33
- * [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning).
33
+ * [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Web/CSS/position).
34
34
  * Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
35
35
  * @default 'fixed'
36
36
  */
package/AppBar/AppBar.js CHANGED
@@ -214,7 +214,7 @@ process.env.NODE_ENV !== "production" ? AppBar.propTypes /* remove-proptypes */
214
214
  enableColorOnDark: PropTypes.bool,
215
215
  /**
216
216
  * The positioning type. The behavior of the different options is described
217
- * [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning).
217
+ * [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Web/CSS/position).
218
218
  * Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
219
219
  * @default 'fixed'
220
220
  */
@@ -65,7 +65,7 @@ export interface AutocompleteRenderOptionState {
65
65
  }
66
66
 
67
67
  export interface AutocompleteRenderGroupParams {
68
- key: string;
68
+ key: number;
69
69
  group: string;
70
70
  children?: React.ReactNode;
71
71
  }
@@ -650,53 +650,6 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
650
650
  };
651
651
  const clearIndicatorSlotProps = externalForwardedProps.slotProps.clearIndicator;
652
652
  const popupIndicatorSlotProps = externalForwardedProps.slotProps.popupIndicator;
653
- const renderAutocompletePopperChildren = children => /*#__PURE__*/_jsx(AutocompletePopper, {
654
- as: PopperSlot,
655
- ...popperProps,
656
- children: /*#__PURE__*/_jsx(AutocompletePaper, {
657
- as: PaperSlot,
658
- ...paperProps,
659
- children: children
660
- })
661
- });
662
- let autocompletePopper = null;
663
- if (groupedOptions.length > 0) {
664
- autocompletePopper = renderAutocompletePopperChildren(
665
- /*#__PURE__*/
666
- // TODO v7: remove `as` prop and move ListboxComponentProp to externalForwardedProps or remove ListboxComponentProp entirely
667
- // https://github.com/mui/material-ui/pull/43994#issuecomment-2401945800
668
- _jsx(ListboxSlot, {
669
- as: ListboxComponentProp,
670
- ...listboxProps,
671
- children: groupedOptions.map((option, index) => {
672
- if (groupBy) {
673
- return renderGroup({
674
- key: option.key,
675
- group: option.group,
676
- children: option.options.map((option2, index2) => renderListOption(option2, option.index + index2))
677
- });
678
- }
679
- return renderListOption(option, index);
680
- })
681
- }));
682
- } else if (loading && groupedOptions.length === 0) {
683
- autocompletePopper = renderAutocompletePopperChildren(/*#__PURE__*/_jsx(AutocompleteLoading, {
684
- className: classes.loading,
685
- ownerState: ownerState,
686
- children: loadingText
687
- }));
688
- } else if (groupedOptions.length === 0 && !freeSolo && !loading) {
689
- autocompletePopper = renderAutocompletePopperChildren(/*#__PURE__*/_jsx(AutocompleteNoOptions, {
690
- className: classes.noOptions,
691
- ownerState: ownerState,
692
- role: "presentation",
693
- onMouseDown: event => {
694
- // Prevent input blur when interacting with the "no options" content
695
- event.preventDefault();
696
- },
697
- children: noOptionsText
698
- }));
699
- }
700
653
  return /*#__PURE__*/_jsxs(React.Fragment, {
701
654
  children: [/*#__PURE__*/_jsx(AutocompleteRoot, {
702
655
  ref: ref,
@@ -750,7 +703,41 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
750
703
  ...getInputProps()
751
704
  }
752
705
  })
753
- }), anchorEl ? autocompletePopper : null]
706
+ }), anchorEl ? /*#__PURE__*/_jsx(AutocompletePopper, {
707
+ as: PopperSlot,
708
+ ...popperProps,
709
+ children: /*#__PURE__*/_jsxs(AutocompletePaper, {
710
+ as: PaperSlot,
711
+ ...paperProps,
712
+ children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/_jsx(AutocompleteLoading, {
713
+ className: classes.loading,
714
+ ownerState: ownerState,
715
+ children: loadingText
716
+ }) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/_jsx(AutocompleteNoOptions, {
717
+ className: classes.noOptions,
718
+ ownerState: ownerState,
719
+ role: "presentation",
720
+ onMouseDown: event => {
721
+ // Prevent input blur when interacting with the "no options" content
722
+ event.preventDefault();
723
+ },
724
+ children: noOptionsText
725
+ }) : null, groupedOptions.length > 0 ? /*#__PURE__*/_jsx(ListboxSlot, {
726
+ as: ListboxComponentProp,
727
+ ...listboxProps,
728
+ children: groupedOptions.map((option, index) => {
729
+ if (groupBy) {
730
+ return renderGroup({
731
+ key: option.key,
732
+ group: option.group,
733
+ children: option.options.map((option2, index2) => renderListOption(option2, option.index + index2))
734
+ });
735
+ }
736
+ return renderListOption(option, index);
737
+ })
738
+ }) : null]
739
+ })
740
+ }) : null]
754
741
  });
755
742
  });
756
743
  process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptypes */ = {
@@ -60,6 +60,24 @@ export interface ButtonOwnProps {
60
60
  * If defined, an `a` element will be used as the root node.
61
61
  */
62
62
  href?: string;
63
+ /**
64
+ * If `true`, the loading indicator is visible and the button is disabled.
65
+ * If `true | false`, the loading wrapper is always rendered before the children to prevent [Google Translation Crash](https://github.com/mui/material-ui/issues/27853).
66
+ * @default null
67
+ */
68
+ loading?: boolean | null;
69
+ /**
70
+ * Element placed before the children if the button is in loading state.
71
+ * The node should contain an element with `role="progressbar"` with an accessible name.
72
+ * By default, it renders a `CircularProgress` that is labeled by the button itself.
73
+ * @default <CircularProgress color="inherit" size={16} />
74
+ */
75
+ loadingIndicator?: React.ReactNode;
76
+ /**
77
+ * The loading indicator can be positioned on the start, end, or the center of the button.
78
+ * @default 'center'
79
+ */
80
+ loadingPosition?: 'start' | 'end' | 'center';
63
81
  /**
64
82
  * The size of the component.
65
83
  * `small` is equivalent to the dense button styling.