@mui/x-date-pickers 8.0.0-alpha.0 → 8.0.0-alpha.2

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 (223) hide show
  1. package/AdapterMoment/AdapterMoment.js +10 -0
  2. package/CHANGELOG.md +651 -6
  3. package/DateCalendar/DateCalendar.js +1 -0
  4. package/DateCalendar/DateCalendar.types.d.ts +2 -1
  5. package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  6. package/DateCalendar/PickersSlideTransition.js +12 -5
  7. package/DateCalendar/useCalendarState.d.ts +6 -4
  8. package/DateField/DateField.js +5 -4
  9. package/DateField/DateField.types.d.ts +10 -9
  10. package/DatePicker/DatePicker.types.d.ts +3 -3
  11. package/DatePicker/DatePickerToolbar.d.ts +3 -2
  12. package/DatePicker/DatePickerToolbar.js +0 -12
  13. package/DatePicker/shared.d.ts +6 -5
  14. package/DateTimeField/DateTimeField.js +5 -4
  15. package/DateTimeField/DateTimeField.types.d.ts +10 -10
  16. package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  17. package/DateTimePicker/DateTimePickerTabs.js +8 -6
  18. package/DateTimePicker/DateTimePickerToolbar.d.ts +3 -4
  19. package/DateTimePicker/DateTimePickerToolbar.js +6 -15
  20. package/DateTimePicker/shared.d.ts +6 -6
  21. package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  22. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
  23. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
  24. package/DigitalClock/DigitalClock.js +1 -0
  25. package/MonthCalendar/MonthCalendar.js +1 -0
  26. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  27. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
  28. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
  29. package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  30. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
  31. package/PickersLayout/PickersLayout.d.ts +7 -5
  32. package/PickersLayout/PickersLayout.js +22 -39
  33. package/PickersLayout/PickersLayout.types.d.ts +14 -15
  34. package/PickersLayout/usePickerLayout.d.ts +5 -4
  35. package/PickersLayout/usePickerLayout.js +20 -17
  36. package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
  37. package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  38. package/PickersTextField/PickersTextField.js +2 -2
  39. package/README.md +9 -6
  40. package/TimeClock/Clock.js +1 -0
  41. package/TimeClock/TimeClock.js +1 -0
  42. package/TimeField/TimeField.js +5 -4
  43. package/TimeField/TimeField.types.d.ts +10 -10
  44. package/TimePicker/TimePicker.types.d.ts +3 -3
  45. package/TimePicker/TimePickerToolbar.d.ts +2 -3
  46. package/TimePicker/TimePickerToolbar.js +6 -15
  47. package/TimePicker/shared.d.ts +6 -6
  48. package/YearCalendar/YearCalendar.js +1 -0
  49. package/hooks/useParsedFormat.d.ts +2 -2
  50. package/hooks/useParsedFormat.js +1 -1
  51. package/hooks/useSplitFieldProps.d.ts +3 -3
  52. package/index.js +1 -1
  53. package/internals/components/PickerProvider.d.ts +26 -0
  54. package/internals/components/PickerProvider.js +3 -1
  55. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  56. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
  57. package/internals/components/PickersToolbar.d.ts +3 -3
  58. package/internals/components/PickersToolbar.js +2 -4
  59. package/internals/hooks/useClockReferenceDate.d.ts +2 -1
  60. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  61. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
  62. package/internals/hooks/useField/useField.d.ts +3 -3
  63. package/internals/hooks/useField/useField.types.d.ts +46 -46
  64. package/internals/hooks/useField/useField.utils.d.ts +4 -3
  65. package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
  66. package/internals/hooks/useField/useFieldState.d.ts +9 -8
  67. package/internals/hooks/useField/useFieldState.js +1 -1
  68. package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
  69. package/internals/hooks/useField/useFieldV7TextField.js +2 -1
  70. package/internals/hooks/useFieldOwnerState.d.ts +6 -0
  71. package/internals/hooks/useFieldOwnerState.js +12 -0
  72. package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  73. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
  74. package/internals/hooks/usePicker/usePicker.d.ts +3 -3
  75. package/internals/hooks/usePicker/usePicker.js +10 -19
  76. package/internals/hooks/usePicker/usePicker.types.d.ts +8 -8
  77. package/internals/hooks/usePicker/usePickerProvider.d.ts +21 -6
  78. package/internals/hooks/usePicker/usePickerProvider.js +61 -5
  79. package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
  80. package/internals/hooks/usePicker/usePickerValue.js +18 -7
  81. package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -30
  82. package/internals/hooks/usePicker/usePickerViews.d.ts +11 -10
  83. package/internals/hooks/usePicker/usePickerViews.js +1 -0
  84. package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  85. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
  86. package/internals/hooks/useValueWithTimezone.d.ts +20 -15
  87. package/internals/hooks/useValueWithTimezone.js +13 -1
  88. package/internals/hooks/useViews.d.ts +5 -5
  89. package/internals/index.d.ts +5 -3
  90. package/internals/index.js +1 -0
  91. package/internals/models/common.d.ts +2 -1
  92. package/internals/models/fields.d.ts +6 -1
  93. package/internals/models/pickers.d.ts +1 -0
  94. package/internals/models/pickers.js +1 -0
  95. package/internals/models/props/basePickerProps.d.ts +4 -3
  96. package/internals/models/props/time.d.ts +2 -1
  97. package/internals/models/props/toolbar.d.ts +2 -2
  98. package/internals/models/value.d.ts +9 -0
  99. package/internals/utils/date-utils.d.ts +3 -3
  100. package/internals/utils/valueManagers.d.ts +4 -3
  101. package/locales/nlNL.js +7 -7
  102. package/models/adapters.d.ts +4 -4
  103. package/models/common.d.ts +1 -0
  104. package/models/fields.d.ts +19 -6
  105. package/models/pickers.d.ts +18 -0
  106. package/models/validation.d.ts +2 -1
  107. package/modern/AdapterMoment/AdapterMoment.js +10 -0
  108. package/modern/DateCalendar/DateCalendar.js +1 -0
  109. package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  110. package/modern/DateCalendar/PickersSlideTransition.js +12 -5
  111. package/modern/DateField/DateField.js +5 -4
  112. package/modern/DatePicker/DatePickerToolbar.js +0 -12
  113. package/modern/DateTimeField/DateTimeField.js +5 -4
  114. package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
  115. package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
  116. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  117. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
  118. package/modern/DigitalClock/DigitalClock.js +1 -0
  119. package/modern/MonthCalendar/MonthCalendar.js +1 -0
  120. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  121. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  122. package/modern/PickersLayout/PickersLayout.js +22 -39
  123. package/modern/PickersLayout/usePickerLayout.js +20 -17
  124. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  125. package/modern/PickersTextField/PickersTextField.js +2 -2
  126. package/modern/TimeClock/Clock.js +1 -0
  127. package/modern/TimeClock/TimeClock.js +1 -0
  128. package/modern/TimeField/TimeField.js +5 -4
  129. package/modern/TimePicker/TimePickerToolbar.js +6 -15
  130. package/modern/YearCalendar/YearCalendar.js +1 -0
  131. package/modern/hooks/useParsedFormat.js +1 -1
  132. package/modern/index.js +1 -1
  133. package/modern/internals/components/PickerProvider.js +3 -1
  134. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  135. package/modern/internals/components/PickersToolbar.js +2 -4
  136. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  137. package/modern/internals/hooks/useField/useFieldState.js +1 -1
  138. package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
  139. package/modern/internals/hooks/useFieldOwnerState.js +12 -0
  140. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  141. package/modern/internals/hooks/usePicker/usePicker.js +10 -19
  142. package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
  143. package/modern/internals/hooks/usePicker/usePickerValue.js +18 -7
  144. package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
  145. package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  146. package/modern/internals/hooks/useValueWithTimezone.js +13 -1
  147. package/modern/internals/index.js +1 -0
  148. package/modern/internals/models/pickers.js +1 -0
  149. package/modern/locales/nlNL.js +7 -7
  150. package/modern/validation/useValidation.js +1 -1
  151. package/modern/validation/validateDate.js +8 -0
  152. package/modern/validation/validateDateTime.js +8 -0
  153. package/modern/validation/validateTime.js +8 -0
  154. package/node/AdapterMoment/AdapterMoment.js +10 -0
  155. package/node/DateCalendar/DateCalendar.js +1 -0
  156. package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  157. package/node/DateCalendar/PickersSlideTransition.js +12 -5
  158. package/node/DateField/DateField.js +5 -4
  159. package/node/DatePicker/DatePickerToolbar.js +0 -12
  160. package/node/DateTimeField/DateTimeField.js +5 -4
  161. package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
  162. package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
  163. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  164. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -34
  165. package/node/DigitalClock/DigitalClock.js +1 -0
  166. package/node/MonthCalendar/MonthCalendar.js +1 -0
  167. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  168. package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  169. package/node/PickersLayout/PickersLayout.js +22 -39
  170. package/node/PickersLayout/usePickerLayout.js +20 -17
  171. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  172. package/node/PickersTextField/PickersTextField.js +2 -2
  173. package/node/TimeClock/Clock.js +1 -0
  174. package/node/TimeClock/TimeClock.js +1 -0
  175. package/node/TimeField/TimeField.js +5 -4
  176. package/node/TimePicker/TimePickerToolbar.js +6 -15
  177. package/node/YearCalendar/YearCalendar.js +1 -0
  178. package/node/hooks/useParsedFormat.js +1 -1
  179. package/node/index.js +1 -1
  180. package/node/internals/components/PickerProvider.js +3 -1
  181. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  182. package/node/internals/components/PickersToolbar.js +2 -4
  183. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  184. package/node/internals/hooks/useField/useFieldState.js +1 -1
  185. package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
  186. package/node/internals/hooks/useFieldOwnerState.js +20 -0
  187. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  188. package/node/internals/hooks/usePicker/usePicker.js +11 -19
  189. package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
  190. package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
  191. package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
  192. package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  193. package/node/internals/hooks/useValueWithTimezone.js +13 -1
  194. package/node/internals/index.js +7 -0
  195. package/node/internals/models/pickers.js +5 -0
  196. package/node/locales/nlNL.js +7 -7
  197. package/node/validation/useValidation.js +1 -1
  198. package/node/validation/validateDate.js +8 -0
  199. package/node/validation/validateDateTime.js +8 -0
  200. package/node/validation/validateTime.js +8 -0
  201. package/package.json +4 -4
  202. package/themeAugmentation/overrides.d.ts +1 -1
  203. package/themeAugmentation/props.d.ts +3 -2
  204. package/validation/useValidation.d.ts +7 -6
  205. package/validation/useValidation.js +1 -1
  206. package/validation/validateDate.d.ts +12 -3
  207. package/validation/validateDate.js +8 -0
  208. package/validation/validateDateTime.d.ts +12 -4
  209. package/validation/validateDateTime.js +8 -0
  210. package/validation/validateTime.d.ts +12 -3
  211. package/validation/validateTime.js +8 -0
  212. package/internals/hooks/useIsLandscape.d.ts +0 -4
  213. package/internals/hooks/useIsLandscape.js +0 -35
  214. package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -33
  215. package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
  216. package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
  217. package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
  218. package/modern/internals/hooks/useIsLandscape.js +0 -35
  219. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
  220. package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
  221. package/node/internals/hooks/useIsLandscape.js +0 -43
  222. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -41
  223. package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
@@ -11,6 +11,7 @@ export const useValueWithTimezone = ({
11
11
  timezone: timezoneProp,
12
12
  value: valueProp,
13
13
  defaultValue,
14
+ referenceDate,
14
15
  onChange,
15
16
  valueManager
16
17
  }) => {
@@ -24,7 +25,16 @@ export const useValueWithTimezone = ({
24
25
  }
25
26
  return valueManager.setTimezone(utils, inputTimezone, newValue);
26
27
  });
27
- const timezoneToRender = timezoneProp ?? inputTimezone ?? 'default';
28
+ let timezoneToRender;
29
+ if (timezoneProp) {
30
+ timezoneToRender = timezoneProp;
31
+ } else if (inputTimezone) {
32
+ timezoneToRender = inputTimezone;
33
+ } else if (referenceDate) {
34
+ timezoneToRender = utils.getTimezone(referenceDate);
35
+ } else {
36
+ timezoneToRender = 'default';
37
+ }
28
38
  const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
29
39
  const handleValueChange = useEventCallback((newValue, ...otherParams) => {
30
40
  const newValueWithInputTimezone = setInputTimezone(newValue);
@@ -45,6 +55,7 @@ export const useControlledValueWithTimezone = ({
45
55
  timezone: timezoneProp,
46
56
  value: valueProp,
47
57
  defaultValue,
58
+ referenceDate,
48
59
  onChange: onChangeProp,
49
60
  valueManager
50
61
  }) => {
@@ -62,6 +73,7 @@ export const useControlledValueWithTimezone = ({
62
73
  timezone: timezoneProp,
63
74
  value: valueWithInputTimezone,
64
75
  defaultValue: undefined,
76
+ referenceDate,
65
77
  onChange,
66
78
  valueManager
67
79
  });
@@ -1,9 +1,9 @@
1
1
  import { MakeOptional } from '@mui/x-internals/types';
2
2
  import type { PickerSelectionState } from './usePicker';
3
- import { DateOrTimeViewWithMeridiem } from '../models';
3
+ import { DateOrTimeViewWithMeridiem, PickerValidValue } from '../models';
4
4
  import { PickerValidDate } from '../../models';
5
5
  export type PickerOnChangeFn = (date: PickerValidDate | null, selectionState?: PickerSelectionState) => void;
6
- export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridiem> {
6
+ export interface UseViewsOptions<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem> {
7
7
  /**
8
8
  * Callback fired when the value changes.
9
9
  * @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.
@@ -54,9 +54,9 @@ export interface UseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridie
54
54
  */
55
55
  onFocusedViewChange?: (view: TView, hasFocus: boolean) => void;
56
56
  }
57
- export interface ExportedUseViewsOptions<TValue, TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<UseViewsOptions<TValue, TView>, 'onChange' | 'openTo' | 'views'> {
57
+ export interface ExportedUseViewsOptions<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem> extends MakeOptional<UseViewsOptions<TValue, TView>, 'onChange' | 'openTo' | 'views'> {
58
58
  }
59
- interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
59
+ interface UseViewsResponse<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem> {
60
60
  view: TView;
61
61
  setView: (view: TView) => void;
62
62
  focusedView: TView | null;
@@ -67,5 +67,5 @@ interface UseViewsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
67
67
  goToNextView: () => void;
68
68
  setValueAndGoToNextView: (value: TValue, currentViewSelectionState?: PickerSelectionState, selectedView?: TView) => void;
69
69
  }
70
- export declare function useViews<TValue, TView extends DateOrTimeViewWithMeridiem>({ onChange, onViewChange, openTo, view: inView, views, autoFocus, focusedView: inFocusedView, onFocusedViewChange, }: UseViewsOptions<TValue, TView>): UseViewsResponse<TValue, TView>;
70
+ export declare function useViews<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem>({ onChange, onViewChange, openTo, view: inView, views, autoFocus, focusedView: inFocusedView, onFocusedViewChange, }: UseViewsOptions<TValue, TView>): UseViewsResponse<TValue, TView>;
71
71
  export {};
@@ -26,6 +26,7 @@ export { useControlledValueWithTimezone } from './hooks/useValueWithTimezone';
26
26
  export type { DesktopOnlyPickerProps } from './hooks/useDesktopPicker';
27
27
  export { useField, createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections, } from './hooks/useField';
28
28
  export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
29
+ export { useFieldOwnerState } from './hooks/useFieldOwnerState';
29
30
  export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
30
31
  export { usePicker } from './hooks/usePicker';
31
32
  export type { UsePickerResponse, UsePickerParams, UsePickerProps, UsePickerValueFieldResponse, PickerViewsRendererProps, } from './hooks/usePicker';
@@ -38,15 +39,16 @@ export { useLocalizationContext, useDefaultDates, useUtils, useNow } from './hoo
38
39
  export type { ExportedUseViewsOptions, UseViewsOptions } from './hooks/useViews';
39
40
  export { useViews } from './hooks/useViews';
40
41
  export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
41
- export type { BaseSingleInputFieldProps } from './models/fields';
42
+ export type { RangePosition } from './models/pickers';
43
+ export type { BaseSingleInputFieldProps, FieldRangeSection } from './models/fields';
42
44
  export type { BasePickerProps, BasePickerInputProps, BaseNonStaticPickerProps, } from './models/props/basePickerProps';
43
45
  export type { BaseClockProps, DesktopOnlyTimePickerProps, AmPmProps } from './models/props/time';
44
46
  export type { BaseTabsProps, ExportedBaseTabsProps } from './models/props/tabs';
45
47
  export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/toolbar';
46
48
  export type { FormProps } from './models/formProps';
47
- export type { WrapperVariant, TimeViewWithMeridiem, DateOrTimeViewWithMeridiem, } from './models/common';
49
+ export type { PickerVariant, TimeViewWithMeridiem, DateOrTimeViewWithMeridiem, } from './models/common';
48
50
  export type { BaseDateValidationProps, BaseTimeValidationProps, TimeValidationProps, MonthValidationProps, YearValidationProps, DayValidationProps, DateTimeValidationProps, } from './models/validation';
49
- export type { PickerRangeValue } from './models/value';
51
+ export type { PickerValue, PickerRangeValue, PickerNonNullableRangeValue, InferNonNullablePickerValue, PickerValidValue, } from './models/value';
50
52
  export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
51
53
  export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem, } from './utils/date-utils';
52
54
  export { resolveTimeViewsResponse, resolveDateTimeFormat } from './utils/date-time-utils';
@@ -12,6 +12,7 @@ export { PickersToolbarButton } from "./components/PickersToolbarButton.js";
12
12
  export { DAY_MARGIN, DIALOG_WIDTH, VIEW_HEIGHT } from "./constants/dimensions.js";
13
13
  export { useControlledValueWithTimezone } from "./hooks/useValueWithTimezone.js";
14
14
  export { useField, createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./hooks/useField/index.js";
15
+ export { useFieldOwnerState } from "./hooks/useFieldOwnerState.js";
15
16
  export { usePicker } from "./hooks/usePicker/index.js";
16
17
  export { usePickerPrivateContext } from "./hooks/usePickerPrivateContext.js";
17
18
  export { useStaticPicker } from "./hooks/useStaticPicker/index.js";
@@ -1,4 +1,5 @@
1
1
  import { DateView, TimeView } from '../../models/views';
2
- export type WrapperVariant = 'mobile' | 'desktop' | null;
2
+ export type PickerOrientation = 'portrait' | 'landscape';
3
+ export type PickerVariant = 'mobile' | 'desktop' | null;
3
4
  export type TimeViewWithMeridiem = TimeView | 'meridiem';
4
5
  export type DateOrTimeViewWithMeridiem = DateView | TimeViewWithMeridiem;
@@ -3,6 +3,11 @@ import { MakeRequired } from '@mui/x-internals/types';
3
3
  import type { ExportedUseClearableFieldProps, UseClearableFieldSlotProps, UseClearableFieldSlots } from '../../hooks/useClearableField';
4
4
  import type { FieldSection, PickerOwnerState } from '../../models';
5
5
  import type { UseFieldInternalProps } from '../hooks/useField';
6
+ import { RangePosition } from './pickers';
7
+ import { PickerValidValue } from './value';
8
+ export interface FieldRangeSection extends FieldSection {
9
+ dateName: RangePosition;
10
+ }
6
11
  export interface BaseForwardedSingleInputFieldProps extends ExportedUseClearableFieldProps {
7
12
  className: string | undefined;
8
13
  sx: SxProps<any> | undefined;
@@ -32,4 +37,4 @@ export interface BaseForwardedSingleInputFieldProps extends ExportedUseClearable
32
37
  * Props the single input field can receive when used inside a picker.
33
38
  * Only contains what the MUI components are passing to the field, not what users can pass using the `props.slotProps.field`.
34
39
  */
35
- export type BaseSingleInputFieldProps<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> = MakeRequired<Pick<UseFieldInternalProps<TValue, TSection, TEnableAccessibleFieldDOMStructure, TError>, 'readOnly' | 'disabled' | 'format' | 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange' | 'timezone' | 'value' | 'onChange' | 'unstableFieldRef' | 'autoFocus'>, 'format' | 'value' | 'onChange' | 'timezone'> & BaseForwardedSingleInputFieldProps;
40
+ export type BaseSingleInputFieldProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> = MakeRequired<Pick<UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, TError>, 'readOnly' | 'disabled' | 'format' | 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange' | 'timezone' | 'value' | 'onChange' | 'unstableFieldRef' | 'autoFocus'>, 'format' | 'value' | 'onChange' | 'timezone'> & BaseForwardedSingleInputFieldProps;
@@ -0,0 +1 @@
1
+ export type RangePosition = 'start' | 'end';
@@ -0,0 +1 @@
1
+ export {};
@@ -7,10 +7,11 @@ import { PickersInputComponentLocaleText } from '../../../locales/utils/pickersL
7
7
  import type { UsePickerViewsProps } from '../../hooks/usePicker/usePickerViews';
8
8
  import { DateOrTimeViewWithMeridiem } from '../common';
9
9
  import { UseFieldInternalProps } from '../../hooks/useField';
10
+ import { PickerValidValue } from '../value';
10
11
  /**
11
12
  * Props common to all pickers after applying the default props on each picker.
12
13
  */
13
- export interface BasePickerProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerBaseProps<TValue, TView, TError, TExternalProps, TAdditionalProps> {
14
+ export interface BasePickerProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerBaseProps<TValue, TView, TError, TExternalProps, TAdditionalProps> {
14
15
  className?: string;
15
16
  /**
16
17
  * The system prop that allows defining system overrides as well as additional CSS styles.
@@ -25,13 +26,13 @@ export interface BasePickerProps<TValue, TView extends DateOrTimeViewWithMeridie
25
26
  /**
26
27
  * Props common to all pickers before applying the default props on each picker.
27
28
  */
28
- export interface BasePickerInputProps<TValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Omit<MakeOptional<BasePickerProps<TValue, TView, TError, any, any>, 'openTo' | 'views'>, 'viewRenderers'> {
29
+ export interface BasePickerInputProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Omit<MakeOptional<BasePickerProps<TValue, TView, TError, any, any>, 'openTo' | 'views'>, 'viewRenderers'> {
29
30
  }
30
31
  /**
31
32
  * Props common to all non-static pickers.
32
33
  * These props are handled by the headless wrappers.
33
34
  */
34
- export interface BaseNonStaticPickerProps extends Pick<UseFieldInternalProps<any, any, any, any>, 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange'> {
35
+ export interface BaseNonStaticPickerProps extends Pick<UseFieldInternalProps<any, any, any>, 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange'> {
35
36
  /**
36
37
  * Format of the date when rendered in the input(s).
37
38
  * Defaults to localized format based on the used `views`.
@@ -6,6 +6,7 @@ import type { ExportedUseViewsOptions } from '../../hooks/useViews';
6
6
  import { TimeViewWithMeridiem } from '../common';
7
7
  import { ExportedValidateTimeProps } from '../../../validation/validateTime';
8
8
  import { FormProps } from '../formProps';
9
+ import { PickerValue } from '../value';
9
10
  export interface AmPmProps {
10
11
  /**
11
12
  * 12h/24h view for hour selection clock.
@@ -15,7 +16,7 @@ export interface AmPmProps {
15
16
  }
16
17
  export interface ExportedBaseClockProps extends ExportedValidateTimeProps, TimezoneProps, AmPmProps {
17
18
  }
18
- export interface BaseClockProps<TView extends TimeViewWithMeridiem> extends ExportedUseViewsOptions<PickerValidDate | null, TView>, ExportedBaseClockProps, FormProps {
19
+ export interface BaseClockProps<TView extends TimeViewWithMeridiem> extends ExportedUseViewsOptions<PickerValue, TView>, ExportedBaseClockProps, FormProps {
19
20
  className?: string;
20
21
  /**
21
22
  * The system prop that allows defining system overrides as well as additional CSS styles.
@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
3
  import { Theme } from '@mui/material/styles';
4
4
  import { DateOrTimeViewWithMeridiem } from '../common';
5
- import { FormProps } from '../formProps';
6
- export interface BaseToolbarProps<TValue, TView extends DateOrTimeViewWithMeridiem> extends ExportedBaseToolbarProps, FormProps {
5
+ import { PickerValidValue } from '../value';
6
+ export interface BaseToolbarProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem> extends ExportedBaseToolbarProps {
7
7
  isLandscape: boolean;
8
8
  onChange: (newValue: TValue) => void;
9
9
  value: TValue;
@@ -1,3 +1,12 @@
1
1
  import { PickerValidDate } from '../../models/pickers';
2
+ /**
3
+ * The type that the `value` and `defaultValue` props can receive on non-range components (date, time and date-time).
4
+ */
2
5
  export type PickerValue = PickerValidDate | null;
6
+ /**
7
+ * The type that the `value` and `defaultValue` props can receive on range components (date-range, time-range and date-time-range).
8
+ */
3
9
  export type PickerRangeValue = [PickerValidDate | null, PickerValidDate | null];
10
+ export type PickerNonNullableRangeValue = [PickerValidDate, PickerValidDate];
11
+ export type PickerValidValue = PickerValue | PickerRangeValue;
12
+ export type InferNonNullablePickerValue<TValue extends PickerValidValue> = TValue extends PickerRangeValue ? TValue extends PickerValue ? PickerValidDate | PickerNonNullableRangeValue : PickerNonNullableRangeValue : PickerValidDate;
@@ -1,4 +1,4 @@
1
- import { DateView, FieldValueType, MuiPickersAdapter, PickersTimezone, PickerValidDate } from '../../models';
1
+ import { DateView, MuiPickersAdapter, PickersTimezone, PickerValidDate, PickerValueType } from '../../models';
2
2
  import { DateOrTimeViewWithMeridiem } from '../models';
3
3
  export declare const mergeDateAndTime: (utils: MuiPickersAdapter, dateParam: PickerValidDate, timeParam: PickerValidDate) => PickerValidDate;
4
4
  interface FindClosestDateParams {
@@ -14,9 +14,9 @@ interface FindClosestDateParams {
14
14
  export declare const findClosestEnabledDate: ({ date, disableFuture, disablePast, maxDate, minDate, isDateDisabled, utils, timezone, }: FindClosestDateParams) => PickerValidDate | null;
15
15
  export declare const replaceInvalidDateByNull: (utils: MuiPickersAdapter, value: PickerValidDate | null) => PickerValidDate | null;
16
16
  export declare const applyDefaultDate: (utils: MuiPickersAdapter, value: PickerValidDate | null | undefined, defaultValue: PickerValidDate) => PickerValidDate;
17
- export declare const areDatesEqual: (utils: MuiPickersAdapter, a: PickerValidDate, b: PickerValidDate) => boolean;
17
+ export declare const areDatesEqual: (utils: MuiPickersAdapter, a: PickerValidDate | null, b: PickerValidDate | null) => boolean;
18
18
  export declare const getMonthsInYear: (utils: MuiPickersAdapter, year: PickerValidDate) => PickerValidDate[];
19
- export declare const getTodayDate: (utils: MuiPickersAdapter, timezone: PickersTimezone, valueType?: FieldValueType) => PickerValidDate;
19
+ export declare const getTodayDate: (utils: MuiPickersAdapter, timezone: PickersTimezone, valueType?: PickerValueType) => PickerValidDate;
20
20
  export declare const formatMeridiem: (utils: MuiPickersAdapter, meridiem: "am" | "pm") => string;
21
21
  export declare const isDatePickerView: (view: DateOrTimeViewWithMeridiem) => view is DateView;
22
22
  export declare const resolveDateFormat: (utils: MuiPickersAdapter, { format, views }: {
@@ -1,6 +1,7 @@
1
1
  import type { PickerValueManager } from '../hooks/usePicker';
2
- import { DateValidationError, TimeValidationError, DateTimeValidationError, FieldSection } from '../../models';
2
+ import { DateValidationError, TimeValidationError, DateTimeValidationError } from '../../models';
3
3
  import type { FieldValueManager } from '../hooks/useField';
4
- export type SingleItemPickerValueManager<TValue = any, TError extends DateValidationError | TimeValidationError | DateTimeValidationError = any> = PickerValueManager<TValue, TError>;
4
+ import { PickerValue } from '../models';
5
+ export type SingleItemPickerValueManager<TError extends DateValidationError | TimeValidationError | DateTimeValidationError = any> = PickerValueManager<PickerValue, TError>;
5
6
  export declare const singleItemValueManager: SingleItemPickerValueManager;
6
- export declare const singleItemFieldValueManager: FieldValueManager<any, FieldSection>;
7
+ export declare const singleItemFieldValueManager: FieldValueManager<PickerValue>;
package/locales/nlNL.js CHANGED
@@ -16,10 +16,10 @@ const nlNLPickers = {
16
16
  // DateRange labels
17
17
  start: 'Start',
18
18
  end: 'Einde',
19
- startDate: 'Start datum',
20
- startTime: 'Start tijd',
21
- endDate: 'Eind datum',
22
- endTime: 'Eind tijd',
19
+ startDate: 'Startdatum',
20
+ startTime: 'Starttijd',
21
+ endDate: 'Einddatum',
22
+ endTime: 'Eindtijd',
23
23
  // Action bar
24
24
  cancelButtonLabel: 'Annuleren',
25
25
  clearButtonLabel: 'Resetten',
@@ -50,11 +50,11 @@ const nlNLPickers = {
50
50
  timeTableLabel: 'kies tijd',
51
51
  dateTableLabel: 'kies datum',
52
52
  // Field section placeholders
53
- fieldYearPlaceholder: params => 'Y'.repeat(params.digitAmount),
53
+ fieldYearPlaceholder: params => 'J'.repeat(params.digitAmount),
54
54
  fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
55
55
  fieldDayPlaceholder: () => 'DD',
56
56
  fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
57
- fieldHoursPlaceholder: () => 'hh',
57
+ fieldHoursPlaceholder: () => 'uu',
58
58
  fieldMinutesPlaceholder: () => 'mm',
59
59
  fieldSecondsPlaceholder: () => 'ss',
60
60
  fieldMeridiemPlaceholder: () => 'aa',
@@ -68,6 +68,6 @@ const nlNLPickers = {
68
68
  seconds: 'Seconden',
69
69
  meridiem: 'Middag',
70
70
  // Common
71
- empty: 'Legen'
71
+ empty: 'Leeg'
72
72
  };
73
73
  export const nlNL = getPickersLocalization(nlNLPickers);
@@ -215,7 +215,7 @@ export interface MuiPickersAdapter<TLocale = any> {
215
215
  */
216
216
  is12HourCycleInCurrentLocale(): boolean;
217
217
  /**
218
- * Create a format with no meta-token (e.g: `LLL` or `PP`).
218
+ * Create a format with no meta-token (for example: `LLL` or `PP`).
219
219
  * @param {string} format The format to expand.
220
220
  * @returns {string} The expanded format.
221
221
  */
@@ -248,7 +248,7 @@ export interface MuiPickersAdapter<TLocale = any> {
248
248
  */
249
249
  formatNumber(numberToFormat: string): string;
250
250
  /**
251
- * Check if the two dates are equal (e.g: they represent the same timestamp).
251
+ * Check if the two dates are equal (which means they represent the same timestamp).
252
252
  * @param {PickerValidDate | null} value The reference date.
253
253
  * @param {PickerValidDate | null} comparing The date to compare with the reference date.
254
254
  * @returns {boolean} `true` if the two dates are equal.
@@ -442,7 +442,7 @@ export interface MuiPickersAdapter<TLocale = any> {
442
442
  */
443
443
  getMonth(value: PickerValidDate): number;
444
444
  /**
445
- * Get the date (e.g: the day in the month) of the given date.
445
+ * Get the date (day in the month) of the given date.
446
446
  * @param {PickerValidDate} value The given date.
447
447
  * @returns {number} The date of the given date.
448
448
  */
@@ -486,7 +486,7 @@ export interface MuiPickersAdapter<TLocale = any> {
486
486
  */
487
487
  setMonth(value: PickerValidDate, month: number): PickerValidDate;
488
488
  /**
489
- * Set the date (e.g: the day in the month) to the given date.
489
+ * Set the date (day in the month) to the given date.
490
490
  * @param {PickerValidDate} value The date to be changed.
491
491
  * @param {number} date The date of the new date.
492
492
  * @returns {PickerValidDate} The new date with the date set.
@@ -3,3 +3,4 @@ export interface TimeStepOptions {
3
3
  minutes?: number;
4
4
  seconds?: number;
5
5
  }
6
+ export type PickerValueType = 'date' | 'time' | 'date-time';
@@ -4,10 +4,10 @@ import type { ExportedUseClearableFieldProps, UseClearableFieldResponse } from '
4
4
  import { ExportedPickersSectionListProps } from '../PickersSectionList';
5
5
  import type { UseFieldInternalProps, UseFieldResponse } from '../internals/hooks/useField';
6
6
  import type { PickersTextFieldProps } from '../PickersTextField';
7
- import { BaseForwardedSingleInputFieldProps } from '../internals/models';
7
+ import { BaseForwardedSingleInputFieldProps, FieldRangeSection, PickerRangeValue, PickerValidValue } from '../internals/models';
8
+ import { PickerOwnerState } from './pickers';
8
9
  export type FieldSectionType = 'year' | 'month' | 'day' | 'weekDay' | 'hours' | 'minutes' | 'seconds' | 'meridiem' | 'empty';
9
10
  export type FieldSectionContentType = 'digit' | 'digit-with-letter' | 'letter';
10
- export type FieldValueType = 'date' | 'time' | 'date-time';
11
11
  export interface FieldSection {
12
12
  /**
13
13
  * Value of the section, as rendered inside the input.
@@ -70,12 +70,14 @@ export interface FieldSection {
70
70
  */
71
71
  endSeparator: string;
72
72
  }
73
- export interface FieldRef<TSection extends FieldSection> {
73
+ type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
74
+ export type InferFieldSection<TValue extends PickerValidValue> = IsAny<TValue> extends true ? FieldSection : TValue extends PickerRangeValue ? FieldRangeSection : FieldSection;
75
+ export interface FieldRef<TValue extends PickerValidValue> {
74
76
  /**
75
77
  * Returns the sections of the current value.
76
- * @returns {TSection[]} The sections of the current value.
78
+ * @returns {InferFieldSection<TValue>[]} The sections of the current value.
77
79
  */
78
- getSections: () => TSection[];
80
+ getSections: () => InferFieldSection<TValue>[];
79
81
  /**
80
82
  * Returns the index of the active section (the first focused section).
81
83
  * If no section is active, returns `null`.
@@ -99,10 +101,20 @@ export interface FieldRef<TSection extends FieldSection> {
99
101
  isFieldFocused: () => boolean;
100
102
  }
101
103
  export type FieldSelectedSections = number | FieldSectionType | null | 'all';
104
+ export interface FieldOwnerState extends PickerOwnerState {
105
+ /**
106
+ * `true` if the field is disabled, `false` otherwise.
107
+ */
108
+ isFieldDisabled: boolean;
109
+ /**
110
+ * `true` if the field is read-only, `false` otherwise.
111
+ */
112
+ isFieldReadOnly: boolean;
113
+ }
102
114
  /**
103
115
  * Props the prop `slotProps.field` of a picker can receive.
104
116
  */
105
- export type PickerFieldSlotProps<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean> = ExportedUseClearableFieldProps & Pick<UseFieldInternalProps<TValue, TSection, TEnableAccessibleFieldDOMStructure, unknown>, 'shouldRespectLeadingZeros' | 'readOnly'> & React.HTMLAttributes<HTMLDivElement> & {
117
+ export type PickerFieldSlotProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean> = ExportedUseClearableFieldProps & Pick<UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, unknown>, 'shouldRespectLeadingZeros' | 'readOnly'> & React.HTMLAttributes<HTMLDivElement> & {
106
118
  ref?: React.Ref<HTMLDivElement>;
107
119
  };
108
120
  /**
@@ -114,3 +126,4 @@ export type BaseSingleInputPickersTextFieldProps<TEnableAccessibleFieldDOMStruct
114
126
  * Props the built-in text field component can receive.
115
127
  */
116
128
  export type BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? Omit<TextFieldProps, 'autoComplete' | 'error' | 'maxRows' | 'minRows' | 'multiline' | 'placeholder' | 'rows' | 'select' | 'SelectProps' | 'type'> : Partial<Omit<PickersTextFieldProps, keyof ExportedPickersSectionListProps>>;
129
+ export {};
@@ -1,3 +1,4 @@
1
+ import { PickerOrientation, PickerVariant } from '../internals/models/common';
1
2
  import type { PickersShortcutsItemContext } from '../PickersShortcuts';
2
3
  export interface PickerChangeHandlerContext<TError> {
3
4
  validationError: TError;
@@ -31,4 +32,21 @@ export interface PickerOwnerState {
31
32
  * Is always `false` if the component you are accessing the ownerState from is not wrapped by a picker.
32
33
  */
33
34
  isPickerReadOnly: boolean;
35
+ /**
36
+ * The responsive variant of the picker.
37
+ * Is equal to "desktop" when using a desktop picker (like <DesktopDatePicker />).
38
+ * Is equal to "mobile" when using a mobile picker (like <MobileDatePicker />).
39
+ * Is equal to "mobile" or "desktop" when using a responsive picker (like <DatePicker />) depending on the `desktopModeMediaQuery` prop.
40
+ * Is equal to "mobile" or "desktop" when using a static picker (like <StaticDatePicker />) depending on the `displayStaticWrapperAs` prop.
41
+ * Is always equal to "desktop" if the component you are accessing the ownerState from is not wrapped by a picker.
42
+ */
43
+ pickerVariant: PickerVariant;
44
+ /**
45
+ * The orientation of the picker.
46
+ * Is equal to "landscape" when the picker is in landscape orientation.
47
+ * Is equal to "portrait" when the picker is in portrait orientation.
48
+ * You can use the "orientation" on any picker component to force the orientation.
49
+ * Is always equal to "portrait" if the component you are accessing the ownerState from is not wrapped by a picker.
50
+ */
51
+ pickerOrientation: PickerOrientation;
34
52
  }
@@ -1,3 +1,4 @@
1
+ import type { PickerValidValue } from '../internals/models';
1
2
  /**
2
3
  * Validation error types applicable to both date and time validation
3
4
  */
@@ -5,7 +6,7 @@ type CommonDateTimeValidationError = 'invalidDate' | 'disableFuture' | 'disableP
5
6
  export type DateValidationError = CommonDateTimeValidationError | 'shouldDisableDate' | 'shouldDisableMonth' | 'shouldDisableYear' | 'minDate' | 'maxDate';
6
7
  export type TimeValidationError = CommonDateTimeValidationError | 'minutesStep' | 'minTime' | 'maxTime' | 'shouldDisableTime-hours' | 'shouldDisableTime-minutes' | 'shouldDisableTime-seconds';
7
8
  export type DateTimeValidationError = DateValidationError | TimeValidationError;
8
- export interface OnErrorProps<TValue, TError> {
9
+ export interface OnErrorProps<TValue extends PickerValidValue, TError> {
9
10
  /**
10
11
  * Callback fired when the error associated with the current value changes.
11
12
  * When a validation error is detected, the `error` parameter contains a non-null value.
@@ -430,12 +430,22 @@ export class AdapterMoment {
430
430
  const end = this.endOfWeek(this.endOfMonth(value));
431
431
  let count = 0;
432
432
  let current = start;
433
+ let currentDayOfYear = current.get('dayOfYear');
433
434
  const nestedWeeks = [];
434
435
  while (current.isBefore(end)) {
435
436
  const weekNumber = Math.floor(count / 7);
436
437
  nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
437
438
  nestedWeeks[weekNumber].push(current);
439
+ const prevDayOfYear = currentDayOfYear;
438
440
  current = this.addDays(current, 1);
441
+ currentDayOfYear = current.get('dayOfYear');
442
+
443
+ // If there is a TZ change at midnight, adding 1 day may only increase the date by 23 hours to 11pm
444
+ // To fix, bump the date into the next day (add 12 hours) and then revert to the start of the day
445
+ // See https://github.com/moment/moment/issues/4743#issuecomment-811306874 for context.
446
+ if (prevDayOfYear === currentDayOfYear) {
447
+ current = current.add(12, 'h').startOf('day');
448
+ }
439
449
  count += 1;
440
450
  }
441
451
  return nestedWeeks;
@@ -137,6 +137,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
137
137
  timezone: timezoneProp,
138
138
  value: valueProp,
139
139
  defaultValue,
140
+ referenceDate: referenceDateProp,
140
141
  onChange,
141
142
  valueManager: singleItemValueManager
142
143
  });
@@ -6,10 +6,7 @@ import { styled, useTheme, useThemeProps } from '@mui/material/styles';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
7
  import { getPickersFadeTransitionGroupUtilityClass } from "./pickersFadeTransitionGroupClasses.js";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
- const useUtilityClasses = ownerState => {
10
- const {
11
- classes
12
- } = ownerState;
9
+ const useUtilityClasses = classes => {
13
10
  const slots = {
14
11
  root: ['root']
15
12
  };
@@ -36,9 +33,10 @@ export function PickersFadeTransitionGroup(inProps) {
36
33
  children,
37
34
  className,
38
35
  reduceAnimations,
39
- transKey
36
+ transKey,
37
+ classes: classesProp
40
38
  } = props;
41
- const classes = useUtilityClasses(props);
39
+ const classes = useUtilityClasses(classesProp);
42
40
  const theme = useTheme();
43
41
  if (reduceAnimations) {
44
42
  return children;
@@ -7,10 +7,10 @@ import { styled, useTheme, useThemeProps } from '@mui/material/styles';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
8
  import { CSSTransition, TransitionGroup } from 'react-transition-group';
9
9
  import { getPickersSlideTransitionUtilityClass, pickersSlideTransitionClasses } from "./pickersSlideTransitionClasses.js";
10
+ import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
- const useUtilityClasses = ownerState => {
12
+ const useUtilityClasses = (classes, ownerState) => {
12
13
  const {
13
- classes,
14
14
  slideDirection
15
15
  } = ownerState;
16
16
  const slots = {
@@ -99,11 +99,18 @@ export function PickersSlideTransition(inProps) {
99
99
  children,
100
100
  className,
101
101
  reduceAnimations,
102
- transKey
103
- // extracting `classes` from `other`
102
+ slideDirection,
103
+ transKey,
104
+ classes: classesProp
104
105
  } = props,
105
106
  other = _objectWithoutPropertiesLoose(props, _excluded);
106
- const classes = useUtilityClasses(props);
107
+ const {
108
+ ownerState: pickerOwnerState
109
+ } = usePickerPrivateContext();
110
+ const ownerState = _extends({}, pickerOwnerState, {
111
+ slideDirection
112
+ });
113
+ const classes = useUtilityClasses(classesProp, ownerState);
107
114
  const theme = useTheme();
108
115
  if (reduceAnimations) {
109
116
  return /*#__PURE__*/_jsx("div", {
@@ -13,6 +13,7 @@ import { useDateField } from "./useDateField.js";
13
13
  import { useClearableField } from "../hooks/index.js";
14
14
  import { PickersTextField } from "../PickersTextField/index.js";
15
15
  import { convertFieldResponseIntoMuiTextFieldProps } from "../internals/utils/convertFieldResponseIntoMuiTextFieldProps.js";
16
+ import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  /**
18
19
  * Demos:
@@ -36,7 +37,7 @@ const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, inRe
36
37
  inputProps
37
38
  } = themeProps,
38
39
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
40
+ const ownerState = useFieldOwnerState(themeProps);
40
41
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
42
  const textFieldProps = useSlotProps({
42
43
  elementType: TextField,
@@ -267,10 +268,10 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
267
268
  */
268
269
  shouldDisableYear: PropTypes.func,
269
270
  /**
270
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
271
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
271
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
272
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
272
273
  *
273
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
274
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
274
275
  *
275
276
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
276
277
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -107,12 +107,6 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
107
107
  */
108
108
  classes: PropTypes.object,
109
109
  className: PropTypes.string,
110
- /**
111
- * If `true`, the component is disabled.
112
- * When disabled, the value cannot be changed and no interaction is possible.
113
- * @default false
114
- */
115
- disabled: PropTypes.bool,
116
110
  /**
117
111
  * If `true`, show the toolbar even in desktop mode.
118
112
  * @default `true` for Desktop, `false` for Mobile.
@@ -126,12 +120,6 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
126
120
  * @param {TView} view The view to open
127
121
  */
128
122
  onViewChange: PropTypes.func.isRequired,
129
- /**
130
- * If `true`, the component is read-only.
131
- * When read-only, the value cannot be changed but the user can interact with the interface.
132
- * @default false
133
- */
134
- readOnly: PropTypes.bool,
135
123
  /**
136
124
  * The system prop that allows defining system overrides as well as additional CSS styles.
137
125
  */
@@ -13,6 +13,7 @@ import { useDateTimeField } from "./useDateTimeField.js";
13
13
  import { useClearableField } from "../hooks/index.js";
14
14
  import { PickersTextField } from "../PickersTextField/index.js";
15
15
  import { convertFieldResponseIntoMuiTextFieldProps } from "../internals/utils/convertFieldResponseIntoMuiTextFieldProps.js";
16
+ import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  /**
18
19
  * Demos:
@@ -36,7 +37,7 @@ const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inPro
36
37
  inputProps
37
38
  } = themeProps,
38
39
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
40
+ const ownerState = useFieldOwnerState(themeProps);
40
41
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
42
  const textFieldProps = useSlotProps({
42
43
  elementType: TextField,
@@ -307,10 +308,10 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
307
308
  */
308
309
  shouldDisableYear: PropTypes.func,
309
310
  /**
310
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
311
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
311
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
312
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
312
313
  *
313
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
314
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
314
315
  *
315
316
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
316
317
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.