@mui/material 6.4.1 → 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.
- package/AppBar/AppBar.d.ts +1 -1
- package/CHANGELOG.md +27 -0
- package/Card/Card.d.ts +1 -1
- package/OverridableComponent/index.d.ts +41 -0
- package/OverridableComponent/index.js +1 -0
- package/OverridableComponent/package.json +6 -0
- package/PaginationItem/PaginationItem.d.ts +1 -1
- package/Slider/useSlider.js +2 -2
- package/TextareaAutosize/TextareaAutosize.js +50 -40
- package/index.js +1 -1
- package/modern/OverridableComponent/index.js +1 -0
- package/modern/Slider/useSlider.js +2 -2
- package/modern/TextareaAutosize/TextareaAutosize.js +50 -40
- package/modern/index.js +1 -1
- package/modern/styles/components.js +1 -0
- package/modern/styles/overrides.js +1 -0
- package/modern/styles/props.js +1 -0
- package/modern/styles/variants.js +1 -0
- package/modern/useAutocomplete/useAutocomplete.js +13 -10
- package/modern/version/index.js +2 -2
- package/node/OverridableComponent/index.js +5 -0
- package/node/Slider/useSlider.js +2 -2
- package/node/TextareaAutosize/TextareaAutosize.js +50 -40
- package/node/index.js +1 -1
- package/node/styles/components.js +5 -0
- package/node/styles/overrides.js +5 -0
- package/node/styles/props.js +5 -0
- package/node/styles/variants.js +5 -0
- package/node/useAutocomplete/useAutocomplete.js +13 -10
- package/node/version/index.js +2 -2
- package/package.json +5 -5
- package/styles/components.d.ts +590 -591
- package/styles/components.js +1 -0
- package/styles/createThemeNoVars.d.ts +1 -1
- package/styles/overrides.d.ts +123 -142
- package/styles/overrides.js +1 -0
- package/styles/props.d.ts +120 -122
- package/styles/props.js +1 -0
- package/styles/variants.d.ts +7 -10
- package/styles/variants.js +1 -0
- package/useAutocomplete/useAutocomplete.js +13 -10
- package/version/index.js +2 -2
- package/OverridableComponent.d.ts +0 -67
package/AppBar/AppBar.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps } from '@mui/system';
|
|
3
3
|
import { OverridableStringUnion } from '@mui/types';
|
|
4
|
-
import { OverridableComponent, OverrideProps } from '
|
|
4
|
+
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
|
|
5
5
|
import { PropTypes, Theme } from '..';
|
|
6
6
|
import { AppBarClasses } from './appBarClasses';
|
|
7
7
|
import { ExtendPaperTypeMap } from '../Paper/Paper';
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## 6.4.2
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v6.4.1..v6.x -->
|
|
6
|
+
|
|
7
|
+
_Jan 29, 2025_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 5 contributors who made this release possible.
|
|
10
|
+
|
|
11
|
+
### `@mui/material@6.4.2`
|
|
12
|
+
|
|
13
|
+
- [Autocomplete] Prevent shrink animation in uncontrolled Autocomplete when default value is set (#44873) @ZeeshanTamboli
|
|
14
|
+
- [Slider] Fix arrow keys past the end for Slider with custom marks (#45050) @joshkel
|
|
15
|
+
- [TextareaAutosize] Temporarily disconnect ResizeObserver to avoid loop error (#44540) @mj12albert
|
|
16
|
+
|
|
17
|
+
### Core
|
|
18
|
+
|
|
19
|
+
- [code-infra] a few fixes uncovered during ESM updates (@Janpot) (#45100) @Janpot
|
|
20
|
+
- [code-infra] Remove rsc-builder (#45079) @Janpot
|
|
21
|
+
- [code-infra] Remove commonjs imports in docs (#44976) @Janpot
|
|
22
|
+
- Prepare stable release from the `v6.x` branch (#45133) @DiegoAndai
|
|
23
|
+
|
|
24
|
+
### Docs
|
|
25
|
+
|
|
26
|
+
- Fix `/base-ui` redirect and prune links (#45083) @mj12albert
|
|
27
|
+
|
|
28
|
+
All contributors of this release in alphabetical order: @DiegoAndai, @Janpot, @joshkel, @mj12albert, @ZeeshanTamboli
|
|
29
|
+
|
|
3
30
|
## 6.4.1
|
|
4
31
|
|
|
5
32
|
<!-- generated comparing v6.4.0..master -->
|
package/Card/Card.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps } from '@mui/system';
|
|
3
3
|
import { DistributiveOmit } from '@mui/types';
|
|
4
|
-
import { OverridableComponent, OverrideProps } from '
|
|
4
|
+
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
|
|
5
5
|
import { Theme } from '..';
|
|
6
6
|
import { PaperOwnProps } from '../Paper';
|
|
7
7
|
import { CardClasses } from './cardClasses';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DistributiveOmit } from '@mui/types';
|
|
3
|
+
import { StyledComponentProps } from '../styles';
|
|
4
|
+
/**
|
|
5
|
+
* A component whose root component can be controlled via a `component` prop.
|
|
6
|
+
*
|
|
7
|
+
* Adjusts valid props based on the type of `component`.
|
|
8
|
+
*/
|
|
9
|
+
export interface OverridableComponent<TypeMap extends OverridableTypeMap> {
|
|
10
|
+
<RootComponent extends React.ElementType>(props: {
|
|
11
|
+
/**
|
|
12
|
+
* The component used for the root node.
|
|
13
|
+
* Either a string to use a HTML element or a component.
|
|
14
|
+
*/
|
|
15
|
+
component: RootComponent;
|
|
16
|
+
} & OverrideProps<TypeMap, RootComponent>): React.JSX.Element | null;
|
|
17
|
+
(props: DefaultComponentProps<TypeMap>): React.JSX.Element | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Props of the component if `component={Component}` is used.
|
|
21
|
+
*/
|
|
22
|
+
export type OverrideProps<TypeMap extends OverridableTypeMap, RootComponent extends React.ElementType> = (BaseProps<TypeMap> & DistributiveOmit<React.ComponentPropsWithRef<RootComponent>, keyof BaseProps<TypeMap>>);
|
|
23
|
+
/**
|
|
24
|
+
* Props if `component={Component}` is NOT used.
|
|
25
|
+
*/
|
|
26
|
+
export type DefaultComponentProps<TypeMap extends OverridableTypeMap> = BaseProps<TypeMap> & DistributiveOmit<React.ComponentPropsWithRef<TypeMap['defaultComponent']>, keyof BaseProps<TypeMap>>;
|
|
27
|
+
/**
|
|
28
|
+
* Props defined on the component (+ common material-ui props).
|
|
29
|
+
*/
|
|
30
|
+
export type BaseProps<TypeMap extends OverridableTypeMap> = TypeMap['props'] & CommonProps;
|
|
31
|
+
/**
|
|
32
|
+
* Props that are valid for material-ui components.
|
|
33
|
+
*/
|
|
34
|
+
export interface CommonProps extends StyledComponentProps<never> {
|
|
35
|
+
className?: string;
|
|
36
|
+
style?: React.CSSProperties;
|
|
37
|
+
}
|
|
38
|
+
export interface OverridableTypeMap {
|
|
39
|
+
props: {};
|
|
40
|
+
defaultComponent: React.ElementType;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { OverridableStringUnion } from '@mui/types';
|
|
3
3
|
import { SxProps } from '@mui/system';
|
|
4
|
-
import { OverridableComponent, OverrideProps } from '
|
|
4
|
+
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
|
|
5
5
|
import { Theme } from '../styles';
|
|
6
6
|
import { UsePaginationItem } from '../usePagination/usePagination';
|
|
7
7
|
import { PaginationItemClasses } from './paginationItemClasses';
|
package/Slider/useSlider.js
CHANGED
|
@@ -245,9 +245,9 @@ export function useSlider(parameters) {
|
|
|
245
245
|
let newValue = valueInput;
|
|
246
246
|
if (marks && step == null) {
|
|
247
247
|
const maxMarksValue = marksValues[marksValues.length - 1];
|
|
248
|
-
if (newValue
|
|
248
|
+
if (newValue >= maxMarksValue) {
|
|
249
249
|
newValue = maxMarksValue;
|
|
250
|
-
} else if (newValue
|
|
250
|
+
} else if (newValue <= marksValues[0]) {
|
|
251
251
|
newValue = marksValues[0];
|
|
252
252
|
} else {
|
|
253
253
|
newValue = newValue < value ? marksValues[marksIndex - 1] : marksValues[marksIndex + 1];
|
|
@@ -22,8 +22,15 @@ const styles = {
|
|
|
22
22
|
transform: 'translateZ(0)'
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
function isObjectEmpty(object) {
|
|
26
|
+
// eslint-disable-next-line
|
|
27
|
+
for (const _ in object) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
25
32
|
function isEmpty(obj) {
|
|
26
|
-
return
|
|
33
|
+
return isObjectEmpty(obj) || obj.outerHeightStyle === 0 && !obj.overflowing;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
/**
|
|
@@ -48,14 +55,18 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
48
55
|
const {
|
|
49
56
|
current: isControlled
|
|
50
57
|
} = React.useRef(value != null);
|
|
51
|
-
const
|
|
52
|
-
const handleRef = useForkRef(forwardedRef,
|
|
58
|
+
const textareaRef = React.useRef(null);
|
|
59
|
+
const handleRef = useForkRef(forwardedRef, textareaRef);
|
|
53
60
|
const heightRef = React.useRef(null);
|
|
54
|
-
const
|
|
61
|
+
const hiddenTextareaRef = React.useRef(null);
|
|
55
62
|
const calculateTextareaStyles = React.useCallback(() => {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
63
|
+
const textarea = textareaRef.current;
|
|
64
|
+
const hiddenTextarea = hiddenTextareaRef.current;
|
|
65
|
+
if (!textarea || !hiddenTextarea) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const containerWindow = ownerWindow(textarea);
|
|
69
|
+
const computedStyle = containerWindow.getComputedStyle(textarea);
|
|
59
70
|
|
|
60
71
|
// If input's width is shrunk and it's not visible, don't sync height.
|
|
61
72
|
if (computedStyle.width === '0px') {
|
|
@@ -64,25 +75,24 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
64
75
|
overflowing: false
|
|
65
76
|
};
|
|
66
77
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (inputShallow.value.slice(-1) === '\n') {
|
|
78
|
+
hiddenTextarea.style.width = computedStyle.width;
|
|
79
|
+
hiddenTextarea.value = textarea.value || props.placeholder || 'x';
|
|
80
|
+
if (hiddenTextarea.value.slice(-1) === '\n') {
|
|
71
81
|
// Certain fonts which overflow the line height will cause the textarea
|
|
72
82
|
// to report a different scrollHeight depending on whether the last line
|
|
73
83
|
// is empty. Make it non-empty to avoid this issue.
|
|
74
|
-
|
|
84
|
+
hiddenTextarea.value += ' ';
|
|
75
85
|
}
|
|
76
86
|
const boxSizing = computedStyle.boxSizing;
|
|
77
87
|
const padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
|
|
78
88
|
const border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
|
|
79
89
|
|
|
80
90
|
// The height of the inner content
|
|
81
|
-
const innerHeight =
|
|
91
|
+
const innerHeight = hiddenTextarea.scrollHeight;
|
|
82
92
|
|
|
83
93
|
// Measure height of a textarea with a single row
|
|
84
|
-
|
|
85
|
-
const singleRowHeight =
|
|
94
|
+
hiddenTextarea.value = 'x';
|
|
95
|
+
const singleRowHeight = hiddenTextarea.scrollHeight;
|
|
86
96
|
|
|
87
97
|
// The height of the outer content
|
|
88
98
|
let outerHeight = innerHeight;
|
|
@@ -103,45 +113,45 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
103
113
|
};
|
|
104
114
|
}, [maxRows, minRows, props.placeholder]);
|
|
105
115
|
const syncHeight = React.useCallback(() => {
|
|
116
|
+
const textarea = textareaRef.current;
|
|
106
117
|
const textareaStyles = calculateTextareaStyles();
|
|
107
|
-
if (isEmpty(textareaStyles)) {
|
|
118
|
+
if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
|
|
108
119
|
return;
|
|
109
120
|
}
|
|
110
121
|
const outerHeightStyle = textareaStyles.outerHeightStyle;
|
|
111
|
-
const input = inputRef.current;
|
|
112
122
|
if (heightRef.current !== outerHeightStyle) {
|
|
113
123
|
heightRef.current = outerHeightStyle;
|
|
114
|
-
|
|
124
|
+
textarea.style.height = `${outerHeightStyle}px`;
|
|
115
125
|
}
|
|
116
|
-
|
|
126
|
+
textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
|
|
117
127
|
}, [calculateTextareaStyles]);
|
|
128
|
+
const frameRef = React.useRef(-1);
|
|
118
129
|
useEnhancedEffect(() => {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Also see https://github.com/mui/mui-x/issues/8733
|
|
126
|
-
let rAF;
|
|
127
|
-
const rAFHandleResize = () => {
|
|
128
|
-
cancelAnimationFrame(rAF);
|
|
129
|
-
rAF = requestAnimationFrame(() => {
|
|
130
|
-
handleResize();
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
const debounceHandleResize = debounce(handleResize);
|
|
134
|
-
const input = inputRef.current;
|
|
135
|
-
const containerWindow = ownerWindow(input);
|
|
130
|
+
const debounceHandleResize = debounce(() => syncHeight());
|
|
131
|
+
const textarea = textareaRef?.current;
|
|
132
|
+
if (!textarea) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
const containerWindow = ownerWindow(textarea);
|
|
136
136
|
containerWindow.addEventListener('resize', debounceHandleResize);
|
|
137
137
|
let resizeObserver;
|
|
138
138
|
if (typeof ResizeObserver !== 'undefined') {
|
|
139
|
-
resizeObserver = new ResizeObserver(
|
|
140
|
-
|
|
139
|
+
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
|
+
});
|
|
150
|
+
resizeObserver.observe(textarea);
|
|
141
151
|
}
|
|
142
152
|
return () => {
|
|
143
153
|
debounceHandleResize.clear();
|
|
144
|
-
cancelAnimationFrame(
|
|
154
|
+
cancelAnimationFrame(frameRef.current);
|
|
145
155
|
containerWindow.removeEventListener('resize', debounceHandleResize);
|
|
146
156
|
if (resizeObserver) {
|
|
147
157
|
resizeObserver.disconnect();
|
|
@@ -173,7 +183,7 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
173
183
|
"aria-hidden": true,
|
|
174
184
|
className: props.className,
|
|
175
185
|
readOnly: true,
|
|
176
|
-
ref:
|
|
186
|
+
ref: hiddenTextareaRef,
|
|
177
187
|
tabIndex: -1,
|
|
178
188
|
style: {
|
|
179
189
|
...styles.shadow,
|
package/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -245,9 +245,9 @@ export function useSlider(parameters) {
|
|
|
245
245
|
let newValue = valueInput;
|
|
246
246
|
if (marks && step == null) {
|
|
247
247
|
const maxMarksValue = marksValues[marksValues.length - 1];
|
|
248
|
-
if (newValue
|
|
248
|
+
if (newValue >= maxMarksValue) {
|
|
249
249
|
newValue = maxMarksValue;
|
|
250
|
-
} else if (newValue
|
|
250
|
+
} else if (newValue <= marksValues[0]) {
|
|
251
251
|
newValue = marksValues[0];
|
|
252
252
|
} else {
|
|
253
253
|
newValue = newValue < value ? marksValues[marksIndex - 1] : marksValues[marksIndex + 1];
|
|
@@ -22,8 +22,15 @@ const styles = {
|
|
|
22
22
|
transform: 'translateZ(0)'
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
function isObjectEmpty(object) {
|
|
26
|
+
// eslint-disable-next-line
|
|
27
|
+
for (const _ in object) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
25
32
|
function isEmpty(obj) {
|
|
26
|
-
return
|
|
33
|
+
return isObjectEmpty(obj) || obj.outerHeightStyle === 0 && !obj.overflowing;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
/**
|
|
@@ -48,14 +55,18 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
48
55
|
const {
|
|
49
56
|
current: isControlled
|
|
50
57
|
} = React.useRef(value != null);
|
|
51
|
-
const
|
|
52
|
-
const handleRef = useForkRef(forwardedRef,
|
|
58
|
+
const textareaRef = React.useRef(null);
|
|
59
|
+
const handleRef = useForkRef(forwardedRef, textareaRef);
|
|
53
60
|
const heightRef = React.useRef(null);
|
|
54
|
-
const
|
|
61
|
+
const hiddenTextareaRef = React.useRef(null);
|
|
55
62
|
const calculateTextareaStyles = React.useCallback(() => {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
63
|
+
const textarea = textareaRef.current;
|
|
64
|
+
const hiddenTextarea = hiddenTextareaRef.current;
|
|
65
|
+
if (!textarea || !hiddenTextarea) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const containerWindow = ownerWindow(textarea);
|
|
69
|
+
const computedStyle = containerWindow.getComputedStyle(textarea);
|
|
59
70
|
|
|
60
71
|
// If input's width is shrunk and it's not visible, don't sync height.
|
|
61
72
|
if (computedStyle.width === '0px') {
|
|
@@ -64,25 +75,24 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
64
75
|
overflowing: false
|
|
65
76
|
};
|
|
66
77
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (inputShallow.value.slice(-1) === '\n') {
|
|
78
|
+
hiddenTextarea.style.width = computedStyle.width;
|
|
79
|
+
hiddenTextarea.value = textarea.value || props.placeholder || 'x';
|
|
80
|
+
if (hiddenTextarea.value.slice(-1) === '\n') {
|
|
71
81
|
// Certain fonts which overflow the line height will cause the textarea
|
|
72
82
|
// to report a different scrollHeight depending on whether the last line
|
|
73
83
|
// is empty. Make it non-empty to avoid this issue.
|
|
74
|
-
|
|
84
|
+
hiddenTextarea.value += ' ';
|
|
75
85
|
}
|
|
76
86
|
const boxSizing = computedStyle.boxSizing;
|
|
77
87
|
const padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
|
|
78
88
|
const border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
|
|
79
89
|
|
|
80
90
|
// The height of the inner content
|
|
81
|
-
const innerHeight =
|
|
91
|
+
const innerHeight = hiddenTextarea.scrollHeight;
|
|
82
92
|
|
|
83
93
|
// Measure height of a textarea with a single row
|
|
84
|
-
|
|
85
|
-
const singleRowHeight =
|
|
94
|
+
hiddenTextarea.value = 'x';
|
|
95
|
+
const singleRowHeight = hiddenTextarea.scrollHeight;
|
|
86
96
|
|
|
87
97
|
// The height of the outer content
|
|
88
98
|
let outerHeight = innerHeight;
|
|
@@ -103,45 +113,45 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
103
113
|
};
|
|
104
114
|
}, [maxRows, minRows, props.placeholder]);
|
|
105
115
|
const syncHeight = React.useCallback(() => {
|
|
116
|
+
const textarea = textareaRef.current;
|
|
106
117
|
const textareaStyles = calculateTextareaStyles();
|
|
107
|
-
if (isEmpty(textareaStyles)) {
|
|
118
|
+
if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
|
|
108
119
|
return;
|
|
109
120
|
}
|
|
110
121
|
const outerHeightStyle = textareaStyles.outerHeightStyle;
|
|
111
|
-
const input = inputRef.current;
|
|
112
122
|
if (heightRef.current !== outerHeightStyle) {
|
|
113
123
|
heightRef.current = outerHeightStyle;
|
|
114
|
-
|
|
124
|
+
textarea.style.height = `${outerHeightStyle}px`;
|
|
115
125
|
}
|
|
116
|
-
|
|
126
|
+
textarea.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
|
|
117
127
|
}, [calculateTextareaStyles]);
|
|
128
|
+
const frameRef = React.useRef(-1);
|
|
118
129
|
useEnhancedEffect(() => {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Also see https://github.com/mui/mui-x/issues/8733
|
|
126
|
-
let rAF;
|
|
127
|
-
const rAFHandleResize = () => {
|
|
128
|
-
cancelAnimationFrame(rAF);
|
|
129
|
-
rAF = requestAnimationFrame(() => {
|
|
130
|
-
handleResize();
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
const debounceHandleResize = debounce(handleResize);
|
|
134
|
-
const input = inputRef.current;
|
|
135
|
-
const containerWindow = ownerWindow(input);
|
|
130
|
+
const debounceHandleResize = debounce(() => syncHeight());
|
|
131
|
+
const textarea = textareaRef?.current;
|
|
132
|
+
if (!textarea) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
const containerWindow = ownerWindow(textarea);
|
|
136
136
|
containerWindow.addEventListener('resize', debounceHandleResize);
|
|
137
137
|
let resizeObserver;
|
|
138
138
|
if (typeof ResizeObserver !== 'undefined') {
|
|
139
|
-
resizeObserver = new ResizeObserver(
|
|
140
|
-
|
|
139
|
+
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
|
+
});
|
|
150
|
+
resizeObserver.observe(textarea);
|
|
141
151
|
}
|
|
142
152
|
return () => {
|
|
143
153
|
debounceHandleResize.clear();
|
|
144
|
-
cancelAnimationFrame(
|
|
154
|
+
cancelAnimationFrame(frameRef.current);
|
|
145
155
|
containerWindow.removeEventListener('resize', debounceHandleResize);
|
|
146
156
|
if (resizeObserver) {
|
|
147
157
|
resizeObserver.disconnect();
|
|
@@ -173,7 +183,7 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
173
183
|
"aria-hidden": true,
|
|
174
184
|
className: props.className,
|
|
175
185
|
readOnly: true,
|
|
176
|
-
ref:
|
|
186
|
+
ref: hiddenTextareaRef,
|
|
177
187
|
tabIndex: -1,
|
|
178
188
|
style: {
|
|
179
189
|
...styles.shadow,
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -47,6 +47,13 @@ const defaultFilterOptions = createFilterOptions();
|
|
|
47
47
|
const pageSize = 5;
|
|
48
48
|
const defaultIsActiveElementInListbox = listboxRef => listboxRef.current !== null && listboxRef.current.parentElement?.contains(document.activeElement);
|
|
49
49
|
const MULTIPLE_DEFAULT_VALUE = [];
|
|
50
|
+
function getInputValue(value, multiple, getOptionLabel) {
|
|
51
|
+
if (multiple || value == null) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
const optionLabel = getOptionLabel(value);
|
|
55
|
+
return typeof optionLabel === 'string' ? optionLabel : '';
|
|
56
|
+
}
|
|
50
57
|
function useAutocomplete(props) {
|
|
51
58
|
const {
|
|
52
59
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -112,6 +119,10 @@ function useAutocomplete(props) {
|
|
|
112
119
|
const [focusedTag, setFocusedTag] = React.useState(-1);
|
|
113
120
|
const defaultHighlighted = autoHighlight ? 0 : -1;
|
|
114
121
|
const highlightedIndexRef = React.useRef(defaultHighlighted);
|
|
122
|
+
|
|
123
|
+
// Calculate the initial inputValue on mount only.
|
|
124
|
+
// Using useRef since defaultValue doesn't need to update inputValue dynamically.
|
|
125
|
+
const initialInputValue = React.useRef(getInputValue(defaultValue, multiple, getOptionLabel)).current;
|
|
115
126
|
const [value, setValueState] = useControlled({
|
|
116
127
|
controlled: valueProp,
|
|
117
128
|
default: defaultValue,
|
|
@@ -119,7 +130,7 @@ function useAutocomplete(props) {
|
|
|
119
130
|
});
|
|
120
131
|
const [inputValue, setInputValueState] = useControlled({
|
|
121
132
|
controlled: inputValueProp,
|
|
122
|
-
default:
|
|
133
|
+
default: initialInputValue,
|
|
123
134
|
name: componentName,
|
|
124
135
|
state: 'inputValue'
|
|
125
136
|
});
|
|
@@ -131,15 +142,7 @@ function useAutocomplete(props) {
|
|
|
131
142
|
if (!isOptionSelected && !clearOnBlur) {
|
|
132
143
|
return;
|
|
133
144
|
}
|
|
134
|
-
|
|
135
|
-
if (multiple) {
|
|
136
|
-
newInputValue = '';
|
|
137
|
-
} else if (newValue == null) {
|
|
138
|
-
newInputValue = '';
|
|
139
|
-
} else {
|
|
140
|
-
const optionLabel = getOptionLabel(newValue);
|
|
141
|
-
newInputValue = typeof optionLabel === 'string' ? optionLabel : '';
|
|
142
|
-
}
|
|
145
|
+
const newInputValue = getInputValue(newValue, multiple, getOptionLabel);
|
|
143
146
|
if (inputValue === newInputValue) {
|
|
144
147
|
return;
|
|
145
148
|
}
|
package/modern/version/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const version = "6.4.
|
|
1
|
+
export const version = "6.4.2";
|
|
2
2
|
export const major = Number("6");
|
|
3
3
|
export const minor = Number("4");
|
|
4
|
-
export const patch = Number("
|
|
4
|
+
export const patch = Number("2");
|
|
5
5
|
export const prerelease = undefined;
|
|
6
6
|
export default version;
|
package/node/Slider/useSlider.js
CHANGED
|
@@ -255,9 +255,9 @@ function useSlider(parameters) {
|
|
|
255
255
|
let newValue = valueInput;
|
|
256
256
|
if (marks && step == null) {
|
|
257
257
|
const maxMarksValue = marksValues[marksValues.length - 1];
|
|
258
|
-
if (newValue
|
|
258
|
+
if (newValue >= maxMarksValue) {
|
|
259
259
|
newValue = maxMarksValue;
|
|
260
|
-
} else if (newValue
|
|
260
|
+
} else if (newValue <= marksValues[0]) {
|
|
261
261
|
newValue = marksValues[0];
|
|
262
262
|
} else {
|
|
263
263
|
newValue = newValue < value ? marksValues[marksIndex - 1] : marksValues[marksIndex + 1];
|