@mui/x-date-pickers-pro 5.0.0-alpha.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 +3785 -0
- package/DateRangePicker/DateRangePicker.d.ts +66 -0
- package/DateRangePicker/DateRangePicker.js +519 -0
- package/DateRangePicker/DateRangePickerInput.d.ts +37 -0
- package/DateRangePicker/DateRangePickerInput.js +128 -0
- package/DateRangePicker/DateRangePickerToolbar.d.ts +15 -0
- package/DateRangePicker/DateRangePickerToolbar.js +59 -0
- package/DateRangePicker/DateRangePickerView.d.ts +41 -0
- package/DateRangePicker/DateRangePickerView.js +179 -0
- package/DateRangePicker/DateRangePickerViewDesktop.d.ts +30 -0
- package/DateRangePicker/DateRangePickerViewDesktop.js +154 -0
- package/DateRangePicker/DateRangePickerViewMobile.d.ts +15 -0
- package/DateRangePicker/DateRangePickerViewMobile.js +60 -0
- package/DateRangePicker/date-range-manager.d.ts +14 -0
- package/DateRangePicker/date-range-manager.js +43 -0
- package/DateRangePicker/index.d.ts +3 -0
- package/DateRangePicker/index.js +1 -0
- package/DateRangePicker/package.json +6 -0
- package/DateRangePickerDay/DateRangePickerDay.d.ts +52 -0
- package/DateRangePickerDay/DateRangePickerDay.js +290 -0
- package/DateRangePickerDay/dateRangePickerDayClasses.d.ts +29 -0
- package/DateRangePickerDay/dateRangePickerDayClasses.js +5 -0
- package/DateRangePickerDay/index.d.ts +4 -0
- package/DateRangePickerDay/index.js +2 -0
- package/DateRangePickerDay/package.json +6 -0
- package/DesktopDateRangePicker/DesktopDateRangePicker.d.ts +66 -0
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +485 -0
- package/DesktopDateRangePicker/index.d.ts +2 -0
- package/DesktopDateRangePicker/index.js +1 -0
- package/DesktopDateRangePicker/package.json +6 -0
- package/MobileDateRangePicker/MobileDateRangePicker.d.ts +66 -0
- package/MobileDateRangePicker/MobileDateRangePicker.js +495 -0
- package/MobileDateRangePicker/index.d.ts +2 -0
- package/MobileDateRangePicker/index.js +1 -0
- package/MobileDateRangePicker/package.json +6 -0
- package/README.md +29 -0
- package/StaticDateRangePicker/StaticDateRangePicker.d.ts +69 -0
- package/StaticDateRangePicker/StaticDateRangePicker.js +455 -0
- package/StaticDateRangePicker/index.d.ts +2 -0
- package/StaticDateRangePicker/index.js +1 -0
- package/StaticDateRangePicker/package.json +6 -0
- package/index.d.ts +7 -0
- package/index.js +12 -0
- package/internal/hooks/validation/useDateRangeValidation.d.ts +12 -0
- package/internal/hooks/validation/useDateRangeValidation.js +27 -0
- package/internal/models/dateRange.d.ts +8 -0
- package/internal/models/dateRange.js +1 -0
- package/internal/models/index.d.ts +1 -0
- package/internal/models/index.js +1 -0
- package/internal/utils/date-utils.d.ts +7 -0
- package/internal/utils/date-utils.js +19 -0
- package/internal/utils/releaseInfo.d.ts +1 -0
- package/internal/utils/releaseInfo.js +15 -0
- package/internal/utils/utils.d.ts +1 -0
- package/internal/utils/utils.js +1 -0
- package/legacy/DateRangePicker/DateRangePicker.js +528 -0
- package/legacy/DateRangePicker/DateRangePickerInput.js +141 -0
- package/legacy/DateRangePicker/DateRangePickerToolbar.js +66 -0
- package/legacy/DateRangePicker/DateRangePickerView.js +184 -0
- package/legacy/DateRangePicker/DateRangePickerViewDesktop.js +172 -0
- package/legacy/DateRangePicker/DateRangePickerViewMobile.js +63 -0
- package/legacy/DateRangePicker/date-range-manager.js +51 -0
- package/legacy/DateRangePicker/index.js +1 -0
- package/legacy/DateRangePickerDay/DateRangePickerDay.js +296 -0
- package/legacy/DateRangePickerDay/dateRangePickerDayClasses.js +5 -0
- package/legacy/DateRangePickerDay/index.js +2 -0
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +494 -0
- package/legacy/DesktopDateRangePicker/index.js +1 -0
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +504 -0
- package/legacy/MobileDateRangePicker/index.js +1 -0
- package/legacy/StaticDateRangePicker/StaticDateRangePicker.js +465 -0
- package/legacy/StaticDateRangePicker/index.js +1 -0
- package/legacy/index.js +12 -0
- package/legacy/internal/hooks/validation/useDateRangeValidation.js +33 -0
- package/legacy/internal/models/dateRange.js +1 -0
- package/legacy/internal/models/index.js +1 -0
- package/legacy/internal/utils/date-utils.js +22 -0
- package/legacy/internal/utils/releaseInfo.js +15 -0
- package/legacy/internal/utils/utils.js +1 -0
- package/legacy/themeAugmentation/index.js +3 -0
- package/modern/DateRangePicker/DateRangePicker.js +519 -0
- package/modern/DateRangePicker/DateRangePickerInput.js +124 -0
- package/modern/DateRangePicker/DateRangePickerToolbar.js +59 -0
- package/modern/DateRangePicker/DateRangePickerView.js +179 -0
- package/modern/DateRangePicker/DateRangePickerViewDesktop.js +154 -0
- package/modern/DateRangePicker/DateRangePickerViewMobile.js +60 -0
- package/modern/DateRangePicker/date-range-manager.js +43 -0
- package/modern/DateRangePicker/index.js +1 -0
- package/modern/DateRangePickerDay/DateRangePickerDay.js +290 -0
- package/modern/DateRangePickerDay/dateRangePickerDayClasses.js +5 -0
- package/modern/DateRangePickerDay/index.js +2 -0
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +485 -0
- package/modern/DesktopDateRangePicker/index.js +1 -0
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +495 -0
- package/modern/MobileDateRangePicker/index.js +1 -0
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +455 -0
- package/modern/StaticDateRangePicker/index.js +1 -0
- package/modern/index.js +12 -0
- package/modern/internal/hooks/validation/useDateRangeValidation.js +27 -0
- package/modern/internal/models/dateRange.js +1 -0
- package/modern/internal/models/index.js +1 -0
- package/modern/internal/utils/date-utils.js +19 -0
- package/modern/internal/utils/releaseInfo.js +15 -0
- package/modern/internal/utils/utils.js +1 -0
- package/modern/themeAugmentation/index.js +3 -0
- package/node/DateRangePicker/DateRangePicker.js +540 -0
- package/node/DateRangePicker/DateRangePickerInput.js +148 -0
- package/node/DateRangePicker/DateRangePickerToolbar.js +79 -0
- package/node/DateRangePicker/DateRangePickerView.js +206 -0
- package/node/DateRangePicker/DateRangePickerViewDesktop.js +175 -0
- package/node/DateRangePicker/DateRangePickerViewMobile.js +80 -0
- package/node/DateRangePicker/date-range-manager.js +52 -0
- package/node/DateRangePicker/index.js +13 -0
- package/node/DateRangePickerDay/DateRangePickerDay.js +315 -0
- package/node/DateRangePickerDay/dateRangePickerDayClasses.js +16 -0
- package/node/DateRangePickerDay/index.js +27 -0
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +506 -0
- package/node/DesktopDateRangePicker/index.js +13 -0
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +516 -0
- package/node/MobileDateRangePicker/index.js +13 -0
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +475 -0
- package/node/StaticDateRangePicker/index.js +13 -0
- package/node/index.js +105 -0
- package/node/internal/hooks/validation/useDateRangeValidation.js +40 -0
- package/node/internal/models/dateRange.js +5 -0
- package/node/internal/models/index.js +18 -0
- package/node/internal/utils/date-utils.js +40 -0
- package/node/internal/utils/releaseInfo.js +25 -0
- package/node/internal/utils/utils.js +10 -0
- package/node/themeAugmentation/index.js +44 -0
- package/package.json +77 -0
- package/themeAugmentation/components.d.ts +13 -0
- package/themeAugmentation/index.d.ts +3 -0
- package/themeAugmentation/index.js +3 -0
- package/themeAugmentation/overrides.d.ts +13 -0
- package/themeAugmentation/package.json +6 -0
- package/themeAugmentation/props.d.ts +12 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ResponsiveWrapperProps, ValidationProps } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { ExportedDateRangePickerViewProps } from './DateRangePickerView';
|
|
4
|
+
import { ExportedDateRangePickerInputProps } from './DateRangePickerInput';
|
|
5
|
+
import { RangeInput, DateRange } from '../internal/models/dateRange';
|
|
6
|
+
import { DateRangeValidationError } from '../internal/hooks/validation/useDateRangeValidation';
|
|
7
|
+
interface BaseDateRangePickerProps<TDate> extends ExportedDateRangePickerViewProps<TDate>, ValidationProps<DateRangeValidationError, RangeInput<TDate>>, ExportedDateRangePickerInputProps {
|
|
8
|
+
/**
|
|
9
|
+
* The components used for each slot.
|
|
10
|
+
* Either a string to use a HTML element or a component.
|
|
11
|
+
* @default {}
|
|
12
|
+
*/
|
|
13
|
+
components?: ExportedDateRangePickerViewProps<TDate>['components'] & ExportedDateRangePickerInputProps['components'];
|
|
14
|
+
/**
|
|
15
|
+
* Text for end input label and toolbar placeholder.
|
|
16
|
+
* @default 'End'
|
|
17
|
+
*/
|
|
18
|
+
endText?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Custom mask. Can be used to override generate from format. (e.g. `__/__/____ __:__` or `__/__/____ __:__ _M`).
|
|
21
|
+
* @default '__/__/____'
|
|
22
|
+
*/
|
|
23
|
+
mask?: ExportedDateRangePickerInputProps['mask'];
|
|
24
|
+
/**
|
|
25
|
+
* Min selectable date. @DateIOType
|
|
26
|
+
* @default defaultMinDate
|
|
27
|
+
*/
|
|
28
|
+
minDate?: TDate;
|
|
29
|
+
/**
|
|
30
|
+
* Max selectable date. @DateIOType
|
|
31
|
+
* @default defaultMaxDate
|
|
32
|
+
*/
|
|
33
|
+
maxDate?: TDate;
|
|
34
|
+
/**
|
|
35
|
+
* Callback fired when the value (the selected date range) changes @DateIOType.
|
|
36
|
+
* @param {DateRange<TDate>} date The new parsed date range.
|
|
37
|
+
* @param {string} keyboardInputValue The current value of the keyboard input.
|
|
38
|
+
*/
|
|
39
|
+
onChange: (date: DateRange<TDate>, keyboardInputValue?: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Text for start input label and toolbar placeholder.
|
|
42
|
+
* @default 'Start'
|
|
43
|
+
*/
|
|
44
|
+
startText?: React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* The value of the date range picker.
|
|
47
|
+
*/
|
|
48
|
+
value: RangeInput<TDate>;
|
|
49
|
+
}
|
|
50
|
+
export interface DateRangePickerProps<TDate> extends BaseDateRangePickerProps<TDate>, ResponsiveWrapperProps {
|
|
51
|
+
}
|
|
52
|
+
declare type DateRangePickerComponent = (<TDate>(props: DateRangePickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => JSX.Element) & {
|
|
53
|
+
propTypes?: any;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* Demos:
|
|
58
|
+
*
|
|
59
|
+
* - [Date Range Picker](https://mui.com/components/x/react-date-pickers/date-range-picker/)
|
|
60
|
+
*
|
|
61
|
+
* API:
|
|
62
|
+
*
|
|
63
|
+
* - [DateRangePicker API](https://mui.com/api/date-range-picker/)
|
|
64
|
+
*/
|
|
65
|
+
export declare const DateRangePicker: DateRangePickerComponent;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["calendars", "value", "onChange", "mask", "startText", "endText", "inputFormat", "minDate", "maxDate"];
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { useThemeProps } from '@mui/material/styles';
|
|
7
|
+
import { useLicenseVerifier } from '@mui/x-license-pro';
|
|
8
|
+
import { ResponsiveTooltipWrapper, useDefaultDates, useUtils, usePickerState } from '@mui/x-date-pickers/internals';
|
|
9
|
+
import { DateRangePickerView } from './DateRangePickerView';
|
|
10
|
+
import { DateRangePickerInput } from './DateRangePickerInput';
|
|
11
|
+
import { useDateRangeValidation } from '../internal/hooks/validation/useDateRangeValidation';
|
|
12
|
+
import { parseRangeInputValue } from '../internal/utils/date-utils';
|
|
13
|
+
import { getReleaseInfo } from '../internal/utils/releaseInfo';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const releaseInfo = getReleaseInfo();
|
|
16
|
+
const KeyboardDateInputComponent = DateRangePickerInput;
|
|
17
|
+
const PureDateInputComponent = DateRangePickerInput;
|
|
18
|
+
const rangePickerValueManager = {
|
|
19
|
+
emptyValue: [null, null],
|
|
20
|
+
parseInput: parseRangeInputValue,
|
|
21
|
+
areValuesEqual: (utils, a, b) => utils.isEqual(a[0], b[0]) && utils.isEqual(a[1], b[1])
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* Demos:
|
|
27
|
+
*
|
|
28
|
+
* - [Date Range Picker](https://mui.com/components/x/react-date-pickers/date-range-picker/)
|
|
29
|
+
*
|
|
30
|
+
* API:
|
|
31
|
+
*
|
|
32
|
+
* - [DateRangePicker API](https://mui.com/api/date-range-picker/)
|
|
33
|
+
*/
|
|
34
|
+
export const DateRangePicker = /*#__PURE__*/React.forwardRef(function DateRangePicker(inProps, ref) {
|
|
35
|
+
const props = useThemeProps({
|
|
36
|
+
props: inProps,
|
|
37
|
+
name: 'MuiDateRangePicker'
|
|
38
|
+
});
|
|
39
|
+
useLicenseVerifier('x-date-pickers-pro', releaseInfo);
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
calendars = 2,
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
mask = '__/__/____',
|
|
46
|
+
startText = 'Start',
|
|
47
|
+
endText = 'End',
|
|
48
|
+
inputFormat: passedInputFormat,
|
|
49
|
+
minDate: minDateProp,
|
|
50
|
+
maxDate: maxDateProp
|
|
51
|
+
} = props,
|
|
52
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
53
|
+
|
|
54
|
+
const utils = useUtils();
|
|
55
|
+
const defaultDates = useDefaultDates();
|
|
56
|
+
const minDate = minDateProp != null ? minDateProp : defaultDates.minDate;
|
|
57
|
+
const maxDate = maxDateProp != null ? maxDateProp : defaultDates.maxDate;
|
|
58
|
+
const [currentlySelectingRangeEnd, setCurrentlySelectingRangeEnd] = React.useState('start');
|
|
59
|
+
|
|
60
|
+
const pickerStateProps = _extends({}, other, {
|
|
61
|
+
value,
|
|
62
|
+
onChange
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const restProps = _extends({}, other, {
|
|
66
|
+
minDate,
|
|
67
|
+
maxDate
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
pickerProps,
|
|
72
|
+
inputProps,
|
|
73
|
+
wrapperProps
|
|
74
|
+
} = usePickerState(pickerStateProps, rangePickerValueManager);
|
|
75
|
+
const validationError = useDateRangeValidation(props);
|
|
76
|
+
|
|
77
|
+
const DateInputProps = _extends({}, inputProps, restProps, {
|
|
78
|
+
currentlySelectingRangeEnd,
|
|
79
|
+
inputFormat: passedInputFormat || utils.formats.keyboardDate,
|
|
80
|
+
setCurrentlySelectingRangeEnd,
|
|
81
|
+
startText,
|
|
82
|
+
endText,
|
|
83
|
+
mask,
|
|
84
|
+
validationError,
|
|
85
|
+
ref
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return /*#__PURE__*/_jsx(ResponsiveTooltipWrapper, _extends({}, restProps, wrapperProps, {
|
|
89
|
+
DateInputProps: DateInputProps,
|
|
90
|
+
KeyboardDateInputComponent: KeyboardDateInputComponent,
|
|
91
|
+
PureDateInputComponent: PureDateInputComponent,
|
|
92
|
+
children: /*#__PURE__*/_jsx(DateRangePickerView, _extends({
|
|
93
|
+
open: wrapperProps.open,
|
|
94
|
+
DateInputProps: DateInputProps,
|
|
95
|
+
calendars: calendars,
|
|
96
|
+
currentlySelectingRangeEnd: currentlySelectingRangeEnd,
|
|
97
|
+
setCurrentlySelectingRangeEnd: setCurrentlySelectingRangeEnd,
|
|
98
|
+
startText: startText,
|
|
99
|
+
endText: endText
|
|
100
|
+
}, pickerProps, restProps))
|
|
101
|
+
}));
|
|
102
|
+
});
|
|
103
|
+
process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
104
|
+
// ----------------------------- Warning --------------------------------
|
|
105
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
106
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
107
|
+
// ----------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Regular expression to detect "accepted" symbols.
|
|
111
|
+
* @default /\dap/gi
|
|
112
|
+
*/
|
|
113
|
+
acceptRegex: PropTypes.instanceOf(RegExp),
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* If `true`, `onChange` is fired on click even if the same date is selected.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
allowSameDateSelection: PropTypes.bool,
|
|
120
|
+
autoFocus: PropTypes.bool,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The number of calendars that render on **desktop**.
|
|
124
|
+
* @default 2
|
|
125
|
+
*/
|
|
126
|
+
calendars: PropTypes.oneOf([1, 2, 3]),
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Cancel text message.
|
|
130
|
+
* @default 'Cancel'
|
|
131
|
+
*/
|
|
132
|
+
cancelText: PropTypes.node,
|
|
133
|
+
children: PropTypes.node,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* className applied to the root component.
|
|
137
|
+
*/
|
|
138
|
+
className: PropTypes.string,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* If `true`, it shows the clear action in the picker dialog.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
clearable: PropTypes.bool,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Clear text message.
|
|
148
|
+
* @default 'Clear'
|
|
149
|
+
*/
|
|
150
|
+
clearText: PropTypes.node,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The components used for each slot.
|
|
154
|
+
* Either a string to use a HTML element or a component.
|
|
155
|
+
* @default {}
|
|
156
|
+
*/
|
|
157
|
+
components: PropTypes.object,
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The props used for each slot inside.
|
|
161
|
+
* @default {}
|
|
162
|
+
*/
|
|
163
|
+
componentsProps: PropTypes.object,
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Default calendar month displayed when `value={null}`.
|
|
167
|
+
*/
|
|
168
|
+
defaultCalendarMonth: PropTypes.any,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* CSS media query when `Mobile` mode will be changed to `Desktop`.
|
|
172
|
+
* @default '@media (pointer: fine)'
|
|
173
|
+
* @example '@media (min-width: 720px)' or theme.breakpoints.up('sm')
|
|
174
|
+
*/
|
|
175
|
+
desktopModeMediaQuery: PropTypes.string,
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Props applied to the [`Dialog`](/api/dialog/) element.
|
|
179
|
+
*/
|
|
180
|
+
DialogProps: PropTypes.object,
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* If `true`, after selecting `start` date calendar will not automatically switch to the month of `end` date.
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
disableAutoMonthSwitching: PropTypes.bool,
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* If `true` the popup or dialog will immediately close after submitting full date.
|
|
190
|
+
* @default `true` for Desktop, `false` for Mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
|
|
191
|
+
*/
|
|
192
|
+
disableCloseOnSelect: PropTypes.bool,
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* If `true`, the picker and text field are disabled.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
disabled: PropTypes.bool,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @default false
|
|
202
|
+
*/
|
|
203
|
+
disableFuture: PropTypes.bool,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* If `true`, todays date is rendering without highlighting with circle.
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
disableHighlightToday: PropTypes.bool,
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Disable mask on the keyboard, this should be used rarely. Consider passing proper mask for your format.
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
disableMaskedInput: PropTypes.bool,
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Do not render open picker button (renders only text field with validation).
|
|
219
|
+
* @default false
|
|
220
|
+
*/
|
|
221
|
+
disableOpenPicker: PropTypes.bool,
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @default false
|
|
225
|
+
*/
|
|
226
|
+
disablePast: PropTypes.bool,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Text for end input label and toolbar placeholder.
|
|
230
|
+
* @default 'End'
|
|
231
|
+
*/
|
|
232
|
+
endText: PropTypes.node,
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get aria-label text for control that opens picker dialog. Aria-label text must include selected date. @DateIOType
|
|
236
|
+
* @default (value, utils) => `Choose date, selected date is ${utils.format(utils.date(value), 'fullDate')}`
|
|
237
|
+
* @param {ParseableDate<TDateValue>} value The date from which we want to add an aria-text.
|
|
238
|
+
* @param {MuiPickersAdapter<TDateValue>} utils The utils to manipulate the date.
|
|
239
|
+
* @returns {string} The aria-text to render inside the dialog.
|
|
240
|
+
*/
|
|
241
|
+
getOpenDialogAriaText: PropTypes.func,
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Get aria-label text for switching between views button.
|
|
245
|
+
* @param {CalendarPickerView} currentView The view from which we want to get the button text.
|
|
246
|
+
* @returns {string} The label of the view.
|
|
247
|
+
*/
|
|
248
|
+
getViewSwitchingButtonText: PropTypes.func,
|
|
249
|
+
ignoreInvalidInputs: PropTypes.bool,
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Props to pass to keyboard input adornment.
|
|
253
|
+
*/
|
|
254
|
+
InputAdornmentProps: PropTypes.object,
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Format string.
|
|
258
|
+
*/
|
|
259
|
+
inputFormat: PropTypes.string,
|
|
260
|
+
InputProps: PropTypes.object,
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Pass a ref to the `input` element.
|
|
264
|
+
*/
|
|
265
|
+
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
266
|
+
current: PropTypes.object
|
|
267
|
+
})]),
|
|
268
|
+
label: PropTypes.node,
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Left arrow icon aria-label text.
|
|
272
|
+
*/
|
|
273
|
+
leftArrowButtonText: PropTypes.string,
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* If `true` renders `LoadingComponent` in calendar instead of calendar view.
|
|
277
|
+
* Can be used to preload information and show it in calendar.
|
|
278
|
+
* @default false
|
|
279
|
+
*/
|
|
280
|
+
loading: PropTypes.bool,
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Custom mask. Can be used to override generate from format. (e.g. `__/__/____ __:__` or `__/__/____ __:__ _M`).
|
|
284
|
+
* @default '__/__/____'
|
|
285
|
+
*/
|
|
286
|
+
mask: PropTypes.string,
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Max selectable date. @DateIOType
|
|
290
|
+
* @default defaultMaxDate
|
|
291
|
+
*/
|
|
292
|
+
maxDate: PropTypes.any,
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Min selectable date. @DateIOType
|
|
296
|
+
* @default defaultMinDate
|
|
297
|
+
*/
|
|
298
|
+
minDate: PropTypes.any,
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Ok button text.
|
|
302
|
+
* @default 'OK'
|
|
303
|
+
*/
|
|
304
|
+
okText: PropTypes.node,
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Callback fired when date is accepted @DateIOType.
|
|
308
|
+
* @param {TDateValue} date The date that was just accepted.
|
|
309
|
+
*/
|
|
310
|
+
onAccept: PropTypes.func,
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Callback fired when the value (the selected date range) changes @DateIOType.
|
|
314
|
+
* @param {DateRange<TDate>} date The new parsed date range.
|
|
315
|
+
* @param {string} keyboardInputValue The current value of the keyboard input.
|
|
316
|
+
*/
|
|
317
|
+
onChange: PropTypes.func.isRequired,
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Callback fired when the popup requests to be closed.
|
|
321
|
+
* Use in controlled mode (see open).
|
|
322
|
+
*/
|
|
323
|
+
onClose: PropTypes.func,
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Callback that fired when input value or new `value` prop validation returns **new** validation error (or value is valid after error).
|
|
327
|
+
* In case of validation error detected `reason` prop return non-null value and `TextField` must be displayed in `error` state.
|
|
328
|
+
* This can be used to render appropriate form error.
|
|
329
|
+
*
|
|
330
|
+
* [Read the guide](https://next.material-ui-pickers.dev/guides/forms) about form integration and error displaying.
|
|
331
|
+
* @DateIOType
|
|
332
|
+
*
|
|
333
|
+
* @param {TError} reason The reason why the current value is not valid.
|
|
334
|
+
* @param {TDateValue} value The invalid value.
|
|
335
|
+
*/
|
|
336
|
+
onError: PropTypes.func,
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Callback firing on month change. @DateIOType
|
|
340
|
+
* @param {TDate} month The new month.
|
|
341
|
+
*/
|
|
342
|
+
onMonthChange: PropTypes.func,
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Callback fired when the popup requests to be opened.
|
|
346
|
+
* Use in controlled mode (see open).
|
|
347
|
+
*/
|
|
348
|
+
onOpen: PropTypes.func,
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Callback fired on view change.
|
|
352
|
+
* @param {CalendarPickerView} view The new view.
|
|
353
|
+
*/
|
|
354
|
+
onViewChange: PropTypes.func,
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Control the popup or dialog open state.
|
|
358
|
+
*/
|
|
359
|
+
open: PropTypes.bool,
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Props to pass to keyboard adornment button.
|
|
363
|
+
*/
|
|
364
|
+
OpenPickerButtonProps: PropTypes.object,
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Force rendering in particular orientation.
|
|
368
|
+
*/
|
|
369
|
+
orientation: PropTypes.oneOf(['landscape', 'portrait']),
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Paper props passed down to [Paper](https://mui.com/api/paper/) component.
|
|
373
|
+
*/
|
|
374
|
+
PaperProps: PropTypes.object,
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Popper props passed down to [Popper](https://mui.com/api/popper/) component.
|
|
378
|
+
*/
|
|
379
|
+
PopperProps: PropTypes.object,
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Make picker read only.
|
|
383
|
+
* @default false
|
|
384
|
+
*/
|
|
385
|
+
readOnly: PropTypes.bool,
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Disable heavy animations.
|
|
389
|
+
* @default typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)
|
|
390
|
+
*/
|
|
391
|
+
reduceAnimations: PropTypes.bool,
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Custom renderer for `<DateRangePicker />` days. @DateIOType
|
|
395
|
+
* @example (date, dateRangePickerDayProps) => <DateRangePickerDay {...dateRangePickerDayProps} />
|
|
396
|
+
* @param {TDate} day The day to render.
|
|
397
|
+
* @param {DateRangePickerDayProps<TDate>} dateRangePickerDayProps The props of the day to render.
|
|
398
|
+
* @returns {JSX.Element} The element representing the day.
|
|
399
|
+
*/
|
|
400
|
+
renderDay: PropTypes.func,
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The `renderInput` prop allows you to customize the rendered input.
|
|
404
|
+
* The `startProps` and `endProps` arguments of this render prop contains props of [TextField](https://mui.com/api/text-field/#textfield-api),
|
|
405
|
+
* that you need to forward to the range start/end inputs respectively.
|
|
406
|
+
* Pay specific attention to the `ref` and `inputProps` keys.
|
|
407
|
+
* @example
|
|
408
|
+
* ```jsx
|
|
409
|
+
* <DateRangePicker
|
|
410
|
+
* renderInput={(startProps, endProps) => (
|
|
411
|
+
* <React.Fragment>
|
|
412
|
+
* <TextField {...startProps} />
|
|
413
|
+
* <Box sx={{ mx: 2 }}> to </Box>
|
|
414
|
+
* <TextField {...endProps} />
|
|
415
|
+
* </React.Fragment>;
|
|
416
|
+
* )}
|
|
417
|
+
* />
|
|
418
|
+
* ````
|
|
419
|
+
* @param {MuiTextFieldProps} startProps Props that you need to forward to the range start input.
|
|
420
|
+
* @param {MuiTextFieldProps} endProps Props that you need to forward to the range end input.
|
|
421
|
+
* @returns {React.ReactElement} The range input to render.
|
|
422
|
+
*/
|
|
423
|
+
renderInput: PropTypes.func.isRequired,
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Component displaying when passed `loading` true.
|
|
427
|
+
* @returns {React.ReactNode} The node to render when loading.
|
|
428
|
+
* @default () => <span data-mui-test="loading-progress">...</span>
|
|
429
|
+
*/
|
|
430
|
+
renderLoading: PropTypes.func,
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Custom formatter to be passed into Rifm component.
|
|
434
|
+
* @param {string} str The un-formatted string.
|
|
435
|
+
* @returns {string} The formatted string.
|
|
436
|
+
*/
|
|
437
|
+
rifmFormatter: PropTypes.func,
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Right arrow icon aria-label text.
|
|
441
|
+
*/
|
|
442
|
+
rightArrowButtonText: PropTypes.string,
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Disable specific date. @DateIOType
|
|
446
|
+
* @param {TDate} day The date to check.
|
|
447
|
+
* @returns {boolean} If `true` the day will be disabled.
|
|
448
|
+
*/
|
|
449
|
+
shouldDisableDate: PropTypes.func,
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Disable specific years dynamically.
|
|
453
|
+
* Works like `shouldDisableDate` but for year selection view @DateIOType.
|
|
454
|
+
* @param {TDate} year The year to test.
|
|
455
|
+
* @returns {boolean} Return `true` if the year should be disabled.
|
|
456
|
+
*/
|
|
457
|
+
shouldDisableYear: PropTypes.func,
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* If `true`, days that have `outsideCurrentMonth={true}` are displayed.
|
|
461
|
+
* @default false
|
|
462
|
+
*/
|
|
463
|
+
showDaysOutsideCurrentMonth: PropTypes.bool,
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* If `true`, the today button is displayed. **Note** that `showClearButton` has a higher priority.
|
|
467
|
+
* @default false
|
|
468
|
+
*/
|
|
469
|
+
showTodayButton: PropTypes.bool,
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* If `true`, show the toolbar even in desktop mode.
|
|
473
|
+
*/
|
|
474
|
+
showToolbar: PropTypes.bool,
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Text for start input label and toolbar placeholder.
|
|
478
|
+
* @default 'Start'
|
|
479
|
+
*/
|
|
480
|
+
startText: PropTypes.node,
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Today text message.
|
|
484
|
+
* @default 'Today'
|
|
485
|
+
*/
|
|
486
|
+
todayText: PropTypes.node,
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Component that will replace default toolbar renderer.
|
|
490
|
+
*/
|
|
491
|
+
ToolbarComponent: PropTypes.elementType,
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Date format, that is displaying in toolbar.
|
|
495
|
+
*/
|
|
496
|
+
toolbarFormat: PropTypes.string,
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Mobile picker date value placeholder, displaying if `value` === `null`.
|
|
500
|
+
* @default '–'
|
|
501
|
+
*/
|
|
502
|
+
toolbarPlaceholder: PropTypes.node,
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Mobile picker title, displaying in the toolbar.
|
|
506
|
+
* @default 'Select date range'
|
|
507
|
+
*/
|
|
508
|
+
toolbarTitle: PropTypes.node,
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Custom component for popper [Transition](https://mui.com/components/transitions/#transitioncomponent-prop).
|
|
512
|
+
*/
|
|
513
|
+
TransitionComponent: PropTypes.elementType,
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The value of the date range picker.
|
|
517
|
+
*/
|
|
518
|
+
value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.any, PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string])).isRequired
|
|
519
|
+
} : void 0;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DateInputProps, ExportedDateInputProps, MuiTextFieldProps } from '@mui/x-date-pickers/internals';
|
|
3
|
+
import { RangeInput, DateRange, CurrentlySelectingRangeEndProps } from '../internal/models/dateRange';
|
|
4
|
+
import { DateRangeValidationError } from '../internal/hooks/validation/useDateRangeValidation';
|
|
5
|
+
export interface ExportedDateRangePickerInputProps extends Omit<ExportedDateInputProps<RangeInput<any>, DateRange<any>>, 'renderInput'> {
|
|
6
|
+
/**
|
|
7
|
+
* The `renderInput` prop allows you to customize the rendered input.
|
|
8
|
+
* The `startProps` and `endProps` arguments of this render prop contains props of [TextField](https://mui.com/api/text-field/#textfield-api),
|
|
9
|
+
* that you need to forward to the range start/end inputs respectively.
|
|
10
|
+
* Pay specific attention to the `ref` and `inputProps` keys.
|
|
11
|
+
* @example
|
|
12
|
+
* ```jsx
|
|
13
|
+
* <DateRangePicker
|
|
14
|
+
* renderInput={(startProps, endProps) => (
|
|
15
|
+
* <React.Fragment>
|
|
16
|
+
* <TextField {...startProps} />
|
|
17
|
+
* <Box sx={{ mx: 2 }}> to </Box>
|
|
18
|
+
* <TextField {...endProps} />
|
|
19
|
+
* </React.Fragment>;
|
|
20
|
+
* )}
|
|
21
|
+
* />
|
|
22
|
+
* ````
|
|
23
|
+
* @param {MuiTextFieldProps} startProps Props that you need to forward to the range start input.
|
|
24
|
+
* @param {MuiTextFieldProps} endProps Props that you need to forward to the range end input.
|
|
25
|
+
* @returns {React.ReactElement} The range input to render.
|
|
26
|
+
*/
|
|
27
|
+
renderInput: (startProps: MuiTextFieldProps, endProps: MuiTextFieldProps) => React.ReactElement;
|
|
28
|
+
}
|
|
29
|
+
export interface DateRangeInputProps extends ExportedDateRangePickerInputProps, CurrentlySelectingRangeEndProps, Omit<DateInputProps<RangeInput<any>, DateRange<any>>, 'validationError' | 'renderInput'> {
|
|
30
|
+
startText: React.ReactNode;
|
|
31
|
+
endText: React.ReactNode;
|
|
32
|
+
validationError: DateRangeValidationError;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @ignore - internal component.
|
|
36
|
+
*/
|
|
37
|
+
export declare const DateRangePickerInput: React.ForwardRefExoticComponent<DateRangeInputProps & React.RefAttributes<HTMLDivElement>>;
|