@mui/x-date-pickers-pro 7.0.0-beta.2 → 7.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +429 -30
- package/DateRangeCalendar/DateRangeCalendar.js +3 -1
- package/DateRangeCalendar/DateRangeCalendar.types.d.ts +3 -0
- package/DateRangePicker/DateRangePicker.d.ts +1 -1
- package/DateRangePicker/DateRangePicker.js +9 -9
- package/DateRangePicker/DateRangePicker.types.d.ts +3 -3
- package/DateRangePicker/DateRangePickerToolbar.d.ts +5 -2
- package/DateRangePicker/DateRangePickerToolbar.js +22 -2
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/DateTimeRangePicker/DateTimeRangePicker.js +11 -12
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +3 -3
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -1
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +3 -0
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +45 -9
- package/DateTimeRangePicker/shared.js +8 -3
- package/DesktopDateRangePicker/DesktopDateRangePicker.d.ts +1 -1
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -9
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +3 -3
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +1 -1
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +11 -12
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +3 -3
- package/MobileDateRangePicker/MobileDateRangePicker.d.ts +1 -1
- package/MobileDateRangePicker/MobileDateRangePicker.js +9 -9
- package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +3 -3
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +1 -1
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +11 -12
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +3 -3
- package/MultiInputDateRangeField/MultiInputDateRangeField.d.ts +1 -1
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -19
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +11 -14
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.d.ts +1 -1
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -19
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +12 -16
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.d.ts +1 -1
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +17 -19
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +12 -16
- package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +2 -2
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +12 -10
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -14
- package/SingleInputDateRangeField/index.d.ts +1 -1
- package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +2 -3
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -15
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +2 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +12 -10
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +12 -15
- package/SingleInputDateTimeRangeField/index.d.ts +1 -1
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +2 -3
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -20
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +2 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +11 -9
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +12 -15
- package/SingleInputTimeRangeField/index.d.ts +1 -1
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +2 -3
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -14
- package/StaticDateRangePicker/StaticDateRangePicker.js +0 -1
- package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +1 -1
- package/index.d.ts +0 -1
- package/index.js +2 -1
- package/internals/hooks/models/useRangePicker.d.ts +5 -5
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -7
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +5 -5
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +15 -15
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +37 -40
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -1
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +18 -9
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +5 -5
- package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +21 -0
- package/internals/hooks/useMultiInputFieldSelectedSections.js +43 -0
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -1
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +17 -12
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +2 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +23 -31
- package/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +4 -4
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +2 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +23 -25
- package/internals/hooks/useRangePosition.d.ts +2 -4
- package/internals/hooks/useRangePosition.js +3 -6
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -0
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
- package/internals/models/dateRange.d.ts +3 -15
- package/internals/models/dateTimeRange.d.ts +4 -6
- package/internals/models/index.d.ts +0 -1
- package/internals/models/index.js +0 -1
- package/internals/models/timeRange.d.ts +3 -6
- package/internals/utils/date-fields-utils.d.ts +1 -5
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.d.ts +1 -2
- package/internals/utils/valueManagers.js +11 -6
- package/models/fields.d.ts +69 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/modern/DateRangeCalendar/DateRangeCalendar.js +3 -1
- package/modern/DateRangePicker/DateRangePicker.js +9 -9
- package/modern/DateRangePicker/DateRangePickerToolbar.js +22 -2
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +11 -12
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -1
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +45 -9
- package/modern/DateTimeRangePicker/shared.js +7 -2
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -9
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +11 -12
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +9 -9
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +11 -12
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -19
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -19
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +17 -19
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +12 -10
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -14
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +12 -10
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -19
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +11 -9
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -13
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +0 -1
- package/modern/index.js +2 -1
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -7
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +34 -37
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +18 -9
- package/modern/internals/hooks/useMultiInputFieldSelectedSections.js +40 -0
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +17 -12
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +23 -30
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +23 -24
- package/modern/internals/hooks/useRangePosition.js +3 -6
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -0
- package/modern/internals/models/index.js +0 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/internals/utils/valueManagers.js +11 -6
- package/modern/models/index.js +1 -0
- package/node/DateRangeCalendar/DateRangeCalendar.js +3 -1
- package/node/DateRangePicker/DateRangePicker.js +9 -9
- package/node/DateRangePicker/DateRangePickerToolbar.js +22 -2
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +11 -12
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -1
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +45 -9
- package/node/DateTimeRangePicker/shared.js +7 -2
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -9
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +11 -12
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +9 -9
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +13 -14
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -19
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -19
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +17 -19
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +12 -10
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -16
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +15 -13
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -21
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +11 -9
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -15
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +0 -1
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -7
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +33 -36
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +18 -9
- package/node/internals/hooks/useMultiInputFieldSelectedSections.js +50 -0
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +16 -11
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +23 -31
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +23 -25
- package/node/internals/hooks/useRangePosition.js +3 -8
- package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -0
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/internals/utils/valueManagers.js +10 -5
- package/node/models/index.js +11 -0
- package/package.json +5 -5
- package/themeAugmentation/props.d.ts +15 -14
- package/internals/models/fields.d.ts +0 -49
- package/legacy/AdapterDateFns/index.js +0 -1
- package/legacy/AdapterDateFnsJalali/index.js +0 -1
- package/legacy/AdapterDateFnsV3/index.js +0 -1
- package/legacy/AdapterDayjs/index.js +0 -1
- package/legacy/AdapterLuxon/index.js +0 -1
- package/legacy/AdapterMoment/index.js +0 -1
- package/legacy/AdapterMomentHijri/index.js +0 -1
- package/legacy/AdapterMomentJalaali/index.js +0 -1
- package/legacy/DateRangeCalendar/DateRangeCalendar.js +0 -764
- package/legacy/DateRangeCalendar/DateRangeCalendar.types.js +0 -1
- package/legacy/DateRangeCalendar/dateRangeCalendarClasses.js +0 -5
- package/legacy/DateRangeCalendar/index.js +0 -2
- package/legacy/DateRangeCalendar/useDragRange.js +0 -258
- package/legacy/DateRangePicker/DateRangePicker.js +0 -334
- package/legacy/DateRangePicker/DateRangePicker.types.js +0 -1
- package/legacy/DateRangePicker/DateRangePickerToolbar.js +0 -127
- package/legacy/DateRangePicker/dateRangePickerToolbarClasses.js +0 -5
- package/legacy/DateRangePicker/index.js +0 -3
- package/legacy/DateRangePicker/shared.js +0 -33
- package/legacy/DateRangePickerDay/DateRangePickerDay.js +0 -366
- package/legacy/DateRangePickerDay/dateRangePickerDayClasses.js +0 -5
- package/legacy/DateRangePickerDay/index.js +0 -2
- package/legacy/DateTimeRangePicker/DateTimeRangePicker.js +0 -413
- package/legacy/DateTimeRangePicker/DateTimeRangePicker.types.js +0 -1
- package/legacy/DateTimeRangePicker/DateTimeRangePickerTabs.js +0 -191
- package/legacy/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +0 -57
- package/legacy/DateTimeRangePicker/DateTimeRangePickerToolbar.js +0 -184
- package/legacy/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +0 -6
- package/legacy/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +0 -5
- package/legacy/DateTimeRangePicker/index.js +0 -5
- package/legacy/DateTimeRangePicker/shared.js +0 -54
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -343
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.types.js +0 -1
- package/legacy/DesktopDateRangePicker/index.js +0 -1
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +0 -491
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +0 -1
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -48
- package/legacy/DesktopDateTimeRangePicker/index.js +0 -1
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +0 -339
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.types.js +0 -1
- package/legacy/MobileDateRangePicker/index.js +0 -1
- package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +0 -484
- package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +0 -1
- package/legacy/MobileDateTimeRangePicker/index.js +0 -1
- package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +0 -316
- package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.types.js +0 -1
- package/legacy/MultiInputDateRangeField/index.js +0 -2
- package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +0 -357
- package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js +0 -1
- package/legacy/MultiInputDateTimeRangeField/index.js +0 -2
- package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +0 -330
- package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.types.js +0 -1
- package/legacy/MultiInputTimeRangeField/index.js +0 -2
- package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +0 -307
- package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.types.js +0 -1
- package/legacy/SingleInputDateRangeField/index.js +0 -2
- package/legacy/SingleInputDateRangeField/useSingleInputDateRangeField.js +0 -30
- package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +0 -348
- package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.js +0 -1
- package/legacy/SingleInputDateTimeRangeField/index.js +0 -2
- package/legacy/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +0 -35
- package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +0 -321
- package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.types.js +0 -1
- package/legacy/SingleInputTimeRangeField/index.js +0 -2
- package/legacy/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +0 -29
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +0 -276
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.types.js +0 -1
- package/legacy/StaticDateRangePicker/index.js +0 -1
- package/legacy/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -87
- package/legacy/dateRangeViewRenderers/index.js +0 -1
- package/legacy/index.js +0 -52
- package/legacy/internals/constants/dimensions.js +0 -5
- package/legacy/internals/hooks/models/index.js +0 -1
- package/legacy/internals/hooks/models/useRangePicker.js +0 -1
- package/legacy/internals/hooks/useDesktopRangePicker/index.js +0 -1
- package/legacy/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +0 -154
- package/legacy/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.js +0 -1
- package/legacy/internals/hooks/useEnrichedRangePickerFieldProps.js +0 -258
- package/legacy/internals/hooks/useMobileRangePicker/index.js +0 -1
- package/legacy/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +0 -144
- package/legacy/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.js +0 -1
- package/legacy/internals/hooks/useMultiInputRangeField/shared.js +0 -9
- package/legacy/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -102
- package/legacy/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -115
- package/legacy/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -1
- package/legacy/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -109
- package/legacy/internals/hooks/useRangePosition.js +0 -39
- package/legacy/internals/hooks/useStaticRangePicker/index.js +0 -1
- package/legacy/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +0 -76
- package/legacy/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.js +0 -1
- package/legacy/internals/models/dateRange.js +0 -1
- package/legacy/internals/models/dateTimeRange.js +0 -1
- package/legacy/internals/models/index.js +0 -5
- package/legacy/internals/models/rangePickerProps.js +0 -1
- package/legacy/internals/models/timeRange.js +0 -1
- package/legacy/internals/utils/date-fields-utils.js +0 -26
- package/legacy/internals/utils/date-range-manager.js +0 -65
- package/legacy/internals/utils/date-utils.js +0 -12
- package/legacy/internals/utils/releaseInfo.js +0 -13
- package/legacy/internals/utils/validation/validateDateRange.js +0 -45
- package/legacy/internals/utils/validation/validateDateTimeRange.js +0 -45
- package/legacy/internals/utils/validation/validateTimeRange.js +0 -32
- package/legacy/internals/utils/valueManagers.js +0 -135
- package/legacy/locales/index.js +0 -1
- package/legacy/models/index.js +0 -3
- package/legacy/models/multiInputRangeFieldClasses.js +0 -1
- package/legacy/models/range.js +0 -1
- package/legacy/models/validation.js +0 -1
- package/legacy/themeAugmentation/index.js +0 -4
- package/modern/internals/models/fields.js +0 -1
- /package/{internals/models → models}/fields.js +0 -0
- /package/{legacy/internals → modern}/models/fields.js +0 -0
- /package/node/{internals/models → models}/fields.js +0 -0
|
@@ -27,6 +27,9 @@ export const useDesktopRangePicker = _ref => {
|
|
|
27
27
|
sx,
|
|
28
28
|
format,
|
|
29
29
|
formatDensity,
|
|
30
|
+
enableAccessibleFieldDOMStructure,
|
|
31
|
+
selectedSections,
|
|
32
|
+
onSelectedSectionsChange,
|
|
30
33
|
timezone,
|
|
31
34
|
label,
|
|
32
35
|
inputRef,
|
|
@@ -41,12 +44,14 @@ export const useDesktopRangePicker = _ref => {
|
|
|
41
44
|
const fieldContainerRef = React.useRef(null);
|
|
42
45
|
const anchorRef = React.useRef(null);
|
|
43
46
|
const popperRef = React.useRef(null);
|
|
47
|
+
const startFieldRef = React.useRef(null);
|
|
48
|
+
const endFieldRef = React.useRef(null);
|
|
44
49
|
const initialView = React.useRef((_props$openTo = props.openTo) != null ? _props$openTo : null);
|
|
50
|
+
const fieldType = (_fieldType = slots.field.fieldType) != null ? _fieldType : 'multi-input';
|
|
45
51
|
const {
|
|
46
52
|
rangePosition,
|
|
47
|
-
onRangePositionChange
|
|
48
|
-
|
|
49
|
-
} = useRangePosition(props);
|
|
53
|
+
onRangePositionChange
|
|
54
|
+
} = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
|
|
50
55
|
const {
|
|
51
56
|
open,
|
|
52
57
|
actions,
|
|
@@ -58,6 +63,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
58
63
|
props,
|
|
59
64
|
wrapperVariant: 'desktop',
|
|
60
65
|
autoFocusView: false,
|
|
66
|
+
fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
|
|
61
67
|
additionalViewProps: {
|
|
62
68
|
rangePosition,
|
|
63
69
|
onRangePositionChange
|
|
@@ -79,7 +85,6 @@ export const useDesktopRangePicker = _ref => {
|
|
|
79
85
|
});
|
|
80
86
|
};
|
|
81
87
|
const Field = slots.field;
|
|
82
|
-
const fieldType = (_fieldType = Field.fieldType) != null ? _fieldType : 'multi-input';
|
|
83
88
|
const fieldProps = useSlotProps({
|
|
84
89
|
elementType: Field,
|
|
85
90
|
externalSlotProps: slotProps == null ? void 0 : slotProps.field,
|
|
@@ -90,13 +95,16 @@ export const useDesktopRangePicker = _ref => {
|
|
|
90
95
|
sx,
|
|
91
96
|
format,
|
|
92
97
|
formatDensity,
|
|
98
|
+
enableAccessibleFieldDOMStructure,
|
|
99
|
+
selectedSections,
|
|
100
|
+
onSelectedSectionsChange,
|
|
93
101
|
timezone,
|
|
94
102
|
autoFocus: autoFocus && !props.open,
|
|
95
103
|
ref: fieldContainerRef
|
|
96
|
-
},
|
|
104
|
+
}, inputRef ? {
|
|
97
105
|
inputRef,
|
|
98
106
|
name
|
|
99
|
-
}),
|
|
107
|
+
} : {}),
|
|
100
108
|
ownerState: props
|
|
101
109
|
});
|
|
102
110
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
@@ -111,11 +119,12 @@ export const useDesktopRangePicker = _ref => {
|
|
|
111
119
|
onBlur: handleBlur,
|
|
112
120
|
rangePosition,
|
|
113
121
|
onRangePositionChange,
|
|
114
|
-
singleInputFieldRef,
|
|
115
122
|
pickerSlotProps: slotProps,
|
|
116
123
|
pickerSlots: slots,
|
|
117
124
|
fieldProps,
|
|
118
125
|
anchorRef,
|
|
126
|
+
startFieldRef,
|
|
127
|
+
endFieldRef,
|
|
119
128
|
currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
|
|
120
129
|
initialView: (_initialView$current = initialView.current) != null ? _initialView$current : undefined,
|
|
121
130
|
onViewChange: layoutProps.onViewChange
|
|
@@ -3,15 +3,15 @@ import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
|
3
3
|
import { RangeOnlyPickerProps, RangePickerAdditionalViewProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
|
|
4
4
|
export interface UseDesktopRangePickerSlots<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem> extends UseRangePickerSlots<TDate, TView>, PickersPopperSlots {
|
|
5
5
|
}
|
|
6
|
-
export interface UseDesktopRangePickerSlotProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem> extends UseRangePickerSlotProps<TDate, TView>, PickersPopperSlotProps {
|
|
6
|
+
export interface UseDesktopRangePickerSlotProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TDate, TView, TEnableAccessibleFieldDOMStructure>, PickersPopperSlotProps {
|
|
7
7
|
}
|
|
8
|
-
export interface DesktopRangeOnlyPickerProps
|
|
8
|
+
export interface DesktopRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
9
9
|
/**
|
|
10
10
|
* If `true`, the start `input` element is focused during the first mount.
|
|
11
11
|
*/
|
|
12
12
|
autoFocus?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export interface UseDesktopRangePickerProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, any, TView, any, any>> extends UseRangePickerProps<TDate, TView, TError, TExternalProps, DesktopRangePickerAdditionalViewProps> {
|
|
14
|
+
export interface UseDesktopRangePickerProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, any, TView, any, any>> extends UseRangePickerProps<TDate, TView, TError, TExternalProps, DesktopRangePickerAdditionalViewProps> {
|
|
15
15
|
/**
|
|
16
16
|
* Overridable component slots.
|
|
17
17
|
* @default {}
|
|
@@ -21,9 +21,9 @@ export interface UseDesktopRangePickerProps<TDate extends PickerValidDate, TView
|
|
|
21
21
|
* The props used for each component slot.
|
|
22
22
|
* @default {}
|
|
23
23
|
*/
|
|
24
|
-
slotProps?: UseDesktopRangePickerSlotProps<TDate, TView>;
|
|
24
|
+
slotProps?: UseDesktopRangePickerSlotProps<TDate, TView, TEnableAccessibleFieldDOMStructure>;
|
|
25
25
|
}
|
|
26
26
|
export interface DesktopRangePickerAdditionalViewProps extends RangePickerAdditionalViewProps {
|
|
27
27
|
}
|
|
28
|
-
export interface UseDesktopRangePickerParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseDesktopRangePickerProps<TDate, TView, any, TExternalProps>> extends UseRangePickerParams<TDate, TView, TExternalProps, DesktopRangePickerAdditionalViewProps> {
|
|
28
|
+
export interface UseDesktopRangePickerParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TDate, TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TDate, TView, TExternalProps, DesktopRangePickerAdditionalViewProps> {
|
|
29
29
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Stack, { StackProps } from '@mui/material/Stack';
|
|
3
3
|
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
4
|
-
import TextField
|
|
4
|
+
import TextField from '@mui/material/TextField';
|
|
5
5
|
import { SlotComponentProps } from '@mui/base/utils';
|
|
6
|
-
import { BaseSingleInputFieldProps, PickerValidDate } from '@mui/x-date-pickers/models';
|
|
6
|
+
import { BaseSingleInputFieldProps, FieldRef, PickerValidDate } from '@mui/x-date-pickers/models';
|
|
7
7
|
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
|
|
8
8
|
import { PickersInputLocaleText } from '@mui/x-date-pickers/locales';
|
|
9
|
-
import { BaseFieldProps, UsePickerResponse, WrapperVariant, UsePickerProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
10
|
-
import {
|
|
11
|
-
import { DateRange, RangePosition } from '../../models';
|
|
9
|
+
import { BaseFieldProps, UsePickerResponse, WrapperVariant, UsePickerProps, SlotComponentPropsFromProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
10
|
+
import { UseDateRangeFieldProps } from '../models';
|
|
11
|
+
import { BaseMultiInputFieldProps, RangeFieldSection, DateRange, RangePosition, FieldType } from '../../models';
|
|
12
12
|
import { UseRangePositionResponse } from './useRangePosition';
|
|
13
13
|
export interface RangePickerFieldSlots extends UseClearableFieldSlots {
|
|
14
14
|
field: React.ElementType;
|
|
@@ -25,35 +25,35 @@ export interface RangePickerFieldSlots extends UseClearableFieldSlots {
|
|
|
25
25
|
/**
|
|
26
26
|
* Form control with an input to render a date or time inside the default field.
|
|
27
27
|
* It is rendered twice: once for the start element and once for the end element.
|
|
28
|
-
*
|
|
29
|
-
* @default TextField from '@mui/material'
|
|
28
|
+
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
|
|
30
29
|
*/
|
|
31
|
-
textField?: React.ElementType
|
|
30
|
+
textField?: React.ElementType;
|
|
32
31
|
}
|
|
33
|
-
export interface RangePickerFieldSlotProps<TDate extends PickerValidDate> extends UseClearableFieldSlotProps {
|
|
34
|
-
field?:
|
|
32
|
+
export interface RangePickerFieldSlotProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean> extends UseClearableFieldSlotProps {
|
|
33
|
+
field?: SlotComponentPropsFromProps<BaseMultiInputFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, unknown>, {}, UsePickerProps<DateRange<TDate>, TDate, any, any, any, any>>;
|
|
35
34
|
fieldRoot?: SlotComponentProps<typeof Stack, {}, Record<string, any>>;
|
|
36
35
|
fieldSeparator?: SlotComponentProps<typeof Typography, {}, Record<string, any>>;
|
|
37
|
-
textField?: SlotComponentProps<typeof TextField, {}, UseDateRangeFieldProps<TDate> & {
|
|
36
|
+
textField?: SlotComponentProps<typeof TextField, {}, UseDateRangeFieldProps<TDate, TEnableAccessibleFieldDOMStructure> & {
|
|
38
37
|
position?: RangePosition;
|
|
39
38
|
}>;
|
|
40
39
|
}
|
|
41
|
-
export interface UseEnrichedRangePickerFieldPropsParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError, FieldProps extends BaseFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TError> = BaseFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TError>> extends Pick<UsePickerResponse<DateRange<TDate>, TView, RangeFieldSection, any>, 'open' | 'actions'>, UseRangePositionResponse {
|
|
40
|
+
export interface UseEnrichedRangePickerFieldPropsParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, FieldProps extends BaseFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError> = BaseFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError>> extends Pick<UsePickerResponse<DateRange<TDate>, TView, RangeFieldSection, any>, 'open' | 'actions'>, UseRangePositionResponse {
|
|
42
41
|
wrapperVariant: WrapperVariant;
|
|
43
42
|
fieldType: FieldType;
|
|
44
43
|
readOnly?: boolean;
|
|
45
44
|
labelId?: string;
|
|
46
45
|
disableOpenPicker?: boolean;
|
|
47
46
|
onBlur?: () => void;
|
|
48
|
-
inputRef?: React.Ref<HTMLInputElement>;
|
|
49
47
|
label?: React.ReactNode;
|
|
50
48
|
localeText: PickersInputLocaleText<TDate> | undefined;
|
|
51
|
-
pickerSlotProps: RangePickerFieldSlotProps<TDate> | undefined;
|
|
49
|
+
pickerSlotProps: RangePickerFieldSlotProps<TDate, TEnableAccessibleFieldDOMStructure> | undefined;
|
|
52
50
|
pickerSlots: RangePickerFieldSlots | undefined;
|
|
53
51
|
fieldProps: FieldProps;
|
|
54
52
|
anchorRef?: React.Ref<HTMLDivElement>;
|
|
55
53
|
currentView?: TView | null;
|
|
56
54
|
initialView?: TView;
|
|
57
55
|
onViewChange?: (view: TView) => void;
|
|
56
|
+
startFieldRef: React.RefObject<FieldRef<RangeFieldSection>>;
|
|
57
|
+
endFieldRef: React.RefObject<FieldRef<RangeFieldSection>>;
|
|
58
58
|
}
|
|
59
|
-
export declare const useEnrichedRangePickerFieldProps: <TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError>(params: UseEnrichedRangePickerFieldPropsParams<TDate, TView, TError, BaseFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TError>>) => BaseMultiInputFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TError> | BaseSingleInputFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TError>;
|
|
59
|
+
export declare const useEnrichedRangePickerFieldProps: <TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError>(params: UseEnrichedRangePickerFieldPropsParams<TDate, TView, TEnableAccessibleFieldDOMStructure, TError, BaseFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError>>) => BaseMultiInputFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError> | BaseSingleInputFieldProps<DateRange<TDate>, TDate, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError>;
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import { resolveComponentProps } from '@mui/base/utils';
|
|
6
6
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
7
7
|
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
-
import { onSpaceOrEnter, useLocaleText
|
|
8
|
+
import { onSpaceOrEnter, useLocaleText } from '@mui/x-date-pickers/internals';
|
|
9
9
|
const useMultiInputFieldSlotProps = ({
|
|
10
10
|
wrapperVariant,
|
|
11
11
|
open,
|
|
@@ -23,35 +23,33 @@ const useMultiInputFieldSlotProps = ({
|
|
|
23
23
|
anchorRef,
|
|
24
24
|
currentView,
|
|
25
25
|
initialView,
|
|
26
|
-
onViewChange
|
|
26
|
+
onViewChange,
|
|
27
|
+
startFieldRef,
|
|
28
|
+
endFieldRef
|
|
27
29
|
}) => {
|
|
28
30
|
const localeText = useLocaleText();
|
|
29
|
-
const startRef = React.useRef(null);
|
|
30
|
-
const endRef = React.useRef(null);
|
|
31
|
-
const startFieldRef = React.useRef(null);
|
|
32
|
-
const endFieldRef = React.useRef(null);
|
|
33
31
|
const handleStartFieldRef = useForkRef(fieldProps.unstableStartFieldRef, startFieldRef);
|
|
34
|
-
const handleEndFieldRef = useForkRef(fieldProps.
|
|
32
|
+
const handleEndFieldRef = useForkRef(fieldProps.unstableEndFieldRef, endFieldRef);
|
|
35
33
|
const previousRangePosition = React.useRef(rangePosition);
|
|
36
34
|
React.useEffect(() => {
|
|
37
|
-
var
|
|
35
|
+
var _currentFieldRef$curr;
|
|
38
36
|
if (!open) {
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
|
-
const currentRef = rangePosition === 'start' ? startRef : endRef;
|
|
42
|
-
(_currentRef$current = currentRef.current) == null || _currentRef$current.focus();
|
|
43
39
|
const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
|
|
40
|
+
(_currentFieldRef$curr = currentFieldRef.current) == null || _currentFieldRef$curr.focusField();
|
|
44
41
|
if (!currentFieldRef.current || !currentView) {
|
|
45
42
|
// could happen when the user is switching between the inputs
|
|
46
43
|
previousRangePosition.current = rangePosition;
|
|
47
44
|
return;
|
|
48
45
|
}
|
|
46
|
+
|
|
49
47
|
// bring back focus to the field
|
|
50
48
|
currentFieldRef.current.setSelectedSections(
|
|
51
49
|
// use the current view or `0` when the range position has just been swapped
|
|
52
50
|
previousRangePosition.current === rangePosition ? currentView : 0);
|
|
53
51
|
previousRangePosition.current = rangePosition;
|
|
54
|
-
}, [rangePosition, open, currentView]);
|
|
52
|
+
}, [rangePosition, open, currentView, startFieldRef, endFieldRef]);
|
|
55
53
|
const openRangeStartSelection = event => {
|
|
56
54
|
event.stopPropagation();
|
|
57
55
|
onRangePositionChange('start');
|
|
@@ -90,12 +88,11 @@ const useMultiInputFieldSlotProps = ({
|
|
|
90
88
|
const slotProps = _extends({}, fieldProps.slotProps, {
|
|
91
89
|
textField: ownerState => {
|
|
92
90
|
const resolvedComponentProps = resolveComponentProps(pickerSlotProps == null ? void 0 : pickerSlotProps.textField, ownerState);
|
|
93
|
-
let
|
|
91
|
+
let textFieldProps;
|
|
94
92
|
let InputProps;
|
|
95
93
|
if (ownerState.position === 'start') {
|
|
96
94
|
var _inLocaleText$start;
|
|
97
|
-
|
|
98
|
-
inputRef: startRef,
|
|
95
|
+
textFieldProps = _extends({
|
|
99
96
|
label: (_inLocaleText$start = inLocaleText == null ? void 0 : inLocaleText.start) != null ? _inLocaleText$start : localeText.start,
|
|
100
97
|
onKeyDown: onSpaceOrEnter(openRangeStartSelection),
|
|
101
98
|
onFocus: handleFocusStart,
|
|
@@ -112,8 +109,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
112
109
|
}
|
|
113
110
|
} else {
|
|
114
111
|
var _inLocaleText$end;
|
|
115
|
-
|
|
116
|
-
inputRef: endRef,
|
|
112
|
+
textFieldProps = _extends({
|
|
117
113
|
label: (_inLocaleText$end = inLocaleText == null ? void 0 : inLocaleText.end) != null ? _inLocaleText$end : localeText.end,
|
|
118
114
|
onKeyDown: onSpaceOrEnter(openRangeEndSelection),
|
|
119
115
|
onFocus: handleFocusEnd,
|
|
@@ -127,7 +123,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
127
123
|
}
|
|
128
124
|
return _extends({}, labelId != null && {
|
|
129
125
|
id: `${labelId}-${ownerState.position}`
|
|
130
|
-
},
|
|
126
|
+
}, textFieldProps, resolveComponentProps(pickerSlotProps == null ? void 0 : pickerSlotProps.textField, ownerState), {
|
|
131
127
|
InputProps
|
|
132
128
|
});
|
|
133
129
|
},
|
|
@@ -141,12 +137,13 @@ const useMultiInputFieldSlotProps = ({
|
|
|
141
137
|
});
|
|
142
138
|
|
|
143
139
|
/* TODO: remove this when a clearable behavior for multiple input range fields is implemented */
|
|
144
|
-
const
|
|
140
|
+
const _ref = fieldProps,
|
|
141
|
+
restFieldProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
145
142
|
const enrichedFieldProps = _extends({}, restFieldProps, {
|
|
146
|
-
slots,
|
|
147
|
-
slotProps,
|
|
148
143
|
unstableStartFieldRef: handleStartFieldRef,
|
|
149
|
-
unstableEndFieldRef: handleEndFieldRef
|
|
144
|
+
unstableEndFieldRef: handleEndFieldRef,
|
|
145
|
+
slots,
|
|
146
|
+
slotProps
|
|
150
147
|
});
|
|
151
148
|
return enrichedFieldProps;
|
|
152
149
|
};
|
|
@@ -155,52 +152,53 @@ const useSingleInputFieldSlotProps = ({
|
|
|
155
152
|
open,
|
|
156
153
|
actions,
|
|
157
154
|
readOnly,
|
|
158
|
-
inputRef: inInputRef,
|
|
159
155
|
labelId,
|
|
160
156
|
disableOpenPicker,
|
|
161
157
|
label,
|
|
162
158
|
onBlur,
|
|
163
159
|
rangePosition,
|
|
164
160
|
onRangePositionChange,
|
|
165
|
-
|
|
161
|
+
startFieldRef,
|
|
162
|
+
endFieldRef,
|
|
166
163
|
pickerSlots,
|
|
167
164
|
pickerSlotProps,
|
|
168
165
|
fieldProps,
|
|
169
166
|
anchorRef,
|
|
170
167
|
currentView
|
|
171
168
|
}) => {
|
|
172
|
-
const
|
|
173
|
-
const handleInputRef = useForkRef(inInputRef, inputRef);
|
|
174
|
-
const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
|
|
169
|
+
const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, startFieldRef, endFieldRef);
|
|
175
170
|
React.useEffect(() => {
|
|
176
|
-
|
|
177
|
-
if (!open) {
|
|
171
|
+
if (!open || !startFieldRef.current) {
|
|
178
172
|
return;
|
|
179
173
|
}
|
|
180
|
-
(
|
|
181
|
-
if (!singleInputFieldRef.current || !currentView) {
|
|
174
|
+
if (startFieldRef.current.isFieldFocused()) {
|
|
182
175
|
return;
|
|
183
176
|
}
|
|
184
|
-
|
|
177
|
+
|
|
185
178
|
// bring back focus to the field with the current view section selected
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
if (currentView) {
|
|
180
|
+
var _startFieldRef$curren;
|
|
181
|
+
const sections = startFieldRef.current.getSections().map(section => section.type);
|
|
182
|
+
const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
|
|
183
|
+
(_startFieldRef$curren = startFieldRef.current) == null || _startFieldRef$curren.focusField(newSelectedSection);
|
|
184
|
+
}
|
|
185
|
+
}, [rangePosition, open, currentView, startFieldRef]);
|
|
188
186
|
const updateRangePosition = () => {
|
|
189
|
-
var
|
|
190
|
-
if (!
|
|
187
|
+
var _startFieldRef$curren2, _startFieldRef$curren3;
|
|
188
|
+
if (!((_startFieldRef$curren2 = startFieldRef.current) != null && _startFieldRef$curren2.isFieldFocused())) {
|
|
191
189
|
return;
|
|
192
190
|
}
|
|
193
|
-
const sections =
|
|
194
|
-
const activeSectionIndex = (
|
|
191
|
+
const sections = startFieldRef.current.getSections();
|
|
192
|
+
const activeSectionIndex = (_startFieldRef$curren3 = startFieldRef.current) == null ? void 0 : _startFieldRef$curren3.getActiveSectionIndex();
|
|
195
193
|
const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
|
|
196
194
|
if (domRangePosition != null && domRangePosition !== rangePosition) {
|
|
197
195
|
onRangePositionChange(domRangePosition);
|
|
198
196
|
}
|
|
199
197
|
};
|
|
200
|
-
const handleSelectedSectionsChange = useEventCallback(
|
|
198
|
+
const handleSelectedSectionsChange = useEventCallback(selectedSection => {
|
|
201
199
|
var _fieldProps$onSelecte;
|
|
202
200
|
setTimeout(updateRangePosition);
|
|
203
|
-
(_fieldProps$onSelecte = fieldProps.onSelectedSectionsChange) == null || _fieldProps$onSelecte.call(fieldProps,
|
|
201
|
+
(_fieldProps$onSelecte = fieldProps.onSelectedSectionsChange) == null || _fieldProps$onSelecte.call(fieldProps, selectedSection);
|
|
204
202
|
});
|
|
205
203
|
const openPicker = event => {
|
|
206
204
|
event.stopPropagation();
|
|
@@ -223,7 +221,6 @@ const useSingleInputFieldSlotProps = ({
|
|
|
223
221
|
slotProps,
|
|
224
222
|
label,
|
|
225
223
|
unstableFieldRef: handleFieldRef,
|
|
226
|
-
inputRef: handleInputRef,
|
|
227
224
|
onKeyDown: onSpaceOrEnter(openPicker, fieldProps.onKeyDown),
|
|
228
225
|
onSelectedSectionsChange: handleSelectedSectionsChange,
|
|
229
226
|
onBlur,
|
|
@@ -2,6 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
4
4
|
import { UseMobileRangePickerParams, UseMobileRangePickerProps } from './useMobileRangePicker.types';
|
|
5
|
-
export declare const useMobileRangePicker: <TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobileRangePickerProps<TDate, TView, any, TExternalProps>>({ props, ...pickerParams }: UseMobileRangePickerParams<TDate, TView, TExternalProps>) => {
|
|
5
|
+
export declare const useMobileRangePicker: <TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TDate, TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({ props, ...pickerParams }: UseMobileRangePickerParams<TDate, TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
|
6
6
|
renderPicker: () => React.JSX.Element;
|
|
7
7
|
};
|
|
@@ -28,6 +28,9 @@ export const useMobileRangePicker = _ref => {
|
|
|
28
28
|
sx,
|
|
29
29
|
format,
|
|
30
30
|
formatDensity,
|
|
31
|
+
enableAccessibleFieldDOMStructure,
|
|
32
|
+
selectedSections,
|
|
33
|
+
onSelectedSectionsChange,
|
|
31
34
|
timezone,
|
|
32
35
|
label,
|
|
33
36
|
inputRef,
|
|
@@ -37,11 +40,13 @@ export const useMobileRangePicker = _ref => {
|
|
|
37
40
|
disableOpenPicker,
|
|
38
41
|
localeText
|
|
39
42
|
} = props;
|
|
43
|
+
const startFieldRef = React.useRef(null);
|
|
44
|
+
const endFieldRef = React.useRef(null);
|
|
45
|
+
const fieldType = (_fieldType = slots.field.fieldType) != null ? _fieldType : 'multi-input';
|
|
40
46
|
const {
|
|
41
47
|
rangePosition,
|
|
42
|
-
onRangePositionChange
|
|
43
|
-
|
|
44
|
-
} = useRangePosition(props);
|
|
48
|
+
onRangePositionChange
|
|
49
|
+
} = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
|
|
45
50
|
const labelId = useId();
|
|
46
51
|
const contextLocaleText = useLocaleText();
|
|
47
52
|
const {
|
|
@@ -54,13 +59,13 @@ export const useMobileRangePicker = _ref => {
|
|
|
54
59
|
props,
|
|
55
60
|
wrapperVariant: 'mobile',
|
|
56
61
|
autoFocusView: true,
|
|
62
|
+
fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
|
|
57
63
|
additionalViewProps: {
|
|
58
64
|
rangePosition,
|
|
59
65
|
onRangePositionChange
|
|
60
66
|
}
|
|
61
67
|
}));
|
|
62
68
|
const Field = slots.field;
|
|
63
|
-
const fieldType = (_fieldType = Field.fieldType) != null ? _fieldType : 'multi-input';
|
|
64
69
|
const fieldProps = useSlotProps({
|
|
65
70
|
elementType: Field,
|
|
66
71
|
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
|
|
@@ -71,11 +76,14 @@ export const useMobileRangePicker = _ref => {
|
|
|
71
76
|
sx,
|
|
72
77
|
format,
|
|
73
78
|
formatDensity,
|
|
79
|
+
enableAccessibleFieldDOMStructure,
|
|
80
|
+
selectedSections,
|
|
81
|
+
onSelectedSectionsChange,
|
|
74
82
|
timezone
|
|
75
|
-
},
|
|
83
|
+
}, inputRef ? {
|
|
76
84
|
inputRef,
|
|
77
85
|
name
|
|
78
|
-
}),
|
|
86
|
+
} : {}),
|
|
79
87
|
ownerState: props
|
|
80
88
|
});
|
|
81
89
|
const isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null || (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
@@ -91,10 +99,11 @@ export const useMobileRangePicker = _ref => {
|
|
|
91
99
|
localeText,
|
|
92
100
|
rangePosition,
|
|
93
101
|
onRangePositionChange,
|
|
94
|
-
singleInputFieldRef,
|
|
95
102
|
pickerSlots: slots,
|
|
96
103
|
pickerSlotProps: innerSlotProps,
|
|
97
|
-
fieldProps
|
|
104
|
+
fieldProps,
|
|
105
|
+
startFieldRef,
|
|
106
|
+
endFieldRef
|
|
98
107
|
});
|
|
99
108
|
const slotPropsForLayout = _extends({}, innerSlotProps, {
|
|
100
109
|
tabs: _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.tabs, {
|
|
@@ -109,7 +118,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
109
118
|
});
|
|
110
119
|
const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickersLayout;
|
|
111
120
|
const finalLocaleText = _extends({}, contextLocaleText, localeText);
|
|
112
|
-
let labelledById = labelId;
|
|
121
|
+
let labelledById = pickerParams.valueType === 'date-time' ? `${labelId}-start-toolbar ${labelId}-end-toolbar` : labelId;
|
|
113
122
|
if (isToolbarHidden) {
|
|
114
123
|
const labels = [];
|
|
115
124
|
if (fieldType === 'multi-input') {
|
|
@@ -3,11 +3,11 @@ import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
|
3
3
|
import { RangeOnlyPickerProps, RangePickerAdditionalViewProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
|
|
4
4
|
export interface UseMobileRangePickerSlots<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem> extends UseRangePickerSlots<TDate, TView>, PickersModalDialogSlots {
|
|
5
5
|
}
|
|
6
|
-
export interface UseMobileRangePickerSlotProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem> extends UseRangePickerSlotProps<TDate, TView>, PickersModalDialogSlotProps {
|
|
6
|
+
export interface UseMobileRangePickerSlotProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TDate, TView, TEnableAccessibleFieldDOMStructure>, PickersModalDialogSlotProps {
|
|
7
7
|
}
|
|
8
|
-
export interface MobileRangeOnlyPickerProps
|
|
8
|
+
export interface MobileRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
9
9
|
}
|
|
10
|
-
export interface UseMobileRangePickerProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, any, TView, any, any>> extends UseRangePickerProps<TDate, TView, TError, TExternalProps, MobileRangePickerAdditionalViewProps> {
|
|
10
|
+
export interface UseMobileRangePickerProps<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, any, TView, any, any>> extends UseRangePickerProps<TDate, TView, TError, TExternalProps, MobileRangePickerAdditionalViewProps> {
|
|
11
11
|
/**
|
|
12
12
|
* Overridable component slots.
|
|
13
13
|
* @default {}
|
|
@@ -17,9 +17,9 @@ export interface UseMobileRangePickerProps<TDate extends PickerValidDate, TView
|
|
|
17
17
|
* The props used for each component slot.
|
|
18
18
|
* @default {}
|
|
19
19
|
*/
|
|
20
|
-
slotProps?: UseMobileRangePickerSlotProps<TDate, TView>;
|
|
20
|
+
slotProps?: UseMobileRangePickerSlotProps<TDate, TView, TEnableAccessibleFieldDOMStructure>;
|
|
21
21
|
}
|
|
22
22
|
export interface MobileRangePickerAdditionalViewProps extends RangePickerAdditionalViewProps {
|
|
23
23
|
}
|
|
24
|
-
export interface UseMobileRangePickerParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobileRangePickerProps<TDate, TView, any, TExternalProps>> extends UseRangePickerParams<TDate, TView, TExternalProps, MobileRangePickerAdditionalViewProps> {
|
|
24
|
+
export interface UseMobileRangePickerParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TDate, TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TDate, TView, TExternalProps, MobileRangePickerAdditionalViewProps> {
|
|
25
25
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { FieldRef, FieldSelectedSections } from '@mui/x-date-pickers/models';
|
|
4
|
+
import { RangeFieldSection } from '../../models';
|
|
5
|
+
interface UseMultiInputFieldSelectedSectionsParams extends Pick<UseFieldInternalProps<any, any, RangeFieldSection, any, any>, 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
6
|
+
unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
7
|
+
unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
8
|
+
}
|
|
9
|
+
export declare const useMultiInputFieldSelectedSections: (params: UseMultiInputFieldSelectedSectionsParams) => {
|
|
10
|
+
start: {
|
|
11
|
+
unstableFieldRef: React.Ref<FieldRef<RangeFieldSection>> | undefined;
|
|
12
|
+
selectedSections: FieldSelectedSections;
|
|
13
|
+
onSelectedSectionsChange: (newSelectedSections: FieldSelectedSections) => void;
|
|
14
|
+
};
|
|
15
|
+
end: {
|
|
16
|
+
unstableFieldRef: ((instance: FieldRef<RangeFieldSection> | null) => void) | null;
|
|
17
|
+
selectedSections: FieldSelectedSections;
|
|
18
|
+
onSelectedSectionsChange: (newSelectedSections: FieldSelectedSections) => void;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
|
+
export const useMultiInputFieldSelectedSections = params => {
|
|
5
|
+
var _params$selectedSecti;
|
|
6
|
+
const unstableEndFieldRef = React.useRef(null);
|
|
7
|
+
const handleUnstableEndFieldRef = useForkRef(params.unstableEndFieldRef, unstableEndFieldRef);
|
|
8
|
+
const [startSelectedSection, setStartSelectedSection] = React.useState((_params$selectedSecti = params.selectedSections) != null ? _params$selectedSecti : null);
|
|
9
|
+
const [endSelectedSection, setEndSelectedSection] = React.useState(null);
|
|
10
|
+
const getActiveField = () => {
|
|
11
|
+
if (unstableEndFieldRef.current && unstableEndFieldRef.current.isFieldFocused()) {
|
|
12
|
+
return 'end';
|
|
13
|
+
}
|
|
14
|
+
return 'start';
|
|
15
|
+
};
|
|
16
|
+
const handleStartSelectedSectionChange = useEventCallback(newSelectedSections => {
|
|
17
|
+
setStartSelectedSection(newSelectedSections);
|
|
18
|
+
if (getActiveField() === 'start') {
|
|
19
|
+
var _params$onSelectedSec;
|
|
20
|
+
(_params$onSelectedSec = params.onSelectedSectionsChange) == null || _params$onSelectedSec.call(params, newSelectedSections);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const handleEndSelectedSectionChange = useEventCallback(newSelectedSections => {
|
|
24
|
+
setEndSelectedSection(newSelectedSections);
|
|
25
|
+
if (getActiveField() === 'end') {
|
|
26
|
+
var _params$onSelectedSec2;
|
|
27
|
+
(_params$onSelectedSec2 = params.onSelectedSectionsChange) == null || _params$onSelectedSec2.call(params, newSelectedSections);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const activeField = getActiveField();
|
|
31
|
+
return {
|
|
32
|
+
start: {
|
|
33
|
+
unstableFieldRef: params.unstableStartFieldRef,
|
|
34
|
+
selectedSections: activeField === 'start' && params.selectedSections !== undefined ? params.selectedSections : startSelectedSection,
|
|
35
|
+
onSelectedSectionsChange: handleStartSelectedSectionChange
|
|
36
|
+
},
|
|
37
|
+
end: {
|
|
38
|
+
unstableFieldRef: handleUnstableEndFieldRef,
|
|
39
|
+
selectedSections: activeField === 'end' && params.selectedSections !== undefined ? params.selectedSections : endSelectedSection,
|
|
40
|
+
onSelectedSectionsChange: handleEndSelectedSectionChange
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
2
2
|
import { UseMultiInputDateRangeFieldParams } from '../../../MultiInputDateRangeField/MultiInputDateRangeField.types';
|
|
3
3
|
import type { UseMultiInputRangeFieldResponse } from './useMultiInputRangeField.types';
|
|
4
|
-
export declare const useMultiInputDateRangeField: <TDate extends PickerValidDate, TTextFieldSlotProps extends {}>({ sharedProps: inSharedProps, startTextFieldProps, unstableStartFieldRef, endTextFieldProps, unstableEndFieldRef, }: UseMultiInputDateRangeFieldParams<TDate, TTextFieldSlotProps>) => UseMultiInputRangeFieldResponse<TTextFieldSlotProps>;
|
|
4
|
+
export declare const useMultiInputDateRangeField: <TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean, TTextFieldSlotProps extends {}>({ sharedProps: inSharedProps, startTextFieldProps, unstableStartFieldRef, endTextFieldProps, unstableEndFieldRef, }: UseMultiInputDateRangeFieldParams<TDate, TEnableAccessibleFieldDOMStructure, TTextFieldSlotProps>) => UseMultiInputRangeFieldResponse<TEnableAccessibleFieldDOMStructure, TTextFieldSlotProps>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
3
3
|
import { unstable_useDateField as useDateField } from '@mui/x-date-pickers/DateField';
|
|
4
|
-
import { useLocalizationContext, useValidation, useControlledValueWithTimezone } from '@mui/x-date-pickers/internals';
|
|
5
|
-
import { useDefaultizedDateRangeFieldProps } from '../../../SingleInputDateRangeField/useSingleInputDateRangeField';
|
|
4
|
+
import { useLocalizationContext, useValidation, useControlledValueWithTimezone, useDefaultizedDateField } from '@mui/x-date-pickers/internals';
|
|
6
5
|
import { validateDateRange } from '../../utils/validation/validateDateRange';
|
|
7
6
|
import { rangeValueManager } from '../../utils/valueManagers';
|
|
8
7
|
import { excludeProps } from './shared';
|
|
8
|
+
import { useMultiInputFieldSelectedSections } from '../useMultiInputFieldSelectedSections';
|
|
9
9
|
export const useMultiInputDateRangeField = ({
|
|
10
10
|
sharedProps: inSharedProps,
|
|
11
11
|
startTextFieldProps,
|
|
@@ -13,7 +13,7 @@ export const useMultiInputDateRangeField = ({
|
|
|
13
13
|
endTextFieldProps,
|
|
14
14
|
unstableEndFieldRef
|
|
15
15
|
}) => {
|
|
16
|
-
const sharedProps =
|
|
16
|
+
const sharedProps = useDefaultizedDateField(inSharedProps);
|
|
17
17
|
const adapter = useLocalizationContext();
|
|
18
18
|
const {
|
|
19
19
|
value: valueProp,
|
|
@@ -26,7 +26,9 @@ export const useMultiInputDateRangeField = ({
|
|
|
26
26
|
readOnly,
|
|
27
27
|
selectedSections,
|
|
28
28
|
onSelectedSectionsChange,
|
|
29
|
-
timezone: timezoneProp
|
|
29
|
+
timezone: timezoneProp,
|
|
30
|
+
enableAccessibleFieldDOMStructure,
|
|
31
|
+
autoFocus
|
|
30
32
|
} = sharedProps;
|
|
31
33
|
const {
|
|
32
34
|
value,
|
|
@@ -63,37 +65,40 @@ export const useMultiInputDateRangeField = ({
|
|
|
63
65
|
value,
|
|
64
66
|
timezone
|
|
65
67
|
}), validateDateRange, rangeValueManager.isSameError, rangeValueManager.defaultErrorState);
|
|
68
|
+
const selectedSectionsResponse = useMultiInputFieldSelectedSections({
|
|
69
|
+
selectedSections,
|
|
70
|
+
onSelectedSectionsChange,
|
|
71
|
+
unstableStartFieldRef,
|
|
72
|
+
unstableEndFieldRef
|
|
73
|
+
});
|
|
66
74
|
const startFieldProps = _extends({
|
|
67
75
|
error: !!validationError[0]
|
|
68
|
-
}, startTextFieldProps, {
|
|
76
|
+
}, startTextFieldProps, selectedSectionsResponse.start, {
|
|
69
77
|
disabled,
|
|
70
78
|
readOnly,
|
|
71
79
|
format,
|
|
72
80
|
formatDensity,
|
|
73
81
|
shouldRespectLeadingZeros,
|
|
74
82
|
timezone,
|
|
75
|
-
unstableFieldRef: unstableStartFieldRef,
|
|
76
83
|
value: valueProp === undefined ? undefined : valueProp[0],
|
|
77
84
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
|
|
78
85
|
onChange: handleStartDateChange,
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
enableAccessibleFieldDOMStructure,
|
|
87
|
+
autoFocus // Do not add on end field.
|
|
81
88
|
});
|
|
82
89
|
const endFieldProps = _extends({
|
|
83
90
|
error: !!validationError[1]
|
|
84
|
-
}, endTextFieldProps, {
|
|
91
|
+
}, endTextFieldProps, selectedSectionsResponse.end, {
|
|
85
92
|
format,
|
|
86
93
|
formatDensity,
|
|
87
94
|
shouldRespectLeadingZeros,
|
|
88
95
|
disabled,
|
|
89
96
|
readOnly,
|
|
90
97
|
timezone,
|
|
91
|
-
unstableFieldRef: unstableEndFieldRef,
|
|
92
98
|
value: valueProp === undefined ? undefined : valueProp[1],
|
|
93
99
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
|
|
94
100
|
onChange: handleEndDateChange,
|
|
95
|
-
|
|
96
|
-
onSelectedSectionsChange
|
|
101
|
+
enableAccessibleFieldDOMStructure
|
|
97
102
|
});
|
|
98
103
|
const startDateResponse = useDateField(startFieldProps);
|
|
99
104
|
const endDateResponse = useDateField(endFieldProps);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UseMultiInputDateTimeRangeFieldParams } from '../../../MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types';
|
|
3
3
|
import type { UseMultiInputRangeFieldResponse } from './useMultiInputRangeField.types';
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const useMultiInputDateTimeRangeField: <TDate extends PickerValidDate, TTextFieldSlotProps extends {}>({ sharedProps: inSharedProps, startTextFieldProps, unstableStartFieldRef, endTextFieldProps, unstableEndFieldRef, }: UseMultiInputDateTimeRangeFieldParams<TDate, TTextFieldSlotProps>) => UseMultiInputRangeFieldResponse<TTextFieldSlotProps>;
|
|
4
|
+
export declare const useMultiInputDateTimeRangeField: <TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean, TTextFieldSlotProps extends {}>({ sharedProps: inSharedProps, startTextFieldProps, unstableStartFieldRef, endTextFieldProps, unstableEndFieldRef, }: UseMultiInputDateTimeRangeFieldParams<TDate, TEnableAccessibleFieldDOMStructure, TTextFieldSlotProps>) => UseMultiInputRangeFieldResponse<TEnableAccessibleFieldDOMStructure, TTextFieldSlotProps>;
|