@mui/material 6.4.0 → 6.4.2

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 (99) hide show
  1. package/AppBar/AppBar.d.ts +1 -1
  2. package/ButtonBase/ButtonBase.d.ts +2 -0
  3. package/ButtonGroup/ButtonGroupButtonContext.js +2 -0
  4. package/ButtonGroup/ButtonGroupContext.js +2 -0
  5. package/CHANGELOG.md +69 -0
  6. package/Card/Card.d.ts +1 -1
  7. package/Dialog/Dialog.d.ts +85 -1
  8. package/Dialog/Dialog.js +91 -20
  9. package/Dialog/DialogContext.js +2 -0
  10. package/Drawer/Drawer.js +1 -1
  11. package/Drawer/drawerClasses.d.ts +32 -8
  12. package/Drawer/drawerClasses.js +1 -1
  13. package/FormControl/FormControl.js +9 -7
  14. package/FormControl/FormControlContext.js +2 -0
  15. package/Hidden/withWidth.js +2 -0
  16. package/IconButton/IconButton.d.ts +3 -2
  17. package/IconButton/IconButton.js +18 -7
  18. package/IconButton/iconButtonClasses.d.ts +2 -0
  19. package/IconButton/iconButtonClasses.js +1 -1
  20. package/OverridableComponent/index.d.ts +41 -0
  21. package/OverridableComponent/index.js +1 -0
  22. package/OverridableComponent/package.json +6 -0
  23. package/PaginationItem/PaginationItem.d.ts +1 -1
  24. package/RadioGroup/RadioGroupContext.js +2 -0
  25. package/Slider/useSlider.js +2 -2
  26. package/Step/StepContext.js +2 -0
  27. package/Stepper/StepperContext.js +2 -0
  28. package/Table/Tablelvl2Context.js +2 -0
  29. package/TextareaAutosize/TextareaAutosize.js +50 -40
  30. package/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +2 -0
  31. package/ToggleButtonGroup/ToggleButtonGroupContext.js +2 -0
  32. package/index.js +1 -1
  33. package/modern/ButtonGroup/ButtonGroupButtonContext.js +2 -0
  34. package/modern/ButtonGroup/ButtonGroupContext.js +2 -0
  35. package/modern/Dialog/Dialog.js +91 -20
  36. package/modern/Dialog/DialogContext.js +2 -0
  37. package/modern/Drawer/Drawer.js +1 -1
  38. package/modern/Drawer/drawerClasses.js +1 -1
  39. package/modern/FormControl/FormControl.js +9 -7
  40. package/modern/FormControl/FormControlContext.js +2 -0
  41. package/modern/Hidden/withWidth.js +2 -0
  42. package/modern/IconButton/IconButton.js +18 -7
  43. package/modern/IconButton/iconButtonClasses.js +1 -1
  44. package/modern/OverridableComponent/index.js +1 -0
  45. package/modern/RadioGroup/RadioGroupContext.js +2 -0
  46. package/modern/Slider/useSlider.js +2 -2
  47. package/modern/Step/StepContext.js +2 -0
  48. package/modern/Stepper/StepperContext.js +2 -0
  49. package/modern/Table/Tablelvl2Context.js +2 -0
  50. package/modern/TextareaAutosize/TextareaAutosize.js +50 -40
  51. package/modern/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +2 -0
  52. package/modern/ToggleButtonGroup/ToggleButtonGroupContext.js +2 -0
  53. package/modern/index.js +1 -1
  54. package/modern/styles/components.js +1 -0
  55. package/modern/styles/overrides.js +1 -0
  56. package/modern/styles/props.js +1 -0
  57. package/modern/styles/variants.js +1 -0
  58. package/modern/useAutocomplete/useAutocomplete.js +13 -10
  59. package/modern/version/index.js +2 -2
  60. package/node/ButtonGroup/ButtonGroupButtonContext.js +1 -0
  61. package/node/ButtonGroup/ButtonGroupContext.js +1 -0
  62. package/node/Dialog/Dialog.js +91 -20
  63. package/node/Dialog/DialogContext.js +1 -0
  64. package/node/Drawer/Drawer.js +1 -1
  65. package/node/Drawer/drawerClasses.js +1 -1
  66. package/node/FormControl/FormControl.js +9 -7
  67. package/node/FormControl/FormControlContext.js +1 -0
  68. package/node/Hidden/withWidth.js +1 -0
  69. package/node/IconButton/IconButton.js +18 -7
  70. package/node/IconButton/iconButtonClasses.js +1 -1
  71. package/node/OverridableComponent/index.js +5 -0
  72. package/node/RadioGroup/RadioGroupContext.js +1 -0
  73. package/node/Slider/useSlider.js +2 -2
  74. package/node/Step/StepContext.js +1 -0
  75. package/node/Stepper/StepperContext.js +1 -0
  76. package/node/Table/Tablelvl2Context.js +1 -0
  77. package/node/TextareaAutosize/TextareaAutosize.js +50 -40
  78. package/node/ToggleButtonGroup/ToggleButtonGroupButtonContext.js +1 -0
  79. package/node/ToggleButtonGroup/ToggleButtonGroupContext.js +1 -0
  80. package/node/index.js +1 -1
  81. package/node/styles/components.js +5 -0
  82. package/node/styles/overrides.js +5 -0
  83. package/node/styles/props.js +5 -0
  84. package/node/styles/variants.js +5 -0
  85. package/node/useAutocomplete/useAutocomplete.js +13 -10
  86. package/node/version/index.js +2 -2
  87. package/package.json +5 -5
  88. package/styles/components.d.ts +590 -591
  89. package/styles/components.js +1 -0
  90. package/styles/createThemeNoVars.d.ts +1 -1
  91. package/styles/overrides.d.ts +123 -142
  92. package/styles/overrides.js +1 -0
  93. package/styles/props.d.ts +120 -122
  94. package/styles/props.js +1 -0
  95. package/styles/variants.d.ts +7 -10
  96. package/styles/variants.js +1 -0
  97. package/useAutocomplete/useAutocomplete.js +13 -10
  98. package/version/index.js +2 -2
  99. package/OverridableComponent.d.ts +0 -67
@@ -29,8 +29,15 @@ const styles = {
29
29
  transform: 'translateZ(0)'
30
30
  }
31
31
  };
32
+ function isObjectEmpty(object) {
33
+ // eslint-disable-next-line
34
+ for (const _ in object) {
35
+ return false;
36
+ }
37
+ return true;
38
+ }
32
39
  function isEmpty(obj) {
33
- return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflowing;
40
+ return isObjectEmpty(obj) || obj.outerHeightStyle === 0 && !obj.overflowing;
34
41
  }
35
42
 
36
43
  /**
@@ -55,14 +62,18 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
55
62
  const {
56
63
  current: isControlled
57
64
  } = React.useRef(value != null);
58
- const inputRef = React.useRef(null);
59
- const handleRef = (0, _utils.unstable_useForkRef)(forwardedRef, inputRef);
65
+ const textareaRef = React.useRef(null);
66
+ const handleRef = (0, _utils.unstable_useForkRef)(forwardedRef, textareaRef);
60
67
  const heightRef = React.useRef(null);
61
- const shadowRef = React.useRef(null);
68
+ const hiddenTextareaRef = React.useRef(null);
62
69
  const calculateTextareaStyles = React.useCallback(() => {
63
- const input = inputRef.current;
64
- const containerWindow = (0, _utils.unstable_ownerWindow)(input);
65
- const computedStyle = containerWindow.getComputedStyle(input);
70
+ const textarea = textareaRef.current;
71
+ const hiddenTextarea = hiddenTextareaRef.current;
72
+ if (!textarea || !hiddenTextarea) {
73
+ return undefined;
74
+ }
75
+ const containerWindow = (0, _utils.unstable_ownerWindow)(textarea);
76
+ const computedStyle = containerWindow.getComputedStyle(textarea);
66
77
 
67
78
  // If input's width is shrunk and it's not visible, don't sync height.
68
79
  if (computedStyle.width === '0px') {
@@ -71,25 +82,24 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
71
82
  overflowing: false
72
83
  };
73
84
  }
74
- const inputShallow = shadowRef.current;
75
- inputShallow.style.width = computedStyle.width;
76
- inputShallow.value = input.value || props.placeholder || 'x';
77
- if (inputShallow.value.slice(-1) === '\n') {
85
+ hiddenTextarea.style.width = computedStyle.width;
86
+ hiddenTextarea.value = textarea.value || props.placeholder || 'x';
87
+ if (hiddenTextarea.value.slice(-1) === '\n') {
78
88
  // Certain fonts which overflow the line height will cause the textarea
79
89
  // to report a different scrollHeight depending on whether the last line
80
90
  // is empty. Make it non-empty to avoid this issue.
81
- inputShallow.value += ' ';
91
+ hiddenTextarea.value += ' ';
82
92
  }
83
93
  const boxSizing = computedStyle.boxSizing;
84
94
  const padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
85
95
  const border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
86
96
 
87
97
  // The height of the inner content
88
- const innerHeight = inputShallow.scrollHeight;
98
+ const innerHeight = hiddenTextarea.scrollHeight;
89
99
 
90
100
  // Measure height of a textarea with a single row
91
- inputShallow.value = 'x';
92
- const singleRowHeight = inputShallow.scrollHeight;
101
+ hiddenTextarea.value = 'x';
102
+ const singleRowHeight = hiddenTextarea.scrollHeight;
93
103
 
94
104
  // The height of the outer content
95
105
  let outerHeight = innerHeight;
@@ -110,45 +120,45 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
110
120
  };
111
121
  }, [maxRows, minRows, props.placeholder]);
112
122
  const syncHeight = React.useCallback(() => {
123
+ const textarea = textareaRef.current;
113
124
  const textareaStyles = calculateTextareaStyles();
114
- if (isEmpty(textareaStyles)) {
125
+ if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
115
126
  return;
116
127
  }
117
128
  const outerHeightStyle = textareaStyles.outerHeightStyle;
118
- const input = inputRef.current;
119
129
  if (heightRef.current !== outerHeightStyle) {
120
130
  heightRef.current = outerHeightStyle;
121
- input.style.height = `${outerHeightStyle}px`;
131
+ textarea.style.height = `${outerHeightStyle}px`;
122
132
  }
123
- input.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
133
+ textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
124
134
  }, [calculateTextareaStyles]);
135
+ const frameRef = React.useRef(-1);
125
136
  (0, _utils.unstable_useEnhancedEffect)(() => {
126
- const handleResize = () => {
127
- syncHeight();
128
- };
129
- // Workaround a "ResizeObserver loop completed with undelivered notifications" error
130
- // in test.
131
- // Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38
132
- // Also see https://github.com/mui/mui-x/issues/8733
133
- let rAF;
134
- const rAFHandleResize = () => {
135
- cancelAnimationFrame(rAF);
136
- rAF = requestAnimationFrame(() => {
137
- handleResize();
138
- });
139
- };
140
- const debounceHandleResize = (0, _utils.unstable_debounce)(handleResize);
141
- const input = inputRef.current;
142
- const containerWindow = (0, _utils.unstable_ownerWindow)(input);
137
+ const debounceHandleResize = (0, _utils.unstable_debounce)(() => syncHeight());
138
+ const textarea = textareaRef?.current;
139
+ if (!textarea) {
140
+ return undefined;
141
+ }
142
+ const containerWindow = (0, _utils.unstable_ownerWindow)(textarea);
143
143
  containerWindow.addEventListener('resize', debounceHandleResize);
144
144
  let resizeObserver;
145
145
  if (typeof ResizeObserver !== 'undefined') {
146
- resizeObserver = new ResizeObserver(process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize);
147
- resizeObserver.observe(input);
146
+ resizeObserver = new ResizeObserver(() => {
147
+ // avoid "ResizeObserver loop completed with undelivered notifications" error
148
+ // by temporarily unobserving the textarea element while manipulating the height
149
+ // and reobserving one frame later
150
+ resizeObserver.unobserve(textarea);
151
+ cancelAnimationFrame(frameRef.current);
152
+ syncHeight();
153
+ frameRef.current = requestAnimationFrame(() => {
154
+ resizeObserver.observe(textarea);
155
+ });
156
+ });
157
+ resizeObserver.observe(textarea);
148
158
  }
149
159
  return () => {
150
160
  debounceHandleResize.clear();
151
- cancelAnimationFrame(rAF);
161
+ cancelAnimationFrame(frameRef.current);
152
162
  containerWindow.removeEventListener('resize', debounceHandleResize);
153
163
  if (resizeObserver) {
154
164
  resizeObserver.disconnect();
@@ -180,7 +190,7 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
180
190
  "aria-hidden": true,
181
191
  className: props.className,
182
192
  readOnly: true,
183
- ref: shadowRef,
193
+ ref: hiddenTextareaRef,
184
194
  tabIndex: -1,
185
195
  style: {
186
196
  ...styles.shadow,
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v6.4.0
2
+ * @mui/material v6.4.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -53,6 +53,13 @@ const defaultFilterOptions = createFilterOptions();
53
53
  const pageSize = 5;
54
54
  const defaultIsActiveElementInListbox = listboxRef => listboxRef.current !== null && listboxRef.current.parentElement?.contains(document.activeElement);
55
55
  const MULTIPLE_DEFAULT_VALUE = [];
56
+ function getInputValue(value, multiple, getOptionLabel) {
57
+ if (multiple || value == null) {
58
+ return '';
59
+ }
60
+ const optionLabel = getOptionLabel(value);
61
+ return typeof optionLabel === 'string' ? optionLabel : '';
62
+ }
56
63
  function useAutocomplete(props) {
57
64
  const {
58
65
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -118,6 +125,10 @@ function useAutocomplete(props) {
118
125
  const [focusedTag, setFocusedTag] = React.useState(-1);
119
126
  const defaultHighlighted = autoHighlight ? 0 : -1;
120
127
  const highlightedIndexRef = React.useRef(defaultHighlighted);
128
+
129
+ // Calculate the initial inputValue on mount only.
130
+ // Using useRef since defaultValue doesn't need to update inputValue dynamically.
131
+ const initialInputValue = React.useRef(getInputValue(defaultValue, multiple, getOptionLabel)).current;
121
132
  const [value, setValueState] = (0, _utils.unstable_useControlled)({
122
133
  controlled: valueProp,
123
134
  default: defaultValue,
@@ -125,7 +136,7 @@ function useAutocomplete(props) {
125
136
  });
126
137
  const [inputValue, setInputValueState] = (0, _utils.unstable_useControlled)({
127
138
  controlled: inputValueProp,
128
- default: '',
139
+ default: initialInputValue,
129
140
  name: componentName,
130
141
  state: 'inputValue'
131
142
  });
@@ -137,15 +148,7 @@ function useAutocomplete(props) {
137
148
  if (!isOptionSelected && !clearOnBlur) {
138
149
  return;
139
150
  }
140
- let newInputValue;
141
- if (multiple) {
142
- newInputValue = '';
143
- } else if (newValue == null) {
144
- newInputValue = '';
145
- } else {
146
- const optionLabel = getOptionLabel(newValue);
147
- newInputValue = typeof optionLabel === 'string' ? optionLabel : '';
148
- }
151
+ const newInputValue = getInputValue(newValue, multiple, getOptionLabel);
149
152
  if (inputValue === newInputValue) {
150
153
  return;
151
154
  }
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = exports.prerelease = exports.patch = exports.minor = exports.major = exports.default = void 0;
7
- const version = exports.version = "6.4.0";
7
+ const version = exports.version = "6.4.2";
8
8
  const major = exports.major = Number("6");
9
9
  const minor = exports.minor = Number("4");
10
- const patch = exports.patch = Number("0");
10
+ const patch = exports.patch = Number("2");
11
11
  const prerelease = exports.prerelease = undefined;
12
12
  var _default = exports.default = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/material",
3
- "version": "6.4.0",
3
+ "version": "6.4.2",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Material UI is an open-source React component library that implements Google's Material Design. It's comprehensive and can be used in production out of the box.",
@@ -35,10 +35,10 @@
35
35
  "prop-types": "^15.8.1",
36
36
  "react-is": "^19.0.0",
37
37
  "react-transition-group": "^4.4.5",
38
- "@mui/core-downloads-tracker": "^6.4.0",
39
- "@mui/utils": "^6.4.0",
38
+ "@mui/core-downloads-tracker": "^6.4.2",
39
+ "@mui/system": "^6.4.2",
40
40
  "@mui/types": "^7.2.21",
41
- "@mui/system": "^6.4.0"
41
+ "@mui/utils": "^6.4.2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@emotion/react": "^11.5.0",
@@ -46,7 +46,7 @@
46
46
  "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
47
47
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
48
48
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
49
- "@mui/material-pigment-css": "^6.4.0"
49
+ "@mui/material-pigment-css": "^6.4.2"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@types/react": {