@mui/material 6.3.1 → 6.4.1

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 (117) 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/ButtonBase/ButtonBase.d.ts +2 -0
  9. package/ButtonGroup/ButtonGroupButtonContext.js +2 -0
  10. package/ButtonGroup/ButtonGroupContext.js +2 -0
  11. package/CHANGELOG.md +91 -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/Dialog/Dialog.d.ts +85 -1
  16. package/Dialog/Dialog.js +91 -20
  17. package/Dialog/DialogContext.js +2 -0
  18. package/Drawer/Drawer.js +1 -1
  19. package/Drawer/drawerClasses.d.ts +32 -8
  20. package/Drawer/drawerClasses.js +1 -1
  21. package/FormControl/FormControl.js +9 -7
  22. package/FormControl/FormControlContext.js +2 -0
  23. package/Hidden/withWidth.js +2 -0
  24. package/IconButton/IconButton.d.ts +13 -0
  25. package/IconButton/IconButton.js +80 -7
  26. package/IconButton/iconButtonClasses.d.ts +6 -0
  27. package/IconButton/iconButtonClasses.js +1 -1
  28. package/LinearProgress/LinearProgress.js +4 -4
  29. package/LinearProgress/linearProgressClasses.d.ts +31 -9
  30. package/LinearProgress/linearProgressClasses.js +1 -1
  31. package/Link/getTextDecoration.js +3 -2
  32. package/RadioGroup/RadioGroupContext.js +2 -0
  33. package/Select/Select.js +10 -1
  34. package/Select/SelectInput.js +1 -1
  35. package/Slider/useSlider.js +5 -2
  36. package/Step/StepContext.js +2 -0
  37. package/StepLabel/StepLabel.d.ts +1 -1
  38. package/Stepper/StepperContext.js +2 -0
  39. package/Table/Tablelvl2Context.js +2 -0
  40. package/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +2 -0
  41. package/ToggleButtonGroup/ToggleButtonGroupContext.js +2 -0
  42. package/Tooltip/Tooltip.d.ts +1 -1
  43. package/index.js +1 -1
  44. package/modern/Alert/Alert.js +53 -21
  45. package/modern/Button/Button.js +233 -15
  46. package/modern/Button/buttonClasses.js +1 -1
  47. package/modern/ButtonGroup/ButtonGroupButtonContext.js +2 -0
  48. package/modern/ButtonGroup/ButtonGroupContext.js +2 -0
  49. package/modern/CardHeader/CardHeader.js +99 -32
  50. package/modern/CircularProgress/CircularProgress.js +2 -2
  51. package/modern/Dialog/Dialog.js +91 -20
  52. package/modern/Dialog/DialogContext.js +2 -0
  53. package/modern/Drawer/Drawer.js +1 -1
  54. package/modern/Drawer/drawerClasses.js +1 -1
  55. package/modern/FormControl/FormControl.js +9 -7
  56. package/modern/FormControl/FormControlContext.js +2 -0
  57. package/modern/Hidden/withWidth.js +2 -0
  58. package/modern/IconButton/IconButton.js +80 -7
  59. package/modern/IconButton/iconButtonClasses.js +1 -1
  60. package/modern/LinearProgress/LinearProgress.js +4 -4
  61. package/modern/LinearProgress/linearProgressClasses.js +1 -1
  62. package/modern/Link/getTextDecoration.js +3 -2
  63. package/modern/RadioGroup/RadioGroupContext.js +2 -0
  64. package/modern/Select/Select.js +10 -1
  65. package/modern/Select/SelectInput.js +1 -1
  66. package/modern/Slider/useSlider.js +5 -2
  67. package/modern/Step/StepContext.js +2 -0
  68. package/modern/Stepper/StepperContext.js +2 -0
  69. package/modern/Table/Tablelvl2Context.js +2 -0
  70. package/modern/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +2 -0
  71. package/modern/ToggleButtonGroup/ToggleButtonGroupContext.js +2 -0
  72. package/modern/index.js +1 -1
  73. package/modern/utils/index.js +1 -0
  74. package/modern/utils/mergeSlotProps.js +43 -0
  75. package/modern/utils/useSlot.js +5 -1
  76. package/modern/version/index.js +2 -2
  77. package/node/Alert/Alert.js +53 -21
  78. package/node/Button/Button.js +233 -15
  79. package/node/Button/buttonClasses.js +1 -1
  80. package/node/ButtonGroup/ButtonGroupButtonContext.js +1 -0
  81. package/node/ButtonGroup/ButtonGroupContext.js +1 -0
  82. package/node/CardHeader/CardHeader.js +99 -32
  83. package/node/CircularProgress/CircularProgress.js +2 -2
  84. package/node/Dialog/Dialog.js +91 -20
  85. package/node/Dialog/DialogContext.js +1 -0
  86. package/node/Drawer/Drawer.js +1 -1
  87. package/node/Drawer/drawerClasses.js +1 -1
  88. package/node/FormControl/FormControl.js +9 -7
  89. package/node/FormControl/FormControlContext.js +1 -0
  90. package/node/Hidden/withWidth.js +1 -0
  91. package/node/IconButton/IconButton.js +79 -6
  92. package/node/IconButton/iconButtonClasses.js +1 -1
  93. package/node/LinearProgress/LinearProgress.js +4 -4
  94. package/node/LinearProgress/linearProgressClasses.js +1 -1
  95. package/node/Link/getTextDecoration.js +3 -2
  96. package/node/RadioGroup/RadioGroupContext.js +1 -0
  97. package/node/Select/Select.js +10 -1
  98. package/node/Select/SelectInput.js +1 -1
  99. package/node/Slider/useSlider.js +5 -2
  100. package/node/Step/StepContext.js +1 -0
  101. package/node/Stepper/StepperContext.js +1 -0
  102. package/node/Table/Tablelvl2Context.js +1 -0
  103. package/node/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +1 -0
  104. package/node/ToggleButtonGroup/ToggleButtonGroupContext.js +1 -0
  105. package/node/index.js +1 -1
  106. package/node/utils/index.js +7 -0
  107. package/node/utils/mergeSlotProps.js +50 -0
  108. package/node/utils/useSlot.js +5 -1
  109. package/node/version/index.js +2 -2
  110. package/package.json +5 -5
  111. package/utils/index.d.ts +1 -0
  112. package/utils/index.js +1 -0
  113. package/utils/mergeSlotProps.d.ts +2 -0
  114. package/utils/mergeSlotProps.js +43 -0
  115. package/utils/useSlot.d.ts +8 -0
  116. package/utils/useSlot.js +5 -1
  117. package/version/index.js +2 -2
package/Dialog/Dialog.js CHANGED
@@ -15,6 +15,7 @@ import Backdrop from "../Backdrop/index.js";
15
15
  import { styled, useTheme } from "../zero-styled/index.js";
16
16
  import memoTheme from "../utils/memoTheme.js";
17
17
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
18
+ import useSlot from "../utils/useSlot.js";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
19
20
  const DialogBackdrop = styled(Backdrop, {
20
21
  name: 'MuiDialog',
@@ -218,6 +219,8 @@ const Dialog = /*#__PURE__*/React.forwardRef(function Dialog(inProps, ref) {
218
219
  PaperComponent = Paper,
219
220
  PaperProps = {},
220
221
  scroll = 'paper',
222
+ slots = {},
223
+ slotProps = {},
221
224
  TransitionComponent = Fade,
222
225
  transitionDuration = defaultTransitionDuration,
223
226
  TransitionProps,
@@ -261,46 +264,89 @@ const Dialog = /*#__PURE__*/React.forwardRef(function Dialog(inProps, ref) {
261
264
  titleId: ariaLabelledby
262
265
  };
263
266
  }, [ariaLabelledby]);
264
- return /*#__PURE__*/_jsx(DialogRoot, {
267
+ const backwardCompatibleSlots = {
268
+ transition: TransitionComponent,
269
+ ...slots
270
+ };
271
+ const backwardCompatibleSlotProps = {
272
+ transition: TransitionProps,
273
+ paper: PaperProps,
274
+ backdrop: BackdropProps,
275
+ ...slotProps
276
+ };
277
+ const externalForwardedProps = {
278
+ slots: backwardCompatibleSlots,
279
+ slotProps: backwardCompatibleSlotProps
280
+ };
281
+ const [RootSlot, rootSlotProps] = useSlot('root', {
282
+ elementType: DialogRoot,
283
+ shouldForwardComponentProp: true,
284
+ externalForwardedProps,
285
+ ownerState,
265
286
  className: clsx(classes.root, className),
287
+ ref
288
+ });
289
+ const [BackdropSlot, backdropSlotProps] = useSlot('backdrop', {
290
+ elementType: DialogBackdrop,
291
+ shouldForwardComponentProp: true,
292
+ externalForwardedProps,
293
+ ownerState
294
+ });
295
+ const [PaperSlot, paperSlotProps] = useSlot('paper', {
296
+ elementType: DialogPaper,
297
+ shouldForwardComponentProp: true,
298
+ externalForwardedProps,
299
+ ownerState,
300
+ className: clsx(classes.paper, PaperProps.className)
301
+ });
302
+ const [ContainerSlot, containerSlotProps] = useSlot('container', {
303
+ elementType: DialogContainer,
304
+ externalForwardedProps,
305
+ ownerState,
306
+ className: clsx(classes.container)
307
+ });
308
+ const [TransitionSlot, transitionSlotProps] = useSlot('transition', {
309
+ elementType: Fade,
310
+ externalForwardedProps,
311
+ ownerState,
312
+ additionalProps: {
313
+ appear: true,
314
+ in: open,
315
+ timeout: transitionDuration,
316
+ role: 'presentation'
317
+ }
318
+ });
319
+ return /*#__PURE__*/_jsx(RootSlot, {
266
320
  closeAfterTransition: true,
267
- components: {
268
- Backdrop: DialogBackdrop
321
+ slots: {
322
+ backdrop: BackdropSlot
269
323
  },
270
- componentsProps: {
324
+ slotProps: {
271
325
  backdrop: {
272
326
  transitionDuration,
273
327
  as: BackdropComponent,
274
- ...BackdropProps
328
+ ...backdropSlotProps
275
329
  }
276
330
  },
277
331
  disableEscapeKeyDown: disableEscapeKeyDown,
278
332
  onClose: onClose,
279
333
  open: open,
280
- ref: ref,
281
334
  onClick: handleBackdropClick,
282
- ownerState: ownerState,
335
+ ...rootSlotProps,
283
336
  ...other,
284
- children: /*#__PURE__*/_jsx(TransitionComponent, {
285
- appear: true,
286
- in: open,
287
- timeout: transitionDuration,
288
- role: "presentation",
289
- ...TransitionProps,
290
- children: /*#__PURE__*/_jsx(DialogContainer, {
291
- className: clsx(classes.container),
337
+ children: /*#__PURE__*/_jsx(TransitionSlot, {
338
+ ...transitionSlotProps,
339
+ children: /*#__PURE__*/_jsx(ContainerSlot, {
292
340
  onMouseDown: handleMouseDown,
293
- ownerState: ownerState,
294
- children: /*#__PURE__*/_jsx(DialogPaper, {
341
+ ...containerSlotProps,
342
+ children: /*#__PURE__*/_jsx(PaperSlot, {
295
343
  as: PaperComponent,
296
344
  elevation: 24,
297
345
  role: "dialog",
298
346
  "aria-describedby": ariaDescribedby,
299
347
  "aria-labelledby": ariaLabelledby,
300
348
  "aria-modal": ariaModal,
301
- ...PaperProps,
302
- className: clsx(classes.paper, PaperProps.className),
303
- ownerState: ownerState,
349
+ ...paperSlotProps,
304
350
  children: /*#__PURE__*/_jsx(DialogContext.Provider, {
305
351
  value: dialogContextValue,
306
352
  children: children
@@ -412,6 +458,7 @@ process.env.NODE_ENV !== "production" ? Dialog.propTypes /* remove-proptypes */
412
458
  /**
413
459
  * Props applied to the [`Paper`](https://mui.com/material-ui/api/paper/) element.
414
460
  * @default {}
461
+ * @deprecated Use `slotProps.paper` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
415
462
  */
416
463
  PaperProps: PropTypes.object,
417
464
  /**
@@ -419,6 +466,28 @@ process.env.NODE_ENV !== "production" ? Dialog.propTypes /* remove-proptypes */
419
466
  * @default 'paper'
420
467
  */
421
468
  scroll: PropTypes.oneOf(['body', 'paper']),
469
+ /**
470
+ * The props used for each slot inside.
471
+ * @default {}
472
+ */
473
+ slotProps: PropTypes.shape({
474
+ backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
475
+ container: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
476
+ paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
477
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
478
+ transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
479
+ }),
480
+ /**
481
+ * The components used for each slot inside.
482
+ * @default {}
483
+ */
484
+ slots: PropTypes.shape({
485
+ backdrop: PropTypes.elementType,
486
+ container: PropTypes.elementType,
487
+ paper: PropTypes.elementType,
488
+ root: PropTypes.elementType,
489
+ transition: PropTypes.elementType
490
+ }),
422
491
  /**
423
492
  * The system prop that allows defining system overrides as well as additional CSS styles.
424
493
  */
@@ -427,6 +496,7 @@ process.env.NODE_ENV !== "production" ? Dialog.propTypes /* remove-proptypes */
427
496
  * The component used for the transition.
428
497
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
429
498
  * @default Fade
499
+ * @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.
430
500
  */
431
501
  TransitionComponent: PropTypes.elementType,
432
502
  /**
@@ -445,6 +515,7 @@ process.env.NODE_ENV !== "production" ? Dialog.propTypes /* remove-proptypes */
445
515
  /**
446
516
  * Props applied to the transition element.
447
517
  * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
518
+ * @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.
448
519
  */
449
520
  TransitionProps: PropTypes.object
450
521
  } : void 0;
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  const DialogContext = /*#__PURE__*/React.createContext({});
3
5
  if (process.env.NODE_ENV !== 'production') {
package/Drawer/Drawer.js CHANGED
@@ -29,7 +29,7 @@ const useUtilityClasses = ownerState => {
29
29
  variant
30
30
  } = ownerState;
31
31
  const slots = {
32
- root: ['root'],
32
+ root: ['root', `anchor${capitalize(anchor)}`],
33
33
  docked: [(variant === 'permanent' || variant === 'persistent') && 'docked'],
34
34
  modal: ['modal'],
35
35
  paper: ['paper', `paperAnchor${capitalize(anchor)}`, variant !== 'temporary' && `paperAnchorDocked${capitalize(anchor)}`]
@@ -5,21 +5,45 @@ export interface DrawerClasses {
5
5
  docked: string;
6
6
  /** Styles applied to the Paper component. */
7
7
  paper: string;
8
- /** Styles applied to the Paper component if `anchor="left"`. */
8
+ /** Styles applied to the root element if `anchor="left"`. */
9
+ anchorLeft: string;
10
+ /** Styles applied to the root element if `anchor="right"`. */
11
+ anchorRight: string;
12
+ /** Styles applied to the root element if `anchor="top"`. */
13
+ anchorTop: string;
14
+ /** Styles applied to the root element if `anchor="bottom"`. */
15
+ anchorBottom: string;
16
+ /** Styles applied to the Paper component if `anchor="left"`.
17
+ * @deprecated Combine the [.MuiDrawer-anchorLeft](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorLeft) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
18
+ */
9
19
  paperAnchorLeft: string;
10
- /** Styles applied to the Paper component if `anchor="right"`. */
20
+ /** Styles applied to the Paper component if `anchor="right"`.
21
+ * @deprecated Combine the [.MuiDrawer-anchorRight](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorRight) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
22
+ */
11
23
  paperAnchorRight: string;
12
- /** Styles applied to the Paper component if `anchor="top"`. */
24
+ /** Styles applied to the Paper component if `anchor="top"`.
25
+ * @deprecated Combine the [.MuiDrawer-anchorTop](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorTop) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
26
+ */
13
27
  paperAnchorTop: string;
14
- /** Styles applied to the Paper component if `anchor="bottom"`. */
28
+ /** Styles applied to the Paper component if `anchor="bottom"`.
29
+ * @deprecated Combine the [.MuiDrawer-anchorBottom](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorBottom) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
30
+ */
15
31
  paperAnchorBottom: string;
16
- /** Styles applied to the Paper component if `anchor="left"` and `variant` is not "temporary". */
32
+ /** Styles applied to the Paper component if `anchor="left"` and `variant` is not "temporary".
33
+ * @deprecated Combine the [.MuiDrawer-anchorLeft](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorLeft), [.MuiDrawer-docked](/material-ui/api/drawer/#drawer-classes-MuiDrawer-docked) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
34
+ */
17
35
  paperAnchorDockedLeft: string;
18
- /** Styles applied to the Paper component if `anchor="top"` and `variant` is not "temporary". */
36
+ /** Styles applied to the Paper component if `anchor="top"` and `variant` is not "temporary".
37
+ * @deprecated Combine the [.MuiDrawer-anchorTop](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorTop), [.MuiDrawer-docked](/material-ui/api/drawer/#drawer-classes-MuiDrawer-docked) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
38
+ */
19
39
  paperAnchorDockedTop: string;
20
- /** Styles applied to the Paper component if `anchor="right"` and `variant` is not "temporary". */
40
+ /** Styles applied to the Paper component if `anchor="right"` and `variant` is not "temporary".
41
+ * @deprecated Combine the [.MuiDrawer-anchorRight](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorRight), [.MuiDrawer-docked](/material-ui/api/drawer/#drawer-classes-MuiDrawer-docked) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
42
+ */
21
43
  paperAnchorDockedRight: string;
22
- /** Styles applied to the Paper component if `anchor="bottom"` and `variant` is not "temporary". */
44
+ /** Styles applied to the Paper component if `anchor="bottom"` and `variant` is not "temporary".
45
+ * @deprecated Combine the [.MuiDrawer-anchorBottom](/material-ui/api/drawer/#drawer-classes-MuiDrawer-anchorBottom), [.MuiDrawer-docked](/material-ui/api/drawer/#drawer-classes-MuiDrawer-docked) and [.MuiDrawer-paper](/material-ui/api/drawer/#drawer-classes-MuiDrawer-paper) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/)
46
+ */
23
47
  paperAnchorDockedBottom: string;
24
48
  /** Styles applied to the Modal component. */
25
49
  modal: string;
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
3
  export function getDrawerUtilityClass(slot) {
4
4
  return generateUtilityClass('MuiDrawer', slot);
5
5
  }
6
- const drawerClasses = generateUtilityClasses('MuiDrawer', ['root', 'docked', 'paper', 'paperAnchorLeft', 'paperAnchorRight', 'paperAnchorTop', 'paperAnchorBottom', 'paperAnchorDockedLeft', 'paperAnchorDockedRight', 'paperAnchorDockedTop', 'paperAnchorDockedBottom', 'modal']);
6
+ const drawerClasses = generateUtilityClasses('MuiDrawer', ['root', 'docked', 'paper', 'anchorLeft', 'anchorRight', 'anchorTop', 'anchorBottom', 'paperAnchorLeft', 'paperAnchorRight', 'paperAnchorTop', 'paperAnchorBottom', 'paperAnchorDockedLeft', 'paperAnchorDockedRight', 'paperAnchorDockedTop', 'paperAnchorDockedBottom', 'modal']);
7
7
  export default drawerClasses;
@@ -179,6 +179,12 @@ const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps,
179
179
  };
180
180
  };
181
181
  }
182
+ const onFilled = React.useCallback(() => {
183
+ setFilled(true);
184
+ }, []);
185
+ const onEmpty = React.useCallback(() => {
186
+ setFilled(false);
187
+ }, []);
182
188
  const childContext = React.useMemo(() => {
183
189
  return {
184
190
  adornedStart,
@@ -194,20 +200,16 @@ const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps,
194
200
  onBlur: () => {
195
201
  setFocused(false);
196
202
  },
197
- onEmpty: () => {
198
- setFilled(false);
199
- },
200
- onFilled: () => {
201
- setFilled(true);
202
- },
203
203
  onFocus: () => {
204
204
  setFocused(true);
205
205
  },
206
+ onEmpty,
207
+ onFilled,
206
208
  registerEffect,
207
209
  required,
208
210
  variant
209
211
  };
210
- }, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, required, size, variant]);
212
+ }, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, onEmpty, onFilled, required, size, variant]);
211
213
  return /*#__PURE__*/_jsx(FormControlContext.Provider, {
212
214
  value: childContext,
213
215
  children: /*#__PURE__*/_jsx(FormControlRoot, {
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  /**
3
5
  * @ignore - internal component.
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import getDisplayName from '@mui/utils/getDisplayName';
@@ -47,6 +47,19 @@ 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
+ * 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).
53
+ * @default null
54
+ */
55
+ loading?: boolean | null;
56
+ /**
57
+ * Element placed before the children if the button is in loading state.
58
+ * The node should contain an element with `role="progressbar"` with an accessible name.
59
+ * By default, it renders a `CircularProgress` that is labeled by the button itself.
60
+ * @default <CircularProgress color="inherit" size={16} />
61
+ */
62
+ loadingIndicator?: React.ReactNode;
50
63
  /**
51
64
  * The size of the component.
52
65
  * `small` is equivalent to the dense button styling.
@@ -5,25 +5,30 @@ 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'],
31
+ loadingWrapper: ['loadingWrapper']
27
32
  };
28
33
  return composeClasses(slots, getIconButtonUtilityClass, classes);
29
34
  };
@@ -34,7 +39,7 @@ const IconButtonRoot = styled(ButtonBase, {
34
39
  const {
35
40
  ownerState
36
41
  } = 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)}`]];
42
+ 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
43
  }
39
44
  })(memoTheme(({
40
45
  theme
@@ -137,8 +142,34 @@ const IconButtonRoot = styled(ButtonBase, {
137
142
  [`&.${iconButtonClasses.disabled}`]: {
138
143
  backgroundColor: 'transparent',
139
144
  color: (theme.vars || theme).palette.action.disabled
145
+ },
146
+ [`&.${iconButtonClasses.loading}`]: {
147
+ color: 'transparent'
140
148
  }
141
149
  })));
150
+ const IconButtonLoadingIndicator = styled('span', {
151
+ name: 'MuiIconButton',
152
+ slot: 'LoadingIndicator',
153
+ overridesResolver: (props, styles) => styles.loadingIndicator
154
+ })(({
155
+ theme
156
+ }) => ({
157
+ display: 'none',
158
+ position: 'absolute',
159
+ visibility: 'visible',
160
+ top: '50%',
161
+ left: '50%',
162
+ transform: 'translate(-50%, -50%)',
163
+ color: (theme.vars || theme).palette.action.disabled,
164
+ variants: [{
165
+ props: {
166
+ loading: true
167
+ },
168
+ style: {
169
+ display: 'flex'
170
+ }
171
+ }]
172
+ }));
142
173
 
143
174
  /**
144
175
  * Refer to the [Icons](/material-ui/icons/) section of the documentation
@@ -157,26 +188,51 @@ const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(inProps, re
157
188
  disabled = false,
158
189
  disableFocusRipple = false,
159
190
  size = 'medium',
191
+ id: idProp,
192
+ loading = null,
193
+ loadingIndicator: loadingIndicatorProp,
160
194
  ...other
161
195
  } = props;
196
+ const id = useId(idProp);
197
+ const loadingIndicator = loadingIndicatorProp ?? /*#__PURE__*/_jsx(CircularProgress, {
198
+ "aria-labelledby": id,
199
+ color: "inherit",
200
+ size: 16
201
+ });
162
202
  const ownerState = {
163
203
  ...props,
164
204
  edge,
165
205
  color,
166
206
  disabled,
167
207
  disableFocusRipple,
208
+ loading,
209
+ loadingIndicator,
168
210
  size
169
211
  };
170
212
  const classes = useUtilityClasses(ownerState);
171
- return /*#__PURE__*/_jsx(IconButtonRoot, {
213
+ return /*#__PURE__*/_jsxs(IconButtonRoot, {
214
+ id: id,
172
215
  className: clsx(classes.root, className),
173
216
  centerRipple: true,
174
217
  focusRipple: !disableFocusRipple,
175
- disabled: disabled,
218
+ disabled: disabled || loading,
176
219
  ref: ref,
177
220
  ...other,
178
221
  ownerState: ownerState,
179
- children: children
222
+ children: [typeof loading === 'boolean' &&
223
+ /*#__PURE__*/
224
+ // use plain HTML span to minimize the runtime overhead
225
+ _jsx("span", {
226
+ className: classes.loadingWrapper,
227
+ style: {
228
+ display: 'contents'
229
+ },
230
+ children: /*#__PURE__*/_jsx(IconButtonLoadingIndicator, {
231
+ className: classes.loadingIndicator,
232
+ ownerState: ownerState,
233
+ children: loading && loadingIndicator
234
+ })
235
+ }), children]
180
236
  });
181
237
  });
182
238
  process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes */ = {
@@ -235,6 +291,23 @@ process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes
235
291
  * @default false
236
292
  */
237
293
  edge: PropTypes.oneOf(['end', 'start', false]),
294
+ /**
295
+ * @ignore
296
+ */
297
+ id: PropTypes.string,
298
+ /**
299
+ * If `true`, the loading indicator is visible and the button is disabled.
300
+ * 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).
301
+ * @default null
302
+ */
303
+ loading: PropTypes.bool,
304
+ /**
305
+ * Element placed before the children if the button is in loading state.
306
+ * The node should contain an element with `role="progressbar"` with an accessible name.
307
+ * By default, it renders a `CircularProgress` that is labeled by the button itself.
308
+ * @default <CircularProgress color="inherit" size={16} />
309
+ */
310
+ loadingIndicator: PropTypes.node,
238
311
  /**
239
312
  * The size of the component.
240
313
  * `small` is equivalent to the dense button styling.
@@ -27,6 +27,12 @@ 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;
34
+ /** Styles applied to the loadingWrapper element. */
35
+ loadingWrapper: string;
30
36
  }
31
37
  export type IconButtonClassKey = keyof IconButtonClasses;
32
38
  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', 'loadingWrapper']);
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
  }
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  /**
3
5
  * @ignore - internal component.