@mui/x-date-pickers 6.0.1 → 6.0.3
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 +2 -0
- package/AdapterDateFnsJalali/index.js +1 -0
- package/AdapterDayjs/index.js +6 -0
- package/AdapterLuxon/index.js +1 -0
- package/AdapterMoment/index.js +6 -0
- package/AdapterMomentHijri/index.d.ts +1 -1
- package/AdapterMomentHijri/index.js +5 -0
- package/AdapterMomentJalaali/index.js +5 -0
- package/CHANGELOG.md +116 -10
- package/DateField/DateField.js +4 -0
- package/DateField/DateField.types.d.ts +2 -2
- package/DateField/useDateField.js +5 -3
- package/DateTimeField/DateTimeField.js +4 -0
- package/DateTimeField/DateTimeField.types.d.ts +2 -2
- package/DateTimeField/useDateTimeField.js +5 -3
- package/PickersDay/PickersDay.js +4 -4
- package/TimeField/TimeField.js +4 -0
- package/TimeField/TimeField.types.d.ts +2 -2
- package/TimeField/useTimeField.js +5 -3
- package/index.d.ts +1 -6
- package/index.js +4 -2
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +8 -2
- package/internals/components/PickersModalDialog.d.ts +2 -2
- package/internals/components/PickersPopper.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +5 -4
- package/internals/hooks/useField/index.d.ts +2 -2
- package/internals/hooks/useField/index.js +1 -1
- package/internals/hooks/useField/useField.d.ts +1 -1
- package/internals/hooks/useField/useField.js +62 -27
- package/internals/hooks/useField/useField.types.d.ts +37 -20
- package/internals/hooks/useField/useField.utils.d.ts +3 -3
- package/internals/hooks/useField/useField.utils.js +63 -35
- package/internals/hooks/useField/useFieldCharacterEditing.js +4 -9
- package/internals/hooks/useField/useFieldState.d.ts +1 -2
- package/internals/hooks/useField/useFieldState.js +44 -43
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +5 -4
- package/internals/hooks/usePicker/usePicker.d.ts +2 -1
- package/internals/hooks/usePicker/usePicker.types.d.ts +4 -3
- package/internals/hooks/usePicker/usePickerValue.d.ts +8 -8
- package/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +2 -1
- package/internals/index.d.ts +2 -2
- package/internals/index.js +2 -2
- package/internals/models/fields.d.ts +3 -3
- package/internals/utils/date-utils.d.ts +1 -0
- package/internals/utils/date-utils.js +6 -0
- package/internals/utils/valueManagers.js +15 -12
- package/legacy/AdapterDateFns/index.js +2 -0
- package/legacy/AdapterDateFnsJalali/index.js +1 -0
- package/legacy/AdapterDayjs/index.js +6 -0
- package/legacy/AdapterLuxon/index.js +1 -0
- package/legacy/AdapterMoment/index.js +6 -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/components/PickersArrowSwitcher/PickersArrowSwitcher.js +8 -2
- package/legacy/internals/hooks/useField/index.js +1 -1
- package/legacy/internals/hooks/useField/useField.js +86 -40
- package/legacy/internals/hooks/useField/useField.utils.js +64 -36
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +4 -9
- package/legacy/internals/hooks/useField/useFieldState.js +46 -47
- package/legacy/internals/hooks/usePicker/usePickerValue.js +9 -13
- package/legacy/internals/index.js +2 -2
- package/legacy/internals/utils/date-utils.js +6 -0
- package/legacy/internals/utils/valueManagers.js +7 -8
- package/legacy/locales/deDE.js +8 -5
- package/legacy/locales/faIR.js +33 -16
- package/legacy/locales/frFR.js +30 -15
- package/legacy/locales/heIL.js +71 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/nlNL.js +12 -10
- package/legacy/locales/plPL.js +12 -10
- package/legacy/models/index.js +1 -0
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +19 -1
- package/locales/deDE.js +4 -5
- package/locales/faIR.js +13 -16
- package/locales/frFR.js +12 -15
- package/locales/heIL.d.ts +51 -0
- package/locales/heIL.js +57 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/nlNL.js +8 -10
- package/locales/plPL.js +8 -10
- package/models/index.d.ts +6 -0
- package/models/index.js +1 -0
- package/models/package.json +6 -0
- package/modern/AdapterDateFns/index.js +2 -0
- package/modern/AdapterDateFnsJalali/index.js +1 -0
- package/modern/AdapterDayjs/index.js +6 -0
- package/modern/AdapterLuxon/index.js +1 -0
- package/modern/AdapterMoment/index.js +6 -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/components/PickersArrowSwitcher/PickersArrowSwitcher.js +8 -2
- package/modern/internals/hooks/useField/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +61 -27
- package/modern/internals/hooks/useField/useField.utils.js +63 -35
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +4 -9
- package/modern/internals/hooks/useField/useFieldState.js +44 -43
- package/modern/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/modern/internals/index.js +2 -2
- package/modern/internals/utils/date-utils.js +6 -0
- package/modern/internals/utils/valueManagers.js +15 -12
- package/modern/locales/deDE.js +4 -5
- package/modern/locales/faIR.js +13 -16
- package/modern/locales/frFR.js +12 -15
- package/modern/locales/heIL.js +57 -0
- package/modern/locales/index.js +1 -0
- package/modern/locales/nlNL.js +8 -10
- package/modern/locales/plPL.js +8 -10
- package/modern/models/index.js +1 -0
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +19 -1
- package/node/AdapterDateFns/index.js +2 -0
- package/node/AdapterDateFnsJalali/index.js +1 -0
- package/node/AdapterDayjs/index.js +6 -0
- package/node/AdapterLuxon/index.js +1 -0
- package/node/AdapterMoment/index.js +6 -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/components/PickersArrowSwitcher/PickersArrowSwitcher.js +8 -2
- package/node/internals/hooks/useField/index.js +0 -6
- package/node/internals/hooks/useField/useField.js +60 -26
- package/node/internals/hooks/useField/useField.utils.js +66 -38
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +3 -8
- package/node/internals/hooks/useField/useFieldState.js +44 -43
- package/node/internals/hooks/usePicker/usePickerValue.js +7 -11
- package/node/internals/index.js +6 -6
- package/node/internals/utils/date-utils.js +9 -2
- package/node/internals/utils/valueManagers.js +13 -10
- package/node/locales/deDE.js +4 -5
- package/node/locales/faIR.js +13 -16
- package/node/locales/frFR.js +12 -15
- package/node/locales/heIL.js +64 -0
- package/node/locales/index.js +11 -0
- package/node/locales/nlNL.js +8 -10
- package/node/locales/plPL.js +8 -10
- package/node/models/index.js +5 -0
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +18 -0
- package/package.json +3 -3
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +19 -1
|
@@ -59,6 +59,10 @@ export var AdapterMomentJalaali = /*#__PURE__*/function (_BaseAdapterMomentJal)
|
|
|
59
59
|
start: '[',
|
|
60
60
|
end: ']'
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
64
|
+
* We should use this one in the future to support all localized formats.
|
|
65
|
+
*/
|
|
62
66
|
_this.expandFormat = function (format) {
|
|
63
67
|
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
64
68
|
var localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
@@ -70,6 +74,7 @@ export var AdapterMomentJalaali = /*#__PURE__*/function (_BaseAdapterMomentJal)
|
|
|
70
74
|
return token;
|
|
71
75
|
}).join('').replace('dd', 'jDD'); // Fix for https://github.com/dmtrKovalenko/date-io/pull/632;
|
|
72
76
|
};
|
|
77
|
+
// Redefined here just to show how it can be written using expandFormat
|
|
73
78
|
_this.getFormatHelperText = function (format) {
|
|
74
79
|
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').replace('jY', 'Y').replace('jM', 'M').replace('jD', 'D').toLocaleLowerCase();
|
|
75
80
|
};
|
|
@@ -263,6 +263,10 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
263
263
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
264
264
|
*/
|
|
265
265
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
266
|
+
/**
|
|
267
|
+
* The ref object used to imperatively interact with the field.
|
|
268
|
+
*/
|
|
269
|
+
unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
266
270
|
/**
|
|
267
271
|
* The selected value.
|
|
268
272
|
* Used when the component is controlled.
|
|
@@ -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", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDate } from '../internals/hooks/validation/useDateValidation';
|
|
@@ -37,6 +37,7 @@ export var useDateField = function useDateField(_ref) {
|
|
|
37
37
|
disablePast = _useDefaultizedDateFi.disablePast,
|
|
38
38
|
selectedSections = _useDefaultizedDateFi.selectedSections,
|
|
39
39
|
onSelectedSectionsChange = _useDefaultizedDateFi.onSelectedSectionsChange,
|
|
40
|
+
unstableFieldRef = _useDefaultizedDateFi.unstableFieldRef,
|
|
40
41
|
other = _objectWithoutProperties(_useDefaultizedDateFi, _excluded);
|
|
41
42
|
return useField({
|
|
42
43
|
inputRef: inputRef,
|
|
@@ -56,7 +57,8 @@ export var useDateField = function useDateField(_ref) {
|
|
|
56
57
|
disableFuture: disableFuture,
|
|
57
58
|
disablePast: disablePast,
|
|
58
59
|
selectedSections: selectedSections,
|
|
59
|
-
onSelectedSectionsChange: onSelectedSectionsChange
|
|
60
|
+
onSelectedSectionsChange: onSelectedSectionsChange,
|
|
61
|
+
unstableFieldRef: unstableFieldRef
|
|
60
62
|
},
|
|
61
63
|
valueManager: singleItemValueManager,
|
|
62
64
|
fieldValueManager: singleItemFieldValueManager,
|
|
@@ -311,6 +311,10 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
311
311
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
312
312
|
*/
|
|
313
313
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
314
|
+
/**
|
|
315
|
+
* The ref object used to imperatively interact with the field.
|
|
316
|
+
*/
|
|
317
|
+
unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
314
318
|
/**
|
|
315
319
|
* The selected value.
|
|
316
320
|
* Used when the component is controlled.
|
|
@@ -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", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDateTime } from '../internals/hooks/validation/useDateTimeValidation';
|
|
@@ -51,6 +51,7 @@ export var useDateTimeField = function useDateTimeField(_ref) {
|
|
|
51
51
|
selectedSections = _useDefaultizedDateTi.selectedSections,
|
|
52
52
|
onSelectedSectionsChange = _useDefaultizedDateTi.onSelectedSectionsChange,
|
|
53
53
|
ampm = _useDefaultizedDateTi.ampm,
|
|
54
|
+
unstableFieldRef = _useDefaultizedDateTi.unstableFieldRef,
|
|
54
55
|
other = _objectWithoutProperties(_useDefaultizedDateTi, _excluded);
|
|
55
56
|
return useField({
|
|
56
57
|
inputRef: inputRef,
|
|
@@ -77,7 +78,8 @@ export var useDateTimeField = function useDateTimeField(_ref) {
|
|
|
77
78
|
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
78
79
|
selectedSections: selectedSections,
|
|
79
80
|
onSelectedSectionsChange: onSelectedSectionsChange,
|
|
80
|
-
ampm: ampm
|
|
81
|
+
ampm: ampm,
|
|
82
|
+
unstableFieldRef: unstableFieldRef
|
|
81
83
|
},
|
|
82
84
|
valueManager: singleItemValueManager,
|
|
83
85
|
fieldValueManager: singleItemFieldValueManager,
|
|
@@ -36,16 +36,16 @@ var styleArg = function styleArg(_ref) {
|
|
|
36
36
|
height: DAY_SIZE,
|
|
37
37
|
borderRadius: '50%',
|
|
38
38
|
padding: 0,
|
|
39
|
-
//
|
|
40
|
-
backgroundColor:
|
|
39
|
+
// explicitly setting to `transparent` to avoid potentially getting impacted by change from the overridden component
|
|
40
|
+
backgroundColor: 'transparent',
|
|
41
41
|
color: (theme.vars || theme).palette.text.primary,
|
|
42
42
|
'@media (pointer: fine)': {
|
|
43
43
|
'&:hover': {
|
|
44
|
-
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.
|
|
44
|
+
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.primary.mainChannel, " / ").concat(theme.vars.palette.action.hoverOpacity, ")") : alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity)
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
'&:focus': _defineProperty({
|
|
48
|
-
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.
|
|
48
|
+
backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.primary.mainChannel, " / ").concat(theme.vars.palette.action.focusOpacity, ")") : alpha(theme.palette.primary.main, theme.palette.action.focusOpacity)
|
|
49
49
|
}, "&.".concat(pickersDayClasses.selected), {
|
|
50
50
|
willChange: 'background-color',
|
|
51
51
|
backgroundColor: (theme.vars || theme).palette.primary.dark
|
|
@@ -274,6 +274,10 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
274
274
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
275
275
|
*/
|
|
276
276
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
277
|
+
/**
|
|
278
|
+
* The ref object used to imperatively interact with the field.
|
|
279
|
+
*/
|
|
280
|
+
unstableFieldRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
277
281
|
/**
|
|
278
282
|
* The selected value.
|
|
279
283
|
* Used when the component is controlled.
|
|
@@ -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.3
|
|
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';
|
|
@@ -103,7 +103,7 @@ export var PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Pickers
|
|
|
103
103
|
elementType: PreviousIconButton,
|
|
104
104
|
externalSlotProps: (_slotProps$previousIc = slotProps == null ? void 0 : slotProps.previousIconButton) != null ? _slotProps$previousIc : componentsProps == null ? void 0 : componentsProps.previousIconButton,
|
|
105
105
|
additionalProps: {
|
|
106
|
-
size: '
|
|
106
|
+
size: 'medium',
|
|
107
107
|
title: leftProps.label,
|
|
108
108
|
'aria-label': leftProps.label,
|
|
109
109
|
disabled: leftProps.isDisabled,
|
|
@@ -120,7 +120,7 @@ export var PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Pickers
|
|
|
120
120
|
elementType: NextIconButton,
|
|
121
121
|
externalSlotProps: (_slotProps$nextIconBu = slotProps == null ? void 0 : slotProps.nextIconButton) != null ? _slotProps$nextIconBu : componentsProps == null ? void 0 : componentsProps.nextIconButton,
|
|
122
122
|
additionalProps: {
|
|
123
|
-
size: '
|
|
123
|
+
size: 'medium',
|
|
124
124
|
title: rightProps.label,
|
|
125
125
|
'aria-label': rightProps.label,
|
|
126
126
|
disabled: rightProps.isDisabled,
|
|
@@ -137,6 +137,9 @@ export var PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Pickers
|
|
|
137
137
|
var _useSlotProps = useSlotProps({
|
|
138
138
|
elementType: LeftArrowIcon,
|
|
139
139
|
externalSlotProps: (_slotProps$leftArrowI = slotProps == null ? void 0 : slotProps.leftArrowIcon) != null ? _slotProps$leftArrowI : componentsProps == null ? void 0 : componentsProps.leftArrowIcon,
|
|
140
|
+
additionalProps: {
|
|
141
|
+
fontSize: 'inherit'
|
|
142
|
+
},
|
|
140
143
|
ownerState: undefined
|
|
141
144
|
}),
|
|
142
145
|
leftArrowIconOwnerState = _useSlotProps.ownerState,
|
|
@@ -146,6 +149,9 @@ export var PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Pickers
|
|
|
146
149
|
var _useSlotProps2 = useSlotProps({
|
|
147
150
|
elementType: RightArrowIcon,
|
|
148
151
|
externalSlotProps: (_slotProps$rightArrow = slotProps == null ? void 0 : slotProps.rightArrowIcon) != null ? _slotProps$rightArrow : componentsProps == null ? void 0 : componentsProps.rightArrowIcon,
|
|
152
|
+
additionalProps: {
|
|
153
|
+
fontSize: 'inherit'
|
|
154
|
+
},
|
|
149
155
|
ownerState: undefined
|
|
150
156
|
}),
|
|
151
157
|
rightArrowIconOwnerState = _useSlotProps2.ownerState,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useField } from './useField';
|
|
2
|
-
export { splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections
|
|
2
|
+
export { splitFormatIntoSections, addPositionPropertiesToSections, createDateStrForInputFromSections } from './useField.utils';
|
|
@@ -6,26 +6,24 @@ 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';
|
|
15
|
+
import { getActiveElement } from '../../utils/utils';
|
|
14
16
|
export var useField = function useField(params) {
|
|
15
17
|
var utils = useUtils();
|
|
16
|
-
if (!utils.formatTokenMap) {
|
|
17
|
-
throw new Error('This adapter is not compatible with the field components');
|
|
18
|
-
}
|
|
19
18
|
var _useFieldState = useFieldState(params),
|
|
20
19
|
state = _useFieldState.state,
|
|
21
20
|
selectedSectionIndexes = _useFieldState.selectedSectionIndexes,
|
|
22
|
-
|
|
21
|
+
_setSelectedSections = _useFieldState.setSelectedSections,
|
|
23
22
|
clearValue = _useFieldState.clearValue,
|
|
24
23
|
clearActiveSection = _useFieldState.clearActiveSection,
|
|
25
24
|
updateSectionValue = _useFieldState.updateSectionValue,
|
|
26
25
|
updateValueFromValueStr = _useFieldState.updateValueFromValueStr,
|
|
27
26
|
setTempAndroidValueStr = _useFieldState.setTempAndroidValueStr,
|
|
28
|
-
sectionOrder = _useFieldState.sectionOrder,
|
|
29
27
|
sectionsValueBoundaries = _useFieldState.sectionsValueBoundaries;
|
|
30
28
|
var _useFieldCharacterEdi = useFieldCharacterEditing({
|
|
31
29
|
sections: state.sections,
|
|
@@ -37,8 +35,10 @@ export var useField = function useField(params) {
|
|
|
37
35
|
resetCharacterQuery = _useFieldCharacterEdi.resetCharacterQuery;
|
|
38
36
|
var inputRefProp = params.inputRef,
|
|
39
37
|
internalProps = params.internalProps,
|
|
40
|
-
_params$internalProps = params.internalProps
|
|
41
|
-
|
|
38
|
+
_params$internalProps = params.internalProps,
|
|
39
|
+
_params$internalProps2 = _params$internalProps.readOnly,
|
|
40
|
+
readOnly = _params$internalProps2 === void 0 ? false : _params$internalProps2,
|
|
41
|
+
unstableFieldRef = _params$internalProps.unstableFieldRef,
|
|
42
42
|
_params$forwardedProp = params.forwardedProps,
|
|
43
43
|
onClick = _params$forwardedProp.onClick,
|
|
44
44
|
onKeyDown = _params$forwardedProp.onKeyDown,
|
|
@@ -54,15 +54,23 @@ export var useField = function useField(params) {
|
|
|
54
54
|
var inputRef = React.useRef(null);
|
|
55
55
|
var handleRef = useForkRef(inputRefProp, inputRef);
|
|
56
56
|
var focusTimeoutRef = React.useRef(undefined);
|
|
57
|
+
var theme = useTheme();
|
|
58
|
+
var sectionOrder = React.useMemo(function () {
|
|
59
|
+
return getSectionOrder(state.sections, theme.direction === 'rtl');
|
|
60
|
+
}, [theme.direction, state.sections]);
|
|
57
61
|
var syncSelectionFromDOM = function syncSelectionFromDOM() {
|
|
58
62
|
var _selectionStart;
|
|
63
|
+
if (readOnly) {
|
|
64
|
+
_setSelectedSections(null);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
59
67
|
var browserStartIndex = (_selectionStart = inputRef.current.selectionStart) != null ? _selectionStart : 0;
|
|
60
68
|
var nextSectionIndex = browserStartIndex <= state.sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.
|
|
61
69
|
: state.sections.findIndex(function (section) {
|
|
62
70
|
return section.startInInput - section.startSeparator.length > browserStartIndex;
|
|
63
71
|
});
|
|
64
72
|
var sectionIndex = nextSectionIndex === -1 ? state.sections.length - 1 : nextSectionIndex - 1;
|
|
65
|
-
|
|
73
|
+
_setSelectedSections(sectionIndex);
|
|
66
74
|
};
|
|
67
75
|
var handleInputClick = useEventCallback(function () {
|
|
68
76
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -90,13 +98,13 @@ export var useField = function useField(params) {
|
|
|
90
98
|
if (!input || input !== inputRef.current) {
|
|
91
99
|
return;
|
|
92
100
|
}
|
|
93
|
-
if (selectedSectionIndexes != null) {
|
|
101
|
+
if (selectedSectionIndexes != null || readOnly) {
|
|
94
102
|
return;
|
|
95
103
|
}
|
|
96
104
|
if (
|
|
97
105
|
// avoid selecting all sections when focusing empty field without value
|
|
98
106
|
input.value.length && Number(input.selectionEnd) - Number(input.selectionStart) === input.value.length) {
|
|
99
|
-
|
|
107
|
+
_setSelectedSections('all');
|
|
100
108
|
} else {
|
|
101
109
|
syncSelectionFromDOM();
|
|
102
110
|
}
|
|
@@ -107,7 +115,7 @@ export var useField = function useField(params) {
|
|
|
107
115
|
args[_key3] = arguments[_key3];
|
|
108
116
|
}
|
|
109
117
|
onBlur == null ? void 0 : onBlur.apply(void 0, _toConsumableArray(args));
|
|
110
|
-
|
|
118
|
+
_setSelectedSections(null);
|
|
111
119
|
});
|
|
112
120
|
var handleInputPaste = useEventCallback(function (event) {
|
|
113
121
|
onPaste == null ? void 0 : onPaste(event);
|
|
@@ -148,27 +156,32 @@ export var useField = function useField(params) {
|
|
|
148
156
|
updateValueFromValueStr(cleanValueStr);
|
|
149
157
|
return;
|
|
150
158
|
}
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
var keyPressed;
|
|
160
|
+
if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1) {
|
|
161
|
+
keyPressed = cleanValueStr;
|
|
162
|
+
} else {
|
|
163
|
+
var prevValueStr = cleanString(fieldValueManager.getValueStrFromSections(state.sections));
|
|
164
|
+
var startOfDiffIndex = -1;
|
|
165
|
+
var endOfDiffIndex = -1;
|
|
166
|
+
for (var i = 0; i < prevValueStr.length; i += 1) {
|
|
167
|
+
if (startOfDiffIndex === -1 && prevValueStr[i] !== cleanValueStr[i]) {
|
|
168
|
+
startOfDiffIndex = i;
|
|
169
|
+
}
|
|
170
|
+
if (endOfDiffIndex === -1 && prevValueStr[prevValueStr.length - i - 1] !== cleanValueStr[cleanValueStr.length - i - 1]) {
|
|
171
|
+
endOfDiffIndex = i;
|
|
172
|
+
}
|
|
157
173
|
}
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
var activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
175
|
+
var hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;
|
|
176
|
+
if (hasDiffOutsideOfActiveSection) {
|
|
177
|
+
// TODO: Support if the new date is valid
|
|
178
|
+
return;
|
|
160
179
|
}
|
|
161
|
-
}
|
|
162
|
-
var activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
163
|
-
var hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;
|
|
164
|
-
if (hasDiffOutsideOfActiveSection) {
|
|
165
|
-
// TODO: Support if the new date is valid
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
180
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
181
|
+
// The active section being selected, the browser has replaced its value with the key pressed by the user.
|
|
182
|
+
var activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;
|
|
183
|
+
keyPressed = cleanValueStr.slice(activeSection.start, activeSectionEndRelativeToNewValue);
|
|
184
|
+
}
|
|
172
185
|
if (isAndroid() && keyPressed.length === 0) {
|
|
173
186
|
setTempAndroidValueStr(valueStr);
|
|
174
187
|
return;
|
|
@@ -189,7 +202,7 @@ export var useField = function useField(params) {
|
|
|
189
202
|
// prevent default to make sure that the next line "select all" while updating
|
|
190
203
|
// the internal state at the same time.
|
|
191
204
|
event.preventDefault();
|
|
192
|
-
|
|
205
|
+
_setSelectedSections('all');
|
|
193
206
|
break;
|
|
194
207
|
}
|
|
195
208
|
|
|
@@ -198,13 +211,13 @@ export var useField = function useField(params) {
|
|
|
198
211
|
{
|
|
199
212
|
event.preventDefault();
|
|
200
213
|
if (selectedSectionIndexes == null) {
|
|
201
|
-
|
|
214
|
+
_setSelectedSections(sectionOrder.startIndex);
|
|
202
215
|
} else if (selectedSectionIndexes.startIndex !== selectedSectionIndexes.endIndex) {
|
|
203
|
-
|
|
216
|
+
_setSelectedSections(selectedSectionIndexes.endIndex);
|
|
204
217
|
} else {
|
|
205
218
|
var nextSectionIndex = sectionOrder.neighbors[selectedSectionIndexes.startIndex].rightIndex;
|
|
206
219
|
if (nextSectionIndex !== null) {
|
|
207
|
-
|
|
220
|
+
_setSelectedSections(nextSectionIndex);
|
|
208
221
|
}
|
|
209
222
|
}
|
|
210
223
|
break;
|
|
@@ -215,13 +228,13 @@ export var useField = function useField(params) {
|
|
|
215
228
|
{
|
|
216
229
|
event.preventDefault();
|
|
217
230
|
if (selectedSectionIndexes == null) {
|
|
218
|
-
|
|
231
|
+
_setSelectedSections(sectionOrder.endIndex);
|
|
219
232
|
} else if (selectedSectionIndexes.startIndex !== selectedSectionIndexes.endIndex) {
|
|
220
|
-
|
|
233
|
+
_setSelectedSections(selectedSectionIndexes.startIndex);
|
|
221
234
|
} else {
|
|
222
235
|
var _nextSectionIndex = sectionOrder.neighbors[selectedSectionIndexes.startIndex].leftIndex;
|
|
223
236
|
if (_nextSectionIndex !== null) {
|
|
224
|
-
|
|
237
|
+
_setSelectedSections(_nextSectionIndex);
|
|
225
238
|
}
|
|
226
239
|
}
|
|
227
240
|
break;
|
|
@@ -264,6 +277,12 @@ export var useField = function useField(params) {
|
|
|
264
277
|
});
|
|
265
278
|
useEnhancedEffect(function () {
|
|
266
279
|
if (selectedSectionIndexes == null) {
|
|
280
|
+
if (inputRef.current.scrollLeft) {
|
|
281
|
+
// Ensure that input content is not marked as selected.
|
|
282
|
+
// setting selection range to 0 causes issues in Safari.
|
|
283
|
+
// https://bugs.webkit.org/show_bug.cgi?id=224425
|
|
284
|
+
inputRef.current.scrollLeft = 0;
|
|
285
|
+
}
|
|
267
286
|
return;
|
|
268
287
|
}
|
|
269
288
|
var firstSelectedSection = state.sections[selectedSectionIndexes.startIndex];
|
|
@@ -275,7 +294,11 @@ export var useField = function useField(params) {
|
|
|
275
294
|
selectionEnd += lastSelectedSection.endSeparator.length;
|
|
276
295
|
}
|
|
277
296
|
if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
|
|
297
|
+
// Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321
|
|
298
|
+
var currentScrollTop = inputRef.current.scrollTop;
|
|
278
299
|
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
300
|
+
// Even reading this variable seems to do the trick, but also setting it just to make use of it
|
|
301
|
+
inputRef.current.scrollTop = currentScrollTop;
|
|
279
302
|
}
|
|
280
303
|
});
|
|
281
304
|
var validationError = useValidation(_extends({}, internalProps, {
|
|
@@ -292,7 +315,7 @@ export var useField = function useField(params) {
|
|
|
292
315
|
React.useEffect(function () {
|
|
293
316
|
// Select the right section when focused on mount (`autoFocus = true` on the input)
|
|
294
317
|
if (inputRef.current && inputRef.current === document.activeElement) {
|
|
295
|
-
|
|
318
|
+
_setSelectedSections('all');
|
|
296
319
|
}
|
|
297
320
|
return function () {
|
|
298
321
|
return window.clearTimeout(focusTimeoutRef.current);
|
|
@@ -323,8 +346,31 @@ export var useField = function useField(params) {
|
|
|
323
346
|
}
|
|
324
347
|
return 'tel';
|
|
325
348
|
}, [selectedSectionIndexes, state.sections]);
|
|
326
|
-
var inputHasFocus = inputRef.current && inputRef.current === document
|
|
327
|
-
var shouldShowPlaceholder = !inputHasFocus &&
|
|
349
|
+
var inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);
|
|
350
|
+
var shouldShowPlaceholder = !inputHasFocus && valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
|
|
351
|
+
React.useImperativeHandle(unstableFieldRef, function () {
|
|
352
|
+
return {
|
|
353
|
+
getSections: function getSections() {
|
|
354
|
+
return state.sections;
|
|
355
|
+
},
|
|
356
|
+
getActiveSectionIndex: function getActiveSectionIndex() {
|
|
357
|
+
var _selectionStart2, _selectionEnd;
|
|
358
|
+
var browserStartIndex = (_selectionStart2 = inputRef.current.selectionStart) != null ? _selectionStart2 : 0;
|
|
359
|
+
var browserEndIndex = (_selectionEnd = inputRef.current.selectionEnd) != null ? _selectionEnd : 0;
|
|
360
|
+
if (browserStartIndex === 0 && browserEndIndex === 0) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
var nextSectionIndex = browserStartIndex <= state.sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.
|
|
364
|
+
: state.sections.findIndex(function (section) {
|
|
365
|
+
return section.startInInput - section.startSeparator.length > browserStartIndex;
|
|
366
|
+
});
|
|
367
|
+
return nextSectionIndex === -1 ? state.sections.length - 1 : nextSectionIndex - 1;
|
|
368
|
+
},
|
|
369
|
+
setSelectedSections: function setSelectedSections(activeSectionIndex) {
|
|
370
|
+
return _setSelectedSections(activeSectionIndex);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
});
|
|
328
374
|
return _extends({
|
|
329
375
|
placeholder: state.placeholder,
|
|
330
376
|
autoComplete: 'off'
|