@mui/x-date-pickers 8.5.3 → 8.7.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 (198) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/DateCalendar/DateCalendar.js +16 -16
  3. package/DateCalendar/DayCalendar.js +48 -48
  4. package/DateCalendar/useCalendarState.js +25 -25
  5. package/DateCalendar/useIsDateDisabled.js +2 -2
  6. package/DatePicker/DatePickerToolbar.js +7 -9
  7. package/DateTimeField/DateTimeField.js +1 -1
  8. package/DateTimePicker/DateTimePicker.js +1 -1
  9. package/DateTimePicker/DateTimePickerToolbar.js +12 -13
  10. package/DateTimePicker/shared.js +3 -3
  11. package/DesktopDatePicker/DesktopDatePicker.js +3 -3
  12. package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
  13. package/DesktopTimePicker/DesktopTimePicker.js +4 -4
  14. package/DigitalClock/DigitalClock.d.ts +1 -1
  15. package/DigitalClock/DigitalClock.js +16 -16
  16. package/LocalizationProvider/LocalizationProvider.d.ts +9 -3
  17. package/LocalizationProvider/LocalizationProvider.js +28 -19
  18. package/MobileDatePicker/MobileDatePicker.js +3 -3
  19. package/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
  20. package/MobileTimePicker/MobileTimePicker.js +4 -4
  21. package/MonthCalendar/MonthCalendar.js +19 -18
  22. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
  23. package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
  24. package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
  25. package/PickerDay2/PickerDay2.js +3 -3
  26. package/PickersActionBar/PickersActionBar.d.ts +2 -2
  27. package/PickersActionBar/PickersActionBar.js +2 -2
  28. package/PickersCalendarHeader/PickersCalendarHeader.js +7 -8
  29. package/PickersDay/PickersDay.js +3 -3
  30. package/PickersDay/usePickerDayOwnerState.js +5 -5
  31. package/PickersTextField/PickersInputBase/PickersInputBase.js +1 -0
  32. package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  33. package/StaticTimePicker/StaticTimePicker.js +1 -1
  34. package/TimeClock/Clock.js +8 -9
  35. package/TimeClock/ClockNumbers.d.ts +3 -3
  36. package/TimeClock/ClockNumbers.js +5 -5
  37. package/TimeClock/TimeClock.js +29 -29
  38. package/TimeField/TimeField.js +1 -1
  39. package/TimePicker/TimePicker.js +1 -1
  40. package/TimePicker/TimePickerToolbar.js +7 -9
  41. package/TimePicker/shared.js +3 -3
  42. package/YearCalendar/YearCalendar.js +19 -18
  43. package/esm/DateCalendar/DateCalendar.js +16 -16
  44. package/esm/DateCalendar/DayCalendar.js +48 -48
  45. package/esm/DateCalendar/useCalendarState.js +25 -25
  46. package/esm/DateCalendar/useIsDateDisabled.js +2 -2
  47. package/esm/DatePicker/DatePickerToolbar.js +6 -8
  48. package/esm/DateTimeField/DateTimeField.js +1 -1
  49. package/esm/DateTimePicker/DateTimePicker.js +1 -1
  50. package/esm/DateTimePicker/DateTimePickerToolbar.js +11 -12
  51. package/esm/DateTimePicker/shared.js +3 -3
  52. package/esm/DesktopDatePicker/DesktopDatePicker.js +3 -3
  53. package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
  54. package/esm/DesktopTimePicker/DesktopTimePicker.js +4 -4
  55. package/esm/DigitalClock/DigitalClock.d.ts +1 -1
  56. package/esm/DigitalClock/DigitalClock.js +16 -16
  57. package/esm/LocalizationProvider/LocalizationProvider.d.ts +9 -3
  58. package/esm/LocalizationProvider/LocalizationProvider.js +27 -18
  59. package/esm/MobileDatePicker/MobileDatePicker.js +3 -3
  60. package/esm/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
  61. package/esm/MobileTimePicker/MobileTimePicker.js +4 -4
  62. package/esm/MonthCalendar/MonthCalendar.js +20 -19
  63. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
  64. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
  65. package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
  66. package/esm/PickerDay2/PickerDay2.js +3 -3
  67. package/esm/PickersActionBar/PickersActionBar.d.ts +2 -2
  68. package/esm/PickersActionBar/PickersActionBar.js +2 -2
  69. package/esm/PickersCalendarHeader/PickersCalendarHeader.js +6 -7
  70. package/esm/PickersDay/PickersDay.js +3 -3
  71. package/esm/PickersDay/usePickerDayOwnerState.js +5 -5
  72. package/esm/PickersTextField/PickersInputBase/PickersInputBase.js +2 -0
  73. package/esm/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
  74. package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
  75. package/esm/TimeClock/Clock.js +7 -8
  76. package/esm/TimeClock/ClockNumbers.d.ts +3 -3
  77. package/esm/TimeClock/ClockNumbers.js +5 -5
  78. package/esm/TimeClock/TimeClock.js +29 -29
  79. package/esm/TimeField/TimeField.js +1 -1
  80. package/esm/TimePicker/TimePicker.js +1 -1
  81. package/esm/TimePicker/TimePickerToolbar.js +6 -8
  82. package/esm/TimePicker/shared.js +3 -3
  83. package/esm/YearCalendar/YearCalendar.js +20 -19
  84. package/esm/hooks/index.d.ts +2 -1
  85. package/esm/hooks/index.js +2 -1
  86. package/esm/hooks/useParsedFormat.js +6 -6
  87. package/esm/hooks/usePickerAdapter.d.ts +7 -0
  88. package/esm/hooks/usePickerAdapter.js +20 -0
  89. package/esm/hooks/usePickerTranslations.js +1 -1
  90. package/esm/index.js +1 -1
  91. package/esm/internals/components/PickerFieldUI.js +2 -0
  92. package/esm/internals/components/PickerPopper/PickerPopper.js +2 -0
  93. package/esm/internals/components/PickerProvider.js +2 -0
  94. package/esm/internals/components/pickersToolbarClasses.d.ts +1 -1
  95. package/esm/internals/demo/DemoContainer.d.ts +2 -3
  96. package/esm/internals/demo/DemoContainer.js +3 -2
  97. package/esm/internals/hooks/date-helpers-hooks.js +16 -16
  98. package/esm/internals/hooks/useClockReferenceDate.d.ts +2 -2
  99. package/esm/internals/hooks/useClockReferenceDate.js +5 -5
  100. package/esm/internals/hooks/useControlledValue.d.ts +2 -2
  101. package/esm/internals/hooks/useControlledValue.js +8 -7
  102. package/esm/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
  103. package/esm/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
  104. package/esm/internals/hooks/useField/useField.types.d.ts +4 -4
  105. package/esm/internals/hooks/useField/useField.utils.d.ts +10 -10
  106. package/esm/internals/hooks/useField/useField.utils.js +69 -69
  107. package/esm/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
  108. package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
  109. package/esm/internals/hooks/useField/useFieldSectionContentProps.js +15 -16
  110. package/esm/internals/hooks/useField/useFieldState.js +24 -24
  111. package/esm/internals/hooks/useField/useFieldV6TextField.js +2 -0
  112. package/esm/internals/hooks/useField/useFieldV7TextField.js +2 -0
  113. package/esm/internals/hooks/useNullableFieldPrivateContext.js +2 -0
  114. package/esm/internals/hooks/usePicker/hooks/useOrientation.js +2 -0
  115. package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +8 -6
  116. package/esm/internals/hooks/usePicker/usePicker.js +7 -6
  117. package/esm/internals/hooks/usePicker/usePicker.types.d.ts +3 -3
  118. package/esm/internals/hooks/useUtils.d.ts +1 -8
  119. package/esm/internals/hooks/useUtils.js +3 -19
  120. package/esm/internals/hooks/useViews.js +2 -0
  121. package/esm/internals/index.d.ts +2 -1
  122. package/esm/internals/index.js +2 -1
  123. package/esm/internals/models/manager.d.ts +17 -17
  124. package/esm/internals/models/props/time.d.ts +1 -1
  125. package/esm/internals/utils/date-time-utils.d.ts +1 -1
  126. package/esm/internals/utils/date-time-utils.js +5 -5
  127. package/esm/internals/utils/date-utils.d.ts +11 -11
  128. package/esm/internals/utils/date-utils.js +34 -34
  129. package/esm/internals/utils/getDefaultReferenceDate.d.ts +2 -2
  130. package/esm/internals/utils/getDefaultReferenceDate.js +16 -16
  131. package/esm/internals/utils/time-utils.d.ts +5 -5
  132. package/esm/internals/utils/time-utils.js +12 -12
  133. package/esm/internals/utils/valueManagers.js +4 -4
  134. package/esm/managers/useDateManager.js +12 -12
  135. package/esm/managers/useDateTimeManager.js +13 -13
  136. package/esm/managers/useTimeManager.js +9 -10
  137. package/esm/validation/useValidation.d.ts +2 -3
  138. package/esm/validation/useValidation.js +2 -2
  139. package/esm/validation/validateDate.js +6 -6
  140. package/esm/validation/validateTime.js +6 -6
  141. package/hooks/index.d.ts +2 -1
  142. package/hooks/index.js +8 -1
  143. package/hooks/useParsedFormat.js +6 -6
  144. package/hooks/usePickerAdapter.d.ts +7 -0
  145. package/hooks/usePickerAdapter.js +29 -0
  146. package/hooks/usePickerTranslations.js +2 -2
  147. package/index.js +1 -1
  148. package/internals/components/PickerFieldUI.js +1 -0
  149. package/internals/components/PickerPopper/PickerPopper.js +1 -0
  150. package/internals/components/PickerProvider.js +1 -0
  151. package/internals/components/pickersToolbarClasses.d.ts +1 -1
  152. package/internals/demo/DemoContainer.d.ts +2 -3
  153. package/internals/demo/DemoContainer.js +3 -2
  154. package/internals/hooks/date-helpers-hooks.js +16 -16
  155. package/internals/hooks/useClockReferenceDate.d.ts +2 -2
  156. package/internals/hooks/useClockReferenceDate.js +5 -5
  157. package/internals/hooks/useControlledValue.d.ts +2 -2
  158. package/internals/hooks/useControlledValue.js +7 -7
  159. package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
  160. package/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
  161. package/internals/hooks/useField/useField.types.d.ts +4 -4
  162. package/internals/hooks/useField/useField.utils.d.ts +10 -10
  163. package/internals/hooks/useField/useField.utils.js +69 -69
  164. package/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
  165. package/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
  166. package/internals/hooks/useField/useFieldSectionContentProps.js +14 -15
  167. package/internals/hooks/useField/useFieldState.js +24 -25
  168. package/internals/hooks/useField/useFieldV6TextField.js +1 -0
  169. package/internals/hooks/useField/useFieldV7TextField.js +1 -0
  170. package/internals/hooks/useNullableFieldPrivateContext.js +1 -0
  171. package/internals/hooks/usePicker/hooks/useOrientation.js +1 -0
  172. package/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +7 -6
  173. package/internals/hooks/usePicker/usePicker.js +6 -6
  174. package/internals/hooks/usePicker/usePicker.types.d.ts +3 -3
  175. package/internals/hooks/useUtils.d.ts +1 -8
  176. package/internals/hooks/useUtils.js +5 -24
  177. package/internals/hooks/useViews.js +1 -0
  178. package/internals/index.d.ts +2 -1
  179. package/internals/index.js +2 -7
  180. package/internals/models/manager.d.ts +17 -17
  181. package/internals/models/props/time.d.ts +1 -1
  182. package/internals/utils/date-time-utils.d.ts +1 -1
  183. package/internals/utils/date-time-utils.js +5 -5
  184. package/internals/utils/date-utils.d.ts +11 -11
  185. package/internals/utils/date-utils.js +34 -34
  186. package/internals/utils/getDefaultReferenceDate.d.ts +2 -2
  187. package/internals/utils/getDefaultReferenceDate.js +16 -16
  188. package/internals/utils/time-utils.d.ts +5 -5
  189. package/internals/utils/time-utils.js +12 -12
  190. package/internals/utils/valueManagers.js +4 -4
  191. package/managers/useDateManager.js +12 -12
  192. package/managers/useDateTimeManager.js +13 -13
  193. package/managers/useTimeManager.js +10 -11
  194. package/package.json +2 -2
  195. package/validation/useValidation.d.ts +2 -3
  196. package/validation/useValidation.js +2 -2
  197. package/validation/validateDate.js +6 -6
  198. package/validation/validateTime.js +6 -6
@@ -8,16 +8,16 @@ exports.buildSectionsFromFormat = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _useField = require("./useField.utils");
10
10
  const expandFormat = ({
11
- utils,
11
+ adapter,
12
12
  format
13
13
  }) => {
14
14
  // Expand the provided format
15
15
  let formatExpansionOverflow = 10;
16
16
  let prevFormat = format;
17
- let nextFormat = utils.expandFormat(format);
17
+ let nextFormat = adapter.expandFormat(format);
18
18
  while (nextFormat !== prevFormat) {
19
19
  prevFormat = nextFormat;
20
- nextFormat = utils.expandFormat(prevFormat);
20
+ nextFormat = adapter.expandFormat(prevFormat);
21
21
  formatExpansionOverflow -= 1;
22
22
  if (formatExpansionOverflow < 0) {
23
23
  throw new Error('MUI X: The format expansion seems to be in an infinite loop. Please open an issue with the format passed to the component.');
@@ -26,14 +26,14 @@ const expandFormat = ({
26
26
  return nextFormat;
27
27
  };
28
28
  const getEscapedPartsFromFormat = ({
29
- utils,
29
+ adapter,
30
30
  expandedFormat
31
31
  }) => {
32
32
  const escapedParts = [];
33
33
  const {
34
34
  start: startChar,
35
35
  end: endChar
36
- } = utils.escapedCharacters;
36
+ } = adapter.escapedCharacters;
37
37
  const regExp = new RegExp(`(\\${startChar}[^\\${endChar}]*\\${endChar})+`, 'g');
38
38
  let match = null;
39
39
  // eslint-disable-next-line no-cond-assign
@@ -45,12 +45,12 @@ const getEscapedPartsFromFormat = ({
45
45
  }
46
46
  return escapedParts;
47
47
  };
48
- const getSectionPlaceholder = (utils, localeText, sectionConfig, sectionFormat) => {
48
+ const getSectionPlaceholder = (adapter, localeText, sectionConfig, sectionFormat) => {
49
49
  switch (sectionConfig.type) {
50
50
  case 'year':
51
51
  {
52
52
  return localeText.fieldYearPlaceholder({
53
- digitAmount: utils.formatByString(utils.date(undefined, 'default'), sectionFormat).length,
53
+ digitAmount: adapter.formatByString(adapter.date(undefined, 'default'), sectionFormat).length,
54
54
  format: sectionFormat
55
55
  });
56
56
  }
@@ -105,7 +105,7 @@ const getSectionPlaceholder = (utils, localeText, sectionConfig, sectionFormat)
105
105
  }
106
106
  };
107
107
  const createSection = ({
108
- utils,
108
+ adapter,
109
109
  date,
110
110
  shouldRespectLeadingZeros,
111
111
  localeText,
@@ -117,15 +117,15 @@ const createSection = ({
117
117
  if (token === '') {
118
118
  throw new Error('MUI X: Should not call `commitToken` with an empty token');
119
119
  }
120
- const sectionConfig = (0, _useField.getDateSectionConfigFromFormatToken)(utils, token);
121
- const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(utils, sectionConfig.contentType, sectionConfig.type, token);
120
+ const sectionConfig = (0, _useField.getDateSectionConfigFromFormatToken)(adapter, token);
121
+ const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(adapter, sectionConfig.contentType, sectionConfig.type, token);
122
122
  const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
123
- const isValidDate = utils.isValid(date);
124
- let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
123
+ const isValidDate = adapter.isValid(date);
124
+ let sectionValue = isValidDate ? adapter.formatByString(date, token) : '';
125
125
  let maxLength = null;
126
126
  if (hasLeadingZerosInInput) {
127
127
  if (hasLeadingZerosInFormat) {
128
- maxLength = sectionValue === '' ? utils.formatByString(now, token).length : sectionValue.length;
128
+ maxLength = sectionValue === '' ? adapter.formatByString(now, token).length : sectionValue.length;
129
129
  } else {
130
130
  if (sectionConfig.maxLength == null) {
131
131
  throw new Error(`MUI X: The token ${token} should have a 'maxLength' property on it's adapter`);
@@ -140,7 +140,7 @@ const createSection = ({
140
140
  format: token,
141
141
  maxLength,
142
142
  value: sectionValue,
143
- placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
143
+ placeholder: getSectionPlaceholder(adapter, localeText, sectionConfig, token),
144
144
  hasLeadingZerosInFormat,
145
145
  hasLeadingZerosInInput,
146
146
  startSeparator,
@@ -150,16 +150,16 @@ const createSection = ({
150
150
  };
151
151
  const buildSections = parameters => {
152
152
  const {
153
- utils,
153
+ adapter,
154
154
  expandedFormat,
155
155
  escapedParts
156
156
  } = parameters;
157
- const now = utils.date(undefined);
157
+ const now = adapter.date(undefined);
158
158
  const sections = [];
159
159
  let startSeparator = '';
160
160
 
161
161
  // This RegExp tests if the beginning of a string corresponds to a supported token
162
- const validTokens = Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length); // Sort to put longest word first
162
+ const validTokens = Object.keys(adapter.formatTokenMap).sort((a, b) => b.length - a.length); // Sort to put longest word first
163
163
 
164
164
  const regExpFirstWordInFormat = /^([a-zA-Z]+)/;
165
165
  const regExpWordOnlyComposedOfTokens = new RegExp(`^(${validTokens.join('|')})*$`);
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferFieldSection, PickerManager, PickerValueType } from "../../../models/index.js";
3
3
  import { InternalPropNames } from "../../../hooks/useSplitFieldProps.js";
4
4
  import type { PickersSectionElement, PickersSectionListRef } from "../../../PickersSectionList/index.js";
5
- import { FormProps, InferNonNullablePickerValue, PickerValidValue } from "../../models/index.js";
5
+ import { FormProps, InferNonNullablePickerValue, PickerRangeValue, PickerValidValue } from "../../models/index.js";
6
6
  export interface UseFieldParameters<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> {
7
7
  manager: PickerManager<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, any>;
8
8
  props: TProps;
@@ -23,7 +23,7 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
23
23
  * For example, on time fields it will be used to determine the date to set.
24
24
  * @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
25
25
  */
26
- referenceDate?: PickerValidDate;
26
+ referenceDate?: TValue extends PickerRangeValue ? TValue | PickerValidDate : PickerValidDate;
27
27
  /**
28
28
  * Callback fired when the value changes.
29
29
  * @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.
@@ -201,12 +201,12 @@ export interface FieldValueManager<TValue extends PickerValidValue> {
201
201
  * Update the reference value with the new value.
202
202
  * This method must make sure that no date inside the returned `referenceValue` is invalid.
203
203
  * @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.
204
- * @param {MuiPickersAdapter} utils The utils to manipulate the date.
204
+ * @param {MuiPickersAdapter} adapter The adapter to manipulate the date.
205
205
  * @param {TValue} value The new value from which we want to take all valid dates in the `referenceValue` state.
206
206
  * @param {TValue} prevReferenceValue The previous reference value. It is used as a fallback for invalid dates in the new value.
207
207
  * @returns {TValue} The new reference value with no invalid date.
208
208
  */
209
- updateReferenceValue: (utils: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
209
+ updateReferenceValue: (adapter: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
210
210
  /**
211
211
  * Extract from the given value the date that contains the given section.
212
212
  * @param {TValue} value The value to extract the date from.
@@ -1,13 +1,13 @@
1
1
  import { FieldSectionsValueBoundaries, SectionOrdering, FieldSectionValueBoundaries, FieldParsedSelectedSections } from "./useField.types.js";
2
2
  import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType, InferFieldSection } from "../../../models/index.js";
3
3
  import { PickerValidValue } from "../../models/index.js";
4
- export declare const getDateSectionConfigFromFormatToken: (utils: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
4
+ export declare const getDateSectionConfigFromFormatToken: (adapter: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
5
5
  maxLength: number | undefined;
6
6
  };
7
- export declare const getDaysInWeekStr: (utils: MuiPickersAdapter, format: string) => string[];
8
- export declare const getLetterEditingOptions: (utils: MuiPickersAdapter, timezone: PickersTimezone, sectionType: FieldSectionType, format: string) => string[];
7
+ export declare const getDaysInWeekStr: (adapter: MuiPickersAdapter, format: string) => string[];
8
+ export declare const getLetterEditingOptions: (adapter: MuiPickersAdapter, timezone: PickersTimezone, sectionType: FieldSectionType, format: string) => string[];
9
9
  export declare const FORMAT_SECONDS_NO_LEADING_ZEROS = "s";
10
- export declare const getLocalizedDigits: (utils: MuiPickersAdapter) => string[];
10
+ export declare const getLocalizedDigits: (adapter: MuiPickersAdapter) => string[];
11
11
  export declare const removeLocalizedDigits: (valueStr: string, localizedDigits: string[]) => string;
12
12
  export declare const applyLocalizedDigits: (valueStr: string, localizedDigits: string[]) => string;
13
13
  export declare const isStringNumber: (valueStr: string, localizedDigits: string[]) => boolean;
@@ -17,20 +17,20 @@ export declare const isStringNumber: (valueStr: string, localizedDigits: string[
17
17
  * Warning: Should only be called with non-localized digits. Call `removeLocalizedDigits` with your value if needed.
18
18
  */
19
19
  export declare const cleanLeadingZeros: (valueStr: string, size: number) => string;
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 cleanDigitSectionValue: (adapter: MuiPickersAdapter, value: number, sectionBoundaries: FieldSectionValueBoundaries<any>, localizedDigits: string[], section: Pick<FieldSection, "format" | "type" | "contentType" | "hasLeadingZerosInFormat" | "hasLeadingZerosInInput" | "maxLength">) => string;
21
21
  export declare const getSectionVisibleValue: (section: FieldSection, target: "input-rtl" | "input-ltr" | "non-input", localizedDigits: string[]) => string;
22
- export declare const changeSectionValueFormat: (utils: MuiPickersAdapter, valueStr: string, currentFormat: string, newFormat: string) => string;
23
- export declare const doesSectionFormatHaveLeadingZeros: (utils: MuiPickersAdapter, contentType: FieldSectionContentType, sectionType: FieldSectionType, format: string) => boolean;
22
+ export declare const changeSectionValueFormat: (adapter: MuiPickersAdapter, valueStr: string, currentFormat: string, newFormat: string) => string;
23
+ export declare const doesSectionFormatHaveLeadingZeros: (adapter: MuiPickersAdapter, contentType: FieldSectionContentType, sectionType: FieldSectionType, format: string) => boolean;
24
24
  /**
25
25
  * Some date libraries like `dayjs` don't support parsing from date with escaped characters.
26
26
  * To make sure that the parsing works, we are building a format and a date without any separator.
27
27
  */
28
- export declare const getDateFromDateSections: (utils: MuiPickersAdapter, sections: FieldSection[], localizedDigits: string[]) => PickerValidDate;
28
+ export declare const getDateFromDateSections: (adapter: MuiPickersAdapter, sections: FieldSection[], localizedDigits: string[]) => PickerValidDate;
29
29
  export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
30
30
  export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
31
- export declare const getSectionsBoundaries: (utils: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
31
+ export declare const getSectionsBoundaries: (adapter: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
32
32
  export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
33
- export declare const mergeDateIntoReferenceDate: (utils: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
33
+ export declare const mergeDateIntoReferenceDate: (adapter: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
34
34
  export declare const isAndroid: () => boolean;
35
35
  export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
36
36
  export declare const parseSelectedSections: (selectedSections: FieldSelectedSections, sections: FieldSection[]) => FieldParsedSelectedSections;
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.validateSections = exports.removeLocalizedDigits = exports.parseSelectedSections = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForV7HiddenInputFromSections = exports.createDateStrForV6InputFromSections = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
7
7
  var _dateUtils = require("../../utils/date-utils");
8
- const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
9
- const config = utils.formatTokenMap[formatToken];
8
+ const getDateSectionConfigFromFormatToken = (adapter, formatToken) => {
9
+ const config = adapter.formatTokenMap[formatToken];
10
10
  if (config == null) {
11
11
  throw new Error([`MUI X: The token "${formatToken}" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
12
12
  }
@@ -24,33 +24,33 @@ const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
24
24
  };
25
25
  };
26
26
  exports.getDateSectionConfigFromFormatToken = getDateSectionConfigFromFormatToken;
27
- const getDaysInWeekStr = (utils, format) => {
27
+ const getDaysInWeekStr = (adapter, format) => {
28
28
  const elements = [];
29
- const now = utils.date(undefined, 'default');
30
- const startDate = utils.startOfWeek(now);
31
- const endDate = utils.endOfWeek(now);
29
+ const now = adapter.date(undefined, 'default');
30
+ const startDate = adapter.startOfWeek(now);
31
+ const endDate = adapter.endOfWeek(now);
32
32
  let current = startDate;
33
- while (utils.isBefore(current, endDate)) {
33
+ while (adapter.isBefore(current, endDate)) {
34
34
  elements.push(current);
35
- current = utils.addDays(current, 1);
35
+ current = adapter.addDays(current, 1);
36
36
  }
37
- return elements.map(weekDay => utils.formatByString(weekDay, format));
37
+ return elements.map(weekDay => adapter.formatByString(weekDay, format));
38
38
  };
39
39
  exports.getDaysInWeekStr = getDaysInWeekStr;
40
- const getLetterEditingOptions = (utils, timezone, sectionType, format) => {
40
+ const getLetterEditingOptions = (adapter, timezone, sectionType, format) => {
41
41
  switch (sectionType) {
42
42
  case 'month':
43
43
  {
44
- return (0, _dateUtils.getMonthsInYear)(utils, utils.date(undefined, timezone)).map(month => utils.formatByString(month, format));
44
+ return (0, _dateUtils.getMonthsInYear)(adapter, adapter.date(undefined, timezone)).map(month => adapter.formatByString(month, format));
45
45
  }
46
46
  case 'weekDay':
47
47
  {
48
- return getDaysInWeekStr(utils, format);
48
+ return getDaysInWeekStr(adapter, format);
49
49
  }
50
50
  case 'meridiem':
51
51
  {
52
- const now = utils.date(undefined, timezone);
53
- return [utils.startOfDay(now), utils.endOfDay(now)].map(date => utils.formatByString(date, format));
52
+ const now = adapter.date(undefined, timezone);
53
+ return [adapter.startOfDay(now), adapter.endOfDay(now)].map(date => adapter.formatByString(date, format));
54
54
  }
55
55
  default:
56
56
  {
@@ -64,15 +64,15 @@ const getLetterEditingOptions = (utils, timezone, sectionType, format) => {
64
64
  exports.getLetterEditingOptions = getLetterEditingOptions;
65
65
  const FORMAT_SECONDS_NO_LEADING_ZEROS = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = 's';
66
66
  const NON_LOCALIZED_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
67
- const getLocalizedDigits = utils => {
68
- const today = utils.date(undefined);
69
- const formattedZero = utils.formatByString(utils.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);
67
+ const getLocalizedDigits = adapter => {
68
+ const today = adapter.date(undefined);
69
+ const formattedZero = adapter.formatByString(adapter.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);
70
70
  if (formattedZero === '0') {
71
71
  return NON_LOCALIZED_DIGITS;
72
72
  }
73
73
  return Array.from({
74
74
  length: 10
75
- }).map((_, index) => utils.formatByString(utils.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));
75
+ }).map((_, index) => adapter.formatByString(adapter.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));
76
76
  };
77
77
  exports.getLocalizedDigits = getLocalizedDigits;
78
78
  const removeLocalizedDigits = (valueStr, localizedDigits) => {
@@ -116,7 +116,7 @@ const cleanLeadingZeros = (valueStr, size) => {
116
116
  return Number(valueStr).toString().padStart(size, '0');
117
117
  };
118
118
  exports.cleanLeadingZeros = cleanLeadingZeros;
119
- const cleanDigitSectionValue = (utils, value, sectionBoundaries, localizedDigits, section) => {
119
+ const cleanDigitSectionValue = (adapter, value, sectionBoundaries, localizedDigits, section) => {
120
120
  if (process.env.NODE_ENV !== 'production') {
121
121
  if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
122
122
  throw new Error([`MUI X: The token "${section.format}" is a digit format with letter in it.'
@@ -124,8 +124,8 @@ const cleanDigitSectionValue = (utils, value, sectionBoundaries, localizedDigits
124
124
  }
125
125
  }
126
126
  if (section.type === 'day' && section.contentType === 'digit-with-letter') {
127
- const date = utils.setDate(sectionBoundaries.longestMonth, value);
128
- return utils.formatByString(date, section.format);
127
+ const date = adapter.setDate(sectionBoundaries.longestMonth, value);
128
+ return adapter.formatByString(date, section.format);
129
129
  }
130
130
 
131
131
  // queryValue without leading `0` (`01` => `1`)
@@ -158,54 +158,54 @@ const getSectionVisibleValue = (section, target, localizedDigits) => {
158
158
  return value;
159
159
  };
160
160
  exports.getSectionVisibleValue = getSectionVisibleValue;
161
- const changeSectionValueFormat = (utils, valueStr, currentFormat, newFormat) => {
161
+ const changeSectionValueFormat = (adapter, valueStr, currentFormat, newFormat) => {
162
162
  if (process.env.NODE_ENV !== 'production') {
163
- if (getDateSectionConfigFromFormatToken(utils, currentFormat).type === 'weekDay') {
163
+ if (getDateSectionConfigFromFormatToken(adapter, currentFormat).type === 'weekDay') {
164
164
  throw new Error("changeSectionValueFormat doesn't support week day formats");
165
165
  }
166
166
  }
167
- return utils.formatByString(utils.parse(valueStr, currentFormat), newFormat);
167
+ return adapter.formatByString(adapter.parse(valueStr, currentFormat), newFormat);
168
168
  };
169
169
  exports.changeSectionValueFormat = changeSectionValueFormat;
170
- const isFourDigitYearFormat = (utils, format) => utils.formatByString(utils.date(undefined, 'system'), format).length === 4;
171
- const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, format) => {
170
+ const isFourDigitYearFormat = (adapter, format) => adapter.formatByString(adapter.date(undefined, 'system'), format).length === 4;
171
+ const doesSectionFormatHaveLeadingZeros = (adapter, contentType, sectionType, format) => {
172
172
  if (contentType !== 'digit') {
173
173
  return false;
174
174
  }
175
- const now = utils.date(undefined, 'default');
175
+ const now = adapter.date(undefined, 'default');
176
176
  switch (sectionType) {
177
- // We can't use `changeSectionValueFormat`, because `utils.parse('1', 'YYYY')` returns `1971` instead of `1`.
177
+ // We can't use `changeSectionValueFormat`, because `adapter.parse('1', 'YYYY')` returns `1971` instead of `1`.
178
178
  case 'year':
179
179
  {
180
180
  // Remove once https://github.com/iamkun/dayjs/pull/2847 is merged and bump dayjs version
181
- if (utils.lib === 'dayjs' && format === 'YY') {
181
+ if (adapter.lib === 'dayjs' && format === 'YY') {
182
182
  return true;
183
183
  }
184
- return utils.formatByString(utils.setYear(now, 1), format).startsWith('0');
184
+ return adapter.formatByString(adapter.setYear(now, 1), format).startsWith('0');
185
185
  }
186
186
  case 'month':
187
187
  {
188
- return utils.formatByString(utils.startOfYear(now), format).length > 1;
188
+ return adapter.formatByString(adapter.startOfYear(now), format).length > 1;
189
189
  }
190
190
  case 'day':
191
191
  {
192
- return utils.formatByString(utils.startOfMonth(now), format).length > 1;
192
+ return adapter.formatByString(adapter.startOfMonth(now), format).length > 1;
193
193
  }
194
194
  case 'weekDay':
195
195
  {
196
- return utils.formatByString(utils.startOfWeek(now), format).length > 1;
196
+ return adapter.formatByString(adapter.startOfWeek(now), format).length > 1;
197
197
  }
198
198
  case 'hours':
199
199
  {
200
- return utils.formatByString(utils.setHours(now, 1), format).length > 1;
200
+ return adapter.formatByString(adapter.setHours(now, 1), format).length > 1;
201
201
  }
202
202
  case 'minutes':
203
203
  {
204
- return utils.formatByString(utils.setMinutes(now, 1), format).length > 1;
204
+ return adapter.formatByString(adapter.setMinutes(now, 1), format).length > 1;
205
205
  }
206
206
  case 'seconds':
207
207
  {
208
- return utils.formatByString(utils.setSeconds(now, 1), format).length > 1;
208
+ return adapter.formatByString(adapter.setSeconds(now, 1), format).length > 1;
209
209
  }
210
210
  default:
211
211
  {
@@ -219,7 +219,7 @@ const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, form
219
219
  * To make sure that the parsing works, we are building a format and a date without any separator.
220
220
  */
221
221
  exports.doesSectionFormatHaveLeadingZeros = doesSectionFormatHaveLeadingZeros;
222
- const getDateFromDateSections = (utils, sections, localizedDigits) => {
222
+ const getDateFromDateSections = (adapter, sections, localizedDigits) => {
223
223
  // If we have both a day and a weekDay section,
224
224
  // Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.
225
225
  // dayjs(dayjs().format('dddd MMMM D YYYY'), 'dddd MMMM D YYYY')) // returns `Invalid Date` even if the format is valid.
@@ -236,7 +236,7 @@ const getDateFromDateSections = (utils, sections, localizedDigits) => {
236
236
  }
237
237
  const formatWithoutSeparator = sectionFormats.join(' ');
238
238
  const dateWithoutSeparatorStr = sectionValues.join(' ');
239
- return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
239
+ return adapter.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
240
240
  };
241
241
  exports.getDateFromDateSections = getDateFromDateSections;
242
242
  const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {
@@ -261,15 +261,15 @@ const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) =
261
261
  return `\u2066${dateStr}\u2069`;
262
262
  };
263
263
  exports.createDateStrForV6InputFromSections = createDateStrForV6InputFromSections;
264
- const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
265
- const today = utils.date(undefined, timezone);
266
- const endOfYear = utils.endOfYear(today);
267
- const endOfDay = utils.endOfDay(today);
264
+ const getSectionsBoundaries = (adapter, localizedDigits, timezone) => {
265
+ const today = adapter.date(undefined, timezone);
266
+ const endOfYear = adapter.endOfYear(today);
267
+ const endOfDay = adapter.endOfDay(today);
268
268
  const {
269
269
  maxDaysInMonth,
270
270
  longestMonth
271
- } = (0, _dateUtils.getMonthsInYear)(utils, today).reduce((acc, month) => {
272
- const daysInMonth = utils.getDaysInMonth(month);
271
+ } = (0, _dateUtils.getMonthsInYear)(adapter, today).reduce((acc, month) => {
272
+ const daysInMonth = adapter.getDaysInMonth(month);
273
273
  if (daysInMonth > acc.maxDaysInMonth) {
274
274
  return {
275
275
  maxDaysInMonth: daysInMonth,
@@ -286,18 +286,18 @@ const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
286
286
  format
287
287
  }) => ({
288
288
  minimum: 0,
289
- maximum: isFourDigitYearFormat(utils, format) ? 9999 : 99
289
+ maximum: isFourDigitYearFormat(adapter, format) ? 9999 : 99
290
290
  }),
291
291
  month: () => ({
292
292
  minimum: 1,
293
293
  // Assumption: All years have the same amount of months
294
- maximum: utils.getMonth(endOfYear) + 1
294
+ maximum: adapter.getMonth(endOfYear) + 1
295
295
  }),
296
296
  day: ({
297
297
  currentDate
298
298
  }) => ({
299
299
  minimum: 1,
300
- maximum: utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,
300
+ maximum: adapter.isValid(currentDate) ? adapter.getDaysInMonth(currentDate) : maxDaysInMonth,
301
301
  longestMonth: longestMonth
302
302
  }),
303
303
  weekDay: ({
@@ -305,7 +305,7 @@ const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
305
305
  contentType
306
306
  }) => {
307
307
  if (contentType === 'digit') {
308
- const daysInWeek = getDaysInWeekStr(utils, format).map(Number);
308
+ const daysInWeek = getDaysInWeekStr(adapter, format).map(Number);
309
309
  return {
310
310
  minimum: Math.min(...daysInWeek),
311
311
  maximum: Math.max(...daysInWeek)
@@ -319,12 +319,12 @@ const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
319
319
  hours: ({
320
320
  format
321
321
  }) => {
322
- const lastHourInDay = utils.getHours(endOfDay);
323
- const hasMeridiem = removeLocalizedDigits(utils.formatByString(utils.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();
322
+ const lastHourInDay = adapter.getHours(endOfDay);
323
+ const hasMeridiem = removeLocalizedDigits(adapter.formatByString(adapter.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();
324
324
  if (hasMeridiem) {
325
325
  return {
326
326
  minimum: 1,
327
- maximum: Number(removeLocalizedDigits(utils.formatByString(utils.startOfDay(today), format), localizedDigits))
327
+ maximum: Number(removeLocalizedDigits(adapter.formatByString(adapter.startOfDay(today), format), localizedDigits))
328
328
  };
329
329
  }
330
330
  return {
@@ -335,12 +335,12 @@ const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
335
335
  minutes: () => ({
336
336
  minimum: 0,
337
337
  // Assumption: All years have the same amount of minutes
338
- maximum: utils.getMinutes(endOfDay)
338
+ maximum: adapter.getMinutes(endOfDay)
339
339
  }),
340
340
  seconds: () => ({
341
341
  minimum: 0,
342
342
  // Assumption: All years have the same amount of seconds
343
- maximum: utils.getSeconds(endOfDay)
343
+ maximum: adapter.getSeconds(endOfDay)
344
344
  }),
345
345
  meridiem: () => ({
346
346
  minimum: 0,
@@ -373,55 +373,55 @@ const validateSections = (sections, valueType) => {
373
373
  }
374
374
  };
375
375
  exports.validateSections = validateSections;
376
- const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTransferTo) => {
376
+ const transferDateSectionValue = (adapter, section, dateToTransferFrom, dateToTransferTo) => {
377
377
  switch (section.type) {
378
378
  case 'year':
379
379
  {
380
- return utils.setYear(dateToTransferTo, utils.getYear(dateToTransferFrom));
380
+ return adapter.setYear(dateToTransferTo, adapter.getYear(dateToTransferFrom));
381
381
  }
382
382
  case 'month':
383
383
  {
384
- return utils.setMonth(dateToTransferTo, utils.getMonth(dateToTransferFrom));
384
+ return adapter.setMonth(dateToTransferTo, adapter.getMonth(dateToTransferFrom));
385
385
  }
386
386
  case 'weekDay':
387
387
  {
388
- let dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
388
+ let dayInWeekStrOfActiveDate = adapter.formatByString(dateToTransferFrom, section.format);
389
389
  if (section.hasLeadingZerosInInput) {
390
390
  dayInWeekStrOfActiveDate = cleanLeadingZeros(dayInWeekStrOfActiveDate, section.maxLength);
391
391
  }
392
- const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);
392
+ const formattedDaysInWeek = getDaysInWeekStr(adapter, section.format);
393
393
  const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
394
394
  const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
395
395
  const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
396
- return utils.addDays(dateToTransferFrom, diff);
396
+ return adapter.addDays(dateToTransferFrom, diff);
397
397
  }
398
398
  case 'day':
399
399
  {
400
- return utils.setDate(dateToTransferTo, utils.getDate(dateToTransferFrom));
400
+ return adapter.setDate(dateToTransferTo, adapter.getDate(dateToTransferFrom));
401
401
  }
402
402
  case 'meridiem':
403
403
  {
404
- const isAM = utils.getHours(dateToTransferFrom) < 12;
405
- const mergedDateHours = utils.getHours(dateToTransferTo);
404
+ const isAM = adapter.getHours(dateToTransferFrom) < 12;
405
+ const mergedDateHours = adapter.getHours(dateToTransferTo);
406
406
  if (isAM && mergedDateHours >= 12) {
407
- return utils.addHours(dateToTransferTo, -12);
407
+ return adapter.addHours(dateToTransferTo, -12);
408
408
  }
409
409
  if (!isAM && mergedDateHours < 12) {
410
- return utils.addHours(dateToTransferTo, 12);
410
+ return adapter.addHours(dateToTransferTo, 12);
411
411
  }
412
412
  return dateToTransferTo;
413
413
  }
414
414
  case 'hours':
415
415
  {
416
- return utils.setHours(dateToTransferTo, utils.getHours(dateToTransferFrom));
416
+ return adapter.setHours(dateToTransferTo, adapter.getHours(dateToTransferFrom));
417
417
  }
418
418
  case 'minutes':
419
419
  {
420
- return utils.setMinutes(dateToTransferTo, utils.getMinutes(dateToTransferFrom));
420
+ return adapter.setMinutes(dateToTransferTo, adapter.getMinutes(dateToTransferFrom));
421
421
  }
422
422
  case 'seconds':
423
423
  {
424
- return utils.setSeconds(dateToTransferTo, utils.getSeconds(dateToTransferFrom));
424
+ return adapter.setSeconds(dateToTransferTo, adapter.getSeconds(dateToTransferFrom));
425
425
  }
426
426
  default:
427
427
  {
@@ -440,11 +440,11 @@ const reliableSectionModificationOrder = {
440
440
  meridiem: 8,
441
441
  empty: 9
442
442
  };
443
- const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
443
+ const mergeDateIntoReferenceDate = (adapter, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
444
444
  // cloning sections before sort to avoid mutating it
445
445
  [...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {
446
446
  if (!shouldLimitToEditedSections || section.modified) {
447
- return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);
447
+ return transferDateSectionValue(adapter, section, dateToTransferFrom, mergedDate);
448
448
  }
449
449
  return mergedDate;
450
450
  }, referenceDate);
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.useFieldCharacterEditing = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
10
- var _useUtils = require("../useUtils");
11
10
  var _useField = require("./useField.utils");
11
+ var _usePickerAdapter = require("../../../hooks/usePickerAdapter");
12
12
  const isQueryResponseWithoutValue = response => response.saveQuery != null;
13
13
 
14
14
  /**
@@ -31,7 +31,7 @@ const useFieldCharacterEditing = ({
31
31
  updateSectionValue
32
32
  }
33
33
  }) => {
34
- const utils = (0, _useUtils.useUtils)();
34
+ const adapter = (0, _usePickerAdapter.usePickerAdapter)();
35
35
  const applyQuery = ({
36
36
  keyPressed,
37
37
  sectionIndex
@@ -82,7 +82,7 @@ const useFieldCharacterEditing = ({
82
82
  };
83
83
  };
84
84
  const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {
85
- const getOptions = format => (0, _useField.getLetterEditingOptions)(utils, timezone, activeSection.type, format);
85
+ const getOptions = format => (0, _useField.getLetterEditingOptions)(adapter, timezone, activeSection.type, format);
86
86
  if (activeSection.contentType === 'letter') {
87
87
  return findMatchingOptions(activeSection.format, getOptions(activeSection.format), queryValue);
88
88
  }
@@ -90,7 +90,7 @@ const useFieldCharacterEditing = ({
90
90
  // When editing a digit-format month / weekDay and the user presses a letter,
91
91
  // We can support the letter editing by using the letter-format month / weekDay and re-formatting the result.
92
92
  // We just have to make sure that the default month / weekDay format is a letter format,
93
- if (fallbackFormat && formatFallbackValue != null && (0, _useField.getDateSectionConfigFromFormatToken)(utils, fallbackFormat).contentType === 'letter') {
93
+ if (fallbackFormat && formatFallbackValue != null && (0, _useField.getDateSectionConfigFromFormatToken)(adapter, fallbackFormat).contentType === 'letter') {
94
94
  const fallbackOptions = getOptions(fallbackFormat);
95
95
  const response = findMatchingOptions(fallbackFormat, fallbackOptions, queryValue);
96
96
  if (isQueryResponseWithoutValue(response)) {
@@ -110,13 +110,13 @@ const useFieldCharacterEditing = ({
110
110
  switch (activeSection.type) {
111
111
  case 'month':
112
112
  {
113
- const formatFallbackValue = fallbackValue => (0, _useField.changeSectionValueFormat)(utils, fallbackValue, utils.formats.month, activeSection.format);
114
- return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.month, formatFallbackValue);
113
+ const formatFallbackValue = fallbackValue => (0, _useField.changeSectionValueFormat)(adapter, fallbackValue, adapter.formats.month, activeSection.format);
114
+ return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, adapter.formats.month, formatFallbackValue);
115
115
  }
116
116
  case 'weekDay':
117
117
  {
118
118
  const formatFallbackValue = (fallbackValue, fallbackOptions) => fallbackOptions.indexOf(fallbackValue).toString();
119
- return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.weekday, formatFallbackValue);
119
+ return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, adapter.formats.weekday, formatFallbackValue);
120
120
  }
121
121
  case 'meridiem':
122
122
  {
@@ -160,7 +160,7 @@ const useFieldCharacterEditing = ({
160
160
  };
161
161
  }
162
162
  const shouldGoToNextSection = queryValueNumber * 10 > sectionBoundaries.maximum || cleanQueryValue.length === sectionBoundaries.maximum.toString().length;
163
- const newSectionValue = (0, _useField.cleanDigitSectionValue)(utils, queryValueNumber, sectionBoundaries, localizedDigits, section);
163
+ const newSectionValue = (0, _useField.cleanDigitSectionValue)(adapter, queryValueNumber, sectionBoundaries, localizedDigits, section);
164
164
  return {
165
165
  sectionValue: newSectionValue,
166
166
  shouldGoToNextSection
@@ -178,7 +178,7 @@ const useFieldCharacterEditing = ({
178
178
  // When editing a letter-format month and the user presses a digit,
179
179
  // We can support the numeric editing by using the digit-format month and re-formatting the result.
180
180
  if (activeSection.type === 'month') {
181
- const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(utils, 'digit', 'month', 'MM');
181
+ const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(adapter, 'digit', 'month', 'MM');
182
182
  const response = getNewSectionValue({
183
183
  queryValue,
184
184
  skipIfBelowMinimum: true,
@@ -194,7 +194,7 @@ const useFieldCharacterEditing = ({
194
194
  if (isQueryResponseWithoutValue(response)) {
195
195
  return response;
196
196
  }
197
- const formattedValue = (0, _useField.changeSectionValueFormat)(utils, response.sectionValue, 'MM', activeSection.format);
197
+ const formattedValue = (0, _useField.changeSectionValueFormat)(adapter, response.sectionValue, 'MM', activeSection.format);
198
198
  return (0, _extends2.default)({}, response, {
199
199
  sectionValue: formattedValue
200
200
  });
@@ -211,7 +211,7 @@ const useFieldCharacterEditing = ({
211
211
  if (isQueryResponseWithoutValue(response)) {
212
212
  return response;
213
213
  }
214
- const formattedValue = (0, _useField.getDaysInWeekStr)(utils, activeSection.format)[Number(response.sectionValue) - 1];
214
+ const formattedValue = (0, _useField.getDaysInWeekStr)(adapter, activeSection.format)[Number(response.sectionValue) - 1];
215
215
  return (0, _extends2.default)({}, response, {
216
216
  sectionValue: formattedValue
217
217
  });