@mui/x-date-pickers-pro 8.0.0-alpha.5 → 8.0.0-alpha.6
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 +79 -0
- package/DateRangePicker/DateRangePickerToolbar.d.ts +1 -1
- package/DateRangePicker/DateRangePickerToolbar.js +2 -16
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +18 -18
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -3
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +49 -50
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +2 -2
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +2 -3
- package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +2 -2
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +2 -3
- package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +2 -2
- package/index.js +1 -1
- package/internals/hooks/models/useRangePicker.d.ts +2 -2
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +13 -14
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +4 -4
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +2 -2
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +8 -5
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +5 -7
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +4 -4
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +4 -4
- package/internals/utils/releaseInfo.js +1 -1
- package/modern/DateRangePicker/DateRangePickerToolbar.js +2 -16
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +18 -18
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +49 -50
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +13 -14
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +8 -5
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +5 -7
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/node/DateRangePicker/DateRangePickerToolbar.js +2 -16
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +17 -17
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +48 -49
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +13 -14
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +8 -5
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +5 -7
- package/node/internals/utils/releaseInfo.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,85 @@
|
|
|
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.6
|
|
9
|
+
|
|
10
|
+
_Dec 26, 2024_
|
|
11
|
+
|
|
12
|
+
We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🏎️ Improve Data Grid scrolling performance
|
|
15
|
+
- 🌍 Improve Dutch (nl-NL) locale on the Data Grid
|
|
16
|
+
- 🐞 Bugfixes
|
|
17
|
+
|
|
18
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
19
|
+
@JoepVerkoelen, @k-rajat19, @lauri865.
|
|
20
|
+
Following are all team members who have contributed to this release:
|
|
21
|
+
@flaviendelangle, @JCQuintas, @LukasTy, @MBilalShafi, @romgrk.
|
|
22
|
+
|
|
23
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
24
|
+
|
|
25
|
+
### Data Grid
|
|
26
|
+
|
|
27
|
+
#### Breaking changes
|
|
28
|
+
|
|
29
|
+
- The `sanitizeFilterItemValue()` utility is not exported anymore.
|
|
30
|
+
|
|
31
|
+
#### `@mui/x-data-grid@8.0.0-alpha.6`
|
|
32
|
+
|
|
33
|
+
- [DataGrid] Avoid subscribing to `renderContext` state in grid root for better scroll performance (#15986) @lauri865
|
|
34
|
+
- [DataGrid] Fix header filters showing clear button while empty (#15829) @k-rajat19
|
|
35
|
+
- [DataGrid] Improve test coverage of server side data source (#15942) @MBilalShafi
|
|
36
|
+
- [DataGrid] Move progress components to leaf import (#15914) @romgrk
|
|
37
|
+
- [DataGrid] Move skeleton to leaf import (#15931) @romgrk
|
|
38
|
+
- [DataGrid] Replace `forwardRef` with a shim for forward compatibility (#15955) @lauri865
|
|
39
|
+
- [l10n] Improve Dutch (nl-NL) locale (#15994) @JoepVerkoelen
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-data-grid-pro@8.0.0-alpha.6` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
42
|
+
|
|
43
|
+
Same changes as in `@mui/x-data-grid@8.0.0-alpha.6`.
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-data-grid-premium@8.0.0-alpha.6` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
46
|
+
|
|
47
|
+
Same changes as in `@mui/x-data-grid-pro@8.0.0-alpha.6`, plus:
|
|
48
|
+
|
|
49
|
+
- [DataGridPremium] Fix column unpinning with row grouping (#15908) @k-rajat19
|
|
50
|
+
|
|
51
|
+
### Date and Time Pickers
|
|
52
|
+
|
|
53
|
+
#### `@mui/x-date-pickers@8.0.0-alpha.6`
|
|
54
|
+
|
|
55
|
+
- [pickers] Use `usePickerContext()` and `usePickerActionsContext()` to get the actions in the `actionBar` slot and in internal components (#15843) @flaviendelangle
|
|
56
|
+
- [pickers] Use `usePickerContext()` to get the view-related props in the layout, toolbar and tabs slots (#15606) @flaviendelangle
|
|
57
|
+
|
|
58
|
+
#### `@mui/x-date-pickers-pro@8.0.0-alpha.6` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
59
|
+
|
|
60
|
+
Same changes as in `@mui/x-date-pickers@8.0.0-alpha.6`.
|
|
61
|
+
|
|
62
|
+
### Charts
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-charts@8.0.0-alpha.6`
|
|
65
|
+
|
|
66
|
+
No changes since `@mui/x-charts@v8.0.0-alpha.5`.
|
|
67
|
+
|
|
68
|
+
#### `@mui/x-charts-pro@8.0.0-alpha.6` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
69
|
+
|
|
70
|
+
Same changes as in `@mui/x-charts@8.0.0-alpha.6`.
|
|
71
|
+
|
|
72
|
+
### Tree View
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-tree-view@8.0.0-alpha.6`
|
|
75
|
+
|
|
76
|
+
No changes since `@mui/x-tree-view-pro@v8.0.0-alpha.5`.
|
|
77
|
+
|
|
78
|
+
#### `@mui/x-tree-view-pro@8.0.0-alpha.6` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
79
|
+
|
|
80
|
+
Same changes as in `@mui/x-tree-view@8.0.0-alpha.6`.
|
|
81
|
+
|
|
82
|
+
### Docs
|
|
83
|
+
|
|
84
|
+
- [docs] Remove production profiler from docs build (#15959) @lauri865
|
|
85
|
+
- [code-infra] Add new `next-env.d.ts` changes (#15947) @JCQuintas
|
|
86
|
+
|
|
8
87
|
## 8.0.0-alpha.5
|
|
9
88
|
|
|
10
89
|
_Dec 19, 2024_
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { BaseToolbarProps, ExportedBaseToolbarProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
|
|
4
4
|
import { DateRangePickerToolbarClasses } from './dateRangePickerToolbarClasses';
|
|
5
|
-
export interface DateRangePickerToolbarProps extends ExportedDateRangePickerToolbarProps, Omit<BaseToolbarProps<PickerRangeValue
|
|
5
|
+
export interface DateRangePickerToolbarProps extends ExportedDateRangePickerToolbarProps, Omit<BaseToolbarProps<PickerRangeValue>, 'onChange' | 'isLandscape'>, Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
|
|
6
6
|
}
|
|
7
7
|
export interface ExportedDateRangePickerToolbarProps extends ExportedBaseToolbarProps {
|
|
8
8
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["value", "rangePosition", "onRangePositionChange", "toolbarFormat", "className", "classes"
|
|
5
|
+
const _excluded = ["value", "rangePosition", "onRangePositionChange", "toolbarFormat", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
@@ -103,12 +103,6 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
103
103
|
*/
|
|
104
104
|
hidden: PropTypes.bool,
|
|
105
105
|
onRangePositionChange: PropTypes.func.isRequired,
|
|
106
|
-
/**
|
|
107
|
-
* Callback called when a toolbar is clicked
|
|
108
|
-
* @template TView
|
|
109
|
-
* @param {TView} view The view to open
|
|
110
|
-
*/
|
|
111
|
-
onViewChange: PropTypes.func.isRequired,
|
|
112
106
|
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
113
107
|
/**
|
|
114
108
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
@@ -124,14 +118,6 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
124
118
|
* @default "––"
|
|
125
119
|
*/
|
|
126
120
|
toolbarPlaceholder: PropTypes.node,
|
|
127
|
-
value: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
128
|
-
/**
|
|
129
|
-
* Currently visible picker view.
|
|
130
|
-
*/
|
|
131
|
-
view: PropTypes.oneOf(['day']).isRequired,
|
|
132
|
-
/**
|
|
133
|
-
* Available views.
|
|
134
|
-
*/
|
|
135
|
-
views: PropTypes.arrayOf(PropTypes.oneOf(['day'])).isRequired
|
|
121
|
+
value: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
136
122
|
} : void 0;
|
|
137
123
|
export { DateRangePickerToolbar };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ExportedBaseTabsProps } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { DateTimeRangePickerTabsClasses } from './dateTimeRangePickerTabsClasses';
|
|
4
4
|
import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
|
|
5
5
|
export interface ExportedDateTimeRangePickerTabsProps extends ExportedBaseTabsProps {
|
|
@@ -23,7 +23,7 @@ export interface ExportedDateTimeRangePickerTabsProps extends ExportedBaseTabsPr
|
|
|
23
23
|
*/
|
|
24
24
|
classes?: Partial<DateTimeRangePickerTabsClasses>;
|
|
25
25
|
}
|
|
26
|
-
export interface DateTimeRangePickerTabsProps extends ExportedDateTimeRangePickerTabsProps,
|
|
26
|
+
export interface DateTimeRangePickerTabsProps extends ExportedDateTimeRangePickerTabsProps, Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
|
|
27
27
|
}
|
|
28
28
|
declare const DateTimeRangePickerTabs: {
|
|
29
29
|
(inProps: DateTimeRangePickerTabsProps): React.JSX.Element | null;
|
|
@@ -8,7 +8,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
8
8
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
9
9
|
import { TimeIcon, DateRangeIcon, ArrowLeftIcon, ArrowRightIcon } from '@mui/x-date-pickers/icons';
|
|
10
10
|
import { isDatePickerView, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
|
|
11
|
-
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
11
|
+
import { usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
12
12
|
import IconButton from '@mui/material/IconButton';
|
|
13
13
|
import Button from '@mui/material/Button';
|
|
14
14
|
import { getDateTimeRangePickerTabsUtilityClass } from "./dateTimeRangePickerTabsClasses.js";
|
|
@@ -69,9 +69,7 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
69
69
|
});
|
|
70
70
|
const {
|
|
71
71
|
dateIcon = /*#__PURE__*/_jsx(DateRangeIcon, {}),
|
|
72
|
-
onViewChange,
|
|
73
72
|
timeIcon = /*#__PURE__*/_jsx(TimeIcon, {}),
|
|
74
|
-
view,
|
|
75
73
|
hidden = typeof window === 'undefined' || window.innerHeight < 667,
|
|
76
74
|
rangePosition,
|
|
77
75
|
onRangePositionChange,
|
|
@@ -83,8 +81,12 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
83
81
|
const {
|
|
84
82
|
ownerState
|
|
85
83
|
} = usePickerPrivateContext();
|
|
84
|
+
const {
|
|
85
|
+
view,
|
|
86
|
+
onViewChange
|
|
87
|
+
} = usePickerContext();
|
|
86
88
|
const classes = useUtilityClasses(classesProp);
|
|
87
|
-
const value = React.useMemo(() => viewToTab(view, rangePosition), [view, rangePosition]);
|
|
89
|
+
const value = React.useMemo(() => view == null ? null : viewToTab(view, rangePosition), [view, rangePosition]);
|
|
88
90
|
const isPreviousHidden = value === 'start-date';
|
|
89
91
|
const isNextHidden = value === 'end-time';
|
|
90
92
|
const tabLabel = React.useMemo(() => {
|
|
@@ -109,18 +111,26 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
109
111
|
}
|
|
110
112
|
});
|
|
111
113
|
const changeToPreviousTab = useEventCallback(() => {
|
|
112
|
-
const previousTab = tabOptions[tabOptions.indexOf(value) - 1];
|
|
114
|
+
const previousTab = value == null ? tabOptions[0] : tabOptions[tabOptions.indexOf(value) - 1];
|
|
113
115
|
onViewChange(tabToView(previousTab));
|
|
114
116
|
handleRangePositionChange(previousTab);
|
|
115
117
|
});
|
|
116
118
|
const changeToNextTab = useEventCallback(() => {
|
|
117
|
-
const nextTab = tabOptions[tabOptions.indexOf(value) + 1];
|
|
119
|
+
const nextTab = value == null ? tabOptions[0] : tabOptions[tabOptions.indexOf(value) + 1];
|
|
118
120
|
onViewChange(tabToView(nextTab));
|
|
119
121
|
handleRangePositionChange(nextTab);
|
|
120
122
|
});
|
|
121
123
|
if (hidden) {
|
|
122
124
|
return null;
|
|
123
125
|
}
|
|
126
|
+
let startIcon;
|
|
127
|
+
if (view == null) {
|
|
128
|
+
startIcon = null;
|
|
129
|
+
} else if (isDatePickerView(view)) {
|
|
130
|
+
startIcon = dateIcon;
|
|
131
|
+
} else {
|
|
132
|
+
startIcon = timeIcon;
|
|
133
|
+
}
|
|
124
134
|
return /*#__PURE__*/_jsxs(DateTimeRangePickerTabsRoot, {
|
|
125
135
|
ownerState: ownerState,
|
|
126
136
|
className: clsx(classes.root, className),
|
|
@@ -133,7 +143,7 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
133
143
|
}) : /*#__PURE__*/_jsx(DateTimeRangePickerTabFiller, {
|
|
134
144
|
className: classes.filler
|
|
135
145
|
}), /*#__PURE__*/_jsx(DateTimeRangePickerTab, {
|
|
136
|
-
startIcon:
|
|
146
|
+
startIcon: startIcon,
|
|
137
147
|
className: classes.tabButton,
|
|
138
148
|
size: "large",
|
|
139
149
|
children: tabLabel
|
|
@@ -168,12 +178,6 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerTabs.propTypes = {
|
|
|
168
178
|
*/
|
|
169
179
|
hidden: PropTypes.bool,
|
|
170
180
|
onRangePositionChange: PropTypes.func.isRequired,
|
|
171
|
-
/**
|
|
172
|
-
* Callback called when a tab is clicked.
|
|
173
|
-
* @template TView
|
|
174
|
-
* @param {TView} view The view to open
|
|
175
|
-
*/
|
|
176
|
-
onViewChange: PropTypes.func.isRequired,
|
|
177
181
|
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
178
182
|
/**
|
|
179
183
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
@@ -183,10 +187,6 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerTabs.propTypes = {
|
|
|
183
187
|
* Time tab icon.
|
|
184
188
|
* @default TimeIcon
|
|
185
189
|
*/
|
|
186
|
-
timeIcon: PropTypes.element
|
|
187
|
-
/**
|
|
188
|
-
* Currently visible picker view.
|
|
189
|
-
*/
|
|
190
|
-
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired
|
|
190
|
+
timeIcon: PropTypes.element
|
|
191
191
|
} : void 0;
|
|
192
192
|
export { DateTimeRangePickerTabs };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { BaseToolbarProps, ExportedBaseToolbarProps,
|
|
2
|
+
import { BaseToolbarProps, ExportedBaseToolbarProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
|
|
4
4
|
import { DateTimeRangePickerToolbarClasses } from './dateTimeRangePickerToolbarClasses';
|
|
5
|
-
|
|
6
|
-
export interface DateTimeRangePickerToolbarProps extends BaseToolbarProps<PickerRangeValue, DateTimeRangeViews>, Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'>, ExportedDateTimeRangePickerToolbarProps {
|
|
5
|
+
export interface DateTimeRangePickerToolbarProps extends BaseToolbarProps<PickerRangeValue>, Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'>, ExportedDateTimeRangePickerToolbarProps {
|
|
7
6
|
ampm?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export interface ExportedDateTimeRangePickerToolbarProps extends ExportedBaseToolbarProps {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["value", "rangePosition", "onRangePositionChange", "className", "classes", "
|
|
5
|
+
const _excluded = ["value", "rangePosition", "onRangePositionChange", "className", "classes", "onChange", "classes", "isLandscape", "ampm", "hidden", "toolbarFormat", "toolbarPlaceholder", "titleId", "sx"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
11
|
-
import { useUtils, useToolbarOwnerState,
|
|
11
|
+
import { useUtils, useToolbarOwnerState, DateTimePickerToolbarOverrideContext } from '@mui/x-date-pickers/internals';
|
|
12
12
|
import { usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
13
13
|
import { DateTimePickerToolbar } from '@mui/x-date-pickers/DateTimePicker';
|
|
14
14
|
import { getDateTimeRangePickerToolbarUtilityClass } from "./dateTimeRangePickerToolbarClasses.js";
|
|
@@ -55,11 +55,8 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
55
55
|
onRangePositionChange,
|
|
56
56
|
className,
|
|
57
57
|
classes: classesProp,
|
|
58
|
-
onViewChange,
|
|
59
58
|
onChange,
|
|
60
|
-
view,
|
|
61
59
|
isLandscape,
|
|
62
|
-
views,
|
|
63
60
|
ampm,
|
|
64
61
|
hidden,
|
|
65
62
|
toolbarFormat,
|
|
@@ -70,7 +67,10 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
70
67
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
71
68
|
const {
|
|
72
69
|
disabled,
|
|
73
|
-
readOnly
|
|
70
|
+
readOnly,
|
|
71
|
+
view,
|
|
72
|
+
onViewChange,
|
|
73
|
+
views
|
|
74
74
|
} = usePickerContext();
|
|
75
75
|
const translations = usePickerTranslations();
|
|
76
76
|
const ownerState = useToolbarOwnerState();
|
|
@@ -85,24 +85,6 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
85
85
|
toolbarFormat,
|
|
86
86
|
toolbarPlaceholder
|
|
87
87
|
};
|
|
88
|
-
const handleStartRangeViewChange = React.useCallback(newView => {
|
|
89
|
-
if (newView === 'year' || newView === 'month') {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (rangePosition !== 'start') {
|
|
93
|
-
onRangePositionChange('start');
|
|
94
|
-
}
|
|
95
|
-
onViewChange(newView);
|
|
96
|
-
}, [onRangePositionChange, onViewChange, rangePosition]);
|
|
97
|
-
const handleEndRangeViewChange = React.useCallback(newView => {
|
|
98
|
-
if (newView === 'year' || newView === 'month') {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (rangePosition !== 'end') {
|
|
102
|
-
onRangePositionChange('end');
|
|
103
|
-
}
|
|
104
|
-
onViewChange(newView);
|
|
105
|
-
}, [onRangePositionChange, onViewChange, rangePosition]);
|
|
106
88
|
const handleOnChange = React.useCallback(newDate => {
|
|
107
89
|
const {
|
|
108
90
|
nextSelection,
|
|
@@ -117,37 +99,68 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
117
99
|
onRangePositionChange(nextSelection);
|
|
118
100
|
onChange(newRange);
|
|
119
101
|
}, [onChange, onRangePositionChange, props.value, rangePosition, utils]);
|
|
102
|
+
const startOverrides = React.useMemo(() => {
|
|
103
|
+
const handleStartRangeViewChange = newView => {
|
|
104
|
+
if (newView === 'year' || newView === 'month') {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (rangePosition !== 'start') {
|
|
108
|
+
onRangePositionChange('start');
|
|
109
|
+
}
|
|
110
|
+
onViewChange(newView);
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
forceDesktopVariant: true,
|
|
114
|
+
onViewChange: handleStartRangeViewChange,
|
|
115
|
+
view: rangePosition === 'start' ? view : null
|
|
116
|
+
};
|
|
117
|
+
}, [rangePosition, view, onRangePositionChange, onViewChange]);
|
|
118
|
+
const endOverrides = React.useMemo(() => {
|
|
119
|
+
const handleEndRangeViewChange = newView => {
|
|
120
|
+
if (newView === 'year' || newView === 'month') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (rangePosition !== 'end') {
|
|
124
|
+
onRangePositionChange('end');
|
|
125
|
+
}
|
|
126
|
+
onViewChange(newView);
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
forceDesktopVariant: true,
|
|
130
|
+
onViewChange: handleEndRangeViewChange,
|
|
131
|
+
view: rangePosition === 'end' ? view : null
|
|
132
|
+
};
|
|
133
|
+
}, [rangePosition, view, onRangePositionChange, onViewChange]);
|
|
120
134
|
if (hidden) {
|
|
121
135
|
return null;
|
|
122
136
|
}
|
|
123
|
-
return /*#__PURE__*/
|
|
137
|
+
return /*#__PURE__*/_jsxs(DateTimeRangePickerToolbarRoot, _extends({
|
|
124
138
|
className: clsx(classes.root, className),
|
|
125
139
|
ownerState: ownerState,
|
|
126
140
|
ref: ref,
|
|
127
141
|
sx: sx
|
|
128
142
|
}, other, {
|
|
129
|
-
children: /*#__PURE__*/
|
|
130
|
-
value:
|
|
131
|
-
children:
|
|
143
|
+
children: [/*#__PURE__*/_jsx(DateTimePickerToolbarOverrideContext.Provider, {
|
|
144
|
+
value: startOverrides,
|
|
145
|
+
children: /*#__PURE__*/_jsx(DateTimeRangePickerToolbarStart, _extends({
|
|
132
146
|
value: start,
|
|
133
|
-
onViewChange: handleStartRangeViewChange,
|
|
134
147
|
toolbarTitle: translations.start,
|
|
135
148
|
ownerState: ownerState,
|
|
136
|
-
view: rangePosition === 'start' ? view : undefined,
|
|
137
149
|
className: classes.startToolbar,
|
|
138
150
|
onChange: handleOnChange,
|
|
139
151
|
titleId: titleId ? `${titleId}-start-toolbar` : undefined
|
|
140
|
-
}, commonToolbarProps))
|
|
152
|
+
}, commonToolbarProps))
|
|
153
|
+
}), /*#__PURE__*/_jsx(DateTimePickerToolbarOverrideContext.Provider, {
|
|
154
|
+
value: endOverrides,
|
|
155
|
+
children: /*#__PURE__*/_jsx(DateTimeRangePickerToolbarEnd, _extends({
|
|
141
156
|
value: end,
|
|
142
|
-
onViewChange: handleEndRangeViewChange,
|
|
143
157
|
toolbarTitle: translations.end,
|
|
144
158
|
ownerState: ownerState,
|
|
145
|
-
view: rangePosition === 'end' ? view : undefined,
|
|
146
159
|
className: classes.endToolbar,
|
|
147
160
|
onChange: handleOnChange,
|
|
148
161
|
titleId: titleId ? `${titleId}-end-toolbar` : undefined
|
|
149
|
-
}, commonToolbarProps))
|
|
150
|
-
})
|
|
162
|
+
}, commonToolbarProps))
|
|
163
|
+
})]
|
|
151
164
|
}));
|
|
152
165
|
});
|
|
153
166
|
process.env.NODE_ENV !== "production" ? DateTimeRangePickerToolbar.propTypes = {
|
|
@@ -169,12 +182,6 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerToolbar.propTypes = {
|
|
|
169
182
|
isLandscape: PropTypes.bool.isRequired,
|
|
170
183
|
onChange: PropTypes.func.isRequired,
|
|
171
184
|
onRangePositionChange: PropTypes.func.isRequired,
|
|
172
|
-
/**
|
|
173
|
-
* Callback called when a toolbar is clicked
|
|
174
|
-
* @template TView
|
|
175
|
-
* @param {TView} view The view to open
|
|
176
|
-
*/
|
|
177
|
-
onViewChange: PropTypes.func.isRequired,
|
|
178
185
|
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
179
186
|
/**
|
|
180
187
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
@@ -190,14 +197,6 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerToolbar.propTypes = {
|
|
|
190
197
|
* @default "––"
|
|
191
198
|
*/
|
|
192
199
|
toolbarPlaceholder: PropTypes.node,
|
|
193
|
-
value: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
194
|
-
/**
|
|
195
|
-
* Currently visible picker view.
|
|
196
|
-
*/
|
|
197
|
-
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'seconds']).isRequired,
|
|
198
|
-
/**
|
|
199
|
-
* Available views.
|
|
200
|
-
*/
|
|
201
|
-
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'seconds']).isRequired).isRequired
|
|
200
|
+
value: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
202
201
|
} : void 0;
|
|
203
202
|
export { DateTimeRangePickerToolbar };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { UseDesktopRangePickerSlots, UseDesktopRangePickerSlotProps, DesktopRangeOnlyPickerProps } from '../internals/hooks/useDesktopRangePicker';
|
|
3
3
|
import { BaseDateRangePickerProps, BaseDateRangePickerSlots, BaseDateRangePickerSlotProps } from '../DateRangePicker/shared';
|
|
4
|
-
export interface DesktopDateRangePickerSlots extends BaseDateRangePickerSlots, MakeOptional<UseDesktopRangePickerSlots
|
|
4
|
+
export interface DesktopDateRangePickerSlots extends BaseDateRangePickerSlots, MakeOptional<UseDesktopRangePickerSlots, 'field'> {
|
|
5
5
|
}
|
|
6
|
-
export interface DesktopDateRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateRangePickerSlotProps, Omit<UseDesktopRangePickerSlotProps<
|
|
6
|
+
export interface DesktopDateRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateRangePickerSlotProps, Omit<UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, 'tabs' | 'toolbar'> {
|
|
7
7
|
}
|
|
8
8
|
export interface DesktopDateRangePickerProps<TEnableAccessibleFieldDOMStructure extends boolean = true> extends BaseDateRangePickerProps, DesktopRangeOnlyPickerProps {
|
|
9
9
|
/**
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { UseDesktopRangePickerSlots, UseDesktopRangePickerSlotProps, DesktopRangeOnlyPickerProps } from '../internals/hooks/useDesktopRangePicker';
|
|
3
3
|
import { BaseDateTimeRangePickerProps, BaseDateTimeRangePickerSlots, BaseDateTimeRangePickerSlotProps } from '../DateTimeRangePicker/shared';
|
|
4
|
-
|
|
5
|
-
export interface DesktopDateTimeRangePickerSlots extends BaseDateTimeRangePickerSlots, MakeOptional<UseDesktopRangePickerSlots<DateTimeRangePickerView>, 'field'> {
|
|
4
|
+
export interface DesktopDateTimeRangePickerSlots extends BaseDateTimeRangePickerSlots, MakeOptional<UseDesktopRangePickerSlots, 'field'> {
|
|
6
5
|
}
|
|
7
|
-
export interface DesktopDateTimeRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateTimeRangePickerSlotProps, Omit<UseDesktopRangePickerSlotProps<
|
|
6
|
+
export interface DesktopDateTimeRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateTimeRangePickerSlotProps, Omit<UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, 'tabs' | 'toolbar'> {
|
|
8
7
|
}
|
|
9
8
|
export interface DesktopDateTimeRangePickerProps<TEnableAccessibleFieldDOMStructure extends boolean = true> extends BaseDateTimeRangePickerProps, DesktopRangeOnlyPickerProps {
|
|
10
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { UseMobileRangePickerSlots, UseMobileRangePickerSlotProps, MobileRangeOnlyPickerProps } from '../internals/hooks/useMobileRangePicker';
|
|
3
3
|
import { BaseDateRangePickerProps, BaseDateRangePickerSlots, BaseDateRangePickerSlotProps } from '../DateRangePicker/shared';
|
|
4
|
-
export interface MobileDateRangePickerSlots extends BaseDateRangePickerSlots, MakeOptional<UseMobileRangePickerSlots
|
|
4
|
+
export interface MobileDateRangePickerSlots extends BaseDateRangePickerSlots, MakeOptional<UseMobileRangePickerSlots, 'field'> {
|
|
5
5
|
}
|
|
6
|
-
export interface MobileDateRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateRangePickerSlotProps, Omit<UseMobileRangePickerSlotProps<
|
|
6
|
+
export interface MobileDateRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateRangePickerSlotProps, Omit<UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, 'tabs' | 'toolbar'> {
|
|
7
7
|
}
|
|
8
8
|
export interface MobileDateRangePickerProps<TEnableAccessibleFieldDOMStructure extends boolean = true> extends BaseDateRangePickerProps, MobileRangeOnlyPickerProps {
|
|
9
9
|
/**
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { UseMobileRangePickerSlots, UseMobileRangePickerSlotProps, MobileRangeOnlyPickerProps } from '../internals/hooks/useMobileRangePicker';
|
|
3
3
|
import { BaseDateTimeRangePickerProps, BaseDateTimeRangePickerSlots, BaseDateTimeRangePickerSlotProps } from '../DateTimeRangePicker/shared';
|
|
4
|
-
|
|
5
|
-
export interface MobileDateTimeRangePickerSlots extends BaseDateTimeRangePickerSlots, MakeOptional<UseMobileRangePickerSlots<DateTimeRangePickerView>, 'field'> {
|
|
4
|
+
export interface MobileDateTimeRangePickerSlots extends BaseDateTimeRangePickerSlots, MakeOptional<UseMobileRangePickerSlots, 'field'> {
|
|
6
5
|
}
|
|
7
|
-
export interface MobileDateTimeRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateTimeRangePickerSlotProps, Omit<UseMobileRangePickerSlotProps<
|
|
6
|
+
export interface MobileDateTimeRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends BaseDateTimeRangePickerSlotProps, Omit<UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, 'tabs' | 'toolbar'> {
|
|
8
7
|
}
|
|
9
8
|
export interface MobileDateTimeRangePickerProps<TEnableAccessibleFieldDOMStructure extends boolean = true> extends BaseDateTimeRangePickerProps, MobileRangeOnlyPickerProps {
|
|
10
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { StaticRangeOnlyPickerProps, UseStaticRangePickerSlots, UseStaticRangePickerSlotProps } from '../internals/hooks/useStaticRangePicker';
|
|
3
3
|
import { BaseDateRangePickerProps, BaseDateRangePickerSlots, BaseDateRangePickerSlotProps } from '../DateRangePicker/shared';
|
|
4
|
-
export interface StaticDateRangePickerSlots extends BaseDateRangePickerSlots, UseStaticRangePickerSlots
|
|
4
|
+
export interface StaticDateRangePickerSlots extends BaseDateRangePickerSlots, UseStaticRangePickerSlots {
|
|
5
5
|
}
|
|
6
|
-
export interface StaticDateRangePickerSlotProps extends BaseDateRangePickerSlotProps, Omit<UseStaticRangePickerSlotProps
|
|
6
|
+
export interface StaticDateRangePickerSlotProps extends BaseDateRangePickerSlotProps, Omit<UseStaticRangePickerSlotProps, 'toolbar'> {
|
|
7
7
|
}
|
|
8
8
|
export interface StaticDateRangePickerProps extends BaseDateRangePickerProps, MakeOptional<StaticRangeOnlyPickerProps, 'displayStaticWrapperAs'> {
|
|
9
9
|
/**
|
package/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps } from '@mui
|
|
|
3
3
|
import { BaseRangeNonStaticPickerProps } from '../../models';
|
|
4
4
|
import { UseRangePositionProps, UseRangePositionResponse } from '../useRangePosition';
|
|
5
5
|
import { RangePickerFieldSlots, RangePickerFieldSlotProps } from '../useEnrichedRangePickerFieldProps';
|
|
6
|
-
export interface UseRangePickerSlots
|
|
6
|
+
export interface UseRangePickerSlots extends ExportedPickersLayoutSlots<PickerRangeValue>, RangePickerFieldSlots {
|
|
7
7
|
}
|
|
8
|
-
export interface UseRangePickerSlotProps<
|
|
8
|
+
export interface UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedPickersLayoutSlotProps<PickerRangeValue>, RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure> {
|
|
9
9
|
tabs?: ExportedBaseTabsProps;
|
|
10
10
|
toolbar?: ExportedBaseToolbarProps;
|
|
11
11
|
}
|
|
@@ -59,8 +59,6 @@ export const useDesktopRangePicker = _ref => {
|
|
|
59
59
|
fieldRef = endFieldRef;
|
|
60
60
|
}
|
|
61
61
|
const {
|
|
62
|
-
open,
|
|
63
|
-
actions,
|
|
64
62
|
layoutProps,
|
|
65
63
|
providerProps,
|
|
66
64
|
renderCurrentView,
|
|
@@ -79,8 +77,8 @@ export const useDesktopRangePicker = _ref => {
|
|
|
79
77
|
}
|
|
80
78
|
}));
|
|
81
79
|
React.useEffect(() => {
|
|
82
|
-
if (
|
|
83
|
-
initialView.current =
|
|
80
|
+
if (providerProps.contextValue.view) {
|
|
81
|
+
initialView.current = providerProps.contextValue.view;
|
|
84
82
|
}
|
|
85
83
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
84
|
}, []);
|
|
@@ -89,7 +87,9 @@ export const useDesktopRangePicker = _ref => {
|
|
|
89
87
|
if (fieldContainerRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
|
|
90
88
|
return;
|
|
91
89
|
}
|
|
92
|
-
|
|
90
|
+
|
|
91
|
+
// This direct access to `providerProps` will go away once the range fields stop having their views in a tooltip.
|
|
92
|
+
providerProps.privateContextValue.dismissViews();
|
|
93
93
|
});
|
|
94
94
|
};
|
|
95
95
|
const Field = slots.field;
|
|
@@ -124,8 +124,9 @@ export const useDesktopRangePicker = _ref => {
|
|
|
124
124
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
125
125
|
variant: 'desktop',
|
|
126
126
|
fieldType,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
128
|
+
open: providerProps.contextValue.open,
|
|
129
|
+
setOpen: providerProps.contextValue.setOpen,
|
|
129
130
|
readOnly,
|
|
130
131
|
disableOpenPicker,
|
|
131
132
|
label,
|
|
@@ -140,9 +141,9 @@ export const useDesktopRangePicker = _ref => {
|
|
|
140
141
|
startFieldRef,
|
|
141
142
|
endFieldRef,
|
|
142
143
|
singleInputFieldRef,
|
|
143
|
-
currentView:
|
|
144
|
+
currentView: providerProps.contextValue.view !== props.openTo ? providerProps.contextValue.view : undefined,
|
|
144
145
|
initialView: initialView.current ?? undefined,
|
|
145
|
-
onViewChange:
|
|
146
|
+
onViewChange: providerProps.contextValue.onViewChange
|
|
146
147
|
});
|
|
147
148
|
const slotPropsForLayout = _extends({}, slotProps, {
|
|
148
149
|
tabs: _extends({}, slotProps?.tabs, {
|
|
@@ -156,14 +157,12 @@ export const useDesktopRangePicker = _ref => {
|
|
|
156
157
|
});
|
|
157
158
|
const Layout = slots?.layout ?? PickersLayout;
|
|
158
159
|
const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
|
|
159
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper,
|
|
160
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, {
|
|
160
161
|
role: "tooltip",
|
|
161
162
|
placement: "bottom-start",
|
|
162
163
|
containerRef: popperRef,
|
|
163
164
|
anchorEl: anchorRef.current,
|
|
164
|
-
onBlur: handleBlur
|
|
165
|
-
}, actions, {
|
|
166
|
-
open: open,
|
|
165
|
+
onBlur: handleBlur,
|
|
167
166
|
slots: slots,
|
|
168
167
|
slotProps: slotProps,
|
|
169
168
|
shouldRestoreFocus: shouldRestoreFocus,
|
|
@@ -173,7 +172,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
173
172
|
slotProps: slotPropsForLayout,
|
|
174
173
|
children: renderCurrentView()
|
|
175
174
|
}))
|
|
176
|
-
})
|
|
175
|
+
})]
|
|
177
176
|
}));
|
|
178
177
|
return {
|
|
179
178
|
renderPicker
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PickersPopperSlots, PickersPopperSlotProps, UsePickerViewsProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { RangeOnlyPickerProps, RangePickerAdditionalViewProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
|
|
3
|
-
export interface UseDesktopRangePickerSlots
|
|
3
|
+
export interface UseDesktopRangePickerSlots extends UseRangePickerSlots, PickersPopperSlots {
|
|
4
4
|
}
|
|
5
|
-
export interface UseDesktopRangePickerSlotProps<
|
|
5
|
+
export interface UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, PickersPopperSlotProps {
|
|
6
6
|
}
|
|
7
7
|
export interface DesktopRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
8
8
|
/**
|
|
@@ -15,12 +15,12 @@ export interface UseDesktopRangePickerProps<TView extends DateOrTimeViewWithMeri
|
|
|
15
15
|
* Overridable component slots.
|
|
16
16
|
* @default {}
|
|
17
17
|
*/
|
|
18
|
-
slots: UseDesktopRangePickerSlots
|
|
18
|
+
slots: UseDesktopRangePickerSlots;
|
|
19
19
|
/**
|
|
20
20
|
* The props used for each component slot.
|
|
21
21
|
* @default {}
|
|
22
22
|
*/
|
|
23
|
-
slotProps?: UseDesktopRangePickerSlotProps<
|
|
23
|
+
slotProps?: UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
24
24
|
}
|
|
25
25
|
export interface DesktopRangePickerAdditionalViewProps extends RangePickerAdditionalViewProps {
|
|
26
26
|
}
|