@mui/x-date-pickers 7.8.0 → 7.10.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 +140 -0
- package/DateCalendar/DayCalendar.js +7 -6
- package/DatePicker/DatePickerToolbar.js +4 -3
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -1
- package/DateTimePicker/DateTimePickerTabs.js +4 -4
- package/DateTimePicker/DateTimePickerToolbar.js +4 -3
- package/DesktopDatePicker/DesktopDatePicker.js +4 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -3
- package/DesktopTimePicker/DesktopTimePicker.js +4 -3
- package/DigitalClock/DigitalClock.js +4 -3
- package/MobileDatePicker/MobileDatePicker.js +4 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +4 -3
- package/MobileTimePicker/MobileTimePicker.js +4 -3
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/PickersActionBar/PickersActionBar.js +6 -6
- package/PickersCalendarHeader/PickersCalendarHeader.js +6 -5
- package/TimeClock/Clock.js +4 -3
- package/TimeClock/TimeClock.js +9 -8
- package/TimePicker/TimePickerToolbar.js +4 -3
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useClearableField.js +3 -3
- package/hooks/usePickersTranslations.d.ts +2 -0
- package/hooks/usePickersTranslations.js +2 -0
- package/index.js +1 -1
- package/internals/hooks/useField/useFieldState.js +6 -5
- package/internals/hooks/useField/useFieldV6TextField.js +10 -9
- package/internals/hooks/useField/useFieldV7TextField.js +7 -9
- package/internals/hooks/useUtils.d.ts +0 -1
- package/internals/hooks/useUtils.js +0 -1
- package/internals/index.d.ts +2 -2
- package/internals/index.js +2 -2
- package/internals/utils/date-time-utils.d.ts +1 -1
- package/internals/utils/validation/extractValidationProps.d.ts +1 -1
- package/modern/DateCalendar/DayCalendar.js +7 -6
- package/modern/DatePicker/DatePickerToolbar.js +4 -3
- package/modern/DateTimePicker/DateTimePickerTabs.js +4 -4
- package/modern/DateTimePicker/DateTimePickerToolbar.js +4 -3
- package/modern/DesktopDatePicker/DesktopDatePicker.js +4 -3
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -3
- package/modern/DesktopTimePicker/DesktopTimePicker.js +4 -3
- package/modern/DigitalClock/DigitalClock.js +4 -3
- package/modern/MobileDatePicker/MobileDatePicker.js +4 -3
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +4 -3
- package/modern/MobileTimePicker/MobileTimePicker.js +4 -3
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/modern/PickersActionBar/PickersActionBar.js +6 -6
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +6 -5
- package/modern/TimeClock/Clock.js +4 -3
- package/modern/TimeClock/TimeClock.js +9 -8
- package/modern/TimePicker/TimePickerToolbar.js +4 -3
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/hooks/usePickersTranslations.js +2 -0
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +6 -5
- package/modern/internals/hooks/useField/useFieldV6TextField.js +10 -9
- package/modern/internals/hooks/useField/useFieldV7TextField.js +7 -9
- package/modern/internals/hooks/useUtils.js +0 -1
- package/modern/internals/index.js +2 -2
- package/node/DateCalendar/DayCalendar.js +6 -5
- package/node/DatePicker/DatePickerToolbar.js +3 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +4 -4
- package/node/DateTimePicker/DateTimePickerToolbar.js +3 -2
- package/node/DesktopDatePicker/DesktopDatePicker.js +3 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -2
- package/node/DesktopTimePicker/DesktopTimePicker.js +3 -2
- package/node/DigitalClock/DigitalClock.js +3 -2
- package/node/MobileDatePicker/MobileDatePicker.js +3 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +3 -2
- package/node/MobileTimePicker/MobileTimePicker.js +3 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +7 -6
- package/node/PickersActionBar/PickersActionBar.js +6 -6
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +5 -4
- package/node/TimeClock/Clock.js +3 -2
- package/node/TimeClock/TimeClock.js +8 -7
- package/node/TimePicker/TimePickerToolbar.js +3 -2
- package/node/hooks/index.js +8 -1
- package/node/hooks/useClearableField.js +3 -3
- package/node/hooks/usePickersTranslations.js +9 -0
- package/node/index.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +5 -4
- package/node/internals/hooks/useField/useFieldV6TextField.js +10 -9
- package/node/internals/hooks/useField/useFieldV7TextField.js +6 -8
- package/node/internals/hooks/useUtils.js +1 -3
- package/node/internals/index.js +6 -6
- package/package.json +3 -3
|
@@ -11,7 +11,8 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
11
11
|
import MenuItem from '@mui/material/MenuItem';
|
|
12
12
|
import MenuList from '@mui/material/MenuList';
|
|
13
13
|
import useForkRef from '@mui/utils/useForkRef';
|
|
14
|
-
import {
|
|
14
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
15
|
+
import { useUtils, useNow } from '../internals/hooks/useUtils';
|
|
15
16
|
import { createIsAfterIgnoreDatePart } from '../internals/utils/time-utils';
|
|
16
17
|
import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
17
18
|
import { getDigitalClockUtilityClass } from './digitalClockClasses';
|
|
@@ -147,7 +148,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
147
148
|
onChange,
|
|
148
149
|
valueManager: singleItemValueManager
|
|
149
150
|
});
|
|
150
|
-
const
|
|
151
|
+
const translations = usePickersTranslations();
|
|
151
152
|
const now = useNow(timezone);
|
|
152
153
|
const ownerState = React.useMemo(() => _extends({}, props, {
|
|
153
154
|
alreadyRendered: !!containerRef.current
|
|
@@ -240,7 +241,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
240
241
|
}, other, {
|
|
241
242
|
children: /*#__PURE__*/_jsx(DigitalClockList, {
|
|
242
243
|
role: "listbox",
|
|
243
|
-
"aria-label":
|
|
244
|
+
"aria-label": translations.timePickerToolbarTitle,
|
|
244
245
|
className: classes.list,
|
|
245
246
|
children: timeOptions.map((option, index) => {
|
|
246
247
|
if (skipDisabled && isTimeDisabled(option)) {
|
|
@@ -5,7 +5,8 @@ import { resolveComponentProps } from '@mui/base/utils';
|
|
|
5
5
|
import { refType } from '@mui/utils';
|
|
6
6
|
import { useMobilePicker } from '../internals/hooks/useMobilePicker';
|
|
7
7
|
import { useDatePickerDefaultizedProps } from '../DatePicker/shared';
|
|
8
|
-
import {
|
|
8
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
9
|
+
import { useUtils } from '../internals/hooks/useUtils';
|
|
9
10
|
import { validateDate } from '../internals/utils/validation/validateDate';
|
|
10
11
|
import { DateField } from '../DateField';
|
|
11
12
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
@@ -23,7 +24,7 @@ import { resolveDateFormat } from '../internals/utils/date-utils';
|
|
|
23
24
|
* - [MobileDatePicker API](https://mui.com/x/api/date-pickers/mobile-date-picker/)
|
|
24
25
|
*/
|
|
25
26
|
const MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker(inProps, ref) {
|
|
26
|
-
const
|
|
27
|
+
const translations = usePickersTranslations();
|
|
27
28
|
const utils = useUtils();
|
|
28
29
|
|
|
29
30
|
// Props with the default values common to all date pickers
|
|
@@ -56,7 +57,7 @@ const MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker
|
|
|
56
57
|
props,
|
|
57
58
|
valueManager: singleItemValueManager,
|
|
58
59
|
valueType: 'date',
|
|
59
|
-
getOpenDialogAriaText: props.localeText?.openDatePickerDialogue ??
|
|
60
|
+
getOpenDialogAriaText: props.localeText?.openDatePickerDialogue ?? translations.openDatePickerDialogue,
|
|
60
61
|
validator: validateDate
|
|
61
62
|
});
|
|
62
63
|
return renderPicker();
|
|
@@ -6,7 +6,8 @@ import { refType } from '@mui/utils';
|
|
|
6
6
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
7
7
|
import { DateTimeField } from '../DateTimeField';
|
|
8
8
|
import { useDateTimePickerDefaultizedProps } from '../DateTimePicker/shared';
|
|
9
|
-
import {
|
|
9
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
10
|
+
import { useUtils } from '../internals/hooks/useUtils';
|
|
10
11
|
import { validateDateTime } from '../internals/utils/validation/validateDateTime';
|
|
11
12
|
import { useMobilePicker } from '../internals/hooks/useMobilePicker';
|
|
12
13
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
@@ -24,7 +25,7 @@ import { resolveDateTimeFormat } from '../internals/utils/date-time-utils';
|
|
|
24
25
|
* - [MobileDateTimePicker API](https://mui.com/x/api/date-pickers/mobile-date-time-picker/)
|
|
25
26
|
*/
|
|
26
27
|
const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTimePicker(inProps, ref) {
|
|
27
|
-
const
|
|
28
|
+
const translations = usePickersTranslations();
|
|
28
29
|
const utils = useUtils();
|
|
29
30
|
|
|
30
31
|
// Props with the default values common to all date time pickers
|
|
@@ -66,7 +67,7 @@ const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTi
|
|
|
66
67
|
props,
|
|
67
68
|
valueManager: singleItemValueManager,
|
|
68
69
|
valueType: 'date-time',
|
|
69
|
-
getOpenDialogAriaText: props.localeText?.openDatePickerDialogue ??
|
|
70
|
+
getOpenDialogAriaText: props.localeText?.openDatePickerDialogue ?? translations.openDatePickerDialogue,
|
|
70
71
|
validator: validateDateTime
|
|
71
72
|
});
|
|
72
73
|
return renderPicker();
|
|
@@ -6,7 +6,8 @@ import { refType } from '@mui/utils';
|
|
|
6
6
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
7
7
|
import { TimeField } from '../TimeField';
|
|
8
8
|
import { useTimePickerDefaultizedProps } from '../TimePicker/shared';
|
|
9
|
-
import {
|
|
9
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
10
|
+
import { useUtils } from '../internals/hooks/useUtils';
|
|
10
11
|
import { validateTime } from '../internals/utils/validation/validateTime';
|
|
11
12
|
import { useMobilePicker } from '../internals/hooks/useMobilePicker';
|
|
12
13
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
@@ -23,7 +24,7 @@ import { resolveTimeFormat } from '../internals/utils/time-utils';
|
|
|
23
24
|
* - [MobileTimePicker API](https://mui.com/x/api/date-pickers/mobile-time-picker/)
|
|
24
25
|
*/
|
|
25
26
|
const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker(inProps, ref) {
|
|
26
|
-
const
|
|
27
|
+
const translations = usePickersTranslations();
|
|
27
28
|
const utils = useUtils();
|
|
28
29
|
|
|
29
30
|
// Props with the default values common to all time pickers
|
|
@@ -59,7 +60,7 @@ const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker
|
|
|
59
60
|
props,
|
|
60
61
|
valueManager: singleItemValueManager,
|
|
61
62
|
valueType: 'time',
|
|
62
|
-
getOpenDialogAriaText: props.localeText?.openTimePickerDialogue ??
|
|
63
|
+
getOpenDialogAriaText: props.localeText?.openTimePickerDialogue ?? translations.openTimePickerDialogue,
|
|
63
64
|
validator: validateTime
|
|
64
65
|
});
|
|
65
66
|
return renderPicker();
|
|
@@ -8,7 +8,8 @@ import { useRtl } from '@mui/system/RtlProvider';
|
|
|
8
8
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
9
9
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
10
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
11
|
-
import {
|
|
11
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
12
|
+
import { useUtils, useNow } from '../internals/hooks/useUtils';
|
|
12
13
|
import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from '../internals/utils/time-utils';
|
|
13
14
|
import { useViews } from '../internals/hooks/useViews';
|
|
14
15
|
import { useMeridiemMode } from '../internals/hooks/date-helpers-hooks';
|
|
@@ -101,7 +102,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
101
102
|
onChange,
|
|
102
103
|
valueManager: singleItemValueManager
|
|
103
104
|
});
|
|
104
|
-
const
|
|
105
|
+
const translations = usePickersTranslations();
|
|
105
106
|
const now = useNow(timezone);
|
|
106
107
|
const timeSteps = React.useMemo(() => _extends({
|
|
107
108
|
hours: 1,
|
|
@@ -233,7 +234,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
233
234
|
utils,
|
|
234
235
|
isDisabled: hours => isTimeDisabled(hours, 'hours'),
|
|
235
236
|
timeStep: timeSteps.hours,
|
|
236
|
-
resolveAriaLabel:
|
|
237
|
+
resolveAriaLabel: translations.hoursClockNumberText,
|
|
237
238
|
valueOrReferenceDate
|
|
238
239
|
})
|
|
239
240
|
};
|
|
@@ -251,7 +252,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
251
252
|
resolveLabel: minutes => utils.format(utils.setMinutes(now, minutes), 'minutes'),
|
|
252
253
|
timeStep: timeSteps.minutes,
|
|
253
254
|
hasValue: !!value,
|
|
254
|
-
resolveAriaLabel:
|
|
255
|
+
resolveAriaLabel: translations.minutesClockNumberText
|
|
255
256
|
})
|
|
256
257
|
};
|
|
257
258
|
}
|
|
@@ -268,7 +269,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
268
269
|
resolveLabel: seconds => utils.format(utils.setSeconds(now, seconds), 'seconds'),
|
|
269
270
|
timeStep: timeSteps.seconds,
|
|
270
271
|
hasValue: !!value,
|
|
271
|
-
resolveAriaLabel:
|
|
272
|
+
resolveAriaLabel: translations.secondsClockNumberText
|
|
272
273
|
})
|
|
273
274
|
};
|
|
274
275
|
}
|
|
@@ -296,7 +297,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
296
297
|
default:
|
|
297
298
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
298
299
|
}
|
|
299
|
-
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds,
|
|
300
|
+
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, handleMeridiemChange]);
|
|
300
301
|
const viewsToRender = React.useMemo(() => {
|
|
301
302
|
if (!isRtl) {
|
|
302
303
|
return views;
|
|
@@ -333,7 +334,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
333
334
|
slots: slots,
|
|
334
335
|
slotProps: slotProps,
|
|
335
336
|
skipDisabled: skipDisabled,
|
|
336
|
-
"aria-label":
|
|
337
|
+
"aria-label": translations.selectViewText(timeView)
|
|
337
338
|
}, timeView))
|
|
338
339
|
}));
|
|
339
340
|
});
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import Button from '@mui/material/Button';
|
|
7
7
|
import DialogActions from '@mui/material/DialogActions';
|
|
8
|
-
import {
|
|
8
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
/**
|
|
11
11
|
* Demos:
|
|
@@ -26,7 +26,7 @@ function PickersActionBar(props) {
|
|
|
26
26
|
actions
|
|
27
27
|
} = props,
|
|
28
28
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
29
|
-
const
|
|
29
|
+
const translations = usePickersTranslations();
|
|
30
30
|
if (actions == null || actions.length === 0) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
@@ -35,22 +35,22 @@ function PickersActionBar(props) {
|
|
|
35
35
|
case 'clear':
|
|
36
36
|
return /*#__PURE__*/_jsx(Button, {
|
|
37
37
|
onClick: onClear,
|
|
38
|
-
children:
|
|
38
|
+
children: translations.clearButtonLabel
|
|
39
39
|
}, actionType);
|
|
40
40
|
case 'cancel':
|
|
41
41
|
return /*#__PURE__*/_jsx(Button, {
|
|
42
42
|
onClick: onCancel,
|
|
43
|
-
children:
|
|
43
|
+
children: translations.cancelButtonLabel
|
|
44
44
|
}, actionType);
|
|
45
45
|
case 'accept':
|
|
46
46
|
return /*#__PURE__*/_jsx(Button, {
|
|
47
47
|
onClick: onAccept,
|
|
48
|
-
children:
|
|
48
|
+
children: translations.okButtonLabel
|
|
49
49
|
}, actionType);
|
|
50
50
|
case 'today':
|
|
51
51
|
return /*#__PURE__*/_jsx(Button, {
|
|
52
52
|
onClick: onSetToday,
|
|
53
|
-
children:
|
|
53
|
+
children: translations.todayButtonLabel
|
|
54
54
|
}, actionType);
|
|
55
55
|
default:
|
|
56
56
|
return null;
|
|
@@ -10,7 +10,8 @@ import { styled, useThemeProps } from '@mui/material/styles';
|
|
|
10
10
|
import { useSlotProps } from '@mui/base/utils';
|
|
11
11
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
12
12
|
import IconButton from '@mui/material/IconButton';
|
|
13
|
-
import {
|
|
13
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
14
|
+
import { useUtils } from '../internals/hooks/useUtils';
|
|
14
15
|
import { PickersFadeTransitionGroup } from '../DateCalendar/PickersFadeTransitionGroup';
|
|
15
16
|
import { ArrowDropDownIcon } from '../icons';
|
|
16
17
|
import { PickersArrowSwitcher } from '../internals/components/PickersArrowSwitcher';
|
|
@@ -107,7 +108,7 @@ const PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDownIcon, {
|
|
|
107
108
|
* - [PickersCalendarHeader API](https://mui.com/x/api/date-pickers/pickers-calendar-header/)
|
|
108
109
|
*/
|
|
109
110
|
const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCalendarHeader(inProps, ref) {
|
|
110
|
-
const
|
|
111
|
+
const translations = usePickersTranslations();
|
|
111
112
|
const utils = useUtils();
|
|
112
113
|
const props = useThemeProps({
|
|
113
114
|
props: inProps,
|
|
@@ -141,7 +142,7 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
|
|
|
141
142
|
externalSlotProps: slotProps?.switchViewButton,
|
|
142
143
|
additionalProps: {
|
|
143
144
|
size: 'small',
|
|
144
|
-
'aria-label':
|
|
145
|
+
'aria-label': translations.calendarViewSwitchingButtonAriaLabel(view)
|
|
145
146
|
},
|
|
146
147
|
ownerState,
|
|
147
148
|
className: classes.switchViewButton
|
|
@@ -216,10 +217,10 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
|
|
|
216
217
|
slotProps: slotProps,
|
|
217
218
|
onGoToPrevious: selectPreviousMonth,
|
|
218
219
|
isPreviousDisabled: isPreviousMonthDisabled,
|
|
219
|
-
previousLabel:
|
|
220
|
+
previousLabel: translations.previousMonth,
|
|
220
221
|
onGoToNext: selectNextMonth,
|
|
221
222
|
isNextDisabled: isNextMonthDisabled,
|
|
222
|
-
nextLabel:
|
|
223
|
+
nextLabel: translations.nextMonth
|
|
223
224
|
})
|
|
224
225
|
})]
|
|
225
226
|
}));
|
|
@@ -5,7 +5,8 @@ import Typography from '@mui/material/Typography';
|
|
|
5
5
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
6
6
|
import { unstable_useEnhancedEffect as useEnhancedEffect, unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
7
|
import { ClockPointer } from './ClockPointer';
|
|
8
|
-
import {
|
|
8
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
9
|
+
import { useUtils } from '../internals/hooks/useUtils';
|
|
9
10
|
import { CLOCK_HOUR_WIDTH, getHours, getMinutes } from './shared';
|
|
10
11
|
import { getClockUtilityClass } from './clockClasses';
|
|
11
12
|
import { formatMeridiem } from '../internals/utils/date-utils';
|
|
@@ -196,7 +197,7 @@ export function Clock(inProps) {
|
|
|
196
197
|
} = props;
|
|
197
198
|
const ownerState = props;
|
|
198
199
|
const utils = useUtils();
|
|
199
|
-
const
|
|
200
|
+
const translations = usePickersTranslations();
|
|
200
201
|
const isMoving = React.useRef(false);
|
|
201
202
|
const classes = useUtilityClasses(ownerState);
|
|
202
203
|
const isSelectedTimeDisabled = isTimeDisabled(viewValue, type);
|
|
@@ -312,7 +313,7 @@ export function Clock(inProps) {
|
|
|
312
313
|
})]
|
|
313
314
|
}), /*#__PURE__*/_jsx(ClockWrapper, {
|
|
314
315
|
"aria-activedescendant": selectedId,
|
|
315
|
-
"aria-label":
|
|
316
|
+
"aria-label": translations.clockLabelText(type, value, utils),
|
|
316
317
|
ref: listboxRef,
|
|
317
318
|
role: "listbox",
|
|
318
319
|
onKeyDown: handleKeyDown,
|
|
@@ -6,7 +6,8 @@ import clsx from 'clsx';
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
8
|
import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
10
|
+
import { useUtils, useNow } from '../internals/hooks/useUtils';
|
|
10
11
|
import { PickersArrowSwitcher } from '../internals/components/PickersArrowSwitcher';
|
|
11
12
|
import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from '../internals/utils/time-utils';
|
|
12
13
|
import { useViews } from '../internals/hooks/useViews';
|
|
@@ -114,7 +115,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
114
115
|
props,
|
|
115
116
|
timezone
|
|
116
117
|
});
|
|
117
|
-
const
|
|
118
|
+
const translations = usePickersTranslations();
|
|
118
119
|
const now = useNow(timezone);
|
|
119
120
|
const {
|
|
120
121
|
view,
|
|
@@ -227,7 +228,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
227
228
|
utils,
|
|
228
229
|
ampm,
|
|
229
230
|
onChange: handleHoursChange,
|
|
230
|
-
getClockNumberText:
|
|
231
|
+
getClockNumberText: translations.hoursClockNumberText,
|
|
231
232
|
isDisabled: hourValue => disabled || isTimeDisabled(hourValue, 'hours'),
|
|
232
233
|
selectedId
|
|
233
234
|
})
|
|
@@ -246,7 +247,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
246
247
|
utils,
|
|
247
248
|
value: minutesValue,
|
|
248
249
|
onChange: handleMinutesChange,
|
|
249
|
-
getClockNumberText:
|
|
250
|
+
getClockNumberText: translations.minutesClockNumberText,
|
|
250
251
|
isDisabled: minuteValue => disabled || isTimeDisabled(minuteValue, 'minutes'),
|
|
251
252
|
selectedId
|
|
252
253
|
})
|
|
@@ -265,7 +266,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
265
266
|
utils,
|
|
266
267
|
value: secondsValue,
|
|
267
268
|
onChange: handleSecondsChange,
|
|
268
|
-
getClockNumberText:
|
|
269
|
+
getClockNumberText: translations.secondsClockNumberText,
|
|
269
270
|
isDisabled: secondValue => disabled || isTimeDisabled(secondValue, 'seconds'),
|
|
270
271
|
selectedId
|
|
271
272
|
})
|
|
@@ -274,7 +275,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
274
275
|
default:
|
|
275
276
|
throw new Error('You must provide the type for ClockView');
|
|
276
277
|
}
|
|
277
|
-
}, [view, utils, value, ampm,
|
|
278
|
+
}, [view, utils, value, ampm, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, selectedId, disabled]);
|
|
278
279
|
const ownerState = props;
|
|
279
280
|
const classes = useUtilityClasses(ownerState);
|
|
280
281
|
return /*#__PURE__*/_jsxs(TimeClockRoot, _extends({
|
|
@@ -301,10 +302,10 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
301
302
|
slotProps: slotProps,
|
|
302
303
|
onGoToPrevious: () => setView(previousView),
|
|
303
304
|
isPreviousDisabled: !previousView,
|
|
304
|
-
previousLabel:
|
|
305
|
+
previousLabel: translations.openPreviousView,
|
|
305
306
|
onGoToNext: () => setView(nextView),
|
|
306
307
|
isNextDisabled: !nextView,
|
|
307
|
-
nextLabel:
|
|
308
|
+
nextLabel: translations.openNextView,
|
|
308
309
|
ownerState: ownerState
|
|
309
310
|
})]
|
|
310
311
|
}));
|
|
@@ -11,7 +11,8 @@ import { PickersToolbarText } from '../internals/components/PickersToolbarText';
|
|
|
11
11
|
import { PickersToolbarButton } from '../internals/components/PickersToolbarButton';
|
|
12
12
|
import { PickersToolbar } from '../internals/components/PickersToolbar';
|
|
13
13
|
import { arrayIncludes } from '../internals/utils/utils';
|
|
14
|
-
import {
|
|
14
|
+
import { usePickersTranslations } from '../hooks/usePickersTranslations';
|
|
15
|
+
import { useUtils } from '../internals/hooks/useUtils';
|
|
15
16
|
import { useMeridiemMode } from '../internals/hooks/date-helpers-hooks';
|
|
16
17
|
import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from './timePickerToolbarClasses';
|
|
17
18
|
import { formatMeridiem } from '../internals/utils/date-utils';
|
|
@@ -131,7 +132,7 @@ function TimePickerToolbar(inProps) {
|
|
|
131
132
|
} = props,
|
|
132
133
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
133
134
|
const utils = useUtils();
|
|
134
|
-
const
|
|
135
|
+
const translations = usePickersTranslations();
|
|
135
136
|
const isRtl = useRtl();
|
|
136
137
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
137
138
|
const {
|
|
@@ -152,7 +153,7 @@ function TimePickerToolbar(inProps) {
|
|
|
152
153
|
});
|
|
153
154
|
return /*#__PURE__*/_jsxs(TimePickerToolbarRoot, _extends({
|
|
154
155
|
landscapeDirection: "row",
|
|
155
|
-
toolbarTitle:
|
|
156
|
+
toolbarTitle: translations.timePickerToolbarTitle,
|
|
156
157
|
isLandscape: isLandscape,
|
|
157
158
|
ownerState: ownerState,
|
|
158
159
|
className: clsx(classes.root, className)
|
package/modern/hooks/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { useClearableField } from './useClearableField';
|
|
1
|
+
export { useClearableField } from './useClearableField';
|
|
2
|
+
export { usePickersTranslations } from './usePickersTranslations';
|
|
@@ -7,10 +7,10 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
7
7
|
import MuiIconButton from '@mui/material/IconButton';
|
|
8
8
|
import InputAdornment from '@mui/material/InputAdornment';
|
|
9
9
|
import { ClearIcon } from '../icons';
|
|
10
|
-
import {
|
|
10
|
+
import { usePickersTranslations } from './usePickersTranslations';
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
export const useClearableField = props => {
|
|
13
|
-
const
|
|
13
|
+
const translations = usePickersTranslations();
|
|
14
14
|
const {
|
|
15
15
|
clearable,
|
|
16
16
|
onClear,
|
|
@@ -28,7 +28,7 @@ export const useClearableField = props => {
|
|
|
28
28
|
ownerState: {},
|
|
29
29
|
className: 'clearButton',
|
|
30
30
|
additionalProps: {
|
|
31
|
-
title:
|
|
31
|
+
title: translations.fieldClearLabel
|
|
32
32
|
}
|
|
33
33
|
}),
|
|
34
34
|
iconButtonProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
package/modern/index.js
CHANGED
|
@@ -2,14 +2,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useControlled from '@mui/utils/useControlled';
|
|
4
4
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
5
|
-
import {
|
|
5
|
+
import { usePickersTranslations } from '../../../hooks/usePickersTranslations';
|
|
6
|
+
import { useUtils, useLocalizationContext } from '../useUtils';
|
|
6
7
|
import { mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections, parseSelectedSections, getLocalizedDigits } from './useField.utils';
|
|
7
8
|
import { buildSectionsFromFormat } from './buildSectionsFromFormat';
|
|
8
9
|
import { useValueWithTimezone } from '../useValueWithTimezone';
|
|
9
10
|
import { getSectionTypeGranularity } from '../../utils/getDefaultReferenceDate';
|
|
10
11
|
export const useFieldState = params => {
|
|
11
12
|
const utils = useUtils();
|
|
12
|
-
const
|
|
13
|
+
const translations = usePickersTranslations();
|
|
13
14
|
const adapter = useLocalizationContext();
|
|
14
15
|
const isRtl = useRtl();
|
|
15
16
|
const {
|
|
@@ -48,7 +49,7 @@ export const useFieldState = params => {
|
|
|
48
49
|
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, date => buildSectionsFromFormat({
|
|
49
50
|
utils,
|
|
50
51
|
timezone,
|
|
51
|
-
localeText,
|
|
52
|
+
localeText: translations,
|
|
52
53
|
localizedDigits,
|
|
53
54
|
format,
|
|
54
55
|
date,
|
|
@@ -56,7 +57,7 @@ export const useFieldState = params => {
|
|
|
56
57
|
shouldRespectLeadingZeros,
|
|
57
58
|
enableAccessibleFieldDOMStructure,
|
|
58
59
|
isRtl
|
|
59
|
-
})), [fieldValueManager, format,
|
|
60
|
+
})), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, utils, formatDensity, timezone, enableAccessibleFieldDOMStructure]);
|
|
60
61
|
const [state, setState] = React.useState(() => {
|
|
61
62
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
62
63
|
validateSections(sections, valueType);
|
|
@@ -156,7 +157,7 @@ export const useFieldState = params => {
|
|
|
156
157
|
const sections = buildSectionsFromFormat({
|
|
157
158
|
utils,
|
|
158
159
|
timezone,
|
|
159
|
-
localeText,
|
|
160
|
+
localeText: translations,
|
|
160
161
|
localizedDigits,
|
|
161
162
|
format,
|
|
162
163
|
date,
|
|
@@ -36,6 +36,7 @@ export const addPositionPropertiesToSections = (sections, localizedDigits, isRtl
|
|
|
36
36
|
export const useFieldV6TextField = params => {
|
|
37
37
|
const isRtl = useRtl();
|
|
38
38
|
const focusTimeoutRef = React.useRef();
|
|
39
|
+
const selectionSyncTimeoutRef = React.useRef();
|
|
39
40
|
const {
|
|
40
41
|
forwardedProps: {
|
|
41
42
|
onFocus,
|
|
@@ -103,10 +104,14 @@ export const useFieldV6TextField = params => {
|
|
|
103
104
|
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
clearTimeout(selectionSyncTimeoutRef.current);
|
|
108
|
+
selectionSyncTimeoutRef.current = setTimeout(() => {
|
|
107
109
|
// handle case when the selection is not updated correctly
|
|
108
110
|
// could happen on Android
|
|
109
|
-
if (inputRef.current && inputRef.current === getActiveElement(document) &&
|
|
111
|
+
if (inputRef.current && inputRef.current === getActiveElement(document) &&
|
|
112
|
+
// The section might loose all selection, where `selectionStart === selectionEnd`
|
|
113
|
+
// https://github.com/mui/mui-x/pull/13652
|
|
114
|
+
inputRef.current.selectionStart === inputRef.current.selectionEnd && (inputRef.current.selectionStart !== selectionStart || inputRef.current.selectionEnd !== selectionEnd)) {
|
|
110
115
|
interactions.syncSelectionToDOM();
|
|
111
116
|
}
|
|
112
117
|
});
|
|
@@ -118,8 +123,7 @@ export const useFieldV6TextField = params => {
|
|
|
118
123
|
getActiveSectionIndexFromDOM: () => {
|
|
119
124
|
const browserStartIndex = inputRef.current.selectionStart ?? 0;
|
|
120
125
|
const browserEndIndex = inputRef.current.selectionEnd ?? 0;
|
|
121
|
-
|
|
122
|
-
if (browserStartIndex === 0 && browserEndIndex === 0 || isInputReadOnly) {
|
|
126
|
+
if (browserStartIndex === 0 && browserEndIndex === 0) {
|
|
123
127
|
return null;
|
|
124
128
|
}
|
|
125
129
|
const nextSectionIndex = browserStartIndex <= sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.
|
|
@@ -134,10 +138,6 @@ export const useFieldV6TextField = params => {
|
|
|
134
138
|
isFieldFocused: () => inputRef.current === getActiveElement(document)
|
|
135
139
|
}), [inputRef, parsedSelectedSections, sections, setSelectedSections]);
|
|
136
140
|
const syncSelectionFromDOM = () => {
|
|
137
|
-
if (readOnly) {
|
|
138
|
-
setSelectedSections(null);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
141
|
const browserStartIndex = inputRef.current.selectionStart ?? 0;
|
|
142
142
|
let nextSectionIndex;
|
|
143
143
|
if (browserStartIndex <= sections[0].startInInput) {
|
|
@@ -162,7 +162,7 @@ export const useFieldV6TextField = params => {
|
|
|
162
162
|
if (!input || input !== inputRef.current) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
if (activeSectionIndex != null
|
|
165
|
+
if (activeSectionIndex != null) {
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
if (
|
|
@@ -296,6 +296,7 @@ export const useFieldV6TextField = params => {
|
|
|
296
296
|
}
|
|
297
297
|
return () => {
|
|
298
298
|
clearTimeout(focusTimeoutRef.current);
|
|
299
|
+
clearTimeout(selectionSyncTimeoutRef.current);
|
|
299
300
|
};
|
|
300
301
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
301
302
|
|
|
@@ -5,7 +5,8 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
5
5
|
import useId from '@mui/utils/useId';
|
|
6
6
|
import { getSectionValueNow, getSectionValueText, parseSelectedSections } from './useField.utils';
|
|
7
7
|
import { getActiveElement } from '../../utils/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { usePickersTranslations } from '../../../hooks/usePickersTranslations';
|
|
9
|
+
import { useUtils } from '../useUtils';
|
|
9
10
|
export const useFieldV7TextField = params => {
|
|
10
11
|
const {
|
|
11
12
|
internalProps: {
|
|
@@ -38,7 +39,7 @@ export const useFieldV7TextField = params => {
|
|
|
38
39
|
} = params;
|
|
39
40
|
const sectionListRef = React.useRef(null);
|
|
40
41
|
const handleSectionListRef = useForkRef(inSectionListRef, sectionListRef);
|
|
41
|
-
const
|
|
42
|
+
const translations = usePickersTranslations();
|
|
42
43
|
const utils = useUtils();
|
|
43
44
|
const id = useId();
|
|
44
45
|
const [focused, setFocused] = React.useState(false);
|
|
@@ -220,7 +221,7 @@ export const useFieldV7TextField = params => {
|
|
|
220
221
|
const getInputContainerClickHandler = useEventCallback(sectionIndex => event => {
|
|
221
222
|
// The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.
|
|
222
223
|
// We avoid this by checking if the call to this function is actually intended, or a side effect.
|
|
223
|
-
if (event.isDefaultPrevented()
|
|
224
|
+
if (event.isDefaultPrevented()) {
|
|
224
225
|
return;
|
|
225
226
|
}
|
|
226
227
|
setSelectedSections(sectionIndex);
|
|
@@ -230,9 +231,6 @@ export const useFieldV7TextField = params => {
|
|
|
230
231
|
event.preventDefault();
|
|
231
232
|
});
|
|
232
233
|
const getInputContentFocusHandler = useEventCallback(sectionIndex => () => {
|
|
233
|
-
if (readOnly) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
234
|
setSelectedSections(sectionIndex);
|
|
237
235
|
});
|
|
238
236
|
const handleInputContentPaste = useEventCallback(event => {
|
|
@@ -341,8 +339,8 @@ export const useFieldV7TextField = params => {
|
|
|
341
339
|
'aria-valuenow': getSectionValueNow(section, utils),
|
|
342
340
|
'aria-valuemin': sectionBoundaries[section.type].minimum,
|
|
343
341
|
'aria-valuemax': sectionBoundaries[section.type].maximum,
|
|
344
|
-
'aria-valuetext': section.value ? getSectionValueText(section, utils) :
|
|
345
|
-
'aria-label':
|
|
342
|
+
'aria-valuetext': section.value ? getSectionValueText(section, utils) : translations.empty,
|
|
343
|
+
'aria-label': translations[section.type],
|
|
346
344
|
'aria-disabled': disabled,
|
|
347
345
|
spellCheck: isEditable ? false : undefined,
|
|
348
346
|
autoCapitalize: isEditable ? 'off' : undefined,
|
|
@@ -364,7 +362,7 @@ export const useFieldV7TextField = params => {
|
|
|
364
362
|
}
|
|
365
363
|
};
|
|
366
364
|
});
|
|
367
|
-
}, [state.sections, getInputContentFocusHandler, handleInputContentPaste, handleInputContentDragOver, handleInputContentInput, getInputContainerClickHandler, handleInputContentMouseUp, disabled, readOnly, isContainerEditable,
|
|
365
|
+
}, [state.sections, getInputContentFocusHandler, handleInputContentPaste, handleInputContentDragOver, handleInputContentInput, getInputContainerClickHandler, handleInputContentMouseUp, disabled, readOnly, isContainerEditable, translations, utils, sectionBoundaries, id]);
|
|
368
366
|
const handleValueStrChange = useEventCallback(event => {
|
|
369
367
|
updateValueFromValueStr(event.target.value);
|
|
370
368
|
});
|
|
@@ -17,7 +17,6 @@ export const useLocalizationContext = () => {
|
|
|
17
17
|
};
|
|
18
18
|
export const useUtils = () => useLocalizationContext().utils;
|
|
19
19
|
export const useDefaultDates = () => useLocalizationContext().defaultDates;
|
|
20
|
-
export const useLocaleText = () => useLocalizationContext().localeText;
|
|
21
20
|
export const useNow = timezone => {
|
|
22
21
|
const utils = useUtils();
|
|
23
22
|
const now = React.useRef();
|
|
@@ -13,13 +13,13 @@ export { useControlledValueWithTimezone } from './hooks/useValueWithTimezone';
|
|
|
13
13
|
export { useField, createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from './hooks/useField';
|
|
14
14
|
export { usePicker } from './hooks/usePicker';
|
|
15
15
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
16
|
-
export { useLocalizationContext, useDefaultDates, useUtils,
|
|
16
|
+
export { useLocalizationContext, useDefaultDates, useUtils, useNow } from './hooks/useUtils';
|
|
17
17
|
export { useViews } from './hooks/useViews';
|
|
18
18
|
export { useValidation } from './hooks/useValidation';
|
|
19
19
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
20
20
|
export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
21
21
|
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate, isDatePickerView, mergeDateAndTime, formatMeridiem } from './utils/date-utils';
|
|
22
|
-
export { resolveTimeViewsResponse } from './utils/date-time-utils';
|
|
22
|
+
export { resolveTimeViewsResponse, resolveDateTimeFormat } from './utils/date-time-utils';
|
|
23
23
|
export { splitFieldInternalAndForwardedProps } from './utils/fields';
|
|
24
24
|
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
|
|
25
25
|
export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
|