@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
@@ -1,19 +1,19 @@
1
1
  import * as React from 'react';
2
- import IconButton, { IconButtonProps } from '@mui/material/IconButton';
3
- import { InputAdornmentProps } from '@mui/material/InputAdornment';
4
- import TextField from '@mui/material/TextField';
5
- import { SlotComponentProps } from '@mui/utils';
2
+ import type { IconButtonProps } from '@mui/material/IconButton';
3
+ import type { InputAdornmentProps } from '@mui/material/InputAdornment';
4
+ import type { TextFieldProps } from '@mui/material/TextField';
6
5
  import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
7
6
  import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
8
7
  import { PickersPopperSlots, PickersPopperSlotProps } from '../../components/PickersPopper';
9
8
  import { UsePickerParams } from '../usePicker';
10
- import { FieldSection, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
9
+ import { FieldOwnerState, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
11
10
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
12
11
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
13
12
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
14
- import { DateOrTimeViewWithMeridiem } from '../../models';
13
+ import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
15
14
  import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '../../../hooks/useClearableField';
16
- export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem> extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValidDate | null, TView>, UseClearableFieldSlots {
15
+ import { PickersTextFieldProps } from '../../../PickersTextField';
16
+ export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem> extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue, TView>, UseClearableFieldSlots {
17
17
  /**
18
18
  * Component used to enter the date with the keyboard.
19
19
  */
@@ -38,13 +38,13 @@ export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem>
38
38
  */
39
39
  openPickerIcon: React.ElementType;
40
40
  }
41
- export interface UseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValidDate | null, TView>, 'toolbar'> {
41
+ export interface UseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue, TView>, 'toolbar'> {
42
42
  }
43
- export interface ExportedUseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValidDate | null, TView>, UseClearableFieldSlotProps {
44
- field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValidDate | null, FieldSection, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
45
- textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
43
+ export interface ExportedUseDesktopPickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue, TView>, UseClearableFieldSlotProps {
44
+ field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
45
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
46
46
  inputAdornment?: SlotComponentPropsFromProps<InputAdornmentProps, {}, PickerOwnerState>;
47
- openPickerButton?: SlotComponentProps<typeof IconButton, {}, PickerOwnerState>;
47
+ openPickerButton?: SlotComponentPropsFromProps<IconButtonProps, {}, PickerOwnerState>;
48
48
  openPickerIcon?: SlotComponentPropsFromProps<Record<string, any>, {}, PickerOwnerState>;
49
49
  }
50
50
  export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps {
@@ -54,7 +54,7 @@ export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNo
54
54
  */
55
55
  autoFocus?: boolean;
56
56
  }
57
- export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValidDate | null, TView, any, {}>> extends BasePickerProps<PickerValidDate | null, TView, TError, TExternalProps, {}>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
57
+ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any, {}>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps, {}>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
58
58
  /**
59
59
  * Overridable component slots.
60
60
  * @default {}
@@ -66,7 +66,7 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
66
66
  */
67
67
  slotProps?: UseDesktopPickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>;
68
68
  }
69
- export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValidDate | null, TView, FieldSection, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
69
+ export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
70
70
  props: TExternalProps;
71
71
  getOpenDialogAriaText: (date: PickerValidDate | null) => string;
72
72
  }
@@ -1,5 +1,5 @@
1
1
  import { UseFieldParams, UseFieldResponse, UseFieldCommonForwardedProps, UseFieldInternalProps, UseFieldForwardedProps } from './useField.types';
2
- import { FieldSection } from '../../../models';
3
- export declare const useField: <TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<any, any, TEnableAccessibleFieldDOMStructure, any> & {
2
+ import { PickerValidValue } from '../../models';
3
+ export declare const useField: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any> & {
4
4
  minutesStep?: number;
5
- }>(params: UseFieldParams<TValue, TSection, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldResponse<TEnableAccessibleFieldDOMStructure, TForwardedProps>;
5
+ }>(params: UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldResponse<TEnableAccessibleFieldDOMStructure, TForwardedProps>;
@@ -1,21 +1,21 @@
1
1
  import * as React from 'react';
2
- import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, FieldValueType, PickerValidDate, FieldRef, OnErrorProps, InferError } from '../../../models';
2
+ import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferError, InferFieldSection, PickerValueType } from '../../../models';
3
3
  import type { PickerValueManager } from '../usePicker';
4
4
  import type { Validator } from '../../../validation';
5
5
  import type { UseFieldStateResponse } from './useFieldState';
6
6
  import type { UseFieldCharacterEditingResponse } from './useFieldCharacterEditing';
7
7
  import { PickersSectionElement, PickersSectionListRef } from '../../../PickersSectionList';
8
8
  import { ExportedUseClearableFieldProps } from '../../../hooks/useClearableField';
9
- import { FormProps } from '../../models';
10
- export interface UseFieldParams<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<any, any, TEnableAccessibleFieldDOMStructure, any>> {
9
+ import { FormProps, InferNonNullablePickerValue, PickerValidValue } from '../../models';
10
+ export interface UseFieldParams<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>> {
11
11
  forwardedProps: TForwardedProps;
12
12
  internalProps: TInternalProps;
13
13
  valueManager: PickerValueManager<TValue, InferError<TInternalProps>>;
14
- fieldValueManager: FieldValueManager<TValue, TSection>;
14
+ fieldValueManager: FieldValueManager<TValue>;
15
15
  validator: Validator<TValue, InferError<TInternalProps>, TInternalProps>;
16
- valueType: FieldValueType;
16
+ valueType: PickerValueType;
17
17
  }
18
- export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
18
+ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
19
19
  /**
20
20
  * The selected value.
21
21
  * Used when the component is controlled.
@@ -50,10 +50,10 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
50
50
  */
51
51
  formatDensity?: 'dense' | 'spacious';
52
52
  /**
53
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
54
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
53
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
54
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
55
55
  *
56
- * 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`.
56
+ * 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`.
57
57
  *
58
58
  * 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.
59
59
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -82,7 +82,7 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
82
82
  /**
83
83
  * The ref object used to imperatively interact with the field.
84
84
  */
85
- unstableFieldRef?: React.Ref<FieldRef<TSection>>;
85
+ unstableFieldRef?: React.Ref<FieldRef<TValue>>;
86
86
  /**
87
87
  * @default true
88
88
  */
@@ -93,7 +93,7 @@ export interface UseFieldInternalProps<TValue, TSection extends FieldSection, TE
93
93
  */
94
94
  autoFocus?: boolean;
95
95
  }
96
- export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any, any>, 'disabled' | 'readOnly'>> {
96
+ export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly'>> {
97
97
  }
98
98
  export interface UseFieldCommonForwardedProps extends ExportedUseClearableFieldProps {
99
99
  onKeyDown?: React.KeyboardEventHandler;
@@ -152,7 +152,7 @@ export type FieldSectionsBoundaries = {
152
152
  maximum: number;
153
153
  };
154
154
  };
155
- export type FieldChangeHandler<TValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
155
+ export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
156
156
  export interface FieldChangeHandlerContext<TError> {
157
157
  validationError: TError;
158
158
  }
@@ -160,7 +160,7 @@ export interface FieldChangeHandlerContext<TError> {
160
160
  * Object used to access and update the active date (i.e: the date containing the active section).
161
161
  * Mainly useful in the range fields where we need to update the date containing the active section without impacting the other one.
162
162
  */
163
- interface FieldActiveDateManager<TValue, TSection extends FieldSection> {
163
+ interface FieldActiveDateManager<TValue extends PickerValidValue> {
164
164
  /**
165
165
  * Active date from `state.value`.
166
166
  */
@@ -170,87 +170,87 @@ interface FieldActiveDateManager<TValue, TSection extends FieldSection> {
170
170
  */
171
171
  referenceDate: PickerValidDate;
172
172
  /**
173
- * @template TSection
174
- * @param {TSection[]} sections The sections of the full value.
175
- * @returns {TSection[]} The sections of the active date.
173
+ * @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.
174
+ * @param {InferFieldSection<TValue>[]} sections The sections of the full value.
175
+ * @returns {InferFieldSection<TValue>[]} The sections of the active date.
176
176
  * Get the sections of the active date.
177
177
  */
178
- getSections: (sections: TSection[]) => TSection[];
178
+ getSections: (sections: InferFieldSection<TValue>[]) => InferFieldSection<TValue>[];
179
179
  /**
180
180
  * Creates the new value and reference value based on the new active date and the current state.
181
- * @template TValue
181
+ * @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.
182
182
  * @param {PickerValidDate | null} newActiveDate The new value of the date containing the active section.
183
- * @returns {Pick<UseFieldState<TValue, any>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
183
+ * @returns {Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>} The new value and reference value to publish and store in the state.
184
184
  */
185
- getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue, any>, 'value' | 'referenceValue'>;
185
+ getNewValuesFromNewActiveDate: (newActiveDate: PickerValidDate | null) => Pick<UseFieldState<TValue>, 'value' | 'referenceValue'>;
186
186
  }
187
187
  export type FieldParsedSelectedSections = number | 'all' | null;
188
- export interface FieldValueManager<TValue, TSection extends FieldSection> {
188
+ export interface FieldValueManager<TValue extends PickerValidValue> {
189
189
  /**
190
190
  * Creates the section list from the current value.
191
191
  * The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
192
- * @template TValue, TSection
192
+ * @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.
193
193
  * @param {MuiPickersAdapter} utils The utils to manipulate the date.
194
194
  * @param {TValue} value The current value to generate sections from.
195
- * @param {TSection[] | null} fallbackSections The sections to use as a fallback if a date is null or invalid.
195
+ * @param {InferFieldSection<TValue>[] | null} fallbackSections The sections to use as a fallback if a date is null or invalid.
196
196
  * @param {(date: PickerValidDate) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
197
- * @returns {TSection[]} The new section list.
197
+ * @returns {InferFieldSection<TValue>[]} The new section list.
198
198
  */
199
- getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections: TSection[] | null, getSectionsFromDate: (date: PickerValidDate) => FieldSection[]) => TSection[];
199
+ getSectionsFromValue: (utils: MuiPickersAdapter, value: TValue, fallbackSections: InferFieldSection<TValue>[] | null, getSectionsFromDate: (date: PickerValidDate) => FieldSection[]) => InferFieldSection<TValue>[];
200
200
  /**
201
201
  * Creates the string value to render in the input based on the current section list.
202
- * @template TSection
203
- * @param {TSection[]} sections The current section list.
202
+ * @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.
203
+ * @param {InferFieldSection<TValue>[]} sections The current section list.
204
204
  * @param {string} localizedDigits The conversion table from localized to 0-9 digits.
205
205
  * @param {boolean} isRtl `true` if the current orientation is "right to left"
206
206
  * @returns {string} The string value to render in the input.
207
207
  */
208
- getV6InputValueFromSections: (sections: TSection[], localizedDigits: string[], isRtl: boolean) => string;
208
+ getV6InputValueFromSections: (sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => string;
209
209
  /**
210
210
  * Creates the string value to render in the input based on the current section list.
211
- * @template TSection
212
- * @param {TSection[]} sections The current section list.
211
+ * @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.
212
+ * @param {InferFieldSection<TValue>[]} sections The current section list.
213
213
  * @returns {string} The string value to render in the input.
214
214
  */
215
- getV7HiddenInputValueFromSections: (sections: TSection[]) => string;
215
+ getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
216
216
  /**
217
217
  * Returns the manager of the active date.
218
- * @template TValue, TSection
218
+ * @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.
219
219
  * @param {MuiPickersAdapter} utils The utils to manipulate the date.
220
- * @param {UseFieldState<TValue, TSection>} state The current state of the field.
221
- * @param {TSection} activeSection The active section.
222
- * @returns {FieldActiveDateManager<TValue, TSection>} The manager of the active date.
220
+ * @param {UseFieldState<TValue>} state The current state of the field.
221
+ * @param {InferFieldSection<TValue>} activeSection The active section.
222
+ * @returns {FieldActiveDateManager<TValue>} The manager of the active date.
223
223
  */
224
- getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue, TSection>, activeSection: TSection) => FieldActiveDateManager<TValue, TSection>;
224
+ getActiveDateManager: (utils: MuiPickersAdapter, state: UseFieldState<TValue>, activeSection: InferFieldSection<TValue>) => FieldActiveDateManager<TValue>;
225
225
  /**
226
226
  * Parses a string version (most of the time coming from the input).
227
227
  * This method should only be used when the change does not come from a single section.
228
- * @template TValue
228
+ * @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.
229
229
  * @param {string} valueStr The string value to parse.
230
230
  * @param {TValue} referenceValue The reference value currently stored in state.
231
231
  * @param {(dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null} parseDate A method to convert a string date into a parsed one.
232
232
  * @returns {TValue} The new parsed value.
233
233
  */
234
- parseValueStr: (valueStr: string, referenceValue: TValue, parseDate: (dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null) => TValue;
234
+ parseValueStr: (valueStr: string, referenceValue: InferNonNullablePickerValue<TValue>, parseDate: (dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null) => TValue;
235
235
  /**
236
236
  * Update the reference value with the new value.
237
237
  * This method must make sure that no date inside the returned `referenceValue` is invalid.
238
- * @template TValue
238
+ * @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.
239
239
  * @param {MuiPickersAdapter} utils The utils to manipulate the date.
240
240
  * @param {TValue} value The new value from which we want to take all valid dates in the `referenceValue` state.
241
241
  * @param {TValue} prevReferenceValue The previous reference value. It is used as a fallback for invalid dates in the new value.
242
242
  * @returns {TValue} The new reference value with no invalid date.
243
243
  */
244
- updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: TValue) => TValue;
244
+ updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
245
245
  }
246
- export interface UseFieldState<TValue, TSection extends FieldSection> {
246
+ export interface UseFieldState<TValue extends PickerValidValue> {
247
247
  value: TValue;
248
248
  /**
249
249
  * Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
250
250
  * It is updated whenever we have a valid date (for the range picker we update only the portion of the range that is valid).
251
251
  */
252
- referenceValue: TValue;
253
- sections: TSection[];
252
+ referenceValue: InferNonNullablePickerValue<TValue>;
253
+ sections: InferFieldSection<TValue>[];
254
254
  /**
255
255
  * Android `onChange` behavior when the input selection is not empty is quite different from a desktop behavior.
256
256
  * There are two `onChange` calls:
@@ -317,13 +317,13 @@ export interface UseFieldTextFieldInteractions {
317
317
  setSelectedSections: (newSelectedSections: FieldSelectedSections) => void;
318
318
  isFieldFocused: () => boolean;
319
319
  }
320
- export type UseFieldTextField<TEnableAccessibleFieldDOMStructure extends boolean> = <TValue, TSection extends FieldSection, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, TEnableAccessibleFieldDOMStructure, any> & {
320
+ export type UseFieldTextField<TEnableAccessibleFieldDOMStructure extends boolean> = <TValue extends PickerValidValue, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any> & {
321
321
  minutesStep?: number;
322
- }>(params: UseFieldTextFieldParams<TValue, TSection, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => {
322
+ }>(params: UseFieldTextFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => {
323
323
  interactions: UseFieldTextFieldInteractions;
324
324
  returnedValue: TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6AdditionalProps & Required<UseFieldV6ForwardedProps> : UseFieldV7AdditionalProps & Required<UseFieldV7ForwardedProps>;
325
325
  };
326
- interface UseFieldTextFieldParams<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<any, any, TEnableAccessibleFieldDOMStructure, any>> extends UseFieldParams<TValue, TSection, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>, UseFieldStateResponse<TValue, TSection>, UseFieldCharacterEditingResponse {
326
+ interface UseFieldTextFieldParams<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>> extends UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>, UseFieldStateResponse<TValue>, UseFieldCharacterEditingResponse {
327
327
  areAllSectionsEmpty: boolean;
328
328
  sectionOrder: SectionOrdering;
329
329
  }
@@ -1,5 +1,6 @@
1
1
  import { AvailableAdjustKeyCode, FieldSectionsValueBoundaries, SectionOrdering, FieldSectionValueBoundaries, FieldParsedSelectedSections } from './useField.types';
2
- import { FieldSectionType, FieldValueType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections } from '../../../models';
2
+ import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType, InferFieldSection } from '../../../models';
3
+ import { PickerValidValue } from '../../models';
3
4
  export declare const getDateSectionConfigFromFormatToken: (utils: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
4
5
  maxLength: number | undefined;
5
6
  };
@@ -17,7 +18,7 @@ export declare const isStringNumber: (valueStr: string, localizedDigits: string[
17
18
  */
18
19
  export declare const cleanLeadingZeros: (valueStr: string, size: number) => string;
19
20
  export declare const cleanDigitSectionValue: (utils: MuiPickersAdapter, value: number, sectionBoundaries: FieldSectionValueBoundaries<any>, localizedDigits: string[], section: Pick<FieldSection, "format" | "type" | "contentType" | "hasLeadingZerosInFormat" | "hasLeadingZerosInInput" | "maxLength">) => string;
20
- export declare const adjustSectionValue: <TSection extends FieldSection>(utils: MuiPickersAdapter, timezone: PickersTimezone, section: TSection, keyCode: AvailableAdjustKeyCode, sectionsValueBoundaries: FieldSectionsValueBoundaries, localizedDigits: string[], activeDate: PickerValidDate | null, stepsAttributes?: {
21
+ export declare const adjustSectionValue: <TValue extends PickerValidValue>(utils: MuiPickersAdapter, timezone: PickersTimezone, section: InferFieldSection<TValue>, keyCode: AvailableAdjustKeyCode, sectionsValueBoundaries: FieldSectionsValueBoundaries, localizedDigits: string[], activeDate: PickerValidDate | null, stepsAttributes?: {
21
22
  minutesStep?: number;
22
23
  }) => string;
23
24
  export declare const getSectionVisibleValue: (section: FieldSection, target: "input-rtl" | "input-ltr" | "non-input", localizedDigits: string[]) => string;
@@ -31,7 +32,7 @@ export declare const getDateFromDateSections: (utils: MuiPickersAdapter, section
31
32
  export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
32
33
  export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
33
34
  export declare const getSectionsBoundaries: (utils: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
34
- export declare const validateSections: <TSection extends FieldSection>(sections: TSection[], valueType: FieldValueType) => void;
35
+ export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
35
36
  export declare const mergeDateIntoReferenceDate: (utils: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
36
37
  export declare const isAndroid: () => boolean;
37
38
  export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
@@ -1,13 +1,14 @@
1
- import { FieldSection, PickersTimezone } from '../../../models';
1
+ import { PickersTimezone, InferFieldSection } from '../../../models';
2
2
  import { FieldSectionsValueBoundaries } from './useField.types';
3
3
  import { UpdateSectionValueParams } from './useFieldState';
4
+ import { PickerValidValue } from '../../models';
4
5
  export interface ApplyCharacterEditingParams {
5
6
  keyPressed: string;
6
7
  sectionIndex: number;
7
8
  }
8
- interface UseFieldCharacterEditingParams<TSection extends FieldSection> {
9
- sections: TSection[];
10
- updateSectionValue: (params: UpdateSectionValueParams<TSection>) => void;
9
+ interface UseFieldCharacterEditingParams<TValue extends PickerValidValue> {
10
+ sections: InferFieldSection<TValue>[];
11
+ updateSectionValue: (params: UpdateSectionValueParams<TValue>) => void;
11
12
  sectionsValueBoundaries: FieldSectionsValueBoundaries;
12
13
  localizedDigits: string[];
13
14
  setTempAndroidValueStr: (newValue: string | null) => void;
@@ -24,5 +25,5 @@ export interface UseFieldCharacterEditingResponse {
24
25
  * 1. The numeric editing when the user presses a digit
25
26
  * 2. The letter editing when the user presses another key
26
27
  */
27
- export declare const useFieldCharacterEditing: <TSection extends FieldSection>({ sections, updateSectionValue, sectionsValueBoundaries, localizedDigits, setTempAndroidValueStr, timezone, }: UseFieldCharacterEditingParams<TSection>) => UseFieldCharacterEditingResponse;
28
+ export declare const useFieldCharacterEditing: <TValue extends PickerValidValue>({ sections, updateSectionValue, sectionsValueBoundaries, localizedDigits, setTempAndroidValueStr, timezone, }: UseFieldCharacterEditingParams<TValue>) => UseFieldCharacterEditingResponse;
28
29
  export {};
@@ -1,10 +1,11 @@
1
1
  import { UseFieldInternalProps, UseFieldParams, UseFieldState, FieldParsedSelectedSections, FieldSectionsValueBoundaries, UseFieldForwardedProps } from './useField.types';
2
- import { FieldSection, FieldSelectedSections, PickersTimezone } from '../../../models';
3
- export interface UpdateSectionValueParams<TSection extends FieldSection> {
2
+ import { FieldSelectedSections, PickersTimezone, InferFieldSection } from '../../../models';
3
+ import { PickerValidValue } from '../../models';
4
+ export interface UpdateSectionValueParams<TValue extends PickerValidValue> {
4
5
  /**
5
6
  * The section on which we want to apply the new value.
6
7
  */
7
- activeSection: TSection;
8
+ activeSection: InferFieldSection<TValue>;
8
9
  /**
9
10
  * Value to apply to the active section.
10
11
  */
@@ -14,19 +15,19 @@ export interface UpdateSectionValueParams<TSection extends FieldSection> {
14
15
  */
15
16
  shouldGoToNextSection: boolean;
16
17
  }
17
- export interface UseFieldStateResponse<TValue, TSection extends FieldSection> {
18
- state: UseFieldState<TValue, TSection>;
18
+ export interface UseFieldStateResponse<TValue extends PickerValidValue> {
19
+ state: UseFieldState<TValue>;
19
20
  activeSectionIndex: number | null;
20
21
  parsedSelectedSections: FieldParsedSelectedSections;
21
22
  setSelectedSections: (sections: FieldSelectedSections) => void;
22
23
  clearValue: () => void;
23
24
  clearActiveSection: () => void;
24
- updateSectionValue: (params: UpdateSectionValueParams<TSection>) => void;
25
+ updateSectionValue: (params: UpdateSectionValueParams<TValue>) => void;
25
26
  updateValueFromValueStr: (valueStr: string) => void;
26
27
  setTempAndroidValueStr: (tempAndroidValueStr: string | null) => void;
27
28
  sectionsValueBoundaries: FieldSectionsValueBoundaries;
28
- getSectionsFromValue: (value: TValue, fallbackSections?: TSection[] | null) => TSection[];
29
+ getSectionsFromValue: (value: TValue, fallbackSections?: InferFieldSection<TValue>[] | null) => InferFieldSection<TValue>[];
29
30
  localizedDigits: string[];
30
31
  timezone: PickersTimezone;
31
32
  }
32
- export declare const useFieldState: <TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<any, any, any, any>>(params: UseFieldParams<TValue, TSection, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldStateResponse<TValue, TSection>;
33
+ export declare const useFieldState: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any>>(params: UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldStateResponse<TValue>;
@@ -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);
@@ -1,6 +1,7 @@
1
1
  import { UseFieldTextField } from './useField.types';
2
- import { FieldSection } from '../../../models';
3
- type FieldSectionWithPositions<TSection> = TSection & {
2
+ import { InferFieldSection } from '../../../models';
3
+ import { PickerValidValue } from '../../models';
4
+ type FieldSectionWithPositions<TValue extends PickerValidValue> = InferFieldSection<TValue> & {
4
5
  /**
5
6
  * Start index of the section in the format
6
7
  */
@@ -20,6 +21,6 @@ type FieldSectionWithPositions<TSection> = TSection & {
20
21
  */
21
22
  endInInput: number;
22
23
  };
23
- export declare const addPositionPropertiesToSections: <TSection extends FieldSection>(sections: TSection[], localizedDigits: string[], isRtl: boolean) => FieldSectionWithPositions<TSection>[];
24
+ export declare const addPositionPropertiesToSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => FieldSectionWithPositions<TValue>[];
24
25
  export declare const useFieldV6TextField: UseFieldTextField<false>;
25
26
  export {};
@@ -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,6 @@
1
+ import { FieldOwnerState } from '../../models';
2
+ import { FormProps } from '../models';
3
+ export declare function useFieldOwnerState(parameters: UseFieldOwnerStateParameters): FieldOwnerState;
4
+ interface UseFieldOwnerStateParameters extends FormProps {
5
+ }
6
+ export {};
@@ -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,16 +1,16 @@
1
1
  import * as React from 'react';
2
- import TextField from '@mui/material/TextField';
3
- import { SlotComponentProps } from '@mui/utils';
2
+ import type { TextFieldProps } from '@mui/material/TextField';
4
3
  import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
5
4
  import { BaseNonStaticPickerProps, BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
6
5
  import { PickersModalDialogSlots, PickersModalDialogSlotProps } from '../../components/PickersModalDialog';
7
6
  import { UsePickerParams } from '../usePicker';
8
- import { FieldSection, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
7
+ import { FieldOwnerState, PickerFieldSlotProps, PickerOwnerState, PickerValidDate } from '../../../models';
9
8
  import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
10
9
  import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
11
10
  import { UsePickerViewsNonStaticProps, UsePickerViewsProps } from '../usePicker/usePickerViews';
12
- import { DateOrTimeViewWithMeridiem } from '../../models';
13
- export interface UseMobilePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerValidDate | null, TView> {
11
+ import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
12
+ import { PickersTextFieldProps } from '../../../PickersTextField';
13
+ export interface UseMobilePickerSlots<TView extends DateOrTimeViewWithMeridiem> extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerValue, TView> {
14
14
  /**
15
15
  * Component used to enter the date with the keyboard.
16
16
  */
@@ -21,15 +21,15 @@ export interface UseMobilePickerSlots<TView extends DateOrTimeViewWithMeridiem>
21
21
  */
22
22
  textField?: React.ElementType;
23
23
  }
24
- export interface ExportedUseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<PickerValidDate | null, TView> {
25
- field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValidDate | null, FieldSection, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
26
- textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
24
+ export interface ExportedUseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<PickerValue, TView> {
25
+ field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
26
+ textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
27
27
  }
28
- export interface UseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValidDate | null, TView>, 'toolbar'> {
28
+ export interface UseMobilePickerSlotProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue, TView>, 'toolbar'> {
29
29
  }
30
30
  export interface MobileOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps {
31
31
  }
32
- export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends BasePickerProps<PickerValidDate | null, TView, TError, TExternalProps, {}>, MakeRequired<MobileOnlyPickerProps, 'format'> {
32
+ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps, {}>, MakeRequired<MobileOnlyPickerProps, 'format'> {
33
33
  /**
34
34
  * Overridable component slots.
35
35
  * @default {}
@@ -41,7 +41,7 @@ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
41
41
  */
42
42
  slotProps?: UseMobilePickerSlotProps<TView, TEnableAccessibleFieldDOMStructure>;
43
43
  }
44
- export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValidDate | null, TView, FieldSection, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator'> {
44
+ export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps, {}>, 'valueManager' | 'valueType' | 'validator'> {
45
45
  props: TExternalProps;
46
46
  getOpenDialogAriaText: (date: PickerValidDate | null) => string;
47
47
  }
@@ -1,4 +1,4 @@
1
1
  import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.types';
2
- import { FieldSection, InferError } from '../../../models';
3
- import { DateOrTimeViewWithMeridiem } from '../../models';
4
- export declare const usePicker: <TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, wrapperVariant, additionalViewProps, validator, autoFocusView, rendererInterceptor, fieldRef, localeText, }: UsePickerParams<TValue, TView, TSection, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, TSection, InferError<TExternalProps>>;
2
+ import { InferError } from '../../../models';
3
+ import { DateOrTimeViewWithMeridiem, PickerValidValue } from '../../models';
4
+ export declare const usePicker: <TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, variant, additionalViewProps, validator, autoFocusView, rendererInterceptor, fieldRef, localeText, }: UsePickerParams<TValue, TView, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, InferError<TExternalProps>>;
@@ -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
  };