@mui/x-date-pickers 8.5.3 → 8.6.0

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 (176) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/DateCalendar/DateCalendar.js +16 -16
  3. package/DateCalendar/DayCalendar.js +48 -48
  4. package/DateCalendar/useCalendarState.js +25 -25
  5. package/DateCalendar/useIsDateDisabled.js +2 -2
  6. package/DatePicker/DatePickerToolbar.js +7 -9
  7. package/DateTimeField/DateTimeField.js +1 -1
  8. package/DateTimePicker/DateTimePicker.js +1 -1
  9. package/DateTimePicker/DateTimePickerToolbar.js +12 -13
  10. package/DateTimePicker/shared.js +3 -3
  11. package/DesktopDatePicker/DesktopDatePicker.js +3 -3
  12. package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
  13. package/DesktopTimePicker/DesktopTimePicker.js +4 -4
  14. package/DigitalClock/DigitalClock.d.ts +1 -1
  15. package/DigitalClock/DigitalClock.js +16 -16
  16. package/LocalizationProvider/LocalizationProvider.d.ts +9 -3
  17. package/LocalizationProvider/LocalizationProvider.js +28 -19
  18. package/MobileDatePicker/MobileDatePicker.js +3 -3
  19. package/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
  20. package/MobileTimePicker/MobileTimePicker.js +4 -4
  21. package/MonthCalendar/MonthCalendar.js +19 -18
  22. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
  23. package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
  24. package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
  25. package/PickerDay2/PickerDay2.js +3 -3
  26. package/PickersActionBar/PickersActionBar.d.ts +2 -2
  27. package/PickersActionBar/PickersActionBar.js +2 -2
  28. package/PickersCalendarHeader/PickersCalendarHeader.js +7 -8
  29. package/PickersDay/PickersDay.js +3 -3
  30. package/PickersDay/usePickerDayOwnerState.js +5 -5
  31. package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  32. package/StaticTimePicker/StaticTimePicker.js +1 -1
  33. package/TimeClock/Clock.js +8 -9
  34. package/TimeClock/ClockNumbers.d.ts +3 -3
  35. package/TimeClock/ClockNumbers.js +5 -5
  36. package/TimeClock/TimeClock.js +29 -29
  37. package/TimeField/TimeField.js +1 -1
  38. package/TimePicker/TimePicker.js +1 -1
  39. package/TimePicker/TimePickerToolbar.js +7 -9
  40. package/TimePicker/shared.js +3 -3
  41. package/YearCalendar/YearCalendar.js +19 -18
  42. package/esm/DateCalendar/DateCalendar.js +16 -16
  43. package/esm/DateCalendar/DayCalendar.js +48 -48
  44. package/esm/DateCalendar/useCalendarState.js +25 -25
  45. package/esm/DateCalendar/useIsDateDisabled.js +2 -2
  46. package/esm/DatePicker/DatePickerToolbar.js +6 -8
  47. package/esm/DateTimeField/DateTimeField.js +1 -1
  48. package/esm/DateTimePicker/DateTimePicker.js +1 -1
  49. package/esm/DateTimePicker/DateTimePickerToolbar.js +11 -12
  50. package/esm/DateTimePicker/shared.js +3 -3
  51. package/esm/DesktopDatePicker/DesktopDatePicker.js +3 -3
  52. package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
  53. package/esm/DesktopTimePicker/DesktopTimePicker.js +4 -4
  54. package/esm/DigitalClock/DigitalClock.d.ts +1 -1
  55. package/esm/DigitalClock/DigitalClock.js +16 -16
  56. package/esm/LocalizationProvider/LocalizationProvider.d.ts +9 -3
  57. package/esm/LocalizationProvider/LocalizationProvider.js +27 -18
  58. package/esm/MobileDatePicker/MobileDatePicker.js +3 -3
  59. package/esm/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
  60. package/esm/MobileTimePicker/MobileTimePicker.js +4 -4
  61. package/esm/MonthCalendar/MonthCalendar.js +20 -19
  62. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
  63. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
  64. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
  65. package/esm/PickerDay2/PickerDay2.js +3 -3
  66. package/esm/PickersActionBar/PickersActionBar.d.ts +2 -2
  67. package/esm/PickersActionBar/PickersActionBar.js +2 -2
  68. package/esm/PickersCalendarHeader/PickersCalendarHeader.js +6 -7
  69. package/esm/PickersDay/PickersDay.js +3 -3
  70. package/esm/PickersDay/usePickerDayOwnerState.js +5 -5
  71. package/esm/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  72. package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
  73. package/esm/TimeClock/Clock.js +7 -8
  74. package/esm/TimeClock/ClockNumbers.d.ts +3 -3
  75. package/esm/TimeClock/ClockNumbers.js +5 -5
  76. package/esm/TimeClock/TimeClock.js +29 -29
  77. package/esm/TimeField/TimeField.js +1 -1
  78. package/esm/TimePicker/TimePicker.js +1 -1
  79. package/esm/TimePicker/TimePickerToolbar.js +6 -8
  80. package/esm/TimePicker/shared.js +3 -3
  81. package/esm/YearCalendar/YearCalendar.js +20 -19
  82. package/esm/hooks/index.d.ts +2 -1
  83. package/esm/hooks/index.js +2 -1
  84. package/esm/hooks/useParsedFormat.js +6 -6
  85. package/esm/hooks/usePickerAdapter.d.ts +7 -0
  86. package/esm/hooks/usePickerAdapter.js +20 -0
  87. package/esm/hooks/usePickerTranslations.js +1 -1
  88. package/esm/index.js +1 -1
  89. package/esm/internals/components/pickersToolbarClasses.d.ts +1 -1
  90. package/esm/internals/demo/DemoContainer.d.ts +2 -3
  91. package/esm/internals/demo/DemoContainer.js +3 -2
  92. package/esm/internals/hooks/date-helpers-hooks.js +16 -16
  93. package/esm/internals/hooks/useClockReferenceDate.d.ts +2 -2
  94. package/esm/internals/hooks/useClockReferenceDate.js +3 -3
  95. package/esm/internals/hooks/useControlledValue.js +8 -7
  96. package/esm/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
  97. package/esm/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
  98. package/esm/internals/hooks/useField/useField.types.d.ts +2 -2
  99. package/esm/internals/hooks/useField/useField.utils.d.ts +10 -10
  100. package/esm/internals/hooks/useField/useField.utils.js +69 -69
  101. package/esm/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
  102. package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
  103. package/esm/internals/hooks/useField/useFieldSectionContentProps.js +15 -16
  104. package/esm/internals/hooks/useField/useFieldState.js +22 -24
  105. package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
  106. package/esm/internals/hooks/usePicker/usePicker.js +5 -6
  107. package/esm/internals/hooks/useUtils.d.ts +1 -8
  108. package/esm/internals/hooks/useUtils.js +3 -19
  109. package/esm/internals/index.d.ts +2 -1
  110. package/esm/internals/index.js +2 -1
  111. package/esm/internals/models/manager.d.ts +14 -14
  112. package/esm/internals/models/props/time.d.ts +1 -1
  113. package/esm/internals/utils/date-time-utils.d.ts +1 -1
  114. package/esm/internals/utils/date-time-utils.js +5 -5
  115. package/esm/internals/utils/date-utils.d.ts +11 -11
  116. package/esm/internals/utils/date-utils.js +34 -34
  117. package/esm/internals/utils/getDefaultReferenceDate.d.ts +2 -2
  118. package/esm/internals/utils/getDefaultReferenceDate.js +16 -16
  119. package/esm/internals/utils/time-utils.d.ts +5 -5
  120. package/esm/internals/utils/time-utils.js +12 -12
  121. package/esm/internals/utils/valueManagers.js +4 -4
  122. package/esm/managers/useDateManager.js +12 -12
  123. package/esm/managers/useDateTimeManager.js +13 -13
  124. package/esm/managers/useTimeManager.js +9 -10
  125. package/esm/validation/useValidation.d.ts +2 -3
  126. package/esm/validation/useValidation.js +2 -2
  127. package/esm/validation/validateDate.js +6 -6
  128. package/esm/validation/validateTime.js +6 -6
  129. package/hooks/index.d.ts +2 -1
  130. package/hooks/index.js +8 -1
  131. package/hooks/useParsedFormat.js +6 -6
  132. package/hooks/usePickerAdapter.d.ts +7 -0
  133. package/hooks/usePickerAdapter.js +29 -0
  134. package/hooks/usePickerTranslations.js +2 -2
  135. package/index.js +1 -1
  136. package/internals/components/pickersToolbarClasses.d.ts +1 -1
  137. package/internals/demo/DemoContainer.d.ts +2 -3
  138. package/internals/demo/DemoContainer.js +3 -2
  139. package/internals/hooks/date-helpers-hooks.js +16 -16
  140. package/internals/hooks/useClockReferenceDate.d.ts +2 -2
  141. package/internals/hooks/useClockReferenceDate.js +3 -3
  142. package/internals/hooks/useControlledValue.js +7 -7
  143. package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
  144. package/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
  145. package/internals/hooks/useField/useField.types.d.ts +2 -2
  146. package/internals/hooks/useField/useField.utils.d.ts +10 -10
  147. package/internals/hooks/useField/useField.utils.js +69 -69
  148. package/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
  149. package/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
  150. package/internals/hooks/useField/useFieldSectionContentProps.js +14 -15
  151. package/internals/hooks/useField/useFieldState.js +23 -25
  152. package/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
  153. package/internals/hooks/usePicker/usePicker.js +5 -6
  154. package/internals/hooks/useUtils.d.ts +1 -8
  155. package/internals/hooks/useUtils.js +5 -24
  156. package/internals/index.d.ts +2 -1
  157. package/internals/index.js +2 -7
  158. package/internals/models/manager.d.ts +14 -14
  159. package/internals/models/props/time.d.ts +1 -1
  160. package/internals/utils/date-time-utils.d.ts +1 -1
  161. package/internals/utils/date-time-utils.js +5 -5
  162. package/internals/utils/date-utils.d.ts +11 -11
  163. package/internals/utils/date-utils.js +34 -34
  164. package/internals/utils/getDefaultReferenceDate.d.ts +2 -2
  165. package/internals/utils/getDefaultReferenceDate.js +16 -16
  166. package/internals/utils/time-utils.d.ts +5 -5
  167. package/internals/utils/time-utils.js +12 -12
  168. package/internals/utils/valueManagers.js +4 -4
  169. package/managers/useDateManager.js +12 -12
  170. package/managers/useDateTimeManager.js +13 -13
  171. package/managers/useTimeManager.js +10 -11
  172. package/package.json +2 -2
  173. package/validation/useValidation.d.ts +2 -3
  174. package/validation/useValidation.js +2 -2
  175. package/validation/validateDate.js +6 -6
  176. package/validation/validateTime.js +6 -6
@@ -1,14 +1,14 @@
1
1
  export const getHourSectionOptions = ({
2
2
  now,
3
3
  value,
4
- utils,
4
+ adapter,
5
5
  ampm,
6
6
  isDisabled,
7
7
  resolveAriaLabel,
8
8
  timeStep,
9
9
  valueOrReferenceDate
10
10
  }) => {
11
- const currentHours = value ? utils.getHours(value) : null;
11
+ const currentHours = value ? adapter.getHours(value) : null;
12
12
  const result = [];
13
13
  const isSelected = (hour, overriddenCurrentHours) => {
14
14
  const resolvedCurrentHours = overriddenCurrentHours ?? currentHours;
@@ -24,13 +24,13 @@ export const getHourSectionOptions = ({
24
24
  return resolvedCurrentHours === hour;
25
25
  };
26
26
  const isFocused = hour => {
27
- return isSelected(hour, utils.getHours(valueOrReferenceDate));
27
+ return isSelected(hour, adapter.getHours(valueOrReferenceDate));
28
28
  };
29
29
  const endHour = ampm ? 11 : 23;
30
30
  for (let hour = 0; hour <= endHour; hour += timeStep) {
31
- let label = utils.format(utils.setHours(now, hour), ampm ? 'hours12h' : 'hours24h');
31
+ let label = adapter.format(adapter.setHours(now, hour), ampm ? 'hours12h' : 'hours24h');
32
32
  const ariaLabel = resolveAriaLabel(parseInt(label, 10).toString());
33
- label = utils.formatNumber(label);
33
+ label = adapter.formatNumber(label);
34
34
  result.push({
35
35
  value: hour,
36
36
  label,
@@ -44,7 +44,7 @@ export const getHourSectionOptions = ({
44
44
  };
45
45
  export const getTimeSectionOptions = ({
46
46
  value,
47
- utils,
47
+ adapter,
48
48
  isDisabled,
49
49
  timeStep,
50
50
  resolveLabel,
@@ -66,7 +66,7 @@ export const getTimeSectionOptions = ({
66
66
  const timeValue = timeStep * index;
67
67
  return {
68
68
  value: timeValue,
69
- label: utils.formatNumber(resolveLabel(timeValue)),
69
+ label: adapter.formatNumber(resolveLabel(timeValue)),
70
70
  isDisabled,
71
71
  isSelected,
72
72
  isFocused,
@@ -11,7 +11,7 @@ import composeClasses from '@mui/utils/composeClasses';
11
11
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
12
12
  import { DAY_MARGIN, DAY_SIZE } from "../internals/constants/dimensions.js";
13
13
  import { pickerDay2Classes, getPickerDay2UtilityClass } from "./pickerDay2Classes.js";
14
- import { useUtils } from "../internals/hooks/useUtils.js";
14
+ import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
15
15
  import { usePickerDayOwnerState } from "../PickersDay/usePickerDayOwnerState.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  const useUtilityClasses = (ownerState, classes) => {
@@ -120,7 +120,7 @@ const PickerDay2Raw = /*#__PURE__*/React.forwardRef(function PickerDay2(inProps,
120
120
  props: inProps,
121
121
  name: 'MuiPickerDay2'
122
122
  });
123
- const utils = useUtils();
123
+ const adapter = usePickerAdapter();
124
124
  const {
125
125
  autoFocus = false,
126
126
  className,
@@ -207,7 +207,7 @@ const PickerDay2Raw = /*#__PURE__*/React.forwardRef(function PickerDay2(inProps,
207
207
  }, other, {
208
208
  ownerState: ownerState,
209
209
  className: clsx(classes.root, className),
210
- children: children ?? (ownerState.isDayFillerCell ? null : utils.format(day, 'dayOfMonth'))
210
+ children: children ?? (ownerState.isDayFillerCell ? null : adapter.format(day, 'dayOfMonth'))
211
211
  }));
212
212
  });
213
213
  if (process.env.NODE_ENV !== "production") PickerDay2Raw.displayName = "PickerDay2Raw";
@@ -6,8 +6,8 @@ export interface PickersActionBarProps extends DialogActionsProps {
6
6
  * Ordered array of actions to display.
7
7
  * If empty, does not display that action bar.
8
8
  * @default
9
- * - `[]` for Desktop Date Picker and Desktop Date Range Picker
10
- * - `['cancel', 'accept']` for all other Pickers
9
+ * - `[]` for Pickers with one selection step which `closeOnSelect`.
10
+ * - `['cancel', 'nextOrAccept']` for all other Pickers.
11
11
  */
12
12
  actions?: PickersActionBarAction[];
13
13
  }
@@ -98,8 +98,8 @@ process.env.NODE_ENV !== "production" ? PickersActionBarComponent.propTypes = {
98
98
  * Ordered array of actions to display.
99
99
  * If empty, does not display that action bar.
100
100
  * @default
101
- * - `[]` for Desktop Date Picker and Desktop Date Range Picker
102
- * - `['cancel', 'accept']` for all other Pickers
101
+ * - `[]` for Pickers with one selection step which `closeOnSelect`.
102
+ * - `['cancel', 'nextOrAccept']` for all other Pickers.
103
103
  */
104
104
  actions: PropTypes.arrayOf(PropTypes.oneOf(['accept', 'cancel', 'clear', 'next', 'nextOrAccept', 'today']).isRequired),
105
105
  /**
@@ -12,8 +12,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
12
12
  import useSlotProps from '@mui/utils/useSlotProps';
13
13
  import composeClasses from '@mui/utils/composeClasses';
14
14
  import IconButton from '@mui/material/IconButton';
15
- import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
16
- import { useUtils } from "../internals/hooks/useUtils.js";
15
+ import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
17
16
  import { PickersFadeTransitionGroup } from "../DateCalendar/PickersFadeTransitionGroup.js";
18
17
  import { ArrowDropDownIcon } from "../icons/index.js";
19
18
  import { PickersArrowSwitcher } from "../internals/components/PickersArrowSwitcher/index.js";
@@ -104,7 +103,7 @@ const PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDownIcon, {
104
103
  */
105
104
  const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCalendarHeader(inProps, ref) {
106
105
  const translations = usePickerTranslations();
107
- const utils = useUtils();
106
+ const adapter = usePickerAdapter();
108
107
  const props = useThemeProps({
109
108
  props: inProps,
110
109
  name: 'MuiPickersCalendarHeader'
@@ -127,7 +126,7 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
127
126
  className,
128
127
  classes: classesProp,
129
128
  timezone,
130
- format = `${utils.formats.month} ${utils.formats.year}`
129
+ format = `${adapter.formats.month} ${adapter.formats.year}`
131
130
  } = props,
132
131
  other = _objectWithoutPropertiesLoose(props, _excluded);
133
132
  const {
@@ -156,8 +155,8 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
156
155
  className: classes.switchViewIcon
157
156
  }),
158
157
  switchViewIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
159
- const selectNextMonth = () => onMonthChange(utils.addMonths(month, 1));
160
- const selectPreviousMonth = () => onMonthChange(utils.addMonths(month, -1));
158
+ const selectNextMonth = () => onMonthChange(adapter.addMonths(month, 1));
159
+ const selectPreviousMonth = () => onMonthChange(adapter.addMonths(month, -1));
161
160
  const isNextMonthDisabled = useNextMonthDisabled(month, {
162
161
  disableFuture,
163
162
  maxDate,
@@ -185,7 +184,7 @@ const PickersCalendarHeader = /*#__PURE__*/React.forwardRef(function PickersCale
185
184
  if (views.length === 1 && views[0] === 'year') {
186
185
  return null;
187
186
  }
188
- const label = utils.formatByString(month, format);
187
+ const label = adapter.formatByString(month, format);
189
188
  return /*#__PURE__*/_jsxs(PickersCalendarHeaderRoot, _extends({}, other, {
190
189
  ownerState: ownerState,
191
190
  className: clsx(classes.root, className),
@@ -11,7 +11,7 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
11
11
  import composeClasses from '@mui/utils/composeClasses';
12
12
  import useForkRef from '@mui/utils/useForkRef';
13
13
  import { alpha, styled, useThemeProps } from '@mui/material/styles';
14
- import { useUtils } from "../internals/hooks/useUtils.js";
14
+ import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
15
15
  import { DAY_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
16
16
  import { getPickersDayUtilityClass, pickersDayClasses } from "./pickersDayClasses.js";
17
17
  import { usePickerDayOwnerState } from "./usePickerDayOwnerState.js";
@@ -164,7 +164,7 @@ const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps,
164
164
  showDaysOutsideCurrentMonth
165
165
  });
166
166
  const classes = useUtilityClasses(classesProp, ownerState);
167
- const utils = useUtils();
167
+ const adapter = usePickerAdapter();
168
168
  const ref = React.useRef(null);
169
169
  const handleRef = useForkRef(ref, forwardedRef);
170
170
 
@@ -217,7 +217,7 @@ const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps,
217
217
  onMouseDown: handleMouseDown
218
218
  }, other, {
219
219
  ownerState: ownerState,
220
- children: children ?? utils.format(day, 'dayOfMonth')
220
+ children: children ?? adapter.format(day, 'dayOfMonth')
221
221
  }));
222
222
  });
223
223
  if (process.env.NODE_ENV !== "production") PickersDayRaw.displayName = "PickersDayRaw";
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
4
- import { useUtils } from "../internals/hooks/useUtils.js";
4
+ import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
5
5
  export function usePickerDayOwnerState(parameters) {
6
6
  const {
7
7
  disabled,
@@ -13,7 +13,7 @@ export function usePickerDayOwnerState(parameters) {
13
13
  disableHighlightToday,
14
14
  showDaysOutsideCurrentMonth
15
15
  } = parameters;
16
- const utils = useUtils();
16
+ const adapter = usePickerAdapter();
17
17
  const {
18
18
  ownerState: pickerOwnerState
19
19
  } = usePickerPrivateContext();
@@ -23,10 +23,10 @@ export function usePickerDayOwnerState(parameters) {
23
23
  isDayDisabled: disabled ?? false,
24
24
  isDayCurrent: today ?? false,
25
25
  isDayOutsideMonth: outsideCurrentMonth ?? false,
26
- isDayStartOfWeek: utils.isSameDay(day, utils.startOfWeek(day)),
27
- isDayEndOfWeek: utils.isSameDay(day, utils.endOfWeek(day)),
26
+ isDayStartOfWeek: adapter.isSameDay(day, adapter.startOfWeek(day)),
27
+ isDayEndOfWeek: adapter.isSameDay(day, adapter.endOfWeek(day)),
28
28
  disableMargin: disableMargin ?? false,
29
29
  disableHighlightToday: disableHighlightToday ?? false,
30
30
  showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth ?? false
31
- }), [utils, pickerOwnerState, day, selected, disabled, today, outsideCurrentMonth, disableMargin, disableHighlightToday, showDaysOutsideCurrentMonth]);
31
+ }), [adapter, pickerOwnerState, day, selected, disabled, today, outsideCurrentMonth, disableMargin, disableHighlightToday, showDaysOutsideCurrentMonth]);
32
32
  }
@@ -107,7 +107,7 @@ StaticDateTimePicker.propTypes = {
107
107
  // ----------------------------------------------------------------------
108
108
  /**
109
109
  * 12h/24h view for hour selection clock.
110
- * @default utils.is12HourCycleInCurrentLocale()
110
+ * @default adapter.is12HourCycleInCurrentLocale()
111
111
  */
112
112
  ampm: PropTypes.bool,
113
113
  /**
@@ -60,7 +60,7 @@ StaticTimePicker.propTypes = {
60
60
  // ----------------------------------------------------------------------
61
61
  /**
62
62
  * 12h/24h view for hour selection clock.
63
- * @default utils.is12HourCycleInCurrentLocale()
63
+ * @default adapter.is12HourCycleInCurrentLocale()
64
64
  */
65
65
  ampm: PropTypes.bool,
66
66
  /**
@@ -7,8 +7,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
7
7
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
8
8
  import composeClasses from '@mui/utils/composeClasses';
9
9
  import { ClockPointer } from "./ClockPointer.js";
10
- import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
11
- import { useUtils } from "../internals/hooks/useUtils.js";
10
+ import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
12
11
  import { CLOCK_HOUR_WIDTH, getHours, getMinutes } from "./shared.js";
13
12
  import { getClockUtilityClass } from "./clockClasses.js";
14
13
  import { formatMeridiem } from "../internals/utils/date-utils.js";
@@ -176,7 +175,7 @@ export function Clock(inProps) {
176
175
  className,
177
176
  classes: classesProp
178
177
  } = props;
179
- const utils = useUtils();
178
+ const adapter = usePickerAdapter();
180
179
  const translations = usePickerTranslations();
181
180
  const {
182
181
  ownerState: pickerOwnerState
@@ -310,7 +309,7 @@ export function Clock(inProps) {
310
309
  })]
311
310
  }), /*#__PURE__*/_jsx(ClockWrapper, {
312
311
  "aria-activedescendant": selectedId,
313
- "aria-label": translations.clockLabelText(type, value == null ? null : utils.format(value, ampm ? 'fullTime12h' : 'fullTime24h')),
312
+ "aria-label": translations.clockLabelText(type, value == null ? null : adapter.format(value, ampm ? 'fullTime12h' : 'fullTime24h')),
314
313
  ref: listboxRef,
315
314
  role: "listbox",
316
315
  onKeyDown: handleKeyDown,
@@ -324,22 +323,22 @@ export function Clock(inProps) {
324
323
  disabled: disabled || meridiemMode === null,
325
324
  ownerState: ownerState,
326
325
  className: classes.amButton,
327
- title: formatMeridiem(utils, 'am'),
326
+ title: formatMeridiem(adapter, 'am'),
328
327
  children: /*#__PURE__*/_jsx(ClockMeridiemText, {
329
328
  variant: "caption",
330
329
  className: classes.meridiemText,
331
- children: formatMeridiem(utils, 'am')
330
+ children: formatMeridiem(adapter, 'am')
332
331
  })
333
332
  }), /*#__PURE__*/_jsx(ClockPmButton, {
334
333
  disabled: disabled || meridiemMode === null,
335
334
  onClick: readOnly ? undefined : () => handleMeridiemChange('pm'),
336
335
  ownerState: ownerState,
337
336
  className: classes.pmButton,
338
- title: formatMeridiem(utils, 'pm'),
337
+ title: formatMeridiem(adapter, 'pm'),
339
338
  children: /*#__PURE__*/_jsx(ClockMeridiemText, {
340
339
  variant: "caption",
341
340
  className: classes.meridiemText,
342
- children: formatMeridiem(utils, 'pm')
341
+ children: formatMeridiem(adapter, 'pm')
343
342
  })
344
343
  })]
345
344
  })]
@@ -12,7 +12,7 @@ interface GetHourNumbersOptions {
12
12
  * Should only be `undefined` on the server
13
13
  */
14
14
  selectedId: string | undefined;
15
- utils: MuiPickersAdapter;
15
+ adapter: MuiPickersAdapter;
16
16
  }
17
17
  /**
18
18
  * @ignore - internal component.
@@ -23,10 +23,10 @@ export declare const getHourNumbers: ({
23
23
  getClockNumberText,
24
24
  isDisabled,
25
25
  selectedId,
26
- utils
26
+ adapter
27
27
  }: GetHourNumbersOptions) => React.JSX.Element[];
28
28
  export declare const getMinutesNumbers: ({
29
- utils,
29
+ adapter,
30
30
  value,
31
31
  isDisabled,
32
32
  getClockNumberText,
@@ -10,9 +10,9 @@ export const getHourNumbers = ({
10
10
  getClockNumberText,
11
11
  isDisabled,
12
12
  selectedId,
13
- utils
13
+ adapter
14
14
  }) => {
15
- const currentHours = value ? utils.getHours(value) : null;
15
+ const currentHours = value ? adapter.getHours(value) : null;
16
16
  const hourNumbers = [];
17
17
  const startHour = ampm ? 1 : 0;
18
18
  const endHour = ampm ? 12 : 23;
@@ -34,7 +34,7 @@ export const getHourNumbers = ({
34
34
  label = '00';
35
35
  }
36
36
  const inner = !ampm && (hour === 0 || hour > 12);
37
- label = utils.formatNumber(label);
37
+ label = adapter.formatNumber(label);
38
38
  const selected = isSelected(hour);
39
39
  hourNumbers.push(/*#__PURE__*/_jsx(ClockNumber, {
40
40
  id: selected ? selectedId : undefined,
@@ -49,13 +49,13 @@ export const getHourNumbers = ({
49
49
  return hourNumbers;
50
50
  };
51
51
  export const getMinutesNumbers = ({
52
- utils,
52
+ adapter,
53
53
  value,
54
54
  isDisabled,
55
55
  getClockNumberText,
56
56
  selectedId
57
57
  }) => {
58
- const f = utils.formatNumber;
58
+ const f = adapter.formatNumber;
59
59
  return [[5, f('05')], [10, f('10')], [15, f('15')], [20, f('20')], [25, f('25')], [30, f('30')], [35, f('35')], [40, f('40')], [45, f('45')], [50, f('50')], [55, f('55')], [0, f('00')]].map(([numberValue, label], index) => {
60
60
  const selected = numberValue === value;
61
61
  return /*#__PURE__*/_jsx(ClockNumber, {
@@ -9,8 +9,8 @@ import PropTypes from 'prop-types';
9
9
  import { styled, useThemeProps } from '@mui/material/styles';
10
10
  import composeClasses from '@mui/utils/composeClasses';
11
11
  import useId from '@mui/utils/useId';
12
- import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
13
- import { useUtils, useNow } from "../internals/hooks/useUtils.js";
12
+ import { usePickerAdapter, usePickerTranslations } from "../hooks/index.js";
13
+ import { useNow } from "../internals/hooks/useUtils.js";
14
14
  import { PickersArrowSwitcher } from "../internals/components/PickersArrowSwitcher/index.js";
15
15
  import { convertValueToMeridiem, createIsAfterIgnoreDatePart } from "../internals/utils/time-utils.js";
16
16
  import { useViews } from "../internals/hooks/useViews.js";
@@ -60,13 +60,13 @@ const TIME_CLOCK_DEFAULT_VIEWS = ['hours', 'minutes'];
60
60
  * - [TimeClock API](https://mui.com/x/api/date-pickers/time-clock/)
61
61
  */
62
62
  export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps, ref) {
63
- const utils = useUtils();
63
+ const adapter = usePickerAdapter();
64
64
  const props = useThemeProps({
65
65
  props: inProps,
66
66
  name: 'MuiTimeClock'
67
67
  });
68
68
  const {
69
- ampm = utils.is12HourCycleInCurrentLocale(),
69
+ ampm = adapter.is12HourCycleInCurrentLocale(),
70
70
  ampmInClock = false,
71
71
  autoFocus,
72
72
  slots,
@@ -112,7 +112,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
112
112
  const valueOrReferenceDate = useClockReferenceDate({
113
113
  value,
114
114
  referenceDate: referenceDateProp,
115
- utils,
115
+ adapter,
116
116
  props,
117
117
  timezone
118
118
  });
@@ -142,7 +142,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
142
142
  handleMeridiemChange
143
143
  } = useMeridiemMode(valueOrReferenceDate, ampm, setValueAndGoToNextView);
144
144
  const isTimeDisabled = React.useCallback((rawValue, viewType) => {
145
- const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, utils);
145
+ const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter);
146
146
  const shouldCheckPastEnd = viewType === 'hours' || viewType === 'minutes' && views.includes('seconds');
147
147
  const containsValidTime = ({
148
148
  start,
@@ -169,11 +169,11 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
169
169
  if (shouldDisableTime) {
170
170
  switch (viewType) {
171
171
  case 'hours':
172
- return !shouldDisableTime(utils.setHours(valueOrReferenceDate, timeValue), 'hours');
172
+ return !shouldDisableTime(adapter.setHours(valueOrReferenceDate, timeValue), 'hours');
173
173
  case 'minutes':
174
- return !shouldDisableTime(utils.setMinutes(valueOrReferenceDate, timeValue), 'minutes');
174
+ return !shouldDisableTime(adapter.setMinutes(valueOrReferenceDate, timeValue), 'minutes');
175
175
  case 'seconds':
176
- return !shouldDisableTime(utils.setSeconds(valueOrReferenceDate, timeValue), 'seconds');
176
+ return !shouldDisableTime(adapter.setSeconds(valueOrReferenceDate, timeValue), 'seconds');
177
177
  default:
178
178
  return false;
179
179
  }
@@ -184,12 +184,12 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
184
184
  case 'hours':
185
185
  {
186
186
  const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
187
- const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
188
- if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
187
+ const dateWithNewHours = adapter.setHours(valueOrReferenceDate, valueWithMeridiem);
188
+ if (adapter.getHours(dateWithNewHours) !== valueWithMeridiem) {
189
189
  return true;
190
190
  }
191
- const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
192
- const end = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
191
+ const start = adapter.setSeconds(adapter.setMinutes(dateWithNewHours, 0), 0);
192
+ const end = adapter.setSeconds(adapter.setMinutes(dateWithNewHours, 59), 59);
193
193
  return !containsValidTime({
194
194
  start,
195
195
  end
@@ -197,9 +197,9 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
197
197
  }
198
198
  case 'minutes':
199
199
  {
200
- const dateWithNewMinutes = utils.setMinutes(valueOrReferenceDate, rawValue);
201
- const start = utils.setSeconds(dateWithNewMinutes, 0);
202
- const end = utils.setSeconds(dateWithNewMinutes, 59);
200
+ const dateWithNewMinutes = adapter.setMinutes(valueOrReferenceDate, rawValue);
201
+ const start = adapter.setSeconds(dateWithNewMinutes, 0);
202
+ const end = adapter.setSeconds(dateWithNewMinutes, 59);
203
203
  return !containsValidTime({
204
204
  start,
205
205
  end
@@ -207,7 +207,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
207
207
  }
208
208
  case 'seconds':
209
209
  {
210
- const dateWithNewSeconds = utils.setSeconds(valueOrReferenceDate, rawValue);
210
+ const dateWithNewSeconds = adapter.setSeconds(valueOrReferenceDate, rawValue);
211
211
  const start = dateWithNewSeconds;
212
212
  const end = dateWithNewSeconds;
213
213
  return !containsValidTime({
@@ -218,16 +218,16 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
218
218
  default:
219
219
  throw new Error('not supported');
220
220
  }
221
- }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
221
+ }, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableTime, adapter, disableFuture, disablePast, now, views]);
222
222
  const viewProps = React.useMemo(() => {
223
223
  switch (view) {
224
224
  case 'hours':
225
225
  {
226
226
  const handleHoursChange = (hourValue, isFinish) => {
227
227
  const valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
228
- setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
228
+ setValueAndGoToNextView(adapter.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
229
229
  };
230
- const viewValue = utils.getHours(valueOrReferenceDate);
230
+ const viewValue = adapter.getHours(valueOrReferenceDate);
231
231
  let viewRange;
232
232
  if (ampm) {
233
233
  if (viewValue > 12) {
@@ -243,7 +243,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
243
243
  viewValue,
244
244
  children: getHourNumbers({
245
245
  value,
246
- utils,
246
+ adapter,
247
247
  ampm,
248
248
  onChange: handleHoursChange,
249
249
  getClockNumberText: translations.hoursClockNumberText,
@@ -255,15 +255,15 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
255
255
  }
256
256
  case 'minutes':
257
257
  {
258
- const minutesValue = utils.getMinutes(valueOrReferenceDate);
258
+ const minutesValue = adapter.getMinutes(valueOrReferenceDate);
259
259
  const handleMinutesChange = (minuteValue, isFinish) => {
260
- setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minuteValue), isFinish, 'minutes');
260
+ setValueAndGoToNextView(adapter.setMinutes(valueOrReferenceDate, minuteValue), isFinish, 'minutes');
261
261
  };
262
262
  return {
263
263
  viewValue: minutesValue,
264
264
  onChange: handleMinutesChange,
265
265
  children: getMinutesNumbers({
266
- utils,
266
+ adapter,
267
267
  value: minutesValue,
268
268
  onChange: handleMinutesChange,
269
269
  getClockNumberText: translations.minutesClockNumberText,
@@ -275,15 +275,15 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
275
275
  }
276
276
  case 'seconds':
277
277
  {
278
- const secondsValue = utils.getSeconds(valueOrReferenceDate);
278
+ const secondsValue = adapter.getSeconds(valueOrReferenceDate);
279
279
  const handleSecondsChange = (secondValue, isFinish) => {
280
- setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, secondValue), isFinish, 'seconds');
280
+ setValueAndGoToNextView(adapter.setSeconds(valueOrReferenceDate, secondValue), isFinish, 'seconds');
281
281
  };
282
282
  return {
283
283
  viewValue: secondsValue,
284
284
  onChange: handleSecondsChange,
285
285
  children: getMinutesNumbers({
286
- utils,
286
+ adapter,
287
287
  value: secondsValue,
288
288
  onChange: handleSecondsChange,
289
289
  getClockNumberText: translations.secondsClockNumberText,
@@ -296,7 +296,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
296
296
  default:
297
297
  throw new Error('You must provide the type for ClockView');
298
298
  }
299
- }, [view, utils, value, ampm, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, selectedId, disabled]);
299
+ }, [view, adapter, value, ampm, translations.hoursClockNumberText, translations.minutesClockNumberText, translations.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, selectedId, disabled]);
300
300
  const classes = useUtilityClasses(classesProp);
301
301
  return /*#__PURE__*/_jsxs(TimeClockRoot, _extends({
302
302
  ref: ref,
@@ -338,7 +338,7 @@ process.env.NODE_ENV !== "production" ? TimeClock.propTypes = {
338
338
  // ----------------------------------------------------------------------
339
339
  /**
340
340
  * 12h/24h view for hour selection clock.
341
- * @default utils.is12HourCycleInCurrentLocale()
341
+ * @default adapter.is12HourCycleInCurrentLocale()
342
342
  */
343
343
  ampm: PropTypes.bool,
344
344
  /**
@@ -51,7 +51,7 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
51
51
  // ----------------------------------------------------------------------
52
52
  /**
53
53
  * 12h/24h view for hour selection clock.
54
- * @default utils.is12HourCycleInCurrentLocale()
54
+ * @default adapter.is12HourCycleInCurrentLocale()
55
55
  */
56
56
  ampm: PropTypes.bool,
57
57
  /**
@@ -53,7 +53,7 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
53
53
  // ----------------------------------------------------------------------
54
54
  /**
55
55
  * 12h/24h view for hour selection clock.
56
- * @default utils.is12HourCycleInCurrentLocale()
56
+ * @default adapter.is12HourCycleInCurrentLocale()
57
57
  */
58
58
  ampm: PropTypes.bool,
59
59
  /**
@@ -12,12 +12,10 @@ import { PickersToolbarText } from "../internals/components/PickersToolbarText.j
12
12
  import { PickersToolbarButton } from "../internals/components/PickersToolbarButton.js";
13
13
  import { PickersToolbar } from "../internals/components/PickersToolbar.js";
14
14
  import { arrayIncludes } from "../internals/utils/utils.js";
15
- import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
16
- import { useUtils } from "../internals/hooks/useUtils.js";
15
+ import { usePickerAdapter, usePickerContext, usePickerTranslations } from "../hooks/index.js";
17
16
  import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
18
17
  import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
19
18
  import { formatMeridiem } from "../internals/utils/date-utils.js";
20
- import { usePickerContext } from "../hooks/index.js";
21
19
  import { useToolbarOwnerState } from "../internals/hooks/useToolbarOwnerState.js";
22
20
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
21
  const useUtilityClasses = (classes, ownerState) => {
@@ -124,7 +122,7 @@ function TimePickerToolbar(inProps) {
124
122
  classes: classesProp
125
123
  } = props,
126
124
  other = _objectWithoutPropertiesLoose(props, _excluded);
127
- const utils = useUtils();
125
+ const adapter = usePickerAdapter();
128
126
  const translations = usePickerTranslations();
129
127
  const ownerState = useToolbarOwnerState();
130
128
  const classes = useUtilityClasses(classesProp, ownerState);
@@ -145,10 +143,10 @@ function TimePickerToolbar(inProps) {
145
143
  changeImportance: 'set'
146
144
  }));
147
145
  const formatSection = format => {
148
- if (!utils.isValid(value)) {
146
+ if (!adapter.isValid(value)) {
149
147
  return '--';
150
148
  }
151
- return utils.format(value, format);
149
+ return adapter.format(value, format);
152
150
  };
153
151
  const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
154
152
  tabIndex: -1,
@@ -192,7 +190,7 @@ function TimePickerToolbar(inProps) {
192
190
  variant: "subtitle2",
193
191
  selected: meridiemMode === 'am',
194
192
  typographyClassName: classes.ampmLabel,
195
- value: formatMeridiem(utils, 'am'),
193
+ value: formatMeridiem(adapter, 'am'),
196
194
  onClick: readOnly ? undefined : () => handleMeridiemChange('am'),
197
195
  disabled: disabled
198
196
  }), /*#__PURE__*/_jsx(PickersToolbarButton, {
@@ -200,7 +198,7 @@ function TimePickerToolbar(inProps) {
200
198
  variant: "subtitle2",
201
199
  selected: meridiemMode === 'pm',
202
200
  typographyClassName: classes.ampmLabel,
203
- value: formatMeridiem(utils, 'pm'),
201
+ value: formatMeridiem(adapter, 'pm'),
204
202
  onClick: readOnly ? undefined : () => handleMeridiemChange('pm'),
205
203
  disabled: disabled
206
204
  })]
@@ -1,18 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useThemeProps } from '@mui/material/styles';
4
- import { useUtils } from "../internals/hooks/useUtils.js";
5
4
  import { TimePickerToolbar } from "./TimePickerToolbar.js";
6
5
  import { applyDefaultViewProps } from "../internals/utils/views.js";
7
6
  import { useApplyDefaultValuesToTimeValidationProps } from "../managers/useTimeManager.js";
7
+ import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
8
8
  export function useTimePickerDefaultizedProps(props, name) {
9
- const utils = useUtils();
9
+ const adapter = usePickerAdapter();
10
10
  const themeProps = useThemeProps({
11
11
  props,
12
12
  name
13
13
  });
14
14
  const validationProps = useApplyDefaultValuesToTimeValidationProps(themeProps);
15
- const ampm = themeProps.ampm ?? utils.is12HourCycleInCurrentLocale();
15
+ const ampm = themeProps.ampm ?? adapter.is12HourCycleInCurrentLocale();
16
16
  const localeText = React.useMemo(() => {
17
17
  if (themeProps.localeText?.toolbarTitle == null) {
18
18
  return themeProps.localeText;