@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
|
@@ -6,7 +6,7 @@ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
|
6
6
|
import { FieldRef, PickerOwnerState, FieldOwnerState } from '@mui/x-date-pickers/models';
|
|
7
7
|
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
|
|
8
8
|
import { PickersInputLocaleText } from '@mui/x-date-pickers/locales';
|
|
9
|
-
import {
|
|
9
|
+
import { UsePickerValueContextValue, PickerVariant, DateOrTimeViewWithMeridiem, BaseSingleInputFieldProps, PickerRangeValue, PickerValue } from '@mui/x-date-pickers/internals';
|
|
10
10
|
import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
|
|
11
11
|
import { RangePosition, FieldType, PickerRangeFieldSlotProps } from '../../models';
|
|
12
12
|
import { UseRangePositionResponse } from './useRangePosition';
|
|
@@ -39,7 +39,7 @@ export interface RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure ex
|
|
|
39
39
|
}>;
|
|
40
40
|
}
|
|
41
41
|
export type RangePickerPropsForFieldSlot<TIsSingleInput extends boolean, TEnableAccessibleFieldDOMStructure extends boolean, TError> = (TIsSingleInput extends true ? BaseSingleInputFieldProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TError> : never) | (TIsSingleInput extends false ? BaseMultiInputFieldProps<TEnableAccessibleFieldDOMStructure, TError> : never);
|
|
42
|
-
export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<
|
|
42
|
+
export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<UsePickerValueContextValue, 'open' | 'setOpen'>, UseRangePositionResponse {
|
|
43
43
|
variant: PickerVariant;
|
|
44
44
|
fieldType: FieldType;
|
|
45
45
|
readOnly?: boolean;
|
|
@@ -10,7 +10,7 @@ import { onSpaceOrEnter } from '@mui/x-date-pickers/internals';
|
|
|
10
10
|
const useMultiInputFieldSlotProps = ({
|
|
11
11
|
variant,
|
|
12
12
|
open,
|
|
13
|
-
|
|
13
|
+
setOpen,
|
|
14
14
|
readOnly,
|
|
15
15
|
labelId,
|
|
16
16
|
disableOpenPicker,
|
|
@@ -54,14 +54,16 @@ const useMultiInputFieldSlotProps = ({
|
|
|
54
54
|
event.stopPropagation();
|
|
55
55
|
onRangePositionChange('start');
|
|
56
56
|
if (!readOnly && !disableOpenPicker) {
|
|
57
|
-
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
setOpen(true);
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
const openRangeEndSelection = event => {
|
|
61
62
|
event.stopPropagation();
|
|
62
63
|
onRangePositionChange('end');
|
|
63
64
|
if (!readOnly && !disableOpenPicker) {
|
|
64
|
-
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
setOpen(true);
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
69
|
const handleFocusStart = () => {
|
|
@@ -148,7 +150,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
148
150
|
const useSingleInputFieldSlotProps = ({
|
|
149
151
|
variant,
|
|
150
152
|
open,
|
|
151
|
-
|
|
153
|
+
setOpen,
|
|
152
154
|
readOnly,
|
|
153
155
|
labelId,
|
|
154
156
|
disableOpenPicker,
|
|
@@ -197,7 +199,8 @@ const useSingleInputFieldSlotProps = ({
|
|
|
197
199
|
const openPicker = event => {
|
|
198
200
|
event.stopPropagation();
|
|
199
201
|
if (!readOnly && !disableOpenPicker) {
|
|
200
|
-
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
setOpen(true);
|
|
201
204
|
}
|
|
202
205
|
};
|
|
203
206
|
const slots = _extends({}, fieldProps.slots, {
|
|
@@ -57,8 +57,6 @@ export const useMobileRangePicker = _ref => {
|
|
|
57
57
|
fieldRef = endFieldRef;
|
|
58
58
|
}
|
|
59
59
|
const {
|
|
60
|
-
open,
|
|
61
|
-
actions,
|
|
62
60
|
layoutProps,
|
|
63
61
|
providerProps,
|
|
64
62
|
renderCurrentView,
|
|
@@ -106,8 +104,9 @@ export const useMobileRangePicker = _ref => {
|
|
|
106
104
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
107
105
|
variant: 'mobile',
|
|
108
106
|
fieldType,
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
108
|
+
open: providerProps.contextValue.open,
|
|
109
|
+
setOpen: providerProps.contextValue.setOpen,
|
|
111
110
|
readOnly,
|
|
112
111
|
labelId,
|
|
113
112
|
disableOpenPicker,
|
|
@@ -156,8 +155,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
156
155
|
}, innerSlotProps?.mobilePaper)
|
|
157
156
|
});
|
|
158
157
|
const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
|
|
159
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog,
|
|
160
|
-
open: open,
|
|
158
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
161
159
|
slots: slots,
|
|
162
160
|
slotProps: slotProps,
|
|
163
161
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
|
|
@@ -165,7 +163,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
165
163
|
slotProps: slotPropsForLayout,
|
|
166
164
|
children: renderCurrentView()
|
|
167
165
|
}))
|
|
168
|
-
})
|
|
166
|
+
})]
|
|
169
167
|
}));
|
|
170
168
|
return {
|
|
171
169
|
renderPicker
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PickersModalDialogSlots, PickersModalDialogSlotProps, UsePickerViewsProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { RangeOnlyPickerProps, RangePickerAdditionalViewProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
|
|
3
|
-
export interface UseMobileRangePickerSlots
|
|
3
|
+
export interface UseMobileRangePickerSlots extends UseRangePickerSlots, PickersModalDialogSlots {
|
|
4
4
|
}
|
|
5
|
-
export interface UseMobileRangePickerSlotProps<
|
|
5
|
+
export interface UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, PickersModalDialogSlotProps {
|
|
6
6
|
}
|
|
7
7
|
export interface MobileRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
8
8
|
}
|
|
@@ -11,12 +11,12 @@ export interface UseMobileRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
11
11
|
* Overridable component slots.
|
|
12
12
|
* @default {}
|
|
13
13
|
*/
|
|
14
|
-
slots: UseMobileRangePickerSlots
|
|
14
|
+
slots: UseMobileRangePickerSlots;
|
|
15
15
|
/**
|
|
16
16
|
* The props used for each component slot.
|
|
17
17
|
* @default {}
|
|
18
18
|
*/
|
|
19
|
-
slotProps?: UseMobileRangePickerSlotProps<
|
|
19
|
+
slotProps?: UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
20
20
|
}
|
|
21
21
|
export interface MobileRangePickerAdditionalViewProps extends RangePickerAdditionalViewProps {
|
|
22
22
|
}
|
|
@@ -2,9 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { BasePickerProps, UsePickerParams, ExportedBaseToolbarProps, StaticOnlyPickerProps, DateOrTimeViewWithMeridiem, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps } from '@mui/x-date-pickers/PickersLayout';
|
|
4
4
|
import { UseRangePositionProps } from '../useRangePosition';
|
|
5
|
-
export interface UseStaticRangePickerSlots
|
|
5
|
+
export interface UseStaticRangePickerSlots extends ExportedPickersLayoutSlots<PickerRangeValue> {
|
|
6
6
|
}
|
|
7
|
-
export interface UseStaticRangePickerSlotProps
|
|
7
|
+
export interface UseStaticRangePickerSlotProps extends ExportedPickersLayoutSlotProps<PickerRangeValue> {
|
|
8
8
|
toolbar?: ExportedBaseToolbarProps;
|
|
9
9
|
}
|
|
10
10
|
export interface StaticRangeOnlyPickerProps extends StaticOnlyPickerProps, UseRangePositionProps {
|
|
@@ -14,12 +14,12 @@ export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
14
14
|
* Overridable components.
|
|
15
15
|
* @default {}
|
|
16
16
|
*/
|
|
17
|
-
slots?: UseStaticRangePickerSlots
|
|
17
|
+
slots?: UseStaticRangePickerSlots;
|
|
18
18
|
/**
|
|
19
19
|
* The props used for each component slot.
|
|
20
20
|
* @default {}
|
|
21
21
|
*/
|
|
22
|
-
slotProps?: UseStaticRangePickerSlotProps
|
|
22
|
+
slotProps?: UseStaticRangePickerSlotProps;
|
|
23
23
|
}
|
|
24
24
|
export interface UseStaticRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator'> {
|
|
25
25
|
props: TExternalProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczNTE2NDAwMDAwMA==";
|
|
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 _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 };
|
|
@@ -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 };
|
|
@@ -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 };
|
package/modern/index.js
CHANGED
|
@@ -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
|
|
@@ -10,7 +10,7 @@ import { onSpaceOrEnter } from '@mui/x-date-pickers/internals';
|
|
|
10
10
|
const useMultiInputFieldSlotProps = ({
|
|
11
11
|
variant,
|
|
12
12
|
open,
|
|
13
|
-
|
|
13
|
+
setOpen,
|
|
14
14
|
readOnly,
|
|
15
15
|
labelId,
|
|
16
16
|
disableOpenPicker,
|
|
@@ -54,14 +54,16 @@ const useMultiInputFieldSlotProps = ({
|
|
|
54
54
|
event.stopPropagation();
|
|
55
55
|
onRangePositionChange('start');
|
|
56
56
|
if (!readOnly && !disableOpenPicker) {
|
|
57
|
-
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
setOpen(true);
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
const openRangeEndSelection = event => {
|
|
61
62
|
event.stopPropagation();
|
|
62
63
|
onRangePositionChange('end');
|
|
63
64
|
if (!readOnly && !disableOpenPicker) {
|
|
64
|
-
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
setOpen(true);
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
69
|
const handleFocusStart = () => {
|
|
@@ -148,7 +150,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
148
150
|
const useSingleInputFieldSlotProps = ({
|
|
149
151
|
variant,
|
|
150
152
|
open,
|
|
151
|
-
|
|
153
|
+
setOpen,
|
|
152
154
|
readOnly,
|
|
153
155
|
labelId,
|
|
154
156
|
disableOpenPicker,
|
|
@@ -197,7 +199,8 @@ const useSingleInputFieldSlotProps = ({
|
|
|
197
199
|
const openPicker = event => {
|
|
198
200
|
event.stopPropagation();
|
|
199
201
|
if (!readOnly && !disableOpenPicker) {
|
|
200
|
-
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
setOpen(true);
|
|
201
204
|
}
|
|
202
205
|
};
|
|
203
206
|
const slots = _extends({}, fieldProps.slots, {
|
|
@@ -57,8 +57,6 @@ export const useMobileRangePicker = _ref => {
|
|
|
57
57
|
fieldRef = endFieldRef;
|
|
58
58
|
}
|
|
59
59
|
const {
|
|
60
|
-
open,
|
|
61
|
-
actions,
|
|
62
60
|
layoutProps,
|
|
63
61
|
providerProps,
|
|
64
62
|
renderCurrentView,
|
|
@@ -106,8 +104,9 @@ export const useMobileRangePicker = _ref => {
|
|
|
106
104
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
107
105
|
variant: 'mobile',
|
|
108
106
|
fieldType,
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
108
|
+
open: providerProps.contextValue.open,
|
|
109
|
+
setOpen: providerProps.contextValue.setOpen,
|
|
111
110
|
readOnly,
|
|
112
111
|
labelId,
|
|
113
112
|
disableOpenPicker,
|
|
@@ -156,8 +155,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
156
155
|
}, innerSlotProps?.mobilePaper)
|
|
157
156
|
});
|
|
158
157
|
const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
|
|
159
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog,
|
|
160
|
-
open: open,
|
|
158
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
161
159
|
slots: slots,
|
|
162
160
|
slotProps: slotProps,
|
|
163
161
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
|
|
@@ -165,7 +163,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
165
163
|
slotProps: slotPropsForLayout,
|
|
166
164
|
children: renderCurrentView()
|
|
167
165
|
}))
|
|
168
|
-
})
|
|
166
|
+
})]
|
|
169
167
|
}));
|
|
170
168
|
return {
|
|
171
169
|
renderPicker
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczNTE2NDAwMDAwMA==";
|
|
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
|