@mui/x-date-pickers 7.16.0 → 7.18.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 (390) hide show
  1. package/AdapterDateFns/AdapterDateFns.js +1 -1
  2. package/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
  3. package/AdapterDayjs/AdapterDayjs.js +1 -1
  4. package/CHANGELOG.md +184 -4
  5. package/DateCalendar/DateCalendar.js +11 -1
  6. package/DateCalendar/useCalendarState.js +2 -0
  7. package/DateCalendar/useIsDateDisabled.d.ts +4 -3
  8. package/DateCalendar/useIsDateDisabled.js +5 -3
  9. package/DateField/DateField.js +2 -0
  10. package/DateField/DateField.types.d.ts +7 -2
  11. package/DateField/index.d.ts +1 -1
  12. package/DateField/useDateField.d.ts +1 -1
  13. package/DateField/useDateField.js +5 -3
  14. package/DatePicker/DatePicker.js +8 -0
  15. package/DatePicker/DatePicker.types.d.ts +5 -5
  16. package/DatePicker/DatePickerToolbar.js +2 -0
  17. package/DateTimeField/DateTimeField.js +2 -0
  18. package/DateTimeField/DateTimeField.types.d.ts +7 -2
  19. package/DateTimeField/index.d.ts +1 -1
  20. package/DateTimeField/useDateTimeField.d.ts +1 -1
  21. package/DateTimeField/useDateTimeField.js +5 -3
  22. package/DateTimePicker/DateTimePicker.js +8 -0
  23. package/DateTimePicker/DateTimePicker.types.d.ts +7 -6
  24. package/DateTimePicker/DateTimePickerTabs.js +2 -0
  25. package/DateTimePicker/DateTimePickerToolbar.js +2 -0
  26. package/DayCalendarSkeleton/DayCalendarSkeleton.js +2 -0
  27. package/DesktopDatePicker/DesktopDatePicker.js +16 -3
  28. package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -6
  29. package/DesktopDateTimePicker/DesktopDateTimePicker.js +16 -3
  30. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +11 -10
  31. package/DesktopTimePicker/DesktopTimePicker.js +10 -3
  32. package/DigitalClock/DigitalClock.js +2 -0
  33. package/LocalizationProvider/LocalizationProvider.js +2 -0
  34. package/MobileDatePicker/MobileDatePicker.js +16 -3
  35. package/MobileDatePicker/MobileDatePicker.types.d.ts +5 -0
  36. package/MobileDateTimePicker/MobileDateTimePicker.js +16 -3
  37. package/MobileTimePicker/MobileTimePicker.js +10 -3
  38. package/MonthCalendar/MonthCalendar.js +2 -0
  39. package/MonthCalendar/MonthCalendar.types.d.ts +1 -1
  40. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
  41. package/PickersActionBar/PickersActionBar.js +2 -0
  42. package/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
  43. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +1 -1
  44. package/PickersDay/PickersDay.js +2 -0
  45. package/PickersLayout/PickersLayout.js +2 -0
  46. package/PickersLayout/usePickerLayout.js +2 -0
  47. package/PickersSectionList/PickersSectionList.js +2 -0
  48. package/PickersShortcuts/PickersShortcuts.js +2 -0
  49. package/PickersTextField/PickersTextField.js +2 -0
  50. package/StaticDatePicker/StaticDatePicker.js +10 -2
  51. package/StaticDatePicker/StaticDatePicker.types.d.ts +5 -0
  52. package/StaticDateTimePicker/StaticDateTimePicker.js +10 -2
  53. package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +5 -0
  54. package/StaticTimePicker/StaticTimePicker.js +3 -1
  55. package/TimeClock/Clock.js +1 -1
  56. package/TimeClock/TimeClock.js +2 -0
  57. package/TimeField/TimeField.js +2 -0
  58. package/TimeField/TimeField.types.d.ts +7 -2
  59. package/TimeField/index.d.ts +1 -1
  60. package/TimeField/useTimeField.d.ts +1 -1
  61. package/TimeField/useTimeField.js +5 -3
  62. package/TimePicker/TimePicker.js +2 -0
  63. package/TimePicker/TimePickerToolbar.js +2 -0
  64. package/YearCalendar/YearCalendar.js +21 -6
  65. package/YearCalendar/YearCalendar.types.d.ts +7 -1
  66. package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
  67. package/dateViewRenderers/dateViewRenderers.js +2 -0
  68. package/hooks/index.d.ts +1 -0
  69. package/hooks/index.js +2 -1
  70. package/hooks/useClearableField.js +2 -0
  71. package/hooks/usePickersTranslations.js +2 -0
  72. package/hooks/useSplitFieldProps.d.ts +19 -0
  73. package/hooks/useSplitFieldProps.js +43 -0
  74. package/index.d.ts +1 -0
  75. package/index.js +3 -2
  76. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  77. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
  78. package/internals/hooks/useField/useField.js +11 -6
  79. package/internals/hooks/useField/useField.types.d.ts +4 -22
  80. package/internals/hooks/useField/useFieldState.js +2 -4
  81. package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  82. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
  83. package/internals/hooks/usePicker/usePicker.d.ts +1 -2
  84. package/internals/hooks/usePicker/usePicker.js +1 -1
  85. package/internals/hooks/usePicker/usePickerValue.d.ts +1 -2
  86. package/internals/hooks/usePicker/usePickerValue.js +12 -16
  87. package/internals/hooks/usePicker/usePickerValue.types.d.ts +4 -15
  88. package/internals/index.d.ts +0 -8
  89. package/internals/index.js +0 -7
  90. package/locales/beBY.d.ts +3 -3
  91. package/locales/beBY.js +4 -4
  92. package/locales/caES.d.ts +3 -3
  93. package/locales/caES.js +3 -3
  94. package/locales/csCZ.d.ts +3 -3
  95. package/locales/csCZ.js +4 -4
  96. package/locales/daDK.d.ts +3 -3
  97. package/locales/daDK.js +3 -3
  98. package/locales/deDE.d.ts +3 -3
  99. package/locales/deDE.js +3 -3
  100. package/locales/elGR.d.ts +3 -3
  101. package/locales/elGR.js +4 -4
  102. package/locales/enUS.d.ts +3 -3
  103. package/locales/enUS.js +4 -4
  104. package/locales/esES.d.ts +3 -3
  105. package/locales/esES.js +3 -3
  106. package/locales/eu.d.ts +3 -3
  107. package/locales/eu.js +3 -3
  108. package/locales/faIR.d.ts +3 -3
  109. package/locales/faIR.js +3 -3
  110. package/locales/fiFI.d.ts +3 -3
  111. package/locales/fiFI.js +3 -3
  112. package/locales/frFR.d.ts +3 -3
  113. package/locales/frFR.js +3 -3
  114. package/locales/heIL.d.ts +3 -3
  115. package/locales/heIL.js +3 -3
  116. package/locales/huHU.d.ts +3 -3
  117. package/locales/huHU.js +3 -3
  118. package/locales/isIS.d.ts +3 -3
  119. package/locales/isIS.js +4 -4
  120. package/locales/itIT.d.ts +3 -3
  121. package/locales/itIT.js +3 -3
  122. package/locales/jaJP.d.ts +3 -3
  123. package/locales/jaJP.js +3 -3
  124. package/locales/koKR.d.ts +3 -3
  125. package/locales/koKR.js +3 -3
  126. package/locales/kzKZ.d.ts +3 -3
  127. package/locales/kzKZ.js +4 -4
  128. package/locales/mk.d.ts +3 -3
  129. package/locales/mk.js +3 -3
  130. package/locales/nbNO.d.ts +3 -3
  131. package/locales/nbNO.js +4 -4
  132. package/locales/nlNL.d.ts +3 -3
  133. package/locales/nlNL.js +3 -3
  134. package/locales/nnNO.d.ts +3 -3
  135. package/locales/nnNO.js +3 -3
  136. package/locales/plPL.d.ts +3 -3
  137. package/locales/plPL.js +4 -4
  138. package/locales/ptBR.d.ts +3 -3
  139. package/locales/ptBR.js +4 -4
  140. package/locales/roRO.d.ts +3 -3
  141. package/locales/roRO.js +3 -3
  142. package/locales/ruRU.d.ts +3 -3
  143. package/locales/ruRU.js +3 -3
  144. package/locales/skSK.d.ts +3 -3
  145. package/locales/skSK.js +4 -4
  146. package/locales/svSE.d.ts +3 -3
  147. package/locales/svSE.js +3 -3
  148. package/locales/trTR.d.ts +3 -3
  149. package/locales/trTR.js +4 -4
  150. package/locales/ukUA.d.ts +3 -3
  151. package/locales/ukUA.js +3 -3
  152. package/locales/urPK.d.ts +3 -3
  153. package/locales/urPK.js +4 -4
  154. package/locales/utils/getPickersLocalization.d.ts +10 -3
  155. package/locales/utils/getPickersLocalization.js +13 -0
  156. package/locales/utils/pickersLocaleTextApi.d.ts +27 -3
  157. package/locales/viVN.d.ts +3 -3
  158. package/locales/viVN.js +3 -3
  159. package/locales/zhCN.d.ts +3 -3
  160. package/locales/zhCN.js +3 -3
  161. package/locales/zhHK.d.ts +3 -3
  162. package/locales/zhHK.js +3 -3
  163. package/models/validation.d.ts +13 -0
  164. package/modern/AdapterDateFns/AdapterDateFns.js +1 -1
  165. package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
  166. package/modern/AdapterDayjs/AdapterDayjs.js +1 -1
  167. package/modern/DateCalendar/DateCalendar.js +11 -1
  168. package/modern/DateCalendar/useCalendarState.js +2 -0
  169. package/modern/DateCalendar/useIsDateDisabled.js +5 -3
  170. package/modern/DateField/DateField.js +2 -0
  171. package/modern/DateField/useDateField.js +5 -3
  172. package/modern/DatePicker/DatePicker.js +8 -0
  173. package/modern/DatePicker/DatePickerToolbar.js +2 -0
  174. package/modern/DateTimeField/DateTimeField.js +2 -0
  175. package/modern/DateTimeField/useDateTimeField.js +5 -3
  176. package/modern/DateTimePicker/DateTimePicker.js +8 -0
  177. package/modern/DateTimePicker/DateTimePickerTabs.js +2 -0
  178. package/modern/DateTimePicker/DateTimePickerToolbar.js +2 -0
  179. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +2 -0
  180. package/modern/DesktopDatePicker/DesktopDatePicker.js +16 -3
  181. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +16 -3
  182. package/modern/DesktopTimePicker/DesktopTimePicker.js +10 -3
  183. package/modern/DigitalClock/DigitalClock.js +2 -0
  184. package/modern/LocalizationProvider/LocalizationProvider.js +2 -0
  185. package/modern/MobileDatePicker/MobileDatePicker.js +16 -3
  186. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +16 -3
  187. package/modern/MobileTimePicker/MobileTimePicker.js +10 -3
  188. package/modern/MonthCalendar/MonthCalendar.js +2 -0
  189. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
  190. package/modern/PickersActionBar/PickersActionBar.js +2 -0
  191. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
  192. package/modern/PickersDay/PickersDay.js +2 -0
  193. package/modern/PickersLayout/PickersLayout.js +2 -0
  194. package/modern/PickersLayout/usePickerLayout.js +2 -0
  195. package/modern/PickersSectionList/PickersSectionList.js +2 -0
  196. package/modern/PickersShortcuts/PickersShortcuts.js +2 -0
  197. package/modern/PickersTextField/PickersTextField.js +2 -0
  198. package/modern/StaticDatePicker/StaticDatePicker.js +10 -2
  199. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +10 -2
  200. package/modern/StaticTimePicker/StaticTimePicker.js +3 -1
  201. package/modern/TimeClock/Clock.js +1 -1
  202. package/modern/TimeClock/TimeClock.js +2 -0
  203. package/modern/TimeField/TimeField.js +2 -0
  204. package/modern/TimeField/useTimeField.js +5 -3
  205. package/modern/TimePicker/TimePicker.js +2 -0
  206. package/modern/TimePicker/TimePickerToolbar.js +2 -0
  207. package/modern/YearCalendar/YearCalendar.js +21 -6
  208. package/modern/dateViewRenderers/dateViewRenderers.js +2 -0
  209. package/modern/hooks/index.js +2 -1
  210. package/modern/hooks/useClearableField.js +2 -0
  211. package/modern/hooks/usePickersTranslations.js +2 -0
  212. package/modern/hooks/useSplitFieldProps.js +43 -0
  213. package/modern/index.js +3 -2
  214. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  215. package/modern/internals/hooks/useField/useField.js +11 -6
  216. package/modern/internals/hooks/useField/useFieldState.js +2 -4
  217. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  218. package/modern/internals/hooks/usePicker/usePicker.js +1 -1
  219. package/modern/internals/hooks/usePicker/usePickerValue.js +12 -16
  220. package/modern/internals/index.js +0 -7
  221. package/modern/locales/beBY.js +4 -4
  222. package/modern/locales/caES.js +3 -3
  223. package/modern/locales/csCZ.js +4 -4
  224. package/modern/locales/daDK.js +3 -3
  225. package/modern/locales/deDE.js +3 -3
  226. package/modern/locales/elGR.js +4 -4
  227. package/modern/locales/enUS.js +4 -4
  228. package/modern/locales/esES.js +3 -3
  229. package/modern/locales/eu.js +3 -3
  230. package/modern/locales/faIR.js +3 -3
  231. package/modern/locales/fiFI.js +3 -3
  232. package/modern/locales/frFR.js +3 -3
  233. package/modern/locales/heIL.js +3 -3
  234. package/modern/locales/huHU.js +3 -3
  235. package/modern/locales/isIS.js +4 -4
  236. package/modern/locales/itIT.js +3 -3
  237. package/modern/locales/jaJP.js +3 -3
  238. package/modern/locales/koKR.js +3 -3
  239. package/modern/locales/kzKZ.js +4 -4
  240. package/modern/locales/mk.js +3 -3
  241. package/modern/locales/nbNO.js +4 -4
  242. package/modern/locales/nlNL.js +3 -3
  243. package/modern/locales/nnNO.js +3 -3
  244. package/modern/locales/plPL.js +4 -4
  245. package/modern/locales/ptBR.js +4 -4
  246. package/modern/locales/roRO.js +3 -3
  247. package/modern/locales/ruRU.js +3 -3
  248. package/modern/locales/skSK.js +4 -4
  249. package/modern/locales/svSE.js +3 -3
  250. package/modern/locales/trTR.js +4 -4
  251. package/modern/locales/ukUA.js +3 -3
  252. package/modern/locales/urPK.js +4 -4
  253. package/modern/locales/utils/getPickersLocalization.js +13 -0
  254. package/modern/locales/viVN.js +3 -3
  255. package/modern/locales/zhCN.js +3 -3
  256. package/modern/locales/zhHK.js +3 -3
  257. package/modern/validation/index.js +5 -0
  258. package/modern/validation/useValidation.js +54 -0
  259. package/{internals/utils → modern}/validation/validateDate.js +6 -4
  260. package/modern/{internals/utils/validation → validation}/validateDateTime.js +8 -3
  261. package/{internals/utils → modern}/validation/validateTime.js +6 -4
  262. package/node/AdapterDateFns/AdapterDateFns.js +1 -1
  263. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
  264. package/node/AdapterDayjs/AdapterDayjs.js +1 -1
  265. package/node/DateCalendar/DateCalendar.js +10 -1
  266. package/node/DateCalendar/useCalendarState.js +1 -0
  267. package/node/DateCalendar/useIsDateDisabled.js +5 -4
  268. package/node/DateField/DateField.js +1 -0
  269. package/node/DateField/useDateField.js +5 -4
  270. package/node/DatePicker/DatePicker.js +7 -0
  271. package/node/DatePicker/DatePickerToolbar.js +1 -0
  272. package/node/DateTimeField/DateTimeField.js +1 -0
  273. package/node/DateTimeField/useDateTimeField.js +5 -4
  274. package/node/DateTimePicker/DateTimePicker.js +7 -0
  275. package/node/DateTimePicker/DateTimePickerTabs.js +1 -0
  276. package/node/DateTimePicker/DateTimePickerToolbar.js +1 -0
  277. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +1 -0
  278. package/node/DesktopDatePicker/DesktopDatePicker.js +17 -5
  279. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -5
  280. package/node/DesktopTimePicker/DesktopTimePicker.js +11 -5
  281. package/node/DigitalClock/DigitalClock.js +1 -0
  282. package/node/LocalizationProvider/LocalizationProvider.js +1 -0
  283. package/node/MobileDatePicker/MobileDatePicker.js +17 -5
  284. package/node/MobileDateTimePicker/MobileDateTimePicker.js +17 -5
  285. package/node/MobileTimePicker/MobileTimePicker.js +11 -5
  286. package/node/MonthCalendar/MonthCalendar.js +1 -0
  287. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  288. package/node/PickersActionBar/PickersActionBar.js +1 -0
  289. package/node/PickersCalendarHeader/PickersCalendarHeader.js +1 -0
  290. package/node/PickersDay/PickersDay.js +1 -0
  291. package/node/PickersLayout/PickersLayout.js +1 -0
  292. package/node/PickersLayout/usePickerLayout.js +1 -0
  293. package/node/PickersSectionList/PickersSectionList.js +1 -0
  294. package/node/PickersShortcuts/PickersShortcuts.js +1 -0
  295. package/node/PickersTextField/PickersTextField.js +1 -0
  296. package/node/StaticDatePicker/StaticDatePicker.js +10 -3
  297. package/node/StaticDateTimePicker/StaticDateTimePicker.js +10 -3
  298. package/node/StaticTimePicker/StaticTimePicker.js +3 -2
  299. package/node/TimeClock/Clock.js +1 -1
  300. package/node/TimeClock/TimeClock.js +1 -0
  301. package/node/TimeField/TimeField.js +1 -0
  302. package/node/TimeField/useTimeField.js +5 -4
  303. package/node/TimePicker/TimePicker.js +1 -0
  304. package/node/TimePicker/TimePickerToolbar.js +1 -0
  305. package/node/YearCalendar/YearCalendar.js +20 -6
  306. package/node/dateViewRenderers/dateViewRenderers.js +2 -0
  307. package/node/hooks/index.js +8 -1
  308. package/node/hooks/useClearableField.js +1 -0
  309. package/node/hooks/usePickersTranslations.js +1 -0
  310. package/node/hooks/useSplitFieldProps.js +51 -0
  311. package/node/index.js +13 -1
  312. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  313. package/node/internals/hooks/useField/useField.js +11 -6
  314. package/node/internals/hooks/useField/useFieldState.js +2 -4
  315. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  316. package/node/internals/hooks/usePicker/usePicker.js +1 -1
  317. package/node/internals/hooks/usePicker/usePickerValue.js +12 -16
  318. package/node/internals/index.js +0 -49
  319. package/node/locales/beBY.js +4 -4
  320. package/node/locales/caES.js +3 -3
  321. package/node/locales/csCZ.js +4 -4
  322. package/node/locales/daDK.js +3 -3
  323. package/node/locales/deDE.js +3 -3
  324. package/node/locales/elGR.js +4 -4
  325. package/node/locales/enUS.js +4 -4
  326. package/node/locales/esES.js +3 -3
  327. package/node/locales/eu.js +3 -3
  328. package/node/locales/faIR.js +3 -3
  329. package/node/locales/fiFI.js +3 -3
  330. package/node/locales/frFR.js +3 -3
  331. package/node/locales/heIL.js +3 -3
  332. package/node/locales/huHU.js +3 -3
  333. package/node/locales/isIS.js +4 -4
  334. package/node/locales/itIT.js +3 -3
  335. package/node/locales/jaJP.js +3 -3
  336. package/node/locales/koKR.js +3 -3
  337. package/node/locales/kzKZ.js +4 -4
  338. package/node/locales/mk.js +3 -3
  339. package/node/locales/nbNO.js +4 -4
  340. package/node/locales/nlNL.js +3 -3
  341. package/node/locales/nnNO.js +3 -3
  342. package/node/locales/plPL.js +4 -4
  343. package/node/locales/ptBR.js +4 -4
  344. package/node/locales/roRO.js +3 -3
  345. package/node/locales/ruRU.js +3 -3
  346. package/node/locales/skSK.js +4 -4
  347. package/node/locales/svSE.js +3 -3
  348. package/node/locales/trTR.js +4 -4
  349. package/node/locales/ukUA.js +3 -3
  350. package/node/locales/urPK.js +4 -4
  351. package/node/locales/utils/getPickersLocalization.js +16 -2
  352. package/node/locales/viVN.js +3 -3
  353. package/node/locales/zhCN.js +3 -3
  354. package/node/locales/zhHK.js +3 -3
  355. package/node/validation/index.js +40 -0
  356. package/node/validation/useValidation.js +61 -0
  357. package/node/{internals/utils/validation → validation}/validateDate.js +6 -4
  358. package/node/{internals/utils/validation → validation}/validateDateTime.js +8 -3
  359. package/node/{internals/utils/validation → validation}/validateTime.js +6 -4
  360. package/package.json +4 -4
  361. package/{internals/utils/validation → validation}/extractValidationProps.d.ts +1 -1
  362. package/validation/index.d.ts +9 -0
  363. package/validation/index.js +5 -0
  364. package/validation/package.json +6 -0
  365. package/validation/useValidation.d.ts +68 -0
  366. package/validation/useValidation.js +54 -0
  367. package/validation/validateDate.d.ts +6 -0
  368. package/{modern/internals/utils/validation → validation}/validateDate.js +6 -4
  369. package/validation/validateDateTime.d.ts +7 -0
  370. package/{internals/utils/validation → validation}/validateDateTime.js +8 -3
  371. package/validation/validateTime.d.ts +6 -0
  372. package/{modern/internals/utils/validation → validation}/validateTime.js +6 -4
  373. package/internals/hooks/useValidation.d.ts +0 -24
  374. package/internals/hooks/useValidation.js +0 -22
  375. package/internals/utils/fields.d.ts +0 -5
  376. package/internals/utils/fields.js +0 -28
  377. package/internals/utils/validation/validateDate.d.ts +0 -7
  378. package/internals/utils/validation/validateDateTime.d.ts +0 -7
  379. package/internals/utils/validation/validateTime.d.ts +0 -7
  380. package/internals/utils/warning.d.ts +0 -2
  381. package/internals/utils/warning.js +0 -21
  382. package/modern/internals/hooks/useValidation.js +0 -22
  383. package/modern/internals/utils/fields.js +0 -28
  384. package/modern/internals/utils/warning.js +0 -21
  385. package/node/internals/hooks/useValidation.js +0 -29
  386. package/node/internals/utils/fields.js +0 -36
  387. package/node/internals/utils/warning.js +0 -28
  388. /package/{internals/utils → modern}/validation/extractValidationProps.js +0 -0
  389. /package/node/{internals/utils/validation → validation}/extractValidationProps.js +0 -0
  390. /package/{modern/internals/utils/validation → validation}/extractValidationProps.js +0 -0
@@ -1,14 +1,16 @@
1
+ 'use client';
2
+
1
3
  import { singleItemFieldValueManager, singleItemValueManager } from "../internals/utils/valueManagers.js";
2
4
  import { useField } from "../internals/hooks/useField/index.js";
3
- import { validateTime } from "../internals/utils/validation/validateTime.js";
4
- import { splitFieldInternalAndForwardedProps } from "../internals/utils/fields.js";
5
+ import { validateTime } from "../validation/index.js";
6
+ import { useSplitFieldProps } from "../hooks/index.js";
5
7
  import { useDefaultizedTimeField } from "../internals/hooks/defaultizedFieldProps.js";
6
8
  export const useTimeField = inProps => {
7
9
  const props = useDefaultizedTimeField(inProps);
8
10
  const {
9
11
  forwardedProps,
10
12
  internalProps
11
- } = splitFieldInternalAndForwardedProps(props, 'time');
13
+ } = useSplitFieldProps(props, 'time');
12
14
  return useField({
13
15
  forwardedProps,
14
16
  internalProps,
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["desktopModeMediaQuery"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "disabled", "readOnly", "className"];
@@ -1,6 +1,8 @@
1
+ 'use client';
2
+
1
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
4
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
5
+ const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsOrder", "yearsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
4
6
  import * as React from 'react';
5
7
  import PropTypes from 'prop-types';
6
8
  import clsx from 'clsx';
@@ -86,6 +88,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
86
88
  onYearFocus,
87
89
  hasFocus,
88
90
  onFocusedViewChange,
91
+ yearsOrder = 'asc',
89
92
  yearsPerRow,
90
93
  timezone: timezoneProp,
91
94
  gridLabelId,
@@ -175,22 +178,24 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
175
178
  React.useEffect(() => {
176
179
  setFocusedYear(prevFocusedYear => selectedYear !== null && prevFocusedYear !== selectedYear ? selectedYear : prevFocusedYear);
177
180
  }, [selectedYear]);
181
+ const verticalDirection = yearsOrder !== 'desc' ? yearsPerRow * 1 : yearsPerRow * -1;
182
+ const horizontalDirection = isRtl || yearsOrder === 'desc' ? -1 : 1;
178
183
  const handleKeyDown = useEventCallback((event, year) => {
179
184
  switch (event.key) {
180
185
  case 'ArrowUp':
181
- focusYear(year - yearsPerRow);
186
+ focusYear(year - verticalDirection);
182
187
  event.preventDefault();
183
188
  break;
184
189
  case 'ArrowDown':
185
- focusYear(year + yearsPerRow);
190
+ focusYear(year + verticalDirection);
186
191
  event.preventDefault();
187
192
  break;
188
193
  case 'ArrowLeft':
189
- focusYear(year + (isRtl ? 1 : -1));
194
+ focusYear(year - horizontalDirection);
190
195
  event.preventDefault();
191
196
  break;
192
197
  case 'ArrowRight':
193
- focusYear(year + (isRtl ? -1 : 1));
198
+ focusYear(year + horizontalDirection);
194
199
  event.preventDefault();
195
200
  break;
196
201
  default:
@@ -228,6 +233,10 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
228
233
  }
229
234
  scrollerRef.current.scrollTop = elementBottom - clientHeight / 2 - offsetHeight / 2;
230
235
  }, [autoFocus]);
236
+ const yearRange = utils.getYearRange([minDate, maxDate]);
237
+ if (yearsOrder === 'desc') {
238
+ yearRange.reverse();
239
+ }
231
240
  return /*#__PURE__*/_jsx(YearCalendarRoot, _extends({
232
241
  ref: handleRef,
233
242
  className: clsx(classes.root, className),
@@ -235,7 +244,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
235
244
  role: "radiogroup",
236
245
  "aria-labelledby": gridLabelId
237
246
  }, other, {
238
- children: utils.getYearRange([minDate, maxDate]).map(year => {
247
+ children: yearRange.map(year => {
239
248
  const yearNumber = utils.getYear(year);
240
249
  const isSelected = yearNumber === selectedYear;
241
250
  const isDisabled = disabled || isYearDisabled(year);
@@ -356,6 +365,12 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
356
365
  * Used when the component is controlled.
357
366
  */
358
367
  value: PropTypes.object,
368
+ /**
369
+ * Years are displayed in ascending (chronological) order by default.
370
+ * If `desc`, years are displayed in descending order.
371
+ * @default 'asc'
372
+ */
373
+ yearsOrder: PropTypes.oneOf(['asc', 'desc']),
359
374
  /**
360
375
  * Years rendered per row.
361
376
  * @default 3
@@ -8,7 +8,7 @@ import type { PickersYearProps } from './PickersYear';
8
8
  import { SlotComponentPropsFromProps } from '../internals/models/helpers';
9
9
  export interface YearCalendarSlots {
10
10
  /**
11
- * Button displayed to render a single year in the "year" view.
11
+ * Button displayed to render a single year in the `year` view.
12
12
  * @default YearCalendarButton
13
13
  */
14
14
  yearButton?: React.ElementType;
@@ -19,6 +19,12 @@ export interface YearCalendarSlotProps {
19
19
  }, {}, PickersYearProps>;
20
20
  }
21
21
  export interface ExportedYearCalendarProps {
22
+ /**
23
+ * Years are displayed in ascending (chronological) order by default.
24
+ * If `desc`, years are displayed in descending order.
25
+ * @default 'asc'
26
+ */
27
+ yearsOrder?: 'asc' | 'desc';
22
28
  /**
23
29
  * Years rendered per row.
24
30
  * @default 3
@@ -8,4 +8,4 @@ export interface DateViewRendererProps<TDate extends PickerValidDate, TView exte
8
8
  views: readonly TView[];
9
9
  focusedView: TView | null;
10
10
  }
11
- export declare const renderDateViewCalendar: <TDate extends PickerValidDate>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, }: DateViewRendererProps<TDate, DateView>) => React.JSX.Element;
11
+ export declare const renderDateViewCalendar: <TDate extends PickerValidDate>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsOrder, yearsPerRow, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, }: DateViewRendererProps<TDate, DateView>) => React.JSX.Element;
@@ -25,6 +25,7 @@ export const renderDateViewCalendar = ({
25
25
  onMonthChange,
26
26
  monthsPerRow,
27
27
  onYearChange,
28
+ yearsOrder,
28
29
  yearsPerRow,
29
30
  slots,
30
31
  slotProps,
@@ -63,6 +64,7 @@ export const renderDateViewCalendar = ({
63
64
  onMonthChange: onMonthChange,
64
65
  monthsPerRow: monthsPerRow,
65
66
  onYearChange: onYearChange,
67
+ yearsOrder: yearsOrder,
66
68
  yearsPerRow: yearsPerRow,
67
69
  slots: slots,
68
70
  slotProps: slotProps,
package/hooks/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { useClearableField } from './useClearableField';
2
2
  export type { ExportedUseClearableFieldProps, UseClearableFieldSlots, UseClearableFieldSlotProps, UseClearableFieldResponse, } from './useClearableField';
3
3
  export { usePickersTranslations } from './usePickersTranslations';
4
+ export { useSplitFieldProps } from './useSplitFieldProps';
package/hooks/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { useClearableField } from "./useClearableField.js";
2
- export { usePickersTranslations } from "./usePickersTranslations.js";
2
+ export { usePickersTranslations } from "./usePickersTranslations.js";
3
+ export { useSplitFieldProps } from "./useSplitFieldProps.js";
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["clearable", "onClear", "InputProps", "sx", "slots", "slotProps"],
@@ -1,2 +1,4 @@
1
+ 'use client';
2
+
1
3
  import { useLocalizationContext } from "../internals/hooks/useUtils.js";
2
4
  export const usePickersTranslations = () => useLocalizationContext().localeText;
@@ -0,0 +1,19 @@
1
+ import { FieldValueType } from '../models';
2
+ import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from '../validation/extractValidationProps';
3
+ declare const SHARED_FIELD_INTERNAL_PROP_NAMES: readonly ["value", "defaultValue", "referenceDate", "format", "formatDensity", "onChange", "timezone", "onError", "shouldRespectLeadingZeros", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef", "enableAccessibleFieldDOMStructure", "disabled", "readOnly", "dateSeparator"];
4
+ type InternalPropNames<TValueType extends FieldValueType> = (typeof SHARED_FIELD_INTERNAL_PROP_NAMES)[number] | (TValueType extends 'date' | 'date-time' ? (typeof DATE_VALIDATION_PROP_NAMES)[number] : never) | (TValueType extends 'time' | 'date-time' ? (typeof TIME_VALIDATION_PROP_NAMES)[number] : never) | (TValueType extends 'date-time' ? (typeof DATE_TIME_VALIDATION_PROP_NAMES)[number] : never);
5
+ /**
6
+ * Split the props received by the field component into:
7
+ * - `internalProps` which are used by the various hooks called by the field component.
8
+ * - `forwardedProps` which are passed to the underlying component.
9
+ * Note that some forwarded props might be used by the hooks as well.
10
+ * For instance, hooks like `useDateField` need props like `autoFocus` to know how to behave.
11
+ * @template TProps, TValueType
12
+ * @param {TProps} props The props received by the field component.
13
+ * @param {TValueType} valueType The type of the field value ('date', 'time', or 'date-time').
14
+ */
15
+ export declare const useSplitFieldProps: <TValueType extends FieldValueType, TProps extends { [key in InternalPropNames<TValueType>]?: any; }>(props: TProps, valueType: TValueType) => {
16
+ forwardedProps: Omit<TProps, InternalPropNames<TValueType>>;
17
+ internalProps: Pick<TProps, InternalPropNames<TValueType>>;
18
+ };
19
+ export {};
@@ -0,0 +1,43 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from "../validation/extractValidationProps.js";
6
+ const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
7
+ /**
8
+ * Split the props received by the field component into:
9
+ * - `internalProps` which are used by the various hooks called by the field component.
10
+ * - `forwardedProps` which are passed to the underlying component.
11
+ * Note that some forwarded props might be used by the hooks as well.
12
+ * For instance, hooks like `useDateField` need props like `autoFocus` to know how to behave.
13
+ * @template TProps, TValueType
14
+ * @param {TProps} props The props received by the field component.
15
+ * @param {TValueType} valueType The type of the field value ('date', 'time', or 'date-time').
16
+ */
17
+ export const useSplitFieldProps = (props, valueType) => {
18
+ return React.useMemo(() => {
19
+ const forwardedProps = _extends({}, props);
20
+ const internalProps = {};
21
+ const extractProp = propName => {
22
+ if (forwardedProps.hasOwnProperty(propName)) {
23
+ // @ts-ignore
24
+ internalProps[propName] = forwardedProps[propName];
25
+ delete forwardedProps[propName];
26
+ }
27
+ };
28
+ SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
29
+ if (valueType === 'date') {
30
+ DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
31
+ } else if (valueType === 'time') {
32
+ TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
33
+ } else if (valueType === 'date-time') {
34
+ DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
35
+ TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
36
+ DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
37
+ }
38
+ return {
39
+ forwardedProps,
40
+ internalProps
41
+ };
42
+ }, [props, valueType]);
43
+ };
package/index.d.ts CHANGED
@@ -35,3 +35,4 @@ export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
35
35
  export * from './models';
36
36
  export * from './icons';
37
37
  export * from './hooks';
38
+ export * from './validation';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v7.16.0
2
+ * @mui/x-date-pickers v7.18.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -56,4 +56,5 @@ export * from "./PickersSectionList/index.js";
56
56
  export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./internals/utils/utils.js";
57
57
  export * from "./models/index.js";
58
58
  export * from "./icons/index.js";
59
- export * from "./hooks/index.js";
59
+ export * from "./hooks/index.js";
60
+ export * from "./validation/index.js";
@@ -10,7 +10,6 @@ import IconButton from '@mui/material/IconButton';
10
10
  import useForkRef from '@mui/utils/useForkRef';
11
11
  import useId from '@mui/utils/useId';
12
12
  import { PickersPopper } from "../../components/PickersPopper.js";
13
- import { useUtils } from "../useUtils.js";
14
13
  import { usePicker } from "../usePicker/index.js";
15
14
  import { LocalizationProvider } from "../../../LocalizationProvider/index.js";
16
15
  import { PickersLayout } from "../../../PickersLayout/index.js";
@@ -47,7 +46,6 @@ export const useDesktopPicker = _ref => {
47
46
  localeText,
48
47
  reduceAnimations
49
48
  } = props;
50
- const utils = useUtils();
51
49
  const containerRef = React.useRef(null);
52
50
  const fieldRef = React.useRef(null);
53
51
  const labelId = useId();
@@ -89,7 +87,7 @@ export const useDesktopPicker = _ref => {
89
87
  additionalProps: {
90
88
  disabled: disabled || readOnly,
91
89
  onClick: open ? actions.onClose : actions.onOpen,
92
- 'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils),
90
+ 'aria-label': getOpenDialogAriaText(pickerFieldProps.value),
93
91
  edge: inputAdornmentProps.position
94
92
  },
95
93
  ownerState: props
@@ -6,7 +6,7 @@ import { SlotComponentProps } from '@mui/utils';
6
6
  import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
7
7
  import { PickersPopperSlots, PickersPopperSlotProps } from '../../components/PickersPopper';
8
8
  import { UsePickerParams, UsePickerProps } from '../usePicker';
9
- import { BaseSingleInputFieldProps, FieldSection, MuiPickersAdapter, PickerValidDate } from '../../../models';
9
+ import { BaseSingleInputFieldProps, FieldSection, PickerValidDate } from '../../../models';
10
10
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
11
11
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
12
12
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
@@ -71,5 +71,5 @@ export interface UseDesktopPickerProps<TDate extends PickerValidDate, TView exte
71
71
  }
72
72
  export interface UseDesktopPickerParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TDate, TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<TDate | null, TDate, TView, FieldSection, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
73
73
  props: TExternalProps;
74
- getOpenDialogAriaText: (date: TDate | null, utils: MuiPickersAdapter<TDate>) => string;
74
+ getOpenDialogAriaText: (date: TDate | null) => string;
75
75
  }
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
4
4
  import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import { useRtl } from '@mui/system/RtlProvider';
6
- import { useValidation } from "../useValidation.js";
6
+ import { useValidation } from "../../../validation/index.js";
7
7
  import { useUtils } from "../useUtils.js";
8
8
  import { adjustSectionValue, getSectionOrder } from "./useField.utils.js";
9
9
  import { useFieldState } from "./useFieldState.js";
@@ -158,18 +158,23 @@ export const useField = params => {
158
158
  useEnhancedEffect(() => {
159
159
  interactions.syncSelectionToDOM();
160
160
  });
161
- const validationError = useValidation(_extends({}, internalProps, {
161
+ const {
162
+ hasValidationError
163
+ } = useValidation({
164
+ props: internalProps,
165
+ validator,
166
+ timezone,
162
167
  value: state.value,
163
- timezone
164
- }), validator, valueManager.isSameError, valueManager.defaultErrorState);
168
+ onError: internalProps.onError
169
+ });
165
170
  const inputError = React.useMemo(() => {
166
171
  // only override when `error` is undefined.
167
172
  // in case of multi input fields, the `error` value is provided externally and will always be defined.
168
173
  if (error !== undefined) {
169
174
  return error;
170
175
  }
171
- return valueManager.hasError(validationError);
172
- }, [valueManager, validationError, error]);
176
+ return hasValidationError;
177
+ }, [hasValidationError, error]);
173
178
  React.useEffect(() => {
174
179
  if (!inputError && activeSectionIndex == null) {
175
180
  resetCharacterQuery();
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, FieldValueType, PickersTimezone, PickerValidDate, FieldRef } from '../../../models';
2
+ import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, FieldValueType, PickerValidDate, FieldRef, OnErrorProps, InferError } from '../../../models';
3
3
  import type { PickerValueManager } from '../usePicker';
4
- import { InferError, Validator } from '../useValidation';
4
+ import type { Validator } from '../../../validation';
5
5
  import type { UseFieldStateResponse } from './useFieldState';
6
6
  import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
7
7
  import { PickersSectionElement, PickersSectionListRef } from '../../../PickersSectionList';
@@ -11,10 +11,10 @@ export interface UseFieldParams<TValue, TDate extends PickerValidDate, TSection
11
11
  internalProps: TInternalProps;
12
12
  valueManager: PickerValueManager<TValue, TDate, InferError<TInternalProps>>;
13
13
  fieldValueManager: FieldValueManager<TValue, TDate, TSection>;
14
- validator: Validator<TValue, TDate, InferError<TInternalProps>, UseFieldValidationProps<TValue, TInternalProps>>;
14
+ validator: Validator<TValue, TDate, InferError<TInternalProps>, TInternalProps>;
15
15
  valueType: FieldValueType;
16
16
  }
17
- export interface UseFieldInternalProps<TValue, TDate extends PickerValidDate, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps {
17
+ export interface UseFieldInternalProps<TValue, TDate extends PickerValidDate, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, OnErrorProps<TValue, TError> {
18
18
  /**
19
19
  * The selected value.
20
20
  * Used when the component is controlled.
@@ -38,16 +38,6 @@ export interface UseFieldInternalProps<TValue, TDate extends PickerValidDate, TS
38
38
  * @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
39
39
  */
40
40
  onChange?: FieldChangeHandler<TValue, TError>;
41
- /**
42
- * Callback fired when the error associated with the current value changes.
43
- * When a validation error is detected, the `error` parameter contains a non-null value.
44
- * This can be used to render an appropriate form error.
45
- * @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
46
- * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
47
- * @param {TError} error The reason why the current value is not valid.
48
- * @param {TValue} value The value associated with the error.
49
- */
50
- onError?: (error: TError, value: TValue) => void;
51
41
  /**
52
42
  * Format of the date when rendered in the input(s).
53
43
  */
@@ -291,14 +281,6 @@ export interface UseFieldState<TValue, TSection extends FieldSection> {
291
281
  */
292
282
  tempValueStrAndroid: string | null;
293
283
  }
294
- export type UseFieldValidationProps<TValue, TInternalProps extends {
295
- value?: TValue;
296
- defaultValue?: TValue;
297
- timezone?: PickersTimezone;
298
- }> = Omit<TInternalProps, 'value' | 'defaultValue' | 'timezone'> & {
299
- value: TValue;
300
- timezone: PickersTimezone;
301
- };
302
284
  export type AvailableAdjustKeyCode = 'ArrowUp' | 'ArrowDown' | 'PageUp' | 'PageDown' | 'Home' | 'End';
303
285
  export type SectionNeighbors = {
304
286
  [sectionIndex: number]: {
@@ -110,10 +110,8 @@ export const useFieldState = params => {
110
110
  validationError: validator({
111
111
  adapter,
112
112
  value,
113
- props: _extends({}, internalProps, {
114
- value,
115
- timezone
116
- })
113
+ timezone,
114
+ props: internalProps
117
115
  })
118
116
  };
119
117
  handleValueChange(value, context);
@@ -8,7 +8,6 @@ import useId from '@mui/utils/useId';
8
8
  import { PickersModalDialog } from "../../components/PickersModalDialog.js";
9
9
  import { usePicker } from "../usePicker/index.js";
10
10
  import { onSpaceOrEnter } from "../../utils/utils.js";
11
- import { useUtils } from "../useUtils.js";
12
11
  import { LocalizationProvider } from "../../../LocalizationProvider/index.js";
13
12
  import { PickersLayout } from "../../../PickersLayout/index.js";
14
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -42,7 +41,6 @@ export const useMobilePicker = _ref => {
42
41
  disabled,
43
42
  localeText
44
43
  } = props;
45
- const utils = useUtils();
46
44
  const fieldRef = React.useRef(null);
47
45
  const labelId = useId();
48
46
  const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
@@ -89,7 +87,7 @@ export const useMobilePicker = _ref => {
89
87
 
90
88
  // TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
91
89
  fieldProps.inputProps = _extends({}, fieldProps.inputProps, {
92
- 'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils)
90
+ 'aria-label': getOpenDialogAriaText(pickerFieldProps.value)
93
91
  });
94
92
  const slotsForField = _extends({
95
93
  textField: slots.textField
@@ -4,7 +4,7 @@ import { SlotComponentProps } from '@mui/utils';
4
4
  import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
5
5
  import { PickersModalDialogSlots, PickersModalDialogSlotProps } from '../../components/PickersModalDialog';
6
6
  import { UsePickerParams, UsePickerProps } from '../usePicker';
7
- import { BaseSingleInputFieldProps, FieldSection, MuiPickersAdapter, PickerValidDate } from '../../../models';
7
+ import { BaseSingleInputFieldProps, FieldSection, PickerValidDate } from '../../../models';
8
8
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
9
9
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
10
10
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
@@ -43,5 +43,5 @@ export interface UseMobilePickerProps<TDate extends PickerValidDate, TView exten
43
43
  }
44
44
  export interface UseMobilePickerParams<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TDate, TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<TDate | null, TDate, TView, FieldSection, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator'> {
45
45
  props: TExternalProps;
46
- getOpenDialogAriaText: (date: TDate | null, utils: MuiPickersAdapter<TDate>) => string;
46
+ getOpenDialogAriaText: (date: TDate | null) => string;
47
47
  }
@@ -1,5 +1,4 @@
1
1
  import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.types';
2
- import { InferError } from '../useValidation';
3
- import { FieldSection, PickerValidDate } from '../../../models';
2
+ import { FieldSection, PickerValidDate, InferError } from '../../../models';
4
3
  import { DateOrTimeViewWithMeridiem } from '../../models';
5
4
  export declare const usePicker: <TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TDate, TView, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, wrapperVariant, additionalViewProps, validator, autoFocusView, rendererInterceptor, fieldRef, }: UsePickerParams<TValue, TDate, TView, TSection, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, TSection, InferError<TExternalProps>>;
@@ -1,7 +1,7 @@
1
+ import { warnOnce } from '@mui/x-internals/warning';
1
2
  import { usePickerValue } from "./usePickerValue.js";
2
3
  import { usePickerViews } from "./usePickerViews.js";
3
4
  import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
4
- import { warnOnce } from "../../utils/warning.js";
5
5
  export const usePicker = ({
6
6
  props,
7
7
  valueManager,
@@ -1,5 +1,4 @@
1
- import { InferError } from '../useValidation';
2
- import { FieldSection, PickerValidDate } from '../../../models';
1
+ import { FieldSection, PickerValidDate, InferError } from '../../../models';
3
2
  import { UsePickerValueProps, UsePickerValueParams, UsePickerValueResponse } from './usePickerValue.types';
4
3
  /**
5
4
  * Manage the value lifecycle of all the pickers.
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import useEventCallback from '@mui/utils/useEventCallback';
4
4
  import { useOpenState } from "../useOpenState.js";
5
5
  import { useLocalizationContext, useUtils } from "../useUtils.js";
6
- import { useValidation } from "../useValidation.js";
6
+ import { useValidation } from "../../../validation/index.js";
7
7
  import { useValueWithTimezone } from "../useValueWithTimezone.js";
8
8
 
9
9
  /**
@@ -180,10 +180,15 @@ export const usePickerValue = ({
180
180
  hasBeenModifiedSinceMount: false
181
181
  };
182
182
  });
183
- useValidation(_extends({}, props, {
183
+ const {
184
+ getValidationErrorForNewValue
185
+ } = useValidation({
186
+ props,
187
+ validator,
188
+ timezone,
184
189
  value: dateState.draft,
185
- timezone
186
- }), validator, valueManager.isSameError, valueManager.defaultErrorState);
190
+ onError: props.onError
191
+ });
187
192
  const updateDate = useEventCallback(action => {
188
193
  const updaterParams = {
189
194
  action,
@@ -204,14 +209,7 @@ export const usePickerValue = ({
204
209
  let cachedContext = null;
205
210
  const getContext = () => {
206
211
  if (!cachedContext) {
207
- const validationError = action.name === 'setValueFromField' ? action.context.validationError : validator({
208
- adapter,
209
- value: action.value,
210
- props: _extends({}, props, {
211
- value: action.value,
212
- timezone
213
- })
214
- });
212
+ const validationError = action.name === 'setValueFromField' ? action.context.validationError : getValidationErrorForNewValue(action.value);
215
213
  cachedContext = {
216
214
  validationError
217
215
  };
@@ -325,10 +323,8 @@ export const usePickerValue = ({
325
323
  const error = validator({
326
324
  adapter,
327
325
  value: testedValue,
328
- props: _extends({}, props, {
329
- value: testedValue,
330
- timezone
331
- })
326
+ timezone,
327
+ props
332
328
  });
333
329
  return !valueManager.hasError(error);
334
330
  };
@@ -1,8 +1,7 @@
1
1
  import { FieldChangeHandlerContext, UseFieldInternalProps } from '../useField';
2
- import { InferError, Validator } from '../useValidation';
3
- import { UseFieldValidationProps } from '../useField/useField.types';
2
+ import { Validator } from '../../../validation';
4
3
  import { WrapperVariant } from '../../models/common';
5
- import { FieldSection, FieldValueType, TimezoneProps, MuiPickersAdapter, PickersTimezone, PickerChangeHandlerContext, PickerValidDate } from '../../../models';
4
+ import { FieldSection, FieldValueType, TimezoneProps, MuiPickersAdapter, PickersTimezone, PickerChangeHandlerContext, PickerValidDate, OnErrorProps, InferError } from '../../../models';
6
5
  import { GetDefaultReferenceDateProps } from '../../utils/getDefaultReferenceDate';
7
6
  import { PickerShortcutChangeImportance, PickersShortcutsItemContext } from '../../../PickersShortcuts';
8
7
  export interface PickerValueManager<TValue, TDate extends PickerValidDate, TError> {
@@ -170,7 +169,7 @@ export type PickerValueUpdateAction<TValue, TError> = {
170
169
  /**
171
170
  * Props used to handle the value that are common to all pickers.
172
171
  */
173
- export interface UsePickerValueBaseProps<TValue, TError> {
172
+ export interface UsePickerValueBaseProps<TValue, TError> extends OnErrorProps<TValue, TError> {
174
173
  /**
175
174
  * The selected value.
176
175
  * Used when the component is controlled.
@@ -197,16 +196,6 @@ export interface UsePickerValueBaseProps<TValue, TError> {
197
196
  * @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
198
197
  */
199
198
  onAccept?: (value: TValue, context: PickerChangeHandlerContext<TError>) => void;
200
- /**
201
- * Callback fired when the error associated with the current value changes.
202
- * When a validation error is detected, the `error` parameter contains a non-null value.
203
- * This can be used to render an appropriate form error.
204
- * @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
205
- * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
206
- * @param {TError} error The reason why the current value is not valid.
207
- * @param {TValue} value The value associated with the error.
208
- */
209
- onError?: (error: TError, value: TValue) => void;
210
199
  }
211
200
  /**
212
201
  * Props used to handle the value of non-static pickers.
@@ -243,7 +232,7 @@ export interface UsePickerValueParams<TValue, TDate extends PickerValidDate, TEx
243
232
  valueManager: PickerValueManager<TValue, TDate, InferError<TExternalProps>>;
244
233
  valueType: FieldValueType;
245
234
  wrapperVariant: WrapperVariant;
246
- validator: Validator<TValue, TDate, InferError<TExternalProps>, UseFieldValidationProps<TValue, TExternalProps>>;
235
+ validator: Validator<TValue, TDate, InferError<TExternalProps>, TExternalProps>;
247
236
  }
248
237
  export interface UsePickerValueActions {
249
238
  onAccept: () => void;
@@ -35,8 +35,6 @@ export type { StaticOnlyPickerProps, UseStaticPickerSlots, UseStaticPickerSlotPr
35
35
  export { useLocalizationContext, useDefaultDates, useUtils, useNow } from './hooks/useUtils';
36
36
  export type { ExportedUseViewsOptions, UseViewsOptions } from './hooks/useViews';
37
37
  export { useViews } from './hooks/useViews';
38
- export { useValidation } from './hooks/useValidation';
39
- export type { ValidationProps, Validator, InferError } from './hooks/useValidation';
40
38
  export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
41
39
  export type { BaseFieldProps } from './models/fields';
42
40
  export type { BasePickerProps, BasePickerInputProps, BaseNonStaticPickerProps, } from './models/props/basePickerProps';
@@ -49,17 +47,11 @@ export type { BaseDateValidationProps, BaseTimeValidationProps, TimeValidationPr
49
47
  export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
50
48
  export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem, } from './utils/date-utils';
51
49
  export { resolveTimeViewsResponse, resolveDateTimeFormat } from './utils/date-time-utils';
52
- export { splitFieldInternalAndForwardedProps } from './utils/fields';
53
50
  export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
54
51
  export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, } from './utils/utils';
55
52
  export { useDefaultizedDateField, useDefaultizedTimeField, useDefaultizedDateTimeField, } from './hooks/defaultizedFieldProps';
56
53
  export { useDefaultReduceAnimations } from './hooks/useDefaultReduceAnimations';
57
- export { extractValidationProps } from './utils/validation/extractValidationProps';
58
- export { validateDate } from './utils/validation/validateDate';
59
- export { validateDateTime } from './utils/validation/validateDateTime';
60
- export { validateTime } from './utils/validation/validateTime';
61
54
  export { applyDefaultViewProps } from './utils/views';
62
- export { warnOnce } from './utils/warning';
63
55
  export { DayCalendar } from '../DateCalendar/DayCalendar';
64
56
  export type { DayCalendarProps, DayCalendarSlots, DayCalendarSlotProps, ExportedDayCalendarProps, } from '../DateCalendar/DayCalendar';
65
57
  export type { ExportedDateCalendarProps } from '../DateCalendar/DateCalendar.types';