@mui/material 7.0.0-beta.3 → 7.0.0-rc.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 (126) hide show
  1. package/Accordion/Accordion.d.ts +13 -2
  2. package/Accordion/Accordion.js +18 -6
  3. package/AccordionSummary/AccordionSummary.d.ts +39 -4
  4. package/AccordionSummary/AccordionSummary.js +67 -16
  5. package/CHANGELOG.md +84 -0
  6. package/InputBase/InputBase.js +2 -2
  7. package/ListItemText/ListItemText.d.ts +10 -0
  8. package/ListItemText/ListItemText.js +14 -5
  9. package/Select/SelectInput.js +2 -2
  10. package/SpeedDial/SpeedDial.d.ts +10 -0
  11. package/SpeedDial/SpeedDial.js +40 -11
  12. package/SpeedDialAction/SpeedDialAction.js +1 -1
  13. package/StepLabel/StepLabel.d.ts +19 -1
  14. package/StepLabel/StepLabel.js +14 -5
  15. package/Switch/Switch.d.ts +62 -1
  16. package/Switch/Switch.js +71 -9
  17. package/TextField/TextField.d.ts +30 -0
  18. package/TextField/TextField.js +22 -11
  19. package/TextareaAutosize/TextareaAutosize.js +25 -14
  20. package/Tooltip/Tooltip.d.ts +1 -1
  21. package/Tooltip/Tooltip.js +1 -1
  22. package/Typography/Typography.d.ts +3 -3
  23. package/esm/Accordion/Accordion.d.ts +13 -2
  24. package/esm/Accordion/Accordion.js +18 -6
  25. package/esm/AccordionSummary/AccordionSummary.d.ts +39 -4
  26. package/esm/AccordionSummary/AccordionSummary.js +67 -16
  27. package/esm/InputBase/InputBase.js +2 -2
  28. package/esm/ListItemText/ListItemText.d.ts +10 -0
  29. package/esm/ListItemText/ListItemText.js +14 -5
  30. package/esm/Select/SelectInput.js +2 -2
  31. package/esm/SpeedDial/SpeedDial.d.ts +10 -0
  32. package/esm/SpeedDial/SpeedDial.js +40 -11
  33. package/esm/SpeedDialAction/SpeedDialAction.js +1 -1
  34. package/esm/StepLabel/StepLabel.d.ts +19 -1
  35. package/esm/StepLabel/StepLabel.js +14 -5
  36. package/esm/Switch/Switch.d.ts +62 -1
  37. package/esm/Switch/Switch.js +71 -9
  38. package/esm/TextField/TextField.d.ts +30 -0
  39. package/esm/TextField/TextField.js +22 -11
  40. package/esm/TextareaAutosize/TextareaAutosize.js +26 -15
  41. package/esm/Tooltip/Tooltip.d.ts +1 -1
  42. package/esm/Tooltip/Tooltip.js +1 -1
  43. package/esm/Typography/Typography.d.ts +3 -3
  44. package/esm/index.js +1 -1
  45. package/esm/styles/ThemeProvider.d.ts +6 -0
  46. package/esm/styles/ThemeProvider.js +11 -0
  47. package/esm/styles/adaptV4Theme.d.ts +2 -2
  48. package/esm/styles/createPalette.js +3 -3
  49. package/esm/styles/createThemeNoVars.d.ts +3 -3
  50. package/esm/styles/createThemeNoVars.js +2 -2
  51. package/esm/styles/createThemeWithVars.js +2 -2
  52. package/esm/styles/createTypography.d.ts +4 -4
  53. package/esm/styles/index.d.ts +1 -1
  54. package/esm/styles/index.js +2 -2
  55. package/esm/styles/makeStyles.js +2 -2
  56. package/esm/styles/responsiveFontSizes.d.ts +3 -3
  57. package/esm/styles/responsiveFontSizes.js +2 -2
  58. package/esm/styles/withStyles.js +2 -2
  59. package/esm/styles/withTheme.js +2 -2
  60. package/esm/useScrollTrigger/useScrollTrigger.d.ts +1 -1
  61. package/esm/useScrollTrigger/useScrollTrigger.js +3 -0
  62. package/esm/utils/mergeSlotProps.js +25 -0
  63. package/esm/version/index.js +2 -2
  64. package/index.js +1 -1
  65. package/modern/Accordion/Accordion.d.ts +13 -2
  66. package/modern/Accordion/Accordion.js +18 -6
  67. package/modern/AccordionSummary/AccordionSummary.d.ts +39 -4
  68. package/modern/AccordionSummary/AccordionSummary.js +67 -16
  69. package/modern/InputBase/InputBase.js +2 -2
  70. package/modern/ListItemText/ListItemText.d.ts +10 -0
  71. package/modern/ListItemText/ListItemText.js +14 -5
  72. package/modern/Select/SelectInput.js +2 -2
  73. package/modern/SpeedDial/SpeedDial.d.ts +10 -0
  74. package/modern/SpeedDial/SpeedDial.js +40 -11
  75. package/modern/SpeedDialAction/SpeedDialAction.js +1 -1
  76. package/modern/StepLabel/StepLabel.d.ts +19 -1
  77. package/modern/StepLabel/StepLabel.js +14 -5
  78. package/modern/Switch/Switch.d.ts +62 -1
  79. package/modern/Switch/Switch.js +71 -9
  80. package/modern/TextField/TextField.d.ts +30 -0
  81. package/modern/TextField/TextField.js +22 -11
  82. package/modern/TextareaAutosize/TextareaAutosize.js +26 -15
  83. package/modern/Tooltip/Tooltip.d.ts +1 -1
  84. package/modern/Tooltip/Tooltip.js +1 -1
  85. package/modern/Typography/Typography.d.ts +3 -3
  86. package/modern/index.js +1 -1
  87. package/modern/styles/ThemeProvider.d.ts +6 -0
  88. package/modern/styles/ThemeProvider.js +11 -0
  89. package/modern/styles/adaptV4Theme.d.ts +2 -2
  90. package/modern/styles/createPalette.js +3 -3
  91. package/modern/styles/createThemeNoVars.d.ts +3 -3
  92. package/modern/styles/createThemeNoVars.js +2 -2
  93. package/modern/styles/createThemeWithVars.js +2 -2
  94. package/modern/styles/createTypography.d.ts +4 -4
  95. package/modern/styles/index.d.ts +1 -1
  96. package/modern/styles/index.js +2 -2
  97. package/modern/styles/makeStyles.js +2 -2
  98. package/modern/styles/responsiveFontSizes.d.ts +3 -3
  99. package/modern/styles/responsiveFontSizes.js +2 -2
  100. package/modern/styles/withStyles.js +2 -2
  101. package/modern/styles/withTheme.js +2 -2
  102. package/modern/useScrollTrigger/useScrollTrigger.d.ts +1 -1
  103. package/modern/useScrollTrigger/useScrollTrigger.js +3 -0
  104. package/modern/utils/mergeSlotProps.js +25 -0
  105. package/modern/version/index.js +2 -2
  106. package/package.json +7 -7
  107. package/styles/ThemeProvider.d.ts +6 -0
  108. package/styles/ThemeProvider.js +11 -0
  109. package/styles/adaptV4Theme.d.ts +2 -2
  110. package/styles/createPalette.js +3 -3
  111. package/styles/createThemeNoVars.d.ts +3 -3
  112. package/styles/createThemeNoVars.js +2 -2
  113. package/styles/createThemeWithVars.js +2 -2
  114. package/styles/createTypography.d.ts +4 -4
  115. package/styles/index.d.ts +1 -1
  116. package/styles/index.js +2 -2
  117. package/styles/makeStyles.js +2 -2
  118. package/styles/responsiveFontSizes.d.ts +3 -3
  119. package/styles/responsiveFontSizes.js +2 -2
  120. package/styles/withStyles.js +2 -2
  121. package/styles/withTheme.js +2 -2
  122. package/tsconfig.build.tsbuildinfo +1 -1
  123. package/useScrollTrigger/useScrollTrigger.d.ts +1 -1
  124. package/useScrollTrigger/useScrollTrigger.js +3 -0
  125. package/utils/mergeSlotProps.js +24 -0
  126. package/version/index.js +2 -2
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
3
+ import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
4
4
  var _InputGlobalStyles;
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
@@ -372,7 +372,7 @@ const InputBase = /*#__PURE__*/React.forwardRef(function InputBase(inProps, ref)
372
372
  if (!isControlled) {
373
373
  const element = event.target || inputRef.current;
374
374
  if (element == null) {
375
- throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: Expected valid input target. ' + 'Did you use a custom `inputComponent` and forget to forward refs? ' + 'See https://mui.com/r/input-component-ref-interface for more info.' : _formatMuiErrorMessage(1));
375
+ throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: Expected valid input target. ' + 'Did you use a custom `inputComponent` and forget to forward refs? ' + 'See https://mui.com/r/input-component-ref-interface for more info.' : _formatErrorMessage(1));
376
376
  }
377
377
  checkDirty({
378
378
  value: element.value
@@ -5,6 +5,11 @@ import { TypographyProps } from "../Typography/index.js";
5
5
  import { ListItemTextClasses } from "./listItemTextClasses.js";
6
6
  import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
7
7
  export interface ListItemTextSlots {
8
+ /**
9
+ * The component that renders the root slot.
10
+ * @default 'div'
11
+ */
12
+ root?: React.ElementType;
8
13
  /**
9
14
  * The component that renders the primary slot.
10
15
  * @default Typography
@@ -17,6 +22,11 @@ export interface ListItemTextSlots {
17
22
  secondary?: React.ElementType;
18
23
  }
19
24
  export type ListItemTextSlotsAndSlotProps = CreateSlotsAndSlotProps<ListItemTextSlots, {
25
+ /**
26
+ * Props forwared to the root slot.
27
+ * By default, the available props are based on `div` element.
28
+ */
29
+ root: SlotProps<'div', {}, ListItemTextOwnerState>;
20
30
  /**
21
31
  * Props forwared to the primary slot (as long as disableTypography is not `true`)
22
32
  * By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component
@@ -107,6 +107,16 @@ const ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(inProps
107
107
  ...slotProps
108
108
  }
109
109
  };
110
+ const [RootSlot, rootSlotProps] = useSlot('root', {
111
+ className: clsx(classes.root, className),
112
+ elementType: ListItemTextRoot,
113
+ externalForwardedProps: {
114
+ ...externalForwardedProps,
115
+ ...other
116
+ },
117
+ ownerState,
118
+ ref
119
+ });
110
120
  const [PrimarySlot, primarySlotProps] = useSlot('primary', {
111
121
  className: classes.primary,
112
122
  elementType: Typography,
@@ -135,11 +145,8 @@ const ListItemText = /*#__PURE__*/React.forwardRef(function ListItemText(inProps
135
145
  children: secondary
136
146
  });
137
147
  }
138
- return /*#__PURE__*/_jsxs(ListItemTextRoot, {
139
- className: clsx(classes.root, className),
140
- ownerState: ownerState,
141
- ref: ref,
142
- ...other,
148
+ return /*#__PURE__*/_jsxs(RootSlot, {
149
+ ...rootSlotProps,
143
150
  children: [primary, secondary]
144
151
  });
145
152
  });
@@ -200,6 +207,7 @@ process.env.NODE_ENV !== "production" ? ListItemText.propTypes /* remove-proptyp
200
207
  */
201
208
  slotProps: PropTypes.shape({
202
209
  primary: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
210
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
203
211
  secondary: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
204
212
  }),
205
213
  /**
@@ -208,6 +216,7 @@ process.env.NODE_ENV !== "production" ? ListItemText.propTypes /* remove-proptyp
208
216
  */
209
217
  slots: PropTypes.shape({
210
218
  primary: PropTypes.elementType,
219
+ root: PropTypes.elementType,
211
220
  secondary: PropTypes.elementType
212
221
  }),
213
222
  /**
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
3
+ import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
4
4
  var _span;
5
5
  import * as React from 'react';
6
6
  import { isFragment } from 'react-is';
@@ -348,7 +348,7 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
348
348
  let selected;
349
349
  if (multiple) {
350
350
  if (!Array.isArray(value)) {
351
- throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: The `value` prop must be an array ' + 'when using the `Select` component with `multiple`.' : _formatMuiErrorMessage(2));
351
+ throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: The `value` prop must be an array ' + 'when using the `Select` component with `multiple`.' : _formatErrorMessage(2));
352
352
  }
353
353
  selected = value.some(v => areEqualValues(v, child.props.value));
354
354
  if (selected && computeDisplay) {
@@ -9,6 +9,11 @@ import { CreateSlotsAndSlotProps, SlotComponentProps } from "../utils/types.js";
9
9
  export type CloseReason = 'toggle' | 'blur' | 'mouseLeave' | 'escapeKeyDown';
10
10
  export type OpenReason = 'toggle' | 'focus' | 'mouseEnter';
11
11
  export interface SpeedDialSlots {
12
+ /**
13
+ * The component that renders the root slot.
14
+ * @default 'div'
15
+ */
16
+ root: React.ElementType;
12
17
  /**
13
18
  * The component that renders the transition.
14
19
  * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
@@ -17,6 +22,11 @@ export interface SpeedDialSlots {
17
22
  transition: React.ElementType;
18
23
  }
19
24
  export type SpeedDialSlotsAndSlotProps = CreateSlotsAndSlotProps<SpeedDialSlots, {
25
+ /**
26
+ * Props forwarded to the root slot.
27
+ * By default, the avaible props are based on div element.
28
+ */
29
+ root: SlotComponentProps<'div', React.HTMLAttributes<HTMLDivElement>, SpeedDialOwnerState>;
20
30
  /**
21
31
  * Props forwarded to the transition slot.
22
32
  * By default, the avaible props are based on the [Zoom](https://mui.com/material-ui/api/zoom/#props) component.
@@ -372,22 +372,49 @@ const SpeedDial = /*#__PURE__*/React.forwardRef(function SpeedDial(inProps, ref)
372
372
  slots: backwardCompatibleSlots,
373
373
  slotProps: backwardCompatibleSlotProps
374
374
  };
375
+ const [RootSlot, rootSlotProps] = useSlot('root', {
376
+ elementType: SpeedDialRoot,
377
+ externalForwardedProps: {
378
+ ...externalForwardedProps,
379
+ ...other
380
+ },
381
+ ownerState,
382
+ ref,
383
+ className: clsx(classes.root, className),
384
+ additionalProps: {
385
+ role: 'presentation'
386
+ },
387
+ getSlotProps: handlers => ({
388
+ ...handlers,
389
+ onKeyDown: event => {
390
+ handlers.onKeyDown?.(event);
391
+ handleKeyDown(event);
392
+ },
393
+ onBlur: event => {
394
+ handlers.onBlur?.(event);
395
+ handleClose(event);
396
+ },
397
+ onFocus: event => {
398
+ handlers.onFocus?.(event);
399
+ handleOpen(event);
400
+ },
401
+ onMouseEnter: event => {
402
+ handlers.onMouseEnter?.(event);
403
+ handleOpen(event);
404
+ },
405
+ onMouseLeave: event => {
406
+ handlers.onMouseLeave?.(event);
407
+ handleClose(event);
408
+ }
409
+ })
410
+ });
375
411
  const [TransitionSlot, transitionProps] = useSlot('transition', {
376
412
  elementType: Zoom,
377
413
  externalForwardedProps,
378
414
  ownerState
379
415
  });
380
- return /*#__PURE__*/_jsxs(SpeedDialRoot, {
381
- className: clsx(classes.root, className),
382
- ref: ref,
383
- role: "presentation",
384
- onKeyDown: handleKeyDown,
385
- onBlur: handleClose,
386
- onFocus: handleOpen,
387
- onMouseEnter: handleOpen,
388
- onMouseLeave: handleClose,
389
- ownerState: ownerState,
390
- ...other,
416
+ return /*#__PURE__*/_jsxs(RootSlot, {
417
+ ...rootSlotProps,
391
418
  children: [/*#__PURE__*/_jsx(TransitionSlot, {
392
419
  in: !hidden,
393
420
  timeout: transitionDuration,
@@ -507,6 +534,7 @@ process.env.NODE_ENV !== "production" ? SpeedDial.propTypes /* remove-proptypes
507
534
  * @default {}
508
535
  */
509
536
  slotProps: PropTypes.shape({
537
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
510
538
  transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
511
539
  }),
512
540
  /**
@@ -514,6 +542,7 @@ process.env.NODE_ENV !== "production" ? SpeedDial.propTypes /* remove-proptypes
514
542
  * @default {}
515
543
  */
516
544
  slots: PropTypes.shape({
545
+ root: PropTypes.elementType,
517
546
  transition: PropTypes.elementType
518
547
  }),
519
548
  /**
@@ -341,7 +341,7 @@ process.env.NODE_ENV !== "production" ? SpeedDialAction.propTypes /* remove-prop
341
341
  * @default 'left'
342
342
  * @deprecated Use `slotProps.tooltip.placement` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
343
343
  */
344
- tooltipPlacement: PropTypes.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
344
+ tooltipPlacement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
345
345
  /**
346
346
  * Label to display in the tooltip.
347
347
  * @deprecated Use `slotProps.tooltip.title` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
@@ -6,6 +6,11 @@ import { Theme } from "../styles/index.js";
6
6
  import { StepLabelClasses } from "./stepLabelClasses.js";
7
7
  import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
8
8
  export interface StepLabelSlots {
9
+ /**
10
+ * The component that renders the root.
11
+ * @default span
12
+ */
13
+ root: React.ElementType;
9
14
  /**
10
15
  * The component that renders the label.
11
16
  * @default span
@@ -17,7 +22,20 @@ export interface StepLabelSlots {
17
22
  stepIcon: React.ElementType;
18
23
  }
19
24
  export type StepLabelSlotsAndSlotProps = CreateSlotsAndSlotProps<StepLabelSlots, {
20
- label: SlotProps<React.ElementType<React.HTMLProps<HTMLSpanElement>>, {}, StepLabelOwnerState>;
25
+ /**
26
+ * Props forwarded to the root slot.
27
+ * By default, the avaible props are based on the span element.
28
+ */
29
+ root: SlotProps<'span', {}, StepLabelOwnerState>;
30
+ /**
31
+ * Props forwarded to the label slot.
32
+ * By default, the avaible props are based on the span element.
33
+ */
34
+ label: SlotProps<'span', {}, StepLabelOwnerState>;
35
+ /**
36
+ * Props forwarded to the stepIcon slot.
37
+ * By default, the avaible props are based on the div element.
38
+ */
21
39
  stepIcon: SlotProps<React.ElementType<StepIconProps>, {}, StepLabelOwnerState>;
22
40
  }>;
23
41
  export interface StepLabelOwnerState extends StepLabelProps {}
@@ -162,6 +162,16 @@ const StepLabel = /*#__PURE__*/React.forwardRef(function StepLabel(inProps, ref)
162
162
  ...slotProps
163
163
  }
164
164
  };
165
+ const [RootSlot, rootProps] = useSlot('root', {
166
+ elementType: StepLabelRoot,
167
+ externalForwardedProps: {
168
+ ...externalForwardedProps,
169
+ ...other
170
+ },
171
+ ownerState,
172
+ ref,
173
+ className: clsx(classes.root, className)
174
+ });
165
175
  const [LabelSlot, labelProps] = useSlot('label', {
166
176
  elementType: StepLabelLabel,
167
177
  externalForwardedProps,
@@ -172,11 +182,8 @@ const StepLabel = /*#__PURE__*/React.forwardRef(function StepLabel(inProps, ref)
172
182
  externalForwardedProps,
173
183
  ownerState
174
184
  });
175
- return /*#__PURE__*/_jsxs(StepLabelRoot, {
176
- className: clsx(classes.root, className),
177
- ref: ref,
178
- ownerState: ownerState,
179
- ...other,
185
+ return /*#__PURE__*/_jsxs(RootSlot, {
186
+ ...rootProps,
180
187
  children: [icon || StepIconSlot ? /*#__PURE__*/_jsx(StepLabelIconContainer, {
181
188
  className: classes.iconContainer,
182
189
  ownerState: ownerState,
@@ -242,6 +249,7 @@ process.env.NODE_ENV !== "production" ? StepLabel.propTypes /* remove-proptypes
242
249
  */
243
250
  slotProps: PropTypes.shape({
244
251
  label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
252
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
245
253
  stepIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
246
254
  }),
247
255
  /**
@@ -250,6 +258,7 @@ process.env.NODE_ENV !== "production" ? StepLabel.propTypes /* remove-proptypes
250
258
  */
251
259
  slots: PropTypes.shape({
252
260
  label: PropTypes.elementType,
261
+ root: PropTypes.elementType,
253
262
  stepIcon: PropTypes.elementType
254
263
  }),
255
264
  /**
@@ -2,11 +2,72 @@ import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
3
  import { OverridableStringUnion } from '@mui/types';
4
4
  import { InternalStandardProps as StandardProps, Theme } from "../index.js";
5
+ import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
5
6
  import { SwitchBaseProps } from "../internal/SwitchBase.js";
6
7
  import { SwitchClasses } from "./switchClasses.js";
7
8
  export interface SwitchPropsSizeOverrides {}
8
9
  export interface SwitchPropsColorOverrides {}
9
- export interface SwitchProps extends StandardProps<SwitchBaseProps, 'checkedIcon' | 'color' | 'icon'> {
10
+ export interface SwitchRootSlotPropsOverrides {}
11
+ export interface SwitchTrackSlotPropsOverrides {}
12
+ export interface SwitchThumbSlotPropsOverrides {}
13
+ export interface SwitchSwitchBaseSlotPropsOverrides {}
14
+ export interface SwitchInputSlotPropsOverrides {}
15
+ export interface SwitchSlots {
16
+ /**
17
+ * The component that renders the root slot.
18
+ * @default 'span'
19
+ */
20
+ root: React.ElementType;
21
+ /**
22
+ * The component that renders the track slot.
23
+ * @default 'span'
24
+ */
25
+ track: React.ElementType;
26
+ /**
27
+ * The component that renders the thumb slot.
28
+ * @default 'span'
29
+ */
30
+ thumb: React.ElementType;
31
+ /**
32
+ * The component that renders the switchBase slot.
33
+ * @default SwitchBase
34
+ */
35
+ switchBase: React.ElementType;
36
+ /**
37
+ * The component that renders the switchBase's input slot.
38
+ * @default SwitchBaseInput
39
+ */
40
+ input: React.ElementType;
41
+ }
42
+ export type SwitchSlotsAndSlotProps = CreateSlotsAndSlotProps<SwitchSlots, {
43
+ /**
44
+ * Props forwarded to the root slot.
45
+ * By default, the avaible props are based on the span element.
46
+ */
47
+ root: SlotProps<'span', SwitchRootSlotPropsOverrides, SwitchOwnerState>;
48
+ /**
49
+ * Props forwarded to the track slot.
50
+ * By default, the avaible props are based on the span element.
51
+ */
52
+ track: SlotProps<'span', SwitchTrackSlotPropsOverrides, SwitchOwnerState>;
53
+ /**
54
+ * Props forwarded to the thumb slot.
55
+ * By default, the avaible props are based on the span element.
56
+ */
57
+ thumb: SlotProps<'span', SwitchThumbSlotPropsOverrides, SwitchOwnerState>;
58
+ /**
59
+ * Props forwarded to the switchBase slot.
60
+ * By default, the avaible props are based on the internal SwitchBase component.
61
+ */
62
+ switchBase: SlotProps<React.ElementType<SwitchBaseProps>, SwitchSwitchBaseSlotPropsOverrides, SwitchOwnerState>;
63
+ /**
64
+ * Props forwarded to the input slot.
65
+ * By default, the avaible props are based on the input element.
66
+ */
67
+ input: SlotProps<'input', SwitchInputSlotPropsOverrides, SwitchOwnerState>;
68
+ }>;
69
+ export interface SwitchOwnerState extends Omit<SwitchProps, 'slots' | 'slotProps'> {}
70
+ export interface SwitchProps extends StandardProps<SwitchBaseProps, 'checkedIcon' | 'color' | 'icon' | 'slots' | 'slotProps'>, SwitchSlotsAndSlotProps {
10
71
  /**
11
72
  * The icon to display when the component is checked.
12
73
  */
@@ -14,6 +14,7 @@ import { styled } from "../zero-styled/index.js";
14
14
  import memoTheme from "../utils/memoTheme.js";
15
15
  import { useDefaultProps } from "../DefaultPropsProvider/index.js";
16
16
  import switchClasses, { getSwitchUtilityClass } from "./switchClasses.js";
17
+ import useSlot from "../utils/useSlot.js";
17
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
19
  const useUtilityClasses = ownerState => {
19
20
  const {
@@ -212,6 +213,8 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(inProps, ref) {
212
213
  edge = false,
213
214
  size = 'medium',
214
215
  sx,
216
+ slots = {},
217
+ slotProps = {},
215
218
  ...other
216
219
  } = props;
217
220
  const ownerState = {
@@ -221,14 +224,36 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(inProps, ref) {
221
224
  size
222
225
  };
223
226
  const classes = useUtilityClasses(ownerState);
224
- const icon = /*#__PURE__*/_jsx(SwitchThumb, {
227
+ const externalForwardedProps = {
228
+ slots,
229
+ slotProps
230
+ };
231
+ const [RootSlot, rootSlotProps] = useSlot('root', {
232
+ className: clsx(classes.root, className),
233
+ elementType: SwitchRoot,
234
+ externalForwardedProps,
235
+ ownerState,
236
+ additionalProps: {
237
+ sx
238
+ }
239
+ });
240
+ const [ThumbSlot, thumbSlotProps] = useSlot('thumb', {
225
241
  className: classes.thumb,
226
- ownerState: ownerState
242
+ elementType: SwitchThumb,
243
+ externalForwardedProps,
244
+ ownerState
227
245
  });
228
- return /*#__PURE__*/_jsxs(SwitchRoot, {
229
- className: clsx(classes.root, className),
230
- sx: sx,
231
- ownerState: ownerState,
246
+ const icon = /*#__PURE__*/_jsx(ThumbSlot, {
247
+ ...thumbSlotProps
248
+ });
249
+ const [TrackSlot, trackSlotProps] = useSlot('track', {
250
+ className: classes.track,
251
+ elementType: SwitchTrack,
252
+ externalForwardedProps,
253
+ ownerState
254
+ });
255
+ return /*#__PURE__*/_jsxs(RootSlot, {
256
+ ...rootSlotProps,
232
257
  children: [/*#__PURE__*/_jsx(SwitchSwitchBase, {
233
258
  type: "checkbox",
234
259
  icon: icon,
@@ -239,10 +264,25 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(inProps, ref) {
239
264
  classes: {
240
265
  ...classes,
241
266
  root: classes.switchBase
267
+ },
268
+ slots: {
269
+ ...(slots.switchBase && {
270
+ root: slots.switchBase
271
+ }),
272
+ ...(slots.input && {
273
+ input: slots.input
274
+ })
275
+ },
276
+ slotProps: {
277
+ ...(slotProps.switchBase && {
278
+ root: typeof slotProps.switchBase === 'function' ? slotProps.switchBase(ownerState) : slotProps.switchBase
279
+ }),
280
+ ...(slotProps.input && {
281
+ input: typeof slotProps.input === 'function' ? slotProps.input(ownerState) : slotProps.input
282
+ })
242
283
  }
243
- }), /*#__PURE__*/_jsx(SwitchTrack, {
244
- className: classes.track,
245
- ownerState: ownerState
284
+ }), /*#__PURE__*/_jsx(TrackSlot, {
285
+ ...trackSlotProps
246
286
  })]
247
287
  });
248
288
  });
@@ -332,6 +372,28 @@ process.env.NODE_ENV !== "production" ? Switch.propTypes /* remove-proptypes */
332
372
  * @default 'medium'
333
373
  */
334
374
  size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
375
+ /**
376
+ * The props used for each slot inside.
377
+ * @default {}
378
+ */
379
+ slotProps: PropTypes.shape({
380
+ input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
381
+ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
382
+ switchBase: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
383
+ thumb: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
384
+ track: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
385
+ }),
386
+ /**
387
+ * The components used for each slot inside.
388
+ * @default {}
389
+ */
390
+ slots: PropTypes.shape({
391
+ input: PropTypes.elementType,
392
+ root: PropTypes.elementType,
393
+ switchBase: PropTypes.elementType,
394
+ thumb: PropTypes.elementType,
395
+ track: PropTypes.elementType
396
+ }),
335
397
  /**
336
398
  * The system prop that allows defining system overrides as well as additional CSS styles.
337
399
  */
@@ -16,6 +16,11 @@ import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
16
16
  export interface TextFieldPropsColorOverrides {}
17
17
  export interface TextFieldPropsSizeOverrides {}
18
18
  export interface TextFieldSlots {
19
+ /**
20
+ * The component that renders the root.
21
+ * @default FormControl
22
+ */
23
+ root: React.ElementType;
19
24
  /**
20
25
  * The component that renders the input.
21
26
  * @default OutlinedInput
@@ -43,10 +48,35 @@ export interface TextFieldSlots {
43
48
  select: React.ElementType;
44
49
  }
45
50
  export type TextFieldSlotsAndSlotProps<InputPropsType> = CreateSlotsAndSlotProps<TextFieldSlots, {
51
+ /**
52
+ * Props forwarded to the root slot.
53
+ * By default, the avaible props are based on the [FormControl](https://mui.com/material-ui/api/form-control/#props) component.
54
+ */
55
+ root: SlotProps<React.ElementType<FormControlProps>, {}, TextFieldOwnerState>;
56
+ /**
57
+ * Props forwarded to the input slot.
58
+ * By default, the avaible props are based on the [Input](https://mui.com/material-ui/api/input/#props) component.
59
+ */
46
60
  input: SlotProps<React.ElementType<InputPropsType>, {}, TextFieldOwnerState>;
61
+ /**
62
+ * Props forwarded to the input label slot.
63
+ * By default, the avaible props are based on the [InputLabel](https://mui.com/material-ui/api/input-label/#props) component.
64
+ */
47
65
  inputLabel: SlotProps<React.ElementType<InputLabelProps>, {}, TextFieldOwnerState>;
66
+ /**
67
+ * Props forwarded to the html input slot.
68
+ * By default, the avaible props are based on the html input element.
69
+ */
48
70
  htmlInput: SlotProps<React.ElementType<InputBaseProps['inputProps']>, {}, TextFieldOwnerState>;
71
+ /**
72
+ * Props forwarded to the form helper text slot.
73
+ * By default, the avaible props are based on the [FormHelperText](https://mui.com/material-ui/api/form-helper-text/#props) component.
74
+ */
49
75
  formHelperText: SlotProps<React.ElementType<FormHelperTextProps>, {}, TextFieldOwnerState>;
76
+ /**
77
+ * Props forwarded to the select slot.
78
+ * By default, the avaible props are based on the [Select](https://mui.com/material-ui/api/select/#props) component.
79
+ */
50
80
  select: SlotProps<React.ElementType<SelectProps>, {}, TextFieldOwnerState>;
51
81
  }>;
52
82
  export interface BaseTextFieldProps extends StandardProps<FormControlProps,
@@ -160,6 +160,25 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
160
160
  }
161
161
  inputAdditionalProps['aria-describedby'] = undefined;
162
162
  }
163
+ const [RootSlot, rootProps] = useSlot('root', {
164
+ elementType: TextFieldRoot,
165
+ shouldForwardComponentProp: true,
166
+ externalForwardedProps: {
167
+ ...externalForwardedProps,
168
+ ...other
169
+ },
170
+ ownerState,
171
+ className: clsx(classes.root, className),
172
+ ref,
173
+ additionalProps: {
174
+ disabled,
175
+ error,
176
+ fullWidth,
177
+ required,
178
+ color,
179
+ variant
180
+ }
181
+ });
163
182
  const [InputSlot, inputProps] = useSlot('input', {
164
183
  elementType: InputComponent,
165
184
  externalForwardedProps,
@@ -211,17 +230,8 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
211
230
  },
212
231
  ...inputProps
213
232
  });
214
- return /*#__PURE__*/_jsxs(TextFieldRoot, {
215
- className: clsx(classes.root, className),
216
- disabled: disabled,
217
- error: error,
218
- fullWidth: fullWidth,
219
- ref: ref,
220
- required: required,
221
- color: color,
222
- variant: variant,
223
- ownerState: ownerState,
224
- ...other,
233
+ return /*#__PURE__*/_jsxs(RootSlot, {
234
+ ...rootProps,
225
235
  children: [label != null && label !== '' && /*#__PURE__*/_jsx(InputLabelSlot, {
226
236
  htmlFor: id,
227
237
  id: inputLabelId,
@@ -423,6 +433,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
423
433
  htmlInput: PropTypes.elementType,
424
434
  input: PropTypes.elementType,
425
435
  inputLabel: PropTypes.elementType,
436
+ root: PropTypes.elementType,
426
437
  select: PropTypes.elementType
427
438
  }),
428
439
  /**
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import PropTypes from 'prop-types';
5
- import { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';
5
+ import { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  function getStyleValue(value) {
8
8
  return parseInt(value, 10) || 0;
@@ -112,6 +112,15 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
112
112
  overflowing
113
113
  };
114
114
  }, [maxRows, minRows, props.placeholder]);
115
+ const didHeightChange = useEventCallback(() => {
116
+ const textarea = textareaRef.current;
117
+ const textareaStyles = calculateTextareaStyles();
118
+ if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
119
+ return false;
120
+ }
121
+ const outerHeightStyle = textareaStyles.outerHeightStyle;
122
+ return heightRef.current != null && heightRef.current !== outerHeightStyle;
123
+ });
115
124
  const syncHeight = React.useCallback(() => {
116
125
  const textarea = textareaRef.current;
117
126
  const textareaStyles = calculateTextareaStyles();
@@ -127,37 +136,39 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
127
136
  }, [calculateTextareaStyles]);
128
137
  const frameRef = React.useRef(-1);
129
138
  useEnhancedEffect(() => {
130
- const debounceHandleResize = debounce(() => syncHeight());
139
+ const debouncedHandleResize = debounce(syncHeight);
131
140
  const textarea = textareaRef?.current;
132
141
  if (!textarea) {
133
142
  return undefined;
134
143
  }
135
144
  const containerWindow = ownerWindow(textarea);
136
- containerWindow.addEventListener('resize', debounceHandleResize);
145
+ containerWindow.addEventListener('resize', debouncedHandleResize);
137
146
  let resizeObserver;
138
147
  if (typeof ResizeObserver !== 'undefined') {
139
148
  resizeObserver = new ResizeObserver(() => {
140
- // avoid "ResizeObserver loop completed with undelivered notifications" error
141
- // by temporarily unobserving the textarea element while manipulating the height
142
- // and reobserving one frame later
143
- resizeObserver.unobserve(textarea);
144
- cancelAnimationFrame(frameRef.current);
145
- syncHeight();
146
- frameRef.current = requestAnimationFrame(() => {
147
- resizeObserver.observe(textarea);
148
- });
149
+ if (didHeightChange()) {
150
+ // avoid "ResizeObserver loop completed with undelivered notifications" error
151
+ // by temporarily unobserving the textarea element while manipulating the height
152
+ // and reobserving one frame later
153
+ resizeObserver.unobserve(textarea);
154
+ cancelAnimationFrame(frameRef.current);
155
+ syncHeight();
156
+ frameRef.current = requestAnimationFrame(() => {
157
+ resizeObserver.observe(textarea);
158
+ });
159
+ }
149
160
  });
150
161
  resizeObserver.observe(textarea);
151
162
  }
152
163
  return () => {
153
- debounceHandleResize.clear();
164
+ debouncedHandleResize.clear();
154
165
  cancelAnimationFrame(frameRef.current);
155
- containerWindow.removeEventListener('resize', debounceHandleResize);
166
+ containerWindow.removeEventListener('resize', debouncedHandleResize);
156
167
  if (resizeObserver) {
157
168
  resizeObserver.disconnect();
158
169
  }
159
170
  };
160
- }, [calculateTextareaStyles, syncHeight]);
171
+ }, [calculateTextareaStyles, syncHeight, didHeightChange]);
161
172
  useEnhancedEffect(() => {
162
173
  syncHeight();
163
174
  });