@mui/x-date-pickers-pro 7.22.2 → 8.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 +142 -155
- package/DateRangeCalendar/DateRangeCalendar.d.ts +1 -2
- package/DateRangeCalendar/DateRangeCalendar.js +23 -22
- package/DateRangeCalendar/DateRangeCalendar.types.d.ts +24 -36
- package/DateRangeCalendar/useDragRange.d.ts +10 -9
- package/DateRangeCalendar/useDragRange.js +3 -3
- package/DateRangePicker/DateRangePicker.d.ts +1 -2
- package/DateRangePicker/DateRangePicker.js +12 -8
- package/DateRangePicker/DateRangePicker.types.d.ts +12 -6
- package/DateRangePicker/DateRangePickerToolbar.d.ts +3 -5
- package/DateRangePicker/DateRangePickerToolbar.js +12 -2
- package/DateRangePicker/index.d.ts +1 -1
- package/DateRangePicker/shared.d.ts +12 -12
- package/DateRangePickerDay/DateRangePickerDay.d.ts +2 -3
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -2
- package/DateTimeRangePicker/DateTimeRangePicker.js +13 -10
- package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +12 -6
- package/DateTimeRangePicker/DateTimeRangePickerTabs.d.ts +1 -2
- package/DateTimeRangePicker/DateTimeRangePickerTabs.js +2 -2
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.d.ts +8 -9
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.d.ts +3 -5
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +12 -2
- package/DateTimeRangePicker/index.d.ts +1 -1
- package/DateTimeRangePicker/shared.d.ts +13 -13
- package/DesktopDateRangePicker/DesktopDateRangePicker.d.ts +1 -2
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +16 -8
- package/DesktopDateRangePicker/DesktopDateRangePicker.types.d.ts +6 -7
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.d.ts +1 -2
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +13 -10
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.types.d.ts +6 -7
- package/MobileDateRangePicker/MobileDateRangePicker.d.ts +1 -2
- package/MobileDateRangePicker/MobileDateRangePicker.js +16 -8
- package/MobileDateRangePicker/MobileDateRangePicker.types.d.ts +6 -7
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.d.ts +1 -2
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +13 -10
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.types.d.ts +6 -7
- package/MultiInputDateRangeField/MultiInputDateRangeField.d.ts +1 -2
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +6 -6
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +9 -10
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.d.ts +1 -2
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +7 -8
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +9 -10
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.d.ts +1 -2
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +6 -6
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +9 -10
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.d.ts +1 -2
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +2 -2
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.types.d.ts +3 -3
- package/README.md +2 -2
- package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +1 -2
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -6
- package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +8 -8
- package/SingleInputDateRangeField/useSingleInputDateRangeField.d.ts +1 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +1 -2
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -8
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +8 -8
- package/SingleInputDateTimeRangeField/useSingleInputDateTimeRangeField.d.ts +1 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +1 -2
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -6
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +8 -8
- package/SingleInputTimeRangeField/useSingleInputTimeRangeField.d.ts +1 -2
- package/StaticDateRangePicker/StaticDateRangePicker.d.ts +1 -2
- package/StaticDateRangePicker/StaticDateRangePicker.js +11 -7
- package/StaticDateRangePicker/StaticDateRangePicker.types.d.ts +6 -7
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +2 -3
- package/index.d.ts +0 -7
- package/index.js +1 -7
- package/internals/hooks/models/useRangePicker.d.ts +6 -7
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -2
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +20 -14
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +6 -7
- package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +15 -13
- package/internals/hooks/useEnrichedRangePickerFieldProps.js +4 -4
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -2
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +21 -15
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +6 -7
- package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +1 -1
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -2
- package/internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +1 -2
- package/internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +1 -2
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -2
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +5 -5
- package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +8 -9
- package/internals/models/dateRange.d.ts +3 -4
- package/internals/models/dateTimeRange.d.ts +5 -10
- package/internals/models/fields.d.ts +26 -0
- package/internals/models/fields.js +1 -0
- package/internals/models/timeRange.d.ts +5 -9
- package/internals/utils/date-range-manager.d.ts +10 -9
- package/internals/utils/date-utils.d.ts +5 -5
- package/internals/utils/releaseInfo.js +1 -1
- package/internals/utils/valueManagers.d.ts +5 -6
- package/models/dateRange.d.ts +4 -5
- package/models/fields.d.ts +5 -32
- package/models/range.d.ts +1 -1
- package/modern/DateRangeCalendar/DateRangeCalendar.js +23 -22
- package/modern/DateRangeCalendar/useDragRange.js +3 -3
- package/modern/DateRangePicker/DateRangePicker.js +12 -8
- package/modern/DateRangePicker/DateRangePickerToolbar.js +12 -2
- package/modern/DateTimeRangePicker/DateTimeRangePicker.js +13 -10
- package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +2 -2
- package/modern/DateTimeRangePicker/DateTimeRangePickerToolbar.js +12 -2
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +16 -8
- package/modern/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +13 -10
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +16 -8
- package/modern/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +13 -10
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +6 -6
- package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +7 -8
- package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +6 -6
- package/modern/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +2 -2
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -6
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -8
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -6
- package/modern/StaticDateRangePicker/StaticDateRangePicker.js +11 -7
- package/modern/index.js +1 -7
- package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +20 -14
- package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +4 -4
- package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +21 -15
- package/modern/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +5 -5
- package/modern/internals/models/fields.js +1 -0
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/validation/validateDateRange.js +5 -0
- package/modern/validation/validateDateTimeRange.js +5 -0
- package/modern/validation/validateTimeRange.js +5 -0
- package/node/DateRangeCalendar/DateRangeCalendar.js +22 -21
- package/node/DateRangeCalendar/useDragRange.js +3 -3
- package/node/DateRangePicker/DateRangePicker.js +12 -8
- package/node/DateRangePicker/DateRangePickerToolbar.js +11 -1
- package/node/DateTimeRangePicker/DateTimeRangePicker.js +13 -10
- package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +1 -1
- package/node/DateTimeRangePicker/DateTimeRangePickerToolbar.js +11 -1
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +16 -8
- package/node/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +13 -10
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +16 -8
- package/node/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +13 -10
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +6 -6
- package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +7 -8
- package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +6 -6
- package/node/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +1 -1
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +6 -6
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +7 -8
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +6 -6
- package/node/StaticDateRangePicker/StaticDateRangePicker.js +11 -7
- package/node/index.js +2 -41
- package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +19 -13
- package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +3 -3
- package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +19 -13
- package/node/internals/hooks/useStaticRangePicker/useStaticRangePicker.js +4 -4
- package/node/internals/models/fields.js +5 -0
- package/node/internals/utils/releaseInfo.js +1 -1
- package/node/validation/validateDateRange.js +4 -0
- package/node/validation/validateDateTimeRange.js +4 -0
- package/node/validation/validateTimeRange.js +4 -0
- package/package.json +5 -5
- package/themeAugmentation/props.d.ts +16 -17
- package/validation/validateDateRange.d.ts +9 -5
- package/validation/validateDateRange.js +5 -0
- package/validation/validateDateTimeRange.d.ts +11 -6
- package/validation/validateDateTimeRange.js +5 -0
- package/validation/validateTimeRange.d.ts +9 -4
- package/validation/validateTimeRange.js +5 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
5
|
+
const _excluded = ["value", "defaultValue", "referenceDate", "onChange", "className", "classes", "disableFuture", "disablePast", "minDate", "maxDate", "shouldDisableDate", "reduceAnimations", "onMonthChange", "rangePosition", "defaultRangePosition", "onRangePositionChange", "calendars", "currentMonthCalendarPosition", "slots", "slotProps", "loading", "renderLoading", "disableHighlightToday", "readOnly", "disabled", "showDaysOutsideCurrentMonth", "dayOfWeekFormatter", "disableAutoMonthSwitching", "autoFocus", "fixedWeekNumber", "disableDragEditing", "displayWeekNumber", "timezone", "availableRangePositions", "views", "view", "openTo", "onViewChange"],
|
|
6
6
|
_excluded2 = ["isDragging", "rangeDragDay", "draggingDatePosition"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -15,7 +15,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
15
15
|
import composeClasses from '@mui/utils/composeClasses';
|
|
16
16
|
import useId from '@mui/utils/useId';
|
|
17
17
|
import { Watermark } from '@mui/x-license';
|
|
18
|
-
import { applyDefaultDate, DayCalendar, useDefaultReduceAnimations, useCalendarState, useDefaultDates, useUtils, useNow, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, useControlledValueWithTimezone, useViews } from '@mui/x-date-pickers/internals';
|
|
18
|
+
import { applyDefaultDate, DayCalendar, useDefaultReduceAnimations, useCalendarState, useDefaultDates, useUtils, useNow, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, useControlledValueWithTimezone, useViews, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
|
|
19
19
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
20
20
|
import { getReleaseInfo } from "../internals/utils/releaseInfo.js";
|
|
21
21
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from "./dateRangeCalendarClasses.js";
|
|
@@ -97,15 +97,11 @@ function useDateRangeCalendarDefaultizedProps(props, name) {
|
|
|
97
97
|
availableRangePositions: themeProps.availableRangePositions ?? ['start', 'end']
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
const useUtilityClasses = ownerState => {
|
|
101
|
-
const {
|
|
102
|
-
classes,
|
|
103
|
-
isDragging
|
|
104
|
-
} = ownerState;
|
|
100
|
+
const useUtilityClasses = (classes, ownerState) => {
|
|
105
101
|
const slots = {
|
|
106
102
|
root: ['root'],
|
|
107
103
|
monthContainer: ['monthContainer'],
|
|
108
|
-
dayCalendar: [
|
|
104
|
+
dayCalendar: [ownerState.isDraggingDay && 'dayDragging']
|
|
109
105
|
};
|
|
110
106
|
return composeClasses(slots, getDateRangeCalendarUtilityClass, classes);
|
|
111
107
|
};
|
|
@@ -130,6 +126,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
130
126
|
referenceDate,
|
|
131
127
|
onChange,
|
|
132
128
|
className,
|
|
129
|
+
classes: classesProp,
|
|
133
130
|
disableFuture,
|
|
134
131
|
disablePast,
|
|
135
132
|
minDate,
|
|
@@ -244,10 +241,13 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
244
241
|
draggingDatePosition
|
|
245
242
|
} = _useDragRange,
|
|
246
243
|
dragEventHandlers = _objectWithoutPropertiesLoose(_useDragRange, _excluded2);
|
|
247
|
-
const
|
|
248
|
-
|
|
244
|
+
const {
|
|
245
|
+
ownerState: pickersOwnerState
|
|
246
|
+
} = usePickerPrivateContext();
|
|
247
|
+
const ownerState = _extends({}, pickersOwnerState, {
|
|
248
|
+
isDraggingDay: isDragging
|
|
249
249
|
});
|
|
250
|
-
const classes = useUtilityClasses(ownerState);
|
|
250
|
+
const classes = useUtilityClasses(classesProp, ownerState);
|
|
251
251
|
const draggingRange = React.useMemo(() => {
|
|
252
252
|
if (!valueDayRange[0] || !valueDayRange[1] || !rangeDragDay) {
|
|
253
253
|
return [null, null];
|
|
@@ -309,7 +309,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
309
309
|
slots,
|
|
310
310
|
slotProps
|
|
311
311
|
},
|
|
312
|
-
ownerState
|
|
312
|
+
ownerState
|
|
313
313
|
});
|
|
314
314
|
const prevValue = React.useRef(null);
|
|
315
315
|
React.useEffect(() => {
|
|
@@ -370,7 +370,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
370
370
|
const slotPropsForDayCalendar = _extends({}, slotProps, {
|
|
371
371
|
day: dayOwnerState => {
|
|
372
372
|
const {
|
|
373
|
-
day
|
|
373
|
+
day,
|
|
374
|
+
isDaySelected
|
|
374
375
|
} = dayOwnerState;
|
|
375
376
|
const isSelectedStartDate = isStartOfRange(utils, day, valueDayRange);
|
|
376
377
|
const isSelectedEndDate = isEndOfRange(utils, day, valueDayRange);
|
|
@@ -393,7 +394,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
393
394
|
isEndOfHighlighting: isDragging ? isEndOfRange(utils, day, draggingRange) : isSelectedEndDate,
|
|
394
395
|
onMouseEnter: shouldHavePreview ? handleDayMouseEnter : undefined,
|
|
395
396
|
// apply selected styling to the dragging start or end day
|
|
396
|
-
isVisuallySelected:
|
|
397
|
+
isVisuallySelected: isDaySelected || isDragging && (isStartOfHighlighting || isEndOfHighlighting),
|
|
397
398
|
'data-position': datePosition
|
|
398
399
|
}, dragEventHandlers, {
|
|
399
400
|
draggable: isElementDraggable ? true : undefined
|
|
@@ -514,9 +515,9 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
514
515
|
currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
|
|
515
516
|
/**
|
|
516
517
|
* Formats the day of week displayed in the calendar header.
|
|
517
|
-
* @param {
|
|
518
|
+
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
518
519
|
* @returns {string} The name to display.
|
|
519
|
-
* @default (date:
|
|
520
|
+
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
520
521
|
*/
|
|
521
522
|
dayOfWeekFormatter: PropTypes.func,
|
|
522
523
|
/**
|
|
@@ -536,7 +537,8 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
536
537
|
*/
|
|
537
538
|
disableAutoMonthSwitching: PropTypes.bool,
|
|
538
539
|
/**
|
|
539
|
-
* If `true`, the
|
|
540
|
+
* If `true`, the component is disabled.
|
|
541
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
540
542
|
* @default false
|
|
541
543
|
*/
|
|
542
544
|
disabled: PropTypes.bool,
|
|
@@ -607,8 +609,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
607
609
|
onFocusedViewChange: PropTypes.func,
|
|
608
610
|
/**
|
|
609
611
|
* Callback fired on month change.
|
|
610
|
-
* @
|
|
611
|
-
* @param {TDate} month The new month.
|
|
612
|
+
* @param {PickerValidDate} month The new month.
|
|
612
613
|
*/
|
|
613
614
|
onMonthChange: PropTypes.func,
|
|
614
615
|
/**
|
|
@@ -634,7 +635,8 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
634
635
|
*/
|
|
635
636
|
rangePosition: PropTypes.oneOf(['end', 'start']),
|
|
636
637
|
/**
|
|
637
|
-
*
|
|
638
|
+
* If `true`, the component is read-only.
|
|
639
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
638
640
|
* @default false
|
|
639
641
|
*/
|
|
640
642
|
readOnly: PropTypes.bool,
|
|
@@ -659,8 +661,7 @@ process.env.NODE_ENV !== "production" ? DateRangeCalendar.propTypes = {
|
|
|
659
661
|
*
|
|
660
662
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
661
663
|
*
|
|
662
|
-
* @
|
|
663
|
-
* @param {TDate} day The date to test.
|
|
664
|
+
* @param {PickerValidDate} day The date to test.
|
|
664
665
|
* @param {string} position The date to test, 'start' or 'end'.
|
|
665
666
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
666
667
|
*/
|
|
@@ -214,9 +214,9 @@ export const useDragRange = ({
|
|
|
214
214
|
}) => {
|
|
215
215
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
216
216
|
const [rangeDragDay, setRangeDragDay] = React.useState(null);
|
|
217
|
-
const handleRangeDragDayChange = useEventCallback(
|
|
218
|
-
if (!utils.isEqual(
|
|
219
|
-
setRangeDragDay(
|
|
217
|
+
const handleRangeDragDayChange = useEventCallback(newValue => {
|
|
218
|
+
if (!utils.isEqual(newValue, rangeDragDay)) {
|
|
219
|
+
setRangeDragDay(newValue);
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
const draggingDatePosition = React.useMemo(() => {
|
|
@@ -74,9 +74,9 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
74
74
|
currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
|
|
75
75
|
/**
|
|
76
76
|
* Formats the day of week displayed in the calendar header.
|
|
77
|
-
* @param {
|
|
77
|
+
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
78
78
|
* @returns {string} The name to display.
|
|
79
|
-
* @default (date:
|
|
79
|
+
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
80
80
|
*/
|
|
81
81
|
dayOfWeekFormatter: PropTypes.func,
|
|
82
82
|
/**
|
|
@@ -102,7 +102,8 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
102
102
|
*/
|
|
103
103
|
disableAutoMonthSwitching: PropTypes.bool,
|
|
104
104
|
/**
|
|
105
|
-
* If `true`, the
|
|
105
|
+
* If `true`, the component is disabled.
|
|
106
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
106
107
|
* @default false
|
|
107
108
|
*/
|
|
108
109
|
disabled: PropTypes.bool,
|
|
@@ -136,7 +137,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
136
137
|
*/
|
|
137
138
|
displayWeekNumber: PropTypes.bool,
|
|
138
139
|
/**
|
|
139
|
-
* @default
|
|
140
|
+
* @default true
|
|
140
141
|
*/
|
|
141
142
|
enableAccessibleFieldDOMStructure: PropTypes.any,
|
|
142
143
|
/**
|
|
@@ -224,8 +225,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
224
225
|
onError: PropTypes.func,
|
|
225
226
|
/**
|
|
226
227
|
* Callback fired on month change.
|
|
227
|
-
* @
|
|
228
|
-
* @param {TDate} month The new month.
|
|
228
|
+
* @param {PickerValidDate} month The new month.
|
|
229
229
|
*/
|
|
230
230
|
onMonthChange: PropTypes.func,
|
|
231
231
|
/**
|
|
@@ -253,6 +253,11 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
253
253
|
* Used when the component position is controlled.
|
|
254
254
|
*/
|
|
255
255
|
rangePosition: PropTypes.oneOf(['end', 'start']),
|
|
256
|
+
/**
|
|
257
|
+
* If `true`, the component is read-only.
|
|
258
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
259
|
+
* @default false
|
|
260
|
+
*/
|
|
256
261
|
readOnly: PropTypes.bool,
|
|
257
262
|
/**
|
|
258
263
|
* If `true`, disable heavy animations.
|
|
@@ -285,8 +290,7 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
285
290
|
*
|
|
286
291
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
287
292
|
*
|
|
288
|
-
* @
|
|
289
|
-
* @param {TDate} day The date to test.
|
|
293
|
+
* @param {PickerValidDate} day The date to test.
|
|
290
294
|
* @param {string} position The date to test, 'start' or 'end'.
|
|
291
295
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
292
296
|
*/
|
|
@@ -10,7 +10,7 @@ import Typography from '@mui/material/Typography';
|
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
12
|
import { PickersToolbar, PickersToolbarButton, useUtils } from '@mui/x-date-pickers/internals';
|
|
13
|
-
import {
|
|
13
|
+
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
14
14
|
import { getDateRangePickerToolbarUtilityClass } from "./dateRangePickerToolbarClasses.js";
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
const useUtilityClasses = ownerState => {
|
|
@@ -59,7 +59,7 @@ const DateRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateRangeP
|
|
|
59
59
|
className
|
|
60
60
|
} = props,
|
|
61
61
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
62
|
-
const translations =
|
|
62
|
+
const translations = usePickerTranslations();
|
|
63
63
|
const startDateValue = start ? utils.formatByString(start, toolbarFormat || utils.formats.shortDate) : translations.start;
|
|
64
64
|
const endDateValue = end ? utils.formatByString(end, toolbarFormat || utils.formats.shortDate) : translations.end;
|
|
65
65
|
const ownerState = props;
|
|
@@ -99,6 +99,11 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
99
99
|
*/
|
|
100
100
|
classes: PropTypes.object,
|
|
101
101
|
className: PropTypes.string,
|
|
102
|
+
/**
|
|
103
|
+
* If `true`, the component is disabled.
|
|
104
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
102
107
|
disabled: PropTypes.bool,
|
|
103
108
|
/**
|
|
104
109
|
* If `true`, show the toolbar even in desktop mode.
|
|
@@ -113,6 +118,11 @@ process.env.NODE_ENV !== "production" ? DateRangePickerToolbar.propTypes = {
|
|
|
113
118
|
*/
|
|
114
119
|
onViewChange: PropTypes.func.isRequired,
|
|
115
120
|
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
121
|
+
/**
|
|
122
|
+
* If `true`, the component is read-only.
|
|
123
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
116
126
|
readOnly: PropTypes.bool,
|
|
117
127
|
/**
|
|
118
128
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
@@ -79,9 +79,9 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
79
79
|
currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
|
|
80
80
|
/**
|
|
81
81
|
* Formats the day of week displayed in the calendar header.
|
|
82
|
-
* @param {
|
|
82
|
+
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
83
83
|
* @returns {string} The name to display.
|
|
84
|
-
* @default (date:
|
|
84
|
+
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
85
85
|
*/
|
|
86
86
|
dayOfWeekFormatter: PropTypes.func,
|
|
87
87
|
/**
|
|
@@ -107,7 +107,8 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
107
107
|
*/
|
|
108
108
|
disableAutoMonthSwitching: PropTypes.bool,
|
|
109
109
|
/**
|
|
110
|
-
* If `true`, the
|
|
110
|
+
* If `true`, the component is disabled.
|
|
111
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
111
112
|
* @default false
|
|
112
113
|
*/
|
|
113
114
|
disabled: PropTypes.bool,
|
|
@@ -146,7 +147,7 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
146
147
|
*/
|
|
147
148
|
displayWeekNumber: PropTypes.bool,
|
|
148
149
|
/**
|
|
149
|
-
* @default
|
|
150
|
+
* @default true
|
|
150
151
|
*/
|
|
151
152
|
enableAccessibleFieldDOMStructure: PropTypes.any,
|
|
152
153
|
/**
|
|
@@ -257,8 +258,7 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
257
258
|
onError: PropTypes.func,
|
|
258
259
|
/**
|
|
259
260
|
* Callback fired on month change.
|
|
260
|
-
* @
|
|
261
|
-
* @param {TDate} month The new month.
|
|
261
|
+
* @param {PickerValidDate} month The new month.
|
|
262
262
|
*/
|
|
263
263
|
onMonthChange: PropTypes.func,
|
|
264
264
|
/**
|
|
@@ -298,6 +298,11 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
298
298
|
* Used when the component position is controlled.
|
|
299
299
|
*/
|
|
300
300
|
rangePosition: PropTypes.oneOf(['end', 'start']),
|
|
301
|
+
/**
|
|
302
|
+
* If `true`, the component is read-only.
|
|
303
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
304
|
+
* @default false
|
|
305
|
+
*/
|
|
301
306
|
readOnly: PropTypes.bool,
|
|
302
307
|
/**
|
|
303
308
|
* If `true`, disable heavy animations.
|
|
@@ -330,16 +335,14 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
330
335
|
*
|
|
331
336
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
332
337
|
*
|
|
333
|
-
* @
|
|
334
|
-
* @param {TDate} day The date to test.
|
|
338
|
+
* @param {PickerValidDate} day The date to test.
|
|
335
339
|
* @param {string} position The date to test, 'start' or 'end'.
|
|
336
340
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
337
341
|
*/
|
|
338
342
|
shouldDisableDate: PropTypes.func,
|
|
339
343
|
/**
|
|
340
344
|
* Disable specific time.
|
|
341
|
-
* @
|
|
342
|
-
* @param {TDate} value The value to check.
|
|
345
|
+
* @param {PickerValidDate} value The value to check.
|
|
343
346
|
* @param {TimeView} view The clock type of the timeValue.
|
|
344
347
|
* @returns {boolean} If `true` the time will be disabled.
|
|
345
348
|
*/
|
|
@@ -8,7 +8,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
8
8
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
9
9
|
import { TimeIcon, DateRangeIcon, ArrowLeftIcon, ArrowRightIcon } from '@mui/x-date-pickers/icons';
|
|
10
10
|
import { isDatePickerView } from '@mui/x-date-pickers/internals';
|
|
11
|
-
import {
|
|
11
|
+
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
12
12
|
import IconButton from '@mui/material/IconButton';
|
|
13
13
|
import Button from '@mui/material/Button';
|
|
14
14
|
import { getDateTimeRangePickerTabsUtilityClass } from "./dateTimeRangePickerTabsClasses.js";
|
|
@@ -81,7 +81,7 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
|
|
|
81
81
|
className,
|
|
82
82
|
sx
|
|
83
83
|
} = props;
|
|
84
|
-
const translations =
|
|
84
|
+
const translations = usePickerTranslations();
|
|
85
85
|
const classes = useUtilityClasses(props);
|
|
86
86
|
const value = React.useMemo(() => viewToTab(view, rangePosition), [view, rangePosition]);
|
|
87
87
|
const isPreviousHidden = value === 'start-date';
|
|
@@ -9,7 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
11
11
|
import { useUtils } from '@mui/x-date-pickers/internals';
|
|
12
|
-
import {
|
|
12
|
+
import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
13
13
|
import { DateTimePickerToolbar } from '@mui/x-date-pickers/DateTimePicker';
|
|
14
14
|
import { getDateTimeRangePickerToolbarUtilityClass } from "./dateTimeRangePickerToolbarClasses.js";
|
|
15
15
|
import { calculateRangeChange } from "../internals/utils/date-range-manager.js";
|
|
@@ -105,7 +105,7 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
105
105
|
toolbarFormat,
|
|
106
106
|
toolbarPlaceholder
|
|
107
107
|
};
|
|
108
|
-
const translations =
|
|
108
|
+
const translations = usePickerTranslations();
|
|
109
109
|
const ownerState = props;
|
|
110
110
|
const classes = useUtilityClasses(ownerState);
|
|
111
111
|
const handleStartRangeViewChange = React.useCallback(newView => {
|
|
@@ -183,6 +183,11 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerToolbar.propTypes = {
|
|
|
183
183
|
*/
|
|
184
184
|
classes: PropTypes.object,
|
|
185
185
|
className: PropTypes.string,
|
|
186
|
+
/**
|
|
187
|
+
* If `true`, the component is disabled.
|
|
188
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
189
|
+
* @default false
|
|
190
|
+
*/
|
|
186
191
|
disabled: PropTypes.bool,
|
|
187
192
|
/**
|
|
188
193
|
* If `true`, show the toolbar even in desktop mode.
|
|
@@ -199,6 +204,11 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePickerToolbar.propTypes = {
|
|
|
199
204
|
*/
|
|
200
205
|
onViewChange: PropTypes.func.isRequired,
|
|
201
206
|
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
|
|
207
|
+
/**
|
|
208
|
+
* If `true`, the component is read-only.
|
|
209
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
210
|
+
* @default false
|
|
211
|
+
*/
|
|
202
212
|
readOnly: PropTypes.bool,
|
|
203
213
|
/**
|
|
204
214
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useUtils } from '@mui/x-date-pickers/internals';
|
|
6
7
|
import { extractValidationProps } from '@mui/x-date-pickers/validation';
|
|
7
8
|
import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
8
9
|
import { refType } from '@mui/utils';
|
|
@@ -23,6 +24,8 @@ import { validateDateRange } from "../validation/index.js";
|
|
|
23
24
|
* - [DesktopDateRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-range-picker/)
|
|
24
25
|
*/
|
|
25
26
|
const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateRangePicker(inProps, ref) {
|
|
27
|
+
const utils = useUtils();
|
|
28
|
+
|
|
26
29
|
// Props with the default values common to all date time pickers
|
|
27
30
|
const defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiDesktopDateRangePicker');
|
|
28
31
|
const viewRenderers = _extends({
|
|
@@ -30,6 +33,7 @@ const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDat
|
|
|
30
33
|
}, defaultizedProps.viewRenderers);
|
|
31
34
|
const props = _extends({}, defaultizedProps, {
|
|
32
35
|
viewRenderers,
|
|
36
|
+
format: utils.formats.keyboardDate,
|
|
33
37
|
calendars: defaultizedProps.calendars ?? 2,
|
|
34
38
|
views: ['day'],
|
|
35
39
|
openTo: 'day',
|
|
@@ -85,9 +89,9 @@ DesktopDateRangePicker.propTypes = {
|
|
|
85
89
|
currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
|
|
86
90
|
/**
|
|
87
91
|
* Formats the day of week displayed in the calendar header.
|
|
88
|
-
* @param {
|
|
92
|
+
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
89
93
|
* @returns {string} The name to display.
|
|
90
|
-
* @default (date:
|
|
94
|
+
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
91
95
|
*/
|
|
92
96
|
dayOfWeekFormatter: PropTypes.func,
|
|
93
97
|
/**
|
|
@@ -107,7 +111,8 @@ DesktopDateRangePicker.propTypes = {
|
|
|
107
111
|
*/
|
|
108
112
|
disableAutoMonthSwitching: PropTypes.bool,
|
|
109
113
|
/**
|
|
110
|
-
* If `true`, the
|
|
114
|
+
* If `true`, the component is disabled.
|
|
115
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
111
116
|
* @default false
|
|
112
117
|
*/
|
|
113
118
|
disabled: PropTypes.bool,
|
|
@@ -141,7 +146,7 @@ DesktopDateRangePicker.propTypes = {
|
|
|
141
146
|
*/
|
|
142
147
|
displayWeekNumber: PropTypes.bool,
|
|
143
148
|
/**
|
|
144
|
-
* @default
|
|
149
|
+
* @default true
|
|
145
150
|
*/
|
|
146
151
|
enableAccessibleFieldDOMStructure: PropTypes.any,
|
|
147
152
|
/**
|
|
@@ -229,8 +234,7 @@ DesktopDateRangePicker.propTypes = {
|
|
|
229
234
|
onError: PropTypes.func,
|
|
230
235
|
/**
|
|
231
236
|
* Callback fired on month change.
|
|
232
|
-
* @
|
|
233
|
-
* @param {TDate} month The new month.
|
|
237
|
+
* @param {PickerValidDate} month The new month.
|
|
234
238
|
*/
|
|
235
239
|
onMonthChange: PropTypes.func,
|
|
236
240
|
/**
|
|
@@ -258,6 +262,11 @@ DesktopDateRangePicker.propTypes = {
|
|
|
258
262
|
* Used when the component position is controlled.
|
|
259
263
|
*/
|
|
260
264
|
rangePosition: PropTypes.oneOf(['end', 'start']),
|
|
265
|
+
/**
|
|
266
|
+
* If `true`, the component is read-only.
|
|
267
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
268
|
+
* @default false
|
|
269
|
+
*/
|
|
261
270
|
readOnly: PropTypes.bool,
|
|
262
271
|
/**
|
|
263
272
|
* If `true`, disable heavy animations.
|
|
@@ -290,8 +299,7 @@ DesktopDateRangePicker.propTypes = {
|
|
|
290
299
|
*
|
|
291
300
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
292
301
|
*
|
|
293
|
-
* @
|
|
294
|
-
* @param {TDate} day The date to test.
|
|
302
|
+
* @param {PickerValidDate} day The date to test.
|
|
295
303
|
* @param {string} position The date to test, 'start' or 'end'.
|
|
296
304
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
297
305
|
*/
|
|
@@ -166,9 +166,9 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
166
166
|
currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
|
|
167
167
|
/**
|
|
168
168
|
* Formats the day of week displayed in the calendar header.
|
|
169
|
-
* @param {
|
|
169
|
+
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
170
170
|
* @returns {string} The name to display.
|
|
171
|
-
* @default (date:
|
|
171
|
+
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
172
172
|
*/
|
|
173
173
|
dayOfWeekFormatter: PropTypes.func,
|
|
174
174
|
/**
|
|
@@ -188,7 +188,8 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
188
188
|
*/
|
|
189
189
|
disableAutoMonthSwitching: PropTypes.bool,
|
|
190
190
|
/**
|
|
191
|
-
* If `true`, the
|
|
191
|
+
* If `true`, the component is disabled.
|
|
192
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
192
193
|
* @default false
|
|
193
194
|
*/
|
|
194
195
|
disabled: PropTypes.bool,
|
|
@@ -227,7 +228,7 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
227
228
|
*/
|
|
228
229
|
displayWeekNumber: PropTypes.bool,
|
|
229
230
|
/**
|
|
230
|
-
* @default
|
|
231
|
+
* @default true
|
|
231
232
|
*/
|
|
232
233
|
enableAccessibleFieldDOMStructure: PropTypes.any,
|
|
233
234
|
/**
|
|
@@ -338,8 +339,7 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
338
339
|
onError: PropTypes.func,
|
|
339
340
|
/**
|
|
340
341
|
* Callback fired on month change.
|
|
341
|
-
* @
|
|
342
|
-
* @param {TDate} month The new month.
|
|
342
|
+
* @param {PickerValidDate} month The new month.
|
|
343
343
|
*/
|
|
344
344
|
onMonthChange: PropTypes.func,
|
|
345
345
|
/**
|
|
@@ -379,6 +379,11 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
379
379
|
* Used when the component position is controlled.
|
|
380
380
|
*/
|
|
381
381
|
rangePosition: PropTypes.oneOf(['end', 'start']),
|
|
382
|
+
/**
|
|
383
|
+
* If `true`, the component is read-only.
|
|
384
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
385
|
+
* @default false
|
|
386
|
+
*/
|
|
382
387
|
readOnly: PropTypes.bool,
|
|
383
388
|
/**
|
|
384
389
|
* If `true`, disable heavy animations.
|
|
@@ -411,16 +416,14 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
411
416
|
*
|
|
412
417
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
413
418
|
*
|
|
414
|
-
* @
|
|
415
|
-
* @param {TDate} day The date to test.
|
|
419
|
+
* @param {PickerValidDate} day The date to test.
|
|
416
420
|
* @param {string} position The date to test, 'start' or 'end'.
|
|
417
421
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
418
422
|
*/
|
|
419
423
|
shouldDisableDate: PropTypes.func,
|
|
420
424
|
/**
|
|
421
425
|
* Disable specific time.
|
|
422
|
-
* @
|
|
423
|
-
* @param {TDate} value The value to check.
|
|
426
|
+
* @param {PickerValidDate} value The value to check.
|
|
424
427
|
* @param {TimeView} view The clock type of the timeValue.
|
|
425
428
|
* @returns {boolean} If `true` the time will be disabled.
|
|
426
429
|
*/
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useUtils } from '@mui/x-date-pickers/internals';
|
|
6
7
|
import { extractValidationProps } from '@mui/x-date-pickers/validation';
|
|
7
8
|
import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
8
9
|
import { refType } from '@mui/utils';
|
|
@@ -23,6 +24,8 @@ import { validateDateRange } from "../validation/index.js";
|
|
|
23
24
|
* - [MobileDateRangePicker API](https://mui.com/x/api/date-pickers/mobile-date-range-picker/)
|
|
24
25
|
*/
|
|
25
26
|
const MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateRangePicker(inProps, ref) {
|
|
27
|
+
const utils = useUtils();
|
|
28
|
+
|
|
26
29
|
// Props with the default values common to all date time pickers
|
|
27
30
|
const defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiMobileDateRangePicker');
|
|
28
31
|
const viewRenderers = _extends({
|
|
@@ -30,6 +33,7 @@ const MobileDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileDateR
|
|
|
30
33
|
}, defaultizedProps.viewRenderers);
|
|
31
34
|
const props = _extends({}, defaultizedProps, {
|
|
32
35
|
viewRenderers,
|
|
36
|
+
format: utils.formats.keyboardDate,
|
|
33
37
|
// Force one calendar on mobile to avoid layout issues
|
|
34
38
|
calendars: 1,
|
|
35
39
|
views: ['day'],
|
|
@@ -81,9 +85,9 @@ MobileDateRangePicker.propTypes = {
|
|
|
81
85
|
currentMonthCalendarPosition: PropTypes.oneOf([1, 2, 3]),
|
|
82
86
|
/**
|
|
83
87
|
* Formats the day of week displayed in the calendar header.
|
|
84
|
-
* @param {
|
|
88
|
+
* @param {PickerValidDate} date The date of the day of week provided by the adapter.
|
|
85
89
|
* @returns {string} The name to display.
|
|
86
|
-
* @default (date:
|
|
90
|
+
* @default (date: PickerValidDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
|
|
87
91
|
*/
|
|
88
92
|
dayOfWeekFormatter: PropTypes.func,
|
|
89
93
|
/**
|
|
@@ -103,7 +107,8 @@ MobileDateRangePicker.propTypes = {
|
|
|
103
107
|
*/
|
|
104
108
|
disableAutoMonthSwitching: PropTypes.bool,
|
|
105
109
|
/**
|
|
106
|
-
* If `true`, the
|
|
110
|
+
* If `true`, the component is disabled.
|
|
111
|
+
* When disabled, the value cannot be changed and no interaction is possible.
|
|
107
112
|
* @default false
|
|
108
113
|
*/
|
|
109
114
|
disabled: PropTypes.bool,
|
|
@@ -137,7 +142,7 @@ MobileDateRangePicker.propTypes = {
|
|
|
137
142
|
*/
|
|
138
143
|
displayWeekNumber: PropTypes.bool,
|
|
139
144
|
/**
|
|
140
|
-
* @default
|
|
145
|
+
* @default true
|
|
141
146
|
*/
|
|
142
147
|
enableAccessibleFieldDOMStructure: PropTypes.any,
|
|
143
148
|
/**
|
|
@@ -225,8 +230,7 @@ MobileDateRangePicker.propTypes = {
|
|
|
225
230
|
onError: PropTypes.func,
|
|
226
231
|
/**
|
|
227
232
|
* Callback fired on month change.
|
|
228
|
-
* @
|
|
229
|
-
* @param {TDate} month The new month.
|
|
233
|
+
* @param {PickerValidDate} month The new month.
|
|
230
234
|
*/
|
|
231
235
|
onMonthChange: PropTypes.func,
|
|
232
236
|
/**
|
|
@@ -254,6 +258,11 @@ MobileDateRangePicker.propTypes = {
|
|
|
254
258
|
* Used when the component position is controlled.
|
|
255
259
|
*/
|
|
256
260
|
rangePosition: PropTypes.oneOf(['end', 'start']),
|
|
261
|
+
/**
|
|
262
|
+
* If `true`, the component is read-only.
|
|
263
|
+
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
257
266
|
readOnly: PropTypes.bool,
|
|
258
267
|
/**
|
|
259
268
|
* If `true`, disable heavy animations.
|
|
@@ -286,8 +295,7 @@ MobileDateRangePicker.propTypes = {
|
|
|
286
295
|
*
|
|
287
296
|
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
288
297
|
*
|
|
289
|
-
* @
|
|
290
|
-
* @param {TDate} day The date to test.
|
|
298
|
+
* @param {PickerValidDate} day The date to test.
|
|
291
299
|
* @param {string} position The date to test, 'start' or 'end'.
|
|
292
300
|
* @returns {boolean} Returns `true` if the date should be disabled.
|
|
293
301
|
*/
|