@mui/x-date-pickers-pro 8.0.0-alpha.0 → 8.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +651 -6
- package/DateRangeCalendar/DateRangeCalendar.js +3 -1
- package/DateRangePicker/DateRangePicker.types.d.ts +2 -2
- package/DateRangePicker/DateRangePickerToolbar.js +0 -12
- package/DateRangePicker/shared.d.ts +3 -2
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +6 -16
- package/DateTimeRangePicker/shared.d.ts +4 -3
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +12 -10
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +11 -9
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +11 -9
- package/README.md +9 -6
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -10
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +11 -10
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +10 -9
- package/index.js +1 -1
- package/internals/hooks/models/useRangePicker.d.ts +1 -2
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +14 -4
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +14 -13
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +17 -18
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +15 -5
- package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +6 -7
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +2 -0
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +2 -0
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +3 -1
- package/internals/hooks/useRangePosition.d.ts +3 -2
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -1
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
- package/internals/models/dateTimeRange.d.ts +2 -2
- package/internals/models/fields.d.ts +6 -6
- package/internals/models/timeRange.d.ts +2 -2
- package/internals/utils/date-fields-utils.d.ts +6 -6
- package/internals/utils/date-range-manager.d.ts +2 -1
- package/internals/utils/date-range-manager.js +11 -9
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.d.ts +4 -3
- package/models/dateRange.d.ts +3 -3
- package/models/fields.d.ts +6 -9
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/models/range.d.ts +0 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +3 -1
- package/modern/DateRangePicker/DateRangePickerToolbar.js +0 -12
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +6 -16
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +14 -4
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +17 -18
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +15 -5
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +2 -0
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +2 -0
- package/modern/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +3 -1
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -1
- package/modern/internals/utils/date-range-manager.js +11 -9
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/models/index.js +2 -1
- package/modern/validation/validateDateRange.js +8 -0
- package/modern/validation/validateDateTimeRange.js +4 -0
- package/modern/validation/validateTimeRange.js +8 -0
- package/node/DateRangeCalendar/DateRangeCalendar.js +3 -1
- package/node/DateRangePicker/DateRangePickerToolbar.js +0 -12
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -6
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +5 -15
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -11
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +9 -11
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -11
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +14 -4
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +17 -18
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +15 -5
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js +2 -0
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js +2 -0
- package/node/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js +3 -1
- package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +1 -1
- package/node/internals/utils/date-range-manager.js +11 -9
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/validation/validateDateRange.js +8 -0
- package/node/validation/validateDateTimeRange.js +4 -0
- package/node/validation/validateTimeRange.js +8 -0
- package/package.json +6 -6
- package/validation/validateDateRange.d.ts +9 -1
- package/validation/validateDateRange.js +8 -0
- package/validation/validateDateTimeRange.d.ts +6 -2
- package/validation/validateDateTimeRange.js +4 -0
- package/validation/validateTimeRange.d.ts +9 -1
- package/validation/validateTimeRange.js +8 -0
|
@@ -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 (
|
|
266
|
-
* If `false`, the format will always add leading zeroes (
|
|
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 (
|
|
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 {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
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
|
|
8
|
-
|
|
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
|
|
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'
|
|
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
|
|
30
|
-
textField?:
|
|
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 (
|
|
306
|
-
* If `false`, the format will always add leading zeroes (
|
|
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 (
|
|
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 {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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 {
|
|
9
|
-
export interface UseSingleInputDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue,
|
|
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
|
|
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'
|
|
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
|
|
31
|
-
textField?:
|
|
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 (
|
|
278
|
-
* If `false`, the format will always add leading zeroes (
|
|
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 (
|
|
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 {
|
|
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 {
|
|
9
|
-
export interface UseSingleInputTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends UseTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure>, ExportedUseClearableFieldProps, Pick<UseFieldInternalProps<PickerRangeValue,
|
|
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
|
|
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'
|
|
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
|
|
31
|
-
textField?:
|
|
31
|
+
export interface SingleInputTimeRangeFieldSlotProps extends UseClearableFieldSlotProps {
|
|
32
|
+
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
32
33
|
}
|
package/index.js
CHANGED
|
@@ -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,
|
|
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' ?
|
|
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,
|
|
@@ -60,9 +69,9 @@ export const useDesktopRangePicker = _ref => {
|
|
|
60
69
|
ownerState
|
|
61
70
|
} = usePicker(_extends({}, pickerParams, {
|
|
62
71
|
props,
|
|
63
|
-
|
|
72
|
+
variant: 'desktop',
|
|
64
73
|
autoFocusView: false,
|
|
65
|
-
fieldRef
|
|
74
|
+
fieldRef,
|
|
66
75
|
localeText,
|
|
67
76
|
additionalViewProps: {
|
|
68
77
|
rangePosition,
|
|
@@ -113,7 +122,7 @@ export const useDesktopRangePicker = _ref => {
|
|
|
113
122
|
ownerState
|
|
114
123
|
});
|
|
115
124
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
116
|
-
|
|
125
|
+
variant: 'desktop',
|
|
117
126
|
fieldType,
|
|
118
127
|
open,
|
|
119
128
|
actions,
|
|
@@ -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,
|
|
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 {
|
|
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,16 +31,16 @@ 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<
|
|
35
|
-
fieldRoot?: SlotComponentProps<typeof Stack, {},
|
|
36
|
-
fieldSeparator?: SlotComponentProps<typeof Typography, {},
|
|
37
|
-
textField?: SlotComponentProps<typeof PickersTextField, {},
|
|
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,
|
|
42
|
-
export interface UseEnrichedRangePickerFieldPropsParams<TIsSingleInput extends boolean, TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends Pick<UsePickerResponse<PickerRangeValue, TView,
|
|
43
|
-
|
|
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
|
+
variant: PickerVariant;
|
|
44
44
|
fieldType: FieldType;
|
|
45
45
|
readOnly?: boolean;
|
|
46
46
|
labelId?: string;
|
|
@@ -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<
|
|
59
|
-
endFieldRef: React.RefObject<FieldRef<
|
|
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<
|
|
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>;
|
|
@@ -8,7 +8,7 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
8
8
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
9
9
|
import { onSpaceOrEnter } from '@mui/x-date-pickers/internals';
|
|
10
10
|
const useMultiInputFieldSlotProps = ({
|
|
11
|
-
|
|
11
|
+
variant,
|
|
12
12
|
open,
|
|
13
13
|
actions,
|
|
14
14
|
readOnly,
|
|
@@ -33,7 +33,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
33
33
|
const handleEndFieldRef = useForkRef(fieldProps.unstableEndFieldRef, endFieldRef);
|
|
34
34
|
const previousRangePosition = React.useRef(rangePosition);
|
|
35
35
|
React.useEffect(() => {
|
|
36
|
-
if (!open) {
|
|
36
|
+
if (!open || variant === 'mobile') {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
const currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
|
|
@@ -49,7 +49,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
49
49
|
// use the current view or `0` when the range position has just been swapped
|
|
50
50
|
previousRangePosition.current === rangePosition ? currentView : 0);
|
|
51
51
|
previousRangePosition.current = rangePosition;
|
|
52
|
-
}, [rangePosition, open, currentView, startFieldRef, endFieldRef]);
|
|
52
|
+
}, [rangePosition, open, currentView, startFieldRef, endFieldRef, variant]);
|
|
53
53
|
const openRangeStartSelection = event => {
|
|
54
54
|
event.stopPropagation();
|
|
55
55
|
onRangePositionChange('start');
|
|
@@ -98,7 +98,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
98
98
|
focused: open ? rangePosition === 'start' : undefined
|
|
99
99
|
}, !readOnly && !fieldProps.disabled && {
|
|
100
100
|
onClick: openRangeStartSelection
|
|
101
|
-
},
|
|
101
|
+
}, variant === 'mobile' && {
|
|
102
102
|
readOnly: true
|
|
103
103
|
});
|
|
104
104
|
if (anchorRef) {
|
|
@@ -114,7 +114,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
114
114
|
focused: open ? rangePosition === 'end' : undefined
|
|
115
115
|
}, !readOnly && !fieldProps.disabled && {
|
|
116
116
|
onClick: openRangeEndSelection
|
|
117
|
-
},
|
|
117
|
+
}, variant === 'mobile' && {
|
|
118
118
|
readOnly: true
|
|
119
119
|
});
|
|
120
120
|
InputProps = resolvedComponentProps?.InputProps;
|
|
@@ -146,7 +146,7 @@ const useMultiInputFieldSlotProps = ({
|
|
|
146
146
|
return enrichedFieldProps;
|
|
147
147
|
};
|
|
148
148
|
const useSingleInputFieldSlotProps = ({
|
|
149
|
-
|
|
149
|
+
variant,
|
|
150
150
|
open,
|
|
151
151
|
actions,
|
|
152
152
|
readOnly,
|
|
@@ -156,36 +156,35 @@ const useSingleInputFieldSlotProps = ({
|
|
|
156
156
|
onBlur,
|
|
157
157
|
rangePosition,
|
|
158
158
|
onRangePositionChange,
|
|
159
|
-
|
|
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,
|
|
166
|
+
const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
|
|
168
167
|
React.useEffect(() => {
|
|
169
|
-
if (!open || !
|
|
168
|
+
if (!open || !singleInputFieldRef.current || variant === 'mobile') {
|
|
170
169
|
return;
|
|
171
170
|
}
|
|
172
|
-
if (
|
|
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 =
|
|
177
|
+
const sections = singleInputFieldRef.current.getSections().map(section => section.type);
|
|
179
178
|
const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
|
|
180
|
-
|
|
179
|
+
singleInputFieldRef.current?.focusField(newSelectedSection);
|
|
181
180
|
}
|
|
182
|
-
}, [rangePosition, open, currentView,
|
|
181
|
+
}, [rangePosition, open, currentView, singleInputFieldRef, variant]);
|
|
183
182
|
const updateRangePosition = () => {
|
|
184
|
-
if (!
|
|
183
|
+
if (!singleInputFieldRef.current?.isFieldFocused()) {
|
|
185
184
|
return;
|
|
186
185
|
}
|
|
187
|
-
const sections =
|
|
188
|
-
const activeSectionIndex =
|
|
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);
|
|
@@ -225,7 +224,7 @@ const useSingleInputFieldSlotProps = ({
|
|
|
225
224
|
focused: open ? true : undefined
|
|
226
225
|
}, labelId != null && {
|
|
227
226
|
id: labelId
|
|
228
|
-
},
|
|
227
|
+
}, variant === 'mobile' && {
|
|
229
228
|
readOnly: true
|
|
230
229
|
}, !readOnly && !fieldProps.disabled && {
|
|
231
230
|
onClick: openPicker
|
|
@@ -40,13 +40,22 @@ export const useMobileRangePicker = _ref => {
|
|
|
40
40
|
} = props;
|
|
41
41
|
const startFieldRef = React.useRef(null);
|
|
42
42
|
const endFieldRef = React.useRef(null);
|
|
43
|
+
const singleInputFieldRef = React.useRef(null);
|
|
43
44
|
const fieldType = slots.field.fieldType ?? 'multi-input';
|
|
44
45
|
const {
|
|
45
46
|
rangePosition,
|
|
46
47
|
onRangePositionChange
|
|
47
|
-
} = useRangePosition(props, fieldType === 'single-input' ?
|
|
48
|
+
} = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
|
|
48
49
|
const labelId = useId();
|
|
49
50
|
const contextTranslations = usePickerTranslations();
|
|
51
|
+
let fieldRef;
|
|
52
|
+
if (fieldType === 'single-input') {
|
|
53
|
+
fieldRef = singleInputFieldRef;
|
|
54
|
+
} else if (rangePosition === 'start') {
|
|
55
|
+
fieldRef = startFieldRef;
|
|
56
|
+
} else {
|
|
57
|
+
fieldRef = endFieldRef;
|
|
58
|
+
}
|
|
50
59
|
const {
|
|
51
60
|
open,
|
|
52
61
|
actions,
|
|
@@ -57,9 +66,9 @@ export const useMobileRangePicker = _ref => {
|
|
|
57
66
|
ownerState
|
|
58
67
|
} = usePicker(_extends({}, pickerParams, {
|
|
59
68
|
props,
|
|
60
|
-
|
|
69
|
+
variant: 'mobile',
|
|
61
70
|
autoFocusView: true,
|
|
62
|
-
fieldRef
|
|
71
|
+
fieldRef,
|
|
63
72
|
localeText,
|
|
64
73
|
additionalViewProps: {
|
|
65
74
|
rangePosition,
|
|
@@ -95,7 +104,7 @@ export const useMobileRangePicker = _ref => {
|
|
|
95
104
|
});
|
|
96
105
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
97
106
|
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
98
|
-
|
|
107
|
+
variant: 'mobile',
|
|
99
108
|
fieldType,
|
|
100
109
|
open,
|
|
101
110
|
actions,
|
|
@@ -110,7 +119,8 @@ export const useMobileRangePicker = _ref => {
|
|
|
110
119
|
pickerSlotProps: innerSlotProps,
|
|
111
120
|
fieldProps,
|
|
112
121
|
startFieldRef,
|
|
113
|
-
endFieldRef
|
|
122
|
+
endFieldRef,
|
|
123
|
+
singleInputFieldRef
|
|
114
124
|
});
|
|
115
125
|
const slotPropsForLayout = _extends({}, innerSlotProps, {
|
|
116
126
|
tabs: _extends({}, innerSlotProps?.tabs, {
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { PickerRangeValue, PickerValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { FieldRef, FieldSelectedSections } from '@mui/x-date-pickers/models';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
4
|
+
interface UseMultiInputFieldSelectedSectionsParams extends Pick<UseFieldInternalProps<PickerRangeValue, any, any>, 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
5
|
+
unstableStartFieldRef?: React.Ref<FieldRef<PickerValue>>;
|
|
6
|
+
unstableEndFieldRef?: React.Ref<FieldRef<PickerValue>>;
|
|
8
7
|
}
|
|
9
8
|
export declare const useMultiInputFieldSelectedSections: (params: UseMultiInputFieldSelectedSectionsParams) => {
|
|
10
9
|
start: {
|
|
11
|
-
unstableFieldRef: React.Ref<FieldRef<
|
|
10
|
+
unstableFieldRef: React.Ref<FieldRef<PickerValue>> | undefined;
|
|
12
11
|
selectedSections: FieldSelectedSections;
|
|
13
12
|
onSelectedSectionsChange: (newSelectedSections: FieldSelectedSections) => void;
|
|
14
13
|
};
|
|
15
14
|
end: {
|
|
16
|
-
unstableFieldRef: ((instance: FieldRef<
|
|
15
|
+
unstableFieldRef: ((instance: FieldRef<PickerValue> | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null;
|
|
17
16
|
selectedSections: FieldSelectedSections;
|
|
18
17
|
onSelectedSectionsChange: (newSelectedSections: FieldSelectedSections) => void;
|
|
19
18
|
};
|
|
@@ -18,6 +18,7 @@ export const useMultiInputDateRangeField = ({
|
|
|
18
18
|
const {
|
|
19
19
|
value: valueProp,
|
|
20
20
|
defaultValue,
|
|
21
|
+
referenceDate,
|
|
21
22
|
format,
|
|
22
23
|
formatDensity,
|
|
23
24
|
shouldRespectLeadingZeros,
|
|
@@ -39,6 +40,7 @@ export const useMultiInputDateRangeField = ({
|
|
|
39
40
|
timezone: timezoneProp,
|
|
40
41
|
value: valueProp,
|
|
41
42
|
defaultValue,
|
|
43
|
+
referenceDate,
|
|
42
44
|
onChange,
|
|
43
45
|
valueManager: rangeValueManager
|
|
44
46
|
});
|
|
@@ -18,6 +18,7 @@ export const useMultiInputDateTimeRangeField = ({
|
|
|
18
18
|
const {
|
|
19
19
|
value: valueProp,
|
|
20
20
|
defaultValue,
|
|
21
|
+
referenceDate,
|
|
21
22
|
format,
|
|
22
23
|
formatDensity,
|
|
23
24
|
shouldRespectLeadingZeros,
|
|
@@ -39,6 +40,7 @@ export const useMultiInputDateTimeRangeField = ({
|
|
|
39
40
|
timezone: timezoneProp,
|
|
40
41
|
value: valueProp,
|
|
41
42
|
defaultValue,
|
|
43
|
+
referenceDate,
|
|
42
44
|
onChange,
|
|
43
45
|
valueManager: rangeValueManager
|
|
44
46
|
});
|
|
@@ -18,6 +18,7 @@ export const useMultiInputTimeRangeField = ({
|
|
|
18
18
|
const {
|
|
19
19
|
value: valueProp,
|
|
20
20
|
defaultValue,
|
|
21
|
+
referenceDate,
|
|
21
22
|
format,
|
|
22
23
|
formatDensity,
|
|
23
24
|
shouldRespectLeadingZeros,
|
|
@@ -40,7 +41,8 @@ export const useMultiInputTimeRangeField = ({
|
|
|
40
41
|
value: valueProp,
|
|
41
42
|
defaultValue,
|
|
42
43
|
onChange,
|
|
43
|
-
valueManager: rangeValueManager
|
|
44
|
+
valueManager: rangeValueManager,
|
|
45
|
+
referenceDate
|
|
44
46
|
});
|
|
45
47
|
const {
|
|
46
48
|
validationError,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FieldRef } from '@mui/x-date-pickers/models';
|
|
3
|
-
import {
|
|
3
|
+
import { PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
4
|
+
import { RangePosition } from '../../models';
|
|
4
5
|
export interface UseRangePositionProps {
|
|
5
6
|
/**
|
|
6
7
|
* The position in the currently edited date range.
|
|
@@ -23,4 +24,4 @@ export interface UseRangePositionResponse {
|
|
|
23
24
|
rangePosition: RangePosition;
|
|
24
25
|
onRangePositionChange: (newPosition: RangePosition) => void;
|
|
25
26
|
}
|
|
26
|
-
export declare const useRangePosition: (props: UseRangePositionProps, singleInputFieldRef?: React.RefObject<FieldRef<
|
|
27
|
+
export declare const useRangePosition: (props: UseRangePositionProps, singleInputFieldRef?: React.RefObject<FieldRef<PickerRangeValue>>) => UseRangePositionResponse;
|
|
@@ -52,7 +52,7 @@ export const useStaticRangePicker = _ref => {
|
|
|
52
52
|
rangePosition,
|
|
53
53
|
onRangePositionChange
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
variant: displayStaticWrapperAs
|
|
56
56
|
}));
|
|
57
57
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
58
58
|
const slotPropsForLayout = _extends({}, slotProps, {
|