@mui/x-date-pickers-pro 8.5.0 → 8.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +204 -0
- package/DateRangeCalendar/DateRangeCalendar.js +3 -2
- package/DateRangePickerDay/DateRangePickerDay.js +1 -1
- package/DateRangePickerDay2/DateRangePickerDay2.d.ts +7 -0
- package/DateRangePickerDay2/DateRangePickerDay2.js +603 -0
- package/DateRangePickerDay2/DateRangePickerDay2.types.d.ts +92 -0
- package/DateRangePickerDay2/DateRangePickerDay2.types.js +5 -0
- package/DateRangePickerDay2/dateRangePickerDay2Classes.d.ts +29 -0
- package/DateRangePickerDay2/dateRangePickerDay2Classes.js +14 -0
- package/DateRangePickerDay2/index.d.ts +4 -0
- package/DateRangePickerDay2/index.js +25 -0
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -1
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -1
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -1
- package/esm/DateRangeCalendar/DateRangeCalendar.js +3 -2
- package/esm/DateRangePickerDay/DateRangePickerDay.js +1 -1
- package/esm/DateRangePickerDay2/DateRangePickerDay2.d.ts +7 -0
- package/esm/DateRangePickerDay2/DateRangePickerDay2.js +595 -0
- package/esm/DateRangePickerDay2/DateRangePickerDay2.types.d.ts +92 -0
- package/esm/DateRangePickerDay2/DateRangePickerDay2.types.js +1 -0
- package/esm/DateRangePickerDay2/dateRangePickerDay2Classes.d.ts +29 -0
- package/esm/DateRangePickerDay2/dateRangePickerDay2Classes.js +6 -0
- package/esm/DateRangePickerDay2/index.d.ts +4 -0
- package/esm/DateRangePickerDay2/index.js +2 -0
- package/esm/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -1
- package/esm/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -1
- package/esm/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -1
- package/esm/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +1 -1
- package/esm/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +1 -1
- package/esm/themeAugmentation/components.d.ts +4 -0
- package/esm/themeAugmentation/overrides.d.ts +2 -0
- package/esm/themeAugmentation/props.d.ts +2 -0
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +1 -1
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +1 -1
- package/package.json +6 -6
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +2 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["autoFocus", "className", "classes", "hidden", "isAnimating", "onClick", "onDaySelect", "onFocus", "onBlur", "onKeyDown", "onMouseDown", "onMouseEnter", "children", "isFirstVisibleCell", "isLastVisibleCell", "day", "selected", "disabled", "today", "outsideCurrentMonth", "disableHighlightToday", "showDaysOutsideCurrentMonth", "isEndOfHighlighting", "isEndOfPreviewing", "isHighlighting", "isPreviewing", "isStartOfHighlighting", "isStartOfPreviewing", "isVisuallySelected", "draggable"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { alpha, styled, useThemeProps } from '@mui/material/styles';
|
|
8
|
+
import ButtonBase from '@mui/material/ButtonBase';
|
|
9
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
10
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
11
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
12
|
+
import { usePickerDayOwnerState, useUtils } from '@mui/x-date-pickers/internals';
|
|
13
|
+
import { dateRangePickerDay2Classes, getDateRangePickerDay2UtilityClass } from "./dateRangePickerDay2Classes.js";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const useUtilityClasses = (ownerState, classes) => {
|
|
16
|
+
const {
|
|
17
|
+
isDaySelected,
|
|
18
|
+
disableHighlightToday,
|
|
19
|
+
isDayCurrent,
|
|
20
|
+
isDayDisabled,
|
|
21
|
+
isDayOutsideMonth,
|
|
22
|
+
isDayFillerCell,
|
|
23
|
+
isDayPreviewStart,
|
|
24
|
+
isDayPreviewEnd,
|
|
25
|
+
isDayInsidePreview,
|
|
26
|
+
isDayPreviewed,
|
|
27
|
+
isDaySelectionStart,
|
|
28
|
+
isDaySelectionEnd,
|
|
29
|
+
isDayInsideSelection,
|
|
30
|
+
isDayStartOfWeek,
|
|
31
|
+
isDayEndOfWeek,
|
|
32
|
+
isDayStartOfMonth,
|
|
33
|
+
isDayEndOfMonth,
|
|
34
|
+
isDayDraggable
|
|
35
|
+
} = ownerState;
|
|
36
|
+
const slots = {
|
|
37
|
+
root: ['root', isDayDisabled && 'disabled', !disableHighlightToday && isDayCurrent && !isDaySelected && !isDayFillerCell && 'today', isDayOutsideMonth && 'dayOutsideMonth', isDayFillerCell && 'fillerCell', isDaySelected && 'selected', isDayPreviewStart && 'previewStart', isDayPreviewEnd && 'previewEnd', isDayInsidePreview && 'insidePreviewing', isDaySelectionStart && 'selectionStart', isDaySelectionEnd && 'selectionEnd', isDayInsideSelection && 'insideSelection', isDayEndOfWeek && 'endOfWeek', isDayStartOfWeek && 'startOfWeek', isDayPreviewed && 'previewed', isDayStartOfMonth && 'startOfMonth', isDayEndOfMonth && 'endOfMonth', isDayDraggable && 'draggable']
|
|
38
|
+
};
|
|
39
|
+
return composeClasses(slots, getDateRangePickerDay2UtilityClass, classes);
|
|
40
|
+
};
|
|
41
|
+
const highlightStyles = theme => ({
|
|
42
|
+
content: '""' /* Creates an empty element */,
|
|
43
|
+
height: '100%',
|
|
44
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity),
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
left: 'calc(var(--PickerDay-horizontalMargin) * (-1))',
|
|
47
|
+
right: 'calc(var(--PickerDay-horizontalMargin) * (-1))'
|
|
48
|
+
});
|
|
49
|
+
const previewStyles = theme => ({
|
|
50
|
+
content: '""' /* Creates an empty element */,
|
|
51
|
+
height: '100%',
|
|
52
|
+
border: `1.2px dashed ${(theme.vars || theme).palette.divider}`,
|
|
53
|
+
borderLeftColor: 'transparent',
|
|
54
|
+
borderRightColor: 'transparent',
|
|
55
|
+
boxSizing: 'border-box',
|
|
56
|
+
borderOffset: '-1px',
|
|
57
|
+
left: 'calc(-1 * var(--PickerDay-horizontalMargin))',
|
|
58
|
+
right: 'calc(-1 * var(--PickerDay-horizontalMargin))'
|
|
59
|
+
});
|
|
60
|
+
const selectedDayStyles = theme => ({
|
|
61
|
+
color: (theme.vars || theme).palette.primary.contrastText,
|
|
62
|
+
backgroundColor: (theme.vars || theme).palette.primary.main,
|
|
63
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
64
|
+
'&:focus, &:hover': {
|
|
65
|
+
willChange: 'background-color',
|
|
66
|
+
backgroundColor: (theme.vars || theme).palette.primary.dark
|
|
67
|
+
},
|
|
68
|
+
[`&.${dateRangePickerDay2Classes.disabled}`]: {
|
|
69
|
+
opacity: 0.6
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const DateRangePickerDay2Root = styled(ButtonBase, {
|
|
73
|
+
name: 'MuiDateRangePickerDay2',
|
|
74
|
+
slot: 'Root',
|
|
75
|
+
overridesResolver: (props, styles) => {
|
|
76
|
+
const {
|
|
77
|
+
ownerState
|
|
78
|
+
} = props;
|
|
79
|
+
return [styles.root, !ownerState.disableHighlightToday && ownerState.isDayCurrent && styles.today, !ownerState.isDayOutsideMonth && styles.dayOutsideMonth, ownerState.isDayFillerCell && styles.fillerCell, ownerState.isDaySelected && !ownerState.isDayInsideSelection && styles.selected, ownerState.isDayPreviewStart && styles.previewStart, ownerState.isDayPreviewEnd && styles.previewEnd, ownerState.isDayInsidePreview && styles.insidePreviewing, ownerState.isDaySelectionStart && styles.selectionStart, ownerState.isDaySelectionEnd && styles.selectionEnd, ownerState.isDayInsideSelection && styles.insideSelection, ownerState.isDayDraggable && styles.draggable, ownerState.isDayStartOfWeek && styles.startOfWeek, ownerState.isDayEndOfWeek && styles.endOfWeek];
|
|
80
|
+
}
|
|
81
|
+
})(({
|
|
82
|
+
theme
|
|
83
|
+
}) => _extends({
|
|
84
|
+
'--PickerDay-horizontalMargin': '2px',
|
|
85
|
+
'--PickerDay-size': '36px'
|
|
86
|
+
}, theme.typography.caption, {
|
|
87
|
+
width: 'var(--PickerDay-size)',
|
|
88
|
+
height: 'var(--PickerDay-size)',
|
|
89
|
+
borderRadius: '18px',
|
|
90
|
+
padding: 0,
|
|
91
|
+
position: 'relative',
|
|
92
|
+
marginLeft: 'var(--PickerDay-horizontalMargin)',
|
|
93
|
+
marginRight: 'var(--PickerDay-horizontalMargin)',
|
|
94
|
+
// explicitly setting to `transparent` to avoid potentially getting impacted by change from the overridden component
|
|
95
|
+
backgroundColor: 'transparent',
|
|
96
|
+
transition: theme.transitions.create('background-color', {
|
|
97
|
+
duration: theme.transitions.duration.short
|
|
98
|
+
}),
|
|
99
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
100
|
+
'@media (pointer: fine)': {
|
|
101
|
+
'&:hover': {
|
|
102
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity)
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
'&:focus': {
|
|
106
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity)
|
|
107
|
+
},
|
|
108
|
+
zIndex: 1,
|
|
109
|
+
isolation: 'isolate',
|
|
110
|
+
'&::before, &::after': {
|
|
111
|
+
zIndex: -1,
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
pointerEvents: 'none',
|
|
114
|
+
mixBlendMode: 'multiply'
|
|
115
|
+
},
|
|
116
|
+
variants: [{
|
|
117
|
+
props: {
|
|
118
|
+
isDayDisabled: true
|
|
119
|
+
},
|
|
120
|
+
style: {
|
|
121
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
props: {
|
|
125
|
+
isDayFillerCell: true
|
|
126
|
+
},
|
|
127
|
+
style: {
|
|
128
|
+
// visibility: 'hidden' does not work here as it hides the element from screen readers
|
|
129
|
+
// and results in unexpected relationships between week day and day columns.
|
|
130
|
+
opacity: 0,
|
|
131
|
+
pointerEvents: 'none'
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
props: {
|
|
135
|
+
isDayOutsideMonth: true
|
|
136
|
+
},
|
|
137
|
+
style: {
|
|
138
|
+
color: (theme.vars || theme).palette.text.secondary
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
props: {
|
|
142
|
+
isDayCurrent: true,
|
|
143
|
+
isDaySelected: false
|
|
144
|
+
},
|
|
145
|
+
style: {
|
|
146
|
+
outline: `1px solid ${(theme.vars || theme).palette.text.secondary}`,
|
|
147
|
+
outlineOffset: -1
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
150
|
+
props: {
|
|
151
|
+
isDayDraggable: true
|
|
152
|
+
},
|
|
153
|
+
style: {
|
|
154
|
+
cursor: 'grab',
|
|
155
|
+
touchAction: 'none'
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
props: {
|
|
159
|
+
isDayPreviewStart: true
|
|
160
|
+
},
|
|
161
|
+
style: {
|
|
162
|
+
'::after': _extends({}, previewStyles(theme), {
|
|
163
|
+
borderTopLeftRadius: 'inherit',
|
|
164
|
+
borderBottomLeftRadius: 'inherit',
|
|
165
|
+
borderLeftColor: (theme.vars || theme).palette.divider,
|
|
166
|
+
left: 0
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
props: {
|
|
171
|
+
isDayPreviewEnd: true
|
|
172
|
+
},
|
|
173
|
+
style: {
|
|
174
|
+
'::after': _extends({}, previewStyles(theme), {
|
|
175
|
+
borderTopRightRadius: 'inherit',
|
|
176
|
+
borderBottomRightRadius: 'inherit',
|
|
177
|
+
borderRightColor: (theme.vars || theme).palette.divider,
|
|
178
|
+
right: 0
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
props: {
|
|
183
|
+
isDayInsidePreview: true
|
|
184
|
+
},
|
|
185
|
+
style: {
|
|
186
|
+
'::after': _extends({}, previewStyles(theme))
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
props: {
|
|
190
|
+
isDaySelectionStart: true
|
|
191
|
+
},
|
|
192
|
+
style: {
|
|
193
|
+
'::before': _extends({}, highlightStyles(theme), {
|
|
194
|
+
borderTopLeftRadius: 'inherit',
|
|
195
|
+
borderBottomLeftRadius: 'inherit',
|
|
196
|
+
left: 0
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
}, {
|
|
200
|
+
props: {
|
|
201
|
+
isDaySelectionEnd: true
|
|
202
|
+
},
|
|
203
|
+
style: {
|
|
204
|
+
'::before': _extends({}, highlightStyles(theme), {
|
|
205
|
+
borderTopRightRadius: 'inherit',
|
|
206
|
+
borderBottomRightRadius: 'inherit',
|
|
207
|
+
right: 0
|
|
208
|
+
}),
|
|
209
|
+
'::after': {
|
|
210
|
+
borderLeftColor: 'transparent'
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
props: {
|
|
215
|
+
isDayInsideSelection: true
|
|
216
|
+
},
|
|
217
|
+
color: 'initial',
|
|
218
|
+
background: 'initial',
|
|
219
|
+
style: {
|
|
220
|
+
'::before': _extends({}, highlightStyles(theme))
|
|
221
|
+
}
|
|
222
|
+
}, {
|
|
223
|
+
props: {
|
|
224
|
+
isDaySelected: true,
|
|
225
|
+
isDayInsideSelection: false
|
|
226
|
+
},
|
|
227
|
+
style: _extends({}, selectedDayStyles(theme))
|
|
228
|
+
}, {
|
|
229
|
+
props: {
|
|
230
|
+
isDaySelectionStart: true,
|
|
231
|
+
isDaySelectionEnd: true
|
|
232
|
+
},
|
|
233
|
+
style: {
|
|
234
|
+
'::before': {
|
|
235
|
+
left: 0,
|
|
236
|
+
right: 0
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
props: {
|
|
241
|
+
isDaySelectionStart: true,
|
|
242
|
+
isDaySelectionEnd: true,
|
|
243
|
+
isDayPreviewEnd: false,
|
|
244
|
+
isDayPreviewStart: false
|
|
245
|
+
},
|
|
246
|
+
style: {
|
|
247
|
+
'::after': {
|
|
248
|
+
left: 0,
|
|
249
|
+
right: 0
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}, {
|
|
253
|
+
props: {
|
|
254
|
+
isDayPreviewEnd: true,
|
|
255
|
+
isDayPreviewStart: true
|
|
256
|
+
},
|
|
257
|
+
style: {
|
|
258
|
+
'::after': {
|
|
259
|
+
left: 0,
|
|
260
|
+
right: 0
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, {
|
|
264
|
+
props: {
|
|
265
|
+
isDayEndOfWeek: true
|
|
266
|
+
},
|
|
267
|
+
style: {
|
|
268
|
+
'::after': {
|
|
269
|
+
borderTopRightRadius: 'inherit',
|
|
270
|
+
borderBottomRightRadius: 'inherit',
|
|
271
|
+
borderRightColor: (theme.vars || theme).palette.divider,
|
|
272
|
+
right: 0
|
|
273
|
+
},
|
|
274
|
+
'::before': {
|
|
275
|
+
borderTopRightRadius: 'inherit',
|
|
276
|
+
borderBottomRightRadius: 'inherit',
|
|
277
|
+
right: 0
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
props: {
|
|
282
|
+
isDayStartOfWeek: true
|
|
283
|
+
},
|
|
284
|
+
style: {
|
|
285
|
+
'::after': {
|
|
286
|
+
borderTopLeftRadius: 'inherit',
|
|
287
|
+
borderBottomLeftRadius: 'inherit',
|
|
288
|
+
borderLeftColor: (theme.vars || theme).palette.divider,
|
|
289
|
+
left: 0
|
|
290
|
+
},
|
|
291
|
+
'::before': {
|
|
292
|
+
borderTopLeftRadius: 'inherit',
|
|
293
|
+
borderBottomLeftRadius: 'inherit',
|
|
294
|
+
left: 0
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}]
|
|
298
|
+
}));
|
|
299
|
+
const noop = () => {};
|
|
300
|
+
const DateRangePickerDay2Raw = /*#__PURE__*/React.forwardRef(function DateRangePickerDay2(inProps, forwardedRef) {
|
|
301
|
+
const props = useThemeProps({
|
|
302
|
+
props: inProps,
|
|
303
|
+
name: 'MuiDateRangePickerDay2'
|
|
304
|
+
});
|
|
305
|
+
const utils = useUtils();
|
|
306
|
+
const {
|
|
307
|
+
autoFocus = false,
|
|
308
|
+
className,
|
|
309
|
+
classes: classesProp,
|
|
310
|
+
isAnimating,
|
|
311
|
+
onClick,
|
|
312
|
+
onDaySelect,
|
|
313
|
+
onFocus = noop,
|
|
314
|
+
onBlur = noop,
|
|
315
|
+
onKeyDown = noop,
|
|
316
|
+
onMouseDown = noop,
|
|
317
|
+
onMouseEnter = noop,
|
|
318
|
+
children,
|
|
319
|
+
isFirstVisibleCell,
|
|
320
|
+
isLastVisibleCell,
|
|
321
|
+
day,
|
|
322
|
+
selected,
|
|
323
|
+
disabled,
|
|
324
|
+
today,
|
|
325
|
+
outsideCurrentMonth,
|
|
326
|
+
disableHighlightToday,
|
|
327
|
+
showDaysOutsideCurrentMonth,
|
|
328
|
+
isEndOfHighlighting,
|
|
329
|
+
isEndOfPreviewing,
|
|
330
|
+
isHighlighting,
|
|
331
|
+
isPreviewing,
|
|
332
|
+
isStartOfHighlighting,
|
|
333
|
+
isStartOfPreviewing,
|
|
334
|
+
draggable
|
|
335
|
+
} = props,
|
|
336
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
337
|
+
const pickersDayOwnerState = usePickerDayOwnerState({
|
|
338
|
+
day,
|
|
339
|
+
selected,
|
|
340
|
+
disabled,
|
|
341
|
+
today,
|
|
342
|
+
outsideCurrentMonth,
|
|
343
|
+
disableMargin: false,
|
|
344
|
+
disableHighlightToday,
|
|
345
|
+
showDaysOutsideCurrentMonth
|
|
346
|
+
});
|
|
347
|
+
const ownerState = _extends({}, pickersDayOwnerState, {
|
|
348
|
+
// Properties that the Base UI implementation will have
|
|
349
|
+
isDaySelectionStart: isStartOfHighlighting,
|
|
350
|
+
isDaySelectionEnd: isEndOfHighlighting,
|
|
351
|
+
isDayInsideSelection: isHighlighting && !isStartOfHighlighting && !isEndOfHighlighting,
|
|
352
|
+
isDaySelected: isHighlighting || Boolean(selected),
|
|
353
|
+
isDayPreviewed: isPreviewing,
|
|
354
|
+
isDayPreviewStart: isStartOfPreviewing,
|
|
355
|
+
isDayPreviewEnd: isEndOfPreviewing,
|
|
356
|
+
isDayInsidePreview: isPreviewing && !isStartOfPreviewing && !isEndOfPreviewing,
|
|
357
|
+
// Properties specific to the MUI implementation (some might be removed in the next major)
|
|
358
|
+
isDayStartOfMonth: utils.isSameDay(day, utils.startOfMonth(day)),
|
|
359
|
+
isDayEndOfMonth: utils.isSameDay(day, utils.endOfMonth(day)),
|
|
360
|
+
isDayFirstVisibleCell: isFirstVisibleCell,
|
|
361
|
+
isDayLastVisibleCell: isLastVisibleCell,
|
|
362
|
+
isDayFillerCell: outsideCurrentMonth && !showDaysOutsideCurrentMonth,
|
|
363
|
+
isDayDraggable: Boolean(draggable)
|
|
364
|
+
});
|
|
365
|
+
const classes = useUtilityClasses(ownerState, classesProp);
|
|
366
|
+
const ref = React.useRef(null);
|
|
367
|
+
const handleRef = useForkRef(ref, forwardedRef);
|
|
368
|
+
|
|
369
|
+
// Since this is rendered when a Popper is opened we can't use passive effects.
|
|
370
|
+
// Focusing in passive effects in Popper causes scroll jump.
|
|
371
|
+
useEnhancedEffect(() => {
|
|
372
|
+
if (autoFocus && !disabled && !isAnimating && !outsideCurrentMonth) {
|
|
373
|
+
// ref.current being null would be a bug in MUI
|
|
374
|
+
ref.current.focus();
|
|
375
|
+
}
|
|
376
|
+
}, [autoFocus, disabled, isAnimating, outsideCurrentMonth]);
|
|
377
|
+
|
|
378
|
+
// For a day outside the current month, move the focus from mouseDown to mouseUp
|
|
379
|
+
// Goal: have the onClick ends before sliding to the new month
|
|
380
|
+
const handleMouseDown = event => {
|
|
381
|
+
onMouseDown(event);
|
|
382
|
+
if (outsideCurrentMonth) {
|
|
383
|
+
event.preventDefault();
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const handleClick = event => {
|
|
387
|
+
if (!disabled) {
|
|
388
|
+
onDaySelect(day);
|
|
389
|
+
}
|
|
390
|
+
if (outsideCurrentMonth) {
|
|
391
|
+
event.currentTarget.focus();
|
|
392
|
+
}
|
|
393
|
+
if (onClick) {
|
|
394
|
+
onClick(event);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
return /*#__PURE__*/_jsx(DateRangePickerDay2Root, _extends({
|
|
398
|
+
ref: handleRef,
|
|
399
|
+
centerRipple: true
|
|
400
|
+
// compat with DateRangePickerDay for tests
|
|
401
|
+
,
|
|
402
|
+
|
|
403
|
+
disabled: ownerState.isDayFillerCell ? undefined : disabled,
|
|
404
|
+
tabIndex: selected ? 0 : -1,
|
|
405
|
+
onKeyDown: event => onKeyDown(event, day),
|
|
406
|
+
onFocus: event => onFocus(event, day),
|
|
407
|
+
onBlur: event => onBlur(event, day),
|
|
408
|
+
onMouseEnter: event => onMouseEnter(event, day),
|
|
409
|
+
onClick: handleClick,
|
|
410
|
+
onMouseDown: handleMouseDown,
|
|
411
|
+
draggable: draggable
|
|
412
|
+
}, other, {
|
|
413
|
+
ownerState: ownerState,
|
|
414
|
+
className: clsx(classes.root, className),
|
|
415
|
+
children: children ?? (ownerState.isDayFillerCell ? null : utils.format(day, 'dayOfMonth'))
|
|
416
|
+
}));
|
|
417
|
+
});
|
|
418
|
+
if (process.env.NODE_ENV !== "production") DateRangePickerDay2Raw.displayName = "DateRangePickerDay2Raw";
|
|
419
|
+
process.env.NODE_ENV !== "production" ? DateRangePickerDay2Raw.propTypes = {
|
|
420
|
+
// ----------------------------- Warning --------------------------------
|
|
421
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
422
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
423
|
+
// ----------------------------------------------------------------------
|
|
424
|
+
/**
|
|
425
|
+
* A ref for imperative actions.
|
|
426
|
+
* It currently only supports `focusVisible()` action.
|
|
427
|
+
*/
|
|
428
|
+
action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
429
|
+
current: PropTypes.shape({
|
|
430
|
+
focusVisible: PropTypes.func.isRequired
|
|
431
|
+
})
|
|
432
|
+
})]),
|
|
433
|
+
/**
|
|
434
|
+
* If `true`, the ripples are centered.
|
|
435
|
+
* They won't start at the cursor interaction position.
|
|
436
|
+
* @default false
|
|
437
|
+
*/
|
|
438
|
+
centerRipple: PropTypes.bool,
|
|
439
|
+
/**
|
|
440
|
+
* Override or extend the styles applied to the component.
|
|
441
|
+
*/
|
|
442
|
+
classes: PropTypes.object,
|
|
443
|
+
className: PropTypes.string,
|
|
444
|
+
component: PropTypes.elementType,
|
|
445
|
+
/**
|
|
446
|
+
* The date to show.
|
|
447
|
+
*/
|
|
448
|
+
day: PropTypes.object.isRequired,
|
|
449
|
+
/**
|
|
450
|
+
* If `true`, renders as disabled.
|
|
451
|
+
* @default false
|
|
452
|
+
*/
|
|
453
|
+
disabled: PropTypes.bool,
|
|
454
|
+
/**
|
|
455
|
+
* If `true`, today's date is rendering without highlighting with circle.
|
|
456
|
+
* @default false
|
|
457
|
+
*/
|
|
458
|
+
disableHighlightToday: PropTypes.bool,
|
|
459
|
+
/**
|
|
460
|
+
* If `true`, days are rendering without margin. Useful for displaying linked range of days.
|
|
461
|
+
* @default false
|
|
462
|
+
*/
|
|
463
|
+
disableMargin: PropTypes.bool,
|
|
464
|
+
/**
|
|
465
|
+
* If `true`, the ripple effect is disabled.
|
|
466
|
+
*
|
|
467
|
+
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
|
|
468
|
+
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
|
|
469
|
+
* @default false
|
|
470
|
+
*/
|
|
471
|
+
disableRipple: PropTypes.bool,
|
|
472
|
+
/**
|
|
473
|
+
* If `true`, the touch ripple effect is disabled.
|
|
474
|
+
* @default false
|
|
475
|
+
*/
|
|
476
|
+
disableTouchRipple: PropTypes.bool,
|
|
477
|
+
/**
|
|
478
|
+
* If `true`, the day can be dragged to change the current date range.
|
|
479
|
+
* @default false
|
|
480
|
+
*/
|
|
481
|
+
draggable: PropTypes.bool,
|
|
482
|
+
/**
|
|
483
|
+
* If `true`, the base button will have a keyboard focus ripple.
|
|
484
|
+
* @default false
|
|
485
|
+
*/
|
|
486
|
+
focusRipple: PropTypes.bool,
|
|
487
|
+
/**
|
|
488
|
+
* This prop can help identify which element has keyboard focus.
|
|
489
|
+
* The class name will be applied when the element gains the focus through keyboard interaction.
|
|
490
|
+
* It's a polyfill for the [CSS :focus-visible selector](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo).
|
|
491
|
+
* The rationale for using this feature [is explained here](https://github.com/WICG/focus-visible/blob/HEAD/explainer.md).
|
|
492
|
+
* A [polyfill can be used](https://github.com/WICG/focus-visible) to apply a `focus-visible` class to other components
|
|
493
|
+
* if needed.
|
|
494
|
+
*/
|
|
495
|
+
focusVisibleClassName: PropTypes.string,
|
|
496
|
+
isAnimating: PropTypes.bool,
|
|
497
|
+
/**
|
|
498
|
+
* Set to `true` if the `day` is the end of a highlighted date range.
|
|
499
|
+
*/
|
|
500
|
+
isEndOfHighlighting: PropTypes.bool.isRequired,
|
|
501
|
+
/**
|
|
502
|
+
* Set to `true` if the `day` is the end of a previewing date range.
|
|
503
|
+
*/
|
|
504
|
+
isEndOfPreviewing: PropTypes.bool.isRequired,
|
|
505
|
+
/**
|
|
506
|
+
* If `true`, day is the first visible cell of the month.
|
|
507
|
+
* Either the first day of the month or the first day of the week depending on `showDaysOutsideCurrentMonth`.
|
|
508
|
+
*/
|
|
509
|
+
isFirstVisibleCell: PropTypes.bool.isRequired,
|
|
510
|
+
/**
|
|
511
|
+
* Set to `true` if the `day` is in a highlighted date range.
|
|
512
|
+
*/
|
|
513
|
+
isHighlighting: PropTypes.bool.isRequired,
|
|
514
|
+
/**
|
|
515
|
+
* If `true`, day is the last visible cell of the month.
|
|
516
|
+
* Either the last day of the month or the last day of the week depending on `showDaysOutsideCurrentMonth`.
|
|
517
|
+
*/
|
|
518
|
+
isLastVisibleCell: PropTypes.bool.isRequired,
|
|
519
|
+
/**
|
|
520
|
+
* Set to `true` if the `day` is in a preview date range.
|
|
521
|
+
*/
|
|
522
|
+
isPreviewing: PropTypes.bool.isRequired,
|
|
523
|
+
/**
|
|
524
|
+
* Set to `true` if the `day` is the start of a highlighted date range.
|
|
525
|
+
*/
|
|
526
|
+
isStartOfHighlighting: PropTypes.bool.isRequired,
|
|
527
|
+
/**
|
|
528
|
+
* Set to `true` if the `day` is the start of a previewing date range.
|
|
529
|
+
*/
|
|
530
|
+
isStartOfPreviewing: PropTypes.bool.isRequired,
|
|
531
|
+
/**
|
|
532
|
+
* Indicates if the day should be visually selected.
|
|
533
|
+
*/
|
|
534
|
+
isVisuallySelected: PropTypes.bool,
|
|
535
|
+
onBlur: PropTypes.func,
|
|
536
|
+
onDaySelect: PropTypes.func.isRequired,
|
|
537
|
+
onFocus: PropTypes.func,
|
|
538
|
+
/**
|
|
539
|
+
* Callback fired when the component is focused with a keyboard.
|
|
540
|
+
* We trigger a `onFocus` callback too.
|
|
541
|
+
*/
|
|
542
|
+
onFocusVisible: PropTypes.func,
|
|
543
|
+
onKeyDown: PropTypes.func,
|
|
544
|
+
onMouseEnter: PropTypes.func,
|
|
545
|
+
/**
|
|
546
|
+
* If `true`, day is outside of month and will be hidden.
|
|
547
|
+
*/
|
|
548
|
+
outsideCurrentMonth: PropTypes.bool.isRequired,
|
|
549
|
+
/**
|
|
550
|
+
* If `true`, renders as selected.
|
|
551
|
+
* @default false
|
|
552
|
+
*/
|
|
553
|
+
selected: PropTypes.bool,
|
|
554
|
+
/**
|
|
555
|
+
* If `true`, days outside the current month are rendered:
|
|
556
|
+
*
|
|
557
|
+
* - if `fixedWeekNumber` is defined, renders days to have the weeks requested.
|
|
558
|
+
*
|
|
559
|
+
* - if `fixedWeekNumber` is not defined, renders day to fill the first and last week of the current month.
|
|
560
|
+
*
|
|
561
|
+
* - ignored if `calendars` equals more than `1` on range pickers.
|
|
562
|
+
* @default false
|
|
563
|
+
*/
|
|
564
|
+
showDaysOutsideCurrentMonth: PropTypes.bool,
|
|
565
|
+
style: PropTypes.object,
|
|
566
|
+
/**
|
|
567
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
568
|
+
*/
|
|
569
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
570
|
+
/**
|
|
571
|
+
* @default 0
|
|
572
|
+
*/
|
|
573
|
+
tabIndex: PropTypes.number,
|
|
574
|
+
/**
|
|
575
|
+
* If `true`, renders as today date.
|
|
576
|
+
* @default false
|
|
577
|
+
*/
|
|
578
|
+
today: PropTypes.bool,
|
|
579
|
+
/**
|
|
580
|
+
* Props applied to the `TouchRipple` element.
|
|
581
|
+
*/
|
|
582
|
+
TouchRippleProps: PropTypes.object,
|
|
583
|
+
/**
|
|
584
|
+
* A ref that points to the `TouchRipple` element.
|
|
585
|
+
*/
|
|
586
|
+
touchRippleRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
587
|
+
current: PropTypes.shape({
|
|
588
|
+
pulsate: PropTypes.func.isRequired,
|
|
589
|
+
start: PropTypes.func.isRequired,
|
|
590
|
+
stop: PropTypes.func.isRequired
|
|
591
|
+
})
|
|
592
|
+
})])
|
|
593
|
+
} : void 0;
|
|
594
|
+
export const DateRangePickerDay2 = /*#__PURE__*/React.memo(DateRangePickerDay2Raw);
|
|
595
|
+
if (process.env.NODE_ENV !== "production") DateRangePickerDay2.displayName = "DateRangePickerDay2";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { PickerDay2OwnerState, PickerDay2Props } from '@mui/x-date-pickers/PickerDay2';
|
|
2
|
+
import { DateRangePickerDay2Classes } from "./dateRangePickerDay2Classes.js";
|
|
3
|
+
export interface DateRangePickerDay2Props extends Omit<PickerDay2Props, 'classes'> {
|
|
4
|
+
/**
|
|
5
|
+
* Set to `true` if the `day` is in a highlighted date range.
|
|
6
|
+
*/
|
|
7
|
+
isHighlighting: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Set to `true` if the `day` is the end of a highlighted date range.
|
|
10
|
+
*/
|
|
11
|
+
isEndOfHighlighting: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Set to `true` if the `day` is the start of a highlighted date range.
|
|
14
|
+
*/
|
|
15
|
+
isStartOfHighlighting: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Set to `true` if the `day` is in a preview date range.
|
|
18
|
+
*/
|
|
19
|
+
isPreviewing: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Set to `true` if the `day` is the end of a previewing date range.
|
|
22
|
+
*/
|
|
23
|
+
isEndOfPreviewing: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Set to `true` if the `day` is the start of a previewing date range.
|
|
26
|
+
*/
|
|
27
|
+
isStartOfPreviewing: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Override or extend the styles applied to the component.
|
|
30
|
+
*/
|
|
31
|
+
classes?: Partial<DateRangePickerDay2Classes>;
|
|
32
|
+
/**
|
|
33
|
+
* Indicates if the day should be visually selected.
|
|
34
|
+
*/
|
|
35
|
+
isVisuallySelected?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* If `true`, the day can be dragged to change the current date range.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
draggable?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface DateRangePickerDay2OwnerState extends PickerDay2OwnerState {
|
|
43
|
+
/**
|
|
44
|
+
* Whether the day is the first day of the selected range.
|
|
45
|
+
*/
|
|
46
|
+
isDaySelectionStart: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the day is the last day of the selected range.
|
|
49
|
+
*/
|
|
50
|
+
isDaySelectionEnd: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the day is within the selected range and is not its first or last day.
|
|
53
|
+
*/
|
|
54
|
+
isDayInsideSelection: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the day is within the preview range.
|
|
57
|
+
*/
|
|
58
|
+
isDayPreviewed: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the day is the first day of the preview range.
|
|
61
|
+
*/
|
|
62
|
+
isDayPreviewStart: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the day is the last day of the preview range.
|
|
65
|
+
*/
|
|
66
|
+
isDayPreviewEnd: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the day is within the preview range and is not its first or last day.
|
|
69
|
+
*/
|
|
70
|
+
isDayInsidePreview: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, the day can be dragged to change the current date range.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
isDayDraggable?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the day is the first day of the month.
|
|
78
|
+
*/
|
|
79
|
+
isDayStartOfMonth: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the day is the last day of the month.
|
|
82
|
+
*/
|
|
83
|
+
isDayEndOfMonth: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the day is the first visible cell of the month it's being rendered in.
|
|
86
|
+
*/
|
|
87
|
+
isDayFirstVisibleCell: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether the day is the last visible cell of the month it's being rendered in.
|
|
90
|
+
*/
|
|
91
|
+
isDayLastVisibleCell: boolean;
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|