@mui/x-date-pickers 8.0.0-alpha.12 → 8.0.0-alpha.14
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/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +96 -94
- package/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/AdapterDateFnsV2/AdapterDateFnsV2.js +96 -94
- package/AdapterDayjs/AdapterDayjs.js +11 -5
- package/CHANGELOG.md +430 -0
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DatePicker/DatePicker.types.d.ts +2 -2
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/DateTimePicker/shared.d.ts +18 -10
- package/DateTimePicker/shared.js +23 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +61 -6
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/PickersTextField/PickersTextField.js +3 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +60 -6
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/TimeClock/Clock.js +2 -2
- package/TimeClock/ClockPointer.js +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/TimePicker/shared.d.ts +1 -1
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
- package/esm/AdapterDayjs/AdapterDayjs.js +9 -5
- package/esm/DateCalendar/DateCalendar.js +1 -1
- package/esm/DateField/useDateField.d.ts +1 -1
- package/esm/DatePicker/DatePicker.types.d.ts +2 -2
- package/esm/DatePicker/shared.d.ts +1 -1
- package/esm/DateTimeField/useDateTimeField.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/esm/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/esm/DateTimePicker/shared.d.ts +18 -10
- package/esm/DateTimePicker/shared.js +23 -2
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/esm/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/esm/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
- package/esm/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/esm/PickersTextField/PickersTextField.js +3 -1
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
- package/esm/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/esm/TimeClock/Clock.js +2 -2
- package/esm/TimeClock/ClockPointer.js +1 -1
- package/esm/TimeField/useTimeField.d.ts +1 -1
- package/esm/TimePicker/TimePicker.types.d.ts +2 -2
- package/esm/TimePicker/shared.d.ts +1 -1
- package/esm/hooks/useSplitFieldProps.d.ts +1 -1
- package/esm/hooks/useSplitFieldProps.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.d.ts +7 -0
- package/esm/internals/components/PickerFieldUI.js +8 -4
- package/esm/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/esm/internals/components/PickerPopper/PickerPopper.js +26 -14
- package/esm/internals/components/PickerProvider.d.ts +158 -7
- package/esm/internals/components/PickerProvider.js +7 -2
- package/esm/internals/demo/DemoContainer.js +3 -3
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
- package/esm/internals/hooks/useField/index.d.ts +1 -2
- package/esm/internals/hooks/useField/useField.js +7 -8
- package/esm/internals/hooks/useField/useField.types.d.ts +56 -47
- package/esm/internals/hooks/useField/useField.utils.js +4 -1
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
- package/esm/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/esm/internals/hooks/useField/useFieldState.js +136 -83
- package/esm/internals/hooks/useField/useFieldV6TextField.js +9 -7
- package/esm/internals/hooks/useField/useFieldV7TextField.js +9 -8
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/esm/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
- package/esm/internals/hooks/useNullableFieldPrivateContext.js +5 -0
- package/esm/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/esm/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
- package/esm/internals/hooks/usePicker/index.d.ts +1 -3
- package/esm/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/esm/internals/hooks/usePicker/usePicker.js +276 -34
- package/esm/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/esm/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/esm/internals/index.d.ts +7 -9
- package/esm/internals/index.js +2 -1
- package/esm/internals/models/fields.d.ts +3 -10
- package/esm/internals/models/manager.d.ts +108 -4
- package/esm/internals/models/props/basePickerProps.d.ts +2 -2
- package/esm/internals/models/props/time.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.d.ts +2 -2
- package/esm/internals/utils/valueManagers.d.ts +1 -1
- package/esm/internals/utils/valueManagers.js +10 -18
- package/esm/locales/bnBD.d.ts +80 -0
- package/esm/locales/bnBD.js +73 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/managers/useDateManager.d.ts +3 -4
- package/esm/managers/useDateTimeManager.d.ts +3 -4
- package/esm/managers/useTimeManager.d.ts +3 -4
- package/esm/models/adapters.d.ts +2 -1
- package/esm/models/fields.d.ts +2 -2
- package/esm/models/manager.d.ts +4 -5
- package/esm/validation/extractValidationProps.d.ts +1 -1
- package/esm/validation/index.d.ts +1 -1
- package/esm/validation/useValidation.d.ts +2 -2
- package/hooks/useSplitFieldProps.d.ts +1 -1
- package/hooks/useSplitFieldProps.js +1 -1
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.d.ts +7 -0
- package/internals/components/PickerFieldUI.js +9 -3
- package/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/internals/components/PickerPopper/PickerPopper.js +25 -13
- package/internals/components/PickerProvider.d.ts +158 -7
- package/internals/components/PickerProvider.js +8 -3
- package/internals/demo/DemoContainer.js +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
- package/internals/hooks/useField/index.d.ts +1 -2
- package/internals/hooks/useField/useField.js +7 -8
- package/internals/hooks/useField/useField.types.d.ts +56 -47
- package/internals/hooks/useField/useField.utils.js +4 -1
- package/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -10
- package/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/internals/hooks/useField/useFieldState.js +135 -82
- package/internals/hooks/useField/useFieldV6TextField.js +9 -7
- package/internals/hooks/useField/useFieldV7TextField.js +9 -8
- package/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
- package/internals/hooks/useNullableFieldPrivateContext.js +13 -0
- package/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/internals/hooks/usePicker/hooks/useOrientation.js +42 -0
- package/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/internals/hooks/usePicker/{usePickerValue.js → hooks/useValueAndOpenStates.js} +97 -114
- package/internals/hooks/usePicker/index.d.ts +1 -3
- package/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/internals/hooks/usePicker/usePicker.js +278 -34
- package/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/internals/index.d.ts +7 -9
- package/internals/index.js +19 -0
- package/internals/models/fields.d.ts +3 -10
- package/internals/models/manager.d.ts +108 -4
- package/internals/models/props/basePickerProps.d.ts +2 -2
- package/internals/models/props/time.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +2 -2
- package/internals/utils/valueManagers.d.ts +1 -1
- package/internals/utils/valueManagers.js +10 -18
- package/locales/bnBD.d.ts +80 -0
- package/locales/bnBD.js +79 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/managers/useDateManager.d.ts +3 -4
- package/managers/useDateTimeManager.d.ts +3 -4
- package/managers/useTimeManager.d.ts +3 -4
- package/models/adapters.d.ts +2 -1
- package/models/fields.d.ts +2 -2
- package/models/manager.d.ts +4 -5
- package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
- package/modern/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/modern/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
- package/modern/AdapterDayjs/AdapterDayjs.js +9 -5
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/useDateField.d.ts +1 -1
- package/modern/DatePicker/DatePicker.types.d.ts +2 -2
- package/modern/DatePicker/shared.d.ts +1 -1
- package/modern/DateTimeField/useDateTimeField.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/modern/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/modern/DateTimePicker/shared.d.ts +18 -10
- package/modern/DateTimePicker/shared.js +23 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
- package/modern/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
- package/modern/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
- package/modern/PickersTextField/PickersTextField.js +3 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
- package/modern/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
- package/modern/TimeClock/Clock.js +2 -2
- package/modern/TimeClock/ClockPointer.js +1 -1
- package/modern/TimeField/useTimeField.d.ts +1 -1
- package/modern/TimePicker/TimePicker.types.d.ts +2 -2
- package/modern/TimePicker/shared.d.ts +1 -1
- package/modern/hooks/useSplitFieldProps.d.ts +1 -1
- package/modern/hooks/useSplitFieldProps.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.d.ts +7 -0
- package/modern/internals/components/PickerFieldUI.js +8 -4
- package/modern/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/modern/internals/components/PickerPopper/PickerPopper.js +26 -14
- package/modern/internals/components/PickerProvider.d.ts +158 -7
- package/modern/internals/components/PickerProvider.js +7 -2
- package/modern/internals/demo/DemoContainer.js +3 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
- package/modern/internals/hooks/useField/index.d.ts +1 -2
- package/modern/internals/hooks/useField/useField.js +7 -8
- package/modern/internals/hooks/useField/useField.types.d.ts +56 -47
- package/modern/internals/hooks/useField/useField.utils.js +4 -1
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
- package/modern/internals/hooks/useField/useFieldState.d.ts +2 -1
- package/modern/internals/hooks/useField/useFieldState.js +136 -83
- package/modern/internals/hooks/useField/useFieldV6TextField.js +9 -7
- package/modern/internals/hooks/useField/useFieldV7TextField.js +9 -8
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
- package/modern/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
- package/modern/internals/hooks/useNullableFieldPrivateContext.js +5 -0
- package/modern/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
- package/modern/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
- package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
- package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
- package/modern/internals/hooks/usePicker/index.d.ts +1 -3
- package/modern/internals/hooks/usePicker/usePicker.d.ts +5 -5
- package/modern/internals/hooks/usePicker/usePicker.js +276 -34
- package/modern/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
- package/modern/internals/hooks/useValueWithTimezone.d.ts +1 -1
- package/modern/internals/index.d.ts +7 -9
- package/modern/internals/index.js +2 -1
- package/modern/internals/models/fields.d.ts +3 -10
- package/modern/internals/models/manager.d.ts +108 -4
- package/modern/internals/models/props/basePickerProps.d.ts +2 -2
- package/modern/internals/models/props/time.d.ts +1 -1
- package/modern/internals/utils/date-time-utils.d.ts +2 -2
- package/modern/internals/utils/valueManagers.d.ts +1 -1
- package/modern/internals/utils/valueManagers.js +10 -18
- package/modern/locales/bnBD.d.ts +80 -0
- package/modern/locales/bnBD.js +73 -0
- package/modern/locales/index.d.ts +1 -0
- package/modern/locales/index.js +1 -0
- package/modern/managers/useDateManager.d.ts +3 -4
- package/modern/managers/useDateTimeManager.d.ts +3 -4
- package/modern/managers/useTimeManager.d.ts +3 -4
- package/modern/models/adapters.d.ts +2 -1
- package/modern/models/fields.d.ts +2 -2
- package/modern/models/manager.d.ts +4 -5
- package/modern/validation/extractValidationProps.d.ts +1 -1
- package/modern/validation/index.d.ts +1 -1
- package/modern/validation/useValidation.d.ts +2 -2
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/extractValidationProps.d.ts +1 -1
- package/validation/index.d.ts +1 -1
- package/validation/useValidation.d.ts +2 -2
- package/esm/internals/hooks/useOpenState.d.ts +0 -14
- package/esm/internals/hooks/useOpenState.js +0 -37
- package/esm/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
- package/esm/internals/hooks/usePicker/usePickerProvider.js +0 -111
- package/esm/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/esm/internals/hooks/usePicker/usePickerValue.js +0 -226
- package/esm/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/esm/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/esm/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
- package/esm/internals/hooks/usePicker/usePickerViews.js +0 -176
- package/internals/hooks/useOpenState.d.ts +0 -14
- package/internals/hooks/useOpenState.js +0 -46
- package/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
- package/internals/hooks/usePicker/usePickerProvider.js +0 -121
- package/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/internals/hooks/usePicker/usePickerValue.types.js +0 -5
- package/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
- package/internals/hooks/usePicker/usePickerViews.js +0 -183
- package/modern/internals/hooks/useOpenState.d.ts +0 -14
- package/modern/internals/hooks/useOpenState.js +0 -37
- package/modern/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
- package/modern/internals/hooks/usePicker/usePickerProvider.js +0 -111
- package/modern/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
- package/modern/internals/hooks/usePicker/usePickerValue.js +0 -226
- package/modern/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +0 -1
- package/modern/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
- package/modern/internals/hooks/usePicker/usePickerViews.js +0 -176
|
@@ -15,10 +15,10 @@ const getChildTypeFromChildName = childName => {
|
|
|
15
15
|
if (childName.match(/^Static([A-Za-z]+)/) || childName.match(/^([A-Za-z]+)(Calendar|Clock)$/)) {
|
|
16
16
|
return 'UI-view';
|
|
17
17
|
}
|
|
18
|
-
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)
|
|
18
|
+
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)) {
|
|
19
19
|
return 'multi-input-range-field';
|
|
20
20
|
}
|
|
21
|
-
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/)) {
|
|
21
|
+
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/) || childName.match(/^([A-Za-z]+)RangePicker$/)) {
|
|
22
22
|
return 'single-input-range-field';
|
|
23
23
|
}
|
|
24
24
|
return 'single-input-field';
|
|
@@ -133,7 +133,7 @@ export function DemoContainer(props) {
|
|
|
133
133
|
minWidth: {
|
|
134
134
|
xs: 300,
|
|
135
135
|
// If demo also contains MultiInputDateTimeRangeField, increase width to avoid cutting off the value.
|
|
136
|
-
md: childrenTypes.has('multi-input-range-field') ? 460 :
|
|
136
|
+
md: childrenTypes.has('multi-input-range-field') ? 460 : 440
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -4,8 +4,6 @@ const _excluded = ["props"],
|
|
|
4
4
|
_excluded2 = ["ownerState"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
-
import useId from '@mui/utils/useId';
|
|
9
7
|
import { PickerPopper } from "../../components/PickerPopper/PickerPopper.js";
|
|
10
8
|
import { usePicker } from "../usePicker/index.js";
|
|
11
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
@@ -29,35 +27,26 @@ export const useDesktopPicker = _ref => {
|
|
|
29
27
|
slotProps: innerSlotProps,
|
|
30
28
|
label,
|
|
31
29
|
inputRef,
|
|
32
|
-
readOnly,
|
|
33
|
-
autoFocus,
|
|
34
30
|
localeText
|
|
35
31
|
} = props;
|
|
36
|
-
const fieldRef = React.useRef(null);
|
|
37
|
-
const labelId = useId();
|
|
38
|
-
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
39
32
|
const {
|
|
40
33
|
providerProps,
|
|
41
34
|
renderCurrentView,
|
|
42
35
|
ownerState
|
|
43
36
|
} = usePicker(_extends({}, pickerParams, {
|
|
44
37
|
props,
|
|
45
|
-
fieldRef,
|
|
46
38
|
localeText,
|
|
47
39
|
autoFocusView: true,
|
|
40
|
+
viewContainerRole: 'dialog',
|
|
48
41
|
variant: 'desktop'
|
|
49
42
|
}));
|
|
43
|
+
const labelId = providerProps.privateContextValue.labelId;
|
|
44
|
+
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
50
45
|
const Field = slots.field;
|
|
51
46
|
const _useSlotProps = useSlotProps({
|
|
52
47
|
elementType: Field,
|
|
53
48
|
externalSlotProps: innerSlotProps?.field,
|
|
54
|
-
additionalProps: _extends({
|
|
55
|
-
// Internal props
|
|
56
|
-
readOnly,
|
|
57
|
-
autoFocus: autoFocus && !props.open,
|
|
58
|
-
// Forwarded props
|
|
59
|
-
focused: providerProps.contextValue.open ? true : undefined
|
|
60
|
-
}, isToolbarHidden && {
|
|
49
|
+
additionalProps: _extends({}, isToolbarHidden && {
|
|
61
50
|
id: labelId
|
|
62
51
|
}),
|
|
63
52
|
ownerState
|
|
@@ -80,18 +69,12 @@ export const useDesktopPicker = _ref => {
|
|
|
80
69
|
'aria-labelledby': labelledById
|
|
81
70
|
}, innerSlotProps?.popper)
|
|
82
71
|
});
|
|
83
|
-
|
|
84
|
-
// TODO: This `as any` will go away once the field ref is handled by the context.
|
|
85
|
-
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
86
72
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
87
73
|
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
88
74
|
slots: slots,
|
|
89
75
|
slotProps: slotProps,
|
|
90
76
|
inputRef: inputRef,
|
|
91
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
92
|
-
unstableFieldRef: handleFieldRef
|
|
93
|
-
})), /*#__PURE__*/_jsx(PickerPopper, {
|
|
94
|
-
role: "dialog",
|
|
77
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps)), /*#__PURE__*/_jsx(PickerPopper, {
|
|
95
78
|
slots: slots,
|
|
96
79
|
slotProps: slotProps,
|
|
97
80
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
@@ -2,37 +2,29 @@ import * as React from 'react';
|
|
|
2
2
|
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
3
3
|
import { BasePickerProps } from "../../models/props/basePickerProps.js";
|
|
4
4
|
import { PickerPopperSlots, PickerPopperSlotProps } from "../../components/PickerPopper/PickerPopper.js";
|
|
5
|
-
import {
|
|
5
|
+
import { UsePickerParameters, UsePickerNonStaticProps, UsePickerProps } from "../usePicker/index.js";
|
|
6
6
|
import { PickerFieldSlotProps, PickerOwnerState } from "../../../models/index.js";
|
|
7
7
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from "../../../PickersLayout/PickersLayout.types.js";
|
|
8
|
-
import { UsePickerValueNonStaticProps } from "../usePicker/usePickerValue.types.js";
|
|
9
|
-
import { UsePickerViewsProps } from "../usePicker/usePickerViews.js";
|
|
10
8
|
import { DateOrTimeViewWithMeridiem, PickerValue } from "../../models/index.js";
|
|
11
9
|
import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from "../../components/PickerFieldUI.js";
|
|
12
|
-
import { UsePickerProviderNonStaticProps } from "../usePicker/usePickerProvider.js";
|
|
13
10
|
export interface UseDesktopPickerSlots extends Pick<PickerPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
|
|
14
11
|
/**
|
|
15
12
|
* Component used to enter the date with the keyboard.
|
|
16
13
|
*/
|
|
17
14
|
field: React.ElementType;
|
|
18
|
-
/**
|
|
19
|
-
* Form control with an input to render the value inside the default field.
|
|
20
|
-
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
|
|
21
|
-
*/
|
|
22
|
-
textField?: React.ElementType;
|
|
23
15
|
}
|
|
24
16
|
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickerPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
|
25
17
|
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
26
18
|
}
|
|
27
19
|
export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
|
|
28
|
-
export interface DesktopOnlyPickerProps extends
|
|
20
|
+
export interface DesktopOnlyPickerProps extends UsePickerNonStaticProps {
|
|
29
21
|
/**
|
|
30
22
|
* If `true`, the `input` element is focused during the first mount.
|
|
31
23
|
* @default false
|
|
32
24
|
*/
|
|
33
25
|
autoFocus?: boolean;
|
|
34
26
|
}
|
|
35
|
-
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends
|
|
27
|
+
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
|
|
36
28
|
/**
|
|
37
29
|
* Overridable component slots.
|
|
38
30
|
* @default {}
|
|
@@ -44,6 +36,6 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
44
36
|
*/
|
|
45
37
|
slotProps?: UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
46
38
|
}
|
|
47
|
-
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<
|
|
39
|
+
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
|
|
48
40
|
props: TExternalProps;
|
|
49
41
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useField } from "./useField.js";
|
|
2
2
|
export type { FieldValueManager, UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext } from './useField.types';
|
|
3
3
|
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
|
4
|
-
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
5
|
-
export type { PickerFieldPrivateContextValue } from './useFieldInternalPropsWithDefaults';
|
|
4
|
+
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
@@ -29,7 +29,6 @@ export const useField = params => {
|
|
|
29
29
|
onClear
|
|
30
30
|
},
|
|
31
31
|
fieldValueManager,
|
|
32
|
-
valueManager,
|
|
33
32
|
validator,
|
|
34
33
|
getOpenPickerButtonAriaLabel: getOpenDialogAriaText
|
|
35
34
|
} = params;
|
|
@@ -37,6 +36,7 @@ export const useField = params => {
|
|
|
37
36
|
const stateResponse = useFieldState(params);
|
|
38
37
|
const {
|
|
39
38
|
state,
|
|
39
|
+
value,
|
|
40
40
|
activeSectionIndex,
|
|
41
41
|
parsedSelectedSections,
|
|
42
42
|
setSelectedSections,
|
|
@@ -59,7 +59,7 @@ export const useField = params => {
|
|
|
59
59
|
const {
|
|
60
60
|
resetCharacterQuery
|
|
61
61
|
} = characterEditingResponse;
|
|
62
|
-
const areAllSectionsEmpty =
|
|
62
|
+
const areAllSectionsEmpty = React.useMemo(() => state.sections.every(section => section.value === ''), [state.sections]);
|
|
63
63
|
const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;
|
|
64
64
|
const sectionOrder = React.useMemo(() => getSectionOrder(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);
|
|
65
65
|
const {
|
|
@@ -149,12 +149,11 @@ export const useField = params => {
|
|
|
149
149
|
setSelectedSections(activeSectionIndex);
|
|
150
150
|
}
|
|
151
151
|
const activeSection = state.sections[activeSectionIndex];
|
|
152
|
-
const
|
|
153
|
-
const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {
|
|
152
|
+
const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, fieldValueManager.getDateFromSection(value, activeSection), {
|
|
154
153
|
minutesStep
|
|
155
154
|
});
|
|
156
155
|
updateSectionValue({
|
|
157
|
-
activeSection,
|
|
156
|
+
section: activeSection,
|
|
158
157
|
newSectionValue,
|
|
159
158
|
shouldGoToNextSection: false
|
|
160
159
|
});
|
|
@@ -171,7 +170,7 @@ export const useField = params => {
|
|
|
171
170
|
props: internalProps,
|
|
172
171
|
validator,
|
|
173
172
|
timezone,
|
|
174
|
-
value
|
|
173
|
+
value,
|
|
175
174
|
onError: internalProps.onError
|
|
176
175
|
});
|
|
177
176
|
const inputError = React.useMemo(() => {
|
|
@@ -225,8 +224,8 @@ export const useField = params => {
|
|
|
225
224
|
};
|
|
226
225
|
const localizationContext = useLocalizationContext();
|
|
227
226
|
const openPickerAriaLabel = React.useMemo(() => getOpenDialogAriaText(_extends({}, localizationContext, {
|
|
228
|
-
value
|
|
229
|
-
})), [getOpenDialogAriaText,
|
|
227
|
+
value
|
|
228
|
+
})), [getOpenDialogAriaText, value, localizationContext]);
|
|
230
229
|
const commonAdditionalProps = {
|
|
231
230
|
disabled,
|
|
232
231
|
readOnly,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, InferFieldSection, PickerValueType } from "../../../models/index.js";
|
|
3
|
-
import type { PickerValueManager } from '
|
|
3
|
+
import type { PickerValueManager } from '../../models';
|
|
4
4
|
import type { Validator } from '../../../validation';
|
|
5
5
|
import type { UseFieldStateResponse } from './useFieldState';
|
|
6
6
|
import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
|
|
@@ -96,6 +96,10 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
|
|
|
96
96
|
* @default false
|
|
97
97
|
*/
|
|
98
98
|
autoFocus?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If `true`, the component is displayed in focused state.
|
|
101
|
+
*/
|
|
102
|
+
focused?: boolean;
|
|
99
103
|
}
|
|
100
104
|
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> {
|
|
101
105
|
/**
|
|
@@ -110,21 +114,22 @@ export interface UseFieldCommonForwardedProps extends Pick<ExportedPickerFieldUI
|
|
|
110
114
|
export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldCommonForwardedProps & (TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps);
|
|
111
115
|
export interface UseFieldV6ForwardedProps {
|
|
112
116
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
113
|
-
onBlur?:
|
|
117
|
+
onBlur?: React.FocusEventHandler;
|
|
114
118
|
onClick?: React.MouseEventHandler;
|
|
115
|
-
onFocus?:
|
|
119
|
+
onFocus?: React.FocusEventHandler;
|
|
116
120
|
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
|
117
121
|
placeholder?: string;
|
|
118
122
|
}
|
|
119
123
|
interface UseFieldV6AdditionalProps extends Required<Pick<React.InputHTMLAttributes<HTMLInputElement>, 'inputMode' | 'placeholder' | 'value' | 'onChange' | 'autoComplete'>> {
|
|
120
124
|
enableAccessibleFieldDOMStructure: false;
|
|
125
|
+
focused?: boolean;
|
|
121
126
|
}
|
|
122
127
|
export interface UseFieldV7ForwardedProps {
|
|
123
128
|
focused?: boolean;
|
|
124
129
|
sectionListRef?: React.Ref<PickersSectionListRef>;
|
|
125
|
-
onBlur?:
|
|
130
|
+
onBlur?: React.FocusEventHandler;
|
|
126
131
|
onClick?: React.MouseEventHandler;
|
|
127
|
-
onFocus?:
|
|
132
|
+
onFocus?: React.FocusEventHandler;
|
|
128
133
|
onInput?: React.FormEventHandler<HTMLDivElement>;
|
|
129
134
|
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
|
130
135
|
}
|
|
@@ -136,6 +141,7 @@ interface UseFieldV7AdditionalProps {
|
|
|
136
141
|
value: string;
|
|
137
142
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
138
143
|
areAllSectionsEmpty: boolean;
|
|
144
|
+
focused: boolean;
|
|
139
145
|
}
|
|
140
146
|
export type UseFieldResponse<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & {
|
|
141
147
|
[key: string]: any;
|
|
@@ -159,47 +165,17 @@ export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value
|
|
|
159
165
|
export interface FieldChangeHandlerContext<TError> {
|
|
160
166
|
validationError: TError;
|
|
161
167
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Object used to access and update the active date (i.e: the date containing the active section).
|
|
164
|
-
* Mainly useful in the range fields where we need to update the date containing the active section without impacting the other one.
|
|
165
|
-
*/
|
|
166
|
-
interface FieldActiveDateManager<TValue extends PickerValidValue> {
|
|
167
|
-
/**
|
|
168
|
-
* Active date from `state.value`.
|
|
169
|
-
*/
|
|
170
|
-
date: PickerValidDate | null;
|
|
171
|
-
/**
|
|
172
|
-
* Active date from the `state.referenceValue`.
|
|
173
|
-
*/
|
|
174
|
-
referenceDate: PickerValidDate;
|
|
175
|
-
/**
|
|
176
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
177
|
-
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
178
|
-
* @returns {InferFieldSection<TValue>[]} The sections of the active date.
|
|
179
|
-
* Get the sections of the active date.
|
|
180
|
-
*/
|
|
181
|
-
getSections: (sections: InferFieldSection<TValue>[]) => InferFieldSection<TValue>[];
|
|
182
|
-
/**
|
|
183
|
-
* Creates the new value and reference value based on the new active date and the current state.
|
|
184
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
185
|
-
* @param {PickerValidDate | null} newActiveDate The new value of the date containing the active section.
|
|
186
|
-
* @returns {Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
|
|
187
|
-
*/
|
|
188
|
-
getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>;
|
|
189
|
-
}
|
|
190
168
|
export type FieldParsedSelectedSections = number | 'all' | null;
|
|
191
169
|
export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
192
170
|
/**
|
|
193
171
|
* Creates the section list from the current value.
|
|
194
172
|
* The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
|
|
195
173
|
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
196
|
-
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
197
174
|
* @param {TValue} value The current value to generate sections from.
|
|
198
|
-
* @param {
|
|
199
|
-
* @param {(date: PickerValidDate) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
|
175
|
+
* @param {(date: PickerValidDate | null) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
|
200
176
|
* @returns {InferFieldSection<TValue>[]} The new section list.
|
|
201
177
|
*/
|
|
202
|
-
getSectionsFromValue: (
|
|
178
|
+
getSectionsFromValue: (value: TValue, getSectionsFromDate: (date: PickerValidDate | null) => FieldSection[]) => InferFieldSection<TValue>[];
|
|
203
179
|
/**
|
|
204
180
|
* Creates the string value to render in the input based on the current section list.
|
|
205
181
|
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
@@ -216,15 +192,6 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
|
216
192
|
* @returns {string} The string value to render in the input.
|
|
217
193
|
*/
|
|
218
194
|
getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
|
|
219
|
-
/**
|
|
220
|
-
* Returns the manager of the active date.
|
|
221
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
222
|
-
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
223
|
-
* @param {UseFieldState<TValue>} state The current state of the field.
|
|
224
|
-
* @param {InferFieldSection<TValue>} activeSection The active section.
|
|
225
|
-
* @returns {FieldActiveDateManager<TValue>} The manager of the active date.
|
|
226
|
-
*/
|
|
227
|
-
getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue>, activeSection: InferFieldSection<TValue>) => FieldActiveDateManager<TValue>;
|
|
228
195
|
/**
|
|
229
196
|
* Parses a string version (most of the time coming from the input).
|
|
230
197
|
* This method should only be used when the change does not come from a single section.
|
|
@@ -245,9 +212,51 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
|
245
212
|
* @returns {TValue} The new reference value with no invalid date.
|
|
246
213
|
*/
|
|
247
214
|
updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
|
|
215
|
+
/**
|
|
216
|
+
* Extract from the given value the date that contains the given section.
|
|
217
|
+
* @param {TValue} value The value to extract the date from.
|
|
218
|
+
* @param {InferFieldSection<TValue>} section The section to get the date from.
|
|
219
|
+
* @returns {PickerValidDate | null} The date that contains the section.
|
|
220
|
+
*/
|
|
221
|
+
getDateFromSection: (value: TValue, section: InferFieldSection<TValue>) => PickerValidDate | null;
|
|
222
|
+
/**
|
|
223
|
+
* Get the sections of the date that contains the given section.
|
|
224
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
225
|
+
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
226
|
+
* @param {InferFieldSection<TValue>} section A section of the date from which we want to get all the sections.
|
|
227
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the date that contains the section.
|
|
228
|
+
*/
|
|
229
|
+
getDateSectionsFromValue: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
|
|
230
|
+
/**
|
|
231
|
+
* Creates a new value based on the provided date and the current value.
|
|
232
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
233
|
+
* @param {TValue} value The value to update the date in.
|
|
234
|
+
* @param {InferFieldSection<TValue>} section A section of the date we want to update in the value.
|
|
235
|
+
* @param {PickerValidDate | null} date The date that contains the section.
|
|
236
|
+
* @returns {TValue} The updated value.
|
|
237
|
+
*/
|
|
238
|
+
updateDateInValue: (value: TValue, section: InferFieldSection<TValue>, date: PickerValidDate | null) => TValue;
|
|
239
|
+
/**
|
|
240
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
241
|
+
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
242
|
+
* @param {InferFieldSection<TValue>} section A section of the date from which we want to clear all the sections.
|
|
243
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the full value with all the sections of the target date cleared.
|
|
244
|
+
*/
|
|
245
|
+
clearDateSections: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
|
|
248
246
|
}
|
|
249
247
|
export interface UseFieldState<TValue extends PickerValidValue> {
|
|
250
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Last value returned by `useControlledValueWithTimezone`.
|
|
250
|
+
*/
|
|
251
|
+
lastValue: TValue | undefined;
|
|
252
|
+
/**
|
|
253
|
+
* Last value of the parameters used to generate the sections.
|
|
254
|
+
*/
|
|
255
|
+
lastSectionsDependencies: {
|
|
256
|
+
format: string;
|
|
257
|
+
isRtl: boolean;
|
|
258
|
+
locale: any;
|
|
259
|
+
};
|
|
251
260
|
/**
|
|
252
261
|
* Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
|
|
253
262
|
* It is updated whenever we have a valid date (for the range picker we update only the portion of the range that is valid).
|
|
@@ -447,8 +447,11 @@ const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTran
|
|
|
447
447
|
}
|
|
448
448
|
case 'weekDay':
|
|
449
449
|
{
|
|
450
|
+
let dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
|
|
451
|
+
if (section.hasLeadingZerosInInput) {
|
|
452
|
+
dayInWeekStrOfActiveDate = cleanLeadingZeros(dayInWeekStrOfActiveDate, section.maxLength);
|
|
453
|
+
}
|
|
450
454
|
const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);
|
|
451
|
-
const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
|
|
452
455
|
const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
|
|
453
456
|
const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
|
|
454
457
|
const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
|
|
@@ -236,7 +236,7 @@ export const useFieldCharacterEditing = ({
|
|
|
236
236
|
return applyQuery(params, getFirstSectionValueMatchingWithQuery, queryValue => isStringNumber(queryValue, localizedDigits));
|
|
237
237
|
};
|
|
238
238
|
const applyCharacterEditing = useEventCallback(params => {
|
|
239
|
-
const
|
|
239
|
+
const section = sections[params.sectionIndex];
|
|
240
240
|
const isNumericEditing = isStringNumber(params.keyPressed, localizedDigits);
|
|
241
241
|
const response = isNumericEditing ? applyNumericEditing(_extends({}, params, {
|
|
242
242
|
keyPressed: applyLocalizedDigits(params.keyPressed, localizedDigits)
|
|
@@ -246,7 +246,7 @@ export const useFieldCharacterEditing = ({
|
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
updateSectionValue({
|
|
249
|
-
|
|
249
|
+
section,
|
|
250
250
|
newSectionValue: response.sectionValue,
|
|
251
251
|
shouldGoToNextSection: response.shouldGoToNextSection
|
|
252
252
|
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { UseFieldInternalProps } from './useField.types';
|
|
3
1
|
import { PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerFieldInternalPropsWithDefaults } from "../../models/index.js";
|
|
4
|
-
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
|
5
2
|
/**
|
|
6
3
|
* Applies the default values to the field internal props.
|
|
7
4
|
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
8
5
|
* It is only here to allow the migration to be done in smaller steps.
|
|
9
6
|
*/
|
|
10
|
-
export declare function useFieldInternalPropsWithDefaults<TManager extends PickerAnyManager>(
|
|
11
|
-
|
|
12
|
-
internalProps
|
|
13
|
-
}: {
|
|
7
|
+
export declare function useFieldInternalPropsWithDefaults<TManager extends PickerAnyManager>(parameters: UseFieldInternalPropsWithDefaultsParameters<TManager>): PickerManagerFieldInternalPropsWithDefaults<TManager>;
|
|
8
|
+
interface UseFieldInternalPropsWithDefaultsParameters<TManager extends PickerAnyManager> {
|
|
14
9
|
manager: TManager;
|
|
15
10
|
internalProps: PickerManagerFieldInternalProps<TManager>;
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Hack to make sure that on multi input range field, the `useNullableFieldPrivateContext().fieldRef` is only bound to the field matching the range position.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
skipContextFieldRefAssignment?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
4
|
import { useLocalizationContext } from "../useUtils.js";
|
|
4
5
|
import { useNullablePickerContext } from "../useNullablePickerContext.js";
|
|
5
|
-
|
|
6
|
+
import { useNullableFieldPrivateContext } from "../useNullableFieldPrivateContext.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Applies the default values to the field internal props.
|
|
9
10
|
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
10
11
|
* It is only here to allow the migration to be done in smaller steps.
|
|
11
12
|
*/
|
|
12
|
-
export function useFieldInternalPropsWithDefaults({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export function useFieldInternalPropsWithDefaults(parameters) {
|
|
14
|
+
const {
|
|
15
|
+
manager,
|
|
16
|
+
internalProps,
|
|
17
|
+
skipContextFieldRefAssignment
|
|
18
|
+
} = parameters;
|
|
16
19
|
const localizationContext = useLocalizationContext();
|
|
17
20
|
const pickerContext = useNullablePickerContext();
|
|
18
|
-
const fieldPrivateContext =
|
|
21
|
+
const fieldPrivateContext = useNullableFieldPrivateContext();
|
|
22
|
+
const handleFieldRef = useForkRef(internalProps.unstableFieldRef, skipContextFieldRefAssignment ? null : fieldPrivateContext?.fieldRef);
|
|
19
23
|
const setValue = pickerContext?.setValue;
|
|
20
24
|
const handleChangeFromPicker = React.useCallback((newValue, ctx) => {
|
|
21
25
|
return setValue?.(newValue, {
|
|
@@ -33,15 +37,19 @@ export function useFieldInternalPropsWithDefaults({
|
|
|
33
37
|
onChange: handleChangeFromPicker,
|
|
34
38
|
timezone: pickerContext.timezone,
|
|
35
39
|
disabled: pickerContext.disabled,
|
|
40
|
+
readOnly: pickerContext.readOnly,
|
|
41
|
+
autoFocus: pickerContext.autoFocus && !pickerContext.open,
|
|
42
|
+
focused: pickerContext.open ? true : undefined,
|
|
36
43
|
format: pickerContext.fieldFormat,
|
|
37
44
|
formatDensity: fieldPrivateContext.formatDensity,
|
|
38
45
|
enableAccessibleFieldDOMStructure: fieldPrivateContext.enableAccessibleFieldDOMStructure,
|
|
39
46
|
selectedSections: fieldPrivateContext.selectedSections,
|
|
40
|
-
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange
|
|
47
|
+
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange,
|
|
48
|
+
unstableFieldRef: handleFieldRef
|
|
41
49
|
}, internalProps);
|
|
42
50
|
}
|
|
43
51
|
return manager.internal_applyDefaultsToFieldInternalProps(_extends({}, localizationContext, {
|
|
44
52
|
internalProps: internalPropsWithDefaultsFromContext
|
|
45
53
|
}));
|
|
46
|
-
}, [manager, localizationContext, pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker]);
|
|
54
|
+
}, [manager, localizationContext, pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker, handleFieldRef]);
|
|
47
55
|
}
|
|
@@ -5,7 +5,7 @@ export interface UpdateSectionValueParams<TValue extends PickerValidValue> {
|
|
|
5
5
|
/**
|
|
6
6
|
* The section on which we want to apply the new value.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
section: InferFieldSection<TValue>;
|
|
9
9
|
/**
|
|
10
10
|
* Value to apply to the active section.
|
|
11
11
|
*/
|
|
@@ -17,6 +17,7 @@ export interface UpdateSectionValueParams<TValue extends PickerValidValue> {
|
|
|
17
17
|
}
|
|
18
18
|
export interface UseFieldStateResponse<TValue extends PickerValidValue> {
|
|
19
19
|
state: UseFieldState<TValue>;
|
|
20
|
+
value: TValue;
|
|
20
21
|
activeSectionIndex: number | null;
|
|
21
22
|
parsedSelectedSections: FieldParsedSelectedSections;
|
|
22
23
|
setSelectedSections: (sections: FieldSelectedSections) => void;
|