@mui/x-date-pickers 6.7.0 → 6.8.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 +77 -15
- package/DateCalendar/DateCalendar.js +16 -6
- package/DateCalendar/DateCalendar.types.d.ts +6 -1
- package/DateCalendar/useCalendarState.d.ts +3 -2
- package/DateCalendar/useCalendarState.js +36 -15
- package/DateField/DateField.js +1 -1
- package/DatePicker/DatePicker.js +1 -1
- package/DateTimeField/DateTimeField.js +1 -1
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/MobileDatePicker/MobileDatePicker.js +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/MonthCalendar/MonthCalendar.js +28 -11
- package/MonthCalendar/MonthCalendar.types.d.ts +5 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/PickersLayout/PickersLayout.js +1 -0
- package/PickersLayout/usePickerLayout.js +4 -3
- package/PickersShortcuts/PickersShortcuts.d.ts +12 -2
- package/PickersShortcuts/PickersShortcuts.js +10 -2
- package/PickersShortcuts/index.d.ts +1 -1
- package/StaticDatePicker/StaticDatePicker.js +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/TimeField/TimeField.js +1 -1
- package/YearCalendar/YearCalendar.js +26 -9
- package/YearCalendar/YearCalendar.types.d.ts +5 -0
- package/index.js +1 -1
- package/internals/hooks/useField/useField.types.d.ts +1 -1
- package/internals/hooks/useField/useFieldState.js +0 -1
- package/internals/hooks/usePicker/usePickerValue.js +22 -2
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +6 -2
- package/internals/utils/date-utils.d.ts +1 -2
- package/internals/utils/date-utils.js +0 -9
- package/internals/utils/getDefaultReferenceDate.d.ts +11 -3
- package/internals/utils/getDefaultReferenceDate.js +2 -3
- package/legacy/DateCalendar/DateCalendar.js +16 -6
- package/legacy/DateCalendar/useCalendarState.js +35 -15
- package/legacy/DateField/DateField.js +1 -1
- package/legacy/DatePicker/DatePicker.js +1 -1
- package/legacy/DateTimeField/DateTimeField.js +1 -1
- package/legacy/DateTimePicker/DateTimePicker.js +1 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +1 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/legacy/MonthCalendar/MonthCalendar.js +30 -13
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/legacy/PickersLayout/PickersLayout.js +1 -0
- package/legacy/PickersLayout/usePickerLayout.js +3 -2
- package/legacy/PickersShortcuts/PickersShortcuts.js +10 -2
- package/legacy/StaticDatePicker/StaticDatePicker.js +1 -1
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/legacy/TimeField/TimeField.js +1 -1
- package/legacy/YearCalendar/YearCalendar.js +28 -11
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useField/useFieldState.js +0 -1
- package/legacy/internals/hooks/usePicker/usePickerValue.js +24 -2
- package/legacy/internals/utils/date-utils.js +0 -9
- package/legacy/internals/utils/getDefaultReferenceDate.js +2 -3
- package/legacy/locales/elGR.js +93 -0
- package/legacy/locales/index.js +1 -0
- package/locales/elGR.d.ts +53 -0
- package/locales/elGR.js +57 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +16 -6
- package/modern/DateCalendar/useCalendarState.js +36 -14
- package/modern/DateField/DateField.js +1 -1
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DateTimeField/DateTimeField.js +1 -1
- package/modern/DateTimePicker/DateTimePicker.js +1 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/modern/MonthCalendar/MonthCalendar.js +28 -11
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/modern/PickersLayout/PickersLayout.js +1 -0
- package/modern/PickersLayout/usePickerLayout.js +4 -3
- package/modern/PickersShortcuts/PickersShortcuts.js +10 -2
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/modern/TimeField/TimeField.js +1 -1
- package/modern/YearCalendar/YearCalendar.js +26 -9
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +0 -1
- package/modern/internals/hooks/usePicker/usePickerValue.js +22 -2
- package/modern/internals/utils/date-utils.js +0 -9
- package/modern/internals/utils/getDefaultReferenceDate.js +2 -3
- package/modern/locales/elGR.js +57 -0
- package/modern/locales/index.js +1 -0
- package/node/DateCalendar/DateCalendar.js +16 -6
- package/node/DateCalendar/useCalendarState.js +36 -14
- package/node/DateField/DateField.js +1 -1
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DateTimeField/DateTimeField.js +1 -1
- package/node/DateTimePicker/DateTimePicker.js +1 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -1
- package/node/MobileDatePicker/MobileDatePicker.js +1 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/node/MonthCalendar/MonthCalendar.js +28 -11
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/node/PickersLayout/PickersLayout.js +1 -0
- package/node/PickersLayout/usePickerLayout.js +4 -3
- package/node/PickersShortcuts/PickersShortcuts.js +10 -2
- package/node/StaticDatePicker/StaticDatePicker.js +1 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/node/TimeField/TimeField.js +1 -1
- package/node/YearCalendar/YearCalendar.js +26 -9
- package/node/index.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +0 -1
- package/node/internals/hooks/usePicker/usePickerValue.js +22 -2
- package/node/internals/utils/date-utils.js +1 -11
- package/node/internals/utils/getDefaultReferenceDate.js +3 -3
- package/node/locales/elGR.js +64 -0
- package/node/locales/index.js +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
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
|
+
## 6.8.0
|
|
7
|
+
|
|
8
|
+
_Jun 16, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🌍 Add Greek (el-GR) locale on Pickers and improve on Data Grid
|
|
13
|
+
- 🚅 Performance improvements
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### `@mui/x-data-grid@6.8.0` / `@mui/x-data-grid-pro@6.8.0` / `@mui/x-data-grid-premium@6.8.0`
|
|
18
|
+
|
|
19
|
+
#### Changes
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Add missing styles to `overridesResolver` (#9248) @mrmuhammadali
|
|
22
|
+
- [DataGrid] Keep column header menu icon always visible on touch devices (#9076) @cherniavskii
|
|
23
|
+
- [DataGrid] Correct the type for single digit edited number value (#9282) @MBilalShafi
|
|
24
|
+
- [DataGrid] Correct the type for single digit edited number for row edit (#9348) @MBilalShafi
|
|
25
|
+
- [DataGrid] Filtering performance: cache values (#9284) @romgrk
|
|
26
|
+
- [DataGrid] Fix tabbing between `actions` cells in edit mode (#9321) @md250721
|
|
27
|
+
- [DataGrid] Make autocompletion work for `GridColDef['type']` (#9320) @cherniavskii
|
|
28
|
+
- [DataGrid] Polish shortcut logic (#9220) @oliviertassinari
|
|
29
|
+
- [DataGrid] Row reordering fix for different row heights (#7006) @yaredtsy
|
|
30
|
+
- [DataGrid] Scroll performance improvements (#9037) @romgrk
|
|
31
|
+
- [l10n] Improve Greek (el-GR) locale (#9292) @clytras
|
|
32
|
+
|
|
33
|
+
### `@mui/x-date-pickers@6.8.0` / `@mui/x-date-pickers-pro@6.8.0`
|
|
34
|
+
|
|
35
|
+
#### Changes
|
|
36
|
+
|
|
37
|
+
- [l10n] Add Greek (el-GR) locale (#9293) @clytras
|
|
38
|
+
- [pickers] Add a `referenceDate` prop on `DateCalendar`, `MonthCalendar` and `YearCalendar` (#9260) @flaviendelangle
|
|
39
|
+
- [pickers] Close the calendar when a shortcut is selected (#9080) @flaviendelangle
|
|
40
|
+
- [pickers] Fix disabling for digital clock (#9300) @alexfauquette
|
|
41
|
+
|
|
42
|
+
### Docs
|
|
43
|
+
|
|
44
|
+
- [docs] Add header filters to the popular features demo (#9069) @MBilalShafi
|
|
45
|
+
- [docs] Fix `Date Calendar` dynamic data demo (#9290) @benzler
|
|
46
|
+
- [docs] Fix Data Grid header filter link (#9225) @oliviertassinari
|
|
47
|
+
- [docs] Fix missing docs version warning (#9221) @oliviertassinari
|
|
48
|
+
- [docs] Improve Chart overview (#9333) @oliviertassinari
|
|
49
|
+
- [docs] Improve Next.js license installation guide (#8975) @oliviertassinari
|
|
50
|
+
- [docs] Link pagination documentation to the migration guide (#9296) @MBilalShafi
|
|
51
|
+
- [docs] One step toward components -> slots (#9251) @oliviertassinari
|
|
52
|
+
- [docs] Improve and reorganize sections on editing page (#8431) @joserodolfofreitas
|
|
53
|
+
- [docs] Add clipboard paste to popular features demo (#9029) @cherniavskii
|
|
54
|
+
|
|
55
|
+
### Core
|
|
56
|
+
|
|
57
|
+
- [core] Polish event name (#9336) @oliviertassinari
|
|
58
|
+
- [core] Re-enable `Argos` CI step (#9301) @LukasTy
|
|
59
|
+
- [core] Upgrade Node.js to v18 on CircleCI, CodeSandbox and Netlify (#9319) @ZeeshanTamboli
|
|
60
|
+
- [core] Upgrade Node.js v18 for l10n GitHub CI (#9355) @ZeeshanTamboli
|
|
61
|
+
- [charts] Add demonstration pages based on Recharts demo (#9175) @alexfauquette
|
|
62
|
+
- [charts] Add legend (#9024) @alexfauquette
|
|
63
|
+
- [charts] Complete the docs to introduce charts (#9153) @alexfauquette
|
|
64
|
+
- [charts] Manage elements highlights (#9242) @alexfauquette
|
|
65
|
+
- [charts] Prefix subcomponents with `Charts` (#9314) @alexfauquette
|
|
66
|
+
- [license] Improve annual license expiration message (#9135) @oliviertassinari
|
|
67
|
+
|
|
6
68
|
## 6.7.0
|
|
7
69
|
|
|
8
70
|
_Jun 9, 2023_
|
|
@@ -17,11 +79,11 @@ We'd like to offer a big thanks to the 12 contributors who made this release pos
|
|
|
17
79
|
<TimePicker views={['hours', 'minutes', 'seconds']} ampm />
|
|
18
80
|
// Format before v6.7.0: `hh:mm aa`
|
|
19
81
|
// Format after v6.7.0: `hh:mm:ss aa`
|
|
20
|
-
|
|
82
|
+
|
|
21
83
|
<DatePicker views={['year']} />
|
|
22
84
|
// Format before v6.7.0: `MM/DD/YYYY`
|
|
23
85
|
// Format after v6.7.0: `YYYY`
|
|
24
|
-
|
|
86
|
+
|
|
25
87
|
<DateTimePicker views={['day', 'hours', 'minutes']} ampm />
|
|
26
88
|
// Format before v6.7.0: `MM/DD/YYYY hh:mm aa`
|
|
27
89
|
// Format after v6.7.0: `DD hh:mm aa`
|
|
@@ -83,7 +145,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
83
145
|
|
|
84
146
|
- 🚀 New date time picking UI on [`DesktopDateTimePicker`](https://mui.com/x/react-date-pickers/date-time-picker/)
|
|
85
147
|
|
|
86
|
-
<img src="https://
|
|
148
|
+
<img src="https://github.com/mui/mui-x/assets/3165635/4e1fe9f9-03eb-4f23-99dd-80212b21fb23" width="840" height="506" />
|
|
87
149
|
|
|
88
150
|
- 🚀 Performance improvements
|
|
89
151
|
- 🐞 Bugfixes
|
|
@@ -151,7 +213,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
151
213
|
- [charts] Manage series stacking (#8888) @alexfauquette
|
|
152
214
|
- [license] List side effects in the license package (#9092) @cherniavskii
|
|
153
215
|
|
|
154
|
-
##
|
|
216
|
+
## 6.5.0
|
|
155
217
|
|
|
156
218
|
_May 19, 2023_
|
|
157
219
|
|
|
@@ -159,9 +221,9 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
159
221
|
|
|
160
222
|
- 💫 Introduce filtering on column headers for `DataGridPro` and `DataGridPremium`:
|
|
161
223
|
|
|
162
|
-
https://github.com/mui/mui-x/
|
|
224
|
+
<img src="https://github.com/mui/mui-x/releases/download/v6.5.0/recording.gif" width="840" height="506" />
|
|
163
225
|
|
|
164
|
-
See [the documentation](https://mui.com/x/react-data-grid/filtering
|
|
226
|
+
See [the documentation](https://mui.com/x/react-data-grid/filtering/header-filters/) for more information
|
|
165
227
|
|
|
166
228
|
- 🌍 Improve Hebrew (he-IL) and Czech (cs-CZ) locales
|
|
167
229
|
- 📝 Support for editing on pinned rows
|
|
@@ -207,7 +269,7 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
207
269
|
- [DataGrid] Memoize root props for better performance (#8942) @romgrk
|
|
208
270
|
- [test] Skip flaky unit tests in JSDOM (#8994) @cherniavskii
|
|
209
271
|
|
|
210
|
-
##
|
|
272
|
+
## 6.4.0
|
|
211
273
|
|
|
212
274
|
_May 12, 2023_
|
|
213
275
|
|
|
@@ -4240,7 +4302,7 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
4240
4302
|
- [docs] Revise and split up "Overview" page into "Introduction" (#4692) @samuelsycamore
|
|
4241
4303
|
- [docs] Use `useKeepGroupedColumnsHiddren` from the grid package on remaining demo (#5382) @flaviendelangle
|
|
4242
4304
|
|
|
4243
|
-
##
|
|
4305
|
+
## 5.12.3
|
|
4244
4306
|
|
|
4245
4307
|
_Jun 23, 2022_
|
|
4246
4308
|
|
|
@@ -4291,7 +4353,7 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
|
|
|
4291
4353
|
- [test] Throw if date adapter is not found (#5289) @cherniavskii
|
|
4292
4354
|
- [test] Use mock for `ResizeObserver` (#5215) @m4theushw
|
|
4293
4355
|
|
|
4294
|
-
##
|
|
4356
|
+
## 5.12.2
|
|
4295
4357
|
|
|
4296
4358
|
_Jun 16, 2022_
|
|
4297
4359
|
|
|
@@ -4334,7 +4396,7 @@ We'd like to offer a big thanks to the 7 contributors who made this release poss
|
|
|
4334
4396
|
- [core] Fix `GridColTypeDef` usage in demo (#5197) @cherniavskii
|
|
4335
4397
|
- [test] Add `waitFor` before asserting height (#5203) @m4theushw
|
|
4336
4398
|
|
|
4337
|
-
##
|
|
4399
|
+
## 5.12.1
|
|
4338
4400
|
|
|
4339
4401
|
_Jun 9, 2022_
|
|
4340
4402
|
|
|
@@ -4391,7 +4453,7 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
4391
4453
|
- [test] Fix dynamic row height test failing on Chrome (#5147) @m4theushw
|
|
4392
4454
|
- [test] Remove delay on server demo for regression tests (#5131) @alexfauquette
|
|
4393
4455
|
|
|
4394
|
-
##
|
|
4456
|
+
## 5.12.0
|
|
4395
4457
|
|
|
4396
4458
|
_May 31, 2022_
|
|
4397
4459
|
|
|
@@ -4472,7 +4534,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
4472
4534
|
- [test] Skip Safari and Firefox on broken tests (#4994) @alexfauquette
|
|
4473
4535
|
- [test] Make argos screenshots stable (#5061) @m4theushw
|
|
4474
4536
|
|
|
4475
|
-
##
|
|
4537
|
+
## 5.11.1
|
|
4476
4538
|
|
|
4477
4539
|
_May 20, 2022_
|
|
4478
4540
|
|
|
@@ -4564,7 +4626,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
|
|
|
4564
4626
|
- [core] Simplify rows cache management (#4933) @flaviendelangle
|
|
4565
4627
|
- [core] Use internal icons for quick filter (#4912) @alexfauquette
|
|
4566
4628
|
|
|
4567
|
-
##
|
|
4629
|
+
## 5.11.0
|
|
4568
4630
|
|
|
4569
4631
|
_May 13, 2022_
|
|
4570
4632
|
|
|
@@ -4708,7 +4770,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
4708
4770
|
- [test] Reset cleanup tracking on Karma tests (#4679) @m4theushw
|
|
4709
4771
|
- [test] Restore `sinon` sandbox after each `karma` test (#4689) @m4theushw
|
|
4710
4772
|
|
|
4711
|
-
##
|
|
4773
|
+
## 5.10.0
|
|
4712
4774
|
|
|
4713
4775
|
_Apr 25, 2022_
|
|
4714
4776
|
|
|
@@ -4744,7 +4806,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
|
|
|
4744
4806
|
- [core] Fix the README of the X packages (#4590) @flaviendelangle
|
|
4745
4807
|
- [test] Fix test to not depend on screen resolution (#4587) @m4theushw
|
|
4746
4808
|
|
|
4747
|
-
##
|
|
4809
|
+
## 5.9.0
|
|
4748
4810
|
|
|
4749
4811
|
_Apr 14, 2022_
|
|
4750
4812
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["autoFocus", "onViewChange", "value", "defaultValue", "disableFuture", "disablePast", "defaultCalendarMonth", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "showDaysOutsideCurrentMonth", "fixedWeekNumber", "dayOfWeekFormatter", "components", "componentsProps", "slots", "slotProps", "loading", "renderLoading", "displayWeekNumber", "yearsPerRow", "monthsPerRow"];
|
|
3
|
+
const _excluded = ["autoFocus", "onViewChange", "value", "defaultValue", "referenceDate", "disableFuture", "disablePast", "defaultCalendarMonth", "onChange", "onYearChange", "onMonthChange", "reduceAnimations", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "view", "views", "openTo", "className", "disabled", "readOnly", "minDate", "maxDate", "disableHighlightToday", "focusedView", "onFocusedViewChange", "showDaysOutsideCurrentMonth", "fixedWeekNumber", "dayOfWeekFormatter", "components", "componentsProps", "slots", "slotProps", "loading", "renderLoading", "displayWeekNumber", "yearsPerRow", "monthsPerRow"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -84,6 +84,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
84
84
|
onViewChange,
|
|
85
85
|
value: valueProp,
|
|
86
86
|
defaultValue,
|
|
87
|
+
referenceDate: referenceDateProp,
|
|
87
88
|
disableFuture,
|
|
88
89
|
disablePast,
|
|
89
90
|
defaultCalendarMonth,
|
|
@@ -147,6 +148,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
147
148
|
onFocusedViewChange
|
|
148
149
|
});
|
|
149
150
|
const {
|
|
151
|
+
referenceDate,
|
|
150
152
|
calendarState,
|
|
151
153
|
changeFocusedDay,
|
|
152
154
|
changeMonth,
|
|
@@ -156,6 +158,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
156
158
|
} = useCalendarState({
|
|
157
159
|
value,
|
|
158
160
|
defaultCalendarMonth,
|
|
161
|
+
referenceDate: referenceDateProp,
|
|
159
162
|
reduceAnimations,
|
|
160
163
|
onMonthChange,
|
|
161
164
|
minDate,
|
|
@@ -207,9 +210,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
207
210
|
changeFocusedDay(closestEnabledDate, true);
|
|
208
211
|
});
|
|
209
212
|
const handleSelectedDayChange = useEventCallback(day => {
|
|
210
|
-
if (
|
|
213
|
+
if (day) {
|
|
211
214
|
// If there is a date already selected, then we want to keep its time
|
|
212
|
-
return handleValueChange(mergeDateAndTime(utils, day, value), 'finish');
|
|
215
|
+
return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish');
|
|
213
216
|
}
|
|
214
217
|
return handleValueChange(day, 'finish');
|
|
215
218
|
});
|
|
@@ -286,7 +289,8 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
286
289
|
shouldDisableYear: shouldDisableYear,
|
|
287
290
|
hasFocus: hasFocus,
|
|
288
291
|
onFocusedViewChange: isViewFocused => setFocusedView('year', isViewFocused),
|
|
289
|
-
yearsPerRow: yearsPerRow
|
|
292
|
+
yearsPerRow: yearsPerRow,
|
|
293
|
+
referenceDate: referenceDate
|
|
290
294
|
})), view === 'month' && /*#__PURE__*/_jsx(MonthCalendar, _extends({}, baseDateValidationProps, commonViewProps, {
|
|
291
295
|
hasFocus: hasFocus,
|
|
292
296
|
className: className,
|
|
@@ -294,7 +298,8 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
294
298
|
onChange: handleDateMonthChange,
|
|
295
299
|
shouldDisableMonth: shouldDisableMonth,
|
|
296
300
|
onFocusedViewChange: isViewFocused => setFocusedView('month', isViewFocused),
|
|
297
|
-
monthsPerRow: monthsPerRow
|
|
301
|
+
monthsPerRow: monthsPerRow,
|
|
302
|
+
referenceDate: referenceDate
|
|
298
303
|
})), view === 'day' && /*#__PURE__*/_jsx(DayCalendar, _extends({}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
299
304
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
300
305
|
onFocusedDayChange: changeFocusedDay,
|
|
@@ -356,7 +361,7 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
356
361
|
*/
|
|
357
362
|
dayOfWeekFormatter: PropTypes.func,
|
|
358
363
|
/**
|
|
359
|
-
* Default calendar month displayed when `value
|
|
364
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
360
365
|
*/
|
|
361
366
|
defaultCalendarMonth: PropTypes.any,
|
|
362
367
|
/**
|
|
@@ -465,6 +470,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
465
470
|
* @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
|
|
466
471
|
*/
|
|
467
472
|
reduceAnimations: PropTypes.bool,
|
|
473
|
+
/**
|
|
474
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
475
|
+
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`.
|
|
476
|
+
*/
|
|
477
|
+
referenceDate: PropTypes.any,
|
|
468
478
|
/**
|
|
469
479
|
* Component displaying when passed `loading` true.
|
|
470
480
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -18,7 +18,7 @@ export interface DateCalendarSlotsComponentsProps<TDate> extends PickersCalendar
|
|
|
18
18
|
}
|
|
19
19
|
export interface ExportedDateCalendarProps<TDate> extends ExportedDayCalendarProps, ExportedMonthCalendarProps, ExportedYearCalendarProps, BaseDateValidationProps<TDate>, DayValidationProps<TDate>, YearValidationProps<TDate>, MonthValidationProps<TDate> {
|
|
20
20
|
/**
|
|
21
|
-
* Default calendar month displayed when `value
|
|
21
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
22
22
|
*/
|
|
23
23
|
defaultCalendarMonth?: TDate;
|
|
24
24
|
/**
|
|
@@ -66,6 +66,11 @@ export interface DateCalendarProps<TDate> extends ExportedDateCalendarProps<TDat
|
|
|
66
66
|
* Used when the component is not controlled.
|
|
67
67
|
*/
|
|
68
68
|
defaultValue?: TDate | null;
|
|
69
|
+
/**
|
|
70
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
71
|
+
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`.
|
|
72
|
+
*/
|
|
73
|
+
referenceDate?: TDate;
|
|
69
74
|
/**
|
|
70
75
|
* Callback fired when the value changes.
|
|
71
76
|
* @template TDate
|
|
@@ -25,10 +25,11 @@ interface ChangeFocusedDayPayload<TDate> {
|
|
|
25
25
|
export declare const createCalendarStateReducer: <TDate extends unknown>(reduceAnimations: boolean, disableSwitchToMonthOnDayFocus: boolean, utils: MuiPickersAdapter<TDate, any>) => (state: CalendarState<TDate>, action: {
|
|
26
26
|
type: "finishMonthSwitchingAnimation";
|
|
27
27
|
} | ReducerAction<"changeMonth", ChangeMonthPayload<TDate>> | ReducerAction<"changeFocusedDay", ChangeFocusedDayPayload<TDate>>) => CalendarState<TDate>;
|
|
28
|
-
interface
|
|
28
|
+
interface UseCalendarStateParams<TDate> extends Pick<DateCalendarDefaultizedProps<TDate>, 'value' | 'referenceDate' | 'defaultCalendarMonth' | 'disableFuture' | 'disablePast' | 'minDate' | 'maxDate' | 'onMonthChange' | 'reduceAnimations' | 'shouldDisableDate'> {
|
|
29
29
|
disableSwitchToMonthOnDayFocus?: boolean;
|
|
30
30
|
}
|
|
31
|
-
export declare const useCalendarState: <TDate extends unknown>(
|
|
31
|
+
export declare const useCalendarState: <TDate extends unknown>(params: UseCalendarStateParams<TDate>) => {
|
|
32
|
+
referenceDate: any;
|
|
32
33
|
calendarState: CalendarState<TDate>;
|
|
33
34
|
changeMonth: (newDate: TDate) => void;
|
|
34
35
|
changeFocusedDay: (newFocusedDate: TDate | null, withoutMonthSwitchingAnimation?: boolean | undefined) => void;
|
|
@@ -3,7 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
4
|
import { useIsDateDisabled } from './useIsDateDisabled';
|
|
5
5
|
import { useUtils, useNow } from '../internals/hooks/useUtils';
|
|
6
|
-
import {
|
|
6
|
+
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
7
|
+
import { SECTION_TYPE_GRANULARITY } from '../internals/utils/getDefaultReferenceDate';
|
|
7
8
|
export const createCalendarStateReducer = (reduceAnimations, disableSwitchToMonthOnDayFocus, utils) => (state, action) => {
|
|
8
9
|
switch (action.type) {
|
|
9
10
|
case 'changeMonth':
|
|
@@ -33,26 +34,45 @@ export const createCalendarStateReducer = (reduceAnimations, disableSwitchToMont
|
|
|
33
34
|
throw new Error('missing support');
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
export const useCalendarState =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
export const useCalendarState = params => {
|
|
38
|
+
const {
|
|
39
|
+
value,
|
|
40
|
+
referenceDate: referenceDateProp,
|
|
41
|
+
defaultCalendarMonth,
|
|
42
|
+
disableFuture,
|
|
43
|
+
disablePast,
|
|
44
|
+
disableSwitchToMonthOnDayFocus = false,
|
|
45
|
+
maxDate,
|
|
46
|
+
minDate,
|
|
47
|
+
onMonthChange,
|
|
48
|
+
reduceAnimations,
|
|
49
|
+
shouldDisableDate
|
|
50
|
+
} = params;
|
|
49
51
|
const now = useNow();
|
|
50
52
|
const utils = useUtils();
|
|
51
53
|
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), disableSwitchToMonthOnDayFocus, utils)).current;
|
|
54
|
+
const referenceDate = React.useMemo(() => {
|
|
55
|
+
let externalReferenceDate = null;
|
|
56
|
+
if (referenceDateProp) {
|
|
57
|
+
externalReferenceDate = referenceDateProp;
|
|
58
|
+
} else if (defaultCalendarMonth) {
|
|
59
|
+
// For `defaultCalendarMonth`, we just want to keep the month and the year to avoid a behavior change.
|
|
60
|
+
externalReferenceDate = utils.startOfMonth(defaultCalendarMonth);
|
|
61
|
+
}
|
|
62
|
+
return singleItemValueManager.getInitialReferenceValue({
|
|
63
|
+
value,
|
|
64
|
+
utils,
|
|
65
|
+
props: params,
|
|
66
|
+
referenceDate: externalReferenceDate,
|
|
67
|
+
granularity: SECTION_TYPE_GRANULARITY.day
|
|
68
|
+
});
|
|
69
|
+
}, [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
70
|
+
);
|
|
71
|
+
|
|
52
72
|
const [calendarState, dispatch] = React.useReducer(reducerFn, {
|
|
53
73
|
isMonthSwitchingAnimating: false,
|
|
54
74
|
focusedDay: value || now,
|
|
55
|
-
currentMonth: utils.startOfMonth(
|
|
75
|
+
currentMonth: utils.startOfMonth(referenceDate),
|
|
56
76
|
slideDirection: 'left'
|
|
57
77
|
});
|
|
58
78
|
const handleChangeMonth = React.useCallback(payload => {
|
|
@@ -95,6 +115,7 @@ export const useCalendarState = ({
|
|
|
95
115
|
}
|
|
96
116
|
});
|
|
97
117
|
return {
|
|
118
|
+
referenceDate,
|
|
98
119
|
calendarState,
|
|
99
120
|
changeMonth,
|
|
100
121
|
changeFocusedDay,
|
package/DateField/DateField.js
CHANGED
|
@@ -230,7 +230,7 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
230
230
|
*/
|
|
231
231
|
readOnly: PropTypes.bool,
|
|
232
232
|
/**
|
|
233
|
-
* The date used to generate a part of the
|
|
233
|
+
* The date used to generate a part of the new value that is not present in the format when both `value` and `defaultValue` are empty.
|
|
234
234
|
* For example, on time fields it will be used to determine the date to set.
|
|
235
235
|
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
236
236
|
*/
|
package/DatePicker/DatePicker.js
CHANGED
|
@@ -73,7 +73,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
73
73
|
*/
|
|
74
74
|
dayOfWeekFormatter: PropTypes.func,
|
|
75
75
|
/**
|
|
76
|
-
* Default calendar month displayed when `value
|
|
76
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
77
77
|
*/
|
|
78
78
|
defaultCalendarMonth: PropTypes.any,
|
|
79
79
|
/**
|
|
@@ -263,7 +263,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
263
263
|
*/
|
|
264
264
|
readOnly: PropTypes.bool,
|
|
265
265
|
/**
|
|
266
|
-
* The date used to generate a part of the
|
|
266
|
+
* The date used to generate a part of the new value that is not present in the format when both `value` and `defaultValue` are empty.
|
|
267
267
|
* For example, on time fields it will be used to determine the date to set.
|
|
268
268
|
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
269
269
|
*/
|
|
@@ -83,7 +83,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
83
83
|
*/
|
|
84
84
|
dayOfWeekFormatter: PropTypes.func,
|
|
85
85
|
/**
|
|
86
|
-
* Default calendar month displayed when `value
|
|
86
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
87
87
|
*/
|
|
88
88
|
defaultCalendarMonth: PropTypes.any,
|
|
89
89
|
/**
|
|
@@ -97,7 +97,7 @@ DesktopDatePicker.propTypes = {
|
|
|
97
97
|
*/
|
|
98
98
|
dayOfWeekFormatter: PropTypes.func,
|
|
99
99
|
/**
|
|
100
|
-
* Default calendar month displayed when `value
|
|
100
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
101
101
|
*/
|
|
102
102
|
defaultCalendarMonth: PropTypes.any,
|
|
103
103
|
/**
|
|
@@ -143,7 +143,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
143
143
|
*/
|
|
144
144
|
dayOfWeekFormatter: PropTypes.func,
|
|
145
145
|
/**
|
|
146
|
-
* Default calendar month displayed when `value
|
|
146
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
147
147
|
*/
|
|
148
148
|
defaultCalendarMonth: PropTypes.any,
|
|
149
149
|
/**
|
|
@@ -94,7 +94,7 @@ MobileDatePicker.propTypes = {
|
|
|
94
94
|
*/
|
|
95
95
|
dayOfWeekFormatter: PropTypes.func,
|
|
96
96
|
/**
|
|
97
|
-
* Default calendar month displayed when `value
|
|
97
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
98
98
|
*/
|
|
99
99
|
defaultCalendarMonth: PropTypes.any,
|
|
100
100
|
/**
|
|
@@ -115,7 +115,7 @@ MobileDateTimePicker.propTypes = {
|
|
|
115
115
|
*/
|
|
116
116
|
dayOfWeekFormatter: PropTypes.func,
|
|
117
117
|
/**
|
|
118
|
-
* Default calendar month displayed when `value
|
|
118
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
119
119
|
*/
|
|
120
120
|
defaultCalendarMonth: PropTypes.any,
|
|
121
121
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["className", "value", "defaultValue", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow"];
|
|
3
|
+
const _excluded = ["className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -11,6 +11,8 @@ import { PickersMonth } from './PickersMonth';
|
|
|
11
11
|
import { useUtils, useNow, useDefaultDates } from '../internals/hooks/useUtils';
|
|
12
12
|
import { getMonthCalendarUtilityClass } from './monthCalendarClasses';
|
|
13
13
|
import { applyDefaultDate, getMonthsInYear } from '../internals/utils/date-utils';
|
|
14
|
+
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
15
|
+
import { SECTION_TYPE_GRANULARITY } from '../internals/utils/getDefaultReferenceDate';
|
|
14
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
17
|
const useUtilityClasses = ownerState => {
|
|
16
18
|
const {
|
|
@@ -56,6 +58,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
56
58
|
className,
|
|
57
59
|
value: valueProp,
|
|
58
60
|
defaultValue,
|
|
61
|
+
referenceDate: referenceDateProp,
|
|
59
62
|
disabled,
|
|
60
63
|
disableFuture,
|
|
61
64
|
disablePast,
|
|
@@ -80,8 +83,16 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
80
83
|
controlled: valueProp,
|
|
81
84
|
default: defaultValue != null ? defaultValue : null
|
|
82
85
|
});
|
|
86
|
+
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
87
|
+
value,
|
|
88
|
+
utils,
|
|
89
|
+
props,
|
|
90
|
+
referenceDate: referenceDateProp,
|
|
91
|
+
granularity: SECTION_TYPE_GRANULARITY.month
|
|
92
|
+
}), [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
93
|
+
);
|
|
94
|
+
|
|
83
95
|
const todayMonth = React.useMemo(() => utils.getMonth(now), [utils, now]);
|
|
84
|
-
const selectedDateOrStartOfMonth = React.useMemo(() => value != null ? value : utils.startOfMonth(now), [now, utils, value]);
|
|
85
96
|
const selectedMonth = React.useMemo(() => {
|
|
86
97
|
if (value != null) {
|
|
87
98
|
return utils.getMonth(value);
|
|
@@ -89,8 +100,8 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
89
100
|
if (disableHighlightToday) {
|
|
90
101
|
return null;
|
|
91
102
|
}
|
|
92
|
-
return utils.getMonth(
|
|
93
|
-
}, [
|
|
103
|
+
return utils.getMonth(referenceDate);
|
|
104
|
+
}, [value, utils, disableHighlightToday, referenceDate]);
|
|
94
105
|
const [focusedMonth, setFocusedMonth] = React.useState(() => selectedMonth || todayMonth);
|
|
95
106
|
const [internalHasFocus, setInternalHasFocus] = useControlled({
|
|
96
107
|
name: 'MonthCalendar',
|
|
@@ -104,30 +115,31 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
104
115
|
onFocusedViewChange(newHasFocus);
|
|
105
116
|
}
|
|
106
117
|
});
|
|
107
|
-
const isMonthDisabled = React.useCallback(
|
|
118
|
+
const isMonthDisabled = React.useCallback(dateToValidate => {
|
|
108
119
|
const firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, minDate) ? now : minDate);
|
|
109
120
|
const lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, maxDate) ? now : maxDate);
|
|
110
|
-
|
|
121
|
+
const monthToValidate = utils.startOfMonth(dateToValidate);
|
|
122
|
+
if (utils.isBefore(monthToValidate, firstEnabledMonth)) {
|
|
111
123
|
return true;
|
|
112
124
|
}
|
|
113
|
-
if (utils.isAfter(
|
|
125
|
+
if (utils.isAfter(monthToValidate, lastEnabledMonth)) {
|
|
114
126
|
return true;
|
|
115
127
|
}
|
|
116
128
|
if (!shouldDisableMonth) {
|
|
117
129
|
return false;
|
|
118
130
|
}
|
|
119
|
-
return shouldDisableMonth(
|
|
131
|
+
return shouldDisableMonth(monthToValidate);
|
|
120
132
|
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableMonth, utils]);
|
|
121
133
|
const handleMonthSelection = useEventCallback((event, month) => {
|
|
122
134
|
if (readOnly) {
|
|
123
135
|
return;
|
|
124
136
|
}
|
|
125
|
-
const newDate = utils.setMonth(
|
|
137
|
+
const newDate = utils.setMonth(value != null ? value : referenceDate, month);
|
|
126
138
|
setValue(newDate);
|
|
127
139
|
onChange == null ? void 0 : onChange(newDate);
|
|
128
140
|
});
|
|
129
141
|
const focusMonth = useEventCallback(month => {
|
|
130
|
-
if (!isMonthDisabled(utils.setMonth(
|
|
142
|
+
if (!isMonthDisabled(utils.setMonth(value != null ? value : referenceDate, month))) {
|
|
131
143
|
setFocusedMonth(month);
|
|
132
144
|
changeHasFocus(true);
|
|
133
145
|
if (onMonthFocus) {
|
|
@@ -175,7 +187,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
175
187
|
className: clsx(classes.root, className),
|
|
176
188
|
ownerState: ownerState
|
|
177
189
|
}, other, {
|
|
178
|
-
children: getMonthsInYear(utils,
|
|
190
|
+
children: getMonthsInYear(utils, value != null ? value : referenceDate).map(month => {
|
|
179
191
|
const monthNumber = utils.getMonth(month);
|
|
180
192
|
const monthText = utils.format(month, 'monthShort');
|
|
181
193
|
const isSelected = monthNumber === selectedMonth;
|
|
@@ -261,6 +273,11 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
261
273
|
* If `true` picker is readonly
|
|
262
274
|
*/
|
|
263
275
|
readOnly: PropTypes.bool,
|
|
276
|
+
/**
|
|
277
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
278
|
+
* @default The closest valid month using the validation props, except callbacks such as `shouldDisableDate`.
|
|
279
|
+
*/
|
|
280
|
+
referenceDate: PropTypes.any,
|
|
264
281
|
/**
|
|
265
282
|
* Disable specific month.
|
|
266
283
|
* @template TDate
|
|
@@ -35,6 +35,11 @@ export interface MonthCalendarProps<TDate> extends ExportedMonthCalendarProps, M
|
|
|
35
35
|
* Used when the component is not controlled.
|
|
36
36
|
*/
|
|
37
37
|
defaultValue?: TDate | null;
|
|
38
|
+
/**
|
|
39
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
40
|
+
* @default The closest valid month using the validation props, except callbacks such as `shouldDisableDate`.
|
|
41
|
+
*/
|
|
42
|
+
referenceDate?: TDate;
|
|
38
43
|
/**
|
|
39
44
|
* Callback fired when the value changes.
|
|
40
45
|
* @template TDate
|
|
@@ -136,7 +136,7 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
136
136
|
return /*#__PURE__*/_jsx(DigitalClockSectionItem, _extends({
|
|
137
137
|
onClick: () => !readOnly && onChange(option.value),
|
|
138
138
|
selected: isSelected,
|
|
139
|
-
disabled: disabled
|
|
139
|
+
disabled: disabled || ((_option$isDisabled2 = option.isDisabled) == null ? void 0 : _option$isDisabled2.call(option, option.value)),
|
|
140
140
|
disableRipple: readOnly,
|
|
141
141
|
role: "option"
|
|
142
142
|
// aria-readonly is not supported here and does not have any effect
|
|
@@ -136,6 +136,7 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
|
136
136
|
onClose: PropTypes.func.isRequired,
|
|
137
137
|
onDismiss: PropTypes.func.isRequired,
|
|
138
138
|
onOpen: PropTypes.func.isRequired,
|
|
139
|
+
onSelectShortcut: PropTypes.func.isRequired,
|
|
139
140
|
onSetToday: PropTypes.func.isRequired,
|
|
140
141
|
onViewChange: PropTypes.func.isRequired,
|
|
141
142
|
/**
|
|
@@ -39,6 +39,7 @@ const usePickerLayout = props => {
|
|
|
39
39
|
onViewChange,
|
|
40
40
|
value,
|
|
41
41
|
onChange,
|
|
42
|
+
onSelectShortcut,
|
|
42
43
|
isValid,
|
|
43
44
|
isLandscape,
|
|
44
45
|
disabled,
|
|
@@ -51,7 +52,7 @@ const usePickerLayout = props => {
|
|
|
51
52
|
// TODO: Remove this "as" hack. It get introduced to mark `value` prop in PickersLayoutProps as not required.
|
|
52
53
|
// The true type should be
|
|
53
54
|
// - For pickers value: TDate | null
|
|
54
|
-
// - For
|
|
55
|
+
// - For range pickers value: [TDate | null, TDate | null]
|
|
55
56
|
} = props;
|
|
56
57
|
const slots = innerSlots != null ? innerSlots : uncapitalizeObjectKeys(components);
|
|
57
58
|
const slotProps = innerSlotProps != null ? innerSlotProps : componentsProps;
|
|
@@ -121,13 +122,13 @@ const usePickerLayout = props => {
|
|
|
121
122
|
additionalProps: {
|
|
122
123
|
isValid,
|
|
123
124
|
isLandscape,
|
|
124
|
-
onChange,
|
|
125
|
+
onChange: onSelectShortcut,
|
|
125
126
|
className: classes.shortcuts
|
|
126
127
|
},
|
|
127
128
|
ownerState: {
|
|
128
129
|
isValid,
|
|
129
130
|
isLandscape,
|
|
130
|
-
onChange,
|
|
131
|
+
onChange: onSelectShortcut,
|
|
131
132
|
className: classes.shortcuts,
|
|
132
133
|
wrapperVariant
|
|
133
134
|
}
|