@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
|
@@ -5,10 +5,11 @@ 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
|
+
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const releaseInfo = getReleaseInfo();
|
|
14
15
|
export const useDesktopRangePicker = _ref => {
|
|
@@ -22,60 +23,46 @@ export const useDesktopRangePicker = _ref => {
|
|
|
22
23
|
slotProps,
|
|
23
24
|
className,
|
|
24
25
|
sx,
|
|
25
|
-
format,
|
|
26
|
-
formatDensity,
|
|
27
|
-
enableAccessibleFieldDOMStructure,
|
|
28
|
-
selectedSections,
|
|
29
|
-
onSelectedSectionsChange,
|
|
30
|
-
timezone,
|
|
31
26
|
label,
|
|
32
27
|
inputRef,
|
|
33
28
|
name,
|
|
34
29
|
readOnly,
|
|
35
|
-
disabled,
|
|
36
30
|
autoFocus,
|
|
37
31
|
disableOpenPicker,
|
|
38
32
|
localeText,
|
|
39
33
|
reduceAnimations
|
|
40
34
|
} = props;
|
|
41
35
|
const fieldContainerRef = React.useRef(null);
|
|
42
|
-
const anchorRef = React.useRef(null);
|
|
43
36
|
const popperRef = React.useRef(null);
|
|
44
37
|
const startFieldRef = React.useRef(null);
|
|
45
38
|
const endFieldRef = React.useRef(null);
|
|
46
39
|
const singleInputFieldRef = React.useRef(null);
|
|
47
40
|
const initialView = React.useRef(props.openTo ?? null);
|
|
48
41
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
49
|
-
const
|
|
50
|
-
rangePosition,
|
|
51
|
-
onRangePositionChange
|
|
52
|
-
} = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
42
|
+
const rangePositionResponse = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
53
43
|
let fieldRef;
|
|
54
44
|
if (fieldType === 'single-input') {
|
|
55
45
|
fieldRef = singleInputFieldRef;
|
|
56
|
-
} else if (rangePosition === 'start') {
|
|
46
|
+
} else if (rangePositionResponse.rangePosition === 'start') {
|
|
57
47
|
fieldRef = startFieldRef;
|
|
58
48
|
} else {
|
|
59
49
|
fieldRef = endFieldRef;
|
|
60
50
|
}
|
|
61
51
|
const {
|
|
62
|
-
layoutProps,
|
|
63
52
|
providerProps,
|
|
64
53
|
renderCurrentView,
|
|
65
54
|
shouldRestoreFocus,
|
|
66
|
-
fieldProps: pickerFieldProps,
|
|
67
55
|
ownerState
|
|
68
56
|
} = usePicker(_extends({}, pickerParams, {
|
|
69
57
|
props,
|
|
70
58
|
variant: 'desktop',
|
|
71
59
|
autoFocusView: false,
|
|
72
60
|
fieldRef,
|
|
73
|
-
localeText
|
|
74
|
-
additionalViewProps: {
|
|
75
|
-
rangePosition,
|
|
76
|
-
onRangePositionChange
|
|
77
|
-
}
|
|
61
|
+
localeText
|
|
78
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';
|
|
79
66
|
React.useEffect(() => {
|
|
80
67
|
if (providerProps.contextValue.view) {
|
|
81
68
|
initialView.current = providerProps.contextValue.view;
|
|
@@ -99,17 +86,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
99
86
|
additionalProps: _extends({
|
|
100
87
|
// Internal props
|
|
101
88
|
readOnly,
|
|
102
|
-
|
|
103
|
-
format,
|
|
104
|
-
formatDensity,
|
|
105
|
-
enableAccessibleFieldDOMStructure,
|
|
106
|
-
selectedSections,
|
|
107
|
-
onSelectedSectionsChange,
|
|
108
|
-
timezone,
|
|
109
|
-
autoFocus: autoFocus && !props.open
|
|
110
|
-
}, pickerFieldProps, {
|
|
111
|
-
// onChange and value
|
|
112
|
-
|
|
89
|
+
autoFocus: autoFocus && !props.open,
|
|
113
90
|
// Forwarded props
|
|
114
91
|
className,
|
|
115
92
|
sx,
|
|
@@ -121,58 +98,54 @@ export const useDesktopRangePicker = _ref => {
|
|
|
121
98
|
}),
|
|
122
99
|
ownerState
|
|
123
100
|
});
|
|
124
|
-
const
|
|
101
|
+
const enrichedFieldResponse = useEnrichedRangePickerField(_extends({
|
|
125
102
|
variant: 'desktop',
|
|
126
103
|
fieldType,
|
|
127
104
|
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
contextValue: providerProps.contextValue,
|
|
106
|
+
fieldPrivateContextValue: providerProps.fieldPrivateContextValue,
|
|
130
107
|
readOnly,
|
|
131
108
|
disableOpenPicker,
|
|
132
109
|
label,
|
|
133
110
|
localeText,
|
|
134
111
|
onBlur: handleBlur,
|
|
135
|
-
rangePosition,
|
|
136
|
-
onRangePositionChange,
|
|
137
112
|
pickerSlotProps: slotProps,
|
|
138
113
|
pickerSlots: slots,
|
|
139
114
|
fieldProps,
|
|
140
|
-
anchorRef,
|
|
115
|
+
anchorRef: providerProps.contextValue.triggerRef,
|
|
141
116
|
startFieldRef,
|
|
142
117
|
endFieldRef,
|
|
143
118
|
singleInputFieldRef,
|
|
144
119
|
currentView: providerProps.contextValue.view !== props.openTo ? providerProps.contextValue.view : undefined,
|
|
145
|
-
initialView: initialView.current ?? undefined
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
const slotPropsForLayout = _extends({}, slotProps, {
|
|
149
|
-
tabs: _extends({}, slotProps?.tabs, {
|
|
150
|
-
rangePosition,
|
|
151
|
-
onRangePositionChange
|
|
152
|
-
}),
|
|
153
|
-
toolbar: _extends({}, slotProps?.toolbar, {
|
|
154
|
-
rangePosition,
|
|
155
|
-
onRangePositionChange
|
|
156
|
-
})
|
|
157
|
-
});
|
|
120
|
+
initialView: initialView.current ?? undefined
|
|
121
|
+
}, rangePositionResponse));
|
|
158
122
|
const Layout = slots?.layout ?? PickersLayout;
|
|
159
|
-
const renderPicker = () => /*#__PURE__*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
containerRef: popperRef,
|
|
164
|
-
anchorEl: anchorRef.current,
|
|
165
|
-
onBlur: handleBlur,
|
|
123
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
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, {
|
|
166
127
|
slots: slots,
|
|
167
128
|
slotProps: slotProps,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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,
|
|
137
|
+
slots: slots,
|
|
138
|
+
slotProps: slotProps,
|
|
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
|
+
})
|
|
148
|
+
})
|
|
176
149
|
}));
|
|
177
150
|
return {
|
|
178
151
|
renderPicker
|
|
@@ -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
|
|
@@ -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
|
+
}
|
|
@@ -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
|
};
|