@mui/x-date-pickers-pro 8.0.0-beta.0 → 8.0.0-beta.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 +171 -0
- package/DateRangeCalendar/DateRangeCalendar.js +2 -7
- package/DateRangeCalendar/DateRangeCalendar.types.d.ts +1 -1
- package/DateRangePicker/DateRangePicker.js +3 -1
- package/DateRangePicker/shared.js +2 -7
- package/DateRangePickerDay/DateRangePickerDay.d.ts +1 -41
- package/DateRangePickerDay/DateRangePickerDay.js +89 -57
- package/DateRangePickerDay/DateRangePickerDay.types.d.ts +91 -0
- package/DateRangePickerDay/DateRangePickerDay.types.js +5 -0
- package/DateRangePickerDay/index.d.ts +1 -1
- package/DateTimeRangePicker/DateTimeRangePicker.js +3 -1
- package/DateTimeRangePicker/shared.js +2 -11
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +1 -0
- package/DesktopTimeRangePicker/DesktopTimeRangePicker.js +1 -0
- package/MobileDateRangePicker/MobileDateRangePicker.js +1 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +1 -0
- package/MobileTimeRangePicker/MobileTimeRangePicker.js +1 -0
- package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +2 -16
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +2 -16
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +2 -16
- package/TimeRangePicker/TimeRangePicker.js +3 -1
- package/TimeRangePicker/shared.js +2 -3
- package/esm/DateRangeCalendar/DateRangeCalendar.js +3 -8
- package/esm/DateRangeCalendar/DateRangeCalendar.types.d.ts +1 -1
- package/esm/DateRangePicker/DateRangePicker.js +3 -1
- package/esm/DateRangePicker/shared.js +3 -8
- package/esm/DateRangePickerDay/DateRangePickerDay.d.ts +1 -41
- package/esm/DateRangePickerDay/DateRangePickerDay.js +90 -58
- package/esm/DateRangePickerDay/DateRangePickerDay.types.d.ts +91 -0
- package/esm/DateRangePickerDay/DateRangePickerDay.types.js +1 -0
- package/esm/DateRangePickerDay/index.d.ts +1 -1
- package/esm/DateTimeRangePicker/DateTimeRangePicker.js +3 -1
- package/esm/DateTimeRangePicker/shared.js +3 -12
- package/esm/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -0
- package/esm/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +1 -0
- package/esm/DesktopTimeRangePicker/DesktopTimeRangePicker.js +1 -0
- package/esm/MobileDateRangePicker/MobileDateRangePicker.js +1 -0
- package/esm/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +1 -0
- package/esm/MobileTimeRangePicker/MobileTimeRangePicker.js +1 -0
- package/esm/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
- package/esm/SingleInputDateRangeField/useSingleInputDateRangeField.js +3 -17
- package/esm/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
- package/esm/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +3 -17
- package/esm/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
- package/esm/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +3 -17
- package/esm/TimeRangePicker/TimeRangePicker.js +3 -1
- package/esm/TimeRangePicker/shared.js +3 -4
- package/esm/hooks/useMultiInputRangeField/useMultiInputRangeField.d.ts +2 -2
- package/esm/hooks/useMultiInputRangeField/useTextFieldProps.js +4 -16
- package/esm/index.js +1 -1
- package/esm/internals/utils/releaseInfo.js +1 -1
- package/esm/managers/useDateRangeManager.js +12 -13
- package/esm/managers/useDateTimeRangeManager.js +13 -13
- package/esm/managers/useTimeRangeManager.js +13 -11
- package/hooks/useMultiInputRangeField/useMultiInputRangeField.d.ts +2 -2
- package/hooks/useMultiInputRangeField/useTextFieldProps.js +3 -15
- package/index.js +1 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/managers/useDateRangeManager.js +11 -12
- package/managers/useDateTimeRangeManager.js +12 -12
- package/managers/useTimeRangeManager.js +12 -10
- package/modern/DateRangeCalendar/DateRangeCalendar.js +3 -8
- package/modern/DateRangeCalendar/DateRangeCalendar.types.d.ts +1 -1
- package/modern/DateRangePicker/DateRangePicker.js +3 -1
- package/modern/DateRangePicker/shared.js +3 -8
- package/modern/DateRangePickerDay/DateRangePickerDay.d.ts +1 -41
- package/modern/DateRangePickerDay/DateRangePickerDay.js +90 -58
- package/modern/DateRangePickerDay/DateRangePickerDay.types.d.ts +91 -0
- package/modern/DateRangePickerDay/DateRangePickerDay.types.js +1 -0
- package/modern/DateRangePickerDay/index.d.ts +1 -1
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +3 -1
- package/modern/DateTimeRangePicker/shared.js +3 -12
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -0
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +1 -0
- package/modern/DesktopTimeRangePicker/DesktopTimeRangePicker.js +1 -0
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -0
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +1 -0
- package/modern/MobileTimeRangePicker/MobileTimeRangePicker.js +1 -0
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -1
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +3 -17
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -1
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +3 -17
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -1
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +3 -17
- package/modern/TimeRangePicker/TimeRangePicker.js +3 -1
- package/modern/TimeRangePicker/shared.js +3 -4
- package/modern/hooks/useMultiInputRangeField/useMultiInputRangeField.d.ts +2 -2
- package/modern/hooks/useMultiInputRangeField/useTextFieldProps.js +4 -16
- package/modern/index.js +1 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/managers/useDateRangeManager.js +12 -13
- package/modern/managers/useDateTimeRangeManager.js +13 -13
- package/modern/managers/useTimeRangeManager.js +13 -11
- package/package.json +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerFieldInternalProps,
|
|
1
|
+
import { PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerFieldInternalProps, UseFieldReturnValue } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { UseTextFieldBaseForwardedProps } from "./useTextFieldProps.js";
|
|
3
3
|
import { PickerAnyRangeManager } from "../../internals/models/managers.js";
|
|
4
4
|
import { UseMultiInputRangeFieldRootPropsReturnValue } from "./useMultiInputRangeFieldRootProps.js";
|
|
@@ -63,7 +63,7 @@ interface UseMultiInputRangeFieldReturnValue<TManager extends PickerAnyRangeMana
|
|
|
63
63
|
endTextField: UseMultiInputRangeFieldTextFieldProps<PickerManagerEnableAccessibleFieldDOMStructure<TManager>, TTextFieldProps>;
|
|
64
64
|
enableAccessibleFieldDOMStructure: PickerManagerEnableAccessibleFieldDOMStructure<TManager>;
|
|
65
65
|
}
|
|
66
|
-
export type UseMultiInputRangeFieldTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseTextFieldBaseForwardedProps> = Omit<
|
|
66
|
+
export type UseMultiInputRangeFieldTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseTextFieldBaseForwardedProps> = Omit<UseFieldReturnValue<TEnableAccessibleFieldDOMStructure, TForwardedProps & {
|
|
67
67
|
onKeyDown: React.KeyboardEventHandler;
|
|
68
68
|
onClick: React.MouseEventHandler;
|
|
69
69
|
onFocus: React.FocusEventHandler;
|
|
@@ -4,8 +4,7 @@ const _excluded = ["clearable", "onClear", "openPickerAriaLabel"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import { useDateManager, useDateTimeManager, useTimeManager } from '@mui/x-date-pickers/managers';
|
|
7
|
-
import {
|
|
8
|
-
import { useField, useFieldInternalPropsWithDefaults, useNullableFieldPrivateContext, useNullablePickerContext, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
|
|
7
|
+
import { useField, useNullableFieldPrivateContext, useNullablePickerContext, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
|
|
9
8
|
import { useNullablePickerRangePositionContext } from "../../internals/hooks/useNullablePickerRangePositionContext.js";
|
|
10
9
|
/**
|
|
11
10
|
* @ignore - internal hook.
|
|
@@ -102,21 +101,10 @@ export function useTextFieldProps(parameters) {
|
|
|
102
101
|
onKeyDown: handleKeyDown,
|
|
103
102
|
onChange: handleChange
|
|
104
103
|
});
|
|
105
|
-
const splittedProps = useSplitFieldProps(allProps, valueType);
|
|
106
|
-
const internalPropsWithDefaults = useFieldInternalPropsWithDefaults({
|
|
107
|
-
manager,
|
|
108
|
-
internalProps: splittedProps.internalProps,
|
|
109
|
-
skipContextFieldRefAssignment: rangePosition !== position
|
|
110
|
-
});
|
|
111
104
|
const _ref = useField({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
fieldValueManager: manager.internal_fieldValueManager,
|
|
116
|
-
validator: manager.validator,
|
|
117
|
-
valueType: manager.valueType,
|
|
118
|
-
// TODO v8: Add a real aria label before moving the opening logic to the field on range pickers.
|
|
119
|
-
getOpenPickerButtonAriaLabel: () => ''
|
|
105
|
+
manager,
|
|
106
|
+
props: allProps,
|
|
107
|
+
skipContextFieldRefAssignment: rangePosition !== position
|
|
120
108
|
}),
|
|
121
109
|
fieldResponse = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
122
110
|
React.useEffect(() => {
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTc0MzExMjgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { useApplyDefaultValuesToDateValidationProps, useUtils } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import { getRangeFieldValueManager, rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
8
8
|
import { validateDateRange } from "../validation/index.js";
|
|
9
9
|
import { formatRange } from "../internals/utils/date-utils.js";
|
|
@@ -20,22 +20,21 @@ export function useDateRangeManager(parameters = {}) {
|
|
|
20
20
|
dateSeparator
|
|
21
21
|
}),
|
|
22
22
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
23
|
-
|
|
24
|
-
internalProps,
|
|
25
|
-
utils,
|
|
26
|
-
defaultDates
|
|
27
|
-
}) => _extends({}, internalProps, getDateFieldInternalPropsDefaults({
|
|
28
|
-
defaultDates,
|
|
29
|
-
utils,
|
|
30
|
-
internalProps
|
|
31
|
-
})),
|
|
23
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateRangeFieldInternalProps,
|
|
32
24
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
33
25
|
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
34
26
|
}
|
|
35
|
-
function useOpenPickerButtonAriaLabel() {
|
|
27
|
+
function useOpenPickerButtonAriaLabel(value) {
|
|
36
28
|
const utils = useUtils();
|
|
37
29
|
const translations = usePickerTranslations();
|
|
38
|
-
return React.
|
|
30
|
+
return React.useMemo(() => {
|
|
39
31
|
return translations.openRangePickerDialogue(formatRange(utils, value, 'fullDate'));
|
|
40
|
-
}, [translations, utils]);
|
|
32
|
+
}, [value, translations, utils]);
|
|
33
|
+
}
|
|
34
|
+
function useApplyDefaultValuesToDateRangeFieldInternalProps(internalProps) {
|
|
35
|
+
const utils = useUtils();
|
|
36
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(internalProps);
|
|
37
|
+
return React.useMemo(() => _extends({}, internalProps, validationProps, {
|
|
38
|
+
format: internalProps.format ?? utils.formats.keyboardDate
|
|
39
|
+
}), [internalProps, validationProps, utils]);
|
|
41
40
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { useApplyDefaultValuesToDateTimeValidationProps, useUtils } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import { getRangeFieldValueManager, rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
8
8
|
import { validateDateTimeRange } from "../validation/index.js";
|
|
9
9
|
import { formatRange } from "../internals/utils/date-utils.js";
|
|
@@ -20,22 +20,22 @@ export function useDateTimeRangeManager(parameters = {}) {
|
|
|
20
20
|
dateSeparator
|
|
21
21
|
}),
|
|
22
22
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
23
|
-
|
|
24
|
-
internalProps,
|
|
25
|
-
utils,
|
|
26
|
-
defaultDates
|
|
27
|
-
}) => _extends({}, internalProps, getDateTimeFieldInternalPropsDefaults({
|
|
28
|
-
internalProps,
|
|
29
|
-
utils,
|
|
30
|
-
defaultDates
|
|
31
|
-
})),
|
|
23
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateTimeRangeFieldInternalProps,
|
|
32
24
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
33
25
|
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
34
26
|
}
|
|
35
|
-
function useOpenPickerButtonAriaLabel() {
|
|
27
|
+
function useOpenPickerButtonAriaLabel(value) {
|
|
36
28
|
const utils = useUtils();
|
|
37
29
|
const translations = usePickerTranslations();
|
|
38
|
-
return React.
|
|
30
|
+
return React.useMemo(() => {
|
|
39
31
|
return translations.openRangePickerDialogue(formatRange(utils, value, 'fullDate'));
|
|
40
|
-
}, [translations, utils]);
|
|
32
|
+
}, [value, translations, utils]);
|
|
33
|
+
}
|
|
34
|
+
function useApplyDefaultValuesToDateTimeRangeFieldInternalProps(internalProps) {
|
|
35
|
+
const utils = useUtils();
|
|
36
|
+
const validationProps = useApplyDefaultValuesToDateTimeValidationProps(internalProps);
|
|
37
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
38
|
+
return React.useMemo(() => _extends({}, internalProps, validationProps, {
|
|
39
|
+
format: internalProps.format ?? (ampm ? utils.formats.keyboardDateTime12h : utils.formats.keyboardDateTime24h)
|
|
40
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
41
41
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { useApplyDefaultValuesToTimeValidationProps, useUtils } from '@mui/x-date-pickers/internals';
|
|
7
7
|
import { getRangeFieldValueManager, rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
8
8
|
import { validateTimeRange } from "../validation/index.js";
|
|
9
9
|
import { formatRange } from "../internals/utils/date-utils.js";
|
|
@@ -21,23 +21,25 @@ export function useTimeRangeManager(parameters = {}) {
|
|
|
21
21
|
dateSeparator
|
|
22
22
|
}),
|
|
23
23
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
24
|
-
|
|
25
|
-
internalProps,
|
|
26
|
-
utils
|
|
27
|
-
}) => _extends({}, internalProps, getTimeFieldInternalPropsDefaults({
|
|
28
|
-
utils,
|
|
29
|
-
internalProps
|
|
30
|
-
})),
|
|
24
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToTimeRangeFieldInternalProps,
|
|
31
25
|
internal_useOpenPickerButtonAriaLabel: createUseOpenPickerButtonAriaLabel(ampm)
|
|
32
26
|
}), [enableAccessibleFieldDOMStructure, dateSeparator, ampm]);
|
|
33
27
|
}
|
|
34
28
|
function createUseOpenPickerButtonAriaLabel(ampm) {
|
|
35
|
-
return function useOpenPickerButtonAriaLabel() {
|
|
29
|
+
return function useOpenPickerButtonAriaLabel(value) {
|
|
36
30
|
const utils = useUtils();
|
|
37
31
|
const translations = usePickerTranslations();
|
|
38
|
-
return React.
|
|
32
|
+
return React.useMemo(() => {
|
|
39
33
|
const formatKey = ampm ?? utils.is12HourCycleInCurrentLocale() ? 'fullTime12h' : 'fullTime24h';
|
|
40
34
|
return translations.openRangePickerDialogue(formatRange(utils, value, formatKey));
|
|
41
|
-
}, [translations, utils]);
|
|
35
|
+
}, [value, translations, utils]);
|
|
42
36
|
};
|
|
37
|
+
}
|
|
38
|
+
function useApplyDefaultValuesToTimeRangeFieldInternalProps(internalProps) {
|
|
39
|
+
const utils = useUtils();
|
|
40
|
+
const validationProps = useApplyDefaultValuesToTimeValidationProps(internalProps);
|
|
41
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
42
|
+
return React.useMemo(() => _extends({}, internalProps, validationProps, {
|
|
43
|
+
format: internalProps.format ?? (ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h)
|
|
44
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
43
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerFieldInternalProps,
|
|
1
|
+
import { PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerFieldInternalProps, UseFieldReturnValue } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { UseTextFieldBaseForwardedProps } from "./useTextFieldProps.js";
|
|
3
3
|
import { PickerAnyRangeManager } from "../../internals/models/managers.js";
|
|
4
4
|
import { UseMultiInputRangeFieldRootPropsReturnValue } from "./useMultiInputRangeFieldRootProps.js";
|
|
@@ -63,7 +63,7 @@ interface UseMultiInputRangeFieldReturnValue<TManager extends PickerAnyRangeMana
|
|
|
63
63
|
endTextField: UseMultiInputRangeFieldTextFieldProps<PickerManagerEnableAccessibleFieldDOMStructure<TManager>, TTextFieldProps>;
|
|
64
64
|
enableAccessibleFieldDOMStructure: PickerManagerEnableAccessibleFieldDOMStructure<TManager>;
|
|
65
65
|
}
|
|
66
|
-
export type UseMultiInputRangeFieldTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseTextFieldBaseForwardedProps> = Omit<
|
|
66
|
+
export type UseMultiInputRangeFieldTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseTextFieldBaseForwardedProps> = Omit<UseFieldReturnValue<TEnableAccessibleFieldDOMStructure, TForwardedProps & {
|
|
67
67
|
onKeyDown: React.KeyboardEventHandler;
|
|
68
68
|
onClick: React.MouseEventHandler;
|
|
69
69
|
onFocus: React.FocusEventHandler;
|
|
@@ -11,7 +11,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _managers = require("@mui/x-date-pickers/managers");
|
|
14
|
-
var _hooks = require("@mui/x-date-pickers/hooks");
|
|
15
14
|
var _internals = require("@mui/x-date-pickers/internals");
|
|
16
15
|
var _useNullablePickerRangePositionContext = require("../../internals/hooks/useNullablePickerRangePositionContext");
|
|
17
16
|
const _excluded = ["clearable", "onClear", "openPickerAriaLabel"];
|
|
@@ -110,21 +109,10 @@ function useTextFieldProps(parameters) {
|
|
|
110
109
|
onKeyDown: handleKeyDown,
|
|
111
110
|
onChange: handleChange
|
|
112
111
|
});
|
|
113
|
-
const splittedProps = (0, _hooks.useSplitFieldProps)(allProps, valueType);
|
|
114
|
-
const internalPropsWithDefaults = (0, _internals.useFieldInternalPropsWithDefaults)({
|
|
115
|
-
manager,
|
|
116
|
-
internalProps: splittedProps.internalProps,
|
|
117
|
-
skipContextFieldRefAssignment: rangePosition !== position
|
|
118
|
-
});
|
|
119
112
|
const _ref = (0, _internals.useField)({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
fieldValueManager: manager.internal_fieldValueManager,
|
|
124
|
-
validator: manager.validator,
|
|
125
|
-
valueType: manager.valueType,
|
|
126
|
-
// TODO v8: Add a real aria label before moving the opening logic to the field on range pickers.
|
|
127
|
-
getOpenPickerButtonAriaLabel: () => ''
|
|
113
|
+
manager,
|
|
114
|
+
props: allProps,
|
|
115
|
+
skipContextFieldRefAssignment: rangePosition !== position
|
|
128
116
|
}),
|
|
129
117
|
fieldResponse = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
130
118
|
React.useEffect(() => {
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTc0MzExMjgwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -27,22 +27,21 @@ function useDateRangeManager(parameters = {}) {
|
|
|
27
27
|
dateSeparator
|
|
28
28
|
}),
|
|
29
29
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
30
|
-
|
|
31
|
-
internalProps,
|
|
32
|
-
utils,
|
|
33
|
-
defaultDates
|
|
34
|
-
}) => (0, _extends2.default)({}, internalProps, (0, _internals.getDateFieldInternalPropsDefaults)({
|
|
35
|
-
defaultDates,
|
|
36
|
-
utils,
|
|
37
|
-
internalProps
|
|
38
|
-
})),
|
|
30
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateRangeFieldInternalProps,
|
|
39
31
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
40
32
|
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
41
33
|
}
|
|
42
|
-
function useOpenPickerButtonAriaLabel() {
|
|
34
|
+
function useOpenPickerButtonAriaLabel(value) {
|
|
43
35
|
const utils = (0, _internals.useUtils)();
|
|
44
36
|
const translations = (0, _hooks.usePickerTranslations)();
|
|
45
|
-
return React.
|
|
37
|
+
return React.useMemo(() => {
|
|
46
38
|
return translations.openRangePickerDialogue((0, _dateUtils.formatRange)(utils, value, 'fullDate'));
|
|
47
|
-
}, [translations, utils]);
|
|
39
|
+
}, [value, translations, utils]);
|
|
40
|
+
}
|
|
41
|
+
function useApplyDefaultValuesToDateRangeFieldInternalProps(internalProps) {
|
|
42
|
+
const utils = (0, _internals.useUtils)();
|
|
43
|
+
const validationProps = (0, _internals.useApplyDefaultValuesToDateValidationProps)(internalProps);
|
|
44
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
45
|
+
format: internalProps.format ?? utils.formats.keyboardDate
|
|
46
|
+
}), [internalProps, validationProps, utils]);
|
|
48
47
|
}
|
|
@@ -27,22 +27,22 @@ function useDateTimeRangeManager(parameters = {}) {
|
|
|
27
27
|
dateSeparator
|
|
28
28
|
}),
|
|
29
29
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
30
|
-
|
|
31
|
-
internalProps,
|
|
32
|
-
utils,
|
|
33
|
-
defaultDates
|
|
34
|
-
}) => (0, _extends2.default)({}, internalProps, (0, _internals.getDateTimeFieldInternalPropsDefaults)({
|
|
35
|
-
internalProps,
|
|
36
|
-
utils,
|
|
37
|
-
defaultDates
|
|
38
|
-
})),
|
|
30
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateTimeRangeFieldInternalProps,
|
|
39
31
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
40
32
|
}), [enableAccessibleFieldDOMStructure, dateSeparator]);
|
|
41
33
|
}
|
|
42
|
-
function useOpenPickerButtonAriaLabel() {
|
|
34
|
+
function useOpenPickerButtonAriaLabel(value) {
|
|
43
35
|
const utils = (0, _internals.useUtils)();
|
|
44
36
|
const translations = (0, _hooks.usePickerTranslations)();
|
|
45
|
-
return React.
|
|
37
|
+
return React.useMemo(() => {
|
|
46
38
|
return translations.openRangePickerDialogue((0, _dateUtils.formatRange)(utils, value, 'fullDate'));
|
|
47
|
-
}, [translations, utils]);
|
|
39
|
+
}, [value, translations, utils]);
|
|
40
|
+
}
|
|
41
|
+
function useApplyDefaultValuesToDateTimeRangeFieldInternalProps(internalProps) {
|
|
42
|
+
const utils = (0, _internals.useUtils)();
|
|
43
|
+
const validationProps = (0, _internals.useApplyDefaultValuesToDateTimeValidationProps)(internalProps);
|
|
44
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
45
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
46
|
+
format: internalProps.format ?? (ampm ? utils.formats.keyboardDateTime12h : utils.formats.keyboardDateTime24h)
|
|
47
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
48
48
|
}
|
|
@@ -28,23 +28,25 @@ function useTimeRangeManager(parameters = {}) {
|
|
|
28
28
|
dateSeparator
|
|
29
29
|
}),
|
|
30
30
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
31
|
-
|
|
32
|
-
internalProps,
|
|
33
|
-
utils
|
|
34
|
-
}) => (0, _extends2.default)({}, internalProps, (0, _internals.getTimeFieldInternalPropsDefaults)({
|
|
35
|
-
utils,
|
|
36
|
-
internalProps
|
|
37
|
-
})),
|
|
31
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToTimeRangeFieldInternalProps,
|
|
38
32
|
internal_useOpenPickerButtonAriaLabel: createUseOpenPickerButtonAriaLabel(ampm)
|
|
39
33
|
}), [enableAccessibleFieldDOMStructure, dateSeparator, ampm]);
|
|
40
34
|
}
|
|
41
35
|
function createUseOpenPickerButtonAriaLabel(ampm) {
|
|
42
|
-
return function useOpenPickerButtonAriaLabel() {
|
|
36
|
+
return function useOpenPickerButtonAriaLabel(value) {
|
|
43
37
|
const utils = (0, _internals.useUtils)();
|
|
44
38
|
const translations = (0, _hooks.usePickerTranslations)();
|
|
45
|
-
return React.
|
|
39
|
+
return React.useMemo(() => {
|
|
46
40
|
const formatKey = ampm ?? utils.is12HourCycleInCurrentLocale() ? 'fullTime12h' : 'fullTime24h';
|
|
47
41
|
return translations.openRangePickerDialogue((0, _dateUtils.formatRange)(utils, value, formatKey));
|
|
48
|
-
}, [translations, utils]);
|
|
42
|
+
}, [value, translations, utils]);
|
|
49
43
|
};
|
|
44
|
+
}
|
|
45
|
+
function useApplyDefaultValuesToTimeRangeFieldInternalProps(internalProps) {
|
|
46
|
+
const utils = (0, _internals.useUtils)();
|
|
47
|
+
const validationProps = (0, _internals.useApplyDefaultValuesToTimeValidationProps)(internalProps);
|
|
48
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
49
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
50
|
+
format: internalProps.format ?? (ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h)
|
|
51
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
50
52
|
}
|
|
@@ -15,7 +15,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
15
15
|
import composeClasses from '@mui/utils/composeClasses';
|
|
16
16
|
import useId from '@mui/utils/useId';
|
|
17
17
|
import { Watermark } from '@mui/x-license';
|
|
18
|
-
import {
|
|
18
|
+
import { DayCalendar, useReduceAnimations, useCalendarState, useUtils, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, useControlledValue, useViews, usePickerPrivateContext, areDatesEqual, useApplyDefaultValuesToDateValidationProps } from '@mui/x-date-pickers/internals';
|
|
19
19
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
20
20
|
import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
|
|
21
21
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from "./dateRangeCalendarClasses.js";
|
|
@@ -74,25 +74,20 @@ const InnerDayCalendarForRange = styled(DayCalendar)(({
|
|
|
74
74
|
}));
|
|
75
75
|
const DayCalendarForRange = InnerDayCalendarForRange;
|
|
76
76
|
function useDateRangeCalendarDefaultizedProps(props, name) {
|
|
77
|
-
const utils = useUtils();
|
|
78
|
-
const defaultDates = useDefaultDates();
|
|
79
77
|
const themeProps = useThemeProps({
|
|
80
78
|
props,
|
|
81
79
|
name
|
|
82
80
|
});
|
|
83
81
|
const reduceAnimations = useReduceAnimations(themeProps.reduceAnimations);
|
|
84
|
-
|
|
82
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
83
|
+
return _extends({}, themeProps, validationProps, {
|
|
85
84
|
renderLoading: themeProps.renderLoading ?? (() => /*#__PURE__*/_jsx("span", {
|
|
86
85
|
children: "..."
|
|
87
86
|
})),
|
|
88
87
|
reduceAnimations,
|
|
89
88
|
loading: props.loading ?? false,
|
|
90
|
-
disablePast: props.disablePast ?? false,
|
|
91
|
-
disableFuture: props.disableFuture ?? false,
|
|
92
89
|
openTo: themeProps.openTo ?? 'day',
|
|
93
90
|
views: themeProps.views ?? ['day'],
|
|
94
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
95
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
|
|
96
91
|
calendars: themeProps.calendars ?? 2,
|
|
97
92
|
disableDragEditing: themeProps.disableDragEditing ?? false,
|
|
98
93
|
availableRangePositions: themeProps.availableRangePositions ?? ['start', 'end']
|
|
@@ -5,7 +5,7 @@ import { Theme } from '@mui/material/styles';
|
|
|
5
5
|
import { DefaultizedProps } from '@mui/x-internals/types';
|
|
6
6
|
import { PickerOwnerState, PickerValidDate, TimezoneProps } from '@mui/x-date-pickers/models';
|
|
7
7
|
import { PickersCalendarHeader, PickersCalendarHeaderSlots, PickersCalendarHeaderSlotProps } from '@mui/x-date-pickers/PickersCalendarHeader';
|
|
8
|
-
import { PickerDayOwnerState } from '@mui/x-date-pickers/
|
|
8
|
+
import { PickerDayOwnerState } from '@mui/x-date-pickers/PickersDay';
|
|
9
9
|
import { BaseDateValidationProps, ExportedDayCalendarProps, DayCalendarSlots, DayCalendarSlotProps, PickersArrowSwitcherSlots, PickersArrowSwitcherSlotProps, ExportedUseViewsOptions, PickerRangeValue, FormProps } from '@mui/x-date-pickers/internals';
|
|
10
10
|
import { RangePosition } from "../models/index.js";
|
|
11
11
|
import { DateRangeCalendarClasses } from "./dateRangeCalendarClasses.js";
|
|
@@ -7,6 +7,7 @@ import * as React from 'react';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
9
9
|
import { useThemeProps } from '@mui/material/styles';
|
|
10
|
+
import { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from '@mui/x-date-pickers/internals';
|
|
10
11
|
import { refType } from '@mui/utils';
|
|
11
12
|
import { DesktopDateRangePicker } from "../DesktopDateRangePicker/index.js";
|
|
12
13
|
import { MobileDateRangePicker } from "../MobileDateRangePicker/index.js";
|
|
@@ -27,7 +28,7 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef(function DateRangePicker(i
|
|
|
27
28
|
name: 'MuiDateRangePicker'
|
|
28
29
|
});
|
|
29
30
|
const {
|
|
30
|
-
desktopModeMediaQuery =
|
|
31
|
+
desktopModeMediaQuery = DEFAULT_DESKTOP_MODE_MEDIA_QUERY
|
|
31
32
|
} = props,
|
|
32
33
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
33
34
|
|
|
@@ -124,6 +125,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
124
125
|
disableHighlightToday: PropTypes.bool,
|
|
125
126
|
/**
|
|
126
127
|
* If `true`, the button to open the Picker will not be rendered (it will only render the field).
|
|
128
|
+
* @deprecated Use the [field component](https://next.mui.com/x/react-date-pickers/fields/) instead.
|
|
127
129
|
* @default false
|
|
128
130
|
*/
|
|
129
131
|
disableOpenPicker: PropTypes.bool,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useThemeProps } from '@mui/material/styles';
|
|
4
|
-
import {
|
|
4
|
+
import { useApplyDefaultValuesToDateValidationProps } from '@mui/x-date-pickers/internals';
|
|
5
5
|
import { DateRangePickerToolbar } from "./DateRangePickerToolbar.js";
|
|
6
6
|
export function useDateRangePickerDefaultizedProps(props, name) {
|
|
7
|
-
const utils = useUtils();
|
|
8
|
-
const defaultDates = useDefaultDates();
|
|
9
7
|
const themeProps = useThemeProps({
|
|
10
8
|
props,
|
|
11
9
|
name
|
|
12
10
|
});
|
|
11
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
13
12
|
const localeText = React.useMemo(() => {
|
|
14
13
|
if (themeProps.localeText?.toolbarTitle == null) {
|
|
15
14
|
return themeProps.localeText;
|
|
@@ -18,12 +17,8 @@ export function useDateRangePickerDefaultizedProps(props, name) {
|
|
|
18
17
|
dateRangePickerToolbarTitle: themeProps.localeText.toolbarTitle
|
|
19
18
|
});
|
|
20
19
|
}, [themeProps.localeText]);
|
|
21
|
-
return _extends({}, themeProps, {
|
|
20
|
+
return _extends({}, themeProps, validationProps, {
|
|
22
21
|
localeText,
|
|
23
|
-
disableFuture: themeProps.disableFuture ?? false,
|
|
24
|
-
disablePast: themeProps.disablePast ?? false,
|
|
25
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
26
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
|
|
27
22
|
slots: _extends({
|
|
28
23
|
toolbar: DateRangePickerToolbar
|
|
29
24
|
}, themeProps.slots)
|
|
@@ -1,45 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { DateRangePickerDayClasses } from "./dateRangePickerDayClasses.js";
|
|
4
|
-
export interface DateRangePickerDayProps extends Omit<PickersDayProps, 'classes' | 'onBlur' | 'onFocus' | 'onKeyDown'> {
|
|
5
|
-
/**
|
|
6
|
-
* Set to `true` if the `day` is in a highlighted date range.
|
|
7
|
-
*/
|
|
8
|
-
isHighlighting: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Set to `true` if the `day` is the end of a highlighted date range.
|
|
11
|
-
*/
|
|
12
|
-
isEndOfHighlighting: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Set to `true` if the `day` is the start of a highlighted date range.
|
|
15
|
-
*/
|
|
16
|
-
isStartOfHighlighting: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Set to `true` if the `day` is in a preview date range.
|
|
19
|
-
*/
|
|
20
|
-
isPreviewing: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Set to `true` if the `day` is the end of a previewing date range.
|
|
23
|
-
*/
|
|
24
|
-
isEndOfPreviewing: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Set to `true` if the `day` is the start of a previewing date range.
|
|
27
|
-
*/
|
|
28
|
-
isStartOfPreviewing: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Override or extend the styles applied to the component.
|
|
31
|
-
*/
|
|
32
|
-
classes?: Partial<DateRangePickerDayClasses>;
|
|
33
|
-
/**
|
|
34
|
-
* Indicates if the day should be visually selected.
|
|
35
|
-
*/
|
|
36
|
-
isVisuallySelected?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* If `true`, the day can be dragged to change the current date range.
|
|
39
|
-
* @default false
|
|
40
|
-
*/
|
|
41
|
-
draggable?: boolean;
|
|
42
|
-
}
|
|
2
|
+
import { DateRangePickerDayProps } from "./DateRangePickerDay.types.js";
|
|
43
3
|
type DateRangePickerDayComponent = (props: DateRangePickerDayProps & React.RefAttributes<HTMLButtonElement>) => React.JSX.Element;
|
|
44
4
|
/**
|
|
45
5
|
* Demos:
|