@mui/x-date-pickers 8.0.0-alpha.0 → 8.0.0-alpha.10
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 +2215 -119
- package/DateCalendar/DateCalendar.js +5 -4
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/DayCalendar.js +2 -0
- 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 +6 -4
- 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 -45
- 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 +92 -93
- 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 -46
- package/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/DigitalClock/DigitalClock.js +14 -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 +32 -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 +12 -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 +10 -7
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
- package/PickersLayout/PickersLayout.d.ts +7 -5
- package/PickersLayout/PickersLayout.js +23 -54
- package/PickersLayout/PickersLayout.types.d.ts +20 -22
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +26 -57
- 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 +51 -44
- 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 +10 -7
- 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 +28 -27
- package/TimeClock/ClockNumber.js +15 -11
- package/TimeClock/ClockPointer.d.ts +6 -1
- package/TimeClock/ClockPointer.js +16 -10
- package/TimeClock/TimeClock.js +31 -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 +40 -64
- package/TimePicker/shared.d.ts +6 -6
- package/YearCalendar/YearCalendar.js +47 -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 +15 -6
- 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 +94 -14
- package/internals/components/PickerProvider.js +28 -8
- 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 +16 -15
- 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 +36 -121
- 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 +56 -49
- 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 +3 -3
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/internals/hooks/useField/useFieldV7TextField.js +8 -4
- 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 +35 -69
- 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 +10 -29
- package/internals/hooks/usePicker/usePicker.types.d.ts +11 -11
- package/internals/hooks/usePicker/usePickerProvider.d.ts +58 -7
- package/internals/hooks/usePicker/usePickerProvider.js +102 -12
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +100 -218
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +135 -79
- package/internals/hooks/usePicker/usePickerViews.d.ts +59 -40
- package/internals/hooks/usePicker/usePickerViews.js +31 -19
- 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 +8 -13
- 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 +20 -15
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +28 -19
- package/internals/index.js +13 -8
- package/internals/models/common.d.ts +2 -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 -20
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +3 -3
- 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/common.d.ts +1 -0
- package/models/fields.d.ts +33 -10
- 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 +25 -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 +5 -4
- package/modern/DateCalendar/DayCalendar.js +2 -0
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- 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 -45
- 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 +92 -93
- 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 -46
- package/modern/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/modern/DigitalClock/DigitalClock.js +14 -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 +32 -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 +12 -7
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -10
- package/modern/PickersActionBar/PickersActionBar.js +26 -17
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +10 -7
- package/modern/PickersLayout/PickersLayout.js +23 -54
- package/modern/PickersLayout/usePickerLayout.js +26 -57
- 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 +51 -44
- 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 +28 -27
- package/modern/TimeClock/ClockNumber.js +15 -11
- package/modern/TimeClock/ClockPointer.js +16 -10
- package/modern/TimeClock/TimeClock.js +31 -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 +40 -64
- package/modern/YearCalendar/YearCalendar.js +47 -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 +28 -8
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersToolbar.js +16 -15
- 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 +36 -121
- 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 +3 -3
- package/modern/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/modern/internals/hooks/useField/useFieldV7TextField.js +8 -4
- package/modern/internals/hooks/useFieldOwnerState.js +16 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +35 -69
- package/modern/internals/hooks/useNullablePickerContext.js +10 -0
- package/modern/internals/hooks/useOpenState.js +11 -9
- package/modern/internals/hooks/usePicker/usePicker.js +10 -29
- package/modern/internals/hooks/usePicker/usePickerProvider.js +102 -12
- package/modern/internals/hooks/usePicker/usePickerValue.js +100 -218
- package/modern/internals/hooks/usePicker/usePickerViews.js +31 -19
- package/modern/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +5 -2
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +8 -13
- package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/hooks/useValueWithTimezone.js +13 -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 +5 -4
- package/node/DateCalendar/DayCalendar.js +1 -0
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- 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 -45
- 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 +93 -93
- 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 -47
- package/node/DesktopTimePicker/DesktopTimePicker.js +6 -22
- package/node/DigitalClock/DigitalClock.js +14 -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 +32 -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 +12 -7
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +13 -10
- package/node/PickersActionBar/PickersActionBar.js +28 -19
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +10 -7
- package/node/PickersLayout/PickersLayout.js +23 -54
- package/node/PickersLayout/usePickerLayout.js +30 -61
- 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 +51 -44
- 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 +28 -27
- package/node/TimeClock/ClockNumber.js +15 -11
- package/node/TimeClock/ClockPointer.js +15 -10
- package/node/TimeClock/TimeClock.js +31 -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 +40 -64
- package/node/YearCalendar/YearCalendar.js +46 -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 +30 -10
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +12 -11
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersToolbar.js +16 -15
- 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 +38 -123
- 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 +3 -3
- package/node/internals/hooks/useField/useFieldV6TextField.js +5 -2
- package/node/internals/hooks/useField/useFieldV7TextField.js +8 -4
- package/node/internals/hooks/useFieldOwnerState.js +24 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +36 -70
- package/node/internals/hooks/useNullablePickerContext.js +16 -0
- package/node/internals/hooks/useOpenState.js +12 -9
- package/node/internals/hooks/usePicker/usePicker.js +10 -29
- package/node/internals/hooks/usePicker/usePickerProvider.js +105 -12
- package/node/internals/hooks/usePicker/usePickerValue.js +100 -217
- package/node/internals/hooks/usePicker/usePickerViews.js +31 -20
- package/node/internals/hooks/{useDefaultReduceAnimations.js → useReduceAnimations.js} +7 -4
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +8 -13
- package/node/internals/hooks/useToolbarOwnerState.js +21 -0
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/hooks/useValueWithTimezone.js +13 -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 +7 -7
- 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 -33
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
- package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- 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 -34
- package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- 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 -41
- package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -52
|
@@ -5,107 +5,6 @@ import { useOpenState } from "../useOpenState.js";
|
|
|
5
5
|
import { useLocalizationContext, useUtils } from "../useUtils.js";
|
|
6
6
|
import { useValidation } from "../../../validation/index.js";
|
|
7
7
|
import { useValueWithTimezone } from "../useValueWithTimezone.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Decide if the new value should be published
|
|
11
|
-
* The published value will be passed to `onChange` if defined.
|
|
12
|
-
*/
|
|
13
|
-
const shouldPublishValue = params => {
|
|
14
|
-
const {
|
|
15
|
-
action,
|
|
16
|
-
hasChanged,
|
|
17
|
-
dateState,
|
|
18
|
-
isControlled
|
|
19
|
-
} = params;
|
|
20
|
-
const isCurrentValueTheDefaultValue = !isControlled && !dateState.hasBeenModifiedSinceMount;
|
|
21
|
-
|
|
22
|
-
// The field is responsible for only calling `onChange` when needed.
|
|
23
|
-
if (action.name === 'setValueFromField') {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
if (action.name === 'setValueFromAction') {
|
|
27
|
-
// If the component is not controlled, and the value has not been modified since the mount,
|
|
28
|
-
// Then we want to publish the default value whenever the user pressed the "Accept", "Today" or "Clear" button.
|
|
29
|
-
if (isCurrentValueTheDefaultValue && ['accept', 'today', 'clear'].includes(action.pickerAction)) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return hasChanged(dateState.lastPublishedValue);
|
|
33
|
-
}
|
|
34
|
-
if (action.name === 'setValueFromView' && action.selectionState !== 'shallow') {
|
|
35
|
-
// On the first view,
|
|
36
|
-
// If the value is not controlled, then clicking on any value (including the one equal to `defaultValue`) should call `onChange`
|
|
37
|
-
if (isCurrentValueTheDefaultValue) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
return hasChanged(dateState.lastPublishedValue);
|
|
41
|
-
}
|
|
42
|
-
if (action.name === 'setValueFromShortcut') {
|
|
43
|
-
// On the first view,
|
|
44
|
-
// If the value is not controlled, then clicking on any value (including the one equal to `defaultValue`) should call `onChange`
|
|
45
|
-
if (isCurrentValueTheDefaultValue) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return hasChanged(dateState.lastPublishedValue);
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Decide if the new value should be committed.
|
|
55
|
-
* The committed value will be passed to `onAccept` if defined.
|
|
56
|
-
* It will also be used as a reset target when calling the `cancel` picker action (when clicking on the "Cancel" button).
|
|
57
|
-
*/
|
|
58
|
-
const shouldCommitValue = params => {
|
|
59
|
-
const {
|
|
60
|
-
action,
|
|
61
|
-
hasChanged,
|
|
62
|
-
dateState,
|
|
63
|
-
isControlled,
|
|
64
|
-
closeOnSelect
|
|
65
|
-
} = params;
|
|
66
|
-
const isCurrentValueTheDefaultValue = !isControlled && !dateState.hasBeenModifiedSinceMount;
|
|
67
|
-
if (action.name === 'setValueFromAction') {
|
|
68
|
-
// If the component is not controlled, and the value has not been modified since the mount,
|
|
69
|
-
// Then we want to commit the default value whenever the user pressed the "Accept", "Today" or "Clear" button.
|
|
70
|
-
if (isCurrentValueTheDefaultValue && ['accept', 'today', 'clear'].includes(action.pickerAction)) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
return hasChanged(dateState.lastCommittedValue);
|
|
74
|
-
}
|
|
75
|
-
if (action.name === 'setValueFromView' && action.selectionState === 'finish' && closeOnSelect) {
|
|
76
|
-
// On picker where the 1st view is also the last view,
|
|
77
|
-
// If the value is not controlled, then clicking on any value (including the one equal to `defaultValue`) should call `onAccept`
|
|
78
|
-
if (isCurrentValueTheDefaultValue) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
return hasChanged(dateState.lastCommittedValue);
|
|
82
|
-
}
|
|
83
|
-
if (action.name === 'setValueFromShortcut') {
|
|
84
|
-
return action.changeImportance === 'accept' && hasChanged(dateState.lastCommittedValue);
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Decide if the picker should be closed after the value is updated.
|
|
91
|
-
*/
|
|
92
|
-
const shouldClosePicker = params => {
|
|
93
|
-
const {
|
|
94
|
-
action,
|
|
95
|
-
closeOnSelect
|
|
96
|
-
} = params;
|
|
97
|
-
if (action.name === 'setValueFromAction') {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
if (action.name === 'setValueFromView') {
|
|
101
|
-
return action.selectionState === 'finish' && closeOnSelect;
|
|
102
|
-
}
|
|
103
|
-
if (action.name === 'setValueFromShortcut') {
|
|
104
|
-
return action.changeImportance === 'accept';
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
8
|
/**
|
|
110
9
|
* Manage the value lifecycle of all the pickers.
|
|
111
10
|
*/
|
|
@@ -113,7 +12,6 @@ export const usePickerValue = ({
|
|
|
113
12
|
props,
|
|
114
13
|
valueManager,
|
|
115
14
|
valueType,
|
|
116
|
-
wrapperVariant,
|
|
117
15
|
validator
|
|
118
16
|
}) => {
|
|
119
17
|
const {
|
|
@@ -121,8 +19,9 @@ export const usePickerValue = ({
|
|
|
121
19
|
onChange,
|
|
122
20
|
value: inValueWithoutRenderTimezone,
|
|
123
21
|
defaultValue: inDefaultValue,
|
|
124
|
-
closeOnSelect =
|
|
125
|
-
timezone: timezoneProp
|
|
22
|
+
closeOnSelect = false,
|
|
23
|
+
timezone: timezoneProp,
|
|
24
|
+
referenceDate
|
|
126
25
|
} = props;
|
|
127
26
|
const {
|
|
128
27
|
current: defaultValue
|
|
@@ -130,6 +29,7 @@ export const usePickerValue = ({
|
|
|
130
29
|
const {
|
|
131
30
|
current: isControlled
|
|
132
31
|
} = React.useRef(inValueWithoutRenderTimezone !== undefined);
|
|
32
|
+
const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
|
|
133
33
|
|
|
134
34
|
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
135
35
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -149,8 +49,8 @@ export const usePickerValue = ({
|
|
|
149
49
|
const utils = useUtils();
|
|
150
50
|
const adapter = useLocalizationContext();
|
|
151
51
|
const {
|
|
152
|
-
|
|
153
|
-
|
|
52
|
+
open,
|
|
53
|
+
setOpen
|
|
154
54
|
} = useOpenState(props);
|
|
155
55
|
const {
|
|
156
56
|
timezone,
|
|
@@ -160,6 +60,7 @@ export const usePickerValue = ({
|
|
|
160
60
|
timezone: timezoneProp,
|
|
161
61
|
value: inValueWithoutRenderTimezone,
|
|
162
62
|
defaultValue,
|
|
63
|
+
referenceDate,
|
|
163
64
|
onChange,
|
|
164
65
|
valueManager
|
|
165
66
|
});
|
|
@@ -176,10 +77,19 @@ export const usePickerValue = ({
|
|
|
176
77
|
draft: initialValue,
|
|
177
78
|
lastPublishedValue: initialValue,
|
|
178
79
|
lastCommittedValue: initialValue,
|
|
179
|
-
lastControlledValue:
|
|
80
|
+
lastControlledValue: inValueWithoutRenderTimezone,
|
|
180
81
|
hasBeenModifiedSinceMount: false
|
|
181
82
|
};
|
|
182
83
|
});
|
|
84
|
+
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
|
|
85
|
+
if (previousTimezoneProp !== timezoneProp) {
|
|
86
|
+
setPreviousTimezoneProp(timezoneProp);
|
|
87
|
+
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
88
|
+
setDateState(prev => _extends({}, prev, {
|
|
89
|
+
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
183
93
|
const {
|
|
184
94
|
getValidationErrorForNewValue
|
|
185
95
|
} = useValidation({
|
|
@@ -189,50 +99,57 @@ export const usePickerValue = ({
|
|
|
189
99
|
value: dateState.draft,
|
|
190
100
|
onError: props.onError
|
|
191
101
|
});
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
102
|
+
const setValue = useEventCallback((newValue, options) => {
|
|
103
|
+
const {
|
|
104
|
+
changeImportance = 'accept',
|
|
105
|
+
skipPublicationIfPristine = false,
|
|
106
|
+
validationError,
|
|
107
|
+
shortcut,
|
|
108
|
+
shouldClose = changeImportance === 'accept'
|
|
109
|
+
} = options ?? {};
|
|
110
|
+
let shouldPublish;
|
|
111
|
+
let shouldCommit;
|
|
112
|
+
if (!skipPublicationIfPristine && !isControlled && !dateState.hasBeenModifiedSinceMount) {
|
|
113
|
+
// If the value is not controlled and the value has never been modified before,
|
|
114
|
+
// Then clicking on any value (including the one equal to `defaultValue`) should call `onChange` and `onAccept`
|
|
115
|
+
shouldPublish = true;
|
|
116
|
+
shouldCommit = changeImportance === 'accept';
|
|
117
|
+
} else {
|
|
118
|
+
shouldPublish = !valueManager.areValuesEqual(utils, newValue, dateState.lastPublishedValue);
|
|
119
|
+
shouldCommit = changeImportance === 'accept' && !valueManager.areValuesEqual(utils, newValue, dateState.lastCommittedValue);
|
|
120
|
+
}
|
|
203
121
|
setDateState(prev => _extends({}, prev, {
|
|
204
|
-
draft:
|
|
205
|
-
lastPublishedValue: shouldPublish ?
|
|
206
|
-
lastCommittedValue: shouldCommit ?
|
|
122
|
+
draft: newValue,
|
|
123
|
+
lastPublishedValue: shouldPublish ? newValue : prev.lastPublishedValue,
|
|
124
|
+
lastCommittedValue: shouldCommit ? newValue : prev.lastCommittedValue,
|
|
207
125
|
hasBeenModifiedSinceMount: true
|
|
208
126
|
}));
|
|
209
127
|
let cachedContext = null;
|
|
210
128
|
const getContext = () => {
|
|
211
129
|
if (!cachedContext) {
|
|
212
|
-
const validationError = action.name === 'setValueFromField' ? action.context.validationError : getValidationErrorForNewValue(action.value);
|
|
213
130
|
cachedContext = {
|
|
214
|
-
validationError
|
|
131
|
+
validationError: validationError == null ? getValidationErrorForNewValue(newValue) : validationError
|
|
215
132
|
};
|
|
216
|
-
if (
|
|
217
|
-
cachedContext.shortcut =
|
|
133
|
+
if (shortcut) {
|
|
134
|
+
cachedContext.shortcut = shortcut;
|
|
218
135
|
}
|
|
219
136
|
}
|
|
220
137
|
return cachedContext;
|
|
221
138
|
};
|
|
222
139
|
if (shouldPublish) {
|
|
223
|
-
handleValueChange(
|
|
140
|
+
handleValueChange(newValue, getContext());
|
|
224
141
|
}
|
|
225
142
|
if (shouldCommit && onAccept) {
|
|
226
|
-
onAccept(
|
|
143
|
+
onAccept(newValue, getContext());
|
|
227
144
|
}
|
|
228
145
|
if (shouldClose) {
|
|
229
|
-
|
|
146
|
+
setOpen(false);
|
|
230
147
|
}
|
|
231
148
|
});
|
|
232
|
-
if (
|
|
149
|
+
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
|
|
233
150
|
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
|
|
234
151
|
setDateState(prev => _extends({}, prev, {
|
|
235
|
-
lastControlledValue:
|
|
152
|
+
lastControlledValue: inValueWithoutRenderTimezone
|
|
236
153
|
}, isUpdateComingFromPicker ? {} : {
|
|
237
154
|
lastCommittedValue: inValueWithTimezoneToRender,
|
|
238
155
|
lastPublishedValue: inValueWithTimezoneToRender,
|
|
@@ -240,85 +157,6 @@ export const usePickerValue = ({
|
|
|
240
157
|
hasBeenModifiedSinceMount: true
|
|
241
158
|
}));
|
|
242
159
|
}
|
|
243
|
-
const handleClear = useEventCallback(() => {
|
|
244
|
-
updateDate({
|
|
245
|
-
value: valueManager.emptyValue,
|
|
246
|
-
name: 'setValueFromAction',
|
|
247
|
-
pickerAction: 'clear'
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
const handleAccept = useEventCallback(() => {
|
|
251
|
-
updateDate({
|
|
252
|
-
value: dateState.lastPublishedValue,
|
|
253
|
-
name: 'setValueFromAction',
|
|
254
|
-
pickerAction: 'accept'
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
const handleDismiss = useEventCallback(() => {
|
|
258
|
-
updateDate({
|
|
259
|
-
value: dateState.lastPublishedValue,
|
|
260
|
-
name: 'setValueFromAction',
|
|
261
|
-
pickerAction: 'dismiss'
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
const handleCancel = useEventCallback(() => {
|
|
265
|
-
updateDate({
|
|
266
|
-
value: dateState.lastCommittedValue,
|
|
267
|
-
name: 'setValueFromAction',
|
|
268
|
-
pickerAction: 'cancel'
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
const handleSetToday = useEventCallback(() => {
|
|
272
|
-
updateDate({
|
|
273
|
-
value: valueManager.getTodayValue(utils, timezone, valueType),
|
|
274
|
-
name: 'setValueFromAction',
|
|
275
|
-
pickerAction: 'today'
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
const handleOpen = useEventCallback(event => {
|
|
279
|
-
event.preventDefault();
|
|
280
|
-
setIsOpen(true);
|
|
281
|
-
});
|
|
282
|
-
const handleClose = useEventCallback(event => {
|
|
283
|
-
event?.preventDefault();
|
|
284
|
-
setIsOpen(false);
|
|
285
|
-
});
|
|
286
|
-
const handleChange = useEventCallback((newValue, selectionState = 'partial') => updateDate({
|
|
287
|
-
name: 'setValueFromView',
|
|
288
|
-
value: newValue,
|
|
289
|
-
selectionState
|
|
290
|
-
}));
|
|
291
|
-
const handleSelectShortcut = useEventCallback((newValue, changeImportance, shortcut) => updateDate({
|
|
292
|
-
name: 'setValueFromShortcut',
|
|
293
|
-
value: newValue,
|
|
294
|
-
changeImportance,
|
|
295
|
-
shortcut
|
|
296
|
-
}));
|
|
297
|
-
const handleChangeFromField = useEventCallback((newValue, context) => updateDate({
|
|
298
|
-
name: 'setValueFromField',
|
|
299
|
-
value: newValue,
|
|
300
|
-
context
|
|
301
|
-
}));
|
|
302
|
-
const actions = {
|
|
303
|
-
onClear: handleClear,
|
|
304
|
-
onAccept: handleAccept,
|
|
305
|
-
onDismiss: handleDismiss,
|
|
306
|
-
onCancel: handleCancel,
|
|
307
|
-
onSetToday: handleSetToday,
|
|
308
|
-
onOpen: handleOpen,
|
|
309
|
-
onClose: handleClose
|
|
310
|
-
};
|
|
311
|
-
const fieldResponse = {
|
|
312
|
-
value: dateState.draft,
|
|
313
|
-
onChange: handleChangeFromField
|
|
314
|
-
};
|
|
315
|
-
const viewValue = React.useMemo(() => valueManager.cleanValue(utils, dateState.draft), [utils, valueManager, dateState.draft]);
|
|
316
|
-
const viewResponse = {
|
|
317
|
-
value: viewValue,
|
|
318
|
-
onChange: handleChange,
|
|
319
|
-
onClose: handleClose,
|
|
320
|
-
open: isOpen
|
|
321
|
-
};
|
|
322
160
|
const isValid = testedValue => {
|
|
323
161
|
const error = validator({
|
|
324
162
|
adapter,
|
|
@@ -328,17 +166,61 @@ export const usePickerValue = ({
|
|
|
328
166
|
});
|
|
329
167
|
return !valueManager.hasError(error);
|
|
330
168
|
};
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
169
|
+
const clearValue = useEventCallback(() => setValue(valueManager.emptyValue));
|
|
170
|
+
const setValueToToday = useEventCallback(() => setValue(valueManager.getTodayValue(utils, timezone, valueType)));
|
|
171
|
+
const acceptValueChanges = useEventCallback(() => setValue(dateState.lastPublishedValue));
|
|
172
|
+
const cancelValueChanges = useEventCallback(() => setValue(dateState.lastCommittedValue, {
|
|
173
|
+
skipPublicationIfPristine: true
|
|
174
|
+
}));
|
|
175
|
+
const dismissViews = useEventCallback(() => {
|
|
176
|
+
setValue(dateState.lastPublishedValue, {
|
|
177
|
+
skipPublicationIfPristine: true
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
const setValueFromView = useEventCallback((newValue, selectionState = 'partial') => {
|
|
181
|
+
// TODO: Expose a new method (private?) like `setView` that only updates the draft value.
|
|
182
|
+
if (selectionState === 'shallow') {
|
|
183
|
+
setDateState(prev => _extends({}, prev, {
|
|
184
|
+
draft: newValue,
|
|
185
|
+
hasBeenModifiedSinceMount: true
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
setValue(newValue, {
|
|
189
|
+
changeImportance: selectionState === 'finish' && closeOnSelect ? 'accept' : 'set'
|
|
190
|
+
});
|
|
336
191
|
});
|
|
192
|
+
const valueWithoutError = React.useMemo(() => valueManager.cleanValue(utils, dateState.draft), [utils, valueManager, dateState.draft]);
|
|
193
|
+
const viewResponse = {
|
|
194
|
+
value: valueWithoutError,
|
|
195
|
+
onChange: setValueFromView,
|
|
196
|
+
open,
|
|
197
|
+
setOpen
|
|
198
|
+
};
|
|
199
|
+
const actionsContextValue = React.useMemo(() => ({
|
|
200
|
+
setValue,
|
|
201
|
+
setOpen,
|
|
202
|
+
clearValue,
|
|
203
|
+
setValueToToday,
|
|
204
|
+
acceptValueChanges,
|
|
205
|
+
cancelValueChanges
|
|
206
|
+
}), [setValue, setOpen, clearValue, setValueToToday, acceptValueChanges, cancelValueChanges]);
|
|
207
|
+
const contextValue = React.useMemo(() => _extends({}, actionsContextValue, {
|
|
208
|
+
value: dateState.draft,
|
|
209
|
+
timezone,
|
|
210
|
+
open
|
|
211
|
+
}), [actionsContextValue, timezone, open, dateState.draft]);
|
|
212
|
+
const privateContextValue = React.useMemo(() => ({
|
|
213
|
+
dismissViews
|
|
214
|
+
}), [dismissViews]);
|
|
215
|
+
const providerParams = {
|
|
216
|
+
value: dateState.draft,
|
|
217
|
+
contextValue,
|
|
218
|
+
actionsContextValue,
|
|
219
|
+
privateContextValue,
|
|
220
|
+
isValidContextValue: isValid
|
|
221
|
+
};
|
|
337
222
|
return {
|
|
338
|
-
open: isOpen,
|
|
339
|
-
fieldProps: fieldResponse,
|
|
340
223
|
viewProps: viewResponse,
|
|
341
|
-
|
|
342
|
-
actions
|
|
224
|
+
provider: providerParams
|
|
343
225
|
};
|
|
344
226
|
};
|
|
@@ -11,14 +11,10 @@ import { isTimeView } from "../../utils/time-utils.js";
|
|
|
11
11
|
* Props used to handle the views that are common to all pickers.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Props used to handle the views of the pickers.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* Props used to handle the value of the pickers.
|
|
20
16
|
*/
|
|
21
|
-
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
18
|
/**
|
|
23
19
|
* Manage the views of all the pickers:
|
|
24
20
|
* - Handles the view switch
|
|
@@ -28,15 +24,15 @@ import { isTimeView } from "../../utils/time-utils.js";
|
|
|
28
24
|
export const usePickerViews = ({
|
|
29
25
|
props,
|
|
30
26
|
propsFromPickerValue,
|
|
31
|
-
additionalViewProps,
|
|
32
27
|
autoFocusView,
|
|
33
|
-
rendererInterceptor,
|
|
28
|
+
rendererInterceptor: RendererInterceptor,
|
|
34
29
|
fieldRef
|
|
35
30
|
}) => {
|
|
36
31
|
const {
|
|
37
32
|
onChange,
|
|
33
|
+
value,
|
|
38
34
|
open,
|
|
39
|
-
|
|
35
|
+
setOpen
|
|
40
36
|
} = propsFromPickerValue;
|
|
41
37
|
const {
|
|
42
38
|
view: inView,
|
|
@@ -88,7 +84,7 @@ export const usePickerViews = ({
|
|
|
88
84
|
return acc;
|
|
89
85
|
}, 0), [viewRenderers, views]);
|
|
90
86
|
const currentViewMode = viewModeLookup[view];
|
|
91
|
-
const
|
|
87
|
+
const doesTheCurrentViewHasAnUI = useEventCallback(() => currentViewMode === 'UI');
|
|
92
88
|
const [popperView, setPopperView] = React.useState(currentViewMode === 'UI' ? view : null);
|
|
93
89
|
if (popperView !== view && viewModeLookup[view] === 'UI') {
|
|
94
90
|
setPopperView(view);
|
|
@@ -96,7 +92,7 @@ export const usePickerViews = ({
|
|
|
96
92
|
useEnhancedEffect(() => {
|
|
97
93
|
// Handle case of `DateTimePicker` without time renderers
|
|
98
94
|
if (currentViewMode === 'field' && open) {
|
|
99
|
-
|
|
95
|
+
setOpen(false);
|
|
100
96
|
setTimeout(() => {
|
|
101
97
|
fieldRef?.current?.setSelectedSections(view);
|
|
102
98
|
// focusing the input before the range selection is done
|
|
@@ -127,15 +123,26 @@ export const usePickerViews = ({
|
|
|
127
123
|
setFocusedView(newView, true);
|
|
128
124
|
}, [open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
129
125
|
|
|
130
|
-
const
|
|
126
|
+
const actionsContextValue = React.useMemo(() => ({
|
|
127
|
+
setView
|
|
128
|
+
}), [setView]);
|
|
129
|
+
const contextValue = React.useMemo(() => _extends({}, actionsContextValue, {
|
|
131
130
|
views,
|
|
132
|
-
view: popperView
|
|
133
|
-
|
|
131
|
+
view: popperView
|
|
132
|
+
}), [actionsContextValue, views, popperView]);
|
|
133
|
+
const privateContextValue = React.useMemo(() => ({
|
|
134
|
+
hasUIView,
|
|
135
|
+
doesTheCurrentViewHasAnUI
|
|
136
|
+
}), [hasUIView, doesTheCurrentViewHasAnUI]);
|
|
137
|
+
const providerParams = {
|
|
138
|
+
hasUIView,
|
|
139
|
+
views,
|
|
140
|
+
contextValue,
|
|
141
|
+
actionsContextValue,
|
|
142
|
+
privateContextValue
|
|
134
143
|
};
|
|
135
144
|
return {
|
|
136
|
-
|
|
137
|
-
shouldRestoreFocus,
|
|
138
|
-
layoutProps,
|
|
145
|
+
provider: providerParams,
|
|
139
146
|
renderCurrentView: () => {
|
|
140
147
|
if (popperView == null) {
|
|
141
148
|
return null;
|
|
@@ -144,9 +151,10 @@ export const usePickerViews = ({
|
|
|
144
151
|
if (renderer == null) {
|
|
145
152
|
return null;
|
|
146
153
|
}
|
|
147
|
-
const rendererProps = _extends({}, propsToForwardToView,
|
|
154
|
+
const rendererProps = _extends({}, propsToForwardToView, {
|
|
148
155
|
views,
|
|
149
156
|
timezone,
|
|
157
|
+
value,
|
|
150
158
|
onChange: setValueAndGoToNextView,
|
|
151
159
|
view: popperView,
|
|
152
160
|
onViewChange: setView,
|
|
@@ -155,8 +163,12 @@ export const usePickerViews = ({
|
|
|
155
163
|
showViewSwitcher: timeViewsCount > 1,
|
|
156
164
|
timeViewsCount
|
|
157
165
|
});
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
166
|
+
if (RendererInterceptor) {
|
|
167
|
+
return /*#__PURE__*/_jsx(RendererInterceptor, {
|
|
168
|
+
viewRenderers: viewRenderers,
|
|
169
|
+
popperView: popperView,
|
|
170
|
+
rendererProps: rendererProps
|
|
171
|
+
});
|
|
160
172
|
}
|
|
161
173
|
return renderer(rendererProps);
|
|
162
174
|
}
|
|
@@ -6,9 +6,12 @@ const mobileVersionMatches = typeof navigator !== 'undefined' && navigator.userA
|
|
|
6
6
|
const androidVersion = mobileVersionMatches && mobileVersionMatches[1] ? parseInt(mobileVersionMatches[1], 10) : null;
|
|
7
7
|
const iOSVersion = mobileVersionMatches && mobileVersionMatches[2] ? parseInt(mobileVersionMatches[2], 10) : null;
|
|
8
8
|
export const slowAnimationDevices = androidVersion && androidVersion < 10 || iOSVersion && iOSVersion < 13 || false;
|
|
9
|
-
export
|
|
9
|
+
export function useReduceAnimations(customReduceAnimations) {
|
|
10
10
|
const prefersReduced = useMediaQuery(PREFERS_REDUCED_MOTION, {
|
|
11
11
|
defaultMatches: false
|
|
12
12
|
});
|
|
13
|
+
if (customReduceAnimations != null) {
|
|
14
|
+
return customReduceAnimations;
|
|
15
|
+
}
|
|
13
16
|
return prefersReduced || slowAnimationDevices;
|
|
14
|
-
}
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["props"
|
|
3
|
+
const _excluded = ["props"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
@@ -8,6 +8,7 @@ import { usePicker } from "../usePicker/index.js";
|
|
|
8
8
|
import { PickerProvider } from "../../components/PickerProvider.js";
|
|
9
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
10
10
|
import { DIALOG_WIDTH } from "../../constants/dimensions.js";
|
|
11
|
+
import { mergeSx } from "../../utils/utils.js";
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
const PickerStaticLayout = styled(PickersLayout)(({
|
|
13
14
|
theme
|
|
@@ -25,39 +26,33 @@ const PickerStaticLayout = styled(PickersLayout)(({
|
|
|
25
26
|
*/
|
|
26
27
|
export const useStaticPicker = _ref => {
|
|
27
28
|
let {
|
|
28
|
-
props
|
|
29
|
-
ref
|
|
29
|
+
props
|
|
30
30
|
} = _ref,
|
|
31
31
|
pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
32
32
|
const {
|
|
33
33
|
localeText,
|
|
34
34
|
slots,
|
|
35
35
|
slotProps,
|
|
36
|
-
className,
|
|
37
|
-
sx,
|
|
38
36
|
displayStaticWrapperAs,
|
|
39
37
|
autoFocus
|
|
40
38
|
} = props;
|
|
41
39
|
const {
|
|
42
|
-
layoutProps,
|
|
43
40
|
providerProps,
|
|
44
41
|
renderCurrentView
|
|
45
42
|
} = usePicker(_extends({}, pickerParams, {
|
|
46
43
|
props,
|
|
47
44
|
autoFocusView: autoFocus ?? false,
|
|
48
|
-
fieldRef: undefined,
|
|
49
45
|
localeText,
|
|
50
|
-
|
|
51
|
-
wrapperVariant: displayStaticWrapperAs
|
|
46
|
+
variant: displayStaticWrapperAs
|
|
52
47
|
}));
|
|
53
48
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
54
49
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
55
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({},
|
|
50
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
56
51
|
slots: slots,
|
|
57
52
|
slotProps: slotProps,
|
|
58
|
-
sx:
|
|
59
|
-
className: clsx(
|
|
60
|
-
ref:
|
|
53
|
+
sx: mergeSx(providerProps.contextValue.rootSx, slotProps?.layout?.sx),
|
|
54
|
+
className: clsx(providerProps.contextValue.rootClassName, slotProps?.layout?.className),
|
|
55
|
+
ref: providerProps.contextValue.rootRef,
|
|
61
56
|
children: renderCurrentView()
|
|
62
57
|
}))
|
|
63
58
|
}));
|
|
@@ -0,0 +1,13 @@
|
|
|
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 useToolbarOwnerState() {
|
|
6
|
+
const {
|
|
7
|
+
ownerState: pickerOwnerState
|
|
8
|
+
} = usePickerPrivateContext();
|
|
9
|
+
const isRtl = useRtl();
|
|
10
|
+
return React.useMemo(() => _extends({}, pickerOwnerState, {
|
|
11
|
+
toolbarDirection: isRtl ? 'rtl' : 'ltr'
|
|
12
|
+
}), [pickerOwnerState, isRtl]);
|
|
13
|
+
}
|
|
@@ -19,7 +19,7 @@ export const useUtils = () => useLocalizationContext().utils;
|
|
|
19
19
|
export const useDefaultDates = () => useLocalizationContext().defaultDates;
|
|
20
20
|
export const useNow = timezone => {
|
|
21
21
|
const utils = useUtils();
|
|
22
|
-
const now = React.useRef();
|
|
22
|
+
const now = React.useRef(undefined);
|
|
23
23
|
if (now.current === undefined) {
|
|
24
24
|
now.current = utils.date(undefined, timezone);
|
|
25
25
|
}
|
|
@@ -11,6 +11,7 @@ export const useValueWithTimezone = ({
|
|
|
11
11
|
timezone: timezoneProp,
|
|
12
12
|
value: valueProp,
|
|
13
13
|
defaultValue,
|
|
14
|
+
referenceDate,
|
|
14
15
|
onChange,
|
|
15
16
|
valueManager
|
|
16
17
|
}) => {
|
|
@@ -24,7 +25,16 @@ export const useValueWithTimezone = ({
|
|
|
24
25
|
}
|
|
25
26
|
return valueManager.setTimezone(utils, inputTimezone, newValue);
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
+
let timezoneToRender;
|
|
29
|
+
if (timezoneProp) {
|
|
30
|
+
timezoneToRender = timezoneProp;
|
|
31
|
+
} else if (inputTimezone) {
|
|
32
|
+
timezoneToRender = inputTimezone;
|
|
33
|
+
} else if (referenceDate) {
|
|
34
|
+
timezoneToRender = utils.getTimezone(referenceDate);
|
|
35
|
+
} else {
|
|
36
|
+
timezoneToRender = 'default';
|
|
37
|
+
}
|
|
28
38
|
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
|
|
29
39
|
const handleValueChange = useEventCallback((newValue, ...otherParams) => {
|
|
30
40
|
const newValueWithInputTimezone = setInputTimezone(newValue);
|
|
@@ -45,6 +55,7 @@ export const useControlledValueWithTimezone = ({
|
|
|
45
55
|
timezone: timezoneProp,
|
|
46
56
|
value: valueProp,
|
|
47
57
|
defaultValue,
|
|
58
|
+
referenceDate,
|
|
48
59
|
onChange: onChangeProp,
|
|
49
60
|
valueManager
|
|
50
61
|
}) => {
|
|
@@ -62,6 +73,7 @@ export const useControlledValueWithTimezone = ({
|
|
|
62
73
|
timezone: timezoneProp,
|
|
63
74
|
value: valueWithInputTimezone,
|
|
64
75
|
defaultValue: undefined,
|
|
76
|
+
referenceDate,
|
|
65
77
|
onChange,
|
|
66
78
|
valueManager
|
|
67
79
|
});
|