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

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 (96) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/DateField/useDateField.d.ts +1 -1
  3. package/DatePicker/DatePickerToolbar.js +8 -9
  4. package/DateTimeField/useDateTimeField.d.ts +1 -1
  5. package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -2
  6. package/DateTimePicker/DateTimePickerToolbar.js +53 -39
  7. package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  8. package/DigitalClock/DigitalClock.js +13 -11
  9. package/DigitalClock/DigitalClock.types.d.ts +8 -2
  10. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
  11. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
  12. package/PickersLayout/PickersLayout.js +2 -2
  13. package/PickersLayout/PickersLayout.types.d.ts +4 -2
  14. package/PickersLayout/usePickerLayout.js +3 -3
  15. package/README.md +1 -1
  16. package/TimeClock/Clock.js +18 -21
  17. package/TimeClock/ClockNumber.js +15 -11
  18. package/TimeClock/ClockPointer.d.ts +6 -1
  19. package/TimeClock/ClockPointer.js +14 -10
  20. package/TimeClock/TimeClock.js +9 -8
  21. package/TimeField/useTimeField.d.ts +1 -1
  22. package/TimePicker/TimePickerToolbar.js +14 -17
  23. package/hooks/useClearableField.d.ts +5 -3
  24. package/hooks/useClearableField.js +4 -2
  25. package/index.js +1 -1
  26. package/internals/components/PickerProvider.d.ts +1 -1
  27. package/internals/components/PickersPopper.d.ts +11 -7
  28. package/internals/components/PickersPopper.js +18 -20
  29. package/internals/components/PickersToolbar.js +15 -12
  30. package/internals/components/PickersToolbarButton.js +4 -6
  31. package/internals/components/PickersToolbarText.js +11 -13
  32. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -2
  33. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +3 -2
  34. package/internals/hooks/usePicker/usePicker.js +3 -3
  35. package/internals/hooks/usePicker/usePicker.types.d.ts +3 -2
  36. package/internals/hooks/usePicker/usePickerProvider.d.ts +15 -4
  37. package/internals/hooks/usePicker/usePickerProvider.js +8 -4
  38. package/internals/hooks/usePicker/usePickerViews.d.ts +5 -15
  39. package/internals/hooks/usePicker/usePickerViews.js +5 -6
  40. package/internals/hooks/useToolbarOwnerState.d.ts +10 -0
  41. package/internals/hooks/useToolbarOwnerState.js +13 -0
  42. package/internals/index.d.ts +5 -1
  43. package/internals/index.js +3 -1
  44. package/internals/models/common.d.ts +1 -1
  45. package/locales/roRO.js +15 -18
  46. package/modern/DatePicker/DatePickerToolbar.js +8 -9
  47. package/modern/DateTimePicker/DateTimePickerToolbar.js +53 -39
  48. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  49. package/modern/DigitalClock/DigitalClock.js +13 -11
  50. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
  51. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
  52. package/modern/PickersLayout/PickersLayout.js +2 -2
  53. package/modern/PickersLayout/usePickerLayout.js +3 -3
  54. package/modern/TimeClock/Clock.js +18 -21
  55. package/modern/TimeClock/ClockNumber.js +15 -11
  56. package/modern/TimeClock/ClockPointer.js +14 -10
  57. package/modern/TimeClock/TimeClock.js +9 -8
  58. package/modern/TimePicker/TimePickerToolbar.js +14 -17
  59. package/modern/hooks/useClearableField.js +4 -2
  60. package/modern/index.js +1 -1
  61. package/modern/internals/components/PickersPopper.js +18 -20
  62. package/modern/internals/components/PickersToolbar.js +15 -12
  63. package/modern/internals/components/PickersToolbarButton.js +4 -6
  64. package/modern/internals/components/PickersToolbarText.js +11 -13
  65. package/modern/internals/hooks/usePicker/usePicker.js +3 -3
  66. package/modern/internals/hooks/usePicker/usePickerProvider.js +8 -4
  67. package/modern/internals/hooks/usePicker/usePickerViews.js +5 -6
  68. package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
  69. package/modern/internals/index.js +3 -1
  70. package/modern/locales/roRO.js +15 -18
  71. package/node/DatePicker/DatePickerToolbar.js +8 -9
  72. package/node/DateTimePicker/DateTimePickerToolbar.js +54 -39
  73. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  74. package/node/DigitalClock/DigitalClock.js +13 -11
  75. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
  76. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
  77. package/node/PickersLayout/PickersLayout.js +2 -2
  78. package/node/PickersLayout/usePickerLayout.js +3 -3
  79. package/node/TimeClock/Clock.js +18 -21
  80. package/node/TimeClock/ClockNumber.js +15 -11
  81. package/node/TimeClock/ClockPointer.js +14 -10
  82. package/node/TimeClock/TimeClock.js +9 -8
  83. package/node/TimePicker/TimePickerToolbar.js +14 -17
  84. package/node/hooks/useClearableField.js +4 -2
  85. package/node/index.js +1 -1
  86. package/node/internals/components/PickersPopper.js +18 -20
  87. package/node/internals/components/PickersToolbar.js +15 -12
  88. package/node/internals/components/PickersToolbarButton.js +4 -6
  89. package/node/internals/components/PickersToolbarText.js +10 -12
  90. package/node/internals/hooks/usePicker/usePicker.js +3 -3
  91. package/node/internals/hooks/usePicker/usePickerProvider.js +8 -4
  92. package/node/internals/hooks/usePicker/usePickerViews.js +5 -6
  93. package/node/internals/hooks/useToolbarOwnerState.js +21 -0
  94. package/node/internals/index.js +15 -1
  95. package/node/locales/roRO.js +15 -18
  96. package/package.json +1 -1
@@ -3,6 +3,8 @@ import { SlotComponentProps } from '@mui/utils';
3
3
  import MuiIconButton from '@mui/material/IconButton';
4
4
  import { SxProps } from '@mui/system';
5
5
  import { ClearIcon } from '../icons';
6
+ import { FieldOwnerState } from '../models/fields';
7
+ import { FormProps } from '../internals/models';
6
8
  export interface ExportedUseClearableFieldProps {
7
9
  /**
8
10
  * If `true`, a clear button will be shown in the field allowing value clearing.
@@ -27,10 +29,10 @@ export interface UseClearableFieldSlots {
27
29
  clearButton?: React.ElementType;
28
30
  }
29
31
  export interface UseClearableFieldSlotProps {
30
- clearIcon?: SlotComponentProps<typeof ClearIcon, {}, {}>;
31
- clearButton?: SlotComponentProps<typeof MuiIconButton, {}, {}>;
32
+ clearIcon?: SlotComponentProps<typeof ClearIcon, {}, FieldOwnerState>;
33
+ clearButton?: SlotComponentProps<typeof MuiIconButton, {}, FieldOwnerState>;
32
34
  }
33
- interface UseClearableFieldProps extends ExportedUseClearableFieldProps {
35
+ interface UseClearableFieldProps extends ExportedUseClearableFieldProps, FormProps {
34
36
  InputProps?: {
35
37
  endAdornment?: React.ReactNode;
36
38
  };
@@ -10,9 +10,11 @@ import MuiIconButton from '@mui/material/IconButton';
10
10
  import InputAdornment from '@mui/material/InputAdornment';
11
11
  import { ClearIcon } from "../icons/index.js";
12
12
  import { usePickerTranslations } from "./usePickerTranslations.js";
13
+ import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
13
14
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
15
  export const useClearableField = props => {
15
16
  const translations = usePickerTranslations();
17
+ const ownerState = useFieldOwnerState(props);
16
18
  const {
17
19
  clearable,
18
20
  onClear,
@@ -27,7 +29,7 @@ export const useClearableField = props => {
27
29
  const _useSlotProps = useSlotProps({
28
30
  elementType: IconButton,
29
31
  externalSlotProps: slotProps?.clearButton,
30
- ownerState: {},
32
+ ownerState,
31
33
  className: 'clearButton',
32
34
  additionalProps: {
33
35
  title: translations.fieldClearLabel,
@@ -39,7 +41,7 @@ export const useClearableField = props => {
39
41
  const endClearIconProps = useSlotProps({
40
42
  elementType: EndClearIcon,
41
43
  externalSlotProps: slotProps?.clearIcon,
42
- ownerState: {}
44
+ ownerState
43
45
  });
44
46
  return _extends({}, other, {
45
47
  InputProps: _extends({}, InputProps, {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.0.0-alpha.3
2
+ * @mui/x-date-pickers v8.0.0-alpha.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { PickerOwnerState } from '../../models';
3
3
  import { PickersInputLocaleText } from '../../locales';
4
4
  import { PickerOrientation, PickerVariant } from '../models';
5
- import { UsePickerValueContextValue } from '../hooks/usePicker/usePickerValue.types';
5
+ import type { UsePickerValueContextValue } from '../hooks/usePicker/usePickerValue.types';
6
6
  export declare const PickerContext: React.Context<PickerContextValue | null>;
7
7
  export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
8
8
  /**
@@ -1,13 +1,14 @@
1
1
  import * as React from 'react';
2
- import MuiPaper, { PaperProps as MuiPaperProps } from '@mui/material/Paper';
3
- import MuiPopper, { PopperProps as MuiPopperProps, PopperPlacementType } from '@mui/material/Popper';
2
+ import { PaperProps as MuiPaperProps, PaperProps } from '@mui/material/Paper';
3
+ import { PopperProps as MuiPopperProps, PopperPlacementType, PopperProps } from '@mui/material/Popper';
4
4
  import { TrapFocusProps as MuiTrapFocusProps } from '@mui/material/Unstable_TrapFocus';
5
- import { SlotComponentProps } from '@mui/utils';
6
5
  import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions';
6
+ import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
7
7
  import { PickersPopperClasses } from './pickersPopperClasses';
8
8
  import { UsePickerValueActions } from '../hooks/usePicker/usePickerValue.types';
9
- interface PickersPopperOwnerState extends PickerPopperProps {
10
- placement: PopperPlacementType;
9
+ import { PickerOwnerState } from '../../models';
10
+ interface PickerPopperOwnerState extends PickerOwnerState {
11
+ popperPlacement: PopperPlacementType;
11
12
  }
12
13
  export interface PickersPopperSlots {
13
14
  /**
@@ -35,7 +36,7 @@ export interface PickersPopperSlotProps {
35
36
  /**
36
37
  * Props passed down to the desktop [Paper](https://mui.com/material-ui/api/paper/) component.
37
38
  */
38
- desktopPaper?: SlotComponentProps<typeof MuiPaper, {}, PickersPopperOwnerState>;
39
+ desktopPaper?: SlotComponentPropsFromProps<PaperProps, {}, PickerPopperOwnerState>;
39
40
  /**
40
41
  * Props passed down to the desktop [Transition](https://mui.com/material-ui/transitions/) component.
41
42
  */
@@ -47,12 +48,15 @@ export interface PickersPopperSlotProps {
47
48
  /**
48
49
  * Props passed down to [Popper](https://mui.com/material-ui/api/popper/) component.
49
50
  */
50
- popper?: SlotComponentProps<typeof MuiPopper, {}, PickerPopperProps>;
51
+ popper?: SlotComponentPropsFromProps<PopperProps, {}, PickerPopperOwnerState>;
51
52
  }
52
53
  export interface PickerPopperProps extends UsePickerValueActions {
53
54
  role: 'tooltip' | 'dialog';
54
55
  anchorEl: MuiPopperProps['anchorEl'];
55
56
  open: MuiPopperProps['open'];
57
+ /**
58
+ * @default "bottom"
59
+ */
56
60
  placement?: MuiPopperProps['placement'];
57
61
  containerRef?: React.Ref<HTMLDivElement>;
58
62
  children?: React.ReactNode;
@@ -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 = ["PaperComponent", "popperPlacement", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
3
+ const _excluded = ["PaperComponent", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
4
4
  import * as React from 'react';
5
5
  import useSlotProps from '@mui/utils/useSlotProps';
6
6
  import Grow from '@mui/material/Grow';
@@ -13,11 +13,9 @@ import { styled, useThemeProps } from '@mui/material/styles';
13
13
  import { getPickersPopperUtilityClass } from "./pickersPopperClasses.js";
14
14
  import { getActiveElement } from "../utils/utils.js";
15
15
  import { useDefaultReduceAnimations } from "../hooks/useDefaultReduceAnimations.js";
16
+ import { usePickerPrivateContext } from "../hooks/usePickerPrivateContext.js";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
- const useUtilityClasses = ownerState => {
18
- const {
19
- classes
20
- } = ownerState;
18
+ const useUtilityClasses = classes => {
21
19
  const slots = {
22
20
  root: ['root'],
23
21
  paper: ['paper']
@@ -42,8 +40,8 @@ const PickersPopperPaper = styled(MuiPaper, {
42
40
  transformOrigin: 'top center',
43
41
  variants: [{
44
42
  props: ({
45
- placement
46
- }) => ['top', 'top-start', 'top-end'].includes(placement),
43
+ popperPlacement
44
+ }) => ['top', 'top-start', 'top-end'].includes(popperPlacement),
47
45
  style: {
48
46
  transformOrigin: 'bottom center'
49
47
  }
@@ -167,8 +165,7 @@ function useClickAwayListener(active, onClickAway) {
167
165
  const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
168
166
  const {
169
167
  PaperComponent,
170
- popperPlacement,
171
- ownerState: inOwnerState,
168
+ ownerState,
172
169
  children,
173
170
  paperSlotProps,
174
171
  paperClasses,
@@ -178,9 +175,6 @@ const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) =>
178
175
  // https://mui.com/material-ui/transitions/#child-requirement
179
176
  } = props,
180
177
  other = _objectWithoutPropertiesLoose(props, _excluded);
181
- const ownerState = _extends({}, inOwnerState, {
182
- placement: popperPlacement
183
- });
184
178
  const paperProps = useSlotProps({
185
179
  elementType: PaperComponent,
186
180
  externalSlotProps: paperSlotProps,
@@ -219,10 +213,11 @@ export function PickersPopper(inProps) {
219
213
  onDismiss,
220
214
  open,
221
215
  role,
222
- placement,
216
+ placement = 'bottom',
223
217
  slots,
224
218
  slotProps,
225
- reduceAnimations: inReduceAnimations
219
+ reduceAnimations: inReduceAnimations,
220
+ classes: classesProp
226
221
  } = props;
227
222
  React.useEffect(() => {
228
223
  function handleKeyDown(nativeEvent) {
@@ -256,10 +251,15 @@ export function PickersPopper(inProps) {
256
251
  const paperRef = React.useRef(null);
257
252
  const handleRef = useForkRef(paperRef, containerRef);
258
253
  const handlePaperRef = useForkRef(handleRef, clickAwayRef);
259
- const ownerState = props;
260
- const classes = useUtilityClasses(ownerState);
254
+ const classes = useUtilityClasses(classesProp);
261
255
  const defaultReduceAnimations = useDefaultReduceAnimations();
262
256
  const reduceAnimations = inReduceAnimations ?? defaultReduceAnimations;
257
+ const {
258
+ ownerState: pickerOwnerState
259
+ } = usePickerPrivateContext();
260
+ const ownerState = _extends({}, pickerOwnerState, {
261
+ popperPlacement: placement
262
+ });
263
263
  const handleKeyDown = event => {
264
264
  if (event.key === 'Escape') {
265
265
  // stop the propagation to avoid closing parent modal
@@ -283,12 +283,11 @@ export function PickersPopper(inProps) {
283
283
  onKeyDown: handleKeyDown
284
284
  },
285
285
  className: classes.root,
286
- ownerState: props
286
+ ownerState
287
287
  });
288
288
  return /*#__PURE__*/_jsx(Popper, _extends({}, popperProps, {
289
289
  children: ({
290
- TransitionProps,
291
- placement: popperPlacement
290
+ TransitionProps
292
291
  }) => /*#__PURE__*/_jsx(FocusTrap, _extends({
293
292
  open: open,
294
293
  disableAutoFocus: true
@@ -304,7 +303,6 @@ export function PickersPopper(inProps) {
304
303
  children: /*#__PURE__*/_jsx(PickersPopperPaperWrapper, {
305
304
  PaperComponent: Paper,
306
305
  ownerState: ownerState,
307
- popperPlacement: popperPlacement,
308
306
  ref: handlePaperRef,
309
307
  onPaperClick: onPaperClick,
310
308
  onPaperTouchStart: onPaperTouchStart,
@@ -1,17 +1,16 @@
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", "toolbarTitle", "hidden", "titleId", "isLandscape", "classes", "landscapeDirection"];
3
+ const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "isLandscape", "classes", "landscapeDirection"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import Typography from '@mui/material/Typography';
7
7
  import { styled, useThemeProps } from '@mui/material/styles';
8
8
  import composeClasses from '@mui/utils/composeClasses';
9
+ import { shouldForwardProp } from '@mui/system/createStyled';
9
10
  import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
11
+ import { useToolbarOwnerState } from "../hooks/useToolbarOwnerState.js";
10
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- const useUtilityClasses = ownerState => {
12
- const {
13
- classes
14
- } = ownerState;
13
+ const useUtilityClasses = classes => {
15
14
  const slots = {
16
15
  root: ['root'],
17
16
  content: ['content']
@@ -32,7 +31,7 @@ const PickersToolbarRoot = styled('div', {
32
31
  padding: theme.spacing(2, 3),
33
32
  variants: [{
34
33
  props: {
35
- isLandscape: true
34
+ pickerOrientation: 'landscape'
36
35
  },
37
36
  style: {
38
37
  height: 'auto',
@@ -46,7 +45,8 @@ const PickersToolbarRoot = styled('div', {
46
45
  const PickersToolbarContent = styled('div', {
47
46
  name: 'MuiPickersToolbar',
48
47
  slot: 'Content',
49
- overridesResolver: (props, styles) => styles.content
48
+ overridesResolver: (props, styles) => styles.content,
49
+ shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'landscapeDirection'
50
50
  })({
51
51
  display: 'flex',
52
52
  flexWrap: 'wrap',
@@ -57,7 +57,7 @@ const PickersToolbarContent = styled('div', {
57
57
  flexDirection: 'row',
58
58
  variants: [{
59
59
  props: {
60
- isLandscape: true
60
+ pickerOrientation: 'landscape'
61
61
  },
62
62
  style: {
63
63
  justifyContent: 'flex-start',
@@ -66,7 +66,7 @@ const PickersToolbarContent = styled('div', {
66
66
  }
67
67
  }, {
68
68
  props: {
69
- isLandscape: true,
69
+ pickerOrientation: 'landscape',
70
70
  landscapeDirection: 'row'
71
71
  },
72
72
  style: {
@@ -82,13 +82,15 @@ export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersTool
82
82
  const {
83
83
  children,
84
84
  className,
85
+ classes: classesProp,
85
86
  toolbarTitle,
86
87
  hidden,
87
- titleId
88
+ titleId,
89
+ landscapeDirection
88
90
  } = props,
89
91
  other = _objectWithoutPropertiesLoose(props, _excluded);
90
- const ownerState = props;
91
- const classes = useUtilityClasses(ownerState);
92
+ const ownerState = useToolbarOwnerState();
93
+ const classes = useUtilityClasses(classesProp);
92
94
  if (hidden) {
93
95
  return null;
94
96
  }
@@ -105,6 +107,7 @@ export const PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersTool
105
107
  }), /*#__PURE__*/_jsx(PickersToolbarContent, {
106
108
  className: classes.content,
107
109
  ownerState: ownerState,
110
+ landscapeDirection: landscapeDirection,
108
111
  children: children
109
112
  })]
110
113
  }));
@@ -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 = ["align", "className", "selected", "typographyClassName", "value", "variant", "width"];
3
+ const _excluded = ["align", "className", "classes", "selected", "typographyClassName", "value", "variant", "width"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import Button from '@mui/material/Button';
@@ -9,10 +9,7 @@ import composeClasses from '@mui/utils/composeClasses';
9
9
  import { PickersToolbarText } from "./PickersToolbarText.js";
10
10
  import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
- const useUtilityClasses = ownerState => {
13
- const {
14
- classes
15
- } = ownerState;
12
+ const useUtilityClasses = classes => {
16
13
  const slots = {
17
14
  root: ['root']
18
15
  };
@@ -35,6 +32,7 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
35
32
  const {
36
33
  align,
37
34
  className,
35
+ classes: classesProp,
38
36
  selected,
39
37
  typographyClassName,
40
38
  value,
@@ -42,7 +40,7 @@ export const PickersToolbarButton = /*#__PURE__*/React.forwardRef(function Picke
42
40
  width
43
41
  } = props,
44
42
  other = _objectWithoutPropertiesLoose(props, _excluded);
45
- const classes = useUtilityClasses(props);
43
+ const classes = useUtilityClasses(classesProp);
46
44
  return /*#__PURE__*/_jsx(PickersToolbarButtonRoot, _extends({
47
45
  variant: "text",
48
46
  ref: ref,
@@ -1,35 +1,29 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["className", "selected", "value"];
3
+ const _excluded = ["className", "classes", "selected", "value"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import Typography from '@mui/material/Typography';
7
7
  import { styled, useThemeProps } from '@mui/material/styles';
8
8
  import composeClasses from '@mui/utils/composeClasses';
9
- import { getPickersToolbarTextUtilityClass, pickersToolbarTextClasses } from "./pickersToolbarTextClasses.js";
9
+ import { getPickersToolbarTextUtilityClass } from "./pickersToolbarTextClasses.js";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- const useUtilityClasses = ownerState => {
12
- const {
13
- classes,
14
- selected
15
- } = ownerState;
11
+ const useUtilityClasses = classes => {
16
12
  const slots = {
17
- root: ['root', selected && 'selected']
13
+ root: ['root']
18
14
  };
19
15
  return composeClasses(slots, getPickersToolbarTextUtilityClass, classes);
20
16
  };
21
17
  const PickersToolbarTextRoot = styled(Typography, {
22
18
  name: 'MuiPickersToolbarText',
23
19
  slot: 'Root',
24
- overridesResolver: (_, styles) => [styles.root, {
25
- [`&.${pickersToolbarTextClasses.selected}`]: styles.selected
26
- }]
20
+ overridesResolver: (_, styles) => [styles.root]
27
21
  })(({
28
22
  theme
29
23
  }) => ({
30
24
  transition: theme.transitions.create('color'),
31
25
  color: (theme.vars || theme).palette.text.secondary,
32
- [`&.${pickersToolbarTextClasses.selected}`]: {
26
+ [`&[data-selected]`]: {
33
27
  color: (theme.vars || theme).palette.text.primary
34
28
  }
35
29
  }));
@@ -40,14 +34,18 @@ export const PickersToolbarText = /*#__PURE__*/React.forwardRef(function Pickers
40
34
  });
41
35
  const {
42
36
  className,
37
+ classes: classesProp,
38
+ selected,
43
39
  value
44
40
  } = props,
45
41
  other = _objectWithoutPropertiesLoose(props, _excluded);
46
- const classes = useUtilityClasses(props);
42
+ const classes = useUtilityClasses(classesProp);
47
43
  return /*#__PURE__*/_jsx(PickersToolbarTextRoot, _extends({
48
44
  ref: ref,
49
45
  className: clsx(classes.root, className),
50
46
  component: "span"
47
+ }, selected && {
48
+ 'data-selected': true
51
49
  }, other, {
52
50
  children: value
53
51
  }));
@@ -9,10 +9,11 @@ import { UsePickerParams } from '../usePicker';
9
9
  import { FieldOwnerState, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
10
10
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
11
11
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
12
- import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
12
+ import { UsePickerViewsProps } from '../usePicker/usePickerViews';
13
13
  import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
14
14
  import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '../../../hooks/useClearableField';
15
15
  import { PickersTextFieldProps } from '../../../PickersTextField';
16
+ import { UsePickerProviderNonStaticProps } from '../usePicker/usePickerProvider';
16
17
  export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem> extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue, TView>, UseClearableFieldSlots {
17
18
  /**
18
19
  * Component used to enter the date with the keyboard.
@@ -47,7 +48,7 @@ export interface ExportedUseDesktopPickerSlotProps<TView extends DateOrTimeViewW
47
48
  openPickerButton?: SlotComponentPropsFromProps<IconButtonProps, {}, PickerOwnerState>;
48
49
  openPickerIcon?: SlotComponentPropsFromProps<Record<string, any>, {}, PickerOwnerState>;
49
50
  }
50
- export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps {
51
+ export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps {
51
52
  /**
52
53
  * If `true`, the `input` element is focused during the first mount.
53
54
  * @default false
@@ -7,9 +7,10 @@ import { UsePickerParams } from '../usePicker';
7
7
  import { FieldOwnerState, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
8
8
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
9
9
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
10
- import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
10
+ import { UsePickerViewsProps } from '../usePicker/usePickerViews';
11
11
  import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
12
12
  import { PickersTextFieldProps } from '../../../PickersTextField';
13
+ import { UsePickerProviderNonStaticProps } from '../usePicker/usePickerProvider';
13
14
  export interface UseMobilePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerValue, TView> {
14
15
  /**
15
16
  * Component used to enter the date with the keyboard.
@@ -27,7 +28,7 @@ export interface ExportedUseMobilePickerSlotProps<TView extends DateOrTimeViewWi
27
28
  }
28
29
  export interface UseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue, TView>, 'toolbar'> {
29
30
  }
30
- export interface MobileOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps {
31
+ export interface MobileOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps {
31
32
  }
32
33
  export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps, {}>, MakeRequired<MobileOnlyPickerProps, 'format'> {
33
34
  /**
@@ -40,8 +40,8 @@ export const usePicker = ({
40
40
  localeText,
41
41
  valueManager,
42
42
  variant,
43
- views: pickerViewsResponse.views,
44
- paramsFromUsePickerValue: pickerValueResponse.provider
43
+ paramsFromUsePickerValue: pickerValueResponse.provider,
44
+ paramsFromUsePickerViews: pickerViewsResponse.provider
45
45
  });
46
46
  return {
47
47
  // Picker value
@@ -50,7 +50,7 @@ export const usePicker = ({
50
50
  fieldProps: pickerValueResponse.fieldProps,
51
51
  // Picker views
52
52
  renderCurrentView: pickerViewsResponse.renderCurrentView,
53
- hasUIView: pickerViewsResponse.hasUIView,
53
+ hasUIView: pickerViewsResponse.provider.hasUIView,
54
54
  shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
55
55
  // Picker layout
56
56
  layoutProps: _extends({}, pickerViewsResponse.layoutProps, pickerValueResponse.layoutProps),
@@ -10,11 +10,12 @@ export interface UsePickerBaseProps<TValue extends PickerValidValue, TView exten
10
10
  }
11
11
  export interface UsePickerProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TError>, UsePickerViewsProps<TValue, TView, TExternalProps, TAdditionalProps>, UsePickerProviderProps {
12
12
  }
13
- export interface UsePickerParams<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | 'variant' | 'validator'>, Pick<UsePickerViewParams<TValue, TView, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'autoFocusView' | 'rendererInterceptor' | 'fieldRef'>, Pick<UsePickerProviderParameters<TValue>, 'localeText'> {
13
+ export interface UsePickerParams<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | 'variant' | 'validator'>, Pick<UsePickerViewParams<TValue, TView, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'autoFocusView' | 'rendererInterceptor' | 'fieldRef'>, Pick<UsePickerProviderParameters<TValue, TView>, 'localeText'> {
14
14
  props: TExternalProps;
15
15
  }
16
- export interface UsePickerResponse<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Pick<UsePickerValueResponse<TValue, TError>, 'open' | 'actions' | 'fieldProps'>, Omit<UsePickerViewsResponse<TView>, 'layoutProps' | 'views'> {
16
+ export interface UsePickerResponse<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Pick<UsePickerValueResponse<TValue, TError>, 'open' | 'actions' | 'fieldProps'>, Pick<UsePickerViewsResponse<TView>, 'shouldRestoreFocus' | 'renderCurrentView'> {
17
17
  ownerState: PickerOwnerState;
18
18
  providerProps: UsePickerProviderReturnValue;
19
19
  layoutProps: UsePickerValueResponse<TValue, TError>['layoutProps'] & UsePickerViewsResponse<TView>['layoutProps'];
20
+ hasUIView: boolean;
20
21
  }
@@ -2,19 +2,20 @@ import { PickerValueManager, UsePickerValueProviderParams } from './usePickerVal
2
2
  import { PickerProviderProps } from '../../components/PickerProvider';
3
3
  import type { UsePickerProps } from './usePicker.types';
4
4
  import { DateOrTimeViewWithMeridiem, FormProps, PickerOrientation, PickerValidValue, PickerVariant } from '../../models';
5
+ import { UsePickerViewsProviderParams } from './usePickerViews';
5
6
  export declare const usePickerOrientation: (views: readonly DateOrTimeViewWithMeridiem[], customOrientation: PickerOrientation | undefined) => PickerOrientation;
6
- export declare function usePickerProvider<TValue extends PickerValidValue>(parameters: UsePickerProviderParameters<TValue>): UsePickerProviderReturnValue;
7
- export interface UsePickerProviderParameters<TValue extends PickerValidValue> extends Pick<PickerProviderProps, 'localeText'> {
7
+ export declare function usePickerProvider<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem>(parameters: UsePickerProviderParameters<TValue, TView>): UsePickerProviderReturnValue;
8
+ export interface UsePickerProviderParameters<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem> extends Pick<PickerProviderProps, 'localeText'> {
8
9
  props: UsePickerProps<TValue, any, any, any, any>;
9
10
  valueManager: PickerValueManager<TValue, any>;
10
11
  variant: PickerVariant;
11
- views: readonly DateOrTimeViewWithMeridiem[];
12
12
  paramsFromUsePickerValue: UsePickerValueProviderParams<TValue>;
13
+ paramsFromUsePickerViews: UsePickerViewsProviderParams<TView>;
13
14
  }
14
15
  export interface UsePickerProviderReturnValue extends Omit<PickerProviderProps, 'children'> {
15
16
  }
16
17
  /**
17
- * Props used to create the private context.
18
+ * Props used to create the picker's contexts.
18
19
  * Those props are exposed on all the pickers.
19
20
  */
20
21
  export interface UsePickerProviderProps extends FormProps {
@@ -23,3 +24,13 @@ export interface UsePickerProviderProps extends FormProps {
23
24
  */
24
25
  orientation?: PickerOrientation;
25
26
  }
27
+ /**
28
+ * Props used to create the picker's contexts and that are not available on static pickers.
29
+ */
30
+ export interface UsePickerProviderNonStaticProps {
31
+ /**
32
+ * If `true`, the open picker button will not be rendered (renders only the field).
33
+ * @default false
34
+ */
35
+ disableOpenPicker?: boolean;
36
+ }
@@ -40,11 +40,11 @@ export function usePickerProvider(parameters) {
40
40
  valueManager,
41
41
  localeText,
42
42
  variant,
43
- views,
44
- paramsFromUsePickerValue
43
+ paramsFromUsePickerValue,
44
+ paramsFromUsePickerViews
45
45
  } = parameters;
46
46
  const utils = useUtils();
47
- const orientation = usePickerOrientation(views, props.orientation);
47
+ const orientation = usePickerOrientation(paramsFromUsePickerViews.views, props.orientation);
48
48
  const ownerState = React.useMemo(() => ({
49
49
  isPickerValueEmpty: valueManager.areValuesEqual(utils, paramsFromUsePickerValue.value, valueManager.emptyValue),
50
50
  isPickerOpen: paramsFromUsePickerValue.contextValue.open,
@@ -70,6 +70,10 @@ export function usePickerProvider(parameters) {
70
70
  }
71
71
 
72
72
  /**
73
- * Props used to create the private context.
73
+ * Props used to create the picker's contexts.
74
74
  * Those props are exposed on all the pickers.
75
+ */
76
+
77
+ /**
78
+ * Props used to create the picker's contexts and that are not available on static pickers.
75
79
  */
@@ -39,16 +39,6 @@ export interface UsePickerViewsBaseProps<TValue extends PickerValidValue, TView
39
39
  */
40
40
  referenceDate?: PickerValidDate;
41
41
  }
42
- /**
43
- * Props used to handle the views of the pickers.
44
- */
45
- export interface UsePickerViewsNonStaticProps {
46
- /**
47
- * If `true`, the open picker button will not be rendered (renders only the field).
48
- * @default false
49
- */
50
- disableOpenPicker?: boolean;
51
- }
52
42
  /**
53
43
  * Props used to handle the value of the pickers.
54
44
  */
@@ -73,20 +63,20 @@ export interface UsePickerViewParams<TValue extends PickerValidValue, TView exte
73
63
  rendererInterceptor?: (viewRenderers: PickerViewRendererLookup<TValue, TView, TExternalProps, TAdditionalProps>, popperView: TView, rendererProps: PickerViewsRendererProps<TValue, TView, TExternalProps, TAdditionalProps>) => React.ReactNode;
74
64
  }
75
65
  export interface UsePickerViewsResponse<TView extends DateOrTimeViewWithMeridiem> {
76
- /**
77
- * Indicates if the the picker has at least one view that should be rendered in UI.
78
- */
79
- hasUIView: boolean;
80
- views: readonly TView[];
81
66
  renderCurrentView: () => React.ReactNode;
82
67
  shouldRestoreFocus: () => boolean;
83
68
  layoutProps: UsePickerViewsLayoutResponse<TView>;
69
+ provider: UsePickerViewsProviderParams<TView>;
84
70
  }
85
71
  export interface UsePickerViewsLayoutResponse<TView extends DateOrTimeViewWithMeridiem> {
86
72
  view: TView | null;
87
73
  onViewChange: (view: TView) => void;
88
74
  views: readonly TView[];
89
75
  }
76
+ export interface UsePickerViewsProviderParams<TView extends DateOrTimeViewWithMeridiem> {
77
+ hasUIView: boolean;
78
+ views: readonly TView[];
79
+ }
90
80
  /**
91
81
  * Manage the views of all the pickers:
92
82
  * - Handles the view switch
@@ -11,10 +11,6 @@ import { isTimeView } from "../../utils/time-utils.js";
11
11
  * Props used to handle the views that are common to all pickers.
12
12
  */
13
13
 
14
- /**
15
- * Props used to handle the views of the pickers.
16
- */
17
-
18
14
  /**
19
15
  * Props used to handle the value of the pickers.
20
16
  */
@@ -132,11 +128,14 @@ export const usePickerViews = ({
132
128
  view: popperView,
133
129
  onViewChange: setView
134
130
  };
135
- return {
131
+ const providerParams = {
136
132
  hasUIView,
137
- views,
133
+ views
134
+ };
135
+ return {
138
136
  shouldRestoreFocus,
139
137
  layoutProps,
138
+ provider: providerParams,
140
139
  renderCurrentView: () => {
141
140
  if (popperView == null) {
142
141
  return null;
@@ -0,0 +1,10 @@
1
+ import { PickerOwnerState } from '../../models';
2
+ export declare function useToolbarOwnerState(): PickerToolbarOwnerState;
3
+ export interface PickerToolbarOwnerState extends PickerOwnerState {
4
+ /**
5
+ * The direction of the toolbar.
6
+ * Is equal to "ltr" when the toolbar is in left-to-right direction.
7
+ * Is equal to "rtl" when the toolbar is in right-to-left direction.
8
+ */
9
+ toolbarDirection: 'ltr' | 'rtl';
10
+ }