@@ -7,26 +7,24 @@ import {
7
7
PickerValue ,
8
8
UseFieldResponse ,
9
9
useControlledValueWithTimezone ,
10
- useDefaultizedDateTimeField ,
10
+ useFieldInternalPropsWithDefaults ,
11
11
} from '@mui/x-date-pickers/internals' ;
12
- import { DateTimeValidationError } from '@mui/x-date-pickers/models' ;
13
12
import { useValidation } from '@mui/x-date-pickers/validation' ;
14
- import type {
15
- UseMultiInputDateTimeRangeFieldParams ,
16
- UseMultiInputDateTimeRangeFieldProps ,
17
- } from '../../../MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types' ;
18
- import { DateTimeRangeValidationError } from '../../../models' ;
13
+ import { DateTimeValidationError } from '@mui/x-date-pickers/models' ;
14
+ import { UseMultiInputDateTimeRangeFieldParams } from '../../../MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types' ;
19
15
import { validateDateTimeRange } from '../../../validation' ;
20
16
import { rangeValueManager } from '../../utils/valueManagers' ;
21
17
import type { UseMultiInputRangeFieldResponse } from './useMultiInputRangeField.types' ;
18
+ import { DateTimeRangeValidationError } from '../../../models' ;
22
19
import { excludeProps } from './shared' ;
23
20
import { useMultiInputFieldSelectedSections } from '../useMultiInputFieldSelectedSections' ;
21
+ import { useDateTimeRangeManager } from '../../../managers' ;
24
22
25
23
export const useMultiInputDateTimeRangeField = <
26
24
TEnableAccessibleFieldDOMStructure extends boolean ,
27
25
TTextFieldSlotProps extends { } ,
28
26
> ( {
29
- sharedProps : inSharedProps ,
27
+ sharedProps,
30
28
startTextFieldProps,
31
29
unstableStartFieldRef,
32
30
endTextFieldProps,
@@ -35,10 +33,11 @@ export const useMultiInputDateTimeRangeField = <
35
33
TEnableAccessibleFieldDOMStructure ,
36
34
TTextFieldSlotProps
37
35
> ) : UseMultiInputRangeFieldResponse < TEnableAccessibleFieldDOMStructure , TTextFieldSlotProps > => {
38
- const sharedProps = useDefaultizedDateTimeField <
39
- UseMultiInputDateTimeRangeFieldProps < TEnableAccessibleFieldDOMStructure > ,
40
- typeof inSharedProps
41
- > ( inSharedProps ) ;
36
+ const manager = useDateTimeRangeManager ( sharedProps ) ;
37
+ const sharedPropsWithDefaults = useFieldInternalPropsWithDefaults ( {
38
+ manager,
39
+ internalProps : sharedProps ,
40
+ } ) ;
42
41
43
42
const {
44
43
value : valueProp ,
@@ -55,10 +54,10 @@ export const useMultiInputDateTimeRangeField = <
55
54
timezone : timezoneProp ,
56
55
enableAccessibleFieldDOMStructure,
57
56
autoFocus,
58
- } = sharedProps ;
57
+ } = sharedPropsWithDefaults ;
59
58
60
59
const { value, handleValueChange, timezone } = useControlledValueWithTimezone ( {
61
- name : 'useMultiInputDateRangeField ' ,
60
+ name : 'useMultiInputDateTimeRangeField ' ,
62
61
timezone : timezoneProp ,
63
62
value : valueProp ,
64
63
defaultValue,
@@ -68,11 +67,11 @@ export const useMultiInputDateTimeRangeField = <
68
67
} ) ;
69
68
70
69
const { validationError, getValidationErrorForNewValue } = useValidation ( {
71
- props : sharedProps ,
70
+ props : sharedPropsWithDefaults ,
72
71
value,
73
72
timezone,
74
73
validator : validateDateTimeRange ,
75
- onError : sharedProps . onError ,
74
+ onError : sharedPropsWithDefaults . onError ,
76
75
} ) ;
77
76
78
77
// TODO: Maybe export utility from `useField` instead of copy/pasting the logic
0 commit comments