@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
@@ -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/modern/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.
@@ -0,0 +1,36 @@
1
+ import { getPickersLocalization } from './utils/getPickersLocalization';
2
+ const faIRPickers = {
3
+ // Calendar navigation
4
+ previousMonth: 'ماه گذشته',
5
+ nextMonth: 'ماه آینده',
6
+ // View navigation
7
+ openPreviousView: 'نمای قبلی',
8
+ openNextView: 'نمای بعدی',
9
+ calendarViewSwitchingButtonAriaLabel: view => view === 'year' ? 'نمای سال باز است، رفتن به نمای تقویم' : 'نمای تقویم باز است، رفتن به نمای سال',
10
+ inputModeToggleButtonAriaLabel: (isKeyboardInputOpen, viewType) => isKeyboardInputOpen ? `نمای ورودی متن باز است، رفتن به نمای ${viewType}` : `نمای ${viewType} باز است، رفتن به نمای ورودی متن`,
11
+ // DateRange placeholders
12
+ start: 'شروع',
13
+ end: 'پایان',
14
+ // Action bar
15
+ cancelButtonLabel: 'لغو',
16
+ clearButtonLabel: 'پاک کردن',
17
+ okButtonLabel: 'اوکی',
18
+ todayButtonLabel: 'امروز',
19
+ // Toolbar titles
20
+ datePickerDefaultToolbarTitle: 'تاریخ را انتخاب کنید',
21
+ dateTimePickerDefaultToolbarTitle: 'تاریخ و ساعت را انتخاب کنید',
22
+ timePickerDefaultToolbarTitle: 'ساعت را انتخاب کنید',
23
+ dateRangePickerDefaultToolbarTitle: 'محدوده تاریخ را انتخاب کنید',
24
+ // Clock labels
25
+ clockLabelText: (view, time, adapter) => `Select ${view}. ${time === null ? 'هیچ ساعتی انتخاب نشده است' : `ساعت انتخاب ${adapter.format(time, 'fullTime')} می باشد`}`,
26
+ hoursClockNumberText: hours => `${hours} ساعت ها`,
27
+ minutesClockNumberText: minutes => `${minutes} دقیقه ها`,
28
+ secondsClockNumberText: seconds => `${seconds} ثانیه ها`,
29
+ // Open picker labels
30
+ openDatePickerDialogue: (rawValue, utils) => rawValue && utils.isValid(utils.date(rawValue)) ? `تاریخ را انتخاب کنید، تاریخ انتخاب شده ${utils.format(utils.date(rawValue), 'fullDate')} می باشد` : 'تاریخ را انتخاب کنید',
31
+ openTimePickerDialogue: (rawValue, utils) => rawValue && utils.isValid(utils.date(rawValue)) ? `ساعت را انتخاب کنید، ساعت انتخاب شده ${utils.format(utils.date(rawValue), 'fullTime')} می باشد` : 'ساعت را انتخاب کنید',
32
+ // Table labels
33
+ timeTableLabel: 'انتخاب تاریخ',
34
+ dateTableLabel: 'انتخاب ساعت'
35
+ };
36
+ export const faIR = getPickersLocalization(faIRPickers);
@@ -0,0 +1,45 @@
1
+ import { getPickersLocalization } from './utils/getPickersLocalization';
2
+ const views = {
3
+ hours: 'tunnit',
4
+ minutes: 'minuutit',
5
+ seconds: 'sekuntit'
6
+ };
7
+ const viewTranslation = {
8
+ calendar: 'kalenteri',
9
+ clock: 'kello'
10
+ };
11
+ const fiFIPickers = {
12
+ // Calendar navigation
13
+ previousMonth: 'Edellinen kuukausi',
14
+ nextMonth: 'Seuraava kuukausi',
15
+ // View navigation
16
+ openPreviousView: 'avaa edellinen kuukausi',
17
+ openNextView: 'avaa seuraava kuukausi',
18
+ calendarViewSwitchingButtonAriaLabel: view => view === 'year' ? 'vuosinäkymä on auki, vaihda kalenterinäkymään' : 'kalenterinäkymä on auki, vaihda vuosinäkymään',
19
+ inputModeToggleButtonAriaLabel: (isKeyboardInputOpen, viewType) => isKeyboardInputOpen ? `tekstikenttä on auki, mene ${viewTranslation[viewType]}näkymään` : `${viewTranslation[viewType]}näkymä on auki, mene tekstikenttään`,
20
+ // DateRange placeholders
21
+ start: 'Alku',
22
+ end: 'Loppu',
23
+ // Action bar
24
+ cancelButtonLabel: 'Peruuta',
25
+ clearButtonLabel: 'Tyhjennä',
26
+ okButtonLabel: 'OK',
27
+ todayButtonLabel: 'Tänään',
28
+ // Toolbar titles
29
+ datePickerDefaultToolbarTitle: 'Valitse päivä',
30
+ dateTimePickerDefaultToolbarTitle: 'Valitse päivä ja aika',
31
+ timePickerDefaultToolbarTitle: 'Valitse aika',
32
+ dateRangePickerDefaultToolbarTitle: 'Valitse aikaväli',
33
+ // Clock labels
34
+ clockLabelText: (view, time, adapter) => `Valitse ${views[view]}. ${time === null ? 'Ei aikaa valittuna' : `Valittu aika on ${adapter.format(time, 'fullTime')}`}`,
35
+ hoursClockNumberText: hours => `${hours} tuntia`,
36
+ minutesClockNumberText: minutes => `${minutes} minuuttia`,
37
+ secondsClockNumberText: seconds => `${seconds} sekunttia`,
38
+ // Open picker labels
39
+ openDatePickerDialogue: (rawValue, utils) => rawValue && utils.isValid(utils.date(rawValue)) ? `Valitse päivä, valittu päivä on ${utils.format(utils.date(rawValue), 'fullDate')}` : 'Valitse päivä',
40
+ openTimePickerDialogue: (rawValue, utils) => rawValue && utils.isValid(utils.date(rawValue)) ? `Valitse aika, valittu aika on ${utils.format(utils.date(rawValue), 'fullTime')}` : 'Valitse aika',
41
+ // Table labels
42
+ timeTableLabel: 'valitse aika',
43
+ dateTableLabel: 'valitse päivä'
44
+ };
45
+ export const fiFI = getPickersLocalization(fiFIPickers);
@@ -4,6 +4,8 @@ export * from './ptBR';
4
4
  export * from './trTR';
5
5
  export * from './deDE';
6
6
  export * from './esES';
7
+ export * from './faIR';
8
+ export * from './fiFI';
7
9
  export * from './frFR';
8
10
  export * from './enUS';
9
11
  export * from './nbNO';
@@ -1,5 +1,4 @@
1
1
  import { getPickersLocalization } from './utils/getPickersLocalization';
2
- // This object is not Partial<PickersLocaleText> because it is the default values
3
2
  const isISPickers = {
4
3
  // Calendar navigation
5
4
  previousMonth: 'Fyrri mánuður',
@@ -101,9 +101,7 @@ const CalendarPickerViewTransitionContainer = (0, _styles.styled)(_PickersFadeTr
101
101
  name: 'MuiCalendarPicker',
102
102
  slot: 'ViewTransitionContainer',
103
103
  overridesResolver: (props, styles) => styles.viewTransitionContainer
104
- })({
105
- overflowY: 'auto'
106
- });
104
+ })({});
107
105
 
108
106
  /**
109
107
  *
@@ -290,6 +288,10 @@ const CalendarPicker = /*#__PURE__*/React.forwardRef(function CalendarPicker(inP
290
288
  setInternalFocusedView(prevView => prevView === eventView ? null : prevView);
291
289
  }
292
290
  });
291
+ React.useEffect(() => {
292
+ // Set focus to the button when switching from a view to another
293
+ handleFocusedViewChange(openView)(true);
294
+ }, [openView, handleFocusedViewChange]);
293
295
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CalendarPickerRoot, {
294
296
  ref: ref,
295
297
  className: (0, _clsx.default)(classes.root, className),
@@ -412,7 +414,7 @@ process.env.NODE_ENV !== "production" ? CalendarPicker.propTypes = {
412
414
  * Get aria-label text for switching between views button.
413
415
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
414
416
  * @returns {string} The label of the view.
415
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
417
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
416
418
  */
417
419
  getViewSwitchingButtonText: _propTypes.default.func,
418
420
 
@@ -393,7 +393,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
393
393
  * @param {TDate | null} time The current time.
394
394
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
395
395
  * @returns {string} The clock label.
396
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
396
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
397
397
  * @default <TDate extends any>(
398
398
  * view: ClockView,
399
399
  * time: TDate | null,
@@ -410,7 +410,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
410
410
  * @param {string} hours The hours to format.
411
411
  * @returns {string} the formatted hours text.
412
412
  * @default (hours: string) => `${hours} hours`
413
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
413
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
414
414
  */
415
415
  getHoursClockNumberText: _propTypes.default.func,
416
416
 
@@ -419,7 +419,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
419
419
  * @param {string} minutes The minutes to format.
420
420
  * @returns {string} the formatted minutes text.
421
421
  * @default (minutes: string) => `${minutes} minutes`
422
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
422
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
423
423
  */
424
424
  getMinutesClockNumberText: _propTypes.default.func,
425
425
 
@@ -428,14 +428,14 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
428
428
  * @param {string} seconds The seconds to format.
429
429
  * @returns {string} the formatted seconds text.
430
430
  * @default (seconds: string) => `${seconds} seconds`
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
  getSecondsClockNumberText: _propTypes.default.func,
434
434
 
435
435
  /**
436
436
  * Left arrow icon aria-label text.
437
437
  * @default 'open previous view'
438
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
438
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
439
439
  */
440
440
  leftArrowButtonText: _propTypes.default.string,
441
441
 
@@ -483,7 +483,7 @@ process.env.NODE_ENV !== "production" ? ClockPicker.propTypes = {
483
483
  /**
484
484
  * Right arrow icon aria-label text.
485
485
  * @default 'open next view'
486
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
486
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
487
487
  */
488
488
  rightArrowButtonText: _propTypes.default.string,
489
489
 
@@ -185,7 +185,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
185
185
  * Get aria-label text for switching between views button.
186
186
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
187
187
  * @returns {string} The label of the view.
188
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
188
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
189
189
  */
190
190
  getViewSwitchingButtonText: _propTypes.default.func,
191
191
  ignoreInvalidInputs: _propTypes.default.bool,
@@ -201,7 +201,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
201
201
  * @param {TDate | null} time The current time.
202
202
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
203
203
  * @returns {string} The clock label.
204
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
204
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
205
205
  * @default <TDate extends any>(
206
206
  * view: ClockView,
207
207
  * time: TDate | null,
@@ -227,7 +227,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
227
227
  * Get aria-label text for switching between views button.
228
228
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
229
229
  * @returns {string} The label of the view.
230
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
230
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
231
231
  */
232
232
  getViewSwitchingButtonText: _propTypes.default.func,
233
233
 
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? DesktopDatePicker.propTypes = {
189
189
  * Get aria-label text for switching between views button.
190
190
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
191
191
  * @returns {string} The label of the view.
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
  */
194
194
  getViewSwitchingButtonText: _propTypes.default.func,
195
195
  ignoreInvalidInputs: _propTypes.default.bool,
@@ -212,7 +212,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
212
212
  * @param {TDate | null} time The current time.
213
213
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
214
214
  * @returns {string} The clock label.
215
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
215
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
216
216
  * @default <TDate extends any>(
217
217
  * view: ClockView,
218
218
  * time: TDate | null,
@@ -238,7 +238,7 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePicker.propTypes = {
238
238
  * Get aria-label text for switching between views button.
239
239
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
240
240
  * @returns {string} The label of the view.
241
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
241
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
242
242
  */
243
243
  getViewSwitchingButtonText: _propTypes.default.func,
244
244
 
@@ -168,7 +168,7 @@ process.env.NODE_ENV !== "production" ? DesktopTimePicker.propTypes = {
168
168
  * @param {TDate | null} time The current time.
169
169
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
170
170
  * @returns {string} The clock label.
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
  * @default <TDate extends any>(
173
173
  * view: ClockView,
174
174
  * time: TDate | null,
@@ -190,7 +190,7 @@ process.env.NODE_ENV !== "production" ? MobileDatePicker.propTypes = {
190
190
  * Get aria-label text for switching between views button.
191
191
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
192
192
  * @returns {string} The label of the view.
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
  */
195
195
  getViewSwitchingButtonText: _propTypes.default.func,
196
196
  ignoreInvalidInputs: _propTypes.default.bool,
@@ -213,7 +213,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes = {
213
213
  * @param {TDate | null} time The current time.
214
214
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
215
215
  * @returns {string} The clock label.
216
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
216
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
217
217
  * @default <TDate extends any>(
218
218
  * view: ClockView,
219
219
  * time: TDate | null,
@@ -239,7 +239,7 @@ process.env.NODE_ENV !== "production" ? MobileDateTimePicker.propTypes = {
239
239
  * Get aria-label text for switching between views button.
240
240
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
241
241
  * @returns {string} The label of the view.
242
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
242
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
243
243
  */
244
244
  getViewSwitchingButtonText: _propTypes.default.func,
245
245
 
@@ -169,7 +169,7 @@ process.env.NODE_ENV !== "production" ? MobileTimePicker.propTypes = {
169
169
  * @param {TDate | null} time The current time.
170
170
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
171
171
  * @returns {string} The clock label.
172
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
172
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
173
173
  * @default <TDate extends any>(
174
174
  * view: ClockView,
175
175
  * time: TDate | null,
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? StaticDatePicker.propTypes = {
189
189
  * Get aria-label text for switching between views button.
190
190
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
191
191
  * @returns {string} The label of the view.
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
  */
194
194
  getViewSwitchingButtonText: _propTypes.default.func,
195
195
  ignoreInvalidInputs: _propTypes.default.bool,
@@ -213,7 +213,7 @@ process.env.NODE_ENV !== "production" ? StaticDateTimePicker.propTypes = {
213
213
  * @param {TDate | null} time The current time.
214
214
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
215
215
  * @returns {string} The clock label.
216
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
216
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
217
217
  * @default <TDate extends any>(
218
218
  * view: ClockView,
219
219
  * time: TDate | null,
@@ -239,7 +239,7 @@ process.env.NODE_ENV !== "production" ? StaticDateTimePicker.propTypes = {
239
239
  * Get aria-label text for switching between views button.
240
240
  * @param {CalendarPickerView} currentView The view from which we want to get the button text.
241
241
  * @returns {string} The label of the view.
242
- * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization
242
+ * @deprecated Use the `localeText` prop of `LocalizationProvider` instead, see https://mui.com/x/react-date-pickers/localization/.
243
243
  */
244
244
  getViewSwitchingButtonText: _propTypes.default.func,
245
245
 
@@ -167,7 +167,7 @@ process.env.NODE_ENV !== "production" ? StaticTimePicker.propTypes = {
167
167
  * @param {TDate | null} time The current time.
168
168
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
169
169
  * @returns {string} The clock label.
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
  * @default <TDate extends any>(
172
172
  * view: ClockView,
173
173
  * time: TDate | null,
@@ -164,7 +164,7 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
164
164
  * @param {TDate | null} time The current time.
165
165
  * @param {MuiPickersAdapter<TDate>} adapter The current date adapter.
166
166
  * @returns {string} The clock label.
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
  * @default <TDate extends any>(
169
169
  * view: ClockView,
170
170
  * time: TDate | null,
@@ -128,11 +128,11 @@ const PickersYear = /*#__PURE__*/React.forwardRef(function PickersYear(props, fo
128
128
  const ownerState = (0, _extends2.default)({}, props, {
129
129
  wrapperVariant
130
130
  });
131
- const classes = useUtilityClasses(ownerState); // TODO: Can we just forward this to the button?
131
+ const classes = useUtilityClasses(ownerState); // We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
132
132
 
133
133
  React.useEffect(() => {
134
134
  if (autoFocus) {
135
- // `ref.current` being `null` would be a bug in MUIu
135
+ // `ref.current` being `null` would be a bug in MUI.
136
136
  ref.current.focus();
137
137
  }
138
138
  }, [autoFocus]);
@@ -17,9 +17,11 @@ var _styles = require("@mui/material/styles");
17
17
 
18
18
  var _material = require("@mui/material");
19
19
 
20
+ var _clsx = _interopRequireDefault(require("clsx"));
21
+
20
22
  var _utils = require("@mui/material/utils");
21
23
 
22
- var _clsx = _interopRequireDefault(require("clsx"));
24
+ var _utils2 = require("@mui/utils");
23
25
 
24
26
  var _PickersYear = require("./PickersYear");
25
27
 
@@ -73,7 +75,8 @@ const YearPickerRoot = (0, _styles.styled)('div', {
73
75
  flexWrap: 'wrap',
74
76
  overflowY: 'auto',
75
77
  height: '100%',
76
- margin: '0 4px'
78
+ padding: '0 4px',
79
+ maxHeight: '304px'
77
80
  });
78
81
  const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref) {
79
82
  const now = (0, _useUtils.useNow)();
@@ -114,7 +117,7 @@ const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, re
114
117
  const wrapperVariant = React.useContext(_WrapperVariantContext.WrapperVariantContext);
115
118
  const selectedYearRef = React.useRef(null);
116
119
  const [focusedYear, setFocusedYear] = React.useState(() => currentYear || utils.getYear(now));
117
- const [internalHasFocus, setInternalHasFocus] = (0, _utils.useControlled)({
120
+ const [internalHasFocus, setInternalHasFocus] = (0, _utils2.unstable_useControlled)({
118
121
  name: 'YearPicker',
119
122
  state: 'hasFocus',
120
123
  controlled: hasFocus,
@@ -206,8 +209,35 @@ const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, re
206
209
  }
207
210
  }, [focusedYear, changeHasFocus]);
208
211
  const nowYear = utils.getYear(now);
212
+ const scrollerRef = React.useRef(null);
213
+ const handleRef = (0, _utils.useForkRef)(ref, scrollerRef);
214
+ React.useEffect(() => {
215
+ if (autoFocus || scrollerRef.current === null) {
216
+ return;
217
+ }
218
+
219
+ const tabbableButton = scrollerRef.current.querySelector('[tabindex="0"]');
220
+
221
+ if (!tabbableButton) {
222
+ return;
223
+ } // Taken from useScroll in x-data-grid, but vertically centered
224
+
225
+
226
+ const offsetHeight = tabbableButton.offsetHeight;
227
+ const offsetTop = tabbableButton.offsetTop;
228
+ const clientHeight = scrollerRef.current.clientHeight;
229
+ const scrollTop = scrollerRef.current.scrollTop;
230
+ const elementBottom = offsetTop + offsetHeight;
231
+
232
+ if (offsetHeight > clientHeight || offsetTop < scrollTop) {
233
+ // Button already visible
234
+ return;
235
+ }
236
+
237
+ scrollerRef.current.scrollTop = elementBottom - clientHeight / 2 - offsetHeight / 2;
238
+ }, [autoFocus]);
209
239
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(YearPickerRoot, {
210
- ref: ref,
240
+ ref: handleRef,
211
241
  className: (0, _clsx.default)(classes.root, className),
212
242
  ownerState: ownerState,
213
243
  children: utils.getYearRange(minDate, maxDate).map(year => {
package/node/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.