@mui/x-date-pickers-pro 8.0.0-beta.1 → 8.0.0-beta.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.
- package/CHANGELOG.md +235 -0
- package/DateRangeCalendar/DateRangeCalendar.js +2 -7
- package/DateRangePicker/shared.js +2 -7
- package/DateRangePickerDay/DateRangePickerDay.js +1 -1
- package/DateTimeRangePicker/shared.js +2 -11
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +9 -1
- package/DesktopTimeRangePicker/DesktopTimeRangePicker.js +9 -1
- package/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -1
- package/MobileTimeRangePicker/MobileTimeRangePicker.js +9 -1
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
- package/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/TimeRangePicker/shared.js +2 -3
- package/esm/DateRangeCalendar/DateRangeCalendar.js +3 -8
- package/esm/DateRangePicker/shared.js +3 -8
- package/esm/DateRangePickerDay/DateRangePickerDay.js +1 -1
- package/esm/DateTimeRangePicker/shared.js +3 -12
- package/esm/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/esm/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +9 -1
- package/esm/DesktopTimeRangePicker/DesktopTimeRangePicker.js +9 -1
- package/esm/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/esm/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +16 -2
- package/esm/MobileTimeRangePicker/MobileTimeRangePicker.js +9 -1
- package/esm/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
- package/esm/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
- package/esm/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
- package/esm/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/esm/TimeRangePicker/shared.js +3 -4
- package/esm/index.js +1 -1
- package/esm/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -0
- package/esm/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +10 -3
- package/esm/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +3 -3
- package/esm/internals/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -0
- package/esm/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +10 -3
- package/esm/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +3 -3
- package/esm/internals/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -0
- package/esm/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -3
- package/esm/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +7 -0
- package/esm/internals/models/rangePickerProps.d.ts +14 -0
- package/esm/internals/utils/createRangePickerStepNavigation.d.ts +16 -0
- package/esm/internals/utils/createRangePickerStepNavigation.js +31 -0
- package/esm/internals/utils/releaseInfo.js +1 -1
- package/esm/managers/useDateRangeManager.js +9 -10
- package/esm/managers/useDateTimeRangeManager.js +10 -10
- package/esm/managers/useTimeRangeManager.js +10 -8
- package/index.js +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -0
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +10 -3
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +3 -3
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -0
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +10 -3
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +3 -3
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -0
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -3
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +7 -0
- package/internals/models/rangePickerProps.d.ts +14 -0
- package/internals/utils/createRangePickerStepNavigation.d.ts +16 -0
- package/internals/utils/createRangePickerStepNavigation.js +37 -0
- package/internals/utils/releaseInfo.js +1 -1
- package/managers/useDateRangeManager.js +8 -9
- package/managers/useDateTimeRangeManager.js +9 -9
- package/managers/useTimeRangeManager.js +9 -7
- package/modern/DateRangeCalendar/DateRangeCalendar.js +3 -8
- package/modern/DateRangePicker/shared.js +3 -8
- package/modern/DateRangePickerDay/DateRangePickerDay.js +1 -1
- package/modern/DateTimeRangePicker/shared.js +3 -12
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +2 -1
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +9 -1
- package/modern/DesktopTimeRangePicker/DesktopTimeRangePicker.js +9 -1
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +2 -1
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +16 -2
- package/modern/MobileTimeRangePicker/MobileTimeRangePicker.js +9 -1
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +2 -1
- package/modern/TimeRangePicker/shared.js +3 -4
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -0
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +10 -3
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +3 -3
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -0
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +10 -3
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +3 -3
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -0
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +10 -3
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +7 -0
- package/modern/internals/models/rangePickerProps.d.ts +14 -0
- package/modern/internals/utils/createRangePickerStepNavigation.d.ts +16 -0
- package/modern/internals/utils/createRangePickerStepNavigation.js +31 -0
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/managers/useDateRangeManager.js +9 -10
- package/modern/managers/useDateTimeRangeManager.js +10 -10
- package/modern/managers/useTimeRangeManager.js +10 -8
- package/package.json +8 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/internals/hooks/models/index.d.ts +0 -1
- package/esm/internals/hooks/models/index.js +0 -1
- package/esm/internals/hooks/models/useRangePicker.d.ts +0 -8
- package/esm/internals/hooks/models/useRangePicker.js +0 -1
- package/internals/hooks/models/index.d.ts +0 -1
- package/internals/hooks/models/index.js +0 -5
- package/internals/hooks/models/useRangePicker.d.ts +0 -8
- package/internals/hooks/models/useRangePicker.js +0 -5
- package/modern/internals/hooks/models/index.d.ts +0 -1
- package/modern/internals/hooks/models/index.js +0 -1
- package/modern/internals/hooks/models/useRangePicker.d.ts +0 -8
- package/modern/internals/hooks/models/useRangePicker.js +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DateOrTimeViewWithMeridiem, RangePosition } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { UseRangePositionResponse } from "../hooks/useRangePosition.js";
|
|
3
|
+
export declare function createRangePickerStepNavigation(parameters: CreateRangePickerStepNavigationParameters): import("@mui/x-date-pickers/internals/utils/createStepNavigation").CreateStepNavigationReturnValue;
|
|
4
|
+
export interface PickerRangeStep {
|
|
5
|
+
/**
|
|
6
|
+
* The views that are handled inside this step.
|
|
7
|
+
* If null, all views are handled by this step.
|
|
8
|
+
*/
|
|
9
|
+
views: readonly DateOrTimeViewWithMeridiem[] | null;
|
|
10
|
+
rangePosition: RangePosition;
|
|
11
|
+
}
|
|
12
|
+
interface CreateRangePickerStepNavigationParameters {
|
|
13
|
+
steps: PickerRangeStep[] | null;
|
|
14
|
+
rangePositionResponse: UseRangePositionResponse;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createStepNavigation } from '@mui/x-date-pickers/internals';
|
|
2
|
+
export function createRangePickerStepNavigation(parameters) {
|
|
3
|
+
const {
|
|
4
|
+
steps,
|
|
5
|
+
rangePositionResponse
|
|
6
|
+
} = parameters;
|
|
7
|
+
return createStepNavigation({
|
|
8
|
+
steps,
|
|
9
|
+
isCurrentViewMatchingStep: (view, step) => {
|
|
10
|
+
if (step.rangePosition !== rangePositionResponse.rangePosition) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return step.views == null || step.views.includes(view);
|
|
14
|
+
},
|
|
15
|
+
onStepChange: ({
|
|
16
|
+
step,
|
|
17
|
+
initialView,
|
|
18
|
+
setView,
|
|
19
|
+
view,
|
|
20
|
+
views
|
|
21
|
+
}) => {
|
|
22
|
+
if (step.rangePosition !== rangePositionResponse.rangePosition) {
|
|
23
|
+
rangePositionResponse.setRangePosition(step.rangePosition);
|
|
24
|
+
}
|
|
25
|
+
const targetView = step.views == null ? initialView : step.views.find(viewBis => views.includes(viewBis));
|
|
26
|
+
if (targetView !== view) {
|
|
27
|
+
setView(targetView);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTc0MzYzMTIwMDAwMA==";
|
|
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,15 +20,7 @@ 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
|
}
|
|
@@ -38,4 +30,11 @@ function useOpenPickerButtonAriaLabel(value) {
|
|
|
38
30
|
return React.useMemo(() => {
|
|
39
31
|
return translations.openRangePickerDialogue(formatRange(utils, value, 'fullDate'));
|
|
40
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,15 +20,7 @@ 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
|
}
|
|
@@ -38,4 +30,12 @@ function useOpenPickerButtonAriaLabel(value) {
|
|
|
38
30
|
return React.useMemo(() => {
|
|
39
31
|
return translations.openRangePickerDialogue(formatRange(utils, value, 'fullDate'));
|
|
40
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,13 +21,7 @@ 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
|
}
|
|
@@ -40,4 +34,12 @@ function createUseOpenPickerButtonAriaLabel(ampm) {
|
|
|
40
34
|
return translations.openRangePickerDialogue(formatRange(utils, value, formatKey));
|
|
41
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
|
}
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
|
3
3
|
import { UseDesktopRangePickerParams, UseDesktopRangePickerProps } from "./useDesktopRangePicker.types.js";
|
|
4
4
|
export declare const useDesktopRangePicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({
|
|
5
5
|
props,
|
|
6
|
+
steps,
|
|
6
7
|
...pickerParams
|
|
7
8
|
}: UseDesktopRangePickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
|
8
9
|
renderPicker: () => React.JSX.Element;
|
|
@@ -17,13 +17,15 @@ var _releaseInfo = require("../../utils/releaseInfo");
|
|
|
17
17
|
var _useRangePosition = require("../useRangePosition");
|
|
18
18
|
var _usePickerRangePositionContext = require("../../../hooks/usePickerRangePositionContext");
|
|
19
19
|
var _dateFieldsUtils = require("../../utils/date-fields-utils");
|
|
20
|
+
var _createRangePickerStepNavigation = require("../../utils/createRangePickerStepNavigation");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
const _excluded = ["props"],
|
|
22
|
+
const _excluded = ["props", "steps"],
|
|
22
23
|
_excluded2 = ["ownerState"];
|
|
23
24
|
const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
|
|
24
25
|
const useDesktopRangePicker = _ref => {
|
|
25
26
|
let {
|
|
26
|
-
props
|
|
27
|
+
props,
|
|
28
|
+
steps
|
|
27
29
|
} = _ref,
|
|
28
30
|
pickerParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
29
31
|
(0, _xLicense.useLicenseVerifier)('x-date-pickers-pro', releaseInfo);
|
|
@@ -36,6 +38,10 @@ const useDesktopRangePicker = _ref => {
|
|
|
36
38
|
const fieldType = (0, _dateFieldsUtils.getRangeFieldType)(slots.field);
|
|
37
39
|
const viewContainerRole = fieldType === 'single-input' ? 'dialog' : 'tooltip';
|
|
38
40
|
const rangePositionResponse = (0, _useRangePosition.useRangePosition)(props);
|
|
41
|
+
const getStepNavigation = (0, _createRangePickerStepNavigation.createRangePickerStepNavigation)({
|
|
42
|
+
steps,
|
|
43
|
+
rangePositionResponse
|
|
44
|
+
});
|
|
39
45
|
const {
|
|
40
46
|
providerProps,
|
|
41
47
|
renderCurrentView,
|
|
@@ -45,7 +51,8 @@ const useDesktopRangePicker = _ref => {
|
|
|
45
51
|
variant: 'desktop',
|
|
46
52
|
autoFocusView: viewContainerRole === 'dialog',
|
|
47
53
|
viewContainerRole,
|
|
48
|
-
localeText
|
|
54
|
+
localeText,
|
|
55
|
+
getStepNavigation
|
|
49
56
|
}));
|
|
50
57
|
const Field = slots.field;
|
|
51
58
|
const _useSlotProps = (0, _useSlotProps2.default)({
|
|
@@ -2,7 +2,7 @@ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
|
2
2
|
import { PickerFieldSlotProps, PickerOwnerState } from '@mui/x-date-pickers/models';
|
|
3
3
|
import { PickerPopperSlots, PickerPopperSlotProps, UsePickerProps, DateOrTimeViewWithMeridiem, PickerRangeValue, PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from '@mui/x-date-pickers/internals';
|
|
4
4
|
import { ExportedPickersLayoutSlotProps, ExportedPickersLayoutSlots } from '@mui/x-date-pickers/PickersLayout';
|
|
5
|
-
import {
|
|
5
|
+
import { NonStaticRangePickerProps, NonStaticRangePickerHookParameters, UseRangePickerProps } from "../../models/index.js";
|
|
6
6
|
export interface UseDesktopRangePickerSlots extends PickerPopperSlots, ExportedPickersLayoutSlots<PickerRangeValue>, PickerFieldUISlotsFromContext {
|
|
7
7
|
/**
|
|
8
8
|
* Component used to enter the date with the keyboard.
|
|
@@ -14,7 +14,7 @@ export interface UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructu
|
|
|
14
14
|
dateSeparator?: string;
|
|
15
15
|
}, {}, PickerOwnerState>;
|
|
16
16
|
}
|
|
17
|
-
export interface DesktopRangeOnlyPickerProps extends
|
|
17
|
+
export interface DesktopRangeOnlyPickerProps extends NonStaticRangePickerProps {
|
|
18
18
|
/**
|
|
19
19
|
* If `true`, the start `input` element is focused during the first mount.
|
|
20
20
|
*/
|
|
@@ -32,4 +32,4 @@ export interface UseDesktopRangePickerProps<TView extends DateOrTimeViewWithMeri
|
|
|
32
32
|
*/
|
|
33
33
|
slotProps?: UseDesktopRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
34
34
|
}
|
|
35
|
-
export interface UseDesktopRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends
|
|
35
|
+
export interface UseDesktopRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends NonStaticRangePickerHookParameters<TView, TExternalProps> {}
|
|
@@ -3,6 +3,7 @@ import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
|
3
3
|
import { UseMobileRangePickerParams, UseMobileRangePickerProps } from "./useMobileRangePicker.types.js";
|
|
4
4
|
export declare const useMobileRangePicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({
|
|
5
5
|
props,
|
|
6
|
+
steps,
|
|
6
7
|
...pickerParams
|
|
7
8
|
}: UseMobileRangePickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
|
8
9
|
renderPicker: () => React.JSX.Element;
|
|
@@ -19,13 +19,15 @@ var _releaseInfo = require("../../utils/releaseInfo");
|
|
|
19
19
|
var _useRangePosition = require("../useRangePosition");
|
|
20
20
|
var _usePickerRangePositionContext = require("../../../hooks/usePickerRangePositionContext");
|
|
21
21
|
var _dateFieldsUtils = require("../../utils/date-fields-utils");
|
|
22
|
+
var _createRangePickerStepNavigation = require("../../utils/createRangePickerStepNavigation");
|
|
22
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
-
const _excluded = ["props"],
|
|
24
|
+
const _excluded = ["props", "steps"],
|
|
24
25
|
_excluded2 = ["ownerState"];
|
|
25
26
|
const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
|
|
26
27
|
const useMobileRangePicker = _ref => {
|
|
27
28
|
let {
|
|
28
|
-
props
|
|
29
|
+
props,
|
|
30
|
+
steps
|
|
29
31
|
} = _ref,
|
|
30
32
|
pickerParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
31
33
|
(0, _xLicense.useLicenseVerifier)('x-date-pickers-pro', releaseInfo);
|
|
@@ -39,6 +41,10 @@ const useMobileRangePicker = _ref => {
|
|
|
39
41
|
const fieldType = (0, _dateFieldsUtils.getRangeFieldType)(slots.field);
|
|
40
42
|
const rangePositionResponse = (0, _useRangePosition.useRangePosition)(props);
|
|
41
43
|
const contextTranslations = (0, _hooks.usePickerTranslations)();
|
|
44
|
+
const getStepNavigation = (0, _createRangePickerStepNavigation.createRangePickerStepNavigation)({
|
|
45
|
+
steps,
|
|
46
|
+
rangePositionResponse
|
|
47
|
+
});
|
|
42
48
|
const {
|
|
43
49
|
providerProps,
|
|
44
50
|
renderCurrentView,
|
|
@@ -48,7 +54,8 @@ const useMobileRangePicker = _ref => {
|
|
|
48
54
|
variant: 'mobile',
|
|
49
55
|
autoFocusView: true,
|
|
50
56
|
viewContainerRole: 'dialog',
|
|
51
|
-
localeText
|
|
57
|
+
localeText,
|
|
58
|
+
getStepNavigation
|
|
52
59
|
}));
|
|
53
60
|
const labelId = providerProps.privateContextValue.labelId;
|
|
54
61
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
@@ -2,7 +2,7 @@ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
|
2
2
|
import { PickerFieldSlotProps, PickerOwnerState } from '@mui/x-date-pickers/models';
|
|
3
3
|
import { PickersModalDialogSlots, PickersModalDialogSlotProps, UsePickerProps, DateOrTimeViewWithMeridiem, PickerRangeValue, PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from '@mui/x-date-pickers/internals';
|
|
4
4
|
import { ExportedPickersLayoutSlotProps, ExportedPickersLayoutSlots, PickersLayoutSlotProps } from '@mui/x-date-pickers/PickersLayout';
|
|
5
|
-
import {
|
|
5
|
+
import { NonStaticRangePickerProps, NonStaticRangePickerHookParameters, UseRangePickerProps } from "../../models/index.js";
|
|
6
6
|
export interface UseMobileRangePickerSlots extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerRangeValue>, PickerFieldUISlotsFromContext {
|
|
7
7
|
/**
|
|
8
8
|
* Component used to enter the date with the keyboard.
|
|
@@ -15,7 +15,7 @@ export interface ExportedUseMobileRangePickerSlotProps<TEnableAccessibleFieldDOM
|
|
|
15
15
|
}, {}, PickerOwnerState>;
|
|
16
16
|
}
|
|
17
17
|
export interface UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerRangeValue>, 'toolbar'> {}
|
|
18
|
-
export interface MobileRangeOnlyPickerProps extends
|
|
18
|
+
export interface MobileRangeOnlyPickerProps extends NonStaticRangePickerProps {}
|
|
19
19
|
export interface UseMobileRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerProps<PickerRangeValue, TView, TError, any>> extends UseRangePickerProps<TView, TError, TExternalProps> {
|
|
20
20
|
/**
|
|
21
21
|
* Overridable component slots.
|
|
@@ -28,4 +28,4 @@ export interface UseMobileRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
28
28
|
*/
|
|
29
29
|
slotProps?: UseMobileRangePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
30
30
|
}
|
|
31
|
-
export interface UseMobileRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends
|
|
31
|
+
export interface UseMobileRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobileRangePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends NonStaticRangePickerHookParameters<TView, TExternalProps> {}
|
|
@@ -7,6 +7,7 @@ import { UseStaticRangePickerParams, UseStaticRangePickerProps } from "./useStat
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const useStaticRangePicker: <TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>>({
|
|
9
9
|
props,
|
|
10
|
+
steps,
|
|
10
11
|
...pickerParams
|
|
11
12
|
}: UseStaticRangePickerParams<TView, TExternalProps>) => {
|
|
12
13
|
renderPicker: () => React.JSX.Element;
|
|
@@ -15,8 +15,9 @@ var _PickersLayout = require("@mui/x-date-pickers/PickersLayout");
|
|
|
15
15
|
var _internals = require("@mui/x-date-pickers/internals");
|
|
16
16
|
var _useRangePosition = require("../useRangePosition");
|
|
17
17
|
var _usePickerRangePositionContext = require("../../../hooks/usePickerRangePositionContext");
|
|
18
|
+
var _createRangePickerStepNavigation = require("../../utils/createRangePickerStepNavigation");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["props"];
|
|
20
|
+
const _excluded = ["props", "steps"];
|
|
20
21
|
const PickerStaticLayout = (0, _styles.styled)(_PickersLayout.PickersLayout)(({
|
|
21
22
|
theme
|
|
22
23
|
}) => ({
|
|
@@ -31,7 +32,8 @@ const PickerStaticLayout = (0, _styles.styled)(_PickersLayout.PickersLayout)(({
|
|
|
31
32
|
*/
|
|
32
33
|
const useStaticRangePicker = _ref => {
|
|
33
34
|
let {
|
|
34
|
-
props
|
|
35
|
+
props,
|
|
36
|
+
steps
|
|
35
37
|
} = _ref,
|
|
36
38
|
pickerParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
37
39
|
const {
|
|
@@ -42,6 +44,10 @@ const useStaticRangePicker = _ref => {
|
|
|
42
44
|
autoFocus
|
|
43
45
|
} = props;
|
|
44
46
|
const rangePositionResponse = (0, _useRangePosition.useRangePosition)(props);
|
|
47
|
+
const getStepNavigation = (0, _createRangePickerStepNavigation.createRangePickerStepNavigation)({
|
|
48
|
+
steps,
|
|
49
|
+
rangePositionResponse
|
|
50
|
+
});
|
|
45
51
|
const {
|
|
46
52
|
providerProps,
|
|
47
53
|
renderCurrentView
|
|
@@ -50,7 +56,8 @@ const useStaticRangePicker = _ref => {
|
|
|
50
56
|
variant: displayStaticWrapperAs,
|
|
51
57
|
autoFocusView: autoFocus ?? false,
|
|
52
58
|
viewContainerRole: null,
|
|
53
|
-
localeText
|
|
59
|
+
localeText,
|
|
60
|
+
getStepNavigation
|
|
54
61
|
}));
|
|
55
62
|
const Layout = slots?.layout ?? PickerStaticLayout;
|
|
56
63
|
const renderPicker = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_usePickerRangePositionContext.PickerRangePositionContext.Provider, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BasePickerProps, UsePickerParameters, ExportedBaseToolbarProps, StaticOnlyPickerProps, DateOrTimeViewWithMeridiem, PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
2
2
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps } from '@mui/x-date-pickers/PickersLayout';
|
|
3
3
|
import { UseRangePositionProps } from "../useRangePosition.js";
|
|
4
|
+
import { PickerRangeStep } from "../../utils/createRangePickerStepNavigation.js";
|
|
4
5
|
export interface UseStaticRangePickerSlots extends ExportedPickersLayoutSlots<PickerRangeValue> {}
|
|
5
6
|
export interface UseStaticRangePickerSlotProps extends ExportedPickersLayoutSlotProps<PickerRangeValue> {
|
|
6
7
|
toolbar?: ExportedBaseToolbarProps;
|
|
@@ -20,4 +21,10 @@ export interface UseStaticRangePickerProps<TView extends DateOrTimeViewWithMerid
|
|
|
20
21
|
}
|
|
21
22
|
export interface UseStaticRangePickerParams<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseStaticRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParameters<PickerRangeValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'ref'> {
|
|
22
23
|
props: TExternalProps;
|
|
24
|
+
/**
|
|
25
|
+
* Steps available for the picker.
|
|
26
|
+
* This will be used to define the behavior of navigation actions.
|
|
27
|
+
* If null, the picker will not have any step navigation.
|
|
28
|
+
*/
|
|
29
|
+
steps: PickerRangeStep[] | null;
|
|
23
30
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { BasePickerProps, DateOrTimeViewWithMeridiem, PickerRangeValue, UsePickerNonStaticProps, UsePickerParameters, UsePickerProps } from '@mui/x-date-pickers/internals';
|
|
1
2
|
import * as React from 'react';
|
|
3
|
+
import { UseRangePositionProps } from "../hooks/useRangePosition.js";
|
|
4
|
+
import { PickerRangeStep } from "../utils/createRangePickerStepNavigation.js";
|
|
2
5
|
/**
|
|
3
6
|
* Props common to all range non-static pickers.
|
|
4
7
|
* These props are handled by the headless wrappers.
|
|
@@ -19,4 +22,15 @@ export interface BaseRangeNonStaticPickerProps {
|
|
|
19
22
|
* Ignored if the field has several inputs.
|
|
20
23
|
*/
|
|
21
24
|
name?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface NonStaticRangePickerProps extends UsePickerNonStaticProps, BaseRangeNonStaticPickerProps, UseRangePositionProps {}
|
|
27
|
+
export interface UseRangePickerProps<TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerProps<PickerRangeValue, TView, TError, any>> extends NonStaticRangePickerProps, BasePickerProps<PickerRangeValue, TView, TError, TExternalProps> {}
|
|
28
|
+
export interface NonStaticRangePickerHookParameters<TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UseRangePickerProps<TView, any, TExternalProps>> extends Pick<UsePickerParameters<PickerRangeValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
|
|
29
|
+
props: TExternalProps;
|
|
30
|
+
/**
|
|
31
|
+
* Steps available for the picker.
|
|
32
|
+
* This will be used to define the behavior of navigation actions.
|
|
33
|
+
* If null, the picker will not have any step navigation.
|
|
34
|
+
*/
|
|
35
|
+
steps: PickerRangeStep[] | null;
|
|
22
36
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DateOrTimeViewWithMeridiem, RangePosition } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { UseRangePositionResponse } from "../hooks/useRangePosition.js";
|
|
3
|
+
export declare function createRangePickerStepNavigation(parameters: CreateRangePickerStepNavigationParameters): import("@mui/x-date-pickers/internals/utils/createStepNavigation").CreateStepNavigationReturnValue;
|
|
4
|
+
export interface PickerRangeStep {
|
|
5
|
+
/**
|
|
6
|
+
* The views that are handled inside this step.
|
|
7
|
+
* If null, all views are handled by this step.
|
|
8
|
+
*/
|
|
9
|
+
views: readonly DateOrTimeViewWithMeridiem[] | null;
|
|
10
|
+
rangePosition: RangePosition;
|
|
11
|
+
}
|
|
12
|
+
interface CreateRangePickerStepNavigationParameters {
|
|
13
|
+
steps: PickerRangeStep[] | null;
|
|
14
|
+
rangePositionResponse: UseRangePositionResponse;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createRangePickerStepNavigation = createRangePickerStepNavigation;
|
|
7
|
+
var _internals = require("@mui/x-date-pickers/internals");
|
|
8
|
+
function createRangePickerStepNavigation(parameters) {
|
|
9
|
+
const {
|
|
10
|
+
steps,
|
|
11
|
+
rangePositionResponse
|
|
12
|
+
} = parameters;
|
|
13
|
+
return (0, _internals.createStepNavigation)({
|
|
14
|
+
steps,
|
|
15
|
+
isCurrentViewMatchingStep: (view, step) => {
|
|
16
|
+
if (step.rangePosition !== rangePositionResponse.rangePosition) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return step.views == null || step.views.includes(view);
|
|
20
|
+
},
|
|
21
|
+
onStepChange: ({
|
|
22
|
+
step,
|
|
23
|
+
initialView,
|
|
24
|
+
setView,
|
|
25
|
+
view,
|
|
26
|
+
views
|
|
27
|
+
}) => {
|
|
28
|
+
if (step.rangePosition !== rangePositionResponse.rangePosition) {
|
|
29
|
+
rangePositionResponse.setRangePosition(step.rangePosition);
|
|
30
|
+
}
|
|
31
|
+
const targetView = step.views == null ? initialView : step.views.find(viewBis => views.includes(viewBis));
|
|
32
|
+
if (targetView !== view) {
|
|
33
|
+
setView(targetView);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -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 = "MTc0MzYzMTIwMDAwMA==";
|
|
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,15 +27,7 @@ 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
|
}
|
|
@@ -45,4 +37,11 @@ function useOpenPickerButtonAriaLabel(value) {
|
|
|
45
37
|
return React.useMemo(() => {
|
|
46
38
|
return translations.openRangePickerDialogue((0, _dateUtils.formatRange)(utils, value, 'fullDate'));
|
|
47
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,15 +27,7 @@ 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
|
}
|
|
@@ -45,4 +37,12 @@ function useOpenPickerButtonAriaLabel(value) {
|
|
|
45
37
|
return React.useMemo(() => {
|
|
46
38
|
return translations.openRangePickerDialogue((0, _dateUtils.formatRange)(utils, value, 'fullDate'));
|
|
47
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,13 +28,7 @@ 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
|
}
|
|
@@ -47,4 +41,12 @@ function createUseOpenPickerButtonAriaLabel(ampm) {
|
|
|
47
41
|
return translations.openRangePickerDialogue((0, _dateUtils.formatRange)(utils, value, formatKey));
|
|
48
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']
|