@mui/x-date-pickers-pro 8.5.3 → 8.6.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 +107 -0
- package/DateRangeCalendar/DateRangeCalendar.js +37 -36
- package/DateRangeCalendar/useDragRange.d.ts +2 -2
- package/DateRangeCalendar/useDragRange.js +17 -17
- package/DateRangePicker/DateRangePickerToolbar.js +4 -4
- package/DateRangePickerDay/DateRangePickerDay.js +5 -4
- package/DateRangePickerDay2/DateRangePickerDay2.js +5 -4
- package/DateTimeRangePicker/DateTimeRangePicker.js +1 -1
- package/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +6 -6
- package/DateTimeRangePicker/DateTimeRangePickerToolbar.js +3 -3
- package/DateTimeRangePicker/shared.js +3 -2
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +4 -4
- package/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +9 -8
- package/DesktopTimeRangePicker/DesktopTimeRangePicker.js +4 -3
- package/MobileDateRangePicker/MobileDateRangePicker.js +5 -5
- package/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +6 -5
- package/MobileTimeRangePicker/MobileTimeRangePicker.js +6 -5
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +1 -1
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +1 -1
- package/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +4 -4
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -1
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -1
- package/TimeRangePicker/TimeRangePicker.js +1 -1
- package/TimeRangePicker/TimeRangePickerTimeWrapper.js +6 -6
- package/TimeRangePicker/TimeRangePickerToolbar.js +7 -7
- package/TimeRangePicker/shared.js +3 -2
- package/esm/DateRangeCalendar/DateRangeCalendar.js +38 -37
- package/esm/DateRangeCalendar/useDragRange.d.ts +2 -2
- package/esm/DateRangeCalendar/useDragRange.js +17 -17
- package/esm/DateRangePicker/DateRangePickerToolbar.js +6 -6
- package/esm/DateRangePickerDay/DateRangePickerDay.js +6 -5
- package/esm/DateRangePickerDay2/DateRangePickerDay2.js +6 -5
- package/esm/DateTimeRangePicker/DateTimeRangePicker.js +1 -1
- package/esm/DateTimeRangePicker/DateTimeRangePickerTimeWrapper.js +4 -4
- package/esm/DateTimeRangePicker/DateTimeRangePickerToolbar.js +5 -5
- package/esm/DateTimeRangePicker/shared.js +4 -3
- package/esm/DesktopDateRangePicker/DesktopDateRangePicker.js +4 -4
- package/esm/DesktopDateTimeRangePicker/DesktopDateTimeRangePicker.js +7 -6
- package/esm/DesktopTimeRangePicker/DesktopTimeRangePicker.js +5 -4
- package/esm/MobileDateRangePicker/MobileDateRangePicker.js +5 -5
- package/esm/MobileDateTimeRangePicker/MobileDateTimeRangePicker.js +5 -4
- package/esm/MobileTimeRangePicker/MobileTimeRangePicker.js +6 -5
- package/esm/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +1 -1
- package/esm/MultiInputTimeRangeField/MultiInputTimeRangeField.js +1 -1
- package/esm/PickersRangeCalendarHeader/PickersRangeCalendarHeader.js +6 -6
- package/esm/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -1
- package/esm/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -1
- package/esm/TimeRangePicker/TimeRangePicker.js +1 -1
- package/esm/TimeRangePicker/TimeRangePickerTimeWrapper.js +4 -4
- package/esm/TimeRangePicker/TimeRangePickerToolbar.js +9 -9
- package/esm/TimeRangePicker/shared.js +4 -3
- package/esm/index.js +1 -1
- package/esm/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +1 -1
- package/esm/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +1 -1
- package/esm/internals/utils/date-range-manager.d.ts +2 -2
- package/esm/internals/utils/date-range-manager.js +8 -8
- package/esm/internals/utils/date-utils.d.ts +5 -5
- package/esm/internals/utils/date-utils.js +11 -11
- package/esm/internals/utils/valueManagers.js +9 -9
- package/esm/managers/useDateRangeManager.js +8 -8
- package/esm/managers/useDateTimeRangeManager.js +9 -9
- package/esm/managers/useTimeRangeManager.js +10 -10
- package/esm/validation/validateDateRange.js +1 -1
- package/esm/validation/validateDateTimeRange.js +1 -1
- package/esm/validation/validateTimeRange.js +1 -1
- package/index.js +1 -1
- package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +1 -1
- package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +1 -1
- package/internals/utils/date-range-manager.d.ts +2 -2
- package/internals/utils/date-range-manager.js +8 -8
- package/internals/utils/date-utils.d.ts +5 -5
- package/internals/utils/date-utils.js +11 -11
- package/internals/utils/valueManagers.js +9 -9
- package/managers/useDateRangeManager.js +6 -6
- package/managers/useDateTimeRangeManager.js +7 -7
- package/managers/useTimeRangeManager.js +8 -8
- package/package.json +4 -4
- package/validation/validateDateRange.js +1 -1
- package/validation/validateDateTimeRange.js +1 -1
- package/validation/validateTimeRange.js +1 -1
|
@@ -15,8 +15,9 @@ 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 { DayCalendar, useReduceAnimations, useCalendarState,
|
|
18
|
+
import { DayCalendar, useReduceAnimations, useCalendarState, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, useControlledValue, useViews, usePickerPrivateContext, areDatesEqual, useApplyDefaultValuesToDateValidationProps } from '@mui/x-date-pickers/internals';
|
|
19
19
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
20
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
20
21
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from "./dateRangeCalendarClasses.js";
|
|
21
22
|
import { isEndOfRange, isRangeValid, isStartOfRange, isWithinRange } from "../internals/utils/date-utils.js";
|
|
22
23
|
import { calculateRangeChange, calculateRangePreview } from "../internals/utils/date-range-manager.js";
|
|
@@ -29,7 +30,7 @@ import { PickersRangeCalendarHeader } from "../PickersRangeCalendarHeader/index.
|
|
|
29
30
|
import { useNullablePickerRangePositionContext } from "../internals/hooks/useNullablePickerRangePositionContext.js";
|
|
30
31
|
import { dateRangePickerDay2Classes } from "../DateRangePickerDay2/index.js";
|
|
31
32
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
|
-
const releaseInfo = "
|
|
33
|
+
const releaseInfo = "MTc1MDk3NTIwMDAwMA==";
|
|
33
34
|
const DateRangeCalendarRoot = styled('div', {
|
|
34
35
|
name: 'MuiDateRangeCalendar',
|
|
35
36
|
slot: 'Root'
|
|
@@ -187,7 +188,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
187
188
|
focusedView: focusedViewProp,
|
|
188
189
|
onFocusedViewChange
|
|
189
190
|
});
|
|
190
|
-
const
|
|
191
|
+
const adapter = usePickerAdapter();
|
|
191
192
|
const id = useId();
|
|
192
193
|
const {
|
|
193
194
|
rangePosition,
|
|
@@ -208,7 +209,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
208
209
|
newRange
|
|
209
210
|
} = calculateRangeChange({
|
|
210
211
|
newDate,
|
|
211
|
-
|
|
212
|
+
adapter,
|
|
212
213
|
range: value,
|
|
213
214
|
rangePosition,
|
|
214
215
|
allowRangeFlip,
|
|
@@ -219,7 +220,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
219
220
|
if (isNextSectionAvailable) {
|
|
220
221
|
setRangePosition(nextSelection);
|
|
221
222
|
}
|
|
222
|
-
const isFullRangeSelected = rangePosition === 'end' && isRangeValid(
|
|
223
|
+
const isFullRangeSelected = rangePosition === 'end' && isRangeValid(adapter, newRange);
|
|
223
224
|
setValueAndGoToNextView(newRange, isFullRangeSelected || !isNextSectionAvailable ? 'finish' : 'partial', view);
|
|
224
225
|
});
|
|
225
226
|
const handleDrop = useEventCallback(newDate => {
|
|
@@ -229,12 +230,12 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
229
230
|
|
|
230
231
|
// Range going for the start of the start day to the end of the end day.
|
|
231
232
|
// This makes sure that `isWithinRange` works with any time in the start and end day.
|
|
232
|
-
const valueDayRange = React.useMemo(() => [!
|
|
233
|
+
const valueDayRange = React.useMemo(() => [!adapter.isValid(value[0]) ? value[0] : adapter.startOfDay(value[0]), !adapter.isValid(value[1]) ? value[1] : adapter.endOfDay(value[1])], [value, adapter]);
|
|
233
234
|
const _useDragRange = useDragRange({
|
|
234
235
|
disableDragEditing: shouldDisableDragEditing,
|
|
235
236
|
onDrop: handleDrop,
|
|
236
237
|
onDatePositionChange: handleDatePositionChange,
|
|
237
|
-
|
|
238
|
+
adapter,
|
|
238
239
|
dateRange: valueDayRange,
|
|
239
240
|
timezone
|
|
240
241
|
}),
|
|
@@ -256,14 +257,14 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
256
257
|
return [null, null];
|
|
257
258
|
}
|
|
258
259
|
const newRange = calculateRangeChange({
|
|
259
|
-
|
|
260
|
+
adapter,
|
|
260
261
|
range: valueDayRange,
|
|
261
262
|
newDate: rangeDragDay,
|
|
262
263
|
rangePosition,
|
|
263
264
|
allowRangeFlip: true
|
|
264
265
|
}).newRange;
|
|
265
|
-
return newRange[0] !== null && newRange[1] !== null ? [
|
|
266
|
-
}, [rangePosition, rangeDragDay,
|
|
266
|
+
return newRange[0] !== null && newRange[1] !== null ? [adapter.startOfDay(newRange[0]), adapter.endOfDay(newRange[1])] : newRange;
|
|
267
|
+
}, [rangePosition, rangeDragDay, adapter, valueDayRange]);
|
|
267
268
|
const wrappedShouldDisableDate = React.useMemo(() => {
|
|
268
269
|
if (!shouldDisableDate) {
|
|
269
270
|
return undefined;
|
|
@@ -286,24 +287,24 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
286
287
|
shouldDisableDate: wrappedShouldDisableDate,
|
|
287
288
|
timezone,
|
|
288
289
|
getCurrentMonthFromVisibleDate: (visibleDate, prevMonth) => {
|
|
289
|
-
const firstVisibleMonth =
|
|
290
|
-
const lastVisibleMonth =
|
|
290
|
+
const firstVisibleMonth = adapter.addMonths(prevMonth, 1 - currentMonthCalendarPosition);
|
|
291
|
+
const lastVisibleMonth = adapter.endOfMonth(adapter.addMonths(firstVisibleMonth, calendars - 1));
|
|
291
292
|
|
|
292
293
|
// The new focused day is inside the visible calendars,
|
|
293
294
|
// Do not change the current month
|
|
294
|
-
if (
|
|
295
|
+
if (adapter.isWithinRange(visibleDate, [firstVisibleMonth, lastVisibleMonth])) {
|
|
295
296
|
return prevMonth;
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
// The new focused day is after the last visible month,
|
|
299
300
|
// Move the current month so that the new focused day is inside the first visible month
|
|
300
|
-
if (
|
|
301
|
-
return
|
|
301
|
+
if (adapter.isAfter(visibleDate, lastVisibleMonth)) {
|
|
302
|
+
return adapter.startOfMonth(adapter.addMonths(visibleDate, currentMonthCalendarPosition - 1));
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
// The new focused day is before the first visible month,
|
|
305
306
|
// Move the current month so that the new focused day is inside the last visible month
|
|
306
|
-
return
|
|
307
|
+
return adapter.startOfMonth(adapter.addMonths(visibleDate, currentMonthCalendarPosition - calendars));
|
|
307
308
|
}
|
|
308
309
|
});
|
|
309
310
|
const CalendarHeader = slots?.calendarHeader ?? PickersRangeCalendarHeader;
|
|
@@ -336,7 +337,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
336
337
|
const prevValue = React.useRef(null);
|
|
337
338
|
React.useEffect(() => {
|
|
338
339
|
const date = rangePosition === 'start' ? value[0] : value[1];
|
|
339
|
-
if (!
|
|
340
|
+
if (!adapter.isValid(date)) {
|
|
340
341
|
return;
|
|
341
342
|
}
|
|
342
343
|
const prevDate = rangePosition === 'start' ? prevValue.current?.[0] : prevValue.current?.[1];
|
|
@@ -344,16 +345,16 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
344
345
|
|
|
345
346
|
// The current date did not change, this call comes either from a `rangePosition` change or a change in the other date.
|
|
346
347
|
// In both cases, we don't want to change the visible month(s).
|
|
347
|
-
if (disableAutoMonthSwitching && prevDate &&
|
|
348
|
+
if (disableAutoMonthSwitching && prevDate && adapter.isEqual(prevDate, date)) {
|
|
348
349
|
return;
|
|
349
350
|
}
|
|
350
351
|
const displayingMonthRange = calendars - currentMonthCalendarPosition;
|
|
351
|
-
const currentMonthNumber =
|
|
352
|
-
const requestedMonthNumber =
|
|
353
|
-
if (!
|
|
352
|
+
const currentMonthNumber = adapter.getMonth(calendarState.currentMonth);
|
|
353
|
+
const requestedMonthNumber = adapter.getMonth(date);
|
|
354
|
+
if (!adapter.isSameYear(calendarState.currentMonth, date) || requestedMonthNumber < currentMonthNumber || requestedMonthNumber > currentMonthNumber + displayingMonthRange) {
|
|
354
355
|
const newMonth = rangePosition === 'start' ? date :
|
|
355
356
|
// If need to focus end, scroll to the state when "end" is displaying in the last calendar
|
|
356
|
-
|
|
357
|
+
adapter.addMonths(date, -displayingMonthRange);
|
|
357
358
|
setVisibleDate({
|
|
358
359
|
target: newMonth,
|
|
359
360
|
reason: 'controlled-value-change'
|
|
@@ -377,7 +378,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
377
378
|
onMouseLeave: () => setRangePreviewDay(null)
|
|
378
379
|
}), []);
|
|
379
380
|
const previewingRange = calculateRangePreview({
|
|
380
|
-
|
|
381
|
+
adapter,
|
|
381
382
|
range: valueDayRange,
|
|
382
383
|
newDate: rangePreviewDay,
|
|
383
384
|
rangePosition
|
|
@@ -386,12 +387,12 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
386
387
|
let cleanNewRangePreviewDay;
|
|
387
388
|
if (valueDayRange[0] == null && valueDayRange[1] == null) {
|
|
388
389
|
cleanNewRangePreviewDay = null;
|
|
389
|
-
} else if (isWithinRange(
|
|
390
|
+
} else if (isWithinRange(adapter, newRangePreviewDay, valueDayRange)) {
|
|
390
391
|
cleanNewRangePreviewDay = null;
|
|
391
392
|
} else {
|
|
392
393
|
cleanNewRangePreviewDay = newRangePreviewDay;
|
|
393
394
|
}
|
|
394
|
-
if (!areDatesEqual(
|
|
395
|
+
if (!areDatesEqual(adapter, cleanNewRangePreviewDay, rangePreviewDay)) {
|
|
395
396
|
setRangePreviewDay(cleanNewRangePreviewDay);
|
|
396
397
|
}
|
|
397
398
|
});
|
|
@@ -404,8 +405,8 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
404
405
|
day,
|
|
405
406
|
isDaySelected
|
|
406
407
|
} = dayOwnerState;
|
|
407
|
-
const isSelectedStartDate = isStartOfRange(
|
|
408
|
-
const isSelectedEndDate = isEndOfRange(
|
|
408
|
+
const isSelectedStartDate = isStartOfRange(adapter, day, valueDayRange);
|
|
409
|
+
const isSelectedEndDate = isEndOfRange(adapter, day, valueDayRange);
|
|
409
410
|
const shouldInitDragging = !shouldDisableDragEditing && valueDayRange[0] && valueDayRange[1];
|
|
410
411
|
const isElementDraggable = shouldInitDragging && (isSelectedStartDate || isSelectedEndDate);
|
|
411
412
|
let datePosition;
|
|
@@ -414,15 +415,15 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
414
415
|
} else if (isSelectedEndDate) {
|
|
415
416
|
datePosition = 'end';
|
|
416
417
|
}
|
|
417
|
-
const isStartOfHighlighting = isDragging ? isStartOfRange(
|
|
418
|
-
const isEndOfHighlighting = isDragging ? isEndOfRange(
|
|
418
|
+
const isStartOfHighlighting = isDragging ? isStartOfRange(adapter, day, draggingRange) : isSelectedStartDate;
|
|
419
|
+
const isEndOfHighlighting = isDragging ? isEndOfRange(adapter, day, draggingRange) : isSelectedEndDate;
|
|
419
420
|
return _extends({
|
|
420
|
-
isPreviewing: shouldHavePreview ? isWithinRange(
|
|
421
|
-
isStartOfPreviewing: shouldHavePreview ? isStartOfRange(
|
|
422
|
-
isEndOfPreviewing: shouldHavePreview ? isEndOfRange(
|
|
423
|
-
isHighlighting: isWithinRange(
|
|
421
|
+
isPreviewing: shouldHavePreview ? isWithinRange(adapter, day, previewingRange) : false,
|
|
422
|
+
isStartOfPreviewing: shouldHavePreview ? isStartOfRange(adapter, day, previewingRange) : false,
|
|
423
|
+
isEndOfPreviewing: shouldHavePreview ? isEndOfRange(adapter, day, previewingRange) : false,
|
|
424
|
+
isHighlighting: isWithinRange(adapter, day, isDragging ? draggingRange : valueDayRange),
|
|
424
425
|
isStartOfHighlighting,
|
|
425
|
-
isEndOfHighlighting: isDragging ? isEndOfRange(
|
|
426
|
+
isEndOfHighlighting: isDragging ? isEndOfRange(adapter, day, draggingRange) : isSelectedEndDate,
|
|
426
427
|
onMouseEnter: shouldHavePreview ? handleDayMouseEnter : undefined,
|
|
427
428
|
// apply selected styling to the dragging start or end day
|
|
428
429
|
isVisuallySelected: isDaySelected || isDragging && (isStartOfHighlighting || isEndOfHighlighting),
|
|
@@ -441,11 +442,11 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
441
442
|
warnOnce(['MUI X: The `currentMonthCalendarPosition` prop must be an integer between `1` and the amount of calendars rendered.', 'For example if you have 2 calendars rendered, it should be equal to either 1 or 2.']);
|
|
442
443
|
}
|
|
443
444
|
}
|
|
444
|
-
const firstMonth =
|
|
445
|
+
const firstMonth = adapter.addMonths(calendarState.currentMonth, 1 - currentMonthCalendarPosition);
|
|
445
446
|
return Array.from({
|
|
446
447
|
length: calendars
|
|
447
|
-
}).map((_, index) =>
|
|
448
|
-
}, [
|
|
448
|
+
}).map((_, index) => adapter.addMonths(firstMonth, index));
|
|
449
|
+
}, [adapter, calendarState.currentMonth, calendars, currentMonthCalendarPosition]);
|
|
449
450
|
const hasFocus = focusedView !== null;
|
|
450
451
|
const prevOpenViewRef = React.useRef(view);
|
|
451
452
|
React.useEffect(() => {
|
|
@@ -4,7 +4,7 @@ import { PickerRangeValue } from '@mui/x-date-pickers/internals';
|
|
|
4
4
|
import { RangePosition } from "../models/index.js";
|
|
5
5
|
interface UseDragRangeParams {
|
|
6
6
|
disableDragEditing?: boolean;
|
|
7
|
-
|
|
7
|
+
adapter: MuiPickersAdapter;
|
|
8
8
|
setRangeDragDay: (value: PickerValidDate | null) => void;
|
|
9
9
|
setIsDragging: (value: boolean) => void;
|
|
10
10
|
isDragging: boolean;
|
|
@@ -31,7 +31,7 @@ interface UseDragRangeResponse extends UseDragRangeEvents {
|
|
|
31
31
|
}
|
|
32
32
|
export declare const useDragRange: ({
|
|
33
33
|
disableDragEditing,
|
|
34
|
-
|
|
34
|
+
adapter,
|
|
35
35
|
onDatePositionChange,
|
|
36
36
|
onDrop,
|
|
37
37
|
dateRange,
|
|
@@ -4,13 +4,13 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import { isEndOfRange, isStartOfRange } from "../internals/utils/date-utils.js";
|
|
7
|
-
const resolveDateFromTarget = (target,
|
|
7
|
+
const resolveDateFromTarget = (target, adapter, timezone) => {
|
|
8
8
|
const timestampString = target.dataset.timestamp;
|
|
9
9
|
if (!timestampString) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
const timestamp = +timestampString;
|
|
13
|
-
return
|
|
13
|
+
return adapter.date(new Date(timestamp).toISOString(), timezone);
|
|
14
14
|
};
|
|
15
15
|
const isSameAsDraggingDate = event => {
|
|
16
16
|
const timestampString = event.target.dataset.timestamp;
|
|
@@ -43,7 +43,7 @@ const resolveElementFromTouch = (event, ignoreTouchTarget) => {
|
|
|
43
43
|
return null;
|
|
44
44
|
};
|
|
45
45
|
const useDragRangeEvents = ({
|
|
46
|
-
|
|
46
|
+
adapter,
|
|
47
47
|
setRangeDragDay,
|
|
48
48
|
setIsDragging,
|
|
49
49
|
isDragging,
|
|
@@ -64,12 +64,12 @@ const useDragRangeEvents = ({
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
const shouldInitDragging = !disableDragEditing && !!dateRange[0] && !!dateRange[1];
|
|
67
|
-
const isSelectedStartDate = isStartOfRange(
|
|
68
|
-
const isSelectedEndDate = isEndOfRange(
|
|
67
|
+
const isSelectedStartDate = isStartOfRange(adapter, day, dateRange);
|
|
68
|
+
const isSelectedEndDate = isEndOfRange(adapter, day, dateRange);
|
|
69
69
|
return shouldInitDragging && (isSelectedStartDate || isSelectedEndDate);
|
|
70
70
|
};
|
|
71
71
|
const handleDragStart = useEventCallback(event => {
|
|
72
|
-
const newDate = resolveDateFromTarget(event.target,
|
|
72
|
+
const newDate = resolveDateFromTarget(event.target, adapter, timezone);
|
|
73
73
|
if (!isElementDraggable(newDate)) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
@@ -93,7 +93,7 @@ const useDragRangeEvents = ({
|
|
|
93
93
|
if (!target) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
const newDate = resolveDateFromTarget(target,
|
|
96
|
+
const newDate = resolveDateFromTarget(target, adapter, timezone);
|
|
97
97
|
if (!isElementDraggable(newDate)) {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
@@ -106,14 +106,14 @@ const useDragRangeEvents = ({
|
|
|
106
106
|
event.preventDefault();
|
|
107
107
|
event.stopPropagation();
|
|
108
108
|
event.dataTransfer.dropEffect = 'move';
|
|
109
|
-
setRangeDragDay(resolveDateFromTarget(event.target,
|
|
109
|
+
setRangeDragDay(resolveDateFromTarget(event.target, adapter, timezone));
|
|
110
110
|
});
|
|
111
111
|
const handleTouchMove = useEventCallback(event => {
|
|
112
112
|
const target = resolveElementFromTouch(event);
|
|
113
113
|
if (!target) {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
const newDate = resolveDateFromTarget(target,
|
|
116
|
+
const newDate = resolveDateFromTarget(target, adapter, timezone);
|
|
117
117
|
if (newDate) {
|
|
118
118
|
setRangeDragDay(newDate);
|
|
119
119
|
}
|
|
@@ -160,7 +160,7 @@ const useDragRangeEvents = ({
|
|
|
160
160
|
|
|
161
161
|
// make sure the focused element is the element where touch ended
|
|
162
162
|
target.focus();
|
|
163
|
-
const newDate = resolveDateFromTarget(target,
|
|
163
|
+
const newDate = resolveDateFromTarget(target, adapter, timezone);
|
|
164
164
|
if (newDate) {
|
|
165
165
|
onDrop(newDate);
|
|
166
166
|
}
|
|
@@ -187,7 +187,7 @@ const useDragRangeEvents = ({
|
|
|
187
187
|
if (isSameAsDraggingDate(event)) {
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
|
-
const newDate = resolveDateFromTarget(event.target,
|
|
190
|
+
const newDate = resolveDateFromTarget(event.target, adapter, timezone);
|
|
191
191
|
if (newDate) {
|
|
192
192
|
onDrop(newDate);
|
|
193
193
|
}
|
|
@@ -206,7 +206,7 @@ const useDragRangeEvents = ({
|
|
|
206
206
|
};
|
|
207
207
|
export const useDragRange = ({
|
|
208
208
|
disableDragEditing,
|
|
209
|
-
|
|
209
|
+
adapter,
|
|
210
210
|
onDatePositionChange,
|
|
211
211
|
onDrop,
|
|
212
212
|
dateRange,
|
|
@@ -215,24 +215,24 @@ export const useDragRange = ({
|
|
|
215
215
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
216
216
|
const [rangeDragDay, setRangeDragDay] = React.useState(null);
|
|
217
217
|
const handleRangeDragDayChange = useEventCallback(newValue => {
|
|
218
|
-
if (!
|
|
218
|
+
if (!adapter.isEqual(newValue, rangeDragDay)) {
|
|
219
219
|
setRangeDragDay(newValue);
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
const draggingDatePosition = React.useMemo(() => {
|
|
223
223
|
const [start, end] = dateRange;
|
|
224
224
|
if (rangeDragDay) {
|
|
225
|
-
if (start &&
|
|
225
|
+
if (start && adapter.isBefore(rangeDragDay, start)) {
|
|
226
226
|
return 'start';
|
|
227
227
|
}
|
|
228
|
-
if (end &&
|
|
228
|
+
if (end && adapter.isAfter(rangeDragDay, end)) {
|
|
229
229
|
return 'end';
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
return null;
|
|
233
|
-
}, [dateRange, rangeDragDay,
|
|
233
|
+
}, [dateRange, rangeDragDay, adapter]);
|
|
234
234
|
const dragRangeEvents = useDragRangeEvents({
|
|
235
|
-
|
|
235
|
+
adapter,
|
|
236
236
|
onDatePositionChange,
|
|
237
237
|
onDrop,
|
|
238
238
|
setIsDragging,
|
|
@@ -9,8 +9,8 @@ import clsx from 'clsx';
|
|
|
9
9
|
import Typography from '@mui/material/Typography';
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
|
-
import { PickersToolbar, PickersToolbarButton,
|
|
13
|
-
import { usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
12
|
+
import { PickersToolbar, PickersToolbarButton, useToolbarOwnerState } from '@mui/x-date-pickers/internals';
|
|
13
|
+
import { usePickerAdapter, usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
14
14
|
import { getDateRangePickerToolbarUtilityClass } from "./dateRangePickerToolbarClasses.js";
|
|
15
15
|
import { usePickerRangePositionContext } from "../hooks/index.js";
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -42,7 +42,7 @@ const DateRangePickerToolbarContainer = styled('div', {
|
|
|
42
42
|
* - [DateRangePickerToolbar API](https://mui.com/x/api/date-pickers/date-range-picker-toolbar/)
|
|
43
43
|
*/
|
|
44
44
|
const DateRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateRangePickerToolbar(inProps, ref) {
|
|
45
|
-
const
|
|
45
|
+
const adapter = usePickerAdapter();
|
|
46
46
|
const props = useThemeProps({
|
|
47
47
|
props: inProps,
|
|
48
48
|
name: 'MuiDateRangePickerToolbar'
|
|
@@ -65,12 +65,12 @@ const DateRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateRangeP
|
|
|
65
65
|
const classes = useUtilityClasses(classesProp);
|
|
66
66
|
|
|
67
67
|
// This can't be a default value when spreading because it breaks the API generation.
|
|
68
|
-
const toolbarFormat = toolbarFormatProp ??
|
|
68
|
+
const toolbarFormat = toolbarFormatProp ?? adapter.formats.shortDate;
|
|
69
69
|
const formatDate = (date, fallback) => {
|
|
70
|
-
if (!
|
|
70
|
+
if (!adapter.isValid(date)) {
|
|
71
71
|
return fallback;
|
|
72
72
|
}
|
|
73
|
-
return
|
|
73
|
+
return adapter.formatByString(date, toolbarFormat);
|
|
74
74
|
};
|
|
75
75
|
return /*#__PURE__*/_jsx(DateRangePickerToolbarRoot, _extends({}, other, {
|
|
76
76
|
toolbarTitle: translations.dateRangePickerToolbarTitle,
|
|
@@ -9,8 +9,9 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { useLicenseVerifier } from '@mui/x-license';
|
|
10
10
|
import { alpha, styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
|
-
import {
|
|
12
|
+
import { usePickerDayOwnerState } from '@mui/x-date-pickers/internals';
|
|
13
13
|
import { PickersDay } from '@mui/x-date-pickers/PickersDay';
|
|
14
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
14
15
|
import { getDateRangePickerDayUtilityClass, dateRangePickerDayClasses } from "./dateRangePickerDayClasses.js";
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
const useUtilityClasses = (classes, ownerState) => {
|
|
@@ -227,8 +228,8 @@ const DateRangePickerDayRaw = /*#__PURE__*/React.forwardRef(function DateRangePi
|
|
|
227
228
|
showDaysOutsideCurrentMonth
|
|
228
229
|
} = props,
|
|
229
230
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
230
|
-
useLicenseVerifier('x-date-pickers-pro', "
|
|
231
|
-
const
|
|
231
|
+
useLicenseVerifier('x-date-pickers-pro', "MTc1MDk3NTIwMDAwMA==");
|
|
232
|
+
const adapter = usePickerAdapter();
|
|
232
233
|
const shouldRenderHighlight = isHighlighting && !outsideCurrentMonth;
|
|
233
234
|
const shouldRenderPreview = isPreviewing && !outsideCurrentMonth;
|
|
234
235
|
const pickersDayOwnerState = usePickerDayOwnerState({
|
|
@@ -252,8 +253,8 @@ const DateRangePickerDayRaw = /*#__PURE__*/React.forwardRef(function DateRangePi
|
|
|
252
253
|
isDayPreviewEnd: isEndOfPreviewing,
|
|
253
254
|
isDayInsidePreview: isPreviewing && !isStartOfPreviewing && !isEndOfPreviewing,
|
|
254
255
|
// Properties specific to the MUI implementation (some might be removed in the next major)
|
|
255
|
-
isDayStartOfMonth:
|
|
256
|
-
isDayEndOfMonth:
|
|
256
|
+
isDayStartOfMonth: adapter.isSameDay(day, adapter.startOfMonth(day)),
|
|
257
|
+
isDayEndOfMonth: adapter.isSameDay(day, adapter.endOfMonth(day)),
|
|
257
258
|
isDayFirstVisibleCell: isFirstVisibleCell,
|
|
258
259
|
isDayLastVisibleCell: isLastVisibleCell,
|
|
259
260
|
isDayFillerCell: outsideCurrentMonth && !showDaysOutsideCurrentMonth
|
|
@@ -9,7 +9,8 @@ import ButtonBase from '@mui/material/ButtonBase';
|
|
|
9
9
|
import useForkRef from '@mui/utils/useForkRef';
|
|
10
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
11
11
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
12
|
-
import { usePickerDayOwnerState
|
|
12
|
+
import { usePickerDayOwnerState } from '@mui/x-date-pickers/internals';
|
|
13
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
13
14
|
import { dateRangePickerDay2Classes, getDateRangePickerDay2UtilityClass } from "./dateRangePickerDay2Classes.js";
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
const useUtilityClasses = (ownerState, classes) => {
|
|
@@ -302,7 +303,7 @@ const DateRangePickerDay2Raw = /*#__PURE__*/React.forwardRef(function DateRangeP
|
|
|
302
303
|
props: inProps,
|
|
303
304
|
name: 'MuiDateRangePickerDay2'
|
|
304
305
|
});
|
|
305
|
-
const
|
|
306
|
+
const adapter = usePickerAdapter();
|
|
306
307
|
const {
|
|
307
308
|
autoFocus = false,
|
|
308
309
|
className,
|
|
@@ -355,8 +356,8 @@ const DateRangePickerDay2Raw = /*#__PURE__*/React.forwardRef(function DateRangeP
|
|
|
355
356
|
isDayPreviewEnd: isEndOfPreviewing,
|
|
356
357
|
isDayInsidePreview: isPreviewing && !isStartOfPreviewing && !isEndOfPreviewing,
|
|
357
358
|
// Properties specific to the MUI implementation (some might be removed in the next major)
|
|
358
|
-
isDayStartOfMonth:
|
|
359
|
-
isDayEndOfMonth:
|
|
359
|
+
isDayStartOfMonth: adapter.isSameDay(day, adapter.startOfMonth(day)),
|
|
360
|
+
isDayEndOfMonth: adapter.isSameDay(day, adapter.endOfMonth(day)),
|
|
360
361
|
isDayFirstVisibleCell: isFirstVisibleCell,
|
|
361
362
|
isDayLastVisibleCell: isLastVisibleCell,
|
|
362
363
|
isDayFillerCell: outsideCurrentMonth && !showDaysOutsideCurrentMonth,
|
|
@@ -412,7 +413,7 @@ const DateRangePickerDay2Raw = /*#__PURE__*/React.forwardRef(function DateRangeP
|
|
|
412
413
|
}, other, {
|
|
413
414
|
ownerState: ownerState,
|
|
414
415
|
className: clsx(classes.root, className),
|
|
415
|
-
children: children ?? (ownerState.isDayFillerCell ? null :
|
|
416
|
+
children: children ?? (ownerState.isDayFillerCell ? null : adapter.format(day, 'dayOfMonth'))
|
|
416
417
|
}));
|
|
417
418
|
});
|
|
418
419
|
if (process.env.NODE_ENV !== "production") DateRangePickerDay2Raw.displayName = "DateRangePickerDay2Raw";
|
|
@@ -53,7 +53,7 @@ process.env.NODE_ENV !== "production" ? DateTimeRangePicker.propTypes = {
|
|
|
53
53
|
// ----------------------------------------------------------------------
|
|
54
54
|
/**
|
|
55
55
|
* 12h/24h view for hour selection clock.
|
|
56
|
-
* @default
|
|
56
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
57
57
|
*/
|
|
58
58
|
ampm: PropTypes.bool,
|
|
59
59
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["viewRenderer", "value", "onChange", "defaultValue", "onViewChange", "views", "className"];
|
|
4
|
-
import {
|
|
4
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
5
5
|
import { isRangeValid } from "../internals/utils/date-utils.js";
|
|
6
6
|
import { calculateRangeChange } from "../internals/utils/date-range-manager.js";
|
|
7
7
|
import { usePickerRangePositionContext } from "../hooks/index.js";
|
|
@@ -9,7 +9,7 @@ import { usePickerRangePositionContext } from "../hooks/index.js";
|
|
|
9
9
|
* @ignore - internal component.
|
|
10
10
|
*/
|
|
11
11
|
function DateTimeRangePickerTimeWrapper(props) {
|
|
12
|
-
const
|
|
12
|
+
const adapter = usePickerAdapter();
|
|
13
13
|
const {
|
|
14
14
|
viewRenderer,
|
|
15
15
|
value,
|
|
@@ -35,11 +35,11 @@ function DateTimeRangePickerTimeWrapper(props) {
|
|
|
35
35
|
newRange
|
|
36
36
|
} = calculateRangeChange({
|
|
37
37
|
newDate,
|
|
38
|
-
|
|
38
|
+
adapter,
|
|
39
39
|
range: value,
|
|
40
40
|
rangePosition
|
|
41
41
|
});
|
|
42
|
-
const isFullRangeSelected = rangePosition === 'end' && isRangeValid(
|
|
42
|
+
const isFullRangeSelected = rangePosition === 'end' && isRangeValid(adapter, newRange);
|
|
43
43
|
onChange(newRange, isFullRangeSelected ? 'finish' : 'partial', selectedView);
|
|
44
44
|
};
|
|
45
45
|
return viewRenderer(_extends({}, other, {
|
|
@@ -8,8 +8,8 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
11
|
-
import {
|
|
12
|
-
import { usePickerContext, usePickerTranslations } from '@mui/x-date-pickers/hooks';
|
|
11
|
+
import { useToolbarOwnerState, DateTimePickerToolbarOverrideContext } from '@mui/x-date-pickers/internals';
|
|
12
|
+
import { usePickerAdapter, usePickerContext, 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";
|
|
@@ -46,7 +46,7 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
46
46
|
props: inProps,
|
|
47
47
|
name: 'MuiDateTimeRangePickerToolbar'
|
|
48
48
|
});
|
|
49
|
-
const
|
|
49
|
+
const adapter = usePickerAdapter();
|
|
50
50
|
const {
|
|
51
51
|
className,
|
|
52
52
|
classes: classesProp,
|
|
@@ -89,7 +89,7 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
89
89
|
newRange
|
|
90
90
|
} = calculateRangeChange({
|
|
91
91
|
newDate,
|
|
92
|
-
|
|
92
|
+
adapter,
|
|
93
93
|
range: value,
|
|
94
94
|
rangePosition,
|
|
95
95
|
allowRangeFlip: true
|
|
@@ -98,7 +98,7 @@ const DateTimeRangePickerToolbar = /*#__PURE__*/React.forwardRef(function DateTi
|
|
|
98
98
|
setValue(newRange, {
|
|
99
99
|
changeImportance: 'set'
|
|
100
100
|
});
|
|
101
|
-
}, [setValue, setRangePosition, value, rangePosition,
|
|
101
|
+
}, [setValue, setRangePosition, value, rangePosition, adapter]);
|
|
102
102
|
const startOverrides = React.useMemo(() => {
|
|
103
103
|
const handleStartRangeViewChange = newView => {
|
|
104
104
|
if (newView === 'year' || newView === 'month') {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { useThemeProps } from '@mui/material/styles';
|
|
3
|
-
import {
|
|
3
|
+
import { applyDefaultViewProps, resolveTimeViewsResponse, useApplyDefaultValuesToDateTimeValidationProps } from '@mui/x-date-pickers/internals';
|
|
4
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
4
5
|
import { DateTimeRangePickerToolbar } from "./DateTimeRangePickerToolbar.js";
|
|
5
6
|
import { DateTimeRangePickerTabs } from "./DateTimeRangePickerTabs.js";
|
|
6
7
|
export function useDateTimeRangePickerDefaultizedProps(props, name) {
|
|
7
|
-
const
|
|
8
|
+
const adapter = usePickerAdapter();
|
|
8
9
|
const themeProps = useThemeProps({
|
|
9
10
|
props,
|
|
10
11
|
name
|
|
11
12
|
});
|
|
12
13
|
const validationProps = useApplyDefaultValuesToDateTimeValidationProps(themeProps);
|
|
13
|
-
const ampm = themeProps.ampm ??
|
|
14
|
+
const ampm = themeProps.ampm ?? adapter.is12HourCycleInCurrentLocale();
|
|
14
15
|
const {
|
|
15
16
|
openTo,
|
|
16
17
|
views: defaultViews
|
|
@@ -3,10 +3,10 @@
|
|
|
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';
|
|
7
|
-
import { extractValidationProps } from '@mui/x-date-pickers/validation';
|
|
8
6
|
import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
9
7
|
import refType from '@mui/utils/refType';
|
|
8
|
+
import { extractValidationProps } from '@mui/x-date-pickers/validation';
|
|
9
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
10
10
|
import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
11
11
|
import { useDateRangePickerDefaultizedProps } from "../DateRangePicker/shared.js";
|
|
12
12
|
import { renderDateRangeViewCalendar } from "../dateRangeViewRenderers/index.js";
|
|
@@ -24,7 +24,7 @@ import { validateDateRange } from "../validation/index.js";
|
|
|
24
24
|
* - [DesktopDateRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-range-picker/)
|
|
25
25
|
*/
|
|
26
26
|
const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateRangePicker(inProps, ref) {
|
|
27
|
-
const
|
|
27
|
+
const adapter = usePickerAdapter();
|
|
28
28
|
|
|
29
29
|
// Props with the default values common to all date time pickers
|
|
30
30
|
const defaultizedProps = useDateRangePickerDefaultizedProps(inProps, 'MuiDesktopDateRangePicker');
|
|
@@ -35,7 +35,7 @@ const DesktopDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDat
|
|
|
35
35
|
closeOnSelect: defaultizedProps.closeOnSelect ?? true,
|
|
36
36
|
viewRenderers,
|
|
37
37
|
// TODO: Replace with resolveDateFormat() once we support month and year views
|
|
38
|
-
format: defaultizedProps.format ??
|
|
38
|
+
format: defaultizedProps.format ?? adapter.formats.keyboardDate,
|
|
39
39
|
calendars: defaultizedProps.calendars ?? 2,
|
|
40
40
|
views: ['day'],
|
|
41
41
|
openTo: 'day',
|
|
@@ -5,15 +5,16 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["openTo"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { isDatePickerView, isInternalTimeView, resolveDateTimeFormat, useUtils } from '@mui/x-date-pickers/internals';
|
|
9
|
-
import { extractValidationProps } from '@mui/x-date-pickers/validation';
|
|
10
8
|
import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
11
9
|
import refType from '@mui/utils/refType';
|
|
10
|
+
import Divider from '@mui/material/Divider';
|
|
11
|
+
import { isDatePickerView, isInternalTimeView, resolveDateTimeFormat } from '@mui/x-date-pickers/internals';
|
|
12
|
+
import { extractValidationProps } from '@mui/x-date-pickers/validation';
|
|
12
13
|
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from '@mui/x-date-pickers/timeViewRenderers';
|
|
13
14
|
import { multiSectionDigitalClockClasses, multiSectionDigitalClockSectionClasses } from '@mui/x-date-pickers/MultiSectionDigitalClock';
|
|
14
|
-
import Divider from '@mui/material/Divider';
|
|
15
15
|
import { digitalClockClasses } from '@mui/x-date-pickers/DigitalClock';
|
|
16
16
|
import { DesktopDateTimePickerLayout } from '@mui/x-date-pickers/DesktopDateTimePicker';
|
|
17
|
+
import { usePickerAdapter } from '@mui/x-date-pickers/hooks';
|
|
17
18
|
import { rangeValueManager } from "../internals/utils/valueManagers.js";
|
|
18
19
|
import { renderDateRangeViewCalendar } from "../dateRangeViewRenderers/index.js";
|
|
19
20
|
import { useDesktopRangePicker } from "../internals/hooks/useDesktopRangePicker/index.js";
|
|
@@ -91,7 +92,7 @@ if (process.env.NODE_ENV !== "production") rendererInterceptor.displayName = "re
|
|
|
91
92
|
* - [DesktopDateTimeRangePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-range-picker/)
|
|
92
93
|
*/
|
|
93
94
|
const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimeRangePicker(inProps, ref) {
|
|
94
|
-
const
|
|
95
|
+
const adapter = usePickerAdapter();
|
|
95
96
|
// Props with the default values common to all date time range pickers
|
|
96
97
|
const defaultizedProps = useDateTimeRangePickerDefaultizedProps(inProps, 'MuiDesktopDateTimeRangePicker');
|
|
97
98
|
const renderTimeView = defaultizedProps.shouldRenderTimeInASingleColumn ? renderDigitalClockTimeView : renderMultiSectionDigitalClockTimeView;
|
|
@@ -109,7 +110,7 @@ const DesktopDateTimeRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
|
|
|
109
110
|
const props = _extends({}, defaultizedProps, {
|
|
110
111
|
views,
|
|
111
112
|
viewRenderers,
|
|
112
|
-
format: resolveDateTimeFormat(
|
|
113
|
+
format: resolveDateTimeFormat(adapter, defaultizedProps, true),
|
|
113
114
|
// force true to correctly handle `renderTimeViewClock` as a renderer
|
|
114
115
|
ampmInClock: true,
|
|
115
116
|
calendars: defaultizedProps.calendars ?? 1,
|
|
@@ -148,7 +149,7 @@ DesktopDateTimeRangePicker.propTypes = {
|
|
|
148
149
|
// ----------------------------------------------------------------------
|
|
149
150
|
/**
|
|
150
151
|
* 12h/24h view for hour selection clock.
|
|
151
|
-
* @default
|
|
152
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
152
153
|
*/
|
|
153
154
|
ampm: PropTypes.bool,
|
|
154
155
|
/**
|