@mui/x-date-pickers-pro 8.0.0-alpha.1 → 8.0.0-alpha.3

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 (77) hide show
  1. package/CHANGELOG.md +330 -7
  2. package/DateRangePicker/DateRangePicker.types.d.ts +2 -2
  3. package/DateRangePicker/shared.d.ts +3 -2
  4. package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +2 -2
  5. package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  6. package/DateTimeRangePicker/shared.d.ts +4 -3
  7. package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  8. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +12 -10
  9. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +11 -9
  11. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  12. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +11 -9
  13. package/README.md +7 -4
  14. package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  15. package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -10
  16. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  17. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +11 -10
  18. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  19. package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +10 -9
  20. package/index.js +1 -1
  21. package/internals/hooks/models/useRangePicker.d.ts +1 -2
  22. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  23. package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +13 -12
  24. package/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  25. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  26. package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +6 -7
  27. package/internals/hooks/useRangePosition.d.ts +3 -2
  28. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
  29. package/internals/models/dateTimeRange.d.ts +2 -2
  30. package/internals/models/fields.d.ts +6 -6
  31. package/internals/models/timeRange.d.ts +2 -2
  32. package/internals/utils/date-fields-utils.d.ts +6 -6
  33. package/internals/utils/releaseInfo.js +1 -1
  34. package/internals/utils/valueManagers.d.ts +4 -3
  35. package/models/dateRange.d.ts +3 -3
  36. package/models/fields.d.ts +6 -9
  37. package/models/index.d.ts +1 -0
  38. package/models/index.js +2 -1
  39. package/models/range.d.ts +0 -1
  40. package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  41. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  42. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  43. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  44. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  45. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  46. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  47. package/modern/index.js +1 -1
  48. package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  49. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  50. package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  51. package/modern/internals/utils/releaseInfo.js +1 -1
  52. package/modern/models/index.js +2 -1
  53. package/modern/validation/validateDateRange.js +8 -0
  54. package/modern/validation/validateDateTimeRange.js +4 -0
  55. package/modern/validation/validateTimeRange.js +8 -0
  56. package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -6
  57. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -11
  58. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +9 -11
  59. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -11
  60. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
  61. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
  62. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
  63. package/node/index.js +1 -1
  64. package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  65. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  66. package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  67. package/node/internals/utils/releaseInfo.js +1 -1
  68. package/node/validation/validateDateRange.js +8 -0
  69. package/node/validation/validateDateTimeRange.js +4 -0
  70. package/node/validation/validateTimeRange.js +8 -0
  71. package/package.json +4 -4
  72. package/validation/validateDateRange.d.ts +9 -1
  73. package/validation/validateDateRange.js +8 -0
  74. package/validation/validateDateTimeRange.d.ts +6 -2
  75. package/validation/validateDateTimeRange.js +4 -0
  76. package/validation/validateTimeRange.d.ts +9 -1
  77. package/validation/validateTimeRange.js +8 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
5
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -12,17 +12,14 @@ import Typography from '@mui/material/Typography';
12
12
  import { styled, useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
14
14
  import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
15
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
15
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
16
16
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
17
17
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
18
18
  import { useMultiInputDateTimeRangeField } from "../internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js";
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export const multiInputDateTimeRangeFieldClasses = generateUtilityClasses('MuiMultiInputDateTimeRangeField', ['root', 'separator']);
21
21
  export const getMultiInputDateTimeRangeFieldUtilityClass = slot => generateUtilityClass('MuiMultiInputDateTimeRangeField', slot);
22
- const useUtilityClasses = ownerState => {
23
- const {
24
- classes
25
- } = ownerState;
22
+ const useUtilityClasses = classes => {
26
23
  const slots = {
27
24
  root: ['root'],
28
25
  separator: ['separator']
@@ -70,11 +67,12 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
70
67
  slotProps,
71
68
  unstableStartFieldRef,
72
69
  unstableEndFieldRef,
73
- className
70
+ className,
71
+ classes: classesProp
74
72
  } = forwardedProps,
75
73
  otherForwardedProps = _objectWithoutPropertiesLoose(forwardedProps, _excluded);
76
- const ownerState = themeProps;
77
- const classes = useUtilityClasses(ownerState);
74
+ const ownerState = useFieldOwnerState(themeProps);
75
+ const classes = useUtilityClasses(classesProp);
78
76
  const Root = slots?.root ?? MultiInputDateTimeRangeFieldRoot;
79
77
  const rootProps = useSlotProps({
80
78
  elementType: Root,
@@ -298,10 +296,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
298
296
  */
299
297
  shouldDisableTime: PropTypes.func,
300
298
  /**
301
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
302
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
299
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
300
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
303
301
  *
304
- * 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`.
302
+ * 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`.
305
303
  *
306
304
  * 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.
307
305
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -1,8 +1,10 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/utils';
3
- import Typography from '@mui/material/Typography';
4
- import Stack, { StackProps } from '@mui/material/Stack';
5
- import TextField from '@mui/material/TextField';
2
+ import type { TypographyProps } from '@mui/material/Typography';
3
+ import type { StackProps } from '@mui/material/Stack';
4
+ import type { TextFieldProps } from '@mui/material/TextField';
5
+ import { FieldOwnerState } from '@mui/x-date-pickers/models';
6
+ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
7
+ import { PickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
6
8
  import { UseDateTimeRangeFieldProps } from '../internals/models/dateTimeRange';
7
9
  import { UseMultiInputRangeFieldParams } from '../internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types';
8
10
  import { MultiInputFieldRefs, MultiInputRangeFieldClasses, RangePosition } from '../models';
@@ -25,7 +27,7 @@ export interface MultiInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStru
25
27
  * The props used for each component slot.
26
28
  * @default {}
27
29
  */
28
- slotProps?: MultiInputDateTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>;
30
+ slotProps?: MultiInputDateTimeRangeFieldSlotProps;
29
31
  }
30
32
  export interface MultiInputDateTimeRangeFieldSlots {
31
33
  /**
@@ -45,10 +47,10 @@ export interface MultiInputDateTimeRangeFieldSlots {
45
47
  */
46
48
  separator?: React.ElementType;
47
49
  }
48
- export interface MultiInputDateTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> {
49
- root?: SlotComponentProps<typeof Stack, {}, MultiInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
50
- textField?: SlotComponentProps<typeof TextField, {}, MultiInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure> & {
50
+ export interface MultiInputDateTimeRangeFieldSlotProps {
51
+ root?: SlotComponentPropsFromProps<StackProps, {}, FieldOwnerState>;
52
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState & {
51
53
  position: RangePosition;
52
54
  }>;
53
- separator?: SlotComponentProps<typeof Typography, {}, MultiInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
55
+ separator?: SlotComponentPropsFromProps<TypographyProps, {}, FieldOwnerState>;
54
56
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
5
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { clsx } from 'clsx';
@@ -12,17 +12,14 @@ import Typography from '@mui/material/Typography';
12
12
  import { styled, useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
14
14
  import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
15
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
15
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
16
16
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
17
17
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
18
18
  import { useMultiInputTimeRangeField } from "../internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js";
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export const multiInputTimeRangeFieldClasses = generateUtilityClasses('MuiMultiInputTimeRangeField', ['root', 'separator']);
21
21
  export const getMultiInputTimeRangeFieldUtilityClass = slot => generateUtilityClass('MuiMultiInputTimeRangeField', slot);
22
- const useUtilityClasses = ownerState => {
23
- const {
24
- classes
25
- } = ownerState;
22
+ const useUtilityClasses = classes => {
26
23
  const slots = {
27
24
  root: ['root'],
28
25
  separator: ['separator']
@@ -70,11 +67,12 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
70
67
  slotProps,
71
68
  unstableStartFieldRef,
72
69
  unstableEndFieldRef,
73
- className
70
+ className,
71
+ classes: classesProp
74
72
  } = forwardedProps,
75
73
  otherForwardedProps = _objectWithoutPropertiesLoose(forwardedProps, _excluded);
76
- const ownerState = themeProps;
77
- const classes = useUtilityClasses(ownerState);
74
+ const ownerState = useFieldOwnerState(themeProps);
75
+ const classes = useUtilityClasses(classesProp);
78
76
  const Root = slots?.root ?? MultiInputTimeRangeFieldRoot;
79
77
  const rootProps = useSlotProps({
80
78
  elementType: Root,
@@ -270,10 +268,10 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
270
268
  */
271
269
  shouldDisableTime: PropTypes.func,
272
270
  /**
273
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
274
- * 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`)
275
273
  *
276
- * 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`.
277
275
  *
278
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.
279
277
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -1,8 +1,10 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/utils';
3
- import Typography from '@mui/material/Typography';
4
- import Stack, { StackProps } from '@mui/material/Stack';
5
- import TextField from '@mui/material/TextField';
2
+ import type { TypographyProps } from '@mui/material/Typography';
3
+ import type { StackProps } from '@mui/material/Stack';
4
+ import type { TextFieldProps } from '@mui/material/TextField';
5
+ import { FieldOwnerState } from '@mui/x-date-pickers/models';
6
+ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
7
+ import { PickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
6
8
  import { UseTimeRangeFieldProps } from '../internals/models/timeRange';
7
9
  import { UseMultiInputRangeFieldParams } from '../internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types';
8
10
  import { MultiInputFieldRefs, MultiInputRangeFieldClasses, RangePosition } from '../models';
@@ -25,7 +27,7 @@ export interface MultiInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructur
25
27
  * The props used for each component slot.
26
28
  * @default {}
27
29
  */
28
- slotProps?: MultiInputTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>;
30
+ slotProps?: MultiInputTimeRangeFieldSlotProps;
29
31
  }
30
32
  export interface MultiInputTimeRangeFieldSlots {
31
33
  /**
@@ -45,10 +47,10 @@ export interface MultiInputTimeRangeFieldSlots {
45
47
  */
46
48
  separator?: React.ElementType;
47
49
  }
48
- export interface MultiInputTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> {
49
- root?: SlotComponentProps<typeof Stack, {}, MultiInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
50
- textField?: SlotComponentProps<typeof TextField, {}, MultiInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure> & {
50
+ export interface MultiInputTimeRangeFieldSlotProps {
51
+ root?: SlotComponentPropsFromProps<StackProps, {}, FieldOwnerState>;
52
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState & {
51
53
  position: RangePosition;
52
54
  }>;
53
- separator?: SlotComponentProps<typeof Typography, {}, MultiInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
55
+ separator?: SlotComponentPropsFromProps<TypographyProps, {}, FieldOwnerState>;
54
56
  }
package/README.md CHANGED
@@ -20,13 +20,16 @@ The pickers currently support the following date libraries:
20
20
  - [Moment.js](https://momentjs.com/)
21
21
 
22
22
  ```bash
23
- // date-fns
23
+ # date-fns
24
24
  npm install date-fns
25
- // or dayjs
25
+
26
+ # or dayjs
26
27
  npm install dayjs
27
- // or luxon
28
+
29
+ # or luxon
28
30
  npm install luxon
29
- // or moment
31
+
32
+ # or moment
30
33
  npm install moment
31
34
  ```
32
35
 
@@ -10,7 +10,7 @@ import { useThemeProps } from '@mui/material/styles';
10
10
  import useSlotProps from '@mui/utils/useSlotProps';
11
11
  import { refType } from '@mui/utils';
12
12
  import { useClearableField } from '@mui/x-date-pickers/hooks';
13
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
13
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
14
14
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
15
15
  import { useSingleInputDateRangeField } from "./useSingleInputDateRangeField.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -36,7 +36,7 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
36
36
  inputProps
37
37
  } = themeProps,
38
38
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
39
+ const ownerState = useFieldOwnerState(themeProps);
40
40
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
41
  const textFieldProps = useSlotProps({
42
42
  elementType: TextField,
@@ -262,10 +262,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
262
262
  */
263
263
  shouldDisableDate: PropTypes.func,
264
264
  /**
265
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
266
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
265
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
266
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
267
267
  *
268
- * 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`.
268
+ * 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`.
269
269
  *
270
270
  * 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.
271
271
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/utils';
3
- import TextField from '@mui/material/TextField';
4
- import { UseFieldInternalProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
5
- import { BuiltInFieldTextFieldProps } from '@mui/x-date-pickers/models';
2
+ import { TextFieldProps } from '@mui/material/TextField';
3
+ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
4
+ import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
5
+ import { BuiltInFieldTextFieldProps, FieldOwnerState } from '@mui/x-date-pickers/models';
6
6
  import { ExportedUseClearableFieldProps, UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
7
- import type { RangeFieldSection, DateRangeValidationError, UseDateRangeFieldProps } from '../models';
8
- export interface UseSingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseDateRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'> {
7
+ import { PickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
8
+ import type { DateRangeValidationError, UseDateRangeFieldProps } from '../models';
9
+ export interface UseSingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseDateRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'> {
9
10
  }
10
11
  export type SingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean = true> = Omit<BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure>, keyof UseSingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure>> & UseSingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure> & {
11
12
  /**
@@ -17,15 +18,15 @@ export type SingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure ex
17
18
  * The props used for each component slot.
18
19
  * @default {}
19
20
  */
20
- slotProps?: SingleInputDateRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>;
21
+ slotProps?: SingleInputDateRangeFieldSlotProps;
21
22
  };
22
23
  export interface SingleInputDateRangeFieldSlots extends UseClearableFieldSlots {
23
24
  /**
24
25
  * Form control with an input to render the value.
25
- * @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
26
+ * @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`.
26
27
  */
27
28
  textField?: React.ElementType;
28
29
  }
29
- export interface SingleInputDateRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseClearableFieldSlotProps {
30
- textField?: SlotComponentProps<typeof TextField, {}, SingleInputDateRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
30
+ export interface SingleInputDateRangeFieldSlotProps extends UseClearableFieldSlotProps {
31
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
31
32
  }
@@ -6,7 +6,7 @@ const _excluded = ["slots", "slotProps", "InputProps", "inputProps"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import MuiTextField from '@mui/material/TextField';
9
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
9
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
10
10
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
11
11
  import { useThemeProps } from '@mui/material/styles';
12
12
  import { refType } from '@mui/utils';
@@ -36,7 +36,7 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
36
36
  inputProps
37
37
  } = themeProps,
38
38
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
39
+ const ownerState = useFieldOwnerState(themeProps);
40
40
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
41
  const textFieldProps = useSlotProps({
42
42
  elementType: TextField,
@@ -302,10 +302,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
302
302
  */
303
303
  shouldDisableTime: PropTypes.func,
304
304
  /**
305
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
306
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
305
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
306
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
307
307
  *
308
- * 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`.
308
+ * 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`.
309
309
  *
310
310
  * 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.
311
311
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/utils';
3
- import TextField from '@mui/material/TextField';
4
- import { UseFieldInternalProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
5
- import { BuiltInFieldTextFieldProps } from '@mui/x-date-pickers/models';
2
+ import { TextFieldProps } from '@mui/material/TextField';
3
+ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
4
+ import { PickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
5
+ import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
6
+ import { BuiltInFieldTextFieldProps, FieldOwnerState } from '@mui/x-date-pickers/models';
6
7
  import { ExportedUseClearableFieldProps, UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
7
8
  import { UseDateTimeRangeFieldProps } from '../internals/models';
8
- import { RangeFieldSection, DateTimeRangeValidationError } from '../models';
9
- export interface UseSingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'> {
9
+ import { DateTimeRangeValidationError } from '../models';
10
+ export interface UseSingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'> {
10
11
  }
11
12
  export type SingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean = true> = Omit<BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure>, keyof UseSingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>> & UseSingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure> & {
12
13
  /**
@@ -18,15 +19,15 @@ export type SingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructur
18
19
  * The props used for each component slot.
19
20
  * @default {}
20
21
  */
21
- slotProps?: SingleInputDateTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>;
22
+ slotProps?: SingleInputDateTimeRangeFieldSlotProps;
22
23
  };
23
24
  export interface SingleInputDateTimeRangeFieldSlots extends UseClearableFieldSlots {
24
25
  /**
25
26
  * Form control with an input to render the value.
26
- * @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
27
+ * @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`.
27
28
  */
28
29
  textField?: React.ElementType;
29
30
  }
30
- export interface SingleInputDateTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseClearableFieldSlotProps {
31
- textField?: SlotComponentProps<typeof TextField, {}, SingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
31
+ export interface SingleInputDateTimeRangeFieldSlotProps extends UseClearableFieldSlotProps {
32
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
32
33
  }
@@ -7,7 +7,7 @@ import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import MuiTextField from '@mui/material/TextField';
9
9
  import { useClearableField } from '@mui/x-date-pickers/hooks';
10
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
10
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
11
11
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
12
12
  import { useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
@@ -36,7 +36,7 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
36
36
  inputProps
37
37
  } = themeProps,
38
38
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
39
+ const ownerState = useFieldOwnerState(themeProps);
40
40
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
41
  const textFieldProps = useSlotProps({
42
42
  elementType: TextField,
@@ -274,10 +274,10 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
274
274
  */
275
275
  shouldDisableTime: PropTypes.func,
276
276
  /**
277
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
278
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
277
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
278
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
279
279
  *
280
- * 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`.
280
+ * 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`.
281
281
  *
282
282
  * 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.
283
283
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/utils';
3
- import TextField from '@mui/material/TextField';
2
+ import type { TextFieldProps } from '@mui/material/TextField';
4
3
  import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
5
- import { BuiltInFieldTextFieldProps } from '@mui/x-date-pickers/models';
4
+ import { BuiltInFieldTextFieldProps, FieldOwnerState } from '@mui/x-date-pickers/models';
5
+ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
6
+ import { PickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
6
7
  import { ExportedUseClearableFieldProps, UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
7
8
  import { UseTimeRangeFieldProps } from '../internals/models';
8
- import { RangeFieldSection, TimeRangeValidationError } from '../models';
9
- export interface UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'> {
9
+ import { TimeRangeValidationError } from '../models';
10
+ export interface UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'> {
10
11
  }
11
12
  export type SingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean = true> = Omit<BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure>, keyof UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>> & UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure> & {
12
13
  /**
@@ -18,15 +19,15 @@ export type SingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure ex
18
19
  * The props used for each component slot.
19
20
  * @default {}
20
21
  */
21
- slotProps?: SingleInputTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>;
22
+ slotProps?: SingleInputTimeRangeFieldSlotProps;
22
23
  };
23
24
  export interface SingleInputTimeRangeFieldSlots extends UseClearableFieldSlots {
24
25
  /**
25
26
  * Form control with an input to render the value.
26
- * @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
27
+ * @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`.
27
28
  */
28
29
  textField?: React.ElementType;
29
30
  }
30
- export interface SingleInputTimeRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseClearableFieldSlotProps {
31
- textField?: SlotComponentProps<typeof TextField, {}, SingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>>;
31
+ export interface SingleInputTimeRangeFieldSlotProps extends UseClearableFieldSlotProps {
32
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
32
33
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v8.0.0-alpha.1
2
+ * @mui/x-date-pickers-pro v8.0.0-alpha.3
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -3,7 +3,6 @@ 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
- import { RangeFieldSection } from '../../../models';
7
6
  export interface UseRangePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends ExportedPickersLayoutSlots<PickerRangeValue, TView>, RangePickerFieldSlots {
8
7
  }
9
8
  export interface UseRangePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedPickersLayoutSlotProps<PickerRangeValue, TView>, RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure> {
@@ -16,6 +15,6 @@ export interface UseRangePickerProps<TView extends DateOrTimeViewWithMeridiem, T
16
15
  }
17
16
  export interface RangePickerAdditionalViewProps extends Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
18
17
  }
19
- export interface UseRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseRangePickerProps<TView, any, TExternalProps, TAdditionalViewProps>, TAdditionalViewProps extends {}> extends Pick<UsePickerParams<PickerRangeValue, TView, RangeFieldSection, TExternalProps, TAdditionalViewProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
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'> {
20
19
  props: TExternalProps;
21
20
  }
@@ -43,12 +43,21 @@ export const useDesktopRangePicker = _ref => {
43
43
  const popperRef = React.useRef(null);
44
44
  const startFieldRef = React.useRef(null);
45
45
  const endFieldRef = React.useRef(null);
46
+ const singleInputFieldRef = React.useRef(null);
46
47
  const initialView = React.useRef(props.openTo ?? null);
47
48
  const fieldType = slots.field.fieldType ?? 'multi-input';
48
49
  const {
49
50
  rangePosition,
50
51
  onRangePositionChange
51
- } = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
52
+ } = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
53
+ let fieldRef;
54
+ if (fieldType === 'single-input') {
55
+ fieldRef = singleInputFieldRef;
56
+ } else if (rangePosition === 'start') {
57
+ fieldRef = startFieldRef;
58
+ } else {
59
+ fieldRef = endFieldRef;
60
+ }
52
61
  const {
53
62
  open,
54
63
  actions,
@@ -62,7 +71,7 @@ export const useDesktopRangePicker = _ref => {
62
71
  props,
63
72
  variant: 'desktop',
64
73
  autoFocusView: false,
65
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
74
+ fieldRef,
66
75
  localeText,
67
76
  additionalViewProps: {
68
77
  rangePosition,
@@ -130,6 +139,7 @@ export const useDesktopRangePicker = _ref => {
130
139
  anchorRef,
131
140
  startFieldRef,
132
141
  endFieldRef,
142
+ singleInputFieldRef,
133
143
  currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
134
144
  initialView: initialView.current ?? undefined,
135
145
  onViewChange: layoutProps.onViewChange
@@ -3,12 +3,12 @@ import Stack, { StackProps } from '@mui/material/Stack';
3
3
  import Typography, { TypographyProps } from '@mui/material/Typography';
4
4
  import { SlotComponentProps } from '@mui/utils';
5
5
  import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
6
- import { FieldRef, PickerOwnerState } from '@mui/x-date-pickers/models';
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 } from '@mui/x-date-pickers/internals';
9
+ import { UsePickerResponse, PickerVariant, DateOrTimeViewWithMeridiem, BaseSingleInputFieldProps, PickerRangeValue, PickerValue } from '@mui/x-date-pickers/internals';
10
10
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
11
- import { RangeFieldSection, RangePosition, FieldType, UseDateRangeFieldProps, PickerRangeFieldSlotProps } from '../../models';
11
+ import { RangePosition, FieldType, PickerRangeFieldSlotProps } from '../../models';
12
12
  import { UseRangePositionResponse } from './useRangePosition';
13
13
  import { BaseMultiInputFieldProps } from '../models/fields';
14
14
  export interface RangePickerFieldSlots extends UseClearableFieldSlots {
@@ -31,15 +31,15 @@ export interface RangePickerFieldSlots extends UseClearableFieldSlots {
31
31
  textField?: React.ElementType;
32
32
  }
33
33
  export interface RangePickerFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseClearableFieldSlotProps {
34
- field?: SlotComponentPropsFromProps<PickerRangeFieldSlotProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
35
- fieldRoot?: SlotComponentProps<typeof Stack, {}, Record<string, any>>;
36
- fieldSeparator?: SlotComponentProps<typeof Typography, {}, Record<string, any>>;
37
- textField?: SlotComponentProps<typeof PickersTextField, {}, UseDateRangeFieldProps<TEnableAccessibleFieldDOMStructure> & {
34
+ field?: SlotComponentPropsFromProps<PickerRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
35
+ fieldRoot?: SlotComponentProps<typeof Stack, {}, FieldOwnerState>;
36
+ fieldSeparator?: SlotComponentProps<typeof Typography, {}, FieldOwnerState>;
37
+ textField?: SlotComponentProps<typeof PickersTextField, {}, FieldOwnerState & {
38
38
  position?: RangePosition;
39
39
  }>;
40
40
  }
41
- export type RangePickerPropsForFieldSlot<TIsSingleInput extends boolean, TEnableAccessibleFieldDOMStructure extends boolean, TError> = (TIsSingleInput extends true ? BaseSingleInputFieldProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError> : never) | (TIsSingleInput extends false ? BaseMultiInputFieldProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError> : never);
42
- export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<UsePickerResponse<PickerRangeValue, TView, RangeFieldSection, any>, 'open' | 'actions'>, UseRangePositionResponse {
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 {
43
43
  variant: PickerVariant;
44
44
  fieldType: FieldType;
45
45
  readOnly?: boolean;
@@ -55,7 +55,8 @@ export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends b
55
55
  currentView?: TView | null;
56
56
  initialView?: TView;
57
57
  onViewChange?: (view: TView) => void;
58
- startFieldRef: React.RefObject<FieldRef<RangeFieldSection>>;
59
- endFieldRef: React.RefObject<FieldRef<RangeFieldSection>>;
58
+ startFieldRef: React.RefObject<FieldRef<PickerValue>>;
59
+ endFieldRef: React.RefObject<FieldRef<PickerValue>>;
60
+ singleInputFieldRef: React.RefObject<FieldRef<PickerRangeValue>>;
60
61
  }
61
- export declare const useEnrichedRangePickerFieldProps: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError>(params: UseEnrichedRangePickerFieldPropsParams<boolean, TView, TEnableAccessibleFieldDOMStructure, TError>) => BaseMultiInputFieldProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError> | BaseSingleInputFieldProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TError>;
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>;
@@ -156,36 +156,35 @@ const useSingleInputFieldSlotProps = ({
156
156
  onBlur,
157
157
  rangePosition,
158
158
  onRangePositionChange,
159
- startFieldRef,
160
- endFieldRef,
159
+ singleInputFieldRef,
161
160
  pickerSlots,
162
161
  pickerSlotProps,
163
162
  fieldProps,
164
163
  anchorRef,
165
164
  currentView
166
165
  }) => {
167
- const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, startFieldRef, endFieldRef);
166
+ const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
168
167
  React.useEffect(() => {
169
- if (!open || !startFieldRef.current || variant === 'mobile') {
168
+ if (!open || !singleInputFieldRef.current || variant === 'mobile') {
170
169
  return;
171
170
  }
172
- if (startFieldRef.current.isFieldFocused()) {
171
+ if (singleInputFieldRef.current.isFieldFocused()) {
173
172
  return;
174
173
  }
175
174
 
176
175
  // bring back focus to the field with the current view section selected
177
176
  if (currentView) {
178
- const sections = startFieldRef.current.getSections().map(section => section.type);
177
+ const sections = singleInputFieldRef.current.getSections().map(section => section.type);
179
178
  const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
180
- startFieldRef.current?.focusField(newSelectedSection);
179
+ singleInputFieldRef.current?.focusField(newSelectedSection);
181
180
  }
182
- }, [rangePosition, open, currentView, startFieldRef, variant]);
181
+ }, [rangePosition, open, currentView, singleInputFieldRef, variant]);
183
182
  const updateRangePosition = () => {
184
- if (!startFieldRef.current?.isFieldFocused()) {
183
+ if (!singleInputFieldRef.current?.isFieldFocused()) {
185
184
  return;
186
185
  }
187
- const sections = startFieldRef.current.getSections();
188
- const activeSectionIndex = startFieldRef.current?.getActiveSectionIndex();
186
+ const sections = singleInputFieldRef.current.getSections();
187
+ const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
189
188
  const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
190
189
  if (domRangePosition != null && domRangePosition !== rangePosition) {
191
190
  onRangePositionChange(domRangePosition);