@mui/x-date-pickers 7.0.0-alpha.8 → 7.0.0-alpha.9
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/AdapterLuxon/AdapterLuxon.d.ts +1 -1
- package/AdapterLuxon/AdapterLuxon.js +4 -12
- package/CHANGELOG.md +379 -2
- package/DatePicker/DatePicker.js +0 -3
- package/DatePicker/DatePickerToolbar.js +0 -3
- package/DateTimePicker/DateTimePicker.js +0 -3
- package/DateTimePicker/DateTimePickerToolbar.js +0 -3
- package/DesktopDatePicker/DesktopDatePicker.js +0 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -3
- package/DesktopTimePicker/DesktopTimePicker.js +0 -3
- package/MobileDatePicker/MobileDatePicker.js +0 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +0 -3
- package/MobileTimePicker/MobileTimePicker.js +0 -3
- package/MonthCalendar/MonthCalendar.js +0 -3
- package/MonthCalendar/MonthCalendar.types.d.ts +0 -3
- package/PickersCalendarHeader/PickersCalendarHeader.js +0 -3
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +0 -3
- package/PickersSectionList/PickersSectionList.js +6 -1
- package/PickersTextField/PickersFilledInput/PickersFilledInput.d.ts +11 -0
- package/{internals/components/PickersInput → PickersTextField/PickersFilledInput}/PickersFilledInput.js +98 -25
- package/PickersTextField/PickersFilledInput/index.d.ts +4 -0
- package/PickersTextField/PickersFilledInput/index.js +2 -0
- package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.d.ts +23 -0
- package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js +8 -0
- package/PickersTextField/PickersInput/PickersInput.d.ts +10 -0
- package/PickersTextField/PickersInput/PickersInput.js +196 -0
- package/{internals/components → PickersTextField}/PickersInput/index.d.ts +2 -2
- package/PickersTextField/PickersInput/index.js +2 -0
- package/PickersTextField/PickersInput/pickersInputClasses.d.ts +22 -0
- package/PickersTextField/PickersInput/pickersInputClasses.js +8 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +16 -0
- package/{internals/components/PickersInput/PickersInput.js → PickersTextField/PickersInputBase/PickersInputBase.js} +106 -27
- package/{internals/components/PickersInput/PickersInput.types.d.ts → PickersTextField/PickersInputBase/PickersInputBase.types.d.ts} +3 -13
- package/PickersTextField/PickersInputBase/index.d.ts +4 -0
- package/PickersTextField/PickersInputBase/index.js +2 -0
- package/PickersTextField/PickersInputBase/pickersInputBaseClasses.d.ts +31 -0
- package/PickersTextField/PickersInputBase/pickersInputBaseClasses.js +6 -0
- package/{internals/components/PickersInput → PickersTextField/PickersOutlinedInput}/Outline.d.ts +3 -0
- package/{modern/internals/components/PickersInput → PickersTextField/PickersOutlinedInput}/Outline.js +5 -1
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.d.ts +10 -0
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +190 -0
- package/PickersTextField/PickersOutlinedInput/index.d.ts +4 -0
- package/PickersTextField/PickersOutlinedInput/index.js +2 -0
- package/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.d.ts +22 -0
- package/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js +8 -0
- package/PickersTextField/PickersTextField.d.ts +3 -0
- package/PickersTextField/PickersTextField.js +258 -0
- package/{internals/components/PickersTextField → PickersTextField}/PickersTextField.types.d.ts +5 -2
- package/PickersTextField/index.d.ts +8 -0
- package/PickersTextField/index.js +6 -0
- package/PickersTextField/package.json +6 -0
- package/README.md +1 -1
- package/StaticDatePicker/StaticDatePicker.js +0 -3
- package/StaticDateTimePicker/StaticDateTimePicker.js +0 -3
- package/StaticTimePicker/StaticTimePicker.js +0 -3
- package/TimePicker/TimePicker.js +0 -3
- package/TimePicker/TimePickerToolbar.js +0 -3
- package/YearCalendar/YearCalendar.js +0 -3
- package/YearCalendar/YearCalendar.types.d.ts +0 -3
- package/index.d.ts +2 -1
- package/index.js +3 -2
- package/internals/hooks/useField/useField.js +6 -4
- package/internals/hooks/useField/useField.types.d.ts +4 -2
- package/internals/hooks/useField/useField.utils.d.ts +19 -9
- package/internals/hooks/useField/useField.utils.js +68 -21
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +2 -1
- package/internals/hooks/useField/useFieldCharacterEditing.js +12 -8
- package/internals/hooks/useField/useFieldState.d.ts +1 -0
- package/internals/hooks/useField/useFieldState.js +9 -7
- package/internals/models/props/basePickerProps.d.ts +0 -3
- package/internals/models/props/toolbar.d.ts +0 -3
- package/internals/utils/valueManagers.js +2 -2
- package/legacy/AdapterLuxon/AdapterLuxon.js +4 -12
- package/legacy/DatePicker/DatePicker.js +0 -3
- package/legacy/DatePicker/DatePickerToolbar.js +0 -3
- package/legacy/DateTimePicker/DateTimePicker.js +0 -3
- package/legacy/DateTimePicker/DateTimePickerToolbar.js +0 -3
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +0 -3
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -3
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +0 -3
- package/legacy/MobileDatePicker/MobileDatePicker.js +0 -3
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +0 -3
- package/legacy/MobileTimePicker/MobileTimePicker.js +0 -3
- package/legacy/MonthCalendar/MonthCalendar.js +0 -3
- package/legacy/PickersCalendarHeader/PickersCalendarHeader.js +0 -3
- package/legacy/PickersSectionList/PickersSectionList.js +6 -1
- package/legacy/{internals/components/PickersInput → PickersTextField/PickersFilledInput}/PickersFilledInput.js +99 -26
- package/legacy/PickersTextField/PickersFilledInput/index.js +2 -0
- package/legacy/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js +8 -0
- package/legacy/PickersTextField/PickersInput/PickersInput.js +190 -0
- package/legacy/PickersTextField/PickersInput/index.js +2 -0
- package/legacy/PickersTextField/PickersInput/pickersInputClasses.js +8 -0
- package/legacy/{internals/components/PickersInput/PickersInput.js → PickersTextField/PickersInputBase/PickersInputBase.js} +106 -27
- package/legacy/PickersTextField/PickersInputBase/index.js +2 -0
- package/legacy/PickersTextField/PickersInputBase/pickersInputBaseClasses.js +6 -0
- package/legacy/{internals/components/PickersInput → PickersTextField/PickersOutlinedInput}/Outline.js +7 -1
- package/legacy/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +183 -0
- package/legacy/PickersTextField/PickersOutlinedInput/index.js +2 -0
- package/legacy/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js +8 -0
- package/legacy/{internals/components/PickersTextField → PickersTextField}/PickersTextField.js +128 -8
- package/legacy/PickersTextField/index.js +6 -0
- package/legacy/StaticDatePicker/StaticDatePicker.js +0 -3
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +0 -3
- package/legacy/StaticTimePicker/StaticTimePicker.js +0 -3
- package/legacy/TimePicker/TimePicker.js +0 -3
- package/legacy/TimePicker/TimePickerToolbar.js +0 -3
- package/legacy/YearCalendar/YearCalendar.js +0 -3
- package/legacy/index.js +3 -2
- package/legacy/internals/hooks/useField/useField.js +6 -4
- package/legacy/internals/hooks/useField/useField.utils.js +71 -20
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +12 -8
- package/legacy/internals/hooks/useField/useFieldState.js +15 -11
- package/legacy/internals/utils/valueManagers.js +2 -2
- package/modern/AdapterLuxon/AdapterLuxon.js +3 -11
- package/modern/DatePicker/DatePicker.js +0 -3
- package/modern/DatePicker/DatePickerToolbar.js +0 -3
- package/modern/DateTimePicker/DateTimePicker.js +0 -3
- package/modern/DateTimePicker/DateTimePickerToolbar.js +0 -3
- package/modern/DesktopDatePicker/DesktopDatePicker.js +0 -3
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -3
- package/modern/DesktopTimePicker/DesktopTimePicker.js +0 -3
- package/modern/MobileDatePicker/MobileDatePicker.js +0 -3
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +0 -3
- package/modern/MobileTimePicker/MobileTimePicker.js +0 -3
- package/modern/MonthCalendar/MonthCalendar.js +0 -3
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +0 -3
- package/modern/PickersSectionList/PickersSectionList.js +6 -1
- package/modern/{internals/components/PickersInput → PickersTextField/PickersFilledInput}/PickersFilledInput.js +98 -25
- package/modern/PickersTextField/PickersFilledInput/index.js +2 -0
- package/modern/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js +8 -0
- package/modern/PickersTextField/PickersInput/PickersInput.js +196 -0
- package/modern/PickersTextField/PickersInput/index.js +2 -0
- package/modern/PickersTextField/PickersInput/pickersInputClasses.js +8 -0
- package/modern/{internals/components/PickersInput/PickersInput.js → PickersTextField/PickersInputBase/PickersInputBase.js} +106 -27
- package/modern/PickersTextField/PickersInputBase/index.js +2 -0
- package/modern/PickersTextField/PickersInputBase/pickersInputBaseClasses.js +6 -0
- package/{internals/components/PickersInput → modern/PickersTextField/PickersOutlinedInput}/Outline.js +5 -1
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +190 -0
- package/modern/PickersTextField/PickersOutlinedInput/index.js +2 -0
- package/modern/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js +8 -0
- package/modern/PickersTextField/PickersTextField.js +258 -0
- package/modern/PickersTextField/index.js +6 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +0 -3
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +0 -3
- package/modern/StaticTimePicker/StaticTimePicker.js +0 -3
- package/modern/TimePicker/TimePicker.js +0 -3
- package/modern/TimePicker/TimePickerToolbar.js +0 -3
- package/modern/YearCalendar/YearCalendar.js +0 -3
- package/modern/index.js +3 -2
- package/modern/internals/hooks/useField/useField.js +5 -3
- package/modern/internals/hooks/useField/useField.utils.js +68 -21
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +12 -8
- package/modern/internals/hooks/useField/useFieldState.js +9 -7
- package/modern/internals/utils/valueManagers.js +2 -2
- package/node/AdapterLuxon/AdapterLuxon.js +3 -11
- package/node/DatePicker/DatePicker.js +0 -3
- package/node/DatePicker/DatePickerToolbar.js +0 -3
- package/node/DateTimePicker/DateTimePicker.js +0 -3
- package/node/DateTimePicker/DateTimePickerToolbar.js +0 -3
- package/node/DesktopDatePicker/DesktopDatePicker.js +0 -3
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -3
- package/node/DesktopTimePicker/DesktopTimePicker.js +0 -3
- package/node/MobileDatePicker/MobileDatePicker.js +0 -3
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +0 -3
- package/node/MobileTimePicker/MobileTimePicker.js +0 -3
- package/node/MonthCalendar/MonthCalendar.js +0 -3
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +0 -3
- package/node/PickersSectionList/PickersSectionList.js +6 -1
- package/node/{internals/components/PickersInput → PickersTextField/PickersFilledInput}/PickersFilledInput.js +102 -30
- package/node/PickersTextField/PickersFilledInput/index.js +25 -0
- package/node/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js +16 -0
- package/node/PickersTextField/PickersInput/PickersInput.js +204 -0
- package/node/{internals/components → PickersTextField}/PickersInput/index.js +0 -7
- package/node/PickersTextField/PickersInput/pickersInputClasses.js +16 -0
- package/node/{internals/components/PickersInput/PickersInput.js → PickersTextField/PickersInputBase/PickersInputBase.js} +105 -27
- package/node/PickersTextField/PickersInputBase/index.js +25 -0
- package/node/PickersTextField/PickersInputBase/pickersInputBaseClasses.js +14 -0
- package/node/{internals/components/PickersInput → PickersTextField/PickersOutlinedInput}/Outline.js +5 -1
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +197 -0
- package/node/PickersTextField/PickersOutlinedInput/index.js +25 -0
- package/node/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js +16 -0
- package/node/{internals/components/PickersTextField → PickersTextField}/PickersTextField.js +128 -9
- package/node/PickersTextField/index.js +78 -0
- package/node/StaticDatePicker/StaticDatePicker.js +0 -3
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +0 -3
- package/node/StaticTimePicker/StaticTimePicker.js +0 -3
- package/node/TimePicker/TimePicker.js +0 -3
- package/node/TimePicker/TimePickerToolbar.js +0 -3
- package/node/YearCalendar/YearCalendar.js +0 -3
- package/node/index.js +17 -5
- package/node/internals/hooks/useField/useField.js +5 -3
- package/node/internals/hooks/useField/useField.utils.js +73 -22
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +11 -7
- package/node/internals/hooks/useField/useFieldState.js +8 -6
- package/node/internals/utils/valueManagers.js +2 -2
- package/package.json +7 -7
- package/themeAugmentation/components.d.ts +26 -0
- package/themeAugmentation/overrides.d.ts +16 -0
- package/themeAugmentation/props.d.ts +16 -0
- package/internals/components/PickersInput/PickersFilledInput.d.ts +0 -3
- package/internals/components/PickersInput/PickersInput.d.ts +0 -13
- package/internals/components/PickersInput/PickersOutlinedInput.d.ts +0 -3
- package/internals/components/PickersInput/PickersOutlinedInput.js +0 -117
- package/internals/components/PickersInput/PickersStandardInput.d.ts +0 -3
- package/internals/components/PickersInput/PickersStandardInput.js +0 -123
- package/internals/components/PickersInput/index.js +0 -3
- package/internals/components/PickersInput/pickersInputClasses.d.ts +0 -84
- package/internals/components/PickersInput/pickersInputClasses.js +0 -18
- package/internals/components/PickersTextField/PickersTextField.d.ts +0 -2
- package/internals/components/PickersTextField/PickersTextField.js +0 -138
- package/internals/components/PickersTextField/index.d.ts +0 -1
- package/internals/components/PickersTextField/index.js +0 -1
- package/legacy/internals/components/PickersInput/PickersOutlinedInput.js +0 -110
- package/legacy/internals/components/PickersInput/PickersStandardInput.js +0 -117
- package/legacy/internals/components/PickersInput/index.js +0 -3
- package/legacy/internals/components/PickersInput/pickersInputClasses.js +0 -18
- package/legacy/internals/components/PickersTextField/index.js +0 -1
- package/modern/internals/components/PickersInput/PickersOutlinedInput.js +0 -117
- package/modern/internals/components/PickersInput/PickersStandardInput.js +0 -123
- package/modern/internals/components/PickersInput/index.js +0 -3
- package/modern/internals/components/PickersInput/pickersInputClasses.js +0 -18
- package/modern/internals/components/PickersTextField/PickersTextField.js +0 -138
- package/modern/internals/components/PickersTextField/index.js +0 -1
- package/node/internals/components/PickersInput/PickersOutlinedInput.js +0 -125
- package/node/internals/components/PickersInput/PickersStandardInput.js +0 -132
- package/node/internals/components/PickersInput/pickersInputClasses.js +0 -29
- package/node/internals/components/PickersTextField/index.js +0 -12
- /package/{internals/components/PickersInput/PickersInput.types.js → PickersTextField/PickersInputBase/PickersInputBase.types.js} +0 -0
- /package/{internals/components/PickersTextField → PickersTextField}/PickersTextField.types.js +0 -0
- /package/{internals/components/PickersTextField → PickersTextField}/pickersTextFieldClasses.d.ts +0 -0
- /package/{internals/components/PickersTextField → PickersTextField}/pickersTextFieldClasses.js +0 -0
- /package/legacy/{internals/components/PickersInput/PickersInput.types.js → PickersTextField/PickersInputBase/PickersInputBase.types.js} +0 -0
- /package/legacy/{internals/components/PickersTextField → PickersTextField}/PickersTextField.types.js +0 -0
- /package/legacy/{internals/components/PickersTextField → PickersTextField}/pickersTextFieldClasses.js +0 -0
- /package/modern/{internals/components/PickersInput/PickersInput.types.js → PickersTextField/PickersInputBase/PickersInputBase.types.js} +0 -0
- /package/modern/{internals/components/PickersTextField → PickersTextField}/PickersTextField.types.js +0 -0
- /package/modern/{internals/components/PickersTextField → PickersTextField}/pickersTextFieldClasses.js +0 -0
- /package/node/{internals/components/PickersInput/PickersInput.types.js → PickersTextField/PickersInputBase/PickersInputBase.types.js} +0 -0
- /package/node/{internals/components/PickersTextField → PickersTextField}/PickersTextField.types.js +0 -0
- /package/node/{internals/components/PickersTextField → PickersTextField}/pickersTextFieldClasses.js +0 -0
|
@@ -8,23 +8,25 @@ exports.PickersTextField = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
12
13
|
var _styles = require("@mui/material/styles");
|
|
13
14
|
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
14
|
-
var
|
|
15
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
16
|
+
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
15
17
|
var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
|
|
16
18
|
var _FormHelperText = _interopRequireDefault(require("@mui/material/FormHelperText"));
|
|
17
19
|
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
18
20
|
var _pickersTextFieldClasses = require("./pickersTextFieldClasses");
|
|
19
|
-
var _PickersOutlinedInput = require("
|
|
20
|
-
var _PickersFilledInput = require("
|
|
21
|
-
var
|
|
21
|
+
var _PickersOutlinedInput = require("./PickersOutlinedInput");
|
|
22
|
+
var _PickersFilledInput = require("./PickersFilledInput");
|
|
23
|
+
var _PickersInput = require("./PickersInput");
|
|
22
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
25
|
const _excluded = ["onFocus", "onBlur", "className", "color", "disabled", "error", "variant", "required", "InputProps", "inputProps", "inputRef", "sectionListRef", "elements", "areAllSectionsEmpty", "onClick", "onKeyDown", "onKeyUp", "onPaste", "onInput", "endAdornment", "startAdornment", "tabIndex", "contentEditable", "focused", "value", "onChange", "fullWidth", "id", "helperText", "FormHelperTextProps", "label", "InputLabelProps"];
|
|
24
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
28
|
const VARIANT_COMPONENT = {
|
|
27
|
-
standard:
|
|
29
|
+
standard: _PickersInput.PickersInput,
|
|
28
30
|
filled: _PickersFilledInput.PickersFilledInput,
|
|
29
31
|
outlined: _PickersOutlinedInput.PickersOutlinedInput
|
|
30
32
|
};
|
|
@@ -43,9 +45,13 @@ const useUtilityClasses = ownerState => {
|
|
|
43
45
|
const slots = {
|
|
44
46
|
root: ['root', focused && !disabled && 'focused', disabled && 'disabled', required && 'required']
|
|
45
47
|
};
|
|
46
|
-
return (0,
|
|
48
|
+
return (0, _composeClasses.default)(slots, _pickersTextFieldClasses.getPickersTextFieldUtilityClass, classes);
|
|
47
49
|
};
|
|
48
|
-
const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField(
|
|
50
|
+
const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRef(function PickersTextField(inProps, ref) {
|
|
51
|
+
const props = (0, _styles.useThemeProps)({
|
|
52
|
+
props: inProps,
|
|
53
|
+
name: 'MuiPickersTextField'
|
|
54
|
+
});
|
|
49
55
|
const {
|
|
50
56
|
// Props used by FormControl
|
|
51
57
|
onFocus,
|
|
@@ -86,7 +92,7 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
|
|
|
86
92
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
87
93
|
const rootRef = React.useRef(null);
|
|
88
94
|
const handleRootRef = (0, _useForkRef.default)(ref, rootRef);
|
|
89
|
-
const id = (0,
|
|
95
|
+
const id = (0, _useId.default)(idProp);
|
|
90
96
|
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
91
97
|
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
92
98
|
const ownerState = (0, _extends2.default)({}, props, {
|
|
@@ -143,4 +149,117 @@ const PickersTextField = exports.PickersTextField = /*#__PURE__*/React.forwardRe
|
|
|
143
149
|
children: helperText
|
|
144
150
|
}))]
|
|
145
151
|
}));
|
|
146
|
-
});
|
|
152
|
+
});
|
|
153
|
+
process.env.NODE_ENV !== "production" ? PickersTextField.propTypes = {
|
|
154
|
+
// ----------------------------- Warning --------------------------------
|
|
155
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
156
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
157
|
+
// ----------------------------------------------------------------------
|
|
158
|
+
/**
|
|
159
|
+
* Is `true` if the current values equals the empty value.
|
|
160
|
+
* For a single item value, it means that `value === null`
|
|
161
|
+
* For a range value, it means that `value === [null, null]`
|
|
162
|
+
*/
|
|
163
|
+
areAllSectionsEmpty: _propTypes.default.bool.isRequired,
|
|
164
|
+
className: _propTypes.default.string,
|
|
165
|
+
/**
|
|
166
|
+
* The color of the component.
|
|
167
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
168
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
169
|
+
* @default 'primary'
|
|
170
|
+
*/
|
|
171
|
+
color: _propTypes.default.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
|
|
172
|
+
component: _propTypes.default.elementType,
|
|
173
|
+
/**
|
|
174
|
+
* If true, the whole element is editable.
|
|
175
|
+
* Useful when all the sections are selected.
|
|
176
|
+
*/
|
|
177
|
+
contentEditable: _propTypes.default.bool.isRequired,
|
|
178
|
+
disabled: _propTypes.default.bool.isRequired,
|
|
179
|
+
/**
|
|
180
|
+
* The elements to render.
|
|
181
|
+
* Each element contains the prop to edit a section of the value.
|
|
182
|
+
*/
|
|
183
|
+
elements: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
184
|
+
after: _propTypes.default.object.isRequired,
|
|
185
|
+
before: _propTypes.default.object.isRequired,
|
|
186
|
+
container: _propTypes.default.object.isRequired,
|
|
187
|
+
content: _propTypes.default.object.isRequired
|
|
188
|
+
})).isRequired,
|
|
189
|
+
endAdornment: _propTypes.default.node,
|
|
190
|
+
error: _propTypes.default.bool.isRequired,
|
|
191
|
+
/**
|
|
192
|
+
* If `true`, the component is displayed in focused state.
|
|
193
|
+
*/
|
|
194
|
+
focused: _propTypes.default.bool,
|
|
195
|
+
FormHelperTextProps: _propTypes.default.object,
|
|
196
|
+
fullWidth: _propTypes.default.bool,
|
|
197
|
+
/**
|
|
198
|
+
* The helper text content.
|
|
199
|
+
*/
|
|
200
|
+
helperText: _propTypes.default.node,
|
|
201
|
+
/**
|
|
202
|
+
* If `true`, the label is hidden.
|
|
203
|
+
* This is used to increase density for a `FilledInput`.
|
|
204
|
+
* Be sure to add `aria-label` to the `input` element.
|
|
205
|
+
* @default false
|
|
206
|
+
*/
|
|
207
|
+
hiddenLabel: _propTypes.default.bool,
|
|
208
|
+
id: _propTypes.default.string,
|
|
209
|
+
InputLabelProps: _propTypes.default.object,
|
|
210
|
+
inputProps: _propTypes.default.object,
|
|
211
|
+
/**
|
|
212
|
+
* Props applied to the Input element.
|
|
213
|
+
* It will be a [`FilledInput`](/material-ui/api/filled-input/),
|
|
214
|
+
* [`OutlinedInput`](/material-ui/api/outlined-input/) or [`Input`](/material-ui/api/input/)
|
|
215
|
+
* component depending on the `variant` prop value.
|
|
216
|
+
*/
|
|
217
|
+
InputProps: _propTypes.default.object,
|
|
218
|
+
inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
219
|
+
current: _propTypes.default.object
|
|
220
|
+
})]),
|
|
221
|
+
label: _propTypes.default.node,
|
|
222
|
+
/**
|
|
223
|
+
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
|
224
|
+
* @default 'none'
|
|
225
|
+
*/
|
|
226
|
+
margin: _propTypes.default.oneOf(['dense', 'none', 'normal']),
|
|
227
|
+
onBlur: _propTypes.default.func.isRequired,
|
|
228
|
+
onChange: _propTypes.default.func.isRequired,
|
|
229
|
+
onClick: _propTypes.default.func.isRequired,
|
|
230
|
+
onFocus: _propTypes.default.func.isRequired,
|
|
231
|
+
onInput: _propTypes.default.func.isRequired,
|
|
232
|
+
onKeyDown: _propTypes.default.func.isRequired,
|
|
233
|
+
onPaste: _propTypes.default.func.isRequired,
|
|
234
|
+
readOnly: _propTypes.default.bool,
|
|
235
|
+
/**
|
|
236
|
+
* If `true`, the label will indicate that the `input` is required.
|
|
237
|
+
* @default false
|
|
238
|
+
*/
|
|
239
|
+
required: _propTypes.default.bool,
|
|
240
|
+
sectionListRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
241
|
+
current: _propTypes.default.shape({
|
|
242
|
+
getRoot: _propTypes.default.func.isRequired,
|
|
243
|
+
getSectionContainer: _propTypes.default.func.isRequired,
|
|
244
|
+
getSectionContent: _propTypes.default.func.isRequired,
|
|
245
|
+
getSectionIndexFromDOMElement: _propTypes.default.func.isRequired
|
|
246
|
+
})
|
|
247
|
+
})]),
|
|
248
|
+
/**
|
|
249
|
+
* The size of the component.
|
|
250
|
+
* @default 'medium'
|
|
251
|
+
*/
|
|
252
|
+
size: _propTypes.default.oneOf(['medium', 'small']),
|
|
253
|
+
startAdornment: _propTypes.default.node,
|
|
254
|
+
style: _propTypes.default.object,
|
|
255
|
+
/**
|
|
256
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
257
|
+
*/
|
|
258
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
259
|
+
value: _propTypes.default.string.isRequired,
|
|
260
|
+
/**
|
|
261
|
+
* The variant to use.
|
|
262
|
+
* @default 'outlined'
|
|
263
|
+
*/
|
|
264
|
+
variant: _propTypes.default.oneOf(['filled', 'outlined', 'standard'])
|
|
265
|
+
} : void 0;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
PickersTextField: true,
|
|
8
|
+
pickersTextFieldClasses: true,
|
|
9
|
+
getPickersTextFieldUtilityClass: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "PickersTextField", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _PickersTextField.PickersTextField;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "getPickersTextFieldUtilityClass", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _pickersTextFieldClasses.getPickersTextFieldUtilityClass;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "pickersTextFieldClasses", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _pickersTextFieldClasses.pickersTextFieldClasses;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _PickersTextField = require("./PickersTextField");
|
|
30
|
+
var _pickersTextFieldClasses = require("./pickersTextFieldClasses");
|
|
31
|
+
var _PickersInput = require("./PickersInput");
|
|
32
|
+
Object.keys(_PickersInput).forEach(function (key) {
|
|
33
|
+
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
+
if (key in exports && exports[key] === _PickersInput[key]) return;
|
|
36
|
+
Object.defineProperty(exports, key, {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _PickersInput[key];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
var _PickersFilledInput = require("./PickersFilledInput");
|
|
44
|
+
Object.keys(_PickersFilledInput).forEach(function (key) {
|
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
47
|
+
if (key in exports && exports[key] === _PickersFilledInput[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _PickersFilledInput[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
var _PickersOutlinedInput = require("./PickersOutlinedInput");
|
|
56
|
+
Object.keys(_PickersOutlinedInput).forEach(function (key) {
|
|
57
|
+
if (key === "default" || key === "__esModule") return;
|
|
58
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
59
|
+
if (key in exports && exports[key] === _PickersOutlinedInput[key]) return;
|
|
60
|
+
Object.defineProperty(exports, key, {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _PickersOutlinedInput[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
var _PickersInputBase = require("./PickersInputBase");
|
|
68
|
+
Object.keys(_PickersInputBase).forEach(function (key) {
|
|
69
|
+
if (key === "default" || key === "__esModule") return;
|
|
70
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
71
|
+
if (key in exports && exports[key] === _PickersInputBase[key]) return;
|
|
72
|
+
Object.defineProperty(exports, key, {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _PickersInputBase[key];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -68,9 +68,6 @@ StaticDatePicker.propTypes = {
|
|
|
68
68
|
* - the `input` element if there is a field rendered.
|
|
69
69
|
*/
|
|
70
70
|
autoFocus: _propTypes.default.bool,
|
|
71
|
-
/**
|
|
72
|
-
* Class name applied to the root element.
|
|
73
|
-
*/
|
|
74
71
|
className: _propTypes.default.string,
|
|
75
72
|
/**
|
|
76
73
|
* Formats the day of week displayed in the calendar header.
|
|
@@ -88,9 +88,6 @@ StaticDateTimePicker.propTypes = {
|
|
|
88
88
|
* - the `input` element if there is a field rendered.
|
|
89
89
|
*/
|
|
90
90
|
autoFocus: _propTypes.default.bool,
|
|
91
|
-
/**
|
|
92
|
-
* Class name applied to the root element.
|
|
93
|
-
*/
|
|
94
91
|
className: _propTypes.default.string,
|
|
95
92
|
/**
|
|
96
93
|
* Formats the day of week displayed in the calendar header.
|
|
@@ -80,9 +80,6 @@ StaticTimePicker.propTypes = {
|
|
|
80
80
|
* - the `input` element if there is a field rendered.
|
|
81
81
|
*/
|
|
82
82
|
autoFocus: _propTypes.default.bool,
|
|
83
|
-
/**
|
|
84
|
-
* Class name applied to the root element.
|
|
85
|
-
*/
|
|
86
83
|
className: _propTypes.default.string,
|
|
87
84
|
/**
|
|
88
85
|
* The default value.
|
|
@@ -74,9 +74,6 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
74
74
|
* - the `input` element if there is a field rendered.
|
|
75
75
|
*/
|
|
76
76
|
autoFocus: _propTypes.default.bool,
|
|
77
|
-
/**
|
|
78
|
-
* Class name applied to the root element.
|
|
79
|
-
*/
|
|
80
77
|
className: _propTypes.default.string,
|
|
81
78
|
/**
|
|
82
79
|
* If `true`, the popover or modal will close after submitting the full date.
|
|
@@ -222,9 +222,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
222
222
|
ampm: _propTypes.default.bool,
|
|
223
223
|
ampmInClock: _propTypes.default.bool,
|
|
224
224
|
classes: _propTypes.default.object,
|
|
225
|
-
/**
|
|
226
|
-
* className applied to the root component.
|
|
227
|
-
*/
|
|
228
225
|
className: _propTypes.default.string,
|
|
229
226
|
disabled: _propTypes.default.bool,
|
|
230
227
|
/**
|
|
@@ -273,9 +273,6 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
|
|
|
273
273
|
* Override or extend the styles applied to the component.
|
|
274
274
|
*/
|
|
275
275
|
classes: _propTypes.default.object,
|
|
276
|
-
/**
|
|
277
|
-
* className applied to the root element.
|
|
278
|
-
*/
|
|
279
276
|
className: _propTypes.default.string,
|
|
280
277
|
/**
|
|
281
278
|
* The default selected value.
|
package/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers v7.0.0-alpha.
|
|
2
|
+
* @mui/x-date-pickers v7.0.0-alpha.9
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -79,15 +79,15 @@ Object.keys(_PickersDay).forEach(function (key) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
|
-
var
|
|
83
|
-
Object.keys(
|
|
82
|
+
var _pickersLocaleTextApi = require("./locales/utils/pickersLocaleTextApi");
|
|
83
|
+
Object.keys(_pickersLocaleTextApi).forEach(function (key) {
|
|
84
84
|
if (key === "default" || key === "__esModule") return;
|
|
85
85
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
-
if (key in exports && exports[key] ===
|
|
86
|
+
if (key in exports && exports[key] === _pickersLocaleTextApi[key]) return;
|
|
87
87
|
Object.defineProperty(exports, key, {
|
|
88
88
|
enumerable: true,
|
|
89
89
|
get: function () {
|
|
90
|
-
return
|
|
90
|
+
return _pickersLocaleTextApi[key];
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
@@ -391,6 +391,18 @@ Object.keys(_PickersCalendarHeader).forEach(function (key) {
|
|
|
391
391
|
}
|
|
392
392
|
});
|
|
393
393
|
});
|
|
394
|
+
var _PickersTextField = require("./PickersTextField");
|
|
395
|
+
Object.keys(_PickersTextField).forEach(function (key) {
|
|
396
|
+
if (key === "default" || key === "__esModule") return;
|
|
397
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
398
|
+
if (key in exports && exports[key] === _PickersTextField[key]) return;
|
|
399
|
+
Object.defineProperty(exports, key, {
|
|
400
|
+
enumerable: true,
|
|
401
|
+
get: function () {
|
|
402
|
+
return _PickersTextField[key];
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
});
|
|
394
406
|
var _PickersSectionList = require("./PickersSectionList");
|
|
395
407
|
Object.keys(_PickersSectionList).forEach(function (key) {
|
|
396
408
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -33,6 +33,7 @@ const useField = params => {
|
|
|
33
33
|
updateValueFromValueStr,
|
|
34
34
|
setTempAndroidValueStr,
|
|
35
35
|
sectionsValueBoundaries,
|
|
36
|
+
localizedDigits,
|
|
36
37
|
placeholder,
|
|
37
38
|
timezone
|
|
38
39
|
} = (0, _useFieldState.useFieldState)(params);
|
|
@@ -68,6 +69,7 @@ const useField = params => {
|
|
|
68
69
|
sections: state.sections,
|
|
69
70
|
updateSectionValue,
|
|
70
71
|
sectionsValueBoundaries,
|
|
72
|
+
localizedDigits,
|
|
71
73
|
setTempAndroidValueStr,
|
|
72
74
|
timezone
|
|
73
75
|
});
|
|
@@ -199,7 +201,7 @@ const useField = params => {
|
|
|
199
201
|
if (selectedSectionIndexes.startIndex === 0 && selectedSectionIndexes.endIndex === state.sections.length - 1 && cleanValueStr.length === 1) {
|
|
200
202
|
keyPressed = cleanValueStr;
|
|
201
203
|
} else {
|
|
202
|
-
const prevValueStr = (0, _useField.cleanString)(fieldValueManager.getValueStrFromSections(state.sections, isRTL));
|
|
204
|
+
const prevValueStr = (0, _useField.cleanString)(fieldValueManager.getValueStrFromSections(state.sections, localizedDigits, isRTL));
|
|
203
205
|
let startOfDiffIndex = -1;
|
|
204
206
|
let endOfDiffIndex = -1;
|
|
205
207
|
for (let i = 0; i < prevValueStr.length; i += 1) {
|
|
@@ -309,7 +311,7 @@ const useField = params => {
|
|
|
309
311
|
}
|
|
310
312
|
const activeSection = state.sections[selectedSectionIndexes.startIndex];
|
|
311
313
|
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
312
|
-
const newSectionValue = (0, _useField.adjustSectionValue)(utils, timezone, activeSection, event.key, sectionsValueBoundaries, activeDateManager.date, {
|
|
314
|
+
const newSectionValue = (0, _useField.adjustSectionValue)(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {
|
|
313
315
|
minutesStep
|
|
314
316
|
});
|
|
315
317
|
updateSectionValue({
|
|
@@ -392,7 +394,7 @@ const useField = params => {
|
|
|
392
394
|
}
|
|
393
395
|
}, [state.tempValueStrAndroid]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
394
396
|
|
|
395
|
-
const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getValueStrFromSections(state.sections, isRTL), [state.sections, fieldValueManager, state.tempValueStrAndroid, isRTL]);
|
|
397
|
+
const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getValueStrFromSections(state.sections, localizedDigits, isRTL), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRTL]);
|
|
396
398
|
const inputMode = React.useMemo(() => {
|
|
397
399
|
if (selectedSectionIndexes == null) {
|
|
398
400
|
return 'text';
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.validateSections = exports.splitFormatIntoSections = exports.mergeDateIntoReferenceDate = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForInputFromSections = exports.cleanString = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.adjustSectionValue = exports.addPositionPropertiesToSections = void 0;
|
|
7
|
+
exports.validateSections = exports.splitFormatIntoSections = exports.removeLocalizedDigits = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForInputFromSections = exports.cleanString = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.adjustSectionValue = exports.addPositionPropertiesToSections = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _dateUtils = require("../../utils/date-utils");
|
|
10
10
|
const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
@@ -74,8 +74,59 @@ const getLetterEditingOptions = (utils, timezone, sectionType, format) => {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
+
|
|
78
|
+
// This format should be the same on all the adapters
|
|
79
|
+
// If some adapter does not respect this convention, then we will need to hardcode the format on each adapter.
|
|
77
80
|
exports.getLetterEditingOptions = getLetterEditingOptions;
|
|
78
|
-
const
|
|
81
|
+
const FORMAT_SECONDS_NO_LEADING_ZEROS = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = 's';
|
|
82
|
+
const NON_LOCALIZED_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
83
|
+
const getLocalizedDigits = utils => {
|
|
84
|
+
const today = utils.date(undefined);
|
|
85
|
+
const formattedZero = utils.formatByString(utils.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);
|
|
86
|
+
if (formattedZero === '0') {
|
|
87
|
+
return NON_LOCALIZED_DIGITS;
|
|
88
|
+
}
|
|
89
|
+
return Array.from({
|
|
90
|
+
length: 10
|
|
91
|
+
}).map((_, index) => utils.formatByString(utils.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));
|
|
92
|
+
};
|
|
93
|
+
exports.getLocalizedDigits = getLocalizedDigits;
|
|
94
|
+
const removeLocalizedDigits = (valueStr, localizedDigits) => {
|
|
95
|
+
if (localizedDigits[0] === '0') {
|
|
96
|
+
return valueStr;
|
|
97
|
+
}
|
|
98
|
+
const digits = [];
|
|
99
|
+
let currentFormattedDigit = '';
|
|
100
|
+
for (let i = 0; i < valueStr.length; i += 1) {
|
|
101
|
+
currentFormattedDigit += valueStr[i];
|
|
102
|
+
const matchingDigitIndex = localizedDigits.indexOf(currentFormattedDigit);
|
|
103
|
+
if (matchingDigitIndex > -1) {
|
|
104
|
+
digits.push(matchingDigitIndex.toString());
|
|
105
|
+
currentFormattedDigit = '';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return digits.join('');
|
|
109
|
+
};
|
|
110
|
+
exports.removeLocalizedDigits = removeLocalizedDigits;
|
|
111
|
+
const applyLocalizedDigits = (valueStr, localizedDigits) => {
|
|
112
|
+
if (localizedDigits[0] === '0') {
|
|
113
|
+
return valueStr;
|
|
114
|
+
}
|
|
115
|
+
return valueStr.split('').map(char => localizedDigits[Number(char)]).join('');
|
|
116
|
+
};
|
|
117
|
+
exports.applyLocalizedDigits = applyLocalizedDigits;
|
|
118
|
+
const isStringNumber = (valueStr, localizedDigits) => {
|
|
119
|
+
const nonLocalizedValueStr = removeLocalizedDigits(valueStr, localizedDigits);
|
|
120
|
+
return !Number.isNaN(Number(nonLocalizedValueStr));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Remove the leading zeroes to a digit section value.
|
|
125
|
+
* E.g.: `03` => `3`
|
|
126
|
+
* Warning: Should only be called with non-localized digits. Call `removeLocalizedDigits` with your value if needed.
|
|
127
|
+
*/
|
|
128
|
+
exports.isStringNumber = isStringNumber;
|
|
129
|
+
const cleanLeadingZeros = (valueStr, size) => {
|
|
79
130
|
let cleanValueStr = valueStr;
|
|
80
131
|
|
|
81
132
|
// Remove the leading zeros
|
|
@@ -88,7 +139,7 @@ const cleanLeadingZeros = (utils, valueStr, size) => {
|
|
|
88
139
|
return cleanValueStr;
|
|
89
140
|
};
|
|
90
141
|
exports.cleanLeadingZeros = cleanLeadingZeros;
|
|
91
|
-
const cleanDigitSectionValue = (utils,
|
|
142
|
+
const cleanDigitSectionValue = (utils, value, sectionBoundaries, localizedDigits, section) => {
|
|
92
143
|
if (process.env.NODE_ENV !== 'production') {
|
|
93
144
|
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
|
94
145
|
throw new Error([`MUI X: The token "${section.format}" is a digit format with letter in it.'
|
|
@@ -101,14 +152,14 @@ const cleanDigitSectionValue = (utils, timezone, value, sectionBoundaries, secti
|
|
|
101
152
|
}
|
|
102
153
|
|
|
103
154
|
// queryValue without leading `0` (`01` => `1`)
|
|
104
|
-
|
|
155
|
+
let valueStr = value.toString();
|
|
105
156
|
if (section.hasLeadingZerosInInput) {
|
|
106
|
-
|
|
157
|
+
valueStr = cleanLeadingZeros(valueStr, section.maxLength);
|
|
107
158
|
}
|
|
108
|
-
return valueStr;
|
|
159
|
+
return applyLocalizedDigits(valueStr, localizedDigits);
|
|
109
160
|
};
|
|
110
161
|
exports.cleanDigitSectionValue = cleanDigitSectionValue;
|
|
111
|
-
const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoundaries, activeDate, stepsAttributes) => {
|
|
162
|
+
const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) => {
|
|
112
163
|
const delta = getDeltaFromKeyCode(keyCode);
|
|
113
164
|
const isStart = keyCode === 'Home';
|
|
114
165
|
const isEnd = keyCode === 'End';
|
|
@@ -119,9 +170,9 @@ const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoun
|
|
|
119
170
|
format: section.format,
|
|
120
171
|
contentType: section.contentType
|
|
121
172
|
});
|
|
122
|
-
const getCleanValue = value => cleanDigitSectionValue(utils,
|
|
173
|
+
const getCleanValue = value => cleanDigitSectionValue(utils, value, sectionBoundaries, localizedDigits, section);
|
|
123
174
|
const step = section.type === 'minutes' && stepsAttributes?.minutesStep ? stepsAttributes.minutesStep : 1;
|
|
124
|
-
const currentSectionValue = parseInt(section.value, 10);
|
|
175
|
+
const currentSectionValue = parseInt(removeLocalizedDigits(section.value, localizedDigits), 10);
|
|
125
176
|
let newSectionValueNumber = currentSectionValue + delta * step;
|
|
126
177
|
if (shouldSetAbsolute) {
|
|
127
178
|
if (section.type === 'year' && !isEnd && !isStart) {
|
|
@@ -170,11 +221,11 @@ const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoun
|
|
|
170
221
|
return adjustLetterSection();
|
|
171
222
|
};
|
|
172
223
|
exports.adjustSectionValue = adjustSectionValue;
|
|
173
|
-
const getSectionVisibleValue = (section, target) => {
|
|
224
|
+
const getSectionVisibleValue = (section, target, localizedDigits) => {
|
|
174
225
|
let value = section.value || section.placeholder;
|
|
175
226
|
const hasLeadingZeros = target === 'non-input' ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;
|
|
176
227
|
if (target === 'non-input' && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {
|
|
177
|
-
value = Number(value).toString();
|
|
228
|
+
value = Number(removeLocalizedDigits(value, localizedDigits)).toString();
|
|
178
229
|
}
|
|
179
230
|
|
|
180
231
|
// In the input, we add an empty character at the end of each section without leading zeros.
|
|
@@ -194,13 +245,13 @@ const getSectionVisibleValue = (section, target) => {
|
|
|
194
245
|
exports.getSectionVisibleValue = getSectionVisibleValue;
|
|
195
246
|
const cleanString = dirtyString => dirtyString.replace(/[\u2066\u2067\u2068\u2069]/g, '');
|
|
196
247
|
exports.cleanString = cleanString;
|
|
197
|
-
const addPositionPropertiesToSections = (sections, isRTL) => {
|
|
248
|
+
const addPositionPropertiesToSections = (sections, localizedDigits, isRTL) => {
|
|
198
249
|
let position = 0;
|
|
199
250
|
let positionInInput = isRTL ? 1 : 0;
|
|
200
251
|
const newSections = [];
|
|
201
252
|
for (let i = 0; i < sections.length; i += 1) {
|
|
202
253
|
const section = sections[i];
|
|
203
|
-
const renderedValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr');
|
|
254
|
+
const renderedValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr', localizedDigits);
|
|
204
255
|
const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;
|
|
205
256
|
const sectionLength = cleanString(sectionStr).length;
|
|
206
257
|
const sectionLengthInInput = sectionStr.length;
|
|
@@ -355,7 +406,7 @@ const getEscapedPartsFromFormat = (utils, format) => {
|
|
|
355
406
|
}
|
|
356
407
|
return escapedParts;
|
|
357
408
|
};
|
|
358
|
-
const splitFormatIntoSections = (utils, timezone, localeText, format, date, formatDensity, shouldRespectLeadingZeros, isRTL) => {
|
|
409
|
+
const splitFormatIntoSections = (utils, timezone, localeText, localizedDigits, format, date, formatDensity, shouldRespectLeadingZeros, isRTL) => {
|
|
359
410
|
let startSeparator = '';
|
|
360
411
|
const sections = [];
|
|
361
412
|
const now = utils.date();
|
|
@@ -378,7 +429,7 @@ const splitFormatIntoSections = (utils, timezone, localeText, format, date, form
|
|
|
378
429
|
}
|
|
379
430
|
maxLength = sectionConfig.maxLength;
|
|
380
431
|
if (isValidDate) {
|
|
381
|
-
sectionValue = cleanLeadingZeros(
|
|
432
|
+
sectionValue = applyLocalizedDigits(cleanLeadingZeros(removeLocalizedDigits(sectionValue, localizedDigits), maxLength), localizedDigits);
|
|
382
433
|
}
|
|
383
434
|
}
|
|
384
435
|
}
|
|
@@ -480,7 +531,7 @@ const splitFormatIntoSections = (utils, timezone, localeText, format, date, form
|
|
|
480
531
|
* To make sure that the parsing works, we are building a format and a date without any separator.
|
|
481
532
|
*/
|
|
482
533
|
exports.splitFormatIntoSections = splitFormatIntoSections;
|
|
483
|
-
const getDateFromDateSections = (utils, sections) => {
|
|
534
|
+
const getDateFromDateSections = (utils, sections, localizedDigits) => {
|
|
484
535
|
// If we have both a day and a weekDay section,
|
|
485
536
|
// Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.
|
|
486
537
|
// dayjs(dayjs().format('dddd MMMM D YYYY'), 'dddd MMMM D YYYY')) // returns `Invalid Date` even if the format is valid.
|
|
@@ -492,7 +543,7 @@ const getDateFromDateSections = (utils, sections) => {
|
|
|
492
543
|
const shouldSkip = shouldSkipWeekDays && section.type === 'weekDay';
|
|
493
544
|
if (!shouldSkip) {
|
|
494
545
|
sectionFormats.push(section.format);
|
|
495
|
-
sectionValues.push(getSectionVisibleValue(section, 'non-input'));
|
|
546
|
+
sectionValues.push(getSectionVisibleValue(section, 'non-input', localizedDigits));
|
|
496
547
|
}
|
|
497
548
|
}
|
|
498
549
|
const formatWithoutSeparator = sectionFormats.join(' ');
|
|
@@ -500,9 +551,9 @@ const getDateFromDateSections = (utils, sections) => {
|
|
|
500
551
|
return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
|
|
501
552
|
};
|
|
502
553
|
exports.getDateFromDateSections = getDateFromDateSections;
|
|
503
|
-
const createDateStrForInputFromSections = (sections, isRTL) => {
|
|
554
|
+
const createDateStrForInputFromSections = (sections, localizedDigits, isRTL) => {
|
|
504
555
|
const formattedSections = sections.map(section => {
|
|
505
|
-
const dateValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr');
|
|
556
|
+
const dateValue = getSectionVisibleValue(section, isRTL ? 'input-rtl' : 'input-ltr', localizedDigits);
|
|
506
557
|
return `${section.startSeparator}${dateValue}${section.endSeparator}`;
|
|
507
558
|
});
|
|
508
559
|
const dateStr = formattedSections.join('');
|
|
@@ -518,7 +569,7 @@ const createDateStrForInputFromSections = (sections, isRTL) => {
|
|
|
518
569
|
return `\u2066${dateStr}\u2069`;
|
|
519
570
|
};
|
|
520
571
|
exports.createDateStrForInputFromSections = createDateStrForInputFromSections;
|
|
521
|
-
const getSectionsBoundaries = (utils, timezone) => {
|
|
572
|
+
const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
522
573
|
const today = utils.date(undefined, timezone);
|
|
523
574
|
const endOfYear = utils.endOfYear(today);
|
|
524
575
|
const endOfDay = utils.endOfDay(today);
|
|
@@ -577,11 +628,11 @@ const getSectionsBoundaries = (utils, timezone) => {
|
|
|
577
628
|
format
|
|
578
629
|
}) => {
|
|
579
630
|
const lastHourInDay = utils.getHours(endOfDay);
|
|
580
|
-
const hasMeridiem = utils.formatByString(utils.endOfDay(today), format) !== lastHourInDay.toString();
|
|
631
|
+
const hasMeridiem = removeLocalizedDigits(utils.formatByString(utils.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();
|
|
581
632
|
if (hasMeridiem) {
|
|
582
633
|
return {
|
|
583
634
|
minimum: 1,
|
|
584
|
-
maximum: Number(utils.formatByString(utils.startOfDay(today), format))
|
|
635
|
+
maximum: Number(removeLocalizedDigits(utils.formatByString(utils.startOfDay(today), format), localizedDigits))
|
|
585
636
|
};
|
|
586
637
|
}
|
|
587
638
|
return {
|