@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
@@ -4,6 +4,48 @@ import { Theme } from '..';
4
4
  import { ExtendButtonBase, ExtendButtonBaseTypeMap } from '../ButtonBase';
5
5
  import { OverrideProps } from '../OverridableComponent';
6
6
  import { TableSortLabelClasses } from './tableSortLabelClasses';
7
+ import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
8
+
9
+ export interface TableSortLabelRootSlotPropsOverrides {}
10
+
11
+ export interface TableSortLabelIconSlotPropsOverrides {}
12
+
13
+ export interface TableSortLabelSlots {
14
+ /**
15
+ * The component that renders the root slot.
16
+ * @default span
17
+ */
18
+ root?: React.ElementType;
19
+ /**
20
+ * The component that renders the icon slot.
21
+ * @default ArrowDownwardIcon
22
+ */
23
+ icon?: React.ElementType;
24
+ }
25
+
26
+ export type TableSortLabelSlotsAndSlotProps = CreateSlotsAndSlotProps<
27
+ TableSortLabelSlots,
28
+ {
29
+ /**
30
+ * Props forwarded to the root slot.
31
+ */
32
+ root: SlotProps<
33
+ React.ElementType<React.HTMLAttributes<HTMLSpanElement>>,
34
+ TableSortLabelRootSlotPropsOverrides,
35
+ TableSortLabelOwnerState
36
+ >;
37
+ /**
38
+ * Props forwarded to the icon slot.
39
+ */
40
+ icon: SlotProps<
41
+ React.ElementType<React.SVGAttributes<SVGSVGElement>>,
42
+ TableSortLabelIconSlotPropsOverrides,
43
+ TableSortLabelOwnerState
44
+ >;
45
+ }
46
+ >;
47
+
48
+ export interface TableSortLabelOwnerState extends TableSortLabelOwnProps {}
7
49
 
8
50
  export interface TableSortLabelOwnProps {
9
51
  /**
@@ -46,7 +88,7 @@ export type TableSortLabelTypeMap<
46
88
  AdditionalProps = {},
47
89
  RootComponent extends React.ElementType = 'span',
48
90
  > = ExtendButtonBaseTypeMap<{
49
- props: AdditionalProps & TableSortLabelOwnProps;
91
+ props: AdditionalProps & TableSortLabelOwnProps & TableSortLabelSlotsAndSlotProps;
50
92
  defaultComponent: RootComponent;
51
93
  }>;
52
94
 
@@ -11,6 +11,7 @@ import memoTheme from "../utils/memoTheme.js";
11
11
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
12
12
  import capitalize from "../utils/capitalize.js";
13
13
  import tableSortLabelClasses, { getTableSortLabelUtilityClass } from "./tableSortLabelClasses.js";
14
+ import useSlot from "../utils/useSlot.js";
14
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
16
  const useUtilityClasses = ownerState => {
16
17
  const {
@@ -110,6 +111,8 @@ const TableSortLabel = /*#__PURE__*/React.forwardRef(function TableSortLabel(inP
110
111
  direction = 'asc',
111
112
  hideSortIcon = false,
112
113
  IconComponent = ArrowDownwardIcon,
114
+ slots = {},
115
+ slotProps = {},
113
116
  ...other
114
117
  } = props;
115
118
  const ownerState = {
@@ -120,17 +123,31 @@ const TableSortLabel = /*#__PURE__*/React.forwardRef(function TableSortLabel(inP
120
123
  IconComponent
121
124
  };
122
125
  const classes = useUtilityClasses(ownerState);
123
- return /*#__PURE__*/_jsxs(TableSortLabelRoot, {
126
+ const externalForwardedProps = {
127
+ slots,
128
+ slotProps
129
+ };
130
+ const [RootSlot, rootProps] = useSlot('root', {
131
+ elementType: TableSortLabelRoot,
132
+ externalForwardedProps,
133
+ ownerState,
124
134
  className: clsx(classes.root, className),
125
- component: "span",
135
+ ref
136
+ });
137
+ const [IconSlot, iconProps] = useSlot('icon', {
138
+ elementType: TableSortLabelIcon,
139
+ externalForwardedProps,
140
+ ownerState,
141
+ className: classes.icon
142
+ });
143
+ return /*#__PURE__*/_jsxs(RootSlot, {
126
144
  disableRipple: true,
127
- ownerState: ownerState,
128
- ref: ref,
145
+ component: "span",
146
+ ...rootProps,
129
147
  ...other,
130
- children: [children, hideSortIcon && !active ? null : /*#__PURE__*/_jsx(TableSortLabelIcon, {
148
+ children: [children, hideSortIcon && !active ? null : /*#__PURE__*/_jsx(IconSlot, {
131
149
  as: IconComponent,
132
- className: clsx(classes.icon),
133
- ownerState: ownerState
150
+ ...iconProps
134
151
  })]
135
152
  });
136
153
  });
@@ -171,6 +188,22 @@ process.env.NODE_ENV !== "production" ? TableSortLabel.propTypes /* remove-propt
171
188
  * @default ArrowDownwardIcon
172
189
  */
173
190
  IconComponent: PropTypes.elementType,
191
+ /**
192
+ * The props used for each slot inside.
193
+ * @default {}
194
+ */
195
+ slotProps: PropTypes.shape({
196
+ icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
197
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
198
+ }),
199
+ /**
200
+ * The components used for each slot inside.
201
+ * @default {}
202
+ */
203
+ slots: PropTypes.shape({
204
+ icon: PropTypes.elementType,
205
+ root: PropTypes.elementType
206
+ }),
174
207
  /**
175
208
  * The system prop that allows defining system overrides as well as additional CSS styles.
176
209
  */
@@ -21,7 +21,7 @@ export interface TooltipSlots {
21
21
  * The component used for the popper.
22
22
  * @default Popper
23
23
  */
24
- popper: React.ElementType<PopperProps>;
24
+ popper: React.ElementType;
25
25
  /**
26
26
  * The component used for the transition.
27
27
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
@@ -379,7 +379,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(inProps, ref) {
379
379
  // eslint-disable-next-line react-hooks/rules-of-hooks -- process.env never changes
380
380
  React.useEffect(() => {
381
381
  if (childNode && childNode.disabled && !isControlled && title !== '' && childNode.tagName.toLowerCase() === 'button') {
382
- console.error(['MUI: You are providing a disabled `button` child to the Tooltip component.', 'A disabled element does not fire events.', "Tooltip needs to listen to the child element's events to display the title.", '', 'Add a simple wrapper element, such as a `span`.'].join('\n'));
382
+ console.warn(['MUI: You are providing a disabled `button` child to the Tooltip component.', 'A disabled element does not fire events.', "Tooltip needs to listen to the child element's events to display the title.", '', 'Add a simple wrapper element, such as a `span`.'].join('\n'));
383
383
  }
384
384
  }, [title, childNode, isControlled]);
385
385
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v6.3.0
2
+ * @mui/material v6.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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.
@@ -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
  */
@@ -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 */ = {