@mui/x-date-pickers 7.6.0 → 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.
Files changed (62) hide show
  1. package/AdapterDayjs/AdapterDayjs.js +5 -1
  2. package/CHANGELOG.md +91 -0
  3. package/DateCalendar/DayCalendar.js +11 -11
  4. package/DateTimePicker/DateTimePickerToolbar.js +59 -49
  5. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
  6. package/MonthCalendar/MonthCalendar.js +4 -4
  7. package/PickersLayout/PickersLayout.d.ts +1 -3
  8. package/PickersLayout/PickersLayout.js +30 -9
  9. package/PickersLayout/PickersLayout.types.d.ts +8 -4
  10. package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +1 -0
  11. package/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
  12. package/TimePicker/TimePickerToolbar.js +21 -18
  13. package/YearCalendar/YearCalendar.js +4 -4
  14. package/index.js +1 -1
  15. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +5 -5
  16. package/internals/components/PickersToolbarButton.d.ts +1 -1
  17. package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
  18. package/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
  19. package/internals/hooks/useField/useField.js +3 -4
  20. package/internals/hooks/useField/useField.types.d.ts +2 -2
  21. package/internals/hooks/useField/useField.utils.d.ts +1 -1
  22. package/internals/hooks/useField/useField.utils.js +6 -5
  23. package/internals/hooks/useField/useFieldState.js +6 -7
  24. package/internals/hooks/useField/useFieldV6TextField.d.ts +1 -1
  25. package/internals/hooks/useField/useFieldV6TextField.js +10 -11
  26. package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -0
  27. package/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
  28. package/modern/AdapterDayjs/AdapterDayjs.js +5 -1
  29. package/modern/DateCalendar/DayCalendar.js +11 -11
  30. package/modern/DateTimePicker/DateTimePickerToolbar.js +59 -49
  31. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
  32. package/modern/MonthCalendar/MonthCalendar.js +4 -4
  33. package/modern/PickersLayout/PickersLayout.js +30 -9
  34. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
  35. package/modern/TimePicker/TimePickerToolbar.js +21 -18
  36. package/modern/YearCalendar/YearCalendar.js +4 -4
  37. package/modern/index.js +1 -1
  38. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +5 -5
  39. package/modern/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
  40. package/modern/internals/hooks/useField/useField.js +3 -4
  41. package/modern/internals/hooks/useField/useField.utils.js +6 -5
  42. package/modern/internals/hooks/useField/useFieldState.js +6 -7
  43. package/modern/internals/hooks/useField/useFieldV6TextField.js +10 -11
  44. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
  45. package/node/AdapterDayjs/AdapterDayjs.js +5 -1
  46. package/node/DateCalendar/DayCalendar.js +10 -10
  47. package/node/DateTimePicker/DateTimePickerToolbar.js +58 -48
  48. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
  49. package/node/MonthCalendar/MonthCalendar.js +4 -4
  50. package/node/PickersLayout/PickersLayout.js +30 -9
  51. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
  52. package/node/TimePicker/TimePickerToolbar.js +20 -17
  53. package/node/YearCalendar/YearCalendar.js +4 -4
  54. package/node/index.js +1 -1
  55. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +4 -4
  56. package/node/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
  57. package/node/internals/hooks/useField/useField.js +3 -4
  58. package/node/internals/hooks/useField/useField.utils.js +6 -5
  59. package/node/internals/hooks/useField/useFieldState.js +6 -7
  60. package/node/internals/hooks/useField/useFieldV6TextField.js +10 -11
  61. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
  62. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import useControlled from '@mui/utils/useControlled';
4
- import { useTheme } from '@mui/material/styles';
4
+ import { useRtl } from '@mui/system/RtlProvider';
5
5
  import { useUtils, useLocaleText, useLocalizationContext } from '../useUtils';
6
6
  import { mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections, parseSelectedSections, getLocalizedDigits } from './useField.utils';
7
7
  import { buildSectionsFromFormat } from './buildSectionsFromFormat';
@@ -11,8 +11,7 @@ export const useFieldState = params => {
11
11
  const utils = useUtils();
12
12
  const localeText = useLocaleText();
13
13
  const adapter = useLocalizationContext();
14
- const theme = useTheme();
15
- const isRTL = theme.direction === 'rtl';
14
+ const isRtl = useRtl();
16
15
  const {
17
16
  valueManager,
18
17
  fieldValueManager,
@@ -56,8 +55,8 @@ export const useFieldState = params => {
56
55
  formatDensity,
57
56
  shouldRespectLeadingZeros,
58
57
  enableAccessibleFieldDOMStructure,
59
- isRTL
60
- })), [fieldValueManager, format, localeText, localizedDigits, isRTL, shouldRespectLeadingZeros, utils, formatDensity, timezone, enableAccessibleFieldDOMStructure]);
58
+ isRtl
59
+ })), [fieldValueManager, format, localeText, localizedDigits, isRtl, shouldRespectLeadingZeros, utils, formatDensity, timezone, enableAccessibleFieldDOMStructure]);
61
60
  const [state, setState] = React.useState(() => {
62
61
  const sections = getSectionsFromValue(valueFromTheOutside);
63
62
  validateSections(sections, valueType);
@@ -164,7 +163,7 @@ export const useFieldState = params => {
164
163
  formatDensity,
165
164
  shouldRespectLeadingZeros,
166
165
  enableAccessibleFieldDOMStructure,
167
- isRTL
166
+ isRtl
168
167
  });
169
168
  return mergeDateIntoReferenceDate(utils, timezone, date, sections, referenceDate, false);
170
169
  };
@@ -234,7 +233,7 @@ export const useFieldState = params => {
234
233
  setState(prevState => _extends({}, prevState, {
235
234
  sections
236
235
  }));
237
- }, [format, utils.locale, isRTL]); // eslint-disable-line react-hooks/exhaustive-deps
236
+ }, [format, utils.locale, isRtl]); // eslint-disable-line react-hooks/exhaustive-deps
238
237
 
239
238
  React.useEffect(() => {
240
239
  let shouldUpdate;
@@ -1,18 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { useTheme } from '@mui/material/styles';
3
+ import { useRtl } from '@mui/system/RtlProvider';
4
4
  import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import useForkRef from '@mui/utils/useForkRef';
6
6
  import { getActiveElement } from '../../utils/utils';
7
7
  import { getSectionVisibleValue, isAndroid } from './useField.utils';
8
8
  const cleanString = dirtyString => dirtyString.replace(/[\u2066\u2067\u2068\u2069]/g, '');
9
- export const addPositionPropertiesToSections = (sections, localizedDigits, isRTL) => {
9
+ export const addPositionPropertiesToSections = (sections, localizedDigits, isRtl) => {
10
10
  let position = 0;
11
- let positionInInput = isRTL ? 1 : 0;
11
+ let positionInInput = isRtl ? 1 : 0;
12
12
  const newSections = [];
13
13
  for (let i = 0; i < sections.length; i += 1) {
14
14
  const section = sections[i];
15
- const renderedValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr', localizedDigits);
15
+ const renderedValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);
16
16
  const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;
17
17
  const sectionLength = cleanString(sectionStr).length;
18
18
  const sectionLengthInInput = sectionStr.length;
@@ -34,8 +34,7 @@ export const addPositionPropertiesToSections = (sections, localizedDigits, isRTL
34
34
  return newSections;
35
35
  };
36
36
  export const useFieldV6TextField = params => {
37
- const theme = useTheme();
38
- const isRTL = theme.direction === 'rtl';
37
+ const isRtl = useRtl();
39
38
  const focusTimeoutRef = React.useRef();
40
39
  const {
41
40
  forwardedProps: {
@@ -68,7 +67,7 @@ export const useFieldV6TextField = params => {
68
67
  } = params;
69
68
  const inputRef = React.useRef(null);
70
69
  const handleRef = useForkRef(inputRefProp, inputRef);
71
- const sections = React.useMemo(() => addPositionPropertiesToSections(state.sections, localizedDigits, isRTL), [state.sections, localizedDigits, isRTL]);
70
+ const sections = React.useMemo(() => addPositionPropertiesToSections(state.sections, localizedDigits, isRtl), [state.sections, localizedDigits, isRtl]);
72
71
  const interactions = React.useMemo(() => ({
73
72
  syncSelectionToDOM: () => {
74
73
  if (!inputRef.current) {
@@ -241,7 +240,7 @@ export const useFieldV6TextField = params => {
241
240
  if (parsedSelectedSections === 'all' && cleanValueStr.length === 1) {
242
241
  keyPressed = cleanValueStr;
243
242
  } else {
244
- const prevValueStr = cleanString(fieldValueManager.getV6InputValueFromSections(sections, localizedDigits, isRTL));
243
+ const prevValueStr = cleanString(fieldValueManager.getV6InputValueFromSections(sections, localizedDigits, isRtl));
245
244
  let startOfDiffIndex = -1;
246
245
  let endOfDiffIndex = -1;
247
246
  for (let i = 0; i < prevValueStr.length; i += 1) {
@@ -281,9 +280,9 @@ export const useFieldV6TextField = params => {
281
280
  if (inPlaceholder !== undefined) {
282
281
  return inPlaceholder;
283
282
  }
284
- return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRTL);
285
- }, [inPlaceholder, fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRTL]);
286
- const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRTL), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRTL]);
283
+ return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRtl);
284
+ }, [inPlaceholder, fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRtl]);
285
+ const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRtl), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRtl]);
287
286
  React.useEffect(() => {
288
287
  // Select all the sections when focused on mount (`autoFocus = true` on the input)
289
288
  if (inputRef.current && inputRef.current === getActiveElement(document)) {
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { useRtl } from '@mui/system/RtlProvider';
2
3
  import { useIsLandscape } from '../useIsLandscape';
3
4
 
4
5
  /**
@@ -19,8 +20,10 @@ export const usePickerLayoutProps = ({
19
20
  orientation
20
21
  } = props;
21
22
  const isLandscape = useIsLandscape(propsFromPickerViews.views, orientation);
23
+ const isRtl = useRtl();
22
24
  const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
23
25
  isLandscape,
26
+ isRtl,
24
27
  wrapperVariant,
25
28
  disabled: props.disabled,
26
29
  readOnly: props.readOnly
@@ -264,7 +264,11 @@ class AdapterDayjs {
264
264
  if ((fixedValue.$offset ?? 0) === (value.$offset ?? 0)) {
265
265
  return value;
266
266
  }
267
- return fixedValue;
267
+ // Change only what is needed to avoid creating a new object with unwanted data
268
+ // Especially important when used in an environment where utc or timezone dates are used only in some places
269
+ // Reference: https://github.com/mui/mui-x/issues/13290
270
+ // @ts-ignore
271
+ value.$offset = fixedValue.$offset;
268
272
  }
269
273
  return value;
270
274
  };
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
12
12
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
13
  var _utils = require("@mui/base/utils");
14
+ var _RtlProvider = require("@mui/system/RtlProvider");
14
15
  var _styles = require("@mui/material/styles");
15
16
  var _utils2 = require("@mui/utils");
16
17
  var _clsx = _interopRequireDefault(require("clsx"));
@@ -258,8 +259,7 @@ function DayCalendar(inProps) {
258
259
  } = props;
259
260
  const now = (0, _useUtils.useNow)(timezone);
260
261
  const classes = useUtilityClasses(props);
261
- const theme = (0, _styles.useTheme)();
262
- const isRTL = theme.direction === 'rtl';
262
+ const isRtl = (0, _RtlProvider.useRtl)();
263
263
  const isDateDisabled = (0, _useIsDateDisabled.useIsDateDisabled)({
264
264
  shouldDisableDate,
265
265
  shouldDisableMonth,
@@ -304,13 +304,13 @@ function DayCalendar(inProps) {
304
304
  break;
305
305
  case 'ArrowLeft':
306
306
  {
307
- const newFocusedDayDefault = utils.addDays(day, isRTL ? 1 : -1);
308
- const nextAvailableMonth = utils.addMonths(day, isRTL ? 1 : -1);
307
+ const newFocusedDayDefault = utils.addDays(day, isRtl ? 1 : -1);
308
+ const nextAvailableMonth = utils.addMonths(day, isRtl ? 1 : -1);
309
309
  const closestDayToFocus = (0, _dateUtils.findClosestEnabledDate)({
310
310
  utils,
311
311
  date: newFocusedDayDefault,
312
- minDate: isRTL ? newFocusedDayDefault : utils.startOfMonth(nextAvailableMonth),
313
- maxDate: isRTL ? utils.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
312
+ minDate: isRtl ? newFocusedDayDefault : utils.startOfMonth(nextAvailableMonth),
313
+ maxDate: isRtl ? utils.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
314
314
  isDateDisabled,
315
315
  timezone
316
316
  });
@@ -320,13 +320,13 @@ function DayCalendar(inProps) {
320
320
  }
321
321
  case 'ArrowRight':
322
322
  {
323
- const newFocusedDayDefault = utils.addDays(day, isRTL ? -1 : 1);
324
- const nextAvailableMonth = utils.addMonths(day, isRTL ? -1 : 1);
323
+ const newFocusedDayDefault = utils.addDays(day, isRtl ? -1 : 1);
324
+ const nextAvailableMonth = utils.addMonths(day, isRtl ? -1 : 1);
325
325
  const closestDayToFocus = (0, _dateUtils.findClosestEnabledDate)({
326
326
  utils,
327
327
  date: newFocusedDayDefault,
328
- minDate: isRTL ? utils.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
329
- maxDate: isRTL ? newFocusedDayDefault : utils.endOfMonth(nextAvailableMonth),
328
+ minDate: isRtl ? utils.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
329
+ maxDate: isRtl ? newFocusedDayDefault : utils.endOfMonth(nextAvailableMonth),
330
330
  isDateDisabled,
331
331
  timezone
332
332
  });
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.DateTimePickerToolbar = DateTimePickerToolbar;
8
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _RtlProvider = require("@mui/system/RtlProvider");
12
13
  var _styles = require("@mui/material/styles");
13
14
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
14
15
  var _clsx = _interopRequireDefault(require("clsx"));
@@ -29,14 +30,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
29
30
  const useUtilityClasses = ownerState => {
30
31
  const {
31
32
  classes,
32
- theme,
33
- isLandscape
33
+ isLandscape,
34
+ isRtl
34
35
  } = ownerState;
35
36
  const slots = {
36
37
  root: ['root'],
37
38
  dateContainer: ['dateContainer'],
38
- timeContainer: ['timeContainer', theme.direction === 'rtl' && 'timeLabelReverse'],
39
- timeDigitsContainer: ['timeDigitsContainer', theme.direction === 'rtl' && 'timeLabelReverse'],
39
+ timeContainer: ['timeContainer', isRtl && 'timeLabelReverse'],
40
+ timeDigitsContainer: ['timeDigitsContainer', isRtl && 'timeLabelReverse'],
40
41
  separator: ['separator'],
41
42
  ampmSelection: ['ampmSelection', isLandscape && 'ampmLandscape'],
42
43
  ampmLabel: ['ampmLabel']
@@ -97,50 +98,59 @@ const DateTimePickerToolbarTimeContainer = (0, _styles.styled)('div', {
97
98
  name: 'MuiDateTimePickerToolbar',
98
99
  slot: 'TimeContainer',
99
100
  overridesResolver: (props, styles) => styles.timeContainer
100
- })(({
101
- theme
102
- }) => {
103
- return (0, _extends2.default)({
104
- display: 'flex',
105
- flexDirection: 'row'
106
- }, theme.direction === 'rtl' && {
107
- flexDirection: 'row-reverse'
101
+ })({
102
+ display: 'flex',
103
+ flexDirection: 'row',
104
+ variants: [{
105
+ props: {
106
+ isRtl: true
107
+ },
108
+ style: {
109
+ flexDirection: 'row-reverse'
110
+ }
108
111
  }, {
109
- variants: [{
110
- props: ({
111
- isLandscape,
112
- toolbarVariant
113
- }) => isLandscape && toolbarVariant !== 'desktop',
114
- style: (0, _extends2.default)({
115
- flexDirection: 'column'
116
- }, theme.direction === 'rtl' && {
117
- flexDirection: 'column-reverse'
118
- })
119
- }, {
120
- props: {
121
- toolbarVariant: 'desktop',
122
- isLandscape: false
123
- },
124
- style: {
125
- gap: 9,
126
- marginRight: 4,
127
- alignSelf: 'flex-end'
128
- }
129
- }]
130
- });
112
+ props: {
113
+ toolbarVariant: 'desktop',
114
+ isLandscape: false
115
+ },
116
+ style: {
117
+ gap: 9,
118
+ marginRight: 4,
119
+ alignSelf: 'flex-end'
120
+ }
121
+ }, {
122
+ props: ({
123
+ isLandscape,
124
+ toolbarVariant
125
+ }) => isLandscape && toolbarVariant !== 'desktop',
126
+ style: {
127
+ flexDirection: 'column'
128
+ }
129
+ }, {
130
+ props: ({
131
+ isLandscape,
132
+ toolbarVariant,
133
+ isRtl
134
+ }) => isLandscape && toolbarVariant !== 'desktop' && isRtl,
135
+ style: {
136
+ flexDirection: 'column-reverse'
137
+ }
138
+ }]
131
139
  });
132
140
  const DateTimePickerToolbarTimeDigitsContainer = (0, _styles.styled)('div', {
133
141
  name: 'MuiDateTimePickerToolbar',
134
142
  slot: 'TimeDigitsContainer',
135
143
  overridesResolver: (props, styles) => styles.timeDigitsContainer
136
- })(({
137
- theme
138
- }) => (0, _extends2.default)({
139
- display: 'flex'
140
- }, theme.direction === 'rtl' && {
141
- flexDirection: 'row-reverse'
142
- }, {
144
+ })({
145
+ display: 'flex',
143
146
  variants: [{
147
+ props: {
148
+ isRtl: true
149
+ },
150
+ style: {
151
+ flexDirection: 'row-reverse'
152
+ }
153
+ }, {
144
154
  props: {
145
155
  toolbarVariant: 'desktop'
146
156
  },
@@ -148,7 +158,7 @@ const DateTimePickerToolbarTimeDigitsContainer = (0, _styles.styled)('div', {
148
158
  gap: 1.5
149
159
  }
150
160
  }]
151
- }));
161
+ });
152
162
  const DateTimePickerToolbarSeparator = (0, _styles.styled)(_PickersToolbarText.PickersToolbarText, {
153
163
  name: 'MuiDateTimePickerToolbar',
154
164
  slot: 'Separator',
@@ -229,7 +239,10 @@ function DateTimePickerToolbar(inProps) {
229
239
  className
230
240
  } = props,
231
241
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
232
- const ownerState = props;
242
+ const isRtl = (0, _RtlProvider.useRtl)();
243
+ const ownerState = (0, _extends2.default)({}, props, {
244
+ isRtl
245
+ });
233
246
  const utils = (0, _useUtils.useUtils)();
234
247
  const {
235
248
  meridiemMode,
@@ -238,10 +251,7 @@ function DateTimePickerToolbar(inProps) {
238
251
  const showAmPmControl = Boolean(ampm && !ampmInClock);
239
252
  const isDesktop = toolbarVariant === 'desktop';
240
253
  const localeText = (0, _useUtils.useLocaleText)();
241
- const theme = (0, _styles.useTheme)();
242
- const classes = useUtilityClasses((0, _extends2.default)({}, ownerState, {
243
- theme
244
- }));
254
+ const classes = useUtilityClasses(ownerState);
245
255
  const toolbarTitle = inToolbarTitle ?? localeText.dateTimePickerToolbarTitle;
246
256
  const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
247
257
  const dateText = React.useMemo(() => {
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.DesktopDateTimePickerLayout = DesktopDateTimePickerLayout;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  var React = _interopRequireWildcard(require("react"));
9
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
11
  var _clsx = _interopRequireDefault(require("clsx"));
12
+ var _RtlProvider = require("@mui/system/RtlProvider");
11
13
  var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
12
14
  var _PickersLayout = require("../PickersLayout");
13
15
  var _jsxRuntime = require("react/jsx-runtime");
@@ -17,6 +19,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
17
19
  * @ignore - internal component.
18
20
  */
19
21
  function DesktopDateTimePickerLayout(props) {
22
+ const isRtl = (0, _RtlProvider.useRtl)();
20
23
  const {
21
24
  toolbar,
22
25
  tabs,
@@ -32,6 +35,9 @@ function DesktopDateTimePickerLayout(props) {
32
35
  classes
33
36
  } = props;
34
37
  const isActionBarVisible = actionBar && (actionBar.props.actions?.length ?? 0) > 0;
38
+ const ownerState = (0, _extends2.default)({}, props, {
39
+ isRtl
40
+ });
35
41
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PickersLayout.PickersLayoutRoot, {
36
42
  ref: ref,
37
43
  className: (0, _clsx.default)(className, _PickersLayout.pickersLayoutClasses.root, classes?.root),
@@ -44,7 +50,7 @@ function DesktopDateTimePickerLayout(props) {
44
50
  gridRow: 5
45
51
  }
46
52
  }, ...(Array.isArray(sx) ? sx : [sx])],
47
- ownerState: props,
53
+ ownerState: ownerState,
48
54
  children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PickersLayout.PickersLayoutContentWrapper, {
49
55
  className: (0, _clsx.default)(_PickersLayout.pickersLayoutClasses.contentWrapper, classes?.contentWrapper),
50
56
  sx: {
@@ -72,6 +78,10 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
72
78
  className: _propTypes.default.string,
73
79
  disabled: _propTypes.default.bool,
74
80
  isLandscape: _propTypes.default.bool.isRequired,
81
+ /**
82
+ * `true` if the application is in right-to-left direction.
83
+ */
84
+ isRtl: _propTypes.default.bool.isRequired,
75
85
  isValid: _propTypes.default.func.isRequired,
76
86
  onAccept: _propTypes.default.func.isRequired,
77
87
  onCancel: _propTypes.default.func.isRequired,
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _clsx = _interopRequireDefault(require("clsx"));
14
- var _system = require("@mui/system");
14
+ var _RtlProvider = require("@mui/system/RtlProvider");
15
15
  var _styles = require("@mui/material/styles");
16
16
  var _utils = require("@mui/utils");
17
17
  var _PickersMonth = require("./PickersMonth");
@@ -109,7 +109,7 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
109
109
  valueManager: _valueManagers.singleItemValueManager
110
110
  });
111
111
  const now = (0, _useUtils.useNow)(timezone);
112
- const theme = (0, _system.useTheme)();
112
+ const isRtl = (0, _RtlProvider.useRtl)();
113
113
  const utils = (0, _useUtils.useUtils)();
114
114
  const referenceDate = React.useMemo(() => _valueManagers.singleItemValueManager.getInitialReferenceValue({
115
115
  value,
@@ -189,11 +189,11 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
189
189
  event.preventDefault();
190
190
  break;
191
191
  case 'ArrowLeft':
192
- focusMonth((monthsInYear + month + (theme.direction === 'ltr' ? -1 : 1)) % monthsInYear);
192
+ focusMonth((monthsInYear + month + (isRtl ? 1 : -1)) % monthsInYear);
193
193
  event.preventDefault();
194
194
  break;
195
195
  case 'ArrowRight':
196
- focusMonth((monthsInYear + month + (theme.direction === 'ltr' ? 1 : -1)) % monthsInYear);
196
+ focusMonth((monthsInYear + month + (isRtl ? -1 : 1)) % monthsInYear);
197
197
  event.preventDefault();
198
198
  break;
199
199
  default:
@@ -30,9 +30,7 @@ const PickersLayoutRoot = exports.PickersLayoutRoot = (0, _styles.styled)('div',
30
30
  name: 'MuiPickersLayout',
31
31
  slot: 'Root',
32
32
  overridesResolver: (props, styles) => styles.root
33
- })(({
34
- theme
35
- }) => ({
33
+ })({
36
34
  display: 'grid',
37
35
  gridAutoColumns: 'max-content auto max-content',
38
36
  gridAutoRows: 'max-content auto max-content',
@@ -46,7 +44,7 @@ const PickersLayoutRoot = exports.PickersLayoutRoot = (0, _styles.styled)('div',
46
44
  },
47
45
  style: {
48
46
  [`& .${_pickersLayoutClasses.pickersLayoutClasses.toolbar}`]: {
49
- gridColumn: theme.direction === 'rtl' ? 3 : 1,
47
+ gridColumn: 1,
50
48
  gridRow: '2 / 3'
51
49
  },
52
50
  [`.${_pickersLayoutClasses.pickersLayoutClasses.shortcuts}`]: {
@@ -54,6 +52,16 @@ const PickersLayoutRoot = exports.PickersLayoutRoot = (0, _styles.styled)('div',
54
52
  gridRow: 1
55
53
  }
56
54
  }
55
+ }, {
56
+ props: {
57
+ isLandscape: true,
58
+ isRtl: true
59
+ },
60
+ style: {
61
+ [`& .${_pickersLayoutClasses.pickersLayoutClasses.toolbar}`]: {
62
+ gridColumn: 3
63
+ }
64
+ }
57
65
  }, {
58
66
  props: {
59
67
  isLandscape: false
@@ -64,12 +72,22 @@ const PickersLayoutRoot = exports.PickersLayoutRoot = (0, _styles.styled)('div',
64
72
  gridRow: 1
65
73
  },
66
74
  [`& .${_pickersLayoutClasses.pickersLayoutClasses.shortcuts}`]: {
67
- gridColumn: theme.direction === 'rtl' ? 3 : 1,
75
+ gridColumn: 1,
68
76
  gridRow: '2 / 3'
69
77
  }
70
78
  }
79
+ }, {
80
+ props: {
81
+ isLandscape: false,
82
+ isRtl: true
83
+ },
84
+ style: {
85
+ [`& .${_pickersLayoutClasses.pickersLayoutClasses.shortcuts}`]: {
86
+ gridColumn: 3
87
+ }
88
+ }
71
89
  }]
72
- }));
90
+ });
73
91
  const PickersLayoutContentWrapper = exports.PickersLayoutContentWrapper = (0, _styles.styled)('div', {
74
92
  name: 'MuiPickersLayout',
75
93
  slot: 'ContentWrapper',
@@ -109,13 +127,12 @@ const PickersLayout = exports.PickersLayout = function PickersLayout(inProps) {
109
127
  ref,
110
128
  wrapperVariant
111
129
  } = props;
112
- const ownerState = props;
113
- const classes = useUtilityClasses(ownerState);
130
+ const classes = useUtilityClasses(props);
114
131
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersLayoutRoot, {
115
132
  ref: ref,
116
133
  sx: sx,
117
134
  className: (0, _clsx.default)(className, classes.root),
118
- ownerState: ownerState,
135
+ ownerState: props,
119
136
  children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersLayoutContentWrapper, {
120
137
  className: classes.contentWrapper,
121
138
  children: wrapperVariant === 'desktop' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
@@ -139,6 +156,10 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
139
156
  className: _propTypes.default.string,
140
157
  disabled: _propTypes.default.bool,
141
158
  isLandscape: _propTypes.default.bool.isRequired,
159
+ /**
160
+ * `true` if the application is in right-to-left direction.
161
+ */
162
+ isRtl: _propTypes.default.bool.isRequired,
142
163
  isValid: _propTypes.default.func.isRequired,
143
164
  onAccept: _propTypes.default.func.isRequired,
144
165
  onCancel: _propTypes.default.func.isRequired,
@@ -17,6 +17,7 @@ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"
17
17
  var _capitalize = _interopRequireDefault(require("@mui/utils/capitalize"));
18
18
  var _utils2 = require("@mui/base/utils");
19
19
  var _visuallyHidden = _interopRequireDefault(require("@mui/utils/visuallyHidden"));
20
+ var _RtlProvider = require("@mui/system/RtlProvider");
20
21
  var _pickersInputBaseClasses = require("./pickersInputBaseClasses");
21
22
  var _PickersSectionList = require("../../PickersSectionList");
22
23
  var _jsxRuntime = require("react/jsx-runtime");
@@ -56,7 +57,7 @@ const PickersInputBaseSectionsContainer = exports.PickersInputBaseSectionsContai
56
57
  overridesResolver: (props, styles) => styles.sectionsContainer
57
58
  })(({
58
59
  theme
59
- }) => (0, _extends2.default)({
60
+ }) => ({
60
61
  padding: '4px 0 5px',
61
62
  fontFamily: theme.typography.fontFamily,
62
63
  fontSize: 'inherit',
@@ -69,11 +70,15 @@ const PickersInputBaseSectionsContainer = exports.PickersInputBaseSectionsContai
69
70
  overflow: 'hidden',
70
71
  letterSpacing: 'inherit',
71
72
  // Baseline behavior
72
- width: '182px'
73
- }, theme.direction === 'rtl' && {
74
- textAlign: 'right /*! @noflip */'
75
- }, {
73
+ width: '182px',
76
74
  variants: [{
75
+ props: {
76
+ isRtl: true
77
+ },
78
+ style: {
79
+ textAlign: 'right /*! @noflip */'
80
+ }
81
+ }, {
77
82
  props: {
78
83
  size: 'small'
79
84
  },
@@ -204,6 +209,7 @@ const PickersInputBase = exports.PickersInputBase = /*#__PURE__*/React.forwardRe
204
209
  const rootRef = React.useRef(null);
205
210
  const handleRootRef = (0, _useForkRef.default)(ref, rootRef);
206
211
  const handleInputRef = (0, _useForkRef.default)(inputProps?.ref, inputRef);
212
+ const isRtl = (0, _RtlProvider.useRtl)();
207
213
  const muiFormControl = (0, _FormControl.useFormControl)();
208
214
  if (!muiFormControl) {
209
215
  throw new Error('MUI X: PickersInputBase should always be used inside a PickersTextField component');
@@ -232,7 +238,9 @@ const PickersInputBase = exports.PickersInputBase = /*#__PURE__*/React.forwardRe
232
238
  muiFormControl.onFilled();
233
239
  }
234
240
  }, [muiFormControl, areAllSectionsEmpty]);
235
- const ownerState = (0, _extends2.default)({}, props, muiFormControl);
241
+ const ownerState = (0, _extends2.default)({}, props, muiFormControl, {
242
+ isRtl
243
+ });
236
244
  const classes = useUtilityClasses(ownerState);
237
245
  const InputRoot = slots?.root || PickersInputBaseRoot;
238
246
  const inputRootProps = (0, _utils2.useSlotProps)({