@mui/x-date-pickers 9.0.0-alpha.4 → 9.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/AdapterDateFnsBase/AdapterDateFnsBase.mjs +1 -1
  2. package/AdapterDayjs/AdapterDayjs.mjs +1 -1
  3. package/AdapterLuxon/AdapterLuxon.mjs +1 -1
  4. package/AdapterMoment/AdapterMoment.mjs +1 -1
  5. package/AdapterMomentHijri/AdapterMomentHijri.mjs +1 -1
  6. package/AdapterMomentJalaali/AdapterMomentJalaali.mjs +1 -1
  7. package/CHANGELOG.md +262 -2
  8. package/DateCalendar/DateCalendar.js +1 -1
  9. package/DateCalendar/DateCalendar.mjs +1 -1
  10. package/DateCalendar/DayCalendar.d.mts +7 -7
  11. package/DateCalendar/DayCalendar.d.ts +7 -7
  12. package/DateCalendar/DayCalendar.js +23 -25
  13. package/DateCalendar/DayCalendar.mjs +23 -25
  14. package/DateField/DateField.d.mts +1 -1
  15. package/DateField/DateField.d.ts +1 -1
  16. package/DateField/DateField.js +22 -4
  17. package/DateField/DateField.mjs +22 -4
  18. package/DateField/DateField.types.d.mts +3 -3
  19. package/DateField/DateField.types.d.ts +3 -3
  20. package/DateField/useDateField.d.mts +1 -1
  21. package/DateField/useDateField.d.ts +1 -1
  22. package/DateField/useDateField.js +1 -1
  23. package/DateField/useDateField.mjs +1 -1
  24. package/DatePicker/DatePicker.d.mts +1 -1
  25. package/DatePicker/DatePicker.d.ts +1 -1
  26. package/DatePicker/DatePicker.js +1 -5
  27. package/DatePicker/DatePicker.mjs +1 -5
  28. package/DatePicker/DatePicker.types.d.mts +3 -3
  29. package/DatePicker/DatePicker.types.d.ts +3 -3
  30. package/DateTimeField/DateTimeField.d.mts +1 -1
  31. package/DateTimeField/DateTimeField.d.ts +1 -1
  32. package/DateTimeField/DateTimeField.js +22 -4
  33. package/DateTimeField/DateTimeField.mjs +22 -4
  34. package/DateTimeField/DateTimeField.types.d.mts +2 -2
  35. package/DateTimeField/DateTimeField.types.d.ts +2 -2
  36. package/DateTimeField/useDateTimeField.d.mts +1 -1
  37. package/DateTimeField/useDateTimeField.d.ts +1 -1
  38. package/DateTimeField/useDateTimeField.js +1 -1
  39. package/DateTimeField/useDateTimeField.mjs +1 -1
  40. package/DateTimePicker/DateTimePicker.d.mts +1 -1
  41. package/DateTimePicker/DateTimePicker.d.ts +1 -1
  42. package/DateTimePicker/DateTimePicker.js +1 -5
  43. package/DateTimePicker/DateTimePicker.mjs +1 -5
  44. package/DateTimePicker/DateTimePicker.types.d.mts +3 -3
  45. package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  46. package/DesktopDatePicker/DesktopDatePicker.d.mts +1 -1
  47. package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -1
  48. package/DesktopDatePicker/DesktopDatePicker.js +1 -5
  49. package/DesktopDatePicker/DesktopDatePicker.mjs +1 -5
  50. package/DesktopDatePicker/DesktopDatePicker.types.d.mts +3 -3
  51. package/DesktopDatePicker/DesktopDatePicker.types.d.ts +3 -3
  52. package/DesktopDateTimePicker/DesktopDateTimePicker.d.mts +1 -1
  53. package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -1
  54. package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -5
  55. package/DesktopDateTimePicker/DesktopDateTimePicker.mjs +1 -5
  56. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.mts +3 -3
  57. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +3 -3
  58. package/DesktopTimePicker/DesktopTimePicker.d.mts +1 -1
  59. package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -1
  60. package/DesktopTimePicker/DesktopTimePicker.js +0 -4
  61. package/DesktopTimePicker/DesktopTimePicker.mjs +0 -4
  62. package/DesktopTimePicker/DesktopTimePicker.types.d.mts +3 -3
  63. package/DesktopTimePicker/DesktopTimePicker.types.d.ts +3 -3
  64. package/DigitalClock/DigitalClock.d.mts +1 -1
  65. package/DigitalClock/DigitalClock.d.ts +1 -1
  66. package/DigitalClock/DigitalClock.js +2 -2
  67. package/DigitalClock/DigitalClock.mjs +3 -3
  68. package/MobileDatePicker/MobileDatePicker.d.mts +1 -1
  69. package/MobileDatePicker/MobileDatePicker.d.ts +1 -1
  70. package/MobileDatePicker/MobileDatePicker.js +1 -5
  71. package/MobileDatePicker/MobileDatePicker.mjs +1 -5
  72. package/MobileDatePicker/MobileDatePicker.types.d.mts +3 -3
  73. package/MobileDatePicker/MobileDatePicker.types.d.ts +3 -3
  74. package/MobileDateTimePicker/MobileDateTimePicker.d.mts +1 -1
  75. package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -1
  76. package/MobileDateTimePicker/MobileDateTimePicker.js +1 -5
  77. package/MobileDateTimePicker/MobileDateTimePicker.mjs +1 -5
  78. package/MobileDateTimePicker/MobileDateTimePicker.types.d.mts +3 -3
  79. package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +3 -3
  80. package/MobileTimePicker/MobileTimePicker.d.mts +1 -1
  81. package/MobileTimePicker/MobileTimePicker.d.ts +1 -1
  82. package/MobileTimePicker/MobileTimePicker.js +0 -4
  83. package/MobileTimePicker/MobileTimePicker.mjs +0 -4
  84. package/MobileTimePicker/MobileTimePicker.types.d.mts +3 -3
  85. package/MobileTimePicker/MobileTimePicker.types.d.ts +3 -3
  86. package/MonthCalendar/MonthCalendarButton.js +2 -2
  87. package/MonthCalendar/MonthCalendarButton.mjs +3 -3
  88. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +2 -2
  89. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.mjs +3 -3
  90. package/PickerDay/PickerDay.d.mts +14 -0
  91. package/PickerDay/PickerDay.d.ts +14 -0
  92. package/{PickerDay2/PickerDay2.js → PickerDay/PickerDay.js} +110 -45
  93. package/{PickerDay2/PickerDay2.mjs → PickerDay/PickerDay.mjs} +110 -45
  94. package/PickerDay/PickerDay.types.d.mts +137 -0
  95. package/PickerDay/PickerDay.types.d.ts +137 -0
  96. package/PickerDay/index.d.mts +4 -0
  97. package/PickerDay/index.d.ts +4 -0
  98. package/PickerDay/index.js +25 -0
  99. package/PickerDay/index.mjs +2 -0
  100. package/{PickerDay2/pickerDay2Classes.d.mts → PickerDay/pickerDayClasses.d.mts} +4 -4
  101. package/{PickerDay2/pickerDay2Classes.d.ts → PickerDay/pickerDayClasses.d.ts} +4 -4
  102. package/PickerDay/pickerDayClasses.js +14 -0
  103. package/PickerDay/pickerDayClasses.mjs +6 -0
  104. package/PickersTextField/PickersFilledInput/PickersFilledInput.js +27 -1
  105. package/PickersTextField/PickersFilledInput/PickersFilledInput.mjs +27 -1
  106. package/PickersTextField/PickersInput/PickersInput.js +27 -1
  107. package/PickersTextField/PickersInput/PickersInput.mjs +27 -1
  108. package/PickersTextField/PickersInputBase/PickersInputBase.js +26 -0
  109. package/PickersTextField/PickersInputBase/PickersInputBase.mjs +26 -0
  110. package/PickersTextField/PickersInputBase/PickersInputBase.types.d.mts +26 -0
  111. package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +26 -0
  112. package/PickersTextField/PickersOutlinedInput/Outline.js +1 -1
  113. package/PickersTextField/PickersOutlinedInput/Outline.mjs +1 -1
  114. package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +27 -1
  115. package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.mjs +27 -1
  116. package/PickersTextField/PickersTextField.js +42 -2
  117. package/PickersTextField/PickersTextField.mjs +42 -2
  118. package/PickersTextField/PickersTextField.types.d.mts +22 -6
  119. package/PickersTextField/PickersTextField.types.d.ts +22 -6
  120. package/StaticDatePicker/StaticDatePicker.js +1 -1
  121. package/StaticDatePicker/StaticDatePicker.mjs +1 -1
  122. package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  123. package/StaticDateTimePicker/StaticDateTimePicker.mjs +1 -1
  124. package/TimeField/TimeField.d.mts +1 -1
  125. package/TimeField/TimeField.d.ts +1 -1
  126. package/TimeField/TimeField.js +22 -4
  127. package/TimeField/TimeField.mjs +22 -4
  128. package/TimeField/TimeField.types.d.mts +2 -2
  129. package/TimeField/TimeField.types.d.ts +2 -2
  130. package/TimeField/useTimeField.d.mts +1 -1
  131. package/TimeField/useTimeField.d.ts +1 -1
  132. package/TimePicker/TimePicker.d.mts +1 -1
  133. package/TimePicker/TimePicker.d.ts +1 -1
  134. package/TimePicker/TimePicker.js +0 -4
  135. package/TimePicker/TimePicker.mjs +0 -4
  136. package/TimePicker/TimePicker.types.d.mts +3 -3
  137. package/TimePicker/TimePicker.types.d.ts +3 -3
  138. package/YearCalendar/YearCalendarButton.js +2 -2
  139. package/YearCalendar/YearCalendarButton.mjs +3 -3
  140. package/hooks/useParsedFormat.js +5 -7
  141. package/hooks/useParsedFormat.mjs +5 -7
  142. package/hooks/useSplitFieldProps.d.mts +1 -1
  143. package/hooks/useSplitFieldProps.d.ts +1 -1
  144. package/hooks/useSplitFieldProps.js +1 -1
  145. package/hooks/useSplitFieldProps.mjs +1 -1
  146. package/index.d.mts +1 -2
  147. package/index.d.ts +1 -2
  148. package/index.js +2 -14
  149. package/index.mjs +2 -3
  150. package/internals/components/PickerFieldUI.d.mts +22 -13
  151. package/internals/components/PickerFieldUI.d.ts +22 -13
  152. package/internals/components/PickerFieldUI.js +22 -80
  153. package/internals/components/PickerFieldUI.mjs +22 -80
  154. package/internals/components/PickerPopper/PickerPopper.js +3 -0
  155. package/internals/components/PickerPopper/PickerPopper.mjs +3 -0
  156. package/internals/components/PickersToolbar.js +3 -1
  157. package/internals/components/PickersToolbar.mjs +3 -1
  158. package/internals/demo/DemoContainer.js +6 -8
  159. package/internals/demo/DemoContainer.mjs +6 -8
  160. package/internals/hooks/PickerDay.types.d.mts +12 -0
  161. package/internals/hooks/PickerDay.types.d.ts +12 -0
  162. package/internals/hooks/useDesktopPicker/useDesktopPicker.d.mts +2 -2
  163. package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +2 -2
  164. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.mts +6 -6
  165. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +6 -6
  166. package/internals/hooks/useField/buildSectionsFromFormat.d.mts +0 -1
  167. package/internals/hooks/useField/buildSectionsFromFormat.d.ts +0 -1
  168. package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
  169. package/internals/hooks/useField/buildSectionsFromFormat.mjs +1 -1
  170. package/internals/hooks/useField/index.d.mts +1 -1
  171. package/internals/hooks/useField/index.d.ts +1 -1
  172. package/internals/hooks/useField/index.js +2 -8
  173. package/internals/hooks/useField/index.mjs +1 -1
  174. package/internals/hooks/useField/useField.d.mts +2 -2
  175. package/internals/hooks/useField/useField.d.ts +2 -2
  176. package/internals/hooks/useField/useField.js +265 -8
  177. package/internals/hooks/useField/useField.mjs +264 -8
  178. package/internals/hooks/useField/useField.types.d.mts +11 -50
  179. package/internals/hooks/useField/useField.types.d.ts +11 -50
  180. package/internals/hooks/useField/useField.utils.d.mts +2 -3
  181. package/internals/hooks/useField/useField.utils.d.ts +2 -3
  182. package/internals/hooks/useField/useField.utils.js +8 -65
  183. package/internals/hooks/useField/useField.utils.mjs +6 -62
  184. package/internals/hooks/useField/useFieldHiddenInputProps.d.mts +2 -4
  185. package/internals/hooks/useField/useFieldHiddenInputProps.d.ts +2 -4
  186. package/internals/hooks/useField/useFieldHiddenInputProps.js +1 -3
  187. package/internals/hooks/useField/useFieldHiddenInputProps.mjs +1 -3
  188. package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +0 -1
  189. package/internals/hooks/useField/useFieldInternalPropsWithDefaults.mjs +0 -1
  190. package/internals/hooks/useField/useFieldRootProps.d.mts +5 -5
  191. package/internals/hooks/useField/useFieldRootProps.d.ts +5 -5
  192. package/internals/hooks/useField/useFieldRootProps.js +183 -11
  193. package/internals/hooks/useField/useFieldRootProps.mjs +183 -11
  194. package/internals/hooks/useField/useFieldSectionContainerProps.d.mts +3 -5
  195. package/internals/hooks/useField/useFieldSectionContainerProps.d.ts +3 -5
  196. package/internals/hooks/useField/useFieldSectionContainerProps.js +2 -4
  197. package/internals/hooks/useField/useFieldSectionContainerProps.mjs +2 -4
  198. package/internals/hooks/useField/useFieldSectionContentProps.d.mts +6 -7
  199. package/internals/hooks/useField/useFieldSectionContentProps.d.ts +6 -7
  200. package/internals/hooks/useField/useFieldSectionContentProps.js +2 -4
  201. package/internals/hooks/useField/useFieldSectionContentProps.mjs +2 -4
  202. package/internals/hooks/useField/useFieldState.d.mts +4 -4
  203. package/internals/hooks/useField/useFieldState.d.ts +4 -4
  204. package/internals/hooks/useField/useFieldState.js +3 -6
  205. package/internals/hooks/useField/useFieldState.mjs +3 -6
  206. package/internals/hooks/useMobilePicker/useMobilePicker.d.mts +2 -2
  207. package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +2 -2
  208. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.mts +6 -6
  209. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +6 -6
  210. package/internals/hooks/useNullableFieldPrivateContext.d.mts +1 -1
  211. package/internals/hooks/useNullableFieldPrivateContext.d.ts +1 -1
  212. package/internals/hooks/usePicker/usePicker.js +1 -3
  213. package/internals/hooks/usePicker/usePicker.mjs +1 -3
  214. package/{PickersDay → internals/hooks}/usePickerDayOwnerState.d.mts +2 -3
  215. package/{PickersDay → internals/hooks}/usePickerDayOwnerState.d.ts +2 -3
  216. package/{PickersDay → internals/hooks}/usePickerDayOwnerState.js +3 -5
  217. package/{PickersDay → internals/hooks}/usePickerDayOwnerState.mjs +3 -5
  218. package/internals/index.d.mts +4 -4
  219. package/internals/index.d.ts +4 -4
  220. package/internals/index.js +9 -9
  221. package/internals/index.mjs +3 -3
  222. package/internals/models/manager.d.mts +3 -5
  223. package/internals/models/manager.d.ts +3 -5
  224. package/internals/utils/valueManagers.js +1 -2
  225. package/internals/utils/valueManagers.mjs +2 -3
  226. package/managers/index.d.mts +2 -2
  227. package/managers/index.d.ts +2 -2
  228. package/managers/useDateManager.d.mts +3 -6
  229. package/managers/useDateManager.d.ts +3 -6
  230. package/managers/useDateManager.js +2 -6
  231. package/managers/useDateManager.mjs +2 -6
  232. package/managers/useDateTimeManager.d.mts +3 -6
  233. package/managers/useDateTimeManager.d.ts +3 -6
  234. package/managers/useDateTimeManager.js +2 -6
  235. package/managers/useDateTimeManager.mjs +2 -6
  236. package/managers/useTimeManager.d.mts +4 -6
  237. package/managers/useTimeManager.d.ts +4 -6
  238. package/managers/useTimeManager.js +1 -3
  239. package/managers/useTimeManager.mjs +1 -3
  240. package/models/fields.d.mts +3 -4
  241. package/models/fields.d.ts +3 -4
  242. package/models/manager.d.mts +2 -8
  243. package/models/manager.d.ts +2 -8
  244. package/package.json +55 -69
  245. package/themeAugmentation/components.d.mts +4 -8
  246. package/themeAugmentation/components.d.ts +4 -8
  247. package/themeAugmentation/overrides.d.mts +2 -4
  248. package/themeAugmentation/overrides.d.ts +2 -4
  249. package/themeAugmentation/props.d.mts +5 -7
  250. package/themeAugmentation/props.d.ts +5 -7
  251. package/PickerDay2/PickerDay2.d.mts +0 -7
  252. package/PickerDay2/PickerDay2.d.ts +0 -7
  253. package/PickerDay2/PickerDay2.types.d.mts +0 -18
  254. package/PickerDay2/PickerDay2.types.d.ts +0 -18
  255. package/PickerDay2/index.d.mts +0 -4
  256. package/PickerDay2/index.d.ts +0 -4
  257. package/PickerDay2/index.js +0 -25
  258. package/PickerDay2/index.mjs +0 -2
  259. package/PickerDay2/pickerDay2Classes.js +0 -14
  260. package/PickerDay2/pickerDay2Classes.mjs +0 -6
  261. package/PickersDay/PickersDay.d.mts +0 -15
  262. package/PickersDay/PickersDay.d.ts +0 -15
  263. package/PickersDay/PickersDay.js +0 -384
  264. package/PickersDay/PickersDay.mjs +0 -377
  265. package/PickersDay/PickersDay.types.d.mts +0 -114
  266. package/PickersDay/PickersDay.types.d.ts +0 -114
  267. package/PickersDay/index.d.mts +0 -4
  268. package/PickersDay/index.d.ts +0 -4
  269. package/PickersDay/index.js +0 -25
  270. package/PickersDay/index.mjs +0 -2
  271. package/PickersDay/pickersDayClasses.d.mts +0 -19
  272. package/PickersDay/pickersDayClasses.d.ts +0 -19
  273. package/PickersDay/pickersDayClasses.js +0 -14
  274. package/PickersDay/pickersDayClasses.mjs +0 -6
  275. package/internals/hooks/useField/useFieldRootHandleKeyDown.d.mts +0 -16
  276. package/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts +0 -16
  277. package/internals/hooks/useField/useFieldRootHandleKeyDown.js +0 -211
  278. package/internals/hooks/useField/useFieldRootHandleKeyDown.mjs +0 -205
  279. package/internals/hooks/useField/useFieldV6TextField.d.mts +0 -26
  280. package/internals/hooks/useField/useFieldV6TextField.d.ts +0 -26
  281. package/internals/hooks/useField/useFieldV6TextField.js +0 -422
  282. package/internals/hooks/useField/useFieldV6TextField.mjs +0 -413
  283. package/internals/hooks/useField/useFieldV7TextField.d.mts +0 -3
  284. package/internals/hooks/useField/useFieldV7TextField.d.ts +0 -3
  285. package/internals/hooks/useField/useFieldV7TextField.js +0 -272
  286. package/internals/hooks/useField/useFieldV7TextField.mjs +0 -264
  287. /package/{PickerDay2/PickerDay2.types.js → PickerDay/PickerDay.types.js} +0 -0
  288. /package/{PickerDay2/PickerDay2.types.mjs → PickerDay/PickerDay.types.mjs} +0 -0
  289. /package/{PickersDay/PickersDay.types.js → internals/hooks/PickerDay.types.js} +0 -0
  290. /package/{PickersDay/PickersDay.types.mjs → internals/hooks/PickerDay.types.mjs} +0 -0
@@ -1,9 +1,265 @@
1
- import { useFieldV7TextField } from "./useFieldV7TextField.mjs";
2
- import { useFieldV6TextField } from "./useFieldV6TextField.mjs";
3
- import { useNullableFieldPrivateContext } from "../useNullableFieldPrivateContext.mjs";
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
5
+ import * as React from 'react';
6
+ import useForkRef from '@mui/utils/useForkRef';
7
+ import useEventCallback from '@mui/utils/useEventCallback';
8
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
9
+ import { warnOnce } from '@mui/x-internals/warning';
10
+ import { parseSelectedSections } from "./useField.utils.mjs";
11
+ import { getActiveElement } from "../../utils/utils.mjs";
12
+ import { useSplitFieldProps } from "../../../hooks/index.mjs";
13
+ import { useFieldCharacterEditing } from "./useFieldCharacterEditing.mjs";
14
+ import { useFieldState } from "./useFieldState.mjs";
15
+ import { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.mjs";
16
+ import { syncSelectionToDOM } from "./syncSelectionToDOM.mjs";
17
+ import { useFieldRootProps } from "./useFieldRootProps.mjs";
18
+ import { useFieldHiddenInputProps } from "./useFieldHiddenInputProps.mjs";
19
+ import { useFieldSectionContainerProps } from "./useFieldSectionContainerProps.mjs";
20
+ import { useFieldSectionContentProps } from "./useFieldSectionContentProps.mjs";
4
21
  export const useField = parameters => {
5
- const fieldPrivateContext = useNullableFieldPrivateContext();
6
- const enableAccessibleFieldDOMStructure = parameters.props.enableAccessibleFieldDOMStructure ?? fieldPrivateContext?.enableAccessibleFieldDOMStructure ?? true;
7
- const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;
8
- return useFieldTextField(parameters);
9
- };
22
+ const {
23
+ props,
24
+ manager,
25
+ skipContextFieldRefAssignment,
26
+ manager: {
27
+ valueType,
28
+ internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
29
+ }
30
+ } = parameters;
31
+ const {
32
+ internalProps,
33
+ forwardedProps
34
+ } = useSplitFieldProps(props, valueType);
35
+ if (process.env.NODE_ENV !== 'production') {
36
+ if (forwardedProps.enableAccessibleFieldDOMStructure != null) {
37
+ warnOnce(['MUI X: The `enableAccessibleFieldDOMStructure` prop has been removed.', 'The accessible DOM structure is now the default and only option.', 'You can safely remove the prop from your code.', 'For more information, please have a look at the migration guide (https://mui.com/x/migration/migration-pickers-v8/).']);
38
+ }
39
+ }
40
+ const internalPropsWithDefaults = useFieldInternalPropsWithDefaults({
41
+ manager,
42
+ internalProps,
43
+ skipContextFieldRefAssignment
44
+ });
45
+ const {
46
+ sectionListRef: sectionListRefProp,
47
+ onBlur,
48
+ onClick,
49
+ onFocus,
50
+ onInput,
51
+ onPaste,
52
+ onKeyDown,
53
+ onClear,
54
+ clearable
55
+ } = forwardedProps;
56
+ const {
57
+ disabled = false,
58
+ readOnly = false,
59
+ autoFocus = false,
60
+ focused: focusedProp,
61
+ fieldRef
62
+ } = internalPropsWithDefaults;
63
+ const sectionListRef = React.useRef(null);
64
+ const handleSectionListRef = useForkRef(sectionListRefProp, sectionListRef);
65
+ const domGetters = React.useMemo(() => ({
66
+ isReady: () => sectionListRef.current != null,
67
+ getRoot: () => sectionListRef.current.getRoot(),
68
+ getSectionContainer: sectionIndex => sectionListRef.current.getSectionContainer(sectionIndex),
69
+ getSectionContent: sectionIndex => sectionListRef.current.getSectionContent(sectionIndex),
70
+ getSectionIndexFromDOMElement: element => sectionListRef.current.getSectionIndexFromDOMElement(element)
71
+ }), [sectionListRef]);
72
+ const stateResponse = useFieldState({
73
+ manager,
74
+ internalPropsWithDefaults,
75
+ forwardedProps
76
+ });
77
+ const {
78
+ // States and derived states
79
+ areAllSectionsEmpty,
80
+ error,
81
+ parsedSelectedSections,
82
+ sectionOrder,
83
+ state,
84
+ value,
85
+ // Methods to update the states
86
+ clearValue,
87
+ setSelectedSections
88
+ } = stateResponse;
89
+ const applyCharacterEditing = useFieldCharacterEditing({
90
+ stateResponse
91
+ });
92
+ const openPickerAriaLabel = useOpenPickerButtonAriaLabel(value);
93
+ const [focused, setFocused] = React.useState(false);
94
+ function focusField(newSelectedSections = 0) {
95
+ if (disabled || !sectionListRef.current ||
96
+ // if the field is already focused, we don't need to focus it again
97
+ getActiveSectionIndex(sectionListRef) != null) {
98
+ return;
99
+ }
100
+ const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);
101
+ setFocused(true);
102
+ sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();
103
+ }
104
+ const rootProps = useFieldRootProps({
105
+ manager,
106
+ internalPropsWithDefaults,
107
+ stateResponse,
108
+ applyCharacterEditing,
109
+ focused,
110
+ setFocused,
111
+ domGetters
112
+ });
113
+ const hiddenInputProps = useFieldHiddenInputProps({
114
+ manager,
115
+ stateResponse
116
+ });
117
+ const createSectionContainerProps = useFieldSectionContainerProps({
118
+ stateResponse,
119
+ internalPropsWithDefaults
120
+ });
121
+ const createSectionContentProps = useFieldSectionContentProps({
122
+ manager,
123
+ stateResponse,
124
+ applyCharacterEditing,
125
+ internalPropsWithDefaults,
126
+ domGetters,
127
+ focused
128
+ });
129
+ const handleRootKeyDown = useEventCallback(event => {
130
+ onKeyDown?.(event);
131
+ rootProps.onKeyDown(event);
132
+ });
133
+ const handleRootBlur = useEventCallback(event => {
134
+ onBlur?.(event);
135
+ rootProps.onBlur(event);
136
+ });
137
+ const handleRootFocus = useEventCallback(event => {
138
+ onFocus?.(event);
139
+ rootProps.onFocus(event);
140
+ });
141
+ const handleRootClick = useEventCallback(event => {
142
+ // The click event on the clear or open button would propagate to the input, trigger this handler and result in an inadvertent section selection.
143
+ // We avoid this by checking if the call of `handleInputClick` is actually intended, or a propagated call, which should be skipped.
144
+ if (event.isDefaultPrevented()) {
145
+ return;
146
+ }
147
+ onClick?.(event);
148
+ rootProps.onClick(event);
149
+ });
150
+ const handleRootPaste = useEventCallback(event => {
151
+ onPaste?.(event);
152
+ rootProps.onPaste(event);
153
+ });
154
+ const handleRootInput = useEventCallback(event => {
155
+ onInput?.(event);
156
+ rootProps.onInput(event);
157
+ });
158
+ const handleClear = useEventCallback((event, ...args) => {
159
+ event.preventDefault();
160
+ onClear?.(event, ...args);
161
+ clearValue();
162
+ if (!isFieldFocused(sectionListRef)) {
163
+ // setSelectedSections is called internally
164
+ focusField(0);
165
+ } else {
166
+ setSelectedSections(sectionOrder.startIndex);
167
+ }
168
+ });
169
+ const elements = React.useMemo(() => {
170
+ return state.sections.map((section, sectionIndex) => {
171
+ const content = createSectionContentProps(section, sectionIndex);
172
+ return {
173
+ container: createSectionContainerProps(sectionIndex),
174
+ content,
175
+ before: {
176
+ children: section.startSeparator
177
+ },
178
+ after: {
179
+ children: section.endSeparator,
180
+ 'data-range-position': section.isEndFormatSeparator ? content['data-range-position'] : undefined
181
+ }
182
+ };
183
+ });
184
+ }, [state.sections, createSectionContainerProps, createSectionContentProps]);
185
+ React.useEffect(() => {
186
+ if (sectionListRef.current == null) {
187
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: The \`sectionListRef\` prop has not been initialized by \`PickersSectionList\`
188
+ You probably tried to pass a component to the \`textField\` slot that contains an \`<input />\` element instead of a \`PickersSectionList\`.
189
+
190
+ Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element` : _formatErrorMessage(249));
191
+ }
192
+ if (autoFocus && !disabled) {
193
+ sectionListRef.current.getSectionContent(sectionOrder.startIndex).focus();
194
+ }
195
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
196
+
197
+ useEnhancedEffect(() => {
198
+ if (!focused || !sectionListRef.current) {
199
+ return;
200
+ }
201
+ if (parsedSelectedSections === 'all') {
202
+ sectionListRef.current.getRoot().focus();
203
+ } else if (typeof parsedSelectedSections === 'number') {
204
+ const domElement = sectionListRef.current.getSectionContent(parsedSelectedSections);
205
+ if (domElement) {
206
+ domElement.focus();
207
+ }
208
+ }
209
+ }, [parsedSelectedSections, focused]);
210
+ useEnhancedEffect(() => {
211
+ syncSelectionToDOM({
212
+ focused,
213
+ domGetters,
214
+ stateResponse
215
+ });
216
+ });
217
+ React.useImperativeHandle(fieldRef, () => ({
218
+ getSections: () => state.sections,
219
+ getActiveSectionIndex: () => getActiveSectionIndex(sectionListRef),
220
+ setSelectedSections: newSelectedSections => {
221
+ if (disabled || !sectionListRef.current) {
222
+ return;
223
+ }
224
+ const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);
225
+ const newActiveSectionIndex = newParsedSelectedSections === 'all' ? 0 : newParsedSelectedSections;
226
+ setFocused(newActiveSectionIndex !== null);
227
+ setSelectedSections(newSelectedSections);
228
+ },
229
+ focusField,
230
+ isFieldFocused: () => isFieldFocused(sectionListRef),
231
+ clearValue
232
+ }));
233
+ return _extends({}, forwardedProps, rootProps, {
234
+ onBlur: handleRootBlur,
235
+ onClick: handleRootClick,
236
+ onFocus: handleRootFocus,
237
+ onInput: handleRootInput,
238
+ onPaste: handleRootPaste,
239
+ onKeyDown: handleRootKeyDown,
240
+ onClear: handleClear
241
+ }, hiddenInputProps, {
242
+ error,
243
+ clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled),
244
+ focused: focusedProp ?? focused,
245
+ sectionListRef: handleSectionListRef,
246
+ // Additional
247
+ elements,
248
+ areAllSectionsEmpty,
249
+ disabled,
250
+ readOnly,
251
+ autoFocus,
252
+ openPickerAriaLabel
253
+ });
254
+ };
255
+ function getActiveSectionIndex(sectionListRef) {
256
+ const activeElement = getActiveElement(sectionListRef.current?.getRoot());
257
+ if (!activeElement || !sectionListRef.current || !sectionListRef.current.getRoot().contains(activeElement)) {
258
+ return null;
259
+ }
260
+ return sectionListRef.current.getSectionIndexFromDOMElement(activeElement);
261
+ }
262
+ function isFieldFocused(sectionListRef) {
263
+ const activeElement = getActiveElement(sectionListRef.current?.getRoot());
264
+ return !!sectionListRef.current && sectionListRef.current.getRoot().contains(activeElement);
265
+ }
@@ -3,12 +3,12 @@ import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapte
3
3
  import { InternalPropNames } from "../../../hooks/useSplitFieldProps.mjs";
4
4
  import type { PickersSectionElement, PickersSectionListRef } from "../../../PickersSectionList/index.mjs";
5
5
  import { FormProps, InferNonNullablePickerValue, PickerRangeValue, PickerValidValue } from "../../models/index.mjs";
6
- export interface UseFieldParameters<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> {
7
- manager: PickerManager<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, any>;
6
+ export interface UseFieldParameters<TValue extends PickerValidValue, TError, TValidationProps extends {}, TProps extends UseFieldProps> {
7
+ manager: PickerManager<TValue, TError, TValidationProps, any>;
8
8
  props: TProps;
9
9
  skipContextFieldRefAssignment?: boolean;
10
10
  }
11
- export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
11
+ export interface UseFieldInternalProps<TValue extends PickerValidValue, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
12
12
  /**
13
13
  * The selected value.
14
14
  * Used when the component is controlled.
@@ -76,10 +76,6 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
76
76
  * The ref object used to imperatively interact with the field.
77
77
  */
78
78
  fieldRef?: React.Ref<FieldRef<TValue>>;
79
- /**
80
- * @default true
81
- */
82
- enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
83
79
  /**
84
80
  * If `true`, the `input` element is focused during the first mount.
85
81
  * @default false
@@ -90,18 +86,7 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
90
86
  */
91
87
  focused?: boolean;
92
88
  }
93
- export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? {
94
- clearable?: boolean;
95
- error?: boolean;
96
- placeholder?: string;
97
- inputRef?: React.Ref<HTMLInputElement>;
98
- onClick?: React.MouseEventHandler;
99
- onFocus?: React.FocusEventHandler;
100
- onKeyDown?: React.KeyboardEventHandler;
101
- onBlur?: React.FocusEventHandler;
102
- onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
103
- onClear?: React.MouseEventHandler;
104
- } : {
89
+ export interface UseFieldForwardedProps {
105
90
  clearable?: boolean;
106
91
  error?: boolean;
107
92
  focused?: boolean;
@@ -113,25 +98,12 @@ export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends bo
113
98
  onInput?: React.FormEventHandler<HTMLDivElement>;
114
99
  onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
115
100
  onClear?: React.MouseEventHandler;
116
- };
117
- type UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? {
118
- /**
119
- * The aria label to set on the button that opens the Picker.
120
- */
121
- openPickerAriaLabel: string;
122
- enableAccessibleFieldDOMStructure: false;
123
- focused: boolean | undefined;
124
- inputMode: 'text' | 'numeric';
125
- placeholder: string;
126
- value: string;
127
- onChange: React.ChangeEventHandler<HTMLInputElement>;
128
- autoComplete: 'off';
129
- } : {
101
+ }
102
+ interface UseFieldAdditionalProps {
130
103
  /**
131
104
  * The aria label to set on the button that opens the Picker.
132
105
  */
133
106
  openPickerAriaLabel: string;
134
- enableAccessibleFieldDOMStructure: true;
135
107
  elements: PickersSectionElement[];
136
108
  tabIndex: number | undefined;
137
109
  contentEditable: boolean;
@@ -139,8 +111,8 @@ type UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure extends boolean>
139
111
  onChange: React.ChangeEventHandler<HTMLInputElement>;
140
112
  areAllSectionsEmpty: boolean;
141
113
  focused: boolean;
142
- };
143
- export type UseFieldReturnValue<TEnableAccessibleFieldDOMStructure extends boolean, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> = Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> & Required<UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>> & UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure> & Omit<TProps, InternalPropNames<PickerValueType>>;
114
+ }
115
+ export type UseFieldReturnValue<TProps extends {}> = Required<Pick<UseFieldInternalProps<any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> & Required<UseFieldForwardedProps> & UseFieldAdditionalProps & Omit<TProps, InternalPropNames<PickerValueType>>;
144
116
  export type FieldSectionValueBoundaries<SectionType extends FieldSectionType> = {
145
117
  minimum: number;
146
118
  maximum: number;
@@ -172,21 +144,12 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
172
144
  */
173
145
  getSectionsFromValue: (value: TValue, getSectionsFromDate: (date: PickerValidDate | null) => FieldSection[]) => InferFieldSection<TValue>[];
174
146
  /**
175
- * Creates the string value to render in the input based on the current section list.
147
+ * Creates the string value to render in the hidden input based on the current section list.
176
148
  * @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
149
  * @param {InferFieldSection<TValue>[]} sections The current section list.
178
- * @param {string} localizedDigits The conversion table from localized to 0-9 digits.
179
- * @param {boolean} isRtl `true` if the current orientation is "right to left"
180
150
  * @returns {string} The string value to render in the input.
181
151
  */
182
- getV6InputValueFromSections: (sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => string;
183
- /**
184
- * Creates the string value to render in the input based on the current section list.
185
- * @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.
186
- * @param {InferFieldSection<TValue>[]} sections The current section list.
187
- * @returns {string} The string value to render in the input.
188
- */
189
- getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
152
+ getHiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
190
153
  /**
191
154
  * Parses a string version (most of the time coming from the input).
192
155
  * This method should only be used when the change does not come from a single section.
@@ -316,9 +279,7 @@ export interface CharacterEditingQuery {
316
279
  sectionIndex: number;
317
280
  sectionType: FieldSectionType;
318
281
  }
319
- export type UseFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure> & {
320
- enableAccessibleFieldDOMStructure?: boolean;
321
- };
282
+ export type UseFieldProps = UseFieldForwardedProps;
322
283
  export interface UseFieldDOMGetters {
323
284
  isReady: () => boolean;
324
285
  getRoot: () => HTMLElement;
@@ -3,12 +3,12 @@ import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapte
3
3
  import { InternalPropNames } from "../../../hooks/useSplitFieldProps.js";
4
4
  import type { PickersSectionElement, PickersSectionListRef } from "../../../PickersSectionList/index.js";
5
5
  import { FormProps, InferNonNullablePickerValue, PickerRangeValue, PickerValidValue } from "../../models/index.js";
6
- export interface UseFieldParameters<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> {
7
- manager: PickerManager<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, any>;
6
+ export interface UseFieldParameters<TValue extends PickerValidValue, TError, TValidationProps extends {}, TProps extends UseFieldProps> {
7
+ manager: PickerManager<TValue, TError, TValidationProps, any>;
8
8
  props: TProps;
9
9
  skipContextFieldRefAssignment?: boolean;
10
10
  }
11
- export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
11
+ export interface UseFieldInternalProps<TValue extends PickerValidValue, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
12
12
  /**
13
13
  * The selected value.
14
14
  * Used when the component is controlled.
@@ -76,10 +76,6 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
76
76
  * The ref object used to imperatively interact with the field.
77
77
  */
78
78
  fieldRef?: React.Ref<FieldRef<TValue>>;
79
- /**
80
- * @default true
81
- */
82
- enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
83
79
  /**
84
80
  * If `true`, the `input` element is focused during the first mount.
85
81
  * @default false
@@ -90,18 +86,7 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
90
86
  */
91
87
  focused?: boolean;
92
88
  }
93
- export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? {
94
- clearable?: boolean;
95
- error?: boolean;
96
- placeholder?: string;
97
- inputRef?: React.Ref<HTMLInputElement>;
98
- onClick?: React.MouseEventHandler;
99
- onFocus?: React.FocusEventHandler;
100
- onKeyDown?: React.KeyboardEventHandler;
101
- onBlur?: React.FocusEventHandler;
102
- onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
103
- onClear?: React.MouseEventHandler;
104
- } : {
89
+ export interface UseFieldForwardedProps {
105
90
  clearable?: boolean;
106
91
  error?: boolean;
107
92
  focused?: boolean;
@@ -113,25 +98,12 @@ export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends bo
113
98
  onInput?: React.FormEventHandler<HTMLDivElement>;
114
99
  onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
115
100
  onClear?: React.MouseEventHandler;
116
- };
117
- type UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? {
118
- /**
119
- * The aria label to set on the button that opens the Picker.
120
- */
121
- openPickerAriaLabel: string;
122
- enableAccessibleFieldDOMStructure: false;
123
- focused: boolean | undefined;
124
- inputMode: 'text' | 'numeric';
125
- placeholder: string;
126
- value: string;
127
- onChange: React.ChangeEventHandler<HTMLInputElement>;
128
- autoComplete: 'off';
129
- } : {
101
+ }
102
+ interface UseFieldAdditionalProps {
130
103
  /**
131
104
  * The aria label to set on the button that opens the Picker.
132
105
  */
133
106
  openPickerAriaLabel: string;
134
- enableAccessibleFieldDOMStructure: true;
135
107
  elements: PickersSectionElement[];
136
108
  tabIndex: number | undefined;
137
109
  contentEditable: boolean;
@@ -139,8 +111,8 @@ type UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure extends boolean>
139
111
  onChange: React.ChangeEventHandler<HTMLInputElement>;
140
112
  areAllSectionsEmpty: boolean;
141
113
  focused: boolean;
142
- };
143
- export type UseFieldReturnValue<TEnableAccessibleFieldDOMStructure extends boolean, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> = Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> & Required<UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>> & UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure> & Omit<TProps, InternalPropNames<PickerValueType>>;
114
+ }
115
+ export type UseFieldReturnValue<TProps extends {}> = Required<Pick<UseFieldInternalProps<any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> & Required<UseFieldForwardedProps> & UseFieldAdditionalProps & Omit<TProps, InternalPropNames<PickerValueType>>;
144
116
  export type FieldSectionValueBoundaries<SectionType extends FieldSectionType> = {
145
117
  minimum: number;
146
118
  maximum: number;
@@ -172,21 +144,12 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
172
144
  */
173
145
  getSectionsFromValue: (value: TValue, getSectionsFromDate: (date: PickerValidDate | null) => FieldSection[]) => InferFieldSection<TValue>[];
174
146
  /**
175
- * Creates the string value to render in the input based on the current section list.
147
+ * Creates the string value to render in the hidden input based on the current section list.
176
148
  * @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
149
  * @param {InferFieldSection<TValue>[]} sections The current section list.
178
- * @param {string} localizedDigits The conversion table from localized to 0-9 digits.
179
- * @param {boolean} isRtl `true` if the current orientation is "right to left"
180
150
  * @returns {string} The string value to render in the input.
181
151
  */
182
- getV6InputValueFromSections: (sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => string;
183
- /**
184
- * Creates the string value to render in the input based on the current section list.
185
- * @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.
186
- * @param {InferFieldSection<TValue>[]} sections The current section list.
187
- * @returns {string} The string value to render in the input.
188
- */
189
- getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
152
+ getHiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
190
153
  /**
191
154
  * Parses a string version (most of the time coming from the input).
192
155
  * This method should only be used when the change does not come from a single section.
@@ -316,9 +279,7 @@ export interface CharacterEditingQuery {
316
279
  sectionIndex: number;
317
280
  sectionType: FieldSectionType;
318
281
  }
319
- export type UseFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure> & {
320
- enableAccessibleFieldDOMStructure?: boolean;
321
- };
282
+ export type UseFieldProps = UseFieldForwardedProps;
322
283
  export interface UseFieldDOMGetters {
323
284
  isReady: () => boolean;
324
285
  getRoot: () => HTMLElement;
@@ -26,11 +26,10 @@ export declare const doesSectionFormatHaveLeadingZeros: (adapter: MuiPickersAdap
26
26
  * To make sure that the parsing works, we are building a format and a date without any separator.
27
27
  */
28
28
  export declare const getDateFromDateSections: (adapter: MuiPickersAdapter, sections: FieldSection[], localizedDigits: string[]) => PickerValidDate;
29
- export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
30
- export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
29
+ export declare const createDateStrForHiddenInputFromSections: (sections: FieldSection[]) => string;
31
30
  export declare const getSectionsBoundaries: (adapter: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
32
31
  export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
33
32
  export declare const mergeDateIntoReferenceDate: (adapter: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
34
33
  export declare const isAndroid: () => boolean;
35
- export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
34
+ export declare const getSectionOrder: (sections: FieldSection[]) => SectionOrdering;
36
35
  export declare const parseSelectedSections: (selectedSections: FieldSelectedSections, sections: FieldSection[]) => FieldParsedSelectedSections;
@@ -26,11 +26,10 @@ export declare const doesSectionFormatHaveLeadingZeros: (adapter: MuiPickersAdap
26
26
  * To make sure that the parsing works, we are building a format and a date without any separator.
27
27
  */
28
28
  export declare const getDateFromDateSections: (adapter: MuiPickersAdapter, sections: FieldSection[], localizedDigits: string[]) => PickerValidDate;
29
- export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
30
- export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
29
+ export declare const createDateStrForHiddenInputFromSections: (sections: FieldSection[]) => string;
31
30
  export declare const getSectionsBoundaries: (adapter: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
32
31
  export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
33
32
  export declare const mergeDateIntoReferenceDate: (adapter: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
34
33
  export declare const isAndroid: () => boolean;
35
- export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
34
+ export declare const getSectionOrder: (sections: FieldSection[]) => SectionOrdering;
36
35
  export declare const parseSelectedSections: (selectedSections: FieldSelectedSections, sections: FieldSection[]) => FieldParsedSelectedSections;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.validateSections = exports.removeLocalizedDigits = exports.parseSelectedSections = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForV7HiddenInputFromSections = exports.createDateStrForV6InputFromSections = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
7
+ exports.validateSections = exports.removeLocalizedDigits = exports.parseSelectedSections = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForHiddenInputFromSections = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
8
8
  var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
9
9
  var _dateUtils = require("../../utils/date-utils");
10
10
  const getDateSectionConfigFromFormatToken = (adapter, formatToken) => {
@@ -242,28 +242,10 @@ const getDateFromDateSections = (adapter, sections, localizedDigits) => {
242
242
  return adapter.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
243
243
  };
244
244
  exports.getDateFromDateSections = getDateFromDateSections;
245
- const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {
245
+ const createDateStrForHiddenInputFromSections = sections => sections.map(section => {
246
246
  return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;
247
247
  }).join('');
248
- exports.createDateStrForV7HiddenInputFromSections = createDateStrForV7HiddenInputFromSections;
249
- const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) => {
250
- const formattedSections = sections.map(section => {
251
- const dateValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);
252
- return `${section.startSeparator}${dateValue}${section.endSeparator}`;
253
- });
254
- const dateStr = formattedSections.join('');
255
- if (!isRtl) {
256
- return dateStr;
257
- }
258
-
259
- // \u2066: start left-to-right isolation
260
- // \u2067: start right-to-left isolation
261
- // \u2068: start first strong character isolation
262
- // \u2069: pop isolation
263
- // wrap into an isolated group such that separators can split the string in smaller ones by adding \u2069\u2068
264
- return `\u2066${dateStr}\u2069`;
265
- };
266
- exports.createDateStrForV6InputFromSections = createDateStrForV6InputFromSections;
248
+ exports.createDateStrForHiddenInputFromSections = createDateStrForHiddenInputFromSections;
267
249
  const getSectionsBoundaries = (adapter, localizedDigits, timezone) => {
268
250
  const today = adapter.date(undefined, timezone);
269
251
  const endOfYear = adapter.endOfYear(today);
@@ -453,51 +435,12 @@ const mergeDateIntoReferenceDate = (adapter, dateToTransferFrom, sections, refer
453
435
  }, referenceDate);
454
436
  exports.mergeDateIntoReferenceDate = mergeDateIntoReferenceDate;
455
437
  const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');
456
-
457
- // TODO v9: Remove
458
438
  exports.isAndroid = isAndroid;
459
- const getSectionOrder = (sections, shouldApplyRTL) => {
439
+ const getSectionOrder = sections => {
460
440
  const neighbors = {};
461
- if (!shouldApplyRTL) {
462
- sections.forEach((_, index) => {
463
- const leftIndex = index === 0 ? null : index - 1;
464
- const rightIndex = index === sections.length - 1 ? null : index + 1;
465
- neighbors[index] = {
466
- leftIndex,
467
- rightIndex
468
- };
469
- });
470
- return {
471
- neighbors,
472
- startIndex: 0,
473
- endIndex: sections.length - 1
474
- };
475
- }
476
- const rtl2ltr = {};
477
- const ltr2rtl = {};
478
- let groupedSectionsStart = 0;
479
- let groupedSectionsEnd = 0;
480
- let RTLIndex = sections.length - 1;
481
- while (RTLIndex >= 0) {
482
- groupedSectionsEnd = sections.findIndex(
483
- // eslint-disable-next-line @typescript-eslint/no-loop-func
484
- (section, index) => index >= groupedSectionsStart && section.endSeparator?.includes(' ') &&
485
- // Special case where the spaces were not there in the initial input
486
- section.endSeparator !== ' / ');
487
- if (groupedSectionsEnd === -1) {
488
- groupedSectionsEnd = sections.length - 1;
489
- }
490
- for (let i = groupedSectionsEnd; i >= groupedSectionsStart; i -= 1) {
491
- ltr2rtl[i] = RTLIndex;
492
- rtl2ltr[RTLIndex] = i;
493
- RTLIndex -= 1;
494
- }
495
- groupedSectionsStart = groupedSectionsEnd + 1;
496
- }
497
441
  sections.forEach((_, index) => {
498
- const rtlIndex = ltr2rtl[index];
499
- const leftIndex = rtlIndex === 0 ? null : rtl2ltr[rtlIndex - 1];
500
- const rightIndex = rtlIndex === sections.length - 1 ? null : rtl2ltr[rtlIndex + 1];
442
+ const leftIndex = index === 0 ? null : index - 1;
443
+ const rightIndex = index === sections.length - 1 ? null : index + 1;
501
444
  neighbors[index] = {
502
445
  leftIndex,
503
446
  rightIndex
@@ -505,8 +448,8 @@ const getSectionOrder = (sections, shouldApplyRTL) => {
505
448
  });
506
449
  return {
507
450
  neighbors,
508
- startIndex: rtl2ltr[0],
509
- endIndex: rtl2ltr[sections.length - 1]
451
+ startIndex: 0,
452
+ endIndex: sections.length - 1
510
453
  };
511
454
  };
512
455
  exports.getSectionOrder = getSectionOrder;