@mui/x-date-pickers-pro 8.0.0-alpha.6 → 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/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.d.ts +1 -1
- package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.d.ts +1 -1
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
- package/CHANGELOG.md +242 -1
- package/DateRangeCalendar/DateRangeCalendar.js +12 -10
- package/DateRangePicker/DateRangePicker.js +1 -1
- package/DateRangePicker/DateRangePicker.types.d.ts +5 -0
- package/DateRangePicker/DateRangePickerToolbar.d.ts +2 -3
- package/DateRangePicker/DateRangePickerToolbar.js +27 -19
- package/DateRangePicker/shared.d.ts +1 -1
- package/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +3 -4
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +10 -9
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +8 -10
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +8 -6
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -3
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +29 -31
- package/DateTimeRangePicker/shared.d.ts +2 -2
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +5 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
- package/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
- 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 +14 -14
- 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 +14 -14
- 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 +14 -14
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -2
- package/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/package.json +6 -0
- 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/hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.d.ts +17 -0
- package/{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/hooks/usePickerRangePositionContext.d.ts +7 -0
- package/hooks/usePickerRangePositionContext.js +15 -0
- package/index.d.ts +2 -0
- package/index.js +4 -2
- package/internals/hooks/models/index.d.ts +1 -1
- package/internals/hooks/models/useRangePicker.d.ts +6 -8
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +40 -67
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +3 -5
- package/internals/hooks/{useEnrichedRangePickerFieldProps.d.ts → useEnrichedRangePickerField.d.ts} +18 -9
- package/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +39 -52
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +33 -56
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +3 -5
- package/internals/hooks/useNullablePickerRangePositionContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
- package/internals/hooks/useRangePosition.d.ts +2 -2
- package/internals/hooks/useRangePosition.js +1 -1
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +2 -2
- 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/date-range-manager.js +2 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.js +7 -7
- package/managers/index.d.ts +6 -0
- package/managers/index.js +3 -0
- package/managers/package.json +6 -0
- package/managers/useDateRangeManager.d.ts +15 -0
- package/managers/useDateRangeManager.js +33 -0
- package/managers/useDateTimeRangeManager.d.ts +15 -0
- package/managers/useDateTimeRangeManager.js +33 -0
- package/managers/useTimeRangeManager.d.ts +15 -0
- package/managers/useTimeRangeManager.js +31 -0
- package/models/fields.d.ts +1 -2
- package/models/index.d.ts +0 -2
- package/models/index.js +0 -2
- package/models/range.d.ts +0 -1
- package/modern/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/modern/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +12 -10
- package/modern/DateRangePicker/DateRangePicker.js +1 -1
- package/modern/DateRangePicker/DateRangePickerToolbar.js +27 -19
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +10 -9
- package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +8 -6
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +29 -31
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
- 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 +14 -14
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +20 -30
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +14 -14
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +20 -30
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +14 -14
- package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
- package/modern/hooks/index.js +2 -0
- package/modern/hooks/useMultiInputRangeField/index.js +1 -0
- package/modern/hooks/useMultiInputRangeField/useMultiInputRangeField.js +149 -0
- package/modern/{internals/hooks/useMultiInputFieldSelectedSections.js → hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.js} +10 -8
- package/modern/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.js +59 -0
- package/modern/hooks/usePickerRangePositionContext.js +15 -0
- package/modern/index.js +4 -2
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +40 -67
- package/modern/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +39 -52
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +33 -56
- package/modern/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
- package/modern/internals/hooks/useRangePosition.js +1 -1
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
- 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/date-range-manager.js +2 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/internals/utils/valueManagers.js +7 -7
- package/modern/managers/index.js +3 -0
- package/modern/managers/useDateRangeManager.js +33 -0
- package/modern/managers/useDateTimeRangeManager.js +33 -0
- package/modern/managers/useTimeRangeManager.js +31 -0
- package/modern/models/index.js +0 -2
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/DateRangeCalendar/DateRangeCalendar.js +12 -10
- package/node/DateRangePicker/DateRangePicker.js +1 -1
- package/node/DateRangePicker/DateRangePickerToolbar.js +26 -18
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +10 -9
- package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +8 -6
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +29 -31
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
- 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 +13 -14
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +19 -29
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +13 -14
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +19 -29
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +13 -14
- package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
- package/node/hooks/index.js +19 -0
- 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/hooks/usePickerRangePositionContext.js +22 -0
- package/node/index.js +23 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +39 -66
- package/node/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +41 -54
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +32 -55
- package/node/internals/hooks/useNullablePickerRangePositionContext.js +16 -0
- package/node/internals/hooks/useRangePosition.js +1 -1
- package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
- 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/date-range-manager.js +2 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/internals/utils/valueManagers.js +7 -7
- package/node/managers/index.js +26 -0
- package/node/managers/useDateRangeManager.js +40 -0
- package/node/managers/useDateTimeRangeManager.js +40 -0
- package/node/managers/useTimeRangeManager.js +38 -0
- package/node/models/index.js +0 -22
- package/package.json +5 -5
- 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/useMultiInputFieldSelectedSections.d.ts +0 -20
- 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 -113
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -113
- 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 -113
- 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 -113
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -113
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -1
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -113
- 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 -121
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -121
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -5
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -121
- 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
|
-
onViewChange,
|
|
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
|
-
|
|
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
|
-
|
|
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,12 +5,13 @@ 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
|
+
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
14
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
const releaseInfo = getReleaseInfo();
|
|
16
17
|
export const useMobileRangePicker = _ref => {
|
|
@@ -24,17 +25,10 @@ export const useMobileRangePicker = _ref => {
|
|
|
24
25
|
slotProps: innerSlotProps,
|
|
25
26
|
className,
|
|
26
27
|
sx,
|
|
27
|
-
format,
|
|
28
|
-
formatDensity,
|
|
29
|
-
enableAccessibleFieldDOMStructure,
|
|
30
|
-
selectedSections,
|
|
31
|
-
onSelectedSectionsChange,
|
|
32
|
-
timezone,
|
|
33
28
|
label,
|
|
34
29
|
inputRef,
|
|
35
30
|
name,
|
|
36
31
|
readOnly,
|
|
37
|
-
disabled,
|
|
38
32
|
disableOpenPicker,
|
|
39
33
|
localeText
|
|
40
34
|
} = props;
|
|
@@ -42,37 +36,31 @@ export const useMobileRangePicker = _ref => {
|
|
|
42
36
|
const endFieldRef = React.useRef(null);
|
|
43
37
|
const singleInputFieldRef = React.useRef(null);
|
|
44
38
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
45
|
-
const
|
|
46
|
-
rangePosition,
|
|
47
|
-
onRangePositionChange
|
|
48
|
-
} = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
39
|
+
const rangePositionResponse = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
49
40
|
const labelId = useId();
|
|
50
41
|
const contextTranslations = usePickerTranslations();
|
|
51
42
|
let fieldRef;
|
|
52
43
|
if (fieldType === 'single-input') {
|
|
53
44
|
fieldRef = singleInputFieldRef;
|
|
54
|
-
} else if (rangePosition === 'start') {
|
|
45
|
+
} else if (rangePositionResponse.rangePosition === 'start') {
|
|
55
46
|
fieldRef = startFieldRef;
|
|
56
47
|
} else {
|
|
57
48
|
fieldRef = endFieldRef;
|
|
58
49
|
}
|
|
59
50
|
const {
|
|
60
|
-
layoutProps,
|
|
61
51
|
providerProps,
|
|
62
52
|
renderCurrentView,
|
|
63
|
-
fieldProps: pickerFieldProps,
|
|
64
53
|
ownerState
|
|
65
54
|
} = usePicker(_extends({}, pickerParams, {
|
|
66
55
|
props,
|
|
67
56
|
variant: 'mobile',
|
|
68
57
|
autoFocusView: true,
|
|
69
58
|
fieldRef,
|
|
70
|
-
localeText
|
|
71
|
-
additionalViewProps: {
|
|
72
|
-
rangePosition,
|
|
73
|
-
onRangePositionChange
|
|
74
|
-
}
|
|
59
|
+
localeText
|
|
75
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';
|
|
76
64
|
const Field = slots.field;
|
|
77
65
|
const fieldProps = useSlotProps({
|
|
78
66
|
elementType: Field,
|
|
@@ -80,16 +68,6 @@ export const useMobileRangePicker = _ref => {
|
|
|
80
68
|
additionalProps: _extends({
|
|
81
69
|
// Internal props
|
|
82
70
|
readOnly: readOnly ?? true,
|
|
83
|
-
disabled,
|
|
84
|
-
format,
|
|
85
|
-
formatDensity,
|
|
86
|
-
enableAccessibleFieldDOMStructure,
|
|
87
|
-
selectedSections,
|
|
88
|
-
onSelectedSectionsChange,
|
|
89
|
-
timezone
|
|
90
|
-
}, pickerFieldProps, {
|
|
91
|
-
// onChange and value
|
|
92
|
-
|
|
93
71
|
// Forwarded props
|
|
94
72
|
className,
|
|
95
73
|
sx
|
|
@@ -101,37 +79,24 @@ export const useMobileRangePicker = _ref => {
|
|
|
101
79
|
ownerState
|
|
102
80
|
});
|
|
103
81
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
104
|
-
const
|
|
82
|
+
const enrichedFieldResponse = useEnrichedRangePickerField(_extends({
|
|
105
83
|
variant: 'mobile',
|
|
106
84
|
fieldType,
|
|
107
85
|
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
108
|
-
|
|
109
|
-
|
|
86
|
+
contextValue: providerProps.contextValue,
|
|
87
|
+
fieldPrivateContextValue: providerProps.fieldPrivateContextValue,
|
|
110
88
|
readOnly,
|
|
111
89
|
labelId,
|
|
112
90
|
disableOpenPicker,
|
|
113
91
|
label,
|
|
114
92
|
localeText,
|
|
115
|
-
rangePosition,
|
|
116
|
-
onRangePositionChange,
|
|
117
93
|
pickerSlots: slots,
|
|
118
94
|
pickerSlotProps: innerSlotProps,
|
|
119
95
|
fieldProps,
|
|
120
96
|
startFieldRef,
|
|
121
97
|
endFieldRef,
|
|
122
98
|
singleInputFieldRef
|
|
123
|
-
});
|
|
124
|
-
const slotPropsForLayout = _extends({}, innerSlotProps, {
|
|
125
|
-
tabs: _extends({}, innerSlotProps?.tabs, {
|
|
126
|
-
rangePosition,
|
|
127
|
-
onRangePositionChange
|
|
128
|
-
}),
|
|
129
|
-
toolbar: _extends({}, innerSlotProps?.toolbar, {
|
|
130
|
-
titleId: labelId,
|
|
131
|
-
rangePosition,
|
|
132
|
-
onRangePositionChange
|
|
133
|
-
})
|
|
134
|
-
});
|
|
99
|
+
}, rangePositionResponse));
|
|
135
100
|
const Layout = slots?.layout ?? PickersLayout;
|
|
136
101
|
const finalLocaleText = _extends({}, contextTranslations, localeText);
|
|
137
102
|
let labelledById = pickerParams.valueType === 'date-time' ? `${labelId}-start-toolbar ${labelId}-end-toolbar` : labelId;
|
|
@@ -150,20 +115,32 @@ export const useMobileRangePicker = _ref => {
|
|
|
150
115
|
labelledById = labels.length > 0 ? labels.join(' ') : undefined;
|
|
151
116
|
}
|
|
152
117
|
const slotProps = _extends({}, innerSlotProps, {
|
|
118
|
+
toolbar: _extends({}, innerSlotProps?.toolbar, {
|
|
119
|
+
titleId: labelId
|
|
120
|
+
}),
|
|
153
121
|
mobilePaper: _extends({
|
|
154
122
|
'aria-labelledby': labelledById
|
|
155
123
|
}, innerSlotProps?.mobilePaper)
|
|
156
124
|
});
|
|
157
|
-
const renderPicker = () => /*#__PURE__*/
|
|
158
|
-
|
|
125
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
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, {
|
|
159
129
|
slots: slots,
|
|
160
130
|
slotProps: slotProps,
|
|
161
|
-
children: /*#__PURE__*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
131
|
+
children: /*#__PURE__*/_jsxs(PickerRangePositionContext.Provider, {
|
|
132
|
+
value: rangePositionResponse,
|
|
133
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldResponse.fieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
134
|
+
slots: slots,
|
|
135
|
+
slotProps: slotProps,
|
|
136
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
137
|
+
slots: slots,
|
|
138
|
+
slotProps: slotProps,
|
|
139
|
+
children: renderCurrentView()
|
|
140
|
+
}))
|
|
141
|
+
})]
|
|
142
|
+
})
|
|
143
|
+
})
|
|
167
144
|
}));
|
|
168
145
|
return {
|
|
169
146
|
renderPicker
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PickersModalDialogSlots, PickersModalDialogSlotProps, UsePickerViewsProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { RangeOnlyPickerProps,
|
|
2
|
+
import { RangeOnlyPickerProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
|
|
3
3
|
export interface UseMobileRangePickerSlots extends UseRangePickerSlots, PickersModalDialogSlots {
|
|
4
4
|
}
|
|
5
5
|
export interface UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, PickersModalDialogSlotProps {
|
|
6
6
|
}
|
|
7
7
|
export interface MobileRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
8
8
|
}
|
|
9
|
-
export interface UseMobileRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any
|
|
9
|
+
export interface UseMobileRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any>> extends UseRangePickerProps<TView, TError, TExternalProps> {
|
|
10
10
|
/**
|
|
11
11
|
* Overridable component slots.
|
|
12
12
|
* @default {}
|
|
@@ -18,7 +18,5 @@ export interface UseMobileRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
18
18
|
*/
|
|
19
19
|
slotProps?: UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
22
|
-
}
|
|
23
|
-
export interface UseMobileRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TView, TExternalProps, MobileRangePickerAdditionalViewProps> {
|
|
21
|
+
export interface UseMobileRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TView, TExternalProps> {
|
|
24
22
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns information about the range position of the picker that wraps the current component.
|
|
3
|
+
* If no picker wraps the current component, returns `null`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useNullablePickerRangePositionContext(): import("./useRangePosition").UseRangePositionResponse | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerRangePositionContext } from "../../hooks/usePickerRangePositionContext.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns information about the range position of the picker that wraps the current component.
|
|
6
|
+
* If no picker wraps the current component, returns `null`.
|
|
7
|
+
*/
|
|
8
|
+
export function useNullablePickerRangePositionContext() {
|
|
9
|
+
return React.useContext(PickerRangePositionContext);
|
|
10
|
+
}
|
|
@@ -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
|
-
export declare const useRangePosition: (props: UseRangePositionProps, singleInputFieldRef?: React.RefObject<FieldRef<PickerRangeValue
|
|
27
|
+
export declare const useRangePosition: (props: UseRangePositionProps, singleInputFieldRef?: React.RefObject<FieldRef<PickerRangeValue> | null>) => UseRangePositionResponse;
|
|
@@ -7,6 +7,7 @@ import { styled } from '@mui/material/styles';
|
|
|
7
7
|
import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
|
|
8
8
|
import { usePicker, DIALOG_WIDTH, PickerProvider } from '@mui/x-date-pickers/internals';
|
|
9
9
|
import { useRangePosition } from "../useRangePosition.js";
|
|
10
|
+
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const PickerStaticLayout = styled(PickersLayout)(({
|
|
12
13
|
theme
|
|
@@ -35,12 +36,8 @@ export const useStaticRangePicker = _ref => {
|
|
|
35
36
|
displayStaticWrapperAs,
|
|
36
37
|
autoFocus
|
|
37
38
|
} = props;
|
|
39
|
+
const rangePositionResponse = useRangePosition(props);
|
|
38
40
|
const {
|
|
39
|
-
rangePosition,
|
|
40
|
-
onRangePositionChange
|
|
41
|
-
} = useRangePosition(props);
|
|
42
|
-
const {
|
|
43
|
-
layoutProps,
|
|
44
41
|
providerProps,
|
|
45
42
|
renderCurrentView
|
|
46
43
|
} = usePicker(_extends({}, pickerParams, {
|
|
@@ -48,29 +45,22 @@ export const useStaticRangePicker = _ref => {
|
|
|
48
45
|
autoFocusView: autoFocus ?? false,
|
|
49
46
|
fieldRef: undefined,
|
|
50
47
|
localeText,
|
|
51
|
-
additionalViewProps: {
|
|
52
|
-
rangePosition,
|
|
53
|
-
onRangePositionChange
|
|
54
|
-
},
|
|
55
48
|
variant: displayStaticWrapperAs
|
|
56
49
|
}));
|
|
57
50
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
className: clsx(className, slotProps?.layout?.className),
|
|
70
|
-
ref: ref,
|
|
71
|
-
children: renderCurrentView()
|
|
51
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerRangePositionContext.Provider, {
|
|
52
|
+
value: rangePositionResponse,
|
|
53
|
+
children: /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
54
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
55
|
+
slots: slots,
|
|
56
|
+
slotProps: slotProps,
|
|
57
|
+
sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps?.layout?.sx) ? slotProps.layout.sx : [slotProps?.layout?.sx])],
|
|
58
|
+
className: clsx(className, slotProps?.layout?.className),
|
|
59
|
+
ref: ref,
|
|
60
|
+
children: renderCurrentView()
|
|
61
|
+
}))
|
|
72
62
|
}))
|
|
73
|
-
})
|
|
63
|
+
});
|
|
74
64
|
return {
|
|
75
65
|
renderPicker
|
|
76
66
|
};
|
|
@@ -9,7 +9,7 @@ export interface UseStaticRangePickerSlotProps extends ExportedPickersLayoutSlot
|
|
|
9
9
|
}
|
|
10
10
|
export interface StaticRangeOnlyPickerProps extends StaticOnlyPickerProps, UseRangePositionProps {
|
|
11
11
|
}
|
|
12
|
-
export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends BasePickerProps<PickerRangeValue, TView, TError, TExternalProps
|
|
12
|
+
export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends BasePickerProps<PickerRangeValue, TView, TError, TExternalProps>, StaticRangeOnlyPickerProps {
|
|
13
13
|
/**
|
|
14
14
|
* Overridable components.
|
|
15
15
|
* @default {}
|
|
@@ -21,7 +21,7 @@ export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
21
21
|
*/
|
|
22
22
|
slotProps?: UseStaticRangePickerSlotProps;
|
|
23
23
|
}
|
|
24
|
-
export interface UseStaticRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps
|
|
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;
|
|
26
26
|
/**
|
|
27
27
|
* Ref to pass to the root element
|
|
@@ -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>;
|