@mui/x-date-pickers-pro 7.0.0-beta.7 → 7.0.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 (91) hide show
  1. package/CHANGELOG.md +195 -12
  2. package/DateRangeCalendar/DateRangeCalendar.js +17 -22
  3. package/DateRangeCalendar/useDragRange.js +1 -2
  4. package/DateRangePicker/DateRangePicker.js +1 -1
  5. package/DateRangePicker/shared.js +3 -5
  6. package/DateTimeRangePicker/DateTimeRangePicker.d.ts +10 -0
  7. package/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
  8. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +4 -5
  9. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -3
  10. package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +2 -2
  11. package/DateTimeRangePicker/shared.d.ts +5 -4
  12. package/DateTimeRangePicker/shared.js +9 -10
  13. package/DesktopDateRangePicker/DesktopDateRangePicker.js +6 -10
  14. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +10 -0
  15. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +31 -28
  16. package/MobileDateRangePicker/MobileDateRangePicker.js +5 -9
  17. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +10 -0
  18. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +20 -14
  19. package/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -15
  20. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -15
  21. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +16 -14
  22. package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +1 -1
  23. package/README.md +1 -1
  24. package/SingleInputDateRangeField/SingleInputDateRangeField.js +8 -4
  25. package/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
  26. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +8 -4
  27. package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
  28. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +7 -3
  29. package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
  30. package/StaticDateRangePicker/StaticDateRangePicker.js +4 -5
  31. package/index.js +1 -1
  32. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -11
  33. package/internals/hooks/useEnrichedRangePickerFieldProps.js +25 -31
  34. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -10
  35. package/internals/hooks/useMultiInputFieldSelectedSections.js +3 -6
  36. package/internals/hooks/useRangePosition.js +3 -5
  37. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -18
  38. package/internals/models/dateRange.d.ts +3 -3
  39. package/internals/models/dateTimeRange.d.ts +2 -2
  40. package/internals/models/timeRange.d.ts +2 -2
  41. package/internals/utils/releaseInfo.js +1 -1
  42. package/internals/utils/validation/validateDateRange.js +2 -2
  43. package/internals/utils/validation/validateDateTimeRange.js +2 -2
  44. package/internals/utils/valueManagers.d.ts +3 -1
  45. package/internals/utils/valueManagers.js +9 -7
  46. package/models/fields.d.ts +8 -1
  47. package/modern/DateRangeCalendar/DateRangeCalendar.js +1 -1
  48. package/modern/DateRangePicker/DateRangePicker.js +1 -1
  49. package/modern/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
  50. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
  51. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
  52. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
  53. package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
  54. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
  55. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
  56. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
  57. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
  58. package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
  59. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
  60. package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
  61. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  62. package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
  63. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
  64. package/modern/index.js +1 -1
  65. package/modern/internals/utils/releaseInfo.js +1 -1
  66. package/modern/internals/utils/valueManagers.js +7 -5
  67. package/node/DateRangeCalendar/DateRangeCalendar.js +1 -1
  68. package/node/DateRangePicker/DateRangePicker.js +1 -1
  69. package/node/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
  70. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
  71. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
  72. package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
  73. package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
  74. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
  75. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
  76. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
  77. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
  78. package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +7 -1
  79. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
  80. package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +7 -1
  81. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
  82. package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +7 -1
  83. package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
  84. package/node/index.js +1 -1
  85. package/node/internals/utils/releaseInfo.js +1 -1
  86. package/node/internals/utils/valueManagers.js +9 -6
  87. package/package.json +7 -7
  88. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +0 -9
  89. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -52
  90. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -51
  91. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -59
@@ -22,7 +22,6 @@ const PickerStaticLayout = styled(PickersLayout)(({
22
22
  * - StaticDateRangePicker
23
23
  */
24
24
  export const useStaticRangePicker = _ref => {
25
- var _slots$layout;
26
25
  let {
27
26
  props,
28
27
  ref
@@ -46,7 +45,7 @@ export const useStaticRangePicker = _ref => {
46
45
  renderCurrentView
47
46
  } = usePicker(_extends({}, pickerParams, {
48
47
  props,
49
- autoFocusView: autoFocus != null ? autoFocus : false,
48
+ autoFocusView: autoFocus ?? false,
50
49
  fieldRef: undefined,
51
50
  additionalViewProps: {
52
51
  rangePosition,
@@ -54,27 +53,24 @@ export const useStaticRangePicker = _ref => {
54
53
  },
55
54
  wrapperVariant: displayStaticWrapperAs
56
55
  }));
57
- const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickerStaticLayout;
56
+ const Layout = slots?.layout ?? PickerStaticLayout;
58
57
  const slotPropsForLayout = _extends({}, slotProps, {
59
- toolbar: _extends({}, slotProps == null ? void 0 : slotProps.toolbar, {
58
+ toolbar: _extends({}, slotProps?.toolbar, {
60
59
  rangePosition,
61
60
  onRangePositionChange
62
61
  })
63
62
  });
64
- const renderPicker = () => {
65
- var _slotProps$layout, _slotProps$layout2, _slotProps$layout3;
66
- return /*#__PURE__*/_jsx(LocalizationProvider, {
67
- localeText: localeText,
68
- children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps == null ? void 0 : slotProps.layout, {
69
- slots: slots,
70
- slotProps: slotPropsForLayout,
71
- sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps == null || (_slotProps$layout = slotProps.layout) == null ? void 0 : _slotProps$layout.sx) ? slotProps.layout.sx : [slotProps == null || (_slotProps$layout2 = slotProps.layout) == null ? void 0 : _slotProps$layout2.sx])],
72
- className: clsx(className, slotProps == null || (_slotProps$layout3 = slotProps.layout) == null ? void 0 : _slotProps$layout3.className),
73
- ref: ref,
74
- children: renderCurrentView()
75
- }))
76
- });
77
- };
63
+ const renderPicker = () => /*#__PURE__*/_jsx(LocalizationProvider, {
64
+ localeText: localeText,
65
+ children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
66
+ slots: slots,
67
+ slotProps: slotPropsForLayout,
68
+ sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps?.layout?.sx) ? slotProps.layout.sx : [slotProps?.layout?.sx])],
69
+ className: clsx(className, slotProps?.layout?.className),
70
+ ref: ref,
71
+ children: renderCurrentView()
72
+ }))
73
+ });
78
74
  return {
79
75
  renderPicker
80
76
  };
@@ -1,6 +1,6 @@
1
1
  import { BaseDateValidationProps, MakeOptional, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers/models';
3
- import type { DateRangeValidationError, RangeFieldSection, DateRange } from '../../models';
3
+ import { DateRangeValidationError, RangeFieldSection, DateRange, RangeFieldSeparatorProps } from '../../models';
4
4
  /**
5
5
  * Props used to validate a day value in range pickers.
6
6
  */
@@ -8,7 +8,7 @@ export interface DayRangeValidationProps<TDate extends PickerValidDate> {
8
8
  /**
9
9
  * Disable specific date.
10
10
  *
11
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
11
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
12
12
  *
13
13
  * @template TDate
14
14
  * @param {TDate} day The date to test.
@@ -17,5 +17,5 @@ export interface DayRangeValidationProps<TDate extends PickerValidDate> {
17
17
  */
18
18
  shouldDisableDate?: (day: TDate, position: 'start' | 'end') => boolean;
19
19
  }
20
- export interface UseDateRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'>, 'format'>, DayRangeValidationProps<TDate>, BaseDateValidationProps<TDate> {
20
+ export interface UseDateRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, DayRangeValidationProps<TDate>, BaseDateValidationProps<TDate> {
21
21
  }
@@ -1,8 +1,8 @@
1
1
  import { BaseDateValidationProps, TimeValidationProps, MakeOptional, UseFieldInternalProps, DateTimeValidationProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers/models';
3
3
  import { DayRangeValidationProps } from './dateRange';
4
- import { DateTimeRangeValidationError, RangeFieldSection, DateRange } from '../../models';
5
- export interface UseDateTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, DayRangeValidationProps<TDate>, TimeValidationProps<TDate>, BaseDateValidationProps<TDate>, DateTimeValidationProps<TDate> {
4
+ import { DateTimeRangeValidationError, RangeFieldSection, DateRange, RangeFieldSeparatorProps } from '../../models';
5
+ export interface UseDateTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, DayRangeValidationProps<TDate>, TimeValidationProps<TDate>, BaseDateValidationProps<TDate>, DateTimeValidationProps<TDate> {
6
6
  /**
7
7
  * 12h/24h view for hour selection clock.
8
8
  * @default `utils.is12HourCycleInCurrentLocale()`
@@ -1,7 +1,7 @@
1
1
  import { BaseTimeValidationProps, TimeValidationProps, MakeOptional, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers/models';
3
- import { TimeRangeValidationError, RangeFieldSection, DateRange } from '../../models';
4
- export interface UseTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, TimeValidationProps<TDate>, BaseTimeValidationProps {
3
+ import { TimeRangeValidationError, RangeFieldSection, DateRange, RangeFieldSeparatorProps } from '../../models';
4
+ export interface UseTimeRangeFieldProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, TimeValidationProps<TDate>, BaseTimeValidationProps {
5
5
  /**
6
6
  * 12h/24h view for hour selection clock.
7
7
  * @default `utils.is12HourCycleInCurrentLocale()`
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxMDM3MDgwMDAwMA==";
3
+ const releaseInfo = "MTcxMTA1ODQwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
@@ -17,13 +17,13 @@ export const validateDateRange = ({
17
17
  adapter,
18
18
  value: start,
19
19
  props: _extends({}, otherProps, {
20
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'start'))
20
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'start')
21
21
  })
22
22
  }), validateDate({
23
23
  adapter,
24
24
  value: end,
25
25
  props: _extends({}, otherProps, {
26
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'end'))
26
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'end')
27
27
  })
28
28
  })];
29
29
  if (dateValidations[0] || dateValidations[1]) {
@@ -17,13 +17,13 @@ export const validateDateTimeRange = ({
17
17
  adapter,
18
18
  value: start,
19
19
  props: _extends({}, otherProps, {
20
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'start'))
20
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'start')
21
21
  })
22
22
  }), validateDateTime({
23
23
  adapter,
24
24
  value: end,
25
25
  props: _extends({}, otherProps, {
26
- shouldDisableDate: day => !!(shouldDisableDate != null && shouldDisableDate(day, 'end'))
26
+ shouldDisableDate: day => !!shouldDisableDate?.(day, 'end')
27
27
  })
28
28
  })];
29
29
  if (dateTimeValidations[0] || dateTimeValidations[1]) {
@@ -3,4 +3,6 @@ import { PickerValidDate } from '@mui/x-date-pickers/models';
3
3
  import type { DateRangeValidationError, DateTimeRangeValidationError, TimeRangeValidationError, RangeFieldSection, DateRange } from '../../models';
4
4
  export type RangePickerValueManager<TValue = [any, any], TDate extends PickerValidDate = any, TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerValueManager<TValue, TDate, TError>;
5
5
  export declare const rangeValueManager: RangePickerValueManager;
6
- export declare const rangeFieldValueManager: FieldValueManager<DateRange<any>, any, RangeFieldSection>;
6
+ export declare const getRangeFieldValueManager: <TDate extends PickerValidDate>({ dateSeparator, }: {
7
+ dateSeparator: string | undefined;
8
+ }) => FieldValueManager<DateRange<TDate>, TDate, RangeFieldSection>;
@@ -17,7 +17,7 @@ export const rangeValueManager = {
17
17
  if (shouldKeepStartDate && shouldKeepEndDate) {
18
18
  return value;
19
19
  }
20
- const referenceDate = referenceDateProp != null ? referenceDateProp : getDefaultReferenceDate(params);
20
+ const referenceDate = referenceDateProp ?? getDefaultReferenceDate(params);
21
21
  return [shouldKeepStartDate ? value[0] : referenceDate, shouldKeepEndDate ? value[1] : referenceDate];
22
22
  },
23
23
  cleanValue: (utils, value) => value.map(date => replaceInvalidDateByNull(utils, date)),
@@ -31,11 +31,13 @@ export const rangeValueManager = {
31
31
  if (timezoneStart != null && timezoneEnd != null && timezoneStart !== timezoneEnd) {
32
32
  throw new Error('MUI X: The timezone of the start and the end date should be the same.');
33
33
  }
34
- return timezoneStart != null ? timezoneStart : timezoneEnd;
34
+ return timezoneStart ?? timezoneEnd;
35
35
  },
36
36
  setTimezone: (utils, timezone, value) => [value[0] == null ? null : utils.setTimezone(value[0], timezone), value[1] == null ? null : utils.setTimezone(value[1], timezone)]
37
37
  };
38
- export const rangeFieldValueManager = {
38
+ export const getRangeFieldValueManager = ({
39
+ dateSeparator = '–'
40
+ }) => ({
39
41
  updateReferenceValue: (utils, value, prevReferenceValue) => {
40
42
  const shouldKeepStartDate = value[0] != null && utils.isValid(value[0]);
41
43
  const shouldKeepEndDate = value[1] != null && utils.isValid(value[1]);
@@ -66,7 +68,7 @@ export const rangeFieldValueManager = {
66
68
  return _extends({}, section, {
67
69
  dateName: position,
68
70
  // TODO: Check if RTL still works
69
- endSeparator: `${section.endSeparator} `
71
+ endSeparator: `${section.endSeparator} ${dateSeparator} `
70
72
  });
71
73
  }
72
74
  return _extends({}, section, {
@@ -85,8 +87,8 @@ export const rangeFieldValueManager = {
85
87
  return createDateStrForV6InputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], localizedDigits, isRTL);
86
88
  },
87
89
  parseValueStr: (valueStr, referenceValue, parseDate) => {
88
- // TODO: Improve because it would not work if the date format has `–` as a separator.
89
- const [startStr, endStr] = valueStr.split('–');
90
+ // TODO: Improve because it would not work if some section have the same separator as the dateSeparator.
91
+ const [startStr, endStr] = valueStr.split(dateSeparator);
90
92
  return [startStr, endStr].map((dateStr, index) => {
91
93
  if (dateStr == null) {
92
94
  return null;
@@ -113,4 +115,4 @@ export const rangeFieldValueManager = {
113
115
  })
114
116
  };
115
117
  }
116
- };
118
+ });
@@ -36,12 +36,19 @@ export interface MultiInputFieldRefs {
36
36
  unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
37
37
  unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
38
38
  }
39
+ export interface RangeFieldSeparatorProps {
40
+ /**
41
+ * String displayed between the start and the end dates.
42
+ * @default "–"
43
+ */
44
+ dateSeparator?: string;
45
+ }
39
46
  /**
40
47
  * Props the multi input field can receive when used inside a picker.
41
48
  * Only contains what the MUI components are passing to the field,
42
49
  * not what users can pass using the `props.slotProps.field`.
43
50
  */
44
- export interface BaseMultiInputFieldProps<TValue, TDate extends PickerValidDate, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Omit<BaseFieldProps<TValue, TDate, TSection, TEnableAccessibleFieldDOMStructure, TError>, 'unstableFieldRef'> {
51
+ export interface BaseMultiInputFieldProps<TValue, TDate extends PickerValidDate, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Omit<BaseFieldProps<TValue, TDate, TSection, TEnableAccessibleFieldDOMStructure, TError>, 'unstableFieldRef'>, RangeFieldSeparatorProps {
45
52
  sx?: SxProps<any>;
46
53
  unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
47
54
  unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
@@ -647,7 +647,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
647
647
  /**
648
648
  * Disable specific date.
649
649
  *
650
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
650
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
651
651
  *
652
652
  * @template TDate
653
653
  * @param {TDate} day The date to test.
@@ -277,7 +277,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
277
277
  /**
278
278
  * Disable specific date.
279
279
  *
280
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
280
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
281
281
  *
282
282
  * @template TDate
283
283
  * @param {TDate} day The date to test.
@@ -9,6 +9,16 @@ import { useThemeProps } from '@mui/material/styles';
9
9
  import { DesktopDateTimeRangePicker } from '../DesktopDateTimeRangePicker';
10
10
  import { MobileDateTimeRangePicker } from '../MobileDateTimeRangePicker';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ /**
13
+ * Demos:
14
+ *
15
+ * - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
16
+ * - [Validation](https://mui.com/x/react-date-pickers/validation/)
17
+ *
18
+ * API:
19
+ *
20
+ * - [DateTimeRangePicker API](https://mui.com/x/api/date-pickers/date-time-range-picker/)
21
+ */
12
22
  const DateTimeRangePicker = /*#__PURE__*/React.forwardRef(function DateTimeRangePicker(inProps, ref) {
13
23
  const props = useThemeProps({
14
24
  props: inProps,
@@ -312,7 +322,7 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
312
322
  /**
313
323
  * Disable specific date.
314
324
  *
315
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
325
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
316
326
  *
317
327
  * @template TDate
318
328
  * @param {TDate} day The date to test.
@@ -282,7 +282,7 @@ DesktopDateRangePicker.propTypes = {
282
282
  /**
283
283
  * Disable specific date.
284
284
  *
285
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
285
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
286
286
  *
287
287
  * @template TDate
288
288
  * @param {TDate} day The date to test.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["openTo", "rangePosition", "sx"];
3
+ const _excluded = ["openTo", "rangePosition"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { extractValidationProps, isDatePickerView, isInternalTimeView } from '@mui/x-date-pickers/internals';
@@ -10,6 +10,7 @@ import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } fr
10
10
  import { multiSectionDigitalClockClasses, multiSectionDigitalClockSectionClasses } from '@mui/x-date-pickers/MultiSectionDigitalClock';
11
11
  import Divider from '@mui/material/Divider';
12
12
  import { digitalClockClasses } from '@mui/x-date-pickers/DigitalClock';
13
+ import { DesktopDateTimePickerLayout } from '@mui/x-date-pickers/DesktopDateTimePicker';
13
14
  import { rangeValueManager } from '../internals/utils/valueManagers';
14
15
  import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
15
16
  import { useDesktopRangePicker } from '../internals/hooks/useDesktopRangePicker';
@@ -18,26 +19,25 @@ import { useDateTimeRangePickerDefaultizedProps } from '../DateTimeRangePicker/s
18
19
  import { MultiInputDateTimeRangeField } from '../MultiInputDateTimeRangeField';
19
20
  import { DateTimeRangePickerTimeWrapper } from '../DateTimeRangePicker/DateTimeRangePickerTimeWrapper';
20
21
  import { RANGE_VIEW_HEIGHT } from '../internals/constants/dimensions';
21
- import { DesktopDateTimeRangePickerLayout } from './DesktopDateTimeRangePickerLayout';
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
24
24
  const rendererInterceptor = function rendererInterceptor(inViewRenderers, popperView, rendererProps) {
25
25
  const {
26
26
  openTo,
27
- rangePosition,
28
- sx
27
+ rangePosition
29
28
  } = rendererProps,
30
29
  otherProps = _objectWithoutPropertiesLoose(rendererProps, _excluded);
31
30
  const finalProps = _extends({}, otherProps, {
32
31
  rangePosition,
33
32
  focusedView: null,
34
33
  sx: [{
35
- borderBottom: 0,
36
- width: 'auto',
34
+ [`&.${multiSectionDigitalClockClasses.root}`]: {
35
+ borderBottom: 0
36
+ },
37
37
  [`&.${multiSectionDigitalClockClasses.root}, .${multiSectionDigitalClockSectionClasses.root}, &.${digitalClockClasses.root}`]: {
38
38
  maxHeight: RANGE_VIEW_HEIGHT
39
39
  }
40
- }, ...(Array.isArray(sx) ? sx : [sx])]
40
+ }]
41
41
  });
42
42
  const isTimeViewActive = isInternalTimeView(popperView);
43
43
  return /*#__PURE__*/_jsxs(React.Fragment, {
@@ -49,11 +49,22 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
49
49
  orientation: "vertical"
50
50
  }), /*#__PURE__*/_jsx(DateTimeRangePickerTimeWrapper, _extends({}, finalProps, {
51
51
  view: isTimeViewActive ? popperView : 'hours',
52
+ views: finalProps.views.filter(isInternalTimeView),
52
53
  openTo: isInternalTimeView(openTo) ? openTo : 'hours',
53
54
  viewRenderer: inViewRenderers[isTimeViewActive ? popperView : 'hours']
54
55
  }))]
55
56
  });
56
57
  };
58
+ /**
59
+ * Demos:
60
+ *
61
+ * - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
62
+ * - [Validation](https://mui.com/x/react-date-pickers/validation/)
63
+ *
64
+ * API:
65
+ *
66
+ * - [DesktopDateTimeRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-range-picker/)
67
+ */
57
68
  const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimeRangePicker(inProps, ref) {
58
69
  // Props with the default values common to all date time range pickers
59
70
  const defaultizedProps = useDateTimeRangePickerDefaultizedProps(inProps, 'MuiDesktopDateTimeRangePicker');
@@ -78,7 +89,7 @@ const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
78
89
  calendars: defaultizedProps.calendars ?? 1,
79
90
  slots: _extends({
80
91
  field: MultiInputDateTimeRangeField,
81
- layout: DesktopDateTimeRangePickerLayout
92
+ layout: DesktopDateTimePickerLayout
82
93
  }, defaultizedProps.slots),
83
94
  slotProps: _extends({}, defaultizedProps.slotProps, {
84
95
  field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
@@ -381,7 +392,7 @@ DesktopDateTimeRangePicker.propTypes = {
381
392
  /**
382
393
  * Disable specific date.
383
394
  *
384
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
395
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
385
396
  *
386
397
  * @template TDate
387
398
  * @param {TDate} day The date to test.
@@ -278,7 +278,7 @@ MobileDateRangePicker.propTypes = {
278
278
  /**
279
279
  * Disable specific date.
280
280
  *
281
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
281
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
282
282
  *
283
283
  * @template TDate
284
284
  * @param {TDate} day The date to test.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["view", "openTo", "rangePosition", "sx"];
3
+ const _excluded = ["view", "openTo", "rangePosition"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { refType } from '@mui/utils';
@@ -22,8 +22,7 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
22
22
  const {
23
23
  view,
24
24
  openTo,
25
- rangePosition,
26
- sx
25
+ rangePosition
27
26
  } = rendererProps,
28
27
  otherRendererProps = _objectWithoutPropertiesLoose(rendererProps, _excluded);
29
28
  const finalProps = _extends({}, otherRendererProps, {
@@ -48,7 +47,7 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
48
47
  [`&.${multiSectionDigitalClockClasses.root}, .${multiSectionDigitalClockSectionClasses.root}`]: {
49
48
  maxHeight: RANGE_VIEW_HEIGHT - 1
50
49
  }
51
- }, ...(Array.isArray(sx) ? sx : [sx])]
50
+ }]
52
51
  });
53
52
  const isTimeView = isInternalTimeView(popperView);
54
53
  const viewRenderer = inViewRenderers[popperView];
@@ -59,6 +58,7 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
59
58
  return /*#__PURE__*/_jsx(DateTimeRangePickerTimeWrapper, _extends({}, finalProps, {
60
59
  viewRenderer: viewRenderer,
61
60
  view: view && isInternalTimeView(view) ? view : 'hours',
61
+ views: finalProps.views,
62
62
  openTo: isInternalTimeView(openTo) ? openTo : 'hours'
63
63
  }));
64
64
  }
@@ -71,6 +71,16 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
71
71
  openTo: isDatePickerView(openTo) ? openTo : 'day'
72
72
  }));
73
73
  };
74
+ /**
75
+ * Demos:
76
+ *
77
+ * - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
78
+ * - [Validation](https://mui.com/x/react-date-pickers/validation/)
79
+ *
80
+ * API:
81
+ *
82
+ * - [MobileDateTimeRangePicker API](https://mui.com/x/api/date-pickers/mobile-date-time-range-picker/)
83
+ */
74
84
  const MobileDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateTimeRangePicker(inProps, ref) {
75
85
  // Props with the default values common to all date time range pickers
76
86
  const defaultizedProps = useDateTimeRangePickerDefaultizedProps(inProps, 'MuiMobileDateTimeRangePicker');
@@ -384,7 +394,7 @@ MobileDateTimeRangePicker.propTypes = {
384
394
  /**
385
395
  * Disable specific date.
386
396
  *
387
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
397
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
388
398
  *
389
399
  * @template TDate
390
400
  * @param {TDate} day The date to test.
@@ -37,9 +37,7 @@ const MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
37
37
  slot: 'Root',
38
38
  overridesResolver: (props, styles) => styles.root
39
39
  })({});
40
- const MultiInputDateRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
41
- children: props.children ?? ' – '
42
- })), {
40
+ const MultiInputDateRangeFieldSeparator = styled(Typography, {
43
41
  name: 'MuiMultiInputDateRangeField',
44
42
  slot: 'Separator',
45
43
  overridesResolver: (props, styles) => styles.separator
@@ -105,6 +103,9 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
105
103
  const separatorProps = useSlotProps({
106
104
  elementType: Separator,
107
105
  externalSlotProps: slotProps?.separator,
106
+ additionalProps: {
107
+ children: ` ${internalProps.dateSeparator ?? '–'} `
108
+ },
108
109
  ownerState,
109
110
  className: classes.separator
110
111
  });
@@ -140,6 +141,11 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
140
141
  classes: PropTypes.object,
141
142
  className: PropTypes.string,
142
143
  component: PropTypes.elementType,
144
+ /**
145
+ * String displayed between the start and the end dates.
146
+ * @default "–"
147
+ */
148
+ dateSeparator: PropTypes.string,
143
149
  /**
144
150
  * The default value. Use when the component is not controlled.
145
151
  */
@@ -237,7 +243,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
237
243
  /**
238
244
  * Disable specific date.
239
245
  *
240
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
246
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
241
247
  *
242
248
  * @template TDate
243
249
  * @param {TDate} day The date to test.
@@ -37,9 +37,7 @@ const MultiInputDateTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((
37
37
  slot: 'Root',
38
38
  overridesResolver: (props, styles) => styles.root
39
39
  })({});
40
- const MultiInputDateTimeRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
41
- children: props.children ?? ' – '
42
- })), {
40
+ const MultiInputDateTimeRangeFieldSeparator = styled(Typography, {
43
41
  name: 'MuiMultiInputDateTimeRangeField',
44
42
  slot: 'Separator',
45
43
  overridesResolver: (props, styles) => styles.separator
@@ -105,6 +103,9 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
105
103
  const separatorProps = useSlotProps({
106
104
  elementType: Separator,
107
105
  externalSlotProps: slotProps?.separator,
106
+ additionalProps: {
107
+ children: ` ${internalProps.dateSeparator ?? '–'} `
108
+ },
108
109
  ownerState,
109
110
  className: classes.separator
110
111
  });
@@ -145,6 +146,11 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
145
146
  classes: PropTypes.object,
146
147
  className: PropTypes.string,
147
148
  component: PropTypes.elementType,
149
+ /**
150
+ * String displayed between the start and the end dates.
151
+ * @default "–"
152
+ */
153
+ dateSeparator: PropTypes.string,
148
154
  /**
149
155
  * The default value. Use when the component is not controlled.
150
156
  */
@@ -270,7 +276,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
270
276
  /**
271
277
  * Disable specific date.
272
278
  *
273
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
279
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
274
280
  *
275
281
  * @template TDate
276
282
  * @param {TDate} day The date to test.
@@ -37,9 +37,7 @@ const MultiInputTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
37
37
  slot: 'Root',
38
38
  overridesResolver: (props, styles) => styles.root
39
39
  })({});
40
- const MultiInputTimeRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
41
- children: props.children ?? ' – '
42
- })), {
40
+ const MultiInputTimeRangeFieldSeparator = styled(Typography, {
43
41
  name: 'MuiMultiInputTimeRangeField',
44
42
  slot: 'Separator',
45
43
  overridesResolver: (props, styles) => styles.separator
@@ -105,6 +103,9 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
105
103
  const separatorProps = useSlotProps({
106
104
  elementType: Separator,
107
105
  externalSlotProps: slotProps?.separator,
106
+ additionalProps: {
107
+ children: ` ${internalProps.dateSeparator ?? '–'} `
108
+ },
108
109
  ownerState,
109
110
  className: classes.separator
110
111
  });
@@ -145,6 +146,11 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
145
146
  classes: PropTypes.object,
146
147
  className: PropTypes.string,
147
148
  component: PropTypes.elementType,
149
+ /**
150
+ * String displayed between the start and the end dates.
151
+ * @default "–"
152
+ */
153
+ dateSeparator: PropTypes.string,
148
154
  /**
149
155
  * The default value. Use when the component is not controlled.
150
156
  */
@@ -82,6 +82,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
82
82
  */
83
83
  color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
84
84
  component: PropTypes.elementType,
85
+ /**
86
+ * String displayed between the start and the end dates.
87
+ * @default "–"
88
+ */
89
+ dateSeparator: PropTypes.string,
85
90
  /**
86
91
  * The default value. Use when the component is not controlled.
87
92
  */
@@ -242,7 +247,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
242
247
  /**
243
248
  * Disable specific date.
244
249
  *
245
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
250
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
246
251
  *
247
252
  * @template TDate
248
253
  * @param {TDate} day The date to test.
@@ -1,5 +1,6 @@
1
+ import * as React from 'react';
1
2
  import { useField, splitFieldInternalAndForwardedProps, useDefaultizedDateField } from '@mui/x-date-pickers/internals';
2
- import { rangeValueManager, rangeFieldValueManager } from '../internals/utils/valueManagers';
3
+ import { rangeValueManager, getRangeFieldValueManager } from '../internals/utils/valueManagers';
3
4
  import { validateDateRange } from '../internals/utils/validation/validateDateRange';
4
5
  export const useSingleInputDateRangeField = inProps => {
5
6
  const props = useDefaultizedDateField(inProps);
@@ -7,11 +8,14 @@ export const useSingleInputDateRangeField = inProps => {
7
8
  forwardedProps,
8
9
  internalProps
9
10
  } = splitFieldInternalAndForwardedProps(props, 'date');
11
+ const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
12
+ dateSeparator: internalProps.dateSeparator
13
+ }), [internalProps.dateSeparator]);
10
14
  return useField({
11
15
  forwardedProps,
12
16
  internalProps,
13
17
  valueManager: rangeValueManager,
14
- fieldValueManager: rangeFieldValueManager,
18
+ fieldValueManager,
15
19
  validator: validateDateRange,
16
20
  valueType: 'date'
17
21
  });
@@ -87,6 +87,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
87
87
  */
88
88
  color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
89
89
  component: PropTypes.elementType,
90
+ /**
91
+ * String displayed between the start and the end dates.
92
+ * @default "–"
93
+ */
94
+ dateSeparator: PropTypes.string,
90
95
  /**
91
96
  * The default value. Use when the component is not controlled.
92
97
  */
@@ -275,7 +280,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
275
280
  /**
276
281
  * Disable specific date.
277
282
  *
278
- * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
283
+ * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
279
284
  *
280
285
  * @template TDate
281
286
  * @param {TDate} day The date to test.