@mui/x-date-pickers 6.1.0 → 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/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 +53 -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 +6 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/MobileDatePicker/MobileDatePicker.js +6 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/MobileTimePicker/MobileTimePicker.js +6 -0
- package/README.md +1 -0
- 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.js +2 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +1 -1
- package/internals/hooks/useField/useField.types.d.ts +6 -0
- package/internals/hooks/useField/useField.utils.d.ts +1 -1
- package/internals/hooks/useField/useField.utils.js +16 -4
- package/internals/hooks/useField/useFieldState.js +3 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +1 -1
- 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/usePickerValue.d.ts +3 -179
- package/internals/hooks/usePicker/usePickerValue.js +187 -153
- 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/index.d.ts +1 -1
- package/internals/models/props/basePickerProps.d.ts +6 -0
- 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 +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/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 +2 -0
- package/legacy/internals/hooks/useField/useField.utils.js +24 -9
- package/legacy/internals/hooks/useField/useFieldState.js +5 -3
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +184 -153
- package/legacy/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- 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/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 +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/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 +2 -0
- package/modern/internals/hooks/useField/useField.utils.js +16 -4
- package/modern/internals/hooks/useField/useFieldState.js +3 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +187 -153
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- 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 +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/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 +2 -0
- package/node/internals/hooks/useField/useField.utils.js +16 -4
- package/node/internals/hooks/useField/useFieldState.js +3 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +187 -152
- package/node/internals/hooks/usePicker/usePickerValue.types.js +5 -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 +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,119 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8
|
-
/* eslint-disable class-methods-use-this */
|
|
9
|
-
import defaultDayjs from 'dayjs';
|
|
10
|
-
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
11
|
-
import BaseAdapterDayjs from '@date-io/dayjs';
|
|
12
|
-
import { buildWarning } from '../internals/utils/warning';
|
|
13
|
-
var localeNotFoundWarning = buildWarning(['Your locale has not been found.', 'Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale', "Or you forget to import the locale with `require('dayjs/locale/{localeUsed}')`", 'fallback on English locale']);
|
|
14
|
-
var formatTokenMap = {
|
|
15
|
-
// Year
|
|
16
|
-
YY: 'year',
|
|
17
|
-
YYYY: 'year',
|
|
18
|
-
// Month
|
|
19
|
-
M: 'month',
|
|
20
|
-
MM: 'month',
|
|
21
|
-
MMM: {
|
|
22
|
-
sectionType: 'month',
|
|
23
|
-
contentType: 'letter'
|
|
24
|
-
},
|
|
25
|
-
MMMM: {
|
|
26
|
-
sectionType: 'month',
|
|
27
|
-
contentType: 'letter'
|
|
28
|
-
},
|
|
29
|
-
// Day of the month
|
|
30
|
-
D: 'day',
|
|
31
|
-
DD: 'day',
|
|
32
|
-
Do: 'day',
|
|
33
|
-
// Day of the week
|
|
34
|
-
d: 'weekDay',
|
|
35
|
-
dd: {
|
|
36
|
-
sectionType: 'weekDay',
|
|
37
|
-
contentType: 'letter'
|
|
38
|
-
},
|
|
39
|
-
ddd: {
|
|
40
|
-
sectionType: 'weekDay',
|
|
41
|
-
contentType: 'letter'
|
|
42
|
-
},
|
|
43
|
-
dddd: {
|
|
44
|
-
sectionType: 'weekDay',
|
|
45
|
-
contentType: 'letter'
|
|
46
|
-
},
|
|
47
|
-
// Meridiem
|
|
48
|
-
A: 'meridiem',
|
|
49
|
-
a: 'meridiem',
|
|
50
|
-
// Hours
|
|
51
|
-
H: 'hours',
|
|
52
|
-
HH: 'hours',
|
|
53
|
-
h: 'hours',
|
|
54
|
-
hh: 'hours',
|
|
55
|
-
// Minutes
|
|
56
|
-
m: 'minutes',
|
|
57
|
-
mm: 'minutes',
|
|
58
|
-
// Seconds
|
|
59
|
-
s: 'seconds',
|
|
60
|
-
ss: 'seconds'
|
|
61
|
-
};
|
|
62
|
-
export var AdapterDayjs = /*#__PURE__*/function (_BaseAdapterDayjs) {
|
|
63
|
-
_inherits(AdapterDayjs, _BaseAdapterDayjs);
|
|
64
|
-
var _super = _createSuper(AdapterDayjs);
|
|
65
|
-
function AdapterDayjs(options) {
|
|
66
|
-
var _this;
|
|
67
|
-
_classCallCheck(this, AdapterDayjs);
|
|
68
|
-
_this = _super.call(this, options);
|
|
69
|
-
_this.isMUIAdapter = true;
|
|
70
|
-
_this.formatTokenMap = formatTokenMap;
|
|
71
|
-
_this.escapedCharacters = {
|
|
72
|
-
start: '[',
|
|
73
|
-
end: ']'
|
|
74
|
-
};
|
|
75
|
-
_this.getLocaleFormats = function () {
|
|
76
|
-
var _this$rawDayJsInstanc;
|
|
77
|
-
var locales = (_this$rawDayJsInstanc = _this.rawDayJsInstance.Ls) != null ? _this$rawDayJsInstanc : defaultDayjs.Ls;
|
|
78
|
-
var locale = _this.locale || 'en';
|
|
79
|
-
var localeObject = locales[locale];
|
|
80
|
-
if (localeObject === undefined) {
|
|
81
|
-
localeNotFoundWarning();
|
|
82
|
-
localeObject = locales.en;
|
|
83
|
-
}
|
|
84
|
-
return localeObject.formats;
|
|
85
|
-
};
|
|
86
|
-
_this.is12HourCycleInCurrentLocale = function () {
|
|
87
|
-
/* istanbul ignore next */
|
|
88
|
-
return /A|a/.test(_this.getLocaleFormats().LT || '');
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* The current getFormatHelperText method uses an outdated format parsing logic.
|
|
92
|
-
* We should use this one in the future to support all localized formats.
|
|
93
|
-
*/
|
|
94
|
-
_this.expandFormat = function (format) {
|
|
95
|
-
var localeFormats = _this.getLocaleFormats();
|
|
96
|
-
|
|
97
|
-
// @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js
|
|
98
|
-
var t = function t(formatBis) {
|
|
99
|
-
return formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function (_, a, b) {
|
|
100
|
-
return a || b.slice(1);
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function (_, a, b) {
|
|
104
|
-
var B = b && b.toUpperCase();
|
|
105
|
-
return a || localeFormats[b] || t(localeFormats[B]);
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
// Redefined here just to show how it can be written using expandFormat
|
|
109
|
-
_this.getFormatHelperText = function (format) {
|
|
110
|
-
return _this.expandFormat(format).replace(/a/gi, '(a|p)m').toLocaleLowerCase();
|
|
111
|
-
};
|
|
112
|
-
_this.getWeekNumber = function (date) {
|
|
113
|
-
return date.week();
|
|
114
|
-
};
|
|
115
|
-
defaultDayjs.extend(weekOfYear);
|
|
116
|
-
return _this;
|
|
117
|
-
}
|
|
118
|
-
return _createClass(AdapterDayjs);
|
|
119
|
-
}(BaseAdapterDayjs);
|
|
1
|
+
export { AdapterDayjs } from './AdapterDayjs';
|
|
@@ -114,6 +114,12 @@ process.env.NODE_ENV !== "production" ? DateField.propTypes = {
|
|
|
114
114
|
* Format of the date when rendered in the input(s).
|
|
115
115
|
*/
|
|
116
116
|
format: PropTypes.string,
|
|
117
|
+
/**
|
|
118
|
+
* Density of the format when rendered in the input.
|
|
119
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
120
|
+
* @default "dense"
|
|
121
|
+
*/
|
|
122
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
117
123
|
/**
|
|
118
124
|
* Props applied to the [`FormHelperText`](/material-ui/api/form-helper-text/) element.
|
|
119
125
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
var _excluded = ["value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
3
|
+
var _excluded = ["value", "defaultValue", "format", "formatDensity", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
|
|
4
4
|
import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
|
|
5
5
|
import { useField } from '../internals/hooks/useField';
|
|
6
6
|
import { validateDate } from '../internals/hooks/validation/useDateValidation';
|
|
@@ -25,6 +25,7 @@ export var useDateField = function useDateField(_ref) {
|
|
|
25
25
|
value = _useDefaultizedDateFi.value,
|
|
26
26
|
defaultValue = _useDefaultizedDateFi.defaultValue,
|
|
27
27
|
format = _useDefaultizedDateFi.format,
|
|
28
|
+
formatDensity = _useDefaultizedDateFi.formatDensity,
|
|
28
29
|
onChange = _useDefaultizedDateFi.onChange,
|
|
29
30
|
readOnly = _useDefaultizedDateFi.readOnly,
|
|
30
31
|
onError = _useDefaultizedDateFi.onError,
|
|
@@ -46,6 +47,7 @@ export var useDateField = function useDateField(_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,
|
|
@@ -126,6 +126,12 @@ process.env.NODE_ENV !== "production" ? DatePicker.propTypes = {
|
|
|
126
126
|
* Defaults to localized format based on the used `views`.
|
|
127
127
|
*/
|
|
128
128
|
format: PropTypes.string,
|
|
129
|
+
/**
|
|
130
|
+
* Density of the format when rendered in the input.
|
|
131
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
132
|
+
* @default "dense"
|
|
133
|
+
*/
|
|
134
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
129
135
|
/**
|
|
130
136
|
* Pass a ref to the `input` element.
|
|
131
137
|
*/
|
|
@@ -124,6 +124,12 @@ process.env.NODE_ENV !== "production" ? DateTimeField.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", "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),
|
|
@@ -142,6 +142,12 @@ DesktopDatePicker.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
|
*/
|
|
@@ -165,6 +165,12 @@ DesktopDateTimePicker.propTypes = {
|
|
|
165
165
|
* Defaults to localized format based on the used `views`.
|
|
166
166
|
*/
|
|
167
167
|
format: PropTypes.string,
|
|
168
|
+
/**
|
|
169
|
+
* Density of the format when rendered in the input.
|
|
170
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
171
|
+
* @default "dense"
|
|
172
|
+
*/
|
|
173
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
168
174
|
/**
|
|
169
175
|
* Pass a ref to the `input` element.
|
|
170
176
|
*/
|
|
@@ -131,6 +131,12 @@ DesktopTimePicker.propTypes = {
|
|
|
131
131
|
* Defaults to localized format based on the used `views`.
|
|
132
132
|
*/
|
|
133
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']),
|
|
134
140
|
/**
|
|
135
141
|
* Pass a ref to the `input` element.
|
|
136
142
|
*/
|
|
@@ -139,6 +139,12 @@ MobileDatePicker.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
|
*/
|
|
@@ -163,6 +163,12 @@ MobileDateTimePicker.propTypes = {
|
|
|
163
163
|
* Defaults to localized format based on the used `views`.
|
|
164
164
|
*/
|
|
165
165
|
format: PropTypes.string,
|
|
166
|
+
/**
|
|
167
|
+
* Density of the format when rendered in the input.
|
|
168
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
169
|
+
* @default "dense"
|
|
170
|
+
*/
|
|
171
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
166
172
|
/**
|
|
167
173
|
* Pass a ref to the `input` element.
|
|
168
174
|
*/
|
|
@@ -130,6 +130,12 @@ MobileTimePicker.propTypes = {
|
|
|
130
130
|
* Defaults to localized format based on the used `views`.
|
|
131
131
|
*/
|
|
132
132
|
format: PropTypes.string,
|
|
133
|
+
/**
|
|
134
|
+
* Density of the format when rendered in the input.
|
|
135
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
136
|
+
* @default "dense"
|
|
137
|
+
*/
|
|
138
|
+
formatDensity: PropTypes.oneOf(['dense', 'spacious']),
|
|
133
139
|
/**
|
|
134
140
|
* Pass a ref to the `input` element.
|
|
135
141
|
*/
|
|
@@ -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
|
@@ -33,6 +33,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
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,
|
|
@@ -98,6 +99,7 @@ export var useDesktopPicker = function useDesktopPicker(_ref) {
|
|
|
98
99
|
className: className,
|
|
99
100
|
sx: sx,
|
|
100
101
|
format: format,
|
|
102
|
+
formatDensity: formatDensity,
|
|
101
103
|
label: label,
|
|
102
104
|
autoFocus: autoFocus && !props.open
|
|
103
105
|
}),
|
|
@@ -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]);
|
|
@@ -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);
|
|
@@ -28,6 +28,7 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
28
28
|
className = props.className,
|
|
29
29
|
sx = props.sx,
|
|
30
30
|
format = props.format,
|
|
31
|
+
formatDensity = props.formatDensity,
|
|
31
32
|
label = props.label,
|
|
32
33
|
inputRef = props.inputRef,
|
|
33
34
|
readOnly = props.readOnly,
|
|
@@ -66,6 +67,7 @@ export var useMobilePicker = function useMobilePicker(_ref) {
|
|
|
66
67
|
className: className,
|
|
67
68
|
sx: sx,
|
|
68
69
|
format: format,
|
|
70
|
+
formatDensity: formatDensity,
|
|
69
71
|
label: label
|
|
70
72
|
}),
|
|
71
73
|
ownerState: props
|