@mui/x-date-pickers 6.5.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterDateFns/AdapterDateFns.d.ts +6 -0
- package/AdapterDateFns/AdapterDateFns.js +38 -19
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
- package/AdapterDayjs/AdapterDayjs.d.ts +14 -1
- package/AdapterDayjs/AdapterDayjs.js +143 -25
- package/AdapterLuxon/AdapterLuxon.d.ts +7 -1
- package/AdapterLuxon/AdapterLuxon.js +78 -28
- package/AdapterMoment/AdapterMoment.d.ts +12 -1
- package/AdapterMoment/AdapterMoment.js +103 -13
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +4 -0
- package/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +4 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
- package/CHANGELOG.md +150 -2
- package/DateCalendar/DateCalendar.js +2 -2
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.js +2 -2
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- package/DateField/DateField.js +6 -0
- package/DateField/DateField.types.d.ts +1 -1
- package/DatePicker/DatePickerToolbar.js +6 -15
- package/DatePicker/shared.d.ts +1 -5
- package/DatePicker/shared.js +1 -16
- package/DateTimeField/DateTimeField.js +6 -0
- package/DateTimeField/DateTimeField.types.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +19 -2
- package/DateTimePicker/DateTimePicker.types.d.ts +4 -3
- package/DateTimePicker/DateTimePickerTabs.d.ts +3 -3
- package/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/DateTimePicker/DateTimePickerToolbar.d.ts +5 -4
- package/DateTimePicker/DateTimePickerToolbar.js +46 -22
- package/DateTimePicker/shared.d.ts +6 -6
- package/DayCalendarSkeleton/DayCalendarSkeleton.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +5 -4
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +58 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +10 -3
- package/DesktopTimePicker/DesktopTimePicker.js +7 -3
- package/LocalizationProvider/LocalizationProvider.js +1 -0
- package/MobileDatePicker/MobileDatePicker.js +3 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +8 -7
- package/MobileTimePicker/MobileTimePicker.js +5 -1
- package/MonthCalendar/MonthCalendar.js +2 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
- package/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/PickersLayout/PickersLayout.d.ts +1 -1
- package/PickersShortcuts/PickersShortcuts.d.ts +2 -2
- package/README.md +5 -5
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -1
- package/TimeClock/Clock.d.ts +1 -1
- package/TimeClock/ClockNumber.d.ts +1 -1
- package/TimeClock/ClockNumbers.d.ts +2 -2
- package/TimeClock/ClockPointer.d.ts +1 -1
- package/TimeField/TimeField.js +6 -0
- package/TimeField/TimeField.types.d.ts +1 -1
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/TimePicker/shared.d.ts +1 -1
- package/YearCalendar/YearCalendar.js +2 -2
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +13 -0
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +148 -0
- package/dateTimeViewRenderers/index.d.ts +2 -0
- package/dateTimeViewRenderers/index.js +1 -0
- package/dateTimeViewRenderers/package.json +6 -0
- package/dateViewRenderers/dateViewRenderers.d.ts +3 -2
- package/dateViewRenderers/dateViewRenderers.js +2 -2
- package/icons/index.d.ts +42 -0
- package/{internals/components/icons → icons}/index.js +7 -7
- package/icons/package.json +6 -0
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.d.ts +2 -0
- package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
- package/internals/components/DateTimeViewWrapper/index.d.ts +1 -0
- package/internals/components/DateTimeViewWrapper/index.js +1 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/internals/components/PickersModalDialog.d.ts +1 -1
- package/internals/components/PickersPopper.d.ts +1 -1
- package/internals/components/PickersToolbarButton.d.ts +1 -0
- package/internals/components/PickersToolbarButton.js +8 -3
- package/internals/constants/dimensions.d.ts +1 -0
- package/internals/constants/dimensions.js +2 -1
- package/internals/demo/DemoContainer.d.ts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/useField.d.ts +1 -1
- package/internals/hooks/useField/useField.js +8 -3
- package/internals/hooks/useField/useField.types.d.ts +8 -2
- package/internals/hooks/useField/useFieldState.d.ts +1 -1
- package/internals/hooks/useField/useFieldState.js +22 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -2
- package/internals/hooks/usePicker/usePickerViews.js +8 -10
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +2 -2
- package/internals/hooks/useViews.js +10 -9
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/internals/models/fields.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +6 -0
- package/internals/utils/date-time-utils.js +41 -0
- package/internals/utils/date-utils.d.ts +8 -1
- package/internals/utils/date-utils.js +35 -0
- package/internals/utils/fields.js +1 -1
- package/internals/utils/getDefaultReferenceDate.d.ts +15 -0
- package/internals/utils/getDefaultReferenceDate.js +62 -0
- package/internals/utils/time-utils.d.ts +8 -2
- package/internals/utils/time-utils.js +28 -0
- package/internals/utils/validation/extractValidationProps.d.ts +1 -1
- package/internals/utils/valueManagers.js +21 -3
- package/internals/utils/views.d.ts +2 -3
- package/internals/utils/views.js +6 -2
- package/legacy/AdapterDateFns/AdapterDateFns.js +38 -19
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
- package/legacy/AdapterDayjs/AdapterDayjs.js +147 -25
- package/legacy/AdapterLuxon/AdapterLuxon.js +78 -28
- package/legacy/AdapterMoment/AdapterMoment.js +109 -17
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
- package/legacy/DateCalendar/DateCalendar.js +2 -2
- package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
- package/legacy/DateField/DateField.js +6 -0
- package/legacy/DatePicker/DatePickerToolbar.js +6 -15
- package/legacy/DatePicker/shared.js +1 -15
- package/legacy/DateTimeField/DateTimeField.js +6 -0
- package/legacy/DateTimePicker/DateTimePicker.js +19 -2
- package/legacy/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/legacy/DateTimePicker/DateTimePickerToolbar.js +51 -23
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +5 -4
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +59 -11
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +7 -3
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -0
- package/legacy/MobileDatePicker/MobileDatePicker.js +3 -2
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +5 -1
- package/legacy/MonthCalendar/MonthCalendar.js +2 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
- package/legacy/TimeField/TimeField.js +6 -0
- package/legacy/YearCalendar/YearCalendar.js +2 -2
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
- package/legacy/dateTimeViewRenderers/index.js +1 -0
- package/legacy/dateViewRenderers/dateViewRenderers.js +2 -4
- package/legacy/{internals/components/icons → icons}/index.js +7 -7
- package/legacy/index.js +3 -2
- package/legacy/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
- package/legacy/internals/components/DateTimeViewWrapper/index.js +1 -0
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/legacy/internals/components/PickersToolbarButton.js +7 -2
- package/legacy/internals/constants/dimensions.js +2 -1
- package/legacy/internals/hooks/useField/useField.js +8 -3
- package/legacy/internals/hooks/useField/useFieldState.js +22 -2
- package/legacy/internals/hooks/usePicker/usePickerViews.js +4 -4
- package/legacy/internals/hooks/useViews.js +10 -9
- package/legacy/internals/index.js +2 -1
- package/legacy/internals/utils/date-time-utils.js +39 -0
- package/legacy/internals/utils/date-utils.js +38 -0
- package/legacy/internals/utils/fields.js +1 -1
- package/legacy/internals/utils/getDefaultReferenceDate.js +64 -0
- package/legacy/internals/utils/time-utils.js +29 -0
- package/legacy/internals/utils/valueManagers.js +20 -4
- package/legacy/internals/utils/views.js +7 -5
- package/legacy/locales/deDE.js +2 -2
- package/legacy/locales/index.js +17 -15
- package/legacy/locales/roRO.js +81 -0
- package/legacy/locales/viVN.js +93 -0
- package/legacy/models/index.js +1 -0
- package/legacy/models/timezone.js +1 -0
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +16 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +349 -79
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +3 -3
- package/legacy/tests/describeValidation/testDayViewValidation.js +129 -52
- package/legacy/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/legacy/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/legacy/tests/describeValidation/testYearViewValidation.js +3 -10
- package/legacy/tests/describeValue/describeValue.js +12 -5
- package/legacy/tests/describeValue/testControlledUnControlled.js +19 -4
- package/legacy/tests/describeValue/testPickerActionBar.js +12 -10
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
- package/legacy/timeViewRenderers/timeViewRenderers.js +1 -1
- package/locales/deDE.js +2 -2
- package/locales/index.d.ts +17 -15
- package/locales/index.js +17 -15
- package/locales/roRO.d.ts +53 -0
- package/locales/roRO.js +63 -0
- package/locales/viVN.d.ts +53 -0
- package/locales/viVN.js +57 -0
- package/models/adapters.d.ts +187 -46
- package/models/fields.d.ts +1 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/timezone.d.ts +1 -0
- package/models/timezone.js +1 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +38 -19
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
- package/modern/AdapterDayjs/AdapterDayjs.js +142 -25
- package/modern/AdapterLuxon/AdapterLuxon.js +77 -28
- package/modern/AdapterMoment/AdapterMoment.js +102 -13
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
- package/modern/DateCalendar/DateCalendar.js +2 -2
- package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
- package/modern/DateField/DateField.js +6 -0
- package/modern/DatePicker/DatePickerToolbar.js +6 -15
- package/modern/DatePicker/shared.js +1 -16
- package/modern/DateTimeField/DateTimeField.js +6 -0
- package/modern/DateTimePicker/DateTimePicker.js +19 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/modern/DateTimePicker/DateTimePickerToolbar.js +46 -22
- package/modern/DesktopDatePicker/DesktopDatePicker.js +5 -4
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +57 -10
- package/modern/DesktopTimePicker/DesktopTimePicker.js +7 -3
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +3 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +5 -1
- package/modern/MonthCalendar/MonthCalendar.js +2 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
- package/modern/TimeField/TimeField.js +6 -0
- package/modern/YearCalendar/YearCalendar.js +2 -2
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
- package/modern/dateTimeViewRenderers/index.js +1 -0
- package/modern/dateViewRenderers/dateViewRenderers.js +2 -2
- package/modern/{internals/components/icons → icons}/index.js +7 -7
- package/modern/index.js +3 -2
- package/modern/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
- package/modern/internals/components/DateTimeViewWrapper/index.js +1 -0
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/modern/internals/components/PickersToolbarButton.js +8 -3
- package/modern/internals/constants/dimensions.js +2 -1
- package/modern/internals/hooks/useField/useField.js +8 -3
- package/modern/internals/hooks/useField/useFieldState.js +22 -2
- package/modern/internals/hooks/usePicker/usePickerViews.js +8 -10
- package/modern/internals/hooks/useViews.js +10 -9
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/date-time-utils.js +41 -0
- package/modern/internals/utils/date-utils.js +35 -0
- package/modern/internals/utils/fields.js +1 -1
- package/modern/internals/utils/getDefaultReferenceDate.js +58 -0
- package/modern/internals/utils/time-utils.js +28 -0
- package/modern/internals/utils/valueManagers.js +21 -3
- package/modern/internals/utils/views.js +6 -2
- package/modern/locales/deDE.js +2 -2
- package/modern/locales/index.js +17 -15
- package/modern/locales/roRO.js +60 -0
- package/modern/locales/viVN.js +57 -0
- package/modern/models/index.js +1 -0
- package/modern/models/timezone.js +1 -0
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +347 -79
- package/modern/tests/describeGregorianAdapter/testLocalization.js +3 -3
- package/modern/tests/describeValidation/testDayViewValidation.js +129 -52
- package/modern/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/modern/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/modern/tests/describeValidation/testYearViewValidation.js +3 -10
- package/modern/tests/describeValue/describeValue.js +13 -4
- package/modern/tests/describeValue/testControlledUnControlled.js +15 -4
- package/modern/tests/describeValue/testPickerActionBar.js +19 -17
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
- package/modern/timeViewRenderers/timeViewRenderers.js +1 -1
- package/node/AdapterDateFns/AdapterDateFns.js +38 -19
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
- package/node/AdapterDayjs/AdapterDayjs.js +142 -25
- package/node/AdapterLuxon/AdapterLuxon.js +77 -28
- package/node/AdapterMoment/AdapterMoment.js +102 -13
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
- package/node/DateCalendar/DateCalendar.js +2 -2
- package/node/DateCalendar/PickersCalendarHeader.js +2 -2
- package/node/DateField/DateField.js +6 -0
- package/node/DatePicker/DatePickerToolbar.js +6 -15
- package/node/DatePicker/shared.js +0 -17
- package/node/DateTimeField/DateTimeField.js +6 -0
- package/node/DateTimePicker/DateTimePicker.js +19 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +6 -5
- package/node/DateTimePicker/DateTimePickerToolbar.js +46 -22
- package/node/DesktopDatePicker/DesktopDatePicker.js +4 -3
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +59 -12
- package/node/DesktopTimePicker/DesktopTimePicker.js +9 -5
- package/node/LocalizationProvider/LocalizationProvider.js +1 -0
- package/node/MobileDatePicker/MobileDatePicker.js +2 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +7 -3
- package/node/MobileTimePicker/MobileTimePicker.js +7 -3
- package/node/MonthCalendar/MonthCalendar.js +2 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -2
- package/node/TimeField/TimeField.js +6 -0
- package/node/YearCalendar/YearCalendar.js +2 -2
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +156 -0
- package/node/dateTimeViewRenderers/index.js +12 -0
- package/node/dateViewRenderers/dateViewRenderers.js +3 -3
- package/node/{internals/components/icons → icons}/index.js +15 -15
- package/node/index.js +13 -1
- package/node/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +12 -0
- package/node/internals/components/DateTimeViewWrapper/index.js +12 -0
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/node/internals/components/PickersToolbarButton.js +8 -3
- package/node/internals/constants/dimensions.js +4 -2
- package/node/internals/hooks/useField/useField.js +8 -3
- package/node/internals/hooks/useField/useFieldState.js +22 -2
- package/node/internals/hooks/usePicker/usePickerViews.js +8 -10
- package/node/internals/hooks/useViews.js +10 -9
- package/node/internals/index.js +13 -0
- package/node/internals/utils/date-time-utils.js +49 -0
- package/node/internals/utils/date-utils.js +40 -2
- package/node/internals/utils/fields.js +1 -1
- package/node/internals/utils/getDefaultReferenceDate.js +66 -0
- package/node/internals/utils/time-utils.js +32 -2
- package/node/internals/utils/valueManagers.js +21 -2
- package/node/internals/utils/views.js +8 -5
- package/node/locales/deDE.js +2 -2
- package/node/locales/index.js +119 -97
- package/node/locales/roRO.js +67 -0
- package/node/locales/viVN.js +64 -0
- package/node/models/index.js +11 -0
- package/node/models/timezone.js +5 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
- package/node/tests/describeGregorianAdapter/testCalculations.js +347 -79
- package/node/tests/describeGregorianAdapter/testLocalization.js +3 -4
- package/node/tests/describeValidation/testDayViewValidation.js +129 -52
- package/node/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/node/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/node/tests/describeValidation/testYearViewValidation.js +3 -10
- package/node/tests/describeValue/describeValue.js +13 -4
- package/node/tests/describeValue/testControlledUnControlled.js +15 -4
- package/node/tests/describeValue/testPickerActionBar.js +19 -16
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +9 -6
- package/node/timeViewRenderers/timeViewRenderers.js +1 -1
- package/package.json +4 -4
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +14 -1
- package/tests/describeGregorianAdapter/testCalculations.js +347 -79
- package/tests/describeGregorianAdapter/testLocalization.js +3 -3
- package/tests/describeValidation/testDayViewValidation.js +129 -52
- package/tests/describeValidation/testMinutesViewValidation.js +3 -10
- package/tests/describeValidation/testMonthViewValidation.js +3 -10
- package/tests/describeValidation/testYearViewValidation.js +3 -10
- package/tests/describeValue/describeValue.js +13 -4
- package/tests/describeValue/testControlledUnControlled.js +15 -4
- package/tests/describeValue/testPickerActionBar.js +19 -17
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
- package/timeViewRenderers/timeViewRenderers.d.ts +4 -4
- package/timeViewRenderers/timeViewRenderers.js +1 -1
- package/internals/components/icons/index.d.ts +0 -42
|
@@ -107,7 +107,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
107
107
|
onFocusedViewChange(newHasFocus);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
const isYearDisabled =
|
|
110
|
+
const isYearDisabled = React.useCallback(dateToValidate => {
|
|
111
111
|
if (disablePast && utils.isBeforeYear(dateToValidate, now)) {
|
|
112
112
|
return true;
|
|
113
113
|
}
|
|
@@ -124,7 +124,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
124
124
|
return true;
|
|
125
125
|
}
|
|
126
126
|
return false;
|
|
127
|
-
});
|
|
127
|
+
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableYear, utils]);
|
|
128
128
|
const handleYearSelection = useEventCallback((event, year) => {
|
|
129
129
|
if (readOnly) {
|
|
130
130
|
return;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Divider from '@mui/material/Divider';
|
|
4
|
+
import { resolveComponentProps } from '@mui/base/utils';
|
|
5
|
+
import { DateCalendar } from '../DateCalendar';
|
|
6
|
+
import { MultiSectionDigitalClock, multiSectionDigitalClockSectionClasses } from '../MultiSectionDigitalClock';
|
|
7
|
+
import { DateTimeViewWrapper } from '../internals/components/DateTimeViewWrapper';
|
|
8
|
+
import { isInternalTimeView } from '../internals/utils/time-utils';
|
|
9
|
+
import { isDatePickerView } from '../internals/utils/date-utils';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
export const renderDesktopDateTimeView = ({
|
|
13
|
+
view,
|
|
14
|
+
onViewChange,
|
|
15
|
+
views,
|
|
16
|
+
focusedView,
|
|
17
|
+
onFocusedViewChange,
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
onChange,
|
|
21
|
+
className,
|
|
22
|
+
classes,
|
|
23
|
+
disableFuture,
|
|
24
|
+
disablePast,
|
|
25
|
+
minDate,
|
|
26
|
+
minTime,
|
|
27
|
+
maxDate,
|
|
28
|
+
maxTime,
|
|
29
|
+
shouldDisableDate,
|
|
30
|
+
shouldDisableMonth,
|
|
31
|
+
shouldDisableYear,
|
|
32
|
+
shouldDisableTime,
|
|
33
|
+
shouldDisableClock,
|
|
34
|
+
reduceAnimations,
|
|
35
|
+
minutesStep,
|
|
36
|
+
ampm,
|
|
37
|
+
onMonthChange,
|
|
38
|
+
monthsPerRow,
|
|
39
|
+
onYearChange,
|
|
40
|
+
yearsPerRow,
|
|
41
|
+
defaultCalendarMonth,
|
|
42
|
+
components,
|
|
43
|
+
componentsProps,
|
|
44
|
+
slots,
|
|
45
|
+
slotProps,
|
|
46
|
+
loading,
|
|
47
|
+
renderLoading,
|
|
48
|
+
disableHighlightToday,
|
|
49
|
+
readOnly,
|
|
50
|
+
disabled,
|
|
51
|
+
showDaysOutsideCurrentMonth,
|
|
52
|
+
dayOfWeekFormatter,
|
|
53
|
+
sx,
|
|
54
|
+
autoFocus,
|
|
55
|
+
fixedWeekNumber,
|
|
56
|
+
displayWeekNumber,
|
|
57
|
+
disableIgnoringDatePartForTimeValidation,
|
|
58
|
+
timeSteps,
|
|
59
|
+
skipDisabled,
|
|
60
|
+
timeViewsCount
|
|
61
|
+
}) => {
|
|
62
|
+
const isActionBarVisible = !!resolveComponentProps(slotProps?.actionBar ?? componentsProps?.actionBar, {})?.actions?.length;
|
|
63
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
64
|
+
children: [/*#__PURE__*/_jsxs(DateTimeViewWrapper, {
|
|
65
|
+
children: [/*#__PURE__*/_jsx(DateCalendar, {
|
|
66
|
+
view: isDatePickerView(view) ? view : 'day',
|
|
67
|
+
onViewChange: onViewChange,
|
|
68
|
+
views: views.filter(isDatePickerView),
|
|
69
|
+
focusedView: focusedView && isDatePickerView(focusedView) ? focusedView : null,
|
|
70
|
+
onFocusedViewChange: onFocusedViewChange,
|
|
71
|
+
value: value,
|
|
72
|
+
defaultValue: defaultValue,
|
|
73
|
+
onChange: onChange,
|
|
74
|
+
className: className,
|
|
75
|
+
classes: classes,
|
|
76
|
+
disableFuture: disableFuture,
|
|
77
|
+
disablePast: disablePast,
|
|
78
|
+
minDate: minDate,
|
|
79
|
+
maxDate: maxDate,
|
|
80
|
+
shouldDisableDate: shouldDisableDate,
|
|
81
|
+
shouldDisableMonth: shouldDisableMonth,
|
|
82
|
+
shouldDisableYear: shouldDisableYear,
|
|
83
|
+
reduceAnimations: reduceAnimations,
|
|
84
|
+
onMonthChange: onMonthChange,
|
|
85
|
+
monthsPerRow: monthsPerRow,
|
|
86
|
+
onYearChange: onYearChange,
|
|
87
|
+
yearsPerRow: yearsPerRow,
|
|
88
|
+
defaultCalendarMonth: defaultCalendarMonth,
|
|
89
|
+
components: components,
|
|
90
|
+
componentsProps: componentsProps,
|
|
91
|
+
slots: slots,
|
|
92
|
+
slotProps: slotProps,
|
|
93
|
+
loading: loading,
|
|
94
|
+
renderLoading: renderLoading,
|
|
95
|
+
disableHighlightToday: disableHighlightToday,
|
|
96
|
+
readOnly: readOnly,
|
|
97
|
+
disabled: disabled,
|
|
98
|
+
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
99
|
+
dayOfWeekFormatter: dayOfWeekFormatter,
|
|
100
|
+
sx: sx,
|
|
101
|
+
autoFocus: autoFocus,
|
|
102
|
+
fixedWeekNumber: fixedWeekNumber,
|
|
103
|
+
displayWeekNumber: displayWeekNumber
|
|
104
|
+
}), timeViewsCount > 0 && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
105
|
+
children: [/*#__PURE__*/_jsx(Divider, {
|
|
106
|
+
orientation: "vertical"
|
|
107
|
+
}), /*#__PURE__*/_jsx(MultiSectionDigitalClock, {
|
|
108
|
+
view: isInternalTimeView(view) ? view : 'hours',
|
|
109
|
+
onViewChange: onViewChange,
|
|
110
|
+
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
111
|
+
onFocusedViewChange: onFocusedViewChange,
|
|
112
|
+
views: views.filter(isInternalTimeView),
|
|
113
|
+
value: value,
|
|
114
|
+
defaultValue: defaultValue,
|
|
115
|
+
onChange: onChange,
|
|
116
|
+
className: className,
|
|
117
|
+
classes: classes,
|
|
118
|
+
disableFuture: disableFuture,
|
|
119
|
+
disablePast: disablePast,
|
|
120
|
+
minTime: minTime,
|
|
121
|
+
maxTime: maxTime,
|
|
122
|
+
shouldDisableTime: shouldDisableTime,
|
|
123
|
+
shouldDisableClock: shouldDisableClock,
|
|
124
|
+
minutesStep: minutesStep,
|
|
125
|
+
ampm: ampm,
|
|
126
|
+
components: components,
|
|
127
|
+
componentsProps: componentsProps,
|
|
128
|
+
slots: slots,
|
|
129
|
+
slotProps: slotProps,
|
|
130
|
+
readOnly: readOnly,
|
|
131
|
+
disabled: disabled,
|
|
132
|
+
sx: _extends({
|
|
133
|
+
borderBottom: 0,
|
|
134
|
+
width: 'auto',
|
|
135
|
+
[`.${multiSectionDigitalClockSectionClasses.root}`]: {
|
|
136
|
+
maxHeight: '100%'
|
|
137
|
+
}
|
|
138
|
+
}, Array.isArray(sx) ? sx : [sx]),
|
|
139
|
+
autoFocus: autoFocus,
|
|
140
|
+
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
141
|
+
timeSteps: timeSteps,
|
|
142
|
+
skipDisabled: skipDisabled
|
|
143
|
+
})]
|
|
144
|
+
})]
|
|
145
|
+
}), isActionBarVisible && /*#__PURE__*/_jsx(Divider, {})]
|
|
146
|
+
});
|
|
147
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderDesktopDateTimeView } from './dateTimeViewRenderers';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DateCalendar } from '../DateCalendar';
|
|
3
|
+
import { isDatePickerView } from '../internals/utils/date-utils';
|
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
const isDatePickerView = view => view === 'year' || view === 'month' || view === 'day';
|
|
5
5
|
export const renderDateViewCalendar = ({
|
|
6
6
|
view,
|
|
7
7
|
onViewChange,
|
|
@@ -45,7 +45,7 @@ export const renderDateViewCalendar = ({
|
|
|
45
45
|
view: view,
|
|
46
46
|
onViewChange: onViewChange,
|
|
47
47
|
views: views.filter(isDatePickerView),
|
|
48
|
-
focusedView: focusedView,
|
|
48
|
+
focusedView: focusedView && isDatePickerView(focusedView) ? focusedView : null,
|
|
49
49
|
onFocusedViewChange: onFocusedViewChange,
|
|
50
50
|
value: value,
|
|
51
51
|
defaultValue: defaultValue,
|
|
@@ -6,35 +6,35 @@ import * as React from 'react';
|
|
|
6
6
|
*/
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
export const
|
|
9
|
+
export const ArrowDropDownIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
10
10
|
d: "M7 10l5 5 5-5z"
|
|
11
11
|
}), 'ArrowDropDown');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @ignore - internal component.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const ArrowLeftIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
17
17
|
d: "M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"
|
|
18
18
|
}), 'ArrowLeft');
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @ignore - internal component.
|
|
22
22
|
*/
|
|
23
|
-
export const
|
|
23
|
+
export const ArrowRightIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
24
24
|
d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"
|
|
25
25
|
}), 'ArrowRight');
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @ignore - internal component.
|
|
29
29
|
*/
|
|
30
|
-
export const
|
|
30
|
+
export const CalendarIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
31
31
|
d: "M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z"
|
|
32
32
|
}), 'Calendar');
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @ignore - internal component.
|
|
36
36
|
*/
|
|
37
|
-
export const
|
|
37
|
+
export const ClockIcon = createSvgIcon( /*#__PURE__*/_jsxs(React.Fragment, {
|
|
38
38
|
children: [/*#__PURE__*/_jsx("path", {
|
|
39
39
|
d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
|
|
40
40
|
}), /*#__PURE__*/_jsx("path", {
|
|
@@ -45,14 +45,14 @@ export const Clock = createSvgIcon( /*#__PURE__*/_jsxs(React.Fragment, {
|
|
|
45
45
|
/**
|
|
46
46
|
* @ignore - internal component.
|
|
47
47
|
*/
|
|
48
|
-
export const
|
|
48
|
+
export const DateRangeIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
49
49
|
d: "M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"
|
|
50
50
|
}), 'DateRange');
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* @ignore - internal component.
|
|
54
54
|
*/
|
|
55
|
-
export const
|
|
55
|
+
export const TimeIcon = createSvgIcon( /*#__PURE__*/_jsxs(React.Fragment, {
|
|
56
56
|
children: [/*#__PURE__*/_jsx("path", {
|
|
57
57
|
d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
|
|
58
58
|
}), /*#__PURE__*/_jsx("path", {
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers v6.
|
|
2
|
+
* @mui/x-date-pickers v6.7.0
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -47,4 +47,5 @@ export * from './PickersLayout';
|
|
|
47
47
|
export * from './PickersActionBar';
|
|
48
48
|
export * from './PickersShortcuts';
|
|
49
49
|
export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
|
|
50
|
-
export * from './models';
|
|
50
|
+
export * from './models';
|
|
51
|
+
export * from './icons';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DateTimeViewWrapper } from './DateTimeViewWrapper';
|
|
@@ -10,7 +10,7 @@ import { useTheme, styled, useThemeProps } from '@mui/material/styles';
|
|
|
10
10
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
11
11
|
import { useSlotProps } from '@mui/base/utils';
|
|
12
12
|
import IconButton from '@mui/material/IconButton';
|
|
13
|
-
import {
|
|
13
|
+
import { ArrowLeftIcon, ArrowRightIcon } from '../../../icons';
|
|
14
14
|
import { getPickersArrowSwitcherUtilityClass } from './pickersArrowSwitcherClasses';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -121,7 +121,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
121
121
|
}),
|
|
122
122
|
className: classes.button
|
|
123
123
|
});
|
|
124
|
-
const LeftArrowIcon = slots?.leftArrowIcon ??
|
|
124
|
+
const LeftArrowIcon = slots?.leftArrowIcon ?? ArrowLeftIcon;
|
|
125
125
|
// The spread is here to avoid this bug mui/material-ui#34056
|
|
126
126
|
const _useSlotProps = useSlotProps({
|
|
127
127
|
elementType: LeftArrowIcon,
|
|
@@ -132,7 +132,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
132
132
|
ownerState: undefined
|
|
133
133
|
}),
|
|
134
134
|
leftArrowIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
135
|
-
const RightArrowIcon = slots?.rightArrowIcon ??
|
|
135
|
+
const RightArrowIcon = slots?.rightArrowIcon ?? ArrowRightIcon;
|
|
136
136
|
// The spread is here to avoid this bug mui/material-ui#34056
|
|
137
137
|
const _useSlotProps2 = useSlotProps({
|
|
138
138
|
elementType: RightArrowIcon,
|
|
@@ -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 = ["align", "className", "selected", "typographyClassName", "value", "variant"];
|
|
3
|
+
const _excluded = ["align", "className", "selected", "typographyClassName", "value", "variant", "width"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import Button from '@mui/material/Button';
|
|
@@ -38,7 +38,8 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
38
38
|
selected,
|
|
39
39
|
typographyClassName,
|
|
40
40
|
value,
|
|
41
|
-
variant
|
|
41
|
+
variant,
|
|
42
|
+
width
|
|
42
43
|
} = props,
|
|
43
44
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
44
45
|
const classes = useUtilityClasses(props);
|
|
@@ -46,7 +47,11 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
46
47
|
variant: "text",
|
|
47
48
|
ref: ref,
|
|
48
49
|
className: clsx(className, classes.root)
|
|
49
|
-
},
|
|
50
|
+
}, width ? {
|
|
51
|
+
sx: {
|
|
52
|
+
width
|
|
53
|
+
}
|
|
54
|
+
} : {}, other, {
|
|
50
55
|
children: /*#__PURE__*/_jsx(PickersToolbarText, {
|
|
51
56
|
align: align,
|
|
52
57
|
className: typographyClassName,
|
|
@@ -2,4 +2,5 @@ export const DAY_SIZE = 36;
|
|
|
2
2
|
export const DAY_MARGIN = 2;
|
|
3
3
|
export const DIALOG_WIDTH = 320;
|
|
4
4
|
export const VIEW_HEIGHT = 358;
|
|
5
|
-
export const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
|
|
5
|
+
export const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
|
|
6
|
+
export const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
|
|
@@ -158,7 +158,7 @@ export const useField = params => {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
let keyPressed;
|
|
161
|
-
if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1) {
|
|
161
|
+
if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1 && cleanValueStr.length === 1) {
|
|
162
162
|
keyPressed = cleanValueStr;
|
|
163
163
|
} else {
|
|
164
164
|
const prevValueStr = cleanString(fieldValueManager.getValueStrFromSections(state.sections, isRTL));
|
|
@@ -181,7 +181,7 @@ export const useField = params => {
|
|
|
181
181
|
|
|
182
182
|
// The active section being selected, the browser has replaced its value with the key pressed by the user.
|
|
183
183
|
const activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;
|
|
184
|
-
keyPressed = cleanValueStr.slice(activeSection.start, activeSectionEndRelativeToNewValue);
|
|
184
|
+
keyPressed = cleanValueStr.slice(activeSection.start + cleanString(activeSection.startSeparator || '').length, activeSectionEndRelativeToNewValue);
|
|
185
185
|
}
|
|
186
186
|
if (isAndroid() && keyPressed.length === 0) {
|
|
187
187
|
setTempAndroidValueStr(valueStr);
|
|
@@ -297,7 +297,12 @@ export const useField = params => {
|
|
|
297
297
|
if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
|
|
298
298
|
// Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321
|
|
299
299
|
const currentScrollTop = inputRef.current.scrollTop;
|
|
300
|
-
|
|
300
|
+
// On multi input range pickers we want to update selection range only for the active input
|
|
301
|
+
// This helps avoiding the focus jumping on Safari https://github.com/mui/mui-x/issues/9003
|
|
302
|
+
// because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425
|
|
303
|
+
if (inputRef.current && inputRef.current === getActiveElement(document)) {
|
|
304
|
+
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
305
|
+
}
|
|
301
306
|
// Even reading this variable seems to do the trick, but also setting it just to make use of it
|
|
302
307
|
inputRef.current.scrollTop = currentScrollTop;
|
|
303
308
|
}
|
|
@@ -4,6 +4,7 @@ import useControlled from '@mui/utils/useControlled';
|
|
|
4
4
|
import { useTheme } from '@mui/material/styles';
|
|
5
5
|
import { useUtils, useLocaleText, useLocalizationContext } from '../useUtils';
|
|
6
6
|
import { addPositionPropertiesToSections, splitFormatIntoSections, clampDaySectionIfPossible, mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections } from './useField.utils';
|
|
7
|
+
import { getSectionTypeGranularity } from '../../utils/getDefaultReferenceDate';
|
|
7
8
|
export const useFieldState = params => {
|
|
8
9
|
const utils = useUtils();
|
|
9
10
|
const localeText = useLocaleText();
|
|
@@ -19,6 +20,7 @@ export const useFieldState = params => {
|
|
|
19
20
|
internalProps: {
|
|
20
21
|
value: valueProp,
|
|
21
22
|
defaultValue,
|
|
23
|
+
referenceDate: referenceDateProp,
|
|
22
24
|
onChange,
|
|
23
25
|
format,
|
|
24
26
|
formatDensity = 'dense',
|
|
@@ -35,12 +37,24 @@ export const useFieldState = params => {
|
|
|
35
37
|
const [state, setState] = React.useState(() => {
|
|
36
38
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
37
39
|
validateSections(sections, valueType);
|
|
38
|
-
|
|
40
|
+
const stateWithoutReferenceDate = {
|
|
39
41
|
sections,
|
|
40
42
|
value: valueFromTheOutside,
|
|
41
|
-
referenceValue:
|
|
43
|
+
referenceValue: valueManager.emptyValue,
|
|
42
44
|
tempValueStrAndroid: null
|
|
43
45
|
};
|
|
46
|
+
const granularity = getSectionTypeGranularity(sections);
|
|
47
|
+
const referenceValue = valueManager.getInitialReferenceValue({
|
|
48
|
+
referenceDate: referenceDateProp,
|
|
49
|
+
value: valueFromTheOutside,
|
|
50
|
+
valueType,
|
|
51
|
+
utils,
|
|
52
|
+
props: internalProps,
|
|
53
|
+
granularity
|
|
54
|
+
});
|
|
55
|
+
return _extends({}, stateWithoutReferenceDate, {
|
|
56
|
+
referenceValue
|
|
57
|
+
});
|
|
44
58
|
});
|
|
45
59
|
const [selectedSections, innerSetSelectedSections] = useControlled({
|
|
46
60
|
controlled: selectedSectionsProp,
|
|
@@ -240,7 +254,13 @@ export const useFieldState = params => {
|
|
|
240
254
|
tempValueStrAndroid
|
|
241
255
|
}));
|
|
242
256
|
React.useEffect(() => {
|
|
257
|
+
let shouldUpdate = false;
|
|
243
258
|
if (!valueManager.areValuesEqual(utils, state.value, valueFromTheOutside)) {
|
|
259
|
+
shouldUpdate = true;
|
|
260
|
+
} else {
|
|
261
|
+
shouldUpdate = valueManager.getTimezone(utils, state.value) !== valueManager.getTimezone(utils, valueFromTheOutside);
|
|
262
|
+
}
|
|
263
|
+
if (shouldUpdate) {
|
|
244
264
|
setState(prevState => _extends({}, prevState, {
|
|
245
265
|
value: valueFromTheOutside,
|
|
246
266
|
referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, prevState.referenceValue),
|
|
@@ -82,15 +82,12 @@ export const usePickerViews = ({
|
|
|
82
82
|
hasUIView: false,
|
|
83
83
|
viewModeLookup: {}
|
|
84
84
|
}), [disableOpenPicker, viewRenderers, views]);
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, 0);
|
|
92
|
-
return numberUITimeViews > 1;
|
|
93
|
-
}, [viewRenderers, views]);
|
|
85
|
+
const timeViewsCount = React.useMemo(() => views.reduce((acc, viewForReduce) => {
|
|
86
|
+
if (viewRenderers[viewForReduce] != null && isTimeView(viewForReduce)) {
|
|
87
|
+
return acc + 1;
|
|
88
|
+
}
|
|
89
|
+
return acc;
|
|
90
|
+
}, 0), [viewRenderers, views]);
|
|
94
91
|
const currentViewMode = viewModeLookup[view];
|
|
95
92
|
const shouldRestoreFocus = useEventCallback(() => currentViewMode === 'UI');
|
|
96
93
|
const [popperView, setPopperView] = React.useState(currentViewMode === 'UI' ? view : null);
|
|
@@ -152,7 +149,8 @@ export const usePickerViews = ({
|
|
|
152
149
|
onViewChange: setView,
|
|
153
150
|
focusedView,
|
|
154
151
|
onFocusedViewChange: setFocusedView,
|
|
155
|
-
showViewSwitcher:
|
|
152
|
+
showViewSwitcher: timeViewsCount > 1,
|
|
153
|
+
timeViewsCount
|
|
156
154
|
}));
|
|
157
155
|
}
|
|
158
156
|
};
|
|
@@ -51,15 +51,6 @@ export function useViews({
|
|
|
51
51
|
const viewIndex = views.indexOf(view);
|
|
52
52
|
const previousView = views[viewIndex - 1] ?? null;
|
|
53
53
|
const nextView = views[viewIndex + 1] ?? null;
|
|
54
|
-
const handleChangeView = useEventCallback(newView => {
|
|
55
|
-
if (newView === view) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
setView(newView);
|
|
59
|
-
if (onViewChange) {
|
|
60
|
-
onViewChange(newView);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
54
|
const handleFocusedViewChange = useEventCallback((viewToFocus, hasFocus) => {
|
|
64
55
|
if (hasFocus) {
|
|
65
56
|
// Focus event
|
|
@@ -72,6 +63,16 @@ export function useViews({
|
|
|
72
63
|
|
|
73
64
|
onFocusedViewChange?.(viewToFocus, hasFocus);
|
|
74
65
|
});
|
|
66
|
+
const handleChangeView = useEventCallback(newView => {
|
|
67
|
+
if (newView === view) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setView(newView);
|
|
71
|
+
handleFocusedViewChange(newView, true);
|
|
72
|
+
if (onViewChange) {
|
|
73
|
+
onViewChange(newView);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
75
76
|
const goToNextView = useEventCallback(() => {
|
|
76
77
|
if (nextView) {
|
|
77
78
|
handleChangeView(nextView);
|
|
@@ -15,8 +15,9 @@ export { useStaticPicker } from './hooks/useStaticPicker';
|
|
|
15
15
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
|
|
16
16
|
export { useValidation } from './hooks/useValidation';
|
|
17
17
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
18
|
-
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
|
|
18
|
+
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate } from './utils/date-utils';
|
|
19
19
|
export { splitFieldInternalAndForwardedProps } from './utils/fields';
|
|
20
|
+
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
|
|
20
21
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
|
|
21
22
|
export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
|
|
22
23
|
export { extractValidationProps } from './utils/validation/extractValidationProps';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["views", "format"];
|
|
4
|
+
import { resolveTimeFormat, isTimeView } from './time-utils';
|
|
5
|
+
import { resolveDateFormat } from './date-utils';
|
|
6
|
+
export const resolveDateTimeFormat = (utils, _ref) => {
|
|
7
|
+
let {
|
|
8
|
+
views,
|
|
9
|
+
format
|
|
10
|
+
} = _ref,
|
|
11
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
12
|
+
if (format) {
|
|
13
|
+
return format;
|
|
14
|
+
}
|
|
15
|
+
const dateViews = [];
|
|
16
|
+
const timeViews = [];
|
|
17
|
+
views.forEach(view => {
|
|
18
|
+
if (isTimeView(view)) {
|
|
19
|
+
timeViews.push(view);
|
|
20
|
+
} else {
|
|
21
|
+
dateViews.push(view);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
if (timeViews.length === 0) {
|
|
25
|
+
return resolveDateFormat(utils, _extends({
|
|
26
|
+
views: dateViews
|
|
27
|
+
}, other), false);
|
|
28
|
+
}
|
|
29
|
+
if (dateViews.length === 0) {
|
|
30
|
+
return resolveTimeFormat(utils, _extends({
|
|
31
|
+
views: timeViews
|
|
32
|
+
}, other));
|
|
33
|
+
}
|
|
34
|
+
const timeFormat = resolveTimeFormat(utils, _extends({
|
|
35
|
+
views: timeViews
|
|
36
|
+
}, other));
|
|
37
|
+
const dateFormat = resolveDateFormat(utils, _extends({
|
|
38
|
+
views: dateViews
|
|
39
|
+
}, other), false);
|
|
40
|
+
return `${dateFormat} ${timeFormat}`;
|
|
41
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { areViewsEqual } from './views';
|
|
1
2
|
export const findClosestEnabledDate = ({
|
|
2
3
|
date,
|
|
3
4
|
disableFuture,
|
|
@@ -85,4 +86,38 @@ export const mergeDateAndTime = (utils, dateParam, timeParam) => {
|
|
|
85
86
|
mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
|
|
86
87
|
mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
|
|
87
88
|
return mergedDate;
|
|
89
|
+
};
|
|
90
|
+
export const getTodayDate = (utils, valueType) => valueType === 'date' ? utils.startOfDay(utils.date()) : utils.date();
|
|
91
|
+
const dateViews = ['year', 'month', 'day'];
|
|
92
|
+
export const isDatePickerView = view => dateViews.includes(view);
|
|
93
|
+
export const resolveDateFormat = (utils, {
|
|
94
|
+
format,
|
|
95
|
+
views
|
|
96
|
+
}, isInToolbar) => {
|
|
97
|
+
if (format != null) {
|
|
98
|
+
return format;
|
|
99
|
+
}
|
|
100
|
+
const formats = utils.formats;
|
|
101
|
+
if (areViewsEqual(views, ['year'])) {
|
|
102
|
+
return formats.year;
|
|
103
|
+
}
|
|
104
|
+
if (areViewsEqual(views, ['month'])) {
|
|
105
|
+
return formats.month;
|
|
106
|
+
}
|
|
107
|
+
if (areViewsEqual(views, ['day'])) {
|
|
108
|
+
return formats.dayOfMonth;
|
|
109
|
+
}
|
|
110
|
+
if (areViewsEqual(views, ['month', 'year'])) {
|
|
111
|
+
return `${formats.month} ${formats.year}`;
|
|
112
|
+
}
|
|
113
|
+
if (areViewsEqual(views, ['day', 'month'])) {
|
|
114
|
+
return `${formats.month} ${formats.dayOfMonth}`;
|
|
115
|
+
}
|
|
116
|
+
if (isInToolbar) {
|
|
117
|
+
// Little localization hack (Google is doing the same for android native pickers):
|
|
118
|
+
// For english localization it is convenient to include weekday into the date "Mon, Jun 1".
|
|
119
|
+
// For other locales using strings like "June 1", without weekday.
|
|
120
|
+
return /en/.test(utils.getCurrentLocaleCode()) ? formats.normalDateWithWeekday : formats.normalDate;
|
|
121
|
+
}
|
|
122
|
+
return formats.keyboardDate;
|
|
88
123
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from './validation/extractValidationProps';
|
|
3
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'format', 'formatDensity', 'onChange', 'readOnly', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef'];
|
|
3
|
+
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'readOnly', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef'];
|
|
4
4
|
export const splitFieldInternalAndForwardedProps = (props, valueType) => {
|
|
5
5
|
const forwardedProps = _extends({}, props);
|
|
6
6
|
const internalProps = {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createIsAfterIgnoreDatePart } from './time-utils';
|
|
2
|
+
import { mergeDateAndTime, getTodayDate } from './date-utils';
|
|
3
|
+
const SECTION_TYPE_GRANULARITY = {
|
|
4
|
+
year: 1,
|
|
5
|
+
month: 2,
|
|
6
|
+
day: 3,
|
|
7
|
+
hours: 4,
|
|
8
|
+
minutes: 5,
|
|
9
|
+
seconds: 6,
|
|
10
|
+
milliseconds: 7
|
|
11
|
+
};
|
|
12
|
+
export const getSectionTypeGranularity = sections => Math.max(...sections.map(section => SECTION_TYPE_GRANULARITY[section.type] ?? 1));
|
|
13
|
+
const roundDate = (utils, granularity, date) => {
|
|
14
|
+
if (granularity === SECTION_TYPE_GRANULARITY.year) {
|
|
15
|
+
return utils.startOfYear(date);
|
|
16
|
+
}
|
|
17
|
+
if (granularity === SECTION_TYPE_GRANULARITY.month) {
|
|
18
|
+
return utils.startOfMonth(date);
|
|
19
|
+
}
|
|
20
|
+
if (granularity === SECTION_TYPE_GRANULARITY.day) {
|
|
21
|
+
return utils.startOfDay(date);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// We don't have startOfHour / startOfMinute / startOfSecond
|
|
25
|
+
let roundedDate = date;
|
|
26
|
+
if (granularity < SECTION_TYPE_GRANULARITY.minutes) {
|
|
27
|
+
roundedDate = utils.setMinutes(roundedDate, 0);
|
|
28
|
+
}
|
|
29
|
+
if (granularity < SECTION_TYPE_GRANULARITY.seconds) {
|
|
30
|
+
roundedDate = utils.setSeconds(roundedDate, 0);
|
|
31
|
+
}
|
|
32
|
+
if (granularity < SECTION_TYPE_GRANULARITY.milliseconds) {
|
|
33
|
+
roundedDate = utils.setMilliseconds(roundedDate, 0);
|
|
34
|
+
}
|
|
35
|
+
return roundedDate;
|
|
36
|
+
};
|
|
37
|
+
export const getDefaultReferenceDate = ({
|
|
38
|
+
props,
|
|
39
|
+
utils,
|
|
40
|
+
valueType,
|
|
41
|
+
granularity
|
|
42
|
+
}) => {
|
|
43
|
+
let referenceDate = roundDate(utils, granularity, getTodayDate(utils, valueType));
|
|
44
|
+
if (props.minDate != null && utils.isAfterDay(props.minDate, referenceDate)) {
|
|
45
|
+
referenceDate = roundDate(utils, granularity, props.minDate);
|
|
46
|
+
}
|
|
47
|
+
if (props.maxDate != null && utils.isBeforeDay(props.maxDate, referenceDate)) {
|
|
48
|
+
referenceDate = roundDate(utils, granularity, props.maxDate);
|
|
49
|
+
}
|
|
50
|
+
const isAfter = createIsAfterIgnoreDatePart(props.disableIgnoringDatePartForTimeValidation ?? false, utils);
|
|
51
|
+
if (props.minTime != null && isAfter(props.minTime, referenceDate)) {
|
|
52
|
+
referenceDate = roundDate(utils, granularity, props.disableIgnoringDatePartForTimeValidation ? props.minTime : mergeDateAndTime(utils, referenceDate, props.minTime));
|
|
53
|
+
}
|
|
54
|
+
if (props.maxTime != null && isAfter(referenceDate, props.maxTime)) {
|
|
55
|
+
referenceDate = roundDate(utils, granularity, props.disableIgnoringDatePartForTimeValidation ? props.maxTime : mergeDateAndTime(utils, referenceDate, props.maxTime));
|
|
56
|
+
}
|
|
57
|
+
return referenceDate;
|
|
58
|
+
};
|