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

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 (205) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/DatePicker/DatePickerToolbar.d.ts +1 -2
  3. package/DatePicker/DatePickerToolbar.js +6 -17
  4. package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
  5. package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
  6. package/DateTimePicker/DateTimePickerTabs.js +6 -13
  7. package/DateTimePicker/DateTimePickerToolbar.d.ts +8 -4
  8. package/DateTimePicker/DateTimePickerToolbar.js +13 -24
  9. package/DateTimePicker/shared.d.ts +2 -2
  10. package/DesktopDatePicker/DesktopDatePicker.types.d.ts +2 -3
  11. package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
  12. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
  13. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
  14. package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
  15. package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
  16. package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
  17. package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
  18. package/MonthCalendar/MonthCalendar.d.ts +1 -1
  19. package/MonthCalendar/MonthCalendar.js +31 -11
  20. package/MonthCalendar/MonthCalendar.types.d.ts +2 -2
  21. package/MonthCalendar/MonthCalendarButton.d.ts +24 -0
  22. package/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
  23. package/MonthCalendar/index.d.ts +0 -3
  24. package/MonthCalendar/index.js +1 -2
  25. package/MonthCalendar/monthCalendarClasses.d.ts +7 -1
  26. package/MonthCalendar/monthCalendarClasses.js +1 -1
  27. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
  28. package/PickersActionBar/PickersActionBar.d.ts +0 -4
  29. package/PickersActionBar/PickersActionBar.js +12 -13
  30. package/PickersLayout/PickersLayout.d.ts +2 -2
  31. package/PickersLayout/PickersLayout.js +1 -11
  32. package/PickersLayout/PickersLayout.types.d.ts +12 -14
  33. package/PickersLayout/usePickerLayout.d.ts +2 -2
  34. package/PickersLayout/usePickerLayout.js +3 -18
  35. package/PickersSectionList/PickersSectionList.js +21 -16
  36. package/PickersSectionList/PickersSectionList.types.d.ts +13 -6
  37. package/PickersTextField/PickersFilledInput/PickersFilledInput.d.ts +7 -0
  38. package/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
  39. package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.d.ts +1 -1
  40. package/PickersTextField/PickersInput/PickersInput.js +20 -14
  41. package/PickersTextField/PickersInput/pickersInputClasses.d.ts +3 -2
  42. package/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
  43. package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +3 -6
  44. package/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
  45. package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +1 -0
  46. package/PickersTextField/PickersOutlinedInput/Outline.d.ts +0 -1
  47. package/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
  48. package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
  49. package/PickersTextField/PickersTextField.js +75 -62
  50. package/PickersTextField/PickersTextField.types.d.ts +43 -4
  51. package/PickersTextField/usePickerTextFieldOwnerState.d.ts +4 -0
  52. package/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
  53. package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
  54. package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
  55. package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
  56. package/TimeClock/Clock.d.ts +4 -0
  57. package/TimeClock/Clock.js +9 -6
  58. package/TimeClock/TimeClock.js +21 -4
  59. package/TimePicker/TimePicker.types.d.ts +2 -2
  60. package/TimePicker/TimePickerToolbar.d.ts +2 -2
  61. package/TimePicker/TimePickerToolbar.js +6 -20
  62. package/YearCalendar/YearCalendar.js +46 -13
  63. package/YearCalendar/YearCalendar.types.d.ts +2 -2
  64. package/YearCalendar/YearCalendarButton.d.ts +23 -0
  65. package/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
  66. package/YearCalendar/index.d.ts +0 -3
  67. package/YearCalendar/index.js +1 -2
  68. package/YearCalendar/yearCalendarClasses.d.ts +7 -1
  69. package/YearCalendar/yearCalendarClasses.js +1 -1
  70. package/hooks/index.d.ts +1 -0
  71. package/hooks/index.js +2 -1
  72. package/hooks/usePickerActionsContext.d.ts +5 -0
  73. package/hooks/usePickerActionsContext.js +16 -0
  74. package/hooks/usePickerContext.d.ts +3 -1
  75. package/hooks/usePickerContext.js +0 -1
  76. package/index.js +1 -1
  77. package/internals/components/PickerProvider.d.ts +11 -6
  78. package/internals/components/PickerProvider.js +12 -6
  79. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  80. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -1
  81. package/internals/components/PickersModalDialog.d.ts +1 -3
  82. package/internals/components/PickersModalDialog.js +9 -3
  83. package/internals/components/PickersPopper.d.ts +1 -3
  84. package/internals/components/PickersPopper.js +11 -6
  85. package/internals/components/PickersToolbar.d.ts +3 -3
  86. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
  87. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +5 -5
  88. package/internals/hooks/useFieldOwnerState.d.ts +1 -0
  89. package/internals/hooks/useFieldOwnerState.js +6 -2
  90. package/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
  91. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +5 -5
  92. package/internals/hooks/usePicker/usePicker.js +1 -3
  93. package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
  94. package/internals/hooks/usePicker/usePickerProvider.js +5 -4
  95. package/internals/hooks/usePicker/usePickerValue.js +46 -64
  96. package/internals/hooks/usePicker/usePickerValue.types.d.ts +38 -17
  97. package/internals/hooks/usePicker/usePickerViews.d.ts +15 -4
  98. package/internals/hooks/usePicker/usePickerViews.js +9 -7
  99. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +4 -4
  100. package/internals/index.d.ts +4 -4
  101. package/internals/index.js +1 -1
  102. package/internals/models/props/tabs.d.ts +0 -13
  103. package/internals/models/props/toolbar.d.ts +1 -16
  104. package/models/fields.d.ts +11 -1
  105. package/modern/DatePicker/DatePickerToolbar.js +6 -17
  106. package/modern/DateTimePicker/DateTimePickerTabs.js +6 -13
  107. package/modern/DateTimePicker/DateTimePickerToolbar.js +13 -24
  108. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
  109. package/modern/MonthCalendar/MonthCalendar.js +31 -11
  110. package/modern/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
  111. package/modern/MonthCalendar/index.js +1 -2
  112. package/modern/MonthCalendar/monthCalendarClasses.js +1 -1
  113. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
  114. package/modern/PickersActionBar/PickersActionBar.js +12 -13
  115. package/modern/PickersLayout/PickersLayout.js +1 -11
  116. package/modern/PickersLayout/usePickerLayout.js +3 -18
  117. package/modern/PickersSectionList/PickersSectionList.js +21 -16
  118. package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
  119. package/modern/PickersTextField/PickersInput/PickersInput.js +20 -14
  120. package/modern/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
  121. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
  122. package/modern/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
  123. package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
  124. package/modern/PickersTextField/PickersTextField.js +75 -62
  125. package/modern/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
  126. package/modern/TimeClock/Clock.js +9 -6
  127. package/modern/TimeClock/TimeClock.js +21 -4
  128. package/modern/TimePicker/TimePickerToolbar.js +6 -20
  129. package/modern/YearCalendar/YearCalendar.js +46 -13
  130. package/modern/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
  131. package/modern/YearCalendar/index.js +1 -2
  132. package/modern/YearCalendar/yearCalendarClasses.js +1 -1
  133. package/modern/hooks/index.js +2 -1
  134. package/modern/hooks/usePickerActionsContext.js +16 -0
  135. package/modern/hooks/usePickerContext.js +0 -1
  136. package/modern/index.js +1 -1
  137. package/modern/internals/components/PickerProvider.js +12 -6
  138. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  139. package/modern/internals/components/PickersModalDialog.js +9 -3
  140. package/modern/internals/components/PickersPopper.js +11 -6
  141. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
  142. package/modern/internals/hooks/useFieldOwnerState.js +6 -2
  143. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
  144. package/modern/internals/hooks/usePicker/usePicker.js +1 -3
  145. package/modern/internals/hooks/usePicker/usePickerProvider.js +5 -4
  146. package/modern/internals/hooks/usePicker/usePickerValue.js +46 -64
  147. package/modern/internals/hooks/usePicker/usePickerViews.js +9 -7
  148. package/modern/internals/index.js +1 -1
  149. package/node/DatePicker/DatePickerToolbar.js +6 -17
  150. package/node/DateTimePicker/DateTimePickerTabs.js +6 -13
  151. package/node/DateTimePicker/DateTimePickerToolbar.js +14 -25
  152. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
  153. package/node/MonthCalendar/MonthCalendar.js +31 -11
  154. package/node/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
  155. package/node/MonthCalendar/index.js +1 -8
  156. package/node/MonthCalendar/monthCalendarClasses.js +1 -1
  157. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
  158. package/node/PickersActionBar/PickersActionBar.js +12 -13
  159. package/node/PickersLayout/PickersLayout.js +1 -11
  160. package/node/PickersLayout/usePickerLayout.js +3 -18
  161. package/node/PickersSectionList/PickersSectionList.js +21 -16
  162. package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
  163. package/node/PickersTextField/PickersInput/PickersInput.js +20 -14
  164. package/node/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
  165. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
  166. package/node/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
  167. package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
  168. package/node/PickersTextField/PickersTextField.js +75 -62
  169. package/node/PickersTextField/usePickerTextFieldOwnerState.js +18 -0
  170. package/node/TimeClock/Clock.js +9 -6
  171. package/node/TimeClock/TimeClock.js +21 -4
  172. package/node/TimePicker/TimePickerToolbar.js +6 -20
  173. package/node/YearCalendar/YearCalendar.js +45 -12
  174. package/node/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
  175. package/node/YearCalendar/index.js +1 -8
  176. package/node/YearCalendar/yearCalendarClasses.js +1 -1
  177. package/node/hooks/index.js +8 -1
  178. package/node/hooks/usePickerActionsContext.js +22 -0
  179. package/node/index.js +1 -1
  180. package/node/internals/components/PickerProvider.js +13 -7
  181. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
  182. package/node/internals/components/PickersModalDialog.js +9 -3
  183. package/node/internals/components/PickersPopper.js +11 -6
  184. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
  185. package/node/internals/hooks/useFieldOwnerState.js +6 -2
  186. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
  187. package/node/internals/hooks/usePicker/usePicker.js +1 -3
  188. package/node/internals/hooks/usePicker/usePickerProvider.js +5 -4
  189. package/node/internals/hooks/usePicker/usePickerValue.js +46 -64
  190. package/node/internals/hooks/usePicker/usePickerViews.js +9 -7
  191. package/node/internals/index.js +2 -2
  192. package/package.json +3 -3
  193. package/themeAugmentation/components.d.ts +0 -8
  194. package/themeAugmentation/overrides.d.ts +2 -4
  195. package/themeAugmentation/props.d.ts +4 -7
  196. package/MonthCalendar/PickersMonth.d.ts +0 -28
  197. package/MonthCalendar/pickersMonthClasses.d.ts +0 -13
  198. package/MonthCalendar/pickersMonthClasses.js +0 -5
  199. package/YearCalendar/PickersYear.d.ts +0 -27
  200. package/YearCalendar/pickersYearClasses.d.ts +0 -13
  201. package/YearCalendar/pickersYearClasses.js +0 -5
  202. package/modern/MonthCalendar/pickersMonthClasses.js +0 -5
  203. package/modern/YearCalendar/pickersYearClasses.js +0 -5
  204. package/node/MonthCalendar/pickersMonthClasses.js +0 -12
  205. package/node/YearCalendar/pickersYearClasses.js +0 -12
@@ -5,4 +5,4 @@ import { pickersInputBaseClasses } from "../PickersInputBase/index.js";
5
5
  export function getPickersInputUtilityClass(slot) {
6
6
  return generateUtilityClass('MuiPickersFilledInput', slot);
7
7
  }
8
- export const pickersInputClasses = _extends({}, pickersInputBaseClasses, generateUtilityClasses('MuiPickersInput', ['root', 'input']));
8
+ export const pickersInputClasses = _extends({}, pickersInputBaseClasses, generateUtilityClasses('MuiPickersInput', ['root', 'underline', 'input']));
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "slotProps", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "name", "readOnly", "inputProps", "inputRef", "sectionListRef", "onFocus", "onBlur"];
3
+ const _excluded = ["elements", "areAllSectionsEmpty", "defaultValue", "label", "value", "onChange", "id", "autoFocus", "endAdornment", "startAdornment", "renderSuffix", "slots", "slotProps", "contentEditable", "tabIndex", "onInput", "onPaste", "onKeyDown", "fullWidth", "name", "readOnly", "inputProps", "inputRef", "sectionListRef", "onFocus", "onBlur", "classes", "ownerState"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useFormControl } from '@mui/material/FormControl';
@@ -11,9 +11,9 @@ import composeClasses from '@mui/utils/composeClasses';
11
11
  import capitalize from '@mui/utils/capitalize';
12
12
  import useSlotProps from '@mui/utils/useSlotProps';
13
13
  import visuallyHidden from '@mui/utils/visuallyHidden';
14
- import { useRtl } from '@mui/system/RtlProvider';
15
14
  import { pickersInputBaseClasses, getPickersInputBaseUtilityClass } from "./pickersInputBaseClasses.js";
16
15
  import { Unstable_PickersSectionList as PickersSectionList, Unstable_PickersSectionListRoot as PickersSectionListRoot, Unstable_PickersSectionListSection as PickersSectionListSection, Unstable_PickersSectionListSectionSeparator as PickersSectionListSectionSeparator, Unstable_PickersSectionListSectionContent as PickersSectionListSectionContent } from "../../PickersSectionList/index.js";
16
+ import { usePickerTextFieldOwnerState } from "../usePickerTextFieldOwnerState.js";
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  const round = value => Math.round(value * 1e5) / 1e5;
19
19
  export const PickersInputBaseRoot = styled('div', {
@@ -35,7 +35,7 @@ export const PickersInputBaseRoot = styled('div', {
35
35
  letterSpacing: `${round(0.15 / 16)}em`,
36
36
  variants: [{
37
37
  props: {
38
- fullWidth: true
38
+ isInputInFullWidth: true
39
39
  },
40
40
  style: {
41
41
  width: '100%'
@@ -64,36 +64,35 @@ export const PickersInputBaseSectionsContainer = styled(PickersSectionListRoot,
64
64
  width: '182px',
65
65
  variants: [{
66
66
  props: {
67
- isRtl: true
67
+ fieldDirection: 'rtl'
68
68
  },
69
69
  style: {
70
70
  textAlign: 'right /*! @noflip */'
71
71
  }
72
72
  }, {
73
73
  props: {
74
- size: 'small'
74
+ inputSize: 'small'
75
75
  },
76
76
  style: {
77
77
  paddingTop: 1
78
78
  }
79
79
  }, {
80
80
  props: {
81
- adornedStart: false,
82
- focused: false,
83
- filled: false
81
+ hasStartAdornment: false,
82
+ isFieldFocused: false,
83
+ isFieldValueEmpty: true
84
84
  },
85
85
  style: {
86
86
  color: 'currentColor',
87
87
  opacity: 0
88
88
  }
89
89
  }, {
90
- // Can't use the object notation because label can be null or undefined
91
- props: ({
92
- adornedStart,
93
- focused,
94
- filled,
95
- label
96
- }) => !adornedStart && !focused && !filled && label == null,
90
+ props: {
91
+ hasStartAdornment: false,
92
+ isFieldFocused: false,
93
+ isFieldValueEmpty: true,
94
+ inputHasLabel: false
95
+ },
97
96
  style: theme.vars ? {
98
97
  opacity: theme.vars.opacity.inputPlaceholder
99
98
  } : {
@@ -142,21 +141,20 @@ const PickersInputBaseInput = styled('input', {
142
141
  slot: 'Input',
143
142
  overridesResolver: (props, styles) => styles.hiddenInput
144
143
  })(_extends({}, visuallyHidden));
145
- const useUtilityClasses = ownerState => {
144
+ const useUtilityClasses = (classes, ownerState) => {
146
145
  const {
147
- focused,
148
- disabled,
149
- error,
150
- classes,
151
- fullWidth,
152
- readOnly,
153
- color,
154
- size,
155
- endAdornment,
156
- startAdornment
146
+ isFieldFocused,
147
+ isFieldDisabled,
148
+ isFieldReadOnly,
149
+ hasFieldError,
150
+ inputSize,
151
+ isInputInFullWidth,
152
+ inputColor,
153
+ hasStartAdornment,
154
+ hasEndAdornment
157
155
  } = ownerState;
158
156
  const slots = {
159
- root: ['root', focused && !disabled && 'focused', disabled && 'disabled', readOnly && 'readOnly', error && 'error', fullWidth && 'fullWidth', `color${capitalize(color)}`, size === 'small' && 'inputSizeSmall', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
157
+ root: ['root', isFieldFocused && !isFieldDisabled && 'focused', isFieldDisabled && 'disabled', isFieldReadOnly && 'readOnly', hasFieldError && 'error', isInputInFullWidth && 'fullWidth', `color${capitalize(inputColor)}`, inputSize === 'small' && 'inputSizeSmall', hasStartAdornment && 'adornedStart', hasEndAdornment && 'adornedEnd'],
160
158
  notchedOutline: ['notchedOutline'],
161
159
  input: ['input'],
162
160
  sectionsContainer: ['sectionsContainer'],
@@ -166,6 +164,7 @@ const useUtilityClasses = ownerState => {
166
164
  };
167
165
  return composeClasses(slots, getPickersInputBaseUtilityClass, classes);
168
166
  };
167
+
169
168
  /**
170
169
  * @ignore - internal component.
171
170
  */
@@ -196,17 +195,20 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
196
195
  inputRef,
197
196
  sectionListRef,
198
197
  onFocus,
199
- onBlur
198
+ onBlur,
199
+ classes: classesProp,
200
+ ownerState: ownerStateProp
200
201
  } = props,
201
202
  other = _objectWithoutPropertiesLoose(props, _excluded);
203
+ const ownerStateContext = usePickerTextFieldOwnerState();
202
204
  const rootRef = React.useRef(null);
203
205
  const handleRootRef = useForkRef(ref, rootRef);
204
206
  const handleInputRef = useForkRef(inputProps?.ref, inputRef);
205
- const isRtl = useRtl();
206
207
  const muiFormControl = useFormControl();
207
208
  if (!muiFormControl) {
208
209
  throw new Error('MUI X: PickersInputBase should always be used inside a PickersTextField component');
209
210
  }
211
+ const ownerState = ownerStateProp ?? ownerStateContext;
210
212
  const handleInputFocus = event => {
211
213
  muiFormControl.onFocus?.(event);
212
214
  onFocus?.(event);
@@ -230,10 +232,7 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
230
232
  muiFormControl.onFilled();
231
233
  }
232
234
  }, [muiFormControl, areAllSectionsEmpty]);
233
- const ownerState = _extends({}, props, muiFormControl, {
234
- isRtl
235
- });
236
- const classes = useUtilityClasses(ownerState);
235
+ const classes = useUtilityClasses(classesProp, ownerState);
237
236
  const InputRoot = slots?.root || PickersInputBaseRoot;
238
237
  const inputRootProps = useSlotProps({
239
238
  elementType: InputRoot,
@@ -266,16 +265,16 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
266
265
  sectionSeparator: PickersInputBaseSectionSeparator
267
266
  },
268
267
  slotProps: {
269
- root: {
268
+ root: _extends({}, slotProps?.input, {
270
269
  ownerState
271
- },
270
+ }),
272
271
  sectionContent: {
273
272
  className: pickersInputBaseClasses.sectionContent
274
273
  },
275
274
  sectionSeparator: ({
276
- position
275
+ separatorPosition
277
276
  }) => ({
278
- className: position === 'before' ? pickersInputBaseClasses.sectionBefore : pickersInputBaseClasses.sectionAfter
277
+ className: separatorPosition === 'before' ? pickersInputBaseClasses.sectionBefore : pickersInputBaseClasses.sectionAfter
279
278
  })
280
279
  }
281
280
  }), endAdornment, renderSuffix ? renderSuffix(_extends({}, muiFormControl)) : null, /*#__PURE__*/_jsx(PickersInputBaseInput, _extends({
@@ -3,6 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["children", "className", "label", "notched", "shrink"];
4
4
  import * as React from 'react';
5
5
  import { styled } from '@mui/material/styles';
6
+ import { shouldForwardProp } from '@mui/system/createStyled';
7
+ import { usePickerTextFieldOwnerState } from "../usePickerTextFieldOwnerState.js";
6
8
  import { jsx as _jsx } from "react/jsx-runtime";
7
9
  const OutlineRoot = styled('fieldset', {
8
10
  name: 'MuiPickersOutlinedInput',
@@ -36,7 +38,9 @@ const OutlineLabel = styled('span')(({
36
38
  fontFamily: theme.typography.fontFamily,
37
39
  fontSize: 'inherit'
38
40
  }));
39
- const OutlineLegend = styled('legend')(({
41
+ const OutlineLegend = styled('legend', {
42
+ shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'notched'
43
+ })(({
40
44
  theme
41
45
  }) => ({
42
46
  float: 'unset',
@@ -47,7 +51,7 @@ const OutlineLegend = styled('legend')(({
47
51
  // Fix Horizontal scroll when label too long
48
52
  variants: [{
49
53
  props: {
50
- withLabel: false
54
+ inputHasLabel: false
51
55
  },
52
56
  style: {
53
57
  padding: 0,
@@ -60,7 +64,7 @@ const OutlineLegend = styled('legend')(({
60
64
  }
61
65
  }, {
62
66
  props: {
63
- withLabel: true
67
+ inputHasLabel: true
64
68
  },
65
69
  style: {
66
70
  display: 'block',
@@ -86,7 +90,7 @@ const OutlineLegend = styled('legend')(({
86
90
  }
87
91
  }, {
88
92
  props: {
89
- withLabel: true,
93
+ inputHasLabel: true,
90
94
  notched: true
91
95
  },
92
96
  style: {
@@ -106,13 +110,11 @@ const OutlineLegend = styled('legend')(({
106
110
  export default function Outline(props) {
107
111
  const {
108
112
  className,
109
- label
113
+ label,
114
+ notched
110
115
  } = props,
111
116
  other = _objectWithoutPropertiesLoose(props, _excluded);
112
- const withLabel = label != null && label !== '';
113
- const ownerState = _extends({}, props, {
114
- withLabel
115
- });
117
+ const ownerState = usePickerTextFieldOwnerState();
116
118
  return /*#__PURE__*/_jsx(OutlineRoot, _extends({
117
119
  "aria-hidden": true,
118
120
  className: className
@@ -120,7 +122,8 @@ export default function Outline(props) {
120
122
  ownerState: ownerState,
121
123
  children: /*#__PURE__*/_jsx(OutlineLegend, {
122
124
  ownerState: ownerState,
123
- children: withLabel ? /*#__PURE__*/_jsx(OutlineLabel, {
125
+ notched: notched,
126
+ children: label ? /*#__PURE__*/_jsx(OutlineLabel, {
124
127
  children: label
125
128
  }) :
126
129
  /*#__PURE__*/
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["label", "autoFocus", "ownerState", "notched"];
3
+ const _excluded = ["label", "autoFocus", "ownerState", "classes", "notched"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useFormControl } from '@mui/material/FormControl';
@@ -51,7 +51,7 @@ const PickersOutlinedInputRoot = styled(PickersInputBaseRoot, {
51
51
  // @ts-ignore
52
52
  .filter(key => (theme.vars ?? theme).palette[key]?.main ?? false).map(color => ({
53
53
  props: {
54
- color
54
+ inputColor: color
55
55
  },
56
56
  style: {
57
57
  [`&.${pickersOutlinedInputClasses.focused}:not(.${pickersOutlinedInputClasses.error}) .${pickersOutlinedInputClasses.notchedOutline}`]: {
@@ -70,17 +70,14 @@ const PickersOutlinedInputSectionsContainer = styled(PickersInputBaseSectionsCon
70
70
  padding: '16.5px 0',
71
71
  variants: [{
72
72
  props: {
73
- size: 'small'
73
+ inputSize: 'small'
74
74
  },
75
75
  style: {
76
76
  padding: '8.5px 0'
77
77
  }
78
78
  }]
79
79
  });
80
- const useUtilityClasses = ownerState => {
81
- const {
82
- classes
83
- } = ownerState;
80
+ const useUtilityClasses = classes => {
84
81
  const slots = {
85
82
  root: ['root'],
86
83
  notchedOutline: ['notchedOutline'],
@@ -89,6 +86,7 @@ const useUtilityClasses = ownerState => {
89
86
  const composedClasses = composeClasses(slots, getPickersOutlinedInputUtilityClass, classes);
90
87
  return _extends({}, classes, composedClasses);
91
88
  };
89
+
92
90
  /**
93
91
  * @ignore - internal component.
94
92
  */
@@ -99,15 +97,12 @@ const PickersOutlinedInput = /*#__PURE__*/React.forwardRef(function PickersOutli
99
97
  });
100
98
  const {
101
99
  label,
102
- ownerState: ownerStateProp,
100
+ classes: classesProp,
103
101
  notched
104
102
  } = props,
105
103
  other = _objectWithoutPropertiesLoose(props, _excluded);
106
104
  const muiFormControl = useFormControl();
107
- const ownerState = _extends({}, props, ownerStateProp, muiFormControl, {
108
- color: muiFormControl?.color || 'primary'
109
- });
110
- const classes = useUtilityClasses(ownerState);
105
+ const classes = useUtilityClasses(classesProp);
111
106
  return /*#__PURE__*/_jsx(PickersInputBase, _extends({
112
107
  slots: {
113
108
  root: PickersOutlinedInputRoot,
@@ -119,8 +114,7 @@ const PickersOutlinedInput = /*#__PURE__*/React.forwardRef(function PickersOutli
119
114
  className: classes.notchedOutline,
120
115
  label: label != null && label !== '' && muiFormControl?.required ? /*#__PURE__*/_jsxs(React.Fragment, {
121
116
  children: [label, "\u2009", '*']
122
- }) : label,
123
- ownerState: ownerState
117
+ }) : label
124
118
  })
125
119
  }, other, {
126
120
  label: label,
@@ -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 = ["onFocus", "onBlur", "className", "color", "disabled", "error", "variant", "required", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
5
+ const _excluded = ["onFocus", "onBlur", "className", "classes", "color", "disabled", "error", "variant", "required", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "name", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -18,6 +18,8 @@ import { getPickersTextFieldUtilityClass } from "./pickersTextFieldClasses.js";
18
18
  import { PickersOutlinedInput } from "./PickersOutlinedInput/index.js";
19
19
  import { PickersFilledInput } from "./PickersFilledInput/index.js";
20
20
  import { PickersInput } from "./PickersInput/index.js";
21
+ import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
22
+ import { PickerTextFieldOwnerStateContext } from "./usePickerTextFieldOwnerState.js";
21
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
24
  const VARIANT_COMPONENT = {
23
25
  standard: PickersInput,
@@ -29,15 +31,14 @@ const PickersTextFieldRoot = styled(FormControl, {
29
31
  slot: 'Root',
30
32
  overridesResolver: (props, styles) => styles.root
31
33
  })({});
32
- const useUtilityClasses = ownerState => {
34
+ const useUtilityClasses = (classes, ownerState) => {
33
35
  const {
34
- focused,
35
- disabled,
36
- classes,
37
- required
36
+ isFieldFocused,
37
+ isFieldDisabled,
38
+ isFieldRequired
38
39
  } = ownerState;
39
40
  const slots = {
40
- root: ['root', focused && !disabled && 'focused', disabled && 'disabled', required && 'required']
41
+ root: ['root', isFieldFocused && !isFieldDisabled && 'focused', isFieldDisabled && 'disabled', isFieldRequired && 'required']
41
42
  };
42
43
  return composeClasses(slots, getPickersTextFieldUtilityClass, classes);
43
44
  };
@@ -51,6 +52,7 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
51
52
  onFocus,
52
53
  onBlur,
53
54
  className,
55
+ classes: classesProp,
54
56
  color = 'primary',
55
57
  disabled = false,
56
58
  error = false,
@@ -91,64 +93,75 @@ const PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField
91
93
  const id = useId(idProp);
92
94
  const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
93
95
  const inputLabelId = label && id ? `${id}-label` : undefined;
94
- const ownerState = _extends({}, props, {
95
- color,
96
- disabled,
97
- error,
98
- focused,
99
- required,
100
- variant
96
+ const fieldOwnerState = useFieldOwnerState({
97
+ disabled: props.disabled,
98
+ required: props.required,
99
+ readOnly: InputProps?.readOnly
101
100
  });
102
- const classes = useUtilityClasses(ownerState);
101
+ const ownerState = React.useMemo(() => _extends({}, fieldOwnerState, {
102
+ isFieldValueEmpty: areAllSectionsEmpty,
103
+ isFieldFocused: focused ?? false,
104
+ hasFieldError: error ?? false,
105
+ inputSize: props.size ?? 'medium',
106
+ inputColor: color ?? 'primary',
107
+ isInputInFullWidth: fullWidth ?? false,
108
+ hasStartAdornment: Boolean(startAdornment ?? InputProps?.startAdornment),
109
+ hasEndAdornment: Boolean(endAdornment ?? InputProps?.endAdornment),
110
+ inputHasLabel: !!label
111
+ }), [fieldOwnerState, areAllSectionsEmpty, focused, error, props.size, color, fullWidth, startAdornment, endAdornment, InputProps?.startAdornment, InputProps?.endAdornment, label]);
112
+ const classes = useUtilityClasses(classesProp, ownerState);
103
113
  const PickersInputComponent = VARIANT_COMPONENT[variant];
104
- return /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
105
- className: clsx(classes.root, className),
106
- ref: handleRootRef,
107
- focused: focused,
108
- disabled: disabled,
109
- variant: variant,
110
- error: error,
111
- color: color,
112
- fullWidth: fullWidth,
113
- required: required,
114
- ownerState: ownerState
115
- }, other, {
116
- children: [/*#__PURE__*/_jsx(InputLabel, _extends({
117
- htmlFor: id,
118
- id: inputLabelId
119
- }, InputLabelProps, {
120
- children: label
121
- })), /*#__PURE__*/_jsx(PickersInputComponent, _extends({
122
- elements: elements,
123
- areAllSectionsEmpty: areAllSectionsEmpty,
124
- onClick: onClick,
125
- onKeyDown: onKeyDown,
126
- onKeyUp: onKeyUp,
127
- onInput: onInput,
128
- onPaste: onPaste,
129
- onFocus: onFocus,
130
- onBlur: onBlur,
131
- endAdornment: endAdornment,
132
- startAdornment: startAdornment,
133
- tabIndex: tabIndex,
134
- contentEditable: contentEditable,
135
- value: value,
136
- onChange: onChange,
137
- id: id,
114
+ return /*#__PURE__*/_jsx(PickerTextFieldOwnerStateContext.Provider, {
115
+ value: ownerState,
116
+ children: /*#__PURE__*/_jsxs(PickersTextFieldRoot, _extends({
117
+ className: clsx(classes.root, className),
118
+ ref: handleRootRef,
119
+ focused: focused,
120
+ disabled: disabled,
121
+ variant: variant,
122
+ error: error,
123
+ color: color,
138
124
  fullWidth: fullWidth,
139
- inputProps: inputProps,
140
- inputRef: inputRef,
141
- sectionListRef: sectionListRef,
142
- label: label,
143
- name: name,
144
- role: "group",
145
- "aria-labelledby": inputLabelId
146
- }, InputProps)), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
147
- id: helperTextId
148
- }, FormHelperTextProps, {
149
- children: helperText
150
- }))]
151
- }));
125
+ required: required,
126
+ ownerState: ownerState
127
+ }, other, {
128
+ children: [/*#__PURE__*/_jsx(InputLabel, _extends({
129
+ htmlFor: id,
130
+ id: inputLabelId
131
+ }, InputLabelProps, {
132
+ children: label
133
+ })), /*#__PURE__*/_jsx(PickersInputComponent, _extends({
134
+ elements: elements,
135
+ areAllSectionsEmpty: areAllSectionsEmpty,
136
+ onClick: onClick,
137
+ onKeyDown: onKeyDown,
138
+ onKeyUp: onKeyUp,
139
+ onInput: onInput,
140
+ onPaste: onPaste,
141
+ onFocus: onFocus,
142
+ onBlur: onBlur,
143
+ endAdornment: endAdornment,
144
+ startAdornment: startAdornment,
145
+ tabIndex: tabIndex,
146
+ contentEditable: contentEditable,
147
+ value: value,
148
+ onChange: onChange,
149
+ id: id,
150
+ fullWidth: fullWidth,
151
+ inputProps: inputProps,
152
+ inputRef: inputRef,
153
+ sectionListRef: sectionListRef,
154
+ label: label,
155
+ name: name,
156
+ role: "group",
157
+ "aria-labelledby": inputLabelId
158
+ }, InputProps)), helperText && /*#__PURE__*/_jsx(FormHelperText, _extends({
159
+ id: helperTextId
160
+ }, FormHelperTextProps, {
161
+ children: helperText
162
+ }))]
163
+ }))
164
+ });
152
165
  });
153
166
  process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
154
167
  // ----------------------------- Warning --------------------------------
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ export const PickerTextFieldOwnerStateContext = /*#__PURE__*/React.createContext(null);
5
+ export const usePickerTextFieldOwnerState = () => {
6
+ const value = React.useContext(PickerTextFieldOwnerStateContext);
7
+ if (value == null) {
8
+ throw new Error(['MUI X: The `usePickerTextFieldOwnerState` can only be called in components that are used inside a PickerTextField component'].join('\n'));
9
+ }
10
+ return value;
11
+ };
@@ -177,6 +177,7 @@ export function Clock(inProps) {
177
177
  selectedId,
178
178
  type,
179
179
  viewValue,
180
+ viewRange: [minViewValue, maxViewValue],
180
181
  disabled = false,
181
182
  readOnly,
182
183
  className,
@@ -251,6 +252,8 @@ export function Clock(inProps) {
251
252
  listboxRef.current.focus();
252
253
  }
253
254
  }, [autoFocus]);
255
+ const clampValue = newValue => Math.max(minViewValue, Math.min(maxViewValue, newValue));
256
+ const circleValue = newValue => (newValue + (maxViewValue + 1)) % (maxViewValue + 1);
254
257
  const handleKeyDown = event => {
255
258
  // TODO: Why this early exit?
256
259
  if (isMoving.current) {
@@ -259,27 +262,27 @@ export function Clock(inProps) {
259
262
  switch (event.key) {
260
263
  case 'Home':
261
264
  // reset both hours and minutes
262
- handleValueChange(0, 'partial');
265
+ handleValueChange(minViewValue, 'partial');
263
266
  event.preventDefault();
264
267
  break;
265
268
  case 'End':
266
- handleValueChange(type === 'minutes' ? 59 : 23, 'partial');
269
+ handleValueChange(maxViewValue, 'partial');
267
270
  event.preventDefault();
268
271
  break;
269
272
  case 'ArrowUp':
270
- handleValueChange(viewValue + keyboardControlStep, 'partial');
273
+ handleValueChange(circleValue(viewValue + keyboardControlStep), 'partial');
271
274
  event.preventDefault();
272
275
  break;
273
276
  case 'ArrowDown':
274
- handleValueChange(viewValue - keyboardControlStep, 'partial');
277
+ handleValueChange(circleValue(viewValue - keyboardControlStep), 'partial');
275
278
  event.preventDefault();
276
279
  break;
277
280
  case 'PageUp':
278
- handleValueChange(viewValue + 5, 'partial');
281
+ handleValueChange(clampValue(viewValue + 5), 'partial');
279
282
  event.preventDefault();
280
283
  break;
281
284
  case 'PageDown':
282
- handleValueChange(viewValue - 5, 'partial');
285
+ handleValueChange(clampValue(viewValue - 5), 'partial');
283
286
  event.preventDefault();
284
287
  break;
285
288
  case 'Enter':
@@ -186,6 +186,9 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
186
186
  {
187
187
  const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
188
188
  const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
189
+ if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
190
+ return true;
191
+ }
189
192
  const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
190
193
  const end = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
191
194
  return !containsValidTime({
@@ -225,9 +228,20 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
225
228
  const valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
226
229
  setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
227
230
  };
231
+ const viewValue = utils.getHours(valueOrReferenceDate);
232
+ let viewRange;
233
+ if (ampm) {
234
+ if (viewValue > 12) {
235
+ viewRange = [12, 23];
236
+ } else {
237
+ viewRange = [0, 11];
238
+ }
239
+ } else {
240
+ viewRange = [0, 23];
241
+ }
228
242
  return {
229
243
  onChange: handleHoursChange,
230
- viewValue: utils.getHours(valueOrReferenceDate),
244
+ viewValue,
231
245
  children: getHourNumbers({
232
246
  value,
233
247
  utils,
@@ -236,7 +250,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
236
250
  getClockNumberText: translations.hoursClockNumberText,
237
251
  isDisabled: hourValue => disabled || isTimeDisabled(hourValue, 'hours'),
238
252
  selectedId
239
- })
253
+ }),
254
+ viewRange
240
255
  };
241
256
  }
242
257
  case 'minutes':
@@ -255,7 +270,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
255
270
  getClockNumberText: translations.minutesClockNumberText,
256
271
  isDisabled: minuteValue => disabled || isTimeDisabled(minuteValue, 'minutes'),
257
272
  selectedId
258
- })
273
+ }),
274
+ viewRange: [0, 59]
259
275
  };
260
276
  }
261
277
  case 'seconds':
@@ -274,7 +290,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
274
290
  getClockNumberText: translations.secondsClockNumberText,
275
291
  isDisabled: secondValue => disabled || isTimeDisabled(secondValue, 'seconds'),
276
292
  selectedId
277
- })
293
+ }),
294
+ viewRange: [0, 59]
278
295
  };
279
296
  }
280
297
  default: