@mui/x-date-pickers 8.0.0-alpha.12 → 8.0.0-alpha.14

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 (299) hide show
  1. package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
  2. package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +96 -94
  3. package/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
  4. package/AdapterDateFnsV2/AdapterDateFnsV2.js +96 -94
  5. package/AdapterDayjs/AdapterDayjs.js +11 -5
  6. package/CHANGELOG.md +430 -0
  7. package/DateCalendar/DateCalendar.js +1 -1
  8. package/DateField/useDateField.d.ts +1 -1
  9. package/DatePicker/DatePicker.types.d.ts +2 -2
  10. package/DatePicker/shared.d.ts +1 -1
  11. package/DateTimeField/useDateTimeField.d.ts +1 -1
  12. package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  13. package/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
  14. package/DateTimePicker/DateTimePickerToolbar.js +1 -1
  15. package/DateTimePicker/shared.d.ts +18 -10
  16. package/DateTimePicker/shared.js +23 -2
  17. package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -11
  18. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
  19. package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
  20. package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
  21. package/MobileDateTimePicker/MobileDateTimePicker.js +61 -6
  22. package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
  23. package/PickersTextField/PickersTextField.js +3 -1
  24. package/StaticDateTimePicker/StaticDateTimePicker.js +60 -6
  25. package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
  26. package/TimeClock/Clock.js +2 -2
  27. package/TimeClock/ClockPointer.js +1 -1
  28. package/TimeField/useTimeField.d.ts +1 -1
  29. package/TimePicker/TimePicker.types.d.ts +2 -2
  30. package/TimePicker/shared.d.ts +1 -1
  31. package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
  32. package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
  33. package/esm/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
  34. package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
  35. package/esm/AdapterDayjs/AdapterDayjs.js +9 -5
  36. package/esm/DateCalendar/DateCalendar.js +1 -1
  37. package/esm/DateField/useDateField.d.ts +1 -1
  38. package/esm/DatePicker/DatePicker.types.d.ts +2 -2
  39. package/esm/DatePicker/shared.d.ts +1 -1
  40. package/esm/DateTimeField/useDateTimeField.d.ts +1 -1
  41. package/esm/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  42. package/esm/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
  43. package/esm/DateTimePicker/DateTimePickerToolbar.js +1 -1
  44. package/esm/DateTimePicker/shared.d.ts +18 -10
  45. package/esm/DateTimePicker/shared.js +23 -2
  46. package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
  47. package/esm/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
  48. package/esm/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
  49. package/esm/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
  50. package/esm/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
  51. package/esm/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
  52. package/esm/PickersTextField/PickersTextField.js +3 -1
  53. package/esm/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
  54. package/esm/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
  55. package/esm/TimeClock/Clock.js +2 -2
  56. package/esm/TimeClock/ClockPointer.js +1 -1
  57. package/esm/TimeField/useTimeField.d.ts +1 -1
  58. package/esm/TimePicker/TimePicker.types.d.ts +2 -2
  59. package/esm/TimePicker/shared.d.ts +1 -1
  60. package/esm/hooks/useSplitFieldProps.d.ts +1 -1
  61. package/esm/hooks/useSplitFieldProps.js +1 -1
  62. package/esm/index.js +1 -1
  63. package/esm/internals/components/PickerFieldUI.d.ts +7 -0
  64. package/esm/internals/components/PickerFieldUI.js +8 -4
  65. package/esm/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
  66. package/esm/internals/components/PickerPopper/PickerPopper.js +26 -14
  67. package/esm/internals/components/PickerProvider.d.ts +158 -7
  68. package/esm/internals/components/PickerProvider.js +7 -2
  69. package/esm/internals/demo/DemoContainer.js +3 -3
  70. package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
  71. package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
  72. package/esm/internals/hooks/useField/index.d.ts +1 -2
  73. package/esm/internals/hooks/useField/useField.js +7 -8
  74. package/esm/internals/hooks/useField/useField.types.d.ts +56 -47
  75. package/esm/internals/hooks/useField/useField.utils.js +4 -1
  76. package/esm/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
  77. package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
  78. package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
  79. package/esm/internals/hooks/useField/useFieldState.d.ts +2 -1
  80. package/esm/internals/hooks/useField/useFieldState.js +136 -83
  81. package/esm/internals/hooks/useField/useFieldV6TextField.js +9 -7
  82. package/esm/internals/hooks/useField/useFieldV7TextField.js +9 -8
  83. package/esm/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
  84. package/esm/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
  85. package/esm/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
  86. package/esm/internals/hooks/useNullableFieldPrivateContext.js +5 -0
  87. package/esm/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
  88. package/esm/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
  89. package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
  90. package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
  91. package/esm/internals/hooks/usePicker/index.d.ts +1 -3
  92. package/esm/internals/hooks/usePicker/usePicker.d.ts +5 -5
  93. package/esm/internals/hooks/usePicker/usePicker.js +276 -34
  94. package/esm/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
  95. package/esm/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
  96. package/esm/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
  97. package/esm/internals/hooks/useValueWithTimezone.d.ts +1 -1
  98. package/esm/internals/index.d.ts +7 -9
  99. package/esm/internals/index.js +2 -1
  100. package/esm/internals/models/fields.d.ts +3 -10
  101. package/esm/internals/models/manager.d.ts +108 -4
  102. package/esm/internals/models/props/basePickerProps.d.ts +2 -2
  103. package/esm/internals/models/props/time.d.ts +1 -1
  104. package/esm/internals/utils/date-time-utils.d.ts +2 -2
  105. package/esm/internals/utils/valueManagers.d.ts +1 -1
  106. package/esm/internals/utils/valueManagers.js +10 -18
  107. package/esm/locales/bnBD.d.ts +80 -0
  108. package/esm/locales/bnBD.js +73 -0
  109. package/esm/locales/index.d.ts +1 -0
  110. package/esm/locales/index.js +1 -0
  111. package/esm/managers/useDateManager.d.ts +3 -4
  112. package/esm/managers/useDateTimeManager.d.ts +3 -4
  113. package/esm/managers/useTimeManager.d.ts +3 -4
  114. package/esm/models/adapters.d.ts +2 -1
  115. package/esm/models/fields.d.ts +2 -2
  116. package/esm/models/manager.d.ts +4 -5
  117. package/esm/validation/extractValidationProps.d.ts +1 -1
  118. package/esm/validation/index.d.ts +1 -1
  119. package/esm/validation/useValidation.d.ts +2 -2
  120. package/hooks/useSplitFieldProps.d.ts +1 -1
  121. package/hooks/useSplitFieldProps.js +1 -1
  122. package/index.js +1 -1
  123. package/internals/components/PickerFieldUI.d.ts +7 -0
  124. package/internals/components/PickerFieldUI.js +9 -3
  125. package/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
  126. package/internals/components/PickerPopper/PickerPopper.js +25 -13
  127. package/internals/components/PickerProvider.d.ts +158 -7
  128. package/internals/components/PickerProvider.js +8 -3
  129. package/internals/demo/DemoContainer.js +3 -3
  130. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
  131. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
  132. package/internals/hooks/useField/index.d.ts +1 -2
  133. package/internals/hooks/useField/useField.js +7 -8
  134. package/internals/hooks/useField/useField.types.d.ts +56 -47
  135. package/internals/hooks/useField/useField.utils.js +4 -1
  136. package/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
  137. package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
  138. package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -10
  139. package/internals/hooks/useField/useFieldState.d.ts +2 -1
  140. package/internals/hooks/useField/useFieldState.js +135 -82
  141. package/internals/hooks/useField/useFieldV6TextField.js +9 -7
  142. package/internals/hooks/useField/useFieldV7TextField.js +9 -8
  143. package/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
  144. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
  145. package/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
  146. package/internals/hooks/useNullableFieldPrivateContext.js +13 -0
  147. package/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
  148. package/internals/hooks/usePicker/hooks/useOrientation.js +42 -0
  149. package/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
  150. package/internals/hooks/usePicker/{usePickerValue.js → hooks/useValueAndOpenStates.js} +97 -114
  151. package/internals/hooks/usePicker/index.d.ts +1 -3
  152. package/internals/hooks/usePicker/usePicker.d.ts +5 -5
  153. package/internals/hooks/usePicker/usePicker.js +278 -34
  154. package/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
  155. package/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
  156. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
  157. package/internals/hooks/useValueWithTimezone.d.ts +1 -1
  158. package/internals/index.d.ts +7 -9
  159. package/internals/index.js +19 -0
  160. package/internals/models/fields.d.ts +3 -10
  161. package/internals/models/manager.d.ts +108 -4
  162. package/internals/models/props/basePickerProps.d.ts +2 -2
  163. package/internals/models/props/time.d.ts +1 -1
  164. package/internals/utils/date-time-utils.d.ts +2 -2
  165. package/internals/utils/valueManagers.d.ts +1 -1
  166. package/internals/utils/valueManagers.js +10 -18
  167. package/locales/bnBD.d.ts +80 -0
  168. package/locales/bnBD.js +79 -0
  169. package/locales/index.d.ts +1 -0
  170. package/locales/index.js +11 -0
  171. package/managers/useDateManager.d.ts +3 -4
  172. package/managers/useDateTimeManager.d.ts +3 -4
  173. package/managers/useTimeManager.d.ts +3 -4
  174. package/models/adapters.d.ts +2 -1
  175. package/models/fields.d.ts +2 -2
  176. package/models/manager.d.ts +4 -5
  177. package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
  178. package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
  179. package/modern/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
  180. package/modern/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
  181. package/modern/AdapterDayjs/AdapterDayjs.js +9 -5
  182. package/modern/DateCalendar/DateCalendar.js +1 -1
  183. package/modern/DateField/useDateField.d.ts +1 -1
  184. package/modern/DatePicker/DatePicker.types.d.ts +2 -2
  185. package/modern/DatePicker/shared.d.ts +1 -1
  186. package/modern/DateTimeField/useDateTimeField.d.ts +1 -1
  187. package/modern/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  188. package/modern/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
  189. package/modern/DateTimePicker/DateTimePickerToolbar.js +1 -1
  190. package/modern/DateTimePicker/shared.d.ts +18 -10
  191. package/modern/DateTimePicker/shared.js +23 -2
  192. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -12
  193. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -7
  194. package/modern/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
  195. package/modern/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -2
  196. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +62 -7
  197. package/modern/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -3
  198. package/modern/PickersTextField/PickersTextField.js +3 -1
  199. package/modern/StaticDateTimePicker/StaticDateTimePicker.js +61 -7
  200. package/modern/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +1 -2
  201. package/modern/TimeClock/Clock.js +2 -2
  202. package/modern/TimeClock/ClockPointer.js +1 -1
  203. package/modern/TimeField/useTimeField.d.ts +1 -1
  204. package/modern/TimePicker/TimePicker.types.d.ts +2 -2
  205. package/modern/TimePicker/shared.d.ts +1 -1
  206. package/modern/hooks/useSplitFieldProps.d.ts +1 -1
  207. package/modern/hooks/useSplitFieldProps.js +1 -1
  208. package/modern/index.js +1 -1
  209. package/modern/internals/components/PickerFieldUI.d.ts +7 -0
  210. package/modern/internals/components/PickerFieldUI.js +8 -4
  211. package/modern/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
  212. package/modern/internals/components/PickerPopper/PickerPopper.js +26 -14
  213. package/modern/internals/components/PickerProvider.d.ts +158 -7
  214. package/modern/internals/components/PickerProvider.js +7 -2
  215. package/modern/internals/demo/DemoContainer.js +3 -3
  216. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
  217. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +4 -12
  218. package/modern/internals/hooks/useField/index.d.ts +1 -2
  219. package/modern/internals/hooks/useField/useField.js +7 -8
  220. package/modern/internals/hooks/useField/useField.types.d.ts +56 -47
  221. package/modern/internals/hooks/useField/useField.utils.js +4 -1
  222. package/modern/internals/hooks/useField/useFieldCharacterEditing.js +2 -2
  223. package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
  224. package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
  225. package/modern/internals/hooks/useField/useFieldState.d.ts +2 -1
  226. package/modern/internals/hooks/useField/useFieldState.js +136 -83
  227. package/modern/internals/hooks/useField/useFieldV6TextField.js +9 -7
  228. package/modern/internals/hooks/useField/useFieldV7TextField.js +9 -8
  229. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
  230. package/modern/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +4 -7
  231. package/modern/internals/hooks/useNullableFieldPrivateContext.d.ts +9 -0
  232. package/modern/internals/hooks/useNullableFieldPrivateContext.js +5 -0
  233. package/modern/internals/hooks/usePicker/hooks/useOrientation.d.ts +2 -0
  234. package/modern/internals/hooks/usePicker/hooks/useOrientation.js +34 -0
  235. package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.d.ts +19 -0
  236. package/modern/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +210 -0
  237. package/modern/internals/hooks/usePicker/index.d.ts +1 -3
  238. package/modern/internals/hooks/usePicker/usePicker.d.ts +5 -5
  239. package/modern/internals/hooks/usePicker/usePicker.js +276 -34
  240. package/modern/internals/hooks/usePicker/usePicker.types.d.ts +181 -9
  241. package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
  242. package/modern/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +3 -4
  243. package/modern/internals/hooks/useValueWithTimezone.d.ts +1 -1
  244. package/modern/internals/index.d.ts +7 -9
  245. package/modern/internals/index.js +2 -1
  246. package/modern/internals/models/fields.d.ts +3 -10
  247. package/modern/internals/models/manager.d.ts +108 -4
  248. package/modern/internals/models/props/basePickerProps.d.ts +2 -2
  249. package/modern/internals/models/props/time.d.ts +1 -1
  250. package/modern/internals/utils/date-time-utils.d.ts +2 -2
  251. package/modern/internals/utils/valueManagers.d.ts +1 -1
  252. package/modern/internals/utils/valueManagers.js +10 -18
  253. package/modern/locales/bnBD.d.ts +80 -0
  254. package/modern/locales/bnBD.js +73 -0
  255. package/modern/locales/index.d.ts +1 -0
  256. package/modern/locales/index.js +1 -0
  257. package/modern/managers/useDateManager.d.ts +3 -4
  258. package/modern/managers/useDateTimeManager.d.ts +3 -4
  259. package/modern/managers/useTimeManager.d.ts +3 -4
  260. package/modern/models/adapters.d.ts +2 -1
  261. package/modern/models/fields.d.ts +2 -2
  262. package/modern/models/manager.d.ts +4 -5
  263. package/modern/validation/extractValidationProps.d.ts +1 -1
  264. package/modern/validation/index.d.ts +1 -1
  265. package/modern/validation/useValidation.d.ts +2 -2
  266. package/package.json +2 -2
  267. package/tsconfig.build.tsbuildinfo +1 -1
  268. package/validation/extractValidationProps.d.ts +1 -1
  269. package/validation/index.d.ts +1 -1
  270. package/validation/useValidation.d.ts +2 -2
  271. package/esm/internals/hooks/useOpenState.d.ts +0 -14
  272. package/esm/internals/hooks/useOpenState.js +0 -37
  273. package/esm/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
  274. package/esm/internals/hooks/usePicker/usePickerProvider.js +0 -111
  275. package/esm/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
  276. package/esm/internals/hooks/usePicker/usePickerValue.js +0 -226
  277. package/esm/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
  278. package/esm/internals/hooks/usePicker/usePickerValue.types.js +0 -1
  279. package/esm/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
  280. package/esm/internals/hooks/usePicker/usePickerViews.js +0 -176
  281. package/internals/hooks/useOpenState.d.ts +0 -14
  282. package/internals/hooks/useOpenState.js +0 -46
  283. package/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
  284. package/internals/hooks/usePicker/usePickerProvider.js +0 -121
  285. package/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
  286. package/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
  287. package/internals/hooks/usePicker/usePickerValue.types.js +0 -5
  288. package/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
  289. package/internals/hooks/usePicker/usePickerViews.js +0 -183
  290. package/modern/internals/hooks/useOpenState.d.ts +0 -14
  291. package/modern/internals/hooks/useOpenState.js +0 -37
  292. package/modern/internals/hooks/usePicker/usePickerProvider.d.ts +0 -60
  293. package/modern/internals/hooks/usePicker/usePickerProvider.js +0 -111
  294. package/modern/internals/hooks/usePicker/usePickerValue.d.ts +0 -12
  295. package/modern/internals/hooks/usePicker/usePickerValue.js +0 -226
  296. package/modern/internals/hooks/usePicker/usePickerValue.types.d.ts +0 -327
  297. package/modern/internals/hooks/usePicker/usePickerValue.types.js +0 -1
  298. package/modern/internals/hooks/usePicker/usePickerViews.d.ts +0 -120
  299. package/modern/internals/hooks/usePicker/usePickerViews.js +0 -176
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
3
  import { Theme } from '@mui/material/styles';
4
- import { PickerOwnerState } from "../../models/index.js";
4
+ import { PickerChangeImportance, PickerOwnerState, PickersTimezone } from "../../models/index.js";
5
5
  import { PickersInputLocaleText } from "../../locales/index.js";
6
6
  import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from "../models/index.js";
7
- import type { UsePickerValueActionsContextValue, UsePickerValueContextValue, UsePickerValuePrivateContextValue } from '../hooks/usePicker/usePickerValue.types';
8
- import { UsePickerViewsActionsContextValue, UsePickerViewsContextValue, UsePickerViewsPrivateContextValue } from "../hooks/usePicker/usePickerViews.js";
9
- import { PickerFieldPrivateContextValue } from "../hooks/useField/useFieldInternalPropsWithDefaults.js";
7
+ import { PickerFieldPrivateContextValue } from "../hooks/useNullableFieldPrivateContext.js";
8
+ import type { PickersShortcutsItemContext } from '../../PickersShortcuts';
10
9
  export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
11
10
  export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
12
11
  /**
@@ -26,7 +25,24 @@ export interface PickerProviderProps<TValue extends PickerValidValue> {
26
25
  localeText: PickersInputLocaleText | undefined;
27
26
  children: React.ReactNode;
28
27
  }
29
- export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends UsePickerValueContextValue<TValue, TError>, UsePickerViewsContextValue<TView> {
28
+ export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends PickerActionsContextValue<TValue, TView, TError> {
29
+ /**
30
+ * The current value of the picker.
31
+ */
32
+ value: TValue;
33
+ /**
34
+ * The timezone to use when rendering the dates.
35
+ * If a `timezone` prop is provided, it will be used.
36
+ * If the `value` prop contains a valid date, its timezone will be used.
37
+ * If no `value` prop is provided, but the `defaultValue` contains a valid date, its timezone will be used.
38
+ * If no `value` or `defaultValue` is provided, but the `referenceDate` is provided, its timezone will be used.
39
+ * Otherwise, the timezone will be the default one of your date library.
40
+ */
41
+ timezone: PickersTimezone;
42
+ /**
43
+ * Whether the picker is open.
44
+ */
45
+ open: boolean;
30
46
  /**
31
47
  * Whether the picker is disabled.
32
48
  */
@@ -35,6 +51,31 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
35
51
  * Whether the picker is read-only.
36
52
  */
37
53
  readOnly: boolean;
54
+ /**
55
+ * Whether the picker should be focused on mount.
56
+ * If the picker has a field and is not open, the field should be focused.
57
+ * If the picker does not have a field (if it is a static picker) or is not open, the view should be focused.
58
+ */
59
+ autoFocus: boolean;
60
+ /**
61
+ * The views that the picker has to render.
62
+ * It is equal to the picker `views` prop—if defined.
63
+ * Otherwise, a default set of views is provided based on the component you are using:
64
+ * - Date Pickers: ['year', 'day']
65
+ * - Time Pickers: ['hours', 'minutes']
66
+ * - Date Time Pickers: ['year', 'day', 'hours', 'minutes']
67
+ * - Date Range Pickers: ['day']
68
+ * - Date Time Range Pickers: ['day', 'hours', 'minutes']
69
+ */
70
+ views: readonly TView[];
71
+ /**
72
+ * The currently rendered view.
73
+ */
74
+ view: TView | null;
75
+ /**
76
+ * The view showed when first opening the picker.
77
+ */
78
+ initialView: TView | null;
38
79
  /**
39
80
  * The responsive variant of the picker.
40
81
  * It is equal to "desktop" when using a desktop picker (like <DesktopDatePicker />).
@@ -68,6 +109,11 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
68
109
  * If it is "enabled", the field should render an interactive UI to open the Picker.
69
110
  */
70
111
  triggerStatus: 'hidden' | 'disabled' | 'enabled';
112
+ /**
113
+ * The ref to attach to the popup's outermost element that contains the view, if any.
114
+ * When using a built-in popup component, this property is automatically attached to the appropriate element.
115
+ */
116
+ popupRef: React.RefObject<any>;
71
117
  /**
72
118
  * The format to use when rendering the value in the field.
73
119
  * It is equal to the picker `format` prop if defined.
@@ -111,10 +157,115 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
111
157
  */
112
158
  rootRef: React.ForwardedRef<HTMLDivElement> | undefined;
113
159
  }
114
- export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string | null> extends UsePickerValueActionsContextValue<TValue, TError>, UsePickerViewsActionsContextValue<TView> {}
115
- export interface PickerPrivateContextValue extends UsePickerValuePrivateContextValue, UsePickerViewsPrivateContextValue {
160
+ export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string | null> {
161
+ /**
162
+ * Set the current value of the picker.
163
+ * @param {TValue} value The new value of the picker.
164
+ * @param {SetValueActionOptions<TError>} options The options to customize the behavior of this update.
165
+ */
166
+ setValue: (value: TValue, options?: SetValueActionOptions<TError>) => void;
167
+ /**
168
+ * Set the current open state of the Picker.
169
+ * It can be a function that will receive the current open state as parameter.
170
+ * ```ts
171
+ * setOpen(true); // Opens the picker.
172
+ * setOpen(false); // Closes the picker.
173
+ * setOpen((prevOpen) => !prevOpen); // Toggles the open state.
174
+ * ```
175
+ * @param {React.SetStateAction<boolean>} action The new open state of the Picker.
176
+ */
177
+ setOpen: React.Dispatch<React.SetStateAction<boolean>>;
178
+ /**
179
+ * Set the current view.
180
+ * @template TView
181
+ * @param {TView} view The view to render
182
+ */
183
+ setView: (view: TView) => void;
184
+ /**
185
+ * Set the current value of the picker to be empty.
186
+ * The value will be `null` on single pickers and `[null, null]` on range pickers.
187
+ */
188
+ clearValue: () => void;
189
+ /**
190
+ * Set the current value of the picker to be the current date.
191
+ * The value will be `today` on single pickers and `[today, today]` on range pickers.
192
+ * With `today` being the current date, with its time set to `00:00:00` on Date Pickers and its time set to the current time on Time and Date Pickers.
193
+ */
194
+ setValueToToday: () => void;
195
+ /**
196
+ * Accept the current value of the picker.
197
+ * Will call `onAccept` if defined.
198
+ * If the picker is re-opened, this value will be the one used to initialize the views.
199
+ */
200
+ acceptValueChanges: () => void;
201
+ /**
202
+ * Cancel the changes made to the current value of the picker.
203
+ * The value will be reset to the last accepted value.
204
+ */
205
+ cancelValueChanges: () => void;
206
+ }
207
+ export interface SetValueActionOptions<TError = string | null> {
208
+ /**
209
+ * The importance of the change when picking a value:
210
+ * - "accept": fires `onChange`, fires `onAccept` and closes the picker.
211
+ * - "set": fires `onChange` but do not fire `onAccept` and does not close the picker.
212
+ * @default "accept"
213
+ */
214
+ changeImportance?: PickerChangeImportance;
215
+ /**
216
+ * The validation error associated to the current value.
217
+ * If not defined, the validation will be computed by the picker.
218
+ */
219
+ validationError?: TError;
220
+ /**
221
+ * The shortcut that triggered this change.
222
+ * It should not be defined if the change does not come from a shortcut.
223
+ */
224
+ shortcut?: PickersShortcutsItemContext;
225
+ /**
226
+ * Whether the value should call `onChange` and `onAccept` when the value is not controlled and has never been modified.
227
+ * If `true`, the `onChange` and `onAccept` callback will only be fired if the value has been modified (and is not equal to the last published value).
228
+ * If `false`, the `onChange` and `onAccept` callback will be fired when the value has never been modified (`onAccept` only if `changeImportance` is set to "accept").
229
+ * @default false
230
+ */
231
+ skipPublicationIfPristine?: boolean;
232
+ /**
233
+ * Whether the picker should close.
234
+ * @default changeImportance === "accept"
235
+ */
236
+ shouldClose?: boolean;
237
+ }
238
+ export interface PickerPrivateContextValue {
116
239
  /**
117
240
  * The ownerState of the picker.
118
241
  */
119
242
  ownerState: PickerOwnerState;
243
+ /**
244
+ * The ref of the root element.
245
+ * This is the object counterpart of the `usePickerContext().rootRef` property which can be a function.
246
+ */
247
+ rootRefObject: React.RefObject<HTMLDivElement | null>;
248
+ /**
249
+ * The id of the label element.
250
+ */
251
+ labelId: string | undefined;
252
+ dismissViews: () => void;
253
+ /**
254
+ * Whether at least one view has an UI (it has a view renderer associated).
255
+ */
256
+ hasUIView: boolean;
257
+ /**
258
+ * Return the mode of the current view.
259
+ * @returns {boolean} The mode of the current view.
260
+ */
261
+ getCurrentViewMode: () => 'UI' | 'field';
262
+ /**
263
+ * The aria role associated with the view container.
264
+ * It is equal to "dialog" when the view is rendered inside a `@mui/material/Dialog`.
265
+ * It is equal to "dialog" when the view is rendered inside a `@mui/material/Popper` and the focus is trapped inside the view.
266
+ * It is equal to "tooltip" when the view is rendered inside a `@mui/material/Popper` and the focus remains inside the field.
267
+ * It is always equal to null if the picker does not have a field (static pickers).
268
+ * It is always equal to null if the component you are accessing the context from is not wrapped by a picker.
269
+ */
270
+ viewContainerRole: 'dialog' | 'tooltip' | null;
120
271
  }
@@ -9,7 +9,7 @@ exports.PickerProvider = PickerProvider;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _LocalizationProvider = require("../../LocalizationProvider");
11
11
  var _useIsValidValue = require("../../hooks/useIsValidValue");
12
- var _useFieldInternalPropsWithDefaults = require("../hooks/useField/useFieldInternalPropsWithDefaults");
12
+ var _useNullableFieldPrivateContext = require("../hooks/useNullableFieldPrivateContext");
13
13
  var _usePickerContext = require("../../hooks/usePickerContext");
14
14
  var _jsxRuntime = require("react/jsx-runtime");
15
15
  const PickerActionsContext = exports.PickerActionsContext = /*#__PURE__*/React.createContext(null);
@@ -24,7 +24,12 @@ const PickerPrivateContext = exports.PickerPrivateContext = /*#__PURE__*/React.c
24
24
  },
25
25
  dismissViews: () => {},
26
26
  hasUIView: true,
27
- doesTheCurrentViewHasAnUI: () => true
27
+ getCurrentViewMode: () => 'UI',
28
+ rootRefObject: {
29
+ current: null
30
+ },
31
+ viewContainerRole: null,
32
+ labelId: undefined
28
33
  });
29
34
 
30
35
  /**
@@ -50,7 +55,7 @@ function PickerProvider(props) {
50
55
  value: actionsContextValue,
51
56
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PickerPrivateContext.Provider, {
52
57
  value: privateContextValue,
53
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useFieldInternalPropsWithDefaults.PickerFieldPrivateContext.Provider, {
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useNullableFieldPrivateContext.PickerFieldPrivateContext.Provider, {
54
59
  value: fieldPrivateContextValue,
55
60
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useIsValidValue.IsValidValueContext.Provider, {
56
61
  value: isValidContextValue,
@@ -24,10 +24,10 @@ const getChildTypeFromChildName = childName => {
24
24
  if (childName.match(/^Static([A-Za-z]+)/) || childName.match(/^([A-Za-z]+)(Calendar|Clock)$/)) {
25
25
  return 'UI-view';
26
26
  }
27
- if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/) || childName.match(/^([A-Za-z]+)RangePicker$/)) {
27
+ if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)) {
28
28
  return 'multi-input-range-field';
29
29
  }
30
- if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/)) {
30
+ if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/) || childName.match(/^([A-Za-z]+)RangePicker$/)) {
31
31
  return 'single-input-range-field';
32
32
  }
33
33
  return 'single-input-field';
@@ -142,7 +142,7 @@ function DemoContainer(props) {
142
142
  minWidth: {
143
143
  xs: 300,
144
144
  // If demo also contains MultiInputDateTimeRangeField, increase width to avoid cutting off the value.
145
- md: childrenTypes.has('multi-input-range-field') ? 460 : 400
145
+ md: childrenTypes.has('multi-input-range-field') ? 460 : 440
146
146
  }
147
147
  }
148
148
  };
@@ -10,8 +10,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
13
- var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
14
- var _useId = _interopRequireDefault(require("@mui/utils/useId"));
15
13
  var _PickerPopper = require("../../components/PickerPopper/PickerPopper");
16
14
  var _usePicker = require("../usePicker");
17
15
  var _PickersLayout = require("../../../PickersLayout");
@@ -36,35 +34,26 @@ const useDesktopPicker = _ref => {
36
34
  slotProps: innerSlotProps,
37
35
  label,
38
36
  inputRef,
39
- readOnly,
40
- autoFocus,
41
37
  localeText
42
38
  } = props;
43
- const fieldRef = React.useRef(null);
44
- const labelId = (0, _useId.default)();
45
- const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
46
39
  const {
47
40
  providerProps,
48
41
  renderCurrentView,
49
42
  ownerState
50
43
  } = (0, _usePicker.usePicker)((0, _extends2.default)({}, pickerParams, {
51
44
  props,
52
- fieldRef,
53
45
  localeText,
54
46
  autoFocusView: true,
47
+ viewContainerRole: 'dialog',
55
48
  variant: 'desktop'
56
49
  }));
50
+ const labelId = providerProps.privateContextValue.labelId;
51
+ const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
57
52
  const Field = slots.field;
58
53
  const _useSlotProps = (0, _useSlotProps2.default)({
59
54
  elementType: Field,
60
55
  externalSlotProps: innerSlotProps?.field,
61
- additionalProps: (0, _extends2.default)({
62
- // Internal props
63
- readOnly,
64
- autoFocus: autoFocus && !props.open,
65
- // Forwarded props
66
- focused: providerProps.contextValue.open ? true : undefined
67
- }, isToolbarHidden && {
56
+ additionalProps: (0, _extends2.default)({}, isToolbarHidden && {
68
57
  id: labelId
69
58
  }),
70
59
  ownerState
@@ -87,18 +76,12 @@ const useDesktopPicker = _ref => {
87
76
  'aria-labelledby': labelledById
88
77
  }, innerSlotProps?.popper)
89
78
  });
90
-
91
- // TODO: This `as any` will go away once the field ref is handled by the context.
92
- const handleFieldRef = (0, _useForkRef.default)(fieldRef, fieldProps.unstableFieldRef);
93
79
  const renderPicker = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerProvider.PickerProvider, (0, _extends2.default)({}, providerProps, {
94
80
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PickerFieldUI.PickerFieldUIContextProvider, {
95
81
  slots: slots,
96
82
  slotProps: slotProps,
97
83
  inputRef: inputRef,
98
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Field, (0, _extends2.default)({}, fieldProps, {
99
- unstableFieldRef: handleFieldRef
100
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerPopper.PickerPopper, {
101
- role: "dialog",
84
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Field, (0, _extends2.default)({}, fieldProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerPopper.PickerPopper, {
102
85
  slots: slots,
103
86
  slotProps: slotProps,
104
87
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, (0, _extends2.default)({}, slotProps?.layout, {
@@ -2,37 +2,29 @@ import * as React from 'react';
2
2
  import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
3
  import { BasePickerProps } from "../../models/props/basePickerProps.js";
4
4
  import { PickerPopperSlots, PickerPopperSlotProps } from "../../components/PickerPopper/PickerPopper.js";
5
- import { UsePickerParams } from "../usePicker/index.js";
5
+ import { UsePickerParameters, UsePickerNonStaticProps, UsePickerProps } from "../usePicker/index.js";
6
6
  import { PickerFieldSlotProps, PickerOwnerState } from "../../../models/index.js";
7
7
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from "../../../PickersLayout/PickersLayout.types.js";
8
- import { UsePickerValueNonStaticProps } from "../usePicker/usePickerValue.types.js";
9
- import { UsePickerViewsProps } from "../usePicker/usePickerViews.js";
10
8
  import { DateOrTimeViewWithMeridiem, PickerValue } from "../../models/index.js";
11
9
  import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from "../../components/PickerFieldUI.js";
12
- import { UsePickerProviderNonStaticProps } from "../usePicker/usePickerProvider.js";
13
10
  export interface UseDesktopPickerSlots extends Pick<PickerPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
14
11
  /**
15
12
  * Component used to enter the date with the keyboard.
16
13
  */
17
14
  field: React.ElementType;
18
- /**
19
- * Form control with an input to render the value inside the default field.
20
- * @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
21
- */
22
- textField?: React.ElementType;
23
15
  }
24
16
  export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickerPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
25
17
  field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
26
18
  }
27
19
  export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
28
- export interface DesktopOnlyPickerProps extends UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps {
20
+ export interface DesktopOnlyPickerProps extends UsePickerNonStaticProps {
29
21
  /**
30
22
  * If `true`, the `input` element is focused during the first mount.
31
23
  * @default false
32
24
  */
33
25
  autoFocus?: boolean;
34
26
  }
35
- export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
27
+ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
36
28
  /**
37
29
  * Overridable component slots.
38
30
  * @default {}
@@ -44,6 +36,6 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
44
36
  */
45
37
  slotProps?: UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>;
46
38
  }
47
- export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
39
+ export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
48
40
  props: TExternalProps;
49
41
  }
@@ -1,5 +1,4 @@
1
1
  export { useField } from "./useField.js";
2
2
  export type { FieldValueManager, UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext } from './useField.types';
3
3
  export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
4
- export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
5
- export type { PickerFieldPrivateContextValue } from './useFieldInternalPropsWithDefaults';
4
+ export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
@@ -37,7 +37,6 @@ const useField = params => {
37
37
  onClear
38
38
  },
39
39
  fieldValueManager,
40
- valueManager,
41
40
  validator,
42
41
  getOpenPickerButtonAriaLabel: getOpenDialogAriaText
43
42
  } = params;
@@ -45,6 +44,7 @@ const useField = params => {
45
44
  const stateResponse = (0, _useFieldState.useFieldState)(params);
46
45
  const {
47
46
  state,
47
+ value,
48
48
  activeSectionIndex,
49
49
  parsedSelectedSections,
50
50
  setSelectedSections,
@@ -67,7 +67,7 @@ const useField = params => {
67
67
  const {
68
68
  resetCharacterQuery
69
69
  } = characterEditingResponse;
70
- const areAllSectionsEmpty = valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
70
+ const areAllSectionsEmpty = React.useMemo(() => state.sections.every(section => section.value === ''), [state.sections]);
71
71
  const useFieldTextField = enableAccessibleFieldDOMStructure ? _useFieldV7TextField.useFieldV7TextField : _useFieldV6TextField.useFieldV6TextField;
72
72
  const sectionOrder = React.useMemo(() => (0, _useField.getSectionOrder)(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);
73
73
  const {
@@ -157,12 +157,11 @@ const useField = params => {
157
157
  setSelectedSections(activeSectionIndex);
158
158
  }
159
159
  const activeSection = state.sections[activeSectionIndex];
160
- const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
161
- const newSectionValue = (0, _useField.adjustSectionValue)(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {
160
+ const newSectionValue = (0, _useField.adjustSectionValue)(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, fieldValueManager.getDateFromSection(value, activeSection), {
162
161
  minutesStep
163
162
  });
164
163
  updateSectionValue({
165
- activeSection,
164
+ section: activeSection,
166
165
  newSectionValue,
167
166
  shouldGoToNextSection: false
168
167
  });
@@ -179,7 +178,7 @@ const useField = params => {
179
178
  props: internalProps,
180
179
  validator,
181
180
  timezone,
182
- value: state.value,
181
+ value,
183
182
  onError: internalProps.onError
184
183
  });
185
184
  const inputError = React.useMemo(() => {
@@ -233,8 +232,8 @@ const useField = params => {
233
232
  };
234
233
  const localizationContext = (0, _useUtils.useLocalizationContext)();
235
234
  const openPickerAriaLabel = React.useMemo(() => getOpenDialogAriaText((0, _extends2.default)({}, localizationContext, {
236
- value: state.value
237
- })), [getOpenDialogAriaText, state.value, localizationContext]);
235
+ value
236
+ })), [getOpenDialogAriaText, value, localizationContext]);
238
237
  const commonAdditionalProps = {
239
238
  disabled,
240
239
  readOnly,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, InferFieldSection, PickerValueType } from "../../../models/index.js";
3
- import type { PickerValueManager } from '../usePicker';
3
+ import type { PickerValueManager } from '../../models';
4
4
  import type { Validator } from '../../../validation';
5
5
  import type { UseFieldStateResponse } from './useFieldState';
6
6
  import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
@@ -96,6 +96,10 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
96
96
  * @default false
97
97
  */
98
98
  autoFocus?: boolean;
99
+ /**
100
+ * If `true`, the component is displayed in focused state.
101
+ */
102
+ focused?: boolean;
99
103
  }
100
104
  export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> {
101
105
  /**
@@ -110,21 +114,22 @@ export interface UseFieldCommonForwardedProps extends Pick<ExportedPickerFieldUI
110
114
  export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldCommonForwardedProps & (TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps);
111
115
  export interface UseFieldV6ForwardedProps {
112
116
  inputRef?: React.Ref<HTMLInputElement>;
113
- onBlur?: () => void;
117
+ onBlur?: React.FocusEventHandler;
114
118
  onClick?: React.MouseEventHandler;
115
- onFocus?: () => void;
119
+ onFocus?: React.FocusEventHandler;
116
120
  onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
117
121
  placeholder?: string;
118
122
  }
119
123
  interface UseFieldV6AdditionalProps extends Required<Pick<React.InputHTMLAttributes<HTMLInputElement>, 'inputMode' | 'placeholder' | 'value' | 'onChange' | 'autoComplete'>> {
120
124
  enableAccessibleFieldDOMStructure: false;
125
+ focused?: boolean;
121
126
  }
122
127
  export interface UseFieldV7ForwardedProps {
123
128
  focused?: boolean;
124
129
  sectionListRef?: React.Ref<PickersSectionListRef>;
125
- onBlur?: () => void;
130
+ onBlur?: React.FocusEventHandler;
126
131
  onClick?: React.MouseEventHandler;
127
- onFocus?: () => void;
132
+ onFocus?: React.FocusEventHandler;
128
133
  onInput?: React.FormEventHandler<HTMLDivElement>;
129
134
  onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
130
135
  }
@@ -136,6 +141,7 @@ interface UseFieldV7AdditionalProps {
136
141
  value: string;
137
142
  onChange: React.ChangeEventHandler<HTMLInputElement>;
138
143
  areAllSectionsEmpty: boolean;
144
+ focused: boolean;
139
145
  }
140
146
  export type UseFieldResponse<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & {
141
147
  [key: string]: any;
@@ -159,47 +165,17 @@ export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value
159
165
  export interface FieldChangeHandlerContext<TError> {
160
166
  validationError: TError;
161
167
  }
162
- /**
163
- * Object used to access and update the active date (i.e: the date containing the active section).
164
- * Mainly useful in the range fields where we need to update the date containing the active section without impacting the other one.
165
- */
166
- interface FieldActiveDateManager<TValue extends PickerValidValue> {
167
- /**
168
- * Active date from `state.value`.
169
- */
170
- date: PickerValidDate | null;
171
- /**
172
- * Active date from the `state.referenceValue`.
173
- */
174
- referenceDate: PickerValidDate;
175
- /**
176
- * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
177
- * @param {InferFieldSection<TValue>[]} sections The sections of the full value.
178
- * @returns {InferFieldSection<TValue>[]} The sections of the active date.
179
- * Get the sections of the active date.
180
- */
181
- getSections: (sections: InferFieldSection<TValue>[]) => InferFieldSection<TValue>[];
182
- /**
183
- * Creates the new value and reference value based on the new active date and the current state.
184
- * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
185
- * @param {PickerValidDate | null} newActiveDate The new value of the date containing the active section.
186
- * @returns {Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
187
- */
188
- getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>;
189
- }
190
168
  export type FieldParsedSelectedSections = number | 'all' | null;
191
169
  export interface FieldValueManager<TValue extends PickerValidValue> {
192
170
  /**
193
171
  * Creates the section list from the current value.
194
172
  * The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
195
173
  * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
196
- * @param {MuiPickersAdapter} utils The utils to manipulate the date.
197
174
  * @param {TValue} value The current value to generate sections from.
198
- * @param {InferFieldSection<TValue>[] | null} fallbackSections The sections to use as a fallback if a date is null or invalid.
199
- * @param {(date: PickerValidDate) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
175
+ * @param {(date: PickerValidDate | null) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
200
176
  * @returns {InferFieldSection<TValue>[]} The new section list.
201
177
  */
202
- getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections: InferFieldSection<TValue>[] | null, getSectionsFromDate: (date: PickerValidDate) => FieldSection[]) => InferFieldSection<TValue>[];
178
+ getSectionsFromValue: (value: TValue, getSectionsFromDate: (date: PickerValidDate | null) => FieldSection[]) => InferFieldSection<TValue>[];
203
179
  /**
204
180
  * Creates the string value to render in the input based on the current section list.
205
181
  * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
@@ -216,15 +192,6 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
216
192
  * @returns {string} The string value to render in the input.
217
193
  */
218
194
  getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
219
- /**
220
- * Returns the manager of the active date.
221
- * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
222
- * @param {MuiPickersAdapter} utils The utils to manipulate the date.
223
- * @param {UseFieldState<TValue>} state The current state of the field.
224
- * @param {InferFieldSection<TValue>} activeSection The active section.
225
- * @returns {FieldActiveDateManager<TValue>} The manager of the active date.
226
- */
227
- getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue>, activeSection: InferFieldSection<TValue>) => FieldActiveDateManager<TValue>;
228
195
  /**
229
196
  * Parses a string version (most of the time coming from the input).
230
197
  * This method should only be used when the change does not come from a single section.
@@ -245,9 +212,51 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
245
212
  * @returns {TValue} The new reference value with no invalid date.
246
213
  */
247
214
  updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
215
+ /**
216
+ * Extract from the given value the date that contains the given section.
217
+ * @param {TValue} value The value to extract the date from.
218
+ * @param {InferFieldSection<TValue>} section The section to get the date from.
219
+ * @returns {PickerValidDate | null} The date that contains the section.
220
+ */
221
+ getDateFromSection: (value: TValue, section: InferFieldSection<TValue>) => PickerValidDate | null;
222
+ /**
223
+ * Get the sections of the date that contains the given section.
224
+ * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
225
+ * @param {InferFieldSection<TValue>[]} sections The sections of the full value.
226
+ * @param {InferFieldSection<TValue>} section A section of the date from which we want to get all the sections.
227
+ * @returns {InferFieldSection<TValue>[]} The sections of the date that contains the section.
228
+ */
229
+ getDateSectionsFromValue: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
230
+ /**
231
+ * Creates a new value based on the provided date and the current value.
232
+ * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
233
+ * @param {TValue} value The value to update the date in.
234
+ * @param {InferFieldSection<TValue>} section A section of the date we want to update in the value.
235
+ * @param {PickerValidDate | null} date The date that contains the section.
236
+ * @returns {TValue} The updated value.
237
+ */
238
+ updateDateInValue: (value: TValue, section: InferFieldSection<TValue>, date: PickerValidDate | null) => TValue;
239
+ /**
240
+ * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
241
+ * @param {InferFieldSection<TValue>[]} sections The sections of the full value.
242
+ * @param {InferFieldSection<TValue>} section A section of the date from which we want to clear all the sections.
243
+ * @returns {InferFieldSection<TValue>[]} The sections of the full value with all the sections of the target date cleared.
244
+ */
245
+ clearDateSections: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
248
246
  }
249
247
  export interface UseFieldState<TValue extends PickerValidValue> {
250
- value: TValue;
248
+ /**
249
+ * Last value returned by `useControlledValueWithTimezone`.
250
+ */
251
+ lastValue: TValue | undefined;
252
+ /**
253
+ * Last value of the parameters used to generate the sections.
254
+ */
255
+ lastSectionsDependencies: {
256
+ format: string;
257
+ isRtl: boolean;
258
+ locale: any;
259
+ };
251
260
  /**
252
261
  * Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
253
262
  * It is updated whenever we have a valid date (for the range picker we update only the portion of the range that is valid).
@@ -471,8 +471,11 @@ const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTran
471
471
  }
472
472
  case 'weekDay':
473
473
  {
474
+ let dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
475
+ if (section.hasLeadingZerosInInput) {
476
+ dayInWeekStrOfActiveDate = cleanLeadingZeros(dayInWeekStrOfActiveDate, section.maxLength);
477
+ }
474
478
  const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);
475
- const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
476
479
  const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
477
480
  const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
478
481
  const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
@@ -243,7 +243,7 @@ const useFieldCharacterEditing = ({
243
243
  return applyQuery(params, getFirstSectionValueMatchingWithQuery, queryValue => (0, _useField.isStringNumber)(queryValue, localizedDigits));
244
244
  };
245
245
  const applyCharacterEditing = (0, _useEventCallback.default)(params => {
246
- const activeSection = sections[params.sectionIndex];
246
+ const section = sections[params.sectionIndex];
247
247
  const isNumericEditing = (0, _useField.isStringNumber)(params.keyPressed, localizedDigits);
248
248
  const response = isNumericEditing ? applyNumericEditing((0, _extends2.default)({}, params, {
249
249
  keyPressed: (0, _useField.applyLocalizedDigits)(params.keyPressed, localizedDigits)
@@ -253,7 +253,7 @@ const useFieldCharacterEditing = ({
253
253
  return;
254
254
  }
255
255
  updateSectionValue({
256
- activeSection,
256
+ section,
257
257
  newSectionValue: response.sectionValue,
258
258
  shouldGoToNextSection: response.shouldGoToNextSection
259
259
  });