@mui/x-date-pickers 7.0.0-alpha.4 → 7.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +342 -0
- package/DateCalendar/DateCalendar.types.d.ts +6 -6
- package/DateCalendar/DayCalendar.d.ts +4 -4
- package/DateCalendar/index.d.ts +1 -1
- package/DateField/DateField.js +17 -50
- package/DateField/DateField.types.d.ts +5 -9
- package/DateField/useDateField.d.ts +2 -2
- package/DateField/useDateField.js +1 -5
- package/DatePicker/DatePicker.js +5 -1
- package/DatePicker/DatePicker.types.d.ts +6 -6
- package/DatePicker/index.d.ts +1 -1
- package/DatePicker/shared.d.ts +6 -6
- package/DateTimeField/DateTimeField.js +17 -50
- package/DateTimeField/DateTimeField.types.d.ts +5 -9
- package/DateTimeField/useDateTimeField.d.ts +2 -2
- package/DateTimeField/useDateTimeField.js +1 -5
- package/DateTimePicker/DateTimePicker.js +5 -1
- package/DateTimePicker/DateTimePicker.types.d.ts +6 -6
- package/DateTimePicker/index.d.ts +1 -1
- package/DateTimePicker/shared.d.ts +6 -6
- package/DesktopDatePicker/DesktopDatePicker.js +7 -2
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +6 -6
- package/DesktopDatePicker/index.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +8 -8
- package/DesktopDateTimePicker/index.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.js +5 -1
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +8 -8
- package/DesktopTimePicker/index.d.ts +1 -1
- package/DigitalClock/DigitalClock.types.d.ts +4 -4
- package/DigitalClock/index.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.js +7 -2
- package/MobileDatePicker/MobileDatePicker.types.d.ts +6 -6
- package/MobileDatePicker/index.d.ts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +6 -6
- package/MobileDateTimePicker/index.d.ts +1 -1
- package/MobileTimePicker/MobileTimePicker.js +5 -1
- package/MobileTimePicker/MobileTimePicker.types.d.ts +6 -6
- package/MobileTimePicker/index.d.ts +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +4 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +3 -3
- package/MultiSectionDigitalClock/index.d.ts +1 -1
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +8 -8
- package/PickersCalendarHeader/index.d.ts +1 -1
- package/PickersLayout/PickersLayout.types.d.ts +6 -6
- package/PickersLayout/index.d.ts +1 -1
- package/PickersSectionList/PickersSectionList.d.ts +11 -0
- package/PickersSectionList/PickersSectionList.js +223 -0
- package/PickersSectionList/PickersSectionList.types.d.ts +56 -0
- package/PickersSectionList/index.d.ts +4 -0
- package/PickersSectionList/index.js +2 -0
- package/PickersSectionList/package.json +6 -0
- package/PickersSectionList/pickersSectionListClasses.d.ts +11 -0
- package/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/StaticDatePicker/StaticDatePicker.js +1 -1
- package/StaticDatePicker/StaticDatePicker.types.d.ts +7 -7
- package/StaticDatePicker/index.d.ts +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +7 -7
- package/StaticDateTimePicker/index.d.ts +1 -1
- package/StaticTimePicker/StaticTimePicker.types.d.ts +7 -7
- package/StaticTimePicker/index.d.ts +1 -1
- package/TimeClock/TimeClock.types.d.ts +5 -5
- package/TimeClock/index.d.ts +1 -1
- package/TimeField/TimeField.js +17 -50
- package/TimeField/TimeField.types.d.ts +5 -9
- package/TimeField/useTimeField.d.ts +2 -2
- package/TimeField/useTimeField.js +1 -5
- package/TimePicker/TimePicker.js +5 -1
- package/TimePicker/TimePicker.types.d.ts +6 -6
- package/TimePicker/index.d.ts +1 -1
- package/TimePicker/shared.d.ts +5 -5
- package/hooks/index.d.ts +1 -0
- package/hooks/useClearableField.d.ts +32 -20
- package/hooks/useClearableField.js +32 -33
- package/index.d.ts +1 -0
- package/index.js +4 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +9 -9
- package/internals/components/PickersArrowSwitcher/index.d.ts +3 -1
- package/internals/components/PickersArrowSwitcher/index.js +2 -1
- package/internals/components/{PickersTextField → PickersInput}/Outline.d.ts +1 -0
- package/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/internals/components/PickersInput/PickersFilledInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersFilledInput.js +166 -0
- package/internals/components/PickersInput/PickersInput.d.ts +15 -0
- package/internals/components/{PickersTextField → PickersInput}/PickersInput.js +78 -106
- package/internals/components/PickersInput/PickersInput.types.d.ts +60 -0
- package/internals/components/PickersInput/PickersOutlinedInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersOutlinedInput.js +117 -0
- package/internals/components/PickersInput/PickersStandardInput.d.ts +3 -0
- package/internals/components/PickersInput/PickersStandardInput.js +123 -0
- package/internals/components/PickersInput/index.d.ts +4 -0
- package/internals/components/PickersInput/index.js +3 -0
- package/internals/components/PickersInput/pickersInputClasses.d.ts +84 -0
- package/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/internals/components/PickersModalDialog.d.ts +4 -4
- package/internals/components/PickersPopper.d.ts +4 -4
- package/internals/components/PickersTextField/PickersTextField.d.ts +1 -2
- package/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/internals/components/PickersTextField/PickersTextField.types.d.ts +46 -3
- package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +0 -31
- package/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- package/internals/hooks/useDesktopPicker/index.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +8 -8
- package/internals/hooks/useField/index.d.ts +1 -1
- package/internals/hooks/useField/useField.js +11 -4
- package/internals/hooks/useField/useField.types.d.ts +4 -24
- package/internals/hooks/useField/useField.utils.js +24 -4
- package/internals/hooks/useField/useFieldState.js +7 -3
- package/internals/hooks/useMobilePicker/index.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +3 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -7
- package/internals/hooks/useStaticPicker/index.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -5
- package/internals/index.d.ts +7 -6
- package/internals/index.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +4 -0
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +3 -0
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +26 -0
- package/legacy/DateField/DateField.js +19 -47
- package/legacy/DateField/useDateField.js +1 -4
- package/legacy/DatePicker/DatePicker.js +5 -1
- package/legacy/DateTimeField/DateTimeField.js +19 -47
- package/legacy/DateTimeField/useDateTimeField.js +1 -4
- package/legacy/DateTimePicker/DateTimePicker.js +5 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +7 -2
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +5 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +7 -2
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +5 -1
- package/legacy/PickersSectionList/PickersSectionList.js +230 -0
- package/legacy/PickersSectionList/index.js +2 -0
- package/legacy/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/legacy/StaticDatePicker/StaticDatePicker.js +1 -1
- package/legacy/TimeField/TimeField.js +19 -47
- package/legacy/TimeField/useTimeField.js +1 -4
- package/legacy/TimePicker/TimePicker.js +5 -1
- package/legacy/hooks/useClearableField.js +30 -32
- package/legacy/index.js +4 -1
- package/legacy/internals/components/PickersArrowSwitcher/index.js +2 -1
- package/legacy/internals/components/{PickersTextField → PickersInput}/Outline.js +40 -22
- package/legacy/internals/components/PickersInput/PickersFilledInput.js +161 -0
- package/legacy/internals/components/{PickersTextField → PickersInput}/PickersInput.js +75 -90
- package/legacy/internals/components/PickersInput/PickersInput.types.js +1 -0
- package/legacy/internals/components/PickersInput/PickersOutlinedInput.js +110 -0
- package/legacy/internals/components/PickersInput/PickersStandardInput.js +117 -0
- package/legacy/internals/components/PickersInput/index.js +3 -0
- package/legacy/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.js +16 -7
- package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/legacy/internals/hooks/useField/useField.js +12 -5
- package/legacy/internals/hooks/useField/useField.utils.js +26 -4
- package/legacy/internals/hooks/useField/useFieldState.js +7 -3
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +3 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +24 -0
- package/legacy/locales/ruRU.js +1 -2
- package/locales/ruRU.js +1 -2
- package/models/fields.d.ts +2 -1
- package/modern/DateField/DateField.js +17 -50
- package/modern/DateField/useDateField.js +1 -5
- package/modern/DatePicker/DatePicker.js +5 -1
- package/modern/DateTimeField/DateTimeField.js +17 -50
- package/modern/DateTimeField/useDateTimeField.js +1 -5
- package/modern/DateTimePicker/DateTimePicker.js +5 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +7 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +5 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +7 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +5 -1
- package/modern/PickersSectionList/PickersSectionList.js +221 -0
- package/modern/PickersSectionList/PickersSectionList.types.js +1 -0
- package/modern/PickersSectionList/index.js +2 -0
- package/modern/PickersSectionList/pickersSectionListClasses.js +6 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -1
- package/modern/TimeField/TimeField.js +17 -50
- package/modern/TimeField/useTimeField.js +1 -5
- package/modern/TimePicker/TimePicker.js +5 -1
- package/modern/hooks/useClearableField.js +32 -33
- package/modern/index.js +4 -1
- package/modern/internals/components/PickersArrowSwitcher/index.js +2 -1
- package/modern/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/modern/internals/components/PickersInput/PickersFilledInput.js +165 -0
- package/modern/internals/components/{PickersTextField → PickersInput}/PickersInput.js +78 -106
- package/modern/internals/components/PickersInput/PickersInput.types.js +1 -0
- package/modern/internals/components/PickersInput/PickersOutlinedInput.js +117 -0
- package/modern/internals/components/PickersInput/PickersStandardInput.js +123 -0
- package/modern/internals/components/PickersInput/index.js +3 -0
- package/modern/internals/components/PickersInput/pickersInputClasses.js +18 -0
- package/modern/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +3 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/modern/internals/hooks/useField/useField.js +11 -4
- package/modern/internals/hooks/useField/useField.utils.js +24 -4
- package/modern/internals/hooks/useField/useFieldState.js +7 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +3 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +26 -0
- package/modern/locales/ruRU.js +1 -2
- package/node/DateField/DateField.js +18 -51
- package/node/DateField/useDateField.js +1 -5
- package/node/DatePicker/DatePicker.js +5 -1
- package/node/DateTimeField/DateTimeField.js +18 -51
- package/node/DateTimeField/useDateTimeField.js +1 -5
- package/node/DateTimePicker/DateTimePicker.js +5 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +10 -5
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +5 -1
- package/node/DesktopTimePicker/DesktopTimePicker.js +5 -1
- package/node/MobileDatePicker/MobileDatePicker.js +10 -5
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +5 -1
- package/node/MobileTimePicker/MobileTimePicker.js +5 -1
- package/node/PickersSectionList/PickersSectionList.js +228 -0
- package/node/PickersSectionList/index.js +49 -0
- package/node/PickersSectionList/pickersSectionListClasses.js +14 -0
- package/node/StaticDatePicker/StaticDatePicker.js +2 -2
- package/node/TimeField/TimeField.js +18 -51
- package/node/TimeField/useTimeField.js +1 -5
- package/node/TimePicker/TimePicker.js +5 -1
- package/node/hooks/useClearableField.js +33 -34
- package/node/index.js +13 -1
- package/node/internals/components/PickersArrowSwitcher/index.js +14 -1
- package/node/internals/components/{PickersTextField → PickersInput}/Outline.js +35 -19
- package/node/internals/components/PickersInput/PickersFilledInput.js +174 -0
- package/node/internals/components/{PickersTextField → PickersInput}/PickersInput.js +80 -108
- package/node/internals/components/PickersInput/PickersInput.types.js +5 -0
- package/node/internals/components/PickersInput/PickersOutlinedInput.js +125 -0
- package/node/internals/components/PickersInput/PickersStandardInput.js +132 -0
- package/node/internals/components/PickersInput/index.js +32 -0
- package/node/internals/components/PickersInput/pickersInputClasses.js +29 -0
- package/node/internals/components/PickersTextField/PickersTextField.js +15 -6
- package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +6 -9
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/node/internals/hooks/useField/useField.js +11 -4
- package/node/internals/hooks/useField/useField.utils.js +24 -4
- package/node/internals/hooks/useField/useFieldState.js +7 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +3 -1
- package/node/internals/index.js +7 -0
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +34 -0
- package/node/locales/ruRU.js +1 -2
- package/package.json +5 -5
- package/themeAugmentation/overrides.d.ts +5 -7
- package/themeAugmentation/props.d.ts +6 -8
- package/internals/components/PickersTextField/PickersInput.d.ts +0 -3
- package/internals/components/PickersTextField/PickersInput.types.d.ts +0 -45
- /package/{internals/components/PickersTextField/PickersInput.types.js → PickersSectionList/PickersSectionList.types.js} +0 -0
- /package/{legacy/internals/components/PickersTextField → internals/components/PickersInput}/PickersInput.types.js +0 -0
- /package/{modern/internals/components/PickersTextField/PickersInput.types.js → legacy/PickersSectionList/PickersSectionList.types.js} +0 -0
- /package/node/{internals/components/PickersTextField/PickersInput.types.js → PickersSectionList/PickersSectionList.types.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["onClick", "onKeyDown", "onFocus", "onBlur", "onMouseUp", "onPaste", "error", "clearable", "onClear", "disabled"];
|
|
4
|
+
var _excluded = ["inputRef", "onClick", "onKeyDown", "onFocus", "onBlur", "onMouseUp", "onPaste", "error", "clearable", "onClear", "disabled"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
7
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
@@ -27,14 +27,14 @@ export var useField = function useField(params) {
|
|
|
27
27
|
sectionsValueBoundaries = _useFieldState.sectionsValueBoundaries,
|
|
28
28
|
placeholder = _useFieldState.placeholder,
|
|
29
29
|
timezone = _useFieldState.timezone;
|
|
30
|
-
var
|
|
31
|
-
internalProps = params.internalProps,
|
|
30
|
+
var internalProps = params.internalProps,
|
|
32
31
|
_params$internalProps = params.internalProps,
|
|
33
32
|
_params$internalProps2 = _params$internalProps.readOnly,
|
|
34
33
|
readOnly = _params$internalProps2 === void 0 ? false : _params$internalProps2,
|
|
35
34
|
unstableFieldRef = _params$internalProps.unstableFieldRef,
|
|
36
35
|
minutesStep = _params$internalProps.minutesStep,
|
|
37
36
|
_params$forwardedProp = params.forwardedProps,
|
|
37
|
+
inputRefProp = _params$forwardedProp.inputRef,
|
|
38
38
|
onClick = _params$forwardedProp.onClick,
|
|
39
39
|
onKeyDown = _params$forwardedProp.onKeyDown,
|
|
40
40
|
onFocus = _params$forwardedProp.onFocus,
|
|
@@ -152,7 +152,14 @@ export var useField = function useField(params) {
|
|
|
152
152
|
var digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
153
153
|
var isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
154
154
|
if (isValidPastedValue) {
|
|
155
|
-
|
|
155
|
+
resetCharacterQuery();
|
|
156
|
+
updateSectionValue({
|
|
157
|
+
activeSection: activeSection,
|
|
158
|
+
newSectionValue: pastedValue,
|
|
159
|
+
shouldGoToNextSection: true
|
|
160
|
+
});
|
|
161
|
+
// prevent default to avoid the input change handler being called
|
|
162
|
+
event.preventDefault();
|
|
156
163
|
return;
|
|
157
164
|
}
|
|
158
165
|
if (lettersOnly || digitsOnly) {
|
|
@@ -455,7 +462,7 @@ export var useField = function useField(params) {
|
|
|
455
462
|
onMouseUp: handleInputMouseUp,
|
|
456
463
|
onClear: handleClearValue,
|
|
457
464
|
error: inputError,
|
|
458
|
-
|
|
465
|
+
inputRef: handleRef,
|
|
459
466
|
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled)
|
|
460
467
|
});
|
|
461
468
|
};
|
|
@@ -202,7 +202,7 @@ export var addPositionPropertiesToSections = function addPositionPropertiesToSec
|
|
|
202
202
|
|
|
203
203
|
// The ...InInput values consider the unicode characters but do include them in their indexes
|
|
204
204
|
var cleanedValue = cleanString(renderedValue);
|
|
205
|
-
var startInInput = positionInInput + renderedValue.indexOf(cleanedValue[0]) + section.startSeparator.length;
|
|
205
|
+
var startInInput = positionInInput + (cleanedValue === '' ? 0 : renderedValue.indexOf(cleanedValue[0])) + section.startSeparator.length;
|
|
206
206
|
var endInInput = startInInput + cleanedValue.length;
|
|
207
207
|
newSections.push(_extends({}, section, {
|
|
208
208
|
start: position,
|
|
@@ -444,6 +444,21 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, tim
|
|
|
444
444
|
_loop(i);
|
|
445
445
|
}
|
|
446
446
|
commitToken(currentTokenValue);
|
|
447
|
+
if (sections.length === 0 && startSeparator.length > 0) {
|
|
448
|
+
sections.push({
|
|
449
|
+
type: 'empty',
|
|
450
|
+
contentType: 'letter',
|
|
451
|
+
maxLength: null,
|
|
452
|
+
format: '',
|
|
453
|
+
value: '',
|
|
454
|
+
placeholder: '',
|
|
455
|
+
hasLeadingZerosInFormat: false,
|
|
456
|
+
hasLeadingZerosInInput: false,
|
|
457
|
+
startSeparator: startSeparator,
|
|
458
|
+
endSeparator: '',
|
|
459
|
+
modified: false
|
|
460
|
+
});
|
|
461
|
+
}
|
|
447
462
|
return sections.map(function (section) {
|
|
448
463
|
var cleanSeparator = function cleanSeparator(separator) {
|
|
449
464
|
var cleanedSeparator = separator;
|
|
@@ -594,6 +609,12 @@ export var getSectionsBoundaries = function getSectionsBoundaries(utils, timezon
|
|
|
594
609
|
minimum: 0,
|
|
595
610
|
maximum: 0
|
|
596
611
|
};
|
|
612
|
+
},
|
|
613
|
+
empty: function empty() {
|
|
614
|
+
return {
|
|
615
|
+
minimum: 0,
|
|
616
|
+
maximum: 0
|
|
617
|
+
};
|
|
597
618
|
}
|
|
598
619
|
};
|
|
599
620
|
};
|
|
@@ -601,7 +622,7 @@ var warnedOnceInvalidSection = false;
|
|
|
601
622
|
export var validateSections = function validateSections(sections, valueType) {
|
|
602
623
|
if (process.env.NODE_ENV !== 'production') {
|
|
603
624
|
if (!warnedOnceInvalidSection) {
|
|
604
|
-
var supportedSections = [];
|
|
625
|
+
var supportedSections = ['empty'];
|
|
605
626
|
if (['date', 'date-time'].includes(valueType)) {
|
|
606
627
|
supportedSections.push('weekDay', 'day', 'month', 'year');
|
|
607
628
|
}
|
|
@@ -612,7 +633,7 @@ export var validateSections = function validateSections(sections, valueType) {
|
|
|
612
633
|
return !supportedSections.includes(section.type);
|
|
613
634
|
});
|
|
614
635
|
if (invalidSection) {
|
|
615
|
-
console.warn("MUI: The field component you are using is not compatible with the \"".concat(invalidSection.type, " date section."), "The supported date sections are [\"".concat(supportedSections.join('", "'), "\"]`."));
|
|
636
|
+
console.warn("MUI: The field component you are using is not compatible with the \"".concat(invalidSection.type, "\" date section."), "The supported date sections are [\"".concat(supportedSections.join('", "'), "\"]`."));
|
|
616
637
|
warnedOnceInvalidSection = true;
|
|
617
638
|
}
|
|
618
639
|
}
|
|
@@ -679,7 +700,8 @@ var reliableSectionModificationOrder = {
|
|
|
679
700
|
hours: 5,
|
|
680
701
|
minutes: 6,
|
|
681
702
|
seconds: 7,
|
|
682
|
-
meridiem: 8
|
|
703
|
+
meridiem: 8,
|
|
704
|
+
empty: 9
|
|
683
705
|
};
|
|
684
706
|
export var mergeDateIntoReferenceDate = function mergeDateIntoReferenceDate(utils, timezone, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) {
|
|
685
707
|
return (
|
|
@@ -111,7 +111,8 @@ export var useFieldState = function useFieldState(params) {
|
|
|
111
111
|
if (typeof selectedSections === 'number') {
|
|
112
112
|
return {
|
|
113
113
|
startIndex: selectedSections,
|
|
114
|
-
endIndex: selectedSections
|
|
114
|
+
endIndex: selectedSections,
|
|
115
|
+
shouldSelectBoundarySelectors: state.sections[selectedSections].type === 'empty'
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
118
|
if (typeof selectedSections === 'string') {
|
|
@@ -120,10 +121,13 @@ export var useFieldState = function useFieldState(params) {
|
|
|
120
121
|
});
|
|
121
122
|
return {
|
|
122
123
|
startIndex: selectedSectionIndex,
|
|
123
|
-
endIndex: selectedSectionIndex
|
|
124
|
+
endIndex: selectedSectionIndex,
|
|
125
|
+
shouldSelectBoundarySelectors: state.sections[selectedSectionIndex].type === 'empty'
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
|
-
return selectedSections
|
|
128
|
+
return _extends({}, selectedSections, {
|
|
129
|
+
shouldSelectBoundarySelectors: selectedSections.startIndex === selectedSections.endIndex && state.sections[selectedSections.startIndex].type === 'empty'
|
|
130
|
+
});
|
|
127
131
|
}, [selectedSections, state.sections]);
|
|
128
132
|
var publishValue = function publishValue(_ref) {
|
|
129
133
|
var value = _ref.value,
|
|
@@ -31,6 +31,7 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
31
31
|
format = props.format,
|
|
32
32
|
formatDensity = props.formatDensity,
|
|
33
33
|
timezone = props.timezone,
|
|
34
|
+
name = props.name,
|
|
34
35
|
label = props.label,
|
|
35
36
|
inputRef = props.inputRef,
|
|
36
37
|
readOnly = props.readOnly,
|
|
@@ -69,7 +70,8 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
69
70
|
format: format,
|
|
70
71
|
formatDensity: formatDensity,
|
|
71
72
|
timezone: timezone,
|
|
72
|
-
label: label
|
|
73
|
+
label: label,
|
|
74
|
+
name: name
|
|
73
75
|
}),
|
|
74
76
|
ownerState: props
|
|
75
77
|
});
|
|
@@ -16,6 +16,7 @@ export { useStaticPicker } from './hooks/useStaticPicker';
|
|
|
16
16
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow } from './hooks/useUtils';
|
|
17
17
|
export { useValidation } from './hooks/useValidation';
|
|
18
18
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
|
|
19
|
+
export { convertFieldResponseIntoMuiTextFieldProps } from './utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
19
20
|
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual, getTodayDate } from './utils/date-utils';
|
|
20
21
|
export { splitFieldInternalAndForwardedProps } from './utils/fields';
|
|
21
22
|
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["onPaste", "onKeyDown", "inputMode", "readOnly", "InputProps", "inputProps", "inputRef"];
|
|
4
|
+
export var convertFieldResponseIntoMuiTextFieldProps = function convertFieldResponseIntoMuiTextFieldProps(fieldResponse) {
|
|
5
|
+
var onPaste = fieldResponse.onPaste,
|
|
6
|
+
onKeyDown = fieldResponse.onKeyDown,
|
|
7
|
+
inputMode = fieldResponse.inputMode,
|
|
8
|
+
readOnly = fieldResponse.readOnly,
|
|
9
|
+
InputProps = fieldResponse.InputProps,
|
|
10
|
+
inputProps = fieldResponse.inputProps,
|
|
11
|
+
inputRef = fieldResponse.inputRef,
|
|
12
|
+
other = _objectWithoutProperties(fieldResponse, _excluded);
|
|
13
|
+
return _extends({}, other, {
|
|
14
|
+
InputProps: _extends({}, InputProps != null ? InputProps : {}, {
|
|
15
|
+
readOnly: readOnly
|
|
16
|
+
}),
|
|
17
|
+
inputProps: _extends({}, inputProps != null ? inputProps : {}, {
|
|
18
|
+
inputMode: inputMode,
|
|
19
|
+
onPaste: onPaste,
|
|
20
|
+
onKeyDown: onKeyDown,
|
|
21
|
+
ref: inputRef
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
package/legacy/locales/ruRU.js
CHANGED
|
@@ -62,8 +62,7 @@ var ruRUPickers = {
|
|
|
62
62
|
openTimePickerDialogue: function openTimePickerDialogue(value, utils) {
|
|
63
63
|
return value !== null && utils.isValid(value) ? "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0440\u0435\u043C\u044F, \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0432\u0440\u0435\u043C\u044F ".concat(utils.format(value, 'fullTime')) : 'Выберите время';
|
|
64
64
|
},
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
fieldClearLabel: 'Очистить значение',
|
|
67
66
|
// Table labels
|
|
68
67
|
timeTableLabel: 'выбрать время',
|
|
69
68
|
dateTableLabel: 'выбрать дату',
|
package/locales/ruRU.js
CHANGED
|
@@ -42,8 +42,7 @@ const ruRUPickers = {
|
|
|
42
42
|
// Open picker labels
|
|
43
43
|
openDatePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите дату, выбрана дата ${utils.format(value, 'fullDate')}` : 'Выберите дату',
|
|
44
44
|
openTimePickerDialogue: (value, utils) => value !== null && utils.isValid(value) ? `Выберите время, выбрано время ${utils.format(value, 'fullTime')}` : 'Выберите время',
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
fieldClearLabel: 'Очистить значение',
|
|
47
46
|
// Table labels
|
|
48
47
|
timeTableLabel: 'выбрать время',
|
|
49
48
|
dateTableLabel: 'выбрать дату',
|
package/models/fields.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { BaseFieldProps } from '../internals/models/fields';
|
|
3
|
-
export type FieldSectionType = 'year' | 'month' | 'day' | 'weekDay' | 'hours' | 'minutes' | 'seconds' | 'meridiem';
|
|
3
|
+
export type FieldSectionType = 'year' | 'month' | 'day' | 'weekDay' | 'hours' | 'minutes' | 'seconds' | 'meridiem' | 'empty';
|
|
4
4
|
export type FieldSectionContentType = 'digit' | 'digit-with-letter' | 'letter';
|
|
5
5
|
export type FieldValueType = 'date' | 'time' | 'date-time';
|
|
6
6
|
export interface FieldSection {
|
|
@@ -112,6 +112,7 @@ export type FieldSelectedSections = number | FieldSectionType | null | 'all' | {
|
|
|
112
112
|
export interface BaseSingleInputFieldProps<TValue, TDate, TSection extends FieldSection, TError> extends BaseFieldProps<TValue, TDate, TSection, TError> {
|
|
113
113
|
label?: React.ReactNode;
|
|
114
114
|
id?: string;
|
|
115
|
+
name?: string;
|
|
115
116
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
116
117
|
onKeyDown?: React.KeyboardEventHandler;
|
|
117
118
|
onBlur?: React.FocusEventHandler;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "InputProps", "inputProps"]
|
|
4
|
-
_excluded2 = ["inputRef"],
|
|
5
|
-
_excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly", "clearable", "onClear"];
|
|
3
|
+
const _excluded = ["slots", "slotProps", "InputProps", "inputProps"];
|
|
6
4
|
import * as React from 'react';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
8
6
|
import MuiTextField from '@mui/material/TextField';
|
|
@@ -11,6 +9,7 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
11
9
|
import { refType } from '@mui/utils';
|
|
12
10
|
import { useDateField } from './useDateField';
|
|
13
11
|
import { useClearableField } from '../hooks';
|
|
12
|
+
import { convertFieldResponseIntoMuiTextFieldProps } from '../internals/utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
/**
|
|
16
15
|
* Demos:
|
|
@@ -22,7 +21,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
22
21
|
*
|
|
23
22
|
* - [DateField API](https://mui.com/x/api/date-pickers/date-field/)
|
|
24
23
|
*/
|
|
25
|
-
const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps,
|
|
24
|
+
const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, inRef) {
|
|
26
25
|
const themeProps = useThemeProps({
|
|
27
26
|
props: inProps,
|
|
28
27
|
name: 'MuiDateField'
|
|
@@ -36,58 +35,26 @@ const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref)
|
|
|
36
35
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
37
36
|
const ownerState = themeProps;
|
|
38
37
|
const TextField = slots?.textField ?? MuiTextField;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
textFieldProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
38
|
+
const textFieldProps = useSlotProps({
|
|
39
|
+
elementType: TextField,
|
|
40
|
+
externalSlotProps: slotProps?.textField,
|
|
41
|
+
externalForwardedProps: other,
|
|
42
|
+
additionalProps: {
|
|
43
|
+
ref: inRef
|
|
44
|
+
},
|
|
45
|
+
ownerState
|
|
46
|
+
});
|
|
49
47
|
|
|
50
48
|
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
51
49
|
textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps);
|
|
52
50
|
textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}),
|
|
57
|
-
{
|
|
58
|
-
ref: inputRef,
|
|
59
|
-
onPaste,
|
|
60
|
-
onKeyDown,
|
|
61
|
-
inputMode,
|
|
62
|
-
readOnly,
|
|
63
|
-
clearable,
|
|
64
|
-
onClear
|
|
65
|
-
} = _useDateField,
|
|
66
|
-
fieldProps = _objectWithoutPropertiesLoose(_useDateField, _excluded3);
|
|
67
|
-
const {
|
|
68
|
-
InputProps: ProcessedInputProps,
|
|
69
|
-
fieldProps: processedFieldProps
|
|
70
|
-
} = useClearableField({
|
|
71
|
-
onClear,
|
|
72
|
-
clearable,
|
|
73
|
-
fieldProps,
|
|
74
|
-
InputProps: fieldProps.InputProps,
|
|
51
|
+
const fieldResponse = useDateField(textFieldProps);
|
|
52
|
+
const convertedFieldResponse = convertFieldResponseIntoMuiTextFieldProps(fieldResponse);
|
|
53
|
+
const processedFieldProps = useClearableField(_extends({}, convertedFieldResponse, {
|
|
75
54
|
slots,
|
|
76
55
|
slotProps
|
|
77
|
-
});
|
|
78
|
-
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
79
|
-
ref: ref
|
|
80
|
-
}, processedFieldProps, {
|
|
81
|
-
InputProps: _extends({}, ProcessedInputProps, {
|
|
82
|
-
readOnly
|
|
83
|
-
}),
|
|
84
|
-
inputProps: _extends({}, fieldProps.inputProps, {
|
|
85
|
-
inputMode,
|
|
86
|
-
onPaste,
|
|
87
|
-
onKeyDown,
|
|
88
|
-
ref: inputRef
|
|
89
|
-
})
|
|
90
56
|
}));
|
|
57
|
+
return /*#__PURE__*/_jsx(TextField, _extends({}, processedFieldProps));
|
|
91
58
|
});
|
|
92
59
|
process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
93
60
|
// ----------------------------- Warning --------------------------------
|
|
@@ -265,7 +232,7 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
265
232
|
* 4. If `null` is provided, no section will be selected
|
|
266
233
|
* If not provided, the selected sections will be handled internally.
|
|
267
234
|
*/
|
|
268
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
235
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
269
236
|
endIndex: PropTypes.number.isRequired,
|
|
270
237
|
startIndex: PropTypes.number.isRequired
|
|
271
238
|
})]),
|
|
@@ -16,17 +16,13 @@ const useDefaultizedDateField = props => {
|
|
|
16
16
|
maxDate: applyDefaultDate(utils, props.maxDate, defaultDates.maxDate)
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
export const useDateField =
|
|
20
|
-
props: inProps,
|
|
21
|
-
inputRef
|
|
22
|
-
}) => {
|
|
19
|
+
export const useDateField = inProps => {
|
|
23
20
|
const props = useDefaultizedDateField(inProps);
|
|
24
21
|
const {
|
|
25
22
|
forwardedProps,
|
|
26
23
|
internalProps
|
|
27
24
|
} = splitFieldInternalAndForwardedProps(props, 'date');
|
|
28
25
|
return useField({
|
|
29
|
-
inputRef,
|
|
30
26
|
forwardedProps,
|
|
31
27
|
internalProps,
|
|
32
28
|
valueManager: singleItemValueManager,
|
|
@@ -160,6 +160,10 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
160
160
|
* @default 3
|
|
161
161
|
*/
|
|
162
162
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
163
|
+
/**
|
|
164
|
+
* Name attribute used by the `input` element in the Field.
|
|
165
|
+
*/
|
|
166
|
+
name: PropTypes.string,
|
|
163
167
|
/**
|
|
164
168
|
* Callback fired when the value is accepted.
|
|
165
169
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -258,7 +262,7 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
258
262
|
* 4. If `null` is provided, no section will be selected
|
|
259
263
|
* If not provided, the selected sections will be handled internally.
|
|
260
264
|
*/
|
|
261
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
265
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
262
266
|
endIndex: PropTypes.number.isRequired,
|
|
263
267
|
startIndex: PropTypes.number.isRequired
|
|
264
268
|
})]),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["slots", "slotProps", "InputProps", "inputProps"]
|
|
4
|
-
_excluded2 = ["inputRef"],
|
|
5
|
-
_excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly", "clearable", "onClear"];
|
|
3
|
+
const _excluded = ["slots", "slotProps", "InputProps", "inputProps"];
|
|
6
4
|
import * as React from 'react';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
8
6
|
import MuiTextField from '@mui/material/TextField';
|
|
@@ -11,6 +9,7 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
11
9
|
import { refType } from '@mui/utils';
|
|
12
10
|
import { useDateTimeField } from './useDateTimeField';
|
|
13
11
|
import { useClearableField } from '../hooks';
|
|
12
|
+
import { convertFieldResponseIntoMuiTextFieldProps } from '../internals/utils/convertFieldResponseIntoMuiTextFieldProps';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
/**
|
|
16
15
|
* Demos:
|
|
@@ -22,7 +21,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
22
21
|
*
|
|
23
22
|
* - [DateTimeField API](https://mui.com/x/api/date-pickers/date-time-field/)
|
|
24
23
|
*/
|
|
25
|
-
const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inProps,
|
|
24
|
+
const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inProps, inRef) {
|
|
26
25
|
const themeProps = useThemeProps({
|
|
27
26
|
props: inProps,
|
|
28
27
|
name: 'MuiDateTimeField'
|
|
@@ -36,58 +35,26 @@ const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inPro
|
|
|
36
35
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
37
36
|
const ownerState = themeProps;
|
|
38
37
|
const TextField = slots?.textField ?? MuiTextField;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
textFieldProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
38
|
+
const textFieldProps = useSlotProps({
|
|
39
|
+
elementType: TextField,
|
|
40
|
+
externalSlotProps: slotProps?.textField,
|
|
41
|
+
externalForwardedProps: other,
|
|
42
|
+
ownerState,
|
|
43
|
+
additionalProps: {
|
|
44
|
+
ref: inRef
|
|
45
|
+
}
|
|
46
|
+
});
|
|
49
47
|
|
|
50
48
|
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
51
49
|
textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps);
|
|
52
50
|
textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}),
|
|
57
|
-
{
|
|
58
|
-
ref: inputRef,
|
|
59
|
-
onPaste,
|
|
60
|
-
onKeyDown,
|
|
61
|
-
inputMode,
|
|
62
|
-
readOnly,
|
|
63
|
-
clearable,
|
|
64
|
-
onClear
|
|
65
|
-
} = _useDateTimeField,
|
|
66
|
-
fieldProps = _objectWithoutPropertiesLoose(_useDateTimeField, _excluded3);
|
|
67
|
-
const {
|
|
68
|
-
InputProps: ProcessedInputProps,
|
|
69
|
-
fieldProps: processedFieldProps
|
|
70
|
-
} = useClearableField({
|
|
71
|
-
onClear,
|
|
72
|
-
clearable,
|
|
73
|
-
fieldProps,
|
|
74
|
-
InputProps: fieldProps.InputProps,
|
|
51
|
+
const fieldResponse = useDateTimeField(textFieldProps);
|
|
52
|
+
const convertedFieldResponse = convertFieldResponseIntoMuiTextFieldProps(fieldResponse);
|
|
53
|
+
const processedFieldProps = useClearableField(_extends({}, convertedFieldResponse, {
|
|
75
54
|
slots,
|
|
76
55
|
slotProps
|
|
77
|
-
});
|
|
78
|
-
return /*#__PURE__*/_jsx(TextField, _extends({
|
|
79
|
-
ref: ref
|
|
80
|
-
}, processedFieldProps, {
|
|
81
|
-
InputProps: _extends({}, ProcessedInputProps, {
|
|
82
|
-
readOnly
|
|
83
|
-
}),
|
|
84
|
-
inputProps: _extends({}, fieldProps.inputProps, {
|
|
85
|
-
inputMode,
|
|
86
|
-
onPaste,
|
|
87
|
-
onKeyDown,
|
|
88
|
-
ref: inputRef
|
|
89
|
-
})
|
|
90
56
|
}));
|
|
57
|
+
return /*#__PURE__*/_jsx(TextField, _extends({}, processedFieldProps));
|
|
91
58
|
});
|
|
92
59
|
process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
93
60
|
// ----------------------------- Warning --------------------------------
|
|
@@ -298,7 +265,7 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
298
265
|
* 4. If `null` is provided, no section will be selected
|
|
299
266
|
* If not provided, the selected sections will be handled internally.
|
|
300
267
|
*/
|
|
301
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
268
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
302
269
|
endIndex: PropTypes.number.isRequired,
|
|
303
270
|
startIndex: PropTypes.number.isRequired
|
|
304
271
|
})]),
|
|
@@ -21,17 +21,13 @@ const useDefaultizedDateTimeField = props => {
|
|
|
21
21
|
maxTime: props.maxDateTime ?? props.maxTime
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
-
export const useDateTimeField =
|
|
25
|
-
props: inProps,
|
|
26
|
-
inputRef
|
|
27
|
-
}) => {
|
|
24
|
+
export const useDateTimeField = inProps => {
|
|
28
25
|
const props = useDefaultizedDateTimeField(inProps);
|
|
29
26
|
const {
|
|
30
27
|
forwardedProps,
|
|
31
28
|
internalProps
|
|
32
29
|
} = splitFieldInternalAndForwardedProps(props, 'date-time');
|
|
33
30
|
return useField({
|
|
34
|
-
inputRef,
|
|
35
31
|
forwardedProps,
|
|
36
32
|
internalProps,
|
|
37
33
|
valueManager: singleItemValueManager,
|
|
@@ -198,6 +198,10 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
198
198
|
* @default 3
|
|
199
199
|
*/
|
|
200
200
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
201
|
+
/**
|
|
202
|
+
* Name attribute used by the `input` element in the Field.
|
|
203
|
+
*/
|
|
204
|
+
name: PropTypes.string,
|
|
201
205
|
/**
|
|
202
206
|
* Callback fired when the value is accepted.
|
|
203
207
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -296,7 +300,7 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
296
300
|
* 4. If `null` is provided, no section will be selected
|
|
297
301
|
* If not provided, the selected sections will be handled internally.
|
|
298
302
|
*/
|
|
299
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
303
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
300
304
|
endIndex: PropTypes.number.isRequired,
|
|
301
305
|
startIndex: PropTypes.number.isRequired
|
|
302
306
|
})]),
|
|
@@ -5,7 +5,8 @@ import { resolveComponentProps } from '@mui/base/utils';
|
|
|
5
5
|
import { refType } from '@mui/utils';
|
|
6
6
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
7
7
|
import { useDatePickerDefaultizedProps } from '../DatePicker/shared';
|
|
8
|
-
import { useLocaleText, useUtils
|
|
8
|
+
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
|
|
9
|
+
import { validateDate } from '../internals/utils/validation/validateDate';
|
|
9
10
|
import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
10
11
|
import { CalendarIcon } from '../icons';
|
|
11
12
|
import { DateField } from '../DateField';
|
|
@@ -174,6 +175,10 @@ DesktopDatePicker.propTypes = {
|
|
|
174
175
|
* @default 3
|
|
175
176
|
*/
|
|
176
177
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
178
|
+
/**
|
|
179
|
+
* Name attribute used by the `input` element in the Field.
|
|
180
|
+
*/
|
|
181
|
+
name: PropTypes.string,
|
|
177
182
|
/**
|
|
178
183
|
* Callback fired when the value is accepted.
|
|
179
184
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -272,7 +277,7 @@ DesktopDatePicker.propTypes = {
|
|
|
272
277
|
* 4. If `null` is provided, no section will be selected
|
|
273
278
|
* If not provided, the selected sections will be handled internally.
|
|
274
279
|
*/
|
|
275
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
280
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
276
281
|
endIndex: PropTypes.number.isRequired,
|
|
277
282
|
startIndex: PropTypes.number.isRequired
|
|
278
283
|
})]),
|
|
@@ -251,6 +251,10 @@ DesktopDateTimePicker.propTypes = {
|
|
|
251
251
|
* @default 3
|
|
252
252
|
*/
|
|
253
253
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
254
|
+
/**
|
|
255
|
+
* Name attribute used by the `input` element in the Field.
|
|
256
|
+
*/
|
|
257
|
+
name: PropTypes.string,
|
|
254
258
|
/**
|
|
255
259
|
* Callback fired when the value is accepted.
|
|
256
260
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -349,7 +353,7 @@ DesktopDateTimePicker.propTypes = {
|
|
|
349
353
|
* 4. If `null` is provided, no section will be selected
|
|
350
354
|
* If not provided, the selected sections will be handled internally.
|
|
351
355
|
*/
|
|
352
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
356
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
353
357
|
endIndex: PropTypes.number.isRequired,
|
|
354
358
|
startIndex: PropTypes.number.isRequired
|
|
355
359
|
})]),
|
|
@@ -185,6 +185,10 @@ DesktopTimePicker.propTypes = {
|
|
|
185
185
|
* @default 1
|
|
186
186
|
*/
|
|
187
187
|
minutesStep: PropTypes.number,
|
|
188
|
+
/**
|
|
189
|
+
* Name attribute used by the `input` element in the Field.
|
|
190
|
+
*/
|
|
191
|
+
name: PropTypes.string,
|
|
188
192
|
/**
|
|
189
193
|
* Callback fired when the value is accepted.
|
|
190
194
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -265,7 +269,7 @@ DesktopTimePicker.propTypes = {
|
|
|
265
269
|
* 4. If `null` is provided, no section will be selected
|
|
266
270
|
* If not provided, the selected sections will be handled internally.
|
|
267
271
|
*/
|
|
268
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
272
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
269
273
|
endIndex: PropTypes.number.isRequired,
|
|
270
274
|
startIndex: PropTypes.number.isRequired
|
|
271
275
|
})]),
|
|
@@ -5,7 +5,8 @@ import { resolveComponentProps } from '@mui/base/utils';
|
|
|
5
5
|
import { refType } from '@mui/utils';
|
|
6
6
|
import { useMobilePicker } from '../internals/hooks/useMobilePicker';
|
|
7
7
|
import { useDatePickerDefaultizedProps } from '../DatePicker/shared';
|
|
8
|
-
import {
|
|
8
|
+
import { useUtils, useLocaleText } from '../internals/hooks/useUtils';
|
|
9
|
+
import { validateDate } from '../internals/utils/validation/validateDate';
|
|
9
10
|
import { DateField } from '../DateField';
|
|
10
11
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
11
12
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
@@ -171,6 +172,10 @@ MobileDatePicker.propTypes = {
|
|
|
171
172
|
* @default 3
|
|
172
173
|
*/
|
|
173
174
|
monthsPerRow: PropTypes.oneOf([3, 4]),
|
|
175
|
+
/**
|
|
176
|
+
* Name attribute used by the `input` element in the Field.
|
|
177
|
+
*/
|
|
178
|
+
name: PropTypes.string,
|
|
174
179
|
/**
|
|
175
180
|
* Callback fired when the value is accepted.
|
|
176
181
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -269,7 +274,7 @@ MobileDatePicker.propTypes = {
|
|
|
269
274
|
* 4. If `null` is provided, no section will be selected
|
|
270
275
|
* If not provided, the selected sections will be handled internally.
|
|
271
276
|
*/
|
|
272
|
-
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
277
|
+
selectedSections: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number, PropTypes.shape({
|
|
273
278
|
endIndex: PropTypes.number.isRequired,
|
|
274
279
|
startIndex: PropTypes.number.isRequired
|
|
275
280
|
})]),
|