@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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export const getHourSectionOptions = ({
|
|
2
2
|
now,
|
|
3
3
|
value,
|
|
4
|
-
|
|
4
|
+
adapter,
|
|
5
5
|
ampm,
|
|
6
6
|
isDisabled,
|
|
7
7
|
resolveAriaLabel,
|
|
8
8
|
timeStep,
|
|
9
9
|
valueOrReferenceDate
|
|
10
10
|
}) => {
|
|
11
|
-
const currentHours = value ?
|
|
11
|
+
const currentHours = value ? adapter.getHours(value) : null;
|
|
12
12
|
const result = [];
|
|
13
13
|
const isSelected = (hour, overriddenCurrentHours) => {
|
|
14
14
|
const resolvedCurrentHours = overriddenCurrentHours ?? currentHours;
|
|
@@ -24,13 +24,13 @@ export const getHourSectionOptions = ({
|
|
|
24
24
|
return resolvedCurrentHours === hour;
|
|
25
25
|
};
|
|
26
26
|
const isFocused = hour => {
|
|
27
|
-
return isSelected(hour,
|
|
27
|
+
return isSelected(hour, adapter.getHours(valueOrReferenceDate));
|
|
28
28
|
};
|
|
29
29
|
const endHour = ampm ? 11 : 23;
|
|
30
30
|
for (let hour = 0; hour <= endHour; hour += timeStep) {
|
|
31
|
-
let label =
|
|
31
|
+
let label = adapter.format(adapter.setHours(now, hour), ampm ? 'hours12h' : 'hours24h');
|
|
32
32
|
const ariaLabel = resolveAriaLabel(parseInt(label, 10).toString());
|
|
33
|
-
label =
|
|
33
|
+
label = adapter.formatNumber(label);
|
|
34
34
|
result.push({
|
|
35
35
|
value: hour,
|
|
36
36
|
label,
|
|
@@ -44,7 +44,7 @@ export const getHourSectionOptions = ({
|
|
|
44
44
|
};
|
|
45
45
|
export const getTimeSectionOptions = ({
|
|
46
46
|
value,
|
|
47
|
-
|
|
47
|
+
adapter,
|
|
48
48
|
isDisabled,
|
|
49
49
|
timeStep,
|
|
50
50
|
resolveLabel,
|
|
@@ -66,7 +66,7 @@ export const getTimeSectionOptions = ({
|
|
|
66
66
|
const timeValue = timeStep * index;
|
|
67
67
|
return {
|
|
68
68
|
value: timeValue,
|
|
69
|
-
label:
|
|
69
|
+
label: adapter.formatNumber(resolveLabel(timeValue)),
|
|
70
70
|
isDisabled,
|
|
71
71
|
isSelected,
|
|
72
72
|
isFocused,
|
|
@@ -11,7 +11,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
11
11
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
12
12
|
import { DAY_MARGIN, DAY_SIZE } from "../internals/constants/dimensions.js";
|
|
13
13
|
import { pickerDay2Classes, getPickerDay2UtilityClass } from "./pickerDay2Classes.js";
|
|
14
|
-
import {
|
|
14
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
15
15
|
import { usePickerDayOwnerState } from "../PickersDay/usePickerDayOwnerState.js";
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
const useUtilityClasses = (ownerState, classes) => {
|
|
@@ -120,7 +120,7 @@ const PickerDay2Raw = /*#__PURE__*/React.forwardRef(function PickerDay2(inProps,
|
|
|
120
120
|
props: inProps,
|
|
121
121
|
name: 'MuiPickerDay2'
|
|
122
122
|
});
|
|
123
|
-
const
|
|
123
|
+
const adapter = usePickerAdapter();
|
|
124
124
|
const {
|
|
125
125
|
autoFocus = false,
|
|
126
126
|
className,
|
|
@@ -207,7 +207,7 @@ const PickerDay2Raw = /*#__PURE__*/React.forwardRef(function PickerDay2(inProps,
|
|
|
207
207
|
}, other, {
|
|
208
208
|
ownerState: ownerState,
|
|
209
209
|
className: clsx(classes.root, className),
|
|
210
|
-
children: children ?? (ownerState.isDayFillerCell ? null :
|
|
210
|
+
children: children ?? (ownerState.isDayFillerCell ? null : adapter.format(day, 'dayOfMonth'))
|
|
211
211
|
}));
|
|
212
212
|
});
|
|
213
213
|
if (process.env.NODE_ENV !== "production") PickerDay2Raw.displayName = "PickerDay2Raw";
|
|
@@ -6,8 +6,8 @@ export interface PickersActionBarProps extends DialogActionsProps {
|
|
|
6
6
|
* Ordered array of actions to display.
|
|
7
7
|
* If empty, does not display that action bar.
|
|
8
8
|
* @default
|
|
9
|
-
* - `[]` for
|
|
10
|
-
* - `['cancel', '
|
|
9
|
+
* - `[]` for Pickers with one selection step which `closeOnSelect`.
|
|
10
|
+
* - `['cancel', 'nextOrAccept']` for all other Pickers.
|
|
11
11
|
*/
|
|
12
12
|
actions?: PickersActionBarAction[];
|
|
13
13
|
}
|
|
@@ -98,8 +98,8 @@ process.env.NODE_ENV !== "production" ? PickersActionBarComponent.propTypes = {
|
|
|
98
98
|
* Ordered array of actions to display.
|
|
99
99
|
* If empty, does not display that action bar.
|
|
100
100
|
* @default
|
|
101
|
-
* - `[]` for
|
|
102
|
-
* - `['cancel', '
|
|
101
|
+
* - `[]` for Pickers with one selection step which `closeOnSelect`.
|
|
102
|
+
* - `['cancel', 'nextOrAccept']` for all other Pickers.
|
|
103
103
|
*/
|
|
104
104
|
actions: PropTypes.arrayOf(PropTypes.oneOf(['accept', 'cancel', 'clear', 'next', 'nextOrAccept', 'today']).isRequired),
|
|
105
105
|
/**
|
|
@@ -12,8 +12,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
12
12
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
13
13
|
import composeClasses from '@mui/utils/composeClasses';
|
|
14
14
|
import IconButton from '@mui/material/IconButton';
|
|
15
|
-
import { usePickerTranslations } from "../hooks/
|
|
16
|
-
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
15
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
17
16
|
import { PickersFadeTransitionGroup } from "../DateCalendar/PickersFadeTransitionGroup.js";
|
|
18
17
|
import { ArrowDropDownIcon } from "../icons/index.js";
|
|
19
18
|
import { PickersArrowSwitcher } from "../internals/components/PickersArrowSwitcher/index.js";
|
|
@@ -104,7 +103,7 @@ const PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDownIcon, {
|
|
|
104
103
|
*/
|
|
105
104
|
const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCalendarHeader(inProps, ref) {
|
|
106
105
|
const translations = usePickerTranslations();
|
|
107
|
-
const
|
|
106
|
+
const adapter = usePickerAdapter();
|
|
108
107
|
const props = useThemeProps({
|
|
109
108
|
props: inProps,
|
|
110
109
|
name: 'MuiPickersCalendarHeader'
|
|
@@ -127,7 +126,7 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
|
|
|
127
126
|
className,
|
|
128
127
|
classes: classesProp,
|
|
129
128
|
timezone,
|
|
130
|
-
format = `${
|
|
129
|
+
format = `${adapter.formats.month} ${adapter.formats.year}`
|
|
131
130
|
} = props,
|
|
132
131
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
133
132
|
const {
|
|
@@ -156,8 +155,8 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
|
|
|
156
155
|
className: classes.switchViewIcon
|
|
157
156
|
}),
|
|
158
157
|
switchViewIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
159
|
-
const selectNextMonth = () => onMonthChange(
|
|
160
|
-
const selectPreviousMonth = () => onMonthChange(
|
|
158
|
+
const selectNextMonth = () => onMonthChange(adapter.addMonths(month, 1));
|
|
159
|
+
const selectPreviousMonth = () => onMonthChange(adapter.addMonths(month, -1));
|
|
161
160
|
const isNextMonthDisabled = useNextMonthDisabled(month, {
|
|
162
161
|
disableFuture,
|
|
163
162
|
maxDate,
|
|
@@ -185,7 +184,7 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
|
|
|
185
184
|
if (views.length === 1 && views[0] === 'year') {
|
|
186
185
|
return null;
|
|
187
186
|
}
|
|
188
|
-
const label =
|
|
187
|
+
const label = adapter.formatByString(month, format);
|
|
189
188
|
return /*#__PURE__*/_jsxs(PickersCalendarHeaderRoot, _extends({}, other, {
|
|
190
189
|
ownerState: ownerState,
|
|
191
190
|
className: clsx(classes.root, className),
|
|
@@ -11,7 +11,7 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
11
11
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
12
|
import useForkRef from '@mui/utils/useForkRef';
|
|
13
13
|
import { alpha, styled, useThemeProps } from '@mui/material/styles';
|
|
14
|
-
import {
|
|
14
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
15
15
|
import { DAY_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
|
|
16
16
|
import { getPickersDayUtilityClass, pickersDayClasses } from "./pickersDayClasses.js";
|
|
17
17
|
import { usePickerDayOwnerState } from "./usePickerDayOwnerState.js";
|
|
@@ -164,7 +164,7 @@ const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps,
|
|
|
164
164
|
showDaysOutsideCurrentMonth
|
|
165
165
|
});
|
|
166
166
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
167
|
-
const
|
|
167
|
+
const adapter = usePickerAdapter();
|
|
168
168
|
const ref = React.useRef(null);
|
|
169
169
|
const handleRef = useForkRef(ref, forwardedRef);
|
|
170
170
|
|
|
@@ -217,7 +217,7 @@ const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps,
|
|
|
217
217
|
onMouseDown: handleMouseDown
|
|
218
218
|
}, other, {
|
|
219
219
|
ownerState: ownerState,
|
|
220
|
-
children: children ??
|
|
220
|
+
children: children ?? adapter.format(day, 'dayOfMonth')
|
|
221
221
|
}));
|
|
222
222
|
});
|
|
223
223
|
if (process.env.NODE_ENV !== "production") PickersDayRaw.displayName = "PickersDayRaw";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
4
|
-
import {
|
|
4
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
5
5
|
export function usePickerDayOwnerState(parameters) {
|
|
6
6
|
const {
|
|
7
7
|
disabled,
|
|
@@ -13,7 +13,7 @@ export function usePickerDayOwnerState(parameters) {
|
|
|
13
13
|
disableHighlightToday,
|
|
14
14
|
showDaysOutsideCurrentMonth
|
|
15
15
|
} = parameters;
|
|
16
|
-
const
|
|
16
|
+
const adapter = usePickerAdapter();
|
|
17
17
|
const {
|
|
18
18
|
ownerState: pickerOwnerState
|
|
19
19
|
} = usePickerPrivateContext();
|
|
@@ -23,10 +23,10 @@ export function usePickerDayOwnerState(parameters) {
|
|
|
23
23
|
isDayDisabled: disabled ?? false,
|
|
24
24
|
isDayCurrent: today ?? false,
|
|
25
25
|
isDayOutsideMonth: outsideCurrentMonth ?? false,
|
|
26
|
-
isDayStartOfWeek:
|
|
27
|
-
isDayEndOfWeek:
|
|
26
|
+
isDayStartOfWeek: adapter.isSameDay(day, adapter.startOfWeek(day)),
|
|
27
|
+
isDayEndOfWeek: adapter.isSameDay(day, adapter.endOfWeek(day)),
|
|
28
28
|
disableMargin: disableMargin ?? false,
|
|
29
29
|
disableHighlightToday: disableHighlightToday ?? false,
|
|
30
30
|
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth ?? false
|
|
31
|
-
}), [
|
|
31
|
+
}), [adapter, pickerOwnerState, day, selected, disabled, today, outsideCurrentMonth, disableMargin, disableHighlightToday, showDaysOutsideCurrentMonth]);
|
|
32
32
|
}
|
|
@@ -107,7 +107,7 @@ StaticDateTimePicker.propTypes = {
|
|
|
107
107
|
// ----------------------------------------------------------------------
|
|
108
108
|
/**
|
|
109
109
|
* 12h/24h view for hour selection clock.
|
|
110
|
-
* @default
|
|
110
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
111
111
|
*/
|
|
112
112
|
ampm: PropTypes.bool,
|
|
113
113
|
/**
|
|
@@ -60,7 +60,7 @@ StaticTimePicker.propTypes = {
|
|
|
60
60
|
// ----------------------------------------------------------------------
|
|
61
61
|
/**
|
|
62
62
|
* 12h/24h view for hour selection clock.
|
|
63
|
-
* @default
|
|
63
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
64
64
|
*/
|
|
65
65
|
ampm: PropTypes.bool,
|
|
66
66
|
/**
|
package/esm/TimeClock/Clock.js
CHANGED
|
@@ -7,8 +7,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
7
7
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
8
|
import composeClasses from '@mui/utils/composeClasses';
|
|
9
9
|
import { ClockPointer } from "./ClockPointer.js";
|
|
10
|
-
import { usePickerTranslations } from "../hooks/
|
|
11
|
-
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
10
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
12
11
|
import { CLOCK_HOUR_WIDTH, getHours, getMinutes } from "./shared.js";
|
|
13
12
|
import { getClockUtilityClass } from "./clockClasses.js";
|
|
14
13
|
import { formatMeridiem } from "../internals/utils/date-utils.js";
|
|
@@ -176,7 +175,7 @@ export function Clock(inProps) {
|
|
|
176
175
|
className,
|
|
177
176
|
classes: classesProp
|
|
178
177
|
} = props;
|
|
179
|
-
const
|
|
178
|
+
const adapter = usePickerAdapter();
|
|
180
179
|
const translations = usePickerTranslations();
|
|
181
180
|
const {
|
|
182
181
|
ownerState: pickerOwnerState
|
|
@@ -310,7 +309,7 @@ export function Clock(inProps) {
|
|
|
310
309
|
})]
|
|
311
310
|
}), /*#__PURE__*/_jsx(ClockWrapper, {
|
|
312
311
|
"aria-activedescendant": selectedId,
|
|
313
|
-
"aria-label": translations.clockLabelText(type, value == null ? null :
|
|
312
|
+
"aria-label": translations.clockLabelText(type, value == null ? null : adapter.format(value, ampm ? 'fullTime12h' : 'fullTime24h')),
|
|
314
313
|
ref: listboxRef,
|
|
315
314
|
role: "listbox",
|
|
316
315
|
onKeyDown: handleKeyDown,
|
|
@@ -324,22 +323,22 @@ export function Clock(inProps) {
|
|
|
324
323
|
disabled: disabled || meridiemMode === null,
|
|
325
324
|
ownerState: ownerState,
|
|
326
325
|
className: classes.amButton,
|
|
327
|
-
title: formatMeridiem(
|
|
326
|
+
title: formatMeridiem(adapter, 'am'),
|
|
328
327
|
children: /*#__PURE__*/_jsx(ClockMeridiemText, {
|
|
329
328
|
variant: "caption",
|
|
330
329
|
className: classes.meridiemText,
|
|
331
|
-
children: formatMeridiem(
|
|
330
|
+
children: formatMeridiem(adapter, 'am')
|
|
332
331
|
})
|
|
333
332
|
}), /*#__PURE__*/_jsx(ClockPmButton, {
|
|
334
333
|
disabled: disabled || meridiemMode === null,
|
|
335
334
|
onClick: readOnly ? undefined : () => handleMeridiemChange('pm'),
|
|
336
335
|
ownerState: ownerState,
|
|
337
336
|
className: classes.pmButton,
|
|
338
|
-
title: formatMeridiem(
|
|
337
|
+
title: formatMeridiem(adapter, 'pm'),
|
|
339
338
|
children: /*#__PURE__*/_jsx(ClockMeridiemText, {
|
|
340
339
|
variant: "caption",
|
|
341
340
|
className: classes.meridiemText,
|
|
342
|
-
children: formatMeridiem(
|
|
341
|
+
children: formatMeridiem(adapter, 'pm')
|
|
343
342
|
})
|
|
344
343
|
})]
|
|
345
344
|
})]
|
|
@@ -12,7 +12,7 @@ interface GetHourNumbersOptions {
|
|
|
12
12
|
* Should only be `undefined` on the server
|
|
13
13
|
*/
|
|
14
14
|
selectedId: string | undefined;
|
|
15
|
-
|
|
15
|
+
adapter: MuiPickersAdapter;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* @ignore - internal component.
|
|
@@ -23,10 +23,10 @@ export declare const getHourNumbers: ({
|
|
|
23
23
|
getClockNumberText,
|
|
24
24
|
isDisabled,
|
|
25
25
|
selectedId,
|
|
26
|
-
|
|
26
|
+
adapter
|
|
27
27
|
}: GetHourNumbersOptions) => React.JSX.Element[];
|
|
28
28
|
export declare const getMinutesNumbers: ({
|
|
29
|
-
|
|
29
|
+
adapter,
|
|
30
30
|
value,
|
|
31
31
|
isDisabled,
|
|
32
32
|
getClockNumberText,
|
|
@@ -10,9 +10,9 @@ export const getHourNumbers = ({
|
|
|
10
10
|
getClockNumberText,
|
|
11
11
|
isDisabled,
|
|
12
12
|
selectedId,
|
|
13
|
-
|
|
13
|
+
adapter
|
|
14
14
|
}) => {
|
|
15
|
-
const currentHours = value ?
|
|
15
|
+
const currentHours = value ? adapter.getHours(value) : null;
|
|
16
16
|
const hourNumbers = [];
|
|
17
17
|
const startHour = ampm ? 1 : 0;
|
|
18
18
|
const endHour = ampm ? 12 : 23;
|
|
@@ -34,7 +34,7 @@ export const getHourNumbers = ({
|
|
|
34
34
|
label = '00';
|
|
35
35
|
}
|
|
36
36
|
const inner = !ampm && (hour === 0 || hour > 12);
|
|
37
|
-
label =
|
|
37
|
+
label = adapter.formatNumber(label);
|
|
38
38
|
const selected = isSelected(hour);
|
|
39
39
|
hourNumbers.push(/*#__PURE__*/_jsx(ClockNumber, {
|
|
40
40
|
id: selected ? selectedId : undefined,
|
|
@@ -49,13 +49,13 @@ export const getHourNumbers = ({
|
|
|
49
49
|
return hourNumbers;
|
|
50
50
|
};
|
|
51
51
|
export const getMinutesNumbers = ({
|
|
52
|
-
|
|
52
|
+
adapter,
|
|
53
53
|
value,
|
|
54
54
|
isDisabled,
|
|
55
55
|
getClockNumberText,
|
|
56
56
|
selectedId
|
|
57
57
|
}) => {
|
|
58
|
-
const f =
|
|
58
|
+
const f = adapter.formatNumber;
|
|
59
59
|
return [[5, f('05')], [10, f('10')], [15, f('15')], [20, f('20')], [25, f('25')], [30, f('30')], [35, f('35')], [40, f('40')], [45, f('45')], [50, f('50')], [55, f('55')], [0, f('00')]].map(([numberValue, label], index) => {
|
|
60
60
|
const selected = numberValue === value;
|
|
61
61
|
return /*#__PURE__*/_jsx(ClockNumber, {
|
|
@@ -9,8 +9,8 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
11
11
|
import useId from '@mui/utils/useId';
|
|
12
|
-
import { usePickerTranslations } from "../hooks/
|
|
13
|
-
import {
|
|
12
|
+
import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
|
|
13
|
+
import { useNow } from "../internals/hooks/useUtils.js";
|
|
14
14
|
import { PickersArrowSwitcher } from "../internals/components/PickersArrowSwitcher/index.js";
|
|
15
15
|
import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from "../internals/utils/time-utils.js";
|
|
16
16
|
import { useViews } from "../internals/hooks/useViews.js";
|
|
@@ -60,13 +60,13 @@ const TIME_CLOCK_DEFAULT_VIEWS = ['hours', 'minutes'];
|
|
|
60
60
|
* - [TimeClock API](https://mui.com/x/api/date-pickers/time-clock/)
|
|
61
61
|
*/
|
|
62
62
|
export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps, ref) {
|
|
63
|
-
const
|
|
63
|
+
const adapter = usePickerAdapter();
|
|
64
64
|
const props = useThemeProps({
|
|
65
65
|
props: inProps,
|
|
66
66
|
name: 'MuiTimeClock'
|
|
67
67
|
});
|
|
68
68
|
const {
|
|
69
|
-
ampm =
|
|
69
|
+
ampm = adapter.is12HourCycleInCurrentLocale(),
|
|
70
70
|
ampmInClock = false,
|
|
71
71
|
autoFocus,
|
|
72
72
|
slots,
|
|
@@ -112,7 +112,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
112
112
|
const valueOrReferenceDate = useClockReferenceDate({
|
|
113
113
|
value,
|
|
114
114
|
referenceDate: referenceDateProp,
|
|
115
|
-
|
|
115
|
+
adapter,
|
|
116
116
|
props,
|
|
117
117
|
timezone
|
|
118
118
|
});
|
|
@@ -142,7 +142,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
142
142
|
handleMeridiemChange
|
|
143
143
|
} = useMeridiemMode(valueOrReferenceDate, ampm, setValueAndGoToNextView);
|
|
144
144
|
const isTimeDisabled = React.useCallback((rawValue, viewType) => {
|
|
145
|
-
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation,
|
|
145
|
+
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter);
|
|
146
146
|
const shouldCheckPastEnd = viewType === 'hours' || viewType === 'minutes' && views.includes('seconds');
|
|
147
147
|
const containsValidTime = ({
|
|
148
148
|
start,
|
|
@@ -169,11 +169,11 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
169
169
|
if (shouldDisableTime) {
|
|
170
170
|
switch (viewType) {
|
|
171
171
|
case 'hours':
|
|
172
|
-
return !shouldDisableTime(
|
|
172
|
+
return !shouldDisableTime(adapter.setHours(valueOrReferenceDate, timeValue), 'hours');
|
|
173
173
|
case 'minutes':
|
|
174
|
-
return !shouldDisableTime(
|
|
174
|
+
return !shouldDisableTime(adapter.setMinutes(valueOrReferenceDate, timeValue), 'minutes');
|
|
175
175
|
case 'seconds':
|
|
176
|
-
return !shouldDisableTime(
|
|
176
|
+
return !shouldDisableTime(adapter.setSeconds(valueOrReferenceDate, timeValue), 'seconds');
|
|
177
177
|
default:
|
|
178
178
|
return false;
|
|
179
179
|
}
|
|
@@ -184,12 +184,12 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
184
184
|
case 'hours':
|
|
185
185
|
{
|
|
186
186
|
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
|
|
187
|
-
const dateWithNewHours =
|
|
188
|
-
if (
|
|
187
|
+
const dateWithNewHours = adapter.setHours(valueOrReferenceDate, valueWithMeridiem);
|
|
188
|
+
if (adapter.getHours(dateWithNewHours) !== valueWithMeridiem) {
|
|
189
189
|
return true;
|
|
190
190
|
}
|
|
191
|
-
const start =
|
|
192
|
-
const end =
|
|
191
|
+
const start = adapter.setSeconds(adapter.setMinutes(dateWithNewHours, 0), 0);
|
|
192
|
+
const end = adapter.setSeconds(adapter.setMinutes(dateWithNewHours, 59), 59);
|
|
193
193
|
return !containsValidTime({
|
|
194
194
|
start,
|
|
195
195
|
end
|
|
@@ -197,9 +197,9 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
197
197
|
}
|
|
198
198
|
case 'minutes':
|
|
199
199
|
{
|
|
200
|
-
const dateWithNewMinutes =
|
|
201
|
-
const start =
|
|
202
|
-
const end =
|
|
200
|
+
const dateWithNewMinutes = adapter.setMinutes(valueOrReferenceDate, rawValue);
|
|
201
|
+
const start = adapter.setSeconds(dateWithNewMinutes, 0);
|
|
202
|
+
const end = adapter.setSeconds(dateWithNewMinutes, 59);
|
|
203
203
|
return !containsValidTime({
|
|
204
204
|
start,
|
|
205
205
|
end
|
|
@@ -207,7 +207,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
207
207
|
}
|
|
208
208
|
case 'seconds':
|
|
209
209
|
{
|
|
210
|
-
const dateWithNewSeconds =
|
|
210
|
+
const dateWithNewSeconds = adapter.setSeconds(valueOrReferenceDate, rawValue);
|
|
211
211
|
const start = dateWithNewSeconds;
|
|
212
212
|
const end = dateWithNewSeconds;
|
|
213
213
|
return !containsValidTime({
|
|
@@ -218,16 +218,16 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
218
218
|
default:
|
|
219
219
|
throw new Error('not supported');
|
|
220
220
|
}
|
|
221
|
-
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime,
|
|
221
|
+
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, adapter, disableFuture, disablePast, now, views]);
|
|
222
222
|
const viewProps = React.useMemo(() => {
|
|
223
223
|
switch (view) {
|
|
224
224
|
case 'hours':
|
|
225
225
|
{
|
|
226
226
|
const handleHoursChange = (hourValue, isFinish) => {
|
|
227
227
|
const valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
|
|
228
|
-
setValueAndGoToNextView(
|
|
228
|
+
setValueAndGoToNextView(adapter.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
|
|
229
229
|
};
|
|
230
|
-
const viewValue =
|
|
230
|
+
const viewValue = adapter.getHours(valueOrReferenceDate);
|
|
231
231
|
let viewRange;
|
|
232
232
|
if (ampm) {
|
|
233
233
|
if (viewValue > 12) {
|
|
@@ -243,7 +243,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
243
243
|
viewValue,
|
|
244
244
|
children: getHourNumbers({
|
|
245
245
|
value,
|
|
246
|
-
|
|
246
|
+
adapter,
|
|
247
247
|
ampm,
|
|
248
248
|
onChange: handleHoursChange,
|
|
249
249
|
getClockNumberText: translations.hoursClockNumberText,
|
|
@@ -255,15 +255,15 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
255
255
|
}
|
|
256
256
|
case 'minutes':
|
|
257
257
|
{
|
|
258
|
-
const minutesValue =
|
|
258
|
+
const minutesValue = adapter.getMinutes(valueOrReferenceDate);
|
|
259
259
|
const handleMinutesChange = (minuteValue, isFinish) => {
|
|
260
|
-
setValueAndGoToNextView(
|
|
260
|
+
setValueAndGoToNextView(adapter.setMinutes(valueOrReferenceDate, minuteValue), isFinish, 'minutes');
|
|
261
261
|
};
|
|
262
262
|
return {
|
|
263
263
|
viewValue: minutesValue,
|
|
264
264
|
onChange: handleMinutesChange,
|
|
265
265
|
children: getMinutesNumbers({
|
|
266
|
-
|
|
266
|
+
adapter,
|
|
267
267
|
value: minutesValue,
|
|
268
268
|
onChange: handleMinutesChange,
|
|
269
269
|
getClockNumberText: translations.minutesClockNumberText,
|
|
@@ -275,15 +275,15 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
275
275
|
}
|
|
276
276
|
case 'seconds':
|
|
277
277
|
{
|
|
278
|
-
const secondsValue =
|
|
278
|
+
const secondsValue = adapter.getSeconds(valueOrReferenceDate);
|
|
279
279
|
const handleSecondsChange = (secondValue, isFinish) => {
|
|
280
|
-
setValueAndGoToNextView(
|
|
280
|
+
setValueAndGoToNextView(adapter.setSeconds(valueOrReferenceDate, secondValue), isFinish, 'seconds');
|
|
281
281
|
};
|
|
282
282
|
return {
|
|
283
283
|
viewValue: secondsValue,
|
|
284
284
|
onChange: handleSecondsChange,
|
|
285
285
|
children: getMinutesNumbers({
|
|
286
|
-
|
|
286
|
+
adapter,
|
|
287
287
|
value: secondsValue,
|
|
288
288
|
onChange: handleSecondsChange,
|
|
289
289
|
getClockNumberText: translations.secondsClockNumberText,
|
|
@@ -296,7 +296,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
296
296
|
default:
|
|
297
297
|
throw new Error('You must provide the type for ClockView');
|
|
298
298
|
}
|
|
299
|
-
}, [view,
|
|
299
|
+
}, [view, adapter, value, ampm, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, selectedId, disabled]);
|
|
300
300
|
const classes = useUtilityClasses(classesProp);
|
|
301
301
|
return /*#__PURE__*/_jsxs(TimeClockRoot, _extends({
|
|
302
302
|
ref: ref,
|
|
@@ -338,7 +338,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
|
|
|
338
338
|
// ----------------------------------------------------------------------
|
|
339
339
|
/**
|
|
340
340
|
* 12h/24h view for hour selection clock.
|
|
341
|
-
* @default
|
|
341
|
+
* @default adapter.is12HourCycleInCurrentLocale()
|
|
342
342
|
*/
|
|
343
343
|
ampm: PropTypes.bool,
|
|
344
344
|
/**
|
|
@@ -51,7 +51,7 @@ process.env.NODE_ENV !== "production" ? TimeField.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" ? TimePicker.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,12 +12,10 @@ import { PickersToolbarText } from "../internals/components/PickersToolbarText.j
|
|
|
12
12
|
import { PickersToolbarButton } from "../internals/components/PickersToolbarButton.js";
|
|
13
13
|
import { PickersToolbar } from "../internals/components/PickersToolbar.js";
|
|
14
14
|
import { arrayIncludes } from "../internals/utils/utils.js";
|
|
15
|
-
import { usePickerTranslations } from "../hooks/
|
|
16
|
-
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
15
|
+
import { usePickerAdapter, usePickerContext, usePickerTranslations } from "../hooks/index.js";
|
|
17
16
|
import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
|
|
18
17
|
import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
|
|
19
18
|
import { formatMeridiem } from "../internals/utils/date-utils.js";
|
|
20
|
-
import { usePickerContext } from "../hooks/index.js";
|
|
21
19
|
import { useToolbarOwnerState } from "../internals/hooks/useToolbarOwnerState.js";
|
|
22
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
21
|
const useUtilityClasses = (classes, ownerState) => {
|
|
@@ -124,7 +122,7 @@ function TimePickerToolbar(inProps) {
|
|
|
124
122
|
classes: classesProp
|
|
125
123
|
} = props,
|
|
126
124
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
127
|
-
const
|
|
125
|
+
const adapter = usePickerAdapter();
|
|
128
126
|
const translations = usePickerTranslations();
|
|
129
127
|
const ownerState = useToolbarOwnerState();
|
|
130
128
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
@@ -145,10 +143,10 @@ function TimePickerToolbar(inProps) {
|
|
|
145
143
|
changeImportance: 'set'
|
|
146
144
|
}));
|
|
147
145
|
const formatSection = format => {
|
|
148
|
-
if (!
|
|
146
|
+
if (!adapter.isValid(value)) {
|
|
149
147
|
return '--';
|
|
150
148
|
}
|
|
151
|
-
return
|
|
149
|
+
return adapter.format(value, format);
|
|
152
150
|
};
|
|
153
151
|
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
|
|
154
152
|
tabIndex: -1,
|
|
@@ -192,7 +190,7 @@ function TimePickerToolbar(inProps) {
|
|
|
192
190
|
variant: "subtitle2",
|
|
193
191
|
selected: meridiemMode === 'am',
|
|
194
192
|
typographyClassName: classes.ampmLabel,
|
|
195
|
-
value: formatMeridiem(
|
|
193
|
+
value: formatMeridiem(adapter, 'am'),
|
|
196
194
|
onClick: readOnly ? undefined : () => handleMeridiemChange('am'),
|
|
197
195
|
disabled: disabled
|
|
198
196
|
}), /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
@@ -200,7 +198,7 @@ function TimePickerToolbar(inProps) {
|
|
|
200
198
|
variant: "subtitle2",
|
|
201
199
|
selected: meridiemMode === 'pm',
|
|
202
200
|
typographyClassName: classes.ampmLabel,
|
|
203
|
-
value: formatMeridiem(
|
|
201
|
+
value: formatMeridiem(adapter, 'pm'),
|
|
204
202
|
onClick: readOnly ? undefined : () => handleMeridiemChange('pm'),
|
|
205
203
|
disabled: disabled
|
|
206
204
|
})]
|
package/esm/TimePicker/shared.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 { useUtils } from "../internals/hooks/useUtils.js";
|
|
5
4
|
import { TimePickerToolbar } from "./TimePickerToolbar.js";
|
|
6
5
|
import { applyDefaultViewProps } from "../internals/utils/views.js";
|
|
7
6
|
import { useApplyDefaultValuesToTimeValidationProps } from "../managers/useTimeManager.js";
|
|
7
|
+
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
|
|
8
8
|
export function useTimePickerDefaultizedProps(props, name) {
|
|
9
|
-
const
|
|
9
|
+
const adapter = usePickerAdapter();
|
|
10
10
|
const themeProps = useThemeProps({
|
|
11
11
|
props,
|
|
12
12
|
name
|
|
13
13
|
});
|
|
14
14
|
const validationProps = useApplyDefaultValuesToTimeValidationProps(themeProps);
|
|
15
|
-
const ampm = themeProps.ampm ??
|
|
15
|
+
const ampm = themeProps.ampm ?? adapter.is12HourCycleInCurrentLocale();
|
|
16
16
|
const localeText = React.useMemo(() => {
|
|
17
17
|
if (themeProps.localeText?.toolbarTitle == null) {
|
|
18
18
|
return themeProps.localeText;
|