@mui/x-date-pickers 8.5.3 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -0
- package/DateCalendar/DateCalendar.js +16 -16
- package/DateCalendar/DayCalendar.js +48 -48
- package/DateCalendar/useCalendarState.js +25 -25
- package/DateCalendar/useIsDateDisabled.js +2 -2
- package/DatePicker/DatePickerToolbar.js +7 -9
- package/DateTimeField/DateTimeField.js +1 -1
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +12 -13
- package/DateTimePicker/shared.js +3 -3
- package/DesktopDatePicker/DesktopDatePicker.js +3 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
- package/DesktopTimePicker/DesktopTimePicker.js +4 -4
- package/DigitalClock/DigitalClock.d.ts +1 -1
- package/DigitalClock/DigitalClock.js +16 -16
- package/LocalizationProvider/LocalizationProvider.d.ts +9 -3
- package/LocalizationProvider/LocalizationProvider.js +28 -19
- package/MobileDatePicker/MobileDatePicker.js +3 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
- package/MobileTimePicker/MobileTimePicker.js +4 -4
- package/MonthCalendar/MonthCalendar.js +19 -18
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
- package/PickerDay2/PickerDay2.js +3 -3
- package/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/PickersActionBar/PickersActionBar.js +2 -2
- package/PickersCalendarHeader/PickersCalendarHeader.js +7 -8
- package/PickersDay/PickersDay.js +3 -3
- package/PickersDay/usePickerDayOwnerState.js +5 -5
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/StaticTimePicker/StaticTimePicker.js +1 -1
- package/TimeClock/Clock.js +8 -9
- package/TimeClock/ClockNumbers.d.ts +3 -3
- package/TimeClock/ClockNumbers.js +5 -5
- package/TimeClock/TimeClock.js +29 -29
- package/TimeField/TimeField.js +1 -1
- package/TimePicker/TimePicker.js +1 -1
- package/TimePicker/TimePickerToolbar.js +7 -9
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +19 -18
- package/esm/DateCalendar/DateCalendar.js +16 -16
- package/esm/DateCalendar/DayCalendar.js +48 -48
- package/esm/DateCalendar/useCalendarState.js +25 -25
- package/esm/DateCalendar/useIsDateDisabled.js +2 -2
- package/esm/DatePicker/DatePickerToolbar.js +6 -8
- package/esm/DateTimeField/DateTimeField.js +1 -1
- package/esm/DateTimePicker/DateTimePicker.js +1 -1
- package/esm/DateTimePicker/DateTimePickerToolbar.js +11 -12
- package/esm/DateTimePicker/shared.js +3 -3
- package/esm/DesktopDatePicker/DesktopDatePicker.js +3 -3
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
- package/esm/DesktopTimePicker/DesktopTimePicker.js +4 -4
- package/esm/DigitalClock/DigitalClock.d.ts +1 -1
- package/esm/DigitalClock/DigitalClock.js +16 -16
- package/esm/LocalizationProvider/LocalizationProvider.d.ts +9 -3
- package/esm/LocalizationProvider/LocalizationProvider.js +27 -18
- package/esm/MobileDatePicker/MobileDatePicker.js +3 -3
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
- package/esm/MobileTimePicker/MobileTimePicker.js +4 -4
- package/esm/MonthCalendar/MonthCalendar.js +20 -19
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
- package/esm/PickerDay2/PickerDay2.js +3 -3
- package/esm/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/esm/PickersActionBar/PickersActionBar.js +2 -2
- package/esm/PickersCalendarHeader/PickersCalendarHeader.js +6 -7
- package/esm/PickersDay/PickersDay.js +3 -3
- package/esm/PickersDay/usePickerDayOwnerState.js +5 -5
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
- package/esm/TimeClock/Clock.js +7 -8
- package/esm/TimeClock/ClockNumbers.d.ts +3 -3
- package/esm/TimeClock/ClockNumbers.js +5 -5
- package/esm/TimeClock/TimeClock.js +29 -29
- package/esm/TimeField/TimeField.js +1 -1
- package/esm/TimePicker/TimePicker.js +1 -1
- package/esm/TimePicker/TimePickerToolbar.js +6 -8
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +20 -19
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useParsedFormat.js +6 -6
- package/esm/hooks/usePickerAdapter.d.ts +7 -0
- package/esm/hooks/usePickerAdapter.js +20 -0
- package/esm/hooks/usePickerTranslations.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/pickersToolbarClasses.d.ts +1 -1
- package/esm/internals/demo/DemoContainer.d.ts +2 -3
- package/esm/internals/demo/DemoContainer.js +3 -2
- package/esm/internals/hooks/date-helpers-hooks.js +16 -16
- package/esm/internals/hooks/useClockReferenceDate.d.ts +2 -2
- package/esm/internals/hooks/useClockReferenceDate.js +3 -3
- package/esm/internals/hooks/useControlledValue.js +8 -7
- package/esm/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/esm/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
- package/esm/internals/hooks/useField/useField.types.d.ts +2 -2
- package/esm/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/esm/internals/hooks/useField/useField.utils.js +69 -69
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +15 -16
- package/esm/internals/hooks/useField/useFieldState.js +22 -24
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
- package/esm/internals/hooks/usePicker/usePicker.js +5 -6
- package/esm/internals/hooks/useUtils.d.ts +1 -8
- package/esm/internals/hooks/useUtils.js +3 -19
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/models/manager.d.ts +14 -14
- package/esm/internals/models/props/time.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.js +5 -5
- package/esm/internals/utils/date-utils.d.ts +11 -11
- package/esm/internals/utils/date-utils.js +34 -34
- package/esm/internals/utils/getDefaultReferenceDate.d.ts +2 -2
- package/esm/internals/utils/getDefaultReferenceDate.js +16 -16
- package/esm/internals/utils/time-utils.d.ts +5 -5
- package/esm/internals/utils/time-utils.js +12 -12
- package/esm/internals/utils/valueManagers.js +4 -4
- package/esm/managers/useDateManager.js +12 -12
- package/esm/managers/useDateTimeManager.js +13 -13
- package/esm/managers/useTimeManager.js +9 -10
- package/esm/validation/useValidation.d.ts +2 -3
- package/esm/validation/useValidation.js +2 -2
- package/esm/validation/validateDate.js +6 -6
- package/esm/validation/validateTime.js +6 -6
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +8 -1
- package/hooks/useParsedFormat.js +6 -6
- package/hooks/usePickerAdapter.d.ts +7 -0
- package/hooks/usePickerAdapter.js +29 -0
- package/hooks/usePickerTranslations.js +2 -2
- package/index.js +1 -1
- package/internals/components/pickersToolbarClasses.d.ts +1 -1
- package/internals/demo/DemoContainer.d.ts +2 -3
- package/internals/demo/DemoContainer.js +3 -2
- package/internals/hooks/date-helpers-hooks.js +16 -16
- package/internals/hooks/useClockReferenceDate.d.ts +2 -2
- package/internals/hooks/useClockReferenceDate.js +3 -3
- package/internals/hooks/useControlledValue.js +7 -7
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/internals/hooks/useField/useField.utils.js +69 -69
- package/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
- package/internals/hooks/useField/useFieldSectionContentProps.js +14 -15
- package/internals/hooks/useField/useFieldState.js +23 -25
- package/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
- package/internals/hooks/usePicker/usePicker.js +5 -6
- package/internals/hooks/useUtils.d.ts +1 -8
- package/internals/hooks/useUtils.js +5 -24
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -7
- package/internals/models/manager.d.ts +14 -14
- package/internals/models/props/time.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +1 -1
- package/internals/utils/date-time-utils.js +5 -5
- package/internals/utils/date-utils.d.ts +11 -11
- package/internals/utils/date-utils.js +34 -34
- package/internals/utils/getDefaultReferenceDate.d.ts +2 -2
- package/internals/utils/getDefaultReferenceDate.js +16 -16
- package/internals/utils/time-utils.d.ts +5 -5
- package/internals/utils/time-utils.js +12 -12
- package/internals/utils/valueManagers.js +4 -4
- package/managers/useDateManager.js +12 -12
- package/managers/useDateTimeManager.js +13 -13
- package/managers/useTimeManager.js +10 -11
- package/package.json +2 -2
- package/validation/useValidation.d.ts +2 -3
- package/validation/useValidation.js +2 -2
- package/validation/validateDate.js +6 -6
- package/validation/validateTime.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,113 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.6.0
|
|
9
|
+
|
|
10
|
+
_Jun 27, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 📊 Add export menu to charts toolbar
|
|
15
|
+
- 📅 Add `usePickerAdapter` hook to access the date adapter.
|
|
16
|
+
|
|
17
|
+
You can use the adapter in your custom components if you need them to work with multiple date libraries — [Learn more](https://mui.com/x/react-date-pickers/custom-components/#access-date-adapter).
|
|
18
|
+
- 🌎 Improve Danish (da-DK) locale
|
|
19
|
+
- 🌎 Improve German (de-DE) locale
|
|
20
|
+
|
|
21
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
22
|
+
@ShahrazH, @vadimka123
|
|
23
|
+
|
|
24
|
+
The following are all team members who have contributed to this release:
|
|
25
|
+
@arminmeh, @bernardobelchior, @JCQuintas, @KenanYusuf, @LukasTy, @MBilalShafi, @michelengelen, @noraleonte, @rita-codes, @sai6855
|
|
26
|
+
|
|
27
|
+
### Data Grid
|
|
28
|
+
|
|
29
|
+
#### `@mui/x-data-grid@8.6.0`
|
|
30
|
+
|
|
31
|
+
- [DataGrid] Fix `label` type in `GridActionsCellItem` type (#18175) @sai6855
|
|
32
|
+
- [DataGrid] Fix grid menu not closing when pressing escape/tab (#18300) @KenanYusuf
|
|
33
|
+
- [l10n] Improve Danish (da-DK) locale (#18428) @ShahrazH
|
|
34
|
+
- [l10n] Improve German (de-DE) locale (#18388) @omalyutin
|
|
35
|
+
|
|
36
|
+
#### `@mui/x-data-grid-pro@8.6.0` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
37
|
+
|
|
38
|
+
Same changes as in `@mui/x-data-grid@8.6.0`, plus:
|
|
39
|
+
|
|
40
|
+
- [DataGridPro] Fix lazy loading params calculated from rendering context (#18460) @arminmeh
|
|
41
|
+
|
|
42
|
+
#### `@mui/x-data-grid-premium@8.6.0` [](https://mui.com/r/x-premium-svg-link "Premium plan")
|
|
43
|
+
|
|
44
|
+
Same changes as in `@mui/x-data-grid-pro@8.6.0`.
|
|
45
|
+
|
|
46
|
+
### Date and Time Pickers
|
|
47
|
+
|
|
48
|
+
#### `@mui/x-date-pickers@8.6.0`
|
|
49
|
+
|
|
50
|
+
- [pickers] Add `usePickerAdapter` hook (#18457) @LukasTy
|
|
51
|
+
- [pickers] Fix to use latest `value` when updating `lastCommittedValue` in internal state (#18518) @LukasTy
|
|
52
|
+
- [pickers] Use `usePickerAdapter` hook internally instead of `useUtils` (#18465) @LukasTy
|
|
53
|
+
|
|
54
|
+
#### `@mui/x-date-pickers-pro@8.6.0` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
55
|
+
|
|
56
|
+
Same changes as in `@mui/x-date-pickers@8.6.0`.
|
|
57
|
+
|
|
58
|
+
### Charts
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-charts@8.6.0`
|
|
61
|
+
|
|
62
|
+
- [charts] Add `data-series` to charts legend item (#18414) @bernardobelchior
|
|
63
|
+
- [charts] Add `data-series` to bar charts (#18413) @bernardobelchior
|
|
64
|
+
- [charts] Add `data-series` to elements of line chart (#18409) @bernardobelchior
|
|
65
|
+
- [charts] Add `data-series` to pie charts (#18432) @bernardobelchior
|
|
66
|
+
- [charts] Fix missing key in bar plot (#18502) @bernardobelchior
|
|
67
|
+
- [charts] Split axis utils from main file (#18517) @JCQuintas
|
|
68
|
+
- [charts] Improve touch behavior for polar axis (#18531) @JCQuintas
|
|
69
|
+
- [charts] Add `isElementInside` helper (#18530) @JCQuintas
|
|
70
|
+
|
|
71
|
+
#### `@mui/x-charts-pro@8.6.0` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
72
|
+
|
|
73
|
+
Same changes as in `@mui/x-charts@8.6.0`, plus:
|
|
74
|
+
|
|
75
|
+
- [charts-pro] Add export menu to charts toolbar (#18210) @bernardobelchior
|
|
76
|
+
- [charts-pro] Fix export docs mentioning tooltip instead of toolbar (#18490) @bernardobelchior
|
|
77
|
+
- [charts-pro] Fix iframe not being removed after print export (#18500) @bernardobelchior
|
|
78
|
+
|
|
79
|
+
### Tree View
|
|
80
|
+
|
|
81
|
+
#### `@mui/x-tree-view@8.6.0`
|
|
82
|
+
|
|
83
|
+
Internal changes.
|
|
84
|
+
|
|
85
|
+
#### `@mui/x-tree-view-pro@8.6.0` [](https://mui.com/r/x-pro-svg-link "Pro plan")
|
|
86
|
+
|
|
87
|
+
Same changes as in `@mui/x-tree-view@8.6.0`, plus:
|
|
88
|
+
|
|
89
|
+
- [tree view pro] Fix theme augmentation (#18437) @LukasTy
|
|
90
|
+
|
|
91
|
+
### Codemod
|
|
92
|
+
|
|
93
|
+
#### `@mui/x-codemod@8.6.0`
|
|
94
|
+
|
|
95
|
+
Internal changes.
|
|
96
|
+
|
|
97
|
+
### Docs
|
|
98
|
+
|
|
99
|
+
- [docs] Document `GridRenderContext` (#18492) @arminmeh
|
|
100
|
+
- [docs] Prevent stale rows to appear on sort and filter change in the lazy loading demo (#18461) @arminmeh
|
|
101
|
+
- [docs][pickers] Update action bar demo to use the `nextOrAccept` action (#18505) @LukasTy
|
|
102
|
+
- [docs] Update indeterminate checkbox section in migration guide (#18229) @michelengelen
|
|
103
|
+
- [docs] Data source nested pagination recipe (#14777) @MBilalShafi
|
|
104
|
+
|
|
105
|
+
### Core
|
|
106
|
+
|
|
107
|
+
- [core] Avoid json stringify whole window object (#18512) @vadimka123
|
|
108
|
+
|
|
109
|
+
### Miscellaneous
|
|
110
|
+
|
|
111
|
+
- [code-infra] Dynamically get pickers adapters dependencies versions (#18446) @JCQuintas
|
|
112
|
+
- [infra] Adjust inquirer version and usage (#18495) @michelengelen
|
|
113
|
+
- [infra] Use `String.raw` for creating the remote regex (#18462) @michelengelen
|
|
114
|
+
|
|
8
115
|
## 8.5.3
|
|
9
116
|
|
|
10
117
|
_Jun 19, 2025_
|
|
@@ -18,7 +18,6 @@ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"
|
|
|
18
18
|
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
19
19
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
20
20
|
var _useCalendarState = require("./useCalendarState");
|
|
21
|
-
var _useUtils = require("../internals/hooks/useUtils");
|
|
22
21
|
var _PickersFadeTransitionGroup = require("./PickersFadeTransitionGroup");
|
|
23
22
|
var _DayCalendar = require("./DayCalendar");
|
|
24
23
|
var _MonthCalendar = require("../MonthCalendar");
|
|
@@ -34,6 +33,7 @@ var _valueManagers = require("../internals/utils/valueManagers");
|
|
|
34
33
|
var _dimensions = require("../internals/constants/dimensions");
|
|
35
34
|
var _usePickerPrivateContext = require("../internals/hooks/usePickerPrivateContext");
|
|
36
35
|
var _useDateManager = require("../managers/useDateManager");
|
|
36
|
+
var _usePickerAdapter = require("../hooks/usePickerAdapter");
|
|
37
37
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
38
38
|
const _excluded = ["autoFocus", "onViewChange", "value", "defaultValue", "referenceDate", "disableFuture", "disablePast", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "classes", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "showDaysOutsideCurrentMonth", "fixedWeekNumber", "dayOfWeekFormatter", "slots", "slotProps", "loading", "renderLoading", "displayWeekNumber", "yearsOrder", "yearsPerRow", "monthsPerRow", "timezone"];
|
|
39
39
|
const useUtilityClasses = classes => {
|
|
@@ -84,7 +84,7 @@ const DateCalendarViewTransitionContainer = (0, _styles.styled)(_PickersFadeTran
|
|
|
84
84
|
* - [DateCalendar API](https://mui.com/x/api/date-pickers/date-calendar/)
|
|
85
85
|
*/
|
|
86
86
|
const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(inProps, ref) {
|
|
87
|
-
const
|
|
87
|
+
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
|
88
88
|
const {
|
|
89
89
|
ownerState
|
|
90
90
|
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
|
@@ -178,10 +178,10 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
178
178
|
disableFuture,
|
|
179
179
|
timezone,
|
|
180
180
|
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
181
|
-
if (
|
|
181
|
+
if (adapter.isSameMonth(visibleDate, prevMonth)) {
|
|
182
182
|
return prevMonth;
|
|
183
183
|
}
|
|
184
|
-
return
|
|
184
|
+
return adapter.startOfMonth(visibleDate);
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
|
|
@@ -215,13 +215,13 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
215
215
|
ownerState
|
|
216
216
|
});
|
|
217
217
|
const handleDateMonthChange = (0, _useEventCallback.default)(newDate => {
|
|
218
|
-
const startOfMonth =
|
|
219
|
-
const endOfMonth =
|
|
218
|
+
const startOfMonth = adapter.startOfMonth(newDate);
|
|
219
|
+
const endOfMonth = adapter.endOfMonth(newDate);
|
|
220
220
|
const closestEnabledDate = isDateDisabled(newDate) ? (0, _dateUtils.findClosestEnabledDate)({
|
|
221
|
-
|
|
221
|
+
adapter,
|
|
222
222
|
date: newDate,
|
|
223
|
-
minDate:
|
|
224
|
-
maxDate:
|
|
223
|
+
minDate: adapter.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
|
|
224
|
+
maxDate: adapter.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
|
|
225
225
|
disablePast,
|
|
226
226
|
disableFuture,
|
|
227
227
|
isDateDisabled,
|
|
@@ -242,13 +242,13 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
const handleDateYearChange = (0, _useEventCallback.default)(newDate => {
|
|
245
|
-
const startOfYear =
|
|
246
|
-
const endOfYear =
|
|
245
|
+
const startOfYear = adapter.startOfYear(newDate);
|
|
246
|
+
const endOfYear = adapter.endOfYear(newDate);
|
|
247
247
|
const closestEnabledDate = isDateDisabled(newDate) ? (0, _dateUtils.findClosestEnabledDate)({
|
|
248
|
-
|
|
248
|
+
adapter,
|
|
249
249
|
date: newDate,
|
|
250
|
-
minDate:
|
|
251
|
-
maxDate:
|
|
250
|
+
minDate: adapter.isBefore(minDate, startOfYear) ? startOfYear : minDate,
|
|
251
|
+
maxDate: adapter.isAfter(maxDate, endOfYear) ? endOfYear : maxDate,
|
|
252
252
|
disablePast,
|
|
253
253
|
disableFuture,
|
|
254
254
|
isDateDisabled,
|
|
@@ -271,12 +271,12 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
271
271
|
const handleSelectedDayChange = (0, _useEventCallback.default)(day => {
|
|
272
272
|
if (day) {
|
|
273
273
|
// If there is a date already selected, then we want to keep its time
|
|
274
|
-
return handleValueChange((0, _dateUtils.mergeDateAndTime)(
|
|
274
|
+
return handleValueChange((0, _dateUtils.mergeDateAndTime)(adapter, day, value ?? referenceDate), 'finish', view);
|
|
275
275
|
}
|
|
276
276
|
return handleValueChange(day, 'finish', view);
|
|
277
277
|
});
|
|
278
278
|
React.useEffect(() => {
|
|
279
|
-
if (
|
|
279
|
+
if (adapter.isValid(value)) {
|
|
280
280
|
setVisibleDate({
|
|
281
281
|
target: value,
|
|
282
282
|
reason: 'controlled-value-change'
|
|
@@ -18,7 +18,7 @@ var _styles = require("@mui/material/styles");
|
|
|
18
18
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
19
19
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
20
20
|
var _PickersDay = require("../PickersDay");
|
|
21
|
-
var
|
|
21
|
+
var _hooks = require("../hooks");
|
|
22
22
|
var _useUtils = require("../internals/hooks/useUtils");
|
|
23
23
|
var _dimensions = require("../internals/constants/dimensions");
|
|
24
24
|
var _PickersSlideTransition = require("./PickersSlideTransition");
|
|
@@ -151,14 +151,14 @@ function WrappedDay(_ref) {
|
|
|
151
151
|
slotProps,
|
|
152
152
|
timezone
|
|
153
153
|
} = parentProps;
|
|
154
|
-
const
|
|
154
|
+
const adapter = (0, _hooks.usePickerAdapter)();
|
|
155
155
|
const now = (0, _useUtils.useNow)(timezone);
|
|
156
|
-
const isFocusableDay = focusedDay != null &&
|
|
156
|
+
const isFocusableDay = focusedDay != null && adapter.isSameDay(day, focusedDay);
|
|
157
157
|
const isFocusedDay = isViewFocused && isFocusableDay;
|
|
158
|
-
const isSelected = selectedDays.some(selectedDay =>
|
|
159
|
-
const isToday =
|
|
158
|
+
const isSelected = selectedDays.some(selectedDay => adapter.isSameDay(selectedDay, day));
|
|
159
|
+
const isToday = adapter.isSameDay(day, now);
|
|
160
160
|
const isDisabled = React.useMemo(() => disabled || isDateDisabled(day), [disabled, isDateDisabled, day]);
|
|
161
|
-
const isOutsideCurrentMonth = React.useMemo(() =>
|
|
161
|
+
const isOutsideCurrentMonth = React.useMemo(() => adapter.getMonth(day) !== currentMonthNumber, [adapter, day, currentMonthNumber]);
|
|
162
162
|
const ownerState = (0, _usePickerDayOwnerState.usePickerDayOwnerState)({
|
|
163
163
|
day,
|
|
164
164
|
selected: isSelected,
|
|
@@ -181,7 +181,7 @@ function WrappedDay(_ref) {
|
|
|
181
181
|
role: 'gridcell',
|
|
182
182
|
isAnimating: isMonthSwitchingAnimating,
|
|
183
183
|
// it is used in date range dragging logic by accessing `dataset.timestamp`
|
|
184
|
-
'data-timestamp':
|
|
184
|
+
'data-timestamp': adapter.toJsDate(day).valueOf()
|
|
185
185
|
}, other),
|
|
186
186
|
ownerState: (0, _extends2.default)({}, ownerState, {
|
|
187
187
|
day,
|
|
@@ -191,19 +191,19 @@ function WrappedDay(_ref) {
|
|
|
191
191
|
}),
|
|
192
192
|
dayProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
|
|
193
193
|
const isFirstVisibleCell = React.useMemo(() => {
|
|
194
|
-
const startOfMonth =
|
|
194
|
+
const startOfMonth = adapter.startOfMonth(adapter.setMonth(day, currentMonthNumber));
|
|
195
195
|
if (!showDaysOutsideCurrentMonth) {
|
|
196
|
-
return
|
|
196
|
+
return adapter.isSameDay(day, startOfMonth);
|
|
197
197
|
}
|
|
198
|
-
return
|
|
199
|
-
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth,
|
|
198
|
+
return adapter.isSameDay(day, adapter.startOfWeek(startOfMonth));
|
|
199
|
+
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth, adapter]);
|
|
200
200
|
const isLastVisibleCell = React.useMemo(() => {
|
|
201
|
-
const endOfMonth =
|
|
201
|
+
const endOfMonth = adapter.endOfMonth(adapter.setMonth(day, currentMonthNumber));
|
|
202
202
|
if (!showDaysOutsideCurrentMonth) {
|
|
203
|
-
return
|
|
203
|
+
return adapter.isSameDay(day, endOfMonth);
|
|
204
204
|
}
|
|
205
|
-
return
|
|
206
|
-
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth,
|
|
205
|
+
return adapter.isSameDay(day, adapter.endOfWeek(endOfMonth));
|
|
206
|
+
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth, adapter]);
|
|
207
207
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Day, (0, _extends2.default)({}, dayProps, {
|
|
208
208
|
day: day,
|
|
209
209
|
disabled: isDisabled,
|
|
@@ -227,7 +227,7 @@ function DayCalendar(inProps) {
|
|
|
227
227
|
props: inProps,
|
|
228
228
|
name: 'MuiDayCalendar'
|
|
229
229
|
});
|
|
230
|
-
const
|
|
230
|
+
const adapter = (0, _hooks.usePickerAdapter)();
|
|
231
231
|
const {
|
|
232
232
|
onFocusedDayChange,
|
|
233
233
|
className,
|
|
@@ -252,7 +252,7 @@ function DayCalendar(inProps) {
|
|
|
252
252
|
shouldDisableDate,
|
|
253
253
|
shouldDisableMonth,
|
|
254
254
|
shouldDisableYear,
|
|
255
|
-
dayOfWeekFormatter = date =>
|
|
255
|
+
dayOfWeekFormatter = date => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase(),
|
|
256
256
|
hasFocus,
|
|
257
257
|
onFocusedViewChange,
|
|
258
258
|
gridLabelId,
|
|
@@ -273,7 +273,7 @@ function DayCalendar(inProps) {
|
|
|
273
273
|
disableFuture,
|
|
274
274
|
timezone
|
|
275
275
|
});
|
|
276
|
-
const translations = (0,
|
|
276
|
+
const translations = (0, _hooks.usePickerTranslations)();
|
|
277
277
|
const handleDaySelect = (0, _useEventCallback.default)(day => {
|
|
278
278
|
if (readOnly) {
|
|
279
279
|
return;
|
|
@@ -289,22 +289,22 @@ function DayCalendar(inProps) {
|
|
|
289
289
|
const handleKeyDown = (0, _useEventCallback.default)((event, day) => {
|
|
290
290
|
switch (event.key) {
|
|
291
291
|
case 'ArrowUp':
|
|
292
|
-
focusDay(
|
|
292
|
+
focusDay(adapter.addDays(day, -7));
|
|
293
293
|
event.preventDefault();
|
|
294
294
|
break;
|
|
295
295
|
case 'ArrowDown':
|
|
296
|
-
focusDay(
|
|
296
|
+
focusDay(adapter.addDays(day, 7));
|
|
297
297
|
event.preventDefault();
|
|
298
298
|
break;
|
|
299
299
|
case 'ArrowLeft':
|
|
300
300
|
{
|
|
301
|
-
const newFocusedDayDefault =
|
|
302
|
-
const nextAvailableMonth =
|
|
301
|
+
const newFocusedDayDefault = adapter.addDays(day, isRtl ? 1 : -1);
|
|
302
|
+
const nextAvailableMonth = adapter.addMonths(day, isRtl ? 1 : -1);
|
|
303
303
|
const closestDayToFocus = (0, _dateUtils.findClosestEnabledDate)({
|
|
304
|
-
|
|
304
|
+
adapter,
|
|
305
305
|
date: newFocusedDayDefault,
|
|
306
|
-
minDate: isRtl ? newFocusedDayDefault :
|
|
307
|
-
maxDate: isRtl ?
|
|
306
|
+
minDate: isRtl ? newFocusedDayDefault : adapter.startOfMonth(nextAvailableMonth),
|
|
307
|
+
maxDate: isRtl ? adapter.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
308
308
|
isDateDisabled,
|
|
309
309
|
timezone
|
|
310
310
|
});
|
|
@@ -314,13 +314,13 @@ function DayCalendar(inProps) {
|
|
|
314
314
|
}
|
|
315
315
|
case 'ArrowRight':
|
|
316
316
|
{
|
|
317
|
-
const newFocusedDayDefault =
|
|
318
|
-
const nextAvailableMonth =
|
|
317
|
+
const newFocusedDayDefault = adapter.addDays(day, isRtl ? -1 : 1);
|
|
318
|
+
const nextAvailableMonth = adapter.addMonths(day, isRtl ? -1 : 1);
|
|
319
319
|
const closestDayToFocus = (0, _dateUtils.findClosestEnabledDate)({
|
|
320
|
-
|
|
320
|
+
adapter,
|
|
321
321
|
date: newFocusedDayDefault,
|
|
322
|
-
minDate: isRtl ?
|
|
323
|
-
maxDate: isRtl ? newFocusedDayDefault :
|
|
322
|
+
minDate: isRtl ? adapter.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
323
|
+
maxDate: isRtl ? newFocusedDayDefault : adapter.endOfMonth(nextAvailableMonth),
|
|
324
324
|
isDateDisabled,
|
|
325
325
|
timezone
|
|
326
326
|
});
|
|
@@ -329,19 +329,19 @@ function DayCalendar(inProps) {
|
|
|
329
329
|
break;
|
|
330
330
|
}
|
|
331
331
|
case 'Home':
|
|
332
|
-
focusDay(
|
|
332
|
+
focusDay(adapter.startOfWeek(day));
|
|
333
333
|
event.preventDefault();
|
|
334
334
|
break;
|
|
335
335
|
case 'End':
|
|
336
|
-
focusDay(
|
|
336
|
+
focusDay(adapter.endOfWeek(day));
|
|
337
337
|
event.preventDefault();
|
|
338
338
|
break;
|
|
339
339
|
case 'PageUp':
|
|
340
|
-
focusDay(
|
|
340
|
+
focusDay(adapter.addMonths(day, 1));
|
|
341
341
|
event.preventDefault();
|
|
342
342
|
break;
|
|
343
343
|
case 'PageDown':
|
|
344
|
-
focusDay(
|
|
344
|
+
focusDay(adapter.addMonths(day, -1));
|
|
345
345
|
event.preventDefault();
|
|
346
346
|
break;
|
|
347
347
|
default:
|
|
@@ -350,33 +350,33 @@ function DayCalendar(inProps) {
|
|
|
350
350
|
});
|
|
351
351
|
const handleFocus = (0, _useEventCallback.default)((event, day) => focusDay(day));
|
|
352
352
|
const handleBlur = (0, _useEventCallback.default)((event, day) => {
|
|
353
|
-
if (focusedDay != null &&
|
|
353
|
+
if (focusedDay != null && adapter.isSameDay(focusedDay, day)) {
|
|
354
354
|
onFocusedViewChange?.(false);
|
|
355
355
|
}
|
|
356
356
|
});
|
|
357
|
-
const currentMonthNumber =
|
|
358
|
-
const currentYearNumber =
|
|
359
|
-
const validSelectedDays = React.useMemo(() => selectedDays.filter(day => !!day).map(day =>
|
|
357
|
+
const currentMonthNumber = adapter.getMonth(currentMonth);
|
|
358
|
+
const currentYearNumber = adapter.getYear(currentMonth);
|
|
359
|
+
const validSelectedDays = React.useMemo(() => selectedDays.filter(day => !!day).map(day => adapter.startOfDay(day)), [adapter, selectedDays]);
|
|
360
360
|
|
|
361
361
|
// need a new ref whenever the `key` of the transition changes: https://reactcommunity.org/react-transition-group/transition/#Transition-prop-nodeRef.
|
|
362
362
|
const transitionKey = `${currentYearNumber}-${currentMonthNumber}`;
|
|
363
363
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
364
364
|
const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
|
|
365
365
|
const weeksToDisplay = React.useMemo(() => {
|
|
366
|
-
const toDisplay =
|
|
367
|
-
let nextMonth =
|
|
366
|
+
const toDisplay = adapter.getWeekArray(currentMonth);
|
|
367
|
+
let nextMonth = adapter.addMonths(currentMonth, 1);
|
|
368
368
|
while (fixedWeekNumber && toDisplay.length < fixedWeekNumber) {
|
|
369
|
-
const additionalWeeks =
|
|
370
|
-
const hasCommonWeek =
|
|
369
|
+
const additionalWeeks = adapter.getWeekArray(nextMonth);
|
|
370
|
+
const hasCommonWeek = adapter.isSameDay(toDisplay[toDisplay.length - 1][0], additionalWeeks[0][0]);
|
|
371
371
|
additionalWeeks.slice(hasCommonWeek ? 1 : 0).forEach(week => {
|
|
372
372
|
if (toDisplay.length < fixedWeekNumber) {
|
|
373
373
|
toDisplay.push(week);
|
|
374
374
|
}
|
|
375
375
|
});
|
|
376
|
-
nextMonth =
|
|
376
|
+
nextMonth = adapter.addMonths(nextMonth, 1);
|
|
377
377
|
}
|
|
378
378
|
return toDisplay;
|
|
379
|
-
}, [currentMonth, fixedWeekNumber,
|
|
379
|
+
}, [currentMonth, fixedWeekNumber, adapter]);
|
|
380
380
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersCalendarDayRoot, {
|
|
381
381
|
role: "grid",
|
|
382
382
|
"aria-labelledby": gridLabelId,
|
|
@@ -390,10 +390,10 @@ function DayCalendar(inProps) {
|
|
|
390
390
|
"aria-label": translations.calendarWeekNumberHeaderLabel,
|
|
391
391
|
className: classes.weekNumberLabel,
|
|
392
392
|
children: translations.calendarWeekNumberHeaderText
|
|
393
|
-
}), (0, _dateUtils.getWeekdays)(
|
|
393
|
+
}), (0, _dateUtils.getWeekdays)(adapter, now).map((weekday, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersCalendarWeekDayLabel, {
|
|
394
394
|
variant: "caption",
|
|
395
395
|
role: "columnheader",
|
|
396
|
-
"aria-label":
|
|
396
|
+
"aria-label": adapter.format(weekday, 'weekday'),
|
|
397
397
|
className: classes.weekDayLabel,
|
|
398
398
|
children: dayOfWeekFormatter(weekday)
|
|
399
399
|
}, i.toString()))]
|
|
@@ -422,8 +422,8 @@ function DayCalendar(inProps) {
|
|
|
422
422
|
children: [displayWeekNumber && /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersCalendarWeekNumber, {
|
|
423
423
|
className: classes.weekNumber,
|
|
424
424
|
role: "rowheader",
|
|
425
|
-
"aria-label": translations.calendarWeekNumberAriaLabelText(
|
|
426
|
-
children: translations.calendarWeekNumberText(
|
|
425
|
+
"aria-label": translations.calendarWeekNumberAriaLabelText(adapter.getWeekNumber(week[0])),
|
|
426
|
+
children: translations.calendarWeekNumberText(adapter.getWeekNumber(week[0]))
|
|
427
427
|
}), week.map((day, dayIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedDay, {
|
|
428
428
|
parentProps: props,
|
|
429
429
|
day: day,
|
|
@@ -11,28 +11,28 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _useIsDateDisabled = require("./useIsDateDisabled");
|
|
14
|
-
var _useUtils = require("../internals/hooks/useUtils");
|
|
15
14
|
var _valueManagers = require("../internals/utils/valueManagers");
|
|
16
15
|
var _getDefaultReferenceDate = require("../internals/utils/getDefaultReferenceDate");
|
|
17
16
|
var _dateUtils = require("../internals/utils/date-utils");
|
|
18
|
-
|
|
17
|
+
var _usePickerAdapter = require("../hooks/usePickerAdapter");
|
|
18
|
+
const createCalendarStateReducer = (reduceAnimations, adapter) => (state, action) => {
|
|
19
19
|
switch (action.type) {
|
|
20
20
|
case 'setVisibleDate':
|
|
21
21
|
return (0, _extends2.default)({}, state, {
|
|
22
22
|
slideDirection: action.direction,
|
|
23
23
|
currentMonth: action.month,
|
|
24
|
-
isMonthSwitchingAnimating: !
|
|
24
|
+
isMonthSwitchingAnimating: !adapter.isSameMonth(action.month, state.currentMonth) && !reduceAnimations && !action.skipAnimation,
|
|
25
25
|
focusedDay: action.focusedDay
|
|
26
26
|
});
|
|
27
27
|
case 'changeMonthTimezone':
|
|
28
28
|
{
|
|
29
29
|
const newTimezone = action.newTimezone;
|
|
30
|
-
if (
|
|
30
|
+
if (adapter.getTimezone(state.currentMonth) === newTimezone) {
|
|
31
31
|
return state;
|
|
32
32
|
}
|
|
33
|
-
let newCurrentMonth =
|
|
34
|
-
if (
|
|
35
|
-
newCurrentMonth =
|
|
33
|
+
let newCurrentMonth = adapter.setTimezone(state.currentMonth, newTimezone);
|
|
34
|
+
if (adapter.getMonth(newCurrentMonth) !== adapter.getMonth(state.currentMonth)) {
|
|
35
|
+
newCurrentMonth = adapter.setMonth(newCurrentMonth, adapter.getMonth(state.currentMonth));
|
|
36
36
|
}
|
|
37
37
|
return (0, _extends2.default)({}, state, {
|
|
38
38
|
currentMonth: newCurrentMonth
|
|
@@ -61,12 +61,12 @@ const useCalendarState = params => {
|
|
|
61
61
|
timezone,
|
|
62
62
|
getCurrentMonthFromVisibleDate
|
|
63
63
|
} = params;
|
|
64
|
-
const
|
|
65
|
-
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations),
|
|
64
|
+
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
|
65
|
+
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), adapter)).current;
|
|
66
66
|
const referenceDate = React.useMemo(() => {
|
|
67
67
|
return _valueManagers.singleItemValueManager.getInitialReferenceValue({
|
|
68
68
|
value,
|
|
69
|
-
|
|
69
|
+
adapter,
|
|
70
70
|
timezone,
|
|
71
71
|
props: params,
|
|
72
72
|
referenceDate: referenceDateProp,
|
|
@@ -79,7 +79,7 @@ const useCalendarState = params => {
|
|
|
79
79
|
const [calendarState, dispatch] = React.useReducer(reducerFn, {
|
|
80
80
|
isMonthSwitchingAnimating: false,
|
|
81
81
|
focusedDay: referenceDate,
|
|
82
|
-
currentMonth:
|
|
82
|
+
currentMonth: adapter.startOfMonth(referenceDate),
|
|
83
83
|
slideDirection: 'left'
|
|
84
84
|
});
|
|
85
85
|
const isDateDisabled = (0, _useIsDateDisabled.useIsDateDisabled)({
|
|
@@ -96,14 +96,14 @@ const useCalendarState = params => {
|
|
|
96
96
|
React.useEffect(() => {
|
|
97
97
|
dispatch({
|
|
98
98
|
type: 'changeMonthTimezone',
|
|
99
|
-
newTimezone:
|
|
99
|
+
newTimezone: adapter.getTimezone(referenceDate)
|
|
100
100
|
});
|
|
101
|
-
}, [referenceDate,
|
|
101
|
+
}, [referenceDate, adapter]);
|
|
102
102
|
const setVisibleDate = (0, _useEventCallback.default)(({
|
|
103
103
|
target,
|
|
104
104
|
reason
|
|
105
105
|
}) => {
|
|
106
|
-
if (reason === 'cell-interaction' && calendarState.focusedDay != null &&
|
|
106
|
+
if (reason === 'cell-interaction' && calendarState.focusedDay != null && adapter.isSameDay(target, calendarState.focusedDay)) {
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
const skipAnimation = reason === 'cell-interaction';
|
|
@@ -113,18 +113,18 @@ const useCalendarState = params => {
|
|
|
113
113
|
month = getCurrentMonthFromVisibleDate(target, calendarState.currentMonth);
|
|
114
114
|
focusedDay = target;
|
|
115
115
|
} else {
|
|
116
|
-
month =
|
|
116
|
+
month = adapter.isSameMonth(target, calendarState.currentMonth) ? calendarState.currentMonth : adapter.startOfMonth(target);
|
|
117
117
|
focusedDay = target;
|
|
118
118
|
|
|
119
119
|
// If the date is disabled, we try to find a non-disabled date inside the same month.
|
|
120
120
|
if (isDateDisabled(focusedDay)) {
|
|
121
|
-
const startOfMonth =
|
|
122
|
-
const endOfMonth =
|
|
121
|
+
const startOfMonth = adapter.startOfMonth(target);
|
|
122
|
+
const endOfMonth = adapter.endOfMonth(target);
|
|
123
123
|
focusedDay = (0, _dateUtils.findClosestEnabledDate)({
|
|
124
|
-
|
|
124
|
+
adapter,
|
|
125
125
|
date: focusedDay,
|
|
126
|
-
minDate:
|
|
127
|
-
maxDate:
|
|
126
|
+
minDate: adapter.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
|
|
127
|
+
maxDate: adapter.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
|
|
128
128
|
disablePast,
|
|
129
129
|
disableFuture,
|
|
130
130
|
isDateDisabled,
|
|
@@ -132,19 +132,19 @@ const useCalendarState = params => {
|
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
const hasChangedMonth = !
|
|
136
|
-
const hasChangedYear = !
|
|
135
|
+
const hasChangedMonth = !adapter.isSameMonth(calendarState.currentMonth, month);
|
|
136
|
+
const hasChangedYear = !adapter.isSameYear(calendarState.currentMonth, month);
|
|
137
137
|
if (hasChangedMonth) {
|
|
138
138
|
onMonthChange?.(month);
|
|
139
139
|
}
|
|
140
140
|
if (hasChangedYear) {
|
|
141
|
-
onYearChange?.(
|
|
141
|
+
onYearChange?.(adapter.startOfYear(month));
|
|
142
142
|
}
|
|
143
143
|
dispatch({
|
|
144
144
|
type: 'setVisibleDate',
|
|
145
145
|
month,
|
|
146
|
-
direction:
|
|
147
|
-
focusedDay: calendarState.focusedDay != null && focusedDay != null &&
|
|
146
|
+
direction: adapter.isAfterDay(month, calendarState.currentMonth) ? 'left' : 'right',
|
|
147
|
+
focusedDay: calendarState.focusedDay != null && focusedDay != null && adapter.isSameDay(focusedDay, calendarState.focusedDay) ? calendarState.focusedDay : focusedDay,
|
|
148
148
|
skipAnimation
|
|
149
149
|
});
|
|
150
150
|
});
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useIsDateDisabled = void 0;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _validation = require("../validation");
|
|
11
|
-
var
|
|
11
|
+
var _usePickerAdapter = require("../hooks/usePickerAdapter");
|
|
12
12
|
const useIsDateDisabled = ({
|
|
13
13
|
shouldDisableDate,
|
|
14
14
|
shouldDisableMonth,
|
|
@@ -19,7 +19,7 @@ const useIsDateDisabled = ({
|
|
|
19
19
|
disablePast,
|
|
20
20
|
timezone
|
|
21
21
|
}) => {
|
|
22
|
-
const adapter = (0,
|
|
22
|
+
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
|
23
23
|
return React.useCallback(day => (0, _validation.validateDate)({
|
|
24
24
|
adapter,
|
|
25
25
|
value: day,
|
|
@@ -16,12 +16,10 @@ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
|
16
16
|
var _styles = require("@mui/material/styles");
|
|
17
17
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
18
18
|
var _PickersToolbar = require("../internals/components/PickersToolbar");
|
|
19
|
-
var
|
|
20
|
-
var _useUtils = require("../internals/hooks/useUtils");
|
|
19
|
+
var _hooks = require("../hooks");
|
|
21
20
|
var _datePickerToolbarClasses = require("./datePickerToolbarClasses");
|
|
22
21
|
var _dateUtils = require("../internals/utils/date-utils");
|
|
23
22
|
var _useToolbarOwnerState = require("../internals/hooks/useToolbarOwnerState");
|
|
24
|
-
var _hooks = require("../hooks");
|
|
25
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
24
|
const _excluded = ["toolbarFormat", "toolbarPlaceholder", "className", "classes"];
|
|
27
25
|
const useUtilityClasses = classes => {
|
|
@@ -70,25 +68,25 @@ const DatePickerToolbar = exports.DatePickerToolbar = /*#__PURE__*/React.forward
|
|
|
70
68
|
classes: classesProp
|
|
71
69
|
} = props,
|
|
72
70
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
73
|
-
const
|
|
71
|
+
const adapter = (0, _hooks.usePickerAdapter)();
|
|
74
72
|
const {
|
|
75
73
|
value,
|
|
76
74
|
views,
|
|
77
75
|
orientation
|
|
78
76
|
} = (0, _hooks.usePickerContext)();
|
|
79
|
-
const translations = (0,
|
|
77
|
+
const translations = (0, _hooks.usePickerTranslations)();
|
|
80
78
|
const ownerState = (0, _useToolbarOwnerState.useToolbarOwnerState)();
|
|
81
79
|
const classes = useUtilityClasses(classesProp);
|
|
82
80
|
const dateText = React.useMemo(() => {
|
|
83
|
-
if (!
|
|
81
|
+
if (!adapter.isValid(value)) {
|
|
84
82
|
return toolbarPlaceholder;
|
|
85
83
|
}
|
|
86
|
-
const formatFromViews = (0, _dateUtils.resolveDateFormat)(
|
|
84
|
+
const formatFromViews = (0, _dateUtils.resolveDateFormat)(adapter, {
|
|
87
85
|
format: toolbarFormat,
|
|
88
86
|
views
|
|
89
87
|
}, true);
|
|
90
|
-
return
|
|
91
|
-
}, [value, toolbarFormat, toolbarPlaceholder,
|
|
88
|
+
return adapter.formatByString(value, formatFromViews);
|
|
89
|
+
}, [value, toolbarFormat, toolbarPlaceholder, adapter, views]);
|
|
92
90
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DatePickerToolbarRoot, (0, _extends2.default)({
|
|
93
91
|
ref: ref,
|
|
94
92
|
toolbarTitle: translations.datePickerToolbarTitle,
|
|
@@ -58,7 +58,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
58
58
|
// ----------------------------------------------------------------------
|
|
59
59
|
/**
|
|
60
60
|
* 12h/24h view for hour selection clock.
|
|
61
|
-
* @default
|
|
61
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
62
62
|
*/
|
|
63
63
|
ampm: _propTypes.default.bool,
|
|
64
64
|
/**
|
|
@@ -60,7 +60,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
60
60
|
// ----------------------------------------------------------------------
|
|
61
61
|
/**
|
|
62
62
|
* 12h/24h view for hour selection clock.
|
|
63
|
-
* @default
|
|
63
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
64
64
|
*/
|
|
65
65
|
ampm: _propTypes.default.bool,
|
|
66
66
|
/**
|