@mui/x-date-pickers 8.0.0-alpha.1 → 8.0.0-alpha.3

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 (165) hide show
  1. package/AdapterMoment/AdapterMoment.js +10 -0
  2. package/CHANGELOG.md +330 -7
  3. package/DateCalendar/DateCalendar.types.d.ts +2 -1
  4. package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  5. package/DateCalendar/PickersSlideTransition.js +12 -5
  6. package/DateCalendar/useCalendarState.d.ts +6 -4
  7. package/DateField/DateField.js +5 -4
  8. package/DateField/DateField.types.d.ts +10 -9
  9. package/DatePicker/DatePicker.types.d.ts +3 -3
  10. package/DatePicker/DatePickerToolbar.d.ts +3 -2
  11. package/DatePicker/shared.d.ts +6 -5
  12. package/DateTimeField/DateTimeField.js +5 -4
  13. package/DateTimeField/DateTimeField.types.d.ts +10 -10
  14. package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  15. package/DateTimePicker/DateTimePickerTabs.js +8 -6
  16. package/DateTimePicker/DateTimePickerToolbar.d.ts +2 -3
  17. package/DateTimePicker/shared.d.ts +6 -6
  18. package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  19. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
  20. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -21
  21. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
  22. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
  23. package/PickersActionBar/PickersActionBar.js +8 -1
  24. package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  25. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
  26. package/PickersLayout/PickersLayout.d.ts +7 -5
  27. package/PickersLayout/PickersLayout.js +22 -27
  28. package/PickersLayout/PickersLayout.types.d.ts +14 -15
  29. package/PickersLayout/usePickerLayout.d.ts +5 -4
  30. package/PickersLayout/usePickerLayout.js +19 -12
  31. package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
  32. package/PickersShortcuts/PickersShortcuts.js +8 -1
  33. package/README.md +7 -4
  34. package/TimeField/TimeField.js +5 -4
  35. package/TimeField/TimeField.types.d.ts +10 -10
  36. package/TimePicker/TimePicker.types.d.ts +3 -3
  37. package/TimePicker/TimePickerToolbar.d.ts +2 -3
  38. package/TimePicker/shared.d.ts +6 -6
  39. package/hooks/useParsedFormat.d.ts +2 -2
  40. package/hooks/useParsedFormat.js +1 -1
  41. package/index.js +1 -1
  42. package/internals/components/PickerProvider.d.ts +2 -15
  43. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  44. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
  45. package/internals/components/PickersToolbar.d.ts +3 -3
  46. package/internals/hooks/useClockReferenceDate.d.ts +2 -1
  47. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
  48. package/internals/hooks/useField/useField.d.ts +3 -3
  49. package/internals/hooks/useField/useField.types.d.ts +45 -45
  50. package/internals/hooks/useField/useField.utils.d.ts +4 -3
  51. package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
  52. package/internals/hooks/useField/useFieldState.d.ts +9 -8
  53. package/internals/hooks/useField/useFieldState.js +0 -1
  54. package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
  55. package/internals/hooks/useFieldOwnerState.d.ts +6 -0
  56. package/internals/hooks/useFieldOwnerState.js +12 -0
  57. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
  58. package/internals/hooks/useOpenState.d.ts +3 -2
  59. package/internals/hooks/useOpenState.js +10 -9
  60. package/internals/hooks/usePicker/usePicker.d.ts +3 -3
  61. package/internals/hooks/usePicker/usePicker.js +4 -10
  62. package/internals/hooks/usePicker/usePicker.types.d.ts +7 -7
  63. package/internals/hooks/usePicker/usePickerProvider.d.ts +5 -6
  64. package/internals/hooks/usePicker/usePickerProvider.js +8 -10
  65. package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
  66. package/internals/hooks/usePicker/usePickerValue.js +22 -12
  67. package/internals/hooks/usePicker/usePickerValue.types.d.ts +51 -24
  68. package/internals/hooks/usePicker/usePickerViews.d.ts +10 -10
  69. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
  70. package/internals/hooks/useValueWithTimezone.d.ts +5 -4
  71. package/internals/hooks/useViews.d.ts +5 -5
  72. package/internals/index.d.ts +4 -2
  73. package/internals/index.js +1 -0
  74. package/internals/models/fields.d.ts +6 -1
  75. package/internals/models/pickers.d.ts +1 -0
  76. package/internals/models/pickers.js +1 -0
  77. package/internals/models/props/basePickerProps.d.ts +4 -3
  78. package/internals/models/props/time.d.ts +2 -1
  79. package/internals/models/props/toolbar.d.ts +2 -1
  80. package/internals/models/value.d.ts +9 -0
  81. package/internals/utils/date-utils.d.ts +1 -1
  82. package/internals/utils/valueManagers.d.ts +4 -3
  83. package/locales/nlNL.js +7 -7
  84. package/models/adapters.d.ts +4 -4
  85. package/models/fields.d.ts +19 -5
  86. package/models/validation.d.ts +2 -1
  87. package/modern/AdapterMoment/AdapterMoment.js +10 -0
  88. package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  89. package/modern/DateCalendar/PickersSlideTransition.js +12 -5
  90. package/modern/DateField/DateField.js +5 -4
  91. package/modern/DateTimeField/DateTimeField.js +5 -4
  92. package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
  93. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  94. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -21
  95. package/modern/PickersActionBar/PickersActionBar.js +8 -1
  96. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  97. package/modern/PickersLayout/PickersLayout.js +22 -27
  98. package/modern/PickersLayout/usePickerLayout.js +19 -12
  99. package/modern/PickersShortcuts/PickersShortcuts.js +8 -1
  100. package/modern/TimeField/TimeField.js +5 -4
  101. package/modern/hooks/useParsedFormat.js +1 -1
  102. package/modern/index.js +1 -1
  103. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  104. package/modern/internals/hooks/useField/useFieldState.js +0 -1
  105. package/modern/internals/hooks/useFieldOwnerState.js +12 -0
  106. package/modern/internals/hooks/useOpenState.js +10 -9
  107. package/modern/internals/hooks/usePicker/usePicker.js +4 -10
  108. package/modern/internals/hooks/usePicker/usePickerProvider.js +8 -10
  109. package/modern/internals/hooks/usePicker/usePickerValue.js +22 -12
  110. package/modern/internals/index.js +1 -0
  111. package/modern/internals/models/pickers.js +1 -0
  112. package/modern/locales/nlNL.js +7 -7
  113. package/modern/validation/useValidation.js +1 -1
  114. package/modern/validation/validateDate.js +8 -0
  115. package/modern/validation/validateDateTime.js +8 -0
  116. package/modern/validation/validateTime.js +8 -0
  117. package/node/AdapterMoment/AdapterMoment.js +10 -0
  118. package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  119. package/node/DateCalendar/PickersSlideTransition.js +12 -5
  120. package/node/DateField/DateField.js +5 -4
  121. package/node/DateTimeField/DateTimeField.js +5 -4
  122. package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
  123. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  124. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -22
  125. package/node/PickersActionBar/PickersActionBar.js +8 -1
  126. package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  127. package/node/PickersLayout/PickersLayout.js +22 -27
  128. package/node/PickersLayout/usePickerLayout.js +19 -12
  129. package/node/PickersShortcuts/PickersShortcuts.js +8 -1
  130. package/node/TimeField/TimeField.js +5 -4
  131. package/node/hooks/useParsedFormat.js +1 -1
  132. package/node/index.js +1 -1
  133. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  134. package/node/internals/hooks/useField/useFieldState.js +0 -1
  135. package/node/internals/hooks/useFieldOwnerState.js +20 -0
  136. package/node/internals/hooks/useOpenState.js +10 -9
  137. package/node/internals/hooks/usePicker/usePicker.js +5 -10
  138. package/node/internals/hooks/usePicker/usePickerProvider.js +9 -11
  139. package/node/internals/hooks/usePicker/usePickerValue.js +22 -11
  140. package/node/internals/index.js +7 -0
  141. package/node/internals/models/pickers.js +5 -0
  142. package/node/locales/nlNL.js +7 -7
  143. package/node/validation/useValidation.js +1 -1
  144. package/node/validation/validateDate.js +8 -0
  145. package/node/validation/validateDateTime.js +8 -0
  146. package/node/validation/validateTime.js +8 -0
  147. package/package.json +2 -2
  148. package/themeAugmentation/overrides.d.ts +1 -1
  149. package/themeAugmentation/props.d.ts +3 -2
  150. package/validation/useValidation.d.ts +7 -6
  151. package/validation/useValidation.js +1 -1
  152. package/validation/validateDate.d.ts +12 -3
  153. package/validation/validateDate.js +8 -0
  154. package/validation/validateDateTime.d.ts +12 -4
  155. package/validation/validateDateTime.js +8 -0
  156. package/validation/validateTime.d.ts +12 -3
  157. package/validation/validateTime.js +8 -0
  158. package/internals/hooks/useIsLandscape.d.ts +0 -4
  159. package/internals/hooks/useIsLandscape.js +0 -35
  160. package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -32
  161. package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
  162. package/modern/internals/hooks/useIsLandscape.js +0 -35
  163. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
  164. package/node/internals/hooks/useIsLandscape.js +0 -43
  165. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -38
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["className"];
5
+ const _excluded = ["className", "classes"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -12,10 +12,7 @@ import composeClasses from '@mui/utils/composeClasses';
12
12
  import { DAY_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
13
13
  import { getDayCalendarSkeletonUtilityClass } from "./dayCalendarSkeletonClasses.js";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
- const useUtilityClasses = ownerState => {
16
- const {
17
- classes
18
- } = ownerState;
15
+ const useUtilityClasses = classes => {
19
16
  const slots = {
20
17
  root: ['root'],
21
18
  week: ['week'],
@@ -45,14 +42,9 @@ const DayCalendarSkeletonDay = styled(Skeleton, {
45
42
  overridesResolver: (props, styles) => styles.daySkeleton
46
43
  })({
47
44
  margin: `0 ${DAY_MARGIN}px`,
48
- variants: [{
49
- props: {
50
- day: 0
51
- },
52
- style: {
53
- visibility: 'hidden'
54
- }
55
- }]
45
+ '&[data-day-in-month="0"]': {
46
+ visibility: 'hidden'
47
+ }
56
48
  });
57
49
  const monthMap = [[0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 0]];
58
50
 
@@ -71,23 +63,22 @@ function DayCalendarSkeleton(inProps) {
71
63
  name: 'MuiDayCalendarSkeleton'
72
64
  });
73
65
  const {
74
- className
66
+ className,
67
+ classes: classesProp
75
68
  } = props,
76
69
  other = _objectWithoutPropertiesLoose(props, _excluded);
77
- const classes = useUtilityClasses(other);
70
+ const classes = useUtilityClasses(classesProp);
78
71
  return /*#__PURE__*/_jsx(DayCalendarSkeletonRoot, _extends({
79
72
  className: clsx(classes.root, className)
80
73
  }, other, {
81
74
  children: monthMap.map((week, index) => /*#__PURE__*/_jsx(DayCalendarSkeletonWeek, {
82
75
  className: classes.week,
83
- children: week.map((day, index2) => /*#__PURE__*/_jsx(DayCalendarSkeletonDay, {
76
+ children: week.map((dayInMonth, index2) => /*#__PURE__*/_jsx(DayCalendarSkeletonDay, {
84
77
  variant: "circular",
85
78
  width: DAY_SIZE,
86
79
  height: DAY_SIZE,
87
80
  className: classes.daySkeleton,
88
- ownerState: {
89
- day
90
- }
81
+ "data-day-in-month": dayInMonth
91
82
  }, index2))
92
83
  }, index))
93
84
  }));
@@ -1,33 +1,31 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import * as React from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import clsx from 'clsx';
5
- import { useRtl } from '@mui/system/RtlProvider';
6
4
  import Divider from '@mui/material/Divider';
7
5
  import { PickersLayoutContentWrapper, PickersLayoutRoot, pickersLayoutClasses, usePickerLayout } from "../PickersLayout/index.js";
6
+ import { usePickerContext } from "../hooks/usePickerContext.js";
8
7
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
8
  /**
10
9
  * @ignore - internal component.
11
10
  */
12
11
  const DesktopDateTimePickerLayout = /*#__PURE__*/React.forwardRef(function DesktopDateTimePickerLayout(props, ref) {
13
- const isRtl = useRtl();
14
12
  const {
15
13
  toolbar,
16
14
  tabs,
17
15
  content,
18
16
  actionBar,
19
- shortcuts
17
+ shortcuts,
18
+ ownerState
20
19
  } = usePickerLayout(props);
20
+ const {
21
+ orientation
22
+ } = usePickerContext();
21
23
  const {
22
24
  sx,
23
25
  className,
24
- isLandscape,
25
26
  classes
26
27
  } = props;
27
28
  const isActionBarVisible = actionBar && (actionBar.props.actions?.length ?? 0) > 0;
28
- const ownerState = _extends({}, props, {
29
- isRtl
30
- });
31
29
  return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
32
30
  ref: ref,
33
31
  className: clsx(pickersLayoutClasses.root, classes?.root, className),
@@ -41,8 +39,9 @@ const DesktopDateTimePickerLayout = /*#__PURE__*/React.forwardRef(function Deskt
41
39
  }
42
40
  }, ...(Array.isArray(sx) ? sx : [sx])],
43
41
  ownerState: ownerState,
44
- children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsxs(PickersLayoutContentWrapper, {
42
+ children: [orientation === 'landscape' ? shortcuts : toolbar, orientation === 'landscape' ? toolbar : shortcuts, /*#__PURE__*/_jsxs(PickersLayoutContentWrapper, {
45
43
  className: clsx(pickersLayoutClasses.contentWrapper, classes?.contentWrapper),
44
+ ownerState: ownerState,
46
45
  sx: {
47
46
  display: 'grid'
48
47
  },
@@ -66,11 +65,6 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
66
65
  */
67
66
  classes: PropTypes.object,
68
67
  className: PropTypes.string,
69
- isLandscape: PropTypes.bool.isRequired,
70
- /**
71
- * `true` if the application is in right-to-left direction.
72
- */
73
- isRtl: PropTypes.bool.isRequired,
74
68
  isValid: PropTypes.func.isRequired,
75
69
  onAccept: PropTypes.func.isRequired,
76
70
  onCancel: PropTypes.func.isRequired,
@@ -82,10 +76,6 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
82
76
  onSelectShortcut: PropTypes.func.isRequired,
83
77
  onSetToday: PropTypes.func.isRequired,
84
78
  onViewChange: PropTypes.func.isRequired,
85
- /**
86
- * Force rendering in particular orientation.
87
- */
88
- orientation: PropTypes.oneOf(['landscape', 'portrait']),
89
79
  /**
90
80
  * The props used for each component slot.
91
81
  * @default {}
@@ -100,9 +90,8 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
100
90
  * The system prop that allows defining system overrides as well as additional CSS styles.
101
91
  */
102
92
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
103
- value: PropTypes.any,
93
+ value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),
104
94
  view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
105
- views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired,
106
- wrapperVariant: PropTypes.oneOf(['desktop', 'mobile'])
95
+ views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired
107
96
  } : void 0;
108
97
  export { DesktopDateTimePickerLayout };
@@ -5,10 +5,17 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
5
5
  const _excluded = ["onAccept", "onClear", "onCancel", "onSetToday", "actions"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
+ import { styled } from '@mui/material/styles';
8
9
  import Button from '@mui/material/Button';
9
10
  import DialogActions from '@mui/material/DialogActions';
10
11
  import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ const PickersActionBarRoot = styled(DialogActions, {
14
+ name: 'MuiPickersLayout',
15
+ slot: 'ActionBar',
16
+ overridesResolver: (_, styles) => styles.actionBar
17
+ })({});
18
+
12
19
  /**
13
20
  * Demos:
14
21
  *
@@ -58,7 +65,7 @@ function PickersActionBar(props) {
58
65
  return null;
59
66
  }
60
67
  });
61
- return /*#__PURE__*/_jsx(DialogActions, _extends({}, other, {
68
+ return /*#__PURE__*/_jsx(PickersActionBarRoot, _extends({}, other, {
62
69
  children: buttons
63
70
  }));
64
71
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["slots", "slotProps", "currentMonth", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onMonthChange", "onViewChange", "view", "reduceAnimations", "views", "labelId", "className", "timezone", "format"],
5
+ const _excluded = ["slots", "slotProps", "currentMonth", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onMonthChange", "onViewChange", "view", "reduceAnimations", "views", "labelId", "className", "classes", "timezone", "format"],
6
6
  _excluded2 = ["ownerState"];
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
@@ -19,11 +19,9 @@ import { ArrowDropDownIcon } from "../icons/index.js";
19
19
  import { PickersArrowSwitcher } from "../internals/components/PickersArrowSwitcher/index.js";
20
20
  import { usePreviousMonthDisabled, useNextMonthDisabled } from "../internals/hooks/date-helpers-hooks.js";
21
21
  import { getPickersCalendarHeaderUtilityClass, pickersCalendarHeaderClasses } from "./pickersCalendarHeaderClasses.js";
22
+ import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
22
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
- const useUtilityClasses = ownerState => {
24
- const {
25
- classes
26
- } = ownerState;
24
+ const useUtilityClasses = classes => {
27
25
  const slots = {
28
26
  root: ['root'],
29
27
  labelContainer: ['labelContainer'],
@@ -132,12 +130,15 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
132
130
  views,
133
131
  labelId,
134
132
  className,
133
+ classes: classesProp,
135
134
  timezone,
136
135
  format = `${utils.formats.month} ${utils.formats.year}`
137
136
  } = props,
138
137
  other = _objectWithoutPropertiesLoose(props, _excluded);
139
- const ownerState = props;
140
- const classes = useUtilityClasses(props);
138
+ const {
139
+ ownerState
140
+ } = usePickerPrivateContext();
141
+ const classes = useUtilityClasses(classesProp);
141
142
  const SwitchViewButton = slots?.switchViewButton ?? PickersCalendarHeaderSwitchViewButton;
142
143
  const switchViewButtonProps = useSlotProps({
143
144
  elementType: SwitchViewButton,
@@ -7,14 +7,14 @@ import { styled, useThemeProps } from '@mui/material/styles';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
8
  import { pickersLayoutClasses, getPickersLayoutUtilityClass } from "./pickersLayoutClasses.js";
9
9
  import usePickerLayout from "./usePickerLayout.js";
10
+ import { usePickerContext } from "../hooks/usePickerContext.js";
10
11
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
11
- const useUtilityClasses = ownerState => {
12
+ const useUtilityClasses = (classes, ownerState) => {
12
13
  const {
13
- isLandscape,
14
- classes
14
+ pickerOrientation
15
15
  } = ownerState;
16
16
  const slots = {
17
- root: ['root', isLandscape && 'landscape'],
17
+ root: ['root', pickerOrientation === 'landscape' && 'landscape'],
18
18
  contentWrapper: ['contentWrapper']
19
19
  };
20
20
  return composeClasses(slots, getPickersLayoutUtilityClass, classes);
@@ -33,7 +33,7 @@ export const PickersLayoutRoot = styled('div', {
33
33
  },
34
34
  variants: [{
35
35
  props: {
36
- isLandscape: true
36
+ pickerOrientation: 'landscape'
37
37
  },
38
38
  style: {
39
39
  [`& .${pickersLayoutClasses.toolbar}`]: {
@@ -47,7 +47,7 @@ export const PickersLayoutRoot = styled('div', {
47
47
  }
48
48
  }, {
49
49
  props: {
50
- isLandscape: true,
50
+ pickerOrientation: 'landscape',
51
51
  isRtl: true
52
52
  },
53
53
  style: {
@@ -57,7 +57,7 @@ export const PickersLayoutRoot = styled('div', {
57
57
  }
58
58
  }, {
59
59
  props: {
60
- isLandscape: false
60
+ pickerOrientation: 'portrait'
61
61
  },
62
62
  style: {
63
63
  [`& .${pickersLayoutClasses.toolbar}`]: {
@@ -71,7 +71,7 @@ export const PickersLayoutRoot = styled('div', {
71
71
  }
72
72
  }, {
73
73
  props: {
74
- isLandscape: false,
74
+ pickerOrientation: 'portrait',
75
75
  isRtl: true
76
76
  },
77
77
  style: {
@@ -110,23 +110,28 @@ const PickersLayout = /*#__PURE__*/React.forwardRef(function PickersLayout(inPro
110
110
  content,
111
111
  tabs,
112
112
  actionBar,
113
- shortcuts
113
+ shortcuts,
114
+ ownerState
114
115
  } = usePickerLayout(props);
116
+ const {
117
+ orientation,
118
+ variant
119
+ } = usePickerContext();
115
120
  const {
116
121
  sx,
117
122
  className,
118
- isLandscape,
119
- wrapperVariant
123
+ classes: classesProp
120
124
  } = props;
121
- const classes = useUtilityClasses(props);
125
+ const classes = useUtilityClasses(classesProp, ownerState);
122
126
  return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
123
127
  ref: ref,
124
128
  sx: sx,
125
129
  className: clsx(classes.root, className),
126
- ownerState: props,
127
- children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsx(PickersLayoutContentWrapper, {
130
+ ownerState: ownerState,
131
+ children: [orientation === 'landscape' ? shortcuts : toolbar, orientation === 'landscape' ? toolbar : shortcuts, /*#__PURE__*/_jsx(PickersLayoutContentWrapper, {
128
132
  className: classes.contentWrapper,
129
- children: wrapperVariant === 'desktop' ? /*#__PURE__*/_jsxs(React.Fragment, {
133
+ ownerState: ownerState,
134
+ children: variant === 'desktop' ? /*#__PURE__*/_jsxs(React.Fragment, {
130
135
  children: [content, tabs]
131
136
  }) : /*#__PURE__*/_jsxs(React.Fragment, {
132
137
  children: [tabs, content]
@@ -145,11 +150,6 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
145
150
  */
146
151
  classes: PropTypes.object,
147
152
  className: PropTypes.string,
148
- isLandscape: PropTypes.bool.isRequired,
149
- /**
150
- * `true` if the application is in right-to-left direction.
151
- */
152
- isRtl: PropTypes.bool.isRequired,
153
153
  isValid: PropTypes.func.isRequired,
154
154
  onAccept: PropTypes.func.isRequired,
155
155
  onCancel: PropTypes.func.isRequired,
@@ -161,10 +161,6 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
161
161
  onSelectShortcut: PropTypes.func.isRequired,
162
162
  onSetToday: PropTypes.func.isRequired,
163
163
  onViewChange: PropTypes.func.isRequired,
164
- /**
165
- * Force rendering in particular orientation.
166
- */
167
- orientation: PropTypes.oneOf(['landscape', 'portrait']),
168
164
  /**
169
165
  * The props used for each component slot.
170
166
  * @default {}
@@ -179,9 +175,8 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
179
175
  * The system prop that allows defining system overrides as well as additional CSS styles.
180
176
  */
181
177
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
182
- value: PropTypes.any,
178
+ value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),
183
179
  view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
184
- views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired,
185
- wrapperVariant: PropTypes.oneOf(['desktop', 'mobile'])
180
+ views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired
186
181
  } : void 0;
187
182
  export { PickersLayout };
@@ -4,20 +4,22 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import useSlotProps from '@mui/utils/useSlotProps';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
+ import { useRtl } from '@mui/system/RtlProvider';
7
8
  import { PickersActionBar } from "../PickersActionBar/index.js";
8
9
  import { getPickersLayoutUtilityClass } from "./pickersLayoutClasses.js";
9
10
  import { PickersShortcuts } from "../PickersShortcuts/index.js";
10
11
  import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
12
+ import { usePickerContext } from "../hooks/index.js";
11
13
  import { jsx as _jsx } from "react/jsx-runtime";
12
14
  function toolbarHasView(toolbarProps) {
13
15
  return toolbarProps.view !== null;
14
16
  }
15
17
  const useUtilityClasses = (classes, ownerState) => {
16
18
  const {
17
- isLandscape
19
+ pickerOrientation
18
20
  } = ownerState;
19
21
  const slots = {
20
- root: ['root', isLandscape && 'landscape'],
22
+ root: ['root', pickerOrientation === 'landscape' && 'landscape'],
21
23
  contentWrapper: ['contentWrapper'],
22
24
  toolbar: ['toolbar'],
23
25
  actionBar: ['actionBar'],
@@ -29,10 +31,14 @@ const useUtilityClasses = (classes, ownerState) => {
29
31
  };
30
32
  const usePickerLayout = props => {
31
33
  const {
32
- ownerState: pickersOwnerState
34
+ ownerState: pickerOwnerState
33
35
  } = usePickerPrivateContext();
34
36
  const {
35
- wrapperVariant,
37
+ variant,
38
+ orientation
39
+ } = usePickerContext();
40
+ const isRtl = useRtl();
41
+ const {
36
42
  onAccept,
37
43
  onClear,
38
44
  onCancel,
@@ -44,7 +50,6 @@ const usePickerLayout = props => {
44
50
  onChange,
45
51
  onSelectShortcut,
46
52
  isValid,
47
- isLandscape,
48
53
  children,
49
54
  slots,
50
55
  slotProps,
@@ -54,9 +59,8 @@ const usePickerLayout = props => {
54
59
  // - For pickers value: PickerValidDate | null
55
60
  // - For range pickers value: [PickerValidDate | null, PickerValidDate | null]
56
61
  } = props;
57
- const ownerState = _extends({}, pickersOwnerState, {
58
- wrapperVariant,
59
- isLandscape
62
+ const ownerState = _extends({}, pickerOwnerState, {
63
+ isRtl
60
64
  });
61
65
  const classes = useUtilityClasses(classesProp, ownerState);
62
66
 
@@ -70,7 +74,7 @@ const usePickerLayout = props => {
70
74
  onClear,
71
75
  onCancel,
72
76
  onSetToday,
73
- actions: wrapperVariant === 'desktop' ? [] : ['cancel', 'accept']
77
+ actions: variant === 'desktop' ? [] : ['cancel', 'accept']
74
78
  },
75
79
  className: classes.actionBar,
76
80
  ownerState
@@ -83,7 +87,8 @@ const usePickerLayout = props => {
83
87
  elementType: Toolbar,
84
88
  externalSlotProps: slotProps?.toolbar,
85
89
  additionalProps: {
86
- isLandscape,
90
+ isLandscape: orientation === 'landscape',
91
+ // Will be removed in a follow up PR?
87
92
  onChange,
88
93
  value,
89
94
  view,
@@ -113,7 +118,8 @@ const usePickerLayout = props => {
113
118
  externalSlotProps: slotProps?.shortcuts,
114
119
  additionalProps: {
115
120
  isValid,
116
- isLandscape,
121
+ isLandscape: orientation === 'landscape',
122
+ // Will be removed in a follow up PR?
117
123
  onChange: onSelectShortcut
118
124
  },
119
125
  className: classes.shortcuts,
@@ -125,7 +131,8 @@ const usePickerLayout = props => {
125
131
  content,
126
132
  tabs,
127
133
  actionBar,
128
- shortcuts
134
+ shortcuts,
135
+ ownerState
129
136
  };
130
137
  };
131
138
  export default usePickerLayout;
@@ -5,12 +5,19 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
5
5
  const _excluded = ["items", "changeImportance", "isLandscape", "onChange", "isValid"],
6
6
  _excluded2 = ["getValue"];
7
7
  import * as React from 'react';
8
+ import { styled } from '@mui/material/styles';
8
9
  import PropTypes from 'prop-types';
9
10
  import List from '@mui/material/List';
10
11
  import ListItem from '@mui/material/ListItem';
11
12
  import Chip from '@mui/material/Chip';
12
13
  import { VIEW_HEIGHT } from "../internals/constants/dimensions.js";
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
+ const PickersShortcutsRoot = styled(List, {
16
+ name: 'MuiPickersLayout',
17
+ slot: 'Shortcuts',
18
+ overridesResolver: (_, styles) => styles.shortcuts
19
+ })({});
20
+
14
21
  /**
15
22
  * Demos:
16
23
  *
@@ -47,7 +54,7 @@ function PickersShortcuts(props) {
47
54
  disabled: !isValid(newValue)
48
55
  });
49
56
  });
50
- return /*#__PURE__*/_jsx(List, _extends({
57
+ return /*#__PURE__*/_jsx(PickersShortcutsRoot, _extends({
51
58
  dense: true,
52
59
  sx: [{
53
60
  maxHeight: VIEW_HEIGHT,
@@ -13,6 +13,7 @@ import { useTimeField } from "./useTimeField.js";
13
13
  import { useClearableField } from "../hooks/index.js";
14
14
  import { PickersTextField } from "../PickersTextField/index.js";
15
15
  import { convertFieldResponseIntoMuiTextFieldProps } from "../internals/utils/convertFieldResponseIntoMuiTextFieldProps.js";
16
+ import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  /**
18
19
  * Demos:
@@ -36,7 +37,7 @@ const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, inRe
36
37
  inputProps
37
38
  } = themeProps,
38
39
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
40
+ const ownerState = useFieldOwnerState(themeProps);
40
41
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
42
  const textFieldProps = useSlotProps({
42
43
  elementType: TextField,
@@ -268,10 +269,10 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
268
269
  */
269
270
  shouldDisableTime: PropTypes.func,
270
271
  /**
271
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
272
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
272
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
273
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
273
274
  *
274
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
275
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
275
276
  *
276
277
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
277
278
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -8,7 +8,7 @@ import { getLocalizedDigits } from "../internals/hooks/useField/useField.utils.j
8
8
  import { usePickerTranslations } from "./usePickerTranslations.js";
9
9
  /**
10
10
  * Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
11
- * This format is localized (e.g: `AAAA` for the year with the French locale) and cannot be parsed by your date library.
11
+ * This format is localized (for example `AAAA` for the year with the French locale) and cannot be parsed by your date library.
12
12
  * @param {object} The parameters needed to build the placeholder.
13
13
  * @param {string} params.format Format of the date to use.
14
14
  * @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.0.0-alpha.1
2
+ * @mui/x-date-pickers v8.0.0-alpha.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel", "labelId"],
3
+ const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel", "labelId", "classes"],
4
4
  _excluded2 = ["ownerState"],
5
5
  _excluded3 = ["ownerState"];
6
6
  import * as React from 'react';
@@ -13,6 +13,7 @@ import useSlotProps from '@mui/utils/useSlotProps';
13
13
  import IconButton from '@mui/material/IconButton';
14
14
  import { ArrowLeftIcon, ArrowRightIcon } from "../../../icons/index.js";
15
15
  import { getPickersArrowSwitcherUtilityClass } from "./pickersArrowSwitcherClasses.js";
16
+ import { usePickerPrivateContext } from "../../hooks/usePickerPrivateContext.js";
16
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
18
  const PickersArrowSwitcherRoot = styled('div', {
18
19
  name: 'MuiPickersArrowSwitcher',
@@ -44,10 +45,7 @@ const PickersArrowSwitcherButton = styled(IconButton, {
44
45
  }
45
46
  }]
46
47
  });
47
- const useUtilityClasses = ownerState => {
48
- const {
49
- classes
50
- } = ownerState;
48
+ const useUtilityClasses = classes => {
51
49
  const slots = {
52
50
  root: ['root'],
53
51
  spacer: ['spacer'],
@@ -78,11 +76,14 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
78
76
  isPreviousHidden,
79
77
  onGoToPrevious,
80
78
  previousLabel,
81
- labelId
79
+ labelId,
80
+ classes: classesProp
82
81
  } = props,
83
82
  other = _objectWithoutPropertiesLoose(props, _excluded);
84
- const ownerState = props;
85
- const classes = useUtilityClasses(ownerState);
83
+ const {
84
+ ownerState
85
+ } = usePickerPrivateContext();
86
+ const classes = useUtilityClasses(classesProp);
86
87
  const nextProps = {
87
88
  isDisabled: isNextDisabled,
88
89
  isHidden: isNextHidden,
@@ -108,7 +109,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
108
109
  onClick: previousProps.goTo
109
110
  },
110
111
  ownerState: _extends({}, ownerState, {
111
- hidden: previousProps.isHidden
112
+ hidden: previousProps.isHidden ?? false
112
113
  }),
113
114
  className: clsx(classes.button, classes.previousIconButton)
114
115
  });
@@ -125,7 +126,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
125
126
  onClick: nextProps.goTo
126
127
  },
127
128
  ownerState: _extends({}, ownerState, {
128
- hidden: nextProps.isHidden
129
+ hidden: nextProps.isHidden ?? false
129
130
  }),
130
131
  className: clsx(classes.button, classes.nextIconButton)
131
132
  });
@@ -64,7 +64,6 @@ export const useFieldState = params => {
64
64
  const stateWithoutReferenceDate = {
65
65
  sections,
66
66
  value: valueFromTheOutside,
67
- referenceValue: valueManager.emptyValue,
68
67
  tempValueStrAndroid: null
69
68
  };
70
69
  const granularity = getSectionTypeGranularity(sections);
@@ -0,0 +1,12 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { usePickerPrivateContext } from "./usePickerPrivateContext.js";
4
+ export function useFieldOwnerState(parameters) {
5
+ const {
6
+ ownerState: pickerOwnerState
7
+ } = usePickerPrivateContext();
8
+ return React.useMemo(() => _extends({}, pickerOwnerState, {
9
+ isFieldDisabled: parameters.disabled ?? false,
10
+ isFieldReadOnly: parameters.readOnly ?? false
11
+ }), [pickerOwnerState, parameters.disabled, parameters.readOnly]);
12
+ }
@@ -5,7 +5,7 @@ export const useOpenState = ({
5
5
  onClose
6
6
  }) => {
7
7
  const isControllingOpenProp = React.useRef(typeof open === 'boolean').current;
8
- const [openState, setIsOpenState] = React.useState(false);
8
+ const [openState, setOpenState] = React.useState(false);
9
9
 
10
10
  // It is required to update inner state in useEffect in order to avoid situation when
11
11
  // Our component is not mounted yet, but `open` state is set to `true` (for example initially opened)
@@ -14,22 +14,23 @@ export const useOpenState = ({
14
14
  if (typeof open !== 'boolean') {
15
15
  throw new Error('You must not mix controlling and uncontrolled mode for `open` prop');
16
16
  }
17
- setIsOpenState(open);
17
+ setOpenState(open);
18
18
  }
19
19
  }, [isControllingOpenProp, open]);
20
- const setIsOpen = React.useCallback(newIsOpen => {
20
+ const setOpen = React.useCallback(action => {
21
+ const newOpen = typeof action === 'function' ? action(openState) : action;
21
22
  if (!isControllingOpenProp) {
22
- setIsOpenState(newIsOpen);
23
+ setOpenState(newOpen);
23
24
  }
24
- if (newIsOpen && onOpen) {
25
+ if (newOpen && onOpen) {
25
26
  onOpen();
26
27
  }
27
- if (!newIsOpen && onClose) {
28
+ if (!newOpen && onClose) {
28
29
  onClose();
29
30
  }
30
- }, [isControllingOpenProp, onOpen, onClose]);
31
+ }, [isControllingOpenProp, onOpen, onClose, openState]);
31
32
  return {
32
- isOpen: openState,
33
- setIsOpen
33
+ open: openState,
34
+ setOpen
34
35
  };
35
36
  };