@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
|
|
@@ -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,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,
|
|
@@ -282,7 +282,7 @@ DesktopDateRangePicker.propTypes = {
|
|
|
282
282
|
/**
|
|
283
283
|
* Disable specific date.
|
|
284
284
|
*
|
|
285
|
-
* 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.
|
|
286
286
|
*
|
|
287
287
|
* @template TDate
|
|
288
288
|
* @param {TDate} day The date to test.
|
|
@@ -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,26 +19,25 @@ 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
25
|
const {
|
|
26
26
|
openTo,
|
|
27
|
-
rangePosition
|
|
28
|
-
sx
|
|
27
|
+
rangePosition
|
|
29
28
|
} = rendererProps,
|
|
30
29
|
otherProps = _objectWithoutPropertiesLoose(rendererProps, _excluded);
|
|
31
30
|
const finalProps = _extends({}, otherProps, {
|
|
32
31
|
rangePosition,
|
|
33
32
|
focusedView: null,
|
|
34
33
|
sx: [{
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
[`&.${multiSectionDigitalClockClasses.root}`]: {
|
|
35
|
+
borderBottom: 0
|
|
36
|
+
},
|
|
37
37
|
[`&.${multiSectionDigitalClockClasses.root}, .${multiSectionDigitalClockSectionClasses.root}, &.${digitalClockClasses.root}`]: {
|
|
38
38
|
maxHeight: RANGE_VIEW_HEIGHT
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}]
|
|
41
41
|
});
|
|
42
42
|
const isTimeViewActive = isInternalTimeView(popperView);
|
|
43
43
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -49,11 +49,22 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
|
|
|
49
49
|
orientation: "vertical"
|
|
50
50
|
}), /*#__PURE__*/_jsx(DateTimeRangePickerTimeWrapper, _extends({}, finalProps, {
|
|
51
51
|
view: isTimeViewActive ? popperView : 'hours',
|
|
52
|
+
views: finalProps.views.filter(isInternalTimeView),
|
|
52
53
|
openTo: isInternalTimeView(openTo) ? openTo : 'hours',
|
|
53
54
|
viewRenderer: inViewRenderers[isTimeViewActive ? popperView : 'hours']
|
|
54
55
|
}))]
|
|
55
56
|
});
|
|
56
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
|
+
*/
|
|
57
68
|
const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimeRangePicker(inProps, ref) {
|
|
58
69
|
// Props with the default values common to all date time range pickers
|
|
59
70
|
const defaultizedProps = useDateTimeRangePickerDefaultizedProps(inProps, 'MuiDesktopDateTimeRangePicker');
|
|
@@ -78,7 +89,7 @@ const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
|
|
|
78
89
|
calendars: defaultizedProps.calendars ?? 1,
|
|
79
90
|
slots: _extends({
|
|
80
91
|
field: MultiInputDateTimeRangeField,
|
|
81
|
-
layout:
|
|
92
|
+
layout: DesktopDateTimePickerLayout
|
|
82
93
|
}, defaultizedProps.slots),
|
|
83
94
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
84
95
|
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
@@ -381,7 +392,7 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
381
392
|
/**
|
|
382
393
|
* Disable specific date.
|
|
383
394
|
*
|
|
384
|
-
* 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.
|
|
385
396
|
*
|
|
386
397
|
* @template TDate
|
|
387
398
|
* @param {TDate} day The date to test.
|
|
@@ -278,7 +278,7 @@ MobileDateRangePicker.propTypes = {
|
|
|
278
278
|
/**
|
|
279
279
|
* Disable specific date.
|
|
280
280
|
*
|
|
281
|
-
* Warning: This function can be called multiple times (
|
|
281
|
+
* 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.
|
|
282
282
|
*
|
|
283
283
|
* @template TDate
|
|
284
284
|
* @param {TDate} day The date to test.
|
|
@@ -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 = ["view", "openTo", "rangePosition"
|
|
3
|
+
const _excluded = ["view", "openTo", "rangePosition"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { refType } from '@mui/utils';
|
|
@@ -22,8 +22,7 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
|
|
|
22
22
|
const {
|
|
23
23
|
view,
|
|
24
24
|
openTo,
|
|
25
|
-
rangePosition
|
|
26
|
-
sx
|
|
25
|
+
rangePosition
|
|
27
26
|
} = rendererProps,
|
|
28
27
|
otherRendererProps = _objectWithoutPropertiesLoose(rendererProps, _excluded);
|
|
29
28
|
const finalProps = _extends({}, otherRendererProps, {
|
|
@@ -48,7 +47,7 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
|
|
|
48
47
|
[`&.${multiSectionDigitalClockClasses.root}, .${multiSectionDigitalClockSectionClasses.root}`]: {
|
|
49
48
|
maxHeight: RANGE_VIEW_HEIGHT - 1
|
|
50
49
|
}
|
|
51
|
-
}
|
|
50
|
+
}]
|
|
52
51
|
});
|
|
53
52
|
const isTimeView = isInternalTimeView(popperView);
|
|
54
53
|
const viewRenderer = inViewRenderers[popperView];
|
|
@@ -59,6 +58,7 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
|
|
|
59
58
|
return /*#__PURE__*/_jsx(DateTimeRangePickerTimeWrapper, _extends({}, finalProps, {
|
|
60
59
|
viewRenderer: viewRenderer,
|
|
61
60
|
view: view && isInternalTimeView(view) ? view : 'hours',
|
|
61
|
+
views: finalProps.views,
|
|
62
62
|
openTo: isInternalTimeView(openTo) ? openTo : 'hours'
|
|
63
63
|
}));
|
|
64
64
|
}
|
|
@@ -71,6 +71,16 @@ const rendererInterceptor = function rendererInterceptor(inViewRenderers, popper
|
|
|
71
71
|
openTo: isDatePickerView(openTo) ? openTo : 'day'
|
|
72
72
|
}));
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Demos:
|
|
76
|
+
*
|
|
77
|
+
* - [DateTimeRangePicker](https://mui.com/x/react-date-pickers/date-time-range-picker/)
|
|
78
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
79
|
+
*
|
|
80
|
+
* API:
|
|
81
|
+
*
|
|
82
|
+
* - [MobileDateTimeRangePicker API](https://mui.com/x/api/date-pickers/mobile-date-time-range-picker/)
|
|
83
|
+
*/
|
|
74
84
|
const MobileDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateTimeRangePicker(inProps, ref) {
|
|
75
85
|
// Props with the default values common to all date time range pickers
|
|
76
86
|
const defaultizedProps = useDateTimeRangePickerDefaultizedProps(inProps, 'MuiMobileDateTimeRangePicker');
|
|
@@ -384,7 +394,7 @@ MobileDateTimeRangePicker.propTypes = {
|
|
|
384
394
|
/**
|
|
385
395
|
* Disable specific date.
|
|
386
396
|
*
|
|
387
|
-
* Warning: This function can be called multiple times (
|
|
397
|
+
* 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.
|
|
388
398
|
*
|
|
389
399
|
* @template TDate
|
|
390
400
|
* @param {TDate} day The date to test.
|
|
@@ -37,9 +37,7 @@ const MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
|
|
|
37
37
|
slot: 'Root',
|
|
38
38
|
overridesResolver: (props, styles) => styles.root
|
|
39
39
|
})({});
|
|
40
|
-
const MultiInputDateRangeFieldSeparator = styled(
|
|
41
|
-
children: props.children ?? ' – '
|
|
42
|
-
})), {
|
|
40
|
+
const MultiInputDateRangeFieldSeparator = styled(Typography, {
|
|
43
41
|
name: 'MuiMultiInputDateRangeField',
|
|
44
42
|
slot: 'Separator',
|
|
45
43
|
overridesResolver: (props, styles) => styles.separator
|
|
@@ -105,6 +103,9 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
105
103
|
const separatorProps = useSlotProps({
|
|
106
104
|
elementType: Separator,
|
|
107
105
|
externalSlotProps: slotProps?.separator,
|
|
106
|
+
additionalProps: {
|
|
107
|
+
children: ` ${internalProps.dateSeparator ?? '–'} `
|
|
108
|
+
},
|
|
108
109
|
ownerState,
|
|
109
110
|
className: classes.separator
|
|
110
111
|
});
|
|
@@ -140,6 +141,11 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
140
141
|
classes: PropTypes.object,
|
|
141
142
|
className: PropTypes.string,
|
|
142
143
|
component: PropTypes.elementType,
|
|
144
|
+
/**
|
|
145
|
+
* String displayed between the start and the end dates.
|
|
146
|
+
* @default "–"
|
|
147
|
+
*/
|
|
148
|
+
dateSeparator: PropTypes.string,
|
|
143
149
|
/**
|
|
144
150
|
* The default value. Use when the component is not controlled.
|
|
145
151
|
*/
|
|
@@ -237,7 +243,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
237
243
|
/**
|
|
238
244
|
* Disable specific date.
|
|
239
245
|
*
|
|
240
|
-
* Warning: This function can be called multiple times (
|
|
246
|
+
* 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.
|
|
241
247
|
*
|
|
242
248
|
* @template TDate
|
|
243
249
|
* @param {TDate} day The date to test.
|
|
@@ -37,9 +37,7 @@ const MultiInputDateTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((
|
|
|
37
37
|
slot: 'Root',
|
|
38
38
|
overridesResolver: (props, styles) => styles.root
|
|
39
39
|
})({});
|
|
40
|
-
const MultiInputDateTimeRangeFieldSeparator = styled(
|
|
41
|
-
children: props.children ?? ' – '
|
|
42
|
-
})), {
|
|
40
|
+
const MultiInputDateTimeRangeFieldSeparator = styled(Typography, {
|
|
43
41
|
name: 'MuiMultiInputDateTimeRangeField',
|
|
44
42
|
slot: 'Separator',
|
|
45
43
|
overridesResolver: (props, styles) => styles.separator
|
|
@@ -105,6 +103,9 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
|
|
|
105
103
|
const separatorProps = useSlotProps({
|
|
106
104
|
elementType: Separator,
|
|
107
105
|
externalSlotProps: slotProps?.separator,
|
|
106
|
+
additionalProps: {
|
|
107
|
+
children: ` ${internalProps.dateSeparator ?? '–'} `
|
|
108
|
+
},
|
|
108
109
|
ownerState,
|
|
109
110
|
className: classes.separator
|
|
110
111
|
});
|
|
@@ -145,6 +146,11 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
145
146
|
classes: PropTypes.object,
|
|
146
147
|
className: PropTypes.string,
|
|
147
148
|
component: PropTypes.elementType,
|
|
149
|
+
/**
|
|
150
|
+
* String displayed between the start and the end dates.
|
|
151
|
+
* @default "–"
|
|
152
|
+
*/
|
|
153
|
+
dateSeparator: PropTypes.string,
|
|
148
154
|
/**
|
|
149
155
|
* The default value. Use when the component is not controlled.
|
|
150
156
|
*/
|
|
@@ -270,7 +276,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
|
|
|
270
276
|
/**
|
|
271
277
|
* Disable specific date.
|
|
272
278
|
*
|
|
273
|
-
* Warning: This function can be called multiple times (
|
|
279
|
+
* 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.
|
|
274
280
|
*
|
|
275
281
|
* @template TDate
|
|
276
282
|
* @param {TDate} day The date to test.
|
|
@@ -37,9 +37,7 @@ const MultiInputTimeRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
|
|
|
37
37
|
slot: 'Root',
|
|
38
38
|
overridesResolver: (props, styles) => styles.root
|
|
39
39
|
})({});
|
|
40
|
-
const MultiInputTimeRangeFieldSeparator = styled(
|
|
41
|
-
children: props.children ?? ' – '
|
|
42
|
-
})), {
|
|
40
|
+
const MultiInputTimeRangeFieldSeparator = styled(Typography, {
|
|
43
41
|
name: 'MuiMultiInputTimeRangeField',
|
|
44
42
|
slot: 'Separator',
|
|
45
43
|
overridesResolver: (props, styles) => styles.separator
|
|
@@ -105,6 +103,9 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
105
103
|
const separatorProps = useSlotProps({
|
|
106
104
|
elementType: Separator,
|
|
107
105
|
externalSlotProps: slotProps?.separator,
|
|
106
|
+
additionalProps: {
|
|
107
|
+
children: ` ${internalProps.dateSeparator ?? '–'} `
|
|
108
|
+
},
|
|
108
109
|
ownerState,
|
|
109
110
|
className: classes.separator
|
|
110
111
|
});
|
|
@@ -145,6 +146,11 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
|
|
|
145
146
|
classes: PropTypes.object,
|
|
146
147
|
className: PropTypes.string,
|
|
147
148
|
component: PropTypes.elementType,
|
|
149
|
+
/**
|
|
150
|
+
* String displayed between the start and the end dates.
|
|
151
|
+
* @default "–"
|
|
152
|
+
*/
|
|
153
|
+
dateSeparator: PropTypes.string,
|
|
148
154
|
/**
|
|
149
155
|
* The default value. Use when the component is not controlled.
|
|
150
156
|
*/
|
|
@@ -82,6 +82,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
82
82
|
*/
|
|
83
83
|
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
|
|
84
84
|
component: PropTypes.elementType,
|
|
85
|
+
/**
|
|
86
|
+
* String displayed between the start and the end dates.
|
|
87
|
+
* @default "–"
|
|
88
|
+
*/
|
|
89
|
+
dateSeparator: PropTypes.string,
|
|
85
90
|
/**
|
|
86
91
|
* The default value. Use when the component is not controlled.
|
|
87
92
|
*/
|
|
@@ -242,7 +247,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
|
242
247
|
/**
|
|
243
248
|
* Disable specific date.
|
|
244
249
|
*
|
|
245
|
-
* Warning: This function can be called multiple times (
|
|
250
|
+
* 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.
|
|
246
251
|
*
|
|
247
252
|
* @template TDate
|
|
248
253
|
* @param {TDate} day The date to test.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { useField, splitFieldInternalAndForwardedProps, useDefaultizedDateField } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { rangeValueManager,
|
|
3
|
+
import { rangeValueManager, getRangeFieldValueManager } from '../internals/utils/valueManagers';
|
|
3
4
|
import { validateDateRange } from '../internals/utils/validation/validateDateRange';
|
|
4
5
|
export const useSingleInputDateRangeField = inProps => {
|
|
5
6
|
const props = useDefaultizedDateField(inProps);
|
|
@@ -7,11 +8,14 @@ export const useSingleInputDateRangeField = inProps => {
|
|
|
7
8
|
forwardedProps,
|
|
8
9
|
internalProps
|
|
9
10
|
} = splitFieldInternalAndForwardedProps(props, 'date');
|
|
11
|
+
const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
|
|
12
|
+
dateSeparator: internalProps.dateSeparator
|
|
13
|
+
}), [internalProps.dateSeparator]);
|
|
10
14
|
return useField({
|
|
11
15
|
forwardedProps,
|
|
12
16
|
internalProps,
|
|
13
17
|
valueManager: rangeValueManager,
|
|
14
|
-
fieldValueManager
|
|
18
|
+
fieldValueManager,
|
|
15
19
|
validator: validateDateRange,
|
|
16
20
|
valueType: 'date'
|
|
17
21
|
});
|
|
@@ -87,6 +87,11 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
|
|
|
87
87
|
*/
|
|
88
88
|
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
|
|
89
89
|
component: PropTypes.elementType,
|
|
90
|
+
/**
|
|
91
|
+
* String displayed between the start and the end dates.
|
|
92
|
+
* @default "–"
|
|
93
|
+
*/
|
|
94
|
+
dateSeparator: PropTypes.string,
|
|
90
95
|
/**
|
|
91
96
|
* The default value. Use when the component is not controlled.
|
|
92
97
|
*/
|
|
@@ -275,7 +280,7 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
|
|
|
275
280
|
/**
|
|
276
281
|
* Disable specific date.
|
|
277
282
|
*
|
|
278
|
-
* Warning: This function can be called multiple times (
|
|
283
|
+
* 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.
|
|
279
284
|
*
|
|
280
285
|
* @template TDate
|
|
281
286
|
* @param {TDate} day The date to test.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { useField, splitFieldInternalAndForwardedProps, useDefaultizedDateTimeField } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { rangeValueManager,
|
|
3
|
+
import { rangeValueManager, getRangeFieldValueManager } from '../internals/utils/valueManagers';
|
|
3
4
|
import { validateDateTimeRange } from '../internals/utils/validation/validateDateTimeRange';
|
|
4
5
|
export const useSingleInputDateTimeRangeField = inProps => {
|
|
5
6
|
const props = useDefaultizedDateTimeField(inProps);
|
|
@@ -7,11 +8,14 @@ export const useSingleInputDateTimeRangeField = inProps => {
|
|
|
7
8
|
forwardedProps,
|
|
8
9
|
internalProps
|
|
9
10
|
} = splitFieldInternalAndForwardedProps(props, 'date-time');
|
|
11
|
+
const fieldValueManager = React.useMemo(() => getRangeFieldValueManager({
|
|
12
|
+
dateSeparator: internalProps.dateSeparator
|
|
13
|
+
}), [internalProps.dateSeparator]);
|
|
10
14
|
return useField({
|
|
11
15
|
forwardedProps,
|
|
12
16
|
internalProps,
|
|
13
17
|
valueManager: rangeValueManager,
|
|
14
|
-
fieldValueManager
|
|
18
|
+
fieldValueManager,
|
|
15
19
|
validator: validateDateTimeRange,
|
|
16
20
|
valueType: 'date-time'
|
|
17
21
|
});
|