@mui/x-date-pickers 6.0.4 → 6.1.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 (189) hide show
  1. package/AdapterDateFns/index.d.ts +1 -1
  2. package/AdapterDateFnsJalali/index.d.ts +1 -1
  3. package/AdapterDayjs/index.d.ts +2 -3
  4. package/AdapterLuxon/index.d.ts +2 -2
  5. package/AdapterLuxon/index.js +1 -1
  6. package/AdapterMoment/index.d.ts +1 -1
  7. package/AdapterMomentHijri/index.d.ts +1 -1
  8. package/AdapterMomentJalaali/index.d.ts +1 -1
  9. package/CHANGELOG.md +58 -0
  10. package/DateCalendar/DateCalendar.js +0 -2
  11. package/DateCalendar/PickersCalendarHeader.d.ts +0 -12
  12. package/DateCalendar/PickersCalendarHeader.js +7 -9
  13. package/DateCalendar/PickersSlideTransition.js +1 -0
  14. package/DateCalendar/useCalendarState.d.ts +1 -1
  15. package/DateField/DateField.js +8 -2
  16. package/DatePicker/shared.d.ts +2 -2
  17. package/DateTimeField/DateTimeField.js +8 -2
  18. package/LocalizationProvider/LocalizationProvider.d.ts +2 -3
  19. package/MonthCalendar/PickersMonth.js +1 -0
  20. package/README.md +2 -2
  21. package/TimeClock/ClockNumbers.d.ts +1 -1
  22. package/TimeClock/TimeClock.js +5 -4
  23. package/TimeField/TimeField.js +8 -2
  24. package/YearCalendar/PickersYear.js +1 -0
  25. package/index.js +1 -1
  26. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -12
  27. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +0 -12
  28. package/internals/components/PickersModalDialog.d.ts +0 -12
  29. package/internals/components/PickersModalDialog.js +7 -9
  30. package/internals/components/PickersPopper.d.ts +0 -2
  31. package/internals/components/PickersPopper.js +2 -7
  32. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +1 -2
  33. package/internals/hooks/useField/useField.js +2 -2
  34. package/internals/hooks/useField/useField.types.d.ts +3 -11
  35. package/internals/hooks/useField/useField.utils.d.ts +2 -3
  36. package/internals/hooks/useField/useField.utils.js +3 -1
  37. package/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
  38. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +1 -2
  39. package/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
  40. package/internals/hooks/usePicker/usePickerValue.d.ts +8 -2
  41. package/internals/hooks/usePicker/usePickerValue.js +23 -2
  42. package/internals/hooks/usePicker/usePickerViews.js +13 -0
  43. package/internals/hooks/useUtils.d.ts +1 -1
  44. package/internals/index.d.ts +0 -1
  45. package/internals/models/index.d.ts +0 -1
  46. package/internals/models/index.js +1 -2
  47. package/internals/utils/date-utils.d.ts +1 -1
  48. package/internals/utils/time-utils.d.ts +1 -2
  49. package/internals/utils/valueManagers.d.ts +1 -1
  50. package/internals/utils/valueManagers.js +2 -2
  51. package/legacy/AdapterLuxon/index.js +1 -1
  52. package/legacy/DateCalendar/DateCalendar.js +0 -2
  53. package/legacy/DateCalendar/PickersCalendarHeader.js +8 -10
  54. package/legacy/DateField/DateField.js +7 -1
  55. package/legacy/DateTimeField/DateTimeField.js +7 -1
  56. package/legacy/TimeClock/TimeClock.js +5 -4
  57. package/legacy/TimeField/TimeField.js +7 -1
  58. package/legacy/index.js +1 -1
  59. package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -12
  60. package/legacy/internals/components/PickersModalDialog.js +7 -9
  61. package/legacy/internals/components/PickersPopper.js +2 -7
  62. package/legacy/internals/hooks/useField/useField.js +2 -2
  63. package/legacy/internals/hooks/useField/useField.utils.js +3 -1
  64. package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
  65. package/legacy/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
  66. package/legacy/internals/hooks/usePicker/usePickerValue.js +23 -4
  67. package/legacy/internals/hooks/usePicker/usePickerViews.js +13 -0
  68. package/legacy/internals/models/index.js +1 -2
  69. package/legacy/internals/utils/valueManagers.js +3 -3
  70. package/legacy/locales/caES.js +88 -0
  71. package/legacy/locales/esES.js +34 -17
  72. package/legacy/locales/heIL.js +33 -16
  73. package/legacy/locales/index.js +1 -0
  74. package/legacy/locales/jaJP.js +3 -1
  75. package/legacy/locales/kzKZ.js +88 -0
  76. package/legacy/locales/nlNL.js +25 -11
  77. package/legacy/locales/ptBR.js +33 -16
  78. package/legacy/models/adapters.js +1 -0
  79. package/legacy/models/index.js +2 -1
  80. package/locales/beBY.d.ts +3 -3
  81. package/locales/caES.d.ts +51 -0
  82. package/locales/caES.js +54 -0
  83. package/locales/csCZ.d.ts +3 -3
  84. package/locales/daDK.d.ts +3 -3
  85. package/locales/deDE.d.ts +3 -3
  86. package/locales/enUS.d.ts +3 -3
  87. package/locales/esES.d.ts +3 -3
  88. package/locales/esES.js +14 -17
  89. package/locales/faIR.d.ts +3 -3
  90. package/locales/fiFI.d.ts +3 -3
  91. package/locales/frFR.d.ts +3 -3
  92. package/locales/heIL.d.ts +3 -3
  93. package/locales/heIL.js +13 -16
  94. package/locales/huHU.d.ts +3 -3
  95. package/locales/index.d.ts +1 -0
  96. package/locales/index.js +1 -0
  97. package/locales/isIS.d.ts +3 -3
  98. package/locales/itIT.d.ts +3 -3
  99. package/locales/jaJP.d.ts +3 -3
  100. package/locales/jaJP.js +1 -1
  101. package/locales/koKR.d.ts +3 -3
  102. package/locales/kzKZ.d.ts +51 -0
  103. package/locales/kzKZ.js +56 -0
  104. package/locales/nbNO.d.ts +3 -3
  105. package/locales/nlNL.d.ts +3 -3
  106. package/locales/nlNL.js +9 -11
  107. package/locales/plPL.d.ts +3 -3
  108. package/locales/ptBR.d.ts +3 -3
  109. package/locales/ptBR.js +13 -16
  110. package/locales/ruRU.d.ts +3 -3
  111. package/locales/svSE.d.ts +3 -3
  112. package/locales/trTR.d.ts +3 -3
  113. package/locales/ukUA.d.ts +3 -3
  114. package/locales/urPK.d.ts +3 -3
  115. package/locales/utils/getPickersLocalization.d.ts +3 -3
  116. package/locales/utils/pickersLocaleTextApi.d.ts +1 -2
  117. package/locales/zhCN.d.ts +3 -3
  118. package/models/adapters.d.ts +567 -0
  119. package/models/adapters.js +1 -0
  120. package/models/index.d.ts +1 -0
  121. package/models/index.js +2 -1
  122. package/modern/AdapterLuxon/index.js +1 -1
  123. package/modern/DateCalendar/DateCalendar.js +0 -2
  124. package/modern/DateCalendar/PickersCalendarHeader.js +6 -8
  125. package/modern/DateCalendar/PickersSlideTransition.js +1 -0
  126. package/modern/DateField/DateField.js +8 -2
  127. package/modern/DateTimeField/DateTimeField.js +8 -2
  128. package/modern/MonthCalendar/PickersMonth.js +1 -0
  129. package/modern/TimeClock/TimeClock.js +5 -4
  130. package/modern/TimeField/TimeField.js +8 -2
  131. package/modern/YearCalendar/PickersYear.js +1 -0
  132. package/modern/index.js +1 -1
  133. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +9 -11
  134. package/modern/internals/components/PickersModalDialog.js +6 -8
  135. package/modern/internals/components/PickersPopper.js +2 -7
  136. package/modern/internals/hooks/useField/useField.js +2 -2
  137. package/modern/internals/hooks/useField/useField.utils.js +3 -1
  138. package/modern/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
  139. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
  140. package/modern/internals/hooks/usePicker/usePickerValue.js +23 -2
  141. package/modern/internals/hooks/usePicker/usePickerViews.js +13 -0
  142. package/modern/internals/models/index.js +1 -2
  143. package/modern/internals/utils/valueManagers.js +2 -2
  144. package/modern/locales/caES.js +54 -0
  145. package/modern/locales/esES.js +14 -17
  146. package/modern/locales/heIL.js +13 -16
  147. package/modern/locales/index.js +1 -0
  148. package/modern/locales/jaJP.js +1 -1
  149. package/modern/locales/kzKZ.js +56 -0
  150. package/modern/locales/nlNL.js +9 -11
  151. package/modern/locales/ptBR.js +13 -16
  152. package/modern/models/adapters.js +1 -0
  153. package/modern/models/index.js +2 -1
  154. package/node/AdapterLuxon/index.js +1 -1
  155. package/node/AdapterMomentHijri/index.js +2 -0
  156. package/node/DateCalendar/DateCalendar.js +0 -2
  157. package/node/DateCalendar/PickersCalendarHeader.js +5 -9
  158. package/node/DateCalendar/PickersSlideTransition.js +1 -0
  159. package/node/DateField/DateField.js +8 -2
  160. package/node/DateTimeField/DateTimeField.js +8 -2
  161. package/node/MonthCalendar/PickersMonth.js +1 -0
  162. package/node/TimeClock/TimeClock.js +5 -4
  163. package/node/TimeField/TimeField.js +8 -2
  164. package/node/YearCalendar/PickersYear.js +1 -0
  165. package/node/index.js +1 -1
  166. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +9 -11
  167. package/node/internals/components/PickersModalDialog.js +6 -8
  168. package/node/internals/components/PickersPopper.js +2 -7
  169. package/node/internals/hooks/useField/useField.js +2 -2
  170. package/node/internals/hooks/useField/useField.utils.js +3 -1
  171. package/node/internals/hooks/useField/useFieldCharacterEditing.js +22 -0
  172. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +5 -0
  173. package/node/internals/hooks/usePicker/usePickerValue.js +22 -2
  174. package/node/internals/hooks/usePicker/usePickerViews.js +12 -0
  175. package/node/internals/models/index.js +0 -11
  176. package/node/internals/utils/valueManagers.js +2 -2
  177. package/node/locales/caES.js +61 -0
  178. package/node/locales/csCZ.js +0 -1
  179. package/node/locales/esES.js +14 -17
  180. package/node/locales/heIL.js +13 -16
  181. package/node/locales/index.js +11 -0
  182. package/node/locales/jaJP.js +1 -1
  183. package/node/locales/kzKZ.js +62 -0
  184. package/node/locales/nlNL.js +9 -11
  185. package/node/locales/ptBR.js +13 -16
  186. package/node/models/adapters.js +5 -0
  187. package/node/models/index.js +11 -0
  188. package/package.json +3 -3
  189. package/internals/models/muiPickersAdapter.d.ts +0 -26
@@ -9,7 +9,6 @@ import { unstable_useForkRef as useForkRef, unstable_useEventCallback as useEven
9
9
  import { styled, useThemeProps } from '@mui/material/styles';
10
10
  import { getPickersPopperUtilityClass } from './pickersPopperClasses';
11
11
  import { getActiveElement } from '../utils/utils';
12
- import { uncapitalizeObjectKeys } from '../utils/slots-migration';
13
12
  import { jsx as _jsx } from "react/jsx-runtime";
14
13
  const useUtilityClasses = ownerState => {
15
14
  const {
@@ -173,13 +172,9 @@ export function PickersPopper(inProps) {
173
172
  open,
174
173
  role,
175
174
  placement,
176
- components,
177
- componentsProps,
178
- slots: innerSlots,
179
- slotProps: innerSlotProps
175
+ slots,
176
+ slotProps
180
177
  } = props;
181
- const slots = innerSlots != null ? innerSlots : uncapitalizeObjectKeys(components);
182
- const slotProps = innerSlotProps != null ? innerSlotProps : componentsProps;
183
178
  React.useEffect(() => {
184
179
  function handleKeyDown(nativeEvent) {
185
180
  // IE11, Edge (prior to using Blink?) use 'Esc'
@@ -3,11 +3,10 @@ import IconButton, { IconButtonProps } from '@mui/material/IconButton';
3
3
  import { InputAdornmentProps } from '@mui/material/InputAdornment';
4
4
  import TextField, { TextFieldProps } from '@mui/material/TextField';
5
5
  import { SlotComponentProps } from '@mui/base/utils';
6
- import { MuiPickersAdapter } from '../../models';
7
6
  import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
8
7
  import { PickersPopperSlotsComponent, PickersPopperSlotsComponentsProps } from '../../components/PickersPopper';
9
8
  import { UsePickerParams, UsePickerProps } from '../usePicker';
10
- import { BaseSingleInputFieldProps, FieldSection, DateOrTimeView } from '../../../models';
9
+ import { BaseSingleInputFieldProps, FieldSection, DateOrTimeView, MuiPickersAdapter } from '../../../models';
11
10
  import { ExportedPickersLayoutSlotsComponent, ExportedPickersLayoutSlotsComponentsProps, PickersLayoutSlotsComponentsProps } from '../../../PickersLayout/PickersLayout.types';
12
11
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue';
13
12
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
@@ -303,8 +303,8 @@ export const useField = params => {
303
303
  if (error !== undefined) {
304
304
  return error;
305
305
  }
306
- return fieldValueManager.hasError(validationError);
307
- }, [fieldValueManager, validationError, error]);
306
+ return valueManager.hasError(validationError);
307
+ }, [valueManager, validationError, error]);
308
308
  React.useEffect(() => {
309
309
  // Select the right section when focused on mount (`autoFocus = true` on the input)
310
310
  if (inputRef.current && inputRef.current === document.activeElement) {
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { MuiPickersAdapter } from '../../models';
3
- import { FieldSectionType, FieldSection, FieldSelectedSections } from '../../../models';
2
+ import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter } from '../../../models';
4
3
  import type { PickerValueManager } from '../usePicker';
5
4
  import { InferError, Validator } from '../validation/useValidation';
6
5
  export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TForwardedProps extends UseFieldForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, any>> {
@@ -8,7 +7,7 @@ export interface UseFieldParams<TValue, TDate, TSection extends FieldSection, TF
8
7
  forwardedProps: TForwardedProps;
9
8
  internalProps: TInternalProps;
10
9
  valueManager: PickerValueManager<TValue, TDate, InferError<TInternalProps>>;
11
- fieldValueManager: FieldValueManager<TValue, TDate, TSection, InferError<TInternalProps>>;
10
+ fieldValueManager: FieldValueManager<TValue, TDate, TSection>;
12
11
  validator: Validator<TValue, TDate, InferError<TInternalProps>, UseFieldValidationProps<TValue, TInternalProps>>;
13
12
  valueType: FieldValueType;
14
13
  }
@@ -158,7 +157,7 @@ export type FieldSelectedSectionsIndexes = {
158
157
  */
159
158
  shouldSelectBoundarySelectors?: boolean;
160
159
  };
161
- export interface FieldValueManager<TValue, TDate, TSection extends FieldSection, TError> {
160
+ export interface FieldValueManager<TValue, TDate, TSection extends FieldSection> {
162
161
  /**
163
162
  * Creates the section list from the current value.
164
163
  * The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
@@ -208,13 +207,6 @@ export interface FieldValueManager<TValue, TDate, TSection extends FieldSection,
208
207
  * @returns {TValue} The new reference value with no invalid date.
209
208
  */
210
209
  updateReferenceValue: (utils: MuiPickersAdapter<TDate>, value: TValue, prevReferenceValue: TValue) => TValue;
211
- /**
212
- * Checks if the current error is empty or not.
213
- * @template TError
214
- * @param {TError} error The current error.
215
- * @returns {boolean} `true` if the current error is not empty.
216
- */
217
- hasError: (error: TError) => boolean;
218
210
  }
219
211
  export interface UseFieldState<TValue, TSection extends FieldSection> {
220
212
  value: TValue;
@@ -1,6 +1,5 @@
1
1
  import { AvailableAdjustKeyCode, FieldSectionsValueBoundaries, SectionOrdering, FieldValueType, FieldSectionWithoutPosition, FieldSectionValueBoundaries } from './useField.types';
2
- import { MuiPickersAdapter } from '../../models';
3
- import { FieldSectionType, FieldSection } from '../../../models';
2
+ import { FieldSectionType, FieldSection, MuiPickersAdapter } from '../../../models';
4
3
  import { PickersLocaleText } from '../../../locales/utils/pickersLocaleTextApi';
5
4
  export declare const getDateSectionConfigFromFormatToken: <TDate>(utils: MuiPickersAdapter<TDate>, formatToken: string) => Pick<FieldSection, 'type' | 'contentType'>;
6
5
  export declare const getDaysInWeekStr: <TDate>(utils: MuiPickersAdapter<TDate>, format: string) => string[];
@@ -12,7 +11,7 @@ export declare const cleanString: (dirtyString: string) => string;
12
11
  export declare const addPositionPropertiesToSections: <TSection extends FieldSection>(sections: FieldSectionWithoutPosition<TSection>[], isRTL: boolean) => TSection[];
13
12
  export declare const changeSectionValueFormat: <TDate>(utils: MuiPickersAdapter<TDate>, valueStr: string, currentFormat: string, newFormat: string) => string;
14
13
  export declare const doesSectionHaveLeadingZeros: <TDate>(utils: MuiPickersAdapter<TDate>, contentType: 'digit' | 'letter', sectionType: FieldSectionType, format: string) => boolean;
15
- export declare const splitFormatIntoSections: <TDate>(utils: MuiPickersAdapter<TDate>, localeText: PickersLocaleText<TDate>, format: string, date: TDate | null) => FieldSectionWithoutPosition<FieldSection>[];
14
+ export declare const splitFormatIntoSections: <TDate>(utils: MuiPickersAdapter<TDate>, localeText: PickersLocaleText<TDate>, format: string, date: TDate | null) => FieldSectionWithoutPosition[];
16
15
  /**
17
16
  * Some date libraries like `dayjs` don't support parsing from date with escaped characters.
18
17
  * To make sure that the parsing works, we are building a format and a date without any separator.
@@ -668,7 +668,9 @@ export const getSectionOrder = (sections, isRTL) => {
668
668
  // eslint-disable-next-line @typescript-eslint/no-loop-func
669
669
  (section, index) => {
670
670
  var _section$endSeparator;
671
- return index >= groupedSectionsStart && ((_section$endSeparator = section.endSeparator) == null ? void 0 : _section$endSeparator.includes(' '));
671
+ return index >= groupedSectionsStart && ((_section$endSeparator = section.endSeparator) == null ? void 0 : _section$endSeparator.includes(' ')) &&
672
+ // Special case where the spaces were not there in the initial input
673
+ section.endSeparator !== ' / ';
672
674
  });
673
675
  if (groupedSectionsEnd === -1) {
674
676
  groupedSectionsEnd = sections.length - 1;
@@ -3,6 +3,29 @@ import * as React from 'react';
3
3
  import useEventCallback from '@mui/utils/useEventCallback';
4
4
  import { useUtils } from '../useUtils';
5
5
  import { changeSectionValueFormat, cleanDigitSectionValue, doesSectionHaveLeadingZeros, getDateSectionConfigFromFormatToken, getDaysInWeekStr, getLetterEditingOptions } from './useField.utils';
6
+
7
+ /**
8
+ * The letter editing and the numeric editing each define a `CharacterEditingApplier`.
9
+ * This function decides what the new section value should be and if the focus should switch to the next section.
10
+ *
11
+ * If it returns `null`, then the section value is not updated and the focus does not move.
12
+ */
13
+
14
+ /**
15
+ * Function called by `applyQuery` which decides:
16
+ * - what is the new section value ?
17
+ * - should the query used to get this value be stored for the next key press ?
18
+ *
19
+ * If it returns `{ sectionValue: string; shouldGoToNextSection: boolean }`,
20
+ * Then we store the query and update the section with the new value.
21
+ *
22
+ * If it returns `{ saveQuery: true` },
23
+ * Then we store the query and don't update the section.
24
+ *
25
+ * If it returns `{ saveQuery: false },
26
+ * Then we do nothing.
27
+ */
28
+
6
29
  const QUERY_LIFE_DURATION_MS = 5000;
7
30
  const isQueryResponseWithoutValue = response => response.saveQuery != null;
8
31
 
@@ -1,11 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import TextField, { TextFieldProps } from '@mui/material/TextField';
3
3
  import { SlotComponentProps } from '@mui/base/utils';
4
- import { MuiPickersAdapter } from '../../models';
5
4
  import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
6
5
  import { PickersModalDialogSlotsComponent, PickersModalDialogSlotsComponentsProps } from '../../components/PickersModalDialog';
7
6
  import { UsePickerParams, UsePickerProps } from '../usePicker';
8
- import { BaseSingleInputFieldProps, FieldSection, DateOrTimeView } from '../../../models';
7
+ import { BaseSingleInputFieldProps, FieldSection, DateOrTimeView, MuiPickersAdapter } from '../../../models';
9
8
  import { ExportedPickersLayoutSlotsComponent, ExportedPickersLayoutSlotsComponentsProps, PickersLayoutSlotsComponentsProps } from '../../../PickersLayout/PickersLayout.types';
10
9
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue';
11
10
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
@@ -1,5 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { useIsLandscape } from '../useIsLandscape';
3
+
4
+ /**
5
+ * Props used to create the layout of the views.
6
+ * Those props are exposed on all the pickers.
7
+ */
8
+
3
9
  /**
4
10
  * Prepare the props for the view layout (managed by `PickersLayout`)
5
11
  */
@@ -2,8 +2,7 @@ import { UseFieldInternalProps } from '../useField';
2
2
  import { InferError, Validator } from '../validation/useValidation';
3
3
  import { UseFieldValidationProps } from '../useField/useField.types';
4
4
  import { WrapperVariant } from '../../models/common';
5
- import { MuiPickersAdapter } from '../../models/muiPickersAdapter';
6
- import { FieldSection, FieldSelectedSections } from '../../../models';
5
+ import { FieldSection, FieldSelectedSections, MuiPickersAdapter } from '../../../models';
7
6
  export interface PickerValueManager<TValue, TDate, TError> {
8
7
  /**
9
8
  * Determines if two values are equal.
@@ -50,6 +49,13 @@ export interface PickerValueManager<TValue, TDate, TError> {
50
49
  * @returns {boolean} `true` if the new error is different from the previous one.
51
50
  */
52
51
  isSameError: (error: TError, prevError: TError | null) => boolean;
52
+ /**
53
+ * Checks if the current error is empty or not.
54
+ * @template TError
55
+ * @param {TError} error The current error.
56
+ * @returns {boolean} `true` if the current error is not empty.
57
+ */
58
+ hasError: (error: TError) => boolean;
53
59
  /**
54
60
  * The value identifying no error, used to initialise the error state.
55
61
  */
@@ -5,6 +5,27 @@ import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import { useOpenState } from '../useOpenState';
6
6
  import { useLocalizationContext, useUtils } from '../useUtils';
7
7
  import { useValidation } from '../validation/useValidation';
8
+
9
+ /**
10
+ * Props used to handle the value that are common to all pickers.
11
+ */
12
+
13
+ /**
14
+ * Props used to handle the value of non-static pickers.
15
+ */
16
+
17
+ /**
18
+ * Props used to handle the value of the pickers.
19
+ */
20
+
21
+ /**
22
+ * Props passed to `usePickerViews`.
23
+ */
24
+
25
+ /**
26
+ * Props passed to `usePickerLayoutProps`.
27
+ */
28
+
8
29
  /**
9
30
  * Manage the value lifecycle of all the pickers.
10
31
  */
@@ -234,14 +255,14 @@ export const usePickerValue = ({
234
255
  onSelectedSectionsChange: handleFieldSelectedSectionsChange
235
256
  };
236
257
  const isValid = testedValue => {
237
- const validationResponse = validator({
258
+ const error = validator({
238
259
  adapter,
239
260
  value: testedValue,
240
261
  props: _extends({}, props, {
241
262
  value: testedValue
242
263
  })
243
264
  });
244
- return Array.isArray(testedValue) ? validationResponse.every(v => v === null) : validationResponse === null;
265
+ return !valueManager.hasError(error);
245
266
  };
246
267
  const layoutResponse = _extends({}, actions, {
247
268
  value: viewValue,
@@ -6,6 +6,19 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import useEventCallback from '@mui/utils/useEventCallback';
7
7
  import { useViews } from '../useViews';
8
8
  import { isTimeView } from '../../utils/time-utils';
9
+
10
+ /**
11
+ * Props used to handle the views that are common to all pickers.
12
+ */
13
+
14
+ /**
15
+ * Props used to handle the views of the pickers.
16
+ */
17
+
18
+ /**
19
+ * Props used to handle the value of the pickers.
20
+ */
21
+
9
22
  /**
10
23
  * Manage the views of all the pickers:
11
24
  * - Handles the view switch
@@ -3,7 +3,7 @@ import { PickersLocaleText } from '../../locales/utils/pickersLocaleTextApi';
3
3
  export declare const useLocalizationContext: <TDate>() => Omit<MuiPickersAdapterContextValue<TDate>, "localeText"> & {
4
4
  localeText: PickersLocaleText<TDate>;
5
5
  };
6
- export declare const useUtils: <TDate>() => import("..").MuiPickersAdapter<TDate>;
6
+ export declare const useUtils: <TDate>() => import("../..").MuiPickersAdapter<TDate>;
7
7
  export declare const useDefaultDates: <TDate>() => {
8
8
  minDate: TDate;
9
9
  maxDate: TDate;
@@ -43,7 +43,6 @@ export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-hel
43
43
  export type { BaseFieldProps, FieldsTextFieldProps } from './models/fields';
44
44
  export type { BasePickerProps, BasePickerInputProps, BaseNonStaticPickerProps, } from './models/props/basePickerProps';
45
45
  export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/toolbar';
46
- export type { MuiPickersAdapter } from './models/muiPickersAdapter';
47
46
  export type { DefaultizedProps, MakeOptional } from './models/helpers';
48
47
  export type { WrapperVariant } from './models/common';
49
48
  export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
@@ -1,2 +1 @@
1
1
  export * from './fields';
2
- export * from './muiPickersAdapter';
@@ -1,2 +1 @@
1
- export * from './fields';
2
- export * from './muiPickersAdapter';
1
+ export * from './fields';
@@ -1,4 +1,4 @@
1
- import { MuiPickersAdapter } from '../models';
1
+ import { MuiPickersAdapter } from '../../models';
2
2
  interface FindClosestDateParams<TDate> {
3
3
  date: TDate;
4
4
  disableFuture?: boolean;
@@ -1,5 +1,4 @@
1
- import { MuiPickersAdapter } from '../models';
2
- import { DateOrTimeView } from '../../models';
1
+ import { DateOrTimeView, MuiPickersAdapter } from '../../models';
3
2
  export declare const isTimeView: (view: DateOrTimeView) => boolean;
4
3
  type Meridiem = 'am' | 'pm' | null;
5
4
  export declare const getMeridiem: <TDate>(date: TDate | null, utils: MuiPickersAdapter<TDate>) => Meridiem;
@@ -3,4 +3,4 @@ import { DateValidationError, TimeValidationError, DateTimeValidationError, Fiel
3
3
  import type { FieldValueManager } from '../hooks/useField';
4
4
  export type SingleItemPickerValueManager<TValue = any, TDate = any, TError extends DateValidationError | TimeValidationError | DateTimeValidationError = any> = PickerValueManager<TValue, TDate, TError>;
5
5
  export declare const singleItemValueManager: SingleItemPickerValueManager;
6
- export declare const singleItemFieldValueManager: FieldValueManager<any, any, FieldSection, DateValidationError | TimeValidationError | DateTimeValidationError>;
6
+ export declare const singleItemFieldValueManager: FieldValueManager<any, any, FieldSection>;
@@ -6,6 +6,7 @@ export const singleItemValueManager = {
6
6
  cleanValue: replaceInvalidDateByNull,
7
7
  areValuesEqual: areDatesEqual,
8
8
  isSameError: (a, b) => a === b,
9
+ hasError: error => error != null,
9
10
  defaultErrorState: null
10
11
  };
11
12
  export const singleItemFieldValueManager = {
@@ -27,6 +28,5 @@ export const singleItemFieldValueManager = {
27
28
  referenceValue: newActiveDate == null || !utils.isValid(newActiveDate) ? state.referenceValue : newActiveDate
28
29
  })
29
30
  }),
30
- parseValueStr: (valueStr, referenceValue, parseDate) => parseDate(valueStr.trim(), referenceValue),
31
- hasError: error => error != null
31
+ parseValueStr: (valueStr, referenceValue, parseDate) => parseDate(valueStr.trim(), referenceValue)
32
32
  };
@@ -98,7 +98,7 @@ export var AdapterLuxon = /*#__PURE__*/function (_BaseAdapterLuxon) {
98
98
  if (!DateTime.expandFormat) {
99
99
  throw Error('Your luxon version does not support `expandFormat`. Consider upgrading it to v3.0.2');
100
100
  }
101
- // Extract escaped section to avoid entending them
101
+ // Extract escaped section to avoid extending them
102
102
  var longFormatRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
103
103
  return format.match(longFormatRegexp).map(function (token) {
104
104
  var firstCharacter = token[0];
@@ -280,8 +280,6 @@ export var DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(in
280
280
  disableFuture: disableFuture,
281
281
  reduceAnimations: reduceAnimations,
282
282
  labelId: gridLabelId,
283
- components: components,
284
- componentsProps: componentsProps,
285
283
  slots: slots,
286
284
  slotProps: slotProps
287
285
  }), /*#__PURE__*/_jsx(DateCalendarViewTransitionContainer, {
@@ -14,6 +14,8 @@ import { ArrowDropDown } from '../internals/components/icons';
14
14
  import { PickersArrowSwitcher } from '../internals/components/PickersArrowSwitcher';
15
15
  import { usePreviousMonthDisabled, useNextMonthDisabled } from '../internals/hooks/date-helpers-hooks';
16
16
  import { getPickersCalendarHeaderUtilityClass, pickersCalendarHeaderClasses } from './pickersCalendarHeaderClasses';
17
+
18
+ // We keep the interface to allow module augmentation
17
19
  import { jsx as _jsx } from "react/jsx-runtime";
18
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
21
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -104,16 +106,14 @@ var PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDown, {
104
106
  * @ignore - do not document.
105
107
  */
106
108
  export function PickersCalendarHeader(inProps) {
107
- var _ref5, _slots$switchViewButt, _slotProps$switchView, _ref6, _slots$switchViewIcon, _slotProps$switchView2;
109
+ var _slots$switchViewButt, _slots$switchViewIcon;
108
110
  var localeText = useLocaleText();
109
111
  var utils = useUtils();
110
112
  var props = useThemeProps({
111
113
  props: inProps,
112
114
  name: 'MuiPickersCalendarHeader'
113
115
  });
114
- var components = props.components,
115
- componentsProps = props.componentsProps,
116
- slots = props.slots,
116
+ var slots = props.slots,
117
117
  slotProps = props.slotProps,
118
118
  month = props.currentMonth,
119
119
  disabled = props.disabled,
@@ -129,10 +129,10 @@ export function PickersCalendarHeader(inProps) {
129
129
  labelId = props.labelId;
130
130
  var ownerState = props;
131
131
  var classes = useUtilityClasses(props);
132
- var SwitchViewButton = (_ref5 = (_slots$switchViewButt = slots == null ? void 0 : slots.switchViewButton) != null ? _slots$switchViewButt : components == null ? void 0 : components.SwitchViewButton) != null ? _ref5 : PickersCalendarHeaderSwitchViewButton;
132
+ var SwitchViewButton = (_slots$switchViewButt = slots == null ? void 0 : slots.switchViewButton) != null ? _slots$switchViewButt : PickersCalendarHeaderSwitchViewButton;
133
133
  var switchViewButtonProps = useSlotProps({
134
134
  elementType: SwitchViewButton,
135
- externalSlotProps: (_slotProps$switchView = slotProps == null ? void 0 : slotProps.switchViewButton) != null ? _slotProps$switchView : componentsProps == null ? void 0 : componentsProps.switchViewButton,
135
+ externalSlotProps: slotProps == null ? void 0 : slotProps.switchViewButton,
136
136
  additionalProps: {
137
137
  size: 'small',
138
138
  'aria-label': localeText.calendarViewSwitchingButtonAriaLabel(view)
@@ -140,11 +140,11 @@ export function PickersCalendarHeader(inProps) {
140
140
  ownerState: ownerState,
141
141
  className: classes.switchViewButton
142
142
  });
143
- var SwitchViewIcon = (_ref6 = (_slots$switchViewIcon = slots == null ? void 0 : slots.switchViewIcon) != null ? _slots$switchViewIcon : components == null ? void 0 : components.SwitchViewIcon) != null ? _ref6 : PickersCalendarHeaderSwitchViewIcon;
143
+ var SwitchViewIcon = (_slots$switchViewIcon = slots == null ? void 0 : slots.switchViewIcon) != null ? _slots$switchViewIcon : PickersCalendarHeaderSwitchViewIcon;
144
144
  // The spread is here to avoid this bug mui/material-ui#34056
145
145
  var _useSlotProps = useSlotProps({
146
146
  elementType: SwitchViewIcon,
147
- externalSlotProps: (_slotProps$switchView2 = slotProps == null ? void 0 : slotProps.switchViewIcon) != null ? _slotProps$switchView2 : componentsProps == null ? void 0 : componentsProps.switchViewIcon,
147
+ externalSlotProps: slotProps == null ? void 0 : slotProps.switchViewIcon,
148
148
  ownerState: undefined,
149
149
  className: classes.switchViewIcon
150
150
  }),
@@ -209,8 +209,6 @@ export function PickersCalendarHeader(inProps) {
209
209
  }), /*#__PURE__*/_jsx(Fade, {
210
210
  in: view === 'day',
211
211
  children: /*#__PURE__*/_jsx(PickersArrowSwitcher, {
212
- components: components,
213
- componentsProps: componentsProps,
214
212
  slots: slots,
215
213
  slotProps: slotProps,
216
214
  onGoToPrevious: selectPreviousMonth,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["components", "componentsProps", "slots", "slotProps"],
3
+ var _excluded = ["components", "componentsProps", "slots", "slotProps", "InputProps", "inputProps"],
4
4
  _excluded2 = ["inputRef"],
5
5
  _excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
6
6
  import * as React from 'react';
@@ -20,6 +20,8 @@ var DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref) {
20
20
  componentsProps = themeProps.componentsProps,
21
21
  slots = themeProps.slots,
22
22
  slotProps = themeProps.slotProps,
23
+ InputProps = themeProps.InputProps,
24
+ inputProps = themeProps.inputProps,
23
25
  other = _objectWithoutProperties(themeProps, _excluded);
24
26
  var ownerState = themeProps;
25
27
  var TextField = (_ref = (_slots$textField = slots == null ? void 0 : slots.textField) != null ? _slots$textField : components == null ? void 0 : components.TextField) != null ? _ref : MuiTextField;
@@ -31,6 +33,10 @@ var DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref) {
31
33
  }),
32
34
  externalInputRef = _useSlotProps.inputRef,
33
35
  textFieldProps = _objectWithoutProperties(_useSlotProps, _excluded2);
36
+
37
+ // TODO: Remove when mui/material-ui#35088 will be merged
38
+ textFieldProps.inputProps = _extends({}, textFieldProps.inputProps, inputProps);
39
+ textFieldProps.InputProps = _extends({}, textFieldProps.InputProps, InputProps);
34
40
  var _useDateField = useDateField({
35
41
  props: textFieldProps,
36
42
  inputRef: externalInputRef
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["components", "componentsProps", "slots", "slotProps"],
3
+ var _excluded = ["components", "componentsProps", "slots", "slotProps", "InputProps", "inputProps"],
4
4
  _excluded2 = ["inputRef"],
5
5
  _excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
6
6
  import * as React from 'react';
@@ -20,6 +20,8 @@ var DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inProps
20
20
  componentsProps = themeProps.componentsProps,
21
21
  slots = themeProps.slots,
22
22
  slotProps = themeProps.slotProps,
23
+ InputProps = themeProps.InputProps,
24
+ inputProps = themeProps.inputProps,
23
25
  other = _objectWithoutProperties(themeProps, _excluded);
24
26
  var ownerState = themeProps;
25
27
  var TextField = (_ref = (_slots$textField = slots == null ? void 0 : slots.textField) != null ? _slots$textField : components == null ? void 0 : components.TextField) != null ? _ref : MuiTextField;
@@ -31,6 +33,10 @@ var DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inProps
31
33
  }),
32
34
  externalInputRef = _useSlotProps.inputRef,
33
35
  textFieldProps = _objectWithoutProperties(_useSlotProps, _excluded2);
36
+
37
+ // TODO: Remove when mui/material-ui#35088 will be merged
38
+ textFieldProps.inputProps = _extends({}, textFieldProps.inputProps, inputProps);
39
+ textFieldProps.InputProps = _extends({}, textFieldProps.InputProps, InputProps);
34
40
  var _useDateTimeField = useDateTimeField({
35
41
  props: textFieldProps,
36
42
  inputRef: externalInputRef
@@ -17,6 +17,7 @@ import { PickerViewRoot } from '../internals/components/PickerViewRoot';
17
17
  import { getTimeClockUtilityClass } from './timeClockClasses';
18
18
  import { Clock } from './Clock';
19
19
  import { getHourNumbers, getMinutesNumbers } from './ClockNumbers';
20
+ import { uncapitalizeObjectKeys } from '../internals/utils/slots-migration';
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
21
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
23
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -70,8 +71,8 @@ export var TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps,
70
71
  autoFocus = props.autoFocus,
71
72
  components = props.components,
72
73
  componentsProps = props.componentsProps,
73
- slots = props.slots,
74
- slotProps = props.slotProps,
74
+ innerSlots = props.slots,
75
+ innerSlotProps = props.slotProps,
75
76
  valueProp = props.value,
76
77
  _props$disableIgnorin = props.disableIgnoringDatePartForTimeValidation,
77
78
  disableIgnoringDatePartForTimeValidation = _props$disableIgnorin === void 0 ? false : _props$disableIgnorin,
@@ -95,6 +96,8 @@ export var TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps,
95
96
  disabled = props.disabled,
96
97
  readOnly = props.readOnly,
97
98
  other = _objectWithoutProperties(props, _excluded);
99
+ var slots = innerSlots != null ? innerSlots : uncapitalizeObjectKeys(components);
100
+ var slotProps = innerSlotProps != null ? innerSlotProps : componentsProps;
98
101
  var _useControlled = useControlled({
99
102
  name: 'DateCalendar',
100
103
  state: 'value',
@@ -297,8 +300,6 @@ export var TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps,
297
300
  readOnly: readOnly
298
301
  }, viewProps)), showViewSwitcher && /*#__PURE__*/_jsx(TimeClockArrowSwitcher, {
299
302
  className: classes.arrowSwitcher,
300
- components: components,
301
- componentsProps: componentsProps,
302
303
  slots: slots,
303
304
  slotProps: slotProps,
304
305
  onGoToPrevious: function onGoToPrevious() {
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["slots", "slotProps", "components", "componentsProps"],
3
+ var _excluded = ["slots", "slotProps", "components", "componentsProps", "InputProps", "inputProps"],
4
4
  _excluded2 = ["inputRef"],
5
5
  _excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
6
6
  import * as React from 'react';
@@ -20,6 +20,8 @@ var TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref) {
20
20
  slotProps = themeProps.slotProps,
21
21
  components = themeProps.components,
22
22
  componentsProps = themeProps.componentsProps,
23
+ InputProps = themeProps.InputProps,
24
+ inputProps = themeProps.inputProps,
23
25
  other = _objectWithoutProperties(themeProps, _excluded);
24
26
  var ownerState = themeProps;
25
27
  var TextField = (_ref = (_slots$textField = slots == null ? void 0 : slots.textField) != null ? _slots$textField : components == null ? void 0 : components.TextField) != null ? _ref : MuiTextField;
@@ -31,6 +33,10 @@ var TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref) {
31
33
  }),
32
34
  externalInputRef = _useSlotProps.inputRef,
33
35
  textFieldProps = _objectWithoutProperties(_useSlotProps, _excluded2);
36
+
37
+ // TODO: Remove when mui/material-ui#35088 will be merged
38
+ textFieldProps.inputProps = _extends({}, textFieldProps.inputProps, inputProps);
39
+ textFieldProps.InputProps = _extends({}, textFieldProps.InputProps, InputProps);
34
40
  var _useTimeField = useTimeField({
35
41
  props: textFieldProps,
36
42
  inputRef: externalInputRef
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.0.4
2
+ * @mui/x-date-pickers v6.1.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the