@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
@@ -8,4 +8,4 @@ export declare const DATE_TIME_VALIDATION_PROP_NAMES: (keyof DateTimeValidationP
8
8
  */
9
9
  export declare const extractValidationProps: <Props extends {
10
10
  [key: string]: any;
11
- }>(props: Props) => Pick<Props, "ampm" | "disableFuture" | "disablePast" | "maxDate" | "minDate" | "shouldDisableYear" | "shouldDisableMonth" | "shouldDisableDate" | "minTime" | "maxTime" | "minutesStep" | "shouldDisableTime" | "disableIgnoringDatePartForTimeValidation" | "minDateTime" | "maxDateTime">;
11
+ }>(props: Props) => Pick<Props, "maxDate" | "minDate" | "disablePast" | "disableFuture" | "shouldDisableYear" | "shouldDisableMonth" | "shouldDisableDate" | "minTime" | "maxTime" | "minutesStep" | "shouldDisableTime" | "disableIgnoringDatePartForTimeValidation" | "ampm" | "minDateTime" | "maxDateTime">;
@@ -6,4 +6,4 @@ export { validateDateTime } from "./validateDateTime.js";
6
6
  export type { ValidateDateTimeProps } from './validateDateTime';
7
7
  export { extractValidationProps } from "./extractValidationProps.js";
8
8
  export { useValidation } from "./useValidation.js";
9
- export type { Validator } from './useValidation';
9
+ export type { Validator, UseValidationReturnValue } from './useValidation';
@@ -1,6 +1,6 @@
1
1
  import { MuiPickersAdapterContextValue } from "../LocalizationProvider/LocalizationProvider.js";
2
2
  import { OnErrorProps, PickersTimezone } from "../models/index.js";
3
- import type { PickerValueManager } from '../internals/hooks/usePicker';
3
+ import type { PickerValueManager } from '../internals/models';
4
4
  import { PickerValidValue } from "../internals/models/index.js";
5
5
  export type Validator<TValue extends PickerValidValue, TError, TValidationProps> = {
6
6
  (params: {
@@ -33,7 +33,7 @@ interface UseValidationOptions<TValue extends PickerValidValue, TError, TValidat
33
33
  */
34
34
  props: TValidationProps;
35
35
  }
36
- interface UseValidationReturnValue<TValue extends PickerValidValue, TError> {
36
+ export interface UseValidationReturnValue<TValue extends PickerValidValue, TError> {
37
37
  /**
38
38
  * The validation error associated to the value passed to the `useValidation` hook.
39
39
  */
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- export interface OpenStateProps {
3
- open?: boolean;
4
- onOpen?: () => void;
5
- onClose?: () => void;
6
- }
7
- export declare const useOpenState: ({
8
- open,
9
- onOpen,
10
- onClose
11
- }: OpenStateProps) => {
12
- open: boolean;
13
- setOpen: (action: React.SetStateAction<boolean>) => void;
14
- };
@@ -1,37 +0,0 @@
1
- import * as React from 'react';
2
- import useEventCallback from '@mui/utils/useEventCallback';
3
- export const useOpenState = ({
4
- open,
5
- onOpen,
6
- onClose
7
- }) => {
8
- const isControllingOpenProp = React.useRef(typeof open === 'boolean').current;
9
- const [openState, setOpenState] = React.useState(false);
10
-
11
- // It is required to update inner state in useEffect in order to avoid situation when
12
- // Our component is not mounted yet, but `open` state is set to `true` (for example initially opened)
13
- React.useEffect(() => {
14
- if (isControllingOpenProp) {
15
- if (typeof open !== 'boolean') {
16
- throw new Error('You must not mix controlling and uncontrolled mode for `open` prop');
17
- }
18
- setOpenState(open);
19
- }
20
- }, [isControllingOpenProp, open]);
21
- const setOpen = useEventCallback(action => {
22
- const newOpen = typeof action === 'function' ? action(openState) : action;
23
- if (!isControllingOpenProp) {
24
- setOpenState(newOpen);
25
- }
26
- if (newOpen && onOpen) {
27
- onOpen();
28
- }
29
- if (!newOpen && onClose) {
30
- onClose();
31
- }
32
- });
33
- return {
34
- open: openState,
35
- setOpen
36
- };
37
- };
@@ -1,60 +0,0 @@
1
- import * as React from 'react';
2
- import { PickerValueManager, UsePickerValueProviderParams } from "./usePickerValue.types.js";
3
- import { PickerProviderProps } from "../../components/PickerProvider.js";
4
- import type { UsePickerProps } from './usePicker.types';
5
- import { DateOrTimeViewWithMeridiem, FormProps, PickerOrientation, PickerValidValue, PickerVariant } from "../../models/index.js";
6
- import { UsePickerViewsProviderParams } from "./usePickerViews.js";
7
- import { PickerFieldPrivateContextValue } from "../useField/useFieldInternalPropsWithDefaults.js";
8
- export declare const usePickerOrientation: (views: readonly DateOrTimeViewWithMeridiem[], customOrientation: PickerOrientation | undefined) => PickerOrientation;
9
- export declare function usePickerProvider<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError>(parameters: UsePickerProviderParameters<TValue, TView, TError>): UsePickerProviderReturnValue<TValue>;
10
- export interface UsePickerProviderParameters<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Pick<PickerProviderProps<TValue>, 'localeText'> {
11
- ref: React.ForwardedRef<HTMLDivElement> | undefined;
12
- props: UsePickerProps<TValue, any, any, any> & UsePickerProviderNonStaticProps;
13
- valueManager: PickerValueManager<TValue, any>;
14
- variant: PickerVariant;
15
- paramsFromUsePickerValue: UsePickerValueProviderParams<TValue, TError>;
16
- paramsFromUsePickerViews: UsePickerViewsProviderParams<TView>;
17
- }
18
- export interface UsePickerProviderReturnValue<TValue extends PickerValidValue> extends Omit<PickerProviderProps<TValue>, 'children'> {}
19
- /**
20
- * Props used to create the picker's contexts.
21
- * Those props are exposed on all the pickers.
22
- */
23
- export interface UsePickerProviderProps extends FormProps {
24
- /**
25
- * Force rendering in particular orientation.
26
- */
27
- orientation?: PickerOrientation;
28
- /**
29
- * If `true`, disable heavy animations.
30
- * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
31
- */
32
- reduceAnimations?: boolean;
33
- }
34
- /**
35
- * Props used to create the picker's contexts and that are not available on static pickers.
36
- */
37
- export interface UsePickerProviderNonStaticProps extends PickerFieldPrivateContextValue {
38
- /**
39
- * Format of the date when rendered in the input(s).
40
- * Defaults to localized format based on the used `views`.
41
- */
42
- format?: string;
43
- /**
44
- * If `true`, the open picker button will not be rendered (renders only the field).
45
- * @default false
46
- */
47
- disableOpenPicker?: boolean;
48
- /**
49
- * The label content.
50
- */
51
- label?: React.ReactNode;
52
- /**
53
- * Pass a ref to the `input` element.
54
- */
55
- inputRef?: React.Ref<HTMLInputElement>;
56
- /**
57
- * Name attribute used by the `input` element in the Field.
58
- */
59
- name?: string;
60
- }
@@ -1,111 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
4
- import { useUtils } from "../useUtils.js";
5
- import { arrayIncludes } from "../../utils/utils.js";
6
- import { useReduceAnimations } from "../useReduceAnimations.js";
7
- function getOrientation() {
8
- if (typeof window === 'undefined') {
9
- return 'portrait';
10
- }
11
- if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
12
- return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
13
- }
14
-
15
- // Support IOS safari
16
- if (window.orientation) {
17
- return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
18
- }
19
- return 'portrait';
20
- }
21
- export const usePickerOrientation = (views, customOrientation) => {
22
- const [orientation, setOrientation] = React.useState(getOrientation);
23
- useEnhancedEffect(() => {
24
- const eventHandler = () => {
25
- setOrientation(getOrientation());
26
- };
27
- window.addEventListener('orientationchange', eventHandler);
28
- return () => {
29
- window.removeEventListener('orientationchange', eventHandler);
30
- };
31
- }, []);
32
- if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {
33
- // could not display 13:34:44 in landscape mode
34
- return 'portrait';
35
- }
36
- return customOrientation ?? orientation;
37
- };
38
- export function usePickerProvider(parameters) {
39
- const {
40
- ref,
41
- props,
42
- valueManager,
43
- localeText,
44
- variant,
45
- paramsFromUsePickerValue,
46
- paramsFromUsePickerViews
47
- } = parameters;
48
- const utils = useUtils();
49
- const orientation = usePickerOrientation(paramsFromUsePickerViews.views, props.orientation);
50
- const reduceAnimations = useReduceAnimations(props.reduceAnimations);
51
- const triggerRef = React.useRef(null);
52
- const ownerState = React.useMemo(() => ({
53
- isPickerValueEmpty: valueManager.areValuesEqual(utils, paramsFromUsePickerValue.value, valueManager.emptyValue),
54
- isPickerOpen: paramsFromUsePickerValue.contextValue.open,
55
- isPickerDisabled: props.disabled ?? false,
56
- isPickerReadOnly: props.readOnly ?? false,
57
- pickerOrientation: orientation,
58
- pickerVariant: variant
59
- }), [utils, valueManager, paramsFromUsePickerValue.value, paramsFromUsePickerValue.contextValue.open, orientation, variant, props.disabled, props.readOnly]);
60
- const triggerStatus = React.useMemo(() => {
61
- if (props.disableOpenPicker || !paramsFromUsePickerViews.hasUIView) {
62
- return 'hidden';
63
- }
64
- if (props.disabled || props.readOnly) {
65
- return 'disabled';
66
- }
67
- return 'enabled';
68
- }, [props.disableOpenPicker, paramsFromUsePickerViews.hasUIView, props.disabled, props.readOnly]);
69
- const contextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.contextValue, paramsFromUsePickerViews.contextValue, {
70
- disabled: props.disabled ?? false,
71
- readOnly: props.readOnly ?? false,
72
- variant,
73
- orientation,
74
- reduceAnimations,
75
- triggerRef,
76
- triggerStatus,
77
- fieldFormat: props.format ?? '',
78
- name: props.name,
79
- label: props.label,
80
- rootSx: props.sx,
81
- rootRef: ref,
82
- rootClassName: props.className
83
- }), [paramsFromUsePickerValue.contextValue, paramsFromUsePickerViews.contextValue, ref, variant, orientation, reduceAnimations, props.disabled, props.readOnly, props.format, props.className, props.name, props.label, props.sx, triggerRef, triggerStatus]);
84
- const privateContextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.privateContextValue, paramsFromUsePickerViews.privateContextValue, {
85
- ownerState
86
- }), [paramsFromUsePickerValue.privateContextValue, paramsFromUsePickerViews.privateContextValue, ownerState]);
87
- const actionsContextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.actionsContextValue, paramsFromUsePickerViews.actionsContextValue), [paramsFromUsePickerValue.actionsContextValue, paramsFromUsePickerViews.actionsContextValue]);
88
- const fieldPrivateContextValue = React.useMemo(() => ({
89
- formatDensity: props.formatDensity,
90
- enableAccessibleFieldDOMStructure: props.enableAccessibleFieldDOMStructure,
91
- selectedSections: props.selectedSections,
92
- onSelectedSectionsChange: props.onSelectedSectionsChange
93
- }), [props.formatDensity, props.enableAccessibleFieldDOMStructure, props.selectedSections, props.onSelectedSectionsChange]);
94
- return {
95
- localeText,
96
- contextValue,
97
- privateContextValue,
98
- actionsContextValue,
99
- fieldPrivateContextValue,
100
- isValidContextValue: paramsFromUsePickerValue.isValidContextValue
101
- };
102
- }
103
-
104
- /**
105
- * Props used to create the picker's contexts.
106
- * Those props are exposed on all the pickers.
107
- */
108
-
109
- /**
110
- * Props used to create the picker's contexts and that are not available on static pickers.
111
- */
@@ -1,12 +0,0 @@
1
- import { InferError } from "../../../models/index.js";
2
- import { UsePickerValueProps, UsePickerValueParams, UsePickerValueResponse } from "./usePickerValue.types.js";
3
- import { PickerValidValue } from "../../models/index.js";
4
- /**
5
- * Manage the value lifecycle of all the pickers.
6
- */
7
- export declare const usePickerValue: <TValue extends PickerValidValue, TExternalProps extends UsePickerValueProps<TValue, any>>({
8
- props,
9
- valueManager,
10
- valueType,
11
- validator
12
- }: UsePickerValueParams<TValue, TExternalProps>) => UsePickerValueResponse<TValue, InferError<TExternalProps>>;
@@ -1,226 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import useEventCallback from '@mui/utils/useEventCallback';
4
- import { useOpenState } from "../useOpenState.js";
5
- import { useLocalizationContext, useUtils } from "../useUtils.js";
6
- import { useValidation } from "../../../validation/index.js";
7
- import { useValueWithTimezone } from "../useValueWithTimezone.js";
8
- /**
9
- * Manage the value lifecycle of all the pickers.
10
- */
11
- export const usePickerValue = ({
12
- props,
13
- valueManager,
14
- valueType,
15
- validator
16
- }) => {
17
- const {
18
- onAccept,
19
- onChange,
20
- value: inValueWithoutRenderTimezone,
21
- defaultValue: inDefaultValue,
22
- closeOnSelect = false,
23
- timezone: timezoneProp,
24
- referenceDate
25
- } = props;
26
- const {
27
- current: defaultValue
28
- } = React.useRef(inDefaultValue);
29
- const {
30
- current: isControlled
31
- } = React.useRef(inValueWithoutRenderTimezone !== undefined);
32
- const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
33
-
34
- /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
35
- if (process.env.NODE_ENV !== 'production') {
36
- React.useEffect(() => {
37
- if (isControlled !== (inValueWithoutRenderTimezone !== undefined)) {
38
- console.error([`MUI X: A component is changing the ${isControlled ? '' : 'un'}controlled value of a picker to be ${isControlled ? 'un' : ''}controlled.`, 'Elements should not switch from uncontrolled to controlled (or vice versa).', `Decide between using a controlled or uncontrolled value` + 'for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
39
- }
40
- }, [inValueWithoutRenderTimezone]);
41
- React.useEffect(() => {
42
- if (!isControlled && defaultValue !== inDefaultValue) {
43
- console.error([`MUI X: A component is changing the defaultValue of an uncontrolled picker after being initialized. ` + `To suppress this warning opt to use a controlled value.`].join('\n'));
44
- }
45
- }, [JSON.stringify(defaultValue)]);
46
- }
47
- /* eslint-enable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
48
-
49
- const utils = useUtils();
50
- const adapter = useLocalizationContext();
51
- const {
52
- open,
53
- setOpen
54
- } = useOpenState(props);
55
- const {
56
- timezone,
57
- value: inValueWithTimezoneToRender,
58
- handleValueChange
59
- } = useValueWithTimezone({
60
- timezone: timezoneProp,
61
- value: inValueWithoutRenderTimezone,
62
- defaultValue,
63
- referenceDate,
64
- onChange,
65
- valueManager
66
- });
67
- const [dateState, setDateState] = React.useState(() => {
68
- let initialValue;
69
- if (inValueWithTimezoneToRender !== undefined) {
70
- initialValue = inValueWithTimezoneToRender;
71
- } else if (defaultValue !== undefined) {
72
- initialValue = defaultValue;
73
- } else {
74
- initialValue = valueManager.emptyValue;
75
- }
76
- return {
77
- draft: initialValue,
78
- lastPublishedValue: initialValue,
79
- lastCommittedValue: initialValue,
80
- lastControlledValue: inValueWithoutRenderTimezone,
81
- hasBeenModifiedSinceMount: false
82
- };
83
- });
84
- const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
85
- if (previousTimezoneProp !== timezoneProp) {
86
- setPreviousTimezoneProp(timezoneProp);
87
- if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
88
- setDateState(prev => _extends({}, prev, {
89
- draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
90
- }));
91
- }
92
- }
93
- const {
94
- getValidationErrorForNewValue
95
- } = useValidation({
96
- props,
97
- validator,
98
- timezone,
99
- value: dateState.draft,
100
- onError: props.onError
101
- });
102
- const setValue = useEventCallback((newValue, options) => {
103
- const {
104
- changeImportance = 'accept',
105
- skipPublicationIfPristine = false,
106
- validationError,
107
- shortcut,
108
- shouldClose = changeImportance === 'accept'
109
- } = options ?? {};
110
- let shouldPublish;
111
- let shouldCommit;
112
- if (!skipPublicationIfPristine && !isControlled && !dateState.hasBeenModifiedSinceMount) {
113
- // If the value is not controlled and the value has never been modified before,
114
- // Then clicking on any value (including the one equal to `defaultValue`) should call `onChange` and `onAccept`
115
- shouldPublish = true;
116
- shouldCommit = changeImportance === 'accept';
117
- } else {
118
- shouldPublish = !valueManager.areValuesEqual(utils, newValue, dateState.lastPublishedValue);
119
- shouldCommit = changeImportance === 'accept' && !valueManager.areValuesEqual(utils, newValue, dateState.lastCommittedValue);
120
- }
121
- setDateState(prev => _extends({}, prev, {
122
- draft: newValue,
123
- lastPublishedValue: shouldPublish ? newValue : prev.lastPublishedValue,
124
- lastCommittedValue: shouldCommit ? newValue : prev.lastCommittedValue,
125
- hasBeenModifiedSinceMount: true
126
- }));
127
- let cachedContext = null;
128
- const getContext = () => {
129
- if (!cachedContext) {
130
- cachedContext = {
131
- validationError: validationError == null ? getValidationErrorForNewValue(newValue) : validationError
132
- };
133
- if (shortcut) {
134
- cachedContext.shortcut = shortcut;
135
- }
136
- }
137
- return cachedContext;
138
- };
139
- if (shouldPublish) {
140
- handleValueChange(newValue, getContext());
141
- }
142
- if (shouldCommit && onAccept) {
143
- onAccept(newValue, getContext());
144
- }
145
- if (shouldClose) {
146
- setOpen(false);
147
- }
148
- });
149
- if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
150
- const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
151
- setDateState(prev => _extends({}, prev, {
152
- lastControlledValue: inValueWithoutRenderTimezone
153
- }, isUpdateComingFromPicker ? {} : {
154
- lastCommittedValue: inValueWithTimezoneToRender,
155
- lastPublishedValue: inValueWithTimezoneToRender,
156
- draft: inValueWithTimezoneToRender,
157
- hasBeenModifiedSinceMount: true
158
- }));
159
- }
160
- const isValid = testedValue => {
161
- const error = validator({
162
- adapter,
163
- value: testedValue,
164
- timezone,
165
- props
166
- });
167
- return !valueManager.hasError(error);
168
- };
169
- const clearValue = useEventCallback(() => setValue(valueManager.emptyValue));
170
- const setValueToToday = useEventCallback(() => setValue(valueManager.getTodayValue(utils, timezone, valueType)));
171
- const acceptValueChanges = useEventCallback(() => setValue(dateState.lastPublishedValue));
172
- const cancelValueChanges = useEventCallback(() => setValue(dateState.lastCommittedValue, {
173
- skipPublicationIfPristine: true
174
- }));
175
- const dismissViews = useEventCallback(() => {
176
- setValue(dateState.lastPublishedValue, {
177
- skipPublicationIfPristine: true
178
- });
179
- });
180
- const setValueFromView = useEventCallback((newValue, selectionState = 'partial') => {
181
- // TODO: Expose a new method (private?) like `setView` that only updates the draft value.
182
- if (selectionState === 'shallow') {
183
- setDateState(prev => _extends({}, prev, {
184
- draft: newValue,
185
- hasBeenModifiedSinceMount: true
186
- }));
187
- }
188
- setValue(newValue, {
189
- changeImportance: selectionState === 'finish' && closeOnSelect ? 'accept' : 'set'
190
- });
191
- });
192
- const valueWithoutError = React.useMemo(() => valueManager.cleanValue(utils, dateState.draft), [utils, valueManager, dateState.draft]);
193
- const viewResponse = {
194
- value: valueWithoutError,
195
- onChange: setValueFromView,
196
- open,
197
- setOpen
198
- };
199
- const actionsContextValue = React.useMemo(() => ({
200
- setValue,
201
- setOpen,
202
- clearValue,
203
- setValueToToday,
204
- acceptValueChanges,
205
- cancelValueChanges
206
- }), [setValue, setOpen, clearValue, setValueToToday, acceptValueChanges, cancelValueChanges]);
207
- const contextValue = React.useMemo(() => _extends({}, actionsContextValue, {
208
- value: dateState.draft,
209
- timezone,
210
- open
211
- }), [actionsContextValue, timezone, open, dateState.draft]);
212
- const privateContextValue = React.useMemo(() => ({
213
- dismissViews
214
- }), [dismissViews]);
215
- const providerParams = {
216
- value: dateState.draft,
217
- contextValue,
218
- actionsContextValue,
219
- privateContextValue,
220
- isValidContextValue: isValid
221
- };
222
- return {
223
- viewProps: viewResponse,
224
- provider: providerParams
225
- };
226
- };