@mui/x-date-pickers 7.16.0 → 7.17.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 (370) hide show
  1. package/AdapterDayjs/AdapterDayjs.js +1 -1
  2. package/CHANGELOG.md +87 -0
  3. package/DateCalendar/DateCalendar.js +2 -0
  4. package/DateCalendar/useCalendarState.js +2 -0
  5. package/DateCalendar/useIsDateDisabled.d.ts +4 -3
  6. package/DateCalendar/useIsDateDisabled.js +5 -3
  7. package/DateField/DateField.js +2 -0
  8. package/DateField/DateField.types.d.ts +7 -2
  9. package/DateField/index.d.ts +1 -1
  10. package/DateField/useDateField.d.ts +1 -1
  11. package/DateField/useDateField.js +5 -3
  12. package/DatePicker/DatePicker.js +2 -0
  13. package/DatePicker/DatePickerToolbar.js +2 -0
  14. package/DateTimeField/DateTimeField.js +2 -0
  15. package/DateTimeField/DateTimeField.types.d.ts +7 -2
  16. package/DateTimeField/index.d.ts +1 -1
  17. package/DateTimeField/useDateTimeField.d.ts +1 -1
  18. package/DateTimeField/useDateTimeField.js +5 -3
  19. package/DateTimePicker/DateTimePicker.js +2 -0
  20. package/DateTimePicker/DateTimePickerTabs.js +2 -0
  21. package/DateTimePicker/DateTimePickerToolbar.js +2 -0
  22. package/DayCalendarSkeleton/DayCalendarSkeleton.js +2 -0
  23. package/DesktopDatePicker/DesktopDatePicker.js +10 -3
  24. package/DesktopDateTimePicker/DesktopDateTimePicker.js +10 -3
  25. package/DesktopTimePicker/DesktopTimePicker.js +10 -3
  26. package/DigitalClock/DigitalClock.js +2 -0
  27. package/LocalizationProvider/LocalizationProvider.js +2 -0
  28. package/MobileDatePicker/MobileDatePicker.js +10 -3
  29. package/MobileDateTimePicker/MobileDateTimePicker.js +10 -3
  30. package/MobileTimePicker/MobileTimePicker.js +10 -3
  31. package/MonthCalendar/MonthCalendar.js +2 -0
  32. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
  33. package/PickersActionBar/PickersActionBar.js +2 -0
  34. package/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
  35. package/PickersDay/PickersDay.js +2 -0
  36. package/PickersLayout/PickersLayout.js +2 -0
  37. package/PickersLayout/usePickerLayout.js +2 -0
  38. package/PickersSectionList/PickersSectionList.js +2 -0
  39. package/PickersShortcuts/PickersShortcuts.js +2 -0
  40. package/PickersTextField/PickersTextField.js +2 -0
  41. package/StaticDatePicker/StaticDatePicker.js +3 -1
  42. package/StaticDateTimePicker/StaticDateTimePicker.js +3 -1
  43. package/StaticTimePicker/StaticTimePicker.js +3 -1
  44. package/TimeClock/Clock.js +1 -1
  45. package/TimeClock/TimeClock.js +2 -0
  46. package/TimeField/TimeField.js +2 -0
  47. package/TimeField/TimeField.types.d.ts +7 -2
  48. package/TimeField/index.d.ts +1 -1
  49. package/TimeField/useTimeField.d.ts +1 -1
  50. package/TimeField/useTimeField.js +5 -3
  51. package/TimePicker/TimePicker.js +2 -0
  52. package/TimePicker/TimePickerToolbar.js +2 -0
  53. package/YearCalendar/YearCalendar.js +2 -0
  54. package/hooks/index.d.ts +1 -0
  55. package/hooks/index.js +2 -1
  56. package/hooks/useClearableField.js +2 -0
  57. package/hooks/usePickersTranslations.js +2 -0
  58. package/hooks/useSplitFieldProps.d.ts +19 -0
  59. package/hooks/useSplitFieldProps.js +43 -0
  60. package/index.d.ts +1 -0
  61. package/index.js +3 -2
  62. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  63. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
  64. package/internals/hooks/useField/useField.js +11 -6
  65. package/internals/hooks/useField/useField.types.d.ts +4 -22
  66. package/internals/hooks/useField/useFieldState.js +2 -4
  67. package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  68. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
  69. package/internals/hooks/usePicker/usePicker.d.ts +1 -2
  70. package/internals/hooks/usePicker/usePicker.js +1 -1
  71. package/internals/hooks/usePicker/usePickerValue.d.ts +1 -2
  72. package/internals/hooks/usePicker/usePickerValue.js +12 -16
  73. package/internals/hooks/usePicker/usePickerValue.types.d.ts +4 -15
  74. package/internals/index.d.ts +0 -8
  75. package/internals/index.js +0 -7
  76. package/locales/beBY.d.ts +3 -3
  77. package/locales/beBY.js +4 -4
  78. package/locales/caES.d.ts +3 -3
  79. package/locales/caES.js +3 -3
  80. package/locales/csCZ.d.ts +3 -3
  81. package/locales/csCZ.js +4 -4
  82. package/locales/daDK.d.ts +3 -3
  83. package/locales/daDK.js +3 -3
  84. package/locales/deDE.d.ts +3 -3
  85. package/locales/deDE.js +3 -3
  86. package/locales/elGR.d.ts +3 -3
  87. package/locales/elGR.js +4 -4
  88. package/locales/enUS.d.ts +3 -3
  89. package/locales/enUS.js +4 -4
  90. package/locales/esES.d.ts +3 -3
  91. package/locales/esES.js +3 -3
  92. package/locales/eu.d.ts +3 -3
  93. package/locales/eu.js +3 -3
  94. package/locales/faIR.d.ts +3 -3
  95. package/locales/faIR.js +3 -3
  96. package/locales/fiFI.d.ts +3 -3
  97. package/locales/fiFI.js +3 -3
  98. package/locales/frFR.d.ts +3 -3
  99. package/locales/frFR.js +3 -3
  100. package/locales/heIL.d.ts +3 -3
  101. package/locales/heIL.js +3 -3
  102. package/locales/huHU.d.ts +3 -3
  103. package/locales/huHU.js +3 -3
  104. package/locales/isIS.d.ts +3 -3
  105. package/locales/isIS.js +4 -4
  106. package/locales/itIT.d.ts +3 -3
  107. package/locales/itIT.js +3 -3
  108. package/locales/jaJP.d.ts +3 -3
  109. package/locales/jaJP.js +3 -3
  110. package/locales/koKR.d.ts +3 -3
  111. package/locales/koKR.js +3 -3
  112. package/locales/kzKZ.d.ts +3 -3
  113. package/locales/kzKZ.js +4 -4
  114. package/locales/mk.d.ts +3 -3
  115. package/locales/mk.js +3 -3
  116. package/locales/nbNO.d.ts +3 -3
  117. package/locales/nbNO.js +4 -4
  118. package/locales/nlNL.d.ts +3 -3
  119. package/locales/nlNL.js +3 -3
  120. package/locales/nnNO.d.ts +3 -3
  121. package/locales/nnNO.js +3 -3
  122. package/locales/plPL.d.ts +3 -3
  123. package/locales/plPL.js +4 -4
  124. package/locales/ptBR.d.ts +3 -3
  125. package/locales/ptBR.js +4 -4
  126. package/locales/roRO.d.ts +3 -3
  127. package/locales/roRO.js +3 -3
  128. package/locales/ruRU.d.ts +3 -3
  129. package/locales/ruRU.js +3 -3
  130. package/locales/skSK.d.ts +3 -3
  131. package/locales/skSK.js +4 -4
  132. package/locales/svSE.d.ts +3 -3
  133. package/locales/svSE.js +3 -3
  134. package/locales/trTR.d.ts +3 -3
  135. package/locales/trTR.js +4 -4
  136. package/locales/ukUA.d.ts +3 -3
  137. package/locales/ukUA.js +3 -3
  138. package/locales/urPK.d.ts +3 -3
  139. package/locales/urPK.js +4 -4
  140. package/locales/utils/getPickersLocalization.d.ts +10 -3
  141. package/locales/utils/getPickersLocalization.js +13 -0
  142. package/locales/utils/pickersLocaleTextApi.d.ts +27 -3
  143. package/locales/viVN.d.ts +3 -3
  144. package/locales/viVN.js +3 -3
  145. package/locales/zhCN.d.ts +3 -3
  146. package/locales/zhCN.js +3 -3
  147. package/locales/zhHK.d.ts +3 -3
  148. package/locales/zhHK.js +3 -3
  149. package/models/validation.d.ts +13 -0
  150. package/modern/AdapterDayjs/AdapterDayjs.js +1 -1
  151. package/modern/DateCalendar/DateCalendar.js +2 -0
  152. package/modern/DateCalendar/useCalendarState.js +2 -0
  153. package/modern/DateCalendar/useIsDateDisabled.js +5 -3
  154. package/modern/DateField/DateField.js +2 -0
  155. package/modern/DateField/useDateField.js +5 -3
  156. package/modern/DatePicker/DatePicker.js +2 -0
  157. package/modern/DatePicker/DatePickerToolbar.js +2 -0
  158. package/modern/DateTimeField/DateTimeField.js +2 -0
  159. package/modern/DateTimeField/useDateTimeField.js +5 -3
  160. package/modern/DateTimePicker/DateTimePicker.js +2 -0
  161. package/modern/DateTimePicker/DateTimePickerTabs.js +2 -0
  162. package/modern/DateTimePicker/DateTimePickerToolbar.js +2 -0
  163. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +2 -0
  164. package/modern/DesktopDatePicker/DesktopDatePicker.js +10 -3
  165. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +10 -3
  166. package/modern/DesktopTimePicker/DesktopTimePicker.js +10 -3
  167. package/modern/DigitalClock/DigitalClock.js +2 -0
  168. package/modern/LocalizationProvider/LocalizationProvider.js +2 -0
  169. package/modern/MobileDatePicker/MobileDatePicker.js +10 -3
  170. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +10 -3
  171. package/modern/MobileTimePicker/MobileTimePicker.js +10 -3
  172. package/modern/MonthCalendar/MonthCalendar.js +2 -0
  173. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
  174. package/modern/PickersActionBar/PickersActionBar.js +2 -0
  175. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
  176. package/modern/PickersDay/PickersDay.js +2 -0
  177. package/modern/PickersLayout/PickersLayout.js +2 -0
  178. package/modern/PickersLayout/usePickerLayout.js +2 -0
  179. package/modern/PickersSectionList/PickersSectionList.js +2 -0
  180. package/modern/PickersShortcuts/PickersShortcuts.js +2 -0
  181. package/modern/PickersTextField/PickersTextField.js +2 -0
  182. package/modern/StaticDatePicker/StaticDatePicker.js +3 -1
  183. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +3 -1
  184. package/modern/StaticTimePicker/StaticTimePicker.js +3 -1
  185. package/modern/TimeClock/Clock.js +1 -1
  186. package/modern/TimeClock/TimeClock.js +2 -0
  187. package/modern/TimeField/TimeField.js +2 -0
  188. package/modern/TimeField/useTimeField.js +5 -3
  189. package/modern/TimePicker/TimePicker.js +2 -0
  190. package/modern/TimePicker/TimePickerToolbar.js +2 -0
  191. package/modern/YearCalendar/YearCalendar.js +2 -0
  192. package/modern/hooks/index.js +2 -1
  193. package/modern/hooks/useClearableField.js +2 -0
  194. package/modern/hooks/usePickersTranslations.js +2 -0
  195. package/modern/hooks/useSplitFieldProps.js +43 -0
  196. package/modern/index.js +3 -2
  197. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  198. package/modern/internals/hooks/useField/useField.js +11 -6
  199. package/modern/internals/hooks/useField/useFieldState.js +2 -4
  200. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  201. package/modern/internals/hooks/usePicker/usePicker.js +1 -1
  202. package/modern/internals/hooks/usePicker/usePickerValue.js +12 -16
  203. package/modern/internals/index.js +0 -7
  204. package/modern/locales/beBY.js +4 -4
  205. package/modern/locales/caES.js +3 -3
  206. package/modern/locales/csCZ.js +4 -4
  207. package/modern/locales/daDK.js +3 -3
  208. package/modern/locales/deDE.js +3 -3
  209. package/modern/locales/elGR.js +4 -4
  210. package/modern/locales/enUS.js +4 -4
  211. package/modern/locales/esES.js +3 -3
  212. package/modern/locales/eu.js +3 -3
  213. package/modern/locales/faIR.js +3 -3
  214. package/modern/locales/fiFI.js +3 -3
  215. package/modern/locales/frFR.js +3 -3
  216. package/modern/locales/heIL.js +3 -3
  217. package/modern/locales/huHU.js +3 -3
  218. package/modern/locales/isIS.js +4 -4
  219. package/modern/locales/itIT.js +3 -3
  220. package/modern/locales/jaJP.js +3 -3
  221. package/modern/locales/koKR.js +3 -3
  222. package/modern/locales/kzKZ.js +4 -4
  223. package/modern/locales/mk.js +3 -3
  224. package/modern/locales/nbNO.js +4 -4
  225. package/modern/locales/nlNL.js +3 -3
  226. package/modern/locales/nnNO.js +3 -3
  227. package/modern/locales/plPL.js +4 -4
  228. package/modern/locales/ptBR.js +4 -4
  229. package/modern/locales/roRO.js +3 -3
  230. package/modern/locales/ruRU.js +3 -3
  231. package/modern/locales/skSK.js +4 -4
  232. package/modern/locales/svSE.js +3 -3
  233. package/modern/locales/trTR.js +4 -4
  234. package/modern/locales/ukUA.js +3 -3
  235. package/modern/locales/urPK.js +4 -4
  236. package/modern/locales/utils/getPickersLocalization.js +13 -0
  237. package/modern/locales/viVN.js +3 -3
  238. package/modern/locales/zhCN.js +3 -3
  239. package/modern/locales/zhHK.js +3 -3
  240. package/modern/validation/index.js +5 -0
  241. package/modern/validation/useValidation.js +54 -0
  242. package/{internals/utils → modern}/validation/validateDate.js +6 -4
  243. package/modern/{internals/utils/validation → validation}/validateDateTime.js +8 -3
  244. package/{internals/utils → modern}/validation/validateTime.js +6 -4
  245. package/node/AdapterDayjs/AdapterDayjs.js +1 -1
  246. package/node/DateCalendar/DateCalendar.js +1 -0
  247. package/node/DateCalendar/useCalendarState.js +1 -0
  248. package/node/DateCalendar/useIsDateDisabled.js +5 -4
  249. package/node/DateField/DateField.js +1 -0
  250. package/node/DateField/useDateField.js +5 -4
  251. package/node/DatePicker/DatePicker.js +1 -0
  252. package/node/DatePicker/DatePickerToolbar.js +1 -0
  253. package/node/DateTimeField/DateTimeField.js +1 -0
  254. package/node/DateTimeField/useDateTimeField.js +5 -4
  255. package/node/DateTimePicker/DateTimePicker.js +1 -0
  256. package/node/DateTimePicker/DateTimePickerTabs.js +1 -0
  257. package/node/DateTimePicker/DateTimePickerToolbar.js +1 -0
  258. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +1 -0
  259. package/node/DesktopDatePicker/DesktopDatePicker.js +11 -5
  260. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +11 -5
  261. package/node/DesktopTimePicker/DesktopTimePicker.js +11 -5
  262. package/node/DigitalClock/DigitalClock.js +1 -0
  263. package/node/LocalizationProvider/LocalizationProvider.js +1 -0
  264. package/node/MobileDatePicker/MobileDatePicker.js +11 -5
  265. package/node/MobileDateTimePicker/MobileDateTimePicker.js +11 -5
  266. package/node/MobileTimePicker/MobileTimePicker.js +11 -5
  267. package/node/MonthCalendar/MonthCalendar.js +1 -0
  268. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  269. package/node/PickersActionBar/PickersActionBar.js +1 -0
  270. package/node/PickersCalendarHeader/PickersCalendarHeader.js +1 -0
  271. package/node/PickersDay/PickersDay.js +1 -0
  272. package/node/PickersLayout/PickersLayout.js +1 -0
  273. package/node/PickersLayout/usePickerLayout.js +1 -0
  274. package/node/PickersSectionList/PickersSectionList.js +1 -0
  275. package/node/PickersShortcuts/PickersShortcuts.js +1 -0
  276. package/node/PickersTextField/PickersTextField.js +1 -0
  277. package/node/StaticDatePicker/StaticDatePicker.js +3 -2
  278. package/node/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
  279. package/node/StaticTimePicker/StaticTimePicker.js +3 -2
  280. package/node/TimeClock/Clock.js +1 -1
  281. package/node/TimeClock/TimeClock.js +1 -0
  282. package/node/TimeField/TimeField.js +1 -0
  283. package/node/TimeField/useTimeField.js +5 -4
  284. package/node/TimePicker/TimePicker.js +1 -0
  285. package/node/TimePicker/TimePickerToolbar.js +1 -0
  286. package/node/YearCalendar/YearCalendar.js +1 -0
  287. package/node/hooks/index.js +8 -1
  288. package/node/hooks/useClearableField.js +1 -0
  289. package/node/hooks/usePickersTranslations.js +1 -0
  290. package/node/hooks/useSplitFieldProps.js +51 -0
  291. package/node/index.js +13 -1
  292. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  293. package/node/internals/hooks/useField/useField.js +11 -6
  294. package/node/internals/hooks/useField/useFieldState.js +2 -4
  295. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  296. package/node/internals/hooks/usePicker/usePicker.js +1 -1
  297. package/node/internals/hooks/usePicker/usePickerValue.js +12 -16
  298. package/node/internals/index.js +0 -49
  299. package/node/locales/beBY.js +4 -4
  300. package/node/locales/caES.js +3 -3
  301. package/node/locales/csCZ.js +4 -4
  302. package/node/locales/daDK.js +3 -3
  303. package/node/locales/deDE.js +3 -3
  304. package/node/locales/elGR.js +4 -4
  305. package/node/locales/enUS.js +4 -4
  306. package/node/locales/esES.js +3 -3
  307. package/node/locales/eu.js +3 -3
  308. package/node/locales/faIR.js +3 -3
  309. package/node/locales/fiFI.js +3 -3
  310. package/node/locales/frFR.js +3 -3
  311. package/node/locales/heIL.js +3 -3
  312. package/node/locales/huHU.js +3 -3
  313. package/node/locales/isIS.js +4 -4
  314. package/node/locales/itIT.js +3 -3
  315. package/node/locales/jaJP.js +3 -3
  316. package/node/locales/koKR.js +3 -3
  317. package/node/locales/kzKZ.js +4 -4
  318. package/node/locales/mk.js +3 -3
  319. package/node/locales/nbNO.js +4 -4
  320. package/node/locales/nlNL.js +3 -3
  321. package/node/locales/nnNO.js +3 -3
  322. package/node/locales/plPL.js +4 -4
  323. package/node/locales/ptBR.js +4 -4
  324. package/node/locales/roRO.js +3 -3
  325. package/node/locales/ruRU.js +3 -3
  326. package/node/locales/skSK.js +4 -4
  327. package/node/locales/svSE.js +3 -3
  328. package/node/locales/trTR.js +4 -4
  329. package/node/locales/ukUA.js +3 -3
  330. package/node/locales/urPK.js +4 -4
  331. package/node/locales/utils/getPickersLocalization.js +16 -2
  332. package/node/locales/viVN.js +3 -3
  333. package/node/locales/zhCN.js +3 -3
  334. package/node/locales/zhHK.js +3 -3
  335. package/node/validation/index.js +40 -0
  336. package/node/validation/useValidation.js +61 -0
  337. package/node/{internals/utils/validation → validation}/validateDate.js +6 -4
  338. package/node/{internals/utils/validation → validation}/validateDateTime.js +8 -3
  339. package/node/{internals/utils/validation → validation}/validateTime.js +6 -4
  340. package/package.json +2 -2
  341. package/{internals/utils/validation → validation}/extractValidationProps.d.ts +1 -1
  342. package/validation/index.d.ts +9 -0
  343. package/validation/index.js +5 -0
  344. package/validation/package.json +6 -0
  345. package/validation/useValidation.d.ts +68 -0
  346. package/validation/useValidation.js +54 -0
  347. package/validation/validateDate.d.ts +6 -0
  348. package/{modern/internals/utils/validation → validation}/validateDate.js +6 -4
  349. package/validation/validateDateTime.d.ts +7 -0
  350. package/{internals/utils/validation → validation}/validateDateTime.js +8 -3
  351. package/validation/validateTime.d.ts +6 -0
  352. package/{modern/internals/utils/validation → validation}/validateTime.js +6 -4
  353. package/internals/hooks/useValidation.d.ts +0 -24
  354. package/internals/hooks/useValidation.js +0 -22
  355. package/internals/utils/fields.d.ts +0 -5
  356. package/internals/utils/fields.js +0 -28
  357. package/internals/utils/validation/validateDate.d.ts +0 -7
  358. package/internals/utils/validation/validateDateTime.d.ts +0 -7
  359. package/internals/utils/validation/validateTime.d.ts +0 -7
  360. package/internals/utils/warning.d.ts +0 -2
  361. package/internals/utils/warning.js +0 -21
  362. package/modern/internals/hooks/useValidation.js +0 -22
  363. package/modern/internals/utils/fields.js +0 -28
  364. package/modern/internals/utils/warning.js +0 -21
  365. package/node/internals/hooks/useValidation.js +0 -29
  366. package/node/internals/utils/fields.js +0 -36
  367. package/node/internals/utils/warning.js +0 -28
  368. /package/{internals/utils → modern}/validation/extractValidationProps.js +0 -0
  369. /package/node/{internals/utils/validation → validation}/extractValidationProps.js +0 -0
  370. /package/{modern/internals/utils/validation → validation}/extractValidationProps.js +0 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "extractValidationProps", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _extractValidationProps.extractValidationProps;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "useValidation", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _useValidation.useValidation;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "validateDate", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _validateDate.validateDate;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "validateDateTime", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _validateDateTime.validateDateTime;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "validateTime", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _validateTime.validateTime;
34
+ }
35
+ });
36
+ var _validateDate = require("./validateDate");
37
+ var _validateTime = require("./validateTime");
38
+ var _validateDateTime = require("./validateDateTime");
39
+ var _extractValidationProps = require("./extractValidationProps");
40
+ var _useValidation = require("./useValidation");
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.useValidation = useValidation;
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
12
+ var _useUtils = require("../internals/hooks/useUtils");
13
+ /**
14
+ * Utility hook to check if a given value is valid based on the provided validation props.
15
+ * @template TDate
16
+ * @template TValue The value type. It will be either the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
17
+ * @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.
18
+ * @param {UseValidationOptions<TValue, TDate, TError, TValidationProps>} options The options to configure the hook.
19
+ * @param {TValue} options.value The value to validate.
20
+ * @param {PickersTimezone} options.timezone The timezone to use for the validation.
21
+ * @param {Validator<TValue, TDate, TError, TValidationProps>} options.validator The validator function to use.
22
+ * @param {TValidationProps} options.props The validation props, they differ depending on the component.
23
+ * @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
24
+ */
25
+ function useValidation(options) {
26
+ const {
27
+ props,
28
+ validator,
29
+ value,
30
+ timezone,
31
+ onError
32
+ } = options;
33
+ const adapter = (0, _useUtils.useLocalizationContext)();
34
+ const previousValidationErrorRef = React.useRef(validator.valueManager.defaultErrorState);
35
+ const validationError = validator({
36
+ adapter,
37
+ value,
38
+ timezone,
39
+ props
40
+ });
41
+ const hasValidationError = validator.valueManager.hasError(validationError);
42
+ React.useEffect(() => {
43
+ if (onError && !validator.valueManager.isSameError(validationError, previousValidationErrorRef.current)) {
44
+ onError(validationError, value);
45
+ }
46
+ previousValidationErrorRef.current = validationError;
47
+ }, [validator, onError, validationError, value]);
48
+ const getValidationErrorForNewValue = (0, _useEventCallback.default)(newValue => {
49
+ return validator({
50
+ adapter,
51
+ value: newValue,
52
+ timezone,
53
+ props
54
+ });
55
+ });
56
+ return {
57
+ validationError,
58
+ hasValidationError,
59
+ getValidationErrorForNewValue
60
+ };
61
+ }
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.validateDate = void 0;
7
- var _dateUtils = require("../date-utils");
7
+ var _dateUtils = require("../internals/utils/date-utils");
8
+ var _valueManagers = require("../internals/utils/valueManagers");
8
9
  const validateDate = ({
9
10
  props,
10
11
  value,
12
+ timezone,
11
13
  adapter
12
14
  }) => {
13
15
  if (value === null) {
@@ -18,8 +20,7 @@ const validateDate = ({
18
20
  shouldDisableMonth,
19
21
  shouldDisableYear,
20
22
  disablePast,
21
- disableFuture,
22
- timezone
23
+ disableFuture
23
24
  } = props;
24
25
  const now = adapter.utils.date(undefined, timezone);
25
26
  const minDate = (0, _dateUtils.applyDefaultDate)(adapter.utils, props.minDate, adapter.defaultDates.minDate);
@@ -45,4 +46,5 @@ const validateDate = ({
45
46
  return null;
46
47
  }
47
48
  };
48
- exports.validateDate = validateDate;
49
+ exports.validateDate = validateDate;
50
+ validateDate.valueManager = _valueManagers.singleItemValueManager;
@@ -6,14 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.validateDateTime = void 0;
7
7
  var _validateDate = require("./validateDate");
8
8
  var _validateTime = require("./validateTime");
9
+ var _valueManagers = require("../internals/utils/valueManagers");
9
10
  const validateDateTime = ({
10
- props,
11
+ adapter,
11
12
  value,
12
- adapter
13
+ timezone,
14
+ props
13
15
  }) => {
14
16
  const dateValidationResult = (0, _validateDate.validateDate)({
15
17
  adapter,
16
18
  value,
19
+ timezone,
17
20
  props
18
21
  });
19
22
  if (dateValidationResult !== null) {
@@ -22,7 +25,9 @@ const validateDateTime = ({
22
25
  return (0, _validateTime.validateTime)({
23
26
  adapter,
24
27
  value,
28
+ timezone,
25
29
  props
26
30
  });
27
31
  };
28
- exports.validateDateTime = validateDateTime;
32
+ exports.validateDateTime = validateDateTime;
33
+ validateDateTime.valueManager = _valueManagers.singleItemValueManager;
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.validateTime = void 0;
7
- var _timeUtils = require("../time-utils");
7
+ var _timeUtils = require("../internals/utils/time-utils");
8
+ var _valueManagers = require("../internals/utils/valueManagers");
8
9
  const validateTime = ({
9
10
  adapter,
10
11
  value,
12
+ timezone,
11
13
  props
12
14
  }) => {
13
15
  if (value === null) {
@@ -20,8 +22,7 @@ const validateTime = ({
20
22
  shouldDisableTime,
21
23
  disableIgnoringDatePartForTimeValidation = false,
22
24
  disablePast,
23
- disableFuture,
24
- timezone
25
+ disableFuture
25
26
  } = props;
26
27
  const now = adapter.utils.date(undefined, timezone);
27
28
  const isAfter = (0, _timeUtils.createIsAfterIgnoreDatePart)(disableIgnoringDatePartForTimeValidation, adapter.utils);
@@ -48,4 +49,5 @@ const validateTime = ({
48
49
  return null;
49
50
  }
50
51
  };
51
- exports.validateTime = validateTime;
52
+ exports.validateTime = validateTime;
53
+ validateTime.valueManager = _valueManagers.singleItemValueManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-date-pickers",
3
- "version": "7.16.0",
3
+ "version": "7.17.0",
4
4
  "description": "The community edition of the Date and Time Picker components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -41,7 +41,7 @@
41
41
  "clsx": "^2.1.1",
42
42
  "prop-types": "^15.8.1",
43
43
  "react-transition-group": "^4.4.5",
44
- "@mui/x-internals": "7.16.0"
44
+ "@mui/x-internals": "7.17.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@emotion/react": "^11.9.0",
@@ -1,4 +1,4 @@
1
- import { BaseDateValidationProps, BaseTimeValidationProps, DateTimeValidationProps, DayValidationProps, MonthValidationProps, TimeValidationProps, YearValidationProps } from '../../models/validation';
1
+ import { BaseDateValidationProps, BaseTimeValidationProps, DateTimeValidationProps, DayValidationProps, MonthValidationProps, TimeValidationProps, YearValidationProps } from '../internals/models/validation';
2
2
  export declare const DATE_VALIDATION_PROP_NAMES: (keyof BaseDateValidationProps<any> | keyof YearValidationProps<any> | keyof MonthValidationProps<any> | keyof DayValidationProps<any>)[];
3
3
  export declare const TIME_VALIDATION_PROP_NAMES: (keyof BaseTimeValidationProps | keyof TimeValidationProps<any> | 'ampm')[];
4
4
  export declare const DATE_TIME_VALIDATION_PROP_NAMES: (keyof DateTimeValidationProps<any>)[];
@@ -0,0 +1,9 @@
1
+ export { validateDate } from './validateDate';
2
+ export type { ValidateDateProps } from './validateDate';
3
+ export { validateTime } from './validateTime';
4
+ export type { ValidateTimeProps } from './validateTime';
5
+ export { validateDateTime } from './validateDateTime';
6
+ export type { ValidateDateTimeProps } from './validateDateTime';
7
+ export { extractValidationProps } from './extractValidationProps';
8
+ export { useValidation } from './useValidation';
9
+ export type { Validator } from './useValidation';
@@ -0,0 +1,5 @@
1
+ export { validateDate } from "./validateDate.js";
2
+ export { validateTime } from "./validateTime.js";
3
+ export { validateDateTime } from "./validateDateTime.js";
4
+ export { extractValidationProps } from "./extractValidationProps.js";
5
+ export { useValidation } from "./useValidation.js";
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/validation/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,68 @@
1
+ import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
2
+ import { OnErrorProps, PickersTimezone, PickerValidDate } from '../models';
3
+ import type { PickerValueManager } from '../internals/hooks/usePicker';
4
+ export type Validator<TValue, TDate extends PickerValidDate, TError, TValidationProps> = {
5
+ (params: {
6
+ adapter: MuiPickersAdapterContextValue<TDate>;
7
+ value: TValue;
8
+ timezone: PickersTimezone;
9
+ props: TValidationProps;
10
+ }): TError;
11
+ valueManager: PickerValueManager<TValue, TDate, any>;
12
+ };
13
+ interface UseValidationOptions<TValue, TDate extends PickerValidDate, TError, TValidationProps extends {}> extends OnErrorProps<TValue, TError> {
14
+ /**
15
+ * The value to validate.
16
+ */
17
+ value: TValue;
18
+ /**
19
+ * The timezone to use for the validation.
20
+ */
21
+ timezone: PickersTimezone;
22
+ /**
23
+ * The validator function to use.
24
+ * They can be imported from `@mui/x-date-pickers/validation` and `@mui/x-date-pickers-pro/validation`.
25
+ * It is recommended to only use the validator exported by the MUI X packages,
26
+ * otherwise you may have inconsistent behaviors between the field and the views.
27
+ */
28
+ validator: Validator<TValue, TDate, TError, TValidationProps>;
29
+ /**
30
+ * The validation props, they differ depending on the component.
31
+ * For example, the `validateTime` function supports `minTime`, `maxTime`, etc.
32
+ */
33
+ props: TValidationProps;
34
+ }
35
+ interface UseValidationReturnValue<TValue, TError> {
36
+ /**
37
+ * The validation error associated to the value passed to the `useValidation` hook.
38
+ */
39
+ validationError: TError;
40
+ /**
41
+ * `true` if the current error is not null.
42
+ * For single value components, it means that the value is invalid.
43
+ * For range components, it means that either start or end value is invalid.
44
+ */
45
+ hasValidationError: boolean;
46
+ /**
47
+ * Get the validation error for a new value.
48
+ * This can be used to validate the value in a change handler before updating the state.
49
+ * @template TValue The value type.
50
+ * @param {TValue} newValue The value to validate.
51
+ * @returns {TError} The validation error associated to the new value.
52
+ */
53
+ getValidationErrorForNewValue: (newValue: TValue) => TError;
54
+ }
55
+ /**
56
+ * Utility hook to check if a given value is valid based on the provided validation props.
57
+ * @template TDate
58
+ * @template TValue The value type. It will be either the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
59
+ * @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.
60
+ * @param {UseValidationOptions<TValue, TDate, TError, TValidationProps>} options The options to configure the hook.
61
+ * @param {TValue} options.value The value to validate.
62
+ * @param {PickersTimezone} options.timezone The timezone to use for the validation.
63
+ * @param {Validator<TValue, TDate, TError, TValidationProps>} options.validator The validator function to use.
64
+ * @param {TValidationProps} options.props The validation props, they differ depending on the component.
65
+ * @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
66
+ */
67
+ export declare function useValidation<TValue, TDate extends PickerValidDate, TError, TValidationProps extends {}>(options: UseValidationOptions<TValue, TDate, TError, TValidationProps>): UseValidationReturnValue<TValue, TError>;
68
+ export {};
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import useEventCallback from '@mui/utils/useEventCallback';
5
+ import { useLocalizationContext } from "../internals/hooks/useUtils.js";
6
+ /**
7
+ * Utility hook to check if a given value is valid based on the provided validation props.
8
+ * @template TDate
9
+ * @template TValue The value type. It will be either the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
10
+ * @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.
11
+ * @param {UseValidationOptions<TValue, TDate, TError, TValidationProps>} options The options to configure the hook.
12
+ * @param {TValue} options.value The value to validate.
13
+ * @param {PickersTimezone} options.timezone The timezone to use for the validation.
14
+ * @param {Validator<TValue, TDate, TError, TValidationProps>} options.validator The validator function to use.
15
+ * @param {TValidationProps} options.props The validation props, they differ depending on the component.
16
+ * @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
17
+ */
18
+ export function useValidation(options) {
19
+ const {
20
+ props,
21
+ validator,
22
+ value,
23
+ timezone,
24
+ onError
25
+ } = options;
26
+ const adapter = useLocalizationContext();
27
+ const previousValidationErrorRef = React.useRef(validator.valueManager.defaultErrorState);
28
+ const validationError = validator({
29
+ adapter,
30
+ value,
31
+ timezone,
32
+ props
33
+ });
34
+ const hasValidationError = validator.valueManager.hasError(validationError);
35
+ React.useEffect(() => {
36
+ if (onError && !validator.valueManager.isSameError(validationError, previousValidationErrorRef.current)) {
37
+ onError(validationError, value);
38
+ }
39
+ previousValidationErrorRef.current = validationError;
40
+ }, [validator, onError, validationError, value]);
41
+ const getValidationErrorForNewValue = useEventCallback(newValue => {
42
+ return validator({
43
+ adapter,
44
+ value: newValue,
45
+ timezone,
46
+ props
47
+ });
48
+ });
49
+ return {
50
+ validationError,
51
+ hasValidationError,
52
+ getValidationErrorForNewValue
53
+ };
54
+ }
@@ -0,0 +1,6 @@
1
+ import { Validator } from './useValidation';
2
+ import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../internals/models/validation';
3
+ import { DateValidationError, PickerValidDate } from '../models';
4
+ export interface ValidateDateProps<TDate extends PickerValidDate> extends DayValidationProps<TDate>, MonthValidationProps<TDate>, YearValidationProps<TDate>, Required<BaseDateValidationProps<TDate>> {
5
+ }
6
+ export declare const validateDate: Validator<any | null, any, DateValidationError, ValidateDateProps<any>>;
@@ -1,7 +1,9 @@
1
- import { applyDefaultDate } from "../date-utils.js";
1
+ import { applyDefaultDate } from "../internals/utils/date-utils.js";
2
+ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
2
3
  export const validateDate = ({
3
4
  props,
4
5
  value,
6
+ timezone,
5
7
  adapter
6
8
  }) => {
7
9
  if (value === null) {
@@ -12,8 +14,7 @@ export const validateDate = ({
12
14
  shouldDisableMonth,
13
15
  shouldDisableYear,
14
16
  disablePast,
15
- disableFuture,
16
- timezone
17
+ disableFuture
17
18
  } = props;
18
19
  const now = adapter.utils.date(undefined, timezone);
19
20
  const minDate = applyDefaultDate(adapter.utils, props.minDate, adapter.defaultDates.minDate);
@@ -38,4 +39,5 @@ export const validateDate = ({
38
39
  default:
39
40
  return null;
40
41
  }
41
- };
42
+ };
43
+ validateDate.valueManager = singleItemValueManager;
@@ -0,0 +1,7 @@
1
+ import { Validator } from './useValidation';
2
+ import { ValidateDateProps } from './validateDate';
3
+ import { ValidateTimeProps } from './validateTime';
4
+ import { DateTimeValidationError, PickerValidDate } from '../models';
5
+ export interface ValidateDateTimeProps<TDate extends PickerValidDate> extends ValidateDateProps<TDate>, ValidateTimeProps<TDate> {
6
+ }
7
+ export declare const validateDateTime: Validator<any | null, any, DateTimeValidationError, ValidateDateTimeProps<any>>;
@@ -1,13 +1,16 @@
1
1
  import { validateDate } from "./validateDate.js";
2
2
  import { validateTime } from "./validateTime.js";
3
+ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
3
4
  export const validateDateTime = ({
4
- props,
5
+ adapter,
5
6
  value,
6
- adapter
7
+ timezone,
8
+ props
7
9
  }) => {
8
10
  const dateValidationResult = validateDate({
9
11
  adapter,
10
12
  value,
13
+ timezone,
11
14
  props
12
15
  });
13
16
  if (dateValidationResult !== null) {
@@ -16,6 +19,8 @@ export const validateDateTime = ({
16
19
  return validateTime({
17
20
  adapter,
18
21
  value,
22
+ timezone,
19
23
  props
20
24
  });
21
- };
25
+ };
26
+ validateDateTime.valueManager = singleItemValueManager;
@@ -0,0 +1,6 @@
1
+ import { Validator } from './useValidation';
2
+ import { BaseTimeValidationProps, TimeValidationProps } from '../internals/models/validation';
3
+ import { PickerValidDate, TimeValidationError } from '../models';
4
+ export interface ValidateTimeProps<TDate extends PickerValidDate> extends Required<BaseTimeValidationProps>, TimeValidationProps<TDate> {
5
+ }
6
+ export declare const validateTime: Validator<any | null, any, TimeValidationError, ValidateTimeProps<any>>;
@@ -1,7 +1,9 @@
1
- import { createIsAfterIgnoreDatePart } from "../time-utils.js";
1
+ import { createIsAfterIgnoreDatePart } from "../internals/utils/time-utils.js";
2
+ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
2
3
  export const validateTime = ({
3
4
  adapter,
4
5
  value,
6
+ timezone,
5
7
  props
6
8
  }) => {
7
9
  if (value === null) {
@@ -14,8 +16,7 @@ export const validateTime = ({
14
16
  shouldDisableTime,
15
17
  disableIgnoringDatePartForTimeValidation = false,
16
18
  disablePast,
17
- disableFuture,
18
- timezone
19
+ disableFuture
19
20
  } = props;
20
21
  const now = adapter.utils.date(undefined, timezone);
21
22
  const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter.utils);
@@ -41,4 +42,5 @@ export const validateTime = ({
41
42
  default:
42
43
  return null;
43
44
  }
44
- };
45
+ };
46
+ validateTime.valueManager = singleItemValueManager;
@@ -1,24 +0,0 @@
1
- import { MuiPickersAdapterContextValue } from '../../LocalizationProvider/LocalizationProvider';
2
- import { PickerValidDate } from '../../models';
3
- interface ValidationCommonProps<TError, TValue> {
4
- /**
5
- * Callback fired when the error associated with the current value changes.
6
- * When a validation error is detected, the `error` parameter contains a non-null value.
7
- * This can be used to render an appropriate form error.
8
- * @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.
9
- * @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.
10
- * @param {TError} error The reason why the current value is not valid.
11
- * @param {TValue} value The value associated with the error.
12
- */
13
- onError?: (error: TError, value: TValue) => void;
14
- value: TValue;
15
- }
16
- export type ValidationProps<TError, TValue, TValidationProps extends {}> = ValidationCommonProps<TError, TValue> & TValidationProps;
17
- export type InferError<TProps> = TProps extends Pick<ValidationCommonProps<any, any>, 'onError'> ? Parameters<Exclude<TProps['onError'], undefined>>[0] : never;
18
- export type Validator<TValue, TDate extends PickerValidDate, TError, TValidationProps> = (params: {
19
- adapter: MuiPickersAdapterContextValue<TDate>;
20
- value: TValue;
21
- props: Omit<TValidationProps, 'value' | 'onError'>;
22
- }) => TError;
23
- export declare function useValidation<TValue, TDate extends PickerValidDate, TError, TValidationProps extends {}>(props: ValidationProps<TError, TValue, TValidationProps>, validate: Validator<TValue, TDate, TError, TValidationProps>, isSameError: (a: TError, b: TError | null) => boolean, defaultErrorState: TError): TError;
24
- export {};
@@ -1,22 +0,0 @@
1
- import * as React from 'react';
2
- import { useLocalizationContext } from "./useUtils.js";
3
- export function useValidation(props, validate, isSameError, defaultErrorState) {
4
- const {
5
- value,
6
- onError
7
- } = props;
8
- const adapter = useLocalizationContext();
9
- const previousValidationErrorRef = React.useRef(defaultErrorState);
10
- const validationError = validate({
11
- adapter,
12
- value,
13
- props
14
- });
15
- React.useEffect(() => {
16
- if (onError && !isSameError(validationError, previousValidationErrorRef.current)) {
17
- onError(validationError, value);
18
- }
19
- previousValidationErrorRef.current = validationError;
20
- }, [isSameError, onError, previousValidationErrorRef, validationError, value]);
21
- return validationError;
22
- }
@@ -1,5 +0,0 @@
1
- import { FieldValueType } from '../../models';
2
- export declare const splitFieldInternalAndForwardedProps: <TProps extends {}, TInternalPropNames extends keyof TProps>(props: TProps, valueType: FieldValueType) => {
3
- forwardedProps: Omit<TProps, TInternalPropNames>;
4
- internalProps: Pick<TProps, TInternalPropNames>;
5
- };
@@ -1,28 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from "./validation/extractValidationProps.js";
3
- const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
4
- export const splitFieldInternalAndForwardedProps = (props, valueType) => {
5
- const forwardedProps = _extends({}, props);
6
- const internalProps = {};
7
- const extractProp = propName => {
8
- if (forwardedProps.hasOwnProperty(propName)) {
9
- // @ts-ignore
10
- internalProps[propName] = forwardedProps[propName];
11
- delete forwardedProps[propName];
12
- }
13
- };
14
- SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
15
- if (valueType === 'date') {
16
- DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
17
- } else if (valueType === 'time') {
18
- TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
19
- } else if (valueType === 'date-time') {
20
- DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
21
- TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
22
- DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
23
- }
24
- return {
25
- forwardedProps,
26
- internalProps
27
- };
28
- };
@@ -1,7 +0,0 @@
1
- import { Validator } from '../../hooks/useValidation';
2
- import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../../models/validation';
3
- import { DateValidationError, PickerValidDate, TimezoneProps } from '../../../models';
4
- import { DefaultizedProps } from '../../models/helpers';
5
- export interface DateComponentValidationProps<TDate extends PickerValidDate> extends DayValidationProps<TDate>, MonthValidationProps<TDate>, YearValidationProps<TDate>, Required<BaseDateValidationProps<TDate>>, DefaultizedProps<TimezoneProps, 'timezone'> {
6
- }
7
- export declare const validateDate: Validator<any | null, any, DateValidationError, DateComponentValidationProps<any>>;
@@ -1,7 +0,0 @@
1
- import { Validator } from '../../hooks/useValidation';
2
- import { DateComponentValidationProps } from './validateDate';
3
- import { TimeComponentValidationProps } from './validateTime';
4
- import { DateTimeValidationError, PickerValidDate } from '../../../models';
5
- export interface DateTimeComponentValidationProps<TDate extends PickerValidDate> extends DateComponentValidationProps<TDate>, TimeComponentValidationProps<TDate> {
6
- }
7
- export declare const validateDateTime: Validator<any | null, any, DateTimeValidationError, DateTimeComponentValidationProps<any>>;
@@ -1,7 +0,0 @@
1
- import { Validator } from '../../hooks/useValidation';
2
- import { BaseTimeValidationProps, TimeValidationProps } from '../../models/validation';
3
- import { PickerValidDate, TimeValidationError, TimezoneProps } from '../../../models';
4
- import { DefaultizedProps } from '../../models/helpers';
5
- export interface TimeComponentValidationProps<TDate extends PickerValidDate> extends Required<BaseTimeValidationProps>, TimeValidationProps<TDate>, DefaultizedProps<TimezoneProps, 'timezone'> {
6
- }
7
- export declare const validateTime: Validator<any | null, any, TimeValidationError, TimeComponentValidationProps<any>>;
@@ -1,2 +0,0 @@
1
- export declare function warnOnce(message: string | string[], gravity?: 'warning' | 'error'): void;
2
- export declare function clearWarningsCache(): void;
@@ -1,21 +0,0 @@
1
- const warnedOnceCache = new Set();
2
-
3
- // TODO move to @mui/x-internals
4
- // TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
5
- export function warnOnce(message, gravity = 'warning') {
6
- if (process.env.NODE_ENV === 'production') {
7
- return;
8
- }
9
- const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
10
- if (!warnedOnceCache.has(cleanMessage)) {
11
- warnedOnceCache.add(cleanMessage);
12
- if (gravity === 'error') {
13
- console.error(cleanMessage);
14
- } else {
15
- console.warn(cleanMessage);
16
- }
17
- }
18
- }
19
- export function clearWarningsCache() {
20
- warnedOnceCache.clear();
21
- }
@@ -1,22 +0,0 @@
1
- import * as React from 'react';
2
- import { useLocalizationContext } from "./useUtils.js";
3
- export function useValidation(props, validate, isSameError, defaultErrorState) {
4
- const {
5
- value,
6
- onError
7
- } = props;
8
- const adapter = useLocalizationContext();
9
- const previousValidationErrorRef = React.useRef(defaultErrorState);
10
- const validationError = validate({
11
- adapter,
12
- value,
13
- props
14
- });
15
- React.useEffect(() => {
16
- if (onError && !isSameError(validationError, previousValidationErrorRef.current)) {
17
- onError(validationError, value);
18
- }
19
- previousValidationErrorRef.current = validationError;
20
- }, [isSameError, onError, previousValidationErrorRef, validationError, value]);
21
- return validationError;
22
- }