@mui/x-date-pickers 6.0.4 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterDateFns/index.d.ts +1 -1
- package/AdapterDateFnsJalali/index.d.ts +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +114 -0
- package/AdapterDayjs/AdapterDayjs.js +387 -0
- package/AdapterDayjs/index.d.ts +1 -29
- package/AdapterDayjs/index.js +1 -102
- package/AdapterLuxon/index.d.ts +2 -2
- package/AdapterLuxon/index.js +1 -1
- package/AdapterMoment/index.d.ts +1 -1
- package/AdapterMomentHijri/index.d.ts +1 -1
- package/AdapterMomentJalaali/index.d.ts +1 -1
- package/CHANGELOG.md +110 -0
- package/DateCalendar/DateCalendar.js +0 -2
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +0 -12
- package/DateCalendar/PickersCalendarHeader.js +7 -9
- package/DateCalendar/PickersSlideTransition.js +1 -0
- package/DateCalendar/useCalendarState.d.ts +1 -1
- package/DateField/DateField.js +14 -2
- package/DateField/useDateField.js +3 -1
- package/DatePicker/DatePicker.js +6 -0
- package/DatePicker/shared.d.ts +2 -2
- package/DateTimeField/DateTimeField.js +14 -2
- package/DateTimeField/useDateTimeField.js +3 -1
- package/DateTimePicker/DateTimePicker.js +6 -0
- package/DateTimePicker/shared.js +3 -1
- package/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/LocalizationProvider/LocalizationProvider.d.ts +2 -3
- package/MobileDatePicker/MobileDatePicker.js +6 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/MobileTimePicker/MobileTimePicker.js +6 -0
- package/MonthCalendar/PickersMonth.js +1 -0
- package/README.md +3 -2
- package/TimeClock/ClockNumbers.d.ts +1 -1
- package/TimeClock/TimeClock.js +5 -4
- package/TimeClock/TimeClock.types.d.ts +1 -1
- package/TimeField/TimeField.js +14 -2
- package/TimeField/useTimeField.js +3 -1
- package/TimePicker/TimePicker.js +6 -0
- package/YearCalendar/PickersYear.js +1 -0
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -12
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +0 -12
- package/internals/components/PickersModalDialog.d.ts +1 -13
- package/internals/components/PickersModalDialog.js +7 -9
- package/internals/components/PickersPopper.d.ts +1 -3
- package/internals/components/PickersPopper.js +2 -7
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -3
- package/internals/hooks/useField/useField.js +2 -2
- package/internals/hooks/useField/useField.types.d.ts +9 -11
- package/internals/hooks/useField/useField.utils.d.ts +2 -3
- package/internals/hooks/useField/useField.utils.js +19 -5
- package/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
- package/internals/hooks/useField/useFieldState.js +3 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -3
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -173
- package/internals/hooks/usePicker/usePickerValue.js +199 -144
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +233 -0
- package/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerViews.js +13 -0
- package/internals/hooks/useUtils.d.ts +1 -1
- package/internals/index.d.ts +1 -2
- package/internals/models/index.d.ts +0 -1
- package/internals/models/index.js +1 -2
- package/internals/models/props/basePickerProps.d.ts +6 -0
- package/internals/utils/date-utils.d.ts +1 -1
- package/internals/utils/time-utils.d.ts +1 -2
- package/internals/utils/valueManagers.d.ts +1 -1
- package/internals/utils/valueManagers.js +2 -2
- package/legacy/AdapterDayjs/AdapterDayjs.js +403 -0
- package/legacy/AdapterDayjs/index.js +1 -119
- package/legacy/AdapterLuxon/index.js +1 -1
- package/legacy/DateCalendar/DateCalendar.js +0 -2
- package/legacy/DateCalendar/PickersCalendarHeader.js +8 -10
- package/legacy/DateField/DateField.js +13 -1
- package/legacy/DateField/useDateField.js +3 -1
- package/legacy/DatePicker/DatePicker.js +6 -0
- package/legacy/DateTimeField/DateTimeField.js +13 -1
- package/legacy/DateTimeField/useDateTimeField.js +3 -1
- package/legacy/DateTimePicker/DateTimePicker.js +6 -0
- package/legacy/DateTimePicker/shared.js +3 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/legacy/MobileDatePicker/MobileDatePicker.js +6 -0
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/legacy/MobileTimePicker/MobileTimePicker.js +6 -0
- package/legacy/TimeClock/TimeClock.js +5 -4
- package/legacy/TimeField/TimeField.js +13 -1
- package/legacy/TimeField/useTimeField.js +3 -1
- package/legacy/TimePicker/TimePicker.js +6 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -12
- package/legacy/internals/components/PickersModalDialog.js +7 -9
- package/legacy/internals/components/PickersPopper.js +2 -7
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/legacy/internals/hooks/useField/useField.js +2 -2
- package/legacy/internals/hooks/useField/useField.utils.js +27 -10
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
- package/legacy/internals/hooks/useField/useFieldState.js +5 -3
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +196 -146
- package/legacy/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/legacy/internals/hooks/usePicker/usePickerViews.js +13 -0
- package/legacy/internals/models/index.js +1 -2
- package/legacy/internals/utils/valueManagers.js +3 -3
- package/legacy/locales/caES.js +88 -0
- package/legacy/locales/esES.js +34 -17
- package/legacy/locales/heIL.js +33 -16
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/jaJP.js +3 -1
- package/legacy/locales/kzKZ.js +88 -0
- package/legacy/locales/nlNL.js +25 -11
- package/legacy/locales/ptBR.js +33 -16
- package/legacy/models/adapters.js +1 -0
- package/legacy/models/index.js +2 -1
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/legacy/tests/describeGregorianAdapter/index.js +1 -0
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +273 -0
- package/legacy/tests/describeGregorianAdapter/testFormat.js +26 -0
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +15 -0
- package/legacy/tests/describeValidation/describeValidation.js +2 -1
- package/legacy/tests/describeValidation/testMinutesViewValidation.js +201 -0
- package/legacy/tests/describeValue/testPickerActionBar.js +52 -3
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/locales/beBY.d.ts +3 -3
- package/locales/caES.d.ts +51 -0
- package/locales/caES.js +54 -0
- package/locales/csCZ.d.ts +3 -3
- package/locales/daDK.d.ts +3 -3
- package/locales/deDE.d.ts +3 -3
- package/locales/enUS.d.ts +3 -3
- package/locales/esES.d.ts +3 -3
- package/locales/esES.js +14 -17
- package/locales/faIR.d.ts +3 -3
- package/locales/fiFI.d.ts +3 -3
- package/locales/frFR.d.ts +3 -3
- package/locales/heIL.d.ts +3 -3
- package/locales/heIL.js +13 -16
- package/locales/huHU.d.ts +3 -3
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/isIS.d.ts +3 -3
- package/locales/itIT.d.ts +3 -3
- package/locales/jaJP.d.ts +3 -3
- package/locales/jaJP.js +1 -1
- package/locales/koKR.d.ts +3 -3
- package/locales/kzKZ.d.ts +51 -0
- package/locales/kzKZ.js +56 -0
- package/locales/nbNO.d.ts +3 -3
- package/locales/nlNL.d.ts +3 -3
- package/locales/nlNL.js +9 -11
- package/locales/plPL.d.ts +3 -3
- package/locales/ptBR.d.ts +3 -3
- package/locales/ptBR.js +13 -16
- package/locales/ruRU.d.ts +3 -3
- package/locales/svSE.d.ts +3 -3
- package/locales/trTR.d.ts +3 -3
- package/locales/ukUA.d.ts +3 -3
- package/locales/urPK.d.ts +3 -3
- package/locales/utils/getPickersLocalization.d.ts +3 -3
- package/locales/utils/pickersLocaleTextApi.d.ts +1 -2
- package/locales/zhCN.d.ts +3 -3
- package/models/adapters.d.ts +568 -0
- package/models/adapters.js +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/modern/AdapterDayjs/AdapterDayjs.js +386 -0
- package/modern/AdapterDayjs/index.js +1 -101
- package/modern/AdapterLuxon/index.js +1 -1
- package/modern/DateCalendar/DateCalendar.js +0 -2
- package/modern/DateCalendar/PickersCalendarHeader.js +6 -8
- package/modern/DateCalendar/PickersSlideTransition.js +1 -0
- package/modern/DateField/DateField.js +14 -2
- package/modern/DateField/useDateField.js +3 -1
- package/modern/DatePicker/DatePicker.js +6 -0
- package/modern/DateTimeField/DateTimeField.js +14 -2
- package/modern/DateTimeField/useDateTimeField.js +3 -1
- package/modern/DateTimePicker/DateTimePicker.js +6 -0
- package/modern/DateTimePicker/shared.js +3 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +6 -0
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +6 -0
- package/modern/MonthCalendar/PickersMonth.js +1 -0
- package/modern/TimeClock/TimeClock.js +5 -4
- package/modern/TimeField/TimeField.js +14 -2
- package/modern/TimeField/useTimeField.js +3 -1
- package/modern/TimePicker/TimePicker.js +6 -0
- package/modern/YearCalendar/PickersYear.js +1 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +9 -11
- package/modern/internals/components/PickersModalDialog.js +6 -8
- package/modern/internals/components/PickersPopper.js +2 -7
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/modern/internals/hooks/useField/useField.js +2 -2
- package/modern/internals/hooks/useField/useField.utils.js +19 -5
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
- package/modern/internals/hooks/useField/useFieldState.js +3 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +199 -144
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/modern/internals/hooks/usePicker/usePickerViews.js +13 -0
- package/modern/internals/models/index.js +1 -2
- package/modern/internals/utils/valueManagers.js +2 -2
- package/modern/locales/caES.js +54 -0
- package/modern/locales/esES.js +14 -17
- package/modern/locales/heIL.js +13 -16
- package/modern/locales/index.js +1 -0
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/kzKZ.js +56 -0
- package/modern/locales/nlNL.js +9 -11
- package/modern/locales/ptBR.js +13 -16
- package/modern/models/adapters.js +1 -0
- package/modern/models/index.js +2 -1
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/modern/tests/describeGregorianAdapter/index.js +1 -0
- package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -0
- package/modern/tests/describeGregorianAdapter/testFormat.js +27 -0
- package/modern/tests/describeGregorianAdapter/testLocalization.js +16 -0
- package/modern/tests/describeValidation/describeValidation.js +2 -1
- package/modern/tests/describeValidation/testMinutesViewValidation.js +200 -0
- package/modern/tests/describeValue/testPickerActionBar.js +52 -3
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/node/AdapterDayjs/AdapterDayjs.js +395 -0
- package/node/AdapterDayjs/index.js +6 -104
- package/node/AdapterLuxon/index.js +1 -1
- package/node/AdapterMomentHijri/index.js +2 -0
- package/node/DateCalendar/DateCalendar.js +0 -2
- package/node/DateCalendar/PickersCalendarHeader.js +5 -9
- package/node/DateCalendar/PickersSlideTransition.js +1 -0
- package/node/DateField/DateField.js +14 -2
- package/node/DateField/useDateField.js +3 -1
- package/node/DatePicker/DatePicker.js +6 -0
- package/node/DateTimeField/DateTimeField.js +14 -2
- package/node/DateTimeField/useDateTimeField.js +3 -1
- package/node/DateTimePicker/DateTimePicker.js +6 -0
- package/node/DateTimePicker/shared.js +3 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/node/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/node/MobileDatePicker/MobileDatePicker.js +6 -0
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/node/MobileTimePicker/MobileTimePicker.js +6 -0
- package/node/MonthCalendar/PickersMonth.js +1 -0
- package/node/TimeClock/TimeClock.js +5 -4
- package/node/TimeField/TimeField.js +14 -2
- package/node/TimeField/useTimeField.js +3 -1
- package/node/TimePicker/TimePicker.js +6 -0
- package/node/YearCalendar/PickersYear.js +1 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +9 -11
- package/node/internals/components/PickersModalDialog.js +6 -8
- package/node/internals/components/PickersPopper.js +2 -7
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/node/internals/hooks/useField/useField.js +2 -2
- package/node/internals/hooks/useField/useField.utils.js +19 -5
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +22 -0
- package/node/internals/hooks/useField/useFieldState.js +3 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +5 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +199 -144
- package/node/internals/hooks/usePicker/usePickerValue.types.js +5 -0
- package/node/internals/hooks/usePicker/usePickerViews.js +12 -0
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/valueManagers.js +2 -2
- package/node/locales/caES.js +61 -0
- package/node/locales/csCZ.js +0 -1
- package/node/locales/esES.js +14 -17
- package/node/locales/heIL.js +13 -16
- package/node/locales/index.js +11 -0
- package/node/locales/jaJP.js +1 -1
- package/node/locales/kzKZ.js +62 -0
- package/node/locales/nlNL.js +9 -11
- package/node/locales/ptBR.js +13 -16
- package/node/models/adapters.js +5 -0
- package/node/models/index.js +11 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +29 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +5 -0
- package/node/tests/describeGregorianAdapter/index.js +18 -0
- package/node/tests/describeGregorianAdapter/testCalculations.js +279 -0
- package/node/tests/describeGregorianAdapter/testFormat.js +34 -0
- package/node/tests/describeGregorianAdapter/testLocalization.js +23 -0
- package/node/tests/describeValidation/describeValidation.js +2 -1
- package/node/tests/describeValidation/testMinutesViewValidation.js +210 -0
- package/node/tests/describeValue/testPickerActionBar.js +52 -3
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/package.json +11 -11
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/tests/describeGregorianAdapter/index.js +1 -0
- package/tests/describeGregorianAdapter/testCalculations.js +272 -0
- package/tests/describeGregorianAdapter/testFormat.js +27 -0
- package/tests/describeGregorianAdapter/testLocalization.js +16 -0
- package/tests/describeValidation/describeValidation.js +2 -1
- package/tests/describeValidation/testMinutesViewValidation.js +200 -0
- package/tests/describeValue/testPickerActionBar.js +52 -3
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/internals/models/muiPickersAdapter.d.ts +0 -26
|
@@ -1,6 +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 = ["components", "componentsProps", "slots", "slotProps"],
|
|
3
|
+
const _excluded = ["components", "componentsProps", "slots", "slotProps", "InputProps", "inputProps"],
|
|
4
4
|
_excluded2 = ["inputRef"],
|
|
5
5
|
_excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -19,7 +19,9 @@ const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inPro
|
|
|
19
19
|
components,
|
|
20
20
|
componentsProps,
|
|
21
21
|
slots,
|
|
22
|
-
slotProps
|
|
22
|
+
slotProps,
|
|
23
|
+
InputProps,
|
|
24
|
+
inputProps
|
|
23
25
|
} = themeProps,
|
|
24
26
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
25
27
|
const ownerState = themeProps;
|
|
@@ -34,6 +36,10 @@ const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inPro
|
|
|
34
36
|
inputRef: externalInputRef
|
|
35
37
|
} = _useSlotProps,
|
|
36
38
|
textFieldProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
39
|
+
|
|
40
|
+
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
41
|
+
textFieldProps.inputProps = _extends({}, textFieldProps.inputProps, inputProps);
|
|
42
|
+
textFieldProps.InputProps = _extends({}, textFieldProps.InputProps, InputProps);
|
|
37
43
|
const _useDateTimeField = useDateTimeField({
|
|
38
44
|
props: textFieldProps,
|
|
39
45
|
inputRef: externalInputRef
|
|
@@ -123,6 +129,12 @@ process.env.NODE_ENV !== "production" ? DateTimeField.propTypes = {
|
|
|
123
129
|
* Format of the date when rendered in the input(s).
|
|
124
130
|
*/
|
|
125
131
|
format: PropTypes.string,
|
|
132
|
+
/**
|
|
133
|
+
* Density of the format when rendered in the input.
|
|
134
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
135
|
+
* @default "dense"
|
|
136
|
+
*/
|
|
137
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
126
138
|
/**
|
|
127
139
|
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
128
140
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
3
|
+
const _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDateTime } from '../internals/hooks/validation/useDateTimeValidation';
|
|
@@ -31,6 +31,7 @@ export const useDateTimeField = ({
|
|
|
31
31
|
value,
|
|
32
32
|
defaultValue,
|
|
33
33
|
format,
|
|
34
|
+
formatDensity,
|
|
34
35
|
onChange,
|
|
35
36
|
readOnly,
|
|
36
37
|
onError,
|
|
@@ -60,6 +61,7 @@ export const useDateTimeField = ({
|
|
|
60
61
|
value,
|
|
61
62
|
defaultValue,
|
|
62
63
|
format,
|
|
64
|
+
formatDensity,
|
|
63
65
|
onChange,
|
|
64
66
|
readOnly,
|
|
65
67
|
onError,
|
|
@@ -142,6 +142,12 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
142
142
|
* Defaults to localized format based on the used `views`.
|
|
143
143
|
*/
|
|
144
144
|
format: PropTypes.string,
|
|
145
|
+
/**
|
|
146
|
+
* Density of the format when rendered in the input.
|
|
147
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
148
|
+
* @default "dense"
|
|
149
|
+
*/
|
|
150
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
145
151
|
/**
|
|
146
152
|
* Pass a ref to the `input` element.
|
|
147
153
|
*/
|
|
@@ -35,7 +35,9 @@ export function useDateTimePickerDefaultizedProps(props, name) {
|
|
|
35
35
|
localeText,
|
|
36
36
|
orientation: themeProps.orientation ?? 'portrait',
|
|
37
37
|
// TODO: Remove from public API
|
|
38
|
-
disableIgnoringDatePartForTimeValidation: themeProps.disableIgnoringDatePartForTimeValidation ?? Boolean(themeProps.minDateTime || themeProps.maxDateTime
|
|
38
|
+
disableIgnoringDatePartForTimeValidation: themeProps.disableIgnoringDatePartForTimeValidation ?? Boolean(themeProps.minDateTime || themeProps.maxDateTime ||
|
|
39
|
+
// allow time clock to correctly check time validity: https://github.com/mui/mui-x/issues/8520
|
|
40
|
+
themeProps.disablePast || themeProps.disableFuture),
|
|
39
41
|
disableFuture: themeProps.disableFuture ?? false,
|
|
40
42
|
disablePast: themeProps.disablePast ?? false,
|
|
41
43
|
minDate: applyDefaultDate(utils, themeProps.minDateTime ?? themeProps.minDate, defaultDates.minDate),
|
|
@@ -139,6 +139,12 @@ DesktopDatePicker.propTypes = {
|
|
|
139
139
|
* Defaults to localized format based on the used `views`.
|
|
140
140
|
*/
|
|
141
141
|
format: PropTypes.string,
|
|
142
|
+
/**
|
|
143
|
+
* Density of the format when rendered in the input.
|
|
144
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
145
|
+
* @default "dense"
|
|
146
|
+
*/
|
|
147
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
142
148
|
/**
|
|
143
149
|
* Pass a ref to the `input` element.
|
|
144
150
|
*/
|
|
@@ -162,6 +162,12 @@ DesktopDateTimePicker.propTypes = {
|
|
|
162
162
|
* Defaults to localized format based on the used `views`.
|
|
163
163
|
*/
|
|
164
164
|
format: PropTypes.string,
|
|
165
|
+
/**
|
|
166
|
+
* Density of the format when rendered in the input.
|
|
167
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
168
|
+
* @default "dense"
|
|
169
|
+
*/
|
|
170
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
165
171
|
/**
|
|
166
172
|
* Pass a ref to the `input` element.
|
|
167
173
|
*/
|
|
@@ -128,6 +128,12 @@ DesktopTimePicker.propTypes = {
|
|
|
128
128
|
* Defaults to localized format based on the used `views`.
|
|
129
129
|
*/
|
|
130
130
|
format: PropTypes.string,
|
|
131
|
+
/**
|
|
132
|
+
* Density of the format when rendered in the input.
|
|
133
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
134
|
+
* @default "dense"
|
|
135
|
+
*/
|
|
136
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
131
137
|
/**
|
|
132
138
|
* Pass a ref to the `input` element.
|
|
133
139
|
*/
|
|
@@ -136,6 +136,12 @@ MobileDatePicker.propTypes = {
|
|
|
136
136
|
* Defaults to localized format based on the used `views`.
|
|
137
137
|
*/
|
|
138
138
|
format: PropTypes.string,
|
|
139
|
+
/**
|
|
140
|
+
* Density of the format when rendered in the input.
|
|
141
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
142
|
+
* @default "dense"
|
|
143
|
+
*/
|
|
144
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
139
145
|
/**
|
|
140
146
|
* Pass a ref to the `input` element.
|
|
141
147
|
*/
|
|
@@ -160,6 +160,12 @@ MobileDateTimePicker.propTypes = {
|
|
|
160
160
|
* Defaults to localized format based on the used `views`.
|
|
161
161
|
*/
|
|
162
162
|
format: PropTypes.string,
|
|
163
|
+
/**
|
|
164
|
+
* Density of the format when rendered in the input.
|
|
165
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
166
|
+
* @default "dense"
|
|
167
|
+
*/
|
|
168
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
163
169
|
/**
|
|
164
170
|
* Pass a ref to the `input` element.
|
|
165
171
|
*/
|
|
@@ -127,6 +127,12 @@ MobileTimePicker.propTypes = {
|
|
|
127
127
|
* Defaults to localized format based on the used `views`.
|
|
128
128
|
*/
|
|
129
129
|
format: PropTypes.string,
|
|
130
|
+
/**
|
|
131
|
+
* Density of the format when rendered in the input.
|
|
132
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
133
|
+
* @default "dense"
|
|
134
|
+
*/
|
|
135
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
130
136
|
/**
|
|
131
137
|
* Pass a ref to the `input` element.
|
|
132
138
|
*/
|
|
@@ -92,6 +92,7 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
|
|
|
92
92
|
onFocus,
|
|
93
93
|
onBlur,
|
|
94
94
|
'aria-current': ariaCurrent
|
|
95
|
+
// We don't want to forward this prop to the root element
|
|
95
96
|
} = props,
|
|
96
97
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
97
98
|
const ref = React.useRef(null);
|
|
@@ -16,6 +16,7 @@ import { PickerViewRoot } from '../internals/components/PickerViewRoot';
|
|
|
16
16
|
import { getTimeClockUtilityClass } from './timeClockClasses';
|
|
17
17
|
import { Clock } from './Clock';
|
|
18
18
|
import { getHourNumbers, getMinutesNumbers } from './ClockNumbers';
|
|
19
|
+
import { uncapitalizeObjectKeys } from '../internals/utils/slots-migration';
|
|
19
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
22
|
const useUtilityClasses = ownerState => {
|
|
@@ -66,8 +67,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
66
67
|
autoFocus,
|
|
67
68
|
components,
|
|
68
69
|
componentsProps,
|
|
69
|
-
slots,
|
|
70
|
-
slotProps,
|
|
70
|
+
slots: innerSlots,
|
|
71
|
+
slotProps: innerSlotProps,
|
|
71
72
|
value: valueProp,
|
|
72
73
|
disableIgnoringDatePartForTimeValidation = false,
|
|
73
74
|
maxTime,
|
|
@@ -89,6 +90,8 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
89
90
|
readOnly
|
|
90
91
|
} = props,
|
|
91
92
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
93
|
+
const slots = innerSlots ?? uncapitalizeObjectKeys(components);
|
|
94
|
+
const slotProps = innerSlotProps ?? componentsProps;
|
|
92
95
|
const [value, setValue] = useControlled({
|
|
93
96
|
name: 'DateCalendar',
|
|
94
97
|
state: 'value',
|
|
@@ -282,8 +285,6 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
282
285
|
readOnly: readOnly
|
|
283
286
|
}, viewProps)), showViewSwitcher && /*#__PURE__*/_jsx(TimeClockArrowSwitcher, {
|
|
284
287
|
className: classes.arrowSwitcher,
|
|
285
|
-
components: components,
|
|
286
|
-
componentsProps: componentsProps,
|
|
287
288
|
slots: slots,
|
|
288
289
|
slotProps: slotProps,
|
|
289
290
|
onGoToPrevious: () => setView(previousView),
|
|
@@ -1,6 +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", "components", "componentsProps"],
|
|
3
|
+
const _excluded = ["slots", "slotProps", "components", "componentsProps", "InputProps", "inputProps"],
|
|
4
4
|
_excluded2 = ["inputRef"],
|
|
5
5
|
_excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -19,7 +19,9 @@ const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref)
|
|
|
19
19
|
slots,
|
|
20
20
|
slotProps,
|
|
21
21
|
components,
|
|
22
|
-
componentsProps
|
|
22
|
+
componentsProps,
|
|
23
|
+
InputProps,
|
|
24
|
+
inputProps
|
|
23
25
|
} = themeProps,
|
|
24
26
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
25
27
|
const ownerState = themeProps;
|
|
@@ -34,6 +36,10 @@ const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref)
|
|
|
34
36
|
inputRef: externalInputRef
|
|
35
37
|
} = _useSlotProps,
|
|
36
38
|
textFieldProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
39
|
+
|
|
40
|
+
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
41
|
+
textFieldProps.inputProps = _extends({}, textFieldProps.inputProps, inputProps);
|
|
42
|
+
textFieldProps.InputProps = _extends({}, textFieldProps.InputProps, InputProps);
|
|
37
43
|
const _useTimeField = useTimeField({
|
|
38
44
|
props: textFieldProps,
|
|
39
45
|
inputRef: externalInputRef
|
|
@@ -123,6 +129,12 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
123
129
|
* Format of the date when rendered in the input(s).
|
|
124
130
|
*/
|
|
125
131
|
format: PropTypes.string,
|
|
132
|
+
/**
|
|
133
|
+
* Density of the format when rendered in the input.
|
|
134
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
135
|
+
* @default "dense"
|
|
136
|
+
*/
|
|
137
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
126
138
|
/**
|
|
127
139
|
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
128
140
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "disableFuture", "disablePast", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
3
|
+
const _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "disableFuture", "disablePast", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateTime } from '../internals/hooks/validation/useTimeValidation';
|
|
@@ -24,6 +24,7 @@ export const useTimeField = ({
|
|
|
24
24
|
value,
|
|
25
25
|
defaultValue,
|
|
26
26
|
format,
|
|
27
|
+
formatDensity,
|
|
27
28
|
onChange,
|
|
28
29
|
readOnly,
|
|
29
30
|
onError,
|
|
@@ -48,6 +49,7 @@ export const useTimeField = ({
|
|
|
48
49
|
value,
|
|
49
50
|
defaultValue,
|
|
50
51
|
format,
|
|
52
|
+
formatDensity,
|
|
51
53
|
onChange,
|
|
52
54
|
readOnly,
|
|
53
55
|
onError,
|
|
@@ -116,6 +116,12 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
116
116
|
* Defaults to localized format based on the used `views`.
|
|
117
117
|
*/
|
|
118
118
|
format: PropTypes.string,
|
|
119
|
+
/**
|
|
120
|
+
* Density of the format when rendered in the input.
|
|
121
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
122
|
+
* @default "dense"
|
|
123
|
+
*/
|
|
124
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
119
125
|
/**
|
|
120
126
|
* Pass a ref to the `input` element.
|
|
121
127
|
*/
|
|
@@ -94,6 +94,7 @@ export const PickersYear = /*#__PURE__*/React.memo(function PickersYear(inProps)
|
|
|
94
94
|
onFocus,
|
|
95
95
|
onBlur,
|
|
96
96
|
'aria-current': ariaCurrent
|
|
97
|
+
// We don't want to forward this prop to the root element
|
|
97
98
|
} = props,
|
|
98
99
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
99
100
|
const ref = React.useRef(null);
|
package/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["children", "className", "
|
|
3
|
+
const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel"],
|
|
4
4
|
_excluded2 = ["ownerState"],
|
|
5
5
|
_excluded3 = ["ownerState"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -60,8 +60,6 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
60
60
|
const {
|
|
61
61
|
children,
|
|
62
62
|
className,
|
|
63
|
-
components,
|
|
64
|
-
componentsProps,
|
|
65
63
|
slots,
|
|
66
64
|
slotProps,
|
|
67
65
|
isNextDisabled,
|
|
@@ -89,10 +87,10 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
89
87
|
label: previousLabel
|
|
90
88
|
};
|
|
91
89
|
const [leftProps, rightProps] = isRTL ? [nextProps, previousProps] : [previousProps, nextProps];
|
|
92
|
-
const PreviousIconButton = slots?.previousIconButton ??
|
|
90
|
+
const PreviousIconButton = slots?.previousIconButton ?? PickersArrowSwitcherButton;
|
|
93
91
|
const previousIconButtonProps = useSlotProps({
|
|
94
92
|
elementType: PreviousIconButton,
|
|
95
|
-
externalSlotProps: slotProps?.previousIconButton
|
|
93
|
+
externalSlotProps: slotProps?.previousIconButton,
|
|
96
94
|
additionalProps: {
|
|
97
95
|
size: 'medium',
|
|
98
96
|
title: leftProps.label,
|
|
@@ -106,10 +104,10 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
106
104
|
}),
|
|
107
105
|
className: classes.button
|
|
108
106
|
});
|
|
109
|
-
const NextIconButton = slots?.nextIconButton ??
|
|
107
|
+
const NextIconButton = slots?.nextIconButton ?? PickersArrowSwitcherButton;
|
|
110
108
|
const nextIconButtonProps = useSlotProps({
|
|
111
109
|
elementType: NextIconButton,
|
|
112
|
-
externalSlotProps: slotProps?.nextIconButton
|
|
110
|
+
externalSlotProps: slotProps?.nextIconButton,
|
|
113
111
|
additionalProps: {
|
|
114
112
|
size: 'medium',
|
|
115
113
|
title: rightProps.label,
|
|
@@ -123,22 +121,22 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
123
121
|
}),
|
|
124
122
|
className: classes.button
|
|
125
123
|
});
|
|
126
|
-
const LeftArrowIcon = slots?.leftArrowIcon ??
|
|
124
|
+
const LeftArrowIcon = slots?.leftArrowIcon ?? ArrowLeft;
|
|
127
125
|
// The spread is here to avoid this bug mui/material-ui#34056
|
|
128
126
|
const _useSlotProps = useSlotProps({
|
|
129
127
|
elementType: LeftArrowIcon,
|
|
130
|
-
externalSlotProps: slotProps?.leftArrowIcon
|
|
128
|
+
externalSlotProps: slotProps?.leftArrowIcon,
|
|
131
129
|
additionalProps: {
|
|
132
130
|
fontSize: 'inherit'
|
|
133
131
|
},
|
|
134
132
|
ownerState: undefined
|
|
135
133
|
}),
|
|
136
134
|
leftArrowIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
137
|
-
const RightArrowIcon = slots?.rightArrowIcon ??
|
|
135
|
+
const RightArrowIcon = slots?.rightArrowIcon ?? ArrowRight;
|
|
138
136
|
// The spread is here to avoid this bug mui/material-ui#34056
|
|
139
137
|
const _useSlotProps2 = useSlotProps({
|
|
140
138
|
elementType: RightArrowIcon,
|
|
141
|
-
externalSlotProps: slotProps?.rightArrowIcon
|
|
139
|
+
externalSlotProps: slotProps?.rightArrowIcon,
|
|
142
140
|
additionalProps: {
|
|
143
141
|
fontSize: 'inherit'
|
|
144
142
|
},
|
|
@@ -25,21 +25,19 @@ export function PickersModalDialog(props) {
|
|
|
25
25
|
children,
|
|
26
26
|
onDismiss,
|
|
27
27
|
open,
|
|
28
|
-
components,
|
|
29
|
-
componentsProps,
|
|
30
28
|
slots,
|
|
31
29
|
slotProps
|
|
32
30
|
} = props;
|
|
33
|
-
const Dialog = slots?.dialog ??
|
|
34
|
-
const Transition = slots?.mobileTransition ??
|
|
31
|
+
const Dialog = slots?.dialog ?? PickersModalDialogRoot;
|
|
32
|
+
const Transition = slots?.mobileTransition ?? Fade;
|
|
35
33
|
return /*#__PURE__*/_jsx(Dialog, _extends({
|
|
36
34
|
open: open,
|
|
37
35
|
onClose: onDismiss
|
|
38
|
-
},
|
|
36
|
+
}, slotProps?.dialog, {
|
|
39
37
|
TransitionComponent: Transition,
|
|
40
|
-
TransitionProps: slotProps?.mobileTransition
|
|
41
|
-
PaperComponent: slots?.mobilePaper
|
|
42
|
-
PaperProps: slotProps?.mobilePaper
|
|
38
|
+
TransitionProps: slotProps?.mobileTransition,
|
|
39
|
+
PaperComponent: slots?.mobilePaper,
|
|
40
|
+
PaperProps: slotProps?.mobilePaper,
|
|
43
41
|
children: /*#__PURE__*/_jsx(PickersModalDialogContent, {
|
|
44
42
|
children: children
|
|
45
43
|
})
|
|
@@ -9,7 +9,6 @@ import { unstable_useForkRef as useForkRef, unstable_useEventCallback as useEven
|
|
|
9
9
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
10
|
import { getPickersPopperUtilityClass } from './pickersPopperClasses';
|
|
11
11
|
import { getActiveElement } from '../utils/utils';
|
|
12
|
-
import { uncapitalizeObjectKeys } from '../utils/slots-migration';
|
|
13
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
13
|
const useUtilityClasses = ownerState => {
|
|
15
14
|
const {
|
|
@@ -172,13 +171,9 @@ export function PickersPopper(inProps) {
|
|
|
172
171
|
open,
|
|
173
172
|
role,
|
|
174
173
|
placement,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
slots: innerSlots,
|
|
178
|
-
slotProps: innerSlotProps
|
|
174
|
+
slots,
|
|
175
|
+
slotProps
|
|
179
176
|
} = props;
|
|
180
|
-
const slots = innerSlots ?? uncapitalizeObjectKeys(components);
|
|
181
|
-
const slotProps = innerSlotProps ?? componentsProps;
|
|
182
177
|
React.useEffect(() => {
|
|
183
178
|
function handleKeyDown(nativeEvent) {
|
|
184
179
|
// IE11, Edge (prior to using Blink?) use 'Esc'
|
|
@@ -33,6 +33,7 @@ export const useDesktopPicker = ({
|
|
|
33
33
|
className,
|
|
34
34
|
sx,
|
|
35
35
|
format,
|
|
36
|
+
formatDensity,
|
|
36
37
|
label,
|
|
37
38
|
inputRef,
|
|
38
39
|
readOnly,
|
|
@@ -98,6 +99,7 @@ export const useDesktopPicker = ({
|
|
|
98
99
|
className,
|
|
99
100
|
sx,
|
|
100
101
|
format,
|
|
102
|
+
formatDensity,
|
|
101
103
|
label,
|
|
102
104
|
autoFocus: autoFocus && !props.open
|
|
103
105
|
}),
|
|
@@ -302,8 +302,8 @@ export const useField = params => {
|
|
|
302
302
|
if (error !== undefined) {
|
|
303
303
|
return error;
|
|
304
304
|
}
|
|
305
|
-
return
|
|
306
|
-
}, [
|
|
305
|
+
return valueManager.hasError(validationError);
|
|
306
|
+
}, [valueManager, validationError, error]);
|
|
307
307
|
React.useEffect(() => {
|
|
308
308
|
// Select the right section when focused on mount (`autoFocus = true` on the input)
|
|
309
309
|
if (inputRef.current && inputRef.current === document.activeElement) {
|
|
@@ -309,7 +309,7 @@ const getEscapedPartsFromFormat = (utils, format) => {
|
|
|
309
309
|
}
|
|
310
310
|
return escapedParts;
|
|
311
311
|
};
|
|
312
|
-
export const splitFormatIntoSections = (utils, localeText, format, date) => {
|
|
312
|
+
export const splitFormatIntoSections = (utils, localeText, format, date, formatDensity) => {
|
|
313
313
|
let startSeparator = '';
|
|
314
314
|
const sections = [];
|
|
315
315
|
const commitToken = token => {
|
|
@@ -380,8 +380,8 @@ export const splitFormatIntoSections = (utils, localeText, format, date) => {
|
|
|
380
380
|
if (cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
|
381
381
|
cleanedSeparator = `\u2069${cleanedSeparator}\u2066`;
|
|
382
382
|
}
|
|
383
|
-
if (
|
|
384
|
-
cleanedSeparator =
|
|
383
|
+
if (formatDensity === 'spacious' && ['/', '.', '-'].includes(cleanedSeparator)) {
|
|
384
|
+
cleanedSeparator = ` ${cleanedSeparator} `;
|
|
385
385
|
}
|
|
386
386
|
return cleanedSeparator;
|
|
387
387
|
};
|
|
@@ -586,7 +586,19 @@ const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTran
|
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
588
|
};
|
|
589
|
-
|
|
589
|
+
const reliableSectionModificationOrder = {
|
|
590
|
+
year: 1,
|
|
591
|
+
month: 2,
|
|
592
|
+
day: 3,
|
|
593
|
+
weekDay: 4,
|
|
594
|
+
hours: 5,
|
|
595
|
+
minutes: 6,
|
|
596
|
+
seconds: 7,
|
|
597
|
+
meridiem: 8
|
|
598
|
+
};
|
|
599
|
+
export const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
|
|
600
|
+
// cloning sections before sort to avoid mutating it
|
|
601
|
+
[...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {
|
|
590
602
|
if (!shouldLimitToEditedSections || section.modified) {
|
|
591
603
|
return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);
|
|
592
604
|
}
|
|
@@ -666,7 +678,9 @@ export const getSectionOrder = (sections, isRTL) => {
|
|
|
666
678
|
while (RTLIndex >= 0) {
|
|
667
679
|
groupedSectionsEnd = sections.findIndex(
|
|
668
680
|
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
669
|
-
(section, index) => index >= groupedSectionsStart && section.endSeparator?.includes(' ')
|
|
681
|
+
(section, index) => index >= groupedSectionsStart && section.endSeparator?.includes(' ') &&
|
|
682
|
+
// Special case where the spaces were not there in the initial input
|
|
683
|
+
section.endSeparator !== ' / ');
|
|
670
684
|
if (groupedSectionsEnd === -1) {
|
|
671
685
|
groupedSectionsEnd = sections.length - 1;
|
|
672
686
|
}
|
|
@@ -3,6 +3,29 @@ import * as React from 'react';
|
|
|
3
3
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
4
|
import { useUtils } from '../useUtils';
|
|
5
5
|
import { changeSectionValueFormat, cleanDigitSectionValue, doesSectionHaveLeadingZeros, getDateSectionConfigFromFormatToken, getDaysInWeekStr, getLetterEditingOptions } from './useField.utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The letter editing and the numeric editing each define a `CharacterEditingApplier`.
|
|
9
|
+
* This function decides what the new section value should be and if the focus should switch to the next section.
|
|
10
|
+
*
|
|
11
|
+
* If it returns `null`, then the section value is not updated and the focus does not move.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Function called by `applyQuery` which decides:
|
|
16
|
+
* - what is the new section value ?
|
|
17
|
+
* - should the query used to get this value be stored for the next key press ?
|
|
18
|
+
*
|
|
19
|
+
* If it returns `{ sectionValue: string; shouldGoToNextSection: boolean }`,
|
|
20
|
+
* Then we store the query and update the section with the new value.
|
|
21
|
+
*
|
|
22
|
+
* If it returns `{ saveQuery: true` },
|
|
23
|
+
* Then we store the query and don't update the section.
|
|
24
|
+
*
|
|
25
|
+
* If it returns `{ saveQuery: false },
|
|
26
|
+
* Then we do nothing.
|
|
27
|
+
*/
|
|
28
|
+
|
|
6
29
|
const QUERY_LIFE_DURATION_MS = 5000;
|
|
7
30
|
const isQueryResponseWithoutValue = response => response.saveQuery != null;
|
|
8
31
|
|
|
@@ -21,6 +21,7 @@ export const useFieldState = params => {
|
|
|
21
21
|
defaultValue,
|
|
22
22
|
onChange,
|
|
23
23
|
format,
|
|
24
|
+
formatDensity = 'dense',
|
|
24
25
|
selectedSections: selectedSectionsProp,
|
|
25
26
|
onSelectedSectionsChange
|
|
26
27
|
}
|
|
@@ -28,7 +29,7 @@ export const useFieldState = params => {
|
|
|
28
29
|
const firstDefaultValue = React.useRef(defaultValue);
|
|
29
30
|
const valueFromTheOutside = valueProp ?? firstDefaultValue.current ?? valueManager.emptyValue;
|
|
30
31
|
const sectionsValueBoundaries = React.useMemo(() => getSectionsBoundaries(utils), [utils]);
|
|
31
|
-
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => splitFormatIntoSections(utils, localeText, format, date)), [fieldValueManager, format, localeText, isRTL, utils]);
|
|
32
|
+
const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, date => splitFormatIntoSections(utils, localeText, format, date, formatDensity)), [fieldValueManager, format, localeText, isRTL, utils, formatDensity]);
|
|
32
33
|
const placeholder = React.useMemo(() => fieldValueManager.getValueStrFromSections(getSectionsFromValue(valueManager.emptyValue), isRTL), [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, isRTL]);
|
|
33
34
|
const [state, setState] = React.useState(() => {
|
|
34
35
|
const sections = getSectionsFromValue(valueFromTheOutside);
|
|
@@ -152,7 +153,7 @@ export const useFieldState = params => {
|
|
|
152
153
|
if (date == null || !utils.isValid(date)) {
|
|
153
154
|
return null;
|
|
154
155
|
}
|
|
155
|
-
const sections = splitFormatIntoSections(utils, localeText, format, date);
|
|
156
|
+
const sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity);
|
|
156
157
|
return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);
|
|
157
158
|
};
|
|
158
159
|
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
@@ -29,6 +29,7 @@ export const useMobilePicker = ({
|
|
|
29
29
|
className,
|
|
30
30
|
sx,
|
|
31
31
|
format,
|
|
32
|
+
formatDensity,
|
|
32
33
|
label,
|
|
33
34
|
inputRef,
|
|
34
35
|
readOnly,
|
|
@@ -69,6 +70,7 @@ export const useMobilePicker = ({
|
|
|
69
70
|
className,
|
|
70
71
|
sx,
|
|
71
72
|
format,
|
|
73
|
+
formatDensity,
|
|
72
74
|
label
|
|
73
75
|
}),
|
|
74
76
|
ownerState: props
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { useIsLandscape } from '../useIsLandscape';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props used to create the layout of the views.
|
|
6
|
+
* Those props are exposed on all the pickers.
|
|
7
|
+
*/
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
5
11
|
*/
|