@mui/x-date-pickers 8.0.0-alpha.0 → 8.0.0-alpha.2

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 (223) hide show
  1. package/AdapterMoment/AdapterMoment.js +10 -0
  2. package/CHANGELOG.md +651 -6
  3. package/DateCalendar/DateCalendar.js +1 -0
  4. package/DateCalendar/DateCalendar.types.d.ts +2 -1
  5. package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  6. package/DateCalendar/PickersSlideTransition.js +12 -5
  7. package/DateCalendar/useCalendarState.d.ts +6 -4
  8. package/DateField/DateField.js +5 -4
  9. package/DateField/DateField.types.d.ts +10 -9
  10. package/DatePicker/DatePicker.types.d.ts +3 -3
  11. package/DatePicker/DatePickerToolbar.d.ts +3 -2
  12. package/DatePicker/DatePickerToolbar.js +0 -12
  13. package/DatePicker/shared.d.ts +6 -5
  14. package/DateTimeField/DateTimeField.js +5 -4
  15. package/DateTimeField/DateTimeField.types.d.ts +10 -10
  16. package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  17. package/DateTimePicker/DateTimePickerTabs.js +8 -6
  18. package/DateTimePicker/DateTimePickerToolbar.d.ts +3 -4
  19. package/DateTimePicker/DateTimePickerToolbar.js +6 -15
  20. package/DateTimePicker/shared.d.ts +6 -6
  21. package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  22. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
  23. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
  24. package/DigitalClock/DigitalClock.js +1 -0
  25. package/MonthCalendar/MonthCalendar.js +1 -0
  26. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  27. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
  28. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
  29. package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  30. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
  31. package/PickersLayout/PickersLayout.d.ts +7 -5
  32. package/PickersLayout/PickersLayout.js +22 -39
  33. package/PickersLayout/PickersLayout.types.d.ts +14 -15
  34. package/PickersLayout/usePickerLayout.d.ts +5 -4
  35. package/PickersLayout/usePickerLayout.js +20 -17
  36. package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
  37. package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  38. package/PickersTextField/PickersTextField.js +2 -2
  39. package/README.md +9 -6
  40. package/TimeClock/Clock.js +1 -0
  41. package/TimeClock/TimeClock.js +1 -0
  42. package/TimeField/TimeField.js +5 -4
  43. package/TimeField/TimeField.types.d.ts +10 -10
  44. package/TimePicker/TimePicker.types.d.ts +3 -3
  45. package/TimePicker/TimePickerToolbar.d.ts +2 -3
  46. package/TimePicker/TimePickerToolbar.js +6 -15
  47. package/TimePicker/shared.d.ts +6 -6
  48. package/YearCalendar/YearCalendar.js +1 -0
  49. package/hooks/useParsedFormat.d.ts +2 -2
  50. package/hooks/useParsedFormat.js +1 -1
  51. package/hooks/useSplitFieldProps.d.ts +3 -3
  52. package/index.js +1 -1
  53. package/internals/components/PickerProvider.d.ts +26 -0
  54. package/internals/components/PickerProvider.js +3 -1
  55. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  56. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
  57. package/internals/components/PickersToolbar.d.ts +3 -3
  58. package/internals/components/PickersToolbar.js +2 -4
  59. package/internals/hooks/useClockReferenceDate.d.ts +2 -1
  60. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  61. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
  62. package/internals/hooks/useField/useField.d.ts +3 -3
  63. package/internals/hooks/useField/useField.types.d.ts +46 -46
  64. package/internals/hooks/useField/useField.utils.d.ts +4 -3
  65. package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
  66. package/internals/hooks/useField/useFieldState.d.ts +9 -8
  67. package/internals/hooks/useField/useFieldState.js +1 -1
  68. package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
  69. package/internals/hooks/useField/useFieldV7TextField.js +2 -1
  70. package/internals/hooks/useFieldOwnerState.d.ts +6 -0
  71. package/internals/hooks/useFieldOwnerState.js +12 -0
  72. package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  73. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
  74. package/internals/hooks/usePicker/usePicker.d.ts +3 -3
  75. package/internals/hooks/usePicker/usePicker.js +10 -19
  76. package/internals/hooks/usePicker/usePicker.types.d.ts +8 -8
  77. package/internals/hooks/usePicker/usePickerProvider.d.ts +21 -6
  78. package/internals/hooks/usePicker/usePickerProvider.js +61 -5
  79. package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
  80. package/internals/hooks/usePicker/usePickerValue.js +18 -7
  81. package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -30
  82. package/internals/hooks/usePicker/usePickerViews.d.ts +11 -10
  83. package/internals/hooks/usePicker/usePickerViews.js +1 -0
  84. package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  85. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
  86. package/internals/hooks/useValueWithTimezone.d.ts +20 -15
  87. package/internals/hooks/useValueWithTimezone.js +13 -1
  88. package/internals/hooks/useViews.d.ts +5 -5
  89. package/internals/index.d.ts +5 -3
  90. package/internals/index.js +1 -0
  91. package/internals/models/common.d.ts +2 -1
  92. package/internals/models/fields.d.ts +6 -1
  93. package/internals/models/pickers.d.ts +1 -0
  94. package/internals/models/pickers.js +1 -0
  95. package/internals/models/props/basePickerProps.d.ts +4 -3
  96. package/internals/models/props/time.d.ts +2 -1
  97. package/internals/models/props/toolbar.d.ts +2 -2
  98. package/internals/models/value.d.ts +9 -0
  99. package/internals/utils/date-utils.d.ts +3 -3
  100. package/internals/utils/valueManagers.d.ts +4 -3
  101. package/locales/nlNL.js +7 -7
  102. package/models/adapters.d.ts +4 -4
  103. package/models/common.d.ts +1 -0
  104. package/models/fields.d.ts +19 -6
  105. package/models/pickers.d.ts +18 -0
  106. package/models/validation.d.ts +2 -1
  107. package/modern/AdapterMoment/AdapterMoment.js +10 -0
  108. package/modern/DateCalendar/DateCalendar.js +1 -0
  109. package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  110. package/modern/DateCalendar/PickersSlideTransition.js +12 -5
  111. package/modern/DateField/DateField.js +5 -4
  112. package/modern/DatePicker/DatePickerToolbar.js +0 -12
  113. package/modern/DateTimeField/DateTimeField.js +5 -4
  114. package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
  115. package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
  116. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  117. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
  118. package/modern/DigitalClock/DigitalClock.js +1 -0
  119. package/modern/MonthCalendar/MonthCalendar.js +1 -0
  120. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  121. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  122. package/modern/PickersLayout/PickersLayout.js +22 -39
  123. package/modern/PickersLayout/usePickerLayout.js +20 -17
  124. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  125. package/modern/PickersTextField/PickersTextField.js +2 -2
  126. package/modern/TimeClock/Clock.js +1 -0
  127. package/modern/TimeClock/TimeClock.js +1 -0
  128. package/modern/TimeField/TimeField.js +5 -4
  129. package/modern/TimePicker/TimePickerToolbar.js +6 -15
  130. package/modern/YearCalendar/YearCalendar.js +1 -0
  131. package/modern/hooks/useParsedFormat.js +1 -1
  132. package/modern/index.js +1 -1
  133. package/modern/internals/components/PickerProvider.js +3 -1
  134. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  135. package/modern/internals/components/PickersToolbar.js +2 -4
  136. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  137. package/modern/internals/hooks/useField/useFieldState.js +1 -1
  138. package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
  139. package/modern/internals/hooks/useFieldOwnerState.js +12 -0
  140. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  141. package/modern/internals/hooks/usePicker/usePicker.js +10 -19
  142. package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
  143. package/modern/internals/hooks/usePicker/usePickerValue.js +18 -7
  144. package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
  145. package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  146. package/modern/internals/hooks/useValueWithTimezone.js +13 -1
  147. package/modern/internals/index.js +1 -0
  148. package/modern/internals/models/pickers.js +1 -0
  149. package/modern/locales/nlNL.js +7 -7
  150. package/modern/validation/useValidation.js +1 -1
  151. package/modern/validation/validateDate.js +8 -0
  152. package/modern/validation/validateDateTime.js +8 -0
  153. package/modern/validation/validateTime.js +8 -0
  154. package/node/AdapterMoment/AdapterMoment.js +10 -0
  155. package/node/DateCalendar/DateCalendar.js +1 -0
  156. package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  157. package/node/DateCalendar/PickersSlideTransition.js +12 -5
  158. package/node/DateField/DateField.js +5 -4
  159. package/node/DatePicker/DatePickerToolbar.js +0 -12
  160. package/node/DateTimeField/DateTimeField.js +5 -4
  161. package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
  162. package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
  163. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  164. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -34
  165. package/node/DigitalClock/DigitalClock.js +1 -0
  166. package/node/MonthCalendar/MonthCalendar.js +1 -0
  167. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  168. package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  169. package/node/PickersLayout/PickersLayout.js +22 -39
  170. package/node/PickersLayout/usePickerLayout.js +20 -17
  171. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  172. package/node/PickersTextField/PickersTextField.js +2 -2
  173. package/node/TimeClock/Clock.js +1 -0
  174. package/node/TimeClock/TimeClock.js +1 -0
  175. package/node/TimeField/TimeField.js +5 -4
  176. package/node/TimePicker/TimePickerToolbar.js +6 -15
  177. package/node/YearCalendar/YearCalendar.js +1 -0
  178. package/node/hooks/useParsedFormat.js +1 -1
  179. package/node/index.js +1 -1
  180. package/node/internals/components/PickerProvider.js +3 -1
  181. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  182. package/node/internals/components/PickersToolbar.js +2 -4
  183. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  184. package/node/internals/hooks/useField/useFieldState.js +1 -1
  185. package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
  186. package/node/internals/hooks/useFieldOwnerState.js +20 -0
  187. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  188. package/node/internals/hooks/usePicker/usePicker.js +11 -19
  189. package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
  190. package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
  191. package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
  192. package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  193. package/node/internals/hooks/useValueWithTimezone.js +13 -1
  194. package/node/internals/index.js +7 -0
  195. package/node/internals/models/pickers.js +5 -0
  196. package/node/locales/nlNL.js +7 -7
  197. package/node/validation/useValidation.js +1 -1
  198. package/node/validation/validateDate.js +8 -0
  199. package/node/validation/validateDateTime.js +8 -0
  200. package/node/validation/validateTime.js +8 -0
  201. package/package.json +4 -4
  202. package/themeAugmentation/overrides.d.ts +1 -1
  203. package/themeAugmentation/props.d.ts +3 -2
  204. package/validation/useValidation.d.ts +7 -6
  205. package/validation/useValidation.js +1 -1
  206. package/validation/validateDate.d.ts +12 -3
  207. package/validation/validateDate.js +8 -0
  208. package/validation/validateDateTime.d.ts +12 -4
  209. package/validation/validateDateTime.js +8 -0
  210. package/validation/validateTime.d.ts +12 -3
  211. package/validation/validateTime.js +8 -0
  212. package/internals/hooks/useIsLandscape.d.ts +0 -4
  213. package/internals/hooks/useIsLandscape.js +0 -35
  214. package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -33
  215. package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
  216. package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
  217. package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
  218. package/modern/internals/hooks/useIsLandscape.js +0 -35
  219. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
  220. package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
  221. package/node/internals/hooks/useIsLandscape.js +0 -43
  222. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -41
  223. package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
@@ -13,6 +13,7 @@ import { useTimeField } from "./useTimeField.js";
13
13
  import { useClearableField } from "../hooks/index.js";
14
14
  import { PickersTextField } from "../PickersTextField/index.js";
15
15
  import { convertFieldResponseIntoMuiTextFieldProps } from "../internals/utils/convertFieldResponseIntoMuiTextFieldProps.js";
16
+ import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  /**
18
19
  * Demos:
@@ -36,7 +37,7 @@ const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, inRe
36
37
  inputProps
37
38
  } = themeProps,
38
39
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
40
+ const ownerState = useFieldOwnerState(themeProps);
40
41
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
42
  const textFieldProps = useSlotProps({
42
43
  elementType: TextField,
@@ -268,10 +269,10 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
268
269
  */
269
270
  shouldDisableTime: PropTypes.func,
270
271
  /**
271
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
272
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
272
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
273
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
273
274
  *
274
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
275
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
275
276
  *
276
277
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
277
278
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -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", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "disabled", "readOnly", "className"];
5
+ const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "className"];
6
6
  import * as React from 'react';
7
7
  import clsx from 'clsx';
8
8
  import PropTypes from 'prop-types';
@@ -18,6 +18,7 @@ import { useUtils } from "../internals/hooks/useUtils.js";
18
18
  import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
19
19
  import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
20
20
  import { formatMeridiem } from "../internals/utils/date-utils.js";
21
+ import { usePickerContext } from "../hooks/index.js";
21
22
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
23
  const useUtilityClasses = ownerState => {
23
24
  const {
@@ -128,14 +129,16 @@ function TimePickerToolbar(inProps) {
128
129
  view,
129
130
  onViewChange,
130
131
  views,
131
- disabled,
132
- readOnly,
133
132
  className
134
133
  } = props,
135
134
  other = _objectWithoutPropertiesLoose(props, _excluded);
136
135
  const utils = useUtils();
137
136
  const translations = usePickerTranslations();
138
137
  const isRtl = useRtl();
138
+ const {
139
+ disabled,
140
+ readOnly
141
+ } = usePickerContext();
139
142
  const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
140
143
  const {
141
144
  meridiemMode,
@@ -216,12 +219,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
216
219
  */
217
220
  classes: PropTypes.object,
218
221
  className: PropTypes.string,
219
- /**
220
- * If `true`, the component is disabled.
221
- * When disabled, the value cannot be changed and no interaction is possible.
222
- * @default false
223
- */
224
- disabled: PropTypes.bool,
225
222
  /**
226
223
  * If `true`, show the toolbar even in desktop mode.
227
224
  * @default `true` for Desktop, `false` for Mobile.
@@ -235,12 +232,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
235
232
  * @param {TView} view The view to open
236
233
  */
237
234
  onViewChange: PropTypes.func.isRequired,
238
- /**
239
- * If `true`, the component is read-only.
240
- * When read-only, the value cannot be changed but the user can interact with the interface.
241
- * @default false
242
- */
243
- readOnly: PropTypes.bool,
244
235
  /**
245
236
  * The system prop that allows defining system overrides as well as additional CSS styles.
246
237
  */
@@ -104,6 +104,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
104
104
  timezone: timezoneProp,
105
105
  value: valueProp,
106
106
  defaultValue,
107
+ referenceDate: referenceDateProp,
107
108
  onChange,
108
109
  valueManager: singleItemValueManager
109
110
  });
@@ -8,7 +8,7 @@ import { getLocalizedDigits } from "../internals/hooks/useField/useField.utils.j
8
8
  import { usePickerTranslations } from "./usePickerTranslations.js";
9
9
  /**
10
10
  * Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
11
- * This format is localized (e.g: `AAAA` for the year with the French locale) and cannot be parsed by your date library.
11
+ * This format is localized (for example `AAAA` for the year with the French locale) and cannot be parsed by your date library.
12
12
  * @param {object} The parameters needed to build the placeholder.
13
13
  * @param {string} params.format Format of the date to use.
14
14
  * @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.0.0-alpha.0
2
+ * @mui/x-date-pickers v8.0.0-alpha.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -7,7 +7,9 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
7
7
  isPickerDisabled: false,
8
8
  isPickerReadOnly: false,
9
9
  isPickerValueEmpty: false,
10
- isPickerOpen: false
10
+ isPickerOpen: false,
11
+ pickerVariant: 'desktop',
12
+ pickerOrientation: 'portrait'
11
13
  }
12
14
  });
13
15
 
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel", "labelId"],
3
+ const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel", "labelId", "classes"],
4
4
  _excluded2 = ["ownerState"],
5
5
  _excluded3 = ["ownerState"];
6
6
  import * as React from 'react';
@@ -13,6 +13,7 @@ import useSlotProps from '@mui/utils/useSlotProps';
13
13
  import IconButton from '@mui/material/IconButton';
14
14
  import { ArrowLeftIcon, ArrowRightIcon } from "../../../icons/index.js";
15
15
  import { getPickersArrowSwitcherUtilityClass } from "./pickersArrowSwitcherClasses.js";
16
+ import { usePickerPrivateContext } from "../../hooks/usePickerPrivateContext.js";
16
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
18
  const PickersArrowSwitcherRoot = styled('div', {
18
19
  name: 'MuiPickersArrowSwitcher',
@@ -44,10 +45,7 @@ const PickersArrowSwitcherButton = styled(IconButton, {
44
45
  }
45
46
  }]
46
47
  });
47
- const useUtilityClasses = ownerState => {
48
- const {
49
- classes
50
- } = ownerState;
48
+ const useUtilityClasses = classes => {
51
49
  const slots = {
52
50
  root: ['root'],
53
51
  spacer: ['spacer'],
@@ -78,11 +76,14 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
78
76
  isPreviousHidden,
79
77
  onGoToPrevious,
80
78
  previousLabel,
81
- labelId
79
+ labelId,
80
+ classes: classesProp
82
81
  } = props,
83
82
  other = _objectWithoutPropertiesLoose(props, _excluded);
84
- const ownerState = props;
85
- const classes = useUtilityClasses(ownerState);
83
+ const {
84
+ ownerState
85
+ } = usePickerPrivateContext();
86
+ const classes = useUtilityClasses(classesProp);
86
87
  const nextProps = {
87
88
  isDisabled: isNextDisabled,
88
89
  isHidden: isNextHidden,
@@ -108,7 +109,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
108
109
  onClick: previousProps.goTo
109
110
  },
110
111
  ownerState: _extends({}, ownerState, {
111
- hidden: previousProps.isHidden
112
+ hidden: previousProps.isHidden ?? false
112
113
  }),
113
114
  className: clsx(classes.button, classes.previousIconButton)
114
115
  });
@@ -125,7 +126,7 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
125
126
  onClick: nextProps.goTo
126
127
  },
127
128
  ownerState: _extends({}, ownerState, {
128
- hidden: nextProps.isHidden
129
+ hidden: nextProps.isHidden ?? false
129
130
  }),
130
131
  className: clsx(classes.button, classes.nextIconButton)
131
132
  });
@@ -10,13 +10,11 @@ import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  const useUtilityClasses = ownerState => {
12
12
  const {
13
- classes,
14
- isLandscape
13
+ classes
15
14
  } = ownerState;
16
15
  const slots = {
17
16
  root: ['root'],
18
- content: ['content'],
19
- penIconButton: ['penIconButton', isLandscape && 'penIconButtonLandscape']
17
+ content: ['content']
20
18
  };
21
19
  return composeClasses(slots, getPickersToolbarUtilityClass, classes);
22
20
  };
@@ -67,7 +67,7 @@ export const useDesktopPicker = _ref => {
67
67
  localeText,
68
68
  autoFocusView: true,
69
69
  additionalViewProps: {},
70
- wrapperVariant: 'desktop'
70
+ variant: 'desktop'
71
71
  }));
72
72
  const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
73
73
  const _useSlotProps = useSlotProps({
@@ -41,6 +41,7 @@ export const useFieldState = params => {
41
41
  timezone: timezoneProp,
42
42
  value: valueProp,
43
43
  defaultValue,
44
+ referenceDate: referenceDateProp,
44
45
  onChange,
45
46
  valueManager
46
47
  });
@@ -63,7 +64,6 @@ export const useFieldState = params => {
63
64
  const stateWithoutReferenceDate = {
64
65
  sections,
65
66
  value: valueFromTheOutside,
66
- referenceValue: valueManager.emptyValue,
67
67
  tempValueStrAndroid: null
68
68
  };
69
69
  const granularity = getSectionTypeGranularity(sections);
@@ -198,8 +198,9 @@ export const useFieldV7TextField = params => {
198
198
  if (focused || !sectionListRef.current) {
199
199
  return;
200
200
  }
201
+ const activeElement = getActiveElement(document);
201
202
  setFocused(true);
202
- const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(getActiveElement(document)) != null;
203
+ const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(activeElement) != null;
203
204
  if (!isFocusInsideASection) {
204
205
  setSelectedSections(sectionOrder.startIndex);
205
206
  }
@@ -0,0 +1,12 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { usePickerPrivateContext } from "./usePickerPrivateContext.js";
4
+ export function useFieldOwnerState(parameters) {
5
+ const {
6
+ ownerState: pickerOwnerState
7
+ } = usePickerPrivateContext();
8
+ return React.useMemo(() => _extends({}, pickerOwnerState, {
9
+ isFieldDisabled: parameters.disabled ?? false,
10
+ isFieldReadOnly: parameters.readOnly ?? false
11
+ }), [pickerOwnerState, parameters.disabled, parameters.readOnly]);
12
+ }
@@ -59,7 +59,7 @@ export const useMobilePicker = _ref => {
59
59
  localeText,
60
60
  autoFocusView: true,
61
61
  additionalViewProps: {},
62
- wrapperVariant: 'mobile'
62
+ variant: 'mobile'
63
63
  }));
64
64
  const Field = slots.field;
65
65
  const fieldProps = useSlotProps({
@@ -1,14 +1,13 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { warnOnce } from '@mui/x-internals/warning';
2
3
  import { usePickerValue } from "./usePickerValue.js";
3
4
  import { usePickerViews } from "./usePickerViews.js";
4
- import { usePickerLayoutProps } from "./usePickerLayoutProps.js";
5
- import { usePickerOwnerState } from "./usePickerOwnerState.js";
6
5
  import { usePickerProvider } from "./usePickerProvider.js";
7
6
  export const usePicker = ({
8
7
  props,
9
8
  valueManager,
10
9
  valueType,
11
- wrapperVariant,
10
+ variant,
12
11
  additionalViewProps,
13
12
  validator,
14
13
  autoFocusView,
@@ -25,7 +24,7 @@ export const usePicker = ({
25
24
  props,
26
25
  valueManager,
27
26
  valueType,
28
- wrapperVariant,
27
+ variant,
29
28
  validator
30
29
  });
31
30
  const pickerViewsResponse = usePickerViews({
@@ -36,21 +35,13 @@ export const usePicker = ({
36
35
  propsFromPickerValue: pickerValueResponse.viewProps,
37
36
  rendererInterceptor
38
37
  });
39
- const pickerLayoutResponse = usePickerLayoutProps({
40
- props,
41
- wrapperVariant,
42
- propsFromPickerValue: pickerValueResponse.layoutProps,
43
- propsFromPickerViews: pickerViewsResponse.layoutProps
44
- });
45
- const pickerOwnerState = usePickerOwnerState({
46
- props,
47
- pickerValueResponse,
48
- valueManager
49
- });
50
38
  const providerProps = usePickerProvider({
39
+ props,
51
40
  pickerValueResponse,
52
- ownerState: pickerOwnerState,
53
- localeText
41
+ localeText,
42
+ valueManager,
43
+ variant,
44
+ views: pickerViewsResponse.views
54
45
  });
55
46
  return {
56
47
  // Picker value
@@ -62,10 +53,10 @@ export const usePicker = ({
62
53
  hasUIView: pickerViewsResponse.hasUIView,
63
54
  shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
64
55
  // Picker layout
65
- layoutProps: pickerLayoutResponse.layoutProps,
56
+ layoutProps: _extends({}, pickerViewsResponse.layoutProps, pickerValueResponse.layoutProps),
66
57
  // Picker provider
67
58
  providerProps,
68
59
  // Picker owner state
69
- ownerState: pickerOwnerState
60
+ ownerState: providerProps.privateContextValue.ownerState
70
61
  };
71
62
  };
@@ -1,15 +1,66 @@
1
1
  import * as React from 'react';
2
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
+ import { useUtils } from "../useUtils.js";
4
+ import { arrayIncludes } from "../../utils/utils.js";
5
+ function getOrientation() {
6
+ if (typeof window === 'undefined') {
7
+ return 'portrait';
8
+ }
9
+ if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
10
+ return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
11
+ }
12
+
13
+ // Support IOS safari
14
+ if (window.orientation) {
15
+ return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
16
+ }
17
+ return 'portrait';
18
+ }
19
+ export const usePickerOrientation = (views, customOrientation) => {
20
+ const [orientation, setOrientation] = React.useState(getOrientation);
21
+ useEnhancedEffect(() => {
22
+ const eventHandler = () => {
23
+ setOrientation(getOrientation());
24
+ };
25
+ window.addEventListener('orientationchange', eventHandler);
26
+ return () => {
27
+ window.removeEventListener('orientationchange', eventHandler);
28
+ };
29
+ }, []);
30
+ if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {
31
+ // could not display 13:34:44 in landscape mode
32
+ return 'portrait';
33
+ }
34
+ return customOrientation ?? orientation;
35
+ };
2
36
  export function usePickerProvider(parameters) {
3
37
  const {
38
+ props,
4
39
  pickerValueResponse,
5
- ownerState,
6
- localeText
40
+ valueManager,
41
+ localeText,
42
+ variant,
43
+ views
7
44
  } = parameters;
45
+ const utils = useUtils();
46
+ const orientation = usePickerOrientation(views, props.orientation);
47
+ const ownerState = React.useMemo(() => ({
48
+ isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
49
+ isPickerOpen: pickerValueResponse.open,
50
+ isPickerDisabled: props.disabled ?? false,
51
+ isPickerReadOnly: props.readOnly ?? false,
52
+ pickerOrientation: orientation,
53
+ pickerVariant: variant
54
+ }), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, orientation, variant, props.disabled, props.readOnly]);
8
55
  const contextValue = React.useMemo(() => ({
9
56
  onOpen: pickerValueResponse.actions.onOpen,
10
57
  onClose: pickerValueResponse.actions.onClose,
11
- open: pickerValueResponse.open
12
- }), [pickerValueResponse.actions.onOpen, pickerValueResponse.actions.onClose, pickerValueResponse.open]);
58
+ open: pickerValueResponse.open,
59
+ disabled: props.disabled ?? false,
60
+ readOnly: props.readOnly ?? false,
61
+ variant,
62
+ orientation
63
+ }), [pickerValueResponse.actions.onOpen, pickerValueResponse.actions.onClose, pickerValueResponse.open, variant, orientation, props.disabled, props.readOnly]);
13
64
  const privateContextValue = React.useMemo(() => ({
14
65
  ownerState
15
66
  }), [ownerState]);
@@ -18,4 +69,9 @@ export function usePickerProvider(parameters) {
18
69
  contextValue,
19
70
  privateContextValue
20
71
  };
21
- }
72
+ }
73
+
74
+ /**
75
+ * Props used to create the private context.
76
+ * Those props are exposed on all the pickers.
77
+ */
@@ -5,7 +5,6 @@ import { useOpenState } from "../useOpenState.js";
5
5
  import { useLocalizationContext, useUtils } from "../useUtils.js";
6
6
  import { useValidation } from "../../../validation/index.js";
7
7
  import { useValueWithTimezone } from "../useValueWithTimezone.js";
8
-
9
8
  /**
10
9
  * Decide if the new value should be published
11
10
  * The published value will be passed to `onChange` if defined.
@@ -113,7 +112,7 @@ export const usePickerValue = ({
113
112
  props,
114
113
  valueManager,
115
114
  valueType,
116
- wrapperVariant,
115
+ variant,
117
116
  validator
118
117
  }) => {
119
118
  const {
@@ -121,8 +120,9 @@ export const usePickerValue = ({
121
120
  onChange,
122
121
  value: inValueWithoutRenderTimezone,
123
122
  defaultValue: inDefaultValue,
124
- closeOnSelect = wrapperVariant === 'desktop',
125
- timezone: timezoneProp
123
+ closeOnSelect = variant === 'desktop',
124
+ timezone: timezoneProp,
125
+ referenceDate
126
126
  } = props;
127
127
  const {
128
128
  current: defaultValue
@@ -130,6 +130,7 @@ export const usePickerValue = ({
130
130
  const {
131
131
  current: isControlled
132
132
  } = React.useRef(inValueWithoutRenderTimezone !== undefined);
133
+ const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
133
134
 
134
135
  /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
135
136
  if (process.env.NODE_ENV !== 'production') {
@@ -160,6 +161,7 @@ export const usePickerValue = ({
160
161
  timezone: timezoneProp,
161
162
  value: inValueWithoutRenderTimezone,
162
163
  defaultValue,
164
+ referenceDate,
163
165
  onChange,
164
166
  valueManager
165
167
  });
@@ -176,10 +178,19 @@ export const usePickerValue = ({
176
178
  draft: initialValue,
177
179
  lastPublishedValue: initialValue,
178
180
  lastCommittedValue: initialValue,
179
- lastControlledValue: inValueWithTimezoneToRender,
181
+ lastControlledValue: inValueWithoutRenderTimezone,
180
182
  hasBeenModifiedSinceMount: false
181
183
  };
182
184
  });
185
+ const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
186
+ if (previousTimezoneProp !== timezoneProp) {
187
+ setPreviousTimezoneProp(timezoneProp);
188
+ if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
189
+ setDateState(prev => _extends({}, prev, {
190
+ draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
191
+ }));
192
+ }
193
+ }
183
194
  const {
184
195
  getValidationErrorForNewValue
185
196
  } = useValidation({
@@ -229,10 +240,10 @@ export const usePickerValue = ({
229
240
  setIsOpen(false);
230
241
  }
231
242
  });
232
- if (inValueWithTimezoneToRender !== undefined && (dateState.lastControlledValue === undefined || !valueManager.areValuesEqual(utils, dateState.lastControlledValue, inValueWithTimezoneToRender))) {
243
+ if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
233
244
  const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
234
245
  setDateState(prev => _extends({}, prev, {
235
- lastControlledValue: inValueWithTimezoneToRender
246
+ lastControlledValue: inValueWithoutRenderTimezone
236
247
  }, isUpdateComingFromPicker ? {} : {
237
248
  lastCommittedValue: inValueWithTimezoneToRender,
238
249
  lastPublishedValue: inValueWithTimezoneToRender,
@@ -134,6 +134,7 @@ export const usePickerViews = ({
134
134
  };
135
135
  return {
136
136
  hasUIView,
137
+ views,
137
138
  shouldRestoreFocus,
138
139
  layoutProps,
139
140
  renderCurrentView: () => {
@@ -48,7 +48,7 @@ export const useStaticPicker = _ref => {
48
48
  fieldRef: undefined,
49
49
  localeText,
50
50
  additionalViewProps: {},
51
- wrapperVariant: displayStaticWrapperAs
51
+ variant: displayStaticWrapperAs
52
52
  }));
53
53
  const Layout = slots?.layout ?? PickerStaticLayout;
54
54
  const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
@@ -11,6 +11,7 @@ export const useValueWithTimezone = ({
11
11
  timezone: timezoneProp,
12
12
  value: valueProp,
13
13
  defaultValue,
14
+ referenceDate,
14
15
  onChange,
15
16
  valueManager
16
17
  }) => {
@@ -24,7 +25,16 @@ export const useValueWithTimezone = ({
24
25
  }
25
26
  return valueManager.setTimezone(utils, inputTimezone, newValue);
26
27
  });
27
- const timezoneToRender = timezoneProp ?? inputTimezone ?? 'default';
28
+ let timezoneToRender;
29
+ if (timezoneProp) {
30
+ timezoneToRender = timezoneProp;
31
+ } else if (inputTimezone) {
32
+ timezoneToRender = inputTimezone;
33
+ } else if (referenceDate) {
34
+ timezoneToRender = utils.getTimezone(referenceDate);
35
+ } else {
36
+ timezoneToRender = 'default';
37
+ }
28
38
  const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
29
39
  const handleValueChange = useEventCallback((newValue, ...otherParams) => {
30
40
  const newValueWithInputTimezone = setInputTimezone(newValue);
@@ -45,6 +55,7 @@ export const useControlledValueWithTimezone = ({
45
55
  timezone: timezoneProp,
46
56
  value: valueProp,
47
57
  defaultValue,
58
+ referenceDate,
48
59
  onChange: onChangeProp,
49
60
  valueManager
50
61
  }) => {
@@ -62,6 +73,7 @@ export const useControlledValueWithTimezone = ({
62
73
  timezone: timezoneProp,
63
74
  value: valueWithInputTimezone,
64
75
  defaultValue: undefined,
76
+ referenceDate,
65
77
  onChange,
66
78
  valueManager
67
79
  });
@@ -12,6 +12,7 @@ export { PickersToolbarButton } from "./components/PickersToolbarButton.js";
12
12
  export { DAY_MARGIN, DIALOG_WIDTH, VIEW_HEIGHT } from "./constants/dimensions.js";
13
13
  export { useControlledValueWithTimezone } from "./hooks/useValueWithTimezone.js";
14
14
  export { useField, createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./hooks/useField/index.js";
15
+ export { useFieldOwnerState } from "./hooks/useFieldOwnerState.js";
15
16
  export { usePicker } from "./hooks/usePicker/index.js";
16
17
  export { usePickerPrivateContext } from "./hooks/usePickerPrivateContext.js";
17
18
  export { useStaticPicker } from "./hooks/useStaticPicker/index.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -16,10 +16,10 @@ const nlNLPickers = {
16
16
  // DateRange labels
17
17
  start: 'Start',
18
18
  end: 'Einde',
19
- startDate: 'Start datum',
20
- startTime: 'Start tijd',
21
- endDate: 'Eind datum',
22
- endTime: 'Eind tijd',
19
+ startDate: 'Startdatum',
20
+ startTime: 'Starttijd',
21
+ endDate: 'Einddatum',
22
+ endTime: 'Eindtijd',
23
23
  // Action bar
24
24
  cancelButtonLabel: 'Annuleren',
25
25
  clearButtonLabel: 'Resetten',
@@ -50,11 +50,11 @@ const nlNLPickers = {
50
50
  timeTableLabel: 'kies tijd',
51
51
  dateTableLabel: 'kies datum',
52
52
  // Field section placeholders
53
- fieldYearPlaceholder: params => 'Y'.repeat(params.digitAmount),
53
+ fieldYearPlaceholder: params => 'J'.repeat(params.digitAmount),
54
54
  fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
55
55
  fieldDayPlaceholder: () => 'DD',
56
56
  fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
57
- fieldHoursPlaceholder: () => 'hh',
57
+ fieldHoursPlaceholder: () => 'uu',
58
58
  fieldMinutesPlaceholder: () => 'mm',
59
59
  fieldSecondsPlaceholder: () => 'ss',
60
60
  fieldMeridiemPlaceholder: () => 'aa',
@@ -68,6 +68,6 @@ const nlNLPickers = {
68
68
  seconds: 'Seconden',
69
69
  meridiem: 'Middag',
70
70
  // Common
71
- empty: 'Legen'
71
+ empty: 'Leeg'
72
72
  };
73
73
  export const nlNL = getPickersLocalization(nlNLPickers);
@@ -5,7 +5,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import { useLocalizationContext } from "../internals/hooks/useUtils.js";
6
6
  /**
7
7
  * Utility hook to check if a given value is valid based on the provided validation props.
8
- * @template TValue The value type. It will be either the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
8
+ * @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
9
9
  * @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
10
10
  * @param {UseValidationOptions<TValue, TError, TValidationProps>} options The options to configure the hook.
11
11
  * @param {TValue} options.value The value to validate.
@@ -5,6 +5,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
5
5
  * Validation props used by the Date Picker, Date Field and Date Calendar components.
6
6
  */
7
7
 
8
+ /**
9
+ * Validation props as received by the validateDate method.
10
+ */
11
+
12
+ /**
13
+ * Name of the props that should be defaulted before being passed to the validateDate method.
14
+ */
15
+
8
16
  export const validateDate = ({
9
17
  props,
10
18
  value,
@@ -6,6 +6,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
6
6
  * Validation props used by the Date Time Picker and Date Time Field components.
7
7
  */
8
8
 
9
+ /**
10
+ * Validation props as received by the validateDateTime method.
11
+ */
12
+
13
+ /**
14
+ * Name of the props that should be defaulted before being passed to the validateDateTime method.
15
+ */
16
+
9
17
  export const validateDateTime = ({
10
18
  adapter,
11
19
  value,