@mui/x-date-pickers 6.6.0 → 6.7.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.
Files changed (108) hide show
  1. package/AdapterDateFns/AdapterDateFns.js +20 -19
  2. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +17 -16
  3. package/AdapterDayjs/AdapterDayjs.js +12 -11
  4. package/AdapterLuxon/AdapterLuxon.js +20 -19
  5. package/AdapterMoment/AdapterMoment.js +12 -11
  6. package/AdapterMomentHijri/AdapterMomentHijri.js +20 -19
  7. package/AdapterMomentJalaali/AdapterMomentJalaali.js +20 -19
  8. package/CHANGELOG.md +72 -0
  9. package/DatePicker/DatePickerToolbar.js +6 -15
  10. package/DatePicker/shared.d.ts +1 -5
  11. package/DatePicker/shared.js +1 -16
  12. package/DesktopDatePicker/DesktopDatePicker.js +3 -2
  13. package/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
  14. package/DesktopTimePicker/DesktopTimePicker.js +5 -1
  15. package/LocalizationProvider/LocalizationProvider.js +1 -0
  16. package/MobileDatePicker/MobileDatePicker.js +3 -2
  17. package/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
  18. package/MobileTimePicker/MobileTimePicker.js +5 -1
  19. package/TimePicker/shared.d.ts +1 -1
  20. package/index.js +1 -1
  21. package/internals/utils/date-time-utils.d.ts +6 -0
  22. package/internals/utils/date-time-utils.js +41 -0
  23. package/internals/utils/date-utils.d.ts +4 -0
  24. package/internals/utils/date-utils.js +33 -1
  25. package/internals/utils/time-utils.d.ts +6 -1
  26. package/internals/utils/time-utils.js +27 -0
  27. package/internals/utils/validation/extractValidationProps.d.ts +1 -1
  28. package/internals/utils/views.d.ts +2 -3
  29. package/internals/utils/views.js +6 -2
  30. package/legacy/AdapterDateFns/AdapterDateFns.js +20 -19
  31. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +17 -16
  32. package/legacy/AdapterDayjs/AdapterDayjs.js +12 -11
  33. package/legacy/AdapterLuxon/AdapterLuxon.js +20 -19
  34. package/legacy/AdapterMoment/AdapterMoment.js +12 -11
  35. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +20 -19
  36. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +20 -19
  37. package/legacy/DatePicker/DatePickerToolbar.js +6 -15
  38. package/legacy/DatePicker/shared.js +1 -15
  39. package/legacy/DesktopDatePicker/DesktopDatePicker.js +3 -2
  40. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
  41. package/legacy/DesktopTimePicker/DesktopTimePicker.js +5 -1
  42. package/legacy/LocalizationProvider/LocalizationProvider.js +1 -0
  43. package/legacy/MobileDatePicker/MobileDatePicker.js +3 -2
  44. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
  45. package/legacy/MobileTimePicker/MobileTimePicker.js +5 -1
  46. package/legacy/index.js +1 -1
  47. package/legacy/internals/utils/date-time-utils.js +39 -0
  48. package/legacy/internals/utils/date-utils.js +31 -0
  49. package/legacy/internals/utils/time-utils.js +26 -0
  50. package/legacy/internals/utils/views.js +7 -5
  51. package/legacy/locales/deDE.js +2 -2
  52. package/legacy/locales/index.js +16 -15
  53. package/legacy/locales/roRO.js +81 -0
  54. package/locales/deDE.js +2 -2
  55. package/locales/index.d.ts +16 -15
  56. package/locales/index.js +16 -15
  57. package/locales/roRO.d.ts +53 -0
  58. package/locales/roRO.js +63 -0
  59. package/models/adapters.d.ts +137 -37
  60. package/modern/AdapterDateFns/AdapterDateFns.js +20 -19
  61. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +17 -16
  62. package/modern/AdapterDayjs/AdapterDayjs.js +12 -11
  63. package/modern/AdapterLuxon/AdapterLuxon.js +20 -19
  64. package/modern/AdapterMoment/AdapterMoment.js +12 -11
  65. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +20 -19
  66. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +20 -19
  67. package/modern/DatePicker/DatePickerToolbar.js +6 -15
  68. package/modern/DatePicker/shared.js +1 -16
  69. package/modern/DesktopDatePicker/DesktopDatePicker.js +3 -2
  70. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
  71. package/modern/DesktopTimePicker/DesktopTimePicker.js +5 -1
  72. package/modern/LocalizationProvider/LocalizationProvider.js +1 -0
  73. package/modern/MobileDatePicker/MobileDatePicker.js +3 -2
  74. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
  75. package/modern/MobileTimePicker/MobileTimePicker.js +5 -1
  76. package/modern/index.js +1 -1
  77. package/modern/internals/utils/date-time-utils.js +41 -0
  78. package/modern/internals/utils/date-utils.js +33 -1
  79. package/modern/internals/utils/time-utils.js +27 -0
  80. package/modern/internals/utils/views.js +6 -2
  81. package/modern/locales/deDE.js +2 -2
  82. package/modern/locales/index.js +16 -15
  83. package/modern/locales/roRO.js +60 -0
  84. package/node/AdapterDateFns/AdapterDateFns.js +20 -19
  85. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +17 -16
  86. package/node/AdapterDayjs/AdapterDayjs.js +12 -11
  87. package/node/AdapterLuxon/AdapterLuxon.js +20 -19
  88. package/node/AdapterMoment/AdapterMoment.js +12 -11
  89. package/node/AdapterMomentHijri/AdapterMomentHijri.js +20 -19
  90. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +20 -19
  91. package/node/DatePicker/DatePickerToolbar.js +6 -15
  92. package/node/DatePicker/shared.js +0 -17
  93. package/node/DesktopDatePicker/DesktopDatePicker.js +2 -1
  94. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -3
  95. package/node/DesktopTimePicker/DesktopTimePicker.js +7 -3
  96. package/node/LocalizationProvider/LocalizationProvider.js +1 -0
  97. package/node/MobileDatePicker/MobileDatePicker.js +2 -1
  98. package/node/MobileDateTimePicker/MobileDateTimePicker.js +7 -3
  99. package/node/MobileTimePicker/MobileTimePicker.js +7 -3
  100. package/node/index.js +1 -1
  101. package/node/internals/utils/date-time-utils.js +49 -0
  102. package/node/internals/utils/date-utils.js +35 -2
  103. package/node/internals/utils/time-utils.js +30 -2
  104. package/node/internals/utils/views.js +8 -5
  105. package/node/locales/deDE.js +2 -2
  106. package/node/locales/index.js +108 -97
  107. package/node/locales/roRO.js +67 -0
  108. package/package.json +1 -1
@@ -5,13 +5,16 @@ import { resolveComponentProps } from '@mui/base/utils';
5
5
  import { singleItemValueManager } from '../internals/utils/valueManagers';
6
6
  import { TimeField } from '../TimeField';
7
7
  import { useTimePickerDefaultizedProps } from '../TimePicker/shared';
8
- import { useLocaleText, validateTime } from '../internals';
8
+ import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
9
+ import { validateTime } from '../internals/utils/validation/validateTime';
9
10
  import { useMobilePicker } from '../internals/hooks/useMobilePicker';
10
11
  import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
11
12
  import { renderTimeViewClock } from '../timeViewRenderers';
13
+ import { resolveTimeFormat } from '../internals/utils/time-utils';
12
14
  const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker(inProps, ref) {
13
15
  var _defaultizedProps$amp, _defaultizedProps$slo2;
14
16
  const localeText = useLocaleText();
17
+ const utils = useUtils();
15
18
 
16
19
  // Props with the default values common to all time pickers
17
20
  const defaultizedProps = useTimePickerDefaultizedProps(inProps, 'MuiMobileTimePicker');
@@ -26,6 +29,7 @@ const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker
26
29
  const props = _extends({}, defaultizedProps, {
27
30
  ampmInClock,
28
31
  viewRenderers,
32
+ format: resolveTimeFormat(utils, defaultizedProps),
29
33
  slots: _extends({
30
34
  field: TimeField
31
35
  }, defaultizedProps.slots),
@@ -56,6 +56,6 @@ export interface BaseTimePickerProps<TDate, TView extends TimeViewWithMeridiem>
56
56
  */
57
57
  viewRenderers?: Partial<PickerViewRendererLookup<TDate | null, TView, TimeViewRendererProps<TView, BaseClockProps<TDate, TView>>, {}>>;
58
58
  }
59
- type UseTimePickerDefaultizedProps<TDate, TView extends TimeViewWithMeridiem, Props extends BaseTimePickerProps<TDate, TView>> = LocalizedComponent<TDate, Omit<DefaultizedProps<Props, 'views' | 'openTo' | keyof BaseTimeValidationProps>, 'components' | 'componentsProps'>>;
59
+ type UseTimePickerDefaultizedProps<TDate, TView extends TimeViewWithMeridiem, Props extends BaseTimePickerProps<TDate, TView>> = LocalizedComponent<TDate, Omit<DefaultizedProps<Props, 'views' | 'openTo' | 'ampm' | keyof BaseTimeValidationProps>, 'components' | 'componentsProps'>>;
60
60
  export declare function useTimePickerDefaultizedProps<TDate, TView extends TimeViewWithMeridiem, Props extends BaseTimePickerProps<TDate, TView>>(props: Props, name: string): UseTimePickerDefaultizedProps<TDate, TView, Props>;
61
61
  export {};
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.6.0
2
+ * @mui/x-date-pickers v6.7.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,6 @@
1
+ import { DateOrTimeView, MuiPickersAdapter } from '../../models';
2
+ export declare const resolveDateTimeFormat: (utils: MuiPickersAdapter<any>, { views, format, ...other }: {
3
+ format?: string | undefined;
4
+ views: readonly DateOrTimeView[];
5
+ ampm: boolean;
6
+ }) => string;
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["views", "format"];
4
+ import { resolveTimeFormat, isTimeView } from './time-utils';
5
+ import { resolveDateFormat } from './date-utils';
6
+ export const resolveDateTimeFormat = (utils, _ref) => {
7
+ let {
8
+ views,
9
+ format
10
+ } = _ref,
11
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
12
+ if (format) {
13
+ return format;
14
+ }
15
+ const dateViews = [];
16
+ const timeViews = [];
17
+ views.forEach(view => {
18
+ if (isTimeView(view)) {
19
+ timeViews.push(view);
20
+ } else {
21
+ dateViews.push(view);
22
+ }
23
+ });
24
+ if (timeViews.length === 0) {
25
+ return resolveDateFormat(utils, _extends({
26
+ views: dateViews
27
+ }, other), false);
28
+ }
29
+ if (dateViews.length === 0) {
30
+ return resolveTimeFormat(utils, _extends({
31
+ views: timeViews
32
+ }, other));
33
+ }
34
+ const timeFormat = resolveTimeFormat(utils, _extends({
35
+ views: timeViews
36
+ }, other));
37
+ const dateFormat = resolveDateFormat(utils, _extends({
38
+ views: dateViews
39
+ }, other), false);
40
+ return `${dateFormat} ${timeFormat}`;
41
+ };
@@ -18,4 +18,8 @@ export declare const getMonthsInYear: <TDate>(utils: MuiPickersAdapter<TDate, an
18
18
  export declare const mergeDateAndTime: <TDate>(utils: MuiPickersAdapter<TDate, any>, dateParam: TDate, timeParam: TDate) => TDate;
19
19
  export declare const getTodayDate: <TDate>(utils: MuiPickersAdapter<TDate, any>, valueType: FieldValueType) => TDate;
20
20
  export declare const isDatePickerView: (view: DateOrTimeViewWithMeridiem) => view is DateView;
21
+ export declare const resolveDateFormat: (utils: MuiPickersAdapter<any>, { format, views }: {
22
+ format?: string | undefined;
23
+ views: readonly DateView[];
24
+ }, isInToolbar: boolean) => string;
21
25
  export {};
@@ -1,3 +1,4 @@
1
+ import { areViewsEqual } from './views';
1
2
  export const findClosestEnabledDate = ({
2
3
  date,
3
4
  disableFuture,
@@ -88,4 +89,35 @@ export const mergeDateAndTime = (utils, dateParam, timeParam) => {
88
89
  };
89
90
  export const getTodayDate = (utils, valueType) => valueType === 'date' ? utils.startOfDay(utils.date()) : utils.date();
90
91
  const dateViews = ['year', 'month', 'day'];
91
- export const isDatePickerView = view => dateViews.includes(view);
92
+ export const isDatePickerView = view => dateViews.includes(view);
93
+ export const resolveDateFormat = (utils, {
94
+ format,
95
+ views
96
+ }, isInToolbar) => {
97
+ if (format != null) {
98
+ return format;
99
+ }
100
+ const formats = utils.formats;
101
+ if (areViewsEqual(views, ['year'])) {
102
+ return formats.year;
103
+ }
104
+ if (areViewsEqual(views, ['month'])) {
105
+ return formats.month;
106
+ }
107
+ if (areViewsEqual(views, ['day'])) {
108
+ return formats.dayOfMonth;
109
+ }
110
+ if (areViewsEqual(views, ['month', 'year'])) {
111
+ return `${formats.month} ${formats.year}`;
112
+ }
113
+ if (areViewsEqual(views, ['day', 'month'])) {
114
+ return `${formats.month} ${formats.dayOfMonth}`;
115
+ }
116
+ if (isInToolbar) {
117
+ // Little localization hack (Google is doing the same for android native pickers):
118
+ // For english localization it is convenient to include weekday into the date "Mon, Jun 1".
119
+ // For other locales using strings like "June 1", without weekday.
120
+ return /en/.test(utils.getCurrentLocaleCode()) ? formats.normalDateWithWeekday : formats.normalDate;
121
+ }
122
+ return formats.keyboardDate;
123
+ };
@@ -1,4 +1,4 @@
1
- import { MuiPickersAdapter } from '../../models';
1
+ import { MuiPickersAdapter, TimeView } from '../../models';
2
2
  import { DateOrTimeViewWithMeridiem, TimeViewWithMeridiem } from '../models';
3
3
  export declare const isTimeView: (view: DateOrTimeViewWithMeridiem) => boolean;
4
4
  export declare const isInternalTimeView: (view: DateOrTimeViewWithMeridiem) => view is TimeViewWithMeridiem;
@@ -8,3 +8,8 @@ export declare const convertValueToMeridiem: (value: number, meridiem: Meridiem
8
8
  export declare const convertToMeridiem: <TDate>(time: TDate, meridiem: Meridiem, ampm: boolean, utils: MuiPickersAdapter<TDate, any>) => TDate;
9
9
  export declare const getSecondsInDay: <TDate>(date: TDate, utils: MuiPickersAdapter<TDate, any>) => number;
10
10
  export declare const createIsAfterIgnoreDatePart: <TDate>(disableIgnoringDatePartForTimeValidation: boolean, utils: MuiPickersAdapter<TDate, any>) => (dateLeft: TDate, dateRight: TDate) => boolean;
11
+ export declare const resolveTimeFormat: (utils: MuiPickersAdapter<any>, { format, views, ampm }: {
12
+ format?: string | undefined;
13
+ views: readonly TimeView[];
14
+ ampm: boolean;
15
+ }) => string;
@@ -1,3 +1,4 @@
1
+ import { areViewsEqual } from './views';
1
2
  const timeViews = ['hours', 'minutes', 'seconds'];
2
3
  export const isTimeView = view => timeViews.includes(view);
3
4
  export const isInternalTimeView = view => timeViews.includes(view) || view === 'meridiem';
@@ -28,4 +29,30 @@ export const createIsAfterIgnoreDatePart = (disableIgnoringDatePartForTimeValida
28
29
  return utils.isAfter(dateLeft, dateRight);
29
30
  }
30
31
  return getSecondsInDay(dateLeft, utils) > getSecondsInDay(dateRight, utils);
32
+ };
33
+ export const resolveTimeFormat = (utils, {
34
+ format,
35
+ views,
36
+ ampm
37
+ }) => {
38
+ if (format != null) {
39
+ return format;
40
+ }
41
+ const formats = utils.formats;
42
+ if (areViewsEqual(views, ['hours'])) {
43
+ return ampm ? `${formats.hours12h} ${formats.meridiem}` : formats.hours24h;
44
+ }
45
+ if (areViewsEqual(views, ['minutes'])) {
46
+ return formats.minutes;
47
+ }
48
+ if (areViewsEqual(views, ['seconds'])) {
49
+ return formats.seconds;
50
+ }
51
+ if (areViewsEqual(views, ['minutes', 'seconds'])) {
52
+ return `${formats.minutes}:${formats.seconds}`;
53
+ }
54
+ if (areViewsEqual(views, ['hours', 'minutes', 'seconds'])) {
55
+ return ampm ? `${formats.hours12h}:${formats.minutes}:${formats.seconds} ${formats.meridiem}` : `${formats.hours24h}:${formats.minutes}:${formats.seconds}`;
56
+ }
57
+ return ampm ? `${formats.hours12h}:${formats.minutes} ${formats.meridiem}` : `${formats.hours24h}:${formats.minutes}`;
31
58
  };
@@ -8,4 +8,4 @@ export declare const DATE_TIME_VALIDATION_PROP_NAMES: (keyof DateTimeValidationP
8
8
  */
9
9
  export declare const extractValidationProps: <Props extends {
10
10
  [key: string]: any;
11
- }>(props: Props) => Pick<Props, "disableFuture" | "disablePast" | "maxDate" | "minDate" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minutesStep" | "minTime" | "maxTime" | "ampm" | "shouldDisableTime" | "shouldDisableClock" | "disableIgnoringDatePartForTimeValidation" | "minDateTime" | "maxDateTime">;
11
+ }>(props: Props) => Pick<Props, "ampm" | "disableFuture" | "disablePast" | "maxDate" | "minDate" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minutesStep" | "minTime" | "maxTime" | "shouldDisableTime" | "shouldDisableClock" | "disableIgnoringDatePartForTimeValidation" | "minDateTime" | "maxDateTime">;
@@ -1,7 +1,6 @@
1
- import { DateView } from '../../models';
1
+ import { DateOrTimeView } from '../../models';
2
2
  import { DateOrTimeViewWithMeridiem } from '../models';
3
- export declare const isYearOnlyView: (views: readonly DateView[]) => views is readonly "year"[];
4
- export declare const isYearAndMonthViews: (views: readonly DateView[]) => views is readonly ("month" | "year")[];
3
+ export declare const areViewsEqual: <TView extends DateOrTimeView>(views: ReadonlyArray<DateOrTimeView>, expectedViews: TView[]) => views is readonly TView[];
5
4
  export declare const applyDefaultViewProps: <TView extends DateOrTimeViewWithMeridiem>({ openTo, defaultOpenTo, views, defaultViews, }: {
6
5
  openTo: TView | undefined;
7
6
  defaultOpenTo: TView;
@@ -1,5 +1,9 @@
1
- export const isYearOnlyView = views => views.length === 1 && views[0] === 'year';
2
- export const isYearAndMonthViews = views => views.length === 2 && views.indexOf('month') !== -1 && views.indexOf('year') !== -1;
1
+ export const areViewsEqual = (views, expectedViews) => {
2
+ if (views.length !== expectedViews.length) {
3
+ return false;
4
+ }
5
+ return expectedViews.every(expectedView => views.includes(expectedView));
6
+ };
3
7
  export const applyDefaultViewProps = ({
4
8
  openTo,
5
9
  defaultOpenTo,
@@ -226,33 +226,34 @@ var formatTokenMap = {
226
226
  ss: 'seconds'
227
227
  };
228
228
  var defaultFormats = {
229
+ year: 'yyyy',
230
+ month: 'LLLL',
231
+ monthShort: 'MMM',
229
232
  dayOfMonth: 'd',
233
+ weekday: 'EEEE',
234
+ weekdayShort: 'EEE',
235
+ hours24h: 'HH',
236
+ hours12h: 'hh',
237
+ meridiem: 'aa',
238
+ minutes: 'mm',
239
+ seconds: 'ss',
230
240
  fullDate: 'PP',
231
241
  fullDateWithWeekday: 'PPPP',
232
- fullDateTime: 'PP p',
233
- fullDateTime12h: 'PP hh:mm aa',
234
- fullDateTime24h: 'PP HH:mm',
242
+ keyboardDate: 'P',
243
+ shortDate: 'MMM d',
244
+ normalDate: 'd MMMM',
245
+ normalDateWithWeekday: 'EEE, MMM d',
246
+ monthAndYear: 'LLLL yyyy',
247
+ monthAndDate: 'MMMM d',
235
248
  fullTime: 'p',
236
249
  fullTime12h: 'hh:mm aa',
237
250
  fullTime24h: 'HH:mm',
238
- hours12h: 'hh',
239
- hours24h: 'HH',
240
- keyboardDate: 'P',
251
+ fullDateTime: 'PP p',
252
+ fullDateTime12h: 'PP hh:mm aa',
253
+ fullDateTime24h: 'PP HH:mm',
241
254
  keyboardDateTime: 'P p',
242
255
  keyboardDateTime12h: 'P hh:mm aa',
243
- keyboardDateTime24h: 'P HH:mm',
244
- minutes: 'mm',
245
- month: 'LLLL',
246
- monthAndDate: 'MMMM d',
247
- monthAndYear: 'LLLL yyyy',
248
- monthShort: 'MMM',
249
- weekday: 'EEEE',
250
- weekdayShort: 'EEE',
251
- normalDate: 'd MMMM',
252
- normalDateWithWeekday: 'EEE, MMM d',
253
- seconds: 'ss',
254
- shortDate: 'MMM d',
255
- year: 'yyyy'
256
+ keyboardDateTime24h: 'P HH:mm'
256
257
  };
257
258
 
258
259
  /**
@@ -226,33 +226,34 @@ var formatTokenMap = {
226
226
  ss: 'seconds'
227
227
  };
228
228
  var defaultFormats = {
229
+ year: 'yyyy',
230
+ month: 'LLLL',
231
+ monthShort: 'MMM',
229
232
  dayOfMonth: 'd',
233
+ weekday: 'EEEE',
234
+ weekdayShort: 'EEE',
235
+ hours24h: 'HH',
236
+ hours12h: 'hh',
237
+ meridiem: 'aa',
238
+ minutes: 'mm',
239
+ seconds: 'ss',
230
240
  fullDate: 'PPP',
231
241
  fullDateWithWeekday: 'PPPP',
242
+ keyboardDate: 'P',
243
+ shortDate: 'd MMM',
244
+ normalDate: 'd MMMM',
245
+ normalDateWithWeekday: 'EEE, d MMMM',
246
+ monthAndYear: 'LLLL yyyy',
247
+ monthAndDate: 'd MMMM',
232
248
  fullDateTime: 'PPP p',
233
249
  fullDateTime12h: 'PPP hh:mm aa',
234
250
  fullDateTime24h: 'PPP HH:mm',
235
251
  fullTime: 'p',
236
252
  fullTime12h: 'hh:mm aaa',
237
253
  fullTime24h: 'HH:mm',
238
- hours12h: 'hh',
239
- hours24h: 'HH',
240
- keyboardDate: 'P',
241
254
  keyboardDateTime: 'P p',
242
255
  keyboardDateTime12h: 'P hh:mm aa',
243
- keyboardDateTime24h: 'P HH:mm',
244
- minutes: 'mm',
245
- month: 'LLLL',
246
- monthAndDate: 'd MMMM',
247
- monthAndYear: 'LLLL yyyy',
248
- monthShort: 'MMM',
249
- weekday: 'EEEE',
250
- weekdayShort: 'EEE',
251
- normalDate: 'd MMMM',
252
- normalDateWithWeekday: 'EEE, d MMMM',
253
- seconds: 'ss',
254
- shortDate: 'd MMM',
255
- year: 'yyyy'
256
+ keyboardDateTime24h: 'P HH:mm'
256
257
  };
257
258
  var NUMBER_SYMBOL_MAP = {
258
259
  '1': '۱',
@@ -97,30 +97,31 @@ var formatTokenMap = {
97
97
  ss: 'seconds'
98
98
  };
99
99
  var defaultFormats = {
100
- normalDateWithWeekday: 'ddd, MMM D',
101
- normalDate: 'D MMMM',
102
- shortDate: 'MMM D',
103
- monthAndDate: 'MMMM D',
104
- dayOfMonth: 'D',
105
100
  year: 'YYYY',
106
101
  month: 'MMMM',
107
102
  monthShort: 'MMM',
108
- monthAndYear: 'MMMM YYYY',
103
+ dayOfMonth: 'D',
109
104
  weekday: 'dddd',
110
105
  weekdayShort: 'ddd',
111
- minutes: 'mm',
112
- hours12h: 'hh',
113
106
  hours24h: 'HH',
107
+ hours12h: 'hh',
108
+ meridiem: 'A',
109
+ minutes: 'mm',
114
110
  seconds: 'ss',
111
+ fullDate: 'll',
112
+ fullDateWithWeekday: 'dddd, LL',
113
+ keyboardDate: 'L',
114
+ shortDate: 'MMM D',
115
+ normalDate: 'D MMMM',
116
+ normalDateWithWeekday: 'ddd, MMM D',
117
+ monthAndYear: 'MMMM YYYY',
118
+ monthAndDate: 'MMMM D',
115
119
  fullTime: 'LT',
116
120
  fullTime12h: 'hh:mm A',
117
121
  fullTime24h: 'HH:mm',
118
- fullDate: 'll',
119
- fullDateWithWeekday: 'dddd, LL',
120
122
  fullDateTime: 'lll',
121
123
  fullDateTime12h: 'll hh:mm A',
122
124
  fullDateTime24h: 'll HH:mm',
123
- keyboardDate: 'L',
124
125
  keyboardDateTime: 'L LT',
125
126
  keyboardDateTime12h: 'L hh:mm A',
126
127
  keyboardDateTime24h: 'L HH:mm'
@@ -111,33 +111,34 @@ var formatTokenMap = {
111
111
  ss: 'seconds'
112
112
  };
113
113
  var defaultFormats = {
114
+ year: 'yyyy',
115
+ month: 'LLLL',
116
+ monthShort: 'MMM',
114
117
  dayOfMonth: 'd',
118
+ weekday: 'cccc',
119
+ weekdayShort: 'ccc',
120
+ hours24h: 'HH',
121
+ hours12h: 'hh',
122
+ meridiem: 'a',
123
+ minutes: 'mm',
124
+ seconds: 'ss',
115
125
  fullDate: 'DD',
116
126
  fullDateWithWeekday: 'DDDD',
117
- fullDateTime: 'ff',
118
- fullDateTime12h: 'DD, hh:mm a',
119
- fullDateTime24h: 'DD, T',
127
+ keyboardDate: 'D',
128
+ shortDate: 'MMM d',
129
+ normalDate: 'd MMMM',
130
+ normalDateWithWeekday: 'EEE, MMM d',
131
+ monthAndYear: 'LLLL yyyy',
132
+ monthAndDate: 'MMMM d',
120
133
  fullTime: 't',
121
134
  fullTime12h: 'hh:mm a',
122
135
  fullTime24h: 'HH:mm',
123
- hours12h: 'hh',
124
- hours24h: 'HH',
125
- keyboardDate: 'D',
136
+ fullDateTime: 'ff',
137
+ fullDateTime12h: 'DD, hh:mm a',
138
+ fullDateTime24h: 'DD, T',
126
139
  keyboardDateTime: 'D t',
127
140
  keyboardDateTime12h: 'D hh:mm a',
128
- keyboardDateTime24h: 'D T',
129
- minutes: 'mm',
130
- seconds: 'ss',
131
- month: 'LLLL',
132
- monthAndDate: 'MMMM d',
133
- monthAndYear: 'LLLL yyyy',
134
- monthShort: 'MMM',
135
- weekday: 'cccc',
136
- weekdayShort: 'ccc',
137
- normalDate: 'd MMMM',
138
- normalDateWithWeekday: 'EEE, MMM d',
139
- shortDate: 'MMM d',
140
- year: 'yyyy'
141
+ keyboardDateTime24h: 'D T'
141
142
  };
142
143
 
143
144
  /**
@@ -96,30 +96,31 @@ var formatTokenMap = {
96
96
  ss: 'seconds'
97
97
  };
98
98
  var defaultFormats = {
99
- normalDateWithWeekday: 'ddd, MMM D',
100
- normalDate: 'D MMMM',
101
- shortDate: 'MMM D',
102
- monthAndDate: 'MMMM D',
103
- dayOfMonth: 'D',
104
99
  year: 'YYYY',
105
100
  month: 'MMMM',
106
101
  monthShort: 'MMM',
107
- monthAndYear: 'MMMM YYYY',
102
+ dayOfMonth: 'D',
108
103
  weekday: 'dddd',
109
104
  weekdayShort: 'ddd',
110
- minutes: 'mm',
111
- hours12h: 'hh',
112
105
  hours24h: 'HH',
106
+ hours12h: 'hh',
107
+ meridiem: 'A',
108
+ minutes: 'mm',
113
109
  seconds: 'ss',
110
+ fullDate: 'll',
111
+ fullDateWithWeekday: 'dddd, LL',
112
+ keyboardDate: 'L',
113
+ shortDate: 'MMM D',
114
+ normalDate: 'D MMMM',
115
+ normalDateWithWeekday: 'ddd, MMM D',
116
+ monthAndYear: 'MMMM YYYY',
117
+ monthAndDate: 'MMMM D',
114
118
  fullTime: 'LT',
115
119
  fullTime12h: 'hh:mm A',
116
120
  fullTime24h: 'HH:mm',
117
- fullDate: 'll',
118
- fullDateWithWeekday: 'dddd, LL',
119
121
  fullDateTime: 'lll',
120
122
  fullDateTime12h: 'll hh:mm A',
121
123
  fullDateTime24h: 'll HH:mm',
122
- keyboardDate: 'L',
123
124
  keyboardDateTime: 'L LT',
124
125
  keyboardDateTime12h: 'L hh:mm A',
125
126
  keyboardDateTime24h: 'L HH:mm'
@@ -74,33 +74,34 @@ var formatTokenMap = {
74
74
  ss: 'seconds'
75
75
  };
76
76
  var defaultFormats = {
77
+ year: 'iYYYY',
78
+ month: 'iMMMM',
79
+ monthShort: 'iMMM',
77
80
  dayOfMonth: 'iD',
81
+ weekday: 'dddd',
82
+ weekdayShort: 'ddd',
83
+ hours24h: 'HH',
84
+ hours12h: 'hh',
85
+ meridiem: 'A',
86
+ minutes: 'mm',
87
+ seconds: 'ss',
78
88
  fullDate: 'iYYYY, iMMMM Do',
79
89
  fullDateWithWeekday: 'iYYYY, iMMMM Do, dddd',
80
- fullDateTime: 'iYYYY, iMMMM Do, hh:mm A',
81
- fullDateTime12h: 'iD iMMMM hh:mm A',
82
- fullDateTime24h: 'iD iMMMM HH:mm',
90
+ keyboardDateTime: 'iYYYY/iMM/iDD LT',
91
+ shortDate: 'iD iMMM',
92
+ normalDate: 'dddd, iD iMMM',
93
+ normalDateWithWeekday: 'DD iMMMM',
94
+ monthAndYear: 'iMMMM iYYYY',
95
+ monthAndDate: 'iD iMMMM',
83
96
  fullTime: 'LT',
84
97
  fullTime12h: 'hh:mm A',
85
98
  fullTime24h: 'HH:mm',
86
- hours12h: 'hh',
87
- hours24h: 'HH',
99
+ fullDateTime: 'iYYYY, iMMMM Do, hh:mm A',
100
+ fullDateTime12h: 'iD iMMMM hh:mm A',
101
+ fullDateTime24h: 'iD iMMMM HH:mm',
88
102
  keyboardDate: 'iYYYY/iMM/iDD',
89
- keyboardDateTime: 'iYYYY/iMM/iDD LT',
90
103
  keyboardDateTime12h: 'iYYYY/iMM/iDD hh:mm A',
91
- keyboardDateTime24h: 'iYYYY/iMM/iDD HH:mm',
92
- minutes: 'mm',
93
- month: 'iMMMM',
94
- monthAndDate: 'iD iMMMM',
95
- monthAndYear: 'iMMMM iYYYY',
96
- monthShort: 'iMMM',
97
- weekday: 'dddd',
98
- weekdayShort: 'ddd',
99
- normalDate: 'dddd, iD iMMM',
100
- normalDateWithWeekday: 'DD iMMMM',
101
- seconds: 'ss',
102
- shortDate: 'iD iMMM',
103
- year: 'iYYYY'
104
+ keyboardDateTime24h: 'iYYYY/iMM/iDD HH:mm'
104
105
  };
105
106
  var NUMBER_SYMBOL_MAP = {
106
107
  '1': '١',
@@ -72,33 +72,34 @@ var formatTokenMap = {
72
72
  ss: 'seconds'
73
73
  };
74
74
  var defaultFormats = {
75
+ year: 'jYYYY',
76
+ month: 'jMMMM',
77
+ monthShort: 'jMMM',
75
78
  dayOfMonth: 'jD',
79
+ weekday: 'dddd',
80
+ weekdayShort: 'ddd',
81
+ hours24h: 'HH',
82
+ hours12h: 'hh',
83
+ meridiem: 'A',
84
+ minutes: 'mm',
85
+ seconds: 'ss',
76
86
  fullDate: 'jYYYY, jMMMM Do',
77
87
  fullDateWithWeekday: 'dddd Do jMMMM jYYYY',
78
- fullDateTime: 'jYYYY, jMMMM Do, hh:mm A',
79
- fullDateTime12h: 'jD jMMMM hh:mm A',
80
- fullDateTime24h: 'jD jMMMM HH:mm',
88
+ keyboardDate: 'jYYYY/jMM/jDD',
89
+ shortDate: 'jD jMMM',
90
+ normalDate: 'dddd, jD jMMM',
91
+ normalDateWithWeekday: 'DD MMMM',
92
+ monthAndYear: 'jMMMM jYYYY',
93
+ monthAndDate: 'jD jMMMM',
81
94
  fullTime: 'LT',
82
95
  fullTime12h: 'hh:mm A',
83
96
  fullTime24h: 'HH:mm',
84
- hours12h: 'hh',
85
- hours24h: 'HH',
86
- keyboardDate: 'jYYYY/jMM/jDD',
97
+ fullDateTime: 'jYYYY, jMMMM Do, hh:mm A',
98
+ fullDateTime12h: 'jD jMMMM hh:mm A',
99
+ fullDateTime24h: 'jD jMMMM HH:mm',
87
100
  keyboardDateTime: 'jYYYY/jMM/jDD LT',
88
101
  keyboardDateTime12h: 'jYYYY/jMM/jDD hh:mm A',
89
- keyboardDateTime24h: 'jYYYY/jMM/jDD HH:mm',
90
- minutes: 'mm',
91
- month: 'jMMMM',
92
- monthAndDate: 'jD jMMMM',
93
- monthAndYear: 'jMMMM jYYYY',
94
- monthShort: 'jMMM',
95
- weekday: 'dddd',
96
- weekdayShort: 'ddd',
97
- normalDate: 'dddd, jD jMMM',
98
- normalDateWithWeekday: 'DD MMMM',
99
- seconds: 'ss',
100
- shortDate: 'jD jMMM',
101
- year: 'jYYYY'
102
+ keyboardDateTime24h: 'jYYYY/jMM/jDD HH:mm'
102
103
  };
103
104
  var NUMBER_SYMBOL_MAP = {
104
105
  '1': '۱',
@@ -8,8 +8,8 @@ import { styled, useThemeProps } from '@mui/material/styles';
8
8
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
9
9
  import { PickersToolbar } from '../internals/components/PickersToolbar';
10
10
  import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
11
- import { isYearOnlyView, isYearAndMonthViews } from '../internals/utils/views';
12
11
  import { getDatePickerToolbarUtilityClass } from './datePickerToolbarClasses';
12
+ import { resolveDateFormat } from '../internals/utils/date-utils';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  var useUtilityClasses = function useUtilityClasses(ownerState) {
15
15
  var classes = ownerState.classes;
@@ -62,20 +62,11 @@ var DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePickerToolbar
62
62
  if (!value) {
63
63
  return toolbarPlaceholder;
64
64
  }
65
- if (toolbarFormat) {
66
- return utils.formatByString(value, toolbarFormat);
67
- }
68
- if (isYearOnlyView(views)) {
69
- return utils.format(value, 'year');
70
- }
71
- if (isYearAndMonthViews(views)) {
72
- return utils.format(value, 'month');
73
- }
74
-
75
- // Little localization hack (Google is doing the same for android native pickers):
76
- // For english localization it is convenient to include weekday into the date "Mon, Jun 1".
77
- // For other locales using strings like "June 1", without weekday.
78
- return /en/.test(utils.getCurrentLocaleCode()) ? utils.format(value, 'normalDateWithWeekday') : utils.format(value, 'normalDate');
65
+ var formatFromViews = resolveDateFormat(utils, {
66
+ format: toolbarFormat,
67
+ views: views
68
+ }, true);
69
+ return utils.formatByString(value, formatFromViews);
79
70
  }, [value, toolbarFormat, toolbarPlaceholder, utils, views]);
80
71
  var ownerState = props;
81
72
  return /*#__PURE__*/_jsx(DatePickerToolbarRoot, _extends({
@@ -2,24 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useThemeProps } from '@mui/material/styles';
4
4
  import { useDefaultDates, useUtils } from '../internals/hooks/useUtils';
5
- import { applyDefaultViewProps, isYearAndMonthViews, isYearOnlyView } from '../internals/utils/views';
5
+ import { applyDefaultViewProps } from '../internals/utils/views';
6
6
  import { applyDefaultDate } from '../internals/utils/date-utils';
7
7
  import { DatePickerToolbar } from './DatePickerToolbar';
8
8
  import { uncapitalizeObjectKeys } from '../internals/utils/slots-migration';
9
- export var getDatePickerFieldFormat = function getDatePickerFieldFormat(utils, _ref) {
10
- var format = _ref.format,
11
- views = _ref.views;
12
- if (format != null) {
13
- return format;
14
- }
15
- if (isYearOnlyView(views)) {
16
- return utils.formats.year;
17
- }
18
- if (isYearAndMonthViews(views)) {
19
- return utils.formats.monthAndYear;
20
- }
21
- return undefined;
22
- };
23
9
  export function useDatePickerDefaultizedProps(props, name) {
24
10
  var _themeProps$slots, _themeProps$disableFu, _themeProps$disablePa, _themeProps$slotProps;
25
11
  var utils = useUtils();