@mui/x-date-pickers 6.5.0 → 6.7.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 (343) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +6 -0
  2. package/AdapterDateFns/AdapterDateFns.js +38 -19
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +6 -0
  4. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
  5. package/AdapterDayjs/AdapterDayjs.d.ts +14 -1
  6. package/AdapterDayjs/AdapterDayjs.js +143 -25
  7. package/AdapterLuxon/AdapterLuxon.d.ts +7 -1
  8. package/AdapterLuxon/AdapterLuxon.js +78 -28
  9. package/AdapterMoment/AdapterMoment.d.ts +12 -1
  10. package/AdapterMoment/AdapterMoment.js +103 -13
  11. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +4 -0
  12. package/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
  13. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +4 -0
  14. package/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
  15. package/CHANGELOG.md +150 -2
  16. package/DateCalendar/DateCalendar.js +2 -2
  17. package/DateCalendar/DayCalendar.d.ts +1 -1
  18. package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
  19. package/DateCalendar/PickersCalendarHeader.js +2 -2
  20. package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
  21. package/DateCalendar/PickersSlideTransition.d.ts +1 -1
  22. package/DateField/DateField.js +6 -0
  23. package/DateField/DateField.types.d.ts +1 -1
  24. package/DatePicker/DatePickerToolbar.js +6 -15
  25. package/DatePicker/shared.d.ts +1 -5
  26. package/DatePicker/shared.js +1 -16
  27. package/DateTimeField/DateTimeField.js +6 -0
  28. package/DateTimeField/DateTimeField.types.d.ts +1 -1
  29. package/DateTimePicker/DateTimePicker.js +19 -2
  30. package/DateTimePicker/DateTimePicker.types.d.ts +4 -3
  31. package/DateTimePicker/DateTimePickerTabs.d.ts +3 -3
  32. package/DateTimePicker/DateTimePickerTabs.js +6 -5
  33. package/DateTimePicker/DateTimePickerToolbar.d.ts +5 -4
  34. package/DateTimePicker/DateTimePickerToolbar.js +46 -22
  35. package/DateTimePicker/shared.d.ts +6 -6
  36. package/DayCalendarSkeleton/DayCalendarSkeleton.d.ts +1 -1
  37. package/DesktopDatePicker/DesktopDatePicker.js +5 -4
  38. package/DesktopDateTimePicker/DesktopDateTimePicker.js +58 -11
  39. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +10 -3
  40. package/DesktopTimePicker/DesktopTimePicker.js +7 -3
  41. package/LocalizationProvider/LocalizationProvider.js +1 -0
  42. package/MobileDatePicker/MobileDatePicker.js +3 -2
  43. package/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
  44. package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +8 -7
  45. package/MobileTimePicker/MobileTimePicker.js +5 -1
  46. package/MonthCalendar/MonthCalendar.js +2 -2
  47. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
  48. package/PickersActionBar/PickersActionBar.d.ts +2 -2
  49. package/PickersLayout/PickersLayout.d.ts +1 -1
  50. package/PickersShortcuts/PickersShortcuts.d.ts +2 -2
  51. package/README.md +5 -5
  52. package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -1
  53. package/TimeClock/Clock.d.ts +1 -1
  54. package/TimeClock/ClockNumber.d.ts +1 -1
  55. package/TimeClock/ClockNumbers.d.ts +2 -2
  56. package/TimeClock/ClockPointer.d.ts +1 -1
  57. package/TimeField/TimeField.js +6 -0
  58. package/TimeField/TimeField.types.d.ts +1 -1
  59. package/TimePicker/TimePickerToolbar.d.ts +2 -2
  60. package/TimePicker/shared.d.ts +1 -1
  61. package/YearCalendar/YearCalendar.js +2 -2
  62. package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +13 -0
  63. package/dateTimeViewRenderers/dateTimeViewRenderers.js +148 -0
  64. package/dateTimeViewRenderers/index.d.ts +2 -0
  65. package/dateTimeViewRenderers/index.js +1 -0
  66. package/dateTimeViewRenderers/package.json +6 -0
  67. package/dateViewRenderers/dateViewRenderers.d.ts +3 -2
  68. package/dateViewRenderers/dateViewRenderers.js +2 -2
  69. package/icons/index.d.ts +42 -0
  70. package/{internals/components/icons → icons}/index.js +7 -7
  71. package/icons/package.json +6 -0
  72. package/index.d.ts +1 -0
  73. package/index.js +3 -2
  74. package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.d.ts +2 -0
  75. package/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
  76. package/internals/components/DateTimeViewWrapper/index.d.ts +1 -0
  77. package/internals/components/DateTimeViewWrapper/index.js +1 -0
  78. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  79. package/internals/components/PickersModalDialog.d.ts +1 -1
  80. package/internals/components/PickersPopper.d.ts +1 -1
  81. package/internals/components/PickersToolbarButton.d.ts +1 -0
  82. package/internals/components/PickersToolbarButton.js +8 -3
  83. package/internals/constants/dimensions.d.ts +1 -0
  84. package/internals/constants/dimensions.js +2 -1
  85. package/internals/demo/DemoContainer.d.ts +2 -2
  86. package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
  87. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
  88. package/internals/hooks/useField/useField.d.ts +1 -1
  89. package/internals/hooks/useField/useField.js +8 -3
  90. package/internals/hooks/useField/useField.types.d.ts +8 -2
  91. package/internals/hooks/useField/useFieldState.d.ts +1 -1
  92. package/internals/hooks/useField/useFieldState.js +22 -2
  93. package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
  94. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
  95. package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -2
  96. package/internals/hooks/usePicker/usePickerViews.js +8 -10
  97. package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +2 -2
  98. package/internals/hooks/useViews.js +10 -9
  99. package/internals/index.d.ts +2 -1
  100. package/internals/index.js +2 -1
  101. package/internals/models/fields.d.ts +1 -1
  102. package/internals/utils/date-time-utils.d.ts +6 -0
  103. package/internals/utils/date-time-utils.js +41 -0
  104. package/internals/utils/date-utils.d.ts +8 -1
  105. package/internals/utils/date-utils.js +35 -0
  106. package/internals/utils/fields.js +1 -1
  107. package/internals/utils/getDefaultReferenceDate.d.ts +15 -0
  108. package/internals/utils/getDefaultReferenceDate.js +62 -0
  109. package/internals/utils/time-utils.d.ts +8 -2
  110. package/internals/utils/time-utils.js +28 -0
  111. package/internals/utils/validation/extractValidationProps.d.ts +1 -1
  112. package/internals/utils/valueManagers.js +21 -3
  113. package/internals/utils/views.d.ts +2 -3
  114. package/internals/utils/views.js +6 -2
  115. package/legacy/AdapterDateFns/AdapterDateFns.js +38 -19
  116. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
  117. package/legacy/AdapterDayjs/AdapterDayjs.js +147 -25
  118. package/legacy/AdapterLuxon/AdapterLuxon.js +78 -28
  119. package/legacy/AdapterMoment/AdapterMoment.js +109 -17
  120. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
  121. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
  122. package/legacy/DateCalendar/DateCalendar.js +2 -2
  123. package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
  124. package/legacy/DateField/DateField.js +6 -0
  125. package/legacy/DatePicker/DatePickerToolbar.js +6 -15
  126. package/legacy/DatePicker/shared.js +1 -15
  127. package/legacy/DateTimeField/DateTimeField.js +6 -0
  128. package/legacy/DateTimePicker/DateTimePicker.js +19 -2
  129. package/legacy/DateTimePicker/DateTimePickerTabs.js +6 -5
  130. package/legacy/DateTimePicker/DateTimePickerToolbar.js +51 -23
  131. package/legacy/DesktopDatePicker/DesktopDatePicker.js +5 -4
  132. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +59 -11
  133. package/legacy/DesktopTimePicker/DesktopTimePicker.js +7 -3
  134. package/legacy/LocalizationProvider/LocalizationProvider.js +1 -0
  135. package/legacy/MobileDatePicker/MobileDatePicker.js +3 -2
  136. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
  137. package/legacy/MobileTimePicker/MobileTimePicker.js +5 -1
  138. package/legacy/MonthCalendar/MonthCalendar.js +2 -2
  139. package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
  140. package/legacy/TimeField/TimeField.js +6 -0
  141. package/legacy/YearCalendar/YearCalendar.js +2 -2
  142. package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
  143. package/legacy/dateTimeViewRenderers/index.js +1 -0
  144. package/legacy/dateViewRenderers/dateViewRenderers.js +2 -4
  145. package/legacy/{internals/components/icons → icons}/index.js +7 -7
  146. package/legacy/index.js +3 -2
  147. package/legacy/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
  148. package/legacy/internals/components/DateTimeViewWrapper/index.js +1 -0
  149. package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  150. package/legacy/internals/components/PickersToolbarButton.js +7 -2
  151. package/legacy/internals/constants/dimensions.js +2 -1
  152. package/legacy/internals/hooks/useField/useField.js +8 -3
  153. package/legacy/internals/hooks/useField/useFieldState.js +22 -2
  154. package/legacy/internals/hooks/usePicker/usePickerViews.js +4 -4
  155. package/legacy/internals/hooks/useViews.js +10 -9
  156. package/legacy/internals/index.js +2 -1
  157. package/legacy/internals/utils/date-time-utils.js +39 -0
  158. package/legacy/internals/utils/date-utils.js +38 -0
  159. package/legacy/internals/utils/fields.js +1 -1
  160. package/legacy/internals/utils/getDefaultReferenceDate.js +64 -0
  161. package/legacy/internals/utils/time-utils.js +29 -0
  162. package/legacy/internals/utils/valueManagers.js +20 -4
  163. package/legacy/internals/utils/views.js +7 -5
  164. package/legacy/locales/deDE.js +2 -2
  165. package/legacy/locales/index.js +17 -15
  166. package/legacy/locales/roRO.js +81 -0
  167. package/legacy/locales/viVN.js +93 -0
  168. package/legacy/models/index.js +1 -0
  169. package/legacy/models/timezone.js +1 -0
  170. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +16 -1
  171. package/legacy/tests/describeGregorianAdapter/testCalculations.js +349 -79
  172. package/legacy/tests/describeGregorianAdapter/testLocalization.js +3 -3
  173. package/legacy/tests/describeValidation/testDayViewValidation.js +129 -52
  174. package/legacy/tests/describeValidation/testMinutesViewValidation.js +3 -10
  175. package/legacy/tests/describeValidation/testMonthViewValidation.js +3 -10
  176. package/legacy/tests/describeValidation/testYearViewValidation.js +3 -10
  177. package/legacy/tests/describeValue/describeValue.js +12 -5
  178. package/legacy/tests/describeValue/testControlledUnControlled.js +19 -4
  179. package/legacy/tests/describeValue/testPickerActionBar.js +12 -10
  180. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
  181. package/legacy/timeViewRenderers/timeViewRenderers.js +1 -1
  182. package/locales/deDE.js +2 -2
  183. package/locales/index.d.ts +17 -15
  184. package/locales/index.js +17 -15
  185. package/locales/roRO.d.ts +53 -0
  186. package/locales/roRO.js +63 -0
  187. package/locales/viVN.d.ts +53 -0
  188. package/locales/viVN.js +57 -0
  189. package/models/adapters.d.ts +187 -46
  190. package/models/fields.d.ts +1 -1
  191. package/models/index.d.ts +1 -0
  192. package/models/index.js +1 -0
  193. package/models/timezone.d.ts +1 -0
  194. package/models/timezone.js +1 -0
  195. package/modern/AdapterDateFns/AdapterDateFns.js +38 -19
  196. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
  197. package/modern/AdapterDayjs/AdapterDayjs.js +142 -25
  198. package/modern/AdapterLuxon/AdapterLuxon.js +77 -28
  199. package/modern/AdapterMoment/AdapterMoment.js +102 -13
  200. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
  201. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
  202. package/modern/DateCalendar/DateCalendar.js +2 -2
  203. package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
  204. package/modern/DateField/DateField.js +6 -0
  205. package/modern/DatePicker/DatePickerToolbar.js +6 -15
  206. package/modern/DatePicker/shared.js +1 -16
  207. package/modern/DateTimeField/DateTimeField.js +6 -0
  208. package/modern/DateTimePicker/DateTimePicker.js +19 -2
  209. package/modern/DateTimePicker/DateTimePickerTabs.js +6 -5
  210. package/modern/DateTimePicker/DateTimePickerToolbar.js +46 -22
  211. package/modern/DesktopDatePicker/DesktopDatePicker.js +5 -4
  212. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +57 -10
  213. package/modern/DesktopTimePicker/DesktopTimePicker.js +7 -3
  214. package/modern/LocalizationProvider/LocalizationProvider.js +1 -0
  215. package/modern/MobileDatePicker/MobileDatePicker.js +3 -2
  216. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
  217. package/modern/MobileTimePicker/MobileTimePicker.js +5 -1
  218. package/modern/MonthCalendar/MonthCalendar.js +2 -2
  219. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +4 -3
  220. package/modern/TimeField/TimeField.js +6 -0
  221. package/modern/YearCalendar/YearCalendar.js +2 -2
  222. package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +147 -0
  223. package/modern/dateTimeViewRenderers/index.js +1 -0
  224. package/modern/dateViewRenderers/dateViewRenderers.js +2 -2
  225. package/modern/{internals/components/icons → icons}/index.js +7 -7
  226. package/modern/index.js +3 -2
  227. package/modern/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +5 -0
  228. package/modern/internals/components/DateTimeViewWrapper/index.js +1 -0
  229. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  230. package/modern/internals/components/PickersToolbarButton.js +8 -3
  231. package/modern/internals/constants/dimensions.js +2 -1
  232. package/modern/internals/hooks/useField/useField.js +8 -3
  233. package/modern/internals/hooks/useField/useFieldState.js +22 -2
  234. package/modern/internals/hooks/usePicker/usePickerViews.js +8 -10
  235. package/modern/internals/hooks/useViews.js +10 -9
  236. package/modern/internals/index.js +2 -1
  237. package/modern/internals/utils/date-time-utils.js +41 -0
  238. package/modern/internals/utils/date-utils.js +35 -0
  239. package/modern/internals/utils/fields.js +1 -1
  240. package/modern/internals/utils/getDefaultReferenceDate.js +58 -0
  241. package/modern/internals/utils/time-utils.js +28 -0
  242. package/modern/internals/utils/valueManagers.js +21 -3
  243. package/modern/internals/utils/views.js +6 -2
  244. package/modern/locales/deDE.js +2 -2
  245. package/modern/locales/index.js +17 -15
  246. package/modern/locales/roRO.js +60 -0
  247. package/modern/locales/viVN.js +57 -0
  248. package/modern/models/index.js +1 -0
  249. package/modern/models/timezone.js +1 -0
  250. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
  251. package/modern/tests/describeGregorianAdapter/testCalculations.js +347 -79
  252. package/modern/tests/describeGregorianAdapter/testLocalization.js +3 -3
  253. package/modern/tests/describeValidation/testDayViewValidation.js +129 -52
  254. package/modern/tests/describeValidation/testMinutesViewValidation.js +3 -10
  255. package/modern/tests/describeValidation/testMonthViewValidation.js +3 -10
  256. package/modern/tests/describeValidation/testYearViewValidation.js +3 -10
  257. package/modern/tests/describeValue/describeValue.js +13 -4
  258. package/modern/tests/describeValue/testControlledUnControlled.js +15 -4
  259. package/modern/tests/describeValue/testPickerActionBar.js +19 -17
  260. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
  261. package/modern/timeViewRenderers/timeViewRenderers.js +1 -1
  262. package/node/AdapterDateFns/AdapterDateFns.js +38 -19
  263. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +35 -16
  264. package/node/AdapterDayjs/AdapterDayjs.js +142 -25
  265. package/node/AdapterLuxon/AdapterLuxon.js +77 -28
  266. package/node/AdapterMoment/AdapterMoment.js +102 -13
  267. package/node/AdapterMomentHijri/AdapterMomentHijri.js +30 -19
  268. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +30 -19
  269. package/node/DateCalendar/DateCalendar.js +2 -2
  270. package/node/DateCalendar/PickersCalendarHeader.js +2 -2
  271. package/node/DateField/DateField.js +6 -0
  272. package/node/DatePicker/DatePickerToolbar.js +6 -15
  273. package/node/DatePicker/shared.js +0 -17
  274. package/node/DateTimeField/DateTimeField.js +6 -0
  275. package/node/DateTimePicker/DateTimePicker.js +19 -2
  276. package/node/DateTimePicker/DateTimePickerTabs.js +6 -5
  277. package/node/DateTimePicker/DateTimePickerToolbar.js +46 -22
  278. package/node/DesktopDatePicker/DesktopDatePicker.js +4 -3
  279. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +59 -12
  280. package/node/DesktopTimePicker/DesktopTimePicker.js +9 -5
  281. package/node/LocalizationProvider/LocalizationProvider.js +1 -0
  282. package/node/MobileDatePicker/MobileDatePicker.js +2 -1
  283. package/node/MobileDateTimePicker/MobileDateTimePicker.js +7 -3
  284. package/node/MobileTimePicker/MobileTimePicker.js +7 -3
  285. package/node/MonthCalendar/MonthCalendar.js +2 -2
  286. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -2
  287. package/node/TimeField/TimeField.js +6 -0
  288. package/node/YearCalendar/YearCalendar.js +2 -2
  289. package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +156 -0
  290. package/node/dateTimeViewRenderers/index.js +12 -0
  291. package/node/dateViewRenderers/dateViewRenderers.js +3 -3
  292. package/node/{internals/components/icons → icons}/index.js +15 -15
  293. package/node/index.js +13 -1
  294. package/node/internals/components/DateTimeViewWrapper/DateTimeViewWrapper.js +12 -0
  295. package/node/internals/components/DateTimeViewWrapper/index.js +12 -0
  296. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  297. package/node/internals/components/PickersToolbarButton.js +8 -3
  298. package/node/internals/constants/dimensions.js +4 -2
  299. package/node/internals/hooks/useField/useField.js +8 -3
  300. package/node/internals/hooks/useField/useFieldState.js +22 -2
  301. package/node/internals/hooks/usePicker/usePickerViews.js +8 -10
  302. package/node/internals/hooks/useViews.js +10 -9
  303. package/node/internals/index.js +13 -0
  304. package/node/internals/utils/date-time-utils.js +49 -0
  305. package/node/internals/utils/date-utils.js +40 -2
  306. package/node/internals/utils/fields.js +1 -1
  307. package/node/internals/utils/getDefaultReferenceDate.js +66 -0
  308. package/node/internals/utils/time-utils.js +32 -2
  309. package/node/internals/utils/valueManagers.js +21 -2
  310. package/node/internals/utils/views.js +8 -5
  311. package/node/locales/deDE.js +2 -2
  312. package/node/locales/index.js +119 -97
  313. package/node/locales/roRO.js +67 -0
  314. package/node/locales/viVN.js +64 -0
  315. package/node/models/index.js +11 -0
  316. package/node/models/timezone.js +5 -0
  317. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +13 -1
  318. package/node/tests/describeGregorianAdapter/testCalculations.js +347 -79
  319. package/node/tests/describeGregorianAdapter/testLocalization.js +3 -4
  320. package/node/tests/describeValidation/testDayViewValidation.js +129 -52
  321. package/node/tests/describeValidation/testMinutesViewValidation.js +3 -10
  322. package/node/tests/describeValidation/testMonthViewValidation.js +3 -10
  323. package/node/tests/describeValidation/testYearViewValidation.js +3 -10
  324. package/node/tests/describeValue/describeValue.js +13 -4
  325. package/node/tests/describeValue/testControlledUnControlled.js +15 -4
  326. package/node/tests/describeValue/testPickerActionBar.js +19 -16
  327. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +9 -6
  328. package/node/timeViewRenderers/timeViewRenderers.js +1 -1
  329. package/package.json +4 -4
  330. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +14 -1
  331. package/tests/describeGregorianAdapter/testCalculations.js +347 -79
  332. package/tests/describeGregorianAdapter/testLocalization.js +3 -3
  333. package/tests/describeValidation/testDayViewValidation.js +129 -52
  334. package/tests/describeValidation/testMinutesViewValidation.js +3 -10
  335. package/tests/describeValidation/testMonthViewValidation.js +3 -10
  336. package/tests/describeValidation/testYearViewValidation.js +3 -10
  337. package/tests/describeValue/describeValue.js +13 -4
  338. package/tests/describeValue/testControlledUnControlled.js +15 -4
  339. package/tests/describeValue/testPickerActionBar.js +19 -17
  340. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +10 -7
  341. package/timeViewRenderers/timeViewRenderers.d.ts +4 -4
  342. package/timeViewRenderers/timeViewRenderers.js +1 -1
  343. package/internals/components/icons/index.d.ts +0 -42
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["align", "className", "selected", "typographyClassName", "value", "variant"];
3
+ const _excluded = ["align", "className", "selected", "typographyClassName", "value", "variant", "width"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import Button from '@mui/material/Button';
@@ -38,7 +38,8 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
38
38
  selected,
39
39
  typographyClassName,
40
40
  value,
41
- variant
41
+ variant,
42
+ width
42
43
  } = props,
43
44
  other = _objectWithoutPropertiesLoose(props, _excluded);
44
45
  const classes = useUtilityClasses(props);
@@ -46,7 +47,11 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
46
47
  variant: "text",
47
48
  ref: ref,
48
49
  className: clsx(className, classes.root)
49
- }, other, {
50
+ }, width ? {
51
+ sx: {
52
+ width
53
+ }
54
+ } : {}, other, {
50
55
  children: /*#__PURE__*/_jsx(PickersToolbarText, {
51
56
  align: align,
52
57
  className: typographyClassName,
@@ -3,3 +3,4 @@ export declare const DAY_MARGIN = 2;
3
3
  export declare const DIALOG_WIDTH = 320;
4
4
  export declare const VIEW_HEIGHT = 358;
5
5
  export declare const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
6
+ export declare const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
@@ -2,4 +2,5 @@ export const DAY_SIZE = 36;
2
2
  export const DAY_MARGIN = 2;
3
3
  export const DIALOG_WIDTH = 320;
4
4
  export const VIEW_HEIGHT = 358;
5
- export const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
5
+ export const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
6
+ export const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
@@ -10,6 +10,6 @@ interface DemoItemProps {
10
10
  component?: string;
11
11
  children: React.ReactNode;
12
12
  }
13
- export declare function DemoItem(props: DemoItemProps): JSX.Element;
14
- export declare function DemoContainer(props: DemoGridProps): JSX.Element;
13
+ export declare function DemoItem(props: DemoItemProps): React.JSX.Element;
14
+ export declare function DemoContainer(props: DemoGridProps): React.JSX.Element;
15
15
  export {};
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { UseDesktopPickerParams, UseDesktopPickerProps } from './useDesktopPicker.types';
3
3
  import { DateOrTimeViewWithMeridiem } from '../../models';
4
4
  /**
@@ -8,5 +8,5 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
8
8
  * - DesktopTimePicker
9
9
  */
10
10
  export declare const useDesktopPicker: <TDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseDesktopPickerProps<TDate, TView, any, TExternalProps>>({ props, getOpenDialogAriaText, ...pickerParams }: UseDesktopPickerParams<TDate, TView, TExternalProps>) => {
11
- renderPicker: () => JSX.Element;
11
+ renderPicker: () => React.JSX.Element;
12
12
  };
@@ -16,7 +16,7 @@ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeV
16
16
  /**
17
17
  * Component used to enter the date with the keyboard.
18
18
  */
19
- Field: React.ElementType<BaseSingleInputFieldProps<TDate | null, FieldSection, any>>;
19
+ Field: React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, any>>;
20
20
  /**
21
21
  * Form control with an input to render the value inside the default field.
22
22
  * Receives the same props as `@mui/material/TextField`.
@@ -41,7 +41,7 @@ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeV
41
41
  export interface UseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView>, Pick<PickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, 'toolbar'> {
42
42
  }
43
43
  export interface ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView> {
44
- field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, any, FieldSection, any, any, any>>;
44
+ field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, any, FieldSection, any, any, any>>;
45
45
  textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
46
46
  inputAdornment?: Partial<InputAdornmentProps>;
47
47
  openPickerButton?: SlotComponentProps<typeof IconButton, {}, UseDesktopPickerProps<TDate, any, any, any>>;
@@ -1,3 +1,3 @@
1
1
  import { UseFieldParams, UseFieldResponse, UseFieldForwardedProps, UseFieldInternalProps } from './useField.types';
2
2
  import { FieldSection } from '../../../models';
3
- export declare const useField: <TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any>>(params: UseFieldParams<TValue, TDate, TSection, TForwardedProps, TInternalProps>) => UseFieldResponse<TForwardedProps>;
3
+ export declare const useField: <TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any, any>>(params: UseFieldParams<TValue, TDate, TSection, TForwardedProps, TInternalProps>) => UseFieldResponse<TForwardedProps>;
@@ -159,7 +159,7 @@ export const useField = params => {
159
159
  return;
160
160
  }
161
161
  let keyPressed;
162
- if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1) {
162
+ if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1 && cleanValueStr.length === 1) {
163
163
  keyPressed = cleanValueStr;
164
164
  } else {
165
165
  const prevValueStr = cleanString(fieldValueManager.getValueStrFromSections(state.sections, isRTL));
@@ -182,7 +182,7 @@ export const useField = params => {
182
182
 
183
183
  // The active section being selected, the browser has replaced its value with the key pressed by the user.
184
184
  const activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;
185
- keyPressed = cleanValueStr.slice(activeSection.start, activeSectionEndRelativeToNewValue);
185
+ keyPressed = cleanValueStr.slice(activeSection.start + cleanString(activeSection.startSeparator || '').length, activeSectionEndRelativeToNewValue);
186
186
  }
187
187
  if (isAndroid() && keyPressed.length === 0) {
188
188
  setTempAndroidValueStr(valueStr);
@@ -298,7 +298,12 @@ export const useField = params => {
298
298
  if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
299
299
  // Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321
300
300
  const currentScrollTop = inputRef.current.scrollTop;
301
- inputRef.current.setSelectionRange(selectionStart, selectionEnd);
301
+ // On multi input range pickers we want to update selection range only for the active input
302
+ // This helps avoiding the focus jumping on Safari https://github.com/mui/mui-x/issues/9003
303
+ // because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425
304
+ if (inputRef.current && inputRef.current === getActiveElement(document)) {
305
+ inputRef.current.setSelectionRange(selectionStart, selectionEnd);
306
+ }
302
307
  // Even reading this variable seems to do the trick, but also setting it just to make use of it
303
308
  inputRef.current.scrollTop = currentScrollTop;
304
309
  }
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, FieldSectionContentType, FieldValueType } from '../../../models';
3
3
  import type { PickerValueManager } from '../usePicker';
4
4
  import { InferError, Validator } from '../useValidation';
5
- export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any>> {
5
+ export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any, any>> {
6
6
  inputRef?: React.Ref<HTMLInputElement>;
7
7
  forwardedProps: TForwardedProps;
8
8
  internalProps: TInternalProps;
@@ -11,7 +11,7 @@ export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TF
11
11
  validator: Validator<TValue, TDate, InferError<TInternalProps>, UseFieldValidationProps<TValue, TInternalProps>>;
12
12
  valueType: FieldValueType;
13
13
  }
14
- export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TError> {
14
+ export interface UseFieldInternalProps<TValue, TDate, TSection extends FieldSection, TError> {
15
15
  /**
16
16
  * The selected value.
17
17
  * Used when the component is controlled.
@@ -21,6 +21,12 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
21
21
  * The default value. Use when the component is not controlled.
22
22
  */
23
23
  defaultValue?: TValue;
24
+ /**
25
+ * The date used to generate a part of the date-time that is not present in the format when both `value` and `defaultValue` are not present.
26
+ * For example, on time fields it will be used to determine the date to set.
27
+ * @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
28
+ */
29
+ referenceDate?: TDate;
24
30
  /**
25
31
  * Callback fired when the value changes.
26
32
  * @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
@@ -14,7 +14,7 @@ export interface UpdateSectionValueParams<TSection extends FieldSection> {
14
14
  */
15
15
  shouldGoToNextSection: boolean;
16
16
  }
17
- export declare const useFieldState: <TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any>>(params: UseFieldParams<TValue, TDate, TSection, TForwardedProps, TInternalProps>) => {
17
+ export declare const useFieldState: <TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any, any>>(params: UseFieldParams<TValue, TDate, TSection, TForwardedProps, TInternalProps>) => {
18
18
  state: UseFieldState<TValue, TSection>;
19
19
  selectedSectionIndexes: FieldSelectedSectionsIndexes | null;
20
20
  setSelectedSections: (newSelectedSections: FieldSelectedSections) => void;
@@ -4,6 +4,7 @@ import useControlled from '@mui/utils/useControlled';
4
4
  import { useTheme } from '@mui/material/styles';
5
5
  import { useUtils, useLocaleText, useLocalizationContext } from '../useUtils';
6
6
  import { addPositionPropertiesToSections, splitFormatIntoSections, clampDaySectionIfPossible, mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections } from './useField.utils';
7
+ import { getSectionTypeGranularity } from '../../utils/getDefaultReferenceDate';
7
8
  export const useFieldState = params => {
8
9
  var _ref;
9
10
  const utils = useUtils();
@@ -20,6 +21,7 @@ export const useFieldState = params => {
20
21
  internalProps: {
21
22
  value: valueProp,
22
23
  defaultValue,
24
+ referenceDate: referenceDateProp,
23
25
  onChange,
24
26
  format,
25
27
  formatDensity = 'dense',
@@ -36,12 +38,24 @@ export const useFieldState = params => {
36
38
  const [state, setState] = React.useState(() => {
37
39
  const sections = getSectionsFromValue(valueFromTheOutside);
38
40
  validateSections(sections, valueType);
39
- return {
41
+ const stateWithoutReferenceDate = {
40
42
  sections,
41
43
  value: valueFromTheOutside,
42
- referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, valueManager.getTodayValue(utils, valueType)),
44
+ referenceValue: valueManager.emptyValue,
43
45
  tempValueStrAndroid: null
44
46
  };
47
+ const granularity = getSectionTypeGranularity(sections);
48
+ const referenceValue = valueManager.getInitialReferenceValue({
49
+ referenceDate: referenceDateProp,
50
+ value: valueFromTheOutside,
51
+ valueType,
52
+ utils,
53
+ props: internalProps,
54
+ granularity
55
+ });
56
+ return _extends({}, stateWithoutReferenceDate, {
57
+ referenceValue
58
+ });
45
59
  });
46
60
  const [selectedSections, innerSetSelectedSections] = useControlled({
47
61
  controlled: selectedSectionsProp,
@@ -241,7 +255,13 @@ export const useFieldState = params => {
241
255
  tempValueStrAndroid
242
256
  }));
243
257
  React.useEffect(() => {
258
+ let shouldUpdate = false;
244
259
  if (!valueManager.areValuesEqual(utils, state.value, valueFromTheOutside)) {
260
+ shouldUpdate = true;
261
+ } else {
262
+ shouldUpdate = valueManager.getTimezone(utils, state.value) !== valueManager.getTimezone(utils, valueFromTheOutside);
263
+ }
264
+ if (shouldUpdate) {
245
265
  setState(prevState => _extends({}, prevState, {
246
266
  value: valueFromTheOutside,
247
267
  referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, prevState.referenceValue),
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { UseMobilePickerParams, UseMobilePickerProps } from './useMobilePicker.types';
3
3
  import { DateOrTimeViewWithMeridiem } from '../../models';
4
4
  /**
@@ -8,5 +8,5 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
8
8
  * - MobileTimePicker
9
9
  */
10
10
  export declare const useMobilePicker: <TDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseMobilePickerProps<TDate, TView, any, TExternalProps>>({ props, getOpenDialogAriaText, ...pickerParams }: UseMobilePickerParams<TDate, TView, TExternalProps>) => {
11
- renderPicker: () => JSX.Element;
11
+ renderPicker: () => React.JSX.Element;
12
12
  };
@@ -14,7 +14,7 @@ export interface UseMobilePickerSlotsComponent<TDate, TView extends DateOrTimeVi
14
14
  /**
15
15
  * Component used to enter the date with the keyboard.
16
16
  */
17
- Field: React.ElementType<BaseSingleInputFieldProps<TDate | null, FieldSection, any>>;
17
+ Field: React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, any>>;
18
18
  /**
19
19
  * Form control with an input to render the value inside the default field.
20
20
  * Receives the same props as `@mui/material/TextField`.
@@ -23,7 +23,7 @@ export interface UseMobilePickerSlotsComponent<TDate, TView extends DateOrTimeVi
23
23
  TextField?: React.ElementType<TextFieldProps>;
24
24
  }
25
25
  export interface ExportedUseMobilePickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends PickersModalDialogSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView> {
26
- field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, any, FieldSection, any, any, any>>;
26
+ field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, any, FieldSection, any, any, any>>;
27
27
  textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
28
28
  }
29
29
  export interface UseMobilePickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends ExportedUseMobilePickerSlotsComponentsProps<TDate, TView>, Pick<PickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, 'toolbar'> {
@@ -3,6 +3,7 @@ import { InferError, Validator } from '../useValidation';
3
3
  import { UseFieldValidationProps } from '../useField/useField.types';
4
4
  import { WrapperVariant } from '../../models/common';
5
5
  import { FieldSection, FieldSelectedSections, FieldValueType, MuiPickersAdapter } from '../../../models';
6
+ import { GetDefaultReferenceDateProps } from '../../utils/getDefaultReferenceDate';
6
7
  export interface PickerValueManager<TValue, TDate, TError> {
7
8
  /**
8
9
  * Determines if two values are equal.
@@ -25,6 +26,26 @@ export interface PickerValueManager<TValue, TDate, TError> {
25
26
  * @returns {TValue} The value to set when clicking the "Today" button.
26
27
  */
27
28
  getTodayValue: (utils: MuiPickersAdapter<TDate>, valueType: FieldValueType) => TValue;
29
+ /**
30
+ * @template TDate, TValue
31
+ * Method returning the reference value to use when mounting the component.
32
+ * @param {object} params The params of the method.
33
+ * @param {TDate | undefined} params.referenceDate The referenceDate provided by the user.
34
+ * @param {TValue} params.value The value provided by the user.
35
+ * @param {GetDefaultReferenceDateProps<TDate>} params.props The validation props needed to compute the reference value.
36
+ * @param {MuiPickersAdapter<TDate>} params.utils The adapter.
37
+ * @param {FieldValueType} params.valueType The type of the value being edited.
38
+ * @param {granularity} params.granularity The granularity of the selection possible on this component.
39
+ * @returns {TValue} The reference value to use for non-provided dates.
40
+ */
41
+ getInitialReferenceValue: (params: {
42
+ referenceDate: TDate | undefined;
43
+ value: TValue;
44
+ props: GetDefaultReferenceDateProps<TDate>;
45
+ utils: MuiPickersAdapter<TDate>;
46
+ valueType: FieldValueType;
47
+ granularity: number;
48
+ }) => TValue;
28
49
  /**
29
50
  * Method parsing the input value to replace all invalid dates by `null`.
30
51
  * @template TDate, TValue
@@ -61,6 +82,15 @@ export interface PickerValueManager<TValue, TDate, TError> {
61
82
  * The value identifying no error, used to initialise the error state.
62
83
  */
63
84
  defaultErrorState: TError;
85
+ /**
86
+ * Return the timezone of the date inside a value.
87
+ * Throw an error on range picker if both values don't have the same timezone.
88
+ @template TValue, TDate
89
+ @param {MuiPickersAdapter<TDate>} utils The utils to manipulate the date.
90
+ @param {TValue} value The current value.
91
+ @returns {string | null} The timezone of the current value.
92
+ */
93
+ getTimezone: (utils: MuiPickersAdapter<TDate>, value: TValue) => string | null;
64
94
  }
65
95
  export interface PickerChangeHandlerContext<TError> {
66
96
  validationError: TError;
@@ -164,7 +194,7 @@ export interface UsePickerValueBaseProps<TValue, TError> {
164
194
  /**
165
195
  * Props used to handle the value of non-static pickers.
166
196
  */
167
- export interface UsePickerValueNonStaticProps<TValue, TSection extends FieldSection> extends Pick<UseFieldInternalProps<TValue, TSection, unknown>, 'selectedSections' | 'onSelectedSectionsChange'> {
197
+ export interface UsePickerValueNonStaticProps<TValue, TSection extends FieldSection> extends Pick<UseFieldInternalProps<TValue, unknown, TSection, unknown>, 'selectedSections' | 'onSelectedSectionsChange'> {
168
198
  /**
169
199
  * If `true`, the popover or modal will close after submitting the full date.
170
200
  * @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
@@ -207,7 +237,7 @@ export interface UsePickerValueActions {
207
237
  onOpen: () => void;
208
238
  onClose: () => void;
209
239
  }
210
- export type UsePickerValueFieldResponse<TValue, TSection extends FieldSection, TError> = Required<Pick<UseFieldInternalProps<TValue, TSection, TError>, 'value' | 'onChange' | 'selectedSections' | 'onSelectedSectionsChange'>>;
240
+ export type UsePickerValueFieldResponse<TValue, TSection extends FieldSection, TError> = Required<Pick<UseFieldInternalProps<TValue, unknown, TSection, TError>, 'value' | 'onChange' | 'selectedSections' | 'onSelectedSectionsChange'>>;
211
241
  /**
212
242
  * Props passed to `usePickerViews`.
213
243
  */
@@ -82,15 +82,12 @@ export const usePickerViews = ({
82
82
  hasUIView: false,
83
83
  viewModeLookup: {}
84
84
  }), [disableOpenPicker, viewRenderers, views]);
85
- const hasMultipleUITimeView = React.useMemo(() => {
86
- const numberUITimeViews = views.reduce((acc, viewForReduce) => {
87
- if (viewRenderers[viewForReduce] != null && isTimeView(viewForReduce)) {
88
- return acc + 1;
89
- }
90
- return acc;
91
- }, 0);
92
- return numberUITimeViews > 1;
93
- }, [viewRenderers, views]);
85
+ const timeViewsCount = React.useMemo(() => views.reduce((acc, viewForReduce) => {
86
+ if (viewRenderers[viewForReduce] != null && isTimeView(viewForReduce)) {
87
+ return acc + 1;
88
+ }
89
+ return acc;
90
+ }, 0), [viewRenderers, views]);
94
91
  const currentViewMode = viewModeLookup[view];
95
92
  const shouldRestoreFocus = useEventCallback(() => currentViewMode === 'UI');
96
93
  const [popperView, setPopperView] = React.useState(currentViewMode === 'UI' ? view : null);
@@ -152,7 +149,8 @@ export const usePickerViews = ({
152
149
  onViewChange: setView,
153
150
  focusedView,
154
151
  onFocusedViewChange: setFocusedView,
155
- showViewSwitcher: hasMultipleUITimeView
152
+ showViewSwitcher: timeViewsCount > 1,
153
+ timeViewsCount
156
154
  }));
157
155
  }
158
156
  };
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { UseStaticPickerParams, UseStaticPickerProps } from './useStaticPicker.types';
3
3
  import { DateOrTimeViewWithMeridiem } from '../../models';
4
4
  /**
@@ -8,5 +8,5 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
8
8
  * - StaticTimePicker
9
9
  */
10
10
  export declare const useStaticPicker: <TDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticPickerProps<TDate, TView, any, TExternalProps>>({ props, ref, ...pickerParams }: UseStaticPickerParams<TDate, TView, TExternalProps>) => {
11
- renderPicker: () => JSX.Element;
11
+ renderPicker: () => React.JSX.Element;
12
12
  };
@@ -52,15 +52,6 @@ export function useViews({
52
52
  const viewIndex = views.indexOf(view);
53
53
  const previousView = (_views = views[viewIndex - 1]) != null ? _views : null;
54
54
  const nextView = (_views2 = views[viewIndex + 1]) != null ? _views2 : null;
55
- const handleChangeView = useEventCallback(newView => {
56
- if (newView === view) {
57
- return;
58
- }
59
- setView(newView);
60
- if (onViewChange) {
61
- onViewChange(newView);
62
- }
63
- });
64
55
  const handleFocusedViewChange = useEventCallback((viewToFocus, hasFocus) => {
65
56
  if (hasFocus) {
66
57
  // Focus event
@@ -73,6 +64,16 @@ export function useViews({
73
64
 
74
65
  onFocusedViewChange == null ? void 0 : onFocusedViewChange(viewToFocus, hasFocus);
75
66
  });
67
+ const handleChangeView = useEventCallback(newView => {
68
+ if (newView === view) {
69
+ return;
70
+ }
71
+ setView(newView);
72
+ handleFocusedViewChange(newView, true);
73
+ if (onViewChange) {
74
+ onViewChange(newView);
75
+ }
76
+ });
76
77
  const goToNextView = useEventCallback(() => {
77
78
  if (nextView) {
78
79
  handleChangeView(nextView);
@@ -42,8 +42,9 @@ export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/
42
42
  export type { DefaultizedProps, MakeOptional } from './models/helpers';
43
43
  export type { WrapperVariant } from './models/common';
44
44
  export type { BaseDateValidationProps, BaseTimeValidationProps, TimeValidationProps, MonthValidationProps, YearValidationProps, DayValidationProps, DateTimeValidationProps, } from './models/validation';
45
- export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
45
+ export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, } from './utils/date-utils';
46
46
  export { splitFieldInternalAndForwardedProps } from './utils/fields';
47
+ export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
47
48
  export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, } from './utils/utils';
48
49
  export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
49
50
  export { extractValidationProps } from './utils/validation/extractValidationProps';
@@ -15,8 +15,9 @@ export { useStaticPicker } from './hooks/useStaticPicker';
15
15
  export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
16
16
  export { useValidation } from './hooks/useValidation';
17
17
  export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
18
- export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
18
+ export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate } from './utils/date-utils';
19
19
  export { splitFieldInternalAndForwardedProps } from './utils/fields';
20
+ export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
20
21
  export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
21
22
  export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
22
23
  export { extractValidationProps } from './utils/validation/extractValidationProps';
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { TextFieldProps } from '@mui/material/TextField';
3
3
  import type { UseFieldInternalProps } from '../hooks/useField';
4
4
  import type { FieldSection } from '../../models';
5
- export interface BaseFieldProps<TValue, TSection extends FieldSection, TError> extends Omit<UseFieldInternalProps<TValue, TSection, TError>, 'format'> {
5
+ export interface BaseFieldProps<TValue, TDate, TSection extends FieldSection, TError> extends Omit<UseFieldInternalProps<TValue, TDate, TSection, TError>, 'format'> {
6
6
  className?: string;
7
7
  format?: string;
8
8
  disabled?: boolean;
@@ -0,0 +1,6 @@
1
+ import { DateOrTimeView, MuiPickersAdapter } from '../../models';
2
+ export declare const resolveDateTimeFormat: (utils: MuiPickersAdapter<any>, { views, format, ...other }: {
3
+ format?: string | undefined;
4
+ views: readonly DateOrTimeView[];
5
+ ampm: boolean;
6
+ }) => string;
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["views", "format"];
4
+ import { resolveTimeFormat, isTimeView } from './time-utils';
5
+ import { resolveDateFormat } from './date-utils';
6
+ export const resolveDateTimeFormat = (utils, _ref) => {
7
+ let {
8
+ views,
9
+ format
10
+ } = _ref,
11
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
12
+ if (format) {
13
+ return format;
14
+ }
15
+ const dateViews = [];
16
+ const timeViews = [];
17
+ views.forEach(view => {
18
+ if (isTimeView(view)) {
19
+ timeViews.push(view);
20
+ } else {
21
+ dateViews.push(view);
22
+ }
23
+ });
24
+ if (timeViews.length === 0) {
25
+ return resolveDateFormat(utils, _extends({
26
+ views: dateViews
27
+ }, other), false);
28
+ }
29
+ if (dateViews.length === 0) {
30
+ return resolveTimeFormat(utils, _extends({
31
+ views: timeViews
32
+ }, other));
33
+ }
34
+ const timeFormat = resolveTimeFormat(utils, _extends({
35
+ views: timeViews
36
+ }, other));
37
+ const dateFormat = resolveDateFormat(utils, _extends({
38
+ views: dateViews
39
+ }, other), false);
40
+ return `${dateFormat} ${timeFormat}`;
41
+ };
@@ -1,4 +1,5 @@
1
- import { MuiPickersAdapter } from '../../models';
1
+ import { DateView, FieldValueType, MuiPickersAdapter } from '../../models';
2
+ import { DateOrTimeViewWithMeridiem } from '../models';
2
3
  interface FindClosestDateParams<TDate> {
3
4
  date: TDate;
4
5
  disableFuture?: boolean;
@@ -15,4 +16,10 @@ export declare const applyDefaultDate: <TDate>(utils: MuiPickersAdapter<TDate, a
15
16
  export declare const areDatesEqual: <TDate>(utils: MuiPickersAdapter<TDate, any>, a: TDate, b: TDate) => boolean;
16
17
  export declare const getMonthsInYear: <TDate>(utils: MuiPickersAdapter<TDate, any>, year: TDate) => TDate[];
17
18
  export declare const mergeDateAndTime: <TDate>(utils: MuiPickersAdapter<TDate, any>, dateParam: TDate, timeParam: TDate) => TDate;
19
+ export declare const getTodayDate: <TDate>(utils: MuiPickersAdapter<TDate, any>, valueType: FieldValueType) => TDate;
20
+ export declare const isDatePickerView: (view: DateOrTimeViewWithMeridiem) => view is DateView;
21
+ export declare const resolveDateFormat: (utils: MuiPickersAdapter<any>, { format, views }: {
22
+ format?: string | undefined;
23
+ views: readonly DateView[];
24
+ }, isInToolbar: boolean) => string;
18
25
  export {};
@@ -1,3 +1,4 @@
1
+ import { areViewsEqual } from './views';
1
2
  export const findClosestEnabledDate = ({
2
3
  date,
3
4
  disableFuture,
@@ -85,4 +86,38 @@ export const mergeDateAndTime = (utils, dateParam, timeParam) => {
85
86
  mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
86
87
  mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
87
88
  return mergedDate;
89
+ };
90
+ export const getTodayDate = (utils, valueType) => valueType === 'date' ? utils.startOfDay(utils.date()) : utils.date();
91
+ const dateViews = ['year', 'month', 'day'];
92
+ export const isDatePickerView = view => dateViews.includes(view);
93
+ export const resolveDateFormat = (utils, {
94
+ format,
95
+ views
96
+ }, isInToolbar) => {
97
+ if (format != null) {
98
+ return format;
99
+ }
100
+ const formats = utils.formats;
101
+ if (areViewsEqual(views, ['year'])) {
102
+ return formats.year;
103
+ }
104
+ if (areViewsEqual(views, ['month'])) {
105
+ return formats.month;
106
+ }
107
+ if (areViewsEqual(views, ['day'])) {
108
+ return formats.dayOfMonth;
109
+ }
110
+ if (areViewsEqual(views, ['month', 'year'])) {
111
+ return `${formats.month} ${formats.year}`;
112
+ }
113
+ if (areViewsEqual(views, ['day', 'month'])) {
114
+ return `${formats.month} ${formats.dayOfMonth}`;
115
+ }
116
+ if (isInToolbar) {
117
+ // Little localization hack (Google is doing the same for android native pickers):
118
+ // For english localization it is convenient to include weekday into the date "Mon, Jun 1".
119
+ // For other locales using strings like "June 1", without weekday.
120
+ return /en/.test(utils.getCurrentLocaleCode()) ? formats.normalDateWithWeekday : formats.normalDate;
121
+ }
122
+ return formats.keyboardDate;
88
123
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from './validation/extractValidationProps';
3
- const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'format', 'formatDensity', 'onChange', 'readOnly', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef'];
3
+ const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'readOnly', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef'];
4
4
  export const splitFieldInternalAndForwardedProps = (props, valueType) => {
5
5
  const forwardedProps = _extends({}, props);
6
6
  const internalProps = {};
@@ -0,0 +1,15 @@
1
+ import { FieldSection, FieldValueType, MuiPickersAdapter } from '../../models';
2
+ export interface GetDefaultReferenceDateProps<TDate> {
3
+ maxDate?: TDate;
4
+ minDate?: TDate;
5
+ minTime?: TDate;
6
+ maxTime?: TDate;
7
+ disableIgnoringDatePartForTimeValidation?: boolean;
8
+ }
9
+ export declare const getSectionTypeGranularity: (sections: FieldSection[]) => number;
10
+ export declare const getDefaultReferenceDate: <TDate>({ props, utils, valueType, granularity, }: {
11
+ props: GetDefaultReferenceDateProps<TDate>;
12
+ utils: MuiPickersAdapter<TDate, any>;
13
+ valueType: FieldValueType;
14
+ granularity: number;
15
+ }) => TDate;