@mui/x-date-pickers-pro 7.0.0-beta.7 → 7.0.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 +195 -12
- package/DateRangeCalendar/DateRangeCalendar.js +17 -22
- package/DateRangeCalendar/useDragRange.js +1 -2
- package/DateRangePicker/DateRangePicker.js +1 -1
- package/DateRangePicker/shared.js +3 -5
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +10 -0
- package/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +4 -5
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -3
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +2 -2
- package/DateTimeRangePicker/shared.d.ts +5 -4
- package/DateTimeRangePicker/shared.js +9 -10
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +6 -10
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +10 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +31 -28
- package/MobileDateRangePicker/MobileDateRangePicker.js +5 -9
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +10 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +20 -14
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -15
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -15
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +16 -14
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +1 -1
- package/README.md +1 -1
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +8 -4
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +8 -4
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +7 -3
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
- package/StaticDateRangePicker/StaticDateRangePicker.js +4 -5
- package/index.js +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -11
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +25 -31
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -10
- package/internals/hooks/useMultiInputFieldSelectedSections.js +3 -6
- package/internals/hooks/useRangePosition.js +3 -5
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -18
- package/internals/models/dateRange.d.ts +3 -3
- package/internals/models/dateTimeRange.d.ts +2 -2
- package/internals/models/timeRange.d.ts +2 -2
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/validation/validateDateRange.js +2 -2
- package/internals/utils/validation/validateDateTimeRange.js +2 -2
- package/internals/utils/valueManagers.d.ts +3 -1
- package/internals/utils/valueManagers.js +9 -7
- package/models/fields.d.ts +8 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +1 -1
- package/modern/DateRangePicker/DateRangePicker.js +1 -1
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/internals/utils/valueManagers.js +7 -5
- package/node/DateRangeCalendar/DateRangeCalendar.js +1 -1
- package/node/DateRangePicker/DateRangePicker.js +1 -1
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +7 -1
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +7 -1
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +7 -1
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/internals/utils/valueManagers.js +9 -6
- package/package.json +7 -7
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +0 -9
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -52
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -51
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -59
|
@@ -23,7 +23,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
23
23
|
* - [SingleInputDateRangeField API](https://mui.com/x/api/single-input-date-range-field/)
|
|
24
24
|
*/
|
|
25
25
|
const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleInputDateRangeField(inProps, inRef) {
|
|
26
|
-
var _slots$textField;
|
|
27
26
|
const themeProps = useThemeProps({
|
|
28
27
|
props: inProps,
|
|
29
28
|
name: 'MuiSingleInputDateRangeField'
|
|
@@ -36,10 +35,10 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
|
|
|
36
35
|
} = themeProps,
|
|
37
36
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
38
37
|
const ownerState = themeProps;
|
|
39
|
-
const TextField =
|
|
38
|
+
const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure ? PickersTextField : MuiTextField);
|
|
40
39
|
const textFieldProps = useSlotProps({
|
|
41
40
|
elementType: TextField,
|
|
42
|
-
externalSlotProps: slotProps
|
|
41
|
+
externalSlotProps: slotProps?.textField,
|
|
43
42
|
externalForwardedProps: other,
|
|
44
43
|
ownerState,
|
|
45
44
|
additionalProps: {
|
|
@@ -83,6 +82,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
83
82
|
*/
|
|
84
83
|
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
|
|
85
84
|
component: PropTypes.elementType,
|
|
85
|
+
/**
|
|
86
|
+
* String displayed between the start and the end dates.
|
|
87
|
+
* @default "–"
|
|
88
|
+
*/
|
|
89
|
+
dateSeparator: PropTypes.string,
|
|
86
90
|
/**
|
|
87
91
|
* The default value. Use when the component is not controlled.
|
|
88
92
|
*/
|
|
@@ -243,7 +247,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
243
247
|
/**
|
|
244
248
|
* Disable specific date.
|
|
245
249
|
*
|
|
246
|
-
* Warning: This function can be called multiple times (
|
|
250
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
247
251
|
*
|
|
248
252
|
* @template TDate
|
|
249
253
|
* @param {TDate} day The date to test.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { useField, splitFieldInternalAndForwardedProps, useDefaultizedDateField } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { rangeValueManager,
|
|
3
|
+
import { rangeValueManager, getRangeFieldValueManager } from '../internals/utils/valueManagers';
|
|
3
4
|
import { validateDateRange } from '../internals/utils/validation/validateDateRange';
|
|
4
5
|
export const useSingleInputDateRangeField = inProps => {
|
|
5
6
|
const props = useDefaultizedDateField(inProps);
|
|
@@ -7,11 +8,14 @@ export const useSingleInputDateRangeField = inProps => {
|
|
|
7
8
|
forwardedProps,
|
|
8
9
|
internalProps
|
|
9
10
|
} = splitFieldInternalAndForwardedProps(props, 'date');
|
|
11
|
+
const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
|
|
12
|
+
dateSeparator: internalProps.dateSeparator
|
|
13
|
+
}), [internalProps.dateSeparator]);
|
|
10
14
|
return useField({
|
|
11
15
|
forwardedProps,
|
|
12
16
|
internalProps,
|
|
13
17
|
valueManager: rangeValueManager,
|
|
14
|
-
fieldValueManager
|
|
18
|
+
fieldValueManager,
|
|
15
19
|
validator: validateDateRange,
|
|
16
20
|
valueType: 'date'
|
|
17
21
|
});
|
|
@@ -23,7 +23,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
23
23
|
* - [SingleInputDateTimeRangeField API](https://mui.com/x/api/single-input-date-time-range-field/)
|
|
24
24
|
*/
|
|
25
25
|
const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleInputDateTimeRangeField(inProps, inRef) {
|
|
26
|
-
var _slots$textField;
|
|
27
26
|
const themeProps = useThemeProps({
|
|
28
27
|
props: inProps,
|
|
29
28
|
name: 'MuiSingleInputDateTimeRangeField'
|
|
@@ -36,10 +35,10 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
|
|
|
36
35
|
} = themeProps,
|
|
37
36
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
38
37
|
const ownerState = themeProps;
|
|
39
|
-
const TextField =
|
|
38
|
+
const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure ? PickersTextField : MuiTextField);
|
|
40
39
|
const textFieldProps = useSlotProps({
|
|
41
40
|
elementType: TextField,
|
|
42
|
-
externalSlotProps: slotProps
|
|
41
|
+
externalSlotProps: slotProps?.textField,
|
|
43
42
|
externalForwardedProps: other,
|
|
44
43
|
ownerState,
|
|
45
44
|
additionalProps: {
|
|
@@ -88,6 +87,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
|
|
|
88
87
|
*/
|
|
89
88
|
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
|
|
90
89
|
component: PropTypes.elementType,
|
|
90
|
+
/**
|
|
91
|
+
* String displayed between the start and the end dates.
|
|
92
|
+
* @default "–"
|
|
93
|
+
*/
|
|
94
|
+
dateSeparator: PropTypes.string,
|
|
91
95
|
/**
|
|
92
96
|
* The default value. Use when the component is not controlled.
|
|
93
97
|
*/
|
|
@@ -276,7 +280,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
|
|
|
276
280
|
/**
|
|
277
281
|
* Disable specific date.
|
|
278
282
|
*
|
|
279
|
-
* Warning: This function can be called multiple times (
|
|
283
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
280
284
|
*
|
|
281
285
|
* @template TDate
|
|
282
286
|
* @param {TDate} day The date to test.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { useField, splitFieldInternalAndForwardedProps, useDefaultizedDateTimeField } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { rangeValueManager,
|
|
3
|
+
import { rangeValueManager, getRangeFieldValueManager } from '../internals/utils/valueManagers';
|
|
3
4
|
import { validateDateTimeRange } from '../internals/utils/validation/validateDateTimeRange';
|
|
4
5
|
export const useSingleInputDateTimeRangeField = inProps => {
|
|
5
6
|
const props = useDefaultizedDateTimeField(inProps);
|
|
@@ -7,11 +8,14 @@ export const useSingleInputDateTimeRangeField = inProps => {
|
|
|
7
8
|
forwardedProps,
|
|
8
9
|
internalProps
|
|
9
10
|
} = splitFieldInternalAndForwardedProps(props, 'date-time');
|
|
11
|
+
const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
|
|
12
|
+
dateSeparator: internalProps.dateSeparator
|
|
13
|
+
}), [internalProps.dateSeparator]);
|
|
10
14
|
return useField({
|
|
11
15
|
forwardedProps,
|
|
12
16
|
internalProps,
|
|
13
17
|
valueManager: rangeValueManager,
|
|
14
|
-
fieldValueManager
|
|
18
|
+
fieldValueManager,
|
|
15
19
|
validator: validateDateTimeRange,
|
|
16
20
|
valueType: 'date-time'
|
|
17
21
|
});
|
|
@@ -23,7 +23,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
23
23
|
* - [SingleInputTimeRangeField API](https://mui.com/x/api/single-input-time-range-field/)
|
|
24
24
|
*/
|
|
25
25
|
const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleInputTimeRangeField(inProps, inRef) {
|
|
26
|
-
var _slots$textField;
|
|
27
26
|
const themeProps = useThemeProps({
|
|
28
27
|
props: inProps,
|
|
29
28
|
name: 'MuiSingleInputTimeRangeField'
|
|
@@ -36,10 +35,10 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
|
|
|
36
35
|
} = themeProps,
|
|
37
36
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
38
37
|
const ownerState = themeProps;
|
|
39
|
-
const TextField =
|
|
38
|
+
const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure ? PickersTextField : MuiTextField);
|
|
40
39
|
const textFieldProps = useSlotProps({
|
|
41
40
|
elementType: TextField,
|
|
42
|
-
externalSlotProps: slotProps
|
|
41
|
+
externalSlotProps: slotProps?.textField,
|
|
43
42
|
externalForwardedProps: other,
|
|
44
43
|
ownerState,
|
|
45
44
|
additionalProps: {
|
|
@@ -88,6 +87,11 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
|
|
|
88
87
|
*/
|
|
89
88
|
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
|
|
90
89
|
component: PropTypes.elementType,
|
|
90
|
+
/**
|
|
91
|
+
* String displayed between the start and the end dates.
|
|
92
|
+
* @default "–"
|
|
93
|
+
*/
|
|
94
|
+
dateSeparator: PropTypes.string,
|
|
91
95
|
/**
|
|
92
96
|
* The default value. Use when the component is not controlled.
|
|
93
97
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { useField, splitFieldInternalAndForwardedProps, useDefaultizedTimeField } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { rangeValueManager,
|
|
3
|
+
import { rangeValueManager, getRangeFieldValueManager } from '../internals/utils/valueManagers';
|
|
3
4
|
import { validateTimeRange } from '../internals/utils/validation/validateTimeRange';
|
|
4
5
|
export const useSingleInputTimeRangeField = inProps => {
|
|
5
6
|
const props = useDefaultizedTimeField(inProps);
|
|
@@ -7,11 +8,14 @@ export const useSingleInputTimeRangeField = inProps => {
|
|
|
7
8
|
forwardedProps,
|
|
8
9
|
internalProps
|
|
9
10
|
} = splitFieldInternalAndForwardedProps(props, 'time');
|
|
11
|
+
const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
|
|
12
|
+
dateSeparator: internalProps.dateSeparator
|
|
13
|
+
}), [internalProps.dateSeparator]);
|
|
10
14
|
return useField({
|
|
11
15
|
forwardedProps,
|
|
12
16
|
internalProps,
|
|
13
17
|
valueManager: rangeValueManager,
|
|
14
|
-
fieldValueManager
|
|
18
|
+
fieldValueManager,
|
|
15
19
|
validator: validateTimeRange,
|
|
16
20
|
valueType: 'time'
|
|
17
21
|
});
|
|
@@ -17,9 +17,8 @@ import { validateDateRange } from '../internals/utils/validation/validateDateRan
|
|
|
17
17
|
* - [StaticDateRangePicker API](https://mui.com/x/api/date-pickers/static-date-range-picker/)
|
|
18
18
|
*/
|
|
19
19
|
const StaticDateRangePicker = /*#__PURE__*/React.forwardRef(function StaticDateRangePicker(inProps, ref) {
|
|
20
|
-
var _defaultizedProps$dis, _defaultizedProps$cal, _defaultizedProps$slo;
|
|
21
20
|
const defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiStaticDateRangePicker');
|
|
22
|
-
const displayStaticWrapperAs =
|
|
21
|
+
const displayStaticWrapperAs = defaultizedProps.displayStaticWrapperAs ?? 'mobile';
|
|
23
22
|
const viewRenderers = _extends({
|
|
24
23
|
day: renderDateRangeViewCalendar
|
|
25
24
|
}, defaultizedProps.viewRenderers);
|
|
@@ -30,11 +29,11 @@ const StaticDateRangePicker = /*#__PURE__*/React.forwardRef(function StaticDateR
|
|
|
30
29
|
displayStaticWrapperAs,
|
|
31
30
|
views: ['day'],
|
|
32
31
|
openTo: 'day',
|
|
33
|
-
calendars:
|
|
32
|
+
calendars: defaultizedProps.calendars ?? (displayStaticWrapperAs === 'mobile' ? 1 : 2),
|
|
34
33
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
35
34
|
toolbar: _extends({
|
|
36
35
|
hidden: displayStaticWrapperAs === 'desktop'
|
|
37
|
-
},
|
|
36
|
+
}, defaultizedProps.slotProps?.toolbar)
|
|
38
37
|
})
|
|
39
38
|
});
|
|
40
39
|
const {
|
|
@@ -218,7 +217,7 @@ StaticDateRangePicker.propTypes = {
|
|
|
218
217
|
/**
|
|
219
218
|
* Disable specific date.
|
|
220
219
|
*
|
|
221
|
-
* Warning: This function can be called multiple times (
|
|
220
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
222
221
|
*
|
|
223
222
|
* @template TDate
|
|
224
223
|
* @param {TDate} day The date to test.
|
package/index.js
CHANGED
|
@@ -14,7 +14,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
const releaseInfo = getReleaseInfo();
|
|
16
16
|
export const useDesktopRangePicker = _ref => {
|
|
17
|
-
var _props$openTo, _fieldType, _initialView$current, _slots$layout;
|
|
18
17
|
let {
|
|
19
18
|
props
|
|
20
19
|
} = _ref,
|
|
@@ -46,8 +45,8 @@ export const useDesktopRangePicker = _ref => {
|
|
|
46
45
|
const popperRef = React.useRef(null);
|
|
47
46
|
const startFieldRef = React.useRef(null);
|
|
48
47
|
const endFieldRef = React.useRef(null);
|
|
49
|
-
const initialView = React.useRef(
|
|
50
|
-
const fieldType =
|
|
48
|
+
const initialView = React.useRef(props.openTo ?? null);
|
|
49
|
+
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
51
50
|
const {
|
|
52
51
|
rangePosition,
|
|
53
52
|
onRangePositionChange
|
|
@@ -77,8 +76,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
77
76
|
}, []);
|
|
78
77
|
const handleBlur = () => {
|
|
79
78
|
executeInTheNextEventLoopTick(() => {
|
|
80
|
-
|
|
81
|
-
if ((_fieldContainerRef$cu = fieldContainerRef.current) != null && _fieldContainerRef$cu.contains(getActiveElement(document)) || (_popperRef$current = popperRef.current) != null && _popperRef$current.contains(getActiveElement(document))) {
|
|
79
|
+
if (fieldContainerRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
|
|
82
80
|
return;
|
|
83
81
|
}
|
|
84
82
|
actions.onDismiss();
|
|
@@ -87,7 +85,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
87
85
|
const Field = slots.field;
|
|
88
86
|
const fieldProps = useSlotProps({
|
|
89
87
|
elementType: Field,
|
|
90
|
-
externalSlotProps: slotProps
|
|
88
|
+
externalSlotProps: slotProps?.field,
|
|
91
89
|
additionalProps: _extends({}, pickerFieldProps, {
|
|
92
90
|
readOnly,
|
|
93
91
|
disabled,
|
|
@@ -126,20 +124,20 @@ export const useDesktopRangePicker = _ref => {
|
|
|
126
124
|
startFieldRef,
|
|
127
125
|
endFieldRef,
|
|
128
126
|
currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
|
|
129
|
-
initialView:
|
|
127
|
+
initialView: initialView.current ?? undefined,
|
|
130
128
|
onViewChange: layoutProps.onViewChange
|
|
131
129
|
});
|
|
132
130
|
const slotPropsForLayout = _extends({}, slotProps, {
|
|
133
|
-
tabs: _extends({}, slotProps
|
|
131
|
+
tabs: _extends({}, slotProps?.tabs, {
|
|
134
132
|
rangePosition,
|
|
135
133
|
onRangePositionChange
|
|
136
134
|
}),
|
|
137
|
-
toolbar: _extends({}, slotProps
|
|
135
|
+
toolbar: _extends({}, slotProps?.toolbar, {
|
|
138
136
|
rangePosition,
|
|
139
137
|
onRangePositionChange
|
|
140
138
|
})
|
|
141
139
|
});
|
|
142
|
-
const Layout =
|
|
140
|
+
const Layout = slots?.layout ?? PickersLayout;
|
|
143
141
|
const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
|
|
144
142
|
localeText: localeText,
|
|
145
143
|
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, _extends({
|
|
@@ -154,7 +152,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
154
152
|
slotProps: slotProps,
|
|
155
153
|
shouldRestoreFocus: shouldRestoreFocus,
|
|
156
154
|
reduceAnimations: reduceAnimations,
|
|
157
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps
|
|
155
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
|
|
158
156
|
slots: slots,
|
|
159
157
|
slotProps: slotPropsForLayout,
|
|
160
158
|
children: renderCurrentView()
|
|
@@ -32,12 +32,11 @@ const useMultiInputFieldSlotProps = ({
|
|
|
32
32
|
const handleEndFieldRef = useForkRef(fieldProps.unstableEndFieldRef, endFieldRef);
|
|
33
33
|
const previousRangePosition = React.useRef(rangePosition);
|
|
34
34
|
React.useEffect(() => {
|
|
35
|
-
var _currentFieldRef$curr;
|
|
36
35
|
if (!open) {
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
38
|
const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
|
|
40
|
-
|
|
39
|
+
currentFieldRef.current?.focusField();
|
|
41
40
|
if (!currentFieldRef.current || !currentView) {
|
|
42
41
|
// could happen when the user is switching between the inputs
|
|
43
42
|
previousRangePosition.current = rangePosition;
|
|
@@ -68,7 +67,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
68
67
|
if (open) {
|
|
69
68
|
onRangePositionChange('start');
|
|
70
69
|
if (previousRangePosition.current !== 'start' && initialView) {
|
|
71
|
-
onViewChange
|
|
70
|
+
onViewChange?.(initialView);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
};
|
|
@@ -76,24 +75,23 @@ const useMultiInputFieldSlotProps = ({
|
|
|
76
75
|
if (open) {
|
|
77
76
|
onRangePositionChange('end');
|
|
78
77
|
if (previousRangePosition.current !== 'end' && initialView) {
|
|
79
|
-
onViewChange
|
|
78
|
+
onViewChange?.(initialView);
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
82
|
const slots = _extends({
|
|
84
|
-
textField: pickerSlots
|
|
85
|
-
root: pickerSlots
|
|
86
|
-
separator: pickerSlots
|
|
83
|
+
textField: pickerSlots?.textField,
|
|
84
|
+
root: pickerSlots?.fieldRoot,
|
|
85
|
+
separator: pickerSlots?.fieldSeparator
|
|
87
86
|
}, fieldProps.slots);
|
|
88
87
|
const slotProps = _extends({}, fieldProps.slotProps, {
|
|
89
88
|
textField: ownerState => {
|
|
90
|
-
const resolvedComponentProps = resolveComponentProps(pickerSlotProps
|
|
89
|
+
const resolvedComponentProps = resolveComponentProps(pickerSlotProps?.textField, ownerState);
|
|
91
90
|
let textFieldProps;
|
|
92
91
|
let InputProps;
|
|
93
92
|
if (ownerState.position === 'start') {
|
|
94
|
-
var _inLocaleText$start;
|
|
95
93
|
textFieldProps = _extends({
|
|
96
|
-
label:
|
|
94
|
+
label: inLocaleText?.start ?? localeText.start,
|
|
97
95
|
onKeyDown: onSpaceOrEnter(openRangeStartSelection),
|
|
98
96
|
onFocus: handleFocusStart,
|
|
99
97
|
focused: open ? rangePosition === 'start' : undefined
|
|
@@ -103,14 +101,13 @@ const useMultiInputFieldSlotProps = ({
|
|
|
103
101
|
readOnly: true
|
|
104
102
|
});
|
|
105
103
|
if (anchorRef) {
|
|
106
|
-
InputProps = _extends({}, resolvedComponentProps
|
|
104
|
+
InputProps = _extends({}, resolvedComponentProps?.InputProps, {
|
|
107
105
|
ref: anchorRef
|
|
108
106
|
});
|
|
109
107
|
}
|
|
110
108
|
} else {
|
|
111
|
-
var _inLocaleText$end;
|
|
112
109
|
textFieldProps = _extends({
|
|
113
|
-
label:
|
|
110
|
+
label: inLocaleText?.end ?? localeText.end,
|
|
114
111
|
onKeyDown: onSpaceOrEnter(openRangeEndSelection),
|
|
115
112
|
onFocus: handleFocusEnd,
|
|
116
113
|
focused: open ? rangePosition === 'end' : undefined
|
|
@@ -119,11 +116,11 @@ const useMultiInputFieldSlotProps = ({
|
|
|
119
116
|
}, wrapperVariant === 'mobile' && {
|
|
120
117
|
readOnly: true
|
|
121
118
|
});
|
|
122
|
-
InputProps = resolvedComponentProps
|
|
119
|
+
InputProps = resolvedComponentProps?.InputProps;
|
|
123
120
|
}
|
|
124
121
|
return _extends({}, labelId != null && {
|
|
125
122
|
id: `${labelId}-${ownerState.position}`
|
|
126
|
-
}, textFieldProps, resolveComponentProps(pickerSlotProps
|
|
123
|
+
}, textFieldProps, resolveComponentProps(pickerSlotProps?.textField, ownerState), {
|
|
127
124
|
InputProps
|
|
128
125
|
});
|
|
129
126
|
},
|
|
@@ -131,9 +128,9 @@ const useMultiInputFieldSlotProps = ({
|
|
|
131
128
|
const rootProps = {
|
|
132
129
|
onBlur
|
|
133
130
|
};
|
|
134
|
-
return _extends({}, rootProps, resolveComponentProps(pickerSlotProps
|
|
131
|
+
return _extends({}, rootProps, resolveComponentProps(pickerSlotProps?.fieldRoot, ownerState));
|
|
135
132
|
},
|
|
136
|
-
separator: pickerSlotProps
|
|
133
|
+
separator: pickerSlotProps?.fieldSeparator
|
|
137
134
|
});
|
|
138
135
|
|
|
139
136
|
/* TODO: remove this when a clearable behavior for multiple input range fields is implemented */
|
|
@@ -177,28 +174,25 @@ const useSingleInputFieldSlotProps = ({
|
|
|
177
174
|
|
|
178
175
|
// bring back focus to the field with the current view section selected
|
|
179
176
|
if (currentView) {
|
|
180
|
-
var _startFieldRef$curren;
|
|
181
177
|
const sections = startFieldRef.current.getSections().map(section => section.type);
|
|
182
178
|
const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
|
|
183
|
-
|
|
179
|
+
startFieldRef.current?.focusField(newSelectedSection);
|
|
184
180
|
}
|
|
185
181
|
}, [rangePosition, open, currentView, startFieldRef]);
|
|
186
182
|
const updateRangePosition = () => {
|
|
187
|
-
|
|
188
|
-
if (!((_startFieldRef$curren2 = startFieldRef.current) != null && _startFieldRef$curren2.isFieldFocused())) {
|
|
183
|
+
if (!startFieldRef.current?.isFieldFocused()) {
|
|
189
184
|
return;
|
|
190
185
|
}
|
|
191
186
|
const sections = startFieldRef.current.getSections();
|
|
192
|
-
const activeSectionIndex =
|
|
187
|
+
const activeSectionIndex = startFieldRef.current?.getActiveSectionIndex();
|
|
193
188
|
const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
|
|
194
189
|
if (domRangePosition != null && domRangePosition !== rangePosition) {
|
|
195
190
|
onRangePositionChange(domRangePosition);
|
|
196
191
|
}
|
|
197
192
|
};
|
|
198
193
|
const handleSelectedSectionsChange = useEventCallback(selectedSection => {
|
|
199
|
-
var _fieldProps$onSelecte;
|
|
200
194
|
setTimeout(updateRangePosition);
|
|
201
|
-
|
|
195
|
+
fieldProps.onSelectedSectionsChange?.(selectedSection);
|
|
202
196
|
});
|
|
203
197
|
const openPicker = event => {
|
|
204
198
|
event.stopPropagation();
|
|
@@ -207,14 +201,14 @@ const useSingleInputFieldSlotProps = ({
|
|
|
207
201
|
}
|
|
208
202
|
};
|
|
209
203
|
const slots = _extends({}, fieldProps.slots, {
|
|
210
|
-
textField: pickerSlots
|
|
211
|
-
clearButton: pickerSlots
|
|
212
|
-
clearIcon: pickerSlots
|
|
204
|
+
textField: pickerSlots?.textField,
|
|
205
|
+
clearButton: pickerSlots?.clearButton,
|
|
206
|
+
clearIcon: pickerSlots?.clearIcon
|
|
213
207
|
});
|
|
214
208
|
const slotProps = _extends({}, fieldProps.slotProps, {
|
|
215
|
-
textField: pickerSlotProps
|
|
216
|
-
clearButton: pickerSlots
|
|
217
|
-
clearIcon: pickerSlots
|
|
209
|
+
textField: pickerSlotProps?.textField,
|
|
210
|
+
clearButton: pickerSlots?.clearButton,
|
|
211
|
+
clearIcon: pickerSlots?.clearIcon
|
|
218
212
|
});
|
|
219
213
|
const enrichedFieldProps = _extends({}, fieldProps, {
|
|
220
214
|
slots,
|
|
@@ -226,7 +220,7 @@ const useSingleInputFieldSlotProps = ({
|
|
|
226
220
|
onBlur,
|
|
227
221
|
InputProps: _extends({
|
|
228
222
|
ref: anchorRef
|
|
229
|
-
}, fieldProps
|
|
223
|
+
}, fieldProps?.InputProps),
|
|
230
224
|
focused: open
|
|
231
225
|
}, labelId != null && {
|
|
232
226
|
id: labelId
|
|
@@ -15,7 +15,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
const releaseInfo = getReleaseInfo();
|
|
17
17
|
export const useMobileRangePicker = _ref => {
|
|
18
|
-
var _fieldType, _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$layout;
|
|
19
18
|
let {
|
|
20
19
|
props
|
|
21
20
|
} = _ref,
|
|
@@ -42,7 +41,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
42
41
|
} = props;
|
|
43
42
|
const startFieldRef = React.useRef(null);
|
|
44
43
|
const endFieldRef = React.useRef(null);
|
|
45
|
-
const fieldType =
|
|
44
|
+
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
46
45
|
const {
|
|
47
46
|
rangePosition,
|
|
48
47
|
onRangePositionChange
|
|
@@ -68,9 +67,9 @@ export const useMobileRangePicker = _ref => {
|
|
|
68
67
|
const Field = slots.field;
|
|
69
68
|
const fieldProps = useSlotProps({
|
|
70
69
|
elementType: Field,
|
|
71
|
-
externalSlotProps: innerSlotProps
|
|
70
|
+
externalSlotProps: innerSlotProps?.field,
|
|
72
71
|
additionalProps: _extends({}, pickerFieldProps, {
|
|
73
|
-
readOnly: readOnly
|
|
72
|
+
readOnly: readOnly ?? true,
|
|
74
73
|
disabled,
|
|
75
74
|
className,
|
|
76
75
|
sx,
|
|
@@ -86,7 +85,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
86
85
|
} : {}),
|
|
87
86
|
ownerState: props
|
|
88
87
|
});
|
|
89
|
-
const isToolbarHidden =
|
|
88
|
+
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
90
89
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
91
90
|
wrapperVariant: 'mobile',
|
|
92
91
|
fieldType,
|
|
@@ -106,17 +105,17 @@ export const useMobileRangePicker = _ref => {
|
|
|
106
105
|
endFieldRef
|
|
107
106
|
});
|
|
108
107
|
const slotPropsForLayout = _extends({}, innerSlotProps, {
|
|
109
|
-
tabs: _extends({}, innerSlotProps
|
|
108
|
+
tabs: _extends({}, innerSlotProps?.tabs, {
|
|
110
109
|
rangePosition,
|
|
111
110
|
onRangePositionChange
|
|
112
111
|
}),
|
|
113
|
-
toolbar: _extends({}, innerSlotProps
|
|
112
|
+
toolbar: _extends({}, innerSlotProps?.toolbar, {
|
|
114
113
|
titleId: labelId,
|
|
115
114
|
rangePosition,
|
|
116
115
|
onRangePositionChange
|
|
117
116
|
})
|
|
118
117
|
});
|
|
119
|
-
const Layout =
|
|
118
|
+
const Layout = slots?.layout ?? PickersLayout;
|
|
120
119
|
const finalLocaleText = _extends({}, contextLocaleText, localeText);
|
|
121
120
|
let labelledById = pickerParams.valueType === 'date-time' ? `${labelId}-start-toolbar ${labelId}-end-toolbar` : labelId;
|
|
122
121
|
if (isToolbarHidden) {
|
|
@@ -136,7 +135,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
136
135
|
const slotProps = _extends({}, innerSlotProps, {
|
|
137
136
|
mobilePaper: _extends({
|
|
138
137
|
'aria-labelledby': labelledById
|
|
139
|
-
}, innerSlotProps
|
|
138
|
+
}, innerSlotProps?.mobilePaper)
|
|
140
139
|
});
|
|
141
140
|
const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
|
|
142
141
|
localeText: localeText,
|
|
@@ -144,7 +143,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
144
143
|
open: open,
|
|
145
144
|
slots: slots,
|
|
146
145
|
slotProps: slotProps,
|
|
147
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps
|
|
146
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
|
|
148
147
|
slots: slots,
|
|
149
148
|
slotProps: slotPropsForLayout,
|
|
150
149
|
children: renderCurrentView()
|
|
@@ -2,10 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import useForkRef from '@mui/utils/useForkRef';
|
|
3
3
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
4
|
export const useMultiInputFieldSelectedSections = params => {
|
|
5
|
-
var _params$selectedSecti;
|
|
6
5
|
const unstableEndFieldRef = React.useRef(null);
|
|
7
6
|
const handleUnstableEndFieldRef = useForkRef(params.unstableEndFieldRef, unstableEndFieldRef);
|
|
8
|
-
const [startSelectedSection, setStartSelectedSection] = React.useState(
|
|
7
|
+
const [startSelectedSection, setStartSelectedSection] = React.useState(params.selectedSections ?? null);
|
|
9
8
|
const [endSelectedSection, setEndSelectedSection] = React.useState(null);
|
|
10
9
|
const getActiveField = () => {
|
|
11
10
|
if (unstableEndFieldRef.current && unstableEndFieldRef.current.isFieldFocused()) {
|
|
@@ -16,15 +15,13 @@ export const useMultiInputFieldSelectedSections = params => {
|
|
|
16
15
|
const handleStartSelectedSectionChange = useEventCallback(newSelectedSections => {
|
|
17
16
|
setStartSelectedSection(newSelectedSections);
|
|
18
17
|
if (getActiveField() === 'start') {
|
|
19
|
-
|
|
20
|
-
(_params$onSelectedSec = params.onSelectedSectionsChange) == null || _params$onSelectedSec.call(params, newSelectedSections);
|
|
18
|
+
params.onSelectedSectionsChange?.(newSelectedSections);
|
|
21
19
|
}
|
|
22
20
|
});
|
|
23
21
|
const handleEndSelectedSectionChange = useEventCallback(newSelectedSections => {
|
|
24
22
|
setEndSelectedSection(newSelectedSections);
|
|
25
23
|
if (getActiveField() === 'end') {
|
|
26
|
-
|
|
27
|
-
(_params$onSelectedSec2 = params.onSelectedSectionsChange) == null || _params$onSelectedSec2.call(params, newSelectedSections);
|
|
24
|
+
params.onSelectedSectionsChange?.(newSelectedSections);
|
|
28
25
|
}
|
|
29
26
|
});
|
|
30
27
|
const activeField = getActiveField();
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import useControlled from '@mui/utils/useControlled';
|
|
2
2
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
3
3
|
export const useRangePosition = (props, singleInputFieldRef) => {
|
|
4
|
-
var _props$defaultRangePo;
|
|
5
4
|
const [rangePosition, setRangePosition] = useControlled({
|
|
6
5
|
name: 'useRangePosition',
|
|
7
6
|
state: 'rangePosition',
|
|
8
7
|
controlled: props.rangePosition,
|
|
9
|
-
default:
|
|
8
|
+
default: props.defaultRangePosition ?? 'start'
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
// When using a single input field,
|
|
13
12
|
// we want to select the 1st section of the edited date when updating the range position.
|
|
14
13
|
const syncRangePositionWithSingleInputField = newRangePosition => {
|
|
15
|
-
if (
|
|
14
|
+
if (singleInputFieldRef?.current == null) {
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
const sections = singleInputFieldRef.current.getSections();
|
|
@@ -20,9 +19,8 @@ export const useRangePosition = (props, singleInputFieldRef) => {
|
|
|
20
19
|
singleInputFieldRef.current.setSelectedSections(targetActiveSectionIndex);
|
|
21
20
|
};
|
|
22
21
|
const handleRangePositionChange = useEventCallback(newRangePosition => {
|
|
23
|
-
var _props$onRangePositio;
|
|
24
22
|
setRangePosition(newRangePosition);
|
|
25
|
-
|
|
23
|
+
props.onRangePositionChange?.(newRangePosition);
|
|
26
24
|
syncRangePositionWithSingleInputField(newRangePosition);
|
|
27
25
|
});
|
|
28
26
|
return {
|