@mui/material 5.2.6 → 5.3.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/Autocomplete/Autocomplete.d.ts +2 -0
- package/Autocomplete/Autocomplete.js +11 -7
- package/Avatar/Avatar.d.ts +3 -1
- package/Backdrop/Backdrop.js +3 -1
- package/Badge/Badge.d.ts +10 -10
- package/Badge/Badge.js +6 -7
- package/Button/buttonClasses.d.ts +1 -1
- package/CHANGELOG.md +240 -33
- package/FilledInput/FilledInput.js +4 -1
- package/FormControlLabel/FormControlLabel.js +3 -1
- package/Input/Input.js +4 -1
- package/InputBase/InputBase.js +4 -1
- package/InputLabel/InputLabel.js +4 -0
- package/ListItem/ListItem.js +3 -1
- package/Modal/Modal.js +3 -1
- package/README.md +5 -4
- package/Select/Select.d.ts +9 -1
- package/Select/Select.js +10 -1
- package/Select/SelectInput.d.ts +1 -0
- package/Select/SelectInput.js +25 -4
- package/Slider/Slider.d.ts +2 -0
- package/Slider/Slider.js +126 -53
- package/StepLabel/StepLabel.js +3 -1
- package/SvgIcon/SvgIcon.d.ts +8 -0
- package/SvgIcon/SvgIcon.js +28 -12
- package/TextField/TextField.d.ts +1 -0
- package/TextField/TextField.js +1 -0
- package/Tooltip/Tooltip.js +6 -1
- package/index.js +1 -1
- package/legacy/Autocomplete/Autocomplete.js +11 -7
- package/legacy/Backdrop/Backdrop.js +3 -1
- package/legacy/Badge/Badge.js +6 -7
- package/legacy/FilledInput/FilledInput.js +4 -1
- package/legacy/FormControlLabel/FormControlLabel.js +3 -1
- package/legacy/Input/Input.js +4 -1
- package/legacy/InputBase/InputBase.js +4 -1
- package/legacy/InputLabel/InputLabel.js +4 -0
- package/legacy/ListItem/ListItem.js +3 -1
- package/legacy/Modal/Modal.js +3 -1
- package/legacy/Select/Select.js +11 -1
- package/legacy/Select/SelectInput.js +29 -7
- package/legacy/Slider/Slider.js +127 -54
- package/legacy/StepLabel/StepLabel.js +3 -1
- package/legacy/SvgIcon/SvgIcon.js +29 -12
- package/legacy/TextField/TextField.js +1 -0
- package/legacy/Tooltip/Tooltip.js +6 -1
- package/legacy/index.js +1 -1
- package/legacy/locale/index.js +139 -128
- package/legacy/utils/shouldSpreadAdditionalProps.js +7 -0
- package/locale/index.js +54 -44
- package/modern/Autocomplete/Autocomplete.js +10 -6
- package/modern/Backdrop/Backdrop.js +3 -1
- package/modern/Badge/Badge.js +6 -7
- package/modern/FilledInput/FilledInput.js +4 -1
- package/modern/FormControlLabel/FormControlLabel.js +3 -1
- package/modern/Input/Input.js +4 -1
- package/modern/InputBase/InputBase.js +4 -1
- package/modern/InputLabel/InputLabel.js +4 -0
- package/modern/ListItem/ListItem.js +3 -1
- package/modern/Modal/Modal.js +3 -1
- package/modern/Select/Select.js +10 -1
- package/modern/Select/SelectInput.js +25 -4
- package/modern/Slider/Slider.js +126 -53
- package/modern/StepLabel/StepLabel.js +3 -1
- package/modern/SvgIcon/SvgIcon.js +27 -11
- package/modern/TextField/TextField.js +1 -0
- package/modern/Tooltip/Tooltip.js +6 -1
- package/modern/index.js +1 -1
- package/modern/locale/index.js +54 -44
- package/modern/utils/shouldSpreadAdditionalProps.js +7 -0
- package/node/Autocomplete/Autocomplete.js +11 -7
- package/node/Backdrop/Backdrop.js +3 -1
- package/node/Badge/Badge.js +8 -8
- package/node/FilledInput/FilledInput.js +4 -1
- package/node/FormControlLabel/FormControlLabel.js +3 -1
- package/node/Input/Input.js +4 -1
- package/node/InputBase/InputBase.js +4 -1
- package/node/InputLabel/InputLabel.js +4 -0
- package/node/ListItem/ListItem.js +3 -1
- package/node/Modal/Modal.js +3 -1
- package/node/Select/Select.js +10 -1
- package/node/Select/SelectInput.js +25 -4
- package/node/Slider/Slider.js +112 -45
- package/node/StepLabel/StepLabel.js +3 -1
- package/node/SvgIcon/SvgIcon.js +28 -12
- package/node/TextField/TextField.js +1 -0
- package/node/Tooltip/Tooltip.js +6 -1
- package/node/index.js +1 -1
- package/node/locale/index.js +54 -44
- package/node/utils/shouldSpreadAdditionalProps.js +15 -0
- package/package.json +7 -7
- package/styles/components.d.ts +452 -113
- package/styles/createTheme.d.ts +12 -6
- package/styles/overrides.d.ts +16 -4
- package/styles/useThemeProps.d.ts +2 -1
- package/umd/material-ui.development.js +619 -289
- package/umd/material-ui.production.min.js +21 -21
- package/utils/shouldSpreadAdditionalProps.js +7 -0
package/locale/index.js
CHANGED
|
@@ -1206,9 +1206,12 @@ export const fiFI = {
|
|
|
1206
1206
|
|
|
1207
1207
|
return 'Mene edelliselle sivulle';
|
|
1208
1208
|
},
|
|
1209
|
-
labelRowsPerPage: 'Rivejä per sivu:'
|
|
1210
|
-
|
|
1211
|
-
|
|
1209
|
+
labelRowsPerPage: 'Rivejä per sivu:',
|
|
1210
|
+
labelDisplayedRows: ({
|
|
1211
|
+
from,
|
|
1212
|
+
to,
|
|
1213
|
+
count
|
|
1214
|
+
}) => `${from}–${to} / ${count !== -1 ? count : `enemmän kuin ${to}`}`
|
|
1212
1215
|
}
|
|
1213
1216
|
},
|
|
1214
1217
|
MuiRating: {
|
|
@@ -3266,26 +3269,29 @@ export const ukUA = {
|
|
|
3266
3269
|
};
|
|
3267
3270
|
export const viVN = {
|
|
3268
3271
|
components: {
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3272
|
+
MuiBreadcrumbs: {
|
|
3273
|
+
defaultProps: {
|
|
3274
|
+
expandText: 'Mở ra'
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3274
3277
|
MuiTablePagination: {
|
|
3275
3278
|
defaultProps: {
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3279
|
+
getItemAriaLabel: type => {
|
|
3280
|
+
if (type === 'first') {
|
|
3281
|
+
return 'Tới trang đầu tiên';
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
if (type === 'last') {
|
|
3285
|
+
return 'Tới trang cuối cùng';
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
if (type === 'next') {
|
|
3289
|
+
return 'Tới trang tiếp theo';
|
|
3290
|
+
} // if (type === 'previous') {
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
return 'Về trang trước đó';
|
|
3294
|
+
},
|
|
3289
3295
|
labelRowsPerPage: 'Số hàng mỗi trang:',
|
|
3290
3296
|
labelDisplayedRows: ({
|
|
3291
3297
|
from,
|
|
@@ -3297,7 +3303,7 @@ export const viVN = {
|
|
|
3297
3303
|
MuiRating: {
|
|
3298
3304
|
defaultProps: {
|
|
3299
3305
|
getLabelText: value => `${value} sao`,
|
|
3300
|
-
emptyLabelText: '
|
|
3306
|
+
emptyLabelText: 'Không có dữ liệu'
|
|
3301
3307
|
}
|
|
3302
3308
|
},
|
|
3303
3309
|
MuiAutocomplete: {
|
|
@@ -3305,7 +3311,7 @@ export const viVN = {
|
|
|
3305
3311
|
clearText: 'Xóa',
|
|
3306
3312
|
closeText: 'Đóng',
|
|
3307
3313
|
loadingText: 'Đang tải…',
|
|
3308
|
-
noOptionsText: 'Không có lựa chọn',
|
|
3314
|
+
noOptionsText: 'Không có lựa chọn nào',
|
|
3309
3315
|
openText: 'Mở'
|
|
3310
3316
|
}
|
|
3311
3317
|
},
|
|
@@ -3313,28 +3319,32 @@ export const viVN = {
|
|
|
3313
3319
|
defaultProps: {
|
|
3314
3320
|
closeText: 'Đóng'
|
|
3315
3321
|
}
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
// }
|
|
3329
|
-
// if (type === 'next') {
|
|
3330
|
-
// return 'Go to next page';
|
|
3331
|
-
// }
|
|
3332
|
-
// // if (type === 'previous') {
|
|
3333
|
-
// return 'Go to previous page';
|
|
3334
|
-
// },
|
|
3335
|
-
// },
|
|
3336
|
-
// },
|
|
3322
|
+
},
|
|
3323
|
+
MuiPagination: {
|
|
3324
|
+
defaultProps: {
|
|
3325
|
+
'aria-label': 'Thanh điều khiển trang',
|
|
3326
|
+
getItemAriaLabel: (type, page, selected) => {
|
|
3327
|
+
if (type === 'page') {
|
|
3328
|
+
return `${selected ? '' : 'Tới '}trang ${page}`;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
if (type === 'first') {
|
|
3332
|
+
return 'Tới trang đầu tiên';
|
|
3333
|
+
}
|
|
3337
3334
|
|
|
3335
|
+
if (type === 'last') {
|
|
3336
|
+
return 'Tới trang cuối cùng';
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
if (type === 'next') {
|
|
3340
|
+
return 'Tới trang tiếp theo';
|
|
3341
|
+
} // if (type === 'previous') {
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
return 'Về trang trước đó';
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3338
3348
|
}
|
|
3339
3349
|
};
|
|
3340
3350
|
export const zhCN = {
|
|
@@ -564,10 +564,11 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
|
|
|
564
564
|
role: "presentation",
|
|
565
565
|
anchorEl: anchorEl,
|
|
566
566
|
open: true,
|
|
567
|
-
children: /*#__PURE__*/_jsxs(AutocompletePaper, {
|
|
568
|
-
as: PaperComponent,
|
|
569
|
-
className: classes.paper,
|
|
567
|
+
children: /*#__PURE__*/_jsxs(AutocompletePaper, _extends({
|
|
570
568
|
ownerState: ownerState,
|
|
569
|
+
as: PaperComponent
|
|
570
|
+
}, componentsProps.paper, {
|
|
571
|
+
className: clsx(classes.paper, componentsProps.paper?.className),
|
|
571
572
|
children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/_jsx(AutocompleteLoading, {
|
|
572
573
|
className: classes.loading,
|
|
573
574
|
ownerState: ownerState,
|
|
@@ -598,7 +599,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
|
|
|
598
599
|
return renderListOption(option, index);
|
|
599
600
|
})
|
|
600
601
|
})) : null]
|
|
601
|
-
})
|
|
602
|
+
}))
|
|
602
603
|
}) : null]
|
|
603
604
|
});
|
|
604
605
|
});
|
|
@@ -668,7 +669,7 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes
|
|
|
668
669
|
* If `true`, the input's text is cleared on blur if no value is selected.
|
|
669
670
|
*
|
|
670
671
|
* Set to `true` if you want to help the user enter a new value.
|
|
671
|
-
* Set to `false` if you want to help the user resume
|
|
672
|
+
* Set to `false` if you want to help the user resume their search.
|
|
672
673
|
* @default !props.freeSolo
|
|
673
674
|
*/
|
|
674
675
|
clearOnBlur: PropTypes.bool,
|
|
@@ -699,7 +700,10 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes
|
|
|
699
700
|
* The props used for each slot inside.
|
|
700
701
|
* @default {}
|
|
701
702
|
*/
|
|
702
|
-
componentsProps: PropTypes.
|
|
703
|
+
componentsProps: PropTypes.shape({
|
|
704
|
+
clearIndicator: PropTypes.object,
|
|
705
|
+
paper: PropTypes.object
|
|
706
|
+
}),
|
|
703
707
|
|
|
704
708
|
/**
|
|
705
709
|
* The default value. Use when the component is not controlled.
|
|
@@ -124,7 +124,9 @@ process.env.NODE_ENV !== "production" ? Backdrop.propTypes
|
|
|
124
124
|
* The props used for each slot inside the Backdrop.
|
|
125
125
|
* @default {}
|
|
126
126
|
*/
|
|
127
|
-
componentsProps: PropTypes.
|
|
127
|
+
componentsProps: PropTypes.shape({
|
|
128
|
+
root: PropTypes.object
|
|
129
|
+
}),
|
|
128
130
|
|
|
129
131
|
/**
|
|
130
132
|
* If `true`, the backdrop is invisible.
|
package/modern/Badge/Badge.js
CHANGED
|
@@ -5,10 +5,11 @@ import * as React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { usePreviousProps } from '@mui/utils';
|
|
8
|
-
import { generateUtilityClasses
|
|
8
|
+
import { generateUtilityClasses } from '@mui/base';
|
|
9
9
|
import BadgeUnstyled, { badgeUnstyledClasses, getBadgeUtilityClass } from '@mui/base/BadgeUnstyled';
|
|
10
10
|
import styled from '../styles/styled';
|
|
11
11
|
import useThemeProps from '../styles/useThemeProps';
|
|
12
|
+
import shouldSpreadAdditionalProps from '../utils/shouldSpreadAdditionalProps';
|
|
12
13
|
import capitalize from '../utils/capitalize';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
export const badgeClasses = _extends({}, badgeUnstyledClasses, generateUtilityClasses('MuiBadge', ['colorError', 'colorInfo', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorWarning', 'overlapRectangular', 'overlapCircular', // TODO: v6 remove the overlap value from these class keys
|
|
@@ -152,11 +153,6 @@ const BadgeBadge = styled('span', {
|
|
|
152
153
|
duration: theme.transitions.duration.leavingScreen
|
|
153
154
|
})
|
|
154
155
|
}));
|
|
155
|
-
|
|
156
|
-
const shouldSpreadAdditionalProps = Slot => {
|
|
157
|
-
return !Slot || !isHostComponent(Slot);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
156
|
const Badge = /*#__PURE__*/React.forwardRef(function Badge(inProps, ref) {
|
|
161
157
|
const props = useThemeProps({
|
|
162
158
|
props: inProps,
|
|
@@ -298,7 +294,10 @@ process.env.NODE_ENV !== "production" ? Badge.propTypes
|
|
|
298
294
|
* The props used for each slot inside the Badge.
|
|
299
295
|
* @default {}
|
|
300
296
|
*/
|
|
301
|
-
componentsProps: PropTypes.
|
|
297
|
+
componentsProps: PropTypes.shape({
|
|
298
|
+
badge: PropTypes.object,
|
|
299
|
+
root: PropTypes.object
|
|
300
|
+
}),
|
|
302
301
|
|
|
303
302
|
/**
|
|
304
303
|
* If `true`, the badge is invisible.
|
|
@@ -257,7 +257,10 @@ process.env.NODE_ENV !== "production" ? FilledInput.propTypes
|
|
|
257
257
|
* The props used for each slot inside the Input.
|
|
258
258
|
* @default {}
|
|
259
259
|
*/
|
|
260
|
-
componentsProps: PropTypes.
|
|
260
|
+
componentsProps: PropTypes.shape({
|
|
261
|
+
input: PropTypes.object,
|
|
262
|
+
root: PropTypes.object
|
|
263
|
+
}),
|
|
261
264
|
|
|
262
265
|
/**
|
|
263
266
|
* The default value. Use when the component is not controlled.
|
|
@@ -162,7 +162,9 @@ process.env.NODE_ENV !== "production" ? FormControlLabel.propTypes
|
|
|
162
162
|
* The props used for each slot inside.
|
|
163
163
|
* @default {}
|
|
164
164
|
*/
|
|
165
|
-
componentsProps: PropTypes.
|
|
165
|
+
componentsProps: PropTypes.shape({
|
|
166
|
+
typography: PropTypes.object
|
|
167
|
+
}),
|
|
166
168
|
|
|
167
169
|
/**
|
|
168
170
|
* A control element. For instance, it can be a `Radio`, a `Switch` or a `Checkbox`.
|
package/modern/Input/Input.js
CHANGED
|
@@ -192,7 +192,10 @@ process.env.NODE_ENV !== "production" ? Input.propTypes
|
|
|
192
192
|
* The props used for each slot inside the Input.
|
|
193
193
|
* @default {}
|
|
194
194
|
*/
|
|
195
|
-
componentsProps: PropTypes.
|
|
195
|
+
componentsProps: PropTypes.shape({
|
|
196
|
+
input: PropTypes.object,
|
|
197
|
+
root: PropTypes.object
|
|
198
|
+
}),
|
|
196
199
|
|
|
197
200
|
/**
|
|
198
201
|
* The default value. Use when the component is not controlled.
|
|
@@ -552,7 +552,10 @@ process.env.NODE_ENV !== "production" ? InputBase.propTypes
|
|
|
552
552
|
* The props used for each slot inside the Input.
|
|
553
553
|
* @default {}
|
|
554
554
|
*/
|
|
555
|
-
componentsProps: PropTypes.
|
|
555
|
+
componentsProps: PropTypes.shape({
|
|
556
|
+
input: PropTypes.object,
|
|
557
|
+
root: PropTypes.object
|
|
558
|
+
}),
|
|
556
559
|
|
|
557
560
|
/**
|
|
558
561
|
* The default value. Use when the component is not controlled.
|
|
@@ -82,6 +82,8 @@ const InputLabelRoot = styled(FormLabel, {
|
|
|
82
82
|
}, ownerState.size === 'small' && {
|
|
83
83
|
transform: 'translate(12px, 13px) scale(1)'
|
|
84
84
|
}, ownerState.shrink && _extends({
|
|
85
|
+
userSelect: 'none',
|
|
86
|
+
pointerEvents: 'auto',
|
|
85
87
|
transform: 'translate(12px, 7px) scale(0.75)',
|
|
86
88
|
maxWidth: 'calc(133% - 24px)'
|
|
87
89
|
}, ownerState.size === 'small' && {
|
|
@@ -95,6 +97,8 @@ const InputLabelRoot = styled(FormLabel, {
|
|
|
95
97
|
}, ownerState.size === 'small' && {
|
|
96
98
|
transform: 'translate(14px, 9px) scale(1)'
|
|
97
99
|
}, ownerState.shrink && {
|
|
100
|
+
userSelect: 'none',
|
|
101
|
+
pointerEvents: 'auto',
|
|
98
102
|
maxWidth: 'calc(133% - 24px)',
|
|
99
103
|
transform: 'translate(14px, -9px) scale(0.75)'
|
|
100
104
|
})));
|
|
@@ -346,7 +346,9 @@ process.env.NODE_ENV !== "production" ? ListItem.propTypes
|
|
|
346
346
|
* The props used for each slot inside the Input.
|
|
347
347
|
* @default {}
|
|
348
348
|
*/
|
|
349
|
-
componentsProps: PropTypes.
|
|
349
|
+
componentsProps: PropTypes.shape({
|
|
350
|
+
root: PropTypes.object
|
|
351
|
+
}),
|
|
350
352
|
|
|
351
353
|
/**
|
|
352
354
|
* The container component used when a `ListItemSecondaryAction` is the last child.
|
package/modern/Modal/Modal.js
CHANGED
|
@@ -177,7 +177,9 @@ process.env.NODE_ENV !== "production" ? Modal.propTypes
|
|
|
177
177
|
* The props used for each slot inside the Modal.
|
|
178
178
|
* @default {}
|
|
179
179
|
*/
|
|
180
|
-
componentsProps: PropTypes.
|
|
180
|
+
componentsProps: PropTypes.shape({
|
|
181
|
+
root: PropTypes.object
|
|
182
|
+
}),
|
|
181
183
|
|
|
182
184
|
/**
|
|
183
185
|
* An HTML element or function that returns one.
|
package/modern/Select/Select.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
|
|
4
4
|
var _Input, _FilledInput;
|
|
5
5
|
|
|
6
|
-
const _excluded = ["autoWidth", "children", "classes", "className", "displayEmpty", "IconComponent", "id", "input", "inputProps", "label", "labelId", "MenuProps", "multiple", "native", "onClose", "onOpen", "open", "renderValue", "SelectDisplayProps", "variant"];
|
|
6
|
+
const _excluded = ["autoWidth", "children", "classes", "className", "defaultOpen", "displayEmpty", "IconComponent", "id", "input", "inputProps", "label", "labelId", "MenuProps", "multiple", "native", "onClose", "onOpen", "open", "renderValue", "SelectDisplayProps", "variant"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import clsx from 'clsx';
|
|
@@ -38,6 +38,7 @@ const Select = /*#__PURE__*/React.forwardRef(function Select(inProps, ref) {
|
|
|
38
38
|
children,
|
|
39
39
|
classes: classesProp = {},
|
|
40
40
|
className,
|
|
41
|
+
defaultOpen = false,
|
|
41
42
|
displayEmpty = false,
|
|
42
43
|
IconComponent = ArrowDropDownIcon,
|
|
43
44
|
id,
|
|
@@ -94,6 +95,7 @@ const Select = /*#__PURE__*/React.forwardRef(function Select(inProps, ref) {
|
|
|
94
95
|
id
|
|
95
96
|
} : {
|
|
96
97
|
autoWidth,
|
|
98
|
+
defaultOpen,
|
|
97
99
|
displayEmpty,
|
|
98
100
|
labelId,
|
|
99
101
|
MenuProps,
|
|
@@ -148,6 +150,13 @@ process.env.NODE_ENV !== "production" ? Select.propTypes
|
|
|
148
150
|
*/
|
|
149
151
|
className: PropTypes.string,
|
|
150
152
|
|
|
153
|
+
/**
|
|
154
|
+
* If `true`, the component is initially open. Use when the component open state is not controlled (i.e. the `open` prop is not defined).
|
|
155
|
+
* You can only use it when the `native` prop is `false` (default).
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
defaultOpen: PropTypes.bool,
|
|
159
|
+
|
|
151
160
|
/**
|
|
152
161
|
* The default value. Use when the component is not controlled.
|
|
153
162
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
|
|
4
|
-
const _excluded = ["aria-describedby", "aria-label", "autoFocus", "autoWidth", "children", "className", "defaultValue", "disabled", "displayEmpty", "IconComponent", "inputRef", "labelId", "MenuProps", "multiple", "name", "onBlur", "onChange", "onClose", "onFocus", "onOpen", "open", "readOnly", "renderValue", "SelectDisplayProps", "tabIndex", "type", "value", "variant"];
|
|
4
|
+
const _excluded = ["aria-describedby", "aria-label", "autoFocus", "autoWidth", "children", "className", "defaultOpen", "defaultValue", "disabled", "displayEmpty", "IconComponent", "inputRef", "labelId", "MenuProps", "multiple", "name", "onBlur", "onChange", "onClose", "onFocus", "onOpen", "open", "readOnly", "renderValue", "SelectDisplayProps", "tabIndex", "type", "value", "variant"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { isFragment } from 'react-is';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
@@ -113,6 +113,7 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
113
113
|
autoWidth,
|
|
114
114
|
children,
|
|
115
115
|
className,
|
|
116
|
+
defaultOpen,
|
|
116
117
|
defaultValue,
|
|
117
118
|
disabled,
|
|
118
119
|
displayEmpty,
|
|
@@ -142,6 +143,11 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
142
143
|
default: defaultValue,
|
|
143
144
|
name: 'Select'
|
|
144
145
|
});
|
|
146
|
+
const [openState, setOpenState] = useControlled({
|
|
147
|
+
controlled: openProp,
|
|
148
|
+
default: defaultOpen,
|
|
149
|
+
name: 'Select'
|
|
150
|
+
});
|
|
145
151
|
const inputRef = React.useRef(null);
|
|
146
152
|
const displayRef = React.useRef(null);
|
|
147
153
|
const [displayNode, setDisplayNode] = React.useState(null);
|
|
@@ -149,7 +155,6 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
149
155
|
current: isOpenControlled
|
|
150
156
|
} = React.useRef(openProp != null);
|
|
151
157
|
const [menuMinWidthState, setMenuMinWidthState] = React.useState();
|
|
152
|
-
const [openState, setOpenState] = React.useState(false);
|
|
153
158
|
const handleRef = useForkRef(ref, inputRefProp);
|
|
154
159
|
const handleDisplayRef = React.useCallback(node => {
|
|
155
160
|
displayRef.current = node;
|
|
@@ -164,7 +169,17 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
164
169
|
},
|
|
165
170
|
node: inputRef.current,
|
|
166
171
|
value
|
|
167
|
-
}), [value]);
|
|
172
|
+
}), [value]); // Resize menu on `defaultOpen` automatic toggle.
|
|
173
|
+
|
|
174
|
+
React.useEffect(() => {
|
|
175
|
+
if (defaultOpen && openState && displayNode && !isOpenControlled) {
|
|
176
|
+
setMenuMinWidthState(autoWidth ? null : displayNode.clientWidth);
|
|
177
|
+
displayRef.current.focus();
|
|
178
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
179
|
+
|
|
180
|
+
}, [displayNode, autoWidth]); // `isOpenControlled` is ignored because the component should never switch between controlled and uncontrolled modes.
|
|
181
|
+
// `defaultOpen` and `openState` are ignored to avoid unnecessary callbacks.
|
|
182
|
+
|
|
168
183
|
React.useEffect(() => {
|
|
169
184
|
if (autoFocus) {
|
|
170
185
|
displayRef.current.focus();
|
|
@@ -300,7 +315,7 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
300
315
|
}
|
|
301
316
|
};
|
|
302
317
|
|
|
303
|
-
const open = displayNode !== null &&
|
|
318
|
+
const open = displayNode !== null && openState;
|
|
304
319
|
|
|
305
320
|
const handleBlur = event => {
|
|
306
321
|
// if open event.stopImmediatePropagation
|
|
@@ -559,6 +574,12 @@ process.env.NODE_ENV !== "production" ? SelectInput.propTypes = {
|
|
|
559
574
|
*/
|
|
560
575
|
className: PropTypes.string,
|
|
561
576
|
|
|
577
|
+
/**
|
|
578
|
+
* If `true`, the component is toggled on mount. Use when the component open state is not controlled.
|
|
579
|
+
* You can only use it when the `native` prop is `false` (default).
|
|
580
|
+
*/
|
|
581
|
+
defaultOpen: PropTypes.bool,
|
|
582
|
+
|
|
562
583
|
/**
|
|
563
584
|
* The default value. Use when the component is not controlled.
|
|
564
585
|
*/
|