@mui/x-date-pickers 6.0.2 → 6.0.4
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/index.js +1 -0
- package/AdapterDateFnsJalali/index.js +69 -0
- package/AdapterDayjs/index.js +5 -0
- package/AdapterLuxon/index.js +13 -3
- package/AdapterMoment/index.js +5 -0
- package/AdapterMomentHijri/index.js +5 -0
- package/AdapterMomentJalaali/index.js +5 -0
- package/CHANGELOG.md +119 -5
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +1 -1
- package/DateCalendar/index.d.ts +0 -1
- package/DateField/DateField.js +4 -0
- package/DateField/DateField.types.d.ts +2 -2
- package/DateField/useDateField.js +5 -3
- package/DatePicker/DatePickerToolbar.d.ts +1 -1
- package/DatePicker/shared.d.ts +2 -2
- package/DateTimeField/DateTimeField.js +4 -0
- package/DateTimeField/DateTimeField.types.d.ts +2 -2
- package/DateTimeField/useDateTimeField.js +5 -3
- package/DateTimePicker/DateTimePickerTabs.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.d.ts +1 -1
- package/DateTimePicker/shared.d.ts +1 -2
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.types.d.ts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +1 -1
- package/MobileTimePicker/MobileTimePicker.types.d.ts +1 -1
- package/PickersDay/PickersDay.js +4 -4
- package/PickersLayout/PickersLayout.d.ts +1 -1
- package/PickersLayout/PickersLayout.types.d.ts +1 -1
- package/PickersLayout/index.d.ts +1 -1
- package/PickersLayout/usePickerLayout.d.ts +1 -1
- package/README.md +1 -1
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -1
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -1
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -1
- package/TimeClock/Clock.d.ts +1 -1
- package/TimeClock/ClockPointer.d.ts +1 -1
- package/TimeClock/TimeClock.types.d.ts +1 -1
- package/TimeClock/index.d.ts +0 -1
- package/TimeField/TimeField.js +4 -0
- package/TimeField/TimeField.types.d.ts +2 -2
- package/TimeField/useTimeField.js +5 -3
- package/TimePicker/TimePickerToolbar.d.ts +1 -1
- package/TimePicker/shared.d.ts +1 -2
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/index.d.ts +1 -6
- package/index.js +4 -2
- package/internals/components/PickersToolbar.d.ts +1 -1
- package/internals/demo/DemoContainer.js +15 -7
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -7
- package/internals/hooks/useField/index.d.ts +2 -2
- package/internals/hooks/useField/index.js +1 -1
- package/internals/hooks/useField/useField.d.ts +3 -2
- package/internals/hooks/useField/useField.js +61 -30
- package/internals/hooks/useField/useField.types.d.ts +48 -116
- package/internals/hooks/useField/useField.utils.d.ts +7 -5
- package/internals/hooks/useField/useField.utils.js +68 -50
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +2 -1
- package/internals/hooks/useField/useFieldState.d.ts +4 -3
- package/internals/hooks/useField/useFieldState.js +86 -65
- package/internals/hooks/useIsLandscape.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -7
- package/internals/hooks/usePicker/usePicker.d.ts +2 -2
- package/internals/hooks/usePicker/usePicker.types.d.ts +4 -4
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.d.ts +9 -8
- package/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +2 -2
- package/internals/hooks/useViews.d.ts +1 -1
- package/internals/hooks/useViews.js +8 -0
- package/internals/hooks/validation/models.d.ts +1 -1
- package/internals/hooks/validation/useDateTimeValidation.d.ts +3 -3
- package/internals/hooks/validation/useDateValidation.d.ts +2 -2
- package/internals/hooks/validation/useTimeValidation.d.ts +2 -2
- package/internals/index.d.ts +4 -8
- package/internals/index.js +2 -2
- package/internals/models/fields.d.ts +2 -20
- package/internals/models/index.d.ts +0 -1
- package/internals/models/index.js +0 -1
- package/internals/models/muiPickersAdapter.d.ts +1 -10
- package/internals/models/props/basePickerProps.d.ts +3 -3
- package/internals/models/props/tabs.d.ts +1 -1
- package/internals/models/props/toolbar.d.ts +1 -1
- package/internals/utils/date-utils.d.ts +1 -0
- package/internals/utils/date-utils.js +6 -0
- package/internals/utils/time-utils.d.ts +2 -1
- package/internals/utils/utils.d.ts +1 -1
- package/internals/utils/utils.js +3 -3
- package/internals/utils/validation.d.ts +1 -1
- package/internals/utils/valueManagers.d.ts +2 -4
- package/internals/utils/valueManagers.js +11 -12
- package/internals/utils/views.d.ts +1 -1
- package/legacy/AdapterDateFns/index.js +1 -0
- package/legacy/AdapterDateFnsJalali/index.js +69 -0
- package/legacy/AdapterDayjs/index.js +5 -0
- package/legacy/AdapterLuxon/index.js +13 -3
- package/legacy/AdapterMoment/index.js +5 -0
- package/legacy/AdapterMomentHijri/index.js +5 -0
- package/legacy/AdapterMomentJalaali/index.js +5 -0
- package/legacy/DateField/DateField.js +4 -0
- package/legacy/DateField/useDateField.js +4 -2
- package/legacy/DateTimeField/DateTimeField.js +4 -0
- package/legacy/DateTimeField/useDateTimeField.js +4 -2
- package/legacy/PickersDay/PickersDay.js +4 -4
- package/legacy/TimeField/TimeField.js +4 -0
- package/legacy/TimeField/useTimeField.js +4 -2
- package/legacy/index.js +4 -2
- package/legacy/internals/demo/DemoContainer.js +12 -6
- package/legacy/internals/hooks/useField/index.js +1 -1
- package/legacy/internals/hooks/useField/useField.js +86 -44
- package/legacy/internals/hooks/useField/useField.utils.js +76 -54
- package/legacy/internals/hooks/useField/useFieldState.js +92 -72
- package/legacy/internals/hooks/usePicker/usePickerValue.js +9 -13
- package/legacy/internals/hooks/useViews.js +10 -0
- package/legacy/internals/index.js +2 -2
- package/legacy/internals/models/index.js +0 -1
- package/legacy/internals/utils/date-utils.js +6 -0
- package/legacy/internals/utils/utils.js +3 -3
- package/legacy/internals/utils/valueManagers.js +12 -19
- package/legacy/locales/daDK.js +91 -0
- package/legacy/locales/faIR.js +33 -16
- package/legacy/locales/nbNO.js +12 -10
- package/legacy/locales/nlNL.js +12 -10
- package/legacy/locales/plPL.js +12 -10
- package/legacy/locales/svSE.js +12 -10
- package/legacy/models/index.js +3 -0
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/locales/daDK.d.ts +51 -0
- package/locales/daDK.js +59 -0
- package/locales/faIR.js +13 -16
- package/locales/nbNO.js +8 -10
- package/locales/nlNL.d.ts +4 -4
- package/locales/nlNL.js +8 -10
- package/locales/plPL.js +8 -10
- package/locales/svSE.js +8 -10
- package/locales/utils/pickersLocaleTextApi.d.ts +2 -1
- package/models/fields.d.ts +117 -0
- package/models/fields.js +1 -0
- package/models/index.d.ts +3 -0
- package/models/index.js +3 -0
- package/models/package.json +6 -0
- package/models/validation.d.ts +8 -0
- package/models/validation.js +1 -0
- package/models/views.js +1 -0
- package/modern/AdapterDateFns/index.js +1 -0
- package/modern/AdapterDateFnsJalali/index.js +69 -0
- package/modern/AdapterDayjs/index.js +5 -0
- package/modern/AdapterLuxon/index.js +13 -3
- package/modern/AdapterMoment/index.js +5 -0
- package/modern/AdapterMomentHijri/index.js +5 -0
- package/modern/AdapterMomentJalaali/index.js +5 -0
- package/modern/DateField/DateField.js +4 -0
- package/modern/DateField/useDateField.js +5 -3
- package/modern/DateTimeField/DateTimeField.js +4 -0
- package/modern/DateTimeField/useDateTimeField.js +5 -3
- package/modern/PickersDay/PickersDay.js +4 -4
- package/modern/TimeField/TimeField.js +4 -0
- package/modern/TimeField/useTimeField.js +5 -3
- package/modern/index.js +4 -2
- package/modern/internals/demo/DemoContainer.js +15 -7
- package/modern/internals/hooks/useField/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +59 -29
- package/modern/internals/hooks/useField/useField.utils.js +68 -50
- package/modern/internals/hooks/useField/useFieldState.js +86 -65
- package/modern/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/modern/internals/hooks/useViews.js +8 -0
- package/modern/internals/index.js +2 -2
- package/modern/internals/models/index.js +0 -1
- package/modern/internals/utils/date-utils.js +6 -0
- package/modern/internals/utils/utils.js +3 -3
- package/modern/internals/utils/valueManagers.js +11 -12
- package/modern/locales/daDK.js +56 -0
- package/modern/locales/faIR.js +13 -16
- package/modern/locales/nbNO.js +8 -10
- package/modern/locales/nlNL.js +8 -10
- package/modern/locales/plPL.js +8 -10
- package/modern/locales/svSE.js +8 -10
- package/modern/models/fields.js +1 -0
- package/modern/models/index.js +3 -0
- package/modern/models/validation.js +1 -0
- package/modern/models/views.js +1 -0
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/node/AdapterDateFns/index.js +1 -0
- package/node/AdapterDateFnsJalali/index.js +69 -0
- package/node/AdapterDayjs/index.js +5 -0
- package/node/AdapterLuxon/index.js +13 -3
- package/node/AdapterMoment/index.js +5 -0
- package/node/AdapterMomentHijri/index.js +5 -0
- package/node/AdapterMomentJalaali/index.js +5 -0
- package/node/DateField/DateField.js +4 -0
- package/node/DateField/useDateField.js +5 -3
- package/node/DateTimeField/DateTimeField.js +4 -0
- package/node/DateTimeField/useDateTimeField.js +5 -3
- package/node/PickersDay/PickersDay.js +4 -4
- package/node/TimeField/TimeField.js +4 -0
- package/node/TimeField/useTimeField.js +5 -3
- package/node/index.js +14 -2
- package/node/internals/demo/DemoContainer.js +15 -7
- package/node/internals/hooks/useField/index.js +0 -6
- package/node/internals/hooks/useField/useField.js +58 -28
- package/node/internals/hooks/useField/useField.utils.js +71 -52
- package/node/internals/hooks/useField/useFieldState.js +85 -64
- package/node/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/node/internals/hooks/useViews.js +8 -0
- package/node/internals/index.js +6 -12
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/date-utils.js +9 -2
- package/node/internals/utils/utils.js +3 -3
- package/node/internals/utils/valueManagers.js +9 -10
- package/node/locales/daDK.js +62 -0
- package/node/locales/faIR.js +13 -16
- package/node/locales/nbNO.js +8 -10
- package/node/locales/nlNL.js +8 -10
- package/node/locales/plPL.js +8 -10
- package/node/locales/svSE.js +8 -10
- package/node/models/index.js +38 -0
- package/node/models/validation.js +5 -0
- package/node/models/views.js +5 -0
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/package.json +2 -2
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +2 -3
- package/themeAugmentation/props.d.ts +1 -1
- package/timeViewRenderers/timeViewRenderers.d.ts +1 -1
- /package/{internals/models/views.js → legacy/models/fields.js} +0 -0
- /package/legacy/{internals/models/views.js → models/validation.js} +0 -0
- /package/{modern/internals → legacy}/models/views.js +0 -0
- /package/{internals/models → models}/views.d.ts +0 -0
- /package/node/{internals/models/views.js → models/fields.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "disableFuture", "disablePast", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "ampm"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "disableFuture", "disablePast", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateTime } from '../internals/hooks/validation/useTimeValidation';
|
|
@@ -37,6 +37,7 @@ export var useTimeField = function useTimeField(_ref) {
|
|
|
37
37
|
selectedSections = _useDefaultizedTimeFi.selectedSections,
|
|
38
38
|
onSelectedSectionsChange = _useDefaultizedTimeFi.onSelectedSectionsChange,
|
|
39
39
|
ampm = _useDefaultizedTimeFi.ampm,
|
|
40
|
+
unstableFieldRef = _useDefaultizedTimeFi.unstableFieldRef,
|
|
40
41
|
other = _objectWithoutProperties(_useDefaultizedTimeFi, _excluded);
|
|
41
42
|
return useField({
|
|
42
43
|
inputRef: inputRef,
|
|
@@ -58,7 +59,8 @@ export var useTimeField = function useTimeField(_ref) {
|
|
|
58
59
|
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
59
60
|
selectedSections: selectedSections,
|
|
60
61
|
onSelectedSectionsChange: onSelectedSectionsChange,
|
|
61
|
-
ampm: ampm
|
|
62
|
+
ampm: ampm,
|
|
63
|
+
unstableFieldRef: unstableFieldRef
|
|
62
64
|
},
|
|
63
65
|
valueManager: singleItemValueManager,
|
|
64
66
|
fieldValueManager: singleItemFieldValueManager,
|
package/legacy/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers v6.0.
|
|
2
|
+
* @mui/x-date-pickers v6.0.4
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -14,6 +14,7 @@ export * from './locales';
|
|
|
14
14
|
export * from './DateField';
|
|
15
15
|
export * from './TimeField';
|
|
16
16
|
export * from './DateTimeField';
|
|
17
|
+
|
|
17
18
|
// Calendars
|
|
18
19
|
export * from './DateCalendar';
|
|
19
20
|
export * from './MonthCalendar';
|
|
@@ -42,4 +43,5 @@ export * from './timeViewRenderers';
|
|
|
42
43
|
export * from './PickersLayout';
|
|
43
44
|
export * from './PickersActionBar';
|
|
44
45
|
export * from './PickersShortcuts';
|
|
45
|
-
export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
|
|
46
|
+
export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './internals/utils/utils';
|
|
47
|
+
export * from './models';
|
|
@@ -95,12 +95,18 @@ export function DemoContainer(props) {
|
|
|
95
95
|
if (childrenTypes.has('UI-view')) {
|
|
96
96
|
// noop
|
|
97
97
|
} else if (childrenTypes.has('single-input-range-field')) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
if (!childrenSupportedSections.has('date-time')) {
|
|
99
|
+
sx = _extends({}, sx, _defineProperty({}, "& > .".concat(textFieldClasses.root), {
|
|
100
|
+
minWidth: 300
|
|
101
|
+
}));
|
|
102
|
+
} else {
|
|
103
|
+
sx = _extends({}, sx, _defineProperty({}, "& > .".concat(textFieldClasses.root), {
|
|
104
|
+
minWidth: {
|
|
105
|
+
xs: 300,
|
|
106
|
+
md: 400
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
104
110
|
} else if (childrenSupportedSections.has('date-time')) {
|
|
105
111
|
sx = _extends({}, sx, _defineProperty({}, "& > .".concat(textFieldClasses.root), {
|
|
106
112
|
minWidth: 270
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useField } from './useField';
|
|
2
|
-
export { splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections
|
|
2
|
+
export { splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections } from './useField.utils';
|
|
@@ -6,9 +6,10 @@ import * as React from 'react';
|
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
7
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
8
8
|
import useForkRef from '@mui/utils/useForkRef';
|
|
9
|
+
import { useTheme } from '@mui/material/styles';
|
|
9
10
|
import { useValidation } from '../validation/useValidation';
|
|
10
11
|
import { useUtils } from '../useUtils';
|
|
11
|
-
import { adjustSectionValue, isAndroid, cleanString } from './useField.utils';
|
|
12
|
+
import { adjustSectionValue, isAndroid, cleanString, getSectionOrder } from './useField.utils';
|
|
12
13
|
import { useFieldState } from './useFieldState';
|
|
13
14
|
import { useFieldCharacterEditing } from './useFieldCharacterEditing';
|
|
14
15
|
import { getActiveElement } from '../../utils/utils';
|
|
@@ -17,14 +18,14 @@ export var useField = function useField(params) {
|
|
|
17
18
|
var _useFieldState = useFieldState(params),
|
|
18
19
|
state = _useFieldState.state,
|
|
19
20
|
selectedSectionIndexes = _useFieldState.selectedSectionIndexes,
|
|
20
|
-
|
|
21
|
+
_setSelectedSections = _useFieldState.setSelectedSections,
|
|
21
22
|
clearValue = _useFieldState.clearValue,
|
|
22
23
|
clearActiveSection = _useFieldState.clearActiveSection,
|
|
23
24
|
updateSectionValue = _useFieldState.updateSectionValue,
|
|
24
25
|
updateValueFromValueStr = _useFieldState.updateValueFromValueStr,
|
|
25
26
|
setTempAndroidValueStr = _useFieldState.setTempAndroidValueStr,
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
sectionsValueBoundaries = _useFieldState.sectionsValueBoundaries,
|
|
28
|
+
placeholder = _useFieldState.placeholder;
|
|
28
29
|
var _useFieldCharacterEdi = useFieldCharacterEditing({
|
|
29
30
|
sections: state.sections,
|
|
30
31
|
updateSectionValue: updateSectionValue,
|
|
@@ -35,8 +36,10 @@ export var useField = function useField(params) {
|
|
|
35
36
|
resetCharacterQuery = _useFieldCharacterEdi.resetCharacterQuery;
|
|
36
37
|
var inputRefProp = params.inputRef,
|
|
37
38
|
internalProps = params.internalProps,
|
|
38
|
-
_params$internalProps = params.internalProps
|
|
39
|
-
|
|
39
|
+
_params$internalProps = params.internalProps,
|
|
40
|
+
_params$internalProps2 = _params$internalProps.readOnly,
|
|
41
|
+
readOnly = _params$internalProps2 === void 0 ? false : _params$internalProps2,
|
|
42
|
+
unstableFieldRef = _params$internalProps.unstableFieldRef,
|
|
40
43
|
_params$forwardedProp = params.forwardedProps,
|
|
41
44
|
onClick = _params$forwardedProp.onClick,
|
|
42
45
|
onKeyDown = _params$forwardedProp.onKeyDown,
|
|
@@ -52,10 +55,15 @@ export var useField = function useField(params) {
|
|
|
52
55
|
var inputRef = React.useRef(null);
|
|
53
56
|
var handleRef = useForkRef(inputRefProp, inputRef);
|
|
54
57
|
var focusTimeoutRef = React.useRef(undefined);
|
|
58
|
+
var theme = useTheme();
|
|
59
|
+
var isRTL = theme.direction === 'rtl';
|
|
60
|
+
var sectionOrder = React.useMemo(function () {
|
|
61
|
+
return getSectionOrder(state.sections, isRTL);
|
|
62
|
+
}, [state.sections, isRTL]);
|
|
55
63
|
var syncSelectionFromDOM = function syncSelectionFromDOM() {
|
|
56
64
|
var _selectionStart;
|
|
57
65
|
if (readOnly) {
|
|
58
|
-
|
|
66
|
+
_setSelectedSections(null);
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
61
69
|
var browserStartIndex = (_selectionStart = inputRef.current.selectionStart) != null ? _selectionStart : 0;
|
|
@@ -64,7 +72,7 @@ export var useField = function useField(params) {
|
|
|
64
72
|
return section.startInInput - section.startSeparator.length > browserStartIndex;
|
|
65
73
|
});
|
|
66
74
|
var sectionIndex = nextSectionIndex === -1 ? state.sections.length - 1 : nextSectionIndex - 1;
|
|
67
|
-
|
|
75
|
+
_setSelectedSections(sectionIndex);
|
|
68
76
|
};
|
|
69
77
|
var handleInputClick = useEventCallback(function () {
|
|
70
78
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -98,7 +106,7 @@ export var useField = function useField(params) {
|
|
|
98
106
|
if (
|
|
99
107
|
// avoid selecting all sections when focusing empty field without value
|
|
100
108
|
input.value.length && Number(input.selectionEnd) - Number(input.selectionStart) === input.value.length) {
|
|
101
|
-
|
|
109
|
+
_setSelectedSections('all');
|
|
102
110
|
} else {
|
|
103
111
|
syncSelectionFromDOM();
|
|
104
112
|
}
|
|
@@ -109,7 +117,7 @@ export var useField = function useField(params) {
|
|
|
109
117
|
args[_key3] = arguments[_key3];
|
|
110
118
|
}
|
|
111
119
|
onBlur == null ? void 0 : onBlur.apply(void 0, _toConsumableArray(args));
|
|
112
|
-
|
|
120
|
+
_setSelectedSections(null);
|
|
113
121
|
});
|
|
114
122
|
var handleInputPaste = useEventCallback(function (event) {
|
|
115
123
|
onPaste == null ? void 0 : onPaste(event);
|
|
@@ -150,27 +158,32 @@ export var useField = function useField(params) {
|
|
|
150
158
|
updateValueFromValueStr(cleanValueStr);
|
|
151
159
|
return;
|
|
152
160
|
}
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
var keyPressed;
|
|
162
|
+
if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1) {
|
|
163
|
+
keyPressed = cleanValueStr;
|
|
164
|
+
} else {
|
|
165
|
+
var prevValueStr = cleanString(fieldValueManager.getValueStrFromSections(state.sections, isRTL));
|
|
166
|
+
var startOfDiffIndex = -1;
|
|
167
|
+
var endOfDiffIndex = -1;
|
|
168
|
+
for (var i = 0; i < prevValueStr.length; i += 1) {
|
|
169
|
+
if (startOfDiffIndex === -1 && prevValueStr[i] !== cleanValueStr[i]) {
|
|
170
|
+
startOfDiffIndex = i;
|
|
171
|
+
}
|
|
172
|
+
if (endOfDiffIndex === -1 && prevValueStr[prevValueStr.length - i - 1] !== cleanValueStr[cleanValueStr.length - i - 1]) {
|
|
173
|
+
endOfDiffIndex = i;
|
|
174
|
+
}
|
|
159
175
|
}
|
|
160
|
-
|
|
161
|
-
|
|
176
|
+
var activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
177
|
+
var hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;
|
|
178
|
+
if (hasDiffOutsideOfActiveSection) {
|
|
179
|
+
// TODO: Support if the new date is valid
|
|
180
|
+
return;
|
|
162
181
|
}
|
|
163
|
-
}
|
|
164
|
-
var activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
165
|
-
var hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;
|
|
166
|
-
if (hasDiffOutsideOfActiveSection) {
|
|
167
|
-
// TODO: Support if the new date is valid
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
182
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
// The active section being selected, the browser has replaced its value with the key pressed by the user.
|
|
184
|
+
var activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;
|
|
185
|
+
keyPressed = cleanValueStr.slice(activeSection.start, activeSectionEndRelativeToNewValue);
|
|
186
|
+
}
|
|
174
187
|
if (isAndroid() && keyPressed.length === 0) {
|
|
175
188
|
setTempAndroidValueStr(valueStr);
|
|
176
189
|
return;
|
|
@@ -191,7 +204,7 @@ export var useField = function useField(params) {
|
|
|
191
204
|
// prevent default to make sure that the next line "select all" while updating
|
|
192
205
|
// the internal state at the same time.
|
|
193
206
|
event.preventDefault();
|
|
194
|
-
|
|
207
|
+
_setSelectedSections('all');
|
|
195
208
|
break;
|
|
196
209
|
}
|
|
197
210
|
|
|
@@ -200,13 +213,13 @@ export var useField = function useField(params) {
|
|
|
200
213
|
{
|
|
201
214
|
event.preventDefault();
|
|
202
215
|
if (selectedSectionIndexes == null) {
|
|
203
|
-
|
|
216
|
+
_setSelectedSections(sectionOrder.startIndex);
|
|
204
217
|
} else if (selectedSectionIndexes.startIndex !== selectedSectionIndexes.endIndex) {
|
|
205
|
-
|
|
218
|
+
_setSelectedSections(selectedSectionIndexes.endIndex);
|
|
206
219
|
} else {
|
|
207
220
|
var nextSectionIndex = sectionOrder.neighbors[selectedSectionIndexes.startIndex].rightIndex;
|
|
208
221
|
if (nextSectionIndex !== null) {
|
|
209
|
-
|
|
222
|
+
_setSelectedSections(nextSectionIndex);
|
|
210
223
|
}
|
|
211
224
|
}
|
|
212
225
|
break;
|
|
@@ -217,13 +230,13 @@ export var useField = function useField(params) {
|
|
|
217
230
|
{
|
|
218
231
|
event.preventDefault();
|
|
219
232
|
if (selectedSectionIndexes == null) {
|
|
220
|
-
|
|
233
|
+
_setSelectedSections(sectionOrder.endIndex);
|
|
221
234
|
} else if (selectedSectionIndexes.startIndex !== selectedSectionIndexes.endIndex) {
|
|
222
|
-
|
|
235
|
+
_setSelectedSections(selectedSectionIndexes.startIndex);
|
|
223
236
|
} else {
|
|
224
237
|
var _nextSectionIndex = sectionOrder.neighbors[selectedSectionIndexes.startIndex].leftIndex;
|
|
225
238
|
if (_nextSectionIndex !== null) {
|
|
226
|
-
|
|
239
|
+
_setSelectedSections(_nextSectionIndex);
|
|
227
240
|
}
|
|
228
241
|
}
|
|
229
242
|
break;
|
|
@@ -254,7 +267,7 @@ export var useField = function useField(params) {
|
|
|
254
267
|
}
|
|
255
268
|
var activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
256
269
|
var activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
257
|
-
var newSectionValue = adjustSectionValue(utils, activeSection, event.key, sectionsValueBoundaries, activeDateManager.
|
|
270
|
+
var newSectionValue = adjustSectionValue(utils, activeSection, event.key, sectionsValueBoundaries, activeDateManager.date);
|
|
258
271
|
updateSectionValue({
|
|
259
272
|
activeSection: activeSection,
|
|
260
273
|
newSectionValue: newSectionValue,
|
|
@@ -266,9 +279,11 @@ export var useField = function useField(params) {
|
|
|
266
279
|
});
|
|
267
280
|
useEnhancedEffect(function () {
|
|
268
281
|
if (selectedSectionIndexes == null) {
|
|
269
|
-
if (inputRef.current.
|
|
270
|
-
// Ensure input
|
|
271
|
-
|
|
282
|
+
if (inputRef.current.scrollLeft) {
|
|
283
|
+
// Ensure that input content is not marked as selected.
|
|
284
|
+
// setting selection range to 0 causes issues in Safari.
|
|
285
|
+
// https://bugs.webkit.org/show_bug.cgi?id=224425
|
|
286
|
+
inputRef.current.scrollLeft = 0;
|
|
272
287
|
}
|
|
273
288
|
return;
|
|
274
289
|
}
|
|
@@ -281,7 +296,11 @@ export var useField = function useField(params) {
|
|
|
281
296
|
selectionEnd += lastSelectedSection.endSeparator.length;
|
|
282
297
|
}
|
|
283
298
|
if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
|
|
299
|
+
// Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321
|
|
300
|
+
var currentScrollTop = inputRef.current.scrollTop;
|
|
284
301
|
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
302
|
+
// Even reading this variable seems to do the trick, but also setting it just to make use of it
|
|
303
|
+
inputRef.current.scrollTop = currentScrollTop;
|
|
285
304
|
}
|
|
286
305
|
});
|
|
287
306
|
var validationError = useValidation(_extends({}, internalProps, {
|
|
@@ -298,7 +317,7 @@ export var useField = function useField(params) {
|
|
|
298
317
|
React.useEffect(function () {
|
|
299
318
|
// Select the right section when focused on mount (`autoFocus = true` on the input)
|
|
300
319
|
if (inputRef.current && inputRef.current === document.activeElement) {
|
|
301
|
-
|
|
320
|
+
_setSelectedSections('all');
|
|
302
321
|
}
|
|
303
322
|
return function () {
|
|
304
323
|
return window.clearTimeout(focusTimeoutRef.current);
|
|
@@ -318,8 +337,8 @@ export var useField = function useField(params) {
|
|
|
318
337
|
|
|
319
338
|
var valueStr = React.useMemo(function () {
|
|
320
339
|
var _state$tempValueStrAn;
|
|
321
|
-
return (_state$tempValueStrAn = state.tempValueStrAndroid) != null ? _state$tempValueStrAn : fieldValueManager.getValueStrFromSections(state.sections);
|
|
322
|
-
}, [state.sections, fieldValueManager, state.tempValueStrAndroid]);
|
|
340
|
+
return (_state$tempValueStrAn = state.tempValueStrAndroid) != null ? _state$tempValueStrAn : fieldValueManager.getValueStrFromSections(state.sections, isRTL);
|
|
341
|
+
}, [state.sections, fieldValueManager, state.tempValueStrAndroid, isRTL]);
|
|
323
342
|
var inputMode = React.useMemo(function () {
|
|
324
343
|
if (selectedSectionIndexes == null) {
|
|
325
344
|
return 'text';
|
|
@@ -330,9 +349,32 @@ export var useField = function useField(params) {
|
|
|
330
349
|
return 'tel';
|
|
331
350
|
}, [selectedSectionIndexes, state.sections]);
|
|
332
351
|
var inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);
|
|
333
|
-
var shouldShowPlaceholder = !inputHasFocus &&
|
|
352
|
+
var shouldShowPlaceholder = !inputHasFocus && valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
|
|
353
|
+
React.useImperativeHandle(unstableFieldRef, function () {
|
|
354
|
+
return {
|
|
355
|
+
getSections: function getSections() {
|
|
356
|
+
return state.sections;
|
|
357
|
+
},
|
|
358
|
+
getActiveSectionIndex: function getActiveSectionIndex() {
|
|
359
|
+
var _selectionStart2, _selectionEnd;
|
|
360
|
+
var browserStartIndex = (_selectionStart2 = inputRef.current.selectionStart) != null ? _selectionStart2 : 0;
|
|
361
|
+
var browserEndIndex = (_selectionEnd = inputRef.current.selectionEnd) != null ? _selectionEnd : 0;
|
|
362
|
+
if (browserStartIndex === 0 && browserEndIndex === 0) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
var nextSectionIndex = browserStartIndex <= state.sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.
|
|
366
|
+
: state.sections.findIndex(function (section) {
|
|
367
|
+
return section.startInInput - section.startSeparator.length > browserStartIndex;
|
|
368
|
+
});
|
|
369
|
+
return nextSectionIndex === -1 ? state.sections.length - 1 : nextSectionIndex - 1;
|
|
370
|
+
},
|
|
371
|
+
setSelectedSections: function setSelectedSections(activeSectionIndex) {
|
|
372
|
+
return _setSelectedSections(activeSectionIndex);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
});
|
|
334
376
|
return _extends({
|
|
335
|
-
placeholder:
|
|
377
|
+
placeholder: placeholder,
|
|
336
378
|
autoComplete: 'off'
|
|
337
379
|
}, otherForwardedProps, {
|
|
338
380
|
value: shouldShowPlaceholder ? '' : valueStr,
|
|
@@ -155,7 +155,7 @@ export var adjustSectionValue = function adjustSectionValue(utils, section, keyC
|
|
|
155
155
|
}
|
|
156
156
|
return adjustLetterSection();
|
|
157
157
|
};
|
|
158
|
-
var getSectionVisibleValue = function getSectionVisibleValue(section,
|
|
158
|
+
export var getSectionVisibleValue = function getSectionVisibleValue(section, target) {
|
|
159
159
|
var value = section.value || section.placeholder;
|
|
160
160
|
|
|
161
161
|
// In the input, we add an empty character at the end of each section without leading zeros.
|
|
@@ -163,26 +163,25 @@ var getSectionVisibleValue = function getSectionVisibleValue(section, willBeRend
|
|
|
163
163
|
// Otherwise, when your input value equals `1/dd/yyyy` (format `M/DD/YYYY` on DayJs),
|
|
164
164
|
// If you press `1`, on the first section, the new value is also `1/dd/yyyy`,
|
|
165
165
|
// So the browser will not fire the input `onChange`.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return "\u2068".concat(value, "\u200E\u2069");
|
|
166
|
+
var shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !section.hasLeadingZeros && value.length === 1;
|
|
167
|
+
if (shouldAddInvisibleSpace) {
|
|
168
|
+
value = "".concat(value, "\u200E");
|
|
170
169
|
}
|
|
171
|
-
if (
|
|
172
|
-
|
|
170
|
+
if (target === 'input-rtl') {
|
|
171
|
+
value = "\u2068".concat(value, "\u2069");
|
|
173
172
|
}
|
|
174
173
|
return value;
|
|
175
174
|
};
|
|
176
175
|
export var cleanString = function cleanString(dirtyString) {
|
|
177
176
|
return dirtyString.replace(/[\u2066\u2067\u2068\u2069]/g, '');
|
|
178
177
|
};
|
|
179
|
-
export var addPositionPropertiesToSections = function addPositionPropertiesToSections(sections) {
|
|
178
|
+
export var addPositionPropertiesToSections = function addPositionPropertiesToSections(sections, isRTL) {
|
|
180
179
|
var position = 0;
|
|
181
|
-
var positionInInput = 1;
|
|
180
|
+
var positionInInput = isRTL ? 1 : 0;
|
|
182
181
|
var newSections = [];
|
|
183
182
|
for (var i = 0; i < sections.length; i += 1) {
|
|
184
183
|
var section = sections[i];
|
|
185
|
-
var renderedValue = getSectionVisibleValue(section,
|
|
184
|
+
var renderedValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr');
|
|
186
185
|
var sectionStr = "".concat(section.startSeparator).concat(renderedValue).concat(section.endSeparator);
|
|
187
186
|
var sectionLength = cleanString(sectionStr).length;
|
|
188
187
|
var sectionLengthInInput = sectionStr.length;
|
|
@@ -328,10 +327,6 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, loc
|
|
|
328
327
|
if (token === '') {
|
|
329
328
|
return null;
|
|
330
329
|
}
|
|
331
|
-
var expandedToken = utils.expandFormat(token);
|
|
332
|
-
if (expandedToken !== token) {
|
|
333
|
-
return expandedToken;
|
|
334
|
-
}
|
|
335
330
|
var sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
336
331
|
var sectionValue = date == null || !utils.isValid(date) ? '' : utils.formatByString(date, token);
|
|
337
332
|
var hasLeadingZeros = doesSectionHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
@@ -346,44 +341,55 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, loc
|
|
|
346
341
|
}));
|
|
347
342
|
return null;
|
|
348
343
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
344
|
+
|
|
345
|
+
// Expand the provided format
|
|
346
|
+
var formatExpansionOverflow = 10;
|
|
347
|
+
var prevFormat = format;
|
|
348
|
+
var nextFormat = utils.expandFormat(format);
|
|
349
|
+
while (nextFormat !== prevFormat) {
|
|
350
|
+
prevFormat = nextFormat;
|
|
351
|
+
nextFormat = utils.expandFormat(prevFormat);
|
|
352
|
+
formatExpansionOverflow -= 1;
|
|
353
|
+
if (formatExpansionOverflow < 0) {
|
|
354
|
+
throw new Error('MUI: The format expansion seems to be enter in an infinite loop. Please open an issue with the format passed to the picker component');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
var expandedFormat = nextFormat;
|
|
358
|
+
|
|
359
|
+
// Get start/end indexes of escaped sections
|
|
360
|
+
var escapedParts = getEscapedPartsFromFormat(utils, expandedFormat);
|
|
361
|
+
|
|
362
|
+
// This RegExp test if the beginning of a string correspond to a supported token
|
|
363
|
+
var isTokenStartRegExp = new RegExp("^(".concat(Object.keys(utils.formatTokenMap).join('|'), ")"));
|
|
364
|
+
var currentTokenValue = '';
|
|
365
|
+
var _loop = function _loop(i) {
|
|
366
|
+
var escapedPartOfCurrentChar = escapedParts.find(function (escapeIndex) {
|
|
367
|
+
return escapeIndex.start <= i && escapeIndex.end >= i;
|
|
368
|
+
});
|
|
369
|
+
var char = expandedFormat[i];
|
|
370
|
+
var isEscapedChar = escapedPartOfCurrentChar != null;
|
|
371
|
+
var potentialToken = "".concat(currentTokenValue).concat(expandedFormat.slice(i));
|
|
372
|
+
if (!isEscapedChar && char.match(/([A-Za-z]+)/) && isTokenStartRegExp.test(potentialToken)) {
|
|
373
|
+
currentTokenValue += char;
|
|
374
|
+
} else {
|
|
375
|
+
// If we are on the opening or closing character of an escaped part of the format,
|
|
376
|
+
// Then we ignore this character.
|
|
377
|
+
var isEscapeBoundary = isEscapedChar && (escapedPartOfCurrentChar == null ? void 0 : escapedPartOfCurrentChar.start) === i || (escapedPartOfCurrentChar == null ? void 0 : escapedPartOfCurrentChar.end) === i;
|
|
378
|
+
if (!isEscapeBoundary) {
|
|
379
|
+
commitToken(currentTokenValue);
|
|
380
|
+
currentTokenValue = '';
|
|
381
|
+
if (sections.length === 0) {
|
|
382
|
+
startSeparator += char;
|
|
383
|
+
} else {
|
|
384
|
+
sections[sections.length - 1].endSeparator += char;
|
|
375
385
|
}
|
|
376
386
|
}
|
|
377
|
-
};
|
|
378
|
-
for (var i = 0; i < token.length; i += 1) {
|
|
379
|
-
_loop(i);
|
|
380
|
-
}
|
|
381
|
-
var expandedToken = commitToken(currentTokenValue);
|
|
382
|
-
if (expandedToken != null) {
|
|
383
|
-
splitFormat(expandedToken);
|
|
384
387
|
}
|
|
385
388
|
};
|
|
386
|
-
|
|
389
|
+
for (var i = 0; i < expandedFormat.length; i += 1) {
|
|
390
|
+
_loop(i);
|
|
391
|
+
}
|
|
392
|
+
commitToken(currentTokenValue);
|
|
387
393
|
return sections.map(function (section) {
|
|
388
394
|
var cleanSeparator = function cleanSeparator(separator) {
|
|
389
395
|
var cleanedSeparator = separator;
|
|
@@ -419,24 +425,28 @@ export var getDateFromDateSections = function getDateFromDateSections(utils, sec
|
|
|
419
425
|
var shouldSkip = shouldSkipWeekDays && section.type === 'weekDay';
|
|
420
426
|
if (!shouldSkip) {
|
|
421
427
|
sectionFormats.push(section.format);
|
|
422
|
-
sectionValues.push(getSectionVisibleValue(section,
|
|
428
|
+
sectionValues.push(getSectionVisibleValue(section, 'non-input'));
|
|
423
429
|
}
|
|
424
430
|
}
|
|
425
431
|
var formatWithoutSeparator = sectionFormats.join(' ');
|
|
426
432
|
var dateWithoutSeparatorStr = sectionValues.join(' ');
|
|
427
433
|
return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
|
|
428
434
|
};
|
|
429
|
-
export var createDateStrForInputFromSections = function createDateStrForInputFromSections(sections) {
|
|
430
|
-
var
|
|
431
|
-
return "".concat(section.startSeparator).concat(getSectionVisibleValue(section,
|
|
435
|
+
export var createDateStrForInputFromSections = function createDateStrForInputFromSections(sections, isRTL) {
|
|
436
|
+
var formattedSections = sections.map(function (section) {
|
|
437
|
+
return "".concat(section.startSeparator).concat(getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr')).concat(section.endSeparator);
|
|
432
438
|
});
|
|
439
|
+
var dateStr = formattedSections.join('');
|
|
440
|
+
if (!isRTL) {
|
|
441
|
+
return dateStr;
|
|
442
|
+
}
|
|
433
443
|
|
|
434
444
|
// \u2066: start left-to-right isolation
|
|
435
445
|
// \u2067: start right-to-left isolation
|
|
436
446
|
// \u2068: start first strong character isolation
|
|
437
447
|
// \u2069: pop isolation
|
|
438
448
|
// wrap into an isolated group such that separators can split the string in smaller ones by adding \u2069\u2068
|
|
439
|
-
return "\u2066".concat(
|
|
449
|
+
return "\u2066".concat(dateStr, "\u2069");
|
|
440
450
|
};
|
|
441
451
|
export var getSectionsBoundaries = function getSectionsBoundaries(utils) {
|
|
442
452
|
var today = utils.date();
|
|
@@ -616,7 +626,19 @@ export var mergeDateIntoReferenceDate = function mergeDateIntoReferenceDate(util
|
|
|
616
626
|
export var isAndroid = function isAndroid() {
|
|
617
627
|
return navigator.userAgent.toLowerCase().indexOf('android') > -1;
|
|
618
628
|
};
|
|
619
|
-
export var
|
|
629
|
+
export var clampDaySectionIfPossible = function clampDaySectionIfPossible(utils, sections, sectionsValueBoundaries) {
|
|
630
|
+
// We can only clamp the day value if:
|
|
631
|
+
// 1. if all the sections are filled (except the week day section which can be empty)
|
|
632
|
+
// 2. there is a day section
|
|
633
|
+
var canClamp = sections.every(function (section) {
|
|
634
|
+
return section.type === 'weekDay' || section.value !== '';
|
|
635
|
+
}) && sections.some(function (section) {
|
|
636
|
+
return section.type === 'day';
|
|
637
|
+
});
|
|
638
|
+
if (!canClamp) {
|
|
639
|
+
return null;
|
|
640
|
+
}
|
|
641
|
+
|
|
620
642
|
// We try to generate a valid date representing the start of the month of the invalid date typed by the user.
|
|
621
643
|
var sectionsForStartOfMonth = sections.map(function (section) {
|
|
622
644
|
if (section.type !== 'day') {
|