@mui/x-date-pickers 9.0.0-alpha.4 → 9.0.0-rc.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/AdapterDateFnsBase/AdapterDateFnsBase.mjs +1 -1
- package/AdapterDayjs/AdapterDayjs.mjs +1 -1
- package/AdapterLuxon/AdapterLuxon.mjs +1 -1
- package/AdapterMoment/AdapterMoment.mjs +1 -1
- package/AdapterMomentHijri/AdapterMomentHijri.mjs +1 -1
- package/AdapterMomentJalaali/AdapterMomentJalaali.mjs +1 -1
- package/CHANGELOG.md +262 -2
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateCalendar/DateCalendar.mjs +1 -1
- package/DateCalendar/DayCalendar.d.mts +7 -7
- package/DateCalendar/DayCalendar.d.ts +7 -7
- package/DateCalendar/DayCalendar.js +23 -25
- package/DateCalendar/DayCalendar.mjs +23 -25
- package/DateField/DateField.d.mts +1 -1
- package/DateField/DateField.d.ts +1 -1
- package/DateField/DateField.js +22 -4
- package/DateField/DateField.mjs +22 -4
- package/DateField/DateField.types.d.mts +3 -3
- package/DateField/DateField.types.d.ts +3 -3
- package/DateField/useDateField.d.mts +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +1 -1
- package/DateField/useDateField.mjs +1 -1
- package/DatePicker/DatePicker.d.mts +1 -1
- package/DatePicker/DatePicker.d.ts +1 -1
- package/DatePicker/DatePicker.js +1 -5
- package/DatePicker/DatePicker.mjs +1 -5
- package/DatePicker/DatePicker.types.d.mts +3 -3
- package/DatePicker/DatePicker.types.d.ts +3 -3
- package/DateTimeField/DateTimeField.d.mts +1 -1
- package/DateTimeField/DateTimeField.d.ts +1 -1
- package/DateTimeField/DateTimeField.js +22 -4
- package/DateTimeField/DateTimeField.mjs +22 -4
- package/DateTimeField/DateTimeField.types.d.mts +2 -2
- package/DateTimeField/DateTimeField.types.d.ts +2 -2
- package/DateTimeField/useDateTimeField.d.mts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +1 -1
- package/DateTimeField/useDateTimeField.mjs +1 -1
- package/DateTimePicker/DateTimePicker.d.mts +1 -1
- package/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +1 -5
- package/DateTimePicker/DateTimePicker.mjs +1 -5
- package/DateTimePicker/DateTimePicker.types.d.mts +3 -3
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DesktopDatePicker/DesktopDatePicker.d.mts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +1 -5
- package/DesktopDatePicker/DesktopDatePicker.mjs +1 -5
- package/DesktopDatePicker/DesktopDatePicker.types.d.mts +3 -3
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +3 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.mts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -5
- package/DesktopDateTimePicker/DesktopDateTimePicker.mjs +1 -5
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.mts +3 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +3 -3
- package/DesktopTimePicker/DesktopTimePicker.d.mts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.js +0 -4
- package/DesktopTimePicker/DesktopTimePicker.mjs +0 -4
- package/DesktopTimePicker/DesktopTimePicker.types.d.mts +3 -3
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +3 -3
- package/DigitalClock/DigitalClock.d.mts +1 -1
- package/DigitalClock/DigitalClock.d.ts +1 -1
- package/DigitalClock/DigitalClock.js +2 -2
- package/DigitalClock/DigitalClock.mjs +3 -3
- package/MobileDatePicker/MobileDatePicker.d.mts +1 -1
- package/MobileDatePicker/MobileDatePicker.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.js +1 -5
- package/MobileDatePicker/MobileDatePicker.mjs +1 -5
- package/MobileDatePicker/MobileDatePicker.types.d.mts +3 -3
- package/MobileDatePicker/MobileDatePicker.types.d.ts +3 -3
- package/MobileDateTimePicker/MobileDateTimePicker.d.mts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +1 -5
- package/MobileDateTimePicker/MobileDateTimePicker.mjs +1 -5
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.mts +3 -3
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +3 -3
- package/MobileTimePicker/MobileTimePicker.d.mts +1 -1
- package/MobileTimePicker/MobileTimePicker.d.ts +1 -1
- package/MobileTimePicker/MobileTimePicker.js +0 -4
- package/MobileTimePicker/MobileTimePicker.mjs +0 -4
- package/MobileTimePicker/MobileTimePicker.types.d.mts +3 -3
- package/MobileTimePicker/MobileTimePicker.types.d.ts +3 -3
- package/MonthCalendar/MonthCalendarButton.js +2 -2
- package/MonthCalendar/MonthCalendarButton.mjs +3 -3
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +2 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.mjs +3 -3
- package/PickerDay/PickerDay.d.mts +14 -0
- package/PickerDay/PickerDay.d.ts +14 -0
- package/{PickerDay2/PickerDay2.js → PickerDay/PickerDay.js} +110 -45
- package/{PickerDay2/PickerDay2.mjs → PickerDay/PickerDay.mjs} +110 -45
- package/PickerDay/PickerDay.types.d.mts +137 -0
- package/PickerDay/PickerDay.types.d.ts +137 -0
- package/PickerDay/index.d.mts +4 -0
- package/PickerDay/index.d.ts +4 -0
- package/PickerDay/index.js +25 -0
- package/PickerDay/index.mjs +2 -0
- package/{PickerDay2/pickerDay2Classes.d.mts → PickerDay/pickerDayClasses.d.mts} +4 -4
- package/{PickerDay2/pickerDay2Classes.d.ts → PickerDay/pickerDayClasses.d.ts} +4 -4
- package/PickerDay/pickerDayClasses.js +14 -0
- package/PickerDay/pickerDayClasses.mjs +6 -0
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +27 -1
- package/PickersTextField/PickersFilledInput/PickersFilledInput.mjs +27 -1
- package/PickersTextField/PickersInput/PickersInput.js +27 -1
- package/PickersTextField/PickersInput/PickersInput.mjs +27 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.js +26 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.mjs +26 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.mts +26 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +26 -0
- package/PickersTextField/PickersOutlinedInput/Outline.js +1 -1
- package/PickersTextField/PickersOutlinedInput/Outline.mjs +1 -1
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +27 -1
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.mjs +27 -1
- package/PickersTextField/PickersTextField.js +42 -2
- package/PickersTextField/PickersTextField.mjs +42 -2
- package/PickersTextField/PickersTextField.types.d.mts +22 -6
- package/PickersTextField/PickersTextField.types.d.ts +22 -6
- package/StaticDatePicker/StaticDatePicker.js +1 -1
- package/StaticDatePicker/StaticDatePicker.mjs +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.mjs +1 -1
- package/TimeField/TimeField.d.mts +1 -1
- package/TimeField/TimeField.d.ts +1 -1
- package/TimeField/TimeField.js +22 -4
- package/TimeField/TimeField.mjs +22 -4
- package/TimeField/TimeField.types.d.mts +2 -2
- package/TimeField/TimeField.types.d.ts +2 -2
- package/TimeField/useTimeField.d.mts +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePicker.d.mts +1 -1
- package/TimePicker/TimePicker.d.ts +1 -1
- package/TimePicker/TimePicker.js +0 -4
- package/TimePicker/TimePicker.mjs +0 -4
- package/TimePicker/TimePicker.types.d.mts +3 -3
- package/TimePicker/TimePicker.types.d.ts +3 -3
- package/YearCalendar/YearCalendarButton.js +2 -2
- package/YearCalendar/YearCalendarButton.mjs +3 -3
- package/hooks/useParsedFormat.js +5 -7
- package/hooks/useParsedFormat.mjs +5 -7
- package/hooks/useSplitFieldProps.d.mts +1 -1
- package/hooks/useSplitFieldProps.d.ts +1 -1
- package/hooks/useSplitFieldProps.js +1 -1
- package/hooks/useSplitFieldProps.mjs +1 -1
- package/index.d.mts +1 -2
- package/index.d.ts +1 -2
- package/index.js +2 -14
- package/index.mjs +2 -3
- package/internals/components/PickerFieldUI.d.mts +22 -13
- package/internals/components/PickerFieldUI.d.ts +22 -13
- package/internals/components/PickerFieldUI.js +22 -80
- package/internals/components/PickerFieldUI.mjs +22 -80
- package/internals/components/PickerPopper/PickerPopper.js +3 -0
- package/internals/components/PickerPopper/PickerPopper.mjs +3 -0
- package/internals/components/PickersToolbar.js +3 -1
- package/internals/components/PickersToolbar.mjs +3 -1
- package/internals/demo/DemoContainer.js +6 -8
- package/internals/demo/DemoContainer.mjs +6 -8
- package/internals/hooks/PickerDay.types.d.mts +12 -0
- package/internals/hooks/PickerDay.types.d.ts +12 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.mts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.mts +6 -6
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +6 -6
- package/internals/hooks/useField/buildSectionsFromFormat.d.mts +0 -1
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +0 -1
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.mjs +1 -1
- package/internals/hooks/useField/index.d.mts +1 -1
- package/internals/hooks/useField/index.d.ts +1 -1
- package/internals/hooks/useField/index.js +2 -8
- package/internals/hooks/useField/index.mjs +1 -1
- package/internals/hooks/useField/useField.d.mts +2 -2
- package/internals/hooks/useField/useField.d.ts +2 -2
- package/internals/hooks/useField/useField.js +265 -8
- package/internals/hooks/useField/useField.mjs +264 -8
- package/internals/hooks/useField/useField.types.d.mts +11 -50
- package/internals/hooks/useField/useField.types.d.ts +11 -50
- package/internals/hooks/useField/useField.utils.d.mts +2 -3
- package/internals/hooks/useField/useField.utils.d.ts +2 -3
- package/internals/hooks/useField/useField.utils.js +8 -65
- package/internals/hooks/useField/useField.utils.mjs +6 -62
- package/internals/hooks/useField/useFieldHiddenInputProps.d.mts +2 -4
- package/internals/hooks/useField/useFieldHiddenInputProps.d.ts +2 -4
- package/internals/hooks/useField/useFieldHiddenInputProps.js +1 -3
- package/internals/hooks/useField/useFieldHiddenInputProps.mjs +1 -3
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +0 -1
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.mjs +0 -1
- package/internals/hooks/useField/useFieldRootProps.d.mts +5 -5
- package/internals/hooks/useField/useFieldRootProps.d.ts +5 -5
- package/internals/hooks/useField/useFieldRootProps.js +183 -11
- package/internals/hooks/useField/useFieldRootProps.mjs +183 -11
- package/internals/hooks/useField/useFieldSectionContainerProps.d.mts +3 -5
- package/internals/hooks/useField/useFieldSectionContainerProps.d.ts +3 -5
- package/internals/hooks/useField/useFieldSectionContainerProps.js +2 -4
- package/internals/hooks/useField/useFieldSectionContainerProps.mjs +2 -4
- package/internals/hooks/useField/useFieldSectionContentProps.d.mts +6 -7
- package/internals/hooks/useField/useFieldSectionContentProps.d.ts +6 -7
- package/internals/hooks/useField/useFieldSectionContentProps.js +2 -4
- package/internals/hooks/useField/useFieldSectionContentProps.mjs +2 -4
- package/internals/hooks/useField/useFieldState.d.mts +4 -4
- package/internals/hooks/useField/useFieldState.d.ts +4 -4
- package/internals/hooks/useField/useFieldState.js +3 -6
- package/internals/hooks/useField/useFieldState.mjs +3 -6
- package/internals/hooks/useMobilePicker/useMobilePicker.d.mts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.mts +6 -6
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +6 -6
- package/internals/hooks/useNullableFieldPrivateContext.d.mts +1 -1
- package/internals/hooks/useNullableFieldPrivateContext.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +1 -3
- package/internals/hooks/usePicker/usePicker.mjs +1 -3
- package/{PickersDay → internals/hooks}/usePickerDayOwnerState.d.mts +2 -3
- package/{PickersDay → internals/hooks}/usePickerDayOwnerState.d.ts +2 -3
- package/{PickersDay → internals/hooks}/usePickerDayOwnerState.js +3 -5
- package/{PickersDay → internals/hooks}/usePickerDayOwnerState.mjs +3 -5
- package/internals/index.d.mts +4 -4
- package/internals/index.d.ts +4 -4
- package/internals/index.js +9 -9
- package/internals/index.mjs +3 -3
- package/internals/models/manager.d.mts +3 -5
- package/internals/models/manager.d.ts +3 -5
- package/internals/utils/valueManagers.js +1 -2
- package/internals/utils/valueManagers.mjs +2 -3
- package/managers/index.d.mts +2 -2
- package/managers/index.d.ts +2 -2
- package/managers/useDateManager.d.mts +3 -6
- package/managers/useDateManager.d.ts +3 -6
- package/managers/useDateManager.js +2 -6
- package/managers/useDateManager.mjs +2 -6
- package/managers/useDateTimeManager.d.mts +3 -6
- package/managers/useDateTimeManager.d.ts +3 -6
- package/managers/useDateTimeManager.js +2 -6
- package/managers/useDateTimeManager.mjs +2 -6
- package/managers/useTimeManager.d.mts +4 -6
- package/managers/useTimeManager.d.ts +4 -6
- package/managers/useTimeManager.js +1 -3
- package/managers/useTimeManager.mjs +1 -3
- package/models/fields.d.mts +3 -4
- package/models/fields.d.ts +3 -4
- package/models/manager.d.mts +2 -8
- package/models/manager.d.ts +2 -8
- package/package.json +55 -69
- package/themeAugmentation/components.d.mts +4 -8
- package/themeAugmentation/components.d.ts +4 -8
- package/themeAugmentation/overrides.d.mts +2 -4
- package/themeAugmentation/overrides.d.ts +2 -4
- package/themeAugmentation/props.d.mts +5 -7
- package/themeAugmentation/props.d.ts +5 -7
- package/PickerDay2/PickerDay2.d.mts +0 -7
- package/PickerDay2/PickerDay2.d.ts +0 -7
- package/PickerDay2/PickerDay2.types.d.mts +0 -18
- package/PickerDay2/PickerDay2.types.d.ts +0 -18
- package/PickerDay2/index.d.mts +0 -4
- package/PickerDay2/index.d.ts +0 -4
- package/PickerDay2/index.js +0 -25
- package/PickerDay2/index.mjs +0 -2
- package/PickerDay2/pickerDay2Classes.js +0 -14
- package/PickerDay2/pickerDay2Classes.mjs +0 -6
- package/PickersDay/PickersDay.d.mts +0 -15
- package/PickersDay/PickersDay.d.ts +0 -15
- package/PickersDay/PickersDay.js +0 -384
- package/PickersDay/PickersDay.mjs +0 -377
- package/PickersDay/PickersDay.types.d.mts +0 -114
- package/PickersDay/PickersDay.types.d.ts +0 -114
- package/PickersDay/index.d.mts +0 -4
- package/PickersDay/index.d.ts +0 -4
- package/PickersDay/index.js +0 -25
- package/PickersDay/index.mjs +0 -2
- package/PickersDay/pickersDayClasses.d.mts +0 -19
- package/PickersDay/pickersDayClasses.d.ts +0 -19
- package/PickersDay/pickersDayClasses.js +0 -14
- package/PickersDay/pickersDayClasses.mjs +0 -6
- package/internals/hooks/useField/useFieldRootHandleKeyDown.d.mts +0 -16
- package/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts +0 -16
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +0 -211
- package/internals/hooks/useField/useFieldRootHandleKeyDown.mjs +0 -205
- package/internals/hooks/useField/useFieldV6TextField.d.mts +0 -26
- package/internals/hooks/useField/useFieldV6TextField.d.ts +0 -26
- package/internals/hooks/useField/useFieldV6TextField.js +0 -422
- package/internals/hooks/useField/useFieldV6TextField.mjs +0 -413
- package/internals/hooks/useField/useFieldV7TextField.d.mts +0 -3
- package/internals/hooks/useField/useFieldV7TextField.d.ts +0 -3
- package/internals/hooks/useField/useFieldV7TextField.js +0 -272
- package/internals/hooks/useField/useFieldV7TextField.mjs +0 -264
- /package/{PickerDay2/PickerDay2.types.js → PickerDay/PickerDay.types.js} +0 -0
- /package/{PickerDay2/PickerDay2.types.mjs → PickerDay/PickerDay.types.mjs} +0 -0
- /package/{PickersDay/PickersDay.types.js → internals/hooks/PickerDay.types.js} +0 -0
- /package/{PickersDay/PickersDay.types.mjs → internals/hooks/PickerDay.types.mjs} +0 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
2
2
|
import useTimeout from '@mui/utils/useTimeout';
|
|
3
|
-
import { useFieldRootHandleKeyDown } from "./useFieldRootHandleKeyDown.mjs";
|
|
4
3
|
import { getActiveElement } from "../../utils/utils.mjs";
|
|
5
4
|
import { syncSelectionToDOM } from "./syncSelectionToDOM.mjs";
|
|
5
|
+
import { usePickerAdapter } from "../../../hooks/usePickerAdapter.mjs";
|
|
6
|
+
import { cleanDigitSectionValue, getLetterEditingOptions, removeLocalizedDigits } from "./useField.utils.mjs";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Generate the props to pass to the root element of the field.
|
|
9
|
-
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
|
10
|
-
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
|
11
10
|
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
12
11
|
* @returns {UseFieldRootPropsReturnValue} The props to forward to the root element of the field.
|
|
13
12
|
*/
|
|
14
13
|
export function useFieldRootProps(parameters) {
|
|
15
14
|
const {
|
|
16
|
-
manager
|
|
15
|
+
manager: {
|
|
16
|
+
internal_fieldValueManager: fieldValueManager
|
|
17
|
+
},
|
|
17
18
|
focused,
|
|
18
19
|
setFocused,
|
|
19
20
|
domGetters,
|
|
@@ -23,25 +24,118 @@ export function useFieldRootProps(parameters) {
|
|
|
23
24
|
stateResponse: {
|
|
24
25
|
// States and derived states
|
|
25
26
|
parsedSelectedSections,
|
|
27
|
+
sectionsValueBoundaries,
|
|
26
28
|
sectionOrder,
|
|
27
29
|
state,
|
|
30
|
+
value,
|
|
31
|
+
activeSectionIndex,
|
|
32
|
+
localizedDigits,
|
|
33
|
+
timezone,
|
|
28
34
|
// Methods to update the states
|
|
29
35
|
clearValue,
|
|
36
|
+
clearActiveSection,
|
|
30
37
|
setCharacterQuery,
|
|
31
38
|
setSelectedSections,
|
|
32
|
-
updateValueFromValueStr
|
|
39
|
+
updateValueFromValueStr,
|
|
40
|
+
updateSectionValue
|
|
33
41
|
},
|
|
34
42
|
internalPropsWithDefaults: {
|
|
35
43
|
disabled = false,
|
|
36
|
-
readOnly = false
|
|
44
|
+
readOnly = false,
|
|
45
|
+
minutesStep
|
|
37
46
|
}
|
|
38
47
|
} = parameters;
|
|
48
|
+
const adapter = usePickerAdapter();
|
|
49
|
+
const handleKeyDown = useEventCallback(event => {
|
|
50
|
+
if (disabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
// eslint-disable-next-line default-case
|
|
55
|
+
switch (true) {
|
|
56
|
+
// Select all
|
|
57
|
+
case (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey:
|
|
58
|
+
{
|
|
59
|
+
// prevent default to make sure that the next line "select all" while updating
|
|
60
|
+
// the internal state at the same time.
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
setSelectedSections('all');
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Move selection to next section
|
|
67
|
+
case event.key === 'ArrowRight':
|
|
68
|
+
{
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
if (parsedSelectedSections == null) {
|
|
71
|
+
setSelectedSections(sectionOrder.startIndex);
|
|
72
|
+
} else if (parsedSelectedSections === 'all') {
|
|
73
|
+
setSelectedSections(sectionOrder.endIndex);
|
|
74
|
+
} else {
|
|
75
|
+
const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].rightIndex;
|
|
76
|
+
if (nextSectionIndex !== null) {
|
|
77
|
+
setSelectedSections(nextSectionIndex);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Move selection to previous section
|
|
84
|
+
case event.key === 'ArrowLeft':
|
|
85
|
+
{
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
if (parsedSelectedSections == null) {
|
|
88
|
+
setSelectedSections(sectionOrder.endIndex);
|
|
89
|
+
} else if (parsedSelectedSections === 'all') {
|
|
90
|
+
setSelectedSections(sectionOrder.startIndex);
|
|
91
|
+
} else {
|
|
92
|
+
const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].leftIndex;
|
|
93
|
+
if (nextSectionIndex !== null) {
|
|
94
|
+
setSelectedSections(nextSectionIndex);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Reset the value of the selected section
|
|
101
|
+
case event.key === 'Delete':
|
|
102
|
+
{
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
if (readOnly) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (parsedSelectedSections == null || parsedSelectedSections === 'all') {
|
|
108
|
+
clearValue();
|
|
109
|
+
} else {
|
|
110
|
+
clearActiveSection();
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Increment / decrement the selected section value
|
|
116
|
+
case ['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(event.key):
|
|
117
|
+
{
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
if (readOnly || activeSectionIndex == null) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// if all sections are selected, mark the currently editing one as selected
|
|
124
|
+
if (parsedSelectedSections === 'all') {
|
|
125
|
+
setSelectedSections(activeSectionIndex);
|
|
126
|
+
}
|
|
127
|
+
const activeSection = state.sections[activeSectionIndex];
|
|
128
|
+
const newSectionValue = adjustSectionValue(adapter, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, fieldValueManager.getDateFromSection(value, activeSection), {
|
|
129
|
+
minutesStep
|
|
130
|
+
});
|
|
131
|
+
updateSectionValue({
|
|
132
|
+
section: activeSection,
|
|
133
|
+
newSectionValue,
|
|
134
|
+
shouldGoToNextSection: false
|
|
135
|
+
});
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
45
139
|
});
|
|
46
140
|
const containerClickTimeout = useTimeout();
|
|
47
141
|
const handleClick = useEventCallback(event => {
|
|
@@ -148,4 +242,82 @@ export function useFieldRootProps(parameters) {
|
|
|
148
242
|
contentEditable: parsedSelectedSections === 'all',
|
|
149
243
|
tabIndex: internalPropsWithDefaults.disabled || parsedSelectedSections === 0 ? -1 : 0 // TODO: Try to set to undefined when there is a section selected.
|
|
150
244
|
};
|
|
245
|
+
}
|
|
246
|
+
function getDeltaFromKeyCode(keyCode) {
|
|
247
|
+
switch (keyCode) {
|
|
248
|
+
case 'ArrowUp':
|
|
249
|
+
return 1;
|
|
250
|
+
case 'ArrowDown':
|
|
251
|
+
return -1;
|
|
252
|
+
case 'PageUp':
|
|
253
|
+
return 5;
|
|
254
|
+
case 'PageDown':
|
|
255
|
+
return -5;
|
|
256
|
+
default:
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function adjustSectionValue(adapter, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) {
|
|
261
|
+
const delta = getDeltaFromKeyCode(keyCode);
|
|
262
|
+
const isStart = keyCode === 'Home';
|
|
263
|
+
const isEnd = keyCode === 'End';
|
|
264
|
+
const shouldSetAbsolute = section.value === '' || isStart || isEnd;
|
|
265
|
+
const adjustDigitSection = () => {
|
|
266
|
+
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
|
267
|
+
currentDate: activeDate,
|
|
268
|
+
format: section.format,
|
|
269
|
+
contentType: section.contentType
|
|
270
|
+
});
|
|
271
|
+
const getCleanValue = value => cleanDigitSectionValue(adapter, value, sectionBoundaries, localizedDigits, section);
|
|
272
|
+
const step = section.type === 'minutes' && stepsAttributes?.minutesStep ? stepsAttributes.minutesStep : 1;
|
|
273
|
+
let newSectionValueNumber;
|
|
274
|
+
if (shouldSetAbsolute) {
|
|
275
|
+
if (section.type === 'year' && !isEnd && !isStart) {
|
|
276
|
+
return adapter.formatByString(adapter.date(undefined, timezone), section.format);
|
|
277
|
+
}
|
|
278
|
+
if (delta > 0 || isStart) {
|
|
279
|
+
newSectionValueNumber = sectionBoundaries.minimum;
|
|
280
|
+
} else {
|
|
281
|
+
newSectionValueNumber = sectionBoundaries.maximum;
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
const currentSectionValue = parseInt(removeLocalizedDigits(section.value, localizedDigits), 10);
|
|
285
|
+
newSectionValueNumber = currentSectionValue + delta * step;
|
|
286
|
+
}
|
|
287
|
+
if (newSectionValueNumber % step !== 0) {
|
|
288
|
+
if (delta < 0 || isStart) {
|
|
289
|
+
newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)
|
|
290
|
+
}
|
|
291
|
+
if (delta > 0 || isEnd) {
|
|
292
|
+
newSectionValueNumber -= newSectionValueNumber % step;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (newSectionValueNumber > sectionBoundaries.maximum) {
|
|
296
|
+
return getCleanValue(sectionBoundaries.minimum + (newSectionValueNumber - sectionBoundaries.maximum - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
|
|
297
|
+
}
|
|
298
|
+
if (newSectionValueNumber < sectionBoundaries.minimum) {
|
|
299
|
+
return getCleanValue(sectionBoundaries.maximum - (sectionBoundaries.minimum - newSectionValueNumber - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
|
|
300
|
+
}
|
|
301
|
+
return getCleanValue(newSectionValueNumber);
|
|
302
|
+
};
|
|
303
|
+
const adjustLetterSection = () => {
|
|
304
|
+
const options = getLetterEditingOptions(adapter, timezone, section.type, section.format);
|
|
305
|
+
if (options.length === 0) {
|
|
306
|
+
return section.value;
|
|
307
|
+
}
|
|
308
|
+
if (shouldSetAbsolute) {
|
|
309
|
+
if (delta > 0 || isStart) {
|
|
310
|
+
return options[0];
|
|
311
|
+
}
|
|
312
|
+
return options[options.length - 1];
|
|
313
|
+
}
|
|
314
|
+
const currentOptionIndex = options.indexOf(section.value);
|
|
315
|
+
const newOptionIndex = (currentOptionIndex + delta) % options.length;
|
|
316
|
+
const clampedIndex = (newOptionIndex + options.length) % options.length;
|
|
317
|
+
return options[clampedIndex];
|
|
318
|
+
};
|
|
319
|
+
if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {
|
|
320
|
+
return adjustDigitSection();
|
|
321
|
+
}
|
|
322
|
+
return adjustLetterSection();
|
|
151
323
|
}
|
|
@@ -3,15 +3,13 @@ import { UseFieldStateReturnValue } from "./useFieldState.mjs";
|
|
|
3
3
|
import { UseFieldInternalProps } from "./useField.types.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Generate the props to pass to the container element of each section of the field.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
9
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
6
|
+
* @param {UseFieldSectionContainerPropsParameters} parameters The parameters of the hook.
|
|
7
|
+
* @returns {UseFieldSectionContainerPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
10
8
|
*/
|
|
11
9
|
export declare function useFieldSectionContainerProps(parameters: UseFieldSectionContainerPropsParameters): UseFieldSectionContainerPropsReturnValue;
|
|
12
10
|
interface UseFieldSectionContainerPropsParameters {
|
|
13
11
|
stateResponse: UseFieldStateReturnValue<any>;
|
|
14
|
-
internalPropsWithDefaults: UseFieldInternalProps<any, any
|
|
12
|
+
internalPropsWithDefaults: UseFieldInternalProps<any, any>;
|
|
15
13
|
}
|
|
16
14
|
type UseFieldSectionContainerPropsReturnValue = (sectionIndex: number) => React.HTMLAttributes<HTMLSpanElement>;
|
|
17
15
|
export {};
|
|
@@ -3,15 +3,13 @@ import { UseFieldStateReturnValue } from "./useFieldState.js";
|
|
|
3
3
|
import { UseFieldInternalProps } from "./useField.types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Generate the props to pass to the container element of each section of the field.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
9
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
6
|
+
* @param {UseFieldSectionContainerPropsParameters} parameters The parameters of the hook.
|
|
7
|
+
* @returns {UseFieldSectionContainerPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
10
8
|
*/
|
|
11
9
|
export declare function useFieldSectionContainerProps(parameters: UseFieldSectionContainerPropsParameters): UseFieldSectionContainerPropsReturnValue;
|
|
12
10
|
interface UseFieldSectionContainerPropsParameters {
|
|
13
11
|
stateResponse: UseFieldStateReturnValue<any>;
|
|
14
|
-
internalPropsWithDefaults: UseFieldInternalProps<any, any
|
|
12
|
+
internalPropsWithDefaults: UseFieldInternalProps<any, any>;
|
|
15
13
|
}
|
|
16
14
|
type UseFieldSectionContainerPropsReturnValue = (sectionIndex: number) => React.HTMLAttributes<HTMLSpanElement>;
|
|
17
15
|
export {};
|
|
@@ -8,10 +8,8 @@ exports.useFieldSectionContainerProps = useFieldSectionContainerProps;
|
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
/**
|
|
10
10
|
* Generate the props to pass to the container element of each section of the field.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
14
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
11
|
+
* @param {UseFieldSectionContainerPropsParameters} parameters The parameters of the hook.
|
|
12
|
+
* @returns {UseFieldSectionContainerPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
15
13
|
*/
|
|
16
14
|
function useFieldSectionContainerProps(parameters) {
|
|
17
15
|
const {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Generate the props to pass to the container element of each section of the field.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
7
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
4
|
+
* @param {UseFieldSectionContainerPropsParameters} parameters The parameters of the hook.
|
|
5
|
+
* @returns {UseFieldSectionContainerPropsReturnValue} The props to forward to the container element of each section of the field.
|
|
8
6
|
*/
|
|
9
7
|
export function useFieldSectionContainerProps(parameters) {
|
|
10
8
|
const {
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { UseFieldStateReturnValue } from "./useFieldState.mjs";
|
|
2
|
-
import { FieldSection
|
|
2
|
+
import { FieldSection } from "../../../models/index.mjs";
|
|
3
3
|
import { UseFieldDOMGetters, UseFieldInternalProps } from "./useField.types.mjs";
|
|
4
4
|
import { UseFieldCharacterEditingReturnValue } from "./useFieldCharacterEditing.mjs";
|
|
5
|
+
import { PickerAnyManager } from "../../models/index.mjs";
|
|
5
6
|
import { PickersSectionElement } from "../../../PickersSectionList/index.mjs";
|
|
6
7
|
/**
|
|
7
8
|
* Generate the props to pass to the content element of each section of the field.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
11
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
9
|
+
* @param {UseFieldSectionContentPropsParameters} parameters The parameters of the hook.
|
|
10
|
+
* @returns {UseFieldSectionContentPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
12
11
|
*/
|
|
13
12
|
export declare function useFieldSectionContentProps(parameters: UseFieldSectionContentPropsParameters): UseFieldSectionContentPropsReturnValue;
|
|
14
13
|
interface UseFieldSectionContentPropsParameters {
|
|
15
|
-
manager:
|
|
14
|
+
manager: PickerAnyManager;
|
|
16
15
|
stateResponse: UseFieldStateReturnValue<any>;
|
|
17
16
|
applyCharacterEditing: UseFieldCharacterEditingReturnValue;
|
|
18
|
-
internalPropsWithDefaults: UseFieldInternalProps<any, any
|
|
17
|
+
internalPropsWithDefaults: UseFieldInternalProps<any, any>;
|
|
19
18
|
domGetters: UseFieldDOMGetters;
|
|
20
19
|
focused: boolean;
|
|
21
20
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
|
2
|
-
import { FieldSection
|
|
2
|
+
import { FieldSection } from "../../../models/index.js";
|
|
3
3
|
import { UseFieldDOMGetters, UseFieldInternalProps } from "./useField.types.js";
|
|
4
4
|
import { UseFieldCharacterEditingReturnValue } from "./useFieldCharacterEditing.js";
|
|
5
|
+
import { PickerAnyManager } from "../../models/index.js";
|
|
5
6
|
import { PickersSectionElement } from "../../../PickersSectionList/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* Generate the props to pass to the content element of each section of the field.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
11
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
9
|
+
* @param {UseFieldSectionContentPropsParameters} parameters The parameters of the hook.
|
|
10
|
+
* @returns {UseFieldSectionContentPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
12
11
|
*/
|
|
13
12
|
export declare function useFieldSectionContentProps(parameters: UseFieldSectionContentPropsParameters): UseFieldSectionContentPropsReturnValue;
|
|
14
13
|
interface UseFieldSectionContentPropsParameters {
|
|
15
|
-
manager:
|
|
14
|
+
manager: PickerAnyManager;
|
|
16
15
|
stateResponse: UseFieldStateReturnValue<any>;
|
|
17
16
|
applyCharacterEditing: UseFieldCharacterEditingReturnValue;
|
|
18
|
-
internalPropsWithDefaults: UseFieldInternalProps<any, any
|
|
17
|
+
internalPropsWithDefaults: UseFieldInternalProps<any, any>;
|
|
19
18
|
domGetters: UseFieldDOMGetters;
|
|
20
19
|
focused: boolean;
|
|
21
20
|
}
|
|
@@ -12,10 +12,8 @@ var _hooks = require("../../../hooks");
|
|
|
12
12
|
var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
|
13
13
|
/**
|
|
14
14
|
* Generate the props to pass to the content element of each section of the field.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
18
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
15
|
+
* @param {UseFieldSectionContentPropsParameters} parameters The parameters of the hook.
|
|
16
|
+
* @returns {UseFieldSectionContentPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
19
17
|
*/
|
|
20
18
|
function useFieldSectionContentProps(parameters) {
|
|
21
19
|
const adapter = (0, _hooks.usePickerAdapter)();
|
|
@@ -4,10 +4,8 @@ import { usePickerAdapter, usePickerTranslations } from "../../../hooks/index.mj
|
|
|
4
4
|
import { syncSelectionToDOM } from "./syncSelectionToDOM.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* Generate the props to pass to the content element of each section of the field.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
|
10
|
-
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
7
|
+
* @param {UseFieldSectionContentPropsParameters} parameters The parameters of the hook.
|
|
8
|
+
* @returns {UseFieldSectionContentPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
11
9
|
*/
|
|
12
10
|
export function useFieldSectionContentProps(parameters) {
|
|
13
11
|
const adapter = usePickerAdapter();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UseFieldInternalProps, UseFieldState, FieldParsedSelectedSections, FieldSectionsValueBoundaries, SectionOrdering, UseFieldForwardedProps, CharacterEditingQuery } from "./useField.types.mjs";
|
|
2
2
|
import { FieldSelectedSections, PickersTimezone, InferFieldSection, PickerManager } from "../../../models/index.mjs";
|
|
3
3
|
import { PickerValidValue } from "../../models/index.mjs";
|
|
4
|
-
export declare const useFieldState: <TValue extends PickerValidValue,
|
|
5
|
-
interface UseFieldStateParameters<TValue extends PickerValidValue,
|
|
6
|
-
manager: PickerManager<TValue,
|
|
7
|
-
internalPropsWithDefaults: UseFieldInternalProps<TValue,
|
|
4
|
+
export declare const useFieldState: <TValue extends PickerValidValue, TError, TValidationProps extends {}, TForwardedProps extends UseFieldForwardedProps>(parameters: UseFieldStateParameters<TValue, TError, TValidationProps, TForwardedProps>) => UseFieldStateReturnValue<TValue>;
|
|
5
|
+
interface UseFieldStateParameters<TValue extends PickerValidValue, TError, TValidationProps extends {}, TForwardedProps extends UseFieldForwardedProps> {
|
|
6
|
+
manager: PickerManager<TValue, TError, TValidationProps, any>;
|
|
7
|
+
internalPropsWithDefaults: UseFieldInternalProps<TValue, TError> & TValidationProps;
|
|
8
8
|
forwardedProps: TForwardedProps;
|
|
9
9
|
}
|
|
10
10
|
export interface UpdateSectionValueParameters<TValue extends PickerValidValue> {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UseFieldInternalProps, UseFieldState, FieldParsedSelectedSections, FieldSectionsValueBoundaries, SectionOrdering, UseFieldForwardedProps, CharacterEditingQuery } from "./useField.types.js";
|
|
2
2
|
import { FieldSelectedSections, PickersTimezone, InferFieldSection, PickerManager } from "../../../models/index.js";
|
|
3
3
|
import { PickerValidValue } from "../../models/index.js";
|
|
4
|
-
export declare const useFieldState: <TValue extends PickerValidValue,
|
|
5
|
-
interface UseFieldStateParameters<TValue extends PickerValidValue,
|
|
6
|
-
manager: PickerManager<TValue,
|
|
7
|
-
internalPropsWithDefaults: UseFieldInternalProps<TValue,
|
|
4
|
+
export declare const useFieldState: <TValue extends PickerValidValue, TError, TValidationProps extends {}, TForwardedProps extends UseFieldForwardedProps>(parameters: UseFieldStateParameters<TValue, TError, TValidationProps, TForwardedProps>) => UseFieldStateReturnValue<TValue>;
|
|
5
|
+
interface UseFieldStateParameters<TValue extends PickerValidValue, TError, TValidationProps extends {}, TForwardedProps extends UseFieldForwardedProps> {
|
|
6
|
+
manager: PickerManager<TValue, TError, TValidationProps, any>;
|
|
7
|
+
internalPropsWithDefaults: UseFieldInternalProps<TValue, TError> & TValidationProps;
|
|
8
8
|
forwardedProps: TForwardedProps;
|
|
9
9
|
}
|
|
10
10
|
export interface UpdateSectionValueParameters<TValue extends PickerValidValue> {
|
|
@@ -42,8 +42,7 @@ const useFieldState = parameters => {
|
|
|
42
42
|
selectedSections: selectedSectionsProp,
|
|
43
43
|
onSelectedSectionsChange,
|
|
44
44
|
shouldRespectLeadingZeros = false,
|
|
45
|
-
timezone: timezoneProp
|
|
46
|
-
enableAccessibleFieldDOMStructure = true
|
|
45
|
+
timezone: timezoneProp
|
|
47
46
|
},
|
|
48
47
|
forwardedProps: {
|
|
49
48
|
error: errorProp
|
|
@@ -85,9 +84,8 @@ const useFieldState = parameters => {
|
|
|
85
84
|
date,
|
|
86
85
|
formatDensity,
|
|
87
86
|
shouldRespectLeadingZeros,
|
|
88
|
-
enableAccessibleFieldDOMStructure,
|
|
89
87
|
isRtl
|
|
90
|
-
})), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, adapter, formatDensity
|
|
88
|
+
})), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, adapter, formatDensity]);
|
|
91
89
|
const [state, setState] = React.useState(() => {
|
|
92
90
|
const sections = getSectionsFromValue(value);
|
|
93
91
|
(0, _useField.validateSections)(sections, valueType);
|
|
@@ -127,7 +125,7 @@ const useFieldState = parameters => {
|
|
|
127
125
|
};
|
|
128
126
|
const parsedSelectedSections = React.useMemo(() => (0, _useField.parseSelectedSections)(selectedSections, state.sections), [selectedSections, state.sections]);
|
|
129
127
|
const activeSectionIndex = parsedSelectedSections === 'all' ? 0 : parsedSelectedSections;
|
|
130
|
-
const sectionOrder = React.useMemo(() => (0, _useField.getSectionOrder)(state.sections
|
|
128
|
+
const sectionOrder = React.useMemo(() => (0, _useField.getSectionOrder)(state.sections), [state.sections]);
|
|
131
129
|
const areAllSectionsEmpty = React.useMemo(() => state.sections.every(section => section.value === ''), [state.sections]);
|
|
132
130
|
|
|
133
131
|
// When the field loses focus (no active section), consider partially filled sections as invalid.
|
|
@@ -230,7 +228,6 @@ const useFieldState = parameters => {
|
|
|
230
228
|
date,
|
|
231
229
|
formatDensity,
|
|
232
230
|
shouldRespectLeadingZeros,
|
|
233
|
-
enableAccessibleFieldDOMStructure,
|
|
234
231
|
isRtl
|
|
235
232
|
});
|
|
236
233
|
return (0, _useField.mergeDateIntoReferenceDate)(adapter, date, sections, referenceDate, false);
|
|
@@ -35,8 +35,7 @@ export const useFieldState = parameters => {
|
|
|
35
35
|
selectedSections: selectedSectionsProp,
|
|
36
36
|
onSelectedSectionsChange,
|
|
37
37
|
shouldRespectLeadingZeros = false,
|
|
38
|
-
timezone: timezoneProp
|
|
39
|
-
enableAccessibleFieldDOMStructure = true
|
|
38
|
+
timezone: timezoneProp
|
|
40
39
|
},
|
|
41
40
|
forwardedProps: {
|
|
42
41
|
error: errorProp
|
|
@@ -78,9 +77,8 @@ export const useFieldState = parameters => {
|
|
|
78
77
|
date,
|
|
79
78
|
formatDensity,
|
|
80
79
|
shouldRespectLeadingZeros,
|
|
81
|
-
enableAccessibleFieldDOMStructure,
|
|
82
80
|
isRtl
|
|
83
|
-
})), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, adapter, formatDensity
|
|
81
|
+
})), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, adapter, formatDensity]);
|
|
84
82
|
const [state, setState] = React.useState(() => {
|
|
85
83
|
const sections = getSectionsFromValue(value);
|
|
86
84
|
validateSections(sections, valueType);
|
|
@@ -120,7 +118,7 @@ export const useFieldState = parameters => {
|
|
|
120
118
|
};
|
|
121
119
|
const parsedSelectedSections = React.useMemo(() => parseSelectedSections(selectedSections, state.sections), [selectedSections, state.sections]);
|
|
122
120
|
const activeSectionIndex = parsedSelectedSections === 'all' ? 0 : parsedSelectedSections;
|
|
123
|
-
const sectionOrder = React.useMemo(() => getSectionOrder(state.sections
|
|
121
|
+
const sectionOrder = React.useMemo(() => getSectionOrder(state.sections), [state.sections]);
|
|
124
122
|
const areAllSectionsEmpty = React.useMemo(() => state.sections.every(section => section.value === ''), [state.sections]);
|
|
125
123
|
|
|
126
124
|
// When the field loses focus (no active section), consider partially filled sections as invalid.
|
|
@@ -223,7 +221,6 @@ export const useFieldState = parameters => {
|
|
|
223
221
|
date,
|
|
224
222
|
formatDensity,
|
|
225
223
|
shouldRespectLeadingZeros,
|
|
226
|
-
enableAccessibleFieldDOMStructure,
|
|
227
224
|
isRtl
|
|
228
225
|
});
|
|
229
226
|
return mergeDateIntoReferenceDate(adapter, date, sections, referenceDate, false);
|
|
@@ -6,10 +6,10 @@ import { DateOrTimeViewWithMeridiem } from "../../models/index.mjs";
|
|
|
6
6
|
* - MobileDateTimePicker
|
|
7
7
|
* - MobileTimePicker
|
|
8
8
|
*/
|
|
9
|
-
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem,
|
|
9
|
+
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobilePickerProps<TView, any, TExternalProps>>({
|
|
10
10
|
props,
|
|
11
11
|
steps,
|
|
12
12
|
...pickerParams
|
|
13
|
-
}: UseMobilePickerParams<TView,
|
|
13
|
+
}: UseMobilePickerParams<TView, TExternalProps>) => {
|
|
14
14
|
renderPicker: () => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
};
|
|
@@ -6,10 +6,10 @@ import { DateOrTimeViewWithMeridiem } from "../../models/index.js";
|
|
|
6
6
|
* - MobileDateTimePicker
|
|
7
7
|
* - MobileTimePicker
|
|
8
8
|
*/
|
|
9
|
-
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem,
|
|
9
|
+
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobilePickerProps<TView, any, TExternalProps>>({
|
|
10
10
|
props,
|
|
11
11
|
steps,
|
|
12
12
|
...pickerParams
|
|
13
|
-
}: UseMobilePickerParams<TView,
|
|
13
|
+
}: UseMobilePickerParams<TView, TExternalProps>) => {
|
|
14
14
|
renderPicker: () => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
};
|
|
@@ -14,12 +14,12 @@ export interface UseMobilePickerSlots extends PickersModalDialogSlots, ExportedP
|
|
|
14
14
|
*/
|
|
15
15
|
field: React.ElementType;
|
|
16
16
|
}
|
|
17
|
-
export interface ExportedUseMobilePickerSlotProps
|
|
18
|
-
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue
|
|
17
|
+
export interface ExportedUseMobilePickerSlotProps extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
|
18
|
+
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue>, {}, PickerOwnerState>;
|
|
19
19
|
}
|
|
20
|
-
export interface UseMobilePickerSlotProps
|
|
20
|
+
export interface UseMobilePickerSlotProps extends ExportedUseMobilePickerSlotProps, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
|
|
21
21
|
export interface MobileOnlyPickerProps extends UsePickerNonStaticProps {}
|
|
22
|
-
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
22
|
+
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps>, MakeRequired<MobileOnlyPickerProps, 'format'> {
|
|
23
23
|
/**
|
|
24
24
|
* Overridable component slots.
|
|
25
25
|
* @default {}
|
|
@@ -29,9 +29,9 @@ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
29
29
|
* The props used for each component slot.
|
|
30
30
|
* @default {}
|
|
31
31
|
*/
|
|
32
|
-
slotProps?: UseMobilePickerSlotProps
|
|
32
|
+
slotProps?: UseMobilePickerSlotProps;
|
|
33
33
|
}
|
|
34
|
-
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem,
|
|
34
|
+
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobilePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'ref'> {
|
|
35
35
|
props: TExternalProps;
|
|
36
36
|
/**
|
|
37
37
|
* Steps available for the picker.
|
|
@@ -14,12 +14,12 @@ export interface UseMobilePickerSlots extends PickersModalDialogSlots, ExportedP
|
|
|
14
14
|
*/
|
|
15
15
|
field: React.ElementType;
|
|
16
16
|
}
|
|
17
|
-
export interface ExportedUseMobilePickerSlotProps
|
|
18
|
-
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue
|
|
17
|
+
export interface ExportedUseMobilePickerSlotProps extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
|
18
|
+
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue>, {}, PickerOwnerState>;
|
|
19
19
|
}
|
|
20
|
-
export interface UseMobilePickerSlotProps
|
|
20
|
+
export interface UseMobilePickerSlotProps extends ExportedUseMobilePickerSlotProps, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
|
|
21
21
|
export interface MobileOnlyPickerProps extends UsePickerNonStaticProps {}
|
|
22
|
-
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
22
|
+
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps>, MakeRequired<MobileOnlyPickerProps, 'format'> {
|
|
23
23
|
/**
|
|
24
24
|
* Overridable component slots.
|
|
25
25
|
* @default {}
|
|
@@ -29,9 +29,9 @@ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
29
29
|
* The props used for each component slot.
|
|
30
30
|
* @default {}
|
|
31
31
|
*/
|
|
32
|
-
slotProps?: UseMobilePickerSlotProps
|
|
32
|
+
slotProps?: UseMobilePickerSlotProps;
|
|
33
33
|
}
|
|
34
|
-
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem,
|
|
34
|
+
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobilePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'ref'> {
|
|
35
35
|
props: TExternalProps;
|
|
36
36
|
/**
|
|
37
37
|
* Steps available for the picker.
|
|
@@ -4,7 +4,7 @@ import { FieldRef } from "../../models/index.mjs";
|
|
|
4
4
|
import { PickerRangeValue, PickerValue } from "../models/index.mjs";
|
|
5
5
|
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
|
6
6
|
export declare function useNullableFieldPrivateContext(): PickerFieldPrivateContextValue | null;
|
|
7
|
-
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any
|
|
7
|
+
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any>, 'formatDensity' | 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
8
8
|
internalFieldRef: React.RefObject<FieldRef<PickerValue> | FieldRef<PickerRangeValue> | null>;
|
|
9
9
|
fieldRef?: React.RefObject<FieldRef<any> | null>;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import { FieldRef } from "../../models/index.js";
|
|
|
4
4
|
import { PickerRangeValue, PickerValue } from "../models/index.js";
|
|
5
5
|
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
|
6
6
|
export declare function useNullableFieldPrivateContext(): PickerFieldPrivateContextValue | null;
|
|
7
|
-
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any
|
|
7
|
+
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any>, 'formatDensity' | 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
8
8
|
internalFieldRef: React.RefObject<FieldRef<PickerValue> | FieldRef<PickerRangeValue> | null>;
|
|
9
9
|
fieldRef?: React.RefObject<FieldRef<any> | null>;
|
|
10
10
|
}
|