@mui/x-date-pickers 7.6.1 → 7.6.2
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/AdapterDayjs/AdapterDayjs.js +5 -1
- package/CHANGELOG.md +66 -0
- package/DateCalendar/DayCalendar.js +11 -11
- package/DateTimePicker/DateTimePickerToolbar.js +59 -49
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
- package/MonthCalendar/MonthCalendar.js +4 -4
- package/PickersLayout/PickersLayout.d.ts +1 -3
- package/PickersLayout/PickersLayout.js +30 -9
- package/PickersLayout/PickersLayout.types.d.ts +8 -4
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +1 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
- package/TimePicker/TimePickerToolbar.js +21 -18
- package/YearCalendar/YearCalendar.js +4 -4
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +5 -5
- package/internals/components/PickersToolbarButton.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
- package/internals/hooks/useField/useField.js +3 -4
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.d.ts +1 -1
- package/internals/hooks/useField/useField.utils.js +6 -5
- package/internals/hooks/useField/useFieldState.js +6 -7
- package/internals/hooks/useField/useFieldV6TextField.d.ts +1 -1
- package/internals/hooks/useField/useFieldV6TextField.js +10 -11
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -0
- package/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +5 -1
- package/modern/DateCalendar/DayCalendar.js +11 -11
- package/modern/DateTimePicker/DateTimePickerToolbar.js +59 -49
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
- package/modern/MonthCalendar/MonthCalendar.js +4 -4
- package/modern/PickersLayout/PickersLayout.js +30 -9
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
- package/modern/TimePicker/TimePickerToolbar.js +21 -18
- package/modern/YearCalendar/YearCalendar.js +4 -4
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +5 -5
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
- package/modern/internals/hooks/useField/useField.js +3 -4
- package/modern/internals/hooks/useField/useField.utils.js +6 -5
- package/modern/internals/hooks/useField/useFieldState.js +6 -7
- package/modern/internals/hooks/useField/useFieldV6TextField.js +10 -11
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
- package/node/AdapterDayjs/AdapterDayjs.js +5 -1
- package/node/DateCalendar/DayCalendar.js +10 -10
- package/node/DateTimePicker/DateTimePickerToolbar.js +58 -48
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
- package/node/MonthCalendar/MonthCalendar.js +4 -4
- package/node/PickersLayout/PickersLayout.js +30 -9
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
- package/node/TimePicker/TimePickerToolbar.js +20 -17
- package/node/YearCalendar/YearCalendar.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +4 -4
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
- package/node/internals/hooks/useField/useField.js +3 -4
- package/node/internals/hooks/useField/useField.utils.js +6 -5
- package/node/internals/hooks/useField/useFieldState.js +6 -7
- package/node/internals/hooks/useField/useFieldV6TextField.js +10 -11
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["ampm", "ampmInClock", "value", "onChange", "view", "isLandscape", "onViewChange", "toolbarFormat", "toolbarPlaceholder", "views", "disabled", "readOnly", "toolbarVariant", "toolbarTitle", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
6
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
7
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
7
8
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
9
|
import clsx from 'clsx';
|
|
9
10
|
import { PickersToolbarText } from '../internals/components/PickersToolbarText';
|
|
@@ -20,14 +21,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
20
21
|
const useUtilityClasses = ownerState => {
|
|
21
22
|
const {
|
|
22
23
|
classes,
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
isLandscape,
|
|
25
|
+
isRtl
|
|
25
26
|
} = ownerState;
|
|
26
27
|
const slots = {
|
|
27
28
|
root: ['root'],
|
|
28
29
|
dateContainer: ['dateContainer'],
|
|
29
|
-
timeContainer: ['timeContainer',
|
|
30
|
-
timeDigitsContainer: ['timeDigitsContainer',
|
|
30
|
+
timeContainer: ['timeContainer', isRtl && 'timeLabelReverse'],
|
|
31
|
+
timeDigitsContainer: ['timeDigitsContainer', isRtl && 'timeLabelReverse'],
|
|
31
32
|
separator: ['separator'],
|
|
32
33
|
ampmSelection: ['ampmSelection', isLandscape && 'ampmLandscape'],
|
|
33
34
|
ampmLabel: ['ampmLabel']
|
|
@@ -88,50 +89,59 @@ const DateTimePickerToolbarTimeContainer = styled('div', {
|
|
|
88
89
|
name: 'MuiDateTimePickerToolbar',
|
|
89
90
|
slot: 'TimeContainer',
|
|
90
91
|
overridesResolver: (props, styles) => styles.timeContainer
|
|
91
|
-
})(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
})({
|
|
93
|
+
display: 'flex',
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
variants: [{
|
|
96
|
+
props: {
|
|
97
|
+
isRtl: true
|
|
98
|
+
},
|
|
99
|
+
style: {
|
|
100
|
+
flexDirection: 'row-reverse'
|
|
101
|
+
}
|
|
99
102
|
}, {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
props: {
|
|
104
|
+
toolbarVariant: 'desktop',
|
|
105
|
+
isLandscape: false
|
|
106
|
+
},
|
|
107
|
+
style: {
|
|
108
|
+
gap: 9,
|
|
109
|
+
marginRight: 4,
|
|
110
|
+
alignSelf: 'flex-end'
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
props: ({
|
|
114
|
+
isLandscape,
|
|
115
|
+
toolbarVariant
|
|
116
|
+
}) => isLandscape && toolbarVariant !== 'desktop',
|
|
117
|
+
style: {
|
|
118
|
+
flexDirection: 'column'
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
props: ({
|
|
122
|
+
isLandscape,
|
|
123
|
+
toolbarVariant,
|
|
124
|
+
isRtl
|
|
125
|
+
}) => isLandscape && toolbarVariant !== 'desktop' && isRtl,
|
|
126
|
+
style: {
|
|
127
|
+
flexDirection: 'column-reverse'
|
|
128
|
+
}
|
|
129
|
+
}]
|
|
122
130
|
});
|
|
123
131
|
const DateTimePickerToolbarTimeDigitsContainer = styled('div', {
|
|
124
132
|
name: 'MuiDateTimePickerToolbar',
|
|
125
133
|
slot: 'TimeDigitsContainer',
|
|
126
134
|
overridesResolver: (props, styles) => styles.timeDigitsContainer
|
|
127
|
-
})(
|
|
128
|
-
|
|
129
|
-
}) => _extends({
|
|
130
|
-
display: 'flex'
|
|
131
|
-
}, theme.direction === 'rtl' && {
|
|
132
|
-
flexDirection: 'row-reverse'
|
|
133
|
-
}, {
|
|
135
|
+
})({
|
|
136
|
+
display: 'flex',
|
|
134
137
|
variants: [{
|
|
138
|
+
props: {
|
|
139
|
+
isRtl: true
|
|
140
|
+
},
|
|
141
|
+
style: {
|
|
142
|
+
flexDirection: 'row-reverse'
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
135
145
|
props: {
|
|
136
146
|
toolbarVariant: 'desktop'
|
|
137
147
|
},
|
|
@@ -139,7 +149,7 @@ const DateTimePickerToolbarTimeDigitsContainer = styled('div', {
|
|
|
139
149
|
gap: 1.5
|
|
140
150
|
}
|
|
141
151
|
}]
|
|
142
|
-
})
|
|
152
|
+
});
|
|
143
153
|
const DateTimePickerToolbarSeparator = styled(PickersToolbarText, {
|
|
144
154
|
name: 'MuiDateTimePickerToolbar',
|
|
145
155
|
slot: 'Separator',
|
|
@@ -220,7 +230,10 @@ function DateTimePickerToolbar(inProps) {
|
|
|
220
230
|
className
|
|
221
231
|
} = props,
|
|
222
232
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
223
|
-
const
|
|
233
|
+
const isRtl = useRtl();
|
|
234
|
+
const ownerState = _extends({}, props, {
|
|
235
|
+
isRtl
|
|
236
|
+
});
|
|
224
237
|
const utils = useUtils();
|
|
225
238
|
const {
|
|
226
239
|
meridiemMode,
|
|
@@ -229,10 +242,7 @@ function DateTimePickerToolbar(inProps) {
|
|
|
229
242
|
const showAmPmControl = Boolean(ampm && !ampmInClock);
|
|
230
243
|
const isDesktop = toolbarVariant === 'desktop';
|
|
231
244
|
const localeText = useLocaleText();
|
|
232
|
-
const
|
|
233
|
-
const classes = useUtilityClasses(_extends({}, ownerState, {
|
|
234
|
-
theme
|
|
235
|
-
}));
|
|
245
|
+
const classes = useUtilityClasses(ownerState);
|
|
236
246
|
const toolbarTitle = inToolbarTitle ?? localeText.dateTimePickerToolbarTitle;
|
|
237
247
|
const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
|
|
238
248
|
const dateText = React.useMemo(() => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import clsx from 'clsx';
|
|
5
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
4
6
|
import Divider from '@mui/material/Divider';
|
|
5
7
|
import { PickersLayoutContentWrapper, PickersLayoutRoot, pickersLayoutClasses, usePickerLayout } from '../PickersLayout';
|
|
6
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -8,6 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
10
|
* @ignore - internal component.
|
|
9
11
|
*/
|
|
10
12
|
function DesktopDateTimePickerLayout(props) {
|
|
13
|
+
const isRtl = useRtl();
|
|
11
14
|
const {
|
|
12
15
|
toolbar,
|
|
13
16
|
tabs,
|
|
@@ -23,6 +26,9 @@ function DesktopDateTimePickerLayout(props) {
|
|
|
23
26
|
classes
|
|
24
27
|
} = props;
|
|
25
28
|
const isActionBarVisible = actionBar && (actionBar.props.actions?.length ?? 0) > 0;
|
|
29
|
+
const ownerState = _extends({}, props, {
|
|
30
|
+
isRtl
|
|
31
|
+
});
|
|
26
32
|
return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
|
|
27
33
|
ref: ref,
|
|
28
34
|
className: clsx(className, pickersLayoutClasses.root, classes?.root),
|
|
@@ -35,7 +41,7 @@ function DesktopDateTimePickerLayout(props) {
|
|
|
35
41
|
gridRow: 5
|
|
36
42
|
}
|
|
37
43
|
}, ...(Array.isArray(sx) ? sx : [sx])],
|
|
38
|
-
ownerState:
|
|
44
|
+
ownerState: ownerState,
|
|
39
45
|
children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsxs(PickersLayoutContentWrapper, {
|
|
40
46
|
className: clsx(pickersLayoutClasses.contentWrapper, classes?.contentWrapper),
|
|
41
47
|
sx: {
|
|
@@ -63,6 +69,10 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
|
|
|
63
69
|
className: PropTypes.string,
|
|
64
70
|
disabled: PropTypes.bool,
|
|
65
71
|
isLandscape: PropTypes.bool.isRequired,
|
|
72
|
+
/**
|
|
73
|
+
* `true` if the application is in right-to-left direction.
|
|
74
|
+
*/
|
|
75
|
+
isRtl: PropTypes.bool.isRequired,
|
|
66
76
|
isValid: PropTypes.func.isRequired,
|
|
67
77
|
onAccept: PropTypes.func.isRequired,
|
|
68
78
|
onCancel: PropTypes.func.isRequired,
|
|
@@ -4,7 +4,7 @@ const _excluded = ["className", "value", "defaultValue", "referenceDate", "disab
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import {
|
|
7
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
8
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
9
9
|
import { unstable_useControlled as useControlled, unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
10
10
|
import { PickersMonth } from './PickersMonth';
|
|
@@ -99,7 +99,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
99
99
|
valueManager: singleItemValueManager
|
|
100
100
|
});
|
|
101
101
|
const now = useNow(timezone);
|
|
102
|
-
const
|
|
102
|
+
const isRtl = useRtl();
|
|
103
103
|
const utils = useUtils();
|
|
104
104
|
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
105
105
|
value,
|
|
@@ -179,11 +179,11 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
179
179
|
event.preventDefault();
|
|
180
180
|
break;
|
|
181
181
|
case 'ArrowLeft':
|
|
182
|
-
focusMonth((monthsInYear + month + (
|
|
182
|
+
focusMonth((monthsInYear + month + (isRtl ? 1 : -1)) % monthsInYear);
|
|
183
183
|
event.preventDefault();
|
|
184
184
|
break;
|
|
185
185
|
case 'ArrowRight':
|
|
186
|
-
focusMonth((monthsInYear + month + (
|
|
186
|
+
focusMonth((monthsInYear + month + (isRtl ? -1 : 1)) % monthsInYear);
|
|
187
187
|
event.preventDefault();
|
|
188
188
|
break;
|
|
189
189
|
default:
|
|
@@ -21,9 +21,7 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
21
21
|
name: 'MuiPickersLayout',
|
|
22
22
|
slot: 'Root',
|
|
23
23
|
overridesResolver: (props, styles) => styles.root
|
|
24
|
-
})(
|
|
25
|
-
theme
|
|
26
|
-
}) => ({
|
|
24
|
+
})({
|
|
27
25
|
display: 'grid',
|
|
28
26
|
gridAutoColumns: 'max-content auto max-content',
|
|
29
27
|
gridAutoRows: 'max-content auto max-content',
|
|
@@ -37,7 +35,7 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
37
35
|
},
|
|
38
36
|
style: {
|
|
39
37
|
[`& .${pickersLayoutClasses.toolbar}`]: {
|
|
40
|
-
gridColumn:
|
|
38
|
+
gridColumn: 1,
|
|
41
39
|
gridRow: '2 / 3'
|
|
42
40
|
},
|
|
43
41
|
[`.${pickersLayoutClasses.shortcuts}`]: {
|
|
@@ -45,6 +43,16 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
45
43
|
gridRow: 1
|
|
46
44
|
}
|
|
47
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
props: {
|
|
48
|
+
isLandscape: true,
|
|
49
|
+
isRtl: true
|
|
50
|
+
},
|
|
51
|
+
style: {
|
|
52
|
+
[`& .${pickersLayoutClasses.toolbar}`]: {
|
|
53
|
+
gridColumn: 3
|
|
54
|
+
}
|
|
55
|
+
}
|
|
48
56
|
}, {
|
|
49
57
|
props: {
|
|
50
58
|
isLandscape: false
|
|
@@ -55,12 +63,22 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
55
63
|
gridRow: 1
|
|
56
64
|
},
|
|
57
65
|
[`& .${pickersLayoutClasses.shortcuts}`]: {
|
|
58
|
-
gridColumn:
|
|
66
|
+
gridColumn: 1,
|
|
59
67
|
gridRow: '2 / 3'
|
|
60
68
|
}
|
|
61
69
|
}
|
|
70
|
+
}, {
|
|
71
|
+
props: {
|
|
72
|
+
isLandscape: false,
|
|
73
|
+
isRtl: true
|
|
74
|
+
},
|
|
75
|
+
style: {
|
|
76
|
+
[`& .${pickersLayoutClasses.shortcuts}`]: {
|
|
77
|
+
gridColumn: 3
|
|
78
|
+
}
|
|
79
|
+
}
|
|
62
80
|
}]
|
|
63
|
-
})
|
|
81
|
+
});
|
|
64
82
|
export const PickersLayoutContentWrapper = styled('div', {
|
|
65
83
|
name: 'MuiPickersLayout',
|
|
66
84
|
slot: 'ContentWrapper',
|
|
@@ -100,13 +118,12 @@ const PickersLayout = function PickersLayout(inProps) {
|
|
|
100
118
|
ref,
|
|
101
119
|
wrapperVariant
|
|
102
120
|
} = props;
|
|
103
|
-
const
|
|
104
|
-
const classes = useUtilityClasses(ownerState);
|
|
121
|
+
const classes = useUtilityClasses(props);
|
|
105
122
|
return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
|
|
106
123
|
ref: ref,
|
|
107
124
|
sx: sx,
|
|
108
125
|
className: clsx(className, classes.root),
|
|
109
|
-
ownerState:
|
|
126
|
+
ownerState: props,
|
|
110
127
|
children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsx(PickersLayoutContentWrapper, {
|
|
111
128
|
className: classes.contentWrapper,
|
|
112
129
|
children: wrapperVariant === 'desktop' ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -130,6 +147,10 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
|
130
147
|
className: PropTypes.string,
|
|
131
148
|
disabled: PropTypes.bool,
|
|
132
149
|
isLandscape: PropTypes.bool.isRequired,
|
|
150
|
+
/**
|
|
151
|
+
* `true` if the application is in right-to-left direction.
|
|
152
|
+
*/
|
|
153
|
+
isRtl: PropTypes.bool.isRequired,
|
|
133
154
|
isValid: PropTypes.func.isRequired,
|
|
134
155
|
onAccept: PropTypes.func.isRequired,
|
|
135
156
|
onCancel: PropTypes.func.isRequired,
|
|
@@ -11,6 +11,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
11
11
|
import capitalize from '@mui/utils/capitalize';
|
|
12
12
|
import { useSlotProps } from '@mui/base/utils';
|
|
13
13
|
import visuallyHidden from '@mui/utils/visuallyHidden';
|
|
14
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
14
15
|
import { pickersInputBaseClasses, getPickersInputBaseUtilityClass } from './pickersInputBaseClasses';
|
|
15
16
|
import { Unstable_PickersSectionList as PickersSectionList, Unstable_PickersSectionListRoot as PickersSectionListRoot, Unstable_PickersSectionListSection as PickersSectionListSection, Unstable_PickersSectionListSectionSeparator as PickersSectionListSectionSeparator, Unstable_PickersSectionListSectionContent as PickersSectionListSectionContent } from '../../PickersSectionList';
|
|
16
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -47,7 +48,7 @@ export const PickersInputBaseSectionsContainer = styled(PickersSectionListRoot,
|
|
|
47
48
|
overridesResolver: (props, styles) => styles.sectionsContainer
|
|
48
49
|
})(({
|
|
49
50
|
theme
|
|
50
|
-
}) =>
|
|
51
|
+
}) => ({
|
|
51
52
|
padding: '4px 0 5px',
|
|
52
53
|
fontFamily: theme.typography.fontFamily,
|
|
53
54
|
fontSize: 'inherit',
|
|
@@ -60,11 +61,15 @@ export const PickersInputBaseSectionsContainer = styled(PickersSectionListRoot,
|
|
|
60
61
|
overflow: 'hidden',
|
|
61
62
|
letterSpacing: 'inherit',
|
|
62
63
|
// Baseline behavior
|
|
63
|
-
width: '182px'
|
|
64
|
-
}, theme.direction === 'rtl' && {
|
|
65
|
-
textAlign: 'right /*! @noflip */'
|
|
66
|
-
}, {
|
|
64
|
+
width: '182px',
|
|
67
65
|
variants: [{
|
|
66
|
+
props: {
|
|
67
|
+
isRtl: true
|
|
68
|
+
},
|
|
69
|
+
style: {
|
|
70
|
+
textAlign: 'right /*! @noflip */'
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
68
73
|
props: {
|
|
69
74
|
size: 'small'
|
|
70
75
|
},
|
|
@@ -195,6 +200,7 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
195
200
|
const rootRef = React.useRef(null);
|
|
196
201
|
const handleRootRef = useForkRef(ref, rootRef);
|
|
197
202
|
const handleInputRef = useForkRef(inputProps?.ref, inputRef);
|
|
203
|
+
const isRtl = useRtl();
|
|
198
204
|
const muiFormControl = useFormControl();
|
|
199
205
|
if (!muiFormControl) {
|
|
200
206
|
throw new Error('MUI X: PickersInputBase should always be used inside a PickersTextField component');
|
|
@@ -223,7 +229,9 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
223
229
|
muiFormControl.onFilled();
|
|
224
230
|
}
|
|
225
231
|
}, [muiFormControl, areAllSectionsEmpty]);
|
|
226
|
-
const ownerState = _extends({}, props, muiFormControl
|
|
232
|
+
const ownerState = _extends({}, props, muiFormControl, {
|
|
233
|
+
isRtl
|
|
234
|
+
});
|
|
227
235
|
const classes = useUtilityClasses(ownerState);
|
|
228
236
|
const InputRoot = slots?.root || PickersInputBaseRoot;
|
|
229
237
|
const inputRootProps = useSlotProps({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "disabled", "readOnly", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import {
|
|
7
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
9
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
9
10
|
import { PickersToolbarText } from '../internals/components/PickersToolbarText';
|
|
10
11
|
import { PickersToolbarButton } from '../internals/components/PickersToolbarButton';
|
|
@@ -17,14 +18,14 @@ import { formatMeridiem } from '../internals/utils/date-utils';
|
|
|
17
18
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
const useUtilityClasses = ownerState => {
|
|
19
20
|
const {
|
|
20
|
-
theme,
|
|
21
21
|
isLandscape,
|
|
22
|
-
classes
|
|
22
|
+
classes,
|
|
23
|
+
isRtl
|
|
23
24
|
} = ownerState;
|
|
24
25
|
const slots = {
|
|
25
26
|
root: ['root'],
|
|
26
27
|
separator: ['separator'],
|
|
27
|
-
hourMinuteLabel: ['hourMinuteLabel', isLandscape && 'hourMinuteLabelLandscape',
|
|
28
|
+
hourMinuteLabel: ['hourMinuteLabel', isLandscape && 'hourMinuteLabelLandscape', isRtl && 'hourMinuteLabelReverse'],
|
|
28
29
|
ampmSelection: ['ampmSelection', isLandscape && 'ampmLandscape'],
|
|
29
30
|
ampmLabel: ['ampmLabel']
|
|
30
31
|
};
|
|
@@ -51,16 +52,18 @@ const TimePickerToolbarHourMinuteLabel = styled('div', {
|
|
|
51
52
|
[`&.${timePickerToolbarClasses.hourMinuteLabelLandscape}`]: styles.hourMinuteLabelLandscape,
|
|
52
53
|
[`&.${timePickerToolbarClasses.hourMinuteLabelReverse}`]: styles.hourMinuteLabelReverse
|
|
53
54
|
}, styles.hourMinuteLabel]
|
|
54
|
-
})(
|
|
55
|
-
theme
|
|
56
|
-
}) => _extends({
|
|
55
|
+
})({
|
|
57
56
|
display: 'flex',
|
|
58
57
|
justifyContent: 'flex-end',
|
|
59
|
-
alignItems: 'flex-end'
|
|
60
|
-
}, theme.direction === 'rtl' && {
|
|
61
|
-
flexDirection: 'row-reverse'
|
|
62
|
-
}, {
|
|
58
|
+
alignItems: 'flex-end',
|
|
63
59
|
variants: [{
|
|
60
|
+
props: {
|
|
61
|
+
isRtl: true
|
|
62
|
+
},
|
|
63
|
+
style: {
|
|
64
|
+
flexDirection: 'row-reverse'
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
64
67
|
props: {
|
|
65
68
|
isLandscape: true
|
|
66
69
|
},
|
|
@@ -68,7 +71,7 @@ const TimePickerToolbarHourMinuteLabel = styled('div', {
|
|
|
68
71
|
marginTop: 'auto'
|
|
69
72
|
}
|
|
70
73
|
}]
|
|
71
|
-
})
|
|
74
|
+
});
|
|
72
75
|
const TimePickerToolbarAmPmSelection = styled('div', {
|
|
73
76
|
name: 'MuiTimePickerToolbar',
|
|
74
77
|
slot: 'AmPmSelection',
|
|
@@ -129,17 +132,17 @@ function TimePickerToolbar(inProps) {
|
|
|
129
132
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
130
133
|
const utils = useUtils();
|
|
131
134
|
const localeText = useLocaleText();
|
|
132
|
-
const
|
|
135
|
+
const isRtl = useRtl();
|
|
133
136
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
134
137
|
const {
|
|
135
138
|
meridiemMode,
|
|
136
139
|
handleMeridiemChange
|
|
137
140
|
} = useMeridiemMode(value, ampm, onChange);
|
|
138
141
|
const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
|
|
139
|
-
const ownerState = props
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
const ownerState = _extends({}, props, {
|
|
143
|
+
isRtl
|
|
144
|
+
});
|
|
145
|
+
const classes = useUtilityClasses(ownerState);
|
|
143
146
|
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
|
|
144
147
|
tabIndex: -1,
|
|
145
148
|
value: ":",
|
|
@@ -4,7 +4,7 @@ const _excluded = ["autoFocus", "className", "value", "defaultValue", "reference
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import {
|
|
7
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
8
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
9
9
|
import { unstable_useForkRef as useForkRef, unstable_composeClasses as composeClasses, unstable_useControlled as useControlled, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
10
10
|
import { PickersYear } from './PickersYear';
|
|
@@ -104,7 +104,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
104
104
|
valueManager: singleItemValueManager
|
|
105
105
|
});
|
|
106
106
|
const now = useNow(timezone);
|
|
107
|
-
const
|
|
107
|
+
const isRtl = useRtl();
|
|
108
108
|
const utils = useUtils();
|
|
109
109
|
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
110
110
|
value,
|
|
@@ -184,11 +184,11 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
184
184
|
event.preventDefault();
|
|
185
185
|
break;
|
|
186
186
|
case 'ArrowLeft':
|
|
187
|
-
focusYear(year + (
|
|
187
|
+
focusYear(year + (isRtl ? 1 : -1));
|
|
188
188
|
event.preventDefault();
|
|
189
189
|
break;
|
|
190
190
|
case 'ArrowRight':
|
|
191
|
-
focusYear(year + (
|
|
191
|
+
focusYear(year + (isRtl ? -1 : 1));
|
|
192
192
|
event.preventDefault();
|
|
193
193
|
break;
|
|
194
194
|
default:
|
package/modern/index.js
CHANGED
|
@@ -6,7 +6,8 @@ const _excluded = ["children", "className", "slots", "slotProps", "isNextDisable
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import Typography from '@mui/material/Typography';
|
|
9
|
-
import {
|
|
9
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
10
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
11
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
11
12
|
import { useSlotProps } from '@mui/base/utils';
|
|
12
13
|
import IconButton from '@mui/material/IconButton';
|
|
@@ -55,8 +56,7 @@ const useUtilityClasses = ownerState => {
|
|
|
55
56
|
return composeClasses(slots, getPickersArrowSwitcherUtilityClass, classes);
|
|
56
57
|
};
|
|
57
58
|
export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrowSwitcher(inProps, ref) {
|
|
58
|
-
const
|
|
59
|
-
const isRTL = theme.direction === 'rtl';
|
|
59
|
+
const isRtl = useRtl();
|
|
60
60
|
const props = useThemeProps({
|
|
61
61
|
props: inProps,
|
|
62
62
|
name: 'MuiPickersArrowSwitcher'
|
|
@@ -152,7 +152,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
152
152
|
ownerState: ownerState
|
|
153
153
|
}, other, {
|
|
154
154
|
children: [/*#__PURE__*/_jsx(PreviousIconButton, _extends({}, previousIconButtonProps, {
|
|
155
|
-
children:
|
|
155
|
+
children: isRtl ? /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps)) : /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps))
|
|
156
156
|
})), children ? /*#__PURE__*/_jsx(Typography, {
|
|
157
157
|
variant: "subtitle1",
|
|
158
158
|
component: "span",
|
|
@@ -161,7 +161,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
161
161
|
className: classes.spacer,
|
|
162
162
|
ownerState: ownerState
|
|
163
163
|
}), /*#__PURE__*/_jsx(NextIconButton, _extends({}, nextIconButtonProps, {
|
|
164
|
-
children:
|
|
164
|
+
children: isRtl ? /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps)) : /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps))
|
|
165
165
|
}))]
|
|
166
166
|
}));
|
|
167
167
|
});
|
|
@@ -217,14 +217,14 @@ const buildSections = params => {
|
|
|
217
217
|
return sections;
|
|
218
218
|
};
|
|
219
219
|
const postProcessSections = ({
|
|
220
|
-
|
|
220
|
+
isRtl,
|
|
221
221
|
formatDensity,
|
|
222
222
|
sections
|
|
223
223
|
}) => {
|
|
224
224
|
return sections.map(section => {
|
|
225
225
|
const cleanSeparator = separator => {
|
|
226
226
|
let cleanedSeparator = separator;
|
|
227
|
-
if (
|
|
227
|
+
if (isRtl && cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
|
228
228
|
cleanedSeparator = `\u2069${cleanedSeparator}\u2066`;
|
|
229
229
|
}
|
|
230
230
|
if (formatDensity === 'spacious' && ['/', '.', '-'].includes(cleanedSeparator)) {
|
|
@@ -239,7 +239,7 @@ const postProcessSections = ({
|
|
|
239
239
|
};
|
|
240
240
|
export const buildSectionsFromFormat = params => {
|
|
241
241
|
let expandedFormat = expandFormat(params);
|
|
242
|
-
if (params.
|
|
242
|
+
if (params.isRtl && params.enableAccessibleFieldDOMStructure) {
|
|
243
243
|
expandedFormat = expandedFormat.split(' ').reverse().join(' ');
|
|
244
244
|
}
|
|
245
245
|
const escapedParts = getEscapedPartsFromFormat(_extends({}, params, {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
-
import {
|
|
5
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
6
6
|
import { useValidation } from '../useValidation';
|
|
7
7
|
import { useUtils } from '../useUtils';
|
|
8
8
|
import { adjustSectionValue, getSectionOrder } from './useField.utils';
|
|
@@ -31,8 +31,7 @@ export const useField = params => {
|
|
|
31
31
|
valueManager,
|
|
32
32
|
validator
|
|
33
33
|
} = params;
|
|
34
|
-
const
|
|
35
|
-
const isRTL = theme.direction === 'rtl';
|
|
34
|
+
const isRtl = useRtl();
|
|
36
35
|
const stateResponse = useFieldState(params);
|
|
37
36
|
const {
|
|
38
37
|
state,
|
|
@@ -60,7 +59,7 @@ export const useField = params => {
|
|
|
60
59
|
} = characterEditingResponse;
|
|
61
60
|
const areAllSectionsEmpty = valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
|
|
62
61
|
const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;
|
|
63
|
-
const sectionOrder = React.useMemo(() => getSectionOrder(state.sections,
|
|
62
|
+
const sectionOrder = React.useMemo(() => getSectionOrder(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);
|
|
64
63
|
const {
|
|
65
64
|
returnedValue,
|
|
66
65
|
interactions
|
|
@@ -195,8 +195,9 @@ export const adjustSectionValue = (utils, timezone, section, keyCode, sectionsVa
|
|
|
195
195
|
return options[options.length - 1];
|
|
196
196
|
}
|
|
197
197
|
const currentOptionIndex = options.indexOf(section.value);
|
|
198
|
-
const newOptionIndex = (currentOptionIndex +
|
|
199
|
-
|
|
198
|
+
const newOptionIndex = (currentOptionIndex + delta) % options.length;
|
|
199
|
+
const clampedIndex = (newOptionIndex + options.length) % options.length;
|
|
200
|
+
return options[clampedIndex];
|
|
200
201
|
};
|
|
201
202
|
if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {
|
|
202
203
|
return adjustDigitSection();
|
|
@@ -306,13 +307,13 @@ export const getDateFromDateSections = (utils, sections, localizedDigits) => {
|
|
|
306
307
|
export const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {
|
|
307
308
|
return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;
|
|
308
309
|
}).join('');
|
|
309
|
-
export const createDateStrForV6InputFromSections = (sections, localizedDigits,
|
|
310
|
+
export const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) => {
|
|
310
311
|
const formattedSections = sections.map(section => {
|
|
311
|
-
const dateValue = getSectionVisibleValue(section,
|
|
312
|
+
const dateValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);
|
|
312
313
|
return `${section.startSeparator}${dateValue}${section.endSeparator}`;
|
|
313
314
|
});
|
|
314
315
|
const dateStr = formattedSections.join('');
|
|
315
|
-
if (!
|
|
316
|
+
if (!isRtl) {
|
|
316
317
|
return dateStr;
|
|
317
318
|
}
|
|
318
319
|
|