@mui/x-date-pickers-pro 6.2.0 → 6.3.0
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 +118 -1
- package/DateRangePicker/shared.d.ts +1 -1
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/README.md +0 -9
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
- package/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -2
- package/index.d.ts +1 -3
- package/index.js +3 -2
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +2 -2
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -9
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +5 -5
- package/internal/hooks/useEnrichedRangePickerFieldProps.d.ts +4 -3
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +2 -2
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -9
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +5 -5
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +4 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +4 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +4 -1
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +2 -2
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -10
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +5 -5
- package/internal/models/dateRange.d.ts +1 -1
- package/internal/models/dateTimeRange.d.ts +1 -1
- package/internal/models/timeRange.d.ts +1 -1
- package/internal/utils/date-fields-utils.d.ts +4 -1
- package/internal/utils/releaseInfo.js +1 -1
- package/internal/{hooks/validation/useDateRangeValidation.d.ts → utils/validation/validateDateRange.d.ts} +1 -7
- package/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/internal/utils/validation/validateDateTimeRange.d.ts +7 -0
- package/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +2 -6
- package/internal/utils/validation/validateTimeRange.d.ts +6 -0
- package/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +2 -6
- package/internal/utils/valueManagers.d.ts +1 -3
- package/internal/utils/valueManagers.js +1 -1
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/legacy/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/legacy/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/legacy/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
- package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/legacy/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
- package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/legacy/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/legacy/index.js +3 -2
- package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +5 -6
- package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +5 -6
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +4 -1
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +4 -1
- package/legacy/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +4 -1
- package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +6 -7
- package/legacy/internal/utils/releaseInfo.js +1 -1
- package/legacy/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/legacy/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +2 -6
- package/legacy/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +2 -6
- package/legacy/internal/utils/valueManagers.js +2 -2
- package/legacy/models/index.js +1 -0
- package/legacy/models/validation.js +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/package.json +6 -0
- package/models/validation.d.ts +9 -0
- package/models/validation.js +1 -0
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +4 -2
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +4 -2
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +4 -2
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/modern/index.js +3 -2
- package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -9
- package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -9
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +4 -1
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +4 -1
- package/modern/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +4 -1
- package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -10
- package/modern/internal/utils/releaseInfo.js +1 -1
- package/modern/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/modern/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +2 -6
- package/modern/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +2 -6
- package/modern/internal/utils/valueManagers.js +1 -1
- package/modern/models/index.js +1 -0
- package/modern/models/validation.js +1 -0
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +3 -2
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +3 -2
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +26 -4
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +27 -4
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +27 -4
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +20 -3
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +5 -3
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +21 -3
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +5 -3
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +21 -3
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +5 -3
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +3 -2
- package/node/index.js +13 -1
- package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -9
- package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -9
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +6 -3
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +6 -3
- package/node/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +6 -3
- package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -10
- package/node/internal/utils/releaseInfo.js +1 -1
- package/node/internal/{hooks/validation/useDateRangeValidation.js → utils/validation/validateDateRange.js} +1 -1
- package/node/internal/{hooks/validation/useDateTimeRangeValidation.js → utils/validation/validateDateTimeRange.js} +3 -8
- package/node/internal/{hooks/validation/useTimeRangeValidation.js → utils/validation/validateTimeRange.js} +3 -8
- package/node/internal/utils/valueManagers.js +1 -1
- package/node/models/index.js +16 -0
- package/node/models/validation.js +5 -0
- package/package.json +4 -7
- package/internal/hooks/validation/useDateTimeRangeValidation.d.ts +0 -14
- package/internal/hooks/validation/useTimeRangeValidation.d.ts +0 -13
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["props"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { useSlotProps } from '@mui/base/utils';
|
|
4
6
|
import { useLicenseVerifier } from '@mui/x-license-pro';
|
|
@@ -15,8 +17,7 @@ var releaseInfo = getReleaseInfo();
|
|
|
15
17
|
export var useMobileRangePicker = function useMobileRangePicker(_ref) {
|
|
16
18
|
var _fieldType, _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$layout;
|
|
17
19
|
var props = _ref.props,
|
|
18
|
-
|
|
19
|
-
validator = _ref.validator;
|
|
20
|
+
pickerParams = _objectWithoutProperties(_ref, _excluded);
|
|
20
21
|
useLicenseVerifier('x-date-pickers-pro', releaseInfo);
|
|
21
22
|
var slots = props.slots,
|
|
22
23
|
innerSlotProps = props.slotProps,
|
|
@@ -36,17 +37,15 @@ export var useMobileRangePicker = function useMobileRangePicker(_ref) {
|
|
|
36
37
|
singleInputFieldRef = _useRangePosition.singleInputFieldRef;
|
|
37
38
|
var labelId = useId();
|
|
38
39
|
var contextLocaleText = useLocaleText();
|
|
39
|
-
var _usePicker = usePicker({
|
|
40
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
40
41
|
props: props,
|
|
41
|
-
valueManager: valueManager,
|
|
42
42
|
wrapperVariant: 'mobile',
|
|
43
|
-
validator: validator,
|
|
44
43
|
autoFocusView: true,
|
|
45
44
|
additionalViewProps: {
|
|
46
45
|
rangePosition: rangePosition,
|
|
47
46
|
onRangePositionChange: onRangePositionChange
|
|
48
47
|
}
|
|
49
|
-
}),
|
|
48
|
+
})),
|
|
50
49
|
open = _usePicker.open,
|
|
51
50
|
actions = _usePicker.actions,
|
|
52
51
|
layoutProps = _usePicker.layoutProps,
|
|
@@ -6,7 +6,7 @@ import { unstable_useDateField as useDateField } from '@mui/x-date-pickers/DateF
|
|
|
6
6
|
import { useLocalizationContext, useValidation } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import useControlled from '@mui/utils/useControlled';
|
|
8
8
|
import { useDefaultizedDateRangeFieldProps } from '../../../SingleInputDateRangeField/useSingleInputDateRangeField';
|
|
9
|
-
import { validateDateRange } from '
|
|
9
|
+
import { validateDateRange } from '../../utils/validation/validateDateRange';
|
|
10
10
|
import { rangeValueManager } from '../../utils/valueManagers';
|
|
11
11
|
export var useMultiInputDateRangeField = function useMultiInputDateRangeField(_ref) {
|
|
12
12
|
var _firstDefaultValue$cu;
|
|
@@ -23,6 +23,7 @@ export var useMultiInputDateRangeField = function useMultiInputDateRangeField(_r
|
|
|
23
23
|
defaultValue = sharedProps.defaultValue,
|
|
24
24
|
format = sharedProps.format,
|
|
25
25
|
formatDensity = sharedProps.formatDensity,
|
|
26
|
+
shouldRespectLeadingZeros = sharedProps.shouldRespectLeadingZeros,
|
|
26
27
|
onChange = sharedProps.onChange,
|
|
27
28
|
disabled = sharedProps.disabled,
|
|
28
29
|
readOnly = sharedProps.readOnly,
|
|
@@ -66,6 +67,7 @@ export var useMultiInputDateRangeField = function useMultiInputDateRangeField(_r
|
|
|
66
67
|
readOnly: readOnly,
|
|
67
68
|
format: format,
|
|
68
69
|
formatDensity: formatDensity,
|
|
70
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
69
71
|
unstableFieldRef: unstableStartFieldRef,
|
|
70
72
|
value: valueProp === undefined ? undefined : valueProp[0],
|
|
71
73
|
defaultValue: defaultValue === undefined ? undefined : defaultValue[0],
|
|
@@ -78,6 +80,7 @@ export var useMultiInputDateRangeField = function useMultiInputDateRangeField(_r
|
|
|
78
80
|
}, endTextFieldProps, {
|
|
79
81
|
format: format,
|
|
80
82
|
formatDensity: formatDensity,
|
|
83
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
81
84
|
disabled: disabled,
|
|
82
85
|
readOnly: readOnly,
|
|
83
86
|
unstableFieldRef: unstableEndFieldRef,
|
|
@@ -5,7 +5,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
5
5
|
import { unstable_useDateTimeField as useDateTimeField } from '@mui/x-date-pickers/DateTimeField';
|
|
6
6
|
import { applyDefaultDate, useDefaultDates, useLocalizationContext, useUtils, useValidation } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import useControlled from '@mui/utils/useControlled';
|
|
8
|
-
import { validateDateTimeRange } from '
|
|
8
|
+
import { validateDateTimeRange } from '../../utils/validation/validateDateTimeRange';
|
|
9
9
|
import { rangeValueManager } from '../../utils/valueManagers';
|
|
10
10
|
export var useDefaultizedDateTimeRangeFieldProps = function useDefaultizedDateTimeRangeFieldProps(props) {
|
|
11
11
|
var _props$ampm, _props$disablePast, _props$disableFuture, _props$format, _props$minDateTime, _props$maxDateTime, _props$minDateTime2, _props$maxDateTime2;
|
|
@@ -38,6 +38,7 @@ export var useMultiInputDateTimeRangeField = function useMultiInputDateTimeRange
|
|
|
38
38
|
var valueProp = sharedProps.value,
|
|
39
39
|
defaultValue = sharedProps.defaultValue,
|
|
40
40
|
format = sharedProps.format,
|
|
41
|
+
shouldRespectLeadingZeros = sharedProps.shouldRespectLeadingZeros,
|
|
41
42
|
onChange = sharedProps.onChange,
|
|
42
43
|
disabled = sharedProps.disabled,
|
|
43
44
|
readOnly = sharedProps.readOnly;
|
|
@@ -76,6 +77,7 @@ export var useMultiInputDateTimeRangeField = function useMultiInputDateTimeRange
|
|
|
76
77
|
error: !!validationError[0]
|
|
77
78
|
}, startTextFieldProps, {
|
|
78
79
|
format: format,
|
|
80
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
79
81
|
disabled: disabled,
|
|
80
82
|
readOnly: readOnly,
|
|
81
83
|
unstableFieldRef: unstableStartFieldRef,
|
|
@@ -87,6 +89,7 @@ export var useMultiInputDateTimeRangeField = function useMultiInputDateTimeRange
|
|
|
87
89
|
error: !!validationError[1]
|
|
88
90
|
}, endTextFieldProps, {
|
|
89
91
|
format: format,
|
|
92
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
90
93
|
disabled: disabled,
|
|
91
94
|
readOnly: readOnly,
|
|
92
95
|
unstableFieldRef: unstableEndFieldRef,
|
|
@@ -5,7 +5,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
5
5
|
import { unstable_useTimeField as useTimeField } from '@mui/x-date-pickers/TimeField';
|
|
6
6
|
import { useLocalizationContext, useUtils, useValidation } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import useControlled from '@mui/utils/useControlled';
|
|
8
|
-
import { validateTimeRange } from '
|
|
8
|
+
import { validateTimeRange } from '../../utils/validation/validateTimeRange';
|
|
9
9
|
import { rangeValueManager } from '../../utils/valueManagers';
|
|
10
10
|
export var useDefaultizedTimeRangeFieldProps = function useDefaultizedTimeRangeFieldProps(props) {
|
|
11
11
|
var _props$ampm, _props$disablePast, _props$disableFuture, _props$format;
|
|
@@ -32,6 +32,7 @@ export var useMultiInputTimeRangeField = function useMultiInputTimeRangeField(_r
|
|
|
32
32
|
var valueProp = sharedProps.value,
|
|
33
33
|
defaultValue = sharedProps.defaultValue,
|
|
34
34
|
format = sharedProps.format,
|
|
35
|
+
shouldRespectLeadingZeros = sharedProps.shouldRespectLeadingZeros,
|
|
35
36
|
onChange = sharedProps.onChange,
|
|
36
37
|
disabled = sharedProps.disabled,
|
|
37
38
|
readOnly = sharedProps.readOnly;
|
|
@@ -70,6 +71,7 @@ export var useMultiInputTimeRangeField = function useMultiInputTimeRangeField(_r
|
|
|
70
71
|
error: !!validationError[0]
|
|
71
72
|
}, startTextFieldProps, {
|
|
72
73
|
format: format,
|
|
74
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
73
75
|
disabled: disabled,
|
|
74
76
|
readOnly: readOnly,
|
|
75
77
|
unstableFieldRef: unstableStartFieldRef,
|
|
@@ -81,6 +83,7 @@ export var useMultiInputTimeRangeField = function useMultiInputTimeRangeField(_r
|
|
|
81
83
|
error: !!validationError[1]
|
|
82
84
|
}, endTextFieldProps, {
|
|
83
85
|
format: format,
|
|
86
|
+
shouldRespectLeadingZeros: shouldRespectLeadingZeros,
|
|
84
87
|
disabled: disabled,
|
|
85
88
|
readOnly: readOnly,
|
|
86
89
|
unstableFieldRef: unstableEndFieldRef,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["props", "ref"];
|
|
3
5
|
import * as React from 'react';
|
|
4
6
|
import clsx from 'clsx';
|
|
5
7
|
import { styled } from '@mui/material/styles';
|
|
@@ -24,9 +26,8 @@ var PickerStaticLayout = styled(PickersLayout)(function (_ref) {
|
|
|
24
26
|
export var useStaticRangePicker = function useStaticRangePicker(_ref2) {
|
|
25
27
|
var _slots$layout;
|
|
26
28
|
var props = _ref2.props,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ref = _ref2.ref;
|
|
29
|
+
ref = _ref2.ref,
|
|
30
|
+
pickerParams = _objectWithoutProperties(_ref2, _excluded);
|
|
30
31
|
var localeText = props.localeText,
|
|
31
32
|
slots = props.slots,
|
|
32
33
|
slotProps = props.slotProps,
|
|
@@ -37,17 +38,15 @@ export var useStaticRangePicker = function useStaticRangePicker(_ref2) {
|
|
|
37
38
|
var _useRangePosition = useRangePosition(props),
|
|
38
39
|
rangePosition = _useRangePosition.rangePosition,
|
|
39
40
|
onRangePositionChange = _useRangePosition.onRangePositionChange;
|
|
40
|
-
var _usePicker = usePicker({
|
|
41
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
41
42
|
props: props,
|
|
42
|
-
valueManager: valueManager,
|
|
43
|
-
validator: validator,
|
|
44
43
|
autoFocusView: autoFocus != null ? autoFocus : false,
|
|
45
44
|
additionalViewProps: {
|
|
46
45
|
rangePosition: rangePosition,
|
|
47
46
|
onRangePositionChange: onRangePositionChange
|
|
48
47
|
},
|
|
49
48
|
wrapperVariant: displayStaticWrapperAs
|
|
50
|
-
}),
|
|
49
|
+
})),
|
|
51
50
|
layoutProps = _usePicker.layoutProps,
|
|
52
51
|
renderCurrentView = _usePicker.renderCurrentView;
|
|
53
52
|
var Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickerStaticLayout;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export var getReleaseInfo = function getReleaseInfo() {
|
|
3
|
-
var releaseInfo = "
|
|
3
|
+
var releaseInfo = "MTY4MjYyOTIwMDAwMA==";
|
|
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
|
|
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
var _excluded = ["shouldDisableDate"];
|
|
5
5
|
import { validateDate } from '@mui/x-date-pickers/internals';
|
|
6
|
-
import { isRangeValid } from '
|
|
6
|
+
import { isRangeValid } from '../date-utils';
|
|
7
7
|
export var validateDateRange = function validateDateRange(_ref) {
|
|
8
8
|
var props = _ref.props,
|
|
9
9
|
value = _ref.value,
|
|
@@ -2,9 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
var _excluded = ["shouldDisableDate"];
|
|
5
|
-
import {
|
|
6
|
-
import { isRangeValid } from '
|
|
7
|
-
import { rangeValueManager } from '../../utils/valueManagers';
|
|
5
|
+
import { validateDateTime } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { isRangeValid } from '../date-utils';
|
|
8
7
|
export var validateDateTimeRange = function validateDateTimeRange(_ref) {
|
|
9
8
|
var props = _ref.props,
|
|
10
9
|
value = _ref.value,
|
|
@@ -43,7 +42,4 @@ export var validateDateTimeRange = function validateDateTimeRange(_ref) {
|
|
|
43
42
|
return ['invalidRange', 'invalidRange'];
|
|
44
43
|
}
|
|
45
44
|
return [null, null];
|
|
46
|
-
};
|
|
47
|
-
export var useDateRangeValidation = function useDateRangeValidation(props) {
|
|
48
|
-
return useValidation(props, validateDateTimeRange, rangeValueManager.isSameError, rangeValueManager.defaultErrorState);
|
|
49
45
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import {
|
|
3
|
-
import { isRangeValid } from '
|
|
4
|
-
import { rangeValueManager } from '../../utils/valueManagers';
|
|
2
|
+
import { validateTime } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { isRangeValid } from '../date-utils';
|
|
5
4
|
export var validateTimeRange = function validateTimeRange(_ref) {
|
|
6
5
|
var props = _ref.props,
|
|
7
6
|
value = _ref.value,
|
|
@@ -30,7 +29,4 @@ export var validateTimeRange = function validateTimeRange(_ref) {
|
|
|
30
29
|
return ['invalidRange', 'invalidRange'];
|
|
31
30
|
}
|
|
32
31
|
return [null, null];
|
|
33
|
-
};
|
|
34
|
-
export var useDateRangeValidation = function useDateRangeValidation(props) {
|
|
35
|
-
return useValidation(props, validateTimeRange, rangeValueManager.isSameError, rangeValueManager.defaultErrorState);
|
|
36
32
|
};
|
|
@@ -5,8 +5,8 @@ import { replaceInvalidDateByNull, addPositionPropertiesToSections, createDateSt
|
|
|
5
5
|
import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
|
|
6
6
|
export var rangeValueManager = {
|
|
7
7
|
emptyValue: [null, null],
|
|
8
|
-
getTodayValue: function getTodayValue(utils) {
|
|
9
|
-
return [utils.date(), utils.date()];
|
|
8
|
+
getTodayValue: function getTodayValue(utils, valueType) {
|
|
9
|
+
return valueType === 'date' ? [utils.startOfDay(utils.date()), utils.startOfDay(utils.date())] : [utils.date(), utils.date()];
|
|
10
10
|
},
|
|
11
11
|
cleanValue: function cleanValue(utils, value) {
|
|
12
12
|
return value.map(function (date) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validation';
|
package/models/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validation';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DateTimeValidationError, DateValidationError, TimeValidationError } from '@mui/x-date-pickers/models';
|
|
2
|
+
type RangeValidation<ItemError extends string | null> = [
|
|
3
|
+
ItemError | 'invalidRange',
|
|
4
|
+
ItemError | 'invalidRange'
|
|
5
|
+
];
|
|
6
|
+
export type DateRangeValidationError = RangeValidation<DateValidationError>;
|
|
7
|
+
export type TimeRangeValidationError = RangeValidation<TimeValidationError>;
|
|
8
|
+
export type DateTimeRangeValidationError = RangeValidation<DateTimeValidationError>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,7 +8,7 @@ import { useDateRangePickerDefaultizedProps } from '../DateRangePicker/shared';
|
|
|
8
8
|
import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
|
|
9
9
|
import { MultiInputDateRangeField } from '../MultiInputDateRangeField';
|
|
10
10
|
import { useDesktopRangePicker } from '../internal/hooks/useDesktopRangePicker';
|
|
11
|
-
import { validateDateRange } from '../internal/
|
|
11
|
+
import { validateDateRange } from '../internal/utils/validation/validateDateRange';
|
|
12
12
|
const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateRangePicker(inProps, ref) {
|
|
13
13
|
// Props with the default values common to all date time pickers
|
|
14
14
|
const defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiDesktopDateRangePicker');
|
|
@@ -37,6 +37,7 @@ const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDat
|
|
|
37
37
|
} = useDesktopRangePicker({
|
|
38
38
|
props,
|
|
39
39
|
valueManager: rangeValueManager,
|
|
40
|
+
valueType: 'date',
|
|
40
41
|
validator: validateDateRange
|
|
41
42
|
});
|
|
42
43
|
return renderPicker();
|
|
@@ -10,7 +10,7 @@ import { useDateRangePickerDefaultizedProps } from '../DateRangePicker/shared';
|
|
|
10
10
|
import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
|
|
11
11
|
import { MultiInputDateRangeField } from '../MultiInputDateRangeField';
|
|
12
12
|
import { useMobileRangePicker } from '../internal/hooks/useMobileRangePicker';
|
|
13
|
-
import { validateDateRange } from '../internal/
|
|
13
|
+
import { validateDateRange } from '../internal/utils/validation/validateDateRange';
|
|
14
14
|
const MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateRangePicker(inProps, ref) {
|
|
15
15
|
// Props with the default values common to all date time pickers
|
|
16
16
|
const _useDateRangePickerDe = useDateRangePickerDefaultizedProps(inProps, 'MuiMobileDateRangePicker'),
|
|
@@ -40,6 +40,7 @@ const MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateR
|
|
|
40
40
|
} = useMobileRangePicker({
|
|
41
41
|
props,
|
|
42
42
|
valueManager: rangeValueManager,
|
|
43
|
+
valueType: 'date',
|
|
43
44
|
validator: validateDateRange
|
|
44
45
|
});
|
|
45
46
|
return renderPicker();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
|
|
3
|
+
const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -25,7 +25,7 @@ const MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
|
|
|
25
25
|
overridesResolver: (props, styles) => styles.root
|
|
26
26
|
})({});
|
|
27
27
|
const MultiInputDateRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
28
|
-
children: props.children ?? '
|
|
28
|
+
children: props.children ?? ' – '
|
|
29
29
|
})), {
|
|
30
30
|
name: 'MuiMultiInputDateRangeField',
|
|
31
31
|
slot: 'Separator',
|
|
@@ -45,6 +45,7 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
45
45
|
defaultValue,
|
|
46
46
|
format,
|
|
47
47
|
formatDensity,
|
|
48
|
+
shouldRespectLeadingZeros,
|
|
48
49
|
onChange,
|
|
49
50
|
readOnly,
|
|
50
51
|
disabled,
|
|
@@ -102,6 +103,7 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
102
103
|
defaultValue,
|
|
103
104
|
format,
|
|
104
105
|
formatDensity,
|
|
106
|
+
shouldRespectLeadingZeros,
|
|
105
107
|
onChange,
|
|
106
108
|
readOnly,
|
|
107
109
|
disabled,
|
|
@@ -139,15 +141,20 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
139
141
|
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
140
142
|
fullWidth: true
|
|
141
143
|
}, startDateProps, {
|
|
144
|
+
InputProps: _extends({}, startDateProps.InputProps, {
|
|
145
|
+
readOnly: startReadOnly
|
|
146
|
+
}),
|
|
142
147
|
inputProps: _extends({}, startDateProps.inputProps, {
|
|
143
148
|
ref: startInputRef,
|
|
144
|
-
readOnly: startReadOnly,
|
|
145
149
|
inputMode: startInputMode,
|
|
146
150
|
onKeyDown: onStartInputKeyDown
|
|
147
151
|
})
|
|
148
152
|
})), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
149
153
|
fullWidth: true
|
|
150
154
|
}, endDateProps, {
|
|
155
|
+
InputProps: _extends({}, endDateProps.InputProps, {
|
|
156
|
+
readOnly: endReadOnly
|
|
157
|
+
}),
|
|
151
158
|
inputProps: _extends({}, endDateProps.inputProps, {
|
|
152
159
|
ref: endInputRef,
|
|
153
160
|
readOnly: endReadOnly,
|
|
@@ -271,6 +278,21 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
271
278
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
272
279
|
*/
|
|
273
280
|
shouldDisableDate: PropTypes.func,
|
|
281
|
+
/**
|
|
282
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
283
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
284
|
+
*
|
|
285
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
286
|
+
*
|
|
287
|
+
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
288
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
289
|
+
*
|
|
290
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
291
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
292
|
+
*
|
|
293
|
+
* @default `false`
|
|
294
|
+
*/
|
|
295
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
274
296
|
/**
|
|
275
297
|
* The props used for each component slot.
|
|
276
298
|
* @default {}
|
|
@@ -296,7 +318,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
296
318
|
/**
|
|
297
319
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
298
320
|
*
|
|
299
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
321
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
300
322
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
301
323
|
*
|
|
302
324
|
* To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
3
|
+
const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "disabled", "onError", "shouldDisableDate", "minDate", "maxDate", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -25,7 +25,7 @@ const MultiInputDateTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((
|
|
|
25
25
|
overridesResolver: (props, styles) => styles.root
|
|
26
26
|
})({});
|
|
27
27
|
const MultiInputDateTimeRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
28
|
-
children: props.children ?? '
|
|
28
|
+
children: props.children ?? ' – '
|
|
29
29
|
})), {
|
|
30
30
|
name: 'MuiMultiInputDateTimeRangeField',
|
|
31
31
|
slot: 'Separator',
|
|
@@ -45,6 +45,7 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
|
|
|
45
45
|
defaultValue,
|
|
46
46
|
format,
|
|
47
47
|
formatDensity,
|
|
48
|
+
shouldRespectLeadingZeros,
|
|
48
49
|
onChange,
|
|
49
50
|
readOnly,
|
|
50
51
|
disabled,
|
|
@@ -111,6 +112,7 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
|
|
|
111
112
|
defaultValue,
|
|
112
113
|
format,
|
|
113
114
|
formatDensity,
|
|
115
|
+
shouldRespectLeadingZeros,
|
|
114
116
|
onChange,
|
|
115
117
|
readOnly,
|
|
116
118
|
disabled,
|
|
@@ -157,15 +159,20 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
|
|
|
157
159
|
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
158
160
|
fullWidth: true
|
|
159
161
|
}, startDateProps, {
|
|
162
|
+
InputProps: _extends({}, startDateProps.InputProps, {
|
|
163
|
+
readOnly: startReadOnly
|
|
164
|
+
}),
|
|
160
165
|
inputProps: _extends({}, startDateProps.inputProps, {
|
|
161
166
|
ref: startInputRef,
|
|
162
|
-
readOnly: startReadOnly,
|
|
163
167
|
inputMode: startInputMode,
|
|
164
168
|
onKeyDown: onStartInputKeyDown
|
|
165
169
|
})
|
|
166
170
|
})), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
167
171
|
fullWidth: true
|
|
168
172
|
}, endDateProps, {
|
|
173
|
+
InputProps: _extends({}, endDateProps.InputProps, {
|
|
174
|
+
readOnly: endReadOnly
|
|
175
|
+
}),
|
|
169
176
|
inputProps: _extends({}, endDateProps.inputProps, {
|
|
170
177
|
ref: endInputRef,
|
|
171
178
|
readOnly: endReadOnly,
|
|
@@ -332,11 +339,27 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
332
339
|
shouldDisableDate: PropTypes.func,
|
|
333
340
|
/**
|
|
334
341
|
* Disable specific time.
|
|
342
|
+
* @template TDate
|
|
335
343
|
* @param {TDate} value The value to check.
|
|
336
344
|
* @param {TimeView} view The clock type of the timeValue.
|
|
337
345
|
* @returns {boolean} If `true` the time will be disabled.
|
|
338
346
|
*/
|
|
339
347
|
shouldDisableTime: PropTypes.func,
|
|
348
|
+
/**
|
|
349
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
350
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
351
|
+
*
|
|
352
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
353
|
+
*
|
|
354
|
+
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
355
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
356
|
+
*
|
|
357
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
358
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
359
|
+
*
|
|
360
|
+
* @default `false`
|
|
361
|
+
*/
|
|
362
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
340
363
|
/**
|
|
341
364
|
* The props used for each component slot.
|
|
342
365
|
* @default {}
|
|
@@ -362,7 +385,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
362
385
|
/**
|
|
363
386
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
364
387
|
*
|
|
365
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
388
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
366
389
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
367
390
|
*
|
|
368
391
|
* To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "disabled", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
3
|
+
const _excluded = ["slots", "slotProps", "components", "componentsProps", "value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "disabled", "onError", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableStartFieldRef", "unstableEndFieldRef", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref", "readOnly", "inputMode"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref", "readOnly", "inputMode"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -25,7 +25,7 @@ const MultiInputTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
|
|
|
25
25
|
overridesResolver: (props, styles) => styles.root
|
|
26
26
|
})({});
|
|
27
27
|
const MultiInputTimeRangeFieldSeparator = styled(props => /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
28
|
-
children: props.children ?? '
|
|
28
|
+
children: props.children ?? ' – '
|
|
29
29
|
})), {
|
|
30
30
|
name: 'MuiMultiInputTimeRangeField',
|
|
31
31
|
slot: 'Separator',
|
|
@@ -45,6 +45,7 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
45
45
|
defaultValue,
|
|
46
46
|
format,
|
|
47
47
|
formatDensity,
|
|
48
|
+
shouldRespectLeadingZeros,
|
|
48
49
|
onChange,
|
|
49
50
|
readOnly,
|
|
50
51
|
disabled,
|
|
@@ -106,6 +107,7 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
106
107
|
defaultValue,
|
|
107
108
|
format,
|
|
108
109
|
formatDensity,
|
|
110
|
+
shouldRespectLeadingZeros,
|
|
109
111
|
onChange,
|
|
110
112
|
readOnly,
|
|
111
113
|
disabled,
|
|
@@ -147,15 +149,20 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
147
149
|
children: [/*#__PURE__*/_jsx(TextField, _extends({
|
|
148
150
|
fullWidth: true
|
|
149
151
|
}, startDateProps, {
|
|
152
|
+
InputProps: _extends({}, startDateProps.InputProps, {
|
|
153
|
+
readOnly: startReadOnly
|
|
154
|
+
}),
|
|
150
155
|
inputProps: _extends({}, startDateProps.inputProps, {
|
|
151
156
|
ref: startInputRef,
|
|
152
|
-
readOnly: startReadOnly,
|
|
153
157
|
inputMode: startInputMode,
|
|
154
158
|
onKeyDown: onStartInputKeyDown
|
|
155
159
|
})
|
|
156
160
|
})), /*#__PURE__*/_jsx(Separator, _extends({}, separatorProps)), /*#__PURE__*/_jsx(TextField, _extends({
|
|
157
161
|
fullWidth: true
|
|
158
162
|
}, endDateProps, {
|
|
163
|
+
InputProps: _extends({}, endDateProps.InputProps, {
|
|
164
|
+
readOnly: endReadOnly
|
|
165
|
+
}),
|
|
159
166
|
inputProps: _extends({}, endDateProps.inputProps, {
|
|
160
167
|
ref: endInputRef,
|
|
161
168
|
readOnly: endReadOnly,
|
|
@@ -298,11 +305,27 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
|
|
|
298
305
|
shouldDisableClock: PropTypes.func,
|
|
299
306
|
/**
|
|
300
307
|
* Disable specific time.
|
|
308
|
+
* @template TDate
|
|
301
309
|
* @param {TDate} value The value to check.
|
|
302
310
|
* @param {TimeView} view The clock type of the timeValue.
|
|
303
311
|
* @returns {boolean} If `true` the time will be disabled.
|
|
304
312
|
*/
|
|
305
313
|
shouldDisableTime: PropTypes.func,
|
|
314
|
+
/**
|
|
315
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
316
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
317
|
+
*
|
|
318
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
319
|
+
*
|
|
320
|
+
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
321
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
322
|
+
*
|
|
323
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
324
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
325
|
+
*
|
|
326
|
+
* @default `false`
|
|
327
|
+
*/
|
|
328
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
306
329
|
/**
|
|
307
330
|
* The props used for each component slot.
|
|
308
331
|
* @default {}
|
|
@@ -328,7 +351,7 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
|
|
|
328
351
|
/**
|
|
329
352
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
330
353
|
*
|
|
331
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
354
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
332
355
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
333
356
|
*
|
|
334
357
|
* To enable this flag globally, follow the [theme's default props](https://mui.com/material-ui/customization/theme-components/#default-props) configuration.
|
|
@@ -54,11 +54,13 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
|
|
|
54
54
|
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
55
55
|
ref: ref
|
|
56
56
|
}, fieldProps, {
|
|
57
|
+
InputProps: _extends({}, fieldProps.InputProps, {
|
|
58
|
+
readOnly
|
|
59
|
+
}),
|
|
57
60
|
inputProps: _extends({}, fieldProps.inputProps, {
|
|
58
|
-
ref: inputRef,
|
|
59
|
-
onPaste,
|
|
60
61
|
inputMode,
|
|
61
|
-
|
|
62
|
+
onPaste,
|
|
63
|
+
ref: inputRef
|
|
62
64
|
})
|
|
63
65
|
}));
|
|
64
66
|
});
|
|
@@ -249,6 +251,21 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
249
251
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
250
252
|
*/
|
|
251
253
|
shouldDisableDate: PropTypes.func,
|
|
254
|
+
/**
|
|
255
|
+
* If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
256
|
+
* If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
257
|
+
*
|
|
258
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
259
|
+
*
|
|
260
|
+
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
261
|
+
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
262
|
+
*
|
|
263
|
+
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
|
264
|
+
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
|
265
|
+
*
|
|
266
|
+
* @default `false`
|
|
267
|
+
*/
|
|
268
|
+
shouldRespectLeadingZeros: PropTypes.bool,
|
|
252
269
|
/**
|
|
253
270
|
* The size of the component.
|
|
254
271
|
*/
|