@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
|
@@ -94,7 +94,7 @@ StaticDateTimePicker.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
|
/**
|
|
@@ -321,6 +321,14 @@ StaticDateTimePicker.propTypes = {
|
|
|
321
321
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
322
322
|
*/
|
|
323
323
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
324
|
+
/**
|
|
325
|
+
* Choose which timezone to use for the value.
|
|
326
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
327
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
328
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
329
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
330
|
+
*/
|
|
331
|
+
timezone: PropTypes.string,
|
|
324
332
|
/**
|
|
325
333
|
* The selected value.
|
|
326
334
|
* Used when the component is controlled.
|
|
@@ -205,6 +205,14 @@ StaticTimePicker.propTypes = {
|
|
|
205
205
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
206
206
|
*/
|
|
207
207
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
208
|
+
/**
|
|
209
|
+
* Choose which timezone to use for the value.
|
|
210
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
211
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
212
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
213
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
214
|
+
*/
|
|
215
|
+
timezone: PropTypes.string,
|
|
208
216
|
/**
|
|
209
217
|
* The selected value.
|
|
210
218
|
* Used when the component is controlled.
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["ampm", "ampmInClock", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "showViewSwitcher", "onChange", "defaultValue", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly"];
|
|
3
|
+
const _excluded = ["ampm", "ampmInClock", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "showViewSwitcher", "onChange", "defaultValue", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "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
|
-
import { unstable_composeClasses as composeClasses,
|
|
9
|
-
import useEventCallback from '@mui/utils/useEventCallback';
|
|
8
|
+
import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
|
|
10
9
|
import { useUtils, useNow, useLocaleText } from '../internals/hooks/useUtils';
|
|
11
10
|
import { PickersArrowSwitcher } from '../internals/components/PickersArrowSwitcher';
|
|
12
11
|
import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from '../internals/utils/time-utils';
|
|
@@ -16,6 +15,8 @@ import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
|
16
15
|
import { getTimeClockUtilityClass } from './timeClockClasses';
|
|
17
16
|
import { Clock } from './Clock';
|
|
18
17
|
import { getHourNumbers, getMinutesNumbers } from './ClockNumbers';
|
|
18
|
+
import { useControlledValueWithTimezone } from '../internals/hooks/useValueWithTimezone';
|
|
19
|
+
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
19
20
|
import { uncapitalizeObjectKeys } from '../internals/utils/slots-migration';
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -54,8 +55,6 @@ const TimeClockArrowSwitcher = styled(PickersArrowSwitcher, {
|
|
|
54
55
|
* - [TimeClock API](https://mui.com/x/api/date-pickers/time-clock/)
|
|
55
56
|
*/
|
|
56
57
|
export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps, ref) {
|
|
57
|
-
const localeText = useLocaleText();
|
|
58
|
-
const now = useNow();
|
|
59
58
|
const utils = useUtils();
|
|
60
59
|
const props = useThemeProps({
|
|
61
60
|
props: inProps,
|
|
@@ -89,21 +88,26 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
89
88
|
onFocusedViewChange,
|
|
90
89
|
className,
|
|
91
90
|
disabled,
|
|
92
|
-
readOnly
|
|
91
|
+
readOnly,
|
|
92
|
+
timezone: timezoneProp
|
|
93
93
|
} = props,
|
|
94
94
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
95
95
|
const slots = innerSlots != null ? innerSlots : uncapitalizeObjectKeys(components);
|
|
96
96
|
const slotProps = innerSlotProps != null ? innerSlotProps : componentsProps;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
const {
|
|
98
|
+
value,
|
|
99
|
+
handleValueChange,
|
|
100
|
+
timezone
|
|
101
|
+
} = useControlledValueWithTimezone({
|
|
102
|
+
name: 'TimeClock',
|
|
103
|
+
timezone: timezoneProp,
|
|
104
|
+
value: valueProp,
|
|
105
|
+
defaultValue,
|
|
106
|
+
onChange,
|
|
107
|
+
valueManager: singleItemValueManager
|
|
106
108
|
});
|
|
109
|
+
const localeText = useLocaleText();
|
|
110
|
+
const now = useNow(timezone);
|
|
107
111
|
const {
|
|
108
112
|
view,
|
|
109
113
|
setView,
|
|
@@ -447,6 +451,14 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
447
451
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
448
452
|
*/
|
|
449
453
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
454
|
+
/**
|
|
455
|
+
* Choose which timezone to use for the value.
|
|
456
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
457
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
458
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
459
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
460
|
+
*/
|
|
461
|
+
timezone: PropTypes.string,
|
|
450
462
|
/**
|
|
451
463
|
* The selected value.
|
|
452
464
|
* Used when the component is controlled.
|
package/TimeField/TimeField.js
CHANGED
|
@@ -247,7 +247,7 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
247
247
|
*/
|
|
248
248
|
readOnly: PropTypes.bool,
|
|
249
249
|
/**
|
|
250
|
-
* The date used to generate a part of the
|
|
250
|
+
* The date used to generate a part of the new value that is not present in the format when both `value` and `defaultValue` are empty.
|
|
251
251
|
* For example, on time fields it will be used to determine the date to set.
|
|
252
252
|
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
253
253
|
*/
|
|
@@ -320,6 +320,14 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
320
320
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
321
321
|
*/
|
|
322
322
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
323
|
+
/**
|
|
324
|
+
* Choose which timezone to use for the value.
|
|
325
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
326
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
327
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
328
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
329
|
+
*/
|
|
330
|
+
timezone: PropTypes.string,
|
|
323
331
|
/**
|
|
324
332
|
* The ref object used to imperatively interact with the field.
|
|
325
333
|
*/
|
package/TimePicker/TimePicker.js
CHANGED
|
@@ -277,6 +277,14 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
277
277
|
minutes: PropTypes.number,
|
|
278
278
|
seconds: PropTypes.number
|
|
279
279
|
}),
|
|
280
|
+
/**
|
|
281
|
+
* Choose which timezone to use for the value.
|
|
282
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
283
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
284
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
285
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
286
|
+
*/
|
|
287
|
+
timezone: PropTypes.string,
|
|
280
288
|
/**
|
|
281
289
|
* The selected value.
|
|
282
290
|
* 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 = ["autoFocus", "className", "value", "defaultValue", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow"];
|
|
3
|
+
const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "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 { PickersYear } from './PickersYear';
|
|
|
11
11
|
import { useUtils, useNow, useDefaultDates } from '../internals/hooks/useUtils';
|
|
12
12
|
import { getYearCalendarUtilityClass } from './yearCalendarClasses';
|
|
13
13
|
import { applyDefaultDate } 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 {
|
|
@@ -51,15 +54,13 @@ const YearCalendarRoot = styled('div', {
|
|
|
51
54
|
maxHeight: 304
|
|
52
55
|
});
|
|
53
56
|
export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(inProps, ref) {
|
|
54
|
-
const now = useNow();
|
|
55
|
-
const theme = useTheme();
|
|
56
|
-
const utils = useUtils();
|
|
57
57
|
const props = useYearCalendarDefaultizedProps(inProps, 'MuiYearCalendar');
|
|
58
58
|
const {
|
|
59
59
|
autoFocus,
|
|
60
60
|
className,
|
|
61
61
|
value: valueProp,
|
|
62
62
|
defaultValue,
|
|
63
|
+
referenceDate: referenceDateProp,
|
|
63
64
|
disabled,
|
|
64
65
|
disableFuture,
|
|
65
66
|
disablePast,
|
|
@@ -72,18 +73,37 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
72
73
|
onYearFocus,
|
|
73
74
|
hasFocus,
|
|
74
75
|
onFocusedViewChange,
|
|
75
|
-
yearsPerRow = 3
|
|
76
|
+
yearsPerRow = 3,
|
|
77
|
+
timezone: timezoneProp
|
|
76
78
|
} = props,
|
|
77
79
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
const {
|
|
81
|
+
value,
|
|
82
|
+
handleValueChange,
|
|
83
|
+
timezone
|
|
84
|
+
} = useControlledValueWithTimezone({
|
|
81
85
|
name: 'YearCalendar',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
timezone: timezoneProp,
|
|
87
|
+
value: valueProp,
|
|
88
|
+
defaultValue,
|
|
89
|
+
onChange: onChange,
|
|
90
|
+
valueManager: singleItemValueManager
|
|
85
91
|
});
|
|
86
|
-
const
|
|
92
|
+
const now = useNow(timezone);
|
|
93
|
+
const theme = useTheme();
|
|
94
|
+
const utils = useUtils();
|
|
95
|
+
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
96
|
+
value,
|
|
97
|
+
utils,
|
|
98
|
+
props,
|
|
99
|
+
timezone,
|
|
100
|
+
referenceDate: referenceDateProp,
|
|
101
|
+
granularity: SECTION_TYPE_GRANULARITY.year
|
|
102
|
+
}), [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const ownerState = props;
|
|
106
|
+
const classes = useUtilityClasses(ownerState);
|
|
87
107
|
const todayYear = React.useMemo(() => utils.getYear(now), [utils, now]);
|
|
88
108
|
const selectedYear = React.useMemo(() => {
|
|
89
109
|
if (value != null) {
|
|
@@ -92,8 +112,8 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
92
112
|
if (disableHighlightToday) {
|
|
93
113
|
return null;
|
|
94
114
|
}
|
|
95
|
-
return utils.getYear(
|
|
96
|
-
}, [
|
|
115
|
+
return utils.getYear(referenceDate);
|
|
116
|
+
}, [value, utils, disableHighlightToday, referenceDate]);
|
|
97
117
|
const [focusedYear, setFocusedYear] = React.useState(() => selectedYear || todayYear);
|
|
98
118
|
const [internalHasFocus, setInternalHasFocus] = useControlled({
|
|
99
119
|
name: 'YearCalendar',
|
|
@@ -120,21 +140,21 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
120
140
|
if (maxDate && utils.isAfterYear(dateToValidate, maxDate)) {
|
|
121
141
|
return true;
|
|
122
142
|
}
|
|
123
|
-
if (shouldDisableYear
|
|
124
|
-
return
|
|
143
|
+
if (!shouldDisableYear) {
|
|
144
|
+
return false;
|
|
125
145
|
}
|
|
126
|
-
|
|
146
|
+
const yearToValidate = utils.startOfYear(dateToValidate);
|
|
147
|
+
return shouldDisableYear(yearToValidate);
|
|
127
148
|
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableYear, utils]);
|
|
128
149
|
const handleYearSelection = useEventCallback((event, year) => {
|
|
129
150
|
if (readOnly) {
|
|
130
151
|
return;
|
|
131
152
|
}
|
|
132
|
-
const newDate = utils.setYear(
|
|
133
|
-
|
|
134
|
-
onChange == null ? void 0 : onChange(newDate);
|
|
153
|
+
const newDate = utils.setYear(value != null ? value : referenceDate, year);
|
|
154
|
+
handleValueChange(newDate);
|
|
135
155
|
});
|
|
136
156
|
const focusYear = useEventCallback(year => {
|
|
137
|
-
if (!isYearDisabled(utils.setYear(
|
|
157
|
+
if (!isYearDisabled(utils.setYear(value != null ? value : referenceDate, year))) {
|
|
138
158
|
setFocusedYear(year);
|
|
139
159
|
changeHasFocus(true);
|
|
140
160
|
onYearFocus == null ? void 0 : onYearFocus(year);
|
|
@@ -272,7 +292,7 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
|
|
|
272
292
|
/**
|
|
273
293
|
* Callback fired when the value changes.
|
|
274
294
|
* @template TDate
|
|
275
|
-
* @param {TDate
|
|
295
|
+
* @param {TDate} value The new value.
|
|
276
296
|
*/
|
|
277
297
|
onChange: PropTypes.func,
|
|
278
298
|
onFocusedViewChange: PropTypes.func,
|
|
@@ -281,6 +301,11 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
|
|
|
281
301
|
* If `true` picker is readonly
|
|
282
302
|
*/
|
|
283
303
|
readOnly: PropTypes.bool,
|
|
304
|
+
/**
|
|
305
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
306
|
+
* @default The closest valid year using the validation props, except callbacks such as `shouldDisableDate`.
|
|
307
|
+
*/
|
|
308
|
+
referenceDate: PropTypes.any,
|
|
284
309
|
/**
|
|
285
310
|
* Disable specific year.
|
|
286
311
|
* @template TDate
|
|
@@ -292,6 +317,14 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
|
|
|
292
317
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
293
318
|
*/
|
|
294
319
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
320
|
+
/**
|
|
321
|
+
* Choose which timezone to use for the value.
|
|
322
|
+
* Example: "default", "system", "UTC", "America/New_York".
|
|
323
|
+
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
|
|
324
|
+
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documention} for more details.
|
|
325
|
+
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
|
|
326
|
+
*/
|
|
327
|
+
timezone: PropTypes.string,
|
|
295
328
|
/**
|
|
296
329
|
* The selected value.
|
|
297
330
|
* 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 { YearCalendarClasses } from './yearCalendarClasses';
|
|
4
4
|
import { BaseDateValidationProps, YearValidationProps } from '../internals/models/validation';
|
|
5
|
+
import { TimezoneProps } from '../models';
|
|
5
6
|
export interface ExportedYearCalendarProps {
|
|
6
7
|
/**
|
|
7
8
|
* Years rendered per row.
|
|
@@ -9,7 +10,7 @@ export interface ExportedYearCalendarProps {
|
|
|
9
10
|
*/
|
|
10
11
|
yearsPerRow?: 3 | 4;
|
|
11
12
|
}
|
|
12
|
-
export interface YearCalendarProps<TDate> extends ExportedYearCalendarProps, YearValidationProps<TDate>, BaseDateValidationProps<TDate
|
|
13
|
+
export interface YearCalendarProps<TDate> extends ExportedYearCalendarProps, YearValidationProps<TDate>, BaseDateValidationProps<TDate>, TimezoneProps {
|
|
13
14
|
autoFocus?: boolean;
|
|
14
15
|
/**
|
|
15
16
|
* className applied to the root element.
|
|
@@ -35,10 +36,15 @@ export interface YearCalendarProps<TDate> extends ExportedYearCalendarProps, Yea
|
|
|
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 year 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 */
|
|
@@ -10,4 +10,4 @@ export interface DateTimeViewRendererProps<TDate> extends Omit<DateCalendarProps
|
|
|
10
10
|
focusedView: DateOrTimeViewWithMeridiem | null;
|
|
11
11
|
timeViewsCount: number;
|
|
12
12
|
}
|
|
13
|
-
export declare const renderDesktopDateTimeView: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minDate, minTime, maxDate, maxTime, shouldDisableDate, shouldDisableMonth, shouldDisableYear, shouldDisableTime, shouldDisableClock, reduceAnimations, minutesStep, ampm, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timeViewsCount, }: DateTimeViewRendererProps<TDate>) => React.JSX.Element;
|
|
13
|
+
export declare const renderDesktopDateTimeView: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minDate, minTime, maxDate, maxTime, shouldDisableDate, shouldDisableMonth, shouldDisableYear, shouldDisableTime, shouldDisableClock, reduceAnimations, minutesStep, ampm, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timeViewsCount, }: DateTimeViewRendererProps<TDate>) => React.JSX.Element;
|
|
@@ -54,6 +54,7 @@ export const renderDesktopDateTimeView = ({
|
|
|
54
54
|
autoFocus,
|
|
55
55
|
fixedWeekNumber,
|
|
56
56
|
displayWeekNumber,
|
|
57
|
+
timezone,
|
|
57
58
|
disableIgnoringDatePartForTimeValidation,
|
|
58
59
|
timeSteps,
|
|
59
60
|
skipDisabled,
|
|
@@ -101,7 +102,8 @@ export const renderDesktopDateTimeView = ({
|
|
|
101
102
|
sx: sx,
|
|
102
103
|
autoFocus: autoFocus,
|
|
103
104
|
fixedWeekNumber: fixedWeekNumber,
|
|
104
|
-
displayWeekNumber: displayWeekNumber
|
|
105
|
+
displayWeekNumber: displayWeekNumber,
|
|
106
|
+
timezone: timezone
|
|
105
107
|
}), timeViewsCount > 0 && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
106
108
|
children: [/*#__PURE__*/_jsx(Divider, {
|
|
107
109
|
orientation: "vertical"
|
|
@@ -140,7 +142,8 @@ export const renderDesktopDateTimeView = ({
|
|
|
140
142
|
autoFocus: autoFocus,
|
|
141
143
|
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
142
144
|
timeSteps: timeSteps,
|
|
143
|
-
skipDisabled: skipDisabled
|
|
145
|
+
skipDisabled: skipDisabled,
|
|
146
|
+
timezone: timezone
|
|
144
147
|
})]
|
|
145
148
|
})]
|
|
146
149
|
}), isActionBarVisible && /*#__PURE__*/_jsx(Divider, {})]
|
|
@@ -8,4 +8,4 @@ export interface DateViewRendererProps<TDate, TView extends DateOrTimeViewWithMe
|
|
|
8
8
|
views: readonly TView[];
|
|
9
9
|
focusedView: TView | null;
|
|
10
10
|
}
|
|
11
|
-
export declare const renderDateViewCalendar: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, }: DateViewRendererProps<TDate, DateView>) => React.JSX.Element;
|
|
11
|
+
export declare const renderDateViewCalendar: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, }: DateViewRendererProps<TDate, DateView>) => React.JSX.Element;
|
|
@@ -40,7 +40,8 @@ export const renderDateViewCalendar = ({
|
|
|
40
40
|
sx,
|
|
41
41
|
autoFocus,
|
|
42
42
|
fixedWeekNumber,
|
|
43
|
-
displayWeekNumber
|
|
43
|
+
displayWeekNumber,
|
|
44
|
+
timezone
|
|
44
45
|
}) => /*#__PURE__*/_jsx(DateCalendar, {
|
|
45
46
|
view: view,
|
|
46
47
|
onViewChange: onViewChange,
|
|
@@ -79,5 +80,6 @@ export const renderDateViewCalendar = ({
|
|
|
79
80
|
sx: sx,
|
|
80
81
|
autoFocus: autoFocus,
|
|
81
82
|
fixedWeekNumber: fixedWeekNumber,
|
|
82
|
-
displayWeekNumber: displayWeekNumber
|
|
83
|
+
displayWeekNumber: displayWeekNumber,
|
|
84
|
+
timezone: timezone
|
|
83
85
|
});
|
package/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { PickerOnChangeFn } from './useViews';
|
|
2
2
|
import { PickerSelectionState } from './usePicker';
|
|
3
|
+
import { PickersTimezone } from '../../models';
|
|
3
4
|
interface MonthValidationOptions<TDate> {
|
|
4
5
|
disablePast?: boolean;
|
|
5
6
|
disableFuture?: boolean;
|
|
6
7
|
minDate: TDate;
|
|
7
8
|
maxDate: TDate;
|
|
9
|
+
timezone: PickersTimezone;
|
|
8
10
|
}
|
|
9
|
-
export declare function useNextMonthDisabled<TDate>(month: TDate, { disableFuture, maxDate }: Pick<MonthValidationOptions<TDate>, 'disableFuture' | 'maxDate'>): boolean;
|
|
10
|
-
export declare function usePreviousMonthDisabled<TDate>(month: TDate, { disablePast, minDate }: Pick<MonthValidationOptions<TDate>, 'disablePast' | 'minDate'>): boolean;
|
|
11
|
+
export declare function useNextMonthDisabled<TDate>(month: TDate, { disableFuture, maxDate, timezone, }: Pick<MonthValidationOptions<TDate>, 'disableFuture' | 'maxDate' | 'timezone'>): boolean;
|
|
12
|
+
export declare function usePreviousMonthDisabled<TDate>(month: TDate, { disablePast, minDate, timezone, }: Pick<MonthValidationOptions<TDate>, 'disablePast' | 'minDate' | 'timezone'>): boolean;
|
|
11
13
|
export declare function useMeridiemMode<TDate>(date: TDate | null, ampm: boolean | undefined, onChange: PickerOnChangeFn<TDate>, selectionState?: PickerSelectionState): {
|
|
12
14
|
meridiemMode: import("../utils/time-utils").Meridiem | null;
|
|
13
15
|
handleMeridiemChange: (mode: 'am' | 'pm') => void;
|
|
@@ -3,25 +3,27 @@ import { useUtils } from './useUtils';
|
|
|
3
3
|
import { getMeridiem, convertToMeridiem } from '../utils/time-utils';
|
|
4
4
|
export function useNextMonthDisabled(month, {
|
|
5
5
|
disableFuture,
|
|
6
|
-
maxDate
|
|
6
|
+
maxDate,
|
|
7
|
+
timezone
|
|
7
8
|
}) {
|
|
8
9
|
const utils = useUtils();
|
|
9
10
|
return React.useMemo(() => {
|
|
10
|
-
const now = utils.
|
|
11
|
+
const now = utils.dateWithTimezone(undefined, timezone);
|
|
11
12
|
const lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, maxDate) ? now : maxDate);
|
|
12
13
|
return !utils.isAfter(lastEnabledMonth, month);
|
|
13
|
-
}, [disableFuture, maxDate, month, utils]);
|
|
14
|
+
}, [disableFuture, maxDate, month, utils, timezone]);
|
|
14
15
|
}
|
|
15
16
|
export function usePreviousMonthDisabled(month, {
|
|
16
17
|
disablePast,
|
|
17
|
-
minDate
|
|
18
|
+
minDate,
|
|
19
|
+
timezone
|
|
18
20
|
}) {
|
|
19
21
|
const utils = useUtils();
|
|
20
22
|
return React.useMemo(() => {
|
|
21
|
-
const now = utils.
|
|
23
|
+
const now = utils.dateWithTimezone(undefined, timezone);
|
|
22
24
|
const firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, minDate) ? now : minDate);
|
|
23
25
|
return !utils.isBefore(firstEnabledMonth, month);
|
|
24
|
-
}, [disablePast, minDate, month, utils]);
|
|
26
|
+
}, [disablePast, minDate, month, utils, timezone]);
|
|
25
27
|
}
|
|
26
28
|
export function useMeridiemMode(date, ampm, onChange, selectionState) {
|
|
27
29
|
const utils = useUtils();
|
|
@@ -36,6 +36,7 @@ export const useDesktopPicker = _ref => {
|
|
|
36
36
|
sx,
|
|
37
37
|
format,
|
|
38
38
|
formatDensity,
|
|
39
|
+
timezone,
|
|
39
40
|
label,
|
|
40
41
|
inputRef,
|
|
41
42
|
readOnly,
|
|
@@ -100,6 +101,7 @@ export const useDesktopPicker = _ref => {
|
|
|
100
101
|
sx,
|
|
101
102
|
format,
|
|
102
103
|
formatDensity,
|
|
104
|
+
timezone,
|
|
103
105
|
label,
|
|
104
106
|
autoFocus: autoFocus && !props.open,
|
|
105
107
|
focused: open ? true : undefined
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { UseFieldParams, UseFieldResponse, UseFieldForwardedProps, UseFieldInternalProps } from './useField.types';
|
|
2
2
|
import { FieldSection } from '../../../models';
|
|
3
|
-
export declare const useField: <TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any, any
|
|
3
|
+
export declare const useField: <TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any, any> & {
|
|
4
|
+
minutesStep?: number | undefined;
|
|
5
|
+
}>(params: UseFieldParams<TValue, TDate, TSection, TForwardedProps, TInternalProps>) => UseFieldResponse<TForwardedProps>;
|
|
@@ -24,14 +24,16 @@ export const useField = params => {
|
|
|
24
24
|
updateValueFromValueStr,
|
|
25
25
|
setTempAndroidValueStr,
|
|
26
26
|
sectionsValueBoundaries,
|
|
27
|
-
placeholder
|
|
27
|
+
placeholder,
|
|
28
|
+
timezone
|
|
28
29
|
} = useFieldState(params);
|
|
29
30
|
const {
|
|
30
31
|
inputRef: inputRefProp,
|
|
31
32
|
internalProps,
|
|
32
33
|
internalProps: {
|
|
33
34
|
readOnly = false,
|
|
34
|
-
unstableFieldRef
|
|
35
|
+
unstableFieldRef,
|
|
36
|
+
minutesStep
|
|
35
37
|
},
|
|
36
38
|
forwardedProps: {
|
|
37
39
|
onClick,
|
|
@@ -54,7 +56,8 @@ export const useField = params => {
|
|
|
54
56
|
sections: state.sections,
|
|
55
57
|
updateSectionValue,
|
|
56
58
|
sectionsValueBoundaries,
|
|
57
|
-
setTempAndroidValueStr
|
|
59
|
+
setTempAndroidValueStr,
|
|
60
|
+
timezone
|
|
58
61
|
});
|
|
59
62
|
const inputRef = React.useRef(null);
|
|
60
63
|
const handleRef = useForkRef(inputRefProp, inputRef);
|
|
@@ -96,7 +99,7 @@ export const useField = params => {
|
|
|
96
99
|
onFocus == null ? void 0 : onFocus(...args);
|
|
97
100
|
// The ref is guaranteed to be resolved at this point.
|
|
98
101
|
const input = inputRef.current;
|
|
99
|
-
clearTimeout(focusTimeoutRef.current);
|
|
102
|
+
window.clearTimeout(focusTimeoutRef.current);
|
|
100
103
|
focusTimeoutRef.current = setTimeout(() => {
|
|
101
104
|
// The ref changed, the component got remounted, the focus event is no longer relevant.
|
|
102
105
|
if (!input || input !== inputRef.current) {
|
|
@@ -143,6 +146,7 @@ export const useField = params => {
|
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
148
|
event.preventDefault();
|
|
149
|
+
resetCharacterQuery();
|
|
146
150
|
updateValueFromValueStr(pastedValue);
|
|
147
151
|
});
|
|
148
152
|
const handleInputChange = useEventCallback(event => {
|
|
@@ -267,7 +271,9 @@ export const useField = params => {
|
|
|
267
271
|
}
|
|
268
272
|
const activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
269
273
|
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
270
|
-
const newSectionValue = adjustSectionValue(utils, activeSection, event.key, sectionsValueBoundaries, activeDateManager.date
|
|
274
|
+
const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, activeDateManager.date, {
|
|
275
|
+
minutesStep
|
|
276
|
+
});
|
|
271
277
|
updateSectionValue({
|
|
272
278
|
activeSection,
|
|
273
279
|
newSectionValue,
|
|
@@ -278,6 +284,9 @@ export const useField = params => {
|
|
|
278
284
|
}
|
|
279
285
|
});
|
|
280
286
|
useEnhancedEffect(() => {
|
|
287
|
+
if (!inputRef.current) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
281
290
|
if (selectedSectionIndexes == null) {
|
|
282
291
|
if (inputRef.current.scrollLeft) {
|
|
283
292
|
// Ensure that input content is not marked as selected.
|
|
@@ -301,7 +310,7 @@ export const useField = params => {
|
|
|
301
310
|
// On multi input range pickers we want to update selection range only for the active input
|
|
302
311
|
// This helps avoiding the focus jumping on Safari https://github.com/mui/mui-x/issues/9003
|
|
303
312
|
// because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425
|
|
304
|
-
if (inputRef.current
|
|
313
|
+
if (inputRef.current === getActiveElement(document)) {
|
|
305
314
|
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
306
315
|
}
|
|
307
316
|
// Even reading this variable seems to do the trick, but also setting it just to make use of it
|
|
@@ -309,7 +318,8 @@ export const useField = params => {
|
|
|
309
318
|
}
|
|
310
319
|
});
|
|
311
320
|
const validationError = useValidation(_extends({}, internalProps, {
|
|
312
|
-
value: state.value
|
|
321
|
+
value: state.value,
|
|
322
|
+
timezone
|
|
313
323
|
}), validator, valueManager.isSameError, valueManager.defaultErrorState);
|
|
314
324
|
const inputError = React.useMemo(() => {
|
|
315
325
|
// only override when `error` is undefined.
|
|
@@ -319,6 +329,12 @@ export const useField = params => {
|
|
|
319
329
|
}
|
|
320
330
|
return valueManager.hasError(validationError);
|
|
321
331
|
}, [valueManager, validationError, error]);
|
|
332
|
+
React.useEffect(() => {
|
|
333
|
+
if (!inputError && !selectedSectionIndexes) {
|
|
334
|
+
resetCharacterQuery();
|
|
335
|
+
}
|
|
336
|
+
}, [state.referenceValue, selectedSectionIndexes, inputError]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
337
|
+
|
|
322
338
|
React.useEffect(() => {
|
|
323
339
|
// Select the right section when focused on mount (`autoFocus = true` on the input)
|
|
324
340
|
if (inputRef.current && inputRef.current === document.activeElement) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, FieldSectionContentType, FieldValueType } from '../../../models';
|
|
2
|
+
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, FieldValueType, PickersTimezone } from '../../../models';
|
|
3
3
|
import type { PickerValueManager } from '../usePicker';
|
|
4
4
|
import { InferError, Validator } from '../useValidation';
|
|
5
5
|
export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any, any>> {
|
|
@@ -11,7 +11,7 @@ export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TF
|
|
|
11
11
|
validator: Validator<TValue, TDate, InferError<TInternalProps>, UseFieldValidationProps<TValue, TInternalProps>>;
|
|
12
12
|
valueType: FieldValueType;
|
|
13
13
|
}
|
|
14
|
-
export interface UseFieldInternalProps<TValue, TDate, TSection extends FieldSection, TError> {
|
|
14
|
+
export interface UseFieldInternalProps<TValue, TDate, TSection extends FieldSection, TError> extends TimezoneProps {
|
|
15
15
|
/**
|
|
16
16
|
* The selected value.
|
|
17
17
|
* Used when the component is controlled.
|
|
@@ -22,7 +22,7 @@ export interface UseFieldInternalProps<TValue, TDate, TSection extends FieldSect
|
|
|
22
22
|
*/
|
|
23
23
|
defaultValue?: TValue;
|
|
24
24
|
/**
|
|
25
|
-
* The date used to generate a part of the
|
|
25
|
+
* The date used to generate a part of the new value that is not present in the format when both `value` and `defaultValue` are empty.
|
|
26
26
|
* For example, on time fields it will be used to determine the date to set.
|
|
27
27
|
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
|
28
28
|
*/
|
|
@@ -266,8 +266,10 @@ export interface UseFieldState<TValue, TSection extends FieldSection> {
|
|
|
266
266
|
export type UseFieldValidationProps<TValue, TInternalProps extends {
|
|
267
267
|
value?: TValue;
|
|
268
268
|
defaultValue?: TValue;
|
|
269
|
-
|
|
269
|
+
timezone?: PickersTimezone;
|
|
270
|
+
}> = Omit<TInternalProps, 'value' | 'defaultValue' | 'timezone'> & {
|
|
270
271
|
value: TValue;
|
|
272
|
+
timezone: PickersTimezone;
|
|
271
273
|
};
|
|
272
274
|
export type AvailableAdjustKeyCode = 'ArrowUp' | 'ArrowDown' | 'PageUp' | 'PageDown' | 'Home' | 'End';
|
|
273
275
|
export type SectionNeighbors = {
|