@mui/x-date-pickers-pro 8.0.0-alpha.1 → 8.0.0-alpha.10
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 +1903 -231
- package/DateRangeCalendar/DateRangeCalendar.js +15 -13
- package/DateRangePicker/DateRangePicker.js +1 -4
- package/DateRangePicker/DateRangePicker.types.d.ts +6 -2
- package/DateRangePicker/DateRangePickerToolbar.d.ts +2 -3
- package/DateRangePicker/DateRangePickerToolbar.js +33 -41
- package/DateRangePicker/shared.d.ts +4 -3
- package/DateTimeRangePicker/DateTimeRangePicker.js +2 -5
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +1 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +4 -5
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +35 -33
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +8 -10
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +8 -6
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -5
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +81 -109
- package/DateTimeRangePicker/shared.d.ts +6 -5
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +11 -9
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +7 -2
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -22
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +2 -3
- package/MobileDateRangePicker/MobileDateRangePicker.js +4 -8
- package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +2 -2
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +18 -16
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +2 -3
- package/MultiInputDateRangeField/MultiInputDateRangeField.d.ts +9 -4
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +15 -121
- 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 +15 -121
- 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 +16 -122
- 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/README.md +8 -5
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +23 -33
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +6 -16
- package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +14 -14
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +23 -33
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +6 -17
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +14 -14
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +23 -33
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +6 -17
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +14 -14
- package/StaticDateRangePicker/StaticDateRangePicker.js +2 -2
- package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +2 -2
- 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/{modern/internals/hooks/useMultiInputFieldSelectedSections.js → hooks/useMultiInputRangeField/useMultiInputRangeFieldSelectedSections.js} +10 -8
- package/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.d.ts +17 -0
- package/hooks/useMultiInputRangeField/useMultiInputRangeFieldTextFieldProps.js +59 -0
- package/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 +8 -11
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +68 -100
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +8 -10
- package/internals/hooks/{useEnrichedRangePickerFieldProps.d.ts → useEnrichedRangePickerField.d.ts} +25 -16
- package/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +50 -63
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +57 -80
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +7 -9
- package/internals/hooks/useNullablePickerRangePositionContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
- package/internals/hooks/useRangePosition.d.ts +4 -3
- package/internals/hooks/useRangePosition.js +1 -1
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +17 -30
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +6 -12
- package/internals/models/dateTimeRange.d.ts +1 -6
- package/internals/models/fields.d.ts +7 -11
- 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 +136 -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-fields-utils.d.ts +6 -6
- package/internals/utils/date-range-manager.js +2 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.d.ts +4 -3
- 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 +7 -11
- package/models/index.d.ts +1 -2
- package/models/index.js +1 -2
- package/models/range.d.ts +0 -2
- package/modern/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/modern/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +15 -13
- package/modern/DateRangePicker/DateRangePicker.js +1 -4
- package/modern/DateRangePicker/DateRangePickerToolbar.js +33 -41
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +2 -5
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +35 -33
- package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +8 -6
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +81 -109
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +11 -9
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -22
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +4 -8
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +18 -16
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +15 -121
- package/modern/MultiInputDateRangeField/index.js +2 -2
- package/modern/MultiInputDateRangeField/multiInputDateRangeFieldClasses.js +4 -0
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +15 -121
- package/modern/MultiInputDateTimeRangeField/index.js +2 -2
- package/modern/MultiInputDateTimeRangeField/multiInputDateTimeRangeFieldClasses.js +4 -0
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +16 -122
- package/modern/MultiInputTimeRangeField/index.js +2 -2
- package/modern/MultiInputTimeRangeField/multiInputTimeRangeFieldClasses.js +4 -0
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +23 -33
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +14 -14
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +23 -33
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +14 -14
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +23 -33
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +14 -14
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +2 -2
- 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/{internals/hooks/useMultiInputFieldSelectedSections.js → modern/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 +68 -100
- package/modern/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +50 -63
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +57 -80
- package/modern/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
- package/modern/internals/hooks/useRangePosition.js +1 -1
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +17 -30
- package/modern/internals/models/index.js +0 -1
- package/modern/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +136 -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 +1 -2
- package/modern/validation/validateDateRange.js +8 -0
- package/modern/validation/validateDateTimeRange.js +4 -0
- package/modern/validation/validateTimeRange.js +8 -0
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/DateRangeCalendar/DateRangeCalendar.js +14 -12
- package/node/DateRangePicker/DateRangePicker.js +1 -4
- package/node/DateRangePicker/DateRangePickerToolbar.js +31 -39
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +2 -5
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +33 -31
- package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +8 -6
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +80 -108
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +11 -9
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -22
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +4 -8
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +18 -16
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +14 -124
- package/node/MultiInputDateRangeField/index.js +3 -9
- package/node/MultiInputDateRangeField/multiInputDateRangeFieldClasses.js +12 -0
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +14 -124
- package/node/MultiInputDateTimeRangeField/index.js +3 -9
- package/node/MultiInputDateTimeRangeField/multiInputDateTimeRangeFieldClasses.js +12 -0
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +15 -125
- package/node/MultiInputTimeRangeField/index.js +3 -9
- package/node/MultiInputTimeRangeField/multiInputTimeRangeFieldClasses.js +12 -0
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +22 -32
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +13 -14
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +22 -32
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +13 -14
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +22 -32
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +13 -14
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +2 -2
- 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 +68 -100
- package/node/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js} +52 -65
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +57 -80
- package/node/internals/hooks/useNullablePickerRangePositionContext.js +16 -0
- package/node/internals/hooks/useRangePosition.js +1 -1
- package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +16 -29
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/createMultiInputRangeField/createMultiInputRangeField.js +143 -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/node/validation/validateDateRange.js +8 -0
- package/node/validation/validateDateTimeRange.js +4 -0
- package/node/validation/validateTimeRange.js +8 -0
- package/package.json +6 -6
- package/themeAugmentation/overrides.d.ts +6 -4
- package/themeAugmentation/props.d.ts +2 -2
- package/validation/validateDateRange.d.ts +9 -1
- package/validation/validateDateRange.js +8 -0
- package/validation/validateDateTimeRange.d.ts +6 -2
- package/validation/validateDateTimeRange.js +4 -0
- package/validation/validateTimeRange.d.ts +9 -1
- package/validation/validateTimeRange.js +8 -0
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +0 -53
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +0 -54
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +0 -54
- package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +0 -21
- package/internals/hooks/useMultiInputRangeField/shared.d.ts +0 -1
- package/internals/hooks/useMultiInputRangeField/shared.js +0 -9
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -113
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -113
- package/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +0 -11
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +0 -3
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -113
- package/internals/models/timeRange.d.ts +0 -6
- package/internals/models/timeRange.js +0 -1
- package/models/dateRange.d.ts +0 -7
- package/models/dateRange.js +0 -1
- package/models/multiInputRangeFieldClasses.d.ts +0 -7
- package/models/multiInputRangeFieldClasses.js +0 -1
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.types.js +0 -1
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js +0 -1
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.types.js +0 -1
- package/modern/internals/hooks/useMultiInputRangeField/shared.js +0 -9
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -113
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -113
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -1
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -113
- package/modern/internals/models/timeRange.js +0 -1
- package/modern/models/dateRange.js +0 -1
- package/modern/models/multiInputRangeFieldClasses.js +0 -1
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.types.js +0 -5
- package/node/internals/hooks/useMultiInputRangeField/shared.js +0 -16
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +0 -121
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +0 -121
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js +0 -5
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +0 -121
- package/node/internals/models/timeRange.js +0 -5
- package/node/models/dateRange.js +0 -5
- package/node/models/multiInputRangeFieldClasses.js +0 -5
- /package/{MultiInputDateRangeField/MultiInputDateRangeField.types.js → internals/models/managers.js} +0 -0
- /package/{MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js → internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.js} +0 -0
- /package/{MultiInputTimeRangeField/MultiInputTimeRangeField.types.js → modern/internals/models/managers.js} +0 -0
- /package/{internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.js → modern/internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.js} +0 -0
- /package/node/{MultiInputDateRangeField/MultiInputDateRangeField.types.js → internals/models/managers.js} +0 -0
- /package/node/{MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.js → internals/utils/createMultiInputRangeField/createMultiInputRangeField.types.js} +0 -0
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers-pro v8.0.0-alpha.
|
|
2
|
+
* @mui/x-date-pickers-pro v8.0.0-alpha.10
|
|
3
3
|
*
|
|
4
4
|
* @license MUI X Commercial
|
|
5
5
|
* This source code is licensed under the commercial license found in the
|
|
@@ -32,4 +32,6 @@ export * from "./MobileDateTimeRangePicker/index.js";
|
|
|
32
32
|
// View renderers
|
|
33
33
|
export * from "./dateRangeViewRenderers/index.js";
|
|
34
34
|
export * from "./models/index.js";
|
|
35
|
-
export * from "./
|
|
35
|
+
export * from "./hooks/index.js";
|
|
36
|
+
export * from "./validation/index.js";
|
|
37
|
+
export * from "./managers/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { UseRangePickerSlots, UseRangePickerSlotProps, RangeOnlyPickerProps,
|
|
1
|
+
export type { UseRangePickerSlots, UseRangePickerSlotProps, RangeOnlyPickerProps, UseRangePickerProps, UseRangePickerParams, } from './useRangePicker';
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { UsePickerParams, BasePickerProps, ExportedBaseToolbarProps, UsePickerViewsProps,
|
|
1
|
+
import { UsePickerParams, BasePickerProps, ExportedBaseToolbarProps, UsePickerViewsProps, UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps, DateOrTimeViewWithMeridiem, ExportedBaseTabsProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps } from '@mui/x-date-pickers/PickersLayout';
|
|
3
3
|
import { BaseRangeNonStaticPickerProps } from '../../models';
|
|
4
|
-
import { UseRangePositionProps
|
|
5
|
-
import { RangePickerFieldSlots, RangePickerFieldSlotProps } from '../
|
|
6
|
-
|
|
7
|
-
export interface UseRangePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends ExportedPickersLayoutSlots<PickerRangeValue, TView>, RangePickerFieldSlots {
|
|
4
|
+
import { UseRangePositionProps } from '../useRangePosition';
|
|
5
|
+
import { RangePickerFieldSlots, RangePickerFieldSlotProps } from '../useEnrichedRangePickerField';
|
|
6
|
+
export interface UseRangePickerSlots extends ExportedPickersLayoutSlots<PickerRangeValue>, RangePickerFieldSlots {
|
|
8
7
|
}
|
|
9
|
-
export interface UseRangePickerSlotProps<
|
|
8
|
+
export interface UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedPickersLayoutSlotProps<PickerRangeValue>, RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure> {
|
|
10
9
|
tabs?: ExportedBaseTabsProps;
|
|
11
10
|
toolbar?: ExportedBaseToolbarProps;
|
|
12
11
|
}
|
|
13
|
-
export interface RangeOnlyPickerProps extends
|
|
12
|
+
export interface RangeOnlyPickerProps extends UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps, BaseRangeNonStaticPickerProps, UseRangePositionProps {
|
|
14
13
|
}
|
|
15
|
-
export interface UseRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, TView, any
|
|
14
|
+
export interface UseRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, TView, any>> extends RangeOnlyPickerProps, BasePickerProps<PickerRangeValue, TView, TError, TExternalProps> {
|
|
16
15
|
}
|
|
17
|
-
export interface
|
|
18
|
-
}
|
|
19
|
-
export interface UseRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseRangePickerProps<TView, any, TExternalProps, TAdditionalViewProps>, TAdditionalViewProps extends {}> extends Pick<UsePickerParams<PickerRangeValue, TView, RangeFieldSection, TExternalProps, TAdditionalViewProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
|
|
16
|
+
export interface UseRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
|
|
20
17
|
props: TExternalProps;
|
|
21
18
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["props"]
|
|
3
|
+
const _excluded = ["props"],
|
|
4
|
+
_excluded2 = ["ownerState"];
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
6
7
|
import { useLicenseVerifier } from '@mui/x-license';
|
|
7
8
|
import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
|
|
8
|
-
import { executeInTheNextEventLoopTick, getActiveElement, usePicker,
|
|
9
|
-
import {
|
|
9
|
+
import { executeInTheNextEventLoopTick, getActiveElement, usePicker, PickerPopper, PickerProvider, PickerFieldUIContextProvider } from '@mui/x-date-pickers/internals';
|
|
10
|
+
import { useEnrichedRangePickerField } from "../useEnrichedRangePickerField.js";
|
|
10
11
|
import { getReleaseInfo } from "../../utils/releaseInfo.js";
|
|
11
12
|
import { useRangePosition } from "../useRangePosition.js";
|
|
13
|
+
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
12
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
15
|
const releaseInfo = getReleaseInfo();
|
|
14
16
|
export const useDesktopRangePicker = _ref => {
|
|
@@ -20,58 +22,45 @@ export const useDesktopRangePicker = _ref => {
|
|
|
20
22
|
const {
|
|
21
23
|
slots,
|
|
22
24
|
slotProps,
|
|
23
|
-
className,
|
|
24
|
-
sx,
|
|
25
|
-
format,
|
|
26
|
-
formatDensity,
|
|
27
|
-
enableAccessibleFieldDOMStructure,
|
|
28
|
-
selectedSections,
|
|
29
|
-
onSelectedSectionsChange,
|
|
30
|
-
timezone,
|
|
31
|
-
label,
|
|
32
25
|
inputRef,
|
|
33
|
-
name,
|
|
34
26
|
readOnly,
|
|
35
|
-
disabled,
|
|
36
27
|
autoFocus,
|
|
37
28
|
disableOpenPicker,
|
|
38
|
-
localeText
|
|
39
|
-
reduceAnimations
|
|
29
|
+
localeText
|
|
40
30
|
} = props;
|
|
41
31
|
const fieldContainerRef = React.useRef(null);
|
|
42
|
-
const anchorRef = React.useRef(null);
|
|
43
32
|
const popperRef = React.useRef(null);
|
|
44
33
|
const startFieldRef = React.useRef(null);
|
|
45
34
|
const endFieldRef = React.useRef(null);
|
|
35
|
+
const singleInputFieldRef = React.useRef(null);
|
|
46
36
|
const initialView = React.useRef(props.openTo ?? null);
|
|
47
37
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
38
|
+
const rangePositionResponse = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
39
|
+
let fieldRef;
|
|
40
|
+
if (fieldType === 'single-input') {
|
|
41
|
+
fieldRef = singleInputFieldRef;
|
|
42
|
+
} else if (rangePositionResponse.rangePosition === 'start') {
|
|
43
|
+
fieldRef = startFieldRef;
|
|
44
|
+
} else {
|
|
45
|
+
fieldRef = endFieldRef;
|
|
46
|
+
}
|
|
48
47
|
const {
|
|
49
|
-
rangePosition,
|
|
50
|
-
onRangePositionChange
|
|
51
|
-
} = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
|
|
52
|
-
const {
|
|
53
|
-
open,
|
|
54
|
-
actions,
|
|
55
|
-
layoutProps,
|
|
56
48
|
providerProps,
|
|
57
49
|
renderCurrentView,
|
|
58
|
-
shouldRestoreFocus,
|
|
59
|
-
fieldProps: pickerFieldProps,
|
|
60
50
|
ownerState
|
|
61
51
|
} = usePicker(_extends({}, pickerParams, {
|
|
62
52
|
props,
|
|
63
53
|
variant: 'desktop',
|
|
64
54
|
autoFocusView: false,
|
|
65
|
-
fieldRef
|
|
66
|
-
localeText
|
|
67
|
-
additionalViewProps: {
|
|
68
|
-
rangePosition,
|
|
69
|
-
onRangePositionChange
|
|
70
|
-
}
|
|
55
|
+
fieldRef,
|
|
56
|
+
localeText
|
|
71
57
|
}));
|
|
58
|
+
|
|
59
|
+
// Temporary hack to hide the opening button on the range pickers until we have migrate them to the new opening logic.
|
|
60
|
+
providerProps.contextValue.triggerStatus = 'hidden';
|
|
72
61
|
React.useEffect(() => {
|
|
73
|
-
if (
|
|
74
|
-
initialView.current =
|
|
62
|
+
if (providerProps.contextValue.view) {
|
|
63
|
+
initialView.current = providerProps.contextValue.view;
|
|
75
64
|
}
|
|
76
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
66
|
}, []);
|
|
@@ -80,90 +69,69 @@ export const useDesktopRangePicker = _ref => {
|
|
|
80
69
|
if (fieldContainerRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
|
|
81
70
|
return;
|
|
82
71
|
}
|
|
83
|
-
|
|
72
|
+
|
|
73
|
+
// This direct access to `providerProps` will go away once the range fields stop having their views in a tooltip.
|
|
74
|
+
providerProps.privateContextValue.dismissViews();
|
|
84
75
|
});
|
|
85
76
|
};
|
|
86
77
|
const Field = slots.field;
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
onSelectedSectionsChange,
|
|
99
|
-
timezone,
|
|
100
|
-
autoFocus: autoFocus && !props.open
|
|
101
|
-
}, pickerFieldProps, {
|
|
102
|
-
// onChange and value
|
|
103
|
-
|
|
104
|
-
// Forwarded props
|
|
105
|
-
className,
|
|
106
|
-
sx,
|
|
107
|
-
ref: fieldContainerRef
|
|
108
|
-
}, fieldType === 'single-input' && !!inputRef && {
|
|
109
|
-
inputRef
|
|
110
|
-
}, fieldType === 'single-input' && {
|
|
111
|
-
name
|
|
78
|
+
const _useSlotProps = useSlotProps({
|
|
79
|
+
elementType: Field,
|
|
80
|
+
externalSlotProps: slotProps?.field,
|
|
81
|
+
additionalProps: {
|
|
82
|
+
// Internal props
|
|
83
|
+
readOnly,
|
|
84
|
+
autoFocus: autoFocus && !props.open,
|
|
85
|
+
// Forwarded props
|
|
86
|
+
ref: fieldContainerRef
|
|
87
|
+
},
|
|
88
|
+
ownerState
|
|
112
89
|
}),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
90
|
+
fieldProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
91
|
+
const enrichedFieldResponse = useEnrichedRangePickerField(_extends({
|
|
116
92
|
variant: 'desktop',
|
|
117
93
|
fieldType,
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
// These direct access to `providerProps` will go away once the range fields handle the picker opening
|
|
95
|
+
contextValue: providerProps.contextValue,
|
|
96
|
+
fieldPrivateContextValue: providerProps.fieldPrivateContextValue,
|
|
120
97
|
readOnly,
|
|
121
98
|
disableOpenPicker,
|
|
122
|
-
label,
|
|
123
99
|
localeText,
|
|
124
100
|
onBlur: handleBlur,
|
|
125
|
-
rangePosition,
|
|
126
|
-
onRangePositionChange,
|
|
127
101
|
pickerSlotProps: slotProps,
|
|
128
102
|
pickerSlots: slots,
|
|
129
103
|
fieldProps,
|
|
130
|
-
anchorRef,
|
|
104
|
+
anchorRef: providerProps.contextValue.triggerRef,
|
|
131
105
|
startFieldRef,
|
|
132
106
|
endFieldRef,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
const slotPropsForLayout = _extends({}, slotProps, {
|
|
138
|
-
tabs: _extends({}, slotProps?.tabs, {
|
|
139
|
-
rangePosition,
|
|
140
|
-
onRangePositionChange
|
|
141
|
-
}),
|
|
142
|
-
toolbar: _extends({}, slotProps?.toolbar, {
|
|
143
|
-
rangePosition,
|
|
144
|
-
onRangePositionChange
|
|
145
|
-
})
|
|
146
|
-
});
|
|
107
|
+
singleInputFieldRef,
|
|
108
|
+
currentView: providerProps.contextValue.view !== props.openTo ? providerProps.contextValue.view : undefined,
|
|
109
|
+
initialView: initialView.current ?? undefined
|
|
110
|
+
}, rangePositionResponse));
|
|
147
111
|
const Layout = slots?.layout ?? PickersLayout;
|
|
148
|
-
const renderPicker = () => /*#__PURE__*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
containerRef: popperRef,
|
|
153
|
-
anchorEl: anchorRef.current,
|
|
154
|
-
onBlur: handleBlur
|
|
155
|
-
}, actions, {
|
|
156
|
-
open: open,
|
|
112
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
113
|
+
// This override will go away once the range fields handle the picker opening
|
|
114
|
+
fieldPrivateContextValue: _extends({}, providerProps.fieldPrivateContextValue, enrichedFieldResponse.fieldPrivateContextValue),
|
|
115
|
+
children: /*#__PURE__*/_jsx(PickerFieldUIContextProvider, {
|
|
157
116
|
slots: slots,
|
|
158
117
|
slotProps: slotProps,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
118
|
+
inputRef: inputRef,
|
|
119
|
+
children: /*#__PURE__*/_jsxs(PickerRangePositionContext.Provider, {
|
|
120
|
+
value: rangePositionResponse,
|
|
121
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldResponse.fieldProps)), /*#__PURE__*/_jsx(PickerPopper, {
|
|
122
|
+
role: "tooltip",
|
|
123
|
+
containerRef: popperRef,
|
|
124
|
+
onBlur: handleBlur,
|
|
125
|
+
slots: slots,
|
|
126
|
+
slotProps: slotProps,
|
|
127
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
128
|
+
slots: slots,
|
|
129
|
+
slotProps: slotProps,
|
|
130
|
+
children: renderCurrentView()
|
|
131
|
+
}))
|
|
132
|
+
})]
|
|
133
|
+
})
|
|
134
|
+
})
|
|
167
135
|
}));
|
|
168
136
|
return {
|
|
169
137
|
renderPicker
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RangeOnlyPickerProps,
|
|
3
|
-
export interface UseDesktopRangePickerSlots
|
|
1
|
+
import { PickerPopperSlots, PickerPopperSlotProps, UsePickerViewsProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { RangeOnlyPickerProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
|
|
3
|
+
export interface UseDesktopRangePickerSlots extends UseRangePickerSlots, PickerPopperSlots {
|
|
4
4
|
}
|
|
5
|
-
export interface UseDesktopRangePickerSlotProps<
|
|
5
|
+
export interface UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, PickerPopperSlotProps {
|
|
6
6
|
}
|
|
7
7
|
export interface DesktopRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
8
8
|
/**
|
|
@@ -10,19 +10,17 @@ export interface DesktopRangeOnlyPickerProps extends RangeOnlyPickerProps {
|
|
|
10
10
|
*/
|
|
11
11
|
autoFocus?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export interface UseDesktopRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any
|
|
13
|
+
export interface UseDesktopRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any>> extends UseRangePickerProps<TView, TError, TExternalProps> {
|
|
14
14
|
/**
|
|
15
15
|
* Overridable component slots.
|
|
16
16
|
* @default {}
|
|
17
17
|
*/
|
|
18
|
-
slots: UseDesktopRangePickerSlots
|
|
18
|
+
slots: UseDesktopRangePickerSlots;
|
|
19
19
|
/**
|
|
20
20
|
* The props used for each component slot.
|
|
21
21
|
* @default {}
|
|
22
22
|
*/
|
|
23
|
-
slotProps?: UseDesktopRangePickerSlotProps<
|
|
23
|
+
slotProps?: UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
26
|
-
}
|
|
27
|
-
export interface UseDesktopRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TView, TExternalProps, DesktopRangePickerAdditionalViewProps> {
|
|
25
|
+
export interface UseDesktopRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TView, TExternalProps> {
|
|
28
26
|
}
|
package/internals/hooks/{useEnrichedRangePickerFieldProps.d.ts → useEnrichedRangePickerField.d.ts}
RENAMED
|
@@ -3,12 +3,12 @@ import Stack, { StackProps } from '@mui/material/Stack';
|
|
|
3
3
|
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
4
4
|
import { SlotComponentProps } from '@mui/utils';
|
|
5
5
|
import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
6
|
-
import { FieldRef, PickerOwnerState } from '@mui/x-date-pickers/models';
|
|
6
|
+
import { FieldSelectedSections, FieldRef, PickerOwnerState, FieldOwnerState } 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 {
|
|
9
|
+
import { PickerVariant, DateOrTimeViewWithMeridiem, BaseSingleInputFieldProps, PickerRangeValue, PickerValue, PickerContextValue, PickerFieldPrivateContextValue } from '@mui/x-date-pickers/internals';
|
|
10
10
|
import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
|
|
11
|
-
import {
|
|
11
|
+
import { RangePosition, FieldType, PickerRangeFieldSlotProps } from '../../models';
|
|
12
12
|
import { UseRangePositionResponse } from './useRangePosition';
|
|
13
13
|
import { BaseMultiInputFieldProps } from '../models/fields';
|
|
14
14
|
export interface RangePickerFieldSlots extends UseClearableFieldSlots {
|
|
@@ -31,31 +31,40 @@ export interface RangePickerFieldSlots extends UseClearableFieldSlots {
|
|
|
31
31
|
textField?: React.ElementType;
|
|
32
32
|
}
|
|
33
33
|
export interface RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseClearableFieldSlotProps {
|
|
34
|
-
field?: SlotComponentPropsFromProps<PickerRangeFieldSlotProps<
|
|
35
|
-
fieldRoot?: SlotComponentProps<typeof Stack, {},
|
|
36
|
-
fieldSeparator?: SlotComponentProps<typeof Typography, {},
|
|
37
|
-
textField?: SlotComponentProps<typeof PickersTextField, {},
|
|
34
|
+
field?: SlotComponentPropsFromProps<PickerRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
35
|
+
fieldRoot?: SlotComponentProps<typeof Stack, {}, FieldOwnerState>;
|
|
36
|
+
fieldSeparator?: SlotComponentProps<typeof Typography, {}, FieldOwnerState>;
|
|
37
|
+
textField?: SlotComponentProps<typeof PickersTextField, {}, FieldOwnerState & {
|
|
38
38
|
position?: RangePosition;
|
|
39
39
|
}>;
|
|
40
40
|
}
|
|
41
|
-
export type RangePickerPropsForFieldSlot<TIsSingleInput extends boolean
|
|
42
|
-
export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends
|
|
41
|
+
export type RangePickerPropsForFieldSlot<TIsSingleInput extends boolean> = (TIsSingleInput extends true ? BaseSingleInputFieldProps<PickerRangeValue> : never) | (TIsSingleInput extends false ? BaseMultiInputFieldProps : never);
|
|
42
|
+
export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends UseRangePositionResponse {
|
|
43
|
+
contextValue: PickerContextValue<PickerRangeValue, TView, TError>;
|
|
44
|
+
fieldPrivateContextValue: PickerFieldPrivateContextValue;
|
|
43
45
|
variant: PickerVariant;
|
|
44
46
|
fieldType: FieldType;
|
|
45
47
|
readOnly?: boolean;
|
|
46
48
|
labelId?: string;
|
|
47
49
|
disableOpenPicker?: boolean;
|
|
48
50
|
onBlur?: () => void;
|
|
49
|
-
label?: React.ReactNode;
|
|
50
51
|
localeText: PickersInputLocaleText | undefined;
|
|
51
52
|
pickerSlotProps: RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure> | undefined;
|
|
52
53
|
pickerSlots: RangePickerFieldSlots | undefined;
|
|
53
|
-
fieldProps: RangePickerPropsForFieldSlot<TIsSingleInput
|
|
54
|
-
anchorRef?: React.Ref<
|
|
54
|
+
fieldProps: RangePickerPropsForFieldSlot<TIsSingleInput>;
|
|
55
|
+
anchorRef?: React.Ref<HTMLElement>;
|
|
55
56
|
currentView?: TView | null;
|
|
56
57
|
initialView?: TView;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
startFieldRef: React.RefObject<FieldRef<PickerValue> | null>;
|
|
59
|
+
endFieldRef: React.RefObject<FieldRef<PickerValue> | null>;
|
|
60
|
+
singleInputFieldRef: React.RefObject<FieldRef<PickerRangeValue> | null>;
|
|
60
61
|
}
|
|
61
|
-
export declare const
|
|
62
|
+
export declare const useEnrichedRangePickerField: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError>(params: UseEnrichedRangePickerFieldPropsParams<boolean, TView, TEnableAccessibleFieldDOMStructure, TError>) => {
|
|
63
|
+
fieldProps: BaseMultiInputFieldProps;
|
|
64
|
+
fieldPrivateContextValue: {};
|
|
65
|
+
} | {
|
|
66
|
+
fieldProps: BaseSingleInputFieldProps<PickerRangeValue>;
|
|
67
|
+
fieldPrivateContextValue: {
|
|
68
|
+
onSelectedSectionsChange: (selectedSection: FieldSelectedSections) => void;
|
|
69
|
+
};
|
|
70
|
+
};
|
package/internals/hooks/{useEnrichedRangePickerFieldProps.js → useEnrichedRangePickerField.js}
RENAMED
|
@@ -8,15 +8,14 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
8
8
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
9
9
|
import { onSpaceOrEnter } from '@mui/x-date-pickers/internals';
|
|
10
10
|
const useMultiInputFieldSlotProps = ({
|
|
11
|
+
contextValue,
|
|
11
12
|
variant,
|
|
12
|
-
open,
|
|
13
|
-
actions,
|
|
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,34 +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();
|
|
56
|
+
contextValue.setOpen(true);
|
|
58
57
|
}
|
|
59
58
|
};
|
|
60
59
|
const openRangeEndSelection = event => {
|
|
61
60
|
event.stopPropagation();
|
|
62
|
-
|
|
61
|
+
setRangePosition('end');
|
|
63
62
|
if (!readOnly && !disableOpenPicker) {
|
|
64
|
-
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
contextValue.setOpen(true);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
const handleFocusStart = () => {
|
|
68
|
-
if (open) {
|
|
69
|
-
|
|
68
|
+
if (contextValue.open) {
|
|
69
|
+
setRangePosition('start');
|
|
70
70
|
if (previousRangePosition.current !== 'start' && initialView) {
|
|
71
|
-
|
|
71
|
+
contextValue.setView?.(initialView);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
const handleFocusEnd = () => {
|
|
76
|
-
if (open) {
|
|
77
|
-
|
|
76
|
+
if (contextValue.open) {
|
|
77
|
+
setRangePosition('end');
|
|
78
78
|
if (previousRangePosition.current !== 'end' && initialView) {
|
|
79
|
-
|
|
79
|
+
contextValue.setView?.(initialView);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
};
|
|
@@ -95,8 +95,8 @@ const useMultiInputFieldSlotProps = ({
|
|
|
95
95
|
label: inLocaleText?.start ?? translations.start,
|
|
96
96
|
onKeyDown: onSpaceOrEnter(openRangeStartSelection),
|
|
97
97
|
onFocus: handleFocusStart,
|
|
98
|
-
focused: open ? rangePosition === 'start' : undefined
|
|
99
|
-
}, !readOnly && !
|
|
98
|
+
focused: contextValue.open ? rangePosition === 'start' : undefined
|
|
99
|
+
}, !readOnly && !contextValue.disabled && {
|
|
100
100
|
onClick: openRangeStartSelection
|
|
101
101
|
}, variant === 'mobile' && {
|
|
102
102
|
readOnly: true
|
|
@@ -111,8 +111,8 @@ const useMultiInputFieldSlotProps = ({
|
|
|
111
111
|
label: inLocaleText?.end ?? translations.end,
|
|
112
112
|
onKeyDown: onSpaceOrEnter(openRangeEndSelection),
|
|
113
113
|
onFocus: handleFocusEnd,
|
|
114
|
-
focused: open ? rangePosition === 'end' : undefined
|
|
115
|
-
}, !readOnly && !
|
|
114
|
+
focused: contextValue.open ? rangePosition === 'end' : undefined
|
|
115
|
+
}, !readOnly && !contextValue.disabled && {
|
|
116
116
|
onClick: openRangeEndSelection
|
|
117
117
|
}, variant === 'mobile' && {
|
|
118
118
|
readOnly: true
|
|
@@ -143,96 +143,83 @@ const useMultiInputFieldSlotProps = ({
|
|
|
143
143
|
slots,
|
|
144
144
|
slotProps
|
|
145
145
|
});
|
|
146
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
fieldProps: enrichedFieldProps,
|
|
148
|
+
fieldPrivateContextValue: {}
|
|
149
|
+
};
|
|
147
150
|
};
|
|
148
151
|
const useSingleInputFieldSlotProps = ({
|
|
152
|
+
contextValue,
|
|
153
|
+
fieldPrivateContextValue,
|
|
149
154
|
variant,
|
|
150
|
-
open,
|
|
151
|
-
actions,
|
|
152
155
|
readOnly,
|
|
153
156
|
labelId,
|
|
154
157
|
disableOpenPicker,
|
|
155
|
-
label,
|
|
156
158
|
onBlur,
|
|
157
159
|
rangePosition,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
endFieldRef,
|
|
161
|
-
pickerSlots,
|
|
162
|
-
pickerSlotProps,
|
|
160
|
+
setRangePosition,
|
|
161
|
+
singleInputFieldRef,
|
|
163
162
|
fieldProps,
|
|
164
|
-
anchorRef,
|
|
165
163
|
currentView
|
|
166
164
|
}) => {
|
|
167
|
-
const handleFieldRef = useForkRef(fieldProps.unstableFieldRef,
|
|
165
|
+
const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
|
|
168
166
|
React.useEffect(() => {
|
|
169
|
-
if (!open || !
|
|
167
|
+
if (!contextValue.open || !singleInputFieldRef.current || variant === 'mobile') {
|
|
170
168
|
return;
|
|
171
169
|
}
|
|
172
|
-
if (
|
|
170
|
+
if (singleInputFieldRef.current.isFieldFocused()) {
|
|
173
171
|
return;
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
// bring back focus to the field with the current view section selected
|
|
177
175
|
if (currentView) {
|
|
178
|
-
const sections =
|
|
176
|
+
const sections = singleInputFieldRef.current.getSections().map(section => section.type);
|
|
179
177
|
const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
|
|
180
|
-
|
|
178
|
+
singleInputFieldRef.current?.focusField(newSelectedSection);
|
|
181
179
|
}
|
|
182
|
-
}, [rangePosition, open, currentView,
|
|
180
|
+
}, [rangePosition, contextValue.open, currentView, singleInputFieldRef, variant]);
|
|
183
181
|
const updateRangePosition = () => {
|
|
184
|
-
if (!
|
|
182
|
+
if (!singleInputFieldRef.current?.isFieldFocused()) {
|
|
185
183
|
return;
|
|
186
184
|
}
|
|
187
|
-
const sections =
|
|
188
|
-
const activeSectionIndex =
|
|
185
|
+
const sections = singleInputFieldRef.current.getSections();
|
|
186
|
+
const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
|
|
189
187
|
const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
|
|
190
188
|
if (domRangePosition != null && domRangePosition !== rangePosition) {
|
|
191
|
-
|
|
189
|
+
setRangePosition(domRangePosition);
|
|
192
190
|
}
|
|
193
191
|
};
|
|
194
192
|
const handleSelectedSectionsChange = useEventCallback(selectedSection => {
|
|
195
193
|
setTimeout(updateRangePosition);
|
|
196
|
-
|
|
194
|
+
fieldPrivateContextValue.onSelectedSectionsChange?.(selectedSection);
|
|
197
195
|
});
|
|
198
196
|
const openPicker = event => {
|
|
199
197
|
event.stopPropagation();
|
|
200
198
|
if (!readOnly && !disableOpenPicker) {
|
|
201
|
-
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
contextValue.setOpen(true);
|
|
202
201
|
}
|
|
203
202
|
};
|
|
204
|
-
const slots = _extends({}, fieldProps.slots, {
|
|
205
|
-
textField: pickerSlots?.textField,
|
|
206
|
-
clearButton: pickerSlots?.clearButton,
|
|
207
|
-
clearIcon: pickerSlots?.clearIcon
|
|
208
|
-
});
|
|
209
|
-
const slotProps = _extends({}, fieldProps.slotProps, {
|
|
210
|
-
textField: pickerSlotProps?.textField,
|
|
211
|
-
clearButton: pickerSlotProps?.clearButton,
|
|
212
|
-
clearIcon: pickerSlotProps?.clearIcon
|
|
213
|
-
});
|
|
214
203
|
const enrichedFieldProps = _extends({}, fieldProps, {
|
|
215
|
-
slots,
|
|
216
|
-
slotProps,
|
|
217
|
-
label,
|
|
218
204
|
unstableFieldRef: handleFieldRef,
|
|
219
205
|
onKeyDown: onSpaceOrEnter(openPicker, fieldProps.onKeyDown),
|
|
220
|
-
onSelectedSectionsChange: handleSelectedSectionsChange,
|
|
221
206
|
onBlur,
|
|
222
|
-
|
|
223
|
-
ref: anchorRef
|
|
224
|
-
}, fieldProps?.InputProps),
|
|
225
|
-
focused: open ? true : undefined
|
|
207
|
+
focused: contextValue.open ? true : undefined
|
|
226
208
|
}, labelId != null && {
|
|
227
209
|
id: labelId
|
|
228
210
|
}, variant === 'mobile' && {
|
|
229
211
|
readOnly: true
|
|
230
|
-
}, !readOnly && !
|
|
212
|
+
}, !readOnly && !contextValue.disabled && {
|
|
231
213
|
onClick: openPicker
|
|
232
214
|
});
|
|
233
|
-
return
|
|
215
|
+
return {
|
|
216
|
+
fieldProps: enrichedFieldProps,
|
|
217
|
+
fieldPrivateContextValue: {
|
|
218
|
+
onSelectedSectionsChange: handleSelectedSectionsChange
|
|
219
|
+
}
|
|
220
|
+
};
|
|
234
221
|
};
|
|
235
|
-
export const
|
|
222
|
+
export const useEnrichedRangePickerField = params => {
|
|
236
223
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
237
224
|
if (process.env.NODE_ENV !== 'production') {
|
|
238
225
|
const fieldTypeRef = React.useRef(params.fieldType);
|