@mui/x-date-pickers 5.0.9 → 5.0.11
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 +71 -0
- package/DateTimePicker/DateTimePicker.d.ts +2 -2
- package/DateTimePicker/DateTimePicker.js +2 -3
- package/MonthPicker/MonthPicker.js +5 -5
- package/YearPicker/YearPicker.js +4 -4
- package/index.js +1 -1
- package/legacy/DateTimePicker/DateTimePicker.js +2 -3
- package/legacy/MonthPicker/MonthPicker.js +7 -5
- package/legacy/YearPicker/YearPicker.js +6 -4
- package/legacy/index.js +1 -1
- package/modern/DateTimePicker/DateTimePicker.js +2 -3
- package/modern/MonthPicker/MonthPicker.js +5 -5
- package/modern/YearPicker/YearPicker.js +4 -4
- package/modern/index.js +1 -1
- package/node/MonthPicker/MonthPicker.js +5 -5
- package/node/YearPicker/YearPicker.js +4 -4
- package/node/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,77 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.17.16
|
|
7
|
+
|
|
8
|
+
_Dec 16, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🐞 Bugfixes
|
|
13
|
+
|
|
14
|
+
### `@mui/x-data-grid@v5.17.16` / `@mui/x-data-grid-pro@v5.17.16` / `@mui/x-data-grid-premium@v5.17.16`
|
|
15
|
+
|
|
16
|
+
#### Changes
|
|
17
|
+
|
|
18
|
+
- [DataGrid] Display sort column menu items as per `sortingOrder` prop (#7125) @hanbin9775
|
|
19
|
+
- [DataGrid] Fix flickering on mount (#7155) @cherniavskii
|
|
20
|
+
- [DataGridPremium] Use separate cache for aggregation columns pre-processor (#7174) @m4theushw
|
|
21
|
+
|
|
22
|
+
### `@mui/x-date-pickers@v5.0.11` / `@mui/x-date-pickers-pro@v5.0.11`
|
|
23
|
+
|
|
24
|
+
#### Changes
|
|
25
|
+
|
|
26
|
+
- [DateTimePicker] Update export pattern (#7172) @kealjones-wk
|
|
27
|
+
|
|
28
|
+
### Docs
|
|
29
|
+
|
|
30
|
+
- [docs] Document aggregation selectors (#7151) @cherniavskii
|
|
31
|
+
|
|
32
|
+
## 5.17.15
|
|
33
|
+
|
|
34
|
+
_Dec 8, 2022_
|
|
35
|
+
|
|
36
|
+
We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
|
|
37
|
+
|
|
38
|
+
- ✨ Fix lazy-loading not working in `DataGridPremium` (#7130) @m4theushw
|
|
39
|
+
- 🐞 Bugfixes
|
|
40
|
+
|
|
41
|
+
### `@mui/x-data-grid@v5.17.15` / `@mui/x-data-grid-pro@v5.17.15` / `@mui/x-data-grid-premium@v5.17.15`
|
|
42
|
+
|
|
43
|
+
#### Changes
|
|
44
|
+
|
|
45
|
+
- [DataGridPremium] Add support for lazy-loading (#7130) @m4theushw
|
|
46
|
+
- [DataGridPremium] Pass `groupId` to the aggregation function (#7143) @m4theushw
|
|
47
|
+
|
|
48
|
+
### `@mui/x-date-pickers@v5.0.10` / `@mui/x-date-pickers-pro@v5.0.10`
|
|
49
|
+
|
|
50
|
+
#### Changes
|
|
51
|
+
|
|
52
|
+
- [pickers] Initialize date without time when selecting year or month (#7136) @LukasTy
|
|
53
|
+
|
|
54
|
+
### Docs
|
|
55
|
+
|
|
56
|
+
- [docs] Fix the nested import on the api pages (#7134) @flaviendelangle
|
|
57
|
+
- [docs] Keep track of the localization completion (#7099) @alexfauquette
|
|
58
|
+
- [docs] Update localization doc to use existing locale (#7104) @LukasTy
|
|
59
|
+
|
|
60
|
+
## 5.17.14
|
|
61
|
+
|
|
62
|
+
_Dec 1, 2022_
|
|
63
|
+
|
|
64
|
+
We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
|
|
65
|
+
|
|
66
|
+
- 🌍 Improve Ukrainian (uk-UA) locale (#7035) @rettoua
|
|
67
|
+
- 🐞 Bugfixes
|
|
68
|
+
|
|
69
|
+
### `@mui/x-data-grid@v5.17.14` / `@mui/x-data-grid-pro@v5.17.14` / `@mui/x-data-grid-premium@v5.17.14`
|
|
70
|
+
|
|
71
|
+
#### Changes
|
|
72
|
+
|
|
73
|
+
- [DataGrid] Fix row selection when clicking blank cell (#7056) @yami03
|
|
74
|
+
- [DataGridPremium] Update cache before hydrating columns (#7043) @m4theushw
|
|
75
|
+
- [l10n] Improve Ukrainian (uk-UA) locale (#7035) @rettoua
|
|
76
|
+
|
|
6
77
|
## 5.17.13
|
|
7
78
|
|
|
8
79
|
_Nov 24, 2022_
|
|
@@ -37,5 +37,5 @@ declare type DateTimePickerComponent = (<TInputDate, TDate = TInputDate>(props:
|
|
|
37
37
|
*
|
|
38
38
|
* - [DateTimePicker API](https://mui.com/x/api/date-pickers/date-time-picker/)
|
|
39
39
|
*/
|
|
40
|
-
declare const DateTimePicker: DateTimePickerComponent;
|
|
41
|
-
export {
|
|
40
|
+
export declare const DateTimePicker: DateTimePickerComponent;
|
|
41
|
+
export {};
|
|
@@ -20,7 +20,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
20
20
|
*
|
|
21
21
|
* - [DateTimePicker API](https://mui.com/x/api/date-pickers/date-time-picker/)
|
|
22
22
|
*/
|
|
23
|
-
const DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
23
|
+
export const DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
24
24
|
const props = useThemeProps({
|
|
25
25
|
props: inProps,
|
|
26
26
|
name: 'MuiDateTimePicker'
|
|
@@ -529,5 +529,4 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
529
529
|
* @default ['year', 'day', 'hours', 'minutes']
|
|
530
530
|
*/
|
|
531
531
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'minutes', 'month', 'seconds', 'year']).isRequired)
|
|
532
|
-
} : void 0;
|
|
533
|
-
export { DateTimePicker };
|
|
532
|
+
} : void 0;
|
|
@@ -76,7 +76,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
76
76
|
const ownerState = props;
|
|
77
77
|
const classes = useUtilityClasses(ownerState);
|
|
78
78
|
const theme = useTheme();
|
|
79
|
-
const
|
|
79
|
+
const selectedDateOrStartOfMonth = React.useMemo(() => date != null ? date : utils.startOfMonth(now), [now, utils, date]);
|
|
80
80
|
const selectedMonth = React.useMemo(() => {
|
|
81
81
|
if (date != null) {
|
|
82
82
|
return utils.getMonth(date);
|
|
@@ -113,7 +113,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const newDate = utils.setMonth(
|
|
116
|
+
const newDate = utils.setMonth(selectedDateOrStartOfMonth, month);
|
|
117
117
|
onChange(newDate, 'finish');
|
|
118
118
|
};
|
|
119
119
|
|
|
@@ -131,7 +131,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
131
131
|
}
|
|
132
132
|
}, [setInternalHasFocus, onFocusedViewChange]);
|
|
133
133
|
const focusMonth = React.useCallback(month => {
|
|
134
|
-
if (!isMonthDisabled(utils.setMonth(
|
|
134
|
+
if (!isMonthDisabled(utils.setMonth(selectedDateOrStartOfMonth, month))) {
|
|
135
135
|
setFocusedMonth(month);
|
|
136
136
|
changeHasFocus(true);
|
|
137
137
|
|
|
@@ -139,7 +139,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
139
139
|
onMonthFocus(month);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
}, [
|
|
142
|
+
}, [isMonthDisabled, utils, selectedDateOrStartOfMonth, changeHasFocus, onMonthFocus]);
|
|
143
143
|
React.useEffect(() => {
|
|
144
144
|
setFocusedMonth(prevFocusedMonth => selectedMonth !== null && prevFocusedMonth !== selectedMonth ? selectedMonth : prevFocusedMonth);
|
|
145
145
|
}, [selectedMonth]);
|
|
@@ -185,7 +185,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
185
185
|
ownerState: ownerState,
|
|
186
186
|
onKeyDown: handleKeyDown
|
|
187
187
|
}, other, {
|
|
188
|
-
children: utils.getMonthArray(
|
|
188
|
+
children: utils.getMonthArray(selectedDateOrStartOfMonth).map(month => {
|
|
189
189
|
const monthNumber = utils.getMonth(month);
|
|
190
190
|
const monthText = utils.format(month, 'monthShort');
|
|
191
191
|
const isDisabled = disabled || isMonthDisabled(month);
|
package/YearPicker/YearPicker.js
CHANGED
|
@@ -76,7 +76,7 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
76
76
|
} = props;
|
|
77
77
|
const ownerState = props;
|
|
78
78
|
const classes = useUtilityClasses(ownerState);
|
|
79
|
-
const
|
|
79
|
+
const selectedDateOrStartOfYear = React.useMemo(() => date != null ? date : utils.startOfYear(now), [now, utils, date]);
|
|
80
80
|
const currentYear = React.useMemo(() => {
|
|
81
81
|
if (date != null) {
|
|
82
82
|
return utils.getYear(date);
|
|
@@ -133,17 +133,17 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const newDate = utils.setYear(
|
|
136
|
+
const newDate = utils.setYear(selectedDateOrStartOfYear, year);
|
|
137
137
|
onChange(newDate, isFinish);
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
const focusYear = React.useCallback(year => {
|
|
141
|
-
if (!isYearDisabled(utils.setYear(
|
|
141
|
+
if (!isYearDisabled(utils.setYear(selectedDateOrStartOfYear, year))) {
|
|
142
142
|
setFocusedYear(year);
|
|
143
143
|
changeHasFocus(true);
|
|
144
144
|
onYearFocus == null ? void 0 : onYearFocus(year);
|
|
145
145
|
}
|
|
146
|
-
}, [isYearDisabled, utils,
|
|
146
|
+
}, [isYearDisabled, utils, selectedDateOrStartOfYear, changeHasFocus, onYearFocus]);
|
|
147
147
|
React.useEffect(() => {
|
|
148
148
|
setFocusedYear(prevFocusedYear => currentYear !== null && prevFocusedYear !== currentYear ? currentYear : prevFocusedYear);
|
|
149
149
|
}, [currentYear]);
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
20
20
|
*
|
|
21
21
|
* - [DateTimePicker API](https://mui.com/x/api/date-pickers/date-time-picker/)
|
|
22
22
|
*/
|
|
23
|
-
var DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
23
|
+
export var DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
24
24
|
var props = useThemeProps({
|
|
25
25
|
props: inProps,
|
|
26
26
|
name: 'MuiDateTimePicker'
|
|
@@ -528,5 +528,4 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
528
528
|
* @default ['year', 'day', 'hours', 'minutes']
|
|
529
529
|
*/
|
|
530
530
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'minutes', 'month', 'seconds', 'year']).isRequired)
|
|
531
|
-
} : void 0;
|
|
532
|
-
export { DateTimePicker };
|
|
531
|
+
} : void 0;
|
|
@@ -76,7 +76,9 @@ export var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inPr
|
|
|
76
76
|
var ownerState = props;
|
|
77
77
|
var classes = useUtilityClasses(ownerState);
|
|
78
78
|
var theme = useTheme();
|
|
79
|
-
var
|
|
79
|
+
var selectedDateOrStartOfMonth = React.useMemo(function () {
|
|
80
|
+
return date != null ? date : utils.startOfMonth(now);
|
|
81
|
+
}, [now, utils, date]);
|
|
80
82
|
var selectedMonth = React.useMemo(function () {
|
|
81
83
|
if (date != null) {
|
|
82
84
|
return utils.getMonth(date);
|
|
@@ -120,7 +122,7 @@ export var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inPr
|
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
var newDate = utils.setMonth(
|
|
125
|
+
var newDate = utils.setMonth(selectedDateOrStartOfMonth, month);
|
|
124
126
|
onChange(newDate, 'finish');
|
|
125
127
|
};
|
|
126
128
|
|
|
@@ -142,7 +144,7 @@ export var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inPr
|
|
|
142
144
|
}
|
|
143
145
|
}, [setInternalHasFocus, onFocusedViewChange]);
|
|
144
146
|
var focusMonth = React.useCallback(function (month) {
|
|
145
|
-
if (!isMonthDisabled(utils.setMonth(
|
|
147
|
+
if (!isMonthDisabled(utils.setMonth(selectedDateOrStartOfMonth, month))) {
|
|
146
148
|
setFocusedMonth(month);
|
|
147
149
|
changeHasFocus(true);
|
|
148
150
|
|
|
@@ -150,7 +152,7 @@ export var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inPr
|
|
|
150
152
|
onMonthFocus(month);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
|
-
}, [
|
|
155
|
+
}, [isMonthDisabled, utils, selectedDateOrStartOfMonth, changeHasFocus, onMonthFocus]);
|
|
154
156
|
React.useEffect(function () {
|
|
155
157
|
setFocusedMonth(function (prevFocusedMonth) {
|
|
156
158
|
return selectedMonth !== null && prevFocusedMonth !== selectedMonth ? selectedMonth : prevFocusedMonth;
|
|
@@ -198,7 +200,7 @@ export var MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inPr
|
|
|
198
200
|
ownerState: ownerState,
|
|
199
201
|
onKeyDown: handleKeyDown
|
|
200
202
|
}, other, {
|
|
201
|
-
children: utils.getMonthArray(
|
|
203
|
+
children: utils.getMonthArray(selectedDateOrStartOfMonth).map(function (month) {
|
|
202
204
|
var monthNumber = utils.getMonth(month);
|
|
203
205
|
var monthText = utils.format(month, 'monthShort');
|
|
204
206
|
var isDisabled = disabled || isMonthDisabled(month);
|
|
@@ -75,7 +75,9 @@ export var YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProp
|
|
|
75
75
|
onFocusedViewChange = props.onFocusedViewChange;
|
|
76
76
|
var ownerState = props;
|
|
77
77
|
var classes = useUtilityClasses(ownerState);
|
|
78
|
-
var
|
|
78
|
+
var selectedDateOrStartOfYear = React.useMemo(function () {
|
|
79
|
+
return date != null ? date : utils.startOfYear(now);
|
|
80
|
+
}, [now, utils, date]);
|
|
79
81
|
var currentYear = React.useMemo(function () {
|
|
80
82
|
if (date != null) {
|
|
81
83
|
return utils.getYear(date);
|
|
@@ -145,17 +147,17 @@ export var YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProp
|
|
|
145
147
|
return;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
var newDate = utils.setYear(
|
|
150
|
+
var newDate = utils.setYear(selectedDateOrStartOfYear, year);
|
|
149
151
|
onChange(newDate, isFinish);
|
|
150
152
|
};
|
|
151
153
|
|
|
152
154
|
var focusYear = React.useCallback(function (year) {
|
|
153
|
-
if (!isYearDisabled(utils.setYear(
|
|
155
|
+
if (!isYearDisabled(utils.setYear(selectedDateOrStartOfYear, year))) {
|
|
154
156
|
setFocusedYear(year);
|
|
155
157
|
changeHasFocus(true);
|
|
156
158
|
onYearFocus == null ? void 0 : onYearFocus(year);
|
|
157
159
|
}
|
|
158
|
-
}, [isYearDisabled, utils,
|
|
160
|
+
}, [isYearDisabled, utils, selectedDateOrStartOfYear, changeHasFocus, onYearFocus]);
|
|
159
161
|
React.useEffect(function () {
|
|
160
162
|
setFocusedYear(function (prevFocusedYear) {
|
|
161
163
|
return currentYear !== null && prevFocusedYear !== currentYear ? currentYear : prevFocusedYear;
|
package/legacy/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
20
20
|
*
|
|
21
21
|
* - [DateTimePicker API](https://mui.com/x/api/date-pickers/date-time-picker/)
|
|
22
22
|
*/
|
|
23
|
-
const DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
23
|
+
export const DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
24
24
|
const props = useThemeProps({
|
|
25
25
|
props: inProps,
|
|
26
26
|
name: 'MuiDateTimePicker'
|
|
@@ -529,5 +529,4 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
529
529
|
* @default ['year', 'day', 'hours', 'minutes']
|
|
530
530
|
*/
|
|
531
531
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'minutes', 'month', 'seconds', 'year']).isRequired)
|
|
532
|
-
} : void 0;
|
|
533
|
-
export { DateTimePicker };
|
|
532
|
+
} : void 0;
|
|
@@ -76,7 +76,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
76
76
|
const ownerState = props;
|
|
77
77
|
const classes = useUtilityClasses(ownerState);
|
|
78
78
|
const theme = useTheme();
|
|
79
|
-
const
|
|
79
|
+
const selectedDateOrStartOfMonth = React.useMemo(() => date ?? utils.startOfMonth(now), [now, utils, date]);
|
|
80
80
|
const selectedMonth = React.useMemo(() => {
|
|
81
81
|
if (date != null) {
|
|
82
82
|
return utils.getMonth(date);
|
|
@@ -113,7 +113,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const newDate = utils.setMonth(
|
|
116
|
+
const newDate = utils.setMonth(selectedDateOrStartOfMonth, month);
|
|
117
117
|
onChange(newDate, 'finish');
|
|
118
118
|
};
|
|
119
119
|
|
|
@@ -131,7 +131,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
131
131
|
}
|
|
132
132
|
}, [setInternalHasFocus, onFocusedViewChange]);
|
|
133
133
|
const focusMonth = React.useCallback(month => {
|
|
134
|
-
if (!isMonthDisabled(utils.setMonth(
|
|
134
|
+
if (!isMonthDisabled(utils.setMonth(selectedDateOrStartOfMonth, month))) {
|
|
135
135
|
setFocusedMonth(month);
|
|
136
136
|
changeHasFocus(true);
|
|
137
137
|
|
|
@@ -139,7 +139,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
139
139
|
onMonthFocus(month);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
}, [
|
|
142
|
+
}, [isMonthDisabled, utils, selectedDateOrStartOfMonth, changeHasFocus, onMonthFocus]);
|
|
143
143
|
React.useEffect(() => {
|
|
144
144
|
setFocusedMonth(prevFocusedMonth => selectedMonth !== null && prevFocusedMonth !== selectedMonth ? selectedMonth : prevFocusedMonth);
|
|
145
145
|
}, [selectedMonth]);
|
|
@@ -185,7 +185,7 @@ export const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(in
|
|
|
185
185
|
ownerState: ownerState,
|
|
186
186
|
onKeyDown: handleKeyDown
|
|
187
187
|
}, other, {
|
|
188
|
-
children: utils.getMonthArray(
|
|
188
|
+
children: utils.getMonthArray(selectedDateOrStartOfMonth).map(month => {
|
|
189
189
|
const monthNumber = utils.getMonth(month);
|
|
190
190
|
const monthText = utils.format(month, 'monthShort');
|
|
191
191
|
const isDisabled = disabled || isMonthDisabled(month);
|
|
@@ -76,7 +76,7 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
76
76
|
} = props;
|
|
77
77
|
const ownerState = props;
|
|
78
78
|
const classes = useUtilityClasses(ownerState);
|
|
79
|
-
const
|
|
79
|
+
const selectedDateOrStartOfYear = React.useMemo(() => date ?? utils.startOfYear(now), [now, utils, date]);
|
|
80
80
|
const currentYear = React.useMemo(() => {
|
|
81
81
|
if (date != null) {
|
|
82
82
|
return utils.getYear(date);
|
|
@@ -133,17 +133,17 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const newDate = utils.setYear(
|
|
136
|
+
const newDate = utils.setYear(selectedDateOrStartOfYear, year);
|
|
137
137
|
onChange(newDate, isFinish);
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
const focusYear = React.useCallback(year => {
|
|
141
|
-
if (!isYearDisabled(utils.setYear(
|
|
141
|
+
if (!isYearDisabled(utils.setYear(selectedDateOrStartOfYear, year))) {
|
|
142
142
|
setFocusedYear(year);
|
|
143
143
|
changeHasFocus(true);
|
|
144
144
|
onYearFocus?.(year);
|
|
145
145
|
}
|
|
146
|
-
}, [isYearDisabled, utils,
|
|
146
|
+
}, [isYearDisabled, utils, selectedDateOrStartOfYear, changeHasFocus, onYearFocus]);
|
|
147
147
|
React.useEffect(() => {
|
|
148
148
|
setFocusedYear(prevFocusedYear => currentYear !== null && prevFocusedYear !== currentYear ? currentYear : prevFocusedYear);
|
|
149
149
|
}, [currentYear]);
|
package/modern/index.js
CHANGED
|
@@ -102,7 +102,7 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
|
|
|
102
102
|
const ownerState = props;
|
|
103
103
|
const classes = useUtilityClasses(ownerState);
|
|
104
104
|
const theme = (0, _system.useTheme)();
|
|
105
|
-
const
|
|
105
|
+
const selectedDateOrStartOfMonth = React.useMemo(() => date != null ? date : utils.startOfMonth(now), [now, utils, date]);
|
|
106
106
|
const selectedMonth = React.useMemo(() => {
|
|
107
107
|
if (date != null) {
|
|
108
108
|
return utils.getMonth(date);
|
|
@@ -139,7 +139,7 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
|
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
const newDate = utils.setMonth(
|
|
142
|
+
const newDate = utils.setMonth(selectedDateOrStartOfMonth, month);
|
|
143
143
|
onChange(newDate, 'finish');
|
|
144
144
|
};
|
|
145
145
|
|
|
@@ -157,7 +157,7 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
|
|
|
157
157
|
}
|
|
158
158
|
}, [setInternalHasFocus, onFocusedViewChange]);
|
|
159
159
|
const focusMonth = React.useCallback(month => {
|
|
160
|
-
if (!isMonthDisabled(utils.setMonth(
|
|
160
|
+
if (!isMonthDisabled(utils.setMonth(selectedDateOrStartOfMonth, month))) {
|
|
161
161
|
setFocusedMonth(month);
|
|
162
162
|
changeHasFocus(true);
|
|
163
163
|
|
|
@@ -165,7 +165,7 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
|
|
|
165
165
|
onMonthFocus(month);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
}, [
|
|
168
|
+
}, [isMonthDisabled, utils, selectedDateOrStartOfMonth, changeHasFocus, onMonthFocus]);
|
|
169
169
|
React.useEffect(() => {
|
|
170
170
|
setFocusedMonth(prevFocusedMonth => selectedMonth !== null && prevFocusedMonth !== selectedMonth ? selectedMonth : prevFocusedMonth);
|
|
171
171
|
}, [selectedMonth]);
|
|
@@ -211,7 +211,7 @@ const MonthPicker = /*#__PURE__*/React.forwardRef(function MonthPicker(inProps,
|
|
|
211
211
|
ownerState: ownerState,
|
|
212
212
|
onKeyDown: handleKeyDown
|
|
213
213
|
}, other, {
|
|
214
|
-
children: utils.getMonthArray(
|
|
214
|
+
children: utils.getMonthArray(selectedDateOrStartOfMonth).map(month => {
|
|
215
215
|
const monthNumber = utils.getMonth(month);
|
|
216
216
|
const monthText = utils.format(month, 'monthShort');
|
|
217
217
|
const isDisabled = disabled || isMonthDisabled(month);
|
|
@@ -102,7 +102,7 @@ const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, re
|
|
|
102
102
|
} = props;
|
|
103
103
|
const ownerState = props;
|
|
104
104
|
const classes = useUtilityClasses(ownerState);
|
|
105
|
-
const
|
|
105
|
+
const selectedDateOrStartOfYear = React.useMemo(() => date != null ? date : utils.startOfYear(now), [now, utils, date]);
|
|
106
106
|
const currentYear = React.useMemo(() => {
|
|
107
107
|
if (date != null) {
|
|
108
108
|
return utils.getYear(date);
|
|
@@ -159,17 +159,17 @@ const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, re
|
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const newDate = utils.setYear(
|
|
162
|
+
const newDate = utils.setYear(selectedDateOrStartOfYear, year);
|
|
163
163
|
onChange(newDate, isFinish);
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
const focusYear = React.useCallback(year => {
|
|
167
|
-
if (!isYearDisabled(utils.setYear(
|
|
167
|
+
if (!isYearDisabled(utils.setYear(selectedDateOrStartOfYear, year))) {
|
|
168
168
|
setFocusedYear(year);
|
|
169
169
|
changeHasFocus(true);
|
|
170
170
|
onYearFocus == null ? void 0 : onYearFocus(year);
|
|
171
171
|
}
|
|
172
|
-
}, [isYearDisabled, utils,
|
|
172
|
+
}, [isYearDisabled, utils, selectedDateOrStartOfYear, changeHasFocus, onYearFocus]);
|
|
173
173
|
React.useEffect(() => {
|
|
174
174
|
setFocusedYear(prevFocusedYear => currentYear !== null && prevFocusedYear !== currentYear ? currentYear : prevFocusedYear);
|
|
175
175
|
}, [currentYear]);
|
package/node/index.js
CHANGED