@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
|
@@ -14,8 +14,8 @@ import MenuItem from '@mui/material/MenuItem';
|
|
|
14
14
|
import MenuList from '@mui/material/MenuList';
|
|
15
15
|
import useForkRef from '@mui/utils/useForkRef';
|
|
16
16
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
17
|
-
import { usePickerTranslations } from "../hooks/
|
|
18
|
-
import {
|
|
17
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
18
|
+
import { useNow } from "../internals/hooks/useUtils.js";
|
|
19
19
|
import { createIsAfterIgnoreDatePart } from "../internals/utils/time-utils.js";
|
|
20
20
|
import { PickerViewRoot } from "../internals/components/PickerViewRoot/index.js";
|
|
21
21
|
import { getDigitalClockUtilityClass } from "./digitalClockClasses.js";
|
|
@@ -100,7 +100,7 @@ export const DigitalClockItem = styled(MenuItem, {
|
|
|
100
100
|
* - [DigitalClock API](https://mui.com/x/api/date-pickers/digital-clock/)
|
|
101
101
|
*/
|
|
102
102
|
export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(inProps, ref) {
|
|
103
|
-
const
|
|
103
|
+
const adapter = usePickerAdapter();
|
|
104
104
|
const containerRef = React.useRef(null);
|
|
105
105
|
const handleRef = useForkRef(ref, containerRef);
|
|
106
106
|
const listRef = React.useRef(null);
|
|
@@ -109,7 +109,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
109
109
|
name: 'MuiDigitalClock'
|
|
110
110
|
});
|
|
111
111
|
const {
|
|
112
|
-
ampm =
|
|
112
|
+
ampm = adapter.is12HourCycleInCurrentLocale(),
|
|
113
113
|
timeStep = 30,
|
|
114
114
|
autoFocus,
|
|
115
115
|
slots,
|
|
@@ -171,7 +171,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
171
171
|
const valueOrReferenceDate = useClockReferenceDate({
|
|
172
172
|
value,
|
|
173
173
|
referenceDate: referenceDateProp,
|
|
174
|
-
|
|
174
|
+
adapter,
|
|
175
175
|
props,
|
|
176
176
|
timezone
|
|
177
177
|
});
|
|
@@ -207,7 +207,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
207
207
|
containerRef.current.scrollTop = offsetTop - 4;
|
|
208
208
|
});
|
|
209
209
|
const isTimeDisabled = React.useCallback(valueToCheck => {
|
|
210
|
-
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation,
|
|
210
|
+
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter);
|
|
211
211
|
const containsValidTime = () => {
|
|
212
212
|
if (minTime && isAfter(minTime, valueToCheck)) {
|
|
213
213
|
return false;
|
|
@@ -224,7 +224,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
224
224
|
return true;
|
|
225
225
|
};
|
|
226
226
|
const isValidValue = () => {
|
|
227
|
-
if (
|
|
227
|
+
if (adapter.getMinutes(valueToCheck) % minutesStep !== 0) {
|
|
228
228
|
return false;
|
|
229
229
|
}
|
|
230
230
|
if (shouldDisableTime) {
|
|
@@ -233,18 +233,18 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
233
233
|
return true;
|
|
234
234
|
};
|
|
235
235
|
return !containsValidTime() || !isValidValue();
|
|
236
|
-
}, [disableIgnoringDatePartForTimeValidation,
|
|
236
|
+
}, [disableIgnoringDatePartForTimeValidation, adapter, minTime, maxTime, disableFuture, now, disablePast, minutesStep, shouldDisableTime]);
|
|
237
237
|
const timeOptions = React.useMemo(() => {
|
|
238
238
|
const result = [];
|
|
239
|
-
const startOfDay =
|
|
239
|
+
const startOfDay = adapter.startOfDay(valueOrReferenceDate);
|
|
240
240
|
let nextTimeStepOption = startOfDay;
|
|
241
|
-
while (
|
|
241
|
+
while (adapter.isSameDay(valueOrReferenceDate, nextTimeStepOption)) {
|
|
242
242
|
result.push(nextTimeStepOption);
|
|
243
|
-
nextTimeStepOption =
|
|
243
|
+
nextTimeStepOption = adapter.addMinutes(nextTimeStepOption, timeStep);
|
|
244
244
|
}
|
|
245
245
|
return result;
|
|
246
|
-
}, [valueOrReferenceDate, timeStep,
|
|
247
|
-
const focusedOptionIndex = timeOptions.findIndex(option =>
|
|
246
|
+
}, [valueOrReferenceDate, timeStep, adapter]);
|
|
247
|
+
const focusedOptionIndex = timeOptions.findIndex(option => adapter.isEqual(option, valueOrReferenceDate));
|
|
248
248
|
const handleKeyDown = event => {
|
|
249
249
|
switch (event.key) {
|
|
250
250
|
case 'PageUp':
|
|
@@ -290,8 +290,8 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
290
290
|
if (skipDisabled && optionDisabled) {
|
|
291
291
|
return null;
|
|
292
292
|
}
|
|
293
|
-
const isSelected =
|
|
294
|
-
const formattedValue =
|
|
293
|
+
const isSelected = adapter.isEqual(option, value);
|
|
294
|
+
const formattedValue = adapter.format(option, ampm ? 'fullTime12h' : 'fullTime24h');
|
|
295
295
|
const isFocused = focusedOptionIndex === index || focusedOptionIndex === -1 && index === 0;
|
|
296
296
|
const tabIndex = isFocused ? 0 : -1;
|
|
297
297
|
return /*#__PURE__*/_jsx(ClockItem, _extends({
|
|
@@ -322,7 +322,7 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
322
322
|
// ----------------------------------------------------------------------
|
|
323
323
|
/**
|
|
324
324
|
* 12h/24h view for hour selection clock.
|
|
325
|
-
* @default
|
|
325
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
326
326
|
*/
|
|
327
327
|
ampm: PropTypes.bool,
|
|
328
328
|
/**
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AdapterFormats, MuiPickersAdapter, PickerValidDate } from "../models/index.js";
|
|
3
3
|
import { PickersInputLocaleText } from "../locales/index.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface PickersAdapterContextValue {
|
|
5
5
|
defaultDates: {
|
|
6
6
|
minDate: PickerValidDate;
|
|
7
7
|
maxDate: PickerValidDate;
|
|
8
8
|
};
|
|
9
9
|
utils: MuiPickersAdapter;
|
|
10
|
+
adapter: MuiPickersAdapter;
|
|
10
11
|
localeText: PickersInputLocaleText | undefined;
|
|
11
12
|
}
|
|
12
|
-
export type
|
|
13
|
-
export declare const
|
|
13
|
+
export type PickerAdapterContextNullableValue = { [K in keyof PickersAdapterContextValue]: PickersAdapterContextValue[K] | null };
|
|
14
|
+
export declare const PickerAdapterContext: React.Context<PickerAdapterContextNullableValue | null>;
|
|
15
|
+
/**
|
|
16
|
+
* The context that provides the date adapter and default dates to the pickers.
|
|
17
|
+
* @deprecated Use `usePickersAdapter` hook if you need access to the adapter instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MuiPickersAdapterContext: React.Context<PickerAdapterContextNullableValue | null>;
|
|
14
20
|
export interface LocalizationProviderProps<TLocale> {
|
|
15
21
|
children?: React.ReactNode;
|
|
16
22
|
/**
|
|
@@ -7,8 +7,15 @@ import * as React from 'react';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useThemeProps } from '@mui/material/styles';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
export const
|
|
11
|
-
|
|
10
|
+
export const PickerAdapterContext = /*#__PURE__*/React.createContext(null);
|
|
11
|
+
|
|
12
|
+
// TODO v9: Remove this public export
|
|
13
|
+
/**
|
|
14
|
+
* The context that provides the date adapter and default dates to the pickers.
|
|
15
|
+
* @deprecated Use `usePickersAdapter` hook if you need access to the adapter instead.
|
|
16
|
+
*/
|
|
17
|
+
if (process.env.NODE_ENV !== "production") PickerAdapterContext.displayName = "PickerAdapterContext";
|
|
18
|
+
export const MuiPickersAdapterContext = PickerAdapterContext;
|
|
12
19
|
/**
|
|
13
20
|
* Demos:
|
|
14
21
|
*
|
|
@@ -27,10 +34,11 @@ export const LocalizationProvider = function LocalizationProvider(inProps) {
|
|
|
27
34
|
} = inProps,
|
|
28
35
|
otherInProps = _objectWithoutPropertiesLoose(inProps, _excluded);
|
|
29
36
|
const {
|
|
30
|
-
|
|
37
|
+
adapter: parentAdapter,
|
|
31
38
|
localeText: parentLocaleText
|
|
32
|
-
} = React.useContext(
|
|
39
|
+
} = React.useContext(PickerAdapterContext) ?? {
|
|
33
40
|
utils: undefined,
|
|
41
|
+
adapter: undefined,
|
|
34
42
|
localeText: undefined
|
|
35
43
|
};
|
|
36
44
|
const props = useThemeProps({
|
|
@@ -48,40 +56,41 @@ export const LocalizationProvider = function LocalizationProvider(inProps) {
|
|
|
48
56
|
localeText: themeLocaleText
|
|
49
57
|
} = props;
|
|
50
58
|
const localeText = React.useMemo(() => _extends({}, themeLocaleText, parentLocaleText, inLocaleText), [themeLocaleText, parentLocaleText, inLocaleText]);
|
|
51
|
-
const
|
|
59
|
+
const adapter = React.useMemo(() => {
|
|
52
60
|
if (!DateAdapter) {
|
|
53
|
-
if (
|
|
54
|
-
return
|
|
61
|
+
if (parentAdapter) {
|
|
62
|
+
return parentAdapter;
|
|
55
63
|
}
|
|
56
64
|
return null;
|
|
57
65
|
}
|
|
58
|
-
const
|
|
66
|
+
const dateAdapter = new DateAdapter({
|
|
59
67
|
locale: adapterLocale,
|
|
60
68
|
formats: dateFormats,
|
|
61
69
|
instance: dateLibInstance
|
|
62
70
|
});
|
|
63
|
-
if (!
|
|
71
|
+
if (!dateAdapter.isMUIAdapter) {
|
|
64
72
|
throw new Error(['MUI X: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`', "For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`", 'More information on the installation documentation: https://mui.com/x/react-date-pickers/quickstart/#installation'].join(`\n`));
|
|
65
73
|
}
|
|
66
|
-
return
|
|
67
|
-
}, [DateAdapter, adapterLocale, dateFormats, dateLibInstance,
|
|
74
|
+
return dateAdapter;
|
|
75
|
+
}, [DateAdapter, adapterLocale, dateFormats, dateLibInstance, parentAdapter]);
|
|
68
76
|
const defaultDates = React.useMemo(() => {
|
|
69
|
-
if (!
|
|
77
|
+
if (!adapter) {
|
|
70
78
|
return null;
|
|
71
79
|
}
|
|
72
80
|
return {
|
|
73
|
-
minDate:
|
|
74
|
-
maxDate:
|
|
81
|
+
minDate: adapter.date('1900-01-01T00:00:00.000'),
|
|
82
|
+
maxDate: adapter.date('2099-12-31T00:00:00.000')
|
|
75
83
|
};
|
|
76
|
-
}, [
|
|
84
|
+
}, [adapter]);
|
|
77
85
|
const contextValue = React.useMemo(() => {
|
|
78
86
|
return {
|
|
79
|
-
utils,
|
|
87
|
+
utils: adapter,
|
|
88
|
+
adapter,
|
|
80
89
|
defaultDates,
|
|
81
90
|
localeText
|
|
82
91
|
};
|
|
83
|
-
}, [defaultDates,
|
|
84
|
-
return /*#__PURE__*/_jsx(
|
|
92
|
+
}, [defaultDates, adapter, localeText]);
|
|
93
|
+
return /*#__PURE__*/_jsx(PickerAdapterContext.Provider, {
|
|
85
94
|
value: contextValue,
|
|
86
95
|
children: children
|
|
87
96
|
});
|
|
@@ -7,7 +7,7 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
|
7
7
|
import refType from '@mui/utils/refType';
|
|
8
8
|
import { useMobilePicker } from "../internals/hooks/useMobilePicker/index.js";
|
|
9
9
|
import { useDatePickerDefaultizedProps } from "../DatePicker/shared.js";
|
|
10
|
-
import {
|
|
10
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
11
11
|
import { extractValidationProps, validateDate } from "../validation/index.js";
|
|
12
12
|
import { DateField } from "../DateField/index.js";
|
|
13
13
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
@@ -24,7 +24,7 @@ import { resolveDateFormat } from "../internals/utils/date-utils.js";
|
|
|
24
24
|
* - [MobileDatePicker API](https://mui.com/x/api/date-pickers/mobile-date-picker/)
|
|
25
25
|
*/
|
|
26
26
|
const MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker(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, 'MuiMobileDatePicker');
|
|
@@ -37,7 +37,7 @@ const MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker
|
|
|
37
37
|
// Props with the default values specific to the mobile variant
|
|
38
38
|
const props = _extends({}, defaultizedProps, {
|
|
39
39
|
viewRenderers,
|
|
40
|
-
format: resolveDateFormat(
|
|
40
|
+
format: resolveDateFormat(adapter, defaultizedProps, false),
|
|
41
41
|
slots: _extends({
|
|
42
42
|
field: DateField
|
|
43
43
|
}, defaultizedProps.slots),
|
|
@@ -8,7 +8,7 @@ import refType from '@mui/utils/refType';
|
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { DateTimeField } from "../DateTimeField/index.js";
|
|
10
10
|
import { useDateTimePickerDefaultizedProps } from "../DateTimePicker/shared.js";
|
|
11
|
-
import {
|
|
11
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
12
12
|
import { extractValidationProps, validateDateTime } from "../validation/index.js";
|
|
13
13
|
import { useMobilePicker } from "../internals/hooks/useMobilePicker/index.js";
|
|
14
14
|
import { renderDateViewCalendar } from "../dateViewRenderers/index.js";
|
|
@@ -36,7 +36,7 @@ const STEPS = [{
|
|
|
36
36
|
* - [MobileDateTimePicker API](https://mui.com/x/api/date-pickers/mobile-date-time-picker/)
|
|
37
37
|
*/
|
|
38
38
|
const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTimePicker(inProps, ref) {
|
|
39
|
-
const
|
|
39
|
+
const adapter = usePickerAdapter();
|
|
40
40
|
|
|
41
41
|
// Props with the default values common to all date time pickers
|
|
42
42
|
const defaultizedProps = useDateTimePickerDefaultizedProps(inProps, 'MuiMobileDateTimePicker');
|
|
@@ -58,7 +58,7 @@ const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTi
|
|
|
58
58
|
// Props with the default values specific to the mobile variant
|
|
59
59
|
const props = _extends({}, defaultizedProps, {
|
|
60
60
|
viewRenderers,
|
|
61
|
-
format: resolveDateTimeFormat(
|
|
61
|
+
format: resolveDateTimeFormat(adapter, defaultizedProps),
|
|
62
62
|
views,
|
|
63
63
|
ampmInClock,
|
|
64
64
|
slots: _extends({
|
|
@@ -118,7 +118,7 @@ MobileDateTimePicker.propTypes = {
|
|
|
118
118
|
// ----------------------------------------------------------------------
|
|
119
119
|
/**
|
|
120
120
|
* 12h/24h view for hour selection clock.
|
|
121
|
-
* @default
|
|
121
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
122
122
|
*/
|
|
123
123
|
ampm: PropTypes.bool,
|
|
124
124
|
/**
|
|
@@ -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 { useMobilePicker } from "../internals/hooks/useMobilePicker/index.js";
|
|
14
14
|
import { renderTimeViewClock } from "../timeViewRenderers/index.js";
|
|
@@ -24,7 +24,7 @@ import { resolveTimeFormat } from "../internals/utils/time-utils.js";
|
|
|
24
24
|
* - [MobileTimePicker API](https://mui.com/x/api/date-pickers/mobile-time-picker/)
|
|
25
25
|
*/
|
|
26
26
|
const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker(inProps, ref) {
|
|
27
|
-
const
|
|
27
|
+
const adapter = usePickerAdapter();
|
|
28
28
|
|
|
29
29
|
// Props with the default values common to all time pickers
|
|
30
30
|
const defaultizedProps = useTimePickerDefaultizedProps(inProps, 'MuiMobileTimePicker');
|
|
@@ -39,7 +39,7 @@ const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker
|
|
|
39
39
|
const props = _extends({}, defaultizedProps, {
|
|
40
40
|
ampmInClock,
|
|
41
41
|
viewRenderers,
|
|
42
|
-
format: resolveTimeFormat(
|
|
42
|
+
format: resolveTimeFormat(adapter, defaultizedProps),
|
|
43
43
|
slots: _extends({
|
|
44
44
|
field: TimeField
|
|
45
45
|
}, defaultizedProps.slots),
|
|
@@ -71,7 +71,7 @@ MobileTimePicker.propTypes = {
|
|
|
71
71
|
// ----------------------------------------------------------------------
|
|
72
72
|
/**
|
|
73
73
|
* 12h/24h view for hour selection clock.
|
|
74
|
-
* @default
|
|
74
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
75
75
|
*/
|
|
76
76
|
ampm: PropTypes.bool,
|
|
77
77
|
/**
|
|
@@ -13,7 +13,7 @@ import useControlled from '@mui/utils/useControlled';
|
|
|
13
13
|
import composeClasses from '@mui/utils/composeClasses';
|
|
14
14
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
15
15
|
import { MonthCalendarButton } from "./MonthCalendarButton.js";
|
|
16
|
-
import {
|
|
16
|
+
import { useNow } from "../internals/hooks/useUtils.js";
|
|
17
17
|
import { getMonthCalendarUtilityClass } from "./monthCalendarClasses.js";
|
|
18
18
|
import { getMonthsInYear } from "../internals/utils/date-utils.js";
|
|
19
19
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
@@ -22,6 +22,7 @@ import { useControlledValue } from "../internals/hooks/useControlledValue.js";
|
|
|
22
22
|
import { DIALOG_WIDTH } from "../internals/constants/dimensions.js";
|
|
23
23
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
24
24
|
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
25
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
27
|
const useUtilityClasses = classes => {
|
|
27
28
|
const slots = {
|
|
@@ -119,13 +120,13 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
119
120
|
});
|
|
120
121
|
const now = useNow(timezone);
|
|
121
122
|
const isRtl = useRtl();
|
|
122
|
-
const
|
|
123
|
+
const adapter = usePickerAdapter();
|
|
123
124
|
const {
|
|
124
125
|
ownerState
|
|
125
126
|
} = usePickerPrivateContext();
|
|
126
127
|
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
127
128
|
value,
|
|
128
|
-
|
|
129
|
+
adapter,
|
|
129
130
|
props,
|
|
130
131
|
timezone,
|
|
131
132
|
referenceDate: referenceDateProp,
|
|
@@ -133,14 +134,14 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
133
134
|
}), [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
134
135
|
);
|
|
135
136
|
const classes = useUtilityClasses(classesProp);
|
|
136
|
-
const todayMonth = React.useMemo(() =>
|
|
137
|
+
const todayMonth = React.useMemo(() => adapter.getMonth(now), [adapter, now]);
|
|
137
138
|
const selectedMonth = React.useMemo(() => {
|
|
138
139
|
if (value != null) {
|
|
139
|
-
return
|
|
140
|
+
return adapter.getMonth(value);
|
|
140
141
|
}
|
|
141
142
|
return null;
|
|
142
|
-
}, [value,
|
|
143
|
-
const [focusedMonth, setFocusedMonth] = React.useState(() => selectedMonth ||
|
|
143
|
+
}, [value, adapter]);
|
|
144
|
+
const [focusedMonth, setFocusedMonth] = React.useState(() => selectedMonth || adapter.getMonth(referenceDate));
|
|
144
145
|
const [internalHasFocus, setInternalHasFocus] = useControlled({
|
|
145
146
|
name: 'MonthCalendar',
|
|
146
147
|
state: 'hasFocus',
|
|
@@ -154,29 +155,29 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
154
155
|
}
|
|
155
156
|
});
|
|
156
157
|
const isMonthDisabled = React.useCallback(dateToValidate => {
|
|
157
|
-
const firstEnabledMonth =
|
|
158
|
-
const lastEnabledMonth =
|
|
159
|
-
const monthToValidate =
|
|
160
|
-
if (
|
|
158
|
+
const firstEnabledMonth = adapter.startOfMonth(disablePast && adapter.isAfter(now, minDate) ? now : minDate);
|
|
159
|
+
const lastEnabledMonth = adapter.startOfMonth(disableFuture && adapter.isBefore(now, maxDate) ? now : maxDate);
|
|
160
|
+
const monthToValidate = adapter.startOfMonth(dateToValidate);
|
|
161
|
+
if (adapter.isBefore(monthToValidate, firstEnabledMonth)) {
|
|
161
162
|
return true;
|
|
162
163
|
}
|
|
163
|
-
if (
|
|
164
|
+
if (adapter.isAfter(monthToValidate, lastEnabledMonth)) {
|
|
164
165
|
return true;
|
|
165
166
|
}
|
|
166
167
|
if (!shouldDisableMonth) {
|
|
167
168
|
return false;
|
|
168
169
|
}
|
|
169
170
|
return shouldDisableMonth(monthToValidate);
|
|
170
|
-
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableMonth,
|
|
171
|
+
}, [disableFuture, disablePast, maxDate, minDate, now, shouldDisableMonth, adapter]);
|
|
171
172
|
const handleMonthSelection = useEventCallback((event, month) => {
|
|
172
173
|
if (readOnly) {
|
|
173
174
|
return;
|
|
174
175
|
}
|
|
175
|
-
const newDate =
|
|
176
|
+
const newDate = adapter.setMonth(value ?? referenceDate, month);
|
|
176
177
|
handleValueChange(newDate);
|
|
177
178
|
});
|
|
178
179
|
const focusMonth = useEventCallback(month => {
|
|
179
|
-
if (!isMonthDisabled(
|
|
180
|
+
if (!isMonthDisabled(adapter.setMonth(value ?? referenceDate, month))) {
|
|
180
181
|
setFocusedMonth(month);
|
|
181
182
|
changeHasFocus(true);
|
|
182
183
|
if (onMonthFocus) {
|
|
@@ -227,10 +228,10 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
227
228
|
"aria-labelledby": gridLabelId,
|
|
228
229
|
monthsPerRow: monthsPerRow
|
|
229
230
|
}, other, {
|
|
230
|
-
children: getMonthsInYear(
|
|
231
|
-
const monthNumber =
|
|
232
|
-
const monthText =
|
|
233
|
-
const monthLabel =
|
|
231
|
+
children: getMonthsInYear(adapter, value ?? referenceDate).map(month => {
|
|
232
|
+
const monthNumber = adapter.getMonth(month);
|
|
233
|
+
const monthText = adapter.format(month, 'monthShort');
|
|
234
|
+
const monthLabel = adapter.format(month, 'month');
|
|
234
235
|
const isSelected = monthNumber === selectedMonth;
|
|
235
236
|
const isDisabled = disabled || isMonthDisabled(month);
|
|
236
237
|
return /*#__PURE__*/_jsx(MonthCalendarButton, {
|
|
@@ -10,8 +10,8 @@ import { useRtl } from '@mui/system/RtlProvider';
|
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
12
12
|
import composeClasses from '@mui/utils/composeClasses';
|
|
13
|
-
import { usePickerTranslations } from "../hooks/
|
|
14
|
-
import {
|
|
13
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
14
|
+
import { useNow } from "../internals/hooks/useUtils.js";
|
|
15
15
|
import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from "../internals/utils/time-utils.js";
|
|
16
16
|
import { useViews } from "../internals/hooks/useViews.js";
|
|
17
17
|
import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
|
|
@@ -52,14 +52,14 @@ const MultiSectionDigitalClockRoot = styled(PickerViewRoot, {
|
|
|
52
52
|
* - [MultiSectionDigitalClock API](https://mui.com/x/api/date-pickers/multi-section-digital-clock/)
|
|
53
53
|
*/
|
|
54
54
|
export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function MultiSectionDigitalClock(inProps, ref) {
|
|
55
|
-
const
|
|
55
|
+
const adapter = usePickerAdapter();
|
|
56
56
|
const isRtl = useRtl();
|
|
57
57
|
const props = useThemeProps({
|
|
58
58
|
props: inProps,
|
|
59
59
|
name: 'MuiMultiSectionDigitalClock'
|
|
60
60
|
});
|
|
61
61
|
const {
|
|
62
|
-
ampm =
|
|
62
|
+
ampm = adapter.is12HourCycleInCurrentLocale(),
|
|
63
63
|
timeSteps: inTimeSteps,
|
|
64
64
|
autoFocus,
|
|
65
65
|
slots,
|
|
@@ -112,7 +112,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
112
112
|
const valueOrReferenceDate = useClockReferenceDate({
|
|
113
113
|
value,
|
|
114
114
|
referenceDate: referenceDateProp,
|
|
115
|
-
|
|
115
|
+
adapter,
|
|
116
116
|
props,
|
|
117
117
|
timezone
|
|
118
118
|
});
|
|
@@ -144,7 +144,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
144
144
|
handleMeridiemChange
|
|
145
145
|
} = useMeridiemMode(valueOrReferenceDate, ampm, handleMeridiemValueChange, 'finish');
|
|
146
146
|
const isTimeDisabled = React.useCallback((rawValue, viewType) => {
|
|
147
|
-
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation,
|
|
147
|
+
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter);
|
|
148
148
|
const shouldCheckPastEnd = viewType === 'hours' || viewType === 'minutes' && views.includes('seconds');
|
|
149
149
|
const containsValidTime = ({
|
|
150
150
|
start,
|
|
@@ -171,11 +171,11 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
171
171
|
if (shouldDisableTime) {
|
|
172
172
|
switch (viewType) {
|
|
173
173
|
case 'hours':
|
|
174
|
-
return !shouldDisableTime(
|
|
174
|
+
return !shouldDisableTime(adapter.setHours(valueOrReferenceDate, timeValue), 'hours');
|
|
175
175
|
case 'minutes':
|
|
176
|
-
return !shouldDisableTime(
|
|
176
|
+
return !shouldDisableTime(adapter.setMinutes(valueOrReferenceDate, timeValue), 'minutes');
|
|
177
177
|
case 'seconds':
|
|
178
|
-
return !shouldDisableTime(
|
|
178
|
+
return !shouldDisableTime(adapter.setSeconds(valueOrReferenceDate, timeValue), 'seconds');
|
|
179
179
|
default:
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
@@ -186,12 +186,12 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
186
186
|
case 'hours':
|
|
187
187
|
{
|
|
188
188
|
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
|
|
189
|
-
const dateWithNewHours =
|
|
190
|
-
if (
|
|
189
|
+
const dateWithNewHours = adapter.setHours(valueOrReferenceDate, valueWithMeridiem);
|
|
190
|
+
if (adapter.getHours(dateWithNewHours) !== valueWithMeridiem) {
|
|
191
191
|
return true;
|
|
192
192
|
}
|
|
193
|
-
const start =
|
|
194
|
-
const end =
|
|
193
|
+
const start = adapter.setSeconds(adapter.setMinutes(dateWithNewHours, 0), 0);
|
|
194
|
+
const end = adapter.setSeconds(adapter.setMinutes(dateWithNewHours, 59), 59);
|
|
195
195
|
return !containsValidTime({
|
|
196
196
|
start,
|
|
197
197
|
end
|
|
@@ -199,9 +199,9 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
199
199
|
}
|
|
200
200
|
case 'minutes':
|
|
201
201
|
{
|
|
202
|
-
const dateWithNewMinutes =
|
|
203
|
-
const start =
|
|
204
|
-
const end =
|
|
202
|
+
const dateWithNewMinutes = adapter.setMinutes(valueOrReferenceDate, rawValue);
|
|
203
|
+
const start = adapter.setSeconds(dateWithNewMinutes, 0);
|
|
204
|
+
const end = adapter.setSeconds(dateWithNewMinutes, 59);
|
|
205
205
|
return !containsValidTime({
|
|
206
206
|
start,
|
|
207
207
|
end
|
|
@@ -209,7 +209,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
209
209
|
}
|
|
210
210
|
case 'seconds':
|
|
211
211
|
{
|
|
212
|
-
const dateWithNewSeconds =
|
|
212
|
+
const dateWithNewSeconds = adapter.setSeconds(valueOrReferenceDate, rawValue);
|
|
213
213
|
const start = dateWithNewSeconds;
|
|
214
214
|
const end = dateWithNewSeconds;
|
|
215
215
|
return !containsValidTime({
|
|
@@ -220,7 +220,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
220
220
|
default:
|
|
221
221
|
throw new Error('not supported');
|
|
222
222
|
}
|
|
223
|
-
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime,
|
|
223
|
+
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, adapter, disableFuture, disablePast, now, views]);
|
|
224
224
|
const buildViewProps = React.useCallback(viewToBuild => {
|
|
225
225
|
switch (viewToBuild) {
|
|
226
226
|
case 'hours':
|
|
@@ -228,13 +228,13 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
228
228
|
return {
|
|
229
229
|
onChange: hours => {
|
|
230
230
|
const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
|
|
231
|
-
setValueAndGoToNextView(
|
|
231
|
+
setValueAndGoToNextView(adapter.setHours(valueOrReferenceDate, valueWithMeridiem), 'finish', 'hours');
|
|
232
232
|
},
|
|
233
233
|
items: getHourSectionOptions({
|
|
234
234
|
now,
|
|
235
235
|
value,
|
|
236
236
|
ampm,
|
|
237
|
-
|
|
237
|
+
adapter,
|
|
238
238
|
isDisabled: hours => isTimeDisabled(hours, 'hours'),
|
|
239
239
|
timeStep: timeSteps.hours,
|
|
240
240
|
resolveAriaLabel: translations.hoursClockNumberText,
|
|
@@ -246,13 +246,13 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
246
246
|
{
|
|
247
247
|
return {
|
|
248
248
|
onChange: minutes => {
|
|
249
|
-
setValueAndGoToNextView(
|
|
249
|
+
setValueAndGoToNextView(adapter.setMinutes(valueOrReferenceDate, minutes), 'finish', 'minutes');
|
|
250
250
|
},
|
|
251
251
|
items: getTimeSectionOptions({
|
|
252
|
-
value:
|
|
253
|
-
|
|
252
|
+
value: adapter.getMinutes(valueOrReferenceDate),
|
|
253
|
+
adapter,
|
|
254
254
|
isDisabled: minutes => isTimeDisabled(minutes, 'minutes'),
|
|
255
|
-
resolveLabel: minutes =>
|
|
255
|
+
resolveLabel: minutes => adapter.format(adapter.setMinutes(now, minutes), 'minutes'),
|
|
256
256
|
timeStep: timeSteps.minutes,
|
|
257
257
|
hasValue: !!value,
|
|
258
258
|
resolveAriaLabel: translations.minutesClockNumberText
|
|
@@ -263,13 +263,13 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
263
263
|
{
|
|
264
264
|
return {
|
|
265
265
|
onChange: seconds => {
|
|
266
|
-
setValueAndGoToNextView(
|
|
266
|
+
setValueAndGoToNextView(adapter.setSeconds(valueOrReferenceDate, seconds), 'finish', 'seconds');
|
|
267
267
|
},
|
|
268
268
|
items: getTimeSectionOptions({
|
|
269
|
-
value:
|
|
270
|
-
|
|
269
|
+
value: adapter.getSeconds(valueOrReferenceDate),
|
|
270
|
+
adapter,
|
|
271
271
|
isDisabled: seconds => isTimeDisabled(seconds, 'seconds'),
|
|
272
|
-
resolveLabel: seconds =>
|
|
272
|
+
resolveLabel: seconds => adapter.format(adapter.setSeconds(now, seconds), 'seconds'),
|
|
273
273
|
timeStep: timeSteps.seconds,
|
|
274
274
|
hasValue: !!value,
|
|
275
275
|
resolveAriaLabel: translations.secondsClockNumberText
|
|
@@ -278,8 +278,8 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
278
278
|
}
|
|
279
279
|
case 'meridiem':
|
|
280
280
|
{
|
|
281
|
-
const amLabel = formatMeridiem(
|
|
282
|
-
const pmLabel = formatMeridiem(
|
|
281
|
+
const amLabel = formatMeridiem(adapter, 'am');
|
|
282
|
+
const pmLabel = formatMeridiem(adapter, 'pm');
|
|
283
283
|
return {
|
|
284
284
|
onChange: handleMeridiemChange,
|
|
285
285
|
items: [{
|
|
@@ -300,7 +300,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
300
300
|
default:
|
|
301
301
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
302
302
|
}
|
|
303
|
-
}, [now, value, ampm,
|
|
303
|
+
}, [now, value, ampm, adapter, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, handleMeridiemChange]);
|
|
304
304
|
const viewsToRender = React.useMemo(() => {
|
|
305
305
|
if (!isRtl) {
|
|
306
306
|
return views;
|
|
@@ -351,7 +351,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
351
351
|
// ----------------------------------------------------------------------
|
|
352
352
|
/**
|
|
353
353
|
* 12h/24h view for hour selection clock.
|
|
354
|
-
* @default
|
|
354
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
355
355
|
*/
|
|
356
356
|
ampm: PropTypes.bool,
|
|
357
357
|
/**
|
|
@@ -3,7 +3,7 @@ import { MultiSectionDigitalClockOption } from "./MultiSectionDigitalClock.types
|
|
|
3
3
|
interface GetHoursSectionOptionsParameters {
|
|
4
4
|
now: PickerValidDate;
|
|
5
5
|
value: PickerValidDate | null;
|
|
6
|
-
|
|
6
|
+
adapter: MuiPickersAdapter;
|
|
7
7
|
ampm: boolean;
|
|
8
8
|
isDisabled: (value: number) => boolean;
|
|
9
9
|
timeStep: number;
|
|
@@ -13,7 +13,7 @@ interface GetHoursSectionOptionsParameters {
|
|
|
13
13
|
export declare const getHourSectionOptions: ({
|
|
14
14
|
now,
|
|
15
15
|
value,
|
|
16
|
-
|
|
16
|
+
adapter,
|
|
17
17
|
ampm,
|
|
18
18
|
isDisabled,
|
|
19
19
|
resolveAriaLabel,
|
|
@@ -22,7 +22,7 @@ export declare const getHourSectionOptions: ({
|
|
|
22
22
|
}: GetHoursSectionOptionsParameters) => MultiSectionDigitalClockOption<number>[];
|
|
23
23
|
interface GetTimeSectionOptionsParameters {
|
|
24
24
|
value: number | null;
|
|
25
|
-
|
|
25
|
+
adapter: MuiPickersAdapter;
|
|
26
26
|
isDisabled: (value: number) => boolean;
|
|
27
27
|
timeStep: number;
|
|
28
28
|
resolveLabel: (value: number) => string;
|
|
@@ -31,7 +31,7 @@ interface GetTimeSectionOptionsParameters {
|
|
|
31
31
|
}
|
|
32
32
|
export declare const getTimeSectionOptions: ({
|
|
33
33
|
value,
|
|
34
|
-
|
|
34
|
+
adapter,
|
|
35
35
|
isDisabled,
|
|
36
36
|
timeStep,
|
|
37
37
|
resolveLabel,
|