@mui/x-date-pickers-pro 7.0.0-alpha.9 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -38
- package/DateRangeCalendar/DateRangeCalendar.js +79 -13
- package/DateRangeCalendar/DateRangeCalendar.types.d.ts +15 -14
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +7 -0
- package/DateTimeRangePicker/DateTimeRangePicker.js +414 -0
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +24 -0
- package/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +32 -0
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +183 -0
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +20 -0
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +59 -0
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +15 -0
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +176 -0
- package/DateTimeRangePicker/dateTimeRangePickerTabsClasses.d.ts +13 -0
- package/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
- package/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.d.ts +11 -0
- package/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
- package/DateTimeRangePicker/index.d.ts +10 -0
- package/DateTimeRangePicker/index.js +5 -0
- package/DateTimeRangePicker/package.json +6 -0
- package/DateTimeRangePicker/shared.d.ts +60 -0
- package/DateTimeRangePicker/shared.js +56 -0
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +1 -1
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +7 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +491 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +25 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.d.ts +8 -0
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +52 -0
- package/DesktopDateTimeRangePicker/index.d.ts +2 -0
- package/DesktopDateTimeRangePicker/index.js +1 -0
- package/DesktopDateTimeRangePicker/package.json +6 -0
- package/MobileDateRangePicker/MobileDateRangePicker.js +1 -5
- package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +1 -6
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +7 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +490 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +20 -0
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
- package/MobileDateTimeRangePicker/index.d.ts +2 -0
- package/MobileDateTimeRangePicker/index.js +1 -0
- package/MobileDateTimeRangePicker/package.json +6 -0
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +2 -5
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +2 -5
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +2 -5
- package/README.md +2 -2
- package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +2 -1
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +2 -1
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +2 -1
- package/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +5 -0
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -4
- package/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/index.d.ts +3 -0
- package/index.js +4 -1
- package/internals/constants/dimensions.d.ts +3 -0
- package/internals/constants/dimensions.js +5 -0
- package/internals/hooks/models/index.d.ts +1 -0
- package/internals/hooks/models/index.js +1 -0
- package/internals/hooks/models/useRangePicker.d.ts +21 -0
- package/internals/hooks/models/useRangePicker.js +1 -0
- package/internals/hooks/useDesktopRangePicker/index.d.ts +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +17 -3
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +8 -14
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +5 -2
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +41 -11
- package/internals/hooks/useMobileRangePicker/index.d.ts +1 -1
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +8 -14
- package/internals/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +2 -6
- package/internals/models/dateTimeRange.d.ts +3 -1
- package/internals/models/fields.d.ts +7 -2
- package/internals/utils/date-range-manager.d.ts +2 -1
- package/internals/utils/date-range-manager.js +12 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/legacy/DateRangeCalendar/DateRangeCalendar.js +77 -12
- package/legacy/DateTimeRangePicker/DateTimeRangePicker.js +413 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePickerTabs.js +191 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +57 -0
- package/legacy/DateTimeRangePicker/DateTimeRangePickerToolbar.js +184 -0
- package/legacy/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
- package/legacy/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
- package/legacy/DateTimeRangePicker/index.js +5 -0
- package/legacy/DateTimeRangePicker/shared.js +54 -0
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +491 -0
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
- package/legacy/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +48 -0
- package/legacy/DesktopDateTimeRangePicker/index.js +1 -0
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +1 -5
- package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +484 -0
- package/legacy/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
- package/legacy/MobileDateTimeRangePicker/index.js +1 -0
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/legacy/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/legacy/index.js +4 -1
- package/legacy/internals/constants/dimensions.js +5 -0
- package/legacy/internals/hooks/models/index.js +1 -0
- package/legacy/internals/hooks/models/useRangePicker.js +1 -0
- package/legacy/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +17 -3
- package/legacy/internals/hooks/useEnrichedRangePickerFieldProps.js +43 -11
- package/legacy/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/legacy/internals/utils/date-range-manager.js +13 -1
- package/legacy/internals/utils/releaseInfo.js +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +78 -12
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +414 -0
- package/modern/DateTimeRangePicker/DateTimeRangePicker.types.js +1 -0
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +183 -0
- package/modern/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +58 -0
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +176 -0
- package/modern/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +6 -0
- package/modern/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +5 -0
- package/modern/DateTimeRangePicker/index.js +5 -0
- package/modern/DateTimeRangePicker/shared.js +55 -0
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +483 -0
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +1 -0
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +51 -0
- package/modern/DesktopDateTimeRangePicker/index.js +1 -0
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +1 -5
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +486 -0
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +1 -0
- package/modern/MobileDateTimeRangePicker/index.js +1 -0
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/modern/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/modern/index.js +4 -1
- package/modern/internals/constants/dimensions.js +5 -0
- package/modern/internals/hooks/models/index.js +1 -0
- package/modern/internals/hooks/models/useRangePicker.js +1 -0
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -2
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +40 -9
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/modern/internals/utils/date-range-manager.js +12 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/node/DateRangeCalendar/DateRangeCalendar.js +78 -12
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +422 -0
- package/node/DateTimeRangePicker/DateTimeRangePicker.types.js +5 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +190 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +64 -0
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +183 -0
- package/node/DateTimeRangePicker/dateTimeRangePickerTabsClasses.js +14 -0
- package/node/DateTimeRangePicker/dateTimeRangePickerToolbarClasses.js +12 -0
- package/node/DateTimeRangePicker/index.js +52 -0
- package/node/DateTimeRangePicker/shared.js +62 -0
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +490 -0
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.js +5 -0
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePickerLayout.js +59 -0
- package/node/DesktopDateTimeRangePicker/index.js +12 -0
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +1 -5
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +494 -0
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.js +5 -0
- package/node/MobileDateTimeRangePicker/index.js +12 -0
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +1 -1
- package/node/dateRangeViewRenderers/dateRangeViewRenderers.js +10 -2
- package/node/index.js +37 -1
- package/node/internals/constants/dimensions.js +16 -0
- package/node/internals/hooks/models/index.js +5 -0
- package/node/internals/hooks/models/useRangePicker.js +5 -0
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +16 -2
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +40 -9
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +4 -0
- package/node/internals/utils/date-range-manager.js +12 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/package.json +6 -6
- package/themeAugmentation/components.d.ts +22 -3
- package/themeAugmentation/overrides.d.ts +7 -0
- package/themeAugmentation/props.d.ts +12 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
5
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
6
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
7
|
+
import { TimeIcon, DateRangeIcon, ArrowLeftIcon, ArrowRightIcon } from '@mui/x-date-pickers/icons';
|
|
8
|
+
import { useLocaleText, isDatePickerView } from '@mui/x-date-pickers/internals';
|
|
9
|
+
import IconButton from '@mui/material/IconButton';
|
|
10
|
+
import Button from '@mui/material/Button';
|
|
11
|
+
import { getDateTimeRangePickerTabsUtilityClass } from './dateTimeRangePickerTabsClasses';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const viewToTab = (view, rangePosition) => {
|
|
15
|
+
if (isDatePickerView(view)) {
|
|
16
|
+
return rangePosition === 'start' ? 'start-date' : 'end-date';
|
|
17
|
+
}
|
|
18
|
+
return rangePosition === 'start' ? 'start-time' : 'end-time';
|
|
19
|
+
};
|
|
20
|
+
const tabToView = tab => {
|
|
21
|
+
if (tab === 'start-date' || tab === 'end-date') {
|
|
22
|
+
return 'day';
|
|
23
|
+
}
|
|
24
|
+
return 'hours';
|
|
25
|
+
};
|
|
26
|
+
const useUtilityClasses = ownerState => {
|
|
27
|
+
const {
|
|
28
|
+
classes
|
|
29
|
+
} = ownerState;
|
|
30
|
+
const slots = {
|
|
31
|
+
root: ['root'],
|
|
32
|
+
tabButton: ['tabButton'],
|
|
33
|
+
navigationButton: ['navigationButton'],
|
|
34
|
+
filler: ['filler']
|
|
35
|
+
};
|
|
36
|
+
return composeClasses(slots, getDateTimeRangePickerTabsUtilityClass, classes);
|
|
37
|
+
};
|
|
38
|
+
const DateTimeRangePickerTabsRoot = styled('div', {
|
|
39
|
+
name: 'MuiDateTimeRangePickerTabs',
|
|
40
|
+
slot: 'Root',
|
|
41
|
+
overridesResolver: (_, styles) => styles.root
|
|
42
|
+
})(({
|
|
43
|
+
theme
|
|
44
|
+
}) => ({
|
|
45
|
+
display: 'flex',
|
|
46
|
+
justifyContent: 'space-between',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
borderBottom: `1px solid ${(theme.vars || theme).palette.divider}`,
|
|
49
|
+
minHeight: 48
|
|
50
|
+
}));
|
|
51
|
+
const DateTimeRangePickerTab = styled(Button, {
|
|
52
|
+
name: 'MuiDateTimeRangePickerTabs',
|
|
53
|
+
slot: 'TabButton',
|
|
54
|
+
overridesResolver: (_, styles) => styles.tabButton
|
|
55
|
+
})({
|
|
56
|
+
textTransform: 'none'
|
|
57
|
+
});
|
|
58
|
+
const DateTimeRangePickerTabFiller = styled('div', {
|
|
59
|
+
name: 'MuiDateTimeRangePickerTabs',
|
|
60
|
+
slot: 'Filler',
|
|
61
|
+
overridesResolver: (_, styles) => styles.filler
|
|
62
|
+
})({
|
|
63
|
+
width: 40
|
|
64
|
+
});
|
|
65
|
+
const tabOptions = ['start-date', 'start-time', 'end-date', 'end-time'];
|
|
66
|
+
const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
67
|
+
const props = useThemeProps({
|
|
68
|
+
props: inProps,
|
|
69
|
+
name: 'MuiDateTimeRangePickerTabs'
|
|
70
|
+
});
|
|
71
|
+
const {
|
|
72
|
+
dateIcon = /*#__PURE__*/_jsx(DateRangeIcon, {}),
|
|
73
|
+
onViewChange,
|
|
74
|
+
timeIcon = /*#__PURE__*/_jsx(TimeIcon, {}),
|
|
75
|
+
view,
|
|
76
|
+
hidden = typeof window === 'undefined' || window.innerHeight < 667,
|
|
77
|
+
rangePosition,
|
|
78
|
+
onRangePositionChange,
|
|
79
|
+
className
|
|
80
|
+
} = props;
|
|
81
|
+
const localeText = useLocaleText();
|
|
82
|
+
const classes = useUtilityClasses(props);
|
|
83
|
+
const value = React.useMemo(() => viewToTab(view, rangePosition), [view, rangePosition]);
|
|
84
|
+
const isPreviousHidden = value === 'start-date';
|
|
85
|
+
const isNextHidden = value === 'end-time';
|
|
86
|
+
const tabLabel = React.useMemo(() => {
|
|
87
|
+
switch (value) {
|
|
88
|
+
case 'start-date':
|
|
89
|
+
return localeText.startDate;
|
|
90
|
+
case 'start-time':
|
|
91
|
+
return localeText.startTime;
|
|
92
|
+
case 'end-date':
|
|
93
|
+
return localeText.endDate;
|
|
94
|
+
case 'end-time':
|
|
95
|
+
return localeText.endTime;
|
|
96
|
+
default:
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
}, [localeText.endDate, localeText.endTime, localeText.startDate, localeText.startTime, value]);
|
|
100
|
+
const handleRangePositionChange = useEventCallback(newTab => {
|
|
101
|
+
if (newTab.includes('start')) {
|
|
102
|
+
onRangePositionChange('start');
|
|
103
|
+
} else {
|
|
104
|
+
onRangePositionChange('end');
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
const changeToPreviousTab = useEventCallback(() => {
|
|
108
|
+
const previousTab = tabOptions[tabOptions.indexOf(value) - 1];
|
|
109
|
+
onViewChange(tabToView(previousTab));
|
|
110
|
+
handleRangePositionChange(previousTab);
|
|
111
|
+
});
|
|
112
|
+
const changeToNextTab = useEventCallback(() => {
|
|
113
|
+
const nextTab = tabOptions[tabOptions.indexOf(value) + 1];
|
|
114
|
+
onViewChange(tabToView(nextTab));
|
|
115
|
+
handleRangePositionChange(nextTab);
|
|
116
|
+
});
|
|
117
|
+
if (hidden) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return /*#__PURE__*/_jsxs(DateTimeRangePickerTabsRoot, {
|
|
121
|
+
ownerState: props,
|
|
122
|
+
className: clsx(classes.root, className),
|
|
123
|
+
children: [!isPreviousHidden ? /*#__PURE__*/_jsx(IconButton, {
|
|
124
|
+
onClick: changeToPreviousTab,
|
|
125
|
+
className: classes.navigationButton,
|
|
126
|
+
title: localeText.openPreviousView,
|
|
127
|
+
children: /*#__PURE__*/_jsx(ArrowLeftIcon, {})
|
|
128
|
+
}) : /*#__PURE__*/_jsx(DateTimeRangePickerTabFiller, {
|
|
129
|
+
className: classes.filler
|
|
130
|
+
}), /*#__PURE__*/_jsx(DateTimeRangePickerTab, {
|
|
131
|
+
startIcon: isDatePickerView(view) ? dateIcon : timeIcon,
|
|
132
|
+
className: classes.tabButton,
|
|
133
|
+
size: "large",
|
|
134
|
+
children: tabLabel
|
|
135
|
+
}), !isNextHidden ? /*#__PURE__*/_jsx(IconButton, {
|
|
136
|
+
onClick: changeToNextTab,
|
|
137
|
+
className: classes.navigationButton,
|
|
138
|
+
title: localeText.openNextView,
|
|
139
|
+
children: /*#__PURE__*/_jsx(ArrowRightIcon, {})
|
|
140
|
+
}) : /*#__PURE__*/_jsx(DateTimeRangePickerTabFiller, {
|
|
141
|
+
className: classes.filler
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
process.env.NODE_ENV !== "production" ? DateTimeRangePickerTabs.propTypes = {
|
|
146
|
+
// ----------------------------- Warning --------------------------------
|
|
147
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
148
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
149
|
+
// ----------------------------------------------------------------------
|
|
150
|
+
/**
|
|
151
|
+
* Override or extend the styles applied to the component.
|
|
152
|
+
*/
|
|
153
|
+
classes: PropTypes.object,
|
|
154
|
+
className: PropTypes.string,
|
|
155
|
+
/**
|
|
156
|
+
* Date tab icon.
|
|
157
|
+
* @default DateRangeIcon
|
|
158
|
+
*/
|
|
159
|
+
dateIcon: PropTypes.element,
|
|
160
|
+
/**
|
|
161
|
+
* Toggles visibility of the tabs allowing view switching.
|
|
162
|
+
* @default `window.innerHeight < 667` for `DesktopDateTimeRangePicker` and `MobileDateTimeRangePicker`
|
|
163
|
+
*/
|
|
164
|
+
hidden: PropTypes.bool,
|
|
165
|
+
onRangePositionChange: PropTypes.func.isRequired,
|
|
166
|
+
/**
|
|
167
|
+
* Callback called when a tab is clicked.
|
|
168
|
+
* @template TView
|
|
169
|
+
* @param {TView} view The view to open
|
|
170
|
+
*/
|
|
171
|
+
onViewChange: PropTypes.func.isRequired,
|
|
172
|
+
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
173
|
+
/**
|
|
174
|
+
* Time tab icon.
|
|
175
|
+
* @default TimeIcon
|
|
176
|
+
*/
|
|
177
|
+
timeIcon: PropTypes.element,
|
|
178
|
+
/**
|
|
179
|
+
* Currently visible picker view.
|
|
180
|
+
*/
|
|
181
|
+
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired
|
|
182
|
+
} : void 0;
|
|
183
|
+
export { DateTimeRangePickerTabs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerSelectionState, PickerViewRenderer, TimeViewWithMeridiem, BaseClockProps } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { DateTimeRangePickerView } from '../internals/models';
|
|
4
|
+
import { DateRange } from '../models';
|
|
5
|
+
import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
|
|
6
|
+
export type DateTimeRangePickerTimeWrapperProps<TDate, TView extends DateTimeRangePickerView, TComponentProps extends Omit<BaseClockProps<TDate, TimeViewWithMeridiem>, 'value' | 'defaultValue' | 'onChange'>> = Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> & Omit<TComponentProps, 'views' | 'view' | 'onViewChange' | 'value' | 'defaultValue' | 'onChange'> & {
|
|
7
|
+
view: TView;
|
|
8
|
+
onViewChange?: (view: TView) => void;
|
|
9
|
+
views: readonly TView[];
|
|
10
|
+
value?: DateRange<TDate>;
|
|
11
|
+
defaultValue?: DateRange<TDate>;
|
|
12
|
+
onChange?: (value: DateRange<TDate>, selectionState: PickerSelectionState, selectedView: TView) => void;
|
|
13
|
+
viewRenderer?: PickerViewRenderer<DateRange<TDate>, TView, any, TComponentProps> | null;
|
|
14
|
+
openTo?: TView;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @ignore - internal component.
|
|
18
|
+
*/
|
|
19
|
+
declare function DateTimeRangePickerTimeWrapper<TDate, TView extends DateTimeRangePickerView, TComponentProps extends Omit<BaseClockProps<TDate, TimeViewWithMeridiem>, 'value' | 'defaultValue' | 'onChange'>>(props: DateTimeRangePickerTimeWrapperProps<TDate, TView, TComponentProps>, ref: React.Ref<HTMLDivElement>): React.ReactNode;
|
|
20
|
+
export { DateTimeRangePickerTimeWrapper };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["rangePosition", "onRangePositionChange", "viewRenderer", "value", "onChange", "defaultValue", "onViewChange", "views", "className"];
|
|
4
|
+
import { isInternalTimeView, useUtils } from '@mui/x-date-pickers/internals';
|
|
5
|
+
import { isRangeValid } from '../internals/utils/date-utils';
|
|
6
|
+
import { calculateRangeChange } from '../internals/utils/date-range-manager';
|
|
7
|
+
/**
|
|
8
|
+
* @ignore - internal component.
|
|
9
|
+
*/
|
|
10
|
+
function DateTimeRangePickerTimeWrapper(props, ref) {
|
|
11
|
+
var _ref, _ref2;
|
|
12
|
+
const utils = useUtils();
|
|
13
|
+
const {
|
|
14
|
+
rangePosition,
|
|
15
|
+
onRangePositionChange,
|
|
16
|
+
viewRenderer,
|
|
17
|
+
value,
|
|
18
|
+
onChange,
|
|
19
|
+
defaultValue,
|
|
20
|
+
onViewChange,
|
|
21
|
+
views
|
|
22
|
+
} = props,
|
|
23
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
24
|
+
if (!viewRenderer) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const currentValue = (_ref = rangePosition === 'start' ? value == null ? void 0 : value[0] : value == null ? void 0 : value[1]) != null ? _ref : null;
|
|
28
|
+
const currentDefaultValue = (_ref2 = rangePosition === 'start' ? defaultValue == null ? void 0 : defaultValue[0] : defaultValue == null ? void 0 : defaultValue[1]) != null ? _ref2 : null;
|
|
29
|
+
const handleOnChange = (newDate, selectionState, selectedView) => {
|
|
30
|
+
if (!onChange || !value) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const {
|
|
34
|
+
newRange
|
|
35
|
+
} = calculateRangeChange({
|
|
36
|
+
newDate,
|
|
37
|
+
utils,
|
|
38
|
+
range: value,
|
|
39
|
+
rangePosition
|
|
40
|
+
});
|
|
41
|
+
const isFullRangeSelected = rangePosition === 'end' && isRangeValid(utils, newRange);
|
|
42
|
+
const timeViews = views.filter(isInternalTimeView);
|
|
43
|
+
// reset view to the first time view and swap range position after selecting the last time view (start or end position)
|
|
44
|
+
if (selectedView === timeViews[timeViews.length - 1] && onViewChange) {
|
|
45
|
+
onViewChange(views[0]);
|
|
46
|
+
onRangePositionChange(rangePosition === 'start' ? 'end' : 'start');
|
|
47
|
+
}
|
|
48
|
+
onChange(newRange, isFullRangeSelected ? 'finish' : 'partial', selectedView);
|
|
49
|
+
};
|
|
50
|
+
return viewRenderer(_extends({}, other, {
|
|
51
|
+
ref,
|
|
52
|
+
views,
|
|
53
|
+
onViewChange,
|
|
54
|
+
value: currentValue,
|
|
55
|
+
onChange: handleOnChange,
|
|
56
|
+
defaultValue: currentDefaultValue
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
export { DateTimeRangePickerTimeWrapper };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BaseToolbarProps, ExportedBaseToolbarProps, DateOrTimeViewWithMeridiem, WrapperVariant } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { DateRange } from '../models';
|
|
4
|
+
import { UseRangePositionResponse } from '../internals/hooks/useRangePosition';
|
|
5
|
+
import { DateTimeRangePickerToolbarClasses } from './dateTimeRangePickerToolbarClasses';
|
|
6
|
+
type DateTimeRangeViews = Exclude<DateOrTimeViewWithMeridiem, 'year' | 'month'>;
|
|
7
|
+
export interface DateTimeRangePickerToolbarProps<TDate> extends BaseToolbarProps<DateRange<TDate>, DateTimeRangeViews>, Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'>, ExportedDateTimeRangePickerToolbarProps {
|
|
8
|
+
ampm?: boolean;
|
|
9
|
+
toolbarVariant?: WrapperVariant;
|
|
10
|
+
}
|
|
11
|
+
export interface ExportedDateTimeRangePickerToolbarProps extends ExportedBaseToolbarProps {
|
|
12
|
+
classes?: Partial<DateTimeRangePickerToolbarClasses>;
|
|
13
|
+
}
|
|
14
|
+
declare const DateTimeRangePickerToolbar: React.ForwardRefExoticComponent<DateTimeRangePickerToolbarProps<unknown> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export { DateTimeRangePickerToolbar };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["value", "rangePosition", "onRangePositionChange", "className", "onViewChange", "toolbarVariant", "onChange", "classes", "view"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
|
+
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
9
|
+
import { useLocaleText, useUtils } from '@mui/x-date-pickers/internals';
|
|
10
|
+
import { DateTimePickerToolbar } from '@mui/x-date-pickers/DateTimePicker';
|
|
11
|
+
import { getDateTimeRangePickerToolbarUtilityClass } from './dateTimeRangePickerToolbarClasses';
|
|
12
|
+
import { calculateRangeChange } from '../internals/utils/date-range-manager';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const useUtilityClasses = ownerState => {
|
|
16
|
+
const {
|
|
17
|
+
classes
|
|
18
|
+
} = ownerState;
|
|
19
|
+
const slots = {
|
|
20
|
+
root: ['root'],
|
|
21
|
+
startToolbar: ['startToolbar'],
|
|
22
|
+
endToolbar: ['endToolbar']
|
|
23
|
+
};
|
|
24
|
+
return composeClasses(slots, getDateTimeRangePickerToolbarUtilityClass, classes);
|
|
25
|
+
};
|
|
26
|
+
const DateTimeRangePickerToolbarRoot = styled('div', {
|
|
27
|
+
name: 'MuiDateTimeRangePickerToolbar',
|
|
28
|
+
slot: 'Root',
|
|
29
|
+
overridesResolver: (_, styles) => styles.root
|
|
30
|
+
})({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column'
|
|
33
|
+
});
|
|
34
|
+
const DateTimeRangePickerToolbarStart = styled(DateTimePickerToolbar, {
|
|
35
|
+
name: 'MuiDateTimeRangePickerToolbar',
|
|
36
|
+
slot: 'StartToolbar',
|
|
37
|
+
overridesResolver: (_, styles) => styles.startToolbar
|
|
38
|
+
})(({
|
|
39
|
+
ownerState
|
|
40
|
+
}) => _extends({
|
|
41
|
+
borderBottom: 'none'
|
|
42
|
+
}, (ownerState == null ? void 0 : ownerState.toolbarVariant) !== 'desktop' ? {
|
|
43
|
+
padding: '12px 8px 0 12px'
|
|
44
|
+
} : {
|
|
45
|
+
paddingBottom: 0
|
|
46
|
+
}));
|
|
47
|
+
const DateTimeRangePickerToolbarEnd = styled(DateTimePickerToolbar, {
|
|
48
|
+
name: 'MuiDateTimeRangePickerToolbar',
|
|
49
|
+
slot: 'EndToolbar',
|
|
50
|
+
overridesResolver: (_, styles) => styles.endToolbar
|
|
51
|
+
})(({
|
|
52
|
+
ownerState
|
|
53
|
+
}) => ({
|
|
54
|
+
padding: (ownerState == null ? void 0 : ownerState.toolbarVariant) !== 'desktop' ? '12px 8px 12px 12px' : undefined
|
|
55
|
+
}));
|
|
56
|
+
const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTimeRangePickerToolbar(inProps, ref) {
|
|
57
|
+
const props = useThemeProps({
|
|
58
|
+
props: inProps,
|
|
59
|
+
name: 'MuiDateTimeRangePickerToolbar'
|
|
60
|
+
});
|
|
61
|
+
const utils = useUtils();
|
|
62
|
+
const {
|
|
63
|
+
value: [start, end],
|
|
64
|
+
rangePosition,
|
|
65
|
+
onRangePositionChange,
|
|
66
|
+
className,
|
|
67
|
+
onViewChange,
|
|
68
|
+
onChange,
|
|
69
|
+
view
|
|
70
|
+
} = props,
|
|
71
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
72
|
+
const localeText = useLocaleText();
|
|
73
|
+
const ownerState = props;
|
|
74
|
+
const classes = useUtilityClasses(ownerState);
|
|
75
|
+
const handleStartRangeViewChange = React.useCallback(newView => {
|
|
76
|
+
if (newView === 'year' || newView === 'month') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (rangePosition !== 'start') {
|
|
80
|
+
onRangePositionChange('start');
|
|
81
|
+
}
|
|
82
|
+
onViewChange(newView);
|
|
83
|
+
}, [onRangePositionChange, onViewChange, rangePosition]);
|
|
84
|
+
const handleEndRangeViewChange = React.useCallback(newView => {
|
|
85
|
+
if (newView === 'year' || newView === 'month') {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (rangePosition !== 'end') {
|
|
89
|
+
onRangePositionChange('end');
|
|
90
|
+
}
|
|
91
|
+
onViewChange(newView);
|
|
92
|
+
}, [onRangePositionChange, onViewChange, rangePosition]);
|
|
93
|
+
const handleOnChange = React.useCallback(newDate => {
|
|
94
|
+
const {
|
|
95
|
+
nextSelection,
|
|
96
|
+
newRange
|
|
97
|
+
} = calculateRangeChange({
|
|
98
|
+
newDate,
|
|
99
|
+
utils,
|
|
100
|
+
range: props.value,
|
|
101
|
+
rangePosition,
|
|
102
|
+
allowRangeFlip: true
|
|
103
|
+
});
|
|
104
|
+
onRangePositionChange(nextSelection);
|
|
105
|
+
onChange(newRange);
|
|
106
|
+
}, [onChange, onRangePositionChange, props.value, rangePosition, utils]);
|
|
107
|
+
return /*#__PURE__*/_jsxs(DateTimeRangePickerToolbarRoot, {
|
|
108
|
+
className: clsx(className, classes.root),
|
|
109
|
+
ownerState: ownerState,
|
|
110
|
+
ref: ref,
|
|
111
|
+
children: [/*#__PURE__*/_jsx(DateTimeRangePickerToolbarStart, _extends({}, other, {
|
|
112
|
+
value: start,
|
|
113
|
+
onViewChange: handleStartRangeViewChange,
|
|
114
|
+
toolbarTitle: localeText.start,
|
|
115
|
+
ownerState: ownerState,
|
|
116
|
+
toolbarVariant: "desktop",
|
|
117
|
+
view: rangePosition === 'start' ? view : undefined,
|
|
118
|
+
className: classes.startToolbar,
|
|
119
|
+
onChange: handleOnChange
|
|
120
|
+
})), /*#__PURE__*/_jsx(DateTimeRangePickerToolbarEnd, _extends({}, other, {
|
|
121
|
+
value: end,
|
|
122
|
+
onViewChange: handleEndRangeViewChange,
|
|
123
|
+
toolbarTitle: localeText.end,
|
|
124
|
+
ownerState: ownerState,
|
|
125
|
+
toolbarVariant: "desktop",
|
|
126
|
+
view: rangePosition === 'end' ? view : undefined,
|
|
127
|
+
className: classes.endToolbar,
|
|
128
|
+
onChange: handleOnChange
|
|
129
|
+
}))]
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
process.env.NODE_ENV !== "production" ? DateTimeRangePickerToolbar.propTypes = {
|
|
133
|
+
// ----------------------------- Warning --------------------------------
|
|
134
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
135
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
136
|
+
// ----------------------------------------------------------------------
|
|
137
|
+
ampm: PropTypes.bool,
|
|
138
|
+
classes: PropTypes.object,
|
|
139
|
+
className: PropTypes.string,
|
|
140
|
+
disabled: PropTypes.bool,
|
|
141
|
+
/**
|
|
142
|
+
* If `true`, show the toolbar even in desktop mode.
|
|
143
|
+
* @default `true` for Desktop, `false` for Mobile.
|
|
144
|
+
*/
|
|
145
|
+
hidden: PropTypes.bool,
|
|
146
|
+
isLandscape: PropTypes.bool.isRequired,
|
|
147
|
+
onChange: PropTypes.func.isRequired,
|
|
148
|
+
onRangePositionChange: PropTypes.func.isRequired,
|
|
149
|
+
/**
|
|
150
|
+
* Callback called when a toolbar is clicked
|
|
151
|
+
* @template TView
|
|
152
|
+
* @param {TView} view The view to open
|
|
153
|
+
*/
|
|
154
|
+
onViewChange: PropTypes.func.isRequired,
|
|
155
|
+
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
156
|
+
readOnly: PropTypes.bool,
|
|
157
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
158
|
+
titleId: PropTypes.string,
|
|
159
|
+
/**
|
|
160
|
+
* Toolbar date format.
|
|
161
|
+
*/
|
|
162
|
+
toolbarFormat: PropTypes.string,
|
|
163
|
+
/**
|
|
164
|
+
* Toolbar value placeholder—it is displayed when the value is empty.
|
|
165
|
+
* @default "––"
|
|
166
|
+
*/
|
|
167
|
+
toolbarPlaceholder: PropTypes.node,
|
|
168
|
+
toolbarVariant: PropTypes.oneOf(['desktop', 'mobile']),
|
|
169
|
+
value: PropTypes.arrayOf(PropTypes.any).isRequired,
|
|
170
|
+
/**
|
|
171
|
+
* Currently visible picker view.
|
|
172
|
+
*/
|
|
173
|
+
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'seconds']).isRequired,
|
|
174
|
+
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'seconds']).isRequired).isRequired
|
|
175
|
+
} : void 0;
|
|
176
|
+
export { DateTimeRangePickerToolbar };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface DateTimeRangePickerTabsClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the tab button element. */
|
|
5
|
+
tabButton: string;
|
|
6
|
+
/** Styles applied to the tab navigation button elements. */
|
|
7
|
+
navigationButton: string;
|
|
8
|
+
/** Styles applied to the filler element, shown instead of a navigation arrow. */
|
|
9
|
+
filler: string;
|
|
10
|
+
}
|
|
11
|
+
export type DateTimeRangePickerTabsClassKey = keyof DateTimeRangePickerTabsClasses;
|
|
12
|
+
export declare function getDateTimeRangePickerTabsUtilityClass(slot: string): string;
|
|
13
|
+
export declare const dateTimeRangePickerTabsClasses: DateTimeRangePickerTabsClasses;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
export function getDateTimeRangePickerTabsUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiDateTimeRangePickerTabs', slot);
|
|
5
|
+
}
|
|
6
|
+
export const dateTimeRangePickerTabsClasses = generateUtilityClasses('MuiDateTimeRangePickerTabs', ['root', 'tabButton', 'navigationButton', 'filler']);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DateTimeRangePickerToolbarClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the start toolbar element. */
|
|
5
|
+
startToolbar: string;
|
|
6
|
+
/** Styles applied to the end toolbar element. */
|
|
7
|
+
endToolbar: string;
|
|
8
|
+
}
|
|
9
|
+
export type DateTimeRangePickerToolbarClassKey = keyof DateTimeRangePickerToolbarClasses;
|
|
10
|
+
export declare function getDateTimeRangePickerToolbarUtilityClass(slot: string): string;
|
|
11
|
+
export declare const dateTimeRangePickerToolbarClasses: DateTimeRangePickerToolbarClasses;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
2
|
+
export function getDateTimeRangePickerToolbarUtilityClass(slot) {
|
|
3
|
+
return generateUtilityClass('MuiDateTimeRangePickerToolbar', slot);
|
|
4
|
+
}
|
|
5
|
+
export const dateTimeRangePickerToolbarClasses = generateUtilityClasses('MuiDateTimeRangePickerToolbar', ['root', 'startToolbar', 'endToolbar']);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { DateTimeRangePicker } from './DateTimeRangePicker';
|
|
2
|
+
export type { DateTimeRangePickerProps, DateTimeRangePickerSlots, DateTimeRangePickerSlotProps, } from './DateTimeRangePicker.types';
|
|
3
|
+
export { DateTimeRangePickerTabs } from './DateTimeRangePickerTabs';
|
|
4
|
+
export type { ExportedDateTimeRangePickerTabsProps } from './DateTimeRangePickerTabs';
|
|
5
|
+
export { getDateTimeRangePickerTabsUtilityClass, dateTimeRangePickerTabsClasses, } from './dateTimeRangePickerTabsClasses';
|
|
6
|
+
export type { DateTimeRangePickerTabsClasses, DateTimeRangePickerTabsClassKey, } from './dateTimeRangePickerTabsClasses';
|
|
7
|
+
export { DateTimeRangePickerToolbar } from './DateTimeRangePickerToolbar';
|
|
8
|
+
export type { DateTimeRangePickerToolbarProps } from './DateTimeRangePickerToolbar';
|
|
9
|
+
export { getDateTimeRangePickerToolbarUtilityClass, dateTimeRangePickerToolbarClasses, } from './dateTimeRangePickerToolbarClasses';
|
|
10
|
+
export type { DateTimeRangePickerToolbarClasses, DateTimeRangePickerToolbarClassKey, } from './dateTimeRangePickerToolbarClasses';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DateTimeRangePicker } from './DateTimeRangePicker';
|
|
2
|
+
export { DateTimeRangePickerTabs } from './DateTimeRangePickerTabs';
|
|
3
|
+
export { getDateTimeRangePickerTabsUtilityClass, dateTimeRangePickerTabsClasses } from './dateTimeRangePickerTabsClasses';
|
|
4
|
+
export { DateTimeRangePickerToolbar } from './DateTimeRangePickerToolbar';
|
|
5
|
+
export { getDateTimeRangePickerToolbarUtilityClass, dateTimeRangePickerToolbarClasses } from './dateTimeRangePickerToolbarClasses';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
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';
|
|
4
|
+
import { TimeViewRendererProps } from '@mui/x-date-pickers/timeViewRenderers';
|
|
5
|
+
import { DigitalClockSlots, DigitalClockSlotProps } from '@mui/x-date-pickers/DigitalClock';
|
|
6
|
+
import { MultiSectionDigitalClockSlots, MultiSectionDigitalClockSlotProps } from '@mui/x-date-pickers/MultiSectionDigitalClock';
|
|
7
|
+
import { DateRange, DateTimeRangeValidationError } from '../models';
|
|
8
|
+
import { DateTimeRangePickerView, DateTimeRangePickerViewExternal } from '../internals/models';
|
|
9
|
+
import { DateRangeCalendarSlots, DateRangeCalendarSlotProps, ExportedDateRangeCalendarProps } from '../DateRangeCalendar';
|
|
10
|
+
import { DateTimeRangePickerToolbarProps, ExportedDateTimeRangePickerToolbarProps } from './DateTimeRangePickerToolbar';
|
|
11
|
+
import { DateRangeViewRendererProps } from '../dateRangeViewRenderers';
|
|
12
|
+
import { DateTimeRangePickerTabsProps, ExportedDateTimeRangePickerTabsProps } from './DateTimeRangePickerTabs';
|
|
13
|
+
export interface BaseDateTimeRangePickerSlots<TDate> extends DateRangeCalendarSlots<TDate>, DigitalClockSlots, MultiSectionDigitalClockSlots {
|
|
14
|
+
/**
|
|
15
|
+
* Tabs enabling toggling between date and time pickers.
|
|
16
|
+
* @default DateTimeRangePickerTabs
|
|
17
|
+
*/
|
|
18
|
+
tabs?: React.ElementType<DateTimeRangePickerTabsProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom component for the toolbar rendered above the views.
|
|
21
|
+
* @default DateTimeRangePickerToolbar
|
|
22
|
+
*/
|
|
23
|
+
toolbar?: React.JSXElementConstructor<DateTimeRangePickerToolbarProps<TDate>>;
|
|
24
|
+
}
|
|
25
|
+
export interface BaseDateTimeRangePickerSlotProps<TDate> extends DateRangeCalendarSlotProps<TDate>, DigitalClockSlotProps, MultiSectionDigitalClockSlotProps {
|
|
26
|
+
/**
|
|
27
|
+
* Props passed down to the tabs component.
|
|
28
|
+
*/
|
|
29
|
+
tabs?: ExportedDateTimeRangePickerTabsProps;
|
|
30
|
+
/**
|
|
31
|
+
* Props passed down to the toolbar component.
|
|
32
|
+
*/
|
|
33
|
+
toolbar?: ExportedDateTimeRangePickerToolbarProps;
|
|
34
|
+
}
|
|
35
|
+
export interface BaseDateTimeRangePickerProps<TDate> 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> {
|
|
36
|
+
/**
|
|
37
|
+
* Overridable component slots.
|
|
38
|
+
* @default {}
|
|
39
|
+
*/
|
|
40
|
+
slots?: BaseDateTimeRangePickerSlots<TDate>;
|
|
41
|
+
/**
|
|
42
|
+
* The props used for each component slot.
|
|
43
|
+
* @default {}
|
|
44
|
+
*/
|
|
45
|
+
slotProps?: BaseDateTimeRangePickerSlotProps<TDate>;
|
|
46
|
+
/**
|
|
47
|
+
* Define custom view renderers for each section.
|
|
48
|
+
* If `null`, the section will only have field editing.
|
|
49
|
+
* If `undefined`, internally defined view will be the used.
|
|
50
|
+
*/
|
|
51
|
+
viewRenderers?: Partial<PickerViewRendererLookup<DateRange<TDate>, DateTimeRangePickerView, Omit<DateRangeViewRendererProps<TDate, 'day'>, 'view' | 'slots' | 'slotProps'> & Omit<TimeViewRendererProps<TimeViewWithMeridiem, BaseClockProps<TDate, TimeViewWithMeridiem>>, 'view' | 'slots' | 'slotProps'> & {
|
|
52
|
+
view: DateTimeRangePickerView;
|
|
53
|
+
}, {}>>;
|
|
54
|
+
}
|
|
55
|
+
type UseDateTimeRangePickerDefaultizedProps<TDate, Props extends BaseDateTimeRangePickerProps<TDate>> = LocalizedComponent<TDate, Omit<DefaultizedProps<Props, 'openTo' | 'ampm' | keyof BaseDateValidationProps<TDate>>, 'views'>> & {
|
|
56
|
+
shouldRenderTimeInASingleColumn: boolean;
|
|
57
|
+
views: readonly DateTimeRangePickerView[];
|
|
58
|
+
};
|
|
59
|
+
export declare function useDateTimeRangePickerDefaultizedProps<TDate, Props extends BaseDateTimeRangePickerProps<TDate>>(props: Props, name: string): UseDateTimeRangePickerDefaultizedProps<TDate, Props>;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { useThemeProps } from '@mui/material/styles';
|
|
3
|
+
import { useDefaultDates, useUtils, applyDefaultDate, applyDefaultViewProps, resolveTimeViewsResponse } from '@mui/x-date-pickers/internals';
|
|
4
|
+
import { DateTimeRangePickerToolbar } from './DateTimeRangePickerToolbar';
|
|
5
|
+
import { DateTimeRangePickerTabs } from './DateTimeRangePickerTabs';
|
|
6
|
+
export function useDateTimeRangePickerDefaultizedProps(props, name) {
|
|
7
|
+
var _themeProps$ampm, _themeProps$disableFu, _themeProps$disablePa, _themeProps$slotProps;
|
|
8
|
+
const utils = useUtils();
|
|
9
|
+
const defaultDates = useDefaultDates();
|
|
10
|
+
const themeProps = useThemeProps({
|
|
11
|
+
props,
|
|
12
|
+
name
|
|
13
|
+
});
|
|
14
|
+
const ampm = (_themeProps$ampm = themeProps.ampm) != null ? _themeProps$ampm : utils.is12HourCycleInCurrentLocale();
|
|
15
|
+
const {
|
|
16
|
+
openTo,
|
|
17
|
+
views: defaultViews
|
|
18
|
+
} = applyDefaultViewProps({
|
|
19
|
+
views: themeProps.views,
|
|
20
|
+
openTo: themeProps.openTo,
|
|
21
|
+
defaultViews: ['day', 'hours', 'minutes'],
|
|
22
|
+
defaultOpenTo: 'day'
|
|
23
|
+
});
|
|
24
|
+
const {
|
|
25
|
+
shouldRenderTimeInASingleColumn,
|
|
26
|
+
thresholdToRenderTimeInASingleColumn,
|
|
27
|
+
views,
|
|
28
|
+
timeSteps
|
|
29
|
+
} = resolveTimeViewsResponse({
|
|
30
|
+
thresholdToRenderTimeInASingleColumn: themeProps.thresholdToRenderTimeInASingleColumn,
|
|
31
|
+
ampm,
|
|
32
|
+
timeSteps: themeProps.timeSteps,
|
|
33
|
+
views: defaultViews
|
|
34
|
+
});
|
|
35
|
+
return _extends({}, themeProps, {
|
|
36
|
+
timeSteps,
|
|
37
|
+
openTo,
|
|
38
|
+
shouldRenderTimeInASingleColumn,
|
|
39
|
+
thresholdToRenderTimeInASingleColumn,
|
|
40
|
+
views,
|
|
41
|
+
ampm,
|
|
42
|
+
disableFuture: (_themeProps$disableFu = themeProps.disableFuture) != null ? _themeProps$disableFu : false,
|
|
43
|
+
disablePast: (_themeProps$disablePa = themeProps.disablePast) != null ? _themeProps$disablePa : false,
|
|
44
|
+
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
45
|
+
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
|
|
46
|
+
slots: _extends({
|
|
47
|
+
tabs: DateTimeRangePickerTabs,
|
|
48
|
+
toolbar: DateTimeRangePickerToolbar
|
|
49
|
+
}, themeProps.slots),
|
|
50
|
+
slotProps: _extends({}, themeProps.slotProps, {
|
|
51
|
+
toolbar: _extends({}, (_themeProps$slotProps = themeProps.slotProps) == null ? void 0 : _themeProps$slotProps.toolbar, {
|
|
52
|
+
ampm
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -3,7 +3,7 @@ import { UseDesktopRangePickerSlots, UseDesktopRangePickerSlotProps, DesktopRang
|
|
|
3
3
|
import { BaseDateRangePickerProps, BaseDateRangePickerSlots, BaseDateRangePickerSlotProps } from '../DateRangePicker/shared';
|
|
4
4
|
export interface DesktopDateRangePickerSlots<TDate> extends BaseDateRangePickerSlots<TDate>, MakeOptional<UseDesktopRangePickerSlots<TDate, 'day'>, 'field'> {
|
|
5
5
|
}
|
|
6
|
-
export interface DesktopDateRangePickerSlotProps<TDate> extends BaseDateRangePickerSlotProps<TDate>, UseDesktopRangePickerSlotProps<TDate, 'day'> {
|
|
6
|
+
export interface DesktopDateRangePickerSlotProps<TDate> extends BaseDateRangePickerSlotProps<TDate>, Omit<UseDesktopRangePickerSlotProps<TDate, 'day'>, 'tabs'> {
|
|
7
7
|
}
|
|
8
8
|
export interface DesktopDateRangePickerProps<TDate> extends BaseDateRangePickerProps<TDate>, DesktopRangeOnlyPickerProps<TDate> {
|
|
9
9
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DesktopDateTimeRangePickerProps } from './DesktopDateTimeRangePicker.types';
|
|
3
|
+
type DesktopDateRangePickerComponent = (<TDate>(props: DesktopDateTimeRangePickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
4
|
+
propTypes?: any;
|
|
5
|
+
};
|
|
6
|
+
declare const DesktopDateTimeRangePicker: DesktopDateRangePickerComponent;
|
|
7
|
+
export { DesktopDateTimeRangePicker };
|