@mui/x-date-pickers 6.7.0 → 6.9.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/AdapterDayjs/AdapterDayjs.d.ts +5 -1
- package/AdapterDayjs/AdapterDayjs.js +42 -15
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -0
- package/AdapterLuxon/AdapterLuxon.js +12 -5
- package/AdapterMoment/AdapterMoment.js +18 -9
- package/CHANGELOG.md +145 -5541
- package/DateCalendar/DateCalendar.js +49 -21
- package/DateCalendar/DateCalendar.types.d.ts +8 -3
- package/DateCalendar/DayCalendar.d.ts +3 -1
- package/DateCalendar/DayCalendar.js +24 -17
- package/DateCalendar/PickersCalendarHeader.js +6 -3
- package/DateCalendar/useCalendarState.d.ts +5 -3
- package/DateCalendar/useCalendarState.js +41 -17
- package/DateCalendar/useIsDateDisabled.d.ts +1 -1
- package/DateCalendar/useIsDateDisabled.js +5 -3
- package/DateField/DateField.js +9 -1
- package/DatePicker/DatePicker.js +9 -1
- package/DateTimeField/DateTimeField.js +9 -1
- package/DateTimePicker/DateTimePicker.js +9 -1
- package/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/DigitalClock/DigitalClock.js +28 -15
- package/MobileDatePicker/MobileDatePicker.js +9 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/MobileTimePicker/MobileTimePicker.js +8 -0
- package/MonthCalendar/MonthCalendar.js +57 -24
- package/MonthCalendar/MonthCalendar.types.d.ts +8 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/PickersLayout/PickersLayout.js +1 -0
- package/PickersLayout/usePickerLayout.js +4 -3
- package/PickersShortcuts/PickersShortcuts.d.ts +12 -2
- package/PickersShortcuts/PickersShortcuts.js +10 -2
- package/PickersShortcuts/index.d.ts +1 -1
- package/StaticDatePicker/StaticDatePicker.js +9 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/StaticTimePicker/StaticTimePicker.js +8 -0
- package/TimeClock/TimeClock.js +27 -15
- package/TimeField/TimeField.js +9 -1
- package/TimePicker/TimePicker.js +8 -0
- package/YearCalendar/YearCalendar.js +55 -22
- package/YearCalendar/YearCalendar.types.d.ts +8 -2
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.js +4 -2
- package/index.js +1 -1
- package/internals/hooks/date-helpers-hooks.d.ts +4 -2
- package/internals/hooks/date-helpers-hooks.js +8 -6
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/internals/hooks/useField/useField.d.ts +3 -1
- package/internals/hooks/useField/useField.js +23 -7
- package/internals/hooks/useField/useField.types.d.ts +6 -4
- package/internals/hooks/useField/useField.utils.d.ts +13 -11
- package/internals/hooks/useField/useField.utils.js +55 -43
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +3 -2
- package/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/internals/hooks/useField/useFieldState.d.ts +1 -0
- package/internals/hooks/useField/useFieldState.js +33 -23
- package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/internals/hooks/usePicker/usePickerValue.js +45 -9
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +22 -6
- package/internals/hooks/usePicker/usePickerViews.d.ts +2 -1
- package/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/internals/hooks/useUtils.d.ts +3 -2
- package/internals/hooks/useUtils.js +5 -2
- package/internals/hooks/useValueWithTimezone.d.ts +33 -0
- package/internals/hooks/useValueWithTimezone.js +69 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/models/props/clock.d.ts +2 -2
- package/internals/utils/date-utils.d.ts +4 -4
- package/internals/utils/date-utils.js +4 -12
- package/internals/utils/fields.js +1 -1
- package/internals/utils/getDefaultReferenceDate.d.ts +12 -3
- package/internals/utils/getDefaultReferenceDate.js +4 -4
- package/internals/utils/validation/extractValidationProps.d.ts +1 -1
- package/internals/utils/validation/validateDate.d.ts +3 -2
- package/internals/utils/validation/validateDate.js +14 -6
- package/internals/utils/validation/validateTime.d.ts +3 -2
- package/internals/utils/validation/validateTime.js +8 -8
- package/internals/utils/valueManagers.js +2 -1
- package/legacy/AdapterDayjs/AdapterDayjs.js +45 -16
- package/legacy/AdapterLuxon/AdapterLuxon.js +13 -6
- package/legacy/AdapterMoment/AdapterMoment.js +18 -9
- package/legacy/DateCalendar/DateCalendar.js +47 -24
- package/legacy/DateCalendar/DayCalendar.js +24 -17
- package/legacy/DateCalendar/PickersCalendarHeader.js +6 -3
- package/legacy/DateCalendar/useCalendarState.js +40 -17
- package/legacy/DateCalendar/useIsDateDisabled.js +5 -3
- package/legacy/DateField/DateField.js +9 -1
- package/legacy/DatePicker/DatePicker.js +9 -1
- package/legacy/DateTimeField/DateTimeField.js +9 -1
- package/legacy/DateTimePicker/DateTimePicker.js +9 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/legacy/DigitalClock/DigitalClock.js +26 -16
- package/legacy/MobileDatePicker/MobileDatePicker.js +9 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +8 -0
- package/legacy/MonthCalendar/MonthCalendar.js +61 -32
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +27 -16
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/legacy/PickersLayout/PickersLayout.js +1 -0
- package/legacy/PickersLayout/usePickerLayout.js +3 -2
- package/legacy/PickersShortcuts/PickersShortcuts.js +10 -2
- package/legacy/StaticDatePicker/StaticDatePicker.js +9 -1
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/legacy/StaticTimePicker/StaticTimePicker.js +8 -0
- package/legacy/TimeClock/TimeClock.js +25 -18
- package/legacy/TimeField/TimeField.js +9 -1
- package/legacy/TimePicker/TimePicker.js +8 -0
- package/legacy/YearCalendar/YearCalendar.js +59 -30
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/legacy/dateViewRenderers/dateViewRenderers.js +4 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/date-helpers-hooks.js +8 -6
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/legacy/internals/hooks/useField/useField.js +22 -6
- package/legacy/internals/hooks/useField/useField.utils.js +56 -44
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/legacy/internals/hooks/useField/useFieldState.js +42 -33
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +46 -9
- package/legacy/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/legacy/internals/hooks/useUtils.js +5 -2
- package/legacy/internals/hooks/useValueWithTimezone.js +81 -0
- package/legacy/internals/index.js +1 -0
- package/legacy/internals/utils/date-utils.js +5 -13
- package/legacy/internals/utils/fields.js +1 -1
- package/legacy/internals/utils/getDefaultReferenceDate.js +4 -4
- package/legacy/internals/utils/validation/validateDate.js +12 -6
- package/legacy/internals/utils/validation/validateTime.js +8 -8
- package/legacy/internals/utils/valueManagers.js +3 -0
- package/legacy/locales/csCZ.js +2 -2
- package/legacy/locales/elGR.js +93 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/tests/describeAdapters/describeAdapters.js +3 -1
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/legacy/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/legacy/timeViewRenderers/timeViewRenderers.js +12 -6
- package/locales/csCZ.js +2 -2
- package/locales/elGR.d.ts +53 -0
- package/locales/elGR.js +57 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/models/adapters.d.ts +2 -2
- package/models/timezone.d.ts +10 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +41 -15
- package/modern/AdapterLuxon/AdapterLuxon.js +12 -4
- package/modern/AdapterMoment/AdapterMoment.js +18 -9
- package/modern/DateCalendar/DateCalendar.js +49 -21
- package/modern/DateCalendar/DayCalendar.js +24 -17
- package/modern/DateCalendar/PickersCalendarHeader.js +6 -3
- package/modern/DateCalendar/useCalendarState.js +41 -16
- package/modern/DateCalendar/useIsDateDisabled.js +5 -3
- package/modern/DateField/DateField.js +9 -1
- package/modern/DatePicker/DatePicker.js +9 -1
- package/modern/DateTimeField/DateTimeField.js +9 -1
- package/modern/DateTimePicker/DateTimePicker.js +9 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/modern/DigitalClock/DigitalClock.js +28 -15
- package/modern/MobileDatePicker/MobileDatePicker.js +9 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +8 -0
- package/modern/MonthCalendar/MonthCalendar.js +57 -24
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/modern/PickersLayout/PickersLayout.js +1 -0
- package/modern/PickersLayout/usePickerLayout.js +4 -3
- package/modern/PickersShortcuts/PickersShortcuts.js +10 -2
- package/modern/StaticDatePicker/StaticDatePicker.js +9 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/modern/StaticTimePicker/StaticTimePicker.js +8 -0
- package/modern/TimeClock/TimeClock.js +27 -15
- package/modern/TimeField/TimeField.js +9 -1
- package/modern/TimePicker/TimePicker.js +8 -0
- package/modern/YearCalendar/YearCalendar.js +55 -22
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/modern/dateViewRenderers/dateViewRenderers.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/hooks/date-helpers-hooks.js +8 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/modern/internals/hooks/useField/useField.js +23 -7
- package/modern/internals/hooks/useField/useField.utils.js +55 -43
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/modern/internals/hooks/useField/useFieldState.js +33 -22
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +45 -9
- package/modern/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/modern/internals/hooks/useUtils.js +5 -2
- package/modern/internals/hooks/useValueWithTimezone.js +68 -0
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/date-utils.js +4 -12
- package/modern/internals/utils/fields.js +1 -1
- package/modern/internals/utils/getDefaultReferenceDate.js +4 -4
- package/modern/internals/utils/validation/validateDate.js +14 -6
- package/modern/internals/utils/validation/validateTime.js +8 -8
- package/modern/internals/utils/valueManagers.js +2 -1
- package/modern/locales/csCZ.js +2 -2
- package/modern/locales/elGR.js +57 -0
- package/modern/locales/index.js +1 -0
- package/modern/tests/describeAdapters/describeAdapters.js +3 -1
- package/modern/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/modern/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/modern/timeViewRenderers/timeViewRenderers.js +12 -6
- package/node/AdapterDayjs/AdapterDayjs.js +41 -15
- package/node/AdapterLuxon/AdapterLuxon.js +12 -4
- package/node/AdapterMoment/AdapterMoment.js +18 -9
- package/node/DateCalendar/DateCalendar.js +48 -20
- package/node/DateCalendar/DayCalendar.js +24 -17
- package/node/DateCalendar/PickersCalendarHeader.js +6 -3
- package/node/DateCalendar/useCalendarState.js +41 -16
- package/node/DateCalendar/useIsDateDisabled.js +5 -3
- package/node/DateField/DateField.js +9 -1
- package/node/DatePicker/DatePicker.js +9 -1
- package/node/DateTimeField/DateTimeField.js +9 -1
- package/node/DateTimePicker/DateTimePicker.js +9 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +9 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
- package/node/DesktopTimePicker/DesktopTimePicker.js +8 -0
- package/node/DigitalClock/DigitalClock.js +28 -15
- package/node/MobileDatePicker/MobileDatePicker.js +9 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
- package/node/MobileTimePicker/MobileTimePicker.js +8 -0
- package/node/MonthCalendar/MonthCalendar.js +57 -24
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
- package/node/PickersLayout/PickersLayout.js +1 -0
- package/node/PickersLayout/usePickerLayout.js +4 -3
- package/node/PickersShortcuts/PickersShortcuts.js +10 -2
- package/node/StaticDatePicker/StaticDatePicker.js +9 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
- package/node/StaticTimePicker/StaticTimePicker.js +8 -0
- package/node/TimeClock/TimeClock.js +26 -14
- package/node/TimeField/TimeField.js +9 -1
- package/node/TimePicker/TimePicker.js +8 -0
- package/node/YearCalendar/YearCalendar.js +55 -22
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
- package/node/dateViewRenderers/dateViewRenderers.js +4 -2
- package/node/index.js +1 -1
- package/node/internals/hooks/date-helpers-hooks.js +8 -6
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/node/internals/hooks/useField/useField.js +23 -7
- package/node/internals/hooks/useField/useField.utils.js +55 -43
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
- package/node/internals/hooks/useField/useFieldState.js +33 -22
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +44 -9
- package/node/internals/hooks/usePicker/usePickerViews.js +7 -2
- package/node/internals/hooks/useUtils.js +5 -2
- package/node/internals/hooks/useValueWithTimezone.js +79 -0
- package/node/internals/index.js +7 -0
- package/node/internals/utils/date-utils.js +5 -14
- package/node/internals/utils/fields.js +1 -1
- package/node/internals/utils/getDefaultReferenceDate.js +5 -4
- package/node/internals/utils/validation/validateDate.js +14 -6
- package/node/internals/utils/validation/validateTime.js +8 -8
- package/node/internals/utils/valueManagers.js +2 -1
- package/node/locales/csCZ.js +2 -2
- package/node/locales/elGR.js +64 -0
- package/node/locales/index.js +11 -0
- package/node/tests/describeAdapters/describeAdapters.js +3 -1
- package/node/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/node/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/node/timeViewRenderers/timeViewRenderers.js +12 -6
- package/package.json +2 -2
- package/tests/describeAdapters/describeAdapters.js +3 -1
- package/tests/describeGregorianAdapter/testCalculations.js +69 -27
- package/tests/describeJalaliAdapter/testCalculations.js +21 -0
- package/timeViewRenderers/timeViewRenderers.d.ts +3 -3
- package/timeViewRenderers/timeViewRenderers.js +12 -6
|
@@ -143,7 +143,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
143
143
|
*/
|
|
144
144
|
dayOfWeekFormatter: PropTypes.func,
|
|
145
145
|
/**
|
|
146
|
-
* Default calendar month displayed when `value
|
|
146
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
147
147
|
*/
|
|
148
148
|
defaultCalendarMonth: PropTypes.any,
|
|
149
149
|
/**
|
|
@@ -434,6 +434,14 @@ DesktopDateTimePicker.propTypes = {
|
|
|
434
434
|
minutes: PropTypes.number,
|
|
435
435
|
seconds: PropTypes.number
|
|
436
436
|
}),
|
|
437
|
+
/**
|
|
438
|
+
* Choose which timezone to use for the value.
|
|
439
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
440
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
441
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
442
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
443
|
+
*/
|
|
444
|
+
timezone: PropTypes.string,
|
|
437
445
|
/**
|
|
438
446
|
* The selected value.
|
|
439
447
|
* Used when the component is controlled.
|
|
@@ -318,6 +318,14 @@ DesktopTimePicker.propTypes = {
|
|
|
318
318
|
minutes: PropTypes.number,
|
|
319
319
|
seconds: PropTypes.number
|
|
320
320
|
}),
|
|
321
|
+
/**
|
|
322
|
+
* Choose which timezone to use for the value.
|
|
323
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
324
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
325
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
326
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
327
|
+
*/
|
|
328
|
+
timezone: PropTypes.string,
|
|
321
329
|
/**
|
|
322
330
|
* The selected value.
|
|
323
331
|
* Used when the component is controlled.
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["ampm", "timeStep", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "defaultValue", "view", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "views", "skipDisabled"];
|
|
3
|
+
const _excluded = ["ampm", "timeStep", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "defaultValue", "view", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "views", "skipDisabled", "timezone"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { alpha, styled, useThemeProps } from '@mui/material/styles';
|
|
8
8
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
9
9
|
import composeClasses from '@mui/utils/composeClasses';
|
|
10
|
-
import useControlled from '@mui/utils/useControlled';
|
|
11
10
|
import MenuItem from '@mui/material/MenuItem';
|
|
12
11
|
import MenuList from '@mui/material/MenuList';
|
|
13
12
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -17,6 +16,8 @@ import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
|
17
16
|
import { getDigitalClockUtilityClass } from './digitalClockClasses';
|
|
18
17
|
import { useViews } from '../internals/hooks/useViews';
|
|
19
18
|
import { DIGITAL_CLOCK_VIEW_HEIGHT } from '../internals/constants/dimensions';
|
|
19
|
+
import { useControlledValueWithTimezone } from '../internals/hooks/useValueWithTimezone';
|
|
20
|
+
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
const useUtilityClasses = ownerState => {
|
|
22
23
|
const {
|
|
@@ -76,11 +77,9 @@ const DigitalClockItem = styled(MenuItem, {
|
|
|
76
77
|
}));
|
|
77
78
|
export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(inProps, ref) {
|
|
78
79
|
var _ref, _slots$digitalClockIt, _slotProps$digitalClo;
|
|
79
|
-
const now = useNow();
|
|
80
80
|
const utils = useUtils();
|
|
81
81
|
const containerRef = React.useRef(null);
|
|
82
82
|
const handleRef = useForkRef(ref, containerRef);
|
|
83
|
-
const localeText = useLocaleText();
|
|
84
83
|
const props = useThemeProps({
|
|
85
84
|
props: inProps,
|
|
86
85
|
name: 'MuiDigitalClock'
|
|
@@ -113,25 +112,31 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
113
112
|
disabled,
|
|
114
113
|
readOnly,
|
|
115
114
|
views = ['hours'],
|
|
116
|
-
skipDisabled = false
|
|
115
|
+
skipDisabled = false,
|
|
116
|
+
timezone: timezoneProp
|
|
117
117
|
} = props,
|
|
118
118
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
119
|
+
const {
|
|
120
|
+
value,
|
|
121
|
+
handleValueChange: handleRawValueChange,
|
|
122
|
+
timezone
|
|
123
|
+
} = useControlledValueWithTimezone({
|
|
124
|
+
name: 'DigitalClock',
|
|
125
|
+
timezone: timezoneProp,
|
|
126
|
+
value: valueProp,
|
|
127
|
+
defaultValue,
|
|
128
|
+
onChange,
|
|
129
|
+
valueManager: singleItemValueManager
|
|
130
|
+
});
|
|
131
|
+
const localeText = useLocaleText();
|
|
132
|
+
const now = useNow(timezone);
|
|
119
133
|
const ownerState = React.useMemo(() => _extends({}, props, {
|
|
120
134
|
alreadyRendered: !!containerRef.current
|
|
121
135
|
}), [props]);
|
|
122
136
|
const classes = useUtilityClasses(ownerState);
|
|
123
137
|
const ClockItem = (_ref = (_slots$digitalClockIt = slots == null ? void 0 : slots.digitalClockItem) != null ? _slots$digitalClockIt : components == null ? void 0 : components.DigitalClockItem) != null ? _ref : DigitalClockItem;
|
|
124
138
|
const clockItemProps = (_slotProps$digitalClo = slotProps == null ? void 0 : slotProps.digitalClockItem) != null ? _slotProps$digitalClo : componentsProps == null ? void 0 : componentsProps.digitalClockItem;
|
|
125
|
-
const
|
|
126
|
-
name: 'DigitalClock',
|
|
127
|
-
state: 'value',
|
|
128
|
-
controlled: valueProp,
|
|
129
|
-
default: defaultValue != null ? defaultValue : null
|
|
130
|
-
});
|
|
131
|
-
const handleValueChange = useEventCallback(newValue => {
|
|
132
|
-
setValue(newValue);
|
|
133
|
-
onChange == null ? void 0 : onChange(newValue, 'finish');
|
|
134
|
-
});
|
|
139
|
+
const handleValueChange = useEventCallback(newValue => handleRawValueChange(newValue, 'finish'));
|
|
135
140
|
const {
|
|
136
141
|
setValueAndGoToNextView
|
|
137
142
|
} = useViews({
|
|
@@ -379,6 +384,14 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
379
384
|
* @default 30
|
|
380
385
|
*/
|
|
381
386
|
timeStep: PropTypes.number,
|
|
387
|
+
/**
|
|
388
|
+
* Choose which timezone to use for the value.
|
|
389
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
390
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
391
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
392
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
393
|
+
*/
|
|
394
|
+
timezone: PropTypes.string,
|
|
382
395
|
/**
|
|
383
396
|
* The selected value.
|
|
384
397
|
* Used when the component is controlled.
|
|
@@ -94,7 +94,7 @@ MobileDatePicker.propTypes = {
|
|
|
94
94
|
*/
|
|
95
95
|
dayOfWeekFormatter: PropTypes.func,
|
|
96
96
|
/**
|
|
97
|
-
* Default calendar month displayed when `value
|
|
97
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
98
98
|
*/
|
|
99
99
|
defaultCalendarMonth: PropTypes.any,
|
|
100
100
|
/**
|
|
@@ -325,6 +325,14 @@ MobileDatePicker.propTypes = {
|
|
|
325
325
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
326
326
|
*/
|
|
327
327
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
328
|
+
/**
|
|
329
|
+
* Choose which timezone to use for the value.
|
|
330
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
331
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
332
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
333
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
334
|
+
*/
|
|
335
|
+
timezone: PropTypes.string,
|
|
328
336
|
/**
|
|
329
337
|
* The selected value.
|
|
330
338
|
* Used when the component is controlled.
|
|
@@ -115,7 +115,7 @@ MobileDateTimePicker.propTypes = {
|
|
|
115
115
|
*/
|
|
116
116
|
dayOfWeekFormatter: PropTypes.func,
|
|
117
117
|
/**
|
|
118
|
-
* Default calendar month displayed when `value
|
|
118
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
119
119
|
*/
|
|
120
120
|
defaultCalendarMonth: PropTypes.any,
|
|
121
121
|
/**
|
|
@@ -390,6 +390,14 @@ MobileDateTimePicker.propTypes = {
|
|
|
390
390
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
391
391
|
*/
|
|
392
392
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
393
|
+
/**
|
|
394
|
+
* Choose which timezone to use for the value.
|
|
395
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
396
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
397
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
398
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
399
|
+
*/
|
|
400
|
+
timezone: PropTypes.string,
|
|
393
401
|
/**
|
|
394
402
|
* The selected value.
|
|
395
403
|
* Used when the component is controlled.
|
|
@@ -275,6 +275,14 @@ MobileTimePicker.propTypes = {
|
|
|
275
275
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
276
276
|
*/
|
|
277
277
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
278
|
+
/**
|
|
279
|
+
* Choose which timezone to use for the value.
|
|
280
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
281
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
282
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
283
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
284
|
+
*/
|
|
285
|
+
timezone: PropTypes.string,
|
|
278
286
|
/**
|
|
279
287
|
* The selected value.
|
|
280
288
|
* Used when the component is controlled.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["className", "value", "defaultValue", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow"];
|
|
3
|
+
const _excluded = ["className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -11,6 +11,9 @@ import { PickersMonth } from './PickersMonth';
|
|
|
11
11
|
import { useUtils, useNow, useDefaultDates } from '../internals/hooks/useUtils';
|
|
12
12
|
import { getMonthCalendarUtilityClass } from './monthCalendarClasses';
|
|
13
13
|
import { applyDefaultDate, getMonthsInYear } from '../internals/utils/date-utils';
|
|
14
|
+
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
15
|
+
import { SECTION_TYPE_GRANULARITY } from '../internals/utils/getDefaultReferenceDate';
|
|
16
|
+
import { useControlledValueWithTimezone } from '../internals/hooks/useValueWithTimezone';
|
|
14
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
18
|
const useUtilityClasses = ownerState => {
|
|
16
19
|
const {
|
|
@@ -48,14 +51,12 @@ const MonthCalendarRoot = styled('div', {
|
|
|
48
51
|
width: 320
|
|
49
52
|
});
|
|
50
53
|
export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalendar(inProps, ref) {
|
|
51
|
-
const now = useNow();
|
|
52
|
-
const theme = useTheme();
|
|
53
|
-
const utils = useUtils();
|
|
54
54
|
const props = useMonthCalendarDefaultizedProps(inProps, 'MuiMonthCalendar');
|
|
55
55
|
const {
|
|
56
56
|
className,
|
|
57
57
|
value: valueProp,
|
|
58
58
|
defaultValue,
|
|
59
|
+
referenceDate: referenceDateProp,
|
|
59
60
|
disabled,
|
|
60
61
|
disableFuture,
|
|
61
62
|
disablePast,
|
|
@@ -69,19 +70,38 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
69
70
|
onMonthFocus,
|
|
70
71
|
hasFocus,
|
|
71
72
|
onFocusedViewChange,
|
|
72
|
-
monthsPerRow = 3
|
|
73
|
+
monthsPerRow = 3,
|
|
74
|
+
timezone: timezoneProp
|
|
73
75
|
} = props,
|
|
74
76
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
const {
|
|
78
|
+
value,
|
|
79
|
+
handleValueChange,
|
|
80
|
+
timezone
|
|
81
|
+
} = useControlledValueWithTimezone({
|
|
78
82
|
name: 'MonthCalendar',
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
timezone: timezoneProp,
|
|
84
|
+
value: valueProp,
|
|
85
|
+
defaultValue,
|
|
86
|
+
onChange: onChange,
|
|
87
|
+
valueManager: singleItemValueManager
|
|
82
88
|
});
|
|
89
|
+
const now = useNow(timezone);
|
|
90
|
+
const theme = useTheme();
|
|
91
|
+
const utils = useUtils();
|
|
92
|
+
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
93
|
+
value,
|
|
94
|
+
utils,
|
|
95
|
+
props,
|
|
96
|
+
timezone,
|
|
97
|
+
referenceDate: referenceDateProp,
|
|
98
|
+
granularity: SECTION_TYPE_GRANULARITY.month
|
|
99
|
+
}), [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const ownerState = props;
|
|
103
|
+
const classes = useUtilityClasses(ownerState);
|
|
83
104
|
const todayMonth = React.useMemo(() => utils.getMonth(now), [utils, now]);
|
|
84
|
-
const selectedDateOrStartOfMonth = React.useMemo(() => value != null ? value : utils.startOfMonth(now), [now, utils, value]);
|
|
85
105
|
const selectedMonth = React.useMemo(() => {
|
|
86
106
|
if (value != null) {
|
|
87
107
|
return utils.getMonth(value);
|
|
@@ -89,8 +109,8 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
89
109
|
if (disableHighlightToday) {
|
|
90
110
|
return null;
|
|
91
111
|
}
|
|
92
|
-
return utils.getMonth(
|
|
93
|
-
}, [
|
|
112
|
+
return utils.getMonth(referenceDate);
|
|
113
|
+
}, [value, utils, disableHighlightToday, referenceDate]);
|
|
94
114
|
const [focusedMonth, setFocusedMonth] = React.useState(() => selectedMonth || todayMonth);
|
|
95
115
|
const [internalHasFocus, setInternalHasFocus] = useControlled({
|
|
96
116
|
name: 'MonthCalendar',
|
|
@@ -104,30 +124,30 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
104
124
|
onFocusedViewChange(newHasFocus);
|
|
105
125
|
}
|
|
106
126
|
});
|
|
107
|
-
const isMonthDisabled = React.useCallback(
|
|
127
|
+
const isMonthDisabled = React.useCallback(dateToValidate => {
|
|
108
128
|
const firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, minDate) ? now : minDate);
|
|
109
129
|
const lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, maxDate) ? now : maxDate);
|
|
110
|
-
|
|
130
|
+
const monthToValidate = utils.startOfMonth(dateToValidate);
|
|
131
|
+
if (utils.isBefore(monthToValidate, firstEnabledMonth)) {
|
|
111
132
|
return true;
|
|
112
133
|
}
|
|
113
|
-
if (utils.isAfter(
|
|
134
|
+
if (utils.isAfter(monthToValidate, lastEnabledMonth)) {
|
|
114
135
|
return true;
|
|
115
136
|
}
|
|
116
137
|
if (!shouldDisableMonth) {
|
|
117
138
|
return false;
|
|
118
139
|
}
|
|
119
|
-
return shouldDisableMonth(
|
|
140
|
+
return shouldDisableMonth(monthToValidate);
|
|
120
141
|
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableMonth, utils]);
|
|
121
142
|
const handleMonthSelection = useEventCallback((event, month) => {
|
|
122
143
|
if (readOnly) {
|
|
123
144
|
return;
|
|
124
145
|
}
|
|
125
|
-
const newDate = utils.setMonth(
|
|
126
|
-
|
|
127
|
-
onChange == null ? void 0 : onChange(newDate);
|
|
146
|
+
const newDate = utils.setMonth(value != null ? value : referenceDate, month);
|
|
147
|
+
handleValueChange(newDate);
|
|
128
148
|
});
|
|
129
149
|
const focusMonth = useEventCallback(month => {
|
|
130
|
-
if (!isMonthDisabled(utils.setMonth(
|
|
150
|
+
if (!isMonthDisabled(utils.setMonth(value != null ? value : referenceDate, month))) {
|
|
131
151
|
setFocusedMonth(month);
|
|
132
152
|
changeHasFocus(true);
|
|
133
153
|
if (onMonthFocus) {
|
|
@@ -175,7 +195,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
175
195
|
className: clsx(classes.root, className),
|
|
176
196
|
ownerState: ownerState
|
|
177
197
|
}, other, {
|
|
178
|
-
children: getMonthsInYear(utils,
|
|
198
|
+
children: getMonthsInYear(utils, value != null ? value : referenceDate).map(month => {
|
|
179
199
|
const monthNumber = utils.getMonth(month);
|
|
180
200
|
const monthText = utils.format(month, 'monthShort');
|
|
181
201
|
const isSelected = monthNumber === selectedMonth;
|
|
@@ -252,7 +272,7 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
252
272
|
/**
|
|
253
273
|
* Callback fired when the value changes.
|
|
254
274
|
* @template TDate
|
|
255
|
-
* @param {TDate
|
|
275
|
+
* @param {TDate} value The new value.
|
|
256
276
|
*/
|
|
257
277
|
onChange: PropTypes.func,
|
|
258
278
|
onFocusedViewChange: PropTypes.func,
|
|
@@ -261,6 +281,11 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
261
281
|
* If `true` picker is readonly
|
|
262
282
|
*/
|
|
263
283
|
readOnly: PropTypes.bool,
|
|
284
|
+
/**
|
|
285
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
286
|
+
* @default The closest valid month using the validation props, except callbacks such as `shouldDisableDate`.
|
|
287
|
+
*/
|
|
288
|
+
referenceDate: PropTypes.any,
|
|
264
289
|
/**
|
|
265
290
|
* Disable specific month.
|
|
266
291
|
* @template TDate
|
|
@@ -272,6 +297,14 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
272
297
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
273
298
|
*/
|
|
274
299
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
300
|
+
/**
|
|
301
|
+
* Choose which timezone to use for the value.
|
|
302
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
303
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
304
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
305
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
306
|
+
*/
|
|
307
|
+
timezone: PropTypes.string,
|
|
275
308
|
/**
|
|
276
309
|
* The selected value.
|
|
277
310
|
* Used when the component is controlled.
|
|
@@ -2,6 +2,7 @@ import { SxProps } from '@mui/system';
|
|
|
2
2
|
import { Theme } from '@mui/material/styles';
|
|
3
3
|
import { MonthCalendarClasses } from './monthCalendarClasses';
|
|
4
4
|
import { BaseDateValidationProps, MonthValidationProps } from '../internals/models/validation';
|
|
5
|
+
import { TimezoneProps } from '../models';
|
|
5
6
|
export interface ExportedMonthCalendarProps {
|
|
6
7
|
/**
|
|
7
8
|
* Months rendered per row.
|
|
@@ -9,7 +10,7 @@ export interface ExportedMonthCalendarProps {
|
|
|
9
10
|
*/
|
|
10
11
|
monthsPerRow?: 3 | 4;
|
|
11
12
|
}
|
|
12
|
-
export interface MonthCalendarProps<TDate> extends ExportedMonthCalendarProps, MonthValidationProps<TDate>, BaseDateValidationProps<TDate
|
|
13
|
+
export interface MonthCalendarProps<TDate> extends ExportedMonthCalendarProps, MonthValidationProps<TDate>, BaseDateValidationProps<TDate>, TimezoneProps {
|
|
13
14
|
autoFocus?: boolean;
|
|
14
15
|
/**
|
|
15
16
|
* className applied to the root element.
|
|
@@ -35,10 +36,15 @@ export interface MonthCalendarProps<TDate> extends ExportedMonthCalendarProps, M
|
|
|
35
36
|
* Used when the component is not controlled.
|
|
36
37
|
*/
|
|
37
38
|
defaultValue?: TDate | null;
|
|
39
|
+
/**
|
|
40
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
41
|
+
* @default The closest valid month using the validation props, except callbacks such as `shouldDisableDate`.
|
|
42
|
+
*/
|
|
43
|
+
referenceDate?: TDate;
|
|
38
44
|
/**
|
|
39
45
|
* Callback fired when the value changes.
|
|
40
46
|
* @template TDate
|
|
41
|
-
* @param {TDate
|
|
47
|
+
* @param {TDate} value The new value.
|
|
42
48
|
*/
|
|
43
49
|
onChange?: (value: TDate) => void;
|
|
44
50
|
/** If `true` picker is readonly */
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["ampm", "timeSteps", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "defaultValue", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "skipDisabled"];
|
|
3
|
+
const _excluded = ["ampm", "timeSteps", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "defaultValue", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "skipDisabled", "timezone"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
8
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
9
9
|
import composeClasses from '@mui/utils/composeClasses';
|
|
10
|
-
import useControlled from '@mui/utils/useControlled';
|
|
11
10
|
import { useUtils, useNow, useLocaleText } from '../internals/hooks/useUtils';
|
|
12
11
|
import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from '../internals/utils/time-utils';
|
|
13
12
|
import { useViews } from '../internals/hooks/useViews';
|
|
@@ -16,6 +15,8 @@ import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
|
16
15
|
import { getMultiSectionDigitalClockUtilityClass } from './multiSectionDigitalClockClasses';
|
|
17
16
|
import { MultiSectionDigitalClockSection } from './MultiSectionDigitalClockSection';
|
|
18
17
|
import { getHourSectionOptions, getTimeSectionOptions } from './MultiSectionDigitalClock.utils';
|
|
18
|
+
import { useControlledValueWithTimezone } from '../internals/hooks/useValueWithTimezone';
|
|
19
|
+
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
19
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
21
|
const useUtilityClasses = ownerState => {
|
|
21
22
|
const {
|
|
@@ -39,9 +40,7 @@ const MultiSectionDigitalClockRoot = styled(PickerViewRoot, {
|
|
|
39
40
|
borderBottom: `1px solid ${(theme.vars || theme).palette.divider}`
|
|
40
41
|
}));
|
|
41
42
|
export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function MultiSectionDigitalClock(inProps, ref) {
|
|
42
|
-
const now = useNow();
|
|
43
43
|
const utils = useUtils();
|
|
44
|
-
const localeText = useLocaleText();
|
|
45
44
|
const props = useThemeProps({
|
|
46
45
|
props: inProps,
|
|
47
46
|
name: 'MuiMultiSectionDigitalClock'
|
|
@@ -74,24 +73,30 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
74
73
|
className,
|
|
75
74
|
disabled,
|
|
76
75
|
readOnly,
|
|
77
|
-
skipDisabled = false
|
|
76
|
+
skipDisabled = false,
|
|
77
|
+
timezone: timezoneProp
|
|
78
78
|
} = props,
|
|
79
79
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
80
|
+
const {
|
|
81
|
+
value,
|
|
82
|
+
handleValueChange: handleRawValueChange,
|
|
83
|
+
timezone
|
|
84
|
+
} = useControlledValueWithTimezone({
|
|
85
|
+
name: 'MultiSectionDigitalClock',
|
|
86
|
+
timezone: timezoneProp,
|
|
87
|
+
value: valueProp,
|
|
88
|
+
defaultValue,
|
|
89
|
+
onChange,
|
|
90
|
+
valueManager: singleItemValueManager
|
|
91
|
+
});
|
|
92
|
+
const localeText = useLocaleText();
|
|
93
|
+
const now = useNow(timezone);
|
|
80
94
|
const timeSteps = React.useMemo(() => _extends({
|
|
81
95
|
hours: 1,
|
|
82
96
|
minutes: 5,
|
|
83
97
|
seconds: 5
|
|
84
98
|
}, inTimeSteps), [inTimeSteps]);
|
|
85
|
-
const
|
|
86
|
-
name: 'MultiSectionDigitalClock',
|
|
87
|
-
state: 'value',
|
|
88
|
-
controlled: valueProp,
|
|
89
|
-
default: defaultValue != null ? defaultValue : null
|
|
90
|
-
});
|
|
91
|
-
const handleValueChange = useEventCallback((newValue, selectionState, selectedView) => {
|
|
92
|
-
setValue(newValue);
|
|
93
|
-
onChange == null ? void 0 : onChange(newValue, selectionState, selectedView);
|
|
94
|
-
});
|
|
99
|
+
const handleValueChange = useEventCallback((newValue, selectionState, selectedView) => handleRawValueChange(newValue, selectionState, selectedView));
|
|
95
100
|
const views = React.useMemo(() => {
|
|
96
101
|
if (!ampm || !inViews.includes('hours')) {
|
|
97
102
|
return inViews;
|
|
@@ -461,6 +466,14 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
461
466
|
minutes: PropTypes.number,
|
|
462
467
|
seconds: PropTypes.number
|
|
463
468
|
}),
|
|
469
|
+
/**
|
|
470
|
+
* Choose which timezone to use for the value.
|
|
471
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
472
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
473
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
474
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
475
|
+
*/
|
|
476
|
+
timezone: PropTypes.string,
|
|
464
477
|
/**
|
|
465
478
|
* The selected value.
|
|
466
479
|
* Used when the component is controlled.
|
|
@@ -136,7 +136,7 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
136
136
|
return /*#__PURE__*/_jsx(DigitalClockSectionItem, _extends({
|
|
137
137
|
onClick: () => !readOnly && onChange(option.value),
|
|
138
138
|
selected: isSelected,
|
|
139
|
-
disabled: disabled
|
|
139
|
+
disabled: disabled || ((_option$isDisabled2 = option.isDisabled) == null ? void 0 : _option$isDisabled2.call(option, option.value)),
|
|
140
140
|
disableRipple: readOnly,
|
|
141
141
|
role: "option"
|
|
142
142
|
// aria-readonly is not supported here and does not have any effect
|
|
@@ -136,6 +136,7 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
|
136
136
|
onClose: PropTypes.func.isRequired,
|
|
137
137
|
onDismiss: PropTypes.func.isRequired,
|
|
138
138
|
onOpen: PropTypes.func.isRequired,
|
|
139
|
+
onSelectShortcut: PropTypes.func.isRequired,
|
|
139
140
|
onSetToday: PropTypes.func.isRequired,
|
|
140
141
|
onViewChange: PropTypes.func.isRequired,
|
|
141
142
|
/**
|
|
@@ -39,6 +39,7 @@ const usePickerLayout = props => {
|
|
|
39
39
|
onViewChange,
|
|
40
40
|
value,
|
|
41
41
|
onChange,
|
|
42
|
+
onSelectShortcut,
|
|
42
43
|
isValid,
|
|
43
44
|
isLandscape,
|
|
44
45
|
disabled,
|
|
@@ -51,7 +52,7 @@ const usePickerLayout = props => {
|
|
|
51
52
|
// TODO: Remove this "as" hack. It get introduced to mark `value` prop in PickersLayoutProps as not required.
|
|
52
53
|
// The true type should be
|
|
53
54
|
// - For pickers value: TDate | null
|
|
54
|
-
// - For
|
|
55
|
+
// - For range pickers value: [TDate | null, TDate | null]
|
|
55
56
|
} = props;
|
|
56
57
|
const slots = innerSlots != null ? innerSlots : uncapitalizeObjectKeys(components);
|
|
57
58
|
const slotProps = innerSlotProps != null ? innerSlotProps : componentsProps;
|
|
@@ -121,13 +122,13 @@ const usePickerLayout = props => {
|
|
|
121
122
|
additionalProps: {
|
|
122
123
|
isValid,
|
|
123
124
|
isLandscape,
|
|
124
|
-
onChange,
|
|
125
|
+
onChange: onSelectShortcut,
|
|
125
126
|
className: classes.shortcuts
|
|
126
127
|
},
|
|
127
128
|
ownerState: {
|
|
128
129
|
isValid,
|
|
129
130
|
isLandscape,
|
|
130
|
-
onChange,
|
|
131
|
+
onChange: onSelectShortcut,
|
|
131
132
|
className: classes.shortcuts,
|
|
132
133
|
wrapperVariant
|
|
133
134
|
}
|
|
@@ -7,15 +7,25 @@ export interface PickersShortcutsItem<TValue> {
|
|
|
7
7
|
label: string;
|
|
8
8
|
getValue: (params: PickersShortcutsItemGetValueParams<TValue>) => TValue;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type PickerShortcutChangeImportance = 'set' | 'accept';
|
|
11
|
+
export interface ExportedPickersShortcutProps<TValue> extends Omit<ListProps, 'onChange'> {
|
|
11
12
|
/**
|
|
12
13
|
* Ordered array of shortcuts to display.
|
|
13
14
|
* If empty, does not display the shortcuts.
|
|
14
15
|
* @default `[]`
|
|
15
16
|
*/
|
|
16
17
|
items?: PickersShortcutsItem<TValue>[];
|
|
18
|
+
/**
|
|
19
|
+
* Importance of the change when picking a shortcut:
|
|
20
|
+
* - "accept": fires `onChange`, fires `onAccept` and closes the picker.
|
|
21
|
+
* - "set": fires `onChange` but do not fire `onAccept` and does not close the picker.
|
|
22
|
+
* @default "accept"
|
|
23
|
+
*/
|
|
24
|
+
changeImportance?: PickerShortcutChangeImportance;
|
|
25
|
+
}
|
|
26
|
+
export interface PickersShortcutsProps<TValue> extends ExportedPickersShortcutProps<TValue> {
|
|
17
27
|
isLandscape: boolean;
|
|
18
|
-
onChange: (newValue: TValue) => void;
|
|
28
|
+
onChange: (newValue: TValue, changeImportance?: PickerShortcutChangeImportance) => void;
|
|
19
29
|
isValid: (value: TValue) => boolean;
|
|
20
30
|
}
|
|
21
31
|
declare function PickersShortcuts<TValue>(props: PickersShortcutsProps<TValue>): React.JSX.Element | null;
|
|
@@ -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 = ["items", "isLandscape", "onChange", "isValid"];
|
|
3
|
+
const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import List from '@mui/material/List';
|
|
@@ -11,6 +11,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
function PickersShortcuts(props) {
|
|
12
12
|
const {
|
|
13
13
|
items,
|
|
14
|
+
changeImportance,
|
|
14
15
|
onChange,
|
|
15
16
|
isValid
|
|
16
17
|
} = props,
|
|
@@ -25,7 +26,7 @@ function PickersShortcuts(props) {
|
|
|
25
26
|
return {
|
|
26
27
|
label: item.label,
|
|
27
28
|
onClick: () => {
|
|
28
|
-
onChange(newValue);
|
|
29
|
+
onChange(newValue, changeImportance);
|
|
29
30
|
},
|
|
30
31
|
disabled: !isValid(newValue)
|
|
31
32
|
};
|
|
@@ -50,6 +51,13 @@ process.env.NODE_ENV !== "production" ? PickersShortcuts.propTypes = {
|
|
|
50
51
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
51
52
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
52
53
|
// ----------------------------------------------------------------------
|
|
54
|
+
/**
|
|
55
|
+
* Importance of the change when picking a shortcut:
|
|
56
|
+
* - "accept": fires `onChange`, fires `onAccept` and closes the picker.
|
|
57
|
+
* - "set": fires `onChange` but do not fire `onAccept` and does not close the picker.
|
|
58
|
+
* @default "accept"
|
|
59
|
+
*/
|
|
60
|
+
changeImportance: PropTypes.oneOf(['accept', 'set']),
|
|
53
61
|
className: PropTypes.string,
|
|
54
62
|
/**
|
|
55
63
|
* If `true`, compact vertical padding designed for keyboard and mouse input is used for
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { PickersShortcuts } from './PickersShortcuts';
|
|
2
|
-
export type { PickersShortcutsProps, PickersShortcutsItem } from './PickersShortcuts';
|
|
2
|
+
export type { PickersShortcutsProps, PickersShortcutsItem, PickerShortcutChangeImportance, } from './PickersShortcuts';
|
|
@@ -74,7 +74,7 @@ StaticDatePicker.propTypes = {
|
|
|
74
74
|
*/
|
|
75
75
|
dayOfWeekFormatter: PropTypes.func,
|
|
76
76
|
/**
|
|
77
|
-
* Default calendar month displayed when `value
|
|
77
|
+
* Default calendar month displayed when `value` and `defaultValue` are empty.
|
|
78
78
|
*/
|
|
79
79
|
defaultCalendarMonth: PropTypes.any,
|
|
80
80
|
/**
|
|
@@ -257,6 +257,14 @@ StaticDatePicker.propTypes = {
|
|
|
257
257
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
258
258
|
*/
|
|
259
259
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
260
|
+
/**
|
|
261
|
+
* Choose which timezone to use for the value.
|
|
262
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
263
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
264
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
265
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
266
|
+
*/
|
|
267
|
+
timezone: PropTypes.string,
|
|
260
268
|
/**
|
|
261
269
|
* The selected value.
|
|
262
270
|
* Used when the component is controlled.
|