@mui/x-date-pickers 6.1.0 → 6.2.1
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/AdapterDayjs/AdapterDayjs.d.ts +114 -0
- package/AdapterDayjs/AdapterDayjs.js +387 -0
- package/AdapterDayjs/index.d.ts +1 -28
- package/AdapterDayjs/index.js +1 -102
- package/CHANGELOG.md +101 -1
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateField/DateField.js +6 -0
- package/DateField/useDateField.js +3 -1
- package/DatePicker/DatePicker.js +6 -0
- package/DateTimeField/DateTimeField.js +6 -0
- package/DateTimeField/useDateTimeField.js +3 -1
- package/DateTimePicker/DateTimePicker.js +6 -0
- package/DateTimePicker/shared.js +3 -1
- package/DesktopDatePicker/DesktopDatePicker.js +7 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/LocalizationProvider/LocalizationProvider.d.ts +1 -1
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MobileDatePicker/MobileDatePicker.js +7 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/MobileTimePicker/MobileTimePicker.js +7 -0
- package/README.md +1 -0
- package/StaticDatePicker/StaticDatePicker.js +1 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/StaticTimePicker/StaticTimePicker.js +3 -2
- package/TimeClock/TimeClock.types.d.ts +1 -1
- package/TimeField/TimeField.js +6 -0
- package/TimeField/useTimeField.js +3 -1
- package/TimePicker/TimePicker.js +6 -0
- package/index.js +1 -1
- package/internals/components/PickersModalDialog.d.ts +1 -1
- package/internals/components/PickersPopper.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -14
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/useField.types.d.ts +7 -2
- package/internals/hooks/useField/useField.utils.d.ts +3 -3
- package/internals/hooks/useField/useField.utils.js +16 -4
- package/internals/hooks/useField/useFieldState.js +4 -3
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +12 -10
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +2 -0
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.d.ts +4 -180
- package/internals/hooks/usePicker/usePickerValue.js +191 -159
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +235 -0
- package/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.d.ts +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/models/props/basePickerProps.d.ts +6 -0
- package/internals/utils/valueManagers.js +1 -1
- package/legacy/AdapterDayjs/AdapterDayjs.js +403 -0
- package/legacy/AdapterDayjs/index.js +1 -119
- package/legacy/DateField/DateField.js +6 -0
- package/legacy/DateField/useDateField.js +3 -1
- package/legacy/DatePicker/DatePicker.js +6 -0
- package/legacy/DateTimeField/DateTimeField.js +6 -0
- 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 +7 -0
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +7 -0
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/legacy/MobileTimePicker/MobileTimePicker.js +7 -0
- package/legacy/StaticDatePicker/StaticDatePicker.js +1 -0
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/legacy/StaticTimePicker/StaticTimePicker.js +3 -2
- package/legacy/TimeField/TimeField.js +6 -0
- package/legacy/TimeField/useTimeField.js +3 -1
- package/legacy/TimePicker/TimePicker.js +6 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +10 -10
- package/legacy/internals/hooks/useField/useField.utils.js +24 -9
- package/legacy/internals/hooks/useField/useFieldState.js +6 -4
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +7 -6
- package/legacy/internals/hooks/usePicker/usePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +186 -159
- package/legacy/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/legacy/internals/hooks/useStaticPicker/useStaticPicker.js +7 -8
- package/legacy/internals/utils/valueManagers.js +2 -2
- 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/models/adapters.d.ts +21 -20
- package/models/fields.d.ts +1 -0
- package/modern/AdapterDayjs/AdapterDayjs.js +386 -0
- package/modern/AdapterDayjs/index.js +1 -101
- package/modern/DateField/DateField.js +6 -0
- package/modern/DateField/useDateField.js +3 -1
- package/modern/DatePicker/DatePicker.js +6 -0
- package/modern/DateTimeField/DateTimeField.js +6 -0
- 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 +7 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +7 -0
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +7 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +1 -0
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/modern/StaticTimePicker/StaticTimePicker.js +3 -2
- package/modern/TimeField/TimeField.js +6 -0
- package/modern/TimeField/useTimeField.js +3 -1
- package/modern/TimePicker/TimePicker.js +6 -0
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -14
- package/modern/internals/hooks/useField/useField.utils.js +16 -4
- package/modern/internals/hooks/useField/useFieldState.js +4 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +12 -10
- package/modern/internals/hooks/usePicker/usePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +191 -159
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/modern/internals/utils/valueManagers.js +1 -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/DateField/DateField.js +6 -0
- package/node/DateField/useDateField.js +3 -1
- package/node/DatePicker/DatePicker.js +6 -0
- package/node/DateTimeField/DateTimeField.js +6 -0
- 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 +7 -0
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +7 -0
- package/node/DesktopTimePicker/DesktopTimePicker.js +7 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MobileDatePicker/MobileDatePicker.js +7 -0
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +7 -0
- package/node/MobileTimePicker/MobileTimePicker.js +7 -0
- package/node/StaticDatePicker/StaticDatePicker.js +1 -0
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +3 -2
- package/node/StaticTimePicker/StaticTimePicker.js +3 -2
- package/node/TimeField/TimeField.js +6 -0
- package/node/TimeField/useTimeField.js +3 -1
- package/node/TimePicker/TimePicker.js +6 -0
- package/node/index.js +1 -1
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +15 -14
- package/node/internals/hooks/useField/useField.utils.js +16 -4
- package/node/internals/hooks/useField/useFieldState.js +4 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +12 -10
- package/node/internals/hooks/usePicker/usePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +191 -158
- package/node/internals/hooks/usePicker/usePickerValue.types.js +5 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +10 -10
- package/node/internals/utils/valueManagers.js +1 -1
- 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 +9 -9
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
3
|
+
var _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';
|
|
@@ -30,6 +30,7 @@ export var useDateTimeField = function useDateTimeField(_ref) {
|
|
|
30
30
|
value = _useDefaultizedDateTi.value,
|
|
31
31
|
defaultValue = _useDefaultizedDateTi.defaultValue,
|
|
32
32
|
format = _useDefaultizedDateTi.format,
|
|
33
|
+
formatDensity = _useDefaultizedDateTi.formatDensity,
|
|
33
34
|
onChange = _useDefaultizedDateTi.onChange,
|
|
34
35
|
readOnly = _useDefaultizedDateTi.readOnly,
|
|
35
36
|
onError = _useDefaultizedDateTi.onError,
|
|
@@ -60,6 +61,7 @@ export var useDateTimeField = function useDateTimeField(_ref) {
|
|
|
60
61
|
value: value,
|
|
61
62
|
defaultValue: defaultValue,
|
|
62
63
|
format: format,
|
|
64
|
+
formatDensity: formatDensity,
|
|
63
65
|
onChange: onChange,
|
|
64
66
|
readOnly: readOnly,
|
|
65
67
|
onError: onError,
|
|
@@ -141,6 +141,12 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
141
141
|
* Defaults to localized format based on the used `views`.
|
|
142
142
|
*/
|
|
143
143
|
format: PropTypes.string,
|
|
144
|
+
/**
|
|
145
|
+
* Density of the format when rendered in the input.
|
|
146
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
147
|
+
* @default "dense"
|
|
148
|
+
*/
|
|
149
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
144
150
|
/**
|
|
145
151
|
* Pass a ref to the `input` element.
|
|
146
152
|
*/
|
|
@@ -37,7 +37,9 @@ export function useDateTimePickerDefaultizedProps(props, name) {
|
|
|
37
37
|
localeText: localeText,
|
|
38
38
|
orientation: (_themeProps$orientati = themeProps.orientation) != null ? _themeProps$orientati : 'portrait',
|
|
39
39
|
// TODO: Remove from public API
|
|
40
|
-
disableIgnoringDatePartForTimeValidation: (_themeProps$disableIg = themeProps.disableIgnoringDatePartForTimeValidation) != null ? _themeProps$disableIg : Boolean(themeProps.minDateTime || themeProps.maxDateTime
|
|
40
|
+
disableIgnoringDatePartForTimeValidation: (_themeProps$disableIg = themeProps.disableIgnoringDatePartForTimeValidation) != null ? _themeProps$disableIg : Boolean(themeProps.minDateTime || themeProps.maxDateTime ||
|
|
41
|
+
// allow time clock to correctly check time validity: https://github.com/mui/mui-x/issues/8520
|
|
42
|
+
themeProps.disablePast || themeProps.disableFuture),
|
|
41
43
|
disableFuture: (_themeProps$disableFu = themeProps.disableFuture) != null ? _themeProps$disableFu : false,
|
|
42
44
|
disablePast: (_themeProps$disablePa = themeProps.disablePast) != null ? _themeProps$disablePa : false,
|
|
43
45
|
minDate: applyDefaultDate(utils, (_themeProps$minDateTi = themeProps.minDateTime) != null ? _themeProps$minDateTi : themeProps.minDate, defaultDates.minDate),
|
|
@@ -47,6 +47,7 @@ var DesktopDatePicker = /*#__PURE__*/React.forwardRef(function DesktopDatePicker
|
|
|
47
47
|
var _useDesktopPicker = useDesktopPicker({
|
|
48
48
|
props: props,
|
|
49
49
|
valueManager: singleItemValueManager,
|
|
50
|
+
valueType: 'date',
|
|
50
51
|
getOpenDialogAriaText: localeText.openDatePickerDialogue,
|
|
51
52
|
validator: validateDate
|
|
52
53
|
}),
|
|
@@ -142,6 +143,12 @@ DesktopDatePicker.propTypes = {
|
|
|
142
143
|
* Defaults to localized format based on the used `views`.
|
|
143
144
|
*/
|
|
144
145
|
format: PropTypes.string,
|
|
146
|
+
/**
|
|
147
|
+
* Density of the format when rendered in the input.
|
|
148
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
149
|
+
* @default "dense"
|
|
150
|
+
*/
|
|
151
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
145
152
|
/**
|
|
146
153
|
* Pass a ref to the `input` element.
|
|
147
154
|
*/
|
|
@@ -55,6 +55,7 @@ var DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTi
|
|
|
55
55
|
var _useDesktopPicker = useDesktopPicker({
|
|
56
56
|
props: props,
|
|
57
57
|
valueManager: singleItemValueManager,
|
|
58
|
+
valueType: 'date-time',
|
|
58
59
|
getOpenDialogAriaText: localeText.openDatePickerDialogue,
|
|
59
60
|
validator: validateDateTime
|
|
60
61
|
}),
|
|
@@ -165,6 +166,12 @@ DesktopDateTimePicker.propTypes = {
|
|
|
165
166
|
* Defaults to localized format based on the used `views`.
|
|
166
167
|
*/
|
|
167
168
|
format: PropTypes.string,
|
|
169
|
+
/**
|
|
170
|
+
* Density of the format when rendered in the input.
|
|
171
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
172
|
+
* @default "dense"
|
|
173
|
+
*/
|
|
174
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
168
175
|
/**
|
|
169
176
|
* Pass a ref to the `input` element.
|
|
170
177
|
*/
|
|
@@ -47,6 +47,7 @@ var DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePicker
|
|
|
47
47
|
var _useDesktopPicker = useDesktopPicker({
|
|
48
48
|
props: props,
|
|
49
49
|
valueManager: singleItemValueManager,
|
|
50
|
+
valueType: 'time',
|
|
50
51
|
getOpenDialogAriaText: localeText.openTimePickerDialogue,
|
|
51
52
|
validator: validateTime
|
|
52
53
|
}),
|
|
@@ -131,6 +132,12 @@ DesktopTimePicker.propTypes = {
|
|
|
131
132
|
* Defaults to localized format based on the used `views`.
|
|
132
133
|
*/
|
|
133
134
|
format: PropTypes.string,
|
|
135
|
+
/**
|
|
136
|
+
* Density of the format when rendered in the input.
|
|
137
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
138
|
+
* @default "dense"
|
|
139
|
+
*/
|
|
140
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
134
141
|
/**
|
|
135
142
|
* Pass a ref to the `input` element.
|
|
136
143
|
*/
|
|
@@ -87,7 +87,7 @@ process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
|
|
|
87
87
|
children: PropTypes.node,
|
|
88
88
|
/**
|
|
89
89
|
* Date library adapter class function.
|
|
90
|
-
* @see See the localization provider {@link https://mui.com/x/react-date-pickers/getting-started/#
|
|
90
|
+
* @see See the localization provider {@link https://mui.com/x/react-date-pickers/getting-started/#setup-your-date-library-adapter date adapter setup section} for more details.
|
|
91
91
|
*/
|
|
92
92
|
dateAdapter: PropTypes.func,
|
|
93
93
|
/**
|
|
@@ -44,6 +44,7 @@ var MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker(i
|
|
|
44
44
|
var _useMobilePicker = useMobilePicker({
|
|
45
45
|
props: props,
|
|
46
46
|
valueManager: singleItemValueManager,
|
|
47
|
+
valueType: 'date',
|
|
47
48
|
getOpenDialogAriaText: localeText.openDatePickerDialogue,
|
|
48
49
|
validator: validateDate
|
|
49
50
|
}),
|
|
@@ -139,6 +140,12 @@ MobileDatePicker.propTypes = {
|
|
|
139
140
|
* Defaults to localized format based on the used `views`.
|
|
140
141
|
*/
|
|
141
142
|
format: PropTypes.string,
|
|
143
|
+
/**
|
|
144
|
+
* Density of the format when rendered in the input.
|
|
145
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
146
|
+
* @default "dense"
|
|
147
|
+
*/
|
|
148
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
142
149
|
/**
|
|
143
150
|
* Pass a ref to the `input` element.
|
|
144
151
|
*/
|
|
@@ -53,6 +53,7 @@ var MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTime
|
|
|
53
53
|
var _useMobilePicker = useMobilePicker({
|
|
54
54
|
props: props,
|
|
55
55
|
valueManager: singleItemValueManager,
|
|
56
|
+
valueType: 'date-time',
|
|
56
57
|
getOpenDialogAriaText: localeText.openDatePickerDialogue,
|
|
57
58
|
validator: validateDateTime
|
|
58
59
|
}),
|
|
@@ -163,6 +164,12 @@ MobileDateTimePicker.propTypes = {
|
|
|
163
164
|
* Defaults to localized format based on the used `views`.
|
|
164
165
|
*/
|
|
165
166
|
format: PropTypes.string,
|
|
167
|
+
/**
|
|
168
|
+
* Density of the format when rendered in the input.
|
|
169
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
170
|
+
* @default "dense"
|
|
171
|
+
*/
|
|
172
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
166
173
|
/**
|
|
167
174
|
* Pass a ref to the `input` element.
|
|
168
175
|
*/
|
|
@@ -46,6 +46,7 @@ var MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker(i
|
|
|
46
46
|
var _useMobilePicker = useMobilePicker({
|
|
47
47
|
props: props,
|
|
48
48
|
valueManager: singleItemValueManager,
|
|
49
|
+
valueType: 'time',
|
|
49
50
|
getOpenDialogAriaText: localeText.openTimePickerDialogue,
|
|
50
51
|
validator: validateTime
|
|
51
52
|
}),
|
|
@@ -130,6 +131,12 @@ MobileTimePicker.propTypes = {
|
|
|
130
131
|
* Defaults to localized format based on the used `views`.
|
|
131
132
|
*/
|
|
132
133
|
format: PropTypes.string,
|
|
134
|
+
/**
|
|
135
|
+
* Density of the format when rendered in the input.
|
|
136
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
137
|
+
* @default "dense"
|
|
138
|
+
*/
|
|
139
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
133
140
|
/**
|
|
134
141
|
* Pass a ref to the `input` element.
|
|
135
142
|
*/
|
|
@@ -40,8 +40,9 @@ var StaticDateTimePicker = /*#__PURE__*/React.forwardRef(function StaticDateTime
|
|
|
40
40
|
var _useStaticPicker = useStaticPicker({
|
|
41
41
|
props: props,
|
|
42
42
|
valueManager: singleItemValueManager,
|
|
43
|
-
|
|
44
|
-
validator: validateDateTime
|
|
43
|
+
valueType: 'date-time',
|
|
44
|
+
validator: validateDateTime,
|
|
45
|
+
ref: ref
|
|
45
46
|
}),
|
|
46
47
|
renderPicker = _useStaticPicker.renderPicker;
|
|
47
48
|
return renderPicker();
|
|
@@ -32,8 +32,9 @@ var StaticTimePicker = /*#__PURE__*/React.forwardRef(function StaticTimePicker(i
|
|
|
32
32
|
var _useStaticPicker = useStaticPicker({
|
|
33
33
|
props: props,
|
|
34
34
|
valueManager: singleItemValueManager,
|
|
35
|
-
|
|
36
|
-
validator: validateTime
|
|
35
|
+
valueType: 'time',
|
|
36
|
+
validator: validateTime,
|
|
37
|
+
ref: ref
|
|
37
38
|
}),
|
|
38
39
|
renderPicker = _useStaticPicker.renderPicker;
|
|
39
40
|
return renderPicker();
|
|
@@ -124,6 +124,12 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
124
124
|
* Format of the date when rendered in the input(s).
|
|
125
125
|
*/
|
|
126
126
|
format: PropTypes.string,
|
|
127
|
+
/**
|
|
128
|
+
* Density of the format when rendered in the input.
|
|
129
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
130
|
+
* @default "dense"
|
|
131
|
+
*/
|
|
132
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
127
133
|
/**
|
|
128
134
|
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
129
135
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "disableFuture", "disablePast", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
|
|
3
|
+
var _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';
|
|
@@ -23,6 +23,7 @@ export var useTimeField = function useTimeField(_ref) {
|
|
|
23
23
|
value = _useDefaultizedTimeFi.value,
|
|
24
24
|
defaultValue = _useDefaultizedTimeFi.defaultValue,
|
|
25
25
|
format = _useDefaultizedTimeFi.format,
|
|
26
|
+
formatDensity = _useDefaultizedTimeFi.formatDensity,
|
|
26
27
|
onChange = _useDefaultizedTimeFi.onChange,
|
|
27
28
|
readOnly = _useDefaultizedTimeFi.readOnly,
|
|
28
29
|
onError = _useDefaultizedTimeFi.onError,
|
|
@@ -46,6 +47,7 @@ export var useTimeField = function useTimeField(_ref) {
|
|
|
46
47
|
value: value,
|
|
47
48
|
defaultValue: defaultValue,
|
|
48
49
|
format: format,
|
|
50
|
+
formatDensity: formatDensity,
|
|
49
51
|
onChange: onChange,
|
|
50
52
|
readOnly: readOnly,
|
|
51
53
|
onError: onError,
|
|
@@ -115,6 +115,12 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
115
115
|
* Defaults to localized format based on the used `views`.
|
|
116
116
|
*/
|
|
117
117
|
format: PropTypes.string,
|
|
118
|
+
/**
|
|
119
|
+
* Density of the format when rendered in the input.
|
|
120
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
121
|
+
* @default "dense"
|
|
122
|
+
*/
|
|
123
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
118
124
|
/**
|
|
119
125
|
* Pass a ref to the `input` element.
|
|
120
126
|
*/
|
package/legacy/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["
|
|
5
|
-
_excluded2 = ["ownerState"]
|
|
4
|
+
var _excluded = ["props", "getOpenDialogAriaText"],
|
|
5
|
+
_excluded2 = ["ownerState"],
|
|
6
|
+
_excluded3 = ["ownerState"];
|
|
6
7
|
import * as React from 'react';
|
|
7
8
|
import { useSlotProps } from '@mui/base/utils';
|
|
8
9
|
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
@@ -25,14 +26,14 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
25
26
|
export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
26
27
|
var _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$inputAdornment, _slots$openPickerButt, _slots$layout;
|
|
27
28
|
var props = _ref.props,
|
|
28
|
-
valueManager = _ref.valueManager,
|
|
29
29
|
getOpenDialogAriaText = _ref.getOpenDialogAriaText,
|
|
30
|
-
|
|
30
|
+
pickerParams = _objectWithoutProperties(_ref, _excluded);
|
|
31
31
|
var slots = props.slots,
|
|
32
32
|
innerSlotProps = props.slotProps,
|
|
33
33
|
className = props.className,
|
|
34
34
|
sx = props.sx,
|
|
35
35
|
format = props.format,
|
|
36
|
+
formatDensity = props.formatDensity,
|
|
36
37
|
label = props.label,
|
|
37
38
|
inputRef = props.inputRef,
|
|
38
39
|
readOnly = props.readOnly,
|
|
@@ -44,15 +45,13 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
44
45
|
var containerRef = React.useRef(null);
|
|
45
46
|
var labelId = useId();
|
|
46
47
|
var isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
47
|
-
var _usePicker = usePicker({
|
|
48
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
48
49
|
props: props,
|
|
49
50
|
inputRef: internalInputRef,
|
|
50
|
-
valueManager: valueManager,
|
|
51
|
-
validator: validator,
|
|
52
51
|
autoFocusView: true,
|
|
53
52
|
additionalViewProps: {},
|
|
54
53
|
wrapperVariant: 'desktop'
|
|
55
|
-
}),
|
|
54
|
+
})),
|
|
56
55
|
open = _usePicker.open,
|
|
57
56
|
actions = _usePicker.actions,
|
|
58
57
|
hasUIView = _usePicker.hasUIView,
|
|
@@ -70,7 +69,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
70
69
|
ownerState: props
|
|
71
70
|
}),
|
|
72
71
|
inputAdornmentOwnerState = _useSlotProps.ownerState,
|
|
73
|
-
inputAdornmentProps = _objectWithoutProperties(_useSlotProps,
|
|
72
|
+
inputAdornmentProps = _objectWithoutProperties(_useSlotProps, _excluded2);
|
|
74
73
|
var OpenPickerButton = (_slots$openPickerButt = slots.openPickerButton) != null ? _slots$openPickerButt : IconButton;
|
|
75
74
|
var _useSlotProps2 = useSlotProps({
|
|
76
75
|
elementType: OpenPickerButton,
|
|
@@ -84,7 +83,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
84
83
|
ownerState: props
|
|
85
84
|
}),
|
|
86
85
|
openPickerButtonOwnerState = _useSlotProps2.ownerState,
|
|
87
|
-
openPickerButtonProps = _objectWithoutProperties(_useSlotProps2,
|
|
86
|
+
openPickerButtonProps = _objectWithoutProperties(_useSlotProps2, _excluded3);
|
|
88
87
|
var OpenPickerIcon = slots.openPickerIcon;
|
|
89
88
|
var Field = slots.field;
|
|
90
89
|
var fieldProps = useSlotProps({
|
|
@@ -98,6 +97,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
98
97
|
className: className,
|
|
99
98
|
sx: sx,
|
|
100
99
|
format: format,
|
|
100
|
+
formatDensity: formatDensity,
|
|
101
101
|
label: label,
|
|
102
102
|
autoFocus: autoFocus && !props.open
|
|
103
103
|
}),
|
|
@@ -320,7 +320,7 @@ var getEscapedPartsFromFormat = function getEscapedPartsFromFormat(utils, format
|
|
|
320
320
|
}
|
|
321
321
|
return escapedParts;
|
|
322
322
|
};
|
|
323
|
-
export var splitFormatIntoSections = function splitFormatIntoSections(utils, localeText, format, date) {
|
|
323
|
+
export var splitFormatIntoSections = function splitFormatIntoSections(utils, localeText, format, date, formatDensity) {
|
|
324
324
|
var startSeparator = '';
|
|
325
325
|
var sections = [];
|
|
326
326
|
var commitToken = function commitToken(token) {
|
|
@@ -396,8 +396,8 @@ export var splitFormatIntoSections = function splitFormatIntoSections(utils, loc
|
|
|
396
396
|
if (cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
|
397
397
|
cleanedSeparator = "\u2069".concat(cleanedSeparator, "\u2066");
|
|
398
398
|
}
|
|
399
|
-
if (
|
|
400
|
-
cleanedSeparator =
|
|
399
|
+
if (formatDensity === 'spacious' && ['/', '.', '-'].includes(cleanedSeparator)) {
|
|
400
|
+
cleanedSeparator = " ".concat(cleanedSeparator, " ");
|
|
401
401
|
}
|
|
402
402
|
return cleanedSeparator;
|
|
403
403
|
};
|
|
@@ -615,13 +615,28 @@ var transferDateSectionValue = function transferDateSectionValue(utils, section,
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
};
|
|
618
|
+
var reliableSectionModificationOrder = {
|
|
619
|
+
year: 1,
|
|
620
|
+
month: 2,
|
|
621
|
+
day: 3,
|
|
622
|
+
weekDay: 4,
|
|
623
|
+
hours: 5,
|
|
624
|
+
minutes: 6,
|
|
625
|
+
seconds: 7,
|
|
626
|
+
meridiem: 8
|
|
627
|
+
};
|
|
618
628
|
export var mergeDateIntoReferenceDate = function mergeDateIntoReferenceDate(utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) {
|
|
619
|
-
return
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
629
|
+
return (
|
|
630
|
+
// cloning sections before sort to avoid mutating it
|
|
631
|
+
_toConsumableArray(sections).sort(function (a, b) {
|
|
632
|
+
return reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type];
|
|
633
|
+
}).reduce(function (mergedDate, section) {
|
|
634
|
+
if (!shouldLimitToEditedSections || section.modified) {
|
|
635
|
+
return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);
|
|
636
|
+
}
|
|
637
|
+
return mergedDate;
|
|
638
|
+
}, referenceDate)
|
|
639
|
+
);
|
|
625
640
|
};
|
|
626
641
|
export var isAndroid = function isAndroid() {
|
|
627
642
|
return navigator.userAgent.toLowerCase().indexOf('android') > -1;
|
|
@@ -23,6 +23,8 @@ export var useFieldState = function useFieldState(params) {
|
|
|
23
23
|
defaultValue = _params$internalProps.defaultValue,
|
|
24
24
|
onChange = _params$internalProps.onChange,
|
|
25
25
|
format = _params$internalProps.format,
|
|
26
|
+
_params$internalProps2 = _params$internalProps.formatDensity,
|
|
27
|
+
formatDensity = _params$internalProps2 === void 0 ? 'dense' : _params$internalProps2,
|
|
26
28
|
selectedSectionsProp = _params$internalProps.selectedSections,
|
|
27
29
|
onSelectedSectionsChange = _params$internalProps.onSelectedSectionsChange;
|
|
28
30
|
var firstDefaultValue = React.useRef(defaultValue);
|
|
@@ -33,9 +35,9 @@ export var useFieldState = function useFieldState(params) {
|
|
|
33
35
|
var getSectionsFromValue = React.useCallback(function (value) {
|
|
34
36
|
var fallbackSections = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
35
37
|
return fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, isRTL, function (date) {
|
|
36
|
-
return splitFormatIntoSections(utils, localeText, format, date);
|
|
38
|
+
return splitFormatIntoSections(utils, localeText, format, date, formatDensity);
|
|
37
39
|
});
|
|
38
|
-
}, [fieldValueManager, format, localeText, isRTL, utils]);
|
|
40
|
+
}, [fieldValueManager, format, localeText, isRTL, utils, formatDensity]);
|
|
39
41
|
var placeholder = React.useMemo(function () {
|
|
40
42
|
return fieldValueManager.getValueStrFromSections(getSectionsFromValue(valueManager.emptyValue), isRTL);
|
|
41
43
|
}, [fieldValueManager, getSectionsFromValue, valueManager.emptyValue, isRTL]);
|
|
@@ -45,7 +47,7 @@ export var useFieldState = function useFieldState(params) {
|
|
|
45
47
|
return {
|
|
46
48
|
sections: sections,
|
|
47
49
|
value: valueFromTheOutside,
|
|
48
|
-
referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, valueManager.getTodayValue(utils)),
|
|
50
|
+
referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, valueManager.getTodayValue(utils, valueType)),
|
|
49
51
|
tempValueStrAndroid: null
|
|
50
52
|
};
|
|
51
53
|
}),
|
|
@@ -176,7 +178,7 @@ export var useFieldState = function useFieldState(params) {
|
|
|
176
178
|
if (date == null || !utils.isValid(date)) {
|
|
177
179
|
return null;
|
|
178
180
|
}
|
|
179
|
-
var sections = splitFormatIntoSections(utils, localeText, format, date);
|
|
181
|
+
var sections = splitFormatIntoSections(utils, localeText, format, date, formatDensity);
|
|
180
182
|
return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);
|
|
181
183
|
};
|
|
182
184
|
var newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["props", "getOpenDialogAriaText"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { useSlotProps } from '@mui/base/utils';
|
|
4
6
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -20,14 +22,14 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
20
22
|
export var useMobilePicker = function useMobilePicker(_ref) {
|
|
21
23
|
var _innerSlotProps$toolb, _innerSlotProps$toolb2, _slots$layout;
|
|
22
24
|
var props = _ref.props,
|
|
23
|
-
valueManager = _ref.valueManager,
|
|
24
25
|
getOpenDialogAriaText = _ref.getOpenDialogAriaText,
|
|
25
|
-
|
|
26
|
+
pickerParams = _objectWithoutProperties(_ref, _excluded);
|
|
26
27
|
var slots = props.slots,
|
|
27
28
|
innerSlotProps = props.slotProps,
|
|
28
29
|
className = props.className,
|
|
29
30
|
sx = props.sx,
|
|
30
31
|
format = props.format,
|
|
32
|
+
formatDensity = props.formatDensity,
|
|
31
33
|
label = props.label,
|
|
32
34
|
inputRef = props.inputRef,
|
|
33
35
|
readOnly = props.readOnly,
|
|
@@ -37,15 +39,13 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
37
39
|
var internalInputRef = React.useRef(null);
|
|
38
40
|
var labelId = useId();
|
|
39
41
|
var isToolbarHidden = (_innerSlotProps$toolb = innerSlotProps == null ? void 0 : (_innerSlotProps$toolb2 = innerSlotProps.toolbar) == null ? void 0 : _innerSlotProps$toolb2.hidden) != null ? _innerSlotProps$toolb : false;
|
|
40
|
-
var _usePicker = usePicker({
|
|
42
|
+
var _usePicker = usePicker(_extends({}, pickerParams, {
|
|
41
43
|
props: props,
|
|
42
44
|
inputRef: internalInputRef,
|
|
43
|
-
valueManager: valueManager,
|
|
44
|
-
validator: validator,
|
|
45
45
|
autoFocusView: true,
|
|
46
46
|
additionalViewProps: {},
|
|
47
47
|
wrapperVariant: 'mobile'
|
|
48
|
-
}),
|
|
48
|
+
})),
|
|
49
49
|
open = _usePicker.open,
|
|
50
50
|
actions = _usePicker.actions,
|
|
51
51
|
layoutProps = _usePicker.layoutProps,
|
|
@@ -66,6 +66,7 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
66
66
|
className: className,
|
|
67
67
|
sx: sx,
|
|
68
68
|
format: format,
|
|
69
|
+
formatDensity: formatDensity,
|
|
69
70
|
label: label
|
|
70
71
|
}),
|
|
71
72
|
ownerState: props
|
|
@@ -6,6 +6,7 @@ var warnRenderInputIsDefined = buildWarning(['The `renderInput` prop has been re
|
|
|
6
6
|
export var usePicker = function usePicker(_ref) {
|
|
7
7
|
var props = _ref.props,
|
|
8
8
|
valueManager = _ref.valueManager,
|
|
9
|
+
valueType = _ref.valueType,
|
|
9
10
|
wrapperVariant = _ref.wrapperVariant,
|
|
10
11
|
inputRef = _ref.inputRef,
|
|
11
12
|
additionalViewProps = _ref.additionalViewProps,
|
|
@@ -19,6 +20,7 @@ export var usePicker = function usePicker(_ref) {
|
|
|
19
20
|
var pickerValueResponse = usePickerValue({
|
|
20
21
|
props: props,
|
|
21
22
|
valueManager: valueManager,
|
|
23
|
+
valueType: valueType,
|
|
22
24
|
wrapperVariant: wrapperVariant,
|
|
23
25
|
validator: validator
|
|
24
26
|
});
|