@mui/x-date-pickers 8.0.0-alpha.2 → 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 (110) hide show
  1. package/CHANGELOG.md +376 -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/PickersActionBar/PickersActionBar.js +8 -1
  13. package/PickersLayout/PickersLayout.js +2 -2
  14. package/PickersLayout/PickersLayout.types.d.ts +4 -2
  15. package/PickersLayout/usePickerLayout.js +3 -3
  16. package/PickersShortcuts/PickersShortcuts.js +8 -1
  17. package/README.md +1 -1
  18. package/TimeClock/Clock.js +18 -21
  19. package/TimeClock/ClockNumber.js +15 -11
  20. package/TimeClock/ClockPointer.d.ts +6 -1
  21. package/TimeClock/ClockPointer.js +14 -10
  22. package/TimeClock/TimeClock.js +9 -8
  23. package/TimeField/useTimeField.d.ts +1 -1
  24. package/TimePicker/TimePickerToolbar.js +14 -17
  25. package/hooks/useClearableField.d.ts +5 -3
  26. package/hooks/useClearableField.js +4 -2
  27. package/index.js +1 -1
  28. package/internals/components/PickerProvider.d.ts +2 -15
  29. package/internals/components/PickersPopper.d.ts +11 -7
  30. package/internals/components/PickersPopper.js +18 -20
  31. package/internals/components/PickersToolbar.js +15 -12
  32. package/internals/components/PickersToolbarButton.js +4 -6
  33. package/internals/components/PickersToolbarText.js +11 -13
  34. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -2
  35. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +3 -2
  36. package/internals/hooks/useOpenState.d.ts +3 -2
  37. package/internals/hooks/useOpenState.js +10 -9
  38. package/internals/hooks/usePicker/usePicker.js +3 -3
  39. package/internals/hooks/usePicker/usePicker.types.d.ts +3 -2
  40. package/internals/hooks/usePicker/usePickerProvider.d.ts +17 -6
  41. package/internals/hooks/usePicker/usePickerProvider.js +14 -12
  42. package/internals/hooks/usePicker/usePickerValue.js +22 -11
  43. package/internals/hooks/usePicker/usePickerValue.types.d.ts +26 -0
  44. package/internals/hooks/usePicker/usePickerViews.d.ts +5 -15
  45. package/internals/hooks/usePicker/usePickerViews.js +5 -6
  46. package/internals/hooks/useToolbarOwnerState.d.ts +10 -0
  47. package/internals/hooks/useToolbarOwnerState.js +13 -0
  48. package/internals/index.d.ts +5 -1
  49. package/internals/index.js +3 -1
  50. package/internals/models/common.d.ts +1 -1
  51. package/locales/roRO.js +15 -18
  52. package/modern/DatePicker/DatePickerToolbar.js +8 -9
  53. package/modern/DateTimePicker/DateTimePickerToolbar.js +53 -39
  54. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  55. package/modern/DigitalClock/DigitalClock.js +13 -11
  56. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
  57. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
  58. package/modern/PickersActionBar/PickersActionBar.js +8 -1
  59. package/modern/PickersLayout/PickersLayout.js +2 -2
  60. package/modern/PickersLayout/usePickerLayout.js +3 -3
  61. package/modern/PickersShortcuts/PickersShortcuts.js +8 -1
  62. package/modern/TimeClock/Clock.js +18 -21
  63. package/modern/TimeClock/ClockNumber.js +15 -11
  64. package/modern/TimeClock/ClockPointer.js +14 -10
  65. package/modern/TimeClock/TimeClock.js +9 -8
  66. package/modern/TimePicker/TimePickerToolbar.js +14 -17
  67. package/modern/hooks/useClearableField.js +4 -2
  68. package/modern/index.js +1 -1
  69. package/modern/internals/components/PickersPopper.js +18 -20
  70. package/modern/internals/components/PickersToolbar.js +15 -12
  71. package/modern/internals/components/PickersToolbarButton.js +4 -6
  72. package/modern/internals/components/PickersToolbarText.js +11 -13
  73. package/modern/internals/hooks/useOpenState.js +10 -9
  74. package/modern/internals/hooks/usePicker/usePicker.js +3 -3
  75. package/modern/internals/hooks/usePicker/usePickerProvider.js +14 -12
  76. package/modern/internals/hooks/usePicker/usePickerValue.js +22 -11
  77. package/modern/internals/hooks/usePicker/usePickerViews.js +5 -6
  78. package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
  79. package/modern/internals/index.js +3 -1
  80. package/modern/locales/roRO.js +15 -18
  81. package/node/DatePicker/DatePickerToolbar.js +8 -9
  82. package/node/DateTimePicker/DateTimePickerToolbar.js +54 -39
  83. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  84. package/node/DigitalClock/DigitalClock.js +13 -11
  85. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
  86. package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
  87. package/node/PickersActionBar/PickersActionBar.js +8 -1
  88. package/node/PickersLayout/PickersLayout.js +2 -2
  89. package/node/PickersLayout/usePickerLayout.js +3 -3
  90. package/node/PickersShortcuts/PickersShortcuts.js +8 -1
  91. package/node/TimeClock/Clock.js +18 -21
  92. package/node/TimeClock/ClockNumber.js +15 -11
  93. package/node/TimeClock/ClockPointer.js +14 -10
  94. package/node/TimeClock/TimeClock.js +9 -8
  95. package/node/TimePicker/TimePickerToolbar.js +14 -17
  96. package/node/hooks/useClearableField.js +4 -2
  97. package/node/index.js +1 -1
  98. package/node/internals/components/PickersPopper.js +18 -20
  99. package/node/internals/components/PickersToolbar.js +15 -12
  100. package/node/internals/components/PickersToolbarButton.js +4 -6
  101. package/node/internals/components/PickersToolbarText.js +10 -12
  102. package/node/internals/hooks/useOpenState.js +10 -9
  103. package/node/internals/hooks/usePicker/usePicker.js +3 -3
  104. package/node/internals/hooks/usePicker/usePickerProvider.js +15 -13
  105. package/node/internals/hooks/usePicker/usePickerValue.js +22 -11
  106. package/node/internals/hooks/usePicker/usePickerViews.js +5 -6
  107. package/node/internals/hooks/useToolbarOwnerState.js +21 -0
  108. package/node/internals/index.js +15 -1
  109. package/node/locales/roRO.js +15 -18
  110. package/package.json +1 -1
@@ -11,20 +11,17 @@ import { useUtils } from "../internals/hooks/useUtils.js";
11
11
  import { CLOCK_HOUR_WIDTH, getHours, getMinutes } from "./shared.js";
12
12
  import { getClockUtilityClass } from "./clockClasses.js";
13
13
  import { formatMeridiem } from "../internals/utils/date-utils.js";
14
+ import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
14
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- const useUtilityClasses = ownerState => {
16
- const {
17
- classes,
18
- meridiemMode
19
- } = ownerState;
16
+ const useUtilityClasses = (classes, ownerState) => {
20
17
  const slots = {
21
18
  root: ['root'],
22
19
  clock: ['clock'],
23
20
  wrapper: ['wrapper'],
24
21
  squareMask: ['squareMask'],
25
22
  pin: ['pin'],
26
- amButton: ['amButton', meridiemMode === 'am' && 'selected'],
27
- pmButton: ['pmButton', meridiemMode === 'pm' && 'selected'],
23
+ amButton: ['amButton', ownerState.clockMeridiemMode === 'am' && 'selected'],
24
+ pmButton: ['pmButton', ownerState.clockMeridiemMode === 'pm' && 'selected'],
28
25
  meridiemText: ['meridiemText']
29
26
  };
30
27
  return composeClasses(slots, getClockUtilityClass, classes);
@@ -78,7 +75,7 @@ const ClockSquareMask = styled('div', {
78
75
  userSelect: 'none',
79
76
  variants: [{
80
77
  props: {
81
- disabled: false
78
+ isClockDisabled: false
82
79
  },
83
80
  style: {
84
81
  '@media (pointer: fine)': {
@@ -182,13 +179,20 @@ export function Clock(inProps) {
182
179
  viewValue,
183
180
  disabled = false,
184
181
  readOnly,
185
- className
182
+ className,
183
+ classes: classesProp
186
184
  } = props;
187
- const ownerState = props;
188
185
  const utils = useUtils();
189
186
  const translations = usePickerTranslations();
187
+ const {
188
+ ownerState: pickerOwnerState
189
+ } = usePickerPrivateContext();
190
+ const ownerState = _extends({}, pickerOwnerState, {
191
+ isClockDisabled: disabled,
192
+ clockMeridiemMode: meridiemMode
193
+ });
190
194
  const isMoving = React.useRef(false);
191
- const classes = useUtilityClasses(ownerState);
195
+ const classes = useUtilityClasses(classesProp, ownerState);
192
196
  const isSelectedTimeDisabled = isTimeDisabled(viewValue, type);
193
197
  const isPointerInner = !ampm && type === 'hours' && (viewValue < 1 || viewValue > 12);
194
198
  const handleValueChange = (newValue, isFinish) => {
@@ -236,12 +240,7 @@ export function Clock(inProps) {
236
240
  }
237
241
  setTime(event.nativeEvent, 'finish');
238
242
  };
239
- const hasSelected = React.useMemo(() => {
240
- if (type === 'hours') {
241
- return true;
242
- }
243
- return viewValue % 5 === 0;
244
- }, [type, viewValue]);
243
+ const isPointerBetweenTwoClockValues = type === 'hours' ? false : viewValue % 5 !== 0;
245
244
  const keyboardControlStep = type === 'minutes' ? minutesStep : 1;
246
245
  const listboxRef = React.useRef(null);
247
246
  // Since this is rendered when a Popper is opened we can't use passive effects.
@@ -302,9 +301,7 @@ export function Clock(inProps) {
302
301
  onTouchEnd: handleTouchEnd,
303
302
  onMouseUp: handleMouseUp,
304
303
  onMouseMove: handleMouseMove,
305
- ownerState: {
306
- disabled
307
- },
304
+ ownerState: ownerState,
308
305
  className: classes.squareMask
309
306
  }), !isSelectedTimeDisabled && /*#__PURE__*/_jsxs(React.Fragment, {
310
307
  children: [/*#__PURE__*/_jsx(ClockPin, {
@@ -313,7 +310,7 @@ export function Clock(inProps) {
313
310
  type: type,
314
311
  viewValue: viewValue,
315
312
  isInner: isPointerInner,
316
- hasSelected: hasSelected
313
+ isBetweenTwoClockValues: isPointerBetweenTwoClockValues
317
314
  })]
318
315
  }), /*#__PURE__*/_jsx(ClockWrapper, {
319
316
  "aria-activedescendant": selectedId,
@@ -1,21 +1,17 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["className", "disabled", "index", "inner", "label", "selected"];
3
+ const _excluded = ["className", "classes", "disabled", "index", "inner", "label", "selected"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { styled, useThemeProps } from '@mui/material/styles';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
8
  import { CLOCK_WIDTH, CLOCK_HOUR_WIDTH } from "./shared.js";
9
9
  import { getClockNumberUtilityClass, clockNumberClasses } from "./clockNumberClasses.js";
10
+ import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
- const useUtilityClasses = ownerState => {
12
- const {
13
- classes,
14
- selected,
15
- disabled
16
- } = ownerState;
12
+ const useUtilityClasses = (classes, ownerState) => {
17
13
  const slots = {
18
- root: ['root', selected && 'selected', disabled && 'disabled']
14
+ root: ['root', ownerState.isClockNumberSelected && 'selected', ownerState.isClockNumberDisabled && 'disabled']
19
15
  };
20
16
  return composeClasses(slots, getClockNumberUtilityClass, classes);
21
17
  };
@@ -52,7 +48,7 @@ const ClockNumberRoot = styled('span', {
52
48
  },
53
49
  variants: [{
54
50
  props: {
55
- inner: true
51
+ isClockNumberInInnerRing: true
56
52
  },
57
53
  style: _extends({}, theme.typography.body2, {
58
54
  color: (theme.vars || theme).palette.text.secondary
@@ -70,6 +66,7 @@ export function ClockNumber(inProps) {
70
66
  });
71
67
  const {
72
68
  className,
69
+ classes: classesProp,
73
70
  disabled,
74
71
  index,
75
72
  inner,
@@ -77,8 +74,15 @@ export function ClockNumber(inProps) {
77
74
  selected
78
75
  } = props,
79
76
  other = _objectWithoutPropertiesLoose(props, _excluded);
80
- const ownerState = props;
81
- const classes = useUtilityClasses(ownerState);
77
+ const {
78
+ ownerState: pickerOwnerState
79
+ } = usePickerPrivateContext();
80
+ const ownerState = _extends({}, pickerOwnerState, {
81
+ isClockNumberInInnerRing: inner,
82
+ isClockNumberSelected: selected,
83
+ isClockNumberDisabled: disabled
84
+ });
85
+ const classes = useUtilityClasses(classesProp, ownerState);
82
86
  const angle = index % 12 / 12 * Math.PI * 2 - Math.PI / 2;
83
87
  const length = (CLOCK_WIDTH - CLOCK_HOUR_WIDTH - 2) / 2 * (inner ? 0.65 : 1);
84
88
  const x = Math.round(Math.cos(angle) * length);
@@ -2,7 +2,12 @@ import * as React from 'react';
2
2
  import { TimeView } from '../models';
3
3
  import { ClockPointerClasses } from './clockPointerClasses';
4
4
  export interface ClockPointerProps extends React.HTMLAttributes<HTMLDivElement> {
5
- hasSelected: boolean;
5
+ /**
6
+ * `true` if the pointer is between two clock values.
7
+ * On the `hours` view, it is always false.
8
+ * On the `minutes` view, it is true if the pointer is on a value that is not a multiple of 5.
9
+ */
10
+ isBetweenTwoClockValues: boolean;
6
11
  isInner: boolean;
7
12
  type: TimeView;
8
13
  viewValue: number;
@@ -1,17 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["className", "hasSelected", "isInner", "type", "viewValue"];
3
+ const _excluded = ["className", "classes", "isBetweenTwoClockValues", "isInner", "type", "viewValue"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { styled, useThemeProps } from '@mui/material/styles';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
8
  import { CLOCK_WIDTH, CLOCK_HOUR_WIDTH } from "./shared.js";
9
9
  import { getClockPointerUtilityClass } from "./clockPointerClasses.js";
10
+ import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
- const useUtilityClasses = ownerState => {
12
- const {
13
- classes
14
- } = ownerState;
12
+ const useUtilityClasses = classes => {
15
13
  const slots = {
16
14
  root: ['root'],
17
15
  thumb: ['thumb']
@@ -33,7 +31,7 @@ const ClockPointerRoot = styled('div', {
33
31
  transformOrigin: 'center bottom 0px',
34
32
  variants: [{
35
33
  props: {
36
- shouldAnimate: true
34
+ isClockPointerAnimated: true
37
35
  },
38
36
  style: {
39
37
  transition: theme.transitions.create(['transform', 'height'])
@@ -58,7 +56,7 @@ const ClockPointerThumb = styled('div', {
58
56
  boxSizing: 'content-box',
59
57
  variants: [{
60
58
  props: {
61
- hasSelected: true
59
+ isBetweenTwoClockValues: false
62
60
  },
63
61
  style: {
64
62
  backgroundColor: (theme.vars || theme).palette.primary.main
@@ -76,6 +74,8 @@ export function ClockPointer(inProps) {
76
74
  });
77
75
  const {
78
76
  className,
77
+ classes: classesProp,
78
+ isBetweenTwoClockValues,
79
79
  isInner,
80
80
  type,
81
81
  viewValue
@@ -85,10 +85,14 @@ export function ClockPointer(inProps) {
85
85
  React.useEffect(() => {
86
86
  previousType.current = type;
87
87
  }, [type]);
88
- const ownerState = _extends({}, props, {
89
- shouldAnimate: previousType.current !== type
88
+ const {
89
+ ownerState: pickerOwnerState
90
+ } = usePickerPrivateContext();
91
+ const ownerState = _extends({}, pickerOwnerState, {
92
+ isClockPointerAnimated: previousType.current !== type,
93
+ isClockPointerBetweenTwoValues: isBetweenTwoClockValues
90
94
  });
91
- const classes = useUtilityClasses(ownerState);
95
+ const classes = useUtilityClasses(classesProp);
92
96
  const getAngleStyle = () => {
93
97
  const max = type === 'hours' ? 12 : 60;
94
98
  let angle = 360 / max * viewValue;
@@ -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 = ["ampm", "ampmInClock", "autoFocus", "slots", "slotProps", "value", "defaultValue", "referenceDate", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableTime", "showViewSwitcher", "onChange", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "timezone"];
5
+ const _excluded = ["ampm", "ampmInClock", "autoFocus", "slots", "slotProps", "value", "defaultValue", "referenceDate", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableTime", "showViewSwitcher", "onChange", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "classes", "disabled", "readOnly", "timezone"];
6
6
  import * as React from 'react';
7
7
  import clsx from 'clsx';
8
8
  import PropTypes from 'prop-types';
@@ -21,11 +21,9 @@ import { getHourNumbers, getMinutesNumbers } from "./ClockNumbers.js";
21
21
  import { useControlledValueWithTimezone } from "../internals/hooks/useValueWithTimezone.js";
22
22
  import { singleItemValueManager } from "../internals/utils/valueManagers.js";
23
23
  import { useClockReferenceDate } from "../internals/hooks/useClockReferenceDate.js";
24
+ import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
24
25
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
- const useUtilityClasses = ownerState => {
26
- const {
27
- classes
28
- } = ownerState;
26
+ const useUtilityClasses = classes => {
29
27
  const slots = {
30
28
  root: ['root'],
31
29
  arrowSwitcher: ['arrowSwitcher']
@@ -93,6 +91,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
93
91
  focusedView,
94
92
  onFocusedViewChange,
95
93
  className,
94
+ classes: classesProp,
96
95
  disabled,
97
96
  readOnly,
98
97
  timezone: timezoneProp
@@ -120,6 +119,10 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
120
119
  });
121
120
  const translations = usePickerTranslations();
122
121
  const now = useNow(timezone);
122
+ const selectedId = useId();
123
+ const {
124
+ ownerState
125
+ } = usePickerPrivateContext();
123
126
  const {
124
127
  view,
125
128
  setView,
@@ -214,7 +217,6 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
214
217
  throw new Error('not supported');
215
218
  }
216
219
  }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
217
- const selectedId = useId();
218
220
  const viewProps = React.useMemo(() => {
219
221
  switch (view) {
220
222
  case 'hours':
@@ -279,8 +281,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
279
281
  throw new Error('You must provide the type for ClockView');
280
282
  }
281
283
  }, [view, utils, value, ampm, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, selectedId, disabled]);
282
- const ownerState = props;
283
- const classes = useUtilityClasses(ownerState);
284
+ const classes = useUtilityClasses(classesProp);
284
285
  return /*#__PURE__*/_jsxs(TimeClockRoot, _extends({
285
286
  ref: ref,
286
287
  className: clsx(classes.root, className),
@@ -1,2 +1,2 @@
1
1
  import { UseTimeFieldProps } from './TimeField.types';
2
- export declare const useTimeField: <TEnableAccessibleFieldDOMStructure extends boolean, TAllProps extends UseTimeFieldProps<TEnableAccessibleFieldDOMStructure>>(inProps: TAllProps) => import("../internals").UseFieldResponse<TEnableAccessibleFieldDOMStructure, Omit<TAllProps & Omit<UseTimeFieldProps<TEnableAccessibleFieldDOMStructure>, keyof import("../internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps> & Required<Pick<UseTimeFieldProps<TEnableAccessibleFieldDOMStructure>, keyof import("../internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps>>, "disabled" | "format" | "onChange" | "onError" | "defaultValue" | "value" | "readOnly" | "formatDensity" | "enableAccessibleFieldDOMStructure" | "selectedSections" | "onSelectedSectionsChange" | "timezone" | "unstableFieldRef" | "referenceDate" | "shouldRespectLeadingZeros" | "ampm" | keyof import("../internals").BaseTimeValidationProps | keyof import("../internals").TimeValidationProps | "dateSeparator">>;
2
+ export declare const useTimeField: <TEnableAccessibleFieldDOMStructure extends boolean, TAllProps extends UseTimeFieldProps<TEnableAccessibleFieldDOMStructure>>(inProps: TAllProps) => import("../internals").UseFieldResponse<TEnableAccessibleFieldDOMStructure, Omit<TAllProps & Omit<UseTimeFieldProps<TEnableAccessibleFieldDOMStructure>, keyof import("../internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps> & Required<Pick<UseTimeFieldProps<TEnableAccessibleFieldDOMStructure>, keyof import("../internals/hooks/defaultizedFieldProps").UseDefaultizedTimeFieldBaseProps>>, "disabled" | "format" | "onChange" | "onError" | "defaultValue" | "value" | "readOnly" | "ampm" | "timezone" | "referenceDate" | "formatDensity" | "shouldRespectLeadingZeros" | "selectedSections" | "onSelectedSectionsChange" | "unstableFieldRef" | "enableAccessibleFieldDOMStructure" | keyof import("../internals").BaseTimeValidationProps | keyof import("../internals").TimeValidationProps | "dateSeparator">>;
@@ -2,11 +2,10 @@
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 = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "className"];
5
+ const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "className", "classes"];
6
6
  import * as React from 'react';
7
7
  import clsx from 'clsx';
8
8
  import PropTypes from 'prop-types';
9
- import { useRtl } from '@mui/system/RtlProvider';
10
9
  import { styled, useThemeProps } from '@mui/material/styles';
11
10
  import composeClasses from '@mui/utils/composeClasses';
12
11
  import { PickersToolbarText } from "../internals/components/PickersToolbarText.js";
@@ -19,18 +18,18 @@ import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
19
18
  import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
20
19
  import { formatMeridiem } from "../internals/utils/date-utils.js";
21
20
  import { usePickerContext } from "../hooks/index.js";
21
+ import { useToolbarOwnerState } from "../internals/hooks/useToolbarOwnerState.js";
22
22
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
- const useUtilityClasses = ownerState => {
23
+ const useUtilityClasses = (classes, ownerState) => {
24
24
  const {
25
- isLandscape,
26
- classes,
27
- isRtl
25
+ pickerOrientation,
26
+ toolbarDirection
28
27
  } = ownerState;
29
28
  const slots = {
30
29
  root: ['root'],
31
30
  separator: ['separator'],
32
- hourMinuteLabel: ['hourMinuteLabel', isLandscape && 'hourMinuteLabelLandscape', isRtl && 'hourMinuteLabelReverse'],
33
- ampmSelection: ['ampmSelection', isLandscape && 'ampmLandscape'],
31
+ hourMinuteLabel: ['hourMinuteLabel', pickerOrientation === 'landscape' && 'hourMinuteLabelLandscape', toolbarDirection === 'rtl' && 'hourMinuteLabelReverse'],
32
+ ampmSelection: ['ampmSelection', pickerOrientation === 'landscape' && 'ampmLandscape'],
34
33
  ampmLabel: ['ampmLabel']
35
34
  };
36
35
  return composeClasses(slots, getTimePickerToolbarUtilityClass, classes);
@@ -62,14 +61,14 @@ const TimePickerToolbarHourMinuteLabel = styled('div', {
62
61
  alignItems: 'flex-end',
63
62
  variants: [{
64
63
  props: {
65
- isRtl: true
64
+ toolbarDirection: 'rtl'
66
65
  },
67
66
  style: {
68
67
  flexDirection: 'row-reverse'
69
68
  }
70
69
  }, {
71
70
  props: {
72
- isLandscape: true
71
+ pickerOrientation: 'landscape'
73
72
  },
74
73
  style: {
75
74
  marginTop: 'auto'
@@ -94,7 +93,7 @@ const TimePickerToolbarAmPmSelection = styled('div', {
94
93
  },
95
94
  variants: [{
96
95
  props: {
97
- isLandscape: true
96
+ pickerOrientation: 'landscape'
98
97
  },
99
98
  style: {
100
99
  margin: '4px 0 auto',
@@ -129,12 +128,14 @@ function TimePickerToolbar(inProps) {
129
128
  view,
130
129
  onViewChange,
131
130
  views,
132
- className
131
+ className,
132
+ classes: classesProp
133
133
  } = props,
134
134
  other = _objectWithoutPropertiesLoose(props, _excluded);
135
135
  const utils = useUtils();
136
136
  const translations = usePickerTranslations();
137
- const isRtl = useRtl();
137
+ const ownerState = useToolbarOwnerState();
138
+ const classes = useUtilityClasses(classesProp, ownerState);
138
139
  const {
139
140
  disabled,
140
141
  readOnly
@@ -145,10 +146,6 @@ function TimePickerToolbar(inProps) {
145
146
  handleMeridiemChange
146
147
  } = useMeridiemMode(value, ampm, onChange);
147
148
  const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
148
- const ownerState = _extends({}, props, {
149
- isRtl
150
- });
151
- const classes = useUtilityClasses(ownerState);
152
149
  const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
153
150
  tabIndex: -1,
154
151
  value: ":",
@@ -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.2
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,6 +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 type { UsePickerValueContextValue } from '../hooks/usePicker/usePickerValue.types';
5
6
  export declare const PickerContext: React.Context<PickerContextValue | null>;
6
7
  export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
7
8
  /**
@@ -18,21 +19,7 @@ export interface PickerProviderProps {
18
19
  localeText: PickersInputLocaleText | undefined;
19
20
  children: React.ReactNode;
20
21
  }
21
- export interface PickerContextValue {
22
- /**
23
- * Open the picker.
24
- * @param {React.UIEvent} event The DOM event that triggered the change.
25
- */
26
- onOpen: (event: React.UIEvent) => void;
27
- /**
28
- * Close the picker.
29
- * @param {React.UIEvent} event The DOM event that triggered the change.
30
- */
31
- onClose: (event: React.UIEvent) => void;
32
- /**
33
- * `true` if the picker is open, `false` otherwise.
34
- */
35
- open: boolean;
22
+ export interface PickerContextValue extends UsePickerValueContextValue {
36
23
  /**
37
24
  * `true` if the picker is disabled, `false` otherwise.
38
25
  */
@@ -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,