@mui/x-date-pickers-pro 8.0.0-alpha.0 → 8.0.0-alpha.2

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 (103) hide show
  1. package/CHANGELOG.md +651 -6
  2. package/DateRangeCalendar/DateRangeCalendar.js +3 -1
  3. package/DateRangePicker/DateRangePicker.types.d.ts +2 -2
  4. package/DateRangePicker/DateRangePickerToolbar.js +0 -12
  5. package/DateRangePicker/shared.d.ts +3 -2
  6. package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +2 -2
  7. package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  8. package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -2
  9. package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +6 -16
  10. package/DateTimeRangePicker/shared.d.ts +4 -3
  11. package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  12. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +12 -10
  13. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  14. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +11 -9
  15. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  16. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +11 -9
  17. package/README.md +9 -6
  18. package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  19. package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -10
  20. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  21. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +11 -10
  22. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  23. package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +10 -9
  24. package/index.js +1 -1
  25. package/internals/hooks/models/useRangePicker.d.ts +1 -2
  26. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +14 -4
  27. package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +14 -13
  28. package/internals/hooks/useEnrichedRangePickerFieldProps.js +17 -18
  29. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +15 -5
  30. package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +6 -7
  31. package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +2 -0
  32. package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +2 -0
  33. package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +3 -1
  34. package/internals/hooks/useRangePosition.d.ts +3 -2
  35. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -1
  36. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
  37. package/internals/models/dateTimeRange.d.ts +2 -2
  38. package/internals/models/fields.d.ts +6 -6
  39. package/internals/models/timeRange.d.ts +2 -2
  40. package/internals/utils/date-fields-utils.d.ts +6 -6
  41. package/internals/utils/date-range-manager.d.ts +2 -1
  42. package/internals/utils/date-range-manager.js +11 -9
  43. package/internals/utils/releaseInfo.js +1 -1
  44. package/internals/utils/valueManagers.d.ts +4 -3
  45. package/models/dateRange.d.ts +3 -3
  46. package/models/fields.d.ts +6 -9
  47. package/models/index.d.ts +1 -0
  48. package/models/index.js +2 -1
  49. package/models/range.d.ts +0 -1
  50. package/modern/DateRangeCalendar/DateRangeCalendar.js +3 -1
  51. package/modern/DateRangePicker/DateRangePickerToolbar.js +0 -12
  52. package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  53. package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +6 -16
  54. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  55. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  56. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  57. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  58. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  59. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  60. package/modern/index.js +1 -1
  61. package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +14 -4
  62. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +17 -18
  63. package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +15 -5
  64. package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +2 -0
  65. package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +2 -0
  66. package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +3 -1
  67. package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -1
  68. package/modern/internals/utils/date-range-manager.js +11 -9
  69. package/modern/internals/utils/releaseInfo.js +1 -1
  70. package/modern/models/index.js +2 -1
  71. package/modern/validation/validateDateRange.js +8 -0
  72. package/modern/validation/validateDateTimeRange.js +4 -0
  73. package/modern/validation/validateTimeRange.js +8 -0
  74. package/node/DateRangeCalendar/DateRangeCalendar.js +3 -1
  75. package/node/DateRangePicker/DateRangePickerToolbar.js +0 -12
  76. package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -6
  77. package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +5 -15
  78. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -11
  79. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +9 -11
  80. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -11
  81. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
  82. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
  83. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
  84. package/node/index.js +1 -1
  85. package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +14 -4
  86. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +17 -18
  87. package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +15 -5
  88. package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +2 -0
  89. package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +2 -0
  90. package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +3 -1
  91. package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -1
  92. package/node/internals/utils/date-range-manager.js +11 -9
  93. package/node/internals/utils/releaseInfo.js +1 -1
  94. package/node/validation/validateDateRange.js +8 -0
  95. package/node/validation/validateDateTimeRange.js +4 -0
  96. package/node/validation/validateTimeRange.js +8 -0
  97. package/package.json +6 -6
  98. package/validation/validateDateRange.d.ts +9 -1
  99. package/validation/validateDateRange.js +8 -0
  100. package/validation/validateDateTimeRange.d.ts +6 -2
  101. package/validation/validateDateTimeRange.js +4 -0
  102. package/validation/validateTimeRange.d.ts +9 -1
  103. package/validation/validateTimeRange.js +8 -0
@@ -23,14 +23,11 @@ var _hooks = require("@mui/x-date-pickers/hooks");
23
23
  var _PickersTextField = require("@mui/x-date-pickers/PickersTextField");
24
24
  var _useMultiInputDateTimeRangeField = require("../internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField");
25
25
  var _jsxRuntime = require("react/jsx-runtime");
26
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
26
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
27
27
  const multiInputDateTimeRangeFieldClasses = exports.multiInputDateTimeRangeFieldClasses = (0, _utils.unstable_generateUtilityClasses)('MuiMultiInputDateTimeRangeField', ['root', 'separator']);
28
28
  const getMultiInputDateTimeRangeFieldUtilityClass = slot => (0, _utils.unstable_generateUtilityClass)('MuiMultiInputDateTimeRangeField', slot);
29
29
  exports.getMultiInputDateTimeRangeFieldUtilityClass = getMultiInputDateTimeRangeFieldUtilityClass;
30
- const useUtilityClasses = ownerState => {
31
- const {
32
- classes
33
- } = ownerState;
30
+ const useUtilityClasses = classes => {
34
31
  const slots = {
35
32
  root: ['root'],
36
33
  separator: ['separator']
@@ -78,11 +75,12 @@ const MultiInputDateTimeRangeField = exports.MultiInputDateTimeRangeField = /*#_
78
75
  slotProps,
79
76
  unstableStartFieldRef,
80
77
  unstableEndFieldRef,
81
- className
78
+ className,
79
+ classes: classesProp
82
80
  } = forwardedProps,
83
81
  otherForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(forwardedProps, _excluded);
84
- const ownerState = themeProps;
85
- const classes = useUtilityClasses(ownerState);
82
+ const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
83
+ const classes = useUtilityClasses(classesProp);
86
84
  const Root = slots?.root ?? MultiInputDateTimeRangeFieldRoot;
87
85
  const rootProps = (0, _useSlotProps.default)({
88
86
  elementType: Root,
@@ -306,10 +304,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
306
304
  */
307
305
  shouldDisableTime: _propTypes.default.func,
308
306
  /**
309
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
310
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
307
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
308
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
311
309
  *
312
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
310
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
313
311
  *
314
312
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
315
313
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -23,14 +23,11 @@ var _hooks = require("@mui/x-date-pickers/hooks");
23
23
  var _PickersTextField = require("@mui/x-date-pickers/PickersTextField");
24
24
  var _useMultiInputTimeRangeField = require("../internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField");
25
25
  var _jsxRuntime = require("react/jsx-runtime");
26
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
26
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
27
27
  const multiInputTimeRangeFieldClasses = exports.multiInputTimeRangeFieldClasses = (0, _utils.unstable_generateUtilityClasses)('MuiMultiInputTimeRangeField', ['root', 'separator']);
28
28
  const getMultiInputTimeRangeFieldUtilityClass = slot => (0, _utils.unstable_generateUtilityClass)('MuiMultiInputTimeRangeField', slot);
29
29
  exports.getMultiInputTimeRangeFieldUtilityClass = getMultiInputTimeRangeFieldUtilityClass;
30
- const useUtilityClasses = ownerState => {
31
- const {
32
- classes
33
- } = ownerState;
30
+ const useUtilityClasses = classes => {
34
31
  const slots = {
35
32
  root: ['root'],
36
33
  separator: ['separator']
@@ -78,11 +75,12 @@ const MultiInputTimeRangeField = exports.MultiInputTimeRangeField = /*#__PURE__*
78
75
  slotProps,
79
76
  unstableStartFieldRef,
80
77
  unstableEndFieldRef,
81
- className
78
+ className,
79
+ classes: classesProp
82
80
  } = forwardedProps,
83
81
  otherForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(forwardedProps, _excluded);
84
- const ownerState = themeProps;
85
- const classes = useUtilityClasses(ownerState);
82
+ const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
83
+ const classes = useUtilityClasses(classesProp);
86
84
  const Root = slots?.root ?? MultiInputTimeRangeFieldRoot;
87
85
  const rootProps = (0, _useSlotProps.default)({
88
86
  elementType: Root,
@@ -278,10 +276,10 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
278
276
  */
279
277
  shouldDisableTime: _propTypes.default.func,
280
278
  /**
281
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
282
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
279
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
280
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
283
281
  *
284
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
282
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
285
283
  *
286
284
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
287
285
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -43,7 +43,7 @@ const SingleInputDateRangeField = exports.SingleInputDateRangeField = /*#__PURE_
43
43
  inputProps
44
44
  } = themeProps,
45
45
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
46
- const ownerState = themeProps;
46
+ const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
47
47
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
48
48
  const textFieldProps = (0, _useSlotProps.default)({
49
49
  elementType: TextField,
@@ -269,10 +269,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
269
269
  */
270
270
  shouldDisableDate: _propTypes.default.func,
271
271
  /**
272
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
273
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
272
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
273
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
274
274
  *
275
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
275
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
276
276
  *
277
277
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
278
278
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -43,7 +43,7 @@ const SingleInputDateTimeRangeField = exports.SingleInputDateTimeRangeField = /*
43
43
  inputProps
44
44
  } = themeProps,
45
45
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
46
- const ownerState = themeProps;
46
+ const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
47
47
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
48
48
  const textFieldProps = (0, _useSlotProps.default)({
49
49
  elementType: TextField,
@@ -309,10 +309,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
309
309
  */
310
310
  shouldDisableTime: _propTypes.default.func,
311
311
  /**
312
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
313
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
312
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
313
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
314
314
  *
315
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
315
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
316
316
  *
317
317
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
318
318
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -43,7 +43,7 @@ const SingleInputTimeRangeField = exports.SingleInputTimeRangeField = /*#__PURE_
43
43
  inputProps
44
44
  } = themeProps,
45
45
  other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
46
- const ownerState = themeProps;
46
+ const ownerState = (0, _internals.useFieldOwnerState)(themeProps);
47
47
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
48
48
  const textFieldProps = (0, _useSlotProps.default)({
49
49
  elementType: TextField,
@@ -281,10 +281,10 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
281
281
  */
282
282
  shouldDisableTime: _propTypes.default.func,
283
283
  /**
284
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
285
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
284
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
285
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
286
286
  *
287
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
287
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
288
288
  *
289
289
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
290
290
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v8.0.0-alpha.0
2
+ * @mui/x-date-pickers-pro v8.0.0-alpha.2
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -51,12 +51,21 @@ const useDesktopRangePicker = _ref => {
51
51
  const popperRef = React.useRef(null);
52
52
  const startFieldRef = React.useRef(null);
53
53
  const endFieldRef = React.useRef(null);
54
+ const singleInputFieldRef = React.useRef(null);
54
55
  const initialView = React.useRef(props.openTo ?? null);
55
56
  const fieldType = slots.field.fieldType ?? 'multi-input';
56
57
  const {
57
58
  rangePosition,
58
59
  onRangePositionChange
59
- } = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ? startFieldRef : undefined);
60
+ } = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
61
+ let fieldRef;
62
+ if (fieldType === 'single-input') {
63
+ fieldRef = singleInputFieldRef;
64
+ } else if (rangePosition === 'start') {
65
+ fieldRef = startFieldRef;
66
+ } else {
67
+ fieldRef = endFieldRef;
68
+ }
60
69
  const {
61
70
  open,
62
71
  actions,
@@ -68,9 +77,9 @@ const useDesktopRangePicker = _ref => {
68
77
  ownerState
69
78
  } = (0, _internals.usePicker)((0, _extends2.default)({}, pickerParams, {
70
79
  props,
71
- wrapperVariant: 'desktop',
80
+ variant: 'desktop',
72
81
  autoFocusView: false,
73
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
82
+ fieldRef,
74
83
  localeText,
75
84
  additionalViewProps: {
76
85
  rangePosition,
@@ -121,7 +130,7 @@ const useDesktopRangePicker = _ref => {
121
130
  ownerState
122
131
  });
123
132
  const enrichedFieldProps = (0, _useEnrichedRangePickerFieldProps.useEnrichedRangePickerFieldProps)({
124
- wrapperVariant: 'desktop',
133
+ variant: 'desktop',
125
134
  fieldType,
126
135
  open,
127
136
  actions,
@@ -138,6 +147,7 @@ const useDesktopRangePicker = _ref => {
138
147
  anchorRef,
139
148
  startFieldRef,
140
149
  endFieldRef,
150
+ singleInputFieldRef,
141
151
  currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
142
152
  initialView: initialView.current ?? undefined,
143
153
  onViewChange: layoutProps.onViewChange
@@ -16,7 +16,7 @@ var _hooks = require("@mui/x-date-pickers/hooks");
16
16
  var _internals = require("@mui/x-date-pickers/internals");
17
17
  const _excluded = ["clearable", "onClear"];
18
18
  const useMultiInputFieldSlotProps = ({
19
- wrapperVariant,
19
+ variant,
20
20
  open,
21
21
  actions,
22
22
  readOnly,
@@ -41,7 +41,7 @@ const useMultiInputFieldSlotProps = ({
41
41
  const handleEndFieldRef = (0, _useForkRef.default)(fieldProps.unstableEndFieldRef, endFieldRef);
42
42
  const previousRangePosition = React.useRef(rangePosition);
43
43
  React.useEffect(() => {
44
- if (!open) {
44
+ if (!open || variant === 'mobile') {
45
45
  return;
46
46
  }
47
47
  const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
@@ -57,7 +57,7 @@ const useMultiInputFieldSlotProps = ({
57
57
  // use the current view or `0` when the range position has just been swapped
58
58
  previousRangePosition.current === rangePosition ? currentView : 0);
59
59
  previousRangePosition.current = rangePosition;
60
- }, [rangePosition, open, currentView, startFieldRef, endFieldRef]);
60
+ }, [rangePosition, open, currentView, startFieldRef, endFieldRef, variant]);
61
61
  const openRangeStartSelection = event => {
62
62
  event.stopPropagation();
63
63
  onRangePositionChange('start');
@@ -106,7 +106,7 @@ const useMultiInputFieldSlotProps = ({
106
106
  focused: open ? rangePosition === 'start' : undefined
107
107
  }, !readOnly && !fieldProps.disabled && {
108
108
  onClick: openRangeStartSelection
109
- }, wrapperVariant === 'mobile' && {
109
+ }, variant === 'mobile' && {
110
110
  readOnly: true
111
111
  });
112
112
  if (anchorRef) {
@@ -122,7 +122,7 @@ const useMultiInputFieldSlotProps = ({
122
122
  focused: open ? rangePosition === 'end' : undefined
123
123
  }, !readOnly && !fieldProps.disabled && {
124
124
  onClick: openRangeEndSelection
125
- }, wrapperVariant === 'mobile' && {
125
+ }, variant === 'mobile' && {
126
126
  readOnly: true
127
127
  });
128
128
  InputProps = resolvedComponentProps?.InputProps;
@@ -154,7 +154,7 @@ const useMultiInputFieldSlotProps = ({
154
154
  return enrichedFieldProps;
155
155
  };
156
156
  const useSingleInputFieldSlotProps = ({
157
- wrapperVariant,
157
+ variant,
158
158
  open,
159
159
  actions,
160
160
  readOnly,
@@ -164,36 +164,35 @@ const useSingleInputFieldSlotProps = ({
164
164
  onBlur,
165
165
  rangePosition,
166
166
  onRangePositionChange,
167
- startFieldRef,
168
- endFieldRef,
167
+ singleInputFieldRef,
169
168
  pickerSlots,
170
169
  pickerSlotProps,
171
170
  fieldProps,
172
171
  anchorRef,
173
172
  currentView
174
173
  }) => {
175
- const handleFieldRef = (0, _useForkRef.default)(fieldProps.unstableFieldRef, startFieldRef, endFieldRef);
174
+ const handleFieldRef = (0, _useForkRef.default)(fieldProps.unstableFieldRef, singleInputFieldRef);
176
175
  React.useEffect(() => {
177
- if (!open || !startFieldRef.current) {
176
+ if (!open || !singleInputFieldRef.current || variant === 'mobile') {
178
177
  return;
179
178
  }
180
- if (startFieldRef.current.isFieldFocused()) {
179
+ if (singleInputFieldRef.current.isFieldFocused()) {
181
180
  return;
182
181
  }
183
182
 
184
183
  // bring back focus to the field with the current view section selected
185
184
  if (currentView) {
186
- const sections = startFieldRef.current.getSections().map(section => section.type);
185
+ const sections = singleInputFieldRef.current.getSections().map(section => section.type);
187
186
  const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
188
- startFieldRef.current?.focusField(newSelectedSection);
187
+ singleInputFieldRef.current?.focusField(newSelectedSection);
189
188
  }
190
- }, [rangePosition, open, currentView, startFieldRef]);
189
+ }, [rangePosition, open, currentView, singleInputFieldRef, variant]);
191
190
  const updateRangePosition = () => {
192
- if (!startFieldRef.current?.isFieldFocused()) {
191
+ if (!singleInputFieldRef.current?.isFieldFocused()) {
193
192
  return;
194
193
  }
195
- const sections = startFieldRef.current.getSections();
196
- const activeSectionIndex = startFieldRef.current?.getActiveSectionIndex();
194
+ const sections = singleInputFieldRef.current.getSections();
195
+ const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
197
196
  const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
198
197
  if (domRangePosition != null && domRangePosition !== rangePosition) {
199
198
  onRangePositionChange(domRangePosition);
@@ -233,7 +232,7 @@ const useSingleInputFieldSlotProps = ({
233
232
  focused: open ? true : undefined
234
233
  }, labelId != null && {
235
234
  id: labelId
236
- }, wrapperVariant === 'mobile' && {
235
+ }, variant === 'mobile' && {
237
236
  readOnly: true
238
237
  }, !readOnly && !fieldProps.disabled && {
239
238
  onClick: openPicker
@@ -48,13 +48,22 @@ const useMobileRangePicker = _ref => {
48
48
  } = props;
49
49
  const startFieldRef = React.useRef(null);
50
50
  const endFieldRef = React.useRef(null);
51
+ const singleInputFieldRef = React.useRef(null);
51
52
  const fieldType = slots.field.fieldType ?? 'multi-input';
52
53
  const {
53
54
  rangePosition,
54
55
  onRangePositionChange
55
- } = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ? startFieldRef : undefined);
56
+ } = (0, _useRangePosition.useRangePosition)(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
56
57
  const labelId = (0, _useId.default)();
57
58
  const contextTranslations = (0, _hooks.usePickerTranslations)();
59
+ let fieldRef;
60
+ if (fieldType === 'single-input') {
61
+ fieldRef = singleInputFieldRef;
62
+ } else if (rangePosition === 'start') {
63
+ fieldRef = startFieldRef;
64
+ } else {
65
+ fieldRef = endFieldRef;
66
+ }
58
67
  const {
59
68
  open,
60
69
  actions,
@@ -65,9 +74,9 @@ const useMobileRangePicker = _ref => {
65
74
  ownerState
66
75
  } = (0, _internals.usePicker)((0, _extends2.default)({}, pickerParams, {
67
76
  props,
68
- wrapperVariant: 'mobile',
77
+ variant: 'mobile',
69
78
  autoFocusView: true,
70
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
79
+ fieldRef,
71
80
  localeText,
72
81
  additionalViewProps: {
73
82
  rangePosition,
@@ -103,7 +112,7 @@ const useMobileRangePicker = _ref => {
103
112
  });
104
113
  const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
105
114
  const enrichedFieldProps = (0, _useEnrichedRangePickerFieldProps.useEnrichedRangePickerFieldProps)({
106
- wrapperVariant: 'mobile',
115
+ variant: 'mobile',
107
116
  fieldType,
108
117
  open,
109
118
  actions,
@@ -118,7 +127,8 @@ const useMobileRangePicker = _ref => {
118
127
  pickerSlotProps: innerSlotProps,
119
128
  fieldProps,
120
129
  startFieldRef,
121
- endFieldRef
130
+ endFieldRef,
131
+ singleInputFieldRef
122
132
  });
123
133
  const slotPropsForLayout = (0, _extends2.default)({}, innerSlotProps, {
124
134
  tabs: (0, _extends2.default)({}, innerSlotProps?.tabs, {
@@ -25,6 +25,7 @@ const useMultiInputDateRangeField = ({
25
25
  const {
26
26
  value: valueProp,
27
27
  defaultValue,
28
+ referenceDate,
28
29
  format,
29
30
  formatDensity,
30
31
  shouldRespectLeadingZeros,
@@ -46,6 +47,7 @@ const useMultiInputDateRangeField = ({
46
47
  timezone: timezoneProp,
47
48
  value: valueProp,
48
49
  defaultValue,
50
+ referenceDate,
49
51
  onChange,
50
52
  valueManager: _valueManagers.rangeValueManager
51
53
  });
@@ -25,6 +25,7 @@ const useMultiInputDateTimeRangeField = ({
25
25
  const {
26
26
  value: valueProp,
27
27
  defaultValue,
28
+ referenceDate,
28
29
  format,
29
30
  formatDensity,
30
31
  shouldRespectLeadingZeros,
@@ -46,6 +47,7 @@ const useMultiInputDateTimeRangeField = ({
46
47
  timezone: timezoneProp,
47
48
  value: valueProp,
48
49
  defaultValue,
50
+ referenceDate,
49
51
  onChange,
50
52
  valueManager: _valueManagers.rangeValueManager
51
53
  });
@@ -25,6 +25,7 @@ const useMultiInputTimeRangeField = ({
25
25
  const {
26
26
  value: valueProp,
27
27
  defaultValue,
28
+ referenceDate,
28
29
  format,
29
30
  formatDensity,
30
31
  shouldRespectLeadingZeros,
@@ -47,7 +48,8 @@ const useMultiInputTimeRangeField = ({
47
48
  value: valueProp,
48
49
  defaultValue,
49
50
  onChange,
50
- valueManager: _valueManagers.rangeValueManager
51
+ valueManager: _valueManagers.rangeValueManager,
52
+ referenceDate
51
53
  });
52
54
  const {
53
55
  validationError,
@@ -60,7 +60,7 @@ const useStaticRangePicker = _ref => {
60
60
  rangePosition,
61
61
  onRangePositionChange
62
62
  },
63
- wrapperVariant: displayStaticWrapperAs
63
+ variant: displayStaticWrapperAs
64
64
  }));
65
65
  const Layout = slots?.layout ?? PickerStaticLayout;
66
66
  const slotPropsForLayout = (0, _extends2.default)({}, slotProps, {
@@ -12,7 +12,8 @@ function calculateRangeChange({
12
12
  newDate: selectedDate,
13
13
  rangePosition,
14
14
  allowRangeFlip = false,
15
- shouldMergeDateAndTime = false
15
+ shouldMergeDateAndTime = false,
16
+ referenceDate
16
17
  }) {
17
18
  const [start, end] = range;
18
19
  if (shouldMergeDateAndTime && selectedDate) {
@@ -24,29 +25,30 @@ function calculateRangeChange({
24
25
  selectedDate = (0, _internals.mergeDateAndTime)(utils, selectedDate, end);
25
26
  }
26
27
  }
28
+ const newSelectedDate = referenceDate && selectedDate && shouldMergeDateAndTime ? (0, _internals.mergeDateAndTime)(utils, selectedDate, referenceDate) : selectedDate;
27
29
  if (rangePosition === 'start') {
28
30
  const truthyResult = allowRangeFlip ? {
29
31
  nextSelection: 'start',
30
- newRange: [end, selectedDate]
32
+ newRange: [end, newSelectedDate]
31
33
  } : {
32
34
  nextSelection: 'end',
33
- newRange: [selectedDate, null]
35
+ newRange: [newSelectedDate, null]
34
36
  };
35
- return Boolean(end) && utils.isAfter(selectedDate, end) ? truthyResult : {
37
+ return Boolean(end) && utils.isAfter(newSelectedDate, end) ? truthyResult : {
36
38
  nextSelection: 'end',
37
- newRange: [selectedDate, end]
39
+ newRange: [newSelectedDate, end]
38
40
  };
39
41
  }
40
42
  const truthyResult = allowRangeFlip ? {
41
43
  nextSelection: 'end',
42
- newRange: [selectedDate, start]
44
+ newRange: [newSelectedDate, start]
43
45
  } : {
44
46
  nextSelection: 'end',
45
- newRange: [selectedDate, null]
47
+ newRange: [newSelectedDate, null]
46
48
  };
47
- return Boolean(start) && utils.isBeforeDay(selectedDate, start) ? truthyResult : {
49
+ return Boolean(start) && utils.isBeforeDay(newSelectedDate, start) ? truthyResult : {
48
50
  nextSelection: 'start',
49
- newRange: [start, selectedDate]
51
+ newRange: [start, newSelectedDate]
50
52
  };
51
53
  }
52
54
  function calculateRangePreview(options) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getReleaseInfo = void 0;
7
7
  var _utils = require("@mui/utils");
8
8
  const getReleaseInfo = () => {
9
- const releaseInfo = "MTczMTUzODgwMDAwMA==";
9
+ const releaseInfo = "MTczMjgzNDgwMDAwMA==";
10
10
  if (process.env.NODE_ENV !== 'production') {
11
11
  // A simple hack to set the value in the test environment (has no build step).
12
12
  // eslint-disable-next-line no-useless-concat
@@ -15,6 +15,14 @@ const _excluded = ["shouldDisableDate"];
15
15
  * Validation props used by the Date Range Picker, Date Range Field and Date Range Calendar components.
16
16
  */
17
17
 
18
+ /**
19
+ * Validation props as received by the validateDateRange method.
20
+ */
21
+
22
+ /**
23
+ * Name of the props that should be defaulted before being passed to the validateDateRange method.
24
+ */
25
+
18
26
  const validateDateRange = ({
19
27
  adapter,
20
28
  value,
@@ -15,6 +15,10 @@ const _excluded = ["shouldDisableDate"];
15
15
  * Validation props used by the Date Time Range Picker and Date Time Range Field.
16
16
  */
17
17
 
18
+ /**
19
+ * Validation props as received by the validateDateTimeRange method.
20
+ */
21
+
18
22
  const validateDateTimeRange = ({
19
23
  adapter,
20
24
  value,
@@ -11,6 +11,14 @@ var _valueManagers = require("../internals/utils/valueManagers");
11
11
  * Validation props used by the Time Range Picker and Time Range Field.
12
12
  */
13
13
 
14
+ /**
15
+ * Validation props as received by the validateTimeRange method.
16
+ */
17
+
18
+ /**
19
+ * Name of the props that should be defaulted before being passed to the validateTimeRange method.
20
+ */
21
+
14
22
  const validateTimeRange = ({
15
23
  adapter,
16
24
  value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-date-pickers-pro",
3
- "version": "8.0.0-alpha.0",
3
+ "version": "8.0.0-alpha.2",
4
4
  "description": "The Pro plan edition of the Date and Time Picker components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -37,9 +37,9 @@
37
37
  "clsx": "^2.1.1",
38
38
  "prop-types": "^15.8.1",
39
39
  "react-transition-group": "^4.4.5",
40
- "@mui/x-date-pickers": "8.0.0-alpha.0",
41
- "@mui/x-license": "8.0.0-alpha.0",
42
- "@mui/x-internals": "8.0.0-alpha.0"
40
+ "@mui/x-date-pickers": "8.0.0-alpha.2",
41
+ "@mui/x-internals": "8.0.0-alpha.2",
42
+ "@mui/x-license": "8.0.0-alpha.2"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@emotion/react": "^11.9.0",
@@ -53,8 +53,8 @@
53
53
  "moment": "^2.29.4",
54
54
  "moment-hijri": "^2.1.2 || ^3.0.0",
55
55
  "moment-jalaali": "^0.7.4 || ^0.8.0 || ^0.9.0 || ^0.10.0",
56
- "react": "^17.0.0 || ^18.0.0",
57
- "react-dom": "^17.0.0 || ^18.0.0"
56
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
57
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "@emotion/react": {
@@ -1,3 +1,4 @@
1
+ import type { MakeRequired } from '@mui/x-internals/types';
1
2
  import { Validator } from '@mui/x-date-pickers/validation';
2
3
  import { BaseDateValidationProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
3
4
  import { DayRangeValidationProps } from '../internals/models/dateRange';
@@ -7,6 +8,13 @@ import { DateRangeValidationError } from '../models';
7
8
  */
8
9
  export interface ExportedValidateDateRangeProps extends DayRangeValidationProps, BaseDateValidationProps {
9
10
  }
10
- export interface ValidateDateRangeProps extends DayRangeValidationProps, Required<BaseDateValidationProps> {
11
+ /**
12
+ * Validation props as received by the validateDateRange method.
13
+ */
14
+ export interface ValidateDateRangeProps extends MakeRequired<ExportedValidateDateRangeProps, ValidateDateRangePropsToDefault> {
11
15
  }
16
+ /**
17
+ * Name of the props that should be defaulted before being passed to the validateDateRange method.
18
+ */
19
+ export type ValidateDateRangePropsToDefault = keyof BaseDateValidationProps;
12
20
  export declare const validateDateRange: Validator<PickerRangeValue, DateRangeValidationError, ValidateDateRangeProps>;
@@ -9,6 +9,14 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
9
9
  * Validation props used by the Date Range Picker, Date Range Field and Date Range Calendar components.
10
10
  */
11
11
 
12
+ /**
13
+ * Validation props as received by the validateDateRange method.
14
+ */
15
+
16
+ /**
17
+ * Name of the props that should be defaulted before being passed to the validateDateRange method.
18
+ */
19
+
12
20
  export const validateDateRange = ({
13
21
  adapter,
14
22
  value,
@@ -1,13 +1,17 @@
1
1
  import { DateTimeValidationProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
2
2
  import { Validator } from '@mui/x-date-pickers/validation';
3
3
  import { DateTimeRangeValidationError } from '../models';
4
- import { ExportedValidateDateRangeProps, ValidateDateRangeProps } from './validateDateRange';
5
- import { ExportedValidateTimeRangeProps, ValidateTimeRangeProps } from './validateTimeRange';
4
+ import { ExportedValidateDateRangeProps, ValidateDateRangeProps, ValidateDateRangePropsToDefault } from './validateDateRange';
5
+ import { ExportedValidateTimeRangeProps, ValidateTimeRangeProps, ValidateTimeRangePropsToDefault } from './validateTimeRange';
6
6
  /**
7
7
  * Validation props used by the Date Time Range Picker and Date Time Range Field.
8
8
  */
9
9
  export interface ExportedValidateDateTimeRangeProps extends ExportedValidateDateRangeProps, ExportedValidateTimeRangeProps, DateTimeValidationProps {
10
10
  }
11
+ /**
12
+ * Validation props as received by the validateDateTimeRange method.
13
+ */
11
14
  export interface ValidateDateTimeRangeProps extends ValidateDateRangeProps, ValidateTimeRangeProps {
12
15
  }
16
+ export type ValidateDateTimeRangePropsToDefault = ValidateDateRangePropsToDefault | ValidateTimeRangePropsToDefault;
13
17
  export declare const validateDateTimeRange: Validator<PickerRangeValue, DateTimeRangeValidationError, ValidateDateTimeRangeProps>;