@mui/x-date-pickers-pro 7.0.0-beta.7 → 7.1.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 +266 -12
- package/DateRangeCalendar/DateRangeCalendar.js +17 -22
- package/DateRangeCalendar/useDragRange.js +1 -2
- package/DateRangePicker/DateRangePicker.js +1 -1
- package/DateRangePicker/shared.js +3 -5
- package/DateRangePickerDay/DateRangePickerDay.d.ts +5 -0
- package/DateRangePickerDay/DateRangePickerDay.js +107 -43
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +10 -0
- package/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +4 -5
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +2 -3
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +31 -15
- package/DateTimeRangePicker/shared.d.ts +5 -4
- package/DateTimeRangePicker/shared.js +9 -10
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +6 -10
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +10 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +31 -28
- package/MobileDateRangePicker/MobileDateRangePicker.js +5 -9
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +10 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +20 -14
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +17 -15
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +17 -15
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +16 -14
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +1 -1
- package/README.md +1 -1
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +8 -4
- package/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +8 -4
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +7 -3
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
- package/StaticDateRangePicker/StaticDateRangePicker.js +4 -5
- package/index.js +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +9 -11
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +26 -32
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +9 -10
- package/internals/hooks/useMultiInputFieldSelectedSections.js +3 -6
- package/internals/hooks/useRangePosition.js +3 -5
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +14 -18
- package/internals/models/dateRange.d.ts +3 -3
- package/internals/models/dateTimeRange.d.ts +2 -2
- package/internals/models/timeRange.d.ts +2 -2
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/validation/validateDateRange.js +2 -2
- package/internals/utils/validation/validateDateTimeRange.js +2 -2
- package/internals/utils/valueManagers.d.ts +3 -1
- package/internals/utils/valueManagers.js +9 -7
- package/models/fields.d.ts +8 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +1 -1
- package/modern/DateRangePicker/DateRangePicker.js +1 -1
- package/modern/DateRangePickerDay/DateRangePickerDay.js +107 -43
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +31 -15
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
- package/modern/SingleInputDateRangeField/useSingleInputDateRangeField.js +6 -2
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
- package/modern/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +6 -2
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
- package/modern/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +6 -2
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +1 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/internals/utils/valueManagers.js +7 -5
- package/node/DateRangeCalendar/DateRangeCalendar.js +1 -1
- package/node/DateRangePicker/DateRangePicker.js +1 -1
- package/node/DateRangePickerDay/DateRangePickerDay.js +107 -43
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +11 -1
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +31 -15
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +1 -1
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +20 -9
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -1
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +15 -5
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -4
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -4
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -3
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -1
- package/node/SingleInputDateRangeField/useSingleInputDateRangeField.js +7 -1
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +6 -1
- package/node/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.js +7 -1
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -0
- package/node/SingleInputTimeRangeField/useSingleInputTimeRangeField.js +7 -1
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +1 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/internals/utils/valueManagers.js +9 -6
- package/package.json +7 -7
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +0 -9
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -52
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -51
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +0 -59
|
@@ -68,26 +68,56 @@ const DateRangePickerDayRoot = styled('div', {
|
|
|
68
68
|
[`&.${dateRangePickerDayClasses.hiddenDayFiller}`]: styles.hiddenDayFiller
|
|
69
69
|
}, styles.root]
|
|
70
70
|
})(({
|
|
71
|
-
theme
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
71
|
+
theme
|
|
72
|
+
}) => ({
|
|
73
|
+
variants: [{
|
|
74
|
+
props: {
|
|
75
|
+
isHiddenDayFiller: false
|
|
76
|
+
},
|
|
77
|
+
style: {
|
|
78
|
+
[`&:first-of-type .${dateRangePickerDayClasses.rangeIntervalDayPreview}`]: _extends({}, startBorderStyle, {
|
|
79
|
+
borderLeftColor: (theme.vars || theme).palette.divider
|
|
80
|
+
}),
|
|
81
|
+
[`&:last-of-type .${dateRangePickerDayClasses.rangeIntervalDayPreview}`]: _extends({}, endBorderStyle, {
|
|
82
|
+
borderRightColor: (theme.vars || theme).palette.divider
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
props: {
|
|
87
|
+
isHiddenDayFiller: false,
|
|
88
|
+
isHighlighting: true
|
|
89
|
+
},
|
|
90
|
+
style: {
|
|
91
|
+
borderRadius: 0,
|
|
92
|
+
color: (theme.vars || theme).palette.primary.contrastText,
|
|
93
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity),
|
|
94
|
+
'&:first-of-type': startBorderStyle,
|
|
95
|
+
'&:last-of-type': endBorderStyle
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
props: ({
|
|
99
|
+
ownerState: {
|
|
100
|
+
isHiddenDayFiller,
|
|
101
|
+
isStartOfHighlighting,
|
|
102
|
+
isFirstVisibleCell
|
|
103
|
+
}
|
|
104
|
+
}) => !isHiddenDayFiller && (isStartOfHighlighting || isFirstVisibleCell),
|
|
105
|
+
style: _extends({}, startBorderStyle, {
|
|
106
|
+
paddingLeft: 0
|
|
107
|
+
})
|
|
108
|
+
}, {
|
|
109
|
+
props: ({
|
|
110
|
+
ownerState: {
|
|
111
|
+
isHiddenDayFiller,
|
|
112
|
+
isEndOfHighlighting,
|
|
113
|
+
isLastVisibleCell
|
|
114
|
+
}
|
|
115
|
+
}) => !isHiddenDayFiller && (isEndOfHighlighting || isLastVisibleCell),
|
|
116
|
+
style: _extends({}, endBorderStyle, {
|
|
117
|
+
paddingRight: 0
|
|
118
|
+
})
|
|
119
|
+
}]
|
|
120
|
+
}));
|
|
91
121
|
DateRangePickerDayRoot.propTypes = {
|
|
92
122
|
// ----------------------------- Warning --------------------------------
|
|
93
123
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -106,21 +136,47 @@ const DateRangePickerDayRangeIntervalPreview = styled('div', {
|
|
|
106
136
|
[`&.${dateRangePickerDayClasses.rangeIntervalDayPreviewEnd}`]: styles.rangeIntervalDayPreviewEnd
|
|
107
137
|
}, styles.rangeIntervalPreview]
|
|
108
138
|
})(({
|
|
109
|
-
theme
|
|
110
|
-
|
|
111
|
-
}) => _extends({
|
|
139
|
+
theme
|
|
140
|
+
}) => ({
|
|
112
141
|
// replace default day component margin with transparent border to avoid jumping on preview
|
|
113
|
-
border: '2px solid transparent'
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
142
|
+
border: '2px solid transparent',
|
|
143
|
+
variants: [{
|
|
144
|
+
props: {
|
|
145
|
+
isPreviewing: true,
|
|
146
|
+
isHiddenDayFiller: false
|
|
147
|
+
},
|
|
148
|
+
style: {
|
|
149
|
+
borderRadius: 0,
|
|
150
|
+
border: `2px dashed ${(theme.vars || theme).palette.divider}`,
|
|
151
|
+
borderLeftColor: 'transparent',
|
|
152
|
+
borderRightColor: 'transparent'
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
props: ({
|
|
156
|
+
ownerState: {
|
|
157
|
+
isPreviewing,
|
|
158
|
+
isHiddenDayFiller,
|
|
159
|
+
isStartOfPreviewing,
|
|
160
|
+
isFirstVisibleCell
|
|
161
|
+
}
|
|
162
|
+
}) => isPreviewing && !isHiddenDayFiller && (isStartOfPreviewing || isFirstVisibleCell),
|
|
163
|
+
style: _extends({
|
|
164
|
+
borderLeftColor: (theme.vars || theme).palette.divider
|
|
165
|
+
}, startBorderStyle)
|
|
166
|
+
}, {
|
|
167
|
+
props: ({
|
|
168
|
+
ownerState: {
|
|
169
|
+
isPreviewing,
|
|
170
|
+
isHiddenDayFiller,
|
|
171
|
+
isEndOfPreviewing,
|
|
172
|
+
isLastVisibleCell
|
|
173
|
+
}
|
|
174
|
+
}) => isPreviewing && !isHiddenDayFiller && (isEndOfPreviewing || isLastVisibleCell),
|
|
175
|
+
style: _extends({
|
|
176
|
+
borderRightColor: (theme.vars || theme).palette.divider
|
|
177
|
+
}, endBorderStyle)
|
|
178
|
+
}]
|
|
179
|
+
}));
|
|
124
180
|
DateRangePickerDayRangeIntervalPreview.propTypes = {
|
|
125
181
|
// ----------------------------- Warning --------------------------------
|
|
126
182
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -138,19 +194,22 @@ const DateRangePickerDayDay = styled(PickersDay, {
|
|
|
138
194
|
}, {
|
|
139
195
|
[`&.${dateRangePickerDayClasses.notSelectedDate}`]: styles.notSelectedDate
|
|
140
196
|
}, styles.day]
|
|
141
|
-
})(
|
|
142
|
-
ownerState
|
|
143
|
-
}) => _extends({
|
|
197
|
+
})({
|
|
144
198
|
// Required to overlap preview border
|
|
145
199
|
transform: 'scale(1.1)',
|
|
146
200
|
'& > *': {
|
|
147
201
|
transform: 'scale(0.9)'
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
202
|
+
},
|
|
203
|
+
variants: [{
|
|
204
|
+
props: {
|
|
205
|
+
draggable: true
|
|
206
|
+
},
|
|
207
|
+
style: {
|
|
208
|
+
cursor: 'grab',
|
|
209
|
+
touchAction: 'none'
|
|
210
|
+
}
|
|
211
|
+
}]
|
|
212
|
+
});
|
|
154
213
|
const DateRangePickerDayRaw = /*#__PURE__*/React.forwardRef(function DateRangePickerDay(inProps, ref) {
|
|
155
214
|
const props = useThemeProps({
|
|
156
215
|
props: inProps,
|
|
@@ -266,6 +325,11 @@ process.env.NODE_ENV !== "production" ? DateRangePickerDayRaw.propTypes = {
|
|
|
266
325
|
* @default false
|
|
267
326
|
*/
|
|
268
327
|
disableTouchRipple: PropTypes.bool,
|
|
328
|
+
/**
|
|
329
|
+
* If `true`, the day can be dragged to change the current date range.
|
|
330
|
+
* @default false
|
|
331
|
+
*/
|
|
332
|
+
draggable: PropTypes.bool,
|
|
269
333
|
/**
|
|
270
334
|
* If `true`, the base button will have a keyboard focus ripple.
|
|
271
335
|
* @default false
|
|
@@ -4,5 +4,15 @@ import { DateTimeRangePickerProps } from './DateTimeRangePicker.types';
|
|
|
4
4
|
type DateTimeRangePickerComponent = (<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false>(props: DateTimeRangePickerProps<TDate, TEnableAccessibleFieldDOMStructure> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
5
5
|
propTypes?: any;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Demos:
|
|
9
|
+
*
|
|
10
|
+
* - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
|
|
11
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
12
|
+
*
|
|
13
|
+
* API:
|
|
14
|
+
*
|
|
15
|
+
* - [DateTimeRangePicker API](https://mui.com/x/api/date-pickers/date-time-range-picker/)
|
|
16
|
+
*/
|
|
7
17
|
declare const DateTimeRangePicker: DateTimeRangePickerComponent;
|
|
8
18
|
export { DateTimeRangePicker };
|
|
@@ -9,6 +9,16 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
9
9
|
import { DesktopDateTimeRangePicker } from '../DesktopDateTimeRangePicker';
|
|
10
10
|
import { MobileDateTimeRangePicker } from '../MobileDateTimeRangePicker';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* Demos:
|
|
14
|
+
*
|
|
15
|
+
* - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
|
|
16
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
17
|
+
*
|
|
18
|
+
* API:
|
|
19
|
+
*
|
|
20
|
+
* - [DateTimeRangePicker API](https://mui.com/x/api/date-pickers/date-time-range-picker/)
|
|
21
|
+
*/
|
|
12
22
|
const DateTimeRangePicker = /*#__PURE__*/React.forwardRef(function DateTimeRangePicker(inProps, ref) {
|
|
13
23
|
const props = useThemeProps({
|
|
14
24
|
props: inProps,
|
|
@@ -312,7 +322,7 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
312
322
|
/**
|
|
313
323
|
* Disable specific date.
|
|
314
324
|
*
|
|
315
|
-
* Warning: This function can be called multiple times (
|
|
325
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
316
326
|
*
|
|
317
327
|
* @template TDate
|
|
318
328
|
* @param {TDate} day The date to test.
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { PickerSelectionState, PickerViewRenderer, TimeViewWithMeridiem, BaseClockProps } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { PickerSelectionState, PickerViewRenderer, TimeViewWithMeridiem, BaseClockProps, DefaultizedProps } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
4
|
-
import { DateTimeRangePickerView } from '../internals/models';
|
|
5
4
|
import { DateRange } from '../models';
|
|
6
5
|
import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
|
|
7
|
-
export type DateTimeRangePickerTimeWrapperProps<TDate extends PickerValidDate, TView extends
|
|
6
|
+
export type DateTimeRangePickerTimeWrapperProps<TDate extends PickerValidDate, TView extends TimeViewWithMeridiem, TComponentProps extends DefaultizedProps<Omit<BaseClockProps<TDate, TView>, 'value' | 'defaultValue' | 'onChange'>, 'views'>> = Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> & Omit<TComponentProps, 'views' | 'view' | 'onViewChange' | 'value' | 'defaultValue' | 'onChange'> & {
|
|
8
7
|
view: TView;
|
|
9
8
|
onViewChange?: (view: TView) => void;
|
|
10
9
|
views: readonly TView[];
|
|
11
10
|
value?: DateRange<TDate>;
|
|
12
11
|
defaultValue?: DateRange<TDate>;
|
|
13
12
|
onChange?: (value: DateRange<TDate>, selectionState: PickerSelectionState, selectedView: TView) => void;
|
|
14
|
-
viewRenderer?: PickerViewRenderer<DateRange<TDate>, TView,
|
|
13
|
+
viewRenderer?: PickerViewRenderer<DateRange<TDate>, TView, TComponentProps, any> | null;
|
|
15
14
|
openTo?: TView;
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
17
|
* @ignore - internal component.
|
|
19
18
|
*/
|
|
20
|
-
declare function DateTimeRangePickerTimeWrapper<TDate extends PickerValidDate, TView extends
|
|
19
|
+
declare function DateTimeRangePickerTimeWrapper<TDate extends PickerValidDate, TView extends TimeViewWithMeridiem, TComponentProps extends DefaultizedProps<Omit<BaseClockProps<TDate, TView>, 'value' | 'defaultValue' | 'onChange'>, 'views'>>(props: DateTimeRangePickerTimeWrapperProps<TDate, TView, TComponentProps>, ref: React.Ref<HTMLDivElement>): React.ReactNode;
|
|
21
20
|
export { DateTimeRangePickerTimeWrapper };
|
|
@@ -8,7 +8,6 @@ import { calculateRangeChange } from '../internals/utils/date-range-manager';
|
|
|
8
8
|
* @ignore - internal component.
|
|
9
9
|
*/
|
|
10
10
|
function DateTimeRangePickerTimeWrapper(props, ref) {
|
|
11
|
-
var _ref, _ref2;
|
|
12
11
|
const utils = useUtils();
|
|
13
12
|
const {
|
|
14
13
|
rangePosition,
|
|
@@ -24,8 +23,8 @@ function DateTimeRangePickerTimeWrapper(props, ref) {
|
|
|
24
23
|
if (!viewRenderer) {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
27
|
-
const currentValue = (
|
|
28
|
-
const currentDefaultValue = (
|
|
26
|
+
const currentValue = (rangePosition === 'start' ? value?.[0] : value?.[1]) ?? null;
|
|
27
|
+
const currentDefaultValue = (rangePosition === 'start' ? defaultValue?.[0] : defaultValue?.[1]) ?? null;
|
|
29
28
|
const handleOnChange = (newDate, selectionState, selectedView) => {
|
|
30
29
|
if (!onChange || !value) {
|
|
31
30
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["value", "rangePosition", "onRangePositionChange", "className", "onViewChange", "toolbarVariant", "onChange", "classes", "view", "isLandscape", "views", "ampm", "disabled", "readOnly", "hidden", "toolbarFormat", "toolbarPlaceholder", "titleId", "sx"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
@@ -35,24 +35,40 @@ const DateTimeRangePickerToolbarStart = styled(DateTimePickerToolbar, {
|
|
|
35
35
|
name: 'MuiDateTimeRangePickerToolbar',
|
|
36
36
|
slot: 'StartToolbar',
|
|
37
37
|
overridesResolver: (_, styles) => styles.startToolbar
|
|
38
|
-
})(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
38
|
+
})({
|
|
39
|
+
borderBottom: 'none',
|
|
40
|
+
variants: [{
|
|
41
|
+
props: ({
|
|
42
|
+
toolbarVariant
|
|
43
|
+
}) => toolbarVariant !== 'desktop',
|
|
44
|
+
style: {
|
|
45
|
+
padding: '12px 8px 0 12px'
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
props: {
|
|
49
|
+
toolbarVariant: 'desktop'
|
|
50
|
+
},
|
|
51
|
+
style: {
|
|
52
|
+
paddingBottom: 0
|
|
53
|
+
}
|
|
54
|
+
}]
|
|
55
|
+
});
|
|
47
56
|
const DateTimeRangePickerToolbarEnd = styled(DateTimePickerToolbar, {
|
|
48
57
|
name: 'MuiDateTimeRangePickerToolbar',
|
|
49
58
|
slot: 'EndToolbar',
|
|
50
59
|
overridesResolver: (_, styles) => styles.endToolbar
|
|
51
|
-
})(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
})({
|
|
61
|
+
variants: [{
|
|
62
|
+
props: ({
|
|
63
|
+
ownerState: {
|
|
64
|
+
toolbarVariant
|
|
65
|
+
}
|
|
66
|
+
}) => toolbarVariant !== 'desktop',
|
|
67
|
+
style: {
|
|
68
|
+
padding: '12px 8px 12px 12px'
|
|
69
|
+
}
|
|
70
|
+
}]
|
|
71
|
+
});
|
|
56
72
|
const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTimeRangePickerToolbar(inProps, ref) {
|
|
57
73
|
const props = useThemeProps({
|
|
58
74
|
props: inProps,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LocalizedComponent } from '@mui/x-date-pickers/locales';
|
|
3
|
-
import { DefaultizedProps, BaseDateValidationProps, BasePickerInputProps, PickerViewRendererLookup, BaseClockProps, DesktopOnlyTimePickerProps, TimeViewWithMeridiem, UseViewsOptions, DateTimeValidationProps } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { DefaultizedProps, BaseDateValidationProps, BasePickerInputProps, PickerViewRendererLookup, BaseClockProps, DesktopOnlyTimePickerProps, TimeViewWithMeridiem, UseViewsOptions, DateTimeValidationProps, DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
|
|
4
4
|
import { PickerValidDate } from '@mui/x-date-pickers/models';
|
|
5
5
|
import { TimeViewRendererProps } from '@mui/x-date-pickers/timeViewRenderers';
|
|
6
6
|
import { DigitalClockSlots, DigitalClockSlotProps } from '@mui/x-date-pickers/DigitalClock';
|
|
@@ -33,6 +33,9 @@ export interface BaseDateTimeRangePickerSlotProps<TDate extends PickerValidDate>
|
|
|
33
33
|
*/
|
|
34
34
|
toolbar?: ExportedDateTimeRangePickerToolbarProps;
|
|
35
35
|
}
|
|
36
|
+
export type DateTimeRangePickerRenderers<TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TAdditionalProps extends {} = {}> = PickerViewRendererLookup<DateRange<TDate>, TView, Omit<DateRangeViewRendererProps<TDate, 'day'>, 'view' | 'slots' | 'slotProps'> & Omit<TimeViewRendererProps<TimeViewWithMeridiem, BaseClockProps<TDate, TimeViewWithMeridiem>>, 'view' | 'slots' | 'slotProps'> & {
|
|
37
|
+
view: TView;
|
|
38
|
+
}, TAdditionalProps>;
|
|
36
39
|
export interface BaseDateTimeRangePickerProps<TDate extends PickerValidDate> extends Omit<BasePickerInputProps<DateRange<TDate>, TDate, DateTimeRangePickerView, DateTimeRangeValidationError>, 'orientation' | 'views' | 'openTo'>, ExportedDateRangeCalendarProps<TDate>, BaseDateValidationProps<TDate>, DesktopOnlyTimePickerProps<TDate>, Partial<Pick<UseViewsOptions<DateRange<TDate>, DateTimeRangePickerViewExternal>, 'openTo' | 'views'>>, DateTimeValidationProps<TDate> {
|
|
37
40
|
/**
|
|
38
41
|
* Overridable component slots.
|
|
@@ -49,9 +52,7 @@ export interface BaseDateTimeRangePickerProps<TDate extends PickerValidDate> ext
|
|
|
49
52
|
* If `null`, the section will only have field editing.
|
|
50
53
|
* If `undefined`, internally defined view will be the used.
|
|
51
54
|
*/
|
|
52
|
-
viewRenderers?: Partial<
|
|
53
|
-
view: DateTimeRangePickerView;
|
|
54
|
-
}, {}>>;
|
|
55
|
+
viewRenderers?: Partial<DateTimeRangePickerRenderers<TDate, DateTimeRangePickerView>>;
|
|
55
56
|
}
|
|
56
57
|
type UseDateTimeRangePickerDefaultizedProps<TDate extends PickerValidDate, Props extends BaseDateTimeRangePickerProps<TDate>> = LocalizedComponent<TDate, Omit<DefaultizedProps<Props, 'openTo' | 'ampm' | keyof BaseDateValidationProps<TDate>>, 'views'>> & {
|
|
57
58
|
shouldRenderTimeInASingleColumn: boolean;
|
|
@@ -4,14 +4,13 @@ import { useDefaultDates, useUtils, applyDefaultDate, applyDefaultViewProps, res
|
|
|
4
4
|
import { DateTimeRangePickerToolbar } from './DateTimeRangePickerToolbar';
|
|
5
5
|
import { DateTimeRangePickerTabs } from './DateTimeRangePickerTabs';
|
|
6
6
|
export function useDateTimeRangePickerDefaultizedProps(props, name) {
|
|
7
|
-
var _themeProps$ampm, _themeProps$disableFu, _themeProps$disablePa, _themeProps$minDateTi, _themeProps$maxDateTi, _themeProps$minDateTi2, _themeProps$maxDateTi2, _themeProps$disableIg, _themeProps$slotProps;
|
|
8
7
|
const utils = useUtils();
|
|
9
8
|
const defaultDates = useDefaultDates();
|
|
10
9
|
const themeProps = useThemeProps({
|
|
11
10
|
props,
|
|
12
11
|
name
|
|
13
12
|
});
|
|
14
|
-
const ampm =
|
|
13
|
+
const ampm = themeProps.ampm ?? utils.is12HourCycleInCurrentLocale();
|
|
15
14
|
const {
|
|
16
15
|
openTo,
|
|
17
16
|
views: defaultViews
|
|
@@ -39,13 +38,13 @@ export function useDateTimeRangePickerDefaultizedProps(props, name) {
|
|
|
39
38
|
thresholdToRenderTimeInASingleColumn,
|
|
40
39
|
views,
|
|
41
40
|
ampm,
|
|
42
|
-
disableFuture:
|
|
43
|
-
disablePast:
|
|
44
|
-
minDate: applyDefaultDate(utils,
|
|
45
|
-
maxDate: applyDefaultDate(utils,
|
|
46
|
-
minTime:
|
|
47
|
-
maxTime:
|
|
48
|
-
disableIgnoringDatePartForTimeValidation:
|
|
41
|
+
disableFuture: themeProps.disableFuture ?? false,
|
|
42
|
+
disablePast: themeProps.disablePast ?? false,
|
|
43
|
+
minDate: applyDefaultDate(utils, themeProps.minDateTime ?? themeProps.minDate, defaultDates.minDate),
|
|
44
|
+
maxDate: applyDefaultDate(utils, themeProps.maxDateTime ?? themeProps.maxDate, defaultDates.maxDate),
|
|
45
|
+
minTime: themeProps.minDateTime ?? themeProps.minTime,
|
|
46
|
+
maxTime: themeProps.maxDateTime ?? themeProps.maxTime,
|
|
47
|
+
disableIgnoringDatePartForTimeValidation: themeProps.disableIgnoringDatePartForTimeValidation ?? Boolean(themeProps.minDateTime || themeProps.maxDateTime ||
|
|
49
48
|
// allow digital clocks to correctly check time validity: https://github.com/mui/mui-x/issues/12048
|
|
50
49
|
themeProps.disablePast || themeProps.disableFuture),
|
|
51
50
|
slots: _extends({
|
|
@@ -53,7 +52,7 @@ export function useDateTimeRangePickerDefaultizedProps(props, name) {
|
|
|
53
52
|
toolbar: DateTimeRangePickerToolbar
|
|
54
53
|
}, themeProps.slots),
|
|
55
54
|
slotProps: _extends({}, themeProps.slotProps, {
|
|
56
|
-
toolbar: _extends({},
|
|
55
|
+
toolbar: _extends({}, themeProps.slotProps?.toolbar, {
|
|
57
56
|
ampm
|
|
58
57
|
})
|
|
59
58
|
})
|
|
@@ -21,7 +21,6 @@ import { validateDateRange } from '../internals/utils/validation/validateDateRan
|
|
|
21
21
|
* - [DesktopDateRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-range-picker/)
|
|
22
22
|
*/
|
|
23
23
|
const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateRangePicker(inProps, ref) {
|
|
24
|
-
var _defaultizedProps$cal, _defaultizedProps$slo2;
|
|
25
24
|
// Props with the default values common to all date time pickers
|
|
26
25
|
const defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiDesktopDateRangePicker');
|
|
27
26
|
const viewRenderers = _extends({
|
|
@@ -29,22 +28,19 @@ const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDat
|
|
|
29
28
|
}, defaultizedProps.viewRenderers);
|
|
30
29
|
const props = _extends({}, defaultizedProps, {
|
|
31
30
|
viewRenderers,
|
|
32
|
-
calendars:
|
|
31
|
+
calendars: defaultizedProps.calendars ?? 2,
|
|
33
32
|
views: ['day'],
|
|
34
33
|
openTo: 'day',
|
|
35
34
|
slots: _extends({
|
|
36
35
|
field: MultiInputDateRangeField
|
|
37
36
|
}, defaultizedProps.slots),
|
|
38
37
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
39
|
-
field: ownerState => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
ref
|
|
43
|
-
});
|
|
44
|
-
},
|
|
38
|
+
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
39
|
+
ref
|
|
40
|
+
}),
|
|
45
41
|
toolbar: _extends({
|
|
46
42
|
hidden: true
|
|
47
|
-
},
|
|
43
|
+
}, defaultizedProps.slotProps?.toolbar)
|
|
48
44
|
})
|
|
49
45
|
});
|
|
50
46
|
const {
|
|
@@ -286,7 +282,7 @@ DesktopDateRangePicker.propTypes = {
|
|
|
286
282
|
/**
|
|
287
283
|
* Disable specific date.
|
|
288
284
|
*
|
|
289
|
-
* Warning: This function can be called multiple times (
|
|
285
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
290
286
|
*
|
|
291
287
|
* @template TDate
|
|
292
288
|
* @param {TDate} day The date to test.
|
|
@@ -4,5 +4,15 @@ import { DesktopDateTimeRangePickerProps } from './DesktopDateTimeRangePicker.ty
|
|
|
4
4
|
type DesktopDateRangePickerComponent = (<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false>(props: DesktopDateTimeRangePickerProps<TDate, TEnableAccessibleFieldDOMStructure> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
5
5
|
propTypes?: any;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Demos:
|
|
9
|
+
*
|
|
10
|
+
* - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
|
|
11
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
12
|
+
*
|
|
13
|
+
* API:
|
|
14
|
+
*
|
|
15
|
+
* - [DesktopDateTimeRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-range-picker/)
|
|
16
|
+
*/
|
|
7
17
|
declare const DesktopDateTimeRangePicker: DesktopDateRangePickerComponent;
|
|
8
18
|
export { DesktopDateTimeRangePicker };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["openTo", "rangePosition"
|
|
3
|
+
const _excluded = ["openTo", "rangePosition"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { extractValidationProps, isDatePickerView, isInternalTimeView } from '@mui/x-date-pickers/internals';
|
|
@@ -10,6 +10,7 @@ import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } fr
|
|
|
10
10
|
import { multiSectionDigitalClockClasses, multiSectionDigitalClockSectionClasses } from '@mui/x-date-pickers/MultiSectionDigitalClock';
|
|
11
11
|
import Divider from '@mui/material/Divider';
|
|
12
12
|
import { digitalClockClasses } from '@mui/x-date-pickers/DigitalClock';
|
|
13
|
+
import { DesktopDateTimePickerLayout } from '@mui/x-date-pickers/DesktopDateTimePicker';
|
|
13
14
|
import { rangeValueManager } from '../internals/utils/valueManagers';
|
|
14
15
|
import { renderDateRangeViewCalendar } from '../dateRangeViewRenderers';
|
|
15
16
|
import { useDesktopRangePicker } from '../internals/hooks/useDesktopRangePicker';
|
|
@@ -18,31 +19,29 @@ import { useDateTimeRangePickerDefaultizedProps } from '../DateTimeRangePicker/s
|
|
|
18
19
|
import { MultiInputDateTimeRangeField } from '../MultiInputDateTimeRangeField';
|
|
19
20
|
import { DateTimeRangePickerTimeWrapper } from '../DateTimeRangePicker/DateTimeRangePickerTimeWrapper';
|
|
20
21
|
import { RANGE_VIEW_HEIGHT } from '../internals/constants/dimensions';
|
|
21
|
-
import { DesktopDateTimeRangePickerLayout } from './DesktopDateTimeRangePickerLayout';
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
const rendererInterceptor = function rendererInterceptor(inViewRenderers, popperView, rendererProps) {
|
|
25
|
-
var _inViewRenderers$day;
|
|
26
25
|
const {
|
|
27
26
|
openTo,
|
|
28
|
-
rangePosition
|
|
29
|
-
sx
|
|
27
|
+
rangePosition
|
|
30
28
|
} = rendererProps,
|
|
31
29
|
otherProps = _objectWithoutPropertiesLoose(rendererProps, _excluded);
|
|
32
30
|
const finalProps = _extends({}, otherProps, {
|
|
33
31
|
rangePosition,
|
|
34
32
|
focusedView: null,
|
|
35
33
|
sx: [{
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
[`&.${multiSectionDigitalClockClasses.root}`]: {
|
|
35
|
+
borderBottom: 0
|
|
36
|
+
},
|
|
38
37
|
[`&.${multiSectionDigitalClockClasses.root}, .${multiSectionDigitalClockSectionClasses.root}, &.${digitalClockClasses.root}`]: {
|
|
39
38
|
maxHeight: RANGE_VIEW_HEIGHT
|
|
40
39
|
}
|
|
41
|
-
}
|
|
40
|
+
}]
|
|
42
41
|
});
|
|
43
42
|
const isTimeViewActive = isInternalTimeView(popperView);
|
|
44
43
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
45
|
-
children: [
|
|
44
|
+
children: [inViewRenderers.day?.(_extends({}, rendererProps, {
|
|
46
45
|
availableRangePositions: [rangePosition],
|
|
47
46
|
view: !isTimeViewActive ? popperView : 'day',
|
|
48
47
|
views: rendererProps.views.filter(isDatePickerView)
|
|
@@ -50,13 +49,23 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
|
|
|
50
49
|
orientation: "vertical"
|
|
51
50
|
}), /*#__PURE__*/_jsx(DateTimeRangePickerTimeWrapper, _extends({}, finalProps, {
|
|
52
51
|
view: isTimeViewActive ? popperView : 'hours',
|
|
52
|
+
views: finalProps.views.filter(isInternalTimeView),
|
|
53
53
|
openTo: isInternalTimeView(openTo) ? openTo : 'hours',
|
|
54
54
|
viewRenderer: inViewRenderers[isTimeViewActive ? popperView : 'hours']
|
|
55
55
|
}))]
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Demos:
|
|
60
|
+
*
|
|
61
|
+
* - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
|
|
62
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
63
|
+
*
|
|
64
|
+
* API:
|
|
65
|
+
*
|
|
66
|
+
* - [DesktopDateTimeRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-range-picker/)
|
|
67
|
+
*/
|
|
58
68
|
const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimeRangePicker(inProps, ref) {
|
|
59
|
-
var _viewRenderers$hours, _defaultizedProps$cal, _defaultizedProps$slo2, _defaultizedProps$slo3;
|
|
60
69
|
// Props with the default values common to all date time range pickers
|
|
61
70
|
const defaultizedProps = useDateTimeRangePickerDefaultizedProps(inProps, 'MuiDesktopDateTimeRangePicker');
|
|
62
71
|
const renderTimeView = defaultizedProps.shouldRenderTimeInASingleColumn ? renderDigitalClockTimeView : renderMultiSectionDigitalClockTimeView;
|
|
@@ -69,7 +78,7 @@ const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
|
|
|
69
78
|
}, defaultizedProps.viewRenderers);
|
|
70
79
|
|
|
71
80
|
// Need to avoid adding the `meridiem` view when unexpected renderer is specified
|
|
72
|
-
const shouldHoursRendererContainMeridiemView =
|
|
81
|
+
const shouldHoursRendererContainMeridiemView = viewRenderers.hours?.name === renderMultiSectionDigitalClockTimeView.name;
|
|
73
82
|
const views = !shouldHoursRendererContainMeridiemView ? defaultizedProps.views.filter(view => view !== 'meridiem') : defaultizedProps.views;
|
|
74
83
|
const actionBarActions = defaultizedProps.shouldRenderTimeInASingleColumn ? [] : ['accept'];
|
|
75
84
|
const props = _extends({}, defaultizedProps, {
|
|
@@ -77,31 +86,25 @@ const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
|
|
|
77
86
|
viewRenderers,
|
|
78
87
|
// force true to correctly handle `renderTimeViewClock` as a renderer
|
|
79
88
|
ampmInClock: true,
|
|
80
|
-
calendars:
|
|
89
|
+
calendars: defaultizedProps.calendars ?? 1,
|
|
81
90
|
slots: _extends({
|
|
82
91
|
field: MultiInputDateTimeRangeField,
|
|
83
|
-
layout:
|
|
92
|
+
layout: DesktopDateTimePickerLayout
|
|
84
93
|
}, defaultizedProps.slots),
|
|
85
94
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
86
|
-
field: ownerState => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
ref
|
|
90
|
-
});
|
|
91
|
-
},
|
|
95
|
+
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
96
|
+
ref
|
|
97
|
+
}),
|
|
92
98
|
tabs: _extends({
|
|
93
99
|
hidden: true
|
|
94
|
-
},
|
|
100
|
+
}, defaultizedProps.slotProps?.tabs),
|
|
95
101
|
toolbar: _extends({
|
|
96
102
|
hidden: true,
|
|
97
103
|
toolbarVariant: 'desktop'
|
|
98
|
-
},
|
|
99
|
-
actionBar: ownerState => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
actions: actionBarActions
|
|
103
|
-
}, resolveComponentProps((_defaultizedProps$slo4 = defaultizedProps.slotProps) == null ? void 0 : _defaultizedProps$slo4.actionBar, ownerState));
|
|
104
|
-
}
|
|
104
|
+
}, defaultizedProps.slotProps?.toolbar),
|
|
105
|
+
actionBar: ownerState => _extends({
|
|
106
|
+
actions: actionBarActions
|
|
107
|
+
}, resolveComponentProps(defaultizedProps.slotProps?.actionBar, ownerState))
|
|
105
108
|
})
|
|
106
109
|
});
|
|
107
110
|
const {
|
|
@@ -389,7 +392,7 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
389
392
|
/**
|
|
390
393
|
* Disable specific date.
|
|
391
394
|
*
|
|
392
|
-
* Warning: This function can be called multiple times (
|
|
395
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
393
396
|
*
|
|
394
397
|
* @template TDate
|
|
395
398
|
* @param {TDate} day The date to test.
|