@mui/material 5.16.13 → 5.17.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.
@@ -33,8 +33,15 @@ const styles = {
33
33
  transform: 'translateZ(0)'
34
34
  }
35
35
  };
36
+ function isObjectEmpty(object) {
37
+ // eslint-disable-next-line
38
+ for (const _ in object) {
39
+ return false;
40
+ }
41
+ return true;
42
+ }
36
43
  function isEmpty(obj) {
37
- return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflowing;
44
+ return isObjectEmpty(obj) || obj.outerHeightStyle === 0 && !obj.overflowing;
38
45
  }
39
46
 
40
47
  /**
@@ -59,14 +66,18 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
59
66
  const {
60
67
  current: isControlled
61
68
  } = React.useRef(value != null);
62
- const inputRef = React.useRef(null);
63
- const handleRef = (0, _utils.unstable_useForkRef)(forwardedRef, inputRef);
69
+ const textareaRef = React.useRef(null);
70
+ const handleRef = (0, _utils.unstable_useForkRef)(forwardedRef, textareaRef);
64
71
  const heightRef = React.useRef(null);
65
- const shadowRef = React.useRef(null);
72
+ const hiddenTextareaRef = React.useRef(null);
66
73
  const calculateTextareaStyles = React.useCallback(() => {
67
- const input = inputRef.current;
68
- const containerWindow = (0, _utils.unstable_ownerWindow)(input);
69
- const computedStyle = containerWindow.getComputedStyle(input);
74
+ const textarea = textareaRef.current;
75
+ const hiddenTextarea = hiddenTextareaRef.current;
76
+ if (!textarea || !hiddenTextarea) {
77
+ return undefined;
78
+ }
79
+ const containerWindow = (0, _utils.unstable_ownerWindow)(textarea);
80
+ const computedStyle = containerWindow.getComputedStyle(textarea);
70
81
 
71
82
  // If input's width is shrunk and it's not visible, don't sync height.
72
83
  if (computedStyle.width === '0px') {
@@ -75,25 +86,24 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
75
86
  overflowing: false
76
87
  };
77
88
  }
78
- const inputShallow = shadowRef.current;
79
- inputShallow.style.width = computedStyle.width;
80
- inputShallow.value = input.value || props.placeholder || 'x';
81
- if (inputShallow.value.slice(-1) === '\n') {
89
+ hiddenTextarea.style.width = computedStyle.width;
90
+ hiddenTextarea.value = textarea.value || props.placeholder || 'x';
91
+ if (hiddenTextarea.value.slice(-1) === '\n') {
82
92
  // Certain fonts which overflow the line height will cause the textarea
83
93
  // to report a different scrollHeight depending on whether the last line
84
94
  // is empty. Make it non-empty to avoid this issue.
85
- inputShallow.value += ' ';
95
+ hiddenTextarea.value += ' ';
86
96
  }
87
97
  const boxSizing = computedStyle.boxSizing;
88
98
  const padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
89
99
  const border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
90
100
 
91
101
  // The height of the inner content
92
- const innerHeight = inputShallow.scrollHeight;
102
+ const innerHeight = hiddenTextarea.scrollHeight;
93
103
 
94
104
  // Measure height of a textarea with a single row
95
- inputShallow.value = 'x';
96
- const singleRowHeight = inputShallow.scrollHeight;
105
+ hiddenTextarea.value = 'x';
106
+ const singleRowHeight = hiddenTextarea.scrollHeight;
97
107
 
98
108
  // The height of the outer content
99
109
  let outerHeight = innerHeight;
@@ -113,52 +123,63 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
113
123
  overflowing
114
124
  };
115
125
  }, [maxRows, minRows, props.placeholder]);
126
+ const didHeightChange = (0, _utils.unstable_useEventCallback)(() => {
127
+ const textarea = textareaRef.current;
128
+ const textareaStyles = calculateTextareaStyles();
129
+ if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
130
+ return false;
131
+ }
132
+ const outerHeightStyle = textareaStyles.outerHeightStyle;
133
+ return heightRef.current != null && heightRef.current !== outerHeightStyle;
134
+ });
116
135
  const syncHeight = React.useCallback(() => {
136
+ const textarea = textareaRef.current;
117
137
  const textareaStyles = calculateTextareaStyles();
118
- if (isEmpty(textareaStyles)) {
138
+ if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
119
139
  return;
120
140
  }
121
141
  const outerHeightStyle = textareaStyles.outerHeightStyle;
122
- const input = inputRef.current;
123
142
  if (heightRef.current !== outerHeightStyle) {
124
143
  heightRef.current = outerHeightStyle;
125
- input.style.height = `${outerHeightStyle}px`;
144
+ textarea.style.height = `${outerHeightStyle}px`;
126
145
  }
127
- input.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
146
+ textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
128
147
  }, [calculateTextareaStyles]);
148
+ const frameRef = React.useRef(-1);
129
149
  (0, _utils.unstable_useEnhancedEffect)(() => {
130
- const handleResize = () => {
131
- syncHeight();
132
- };
133
- // Workaround a "ResizeObserver loop completed with undelivered notifications" error
134
- // in test.
135
- // Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38
136
- // Also see https://github.com/mui/mui-x/issues/8733
137
- let rAF;
138
- const rAFHandleResize = () => {
139
- cancelAnimationFrame(rAF);
140
- rAF = requestAnimationFrame(() => {
141
- handleResize();
142
- });
143
- };
144
- const debounceHandleResize = (0, _utils.unstable_debounce)(handleResize);
145
- const input = inputRef.current;
146
- const containerWindow = (0, _utils.unstable_ownerWindow)(input);
147
- containerWindow.addEventListener('resize', debounceHandleResize);
150
+ const debouncedHandleResize = (0, _utils.unstable_debounce)(syncHeight);
151
+ const textarea = textareaRef == null ? void 0 : textareaRef.current;
152
+ if (!textarea) {
153
+ return undefined;
154
+ }
155
+ const containerWindow = (0, _utils.unstable_ownerWindow)(textarea);
156
+ containerWindow.addEventListener('resize', debouncedHandleResize);
148
157
  let resizeObserver;
149
158
  if (typeof ResizeObserver !== 'undefined') {
150
- resizeObserver = new ResizeObserver(process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize);
151
- resizeObserver.observe(input);
159
+ resizeObserver = new ResizeObserver(() => {
160
+ if (didHeightChange()) {
161
+ // avoid "ResizeObserver loop completed with undelivered notifications" error
162
+ // by temporarily unobserving the textarea element while manipulating the height
163
+ // and reobserving one frame later
164
+ resizeObserver.unobserve(textarea);
165
+ cancelAnimationFrame(frameRef.current);
166
+ syncHeight();
167
+ frameRef.current = requestAnimationFrame(() => {
168
+ resizeObserver.observe(textarea);
169
+ });
170
+ }
171
+ });
172
+ resizeObserver.observe(textarea);
152
173
  }
153
174
  return () => {
154
- debounceHandleResize.clear();
155
- cancelAnimationFrame(rAF);
156
- containerWindow.removeEventListener('resize', debounceHandleResize);
175
+ debouncedHandleResize.clear();
176
+ cancelAnimationFrame(frameRef.current);
177
+ containerWindow.removeEventListener('resize', debouncedHandleResize);
157
178
  if (resizeObserver) {
158
179
  resizeObserver.disconnect();
159
180
  }
160
181
  };
161
- }, [calculateTextareaStyles, syncHeight]);
182
+ }, [calculateTextareaStyles, syncHeight, didHeightChange]);
162
183
  (0, _utils.unstable_useEnhancedEffect)(() => {
163
184
  syncHeight();
164
185
  });
@@ -183,7 +204,7 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
183
204
  "aria-hidden": true,
184
205
  className: props.className,
185
206
  readOnly: true,
186
- ref: shadowRef,
207
+ ref: hiddenTextareaRef,
187
208
  tabIndex: -1,
188
209
  style: (0, _extends2.default)({}, styles.shadow, style, {
189
210
  paddingTop: 0,
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.16.13
2
+ * @mui/material v5.17.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -22,9 +22,21 @@ function ThemeProvider(_ref) {
22
22
  } = _ref,
23
23
  props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
24
24
  const scopedTheme = themeInput[_identifier.default];
25
+ let finalTheme = scopedTheme || themeInput;
26
+ if (typeof themeInput !== 'function') {
27
+ if (scopedTheme && !scopedTheme.vars) {
28
+ finalTheme = (0, _extends2.default)({}, scopedTheme, {
29
+ vars: null
30
+ });
31
+ } else if (themeInput && !themeInput.vars) {
32
+ finalTheme = (0, _extends2.default)({}, themeInput, {
33
+ vars: null
34
+ });
35
+ }
36
+ }
25
37
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.ThemeProvider, (0, _extends2.default)({}, props, {
26
38
  themeId: scopedTheme ? _identifier.default : undefined,
27
- theme: scopedTheme || themeInput
39
+ theme: finalTheme
28
40
  }));
29
41
  }
30
42
  process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
@@ -30,7 +30,10 @@ function createTheme(options = {}, ...args) {
30
30
  typography: typographyInput = {}
31
31
  } = options,
32
32
  other = (0, _objectWithoutPropertiesLoose2.default)(options, _excluded);
33
- if (options.vars) {
33
+ if (options.vars &&
34
+ // The error should throw only for the root theme creation because user is not allowed to use a custom node `vars`.
35
+ // `generateCssVars` is the closest identifier for checking that the `options` is a result of `extendTheme` with CSS variables so that user can create new theme for nested ThemeProvider.
36
+ options.generateCssVars === undefined) {
34
37
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: \`vars\` is a private field used for CSS variables support.
35
38
  Please use another name.` : (0, _formatMuiErrorMessage2.default)(18));
36
39
  }
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = exports.preReleaseNumber = exports.preReleaseLabel = exports.patch = exports.minor = exports.major = exports.default = void 0;
7
- const version = exports.version = "5.16.13";
7
+ const version = exports.version = "5.17.0";
8
8
  const major = exports.major = Number("5");
9
- const minor = exports.minor = Number("16");
10
- const patch = exports.patch = Number("13");
9
+ const minor = exports.minor = Number("17");
10
+ const patch = exports.patch = Number("0");
11
11
  const preReleaseLabel = exports.preReleaseLabel = undefined || null;
12
12
  const preReleaseNumber = exports.preReleaseNumber = Number(undefined) || null;
13
13
  var _default = exports.default = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/material",
3
- "version": "5.16.13",
3
+ "version": "5.17.0",
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": "^5.16.13",
39
- "@mui/system": "^5.16.13",
40
- "@mui/utils": "^5.16.13",
41
- "@mui/types": "^7.2.15"
38
+ "@mui/core-downloads-tracker": "^5.17.0",
39
+ "@mui/types": "^7.2.15",
40
+ "@mui/system": "^5.16.14",
41
+ "@mui/utils": "^5.16.14"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@emotion/react": "^11.5.0",
@@ -14,9 +14,21 @@ export default function ThemeProvider(_ref) {
14
14
  } = _ref,
15
15
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
16
16
  const scopedTheme = themeInput[THEME_ID];
17
+ let finalTheme = scopedTheme || themeInput;
18
+ if (typeof themeInput !== 'function') {
19
+ if (scopedTheme && !scopedTheme.vars) {
20
+ finalTheme = _extends({}, scopedTheme, {
21
+ vars: null
22
+ });
23
+ } else if (themeInput && !themeInput.vars) {
24
+ finalTheme = _extends({}, themeInput, {
25
+ vars: null
26
+ });
27
+ }
28
+ }
17
29
  return /*#__PURE__*/_jsx(SystemThemeProvider, _extends({}, props, {
18
30
  themeId: scopedTheme ? THEME_ID : undefined,
19
- theme: scopedTheme || themeInput
31
+ theme: finalTheme
20
32
  }));
21
33
  }
22
34
  process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
@@ -20,7 +20,10 @@ function createTheme(options = {}, ...args) {
20
20
  typography: typographyInput = {}
21
21
  } = options,
22
22
  other = _objectWithoutPropertiesLoose(options, _excluded);
23
- if (options.vars) {
23
+ if (options.vars &&
24
+ // The error should throw only for the root theme creation because user is not allowed to use a custom node `vars`.
25
+ // `generateCssVars` is the closest identifier for checking that the `options` is a result of `extendTheme` with CSS variables so that user can create new theme for nested ThemeProvider.
26
+ options.generateCssVars === undefined) {
24
27
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: \`vars\` is a private field used for CSS variables support.
25
28
  Please use another name.` : _formatMuiErrorMessage(18));
26
29
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.16.13
2
+ * @mui/material v5.17.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -6613,13 +6613,13 @@
6613
6613
  return muiTheme;
6614
6614
  }
6615
6615
 
6616
- function isObjectEmpty(obj) {
6616
+ function isObjectEmpty$1(obj) {
6617
6617
  return Object.keys(obj).length === 0;
6618
6618
  }
6619
6619
  function useTheme$3() {
6620
6620
  var defaultTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
6621
6621
  var contextTheme = React__namespace.useContext(ThemeContext$2);
6622
- return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
6622
+ return !contextTheme || isObjectEmpty$1(contextTheme) ? defaultTheme : contextTheme;
6623
6623
  }
6624
6624
 
6625
6625
  var systemDefaultTheme$1 = createTheme$1();
@@ -11140,7 +11140,10 @@
11140
11140
  typographyInput = _options$typography === void 0 ? {} : _options$typography;
11141
11141
  options.shape;
11142
11142
  var other = _objectWithoutProperties(options, ["breakpoints", "mixins", "spacing", "palette", "transitions", "typography", "shape"]);
11143
- if (options.vars) {
11143
+ if (options.vars &&
11144
+ // The error should throw only for the root theme creation because user is not allowed to use a custom node `vars`.
11145
+ // `generateCssVars` is the closest identifier for checking that the `options` is a result of `extendTheme` with CSS variables so that user can create new theme for nested ThemeProvider.
11146
+ options.generateCssVars === undefined) {
11144
11147
  throw new Error("MUI: `vars` is a private field used for CSS variables support.\nPlease use another name." );
11145
11148
  }
11146
11149
  var palette = createPalette(paletteInput);
@@ -11459,9 +11462,21 @@
11459
11462
  var themeInput = _ref.theme,
11460
11463
  props = _objectWithoutProperties(_ref, ["theme"]);
11461
11464
  var scopedTheme = themeInput[THEME_ID];
11465
+ var finalTheme = scopedTheme || themeInput;
11466
+ if (typeof themeInput !== 'function') {
11467
+ if (scopedTheme && !scopedTheme.vars) {
11468
+ finalTheme = _extends({}, scopedTheme, {
11469
+ vars: null
11470
+ });
11471
+ } else if (themeInput && !themeInput.vars) {
11472
+ finalTheme = _extends({}, themeInput, {
11473
+ vars: null
11474
+ });
11475
+ }
11476
+ }
11462
11477
  return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$1, _extends({}, props, {
11463
11478
  themeId: scopedTheme ? THEME_ID : undefined,
11464
- theme: scopedTheme || themeInput
11479
+ theme: finalTheme
11465
11480
  }));
11466
11481
  }
11467
11482
  ThemeProvider.propTypes = {
@@ -20278,8 +20293,15 @@
20278
20293
  transform: 'translateZ(0)'
20279
20294
  }
20280
20295
  };
20296
+ function isObjectEmpty(object) {
20297
+ // eslint-disable-next-line
20298
+ for (var _ in object) {
20299
+ return false;
20300
+ }
20301
+ return true;
20302
+ }
20281
20303
  function isEmpty$1(obj) {
20282
- return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflowing;
20304
+ return isObjectEmpty(obj) || obj.outerHeightStyle === 0 && !obj.overflowing;
20283
20305
  }
20284
20306
 
20285
20307
  /**
@@ -20302,14 +20324,18 @@
20302
20324
  other = _objectWithoutProperties(props, ["onChange", "maxRows", "minRows", "style", "value"]);
20303
20325
  var _React$useRef = React__namespace.useRef(value != null),
20304
20326
  isControlled = _React$useRef.current;
20305
- var inputRef = React__namespace.useRef(null);
20306
- var handleRef = useForkRef(forwardedRef, inputRef);
20327
+ var textareaRef = React__namespace.useRef(null);
20328
+ var handleRef = useForkRef(forwardedRef, textareaRef);
20307
20329
  var heightRef = React__namespace.useRef(null);
20308
- var shadowRef = React__namespace.useRef(null);
20330
+ var hiddenTextareaRef = React__namespace.useRef(null);
20309
20331
  var calculateTextareaStyles = React__namespace.useCallback(function () {
20310
- var input = inputRef.current;
20311
- var containerWindow = ownerWindow(input);
20312
- var computedStyle = containerWindow.getComputedStyle(input);
20332
+ var textarea = textareaRef.current;
20333
+ var hiddenTextarea = hiddenTextareaRef.current;
20334
+ if (!textarea || !hiddenTextarea) {
20335
+ return undefined;
20336
+ }
20337
+ var containerWindow = ownerWindow(textarea);
20338
+ var computedStyle = containerWindow.getComputedStyle(textarea);
20313
20339
 
20314
20340
  // If input's width is shrunk and it's not visible, don't sync height.
20315
20341
  if (computedStyle.width === '0px') {
@@ -20318,25 +20344,24 @@
20318
20344
  overflowing: false
20319
20345
  };
20320
20346
  }
20321
- var inputShallow = shadowRef.current;
20322
- inputShallow.style.width = computedStyle.width;
20323
- inputShallow.value = input.value || props.placeholder || 'x';
20324
- if (inputShallow.value.slice(-1) === '\n') {
20347
+ hiddenTextarea.style.width = computedStyle.width;
20348
+ hiddenTextarea.value = textarea.value || props.placeholder || 'x';
20349
+ if (hiddenTextarea.value.slice(-1) === '\n') {
20325
20350
  // Certain fonts which overflow the line height will cause the textarea
20326
20351
  // to report a different scrollHeight depending on whether the last line
20327
20352
  // is empty. Make it non-empty to avoid this issue.
20328
- inputShallow.value += ' ';
20353
+ hiddenTextarea.value += ' ';
20329
20354
  }
20330
20355
  var boxSizing = computedStyle.boxSizing;
20331
20356
  var padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
20332
20357
  var border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
20333
20358
 
20334
20359
  // The height of the inner content
20335
- var innerHeight = inputShallow.scrollHeight;
20360
+ var innerHeight = hiddenTextarea.scrollHeight;
20336
20361
 
20337
20362
  // Measure height of a textarea with a single row
20338
- inputShallow.value = 'x';
20339
- var singleRowHeight = inputShallow.scrollHeight;
20363
+ hiddenTextarea.value = 'x';
20364
+ var singleRowHeight = hiddenTextarea.scrollHeight;
20340
20365
 
20341
20366
  // The height of the outer content
20342
20367
  var outerHeight = innerHeight;
@@ -20356,46 +20381,63 @@
20356
20381
  overflowing: overflowing
20357
20382
  };
20358
20383
  }, [maxRows, minRows, props.placeholder]);
20384
+ var didHeightChange = useEventCallback(function () {
20385
+ var textarea = textareaRef.current;
20386
+ var textareaStyles = calculateTextareaStyles();
20387
+ if (!textarea || !textareaStyles || isEmpty$1(textareaStyles)) {
20388
+ return false;
20389
+ }
20390
+ var outerHeightStyle = textareaStyles.outerHeightStyle;
20391
+ return heightRef.current != null && heightRef.current !== outerHeightStyle;
20392
+ });
20359
20393
  var syncHeight = React__namespace.useCallback(function () {
20394
+ var textarea = textareaRef.current;
20360
20395
  var textareaStyles = calculateTextareaStyles();
20361
- if (isEmpty$1(textareaStyles)) {
20396
+ if (!textarea || !textareaStyles || isEmpty$1(textareaStyles)) {
20362
20397
  return;
20363
20398
  }
20364
20399
  var outerHeightStyle = textareaStyles.outerHeightStyle;
20365
- var input = inputRef.current;
20366
20400
  if (heightRef.current !== outerHeightStyle) {
20367
20401
  heightRef.current = outerHeightStyle;
20368
- input.style.height = "".concat(outerHeightStyle, "px");
20402
+ textarea.style.height = "".concat(outerHeightStyle, "px");
20369
20403
  }
20370
- input.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
20404
+ textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
20371
20405
  }, [calculateTextareaStyles]);
20406
+ var frameRef = React__namespace.useRef(-1);
20372
20407
  useEnhancedEffect$1(function () {
20373
- var handleResize = function handleResize() {
20374
- syncHeight();
20375
- };
20376
- // Workaround a "ResizeObserver loop completed with undelivered notifications" error
20377
- // in test.
20378
- // Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38
20379
- // Also see https://github.com/mui/mui-x/issues/8733
20380
- var rAF;
20381
- var debounceHandleResize = debounce$1(handleResize);
20382
- var input = inputRef.current;
20383
- var containerWindow = ownerWindow(input);
20384
- containerWindow.addEventListener('resize', debounceHandleResize);
20408
+ var debouncedHandleResize = debounce$1(syncHeight);
20409
+ var textarea = textareaRef == null ? void 0 : textareaRef.current;
20410
+ if (!textarea) {
20411
+ return undefined;
20412
+ }
20413
+ var containerWindow = ownerWindow(textarea);
20414
+ containerWindow.addEventListener('resize', debouncedHandleResize);
20385
20415
  var resizeObserver;
20386
20416
  if (typeof ResizeObserver !== 'undefined') {
20387
- resizeObserver = new ResizeObserver(handleResize);
20388
- resizeObserver.observe(input);
20417
+ resizeObserver = new ResizeObserver(function () {
20418
+ if (didHeightChange()) {
20419
+ // avoid "ResizeObserver loop completed with undelivered notifications" error
20420
+ // by temporarily unobserving the textarea element while manipulating the height
20421
+ // and reobserving one frame later
20422
+ resizeObserver.unobserve(textarea);
20423
+ cancelAnimationFrame(frameRef.current);
20424
+ syncHeight();
20425
+ frameRef.current = requestAnimationFrame(function () {
20426
+ resizeObserver.observe(textarea);
20427
+ });
20428
+ }
20429
+ });
20430
+ resizeObserver.observe(textarea);
20389
20431
  }
20390
20432
  return function () {
20391
- debounceHandleResize.clear();
20392
- cancelAnimationFrame(rAF);
20393
- containerWindow.removeEventListener('resize', debounceHandleResize);
20433
+ debouncedHandleResize.clear();
20434
+ cancelAnimationFrame(frameRef.current);
20435
+ containerWindow.removeEventListener('resize', debouncedHandleResize);
20394
20436
  if (resizeObserver) {
20395
20437
  resizeObserver.disconnect();
20396
20438
  }
20397
20439
  };
20398
- }, [calculateTextareaStyles, syncHeight]);
20440
+ }, [calculateTextareaStyles, syncHeight, didHeightChange]);
20399
20441
  useEnhancedEffect$1(function () {
20400
20442
  syncHeight();
20401
20443
  });
@@ -20420,7 +20462,7 @@
20420
20462
  "aria-hidden": true,
20421
20463
  className: props.className,
20422
20464
  readOnly: true,
20423
- ref: shadowRef,
20465
+ ref: hiddenTextareaRef,
20424
20466
  tabIndex: -1,
20425
20467
  style: _extends({}, styles$4.shadow, style, {
20426
20468
  paddingTop: 0,
@@ -21818,67 +21860,6 @@
21818
21860
  var paperSlotProps = (_slotProps$paper = slotProps.paper) != null ? _slotProps$paper : componentsProps.paper;
21819
21861
  var popperSlotProps = (_slotProps$popper = slotProps.popper) != null ? _slotProps$popper : componentsProps.popper;
21820
21862
  var popupIndicatorSlotProps = (_slotProps$popupIndic = slotProps.popupIndicator) != null ? _slotProps$popupIndic : componentsProps.popupIndicator;
21821
- var renderAutocompletePopperChildren = function renderAutocompletePopperChildren(children) {
21822
- return /*#__PURE__*/jsxRuntimeExports.jsx(AutocompletePopper, _extends({
21823
- as: PopperComponent,
21824
- disablePortal: disablePortal,
21825
- style: {
21826
- width: anchorEl ? anchorEl.clientWidth : null
21827
- },
21828
- ownerState: ownerState,
21829
- role: "presentation",
21830
- anchorEl: anchorEl,
21831
- open: popupOpen
21832
- }, popperSlotProps, {
21833
- className: clsx(classes.popper, popperSlotProps == null ? void 0 : popperSlotProps.className),
21834
- children: /*#__PURE__*/jsxRuntimeExports.jsx(AutocompletePaper, _extends({
21835
- ownerState: ownerState,
21836
- as: PaperComponent
21837
- }, paperSlotProps, {
21838
- className: clsx(classes.paper, paperSlotProps == null ? void 0 : paperSlotProps.className),
21839
- children: children
21840
- }))
21841
- }));
21842
- };
21843
- var autocompletePopper = null;
21844
- if (groupedOptions.length > 0) {
21845
- autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteListbox, _extends({
21846
- as: ListboxComponent,
21847
- className: classes.listbox,
21848
- ownerState: ownerState
21849
- }, otherListboxProps, ListboxProps, {
21850
- ref: combinedListboxRef,
21851
- children: groupedOptions.map(function (option, index) {
21852
- if (groupBy) {
21853
- return renderGroup({
21854
- key: option.key,
21855
- group: option.group,
21856
- children: option.options.map(function (option2, index2) {
21857
- return renderListOption(option2, option.index + index2);
21858
- })
21859
- });
21860
- }
21861
- return renderListOption(option, index);
21862
- })
21863
- })));
21864
- } else if (loading && groupedOptions.length === 0) {
21865
- autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteLoading, {
21866
- className: classes.loading,
21867
- ownerState: ownerState,
21868
- children: loadingText
21869
- }));
21870
- } else if (groupedOptions.length === 0 && !freeSolo && !loading) {
21871
- autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteNoOptions, {
21872
- className: classes.noOptions,
21873
- ownerState: ownerState,
21874
- role: "presentation",
21875
- onMouseDown: function onMouseDown(event) {
21876
- // Prevent input blur when interacting with the "no options" content
21877
- event.preventDefault();
21878
- },
21879
- children: noOptionsText
21880
- }));
21881
- }
21882
21863
  return /*#__PURE__*/jsxRuntimeExports.jsxs(React__namespace.Fragment, {
21883
21864
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteRoot, _extends({
21884
21865
  ref: ref,
@@ -21928,7 +21909,57 @@
21928
21909
  readOnly: readOnly
21929
21910
  }, getInputProps())
21930
21911
  })
21931
- })), anchorEl ? autocompletePopper : null]
21912
+ })), anchorEl ? /*#__PURE__*/jsxRuntimeExports.jsx(AutocompletePopper, _extends({
21913
+ as: PopperComponent,
21914
+ disablePortal: disablePortal,
21915
+ style: {
21916
+ width: anchorEl ? anchorEl.clientWidth : null
21917
+ },
21918
+ ownerState: ownerState,
21919
+ role: "presentation",
21920
+ anchorEl: anchorEl,
21921
+ open: popupOpen
21922
+ }, popperSlotProps, {
21923
+ className: clsx(classes.popper, popperSlotProps == null ? void 0 : popperSlotProps.className),
21924
+ children: /*#__PURE__*/jsxRuntimeExports.jsxs(AutocompletePaper, _extends({
21925
+ ownerState: ownerState,
21926
+ as: PaperComponent
21927
+ }, paperSlotProps, {
21928
+ className: clsx(classes.paper, paperSlotProps == null ? void 0 : paperSlotProps.className),
21929
+ children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteLoading, {
21930
+ className: classes.loading,
21931
+ ownerState: ownerState,
21932
+ children: loadingText
21933
+ }) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteNoOptions, {
21934
+ className: classes.noOptions,
21935
+ ownerState: ownerState,
21936
+ role: "presentation",
21937
+ onMouseDown: function onMouseDown(event) {
21938
+ // Prevent input blur when interacting with the "no options" content
21939
+ event.preventDefault();
21940
+ },
21941
+ children: noOptionsText
21942
+ }) : null, groupedOptions.length > 0 ? /*#__PURE__*/jsxRuntimeExports.jsx(AutocompleteListbox, _extends({
21943
+ as: ListboxComponent,
21944
+ className: classes.listbox,
21945
+ ownerState: ownerState
21946
+ }, otherListboxProps, ListboxProps, {
21947
+ ref: combinedListboxRef,
21948
+ children: groupedOptions.map(function (option, index) {
21949
+ if (groupBy) {
21950
+ return renderGroup({
21951
+ key: option.key,
21952
+ group: option.group,
21953
+ children: option.options.map(function (option2, index2) {
21954
+ return renderListOption(option2, option.index + index2);
21955
+ })
21956
+ });
21957
+ }
21958
+ return renderListOption(option, index);
21959
+ })
21960
+ })) : null]
21961
+ }))
21962
+ })) : null]
21932
21963
  });
21933
21964
  });
21934
21965
  Autocomplete.propTypes /* remove-proptypes */ = {