@mui/x-date-pickers 6.5.0 → 6.6.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 +18 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/AdapterDayjs/AdapterDayjs.d.ts +14 -1
- package/AdapterDayjs/AdapterDayjs.js +131 -14
- package/AdapterLuxon/AdapterLuxon.d.ts +7 -1
- package/AdapterLuxon/AdapterLuxon.js +58 -9
- package/AdapterMoment/AdapterMoment.d.ts +12 -1
- package/AdapterMoment/AdapterMoment.js +91 -2
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +4 -0
- package/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +4 -0
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/CHANGELOG.md +78 -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/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 +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +53 -10
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +10 -3
- package/DesktopTimePicker/DesktopTimePicker.js +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +8 -7
- 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/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-utils.d.ts +4 -1
- package/internals/utils/date-utils.js +4 -1
- 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 +2 -1
- package/internals/utils/time-utils.js +1 -0
- package/internals/utils/valueManagers.js +21 -3
- package/legacy/AdapterDateFns/AdapterDateFns.js +18 -0
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/legacy/AdapterDayjs/AdapterDayjs.js +135 -14
- package/legacy/AdapterLuxon/AdapterLuxon.js +58 -9
- package/legacy/AdapterMoment/AdapterMoment.js +97 -6
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/legacy/DateCalendar/DateCalendar.js +2 -2
- package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
- package/legacy/DateField/DateField.js +6 -0
- 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 +2 -2
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +54 -10
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +2 -2
- 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-utils.js +7 -0
- package/legacy/internals/utils/fields.js +1 -1
- package/legacy/internals/utils/getDefaultReferenceDate.js +64 -0
- package/legacy/internals/utils/time-utils.js +3 -0
- package/legacy/internals/utils/valueManagers.js +20 -4
- package/legacy/locales/index.js +1 -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/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/viVN.d.ts +53 -0
- package/locales/viVN.js +57 -0
- package/models/adapters.d.ts +50 -9
- 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 +18 -0
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +130 -14
- package/modern/AdapterLuxon/AdapterLuxon.js +57 -9
- package/modern/AdapterMoment/AdapterMoment.js +90 -2
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +2 -2
- package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
- package/modern/DateField/DateField.js +6 -0
- 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 +2 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +52 -9
- package/modern/DesktopTimePicker/DesktopTimePicker.js +2 -2
- 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-utils.js +4 -1
- package/modern/internals/utils/fields.js +1 -1
- package/modern/internals/utils/getDefaultReferenceDate.js +58 -0
- package/modern/internals/utils/time-utils.js +1 -0
- package/modern/internals/utils/valueManagers.js +21 -3
- package/modern/locales/index.js +1 -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 +18 -0
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +18 -0
- package/node/AdapterDayjs/AdapterDayjs.js +130 -14
- package/node/AdapterLuxon/AdapterLuxon.js +57 -9
- package/node/AdapterMoment/AdapterMoment.js +90 -2
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +10 -0
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +10 -0
- package/node/DateCalendar/DateCalendar.js +2 -2
- package/node/DateCalendar/PickersCalendarHeader.js +2 -2
- package/node/DateField/DateField.js +6 -0
- 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 +2 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +52 -9
- package/node/DesktopTimePicker/DesktopTimePicker.js +2 -2
- 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-utils.js +7 -2
- package/node/internals/utils/fields.js +1 -1
- package/node/internals/utils/getDefaultReferenceDate.js +66 -0
- package/node/internals/utils/time-utils.js +3 -1
- package/node/internals/utils/valueManagers.js +21 -2
- package/node/locales/index.js +11 -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
|
@@ -6,7 +6,7 @@ import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
|
6
6
|
import { getDatePickerFieldFormat, useDatePickerDefaultizedProps } from '../DatePicker/shared';
|
|
7
7
|
import { useLocaleText, useUtils, validateDate } from '../internals';
|
|
8
8
|
import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
9
|
-
import {
|
|
9
|
+
import { CalendarIcon } from '../icons';
|
|
10
10
|
import { DateField } from '../DateField';
|
|
11
11
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
12
12
|
import { renderDateViewCalendar } from '../dateViewRenderers';
|
|
@@ -28,7 +28,7 @@ const DesktopDatePicker = /*#__PURE__*/React.forwardRef(function DesktopDatePick
|
|
|
28
28
|
format: getDatePickerFieldFormat(utils, defaultizedProps),
|
|
29
29
|
yearsPerRow: defaultizedProps.yearsPerRow ?? 4,
|
|
30
30
|
slots: _extends({
|
|
31
|
-
openPickerIcon:
|
|
31
|
+
openPickerIcon: CalendarIcon,
|
|
32
32
|
field: DateField
|
|
33
33
|
}, defaultizedProps.slots),
|
|
34
34
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
@@ -5,9 +5,10 @@ import { resolveComponentProps } from '@mui/base/utils';
|
|
|
5
5
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
6
6
|
import { DateTimeField } from '../DateTimeField';
|
|
7
7
|
import { useDateTimePickerDefaultizedProps } from '../DateTimePicker/shared';
|
|
8
|
-
import { renderDateViewCalendar } from '../dateViewRenderers';
|
|
8
|
+
import { renderDateViewCalendar } from '../dateViewRenderers/dateViewRenderers';
|
|
9
|
+
import { renderDesktopDateTimeView } from '../dateTimeViewRenderers';
|
|
9
10
|
import { useLocaleText, validateDateTime } from '../internals';
|
|
10
|
-
import {
|
|
11
|
+
import { CalendarIcon } from '../icons';
|
|
11
12
|
import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
12
13
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
13
14
|
const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimePicker(inProps, ref) {
|
|
@@ -15,24 +16,45 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
15
16
|
|
|
16
17
|
// Props with the default values common to all date time pickers
|
|
17
18
|
const defaultizedProps = useDateTimePickerDefaultizedProps(inProps, 'MuiDesktopDateTimePicker');
|
|
18
|
-
const
|
|
19
|
+
const timeSteps = _extends({
|
|
20
|
+
hours: 1,
|
|
21
|
+
minutes: 5,
|
|
22
|
+
seconds: 5
|
|
23
|
+
}, defaultizedProps.timeSteps);
|
|
24
|
+
const shouldUseNewRenderer = !defaultizedProps.viewRenderers || Object.keys(defaultizedProps.viewRenderers).length === 0;
|
|
25
|
+
const viewRenderers =
|
|
26
|
+
// we can only ensure the expected two-column layout if none of the renderers are overridden
|
|
27
|
+
shouldUseNewRenderer ? {
|
|
28
|
+
day: renderDesktopDateTimeView,
|
|
29
|
+
month: renderDesktopDateTimeView,
|
|
30
|
+
year: renderDesktopDateTimeView,
|
|
31
|
+
hours: renderDesktopDateTimeView,
|
|
32
|
+
minutes: renderDesktopDateTimeView,
|
|
33
|
+
seconds: renderDesktopDateTimeView,
|
|
34
|
+
meridiem: renderDesktopDateTimeView
|
|
35
|
+
} : _extends({
|
|
19
36
|
day: renderDateViewCalendar,
|
|
20
37
|
month: renderDateViewCalendar,
|
|
21
38
|
year: renderDateViewCalendar,
|
|
22
39
|
hours: null,
|
|
23
40
|
minutes: null,
|
|
24
|
-
seconds: null
|
|
41
|
+
seconds: null,
|
|
42
|
+
meridiem: null
|
|
25
43
|
}, defaultizedProps.viewRenderers);
|
|
26
44
|
const ampmInClock = defaultizedProps.ampmInClock ?? true;
|
|
45
|
+
// add "accept" action only when the new date time view renderers are used
|
|
46
|
+
const actionBarActions = shouldUseNewRenderer ? ['accept'] : [];
|
|
27
47
|
|
|
28
48
|
// Props with the default values specific to the desktop variant
|
|
29
49
|
const props = _extends({}, defaultizedProps, {
|
|
30
50
|
viewRenderers,
|
|
51
|
+
views: defaultizedProps.ampm ? [...defaultizedProps.views, 'meridiem'] : defaultizedProps.views,
|
|
31
52
|
yearsPerRow: defaultizedProps.yearsPerRow ?? 4,
|
|
32
53
|
ampmInClock,
|
|
54
|
+
timeSteps,
|
|
33
55
|
slots: _extends({
|
|
34
56
|
field: DateTimeField,
|
|
35
|
-
openPickerIcon:
|
|
57
|
+
openPickerIcon: CalendarIcon
|
|
36
58
|
}, defaultizedProps.slots),
|
|
37
59
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
38
60
|
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
@@ -40,11 +62,15 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
40
62
|
}),
|
|
41
63
|
toolbar: _extends({
|
|
42
64
|
hidden: true,
|
|
43
|
-
ampmInClock
|
|
65
|
+
ampmInClock,
|
|
66
|
+
toolbarVariant: shouldUseNewRenderer ? 'desktop' : 'mobile'
|
|
44
67
|
}, defaultizedProps.slotProps?.toolbar),
|
|
45
68
|
tabs: _extends({
|
|
46
69
|
hidden: true
|
|
47
|
-
}, defaultizedProps.slotProps?.tabs)
|
|
70
|
+
}, defaultizedProps.slotProps?.tabs),
|
|
71
|
+
actionBar: _extends({
|
|
72
|
+
actions: actionBarActions
|
|
73
|
+
}, defaultizedProps.slotProps?.actionBar)
|
|
48
74
|
})
|
|
49
75
|
});
|
|
50
76
|
const {
|
|
@@ -292,7 +318,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
292
318
|
* Used when the component view is not controlled.
|
|
293
319
|
* Must be a valid option from `views` list.
|
|
294
320
|
*/
|
|
295
|
-
openTo: PropTypes.oneOf(['day', 'hours', 'minutes', 'month', 'seconds', 'year']),
|
|
321
|
+
openTo: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
296
322
|
/**
|
|
297
323
|
* Force rendering in particular orientation.
|
|
298
324
|
*/
|
|
@@ -370,6 +396,11 @@ DesktopDateTimePicker.propTypes = {
|
|
|
370
396
|
* @default false
|
|
371
397
|
*/
|
|
372
398
|
showDaysOutsideCurrentMonth: PropTypes.bool,
|
|
399
|
+
/**
|
|
400
|
+
* If `true`, disabled digital clock items will not be rendered.
|
|
401
|
+
* @default false
|
|
402
|
+
*/
|
|
403
|
+
skipDisabled: PropTypes.bool,
|
|
373
404
|
/**
|
|
374
405
|
* The props used for each component slot.
|
|
375
406
|
* @default {}
|
|
@@ -384,6 +415,17 @@ DesktopDateTimePicker.propTypes = {
|
|
|
384
415
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
385
416
|
*/
|
|
386
417
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
418
|
+
/**
|
|
419
|
+
* The time steps between two time unit options.
|
|
420
|
+
* For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
421
|
+
* When single column time renderer is used, only `timeStep.minutes` will be used.
|
|
422
|
+
* @default{ hours: 1, minutes: 5, seconds: 5 }
|
|
423
|
+
*/
|
|
424
|
+
timeSteps: PropTypes.shape({
|
|
425
|
+
hours: PropTypes.number,
|
|
426
|
+
minutes: PropTypes.number,
|
|
427
|
+
seconds: PropTypes.number
|
|
428
|
+
}),
|
|
387
429
|
/**
|
|
388
430
|
* The selected value.
|
|
389
431
|
* Used when the component is controlled.
|
|
@@ -394,7 +436,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
394
436
|
* Used when the component view is controlled.
|
|
395
437
|
* Must be a valid option from `views` list.
|
|
396
438
|
*/
|
|
397
|
-
view: PropTypes.oneOf(['day', 'hours', 'minutes', 'month', 'seconds', 'year']),
|
|
439
|
+
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
398
440
|
/**
|
|
399
441
|
* Define custom view renderers for each section.
|
|
400
442
|
* If `null`, the section will only have field editing.
|
|
@@ -403,6 +445,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
403
445
|
viewRenderers: PropTypes.shape({
|
|
404
446
|
day: PropTypes.func,
|
|
405
447
|
hours: PropTypes.func,
|
|
448
|
+
meridiem: PropTypes.func,
|
|
406
449
|
minutes: PropTypes.func,
|
|
407
450
|
month: PropTypes.func,
|
|
408
451
|
seconds: PropTypes.func,
|
|
@@ -6,7 +6,7 @@ import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
|
6
6
|
import { TimeField } from '../TimeField';
|
|
7
7
|
import { useTimePickerDefaultizedProps } from '../TimePicker/shared';
|
|
8
8
|
import { useLocaleText, validateTime } from '../internals';
|
|
9
|
-
import {
|
|
9
|
+
import { ClockIcon } from '../icons';
|
|
10
10
|
import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
11
11
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
12
12
|
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from '../timeViewRenderers';
|
|
@@ -45,7 +45,7 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
|
|
|
45
45
|
views: shouldRenderTimeInASingleColumn ? ['hours'] : views,
|
|
46
46
|
slots: _extends({
|
|
47
47
|
field: TimeField,
|
|
48
|
-
openPickerIcon:
|
|
48
|
+
openPickerIcon: ClockIcon
|
|
49
49
|
}, defaultizedProps.slots),
|
|
50
50
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
51
51
|
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
@@ -104,7 +104,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
104
104
|
onFocusedViewChange(newHasFocus);
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
-
const isMonthDisabled =
|
|
107
|
+
const isMonthDisabled = React.useCallback(month => {
|
|
108
108
|
const firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, minDate) ? now : minDate);
|
|
109
109
|
const lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, maxDate) ? now : maxDate);
|
|
110
110
|
if (utils.isBefore(month, firstEnabledMonth)) {
|
|
@@ -117,7 +117,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
return shouldDisableMonth(month);
|
|
120
|
-
});
|
|
120
|
+
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableMonth, utils]);
|
|
121
121
|
const handleMonthSelection = useEventCallback((event, month) => {
|
|
122
122
|
if (readOnly) {
|
|
123
123
|
return;
|
|
@@ -9,7 +9,7 @@ import MenuList from '@mui/material/MenuList';
|
|
|
9
9
|
import MenuItem from '@mui/material/MenuItem';
|
|
10
10
|
import useForkRef from '@mui/utils/useForkRef';
|
|
11
11
|
import { getMultiSectionDigitalClockSectionUtilityClass } from './multiSectionDigitalClockSectionClasses';
|
|
12
|
-
import { DIGITAL_CLOCK_VIEW_HEIGHT } from '../internals/constants/dimensions';
|
|
12
|
+
import { DIGITAL_CLOCK_VIEW_HEIGHT, MULTI_SECTION_CLOCK_SECTION_WIDTH } from '../internals/constants/dimensions';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
const useUtilityClasses = ownerState => {
|
|
15
15
|
const {
|
|
@@ -43,7 +43,8 @@ const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
|
|
|
43
43
|
'&:after': {
|
|
44
44
|
display: 'block',
|
|
45
45
|
content: '""',
|
|
46
|
-
height
|
|
46
|
+
// subtracting the height of one item, extra margin and borders to make sure the max height is correct
|
|
47
|
+
height: 'calc(100% - 40px - 6px)'
|
|
47
48
|
}
|
|
48
49
|
}));
|
|
49
50
|
const MultiSectionDigitalClockSectionItem = styled(MenuItem, {
|
|
@@ -55,7 +56,7 @@ const MultiSectionDigitalClockSectionItem = styled(MenuItem, {
|
|
|
55
56
|
}) => ({
|
|
56
57
|
padding: 8,
|
|
57
58
|
margin: '2px 4px',
|
|
58
|
-
width:
|
|
59
|
+
width: MULTI_SECTION_CLOCK_SECTION_WIDTH,
|
|
59
60
|
justifyContent: 'center',
|
|
60
61
|
'&:first-of-type': {
|
|
61
62
|
marginTop: 4
|
|
@@ -245,6 +245,12 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
245
245
|
* @default false
|
|
246
246
|
*/
|
|
247
247
|
readOnly: PropTypes.bool,
|
|
248
|
+
/**
|
|
249
|
+
* The date used to generate a part of the date-time that is not present in the format when both `value` and `defaultValue` are not present.
|
|
250
|
+
* For example, on time fields it will be used to determine the date to set.
|
|
251
|
+
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
252
|
+
*/
|
|
253
|
+
referenceDate: PropTypes.any,
|
|
248
254
|
/**
|
|
249
255
|
* If `true`, the label is displayed as required and the `input` element is required.
|
|
250
256
|
* @default false
|
|
@@ -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.6.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),
|