@mui/x-date-pickers-pro 8.0.0-alpha.6 → 8.0.0-alpha.7
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 +127 -1
- package/DateRangeCalendar/DateRangeCalendar.js +9 -7
- package/DateRangePicker/DateRangePicker.js +1 -1
- package/DateRangePicker/DateRangePicker.types.d.ts +5 -0
- package/DateRangePicker/DateRangePickerToolbar.d.ts +2 -3
- package/DateRangePicker/DateRangePickerToolbar.js +25 -17
- package/DateRangePicker/shared.d.ts +1 -1
- package/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +3 -4
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +8 -10
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +7 -5
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -3
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +26 -28
- package/DateTimeRangePicker/shared.d.ts +2 -2
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +5 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
- package/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
- package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +13 -14
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +13 -14
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +13 -14
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -2
- package/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/package.json +6 -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/useRangePicker.d.ts +2 -2
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +26 -43
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +3 -5
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +5 -5
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +3 -3
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +21 -35
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +3 -5
- package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +10 -12
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -1
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +11 -6
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +2 -2
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +12 -7
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +2 -2
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +13 -8
- package/internals/hooks/useNullablePickerRangePositionContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
- package/internals/hooks/useRangePosition.d.ts +1 -1
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +2 -2
- package/internals/utils/date-range-manager.js +2 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.js +7 -7
- package/managers/index.d.ts +6 -0
- package/managers/index.js +3 -0
- package/managers/package.json +6 -0
- package/managers/useDateRangeManager.d.ts +15 -0
- package/managers/useDateRangeManager.js +31 -0
- package/managers/useDateTimeRangeManager.d.ts +15 -0
- package/managers/useDateTimeRangeManager.js +31 -0
- package/managers/useTimeRangeManager.d.ts +15 -0
- package/managers/useTimeRangeManager.js +29 -0
- package/models/range.d.ts +0 -1
- package/modern/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/modern/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +9 -7
- package/modern/DateRangePicker/DateRangePicker.js +1 -1
- package/modern/DateRangePicker/DateRangePickerToolbar.js +25 -17
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +7 -5
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +26 -28
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +13 -14
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +13 -14
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +13 -14
- package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/usePickerRangePositionContext.js +15 -0
- package/modern/index.js +4 -2
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +26 -43
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +3 -3
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +21 -35
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +11 -6
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +12 -7
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +13 -8
- package/modern/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
- 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 +31 -0
- package/modern/managers/useDateTimeRangeManager.js +31 -0
- package/modern/managers/useTimeRangeManager.js +29 -0
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/DateRangeCalendar/DateRangeCalendar.js +9 -7
- package/node/DateRangePicker/DateRangePicker.js +1 -1
- package/node/DateRangePicker/DateRangePickerToolbar.js +24 -16
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +7 -5
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +26 -28
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +12 -14
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +12 -14
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +12 -14
- package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
- package/node/hooks/index.js +12 -0
- package/node/hooks/usePickerRangePositionContext.js +22 -0
- package/node/index.js +23 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +26 -43
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +3 -3
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +21 -35
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +10 -5
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +11 -6
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +12 -7
- package/node/internals/hooks/useNullablePickerRangePositionContext.js +16 -0
- package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
- 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 +38 -0
- package/node/managers/useDateTimeRangeManager.js +38 -0
- package/node/managers/useTimeRangeManager.js +36 -0
- package/package.json +5 -5
|
@@ -7,6 +7,7 @@ import { styled } from '@mui/material/styles';
|
|
|
7
7
|
import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
|
|
8
8
|
import { usePicker, DIALOG_WIDTH, PickerProvider } from '@mui/x-date-pickers/internals';
|
|
9
9
|
import { useRangePosition } from "../useRangePosition.js";
|
|
10
|
+
import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const PickerStaticLayout = styled(PickersLayout)(({
|
|
12
13
|
theme
|
|
@@ -35,12 +36,8 @@ export const useStaticRangePicker = _ref => {
|
|
|
35
36
|
displayStaticWrapperAs,
|
|
36
37
|
autoFocus
|
|
37
38
|
} = props;
|
|
39
|
+
const rangePositionResponse = useRangePosition(props);
|
|
38
40
|
const {
|
|
39
|
-
rangePosition,
|
|
40
|
-
onRangePositionChange
|
|
41
|
-
} = useRangePosition(props);
|
|
42
|
-
const {
|
|
43
|
-
layoutProps,
|
|
44
41
|
providerProps,
|
|
45
42
|
renderCurrentView
|
|
46
43
|
} = usePicker(_extends({}, pickerParams, {
|
|
@@ -48,29 +45,22 @@ export const useStaticRangePicker = _ref => {
|
|
|
48
45
|
autoFocusView: autoFocus ?? false,
|
|
49
46
|
fieldRef: undefined,
|
|
50
47
|
localeText,
|
|
51
|
-
additionalViewProps: {
|
|
52
|
-
rangePosition,
|
|
53
|
-
onRangePositionChange
|
|
54
|
-
},
|
|
55
48
|
variant: displayStaticWrapperAs
|
|
56
49
|
}));
|
|
57
50
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
className: clsx(className, slotProps?.layout?.className),
|
|
70
|
-
ref: ref,
|
|
71
|
-
children: renderCurrentView()
|
|
51
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerRangePositionContext.Provider, {
|
|
52
|
+
value: rangePositionResponse,
|
|
53
|
+
children: /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
54
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
55
|
+
slots: slots,
|
|
56
|
+
slotProps: slotProps,
|
|
57
|
+
sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps?.layout?.sx) ? slotProps.layout.sx : [slotProps?.layout?.sx])],
|
|
58
|
+
className: clsx(className, slotProps?.layout?.className),
|
|
59
|
+
ref: ref,
|
|
60
|
+
children: renderCurrentView()
|
|
61
|
+
}))
|
|
72
62
|
}))
|
|
73
|
-
})
|
|
63
|
+
});
|
|
74
64
|
return {
|
|
75
65
|
renderPicker
|
|
76
66
|
};
|
|
@@ -9,7 +9,7 @@ export interface UseStaticRangePickerSlotProps extends ExportedPickersLayoutSlot
|
|
|
9
9
|
}
|
|
10
10
|
export interface StaticRangeOnlyPickerProps extends StaticOnlyPickerProps, UseRangePositionProps {
|
|
11
11
|
}
|
|
12
|
-
export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends BasePickerProps<PickerRangeValue, TView, TError, TExternalProps
|
|
12
|
+
export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends BasePickerProps<PickerRangeValue, TView, TError, TExternalProps>, StaticRangeOnlyPickerProps {
|
|
13
13
|
/**
|
|
14
14
|
* Overridable components.
|
|
15
15
|
* @default {}
|
|
@@ -21,7 +21,7 @@ export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
21
21
|
*/
|
|
22
22
|
slotProps?: UseStaticRangePickerSlotProps;
|
|
23
23
|
}
|
|
24
|
-
export interface UseStaticRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps
|
|
24
|
+
export interface UseStaticRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator'> {
|
|
25
25
|
props: TExternalProps;
|
|
26
26
|
/**
|
|
27
27
|
* Ref to pass to the root element
|
|
@@ -8,7 +8,8 @@ export function calculateRangeChange({
|
|
|
8
8
|
shouldMergeDateAndTime = false,
|
|
9
9
|
referenceDate
|
|
10
10
|
}) {
|
|
11
|
-
const
|
|
11
|
+
const start = !utils.isValid(range[0]) ? null : range[0];
|
|
12
|
+
const end = !utils.isValid(range[1]) ? null : range[1];
|
|
12
13
|
if (shouldMergeDateAndTime && selectedDate) {
|
|
13
14
|
// If there is a date already selected, then we want to keep its time
|
|
14
15
|
if (start && rangePosition === 'start') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczNjM3NzIwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -12,8 +12,8 @@ export const rangeValueManager = {
|
|
|
12
12
|
referenceDate: referenceDateProp
|
|
13
13
|
} = _ref,
|
|
14
14
|
params = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
|
-
const shouldKeepStartDate =
|
|
16
|
-
const shouldKeepEndDate =
|
|
15
|
+
const shouldKeepStartDate = params.utils.isValid(value[0]);
|
|
16
|
+
const shouldKeepEndDate = params.utils.isValid(value[1]);
|
|
17
17
|
if (shouldKeepStartDate && shouldKeepEndDate) {
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
@@ -26,8 +26,8 @@ export const rangeValueManager = {
|
|
|
26
26
|
hasError: error => error[0] != null || error[1] != null,
|
|
27
27
|
defaultErrorState: [null, null],
|
|
28
28
|
getTimezone: (utils, value) => {
|
|
29
|
-
const timezoneStart =
|
|
30
|
-
const timezoneEnd =
|
|
29
|
+
const timezoneStart = utils.isValid(value[0]) ? utils.getTimezone(value[0]) : null;
|
|
30
|
+
const timezoneEnd = utils.isValid(value[1]) ? utils.getTimezone(value[1]) : null;
|
|
31
31
|
if (timezoneStart != null && timezoneEnd != null && timezoneStart !== timezoneEnd) {
|
|
32
32
|
throw new Error('MUI X: The timezone of the start and the end date should be the same.');
|
|
33
33
|
}
|
|
@@ -39,8 +39,8 @@ export const getRangeFieldValueManager = ({
|
|
|
39
39
|
dateSeparator = '–'
|
|
40
40
|
}) => ({
|
|
41
41
|
updateReferenceValue: (utils, value, prevReferenceValue) => {
|
|
42
|
-
const shouldKeepStartDate =
|
|
43
|
-
const shouldKeepEndDate =
|
|
42
|
+
const shouldKeepStartDate = utils.isValid(value[0]);
|
|
43
|
+
const shouldKeepEndDate = utils.isValid(value[1]);
|
|
44
44
|
if (!shouldKeepStartDate && !shouldKeepEndDate) {
|
|
45
45
|
return prevReferenceValue;
|
|
46
46
|
}
|
|
@@ -111,7 +111,7 @@ export const getRangeFieldValueManager = ({
|
|
|
111
111
|
},
|
|
112
112
|
getNewValuesFromNewActiveDate: newActiveDate => ({
|
|
113
113
|
value: updateDateInRange(newActiveDate, state.value),
|
|
114
|
-
referenceValue:
|
|
114
|
+
referenceValue: !utils.isValid(newActiveDate) ? state.referenceValue : updateDateInRange(newActiveDate, state.referenceValue)
|
|
115
115
|
})
|
|
116
116
|
};
|
|
117
117
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useDateRangeManager } from './useDateRangeManager';
|
|
2
|
+
export type { UseDateRangeManagerReturnValue, UseDateRangeManagerParameters, } from './useDateRangeManager';
|
|
3
|
+
export { useTimeRangeManager } from './useTimeRangeManager';
|
|
4
|
+
export type { UseTimeRangeManagerReturnValue, UseTimeRangeManagerParameters, } from './useTimeRangeManager';
|
|
5
|
+
export { useDateTimeRangeManager } from './useDateTimeRangeManager';
|
|
6
|
+
export type { UseDateTimeRangeManagerReturnValue, UseDateTimeRangeManagerParameters, } from './useDateTimeRangeManager';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
|
+
import { PickerManager } from '@mui/x-date-pickers/models';
|
|
3
|
+
import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
4
|
+
import { DateRangeValidationError, RangeFieldSeparatorProps } from '../models';
|
|
5
|
+
import { ExportedValidateDateRangeProps, ValidateDateRangeProps } from '../validation/validateDateRange';
|
|
6
|
+
export declare function useDateRangeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateRangeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
7
|
+
export interface UseDateRangeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> extends RangeFieldSeparatorProps {
|
|
8
|
+
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
9
|
+
}
|
|
10
|
+
export type UseDateRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError, DateRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, DateRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
|
|
11
|
+
interface DateRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateRangeProps {
|
|
12
|
+
}
|
|
13
|
+
interface DateRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, ValidateDateRangeProps, RangeFieldSeparatorProps {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { getDateFieldInternalPropsDefaults } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { getRangeFieldValueManager, rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
7
|
+
import { validateDateRange } from "../validation/index.js";
|
|
8
|
+
export function useDateRangeManager(parameters = {}) {
|
|
9
|
+
const {
|
|
10
|
+
enableAccessibleFieldDOMStructure = true,
|
|
11
|
+
dateSeparator
|
|
12
|
+
} = parameters;
|
|
13
|
+
return React.useMemo(() => ({
|
|
14
|
+
valueType: 'date',
|
|
15
|
+
validator: validateDateRange,
|
|
16
|
+
internal_valueManager: rangeValueManager,
|
|
17
|
+
internal_fieldValueManager: getRangeFieldValueManager({
|
|
18
|
+
dateSeparator
|
|
19
|
+
}),
|
|
20
|
+
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
21
|
+
internal_applyDefaultsToFieldInternalProps: ({
|
|
22
|
+
internalProps,
|
|
23
|
+
utils,
|
|
24
|
+
defaultDates
|
|
25
|
+
}) => _extends({}, internalProps, getDateFieldInternalPropsDefaults({
|
|
26
|
+
defaultDates,
|
|
27
|
+
utils,
|
|
28
|
+
internalProps
|
|
29
|
+
}))
|
|
30
|
+
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
|
+
import { PickerManager } from '@mui/x-date-pickers/models';
|
|
3
|
+
import { AmPmProps, PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
4
|
+
import { DateTimeRangeValidationError, RangeFieldSeparatorProps } from '../models';
|
|
5
|
+
import { ExportedValidateDateTimeRangeProps, ValidateDateTimeRangeProps } from '../validation/validateDateTimeRange';
|
|
6
|
+
export declare function useDateTimeRangeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateTimeRangeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateTimeRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
7
|
+
export interface UseDateTimeRangeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> extends RangeFieldSeparatorProps {
|
|
8
|
+
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
9
|
+
}
|
|
10
|
+
export type UseDateTimeRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError, DateTimeRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, DateTimeRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
|
|
11
|
+
interface DateTimeRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'format'>, ExportedValidateDateTimeRangeProps, AmPmProps, RangeFieldSeparatorProps {
|
|
12
|
+
}
|
|
13
|
+
interface DateTimeRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, ValidateDateTimeRangeProps, RangeFieldSeparatorProps {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { getDateTimeFieldInternalPropsDefaults } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { getRangeFieldValueManager, rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
7
|
+
import { validateDateTimeRange } from "../validation/index.js";
|
|
8
|
+
export function useDateTimeRangeManager(parameters = {}) {
|
|
9
|
+
const {
|
|
10
|
+
enableAccessibleFieldDOMStructure = true,
|
|
11
|
+
dateSeparator
|
|
12
|
+
} = parameters;
|
|
13
|
+
return React.useMemo(() => ({
|
|
14
|
+
valueType: 'date-time',
|
|
15
|
+
validator: validateDateTimeRange,
|
|
16
|
+
internal_valueManager: rangeValueManager,
|
|
17
|
+
internal_fieldValueManager: getRangeFieldValueManager({
|
|
18
|
+
dateSeparator
|
|
19
|
+
}),
|
|
20
|
+
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
21
|
+
internal_applyDefaultsToFieldInternalProps: ({
|
|
22
|
+
internalProps,
|
|
23
|
+
utils,
|
|
24
|
+
defaultDates
|
|
25
|
+
}) => _extends({}, internalProps, getDateTimeFieldInternalPropsDefaults({
|
|
26
|
+
internalProps,
|
|
27
|
+
utils,
|
|
28
|
+
defaultDates
|
|
29
|
+
}))
|
|
30
|
+
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
|
+
import { PickerManager } from '@mui/x-date-pickers/models';
|
|
3
|
+
import { AmPmProps, PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
4
|
+
import { TimeRangeValidationError, RangeFieldSeparatorProps } from '../models';
|
|
5
|
+
import { ExportedValidateTimeRangeProps, ValidateTimeRangeProps } from '../validation/validateTimeRange';
|
|
6
|
+
export declare function useTimeRangeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseTimeRangeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseTimeRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
7
|
+
export interface UseTimeRangeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> extends RangeFieldSeparatorProps {
|
|
8
|
+
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
9
|
+
}
|
|
10
|
+
export type UseTimeRangeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError, TimeRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, TimeRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
|
|
11
|
+
interface TimeRangeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'format'>, ExportedValidateTimeRangeProps, AmPmProps, RangeFieldSeparatorProps {
|
|
12
|
+
}
|
|
13
|
+
interface TimeRangeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, ValidateTimeRangeProps {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { getTimeFieldInternalPropsDefaults } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { getRangeFieldValueManager, rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
7
|
+
import { validateTimeRange } from "../validation/index.js";
|
|
8
|
+
export function useTimeRangeManager(parameters = {}) {
|
|
9
|
+
const {
|
|
10
|
+
enableAccessibleFieldDOMStructure = true,
|
|
11
|
+
dateSeparator
|
|
12
|
+
} = parameters;
|
|
13
|
+
return React.useMemo(() => ({
|
|
14
|
+
valueType: 'time',
|
|
15
|
+
validator: validateTimeRange,
|
|
16
|
+
internal_valueManager: rangeValueManager,
|
|
17
|
+
internal_fieldValueManager: getRangeFieldValueManager({
|
|
18
|
+
dateSeparator
|
|
19
|
+
}),
|
|
20
|
+
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
21
|
+
internal_applyDefaultsToFieldInternalProps: ({
|
|
22
|
+
internalProps,
|
|
23
|
+
utils
|
|
24
|
+
}) => _extends({}, internalProps, getTimeFieldInternalPropsDefaults({
|
|
25
|
+
utils,
|
|
26
|
+
internalProps
|
|
27
|
+
}))
|
|
28
|
+
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
29
|
+
}
|
package/models/range.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AdapterDateFnsJalali } from '@mui/x-date-pickers/
|
|
1
|
+
export { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV2';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AdapterDateFns } from '@mui/x-date-pickers/
|
|
1
|
+
export { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV2';
|
|
@@ -27,6 +27,7 @@ import { useDragRange } from "./useDragRange.js";
|
|
|
27
27
|
import { useRangePosition } from "../internals/hooks/useRangePosition.js";
|
|
28
28
|
import { DAY_RANGE_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
|
|
29
29
|
import { PickersRangeCalendarHeader } from "../PickersRangeCalendarHeader/index.js";
|
|
30
|
+
import { useNullablePickerRangePositionContext } from "../internals/hooks/useNullablePickerRangePositionContext.js";
|
|
30
31
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
32
|
const releaseInfo = getReleaseInfo();
|
|
32
33
|
const DateRangeCalendarRoot = styled('div', {
|
|
@@ -135,8 +136,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
135
136
|
reduceAnimations,
|
|
136
137
|
onMonthChange,
|
|
137
138
|
rangePosition: rangePositionProp,
|
|
138
|
-
defaultRangePosition:
|
|
139
|
-
onRangePositionChange:
|
|
139
|
+
defaultRangePosition: defaultRangePositionProp,
|
|
140
|
+
onRangePositionChange: onRangePositionChangeProp,
|
|
140
141
|
calendars,
|
|
141
142
|
currentMonthCalendarPosition = 1,
|
|
142
143
|
slots,
|
|
@@ -161,6 +162,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
161
162
|
onViewChange
|
|
162
163
|
} = props,
|
|
163
164
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
165
|
+
const rangePositionContext = useNullablePickerRangePositionContext();
|
|
164
166
|
const {
|
|
165
167
|
value,
|
|
166
168
|
handleValueChange,
|
|
@@ -192,9 +194,9 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
192
194
|
rangePosition,
|
|
193
195
|
onRangePositionChange
|
|
194
196
|
} = useRangePosition({
|
|
195
|
-
rangePosition: rangePositionProp,
|
|
196
|
-
defaultRangePosition:
|
|
197
|
-
onRangePositionChange:
|
|
197
|
+
rangePosition: rangePositionProp ?? rangePositionContext?.rangePosition,
|
|
198
|
+
defaultRangePosition: defaultRangePositionProp,
|
|
199
|
+
onRangePositionChange: onRangePositionChangeProp ?? rangePositionContext?.onRangePositionChange
|
|
198
200
|
});
|
|
199
201
|
const handleDatePositionChange = useEventCallback(position => {
|
|
200
202
|
if (rangePosition !== position) {
|
|
@@ -228,7 +230,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
228
230
|
|
|
229
231
|
// Range going for the start of the start day to the end of the end day.
|
|
230
232
|
// This makes sure that `isWithinRange` works with any time in the start and end day.
|
|
231
|
-
const valueDayRange = React.useMemo(() => [
|
|
233
|
+
const valueDayRange = React.useMemo(() => [!utils.isValid(value[0]) ? value[0] : utils.startOfDay(value[0]), !utils.isValid(value[1]) ? value[1] : utils.endOfDay(value[1])], [value, utils]);
|
|
232
234
|
const _useDragRange = useDragRange({
|
|
233
235
|
disableDragEditing: shouldDisableDragEditing,
|
|
234
236
|
onDrop: handleDrop,
|
|
@@ -316,7 +318,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
316
318
|
const prevValue = React.useRef(null);
|
|
317
319
|
React.useEffect(() => {
|
|
318
320
|
const date = rangePosition === 'start' ? value[0] : value[1];
|
|
319
|
-
if (!
|
|
321
|
+
if (!utils.isValid(date)) {
|
|
320
322
|
return;
|
|
321
323
|
}
|
|
322
324
|
const prevDate = rangePosition === 'start' ? prevValue.current?.[0] : prevValue.current?.[1];
|
|
@@ -63,7 +63,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
63
63
|
calendars: PropTypes.oneOf([1, 2, 3]),
|
|
64
64
|
className: PropTypes.string,
|
|
65
65
|
/**
|
|
66
|
-
* If `true`, the
|
|
66
|
+
* If `true`, the Picker will close after submitting the full date.
|
|
67
67
|
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
|
|
68
68
|
*/
|
|
69
69
|
closeOnSelect: PropTypes.bool,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["
|
|
5
|
+
const _excluded = ["toolbarFormat", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
@@ -10,8 +10,9 @@ import Typography from '@mui/material/Typography';
|
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
12
|
import { PickersToolbar, PickersToolbarButton, useUtils, useToolbarOwnerState } from '@mui/x-date-pickers/internals';
|
|
13
|
-
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
13
|
+
import { usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
14
14
|
import { getDateRangePickerToolbarUtilityClass } from "./dateRangePickerToolbarClasses.js";
|
|
15
|
+
import { usePickerRangePositionContext } from "../hooks/index.js";
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
const useUtilityClasses = classes => {
|
|
17
18
|
const slots = {
|
|
@@ -49,38 +50,48 @@ const DateRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateRangeP
|
|
|
49
50
|
name: 'MuiDateRangePickerToolbar'
|
|
50
51
|
});
|
|
51
52
|
const {
|
|
52
|
-
|
|
53
|
-
rangePosition,
|
|
54
|
-
onRangePositionChange,
|
|
55
|
-
toolbarFormat,
|
|
53
|
+
toolbarFormat: toolbarFormatProp,
|
|
56
54
|
className,
|
|
57
55
|
classes: classesProp
|
|
58
56
|
} = props,
|
|
59
57
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
58
|
+
const {
|
|
59
|
+
value
|
|
60
|
+
} = usePickerContext();
|
|
60
61
|
const translations = usePickerTranslations();
|
|
61
62
|
const ownerState = useToolbarOwnerState();
|
|
63
|
+
const {
|
|
64
|
+
rangePosition,
|
|
65
|
+
onRangePositionChange
|
|
66
|
+
} = usePickerRangePositionContext();
|
|
62
67
|
const classes = useUtilityClasses(classesProp);
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
|
|
69
|
+
// This can't be a default value when spreading because it breaks the API generation.
|
|
70
|
+
const toolbarFormat = toolbarFormatProp ?? utils.formats.shortDate;
|
|
71
|
+
const formatDate = (date, fallback) => {
|
|
72
|
+
if (!utils.isValid(date)) {
|
|
73
|
+
return fallback;
|
|
74
|
+
}
|
|
75
|
+
return utils.formatByString(date, toolbarFormat);
|
|
76
|
+
};
|
|
65
77
|
return /*#__PURE__*/_jsx(DateRangePickerToolbarRoot, _extends({}, other, {
|
|
66
78
|
toolbarTitle: translations.dateRangePickerToolbarTitle,
|
|
67
|
-
isLandscape: false,
|
|
68
79
|
className: clsx(classes.root, className),
|
|
69
80
|
ownerState: ownerState,
|
|
70
81
|
ref: ref,
|
|
71
82
|
children: /*#__PURE__*/_jsxs(DateRangePickerToolbarContainer, {
|
|
72
83
|
className: classes.container,
|
|
73
84
|
children: [/*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
74
|
-
variant:
|
|
75
|
-
value:
|
|
85
|
+
variant: value[0] == null ? 'h6' : 'h5',
|
|
86
|
+
value: formatDate(value[0], translations.start),
|
|
76
87
|
selected: rangePosition === 'start',
|
|
77
88
|
onClick: () => onRangePositionChange('start')
|
|
78
89
|
}), /*#__PURE__*/_jsxs(Typography, {
|
|
79
90
|
variant: "h5",
|
|
80
91
|
children: ["\xA0", '–', "\xA0"]
|
|
81
92
|
}), /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
82
|
-
variant:
|
|
83
|
-
value:
|
|
93
|
+
variant: value[1] == null ? 'h6' : 'h5',
|
|
94
|
+
value: formatDate(value[1], translations.end),
|
|
84
95
|
selected: rangePosition === 'end',
|
|
85
96
|
onClick: () => onRangePositionChange('end')
|
|
86
97
|
})]
|
|
@@ -102,8 +113,6 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
102
113
|
* @default `true` for Desktop, `false` for Mobile.
|
|
103
114
|
*/
|
|
104
115
|
hidden: PropTypes.bool,
|
|
105
|
-
onRangePositionChange: PropTypes.func.isRequired,
|
|
106
|
-
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
107
116
|
/**
|
|
108
117
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
109
118
|
*/
|
|
@@ -117,7 +126,6 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
117
126
|
* Toolbar value placeholder—it is displayed when the value is empty.
|
|
118
127
|
* @default "––"
|
|
119
128
|
*/
|
|
120
|
-
toolbarPlaceholder: PropTypes.node
|
|
121
|
-
value: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
129
|
+
toolbarPlaceholder: PropTypes.node
|
|
122
130
|
} : void 0;
|
|
123
131
|
export { DateRangePickerToolbar };
|
|
@@ -68,8 +68,8 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
68
68
|
calendars: PropTypes.oneOf([1, 2, 3]),
|
|
69
69
|
className: PropTypes.string,
|
|
70
70
|
/**
|
|
71
|
-
* If `true`, the
|
|
72
|
-
* @default
|
|
71
|
+
* If `true`, the Picker will close after submitting the full date.
|
|
72
|
+
* @default false
|
|
73
73
|
*/
|
|
74
74
|
closeOnSelect: PropTypes.bool,
|
|
75
75
|
/**
|
|
@@ -12,6 +12,7 @@ import { usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hoo
|
|
|
12
12
|
import IconButton from '@mui/material/IconButton';
|
|
13
13
|
import Button from '@mui/material/Button';
|
|
14
14
|
import { getDateTimeRangePickerTabsUtilityClass } from "./dateTimeRangePickerTabsClasses.js";
|
|
15
|
+
import { usePickerRangePositionContext } from "../hooks/index.js";
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
const viewToTab = (view, rangePosition) => {
|
|
17
18
|
if (isDatePickerView(view)) {
|
|
@@ -71,8 +72,6 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
71
72
|
dateIcon = /*#__PURE__*/_jsx(DateRangeIcon, {}),
|
|
72
73
|
timeIcon = /*#__PURE__*/_jsx(TimeIcon, {}),
|
|
73
74
|
hidden = typeof window === 'undefined' || window.innerHeight < 667,
|
|
74
|
-
rangePosition,
|
|
75
|
-
onRangePositionChange,
|
|
76
75
|
className,
|
|
77
76
|
classes: classesProp,
|
|
78
77
|
sx
|
|
@@ -83,9 +82,13 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
83
82
|
} = usePickerPrivateContext();
|
|
84
83
|
const {
|
|
85
84
|
view,
|
|
86
|
-
|
|
85
|
+
setView
|
|
87
86
|
} = usePickerContext();
|
|
88
87
|
const classes = useUtilityClasses(classesProp);
|
|
88
|
+
const {
|
|
89
|
+
rangePosition,
|
|
90
|
+
onRangePositionChange
|
|
91
|
+
} = usePickerRangePositionContext();
|
|
89
92
|
const value = React.useMemo(() => view == null ? null : viewToTab(view, rangePosition), [view, rangePosition]);
|
|
90
93
|
const isPreviousHidden = value === 'start-date';
|
|
91
94
|
const isNextHidden = value === 'end-time';
|
|
@@ -112,12 +115,12 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
112
115
|
});
|
|
113
116
|
const changeToPreviousTab = useEventCallback(() => {
|
|
114
117
|
const previousTab = value == null ? tabOptions[0] : tabOptions[tabOptions.indexOf(value) - 1];
|
|
115
|
-
|
|
118
|
+
setView(tabToView(previousTab));
|
|
116
119
|
handleRangePositionChange(previousTab);
|
|
117
120
|
});
|
|
118
121
|
const changeToNextTab = useEventCallback(() => {
|
|
119
122
|
const nextTab = value == null ? tabOptions[0] : tabOptions[tabOptions.indexOf(value) + 1];
|
|
120
|
-
|
|
123
|
+
setView(tabToView(nextTab));
|
|
121
124
|
handleRangePositionChange(nextTab);
|
|
122
125
|
});
|
|
123
126
|
if (hidden) {
|
|
@@ -177,8 +180,6 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerTabs.propTypes = {
|
|
|
177
180
|
* @default `window.innerHeight < 667` for `DesktopDateTimeRangePicker` and `MobileDateTimeRangePicker`
|
|
178
181
|
*/
|
|
179
182
|
hidden: PropTypes.bool,
|
|
180
|
-
onRangePositionChange: PropTypes.func.isRequired,
|
|
181
|
-
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
182
183
|
/**
|
|
183
184
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
184
185
|
*/
|
|
@@ -1,17 +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 = ["
|
|
3
|
+
const _excluded = ["viewRenderer", "value", "onChange", "defaultValue", "onViewChange", "views", "className"];
|
|
4
4
|
import { isInternalTimeView, useUtils } from '@mui/x-date-pickers/internals';
|
|
5
5
|
import { isRangeValid } from "../internals/utils/date-utils.js";
|
|
6
6
|
import { calculateRangeChange } from "../internals/utils/date-range-manager.js";
|
|
7
|
+
import { usePickerRangePositionContext } from "../hooks/index.js";
|
|
7
8
|
/**
|
|
8
9
|
* @ignore - internal component.
|
|
9
10
|
*/
|
|
10
|
-
function DateTimeRangePickerTimeWrapper(props
|
|
11
|
+
function DateTimeRangePickerTimeWrapper(props) {
|
|
11
12
|
const utils = useUtils();
|
|
12
13
|
const {
|
|
13
|
-
rangePosition,
|
|
14
|
-
onRangePositionChange,
|
|
15
14
|
viewRenderer,
|
|
16
15
|
value,
|
|
17
16
|
onChange,
|
|
@@ -20,6 +19,10 @@ function DateTimeRangePickerTimeWrapper(props, ref) {
|
|
|
20
19
|
views
|
|
21
20
|
} = props,
|
|
22
21
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
22
|
+
const {
|
|
23
|
+
rangePosition,
|
|
24
|
+
onRangePositionChange
|
|
25
|
+
} = usePickerRangePositionContext();
|
|
23
26
|
if (!viewRenderer) {
|
|
24
27
|
return null;
|
|
25
28
|
}
|
|
@@ -47,7 +50,6 @@ function DateTimeRangePickerTimeWrapper(props, ref) {
|
|
|
47
50
|
onChange(newRange, isFullRangeSelected ? 'finish' : 'partial', selectedView);
|
|
48
51
|
};
|
|
49
52
|
return viewRenderer(_extends({}, other, {
|
|
50
|
-
ref,
|
|
51
53
|
views,
|
|
52
54
|
onViewChange,
|
|
53
55
|
value: currentValue,
|