@mui/x-date-pickers-pro 6.0.0-alpha.11 → 6.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +260 -0
- package/DateRangeCalendar/DateRangeCalendar.js +30 -3
- package/DateRangeCalendar/DateRangeCalendar.types.d.ts +37 -37
- package/DateRangePicker/DateRangePicker.js +0 -6
- package/DateRangePicker/DateRangePickerView.d.ts +3 -3
- package/DateRangePicker/DateRangePickerView.js +6 -3
- package/DateRangePicker/DateRangePickerViewMobile.js +1 -1
- package/DateRangePickerDay/DateRangePickerDay.js +72 -1
- package/DesktopDateRangePicker/DesktopDateRangePicker.d.ts +5 -0
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
- package/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
- package/MobileDateRangePicker/MobileDateRangePicker.d.ts +5 -0
- package/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
- package/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +51 -11
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +4 -2
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +3 -3
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +2 -2
- package/NextDateRangePicker/NextDateRangePicker.js +16 -2
- package/NextDateRangePicker/shared.d.ts +9 -2
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +3 -2
- package/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
- package/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +13 -0
- package/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
- package/dateRangeViewRenderers/index.d.ts +2 -0
- package/dateRangeViewRenderers/index.js +1 -0
- package/dateRangeViewRenderers/package.json +6 -0
- package/index.d.ts +2 -1
- package/index.js +5 -2
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +4 -5
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -1
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +4 -5
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +2 -0
- package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
- package/internal/hooks/useRangePickerInputProps.d.ts +7 -7
- package/internal/hooks/useRangePickerInputProps.js +12 -11
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +2 -2
- package/internal/models/dateRange.d.ts +11 -1
- package/internal/models/dateTimeRange.d.ts +2 -2
- package/internal/models/fields.d.ts +6 -1
- package/internal/models/range.d.ts +0 -4
- package/internal/models/timeRange.d.ts +2 -1
- package/internal/utils/date-fields-utils.d.ts +21 -5
- package/internal/utils/releaseInfo.js +1 -1
- package/internal/utils/valueManagers.d.ts +3 -2
- package/internal/utils/valueManagers.js +21 -22
- package/legacy/DateRangeCalendar/DateRangeCalendar.js +36 -3
- package/legacy/DateRangePicker/DateRangePicker.js +0 -6
- package/legacy/DateRangePicker/DateRangePickerView.js +7 -2
- package/legacy/DateRangePicker/DateRangePickerViewMobile.js +1 -1
- package/legacy/DateRangePickerDay/DateRangePickerDay.js +72 -1
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
- package/legacy/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
- package/legacy/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
- package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +48 -8
- package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +43 -8
- package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +43 -8
- package/legacy/NextDateRangePicker/NextDateRangePicker.js +16 -2
- package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +109 -4
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
- package/legacy/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
- package/legacy/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
- package/legacy/dateRangeViewRenderers/index.js +1 -0
- package/legacy/index.js +5 -2
- package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
- package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
- package/legacy/internal/hooks/useRangePickerInputProps.js +12 -11
- package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
- package/legacy/internal/utils/releaseInfo.js +1 -1
- package/legacy/internal/utils/valueManagers.js +20 -23
- package/legacy/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +29 -3
- package/modern/DateRangePicker/DateRangePicker.js +0 -6
- package/modern/DateRangePicker/DateRangePickerView.js +6 -3
- package/modern/DateRangePicker/DateRangePickerViewMobile.js +1 -1
- package/modern/DateRangePickerDay/DateRangePickerDay.js +72 -1
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
- package/modern/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
- package/modern/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +51 -11
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
- package/modern/NextDateRangePicker/NextDateRangePicker.js +16 -2
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
- package/modern/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
- package/modern/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +3 -4
- package/modern/dateRangeViewRenderers/index.js +1 -0
- package/modern/index.js +5 -2
- package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
- package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
- package/modern/internal/hooks/useRangePickerInputProps.js +11 -11
- package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
- package/modern/internal/utils/releaseInfo.js +1 -1
- package/modern/internal/utils/valueManagers.js +21 -22
- package/modern/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
- package/node/DateRangeCalendar/DateRangeCalendar.js +28 -2
- package/node/DateRangePicker/DateRangePicker.js +0 -6
- package/node/DateRangePicker/DateRangePickerView.js +6 -3
- package/node/DateRangePicker/DateRangePickerViewMobile.js +1 -1
- package/node/DateRangePickerDay/DateRangePickerDay.js +72 -1
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -6
- package/node/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +22 -9
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +0 -6
- package/node/MobileNextDateRangePicker/MobileNextDateRangePicker.js +22 -9
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +51 -11
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +45 -10
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +45 -10
- package/node/NextDateRangePicker/NextDateRangePicker.js +16 -2
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +110 -5
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +0 -5
- package/node/StaticNextDateRangePicker/StaticNextDateRangePicker.js +20 -6
- package/node/{internal/utils/viewRenderers.js → dateRangeViewRenderers/dateRangeViewRenderers.js} +4 -4
- package/node/dateRangeViewRenderers/index.js +12 -0
- package/node/index.js +13 -1
- package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +6 -4
- package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -4
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +7 -1
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +7 -1
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +7 -1
- package/node/internal/hooks/useRangePickerInputProps.js +11 -11
- package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -3
- package/node/internal/utils/releaseInfo.js +1 -1
- package/node/internal/utils/valueManagers.js +20 -21
- package/node/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
- package/package.json +4 -4
- package/tests/describeRangeValidation/testTextFieldRangeValidation.js +1 -1
- package/internal/utils/viewRenderers.d.ts +0 -7
|
@@ -12,7 +12,6 @@ const releaseInfo = getReleaseInfo();
|
|
|
12
12
|
export const useDesktopRangePicker = ({
|
|
13
13
|
props,
|
|
14
14
|
valueManager,
|
|
15
|
-
viewLookup,
|
|
16
15
|
validator
|
|
17
16
|
}) => {
|
|
18
17
|
useLicenseVerifier('x-date-pickers-pro', releaseInfo);
|
|
@@ -23,6 +22,7 @@ export const useDesktopRangePicker = ({
|
|
|
23
22
|
format,
|
|
24
23
|
readOnly,
|
|
25
24
|
disabled,
|
|
25
|
+
autoFocus,
|
|
26
26
|
disableOpenPicker,
|
|
27
27
|
localeText
|
|
28
28
|
} = props;
|
|
@@ -40,8 +40,8 @@ export const useDesktopRangePicker = ({
|
|
|
40
40
|
props,
|
|
41
41
|
valueManager,
|
|
42
42
|
wrapperVariant: 'desktop',
|
|
43
|
-
viewLookup,
|
|
44
43
|
validator,
|
|
44
|
+
autoFocusView: true,
|
|
45
45
|
additionalViewProps: {
|
|
46
46
|
rangePosition,
|
|
47
47
|
onRangePositionChange: setRangePosition
|
|
@@ -57,12 +57,13 @@ export const useDesktopRangePicker = ({
|
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
const fieldSlotsProps = useRangePickerInputProps({
|
|
60
|
-
wrapperVariant: '
|
|
60
|
+
wrapperVariant: 'desktop',
|
|
61
61
|
open,
|
|
62
62
|
actions,
|
|
63
63
|
readOnly,
|
|
64
64
|
disabled,
|
|
65
65
|
disableOpenPicker,
|
|
66
|
+
localeText,
|
|
66
67
|
onBlur: handleBlur,
|
|
67
68
|
rangePosition,
|
|
68
69
|
onRangePositionChange: setRangePosition
|
|
@@ -76,6 +77,7 @@ export const useDesktopRangePicker = ({
|
|
|
76
77
|
disabled,
|
|
77
78
|
className,
|
|
78
79
|
format,
|
|
80
|
+
autoFocus: autoFocus && !props.open,
|
|
79
81
|
ref: fieldRef
|
|
80
82
|
}),
|
|
81
83
|
ownerState: props
|
|
@@ -92,7 +94,7 @@ export const useDesktopRangePicker = ({
|
|
|
92
94
|
const inputPropsPassedByField = resolveComponentProps((_fieldProps$component = fieldProps.componentsProps) == null ? void 0 : _fieldProps$component.input, ownerState);
|
|
93
95
|
const inputPropsPassedByPicker = ownerState.position === 'start' ? fieldSlotsProps.startInput : fieldSlotsProps.endInput;
|
|
94
96
|
return _extends({}, externalInputProps, inputPropsPassedByField, inputPropsPassedByPicker, {
|
|
95
|
-
inputProps: _extends({}, externalInputProps == null ? void 0 : externalInputProps.inputProps, inputPropsPassedByField == null ? void 0 : inputPropsPassedByField.inputProps
|
|
97
|
+
inputProps: _extends({}, externalInputProps == null ? void 0 : externalInputProps.inputProps, inputPropsPassedByField == null ? void 0 : inputPropsPassedByField.inputProps)
|
|
96
98
|
});
|
|
97
99
|
},
|
|
98
100
|
root: ownerState => {
|
|
@@ -3,7 +3,7 @@ import TextField, { TextFieldProps } from '@mui/material/TextField';
|
|
|
3
3
|
import Stack, { StackProps } from '@mui/material/Stack';
|
|
4
4
|
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
5
5
|
import { SlotComponentProps } from '@mui/base/utils';
|
|
6
|
-
import { DateOrTimeView, UsePickerParams, BaseNextPickerProps, PickersPopperSlotsComponent, PickersPopperSlotsComponentsProps, ExportedPickersViewLayoutSlotsComponent, ExportedPickersViewLayoutSlotsComponentsProps, ExportedBaseToolbarProps, DesktopOnlyPickerProps } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { DateOrTimeView, UsePickerParams, BaseNextPickerProps, PickersPopperSlotsComponent, PickersPopperSlotsComponentsProps, ExportedPickersViewLayoutSlotsComponent, ExportedPickersViewLayoutSlotsComponentsProps, ExportedBaseToolbarProps, DesktopOnlyPickerProps, UsePickerViewsProps } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import { DateRange, RangePositionProps } from '../../models';
|
|
8
8
|
import { BaseMultiInputFieldProps } from '../../models/fields';
|
|
9
9
|
export interface UseDesktopRangePickerSlotsComponent extends PickersPopperSlotsComponent, ExportedPickersViewLayoutSlotsComponent {
|
|
@@ -21,7 +21,7 @@ export interface UseDesktopRangePickerSlotsComponentsProps<TDate, TView extends
|
|
|
21
21
|
}
|
|
22
22
|
export interface DesktopRangeOnlyPickerProps<TDate> extends DesktopOnlyPickerProps<TDate> {
|
|
23
23
|
}
|
|
24
|
-
export interface UseDesktopRangePickerProps<TDate, TView extends DateOrTimeView, TError
|
|
24
|
+
export interface UseDesktopRangePickerProps<TDate, TView extends DateOrTimeView, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends DesktopRangeOnlyPickerProps<TDate>, BaseNextPickerProps<DateRange<TDate>, TDate, TView, TError, TExternalProps, DesktopRangePickerAdditionalViewProps> {
|
|
25
25
|
/**
|
|
26
26
|
* Overrideable components.
|
|
27
27
|
* @default {}
|
|
@@ -33,9 +33,8 @@ export interface UseDesktopRangePickerProps<TDate, TView extends DateOrTimeView,
|
|
|
33
33
|
*/
|
|
34
34
|
componentsProps?: UseDesktopRangePickerSlotsComponentsProps<TDate, TView>;
|
|
35
35
|
}
|
|
36
|
-
interface DesktopRangePickerAdditionalViewProps extends RangePositionProps {
|
|
36
|
+
export interface DesktopRangePickerAdditionalViewProps extends RangePositionProps {
|
|
37
37
|
}
|
|
38
|
-
export interface UseDesktopRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseDesktopRangePickerProps<TDate, TView, any>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, TExternalProps, DesktopRangePickerAdditionalViewProps>, 'valueManager' | '
|
|
38
|
+
export interface UseDesktopRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseDesktopRangePickerProps<TDate, TView, any, TExternalProps>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, TExternalProps, DesktopRangePickerAdditionalViewProps>, 'valueManager' | 'validator'> {
|
|
39
39
|
props: TExternalProps;
|
|
40
40
|
}
|
|
41
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DateOrTimeView } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { UseMobileRangePickerParams, UseMobileRangePickerProps } from './useMobileRangePicker.types';
|
|
4
|
-
export declare const useMobileRangePicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseMobileRangePickerProps<TDate, TView, any>>({ props, valueManager,
|
|
4
|
+
export declare const useMobileRangePicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseMobileRangePickerProps<TDate, TView, any, TExternalProps>>({ props, valueManager, validator, }: UseMobileRangePickerParams<TDate, TView, TExternalProps>) => {
|
|
5
5
|
renderPicker: () => JSX.Element;
|
|
6
6
|
};
|
|
@@ -12,7 +12,6 @@ const releaseInfo = getReleaseInfo();
|
|
|
12
12
|
export const useMobileRangePicker = ({
|
|
13
13
|
props,
|
|
14
14
|
valueManager,
|
|
15
|
-
viewLookup,
|
|
16
15
|
validator
|
|
17
16
|
}) => {
|
|
18
17
|
useLicenseVerifier('x-date-pickers-pro', releaseInfo);
|
|
@@ -38,8 +37,8 @@ export const useMobileRangePicker = ({
|
|
|
38
37
|
props,
|
|
39
38
|
valueManager,
|
|
40
39
|
wrapperVariant: 'mobile',
|
|
41
|
-
viewLookup,
|
|
42
40
|
validator,
|
|
41
|
+
autoFocusView: true,
|
|
43
42
|
additionalViewProps: {
|
|
44
43
|
rangePosition,
|
|
45
44
|
onRangePositionChange: setRangePosition
|
|
@@ -52,6 +51,7 @@ export const useMobileRangePicker = ({
|
|
|
52
51
|
readOnly,
|
|
53
52
|
disabled,
|
|
54
53
|
disableOpenPicker,
|
|
54
|
+
localeText,
|
|
55
55
|
rangePosition,
|
|
56
56
|
onRangePositionChange: setRangePosition
|
|
57
57
|
});
|
|
@@ -60,7 +60,7 @@ export const useMobileRangePicker = ({
|
|
|
60
60
|
elementType: Field,
|
|
61
61
|
externalSlotProps: componentsProps.field,
|
|
62
62
|
additionalProps: _extends({}, pickerFieldProps, {
|
|
63
|
-
readOnly,
|
|
63
|
+
readOnly: readOnly != null ? readOnly : true,
|
|
64
64
|
disabled,
|
|
65
65
|
className,
|
|
66
66
|
format,
|
|
@@ -78,7 +78,7 @@ export const useMobileRangePicker = ({
|
|
|
78
78
|
const inputPropsPassedByField = resolveComponentProps((_fieldProps$component = fieldProps.componentsProps) == null ? void 0 : _fieldProps$component.input, ownerState);
|
|
79
79
|
const inputPropsPassedByPicker = ownerState.position === 'start' ? fieldSlotsProps.startInput : fieldSlotsProps.endInput;
|
|
80
80
|
return _extends({}, externalInputProps, inputPropsPassedByField, inputPropsPassedByPicker, {
|
|
81
|
-
inputProps: _extends({}, externalInputProps == null ? void 0 : externalInputProps.inputProps, inputPropsPassedByField == null ? void 0 : inputPropsPassedByField.inputProps
|
|
81
|
+
inputProps: _extends({}, externalInputProps == null ? void 0 : externalInputProps.inputProps, inputPropsPassedByField == null ? void 0 : inputPropsPassedByField.inputProps)
|
|
82
82
|
});
|
|
83
83
|
},
|
|
84
84
|
root: ownerState => {
|
|
@@ -3,7 +3,7 @@ import TextField, { TextFieldProps } from '@mui/material/TextField';
|
|
|
3
3
|
import Stack, { StackProps } from '@mui/material/Stack';
|
|
4
4
|
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
5
5
|
import { SlotComponentProps } from '@mui/base/utils';
|
|
6
|
-
import { DateOrTimeView, UsePickerParams, BaseNextPickerProps, PickersModalDialogSlotsComponent, PickersModalDialogSlotsComponentsProps, ExportedPickersViewLayoutSlotsComponent, ExportedPickersViewLayoutSlotsComponentsProps, ExportedBaseToolbarProps, MobileOnlyPickerProps } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { DateOrTimeView, UsePickerParams, BaseNextPickerProps, PickersModalDialogSlotsComponent, PickersModalDialogSlotsComponentsProps, ExportedPickersViewLayoutSlotsComponent, ExportedPickersViewLayoutSlotsComponentsProps, ExportedBaseToolbarProps, MobileOnlyPickerProps, UsePickerViewsProps } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import { DateRange, RangePositionProps } from '../../models';
|
|
8
8
|
import { BaseMultiInputFieldProps } from '../../models/fields';
|
|
9
9
|
export interface UseMobileRangePickerSlotsComponent extends PickersModalDialogSlotsComponent, ExportedPickersViewLayoutSlotsComponent {
|
|
@@ -21,7 +21,7 @@ export interface UseMobileRangePickerSlotsComponentsProps<TDate, TView extends D
|
|
|
21
21
|
}
|
|
22
22
|
export interface MobileRangeOnlyPickerProps<TDate> extends MobileOnlyPickerProps<TDate> {
|
|
23
23
|
}
|
|
24
|
-
export interface UseMobileRangePickerProps<TDate, TView extends DateOrTimeView, TError
|
|
24
|
+
export interface UseMobileRangePickerProps<TDate, TView extends DateOrTimeView, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends MobileRangeOnlyPickerProps<TDate>, BaseNextPickerProps<DateRange<TDate>, TDate, TView, TError, TExternalProps, MobileRangePickerAdditionalViewProps> {
|
|
25
25
|
/**
|
|
26
26
|
* Overrideable components.
|
|
27
27
|
* @default {}
|
|
@@ -33,9 +33,8 @@ export interface UseMobileRangePickerProps<TDate, TView extends DateOrTimeView,
|
|
|
33
33
|
*/
|
|
34
34
|
componentsProps?: UseMobileRangePickerSlotsComponentsProps<TDate, TView>;
|
|
35
35
|
}
|
|
36
|
-
interface MobileRangePickerAdditionalViewProps extends RangePositionProps {
|
|
36
|
+
export interface MobileRangePickerAdditionalViewProps extends RangePositionProps {
|
|
37
37
|
}
|
|
38
|
-
export interface UseMobileRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseMobileRangePickerProps<TDate, TView, any>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, TExternalProps, MobileRangePickerAdditionalViewProps>, 'valueManager' | '
|
|
38
|
+
export interface UseMobileRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseMobileRangePickerProps<TDate, TView, any, TExternalProps>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, TExternalProps, MobileRangePickerAdditionalViewProps>, 'valueManager' | 'validator'> {
|
|
39
39
|
props: TExternalProps;
|
|
40
40
|
}
|
|
41
|
-
export {};
|
|
@@ -20,7 +20,9 @@ export const useMultiInputDateRangeField = ({
|
|
|
20
20
|
value: valueProp,
|
|
21
21
|
defaultValue,
|
|
22
22
|
format,
|
|
23
|
-
onChange
|
|
23
|
+
onChange,
|
|
24
|
+
disabled,
|
|
25
|
+
readOnly
|
|
24
26
|
} = sharedProps;
|
|
25
27
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
26
28
|
|
|
@@ -48,6 +50,8 @@ export const useMultiInputDateRangeField = ({
|
|
|
48
50
|
const handleStartDateChange = useEventCallback(buildChangeHandler(0));
|
|
49
51
|
const handleEndDateChange = useEventCallback(buildChangeHandler(1));
|
|
50
52
|
const startInputProps = _extends({}, inStartInputProps, {
|
|
53
|
+
disabled,
|
|
54
|
+
readOnly,
|
|
51
55
|
format,
|
|
52
56
|
value: valueProp === undefined ? undefined : valueProp[0],
|
|
53
57
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
|
|
@@ -55,6 +59,8 @@ export const useMultiInputDateRangeField = ({
|
|
|
55
59
|
});
|
|
56
60
|
const endInputProps = _extends({}, inEndInputProps, {
|
|
57
61
|
format,
|
|
62
|
+
disabled,
|
|
63
|
+
readOnly,
|
|
58
64
|
value: valueProp === undefined ? undefined : valueProp[1],
|
|
59
65
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
|
|
60
66
|
onChange: handleEndDateChange
|
|
@@ -36,7 +36,9 @@ export const useMultiInputDateTimeRangeField = ({
|
|
|
36
36
|
value: valueProp,
|
|
37
37
|
defaultValue,
|
|
38
38
|
format,
|
|
39
|
-
onChange
|
|
39
|
+
onChange,
|
|
40
|
+
disabled,
|
|
41
|
+
readOnly
|
|
40
42
|
} = sharedProps;
|
|
41
43
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
42
44
|
|
|
@@ -65,12 +67,16 @@ export const useMultiInputDateTimeRangeField = ({
|
|
|
65
67
|
const handleEndDateChange = useEventCallback(buildChangeHandler(1));
|
|
66
68
|
const startInputProps = _extends({}, inStartInputProps, {
|
|
67
69
|
format,
|
|
70
|
+
disabled,
|
|
71
|
+
readOnly,
|
|
68
72
|
value: valueProp === undefined ? undefined : valueProp[0],
|
|
69
73
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
|
|
70
74
|
onChange: handleStartDateChange
|
|
71
75
|
});
|
|
72
76
|
const endInputProps = _extends({}, inEndInputProps, {
|
|
73
77
|
format,
|
|
78
|
+
disabled,
|
|
79
|
+
readOnly,
|
|
74
80
|
value: valueProp === undefined ? undefined : valueProp[1],
|
|
75
81
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
|
|
76
82
|
onChange: handleEndDateChange
|
|
@@ -2,8 +2,10 @@ import { UseFieldResponse } from '@mui/x-date-pickers/internals';
|
|
|
2
2
|
export interface UseMultiInputRangeFieldResponse<TChildProps extends {}> {
|
|
3
3
|
startDate: UseFieldResponse<TChildProps> & {
|
|
4
4
|
error: boolean;
|
|
5
|
+
readOnly: boolean;
|
|
5
6
|
};
|
|
6
7
|
endDate: UseFieldResponse<TChildProps> & {
|
|
7
8
|
error: boolean;
|
|
9
|
+
readOnly: boolean;
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -32,7 +32,9 @@ export const useMultiInputTimeRangeField = ({
|
|
|
32
32
|
value: valueProp,
|
|
33
33
|
defaultValue,
|
|
34
34
|
format,
|
|
35
|
-
onChange
|
|
35
|
+
onChange,
|
|
36
|
+
disabled,
|
|
37
|
+
readOnly
|
|
36
38
|
} = sharedProps;
|
|
37
39
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
38
40
|
|
|
@@ -61,12 +63,16 @@ export const useMultiInputTimeRangeField = ({
|
|
|
61
63
|
const handleEndDateChange = useEventCallback(buildChangeHandler(1));
|
|
62
64
|
const startInputProps = _extends({}, inStartInputProps, {
|
|
63
65
|
format,
|
|
66
|
+
disabled,
|
|
67
|
+
readOnly,
|
|
64
68
|
value: valueProp === undefined ? undefined : valueProp[0],
|
|
65
69
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
|
|
66
70
|
onChange: handleStartDateChange
|
|
67
71
|
});
|
|
68
72
|
const endInputProps = _extends({}, inEndInputProps, {
|
|
69
73
|
format,
|
|
74
|
+
disabled,
|
|
75
|
+
readOnly,
|
|
70
76
|
value: valueProp === undefined ? undefined : valueProp[1],
|
|
71
77
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[1],
|
|
72
78
|
onChange: handleEndDateChange
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { PickersInputLocaleText } from '@mui/x-date-pickers';
|
|
2
3
|
import { DateOrTimeView, UsePickerResponse, WrapperVariant } from '@mui/x-date-pickers/internals';
|
|
3
4
|
import { DateRange, RangePosition } from '../models';
|
|
4
5
|
interface UseRangePickerFieldParams<TDate, TView extends DateOrTimeView> extends Pick<UsePickerResponse<DateRange<TDate>, TView, any>, 'open' | 'actions'> {
|
|
@@ -9,12 +10,12 @@ interface UseRangePickerFieldParams<TDate, TView extends DateOrTimeView> extends
|
|
|
9
10
|
onBlur?: () => void;
|
|
10
11
|
rangePosition: RangePosition;
|
|
11
12
|
onRangePositionChange: (newPosition: RangePosition) => void;
|
|
13
|
+
localeText: PickersInputLocaleText<TDate> | undefined;
|
|
12
14
|
}
|
|
13
|
-
export declare const useRangePickerInputProps: <TDate, TView extends DateOrTimeView>({ wrapperVariant, open, actions, readOnly, disabled, disableOpenPicker, onBlur, rangePosition, onRangePositionChange, }: UseRangePickerFieldParams<TDate, TView>) => {
|
|
15
|
+
export declare const useRangePickerInputProps: <TDate, TView extends DateOrTimeView>({ wrapperVariant, open, actions, readOnly, disabled, disableOpenPicker, onBlur, rangePosition, onRangePositionChange, localeText: inLocaleText, }: UseRangePickerFieldParams<TDate, TView>) => {
|
|
14
16
|
startInput: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
disabled: boolean | undefined;
|
|
18
19
|
onClick?: ((event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
19
20
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
20
21
|
label: string;
|
|
@@ -23,9 +24,8 @@ export declare const useRangePickerInputProps: <TDate, TView extends DateOrTimeV
|
|
|
23
24
|
focused: boolean | undefined;
|
|
24
25
|
};
|
|
25
26
|
endInput: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
27
|
+
readOnly: boolean;
|
|
28
|
+
disabled: boolean | undefined;
|
|
29
29
|
onClick?: ((event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
30
30
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
31
31
|
label: string;
|
|
@@ -10,8 +10,10 @@ export const useRangePickerInputProps = ({
|
|
|
10
10
|
disableOpenPicker,
|
|
11
11
|
onBlur,
|
|
12
12
|
rangePosition,
|
|
13
|
-
onRangePositionChange
|
|
13
|
+
onRangePositionChange,
|
|
14
|
+
localeText: inLocaleText
|
|
14
15
|
}) => {
|
|
16
|
+
var _inLocaleText$start, _inLocaleText$end;
|
|
15
17
|
const localeText = useLocaleText();
|
|
16
18
|
const startRef = React.useRef(null);
|
|
17
19
|
const endRef = React.useRef(null);
|
|
@@ -28,14 +30,14 @@ export const useRangePickerInputProps = ({
|
|
|
28
30
|
}
|
|
29
31
|
}, [rangePosition, open]);
|
|
30
32
|
const openRangeStartSelection = event => {
|
|
31
|
-
event
|
|
33
|
+
event.stopPropagation();
|
|
32
34
|
onRangePositionChange('start');
|
|
33
35
|
if (!readOnly && !disableOpenPicker) {
|
|
34
36
|
actions.onOpen();
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
const openRangeEndSelection = event => {
|
|
38
|
-
event
|
|
40
|
+
event.stopPropagation();
|
|
39
41
|
onRangePositionChange('end');
|
|
40
42
|
if (!readOnly && !disableOpenPicker) {
|
|
41
43
|
actions.onOpen();
|
|
@@ -51,31 +53,30 @@ export const useRangePickerInputProps = ({
|
|
|
51
53
|
onRangePositionChange('end');
|
|
52
54
|
}
|
|
53
55
|
};
|
|
56
|
+
const readOnlyInput = readOnly != null ? readOnly : wrapperVariant === 'mobile';
|
|
54
57
|
const startInputProps = _extends({
|
|
55
58
|
inputRef: startRef,
|
|
56
|
-
label: localeText.start,
|
|
59
|
+
label: (_inLocaleText$start = inLocaleText == null ? void 0 : inLocaleText.start) != null ? _inLocaleText$start : localeText.start,
|
|
57
60
|
onKeyDown: onSpaceOrEnter(openRangeStartSelection),
|
|
58
61
|
onFocus: focusOnRangeStart,
|
|
59
62
|
focused: open ? rangePosition === 'start' : undefined
|
|
60
63
|
}, !readOnly && !disabled && {
|
|
61
64
|
onClick: openRangeStartSelection
|
|
62
65
|
}, {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
+
readOnly: readOnlyInput,
|
|
67
|
+
disabled
|
|
66
68
|
});
|
|
67
69
|
const endInputProps = _extends({
|
|
68
70
|
inputRef: endRef,
|
|
69
|
-
label: localeText.end,
|
|
71
|
+
label: (_inLocaleText$end = inLocaleText == null ? void 0 : inLocaleText.end) != null ? _inLocaleText$end : localeText.end,
|
|
70
72
|
onKeyDown: onSpaceOrEnter(openRangeEndSelection),
|
|
71
73
|
onFocus: focusOnRangeEnd,
|
|
72
74
|
focused: open ? rangePosition === 'end' : undefined
|
|
73
75
|
}, !readOnly && !disabled && {
|
|
74
76
|
onClick: openRangeEndSelection
|
|
75
77
|
}, {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
78
|
+
readOnly: readOnlyInput,
|
|
79
|
+
disabled
|
|
79
80
|
});
|
|
80
81
|
const rootProps = {
|
|
81
82
|
onBlur
|
|
@@ -5,6 +5,6 @@ import { UseStaticRangePickerParams, UseStaticRangePickerProps } from './useStat
|
|
|
5
5
|
* Hook managing all the range static pickers:
|
|
6
6
|
* - StaticDateRangePicker
|
|
7
7
|
*/
|
|
8
|
-
export declare const useStaticRangePicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticRangePickerProps<TDate, TView, any>>({ props, valueManager,
|
|
8
|
+
export declare const useStaticRangePicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticRangePickerProps<TDate, TView, any, TExternalProps>>({ props, valueManager, validator, ref, }: UseStaticRangePickerParams<TDate, TView, TExternalProps>) => {
|
|
9
9
|
renderPicker: () => JSX.Element;
|
|
10
10
|
};
|
|
@@ -19,7 +19,6 @@ const PickerStaticViewLayout = styled(PickersViewLayout)(({
|
|
|
19
19
|
export const useStaticRangePicker = ({
|
|
20
20
|
props,
|
|
21
21
|
valueManager,
|
|
22
|
-
viewLookup,
|
|
23
22
|
validator,
|
|
24
23
|
ref
|
|
25
24
|
}) => {
|
|
@@ -27,7 +26,8 @@ export const useStaticRangePicker = ({
|
|
|
27
26
|
localeText,
|
|
28
27
|
components,
|
|
29
28
|
componentsProps,
|
|
30
|
-
displayStaticWrapperAs
|
|
29
|
+
displayStaticWrapperAs,
|
|
30
|
+
autoFocus
|
|
31
31
|
} = props;
|
|
32
32
|
const [rangePosition, setRangePosition] = React.useState('start');
|
|
33
33
|
const {
|
|
@@ -35,9 +35,9 @@ export const useStaticRangePicker = ({
|
|
|
35
35
|
renderCurrentView
|
|
36
36
|
} = usePicker({
|
|
37
37
|
props,
|
|
38
|
-
viewLookup,
|
|
39
38
|
valueManager,
|
|
40
39
|
validator,
|
|
40
|
+
autoFocusView: autoFocus != null ? autoFocus : false,
|
|
41
41
|
additionalViewProps: {},
|
|
42
42
|
wrapperVariant: displayStaticWrapperAs
|
|
43
43
|
});
|
|
@@ -8,7 +8,7 @@ export interface UseStaticRangePickerSlotsComponentsProps<TDate, TView extends D
|
|
|
8
8
|
}
|
|
9
9
|
export interface StaticRangeOnlyPickerProps extends StaticOnlyPickerProps {
|
|
10
10
|
}
|
|
11
|
-
export interface UseStaticRangePickerProps<TDate, TView extends DateOrTimeView, TError
|
|
11
|
+
export interface UseStaticRangePickerProps<TDate, TView extends DateOrTimeView, TError, TExternalProps extends UseStaticRangePickerProps<TDate, TView, any, TExternalProps>> extends BaseNextPickerProps<DateRange<TDate>, TDate, TView, TError, TExternalProps, {}>, StaticRangeOnlyPickerProps {
|
|
12
12
|
/**
|
|
13
13
|
* Overrideable components.
|
|
14
14
|
* @default {}
|
|
@@ -20,7 +20,7 @@ export interface UseStaticRangePickerProps<TDate, TView extends DateOrTimeView,
|
|
|
20
20
|
*/
|
|
21
21
|
componentsProps?: UseStaticRangePickerSlotsComponentsProps<TDate, TView>;
|
|
22
22
|
}
|
|
23
|
-
export interface UseStaticRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticRangePickerProps<TDate, TView, any>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, TExternalProps, {}>, 'valueManager' | '
|
|
23
|
+
export interface UseStaticRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseStaticRangePickerProps<TDate, TView, any, TExternalProps>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, TExternalProps, {}>, 'valueManager' | 'validator'> {
|
|
24
24
|
props: TExternalProps;
|
|
25
25
|
/**
|
|
26
26
|
* Ref to pass to the root element
|
|
@@ -14,6 +14,16 @@ export interface DayRangeValidationProps<TDate> {
|
|
|
14
14
|
*/
|
|
15
15
|
shouldDisableDate?: (day: TDate, position: 'start' | 'end') => boolean;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Props used in every range picker.
|
|
19
|
+
*/
|
|
20
|
+
export interface BaseRangeProps {
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, the component is disabled.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface UseDateRangeFieldProps<TDate> extends MakeOptional<UseFieldInternalProps<DateRange<TDate>, DateRangeValidationError>, 'format'>, DayRangeValidationProps<TDate>, BaseDateValidationProps<TDate>, BaseRangeProps {
|
|
18
28
|
}
|
|
19
29
|
export type UseDateRangeFieldDefaultizedProps<TDate> = DefaultizedProps<UseDateRangeFieldProps<TDate>, keyof BaseDateValidationProps<TDate> | 'format'>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseDateValidationProps, TimeValidationProps, DefaultizedProps, MakeOptional, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { DayRangeValidationProps } from './dateRange';
|
|
2
|
+
import { BaseRangeProps, DayRangeValidationProps } from './dateRange';
|
|
3
3
|
import { DateRange } from './range';
|
|
4
4
|
import { DateTimeRangeValidationError } from '../hooks/validation/useDateTimeRangeValidation';
|
|
5
|
-
export interface UseDateTimeRangeFieldProps<TDate> extends MakeOptional<UseFieldInternalProps<DateRange<TDate>, DateTimeRangeValidationError>, 'format'>, DayRangeValidationProps<TDate>, TimeValidationProps<TDate>, BaseDateValidationProps<TDate
|
|
5
|
+
export interface UseDateTimeRangeFieldProps<TDate> extends MakeOptional<UseFieldInternalProps<DateRange<TDate>, DateTimeRangeValidationError>, 'format'>, DayRangeValidationProps<TDate>, TimeValidationProps<TDate>, BaseDateValidationProps<TDate>, BaseRangeProps {
|
|
6
6
|
/**
|
|
7
7
|
* Minimal selectable moment of time with binding to date, to set min time in each day use `minTime`.
|
|
8
8
|
*/
|
|
@@ -3,7 +3,12 @@ import { SlotComponentProps } from '@mui/base/utils';
|
|
|
3
3
|
import TextField, { TextFieldProps } from '@mui/material/TextField';
|
|
4
4
|
import Stack, { StackProps } from '@mui/material/Stack';
|
|
5
5
|
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
6
|
-
import { BaseFieldProps } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { BaseFieldProps, FieldSection } from '@mui/x-date-pickers/internals';
|
|
7
|
+
export interface RangeFieldSection extends FieldSection {
|
|
8
|
+
dateName: 'start' | 'end';
|
|
9
|
+
}
|
|
10
|
+
export interface RangeFieldSectionWithoutPosition extends Omit<RangeFieldSection, 'start' | 'end' | 'startInInput' | 'endInInput'> {
|
|
11
|
+
}
|
|
7
12
|
export interface BaseMultiInputFieldProps<TValue, TError> extends Omit<BaseFieldProps<TValue, TError>, 'components' | 'componentsProps'> {
|
|
8
13
|
components?: {
|
|
9
14
|
Root?: React.ElementType<StackProps>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FieldSection } from '@mui/x-date-pickers/internals';
|
|
2
1
|
export type DateRange<TDate> = [TDate | null, TDate | null];
|
|
3
2
|
export type NonEmptyDateRange<TDate> = [TDate, TDate];
|
|
4
3
|
export type RangePosition = 'start' | 'end';
|
|
@@ -6,6 +5,3 @@ export interface RangePositionProps {
|
|
|
6
5
|
rangePosition: RangePosition;
|
|
7
6
|
onRangePositionChange: (newPosition: RangePosition) => void;
|
|
8
7
|
}
|
|
9
|
-
export interface DateRangeFieldSection extends FieldSection {
|
|
10
|
-
dateName: 'start' | 'end';
|
|
11
|
-
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseTimeValidationProps, TimeValidationProps, DefaultizedProps, MakeOptional, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { DateRange } from './range';
|
|
3
3
|
import { TimeRangeValidationError } from '../hooks/validation/useTimeRangeValidation';
|
|
4
|
-
|
|
4
|
+
import { BaseRangeProps } from './dateRange';
|
|
5
|
+
export interface UseTimeRangeFieldProps<TDate> extends MakeOptional<UseFieldInternalProps<DateRange<TDate>, TimeRangeValidationError>, 'format'>, TimeValidationProps<TDate>, BaseTimeValidationProps, BaseRangeProps {
|
|
5
6
|
/**
|
|
6
7
|
* 12h/24h view for hour selection clock.
|
|
7
8
|
* @default `utils.is12HourCycleInCurrentLocale()`
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const splitDateRangeSections: (sections:
|
|
3
|
-
startDate:
|
|
4
|
-
endDate:
|
|
1
|
+
import { RangeFieldSection } from '../models/fields';
|
|
2
|
+
export declare const splitDateRangeSections: (sections: RangeFieldSection[]) => {
|
|
3
|
+
startDate: RangeFieldSection[];
|
|
4
|
+
endDate: RangeFieldSection[];
|
|
5
5
|
};
|
|
6
|
-
export declare const removeLastSeparator: (dateSections:
|
|
6
|
+
export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
|
|
7
|
+
separator: null;
|
|
8
|
+
dateName: "start" | "end";
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
startInInput: number;
|
|
12
|
+
endInInput: number;
|
|
13
|
+
value: string;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
startSeparator: string;
|
|
16
|
+
endSeparator: string;
|
|
17
|
+
dateSectionName: import("@mui/x-date-pickers").MuiDateSectionName;
|
|
18
|
+
contentType: "digit" | "letter";
|
|
19
|
+
formatValue: string;
|
|
20
|
+
edited: boolean;
|
|
21
|
+
hasTrailingZeroes: boolean;
|
|
22
|
+
})[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY3MTgzMjgwMDAwMA==";
|
|
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
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PickerStateValueManager, FieldValueManager } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { DateRange
|
|
2
|
+
import { DateRange } from '../models/range';
|
|
3
3
|
import type { DateRangeValidationError } from '../hooks/validation/useDateRangeValidation';
|
|
4
4
|
import type { TimeRangeValidationError } from '../hooks/validation/useTimeRangeValidation';
|
|
5
5
|
import type { DateTimeRangeValidationError } from '../hooks/validation/useDateTimeRangeValidation';
|
|
6
|
+
import { RangeFieldSection } from '../models/fields';
|
|
6
7
|
export type RangePickerStateValueManager<TValue = [any, any], TDate = any, TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerStateValueManager<TValue, TDate, TError>;
|
|
7
8
|
export declare const rangeValueManager: RangePickerStateValueManager;
|
|
8
|
-
export declare const rangeFieldValueManager: FieldValueManager<DateRange<any>, any,
|
|
9
|
+
export declare const rangeFieldValueManager: FieldValueManager<DateRange<any>, any, RangeFieldSection, DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections,
|
|
2
|
+
import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections, getSectionOrder } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
|
|
4
4
|
export const rangeValueManager = {
|
|
5
5
|
emptyValue: [null, null],
|
|
@@ -29,36 +29,29 @@ export const rangeFieldValueManager = {
|
|
|
29
29
|
startDate: null,
|
|
30
30
|
endDate: null
|
|
31
31
|
} : splitDateRangeSections(prevSections);
|
|
32
|
-
const getSections = (newDate, prevDateSections) => {
|
|
32
|
+
const getSections = (newDate, prevDateSections, position) => {
|
|
33
33
|
const shouldReUsePrevDateSections = !utils.isValid(newDate) && !!prevDateSections;
|
|
34
34
|
if (shouldReUsePrevDateSections) {
|
|
35
35
|
return prevDateSections;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const sections = splitFormatIntoSections(utils, localeText, format, newDate);
|
|
38
|
+
return sections.map((section, sectionIndex) => {
|
|
39
|
+
if (sectionIndex === sections.length - 1 && position === 'start') {
|
|
40
|
+
return _extends({}, section, {
|
|
41
|
+
dateName: position,
|
|
42
|
+
endSeparator: `${section.endSeparator}\u2069 – \u2066`
|
|
43
|
+
});
|
|
44
|
+
}
|
|
43
45
|
return _extends({}, section, {
|
|
44
|
-
dateName:
|
|
45
|
-
separator: ' – '
|
|
46
|
+
dateName: position
|
|
46
47
|
});
|
|
47
|
-
}
|
|
48
|
-
return _extends({}, section, {
|
|
49
|
-
dateName: 'start'
|
|
50
48
|
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
dateName: 'end'
|
|
54
|
-
}));
|
|
55
|
-
return addPositionPropertiesToSections([...sectionsOfStartDate, ...sectionsOfEndDate]);
|
|
49
|
+
};
|
|
50
|
+
return addPositionPropertiesToSections([...getSections(start, prevDateRangeSections.startDate, 'start'), ...getSections(end, prevDateRangeSections.endDate, 'end')]);
|
|
56
51
|
},
|
|
57
52
|
getValueStrFromSections: sections => {
|
|
58
53
|
const dateRangeSections = splitDateRangeSections(sections);
|
|
59
|
-
|
|
60
|
-
const endDateStr = createDateStrFromSections(dateRangeSections.endDate, true);
|
|
61
|
-
return `${startDateStr}${endDateStr}`;
|
|
54
|
+
return createDateStrForInputFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate]);
|
|
62
55
|
},
|
|
63
56
|
getActiveDateSections: (sections, activeSection) => {
|
|
64
57
|
const index = activeSection.dateName === 'start' ? 0 : 1;
|
|
@@ -87,5 +80,11 @@ export const rangeFieldValueManager = {
|
|
|
87
80
|
})
|
|
88
81
|
};
|
|
89
82
|
},
|
|
90
|
-
hasError: error => error[0] != null || error[1] != null
|
|
83
|
+
hasError: error => error[0] != null || error[1] != null,
|
|
84
|
+
getSectionOrder: (utils, localeText, format, isRTL) => {
|
|
85
|
+
const splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
|
|
86
|
+
return getSectionOrder([...splitedFormat.slice(0, splitedFormat.length - 1), _extends({}, splitedFormat[splitedFormat.length - 1], {
|
|
87
|
+
endSeparator: ' – '
|
|
88
|
+
}), ...splitedFormat], isRTL);
|
|
89
|
+
}
|
|
91
90
|
};
|