@mui/x-date-pickers 7.0.0-beta.7 → 7.0.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/AdapterDateFns/AdapterDateFns.js +1 -1
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +1 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -4
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
- package/AdapterDayjs/AdapterDayjs.js +2 -4
- package/AdapterLuxon/AdapterLuxon.js +12 -9
- package/AdapterMoment/AdapterMoment.js +5 -6
- package/CHANGELOG.md +195 -12
- package/DateCalendar/DateCalendar.js +14 -16
- package/DateCalendar/DayCalendar.js +5 -6
- package/DateField/DateField.js +3 -4
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/shared.d.ts +2 -1
- package/DatePicker/shared.js +3 -5
- package/DateTimeField/DateTimeField.js +3 -4
- package/DateTimePicker/DateTimePicker.js +1 -1
- package/DateTimePicker/DateTimePickerToolbar.js +1 -1
- package/DateTimePicker/shared.d.ts +2 -1
- package/DateTimePicker/shared.js +11 -13
- package/DesktopDatePicker/DesktopDatePicker.js +7 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +72 -37
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +12 -0
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +101 -0
- package/DesktopDateTimePicker/index.d.ts +1 -0
- package/DesktopDateTimePicker/index.js +2 -1
- package/DesktopTimePicker/DesktopTimePicker.js +8 -12
- package/DigitalClock/DigitalClock.js +2 -3
- package/LocalizationProvider/LocalizationProvider.js +1 -2
- package/MobileDatePicker/MobileDatePicker.js +6 -10
- package/MobileDateTimePicker/MobileDateTimePicker.js +8 -12
- package/MobileTimePicker/MobileTimePicker.js +6 -10
- package/MonthCalendar/MonthCalendar.js +4 -4
- package/MonthCalendar/PickersMonth.js +1 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +3 -5
- package/PickersActionBar/PickersActionBar.js +1 -1
- package/PickersCalendarHeader/PickersCalendarHeader.js +4 -5
- package/PickersLayout/usePickerLayout.js +8 -9
- package/PickersSectionList/PickersSectionList.js +9 -11
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +2 -3
- package/PickersTextField/PickersInput/PickersInput.js +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.js +4 -5
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +2 -2
- package/README.md +1 -1
- package/StaticDatePicker/StaticDatePicker.js +4 -5
- package/StaticDateTimePicker/StaticDateTimePicker.js +6 -7
- package/StaticTimePicker/StaticTimePicker.js +3 -4
- package/TimeClock/TimeClock.js +1 -1
- package/TimeField/TimeField.js +2 -3
- package/TimePicker/shared.d.ts +2 -1
- package/TimePicker/shared.js +5 -7
- package/YearCalendar/YearCalendar.js +5 -6
- package/hooks/useClearableField.js +6 -7
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +8 -9
- package/internals/components/PickersModalDialog.js +6 -7
- package/internals/components/PickersPopper.js +13 -16
- package/internals/components/PickersToolbar.js +9 -12
- package/internals/hooks/date-helpers-hooks.js +1 -1
- package/internals/hooks/defaultizedFieldProps.js +15 -18
- package/internals/hooks/useClockReferenceDate.js +1 -1
- package/internals/hooks/useDesktopPicker/index.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +11 -12
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/buildSectionsFromFormat.js +35 -31
- package/internals/hooks/useField/useField.js +2 -2
- package/internals/hooks/useField/useField.utils.js +4 -7
- package/internals/hooks/useField/useFieldCharacterEditing.js +1 -2
- package/internals/hooks/useField/useFieldState.js +1 -1
- package/internals/hooks/useField/useFieldV6TextField.js +9 -15
- package/internals/hooks/useField/useFieldV7TextField.js +9 -11
- package/internals/hooks/useMobilePicker/useMobilePicker.js +7 -8
- package/internals/hooks/useOpenState.js +1 -1
- package/internals/hooks/usePicker/index.d.ts +1 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +4 -2
- package/internals/hooks/usePicker/usePickerViews.js +1 -2
- package/internals/hooks/useStaticPicker/useStaticPicker.js +13 -17
- package/internals/hooks/useValueWithTimezone.js +5 -6
- package/internals/hooks/useViews.js +3 -4
- package/internals/index.d.ts +1 -1
- package/internals/models/validation.d.ts +1 -1
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +3 -3
- package/internals/utils/date-time-utils.js +2 -5
- package/internals/utils/fields.js +1 -1
- package/internals/utils/getDefaultReferenceDate.js +2 -6
- package/internals/utils/views.js +1 -1
- package/locales/csCZ.js +1 -4
- package/locales/daDK.js +1 -4
- package/locales/deDE.js +1 -4
- package/locales/huHU.js +1 -4
- package/locales/jaJP.js +1 -4
- package/locales/roRO.js +1 -4
- package/locales/skSK.js +1 -4
- package/modern/AdapterLuxon/AdapterLuxon.js +9 -4
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/DateField.js +1 -1
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DateTimeField/DateTimeField.js +1 -1
- package/modern/DateTimePicker/DateTimePicker.js +1 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +64 -25
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +101 -0
- package/modern/DesktopDateTimePicker/index.js +2 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersPopper.js +1 -1
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
- package/modern/internals/hooks/useField/useFieldV7TextField.js +1 -1
- package/modern/internals/hooks/useOpenState.js +1 -1
- package/modern/internals/utils/fields.js +1 -1
- package/node/AdapterLuxon/AdapterLuxon.js +9 -4
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateField/DateField.js +1 -1
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DateTimeField/DateTimeField.js +1 -1
- package/node/DateTimePicker/DateTimePicker.js +1 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +63 -25
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +108 -0
- package/node/DesktopDateTimePicker/index.js +8 -1
- package/node/MobileDatePicker/MobileDatePicker.js +1 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -1
- package/node/StaticDatePicker/StaticDatePicker.js +1 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersPopper.js +1 -1
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +34 -30
- package/node/internals/hooks/useField/useFieldV7TextField.js +1 -1
- package/node/internals/hooks/useOpenState.js +1 -1
- package/node/internals/utils/fields.js +1 -1
- package/package.json +5 -5
- package/timeViewRenderers/timeViewRenderers.js +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +0 -15
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -163
- package/dateTimeViewRenderers/index.d.ts +0 -2
- package/dateTimeViewRenderers/index.js +0 -1
- package/dateTimeViewRenderers/package.json +0 -6
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -162
- package/modern/dateTimeViewRenderers/index.js +0 -1
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +0 -171
- package/node/dateTimeViewRenderers/index.js +0 -12
|
@@ -9,10 +9,7 @@ export const SECTION_TYPE_GRANULARITY = {
|
|
|
9
9
|
seconds: 6,
|
|
10
10
|
milliseconds: 7
|
|
11
11
|
};
|
|
12
|
-
export const getSectionTypeGranularity = sections => Math.max(...sections.map(section =>
|
|
13
|
-
var _SECTION_TYPE_GRANULA;
|
|
14
|
-
return (_SECTION_TYPE_GRANULA = SECTION_TYPE_GRANULARITY[section.type]) != null ? _SECTION_TYPE_GRANULA : 1;
|
|
15
|
-
}));
|
|
12
|
+
export const getSectionTypeGranularity = sections => Math.max(...sections.map(section => SECTION_TYPE_GRANULARITY[section.type] ?? 1));
|
|
16
13
|
const roundDate = (utils, granularity, date) => {
|
|
17
14
|
if (granularity === SECTION_TYPE_GRANULARITY.year) {
|
|
18
15
|
return utils.startOfYear(date);
|
|
@@ -44,7 +41,6 @@ export const getDefaultReferenceDate = ({
|
|
|
44
41
|
timezone,
|
|
45
42
|
getTodayDate: inGetTodayDate
|
|
46
43
|
}) => {
|
|
47
|
-
var _props$disableIgnorin;
|
|
48
44
|
let referenceDate = inGetTodayDate ? inGetTodayDate() : roundDate(utils, granularity, getTodayDate(utils, timezone));
|
|
49
45
|
if (props.minDate != null && utils.isAfterDay(props.minDate, referenceDate)) {
|
|
50
46
|
referenceDate = roundDate(utils, granularity, props.minDate);
|
|
@@ -52,7 +48,7 @@ export const getDefaultReferenceDate = ({
|
|
|
52
48
|
if (props.maxDate != null && utils.isBeforeDay(props.maxDate, referenceDate)) {
|
|
53
49
|
referenceDate = roundDate(utils, granularity, props.maxDate);
|
|
54
50
|
}
|
|
55
|
-
const isAfter = createIsAfterIgnoreDatePart(
|
|
51
|
+
const isAfter = createIsAfterIgnoreDatePart(props.disableIgnoringDatePartForTimeValidation ?? false, utils);
|
|
56
52
|
if (props.minTime != null && isAfter(props.minTime, referenceDate)) {
|
|
57
53
|
referenceDate = roundDate(utils, granularity, props.disableIgnoringDatePartForTimeValidation ? props.minTime : mergeDateAndTime(utils, referenceDate, props.minTime));
|
|
58
54
|
}
|
package/internals/utils/views.js
CHANGED
|
@@ -10,7 +10,7 @@ export const applyDefaultViewProps = ({
|
|
|
10
10
|
views,
|
|
11
11
|
defaultViews
|
|
12
12
|
}) => {
|
|
13
|
-
const viewsWithDefault = views
|
|
13
|
+
const viewsWithDefault = views ?? defaultViews;
|
|
14
14
|
let openToWithDefault;
|
|
15
15
|
if (openTo != null) {
|
|
16
16
|
openToWithDefault = openTo;
|
package/locales/csCZ.js
CHANGED
|
@@ -33,10 +33,7 @@ const csCZPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Vyberte čas',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Vyberete rozmezí dat',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} vybrány. ${time === null ? 'Není vybrán čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} vybrány. ${time === null ? 'Není vybrán čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} hodin`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} minut`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} sekund`,
|
package/locales/daDK.js
CHANGED
|
@@ -33,10 +33,7 @@ const daDKPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Vælg tidspunkt',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Vælg datointerval',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `Vælg ${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}. ${time === null ? 'Intet tidspunkt valgt' : `Valgte tidspunkt er ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `Vælg ${timeViews[view] ?? view}. ${time === null ? 'Intet tidspunkt valgt' : `Valgte tidspunkt er ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} timer`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} minutter`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} sekunder`,
|
package/locales/deDE.js
CHANGED
|
@@ -33,10 +33,7 @@ const deDEPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Uhrzeit auswählen',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Datumsbereich auswählen',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} auswählen. ${time === null ? 'Keine Uhrzeit ausgewählt' : `Gewählte Uhrzeit ist ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} auswählen. ${time === null ? 'Keine Uhrzeit ausgewählt' : `Gewählte Uhrzeit ist ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
package/locales/huHU.js
CHANGED
|
@@ -33,10 +33,7 @@ const huHUPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Idő kiválasztása',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Dátumhatárok kiválasztása',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} kiválasztása. ${time === null ? 'Nincs kiválasztva idő' : `A kiválasztott idő ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} kiválasztása. ${time === null ? 'Nincs kiválasztva idő' : `A kiválasztott idő ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours.toLowerCase()}`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes.toLowerCase()}`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds.toLowerCase()}`,
|
package/locales/jaJP.js
CHANGED
|
@@ -32,10 +32,7 @@ const jaJPPickers = {
|
|
|
32
32
|
timePickerToolbarTitle: '時間を選択',
|
|
33
33
|
dateRangePickerToolbarTitle: '日付の範囲を選択',
|
|
34
34
|
// Clock labels
|
|
35
|
-
clockLabelText: (view, time, adapter) => {
|
|
36
|
-
var _timeViews$view;
|
|
37
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}を選択してください ${time === null ? '時間が選択されていません' : `選択した時間は ${adapter.format(time, 'fullTime')} です`}`;
|
|
38
|
-
},
|
|
35
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view}を選択してください ${time === null ? '時間が選択されていません' : `選択した時間は ${adapter.format(time, 'fullTime')} です`}`,
|
|
39
36
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
40
37
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
41
38
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
package/locales/roRO.js
CHANGED
|
@@ -33,10 +33,7 @@ const roROPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Selectați ora',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Selectați intervalul de date',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `Selectați ${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view}. ${time === null ? 'Nicio oră selectată' : `Ora selectată este ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `Selectați ${timeViews[view] ?? view}. ${time === null ? 'Nicio oră selectată' : `Ora selectată este ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} ${timeViews.minutes}`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} ${timeViews.seconds}`,
|
package/locales/skSK.js
CHANGED
|
@@ -33,10 +33,7 @@ const skSKPickers = {
|
|
|
33
33
|
timePickerToolbarTitle: 'Vyberte čas',
|
|
34
34
|
dateRangePickerToolbarTitle: 'Vyberete rozmedzie dátumov',
|
|
35
35
|
// Clock labels
|
|
36
|
-
clockLabelText: (view, time, adapter) => {
|
|
37
|
-
var _timeViews$view;
|
|
38
|
-
return `${(_timeViews$view = timeViews[view]) != null ? _timeViews$view : view} vybraný. ${time === null ? 'Nie je vybraný čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`;
|
|
39
|
-
},
|
|
36
|
+
clockLabelText: (view, time, adapter) => `${timeViews[view] ?? view} vybraný. ${time === null ? 'Nie je vybraný čas' : `Vybraný čas je ${adapter.format(time, 'fullTime')}`}`,
|
|
40
37
|
hoursClockNumberText: hours => `${hours} hodín`,
|
|
41
38
|
minutesClockNumberText: minutes => `${minutes} minút`,
|
|
42
39
|
secondsClockNumberText: seconds => `${seconds} sekúnd`,
|
|
@@ -240,6 +240,10 @@ export class AdapterLuxon {
|
|
|
240
240
|
// Extract escaped section to avoid extending them
|
|
241
241
|
const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;
|
|
242
242
|
|
|
243
|
+
// This RegExp tests if a string is only mad of supported tokens
|
|
244
|
+
const validTokens = [...Object.keys(this.formatTokenMap), 'yyyyy'];
|
|
245
|
+
const isWordComposedOfTokens = new RegExp(`^(${validTokens.join('|')})+$`);
|
|
246
|
+
|
|
243
247
|
// Extract words to test if they are a token or a word to escape.
|
|
244
248
|
const catchWordsRegexp = /(?:^|[^a-z])([a-z]+)(?:[^a-z]|$)|([a-z]+)/gi;
|
|
245
249
|
return format.match(catchEscapedSectionsRegexp).map(token => {
|
|
@@ -250,12 +254,13 @@ export class AdapterLuxon {
|
|
|
250
254
|
const expandedToken = DateTime.expandFormat(token, {
|
|
251
255
|
locale: this.locale
|
|
252
256
|
});
|
|
253
|
-
return expandedToken.replace(catchWordsRegexp, (
|
|
257
|
+
return expandedToken.replace(catchWordsRegexp, (substring, g1, g2) => {
|
|
254
258
|
const word = g1 || g2; // words are either in group 1 or group 2
|
|
255
|
-
|
|
256
|
-
|
|
259
|
+
|
|
260
|
+
if (isWordComposedOfTokens.test(word)) {
|
|
261
|
+
return substring;
|
|
257
262
|
}
|
|
258
|
-
return `'${
|
|
263
|
+
return `'${substring}'`;
|
|
259
264
|
});
|
|
260
265
|
}).join('')
|
|
261
266
|
// The returned format can contain `yyyyy` which means year between 4 and 6 digits.
|
|
@@ -487,7 +487,7 @@ process.env.NODE_ENV !== "production" ? DateCalendar.propTypes = {
|
|
|
487
487
|
/**
|
|
488
488
|
* Disable specific date.
|
|
489
489
|
*
|
|
490
|
-
* Warning: This function can be called multiple times (
|
|
490
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
491
491
|
*
|
|
492
492
|
* @template TDate
|
|
493
493
|
* @param {TDate} day The date to test.
|
|
@@ -241,7 +241,7 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
241
241
|
/**
|
|
242
242
|
* Disable specific date.
|
|
243
243
|
*
|
|
244
|
-
* Warning: This function can be called multiple times (
|
|
244
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
245
245
|
*
|
|
246
246
|
* @template TDate
|
|
247
247
|
* @param {TDate} day The date to test.
|
|
@@ -266,7 +266,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
266
266
|
/**
|
|
267
267
|
* Disable specific date.
|
|
268
268
|
*
|
|
269
|
-
* Warning: This function can be called multiple times (
|
|
269
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
270
270
|
*
|
|
271
271
|
* @template TDate
|
|
272
272
|
* @param {TDate} day The date to test.
|
|
@@ -274,7 +274,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
274
274
|
/**
|
|
275
275
|
* Disable specific date.
|
|
276
276
|
*
|
|
277
|
-
* Warning: This function can be called multiple times (
|
|
277
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
278
278
|
*
|
|
279
279
|
* @template TDate
|
|
280
280
|
* @param {TDate} day The date to test.
|
|
@@ -304,7 +304,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
304
304
|
/**
|
|
305
305
|
* Disable specific date.
|
|
306
306
|
*
|
|
307
|
-
* Warning: This function can be called multiple times (
|
|
307
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
308
308
|
*
|
|
309
309
|
* @template TDate
|
|
310
310
|
* @param {TDate} day The date to test.
|
|
@@ -281,7 +281,7 @@ DesktopDatePicker.propTypes = {
|
|
|
281
281
|
/**
|
|
282
282
|
* Disable specific date.
|
|
283
283
|
*
|
|
284
|
-
* Warning: This function can be called multiple times (
|
|
284
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
285
285
|
*
|
|
286
286
|
* @template TDate
|
|
287
287
|
* @param {TDate} day The date to test.
|
|
@@ -1,19 +1,64 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["openTo", "focusedView", "timeViewsCount"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
import { resolveComponentProps } from '@mui/base/utils';
|
|
5
7
|
import { refType } from '@mui/utils';
|
|
8
|
+
import Divider from '@mui/material/Divider';
|
|
6
9
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
7
10
|
import { DateTimeField } from '../DateTimeField';
|
|
8
11
|
import { useDateTimePickerDefaultizedProps } from '../DateTimePicker/shared';
|
|
9
12
|
import { renderDateViewCalendar } from '../dateViewRenderers/dateViewRenderers';
|
|
10
|
-
import { renderDesktopDateTimeView } from '../dateTimeViewRenderers';
|
|
11
13
|
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
|
|
12
14
|
import { validateDateTime } from '../internals/utils/validation/validateDateTime';
|
|
13
15
|
import { CalendarIcon } from '../icons';
|
|
14
16
|
import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
15
17
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
16
18
|
import { resolveDateTimeFormat, resolveTimeViewsResponse } from '../internals/utils/date-time-utils';
|
|
19
|
+
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from '../timeViewRenderers';
|
|
20
|
+
import { VIEW_HEIGHT, isDatePickerView, isInternalTimeView } from '../internals';
|
|
21
|
+
import { multiSectionDigitalClockClasses, multiSectionDigitalClockSectionClasses } from '../MultiSectionDigitalClock';
|
|
22
|
+
import { digitalClockClasses } from '../DigitalClock';
|
|
23
|
+
import { DesktopDateTimePickerLayout } from './DesktopDateTimePickerLayout';
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
+
const rendererInterceptor = function rendererInterceptor(inViewRenderers, popperView, rendererProps) {
|
|
27
|
+
const {
|
|
28
|
+
openTo,
|
|
29
|
+
focusedView,
|
|
30
|
+
timeViewsCount
|
|
31
|
+
} = rendererProps,
|
|
32
|
+
otherProps = _objectWithoutPropertiesLoose(rendererProps, _excluded);
|
|
33
|
+
const finalProps = _extends({}, otherProps, {
|
|
34
|
+
focusedView: null,
|
|
35
|
+
sx: [{
|
|
36
|
+
[`&.${multiSectionDigitalClockClasses.root}`]: {
|
|
37
|
+
borderBottom: 0
|
|
38
|
+
},
|
|
39
|
+
[`&.${multiSectionDigitalClockClasses.root}, .${multiSectionDigitalClockSectionClasses.root}, &.${digitalClockClasses.root}`]: {
|
|
40
|
+
maxHeight: VIEW_HEIGHT
|
|
41
|
+
}
|
|
42
|
+
}]
|
|
43
|
+
});
|
|
44
|
+
const isTimeViewActive = isInternalTimeView(popperView);
|
|
45
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
46
|
+
children: [inViewRenderers[!isTimeViewActive ? popperView : 'day']?.(_extends({}, rendererProps, {
|
|
47
|
+
view: !isTimeViewActive ? popperView : 'day',
|
|
48
|
+
focusedView: focusedView && isDatePickerView(focusedView) ? focusedView : null,
|
|
49
|
+
views: rendererProps.views.filter(isDatePickerView)
|
|
50
|
+
})), timeViewsCount > 0 && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
51
|
+
children: [/*#__PURE__*/_jsx(Divider, {
|
|
52
|
+
orientation: "vertical"
|
|
53
|
+
}), inViewRenderers[isTimeViewActive ? popperView : 'hours']?.(_extends({}, finalProps, {
|
|
54
|
+
view: isTimeViewActive ? popperView : 'hours',
|
|
55
|
+
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
56
|
+
openTo: isInternalTimeView(openTo) ? openTo : 'hours',
|
|
57
|
+
views: rendererProps.views.filter(isInternalTimeView)
|
|
58
|
+
}))]
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
};
|
|
17
62
|
/**
|
|
18
63
|
* Demos:
|
|
19
64
|
*
|
|
@@ -33,32 +78,24 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
33
78
|
const {
|
|
34
79
|
shouldRenderTimeInASingleColumn,
|
|
35
80
|
thresholdToRenderTimeInASingleColumn,
|
|
36
|
-
views,
|
|
81
|
+
views: resolvedViews,
|
|
37
82
|
timeSteps
|
|
38
83
|
} = resolveTimeViewsResponse(defaultizedProps);
|
|
39
|
-
const
|
|
40
|
-
const viewRenderers =
|
|
41
|
-
// we can only ensure the expected two-column layout if none of the renderers are overridden
|
|
42
|
-
shouldUseNewRenderer ? {
|
|
43
|
-
day: renderDesktopDateTimeView,
|
|
44
|
-
month: renderDesktopDateTimeView,
|
|
45
|
-
year: renderDesktopDateTimeView,
|
|
46
|
-
hours: renderDesktopDateTimeView,
|
|
47
|
-
minutes: renderDesktopDateTimeView,
|
|
48
|
-
seconds: renderDesktopDateTimeView,
|
|
49
|
-
meridiem: renderDesktopDateTimeView
|
|
50
|
-
} : _extends({
|
|
84
|
+
const renderTimeView = shouldRenderTimeInASingleColumn ? renderDigitalClockTimeView : renderMultiSectionDigitalClockTimeView;
|
|
85
|
+
const viewRenderers = _extends({
|
|
51
86
|
day: renderDateViewCalendar,
|
|
52
87
|
month: renderDateViewCalendar,
|
|
53
88
|
year: renderDateViewCalendar,
|
|
54
|
-
hours:
|
|
55
|
-
minutes:
|
|
56
|
-
seconds:
|
|
57
|
-
meridiem:
|
|
89
|
+
hours: renderTimeView,
|
|
90
|
+
minutes: renderTimeView,
|
|
91
|
+
seconds: renderTimeView,
|
|
92
|
+
meridiem: renderTimeView
|
|
58
93
|
}, defaultizedProps.viewRenderers);
|
|
59
94
|
const ampmInClock = defaultizedProps.ampmInClock ?? true;
|
|
60
|
-
//
|
|
61
|
-
const
|
|
95
|
+
// Need to avoid adding the `meridiem` view when unexpected renderer is specified
|
|
96
|
+
const shouldHoursRendererContainMeridiemView = viewRenderers.hours?.name === renderMultiSectionDigitalClockTimeView.name;
|
|
97
|
+
const views = !shouldHoursRendererContainMeridiemView ? resolvedViews.filter(view => view !== 'meridiem') : resolvedViews;
|
|
98
|
+
const actionBarActions = shouldRenderTimeInASingleColumn ? [] : ['accept'];
|
|
62
99
|
|
|
63
100
|
// Props with the default values specific to the desktop variant
|
|
64
101
|
const props = _extends({}, defaultizedProps, {
|
|
@@ -72,6 +109,7 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
72
109
|
shouldRenderTimeInASingleColumn,
|
|
73
110
|
slots: _extends({
|
|
74
111
|
field: DateTimeField,
|
|
112
|
+
layout: DesktopDateTimePickerLayout,
|
|
75
113
|
openPickerIcon: CalendarIcon
|
|
76
114
|
}, defaultizedProps.slots),
|
|
77
115
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
@@ -81,14 +119,14 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
81
119
|
toolbar: _extends({
|
|
82
120
|
hidden: true,
|
|
83
121
|
ampmInClock,
|
|
84
|
-
toolbarVariant:
|
|
122
|
+
toolbarVariant: 'desktop'
|
|
85
123
|
}, defaultizedProps.slotProps?.toolbar),
|
|
86
124
|
tabs: _extends({
|
|
87
125
|
hidden: true
|
|
88
126
|
}, defaultizedProps.slotProps?.tabs),
|
|
89
|
-
actionBar: _extends({
|
|
127
|
+
actionBar: ownerState => _extends({
|
|
90
128
|
actions: actionBarActions
|
|
91
|
-
}, defaultizedProps.slotProps?.actionBar)
|
|
129
|
+
}, resolveComponentProps(defaultizedProps.slotProps?.actionBar, ownerState))
|
|
92
130
|
})
|
|
93
131
|
});
|
|
94
132
|
const {
|
|
@@ -98,7 +136,8 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
98
136
|
valueManager: singleItemValueManager,
|
|
99
137
|
valueType: 'date-time',
|
|
100
138
|
getOpenDialogAriaText: props.localeText?.openDatePickerDialogue ?? localeText.openDatePickerDialogue,
|
|
101
|
-
validator: validateDateTime
|
|
139
|
+
validator: validateDateTime,
|
|
140
|
+
rendererInterceptor
|
|
102
141
|
});
|
|
103
142
|
return renderPicker();
|
|
104
143
|
});
|
|
@@ -357,7 +396,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
357
396
|
/**
|
|
358
397
|
* Disable specific date.
|
|
359
398
|
*
|
|
360
|
-
* Warning: This function can be called multiple times (
|
|
399
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
361
400
|
*
|
|
362
401
|
* @template TDate
|
|
363
402
|
* @param {TDate} day The date to test.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import Divider from '@mui/material/Divider';
|
|
5
|
+
import { PickersLayoutContentWrapper, PickersLayoutRoot, pickersLayoutClasses, usePickerLayout } from '../PickersLayout';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* @ignore - internal component.
|
|
10
|
+
*/
|
|
11
|
+
function DesktopDateTimePickerLayout(props) {
|
|
12
|
+
const {
|
|
13
|
+
toolbar,
|
|
14
|
+
tabs,
|
|
15
|
+
content,
|
|
16
|
+
actionBar,
|
|
17
|
+
shortcuts
|
|
18
|
+
} = usePickerLayout(props);
|
|
19
|
+
const {
|
|
20
|
+
sx,
|
|
21
|
+
className,
|
|
22
|
+
isLandscape,
|
|
23
|
+
ref
|
|
24
|
+
} = props;
|
|
25
|
+
const isActionBarVisible = actionBar && (actionBar.props.actions?.length ?? 0) > 0;
|
|
26
|
+
return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
|
|
27
|
+
ref: ref,
|
|
28
|
+
className: clsx(className, pickersLayoutClasses.root),
|
|
29
|
+
sx: [{
|
|
30
|
+
[`& .${pickersLayoutClasses.tabs}`]: {
|
|
31
|
+
gridRow: 4,
|
|
32
|
+
gridColumn: '1 / 4'
|
|
33
|
+
},
|
|
34
|
+
[`& .${pickersLayoutClasses.actionBar}`]: {
|
|
35
|
+
gridRow: 5
|
|
36
|
+
}
|
|
37
|
+
}, ...(Array.isArray(sx) ? sx : [sx])],
|
|
38
|
+
ownerState: props,
|
|
39
|
+
children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsxs(PickersLayoutContentWrapper, {
|
|
40
|
+
className: pickersLayoutClasses.contentWrapper,
|
|
41
|
+
sx: {
|
|
42
|
+
display: 'grid'
|
|
43
|
+
},
|
|
44
|
+
children: [content, tabs, isActionBarVisible && /*#__PURE__*/_jsx(Divider, {
|
|
45
|
+
sx: {
|
|
46
|
+
gridRow: 3,
|
|
47
|
+
gridColumn: '1 / 4'
|
|
48
|
+
}
|
|
49
|
+
})]
|
|
50
|
+
}), actionBar]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes = {
|
|
54
|
+
// ----------------------------- Warning --------------------------------
|
|
55
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
56
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
57
|
+
// ----------------------------------------------------------------------
|
|
58
|
+
children: PropTypes.node,
|
|
59
|
+
/**
|
|
60
|
+
* Override or extend the styles applied to the component.
|
|
61
|
+
*/
|
|
62
|
+
classes: PropTypes.object,
|
|
63
|
+
className: PropTypes.string,
|
|
64
|
+
disabled: PropTypes.bool,
|
|
65
|
+
isLandscape: PropTypes.bool.isRequired,
|
|
66
|
+
isValid: PropTypes.func.isRequired,
|
|
67
|
+
onAccept: PropTypes.func.isRequired,
|
|
68
|
+
onCancel: PropTypes.func.isRequired,
|
|
69
|
+
onChange: PropTypes.func.isRequired,
|
|
70
|
+
onClear: PropTypes.func.isRequired,
|
|
71
|
+
onClose: PropTypes.func.isRequired,
|
|
72
|
+
onDismiss: PropTypes.func.isRequired,
|
|
73
|
+
onOpen: PropTypes.func.isRequired,
|
|
74
|
+
onSelectShortcut: PropTypes.func.isRequired,
|
|
75
|
+
onSetToday: PropTypes.func.isRequired,
|
|
76
|
+
onViewChange: PropTypes.func.isRequired,
|
|
77
|
+
/**
|
|
78
|
+
* Force rendering in particular orientation.
|
|
79
|
+
*/
|
|
80
|
+
orientation: PropTypes.oneOf(['landscape', 'portrait']),
|
|
81
|
+
readOnly: PropTypes.bool,
|
|
82
|
+
/**
|
|
83
|
+
* The props used for each component slot.
|
|
84
|
+
* @default {}
|
|
85
|
+
*/
|
|
86
|
+
slotProps: PropTypes.object,
|
|
87
|
+
/**
|
|
88
|
+
* Overridable component slots.
|
|
89
|
+
* @default {}
|
|
90
|
+
*/
|
|
91
|
+
slots: PropTypes.object,
|
|
92
|
+
/**
|
|
93
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
94
|
+
*/
|
|
95
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
96
|
+
value: PropTypes.any,
|
|
97
|
+
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
98
|
+
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired,
|
|
99
|
+
wrapperVariant: PropTypes.oneOf(['desktop', 'mobile'])
|
|
100
|
+
} : void 0;
|
|
101
|
+
export { DesktopDateTimePickerLayout };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { DesktopDateTimePicker } from './DesktopDateTimePicker';
|
|
1
|
+
export { DesktopDateTimePicker } from './DesktopDateTimePicker';
|
|
2
|
+
export { DesktopDateTimePickerLayout } from './DesktopDateTimePickerLayout';
|
|
@@ -278,7 +278,7 @@ MobileDatePicker.propTypes = {
|
|
|
278
278
|
/**
|
|
279
279
|
* Disable specific date.
|
|
280
280
|
*
|
|
281
|
-
* Warning: This function can be called multiple times (
|
|
281
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
282
282
|
*
|
|
283
283
|
* @template TDate
|
|
284
284
|
* @param {TDate} day The date to test.
|
|
@@ -326,7 +326,7 @@ MobileDateTimePicker.propTypes = {
|
|
|
326
326
|
/**
|
|
327
327
|
* Disable specific date.
|
|
328
328
|
*
|
|
329
|
-
* Warning: This function can be called multiple times (
|
|
329
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
330
330
|
*
|
|
331
331
|
* @template TDate
|
|
332
332
|
* @param {TDate} day The date to test.
|
|
@@ -208,7 +208,7 @@ StaticDatePicker.propTypes = {
|
|
|
208
208
|
/**
|
|
209
209
|
* Disable specific date.
|
|
210
210
|
*
|
|
211
|
-
* Warning: This function can be called multiple times (
|
|
211
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
212
212
|
*
|
|
213
213
|
* @template TDate
|
|
214
214
|
* @param {TDate} day The date to test.
|
|
@@ -256,7 +256,7 @@ StaticDateTimePicker.propTypes = {
|
|
|
256
256
|
/**
|
|
257
257
|
* Disable specific date.
|
|
258
258
|
*
|
|
259
|
-
* Warning: This function can be called multiple times (
|
|
259
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
260
260
|
*
|
|
261
261
|
* @template TDate
|
|
262
262
|
* @param {TDate} day The date to test.
|
package/modern/index.js
CHANGED
|
@@ -146,7 +146,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
146
146
|
// TODO This behavior is not tested automatically
|
|
147
147
|
// It's unclear whether this is due to different update semantics in test (batched in act() vs discrete on click).
|
|
148
148
|
// Or if this is a timing related issues due to different Transition components
|
|
149
|
-
// Once we get rid of all the manual scheduling (
|
|
149
|
+
// Once we get rid of all the manual scheduling (for example setTimeout(update, 0)) we can revisit this code+test.
|
|
150
150
|
if (active) {
|
|
151
151
|
const doc = ownerDocument(nodeRef.current);
|
|
152
152
|
doc.addEventListener('click', handleClickAway);
|
|
@@ -152,49 +152,53 @@ const buildSections = params => {
|
|
|
152
152
|
const sections = [];
|
|
153
153
|
let startSeparator = '';
|
|
154
154
|
|
|
155
|
-
// This RegExp
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
// This RegExp tests if the beginning of a string corresponds to a supported token
|
|
156
|
+
const validTokens = Object.keys(utils.formatTokenMap).sort((a, b) => b.length - a.length); // Sort to put longest word first
|
|
157
|
+
|
|
158
|
+
const regExpFirstWordInFormat = /^([a-zA-Z]+)/;
|
|
159
|
+
const regExpWordOnlyComposedOfTokens = new RegExp(`^(${validTokens.join('|')})*$`);
|
|
160
|
+
const regExpFirstTokenInWord = new RegExp(`^(${validTokens.join('|')})`);
|
|
161
|
+
const getEscapedPartOfCurrentChar = i => escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
|
|
162
|
+
let i = 0;
|
|
163
|
+
while (i < expandedFormat.length) {
|
|
164
|
+
const escapedPartOfCurrentChar = getEscapedPartOfCurrentChar(i);
|
|
163
165
|
const isEscapedChar = escapedPartOfCurrentChar != null;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
const firstWordInFormat = regExpFirstWordInFormat.exec(expandedFormat.slice(i))?.[1];
|
|
167
|
+
|
|
168
|
+
// The first word in the format is only composed of tokens.
|
|
169
|
+
// We extract those tokens to create a new sections.
|
|
170
|
+
if (!isEscapedChar && firstWordInFormat != null && regExpWordOnlyComposedOfTokens.test(firstWordInFormat)) {
|
|
171
|
+
let word = firstWordInFormat;
|
|
172
|
+
while (word.length > 0) {
|
|
173
|
+
const firstWord = regExpFirstTokenInWord.exec(word)[1];
|
|
174
|
+
word = word.slice(firstWord.length);
|
|
175
|
+
sections.push(createSection(_extends({}, params, {
|
|
176
|
+
now,
|
|
177
|
+
token: firstWord,
|
|
178
|
+
startSeparator
|
|
179
|
+
})));
|
|
180
|
+
startSeparator = '';
|
|
181
|
+
}
|
|
182
|
+
i += firstWordInFormat.length;
|
|
183
|
+
}
|
|
184
|
+
// The remaining format does not start with a token,
|
|
185
|
+
// We take the first character and add it to the current section's end separator.
|
|
186
|
+
else {
|
|
187
|
+
const char = expandedFormat[i];
|
|
188
|
+
|
|
170
189
|
// If we are on the opening or closing character of an escaped part of the format,
|
|
171
190
|
// Then we ignore this character.
|
|
172
191
|
const isEscapeBoundary = isEscapedChar && escapedPartOfCurrentChar?.start === i || escapedPartOfCurrentChar?.end === i;
|
|
173
192
|
if (!isEscapeBoundary) {
|
|
174
|
-
if (currentTokenValue !== '') {
|
|
175
|
-
sections.push(createSection(_extends({}, params, {
|
|
176
|
-
now,
|
|
177
|
-
token: currentTokenValue,
|
|
178
|
-
startSeparator
|
|
179
|
-
})));
|
|
180
|
-
currentTokenValue = '';
|
|
181
|
-
}
|
|
182
193
|
if (sections.length === 0) {
|
|
183
194
|
startSeparator += char;
|
|
184
195
|
} else {
|
|
185
|
-
startSeparator = '';
|
|
186
196
|
sections[sections.length - 1].endSeparator += char;
|
|
187
197
|
}
|
|
188
198
|
}
|
|
199
|
+
i += 1;
|
|
189
200
|
}
|
|
190
201
|
}
|
|
191
|
-
if (currentTokenValue !== '') {
|
|
192
|
-
sections.push(createSection(_extends({}, params, {
|
|
193
|
-
now,
|
|
194
|
-
token: currentTokenValue,
|
|
195
|
-
startSeparator
|
|
196
|
-
})));
|
|
197
|
-
}
|
|
198
202
|
if (sections.length === 0 && startSeparator.length > 0) {
|
|
199
203
|
sections.push({
|
|
200
204
|
type: 'empty',
|