@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.
Files changed (276) hide show
  1. package/AdapterDayjs/AdapterDayjs.d.ts +5 -1
  2. package/AdapterDayjs/AdapterDayjs.js +42 -15
  3. package/AdapterLuxon/AdapterLuxon.d.ts +1 -0
  4. package/AdapterLuxon/AdapterLuxon.js +12 -5
  5. package/AdapterMoment/AdapterMoment.js +18 -9
  6. package/CHANGELOG.md +145 -5541
  7. package/DateCalendar/DateCalendar.js +49 -21
  8. package/DateCalendar/DateCalendar.types.d.ts +8 -3
  9. package/DateCalendar/DayCalendar.d.ts +3 -1
  10. package/DateCalendar/DayCalendar.js +24 -17
  11. package/DateCalendar/PickersCalendarHeader.js +6 -3
  12. package/DateCalendar/useCalendarState.d.ts +5 -3
  13. package/DateCalendar/useCalendarState.js +41 -17
  14. package/DateCalendar/useIsDateDisabled.d.ts +1 -1
  15. package/DateCalendar/useIsDateDisabled.js +5 -3
  16. package/DateField/DateField.js +9 -1
  17. package/DatePicker/DatePicker.js +9 -1
  18. package/DateTimeField/DateTimeField.js +9 -1
  19. package/DateTimePicker/DateTimePicker.js +9 -1
  20. package/DesktopDatePicker/DesktopDatePicker.js +9 -1
  21. package/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
  22. package/DesktopTimePicker/DesktopTimePicker.js +8 -0
  23. package/DigitalClock/DigitalClock.js +28 -15
  24. package/MobileDatePicker/MobileDatePicker.js +9 -1
  25. package/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
  26. package/MobileTimePicker/MobileTimePicker.js +8 -0
  27. package/MonthCalendar/MonthCalendar.js +57 -24
  28. package/MonthCalendar/MonthCalendar.types.d.ts +8 -2
  29. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
  30. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
  31. package/PickersLayout/PickersLayout.js +1 -0
  32. package/PickersLayout/usePickerLayout.js +4 -3
  33. package/PickersShortcuts/PickersShortcuts.d.ts +12 -2
  34. package/PickersShortcuts/PickersShortcuts.js +10 -2
  35. package/PickersShortcuts/index.d.ts +1 -1
  36. package/StaticDatePicker/StaticDatePicker.js +9 -1
  37. package/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
  38. package/StaticTimePicker/StaticTimePicker.js +8 -0
  39. package/TimeClock/TimeClock.js +27 -15
  40. package/TimeField/TimeField.js +9 -1
  41. package/TimePicker/TimePicker.js +8 -0
  42. package/YearCalendar/YearCalendar.js +55 -22
  43. package/YearCalendar/YearCalendar.types.d.ts +8 -2
  44. package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
  45. package/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
  46. package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
  47. package/dateViewRenderers/dateViewRenderers.js +4 -2
  48. package/index.js +1 -1
  49. package/internals/hooks/date-helpers-hooks.d.ts +4 -2
  50. package/internals/hooks/date-helpers-hooks.js +8 -6
  51. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
  52. package/internals/hooks/useField/useField.d.ts +3 -1
  53. package/internals/hooks/useField/useField.js +23 -7
  54. package/internals/hooks/useField/useField.types.d.ts +6 -4
  55. package/internals/hooks/useField/useField.utils.d.ts +13 -11
  56. package/internals/hooks/useField/useField.utils.js +55 -43
  57. package/internals/hooks/useField/useFieldCharacterEditing.d.ts +3 -2
  58. package/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
  59. package/internals/hooks/useField/useFieldState.d.ts +1 -0
  60. package/internals/hooks/useField/useFieldState.js +33 -23
  61. package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
  62. package/internals/hooks/usePicker/usePickerValue.js +45 -9
  63. package/internals/hooks/usePicker/usePickerValue.types.d.ts +22 -6
  64. package/internals/hooks/usePicker/usePickerViews.d.ts +2 -1
  65. package/internals/hooks/usePicker/usePickerViews.js +7 -2
  66. package/internals/hooks/useUtils.d.ts +3 -2
  67. package/internals/hooks/useUtils.js +5 -2
  68. package/internals/hooks/useValueWithTimezone.d.ts +33 -0
  69. package/internals/hooks/useValueWithTimezone.js +69 -0
  70. package/internals/index.d.ts +1 -0
  71. package/internals/index.js +1 -0
  72. package/internals/models/props/clock.d.ts +2 -2
  73. package/internals/utils/date-utils.d.ts +4 -4
  74. package/internals/utils/date-utils.js +4 -12
  75. package/internals/utils/fields.js +1 -1
  76. package/internals/utils/getDefaultReferenceDate.d.ts +12 -3
  77. package/internals/utils/getDefaultReferenceDate.js +4 -4
  78. package/internals/utils/validation/extractValidationProps.d.ts +1 -1
  79. package/internals/utils/validation/validateDate.d.ts +3 -2
  80. package/internals/utils/validation/validateDate.js +14 -6
  81. package/internals/utils/validation/validateTime.d.ts +3 -2
  82. package/internals/utils/validation/validateTime.js +8 -8
  83. package/internals/utils/valueManagers.js +2 -1
  84. package/legacy/AdapterDayjs/AdapterDayjs.js +45 -16
  85. package/legacy/AdapterLuxon/AdapterLuxon.js +13 -6
  86. package/legacy/AdapterMoment/AdapterMoment.js +18 -9
  87. package/legacy/DateCalendar/DateCalendar.js +47 -24
  88. package/legacy/DateCalendar/DayCalendar.js +24 -17
  89. package/legacy/DateCalendar/PickersCalendarHeader.js +6 -3
  90. package/legacy/DateCalendar/useCalendarState.js +40 -17
  91. package/legacy/DateCalendar/useIsDateDisabled.js +5 -3
  92. package/legacy/DateField/DateField.js +9 -1
  93. package/legacy/DatePicker/DatePicker.js +9 -1
  94. package/legacy/DateTimeField/DateTimeField.js +9 -1
  95. package/legacy/DateTimePicker/DateTimePicker.js +9 -1
  96. package/legacy/DesktopDatePicker/DesktopDatePicker.js +9 -1
  97. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
  98. package/legacy/DesktopTimePicker/DesktopTimePicker.js +8 -0
  99. package/legacy/DigitalClock/DigitalClock.js +26 -16
  100. package/legacy/MobileDatePicker/MobileDatePicker.js +9 -1
  101. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
  102. package/legacy/MobileTimePicker/MobileTimePicker.js +8 -0
  103. package/legacy/MonthCalendar/MonthCalendar.js +61 -32
  104. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +27 -16
  105. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
  106. package/legacy/PickersLayout/PickersLayout.js +1 -0
  107. package/legacy/PickersLayout/usePickerLayout.js +3 -2
  108. package/legacy/PickersShortcuts/PickersShortcuts.js +10 -2
  109. package/legacy/StaticDatePicker/StaticDatePicker.js +9 -1
  110. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
  111. package/legacy/StaticTimePicker/StaticTimePicker.js +8 -0
  112. package/legacy/TimeClock/TimeClock.js +25 -18
  113. package/legacy/TimeField/TimeField.js +9 -1
  114. package/legacy/TimePicker/TimePicker.js +8 -0
  115. package/legacy/YearCalendar/YearCalendar.js +59 -30
  116. package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
  117. package/legacy/dateViewRenderers/dateViewRenderers.js +4 -2
  118. package/legacy/index.js +1 -1
  119. package/legacy/internals/hooks/date-helpers-hooks.js +8 -6
  120. package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
  121. package/legacy/internals/hooks/useField/useField.js +22 -6
  122. package/legacy/internals/hooks/useField/useField.utils.js +56 -44
  123. package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
  124. package/legacy/internals/hooks/useField/useFieldState.js +42 -33
  125. package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
  126. package/legacy/internals/hooks/usePicker/usePickerValue.js +46 -9
  127. package/legacy/internals/hooks/usePicker/usePickerViews.js +7 -2
  128. package/legacy/internals/hooks/useUtils.js +5 -2
  129. package/legacy/internals/hooks/useValueWithTimezone.js +81 -0
  130. package/legacy/internals/index.js +1 -0
  131. package/legacy/internals/utils/date-utils.js +5 -13
  132. package/legacy/internals/utils/fields.js +1 -1
  133. package/legacy/internals/utils/getDefaultReferenceDate.js +4 -4
  134. package/legacy/internals/utils/validation/validateDate.js +12 -6
  135. package/legacy/internals/utils/validation/validateTime.js +8 -8
  136. package/legacy/internals/utils/valueManagers.js +3 -0
  137. package/legacy/locales/csCZ.js +2 -2
  138. package/legacy/locales/elGR.js +93 -0
  139. package/legacy/locales/index.js +1 -0
  140. package/legacy/tests/describeAdapters/describeAdapters.js +3 -1
  141. package/legacy/tests/describeGregorianAdapter/testCalculations.js +69 -27
  142. package/legacy/tests/describeJalaliAdapter/testCalculations.js +21 -0
  143. package/legacy/timeViewRenderers/timeViewRenderers.js +12 -6
  144. package/locales/csCZ.js +2 -2
  145. package/locales/elGR.d.ts +53 -0
  146. package/locales/elGR.js +57 -0
  147. package/locales/index.d.ts +1 -0
  148. package/locales/index.js +1 -0
  149. package/models/adapters.d.ts +2 -2
  150. package/models/timezone.d.ts +10 -0
  151. package/modern/AdapterDayjs/AdapterDayjs.js +41 -15
  152. package/modern/AdapterLuxon/AdapterLuxon.js +12 -4
  153. package/modern/AdapterMoment/AdapterMoment.js +18 -9
  154. package/modern/DateCalendar/DateCalendar.js +49 -21
  155. package/modern/DateCalendar/DayCalendar.js +24 -17
  156. package/modern/DateCalendar/PickersCalendarHeader.js +6 -3
  157. package/modern/DateCalendar/useCalendarState.js +41 -16
  158. package/modern/DateCalendar/useIsDateDisabled.js +5 -3
  159. package/modern/DateField/DateField.js +9 -1
  160. package/modern/DatePicker/DatePicker.js +9 -1
  161. package/modern/DateTimeField/DateTimeField.js +9 -1
  162. package/modern/DateTimePicker/DateTimePicker.js +9 -1
  163. package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -1
  164. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
  165. package/modern/DesktopTimePicker/DesktopTimePicker.js +8 -0
  166. package/modern/DigitalClock/DigitalClock.js +28 -15
  167. package/modern/MobileDatePicker/MobileDatePicker.js +9 -1
  168. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
  169. package/modern/MobileTimePicker/MobileTimePicker.js +8 -0
  170. package/modern/MonthCalendar/MonthCalendar.js +57 -24
  171. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
  172. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
  173. package/modern/PickersLayout/PickersLayout.js +1 -0
  174. package/modern/PickersLayout/usePickerLayout.js +4 -3
  175. package/modern/PickersShortcuts/PickersShortcuts.js +10 -2
  176. package/modern/StaticDatePicker/StaticDatePicker.js +9 -1
  177. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
  178. package/modern/StaticTimePicker/StaticTimePicker.js +8 -0
  179. package/modern/TimeClock/TimeClock.js +27 -15
  180. package/modern/TimeField/TimeField.js +9 -1
  181. package/modern/TimePicker/TimePicker.js +8 -0
  182. package/modern/YearCalendar/YearCalendar.js +55 -22
  183. package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
  184. package/modern/dateViewRenderers/dateViewRenderers.js +4 -2
  185. package/modern/index.js +1 -1
  186. package/modern/internals/hooks/date-helpers-hooks.js +8 -6
  187. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
  188. package/modern/internals/hooks/useField/useField.js +23 -7
  189. package/modern/internals/hooks/useField/useField.utils.js +55 -43
  190. package/modern/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
  191. package/modern/internals/hooks/useField/useFieldState.js +33 -22
  192. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
  193. package/modern/internals/hooks/usePicker/usePickerValue.js +45 -9
  194. package/modern/internals/hooks/usePicker/usePickerViews.js +7 -2
  195. package/modern/internals/hooks/useUtils.js +5 -2
  196. package/modern/internals/hooks/useValueWithTimezone.js +68 -0
  197. package/modern/internals/index.js +1 -0
  198. package/modern/internals/utils/date-utils.js +4 -12
  199. package/modern/internals/utils/fields.js +1 -1
  200. package/modern/internals/utils/getDefaultReferenceDate.js +4 -4
  201. package/modern/internals/utils/validation/validateDate.js +14 -6
  202. package/modern/internals/utils/validation/validateTime.js +8 -8
  203. package/modern/internals/utils/valueManagers.js +2 -1
  204. package/modern/locales/csCZ.js +2 -2
  205. package/modern/locales/elGR.js +57 -0
  206. package/modern/locales/index.js +1 -0
  207. package/modern/tests/describeAdapters/describeAdapters.js +3 -1
  208. package/modern/tests/describeGregorianAdapter/testCalculations.js +69 -27
  209. package/modern/tests/describeJalaliAdapter/testCalculations.js +21 -0
  210. package/modern/timeViewRenderers/timeViewRenderers.js +12 -6
  211. package/node/AdapterDayjs/AdapterDayjs.js +41 -15
  212. package/node/AdapterLuxon/AdapterLuxon.js +12 -4
  213. package/node/AdapterMoment/AdapterMoment.js +18 -9
  214. package/node/DateCalendar/DateCalendar.js +48 -20
  215. package/node/DateCalendar/DayCalendar.js +24 -17
  216. package/node/DateCalendar/PickersCalendarHeader.js +6 -3
  217. package/node/DateCalendar/useCalendarState.js +41 -16
  218. package/node/DateCalendar/useIsDateDisabled.js +5 -3
  219. package/node/DateField/DateField.js +9 -1
  220. package/node/DatePicker/DatePicker.js +9 -1
  221. package/node/DateTimeField/DateTimeField.js +9 -1
  222. package/node/DateTimePicker/DateTimePicker.js +9 -1
  223. package/node/DesktopDatePicker/DesktopDatePicker.js +9 -1
  224. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +9 -1
  225. package/node/DesktopTimePicker/DesktopTimePicker.js +8 -0
  226. package/node/DigitalClock/DigitalClock.js +28 -15
  227. package/node/MobileDatePicker/MobileDatePicker.js +9 -1
  228. package/node/MobileDateTimePicker/MobileDateTimePicker.js +9 -1
  229. package/node/MobileTimePicker/MobileTimePicker.js +8 -0
  230. package/node/MonthCalendar/MonthCalendar.js +57 -24
  231. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +28 -15
  232. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +1 -1
  233. package/node/PickersLayout/PickersLayout.js +1 -0
  234. package/node/PickersLayout/usePickerLayout.js +4 -3
  235. package/node/PickersShortcuts/PickersShortcuts.js +10 -2
  236. package/node/StaticDatePicker/StaticDatePicker.js +9 -1
  237. package/node/StaticDateTimePicker/StaticDateTimePicker.js +9 -1
  238. package/node/StaticTimePicker/StaticTimePicker.js +8 -0
  239. package/node/TimeClock/TimeClock.js +26 -14
  240. package/node/TimeField/TimeField.js +9 -1
  241. package/node/TimePicker/TimePicker.js +8 -0
  242. package/node/YearCalendar/YearCalendar.js +55 -22
  243. package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -2
  244. package/node/dateViewRenderers/dateViewRenderers.js +4 -2
  245. package/node/index.js +1 -1
  246. package/node/internals/hooks/date-helpers-hooks.js +8 -6
  247. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
  248. package/node/internals/hooks/useField/useField.js +23 -7
  249. package/node/internals/hooks/useField/useField.utils.js +55 -43
  250. package/node/internals/hooks/useField/useFieldCharacterEditing.js +6 -5
  251. package/node/internals/hooks/useField/useFieldState.js +33 -22
  252. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
  253. package/node/internals/hooks/usePicker/usePickerValue.js +44 -9
  254. package/node/internals/hooks/usePicker/usePickerViews.js +7 -2
  255. package/node/internals/hooks/useUtils.js +5 -2
  256. package/node/internals/hooks/useValueWithTimezone.js +79 -0
  257. package/node/internals/index.js +7 -0
  258. package/node/internals/utils/date-utils.js +5 -14
  259. package/node/internals/utils/fields.js +1 -1
  260. package/node/internals/utils/getDefaultReferenceDate.js +5 -4
  261. package/node/internals/utils/validation/validateDate.js +14 -6
  262. package/node/internals/utils/validation/validateTime.js +8 -8
  263. package/node/internals/utils/valueManagers.js +2 -1
  264. package/node/locales/csCZ.js +2 -2
  265. package/node/locales/elGR.js +64 -0
  266. package/node/locales/index.js +11 -0
  267. package/node/tests/describeAdapters/describeAdapters.js +3 -1
  268. package/node/tests/describeGregorianAdapter/testCalculations.js +69 -27
  269. package/node/tests/describeJalaliAdapter/testCalculations.js +21 -0
  270. package/node/timeViewRenderers/timeViewRenderers.js +12 -6
  271. package/package.json +2 -2
  272. package/tests/describeAdapters/describeAdapters.js +3 -1
  273. package/tests/describeGregorianAdapter/testCalculations.js +69 -27
  274. package/tests/describeJalaliAdapter/testCalculations.js +21 -0
  275. package/timeViewRenderers/timeViewRenderers.d.ts +3 -3
  276. 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={null}`.
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.
@@ -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, unstable_useControlled as useControlled, unstable_useId as useId } from '@mui/utils';
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 [value, setValue] = useControlled({
98
- name: 'DateCalendar',
99
- state: 'value',
100
- controlled: valueProp,
101
- default: defaultValue != null ? defaultValue : null
102
- });
103
- const handleValueChange = useEventCallback((newValue, selectionState) => {
104
- setValue(newValue);
105
- onChange == null ? void 0 : onChange(newValue, selectionState);
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.
@@ -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 date-time that is not present in the format when both `value` and `defaultValue` are not present.
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
  */
@@ -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 ownerState = props;
79
- const classes = useUtilityClasses(ownerState);
80
- const [value, setValue] = useControlled({
80
+ const {
81
+ value,
82
+ handleValueChange,
83
+ timezone
84
+ } = useControlledValueWithTimezone({
81
85
  name: 'YearCalendar',
82
- state: 'value',
83
- controlled: valueProp,
84
- default: defaultValue != null ? defaultValue : null
86
+ timezone: timezoneProp,
87
+ value: valueProp,
88
+ defaultValue,
89
+ onChange: onChange,
90
+ valueManager: singleItemValueManager
85
91
  });
86
- const selectedDateOrStartOfYear = React.useMemo(() => value != null ? value : utils.startOfYear(now), [now, utils, value]);
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(now);
96
- }, [now, value, utils, disableHighlightToday]);
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 && shouldDisableYear(dateToValidate)) {
124
- return true;
143
+ if (!shouldDisableYear) {
144
+ return false;
125
145
  }
126
- return false;
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(selectedDateOrStartOfYear, year);
133
- setValue(newDate);
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(selectedDateOrStartOfYear, year))) {
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 | null} value The new value.
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 | null} value The new value.
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,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.7.0
2
+ * @mui/x-date-pickers v6.9.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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.date();
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.date();
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>>(params: UseFieldParams<TValue, TDate, TSection, TForwardedProps, TInternalProps>) => UseFieldResponse<TForwardedProps>;
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 && inputRef.current === getActiveElement(document)) {
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 date-time that is not present in the format when both `value` and `defaultValue` are not present.
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
- }> = Omit<TInternalProps, 'value' | 'defaultValue'> & {
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 = {