@mui/x-date-pickers-pro 8.0.0-alpha.7 → 8.0.0-alpha.9
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 +551 -3
- package/DateRangeCalendar/DateRangeCalendar.js +4 -4
- package/DateRangePicker/DateRangePickerToolbar.js +3 -3
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +3 -3
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +7 -7
- package/MultiInputDateRangeField/MultiInputDateRangeField.d.ts +9 -4
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +12 -116
- package/MultiInputDateRangeField/index.d.ts +5 -3
- package/MultiInputDateRangeField/index.js +2 -2
- package/MultiInputDateRangeField/multiInputDateRangeFieldClasses.d.ts +6 -0
- package/MultiInputDateRangeField/multiInputDateRangeFieldClasses.js +4 -0
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.d.ts +9 -4
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +12 -116
- package/MultiInputDateTimeRangeField/index.d.ts +5 -3
- package/MultiInputDateTimeRangeField/index.js +2 -2
- package/MultiInputDateTimeRangeField/multiInputDateTimeRangeFieldClasses.d.ts +6 -0
- package/MultiInputDateTimeRangeField/multiInputDateTimeRangeFieldClasses.js +4 -0
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.d.ts +9 -4
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +13 -117
- package/MultiInputTimeRangeField/index.d.ts +5 -3
- package/MultiInputTimeRangeField/index.js +2 -2
- package/MultiInputTimeRangeField/multiInputTimeRangeFieldClasses.d.ts +6 -0
- package/MultiInputTimeRangeField/multiInputTimeRangeFieldClasses.js +4 -0
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -30
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +6 -17
- package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -1
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +20 -30
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +6 -18
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -1
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +20 -30
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +6 -18
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useMultiInputRangeField/index.d.ts +1 -0
- package/hooks/useMultiInputRangeField/index.js +1 -0
- package/hooks/useMultiInputRangeField/useMultiInputRangeField.d.ts +53 -0
- package/hooks/useMultiInputRangeField/useMultiInputRangeField.js +149 -0
- package/{internals/hooks/useMultiInputFieldSelectedSections.d.ts → hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.d.ts} +3 -4
- package/{modern/internals/hooks/useMultiInputFieldSelectedSections.js → hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.js} +10 -8
- package/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.d.ts +17 -0
- package/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.js +59 -0
- package/index.js +1 -1
- package/internals/hooks/models/index.d.ts +1 -1
- package/internals/hooks/models/useRangePicker.d.ts +4 -6
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -42
- package/internals/hooks/{useEnrichedRangePickerFieldProps.d.ts → useEnrichedRangePickerField.d.ts} +15 -6
- package/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +39 -52
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +23 -32
- package/internals/hooks/useRangePosition.d.ts +1 -1
- package/internals/hooks/useRangePosition.js +1 -1
- package/internals/models/dateTimeRange.d.ts +1 -6
- package/internals/models/fields.d.ts +1 -2
- package/internals/models/index.d.ts +0 -1
- package/internals/models/index.js +0 -1
- package/internals/models/managers.d.ts +3 -0
- package/internals/utils/createMultiInputRangeField/createMultiInputRangeField.d.ts +3 -0
- package/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +133 -0
- package/internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.d.ts +72 -0
- package/internals/utils/createMultiInputRangeField/index.d.ts +3 -0
- package/internals/utils/createMultiInputRangeField/index.js +2 -0
- package/internals/utils/releaseInfo.js +1 -1
- package/managers/index.d.ts +3 -3
- package/managers/useDateRangeManager.d.ts +1 -1
- package/managers/useDateRangeManager.js +3 -1
- package/managers/useDateTimeRangeManager.d.ts +1 -1
- package/managers/useDateTimeRangeManager.js +3 -1
- package/managers/useTimeRangeManager.d.ts +1 -1
- package/managers/useTimeRangeManager.js +3 -1
- package/models/fields.d.ts +1 -2
- package/models/index.d.ts +0 -2
- package/models/index.js +0 -2
- package/modern/DateRangeCalendar/DateRangeCalendar.js +4 -4
- package/modern/DateRangePicker/DateRangePickerToolbar.js +3 -3
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +3 -3
- package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -2
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +7 -7
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +12 -116
- package/modern/MultiInputDateRangeField/index.js +2 -2
- package/modern/MultiInputDateRangeField/multiInputDateRangeFieldClasses.js +4 -0
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +12 -116
- package/modern/MultiInputDateTimeRangeField/index.js +2 -2
- package/modern/MultiInputDateTimeRangeField/multiInputDateTimeRangeFieldClasses.js +4 -0
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +13 -117
- package/modern/MultiInputTimeRangeField/index.js +2 -2
- package/modern/MultiInputTimeRangeField/multiInputTimeRangeFieldClasses.js +4 -0
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -30
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -1
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +20 -30
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -1
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +20 -30
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -1
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/useMultiInputRangeField/index.js +1 -0
- package/modern/hooks/useMultiInputRangeField/useMultiInputRangeField.js +149 -0
- package/{internals/hooks/useMultiInputFieldSelectedSections.js → modern/hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.js} +10 -8
- package/modern/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.js +59 -0
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -42
- package/modern/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +39 -52
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +23 -32
- package/modern/internals/hooks/useRangePosition.js +1 -1
- package/modern/internals/models/index.js +0 -1
- package/modern/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +133 -0
- package/modern/internals/utils/createMultiInputRangeField/index.js +2 -0
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/managers/useDateRangeManager.js +3 -1
- package/modern/managers/useDateTimeRangeManager.js +3 -1
- package/modern/managers/useTimeRangeManager.js +3 -1
- package/modern/models/index.js +0 -2
- package/node/DateRangeCalendar/DateRangeCalendar.js +4 -4
- package/node/DateRangePicker/DateRangePickerToolbar.js +3 -3
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +3 -3
- package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -2
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +7 -7
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +11 -119
- package/node/MultiInputDateRangeField/index.js +3 -9
- package/node/MultiInputDateRangeField/multiInputDateRangeFieldClasses.js +12 -0
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +11 -119
- package/node/MultiInputDateTimeRangeField/index.js +3 -9
- package/node/MultiInputDateTimeRangeField/multiInputDateTimeRangeFieldClasses.js +12 -0
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +12 -120
- package/node/MultiInputTimeRangeField/index.js +3 -9
- package/node/MultiInputTimeRangeField/multiInputTimeRangeFieldClasses.js +12 -0
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +19 -29
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -1
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +19 -29
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -1
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +19 -29
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -1
- package/node/hooks/index.js +8 -1
- package/node/hooks/useMultiInputRangeField/index.js +12 -0
- package/node/hooks/useMultiInputRangeField/useMultiInputRangeField.js +155 -0
- package/node/{internals/hooks/useMultiInputFieldSelectedSections.js → hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.js} +11 -10
- package/node/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.js +66 -0
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +31 -41
- package/node/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +41 -54
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +22 -31
- package/node/internals/hooks/useRangePosition.js +1 -1
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +140 -0
- package/node/internals/utils/createMultiInputRangeField/index.js +19 -0
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/managers/useDateRangeManager.js +3 -1
- package/node/managers/useDateTimeRangeManager.js +3 -1
- package/node/managers/useTimeRangeManager.js +3 -1
- package/node/models/index.js +0 -22
- package/package.json +4 -4
- package/themeAugmentation/overrides.d.ts +6 -4
- package/themeAugmentation/props.d.ts +2 -2
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +0 -55
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +0 -56
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +0 -56
- package/internals/hooks/useMultiInputRangeField/shared.d.ts +0 -1
- package/internals/hooks/useMultiInputRangeField/shared.js +0 -9
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -118
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -118
- package/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +0 -11
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -118
- package/internals/models/timeRange.d.ts +0 -6
- package/internals/models/timeRange.js +0 -1
- package/models/dateRange.d.ts +0 -7
- package/models/dateRange.js +0 -1
- package/models/multiInputRangeFieldClasses.d.ts +0 -7
- package/models/multiInputRangeFieldClasses.js +0 -1
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.types.js +0 -1
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js +0 -1
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.types.js +0 -1
- package/modern/internals/hooks/useMultiInputRangeField/shared.js +0 -9
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -118
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -118
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -1
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -118
- package/modern/internals/models/timeRange.js +0 -1
- package/modern/models/dateRange.js +0 -1
- package/modern/models/multiInputRangeFieldClasses.js +0 -1
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.types.js +0 -5
- package/node/internals/hooks/useMultiInputRangeField/shared.js +0 -16
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -126
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -126
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -5
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -126
- package/node/internals/models/timeRange.js +0 -5
- package/node/models/dateRange.js +0 -5
- package/node/models/multiInputRangeFieldClasses.js +0 -5
- /package/{MultiInputDateRangeField/MultiInputDateRangeField.types.js → internals/models/managers.js} +0 -0
- /package/{MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js → internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.js} +0 -0
- /package/{MultiInputTimeRangeField/MultiInputTimeRangeField.types.js → modern/internals/models/managers.js} +0 -0
- /package/{internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js → modern/internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.js} +0 -0
- /package/node/{MultiInputDateRangeField/MultiInputDateRangeField.types.js → internals/models/managers.js} +0 -0
- /package/node/{MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js → internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.js} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
const _excluded = ["clearable", "onClear"];
|
|
3
|
+
import { useDateManager, useDateTimeManager, useTimeManager } from '@mui/x-date-pickers/managers';
|
|
4
|
+
import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
|
|
5
|
+
import { useField, useFieldInternalPropsWithDefaults } from '@mui/x-date-pickers/internals';
|
|
6
|
+
/**
|
|
7
|
+
* @ignore - internal hook.
|
|
8
|
+
*/
|
|
9
|
+
export function useMultiInputRangeFieldTextFieldProps(parameters) {
|
|
10
|
+
const {
|
|
11
|
+
fieldProps,
|
|
12
|
+
valueType
|
|
13
|
+
} = parameters;
|
|
14
|
+
let useManager;
|
|
15
|
+
switch (valueType) {
|
|
16
|
+
case 'date':
|
|
17
|
+
{
|
|
18
|
+
useManager = useDateManager;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
case 'time':
|
|
22
|
+
{
|
|
23
|
+
useManager = useTimeManager;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case 'date-time':
|
|
27
|
+
{
|
|
28
|
+
useManager = useDateTimeManager;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
default:
|
|
32
|
+
{
|
|
33
|
+
throw new Error(`Unknown valueType: ${valueType}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const manager = useManager({
|
|
37
|
+
enableAccessibleFieldDOMStructure: fieldProps.enableAccessibleFieldDOMStructure
|
|
38
|
+
});
|
|
39
|
+
const {
|
|
40
|
+
forwardedProps,
|
|
41
|
+
internalProps
|
|
42
|
+
} = useSplitFieldProps(fieldProps, 'date');
|
|
43
|
+
const internalPropsWithDefaults = useFieldInternalPropsWithDefaults({
|
|
44
|
+
manager,
|
|
45
|
+
internalProps
|
|
46
|
+
});
|
|
47
|
+
const _ref = useField({
|
|
48
|
+
forwardedProps,
|
|
49
|
+
internalProps: internalPropsWithDefaults,
|
|
50
|
+
valueManager: manager.internal_valueManager,
|
|
51
|
+
fieldValueManager: manager.internal_fieldValueManager,
|
|
52
|
+
validator: manager.validator,
|
|
53
|
+
valueType: manager.valueType,
|
|
54
|
+
// TODO v8: Add a real aria label before moving the opening logic to the field on range pickers.
|
|
55
|
+
getOpenPickerButtonAriaLabel: () => ''
|
|
56
|
+
}),
|
|
57
|
+
fieldResponse = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
58
|
+
return fieldResponse;
|
|
59
|
+
}
|
package/modern/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import * as React from 'react';
|
|
|
5
5
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
6
6
|
import { useLicenseVerifier } from '@mui/x-license';
|
|
7
7
|
import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
|
|
8
|
-
import { executeInTheNextEventLoopTick, getActiveElement, usePicker, PickersPopper, PickerProvider } from '@mui/x-date-pickers/internals';
|
|
9
|
-
import {
|
|
8
|
+
import { executeInTheNextEventLoopTick, getActiveElement, usePicker, PickersPopper, PickerProvider, PickerFieldUIContextProvider } from '@mui/x-date-pickers/internals';
|
|
9
|
+
import { useEnrichedRangePickerField } from "../useEnrichedRangePickerField.js";
|
|
10
10
|
import { getReleaseInfo } from "../../utils/releaseInfo.js";
|
|
11
11
|
import { useRangePosition } from "../useRangePosition.js";
|
|
12
12
|
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
@@ -23,24 +23,16 @@ export const useDesktopRangePicker = _ref => {
|
|
|
23
23
|
slotProps,
|
|
24
24
|
className,
|
|
25
25
|
sx,
|
|
26
|
-
format,
|
|
27
|
-
formatDensity,
|
|
28
|
-
enableAccessibleFieldDOMStructure,
|
|
29
|
-
selectedSections,
|
|
30
|
-
onSelectedSectionsChange,
|
|
31
|
-
timezone,
|
|
32
26
|
label,
|
|
33
27
|
inputRef,
|
|
34
28
|
name,
|
|
35
29
|
readOnly,
|
|
36
|
-
disabled,
|
|
37
30
|
autoFocus,
|
|
38
31
|
disableOpenPicker,
|
|
39
32
|
localeText,
|
|
40
33
|
reduceAnimations
|
|
41
34
|
} = props;
|
|
42
35
|
const fieldContainerRef = React.useRef(null);
|
|
43
|
-
const anchorRef = React.useRef(null);
|
|
44
36
|
const popperRef = React.useRef(null);
|
|
45
37
|
const startFieldRef = React.useRef(null);
|
|
46
38
|
const endFieldRef = React.useRef(null);
|
|
@@ -60,7 +52,6 @@ export const useDesktopRangePicker = _ref => {
|
|
|
60
52
|
providerProps,
|
|
61
53
|
renderCurrentView,
|
|
62
54
|
shouldRestoreFocus,
|
|
63
|
-
fieldProps: pickerFieldProps,
|
|
64
55
|
ownerState
|
|
65
56
|
} = usePicker(_extends({}, pickerParams, {
|
|
66
57
|
props,
|
|
@@ -69,6 +60,9 @@ export const useDesktopRangePicker = _ref => {
|
|
|
69
60
|
fieldRef,
|
|
70
61
|
localeText
|
|
71
62
|
}));
|
|
63
|
+
|
|
64
|
+
// Temporary hack to hide the opening button on the range pickers until we have migrate them to the new opening logic.
|
|
65
|
+
providerProps.contextValue.triggerStatus = 'hidden';
|
|
72
66
|
React.useEffect(() => {
|
|
73
67
|
if (providerProps.contextValue.view) {
|
|
74
68
|
initialView.current = providerProps.contextValue.view;
|
|
@@ -92,17 +86,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
92
86
|
additionalProps: _extends({
|
|
93
87
|
// Internal props
|
|
94
88
|
readOnly,
|
|
95
|
-
|
|
96
|
-
format,
|
|
97
|
-
formatDensity,
|
|
98
|
-
enableAccessibleFieldDOMStructure,
|
|
99
|
-
selectedSections,
|
|
100
|
-
onSelectedSectionsChange,
|
|
101
|
-
timezone,
|
|
102
|
-
autoFocus: autoFocus && !props.open
|
|
103
|
-
}, pickerFieldProps, {
|
|
104
|
-
// onChange and value
|
|
105
|
-
|
|
89
|
+
autoFocus: autoFocus && !props.open,
|
|
106
90
|
// Forwarded props
|
|
107
91
|
className,
|
|
108
92
|
sx,
|
|
@@ -114,12 +98,12 @@ export const useDesktopRangePicker = _ref => {
|
|
|
114
98
|
}),
|
|
115
99
|
ownerState
|
|
116
100
|
});
|
|
117
|
-
const
|
|
101
|
+
const enrichedFieldResponse = useEnrichedRangePickerField(_extends({
|
|
118
102
|
variant: 'desktop',
|
|
119
103
|
fieldType,
|
|
120
104
|
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
121
|
-
|
|
122
|
-
|
|
105
|
+
contextValue: providerProps.contextValue,
|
|
106
|
+
fieldPrivateContextValue: providerProps.fieldPrivateContextValue,
|
|
123
107
|
readOnly,
|
|
124
108
|
disableOpenPicker,
|
|
125
109
|
label,
|
|
@@ -128,7 +112,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
128
112
|
pickerSlotProps: slotProps,
|
|
129
113
|
pickerSlots: slots,
|
|
130
114
|
fieldProps,
|
|
131
|
-
anchorRef,
|
|
115
|
+
anchorRef: providerProps.contextValue.triggerRef,
|
|
132
116
|
startFieldRef,
|
|
133
117
|
endFieldRef,
|
|
134
118
|
singleInputFieldRef,
|
|
@@ -137,24 +121,30 @@ export const useDesktopRangePicker = _ref => {
|
|
|
137
121
|
}, rangePositionResponse));
|
|
138
122
|
const Layout = slots?.layout ?? PickersLayout;
|
|
139
123
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
124
|
+
// This override will go away once the range fields handle the picker opening
|
|
125
|
+
fieldPrivateContextValue: _extends({}, providerProps.fieldPrivateContextValue, enrichedFieldResponse.fieldPrivateContextValue),
|
|
126
|
+
children: /*#__PURE__*/_jsx(PickerFieldUIContextProvider, {
|
|
127
|
+
slots: slots,
|
|
128
|
+
slotProps: slotProps,
|
|
129
|
+
children: /*#__PURE__*/_jsxs(PickerRangePositionContext.Provider, {
|
|
130
|
+
value: rangePositionResponse,
|
|
131
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldResponse.fieldProps)), /*#__PURE__*/_jsx(PickersPopper, {
|
|
132
|
+
role: "tooltip",
|
|
133
|
+
placement: "bottom-start",
|
|
134
|
+
containerRef: popperRef,
|
|
135
|
+
anchorEl: providerProps.contextValue.triggerRef.current,
|
|
136
|
+
onBlur: handleBlur,
|
|
153
137
|
slots: slots,
|
|
154
138
|
slotProps: slotProps,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
139
|
+
shouldRestoreFocus: shouldRestoreFocus,
|
|
140
|
+
reduceAnimations: reduceAnimations,
|
|
141
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
142
|
+
slots: slots,
|
|
143
|
+
slotProps: slotProps,
|
|
144
|
+
children: renderCurrentView()
|
|
145
|
+
}))
|
|
146
|
+
})]
|
|
147
|
+
})
|
|
158
148
|
})
|
|
159
149
|
}));
|
|
160
150
|
return {
|
|
@@ -8,15 +8,14 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
8
8
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
9
9
|
import { onSpaceOrEnter } from '@mui/x-date-pickers/internals';
|
|
10
10
|
const useMultiInputFieldSlotProps = ({
|
|
11
|
+
contextValue,
|
|
11
12
|
variant,
|
|
12
|
-
open,
|
|
13
|
-
setOpen,
|
|
14
13
|
readOnly,
|
|
15
14
|
labelId,
|
|
16
15
|
disableOpenPicker,
|
|
17
16
|
onBlur,
|
|
18
17
|
rangePosition,
|
|
19
|
-
|
|
18
|
+
setRangePosition,
|
|
20
19
|
localeText: inLocaleText,
|
|
21
20
|
pickerSlotProps,
|
|
22
21
|
pickerSlots,
|
|
@@ -24,7 +23,6 @@ const useMultiInputFieldSlotProps = ({
|
|
|
24
23
|
anchorRef,
|
|
25
24
|
currentView,
|
|
26
25
|
initialView,
|
|
27
|
-
setView,
|
|
28
26
|
startFieldRef,
|
|
29
27
|
endFieldRef
|
|
30
28
|
}) => {
|
|
@@ -33,7 +31,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
33
31
|
const handleEndFieldRef = useForkRef(fieldProps.unstableEndFieldRef, endFieldRef);
|
|
34
32
|
const previousRangePosition = React.useRef(rangePosition);
|
|
35
33
|
React.useEffect(() => {
|
|
36
|
-
if (!open || variant === 'mobile') {
|
|
34
|
+
if (!contextValue.open || variant === 'mobile') {
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
39
37
|
const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
|
|
@@ -49,36 +47,36 @@ const useMultiInputFieldSlotProps = ({
|
|
|
49
47
|
// use the current view or `0` when the range position has just been swapped
|
|
50
48
|
previousRangePosition.current === rangePosition ? currentView : 0);
|
|
51
49
|
previousRangePosition.current = rangePosition;
|
|
52
|
-
}, [rangePosition, open, currentView, startFieldRef, endFieldRef, variant]);
|
|
50
|
+
}, [rangePosition, contextValue.open, currentView, startFieldRef, endFieldRef, variant]);
|
|
53
51
|
const openRangeStartSelection = event => {
|
|
54
52
|
event.stopPropagation();
|
|
55
|
-
|
|
53
|
+
setRangePosition('start');
|
|
56
54
|
if (!readOnly && !disableOpenPicker) {
|
|
57
55
|
event.preventDefault();
|
|
58
|
-
setOpen(true);
|
|
56
|
+
contextValue.setOpen(true);
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
59
|
const openRangeEndSelection = event => {
|
|
62
60
|
event.stopPropagation();
|
|
63
|
-
|
|
61
|
+
setRangePosition('end');
|
|
64
62
|
if (!readOnly && !disableOpenPicker) {
|
|
65
63
|
event.preventDefault();
|
|
66
|
-
setOpen(true);
|
|
64
|
+
contextValue.setOpen(true);
|
|
67
65
|
}
|
|
68
66
|
};
|
|
69
67
|
const handleFocusStart = () => {
|
|
70
|
-
if (open) {
|
|
71
|
-
|
|
68
|
+
if (contextValue.open) {
|
|
69
|
+
setRangePosition('start');
|
|
72
70
|
if (previousRangePosition.current !== 'start' && initialView) {
|
|
73
|
-
setView?.(initialView);
|
|
71
|
+
contextValue.setView?.(initialView);
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
};
|
|
77
75
|
const handleFocusEnd = () => {
|
|
78
|
-
if (open) {
|
|
79
|
-
|
|
76
|
+
if (contextValue.open) {
|
|
77
|
+
setRangePosition('end');
|
|
80
78
|
if (previousRangePosition.current !== 'end' && initialView) {
|
|
81
|
-
setView?.(initialView);
|
|
79
|
+
contextValue.setView?.(initialView);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
};
|
|
@@ -97,8 +95,8 @@ const useMultiInputFieldSlotProps = ({
|
|
|
97
95
|
label: inLocaleText?.start ?? translations.start,
|
|
98
96
|
onKeyDown: onSpaceOrEnter(openRangeStartSelection),
|
|
99
97
|
onFocus: handleFocusStart,
|
|
100
|
-
focused: open ? rangePosition === 'start' : undefined
|
|
101
|
-
}, !readOnly && !
|
|
98
|
+
focused: contextValue.open ? rangePosition === 'start' : undefined
|
|
99
|
+
}, !readOnly && !contextValue.disabled && {
|
|
102
100
|
onClick: openRangeStartSelection
|
|
103
101
|
}, variant === 'mobile' && {
|
|
104
102
|
readOnly: true
|
|
@@ -113,8 +111,8 @@ const useMultiInputFieldSlotProps = ({
|
|
|
113
111
|
label: inLocaleText?.end ?? translations.end,
|
|
114
112
|
onKeyDown: onSpaceOrEnter(openRangeEndSelection),
|
|
115
113
|
onFocus: handleFocusEnd,
|
|
116
|
-
focused: open ? rangePosition === 'end' : undefined
|
|
117
|
-
}, !readOnly && !
|
|
114
|
+
focused: contextValue.open ? rangePosition === 'end' : undefined
|
|
115
|
+
}, !readOnly && !contextValue.disabled && {
|
|
118
116
|
onClick: openRangeEndSelection
|
|
119
117
|
}, variant === 'mobile' && {
|
|
120
118
|
readOnly: true
|
|
@@ -145,29 +143,29 @@ const useMultiInputFieldSlotProps = ({
|
|
|
145
143
|
slots,
|
|
146
144
|
slotProps
|
|
147
145
|
});
|
|
148
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
fieldProps: enrichedFieldProps,
|
|
148
|
+
fieldPrivateContextValue: {}
|
|
149
|
+
};
|
|
149
150
|
};
|
|
150
151
|
const useSingleInputFieldSlotProps = ({
|
|
152
|
+
contextValue,
|
|
153
|
+
fieldPrivateContextValue,
|
|
151
154
|
variant,
|
|
152
|
-
open,
|
|
153
|
-
setOpen,
|
|
154
155
|
readOnly,
|
|
155
156
|
labelId,
|
|
156
157
|
disableOpenPicker,
|
|
157
158
|
label,
|
|
158
159
|
onBlur,
|
|
159
160
|
rangePosition,
|
|
160
|
-
|
|
161
|
+
setRangePosition,
|
|
161
162
|
singleInputFieldRef,
|
|
162
|
-
pickerSlots,
|
|
163
|
-
pickerSlotProps,
|
|
164
163
|
fieldProps,
|
|
165
|
-
anchorRef,
|
|
166
164
|
currentView
|
|
167
165
|
}) => {
|
|
168
166
|
const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
|
|
169
167
|
React.useEffect(() => {
|
|
170
|
-
if (!open || !singleInputFieldRef.current || variant === 'mobile') {
|
|
168
|
+
if (!contextValue.open || !singleInputFieldRef.current || variant === 'mobile') {
|
|
171
169
|
return;
|
|
172
170
|
}
|
|
173
171
|
if (singleInputFieldRef.current.isFieldFocused()) {
|
|
@@ -180,7 +178,7 @@ const useSingleInputFieldSlotProps = ({
|
|
|
180
178
|
const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
|
|
181
179
|
singleInputFieldRef.current?.focusField(newSelectedSection);
|
|
182
180
|
}
|
|
183
|
-
}, [rangePosition, open, currentView, singleInputFieldRef, variant]);
|
|
181
|
+
}, [rangePosition, contextValue.open, currentView, singleInputFieldRef, variant]);
|
|
184
182
|
const updateRangePosition = () => {
|
|
185
183
|
if (!singleInputFieldRef.current?.isFieldFocused()) {
|
|
186
184
|
return;
|
|
@@ -189,52 +187,41 @@ const useSingleInputFieldSlotProps = ({
|
|
|
189
187
|
const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
|
|
190
188
|
const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
|
|
191
189
|
if (domRangePosition != null && domRangePosition !== rangePosition) {
|
|
192
|
-
|
|
190
|
+
setRangePosition(domRangePosition);
|
|
193
191
|
}
|
|
194
192
|
};
|
|
195
193
|
const handleSelectedSectionsChange = useEventCallback(selectedSection => {
|
|
196
194
|
setTimeout(updateRangePosition);
|
|
197
|
-
|
|
195
|
+
fieldPrivateContextValue.onSelectedSectionsChange?.(selectedSection);
|
|
198
196
|
});
|
|
199
197
|
const openPicker = event => {
|
|
200
198
|
event.stopPropagation();
|
|
201
199
|
if (!readOnly && !disableOpenPicker) {
|
|
202
200
|
event.preventDefault();
|
|
203
|
-
setOpen(true);
|
|
201
|
+
contextValue.setOpen(true);
|
|
204
202
|
}
|
|
205
203
|
};
|
|
206
|
-
const slots = _extends({}, fieldProps.slots, {
|
|
207
|
-
textField: pickerSlots?.textField,
|
|
208
|
-
clearButton: pickerSlots?.clearButton,
|
|
209
|
-
clearIcon: pickerSlots?.clearIcon
|
|
210
|
-
});
|
|
211
|
-
const slotProps = _extends({}, fieldProps.slotProps, {
|
|
212
|
-
textField: pickerSlotProps?.textField,
|
|
213
|
-
clearButton: pickerSlotProps?.clearButton,
|
|
214
|
-
clearIcon: pickerSlotProps?.clearIcon
|
|
215
|
-
});
|
|
216
204
|
const enrichedFieldProps = _extends({}, fieldProps, {
|
|
217
|
-
slots,
|
|
218
|
-
slotProps,
|
|
219
205
|
label,
|
|
220
206
|
unstableFieldRef: handleFieldRef,
|
|
221
207
|
onKeyDown: onSpaceOrEnter(openPicker, fieldProps.onKeyDown),
|
|
222
|
-
onSelectedSectionsChange: handleSelectedSectionsChange,
|
|
223
208
|
onBlur,
|
|
224
|
-
|
|
225
|
-
ref: anchorRef
|
|
226
|
-
}, fieldProps?.InputProps),
|
|
227
|
-
focused: open ? true : undefined
|
|
209
|
+
focused: contextValue.open ? true : undefined
|
|
228
210
|
}, labelId != null && {
|
|
229
211
|
id: labelId
|
|
230
212
|
}, variant === 'mobile' && {
|
|
231
213
|
readOnly: true
|
|
232
|
-
}, !readOnly && !
|
|
214
|
+
}, !readOnly && !contextValue.disabled && {
|
|
233
215
|
onClick: openPicker
|
|
234
216
|
});
|
|
235
|
-
return
|
|
217
|
+
return {
|
|
218
|
+
fieldProps: enrichedFieldProps,
|
|
219
|
+
fieldPrivateContextValue: {
|
|
220
|
+
onSelectedSectionsChange: handleSelectedSectionsChange
|
|
221
|
+
}
|
|
222
|
+
};
|
|
236
223
|
};
|
|
237
|
-
export const
|
|
224
|
+
export const useEnrichedRangePickerField = params => {
|
|
238
225
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
239
226
|
if (process.env.NODE_ENV !== 'production') {
|
|
240
227
|
const fieldTypeRef = React.useRef(params.fieldType);
|
|
@@ -5,10 +5,10 @@ import * as React from 'react';
|
|
|
5
5
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
6
6
|
import { useLicenseVerifier } from '@mui/x-license';
|
|
7
7
|
import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
|
|
8
|
-
import { usePicker, PickersModalDialog, PickerProvider } from '@mui/x-date-pickers/internals';
|
|
8
|
+
import { usePicker, PickersModalDialog, PickerProvider, PickerFieldUIContextProvider } from '@mui/x-date-pickers/internals';
|
|
9
9
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
10
10
|
import useId from '@mui/utils/useId';
|
|
11
|
-
import {
|
|
11
|
+
import { useEnrichedRangePickerField } from "../useEnrichedRangePickerField.js";
|
|
12
12
|
import { getReleaseInfo } from "../../utils/releaseInfo.js";
|
|
13
13
|
import { useRangePosition } from "../useRangePosition.js";
|
|
14
14
|
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
@@ -25,17 +25,10 @@ export const useMobileRangePicker = _ref => {
|
|
|
25
25
|
slotProps: innerSlotProps,
|
|
26
26
|
className,
|
|
27
27
|
sx,
|
|
28
|
-
format,
|
|
29
|
-
formatDensity,
|
|
30
|
-
enableAccessibleFieldDOMStructure,
|
|
31
|
-
selectedSections,
|
|
32
|
-
onSelectedSectionsChange,
|
|
33
|
-
timezone,
|
|
34
28
|
label,
|
|
35
29
|
inputRef,
|
|
36
30
|
name,
|
|
37
31
|
readOnly,
|
|
38
|
-
disabled,
|
|
39
32
|
disableOpenPicker,
|
|
40
33
|
localeText
|
|
41
34
|
} = props;
|
|
@@ -57,7 +50,6 @@ export const useMobileRangePicker = _ref => {
|
|
|
57
50
|
const {
|
|
58
51
|
providerProps,
|
|
59
52
|
renderCurrentView,
|
|
60
|
-
fieldProps: pickerFieldProps,
|
|
61
53
|
ownerState
|
|
62
54
|
} = usePicker(_extends({}, pickerParams, {
|
|
63
55
|
props,
|
|
@@ -66,6 +58,9 @@ export const useMobileRangePicker = _ref => {
|
|
|
66
58
|
fieldRef,
|
|
67
59
|
localeText
|
|
68
60
|
}));
|
|
61
|
+
|
|
62
|
+
// Temporary hack to hide the opening button on the range pickers until we have migrate them to the new opening logic.
|
|
63
|
+
providerProps.contextValue.triggerStatus = 'hidden';
|
|
69
64
|
const Field = slots.field;
|
|
70
65
|
const fieldProps = useSlotProps({
|
|
71
66
|
elementType: Field,
|
|
@@ -73,16 +68,6 @@ export const useMobileRangePicker = _ref => {
|
|
|
73
68
|
additionalProps: _extends({
|
|
74
69
|
// Internal props
|
|
75
70
|
readOnly: readOnly ?? true,
|
|
76
|
-
disabled,
|
|
77
|
-
format,
|
|
78
|
-
formatDensity,
|
|
79
|
-
enableAccessibleFieldDOMStructure,
|
|
80
|
-
selectedSections,
|
|
81
|
-
onSelectedSectionsChange,
|
|
82
|
-
timezone
|
|
83
|
-
}, pickerFieldProps, {
|
|
84
|
-
// onChange and value
|
|
85
|
-
|
|
86
71
|
// Forwarded props
|
|
87
72
|
className,
|
|
88
73
|
sx
|
|
@@ -94,12 +79,12 @@ export const useMobileRangePicker = _ref => {
|
|
|
94
79
|
ownerState
|
|
95
80
|
});
|
|
96
81
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
97
|
-
const
|
|
82
|
+
const enrichedFieldResponse = useEnrichedRangePickerField(_extends({
|
|
98
83
|
variant: 'mobile',
|
|
99
84
|
fieldType,
|
|
100
85
|
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
contextValue: providerProps.contextValue,
|
|
87
|
+
fieldPrivateContextValue: providerProps.fieldPrivateContextValue,
|
|
103
88
|
readOnly,
|
|
104
89
|
labelId,
|
|
105
90
|
disableOpenPicker,
|
|
@@ -138,17 +123,23 @@ export const useMobileRangePicker = _ref => {
|
|
|
138
123
|
}, innerSlotProps?.mobilePaper)
|
|
139
124
|
});
|
|
140
125
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
126
|
+
// This override will go away once the range fields handle the picker opening
|
|
127
|
+
fieldPrivateContextValue: _extends({}, providerProps.fieldPrivateContextValue, enrichedFieldResponse.fieldPrivateContextValue),
|
|
128
|
+
children: /*#__PURE__*/_jsx(PickerFieldUIContextProvider, {
|
|
129
|
+
slots: slots,
|
|
130
|
+
slotProps: slotProps,
|
|
131
|
+
children: /*#__PURE__*/_jsxs(PickerRangePositionContext.Provider, {
|
|
132
|
+
value: rangePositionResponse,
|
|
133
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldResponse.fieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
147
134
|
slots: slots,
|
|
148
135
|
slotProps: slotProps,
|
|
149
|
-
children:
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
137
|
+
slots: slots,
|
|
138
|
+
slotProps: slotProps,
|
|
139
|
+
children: renderCurrentView()
|
|
140
|
+
}))
|
|
141
|
+
})]
|
|
142
|
+
})
|
|
152
143
|
})
|
|
153
144
|
}));
|
|
154
145
|
return {
|