@mui/x-date-pickers-pro 6.0.0-alpha.11 → 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 (147) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/DateRangeCalendar/DateRangeCalendar.js +30 -3
  3. package/DateRangeCalendar/DateRangeCalendar.types.d.ts +37 -37
  4. package/DateRangePicker/DateRangePicker.js +0 -6
  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 -6
  11. package/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
  12. package/MobileDateRangePicker/MobileDateRangePicker.d.ts +5 -0
  13. package/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
  14. package/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
  15. package/MultiInputDateRangeField/MultiInputDateRangeField.js +51 -11
  16. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +4 -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 +2 -1
  33. package/index.js +5 -2
  34. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
  35. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -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 +4 -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 +7 -7
  45. package/internal/hooks/useRangePickerInputProps.js +12 -11
  46. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
  47. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
  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/fields.d.ts +6 -1
  52. package/internal/models/range.d.ts +0 -4
  53. package/internal/models/timeRange.d.ts +2 -1
  54. package/internal/utils/date-fields-utils.d.ts +21 -5
  55. package/internal/utils/releaseInfo.js +1 -1
  56. package/internal/utils/valueManagers.d.ts +3 -2
  57. package/internal/utils/valueManagers.js +21 -22
  58. package/legacy/DateRangeCalendar/DateRangeCalendar.js +36 -3
  59. package/legacy/DateRangePicker/DateRangePicker.js +0 -6
  60. package/legacy/DateRangePicker/DateRangePickerView.js +7 -2
  61. package/legacy/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  62. package/legacy/DateRangePickerDay/DateRangePickerDay.js +72 -1
  63. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
  64. package/legacy/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
  65. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
  66. package/legacy/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
  67. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +48 -8
  68. package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +43 -8
  69. package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +43 -8
  70. package/legacy/NextDateRangePicker/NextDateRangePicker.js +16 -2
  71. package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +109 -4
  72. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  73. package/legacy/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  74. package/legacy/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
  75. package/legacy/dateRangeViewRenderers/index.js +1 -0
  76. package/legacy/index.js +5 -2
  77. package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
  78. package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
  79. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  80. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  81. package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  82. package/legacy/internal/hooks/useRangePickerInputProps.js +12 -11
  83. package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
  84. package/legacy/internal/utils/releaseInfo.js +1 -1
  85. package/legacy/internal/utils/valueManagers.js +20 -23
  86. package/legacy/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  87. package/modern/DateRangeCalendar/DateRangeCalendar.js +29 -3
  88. package/modern/DateRangePicker/DateRangePicker.js +0 -6
  89. package/modern/DateRangePicker/DateRangePickerView.js +6 -3
  90. package/modern/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  91. package/modern/DateRangePickerDay/DateRangePickerDay.js +72 -1
  92. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
  93. package/modern/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
  94. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
  95. package/modern/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
  96. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +51 -11
  97. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
  98. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
  99. package/modern/NextDateRangePicker/NextDateRangePicker.js +16 -2
  100. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
  101. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  102. package/modern/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  103. package/modern/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
  104. package/modern/dateRangeViewRenderers/index.js +1 -0
  105. package/modern/index.js +5 -2
  106. package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
  107. package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
  108. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  109. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  110. package/modern/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  111. package/modern/internal/hooks/useRangePickerInputProps.js +11 -11
  112. package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
  113. package/modern/internal/utils/releaseInfo.js +1 -1
  114. package/modern/internal/utils/valueManagers.js +21 -22
  115. package/modern/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  116. package/node/DateRangeCalendar/DateRangeCalendar.js +28 -2
  117. package/node/DateRangePicker/DateRangePicker.js +0 -6
  118. package/node/DateRangePicker/DateRangePickerView.js +6 -3
  119. package/node/DateRangePicker/DateRangePickerViewMobile.js +1 -1
  120. package/node/DateRangePickerDay/DateRangePickerDay.js +72 -1
  121. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
  122. package/node/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
  123. package/node/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
  124. package/node/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
  125. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +51 -11
  126. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
  127. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
  128. package/node/NextDateRangePicker/NextDateRangePicker.js +16 -2
  129. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
  130. package/node/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
  131. package/node/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
  132. package/node/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +4 -4
  133. package/node/dateRangeViewRenderers/index.js +12 -0
  134. package/node/index.js +13 -1
  135. package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
  136. package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
  137. package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
  138. package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
  139. package/node/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
  140. package/node/internal/hooks/useRangePickerInputProps.js +11 -11
  141. package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
  142. package/node/internal/utils/releaseInfo.js +1 -1
  143. package/node/internal/utils/valueManagers.js +20 -21
  144. package/node/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  145. package/package.json +4 -4
  146. package/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
  147. 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.11
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);
@@ -23,6 +22,7 @@ export const useDesktopRangePicker = ({
23
22
  format,
24
23
  readOnly,
25
24
  disabled,
25
+ autoFocus,
26
26
  disableOpenPicker,
27
27
  localeText
28
28
  } = props;
@@ -40,8 +40,8 @@ export const useDesktopRangePicker = ({
40
40
  props,
41
41
  valueManager,
42
42
  wrapperVariant: 'desktop',
43
- viewLookup,
44
43
  validator,
44
+ autoFocusView: true,
45
45
  additionalViewProps: {
46
46
  rangePosition,
47
47
  onRangePositionChange: setRangePosition
@@ -56,12 +56,13 @@ export const useDesktopRangePicker = ({
56
56
  });
57
57
  };
58
58
  const fieldSlotsProps = useRangePickerInputProps({
59
- wrapperVariant: 'mobile',
59
+ wrapperVariant: 'desktop',
60
60
  open,
61
61
  actions,
62
62
  readOnly,
63
63
  disabled,
64
64
  disableOpenPicker,
65
+ localeText,
65
66
  onBlur: handleBlur,
66
67
  rangePosition,
67
68
  onRangePositionChange: setRangePosition
@@ -75,6 +76,7 @@ export const useDesktopRangePicker = ({
75
76
  disabled,
76
77
  className,
77
78
  format,
79
+ autoFocus: autoFocus && !props.open,
78
80
  ref: fieldRef
79
81
  }),
80
82
  ownerState: props
@@ -90,7 +92,7 @@ export const useDesktopRangePicker = ({
90
92
  const inputPropsPassedByField = resolveComponentProps(fieldProps.componentsProps?.input, ownerState);
91
93
  const inputPropsPassedByPicker = ownerState.position === 'start' ? fieldSlotsProps.startInput : fieldSlotsProps.endInput;
92
94
  return _extends({}, externalInputProps, inputPropsPassedByField, inputPropsPassedByPicker, {
93
- inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps, inputPropsPassedByPicker?.inputProps)
95
+ inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps)
94
96
  });
95
97
  },
96
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,8 +37,8 @@ export const useMobileRangePicker = ({
38
37
  props,
39
38
  valueManager,
40
39
  wrapperVariant: 'mobile',
41
- viewLookup,
42
40
  validator,
41
+ autoFocusView: true,
43
42
  additionalViewProps: {
44
43
  rangePosition,
45
44
  onRangePositionChange: setRangePosition
@@ -52,6 +51,7 @@ export const useMobileRangePicker = ({
52
51
  readOnly,
53
52
  disabled,
54
53
  disableOpenPicker,
54
+ localeText,
55
55
  rangePosition,
56
56
  onRangePositionChange: setRangePosition
57
57
  });
@@ -60,7 +60,7 @@ export const useMobileRangePicker = ({
60
60
  elementType: Field,
61
61
  externalSlotProps: componentsProps.field,
62
62
  additionalProps: _extends({}, pickerFieldProps, {
63
- readOnly,
63
+ readOnly: readOnly ?? true,
64
64
  disabled,
65
65
  className,
66
66
  format,
@@ -77,7 +77,7 @@ export const useMobileRangePicker = ({
77
77
  const inputPropsPassedByField = resolveComponentProps(fieldProps.componentsProps?.input, ownerState);
78
78
  const inputPropsPassedByPicker = ownerState.position === 'start' ? fieldSlotsProps.startInput : fieldSlotsProps.endInput;
79
79
  return _extends({}, externalInputProps, inputPropsPassedByField, inputPropsPassedByPicker, {
80
- inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps, inputPropsPassedByPicker?.inputProps)
80
+ inputProps: _extends({}, externalInputProps?.inputProps, inputPropsPassedByField?.inputProps)
81
81
  });
82
82
  },
83
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
@@ -10,7 +10,8 @@ export const useRangePickerInputProps = ({
10
10
  disableOpenPicker,
11
11
  onBlur,
12
12
  rangePosition,
13
- onRangePositionChange
13
+ onRangePositionChange,
14
+ localeText: inLocaleText
14
15
  }) => {
15
16
  const localeText = useLocaleText();
16
17
  const startRef = React.useRef(null);
@@ -26,14 +27,14 @@ export const useRangePickerInputProps = ({
26
27
  }
27
28
  }, [rangePosition, open]);
28
29
  const openRangeStartSelection = event => {
29
- event?.stopPropagation();
30
+ event.stopPropagation();
30
31
  onRangePositionChange('start');
31
32
  if (!readOnly && !disableOpenPicker) {
32
33
  actions.onOpen();
33
34
  }
34
35
  };
35
36
  const openRangeEndSelection = event => {
36
- event?.stopPropagation();
37
+ event.stopPropagation();
37
38
  onRangePositionChange('end');
38
39
  if (!readOnly && !disableOpenPicker) {
39
40
  actions.onOpen();
@@ -49,31 +50,30 @@ export const useRangePickerInputProps = ({
49
50
  onRangePositionChange('end');
50
51
  }
51
52
  };
53
+ const readOnlyInput = readOnly ?? wrapperVariant === 'mobile';
52
54
  const startInputProps = _extends({
53
55
  inputRef: startRef,
54
- label: localeText.start,
56
+ label: inLocaleText?.start ?? localeText.start,
55
57
  onKeyDown: onSpaceOrEnter(openRangeStartSelection),
56
58
  onFocus: focusOnRangeStart,
57
59
  focused: open ? rangePosition === 'start' : undefined
58
60
  }, !readOnly && !disabled && {
59
61
  onClick: openRangeStartSelection
60
62
  }, {
61
- inputProps: {
62
- readOnly: wrapperVariant === 'mobile'
63
- }
63
+ readOnly: readOnlyInput,
64
+ disabled
64
65
  });
65
66
  const endInputProps = _extends({
66
67
  inputRef: endRef,
67
- label: localeText.end,
68
+ label: inLocaleText?.end ?? localeText.end,
68
69
  onKeyDown: onSpaceOrEnter(openRangeEndSelection),
69
70
  onFocus: focusOnRangeEnd,
70
71
  focused: open ? rangePosition === 'end' : undefined
71
72
  }, !readOnly && !disabled && {
72
73
  onClick: openRangeEndSelection
73
74
  }, {
74
- inputProps: {
75
- readOnly: wrapperVariant === 'mobile'
76
- }
75
+ readOnly: readOnlyInput,
76
+ disabled
77
77
  });
78
78
  const rootProps = {
79
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
  }) => {
@@ -27,7 +26,8 @@ export const useStaticRangePicker = ({
27
26
  localeText,
28
27
  components,
29
28
  componentsProps,
30
- displayStaticWrapperAs
29
+ displayStaticWrapperAs,
30
+ autoFocus
31
31
  } = props;
32
32
  const [rangePosition, setRangePosition] = React.useState('start');
33
33
  const {
@@ -35,9 +35,9 @@ export const useStaticRangePicker = ({
35
35
  renderCurrentView
36
36
  } = usePicker({
37
37
  props,
38
- viewLookup,
39
38
  valueManager,
40
39
  validator,
40
+ autoFocusView: autoFocus ?? false,
41
41
  additionalViewProps: {},
42
42
  wrapperVariant: displayStaticWrapperAs
43
43
  });
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY3MDQ1NDAwMDAwMA==";
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 } 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,36 +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: ' – '
46
+ dateName: position
46
47
  });
47
- }
48
- return _extends({}, section, {
49
- dateName: 'start'
50
48
  });
51
- });
52
- const sectionsOfEndDate = rawSectionsOfEndDate.map(section => _extends({}, section, {
53
- dateName: 'end'
54
- }));
55
- return addPositionPropertiesToSections([...sectionsOfStartDate, ...sectionsOfEndDate]);
49
+ };
50
+ return addPositionPropertiesToSections([...getSections(start, prevDateRangeSections.startDate, 'start'), ...getSections(end, prevDateRangeSections.endDate, 'end')]);
56
51
  },
57
52
  getValueStrFromSections: sections => {
58
53
  const dateRangeSections = splitDateRangeSections(sections);
59
- const startDateStr = createDateStrFromSections(dateRangeSections.startDate, true);
60
- const endDateStr = createDateStrFromSections(dateRangeSections.endDate, true);
61
- return `${startDateStr}${endDateStr}`;
54
+ return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate]);
62
55
  },
63
56
  getActiveDateSections: (sections, activeSection) => {
64
57
  const index = activeSection.dateName === 'start' ? 0 : 1;
@@ -87,5 +80,11 @@ export const rangeFieldValueManager = {
87
80
  })
88
81
  };
89
82
  },
90
- hasError: error => error[0] != null || error[1] != null
83
+ hasError: error => error[0] != null || error[1] != null,
84
+ getSectionOrder: (utils, localeText, format, isRTL) => {
85
+ const splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
86
+ return getSectionOrder([...splitedFormat.slice(0, splitedFormat.length - 1), _extends({}, splitedFormat[splitedFormat.length - 1], {
87
+ endSeparator: ' – '
88
+ }), ...splitedFormat], isRTL);
89
+ }
91
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:', () => {