@mui/x-date-pickers-pro 7.0.0-alpha.8 → 7.0.0-beta.0
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 +508 -30
- package/DateRangeCalendar/DateRangeCalendar.js +79 -13
- package/DateRangeCalendar/DateRangeCalendar.types.d.ts +15 -14
- package/DateRangePicker/DateRangePicker.js +0 -3
- package/DateRangePicker/DateRangePickerToolbar.js +0 -3
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +7 -0
- package/DateTimeRangePicker/DateTimeRangePicker.js +414 -0
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +24 -0
- package/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +32 -0
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +183 -0
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +20 -0
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +59 -0
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +15 -0
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +176 -0
- package/DateTimeRangePicker/dateTimeRangePickerTabsClasses.d.ts +13 -0
- package/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
- package/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.d.ts +11 -0
- package/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
- package/DateTimeRangePicker/index.d.ts +10 -0
- package/DateTimeRangePicker/index.js +5 -0
- package/DateTimeRangePicker/package.json +6 -0
- package/DateTimeRangePicker/shared.d.ts +60 -0
- package/DateTimeRangePicker/shared.js +56 -0
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +1 -1
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +7 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +491 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +25 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +8 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +52 -0
- package/DesktopDateTimeRangePicker/index.d.ts +2 -0
- package/DesktopDateTimeRangePicker/index.js +1 -0
- package/DesktopDateTimeRangePicker/package.json +6 -0
- package/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
- package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +1 -6
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +7 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +490 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +20 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
- package/MobileDateTimeRangePicker/index.d.ts +2 -0
- package/MobileDateTimeRangePicker/index.js +1 -0
- package/MobileDateTimeRangePicker/package.json +6 -0
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +2 -5
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +2 -5
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +2 -5
- package/README.md +3 -3
- package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +2 -1
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +2 -1
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +2 -1
- package/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
- package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +5 -0
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -4
- package/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/index.d.ts +3 -0
- package/index.js +4 -1
- package/internals/constants/dimensions.d.ts +3 -0
- package/internals/constants/dimensions.js +5 -0
- package/internals/hooks/models/index.d.ts +1 -0
- package/internals/hooks/models/index.js +1 -0
- package/internals/hooks/models/useRangePicker.d.ts +21 -0
- package/internals/hooks/models/useRangePicker.js +1 -0
- package/internals/hooks/useDesktopRangePicker/index.d.ts +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +17 -3
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +8 -14
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +5 -2
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +41 -11
- package/internals/hooks/useMobileRangePicker/index.d.ts +1 -1
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +8 -14
- package/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +2 -6
- package/internals/models/dateTimeRange.d.ts +3 -1
- package/internals/models/fields.d.ts +7 -2
- package/internals/utils/date-range-manager.d.ts +2 -1
- package/internals/utils/date-range-manager.js +12 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.js +4 -4
- package/legacy/DateRangeCalendar/DateRangeCalendar.js +77 -12
- package/legacy/DateRangePicker/DateRangePicker.js +0 -3
- package/legacy/DateRangePicker/DateRangePickerToolbar.js +0 -3
- package/legacy/DateTimeRangePicker/DateTimeRangePicker.js +413 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePickerTabs.js +191 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +57 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePickerToolbar.js +184 -0
- package/legacy/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
- package/legacy/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
- package/legacy/DateTimeRangePicker/index.js +5 -0
- package/legacy/DateTimeRangePicker/shared.js +54 -0
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +491 -0
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +48 -0
- package/legacy/DesktopDateTimeRangePicker/index.js +1 -0
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
- package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +484 -0
- package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
- package/legacy/MobileDateTimeRangePicker/index.js +1 -0
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
- package/legacy/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/legacy/index.js +4 -1
- package/legacy/internals/constants/dimensions.js +5 -0
- package/legacy/internals/hooks/models/index.js +1 -0
- package/legacy/internals/hooks/models/useRangePicker.js +1 -0
- package/legacy/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +17 -3
- package/legacy/internals/hooks/useEnrichedRangePickerFieldProps.js +43 -11
- package/legacy/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/legacy/internals/utils/date-range-manager.js +13 -1
- package/legacy/internals/utils/releaseInfo.js +1 -1
- package/legacy/internals/utils/valueManagers.js +4 -4
- package/legacy/locales/index.js +1 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/package.json +6 -0
- package/modern/DateRangeCalendar/DateRangeCalendar.js +78 -12
- package/modern/DateRangePicker/DateRangePicker.js +0 -3
- package/modern/DateRangePicker/DateRangePickerToolbar.js +0 -3
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +414 -0
- package/modern/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +183 -0
- package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +58 -0
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +176 -0
- package/modern/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
- package/modern/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
- package/modern/DateTimeRangePicker/index.js +5 -0
- package/modern/DateTimeRangePicker/shared.js +55 -0
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +483 -0
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +51 -0
- package/modern/DesktopDateTimeRangePicker/index.js +1 -0
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +486 -0
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
- package/modern/MobileDateTimeRangePicker/index.js +1 -0
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
- package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/modern/index.js +4 -1
- package/modern/internals/constants/dimensions.js +5 -0
- package/modern/internals/hooks/models/index.js +1 -0
- package/modern/internals/hooks/models/useRangePicker.js +1 -0
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -2
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +40 -9
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/modern/internals/utils/date-range-manager.js +12 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/internals/utils/valueManagers.js +4 -4
- package/modern/locales/index.js +1 -0
- package/node/DateRangeCalendar/DateRangeCalendar.js +78 -12
- package/node/DateRangePicker/DateRangePicker.js +0 -3
- package/node/DateRangePicker/DateRangePickerToolbar.js +0 -3
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +422 -0
- package/node/DateTimeRangePicker/DateTimeRangePicker.types.js +5 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +190 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +64 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +183 -0
- package/node/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +14 -0
- package/node/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +12 -0
- package/node/DateTimeRangePicker/index.js +52 -0
- package/node/DateTimeRangePicker/shared.js +62 -0
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -3
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +490 -0
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +5 -0
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +59 -0
- package/node/DesktopDateTimeRangePicker/index.js +12 -0
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -8
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +494 -0
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +5 -0
- package/node/MobileDateTimeRangePicker/index.js +12 -0
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -4
- package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/node/index.js +37 -1
- package/node/internals/constants/dimensions.js +16 -0
- package/node/internals/hooks/models/index.js +5 -0
- package/node/internals/hooks/models/useRangePicker.js +5 -0
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -2
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +40 -9
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/node/internals/utils/date-range-manager.js +12 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/internals/utils/valueManagers.js +4 -4
- package/node/locales/index.js +16 -0
- package/package.json +9 -9
- package/themeAugmentation/components.d.ts +22 -3
- package/themeAugmentation/overrides.d.ts +7 -0
- package/themeAugmentation/props.d.ts +12 -0
|
@@ -20,22 +20,37 @@ var useMultiInputFieldSlotProps = function useMultiInputFieldSlotProps(_ref) {
|
|
|
20
20
|
pickerSlotProps = _ref.pickerSlotProps,
|
|
21
21
|
pickerSlots = _ref.pickerSlots,
|
|
22
22
|
fieldProps = _ref.fieldProps,
|
|
23
|
-
anchorRef = _ref.anchorRef
|
|
23
|
+
anchorRef = _ref.anchorRef,
|
|
24
|
+
currentView = _ref.currentView,
|
|
25
|
+
initialView = _ref.initialView,
|
|
26
|
+
onViewChange = _ref.onViewChange;
|
|
24
27
|
var localeText = useLocaleText();
|
|
25
28
|
var startRef = React.useRef(null);
|
|
26
29
|
var endRef = React.useRef(null);
|
|
30
|
+
var startFieldRef = React.useRef(null);
|
|
31
|
+
var endFieldRef = React.useRef(null);
|
|
32
|
+
var handleStartFieldRef = useForkRef(fieldProps.unstableStartFieldRef, startFieldRef);
|
|
33
|
+
var handleEndFieldRef = useForkRef(fieldProps.unstableFieldRef, endFieldRef);
|
|
34
|
+
var previousRangePosition = React.useRef(rangePosition);
|
|
27
35
|
React.useEffect(function () {
|
|
36
|
+
var _currentRef$current;
|
|
28
37
|
if (!open) {
|
|
29
38
|
return;
|
|
30
39
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
var currentRef = rangePosition === 'start' ? startRef : endRef;
|
|
41
|
+
(_currentRef$current = currentRef.current) == null || _currentRef$current.focus();
|
|
42
|
+
var currentFieldRef = rangePosition === 'start' ? startFieldRef : endFieldRef;
|
|
43
|
+
if (!currentFieldRef.current || !currentView) {
|
|
44
|
+
// could happen when the user is switching between the inputs
|
|
45
|
+
previousRangePosition.current = rangePosition;
|
|
46
|
+
return;
|
|
37
47
|
}
|
|
38
|
-
|
|
48
|
+
// bring back focus to the field
|
|
49
|
+
currentFieldRef.current.setSelectedSections(
|
|
50
|
+
// use the current view or `0` when the range position has just been swapped
|
|
51
|
+
previousRangePosition.current === rangePosition ? currentView : 0);
|
|
52
|
+
previousRangePosition.current = rangePosition;
|
|
53
|
+
}, [rangePosition, open, currentView]);
|
|
39
54
|
var openRangeStartSelection = function openRangeStartSelection(event) {
|
|
40
55
|
event.stopPropagation();
|
|
41
56
|
onRangePositionChange('start');
|
|
@@ -53,11 +68,17 @@ var useMultiInputFieldSlotProps = function useMultiInputFieldSlotProps(_ref) {
|
|
|
53
68
|
var handleFocusStart = function handleFocusStart() {
|
|
54
69
|
if (open) {
|
|
55
70
|
onRangePositionChange('start');
|
|
71
|
+
if (previousRangePosition.current !== 'start' && initialView) {
|
|
72
|
+
onViewChange == null || onViewChange(initialView);
|
|
73
|
+
}
|
|
56
74
|
}
|
|
57
75
|
};
|
|
58
76
|
var handleFocusEnd = function handleFocusEnd() {
|
|
59
77
|
if (open) {
|
|
60
78
|
onRangePositionChange('end');
|
|
79
|
+
if (previousRangePosition.current !== 'end' && initialView) {
|
|
80
|
+
onViewChange == null || onViewChange(initialView);
|
|
81
|
+
}
|
|
61
82
|
}
|
|
62
83
|
};
|
|
63
84
|
var slots = _extends({
|
|
@@ -124,7 +145,9 @@ var useMultiInputFieldSlotProps = function useMultiInputFieldSlotProps(_ref) {
|
|
|
124
145
|
restFieldProps = _objectWithoutProperties(fieldProps, _excluded);
|
|
125
146
|
var enrichedFieldProps = _extends({}, restFieldProps, {
|
|
126
147
|
slots: slots,
|
|
127
|
-
slotProps: slotProps
|
|
148
|
+
slotProps: slotProps,
|
|
149
|
+
unstableStartFieldRef: handleStartFieldRef,
|
|
150
|
+
unstableEndFieldRef: handleEndFieldRef
|
|
128
151
|
});
|
|
129
152
|
return enrichedFieldProps;
|
|
130
153
|
};
|
|
@@ -144,7 +167,8 @@ var useSingleInputFieldSlotProps = function useSingleInputFieldSlotProps(_ref2)
|
|
|
144
167
|
pickerSlots = _ref2.pickerSlots,
|
|
145
168
|
pickerSlotProps = _ref2.pickerSlotProps,
|
|
146
169
|
fieldProps = _ref2.fieldProps,
|
|
147
|
-
anchorRef = _ref2.anchorRef
|
|
170
|
+
anchorRef = _ref2.anchorRef,
|
|
171
|
+
currentView = _ref2.currentView;
|
|
148
172
|
var inputRef = React.useRef(null);
|
|
149
173
|
var handleInputRef = useForkRef(inInputRef, inputRef);
|
|
150
174
|
var handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
|
|
@@ -154,7 +178,15 @@ var useSingleInputFieldSlotProps = function useSingleInputFieldSlotProps(_ref2)
|
|
|
154
178
|
return;
|
|
155
179
|
}
|
|
156
180
|
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
157
|
-
|
|
181
|
+
if (!singleInputFieldRef.current || !currentView) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
var sections = singleInputFieldRef.current.getSections().map(function (section) {
|
|
185
|
+
return section.type;
|
|
186
|
+
});
|
|
187
|
+
// bring back focus to the field with the current view section selected
|
|
188
|
+
singleInputFieldRef.current.setSelectedSections(rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView));
|
|
189
|
+
}, [rangePosition, open, currentView, singleInputFieldRef]);
|
|
158
190
|
var updateRangePosition = function updateRangePosition() {
|
|
159
191
|
var _singleInputFieldRef$;
|
|
160
192
|
if (!singleInputFieldRef.current || inputRef.current !== getActiveElement(document)) {
|
|
@@ -91,6 +91,10 @@ export var useMobileRangePicker = function useMobileRangePicker(_ref) {
|
|
|
91
91
|
fieldProps: fieldProps
|
|
92
92
|
});
|
|
93
93
|
var slotPropsForLayout = _extends({}, innerSlotProps, {
|
|
94
|
+
tabs: _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.tabs, {
|
|
95
|
+
rangePosition: rangePosition,
|
|
96
|
+
onRangePositionChange: onRangePositionChange
|
|
97
|
+
}),
|
|
94
98
|
toolbar: _extends({}, innerSlotProps == null ? void 0 : innerSlotProps.toolbar, {
|
|
95
99
|
titleId: labelId,
|
|
96
100
|
rangePosition: rangePosition,
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { mergeDateAndTime } from '@mui/x-date-pickers/internals';
|
|
2
3
|
export function calculateRangeChange(_ref) {
|
|
3
4
|
var utils = _ref.utils,
|
|
4
5
|
range = _ref.range,
|
|
5
6
|
selectedDate = _ref.newDate,
|
|
6
7
|
rangePosition = _ref.rangePosition,
|
|
7
8
|
_ref$allowRangeFlip = _ref.allowRangeFlip,
|
|
8
|
-
allowRangeFlip = _ref$allowRangeFlip === void 0 ? false : _ref$allowRangeFlip
|
|
9
|
+
allowRangeFlip = _ref$allowRangeFlip === void 0 ? false : _ref$allowRangeFlip,
|
|
10
|
+
_ref$shouldMergeDateA = _ref.shouldMergeDateAndTime,
|
|
11
|
+
shouldMergeDateAndTime = _ref$shouldMergeDateA === void 0 ? false : _ref$shouldMergeDateA;
|
|
9
12
|
var _range = _slicedToArray(range, 2),
|
|
10
13
|
start = _range[0],
|
|
11
14
|
end = _range[1];
|
|
15
|
+
if (shouldMergeDateAndTime && selectedDate) {
|
|
16
|
+
// If there is a date already selected, then we want to keep its time
|
|
17
|
+
if (start && rangePosition === 'start') {
|
|
18
|
+
selectedDate = mergeDateAndTime(utils, selectedDate, start);
|
|
19
|
+
}
|
|
20
|
+
if (end && rangePosition === 'end') {
|
|
21
|
+
selectedDate = mergeDateAndTime(utils, selectedDate, end);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
12
24
|
if (rangePosition === 'start') {
|
|
13
25
|
var _truthyResult = allowRangeFlip ? {
|
|
14
26
|
nextSelection: 'start',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export var getReleaseInfo = function getReleaseInfo() {
|
|
3
|
-
var releaseInfo = "
|
|
3
|
+
var releaseInfo = "MTcwNjIyMDAwMDAwMA==";
|
|
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
|
|
@@ -64,7 +64,7 @@ export var rangeFieldValueManager = {
|
|
|
64
64
|
}
|
|
65
65
|
return [prevReferenceValue[1], value[1]];
|
|
66
66
|
},
|
|
67
|
-
getSectionsFromValue: function getSectionsFromValue(utils, _ref2, fallbackSections, isRTL, getSectionsFromDate) {
|
|
67
|
+
getSectionsFromValue: function getSectionsFromValue(utils, _ref2, fallbackSections, localizedDigits, isRTL, getSectionsFromDate) {
|
|
68
68
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
69
69
|
start = _ref3[0],
|
|
70
70
|
end = _ref3[1];
|
|
@@ -90,11 +90,11 @@ export var rangeFieldValueManager = {
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
|
-
return addPositionPropertiesToSections([].concat(_toConsumableArray(getSections(start, separatedFallbackSections.startDate, 'start')), _toConsumableArray(getSections(end, separatedFallbackSections.endDate, 'end'))), isRTL);
|
|
93
|
+
return addPositionPropertiesToSections([].concat(_toConsumableArray(getSections(start, separatedFallbackSections.startDate, 'start')), _toConsumableArray(getSections(end, separatedFallbackSections.endDate, 'end'))), localizedDigits, isRTL);
|
|
94
94
|
},
|
|
95
|
-
getValueStrFromSections: function getValueStrFromSections(sections, isRTL) {
|
|
95
|
+
getValueStrFromSections: function getValueStrFromSections(sections, localizedDigits, isRTL) {
|
|
96
96
|
var dateRangeSections = splitDateRangeSections(sections);
|
|
97
|
-
return createDateStrForInputFromSections([].concat(_toConsumableArray(dateRangeSections.startDate), _toConsumableArray(dateRangeSections.endDate)), isRTL);
|
|
97
|
+
return createDateStrForInputFromSections([].concat(_toConsumableArray(dateRangeSections.startDate), _toConsumableArray(dateRangeSections.endDate)), localizedDigits, isRTL);
|
|
98
98
|
},
|
|
99
99
|
parseValueStr: function parseValueStr(valueStr, referenceValue, parseDate) {
|
|
100
100
|
// TODO: Improve because it would not work if the date format has `–` as a separator.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mui/x-date-pickers/locales';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mui/x-date-pickers/locales';
|
package/locales/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mui/x-date-pickers/locales';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone"],
|
|
3
|
+
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
4
4
|
_excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -12,7 +12,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
12
12
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
13
13
|
import { Watermark } from '@mui/x-license-pro';
|
|
14
14
|
import { PickersCalendarHeader } from '@mui/x-date-pickers/PickersCalendarHeader';
|
|
15
|
-
import { applyDefaultDate,
|
|
15
|
+
import { applyDefaultDate, DayCalendar, useDefaultReduceAnimations, PickersArrowSwitcher, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, useNow, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, buildWarning, useControlledValueWithTimezone, useViews } from '@mui/x-date-pickers/internals';
|
|
16
16
|
import { getReleaseInfo } from '../internals/utils/releaseInfo';
|
|
17
17
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from './dateRangeCalendarClasses';
|
|
18
18
|
import { isEndOfRange, isRangeValid, isStartOfRange, isWithinRange } from '../internals/utils/date-utils';
|
|
@@ -21,6 +21,7 @@ import { DateRangePickerDay, dateRangePickerDayClasses as dayClasses } from '../
|
|
|
21
21
|
import { rangeValueManager } from '../internals/utils/valueManagers';
|
|
22
22
|
import { useDragRange } from './useDragRange';
|
|
23
23
|
import { useRangePosition } from '../internals/hooks/useRangePosition';
|
|
24
|
+
import { DAY_RANGE_SIZE, DAY_MARGIN } from '../internals/constants/dimensions';
|
|
24
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
27
|
const releaseInfo = getReleaseInfo();
|
|
@@ -49,7 +50,6 @@ const DateRangeCalendarArrowSwitcher = styled(PickersArrowSwitcher)({
|
|
|
49
50
|
alignItems: 'center',
|
|
50
51
|
justifyContent: 'space-between'
|
|
51
52
|
});
|
|
52
|
-
const DAY_RANGE_SIZE = 40;
|
|
53
53
|
const weeksContainerHeight = (DAY_RANGE_SIZE + DAY_MARGIN * 2) * 6;
|
|
54
54
|
const warnInvalidCurrentMonthCalendarPosition = buildWarning(['The `currentMonthCalendarPosition` prop must be an integer between `1` and the amount of calendars rendered.', 'For example if you have 2 calendars rendered, it should be equal to either 1 or 2.']);
|
|
55
55
|
const DayCalendarForRange = styled(DayCalendar)(({
|
|
@@ -90,10 +90,13 @@ function useDateRangeCalendarDefaultizedProps(props, name) {
|
|
|
90
90
|
loading: props.loading ?? false,
|
|
91
91
|
disablePast: props.disablePast ?? false,
|
|
92
92
|
disableFuture: props.disableFuture ?? false,
|
|
93
|
+
openTo: themeProps.openTo ?? 'day',
|
|
94
|
+
views: themeProps.views ?? ['day'],
|
|
93
95
|
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
94
96
|
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
|
|
95
97
|
calendars: themeProps.calendars ?? 2,
|
|
96
|
-
disableDragEditing: themeProps.disableDragEditing ?? false
|
|
98
|
+
disableDragEditing: themeProps.disableDragEditing ?? false,
|
|
99
|
+
availableRangePositions: themeProps.availableRangePositions ?? ['start', 'end']
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
const useUtilityClasses = ownerState => {
|
|
@@ -155,7 +158,12 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
155
158
|
fixedWeekNumber,
|
|
156
159
|
disableDragEditing,
|
|
157
160
|
displayWeekNumber,
|
|
158
|
-
timezone: timezoneProp
|
|
161
|
+
timezone: timezoneProp,
|
|
162
|
+
availableRangePositions,
|
|
163
|
+
views,
|
|
164
|
+
view: inView,
|
|
165
|
+
openTo,
|
|
166
|
+
onViewChange
|
|
159
167
|
} = props,
|
|
160
168
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
161
169
|
const {
|
|
@@ -170,6 +178,17 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
170
178
|
onChange,
|
|
171
179
|
valueManager: rangeValueManager
|
|
172
180
|
});
|
|
181
|
+
const {
|
|
182
|
+
setValueAndGoToNextView,
|
|
183
|
+
view
|
|
184
|
+
} = useViews({
|
|
185
|
+
view: inView,
|
|
186
|
+
views,
|
|
187
|
+
openTo,
|
|
188
|
+
onChange: handleValueChange,
|
|
189
|
+
onViewChange,
|
|
190
|
+
autoFocus
|
|
191
|
+
});
|
|
173
192
|
const utils = useUtils();
|
|
174
193
|
const localeText = useLocaleText();
|
|
175
194
|
const now = useNow(timezone);
|
|
@@ -195,11 +214,15 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
195
214
|
utils,
|
|
196
215
|
range: value,
|
|
197
216
|
rangePosition,
|
|
198
|
-
allowRangeFlip
|
|
217
|
+
allowRangeFlip,
|
|
218
|
+
shouldMergeDateAndTime: true
|
|
199
219
|
});
|
|
200
|
-
|
|
220
|
+
const isNextSectionAvailable = availableRangePositions.includes(nextSelection);
|
|
221
|
+
if (isNextSectionAvailable) {
|
|
222
|
+
onRangePositionChange(nextSelection);
|
|
223
|
+
}
|
|
201
224
|
const isFullRangeSelected = rangePosition === 'end' && isRangeValid(utils, newRange);
|
|
202
|
-
|
|
225
|
+
setValueAndGoToNextView(newRange, isFullRangeSelected || !isNextSectionAvailable ? 'finish' : 'partial', view);
|
|
203
226
|
});
|
|
204
227
|
const handleDrop = useEventCallback(newDate => {
|
|
205
228
|
handleSelectedDayChange(newDate, undefined, true);
|
|
@@ -490,6 +513,14 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
490
513
|
* - the `input` element if there is a field rendered.
|
|
491
514
|
*/
|
|
492
515
|
autoFocus: PropTypes.bool,
|
|
516
|
+
/**
|
|
517
|
+
* Range positions available for selection.
|
|
518
|
+
* This list is checked against when checking if a next range position can be selected.
|
|
519
|
+
*
|
|
520
|
+
* Used on Date Time Range pickers with current `rangePosition` to force a `finish` selection after just one range position selection.
|
|
521
|
+
* @default ['start', 'end']
|
|
522
|
+
*/
|
|
523
|
+
availableRangePositions: PropTypes.arrayOf(PropTypes.oneOf(['end', 'start']).isRequired),
|
|
493
524
|
/**
|
|
494
525
|
* The number of calendars to render.
|
|
495
526
|
* @default 2
|
|
@@ -560,6 +591,10 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
560
591
|
* @default undefined
|
|
561
592
|
*/
|
|
562
593
|
fixedWeekNumber: PropTypes.number,
|
|
594
|
+
/**
|
|
595
|
+
* Controlled focused view.
|
|
596
|
+
*/
|
|
597
|
+
focusedView: PropTypes.oneOf(['day']),
|
|
563
598
|
/**
|
|
564
599
|
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
|
565
600
|
* Can be used to preload information and show it in calendar.
|
|
@@ -576,11 +611,20 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
576
611
|
minDate: PropTypes.any,
|
|
577
612
|
/**
|
|
578
613
|
* Callback fired when the value changes.
|
|
579
|
-
* @template
|
|
580
|
-
* @
|
|
581
|
-
* @param {
|
|
614
|
+
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
615
|
+
* @template TView The view type. Will be one of date or time views.
|
|
616
|
+
* @param {TValue} value The new value.
|
|
617
|
+
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
618
|
+
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
582
619
|
*/
|
|
583
620
|
onChange: PropTypes.func,
|
|
621
|
+
/**
|
|
622
|
+
* Callback fired on focused view change.
|
|
623
|
+
* @template TView
|
|
624
|
+
* @param {TView} view The new view to focus or not.
|
|
625
|
+
* @param {boolean} hasFocus `true` if the view should be focused.
|
|
626
|
+
*/
|
|
627
|
+
onFocusedViewChange: PropTypes.func,
|
|
584
628
|
/**
|
|
585
629
|
* Callback fired on month change.
|
|
586
630
|
* @template TDate
|
|
@@ -592,6 +636,18 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
592
636
|
* @param {RangePosition} rangePosition The new range position.
|
|
593
637
|
*/
|
|
594
638
|
onRangePositionChange: PropTypes.func,
|
|
639
|
+
/**
|
|
640
|
+
* Callback fired on view change.
|
|
641
|
+
* @template TView
|
|
642
|
+
* @param {TView} view The new view.
|
|
643
|
+
*/
|
|
644
|
+
onViewChange: PropTypes.func,
|
|
645
|
+
/**
|
|
646
|
+
* The default visible view.
|
|
647
|
+
* Used when the component view is not controlled.
|
|
648
|
+
* Must be a valid option from `views` list.
|
|
649
|
+
*/
|
|
650
|
+
openTo: PropTypes.oneOf(['day']),
|
|
595
651
|
/**
|
|
596
652
|
* The position in the currently edited date range.
|
|
597
653
|
* Used when the component position is controlled.
|
|
@@ -666,6 +722,16 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
666
722
|
* The selected value.
|
|
667
723
|
* Used when the component is controlled.
|
|
668
724
|
*/
|
|
669
|
-
value: PropTypes.arrayOf(PropTypes.any)
|
|
725
|
+
value: PropTypes.arrayOf(PropTypes.any),
|
|
726
|
+
/**
|
|
727
|
+
* The visible view.
|
|
728
|
+
* Used when the component view is controlled.
|
|
729
|
+
* Must be a valid option from `views` list.
|
|
730
|
+
*/
|
|
731
|
+
view: PropTypes.oneOf(['day']),
|
|
732
|
+
/**
|
|
733
|
+
* Available views.
|
|
734
|
+
*/
|
|
735
|
+
views: PropTypes.arrayOf(PropTypes.oneOf(['day']))
|
|
670
736
|
} : void 0;
|
|
671
737
|
export { DateRangeCalendar };
|
|
@@ -59,9 +59,6 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
59
59
|
* @default 2
|
|
60
60
|
*/
|
|
61
61
|
calendars: PropTypes.oneOf([1, 2, 3]),
|
|
62
|
-
/**
|
|
63
|
-
* Class name applied to the root element.
|
|
64
|
-
*/
|
|
65
62
|
className: PropTypes.string,
|
|
66
63
|
/**
|
|
67
64
|
* If `true`, the popover or modal will close after submitting the full date.
|
|
@@ -94,9 +94,6 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
94
94
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
95
95
|
// ----------------------------------------------------------------------
|
|
96
96
|
classes: PropTypes.object,
|
|
97
|
-
/**
|
|
98
|
-
* className applied to the root component.
|
|
99
|
-
*/
|
|
100
97
|
className: PropTypes.string,
|
|
101
98
|
disabled: PropTypes.bool,
|
|
102
99
|
/**
|