@mui/x-date-pickers-pro 8.0.0-alpha.7 → 8.0.0-alpha.8
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 +115 -0
- 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
package/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js}
RENAMED
|
@@ -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 {
|
|
@@ -22,6 +22,6 @@ export interface UseRangePositionProps {
|
|
|
22
22
|
}
|
|
23
23
|
export interface UseRangePositionResponse {
|
|
24
24
|
rangePosition: RangePosition;
|
|
25
|
-
|
|
25
|
+
setRangePosition: (newPosition: RangePosition) => void;
|
|
26
26
|
}
|
|
27
27
|
export declare const useRangePosition: (props: UseRangePositionProps, singleInputFieldRef?: React.RefObject<FieldRef<PickerRangeValue> | null>) => UseRangePositionResponse;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UseFieldInternalProps, DateOrTimeViewWithMeridiem, AmPmProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
3
|
-
import { DateTimeRangeValidationError, RangeFieldSeparatorProps } from '../../models';
|
|
4
|
-
import { ExportedValidateDateTimeRangeProps } from '../../validation/validateDateTimeRange';
|
|
5
|
-
export interface UseDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateTimeRangeProps, AmPmProps {
|
|
6
|
-
}
|
|
1
|
+
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
7
2
|
export type DateTimeRangePickerView = Exclude<DateOrTimeViewWithMeridiem, 'month' | 'year'>;
|
|
8
3
|
export type DateTimeRangePickerViewExternal = Exclude<DateTimeRangePickerView, 'meridiem'>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SxProps } from '@mui/material/styles';
|
|
2
2
|
import { SlotComponentProps } from '@mui/utils';
|
|
3
|
-
import { MakeRequired } from '@mui/x-internals/types';
|
|
4
3
|
import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
5
4
|
import { FieldOwnerState } from '@mui/x-date-pickers/models';
|
|
6
5
|
import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
|
|
@@ -9,7 +8,7 @@ import type { MultiInputFieldRefs, MultiInputFieldSlotRootProps, RangeFieldSepar
|
|
|
9
8
|
* Props the multi input field can receive when used inside a picker.
|
|
10
9
|
* Only contains what the MUI components are passing to the field, not what users can pass using the `props.slotProps.field`.
|
|
11
10
|
*/
|
|
12
|
-
export interface BaseMultiInputFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TError> extends
|
|
11
|
+
export interface BaseMultiInputFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TError>, 'readOnly' | 'autoFocus'>, RangeFieldSeparatorProps, MultiInputFieldRefs {
|
|
13
12
|
className: string | undefined;
|
|
14
13
|
sx: SxProps<any> | undefined;
|
|
15
14
|
slots?: {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CreateMultiInputRangeFieldParameters, CreateMultiInputRangeFieldReturnValue } from './createMultiInputRangeField.types';
|
|
2
|
+
import { PickerAnyRangeManager } from '../../models/managers';
|
|
3
|
+
export declare function createMultiInputRangeField<TManager extends PickerAnyRangeManager>({ useManager, name, getUtilityClass, }: CreateMultiInputRangeFieldParameters<TManager>): CreateMultiInputRangeFieldReturnValue<TManager>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
const _excluded = ["slots", "slotProps", "className", "classes"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import Stack from '@mui/material/Stack';
|
|
9
|
+
import MuiTextField from '@mui/material/TextField';
|
|
10
|
+
import Typography from '@mui/material/Typography';
|
|
11
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
12
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
13
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
14
|
+
import { cleanFieldResponse, useFieldOwnerState } from '@mui/x-date-pickers/internals';
|
|
15
|
+
import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
|
|
16
|
+
import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
|
|
17
|
+
import { useMultiInputRangeField } from "../../../hooks/useMultiInputRangeField/index.js";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
export function createMultiInputRangeField({
|
|
20
|
+
useManager,
|
|
21
|
+
name,
|
|
22
|
+
getUtilityClass
|
|
23
|
+
}) {
|
|
24
|
+
const useUtilityClasses = classes => {
|
|
25
|
+
const slots = {
|
|
26
|
+
root: ['root'],
|
|
27
|
+
separator: ['separator']
|
|
28
|
+
};
|
|
29
|
+
return composeClasses(slots, getUtilityClass, classes);
|
|
30
|
+
};
|
|
31
|
+
const MultiInputRangeFieldRoot = styled(/*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/_jsx(Stack, _extends({
|
|
32
|
+
ref: ref,
|
|
33
|
+
spacing: 2,
|
|
34
|
+
direction: "row",
|
|
35
|
+
alignItems: "center"
|
|
36
|
+
}, props))), {
|
|
37
|
+
name,
|
|
38
|
+
slot: 'Root',
|
|
39
|
+
overridesResolver: (props, styles) => styles.root
|
|
40
|
+
})({});
|
|
41
|
+
const MultiInputRangeFieldSeparator = styled(Typography, {
|
|
42
|
+
name,
|
|
43
|
+
slot: 'Separator',
|
|
44
|
+
overridesResolver: (props, styles) => styles.separator
|
|
45
|
+
})({
|
|
46
|
+
lineHeight: '1.4375em' // 23px
|
|
47
|
+
});
|
|
48
|
+
const MultiInputRangeField = /*#__PURE__*/React.forwardRef(function MultiInputRangeField(props, ref) {
|
|
49
|
+
const themeProps = useThemeProps({
|
|
50
|
+
props,
|
|
51
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
52
|
+
name
|
|
53
|
+
});
|
|
54
|
+
const manager = useManager({
|
|
55
|
+
enableAccessibleFieldDOMStructure: props.enableAccessibleFieldDOMStructure,
|
|
56
|
+
dateSeparator: props.dateSeparator
|
|
57
|
+
});
|
|
58
|
+
const {
|
|
59
|
+
internalProps,
|
|
60
|
+
forwardedProps
|
|
61
|
+
} = useSplitFieldProps(themeProps, manager.valueType);
|
|
62
|
+
const {
|
|
63
|
+
slots,
|
|
64
|
+
slotProps,
|
|
65
|
+
className,
|
|
66
|
+
classes: classesProp
|
|
67
|
+
} = forwardedProps,
|
|
68
|
+
otherForwardedProps = _objectWithoutPropertiesLoose(forwardedProps, _excluded);
|
|
69
|
+
const classes = useUtilityClasses(classesProp);
|
|
70
|
+
const ownerState = useFieldOwnerState(internalProps);
|
|
71
|
+
const Root = slots?.root ?? MultiInputRangeFieldRoot;
|
|
72
|
+
const rootProps = useSlotProps({
|
|
73
|
+
elementType: Root,
|
|
74
|
+
externalSlotProps: slotProps?.root,
|
|
75
|
+
externalForwardedProps: otherForwardedProps,
|
|
76
|
+
additionalProps: {
|
|
77
|
+
ref
|
|
78
|
+
},
|
|
79
|
+
ownerState,
|
|
80
|
+
className: clsx(className, classes.root)
|
|
81
|
+
});
|
|
82
|
+
const startTextFieldProps = useSlotProps({
|
|
83
|
+
elementType: PickersTextField,
|
|
84
|
+
externalSlotProps: slotProps?.textField,
|
|
85
|
+
ownerState: _extends({}, ownerState, {
|
|
86
|
+
position: 'start'
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
const endTextFieldProps = useSlotProps({
|
|
90
|
+
elementType: PickersTextField,
|
|
91
|
+
externalSlotProps: slotProps?.textField,
|
|
92
|
+
ownerState: _extends({}, ownerState, {
|
|
93
|
+
position: 'end'
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
const {
|
|
97
|
+
startDate,
|
|
98
|
+
endDate,
|
|
99
|
+
enableAccessibleFieldDOMStructure
|
|
100
|
+
} = useMultiInputRangeField({
|
|
101
|
+
manager,
|
|
102
|
+
internalProps,
|
|
103
|
+
startForwardedProps: startTextFieldProps,
|
|
104
|
+
endForwardedProps: endTextFieldProps
|
|
105
|
+
});
|
|
106
|
+
const Separator = slots?.separator ?? MultiInputRangeFieldSeparator;
|
|
107
|
+
const separatorProps = useSlotProps({
|
|
108
|
+
elementType: Separator,
|
|
109
|
+
externalSlotProps: slotProps?.separator,
|
|
110
|
+
additionalProps: {
|
|
111
|
+
children: internalProps.dateSeparator ?? '–'
|
|
112
|
+
},
|
|
113
|
+
ownerState,
|
|
114
|
+
className: classes.separator
|
|
115
|
+
});
|
|
116
|
+
const {
|
|
117
|
+
textFieldProps: startDateProps
|
|
118
|
+
} = cleanFieldResponse(startDate);
|
|
119
|
+
const {
|
|
120
|
+
textFieldProps: endDateProps
|
|
121
|
+
} = cleanFieldResponse(endDate);
|
|
122
|
+
const TextField = slots?.textField ?? (enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
|
|
123
|
+
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
|
124
|
+
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
125
|
+
fullWidth: true
|
|
126
|
+
}, startDateProps)), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
127
|
+
fullWidth: true
|
|
128
|
+
}, endDateProps))]
|
|
129
|
+
}));
|
|
130
|
+
});
|
|
131
|
+
MultiInputRangeField.fieldType = 'multi-input';
|
|
132
|
+
return MultiInputRangeField;
|
|
133
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { TypographyProps } from '@mui/material/Typography';
|
|
2
|
+
import type { StackProps } from '@mui/material/Stack';
|
|
3
|
+
import type { TextFieldProps } from '@mui/material/TextField';
|
|
4
|
+
import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
5
|
+
import { PickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
|
|
6
|
+
import { FieldOwnerState } from '@mui/x-date-pickers/models';
|
|
7
|
+
import { PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
8
|
+
import { FieldType, MultiInputFieldRefs, RangeFieldSeparatorProps, RangePosition } from '../../../models';
|
|
9
|
+
import { PickerAnyRangeManager } from '../../models/managers';
|
|
10
|
+
export type MultiInputRangeFieldProps<TManager extends PickerAnyRangeManager> = MultiInputFieldRefs & RangeFieldSeparatorProps & Omit<PickerManagerFieldInternalProps<TManager>, 'unstableFieldRef' | 'clearable' | 'onClear'> & Omit<StackProps, 'position' | keyof PickerManagerFieldInternalProps<TManager>> & {
|
|
11
|
+
/**
|
|
12
|
+
* If `true`, the field is focused during the first mount.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Override or extend the styles applied to the component.
|
|
19
|
+
*/
|
|
20
|
+
classes?: Partial<MultiInputRangeFieldClasses>;
|
|
21
|
+
/**
|
|
22
|
+
* Overridable component slots.
|
|
23
|
+
* @default {}
|
|
24
|
+
*/
|
|
25
|
+
slots?: MultiInputRangeFieldSlots;
|
|
26
|
+
/**
|
|
27
|
+
* The props used for each component slot.
|
|
28
|
+
* @default {}
|
|
29
|
+
*/
|
|
30
|
+
slotProps?: MultiInputRangeFieldSlotProps;
|
|
31
|
+
};
|
|
32
|
+
export interface MultiInputRangeFieldSlots {
|
|
33
|
+
/**
|
|
34
|
+
* Element rendered at the root.
|
|
35
|
+
* @default MultiInputRangeFieldRoot
|
|
36
|
+
*/
|
|
37
|
+
root?: React.ElementType;
|
|
38
|
+
/**
|
|
39
|
+
* Form control with an input to render a date.
|
|
40
|
+
* It is rendered twice: once for the start date and once for the end date.
|
|
41
|
+
* @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`.
|
|
42
|
+
*/
|
|
43
|
+
textField?: React.ElementType;
|
|
44
|
+
/**
|
|
45
|
+
* Element rendered between the two inputs.
|
|
46
|
+
* @default MultiInputRangeFieldSeparator
|
|
47
|
+
*/
|
|
48
|
+
separator?: React.ElementType;
|
|
49
|
+
}
|
|
50
|
+
export interface MultiInputRangeFieldSlotProps {
|
|
51
|
+
root?: SlotComponentPropsFromProps<StackProps, {}, FieldOwnerState>;
|
|
52
|
+
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState & {
|
|
53
|
+
position: RangePosition;
|
|
54
|
+
}>;
|
|
55
|
+
separator?: SlotComponentPropsFromProps<TypographyProps, {}, FieldOwnerState>;
|
|
56
|
+
}
|
|
57
|
+
export interface MultiInputRangeFieldClasses {
|
|
58
|
+
/** Styles applied to the root element. */
|
|
59
|
+
root: string;
|
|
60
|
+
/** Styles applied to the separator element. */
|
|
61
|
+
separator: string;
|
|
62
|
+
}
|
|
63
|
+
export interface CreateMultiInputRangeFieldParameters<TManager extends PickerAnyRangeManager> {
|
|
64
|
+
name: string;
|
|
65
|
+
getUtilityClass: (slot: string) => string;
|
|
66
|
+
useManager: (params: RangeFieldSeparatorProps & {
|
|
67
|
+
enableAccessibleFieldDOMStructure: PickerManagerEnableAccessibleFieldDOMStructure<TManager>;
|
|
68
|
+
}) => TManager;
|
|
69
|
+
}
|
|
70
|
+
export type CreateMultiInputRangeFieldReturnValue<TManager extends PickerAnyRangeManager> = ((props: MultiInputRangeFieldProps<TManager> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
71
|
+
fieldType?: FieldType;
|
|
72
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createMultiInputRangeField } from './createMultiInputRangeField';
|
|
2
|
+
export type { MultiInputRangeFieldProps, MultiInputRangeFieldSlots, MultiInputRangeFieldSlotProps, MultiInputRangeFieldClasses, } from './createMultiInputRangeField.types';
|
|
3
|
+
export { useMultiInputRangeField as unstable_useMultiInputRangeField } from '../../../hooks/useMultiInputRangeField/useMultiInputRangeField';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczNjk4MjAwMDAwMA==";
|
|
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
|
package/managers/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useDateRangeManager } from './useDateRangeManager';
|
|
2
|
-
export type { UseDateRangeManagerReturnValue, UseDateRangeManagerParameters, } from './useDateRangeManager';
|
|
2
|
+
export type { UseDateRangeManagerReturnValue, UseDateRangeManagerParameters, DateRangeManagerFieldInternalProps, } from './useDateRangeManager';
|
|
3
3
|
export { useTimeRangeManager } from './useTimeRangeManager';
|
|
4
|
-
export type { UseTimeRangeManagerReturnValue, UseTimeRangeManagerParameters, } from './useTimeRangeManager';
|
|
4
|
+
export type { UseTimeRangeManagerReturnValue, UseTimeRangeManagerParameters, TimeRangeManagerFieldInternalProps, } from './useTimeRangeManager';
|
|
5
5
|
export { useDateTimeRangeManager } from './useDateTimeRangeManager';
|
|
6
|
-
export type { UseDateTimeRangeManagerReturnValue, UseDateTimeRangeManagerParameters, } from './useDateTimeRangeManager';
|
|
6
|
+
export type { UseDateTimeRangeManagerReturnValue, UseDateTimeRangeManagerParameters, DateTimeRangeManagerFieldInternalProps, } from './useDateTimeRangeManager';
|
|
@@ -8,7 +8,7 @@ export interface UseDateRangeManagerParameters<TEnableAccessibleFieldDOMStructur
|
|
|
8
8
|
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
9
9
|
}
|
|
10
10
|
export type UseDateRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError, DateRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, DateRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
|
|
11
|
-
interface DateRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateRangeProps {
|
|
11
|
+
export interface DateRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateRangeProps {
|
|
12
12
|
}
|
|
13
13
|
interface DateRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, ValidateDateRangeProps, RangeFieldSeparatorProps {
|
|
14
14
|
}
|
|
@@ -26,6 +26,8 @@ export function useDateRangeManager(parameters = {}) {
|
|
|
26
26
|
defaultDates,
|
|
27
27
|
utils,
|
|
28
28
|
internalProps
|
|
29
|
-
}))
|
|
29
|
+
})),
|
|
30
|
+
// TODO v8: Add a real aria label before moving the opening logic to the field on range pickers.
|
|
31
|
+
internal_getOpenPickerButtonAriaLabel: () => ''
|
|
30
32
|
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
31
33
|
}
|