@mui/material 5.16.14 → 5.17.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.
- package/CHANGELOG.md +21 -0
- package/TextareaAutosize/TextareaAutosize.js +66 -45
- package/index.js +1 -1
- package/legacy/TextareaAutosize/TextareaAutosize.js +66 -45
- package/legacy/index.js +1 -1
- package/legacy/styles/ThemeProvider.js +13 -1
- package/legacy/styles/createTheme.js +4 -1
- package/legacy/version/index.js +3 -3
- package/modern/TextareaAutosize/TextareaAutosize.js +66 -45
- package/modern/index.js +1 -1
- package/modern/styles/ThemeProvider.js +13 -1
- package/modern/styles/createTheme.js +4 -1
- package/modern/version/index.js +3 -3
- package/node/TextareaAutosize/TextareaAutosize.js +65 -44
- package/node/index.js +1 -1
- package/node/styles/ThemeProvider.js +13 -1
- package/node/styles/createTheme.js +4 -1
- package/node/version/index.js +3 -3
- package/package.json +5 -5
- package/styles/ThemeProvider.js +13 -1
- package/styles/createTheme.js +4 -1
- package/umd/material-ui.development.js +85 -43
- package/umd/material-ui.production.min.js +2 -2
- package/version/index.js +3 -3
|
@@ -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:
|
|
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
|
}
|
package/modern/version/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const version = "5.
|
|
1
|
+
export const version = "5.17.1";
|
|
2
2
|
export const major = Number("5");
|
|
3
|
-
export const minor = Number("
|
|
4
|
-
export const patch = Number("
|
|
3
|
+
export const minor = Number("17");
|
|
4
|
+
export const patch = Number("1");
|
|
5
5
|
export const preReleaseLabel = undefined || null;
|
|
6
6
|
export const preReleaseNumber = Number(undefined) || null;
|
|
7
7
|
export default version;
|
|
@@ -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
|
|
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
|
|
63
|
-
const handleRef = (0, _utils.unstable_useForkRef)(forwardedRef,
|
|
69
|
+
const textareaRef = React.useRef(null);
|
|
70
|
+
const handleRef = (0, _utils.unstable_useForkRef)(forwardedRef, textareaRef);
|
|
64
71
|
const heightRef = React.useRef(null);
|
|
65
|
-
const
|
|
72
|
+
const hiddenTextareaRef = React.useRef(null);
|
|
66
73
|
const calculateTextareaStyles = React.useCallback(() => {
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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 =
|
|
102
|
+
const innerHeight = hiddenTextarea.scrollHeight;
|
|
93
103
|
|
|
94
104
|
// Measure height of a textarea with a single row
|
|
95
|
-
|
|
96
|
-
const singleRowHeight =
|
|
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
|
-
|
|
144
|
+
textarea.style.height = `${outerHeightStyle}px`;
|
|
126
145
|
}
|
|
127
|
-
|
|
146
|
+
textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
|
|
128
147
|
}, [calculateTextareaStyles]);
|
|
148
|
+
const frameRef = React.useRef(-1);
|
|
129
149
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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(
|
|
151
|
-
|
|
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
|
-
|
|
155
|
-
cancelAnimationFrame(
|
|
156
|
-
containerWindow.removeEventListener('resize',
|
|
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:
|
|
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
|
@@ -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:
|
|
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
|
}
|
package/node/version/index.js
CHANGED
|
@@ -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.
|
|
7
|
+
const version = exports.version = "5.17.1";
|
|
8
8
|
const major = exports.major = Number("5");
|
|
9
|
-
const minor = exports.minor = Number("
|
|
10
|
-
const patch = exports.patch = Number("
|
|
9
|
+
const minor = exports.minor = Number("17");
|
|
10
|
+
const patch = exports.patch = Number("1");
|
|
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.
|
|
3
|
+
"version": "5.17.1",
|
|
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.
|
|
39
|
-
"@mui/
|
|
40
|
-
"@mui/
|
|
41
|
-
"@mui/
|
|
38
|
+
"@mui/core-downloads-tracker": "^5.17.1",
|
|
39
|
+
"@mui/system": "^5.17.1",
|
|
40
|
+
"@mui/types": "~7.2.15",
|
|
41
|
+
"@mui/utils": "^5.17.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@emotion/react": "^11.5.0",
|
package/styles/ThemeProvider.js
CHANGED
|
@@ -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:
|
|
31
|
+
theme: finalTheme
|
|
20
32
|
}));
|
|
21
33
|
}
|
|
22
34
|
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
|
package/styles/createTheme.js
CHANGED
|
@@ -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.
|
|
2
|
+
* @mui/material v5.17.1
|
|
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:
|
|
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
|
|
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
|
|
20306
|
-
var handleRef = useForkRef(forwardedRef,
|
|
20327
|
+
var textareaRef = React__namespace.useRef(null);
|
|
20328
|
+
var handleRef = useForkRef(forwardedRef, textareaRef);
|
|
20307
20329
|
var heightRef = React__namespace.useRef(null);
|
|
20308
|
-
var
|
|
20330
|
+
var hiddenTextareaRef = React__namespace.useRef(null);
|
|
20309
20331
|
var calculateTextareaStyles = React__namespace.useCallback(function () {
|
|
20310
|
-
var
|
|
20311
|
-
var
|
|
20312
|
-
|
|
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
|
-
|
|
20322
|
-
|
|
20323
|
-
|
|
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
|
-
|
|
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 =
|
|
20360
|
+
var innerHeight = hiddenTextarea.scrollHeight;
|
|
20336
20361
|
|
|
20337
20362
|
// Measure height of a textarea with a single row
|
|
20338
|
-
|
|
20339
|
-
var singleRowHeight =
|
|
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
|
-
|
|
20402
|
+
textarea.style.height = "".concat(outerHeightStyle, "px");
|
|
20369
20403
|
}
|
|
20370
|
-
|
|
20404
|
+
textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
|
|
20371
20405
|
}, [calculateTextareaStyles]);
|
|
20406
|
+
var frameRef = React__namespace.useRef(-1);
|
|
20372
20407
|
useEnhancedEffect$1(function () {
|
|
20373
|
-
var
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
|
|
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(
|
|
20388
|
-
|
|
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
|
-
|
|
20392
|
-
cancelAnimationFrame(
|
|
20393
|
-
containerWindow.removeEventListener('resize',
|
|
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:
|
|
20465
|
+
ref: hiddenTextareaRef,
|
|
20424
20466
|
tabIndex: -1,
|
|
20425
20467
|
style: _extends({}, styles$4.shadow, style, {
|
|
20426
20468
|
paddingTop: 0,
|