@mui/x-date-pickers 6.16.1 → 6.16.2
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.js +6 -4
- package/AdapterMoment/AdapterMoment.js +2 -5
- package/CHANGELOG.md +104 -0
- package/DateField/DateField.d.ts +10 -0
- package/DateField/DateField.js +10 -0
- package/DateTimeField/DateTimeField.d.ts +10 -0
- package/DateTimeField/DateTimeField.js +10 -0
- package/DateTimePicker/DateTimePicker.d.ts +10 -0
- package/DateTimePicker/DateTimePicker.js +15 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +10 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +25 -7
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +4 -3
- package/DesktopTimePicker/DesktopTimePicker.d.ts +10 -0
- package/DesktopTimePicker/DesktopTimePicker.js +18 -9
- package/DigitalClock/DigitalClock.js +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +10 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +10 -0
- package/MobileTimePicker/MobileTimePicker.d.ts +10 -0
- package/MobileTimePicker/MobileTimePicker.js +10 -0
- package/StaticDateTimePicker/StaticDateTimePicker.d.ts +10 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +10 -0
- package/StaticTimePicker/StaticTimePicker.d.ts +10 -0
- package/StaticTimePicker/StaticTimePicker.js +10 -0
- package/TimeField/TimeField.d.ts +10 -0
- package/TimeField/TimeField.js +10 -0
- package/TimePicker/TimePicker.d.ts +10 -0
- package/TimePicker/TimePicker.js +10 -0
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +2 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +52 -33
- package/index.js +1 -1
- package/internals/components/FakeTextField/FakeTextField.d.ts +7 -0
- package/internals/components/FakeTextField/FakeTextField.js +19 -0
- package/internals/components/FakeTextField/index.d.ts +1 -0
- package/internals/components/FakeTextField/index.js +1 -0
- package/internals/utils/date-time-utils.d.ts +11 -0
- package/internals/utils/date-time-utils.js +32 -2
- package/legacy/AdapterDayjs/AdapterDayjs.js +6 -4
- package/legacy/AdapterMoment/AdapterMoment.js +2 -5
- package/legacy/DateField/DateField.js +10 -0
- package/legacy/DateTimeField/DateTimeField.js +10 -0
- package/legacy/DateTimePicker/DateTimePicker.js +15 -0
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +24 -8
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +19 -10
- package/legacy/DigitalClock/DigitalClock.js +1 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +10 -0
- package/legacy/MobileTimePicker/MobileTimePicker.js +10 -0
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +10 -0
- package/legacy/StaticTimePicker/StaticTimePicker.js +10 -0
- package/legacy/TimeField/TimeField.js +10 -0
- package/legacy/TimePicker/TimePicker.js +10 -0
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +51 -33
- package/legacy/index.js +1 -1
- package/legacy/internals/components/FakeTextField/FakeTextField.js +19 -0
- package/legacy/internals/components/FakeTextField/index.js +1 -0
- package/legacy/internals/utils/date-time-utils.js +34 -2
- package/legacy/locales/esES.js +1 -1
- package/locales/esES.js +1 -1
- package/modern/AdapterDayjs/AdapterDayjs.js +6 -4
- package/modern/AdapterMoment/AdapterMoment.js +2 -5
- package/modern/DateField/DateField.js +10 -0
- package/modern/DateTimeField/DateTimeField.js +10 -0
- package/modern/DateTimePicker/DateTimePicker.js +15 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +25 -7
- package/modern/DesktopTimePicker/DesktopTimePicker.js +17 -8
- package/modern/DigitalClock/DigitalClock.js +1 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +10 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +10 -0
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +10 -0
- package/modern/StaticTimePicker/StaticTimePicker.js +10 -0
- package/modern/TimeField/TimeField.js +10 -0
- package/modern/TimePicker/TimePicker.js +10 -0
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +52 -33
- package/modern/index.js +1 -1
- package/modern/internals/components/FakeTextField/FakeTextField.js +19 -0
- package/modern/internals/components/FakeTextField/index.js +1 -0
- package/modern/internals/utils/date-time-utils.js +29 -2
- package/modern/locales/esES.js +1 -1
- package/node/AdapterDayjs/AdapterDayjs.js +6 -4
- package/node/AdapterMoment/AdapterMoment.js +2 -5
- package/node/DateField/DateField.js +10 -0
- package/node/DateTimeField/DateTimeField.js +10 -0
- package/node/DateTimePicker/DateTimePicker.js +15 -0
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +24 -6
- package/node/DesktopTimePicker/DesktopTimePicker.js +17 -8
- package/node/DigitalClock/DigitalClock.js +1 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +10 -0
- package/node/MobileTimePicker/MobileTimePicker.js +10 -0
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +10 -0
- package/node/StaticTimePicker/StaticTimePicker.js +10 -0
- package/node/TimeField/TimeField.js +10 -0
- package/node/TimePicker/TimePicker.js +10 -0
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +51 -32
- package/node/index.js +1 -1
- package/node/internals/components/FakeTextField/FakeTextField.js +27 -0
- package/node/internals/components/FakeTextField/index.js +12 -0
- package/node/internals/utils/date-time-utils.js +29 -1
- package/node/locales/esES.js +1 -1
- package/package.json +1 -1
|
@@ -4,10 +4,13 @@ import * as React from 'react';
|
|
|
4
4
|
import Divider from '@mui/material/Divider';
|
|
5
5
|
import { resolveComponentProps } from '@mui/base/utils';
|
|
6
6
|
import { DateCalendar } from '../DateCalendar';
|
|
7
|
-
import {
|
|
7
|
+
import { multiSectionDigitalClockSectionClasses } from '../MultiSectionDigitalClock';
|
|
8
8
|
import { DateTimeViewWrapper } from '../internals/components/DateTimeViewWrapper';
|
|
9
9
|
import { isInternalTimeView } from '../internals/utils/time-utils';
|
|
10
10
|
import { isDatePickerView } from '../internals/utils/date-utils';
|
|
11
|
+
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from '../timeViewRenderers';
|
|
12
|
+
import { digitalClockClasses } from '../DigitalClock';
|
|
13
|
+
import { VIEW_HEIGHT } from '../internals/constants/dimensions';
|
|
11
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
16
|
export var renderDesktopDateTimeView = function renderDesktopDateTimeView(_ref) {
|
|
@@ -61,8 +64,41 @@ export var renderDesktopDateTimeView = function renderDesktopDateTimeView(_ref)
|
|
|
61
64
|
disableIgnoringDatePartForTimeValidation = _ref.disableIgnoringDatePartForTimeValidation,
|
|
62
65
|
timeSteps = _ref.timeSteps,
|
|
63
66
|
skipDisabled = _ref.skipDisabled,
|
|
64
|
-
timeViewsCount = _ref.timeViewsCount
|
|
67
|
+
timeViewsCount = _ref.timeViewsCount,
|
|
68
|
+
shouldRenderTimeInASingleColumn = _ref.shouldRenderTimeInASingleColumn;
|
|
65
69
|
var isActionBarVisible = !!((_resolveComponentProp = resolveComponentProps((_slotProps$actionBar = slotProps == null ? void 0 : slotProps.actionBar) != null ? _slotProps$actionBar : componentsProps == null ? void 0 : componentsProps.actionBar, {})) != null && (_resolveComponentProp = _resolveComponentProp.actions) != null && _resolveComponentProp.length);
|
|
70
|
+
var commonTimeProps = {
|
|
71
|
+
view: isInternalTimeView(view) ? view : 'hours',
|
|
72
|
+
onViewChange: onViewChange,
|
|
73
|
+
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
74
|
+
onFocusedViewChange: onFocusedViewChange,
|
|
75
|
+
views: views.filter(isInternalTimeView),
|
|
76
|
+
value: value,
|
|
77
|
+
defaultValue: defaultValue,
|
|
78
|
+
referenceDate: referenceDate,
|
|
79
|
+
onChange: onChange,
|
|
80
|
+
className: className,
|
|
81
|
+
classes: classes,
|
|
82
|
+
disableFuture: disableFuture,
|
|
83
|
+
disablePast: disablePast,
|
|
84
|
+
minTime: minTime,
|
|
85
|
+
maxTime: maxTime,
|
|
86
|
+
shouldDisableTime: shouldDisableTime,
|
|
87
|
+
shouldDisableClock: shouldDisableClock,
|
|
88
|
+
minutesStep: minutesStep,
|
|
89
|
+
ampm: ampm,
|
|
90
|
+
components: components,
|
|
91
|
+
componentsProps: componentsProps,
|
|
92
|
+
slots: slots,
|
|
93
|
+
slotProps: slotProps,
|
|
94
|
+
readOnly: readOnly,
|
|
95
|
+
disabled: disabled,
|
|
96
|
+
autoFocus: autoFocus,
|
|
97
|
+
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
98
|
+
timeSteps: timeSteps,
|
|
99
|
+
skipDisabled: skipDisabled,
|
|
100
|
+
timezone: timezone
|
|
101
|
+
};
|
|
66
102
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
67
103
|
children: [/*#__PURE__*/_jsxs(DateTimeViewWrapper, {
|
|
68
104
|
children: [/*#__PURE__*/_jsx(DateCalendar, {
|
|
@@ -109,44 +145,26 @@ export var renderDesktopDateTimeView = function renderDesktopDateTimeView(_ref)
|
|
|
109
145
|
}), timeViewsCount > 0 && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
110
146
|
children: [/*#__PURE__*/_jsx(Divider, {
|
|
111
147
|
orientation: "vertical"
|
|
112
|
-
}),
|
|
148
|
+
}), shouldRenderTimeInASingleColumn ? renderDigitalClockTimeView(_extends({}, commonTimeProps, {
|
|
149
|
+
view: 'hours',
|
|
150
|
+
views: ['hours'],
|
|
151
|
+
focusedView: focusedView && isInternalTimeView(focusedView) ? 'hours' : null,
|
|
152
|
+
sx: _extends(_defineProperty({
|
|
153
|
+
width: 'auto'
|
|
154
|
+
}, "&.".concat(digitalClockClasses.root), {
|
|
155
|
+
maxHeight: VIEW_HEIGHT
|
|
156
|
+
}), Array.isArray(sx) ? sx : [sx])
|
|
157
|
+
})) : renderMultiSectionDigitalClockTimeView(_extends({}, commonTimeProps, {
|
|
113
158
|
view: isInternalTimeView(view) ? view : 'hours',
|
|
114
|
-
onViewChange: onViewChange,
|
|
115
|
-
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
116
|
-
onFocusedViewChange: onFocusedViewChange,
|
|
117
159
|
views: views.filter(isInternalTimeView),
|
|
118
|
-
|
|
119
|
-
defaultValue: defaultValue,
|
|
120
|
-
referenceDate: referenceDate,
|
|
121
|
-
onChange: onChange,
|
|
122
|
-
className: className,
|
|
123
|
-
classes: classes,
|
|
124
|
-
disableFuture: disableFuture,
|
|
125
|
-
disablePast: disablePast,
|
|
126
|
-
minTime: minTime,
|
|
127
|
-
maxTime: maxTime,
|
|
128
|
-
shouldDisableTime: shouldDisableTime,
|
|
129
|
-
shouldDisableClock: shouldDisableClock,
|
|
130
|
-
minutesStep: minutesStep,
|
|
131
|
-
ampm: ampm,
|
|
132
|
-
components: components,
|
|
133
|
-
componentsProps: componentsProps,
|
|
134
|
-
slots: slots,
|
|
135
|
-
slotProps: slotProps,
|
|
136
|
-
readOnly: readOnly,
|
|
137
|
-
disabled: disabled,
|
|
160
|
+
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
138
161
|
sx: _extends(_defineProperty({
|
|
139
162
|
borderBottom: 0,
|
|
140
163
|
width: 'auto'
|
|
141
164
|
}, ".".concat(multiSectionDigitalClockSectionClasses.root), {
|
|
142
165
|
maxHeight: '100%'
|
|
143
|
-
}), Array.isArray(sx) ? sx : [sx])
|
|
144
|
-
|
|
145
|
-
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
146
|
-
timeSteps: timeSteps,
|
|
147
|
-
skipDisabled: skipDisabled,
|
|
148
|
-
timezone: timezone
|
|
149
|
-
})]
|
|
166
|
+
}), Array.isArray(sx) ? sx : [sx])
|
|
167
|
+
}))]
|
|
150
168
|
})]
|
|
151
169
|
}), isActionBarVisible && /*#__PURE__*/_jsx(Divider, {})]
|
|
152
170
|
});
|
package/legacy/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Stack from '@mui/material/Stack';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export function FakeTextField(props) {
|
|
6
|
+
var sections = props.sections;
|
|
7
|
+
return /*#__PURE__*/_jsx(Stack, {
|
|
8
|
+
direction: "row",
|
|
9
|
+
spacing: 1,
|
|
10
|
+
children: sections.map(function (section) {
|
|
11
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
12
|
+
children: [section.startSeparator, /*#__PURE__*/_jsx("input", {
|
|
13
|
+
value: section.value,
|
|
14
|
+
onChange: function onChange() {}
|
|
15
|
+
}), section.endSeparator]
|
|
16
|
+
});
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FakeTextField } from './FakeTextField';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
4
|
var _excluded = ["views", "format"];
|
|
4
|
-
import { resolveTimeFormat, isTimeView } from './time-utils';
|
|
5
|
+
import { resolveTimeFormat, isTimeView, isInternalTimeView } from './time-utils';
|
|
5
6
|
import { resolveDateFormat } from './date-utils';
|
|
6
7
|
export var resolveDateTimeFormat = function resolveDateTimeFormat(utils, _ref) {
|
|
7
8
|
var views = _ref.views,
|
|
@@ -36,4 +37,35 @@ export var resolveDateTimeFormat = function resolveDateTimeFormat(utils, _ref) {
|
|
|
36
37
|
views: dateViews
|
|
37
38
|
}, other), false);
|
|
38
39
|
return "".concat(dateFormat, " ").concat(timeFormat);
|
|
39
|
-
};
|
|
40
|
+
};
|
|
41
|
+
var resolveViews = function resolveViews(ampm, views, shouldUseSingleColumn) {
|
|
42
|
+
if (shouldUseSingleColumn) {
|
|
43
|
+
return views.filter(function (view) {
|
|
44
|
+
return !isInternalTimeView(view) || view === 'hours';
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return ampm ? [].concat(_toConsumableArray(views), ['meridiem']) : views;
|
|
48
|
+
};
|
|
49
|
+
var resolveShouldRenderTimeInASingleColumn = function resolveShouldRenderTimeInASingleColumn(timeSteps, threshold) {
|
|
50
|
+
var _timeSteps$hours, _timeSteps$minutes;
|
|
51
|
+
return 24 * 60 / (((_timeSteps$hours = timeSteps.hours) != null ? _timeSteps$hours : 1) * ((_timeSteps$minutes = timeSteps.minutes) != null ? _timeSteps$minutes : 5)) <= threshold;
|
|
52
|
+
};
|
|
53
|
+
export function resolveTimeViewsResponse(_ref2) {
|
|
54
|
+
var inThreshold = _ref2.thresholdToRenderTimeInASingleColumn,
|
|
55
|
+
ampm = _ref2.ampm,
|
|
56
|
+
inTimeSteps = _ref2.timeSteps,
|
|
57
|
+
views = _ref2.views;
|
|
58
|
+
var thresholdToRenderTimeInASingleColumn = inThreshold != null ? inThreshold : 24;
|
|
59
|
+
var timeSteps = _extends({
|
|
60
|
+
hours: 1,
|
|
61
|
+
minutes: 5,
|
|
62
|
+
seconds: 5
|
|
63
|
+
}, inTimeSteps);
|
|
64
|
+
var shouldRenderTimeInASingleColumn = resolveShouldRenderTimeInASingleColumn(timeSteps, thresholdToRenderTimeInASingleColumn);
|
|
65
|
+
return {
|
|
66
|
+
thresholdToRenderTimeInASingleColumn: thresholdToRenderTimeInASingleColumn,
|
|
67
|
+
timeSteps: timeSteps,
|
|
68
|
+
shouldRenderTimeInASingleColumn: shouldRenderTimeInASingleColumn,
|
|
69
|
+
views: resolveViews(ampm, views, shouldRenderTimeInASingleColumn)
|
|
70
|
+
};
|
|
71
|
+
}
|
package/legacy/locales/esES.js
CHANGED
|
@@ -68,7 +68,7 @@ var esESPickers = {
|
|
|
68
68
|
dateTableLabel: 'elige la hora',
|
|
69
69
|
// Field section placeholders
|
|
70
70
|
fieldYearPlaceholder: function fieldYearPlaceholder(params) {
|
|
71
|
-
return '
|
|
71
|
+
return 'A'.repeat(params.digitAmount);
|
|
72
72
|
},
|
|
73
73
|
fieldMonthPlaceholder: function fieldMonthPlaceholder(params) {
|
|
74
74
|
return params.contentType === 'letter' ? 'MMMM' : 'MM';
|
package/locales/esES.js
CHANGED
|
@@ -47,7 +47,7 @@ const esESPickers = {
|
|
|
47
47
|
timeTableLabel: 'elige la fecha',
|
|
48
48
|
dateTableLabel: 'elige la hora',
|
|
49
49
|
// Field section placeholders
|
|
50
|
-
fieldYearPlaceholder: params => '
|
|
50
|
+
fieldYearPlaceholder: params => 'A'.repeat(params.digitAmount),
|
|
51
51
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
|
|
52
52
|
fieldDayPlaceholder: () => 'DD',
|
|
53
53
|
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
|
|
@@ -295,13 +295,15 @@ export class AdapterDayjs {
|
|
|
295
295
|
return parsedValue.locale(this.locale);
|
|
296
296
|
};
|
|
297
297
|
this.getTimezone = value => {
|
|
298
|
-
if (this.hasUTCPlugin() && value.isUTC()) {
|
|
299
|
-
return 'UTC';
|
|
300
|
-
}
|
|
301
298
|
if (this.hasTimezonePlugin()) {
|
|
302
299
|
// @ts-ignore
|
|
303
300
|
const zone = value.$x?.$timezone;
|
|
304
|
-
|
|
301
|
+
if (zone) {
|
|
302
|
+
return zone;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (this.hasUTCPlugin() && value.isUTC()) {
|
|
306
|
+
return 'UTC';
|
|
305
307
|
}
|
|
306
308
|
return 'system';
|
|
307
309
|
};
|
|
@@ -239,16 +239,13 @@ export class AdapterMoment {
|
|
|
239
239
|
return this.createTZDate(value, timezone);
|
|
240
240
|
};
|
|
241
241
|
this.getTimezone = value => {
|
|
242
|
-
if (value.isUTC()) {
|
|
243
|
-
return 'UTC';
|
|
244
|
-
}
|
|
245
|
-
|
|
246
242
|
// @ts-ignore
|
|
247
243
|
// eslint-disable-next-line no-underscore-dangle
|
|
248
244
|
const zone = value._z?.name;
|
|
245
|
+
const defaultZone = value.isUTC() ? 'UTC' : 'system';
|
|
249
246
|
|
|
250
247
|
// @ts-ignore
|
|
251
|
-
return zone ?? this.moment.defaultZone?.name ??
|
|
248
|
+
return zone ?? this.moment.defaultZone?.name ?? defaultZone;
|
|
252
249
|
};
|
|
253
250
|
this.setTimezone = (value, timezone) => {
|
|
254
251
|
if (this.getTimezone(value) === timezone) {
|
|
@@ -12,6 +12,16 @@ import { refType } from '@mui/utils';
|
|
|
12
12
|
import { useDateField } from './useDateField';
|
|
13
13
|
import { useClearableField } from '../hooks';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Demos:
|
|
17
|
+
*
|
|
18
|
+
* - [DateField](http://mui.com/x/react-date-pickers/date-field/)
|
|
19
|
+
* - [Fields](https://mui.com/x/react-date-pickers/fields/)
|
|
20
|
+
*
|
|
21
|
+
* API:
|
|
22
|
+
*
|
|
23
|
+
* - [DateField API](https://mui.com/x/api/date-pickers/date-field/)
|
|
24
|
+
*/
|
|
15
25
|
const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref) {
|
|
16
26
|
const themeProps = useThemeProps({
|
|
17
27
|
props: inProps,
|
|
@@ -12,6 +12,16 @@ import { refType } from '@mui/utils';
|
|
|
12
12
|
import { useDateTimeField } from './useDateTimeField';
|
|
13
13
|
import { useClearableField } from '../hooks';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Demos:
|
|
17
|
+
*
|
|
18
|
+
* - [DateTimeField](http://mui.com/x/react-date-pickers/date-time-field/)
|
|
19
|
+
* - [Fields](https://mui.com/x/react-date-pickers/fields/)
|
|
20
|
+
*
|
|
21
|
+
* API:
|
|
22
|
+
*
|
|
23
|
+
* - [DateTimeField API](https://mui.com/x/api/date-pickers/date-time-field/)
|
|
24
|
+
*/
|
|
15
25
|
const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inProps, ref) {
|
|
16
26
|
const themeProps = useThemeProps({
|
|
17
27
|
props: inProps,
|
|
@@ -10,6 +10,16 @@ import { DesktopDateTimePicker } from '../DesktopDateTimePicker';
|
|
|
10
10
|
import { MobileDateTimePicker } from '../MobileDateTimePicker';
|
|
11
11
|
import { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from '../internals/utils/utils';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Demos:
|
|
15
|
+
*
|
|
16
|
+
* - [DateTimePicker](https://mui.com/x/react-date-pickers/date-time-picker/)
|
|
17
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
18
|
+
*
|
|
19
|
+
* API:
|
|
20
|
+
*
|
|
21
|
+
* - [DateTimePicker API](https://mui.com/x/api/date-pickers/date-time-picker/)
|
|
22
|
+
*/
|
|
13
23
|
const DateTimePicker = /*#__PURE__*/React.forwardRef(function DateTimePicker(inProps, ref) {
|
|
14
24
|
const props = useThemeProps({
|
|
15
25
|
props: inProps,
|
|
@@ -377,6 +387,11 @@ process.env.NODE_ENV !== "production" ? DateTimePicker.propTypes = {
|
|
|
377
387
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
378
388
|
*/
|
|
379
389
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
390
|
+
/**
|
|
391
|
+
* Amount of time options below or at which the single column time renderer is used.
|
|
392
|
+
* @default 24
|
|
393
|
+
*/
|
|
394
|
+
thresholdToRenderTimeInASingleColumn: PropTypes.number,
|
|
380
395
|
/**
|
|
381
396
|
* The time steps between two time unit options.
|
|
382
397
|
* For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
@@ -13,18 +13,29 @@ import { validateDateTime } from '../internals/utils/validation/validateDateTime
|
|
|
13
13
|
import { CalendarIcon } from '../icons';
|
|
14
14
|
import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
15
15
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
16
|
-
import { resolveDateTimeFormat } from '../internals/utils/date-time-utils';
|
|
16
|
+
import { resolveDateTimeFormat, resolveTimeViewsResponse } from '../internals/utils/date-time-utils';
|
|
17
|
+
/**
|
|
18
|
+
* Demos:
|
|
19
|
+
*
|
|
20
|
+
* - [DateTimePicker](https://mui.com/x/react-date-pickers/date-time-picker/)
|
|
21
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
22
|
+
*
|
|
23
|
+
* API:
|
|
24
|
+
*
|
|
25
|
+
* - [DesktopDateTimePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-picker/)
|
|
26
|
+
*/
|
|
17
27
|
const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimePicker(inProps, ref) {
|
|
18
28
|
const localeText = useLocaleText();
|
|
19
29
|
const utils = useUtils();
|
|
20
30
|
|
|
21
31
|
// Props with the default values common to all date time pickers
|
|
22
32
|
const defaultizedProps = useDateTimePickerDefaultizedProps(inProps, 'MuiDesktopDateTimePicker');
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
const {
|
|
34
|
+
shouldRenderTimeInASingleColumn,
|
|
35
|
+
thresholdToRenderTimeInASingleColumn,
|
|
36
|
+
views,
|
|
37
|
+
timeSteps
|
|
38
|
+
} = resolveTimeViewsResponse(defaultizedProps);
|
|
28
39
|
const shouldUseNewRenderer = !defaultizedProps.viewRenderers || Object.keys(defaultizedProps.viewRenderers).length === 0;
|
|
29
40
|
const viewRenderers =
|
|
30
41
|
// we can only ensure the expected two-column layout if none of the renderers are overridden
|
|
@@ -53,10 +64,12 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
53
64
|
const props = _extends({}, defaultizedProps, {
|
|
54
65
|
viewRenderers,
|
|
55
66
|
format: resolveDateTimeFormat(utils, defaultizedProps),
|
|
56
|
-
views
|
|
67
|
+
views,
|
|
57
68
|
yearsPerRow: defaultizedProps.yearsPerRow ?? 4,
|
|
58
69
|
ampmInClock,
|
|
59
70
|
timeSteps,
|
|
71
|
+
thresholdToRenderTimeInASingleColumn,
|
|
72
|
+
shouldRenderTimeInASingleColumn,
|
|
60
73
|
slots: _extends({
|
|
61
74
|
field: DateTimeField,
|
|
62
75
|
openPickerIcon: CalendarIcon
|
|
@@ -427,6 +440,11 @@ DesktopDateTimePicker.propTypes = {
|
|
|
427
440
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
428
441
|
*/
|
|
429
442
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
443
|
+
/**
|
|
444
|
+
* Amount of time options below or at which the single column time renderer is used.
|
|
445
|
+
* @default 24
|
|
446
|
+
*/
|
|
447
|
+
thresholdToRenderTimeInASingleColumn: PropTypes.number,
|
|
430
448
|
/**
|
|
431
449
|
* The time steps between two time unit options.
|
|
432
450
|
* For example, if `timeStep.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
|
|
@@ -13,19 +13,28 @@ import { useDesktopPicker } from '../internals/hooks/useDesktopPicker';
|
|
|
13
13
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
14
14
|
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from '../timeViewRenderers';
|
|
15
15
|
import { resolveTimeFormat } from '../internals/utils/time-utils';
|
|
16
|
+
import { resolveTimeViewsResponse } from '../internals/utils/date-time-utils';
|
|
17
|
+
/**
|
|
18
|
+
* Demos:
|
|
19
|
+
*
|
|
20
|
+
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
|
|
21
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
22
|
+
*
|
|
23
|
+
* API:
|
|
24
|
+
*
|
|
25
|
+
* - [DesktopTimePicker API](https://mui.com/x/api/date-pickers/desktop-time-picker/)
|
|
26
|
+
*/
|
|
16
27
|
const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePicker(inProps, ref) {
|
|
17
28
|
const localeText = useLocaleText();
|
|
18
29
|
const utils = useUtils();
|
|
19
30
|
|
|
20
31
|
// Props with the default values common to all time pickers
|
|
21
32
|
const defaultizedProps = useTimePickerDefaultizedProps(inProps, 'MuiDesktopTimePicker');
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, defaultizedProps.timeSteps);
|
|
28
|
-
const shouldRenderTimeInASingleColumn = 24 * 60 / (timeSteps.hours * timeSteps.minutes) <= thresholdToRenderTimeInASingleColumn;
|
|
33
|
+
const {
|
|
34
|
+
shouldRenderTimeInASingleColumn,
|
|
35
|
+
views: resolvedViews,
|
|
36
|
+
timeSteps
|
|
37
|
+
} = resolveTimeViewsResponse(defaultizedProps);
|
|
29
38
|
const renderTimeView = shouldRenderTimeInASingleColumn ? renderDigitalClockTimeView : renderMultiSectionDigitalClockTimeView;
|
|
30
39
|
const viewRenderers = _extends({
|
|
31
40
|
hours: renderTimeView,
|
|
@@ -37,7 +46,7 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
|
|
|
37
46
|
const actionBarActions = shouldRenderTimeInASingleColumn ? [] : ['accept'];
|
|
38
47
|
// Need to avoid adding the `meridiem` view when unexpected renderer is specified
|
|
39
48
|
const shouldHoursRendererContainMeridiemView = viewRenderers.hours?.name === renderMultiSectionDigitalClockTimeView.name;
|
|
40
|
-
const views =
|
|
49
|
+
const views = !shouldHoursRendererContainMeridiemView ? resolvedViews.filter(view => view !== 'meridiem') : resolvedViews;
|
|
41
50
|
|
|
42
51
|
// Props with the default values specific to the desktop variant
|
|
43
52
|
const props = _extends({}, defaultizedProps, {
|
|
@@ -152,7 +152,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
152
152
|
props,
|
|
153
153
|
timezone
|
|
154
154
|
});
|
|
155
|
-
const handleValueChange = useEventCallback(newValue => handleRawValueChange(newValue, 'finish'));
|
|
155
|
+
const handleValueChange = useEventCallback(newValue => handleRawValueChange(newValue, 'finish', 'hours'));
|
|
156
156
|
const {
|
|
157
157
|
setValueAndGoToNextView
|
|
158
158
|
} = useViews({
|
|
@@ -13,6 +13,16 @@ import { extractValidationProps } from '../internals/utils/validation/extractVal
|
|
|
13
13
|
import { renderDateViewCalendar } from '../dateViewRenderers';
|
|
14
14
|
import { renderTimeViewClock } from '../timeViewRenderers';
|
|
15
15
|
import { resolveDateTimeFormat } from '../internals/utils/date-time-utils';
|
|
16
|
+
/**
|
|
17
|
+
* Demos:
|
|
18
|
+
*
|
|
19
|
+
* - [DateTimePicker](https://mui.com/x/react-date-pickers/date-time-picker/)
|
|
20
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
21
|
+
*
|
|
22
|
+
* API:
|
|
23
|
+
*
|
|
24
|
+
* - [MobileDateTimePicker API](https://mui.com/x/api/date-pickers/mobile-date-time-picker/)
|
|
25
|
+
*/
|
|
16
26
|
const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTimePicker(inProps, ref) {
|
|
17
27
|
const localeText = useLocaleText();
|
|
18
28
|
const utils = useUtils();
|
|
@@ -12,6 +12,16 @@ import { useMobilePicker } from '../internals/hooks/useMobilePicker';
|
|
|
12
12
|
import { extractValidationProps } from '../internals/utils/validation/extractValidationProps';
|
|
13
13
|
import { renderTimeViewClock } from '../timeViewRenderers';
|
|
14
14
|
import { resolveTimeFormat } from '../internals/utils/time-utils';
|
|
15
|
+
/**
|
|
16
|
+
* Demos:
|
|
17
|
+
*
|
|
18
|
+
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
|
|
19
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
20
|
+
*
|
|
21
|
+
* API:
|
|
22
|
+
*
|
|
23
|
+
* - [MobileTimePicker API](https://mui.com/x/api/date-pickers/mobile-time-picker/)
|
|
24
|
+
*/
|
|
15
25
|
const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker(inProps, ref) {
|
|
16
26
|
const localeText = useLocaleText();
|
|
17
27
|
const utils = useUtils();
|
|
@@ -7,6 +7,16 @@ import { renderDateViewCalendar } from '../dateViewRenderers';
|
|
|
7
7
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
8
8
|
import { useStaticPicker } from '../internals/hooks/useStaticPicker';
|
|
9
9
|
import { validateDateTime } from '../internals/utils/validation/validateDateTime';
|
|
10
|
+
/**
|
|
11
|
+
* Demos:
|
|
12
|
+
*
|
|
13
|
+
* - [DateTimePicker](https://mui.com/x/react-date-pickers/date-time-picker/)
|
|
14
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
15
|
+
*
|
|
16
|
+
* API:
|
|
17
|
+
*
|
|
18
|
+
* - [StaticDateTimePicker API](https://mui.com/x/api/date-pickers/static-date-time-picker/)
|
|
19
|
+
*/
|
|
10
20
|
const StaticDateTimePicker = /*#__PURE__*/React.forwardRef(function StaticDateTimePicker(inProps, ref) {
|
|
11
21
|
const defaultizedProps = useDateTimePickerDefaultizedProps(inProps, 'MuiStaticDateTimePicker');
|
|
12
22
|
const displayStaticWrapperAs = defaultizedProps.displayStaticWrapperAs ?? 'mobile';
|
|
@@ -6,6 +6,16 @@ import { renderTimeViewClock } from '../timeViewRenderers';
|
|
|
6
6
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
7
7
|
import { useStaticPicker } from '../internals/hooks/useStaticPicker';
|
|
8
8
|
import { validateTime } from '../internals/utils/validation/validateTime';
|
|
9
|
+
/**
|
|
10
|
+
* Demos:
|
|
11
|
+
*
|
|
12
|
+
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
|
|
13
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
14
|
+
*
|
|
15
|
+
* API:
|
|
16
|
+
*
|
|
17
|
+
* - [StaticTimePicker API](https://mui.com/x/api/date-pickers/static-time-picker/)
|
|
18
|
+
*/
|
|
9
19
|
const StaticTimePicker = /*#__PURE__*/React.forwardRef(function StaticTimePicker(inProps, ref) {
|
|
10
20
|
const defaultizedProps = useTimePickerDefaultizedProps(inProps, 'MuiStaticTimePicker');
|
|
11
21
|
const displayStaticWrapperAs = defaultizedProps.displayStaticWrapperAs ?? 'mobile';
|
|
@@ -12,6 +12,16 @@ import { refType } from '@mui/utils';
|
|
|
12
12
|
import { useTimeField } from './useTimeField';
|
|
13
13
|
import { useClearableField } from '../hooks';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Demos:
|
|
17
|
+
*
|
|
18
|
+
* - [TimeField](http://mui.com/x/react-date-pickers/time-field/)
|
|
19
|
+
* - [Fields](https://mui.com/x/react-date-pickers/fields/)
|
|
20
|
+
*
|
|
21
|
+
* API:
|
|
22
|
+
*
|
|
23
|
+
* - [TimeField API](https://mui.com/x/api/date-pickers/time-field/)
|
|
24
|
+
*/
|
|
15
25
|
const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, ref) {
|
|
16
26
|
const themeProps = useThemeProps({
|
|
17
27
|
props: inProps,
|
|
@@ -10,6 +10,16 @@ import { DesktopTimePicker } from '../DesktopTimePicker';
|
|
|
10
10
|
import { MobileTimePicker } from '../MobileTimePicker';
|
|
11
11
|
import { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from '../internals/utils/utils';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Demos:
|
|
15
|
+
*
|
|
16
|
+
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
|
|
17
|
+
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
|
|
18
|
+
*
|
|
19
|
+
* API:
|
|
20
|
+
*
|
|
21
|
+
* - [TimePicker API](https://mui.com/x/api/date-pickers/time-picker/)
|
|
22
|
+
*/
|
|
13
23
|
const TimePicker = /*#__PURE__*/React.forwardRef(function TimePicker(inProps, ref) {
|
|
14
24
|
const props = useThemeProps({
|
|
15
25
|
props: inProps,
|