@mui/x-date-pickers 6.14.0 → 6.16.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 (432) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/DateCalendar/DateCalendar.js +6 -2
  3. package/DateCalendar/DateCalendar.types.d.ts +1 -1
  4. package/DateCalendar/DayCalendar.d.ts +6 -5
  5. package/DateCalendar/DayCalendar.js +18 -6
  6. package/DateCalendar/dayCalendarClasses.d.ts +2 -0
  7. package/DateCalendar/dayCalendarClasses.js +1 -1
  8. package/DateField/DateField.js +32 -4
  9. package/DateField/DateField.types.d.ts +3 -2
  10. package/DatePicker/DatePicker.js +6 -2
  11. package/DateTimeField/DateTimeField.js +32 -4
  12. package/DateTimeField/DateTimeField.types.d.ts +3 -2
  13. package/DateTimePicker/DateTimePicker.js +6 -2
  14. package/DateTimePicker/DateTimePickerToolbar.js +1 -0
  15. package/DesktopDatePicker/DesktopDatePicker.js +6 -2
  16. package/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  17. package/MobileDatePicker/MobileDatePicker.js +6 -2
  18. package/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  19. package/StaticDatePicker/StaticDatePicker.js +6 -2
  20. package/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  21. package/TimeField/TimeField.js +29 -4
  22. package/TimeField/TimeField.types.d.ts +3 -2
  23. package/TimePicker/TimePickerToolbar.js +1 -0
  24. package/hooks/index.d.ts +1 -0
  25. package/hooks/index.js +1 -0
  26. package/hooks/package.json +6 -0
  27. package/hooks/useClearableField.d.ts +25 -0
  28. package/hooks/useClearableField.js +79 -0
  29. package/icons/index.d.ts +6 -0
  30. package/icons/index.js +8 -1
  31. package/index.d.ts +1 -0
  32. package/index.js +3 -2
  33. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  34. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -2
  35. package/internals/hooks/useField/index.d.ts +1 -1
  36. package/internals/hooks/useField/useField.js +24 -6
  37. package/internals/hooks/useField/useField.types.d.ts +31 -1
  38. package/internals/hooks/useField/useField.utils.js +8 -3
  39. package/internals/index.d.ts +1 -1
  40. package/internals/models/props/toolbar.d.ts +3 -0
  41. package/internals/models/validation.d.ts +3 -0
  42. package/internals/utils/date-utils.d.ts +1 -0
  43. package/internals/utils/date-utils.js +4 -0
  44. package/legacy/DateCalendar/DateCalendar.js +6 -2
  45. package/legacy/DateCalendar/DayCalendar.js +22 -9
  46. package/legacy/DateCalendar/dayCalendarClasses.js +1 -1
  47. package/legacy/DateField/DateField.js +30 -3
  48. package/legacy/DatePicker/DatePicker.js +6 -2
  49. package/legacy/DateTimeField/DateTimeField.js +30 -3
  50. package/legacy/DateTimePicker/DateTimePicker.js +6 -2
  51. package/legacy/DateTimePicker/DateTimePickerToolbar.js +1 -0
  52. package/legacy/DesktopDatePicker/DesktopDatePicker.js +6 -2
  53. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  54. package/legacy/MobileDatePicker/MobileDatePicker.js +6 -2
  55. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  56. package/legacy/StaticDatePicker/StaticDatePicker.js +6 -2
  57. package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  58. package/legacy/TimeField/TimeField.js +27 -3
  59. package/legacy/TimePicker/TimePickerToolbar.js +1 -0
  60. package/legacy/hooks/index.js +1 -0
  61. package/legacy/hooks/useClearableField.js +80 -0
  62. package/legacy/icons/index.js +8 -1
  63. package/legacy/index.js +3 -2
  64. package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  65. package/legacy/internals/hooks/useField/useField.js +28 -7
  66. package/legacy/internals/hooks/useField/useField.utils.js +16 -8
  67. package/legacy/internals/utils/date-utils.js +6 -0
  68. package/legacy/locales/beBY.js +2 -0
  69. package/legacy/locales/caES.js +2 -0
  70. package/legacy/locales/csCZ.js +2 -0
  71. package/legacy/locales/daDK.js +2 -0
  72. package/legacy/locales/deDE.js +2 -0
  73. package/legacy/locales/elGR.js +2 -0
  74. package/legacy/locales/enUS.js +1 -0
  75. package/legacy/locales/esES.js +2 -0
  76. package/legacy/locales/faIR.js +2 -0
  77. package/legacy/locales/fiFI.js +27 -11
  78. package/legacy/locales/frFR.js +2 -0
  79. package/legacy/locales/heIL.js +2 -0
  80. package/legacy/locales/huHU.js +1 -0
  81. package/legacy/locales/isIS.js +2 -0
  82. package/legacy/locales/itIT.js +2 -0
  83. package/legacy/locales/jaJP.js +2 -0
  84. package/legacy/locales/koKR.js +2 -0
  85. package/legacy/locales/kzKZ.js +2 -0
  86. package/legacy/locales/nbNO.js +2 -0
  87. package/legacy/locales/nlNL.js +2 -0
  88. package/legacy/locales/plPL.js +2 -0
  89. package/legacy/locales/ptBR.js +2 -0
  90. package/legacy/locales/roRO.js +1 -0
  91. package/legacy/locales/ruRU.js +2 -0
  92. package/legacy/locales/skSK.js +2 -0
  93. package/legacy/locales/svSE.js +2 -0
  94. package/legacy/locales/trTR.js +2 -0
  95. package/legacy/locales/ukUA.js +2 -0
  96. package/legacy/locales/urPK.js +2 -0
  97. package/legacy/locales/viVN.js +2 -0
  98. package/legacy/locales/zhCN.js +2 -0
  99. package/legacy/locales/zhHK.js +2 -0
  100. package/locales/beBY.d.ts +1 -0
  101. package/locales/beBY.js +2 -0
  102. package/locales/caES.d.ts +1 -0
  103. package/locales/caES.js +2 -0
  104. package/locales/csCZ.d.ts +1 -0
  105. package/locales/csCZ.js +2 -0
  106. package/locales/daDK.d.ts +1 -0
  107. package/locales/daDK.js +2 -0
  108. package/locales/deDE.d.ts +1 -0
  109. package/locales/deDE.js +2 -0
  110. package/locales/elGR.d.ts +1 -0
  111. package/locales/elGR.js +2 -0
  112. package/locales/enUS.d.ts +1 -0
  113. package/locales/enUS.js +1 -0
  114. package/locales/esES.d.ts +1 -0
  115. package/locales/esES.js +2 -0
  116. package/locales/faIR.d.ts +1 -0
  117. package/locales/faIR.js +2 -0
  118. package/locales/fiFI.d.ts +1 -0
  119. package/locales/fiFI.js +11 -11
  120. package/locales/frFR.d.ts +1 -0
  121. package/locales/frFR.js +2 -0
  122. package/locales/heIL.d.ts +1 -0
  123. package/locales/heIL.js +2 -0
  124. package/locales/huHU.d.ts +1 -0
  125. package/locales/huHU.js +1 -0
  126. package/locales/isIS.d.ts +1 -0
  127. package/locales/isIS.js +2 -0
  128. package/locales/itIT.d.ts +1 -0
  129. package/locales/itIT.js +2 -0
  130. package/locales/jaJP.d.ts +1 -0
  131. package/locales/jaJP.js +2 -0
  132. package/locales/koKR.d.ts +1 -0
  133. package/locales/koKR.js +2 -0
  134. package/locales/kzKZ.d.ts +1 -0
  135. package/locales/kzKZ.js +2 -0
  136. package/locales/nbNO.d.ts +1 -0
  137. package/locales/nbNO.js +2 -0
  138. package/locales/nlNL.d.ts +1 -0
  139. package/locales/nlNL.js +2 -0
  140. package/locales/plPL.d.ts +1 -0
  141. package/locales/plPL.js +2 -0
  142. package/locales/ptBR.d.ts +1 -0
  143. package/locales/ptBR.js +2 -0
  144. package/locales/roRO.d.ts +1 -0
  145. package/locales/roRO.js +1 -0
  146. package/locales/ruRU.d.ts +1 -0
  147. package/locales/ruRU.js +2 -0
  148. package/locales/skSK.d.ts +1 -0
  149. package/locales/skSK.js +2 -0
  150. package/locales/svSE.d.ts +1 -0
  151. package/locales/svSE.js +2 -0
  152. package/locales/trTR.d.ts +1 -0
  153. package/locales/trTR.js +2 -0
  154. package/locales/ukUA.d.ts +1 -0
  155. package/locales/ukUA.js +2 -0
  156. package/locales/urPK.d.ts +1 -0
  157. package/locales/urPK.js +2 -0
  158. package/locales/utils/getPickersLocalization.d.ts +1 -0
  159. package/locales/utils/pickersLocaleTextApi.d.ts +1 -0
  160. package/locales/viVN.d.ts +1 -0
  161. package/locales/viVN.js +2 -0
  162. package/locales/zhCN.d.ts +1 -0
  163. package/locales/zhCN.js +2 -0
  164. package/locales/zhHK.d.ts +1 -0
  165. package/locales/zhHK.js +2 -0
  166. package/models/adapters.d.ts +1 -0
  167. package/models/fields.d.ts +2 -0
  168. package/modern/DateCalendar/DateCalendar.js +6 -2
  169. package/modern/DateCalendar/DayCalendar.js +25 -11
  170. package/modern/DateCalendar/dayCalendarClasses.js +1 -1
  171. package/modern/DateField/DateField.js +32 -4
  172. package/modern/DatePicker/DatePicker.js +6 -2
  173. package/modern/DateTimeField/DateTimeField.js +32 -4
  174. package/modern/DateTimePicker/DateTimePicker.js +6 -2
  175. package/modern/DateTimePicker/DateTimePickerToolbar.js +1 -0
  176. package/modern/DesktopDatePicker/DesktopDatePicker.js +6 -2
  177. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  178. package/modern/MobileDatePicker/MobileDatePicker.js +6 -2
  179. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  180. package/modern/StaticDatePicker/StaticDatePicker.js +6 -2
  181. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  182. package/modern/TimeField/TimeField.js +29 -4
  183. package/modern/TimePicker/TimePickerToolbar.js +1 -0
  184. package/modern/hooks/index.js +1 -0
  185. package/modern/hooks/useClearableField.js +78 -0
  186. package/modern/icons/index.js +8 -1
  187. package/modern/index.js +3 -2
  188. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  189. package/modern/internals/hooks/useField/useField.js +23 -6
  190. package/modern/internals/hooks/useField/useField.utils.js +8 -3
  191. package/modern/internals/utils/date-utils.js +4 -0
  192. package/modern/locales/beBY.js +2 -0
  193. package/modern/locales/caES.js +2 -0
  194. package/modern/locales/csCZ.js +2 -0
  195. package/modern/locales/daDK.js +2 -0
  196. package/modern/locales/deDE.js +2 -0
  197. package/modern/locales/elGR.js +2 -0
  198. package/modern/locales/enUS.js +1 -0
  199. package/modern/locales/esES.js +2 -0
  200. package/modern/locales/faIR.js +2 -0
  201. package/modern/locales/fiFI.js +11 -11
  202. package/modern/locales/frFR.js +2 -0
  203. package/modern/locales/heIL.js +2 -0
  204. package/modern/locales/huHU.js +1 -0
  205. package/modern/locales/isIS.js +2 -0
  206. package/modern/locales/itIT.js +2 -0
  207. package/modern/locales/jaJP.js +2 -0
  208. package/modern/locales/koKR.js +2 -0
  209. package/modern/locales/kzKZ.js +2 -0
  210. package/modern/locales/nbNO.js +2 -0
  211. package/modern/locales/nlNL.js +2 -0
  212. package/modern/locales/plPL.js +2 -0
  213. package/modern/locales/ptBR.js +2 -0
  214. package/modern/locales/roRO.js +1 -0
  215. package/modern/locales/ruRU.js +2 -0
  216. package/modern/locales/skSK.js +2 -0
  217. package/modern/locales/svSE.js +2 -0
  218. package/modern/locales/trTR.js +2 -0
  219. package/modern/locales/ukUA.js +2 -0
  220. package/modern/locales/urPK.js +2 -0
  221. package/modern/locales/viVN.js +2 -0
  222. package/modern/locales/zhCN.js +2 -0
  223. package/modern/locales/zhHK.js +2 -0
  224. package/node/DateCalendar/DateCalendar.js +6 -2
  225. package/node/DateCalendar/DayCalendar.js +24 -10
  226. package/node/DateCalendar/dayCalendarClasses.js +1 -1
  227. package/node/DateField/DateField.js +32 -4
  228. package/node/DatePicker/DatePicker.js +6 -2
  229. package/node/DateTimeField/DateTimeField.js +32 -4
  230. package/node/DateTimePicker/DateTimePicker.js +6 -2
  231. package/node/DateTimePicker/DateTimePickerToolbar.js +1 -0
  232. package/node/DesktopDatePicker/DesktopDatePicker.js +6 -2
  233. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -2
  234. package/node/MobileDatePicker/MobileDatePicker.js +6 -2
  235. package/node/MobileDateTimePicker/MobileDateTimePicker.js +6 -2
  236. package/node/StaticDatePicker/StaticDatePicker.js +6 -2
  237. package/node/StaticDateTimePicker/StaticDateTimePicker.js +6 -2
  238. package/node/TimeField/TimeField.js +29 -4
  239. package/node/TimePicker/TimePickerToolbar.js +1 -0
  240. package/node/hooks/index.js +12 -0
  241. package/node/hooks/useClearableField.js +87 -0
  242. package/node/icons/index.js +10 -2
  243. package/node/index.js +13 -1
  244. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +3 -1
  245. package/node/internals/hooks/useField/useField.js +23 -6
  246. package/node/internals/hooks/useField/useField.utils.js +8 -3
  247. package/node/internals/utils/date-utils.js +7 -2
  248. package/node/locales/beBY.js +2 -0
  249. package/node/locales/caES.js +2 -0
  250. package/node/locales/csCZ.js +2 -0
  251. package/node/locales/daDK.js +2 -0
  252. package/node/locales/deDE.js +2 -0
  253. package/node/locales/elGR.js +2 -0
  254. package/node/locales/enUS.js +1 -0
  255. package/node/locales/esES.js +2 -0
  256. package/node/locales/faIR.js +2 -0
  257. package/node/locales/fiFI.js +11 -11
  258. package/node/locales/frFR.js +2 -0
  259. package/node/locales/heIL.js +2 -0
  260. package/node/locales/huHU.js +1 -0
  261. package/node/locales/isIS.js +2 -0
  262. package/node/locales/itIT.js +2 -0
  263. package/node/locales/jaJP.js +2 -0
  264. package/node/locales/koKR.js +2 -0
  265. package/node/locales/kzKZ.js +2 -0
  266. package/node/locales/nbNO.js +2 -0
  267. package/node/locales/nlNL.js +2 -0
  268. package/node/locales/plPL.js +2 -0
  269. package/node/locales/ptBR.js +2 -0
  270. package/node/locales/roRO.js +1 -0
  271. package/node/locales/ruRU.js +2 -0
  272. package/node/locales/skSK.js +2 -0
  273. package/node/locales/svSE.js +2 -0
  274. package/node/locales/trTR.js +2 -0
  275. package/node/locales/ukUA.js +2 -0
  276. package/node/locales/urPK.js +2 -0
  277. package/node/locales/viVN.js +2 -0
  278. package/node/locales/zhCN.js +2 -0
  279. package/node/locales/zhHK.js +2 -0
  280. package/package.json +1 -1
  281. package/legacy/tests/describe.types.js +0 -1
  282. package/legacy/tests/describeAdapters/describeAdapters.js +0 -29
  283. package/legacy/tests/describeAdapters/index.js +0 -1
  284. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -32
  285. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -1
  286. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -2
  287. package/legacy/tests/describeGregorianAdapter/index.js +0 -2
  288. package/legacy/tests/describeGregorianAdapter/testCalculations.js +0 -707
  289. package/legacy/tests/describeGregorianAdapter/testFormat.js +0 -26
  290. package/legacy/tests/describeGregorianAdapter/testLocalization.js +0 -49
  291. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +0 -21
  292. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -1
  293. package/legacy/tests/describeHijriAdapter/index.js +0 -1
  294. package/legacy/tests/describeHijriAdapter/testCalculations.js +0 -167
  295. package/legacy/tests/describeHijriAdapter/testLocalization.js +0 -20
  296. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -21
  297. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -1
  298. package/legacy/tests/describeJalaliAdapter/index.js +0 -1
  299. package/legacy/tests/describeJalaliAdapter/testCalculations.js +0 -236
  300. package/legacy/tests/describeJalaliAdapter/testLocalization.js +0 -20
  301. package/legacy/tests/describePicker/describePicker.js +0 -159
  302. package/legacy/tests/describePicker/describePicker.types.js +0 -1
  303. package/legacy/tests/describePicker/index.js +0 -1
  304. package/legacy/tests/describeValidation/describeValidation.js +0 -31
  305. package/legacy/tests/describeValidation/describeValidation.types.js +0 -1
  306. package/legacy/tests/describeValidation/index.js +0 -1
  307. package/legacy/tests/describeValidation/testDayViewValidation.js +0 -281
  308. package/legacy/tests/describeValidation/testMinutesViewValidation.js +0 -194
  309. package/legacy/tests/describeValidation/testMonthViewValidation.js +0 -136
  310. package/legacy/tests/describeValidation/testTextFieldValidation.js +0 -463
  311. package/legacy/tests/describeValidation/testYearViewValidation.js +0 -95
  312. package/legacy/tests/describeValue/describeValue.js +0 -57
  313. package/legacy/tests/describeValue/describeValue.types.js +0 -1
  314. package/legacy/tests/describeValue/index.js +0 -1
  315. package/legacy/tests/describeValue/testControlledUnControlled.js +0 -237
  316. package/legacy/tests/describeValue/testPickerActionBar.js +0 -250
  317. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -362
  318. package/legacy/tests/describeValue/testShortcuts.js +0 -119
  319. package/modern/tests/describe.types.js +0 -1
  320. package/modern/tests/describeAdapters/describeAdapters.js +0 -29
  321. package/modern/tests/describeAdapters/index.js +0 -1
  322. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -29
  323. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -1
  324. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -2
  325. package/modern/tests/describeGregorianAdapter/index.js +0 -2
  326. package/modern/tests/describeGregorianAdapter/testCalculations.js +0 -706
  327. package/modern/tests/describeGregorianAdapter/testFormat.js +0 -27
  328. package/modern/tests/describeGregorianAdapter/testLocalization.js +0 -50
  329. package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +0 -21
  330. package/modern/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -1
  331. package/modern/tests/describeHijriAdapter/index.js +0 -1
  332. package/modern/tests/describeHijriAdapter/testCalculations.js +0 -164
  333. package/modern/tests/describeHijriAdapter/testLocalization.js +0 -21
  334. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -21
  335. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -1
  336. package/modern/tests/describeJalaliAdapter/index.js +0 -1
  337. package/modern/tests/describeJalaliAdapter/testCalculations.js +0 -237
  338. package/modern/tests/describeJalaliAdapter/testLocalization.js +0 -21
  339. package/modern/tests/describePicker/describePicker.js +0 -162
  340. package/modern/tests/describePicker/describePicker.types.js +0 -1
  341. package/modern/tests/describePicker/index.js +0 -1
  342. package/modern/tests/describeValidation/describeValidation.js +0 -31
  343. package/modern/tests/describeValidation/describeValidation.types.js +0 -1
  344. package/modern/tests/describeValidation/index.js +0 -1
  345. package/modern/tests/describeValidation/testDayViewValidation.js +0 -280
  346. package/modern/tests/describeValidation/testMinutesViewValidation.js +0 -193
  347. package/modern/tests/describeValidation/testMonthViewValidation.js +0 -137
  348. package/modern/tests/describeValidation/testTextFieldValidation.js +0 -470
  349. package/modern/tests/describeValidation/testYearViewValidation.js +0 -94
  350. package/modern/tests/describeValue/describeValue.js +0 -59
  351. package/modern/tests/describeValue/describeValue.types.js +0 -1
  352. package/modern/tests/describeValue/index.js +0 -1
  353. package/modern/tests/describeValue/testControlledUnControlled.js +0 -239
  354. package/modern/tests/describeValue/testPickerActionBar.js +0 -254
  355. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -371
  356. package/modern/tests/describeValue/testShortcuts.js +0 -112
  357. package/node/tests/describe.types.js +0 -5
  358. package/node/tests/describeAdapters/describeAdapters.js +0 -37
  359. package/node/tests/describeAdapters/index.js +0 -12
  360. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -37
  361. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -5
  362. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -10
  363. package/node/tests/describeGregorianAdapter/index.js +0 -19
  364. package/node/tests/describeGregorianAdapter/testCalculations.js +0 -711
  365. package/node/tests/describeGregorianAdapter/testFormat.js +0 -34
  366. package/node/tests/describeGregorianAdapter/testLocalization.js +0 -57
  367. package/node/tests/describeHijriAdapter/describeHijriAdapter.js +0 -29
  368. package/node/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -5
  369. package/node/tests/describeHijriAdapter/index.js +0 -12
  370. package/node/tests/describeHijriAdapter/testCalculations.js +0 -171
  371. package/node/tests/describeHijriAdapter/testLocalization.js +0 -28
  372. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -29
  373. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -5
  374. package/node/tests/describeJalaliAdapter/index.js +0 -12
  375. package/node/tests/describeJalaliAdapter/testCalculations.js +0 -244
  376. package/node/tests/describeJalaliAdapter/testLocalization.js +0 -28
  377. package/node/tests/describePicker/describePicker.js +0 -173
  378. package/node/tests/describePicker/describePicker.types.js +0 -5
  379. package/node/tests/describePicker/index.js +0 -12
  380. package/node/tests/describeValidation/describeValidation.js +0 -39
  381. package/node/tests/describeValidation/describeValidation.types.js +0 -5
  382. package/node/tests/describeValidation/index.js +0 -12
  383. package/node/tests/describeValidation/testDayViewValidation.js +0 -290
  384. package/node/tests/describeValidation/testMinutesViewValidation.js +0 -203
  385. package/node/tests/describeValidation/testMonthViewValidation.js +0 -147
  386. package/node/tests/describeValidation/testTextFieldValidation.js +0 -480
  387. package/node/tests/describeValidation/testYearViewValidation.js +0 -104
  388. package/node/tests/describeValue/describeValue.js +0 -69
  389. package/node/tests/describeValue/describeValue.types.js +0 -5
  390. package/node/tests/describeValue/index.js +0 -12
  391. package/node/tests/describeValue/testControlledUnControlled.js +0 -248
  392. package/node/tests/describeValue/testPickerActionBar.js +0 -264
  393. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -381
  394. package/node/tests/describeValue/testShortcuts.js +0 -122
  395. package/tests/describe.types.js +0 -1
  396. package/tests/describeAdapters/describeAdapters.js +0 -29
  397. package/tests/describeAdapters/index.js +0 -1
  398. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +0 -30
  399. package/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +0 -1
  400. package/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +0 -2
  401. package/tests/describeGregorianAdapter/index.js +0 -2
  402. package/tests/describeGregorianAdapter/testCalculations.js +0 -706
  403. package/tests/describeGregorianAdapter/testFormat.js +0 -27
  404. package/tests/describeGregorianAdapter/testLocalization.js +0 -50
  405. package/tests/describeHijriAdapter/describeHijriAdapter.js +0 -21
  406. package/tests/describeHijriAdapter/describeHijriAdapter.types.js +0 -1
  407. package/tests/describeHijriAdapter/index.js +0 -1
  408. package/tests/describeHijriAdapter/testCalculations.js +0 -164
  409. package/tests/describeHijriAdapter/testLocalization.js +0 -21
  410. package/tests/describeJalaliAdapter/describeJalaliAdapter.js +0 -21
  411. package/tests/describeJalaliAdapter/describeJalaliAdapter.types.js +0 -1
  412. package/tests/describeJalaliAdapter/index.js +0 -1
  413. package/tests/describeJalaliAdapter/testCalculations.js +0 -237
  414. package/tests/describeJalaliAdapter/testLocalization.js +0 -21
  415. package/tests/describePicker/describePicker.js +0 -162
  416. package/tests/describePicker/describePicker.types.js +0 -1
  417. package/tests/describePicker/index.js +0 -1
  418. package/tests/describeValidation/describeValidation.js +0 -31
  419. package/tests/describeValidation/describeValidation.types.js +0 -1
  420. package/tests/describeValidation/index.js +0 -1
  421. package/tests/describeValidation/testDayViewValidation.js +0 -280
  422. package/tests/describeValidation/testMinutesViewValidation.js +0 -193
  423. package/tests/describeValidation/testMonthViewValidation.js +0 -137
  424. package/tests/describeValidation/testTextFieldValidation.js +0 -470
  425. package/tests/describeValidation/testYearViewValidation.js +0 -94
  426. package/tests/describeValue/describeValue.js +0 -59
  427. package/tests/describeValue/describeValue.types.js +0 -1
  428. package/tests/describeValue/index.js +0 -1
  429. package/tests/describeValue/testControlledUnControlled.js +0 -239
  430. package/tests/describeValue/testPickerActionBar.js +0 -254
  431. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +0 -371
  432. package/tests/describeValue/testShortcuts.js +0 -112
@@ -89,9 +89,10 @@ MobileDatePicker.propTypes = {
89
89
  componentsProps: PropTypes.object,
90
90
  /**
91
91
  * Formats the day of week displayed in the calendar header.
92
- * @param {string} day The day of week provided by the adapter's method `getWeekdays`.
92
+ * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
93
+ * @param {TDate} date The date of the day of week provided by the adapter.
93
94
  * @returns {string} The name to display.
94
- * @default (day) => day.charAt(0).toUpperCase()
95
+ * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
95
96
  */
96
97
  dayOfWeekFormatter: PropTypes.func,
97
98
  /**
@@ -285,6 +286,9 @@ MobileDatePicker.propTypes = {
285
286
  })]),
286
287
  /**
287
288
  * Disable specific date.
289
+ *
290
+ * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
291
+ *
288
292
  * @template TDate
289
293
  * @param {TDate} day The date to test.
290
294
  * @returns {boolean} If `true` the date will be disabled.
@@ -110,9 +110,10 @@ MobileDateTimePicker.propTypes = {
110
110
  componentsProps: PropTypes.object,
111
111
  /**
112
112
  * Formats the day of week displayed in the calendar header.
113
- * @param {string} day The day of week provided by the adapter's method `getWeekdays`.
113
+ * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
114
+ * @param {TDate} date The date of the day of week provided by the adapter.
114
115
  * @returns {string} The name to display.
115
- * @default (day) => day.charAt(0).toUpperCase()
116
+ * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
116
117
  */
117
118
  dayOfWeekFormatter: PropTypes.func,
118
119
  /**
@@ -342,6 +343,9 @@ MobileDateTimePicker.propTypes = {
342
343
  shouldDisableClock: PropTypes.func,
343
344
  /**
344
345
  * Disable specific date.
346
+ *
347
+ * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
348
+ *
345
349
  * @template TDate
346
350
  * @param {TDate} day The date to test.
347
351
  * @returns {boolean} If `true` the date will be disabled.
@@ -68,9 +68,10 @@ StaticDatePicker.propTypes = {
68
68
  componentsProps: PropTypes.object,
69
69
  /**
70
70
  * Formats the day of week displayed in the calendar header.
71
- * @param {string} day The day of week provided by the adapter's method `getWeekdays`.
71
+ * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
72
+ * @param {TDate} date The date of the day of week provided by the adapter.
72
73
  * @returns {string} The name to display.
73
- * @default (day) => day.charAt(0).toUpperCase()
74
+ * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
74
75
  */
75
76
  dayOfWeekFormatter: PropTypes.func,
76
77
  /**
@@ -218,6 +219,9 @@ StaticDatePicker.propTypes = {
218
219
  renderLoading: PropTypes.func,
219
220
  /**
220
221
  * Disable specific date.
222
+ *
223
+ * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
224
+ *
221
225
  * @template TDate
222
226
  * @param {TDate} day The date to test.
223
227
  * @returns {boolean} If `true` the date will be disabled.
@@ -88,9 +88,10 @@ StaticDateTimePicker.propTypes = {
88
88
  componentsProps: PropTypes.object,
89
89
  /**
90
90
  * Formats the day of week displayed in the calendar header.
91
- * @param {string} day The day of week provided by the adapter's method `getWeekdays`.
91
+ * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
92
+ * @param {TDate} date The date of the day of week provided by the adapter.
92
93
  * @returns {string} The name to display.
93
- * @default (day) => day.charAt(0).toUpperCase()
94
+ * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
94
95
  */
95
96
  dayOfWeekFormatter: PropTypes.func,
96
97
  /**
@@ -274,6 +275,9 @@ StaticDateTimePicker.propTypes = {
274
275
  shouldDisableClock: PropTypes.func,
275
276
  /**
276
277
  * Disable specific date.
278
+ *
279
+ * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
280
+ *
277
281
  * @template TDate
278
282
  * @param {TDate} day The date to test.
279
283
  * @returns {boolean} If `true` the date will be disabled.
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["slots", "slotProps", "components", "componentsProps", "InputProps", "inputProps"],
4
4
  _excluded2 = ["inputRef"],
5
- _excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly"];
5
+ _excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly", "clearable", "onClear"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import MuiTextField from '@mui/material/TextField';
@@ -10,6 +10,7 @@ import { useThemeProps } from '@mui/material/styles';
10
10
  import { useSlotProps } from '@mui/base/utils';
11
11
  import { refType } from '@mui/utils';
12
12
  import { useTimeField } from './useTimeField';
13
+ import { useClearableField } from '../hooks';
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref) {
15
16
  var _ref, _slots$textField, _slotProps$textField;
@@ -51,13 +52,28 @@ const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref)
51
52
  onPaste,
52
53
  onKeyDown,
53
54
  inputMode,
54
- readOnly
55
+ readOnly,
56
+ clearable,
57
+ onClear
55
58
  } = _useTimeField,
56
59
  fieldProps = _objectWithoutPropertiesLoose(_useTimeField, _excluded3);
60
+ const {
61
+ InputProps: ProcessedInputProps,
62
+ fieldProps: processedFieldProps
63
+ } = useClearableField({
64
+ onClear,
65
+ clearable,
66
+ fieldProps,
67
+ InputProps: fieldProps.InputProps,
68
+ slots,
69
+ slotProps,
70
+ components,
71
+ componentsProps
72
+ });
57
73
  return /*#__PURE__*/_jsx(TextField, _extends({
58
74
  ref: ref
59
- }, fieldProps, {
60
- InputProps: _extends({}, fieldProps.InputProps, {
75
+ }, processedFieldProps, {
76
+ InputProps: _extends({}, ProcessedInputProps, {
61
77
  readOnly
62
78
  }),
63
79
  inputProps: _extends({}, fieldProps.inputProps, {
@@ -84,6 +100,11 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
84
100
  */
85
101
  autoFocus: PropTypes.bool,
86
102
  className: PropTypes.string,
103
+ /**
104
+ * If `true`, a clear button will be shown in the field allowing value clearing.
105
+ * @default false
106
+ */
107
+ clearable: PropTypes.bool,
87
108
  /**
88
109
  * The color of the component.
89
110
  * It supports both default and custom theme colors, which can be added as shown in the
@@ -224,6 +245,10 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
224
245
  * @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
225
246
  */
226
247
  onChange: PropTypes.func,
248
+ /**
249
+ * Callback fired when the clear button is clicked.
250
+ */
251
+ onClear: PropTypes.func,
227
252
  /**
228
253
  * Callback fired when the error associated to the current value changes.
229
254
  * @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.
@@ -7,6 +7,7 @@ import { BaseTimeValidationProps, TimeValidationProps } from '../internals/model
7
7
  import { UncapitalizeObjectKeys } from '../internals/utils/slots-migration';
8
8
  import { FieldsTextFieldProps } from '../internals/models/fields';
9
9
  import { FieldSection, TimeValidationError } from '../models';
10
+ import { FieldSlotsComponents, FieldSlotsComponentsProps } from '../internals';
10
11
  export interface UseTimeFieldParams<TDate, TChildProps extends {}> {
11
12
  props: UseTimeFieldComponentProps<TDate, TChildProps>;
12
13
  inputRef?: React.Ref<HTMLInputElement>;
@@ -45,7 +46,7 @@ export interface TimeFieldProps<TDate> extends UseTimeFieldComponentProps<TDate,
45
46
  slotProps?: TimeFieldSlotsComponentsProps<TDate>;
46
47
  }
47
48
  export type TimeFieldOwnerState<TDate> = TimeFieldProps<TDate>;
48
- export interface TimeFieldSlotsComponent {
49
+ export interface TimeFieldSlotsComponent extends FieldSlotsComponents {
49
50
  /**
50
51
  * Form control with an input to render the value.
51
52
  * Receives the same props as `@mui/material/TextField`.
@@ -53,6 +54,6 @@ export interface TimeFieldSlotsComponent {
53
54
  */
54
55
  TextField?: React.ElementType;
55
56
  }
56
- export interface TimeFieldSlotsComponentsProps<TDate> {
57
+ export interface TimeFieldSlotsComponentsProps<TDate> extends FieldSlotsComponentsProps {
57
58
  textField?: SlotComponentProps<typeof TextField, {}, TimeFieldOwnerState<TDate>>;
58
59
  }
@@ -222,6 +222,7 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
222
222
  */
223
223
  onViewChange: PropTypes.func.isRequired,
224
224
  readOnly: PropTypes.bool,
225
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
225
226
  titleId: PropTypes.string,
226
227
  /**
227
228
  * Toolbar date format.
@@ -0,0 +1 @@
1
+ export { useClearableField } from './useClearableField';
package/hooks/index.js ADDED
@@ -0,0 +1 @@
1
+ export { useClearableField } from './useClearableField';
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/hooks/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { FieldSlotsComponents, FieldSlotsComponentsProps, FieldsTextFieldProps } from '../internals';
3
+ type UseClearableFieldProps<TFieldProps extends FieldsTextFieldProps, TInputProps extends {
4
+ endAdornment?: React.ReactNode;
5
+ } | undefined, TFieldSlots extends FieldSlotsComponents, TFieldSlotsComponentsProps extends FieldSlotsComponentsProps> = {
6
+ clearable: boolean;
7
+ fieldProps: TFieldProps;
8
+ InputProps: TInputProps;
9
+ onClear: React.MouseEventHandler<HTMLButtonElement>;
10
+ slots?: {
11
+ [K in keyof TFieldSlots as Uncapitalize<K & string>]: TFieldSlots[K];
12
+ };
13
+ slotProps?: TFieldSlotsComponentsProps;
14
+ components?: TFieldSlots;
15
+ componentsProps?: TFieldSlotsComponentsProps;
16
+ };
17
+ export declare const useClearableField: <TFieldProps extends FieldsTextFieldProps, TInputProps extends {
18
+ endAdornment?: React.ReactNode;
19
+ } | undefined, TFieldSlotsComponents extends FieldSlotsComponents, TFieldSlotsComponentsProps extends FieldSlotsComponentsProps>({ clearable, fieldProps: forwardedFieldProps, InputProps: ForwardedInputProps, onClear, slots, slotProps, components, componentsProps, }: UseClearableFieldProps<TFieldProps, TInputProps, TFieldSlotsComponents, TFieldSlotsComponentsProps>) => {
20
+ InputProps: TInputProps & {
21
+ endAdornment: string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
22
+ };
23
+ fieldProps: TFieldProps;
24
+ };
25
+ export {};
@@ -0,0 +1,79 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["ownerState"];
4
+ import * as React from 'react';
5
+ import { useSlotProps } from '@mui/base/utils';
6
+ import MuiIconButton from '@mui/material/IconButton';
7
+ import InputAdornment from '@mui/material/InputAdornment';
8
+ import { ClearIcon } from '../icons';
9
+ import { useLocaleText } from '../internals';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ export const useClearableField = ({
13
+ clearable,
14
+ fieldProps: forwardedFieldProps,
15
+ InputProps: ForwardedInputProps,
16
+ onClear,
17
+ slots,
18
+ slotProps,
19
+ components,
20
+ componentsProps
21
+ }) => {
22
+ var _ref, _slots$clearButton, _slotProps$clearButto, _ref2, _slots$clearIcon, _slotProps$clearIcon;
23
+ const localeText = useLocaleText();
24
+ const IconButton = (_ref = (_slots$clearButton = slots == null ? void 0 : slots.clearButton) != null ? _slots$clearButton : components == null ? void 0 : components.ClearButton) != null ? _ref : MuiIconButton;
25
+ // The spread is here to avoid this bug mui/material-ui#34056
26
+ const _useSlotProps = useSlotProps({
27
+ elementType: IconButton,
28
+ externalSlotProps: (_slotProps$clearButto = slotProps == null ? void 0 : slotProps.clearButton) != null ? _slotProps$clearButto : componentsProps == null ? void 0 : componentsProps.clearButton,
29
+ ownerState: {},
30
+ className: 'clearButton',
31
+ additionalProps: {
32
+ title: localeText.fieldClearLabel
33
+ }
34
+ }),
35
+ iconButtonProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded);
36
+ const EndClearIcon = (_ref2 = (_slots$clearIcon = slots == null ? void 0 : slots.clearIcon) != null ? _slots$clearIcon : components == null ? void 0 : components.ClearIcon) != null ? _ref2 : ClearIcon;
37
+ const endClearIconProps = useSlotProps({
38
+ elementType: EndClearIcon,
39
+ externalSlotProps: (_slotProps$clearIcon = slotProps == null ? void 0 : slotProps.clearIcon) != null ? _slotProps$clearIcon : componentsProps == null ? void 0 : componentsProps.clearIcon,
40
+ ownerState: {}
41
+ });
42
+ const InputProps = _extends({}, ForwardedInputProps, {
43
+ endAdornment: clearable ? /*#__PURE__*/_jsxs(React.Fragment, {
44
+ children: [/*#__PURE__*/_jsx(InputAdornment, {
45
+ position: "end",
46
+ sx: {
47
+ marginRight: ForwardedInputProps != null && ForwardedInputProps.endAdornment ? -1 : -1.5
48
+ },
49
+ children: /*#__PURE__*/_jsx(IconButton, _extends({}, iconButtonProps, {
50
+ onClick: onClear,
51
+ children: /*#__PURE__*/_jsx(EndClearIcon, _extends({
52
+ fontSize: "small"
53
+ }, endClearIconProps))
54
+ }))
55
+ }), ForwardedInputProps == null ? void 0 : ForwardedInputProps.endAdornment]
56
+ }) : ForwardedInputProps == null ? void 0 : ForwardedInputProps.endAdornment
57
+ });
58
+ const fieldProps = _extends({}, forwardedFieldProps, {
59
+ sx: [{
60
+ '& .clearButton': {
61
+ opacity: 1
62
+ },
63
+ '@media (pointer: fine)': {
64
+ '& .clearButton': {
65
+ opacity: 0
66
+ },
67
+ '&:hover, &:focus-within': {
68
+ '.clearButton': {
69
+ opacity: 1
70
+ }
71
+ }
72
+ }
73
+ }, ...(Array.isArray(forwardedFieldProps.sx) ? forwardedFieldProps.sx : [forwardedFieldProps.sx])]
74
+ });
75
+ return {
76
+ InputProps,
77
+ fieldProps
78
+ };
79
+ };
package/icons/index.d.ts CHANGED
@@ -40,3 +40,9 @@ export declare const DateRangeIcon: import("@mui/material/OverridableComponent")
40
40
  export declare const TimeIcon: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
41
41
  muiName: string;
42
42
  };
43
+ /**
44
+ * @ignore - internal component.
45
+ */
46
+ export declare const ClearIcon: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
47
+ muiName: string;
48
+ };
package/icons/index.js CHANGED
@@ -58,4 +58,11 @@ export const TimeIcon = createSvgIcon( /*#__PURE__*/_jsxs(React.Fragment, {
58
58
  }), /*#__PURE__*/_jsx("path", {
59
59
  d: "M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"
60
60
  })]
61
- }), 'Time');
61
+ }), 'Time');
62
+
63
+ /**
64
+ * @ignore - internal component.
65
+ */
66
+ export const ClearIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
67
+ d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
68
+ }), 'Clear');
package/index.d.ts CHANGED
@@ -31,3 +31,4 @@ export * from './PickersShortcuts';
31
31
  export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
32
32
  export * from './models';
33
33
  export * from './icons';
34
+ export * from './hooks';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.14.0
2
+ * @mui/x-date-pickers v6.16.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -48,4 +48,5 @@ export * from './PickersActionBar';
48
48
  export * from './PickersShortcuts';
49
49
  export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
50
50
  export * from './models';
51
- export * from './icons';
51
+ export * from './icons';
52
+ export * from './hooks';
@@ -122,7 +122,9 @@ export const useDesktopPicker = _ref => {
122
122
  });
123
123
  }
124
124
  const slotsForField = _extends({
125
- textField: slots.textField
125
+ textField: slots.textField,
126
+ clearIcon: slots.clearIcon,
127
+ clearButton: slots.clearButton
126
128
  }, fieldProps.slots);
127
129
  const Layout = (_slots$layout = slots.layout) != null ? _slots$layout : PickersLayout;
128
130
  const handleInputRef = useForkRef(internalInputRef, fieldProps.inputRef, inputRef);
@@ -12,7 +12,8 @@ import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types'
12
12
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
13
13
  import { UncapitalizeObjectKeys } from '../../utils/slots-migration';
14
14
  import { DateOrTimeViewWithMeridiem } from '../../models';
15
- export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeViewWithMeridiem> extends Pick<PickersPopperSlotsComponent, 'DesktopPaper' | 'DesktopTransition' | 'DesktopTrapFocus' | 'Popper'>, ExportedPickersLayoutSlotsComponent<TDate | null, TDate, TView> {
15
+ import { FieldSlotsComponents, FieldSlotsComponentsProps } from '../useField';
16
+ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeViewWithMeridiem> extends Pick<PickersPopperSlotsComponent, 'DesktopPaper' | 'DesktopTransition' | 'DesktopTrapFocus' | 'Popper'>, ExportedPickersLayoutSlotsComponent<TDate | null, TDate, TView>, FieldSlotsComponents {
16
17
  /**
17
18
  * Component used to enter the date with the keyboard.
18
19
  */
@@ -40,7 +41,7 @@ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeV
40
41
  }
41
42
  export interface UseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView>, Pick<PickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, 'toolbar'> {
42
43
  }
43
- export interface ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView> {
44
+ export interface ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, FieldSlotsComponentsProps {
44
45
  field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, TDate, any, FieldSection, any, any, any>>;
45
46
  textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
46
47
  inputAdornment?: Partial<InputAdornmentProps>;
@@ -1,3 +1,3 @@
1
1
  export { useField } from './useField';
2
- export type { FieldValueManager, UseFieldInternalProps, UseFieldForwardedProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext, FieldRef, } from './useField.types';
2
+ export type { FieldValueManager, UseFieldInternalProps, UseFieldForwardedProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext, FieldRef, FieldSlotsComponents, FieldSlotsComponentsProps, } from './useField.types';
3
3
  export { splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections, } from './useField.utils';
@@ -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 = ["onClick", "onKeyDown", "onFocus", "onBlur", "onMouseUp", "onPaste", "error"];
3
+ const _excluded = ["onClick", "onKeyDown", "onFocus", "onBlur", "onMouseUp", "onPaste", "error", "clearable", "onClear"];
4
4
  import * as React from 'react';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import useEventCallback from '@mui/utils/useEventCallback';
@@ -42,7 +42,9 @@ export const useField = params => {
42
42
  onBlur,
43
43
  onMouseUp,
44
44
  onPaste,
45
- error
45
+ error,
46
+ clearable,
47
+ onClear
46
48
  },
47
49
  fieldValueManager,
48
50
  valueManager,
@@ -85,8 +87,13 @@ export const useField = params => {
85
87
  const sectionIndex = nextSectionIndex === -1 ? state.sections.length - 1 : nextSectionIndex - 1;
86
88
  setSelectedSections(sectionIndex);
87
89
  };
88
- const handleInputClick = useEventCallback((...args) => {
89
- onClick == null || onClick(...args);
90
+ const handleInputClick = useEventCallback((event, ...args) => {
91
+ // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.
92
+ // We avoid this by checking if the call of `handleInputClick` is actually intended, or a side effect.
93
+ if (event.isDefaultPrevented()) {
94
+ return;
95
+ }
96
+ onClick == null || onClick(event, ...args);
90
97
  syncSelectionFromDOM();
91
98
  });
92
99
  const handleInputMouseUp = useEventCallback(event => {
@@ -373,7 +380,8 @@ export const useField = params => {
373
380
  return 'numeric';
374
381
  }, [selectedSectionIndexes, state.sections]);
375
382
  const inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);
376
- const shouldShowPlaceholder = !inputHasFocus && valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
383
+ const areAllSectionsEmpty = valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
384
+ const shouldShowPlaceholder = !inputHasFocus && areAllSectionsEmpty;
377
385
  React.useImperativeHandle(unstableFieldRef, () => ({
378
386
  getSections: () => state.sections,
379
387
  getActiveSectionIndex: () => {
@@ -389,6 +397,14 @@ export const useField = params => {
389
397
  },
390
398
  setSelectedSections: activeSectionIndex => setSelectedSections(activeSectionIndex)
391
399
  }));
400
+ const handleClearValue = useEventCallback((event, ...args) => {
401
+ var _inputRef$current;
402
+ event.preventDefault();
403
+ onClear == null || onClear(event, ...args);
404
+ clearValue();
405
+ inputRef == null || (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
406
+ setSelectedSections(0);
407
+ });
392
408
  return _extends({
393
409
  placeholder,
394
410
  autoComplete: 'off'
@@ -403,7 +419,9 @@ export const useField = params => {
403
419
  onChange: handleInputChange,
404
420
  onKeyDown: handleInputKeyDown,
405
421
  onMouseUp: handleInputMouseUp,
422
+ onClear: handleClearValue,
406
423
  error: inputError,
407
- ref: handleRef
424
+ ref: handleRef,
425
+ clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly)
408
426
  });
409
427
  };
@@ -1,4 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { SlotComponentProps } from '@mui/base/utils';
3
+ import IconButton from '@mui/material/IconButton';
4
+ import { ClearIcon } from '../../../icons';
2
5
  import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, FieldValueType, PickersTimezone } from '../../../models';
3
6
  import type { PickerValueManager } from '../usePicker';
4
7
  import { InferError, Validator } from '../useValidation';
@@ -93,6 +96,15 @@ export interface UseFieldInternalProps<TValue, TDate, TSection extends FieldSect
93
96
  * The ref object used to imperatively interact with the field.
94
97
  */
95
98
  unstableFieldRef?: React.Ref<FieldRef<TSection>>;
99
+ /**
100
+ * Callback fired when the clear button is clicked.
101
+ */
102
+ onClear?: React.MouseEventHandler;
103
+ /**
104
+ * If `true`, a clear button will be shown in the field allowing value clearing.
105
+ * @default false
106
+ */
107
+ clearable?: boolean;
96
108
  }
97
109
  export interface FieldRef<TSection extends FieldSection> {
98
110
  /**
@@ -116,10 +128,12 @@ export interface UseFieldForwardedProps {
116
128
  onKeyDown?: React.KeyboardEventHandler;
117
129
  onMouseUp?: React.MouseEventHandler;
118
130
  onPaste?: React.ClipboardEventHandler<HTMLInputElement>;
119
- onClick?: () => void;
131
+ onClick?: React.MouseEventHandler;
120
132
  onFocus?: () => void;
121
133
  onBlur?: () => void;
122
134
  error?: boolean;
135
+ onClear?: React.MouseEventHandler;
136
+ clearable?: boolean;
123
137
  }
124
138
  export type UseFieldResponse<TForwardedProps extends UseFieldForwardedProps> = Omit<TForwardedProps, keyof UseFieldForwardedProps> & Required<UseFieldForwardedProps> & Pick<React.HTMLAttributes<HTMLInputElement>, 'autoCorrect' | 'inputMode' | 'placeholder'> & {
125
139
  ref: React.Ref<HTMLInputElement>;
@@ -298,4 +312,20 @@ export type SectionOrdering = {
298
312
  */
299
313
  endIndex: number;
300
314
  };
315
+ export interface FieldSlotsComponents {
316
+ /**
317
+ * Icon to display inside the clear button.
318
+ * @default ClearIcon
319
+ */
320
+ ClearIcon?: React.ElementType;
321
+ /**
322
+ * Button to clear the value.
323
+ * @default IconButton
324
+ */
325
+ ClearButton?: React.ElementType;
326
+ }
327
+ export interface FieldSlotsComponentsProps {
328
+ clearIcon?: SlotComponentProps<typeof ClearIcon, {}, {}>;
329
+ clearButton?: SlotComponentProps<typeof IconButton, {}, {}>;
330
+ }
301
331
  export {};
@@ -385,15 +385,20 @@ export const splitFormatIntoSections = (utils, timezone, localeText, format, dat
385
385
  const escapedParts = getEscapedPartsFromFormat(utils, expandedFormat);
386
386
 
387
387
  // This RegExp test if the beginning of a string correspond to a supported token
388
- const isTokenStartRegExp = new RegExp(`^(${Object.keys(utils.formatTokenMap).join('|')})`);
388
+ const isTokenStartRegExp = new RegExp(`^(${Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length) // Sort to put longest word first
389
+ .join('|')})`, 'g') // used to get access to lastIndex state
390
+ ;
391
+
389
392
  let currentTokenValue = '';
390
393
  for (let i = 0; i < expandedFormat.length; i += 1) {
391
394
  const escapedPartOfCurrentChar = escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
392
395
  const char = expandedFormat[i];
393
396
  const isEscapedChar = escapedPartOfCurrentChar != null;
394
397
  const potentialToken = `${currentTokenValue}${expandedFormat.slice(i)}`;
395
- if (!isEscapedChar && char.match(/([A-Za-z]+)/) && isTokenStartRegExp.test(potentialToken)) {
396
- currentTokenValue += char;
398
+ const regExpMatch = isTokenStartRegExp.test(potentialToken);
399
+ if (!isEscapedChar && char.match(/([A-Za-z]+)/) && regExpMatch) {
400
+ currentTokenValue = potentialToken.slice(0, isTokenStartRegExp.lastIndex);
401
+ i += isTokenStartRegExp.lastIndex - 1;
397
402
  } else {
398
403
  // If we are on the opening or closing character of an escaped part of the format,
399
404
  // Then we ignore this character.
@@ -24,7 +24,7 @@ export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
24
24
  export { useControlledValueWithTimezone } from './hooks/useValueWithTimezone';
25
25
  export type { DesktopOnlyPickerProps } from './hooks/useDesktopPicker';
26
26
  export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections, } from './hooks/useField';
27
- export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldForwardedProps, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
27
+ export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldForwardedProps, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext, FieldSlotsComponents, FieldSlotsComponentsProps, } from './hooks/useField';
28
28
  export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
29
29
  export { usePicker } from './hooks/usePicker';
30
30
  export type { UsePickerResponse, UsePickerParams, UsePickerProps } from './hooks/usePicker';
@@ -1,4 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { SxProps } from '@mui/system';
3
+ import { Theme } from '@mui/material/styles';
2
4
  import { DateOrTimeViewWithMeridiem } from '../common';
3
5
  export interface BaseToolbarProps<TValue, TView extends DateOrTimeViewWithMeridiem> extends ExportedBaseToolbarProps {
4
6
  isLandscape: boolean;
@@ -38,4 +40,5 @@ export interface ExportedBaseToolbarProps {
38
40
  * @default `true` for Desktop, `false` for Mobile.
39
41
  */
40
42
  hidden?: boolean;
43
+ sx?: SxProps<Theme>;
41
44
  }
@@ -78,6 +78,9 @@ export interface BaseDateValidationProps<TDate> extends FutureAndPastValidationP
78
78
  export interface DayValidationProps<TDate> {
79
79
  /**
80
80
  * Disable specific date.
81
+ *
82
+ * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
83
+ *
81
84
  * @template TDate
82
85
  * @param {TDate} day The date to test.
83
86
  * @returns {boolean} If `true` the date will be disabled.
@@ -23,4 +23,5 @@ export declare const resolveDateFormat: (utils: MuiPickersAdapter<any>, { format
23
23
  format?: string | undefined;
24
24
  views: readonly DateView[];
25
25
  }, isInToolbar: boolean) => string;
26
+ export declare const getWeekdays: <TDate>(utils: MuiPickersAdapter<TDate, any>, date: TDate) => TDate[];
26
27
  export {};
@@ -116,4 +116,8 @@ export const resolveDateFormat = (utils, {
116
116
  return /en/.test(utils.getCurrentLocaleCode()) ? formats.normalDateWithWeekday : formats.normalDate;
117
117
  }
118
118
  return formats.keyboardDate;
119
+ };
120
+ export const getWeekdays = (utils, date) => {
121
+ const start = utils.startOfWeek(date);
122
+ return [0, 1, 2, 3, 4, 5, 6].map(diff => utils.addDays(start, diff));
119
123
  };
@@ -384,9 +384,10 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
384
384
  componentsProps: PropTypes.object,
385
385
  /**
386
386
  * Formats the day of week displayed in the calendar header.
387
- * @param {string} day The day of week provided by the adapter's method `getWeekdays`.
387
+ * @param {string} day The day of week provided by the adapter. Deprecated, will be removed in v7: Use `date` instead.
388
+ * @param {TDate} date The date of the day of week provided by the adapter.
388
389
  * @returns {string} The name to display.
389
- * @default (day) => day.charAt(0).toUpperCase()
390
+ * @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
390
391
  */
391
392
  dayOfWeekFormatter: PropTypes.func,
392
393
  /**
@@ -512,6 +513,9 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
512
513
  renderLoading: PropTypes.func,
513
514
  /**
514
515
  * Disable specific date.
516
+ *
517
+ * Warning: This function can be called multiple times (e.g. when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
518
+ *
515
519
  * @template TDate
516
520
  * @param {TDate} day The date to test.
517
521
  * @returns {boolean} If `true` the date will be disabled.