@mui/x-date-pickers-pro 6.0.0-alpha.12 → 6.0.0-alpha.13

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 (144) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/DateRangeCalendar/DateRangeCalendar.js +7 -1
  3. package/DateRangeCalendar/DateRangeCalendar.types.d.ts +37 -37
  4. package/DateRangePicker/DateRangePicker.js +0 -5
  5. package/DateRangePicker/DateRangePickerView.d.ts +3 -3
  6. package/DateRangePicker/DateRangePickerView.js +6 -3
  7. package/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  8. package/DateRangePickerDay/DateRangePickerDay.js +72 -1
  9. package/DesktopDateRangePicker/DesktopDateRangePicker.d.ts +5 -0
  10. package/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -5
  11. package/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -8
  12. package/MobileDateRangePicker/MobileDateRangePicker.d.ts +5 -0
  13. package/MobileDateRangePicker/MobileDateRangePicker.js +0 -5
  14. package/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -8
  15. package/MultiInputDateRangeField/MultiInputDateRangeField.js +46 -13
  16. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +2 -2
  17. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
  18. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +3 -3
  19. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
  20. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +2 -2
  21. package/NextDateRangePicker/NextDateRangePicker.js +16 -2
  22. package/NextDateRangePicker/shared.d.ts +9 -2
  23. package/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
  24. package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +3 -2
  25. package/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  26. package/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  27. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +13 -0
  28. package/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
  29. package/dateRangeViewRenderers/index.d.ts +2 -0
  30. package/dateRangeViewRenderers/index.js +1 -0
  31. package/dateRangeViewRenderers/package.json +6 -0
  32. package/index.d.ts +1 -0
  33. package/index.js +5 -2
  34. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
  35. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +2 -4
  36. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +4 -5
  37. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -1
  38. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -4
  39. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +4 -5
  40. package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  41. package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  42. package/internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +2 -0
  43. package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  44. package/internal/hooks/useRangePickerInputProps.d.ts +4 -6
  45. package/internal/hooks/useRangePickerInputProps.js +5 -6
  46. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
  47. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +0 -2
  48. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +2 -2
  49. package/internal/models/dateRange.d.ts +11 -1
  50. package/internal/models/dateTimeRange.d.ts +2 -2
  51. package/internal/models/timeRange.d.ts +2 -1
  52. package/internal/utils/date-fields-utils.d.ts +17 -1
  53. package/internal/utils/releaseInfo.js +1 -1
  54. package/internal/utils/valueManagers.js +15 -21
  55. package/legacy/DateRangeCalendar/DateRangeCalendar.js +7 -1
  56. package/legacy/DateRangePicker/DateRangePicker.js +0 -5
  57. package/legacy/DateRangePicker/DateRangePickerView.js +7 -2
  58. package/legacy/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  59. package/legacy/DateRangePickerDay/DateRangePickerDay.js +72 -1
  60. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -5
  61. package/legacy/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -8
  62. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +0 -5
  63. package/legacy/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -8
  64. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +44 -11
  65. package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +43 -8
  66. package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +43 -8
  67. package/legacy/NextDateRangePicker/NextDateRangePicker.js +16 -2
  68. package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +109 -4
  69. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  70. package/legacy/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  71. package/legacy/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
  72. package/legacy/dateRangeViewRenderers/index.js +1 -0
  73. package/legacy/index.js +5 -2
  74. package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +2 -4
  75. package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -4
  76. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  77. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  78. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  79. package/legacy/internal/hooks/useRangePickerInputProps.js +5 -6
  80. package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +0 -2
  81. package/legacy/internal/utils/releaseInfo.js +1 -1
  82. package/legacy/internal/utils/valueManagers.js +15 -23
  83. package/legacy/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  84. package/modern/DateRangeCalendar/DateRangeCalendar.js +7 -1
  85. package/modern/DateRangePicker/DateRangePicker.js +0 -5
  86. package/modern/DateRangePicker/DateRangePickerView.js +6 -3
  87. package/modern/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  88. package/modern/DateRangePickerDay/DateRangePickerDay.js +72 -1
  89. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -5
  90. package/modern/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -8
  91. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +0 -5
  92. package/modern/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -8
  93. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +46 -13
  94. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
  95. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
  96. package/modern/NextDateRangePicker/NextDateRangePicker.js +16 -2
  97. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
  98. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  99. package/modern/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  100. package/modern/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
  101. package/modern/dateRangeViewRenderers/index.js +1 -0
  102. package/modern/index.js +5 -2
  103. package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +2 -4
  104. package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -4
  105. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  106. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  107. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  108. package/modern/internal/hooks/useRangePickerInputProps.js +5 -6
  109. package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +0 -2
  110. package/modern/internal/utils/releaseInfo.js +1 -1
  111. package/modern/internal/utils/valueManagers.js +15 -21
  112. package/modern/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  113. package/node/DateRangeCalendar/DateRangeCalendar.js +7 -1
  114. package/node/DateRangePicker/DateRangePicker.js +0 -5
  115. package/node/DateRangePicker/DateRangePickerView.js +6 -3
  116. package/node/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  117. package/node/DateRangePickerDay/DateRangePickerDay.js +72 -1
  118. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -5
  119. package/node/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -8
  120. package/node/MobileDateRangePicker/MobileDateRangePicker.js +0 -5
  121. package/node/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -8
  122. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +46 -13
  123. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
  124. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
  125. package/node/NextDateRangePicker/NextDateRangePicker.js +16 -2
  126. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
  127. package/node/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  128. package/node/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  129. package/node/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +4 -4
  130. package/node/dateRangeViewRenderers/index.js +12 -0
  131. package/node/index.js +13 -1
  132. package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +2 -4
  133. package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -4
  134. package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  135. package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  136. package/node/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  137. package/node/internal/hooks/useRangePickerInputProps.js +5 -6
  138. package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +0 -2
  139. package/node/internal/utils/releaseInfo.js +1 -1
  140. package/node/internal/utils/valueManagers.js +14 -20
  141. package/node/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  142. package/package.json +3 -3
  143. package/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  144. package/internal/utils/viewRenderers.d.ts +0 -7
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["components", "componentsProps"],
4
- _excluded2 = ["ref", "onPaste", "inputMode"];
4
+ _excluded2 = ["ref", "onPaste", "inputMode", "readOnly"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import TextField from '@mui/material/TextField';
@@ -34,7 +34,8 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
34
34
  {
35
35
  ref: inputRef,
36
36
  onPaste,
37
- inputMode
37
+ inputMode,
38
+ readOnly
38
39
  } = _useSingleInputDateRa,
39
40
  fieldProps = _objectWithoutPropertiesLoose(_useSingleInputDateRa, _excluded2);
40
41
  return /*#__PURE__*/_jsx(Input, _extends({
@@ -43,7 +44,8 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
43
44
  inputProps: _extends({}, fieldProps.inputProps, {
44
45
  ref: inputRef,
45
46
  onPaste,
46
- inputMode
47
+ inputMode,
48
+ readOnly
47
49
  })
48
50
  }));
49
51
  });
@@ -52,6 +54,19 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
52
54
  // | These PropTypes are generated from the TypeScript type definitions |
53
55
  // | To update them edit the TypeScript types and run "yarn proptypes" |
54
56
  // ----------------------------------------------------------------------
57
+ /**
58
+ * If `true`, the `input` element is focused during the first mount.
59
+ * @default false
60
+ */
61
+ autoFocus: PropTypes.bool,
62
+ className: PropTypes.string,
63
+ /**
64
+ * The color of the component.
65
+ * It supports both default and custom theme colors, which can be added as shown in the
66
+ * [palette customization guide](https://mui.com/material-ui/customization/palette/#adding-new-colors).
67
+ * @default 'primary'
68
+ */
69
+ color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
55
70
  /**
56
71
  * Overrideable components.
57
72
  * @default {}
@@ -66,6 +81,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
66
81
  * The default value. Use when the component is not controlled.
67
82
  */
68
83
  defaultValue: PropTypes.arrayOf(PropTypes.any),
84
+ /**
85
+ * If `true`, the component is disabled.
86
+ * @default false
87
+ */
88
+ disabled: PropTypes.bool,
69
89
  /**
70
90
  * If `true` disable values before the current date for date components, time for time components and both for date time components.
71
91
  * @default false
@@ -76,10 +96,70 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
76
96
  * @default false
77
97
  */
78
98
  disablePast: PropTypes.bool,
99
+ /**
100
+ * If `true`, the component is displayed in focused state.
101
+ */
102
+ focused: PropTypes.bool,
79
103
  /**
80
104
  * Format of the date when rendered in the input(s).
81
105
  */
82
106
  format: PropTypes.string,
107
+ /**
108
+ * Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
109
+ */
110
+ FormHelperTextProps: PropTypes.object,
111
+ /**
112
+ * If `true`, the input will take up the full width of its container.
113
+ * @default false
114
+ */
115
+ fullWidth: PropTypes.bool,
116
+ /**
117
+ * The helper text content.
118
+ */
119
+ helperText: PropTypes.node,
120
+ /**
121
+ * If `true`, the label is hidden.
122
+ * This is used to increase density for a `FilledInput`.
123
+ * Be sure to add `aria-label` to the `input` element.
124
+ * @default false
125
+ */
126
+ hiddenLabel: PropTypes.bool,
127
+ /**
128
+ * The id of the `input` element.
129
+ * Use this prop to make `label` and `helperText` accessible for screen readers.
130
+ */
131
+ id: PropTypes.string,
132
+ /**
133
+ * Props applied to the [`InputLabel`](/material-ui/api/input-label/) element.
134
+ * Pointer events like `onClick` are enabled if and only if `shrink` is `true`.
135
+ */
136
+ InputLabelProps: PropTypes.object,
137
+ /**
138
+ * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
139
+ */
140
+ inputProps: PropTypes.object,
141
+ /**
142
+ * Props applied to the Input element.
143
+ * It will be a [`FilledInput`](/material-ui/api/filled-input/),
144
+ * [`OutlinedInput`](/material-ui/api/outlined-input/) or [`Input`](/material-ui/api/input/)
145
+ * component depending on the `variant` prop value.
146
+ */
147
+ InputProps: PropTypes.object,
148
+ /**
149
+ * Pass a ref to the `input` element.
150
+ */
151
+ inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
152
+ current: PropTypes.any.isRequired
153
+ })]),
154
+ /**
155
+ * The label content.
156
+ */
157
+ label: PropTypes.node,
158
+ /**
159
+ * If `dense` or `normal`, will adjust vertical spacing of this and contained components.
160
+ * @default 'none'
161
+ */
162
+ margin: PropTypes.oneOf(['dense', 'none', 'normal']),
83
163
  /**
84
164
  * Maximal selectable date.
85
165
  */
@@ -88,6 +168,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
88
168
  * Minimal selectable date.
89
169
  */
90
170
  minDate: PropTypes.any,
171
+ /**
172
+ * Name attribute of the `input` element.
173
+ */
174
+ name: PropTypes.string,
175
+ onBlur: PropTypes.func,
91
176
  /**
92
177
  * Callback fired when the value changes.
93
178
  * @template TValue, TError
@@ -102,6 +187,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
102
187
  * @param {TValue} value The value associated to the error.
103
188
  */
104
189
  onError: PropTypes.func,
190
+ onFocus: PropTypes.func,
105
191
  /**
106
192
  * Callback fired when the selected sections change.
107
193
  * @param {FieldSelectedSections} newValue The new selected sections.
@@ -113,6 +199,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
113
199
  * @default false
114
200
  */
115
201
  readOnly: PropTypes.bool,
202
+ /**
203
+ * If `true`, the label is displayed as required and the `input` element is required.
204
+ * @default false
205
+ */
206
+ required: PropTypes.bool,
116
207
  /**
117
208
  * The currently selected sections.
118
209
  * This prop accept four formats:
@@ -122,7 +213,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
122
213
  * 4. If `null` is provided, no section will be selected
123
214
  * If not provided, the selected sections will be handled internally.
124
215
  */
125
- selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']), PropTypes.number, PropTypes.shape({
216
+ selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']), PropTypes.number, PropTypes.shape({
126
217
  endIndex: PropTypes.number.isRequired,
127
218
  startIndex: PropTypes.number.isRequired
128
219
  })]),
@@ -134,10 +225,24 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
134
225
  * @returns {boolean} Returns `true` if the date should be disabled.
135
226
  */
136
227
  shouldDisableDate: PropTypes.func,
228
+ /**
229
+ * The size of the component.
230
+ */
231
+ size: PropTypes.oneOf(['medium', 'small']),
232
+ style: PropTypes.object,
233
+ /**
234
+ * The system prop that allows defining system overrides as well as additional CSS styles.
235
+ */
236
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
137
237
  /**
138
238
  * The selected value.
139
239
  * Used when the component is controlled.
140
240
  */
141
- value: PropTypes.arrayOf(PropTypes.any)
241
+ value: PropTypes.arrayOf(PropTypes.any),
242
+ /**
243
+ * The variant to use.
244
+ * @default 'outlined'
245
+ */
246
+ variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
142
247
  } : void 0;
143
248
  export { SingleInputDateRangeField };
@@ -245,11 +245,6 @@ process.env.NODE_ENV !== "production" ? StaticDateRangePicker.propTypes = {
245
245
  * @returns {void|Promise} -
246
246
  */
247
247
  onMonthChange: PropTypes.func,
248
- /**
249
- * Callback fired on view change.
250
- * @param {DateView} view The new view.
251
- */
252
- onViewChange: PropTypes.func,
253
248
  /**
254
249
  * Props to pass to keyboard adornment button.
255
250
  */
@@ -3,18 +3,19 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { useStaticRangePicker } from '../internal/hooks/useStaticRangePicker';
5
5
  import { useNextDateRangePickerDefaultizedProps } from '../NextDateRangePicker/shared';
6
+ import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
6
7
  import { rangeValueManager } from '../internal/utils/valueManagers';
7
- import { renderDateRangeView } from '../internal/utils/viewRenderers';
8
8
  import { validateDateRange } from '../internal/hooks/validation/useDateRangeValidation';
9
- const VIEW_LOOKUP = {
10
- day: renderDateRangeView
11
- };
12
9
  const StaticNextDateRangePicker = /*#__PURE__*/React.forwardRef(function StaticNextDateRangePicker(inProps, ref) {
13
10
  const defaultizedProps = useNextDateRangePickerDefaultizedProps(inProps, 'MuiStaticNextDateRangePicker');
14
11
  const displayStaticWrapperAs = defaultizedProps.displayStaticWrapperAs ?? 'mobile';
12
+ const viewRenderers = _extends({
13
+ day: renderDateRangeViewCalendar
14
+ }, defaultizedProps.viewRenderers);
15
15
 
16
16
  // Props with the default values specific to the static variant
17
17
  const props = _extends({}, defaultizedProps, {
18
+ viewRenderers,
18
19
  displayStaticWrapperAs,
19
20
  views: ['day'],
20
21
  openTo: 'day',
@@ -26,7 +27,6 @@ const StaticNextDateRangePicker = /*#__PURE__*/React.forwardRef(function StaticN
26
27
  } = useStaticRangePicker({
27
28
  props,
28
29
  valueManager: rangeValueManager,
29
- viewLookup: VIEW_LOOKUP,
30
30
  validator: validateDateRange,
31
31
  ref
32
32
  });
@@ -37,6 +37,12 @@ StaticNextDateRangePicker.propTypes = {
37
37
  // | These PropTypes are generated from the TypeScript type definitions |
38
38
  // | To update them edit the TypeScript types and run "yarn proptypes" |
39
39
  // ----------------------------------------------------------------------
40
+ /**
41
+ * If `true`, the main element is focused during the first mount.
42
+ * This main element is:
43
+ * - the element chosen by the visible view if any (i.e: the selected day on the `day` view).
44
+ * - the `input` element if there is a field rendered.
45
+ */
40
46
  autoFocus: PropTypes.bool,
41
47
  /**
42
48
  * The number of calendars to render.
@@ -204,6 +210,14 @@ StaticNextDateRangePicker.propTypes = {
204
210
  * The selected value.
205
211
  * Used when the component is controlled.
206
212
  */
207
- value: PropTypes.arrayOf(PropTypes.any)
213
+ value: PropTypes.arrayOf(PropTypes.any),
214
+ /**
215
+ * Define custom view renderers for each section.
216
+ * If `null`, the section will only have field editing.
217
+ * If `undefined`, internally defined view will be the used.
218
+ */
219
+ viewRenderers: PropTypes.shape({
220
+ day: PropTypes.func
221
+ })
208
222
  };
209
223
  export { StaticNextDateRangePicker };
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
- import { DateRangeCalendar } from '../../DateRangeCalendar';
3
-
2
+ import { DateRangeCalendar } from '../DateRangeCalendar';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  /**
5
5
  * We don't pass all the props down to `DateRangeCalendar`,
6
6
  * because otherwise some unwanted props would be passed to the HTML element.
7
7
  */
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- export const renderDateRangeView = ({
8
+ export const renderDateRangeViewCalendar = ({
10
9
  value,
11
10
  defaultValue,
12
11
  onChange,
@@ -0,0 +1 @@
1
+ export { renderDateRangeViewCalendar } from './dateRangeViewRenderers';
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v6.0.0-alpha.12
1
+ /** @license MUI v6.0.0-alpha.13
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -23,4 +23,7 @@ export * from './DateRangeCalendar';
23
23
  export * from './NextDateRangePicker';
24
24
  export * from './DesktopNextDateRangePicker';
25
25
  export * from './MobileNextDateRangePicker';
26
- export * from './StaticNextDateRangePicker';
26
+ export * from './StaticNextDateRangePicker';
27
+
28
+ // View renderers
29
+ export * from './dateRangeViewRenderers';
@@ -12,7 +12,6 @@ const releaseInfo = getReleaseInfo();
12
12
  export const useDesktopRangePicker = ({
13
13
  props,
14
14
  valueManager,
15
- viewLookup,
16
15
  validator
17
16
  }) => {
18
17
  useLicenseVerifier('x-date-pickers-pro', releaseInfo);
@@ -41,7 +40,6 @@ export const useDesktopRangePicker = ({
41
40
  props,
42
41
  valueManager,
43
42
  wrapperVariant: 'desktop',
44
- viewLookup,
45
43
  validator,
46
44
  autoFocusView: true,
47
45
  additionalViewProps: {
@@ -58,7 +56,7 @@ export const useDesktopRangePicker = ({
58
56
  });
59
57
  };
60
58
  const fieldSlotsProps = useRangePickerInputProps({
61
- wrapperVariant: 'mobile',
59
+ wrapperVariant: 'desktop',
62
60
  open,
63
61
  actions,
64
62
  readOnly,
@@ -94,7 +92,7 @@ export const useDesktopRangePicker = ({
94
92
  const inputPropsPassedByField = resolveComponentProps(fieldProps.componentsProps?.input, ownerState);
95
93
  const inputPropsPassedByPicker = ownerState.position === 'start' ? fieldSlotsProps.startInput : fieldSlotsProps.endInput;
96
94
  return _extends({}, externalInputProps, inputPropsPassedByField, inputPropsPassedByPicker, {
97
- inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps, inputPropsPassedByPicker?.inputProps)
95
+ inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps)
98
96
  });
99
97
  },
100
98
  root: ownerState => {
@@ -12,7 +12,6 @@ const releaseInfo = getReleaseInfo();
12
12
  export const useMobileRangePicker = ({
13
13
  props,
14
14
  valueManager,
15
- viewLookup,
16
15
  validator
17
16
  }) => {
18
17
  useLicenseVerifier('x-date-pickers-pro', releaseInfo);
@@ -38,7 +37,6 @@ export const useMobileRangePicker = ({
38
37
  props,
39
38
  valueManager,
40
39
  wrapperVariant: 'mobile',
41
- viewLookup,
42
40
  validator,
43
41
  autoFocusView: true,
44
42
  additionalViewProps: {
@@ -62,7 +60,7 @@ export const useMobileRangePicker = ({
62
60
  elementType: Field,
63
61
  externalSlotProps: componentsProps.field,
64
62
  additionalProps: _extends({}, pickerFieldProps, {
65
- readOnly,
63
+ readOnly: readOnly ?? true,
66
64
  disabled,
67
65
  className,
68
66
  format,
@@ -79,7 +77,7 @@ export const useMobileRangePicker = ({
79
77
  const inputPropsPassedByField = resolveComponentProps(fieldProps.componentsProps?.input, ownerState);
80
78
  const inputPropsPassedByPicker = ownerState.position === 'start' ? fieldSlotsProps.startInput : fieldSlotsProps.endInput;
81
79
  return _extends({}, externalInputProps, inputPropsPassedByField, inputPropsPassedByPicker, {
82
- inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps, inputPropsPassedByPicker?.inputProps)
80
+ inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps)
83
81
  });
84
82
  },
85
83
  root: ownerState => {
@@ -19,7 +19,9 @@ export const useMultiInputDateRangeField = ({
19
19
  value: valueProp,
20
20
  defaultValue,
21
21
  format,
22
- onChange
22
+ onChange,
23
+ disabled,
24
+ readOnly
23
25
  } = sharedProps;
24
26
  const firstDefaultValue = React.useRef(defaultValue);
25
27
 
@@ -46,6 +48,8 @@ export const useMultiInputDateRangeField = ({
46
48
  const handleStartDateChange = useEventCallback(buildChangeHandler(0));
47
49
  const handleEndDateChange = useEventCallback(buildChangeHandler(1));
48
50
  const startInputProps = _extends({}, inStartInputProps, {
51
+ disabled,
52
+ readOnly,
49
53
  format,
50
54
  value: valueProp === undefined ? undefined : valueProp[0],
51
55
  defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
@@ -53,6 +57,8 @@ export const useMultiInputDateRangeField = ({
53
57
  });
54
58
  const endInputProps = _extends({}, inEndInputProps, {
55
59
  format,
60
+ disabled,
61
+ readOnly,
56
62
  value: valueProp === undefined ? undefined : valueProp[1],
57
63
  defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
58
64
  onChange: handleEndDateChange
@@ -34,7 +34,9 @@ export const useMultiInputDateTimeRangeField = ({
34
34
  value: valueProp,
35
35
  defaultValue,
36
36
  format,
37
- onChange
37
+ onChange,
38
+ disabled,
39
+ readOnly
38
40
  } = sharedProps;
39
41
  const firstDefaultValue = React.useRef(defaultValue);
40
42
 
@@ -62,12 +64,16 @@ export const useMultiInputDateTimeRangeField = ({
62
64
  const handleEndDateChange = useEventCallback(buildChangeHandler(1));
63
65
  const startInputProps = _extends({}, inStartInputProps, {
64
66
  format,
67
+ disabled,
68
+ readOnly,
65
69
  value: valueProp === undefined ? undefined : valueProp[0],
66
70
  defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
67
71
  onChange: handleStartDateChange
68
72
  });
69
73
  const endInputProps = _extends({}, inEndInputProps, {
70
74
  format,
75
+ disabled,
76
+ readOnly,
71
77
  value: valueProp === undefined ? undefined : valueProp[1],
72
78
  defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
73
79
  onChange: handleEndDateChange
@@ -30,7 +30,9 @@ export const useMultiInputTimeRangeField = ({
30
30
  value: valueProp,
31
31
  defaultValue,
32
32
  format,
33
- onChange
33
+ onChange,
34
+ disabled,
35
+ readOnly
34
36
  } = sharedProps;
35
37
  const firstDefaultValue = React.useRef(defaultValue);
36
38
 
@@ -58,12 +60,16 @@ export const useMultiInputTimeRangeField = ({
58
60
  const handleEndDateChange = useEventCallback(buildChangeHandler(1));
59
61
  const startInputProps = _extends({}, inStartInputProps, {
60
62
  format,
63
+ disabled,
64
+ readOnly,
61
65
  value: valueProp === undefined ? undefined : valueProp[0],
62
66
  defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
63
67
  onChange: handleStartDateChange
64
68
  });
65
69
  const endInputProps = _extends({}, inEndInputProps, {
66
70
  format,
71
+ disabled,
72
+ readOnly,
67
73
  value: valueProp === undefined ? undefined : valueProp[1],
68
74
  defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
69
75
  onChange: handleEndDateChange
@@ -50,6 +50,7 @@ export const useRangePickerInputProps = ({
50
50
  onRangePositionChange('end');
51
51
  }
52
52
  };
53
+ const readOnlyInput = readOnly ?? wrapperVariant === 'mobile';
53
54
  const startInputProps = _extends({
54
55
  inputRef: startRef,
55
56
  label: inLocaleText?.start ?? localeText.start,
@@ -59,9 +60,8 @@ export const useRangePickerInputProps = ({
59
60
  }, !readOnly && !disabled && {
60
61
  onClick: openRangeStartSelection
61
62
  }, {
62
- inputProps: {
63
- readOnly: wrapperVariant === 'mobile'
64
- }
63
+ readOnly: readOnlyInput,
64
+ disabled
65
65
  });
66
66
  const endInputProps = _extends({
67
67
  inputRef: endRef,
@@ -72,9 +72,8 @@ export const useRangePickerInputProps = ({
72
72
  }, !readOnly && !disabled && {
73
73
  onClick: openRangeEndSelection
74
74
  }, {
75
- inputProps: {
76
- readOnly: wrapperVariant === 'mobile'
77
- }
75
+ readOnly: readOnlyInput,
76
+ disabled
78
77
  });
79
78
  const rootProps = {
80
79
  onBlur
@@ -19,7 +19,6 @@ const PickerStaticViewLayout = styled(PickersViewLayout)(({
19
19
  export const useStaticRangePicker = ({
20
20
  props,
21
21
  valueManager,
22
- viewLookup,
23
22
  validator,
24
23
  ref
25
24
  }) => {
@@ -36,7 +35,6 @@ export const useStaticRangePicker = ({
36
35
  renderCurrentView
37
36
  } = usePicker({
38
37
  props,
39
- viewLookup,
40
38
  valueManager,
41
39
  validator,
42
40
  autoFocusView: autoFocus ?? false,
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY3MTE0NTIwMDAwMA==";
3
+ const releaseInfo = "MTY3MTgzMjgwMDAwMA==";
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
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections, getSectionOrder } from '@mui/x-date-pickers/internals';
2
+ import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections, getSectionOrder } from '@mui/x-date-pickers/internals';
3
3
  import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
4
4
  export const rangeValueManager = {
5
5
  emptyValue: [null, null],
@@ -29,35 +29,29 @@ export const rangeFieldValueManager = {
29
29
  startDate: null,
30
30
  endDate: null
31
31
  } : splitDateRangeSections(prevSections);
32
- const getSections = (newDate, prevDateSections) => {
32
+ const getSections = (newDate, prevDateSections, position) => {
33
33
  const shouldReUsePrevDateSections = !utils.isValid(newDate) && !!prevDateSections;
34
34
  if (shouldReUsePrevDateSections) {
35
35
  return prevDateSections;
36
36
  }
37
- return splitFormatIntoSections(utils, localeText, format, newDate);
38
- };
39
- const rawSectionsOfStartDate = getSections(start, prevDateRangeSections.startDate);
40
- const rawSectionsOfEndDate = getSections(end, prevDateRangeSections.endDate);
41
- const sectionsOfStartDate = rawSectionsOfStartDate.map((section, sectionIndex) => {
42
- if (sectionIndex === rawSectionsOfStartDate.length - 1) {
37
+ const sections = splitFormatIntoSections(utils, localeText, format, newDate);
38
+ return sections.map((section, sectionIndex) => {
39
+ if (sectionIndex === sections.length - 1 && position === 'start') {
40
+ return _extends({}, section, {
41
+ dateName: position,
42
+ endSeparator: `${section.endSeparator}\u2069 \u2066`
43
+ });
44
+ }
43
45
  return _extends({}, section, {
44
- dateName: 'start',
45
- separator: `\u2069 – \u2066`,
46
- parsingSeparator: ' – '
46
+ dateName: position
47
47
  });
48
- }
49
- return _extends({}, section, {
50
- dateName: 'start'
51
48
  });
52
- });
53
- const sectionsOfEndDate = rawSectionsOfEndDate.map(section => _extends({}, section, {
54
- dateName: 'end'
55
- }));
56
- return addPositionPropertiesToSections([...sectionsOfStartDate, ...sectionsOfEndDate]);
49
+ };
50
+ return addPositionPropertiesToSections([...getSections(start, prevDateRangeSections.startDate, 'start'), ...getSections(end, prevDateRangeSections.endDate, 'end')]);
57
51
  },
58
52
  getValueStrFromSections: sections => {
59
53
  const dateRangeSections = splitDateRangeSections(sections);
60
- return createDateStrFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], true);
54
+ return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate]);
61
55
  },
62
56
  getActiveDateSections: (sections, activeSection) => {
63
57
  const index = activeSection.dateName === 'start' ? 0 : 1;
@@ -90,7 +84,7 @@ export const rangeFieldValueManager = {
90
84
  getSectionOrder: (utils, localeText, format, isRTL) => {
91
85
  const splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
92
86
  return getSectionOrder([...splitedFormat.slice(0, splitedFormat.length - 1), _extends({}, splitedFormat[splitedFormat.length - 1], {
93
- separator: ' – '
87
+ endSeparator: ' – '
94
88
  }), ...splitedFormat], isRTL);
95
89
  }
96
90
  };
@@ -26,7 +26,7 @@ export const testTextFieldRangeValidation = (ElementToTest, getOptions) => {
26
26
  withDate,
27
27
  withTime
28
28
  } = getOptions();
29
- if (!['legacy-picker', 'picker'].includes(componentFamily)) {
29
+ if (!['legacy-picker', 'new-picker'].includes(componentFamily)) {
30
30
  return;
31
31
  }
32
32
  describe('text field:', () => {
@@ -387,7 +387,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
387
387
  className: classes.monthContainer,
388
388
  children: [calendars === 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.PickersCalendarHeader, {
389
389
  views: ['day'],
390
- openView: 'day',
390
+ view: 'day',
391
391
  currentMonth: calendarState.currentMonth,
392
392
  onMonthChange: (newMonth, direction) => handleChangeMonth({
393
393
  newMonth,
@@ -443,6 +443,12 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
443
443
  // | These PropTypes are generated from the TypeScript type definitions |
444
444
  // | To update them edit the TypeScript types and run "yarn proptypes" |
445
445
  // ----------------------------------------------------------------------
446
+ /**
447
+ * If `true`, the main element is focused during the first mount.
448
+ * This main element is:
449
+ * - the element chosen by the visible view if any (i.e: the selected day on the `day` view).
450
+ * - the `input` element if there is a field rendered.
451
+ */
446
452
  autoFocus: _propTypes.default.bool,
447
453
  /**
448
454
  * The number of calendars to render.
@@ -244,11 +244,6 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
244
244
  * Use in controlled mode (see open).
245
245
  */
246
246
  onOpen: _propTypes.default.func,
247
- /**
248
- * Callback fired on view change.
249
- * @param {DateView} view The new view.
250
- */
251
- onViewChange: _propTypes.default.func,
252
247
  /**
253
248
  * Control the popup or dialog open state.
254
249
  */
@@ -18,7 +18,7 @@ var _DateRangePickerInput = require("./DateRangePickerInput");
18
18
  var _DateRangePickerViewDesktop = require("./DateRangePickerViewDesktop");
19
19
  var _releaseInfo = require("../internal/utils/releaseInfo");
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
- const _excluded = ["calendars", "className", "value", "DateInputProps", "defaultCalendarMonth", "disableAutoMonthSwitching", "disableFuture", "disableHighlightToday", "disablePast", "isMobileKeyboardViewOpen", "maxDate", "minDate", "onDateChange", "onMonthChange", "open", "reduceAnimations", "rangePosition", "onRangePositionChange", "shouldDisableDate", "showToolbar", "toggleMobileKeyboardView", "components", "componentsProps"];
21
+ const _excluded = ["calendars", "className", "value", "DateInputProps", "defaultCalendarMonth", "disableAutoMonthSwitching", "disableFuture", "disableHighlightToday", "disablePast", "isMobileKeyboardViewOpen", "maxDate", "minDate", "onDateChange", "onMonthChange", "open", "reduceAnimations", "rangePosition", "onRangePositionChange", "shouldDisableDate", "showToolbar", "toggleMobileKeyboardView", "components", "componentsProps", "onFocusedViewChange"];
22
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
23
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
24
  const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
@@ -48,7 +48,8 @@ function DateRangePickerViewRaw(props) {
48
48
  showToolbar,
49
49
  toggleMobileKeyboardView,
50
50
  components,
51
- componentsProps
51
+ componentsProps,
52
+ onFocusedViewChange
52
53
  } = props,
53
54
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
54
55
  const utils = (0, _internals.useUtils)();
@@ -130,7 +131,9 @@ function DateRangePickerViewRaw(props) {
130
131
  components,
131
132
  componentsProps,
132
133
  shouldDisableDate: wrappedShouldDisableDate
133
- }, calendarState, other);
134
+ }, calendarState, {
135
+ onFocusedViewChange: onFocusedViewChange ? newHasFocus => onFocusedViewChange('day', newHasFocus) : undefined
136
+ }, other);
134
137
  switch (wrapperVariant) {
135
138
  case 'desktop':
136
139
  {