@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
|
@@ -256,7 +256,11 @@ export class AdapterDayjs {
|
|
|
256
256
|
if ((fixedValue.$offset ?? 0) === (value.$offset ?? 0)) {
|
|
257
257
|
return value;
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
// Change only what is needed to avoid creating a new object with unwanted data
|
|
260
|
+
// Especially important when used in an environment where utc or timezone dates are used only in some places
|
|
261
|
+
// Reference: https://github.com/mui/mui-x/issues/13290
|
|
262
|
+
// @ts-ignore
|
|
263
|
+
value.$offset = fixedValue.$offset;
|
|
260
264
|
}
|
|
261
265
|
return value;
|
|
262
266
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,72 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.6.2
|
|
7
|
+
|
|
8
|
+
_Jun 6, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 📚 Adds Date and Time Pickers accessibility page
|
|
13
|
+
- 🐞 Bugfixes
|
|
14
|
+
- 📚 Documentation improvements
|
|
15
|
+
|
|
16
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
17
|
+
|
|
18
|
+
### Data Grid
|
|
19
|
+
|
|
20
|
+
#### `@mui/x-data-grid@7.6.2`
|
|
21
|
+
|
|
22
|
+
- [DataGrid] Add the `areElementSizesEqual` utility to improve code readability (#13254) @layerok
|
|
23
|
+
- [DataGrid] Clean up IE remnants from the codebase (#13390) @MBilalShafi
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid-pro@7.6.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
26
|
+
|
|
27
|
+
Same changes as in `@mui/x-data-grid@7.6.2`.
|
|
28
|
+
|
|
29
|
+
#### `@mui/x-data-grid-premium@7.6.2` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
30
|
+
|
|
31
|
+
Same changes as in `@mui/x-data-grid-pro@7.6.2`.
|
|
32
|
+
|
|
33
|
+
### Date and Time Pickers
|
|
34
|
+
|
|
35
|
+
#### `@mui/x-date-pickers@7.6.2`
|
|
36
|
+
|
|
37
|
+
- [fields] Fix `PageUp` and `PageDown` editing on letter sections (#13310) @arthurbalduini
|
|
38
|
+
- [pickers] Fix `AdapterDayjs` timezone behavior (#13362) @LukasTy
|
|
39
|
+
- [pickers] Use `useRtl` instead of `useTheme` to access direction (#13363) @flaviendelangle
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-date-pickers-pro@7.6.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
42
|
+
|
|
43
|
+
Same changes as in `@mui/x-date-pickers@7.6.2`.
|
|
44
|
+
|
|
45
|
+
### Charts
|
|
46
|
+
|
|
47
|
+
#### `@mui/x-charts@7.6.2`
|
|
48
|
+
|
|
49
|
+
- [charts] Add `Initializable` type and behaviour to allow checking if a complex context has been initialized. (#13365) @JCQuintas
|
|
50
|
+
- [charts] Fix some props not working in `xAxis` and `yAxis` (#13372) @Valyok26
|
|
51
|
+
- [charts] Harmonize charts types (#13366) @alexfauquette
|
|
52
|
+
- [charts] Introduce plugins system (#13367) @alexfauquette
|
|
53
|
+
- [charts] Simplify plugin types (#13396) @JCQuintas
|
|
54
|
+
|
|
55
|
+
### Docs
|
|
56
|
+
|
|
57
|
+
- [docs] Add badges like in Material UI @oliviertassinari
|
|
58
|
+
- [docs] Update twitter.com to x.com @oliviertassinari
|
|
59
|
+
- [docs] Fix the description of `tickInterval` (#13355) @alexfauquette
|
|
60
|
+
- [docs] Adjust the code example for `quickFilterValues` (#12919) @michelengelen
|
|
61
|
+
- [docs] Create Pickers accessibility page (#13274) @arthurbalduini
|
|
62
|
+
|
|
63
|
+
### Core
|
|
64
|
+
|
|
65
|
+
- [core] Comment on `CSS.escape` for the future @oliviertassinari
|
|
66
|
+
- [core] Fix `l10n` action setup (#13382) @LukasTy
|
|
67
|
+
- [core] Fixes in preparation for React 18.3 (#13378) @LukasTy
|
|
68
|
+
- [core] Remove explicit `marked` dependency (#13383) @LukasTy
|
|
69
|
+
- [core] Remove unused `@types/prettier` dependency (#13389) @LukasTy
|
|
70
|
+
- [core] Add `docs/.env.local` to `.gitignore` (#13377) @KenanYusuf
|
|
71
|
+
|
|
6
72
|
## 7.6.1
|
|
7
73
|
|
|
8
74
|
_May 31, 2024_
|
|
@@ -6,7 +6,8 @@ import * as React from 'react';
|
|
|
6
6
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
7
7
|
import Typography from '@mui/material/Typography';
|
|
8
8
|
import { useSlotProps } from '@mui/base/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
10
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
11
|
import { unstable_composeClasses as composeClasses, unstable_useControlled as useControlled } from '@mui/utils';
|
|
11
12
|
import clsx from 'clsx';
|
|
12
13
|
import { PickersDay } from '../PickersDay/PickersDay';
|
|
@@ -249,8 +250,7 @@ export function DayCalendar(inProps) {
|
|
|
249
250
|
} = props;
|
|
250
251
|
const now = useNow(timezone);
|
|
251
252
|
const classes = useUtilityClasses(props);
|
|
252
|
-
const
|
|
253
|
-
const isRTL = theme.direction === 'rtl';
|
|
253
|
+
const isRtl = useRtl();
|
|
254
254
|
const isDateDisabled = useIsDateDisabled({
|
|
255
255
|
shouldDisableDate,
|
|
256
256
|
shouldDisableMonth,
|
|
@@ -295,13 +295,13 @@ export function DayCalendar(inProps) {
|
|
|
295
295
|
break;
|
|
296
296
|
case 'ArrowLeft':
|
|
297
297
|
{
|
|
298
|
-
const newFocusedDayDefault = utils.addDays(day,
|
|
299
|
-
const nextAvailableMonth = utils.addMonths(day,
|
|
298
|
+
const newFocusedDayDefault = utils.addDays(day, isRtl ? 1 : -1);
|
|
299
|
+
const nextAvailableMonth = utils.addMonths(day, isRtl ? 1 : -1);
|
|
300
300
|
const closestDayToFocus = findClosestEnabledDate({
|
|
301
301
|
utils,
|
|
302
302
|
date: newFocusedDayDefault,
|
|
303
|
-
minDate:
|
|
304
|
-
maxDate:
|
|
303
|
+
minDate: isRtl ? newFocusedDayDefault : utils.startOfMonth(nextAvailableMonth),
|
|
304
|
+
maxDate: isRtl ? utils.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
305
305
|
isDateDisabled,
|
|
306
306
|
timezone
|
|
307
307
|
});
|
|
@@ -311,13 +311,13 @@ export function DayCalendar(inProps) {
|
|
|
311
311
|
}
|
|
312
312
|
case 'ArrowRight':
|
|
313
313
|
{
|
|
314
|
-
const newFocusedDayDefault = utils.addDays(day,
|
|
315
|
-
const nextAvailableMonth = utils.addMonths(day,
|
|
314
|
+
const newFocusedDayDefault = utils.addDays(day, isRtl ? -1 : 1);
|
|
315
|
+
const nextAvailableMonth = utils.addMonths(day, isRtl ? -1 : 1);
|
|
316
316
|
const closestDayToFocus = findClosestEnabledDate({
|
|
317
317
|
utils,
|
|
318
318
|
date: newFocusedDayDefault,
|
|
319
|
-
minDate:
|
|
320
|
-
maxDate:
|
|
319
|
+
minDate: isRtl ? utils.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
|
|
320
|
+
maxDate: isRtl ? newFocusedDayDefault : utils.endOfMonth(nextAvailableMonth),
|
|
321
321
|
isDateDisabled,
|
|
322
322
|
timezone
|
|
323
323
|
});
|
|
@@ -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:
|
|
@@ -3,9 +3,7 @@ import { PickersLayoutProps } from './PickersLayout.types';
|
|
|
3
3
|
import { DateOrTimeViewWithMeridiem } from '../internals/models';
|
|
4
4
|
import { PickerValidDate } from '../models';
|
|
5
5
|
export declare const PickersLayoutRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
6
|
-
ownerState:
|
|
7
|
-
isLandscape: boolean;
|
|
8
|
-
};
|
|
6
|
+
ownerState: PickersLayoutProps<any, any, any>;
|
|
9
7
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
10
8
|
export declare const PickersLayoutContentWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
11
9
|
/**
|
|
@@ -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,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
3
|
import { SlotComponentProps } from '@mui/base/utils';
|
|
4
|
-
import { PickersActionBarProps } from '../PickersActionBar';
|
|
4
|
+
import { PickersActionBar, PickersActionBarProps } from '../PickersActionBar';
|
|
5
5
|
import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/props/toolbar';
|
|
6
6
|
import { BaseTabsProps, ExportedBaseTabsProps } from '../internals/models/props/tabs';
|
|
7
7
|
import { UsePickerLayoutPropsResponseLayoutProps } from '../internals/hooks/usePicker/usePickerLayoutProps';
|
|
8
8
|
import { PickersLayoutClasses } from './pickersLayoutClasses';
|
|
9
9
|
import { DateOrTimeViewWithMeridiem, WrapperVariant } from '../internals/models/common';
|
|
10
10
|
import { PickersShortcutsProps } from '../PickersShortcuts';
|
|
11
|
-
import { ExportedPickersShortcutProps } from '../PickersShortcuts/PickersShortcuts';
|
|
11
|
+
import { ExportedPickersShortcutProps, PickersShortcuts } from '../PickersShortcuts/PickersShortcuts';
|
|
12
12
|
import { PickerValidDate } from '../models';
|
|
13
13
|
export interface ExportedPickersLayoutSlots<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem> {
|
|
14
14
|
/**
|
|
@@ -37,11 +37,11 @@ export interface ExportedPickersLayoutSlotProps<TValue, TDate extends PickerVali
|
|
|
37
37
|
/**
|
|
38
38
|
* Props passed down to the action bar component.
|
|
39
39
|
*/
|
|
40
|
-
actionBar?: SlotComponentProps<
|
|
40
|
+
actionBar?: SlotComponentProps<typeof PickersActionBar, {}, PickersLayoutActionBarOwnerState<TValue, TDate, TView>>;
|
|
41
41
|
/**
|
|
42
42
|
* Props passed down to the shortcuts component.
|
|
43
43
|
*/
|
|
44
|
-
shortcuts?: SlotComponentProps<
|
|
44
|
+
shortcuts?: SlotComponentProps<typeof PickersShortcuts, {}, PickersShortcutsOwnerState<TValue>>;
|
|
45
45
|
/**
|
|
46
46
|
* Props passed down to the layoutRoot component.
|
|
47
47
|
*/
|
|
@@ -94,6 +94,10 @@ export interface PickersLayoutProps<TValue, TDate extends PickerValidDate, TView
|
|
|
94
94
|
* @default {}
|
|
95
95
|
*/
|
|
96
96
|
slotProps?: PickersLayoutSlotProps<TValue, TDate, TView>;
|
|
97
|
+
/**
|
|
98
|
+
* `true` if the application is in right-to-left direction.
|
|
99
|
+
*/
|
|
100
|
+
isRtl: boolean;
|
|
97
101
|
}
|
|
98
102
|
export interface SubComponents<TValue> {
|
|
99
103
|
toolbar: React.ReactElement<ExportedBaseToolbarProps> | null;
|
|
@@ -8,6 +8,7 @@ export declare const PickersInputBaseSectionsContainer: import("@emotion/styled"
|
|
|
8
8
|
ownerState: OwnerStateType;
|
|
9
9
|
}, {}, {}>;
|
|
10
10
|
interface OwnerStateType extends FormControlState, Omit<PickersInputBaseProps, keyof FormControlState> {
|
|
11
|
+
isRtl: boolean;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* @ignore - internal component.
|
|
@@ -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({
|