@mui/x-date-pickers 8.0.0-alpha.6 → 8.0.0-alpha.7

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 (281) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +2 -4
  2. package/AdapterDateFns/AdapterDateFns.js +49 -47
  3. package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -1
  4. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -4
  5. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
  6. package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts} +2 -2
  7. package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
  8. package/AdapterDateFnsJalaliV2/index.d.ts +1 -0
  9. package/AdapterDateFnsJalaliV2/index.js +1 -0
  10. package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
  11. package/{AdapterDateFnsV3/AdapterDateFnsV3.d.ts → AdapterDateFnsV2/AdapterDateFnsV2.d.ts} +2 -2
  12. package/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
  13. package/AdapterDateFnsV2/index.d.ts +1 -0
  14. package/AdapterDateFnsV2/index.js +1 -0
  15. package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
  16. package/AdapterDayjs/AdapterDayjs.d.ts +1 -1
  17. package/AdapterLuxon/AdapterLuxon.d.ts +1 -1
  18. package/AdapterMoment/AdapterMoment.d.ts +1 -1
  19. package/CHANGELOG.md +127 -1
  20. package/DateCalendar/DateCalendar.js +1 -1
  21. package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
  22. package/DateCalendar/PickersSlideTransition.d.ts +1 -1
  23. package/DateField/useDateField.d.ts +1 -1
  24. package/DateField/useDateField.js +13 -11
  25. package/DatePicker/DatePicker.js +1 -1
  26. package/DatePicker/DatePicker.types.d.ts +5 -0
  27. package/DatePicker/DatePickerToolbar.d.ts +1 -2
  28. package/DatePicker/DatePickerToolbar.js +7 -11
  29. package/DatePicker/shared.d.ts +1 -1
  30. package/DateTimeField/useDateTimeField.d.ts +1 -1
  31. package/DateTimeField/useDateTimeField.js +13 -11
  32. package/DateTimePicker/DateTimePicker.js +2 -2
  33. package/DateTimePicker/DateTimePickerTabs.js +2 -2
  34. package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -2
  35. package/DateTimePicker/DateTimePickerToolbar.js +36 -31
  36. package/DateTimePicker/shared.d.ts +1 -1
  37. package/DesktopDatePicker/DesktopDatePicker.js +9 -3
  38. package/DesktopDatePicker/DesktopDatePicker.types.d.ts +5 -0
  39. package/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
  40. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
  41. package/DesktopTimePicker/DesktopTimePicker.js +3 -7
  42. package/MobileDatePicker/MobileDatePicker.js +2 -2
  43. package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  44. package/MobileTimePicker/MobileTimePicker.js +2 -2
  45. package/PickersActionBar/PickersActionBar.d.ts +6 -3
  46. package/PickersActionBar/PickersActionBar.js +6 -3
  47. package/PickersLayout/PickersLayout.js +1 -5
  48. package/PickersLayout/PickersLayout.types.d.ts +2 -3
  49. package/PickersLayout/usePickerLayout.js +12 -31
  50. package/PickersShortcuts/PickersShortcuts.d.ts +2 -5
  51. package/PickersShortcuts/PickersShortcuts.js +13 -10
  52. package/PickersShortcuts/index.d.ts +1 -1
  53. package/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
  54. package/PickersTextField/PickersTextField.js +1 -1
  55. package/TimeField/useTimeField.d.ts +1 -1
  56. package/TimeField/useTimeField.js +13 -11
  57. package/TimePicker/TimePicker.js +2 -2
  58. package/TimePicker/TimePickerToolbar.d.ts +1 -2
  59. package/TimePicker/TimePickerToolbar.js +20 -18
  60. package/TimePicker/shared.d.ts +1 -1
  61. package/hooks/index.d.ts +1 -0
  62. package/hooks/index.js +2 -1
  63. package/hooks/useIsValidValue.d.ts +7 -0
  64. package/hooks/useIsValidValue.js +11 -0
  65. package/hooks/usePickerActionsContext.d.ts +3 -1
  66. package/hooks/usePickerActionsContext.js +0 -1
  67. package/hooks/usePickerContext.d.ts +2 -2
  68. package/hooks/usePickerContext.js +1 -1
  69. package/index.d.ts +1 -0
  70. package/index.js +3 -2
  71. package/internals/components/PickerProvider.d.ts +11 -10
  72. package/internals/components/PickerProvider.js +8 -3
  73. package/internals/components/PickersToolbar.d.ts +2 -3
  74. package/internals/components/PickersToolbar.js +1 -1
  75. package/internals/hooks/date-helpers-hooks.js +4 -3
  76. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  77. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
  78. package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
  79. package/internals/hooks/useField/index.d.ts +1 -1
  80. package/internals/hooks/useField/index.js +1 -1
  81. package/internals/hooks/useField/useField.d.ts +10 -1
  82. package/internals/hooks/useField/useField.js +17 -1
  83. package/internals/hooks/useField/useField.utils.js +2 -2
  84. package/internals/hooks/useField/useFieldState.js +2 -2
  85. package/internals/hooks/useField/useFieldV6TextField.js +2 -2
  86. package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  87. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
  88. package/internals/hooks/useOpenState.js +3 -2
  89. package/internals/hooks/usePicker/usePicker.d.ts +1 -1
  90. package/internals/hooks/usePicker/usePicker.js +0 -6
  91. package/internals/hooks/usePicker/usePicker.types.d.ts +5 -6
  92. package/internals/hooks/usePicker/usePickerProvider.d.ts +5 -5
  93. package/internals/hooks/usePicker/usePickerProvider.js +4 -2
  94. package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
  95. package/internals/hooks/usePicker/usePickerValue.js +67 -184
  96. package/internals/hooks/usePicker/usePickerValue.types.d.ts +48 -54
  97. package/internals/hooks/usePicker/usePickerViews.d.ts +27 -23
  98. package/internals/hooks/usePicker/usePickerViews.js +17 -11
  99. package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
  100. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +2 -2
  101. package/internals/hooks/useUtils.js +1 -1
  102. package/internals/index.d.ts +5 -3
  103. package/internals/index.js +5 -3
  104. package/internals/models/index.d.ts +1 -0
  105. package/internals/models/index.js +2 -1
  106. package/internals/models/manager.d.ts +12 -0
  107. package/internals/models/manager.js +1 -0
  108. package/internals/models/props/basePickerProps.d.ts +2 -2
  109. package/internals/models/props/toolbar.d.ts +1 -5
  110. package/internals/utils/date-utils.js +1 -1
  111. package/internals/utils/valueManagers.js +4 -4
  112. package/locales/index.d.ts +1 -0
  113. package/locales/index.js +1 -0
  114. package/locales/nbNO.js +15 -19
  115. package/locales/utils/getPickersLocalization.js +1 -1
  116. package/locales/zhTW.d.ts +80 -0
  117. package/locales/zhTW.js +73 -0
  118. package/managers/index.d.ts +6 -0
  119. package/managers/index.js +3 -0
  120. package/managers/package.json +6 -0
  121. package/managers/useDateManager.d.ts +27 -0
  122. package/managers/useDateManager.js +47 -0
  123. package/managers/useDateTimeManager.d.ts +28 -0
  124. package/managers/useDateTimeManager.js +52 -0
  125. package/managers/useTimeManager.d.ts +28 -0
  126. package/managers/useTimeManager.js +43 -0
  127. package/models/adapters.d.ts +1 -1
  128. package/models/index.d.ts +1 -0
  129. package/models/index.js +1 -0
  130. package/models/manager.d.ts +78 -0
  131. package/models/manager.js +1 -0
  132. package/models/pickers.d.ts +7 -0
  133. package/modern/AdapterDateFns/AdapterDateFns.js +49 -47
  134. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
  135. package/modern/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
  136. package/modern/AdapterDateFnsJalaliV2/index.js +1 -0
  137. package/modern/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
  138. package/modern/AdapterDateFnsV2/index.js +1 -0
  139. package/modern/DateCalendar/DateCalendar.js +1 -1
  140. package/modern/DateField/useDateField.js +13 -11
  141. package/modern/DatePicker/DatePicker.js +1 -1
  142. package/modern/DatePicker/DatePickerToolbar.js +7 -11
  143. package/modern/DateTimeField/useDateTimeField.js +13 -11
  144. package/modern/DateTimePicker/DateTimePicker.js +2 -2
  145. package/modern/DateTimePicker/DateTimePickerTabs.js +2 -2
  146. package/modern/DateTimePicker/DateTimePickerToolbar.js +36 -31
  147. package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -3
  148. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
  149. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
  150. package/modern/DesktopTimePicker/DesktopTimePicker.js +3 -7
  151. package/modern/MobileDatePicker/MobileDatePicker.js +2 -2
  152. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  153. package/modern/MobileTimePicker/MobileTimePicker.js +2 -2
  154. package/modern/PickersActionBar/PickersActionBar.js +6 -3
  155. package/modern/PickersLayout/PickersLayout.js +1 -5
  156. package/modern/PickersLayout/usePickerLayout.js +12 -31
  157. package/modern/PickersShortcuts/PickersShortcuts.js +13 -10
  158. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
  159. package/modern/PickersTextField/PickersTextField.js +1 -1
  160. package/modern/TimeField/useTimeField.js +13 -11
  161. package/modern/TimePicker/TimePicker.js +2 -2
  162. package/modern/TimePicker/TimePickerToolbar.js +20 -18
  163. package/modern/hooks/index.js +2 -1
  164. package/modern/hooks/useIsValidValue.js +11 -0
  165. package/modern/hooks/usePickerActionsContext.js +0 -1
  166. package/modern/hooks/usePickerContext.js +1 -1
  167. package/modern/index.js +3 -2
  168. package/modern/internals/components/PickerProvider.js +8 -3
  169. package/modern/internals/components/PickersToolbar.js +1 -1
  170. package/modern/internals/hooks/date-helpers-hooks.js +4 -3
  171. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  172. package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
  173. package/modern/internals/hooks/useField/index.js +1 -1
  174. package/modern/internals/hooks/useField/useField.js +17 -1
  175. package/modern/internals/hooks/useField/useField.utils.js +2 -2
  176. package/modern/internals/hooks/useField/useFieldState.js +2 -2
  177. package/modern/internals/hooks/useField/useFieldV6TextField.js +2 -2
  178. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  179. package/modern/internals/hooks/useOpenState.js +3 -2
  180. package/modern/internals/hooks/usePicker/usePicker.js +0 -6
  181. package/modern/internals/hooks/usePicker/usePickerProvider.js +4 -2
  182. package/modern/internals/hooks/usePicker/usePickerValue.js +67 -184
  183. package/modern/internals/hooks/usePicker/usePickerViews.js +17 -11
  184. package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
  185. package/modern/internals/hooks/useUtils.js +1 -1
  186. package/modern/internals/index.js +5 -3
  187. package/modern/internals/models/index.js +2 -1
  188. package/modern/internals/models/manager.js +1 -0
  189. package/modern/internals/utils/date-utils.js +1 -1
  190. package/modern/internals/utils/valueManagers.js +4 -4
  191. package/modern/locales/index.js +1 -0
  192. package/modern/locales/nbNO.js +15 -19
  193. package/modern/locales/utils/getPickersLocalization.js +1 -1
  194. package/modern/locales/zhTW.js +73 -0
  195. package/modern/managers/index.js +3 -0
  196. package/modern/managers/useDateManager.js +47 -0
  197. package/modern/managers/useDateTimeManager.js +52 -0
  198. package/modern/managers/useTimeManager.js +43 -0
  199. package/modern/models/index.js +1 -0
  200. package/modern/models/manager.js +1 -0
  201. package/node/AdapterDateFns/AdapterDateFns.js +97 -97
  202. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +97 -96
  203. package/node/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +94 -101
  204. package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
  205. package/node/AdapterDateFnsV2/AdapterDateFnsV2.js +291 -0
  206. package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
  207. package/node/DateCalendar/DateCalendar.js +1 -1
  208. package/node/DateField/useDateField.js +12 -10
  209. package/node/DatePicker/DatePicker.js +1 -1
  210. package/node/DatePicker/DatePickerToolbar.js +7 -11
  211. package/node/DateTimeField/useDateTimeField.js +12 -10
  212. package/node/DateTimePicker/DateTimePicker.js +2 -2
  213. package/node/DateTimePicker/DateTimePickerTabs.js +2 -2
  214. package/node/DateTimePicker/DateTimePickerToolbar.js +36 -31
  215. package/node/DesktopDatePicker/DesktopDatePicker.js +9 -3
  216. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
  217. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
  218. package/node/DesktopTimePicker/DesktopTimePicker.js +3 -7
  219. package/node/MobileDatePicker/MobileDatePicker.js +2 -2
  220. package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
  221. package/node/MobileTimePicker/MobileTimePicker.js +2 -2
  222. package/node/PickersActionBar/PickersActionBar.js +8 -5
  223. package/node/PickersLayout/PickersLayout.js +1 -5
  224. package/node/PickersLayout/usePickerLayout.js +16 -35
  225. package/node/PickersShortcuts/PickersShortcuts.js +13 -10
  226. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
  227. package/node/PickersTextField/PickersTextField.js +1 -1
  228. package/node/TimeField/useTimeField.js +12 -10
  229. package/node/TimePicker/TimePicker.js +2 -2
  230. package/node/TimePicker/TimePickerToolbar.js +20 -18
  231. package/node/hooks/index.js +8 -1
  232. package/node/hooks/useIsValidValue.js +18 -0
  233. package/node/hooks/usePickerContext.js +1 -1
  234. package/node/index.js +13 -1
  235. package/node/internals/components/PickerProvider.js +8 -3
  236. package/node/internals/components/PickersToolbar.js +1 -1
  237. package/node/internals/hooks/date-helpers-hooks.js +4 -3
  238. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
  239. package/node/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
  240. package/node/internals/hooks/useField/index.js +6 -0
  241. package/node/internals/hooks/useField/useField.js +18 -1
  242. package/node/internals/hooks/useField/useField.utils.js +2 -2
  243. package/node/internals/hooks/useField/useFieldState.js +2 -2
  244. package/node/internals/hooks/useField/useFieldV6TextField.js +2 -2
  245. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
  246. package/node/internals/hooks/useOpenState.js +4 -2
  247. package/node/internals/hooks/usePicker/usePicker.js +0 -7
  248. package/node/internals/hooks/usePicker/usePickerProvider.js +4 -2
  249. package/node/internals/hooks/usePicker/usePickerValue.js +67 -184
  250. package/node/internals/hooks/usePicker/usePickerViews.js +17 -12
  251. package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
  252. package/node/internals/hooks/useUtils.js +1 -1
  253. package/node/internals/index.js +26 -18
  254. package/node/internals/models/index.js +11 -0
  255. package/node/internals/models/manager.js +5 -0
  256. package/node/internals/utils/date-utils.js +1 -1
  257. package/node/internals/utils/valueManagers.js +4 -4
  258. package/node/locales/index.js +11 -0
  259. package/node/locales/nbNO.js +15 -19
  260. package/node/locales/utils/getPickersLocalization.js +1 -1
  261. package/node/locales/zhTW.js +79 -0
  262. package/node/managers/index.js +26 -0
  263. package/node/managers/useDateManager.js +55 -0
  264. package/node/managers/useDateTimeManager.js +60 -0
  265. package/node/managers/useTimeManager.js +51 -0
  266. package/node/models/index.js +11 -0
  267. package/node/models/manager.js +5 -0
  268. package/package.json +3 -3
  269. package/themeAugmentation/props.d.ts +1 -1
  270. package/validation/extractValidationProps.d.ts +1 -1
  271. package/AdapterDateFnsJalaliV3/index.d.ts +0 -1
  272. package/AdapterDateFnsJalaliV3/index.js +0 -1
  273. package/AdapterDateFnsV3/index.d.ts +0 -1
  274. package/AdapterDateFnsV3/index.js +0 -1
  275. package/internals/hooks/defaultizedFieldProps.d.ts +0 -18
  276. package/internals/hooks/defaultizedFieldProps.js +0 -40
  277. package/modern/AdapterDateFnsJalaliV3/index.js +0 -1
  278. package/modern/AdapterDateFnsV3/index.js +0 -1
  279. package/modern/internals/hooks/defaultizedFieldProps.js +0 -40
  280. package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -299
  281. package/node/internals/hooks/defaultizedFieldProps.js +0 -50
@@ -0,0 +1,6 @@
1
+ export { useDateManager } from './useDateManager';
2
+ export type { UseDateManagerReturnValue, UseDateManagerParameters } from './useDateManager';
3
+ export { useTimeManager } from './useTimeManager';
4
+ export type { UseTimeManagerReturnValue, UseTimeManagerParameters } from './useTimeManager';
5
+ export { useDateTimeManager } from './useDateTimeManager';
6
+ export type { UseDateTimeManagerReturnValue, UseDateTimeManagerParameters, } from './useDateTimeManager';
@@ -0,0 +1,3 @@
1
+ export { useDateManager } from "./useDateManager.js";
2
+ export { useTimeManager } from "./useTimeManager.js";
3
+ export { useDateTimeManager } from "./useDateTimeManager.js";
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/managers/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,27 @@
1
+ import type { MakeOptional } from '@mui/x-internals/types';
2
+ import { PickerManager, DateValidationError } from '../models';
3
+ import { UseFieldInternalProps } from '../internals/hooks/useField';
4
+ import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
5
+ import { ExportedValidateDateProps, ValidateDatePropsToDefault, ValidateDateProps } from '../validation/validateDate';
6
+ import { PickerValue } from '../internals/models';
7
+ export declare function useDateManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
8
+ /**
9
+ * Private utility function to get the default internal props for the fields with date editing.
10
+ * Is used by the `useDateManager` and `useDateRangeManager` hooks.
11
+ */
12
+ export declare function getDateFieldInternalPropsDefaults(parameters: GetDateFieldInternalPropsDefaultsParameters): GetDateFieldInternalPropsDefaultsReturnValue;
13
+ export interface UseDateManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> {
14
+ enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
15
+ }
16
+ export type UseDateManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, DateValidationError, DateManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, DateManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
17
+ interface DateManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateValidationError>, 'format'>, ExportedValidateDateProps {
18
+ }
19
+ interface DateManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateValidationError>, ValidateDateProps {
20
+ }
21
+ type DateManagerFieldPropsToDefault = 'format' | ValidateDatePropsToDefault;
22
+ interface GetDateFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'defaultDates' | 'utils'> {
23
+ internalProps: Pick<DateManagerFieldInternalProps<true>, DateManagerFieldPropsToDefault>;
24
+ }
25
+ interface GetDateFieldInternalPropsDefaultsReturnValue extends Pick<DateManagerFieldInternalPropsWithDefaults<true>, DateManagerFieldPropsToDefault> {
26
+ }
27
+ export {};
@@ -0,0 +1,47 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { applyDefaultDate } from "../internals/utils/date-utils.js";
6
+ import { singleItemFieldValueManager, singleItemValueManager } from "../internals/utils/valueManagers.js";
7
+ import { validateDate } from "../validation/index.js";
8
+ export function useDateManager(parameters = {}) {
9
+ const {
10
+ enableAccessibleFieldDOMStructure = true
11
+ } = parameters;
12
+ return React.useMemo(() => ({
13
+ valueType: 'date',
14
+ validator: validateDate,
15
+ internal_valueManager: singleItemValueManager,
16
+ internal_fieldValueManager: singleItemFieldValueManager,
17
+ internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
18
+ internal_applyDefaultsToFieldInternalProps: ({
19
+ internalProps,
20
+ utils,
21
+ defaultDates
22
+ }) => _extends({}, internalProps, getDateFieldInternalPropsDefaults({
23
+ defaultDates,
24
+ utils,
25
+ internalProps
26
+ }))
27
+ }), [enableAccessibleFieldDOMStructure]);
28
+ }
29
+
30
+ /**
31
+ * Private utility function to get the default internal props for the fields with date editing.
32
+ * Is used by the `useDateManager` and `useDateRangeManager` hooks.
33
+ */
34
+ export function getDateFieldInternalPropsDefaults(parameters) {
35
+ const {
36
+ defaultDates,
37
+ utils,
38
+ internalProps
39
+ } = parameters;
40
+ return {
41
+ format: internalProps.format ?? utils.formats.keyboardDate,
42
+ disablePast: internalProps.disablePast ?? false,
43
+ disableFuture: internalProps.disableFuture ?? false,
44
+ minDate: applyDefaultDate(utils, internalProps.minDate, defaultDates.minDate),
45
+ maxDate: applyDefaultDate(utils, internalProps.maxDate, defaultDates.maxDate)
46
+ };
47
+ }
@@ -0,0 +1,28 @@
1
+ import type { MakeOptional } from '@mui/x-internals/types';
2
+ import { PickerManager, DateTimeValidationError } from '../models';
3
+ import { UseFieldInternalProps } from '../internals/hooks/useField';
4
+ import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
5
+ import { AmPmProps } from '../internals/models/props/time';
6
+ import { ExportedValidateDateTimeProps, ValidateDateTimeProps, ValidateDateTimePropsToDefault } from '../validation/validateDateTime';
7
+ import { PickerValue } from '../internals/models';
8
+ export declare function useDateTimeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateTimeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
9
+ /**
10
+ * Private utility function to get the default internal props for the field with date time editing.
11
+ * Is used by the `useDateTimeManager` and `useDateTimeRangeManager` hooks.
12
+ */
13
+ export declare function getDateTimeFieldInternalPropsDefaults(parameters: GetDateTimeFieldInternalPropsDefaultsParameters): GetDateTimeFieldInternalPropsDefaultsReturnValue;
14
+ export interface UseDateTimeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> {
15
+ enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
16
+ }
17
+ export type UseDateTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError, DateTimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, DateTimeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
18
+ interface DateTimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError>, 'format'>, ExportedValidateDateTimeProps, AmPmProps {
19
+ }
20
+ interface DateTimeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError>, ValidateDateTimeProps {
21
+ }
22
+ type DateTimeManagerFieldPropsToDefault = 'format' | 'minTime' | 'maxTime' | ValidateDateTimePropsToDefault;
23
+ interface GetDateTimeFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'defaultDates' | 'utils'> {
24
+ internalProps: Pick<DateTimeManagerFieldInternalProps<true>, DateTimeManagerFieldPropsToDefault | 'minDateTime' | 'maxDateTime' | 'ampm'>;
25
+ }
26
+ interface GetDateTimeFieldInternalPropsDefaultsReturnValue extends Pick<DateTimeManagerFieldInternalPropsWithDefaults<true>, DateTimeManagerFieldPropsToDefault | 'disableIgnoringDatePartForTimeValidation'> {
27
+ }
28
+ export {};
@@ -0,0 +1,52 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { applyDefaultDate } from "../internals/utils/date-utils.js";
6
+ import { singleItemFieldValueManager, singleItemValueManager } from "../internals/utils/valueManagers.js";
7
+ import { validateDateTime } from "../validation/index.js";
8
+ export function useDateTimeManager(parameters = {}) {
9
+ const {
10
+ enableAccessibleFieldDOMStructure = true
11
+ } = parameters;
12
+ return React.useMemo(() => ({
13
+ valueType: 'date-time',
14
+ validator: validateDateTime,
15
+ internal_valueManager: singleItemValueManager,
16
+ internal_fieldValueManager: singleItemFieldValueManager,
17
+ internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
18
+ internal_applyDefaultsToFieldInternalProps: ({
19
+ internalProps,
20
+ utils,
21
+ defaultDates
22
+ }) => _extends({}, internalProps, getDateTimeFieldInternalPropsDefaults({
23
+ internalProps,
24
+ utils,
25
+ defaultDates
26
+ }))
27
+ }), [enableAccessibleFieldDOMStructure]);
28
+ }
29
+
30
+ /**
31
+ * Private utility function to get the default internal props for the field with date time editing.
32
+ * Is used by the `useDateTimeManager` and `useDateTimeRangeManager` hooks.
33
+ */
34
+ export function getDateTimeFieldInternalPropsDefaults(parameters) {
35
+ const {
36
+ defaultDates,
37
+ utils,
38
+ internalProps
39
+ } = parameters;
40
+ const ampm = internalProps.ampm ?? utils.is12HourCycleInCurrentLocale();
41
+ const defaultFormat = ampm ? utils.formats.keyboardDateTime12h : utils.formats.keyboardDateTime24h;
42
+ return {
43
+ disablePast: internalProps.disablePast ?? false,
44
+ disableFuture: internalProps.disableFuture ?? false,
45
+ format: internalProps.format ?? defaultFormat,
46
+ disableIgnoringDatePartForTimeValidation: Boolean(internalProps.minDateTime || internalProps.maxDateTime),
47
+ minDate: applyDefaultDate(utils, internalProps.minDateTime ?? internalProps.minDate, defaultDates.minDate),
48
+ maxDate: applyDefaultDate(utils, internalProps.maxDateTime ?? internalProps.maxDate, defaultDates.maxDate),
49
+ minTime: internalProps.minDateTime ?? internalProps.minTime,
50
+ maxTime: internalProps.maxDateTime ?? internalProps.maxTime
51
+ };
52
+ }
@@ -0,0 +1,28 @@
1
+ import type { MakeOptional } from '@mui/x-internals/types';
2
+ import { PickerManager, TimeValidationError } from '../models';
3
+ import { UseFieldInternalProps } from '../internals/hooks/useField';
4
+ import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
5
+ import { AmPmProps } from '../internals/models/props/time';
6
+ import { ExportedValidateTimeProps, ValidateTimeProps, ValidateTimePropsToDefault } from '../validation/validateTime';
7
+ import { PickerValue } from '../internals/models';
8
+ export declare function useTimeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseTimeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
9
+ /**
10
+ * Private utility function to get the default internal props for the fields with time editing.
11
+ * Is used by the `useTimeManager` and `useTimeRangeManager` hooks.
12
+ */
13
+ export declare function getTimeFieldInternalPropsDefaults(parameters: GetTimeFieldInternalPropsDefaultsParameters): GetTimeFieldInternalPropsDefaultsReturnValue;
14
+ export interface UseTimeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> {
15
+ enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
16
+ }
17
+ export type UseTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError, TimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>, TimeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure>>;
18
+ interface TimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError>, 'format'>, ExportedValidateTimeProps, AmPmProps {
19
+ }
20
+ interface TimeManagerFieldInternalPropsWithDefaults<TEnableAccessibleFieldDOMStructure extends boolean> extends UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError>, ValidateTimeProps {
21
+ }
22
+ type TimeManagerFieldPropsToDefault = 'format' | ValidateTimePropsToDefault;
23
+ interface GetTimeFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'utils'> {
24
+ internalProps: Pick<TimeManagerFieldInternalProps<true>, TimeManagerFieldPropsToDefault | 'ampm'>;
25
+ }
26
+ interface GetTimeFieldInternalPropsDefaultsReturnValue extends Pick<TimeManagerFieldInternalPropsWithDefaults<true>, TimeManagerFieldPropsToDefault> {
27
+ }
28
+ export {};
@@ -0,0 +1,43 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { singleItemFieldValueManager, singleItemValueManager } from "../internals/utils/valueManagers.js";
6
+ import { validateTime } from "../validation/index.js";
7
+ export function useTimeManager(parameters = {}) {
8
+ const {
9
+ enableAccessibleFieldDOMStructure = true
10
+ } = parameters;
11
+ return React.useMemo(() => ({
12
+ valueType: 'time',
13
+ validator: validateTime,
14
+ internal_valueManager: singleItemValueManager,
15
+ internal_fieldValueManager: singleItemFieldValueManager,
16
+ internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
17
+ internal_applyDefaultsToFieldInternalProps: ({
18
+ internalProps,
19
+ utils
20
+ }) => _extends({}, internalProps, getTimeFieldInternalPropsDefaults({
21
+ utils,
22
+ internalProps
23
+ }))
24
+ }), [enableAccessibleFieldDOMStructure]);
25
+ }
26
+
27
+ /**
28
+ * Private utility function to get the default internal props for the fields with time editing.
29
+ * Is used by the `useTimeManager` and `useTimeRangeManager` hooks.
30
+ */
31
+ export function getTimeFieldInternalPropsDefaults(parameters) {
32
+ const {
33
+ utils,
34
+ internalProps
35
+ } = parameters;
36
+ const ampm = internalProps.ampm ?? utils.is12HourCycleInCurrentLocale();
37
+ const defaultFormat = ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h;
38
+ return {
39
+ disablePast: internalProps.disablePast ?? false,
40
+ disableFuture: internalProps.disableFuture ?? false,
41
+ format: internalProps.format ?? defaultFormat
42
+ };
43
+ }
@@ -225,7 +225,7 @@ export interface MuiPickersAdapter<TLocale = any> {
225
225
  * @param {PickerValidDate | null} value The value to test.
226
226
  * @returns {boolean} `true` if the value is a valid date according to the date library.
227
227
  */
228
- isValid(value: PickerValidDate | null): boolean;
228
+ isValid(value: PickerValidDate | null): value is PickerValidDate;
229
229
  /**
230
230
  * Format a date using an adapter format string (see the `AdapterFormats` interface)
231
231
  * @param {PickerValidDate} value The date to format.
package/models/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './views';
5
5
  export * from './adapters';
6
6
  export * from './common';
7
7
  export * from './pickers';
8
+ export * from './manager';
8
9
  export type { PropsFromSlot } from '@mui/x-internals/slots';
package/models/index.js CHANGED
@@ -5,6 +5,7 @@ export * from "./views.js";
5
5
  export * from "./adapters.js";
6
6
  export * from "./common.js";
7
7
  export * from "./pickers.js";
8
+ export * from "./manager.js";
8
9
 
9
10
  // Utils shared across the X packages
10
11
  export {};
@@ -0,0 +1,78 @@
1
+ import type { FieldValueManager, UseFieldInternalProps } from '../internals/hooks/useField';
2
+ import type { PickerValueManager } from '../internals/hooks/usePicker';
3
+ import type { PickerValidValue } from '../internals/models';
4
+ import type { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
5
+ import type { Validator } from '../validation';
6
+ import type { PickerValueType } from './common';
7
+ /**
8
+ * Object that contains all the necessary methods and properties to adapter a picker or a field for a given value type.
9
+ * You should never create your own manager.
10
+ * Instead, use the hooks exported from '@mui/x-date-pickers/managers' and '@mui/x-date-pickers-pro/managers'.
11
+ *
12
+ * ```tsx
13
+ * import { useDateManager } from '@mui/x-date-pickers/managers';
14
+ * import { useValidation } from '@mui/x-date-pickers/validation';
15
+ *
16
+ * const manager = useDateManager();
17
+ * const { hasValidationError } = useValidation({
18
+ * validator: manager.validator,
19
+ * value,
20
+ * timezone,
21
+ * props,
22
+ * });
23
+ * ```
24
+ */
25
+ export interface PickerManager<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TFieldInternalProps extends {}, TFieldInternalPropsWithDefaults extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, TError>> {
26
+ /**
27
+ * The type of the value (e.g. 'date', 'date-time', 'time').
28
+ */
29
+ valueType: PickerValueType;
30
+ /**
31
+ * Checks if a value is valid and returns an error code otherwise.
32
+ * It can be passed to the `useValidation` hook to validate a value:
33
+ *
34
+ * ```tsx
35
+ * import { useDateManager } from '@mui/x-date-pickers/managers';
36
+ * import { useValidation } from '@mui/x-date-pickers/validation';
37
+ *
38
+ * const manager = useDateManager();
39
+ * const { hasValidationError } = useValidation({
40
+ * validator: manager.validator,
41
+ * value,
42
+ * timezone,
43
+ * props,
44
+ * });
45
+ * ```
46
+ */
47
+ validator: Validator<TValue, TError, TFieldInternalPropsWithDefaults>;
48
+ /**
49
+ * Object containing basic methods to interact with the value of the picker or field.
50
+ * This property is not part of the public API and should not be used directly.
51
+ */
52
+ internal_valueManager: PickerValueManager<TValue, TError>;
53
+ /**
54
+ * Object containing all the necessary methods to interact with the value of the field.
55
+ * This property is not part of the public API and should not be used directly.
56
+ */
57
+ internal_fieldValueManager: FieldValueManager<TValue>;
58
+ /**
59
+ * `true` if the field is using the accessible DOM structure.
60
+ * `false` if the field is using the non-accessible DOM structure.
61
+ * This property is not part of the public API and should not be used directly.
62
+ */
63
+ internal_enableAccessibleFieldDOMStructure: TEnableAccessibleFieldDOMStructure;
64
+ /**
65
+ * Applies the default values to the field internal props.
66
+ * This usually includes:
67
+ * - a default format to display the value in the field
68
+ * - some default validation props that are needed to validate the value (e.g: minDate, maxDate)
69
+ * This property is not part of the public API and should not be used directly.
70
+ * @param {ApplyDefaultsToFieldInternalPropsParameters} parameters The parameters to apply the defaults.
71
+ * @returns {TFieldInternalPropsWithDefaults} The field internal props with the defaults applied.
72
+ */
73
+ internal_applyDefaultsToFieldInternalProps: (parameters: ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps>) => TFieldInternalPropsWithDefaults;
74
+ }
75
+ interface ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps extends {}> extends MuiPickersAdapterContextValue {
76
+ internalProps: TFieldInternalProps;
77
+ }
78
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -11,6 +11,13 @@ export interface PickerChangeHandlerContext<TError> {
11
11
  export interface PickerValidDateLookup {
12
12
  }
13
13
  export type PickerValidDate = keyof PickerValidDateLookup extends never ? any : PickerValidDateLookup[keyof PickerValidDateLookup];
14
+ /**
15
+ * Importance of the change when picking a value:
16
+ * - "accept": fires `onChange`, fires `onAccept` and closes the picker.
17
+ * - "set": fires `onChange` but do not fire `onAccept` and does not close the picker.
18
+ * @default "accept"
19
+ */
20
+ export type PickerChangeImportance = 'set' | 'accept';
14
21
  export interface PickerOwnerState {
15
22
  /**
16
23
  * `true` if the value of the picker is currently empty.
@@ -1,49 +1,47 @@
1
1
  /* eslint-disable class-methods-use-this */
2
- import addDays from 'date-fns/addDays';
3
- import addSeconds from 'date-fns/addSeconds';
4
- import addMinutes from 'date-fns/addMinutes';
5
- import addHours from 'date-fns/addHours';
6
- import addWeeks from 'date-fns/addWeeks';
7
- import addMonths from 'date-fns/addMonths';
8
- import addYears from 'date-fns/addYears';
9
- import endOfDay from 'date-fns/endOfDay';
10
- import endOfWeek from 'date-fns/endOfWeek';
11
- import endOfYear from 'date-fns/endOfYear';
12
- import dateFnsFormat from 'date-fns/format';
13
- import getDate from 'date-fns/getDate';
14
- import getDaysInMonth from 'date-fns/getDaysInMonth';
15
- import getHours from 'date-fns/getHours';
16
- import getMinutes from 'date-fns/getMinutes';
17
- import getMonth from 'date-fns/getMonth';
18
- import getSeconds from 'date-fns/getSeconds';
19
- import getMilliseconds from 'date-fns/getMilliseconds';
20
- import getWeek from 'date-fns/getWeek';
21
- import getYear from 'date-fns/getYear';
22
- import isAfter from 'date-fns/isAfter';
23
- import isBefore from 'date-fns/isBefore';
24
- import isEqual from 'date-fns/isEqual';
25
- import isSameDay from 'date-fns/isSameDay';
26
- import isSameYear from 'date-fns/isSameYear';
27
- import isSameMonth from 'date-fns/isSameMonth';
28
- import isSameHour from 'date-fns/isSameHour';
29
- import isValid from 'date-fns/isValid';
30
- import dateFnsParse from 'date-fns/parse';
31
- import setDate from 'date-fns/setDate';
32
- import setHours from 'date-fns/setHours';
33
- import setMinutes from 'date-fns/setMinutes';
34
- import setMonth from 'date-fns/setMonth';
35
- import setSeconds from 'date-fns/setSeconds';
36
- import setMilliseconds from 'date-fns/setMilliseconds';
37
- import setYear from 'date-fns/setYear';
38
- import startOfDay from 'date-fns/startOfDay';
39
- import startOfMonth from 'date-fns/startOfMonth';
40
- import endOfMonth from 'date-fns/endOfMonth';
41
- import startOfWeek from 'date-fns/startOfWeek';
42
- import startOfYear from 'date-fns/startOfYear';
43
- import isWithinInterval from 'date-fns/isWithinInterval';
44
- import defaultLocale from 'date-fns/locale/en-US';
45
- // @ts-ignore
46
- import longFormatters from 'date-fns/_lib/format/longFormatters';
2
+ import { addDays } from 'date-fns/addDays';
3
+ import { addSeconds } from 'date-fns/addSeconds';
4
+ import { addMinutes } from 'date-fns/addMinutes';
5
+ import { addHours } from 'date-fns/addHours';
6
+ import { addWeeks } from 'date-fns/addWeeks';
7
+ import { addMonths } from 'date-fns/addMonths';
8
+ import { addYears } from 'date-fns/addYears';
9
+ import { endOfDay } from 'date-fns/endOfDay';
10
+ import { endOfWeek } from 'date-fns/endOfWeek';
11
+ import { endOfYear } from 'date-fns/endOfYear';
12
+ import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
13
+ import { getDate } from 'date-fns/getDate';
14
+ import { getDaysInMonth } from 'date-fns/getDaysInMonth';
15
+ import { getHours } from 'date-fns/getHours';
16
+ import { getMinutes } from 'date-fns/getMinutes';
17
+ import { getMonth } from 'date-fns/getMonth';
18
+ import { getSeconds } from 'date-fns/getSeconds';
19
+ import { getMilliseconds } from 'date-fns/getMilliseconds';
20
+ import { getWeek } from 'date-fns/getWeek';
21
+ import { getYear } from 'date-fns/getYear';
22
+ import { isAfter } from 'date-fns/isAfter';
23
+ import { isBefore } from 'date-fns/isBefore';
24
+ import { isEqual } from 'date-fns/isEqual';
25
+ import { isSameDay } from 'date-fns/isSameDay';
26
+ import { isSameYear } from 'date-fns/isSameYear';
27
+ import { isSameMonth } from 'date-fns/isSameMonth';
28
+ import { isSameHour } from 'date-fns/isSameHour';
29
+ import { isValid } from 'date-fns/isValid';
30
+ import { parse as dateFnsParse } from 'date-fns/parse';
31
+ import { setDate } from 'date-fns/setDate';
32
+ import { setHours } from 'date-fns/setHours';
33
+ import { setMinutes } from 'date-fns/setMinutes';
34
+ import { setMonth } from 'date-fns/setMonth';
35
+ import { setSeconds } from 'date-fns/setSeconds';
36
+ import { setMilliseconds } from 'date-fns/setMilliseconds';
37
+ import { setYear } from 'date-fns/setYear';
38
+ import { startOfDay } from 'date-fns/startOfDay';
39
+ import { startOfMonth } from 'date-fns/startOfMonth';
40
+ import { endOfMonth } from 'date-fns/endOfMonth';
41
+ import { startOfWeek } from 'date-fns/startOfWeek';
42
+ import { startOfYear } from 'date-fns/startOfYear';
43
+ import { isWithinInterval } from 'date-fns/isWithinInterval';
44
+ import { enUS } from 'date-fns/locale/en-US';
47
45
  import { AdapterDateFnsBase } from "../AdapterDateFnsBase/index.js";
48
46
  /**
49
47
  * Based on `@date-io/date-fns`
@@ -78,14 +76,18 @@ export class AdapterDateFns extends AdapterDateFnsBase {
78
76
  /* istanbul ignore next */
79
77
  if (process.env.NODE_ENV !== 'production') {
80
78
  if (typeof addDays !== 'function') {
81
- throw new Error(['MUI: This adapter is only compatible with `date-fns` v2.x package versions.', 'Please, install v2.x of the package or use the `AdapterDateFnsV3` instead.'].join('\n'));
79
+ throw new Error(['MUI: The `date-fns` package v2.x is not compatible with this adapter.', 'Please, install v3.x or v4.x of the package or use the `AdapterDateFnsV2` instead.'].join('\n'));
80
+ }
81
+ if (!longFormatters) {
82
+ throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
82
83
  }
83
84
  }
84
85
  super({
85
- locale: locale ?? defaultLocale,
86
+ locale: locale ?? enUS,
86
87
  formats,
87
88
  longFormatters
88
89
  });
90
+ // TODO: explicit return types can be removed once there is only one date-fns version supported
89
91
  this.parse = (value, format) => {
90
92
  if (value === '') {
91
93
  return null;
@@ -1,50 +1,48 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  /* eslint-disable class-methods-use-this */
3
- import addSeconds from 'date-fns-jalali/addSeconds';
4
- import addMinutes from 'date-fns-jalali/addMinutes';
5
- import addHours from 'date-fns-jalali/addHours';
6
- import addDays from 'date-fns-jalali/addDays';
7
- import addWeeks from 'date-fns-jalali/addWeeks';
8
- import addMonths from 'date-fns-jalali/addMonths';
9
- import addYears from 'date-fns-jalali/addYears';
10
- import endOfDay from 'date-fns-jalali/endOfDay';
11
- import endOfWeek from 'date-fns-jalali/endOfWeek';
12
- import endOfYear from 'date-fns-jalali/endOfYear';
13
- import dateFnsFormat from 'date-fns-jalali/format';
14
- import getHours from 'date-fns-jalali/getHours';
15
- import getSeconds from 'date-fns-jalali/getSeconds';
16
- import getMilliseconds from 'date-fns-jalali/getMilliseconds';
17
- import getWeek from 'date-fns-jalali/getWeek';
18
- import getYear from 'date-fns-jalali/getYear';
19
- import getMonth from 'date-fns-jalali/getMonth';
20
- import getDate from 'date-fns-jalali/getDate';
21
- import getDaysInMonth from 'date-fns-jalali/getDaysInMonth';
22
- import getMinutes from 'date-fns-jalali/getMinutes';
23
- import isAfter from 'date-fns-jalali/isAfter';
24
- import isBefore from 'date-fns-jalali/isBefore';
25
- import isEqual from 'date-fns-jalali/isEqual';
26
- import isSameDay from 'date-fns-jalali/isSameDay';
27
- import isSameYear from 'date-fns-jalali/isSameYear';
28
- import isSameMonth from 'date-fns-jalali/isSameMonth';
29
- import isSameHour from 'date-fns-jalali/isSameHour';
30
- import isValid from 'date-fns-jalali/isValid';
31
- import dateFnsParse from 'date-fns-jalali/parse';
32
- import setDate from 'date-fns-jalali/setDate';
33
- import setHours from 'date-fns-jalali/setHours';
34
- import setMinutes from 'date-fns-jalali/setMinutes';
35
- import setMonth from 'date-fns-jalali/setMonth';
36
- import setSeconds from 'date-fns-jalali/setSeconds';
37
- import setMilliseconds from 'date-fns-jalali/setMilliseconds';
38
- import setYear from 'date-fns-jalali/setYear';
39
- import startOfDay from 'date-fns-jalali/startOfDay';
40
- import startOfMonth from 'date-fns-jalali/startOfMonth';
41
- import endOfMonth from 'date-fns-jalali/endOfMonth';
42
- import startOfWeek from 'date-fns-jalali/startOfWeek';
43
- import startOfYear from 'date-fns-jalali/startOfYear';
44
- import isWithinInterval from 'date-fns-jalali/isWithinInterval';
45
- import defaultLocale from 'date-fns-jalali/locale/fa-IR';
46
- // @ts-ignore
47
- import longFormatters from 'date-fns-jalali/_lib/format/longFormatters';
3
+ import { addSeconds } from 'date-fns-jalali/addSeconds';
4
+ import { addMinutes } from 'date-fns-jalali/addMinutes';
5
+ import { addHours } from 'date-fns-jalali/addHours';
6
+ import { addDays } from 'date-fns-jalali/addDays';
7
+ import { addWeeks } from 'date-fns-jalali/addWeeks';
8
+ import { addMonths } from 'date-fns-jalali/addMonths';
9
+ import { addYears } from 'date-fns-jalali/addYears';
10
+ import { endOfDay } from 'date-fns-jalali/endOfDay';
11
+ import { endOfWeek } from 'date-fns-jalali/endOfWeek';
12
+ import { endOfYear } from 'date-fns-jalali/endOfYear';
13
+ import { format as dateFnsFormat, longFormatters } from 'date-fns-jalali/format';
14
+ import { getHours } from 'date-fns-jalali/getHours';
15
+ import { getSeconds } from 'date-fns-jalali/getSeconds';
16
+ import { getMilliseconds } from 'date-fns-jalali/getMilliseconds';
17
+ import { getWeek } from 'date-fns-jalali/getWeek';
18
+ import { getYear } from 'date-fns-jalali/getYear';
19
+ import { getMonth } from 'date-fns-jalali/getMonth';
20
+ import { getDate } from 'date-fns-jalali/getDate';
21
+ import { getDaysInMonth } from 'date-fns-jalali/getDaysInMonth';
22
+ import { getMinutes } from 'date-fns-jalali/getMinutes';
23
+ import { isAfter } from 'date-fns-jalali/isAfter';
24
+ import { isBefore } from 'date-fns-jalali/isBefore';
25
+ import { isEqual } from 'date-fns-jalali/isEqual';
26
+ import { isSameDay } from 'date-fns-jalali/isSameDay';
27
+ import { isSameYear } from 'date-fns-jalali/isSameYear';
28
+ import { isSameMonth } from 'date-fns-jalali/isSameMonth';
29
+ import { isSameHour } from 'date-fns-jalali/isSameHour';
30
+ import { isValid } from 'date-fns-jalali/isValid';
31
+ import { parse as dateFnsParse } from 'date-fns-jalali/parse';
32
+ import { setDate } from 'date-fns-jalali/setDate';
33
+ import { setHours } from 'date-fns-jalali/setHours';
34
+ import { setMinutes } from 'date-fns-jalali/setMinutes';
35
+ import { setMonth } from 'date-fns-jalali/setMonth';
36
+ import { setSeconds } from 'date-fns-jalali/setSeconds';
37
+ import { setMilliseconds } from 'date-fns-jalali/setMilliseconds';
38
+ import { setYear } from 'date-fns-jalali/setYear';
39
+ import { startOfDay } from 'date-fns-jalali/startOfDay';
40
+ import { startOfMonth } from 'date-fns-jalali/startOfMonth';
41
+ import { endOfMonth } from 'date-fns-jalali/endOfMonth';
42
+ import { startOfWeek } from 'date-fns-jalali/startOfWeek';
43
+ import { startOfYear } from 'date-fns-jalali/startOfYear';
44
+ import { isWithinInterval } from 'date-fns-jalali/isWithinInterval';
45
+ import { faIR as defaultLocale } from 'date-fns-jalali/locale/fa-IR';
48
46
  import { AdapterDateFnsBase } from "../AdapterDateFnsBase/index.js";
49
47
  const defaultFormats = {
50
48
  year: 'yyyy',
@@ -116,7 +114,10 @@ export class AdapterDateFnsJalali extends AdapterDateFnsBase {
116
114
  /* istanbul ignore next */
117
115
  if (process.env.NODE_ENV !== 'production') {
118
116
  if (typeof addDays !== 'function') {
119
- throw new Error(['MUI: The `date-fns-jalali` package v3.x is not compatible with this adapter.', 'Please, install v2.x of the package or use the `AdapterDateFnsJalaliV3` instead.'].join('\n'));
117
+ throw new Error(['MUI: The `date-fns-jalali` package v2.x is not compatible with this adapter.', 'Please, install v3.x or v4.x of the package or use the `AdapterDateFnsJalaliV2` instead.'].join('\n'));
118
+ }
119
+ if (!longFormatters) {
120
+ throw new Error('MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.');
120
121
  }
121
122
  }
122
123
  super({
@@ -127,6 +128,7 @@ export class AdapterDateFnsJalali extends AdapterDateFnsBase {
127
128
  longFormatters,
128
129
  lib: 'date-fns-jalali'
129
130
  });
131
+ // TODO: explicit return types can be removed once there is only one date-fns version supported
130
132
  this.parse = (value, format) => {
131
133
  if (value === '') {
132
134
  return null;