@mui/x-date-pickers 7.0.0-alpha.6 → 7.0.0-alpha.7

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 (41) hide show
  1. package/CHANGELOG.md +185 -3
  2. package/DateCalendar/DateCalendar.js +6 -4
  3. package/DateCalendar/DateCalendar.types.d.ts +0 -8
  4. package/DigitalClock/DigitalClock.js +3 -2
  5. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  6. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  7. package/TimeClock/TimeClock.js +3 -2
  8. package/index.js +1 -1
  9. package/internals/components/PickersInput/PickersFilledInput.js +2 -2
  10. package/internals/components/PickersInput/PickersStandardInput.js +2 -2
  11. package/internals/hooks/useViews.d.ts +4 -4
  12. package/internals/hooks/useViews.js +13 -13
  13. package/internals/models/props/clock.d.ts +0 -9
  14. package/legacy/DateCalendar/DateCalendar.js +6 -4
  15. package/legacy/DigitalClock/DigitalClock.js +3 -2
  16. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  17. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  18. package/legacy/TimeClock/TimeClock.js +3 -2
  19. package/legacy/index.js +1 -1
  20. package/legacy/internals/components/PickersInput/PickersFilledInput.js +2 -2
  21. package/legacy/internals/components/PickersInput/PickersStandardInput.js +2 -2
  22. package/legacy/internals/hooks/useViews.js +13 -13
  23. package/modern/DateCalendar/DateCalendar.js +6 -4
  24. package/modern/DigitalClock/DigitalClock.js +3 -2
  25. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  26. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  27. package/modern/TimeClock/TimeClock.js +3 -2
  28. package/modern/index.js +1 -1
  29. package/modern/internals/components/PickersInput/PickersFilledInput.js +2 -2
  30. package/modern/internals/components/PickersInput/PickersStandardInput.js +2 -2
  31. package/modern/internals/hooks/useViews.js +13 -13
  32. package/node/DateCalendar/DateCalendar.js +6 -4
  33. package/node/DigitalClock/DigitalClock.js +3 -2
  34. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +9 -13
  35. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -8
  36. package/node/TimeClock/TimeClock.js +3 -2
  37. package/node/index.js +1 -1
  38. package/node/internals/components/PickersInput/PickersFilledInput.js +2 -2
  39. package/node/internals/components/PickersInput/PickersStandardInput.js +2 -2
  40. package/node/internals/hooks/useViews.js +13 -13
  41. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -3,6 +3,146 @@
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
+ ## 7.0.0-alpha.7
7
+
8
+ _Jan 5, 2024_
9
+
10
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🎁 New component to create a Tree View from a structured data source:
13
+
14
+ You can now directly pass your data to the `RichTreeView` component instead of manually converting it into JSX `TreeItem` components:
15
+
16
+ ```tsx
17
+ const ITEMS = [
18
+ {
19
+ id: 'node-1',
20
+ label: 'Node 1',
21
+ children: [
22
+ { id: 'node-1-1', label: Node 1.1' },
23
+ { id: 'node-1-2', label: Node 1.2' },
24
+ ],
25
+ },
26
+ {
27
+ id: 'node-2',
28
+ label: 'Node 2',
29
+ },
30
+ ];
31
+
32
+ <RichTreeView
33
+ items={MUI_X_PRODUCTS}
34
+ defaultCollapseIcon={<ExpandMoreIcon />}
35
+ defaultExpandIcon={<ChevronRightIcon />}
36
+ />
37
+ ```
38
+
39
+ - 🌍 Improve Czech (cs-CZ) locale on the Data Grid
40
+ - 🐞 Bugfixes
41
+
42
+ ### Data Grid
43
+
44
+ #### `@mui/x-data-grid@7.0.0-alpha.7`
45
+
46
+ - [DataGrid] Don't evaluate `hasEval` when `disableEval` is set (#11516) @reihwald
47
+ - [DataGrid] follow warning message guideline for `autoPageSize` and `autoHeight` (#11585) @Sboonny
48
+ - [DataGrid] Replace `eval` with `new Function` (#11557) @oliviertassinari
49
+ - [DataGrid] Warn devs when `autoPageSize` is used with `autoHeight` (#11554) @Sboonny
50
+ - [l10n] Improve Czech (cs-CZ) locale (#11526) @fdebef
51
+
52
+ #### `@mui/x-data-grid-pro@7.0.0-alpha.7` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
53
+
54
+ Same changes as in `@mui/x-data-grid@7.0.0-alpha.7`.
55
+
56
+ #### `@mui/x-data-grid-premium@7.0.0-alpha.7` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
57
+
58
+ Same changes as in `@mui/x-data-grid-pro@7.0.0-alpha.7`.
59
+
60
+ ### Date Pickers
61
+
62
+ #### `@mui/x-date-pickers@7.0.0-alpha.7`
63
+
64
+ - [pickers] Fix views management (#11419) @LukasTy
65
+
66
+ #### `@mui/x-date-pickers-pro@7.0.0-alpha.7` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
67
+
68
+ Same changes as in `@mui/x-date-pickers@7.0.0-alpha.7`.
69
+
70
+ ### Charts / `@mui/x-charts@7.0.0-alpha.7`
71
+
72
+ - [charts] Add `arcLabelRadius` property (#11487) @alexfauquette
73
+ - [charts] Fix `null` in line chart using dataset (#11550) @alexfauquette
74
+
75
+ ### Tree View
76
+
77
+ #### Breaking changes
78
+
79
+ - The expansion props have been renamed to better describe their behaviors:
80
+
81
+ | Old name | New name |
82
+ | :---------------- | :---------------------- |
83
+ | `onNodeToggle` | `onExpandedNodesChange` |
84
+ | `expanded` | `expandedNodes` |
85
+ | `defaultExpanded` | `defaultExpandedNodes` |
86
+
87
+ ```diff
88
+ <TreeView
89
+ - onNodeToggle={handleExpansionChange}
90
+ + onExpandedNodesChange={handleExpansionChange}
91
+
92
+ - expanded={expandedNodes}
93
+ + expandedNodes={expandedNodes}
94
+
95
+ - defaultExpanded={defaultExpandedNodes}
96
+ + defaultExpandedNodes={defaultExpandedNodes}
97
+ />
98
+ ```
99
+
100
+ - The selection props have been renamed to better describe their behaviors:
101
+
102
+ | Old name | New name |
103
+ | :---------------- | :---------------------- |
104
+ | `onNodeSelect` | `onSelectedNodesChange` |
105
+ | `selected` | `selectedNodes` |
106
+ | `defaultSelected` | `defaultSelectedNodes` |
107
+
108
+ ```diff
109
+ <TreeView
110
+ - onNodeSelect={handleSelectionChange}
111
+ + onSelectedNodesChange={handleSelectionChange}
112
+
113
+ - selected={selectedNodes}
114
+ + selectedNodes={selectedNodes}
115
+
116
+ - defaultSelected={defaultSelectedNodes}
117
+ + defaultSelectedNodes={defaultSelectedNodes}
118
+ />
119
+ ```
120
+
121
+ #### `@mui/x-tree-view@7.0.0-alpha.7`
122
+
123
+ - [TreeView] Improve the expansion API (#11476) @flaviendelangle
124
+ - [TreeView] Improve the selection API (#11560) @flaviendelangle
125
+ - [TreeView] Introduce the `items` prop (#11059) @flaviendelangle
126
+
127
+ ### Docs
128
+
129
+ - [docs] Add example for TreeView `onNodeExpansionToggle` prop (#11547) @flaviendelangle
130
+ - [docs] Clarify Pickers usage with Luxon (#11545) @LukasTy
131
+ - [docs] Complete transition to next branch (#11521) @oliviertassinari
132
+ - [docs] Fix 404 links in the docs @oliviertassinari
133
+ - [docs] Fix over page fetching @oliviertassinari
134
+ - [docs] Lint `next.config.js` (#11514) @oliviertassinari
135
+
136
+ ### Core
137
+
138
+ - [core] Fix release changelog (#11496) @romgrk
139
+ - [core] Fix use of ::before & ::after (#11515) @oliviertassinari
140
+ - [core] Localize the issue template to MUI X (#11511) @oliviertassinari
141
+ - [core] Regen api files (#11542) @flaviendelangle
142
+ - [core] Remove issue emoji @oliviertassinari
143
+ - [core] Sync the release instructions with MUI Core @oliviertassinari
144
+ - [core] Yaml format match most common convention @oliviertassinari
145
+
6
146
  ## 7.0.0-alpha.6
7
147
 
8
148
  _Dec 22, 2023_
@@ -65,7 +205,6 @@ Same changes as in `@mui/x-data-grid-pro@7.0.0-alpha.6`.
65
205
  - [fields] Adjust `PickersInput` sizing styles (#11392) @noraleonte
66
206
  - [fields] Fix section pasting (#11447) @LukasTy
67
207
  - [pickers] Add `PickersTextField` `standard` and `filled` variants (#11250) @noraleonte
68
- - [pickers] Add missing breaking changes to changelog (#11420) @MBilalShafi
69
208
  - [pickers] Cleanup error messages in `PickersSectionList` (#11449) @flaviendelangle
70
209
  - [pickers] Create new component `PickersSectionList` (#11352) @flaviendelangle
71
210
 
@@ -73,7 +212,7 @@ Same changes as in `@mui/x-data-grid-pro@7.0.0-alpha.6`.
73
212
 
74
213
  Same changes as in `@mui/x-date-pickers@7.0.0-alpha.6`.
75
214
 
76
- ### Charts / `@mui/x-charts@7.0.0-alpha.6`
215
+ ### Charts / `@mui/x-charts@7.0.0-alpha.5`
77
216
 
78
217
  - [charts] Allow percentage values for pie chart center and radius (#11464) @alexfauquette
79
218
  - [charts] Improve dataset typing (#11372) @alexfauquette
@@ -88,6 +227,7 @@ Same changes as in `@mui/x-date-pickers@7.0.0-alpha.6`.
88
227
 
89
228
  ### Core
90
229
 
230
+ - [core] Add missing breaking changes to changelog (#11420) @MBilalShafi
91
231
  - [core] Cherry pick follow up (#11469) @LukasTy
92
232
  - [core] Fix `cherry-pick` action (#11446) @LukasTy
93
233
  - [core] Fix security regressions in cherry-pick-next-to-master.yml (#11482) @MBilalShafi
@@ -1200,6 +1340,48 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
1200
1340
  - [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
1201
1341
  - [license] Correctly throw errors (#10924) @oliviertassinari
1202
1342
 
1343
+ ## 6.18.7
1344
+
1345
+ _Jan 5, 2024_
1346
+
1347
+ We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
1348
+
1349
+ - 🌍 Improve Czech (cs-CZ) locale on Data Grid (#11429) @wensiet
1350
+ - 🐞 Bugfixes
1351
+
1352
+ ### Data Grid
1353
+
1354
+ #### `@mui/x-data-grid@6.18.7`
1355
+
1356
+ - [DataGrid] Don't evaluate `hasEval` when `disableEval` is set (#11553) @reihwald
1357
+ - [l10n] Update Czech (cs-CZ) locale (#11498) @fdebef
1358
+
1359
+ #### `@mui/x-data-grid-pro@6.18.7` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
1360
+
1361
+ Same changes as in `@mui/x-data-grid@6.18.7`.
1362
+
1363
+ #### `@mui/x-data-grid-premium@6.18.7` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
1364
+
1365
+ Same changes as in `@mui/x-data-grid-pro@6.18.7`.
1366
+
1367
+ ### Date Pickers
1368
+
1369
+ #### `@mui/x-date-pickers@6.18.7`
1370
+
1371
+ - [pickers] Fix views management (@LukasTy) (#11572)
1372
+
1373
+ #### `@mui/x-date-pickers-pro@6.18.7` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
1374
+
1375
+ Same changes as in `@mui/x-date-pickers@6.18.7`.
1376
+
1377
+ ### Charts / `@mui/x-charts@6.18.7`
1378
+
1379
+ - [charts] Fix `null` in line chart using dataset (@alexfauquette) (#11561)
1380
+
1381
+ ### Docs
1382
+
1383
+ - [docs] Clarify Pickers usage with Luxon (#11566) @LukasTy
1384
+
1203
1385
  ## 6.18.6
1204
1386
 
1205
1387
  _Dec 22, 2023_
@@ -1234,7 +1416,7 @@ Same changes as in `@mui/x-data-grid-pro@6.18.6`.
1234
1416
 
1235
1417
  Same changes as in `@mui/x-date-pickers@6.18.6`.
1236
1418
 
1237
- ### Charts / `@mui/x-charts@6.18.6`
1419
+ ### Charts / `@mui/x-charts@6.18.4`
1238
1420
 
1239
1421
  - [charts] Allow percentage values for pie chart center and radius (#11464) @alexfauquette
1240
1422
  - [charts] Make error message more explicit (#11457) @alexfauquette
@@ -254,9 +254,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
254
254
  const handleSelectedDayChange = useEventCallback(day => {
255
255
  if (day) {
256
256
  // If there is a date already selected, then we want to keep its time
257
- return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish');
257
+ return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish', view);
258
258
  }
259
- return handleValueChange(day, 'finish');
259
+ return handleValueChange(day, 'finish', view);
260
260
  });
261
261
  React.useEffect(() => {
262
262
  if (value != null && utils.isValid(value)) {
@@ -425,9 +425,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
425
425
  monthsPerRow: PropTypes.oneOf([3, 4]),
426
426
  /**
427
427
  * Callback fired when the value changes.
428
- * @template TDate
429
- * @param {TDate | null} value The new value.
428
+ * @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.
429
+ * @template TView The view type. Will be one of date or time views.
430
+ * @param {TValue} value The new value.
430
431
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
432
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
431
433
  */
432
434
  onChange: PropTypes.func,
433
435
  /**
@@ -6,7 +6,6 @@ import { PickersCalendarHeader, PickersCalendarHeaderProps, PickersCalendarHeade
6
6
  import { DayCalendarSlots, DayCalendarSlotProps, ExportedDayCalendarProps } from './DayCalendar';
7
7
  import { DateCalendarClasses } from './dateCalendarClasses';
8
8
  import { BaseDateValidationProps, YearValidationProps, MonthValidationProps, DayValidationProps } from '../internals/models/validation';
9
- import { PickerSelectionState } from '../internals/hooks/usePicker/usePickerValue.types';
10
9
  import { ExportedUseViewsOptions } from '../internals/hooks/useViews';
11
10
  import { DateView, TimezoneProps } from '../models';
12
11
  import { DefaultizedProps } from '../internals/models/helpers';
@@ -74,13 +73,6 @@ export interface DateCalendarProps<TDate> extends ExportedDateCalendarProps<TDat
74
73
  * @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`.
75
74
  */
76
75
  referenceDate?: TDate;
77
- /**
78
- * Callback fired when the value changes.
79
- * @template TDate
80
- * @param {TDate | null} value The new value.
81
- * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
82
- */
83
- onChange?: (value: TDate | null, selectionState?: PickerSelectionState) => void;
84
76
  className?: string;
85
77
  classes?: Partial<DateCalendarClasses>;
86
78
  /**
@@ -328,8 +328,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
328
328
  minutesStep: PropTypes.number,
329
329
  /**
330
330
  * Callback fired when the value changes.
331
- * @template TDate, TView
332
- * @param {TDate | null} value The new value.
331
+ * @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.
332
+ * @template TView The view type. Will be one of date or time views.
333
+ * @param {TValue} value The new value.
333
334
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
334
335
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
335
336
  */
@@ -122,7 +122,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
122
122
  }, [ampm, inViews]);
123
123
  const {
124
124
  view,
125
- setValueAndGoToView,
125
+ setValueAndGoToNextView,
126
126
  focusedView
127
127
  } = useViews({
128
128
  view: inView,
@@ -134,7 +134,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
134
134
  onFocusedViewChange
135
135
  });
136
136
  const handleMeridiemValueChange = useEventCallback(newValue => {
137
- setValueAndGoToView(newValue, null, 'meridiem');
137
+ setValueAndGoToNextView(newValue, 'finish', 'meridiem');
138
138
  });
139
139
  const {
140
140
  meridiemMode,
@@ -215,11 +215,6 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
215
215
  throw new Error('not supported');
216
216
  }
217
217
  }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
218
- const handleSectionChange = useEventCallback((sectionView, newValue) => {
219
- const viewIndex = views.indexOf(sectionView);
220
- const nextView = views[viewIndex + 1];
221
- setValueAndGoToView(newValue, nextView, sectionView);
222
- });
223
218
  const buildViewProps = React.useCallback(viewToBuild => {
224
219
  switch (viewToBuild) {
225
220
  case 'hours':
@@ -227,7 +222,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
227
222
  return {
228
223
  onChange: hours => {
229
224
  const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
230
- handleSectionChange('hours', utils.setHours(valueOrReferenceDate, valueWithMeridiem));
225
+ setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
231
226
  },
232
227
  items: getHourSectionOptions({
233
228
  now,
@@ -245,7 +240,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
245
240
  {
246
241
  return {
247
242
  onChange: minutes => {
248
- handleSectionChange('minutes', utils.setMinutes(valueOrReferenceDate, minutes));
243
+ setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
249
244
  },
250
245
  items: getTimeSectionOptions({
251
246
  value: utils.getMinutes(valueOrReferenceDate),
@@ -262,7 +257,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
262
257
  {
263
258
  return {
264
259
  onChange: seconds => {
265
- handleSectionChange('seconds', utils.setSeconds(valueOrReferenceDate, seconds));
260
+ setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
266
261
  },
267
262
  items: getTimeSectionOptions({
268
263
  value: utils.getSeconds(valueOrReferenceDate),
@@ -299,7 +294,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
299
294
  default:
300
295
  throw new Error(`Unknown view: ${viewToBuild} found.`);
301
296
  }
302
- }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
297
+ }, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
303
298
  const viewTimeOptions = React.useMemo(() => {
304
299
  return views.reduce((result, currentView) => {
305
300
  return _extends({}, result, {
@@ -397,8 +392,9 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
397
392
  minutesStep: PropTypes.number,
398
393
  /**
399
394
  * Callback fired when the value changes.
400
- * @template TDate, TView
401
- * @param {TDate | null} value The new value.
395
+ * @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.
396
+ * @template TView The view type. Will be one of date or time views.
397
+ * @param {TValue} value The new value.
402
398
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
403
399
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
404
400
  */
@@ -47,7 +47,7 @@ const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
47
47
  '&:not(:first-of-type)': {
48
48
  borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
49
49
  },
50
- '&:after': {
50
+ '&::after': {
51
51
  display: 'block',
52
52
  content: '""',
53
53
  // subtracting the height of one item, extra margin and borders to make sure the max height is correct
@@ -117,17 +117,13 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
117
117
  return;
118
118
  }
119
119
  const activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
120
+ if (active && autoFocus && activeItem) {
121
+ activeItem.focus();
122
+ }
120
123
  if (!activeItem || previousActive.current === activeItem) {
121
- // Handle setting the ref to null if the selected item is ever reset via UI
122
- if (previousActive.current !== activeItem) {
123
- previousActive.current = activeItem;
124
- }
125
124
  return;
126
125
  }
127
126
  previousActive.current = activeItem;
128
- if (active && autoFocus) {
129
- activeItem.focus();
130
- }
131
127
  const offsetTop = activeItem.offsetTop;
132
128
 
133
129
  // Subtracting the 4px of extra margin intended for the first visible section item
@@ -383,8 +383,9 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
383
383
  minutesStep: PropTypes.number,
384
384
  /**
385
385
  * Callback fired when the value changes.
386
- * @template TDate, TView
387
- * @param {TDate | null} value The new value.
386
+ * @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.
387
+ * @template TView The view type. Will be one of date or time views.
388
+ * @param {TValue} value The new value.
388
389
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
389
390
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
390
391
  */
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v7.0.0-alpha.6
2
+ * @mui/x-date-pickers v7.0.0-alpha.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -44,7 +44,7 @@ const FilledInputRoot = styled(PickersInputRoot, {
44
44
  backgroundColor: theme.vars ? theme.vars.palette.FilledInput.disabledBg : disabledBackground
45
45
  }
46
46
  }, !ownerState.disableUnderline && {
47
- '&:after': {
47
+ '&::after': {
48
48
  borderBottom: `2px solid ${(_palette = (theme.vars || theme).palette[ownerState.color || 'primary']) == null ? void 0 : _palette.main}`,
49
49
  left: 0,
50
50
  bottom: 0,
@@ -69,7 +69,7 @@ const FilledInputRoot = styled(PickersInputRoot, {
69
69
  borderBottomColor: (theme.vars || theme).palette.error.main
70
70
  }
71
71
  },
72
- '&:before': {
72
+ '&::before': {
73
73
  borderBottom: `1px solid ${theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})` : bottomLineColor}`,
74
74
  left: 0,
75
75
  bottom: 0,
@@ -26,7 +26,7 @@ const StandardInputRoot = styled(PickersInputRoot, {
26
26
  marginTop: 16
27
27
  }
28
28
  }, !ownerState.disableUnderline && {
29
- '&:after': {
29
+ '&::after': {
30
30
  background: 'red',
31
31
  borderBottom: `2px solid ${(theme.vars || theme).palette[ownerState.color].main}`,
32
32
  left: 0,
@@ -52,7 +52,7 @@ const StandardInputRoot = styled(PickersInputRoot, {
52
52
  borderBottomColor: (theme.vars || theme).palette.error.main
53
53
  }
54
54
  },
55
- '&:before': {
55
+ '&::before': {
56
56
  borderBottom: `1px solid ${bottomLineColor}`,
57
57
  left: 0,
58
58
  bottom: 0,
@@ -5,7 +5,8 @@ export type PickerOnChangeFn<TDate> = (date: TDate | null, selectionState?: Pick
5
5
  export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridiem> {
6
6
  /**
7
7
  * Callback fired when the value changes.
8
- * @template TValue
8
+ * @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.
9
+ * @template TView The view type. Will be one of date or time views.
9
10
  * @param {TValue} value The new value.
10
11
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
11
12
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
@@ -52,7 +53,7 @@ export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridie
52
53
  */
53
54
  onFocusedViewChange?: (view: TView, hasFocus: boolean) => void;
54
55
  }
55
- export interface ExportedUseViewsOptions<TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<Omit<UseViewsOptions<any, TView>, 'onChange'>, 'openTo' | 'views'> {
56
+ export interface ExportedUseViewsOptions<TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<UseViewsOptions<any, TView>, 'onChange' | 'openTo' | 'views'> {
56
57
  }
57
58
  interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
58
59
  view: TView;
@@ -63,8 +64,7 @@ interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
63
64
  previousView: TView | null;
64
65
  defaultView: TView;
65
66
  goToNextView: () => void;
66
- setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState) => void;
67
- setValueAndGoToView: (value: TValue, newView: TView | null, selectedView: TView) => void;
67
+ setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState, selectedView?: TView) => void;
68
68
  }
69
69
  export declare function useViews<TValue, TView extends DateOrTimeViewWithMeridiem>({ onChange, onViewChange, openTo, view: inView, views, autoFocus, focusedView: inFocusedView, onFocusedViewChange, }: UseViewsOptions<TValue, TView>): UseViewsResponse<TValue, TView>;
70
70
  export {};
@@ -64,11 +64,12 @@ export function useViews({
64
64
  onFocusedViewChange == null || onFocusedViewChange(viewToFocus, hasFocus);
65
65
  });
66
66
  const handleChangeView = useEventCallback(newView => {
67
+ // always keep the focused view in sync
68
+ handleFocusedViewChange(newView, true);
67
69
  if (newView === view) {
68
70
  return;
69
71
  }
70
72
  setView(newView);
71
- handleFocusedViewChange(newView, true);
72
73
  if (onViewChange) {
73
74
  onViewChange(newView);
74
75
  }
@@ -77,7 +78,6 @@ export function useViews({
77
78
  if (nextView) {
78
79
  handleChangeView(nextView);
79
80
  }
80
- handleFocusedViewChange(nextView, true);
81
81
  });
82
82
  const setValueAndGoToNextView = useEventCallback((value, currentViewSelectionState, selectedView) => {
83
83
  const isSelectionFinishedOnCurrentView = currentViewSelectionState === 'finish';
@@ -86,18 +86,19 @@ export function useViews({
86
86
  // but when it's not the final view given all `views` -> overall selection state should be `partial`.
87
87
  views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
88
88
  const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? 'partial' : currentViewSelectionState;
89
- onChange(value, globalSelectionState);
90
- if (isSelectionFinishedOnCurrentView) {
89
+ onChange(value, globalSelectionState, selectedView);
90
+ // Detects if the selected view is not the active one.
91
+ // Can happen if multiple views are displayed, like in `DesktopDateTimePicker` or `MultiSectionDigitalClock`.
92
+ if (selectedView && selectedView !== view) {
93
+ const nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
94
+ if (nextViewAfterSelected) {
95
+ // move to next view after the selected one
96
+ handleChangeView(nextViewAfterSelected);
97
+ }
98
+ } else if (isSelectionFinishedOnCurrentView) {
91
99
  goToNextView();
92
100
  }
93
101
  });
94
- const setValueAndGoToView = useEventCallback((value, newView, selectedView) => {
95
- onChange(value, newView ? 'partial' : 'finish', selectedView);
96
- if (newView) {
97
- handleChangeView(newView);
98
- handleFocusedViewChange(newView, true);
99
- }
100
- });
101
102
  return {
102
103
  view,
103
104
  setView: handleChangeView,
@@ -108,7 +109,6 @@ export function useViews({
108
109
  // Always return up-to-date default view instead of the initial one (i.e. defaultView.current)
109
110
  defaultView: views.includes(openTo) ? openTo : views[0],
110
111
  goToNextView,
111
- setValueAndGoToNextView,
112
- setValueAndGoToView
112
+ setValueAndGoToNextView
113
113
  };
114
114
  }
@@ -1,6 +1,5 @@
1
1
  import { SxProps, Theme } from '@mui/material/styles';
2
2
  import { BaseTimeValidationProps, TimeValidationProps } from '../validation';
3
- import { PickerSelectionState } from '../../hooks/usePicker/usePickerValue.types';
4
3
  import { TimeStepOptions, TimezoneProps } from '../../../models';
5
4
  import type { ExportedDigitalClockProps } from '../../../DigitalClock/DigitalClock.types';
6
5
  import type { ExportedMultiSectionDigitalClockProps } from '../../../MultiSectionDigitalClock/MultiSectionDigitalClock.types';
@@ -29,14 +28,6 @@ export interface BaseClockProps<TDate, TView extends TimeViewWithMeridiem> exten
29
28
  * Used when the component is not controlled.
30
29
  */
31
30
  defaultValue?: TDate | null;
32
- /**
33
- * Callback fired when the value changes.
34
- * @template TDate, TView
35
- * @param {TDate | null} value The new value.
36
- * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
37
- * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
38
- */
39
- onChange?: (value: TDate | null, selectionState?: PickerSelectionState, selectedView?: TView) => void;
40
31
  /**
41
32
  * If `true`, the picker views and text field are disabled.
42
33
  * @default false
@@ -255,9 +255,9 @@ export var DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(in
255
255
  var handleSelectedDayChange = useEventCallback(function (day) {
256
256
  if (day) {
257
257
  // If there is a date already selected, then we want to keep its time
258
- return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish');
258
+ return handleValueChange(mergeDateAndTime(utils, day, value != null ? value : referenceDate), 'finish', view);
259
259
  }
260
- return handleValueChange(day, 'finish');
260
+ return handleValueChange(day, 'finish', view);
261
261
  });
262
262
  React.useEffect(function () {
263
263
  if (value != null && utils.isValid(value)) {
@@ -434,9 +434,11 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
434
434
  monthsPerRow: PropTypes.oneOf([3, 4]),
435
435
  /**
436
436
  * Callback fired when the value changes.
437
- * @template TDate
438
- * @param {TDate | null} value The new value.
437
+ * @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.
438
+ * @template TView The view type. Will be one of date or time views.
439
+ * @param {TValue} value The new value.
439
440
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
441
+ * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
440
442
  */
441
443
  onChange: PropTypes.func,
442
444
  /**
@@ -347,8 +347,9 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
347
347
  minutesStep: PropTypes.number,
348
348
  /**
349
349
  * Callback fired when the value changes.
350
- * @template TDate, TView
351
- * @param {TDate | null} value The new value.
350
+ * @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.
351
+ * @template TView The view type. Will be one of date or time views.
352
+ * @param {TValue} value The new value.
352
353
  * @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
353
354
  * @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
354
355
  */