@mui/x-date-pickers-pro 8.0.0-alpha.10 → 8.0.0-alpha.11
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.
- package/CHANGELOG.md +107 -2
- package/DateRangeCalendar/DateRangeCalendar.js +59 -34
- package/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +2 -0
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +2 -2
- package/index.js +1 -1
- package/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +1 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +59 -34
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +2 -0
- package/modern/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +1 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/node/DateRangeCalendar/DateRangeCalendar.js +58 -33
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +2 -0
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +2 -0
- package/node/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +1 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,110 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## **8.0.0-alpha.11**
|
|
9
|
+
|
|
10
|
+
_Feb 7, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- ⚡ Mount and resize performance improvements for the Data Grid
|
|
15
|
+
|
|
16
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
17
|
+
@lauri865.
|
|
18
|
+
Following are all team members who have contributed to this release:
|
|
19
|
+
@alexfauquette, @arminmeh, @bernardobelchior, @flaviendelangle, @Janpot, @KenanYusuf, @LukasTy, @MBilalShafi, @noraleonte, @romgrk.
|
|
20
|
+
|
|
21
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### Breaking changes
|
|
26
|
+
|
|
27
|
+
- `createUseGridApiEventHandler()` is not exported anymore.
|
|
28
|
+
- The `filteredRowsLookup` object of the filter state does not contain `true` values anymore. If the row is filtered out, the value is `false`. Otherwise, the row id is not present in the object.
|
|
29
|
+
This change only impacts you if you relied on `filteredRowsLookup` to get ids of filtered rows. In this case,use `gridDataRowIdsSelector` selector to get row ids and check `filteredRowsLookup` for `false` values:
|
|
30
|
+
|
|
31
|
+
```diff
|
|
32
|
+
const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
|
|
33
|
+
-const filteredRowIds = Object.keys(filteredRowsLookup).filter((rowId) => filteredRowsLookup[rowId] === true);
|
|
34
|
+
+const rowIds = gridDataRowIdsSelector(apiRef);
|
|
35
|
+
+const filteredRowIds = rowIds.filter((rowId) => filteredRowsLookup[rowId] !== false);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- The `visibleRowsLookup` state does not contain `true` values anymore. If the row is not visible, the value is `false`. Otherwise, the row id is not present in the object:
|
|
39
|
+
|
|
40
|
+
```diff
|
|
41
|
+
const visibleRowsLookup = gridVisibleRowsLookupSelector(apiRef);
|
|
42
|
+
-const isRowVisible = visibleRowsLookup[rowId] === true;
|
|
43
|
+
+const isRowVisible = visibleRowsLookup[rowId] !== false;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### `@mui/x-data-grid@8.0.0-alpha.11`
|
|
47
|
+
|
|
48
|
+
- [DataGrid] Avoid `<GridRoot />` double-render pass on mount in SPA mode (#15648) @lauri865
|
|
49
|
+
- [DataGrid] Fix loading overlay not in sync with scroll (#16437) @MBilalShafi
|
|
50
|
+
- [DataGrid] Refactor: remove material `MenuList` import (#16444) @romgrk
|
|
51
|
+
- [DataGrid] Refactor: simplify `useGridApiEventHandler()` (#16479) @romgrk
|
|
52
|
+
|
|
53
|
+
#### `@mui/x-data-grid-pro@8.0.0-alpha.11` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
54
|
+
|
|
55
|
+
Same changes as in `@mui/x-data-grid@8.0.0-alpha.11`, plus:
|
|
56
|
+
|
|
57
|
+
- [DataGridPro] Fix the return type of `useGridApiContext()` for Pro and Premium packages on React < 19 (#16441) @arminmeh
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-data-grid-premium@8.0.0-alpha.11` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
60
|
+
|
|
61
|
+
Same changes as in `@mui/x-data-grid-pro@8.0.0-alpha.11`, plus:
|
|
62
|
+
|
|
63
|
+
- [DataGridPremium] Fix "no rows" overlay not showing with active aggregation (#16466) @KenanYusuf
|
|
64
|
+
|
|
65
|
+
### Date and Time Pickers
|
|
66
|
+
|
|
67
|
+
#### `@mui/x-date-pickers@8.0.0-alpha.11`
|
|
68
|
+
|
|
69
|
+
Internal changes.
|
|
70
|
+
|
|
71
|
+
#### `@mui/x-date-pickers-pro@8.0.0-alpha.11` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
72
|
+
|
|
73
|
+
Same changes as in `@mui/x-date-pickers@8.0.0-alpha.11`, plus:
|
|
74
|
+
|
|
75
|
+
- [DateRangeCalendar] Support arrow navigation with multiple months rendered (#16363) @flaviendelangle
|
|
76
|
+
- [DateRangePicker] Fix `currentMonthCalendarPosition` prop behavior on mobile (#16455) @LukasTy
|
|
77
|
+
- [DateRangePicker] Fix vertical alignment for multi input fields (#16489) @noraleonte
|
|
78
|
+
|
|
79
|
+
### Charts
|
|
80
|
+
|
|
81
|
+
#### `@mui/x-charts@8.0.0-alpha.11`
|
|
82
|
+
|
|
83
|
+
- [charts] Add `color` prop to `Sparkline` and deprecate `colors` (#16477) @bernardobelchior
|
|
84
|
+
- [charts] Make typescript more flexible about plugins and their params (#16478) @alexfauquette
|
|
85
|
+
- [charts] Remove component for axis event listener (#16314) @alexfauquette
|
|
86
|
+
|
|
87
|
+
#### `@mui/x-charts-pro@8.0.0-alpha.11` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
88
|
+
|
|
89
|
+
Same changes as in `@mui/x-charts@8.0.0-alpha.11`.
|
|
90
|
+
|
|
91
|
+
### Tree View
|
|
92
|
+
|
|
93
|
+
#### `@mui/x-tree-view@8.0.0-alpha.11`
|
|
94
|
+
|
|
95
|
+
Internal changes.
|
|
96
|
+
|
|
97
|
+
#### `@mui/x-tree-view-pro@8.0.0-alpha.11` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
98
|
+
|
|
99
|
+
Same changes as in `@mui/x-tree-view@8.0.0-alpha.11`.
|
|
100
|
+
|
|
101
|
+
### Docs
|
|
102
|
+
|
|
103
|
+
- [docs] Update charts colors default value (#16484) @bernardobelchior
|
|
104
|
+
|
|
105
|
+
### Core
|
|
106
|
+
|
|
107
|
+
- [core] Fix corepack and pnpm installation in CircleCI (#16434) @flaviendelangle
|
|
108
|
+
- [code-infra] Update monorepo (#16112) @Janpot
|
|
109
|
+
- [test] Avoid test warning when running on React 18 (#16486) @LukasTy
|
|
110
|
+
- [test] Disable `react-transition-group` transitions in unit testing (#16288) @lauri865
|
|
111
|
+
|
|
8
112
|
## 8.0.0-alpha.10
|
|
9
113
|
|
|
10
114
|
_Jan 30, 2025_
|
|
@@ -50,6 +154,7 @@ Following are all team members who have contributed to this release:
|
|
|
50
154
|
+ },
|
|
51
155
|
});
|
|
52
156
|
```
|
|
157
|
+
|
|
53
158
|
- The `detailPanels`, `pinnedColumns`, and `pinnedRowsRenderZone` classes have been removed.
|
|
54
159
|
- Return type of the `useGridApiRef()` hook and the type of `apiRef` prop are updated to explicitly include the possibilty of `null`. In addition to this, `useGridApiRef()` returns a reference that is initialized with `null` instead of `{}`.
|
|
55
160
|
|
|
@@ -91,7 +196,7 @@ Same changes as in `@mui/x-data-grid-pro@8.0.0-alpha.10`.
|
|
|
91
196
|
|
|
92
197
|
#### Breaking changes
|
|
93
198
|
|
|
94
|
-
- The component passed to the `field` slot no longer receives the `ref`,
|
|
199
|
+
- The component passed to the `field` slot no longer receives the `ref`, `disabled`, `className`, `sx`, `label`, `name`, `formatDensity`, `enableAccessibleFieldDOMStructure`, `selectedSections`, `onSelectedSectionsChange` and `inputRef` props — [Learn more](https://next.mui.com/x/migration/migration-pickers-v7/#slot-field)
|
|
95
200
|
- The `MuiPickersPopper` theme entry have been renamed `MuiPickerPopper` and some of its props have been removed — [Learn more](https://next.mui.com/x/migration/migration-pickers-v7/#muipickerspopper)
|
|
96
201
|
|
|
97
202
|
#### `@mui/x-date-pickers@8.0.0-alpha.10`
|
|
@@ -111,7 +216,7 @@ Same changes as in `@mui/x-date-pickers@8.0.0-alpha.10`.
|
|
|
111
216
|
|
|
112
217
|
- Replace `legend.position.horizontal` from `"left" | "middle" | "right"` to `"start" | "center" | "end"`.
|
|
113
218
|
This is to align with the CSS values and reflect the RTL ability of the legend component.
|
|
114
|
-
- The default colors have changed. To keep using the old palette. It is possible to import `blueberryTwilightPalette` from
|
|
219
|
+
- The default colors have changed. To keep using the old palette. It is possible to import `blueberryTwilightPalette` from `@mui/x-charts/colorPalettes` and set it on the `colors` property of charts.
|
|
115
220
|
- The `id` property is now optional on the `Pie` and `Scatter` data types.
|
|
116
221
|
|
|
117
222
|
#### `@mui/x-charts@8.0.0-alpha.10`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
5
|
+
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "focusedView", "onFocusedViewChange", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
6
6
|
_excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -15,7 +15,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
15
15
|
import composeClasses from '@mui/utils/composeClasses';
|
|
16
16
|
import useId from '@mui/utils/useId';
|
|
17
17
|
import { Watermark } from '@mui/x-license';
|
|
18
|
-
import { applyDefaultDate, DayCalendar, useReduceAnimations, useCalendarState, useDefaultDates, useUtils,
|
|
18
|
+
import { applyDefaultDate, DayCalendar, useReduceAnimations, useCalendarState, useDefaultDates, useUtils, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, useControlledValueWithTimezone, useViews, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
|
|
19
19
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
20
20
|
import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
|
|
21
21
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from "./dateRangeCalendarClasses.js";
|
|
@@ -145,6 +145,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
145
145
|
loading,
|
|
146
146
|
renderLoading,
|
|
147
147
|
disableHighlightToday,
|
|
148
|
+
focusedView: focusedViewProp,
|
|
149
|
+
onFocusedViewChange,
|
|
148
150
|
readOnly,
|
|
149
151
|
disabled,
|
|
150
152
|
showDaysOutsideCurrentMonth,
|
|
@@ -177,18 +179,21 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
177
179
|
valueManager: rangeValueManager
|
|
178
180
|
});
|
|
179
181
|
const {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
view,
|
|
183
|
+
setFocusedView,
|
|
184
|
+
focusedView,
|
|
185
|
+
setValueAndGoToNextView
|
|
182
186
|
} = useViews({
|
|
183
187
|
view: inView,
|
|
184
188
|
views,
|
|
185
189
|
openTo,
|
|
186
190
|
onChange: handleValueChange,
|
|
187
191
|
onViewChange,
|
|
188
|
-
autoFocus
|
|
192
|
+
autoFocus,
|
|
193
|
+
focusedView: focusedViewProp,
|
|
194
|
+
onFocusedViewChange
|
|
189
195
|
});
|
|
190
196
|
const utils = useUtils();
|
|
191
|
-
const now = useNow(timezone);
|
|
192
197
|
const id = useId();
|
|
193
198
|
const {
|
|
194
199
|
rangePosition,
|
|
@@ -273,22 +278,39 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
273
278
|
}, [shouldDisableDate, rangePosition, draggingDatePosition]);
|
|
274
279
|
const {
|
|
275
280
|
calendarState,
|
|
276
|
-
|
|
277
|
-
changeMonth,
|
|
278
|
-
handleChangeMonth,
|
|
281
|
+
setVisibleDate,
|
|
279
282
|
onMonthSwitchingAnimationEnd
|
|
280
283
|
} = useCalendarState({
|
|
281
284
|
value: value[0] || value[1],
|
|
282
285
|
referenceDate,
|
|
283
286
|
disableFuture,
|
|
284
287
|
disablePast,
|
|
285
|
-
disableSwitchToMonthOnDayFocus: true,
|
|
286
288
|
maxDate,
|
|
287
289
|
minDate,
|
|
288
290
|
onMonthChange,
|
|
289
291
|
reduceAnimations,
|
|
290
292
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
291
|
-
timezone
|
|
293
|
+
timezone,
|
|
294
|
+
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
295
|
+
const firstVisibleMonth = utils.addMonths(prevMonth, 1 - currentMonthCalendarPosition);
|
|
296
|
+
const lastVisibleMonth = utils.endOfMonth(utils.addMonths(firstVisibleMonth, calendars - 1));
|
|
297
|
+
|
|
298
|
+
// The new focused day is inside the visible calendars,
|
|
299
|
+
// Do not change the current month
|
|
300
|
+
if (utils.isWithinRange(visibleDate, [firstVisibleMonth, lastVisibleMonth])) {
|
|
301
|
+
return prevMonth;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// The new focused day is after the last visible month,
|
|
305
|
+
// Move the current month so that the new focused day is inside the first visible month
|
|
306
|
+
if (utils.isAfter(visibleDate, lastVisibleMonth)) {
|
|
307
|
+
return utils.startOfMonth(utils.addMonths(visibleDate, currentMonthCalendarPosition - 1));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// The new focused day is before the first visible month,
|
|
311
|
+
// Move the current month so that the new focused day is inside the last visible month
|
|
312
|
+
return utils.startOfMonth(utils.addMonths(visibleDate, currentMonthCalendarPosition - calendars));
|
|
313
|
+
}
|
|
292
314
|
});
|
|
293
315
|
const CalendarHeader = slots?.calendarHeader ?? PickersRangeCalendarHeader;
|
|
294
316
|
const calendarHeaderProps = useSlotProps({
|
|
@@ -299,9 +321,9 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
299
321
|
views: ['day'],
|
|
300
322
|
view: 'day',
|
|
301
323
|
currentMonth: calendarState.currentMonth,
|
|
302
|
-
onMonthChange:
|
|
303
|
-
|
|
304
|
-
|
|
324
|
+
onMonthChange: month => setVisibleDate({
|
|
325
|
+
target: month,
|
|
326
|
+
reason: 'header-navigation'
|
|
305
327
|
}),
|
|
306
328
|
minDate,
|
|
307
329
|
maxDate,
|
|
@@ -315,6 +337,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
315
337
|
},
|
|
316
338
|
ownerState
|
|
317
339
|
});
|
|
340
|
+
|
|
341
|
+
// TODO: Move this logic inside the render instead of using an effect
|
|
318
342
|
const prevValue = React.useRef(null);
|
|
319
343
|
React.useEffect(() => {
|
|
320
344
|
const date = rangePosition === 'start' ? value[0] : value[1];
|
|
@@ -336,7 +360,10 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
336
360
|
const newMonth = rangePosition === 'start' ? date :
|
|
337
361
|
// If need to focus end, scroll to the state when "end" is displaying in the last calendar
|
|
338
362
|
utils.addMonths(date, -displayingMonthRange);
|
|
339
|
-
|
|
363
|
+
setVisibleDate({
|
|
364
|
+
target: newMonth,
|
|
365
|
+
reason: 'controlled-value-change'
|
|
366
|
+
});
|
|
340
367
|
}
|
|
341
368
|
}, [rangePosition, value]); // eslint-disable-line
|
|
342
369
|
|
|
@@ -419,25 +446,19 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
419
446
|
length: calendars
|
|
420
447
|
}).map((_, index) => utils.addMonths(firstMonth, index));
|
|
421
448
|
}, [utils, calendarState.currentMonth, calendars, currentMonthCalendarPosition]);
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
// 2. Month of the `end` date
|
|
430
|
-
// 3. Month of the current date
|
|
431
|
-
// 4. First visible month
|
|
432
|
-
|
|
433
|
-
if (value[0] != null) {
|
|
434
|
-
return visibleMonths.find(month => utils.isSameMonth(month, value[0]));
|
|
449
|
+
const hasFocus = focusedView !== null;
|
|
450
|
+
const prevOpenViewRef = React.useRef(view);
|
|
451
|
+
React.useEffect(() => {
|
|
452
|
+
// If the view change and the focus was on the previous view
|
|
453
|
+
// Then we update the focus.
|
|
454
|
+
if (prevOpenViewRef.current === view) {
|
|
455
|
+
return;
|
|
435
456
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
457
|
+
if (focusedView === prevOpenViewRef.current) {
|
|
458
|
+
setFocusedView(view, true);
|
|
438
459
|
}
|
|
439
|
-
|
|
440
|
-
}, [
|
|
460
|
+
prevOpenViewRef.current = view;
|
|
461
|
+
}, [focusedView, setFocusedView, view]);
|
|
441
462
|
return /*#__PURE__*/_jsxs(DateRangeCalendarRoot, _extends({
|
|
442
463
|
ref: ref,
|
|
443
464
|
className: clsx(classes.root, className),
|
|
@@ -459,20 +480,24 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
459
480
|
className: classes.dayCalendar
|
|
460
481
|
}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
461
482
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
462
|
-
onFocusedDayChange:
|
|
483
|
+
onFocusedDayChange: focusedDate => setVisibleDate({
|
|
484
|
+
target: focusedDate,
|
|
485
|
+
reason: 'cell-interaction'
|
|
486
|
+
}),
|
|
463
487
|
reduceAnimations: reduceAnimations,
|
|
464
488
|
selectedDays: value,
|
|
465
489
|
onSelectedDaysChange: handleSelectedDayChange,
|
|
466
490
|
currentMonth: month,
|
|
467
491
|
TransitionProps: CalendarTransitionProps,
|
|
468
492
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
493
|
+
hasFocus: hasFocus,
|
|
494
|
+
onFocusedViewChange: isViewFocused => setFocusedView('day', isViewFocused),
|
|
469
495
|
showDaysOutsideCurrentMonth: calendars === 1 && showDaysOutsideCurrentMonth,
|
|
470
496
|
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
471
497
|
loading: loading,
|
|
472
498
|
renderLoading: renderLoading,
|
|
473
499
|
slots: slotsForDayCalendar,
|
|
474
500
|
slotProps: slotPropsForDayCalendar,
|
|
475
|
-
autoFocus: month === focusedMonth,
|
|
476
501
|
fixedWeekNumber: fixedWeekNumber,
|
|
477
502
|
displayWeekNumber: displayWeekNumber,
|
|
478
503
|
timezone: timezone,
|
|
@@ -36,6 +36,8 @@ const MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateR
|
|
|
36
36
|
format: utils.formats.keyboardDate,
|
|
37
37
|
// Force one calendar on mobile to avoid layout issues
|
|
38
38
|
calendars: 1,
|
|
39
|
+
// force current calendar position, since we only have one calendar
|
|
40
|
+
currentMonthCalendarPosition: 1,
|
|
39
41
|
views: ['day'],
|
|
40
42
|
openTo: 'day',
|
|
41
43
|
slots: _extends({
|
|
@@ -110,6 +110,8 @@ const MobileDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function MobileD
|
|
|
110
110
|
calendars: 1,
|
|
111
111
|
// force true to correctly handle `renderTimeViewClock` as a renderer
|
|
112
112
|
ampmInClock: true,
|
|
113
|
+
// force current calendar position, since we only have one calendar
|
|
114
|
+
currentMonthCalendarPosition: 1,
|
|
113
115
|
slots: _extends({
|
|
114
116
|
field: MultiInputDateTimeRangeField
|
|
115
117
|
}, defaultizedProps.slots),
|
|
@@ -57,8 +57,8 @@ const PickersRangeCalendarHeader = /*#__PURE__*/React.forwardRef(function Picker
|
|
|
57
57
|
ref: ref
|
|
58
58
|
}));
|
|
59
59
|
}
|
|
60
|
-
const selectNextMonth = () => onMonthChange(utils.addMonths(currentMonth, 1)
|
|
61
|
-
const selectPreviousMonth = () => onMonthChange(utils.addMonths(currentMonth, -1)
|
|
60
|
+
const selectNextMonth = () => onMonthChange(utils.addMonths(currentMonth, 1));
|
|
61
|
+
const selectPreviousMonth = () => onMonthChange(utils.addMonths(currentMonth, -1));
|
|
62
62
|
return /*#__PURE__*/_jsx(PickersRangeCalendarHeaderContentMultipleCalendars, _extends({}, otherRangeProps, {
|
|
63
63
|
ref: ref,
|
|
64
64
|
onGoToPrevious: selectPreviousMonth,
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczODg4MjgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
5
|
+
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "focusedView", "onFocusedViewChange", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
6
6
|
_excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -15,7 +15,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
15
15
|
import composeClasses from '@mui/utils/composeClasses';
|
|
16
16
|
import useId from '@mui/utils/useId';
|
|
17
17
|
import { Watermark } from '@mui/x-license';
|
|
18
|
-
import { applyDefaultDate, DayCalendar, useReduceAnimations, useCalendarState, useDefaultDates, useUtils,
|
|
18
|
+
import { applyDefaultDate, DayCalendar, useReduceAnimations, useCalendarState, useDefaultDates, useUtils, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, useControlledValueWithTimezone, useViews, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
|
|
19
19
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
20
20
|
import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
|
|
21
21
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from "./dateRangeCalendarClasses.js";
|
|
@@ -145,6 +145,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
145
145
|
loading,
|
|
146
146
|
renderLoading,
|
|
147
147
|
disableHighlightToday,
|
|
148
|
+
focusedView: focusedViewProp,
|
|
149
|
+
onFocusedViewChange,
|
|
148
150
|
readOnly,
|
|
149
151
|
disabled,
|
|
150
152
|
showDaysOutsideCurrentMonth,
|
|
@@ -177,18 +179,21 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
177
179
|
valueManager: rangeValueManager
|
|
178
180
|
});
|
|
179
181
|
const {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
view,
|
|
183
|
+
setFocusedView,
|
|
184
|
+
focusedView,
|
|
185
|
+
setValueAndGoToNextView
|
|
182
186
|
} = useViews({
|
|
183
187
|
view: inView,
|
|
184
188
|
views,
|
|
185
189
|
openTo,
|
|
186
190
|
onChange: handleValueChange,
|
|
187
191
|
onViewChange,
|
|
188
|
-
autoFocus
|
|
192
|
+
autoFocus,
|
|
193
|
+
focusedView: focusedViewProp,
|
|
194
|
+
onFocusedViewChange
|
|
189
195
|
});
|
|
190
196
|
const utils = useUtils();
|
|
191
|
-
const now = useNow(timezone);
|
|
192
197
|
const id = useId();
|
|
193
198
|
const {
|
|
194
199
|
rangePosition,
|
|
@@ -273,22 +278,39 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
273
278
|
}, [shouldDisableDate, rangePosition, draggingDatePosition]);
|
|
274
279
|
const {
|
|
275
280
|
calendarState,
|
|
276
|
-
|
|
277
|
-
changeMonth,
|
|
278
|
-
handleChangeMonth,
|
|
281
|
+
setVisibleDate,
|
|
279
282
|
onMonthSwitchingAnimationEnd
|
|
280
283
|
} = useCalendarState({
|
|
281
284
|
value: value[0] || value[1],
|
|
282
285
|
referenceDate,
|
|
283
286
|
disableFuture,
|
|
284
287
|
disablePast,
|
|
285
|
-
disableSwitchToMonthOnDayFocus: true,
|
|
286
288
|
maxDate,
|
|
287
289
|
minDate,
|
|
288
290
|
onMonthChange,
|
|
289
291
|
reduceAnimations,
|
|
290
292
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
291
|
-
timezone
|
|
293
|
+
timezone,
|
|
294
|
+
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
295
|
+
const firstVisibleMonth = utils.addMonths(prevMonth, 1 - currentMonthCalendarPosition);
|
|
296
|
+
const lastVisibleMonth = utils.endOfMonth(utils.addMonths(firstVisibleMonth, calendars - 1));
|
|
297
|
+
|
|
298
|
+
// The new focused day is inside the visible calendars,
|
|
299
|
+
// Do not change the current month
|
|
300
|
+
if (utils.isWithinRange(visibleDate, [firstVisibleMonth, lastVisibleMonth])) {
|
|
301
|
+
return prevMonth;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// The new focused day is after the last visible month,
|
|
305
|
+
// Move the current month so that the new focused day is inside the first visible month
|
|
306
|
+
if (utils.isAfter(visibleDate, lastVisibleMonth)) {
|
|
307
|
+
return utils.startOfMonth(utils.addMonths(visibleDate, currentMonthCalendarPosition - 1));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// The new focused day is before the first visible month,
|
|
311
|
+
// Move the current month so that the new focused day is inside the last visible month
|
|
312
|
+
return utils.startOfMonth(utils.addMonths(visibleDate, currentMonthCalendarPosition - calendars));
|
|
313
|
+
}
|
|
292
314
|
});
|
|
293
315
|
const CalendarHeader = slots?.calendarHeader ?? PickersRangeCalendarHeader;
|
|
294
316
|
const calendarHeaderProps = useSlotProps({
|
|
@@ -299,9 +321,9 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
299
321
|
views: ['day'],
|
|
300
322
|
view: 'day',
|
|
301
323
|
currentMonth: calendarState.currentMonth,
|
|
302
|
-
onMonthChange:
|
|
303
|
-
|
|
304
|
-
|
|
324
|
+
onMonthChange: month => setVisibleDate({
|
|
325
|
+
target: month,
|
|
326
|
+
reason: 'header-navigation'
|
|
305
327
|
}),
|
|
306
328
|
minDate,
|
|
307
329
|
maxDate,
|
|
@@ -315,6 +337,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
315
337
|
},
|
|
316
338
|
ownerState
|
|
317
339
|
});
|
|
340
|
+
|
|
341
|
+
// TODO: Move this logic inside the render instead of using an effect
|
|
318
342
|
const prevValue = React.useRef(null);
|
|
319
343
|
React.useEffect(() => {
|
|
320
344
|
const date = rangePosition === 'start' ? value[0] : value[1];
|
|
@@ -336,7 +360,10 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
336
360
|
const newMonth = rangePosition === 'start' ? date :
|
|
337
361
|
// If need to focus end, scroll to the state when "end" is displaying in the last calendar
|
|
338
362
|
utils.addMonths(date, -displayingMonthRange);
|
|
339
|
-
|
|
363
|
+
setVisibleDate({
|
|
364
|
+
target: newMonth,
|
|
365
|
+
reason: 'controlled-value-change'
|
|
366
|
+
});
|
|
340
367
|
}
|
|
341
368
|
}, [rangePosition, value]); // eslint-disable-line
|
|
342
369
|
|
|
@@ -419,25 +446,19 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
419
446
|
length: calendars
|
|
420
447
|
}).map((_, index) => utils.addMonths(firstMonth, index));
|
|
421
448
|
}, [utils, calendarState.currentMonth, calendars, currentMonthCalendarPosition]);
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
// 2. Month of the `end` date
|
|
430
|
-
// 3. Month of the current date
|
|
431
|
-
// 4. First visible month
|
|
432
|
-
|
|
433
|
-
if (value[0] != null) {
|
|
434
|
-
return visibleMonths.find(month => utils.isSameMonth(month, value[0]));
|
|
449
|
+
const hasFocus = focusedView !== null;
|
|
450
|
+
const prevOpenViewRef = React.useRef(view);
|
|
451
|
+
React.useEffect(() => {
|
|
452
|
+
// If the view change and the focus was on the previous view
|
|
453
|
+
// Then we update the focus.
|
|
454
|
+
if (prevOpenViewRef.current === view) {
|
|
455
|
+
return;
|
|
435
456
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
457
|
+
if (focusedView === prevOpenViewRef.current) {
|
|
458
|
+
setFocusedView(view, true);
|
|
438
459
|
}
|
|
439
|
-
|
|
440
|
-
}, [
|
|
460
|
+
prevOpenViewRef.current = view;
|
|
461
|
+
}, [focusedView, setFocusedView, view]);
|
|
441
462
|
return /*#__PURE__*/_jsxs(DateRangeCalendarRoot, _extends({
|
|
442
463
|
ref: ref,
|
|
443
464
|
className: clsx(classes.root, className),
|
|
@@ -459,20 +480,24 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
459
480
|
className: classes.dayCalendar
|
|
460
481
|
}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
461
482
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
462
|
-
onFocusedDayChange:
|
|
483
|
+
onFocusedDayChange: focusedDate => setVisibleDate({
|
|
484
|
+
target: focusedDate,
|
|
485
|
+
reason: 'cell-interaction'
|
|
486
|
+
}),
|
|
463
487
|
reduceAnimations: reduceAnimations,
|
|
464
488
|
selectedDays: value,
|
|
465
489
|
onSelectedDaysChange: handleSelectedDayChange,
|
|
466
490
|
currentMonth: month,
|
|
467
491
|
TransitionProps: CalendarTransitionProps,
|
|
468
492
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
493
|
+
hasFocus: hasFocus,
|
|
494
|
+
onFocusedViewChange: isViewFocused => setFocusedView('day', isViewFocused),
|
|
469
495
|
showDaysOutsideCurrentMonth: calendars === 1 && showDaysOutsideCurrentMonth,
|
|
470
496
|
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
471
497
|
loading: loading,
|
|
472
498
|
renderLoading: renderLoading,
|
|
473
499
|
slots: slotsForDayCalendar,
|
|
474
500
|
slotProps: slotPropsForDayCalendar,
|
|
475
|
-
autoFocus: month === focusedMonth,
|
|
476
501
|
fixedWeekNumber: fixedWeekNumber,
|
|
477
502
|
displayWeekNumber: displayWeekNumber,
|
|
478
503
|
timezone: timezone,
|
|
@@ -36,6 +36,8 @@ const MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateR
|
|
|
36
36
|
format: utils.formats.keyboardDate,
|
|
37
37
|
// Force one calendar on mobile to avoid layout issues
|
|
38
38
|
calendars: 1,
|
|
39
|
+
// force current calendar position, since we only have one calendar
|
|
40
|
+
currentMonthCalendarPosition: 1,
|
|
39
41
|
views: ['day'],
|
|
40
42
|
openTo: 'day',
|
|
41
43
|
slots: _extends({
|
|
@@ -110,6 +110,8 @@ const MobileDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function MobileD
|
|
|
110
110
|
calendars: 1,
|
|
111
111
|
// force true to correctly handle `renderTimeViewClock` as a renderer
|
|
112
112
|
ampmInClock: true,
|
|
113
|
+
// force current calendar position, since we only have one calendar
|
|
114
|
+
currentMonthCalendarPosition: 1,
|
|
113
115
|
slots: _extends({
|
|
114
116
|
field: MultiInputDateTimeRangeField
|
|
115
117
|
}, defaultizedProps.slots),
|
|
@@ -57,8 +57,8 @@ const PickersRangeCalendarHeader = /*#__PURE__*/React.forwardRef(function Picker
|
|
|
57
57
|
ref: ref
|
|
58
58
|
}));
|
|
59
59
|
}
|
|
60
|
-
const selectNextMonth = () => onMonthChange(utils.addMonths(currentMonth, 1)
|
|
61
|
-
const selectPreviousMonth = () => onMonthChange(utils.addMonths(currentMonth, -1)
|
|
60
|
+
const selectNextMonth = () => onMonthChange(utils.addMonths(currentMonth, 1));
|
|
61
|
+
const selectPreviousMonth = () => onMonthChange(utils.addMonths(currentMonth, -1));
|
|
62
62
|
return /*#__PURE__*/_jsx(PickersRangeCalendarHeaderContentMultipleCalendars, _extends({}, otherRangeProps, {
|
|
63
63
|
ref: ref,
|
|
64
64
|
onGoToPrevious: selectPreviousMonth,
|
package/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczODg4MjgwMDAwMA==";
|
|
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
|
|
@@ -34,7 +34,7 @@ var _dimensions = require("../internals/constants/dimensions");
|
|
|
34
34
|
var _PickersRangeCalendarHeader = require("../PickersRangeCalendarHeader");
|
|
35
35
|
var _useNullablePickerRangePositionContext = require("../internals/hooks/useNullablePickerRangePositionContext");
|
|
36
36
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
37
|
-
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
37
|
+
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "focusedView", "onFocusedViewChange", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
38
38
|
_excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
|
|
39
39
|
const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
|
|
40
40
|
const DateRangeCalendarRoot = (0, _styles.styled)('div', {
|
|
@@ -152,6 +152,8 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
152
152
|
loading,
|
|
153
153
|
renderLoading,
|
|
154
154
|
disableHighlightToday,
|
|
155
|
+
focusedView: focusedViewProp,
|
|
156
|
+
onFocusedViewChange,
|
|
155
157
|
readOnly,
|
|
156
158
|
disabled,
|
|
157
159
|
showDaysOutsideCurrentMonth,
|
|
@@ -184,18 +186,21 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
184
186
|
valueManager: _valueManagers.rangeValueManager
|
|
185
187
|
});
|
|
186
188
|
const {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
view,
|
|
190
|
+
setFocusedView,
|
|
191
|
+
focusedView,
|
|
192
|
+
setValueAndGoToNextView
|
|
189
193
|
} = (0, _internals.useViews)({
|
|
190
194
|
view: inView,
|
|
191
195
|
views,
|
|
192
196
|
openTo,
|
|
193
197
|
onChange: handleValueChange,
|
|
194
198
|
onViewChange,
|
|
195
|
-
autoFocus
|
|
199
|
+
autoFocus,
|
|
200
|
+
focusedView: focusedViewProp,
|
|
201
|
+
onFocusedViewChange
|
|
196
202
|
});
|
|
197
203
|
const utils = (0, _internals.useUtils)();
|
|
198
|
-
const now = (0, _internals.useNow)(timezone);
|
|
199
204
|
const id = (0, _useId.default)();
|
|
200
205
|
const {
|
|
201
206
|
rangePosition,
|
|
@@ -280,22 +285,39 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
280
285
|
}, [shouldDisableDate, rangePosition, draggingDatePosition]);
|
|
281
286
|
const {
|
|
282
287
|
calendarState,
|
|
283
|
-
|
|
284
|
-
changeMonth,
|
|
285
|
-
handleChangeMonth,
|
|
288
|
+
setVisibleDate,
|
|
286
289
|
onMonthSwitchingAnimationEnd
|
|
287
290
|
} = (0, _internals.useCalendarState)({
|
|
288
291
|
value: value[0] || value[1],
|
|
289
292
|
referenceDate,
|
|
290
293
|
disableFuture,
|
|
291
294
|
disablePast,
|
|
292
|
-
disableSwitchToMonthOnDayFocus: true,
|
|
293
295
|
maxDate,
|
|
294
296
|
minDate,
|
|
295
297
|
onMonthChange,
|
|
296
298
|
reduceAnimations,
|
|
297
299
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
298
|
-
timezone
|
|
300
|
+
timezone,
|
|
301
|
+
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
302
|
+
const firstVisibleMonth = utils.addMonths(prevMonth, 1 - currentMonthCalendarPosition);
|
|
303
|
+
const lastVisibleMonth = utils.endOfMonth(utils.addMonths(firstVisibleMonth, calendars - 1));
|
|
304
|
+
|
|
305
|
+
// The new focused day is inside the visible calendars,
|
|
306
|
+
// Do not change the current month
|
|
307
|
+
if (utils.isWithinRange(visibleDate, [firstVisibleMonth, lastVisibleMonth])) {
|
|
308
|
+
return prevMonth;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// The new focused day is after the last visible month,
|
|
312
|
+
// Move the current month so that the new focused day is inside the first visible month
|
|
313
|
+
if (utils.isAfter(visibleDate, lastVisibleMonth)) {
|
|
314
|
+
return utils.startOfMonth(utils.addMonths(visibleDate, currentMonthCalendarPosition - 1));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// The new focused day is before the first visible month,
|
|
318
|
+
// Move the current month so that the new focused day is inside the last visible month
|
|
319
|
+
return utils.startOfMonth(utils.addMonths(visibleDate, currentMonthCalendarPosition - calendars));
|
|
320
|
+
}
|
|
299
321
|
});
|
|
300
322
|
const CalendarHeader = slots?.calendarHeader ?? _PickersRangeCalendarHeader.PickersRangeCalendarHeader;
|
|
301
323
|
const calendarHeaderProps = (0, _useSlotProps.default)({
|
|
@@ -306,9 +328,9 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
306
328
|
views: ['day'],
|
|
307
329
|
view: 'day',
|
|
308
330
|
currentMonth: calendarState.currentMonth,
|
|
309
|
-
onMonthChange:
|
|
310
|
-
|
|
311
|
-
|
|
331
|
+
onMonthChange: month => setVisibleDate({
|
|
332
|
+
target: month,
|
|
333
|
+
reason: 'header-navigation'
|
|
312
334
|
}),
|
|
313
335
|
minDate,
|
|
314
336
|
maxDate,
|
|
@@ -322,6 +344,8 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
322
344
|
},
|
|
323
345
|
ownerState
|
|
324
346
|
});
|
|
347
|
+
|
|
348
|
+
// TODO: Move this logic inside the render instead of using an effect
|
|
325
349
|
const prevValue = React.useRef(null);
|
|
326
350
|
React.useEffect(() => {
|
|
327
351
|
const date = rangePosition === 'start' ? value[0] : value[1];
|
|
@@ -343,7 +367,10 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
343
367
|
const newMonth = rangePosition === 'start' ? date :
|
|
344
368
|
// If need to focus end, scroll to the state when "end" is displaying in the last calendar
|
|
345
369
|
utils.addMonths(date, -displayingMonthRange);
|
|
346
|
-
|
|
370
|
+
setVisibleDate({
|
|
371
|
+
target: newMonth,
|
|
372
|
+
reason: 'controlled-value-change'
|
|
373
|
+
});
|
|
347
374
|
}
|
|
348
375
|
}, [rangePosition, value]); // eslint-disable-line
|
|
349
376
|
|
|
@@ -426,25 +453,19 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
426
453
|
length: calendars
|
|
427
454
|
}).map((_, index) => utils.addMonths(firstMonth, index));
|
|
428
455
|
}, [utils, calendarState.currentMonth, calendars, currentMonthCalendarPosition]);
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
// 2. Month of the `end` date
|
|
437
|
-
// 3. Month of the current date
|
|
438
|
-
// 4. First visible month
|
|
439
|
-
|
|
440
|
-
if (value[0] != null) {
|
|
441
|
-
return visibleMonths.find(month => utils.isSameMonth(month, value[0]));
|
|
456
|
+
const hasFocus = focusedView !== null;
|
|
457
|
+
const prevOpenViewRef = React.useRef(view);
|
|
458
|
+
React.useEffect(() => {
|
|
459
|
+
// If the view change and the focus was on the previous view
|
|
460
|
+
// Then we update the focus.
|
|
461
|
+
if (prevOpenViewRef.current === view) {
|
|
462
|
+
return;
|
|
442
463
|
}
|
|
443
|
-
if (
|
|
444
|
-
|
|
464
|
+
if (focusedView === prevOpenViewRef.current) {
|
|
465
|
+
setFocusedView(view, true);
|
|
445
466
|
}
|
|
446
|
-
|
|
447
|
-
}, [
|
|
467
|
+
prevOpenViewRef.current = view;
|
|
468
|
+
}, [focusedView, setFocusedView, view]);
|
|
448
469
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateRangeCalendarRoot, (0, _extends2.default)({
|
|
449
470
|
ref: ref,
|
|
450
471
|
className: (0, _clsx.default)(classes.root, className),
|
|
@@ -466,20 +487,24 @@ const DateRangeCalendar = exports.DateRangeCalendar = /*#__PURE__*/React.forward
|
|
|
466
487
|
className: classes.dayCalendar
|
|
467
488
|
}, calendarState, baseDateValidationProps, commonViewProps, {
|
|
468
489
|
onMonthSwitchingAnimationEnd: onMonthSwitchingAnimationEnd,
|
|
469
|
-
onFocusedDayChange:
|
|
490
|
+
onFocusedDayChange: focusedDate => setVisibleDate({
|
|
491
|
+
target: focusedDate,
|
|
492
|
+
reason: 'cell-interaction'
|
|
493
|
+
}),
|
|
470
494
|
reduceAnimations: reduceAnimations,
|
|
471
495
|
selectedDays: value,
|
|
472
496
|
onSelectedDaysChange: handleSelectedDayChange,
|
|
473
497
|
currentMonth: month,
|
|
474
498
|
TransitionProps: CalendarTransitionProps,
|
|
475
499
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
500
|
+
hasFocus: hasFocus,
|
|
501
|
+
onFocusedViewChange: isViewFocused => setFocusedView('day', isViewFocused),
|
|
476
502
|
showDaysOutsideCurrentMonth: calendars === 1 && showDaysOutsideCurrentMonth,
|
|
477
503
|
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
478
504
|
loading: loading,
|
|
479
505
|
renderLoading: renderLoading,
|
|
480
506
|
slots: slotsForDayCalendar,
|
|
481
507
|
slotProps: slotPropsForDayCalendar,
|
|
482
|
-
autoFocus: month === focusedMonth,
|
|
483
508
|
fixedWeekNumber: fixedWeekNumber,
|
|
484
509
|
displayWeekNumber: displayWeekNumber,
|
|
485
510
|
timezone: timezone,
|
|
@@ -43,6 +43,8 @@ const MobileDateRangePicker = exports.MobileDateRangePicker = /*#__PURE__*/React
|
|
|
43
43
|
format: utils.formats.keyboardDate,
|
|
44
44
|
// Force one calendar on mobile to avoid layout issues
|
|
45
45
|
calendars: 1,
|
|
46
|
+
// force current calendar position, since we only have one calendar
|
|
47
|
+
currentMonthCalendarPosition: 1,
|
|
46
48
|
views: ['day'],
|
|
47
49
|
openTo: 'day',
|
|
48
50
|
slots: (0, _extends2.default)({
|
|
@@ -117,6 +117,8 @@ const MobileDateTimeRangePicker = exports.MobileDateTimeRangePicker = /*#__PURE_
|
|
|
117
117
|
calendars: 1,
|
|
118
118
|
// force true to correctly handle `renderTimeViewClock` as a renderer
|
|
119
119
|
ampmInClock: true,
|
|
120
|
+
// force current calendar position, since we only have one calendar
|
|
121
|
+
currentMonthCalendarPosition: 1,
|
|
120
122
|
slots: (0, _extends2.default)({
|
|
121
123
|
field: _MultiInputDateTimeRangeField.MultiInputDateTimeRangeField
|
|
122
124
|
}, defaultizedProps.slots),
|
|
@@ -64,8 +64,8 @@ const PickersRangeCalendarHeader = exports.PickersRangeCalendarHeader = /*#__PUR
|
|
|
64
64
|
ref: ref
|
|
65
65
|
}));
|
|
66
66
|
}
|
|
67
|
-
const selectNextMonth = () => onMonthChange(utils.addMonths(currentMonth, 1)
|
|
68
|
-
const selectPreviousMonth = () => onMonthChange(utils.addMonths(currentMonth, -1)
|
|
67
|
+
const selectNextMonth = () => onMonthChange(utils.addMonths(currentMonth, 1));
|
|
68
|
+
const selectPreviousMonth = () => onMonthChange(utils.addMonths(currentMonth, -1));
|
|
69
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersRangeCalendarHeaderContentMultipleCalendars, (0, _extends2.default)({}, otherRangeProps, {
|
|
70
70
|
ref: ref,
|
|
71
71
|
onGoToPrevious: selectPreviousMonth,
|
package/node/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTczODg4MjgwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers-pro",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.11",
|
|
4
4
|
"description": "The Pro plan edition of the Date and Time Picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"clsx": "^2.1.1",
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
39
|
"react-transition-group": "^4.4.5",
|
|
40
|
-
"@mui/x-
|
|
41
|
-
"@mui/x-
|
|
42
|
-
"@mui/x-
|
|
40
|
+
"@mui/x-date-pickers": "8.0.0-alpha.11",
|
|
41
|
+
"@mui/x-internals": "8.0.0-alpha.11",
|
|
42
|
+
"@mui/x-license": "8.0.0-alpha.11"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.9.0",
|