@mui/x-date-pickers 8.5.3 → 8.6.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.
- package/CHANGELOG.md +107 -0
- package/DateCalendar/DateCalendar.js +16 -16
- package/DateCalendar/DayCalendar.js +48 -48
- package/DateCalendar/useCalendarState.js +25 -25
- package/DateCalendar/useIsDateDisabled.js +2 -2
- package/DatePicker/DatePickerToolbar.js +7 -9
- package/DateTimeField/DateTimeField.js +1 -1
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +12 -13
- package/DateTimePicker/shared.js +3 -3
- package/DesktopDatePicker/DesktopDatePicker.js +3 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
- package/DesktopTimePicker/DesktopTimePicker.js +4 -4
- package/DigitalClock/DigitalClock.d.ts +1 -1
- package/DigitalClock/DigitalClock.js +16 -16
- package/LocalizationProvider/LocalizationProvider.d.ts +9 -3
- package/LocalizationProvider/LocalizationProvider.js +28 -19
- package/MobileDatePicker/MobileDatePicker.js +3 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
- package/MobileTimePicker/MobileTimePicker.js +4 -4
- package/MonthCalendar/MonthCalendar.js +19 -18
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
- package/PickerDay2/PickerDay2.js +3 -3
- package/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/PickersActionBar/PickersActionBar.js +2 -2
- package/PickersCalendarHeader/PickersCalendarHeader.js +7 -8
- package/PickersDay/PickersDay.js +3 -3
- package/PickersDay/usePickerDayOwnerState.js +5 -5
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/StaticTimePicker/StaticTimePicker.js +1 -1
- package/TimeClock/Clock.js +8 -9
- package/TimeClock/ClockNumbers.d.ts +3 -3
- package/TimeClock/ClockNumbers.js +5 -5
- package/TimeClock/TimeClock.js +29 -29
- package/TimeField/TimeField.js +1 -1
- package/TimePicker/TimePicker.js +1 -1
- package/TimePicker/TimePickerToolbar.js +7 -9
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +19 -18
- package/esm/DateCalendar/DateCalendar.js +16 -16
- package/esm/DateCalendar/DayCalendar.js +48 -48
- package/esm/DateCalendar/useCalendarState.js +25 -25
- package/esm/DateCalendar/useIsDateDisabled.js +2 -2
- package/esm/DatePicker/DatePickerToolbar.js +6 -8
- package/esm/DateTimeField/DateTimeField.js +1 -1
- package/esm/DateTimePicker/DateTimePicker.js +1 -1
- package/esm/DateTimePicker/DateTimePickerToolbar.js +11 -12
- package/esm/DateTimePicker/shared.js +3 -3
- package/esm/DesktopDatePicker/DesktopDatePicker.js +3 -3
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -4
- package/esm/DesktopTimePicker/DesktopTimePicker.js +4 -4
- package/esm/DigitalClock/DigitalClock.d.ts +1 -1
- package/esm/DigitalClock/DigitalClock.js +16 -16
- package/esm/LocalizationProvider/LocalizationProvider.d.ts +9 -3
- package/esm/LocalizationProvider/LocalizationProvider.js +27 -18
- package/esm/MobileDatePicker/MobileDatePicker.js +3 -3
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +4 -4
- package/esm/MobileTimePicker/MobileTimePicker.js +4 -4
- package/esm/MonthCalendar/MonthCalendar.js +20 -19
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +32 -32
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +4 -4
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +7 -7
- package/esm/PickerDay2/PickerDay2.js +3 -3
- package/esm/PickersActionBar/PickersActionBar.d.ts +2 -2
- package/esm/PickersActionBar/PickersActionBar.js +2 -2
- package/esm/PickersCalendarHeader/PickersCalendarHeader.js +6 -7
- package/esm/PickersDay/PickersDay.js +3 -3
- package/esm/PickersDay/usePickerDayOwnerState.js +5 -5
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/esm/StaticTimePicker/StaticTimePicker.js +1 -1
- package/esm/TimeClock/Clock.js +7 -8
- package/esm/TimeClock/ClockNumbers.d.ts +3 -3
- package/esm/TimeClock/ClockNumbers.js +5 -5
- package/esm/TimeClock/TimeClock.js +29 -29
- package/esm/TimeField/TimeField.js +1 -1
- package/esm/TimePicker/TimePicker.js +1 -1
- package/esm/TimePicker/TimePickerToolbar.js +6 -8
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +20 -19
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useParsedFormat.js +6 -6
- package/esm/hooks/usePickerAdapter.d.ts +7 -0
- package/esm/hooks/usePickerAdapter.js +20 -0
- package/esm/hooks/usePickerTranslations.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/pickersToolbarClasses.d.ts +1 -1
- package/esm/internals/demo/DemoContainer.d.ts +2 -3
- package/esm/internals/demo/DemoContainer.js +3 -2
- package/esm/internals/hooks/date-helpers-hooks.js +16 -16
- package/esm/internals/hooks/useClockReferenceDate.d.ts +2 -2
- package/esm/internals/hooks/useClockReferenceDate.js +3 -3
- package/esm/internals/hooks/useControlledValue.js +8 -7
- package/esm/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/esm/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
- package/esm/internals/hooks/useField/useField.types.d.ts +2 -2
- package/esm/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/esm/internals/hooks/useField/useField.utils.js +69 -69
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +15 -16
- package/esm/internals/hooks/useField/useFieldState.js +22 -24
- package/esm/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
- package/esm/internals/hooks/usePicker/usePicker.js +5 -6
- package/esm/internals/hooks/useUtils.d.ts +1 -8
- package/esm/internals/hooks/useUtils.js +3 -19
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/models/manager.d.ts +14 -14
- package/esm/internals/models/props/time.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.d.ts +1 -1
- package/esm/internals/utils/date-time-utils.js +5 -5
- package/esm/internals/utils/date-utils.d.ts +11 -11
- package/esm/internals/utils/date-utils.js +34 -34
- package/esm/internals/utils/getDefaultReferenceDate.d.ts +2 -2
- package/esm/internals/utils/getDefaultReferenceDate.js +16 -16
- package/esm/internals/utils/time-utils.d.ts +5 -5
- package/esm/internals/utils/time-utils.js +12 -12
- package/esm/internals/utils/valueManagers.js +4 -4
- package/esm/managers/useDateManager.js +12 -12
- package/esm/managers/useDateTimeManager.js +13 -13
- package/esm/managers/useTimeManager.js +9 -10
- package/esm/validation/useValidation.d.ts +2 -3
- package/esm/validation/useValidation.js +2 -2
- package/esm/validation/validateDate.js +6 -6
- package/esm/validation/validateTime.js +6 -6
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +8 -1
- package/hooks/useParsedFormat.js +6 -6
- package/hooks/usePickerAdapter.d.ts +7 -0
- package/hooks/usePickerAdapter.js +29 -0
- package/hooks/usePickerTranslations.js +2 -2
- package/index.js +1 -1
- package/internals/components/pickersToolbarClasses.d.ts +1 -1
- package/internals/demo/DemoContainer.d.ts +2 -3
- package/internals/demo/DemoContainer.js +3 -2
- package/internals/hooks/date-helpers-hooks.js +16 -16
- package/internals/hooks/useClockReferenceDate.d.ts +2 -2
- package/internals/hooks/useClockReferenceDate.js +3 -3
- package/internals/hooks/useControlledValue.js +7 -7
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.js +17 -17
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.d.ts +10 -10
- package/internals/hooks/useField/useField.utils.js +69 -69
- package/internals/hooks/useField/useFieldCharacterEditing.js +11 -11
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +7 -7
- package/internals/hooks/useField/useFieldSectionContentProps.js +14 -15
- package/internals/hooks/useField/useFieldState.js +23 -25
- package/internals/hooks/usePicker/hooks/useValueAndOpenStates.js +6 -6
- package/internals/hooks/usePicker/usePicker.js +5 -6
- package/internals/hooks/useUtils.d.ts +1 -8
- package/internals/hooks/useUtils.js +5 -24
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -7
- package/internals/models/manager.d.ts +14 -14
- package/internals/models/props/time.d.ts +1 -1
- package/internals/utils/date-time-utils.d.ts +1 -1
- package/internals/utils/date-time-utils.js +5 -5
- package/internals/utils/date-utils.d.ts +11 -11
- package/internals/utils/date-utils.js +34 -34
- package/internals/utils/getDefaultReferenceDate.d.ts +2 -2
- package/internals/utils/getDefaultReferenceDate.js +16 -16
- package/internals/utils/time-utils.d.ts +5 -5
- package/internals/utils/time-utils.js +12 -12
- package/internals/utils/valueManagers.js +4 -4
- package/managers/useDateManager.js +12 -12
- package/managers/useDateTimeManager.js +13 -13
- package/managers/useTimeManager.js +10 -11
- package/package.json +2 -2
- package/validation/useValidation.d.ts +2 -3
- package/validation/useValidation.js +2 -2
- package/validation/validateDate.js +6 -6
- package/validation/validateTime.js +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMonthsInYear } from "../../utils/date-utils.js";
|
|
2
|
-
export const getDateSectionConfigFromFormatToken = (
|
|
3
|
-
const config =
|
|
2
|
+
export const getDateSectionConfigFromFormatToken = (adapter, formatToken) => {
|
|
3
|
+
const config = adapter.formatTokenMap[formatToken];
|
|
4
4
|
if (config == null) {
|
|
5
5
|
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'));
|
|
6
6
|
}
|
|
@@ -17,32 +17,32 @@ export const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
|
17
17
|
maxLength: config.maxLength
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export const getDaysInWeekStr = (
|
|
20
|
+
export const getDaysInWeekStr = (adapter, format) => {
|
|
21
21
|
const elements = [];
|
|
22
|
-
const now =
|
|
23
|
-
const startDate =
|
|
24
|
-
const endDate =
|
|
22
|
+
const now = adapter.date(undefined, 'default');
|
|
23
|
+
const startDate = adapter.startOfWeek(now);
|
|
24
|
+
const endDate = adapter.endOfWeek(now);
|
|
25
25
|
let current = startDate;
|
|
26
|
-
while (
|
|
26
|
+
while (adapter.isBefore(current, endDate)) {
|
|
27
27
|
elements.push(current);
|
|
28
|
-
current =
|
|
28
|
+
current = adapter.addDays(current, 1);
|
|
29
29
|
}
|
|
30
|
-
return elements.map(weekDay =>
|
|
30
|
+
return elements.map(weekDay => adapter.formatByString(weekDay, format));
|
|
31
31
|
};
|
|
32
|
-
export const getLetterEditingOptions = (
|
|
32
|
+
export const getLetterEditingOptions = (adapter, timezone, sectionType, format) => {
|
|
33
33
|
switch (sectionType) {
|
|
34
34
|
case 'month':
|
|
35
35
|
{
|
|
36
|
-
return getMonthsInYear(
|
|
36
|
+
return getMonthsInYear(adapter, adapter.date(undefined, timezone)).map(month => adapter.formatByString(month, format));
|
|
37
37
|
}
|
|
38
38
|
case 'weekDay':
|
|
39
39
|
{
|
|
40
|
-
return getDaysInWeekStr(
|
|
40
|
+
return getDaysInWeekStr(adapter, format);
|
|
41
41
|
}
|
|
42
42
|
case 'meridiem':
|
|
43
43
|
{
|
|
44
|
-
const now =
|
|
45
|
-
return [
|
|
44
|
+
const now = adapter.date(undefined, timezone);
|
|
45
|
+
return [adapter.startOfDay(now), adapter.endOfDay(now)].map(date => adapter.formatByString(date, format));
|
|
46
46
|
}
|
|
47
47
|
default:
|
|
48
48
|
{
|
|
@@ -55,15 +55,15 @@ export const getLetterEditingOptions = (utils, timezone, sectionType, format) =>
|
|
|
55
55
|
// If some adapter does not respect this convention, then we will need to hardcode the format on each adapter.
|
|
56
56
|
export const FORMAT_SECONDS_NO_LEADING_ZEROS = 's';
|
|
57
57
|
const NON_LOCALIZED_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
58
|
-
export const getLocalizedDigits =
|
|
59
|
-
const today =
|
|
60
|
-
const formattedZero =
|
|
58
|
+
export const getLocalizedDigits = adapter => {
|
|
59
|
+
const today = adapter.date(undefined);
|
|
60
|
+
const formattedZero = adapter.formatByString(adapter.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);
|
|
61
61
|
if (formattedZero === '0') {
|
|
62
62
|
return NON_LOCALIZED_DIGITS;
|
|
63
63
|
}
|
|
64
64
|
return Array.from({
|
|
65
65
|
length: 10
|
|
66
|
-
}).map((_, index) =>
|
|
66
|
+
}).map((_, index) => adapter.formatByString(adapter.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));
|
|
67
67
|
};
|
|
68
68
|
export const removeLocalizedDigits = (valueStr, localizedDigits) => {
|
|
69
69
|
if (localizedDigits[0] === '0') {
|
|
@@ -102,7 +102,7 @@ export const cleanLeadingZeros = (valueStr, size) => {
|
|
|
102
102
|
// Remove the leading zeros and then add back as many as needed.
|
|
103
103
|
return Number(valueStr).toString().padStart(size, '0');
|
|
104
104
|
};
|
|
105
|
-
export const cleanDigitSectionValue = (
|
|
105
|
+
export const cleanDigitSectionValue = (adapter, value, sectionBoundaries, localizedDigits, section) => {
|
|
106
106
|
if (process.env.NODE_ENV !== 'production') {
|
|
107
107
|
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
108
108
|
throw new Error([`MUI X: The token "${section.format}" is a digit format with letter in it.'
|
|
@@ -110,8 +110,8 @@ export const cleanDigitSectionValue = (utils, value, sectionBoundaries, localize
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
if (section.type === 'day' && section.contentType === 'digit-with-letter') {
|
|
113
|
-
const date =
|
|
114
|
-
return
|
|
113
|
+
const date = adapter.setDate(sectionBoundaries.longestMonth, value);
|
|
114
|
+
return adapter.formatByString(date, section.format);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// queryValue without leading `0` (`01` => `1`)
|
|
@@ -142,53 +142,53 @@ export const getSectionVisibleValue = (section, target, localizedDigits) => {
|
|
|
142
142
|
}
|
|
143
143
|
return value;
|
|
144
144
|
};
|
|
145
|
-
export const changeSectionValueFormat = (
|
|
145
|
+
export const changeSectionValueFormat = (adapter, valueStr, currentFormat, newFormat) => {
|
|
146
146
|
if (process.env.NODE_ENV !== 'production') {
|
|
147
|
-
if (getDateSectionConfigFromFormatToken(
|
|
147
|
+
if (getDateSectionConfigFromFormatToken(adapter, currentFormat).type === 'weekDay') {
|
|
148
148
|
throw new Error("changeSectionValueFormat doesn't support week day formats");
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
return
|
|
151
|
+
return adapter.formatByString(adapter.parse(valueStr, currentFormat), newFormat);
|
|
152
152
|
};
|
|
153
|
-
const isFourDigitYearFormat = (
|
|
154
|
-
export const doesSectionFormatHaveLeadingZeros = (
|
|
153
|
+
const isFourDigitYearFormat = (adapter, format) => adapter.formatByString(adapter.date(undefined, 'system'), format).length === 4;
|
|
154
|
+
export const doesSectionFormatHaveLeadingZeros = (adapter, contentType, sectionType, format) => {
|
|
155
155
|
if (contentType !== 'digit') {
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
|
-
const now =
|
|
158
|
+
const now = adapter.date(undefined, 'default');
|
|
159
159
|
switch (sectionType) {
|
|
160
|
-
// We can't use `changeSectionValueFormat`, because `
|
|
160
|
+
// We can't use `changeSectionValueFormat`, because `adapter.parse('1', 'YYYY')` returns `1971` instead of `1`.
|
|
161
161
|
case 'year':
|
|
162
162
|
{
|
|
163
163
|
// Remove once https://github.com/iamkun/dayjs/pull/2847 is merged and bump dayjs version
|
|
164
|
-
if (
|
|
164
|
+
if (adapter.lib === 'dayjs' && format === 'YY') {
|
|
165
165
|
return true;
|
|
166
166
|
}
|
|
167
|
-
return
|
|
167
|
+
return adapter.formatByString(adapter.setYear(now, 1), format).startsWith('0');
|
|
168
168
|
}
|
|
169
169
|
case 'month':
|
|
170
170
|
{
|
|
171
|
-
return
|
|
171
|
+
return adapter.formatByString(adapter.startOfYear(now), format).length > 1;
|
|
172
172
|
}
|
|
173
173
|
case 'day':
|
|
174
174
|
{
|
|
175
|
-
return
|
|
175
|
+
return adapter.formatByString(adapter.startOfMonth(now), format).length > 1;
|
|
176
176
|
}
|
|
177
177
|
case 'weekDay':
|
|
178
178
|
{
|
|
179
|
-
return
|
|
179
|
+
return adapter.formatByString(adapter.startOfWeek(now), format).length > 1;
|
|
180
180
|
}
|
|
181
181
|
case 'hours':
|
|
182
182
|
{
|
|
183
|
-
return
|
|
183
|
+
return adapter.formatByString(adapter.setHours(now, 1), format).length > 1;
|
|
184
184
|
}
|
|
185
185
|
case 'minutes':
|
|
186
186
|
{
|
|
187
|
-
return
|
|
187
|
+
return adapter.formatByString(adapter.setMinutes(now, 1), format).length > 1;
|
|
188
188
|
}
|
|
189
189
|
case 'seconds':
|
|
190
190
|
{
|
|
191
|
-
return
|
|
191
|
+
return adapter.formatByString(adapter.setSeconds(now, 1), format).length > 1;
|
|
192
192
|
}
|
|
193
193
|
default:
|
|
194
194
|
{
|
|
@@ -201,7 +201,7 @@ export const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionTyp
|
|
|
201
201
|
* Some date libraries like `dayjs` don't support parsing from date with escaped characters.
|
|
202
202
|
* To make sure that the parsing works, we are building a format and a date without any separator.
|
|
203
203
|
*/
|
|
204
|
-
export const getDateFromDateSections = (
|
|
204
|
+
export const getDateFromDateSections = (adapter, sections, localizedDigits) => {
|
|
205
205
|
// If we have both a day and a weekDay section,
|
|
206
206
|
// Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.
|
|
207
207
|
// dayjs(dayjs().format('dddd MMMM D YYYY'), 'dddd MMMM D YYYY')) // returns `Invalid Date` even if the format is valid.
|
|
@@ -218,7 +218,7 @@ export const getDateFromDateSections = (utils, sections, localizedDigits) => {
|
|
|
218
218
|
}
|
|
219
219
|
const formatWithoutSeparator = sectionFormats.join(' ');
|
|
220
220
|
const dateWithoutSeparatorStr = sectionValues.join(' ');
|
|
221
|
-
return
|
|
221
|
+
return adapter.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
|
|
222
222
|
};
|
|
223
223
|
export const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {
|
|
224
224
|
return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;
|
|
@@ -240,15 +240,15 @@ export const createDateStrForV6InputFromSections = (sections, localizedDigits, i
|
|
|
240
240
|
// wrap into an isolated group such that separators can split the string in smaller ones by adding \u2069\u2068
|
|
241
241
|
return `\u2066${dateStr}\u2069`;
|
|
242
242
|
};
|
|
243
|
-
export const getSectionsBoundaries = (
|
|
244
|
-
const today =
|
|
245
|
-
const endOfYear =
|
|
246
|
-
const endOfDay =
|
|
243
|
+
export const getSectionsBoundaries = (adapter, localizedDigits, timezone) => {
|
|
244
|
+
const today = adapter.date(undefined, timezone);
|
|
245
|
+
const endOfYear = adapter.endOfYear(today);
|
|
246
|
+
const endOfDay = adapter.endOfDay(today);
|
|
247
247
|
const {
|
|
248
248
|
maxDaysInMonth,
|
|
249
249
|
longestMonth
|
|
250
|
-
} = getMonthsInYear(
|
|
251
|
-
const daysInMonth =
|
|
250
|
+
} = getMonthsInYear(adapter, today).reduce((acc, month) => {
|
|
251
|
+
const daysInMonth = adapter.getDaysInMonth(month);
|
|
252
252
|
if (daysInMonth > acc.maxDaysInMonth) {
|
|
253
253
|
return {
|
|
254
254
|
maxDaysInMonth: daysInMonth,
|
|
@@ -265,18 +265,18 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
265
265
|
format
|
|
266
266
|
}) => ({
|
|
267
267
|
minimum: 0,
|
|
268
|
-
maximum: isFourDigitYearFormat(
|
|
268
|
+
maximum: isFourDigitYearFormat(adapter, format) ? 9999 : 99
|
|
269
269
|
}),
|
|
270
270
|
month: () => ({
|
|
271
271
|
minimum: 1,
|
|
272
272
|
// Assumption: All years have the same amount of months
|
|
273
|
-
maximum:
|
|
273
|
+
maximum: adapter.getMonth(endOfYear) + 1
|
|
274
274
|
}),
|
|
275
275
|
day: ({
|
|
276
276
|
currentDate
|
|
277
277
|
}) => ({
|
|
278
278
|
minimum: 1,
|
|
279
|
-
maximum:
|
|
279
|
+
maximum: adapter.isValid(currentDate) ? adapter.getDaysInMonth(currentDate) : maxDaysInMonth,
|
|
280
280
|
longestMonth: longestMonth
|
|
281
281
|
}),
|
|
282
282
|
weekDay: ({
|
|
@@ -284,7 +284,7 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
284
284
|
contentType
|
|
285
285
|
}) => {
|
|
286
286
|
if (contentType === 'digit') {
|
|
287
|
-
const daysInWeek = getDaysInWeekStr(
|
|
287
|
+
const daysInWeek = getDaysInWeekStr(adapter, format).map(Number);
|
|
288
288
|
return {
|
|
289
289
|
minimum: Math.min(...daysInWeek),
|
|
290
290
|
maximum: Math.max(...daysInWeek)
|
|
@@ -298,12 +298,12 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
298
298
|
hours: ({
|
|
299
299
|
format
|
|
300
300
|
}) => {
|
|
301
|
-
const lastHourInDay =
|
|
302
|
-
const hasMeridiem = removeLocalizedDigits(
|
|
301
|
+
const lastHourInDay = adapter.getHours(endOfDay);
|
|
302
|
+
const hasMeridiem = removeLocalizedDigits(adapter.formatByString(adapter.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();
|
|
303
303
|
if (hasMeridiem) {
|
|
304
304
|
return {
|
|
305
305
|
minimum: 1,
|
|
306
|
-
maximum: Number(removeLocalizedDigits(
|
|
306
|
+
maximum: Number(removeLocalizedDigits(adapter.formatByString(adapter.startOfDay(today), format), localizedDigits))
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
return {
|
|
@@ -314,12 +314,12 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
314
314
|
minutes: () => ({
|
|
315
315
|
minimum: 0,
|
|
316
316
|
// Assumption: All years have the same amount of minutes
|
|
317
|
-
maximum:
|
|
317
|
+
maximum: adapter.getMinutes(endOfDay)
|
|
318
318
|
}),
|
|
319
319
|
seconds: () => ({
|
|
320
320
|
minimum: 0,
|
|
321
321
|
// Assumption: All years have the same amount of seconds
|
|
322
|
-
maximum:
|
|
322
|
+
maximum: adapter.getSeconds(endOfDay)
|
|
323
323
|
}),
|
|
324
324
|
meridiem: () => ({
|
|
325
325
|
minimum: 0,
|
|
@@ -350,55 +350,55 @@ export const validateSections = (sections, valueType) => {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
};
|
|
353
|
-
const transferDateSectionValue = (
|
|
353
|
+
const transferDateSectionValue = (adapter, section, dateToTransferFrom, dateToTransferTo) => {
|
|
354
354
|
switch (section.type) {
|
|
355
355
|
case 'year':
|
|
356
356
|
{
|
|
357
|
-
return
|
|
357
|
+
return adapter.setYear(dateToTransferTo, adapter.getYear(dateToTransferFrom));
|
|
358
358
|
}
|
|
359
359
|
case 'month':
|
|
360
360
|
{
|
|
361
|
-
return
|
|
361
|
+
return adapter.setMonth(dateToTransferTo, adapter.getMonth(dateToTransferFrom));
|
|
362
362
|
}
|
|
363
363
|
case 'weekDay':
|
|
364
364
|
{
|
|
365
|
-
let dayInWeekStrOfActiveDate =
|
|
365
|
+
let dayInWeekStrOfActiveDate = adapter.formatByString(dateToTransferFrom, section.format);
|
|
366
366
|
if (section.hasLeadingZerosInInput) {
|
|
367
367
|
dayInWeekStrOfActiveDate = cleanLeadingZeros(dayInWeekStrOfActiveDate, section.maxLength);
|
|
368
368
|
}
|
|
369
|
-
const formattedDaysInWeek = getDaysInWeekStr(
|
|
369
|
+
const formattedDaysInWeek = getDaysInWeekStr(adapter, section.format);
|
|
370
370
|
const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
|
|
371
371
|
const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
|
|
372
372
|
const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
|
|
373
|
-
return
|
|
373
|
+
return adapter.addDays(dateToTransferFrom, diff);
|
|
374
374
|
}
|
|
375
375
|
case 'day':
|
|
376
376
|
{
|
|
377
|
-
return
|
|
377
|
+
return adapter.setDate(dateToTransferTo, adapter.getDate(dateToTransferFrom));
|
|
378
378
|
}
|
|
379
379
|
case 'meridiem':
|
|
380
380
|
{
|
|
381
|
-
const isAM =
|
|
382
|
-
const mergedDateHours =
|
|
381
|
+
const isAM = adapter.getHours(dateToTransferFrom) < 12;
|
|
382
|
+
const mergedDateHours = adapter.getHours(dateToTransferTo);
|
|
383
383
|
if (isAM && mergedDateHours >= 12) {
|
|
384
|
-
return
|
|
384
|
+
return adapter.addHours(dateToTransferTo, -12);
|
|
385
385
|
}
|
|
386
386
|
if (!isAM && mergedDateHours < 12) {
|
|
387
|
-
return
|
|
387
|
+
return adapter.addHours(dateToTransferTo, 12);
|
|
388
388
|
}
|
|
389
389
|
return dateToTransferTo;
|
|
390
390
|
}
|
|
391
391
|
case 'hours':
|
|
392
392
|
{
|
|
393
|
-
return
|
|
393
|
+
return adapter.setHours(dateToTransferTo, adapter.getHours(dateToTransferFrom));
|
|
394
394
|
}
|
|
395
395
|
case 'minutes':
|
|
396
396
|
{
|
|
397
|
-
return
|
|
397
|
+
return adapter.setMinutes(dateToTransferTo, adapter.getMinutes(dateToTransferFrom));
|
|
398
398
|
}
|
|
399
399
|
case 'seconds':
|
|
400
400
|
{
|
|
401
|
-
return
|
|
401
|
+
return adapter.setSeconds(dateToTransferTo, adapter.getSeconds(dateToTransferFrom));
|
|
402
402
|
}
|
|
403
403
|
default:
|
|
404
404
|
{
|
|
@@ -417,11 +417,11 @@ const reliableSectionModificationOrder = {
|
|
|
417
417
|
meridiem: 8,
|
|
418
418
|
empty: 9
|
|
419
419
|
};
|
|
420
|
-
export const mergeDateIntoReferenceDate = (
|
|
420
|
+
export const mergeDateIntoReferenceDate = (adapter, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
|
|
421
421
|
// cloning sections before sort to avoid mutating it
|
|
422
422
|
[...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {
|
|
423
423
|
if (!shouldLimitToEditedSections || section.modified) {
|
|
424
|
-
return transferDateSectionValue(
|
|
424
|
+
return transferDateSectionValue(adapter, section, dateToTransferFrom, mergedDate);
|
|
425
425
|
}
|
|
426
426
|
return mergedDate;
|
|
427
427
|
}, referenceDate);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
3
|
-
import { useUtils } from "../useUtils.js";
|
|
4
3
|
import { changeSectionValueFormat, cleanDigitSectionValue, doesSectionFormatHaveLeadingZeros, getDateSectionConfigFromFormatToken, getDaysInWeekStr, getLetterEditingOptions, applyLocalizedDigits, removeLocalizedDigits, isStringNumber } from "./useField.utils.js";
|
|
4
|
+
import { usePickerAdapter } from "../../../hooks/usePickerAdapter.js";
|
|
5
5
|
const isQueryResponseWithoutValue = response => response.saveQuery != null;
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -24,7 +24,7 @@ export const useFieldCharacterEditing = ({
|
|
|
24
24
|
updateSectionValue
|
|
25
25
|
}
|
|
26
26
|
}) => {
|
|
27
|
-
const
|
|
27
|
+
const adapter = usePickerAdapter();
|
|
28
28
|
const applyQuery = ({
|
|
29
29
|
keyPressed,
|
|
30
30
|
sectionIndex
|
|
@@ -75,7 +75,7 @@ export const useFieldCharacterEditing = ({
|
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {
|
|
78
|
-
const getOptions = format => getLetterEditingOptions(
|
|
78
|
+
const getOptions = format => getLetterEditingOptions(adapter, timezone, activeSection.type, format);
|
|
79
79
|
if (activeSection.contentType === 'letter') {
|
|
80
80
|
return findMatchingOptions(activeSection.format, getOptions(activeSection.format), queryValue);
|
|
81
81
|
}
|
|
@@ -83,7 +83,7 @@ export const useFieldCharacterEditing = ({
|
|
|
83
83
|
// When editing a digit-format month / weekDay and the user presses a letter,
|
|
84
84
|
// We can support the letter editing by using the letter-format month / weekDay and re-formatting the result.
|
|
85
85
|
// We just have to make sure that the default month / weekDay format is a letter format,
|
|
86
|
-
if (fallbackFormat && formatFallbackValue != null && getDateSectionConfigFromFormatToken(
|
|
86
|
+
if (fallbackFormat && formatFallbackValue != null && getDateSectionConfigFromFormatToken(adapter, fallbackFormat).contentType === 'letter') {
|
|
87
87
|
const fallbackOptions = getOptions(fallbackFormat);
|
|
88
88
|
const response = findMatchingOptions(fallbackFormat, fallbackOptions, queryValue);
|
|
89
89
|
if (isQueryResponseWithoutValue(response)) {
|
|
@@ -103,13 +103,13 @@ export const useFieldCharacterEditing = ({
|
|
|
103
103
|
switch (activeSection.type) {
|
|
104
104
|
case 'month':
|
|
105
105
|
{
|
|
106
|
-
const formatFallbackValue = fallbackValue => changeSectionValueFormat(
|
|
107
|
-
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection,
|
|
106
|
+
const formatFallbackValue = fallbackValue => changeSectionValueFormat(adapter, fallbackValue, adapter.formats.month, activeSection.format);
|
|
107
|
+
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, adapter.formats.month, formatFallbackValue);
|
|
108
108
|
}
|
|
109
109
|
case 'weekDay':
|
|
110
110
|
{
|
|
111
111
|
const formatFallbackValue = (fallbackValue, fallbackOptions) => fallbackOptions.indexOf(fallbackValue).toString();
|
|
112
|
-
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection,
|
|
112
|
+
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, adapter.formats.weekday, formatFallbackValue);
|
|
113
113
|
}
|
|
114
114
|
case 'meridiem':
|
|
115
115
|
{
|
|
@@ -153,7 +153,7 @@ export const useFieldCharacterEditing = ({
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
const shouldGoToNextSection = queryValueNumber * 10 > sectionBoundaries.maximum || cleanQueryValue.length === sectionBoundaries.maximum.toString().length;
|
|
156
|
-
const newSectionValue = cleanDigitSectionValue(
|
|
156
|
+
const newSectionValue = cleanDigitSectionValue(adapter, queryValueNumber, sectionBoundaries, localizedDigits, section);
|
|
157
157
|
return {
|
|
158
158
|
sectionValue: newSectionValue,
|
|
159
159
|
shouldGoToNextSection
|
|
@@ -171,7 +171,7 @@ export const useFieldCharacterEditing = ({
|
|
|
171
171
|
// When editing a letter-format month and the user presses a digit,
|
|
172
172
|
// We can support the numeric editing by using the digit-format month and re-formatting the result.
|
|
173
173
|
if (activeSection.type === 'month') {
|
|
174
|
-
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(
|
|
174
|
+
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(adapter, 'digit', 'month', 'MM');
|
|
175
175
|
const response = getNewSectionValue({
|
|
176
176
|
queryValue,
|
|
177
177
|
skipIfBelowMinimum: true,
|
|
@@ -187,7 +187,7 @@ export const useFieldCharacterEditing = ({
|
|
|
187
187
|
if (isQueryResponseWithoutValue(response)) {
|
|
188
188
|
return response;
|
|
189
189
|
}
|
|
190
|
-
const formattedValue = changeSectionValueFormat(
|
|
190
|
+
const formattedValue = changeSectionValueFormat(adapter, response.sectionValue, 'MM', activeSection.format);
|
|
191
191
|
return _extends({}, response, {
|
|
192
192
|
sectionValue: formattedValue
|
|
193
193
|
});
|
|
@@ -204,7 +204,7 @@ export const useFieldCharacterEditing = ({
|
|
|
204
204
|
if (isQueryResponseWithoutValue(response)) {
|
|
205
205
|
return response;
|
|
206
206
|
}
|
|
207
|
-
const formattedValue = getDaysInWeekStr(
|
|
207
|
+
const formattedValue = getDaysInWeekStr(adapter, activeSection.format)[Number(response.sectionValue) - 1];
|
|
208
208
|
return _extends({}, response, {
|
|
209
209
|
sectionValue: formattedValue
|
|
210
210
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
2
|
-
import { useUtils } from "../useUtils.js";
|
|
3
2
|
import { cleanDigitSectionValue, getLetterEditingOptions, removeLocalizedDigits } from "./useField.utils.js";
|
|
3
|
+
import { usePickerAdapter } from "../../../hooks/usePickerAdapter.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the `onKeyDown` handler to pass to the root element of the field.
|
|
7
7
|
*/
|
|
8
8
|
export function useFieldRootHandleKeyDown(parameters) {
|
|
9
|
-
const
|
|
9
|
+
const adapter = usePickerAdapter();
|
|
10
10
|
const {
|
|
11
11
|
manager: {
|
|
12
12
|
internal_fieldValueManager: fieldValueManager
|
|
@@ -112,7 +112,7 @@ export function useFieldRootHandleKeyDown(parameters) {
|
|
|
112
112
|
setSelectedSections(activeSectionIndex);
|
|
113
113
|
}
|
|
114
114
|
const activeSection = state.sections[activeSectionIndex];
|
|
115
|
-
const newSectionValue = adjustSectionValue(
|
|
115
|
+
const newSectionValue = adjustSectionValue(adapter, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, fieldValueManager.getDateFromSection(value, activeSection), {
|
|
116
116
|
minutesStep
|
|
117
117
|
});
|
|
118
118
|
updateSectionValue({
|
|
@@ -139,7 +139,7 @@ function getDeltaFromKeyCode(keyCode) {
|
|
|
139
139
|
return 0;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function adjustSectionValue(
|
|
142
|
+
function adjustSectionValue(adapter, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) {
|
|
143
143
|
const delta = getDeltaFromKeyCode(keyCode);
|
|
144
144
|
const isStart = keyCode === 'Home';
|
|
145
145
|
const isEnd = keyCode === 'End';
|
|
@@ -150,12 +150,12 @@ function adjustSectionValue(utils, timezone, section, keyCode, sectionsValueBoun
|
|
|
150
150
|
format: section.format,
|
|
151
151
|
contentType: section.contentType
|
|
152
152
|
});
|
|
153
|
-
const getCleanValue = value => cleanDigitSectionValue(
|
|
153
|
+
const getCleanValue = value => cleanDigitSectionValue(adapter, value, sectionBoundaries, localizedDigits, section);
|
|
154
154
|
const step = section.type === 'minutes' && stepsAttributes?.minutesStep ? stepsAttributes.minutesStep : 1;
|
|
155
155
|
let newSectionValueNumber;
|
|
156
156
|
if (shouldSetAbsolute) {
|
|
157
157
|
if (section.type === 'year' && !isEnd && !isStart) {
|
|
158
|
-
return
|
|
158
|
+
return adapter.formatByString(adapter.date(undefined, timezone), section.format);
|
|
159
159
|
}
|
|
160
160
|
if (delta > 0 || isStart) {
|
|
161
161
|
newSectionValueNumber = sectionBoundaries.minimum;
|
|
@@ -183,7 +183,7 @@ function adjustSectionValue(utils, timezone, section, keyCode, sectionsValueBoun
|
|
|
183
183
|
return getCleanValue(newSectionValueNumber);
|
|
184
184
|
};
|
|
185
185
|
const adjustLetterSection = () => {
|
|
186
|
-
const options = getLetterEditingOptions(
|
|
186
|
+
const options = getLetterEditingOptions(adapter, timezone, section.type, section.format);
|
|
187
187
|
if (options.length === 0) {
|
|
188
188
|
return section.value;
|
|
189
189
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
3
3
|
import useId from '@mui/utils/useId';
|
|
4
|
-
import {
|
|
5
|
-
import { usePickerTranslations } from "../../../hooks/index.js";
|
|
4
|
+
import { usePickerAdapter, usePickerTranslations } from "../../../hooks/index.js";
|
|
6
5
|
import { syncSelectionToDOM } from "./syncSelectionToDOM.js";
|
|
7
6
|
/**
|
|
8
7
|
* Generate the props to pass to the content element of each section of the field.
|
|
@@ -12,7 +11,7 @@ import { syncSelectionToDOM } from "./syncSelectionToDOM.js";
|
|
|
12
11
|
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
|
13
12
|
*/
|
|
14
13
|
export function useFieldSectionContentProps(parameters) {
|
|
15
|
-
const
|
|
14
|
+
const adapter = usePickerAdapter();
|
|
16
15
|
const translations = usePickerTranslations();
|
|
17
16
|
const id = useId();
|
|
18
17
|
const {
|
|
@@ -150,10 +149,10 @@ export function useFieldSectionContentProps(parameters) {
|
|
|
150
149
|
// Aria attributes
|
|
151
150
|
'aria-labelledby': `${id}-${section.type}`,
|
|
152
151
|
'aria-readonly': readOnly,
|
|
153
|
-
'aria-valuenow': getSectionValueNow(section,
|
|
152
|
+
'aria-valuenow': getSectionValueNow(section, adapter),
|
|
154
153
|
'aria-valuemin': sectionBoundaries.minimum,
|
|
155
154
|
'aria-valuemax': sectionBoundaries.maximum,
|
|
156
|
-
'aria-valuetext': section.value ? getSectionValueText(section,
|
|
155
|
+
'aria-valuetext': section.value ? getSectionValueText(section, adapter) : translations.empty,
|
|
157
156
|
'aria-label': translations[section.type],
|
|
158
157
|
'aria-disabled': disabled,
|
|
159
158
|
// Other
|
|
@@ -168,9 +167,9 @@ export function useFieldSectionContentProps(parameters) {
|
|
|
168
167
|
children: section.value || section.placeholder,
|
|
169
168
|
inputMode: section.contentType === 'letter' ? 'text' : 'numeric'
|
|
170
169
|
};
|
|
171
|
-
}, [sectionsValueBoundaries, id, isContainerEditable, disabled, readOnly, isEditable, translations,
|
|
170
|
+
}, [sectionsValueBoundaries, id, isContainerEditable, disabled, readOnly, isEditable, translations, adapter, handleInput, handlePaste, handleMouseUp, handleDragOver, createFocusHandler, fieldValueManager, value]);
|
|
172
171
|
}
|
|
173
|
-
function getSectionValueText(section,
|
|
172
|
+
function getSectionValueText(section, adapter) {
|
|
174
173
|
if (!section.value) {
|
|
175
174
|
return undefined;
|
|
176
175
|
}
|
|
@@ -178,13 +177,13 @@ function getSectionValueText(section, utils) {
|
|
|
178
177
|
case 'month':
|
|
179
178
|
{
|
|
180
179
|
if (section.contentType === 'digit') {
|
|
181
|
-
return
|
|
180
|
+
return adapter.format(adapter.setMonth(adapter.date(), Number(section.value) - 1), 'month');
|
|
182
181
|
}
|
|
183
|
-
const parsedDate =
|
|
184
|
-
return parsedDate ?
|
|
182
|
+
const parsedDate = adapter.parse(section.value, section.format);
|
|
183
|
+
return parsedDate ? adapter.format(parsedDate, 'month') : undefined;
|
|
185
184
|
}
|
|
186
185
|
case 'day':
|
|
187
|
-
return section.contentType === 'digit' ?
|
|
186
|
+
return section.contentType === 'digit' ? adapter.format(adapter.setDate(adapter.startOfYear(adapter.date()), Number(section.value)), 'dayOfMonthFull') : section.value;
|
|
188
187
|
case 'weekDay':
|
|
189
188
|
// TODO: improve by providing the label of the week day
|
|
190
189
|
return undefined;
|
|
@@ -192,7 +191,7 @@ function getSectionValueText(section, utils) {
|
|
|
192
191
|
return undefined;
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
|
-
function getSectionValueNow(section,
|
|
194
|
+
function getSectionValueNow(section, adapter) {
|
|
196
195
|
if (!section.value) {
|
|
197
196
|
return undefined;
|
|
198
197
|
}
|
|
@@ -207,9 +206,9 @@ function getSectionValueNow(section, utils) {
|
|
|
207
206
|
}
|
|
208
207
|
case 'meridiem':
|
|
209
208
|
{
|
|
210
|
-
const parsedDate =
|
|
209
|
+
const parsedDate = adapter.parse(`01:00 ${section.value}`, `${adapter.formats.hours12h}:${adapter.formats.minutes} ${section.format}`);
|
|
211
210
|
if (parsedDate) {
|
|
212
|
-
return
|
|
211
|
+
return adapter.getHours(parsedDate) >= 12 ? 1 : 0;
|
|
213
212
|
}
|
|
214
213
|
return undefined;
|
|
215
214
|
}
|
|
@@ -220,8 +219,8 @@ function getSectionValueNow(section, utils) {
|
|
|
220
219
|
if (section.contentType === 'digit') {
|
|
221
220
|
return Number(section.value);
|
|
222
221
|
}
|
|
223
|
-
const parsedDate =
|
|
224
|
-
return parsedDate ?
|
|
222
|
+
const parsedDate = adapter.parse(section.value, section.format);
|
|
223
|
+
return parsedDate ? adapter.getMonth(parsedDate) + 1 : undefined;
|
|
225
224
|
}
|
|
226
225
|
default:
|
|
227
226
|
return section.contentType !== 'letter' ? Number(section.value) : undefined;
|