@mui/x-date-pickers-pro 8.0.0-alpha.5 → 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 (148) hide show
  1. package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.d.ts +1 -1
  2. package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
  3. package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
  4. package/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.d.ts +1 -1
  5. package/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
  6. package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
  7. package/CHANGELOG.md +206 -1
  8. package/DateRangeCalendar/DateRangeCalendar.js +9 -7
  9. package/DateRangePicker/DateRangePicker.js +1 -1
  10. package/DateRangePicker/DateRangePicker.types.d.ts +5 -0
  11. package/DateRangePicker/DateRangePickerToolbar.d.ts +2 -3
  12. package/DateRangePicker/DateRangePickerToolbar.js +25 -31
  13. package/DateRangePicker/shared.d.ts +1 -1
  14. package/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
  15. package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +4 -5
  16. package/DateTimeRangePicker/DateTimeRangePickerTabs.js +25 -24
  17. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +8 -10
  18. package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +7 -5
  19. package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -4
  20. package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +66 -69
  21. package/DateTimeRangePicker/shared.d.ts +2 -2
  22. package/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
  23. package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +7 -2
  24. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
  25. package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +2 -3
  26. package/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
  27. package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +2 -2
  28. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
  29. package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +2 -3
  30. package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
  31. package/SingleInputDateRangeField/useSingleInputDateRangeField.js +13 -14
  32. package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
  33. package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +13 -14
  34. package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
  35. package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +13 -14
  36. package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +2 -2
  37. package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -2
  38. package/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
  39. package/hooks/index.d.ts +1 -0
  40. package/hooks/index.js +1 -0
  41. package/hooks/package.json +6 -0
  42. package/hooks/usePickerRangePositionContext.d.ts +7 -0
  43. package/hooks/usePickerRangePositionContext.js +15 -0
  44. package/index.d.ts +2 -0
  45. package/index.js +4 -2
  46. package/internals/hooks/models/useRangePicker.d.ts +4 -4
  47. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +35 -53
  48. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +7 -9
  49. package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +6 -6
  50. package/internals/hooks/useEnrichedRangePickerFieldProps.js +11 -8
  51. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +24 -40
  52. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +7 -9
  53. package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +10 -12
  54. package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -1
  55. package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +11 -6
  56. package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +2 -2
  57. package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +12 -7
  58. package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +2 -2
  59. package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +13 -8
  60. package/internals/hooks/useNullablePickerRangePositionContext.d.ts +5 -0
  61. package/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
  62. package/internals/hooks/useRangePosition.d.ts +1 -1
  63. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
  64. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +6 -6
  65. package/internals/utils/date-range-manager.js +2 -1
  66. package/internals/utils/releaseInfo.js +1 -1
  67. package/internals/utils/valueManagers.js +7 -7
  68. package/managers/index.d.ts +6 -0
  69. package/managers/index.js +3 -0
  70. package/managers/package.json +6 -0
  71. package/managers/useDateRangeManager.d.ts +15 -0
  72. package/managers/useDateRangeManager.js +31 -0
  73. package/managers/useDateTimeRangeManager.d.ts +15 -0
  74. package/managers/useDateTimeRangeManager.js +31 -0
  75. package/managers/useTimeRangeManager.d.ts +15 -0
  76. package/managers/useTimeRangeManager.js +29 -0
  77. package/models/range.d.ts +0 -1
  78. package/modern/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
  79. package/modern/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
  80. package/modern/DateRangeCalendar/DateRangeCalendar.js +9 -7
  81. package/modern/DateRangePicker/DateRangePicker.js +1 -1
  82. package/modern/DateRangePicker/DateRangePickerToolbar.js +25 -31
  83. package/modern/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
  84. package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +25 -24
  85. package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +7 -5
  86. package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +66 -69
  87. package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
  88. package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
  89. package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
  90. package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
  91. package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +13 -14
  92. package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +13 -14
  93. package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +13 -14
  94. package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
  95. package/modern/hooks/index.js +1 -0
  96. package/modern/hooks/usePickerRangePositionContext.js +15 -0
  97. package/modern/index.js +4 -2
  98. package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +35 -53
  99. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +11 -8
  100. package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +24 -40
  101. package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +11 -6
  102. package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +12 -7
  103. package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +13 -8
  104. package/modern/internals/hooks/useNullablePickerRangePositionContext.js +10 -0
  105. package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
  106. package/modern/internals/utils/date-range-manager.js +2 -1
  107. package/modern/internals/utils/releaseInfo.js +1 -1
  108. package/modern/internals/utils/valueManagers.js +7 -7
  109. package/modern/managers/index.js +3 -0
  110. package/modern/managers/useDateRangeManager.js +31 -0
  111. package/modern/managers/useDateTimeRangeManager.js +31 -0
  112. package/modern/managers/useTimeRangeManager.js +29 -0
  113. package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
  114. package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
  115. package/node/DateRangeCalendar/DateRangeCalendar.js +9 -7
  116. package/node/DateRangePicker/DateRangePicker.js +1 -1
  117. package/node/DateRangePicker/DateRangePickerToolbar.js +24 -30
  118. package/node/DateTimeRangePicker/DateTimeRangePicker.js +2 -2
  119. package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +24 -23
  120. package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +7 -5
  121. package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +65 -68
  122. package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +9 -3
  123. package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +17 -14
  124. package/node/MobileDateRangePicker/MobileDateRangePicker.js +2 -2
  125. package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -8
  126. package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +12 -14
  127. package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +12 -14
  128. package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +12 -14
  129. package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +0 -6
  130. package/node/hooks/index.js +12 -0
  131. package/node/hooks/usePickerRangePositionContext.js +22 -0
  132. package/node/index.js +23 -1
  133. package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +35 -53
  134. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +11 -8
  135. package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +24 -40
  136. package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +10 -5
  137. package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +11 -6
  138. package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +12 -7
  139. package/node/internals/hooks/useNullablePickerRangePositionContext.js +16 -0
  140. package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -24
  141. package/node/internals/utils/date-range-manager.js +2 -1
  142. package/node/internals/utils/releaseInfo.js +1 -1
  143. package/node/internals/utils/valueManagers.js +7 -7
  144. package/node/managers/index.js +26 -0
  145. package/node/managers/useDateRangeManager.js +38 -0
  146. package/node/managers/useDateTimeRangeManager.js +38 -0
  147. package/node/managers/useTimeRangeManager.js +36 -0
  148. package/package.json +5 -5
@@ -1,25 +1,24 @@
1
1
  'use client';
2
2
 
3
- import * as React from 'react';
4
- import { useField, useDefaultizedDateTimeField } from '@mui/x-date-pickers/internals';
3
+ import { useField, useFieldInternalPropsWithDefaults } from '@mui/x-date-pickers/internals';
5
4
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
6
- import { rangeValueManager, getRangeFieldValueManager } from "../internals/utils/valueManagers.js";
7
- import { validateDateTimeRange } from "../validation/index.js";
8
- export const useSingleInputDateTimeRangeField = inProps => {
9
- const props = useDefaultizedDateTimeField(inProps);
5
+ import { useDateTimeRangeManager } from "../managers/index.js";
6
+ export const useSingleInputDateTimeRangeField = props => {
7
+ const manager = useDateTimeRangeManager(props);
10
8
  const {
11
9
  forwardedProps,
12
10
  internalProps
13
11
  } = useSplitFieldProps(props, 'date-time');
14
- const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
15
- dateSeparator: internalProps.dateSeparator
16
- }), [internalProps.dateSeparator]);
12
+ const internalPropsWithDefaults = useFieldInternalPropsWithDefaults({
13
+ manager,
14
+ internalProps
15
+ });
17
16
  return useField({
18
17
  forwardedProps,
19
- internalProps,
20
- valueManager: rangeValueManager,
21
- fieldValueManager,
22
- validator: validateDateTimeRange,
23
- valueType: 'date-time'
18
+ internalProps: internalPropsWithDefaults,
19
+ valueManager: manager.internal_valueManager,
20
+ fieldValueManager: manager.internal_fieldValueManager,
21
+ validator: manager.validator,
22
+ valueType: manager.valueType
24
23
  });
25
24
  };
@@ -1,2 +1,2 @@
1
1
  import { UseSingleInputTimeRangeFieldProps } from './SingleInputTimeRangeField.types';
2
- export declare const useSingleInputTimeRangeField: <TEnableAccessibleFieldDOMStructure extends boolean, TAllProps extends UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>(inProps: TAllProps) => import("@mui/x-date-pickers/internals").UseFieldResponse<TEnableAccessibleFieldDOMStructure, Omit<TAllProps & Omit<UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, keyof import("@mui/x-date-pickers/internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps> & Required<Pick<UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, keyof import("@mui/x-date-pickers/internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps>>, "disabled" | "format" | "onChange" | "onError" | "defaultValue" | "value" | "readOnly" | "referenceDate" | "timezone" | "formatDensity" | "enableAccessibleFieldDOMStructure" | "selectedSections" | "onSelectedSectionsChange" | "shouldRespectLeadingZeros" | "unstableFieldRef" | "ampm" | keyof import("@mui/x-date-pickers/internals").BaseTimeValidationProps | keyof import("@mui/x-date-pickers/internals").TimeValidationProps | "dateSeparator">>;
2
+ export declare const useSingleInputTimeRangeField: <TEnableAccessibleFieldDOMStructure extends boolean, TAllProps extends UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>(props: TAllProps) => import("@mui/x-date-pickers/internals").UseFieldResponse<TEnableAccessibleFieldDOMStructure, Omit<TAllProps, "disabled" | "readOnly" | "value" | "defaultValue" | "onChange" | "onError" | "format" | "referenceDate" | "timezone" | "formatDensity" | "enableAccessibleFieldDOMStructure" | "selectedSections" | "onSelectedSectionsChange" | "shouldRespectLeadingZeros" | "unstableFieldRef" | "ampm" | keyof import("@mui/x-date-pickers/internals").BaseTimeValidationProps | keyof import("@mui/x-date-pickers/internals").TimeValidationProps | "dateSeparator">>;
@@ -1,25 +1,24 @@
1
1
  'use client';
2
2
 
3
- import * as React from 'react';
4
- import { useField, useDefaultizedTimeField } from '@mui/x-date-pickers/internals';
3
+ import { useField, useFieldInternalPropsWithDefaults } from '@mui/x-date-pickers/internals';
5
4
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
6
- import { rangeValueManager, getRangeFieldValueManager } from "../internals/utils/valueManagers.js";
7
- import { validateTimeRange } from "../validation/index.js";
8
- export const useSingleInputTimeRangeField = inProps => {
9
- const props = useDefaultizedTimeField(inProps);
5
+ import { useTimeRangeManager } from "../managers/index.js";
6
+ export const useSingleInputTimeRangeField = props => {
7
+ const manager = useTimeRangeManager(props);
10
8
  const {
11
9
  forwardedProps,
12
10
  internalProps
13
11
  } = useSplitFieldProps(props, 'time');
14
- const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
15
- dateSeparator: internalProps.dateSeparator
16
- }), [internalProps.dateSeparator]);
12
+ const internalPropsWithDefaults = useFieldInternalPropsWithDefaults({
13
+ manager,
14
+ internalProps
15
+ });
17
16
  return useField({
18
17
  forwardedProps,
19
- internalProps,
20
- valueManager: rangeValueManager,
21
- fieldValueManager,
22
- validator: validateTimeRange,
23
- valueType: 'time'
18
+ internalProps: internalPropsWithDefaults,
19
+ valueManager: manager.internal_valueManager,
20
+ fieldValueManager: manager.internal_fieldValueManager,
21
+ validator: manager.validator,
22
+ valueType: manager.valueType
24
23
  });
25
24
  };
@@ -1,9 +1,9 @@
1
1
  import { MakeOptional } from '@mui/x-internals/types';
2
2
  import { StaticRangeOnlyPickerProps, UseStaticRangePickerSlots, UseStaticRangePickerSlotProps } from '../internals/hooks/useStaticRangePicker';
3
3
  import { BaseDateRangePickerProps, BaseDateRangePickerSlots, BaseDateRangePickerSlotProps } from '../DateRangePicker/shared';
4
- export interface StaticDateRangePickerSlots extends BaseDateRangePickerSlots, UseStaticRangePickerSlots<'day'> {
4
+ export interface StaticDateRangePickerSlots extends BaseDateRangePickerSlots, UseStaticRangePickerSlots {
5
5
  }
6
- export interface StaticDateRangePickerSlotProps extends BaseDateRangePickerSlotProps, Omit<UseStaticRangePickerSlotProps<'day'>, 'toolbar'> {
6
+ export interface StaticDateRangePickerSlotProps extends BaseDateRangePickerSlotProps, Omit<UseStaticRangePickerSlotProps, 'toolbar'> {
7
7
  }
8
8
  export interface StaticDateRangePickerProps extends BaseDateRangePickerProps, MakeOptional<StaticRangeOnlyPickerProps, 'displayStaticWrapperAs'> {
9
9
  /**
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
3
3
  import { DateRangeCalendarProps } from '../DateRangeCalendar';
4
- export interface DateRangeViewRendererProps<TView extends DateOrTimeViewWithMeridiem> extends Omit<DateRangeCalendarProps, 'views'> {
4
+ export interface DateRangeViewRendererProps<TView extends DateOrTimeViewWithMeridiem> extends Omit<DateRangeCalendarProps, 'views' | 'onRangePositionChange' | 'rangePosition' | 'defaultRangePosition'> {
5
5
  views: readonly TView[];
6
6
  }
7
7
  /**
8
8
  * We don't pass all the props down to `DateRangeCalendar`,
9
9
  * because otherwise some unwanted props would be passed to the HTML element.
10
10
  */
11
- export declare const renderDateRangeViewCalendar: ({ value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, reduceAnimations, onMonthChange, rangePosition, defaultRangePosition, onRangePositionChange, calendars, currentMonthCalendarPosition, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, disableAutoMonthSwitching, sx, autoFocus, fixedWeekNumber, disableDragEditing, displayWeekNumber, timezone, availableRangePositions, views, view, onViewChange, }: DateRangeViewRendererProps<"day">) => React.JSX.Element;
11
+ export declare const renderDateRangeViewCalendar: ({ value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, reduceAnimations, onMonthChange, calendars, currentMonthCalendarPosition, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, disableAutoMonthSwitching, sx, autoFocus, fixedWeekNumber, disableDragEditing, displayWeekNumber, timezone, availableRangePositions, views, view, onViewChange, }: DateRangeViewRendererProps<"day">) => React.JSX.Element;
@@ -19,9 +19,6 @@ export const renderDateRangeViewCalendar = ({
19
19
  shouldDisableDate,
20
20
  reduceAnimations,
21
21
  onMonthChange,
22
- rangePosition,
23
- defaultRangePosition,
24
- onRangePositionChange,
25
22
  calendars,
26
23
  currentMonthCalendarPosition,
27
24
  slots,
@@ -58,9 +55,6 @@ export const renderDateRangeViewCalendar = ({
58
55
  shouldDisableDate: shouldDisableDate,
59
56
  reduceAnimations: reduceAnimations,
60
57
  onMonthChange: onMonthChange,
61
- rangePosition: rangePosition,
62
- defaultRangePosition: defaultRangePosition,
63
- onRangePositionChange: onRangePositionChange,
64
58
  calendars: calendars,
65
59
  currentMonthCalendarPosition: currentMonthCalendarPosition,
66
60
  slots: slots,
@@ -0,0 +1 @@
1
+ export { usePickerRangePositionContext } from './usePickerRangePositionContext';
package/hooks/index.js ADDED
@@ -0,0 +1 @@
1
+ export { usePickerRangePositionContext } from "./usePickerRangePositionContext.js";
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/hooks/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
3
+ export declare const PickerRangePositionContext: React.Context<UseRangePositionResponse | null>;
4
+ /**
5
+ * Returns information about the range position of the picker that wraps the current component.
6
+ */
7
+ export declare function usePickerRangePositionContext(): UseRangePositionResponse;
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ export const PickerRangePositionContext = /*#__PURE__*/React.createContext(null);
5
+
6
+ /**
7
+ * Returns information about the range position of the picker that wraps the current component.
8
+ */
9
+ export function usePickerRangePositionContext() {
10
+ const value = React.useContext(PickerRangePositionContext);
11
+ if (value == null) {
12
+ throw new Error(['MUI X: The `usePickerRangePositionContext` can only be called in components that are used inside a picker component'].join('\n'));
13
+ }
14
+ return value;
15
+ }
package/index.d.ts CHANGED
@@ -17,4 +17,6 @@ export * from './DesktopDateTimeRangePicker';
17
17
  export * from './MobileDateTimeRangePicker';
18
18
  export * from './dateRangeViewRenderers';
19
19
  export * from './models';
20
+ export * from './hooks';
20
21
  export * from './validation';
22
+ export * from './managers';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v8.0.0-alpha.5
2
+ * @mui/x-date-pickers-pro v8.0.0-alpha.7
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -32,4 +32,6 @@ export * from "./MobileDateTimeRangePicker/index.js";
32
32
  // View renderers
33
33
  export * from "./dateRangeViewRenderers/index.js";
34
34
  export * from "./models/index.js";
35
- export * from "./validation/index.js";
35
+ export * from "./hooks/index.js";
36
+ export * from "./validation/index.js";
37
+ export * from "./managers/index.js";
@@ -3,18 +3,18 @@ import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps } from '@mui
3
3
  import { BaseRangeNonStaticPickerProps } from '../../models';
4
4
  import { UseRangePositionProps, UseRangePositionResponse } from '../useRangePosition';
5
5
  import { RangePickerFieldSlots, RangePickerFieldSlotProps } from '../useEnrichedRangePickerFieldProps';
6
- export interface UseRangePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends ExportedPickersLayoutSlots<PickerRangeValue, TView>, RangePickerFieldSlots {
6
+ export interface UseRangePickerSlots extends ExportedPickersLayoutSlots<PickerRangeValue>, RangePickerFieldSlots {
7
7
  }
8
- export interface UseRangePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedPickersLayoutSlotProps<PickerRangeValue, TView>, RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure> {
8
+ export interface UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedPickersLayoutSlotProps<PickerRangeValue>, RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure> {
9
9
  tabs?: ExportedBaseTabsProps;
10
10
  toolbar?: ExportedBaseToolbarProps;
11
11
  }
12
12
  export interface RangeOnlyPickerProps extends BaseNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps, BaseRangeNonStaticPickerProps, UseRangePositionProps {
13
13
  }
14
- export interface UseRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>, TAdditionalViewProps extends {}> extends RangeOnlyPickerProps, BasePickerProps<PickerRangeValue, TView, TError, TExternalProps, TAdditionalViewProps> {
14
+ export interface UseRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, TView, any>> extends RangeOnlyPickerProps, BasePickerProps<PickerRangeValue, TView, TError, TExternalProps> {
15
15
  }
16
16
  export interface RangePickerAdditionalViewProps extends Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
17
17
  }
18
- export interface UseRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseRangePickerProps<TView, any, TExternalProps, TAdditionalViewProps>, TAdditionalViewProps extends {}> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps, TAdditionalViewProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
18
+ export interface UseRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParams<PickerRangeValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
19
19
  props: TExternalProps;
20
20
  }
@@ -9,6 +9,7 @@ import { executeInTheNextEventLoopTick, getActiveElement, usePicker, PickersPopp
9
9
  import { useEnrichedRangePickerFieldProps } from "../useEnrichedRangePickerFieldProps.js";
10
10
  import { getReleaseInfo } from "../../utils/releaseInfo.js";
11
11
  import { useRangePosition } from "../useRangePosition.js";
12
+ import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
12
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const releaseInfo = getReleaseInfo();
14
15
  export const useDesktopRangePicker = _ref => {
@@ -46,22 +47,16 @@ export const useDesktopRangePicker = _ref => {
46
47
  const singleInputFieldRef = React.useRef(null);
47
48
  const initialView = React.useRef(props.openTo ?? null);
48
49
  const fieldType = slots.field.fieldType ?? 'multi-input';
49
- const {
50
- rangePosition,
51
- onRangePositionChange
52
- } = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
50
+ const rangePositionResponse = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
53
51
  let fieldRef;
54
52
  if (fieldType === 'single-input') {
55
53
  fieldRef = singleInputFieldRef;
56
- } else if (rangePosition === 'start') {
54
+ } else if (rangePositionResponse.rangePosition === 'start') {
57
55
  fieldRef = startFieldRef;
58
56
  } else {
59
57
  fieldRef = endFieldRef;
60
58
  }
61
59
  const {
62
- open,
63
- actions,
64
- layoutProps,
65
60
  providerProps,
66
61
  renderCurrentView,
67
62
  shouldRestoreFocus,
@@ -72,15 +67,11 @@ export const useDesktopRangePicker = _ref => {
72
67
  variant: 'desktop',
73
68
  autoFocusView: false,
74
69
  fieldRef,
75
- localeText,
76
- additionalViewProps: {
77
- rangePosition,
78
- onRangePositionChange
79
- }
70
+ localeText
80
71
  }));
81
72
  React.useEffect(() => {
82
- if (layoutProps.view) {
83
- initialView.current = layoutProps.view;
73
+ if (providerProps.contextValue.view) {
74
+ initialView.current = providerProps.contextValue.view;
84
75
  }
85
76
  // eslint-disable-next-line react-hooks/exhaustive-deps
86
77
  }, []);
@@ -89,7 +80,9 @@ export const useDesktopRangePicker = _ref => {
89
80
  if (fieldContainerRef.current?.contains(getActiveElement(document)) || popperRef.current?.contains(getActiveElement(document))) {
90
81
  return;
91
82
  }
92
- actions.onDismiss();
83
+
84
+ // This direct access to `providerProps` will go away once the range fields stop having their views in a tooltip.
85
+ providerProps.privateContextValue.dismissViews();
93
86
  });
94
87
  };
95
88
  const Field = slots.field;
@@ -121,18 +114,17 @@ export const useDesktopRangePicker = _ref => {
121
114
  }),
122
115
  ownerState
123
116
  });
124
- const enrichedFieldProps = useEnrichedRangePickerFieldProps({
117
+ const enrichedFieldProps = useEnrichedRangePickerFieldProps(_extends({
125
118
  variant: 'desktop',
126
119
  fieldType,
127
- open,
128
- actions,
120
+ // These direct access to `providerProps` will go away once the range fields handle the picker opening
121
+ open: providerProps.contextValue.open,
122
+ setOpen: providerProps.contextValue.setOpen,
129
123
  readOnly,
130
124
  disableOpenPicker,
131
125
  label,
132
126
  localeText,
133
127
  onBlur: handleBlur,
134
- rangePosition,
135
- onRangePositionChange,
136
128
  pickerSlotProps: slotProps,
137
129
  pickerSlots: slots,
138
130
  fieldProps,
@@ -140,40 +132,30 @@ export const useDesktopRangePicker = _ref => {
140
132
  startFieldRef,
141
133
  endFieldRef,
142
134
  singleInputFieldRef,
143
- currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
144
- initialView: initialView.current ?? undefined,
145
- onViewChange: layoutProps.onViewChange
146
- });
147
- const slotPropsForLayout = _extends({}, slotProps, {
148
- tabs: _extends({}, slotProps?.tabs, {
149
- rangePosition,
150
- onRangePositionChange
151
- }),
152
- toolbar: _extends({}, slotProps?.toolbar, {
153
- rangePosition,
154
- onRangePositionChange
155
- })
156
- });
135
+ currentView: providerProps.contextValue.view !== props.openTo ? providerProps.contextValue.view : undefined,
136
+ initialView: initialView.current ?? undefined
137
+ }, rangePositionResponse));
157
138
  const Layout = slots?.layout ?? PickersLayout;
158
- const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
159
- children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, _extends({
160
- role: "tooltip",
161
- placement: "bottom-start",
162
- containerRef: popperRef,
163
- anchorEl: anchorRef.current,
164
- onBlur: handleBlur
165
- }, actions, {
166
- open: open,
167
- slots: slots,
168
- slotProps: slotProps,
169
- shouldRestoreFocus: shouldRestoreFocus,
170
- reduceAnimations: reduceAnimations,
171
- children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
139
+ const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
140
+ children: /*#__PURE__*/_jsxs(PickerRangePositionContext.Provider, {
141
+ value: rangePositionResponse,
142
+ children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, {
143
+ role: "tooltip",
144
+ placement: "bottom-start",
145
+ containerRef: popperRef,
146
+ anchorEl: anchorRef.current,
147
+ onBlur: handleBlur,
172
148
  slots: slots,
173
- slotProps: slotPropsForLayout,
174
- children: renderCurrentView()
175
- }))
176
- }))]
149
+ slotProps: slotProps,
150
+ shouldRestoreFocus: shouldRestoreFocus,
151
+ reduceAnimations: reduceAnimations,
152
+ children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
153
+ slots: slots,
154
+ slotProps: slotProps,
155
+ children: renderCurrentView()
156
+ }))
157
+ })]
158
+ })
177
159
  }));
178
160
  return {
179
161
  renderPicker
@@ -1,8 +1,8 @@
1
1
  import { PickersPopperSlots, PickersPopperSlotProps, UsePickerViewsProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
2
- import { RangeOnlyPickerProps, RangePickerAdditionalViewProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
3
- export interface UseDesktopRangePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends UseRangePickerSlots<TView>, PickersPopperSlots {
2
+ import { RangeOnlyPickerProps, UseRangePickerParams, UseRangePickerProps, UseRangePickerSlotProps, UseRangePickerSlots } from '../models/useRangePicker';
3
+ export interface UseDesktopRangePickerSlots extends UseRangePickerSlots, PickersPopperSlots {
4
4
  }
5
- export interface UseDesktopRangePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, PickersPopperSlotProps {
5
+ export interface UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, PickersPopperSlotProps {
6
6
  }
7
7
  export interface DesktopRangeOnlyPickerProps extends RangeOnlyPickerProps {
8
8
  /**
@@ -10,19 +10,17 @@ export interface DesktopRangeOnlyPickerProps extends RangeOnlyPickerProps {
10
10
  */
11
11
  autoFocus?: boolean;
12
12
  }
13
- export interface UseDesktopRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends UseRangePickerProps<TView, TError, TExternalProps, DesktopRangePickerAdditionalViewProps> {
13
+ export interface UseDesktopRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any>> extends UseRangePickerProps<TView, TError, TExternalProps> {
14
14
  /**
15
15
  * Overridable component slots.
16
16
  * @default {}
17
17
  */
18
- slots: UseDesktopRangePickerSlots<TView>;
18
+ slots: UseDesktopRangePickerSlots;
19
19
  /**
20
20
  * The props used for each component slot.
21
21
  * @default {}
22
22
  */
23
- slotProps?: UseDesktopRangePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>;
23
+ slotProps?: UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
24
24
  }
25
- export interface DesktopRangePickerAdditionalViewProps extends RangePickerAdditionalViewProps {
26
- }
27
- export interface UseDesktopRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TView, TExternalProps, DesktopRangePickerAdditionalViewProps> {
25
+ export interface UseDesktopRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends UseRangePickerParams<TView, TExternalProps> {
28
26
  }
@@ -6,7 +6,7 @@ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
6
6
  import { FieldRef, PickerOwnerState, FieldOwnerState } from '@mui/x-date-pickers/models';
7
7
  import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
8
8
  import { PickersInputLocaleText } from '@mui/x-date-pickers/locales';
9
- import { UsePickerResponse, PickerVariant, DateOrTimeViewWithMeridiem, BaseSingleInputFieldProps, PickerRangeValue, PickerValue } from '@mui/x-date-pickers/internals';
9
+ import { UsePickerValueContextValue, PickerVariant, DateOrTimeViewWithMeridiem, BaseSingleInputFieldProps, PickerRangeValue, PickerValue } from '@mui/x-date-pickers/internals';
10
10
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
11
11
  import { RangePosition, FieldType, PickerRangeFieldSlotProps } from '../../models';
12
12
  import { UseRangePositionResponse } from './useRangePosition';
@@ -39,7 +39,7 @@ export interface RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure ex
39
39
  }>;
40
40
  }
41
41
  export type RangePickerPropsForFieldSlot<TIsSingleInput extends boolean, TEnableAccessibleFieldDOMStructure extends boolean, TError> = (TIsSingleInput extends true ? BaseSingleInputFieldProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TError> : never) | (TIsSingleInput extends false ? BaseMultiInputFieldProps<TEnableAccessibleFieldDOMStructure, TError> : never);
42
- export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<UsePickerResponse<PickerRangeValue, TView, any>, 'open' | 'actions'>, UseRangePositionResponse {
42
+ export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<UsePickerValueContextValue<PickerRangeValue, TError>, 'open' | 'setOpen'>, UseRangePositionResponse {
43
43
  variant: PickerVariant;
44
44
  fieldType: FieldType;
45
45
  readOnly?: boolean;
@@ -54,9 +54,9 @@ export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends b
54
54
  anchorRef?: React.Ref<HTMLDivElement>;
55
55
  currentView?: TView | null;
56
56
  initialView?: TView;
57
- onViewChange?: (view: TView) => void;
58
- startFieldRef: React.RefObject<FieldRef<PickerValue>>;
59
- endFieldRef: React.RefObject<FieldRef<PickerValue>>;
60
- singleInputFieldRef: React.RefObject<FieldRef<PickerRangeValue>>;
57
+ setView?: (view: TView) => void;
58
+ startFieldRef: React.RefObject<FieldRef<PickerValue> | null>;
59
+ endFieldRef: React.RefObject<FieldRef<PickerValue> | null>;
60
+ singleInputFieldRef: React.RefObject<FieldRef<PickerRangeValue> | null>;
61
61
  }
62
62
  export declare const useEnrichedRangePickerFieldProps: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError>(params: UseEnrichedRangePickerFieldPropsParams<boolean, TView, TEnableAccessibleFieldDOMStructure, TError>) => BaseMultiInputFieldProps<TEnableAccessibleFieldDOMStructure, TError> | BaseSingleInputFieldProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TError>;
@@ -10,7 +10,7 @@ import { onSpaceOrEnter } from '@mui/x-date-pickers/internals';
10
10
  const useMultiInputFieldSlotProps = ({
11
11
  variant,
12
12
  open,
13
- actions,
13
+ setOpen,
14
14
  readOnly,
15
15
  labelId,
16
16
  disableOpenPicker,
@@ -24,7 +24,7 @@ const useMultiInputFieldSlotProps = ({
24
24
  anchorRef,
25
25
  currentView,
26
26
  initialView,
27
- onViewChange,
27
+ setView,
28
28
  startFieldRef,
29
29
  endFieldRef
30
30
  }) => {
@@ -54,21 +54,23 @@ const useMultiInputFieldSlotProps = ({
54
54
  event.stopPropagation();
55
55
  onRangePositionChange('start');
56
56
  if (!readOnly && !disableOpenPicker) {
57
- actions.onOpen(event);
57
+ event.preventDefault();
58
+ setOpen(true);
58
59
  }
59
60
  };
60
61
  const openRangeEndSelection = event => {
61
62
  event.stopPropagation();
62
63
  onRangePositionChange('end');
63
64
  if (!readOnly && !disableOpenPicker) {
64
- actions.onOpen(event);
65
+ event.preventDefault();
66
+ setOpen(true);
65
67
  }
66
68
  };
67
69
  const handleFocusStart = () => {
68
70
  if (open) {
69
71
  onRangePositionChange('start');
70
72
  if (previousRangePosition.current !== 'start' && initialView) {
71
- onViewChange?.(initialView);
73
+ setView?.(initialView);
72
74
  }
73
75
  }
74
76
  };
@@ -76,7 +78,7 @@ const useMultiInputFieldSlotProps = ({
76
78
  if (open) {
77
79
  onRangePositionChange('end');
78
80
  if (previousRangePosition.current !== 'end' && initialView) {
79
- onViewChange?.(initialView);
81
+ setView?.(initialView);
80
82
  }
81
83
  }
82
84
  };
@@ -148,7 +150,7 @@ const useMultiInputFieldSlotProps = ({
148
150
  const useSingleInputFieldSlotProps = ({
149
151
  variant,
150
152
  open,
151
- actions,
153
+ setOpen,
152
154
  readOnly,
153
155
  labelId,
154
156
  disableOpenPicker,
@@ -197,7 +199,8 @@ const useSingleInputFieldSlotProps = ({
197
199
  const openPicker = event => {
198
200
  event.stopPropagation();
199
201
  if (!readOnly && !disableOpenPicker) {
200
- actions.onOpen(event);
202
+ event.preventDefault();
203
+ setOpen(true);
201
204
  }
202
205
  };
203
206
  const slots = _extends({}, fieldProps.slots, {
@@ -11,6 +11,7 @@ import useId from '@mui/utils/useId';
11
11
  import { useEnrichedRangePickerFieldProps } from "../useEnrichedRangePickerFieldProps.js";
12
12
  import { getReleaseInfo } from "../../utils/releaseInfo.js";
13
13
  import { useRangePosition } from "../useRangePosition.js";
14
+ import { PickerRangePositionContext } from "../../../hooks/usePickerRangePositionContext.js";
14
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
16
  const releaseInfo = getReleaseInfo();
16
17
  export const useMobileRangePicker = _ref => {
@@ -42,24 +43,18 @@ export const useMobileRangePicker = _ref => {
42
43
  const endFieldRef = React.useRef(null);
43
44
  const singleInputFieldRef = React.useRef(null);
44
45
  const fieldType = slots.field.fieldType ?? 'multi-input';
45
- const {
46
- rangePosition,
47
- onRangePositionChange
48
- } = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
46
+ const rangePositionResponse = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
49
47
  const labelId = useId();
50
48
  const contextTranslations = usePickerTranslations();
51
49
  let fieldRef;
52
50
  if (fieldType === 'single-input') {
53
51
  fieldRef = singleInputFieldRef;
54
- } else if (rangePosition === 'start') {
52
+ } else if (rangePositionResponse.rangePosition === 'start') {
55
53
  fieldRef = startFieldRef;
56
54
  } else {
57
55
  fieldRef = endFieldRef;
58
56
  }
59
57
  const {
60
- open,
61
- actions,
62
- layoutProps,
63
58
  providerProps,
64
59
  renderCurrentView,
65
60
  fieldProps: pickerFieldProps,
@@ -69,11 +64,7 @@ export const useMobileRangePicker = _ref => {
69
64
  variant: 'mobile',
70
65
  autoFocusView: true,
71
66
  fieldRef,
72
- localeText,
73
- additionalViewProps: {
74
- rangePosition,
75
- onRangePositionChange
76
- }
67
+ localeText
77
68
  }));
78
69
  const Field = slots.field;
79
70
  const fieldProps = useSlotProps({
@@ -103,36 +94,24 @@ export const useMobileRangePicker = _ref => {
103
94
  ownerState
104
95
  });
105
96
  const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
106
- const enrichedFieldProps = useEnrichedRangePickerFieldProps({
97
+ const enrichedFieldProps = useEnrichedRangePickerFieldProps(_extends({
107
98
  variant: 'mobile',
108
99
  fieldType,
109
- open,
110
- actions,
100
+ // These direct access to `providerProps` will go away once the range fields handle the picker opening
101
+ open: providerProps.contextValue.open,
102
+ setOpen: providerProps.contextValue.setOpen,
111
103
  readOnly,
112
104
  labelId,
113
105
  disableOpenPicker,
114
106
  label,
115
107
  localeText,
116
- rangePosition,
117
- onRangePositionChange,
118
108
  pickerSlots: slots,
119
109
  pickerSlotProps: innerSlotProps,
120
110
  fieldProps,
121
111
  startFieldRef,
122
112
  endFieldRef,
123
113
  singleInputFieldRef
124
- });
125
- const slotPropsForLayout = _extends({}, innerSlotProps, {
126
- tabs: _extends({}, innerSlotProps?.tabs, {
127
- rangePosition,
128
- onRangePositionChange
129
- }),
130
- toolbar: _extends({}, innerSlotProps?.toolbar, {
131
- titleId: labelId,
132
- rangePosition,
133
- onRangePositionChange
134
- })
135
- });
114
+ }, rangePositionResponse));
136
115
  const Layout = slots?.layout ?? PickersLayout;
137
116
  const finalLocaleText = _extends({}, contextTranslations, localeText);
138
117
  let labelledById = pickerParams.valueType === 'date-time' ? `${labelId}-start-toolbar ${labelId}-end-toolbar` : labelId;
@@ -151,21 +130,26 @@ export const useMobileRangePicker = _ref => {
151
130
  labelledById = labels.length > 0 ? labels.join(' ') : undefined;
152
131
  }
153
132
  const slotProps = _extends({}, innerSlotProps, {
133
+ toolbar: _extends({}, innerSlotProps?.toolbar, {
134
+ titleId: labelId
135
+ }),
154
136
  mobilePaper: _extends({
155
137
  'aria-labelledby': labelledById
156
138
  }, innerSlotProps?.mobilePaper)
157
139
  });
158
- const renderPicker = () => /*#__PURE__*/_jsxs(PickerProvider, _extends({}, providerProps, {
159
- children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, _extends({}, actions, {
160
- open: open,
161
- slots: slots,
162
- slotProps: slotProps,
163
- children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
140
+ const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
141
+ children: /*#__PURE__*/_jsxs(PickerRangePositionContext.Provider, {
142
+ value: rangePositionResponse,
143
+ children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, {
164
144
  slots: slots,
165
- slotProps: slotPropsForLayout,
166
- children: renderCurrentView()
167
- }))
168
- }))]
145
+ slotProps: slotProps,
146
+ children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
147
+ slots: slots,
148
+ slotProps: slotProps,
149
+ children: renderCurrentView()
150
+ }))
151
+ })]
152
+ })
169
153
  }));
170
154
  return {
171
155
  renderPicker