@mui/x-date-pickers-pro 8.0.0-alpha.1 → 8.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +330 -7
  2. package/DateRangePicker/DateRangePicker.types.d.ts +2 -2
  3. package/DateRangePicker/shared.d.ts +3 -2
  4. package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +2 -2
  5. package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  6. package/DateTimeRangePicker/shared.d.ts +4 -3
  7. package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  8. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +12 -10
  9. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +11 -9
  11. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  12. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +11 -9
  13. package/README.md +7 -4
  14. package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  15. package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -10
  16. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  17. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +11 -10
  18. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  19. package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +10 -9
  20. package/index.js +1 -1
  21. package/internals/hooks/models/useRangePicker.d.ts +1 -2
  22. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  23. package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +13 -12
  24. package/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  25. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  26. package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +6 -7
  27. package/internals/hooks/useRangePosition.d.ts +3 -2
  28. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
  29. package/internals/models/dateTimeRange.d.ts +2 -2
  30. package/internals/models/fields.d.ts +6 -6
  31. package/internals/models/timeRange.d.ts +2 -2
  32. package/internals/utils/date-fields-utils.d.ts +6 -6
  33. package/internals/utils/releaseInfo.js +1 -1
  34. package/internals/utils/valueManagers.d.ts +4 -3
  35. package/models/dateRange.d.ts +3 -3
  36. package/models/fields.d.ts +6 -9
  37. package/models/index.d.ts +1 -0
  38. package/models/index.js +2 -1
  39. package/models/range.d.ts +0 -1
  40. package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  41. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  42. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  43. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  44. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  45. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  46. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  47. package/modern/index.js +1 -1
  48. package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  49. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  50. package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  51. package/modern/internals/utils/releaseInfo.js +1 -1
  52. package/modern/models/index.js +2 -1
  53. package/modern/validation/validateDateRange.js +8 -0
  54. package/modern/validation/validateDateTimeRange.js +4 -0
  55. package/modern/validation/validateTimeRange.js +8 -0
  56. package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -6
  57. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -11
  58. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +9 -11
  59. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -11
  60. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
  61. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
  62. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
  63. package/node/index.js +1 -1
  64. package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  65. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  66. package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  67. package/node/internals/utils/releaseInfo.js +1 -1
  68. package/node/validation/validateDateRange.js +8 -0
  69. package/node/validation/validateDateTimeRange.js +4 -0
  70. package/node/validation/validateTimeRange.js +8 -0
  71. package/package.json +4 -4
  72. package/validation/validateDateRange.d.ts +9 -1
  73. package/validation/validateDateRange.js +8 -0
  74. package/validation/validateDateTimeRange.d.ts +6 -2
  75. package/validation/validateDateTimeRange.js +4 -0
  76. package/validation/validateTimeRange.d.ts +9 -1
  77. package/validation/validateTimeRange.js +8 -0
@@ -43,12 +43,21 @@ export const useDesktopRangePicker = _ref => {
43
43
  const popperRef = React.useRef(null);
44
44
  const startFieldRef = React.useRef(null);
45
45
  const endFieldRef = React.useRef(null);
46
+ const singleInputFieldRef = React.useRef(null);
46
47
  const initialView = React.useRef(props.openTo ?? null);
47
48
  const fieldType = slots.field.fieldType ?? 'multi-input';
48
49
  const {
49
50
  rangePosition,
50
51
  onRangePositionChange
51
- } = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
52
+ } = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
53
+ let fieldRef;
54
+ if (fieldType === 'single-input') {
55
+ fieldRef = singleInputFieldRef;
56
+ } else if (rangePosition === 'start') {
57
+ fieldRef = startFieldRef;
58
+ } else {
59
+ fieldRef = endFieldRef;
60
+ }
52
61
  const {
53
62
  open,
54
63
  actions,
@@ -62,7 +71,7 @@ export const useDesktopRangePicker = _ref => {
62
71
  props,
63
72
  variant: 'desktop',
64
73
  autoFocusView: false,
65
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
74
+ fieldRef,
66
75
  localeText,
67
76
  additionalViewProps: {
68
77
  rangePosition,
@@ -130,6 +139,7 @@ export const useDesktopRangePicker = _ref => {
130
139
  anchorRef,
131
140
  startFieldRef,
132
141
  endFieldRef,
142
+ singleInputFieldRef,
133
143
  currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
134
144
  initialView: initialView.current ?? undefined,
135
145
  onViewChange: layoutProps.onViewChange
@@ -156,36 +156,35 @@ const useSingleInputFieldSlotProps = ({
156
156
  onBlur,
157
157
  rangePosition,
158
158
  onRangePositionChange,
159
- startFieldRef,
160
- endFieldRef,
159
+ singleInputFieldRef,
161
160
  pickerSlots,
162
161
  pickerSlotProps,
163
162
  fieldProps,
164
163
  anchorRef,
165
164
  currentView
166
165
  }) => {
167
- const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, startFieldRef, endFieldRef);
166
+ const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
168
167
  React.useEffect(() => {
169
- if (!open || !startFieldRef.current || variant === 'mobile') {
168
+ if (!open || !singleInputFieldRef.current || variant === 'mobile') {
170
169
  return;
171
170
  }
172
- if (startFieldRef.current.isFieldFocused()) {
171
+ if (singleInputFieldRef.current.isFieldFocused()) {
173
172
  return;
174
173
  }
175
174
 
176
175
  // bring back focus to the field with the current view section selected
177
176
  if (currentView) {
178
- const sections = startFieldRef.current.getSections().map(section => section.type);
177
+ const sections = singleInputFieldRef.current.getSections().map(section => section.type);
179
178
  const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
180
- startFieldRef.current?.focusField(newSelectedSection);
179
+ singleInputFieldRef.current?.focusField(newSelectedSection);
181
180
  }
182
- }, [rangePosition, open, currentView, startFieldRef, variant]);
181
+ }, [rangePosition, open, currentView, singleInputFieldRef, variant]);
183
182
  const updateRangePosition = () => {
184
- if (!startFieldRef.current?.isFieldFocused()) {
183
+ if (!singleInputFieldRef.current?.isFieldFocused()) {
185
184
  return;
186
185
  }
187
- const sections = startFieldRef.current.getSections();
188
- const activeSectionIndex = startFieldRef.current?.getActiveSectionIndex();
186
+ const sections = singleInputFieldRef.current.getSections();
187
+ const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
189
188
  const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
190
189
  if (domRangePosition != null && domRangePosition !== rangePosition) {
191
190
  onRangePositionChange(domRangePosition);
@@ -40,13 +40,22 @@ export const useMobileRangePicker = _ref => {
40
40
  } = props;
41
41
  const startFieldRef = React.useRef(null);
42
42
  const endFieldRef = React.useRef(null);
43
+ const singleInputFieldRef = React.useRef(null);
43
44
  const fieldType = slots.field.fieldType ?? 'multi-input';
44
45
  const {
45
46
  rangePosition,
46
47
  onRangePositionChange
47
- } = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
48
+ } = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
48
49
  const labelId = useId();
49
50
  const contextTranslations = usePickerTranslations();
51
+ let fieldRef;
52
+ if (fieldType === 'single-input') {
53
+ fieldRef = singleInputFieldRef;
54
+ } else if (rangePosition === 'start') {
55
+ fieldRef = startFieldRef;
56
+ } else {
57
+ fieldRef = endFieldRef;
58
+ }
50
59
  const {
51
60
  open,
52
61
  actions,
@@ -59,7 +68,7 @@ export const useMobileRangePicker = _ref => {
59
68
  props,
60
69
  variant: 'mobile',
61
70
  autoFocusView: true,
62
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
71
+ fieldRef,
63
72
  localeText,
64
73
  additionalViewProps: {
65
74
  rangePosition,
@@ -110,7 +119,8 @@ export const useMobileRangePicker = _ref => {
110
119
  pickerSlotProps: innerSlotProps,
111
120
  fieldProps,
112
121
  startFieldRef,
113
- endFieldRef
122
+ endFieldRef,
123
+ singleInputFieldRef
114
124
  });
115
125
  const slotPropsForLayout = _extends({}, innerSlotProps, {
116
126
  tabs: _extends({}, innerSlotProps?.tabs, {
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTczMjIzMDAwMDAwMA==";
3
+ const releaseInfo = "MTczMzM1MzIwMDAwMA==";
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
@@ -2,4 +2,5 @@ export * from "./dateRange.js";
2
2
  export * from "./fields.js";
3
3
  export * from "./range.js";
4
4
  export * from "./validation.js";
5
- export * from "./multiInputRangeFieldClasses.js";
5
+ export * from "./multiInputRangeFieldClasses.js";
6
+ export {};
@@ -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,
@@ -9,6 +9,10 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
9
9
  * Validation props used by the Date Time Range Picker and Date Time Range Field.
10
10
  */
11
11
 
12
+ /**
13
+ * Validation props as received by the validateDateTimeRange method.
14
+ */
15
+
12
16
  export const validateDateTimeRange = ({
13
17
  adapter,
14
18
  value,
@@ -6,6 +6,14 @@ import { rangeValueManager } from "../internals/utils/valueManagers.js";
6
6
  * Validation props used by the Time Range Picker and Time Range Field.
7
7
  */
8
8
 
9
+ /**
10
+ * Validation props as received by the validateTimeRange method.
11
+ */
12
+
13
+ /**
14
+ * Name of the props that should be defaulted before being passed to the validateTimeRange method.
15
+ */
16
+
9
17
  export const validateTimeRange = ({
10
18
  adapter,
11
19
  value,
@@ -32,10 +32,7 @@ const tabToView = tab => {
32
32
  }
33
33
  return 'hours';
34
34
  };
35
- const useUtilityClasses = ownerState => {
36
- const {
37
- classes
38
- } = ownerState;
35
+ const useUtilityClasses = classes => {
39
36
  const slots = {
40
37
  root: ['root'],
41
38
  tabButton: ['tabButton'],
@@ -86,10 +83,14 @@ const DateTimeRangePickerTabs = exports.DateTimeRangePickerTabs = function DateT
86
83
  rangePosition,
87
84
  onRangePositionChange,
88
85
  className,
86
+ classes: classesProp,
89
87
  sx
90
88
  } = props;
91
89
  const translations = (0, _hooks.usePickerTranslations)();
92
- const classes = useUtilityClasses(props);
90
+ const {
91
+ ownerState
92
+ } = (0, _internals.usePickerPrivateContext)();
93
+ const classes = useUtilityClasses(classesProp);
93
94
  const value = React.useMemo(() => viewToTab(view, rangePosition), [view, rangePosition]);
94
95
  const isPreviousHidden = value === 'start-date';
95
96
  const isNextHidden = value === 'end-time';
@@ -128,7 +129,7 @@ const DateTimeRangePickerTabs = exports.DateTimeRangePickerTabs = function DateT
128
129
  return null;
129
130
  }
130
131
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateTimeRangePickerTabsRoot, {
131
- ownerState: props,
132
+ ownerState: ownerState,
132
133
  className: (0, _clsx.default)(classes.root, className),
133
134
  sx: sx,
134
135
  children: [!isPreviousHidden ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
@@ -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 _useMultiInputDateRangeField = require("../internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField");
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 multiInputDateRangeFieldClasses = exports.multiInputDateRangeFieldClasses = (0, _utils.unstable_generateUtilityClasses)('MuiMultiInputDateRangeField', ['root', 'separator']);
28
28
  const getMultiInputDateRangeFieldUtilityClass = slot => (0, _utils.unstable_generateUtilityClass)('MuiMultiInputDateRangeField', slot);
29
29
  exports.getMultiInputDateRangeFieldUtilityClass = getMultiInputDateRangeFieldUtilityClass;
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 MultiInputDateRangeField = exports.MultiInputDateRangeField = /*#__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)(internalProps);
83
+ const classes = useUtilityClasses(classesProp);
86
84
  const Root = slots?.root ?? MultiInputDateRangeFieldRoot;
87
85
  const rootProps = (0, _useSlotProps.default)({
88
86
  elementType: Root,
@@ -266,10 +264,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
266
264
  */
267
265
  shouldDisableDate: _propTypes.default.func,
268
266
  /**
269
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
270
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
267
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
268
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
271
269
  *
272
- * 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`.
270
+ * 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`.
273
271
  *
274
272
  * 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.
275
273
  * 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 _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.1
2
+ * @mui/x-date-pickers-pro v8.0.0-alpha.3
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,
@@ -70,7 +79,7 @@ const useDesktopRangePicker = _ref => {
70
79
  props,
71
80
  variant: 'desktop',
72
81
  autoFocusView: false,
73
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
82
+ fieldRef,
74
83
  localeText,
75
84
  additionalViewProps: {
76
85
  rangePosition,
@@ -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
@@ -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 || variant === 'mobile') {
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, variant]);
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);
@@ -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,
@@ -67,7 +76,7 @@ const useMobileRangePicker = _ref => {
67
76
  props,
68
77
  variant: 'mobile',
69
78
  autoFocusView: true,
70
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
79
+ fieldRef,
71
80
  localeText,
72
81
  additionalViewProps: {
73
82
  rangePosition,
@@ -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, {
@@ -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 = "MTczMjIzMDAwMDAwMA==";
9
+ const releaseInfo = "MTczMzM1MzIwMDAwMA==";
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,