@mui/x-date-pickers 5.0.2 → 5.0.3

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/CalendarPicker/CalendarPicker.js +6 -4
  3. package/CalendarPicker/PickersCalendarHeader.d.ts +1 -1
  4. package/ClockPicker/ClockPicker.d.ts +6 -6
  5. package/ClockPicker/ClockPicker.js +6 -6
  6. package/DatePicker/DatePicker.js +1 -1
  7. package/DateTimePicker/DateTimePicker.js +2 -2
  8. package/DesktopDatePicker/DesktopDatePicker.js +1 -1
  9. package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  10. package/DesktopTimePicker/DesktopTimePicker.js +1 -1
  11. package/MobileDatePicker/MobileDatePicker.js +1 -1
  12. package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  13. package/MobileTimePicker/MobileTimePicker.js +1 -1
  14. package/StaticDatePicker/StaticDatePicker.js +1 -1
  15. package/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  16. package/StaticTimePicker/StaticTimePicker.js +1 -1
  17. package/TimePicker/TimePicker.js +1 -1
  18. package/YearPicker/PickersYear.js +2 -2
  19. package/YearPicker/YearPicker.js +32 -3
  20. package/index.js +1 -1
  21. package/internals/models/muiPickersAdapter.d.ts +12 -7
  22. package/legacy/CalendarPicker/CalendarPicker.js +6 -4
  23. package/legacy/ClockPicker/ClockPicker.js +6 -6
  24. package/legacy/DatePicker/DatePicker.js +1 -1
  25. package/legacy/DateTimePicker/DateTimePicker.js +2 -2
  26. package/legacy/DesktopDatePicker/DesktopDatePicker.js +1 -1
  27. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  28. package/legacy/DesktopTimePicker/DesktopTimePicker.js +1 -1
  29. package/legacy/MobileDatePicker/MobileDatePicker.js +1 -1
  30. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  31. package/legacy/MobileTimePicker/MobileTimePicker.js +1 -1
  32. package/legacy/StaticDatePicker/StaticDatePicker.js +1 -1
  33. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  34. package/legacy/StaticTimePicker/StaticTimePicker.js +1 -1
  35. package/legacy/TimePicker/TimePicker.js +1 -1
  36. package/legacy/YearPicker/PickersYear.js +2 -2
  37. package/legacy/YearPicker/YearPicker.js +32 -3
  38. package/legacy/index.js +1 -1
  39. package/legacy/locales/faIR.js +52 -0
  40. package/legacy/locales/fiFI.js +61 -0
  41. package/legacy/locales/index.js +2 -0
  42. package/legacy/locales/isIS.js +0 -1
  43. package/locales/faIR.d.ts +35 -0
  44. package/locales/faIR.js +36 -0
  45. package/locales/fiFI.d.ts +35 -0
  46. package/locales/fiFI.js +45 -0
  47. package/locales/index.d.ts +2 -0
  48. package/locales/index.js +2 -0
  49. package/locales/isIS.js +0 -1
  50. package/modern/CalendarPicker/CalendarPicker.js +6 -4
  51. package/modern/ClockPicker/ClockPicker.js +6 -6
  52. package/modern/DatePicker/DatePicker.js +1 -1
  53. package/modern/DateTimePicker/DateTimePicker.js +2 -2
  54. package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
  55. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  56. package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -1
  57. package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
  58. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  59. package/modern/MobileTimePicker/MobileTimePicker.js +1 -1
  60. package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
  61. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  62. package/modern/StaticTimePicker/StaticTimePicker.js +1 -1
  63. package/modern/TimePicker/TimePicker.js +1 -1
  64. package/modern/YearPicker/PickersYear.js +2 -2
  65. package/modern/YearPicker/YearPicker.js +32 -3
  66. package/modern/index.js +1 -1
  67. package/modern/locales/faIR.js +36 -0
  68. package/modern/locales/fiFI.js +45 -0
  69. package/modern/locales/index.js +2 -0
  70. package/modern/locales/isIS.js +0 -1
  71. package/node/CalendarPicker/CalendarPicker.js +6 -4
  72. package/node/ClockPicker/ClockPicker.js +6 -6
  73. package/node/DatePicker/DatePicker.js +1 -1
  74. package/node/DateTimePicker/DateTimePicker.js +2 -2
  75. package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
  76. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
  77. package/node/DesktopTimePicker/DesktopTimePicker.js +1 -1
  78. package/node/MobileDatePicker/MobileDatePicker.js +1 -1
  79. package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  80. package/node/MobileTimePicker/MobileTimePicker.js +1 -1
  81. package/node/StaticDatePicker/StaticDatePicker.js +1 -1
  82. package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
  83. package/node/StaticTimePicker/StaticTimePicker.js +1 -1
  84. package/node/TimePicker/TimePicker.js +1 -1
  85. package/node/YearPicker/PickersYear.js +2 -2
  86. package/node/YearPicker/YearPicker.js +34 -4
  87. package/node/index.js +1 -1
  88. package/node/locales/faIR.js +45 -0
  89. package/node/locales/fiFI.js +54 -0
  90. package/node/locales/index.js +26 -0
  91. package/node/locales/isIS.js +0 -1
  92. package/package.json +1 -1
  93. package/internals/models/muiPickersAdapter.js +0 -1
  94. package/legacy/internals/models/muiPickersAdapter.js +0 -1
  95. package/modern/internals/models/muiPickersAdapter.js +0 -1
  96. package/node/internals/models/muiPickersAdapter.js +0 -5
package/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
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
+ ## v5.17.4
7
+
8
+ _Sep 22, 2022_
9
+
10
+ We'd like to offer a big thanks to the 5 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🌍 Add Finnish (fi-FI) locale to the pickers (#6230) @PetroSilenius
13
+ - 🌍 Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
14
+ - 🐞 Bugfixes
15
+
16
+ ### `@mui/x-data-grid@v5.17.4` / `@mui/x-data-grid-pro@v5.17.4` / `@mui/x-data-grid-premium@v5.17.4`
17
+
18
+ #### Changes
19
+
20
+ - [DataGrid] Do not publish `cellFocusOut` event if the row was removed (#6251) @cherniavskii
21
+ - [DataGrid] Improve Polish (pl-PL) locale on the data grid (#6245) @grzegorz-bach
22
+
23
+ ### `@mui/x-date-pickers@v5.0.3` / `@mui/x-date-pickers-pro@v5.0.3`
24
+
25
+ #### Changes
26
+
27
+ - [pickers] Add Finnish (fi-FI) locale to pickers (#6219) (#6230) @PetroSilenius
28
+ - [pickers] Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
29
+ - [pickers] Fix usage with Typescript 4.8 (#6229) @flaviendelangle
30
+ - [YearPicker] Scroll to the current year even with `autoFocus=false` (#6224) @alexfauquette
31
+
32
+ ### Docs
33
+
34
+ - [docs] Fix 301 link (#6239) @oliviertassinari
35
+
36
+ ### Core
37
+
38
+ - [core] Use the official repository for `@mui/monorepo` instead of a fork (#6189) @oliviertassinari
39
+
6
40
  ## 5.17.3
7
41
 
8
42
  _Sep 16, 2022_
@@ -101,7 +135,7 @@ We'd like to offer a big thanks to the 3 contributors who made this release poss
101
135
 
102
136
  _Sep 2, 2022_
103
137
 
104
- 🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
138
+ 🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
105
139
 
106
140
  If you are still using picker components from the `lab`, take a look at the [migration guide](https://mui.com/x/react-date-pickers/migration-lab/).
107
141
 
@@ -68,9 +68,7 @@ const CalendarPickerViewTransitionContainer = styled(PickersFadeTransitionGroup,
68
68
  name: 'MuiCalendarPicker',
69
69
  slot: 'ViewTransitionContainer',
70
70
  overridesResolver: (props, styles) => styles.viewTransitionContainer
71
- })({
72
- overflowY: 'auto'
73
- });
71
+ })({});
74
72
 
75
73
  /**
76
74
  *
@@ -259,6 +257,10 @@ export const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPic
259
257
  setInternalFocusedView(prevView => prevView === eventView ? null : prevView);
260
258
  }
261
259
  });
260
+ React.useEffect(() => {
261
+ // Set focus to the button when switching from a view to another
262
+ handleFocusedViewChange(openView)(true);
263
+ }, [openView, handleFocusedViewChange]);
262
264
  return /*#__PURE__*/_jsxs(CalendarPickerRoot, {
263
265
  ref: ref,
264
266
  className: clsx(classes.root, className),
@@ -380,7 +382,7 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
380
382
  * Get aria-label text for switching between views button.
381
383
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
382
384
  * @returns {string} The label of the view.
383
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
385
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
384
386
  */
385
387
  getViewSwitchingButtonText: PropTypes.func,
386
388
 
@@ -41,7 +41,7 @@ export interface PickersCalendarHeaderProps<TDate> extends ExportedArrowSwitcher
41
41
  * Get aria-label text for switching between views button.
42
42
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
43
43
  * @returns {string} The label of the view.
44
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
44
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
45
45
  */
46
46
  getViewSwitchingButtonText?: (currentView: CalendarPickerView) => string;
47
47
  onMonthChange: (date: TDate, slideDirection: SlideDirection) => void;
@@ -22,7 +22,7 @@ export interface ExportedClockPickerProps<TDate> extends ExportedTimeValidationP
22
22
  * @param {TDate | null} time The current time.
23
23
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
24
24
  * @returns {string} The clock label.
25
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
25
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
26
26
  * @default <TDate extends any>(
27
27
  * view: ClockView,
28
28
  * time: TDate | null,
@@ -69,7 +69,7 @@ export interface ClockPickerProps<TDate> extends ExportedClockPickerProps<TDate>
69
69
  * @param {string} hours The hours to format.
70
70
  * @returns {string} the formatted hours text.
71
71
  * @default (hours: string) => `${hours} hours`
72
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
72
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
73
73
  */
74
74
  getHoursClockNumberText?: (hours: string) => string;
75
75
  /**
@@ -77,7 +77,7 @@ export interface ClockPickerProps<TDate> extends ExportedClockPickerProps<TDate>
77
77
  * @param {string} minutes The minutes to format.
78
78
  * @returns {string} the formatted minutes text.
79
79
  * @default (minutes: string) => `${minutes} minutes`
80
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
80
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
81
81
  */
82
82
  getMinutesClockNumberText?: (minutes: string) => string;
83
83
  /**
@@ -85,13 +85,13 @@ export interface ClockPickerProps<TDate> extends ExportedClockPickerProps<TDate>
85
85
  * @param {string} seconds The seconds to format.
86
86
  * @returns {string} the formatted seconds text.
87
87
  * @default (seconds: string) => `${seconds} seconds`
88
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
88
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
89
89
  */
90
90
  getSecondsClockNumberText?: (seconds: string) => string;
91
91
  /**
92
92
  * Left arrow icon aria-label text.
93
93
  * @default 'open previous view'
94
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
94
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
95
95
  */
96
96
  leftArrowButtonText?: string;
97
97
  /**
@@ -101,7 +101,7 @@ export interface ClockPickerProps<TDate> extends ExportedClockPickerProps<TDate>
101
101
  /**
102
102
  * Right arrow icon aria-label text.
103
103
  * @default 'open next view'
104
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
104
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
105
105
  */
106
106
  rightArrowButtonText?: string;
107
107
  showViewSwitcher?: boolean;
@@ -363,7 +363,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
363
363
  * @param {TDate | null} time The current time.
364
364
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
365
365
  * @returns {string} The clock label.
366
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
366
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
367
367
  * @default <TDate extends any>(
368
368
  * view: ClockView,
369
369
  * time: TDate | null,
@@ -380,7 +380,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
380
380
  * @param {string} hours The hours to format.
381
381
  * @returns {string} the formatted hours text.
382
382
  * @default (hours: string) => `${hours} hours`
383
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
383
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
384
384
  */
385
385
  getHoursClockNumberText: PropTypes.func,
386
386
 
@@ -389,7 +389,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
389
389
  * @param {string} minutes The minutes to format.
390
390
  * @returns {string} the formatted minutes text.
391
391
  * @default (minutes: string) => `${minutes} minutes`
392
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
392
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
393
393
  */
394
394
  getMinutesClockNumberText: PropTypes.func,
395
395
 
@@ -398,14 +398,14 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
398
398
  * @param {string} seconds The seconds to format.
399
399
  * @returns {string} the formatted seconds text.
400
400
  * @default (seconds: string) => `${seconds} seconds`
401
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
401
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
402
402
  */
403
403
  getSecondsClockNumberText: PropTypes.func,
404
404
 
405
405
  /**
406
406
  * Left arrow icon aria-label text.
407
407
  * @default 'open previous view'
408
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
408
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
409
409
  */
410
410
  leftArrowButtonText: PropTypes.string,
411
411
 
@@ -453,7 +453,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
453
453
  /**
454
454
  * Right arrow icon aria-label text.
455
455
  * @default 'open next view'
456
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
456
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
457
457
  */
458
458
  rightArrowButtonText: PropTypes.string,
459
459
 
@@ -164,7 +164,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
164
164
  * Get aria-label text for switching between views button.
165
165
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
166
166
  * @returns {string} The label of the view.
167
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
167
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
168
168
  */
169
169
  getViewSwitchingButtonText: PropTypes.func,
170
170
  ignoreInvalidInputs: PropTypes.bool,
@@ -180,7 +180,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
180
180
  * @param {TDate | null} time The current time.
181
181
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
182
182
  * @returns {string} The clock label.
183
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
183
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
184
184
  * @default <TDate extends any>(
185
185
  * view: ClockView,
186
186
  * time: TDate | null,
@@ -206,7 +206,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
206
206
  * Get aria-label text for switching between views button.
207
207
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
208
208
  * @returns {string} The label of the view.
209
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
209
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
210
210
  */
211
211
  getViewSwitchingButtonText: PropTypes.func,
212
212
 
@@ -166,7 +166,7 @@ process.env.NODE_ENV !== "production" ? DesktopDatePicker.propTypes = {
166
166
  * Get aria-label text for switching between views button.
167
167
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
168
168
  * @returns {string} The label of the view.
169
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
169
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
170
170
  */
171
171
  getViewSwitchingButtonText: PropTypes.func,
172
172
  ignoreInvalidInputs: PropTypes.bool,
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
189
189
  * @param {TDate | null} time The current time.
190
190
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
191
191
  * @returns {string} The clock label.
192
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
192
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
193
193
  * @default <TDate extends any>(
194
194
  * view: ClockView,
195
195
  * time: TDate | null,
@@ -215,7 +215,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
215
215
  * Get aria-label text for switching between views button.
216
216
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
217
217
  * @returns {string} The label of the view.
218
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
218
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
219
219
  */
220
220
  getViewSwitchingButtonText: PropTypes.func,
221
221
 
@@ -145,7 +145,7 @@ process.env.NODE_ENV !== "production" ? DesktopTimePicker.propTypes = {
145
145
  * @param {TDate | null} time The current time.
146
146
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
147
147
  * @returns {string} The clock label.
148
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
148
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
149
149
  * @default <TDate extends any>(
150
150
  * view: ClockView,
151
151
  * time: TDate | null,
@@ -166,7 +166,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes = {
166
166
  * Get aria-label text for switching between views button.
167
167
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
168
168
  * @returns {string} The label of the view.
169
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
169
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
170
170
  */
171
171
  getViewSwitchingButtonText: PropTypes.func,
172
172
  ignoreInvalidInputs: PropTypes.bool,
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes = {
189
189
  * @param {TDate | null} time The current time.
190
190
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
191
191
  * @returns {string} The clock label.
192
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
192
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
193
193
  * @default <TDate extends any>(
194
194
  * view: ClockView,
195
195
  * time: TDate | null,
@@ -215,7 +215,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes = {
215
215
  * Get aria-label text for switching between views button.
216
216
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
217
217
  * @returns {string} The label of the view.
218
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
218
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
219
219
  */
220
220
  getViewSwitchingButtonText: PropTypes.func,
221
221
 
@@ -145,7 +145,7 @@ process.env.NODE_ENV !== "production" ? MobileTimePicker.propTypes = {
145
145
  * @param {TDate | null} time The current time.
146
146
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
147
147
  * @returns {string} The clock label.
148
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
148
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
149
149
  * @default <TDate extends any>(
150
150
  * view: ClockView,
151
151
  * time: TDate | null,
@@ -167,7 +167,7 @@ process.env.NODE_ENV !== "production" ? StaticDatePicker.propTypes = {
167
167
  * Get aria-label text for switching between views button.
168
168
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
169
169
  * @returns {string} The label of the view.
170
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
170
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
171
171
  */
172
172
  getViewSwitchingButtonText: PropTypes.func,
173
173
  ignoreInvalidInputs: PropTypes.bool,
@@ -190,7 +190,7 @@ process.env.NODE_ENV !== "production" ? StaticDateTimePicker.propTypes = {
190
190
  * @param {TDate | null} time The current time.
191
191
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
192
192
  * @returns {string} The clock label.
193
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
193
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
194
194
  * @default <TDate extends any>(
195
195
  * view: ClockView,
196
196
  * time: TDate | null,
@@ -216,7 +216,7 @@ process.env.NODE_ENV !== "production" ? StaticDateTimePicker.propTypes = {
216
216
  * Get aria-label text for switching between views button.
217
217
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
218
218
  * @returns {string} The label of the view.
219
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
219
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
220
220
  */
221
221
  getViewSwitchingButtonText: PropTypes.func,
222
222
 
@@ -146,7 +146,7 @@ process.env.NODE_ENV !== "production" ? StaticTimePicker.propTypes = {
146
146
  * @param {TDate | null} time The current time.
147
147
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
148
148
  * @returns {string} The clock label.
149
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
149
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
150
150
  * @default <TDate extends any>(
151
151
  * view: ClockView,
152
152
  * time: TDate | null,
@@ -143,7 +143,7 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
143
143
  * @param {TDate | null} time The current time.
144
144
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
145
145
  * @returns {string} The clock label.
146
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
146
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
147
147
  * @default <TDate extends any>(
148
148
  * view: ClockView,
149
149
  * time: TDate | null,
@@ -108,11 +108,11 @@ export const PickersYear = /*#__PURE__*/React.forwardRef(function PickersYear(pr
108
108
  wrapperVariant
109
109
  });
110
110
 
111
- const classes = useUtilityClasses(ownerState); // TODO: Can we just forward this to the button?
111
+ const classes = useUtilityClasses(ownerState); // We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
112
112
 
113
113
  React.useEffect(() => {
114
114
  if (autoFocus) {
115
- // `ref.current` being `null` would be a bug in MUIu
115
+ // `ref.current` being `null` would be a bug in MUI.
116
116
  ref.current.focus();
117
117
  }
118
118
  }, [autoFocus]);
@@ -3,8 +3,9 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { useTheme, styled, useThemeProps } from '@mui/material/styles';
5
5
  import { unstable_composeClasses as composeClasses } from '@mui/material';
6
- import { useControlled } from '@mui/material/utils';
7
6
  import clsx from 'clsx';
7
+ import { useForkRef } from '@mui/material/utils';
8
+ import { unstable_useControlled as useControlled } from '@mui/utils';
8
9
  import { PickersYear } from './PickersYear';
9
10
  import { useUtils, useNow, useDefaultDates } from '../internals/hooks/useUtils';
10
11
  import { WrapperVariantContext } from '../internals/components/wrappers/WrapperVariantContext';
@@ -48,7 +49,8 @@ const YearPickerRoot = styled('div', {
48
49
  flexWrap: 'wrap',
49
50
  overflowY: 'auto',
50
51
  height: '100%',
51
- margin: '0 4px'
52
+ padding: '0 4px',
53
+ maxHeight: '304px'
52
54
  });
53
55
  export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref) {
54
56
  const now = useNow();
@@ -181,8 +183,35 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
181
183
  }
182
184
  }, [focusedYear, changeHasFocus]);
183
185
  const nowYear = utils.getYear(now);
186
+ const scrollerRef = React.useRef(null);
187
+ const handleRef = useForkRef(ref, scrollerRef);
188
+ React.useEffect(() => {
189
+ if (autoFocus || scrollerRef.current === null) {
190
+ return;
191
+ }
192
+
193
+ const tabbableButton = scrollerRef.current.querySelector('[tabindex="0"]');
194
+
195
+ if (!tabbableButton) {
196
+ return;
197
+ } // Taken from useScroll in x-data-grid, but vertically centered
198
+
199
+
200
+ const offsetHeight = tabbableButton.offsetHeight;
201
+ const offsetTop = tabbableButton.offsetTop;
202
+ const clientHeight = scrollerRef.current.clientHeight;
203
+ const scrollTop = scrollerRef.current.scrollTop;
204
+ const elementBottom = offsetTop + offsetHeight;
205
+
206
+ if (offsetHeight > clientHeight || offsetTop < scrollTop) {
207
+ // Button already visible
208
+ return;
209
+ }
210
+
211
+ scrollerRef.current.scrollTop = elementBottom - clientHeight / 2 - offsetHeight / 2;
212
+ }, [autoFocus]);
184
213
  return /*#__PURE__*/_jsx(YearPickerRoot, {
185
- ref: ref,
214
+ ref: handleRef,
186
215
  className: clsx(classes.root, className),
187
216
  ownerState: ownerState,
188
217
  children: utils.getYearRange(minDate, maxDate).map(year => {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.0.2
1
+ /** @license MUI v5.0.3
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,10 +1,15 @@
1
1
  import { IUtils } from '@date-io/core/IUtils';
2
- export declare type MuiPickersAdapter<TDate> = IUtils<TDate>;
3
- export declare type MuiDateSectionName = 'day' | 'month' | 'year' | 'hour' | 'minute' | 'second' | 'am-pm';
4
- export declare type MuiFormatTokenMap = {
5
- [formatToken: string]: MuiDateSectionName;
6
- };
2
+
3
+ // TODO: Maybe we should add the same constraint.
4
+ // @ts-expect-error TDate in our codebase does not have the `ExtendableDateType` constraint.
5
+ export type MuiPickersAdapter<TDate> = IUtils<TDate>;
6
+
7
+ export type MuiDateSectionName = 'day' | 'month' | 'year' | 'hour' | 'minute' | 'second' | 'am-pm';
8
+
9
+ export type MuiFormatTokenMap = { [formatToken: string]: MuiDateSectionName };
10
+
7
11
  export interface MuiPickerFieldAdapter<TDate> extends MuiPickersAdapter<TDate> {
8
- formatTokenMap: MuiFormatTokenMap;
9
- expandFormat: (format: string) => string;
12
+ formatTokenMap: MuiFormatTokenMap;
13
+
14
+ expandFormat: (format: string) => string;
10
15
  }
@@ -73,9 +73,7 @@ var CalendarPickerViewTransitionContainer = styled(PickersFadeTransitionGroup, {
73
73
  overridesResolver: function overridesResolver(props, styles) {
74
74
  return styles.viewTransitionContainer;
75
75
  }
76
- })({
77
- overflowY: 'auto'
78
- });
76
+ })({});
79
77
 
80
78
  /**
81
79
  *
@@ -272,6 +270,10 @@ export var CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicke
272
270
  }
273
271
  };
274
272
  });
273
+ React.useEffect(function () {
274
+ // Set focus to the button when switching from a view to another
275
+ handleFocusedViewChange(openView)(true);
276
+ }, [openView, handleFocusedViewChange]);
275
277
  return /*#__PURE__*/_jsxs(CalendarPickerRoot, {
276
278
  ref: ref,
277
279
  className: clsx(classes.root, className),
@@ -395,7 +397,7 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
395
397
  * Get aria-label text for switching between views button.
396
398
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
397
399
  * @returns {string} The label of the view.
398
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
400
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
399
401
  */
400
402
  getViewSwitchingButtonText: PropTypes.func,
401
403
 
@@ -386,7 +386,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
386
386
  * @param {TDate | null} time The current time.
387
387
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
388
388
  * @returns {string} The clock label.
389
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
389
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
390
390
  * @default <TDate extends any>(
391
391
  * view: ClockView,
392
392
  * time: TDate | null,
@@ -403,7 +403,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
403
403
  * @param {string} hours The hours to format.
404
404
  * @returns {string} the formatted hours text.
405
405
  * @default (hours: string) => `${hours} hours`
406
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
406
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
407
407
  */
408
408
  getHoursClockNumberText: PropTypes.func,
409
409
 
@@ -412,7 +412,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
412
412
  * @param {string} minutes The minutes to format.
413
413
  * @returns {string} the formatted minutes text.
414
414
  * @default (minutes: string) => `${minutes} minutes`
415
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
415
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
416
416
  */
417
417
  getMinutesClockNumberText: PropTypes.func,
418
418
 
@@ -421,14 +421,14 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
421
421
  * @param {string} seconds The seconds to format.
422
422
  * @returns {string} the formatted seconds text.
423
423
  * @default (seconds: string) => `${seconds} seconds`
424
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
424
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
425
425
  */
426
426
  getSecondsClockNumberText: PropTypes.func,
427
427
 
428
428
  /**
429
429
  * Left arrow icon aria-label text.
430
430
  * @default 'open previous view'
431
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
431
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
432
432
  */
433
433
  leftArrowButtonText: PropTypes.string,
434
434
 
@@ -476,7 +476,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
476
476
  /**
477
477
  * Right arrow icon aria-label text.
478
478
  * @default 'open next view'
479
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
479
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
480
480
  */
481
481
  rightArrowButtonText: PropTypes.string,
482
482
 
@@ -163,7 +163,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
163
163
  * Get aria-label text for switching between views button.
164
164
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
165
165
  * @returns {string} The label of the view.
166
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
166
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
167
167
  */
168
168
  getViewSwitchingButtonText: PropTypes.func,
169
169
  ignoreInvalidInputs: PropTypes.bool,
@@ -179,7 +179,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
179
179
  * @param {TDate | null} time The current time.
180
180
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
181
181
  * @returns {string} The clock label.
182
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
182
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
183
183
  * @default <TDate extends any>(
184
184
  * view: ClockView,
185
185
  * time: TDate | null,
@@ -205,7 +205,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
205
205
  * Get aria-label text for switching between views button.
206
206
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
207
207
  * @returns {string} The label of the view.
208
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
208
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
209
209
  */
210
210
  getViewSwitchingButtonText: PropTypes.func,
211
211
 
@@ -167,7 +167,7 @@ process.env.NODE_ENV !== "production" ? DesktopDatePicker.propTypes = {
167
167
  * Get aria-label text for switching between views button.
168
168
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
169
169
  * @returns {string} The label of the view.
170
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
170
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
171
171
  */
172
172
  getViewSwitchingButtonText: PropTypes.func,
173
173
  ignoreInvalidInputs: PropTypes.bool,
@@ -193,7 +193,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
193
193
  * @param {TDate | null} time The current time.
194
194
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
195
195
  * @returns {string} The clock label.
196
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
196
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
197
197
  * @default <TDate extends any>(
198
198
  * view: ClockView,
199
199
  * time: TDate | null,
@@ -219,7 +219,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
219
219
  * Get aria-label text for switching between views button.
220
220
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
221
221
  * @returns {string} The label of the view.
222
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
222
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
223
223
  */
224
224
  getViewSwitchingButtonText: PropTypes.func,
225
225
 
@@ -146,7 +146,7 @@ process.env.NODE_ENV !== "production" ? DesktopTimePicker.propTypes = {
146
146
  * @param {TDate | null} time The current time.
147
147
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
148
148
  * @returns {string} The clock label.
149
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
149
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
150
150
  * @default <TDate extends any>(
151
151
  * view: ClockView,
152
152
  * time: TDate | null,
@@ -168,7 +168,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes = {
168
168
  * Get aria-label text for switching between views button.
169
169
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
170
170
  * @returns {string} The label of the view.
171
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
171
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
172
172
  */
173
173
  getViewSwitchingButtonText: PropTypes.func,
174
174
  ignoreInvalidInputs: PropTypes.bool,