@mui/x-date-pickers-pro 6.0.0-beta.1 → 6.0.0-beta.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 (92) hide show
  1. package/CHANGELOG.md +173 -3
  2. package/DateRangeCalendar/DateRangeCalendar.js +30 -14
  3. package/DateRangeCalendar/DateRangeCalendar.types.d.ts +5 -5
  4. package/DateRangeCalendar/index.d.ts +1 -0
  5. package/DateRangePicker/DateRangePicker.js +27 -10
  6. package/DateRangePicker/DateRangePickerToolbar.d.ts +3 -2
  7. package/DesktopDateRangePicker/DesktopDateRangePicker.js +27 -10
  8. package/MobileDateRangePicker/MobileDateRangePicker.js +27 -10
  9. package/MultiInputDateRangeField/MultiInputDateRangeField.js +13 -7
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +13 -7
  11. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +12 -6
  12. package/SingleInputDateRangeField/SingleInputDateRangeField.js +7 -5
  13. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -5
  14. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -4
  15. package/StaticDateRangePicker/StaticDateRangePicker.js +24 -7
  16. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +1 -1
  17. package/dateRangeViewRenderers/dateRangeViewRenderers.js +2 -0
  18. package/index.js +1 -1
  19. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +8 -4
  20. package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +4 -3
  21. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +8 -4
  22. package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +4 -3
  23. package/internal/hooks/useRangePosition.d.ts +24 -0
  24. package/internal/hooks/useRangePosition.js +20 -0
  25. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +7 -3
  26. package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +2 -1
  27. package/internal/models/dateRange.d.ts +1 -1
  28. package/internal/models/range.d.ts +0 -4
  29. package/internal/utils/date-fields-utils.d.ts +1 -1
  30. package/internal/utils/releaseInfo.js +1 -1
  31. package/legacy/DateRangeCalendar/DateRangeCalendar.js +29 -17
  32. package/legacy/DateRangePicker/DateRangePicker.js +27 -10
  33. package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +27 -10
  34. package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +27 -10
  35. package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +13 -7
  36. package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +13 -7
  37. package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +12 -6
  38. package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +7 -5
  39. package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -5
  40. package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -4
  41. package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +24 -7
  42. package/legacy/dateRangeViewRenderers/dateRangeViewRenderers.js +2 -0
  43. package/legacy/index.js +1 -1
  44. package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +7 -8
  45. package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +7 -8
  46. package/legacy/internal/hooks/useRangePosition.js +24 -0
  47. package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +6 -7
  48. package/legacy/internal/utils/releaseInfo.js +1 -1
  49. package/legacy/tests/describeRangeValidation/describeRangeValidation.js +18 -18
  50. package/modern/DateRangeCalendar/DateRangeCalendar.js +30 -14
  51. package/modern/DateRangePicker/DateRangePicker.js +27 -10
  52. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +27 -10
  53. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +27 -10
  54. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +13 -7
  55. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +13 -7
  56. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +12 -6
  57. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +7 -5
  58. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -5
  59. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -4
  60. package/modern/StaticDateRangePicker/StaticDateRangePicker.js +24 -7
  61. package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +2 -0
  62. package/modern/index.js +1 -1
  63. package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +8 -4
  64. package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +8 -4
  65. package/modern/internal/hooks/useRangePosition.js +18 -0
  66. package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +7 -3
  67. package/modern/internal/utils/releaseInfo.js +1 -1
  68. package/modern/tests/describeRangeValidation/describeRangeValidation.js +18 -18
  69. package/node/DateRangeCalendar/DateRangeCalendar.js +30 -14
  70. package/node/DateRangePicker/DateRangePicker.js +27 -10
  71. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +27 -10
  72. package/node/MobileDateRangePicker/MobileDateRangePicker.js +27 -10
  73. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +13 -7
  74. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +13 -7
  75. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +12 -6
  76. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +7 -5
  77. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -5
  78. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -4
  79. package/node/StaticDateRangePicker/StaticDateRangePicker.js +24 -7
  80. package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +2 -0
  81. package/node/index.js +1 -1
  82. package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +8 -4
  83. package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +8 -4
  84. package/node/internal/hooks/useRangePosition.js +26 -0
  85. package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +7 -3
  86. package/node/internal/utils/releaseInfo.js +1 -1
  87. package/node/tests/describeRangeValidation/describeRangeValidation.js +20 -19
  88. package/package.json +6 -7
  89. package/tests/describeRangeValidation/describeRangeValidation.js +18 -18
  90. package/themeAugmentation/components.d.ts +20 -0
  91. package/themeAugmentation/overrides.d.ts +9 -2
  92. package/themeAugmentation/props.d.ts +14 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,117 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.0.0-beta.3
7
+
8
+ _Feb 9, 2023_
9
+
10
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - ⬅️ Add right-to-left support for the data grid (#6580) @yaredtsy
13
+ - ⚡️ Improve grid resize performance (#7864) @cherniavskii
14
+ - ✨ New codemods for migrating to v6 @MBilalShafi
15
+ - 📚 Documentation improvements
16
+ - 🐞 Bugfixes
17
+
18
+ ### `@mui/x-data-grid@v6.0.0-beta.3` / `@mui/x-data-grid-pro@v6.0.0-beta.3` / `@mui/x-data-grid-premium@v6.0.0-beta.3`
19
+
20
+ #### Changes
21
+
22
+ - [DataGrid] Add `BaseIconButton` component slot (#7329) @123joshuawu
23
+ - [DataGrid] Allow to customize the value displayed in the filter button tooltip (#6956) @ithrforu
24
+ - [DataGrid] Improve grid resize performance (#7864) @cherniavskii
25
+ - [DataGrid] Make `apiRef.current.getRowWithUpdatedValues` stable (#7788) @m4theushw
26
+ - [DataGrid] Support RTL (#6580) @yaredtsy
27
+ - [DataGrid] Improve query selectors for selecting cell element (#7354) @yaredtsy
28
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#7854) @ed-ateixeira
29
+
30
+ ### `@mui/x-date-pickers@v6.0.0-beta.3` / `@mui/x-date-pickers-pro@v6.0.0-beta.3`
31
+
32
+ #### Changes
33
+
34
+ - [fields] Allow to select year 2000 on 2-digit year section (#7858) @flaviendelangle
35
+ - [fields] Fix year editing on `day.js` (#7862) @flaviendelangle
36
+ - [fields] Fix year editing on valid date (#7834) @flaviendelangle
37
+ - [fields] Reset query when pressing `Backspace` or `Delete` (#7855) @flaviendelangle
38
+ - [pickers] Clean Popper position on new pickers (#7445) @flaviendelangle
39
+ - [pickers] Ditch pickers `skipLibCheck` (#7808) @LukasTy
40
+ - [pickers] Improve JSDoc and resulting API docs pages (#7847) @LukasTy
41
+
42
+ ### `@mui/x-codemod@v6.0.0-beta.3`
43
+
44
+ #### Changes
45
+
46
+ - [codemod] Add more cases to `rename-selectors-and-events` codemod (#7856) @MBilalShafi
47
+ - [codemod] Add warning message to the codemods and migration guide (#7813) @MBilalShafi
48
+ - [codemod] Add codemod to remove unnecessary `experimentalFeatures` flag (#7836) @MBilalShafi
49
+ - [codemod] Rename `GridFilterItem` props (#7483) @MBilalShafi
50
+ - [codemod] Rename `linkOperators` to `logicOperators` (#7707) @MBilalShafi
51
+ - [codemod] Replace `onCellFocusOut` prop for Data Grid (#7786) @MBilalShafi
52
+
53
+ ### Docs
54
+
55
+ - [docs] Add a "Whats new in v6" page linked on the sidebar (#7820) @joserodolfofreitas
56
+ - [docs] Fix hydration crash in pickers (#7734) @oliviertassinari
57
+ - [docs] Remove no longer relevant range shortcuts section (#7840) @LukasTy
58
+ - [docs] Use `@next` tag in grid and pickers installation instructions (#7814) @cherniavskii
59
+
60
+ ### Core
61
+
62
+ - [core] Remove `tslint` package leftovers (#7841) @LukasTy
63
+ - [test] Use `createDescribes` for `describeValue` and `describeValidation` (#7866) @flaviendelangle
64
+
65
+ ## 6.0.0-beta.2
66
+
67
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
68
+
69
+ - 🚀 Support week day formats in the field components
70
+ - 🌍 Add Hungarian (hu-HU) and Urdu (ur-PK) locales
71
+ - 🌍 Improve French (fr-FR) and Italian (it-IT) locales
72
+ - ✨ New codemods for migrating to v6
73
+ - 📚 Documentation improvements
74
+ - 🐞 Bug fixes
75
+
76
+ ### `@mui/x-data-grid@v6.0.0-beta.2` / `@mui/x-data-grid-pro@v6.0.0-beta.2` / `@mui/x-data-grid-premium@v6.0.0-beta.2`
77
+
78
+ #### Changes
79
+
80
+ - [DataGrid] Handle non-numeric values returned by `getRowHeight` prop (#7703) @cherniavskii
81
+ - [DataGrid] Merge row styles with `componentsProps.row.style` (#7641) @marktoman
82
+ - [l10n] Add Hungarian (hu-HU) locale (#7776) @noherczeg
83
+ - [l10n] Add Urdu (ur-PK) locale (#6866) @MBilalShafi
84
+ - [l10n] Improve French (fr-FR) locale (#7777) @Vivek-Prajapatii
85
+ - [l10n] Improve Italian (it-IT) locale (#7761) @simonecervini
86
+
87
+ ### `@mui/x-date-pickers@v6.0.0-beta.2` / `@mui/x-date-pickers-pro@v6.0.0-beta.2`
88
+
89
+ #### Changes
90
+
91
+ - [fields] Support week day formats (#7392) @flaviendelangle
92
+ - [pickers] Allow to initialize and control the `rangePosition` on all range components (#7764) @flaviendelangle
93
+ - [pickers] Fix theme augmentation (#7800) @LukasTy
94
+ - [pickers] Hide scrollbars in the date calendar container (#7766) @Vivek-Prajapatii
95
+ - [pickers] Remove the dependency on `rifm` (#7785) @alexfauquette
96
+
97
+ ### `@mui/x-codemod@v6.0.0-beta.2`
98
+
99
+ #### Changes
100
+
101
+ - [codemod] Add pickers `rename-default-toolbar-title-localeText` codemod (#7752) @LukasTy
102
+ - [codemod] Add pickers `rename-inputFormat-prop` codemod (#7736) @LukasTy
103
+
104
+ ### Docs
105
+
106
+ - [docs] Fix a typo in data grid layout page (#7113) @sfbaker7
107
+ - [docs] Fix require context path to avoid duplicate key creation (#7781) @LukasTy
108
+ - [docs] Polish pickers migration docs (#7737) @LukasTy
109
+ - [docs] Rename `next` translation docs and remove duplicates with `-next` (#7729) @LukasTy
110
+
111
+ ### Core
112
+
113
+ - [core] Fix l10n data file (#7804) @flaviendelangle
114
+ - [core] Fix Next.js warning (#7754) @oliviertassinari
115
+ - [core] Remove unused demos (#7758) @flaviendelangle
116
+
6
117
  ## 6.0.0-beta.1
7
118
 
8
119
  _Jan 27, 2023_
@@ -1368,8 +1479,7 @@ We'd like to offer a big thanks to the 9 contributors who made this release poss
1368
1479
  - The toolbar related translation keys have been renamed to better fit their usage:
1369
1480
 
1370
1481
  ```diff
1371
- // Same on all other pickers
1372
- <DatePicker
1482
+ <LocalizationProvider
1373
1483
  localeText={{
1374
1484
  - datePickerDefaultToolbarTitle: 'Date Picker',
1375
1485
  + datePickerToolbarTitle: 'Date Picker',
@@ -2022,7 +2132,67 @@ You can find more information about the new api, including how to set those tran
2022
2132
  - [test] Skip tests for column pinning and dynamic row height (#5997) @m4theushw
2023
2133
  - [website] Improve security header @oliviertassinari
2024
2134
 
2025
- ## v5.17.21
2135
+ ## 5.17.23
2136
+
2137
+ _Feb 9, 2023_
2138
+
2139
+ We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
2140
+
2141
+ - 🌍 Improve Brazilian Portuguese (pt-BR) locale
2142
+ - 🎉 Add banner and callouts to inform about MUI X v6 beta
2143
+ - 🐞 Bugfixes
2144
+
2145
+ ### `@mui/x-data-grid@v5.17.23` / `@mui/x-data-grid-pro@v5.17.23` / `@mui/x-data-grid-premium@v5.17.23`
2146
+
2147
+ #### Changes
2148
+
2149
+ - [DataGrid] Allow to customize the value displayed in the filter button tooltip (#7816) @ithrforu
2150
+ - [DataGrid] Fix `getCellElement` method not working with pinned columns (#7844) @yaredtsy
2151
+ - [DataGrid] Fix stale rows issue in `unstable_replaceRows` (#7694) @MBilalShafi
2152
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#7850) @ed-ateixeira
2153
+
2154
+ ### `@mui/x-date-pickers@v_5.0.18` / `@mui/x-date-pickers-pro@v_5.0.18`
2155
+
2156
+ #### Changes
2157
+
2158
+ - [pickers] Update pickers when new value has a distinct timezone (#7853) @alexfauquette
2159
+
2160
+ ### Docs
2161
+
2162
+ - [docs] Add messages in v5 doc to inform people about v6 (#7838) @flaviendelangle
2163
+ - [docs] Fix 301 link @oliviertassinari
2164
+
2165
+ ### Core
2166
+
2167
+ - [core] Upgrade monorepo (#7849) @cherniavskii
2168
+
2169
+ ## 5.17.22
2170
+
2171
+ _Feb 2, 2023_
2172
+
2173
+ We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
2174
+
2175
+ - 🌍 Add Urdu (ur-PK) locale
2176
+ - 🌍 Improve French (fr-FR) and Italian (it-IT) locales
2177
+ - 🐞 Bugfixes
2178
+
2179
+ ### `@mui/x-data-grid@v5.17.22` / `@mui/x-data-grid-pro@v5.17.22` / `@mui/x-data-grid-premium@v5.17.22`
2180
+
2181
+ #### Changes
2182
+
2183
+ - [DataGrid] Fix an error when deleting pinned row using the buttons in the `actions` column (#7767) @cherniavskii
2184
+ - [DataGrid] Fix print preview regression in Chrome browser (#7405) @cherniavskii
2185
+ - [l10n] Add Urdu (ur-PK) locale (#7778) @MBilalShafi
2186
+ - [l10n] Improve French (fr-FR) locale (#7795) @Vivek-Prajapatii
2187
+
2188
+ ### `@mui/x-date-pickers@v5.0.17` / `@mui/x-date-pickers-pro@v5.0.17`
2189
+
2190
+ #### Changes
2191
+
2192
+ - [TimePicker] Add missing `themeAugmentation` entry (#7732) @LukasTy
2193
+ - [l10n] Improve Italian (it-IT) locale (#7761) @simonecervini
2194
+
2195
+ ## 5.17.21
2026
2196
 
2027
2197
  _Jan 27, 2023_
2028
2198
 
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["value", "defaultValue", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "defaultCalendarMonth", "rangePosition", "onRangePositionChange", "calendars", "components", "componentsProps", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber"],
3
+ const _excluded = ["value", "defaultValue", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "defaultCalendarMonth", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "components", "componentsProps", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber"],
4
4
  _excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
@@ -20,6 +20,7 @@ import { calculateRangeChange, calculateRangePreview } from '../internal/utils/d
20
20
  import { DateRangePickerDay, dateRangePickerDayClasses as dayClasses } from '../DateRangePickerDay';
21
21
  import { rangeValueManager } from '../internal/utils/valueManagers';
22
22
  import { useDragRange } from './useDragRange';
23
+ import { useRangePosition } from '../internal/hooks/useRangePosition';
23
24
  import { jsx as _jsx } from "react/jsx-runtime";
24
25
  import { jsxs as _jsxs } from "react/jsx-runtime";
25
26
  const releaseInfo = getReleaseInfo();
@@ -127,8 +128,9 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
127
128
  reduceAnimations,
128
129
  onMonthChange,
129
130
  defaultCalendarMonth,
130
- rangePosition: rangePositionProps,
131
- onRangePositionChange,
131
+ rangePosition: rangePositionProp,
132
+ defaultRangePosition: inDefaultRangePosition,
133
+ onRangePositionChange: inOnRangePositionChange,
132
134
  calendars,
133
135
  components,
134
136
  componentsProps,
@@ -156,15 +158,17 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
156
158
  name: 'DateRangeCalendar',
157
159
  state: 'value'
158
160
  });
159
- const [rangePosition, setRangePosition] = useControlled({
160
- controlled: rangePositionProps,
161
- default: 'start',
162
- name: 'DateRangeCalendar',
163
- state: 'rangePosition'
161
+ const {
162
+ rangePosition,
163
+ onRangePositionChange
164
+ } = useRangePosition({
165
+ rangePosition: rangePositionProp,
166
+ defaultRangePosition: inDefaultRangePosition,
167
+ onRangePositionChange: inOnRangePositionChange
164
168
  });
165
169
  const handleDatePositionChange = useEventCallback(position => {
166
170
  if (rangePosition !== position) {
167
- setRangePosition(position);
171
+ onRangePositionChange(position);
168
172
  }
169
173
  });
170
174
  const handleSelectedDayChange = useEventCallback((newDate, selectionState, allowRangeFlip = false) => {
@@ -178,8 +182,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
178
182
  rangePosition,
179
183
  allowRangeFlip
180
184
  });
181
- setRangePosition(nextSelection);
182
- onRangePositionChange == null ? void 0 : onRangePositionChange(nextSelection);
185
+ onRangePositionChange(nextSelection);
183
186
  const isFullRangeSelected = rangePosition === 'end' && isRangeValid(utils, newRange);
184
187
  setValue(newRange);
185
188
  onChange == null ? void 0 : onChange(newRange, isFullRangeSelected ? 'finish' : 'partial');
@@ -482,6 +485,12 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
482
485
  * Default calendar month displayed when `value={[null, null]}`.
483
486
  */
484
487
  defaultCalendarMonth: PropTypes.any,
488
+ /**
489
+ * The initial position in the edited date range.
490
+ * Used when the component is not controlled.
491
+ * @default 'start'
492
+ */
493
+ defaultRangePosition: PropTypes.oneOf(['end', 'start']),
485
494
  /**
486
495
  * The default selected value.
487
496
  * Used when the component is not controlled.
@@ -549,13 +558,20 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
549
558
  */
550
559
  onChange: PropTypes.func,
551
560
  /**
552
- * Callback firing on month change @DateIOType.
561
+ * Callback fired on month change.
553
562
  * @template TDate
554
563
  * @param {TDate} month The new month.
555
- * @returns {void|Promise} -
556
564
  */
557
565
  onMonthChange: PropTypes.func,
566
+ /**
567
+ * Callback fired when the range position changes.
568
+ * @param {RangePosition} rangePosition The new range position.
569
+ */
558
570
  onRangePositionChange: PropTypes.func,
571
+ /**
572
+ * The position in the currently edited date range.
573
+ * Used when the component position is controlled.
574
+ */
559
575
  rangePosition: PropTypes.oneOf(['end', 'start']),
560
576
  /**
561
577
  * Make picker read only.
@@ -574,7 +590,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
574
590
  */
575
591
  renderLoading: PropTypes.func,
576
592
  /**
577
- * Disable specific date. @DateIOType
593
+ * Disable specific date.
578
594
  * @template TDate
579
595
  * @param {TDate} day The date to test.
580
596
  * @param {string} position The date to test, 'start' or 'end'.
@@ -3,9 +3,10 @@ import { SxProps } from '@mui/system';
3
3
  import { SlotComponentProps } from '@mui/base';
4
4
  import { Theme } from '@mui/material/styles';
5
5
  import { BaseDateValidationProps, DefaultizedProps, ExportedDayCalendarProps, DayCalendarSlotsComponent, DayCalendarSlotsComponentsProps, PickersArrowSwitcherSlotsComponent, PickersArrowSwitcherSlotsComponentsProps, PickerSelectionState, PickersCalendarHeaderSlotsComponent, PickersCalendarHeaderSlotsComponentsProps, DayCalendarProps, ExportedUseViewsOptions, UncapitalizeObjectKeys } from '@mui/x-date-pickers/internals';
6
- import { DateRange, RangePositionProps, DayRangeValidationProps } from '../internal/models';
6
+ import { DateRange, DayRangeValidationProps } from '../internal/models';
7
7
  import { DateRangeCalendarClasses } from './dateRangeCalendarClasses';
8
8
  import { DateRangePickerDay, DateRangePickerDayProps } from '../DateRangePickerDay';
9
+ import { UseRangePositionProps } from '../internal/hooks/useRangePosition';
9
10
  export type DateRangePosition = 'start' | 'end';
10
11
  export interface DateRangeCalendarSlotsComponent<TDate> extends PickersArrowSwitcherSlotsComponent, Omit<DayCalendarSlotsComponent<TDate>, 'Day'>, PickersCalendarHeaderSlotsComponent {
11
12
  /**
@@ -47,12 +48,11 @@ export interface ExportedDateRangeCalendarProps<TDate> extends ExportedDayCalend
47
48
  */
48
49
  reduceAnimations?: boolean;
49
50
  /**
50
- * Callback firing on month change @DateIOType.
51
+ * Callback fired on month change.
51
52
  * @template TDate
52
53
  * @param {TDate} month The new month.
53
- * @returns {void|Promise} -
54
54
  */
55
- onMonthChange?: (month: TDate) => void | Promise<void>;
55
+ onMonthChange?: (month: TDate) => void;
56
56
  /**
57
57
  * The number of calendars to render.
58
58
  * @default 2
@@ -64,7 +64,7 @@ export interface ExportedDateRangeCalendarProps<TDate> extends ExportedDayCalend
64
64
  */
65
65
  disableDragEditing?: boolean;
66
66
  }
67
- export interface DateRangeCalendarProps<TDate> extends ExportedDateRangeCalendarProps<TDate>, Partial<RangePositionProps> {
67
+ export interface DateRangeCalendarProps<TDate> extends ExportedDateRangeCalendarProps<TDate>, UseRangePositionProps {
68
68
  /**
69
69
  * The selected value.
70
70
  * Used when the component is controlled.
@@ -1,3 +1,4 @@
1
1
  export { DateRangeCalendar } from './DateRangeCalendar';
2
2
  export type { DateRangeCalendarProps, DateRangeCalendarSlotsComponent, DateRangeCalendarSlotsComponentsProps, ExportedDateRangeCalendarProps, } from './DateRangeCalendar.types';
3
3
  export { getDateRangeCalendarUtilityClass, dateRangeCalendarClasses, } from './dateRangeCalendarClasses';
4
+ export type { DateRangeCalendarClassKey, DateRangeCalendarClasses, } from './dateRangeCalendarClasses';
@@ -80,6 +80,12 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
80
80
  * Default calendar month displayed when `value={[null, null]}`.
81
81
  */
82
82
  defaultCalendarMonth: PropTypes.any,
83
+ /**
84
+ * The initial position in the edited date range.
85
+ * Used when the component is not controlled.
86
+ * @default 'start'
87
+ */
88
+ defaultRangePosition: PropTypes.oneOf(['end', 'start']),
83
89
  /**
84
90
  * The default value.
85
91
  * Used when the component is not controlled.
@@ -162,43 +168,49 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
162
168
  minDate: PropTypes.any,
163
169
  /**
164
170
  * Callback fired when the value is accepted.
165
- * @template TValue
171
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
166
172
  * @param {TValue} value The value that was just accepted.
167
173
  */
168
174
  onAccept: PropTypes.func,
169
175
  /**
170
176
  * Callback fired when the value changes.
171
- * @template TValue, TError
177
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
178
+ * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
172
179
  * @param {TValue} value The new value.
173
- * @param {FieldChangeHandlerContext<TError>} The context containing the validation result of the current value.
180
+ * @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
174
181
  */
175
182
  onChange: PropTypes.func,
176
183
  /**
177
184
  * Callback fired when the popup requests to be closed.
178
- * Use in controlled mode (see open).
185
+ * Use in controlled mode (see `open`).
179
186
  */
180
187
  onClose: PropTypes.func,
181
188
  /**
182
189
  * Callback fired when the error associated to the current value changes.
183
190
  * If the error has a non-null value, then the `TextField` will be rendered in `error` state.
184
191
  *
185
- * @template TValue, TError
192
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
193
+ * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
186
194
  * @param {TError} error The new error describing why the current value is not valid.
187
195
  * @param {TValue} value The value associated to the error.
188
196
  */
189
197
  onError: PropTypes.func,
190
198
  /**
191
- * Callback firing on month change @DateIOType.
199
+ * Callback fired on month change.
192
200
  * @template TDate
193
201
  * @param {TDate} month The new month.
194
- * @returns {void|Promise} -
195
202
  */
196
203
  onMonthChange: PropTypes.func,
197
204
  /**
198
205
  * Callback fired when the popup requests to be opened.
199
- * Use in controlled mode (see open).
206
+ * Use in controlled mode (see `open`).
200
207
  */
201
208
  onOpen: PropTypes.func,
209
+ /**
210
+ * Callback fired when the range position changes.
211
+ * @param {RangePosition} rangePosition The new range position.
212
+ */
213
+ onRangePositionChange: PropTypes.func,
202
214
  /**
203
215
  * Callback fired when the selected sections change.
204
216
  * @param {FieldSelectedSections} newValue The new selected sections.
@@ -209,6 +221,11 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
209
221
  * @default false
210
222
  */
211
223
  open: PropTypes.bool,
224
+ /**
225
+ * The position in the currently edited date range.
226
+ * Used when the component position is controlled.
227
+ */
228
+ rangePosition: PropTypes.oneOf(['end', 'start']),
212
229
  readOnly: PropTypes.bool,
213
230
  /**
214
231
  * Disable heavy animations.
@@ -230,12 +247,12 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
230
247
  * 4. If `null` is provided, no section will be selected
231
248
  * If not provided, the selected sections will be handled internally.
232
249
  */
233
- selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']), PropTypes.number, PropTypes.shape({
250
+ selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
234
251
  endIndex: PropTypes.number.isRequired,
235
252
  startIndex: PropTypes.number.isRequired
236
253
  })]),
237
254
  /**
238
- * Disable specific date. @DateIOType
255
+ * Disable specific date.
239
256
  * @template TDate
240
257
  * @param {TDate} day The date to test.
241
258
  * @param {string} position The date to test, 'start' or 'end'.
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { BaseToolbarProps, ExportedBaseToolbarProps } from '@mui/x-date-pickers/internals';
3
- import { DateRange, RangePositionProps } from '../internal/models';
3
+ import { DateRange } from '../internal/models';
4
+ import { UseRangePositionResponse } from '../internal/hooks/useRangePosition';
4
5
  import { DateRangePickerToolbarClasses } from './dateRangePickerToolbarClasses';
5
- export interface DateRangePickerToolbarProps<TDate> extends Omit<BaseToolbarProps<DateRange<TDate>, 'day'>, 'views' | 'view' | 'onViewChange' | 'onChange' | 'isLandscape'>, RangePositionProps {
6
+ export interface DateRangePickerToolbarProps<TDate> extends Omit<BaseToolbarProps<DateRange<TDate>, 'day'>, 'views' | 'view' | 'onViewChange' | 'onChange' | 'isLandscape'>, UseRangePositionResponse {
6
7
  classes?: Partial<DateRangePickerToolbarClasses>;
7
8
  }
8
9
  export interface ExportedDateRangePickerToolbarProps extends ExportedBaseToolbarProps {
@@ -94,6 +94,12 @@ DesktopDateRangePicker.propTypes = {
94
94
  * Default calendar month displayed when `value={[null, null]}`.
95
95
  */
96
96
  defaultCalendarMonth: PropTypes.any,
97
+ /**
98
+ * The initial position in the edited date range.
99
+ * Used when the component is not controlled.
100
+ * @default 'start'
101
+ */
102
+ defaultRangePosition: PropTypes.oneOf(['end', 'start']),
97
103
  /**
98
104
  * The default value.
99
105
  * Used when the component is not controlled.
@@ -170,43 +176,49 @@ DesktopDateRangePicker.propTypes = {
170
176
  minDate: PropTypes.any,
171
177
  /**
172
178
  * Callback fired when the value is accepted.
173
- * @template TValue
179
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
174
180
  * @param {TValue} value The value that was just accepted.
175
181
  */
176
182
  onAccept: PropTypes.func,
177
183
  /**
178
184
  * Callback fired when the value changes.
179
- * @template TValue, TError
185
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
186
+ * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
180
187
  * @param {TValue} value The new value.
181
- * @param {FieldChangeHandlerContext<TError>} The context containing the validation result of the current value.
188
+ * @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
182
189
  */
183
190
  onChange: PropTypes.func,
184
191
  /**
185
192
  * Callback fired when the popup requests to be closed.
186
- * Use in controlled mode (see open).
193
+ * Use in controlled mode (see `open`).
187
194
  */
188
195
  onClose: PropTypes.func,
189
196
  /**
190
197
  * Callback fired when the error associated to the current value changes.
191
198
  * If the error has a non-null value, then the `TextField` will be rendered in `error` state.
192
199
  *
193
- * @template TValue, TError
200
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
201
+ * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
194
202
  * @param {TError} error The new error describing why the current value is not valid.
195
203
  * @param {TValue} value The value associated to the error.
196
204
  */
197
205
  onError: PropTypes.func,
198
206
  /**
199
- * Callback firing on month change @DateIOType.
207
+ * Callback fired on month change.
200
208
  * @template TDate
201
209
  * @param {TDate} month The new month.
202
- * @returns {void|Promise} -
203
210
  */
204
211
  onMonthChange: PropTypes.func,
205
212
  /**
206
213
  * Callback fired when the popup requests to be opened.
207
- * Use in controlled mode (see open).
214
+ * Use in controlled mode (see `open`).
208
215
  */
209
216
  onOpen: PropTypes.func,
217
+ /**
218
+ * Callback fired when the range position changes.
219
+ * @param {RangePosition} rangePosition The new range position.
220
+ */
221
+ onRangePositionChange: PropTypes.func,
210
222
  /**
211
223
  * Callback fired when the selected sections change.
212
224
  * @param {FieldSelectedSections} newValue The new selected sections.
@@ -217,6 +229,11 @@ DesktopDateRangePicker.propTypes = {
217
229
  * @default false
218
230
  */
219
231
  open: PropTypes.bool,
232
+ /**
233
+ * The position in the currently edited date range.
234
+ * Used when the component position is controlled.
235
+ */
236
+ rangePosition: PropTypes.oneOf(['end', 'start']),
220
237
  readOnly: PropTypes.bool,
221
238
  /**
222
239
  * Disable heavy animations.
@@ -238,12 +255,12 @@ DesktopDateRangePicker.propTypes = {
238
255
  * 4. If `null` is provided, no section will be selected
239
256
  * If not provided, the selected sections will be handled internally.
240
257
  */
241
- selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']), PropTypes.number, PropTypes.shape({
258
+ selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
242
259
  endIndex: PropTypes.number.isRequired,
243
260
  startIndex: PropTypes.number.isRequired
244
261
  })]),
245
262
  /**
246
- * Disable specific date. @DateIOType
263
+ * Disable specific date.
247
264
  * @template TDate
248
265
  * @param {TDate} day The date to test.
249
266
  * @param {string} position The date to test, 'start' or 'end'.
@@ -97,6 +97,12 @@ MobileDateRangePicker.propTypes = {
97
97
  * Default calendar month displayed when `value={[null, null]}`.
98
98
  */
99
99
  defaultCalendarMonth: PropTypes.any,
100
+ /**
101
+ * The initial position in the edited date range.
102
+ * Used when the component is not controlled.
103
+ * @default 'start'
104
+ */
105
+ defaultRangePosition: PropTypes.oneOf(['end', 'start']),
100
106
  /**
101
107
  * The default value.
102
108
  * Used when the component is not controlled.
@@ -173,43 +179,49 @@ MobileDateRangePicker.propTypes = {
173
179
  minDate: PropTypes.any,
174
180
  /**
175
181
  * Callback fired when the value is accepted.
176
- * @template TValue
182
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
177
183
  * @param {TValue} value The value that was just accepted.
178
184
  */
179
185
  onAccept: PropTypes.func,
180
186
  /**
181
187
  * Callback fired when the value changes.
182
- * @template TValue, TError
188
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
189
+ * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
183
190
  * @param {TValue} value The new value.
184
- * @param {FieldChangeHandlerContext<TError>} The context containing the validation result of the current value.
191
+ * @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
185
192
  */
186
193
  onChange: PropTypes.func,
187
194
  /**
188
195
  * Callback fired when the popup requests to be closed.
189
- * Use in controlled mode (see open).
196
+ * Use in controlled mode (see `open`).
190
197
  */
191
198
  onClose: PropTypes.func,
192
199
  /**
193
200
  * Callback fired when the error associated to the current value changes.
194
201
  * If the error has a non-null value, then the `TextField` will be rendered in `error` state.
195
202
  *
196
- * @template TValue, TError
203
+ * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
204
+ * @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
197
205
  * @param {TError} error The new error describing why the current value is not valid.
198
206
  * @param {TValue} value The value associated to the error.
199
207
  */
200
208
  onError: PropTypes.func,
201
209
  /**
202
- * Callback firing on month change @DateIOType.
210
+ * Callback fired on month change.
203
211
  * @template TDate
204
212
  * @param {TDate} month The new month.
205
- * @returns {void|Promise} -
206
213
  */
207
214
  onMonthChange: PropTypes.func,
208
215
  /**
209
216
  * Callback fired when the popup requests to be opened.
210
- * Use in controlled mode (see open).
217
+ * Use in controlled mode (see `open`).
211
218
  */
212
219
  onOpen: PropTypes.func,
220
+ /**
221
+ * Callback fired when the range position changes.
222
+ * @param {RangePosition} rangePosition The new range position.
223
+ */
224
+ onRangePositionChange: PropTypes.func,
213
225
  /**
214
226
  * Callback fired when the selected sections change.
215
227
  * @param {FieldSelectedSections} newValue The new selected sections.
@@ -220,6 +232,11 @@ MobileDateRangePicker.propTypes = {
220
232
  * @default false
221
233
  */
222
234
  open: PropTypes.bool,
235
+ /**
236
+ * The position in the currently edited date range.
237
+ * Used when the component position is controlled.
238
+ */
239
+ rangePosition: PropTypes.oneOf(['end', 'start']),
223
240
  readOnly: PropTypes.bool,
224
241
  /**
225
242
  * Disable heavy animations.
@@ -241,12 +258,12 @@ MobileDateRangePicker.propTypes = {
241
258
  * 4. If `null` is provided, no section will be selected
242
259
  * If not provided, the selected sections will be handled internally.
243
260
  */
244
- selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']), PropTypes.number, PropTypes.shape({
261
+ selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
245
262
  endIndex: PropTypes.number.isRequired,
246
263
  startIndex: PropTypes.number.isRequired
247
264
  })]),
248
265
  /**
249
- * Disable specific date. @DateIOType
266
+ * Disable specific date.
250
267
  * @template TDate
251
268
  * @param {TDate} day The date to test.
252
269
  * @param {string} position The date to test, 'start' or 'end'.