@mui/x-date-pickers 7.22.3 → 8.0.0-alpha.1

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 (514) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +1 -1
  2. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +3 -3
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -1
  4. package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +1 -1
  5. package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +1 -1
  6. package/AdapterDayjs/AdapterDayjs.d.ts +2 -2
  7. package/AdapterLuxon/AdapterLuxon.d.ts +2 -2
  8. package/AdapterMoment/AdapterMoment.d.ts +2 -2
  9. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +2 -2
  10. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +2 -2
  11. package/CHANGELOG.md +348 -12
  12. package/DateCalendar/DateCalendar.d.ts +1 -2
  13. package/DateCalendar/DateCalendar.js +21 -22
  14. package/DateCalendar/DateCalendar.types.d.ts +21 -31
  15. package/DateCalendar/DayCalendar.d.ts +25 -24
  16. package/DateCalendar/DayCalendar.js +13 -10
  17. package/DateCalendar/index.d.ts +1 -0
  18. package/DateCalendar/useCalendarState.d.ts +16 -16
  19. package/DateCalendar/useIsDateDisabled.d.ts +2 -2
  20. package/DateField/DateField.d.ts +1 -2
  21. package/DateField/DateField.js +8 -10
  22. package/DateField/DateField.types.d.ts +8 -9
  23. package/DateField/index.d.ts +1 -1
  24. package/DateField/useDateField.d.ts +1 -2
  25. package/DatePicker/DatePicker.d.ts +1 -2
  26. package/DatePicker/DatePicker.js +15 -14
  27. package/DatePicker/DatePicker.types.d.ts +10 -11
  28. package/DatePicker/DatePickerToolbar.d.ts +2 -2
  29. package/DatePicker/DatePickerToolbar.js +2 -4
  30. package/DatePicker/shared.d.ts +11 -11
  31. package/DateTimeField/DateTimeField.d.ts +1 -2
  32. package/DateTimeField/DateTimeField.js +9 -12
  33. package/DateTimeField/DateTimeField.types.d.ts +9 -14
  34. package/DateTimeField/index.d.ts +1 -1
  35. package/DateTimeField/useDateTimeField.d.ts +1 -2
  36. package/DateTimePicker/DateTimePicker.d.ts +1 -2
  37. package/DateTimePicker/DateTimePicker.js +16 -16
  38. package/DateTimePicker/DateTimePicker.types.d.ts +10 -13
  39. package/DateTimePicker/DateTimePickerTabs.d.ts +1 -2
  40. package/DateTimePicker/DateTimePickerTabs.js +2 -2
  41. package/DateTimePicker/DateTimePickerToolbar.d.ts +5 -5
  42. package/DateTimePicker/DateTimePickerToolbar.js +8 -7
  43. package/DateTimePicker/shared.d.ts +12 -12
  44. package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -2
  45. package/DesktopDatePicker/DesktopDatePicker.js +17 -16
  46. package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -7
  47. package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -2
  48. package/DesktopDateTimePicker/DesktopDateTimePicker.js +18 -18
  49. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +8 -8
  50. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
  51. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -2
  52. package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -2
  53. package/DesktopTimePicker/DesktopTimePicker.js +11 -6
  54. package/DesktopTimePicker/DesktopTimePicker.types.d.ts +8 -8
  55. package/DigitalClock/DigitalClock.d.ts +1 -2
  56. package/DigitalClock/DigitalClock.js +8 -6
  57. package/DigitalClock/DigitalClock.types.d.ts +4 -4
  58. package/LocalizationProvider/LocalizationProvider.d.ts +12 -12
  59. package/MobileDatePicker/MobileDatePicker.d.ts +1 -2
  60. package/MobileDatePicker/MobileDatePicker.js +17 -16
  61. package/MobileDatePicker/MobileDatePicker.types.d.ts +7 -7
  62. package/MobileDateTimePicker/MobileDateTimePicker.d.ts +2 -2
  63. package/MobileDateTimePicker/MobileDateTimePicker.js +18 -18
  64. package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +7 -7
  65. package/MobileTimePicker/MobileTimePicker.d.ts +2 -2
  66. package/MobileTimePicker/MobileTimePicker.js +11 -6
  67. package/MobileTimePicker/MobileTimePicker.types.d.ts +7 -7
  68. package/MonthCalendar/MonthCalendar.d.ts +3 -4
  69. package/MonthCalendar/MonthCalendar.js +18 -14
  70. package/MonthCalendar/MonthCalendar.types.d.ts +14 -15
  71. package/MonthCalendar/PickersMonth.js +17 -13
  72. package/MultiSectionDigitalClock/MultiSectionDigitalClock.d.ts +1 -2
  73. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -6
  74. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +3 -4
  75. package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +9 -9
  76. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +2 -3
  77. package/PickersActionBar/PickersActionBar.js +2 -2
  78. package/PickersCalendarHeader/PickersCalendarHeader.d.ts +1 -2
  79. package/PickersCalendarHeader/PickersCalendarHeader.js +2 -2
  80. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +9 -9
  81. package/PickersDay/PickersDay.d.ts +8 -8
  82. package/PickersLayout/PickersLayout.d.ts +2 -3
  83. package/PickersLayout/PickersLayout.js +0 -2
  84. package/PickersLayout/PickersLayout.types.d.ts +16 -19
  85. package/PickersLayout/index.d.ts +1 -1
  86. package/PickersLayout/usePickerLayout.d.ts +1 -2
  87. package/PickersLayout/usePickerLayout.js +18 -23
  88. package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  89. package/PickersTextField/PickersTextField.js +2 -2
  90. package/README.md +4 -4
  91. package/StaticDatePicker/StaticDatePicker.d.ts +1 -2
  92. package/StaticDatePicker/StaticDatePicker.js +14 -13
  93. package/StaticDatePicker/StaticDatePicker.types.d.ts +7 -7
  94. package/StaticDateTimePicker/StaticDateTimePicker.d.ts +1 -2
  95. package/StaticDateTimePicker/StaticDateTimePicker.js +15 -15
  96. package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +7 -7
  97. package/StaticTimePicker/StaticTimePicker.d.ts +1 -2
  98. package/StaticTimePicker/StaticTimePicker.js +8 -3
  99. package/StaticTimePicker/StaticTimePicker.types.d.ts +7 -7
  100. package/TimeClock/Clock.d.ts +4 -5
  101. package/TimeClock/Clock.js +4 -3
  102. package/TimeClock/ClockNumbers.d.ts +5 -5
  103. package/TimeClock/TimeClock.d.ts +1 -2
  104. package/TimeClock/TimeClock.js +8 -6
  105. package/TimeClock/TimeClock.types.d.ts +4 -4
  106. package/TimeField/TimeField.d.ts +1 -2
  107. package/TimeField/TimeField.js +6 -6
  108. package/TimeField/TimeField.types.d.ts +9 -14
  109. package/TimeField/index.d.ts +1 -1
  110. package/TimeField/useTimeField.d.ts +1 -2
  111. package/TimePicker/TimePicker.d.ts +1 -2
  112. package/TimePicker/TimePicker.js +9 -4
  113. package/TimePicker/TimePicker.types.d.ts +10 -13
  114. package/TimePicker/TimePickerToolbar.d.ts +2 -2
  115. package/TimePicker/TimePickerToolbar.js +8 -7
  116. package/TimePicker/shared.d.ts +10 -10
  117. package/YearCalendar/PickersYear.js +17 -13
  118. package/YearCalendar/YearCalendar.d.ts +1 -2
  119. package/YearCalendar/YearCalendar.js +18 -14
  120. package/YearCalendar/YearCalendar.types.d.ts +14 -15
  121. package/dateViewRenderers/dateViewRenderers.d.ts +3 -3
  122. package/hooks/index.d.ts +2 -2
  123. package/hooks/index.js +2 -2
  124. package/hooks/useClearableField.js +4 -3
  125. package/hooks/useParsedFormat.d.ts +2 -3
  126. package/hooks/useParsedFormat.js +2 -2
  127. package/hooks/usePickerContext.d.ts +4 -0
  128. package/hooks/usePickerContext.js +15 -0
  129. package/hooks/usePickerTranslations.d.ts +1 -0
  130. package/{modern/hooks/usePickersTranslations.js → hooks/usePickerTranslations.js} +1 -1
  131. package/hooks/useSplitFieldProps.d.ts +3 -3
  132. package/index.js +1 -1
  133. package/internals/components/PickerProvider.d.ts +67 -0
  134. package/internals/components/PickerProvider.js +40 -0
  135. package/internals/hooks/date-helpers-hooks.d.ts +6 -6
  136. package/internals/hooks/defaultizedFieldProps.d.ts +7 -8
  137. package/internals/hooks/useClockReferenceDate.d.ts +5 -5
  138. package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -2
  139. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +22 -18
  140. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +15 -15
  141. package/internals/hooks/useField/buildSectionsFromFormat.d.ts +5 -5
  142. package/internals/hooks/useField/useField.d.ts +3 -3
  143. package/internals/hooks/useField/useField.js +1 -1
  144. package/internals/hooks/useField/useField.types.d.ts +40 -50
  145. package/internals/hooks/useField/useField.utils.d.ts +15 -15
  146. package/internals/hooks/useField/useFieldCharacterEditing.d.ts +4 -4
  147. package/internals/hooks/useField/useFieldState.d.ts +4 -4
  148. package/internals/hooks/useField/useFieldState.js +4 -3
  149. package/internals/hooks/useField/useFieldV7TextField.js +4 -3
  150. package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -2
  151. package/internals/hooks/useMobilePicker/useMobilePicker.js +24 -19
  152. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +12 -12
  153. package/internals/hooks/usePicker/usePicker.d.ts +2 -2
  154. package/internals/hooks/usePicker/usePicker.js +15 -10
  155. package/internals/hooks/usePicker/usePicker.types.d.ts +9 -7
  156. package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +6 -8
  157. package/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
  158. package/internals/hooks/usePicker/usePickerProvider.d.ts +26 -0
  159. package/internals/hooks/usePicker/usePickerProvider.js +77 -0
  160. package/internals/hooks/usePicker/usePickerValue.d.ts +2 -2
  161. package/internals/hooks/usePicker/usePickerValue.js +7 -10
  162. package/internals/hooks/usePicker/usePickerValue.types.d.ts +38 -39
  163. package/internals/hooks/usePicker/usePickerViews.d.ts +7 -11
  164. package/internals/hooks/usePicker/usePickerViews.js +1 -0
  165. package/internals/hooks/usePickerPrivateContext.d.ts +4 -0
  166. package/internals/hooks/usePickerPrivateContext.js +9 -0
  167. package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -2
  168. package/internals/hooks/useStaticPicker/useStaticPicker.js +6 -5
  169. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +6 -6
  170. package/internals/hooks/useUtils.d.ts +7 -7
  171. package/internals/hooks/useValueWithTimezone.d.ts +19 -15
  172. package/internals/hooks/useValueWithTimezone.js +13 -1
  173. package/internals/hooks/useViews.d.ts +3 -3
  174. package/internals/hooks/useViews.js +1 -1
  175. package/internals/index.d.ts +7 -5
  176. package/internals/index.js +2 -1
  177. package/internals/models/common.d.ts +2 -1
  178. package/internals/models/fields.d.ts +32 -7
  179. package/internals/models/formProps.d.ts +14 -0
  180. package/internals/models/helpers.d.ts +0 -4
  181. package/internals/models/index.d.ts +2 -0
  182. package/internals/models/index.js +3 -1
  183. package/internals/models/props/basePickerProps.d.ts +5 -6
  184. package/internals/models/props/{clock.d.ts → time.d.ts} +10 -17
  185. package/internals/models/props/toolbar.d.ts +0 -2
  186. package/internals/models/validation.d.ts +21 -25
  187. package/internals/models/value.d.ts +3 -0
  188. package/internals/models/value.js +1 -0
  189. package/internals/utils/date-time-utils.d.ts +7 -7
  190. package/internals/utils/date-utils.d.ts +17 -17
  191. package/internals/utils/getDefaultReferenceDate.d.ts +10 -10
  192. package/internals/utils/time-utils.d.ts +5 -5
  193. package/internals/utils/valueManagers.d.ts +3 -3
  194. package/locales/beBY.d.ts +3 -3
  195. package/locales/beBY.js +3 -3
  196. package/locales/bgBG.d.ts +3 -3
  197. package/locales/bgBG.js +3 -3
  198. package/locales/caES.d.ts +3 -3
  199. package/locales/caES.js +3 -3
  200. package/locales/csCZ.d.ts +3 -3
  201. package/locales/csCZ.js +3 -3
  202. package/locales/daDK.d.ts +3 -3
  203. package/locales/daDK.js +3 -3
  204. package/locales/deDE.d.ts +3 -3
  205. package/locales/deDE.js +3 -3
  206. package/locales/elGR.d.ts +3 -3
  207. package/locales/elGR.js +12 -13
  208. package/locales/enUS.d.ts +4 -4
  209. package/locales/enUS.js +3 -3
  210. package/locales/esES.d.ts +3 -3
  211. package/locales/esES.js +3 -3
  212. package/locales/eu.d.ts +3 -3
  213. package/locales/eu.js +3 -3
  214. package/locales/faIR.d.ts +3 -3
  215. package/locales/faIR.js +3 -3
  216. package/locales/fiFI.d.ts +3 -3
  217. package/locales/fiFI.js +3 -3
  218. package/locales/frFR.d.ts +3 -3
  219. package/locales/frFR.js +3 -3
  220. package/locales/heIL.d.ts +3 -3
  221. package/locales/heIL.js +3 -3
  222. package/locales/hrHR.d.ts +3 -3
  223. package/locales/hrHR.js +3 -3
  224. package/locales/huHU.d.ts +3 -3
  225. package/locales/huHU.js +3 -3
  226. package/locales/isIS.d.ts +3 -3
  227. package/locales/isIS.js +3 -3
  228. package/locales/itIT.d.ts +3 -3
  229. package/locales/itIT.js +3 -3
  230. package/locales/jaJP.d.ts +3 -3
  231. package/locales/jaJP.js +3 -3
  232. package/locales/koKR.d.ts +3 -3
  233. package/locales/koKR.js +3 -3
  234. package/locales/kzKZ.d.ts +3 -3
  235. package/locales/kzKZ.js +3 -3
  236. package/locales/mk.d.ts +3 -3
  237. package/locales/mk.js +3 -3
  238. package/locales/nbNO.d.ts +3 -3
  239. package/locales/nbNO.js +3 -3
  240. package/locales/nlNL.d.ts +3 -3
  241. package/locales/nlNL.js +3 -3
  242. package/locales/nnNO.d.ts +3 -3
  243. package/locales/nnNO.js +3 -3
  244. package/locales/plPL.d.ts +3 -3
  245. package/locales/plPL.js +3 -3
  246. package/locales/ptBR.d.ts +3 -3
  247. package/locales/ptBR.js +5 -3
  248. package/locales/ptPT.d.ts +3 -3
  249. package/locales/ptPT.js +3 -3
  250. package/locales/roRO.d.ts +3 -3
  251. package/locales/roRO.js +3 -3
  252. package/locales/ruRU.d.ts +3 -3
  253. package/locales/ruRU.js +3 -3
  254. package/locales/skSK.d.ts +3 -3
  255. package/locales/skSK.js +3 -3
  256. package/locales/svSE.d.ts +3 -3
  257. package/locales/svSE.js +3 -3
  258. package/locales/trTR.d.ts +3 -3
  259. package/locales/trTR.js +3 -3
  260. package/locales/ukUA.d.ts +3 -3
  261. package/locales/ukUA.js +3 -3
  262. package/locales/urPK.d.ts +3 -3
  263. package/locales/urPK.js +3 -3
  264. package/locales/utils/getPickersLocalization.d.ts +9 -9
  265. package/locales/utils/getPickersLocalization.js +1 -1
  266. package/locales/utils/pickersLocaleTextApi.d.ts +12 -36
  267. package/locales/viVN.d.ts +3 -3
  268. package/locales/viVN.js +3 -3
  269. package/locales/zhCN.d.ts +3 -3
  270. package/locales/zhCN.js +3 -3
  271. package/locales/zhHK.d.ts +3 -3
  272. package/locales/zhHK.js +3 -3
  273. package/models/adapters.d.ts +151 -202
  274. package/models/common.d.ts +1 -0
  275. package/models/fields.d.ts +9 -42
  276. package/models/pickers.d.ts +28 -6
  277. package/modern/DateCalendar/DateCalendar.js +21 -22
  278. package/modern/DateCalendar/DayCalendar.js +13 -10
  279. package/modern/DateField/DateField.js +8 -10
  280. package/modern/DatePicker/DatePicker.js +15 -14
  281. package/modern/DatePicker/DatePickerToolbar.js +2 -4
  282. package/modern/DateTimeField/DateTimeField.js +9 -12
  283. package/modern/DateTimePicker/DateTimePicker.js +16 -16
  284. package/modern/DateTimePicker/DateTimePickerTabs.js +2 -2
  285. package/modern/DateTimePicker/DateTimePickerToolbar.js +8 -7
  286. package/modern/DesktopDatePicker/DesktopDatePicker.js +17 -16
  287. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +18 -18
  288. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -2
  289. package/modern/DesktopTimePicker/DesktopTimePicker.js +11 -6
  290. package/modern/DigitalClock/DigitalClock.js +8 -6
  291. package/modern/MobileDatePicker/MobileDatePicker.js +17 -16
  292. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +18 -18
  293. package/modern/MobileTimePicker/MobileTimePicker.js +11 -6
  294. package/modern/MonthCalendar/MonthCalendar.js +18 -14
  295. package/modern/MonthCalendar/PickersMonth.js +17 -13
  296. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -6
  297. package/modern/PickersActionBar/PickersActionBar.js +2 -2
  298. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +2 -2
  299. package/modern/PickersLayout/PickersLayout.js +0 -2
  300. package/modern/PickersLayout/usePickerLayout.js +18 -23
  301. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  302. package/modern/PickersTextField/PickersTextField.js +2 -2
  303. package/modern/StaticDatePicker/StaticDatePicker.js +14 -13
  304. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +15 -15
  305. package/modern/StaticTimePicker/StaticTimePicker.js +8 -3
  306. package/modern/TimeClock/Clock.js +4 -3
  307. package/modern/TimeClock/TimeClock.js +8 -6
  308. package/modern/TimeField/TimeField.js +6 -6
  309. package/modern/TimePicker/TimePicker.js +9 -4
  310. package/modern/TimePicker/TimePickerToolbar.js +8 -7
  311. package/modern/YearCalendar/PickersYear.js +17 -13
  312. package/modern/YearCalendar/YearCalendar.js +18 -14
  313. package/modern/hooks/index.js +2 -2
  314. package/modern/hooks/useClearableField.js +4 -3
  315. package/modern/hooks/useParsedFormat.js +2 -2
  316. package/modern/hooks/usePickerContext.js +15 -0
  317. package/{hooks/usePickersTranslations.js → modern/hooks/usePickerTranslations.js} +1 -1
  318. package/modern/index.js +1 -1
  319. package/modern/internals/components/PickerProvider.js +40 -0
  320. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +22 -18
  321. package/modern/internals/hooks/useField/useField.js +1 -1
  322. package/modern/internals/hooks/useField/useFieldState.js +4 -3
  323. package/modern/internals/hooks/useField/useFieldV7TextField.js +4 -3
  324. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +24 -19
  325. package/modern/internals/hooks/usePicker/usePicker.js +15 -10
  326. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
  327. package/modern/internals/hooks/usePicker/usePickerProvider.js +77 -0
  328. package/modern/internals/hooks/usePicker/usePickerValue.js +7 -10
  329. package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
  330. package/modern/internals/hooks/usePickerPrivateContext.js +9 -0
  331. package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +6 -5
  332. package/modern/internals/hooks/useValueWithTimezone.js +13 -1
  333. package/modern/internals/hooks/useViews.js +1 -1
  334. package/modern/internals/index.js +2 -1
  335. package/modern/internals/models/formProps.js +1 -0
  336. package/modern/internals/models/index.js +3 -1
  337. package/modern/internals/models/props/time.js +1 -0
  338. package/modern/internals/models/value.js +1 -0
  339. package/modern/locales/beBY.js +3 -3
  340. package/modern/locales/bgBG.js +3 -3
  341. package/modern/locales/caES.js +3 -3
  342. package/modern/locales/csCZ.js +3 -3
  343. package/modern/locales/daDK.js +3 -3
  344. package/modern/locales/deDE.js +3 -3
  345. package/modern/locales/elGR.js +12 -13
  346. package/modern/locales/enUS.js +3 -3
  347. package/modern/locales/esES.js +3 -3
  348. package/modern/locales/eu.js +3 -3
  349. package/modern/locales/faIR.js +3 -3
  350. package/modern/locales/fiFI.js +3 -3
  351. package/modern/locales/frFR.js +3 -3
  352. package/modern/locales/heIL.js +3 -3
  353. package/modern/locales/hrHR.js +3 -3
  354. package/modern/locales/huHU.js +3 -3
  355. package/modern/locales/isIS.js +3 -3
  356. package/modern/locales/itIT.js +3 -3
  357. package/modern/locales/jaJP.js +3 -3
  358. package/modern/locales/koKR.js +3 -3
  359. package/modern/locales/kzKZ.js +3 -3
  360. package/modern/locales/mk.js +3 -3
  361. package/modern/locales/nbNO.js +3 -3
  362. package/modern/locales/nlNL.js +3 -3
  363. package/modern/locales/nnNO.js +3 -3
  364. package/modern/locales/plPL.js +3 -3
  365. package/modern/locales/ptBR.js +5 -3
  366. package/modern/locales/ptPT.js +3 -3
  367. package/modern/locales/roRO.js +3 -3
  368. package/modern/locales/ruRU.js +3 -3
  369. package/modern/locales/skSK.js +3 -3
  370. package/modern/locales/svSE.js +3 -3
  371. package/modern/locales/trTR.js +3 -3
  372. package/modern/locales/ukUA.js +3 -3
  373. package/modern/locales/urPK.js +3 -3
  374. package/modern/locales/utils/getPickersLocalization.js +1 -1
  375. package/modern/locales/viVN.js +3 -3
  376. package/modern/locales/zhCN.js +3 -3
  377. package/modern/locales/zhHK.js +3 -3
  378. package/modern/validation/useValidation.js +2 -3
  379. package/modern/validation/validateDate.js +5 -0
  380. package/modern/validation/validateDateTime.js +5 -0
  381. package/modern/validation/validateTime.js +5 -0
  382. package/node/DateCalendar/DateCalendar.js +21 -22
  383. package/node/DateCalendar/DayCalendar.js +13 -10
  384. package/node/DateField/DateField.js +8 -10
  385. package/node/DatePicker/DatePicker.js +15 -14
  386. package/node/DatePicker/DatePickerToolbar.js +2 -4
  387. package/node/DateTimeField/DateTimeField.js +9 -12
  388. package/node/DateTimePicker/DateTimePicker.js +16 -16
  389. package/node/DateTimePicker/DateTimePickerTabs.js +2 -2
  390. package/node/DateTimePicker/DateTimePickerToolbar.js +8 -7
  391. package/node/DesktopDatePicker/DesktopDatePicker.js +17 -16
  392. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +18 -18
  393. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +0 -2
  394. package/node/DesktopTimePicker/DesktopTimePicker.js +11 -6
  395. package/node/DigitalClock/DigitalClock.js +8 -6
  396. package/node/MobileDatePicker/MobileDatePicker.js +17 -16
  397. package/node/MobileDateTimePicker/MobileDateTimePicker.js +18 -18
  398. package/node/MobileTimePicker/MobileTimePicker.js +11 -6
  399. package/node/MonthCalendar/MonthCalendar.js +18 -14
  400. package/node/MonthCalendar/PickersMonth.js +17 -13
  401. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -6
  402. package/node/PickersActionBar/PickersActionBar.js +2 -2
  403. package/node/PickersCalendarHeader/PickersCalendarHeader.js +2 -2
  404. package/node/PickersLayout/PickersLayout.js +0 -2
  405. package/node/PickersLayout/usePickerLayout.js +18 -23
  406. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  407. package/node/PickersTextField/PickersTextField.js +2 -2
  408. package/node/StaticDatePicker/StaticDatePicker.js +14 -13
  409. package/node/StaticDateTimePicker/StaticDateTimePicker.js +15 -15
  410. package/node/StaticTimePicker/StaticTimePicker.js +8 -3
  411. package/node/TimeClock/Clock.js +4 -3
  412. package/node/TimeClock/TimeClock.js +8 -6
  413. package/node/TimeField/TimeField.js +6 -6
  414. package/node/TimePicker/TimePicker.js +9 -4
  415. package/node/TimePicker/TimePickerToolbar.js +8 -7
  416. package/node/YearCalendar/PickersYear.js +17 -13
  417. package/node/YearCalendar/YearCalendar.js +18 -14
  418. package/node/hooks/index.js +6 -6
  419. package/node/hooks/useClearableField.js +4 -3
  420. package/node/hooks/useParsedFormat.js +2 -2
  421. package/node/hooks/usePickerContext.js +21 -0
  422. package/node/hooks/usePickerTranslations.js +10 -0
  423. package/node/index.js +1 -1
  424. package/node/internals/components/PickerProvider.js +48 -0
  425. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +22 -18
  426. package/node/internals/hooks/useField/useField.js +1 -1
  427. package/node/internals/hooks/useField/useFieldState.js +4 -3
  428. package/node/internals/hooks/useField/useFieldV7TextField.js +4 -3
  429. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +24 -19
  430. package/node/internals/hooks/usePicker/usePicker.js +15 -10
  431. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +2 -5
  432. package/node/internals/hooks/usePicker/usePickerProvider.js +87 -0
  433. package/node/internals/hooks/usePicker/usePickerValue.js +6 -10
  434. package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
  435. package/node/internals/hooks/usePickerPrivateContext.js +15 -0
  436. package/node/internals/hooks/useStaticPicker/useStaticPicker.js +6 -5
  437. package/node/internals/hooks/useValueWithTimezone.js +13 -1
  438. package/node/internals/hooks/useViews.js +3 -3
  439. package/node/internals/index.js +14 -7
  440. package/node/internals/models/index.js +22 -0
  441. package/node/internals/models/props/time.js +5 -0
  442. package/node/internals/models/value.js +5 -0
  443. package/node/locales/beBY.js +3 -3
  444. package/node/locales/bgBG.js +3 -3
  445. package/node/locales/caES.js +3 -3
  446. package/node/locales/csCZ.js +3 -3
  447. package/node/locales/daDK.js +3 -3
  448. package/node/locales/deDE.js +3 -3
  449. package/node/locales/elGR.js +12 -13
  450. package/node/locales/enUS.js +3 -3
  451. package/node/locales/esES.js +3 -3
  452. package/node/locales/eu.js +3 -3
  453. package/node/locales/faIR.js +3 -3
  454. package/node/locales/fiFI.js +3 -3
  455. package/node/locales/frFR.js +3 -3
  456. package/node/locales/heIL.js +3 -3
  457. package/node/locales/hrHR.js +3 -3
  458. package/node/locales/huHU.js +3 -3
  459. package/node/locales/isIS.js +3 -3
  460. package/node/locales/itIT.js +3 -3
  461. package/node/locales/jaJP.js +3 -3
  462. package/node/locales/koKR.js +3 -3
  463. package/node/locales/kzKZ.js +3 -3
  464. package/node/locales/mk.js +3 -3
  465. package/node/locales/nbNO.js +3 -3
  466. package/node/locales/nlNL.js +3 -3
  467. package/node/locales/nnNO.js +3 -3
  468. package/node/locales/plPL.js +3 -3
  469. package/node/locales/ptBR.js +5 -3
  470. package/node/locales/ptPT.js +3 -3
  471. package/node/locales/roRO.js +3 -3
  472. package/node/locales/ruRU.js +3 -3
  473. package/node/locales/skSK.js +3 -3
  474. package/node/locales/svSE.js +3 -3
  475. package/node/locales/trTR.js +3 -3
  476. package/node/locales/ukUA.js +3 -3
  477. package/node/locales/urPK.js +3 -3
  478. package/node/locales/utils/getPickersLocalization.js +1 -1
  479. package/node/locales/viVN.js +3 -3
  480. package/node/locales/zhCN.js +3 -3
  481. package/node/locales/zhHK.js +3 -3
  482. package/node/validation/useValidation.js +2 -3
  483. package/node/validation/validateDate.js +4 -0
  484. package/node/validation/validateDateTime.js +4 -0
  485. package/node/validation/validateTime.js +4 -0
  486. package/package.json +5 -5
  487. package/themeAugmentation/props.d.ts +28 -28
  488. package/timeViewRenderers/timeViewRenderers.d.ts +6 -6
  489. package/validation/extractValidationProps.d.ts +4 -4
  490. package/validation/useValidation.d.ts +9 -10
  491. package/validation/useValidation.js +2 -3
  492. package/validation/validateDate.d.ts +7 -2
  493. package/validation/validateDate.js +5 -0
  494. package/validation/validateDateTime.d.ts +10 -4
  495. package/validation/validateDateTime.js +5 -0
  496. package/validation/validateTime.d.ts +7 -2
  497. package/validation/validateTime.js +5 -0
  498. package/hooks/usePickersContext.d.ts +0 -4
  499. package/hooks/usePickersContext.js +0 -15
  500. package/hooks/usePickersTranslations.d.ts +0 -2
  501. package/internals/components/PickersProvider.d.ts +0 -34
  502. package/internals/components/PickersProvider.js +0 -26
  503. package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -9
  504. package/internals/hooks/usePicker/usePickerOwnerState.js +0 -13
  505. package/modern/hooks/usePickersContext.js +0 -15
  506. package/modern/internals/components/PickersProvider.js +0 -26
  507. package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -13
  508. package/node/hooks/usePickersContext.js +0 -21
  509. package/node/hooks/usePickersTranslations.js +0 -10
  510. package/node/internals/components/PickersProvider.js +0 -34
  511. package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -20
  512. /package/internals/models/{props/clock.js → formProps.js} +0 -0
  513. /package/{modern/internals/models/props/clock.js → internals/models/props/time.js} +0 -0
  514. /package/node/internals/models/{props/clock.js → formProps.js} +0 -0
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { PickerContext } from "../internals/components/PickerProvider.js";
5
+
6
+ /**
7
+ * Returns the context passed by the picker that wraps the current component.
8
+ */
9
+ export const usePickerContext = () => {
10
+ const value = React.useContext(PickerContext);
11
+ if (value == null) {
12
+ throw new Error(['MUI X: The `usePickerContext` can only be called in fields that are used as a slot of a picker component'].join('\n'));
13
+ }
14
+ return value;
15
+ };
@@ -1,4 +1,4 @@
1
1
  'use client';
2
2
 
3
3
  import { useLocalizationContext } from "../internals/hooks/useUtils.js";
4
- export const usePickersTranslations = () => useLocalizationContext().localeText;
4
+ export const usePickerTranslations = () => useLocalizationContext().localeText;
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v7.22.3
2
+ * @mui/x-date-pickers v8.0.0-alpha.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { LocalizationProvider } from "../../LocalizationProvider/index.js";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export const PickerContext = /*#__PURE__*/React.createContext(null);
5
+ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
6
+ ownerState: {
7
+ isPickerDisabled: false,
8
+ isPickerReadOnly: false,
9
+ isPickerValueEmpty: false,
10
+ isPickerOpen: false,
11
+ pickerVariant: 'desktop',
12
+ pickerOrientation: 'portrait'
13
+ }
14
+ });
15
+
16
+ /**
17
+ * Provides the context for the various parts of a picker component:
18
+ * - contextValue: the context for the picker sub-components.
19
+ * - localizationProvider: the translations passed through the props and through a parent LocalizationProvider.
20
+ *
21
+ * @ignore - do not document.
22
+ */
23
+ export function PickerProvider(props) {
24
+ const {
25
+ contextValue,
26
+ privateContextValue,
27
+ localeText,
28
+ children
29
+ } = props;
30
+ return /*#__PURE__*/_jsx(PickerContext.Provider, {
31
+ value: contextValue,
32
+ children: /*#__PURE__*/_jsx(PickerPrivateContext.Provider, {
33
+ value: privateContextValue,
34
+ children: /*#__PURE__*/_jsx(LocalizationProvider, {
35
+ localeText: localeText,
36
+ children: children
37
+ })
38
+ })
39
+ });
40
+ }
@@ -12,7 +12,7 @@ import useId from '@mui/utils/useId';
12
12
  import { PickersPopper } from "../../components/PickersPopper.js";
13
13
  import { usePicker } from "../usePicker/index.js";
14
14
  import { PickersLayout } from "../../../PickersLayout/index.js";
15
- import { PickersProvider } from "../../components/PickersProvider.js";
15
+ import { PickerProvider } from "../../components/PickerProvider.js";
16
16
 
17
17
  /**
18
18
  * Hook managing all the single-date desktop pickers:
@@ -56,17 +56,18 @@ export const useDesktopPicker = _ref => {
56
56
  actions,
57
57
  hasUIView,
58
58
  layoutProps,
59
+ providerProps,
59
60
  renderCurrentView,
60
61
  shouldRestoreFocus,
61
62
  fieldProps: pickerFieldProps,
62
- contextValue,
63
63
  ownerState
64
64
  } = usePicker(_extends({}, pickerParams, {
65
65
  props,
66
66
  fieldRef,
67
+ localeText,
67
68
  autoFocusView: true,
68
69
  additionalViewProps: {},
69
- wrapperVariant: 'desktop'
70
+ variant: 'desktop'
70
71
  }));
71
72
  const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
72
73
  const _useSlotProps = useSlotProps({
@@ -75,7 +76,7 @@ export const useDesktopPicker = _ref => {
75
76
  additionalProps: {
76
77
  position: 'end'
77
78
  },
78
- ownerState: props
79
+ ownerState
79
80
  }),
80
81
  inputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
81
82
  const OpenPickerButton = slots.openPickerButton ?? IconButton;
@@ -88,7 +89,7 @@ export const useDesktopPicker = _ref => {
88
89
  'aria-label': getOpenDialogAriaText(pickerFieldProps.value),
89
90
  edge: inputAdornmentProps.position
90
91
  },
91
- ownerState: props
92
+ ownerState
92
93
  }),
93
94
  openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);
94
95
  const OpenPickerIcon = slots.openPickerIcon;
@@ -101,27 +102,32 @@ export const useDesktopPicker = _ref => {
101
102
  const fieldProps = useSlotProps({
102
103
  elementType: Field,
103
104
  externalSlotProps: innerSlotProps?.field,
104
- additionalProps: _extends({}, pickerFieldProps, isToolbarHidden && {
105
- id: labelId
106
- }, {
105
+ additionalProps: _extends({
106
+ // Internal props
107
107
  readOnly,
108
108
  disabled,
109
- className,
110
- sx,
111
109
  format,
112
110
  formatDensity,
113
111
  enableAccessibleFieldDOMStructure,
114
112
  selectedSections,
115
113
  onSelectedSectionsChange,
116
114
  timezone,
115
+ autoFocus: autoFocus && !props.open
116
+ }, pickerFieldProps, {
117
+ // onChange and value
118
+
119
+ // Forwarded props
120
+ className,
121
+ sx,
117
122
  label,
118
123
  name,
119
- autoFocus: autoFocus && !props.open,
120
124
  focused: open ? true : undefined
121
- }, inputRef ? {
125
+ }, isToolbarHidden && {
126
+ id: labelId
127
+ }, !!inputRef && {
122
128
  inputRef
123
- } : {}),
124
- ownerState: props
129
+ }),
130
+ ownerState
125
131
  });
126
132
 
127
133
  // TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
@@ -159,9 +165,7 @@ export const useDesktopPicker = _ref => {
159
165
  }, innerSlotProps?.popper)
160
166
  });
161
167
  const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
162
- const renderPicker = () => /*#__PURE__*/_jsxs(PickersProvider, {
163
- contextValue: contextValue,
164
- localeText: localeText,
168
+ const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
165
169
  children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
166
170
  slots: slotsForField,
167
171
  slotProps: slotProps,
@@ -182,7 +186,7 @@ export const useDesktopPicker = _ref => {
182
186
  children: renderCurrentView()
183
187
  }))
184
188
  }))]
185
- });
189
+ }));
186
190
  return {
187
191
  renderPicker
188
192
  };
@@ -17,7 +17,7 @@ export const useField = params => {
17
17
  internalProps: {
18
18
  unstableFieldRef,
19
19
  minutesStep,
20
- enableAccessibleFieldDOMStructure = false,
20
+ enableAccessibleFieldDOMStructure = true,
21
21
  disabled = false,
22
22
  readOnly = false
23
23
  },
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import useControlled from '@mui/utils/useControlled';
4
4
  import { useRtl } from '@mui/system/RtlProvider';
5
- import { usePickersTranslations } from "../../../hooks/usePickersTranslations.js";
5
+ import { usePickerTranslations } from "../../../hooks/usePickerTranslations.js";
6
6
  import { useUtils, useLocalizationContext } from "../useUtils.js";
7
7
  import { mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections, parseSelectedSections, getLocalizedDigits } from "./useField.utils.js";
8
8
  import { buildSectionsFromFormat } from "./buildSectionsFromFormat.js";
@@ -10,7 +10,7 @@ import { useValueWithTimezone } from "../useValueWithTimezone.js";
10
10
  import { getSectionTypeGranularity } from "../../utils/getDefaultReferenceDate.js";
11
11
  export const useFieldState = params => {
12
12
  const utils = useUtils();
13
- const translations = usePickersTranslations();
13
+ const translations = usePickerTranslations();
14
14
  const adapter = useLocalizationContext();
15
15
  const isRtl = useRtl();
16
16
  const {
@@ -30,7 +30,7 @@ export const useFieldState = params => {
30
30
  onSelectedSectionsChange,
31
31
  shouldRespectLeadingZeros = false,
32
32
  timezone: timezoneProp,
33
- enableAccessibleFieldDOMStructure = false
33
+ enableAccessibleFieldDOMStructure = true
34
34
  }
35
35
  } = params;
36
36
  const {
@@ -41,6 +41,7 @@ export const useFieldState = params => {
41
41
  timezone: timezoneProp,
42
42
  value: valueProp,
43
43
  defaultValue,
44
+ referenceDate: referenceDateProp,
44
45
  onChange,
45
46
  valueManager
46
47
  });
@@ -5,7 +5,7 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
5
  import useId from '@mui/utils/useId';
6
6
  import { getSectionValueNow, getSectionValueText, parseSelectedSections } from "./useField.utils.js";
7
7
  import { getActiveElement } from "../../utils/utils.js";
8
- import { usePickersTranslations } from "../../../hooks/usePickersTranslations.js";
8
+ import { usePickerTranslations } from "../../../hooks/usePickerTranslations.js";
9
9
  import { useUtils } from "../useUtils.js";
10
10
  export const useFieldV7TextField = params => {
11
11
  const {
@@ -39,7 +39,7 @@ export const useFieldV7TextField = params => {
39
39
  } = params;
40
40
  const sectionListRef = React.useRef(null);
41
41
  const handleSectionListRef = useForkRef(inSectionListRef, sectionListRef);
42
- const translations = usePickersTranslations();
42
+ const translations = usePickerTranslations();
43
43
  const utils = useUtils();
44
44
  const id = useId();
45
45
  const [focused, setFocused] = React.useState(false);
@@ -198,8 +198,9 @@ export const useFieldV7TextField = params => {
198
198
  if (focused || !sectionListRef.current) {
199
199
  return;
200
200
  }
201
+ const activeElement = getActiveElement(document);
201
202
  setFocused(true);
202
- const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(getActiveElement(document)) != null;
203
+ const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(activeElement) != null;
203
204
  if (!isFocusInsideASection) {
204
205
  setSelectedSections(sectionOrder.startIndex);
205
206
  }
@@ -9,7 +9,7 @@ import { PickersModalDialog } from "../../components/PickersModalDialog.js";
9
9
  import { usePicker } from "../usePicker/index.js";
10
10
  import { onSpaceOrEnter } from "../../utils/utils.js";
11
11
  import { PickersLayout } from "../../../PickersLayout/index.js";
12
- import { PickersProvider } from "../../components/PickersProvider.js";
12
+ import { PickerProvider } from "../../components/PickerProvider.js";
13
13
 
14
14
  /**
15
15
  * Hook managing all the single-date mobile pickers:
@@ -49,42 +49,49 @@ export const useMobilePicker = _ref => {
49
49
  open,
50
50
  actions,
51
51
  layoutProps,
52
+ providerProps,
52
53
  renderCurrentView,
53
54
  fieldProps: pickerFieldProps,
54
- contextValue
55
+ ownerState
55
56
  } = usePicker(_extends({}, pickerParams, {
56
57
  props,
57
58
  fieldRef,
59
+ localeText,
58
60
  autoFocusView: true,
59
61
  additionalViewProps: {},
60
- wrapperVariant: 'mobile'
62
+ variant: 'mobile'
61
63
  }));
62
64
  const Field = slots.field;
63
65
  const fieldProps = useSlotProps({
64
66
  elementType: Field,
65
67
  externalSlotProps: innerSlotProps?.field,
66
- additionalProps: _extends({}, pickerFieldProps, isToolbarHidden && {
67
- id: labelId
68
- }, !(disabled || readOnly) && {
69
- onClick: actions.onOpen,
70
- onKeyDown: onSpaceOrEnter(actions.onOpen)
71
- }, {
68
+ additionalProps: _extends({
69
+ // Internal props
72
70
  readOnly: readOnly ?? true,
73
71
  disabled,
74
- className,
75
- sx,
76
72
  format,
77
73
  formatDensity,
78
74
  enableAccessibleFieldDOMStructure,
79
75
  selectedSections,
80
76
  onSelectedSectionsChange,
81
- timezone,
77
+ timezone
78
+ }, pickerFieldProps, {
79
+ // onChange and value
80
+
81
+ // Forwarded props
82
+ className,
83
+ sx,
82
84
  label,
83
85
  name
84
- }, inputRef ? {
86
+ }, isToolbarHidden && {
87
+ id: labelId
88
+ }, !(disabled || readOnly) && {
89
+ onClick: actions.onOpen,
90
+ onKeyDown: onSpaceOrEnter(actions.onOpen)
91
+ }, !!inputRef && {
85
92
  inputRef
86
- } : {}),
87
- ownerState: props
93
+ }),
94
+ ownerState
88
95
  });
89
96
 
90
97
  // TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
@@ -112,9 +119,7 @@ export const useMobilePicker = _ref => {
112
119
  }, innerSlotProps?.mobilePaper)
113
120
  });
114
121
  const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
115
- const renderPicker = () => /*#__PURE__*/_jsxs(PickersProvider, {
116
- contextValue: contextValue,
117
- localeText: localeText,
122
+ const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
118
123
  children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
119
124
  slots: slotsForField,
120
125
  slotProps: slotProps,
@@ -129,7 +134,7 @@ export const useMobilePicker = _ref => {
129
134
  children: renderCurrentView()
130
135
  }))
131
136
  }))]
132
- });
137
+ }));
133
138
  return {
134
139
  renderPicker
135
140
  };
@@ -2,17 +2,18 @@ import { warnOnce } from '@mui/x-internals/warning';
2
2
  import { usePickerValue } from "./usePickerValue.js";
3
3
  import { usePickerViews } from "./usePickerViews.js";
4
4
  import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
5
- import { usePickerOwnerState } from "./usePickerOwnerState.js";
5
+ import { usePickerProvider } from "./usePickerProvider.js";
6
6
  export const usePicker = ({
7
7
  props,
8
8
  valueManager,
9
9
  valueType,
10
- wrapperVariant,
10
+ variant,
11
11
  additionalViewProps,
12
12
  validator,
13
13
  autoFocusView,
14
14
  rendererInterceptor,
15
- fieldRef
15
+ fieldRef,
16
+ localeText
16
17
  }) => {
17
18
  if (process.env.NODE_ENV !== 'production') {
18
19
  if (props.renderInput != null) {
@@ -23,7 +24,7 @@ export const usePicker = ({
23
24
  props,
24
25
  valueManager,
25
26
  valueType,
26
- wrapperVariant,
27
+ variant,
27
28
  validator
28
29
  });
29
30
  const pickerViewsResponse = usePickerViews({
@@ -36,13 +37,17 @@ export const usePicker = ({
36
37
  });
37
38
  const pickerLayoutResponse = usePickerLayoutProps({
38
39
  props,
39
- wrapperVariant,
40
+ variant,
40
41
  propsFromPickerValue: pickerValueResponse.layoutProps,
41
42
  propsFromPickerViews: pickerViewsResponse.layoutProps
42
43
  });
43
- const pickerOwnerState = usePickerOwnerState({
44
+ const providerProps = usePickerProvider({
44
45
  props,
45
- pickerValueResponse
46
+ pickerValueResponse,
47
+ localeText,
48
+ valueManager,
49
+ variant,
50
+ views: pickerViewsResponse.views
46
51
  });
47
52
  return {
48
53
  // Picker value
@@ -55,9 +60,9 @@ export const usePicker = ({
55
60
  shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
56
61
  // Picker layout
57
62
  layoutProps: pickerLayoutResponse.layoutProps,
58
- // Picker context
59
- contextValue: pickerValueResponse.contextValue,
63
+ // Picker provider
64
+ providerProps,
60
65
  // Picker owner state
61
- ownerState: pickerOwnerState
66
+ ownerState: providerProps.privateContextValue.ownerState
62
67
  };
63
68
  };
@@ -4,7 +4,6 @@ import { useIsLandscape } from "../useIsLandscape.js";
4
4
 
5
5
  /**
6
6
  * Props used to create the layout of the views.
7
- * Those props are exposed on all the pickers.
8
7
  */
9
8
 
10
9
  /**
@@ -14,7 +13,7 @@ export const usePickerLayoutProps = ({
14
13
  props,
15
14
  propsFromPickerValue,
16
15
  propsFromPickerViews,
17
- wrapperVariant
16
+ variant
18
17
  }) => {
19
18
  const {
20
19
  orientation
@@ -24,9 +23,7 @@ export const usePickerLayoutProps = ({
24
23
  const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
25
24
  isLandscape,
26
25
  isRtl,
27
- wrapperVariant,
28
- disabled: props.disabled,
29
- readOnly: props.readOnly
26
+ wrapperVariant: variant
30
27
  });
31
28
  return {
32
29
  layoutProps
@@ -0,0 +1,77 @@
1
+ import * as React from 'react';
2
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
+ import { useUtils } from "../useUtils.js";
4
+ import { arrayIncludes } from "../../utils/utils.js";
5
+ function getOrientation() {
6
+ if (typeof window === 'undefined') {
7
+ return 'portrait';
8
+ }
9
+ if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
10
+ return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
11
+ }
12
+
13
+ // Support IOS safari
14
+ if (window.orientation) {
15
+ return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
16
+ }
17
+ return 'portrait';
18
+ }
19
+ export const usePickerOrientation = (views, customOrientation) => {
20
+ const [orientation, setOrientation] = React.useState(getOrientation);
21
+ useEnhancedEffect(() => {
22
+ const eventHandler = () => {
23
+ setOrientation(getOrientation());
24
+ };
25
+ window.addEventListener('orientationchange', eventHandler);
26
+ return () => {
27
+ window.removeEventListener('orientationchange', eventHandler);
28
+ };
29
+ }, []);
30
+ if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {
31
+ // could not display 13:34:44 in landscape mode
32
+ return 'portrait';
33
+ }
34
+ return customOrientation ?? orientation;
35
+ };
36
+ export function usePickerProvider(parameters) {
37
+ const {
38
+ props,
39
+ pickerValueResponse,
40
+ valueManager,
41
+ localeText,
42
+ variant,
43
+ views
44
+ } = parameters;
45
+ const utils = useUtils();
46
+ const orientation = usePickerOrientation(views, props.orientation);
47
+ const ownerState = React.useMemo(() => ({
48
+ isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
49
+ isPickerOpen: pickerValueResponse.open,
50
+ isPickerDisabled: props.disabled ?? false,
51
+ isPickerReadOnly: props.readOnly ?? false,
52
+ pickerOrientation: orientation,
53
+ pickerVariant: variant
54
+ }), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, orientation, variant, props.disabled, props.readOnly]);
55
+ const contextValue = React.useMemo(() => ({
56
+ onOpen: pickerValueResponse.actions.onOpen,
57
+ onClose: pickerValueResponse.actions.onClose,
58
+ open: pickerValueResponse.open,
59
+ disabled: props.disabled ?? false,
60
+ readOnly: props.readOnly ?? false,
61
+ variant,
62
+ orientation
63
+ }), [pickerValueResponse.actions.onOpen, pickerValueResponse.actions.onClose, pickerValueResponse.open, variant, orientation, props.disabled, props.readOnly]);
64
+ const privateContextValue = React.useMemo(() => ({
65
+ ownerState
66
+ }), [ownerState]);
67
+ return {
68
+ localeText,
69
+ contextValue,
70
+ privateContextValue
71
+ };
72
+ }
73
+
74
+ /**
75
+ * Props used to create the private context.
76
+ * Those props are exposed on all the pickers.
77
+ */
@@ -5,6 +5,7 @@ import { useOpenState } from "../useOpenState.js";
5
5
  import { useLocalizationContext, useUtils } from "../useUtils.js";
6
6
  import { useValidation } from "../../../validation/index.js";
7
7
  import { useValueWithTimezone } from "../useValueWithTimezone.js";
8
+
8
9
  /**
9
10
  * Decide if the new value should be published
10
11
  * The published value will be passed to `onChange` if defined.
@@ -112,7 +113,7 @@ export const usePickerValue = ({
112
113
  props,
113
114
  valueManager,
114
115
  valueType,
115
- wrapperVariant,
116
+ variant,
116
117
  validator
117
118
  }) => {
118
119
  const {
@@ -120,8 +121,9 @@ export const usePickerValue = ({
120
121
  onChange,
121
122
  value: inValueWithoutRenderTimezone,
122
123
  defaultValue: inDefaultValue,
123
- closeOnSelect = wrapperVariant === 'desktop',
124
- timezone: timezoneProp
124
+ closeOnSelect = variant === 'desktop',
125
+ timezone: timezoneProp,
126
+ referenceDate
125
127
  } = props;
126
128
  const {
127
129
  current: defaultValue
@@ -160,6 +162,7 @@ export const usePickerValue = ({
160
162
  timezone: timezoneProp,
161
163
  value: inValueWithoutRenderTimezone,
162
164
  defaultValue,
165
+ referenceDate,
163
166
  onChange,
164
167
  valueManager
165
168
  });
@@ -343,17 +346,11 @@ export const usePickerValue = ({
343
346
  onSelectShortcut: handleSelectShortcut,
344
347
  isValid
345
348
  });
346
- const contextValue = React.useMemo(() => ({
347
- onOpen: handleOpen,
348
- onClose: handleClose,
349
- open: isOpen
350
- }), [isOpen, handleClose, handleOpen]);
351
349
  return {
352
350
  open: isOpen,
353
351
  fieldProps: fieldResponse,
354
352
  viewProps: viewResponse,
355
353
  layoutProps: layoutResponse,
356
- actions,
357
- contextValue
354
+ actions
358
355
  };
359
356
  };
@@ -134,6 +134,7 @@ export const usePickerViews = ({
134
134
  };
135
135
  return {
136
136
  hasUIView,
137
+ views,
137
138
  shouldRestoreFocus,
138
139
  layoutProps,
139
140
  renderCurrentView: () => {
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { PickerPrivateContext } from "../components/PickerProvider.js";
5
+
6
+ /**
7
+ * Returns the private context passed by the picker that wraps the current component.
8
+ */
9
+ export const usePickerPrivateContext = () => React.useContext(PickerPrivateContext);
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { styled } from '@mui/material/styles';
7
7
  import { usePicker } from "../usePicker/index.js";
8
- import { LocalizationProvider } from "../../../LocalizationProvider/index.js";
8
+ import { PickerProvider } from "../../components/PickerProvider.js";
9
9
  import { PickersLayout } from "../../../PickersLayout/index.js";
10
10
  import { DIALOG_WIDTH } from "../../constants/dimensions.js";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -40,17 +40,18 @@ export const useStaticPicker = _ref => {
40
40
  } = props;
41
41
  const {
42
42
  layoutProps,
43
+ providerProps,
43
44
  renderCurrentView
44
45
  } = usePicker(_extends({}, pickerParams, {
45
46
  props,
46
47
  autoFocusView: autoFocus ?? false,
47
48
  fieldRef: undefined,
49
+ localeText,
48
50
  additionalViewProps: {},
49
- wrapperVariant: displayStaticWrapperAs
51
+ variant: displayStaticWrapperAs
50
52
  }));
51
53
  const Layout = slots?.layout ?? PickerStaticLayout;
52
- const renderPicker = () => /*#__PURE__*/_jsx(LocalizationProvider, {
53
- localeText: localeText,
54
+ const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
54
55
  children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
55
56
  slots: slots,
56
57
  slotProps: slotProps,
@@ -59,7 +60,7 @@ export const useStaticPicker = _ref => {
59
60
  ref: ref,
60
61
  children: renderCurrentView()
61
62
  }))
62
- });
63
+ }));
63
64
  return {
64
65
  renderPicker
65
66
  };
@@ -11,6 +11,7 @@ export const useValueWithTimezone = ({
11
11
  timezone: timezoneProp,
12
12
  value: valueProp,
13
13
  defaultValue,
14
+ referenceDate,
14
15
  onChange,
15
16
  valueManager
16
17
  }) => {
@@ -24,7 +25,16 @@ export const useValueWithTimezone = ({
24
25
  }
25
26
  return valueManager.setTimezone(utils, inputTimezone, newValue);
26
27
  });
27
- const timezoneToRender = timezoneProp ?? inputTimezone ?? 'default';
28
+ let timezoneToRender;
29
+ if (timezoneProp) {
30
+ timezoneToRender = timezoneProp;
31
+ } else if (inputTimezone) {
32
+ timezoneToRender = inputTimezone;
33
+ } else if (referenceDate) {
34
+ timezoneToRender = utils.getTimezone(referenceDate);
35
+ } else {
36
+ timezoneToRender = 'default';
37
+ }
28
38
  const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
29
39
  const handleValueChange = useEventCallback((newValue, ...otherParams) => {
30
40
  const newValueWithInputTimezone = setInputTimezone(newValue);
@@ -45,6 +55,7 @@ export const useControlledValueWithTimezone = ({
45
55
  timezone: timezoneProp,
46
56
  value: valueProp,
47
57
  defaultValue,
58
+ referenceDate,
48
59
  onChange: onChangeProp,
49
60
  valueManager
50
61
  }) => {
@@ -62,6 +73,7 @@ export const useControlledValueWithTimezone = ({
62
73
  timezone: timezoneProp,
63
74
  value: valueWithInputTimezone,
64
75
  defaultValue: undefined,
76
+ referenceDate,
65
77
  onChange,
66
78
  valueManager
67
79
  });