@mui/x-date-pickers 8.0.0-alpha.1 → 8.0.0-alpha.11
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/AdapterDateFns/AdapterDateFns.d.ts +2 -4
- package/AdapterDateFns/AdapterDateFns.js +49 -47
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -1
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -4
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts} +2 -2
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/AdapterDateFnsJalaliV2/index.d.ts +1 -0
- package/AdapterDateFnsJalaliV2/index.js +1 -0
- package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
- package/{AdapterDateFnsV3/AdapterDateFnsV3.d.ts → AdapterDateFnsV2/AdapterDateFnsV2.d.ts} +2 -2
- package/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/AdapterDateFnsV2/index.d.ts +1 -0
- package/AdapterDateFnsV2/index.js +1 -0
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +1 -1
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.js +10 -0
- package/CHANGELOG.md +2007 -230
- package/DateCalendar/DateCalendar.js +41 -22
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/DayCalendar.d.ts +1 -2
- package/DateCalendar/DayCalendar.js +12 -36
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.js +12 -5
- package/DateCalendar/useCalendarState.d.ts +13 -27
- package/DateCalendar/useCalendarState.js +65 -55
- package/DateField/DateField.js +29 -33
- package/DateField/DateField.types.d.ts +7 -15
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +14 -11
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePicker.types.d.ts +7 -3
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +17 -33
- package/DatePicker/shared.d.ts +6 -5
- package/DateTimeField/DateTimeField.js +29 -33
- package/DateTimeField/DateTimeField.types.d.ts +7 -16
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +14 -11
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DateTimePicker/DateTimePicker.types.d.ts +4 -5
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
- package/DateTimePicker/DateTimePickerTabs.js +15 -20
- package/DateTimePicker/DateTimePickerToolbar.d.ts +16 -5
- package/DateTimePicker/DateTimePickerToolbar.js +88 -80
- package/DateTimePicker/shared.d.ts +8 -8
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/DesktopDatePicker/DesktopDatePicker.js +11 -17
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -27
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +9 -34
- package/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/DigitalClock/DigitalClock.js +13 -11
- package/DigitalClock/DigitalClock.types.d.ts +8 -2
- package/MobileDatePicker/MobileDatePicker.js +4 -14
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +4 -14
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.js +4 -14
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- package/MonthCalendar/MonthCalendar.d.ts +1 -1
- package/MonthCalendar/MonthCalendar.js +31 -11
- package/MonthCalendar/MonthCalendar.types.d.ts +2 -2
- package/MonthCalendar/MonthCalendarButton.d.ts +24 -0
- package/{modern/MonthCalendar/PickersMonth.js → MonthCalendar/MonthCalendarButton.js} +20 -61
- package/MonthCalendar/index.d.ts +0 -3
- package/MonthCalendar/index.js +1 -2
- package/MonthCalendar/monthCalendarClasses.d.ts +7 -1
- package/MonthCalendar/monthCalendarClasses.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -7
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -10
- package/PickersActionBar/PickersActionBar.d.ts +6 -7
- package/PickersActionBar/PickersActionBar.js +26 -17
- package/PickersCalendarHeader/PickersCalendarHeader.js +12 -9
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +4 -6
- package/PickersLayout/PickersLayout.d.ts +7 -5
- package/PickersLayout/PickersLayout.js +23 -42
- package/PickersLayout/PickersLayout.types.d.ts +20 -22
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +26 -53
- package/PickersSectionList/PickersSectionList.js +21 -16
- package/PickersSectionList/PickersSectionList.types.d.ts +13 -6
- package/PickersShortcuts/PickersShortcuts.d.ts +9 -11
- package/PickersShortcuts/PickersShortcuts.js +21 -11
- package/PickersShortcuts/index.d.ts +1 -1
- package/PickersTextField/PickersFilledInput/PickersFilledInput.d.ts +7 -0
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.d.ts +1 -1
- package/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/PickersTextField/PickersInput/pickersInputClasses.d.ts +3 -2
- package/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +3 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +45 -38
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +1 -0
- package/PickersTextField/PickersOutlinedInput/Outline.d.ts +0 -1
- package/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/PickersTextField/PickersTextField.js +75 -62
- package/PickersTextField/PickersTextField.types.d.ts +43 -4
- package/PickersTextField/usePickerTextFieldOwnerState.d.ts +4 -0
- package/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/README.md +8 -5
- package/StaticDatePicker/StaticDatePicker.js +2 -2
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
- package/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.js +2 -2
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
- package/TimeClock/Clock.d.ts +4 -0
- package/TimeClock/Clock.js +27 -27
- package/TimeClock/ClockNumber.js +15 -11
- package/TimeClock/ClockPointer.d.ts +6 -1
- package/TimeClock/ClockPointer.js +16 -10
- package/TimeClock/TimeClock.js +30 -12
- package/TimeField/TimeField.js +28 -32
- package/TimeField/TimeField.types.d.ts +7 -16
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +14 -11
- package/TimePicker/TimePicker.js +2 -2
- package/TimePicker/TimePicker.types.d.ts +4 -5
- package/TimePicker/TimePickerToolbar.d.ts +1 -3
- package/TimePicker/TimePickerToolbar.js +36 -51
- package/TimePicker/shared.d.ts +6 -6
- package/YearCalendar/YearCalendar.js +46 -13
- package/YearCalendar/YearCalendar.types.d.ts +2 -2
- package/YearCalendar/YearCalendarButton.d.ts +23 -0
- package/{modern/YearCalendar/PickersYear.js → YearCalendar/YearCalendarButton.js} +20 -59
- package/YearCalendar/index.d.ts +0 -3
- package/YearCalendar/index.js +1 -2
- package/YearCalendar/yearCalendarClasses.d.ts +7 -1
- package/YearCalendar/yearCalendarClasses.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -1
- package/hooks/useClearableField.d.ts +5 -3
- package/hooks/useClearableField.js +4 -2
- package/hooks/useIsValidValue.d.ts +7 -0
- package/hooks/useIsValidValue.js +11 -0
- package/hooks/useParsedFormat.d.ts +9 -7
- package/hooks/useParsedFormat.js +11 -13
- package/hooks/usePickerActionsContext.d.ts +7 -0
- package/hooks/usePickerActionsContext.js +15 -0
- package/hooks/usePickerContext.d.ts +5 -1
- package/hooks/usePickerContext.js +2 -2
- package/hooks/useSplitFieldProps.d.ts +12 -3
- package/hooks/useSplitFieldProps.js +8 -3
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/PickerFieldUI.d.ts +133 -0
- package/internals/components/PickerFieldUI.js +317 -0
- package/internals/components/{PickersPopper.d.ts → PickerPopper/PickerPopper.d.ts} +26 -25
- package/{modern/internals/components/PickersPopper.js → internals/components/PickerPopper/PickerPopper.js} +47 -47
- package/internals/components/PickerPopper/index.d.ts +4 -0
- package/internals/components/PickerPopper/index.js +2 -0
- package/internals/components/PickerPopper/pickerPopperClasses.d.ts +9 -0
- package/internals/components/PickerPopper/pickerPopperClasses.js +6 -0
- package/internals/components/PickerProvider.d.ts +86 -32
- package/internals/components/PickerProvider.js +25 -7
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
- package/internals/components/PickersModalDialog.d.ts +1 -3
- package/internals/components/PickersModalDialog.js +9 -3
- package/internals/components/PickersToolbar.d.ts +2 -3
- package/internals/components/PickersToolbar.js +15 -12
- package/internals/components/PickersToolbarButton.js +4 -6
- package/internals/components/PickersToolbarText.js +11 -13
- package/internals/hooks/date-helpers-hooks.js +4 -3
- package/internals/hooks/useClockReferenceDate.d.ts +2 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +35 -120
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +16 -38
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/index.d.ts +2 -0
- package/internals/hooks/useField/index.js +2 -1
- package/internals/hooks/useField/useField.d.ts +3 -3
- package/internals/hooks/useField/useField.js +17 -4
- package/internals/hooks/useField/useField.types.d.ts +55 -48
- package/internals/hooks/useField/useField.utils.d.ts +4 -3
- package/internals/hooks/useField/useField.utils.js +2 -2
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +15 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +47 -0
- package/internals/hooks/useField/useFieldState.d.ts +9 -8
- package/internals/hooks/useField/useFieldState.js +2 -3
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/internals/hooks/useFieldOwnerState.d.ts +6 -0
- package/internals/hooks/useFieldOwnerState.js +16 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +34 -68
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +15 -22
- package/internals/hooks/useNullablePickerContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerContext.js +10 -0
- package/internals/hooks/useOpenState.d.ts +3 -2
- package/internals/hooks/useOpenState.js +11 -9
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.d.ts +3 -4
- package/internals/hooks/usePicker/usePicker.js +4 -20
- package/internals/hooks/usePicker/usePicker.types.d.ts +10 -10
- package/internals/hooks/usePicker/usePickerProvider.d.ts +45 -10
- package/internals/hooks/usePicker/usePickerProvider.js +50 -16
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +84 -214
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +130 -75
- package/internals/hooks/usePicker/usePickerViews.d.ts +59 -41
- package/internals/hooks/usePicker/usePickerViews.js +31 -20
- package/internals/hooks/useReduceAnimations.d.ts +2 -0
- package/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +5 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.js +7 -12
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +7 -13
- package/internals/hooks/useToolbarOwnerState.d.ts +10 -0
- package/internals/hooks/useToolbarOwnerState.js +13 -0
- package/internals/hooks/useUtils.d.ts +4 -3
- package/internals/hooks/useUtils.js +1 -1
- package/internals/hooks/useValueWithTimezone.d.ts +5 -4
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +27 -18
- package/internals/index.js +13 -8
- package/internals/models/common.d.ts +1 -1
- package/internals/models/fields.d.ts +8 -24
- package/internals/models/index.d.ts +1 -0
- package/internals/models/index.js +2 -1
- package/internals/models/manager.d.ts +15 -0
- package/internals/models/manager.js +1 -0
- package/internals/models/pickers.d.ts +1 -0
- package/internals/models/pickers.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +3 -33
- package/internals/models/props/tabs.d.ts +0 -13
- package/internals/models/props/time.d.ts +2 -1
- package/internals/models/props/toolbar.d.ts +1 -19
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +1 -1
- package/internals/utils/date-utils.js +1 -1
- package/internals/utils/utils.d.ts +3 -0
- package/internals/utils/utils.js +11 -1
- package/internals/utils/valueManagers.d.ts +4 -3
- package/internals/utils/valueManagers.js +4 -4
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/nbNO.js +15 -19
- package/locales/nlNL.js +7 -7
- package/locales/roRO.js +15 -18
- package/locales/utils/getPickersLocalization.d.ts +0 -7
- package/locales/utils/getPickersLocalization.js +0 -13
- package/locales/zhTW.d.ts +80 -0
- package/locales/zhTW.js +73 -0
- package/managers/index.d.ts +6 -0
- package/managers/index.js +3 -0
- package/managers/package.json +6 -0
- package/managers/useDateManager.d.ts +27 -0
- package/managers/useDateManager.js +55 -0
- package/managers/useDateTimeManager.d.ts +28 -0
- package/managers/useDateTimeManager.js +60 -0
- package/managers/useTimeManager.d.ts +28 -0
- package/managers/useTimeManager.js +51 -0
- package/models/adapters.d.ts +5 -5
- package/models/fields.d.ts +33 -9
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/manager.d.ts +87 -0
- package/models/manager.js +1 -0
- package/models/pickers.d.ts +7 -0
- package/models/validation.d.ts +2 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +49 -47
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/modern/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/modern/AdapterDateFnsJalaliV2/index.js +1 -0
- package/modern/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/modern/AdapterDateFnsV2/index.js +1 -0
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +41 -22
- package/modern/DateCalendar/DayCalendar.js +12 -36
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- package/modern/DateCalendar/useCalendarState.js +65 -55
- package/modern/DateField/DateField.js +29 -33
- package/modern/DateField/useDateField.js +14 -11
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DatePicker/DatePickerToolbar.js +17 -33
- package/modern/DateTimeField/DateTimeField.js +29 -33
- package/modern/DateTimeField/useDateTimeField.js +14 -11
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +15 -20
- package/modern/DateTimePicker/DateTimePickerToolbar.js +88 -80
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/modern/DesktopDatePicker/DesktopDatePicker.js +11 -17
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -27
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +9 -34
- package/modern/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/modern/DigitalClock/DigitalClock.js +13 -11
- package/modern/MobileDatePicker/MobileDatePicker.js +4 -14
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +4 -14
- package/modern/MobileTimePicker/MobileTimePicker.js +4 -14
- package/modern/MonthCalendar/MonthCalendar.js +31 -11
- package/{MonthCalendar/PickersMonth.js → modern/MonthCalendar/MonthCalendarButton.js} +20 -61
- package/modern/MonthCalendar/index.js +1 -2
- package/modern/MonthCalendar/monthCalendarClasses.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -7
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -10
- package/modern/PickersActionBar/PickersActionBar.js +26 -17
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +12 -9
- package/modern/PickersLayout/PickersLayout.js +23 -42
- package/modern/PickersLayout/usePickerLayout.js +26 -53
- package/modern/PickersSectionList/PickersSectionList.js +21 -16
- package/modern/PickersShortcuts/PickersShortcuts.js +21 -11
- package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/modern/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/modern/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +45 -38
- package/modern/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/modern/PickersTextField/PickersTextField.js +75 -62
- package/modern/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +2 -2
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/modern/StaticTimePicker/StaticTimePicker.js +2 -2
- package/modern/TimeClock/Clock.js +27 -27
- package/modern/TimeClock/ClockNumber.js +15 -11
- package/modern/TimeClock/ClockPointer.js +16 -10
- package/modern/TimeClock/TimeClock.js +30 -12
- package/modern/TimeField/TimeField.js +28 -32
- package/modern/TimeField/useTimeField.js +14 -11
- package/modern/TimePicker/TimePicker.js +2 -2
- package/modern/TimePicker/TimePickerToolbar.js +36 -51
- package/modern/YearCalendar/YearCalendar.js +46 -13
- package/{YearCalendar/PickersYear.js → modern/YearCalendar/YearCalendarButton.js} +20 -59
- package/modern/YearCalendar/index.js +1 -2
- package/modern/YearCalendar/yearCalendarClasses.js +1 -1
- package/modern/hooks/index.js +3 -1
- package/modern/hooks/useClearableField.js +4 -2
- package/modern/hooks/useIsValidValue.js +11 -0
- package/modern/hooks/useParsedFormat.js +11 -13
- package/modern/hooks/usePickerActionsContext.js +15 -0
- package/modern/hooks/usePickerContext.js +2 -2
- package/modern/hooks/useSplitFieldProps.js +8 -3
- package/modern/index.js +3 -2
- package/modern/internals/components/PickerFieldUI.js +317 -0
- package/{internals/components/PickersPopper.js → modern/internals/components/PickerPopper/PickerPopper.js} +47 -47
- package/modern/internals/components/PickerPopper/index.js +2 -0
- package/modern/internals/components/PickerPopper/pickerPopperClasses.js +6 -0
- package/modern/internals/components/PickerProvider.js +25 -7
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersToolbar.js +15 -12
- package/modern/internals/components/PickersToolbarButton.js +4 -6
- package/modern/internals/components/PickersToolbarText.js +11 -13
- package/modern/internals/hooks/date-helpers-hooks.js +4 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +35 -120
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/modern/internals/hooks/useField/index.js +2 -1
- package/modern/internals/hooks/useField/useField.js +17 -4
- package/modern/internals/hooks/useField/useField.utils.js +2 -2
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +47 -0
- package/modern/internals/hooks/useField/useFieldState.js +2 -3
- package/modern/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/modern/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/modern/internals/hooks/useFieldOwnerState.js +16 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +34 -68
- package/modern/internals/hooks/useNullablePickerContext.js +10 -0
- package/modern/internals/hooks/useOpenState.js +11 -9
- package/modern/internals/hooks/usePicker/usePicker.js +4 -20
- package/modern/internals/hooks/usePicker/usePickerProvider.js +50 -16
- package/modern/internals/hooks/usePicker/usePickerValue.js +84 -214
- package/modern/internals/hooks/usePicker/usePickerViews.js +31 -20
- package/modern/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +5 -2
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +7 -12
- package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/index.js +13 -8
- package/modern/internals/models/index.js +2 -1
- package/modern/internals/models/manager.js +1 -0
- package/modern/internals/models/pickers.js +1 -0
- package/modern/internals/utils/date-utils.js +1 -1
- package/modern/internals/utils/utils.js +11 -1
- package/modern/internals/utils/valueManagers.js +4 -4
- package/modern/locales/index.js +1 -0
- package/modern/locales/nbNO.js +15 -19
- package/modern/locales/nlNL.js +7 -7
- package/modern/locales/roRO.js +15 -18
- package/modern/locales/utils/getPickersLocalization.js +0 -13
- package/modern/locales/zhTW.js +73 -0
- package/modern/managers/index.js +3 -0
- package/modern/managers/useDateManager.js +55 -0
- package/modern/managers/useDateTimeManager.js +60 -0
- package/modern/managers/useTimeManager.js +51 -0
- package/modern/models/index.js +1 -0
- package/modern/models/manager.js +1 -0
- package/modern/validation/useValidation.js +1 -1
- package/modern/validation/validateDate.js +8 -0
- package/modern/validation/validateDateTime.js +8 -0
- package/modern/validation/validateTime.js +8 -0
- package/node/AdapterDateFns/AdapterDateFns.js +97 -97
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +97 -96
- package/node/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +94 -101
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/AdapterDateFnsV2/AdapterDateFnsV2.js +291 -0
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/AdapterMoment/AdapterMoment.js +10 -0
- package/node/DateCalendar/DateCalendar.js +41 -22
- package/node/DateCalendar/DayCalendar.js +12 -37
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- package/node/DateCalendar/useCalendarState.js +66 -57
- package/node/DateField/DateField.js +29 -33
- package/node/DateField/useDateField.js +13 -10
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +17 -33
- package/node/DateTimeField/DateTimeField.js +29 -33
- package/node/DateTimeField/useDateTimeField.js +13 -10
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +15 -20
- package/node/DateTimePicker/DateTimePickerToolbar.js +89 -80
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/node/DesktopDatePicker/DesktopDatePicker.js +11 -17
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -27
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -35
- package/node/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/node/DigitalClock/DigitalClock.js +13 -11
- package/node/MobileDatePicker/MobileDatePicker.js +4 -14
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +4 -14
- package/node/MobileTimePicker/MobileTimePicker.js +4 -14
- package/node/MonthCalendar/MonthCalendar.js +31 -11
- package/node/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/node/MonthCalendar/index.js +1 -8
- package/node/MonthCalendar/monthCalendarClasses.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +11 -7
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -10
- package/node/PickersActionBar/PickersActionBar.js +28 -19
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +12 -9
- package/node/PickersLayout/PickersLayout.js +23 -42
- package/node/PickersLayout/usePickerLayout.js +30 -57
- package/node/PickersSectionList/PickersSectionList.js +21 -16
- package/node/PickersShortcuts/PickersShortcuts.js +21 -11
- package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/node/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/node/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +45 -38
- package/node/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/node/PickersTextField/PickersTextField.js +75 -62
- package/node/PickersTextField/usePickerTextFieldOwnerState.js +18 -0
- package/node/StaticDatePicker/StaticDatePicker.js +2 -2
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/node/StaticTimePicker/StaticTimePicker.js +2 -2
- package/node/TimeClock/Clock.js +27 -27
- package/node/TimeClock/ClockNumber.js +15 -11
- package/node/TimeClock/ClockPointer.js +15 -10
- package/node/TimeClock/TimeClock.js +30 -12
- package/node/TimeField/TimeField.js +28 -32
- package/node/TimeField/useTimeField.js +13 -10
- package/node/TimePicker/TimePicker.js +2 -2
- package/node/TimePicker/TimePickerToolbar.js +36 -51
- package/node/YearCalendar/YearCalendar.js +45 -12
- package/node/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/node/YearCalendar/index.js +1 -8
- package/node/YearCalendar/yearCalendarClasses.js +1 -1
- package/node/hooks/index.js +15 -1
- package/node/hooks/useClearableField.js +4 -2
- package/node/hooks/useIsValidValue.js +18 -0
- package/node/hooks/useParsedFormat.js +11 -13
- package/node/hooks/usePickerActionsContext.js +22 -0
- package/node/hooks/usePickerContext.js +5 -4
- package/node/hooks/useSplitFieldProps.js +7 -2
- package/node/index.js +13 -1
- package/node/internals/components/PickerFieldUI.js +329 -0
- package/node/internals/components/{PickersPopper.js → PickerPopper/PickerPopper.js} +48 -48
- package/node/internals/components/PickerPopper/index.js +25 -0
- package/node/internals/components/PickerPopper/pickerPopperClasses.js +14 -0
- package/node/internals/components/PickerProvider.js +27 -9
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersToolbar.js +15 -12
- package/node/internals/components/PickersToolbarButton.js +4 -6
- package/node/internals/components/PickersToolbarText.js +10 -12
- package/node/internals/hooks/date-helpers-hooks.js +4 -3
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +37 -122
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/node/internals/hooks/useField/index.js +8 -1
- package/node/internals/hooks/useField/useField.js +16 -3
- package/node/internals/hooks/useField/useField.utils.js +2 -2
- package/node/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +56 -0
- package/node/internals/hooks/useField/useFieldState.js +2 -3
- package/node/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/node/internals/hooks/useField/useFieldV7TextField.js +6 -3
- package/node/internals/hooks/useFieldOwnerState.js +24 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +35 -69
- package/node/internals/hooks/useNullablePickerContext.js +16 -0
- package/node/internals/hooks/useOpenState.js +12 -9
- package/node/internals/hooks/usePicker/usePicker.js +4 -20
- package/node/internals/hooks/usePicker/usePickerProvider.js +51 -17
- package/node/internals/hooks/usePicker/usePickerValue.js +84 -213
- package/node/internals/hooks/usePicker/usePickerViews.js +31 -21
- package/node/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +7 -4
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +7 -12
- package/node/internals/hooks/useToolbarOwnerState.js +21 -0
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/index.js +87 -34
- package/node/internals/models/index.js +11 -0
- package/node/internals/models/manager.js +5 -0
- package/node/internals/models/pickers.js +5 -0
- package/node/internals/utils/date-utils.js +1 -1
- package/node/internals/utils/utils.js +14 -2
- package/node/internals/utils/valueManagers.js +4 -4
- package/node/locales/index.js +11 -0
- package/node/locales/nbNO.js +15 -19
- package/node/locales/nlNL.js +7 -7
- package/node/locales/roRO.js +15 -18
- package/node/locales/utils/getPickersLocalization.js +2 -16
- package/node/locales/zhTW.js +79 -0
- package/node/managers/index.js +26 -0
- package/node/managers/useDateManager.js +63 -0
- package/node/managers/useDateTimeManager.js +68 -0
- package/node/managers/useTimeManager.js +59 -0
- package/node/models/index.js +11 -0
- package/node/models/manager.js +5 -0
- package/node/validation/useValidation.js +1 -1
- package/node/validation/validateDate.js +8 -0
- package/node/validation/validateDateTime.js +8 -0
- package/node/validation/validateTime.js +8 -0
- package/package.json +5 -5
- package/themeAugmentation/components.d.ts +3 -11
- package/themeAugmentation/overrides.d.ts +5 -7
- package/themeAugmentation/props.d.ts +7 -9
- package/validation/extractValidationProps.d.ts +1 -1
- package/validation/useValidation.d.ts +7 -6
- package/validation/useValidation.js +1 -1
- package/validation/validateDate.d.ts +12 -3
- package/validation/validateDate.js +8 -0
- package/validation/validateDateTime.d.ts +12 -4
- package/validation/validateDateTime.js +8 -0
- package/validation/validateTime.d.ts +12 -3
- package/validation/validateTime.js +8 -0
- package/AdapterDateFnsJalaliV3/index.d.ts +0 -1
- package/AdapterDateFnsJalaliV3/index.js +0 -1
- package/AdapterDateFnsV3/index.d.ts +0 -1
- package/AdapterDateFnsV3/index.js +0 -1
- package/MonthCalendar/PickersMonth.d.ts +0 -28
- package/MonthCalendar/pickersMonthClasses.d.ts +0 -13
- package/MonthCalendar/pickersMonthClasses.js +0 -5
- package/YearCalendar/PickersYear.d.ts +0 -27
- package/YearCalendar/pickersYearClasses.d.ts +0 -13
- package/YearCalendar/pickersYearClasses.js +0 -5
- package/internals/components/pickersPopperClasses.d.ts +0 -9
- package/internals/components/pickersPopperClasses.js +0 -5
- package/internals/hooks/defaultizedFieldProps.d.ts +0 -18
- package/internals/hooks/defaultizedFieldProps.js +0 -40
- package/internals/hooks/useDefaultReduceAnimations.d.ts +0 -2
- package/internals/hooks/useIsLandscape.d.ts +0 -4
- package/internals/hooks/useIsLandscape.js +0 -35
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -32
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +0 -3
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/modern/AdapterDateFnsJalaliV3/index.js +0 -1
- package/modern/AdapterDateFnsV3/index.js +0 -1
- package/modern/MonthCalendar/pickersMonthClasses.js +0 -5
- package/modern/YearCalendar/pickersYearClasses.js +0 -5
- package/modern/internals/components/pickersPopperClasses.js +0 -5
- package/modern/internals/hooks/defaultizedFieldProps.js +0 -40
- package/modern/internals/hooks/useIsLandscape.js +0 -35
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -299
- package/node/MonthCalendar/pickersMonthClasses.js +0 -12
- package/node/YearCalendar/pickersYearClasses.js +0 -12
- package/node/internals/components/pickersPopperClasses.js +0 -12
- package/node/internals/hooks/defaultizedFieldProps.js +0 -50
- package/node/internals/hooks/useIsLandscape.js +0 -43
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -38
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -52
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, PickerValueType } from '../../../models';
|
|
2
|
+
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, InferFieldSection, PickerValueType } from '../../../models';
|
|
3
3
|
import type { PickerValueManager } from '../usePicker';
|
|
4
4
|
import type { Validator } from '../../../validation';
|
|
5
5
|
import type { UseFieldStateResponse } from './useFieldState';
|
|
6
6
|
import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
|
|
7
7
|
import { PickersSectionElement, PickersSectionListRef } from '../../../PickersSectionList';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
8
|
+
import { FormProps, InferNonNullablePickerValue, PickerValidValue } from '../../models';
|
|
9
|
+
import type { ExportedPickerFieldUIProps } from '../../components/PickerFieldUI';
|
|
10
|
+
import { UseLocalizationContextReturnValue } from '../useUtils';
|
|
11
|
+
export interface UseFieldParams<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>> {
|
|
11
12
|
forwardedProps: TForwardedProps;
|
|
12
13
|
internalProps: TInternalProps;
|
|
13
14
|
valueManager: PickerValueManager<TValue, InferError<TInternalProps>>;
|
|
14
|
-
fieldValueManager: FieldValueManager<TValue
|
|
15
|
+
fieldValueManager: FieldValueManager<TValue>;
|
|
15
16
|
validator: Validator<TValue, InferError<TInternalProps>, TInternalProps>;
|
|
16
17
|
valueType: PickerValueType;
|
|
18
|
+
getOpenPickerButtonAriaLabel: (parameters: UseLocalizationContextReturnValue & {
|
|
19
|
+
value: TValue;
|
|
20
|
+
}) => string;
|
|
17
21
|
}
|
|
18
|
-
export interface UseFieldInternalProps<TValue
|
|
22
|
+
export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
|
|
19
23
|
/**
|
|
20
24
|
* The selected value.
|
|
21
25
|
* Used when the component is controlled.
|
|
@@ -50,10 +54,10 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
|
|
|
50
54
|
*/
|
|
51
55
|
formatDensity?: 'dense' | 'spacious';
|
|
52
56
|
/**
|
|
53
|
-
* If `true`, the format will respect the leading zeroes (
|
|
54
|
-
* If `false`, the format will always add leading zeroes (
|
|
57
|
+
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
|
58
|
+
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
|
55
59
|
*
|
|
56
|
-
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (
|
|
60
|
+
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
|
57
61
|
*
|
|
58
62
|
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
|
59
63
|
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
|
@@ -82,7 +86,7 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
|
|
|
82
86
|
/**
|
|
83
87
|
* The ref object used to imperatively interact with the field.
|
|
84
88
|
*/
|
|
85
|
-
unstableFieldRef?: React.Ref<FieldRef<
|
|
89
|
+
unstableFieldRef?: React.Ref<FieldRef<TValue>>;
|
|
86
90
|
/**
|
|
87
91
|
* @default true
|
|
88
92
|
*/
|
|
@@ -93,9 +97,13 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
|
|
|
93
97
|
*/
|
|
94
98
|
autoFocus?: boolean;
|
|
95
99
|
}
|
|
96
|
-
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any
|
|
100
|
+
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> {
|
|
101
|
+
/**
|
|
102
|
+
* The aria label to set on the button that opens the picker.
|
|
103
|
+
*/
|
|
104
|
+
openPickerAriaLabel: string;
|
|
97
105
|
}
|
|
98
|
-
export interface UseFieldCommonForwardedProps extends
|
|
106
|
+
export interface UseFieldCommonForwardedProps extends Pick<ExportedPickerFieldUIProps, 'clearable' | 'onClear'> {
|
|
99
107
|
onKeyDown?: React.KeyboardEventHandler;
|
|
100
108
|
error?: boolean;
|
|
101
109
|
}
|
|
@@ -113,7 +121,6 @@ interface UseFieldV6AdditionalProps extends Required<Pick<React.InputHTMLAttribu
|
|
|
113
121
|
}
|
|
114
122
|
export interface UseFieldV7ForwardedProps {
|
|
115
123
|
focused?: boolean;
|
|
116
|
-
autoFocus?: boolean;
|
|
117
124
|
sectionListRef?: React.Ref<PickersSectionListRef>;
|
|
118
125
|
onBlur?: () => void;
|
|
119
126
|
onClick?: React.MouseEventHandler;
|
|
@@ -152,7 +159,7 @@ export type FieldSectionsBoundaries = {
|
|
|
152
159
|
maximum: number;
|
|
153
160
|
};
|
|
154
161
|
};
|
|
155
|
-
export type FieldChangeHandler<TValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
|
|
162
|
+
export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
|
|
156
163
|
export interface FieldChangeHandlerContext<TError> {
|
|
157
164
|
validationError: TError;
|
|
158
165
|
}
|
|
@@ -160,7 +167,7 @@ export interface FieldChangeHandlerContext<TError> {
|
|
|
160
167
|
* Object used to access and update the active date (i.e: the date containing the active section).
|
|
161
168
|
* Mainly useful in the range fields where we need to update the date containing the active section without impacting the other one.
|
|
162
169
|
*/
|
|
163
|
-
interface FieldActiveDateManager<TValue
|
|
170
|
+
interface FieldActiveDateManager<TValue extends PickerValidValue> {
|
|
164
171
|
/**
|
|
165
172
|
* Active date from `state.value`.
|
|
166
173
|
*/
|
|
@@ -170,87 +177,87 @@ interface FieldActiveDateManager<TValue, TSection extends FieldSection> {
|
|
|
170
177
|
*/
|
|
171
178
|
referenceDate: PickerValidDate;
|
|
172
179
|
/**
|
|
173
|
-
* @template
|
|
174
|
-
* @param {
|
|
175
|
-
* @returns {
|
|
180
|
+
* @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.
|
|
181
|
+
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
|
182
|
+
* @returns {InferFieldSection<TValue>[]} The sections of the active date.
|
|
176
183
|
* Get the sections of the active date.
|
|
177
184
|
*/
|
|
178
|
-
getSections: (sections:
|
|
185
|
+
getSections: (sections: InferFieldSection<TValue>[]) => InferFieldSection<TValue>[];
|
|
179
186
|
/**
|
|
180
187
|
* Creates the new value and reference value based on the new active date and the current state.
|
|
181
|
-
* @template TValue
|
|
188
|
+
* @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.
|
|
182
189
|
* @param {PickerValidDate | null} newActiveDate The new value of the date containing the active section.
|
|
183
|
-
* @returns {Pick<UseFieldState<TValue
|
|
190
|
+
* @returns {Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
|
|
184
191
|
*/
|
|
185
|
-
getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue
|
|
192
|
+
getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>;
|
|
186
193
|
}
|
|
187
194
|
export type FieldParsedSelectedSections = number | 'all' | null;
|
|
188
|
-
export interface FieldValueManager<TValue
|
|
195
|
+
export interface FieldValueManager<TValue extends PickerValidValue> {
|
|
189
196
|
/**
|
|
190
197
|
* Creates the section list from the current value.
|
|
191
198
|
* The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
|
|
192
|
-
* @template TValue,
|
|
199
|
+
* @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.
|
|
193
200
|
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
194
201
|
* @param {TValue} value The current value to generate sections from.
|
|
195
|
-
* @param {
|
|
202
|
+
* @param {InferFieldSection<TValue>[] | null} fallbackSections The sections to use as a fallback if a date is null or invalid.
|
|
196
203
|
* @param {(date: PickerValidDate) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
|
197
|
-
* @returns {
|
|
204
|
+
* @returns {InferFieldSection<TValue>[]} The new section list.
|
|
198
205
|
*/
|
|
199
|
-
getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections:
|
|
206
|
+
getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections: InferFieldSection<TValue>[] | null, getSectionsFromDate: (date: PickerValidDate) => FieldSection[]) => InferFieldSection<TValue>[];
|
|
200
207
|
/**
|
|
201
208
|
* Creates the string value to render in the input based on the current section list.
|
|
202
|
-
* @template
|
|
203
|
-
* @param {
|
|
209
|
+
* @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.
|
|
210
|
+
* @param {InferFieldSection<TValue>[]} sections The current section list.
|
|
204
211
|
* @param {string} localizedDigits The conversion table from localized to 0-9 digits.
|
|
205
212
|
* @param {boolean} isRtl `true` if the current orientation is "right to left"
|
|
206
213
|
* @returns {string} The string value to render in the input.
|
|
207
214
|
*/
|
|
208
|
-
getV6InputValueFromSections: (sections:
|
|
215
|
+
getV6InputValueFromSections: (sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => string;
|
|
209
216
|
/**
|
|
210
217
|
* Creates the string value to render in the input based on the current section list.
|
|
211
|
-
* @template
|
|
212
|
-
* @param {
|
|
218
|
+
* @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.
|
|
219
|
+
* @param {InferFieldSection<TValue>[]} sections The current section list.
|
|
213
220
|
* @returns {string} The string value to render in the input.
|
|
214
221
|
*/
|
|
215
|
-
getV7HiddenInputValueFromSections: (sections:
|
|
222
|
+
getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
|
|
216
223
|
/**
|
|
217
224
|
* Returns the manager of the active date.
|
|
218
|
-
* @template TValue,
|
|
225
|
+
* @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.
|
|
219
226
|
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
220
|
-
* @param {UseFieldState<TValue
|
|
221
|
-
* @param {
|
|
222
|
-
* @returns {FieldActiveDateManager<TValue
|
|
227
|
+
* @param {UseFieldState<TValue>} state The current state of the field.
|
|
228
|
+
* @param {InferFieldSection<TValue>} activeSection The active section.
|
|
229
|
+
* @returns {FieldActiveDateManager<TValue>} The manager of the active date.
|
|
223
230
|
*/
|
|
224
|
-
getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue
|
|
231
|
+
getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue>, activeSection: InferFieldSection<TValue>) => FieldActiveDateManager<TValue>;
|
|
225
232
|
/**
|
|
226
233
|
* Parses a string version (most of the time coming from the input).
|
|
227
234
|
* This method should only be used when the change does not come from a single section.
|
|
228
|
-
* @template TValue
|
|
235
|
+
* @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.
|
|
229
236
|
* @param {string} valueStr The string value to parse.
|
|
230
237
|
* @param {TValue} referenceValue The reference value currently stored in state.
|
|
231
238
|
* @param {(dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null} parseDate A method to convert a string date into a parsed one.
|
|
232
239
|
* @returns {TValue} The new parsed value.
|
|
233
240
|
*/
|
|
234
|
-
parseValueStr: (valueStr: string, referenceValue: TValue
|
|
241
|
+
parseValueStr: (valueStr: string, referenceValue: InferNonNullablePickerValue<TValue>, parseDate: (dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null) => TValue;
|
|
235
242
|
/**
|
|
236
243
|
* Update the reference value with the new value.
|
|
237
244
|
* This method must make sure that no date inside the returned `referenceValue` is invalid.
|
|
238
|
-
* @template TValue
|
|
245
|
+
* @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.
|
|
239
246
|
* @param {MuiPickersAdapter} utils The utils to manipulate the date.
|
|
240
247
|
* @param {TValue} value The new value from which we want to take all valid dates in the `referenceValue` state.
|
|
241
248
|
* @param {TValue} prevReferenceValue The previous reference value. It is used as a fallback for invalid dates in the new value.
|
|
242
249
|
* @returns {TValue} The new reference value with no invalid date.
|
|
243
250
|
*/
|
|
244
|
-
updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: TValue) => TValue
|
|
251
|
+
updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
|
|
245
252
|
}
|
|
246
|
-
export interface UseFieldState<TValue
|
|
253
|
+
export interface UseFieldState<TValue extends PickerValidValue> {
|
|
247
254
|
value: TValue;
|
|
248
255
|
/**
|
|
249
256
|
* Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
|
|
250
257
|
* It is updated whenever we have a valid date (for the range picker we update only the portion of the range that is valid).
|
|
251
258
|
*/
|
|
252
|
-
referenceValue: TValue
|
|
253
|
-
sections:
|
|
259
|
+
referenceValue: InferNonNullablePickerValue<TValue>;
|
|
260
|
+
sections: InferFieldSection<TValue>[];
|
|
254
261
|
/**
|
|
255
262
|
* Android `onChange` behavior when the input selection is not empty is quite different from a desktop behavior.
|
|
256
263
|
* There are two `onChange` calls:
|
|
@@ -317,13 +324,13 @@ export interface UseFieldTextFieldInteractions {
|
|
|
317
324
|
setSelectedSections: (newSelectedSections: FieldSelectedSections) => void;
|
|
318
325
|
isFieldFocused: () => boolean;
|
|
319
326
|
}
|
|
320
|
-
export type UseFieldTextField<TEnableAccessibleFieldDOMStructure extends boolean> = <TValue
|
|
327
|
+
export type UseFieldTextField<TEnableAccessibleFieldDOMStructure extends boolean> = <TValue extends PickerValidValue, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any> & {
|
|
321
328
|
minutesStep?: number;
|
|
322
|
-
}>(params: UseFieldTextFieldParams<TValue,
|
|
329
|
+
}>(params: UseFieldTextFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => {
|
|
323
330
|
interactions: UseFieldTextFieldInteractions;
|
|
324
331
|
returnedValue: TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6AdditionalProps & Required<UseFieldV6ForwardedProps> : UseFieldV7AdditionalProps & Required<UseFieldV7ForwardedProps>;
|
|
325
332
|
};
|
|
326
|
-
interface UseFieldTextFieldParams<TValue
|
|
333
|
+
interface UseFieldTextFieldParams<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>> extends UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>, UseFieldStateResponse<TValue>, UseFieldCharacterEditingResponse {
|
|
327
334
|
areAllSectionsEmpty: boolean;
|
|
328
335
|
sectionOrder: SectionOrdering;
|
|
329
336
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AvailableAdjustKeyCode, FieldSectionsValueBoundaries, SectionOrdering, FieldSectionValueBoundaries, FieldParsedSelectedSections } from './useField.types';
|
|
2
|
-
import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType } from '../../../models';
|
|
2
|
+
import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType, InferFieldSection } from '../../../models';
|
|
3
|
+
import { PickerValidValue } from '../../models';
|
|
3
4
|
export declare const getDateSectionConfigFromFormatToken: (utils: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
|
|
4
5
|
maxLength: number | undefined;
|
|
5
6
|
};
|
|
@@ -17,7 +18,7 @@ export declare const isStringNumber: (valueStr: string, localizedDigits: string[
|
|
|
17
18
|
*/
|
|
18
19
|
export declare const cleanLeadingZeros: (valueStr: string, size: number) => string;
|
|
19
20
|
export declare const cleanDigitSectionValue: (utils: MuiPickersAdapter, value: number, sectionBoundaries: FieldSectionValueBoundaries<any>, localizedDigits: string[], section: Pick<FieldSection, "format" | "type" | "contentType" | "hasLeadingZerosInFormat" | "hasLeadingZerosInInput" | "maxLength">) => string;
|
|
20
|
-
export declare const adjustSectionValue: <
|
|
21
|
+
export declare const adjustSectionValue: <TValue extends PickerValidValue>(utils: MuiPickersAdapter, timezone: PickersTimezone, section: InferFieldSection<TValue>, keyCode: AvailableAdjustKeyCode, sectionsValueBoundaries: FieldSectionsValueBoundaries, localizedDigits: string[], activeDate: PickerValidDate | null, stepsAttributes?: {
|
|
21
22
|
minutesStep?: number;
|
|
22
23
|
}) => string;
|
|
23
24
|
export declare const getSectionVisibleValue: (section: FieldSection, target: "input-rtl" | "input-ltr" | "non-input", localizedDigits: string[]) => string;
|
|
@@ -31,7 +32,7 @@ export declare const getDateFromDateSections: (utils: MuiPickersAdapter, section
|
|
|
31
32
|
export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
|
|
32
33
|
export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
|
|
33
34
|
export declare const getSectionsBoundaries: (utils: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
|
|
34
|
-
export declare const validateSections: <
|
|
35
|
+
export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
|
|
35
36
|
export declare const mergeDateIntoReferenceDate: (utils: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
|
|
36
37
|
export declare const isAndroid: () => boolean;
|
|
37
38
|
export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
|
|
@@ -361,7 +361,7 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
361
361
|
currentDate
|
|
362
362
|
}) => ({
|
|
363
363
|
minimum: 1,
|
|
364
|
-
maximum:
|
|
364
|
+
maximum: utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,
|
|
365
365
|
longestMonth: longestMonth
|
|
366
366
|
}),
|
|
367
367
|
weekDay: ({
|
|
@@ -509,7 +509,7 @@ export const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections,
|
|
|
509
509
|
}, referenceDate);
|
|
510
510
|
export const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');
|
|
511
511
|
|
|
512
|
-
// TODO
|
|
512
|
+
// TODO v9: Remove
|
|
513
513
|
export const getSectionOrder = (sections, shouldApplyRTL) => {
|
|
514
514
|
const neighbors = {};
|
|
515
515
|
if (!shouldApplyRTL) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PickersTimezone, InferFieldSection } from '../../../models';
|
|
2
2
|
import { FieldSectionsValueBoundaries } from './useField.types';
|
|
3
3
|
import { UpdateSectionValueParams } from './useFieldState';
|
|
4
|
+
import { PickerValidValue } from '../../models';
|
|
4
5
|
export interface ApplyCharacterEditingParams {
|
|
5
6
|
keyPressed: string;
|
|
6
7
|
sectionIndex: number;
|
|
7
8
|
}
|
|
8
|
-
interface UseFieldCharacterEditingParams<
|
|
9
|
-
sections:
|
|
10
|
-
updateSectionValue: (params: UpdateSectionValueParams<
|
|
9
|
+
interface UseFieldCharacterEditingParams<TValue extends PickerValidValue> {
|
|
10
|
+
sections: InferFieldSection<TValue>[];
|
|
11
|
+
updateSectionValue: (params: UpdateSectionValueParams<TValue>) => void;
|
|
11
12
|
sectionsValueBoundaries: FieldSectionsValueBoundaries;
|
|
12
13
|
localizedDigits: string[];
|
|
13
14
|
setTempAndroidValueStr: (newValue: string | null) => void;
|
|
@@ -24,5 +25,5 @@ export interface UseFieldCharacterEditingResponse {
|
|
|
24
25
|
* 1. The numeric editing when the user presses a digit
|
|
25
26
|
* 2. The letter editing when the user presses another key
|
|
26
27
|
*/
|
|
27
|
-
export declare const useFieldCharacterEditing: <
|
|
28
|
+
export declare const useFieldCharacterEditing: <TValue extends PickerValidValue>({ sections, updateSectionValue, sectionsValueBoundaries, localizedDigits, setTempAndroidValueStr, timezone, }: UseFieldCharacterEditingParams<TValue>) => UseFieldCharacterEditingResponse;
|
|
28
29
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { UseFieldInternalProps } from './useField.types';
|
|
3
|
+
import { PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerFieldInternalPropsWithDefaults } from '../../models';
|
|
4
|
+
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Applies the default values to the field internal props.
|
|
7
|
+
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
8
|
+
* It is only here to allow the migration to be done in smaller steps.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useFieldInternalPropsWithDefaults<TManager extends PickerAnyManager>({ manager, internalProps, }: {
|
|
11
|
+
manager: TManager;
|
|
12
|
+
internalProps: PickerManagerFieldInternalProps<TManager>;
|
|
13
|
+
}): PickerManagerFieldInternalPropsWithDefaults<TManager>;
|
|
14
|
+
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any, any>, 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
15
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useLocalizationContext } from "../useUtils.js";
|
|
4
|
+
import { useNullablePickerContext } from "../useNullablePickerContext.js";
|
|
5
|
+
export const PickerFieldPrivateContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Applies the default values to the field internal props.
|
|
9
|
+
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
10
|
+
* It is only here to allow the migration to be done in smaller steps.
|
|
11
|
+
*/
|
|
12
|
+
export function useFieldInternalPropsWithDefaults({
|
|
13
|
+
manager,
|
|
14
|
+
internalProps
|
|
15
|
+
}) {
|
|
16
|
+
const localizationContext = useLocalizationContext();
|
|
17
|
+
const pickerContext = useNullablePickerContext();
|
|
18
|
+
const fieldPrivateContext = React.useContext(PickerFieldPrivateContext);
|
|
19
|
+
const setValue = pickerContext?.setValue;
|
|
20
|
+
const handleChangeFromPicker = React.useCallback((newValue, ctx) => {
|
|
21
|
+
return setValue?.(newValue, {
|
|
22
|
+
validationError: ctx.validationError,
|
|
23
|
+
shouldClose: false
|
|
24
|
+
});
|
|
25
|
+
}, [setValue]);
|
|
26
|
+
return React.useMemo(() => {
|
|
27
|
+
let internalPropsWithDefaultsFromContext = internalProps;
|
|
28
|
+
// If one of the context is null,
|
|
29
|
+
// Then the field is used as a standalone component and the other context will be null as well.
|
|
30
|
+
if (fieldPrivateContext != null && pickerContext != null) {
|
|
31
|
+
internalPropsWithDefaultsFromContext = _extends({
|
|
32
|
+
value: pickerContext.value,
|
|
33
|
+
onChange: handleChangeFromPicker,
|
|
34
|
+
timezone: pickerContext.timezone,
|
|
35
|
+
disabled: pickerContext.disabled,
|
|
36
|
+
format: pickerContext.fieldFormat,
|
|
37
|
+
formatDensity: fieldPrivateContext.formatDensity,
|
|
38
|
+
enableAccessibleFieldDOMStructure: fieldPrivateContext.enableAccessibleFieldDOMStructure,
|
|
39
|
+
selectedSections: fieldPrivateContext.selectedSections,
|
|
40
|
+
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange
|
|
41
|
+
}, internalProps);
|
|
42
|
+
}
|
|
43
|
+
return manager.internal_applyDefaultsToFieldInternalProps(_extends({}, localizationContext, {
|
|
44
|
+
internalProps: internalPropsWithDefaultsFromContext
|
|
45
|
+
}));
|
|
46
|
+
}, [manager, localizationContext, pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker]);
|
|
47
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { UseFieldInternalProps, UseFieldParams, UseFieldState, FieldParsedSelectedSections, FieldSectionsValueBoundaries, UseFieldForwardedProps } from './useField.types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { FieldSelectedSections, PickersTimezone, InferFieldSection } from '../../../models';
|
|
3
|
+
import { PickerValidValue } from '../../models';
|
|
4
|
+
export interface UpdateSectionValueParams<TValue extends PickerValidValue> {
|
|
4
5
|
/**
|
|
5
6
|
* The section on which we want to apply the new value.
|
|
6
7
|
*/
|
|
7
|
-
activeSection:
|
|
8
|
+
activeSection: InferFieldSection<TValue>;
|
|
8
9
|
/**
|
|
9
10
|
* Value to apply to the active section.
|
|
10
11
|
*/
|
|
@@ -14,19 +15,19 @@ export interface UpdateSectionValueParams<TSection extends FieldSection> {
|
|
|
14
15
|
*/
|
|
15
16
|
shouldGoToNextSection: boolean;
|
|
16
17
|
}
|
|
17
|
-
export interface UseFieldStateResponse<TValue
|
|
18
|
-
state: UseFieldState<TValue
|
|
18
|
+
export interface UseFieldStateResponse<TValue extends PickerValidValue> {
|
|
19
|
+
state: UseFieldState<TValue>;
|
|
19
20
|
activeSectionIndex: number | null;
|
|
20
21
|
parsedSelectedSections: FieldParsedSelectedSections;
|
|
21
22
|
setSelectedSections: (sections: FieldSelectedSections) => void;
|
|
22
23
|
clearValue: () => void;
|
|
23
24
|
clearActiveSection: () => void;
|
|
24
|
-
updateSectionValue: (params: UpdateSectionValueParams<
|
|
25
|
+
updateSectionValue: (params: UpdateSectionValueParams<TValue>) => void;
|
|
25
26
|
updateValueFromValueStr: (valueStr: string) => void;
|
|
26
27
|
setTempAndroidValueStr: (tempAndroidValueStr: string | null) => void;
|
|
27
28
|
sectionsValueBoundaries: FieldSectionsValueBoundaries;
|
|
28
|
-
getSectionsFromValue: (value: TValue, fallbackSections?:
|
|
29
|
+
getSectionsFromValue: (value: TValue, fallbackSections?: InferFieldSection<TValue>[] | null) => InferFieldSection<TValue>[];
|
|
29
30
|
localizedDigits: string[];
|
|
30
31
|
timezone: PickersTimezone;
|
|
31
32
|
}
|
|
32
|
-
export declare const useFieldState: <TValue
|
|
33
|
+
export declare const useFieldState: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>>(params: UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldStateResponse<TValue>;
|
|
@@ -64,7 +64,6 @@ export const useFieldState = params => {
|
|
|
64
64
|
const stateWithoutReferenceDate = {
|
|
65
65
|
sections,
|
|
66
66
|
value: valueFromTheOutside,
|
|
67
|
-
referenceValue: valueManager.emptyValue,
|
|
68
67
|
tempValueStrAndroid: null
|
|
69
68
|
};
|
|
70
69
|
const granularity = getSectionTypeGranularity(sections);
|
|
@@ -149,7 +148,7 @@ export const useFieldState = params => {
|
|
|
149
148
|
const updateValueFromValueStr = valueStr => {
|
|
150
149
|
const parseDateStr = (dateStr, referenceDate) => {
|
|
151
150
|
const date = utils.parse(dateStr, format);
|
|
152
|
-
if (
|
|
151
|
+
if (!utils.isValid(date)) {
|
|
153
152
|
return null;
|
|
154
153
|
}
|
|
155
154
|
const sections = buildSectionsFromFormat({
|
|
@@ -200,7 +199,7 @@ export const useFieldState = params => {
|
|
|
200
199
|
* Then we merge the value of the modified sections into the reference date.
|
|
201
200
|
* This makes sure that we don't lose some information of the initial date (like the time on a date field).
|
|
202
201
|
*/
|
|
203
|
-
if (
|
|
202
|
+
if (utils.isValid(newActiveDate)) {
|
|
204
203
|
const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);
|
|
205
204
|
values = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);
|
|
206
205
|
shouldPublish = true;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UseFieldTextField } from './useField.types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { InferFieldSection } from '../../../models';
|
|
3
|
+
import { PickerValidValue } from '../../models';
|
|
4
|
+
type FieldSectionWithPositions<TValue extends PickerValidValue> = InferFieldSection<TValue> & {
|
|
4
5
|
/**
|
|
5
6
|
* Start index of the section in the format
|
|
6
7
|
*/
|
|
@@ -20,6 +21,6 @@ type FieldSectionWithPositions<TSection> = TSection & {
|
|
|
20
21
|
*/
|
|
21
22
|
endInInput: number;
|
|
22
23
|
};
|
|
23
|
-
export declare const addPositionPropertiesToSections: <
|
|
24
|
+
export declare const addPositionPropertiesToSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => FieldSectionWithPositions<TValue>[];
|
|
24
25
|
export declare const useFieldV6TextField: UseFieldTextField<false>;
|
|
25
26
|
export {};
|
|
@@ -35,8 +35,8 @@ export const addPositionPropertiesToSections = (sections, localizedDigits, isRtl
|
|
|
35
35
|
};
|
|
36
36
|
export const useFieldV6TextField = params => {
|
|
37
37
|
const isRtl = useRtl();
|
|
38
|
-
const focusTimeoutRef = React.useRef();
|
|
39
|
-
const selectionSyncTimeoutRef = React.useRef();
|
|
38
|
+
const focusTimeoutRef = React.useRef(undefined);
|
|
39
|
+
const selectionSyncTimeoutRef = React.useRef(undefined);
|
|
40
40
|
const {
|
|
41
41
|
forwardedProps: {
|
|
42
42
|
onFocus,
|
|
@@ -237,6 +237,9 @@ export const useFieldV6TextField = params => {
|
|
|
237
237
|
const shouldUseEventData = eventData && eventData.length > 1;
|
|
238
238
|
const valueStr = shouldUseEventData ? eventData : targetValue;
|
|
239
239
|
const cleanValueStr = cleanString(valueStr);
|
|
240
|
+
if (parsedSelectedSections === 'all') {
|
|
241
|
+
setSelectedSections(activeSectionIndex);
|
|
242
|
+
}
|
|
240
243
|
|
|
241
244
|
// If no section is selected or eventData should be used, we just try to parse the new value
|
|
242
245
|
// This line is mostly triggered by imperative code / application tests.
|
|
@@ -11,7 +11,8 @@ export const useFieldV7TextField = params => {
|
|
|
11
11
|
const {
|
|
12
12
|
internalProps: {
|
|
13
13
|
disabled,
|
|
14
|
-
readOnly = false
|
|
14
|
+
readOnly = false,
|
|
15
|
+
autoFocus = false
|
|
15
16
|
},
|
|
16
17
|
forwardedProps: {
|
|
17
18
|
sectionListRef: inSectionListRef,
|
|
@@ -20,8 +21,7 @@ export const useFieldV7TextField = params => {
|
|
|
20
21
|
onFocus,
|
|
21
22
|
onInput,
|
|
22
23
|
onPaste,
|
|
23
|
-
focused: focusedProp
|
|
24
|
-
autoFocus = false
|
|
24
|
+
focused: focusedProp
|
|
25
25
|
},
|
|
26
26
|
fieldValueManager,
|
|
27
27
|
applyCharacterEditing,
|
|
@@ -176,6 +176,9 @@ export const useFieldV7TextField = params => {
|
|
|
176
176
|
} else if (keyPressed.length > 1) {
|
|
177
177
|
updateValueFromValueStr(keyPressed);
|
|
178
178
|
} else {
|
|
179
|
+
if (parsedSelectedSections === 'all') {
|
|
180
|
+
setSelectedSections(0);
|
|
181
|
+
}
|
|
179
182
|
applyCharacterEditing({
|
|
180
183
|
keyPressed,
|
|
181
184
|
sectionIndex: 0
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FieldOwnerState } from '../../models';
|
|
2
|
+
import { FormProps } from '../models';
|
|
3
|
+
export declare function useFieldOwnerState(parameters: UseFieldOwnerStateParameters): FieldOwnerState;
|
|
4
|
+
export interface UseFieldOwnerStateParameters extends FormProps {
|
|
5
|
+
required?: boolean;
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
4
|
+
import { usePickerPrivateContext } from "./usePickerPrivateContext.js";
|
|
5
|
+
export function useFieldOwnerState(parameters) {
|
|
6
|
+
const {
|
|
7
|
+
ownerState: pickerOwnerState
|
|
8
|
+
} = usePickerPrivateContext();
|
|
9
|
+
const isRtl = useRtl();
|
|
10
|
+
return React.useMemo(() => _extends({}, pickerOwnerState, {
|
|
11
|
+
isFieldDisabled: parameters.disabled ?? false,
|
|
12
|
+
isFieldReadOnly: parameters.readOnly ?? false,
|
|
13
|
+
isFieldRequired: parameters.required ?? false,
|
|
14
|
+
fieldDirection: isRtl ? 'rtl' : 'ltr'
|
|
15
|
+
}), [pickerOwnerState, parameters.disabled, parameters.readOnly, parameters.required, isRtl]);
|
|
16
|
+
}
|
|
@@ -7,6 +7,6 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
|
7
7
|
* - MobileDateTimePicker
|
|
8
8
|
* - MobileTimePicker
|
|
9
9
|
*/
|
|
10
|
-
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({ props,
|
|
10
|
+
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({ props, ...pickerParams }: UseMobilePickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
|
11
11
|
renderPicker: () => React.JSX.Element;
|
|
12
12
|
};
|