@mui/material 6.3.1 → 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 (69) hide show
  1. package/Alert/Alert.d.ts +69 -0
  2. package/Alert/Alert.js +53 -21
  3. package/Autocomplete/Autocomplete.d.ts +1 -1
  4. package/Button/Button.d.ts +18 -0
  5. package/Button/Button.js +233 -15
  6. package/Button/buttonClasses.d.ts +14 -0
  7. package/Button/buttonClasses.js +1 -1
  8. package/CHANGELOG.md +49 -0
  9. package/CardHeader/CardHeader.d.ts +114 -1
  10. package/CardHeader/CardHeader.js +99 -32
  11. package/CircularProgress/CircularProgress.js +2 -2
  12. package/IconButton/IconButton.d.ts +12 -0
  13. package/IconButton/IconButton.js +69 -7
  14. package/IconButton/iconButtonClasses.d.ts +4 -0
  15. package/IconButton/iconButtonClasses.js +1 -1
  16. package/LinearProgress/LinearProgress.js +4 -4
  17. package/LinearProgress/linearProgressClasses.d.ts +31 -9
  18. package/LinearProgress/linearProgressClasses.js +1 -1
  19. package/Link/getTextDecoration.js +3 -2
  20. package/Select/Select.js +10 -1
  21. package/Select/SelectInput.js +1 -1
  22. package/Slider/useSlider.js +5 -2
  23. package/StepLabel/StepLabel.d.ts +1 -1
  24. package/Tooltip/Tooltip.d.ts +1 -1
  25. package/index.js +1 -1
  26. package/modern/Alert/Alert.js +53 -21
  27. package/modern/Button/Button.js +233 -15
  28. package/modern/Button/buttonClasses.js +1 -1
  29. package/modern/CardHeader/CardHeader.js +99 -32
  30. package/modern/CircularProgress/CircularProgress.js +2 -2
  31. package/modern/IconButton/IconButton.js +69 -7
  32. package/modern/IconButton/iconButtonClasses.js +1 -1
  33. package/modern/LinearProgress/LinearProgress.js +4 -4
  34. package/modern/LinearProgress/linearProgressClasses.js +1 -1
  35. package/modern/Link/getTextDecoration.js +3 -2
  36. package/modern/Select/Select.js +10 -1
  37. package/modern/Select/SelectInput.js +1 -1
  38. package/modern/Slider/useSlider.js +5 -2
  39. package/modern/index.js +1 -1
  40. package/modern/utils/index.js +1 -0
  41. package/modern/utils/mergeSlotProps.js +43 -0
  42. package/modern/utils/useSlot.js +5 -1
  43. package/modern/version/index.js +3 -3
  44. package/node/Alert/Alert.js +53 -21
  45. package/node/Button/Button.js +233 -15
  46. package/node/Button/buttonClasses.js +1 -1
  47. package/node/CardHeader/CardHeader.js +99 -32
  48. package/node/CircularProgress/CircularProgress.js +2 -2
  49. package/node/IconButton/IconButton.js +68 -6
  50. package/node/IconButton/iconButtonClasses.js +1 -1
  51. package/node/LinearProgress/LinearProgress.js +4 -4
  52. package/node/LinearProgress/linearProgressClasses.js +1 -1
  53. package/node/Link/getTextDecoration.js +3 -2
  54. package/node/Select/Select.js +10 -1
  55. package/node/Select/SelectInput.js +1 -1
  56. package/node/Slider/useSlider.js +5 -2
  57. package/node/index.js +1 -1
  58. package/node/utils/index.js +7 -0
  59. package/node/utils/mergeSlotProps.js +50 -0
  60. package/node/utils/useSlot.js +5 -1
  61. package/node/version/index.js +3 -3
  62. package/package.json +5 -5
  63. package/utils/index.d.ts +1 -0
  64. package/utils/index.js +1 -0
  65. package/utils/mergeSlotProps.d.ts +2 -0
  66. package/utils/mergeSlotProps.js +43 -0
  67. package/utils/useSlot.d.ts +8 -0
  68. package/utils/useSlot.js +5 -1
  69. package/version/index.js +3 -3
@@ -3,8 +3,116 @@ import { SxProps } from '@mui/system';
3
3
  import { TypographyProps } from '../Typography';
4
4
  import { OverridableComponent, OverrideProps } from '../OverridableComponent';
5
5
  import { Theme } from '..';
6
+ import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
6
7
  import { CardHeaderClasses } from './cardHeaderClasses';
7
8
 
9
+ export interface CardHeaderRootSlotPropsOverrides {}
10
+
11
+ export interface CardHeaderAvatarSlotPropsOverrides {}
12
+
13
+ export interface CardHeaderActionSlotPropsOverrides {}
14
+
15
+ export interface CardHeaderContentSlotPropsOverrides {}
16
+
17
+ export interface CardHeaderTitleSlotPropsOverrides {}
18
+
19
+ export interface CardHeaderSubheaderSlotPropsOverrides {}
20
+
21
+ export interface CardHeaderSlots {
22
+ /**
23
+ * The component that renders the root slot.
24
+ * @default 'div'
25
+ */
26
+ root: React.ElementType;
27
+ /**
28
+ * The component that renders the avatar slot.
29
+ * @default 'div'
30
+ */
31
+ avatar: React.ElementType;
32
+ /**
33
+ * The component that renders the action slot.
34
+ * @default 'div'
35
+ */
36
+ action: React.ElementType;
37
+ /**
38
+ * The component that renders the content slot.
39
+ * @default 'div'
40
+ */
41
+ content: React.ElementType;
42
+ /**
43
+ * The component that renders the title slot (as long as disableTypography is not `true`).
44
+ * [Follow this guide](https://mui.com/material-ui/api/typography/#props) to learn more about the requirements for this component.
45
+ * @default Typography
46
+ */
47
+ title: React.ElementType;
48
+ /**
49
+ * The component that renders the subheader slot (as long as disableTypography is not `true`).
50
+ * [Follow this guide](https://mui.com/material-ui/api/typography/#props) to learn more about the requirements for this component.
51
+ * @default Typography
52
+ */
53
+ subheader: React.ElementType;
54
+ }
55
+
56
+ export type CardHeaderSlotsAndSlotProps = CreateSlotsAndSlotProps<
57
+ CardHeaderSlots,
58
+ {
59
+ /**
60
+ * Props forwarded to the root slot.
61
+ * By default, the avaible props are based on the div element.
62
+ */
63
+ root: SlotProps<
64
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
65
+ CardHeaderRootSlotPropsOverrides,
66
+ CardHeaderOwnerState
67
+ >;
68
+ /**
69
+ * Props forwarded to the avatar slot.
70
+ * By default, the avaible props are based on the div element.
71
+ */
72
+ avatar: SlotProps<
73
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
74
+ CardHeaderAvatarSlotPropsOverrides,
75
+ CardHeaderOwnerState
76
+ >;
77
+ /**
78
+ * Props forwarded to the action slot.
79
+ * By default, the avaible props are based on the div element.
80
+ */
81
+ action: SlotProps<
82
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
83
+ CardHeaderActionSlotPropsOverrides,
84
+ CardHeaderOwnerState
85
+ >;
86
+ /**
87
+ * Props forwarded to the content slot.
88
+ * By default, the avaible props are based on the div element.
89
+ */
90
+ content: SlotProps<
91
+ React.ElementType<React.DetailsHTMLAttributes<HTMLDivElement>>,
92
+ CardHeaderContentSlotPropsOverrides,
93
+ CardHeaderOwnerState
94
+ >;
95
+ /**
96
+ * Props forwarded to the title slot (as long as disableTypography is not `true`).
97
+ * By default, the avaible props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component.
98
+ */
99
+ title: SlotProps<
100
+ React.ElementType<TypographyProps>,
101
+ CardHeaderTitleSlotPropsOverrides,
102
+ CardHeaderOwnerState
103
+ >;
104
+ /**
105
+ * Props forwarded to the subheader slot (as long as disableTypography is not `true`).
106
+ * By default, the avaible props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component.
107
+ */
108
+ subheader: SlotProps<
109
+ React.ElementType<TypographyProps>,
110
+ CardHeaderSubheaderSlotPropsOverrides,
111
+ CardHeaderOwnerState
112
+ >;
113
+ }
114
+ >;
115
+
8
116
  export interface CardHeaderOwnProps<
9
117
  TitleTypographyComponent extends React.ElementType = 'span',
10
118
  SubheaderTypographyComponent extends React.ElementType = 'span',
@@ -36,6 +144,7 @@ export interface CardHeaderOwnProps<
36
144
  /**
37
145
  * These props will be forwarded to the subheader
38
146
  * (as long as disableTypography is not `true`).
147
+ * @deprecated Use `slotProps.subheader` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
39
148
  */
40
149
  subheaderTypographyProps?: TypographyProps<
41
150
  SubheaderTypographyComponent,
@@ -54,6 +163,7 @@ export interface CardHeaderOwnProps<
54
163
  /**
55
164
  * These props will be forwarded to the title
56
165
  * (as long as disableTypography is not `true`).
166
+ * @deprecated Use `slotProps.title` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
57
167
  */
58
168
  titleTypographyProps?: TypographyProps<
59
169
  TitleTypographyComponent,
@@ -63,6 +173,8 @@ export interface CardHeaderOwnProps<
63
173
  >;
64
174
  }
65
175
 
176
+ export interface CardHeaderOwnerState extends CardHeaderOwnProps {}
177
+
66
178
  export interface CardHeaderTypeMap<
67
179
  AdditionalProps = {},
68
180
  RootComponent extends React.ElementType = 'div',
@@ -70,7 +182,8 @@ export interface CardHeaderTypeMap<
70
182
  SubheaderTypographyComponent extends React.ElementType = 'span',
71
183
  > {
72
184
  props: AdditionalProps &
73
- CardHeaderOwnProps<TitleTypographyComponent, SubheaderTypographyComponent>;
185
+ CardHeaderOwnProps<TitleTypographyComponent, SubheaderTypographyComponent> &
186
+ CardHeaderSlotsAndSlotProps;
74
187
  defaultComponent: RootComponent;
75
188
  }
76
189
  /**
@@ -2,12 +2,12 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import PropTypes from 'prop-types';
5
- import clsx from 'clsx';
6
5
  import composeClasses from '@mui/utils/composeClasses';
7
6
  import Typography, { typographyClasses } from "../Typography/index.js";
8
7
  import { styled } from "../zero-styled/index.js";
9
8
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
10
9
  import cardHeaderClasses, { getCardHeaderUtilityClass } from "./cardHeaderClasses.js";
10
+ import useSlot from "../utils/useSlot.js";
11
11
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  const useUtilityClasses = ownerState => {
13
13
  const {
@@ -79,13 +79,14 @@ const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, re
79
79
  const {
80
80
  action,
81
81
  avatar,
82
- className,
83
82
  component = 'div',
84
83
  disableTypography = false,
85
84
  subheader: subheaderProp,
86
85
  subheaderTypographyProps,
87
86
  title: titleProp,
88
87
  titleTypographyProps,
88
+ slots = {},
89
+ slotProps = {},
89
90
  ...other
90
91
  } = props;
91
92
  const ownerState = {
@@ -94,44 +95,88 @@ const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, re
94
95
  disableTypography
95
96
  };
96
97
  const classes = useUtilityClasses(ownerState);
98
+ const externalForwardedProps = {
99
+ slots,
100
+ slotProps: {
101
+ title: titleTypographyProps,
102
+ subheader: subheaderTypographyProps,
103
+ ...slotProps
104
+ }
105
+ };
97
106
  let title = titleProp;
98
- if (title != null && title.type !== Typography && !disableTypography) {
99
- title = /*#__PURE__*/_jsx(Typography, {
107
+ const [TitleSlot, titleSlotProps] = useSlot('title', {
108
+ className: classes.title,
109
+ elementType: Typography,
110
+ externalForwardedProps,
111
+ ownerState,
112
+ additionalProps: {
100
113
  variant: avatar ? 'body2' : 'h5',
101
- className: classes.title,
102
- component: "span",
103
- ...titleTypographyProps,
114
+ component: 'span'
115
+ }
116
+ });
117
+ if (title != null && title.type !== Typography && !disableTypography) {
118
+ title = /*#__PURE__*/_jsx(TitleSlot, {
119
+ ...titleSlotProps,
104
120
  children: title
105
121
  });
106
122
  }
107
123
  let subheader = subheaderProp;
108
- if (subheader != null && subheader.type !== Typography && !disableTypography) {
109
- subheader = /*#__PURE__*/_jsx(Typography, {
124
+ const [SubheaderSlot, subheaderSlotProps] = useSlot('subheader', {
125
+ className: classes.subheader,
126
+ elementType: Typography,
127
+ externalForwardedProps,
128
+ ownerState,
129
+ additionalProps: {
110
130
  variant: avatar ? 'body2' : 'body1',
111
- className: classes.subheader,
112
- color: "textSecondary",
113
- component: "span",
114
- ...subheaderTypographyProps,
131
+ color: 'textSecondary',
132
+ component: 'span'
133
+ }
134
+ });
135
+ if (subheader != null && subheader.type !== Typography && !disableTypography) {
136
+ subheader = /*#__PURE__*/_jsx(SubheaderSlot, {
137
+ ...subheaderSlotProps,
115
138
  children: subheader
116
139
  });
117
140
  }
118
- return /*#__PURE__*/_jsxs(CardHeaderRoot, {
119
- className: clsx(classes.root, className),
120
- as: component,
121
- ref: ref,
122
- ownerState: ownerState,
123
- ...other,
124
- children: [avatar && /*#__PURE__*/_jsx(CardHeaderAvatar, {
125
- className: classes.avatar,
126
- ownerState: ownerState,
141
+ const [RootSlot, rootSlotProps] = useSlot('root', {
142
+ ref,
143
+ className: classes.root,
144
+ elementType: CardHeaderRoot,
145
+ externalForwardedProps: {
146
+ ...externalForwardedProps,
147
+ ...other,
148
+ component
149
+ },
150
+ ownerState
151
+ });
152
+ const [AvatarSlot, avatarSlotProps] = useSlot('avatar', {
153
+ className: classes.avatar,
154
+ elementType: CardHeaderAvatar,
155
+ externalForwardedProps,
156
+ ownerState
157
+ });
158
+ const [ContentSlot, contentSlotProps] = useSlot('content', {
159
+ className: classes.content,
160
+ elementType: CardHeaderContent,
161
+ externalForwardedProps,
162
+ ownerState
163
+ });
164
+ const [ActionSlot, actionSlotProps] = useSlot('action', {
165
+ className: classes.action,
166
+ elementType: CardHeaderAction,
167
+ externalForwardedProps,
168
+ ownerState
169
+ });
170
+ return /*#__PURE__*/_jsxs(RootSlot, {
171
+ ...rootSlotProps,
172
+ children: [avatar && /*#__PURE__*/_jsx(AvatarSlot, {
173
+ ...avatarSlotProps,
127
174
  children: avatar
128
- }), /*#__PURE__*/_jsxs(CardHeaderContent, {
129
- className: classes.content,
130
- ownerState: ownerState,
175
+ }), /*#__PURE__*/_jsxs(ContentSlot, {
176
+ ...contentSlotProps,
131
177
  children: [title, subheader]
132
- }), action && /*#__PURE__*/_jsx(CardHeaderAction, {
133
- className: classes.action,
134
- ownerState: ownerState,
178
+ }), action && /*#__PURE__*/_jsx(ActionSlot, {
179
+ ...actionSlotProps,
135
180
  children: action
136
181
  })]
137
182
  });
@@ -157,10 +202,6 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
157
202
  * Override or extend the styles applied to the component.
158
203
  */
159
204
  classes: PropTypes.object,
160
- /**
161
- * @ignore
162
- */
163
- className: PropTypes.string,
164
205
  /**
165
206
  * The component used for the root node.
166
207
  * Either a string to use a HTML element or a component.
@@ -174,6 +215,30 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
174
215
  * @default false
175
216
  */
176
217
  disableTypography: PropTypes.bool,
218
+ /**
219
+ * The props used for each slot inside.
220
+ * @default {}
221
+ */
222
+ slotProps: PropTypes.shape({
223
+ action: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
224
+ avatar: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
225
+ content: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
226
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
227
+ subheader: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
228
+ title: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
229
+ }),
230
+ /**
231
+ * The components used for each slot inside.
232
+ * @default {}
233
+ */
234
+ slots: PropTypes.shape({
235
+ action: PropTypes.elementType,
236
+ avatar: PropTypes.elementType,
237
+ content: PropTypes.elementType,
238
+ root: PropTypes.elementType,
239
+ subheader: PropTypes.elementType,
240
+ title: PropTypes.elementType
241
+ }),
177
242
  /**
178
243
  * The content of the component.
179
244
  */
@@ -181,6 +246,7 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
181
246
  /**
182
247
  * These props will be forwarded to the subheader
183
248
  * (as long as disableTypography is not `true`).
249
+ * @deprecated Use `slotProps.subheader` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
184
250
  */
185
251
  subheaderTypographyProps: PropTypes.object,
186
252
  /**
@@ -194,6 +260,7 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
194
260
  /**
195
261
  * These props will be forwarded to the title
196
262
  * (as long as disableTypography is not `true`).
263
+ * @deprecated Use `slotProps.title` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
197
264
  */
198
265
  titleTypographyProps: PropTypes.object
199
266
  } : void 0;
@@ -34,8 +34,8 @@ const circularDashKeyframe = keyframes`
34
34
  }
35
35
 
36
36
  100% {
37
- stroke-dasharray: 100px, 200px;
38
- stroke-dashoffset: -125px;
37
+ stroke-dasharray: 1px, 200px;
38
+ stroke-dashoffset: -126px;
39
39
  }
40
40
  `;
41
41
 
@@ -47,6 +47,18 @@ export interface IconButtonOwnProps {
47
47
  * @default false
48
48
  */
49
49
  edge?: 'start' | 'end' | false;
50
+ /**
51
+ * If `true`, the loading indicator is visible and the button is disabled.
52
+ * @default false
53
+ */
54
+ loading?: boolean;
55
+ /**
56
+ * Element placed before the children if the button is in loading state.
57
+ * The node should contain an element with `role="progressbar"` with an accessible name.
58
+ * By default, it renders a `CircularProgress` that is labeled by the button itself.
59
+ * @default <CircularProgress color="inherit" size={16} />
60
+ */
61
+ loadingIndicator?: React.ReactNode;
50
62
  /**
51
63
  * The size of the component.
52
64
  * `small` is equivalent to the dense button styling.
@@ -5,25 +5,29 @@ import PropTypes from 'prop-types';
5
5
  import clsx from 'clsx';
6
6
  import chainPropTypes from '@mui/utils/chainPropTypes';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
+ import { unstable_useId as useId } from '@mui/material/utils';
8
9
  import { alpha } from '@mui/system/colorManipulator';
9
10
  import { styled } from "../zero-styled/index.js";
10
11
  import memoTheme from "../utils/memoTheme.js";
11
12
  import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
12
13
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
13
14
  import ButtonBase from "../ButtonBase/index.js";
15
+ import CircularProgress from "../CircularProgress/index.js";
14
16
  import capitalize from "../utils/capitalize.js";
15
17
  import iconButtonClasses, { getIconButtonUtilityClass } from "./iconButtonClasses.js";
16
- import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
19
  const useUtilityClasses = ownerState => {
18
20
  const {
19
21
  classes,
20
22
  disabled,
21
23
  color,
22
24
  edge,
23
- size
25
+ size,
26
+ loading
24
27
  } = ownerState;
25
28
  const slots = {
26
- root: ['root', disabled && 'disabled', color !== 'default' && `color${capitalize(color)}`, edge && `edge${capitalize(edge)}`, `size${capitalize(size)}`]
29
+ root: ['root', loading && 'loading', disabled && 'disabled', color !== 'default' && `color${capitalize(color)}`, edge && `edge${capitalize(edge)}`, `size${capitalize(size)}`],
30
+ loadingIndicator: ['loadingIndicator']
27
31
  };
28
32
  return composeClasses(slots, getIconButtonUtilityClass, classes);
29
33
  };
@@ -34,7 +38,7 @@ const IconButtonRoot = styled(ButtonBase, {
34
38
  const {
35
39
  ownerState
36
40
  } = props;
37
- return [styles.root, ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`], ownerState.edge && styles[`edge${capitalize(ownerState.edge)}`], styles[`size${capitalize(ownerState.size)}`]];
41
+ return [styles.root, ownerState.loading && styles.loading, ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`], ownerState.edge && styles[`edge${capitalize(ownerState.edge)}`], styles[`size${capitalize(ownerState.size)}`]];
38
42
  }
39
43
  })(memoTheme(({
40
44
  theme
@@ -137,8 +141,34 @@ const IconButtonRoot = styled(ButtonBase, {
137
141
  [`&.${iconButtonClasses.disabled}`]: {
138
142
  backgroundColor: 'transparent',
139
143
  color: (theme.vars || theme).palette.action.disabled
144
+ },
145
+ [`&.${iconButtonClasses.loading}`]: {
146
+ color: 'transparent'
140
147
  }
141
148
  })));
149
+ const IconButtonLoadingIndicator = styled('span', {
150
+ name: 'MuiIconButton',
151
+ slot: 'LoadingIndicator',
152
+ overridesResolver: (props, styles) => styles.loadingIndicator
153
+ })(({
154
+ theme
155
+ }) => ({
156
+ display: 'none',
157
+ position: 'absolute',
158
+ visibility: 'visible',
159
+ top: '50%',
160
+ left: '50%',
161
+ transform: 'translate(-50%, -50%)',
162
+ color: (theme.vars || theme).palette.action.disabled,
163
+ variants: [{
164
+ props: {
165
+ loading: true
166
+ },
167
+ style: {
168
+ display: 'flex'
169
+ }
170
+ }]
171
+ }));
142
172
 
143
173
  /**
144
174
  * Refer to the [Icons](/material-ui/icons/) section of the documentation
@@ -157,26 +187,42 @@ const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(inProps, re
157
187
  disabled = false,
158
188
  disableFocusRipple = false,
159
189
  size = 'medium',
190
+ id: idProp,
191
+ loading = false,
192
+ loadingIndicator: loadingIndicatorProp,
160
193
  ...other
161
194
  } = props;
195
+ const id = useId(idProp);
196
+ const loadingIndicator = loadingIndicatorProp ?? /*#__PURE__*/_jsx(CircularProgress, {
197
+ "aria-labelledby": id,
198
+ color: "inherit",
199
+ size: 16
200
+ });
162
201
  const ownerState = {
163
202
  ...props,
164
203
  edge,
165
204
  color,
166
205
  disabled,
167
206
  disableFocusRipple,
207
+ loading,
208
+ loadingIndicator,
168
209
  size
169
210
  };
170
211
  const classes = useUtilityClasses(ownerState);
171
- return /*#__PURE__*/_jsx(IconButtonRoot, {
212
+ return /*#__PURE__*/_jsxs(IconButtonRoot, {
213
+ id: id,
172
214
  className: clsx(classes.root, className),
173
215
  centerRipple: true,
174
216
  focusRipple: !disableFocusRipple,
175
- disabled: disabled,
217
+ disabled: disabled || loading,
176
218
  ref: ref,
177
219
  ...other,
178
220
  ownerState: ownerState,
179
- children: children
221
+ children: [/*#__PURE__*/_jsx(IconButtonLoadingIndicator, {
222
+ className: classes.loadingIndicator,
223
+ ownerState: ownerState,
224
+ children: loading && loadingIndicator
225
+ }), children]
180
226
  });
181
227
  });
182
228
  process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes */ = {
@@ -235,6 +281,22 @@ process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes
235
281
  * @default false
236
282
  */
237
283
  edge: PropTypes.oneOf(['end', 'start', false]),
284
+ /**
285
+ * @ignore
286
+ */
287
+ id: PropTypes.string,
288
+ /**
289
+ * If `true`, the loading indicator is visible and the button is disabled.
290
+ * @default false
291
+ */
292
+ loading: PropTypes.bool,
293
+ /**
294
+ * Element placed before the children if the button is in loading state.
295
+ * The node should contain an element with `role="progressbar"` with an accessible name.
296
+ * By default, it renders a `CircularProgress` that is labeled by the button itself.
297
+ * @default <CircularProgress color="inherit" size={16} />
298
+ */
299
+ loadingIndicator: PropTypes.node,
238
300
  /**
239
301
  * The size of the component.
240
302
  * `small` is equivalent to the dense button styling.
@@ -27,6 +27,10 @@ export interface IconButtonClasses {
27
27
  sizeMedium: string;
28
28
  /** Styles applied to the root element if `size="large"`. */
29
29
  sizeLarge: string;
30
+ /** Styles applied to the root element if `loading={true}`. */
31
+ loading: string;
32
+ /** Styles applied to the loadingIndicator element. */
33
+ loadingIndicator: string;
30
34
  }
31
35
  export type IconButtonClassKey = keyof IconButtonClasses;
32
36
  export declare function getIconButtonUtilityClass(slot: string): string;
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
3
  export function getIconButtonUtilityClass(slot) {
4
4
  return generateUtilityClass('MuiIconButton', slot);
5
5
  }
6
- const iconButtonClasses = generateUtilityClasses('MuiIconButton', ['root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'sizeLarge']);
6
+ const iconButtonClasses = generateUtilityClasses('MuiIconButton', ['root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'sizeLarge', 'loading', 'loadingIndicator']);
7
7
  export default iconButtonClasses;
@@ -84,8 +84,8 @@ const useUtilityClasses = ownerState => {
84
84
  const slots = {
85
85
  root: ['root', `color${capitalize(color)}`, variant],
86
86
  dashed: ['dashed', `dashedColor${capitalize(color)}`],
87
- bar1: ['bar', `barColor${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar1Indeterminate', variant === 'determinate' && 'bar1Determinate', variant === 'buffer' && 'bar1Buffer'],
88
- bar2: ['bar', variant !== 'buffer' && `barColor${capitalize(color)}`, variant === 'buffer' && `color${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar2Indeterminate', variant === 'buffer' && 'bar2Buffer']
87
+ bar1: ['bar', 'bar1', `barColor${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar1Indeterminate', variant === 'determinate' && 'bar1Determinate', variant === 'buffer' && 'bar1Buffer'],
88
+ bar2: ['bar', 'bar2', variant !== 'buffer' && `barColor${capitalize(color)}`, variant === 'buffer' && `color${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar2Indeterminate', variant === 'buffer' && 'bar2Buffer']
89
89
  };
90
90
  return composeClasses(slots, getLinearProgressUtilityClass, classes);
91
91
  };
@@ -203,7 +203,7 @@ const LinearProgressBar1 = styled('span', {
203
203
  const {
204
204
  ownerState
205
205
  } = props;
206
- return [styles.bar, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar1Indeterminate, ownerState.variant === 'determinate' && styles.bar1Determinate, ownerState.variant === 'buffer' && styles.bar1Buffer];
206
+ return [styles.bar, styles.bar1, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar1Indeterminate, ownerState.variant === 'determinate' && styles.bar1Determinate, ownerState.variant === 'buffer' && styles.bar1Buffer];
207
207
  }
208
208
  })(memoTheme(({
209
209
  theme
@@ -267,7 +267,7 @@ const LinearProgressBar2 = styled('span', {
267
267
  const {
268
268
  ownerState
269
269
  } = props;
270
- return [styles.bar, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar2Indeterminate, ownerState.variant === 'buffer' && styles.bar2Buffer];
270
+ return [styles.bar, styles.bar2, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar2Indeterminate, ownerState.variant === 'buffer' && styles.bar2Buffer];
271
271
  }
272
272
  })(memoTheme(({
273
273
  theme
@@ -15,25 +15,47 @@ export interface LinearProgressClasses {
15
15
  query: string;
16
16
  /** Styles applied to the additional bar element if `variant="buffer"`. */
17
17
  dashed: string;
18
- /** Styles applied to the additional bar element if `variant="buffer"` and `color="primary"`. */
18
+ /** Styles applied to the additional bar element if `variant="buffer"` and `color="primary"`.
19
+ * @deprecated Combine the [.MuiLinearProgress-dashed](/material-ui/api/linear-progress/#linear-progress-classes-dashed) and [.MuiLinearProgress-colorPrimary](/material-ui/api/linear-progress/#linear-progress-classes-colorPrimary) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
20
+ */
19
21
  dashedColorPrimary: string;
20
- /** Styles applied to the additional bar element if `variant="buffer"` and `color="secondary"`. */
22
+ /** Styles applied to the additional bar element if `variant="buffer"` and `color="secondary"`.
23
+ * @deprecated Combine the [.MuiLinearProgress-dashed](/material-ui/api/linear-progress/#linear-progress-classes-dashed) and [.MuiLinearProgress-colorSecondary](/material-ui/api/linear-progress/#linear-progress-classes-colorSecondary) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
24
+ */
21
25
  dashedColorSecondary: string;
22
26
  /** Styles applied to the layered bar1 and bar2 elements. */
23
27
  bar: string;
24
- /** Styles applied to the bar elements if `color="primary"`; bar2 if `variant` not "buffer". */
28
+ /** Styles applied to the bar1 element. */
29
+ bar1: string;
30
+ /** Styles applied to the bar2 element. */
31
+ bar2: string;
32
+ /** Styles applied to the bar elements if `color="primary"`; bar2 if `variant` not "buffer".
33
+ * @deprecated Use the [.MuiLinearProgress-bar](/material-ui/api/linear-progress/#linear-progress-classes-bar) and [.MuiLinearProgress-colorPrimary](/material-ui/api/linear-progress/#linear-progress-classes-colorPrimary) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
34
+ */
25
35
  barColorPrimary: string;
26
- /** Styles applied to the bar elements if `color="secondary"`; bar2 if `variant` not "buffer". */
36
+ /** Styles applied to the bar elements if `color="secondary"`; bar2 if `variant` not "buffer".
37
+ * @deprecated Use the [.MuiLinearProgress-bar](/material-ui/api/linear-progress/#linear-progress-classes-bar) and [.MuiLinearProgress-colorSecondary](/material-ui/api/linear-progress/#linear-progress-classes-colorSecondary) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
38
+ */
27
39
  barColorSecondary: string;
28
- /** Styles applied to the bar1 element if `variant="indeterminate or query"`. */
40
+ /** Styles applied to the bar1 element if `variant="indeterminate or query"`.
41
+ * @deprecated Use the [.MuiLinearProgress-bar1](/material-ui/api/linear-progress/#linear-progress-classes-bar1) and [.MuiLinearProgress-indeterminate](/material-ui/api/linear-progress/#linear-progress-classes-indeterminate) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
42
+ */
29
43
  bar1Indeterminate: string;
30
- /** Styles applied to the bar1 element if `variant="determinate"`. */
44
+ /** Styles applied to the bar1 element if `variant="determinate"`.
45
+ * @deprecated Use the [.MuiLinearProgress-bar1](/material-ui/api/linear-progress/#linear-progress-classes-bar1) and [.MuiLinearProgress-determinate](/material-ui/api/linear-progress/#linear-progress-classes-determinate) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
46
+ */
31
47
  bar1Determinate: string;
32
- /** Styles applied to the bar1 element if `variant="buffer"`. */
48
+ /** Styles applied to the bar1 element if `variant="buffer"`.
49
+ * @deprecated Use the [.MuiLinearProgress-bar1](/material-ui/api/linear-progress/#linear-progress-classes-bar1) and [.MuiLinearProgress-buffer](/material-ui/api/linear-progress/#linear-progress-classes-buffer) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
50
+ */
33
51
  bar1Buffer: string;
34
- /** Styles applied to the bar2 element if `variant="indeterminate or query"`. */
52
+ /** Styles applied to the bar2 element if `variant="indeterminate or query"`.
53
+ * @deprecated Use the [.MuiLinearProgress-bar2](/material-ui/api/linear-progress/#linear-progress-classes-bar2) and [.MuiLinearProgress-indeterminate](/material-ui/api/linear-progress/#linear-progress-classes-indeterminate) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
54
+ */
35
55
  bar2Indeterminate: string;
36
- /** Styles applied to the bar2 element if `variant="buffer"`. */
56
+ /** Styles applied to the bar2 element if `variant="buffer"`.
57
+ * @deprecated Use the [.MuiLinearProgress-bar2](/material-ui/api/linear-progress/#linear-progress-classes-bar2) and [.MuiLinearProgress-buffer](/material-ui/api/linear-progress/#linear-progress-classes-buffer) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
58
+ */
37
59
  bar2Buffer: string;
38
60
  }
39
61
  export type LinearProgressClassKey = keyof LinearProgressClasses;
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
3
  export function getLinearProgressUtilityClass(slot) {
4
4
  return generateUtilityClass('MuiLinearProgress', slot);
5
5
  }
6
- const linearProgressClasses = generateUtilityClasses('MuiLinearProgress', ['root', 'colorPrimary', 'colorSecondary', 'determinate', 'indeterminate', 'buffer', 'query', 'dashed', 'dashedColorPrimary', 'dashedColorSecondary', 'bar', 'barColorPrimary', 'barColorSecondary', 'bar1Indeterminate', 'bar1Determinate', 'bar1Buffer', 'bar2Indeterminate', 'bar2Buffer']);
6
+ const linearProgressClasses = generateUtilityClasses('MuiLinearProgress', ['root', 'colorPrimary', 'colorSecondary', 'determinate', 'indeterminate', 'buffer', 'query', 'dashed', 'dashedColorPrimary', 'dashedColorSecondary', 'bar', 'bar1', 'bar2', 'barColorPrimary', 'barColorSecondary', 'bar1Indeterminate', 'bar1Determinate', 'bar1Buffer', 'bar2Indeterminate', 'bar2Buffer']);
7
7
  export default linearProgressClasses;
@@ -5,8 +5,9 @@ const getTextDecoration = ({
5
5
  ownerState
6
6
  }) => {
7
7
  const transformedColor = ownerState.color;
8
- const color = getPath(theme, `palette.${transformedColor}`, false) || ownerState.color;
9
- const channelColor = getPath(theme, `palette.${transformedColor}Channel`);
8
+ // check the `main` color first for a custom palette, then fallback to the color itself
9
+ const color = getPath(theme, `palette.${transformedColor}.main`, false) || getPath(theme, `palette.${transformedColor}`, false) || ownerState.color;
10
+ const channelColor = getPath(theme, `palette.${transformedColor}.mainChannel`) || getPath(theme, `palette.${transformedColor}Channel`);
10
11
  if ('vars' in theme && channelColor) {
11
12
  return `rgba(${channelColor} / 0.4)`;
12
13
  }