@mui/x-date-pickers 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/DateCalendar/DateCalendar.js +16 -16
- package/DateCalendar/DayCalendar.js +48 -48
- package/DateCalendar/useCalendarState.js +25 -25
- package/DateCalendar/useIsDateDisabled.js +2 -2
- package/DatePicker/DatePickerToolbar.js +7 -9
- package/DateTimeField/DateTimeField.js +1 -1
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +12 -13
- package/DateTimePicker/shared.js +3 -3
- package/DesktopDatePicker/DesktopDatePicker.js +3 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
- package/DesktopTimePicker/DesktopTimePicker.js +4 -4
- package/DigitalClock/DigitalClock.d.ts +1 -1
- package/DigitalClock/DigitalClock.js +16 -16
- package/LocalizationProvider/LocalizationProvider.d.ts +9 -3
- package/LocalizationProvider/LocalizationProvider.js +28 -19
- package/MobileDatePicker/MobileDatePicker.js +3 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
- package/MobileTimePicker/MobileTimePicker.js +4 -4
- package/MonthCalendar/MonthCalendar.js +19 -18
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
- package/PickerDay2/PickerDay2.js +3 -3
- package/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/PickersActionBar/PickersActionBar.js +2 -2
- package/PickersCalendarHeader/PickersCalendarHeader.js +7 -8
- package/PickersDay/PickersDay.js +3 -3
- package/PickersDay/usePickerDayOwnerState.js +5 -5
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/StaticTimePicker/StaticTimePicker.js +1 -1
- package/TimeClock/Clock.js +8 -9
- package/TimeClock/ClockNumbers.d.ts +3 -3
- package/TimeClock/ClockNumbers.js +5 -5
- package/TimeClock/TimeClock.js +29 -29
- package/TimeField/TimeField.js +1 -1
- package/TimePicker/TimePicker.js +1 -1
- package/TimePicker/TimePickerToolbar.js +7 -9
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +19 -18
- package/esm/DateCalendar/DateCalendar.js +16 -16
- package/esm/DateCalendar/DayCalendar.js +48 -48
- package/esm/DateCalendar/useCalendarState.js +25 -25
- package/esm/DateCalendar/useIsDateDisabled.js +2 -2
- package/esm/DatePicker/DatePickerToolbar.js +6 -8
- package/esm/DateTimeField/DateTimeField.js +1 -1
- package/esm/DateTimePicker/DateTimePicker.js +1 -1
- package/esm/DateTimePicker/DateTimePickerToolbar.js +11 -12
- package/esm/DateTimePicker/shared.js +3 -3
- package/esm/DesktopDatePicker/DesktopDatePicker.js +3 -3
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
- package/esm/DesktopTimePicker/DesktopTimePicker.js +4 -4
- package/esm/DigitalClock/DigitalClock.d.ts +1 -1
- package/esm/DigitalClock/DigitalClock.js +16 -16
- package/esm/LocalizationProvider/LocalizationProvider.d.ts +9 -3
- package/esm/LocalizationProvider/LocalizationProvider.js +27 -18
- package/esm/MobileDatePicker/MobileDatePicker.js +3 -3
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
- package/esm/MobileTimePicker/MobileTimePicker.js +4 -4
- package/esm/MonthCalendar/MonthCalendar.js +20 -19
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
- package/esm/PickerDay2/PickerDay2.js +3 -3
- package/esm/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/esm/PickersActionBar/PickersActionBar.js +2 -2
- package/esm/PickersCalendarHeader/PickersCalendarHeader.js +6 -7
- package/esm/PickersDay/PickersDay.js +3 -3
- package/esm/PickersDay/usePickerDayOwnerState.js +5 -5
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
- package/esm/TimeClock/Clock.js +7 -8
- package/esm/TimeClock/ClockNumbers.d.ts +3 -3
- package/esm/TimeClock/ClockNumbers.js +5 -5
- package/esm/TimeClock/TimeClock.js +29 -29
- package/esm/TimeField/TimeField.js +1 -1
- package/esm/TimePicker/TimePicker.js +1 -1
- package/esm/TimePicker/TimePickerToolbar.js +6 -8
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +20 -19
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useParsedFormat.js +6 -6
- package/esm/hooks/usePickerAdapter.d.ts +7 -0
- package/esm/hooks/usePickerAdapter.js +20 -0
- package/esm/hooks/usePickerTranslations.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/pickersToolbarClasses.d.ts +1 -1
- package/esm/internals/demo/DemoContainer.d.ts +2 -3
- package/esm/internals/demo/DemoContainer.js +3 -2
- package/esm/internals/hooks/date-helpers-hooks.js +16 -16
- package/esm/internals/hooks/useClockReferenceDate.d.ts +2 -2
- package/esm/internals/hooks/useClockReferenceDate.js +3 -3
- package/esm/internals/hooks/useControlledValue.js +8 -7
- package/esm/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/esm/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
- package/esm/internals/hooks/useField/useField.types.d.ts +2 -2
- package/esm/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/esm/internals/hooks/useField/useField.utils.js +69 -69
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +15 -16
- package/esm/internals/hooks/useField/useFieldState.js +22 -24
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
- package/esm/internals/hooks/usePicker/usePicker.js +5 -6
- package/esm/internals/hooks/useUtils.d.ts +1 -8
- package/esm/internals/hooks/useUtils.js +3 -19
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/models/manager.d.ts +14 -14
- package/esm/internals/models/props/time.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.js +5 -5
- package/esm/internals/utils/date-utils.d.ts +11 -11
- package/esm/internals/utils/date-utils.js +34 -34
- package/esm/internals/utils/getDefaultReferenceDate.d.ts +2 -2
- package/esm/internals/utils/getDefaultReferenceDate.js +16 -16
- package/esm/internals/utils/time-utils.d.ts +5 -5
- package/esm/internals/utils/time-utils.js +12 -12
- package/esm/internals/utils/valueManagers.js +4 -4
- package/esm/managers/useDateManager.js +12 -12
- package/esm/managers/useDateTimeManager.js +13 -13
- package/esm/managers/useTimeManager.js +9 -10
- package/esm/validation/useValidation.d.ts +2 -3
- package/esm/validation/useValidation.js +2 -2
- package/esm/validation/validateDate.js +6 -6
- package/esm/validation/validateTime.js +6 -6
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +8 -1
- package/hooks/useParsedFormat.js +6 -6
- package/hooks/usePickerAdapter.d.ts +7 -0
- package/hooks/usePickerAdapter.js +29 -0
- package/hooks/usePickerTranslations.js +2 -2
- package/index.js +1 -1
- package/internals/components/pickersToolbarClasses.d.ts +1 -1
- package/internals/demo/DemoContainer.d.ts +2 -3
- package/internals/demo/DemoContainer.js +3 -2
- package/internals/hooks/date-helpers-hooks.js +16 -16
- package/internals/hooks/useClockReferenceDate.d.ts +2 -2
- package/internals/hooks/useClockReferenceDate.js +3 -3
- package/internals/hooks/useControlledValue.js +7 -7
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/internals/hooks/useField/useField.utils.js +69 -69
- package/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
- package/internals/hooks/useField/useFieldSectionContentProps.js +14 -15
- package/internals/hooks/useField/useFieldState.js +23 -25
- package/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
- package/internals/hooks/usePicker/usePicker.js +5 -6
- package/internals/hooks/useUtils.d.ts +1 -8
- package/internals/hooks/useUtils.js +5 -24
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -7
- package/internals/models/manager.d.ts +14 -14
- package/internals/models/props/time.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +1 -1
- package/internals/utils/date-time-utils.js +5 -5
- package/internals/utils/date-utils.d.ts +11 -11
- package/internals/utils/date-utils.js +34 -34
- package/internals/utils/getDefaultReferenceDate.d.ts +2 -2
- package/internals/utils/getDefaultReferenceDate.js +16 -16
- package/internals/utils/time-utils.d.ts +5 -5
- package/internals/utils/time-utils.js +12 -12
- package/internals/utils/valueManagers.js +4 -4
- package/managers/useDateManager.js +12 -12
- package/managers/useDateTimeManager.js +13 -13
- package/managers/useTimeManager.js +10 -11
- package/package.json +2 -2
- package/validation/useValidation.d.ts +2 -3
- package/validation/useValidation.js +2 -2
- package/validation/validateDate.js +6 -6
- package/validation/validateTime.js +6 -6
|
@@ -13,8 +13,8 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
13
13
|
import composeClasses from '@mui/utils/composeClasses';
|
|
14
14
|
import clsx from 'clsx';
|
|
15
15
|
import { PickersDay } from "../PickersDay/index.js";
|
|
16
|
-
import { usePickerTranslations } from "../hooks/
|
|
17
|
-
import {
|
|
16
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
17
|
+
import { useNow } from "../internals/hooks/useUtils.js";
|
|
18
18
|
import { DAY_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
|
|
19
19
|
import { PickersSlideTransition } from "./PickersSlideTransition.js";
|
|
20
20
|
import { useIsDateDisabled } from "./useIsDateDisabled.js";
|
|
@@ -144,14 +144,14 @@ function WrappedDay(_ref) {
|
|
|
144
144
|
slotProps,
|
|
145
145
|
timezone
|
|
146
146
|
} = parentProps;
|
|
147
|
-
const
|
|
147
|
+
const adapter = usePickerAdapter();
|
|
148
148
|
const now = useNow(timezone);
|
|
149
|
-
const isFocusableDay = focusedDay != null &&
|
|
149
|
+
const isFocusableDay = focusedDay != null && adapter.isSameDay(day, focusedDay);
|
|
150
150
|
const isFocusedDay = isViewFocused && isFocusableDay;
|
|
151
|
-
const isSelected = selectedDays.some(selectedDay =>
|
|
152
|
-
const isToday =
|
|
151
|
+
const isSelected = selectedDays.some(selectedDay => adapter.isSameDay(selectedDay, day));
|
|
152
|
+
const isToday = adapter.isSameDay(day, now);
|
|
153
153
|
const isDisabled = React.useMemo(() => disabled || isDateDisabled(day), [disabled, isDateDisabled, day]);
|
|
154
|
-
const isOutsideCurrentMonth = React.useMemo(() =>
|
|
154
|
+
const isOutsideCurrentMonth = React.useMemo(() => adapter.getMonth(day) !== currentMonthNumber, [adapter, day, currentMonthNumber]);
|
|
155
155
|
const ownerState = usePickerDayOwnerState({
|
|
156
156
|
day,
|
|
157
157
|
selected: isSelected,
|
|
@@ -174,7 +174,7 @@ function WrappedDay(_ref) {
|
|
|
174
174
|
role: 'gridcell',
|
|
175
175
|
isAnimating: isMonthSwitchingAnimating,
|
|
176
176
|
// it is used in date range dragging logic by accessing `dataset.timestamp`
|
|
177
|
-
'data-timestamp':
|
|
177
|
+
'data-timestamp': adapter.toJsDate(day).valueOf()
|
|
178
178
|
}, other),
|
|
179
179
|
ownerState: _extends({}, ownerState, {
|
|
180
180
|
day,
|
|
@@ -184,19 +184,19 @@ function WrappedDay(_ref) {
|
|
|
184
184
|
}),
|
|
185
185
|
dayProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
186
186
|
const isFirstVisibleCell = React.useMemo(() => {
|
|
187
|
-
const startOfMonth =
|
|
187
|
+
const startOfMonth = adapter.startOfMonth(adapter.setMonth(day, currentMonthNumber));
|
|
188
188
|
if (!showDaysOutsideCurrentMonth) {
|
|
189
|
-
return
|
|
189
|
+
return adapter.isSameDay(day, startOfMonth);
|
|
190
190
|
}
|
|
191
|
-
return
|
|
192
|
-
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth,
|
|
191
|
+
return adapter.isSameDay(day, adapter.startOfWeek(startOfMonth));
|
|
192
|
+
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth, adapter]);
|
|
193
193
|
const isLastVisibleCell = React.useMemo(() => {
|
|
194
|
-
const endOfMonth =
|
|
194
|
+
const endOfMonth = adapter.endOfMonth(adapter.setMonth(day, currentMonthNumber));
|
|
195
195
|
if (!showDaysOutsideCurrentMonth) {
|
|
196
|
-
return
|
|
196
|
+
return adapter.isSameDay(day, endOfMonth);
|
|
197
197
|
}
|
|
198
|
-
return
|
|
199
|
-
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth,
|
|
198
|
+
return adapter.isSameDay(day, adapter.endOfWeek(endOfMonth));
|
|
199
|
+
}, [currentMonthNumber, day, showDaysOutsideCurrentMonth, adapter]);
|
|
200
200
|
return /*#__PURE__*/_jsx(Day, _extends({}, dayProps, {
|
|
201
201
|
day: day,
|
|
202
202
|
disabled: isDisabled,
|
|
@@ -220,7 +220,7 @@ export function DayCalendar(inProps) {
|
|
|
220
220
|
props: inProps,
|
|
221
221
|
name: 'MuiDayCalendar'
|
|
222
222
|
});
|
|
223
|
-
const
|
|
223
|
+
const adapter = usePickerAdapter();
|
|
224
224
|
const {
|
|
225
225
|
onFocusedDayChange,
|
|
226
226
|
className,
|
|
@@ -245,7 +245,7 @@ export function DayCalendar(inProps) {
|
|
|
245
245
|
shouldDisableDate,
|
|
246
246
|
shouldDisableMonth,
|
|
247
247
|
shouldDisableYear,
|
|
248
|
-
dayOfWeekFormatter = date =>
|
|
248
|
+
dayOfWeekFormatter = date => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase(),
|
|
249
249
|
hasFocus,
|
|
250
250
|
onFocusedViewChange,
|
|
251
251
|
gridLabelId,
|
|
@@ -282,22 +282,22 @@ export function DayCalendar(inProps) {
|
|
|
282
282
|
const handleKeyDown = useEventCallback((event, day) => {
|
|
283
283
|
switch (event.key) {
|
|
284
284
|
case 'ArrowUp':
|
|
285
|
-
focusDay(
|
|
285
|
+
focusDay(adapter.addDays(day, -7));
|
|
286
286
|
event.preventDefault();
|
|
287
287
|
break;
|
|
288
288
|
case 'ArrowDown':
|
|
289
|
-
focusDay(
|
|
289
|
+
focusDay(adapter.addDays(day, 7));
|
|
290
290
|
event.preventDefault();
|
|
291
291
|
break;
|
|
292
292
|
case 'ArrowLeft':
|
|
293
293
|
{
|
|
294
|
-
const newFocusedDayDefault =
|
|
295
|
-
const nextAvailableMonth =
|
|
294
|
+
const newFocusedDayDefault = adapter.addDays(day, isRtl ? 1 : -1);
|
|
295
|
+
const nextAvailableMonth = adapter.addMonths(day, isRtl ? 1 : -1);
|
|
296
296
|
const closestDayToFocus = findClosestEnabledDate({
|
|
297
|
-
|
|
297
|
+
adapter,
|
|
298
298
|
date: newFocusedDayDefault,
|
|
299
|
-
minDate: isRtl ? newFocusedDayDefault :
|
|
300
|
-
maxDate: isRtl ?
|
|
299
|
+
minDate: isRtl ? newFocusedDayDefault : adapter.startOfMonth(nextAvailableMonth),
|
|
300
|
+
maxDate: isRtl ? adapter.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
301
301
|
isDateDisabled,
|
|
302
302
|
timezone
|
|
303
303
|
});
|
|
@@ -307,13 +307,13 @@ export function DayCalendar(inProps) {
|
|
|
307
307
|
}
|
|
308
308
|
case 'ArrowRight':
|
|
309
309
|
{
|
|
310
|
-
const newFocusedDayDefault =
|
|
311
|
-
const nextAvailableMonth =
|
|
310
|
+
const newFocusedDayDefault = adapter.addDays(day, isRtl ? -1 : 1);
|
|
311
|
+
const nextAvailableMonth = adapter.addMonths(day, isRtl ? -1 : 1);
|
|
312
312
|
const closestDayToFocus = findClosestEnabledDate({
|
|
313
|
-
|
|
313
|
+
adapter,
|
|
314
314
|
date: newFocusedDayDefault,
|
|
315
|
-
minDate: isRtl ?
|
|
316
|
-
maxDate: isRtl ? newFocusedDayDefault :
|
|
315
|
+
minDate: isRtl ? adapter.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
316
|
+
maxDate: isRtl ? newFocusedDayDefault : adapter.endOfMonth(nextAvailableMonth),
|
|
317
317
|
isDateDisabled,
|
|
318
318
|
timezone
|
|
319
319
|
});
|
|
@@ -322,19 +322,19 @@ export function DayCalendar(inProps) {
|
|
|
322
322
|
break;
|
|
323
323
|
}
|
|
324
324
|
case 'Home':
|
|
325
|
-
focusDay(
|
|
325
|
+
focusDay(adapter.startOfWeek(day));
|
|
326
326
|
event.preventDefault();
|
|
327
327
|
break;
|
|
328
328
|
case 'End':
|
|
329
|
-
focusDay(
|
|
329
|
+
focusDay(adapter.endOfWeek(day));
|
|
330
330
|
event.preventDefault();
|
|
331
331
|
break;
|
|
332
332
|
case 'PageUp':
|
|
333
|
-
focusDay(
|
|
333
|
+
focusDay(adapter.addMonths(day, 1));
|
|
334
334
|
event.preventDefault();
|
|
335
335
|
break;
|
|
336
336
|
case 'PageDown':
|
|
337
|
-
focusDay(
|
|
337
|
+
focusDay(adapter.addMonths(day, -1));
|
|
338
338
|
event.preventDefault();
|
|
339
339
|
break;
|
|
340
340
|
default:
|
|
@@ -343,33 +343,33 @@ export function DayCalendar(inProps) {
|
|
|
343
343
|
});
|
|
344
344
|
const handleFocus = useEventCallback((event, day) => focusDay(day));
|
|
345
345
|
const handleBlur = useEventCallback((event, day) => {
|
|
346
|
-
if (focusedDay != null &&
|
|
346
|
+
if (focusedDay != null && adapter.isSameDay(focusedDay, day)) {
|
|
347
347
|
onFocusedViewChange?.(false);
|
|
348
348
|
}
|
|
349
349
|
});
|
|
350
|
-
const currentMonthNumber =
|
|
351
|
-
const currentYearNumber =
|
|
352
|
-
const validSelectedDays = React.useMemo(() => selectedDays.filter(day => !!day).map(day =>
|
|
350
|
+
const currentMonthNumber = adapter.getMonth(currentMonth);
|
|
351
|
+
const currentYearNumber = adapter.getYear(currentMonth);
|
|
352
|
+
const validSelectedDays = React.useMemo(() => selectedDays.filter(day => !!day).map(day => adapter.startOfDay(day)), [adapter, selectedDays]);
|
|
353
353
|
|
|
354
354
|
// need a new ref whenever the `key` of the transition changes: https://reactcommunity.org/react-transition-group/transition/#Transition-prop-nodeRef.
|
|
355
355
|
const transitionKey = `${currentYearNumber}-${currentMonthNumber}`;
|
|
356
356
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
357
357
|
const slideNodeRef = React.useMemo(() => /*#__PURE__*/React.createRef(), [transitionKey]);
|
|
358
358
|
const weeksToDisplay = React.useMemo(() => {
|
|
359
|
-
const toDisplay =
|
|
360
|
-
let nextMonth =
|
|
359
|
+
const toDisplay = adapter.getWeekArray(currentMonth);
|
|
360
|
+
let nextMonth = adapter.addMonths(currentMonth, 1);
|
|
361
361
|
while (fixedWeekNumber && toDisplay.length < fixedWeekNumber) {
|
|
362
|
-
const additionalWeeks =
|
|
363
|
-
const hasCommonWeek =
|
|
362
|
+
const additionalWeeks = adapter.getWeekArray(nextMonth);
|
|
363
|
+
const hasCommonWeek = adapter.isSameDay(toDisplay[toDisplay.length - 1][0], additionalWeeks[0][0]);
|
|
364
364
|
additionalWeeks.slice(hasCommonWeek ? 1 : 0).forEach(week => {
|
|
365
365
|
if (toDisplay.length < fixedWeekNumber) {
|
|
366
366
|
toDisplay.push(week);
|
|
367
367
|
}
|
|
368
368
|
});
|
|
369
|
-
nextMonth =
|
|
369
|
+
nextMonth = adapter.addMonths(nextMonth, 1);
|
|
370
370
|
}
|
|
371
371
|
return toDisplay;
|
|
372
|
-
}, [currentMonth, fixedWeekNumber,
|
|
372
|
+
}, [currentMonth, fixedWeekNumber, adapter]);
|
|
373
373
|
return /*#__PURE__*/_jsxs(PickersCalendarDayRoot, {
|
|
374
374
|
role: "grid",
|
|
375
375
|
"aria-labelledby": gridLabelId,
|
|
@@ -383,10 +383,10 @@ export function DayCalendar(inProps) {
|
|
|
383
383
|
"aria-label": translations.calendarWeekNumberHeaderLabel,
|
|
384
384
|
className: classes.weekNumberLabel,
|
|
385
385
|
children: translations.calendarWeekNumberHeaderText
|
|
386
|
-
}), getWeekdays(
|
|
386
|
+
}), getWeekdays(adapter, now).map((weekday, i) => /*#__PURE__*/_jsx(PickersCalendarWeekDayLabel, {
|
|
387
387
|
variant: "caption",
|
|
388
388
|
role: "columnheader",
|
|
389
|
-
"aria-label":
|
|
389
|
+
"aria-label": adapter.format(weekday, 'weekday'),
|
|
390
390
|
className: classes.weekDayLabel,
|
|
391
391
|
children: dayOfWeekFormatter(weekday)
|
|
392
392
|
}, i.toString()))]
|
|
@@ -415,8 +415,8 @@ export function DayCalendar(inProps) {
|
|
|
415
415
|
children: [displayWeekNumber && /*#__PURE__*/_jsx(PickersCalendarWeekNumber, {
|
|
416
416
|
className: classes.weekNumber,
|
|
417
417
|
role: "rowheader",
|
|
418
|
-
"aria-label": translations.calendarWeekNumberAriaLabelText(
|
|
419
|
-
children: translations.calendarWeekNumberText(
|
|
418
|
+
"aria-label": translations.calendarWeekNumberAriaLabelText(adapter.getWeekNumber(week[0])),
|
|
419
|
+
children: translations.calendarWeekNumberText(adapter.getWeekNumber(week[0]))
|
|
420
420
|
}), week.map((day, dayIndex) => /*#__PURE__*/_jsx(WrappedDay, {
|
|
421
421
|
parentProps: props,
|
|
422
422
|
day: day,
|
|
@@ -4,28 +4,28 @@ 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 { useIsDateDisabled } from "./useIsDateDisabled.js";
|
|
7
|
-
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
8
7
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
8
|
import { SECTION_TYPE_GRANULARITY } from "../internals/utils/getDefaultReferenceDate.js";
|
|
10
9
|
import { findClosestEnabledDate } from "../internals/utils/date-utils.js";
|
|
11
|
-
|
|
10
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
11
|
+
const createCalendarStateReducer = (reduceAnimations, adapter) => (state, action) => {
|
|
12
12
|
switch (action.type) {
|
|
13
13
|
case 'setVisibleDate':
|
|
14
14
|
return _extends({}, state, {
|
|
15
15
|
slideDirection: action.direction,
|
|
16
16
|
currentMonth: action.month,
|
|
17
|
-
isMonthSwitchingAnimating: !
|
|
17
|
+
isMonthSwitchingAnimating: !adapter.isSameMonth(action.month, state.currentMonth) && !reduceAnimations && !action.skipAnimation,
|
|
18
18
|
focusedDay: action.focusedDay
|
|
19
19
|
});
|
|
20
20
|
case 'changeMonthTimezone':
|
|
21
21
|
{
|
|
22
22
|
const newTimezone = action.newTimezone;
|
|
23
|
-
if (
|
|
23
|
+
if (adapter.getTimezone(state.currentMonth) === newTimezone) {
|
|
24
24
|
return state;
|
|
25
25
|
}
|
|
26
|
-
let newCurrentMonth =
|
|
27
|
-
if (
|
|
28
|
-
newCurrentMonth =
|
|
26
|
+
let newCurrentMonth = adapter.setTimezone(state.currentMonth, newTimezone);
|
|
27
|
+
if (adapter.getMonth(newCurrentMonth) !== adapter.getMonth(state.currentMonth)) {
|
|
28
|
+
newCurrentMonth = adapter.setMonth(newCurrentMonth, adapter.getMonth(state.currentMonth));
|
|
29
29
|
}
|
|
30
30
|
return _extends({}, state, {
|
|
31
31
|
currentMonth: newCurrentMonth
|
|
@@ -54,12 +54,12 @@ export const useCalendarState = params => {
|
|
|
54
54
|
timezone,
|
|
55
55
|
getCurrentMonthFromVisibleDate
|
|
56
56
|
} = params;
|
|
57
|
-
const
|
|
58
|
-
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations),
|
|
57
|
+
const adapter = usePickerAdapter();
|
|
58
|
+
const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), adapter)).current;
|
|
59
59
|
const referenceDate = React.useMemo(() => {
|
|
60
60
|
return singleItemValueManager.getInitialReferenceValue({
|
|
61
61
|
value,
|
|
62
|
-
|
|
62
|
+
adapter,
|
|
63
63
|
timezone,
|
|
64
64
|
props: params,
|
|
65
65
|
referenceDate: referenceDateProp,
|
|
@@ -72,7 +72,7 @@ export const useCalendarState = params => {
|
|
|
72
72
|
const [calendarState, dispatch] = React.useReducer(reducerFn, {
|
|
73
73
|
isMonthSwitchingAnimating: false,
|
|
74
74
|
focusedDay: referenceDate,
|
|
75
|
-
currentMonth:
|
|
75
|
+
currentMonth: adapter.startOfMonth(referenceDate),
|
|
76
76
|
slideDirection: 'left'
|
|
77
77
|
});
|
|
78
78
|
const isDateDisabled = useIsDateDisabled({
|
|
@@ -89,14 +89,14 @@ export const useCalendarState = params => {
|
|
|
89
89
|
React.useEffect(() => {
|
|
90
90
|
dispatch({
|
|
91
91
|
type: 'changeMonthTimezone',
|
|
92
|
-
newTimezone:
|
|
92
|
+
newTimezone: adapter.getTimezone(referenceDate)
|
|
93
93
|
});
|
|
94
|
-
}, [referenceDate,
|
|
94
|
+
}, [referenceDate, adapter]);
|
|
95
95
|
const setVisibleDate = useEventCallback(({
|
|
96
96
|
target,
|
|
97
97
|
reason
|
|
98
98
|
}) => {
|
|
99
|
-
if (reason === 'cell-interaction' && calendarState.focusedDay != null &&
|
|
99
|
+
if (reason === 'cell-interaction' && calendarState.focusedDay != null && adapter.isSameDay(target, calendarState.focusedDay)) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
const skipAnimation = reason === 'cell-interaction';
|
|
@@ -106,18 +106,18 @@ export const useCalendarState = params => {
|
|
|
106
106
|
month = getCurrentMonthFromVisibleDate(target, calendarState.currentMonth);
|
|
107
107
|
focusedDay = target;
|
|
108
108
|
} else {
|
|
109
|
-
month =
|
|
109
|
+
month = adapter.isSameMonth(target, calendarState.currentMonth) ? calendarState.currentMonth : adapter.startOfMonth(target);
|
|
110
110
|
focusedDay = target;
|
|
111
111
|
|
|
112
112
|
// If the date is disabled, we try to find a non-disabled date inside the same month.
|
|
113
113
|
if (isDateDisabled(focusedDay)) {
|
|
114
|
-
const startOfMonth =
|
|
115
|
-
const endOfMonth =
|
|
114
|
+
const startOfMonth = adapter.startOfMonth(target);
|
|
115
|
+
const endOfMonth = adapter.endOfMonth(target);
|
|
116
116
|
focusedDay = findClosestEnabledDate({
|
|
117
|
-
|
|
117
|
+
adapter,
|
|
118
118
|
date: focusedDay,
|
|
119
|
-
minDate:
|
|
120
|
-
maxDate:
|
|
119
|
+
minDate: adapter.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
|
|
120
|
+
maxDate: adapter.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
|
|
121
121
|
disablePast,
|
|
122
122
|
disableFuture,
|
|
123
123
|
isDateDisabled,
|
|
@@ -125,19 +125,19 @@ export const useCalendarState = params => {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const hasChangedMonth = !
|
|
129
|
-
const hasChangedYear = !
|
|
128
|
+
const hasChangedMonth = !adapter.isSameMonth(calendarState.currentMonth, month);
|
|
129
|
+
const hasChangedYear = !adapter.isSameYear(calendarState.currentMonth, month);
|
|
130
130
|
if (hasChangedMonth) {
|
|
131
131
|
onMonthChange?.(month);
|
|
132
132
|
}
|
|
133
133
|
if (hasChangedYear) {
|
|
134
|
-
onYearChange?.(
|
|
134
|
+
onYearChange?.(adapter.startOfYear(month));
|
|
135
135
|
}
|
|
136
136
|
dispatch({
|
|
137
137
|
type: 'setVisibleDate',
|
|
138
138
|
month,
|
|
139
|
-
direction:
|
|
140
|
-
focusedDay: calendarState.focusedDay != null && focusedDay != null &&
|
|
139
|
+
direction: adapter.isAfterDay(month, calendarState.currentMonth) ? 'left' : 'right',
|
|
140
|
+
focusedDay: calendarState.focusedDay != null && focusedDay != null && adapter.isSameDay(focusedDay, calendarState.focusedDay) ? calendarState.focusedDay : focusedDay,
|
|
141
141
|
skipAnimation
|
|
142
142
|
});
|
|
143
143
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { validateDate } from "../validation/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
6
6
|
export const useIsDateDisabled = ({
|
|
7
7
|
shouldDisableDate,
|
|
8
8
|
shouldDisableMonth,
|
|
@@ -13,7 +13,7 @@ export const useIsDateDisabled = ({
|
|
|
13
13
|
disablePast,
|
|
14
14
|
timezone
|
|
15
15
|
}) => {
|
|
16
|
-
const adapter =
|
|
16
|
+
const adapter = usePickerAdapter();
|
|
17
17
|
return React.useCallback(day => validateDate({
|
|
18
18
|
adapter,
|
|
19
19
|
value: day,
|
|
@@ -10,12 +10,10 @@ 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 } from "../internals/components/PickersToolbar.js";
|
|
13
|
-
import { usePickerTranslations } from "../hooks/
|
|
14
|
-
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
13
|
+
import { usePickerAdapter, usePickerContext, usePickerTranslations } from "../hooks/index.js";
|
|
15
14
|
import { getDatePickerToolbarUtilityClass } from "./datePickerToolbarClasses.js";
|
|
16
15
|
import { resolveDateFormat } from "../internals/utils/date-utils.js";
|
|
17
16
|
import { useToolbarOwnerState } from "../internals/hooks/useToolbarOwnerState.js";
|
|
18
|
-
import { usePickerContext } from "../hooks/index.js";
|
|
19
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
18
|
const useUtilityClasses = classes => {
|
|
21
19
|
const slots = {
|
|
@@ -63,7 +61,7 @@ export const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePick
|
|
|
63
61
|
classes: classesProp
|
|
64
62
|
} = props,
|
|
65
63
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
66
|
-
const
|
|
64
|
+
const adapter = usePickerAdapter();
|
|
67
65
|
const {
|
|
68
66
|
value,
|
|
69
67
|
views,
|
|
@@ -73,15 +71,15 @@ export const DatePickerToolbar = /*#__PURE__*/React.forwardRef(function DatePick
|
|
|
73
71
|
const ownerState = useToolbarOwnerState();
|
|
74
72
|
const classes = useUtilityClasses(classesProp);
|
|
75
73
|
const dateText = React.useMemo(() => {
|
|
76
|
-
if (!
|
|
74
|
+
if (!adapter.isValid(value)) {
|
|
77
75
|
return toolbarPlaceholder;
|
|
78
76
|
}
|
|
79
|
-
const formatFromViews = resolveDateFormat(
|
|
77
|
+
const formatFromViews = resolveDateFormat(adapter, {
|
|
80
78
|
format: toolbarFormat,
|
|
81
79
|
views
|
|
82
80
|
}, true);
|
|
83
|
-
return
|
|
84
|
-
}, [value, toolbarFormat, toolbarPlaceholder,
|
|
81
|
+
return adapter.formatByString(value, formatFromViews);
|
|
82
|
+
}, [value, toolbarFormat, toolbarPlaceholder, adapter, views]);
|
|
85
83
|
return /*#__PURE__*/_jsx(DatePickerToolbarRoot, _extends({
|
|
86
84
|
ref: ref,
|
|
87
85
|
toolbarTitle: translations.datePickerToolbarTitle,
|
|
@@ -51,7 +51,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
51
51
|
// ----------------------------------------------------------------------
|
|
52
52
|
/**
|
|
53
53
|
* 12h/24h view for hour selection clock.
|
|
54
|
-
* @default
|
|
54
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
55
55
|
*/
|
|
56
56
|
ampm: PropTypes.bool,
|
|
57
57
|
/**
|
|
@@ -53,7 +53,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.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
|
/**
|
|
@@ -12,8 +12,7 @@ import { shouldForwardProp } from '@mui/system/createStyled';
|
|
|
12
12
|
import { PickersToolbarText } from "../internals/components/PickersToolbarText.js";
|
|
13
13
|
import { PickersToolbar } from "../internals/components/PickersToolbar.js";
|
|
14
14
|
import { PickersToolbarButton } from "../internals/components/PickersToolbarButton.js";
|
|
15
|
-
import { usePickerTranslations } from "../hooks/
|
|
16
|
-
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
15
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
17
16
|
import { dateTimePickerToolbarClasses, getDateTimePickerToolbarUtilityClass } from "./dateTimePickerToolbarClasses.js";
|
|
18
17
|
import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
|
|
19
18
|
import { MULTI_SECTION_CLOCK_SECTION_WIDTH } from "../internals/constants/dimensions.js";
|
|
@@ -247,7 +246,7 @@ function DateTimePickerToolbar(inProps) {
|
|
|
247
246
|
const translations = usePickerTranslations();
|
|
248
247
|
const ownerState = useToolbarOwnerState();
|
|
249
248
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
250
|
-
const
|
|
249
|
+
const adapter = usePickerAdapter();
|
|
251
250
|
const overrides = React.useContext(DateTimePickerToolbarOverrideContext);
|
|
252
251
|
const value = overrides ? overrides.value : valueContext;
|
|
253
252
|
const setValue = overrides ? overrides.setValue : setValueContext;
|
|
@@ -264,19 +263,19 @@ function DateTimePickerToolbar(inProps) {
|
|
|
264
263
|
const showAmPmControl = Boolean(ampm && !ampmInClock);
|
|
265
264
|
const toolbarTitle = inToolbarTitle ?? translations.dateTimePickerToolbarTitle;
|
|
266
265
|
const dateText = React.useMemo(() => {
|
|
267
|
-
if (!
|
|
266
|
+
if (!adapter.isValid(value)) {
|
|
268
267
|
return toolbarPlaceholder;
|
|
269
268
|
}
|
|
270
269
|
if (toolbarFormat) {
|
|
271
|
-
return
|
|
270
|
+
return adapter.formatByString(value, toolbarFormat);
|
|
272
271
|
}
|
|
273
|
-
return
|
|
274
|
-
}, [value, toolbarFormat, toolbarPlaceholder,
|
|
272
|
+
return adapter.format(value, 'shortDate');
|
|
273
|
+
}, [value, toolbarFormat, toolbarPlaceholder, adapter]);
|
|
275
274
|
const formatSection = (format, fallback) => {
|
|
276
|
-
if (!
|
|
275
|
+
if (!adapter.isValid(value)) {
|
|
277
276
|
return fallback;
|
|
278
277
|
}
|
|
279
|
-
return
|
|
278
|
+
return adapter.format(value, format);
|
|
280
279
|
};
|
|
281
280
|
return /*#__PURE__*/_jsxs(DateTimePickerToolbarRoot, _extends({
|
|
282
281
|
className: clsx(classes.root, className),
|
|
@@ -351,14 +350,14 @@ function DateTimePickerToolbar(inProps) {
|
|
|
351
350
|
variant: "subtitle2",
|
|
352
351
|
selected: meridiemMode === 'am',
|
|
353
352
|
typographyClassName: classes.ampmLabel,
|
|
354
|
-
value: formatMeridiem(
|
|
353
|
+
value: formatMeridiem(adapter, 'am'),
|
|
355
354
|
onClick: readOnly ? undefined : () => handleMeridiemChange('am'),
|
|
356
355
|
disabled: disabled
|
|
357
356
|
}), /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
358
357
|
variant: "subtitle2",
|
|
359
358
|
selected: meridiemMode === 'pm',
|
|
360
359
|
typographyClassName: classes.ampmLabel,
|
|
361
|
-
value: formatMeridiem(
|
|
360
|
+
value: formatMeridiem(adapter, 'pm'),
|
|
362
361
|
onClick: readOnly ? undefined : () => handleMeridiemChange('pm'),
|
|
363
362
|
disabled: disabled
|
|
364
363
|
})]
|
|
@@ -366,7 +365,7 @@ function DateTimePickerToolbar(inProps) {
|
|
|
366
365
|
variant: "h5",
|
|
367
366
|
onClick: () => setView('meridiem'),
|
|
368
367
|
selected: view === 'meridiem',
|
|
369
|
-
value: value && meridiemMode ? formatMeridiem(
|
|
368
|
+
value: value && meridiemMode ? formatMeridiem(adapter, meridiemMode) : '--',
|
|
370
369
|
width: MULTI_SECTION_CLOCK_SECTION_WIDTH
|
|
371
370
|
})]
|
|
372
371
|
})]
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useThemeProps } from '@mui/material/styles';
|
|
4
|
-
import {
|
|
4
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
5
5
|
import { DateTimePickerTabs } from "./DateTimePickerTabs.js";
|
|
6
6
|
import { DateTimePickerToolbar } from "./DateTimePickerToolbar.js";
|
|
7
7
|
import { applyDefaultViewProps } from "../internals/utils/views.js";
|
|
8
8
|
import { resolveTimeViewsResponse } from "../internals/utils/date-time-utils.js";
|
|
9
9
|
import { useApplyDefaultValuesToDateTimeValidationProps } from "../managers/useDateTimeManager.js";
|
|
10
10
|
export function useDateTimePickerDefaultizedProps(props, name) {
|
|
11
|
-
const
|
|
11
|
+
const adapter = usePickerAdapter();
|
|
12
12
|
const themeProps = useThemeProps({
|
|
13
13
|
props,
|
|
14
14
|
name
|
|
15
15
|
});
|
|
16
16
|
const validationProps = useApplyDefaultValuesToDateTimeValidationProps(themeProps);
|
|
17
|
-
const ampm = themeProps.ampm ??
|
|
17
|
+
const ampm = themeProps.ampm ?? adapter.is12HourCycleInCurrentLocale();
|
|
18
18
|
const localeText = React.useMemo(() => {
|
|
19
19
|
if (themeProps.localeText?.toolbarTitle == null) {
|
|
20
20
|
return themeProps.localeText;
|
|
@@ -7,7 +7,7 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
|
7
7
|
import refType from '@mui/utils/refType';
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { useDatePickerDefaultizedProps } from "../DatePicker/shared.js";
|
|
10
|
-
import {
|
|
10
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
11
11
|
import { validateDate, extractValidationProps } from "../validation/index.js";
|
|
12
12
|
import { useDesktopPicker } from "../internals/hooks/useDesktopPicker/index.js";
|
|
13
13
|
import { DateField } from "../DateField/index.js";
|
|
@@ -24,7 +24,7 @@ import { resolveDateFormat } from "../internals/utils/date-utils.js";
|
|
|
24
24
|
* - [DesktopDatePicker API](https://mui.com/x/api/date-pickers/desktop-date-picker/)
|
|
25
25
|
*/
|
|
26
26
|
const DesktopDatePicker = /*#__PURE__*/React.forwardRef(function DesktopDatePicker(inProps, ref) {
|
|
27
|
-
const
|
|
27
|
+
const adapter = usePickerAdapter();
|
|
28
28
|
|
|
29
29
|
// Props with the default values common to all date pickers
|
|
30
30
|
const defaultizedProps = useDatePickerDefaultizedProps(inProps, 'MuiDesktopDatePicker');
|
|
@@ -38,7 +38,7 @@ const DesktopDatePicker = /*#__PURE__*/React.forwardRef(function DesktopDatePick
|
|
|
38
38
|
const props = _extends({}, defaultizedProps, {
|
|
39
39
|
closeOnSelect: defaultizedProps.closeOnSelect ?? true,
|
|
40
40
|
viewRenderers,
|
|
41
|
-
format: resolveDateFormat(
|
|
41
|
+
format: resolveDateFormat(adapter, defaultizedProps, false),
|
|
42
42
|
yearsPerRow: defaultizedProps.yearsPerRow ?? 4,
|
|
43
43
|
slots: _extends({
|
|
44
44
|
field: DateField
|
|
@@ -12,7 +12,7 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
12
12
|
import { DateTimeField } from "../DateTimeField/index.js";
|
|
13
13
|
import { useDateTimePickerDefaultizedProps } from "../DateTimePicker/shared.js";
|
|
14
14
|
import { renderDateViewCalendar } from "../dateViewRenderers/dateViewRenderers.js";
|
|
15
|
-
import {
|
|
15
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
16
16
|
import { validateDateTime, extractValidationProps } from "../validation/index.js";
|
|
17
17
|
import { useDesktopPicker } from "../internals/hooks/useDesktopPicker/index.js";
|
|
18
18
|
import { resolveDateTimeFormat } from "../internals/utils/date-time-utils.js";
|
|
@@ -90,7 +90,7 @@ if (process.env.NODE_ENV !== "production") rendererInterceptor.displayName = "re
|
|
|
90
90
|
* - [DesktopDateTimePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-picker/)
|
|
91
91
|
*/
|
|
92
92
|
const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimePicker(inProps, ref) {
|
|
93
|
-
const
|
|
93
|
+
const adapter = usePickerAdapter();
|
|
94
94
|
|
|
95
95
|
// Props with the default values common to all date time pickers
|
|
96
96
|
const defaultizedProps = useDateTimePickerDefaultizedProps(inProps, 'MuiDesktopDateTimePicker');
|
|
@@ -112,7 +112,7 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
112
112
|
// Props with the default values specific to the desktop variant
|
|
113
113
|
const props = _extends({}, defaultizedProps, {
|
|
114
114
|
viewRenderers,
|
|
115
|
-
format: resolveDateTimeFormat(
|
|
115
|
+
format: resolveDateTimeFormat(adapter, defaultizedProps),
|
|
116
116
|
views,
|
|
117
117
|
yearsPerRow: defaultizedProps.yearsPerRow ?? 4,
|
|
118
118
|
ampmInClock,
|
|
@@ -152,7 +152,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
152
152
|
// ----------------------------------------------------------------------
|
|
153
153
|
/**
|
|
154
154
|
* 12h/24h view for hour selection clock.
|
|
155
|
-
* @default
|
|
155
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
156
156
|
*/
|
|
157
157
|
ampm: PropTypes.bool,
|
|
158
158
|
/**
|
|
@@ -8,7 +8,7 @@ import refType from '@mui/utils/refType';
|
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { TimeField } from "../TimeField/index.js";
|
|
10
10
|
import { useTimePickerDefaultizedProps } from "../TimePicker/shared.js";
|
|
11
|
-
import {
|
|
11
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
12
12
|
import { extractValidationProps, validateTime } from "../validation/index.js";
|
|
13
13
|
import { useDesktopPicker } from "../internals/hooks/useDesktopPicker/index.js";
|
|
14
14
|
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from "../timeViewRenderers/index.js";
|
|
@@ -25,7 +25,7 @@ import { resolveTimeViewsResponse } from "../internals/utils/date-time-utils.js"
|
|
|
25
25
|
* - [DesktopTimePicker API](https://mui.com/x/api/date-pickers/desktop-time-picker/)
|
|
26
26
|
*/
|
|
27
27
|
const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePicker(inProps, ref) {
|
|
28
|
-
const
|
|
28
|
+
const adapter = usePickerAdapter();
|
|
29
29
|
|
|
30
30
|
// Props with the default values common to all time pickers
|
|
31
31
|
const defaultizedProps = useTimePickerDefaultizedProps(inProps, 'MuiDesktopTimePicker');
|
|
@@ -51,7 +51,7 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
|
|
|
51
51
|
ampmInClock,
|
|
52
52
|
timeSteps,
|
|
53
53
|
viewRenderers,
|
|
54
|
-
format: resolveTimeFormat(
|
|
54
|
+
format: resolveTimeFormat(adapter, defaultizedProps),
|
|
55
55
|
// Setting only `hours` time view in case of single column time picker
|
|
56
56
|
// Allows for easy view lifecycle management
|
|
57
57
|
views: shouldRenderTimeInASingleColumn ? ['hours'] : views,
|
|
@@ -86,7 +86,7 @@ DesktopTimePicker.propTypes = {
|
|
|
86
86
|
// ----------------------------------------------------------------------
|
|
87
87
|
/**
|
|
88
88
|
* 12h/24h view for hour selection clock.
|
|
89
|
-
* @default
|
|
89
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
90
90
|
*/
|
|
91
91
|
ampm: PropTypes.bool,
|
|
92
92
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DigitalClockProps } from "./DigitalClock.types.js";
|
|
3
|
-
export declare const DigitalClockItem: import("@emotion/styled").StyledComponent<import("@mui/material/MenuItem").MenuItemOwnProps & Omit<import("@mui/material/ButtonBase").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "disabled" | "autoFocus" | "dense" | "
|
|
3
|
+
export declare const DigitalClockItem: import("@emotion/styled").StyledComponent<import("@mui/material/MenuItem").MenuItemOwnProps & Omit<import("@mui/material/ButtonBase").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "disabled" | "autoFocus" | "dense" | "style" | "tabIndex" | "className" | "children" | "classes" | "sx" | "disableGutters" | "divider" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
4
4
|
type DigitalClockComponent = ((props: DigitalClockProps & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
5
5
|
propTypes?: any;
|
|
6
6
|
};
|