@mui/x-date-pickers 6.11.2 → 6.12.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/AdapterDateFns/AdapterDateFns.d.ts +2 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -2
- package/AdapterDayjs/AdapterDayjs.d.ts +2 -2
- package/AdapterLuxon/AdapterLuxon.d.ts +2 -2
- package/AdapterMoment/AdapterMoment.d.ts +2 -2
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +2 -2
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +2 -2
- package/CHANGELOG.md +158 -33
- package/DateCalendar/DateCalendar.js +3 -3
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/DayCalendar.js +2 -2
- package/DateField/DateField.js +0 -4
- package/DatePicker/DatePicker.js +6 -1
- package/DateTimeField/DateTimeField.js +0 -4
- package/DateTimePicker/DateTimePicker.js +6 -1
- package/DesktopDatePicker/DesktopDatePicker.js +6 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -1
- package/DesktopTimePicker/DesktopTimePicker.js +6 -1
- package/MobileDatePicker/MobileDatePicker.js +6 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +6 -1
- package/MobileTimePicker/MobileTimePicker.js +6 -1
- package/MonthCalendar/PickersMonth.js +1 -1
- package/StaticDatePicker/StaticDatePicker.js +6 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +6 -1
- package/StaticTimePicker/StaticTimePicker.js +6 -1
- package/TimeField/TimeField.js +0 -4
- package/TimePicker/TimePicker.js +6 -1
- package/YearCalendar/YearCalendar.js +5 -2
- package/dateTimeViewRenderers/dateTimeViewRenderers.d.ts +1 -1
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +3 -0
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.js +2 -0
- package/index.js +1 -1
- package/internals/components/PickersPopper.d.ts +5 -3
- package/internals/components/PickersPopper.js +58 -30
- package/internals/demo/DemoContainer.d.ts +8 -0
- package/internals/demo/DemoContainer.js +9 -0
- package/internals/hooks/useDefaultReduceAnimations.d.ts +1 -1
- package/internals/hooks/useDefaultReduceAnimations.js +7 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/useField.js +6 -6
- package/internals/hooks/useField/useField.utils.d.ts +0 -1
- package/internals/hooks/useField/useField.utils.js +0 -48
- package/internals/hooks/useField/useFieldState.js +5 -25
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.types.d.ts +3 -3
- package/internals/hooks/usePicker/usePickerValue.js +1 -1
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -6
- package/internals/hooks/usePicker/usePickerViews.js +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +1 -1
- package/internals/hooks/useValidation.d.ts +2 -4
- package/internals/hooks/useValueWithTimezone.js +2 -2
- package/internals/hooks/useViews.js +1 -1
- package/internals/models/props/basePickerProps.d.ts +1 -1
- package/legacy/DateCalendar/DateCalendar.js +3 -3
- package/legacy/DateCalendar/DayCalendar.js +2 -2
- package/legacy/DateField/DateField.js +0 -4
- package/legacy/DatePicker/DatePicker.js +6 -1
- package/legacy/DateTimeField/DateTimeField.js +0 -4
- package/legacy/DateTimePicker/DateTimePicker.js +6 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +6 -1
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -1
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +6 -1
- package/legacy/MobileDatePicker/MobileDatePicker.js +6 -1
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +6 -1
- package/legacy/MobileTimePicker/MobileTimePicker.js +6 -1
- package/legacy/MonthCalendar/PickersMonth.js +1 -1
- package/legacy/StaticDatePicker/StaticDatePicker.js +6 -1
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +6 -1
- package/legacy/StaticTimePicker/StaticTimePicker.js +6 -1
- package/legacy/TimeField/TimeField.js +0 -4
- package/legacy/TimePicker/TimePicker.js +6 -1
- package/legacy/YearCalendar/YearCalendar.js +5 -2
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +3 -0
- package/legacy/dateViewRenderers/dateViewRenderers.js +2 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersPopper.js +54 -30
- package/legacy/internals/demo/DemoContainer.js +9 -0
- package/legacy/internals/hooks/useDefaultReduceAnimations.js +7 -2
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/legacy/internals/hooks/useField/useField.js +6 -6
- package/legacy/internals/hooks/useField/useField.utils.js +0 -52
- package/legacy/internals/hooks/useField/useFieldState.js +4 -24
- package/legacy/internals/hooks/usePicker/usePickerValue.js +1 -1
- package/legacy/internals/hooks/usePicker/usePickerViews.js +1 -1
- package/legacy/internals/hooks/useValueWithTimezone.js +2 -2
- package/legacy/internals/hooks/useViews.js +1 -1
- package/legacy/tests/describeValue/testControlledUnControlled.js +1 -1
- package/legacy/timeViewRenderers/timeViewRenderers.js +6 -0
- package/models/adapters.d.ts +2 -1
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/DateField.js +0 -4
- package/modern/DatePicker/DatePicker.js +6 -1
- package/modern/DateTimeField/DateTimeField.js +0 -4
- package/modern/DateTimePicker/DateTimePicker.js +6 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +6 -1
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -1
- package/modern/DesktopTimePicker/DesktopTimePicker.js +6 -1
- package/modern/MobileDatePicker/MobileDatePicker.js +6 -1
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +6 -1
- package/modern/MobileTimePicker/MobileTimePicker.js +6 -1
- package/modern/StaticDatePicker/StaticDatePicker.js +6 -1
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +6 -1
- package/modern/StaticTimePicker/StaticTimePicker.js +6 -1
- package/modern/TimeField/TimeField.js +0 -4
- package/modern/TimePicker/TimePicker.js +6 -1
- package/modern/YearCalendar/YearCalendar.js +4 -1
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +3 -0
- package/modern/dateViewRenderers/dateViewRenderers.js +2 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersPopper.js +56 -28
- package/modern/internals/demo/DemoContainer.js +9 -0
- package/modern/internals/hooks/useDefaultReduceAnimations.js +7 -2
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/modern/internals/hooks/useField/useField.utils.js +0 -48
- package/modern/internals/hooks/useField/useFieldState.js +4 -24
- package/modern/timeViewRenderers/timeViewRenderers.js +6 -0
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateField/DateField.js +0 -4
- package/node/DatePicker/DatePicker.js +6 -1
- package/node/DateTimeField/DateTimeField.js +0 -4
- package/node/DateTimePicker/DateTimePicker.js +6 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +6 -1
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -1
- package/node/DesktopTimePicker/DesktopTimePicker.js +6 -1
- package/node/MobileDatePicker/MobileDatePicker.js +6 -1
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +6 -1
- package/node/MobileTimePicker/MobileTimePicker.js +6 -1
- package/node/StaticDatePicker/StaticDatePicker.js +6 -1
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +6 -1
- package/node/StaticTimePicker/StaticTimePicker.js +6 -1
- package/node/TimeField/TimeField.js +0 -4
- package/node/TimePicker/TimePicker.js +6 -1
- package/node/YearCalendar/YearCalendar.js +4 -1
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +3 -0
- package/node/dateViewRenderers/dateViewRenderers.js +2 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickersPopper.js +56 -28
- package/node/internals/demo/DemoContainer.js +9 -0
- package/node/internals/hooks/useDefaultReduceAnimations.js +9 -4
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/node/internals/hooks/useField/useField.utils.js +1 -50
- package/node/internals/hooks/useField/useFieldState.js +3 -23
- package/node/timeViewRenderers/timeViewRenderers.js +6 -0
- package/package.json +3 -3
- package/tests/describeValue/testControlledUnControlled.js +1 -1
- package/timeViewRenderers/timeViewRenderers.d.ts +3 -3
- package/timeViewRenderers/timeViewRenderers.js +6 -0
|
@@ -211,9 +211,14 @@ StaticDatePicker.propTypes = {
|
|
|
211
211
|
readOnly: _propTypes.default.bool,
|
|
212
212
|
/**
|
|
213
213
|
* If `true`, disable heavy animations.
|
|
214
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
214
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
215
215
|
*/
|
|
216
216
|
reduceAnimations: _propTypes.default.bool,
|
|
217
|
+
/**
|
|
218
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
219
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
220
|
+
*/
|
|
221
|
+
referenceDate: _propTypes.default.any,
|
|
217
222
|
/**
|
|
218
223
|
* Component displaying when passed `loading` true.
|
|
219
224
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -259,9 +259,14 @@ StaticDateTimePicker.propTypes = {
|
|
|
259
259
|
readOnly: _propTypes.default.bool,
|
|
260
260
|
/**
|
|
261
261
|
* If `true`, disable heavy animations.
|
|
262
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
262
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
263
263
|
*/
|
|
264
264
|
reduceAnimations: _propTypes.default.bool,
|
|
265
|
+
/**
|
|
266
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
267
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
268
|
+
*/
|
|
269
|
+
referenceDate: _propTypes.default.any,
|
|
265
270
|
/**
|
|
266
271
|
* Component displaying when passed `loading` true.
|
|
267
272
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -186,9 +186,14 @@ StaticTimePicker.propTypes = {
|
|
|
186
186
|
readOnly: _propTypes.default.bool,
|
|
187
187
|
/**
|
|
188
188
|
* If `true`, disable heavy animations.
|
|
189
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
189
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
190
190
|
*/
|
|
191
191
|
reduceAnimations: _propTypes.default.bool,
|
|
192
|
+
/**
|
|
193
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
194
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
195
|
+
*/
|
|
196
|
+
referenceDate: _propTypes.default.any,
|
|
192
197
|
/**
|
|
193
198
|
* Disable specific clock time.
|
|
194
199
|
* @param {number} clockValue The value to check.
|
|
@@ -234,10 +234,6 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
234
234
|
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
235
235
|
*/
|
|
236
236
|
onChange: _propTypes.default.func,
|
|
237
|
-
/**
|
|
238
|
-
* @ignore
|
|
239
|
-
*/
|
|
240
|
-
onClick: _propTypes.default.func,
|
|
241
237
|
/**
|
|
242
238
|
* Callback fired when the error associated to the current value changes.
|
|
243
239
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
@@ -225,9 +225,14 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
225
225
|
readOnly: _propTypes.default.bool,
|
|
226
226
|
/**
|
|
227
227
|
* If `true`, disable heavy animations.
|
|
228
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
228
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
229
229
|
*/
|
|
230
230
|
reduceAnimations: _propTypes.default.bool,
|
|
231
|
+
/**
|
|
232
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
233
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
234
|
+
*/
|
|
235
|
+
referenceDate: _propTypes.default.any,
|
|
231
236
|
/**
|
|
232
237
|
* The currently selected sections.
|
|
233
238
|
* This prop accept four formats:
|
|
@@ -60,7 +60,10 @@ const YearCalendarRoot = (0, _styles.styled)('div', {
|
|
|
60
60
|
height: '100%',
|
|
61
61
|
padding: '0 4px',
|
|
62
62
|
width: 320,
|
|
63
|
-
maxHeight: 304
|
|
63
|
+
maxHeight: 304,
|
|
64
|
+
// avoid padding increasing width over defined
|
|
65
|
+
boxSizing: 'border-box',
|
|
66
|
+
position: 'relative'
|
|
64
67
|
});
|
|
65
68
|
const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(inProps, ref) {
|
|
66
69
|
const props = useYearCalendarDefaultizedProps(inProps, 'MuiYearCalendar');
|
|
@@ -25,6 +25,7 @@ const renderDesktopDateTimeView = ({
|
|
|
25
25
|
onFocusedViewChange,
|
|
26
26
|
value,
|
|
27
27
|
defaultValue,
|
|
28
|
+
referenceDate,
|
|
28
29
|
onChange,
|
|
29
30
|
className,
|
|
30
31
|
classes,
|
|
@@ -79,6 +80,7 @@ const renderDesktopDateTimeView = ({
|
|
|
79
80
|
onFocusedViewChange: onFocusedViewChange,
|
|
80
81
|
value: value,
|
|
81
82
|
defaultValue: defaultValue,
|
|
83
|
+
referenceDate: referenceDate,
|
|
82
84
|
onChange: onChange,
|
|
83
85
|
className: className,
|
|
84
86
|
classes: classes,
|
|
@@ -122,6 +124,7 @@ const renderDesktopDateTimeView = ({
|
|
|
122
124
|
views: views.filter(_timeUtils.isInternalTimeView),
|
|
123
125
|
value: value,
|
|
124
126
|
defaultValue: defaultValue,
|
|
127
|
+
referenceDate: referenceDate,
|
|
125
128
|
onChange: onChange,
|
|
126
129
|
className: className,
|
|
127
130
|
classes: classes,
|
|
@@ -18,6 +18,7 @@ const renderDateViewCalendar = ({
|
|
|
18
18
|
onFocusedViewChange,
|
|
19
19
|
value,
|
|
20
20
|
defaultValue,
|
|
21
|
+
referenceDate,
|
|
21
22
|
onChange,
|
|
22
23
|
className,
|
|
23
24
|
classes,
|
|
@@ -58,6 +59,7 @@ const renderDateViewCalendar = ({
|
|
|
58
59
|
onFocusedViewChange: onFocusedViewChange,
|
|
59
60
|
value: value,
|
|
60
61
|
defaultValue: defaultValue,
|
|
62
|
+
referenceDate: referenceDate,
|
|
61
63
|
onChange: onChange,
|
|
62
64
|
className: className,
|
|
63
65
|
classes: classes,
|
package/node/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.PickersPopper = PickersPopper;
|
|
8
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var React = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _utils = require("@mui/base/utils");
|
|
@@ -19,6 +20,7 @@ var _pickersPopperClasses = require("./pickersPopperClasses");
|
|
|
19
20
|
var _utils3 = require("../utils/utils");
|
|
20
21
|
var _useDefaultReduceAnimations = require("../hooks/useDefaultReduceAnimations");
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
const _excluded = ["PaperComponent", "popperPlacement", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
26
|
const useUtilityClasses = ownerState => {
|
|
@@ -47,9 +49,9 @@ const PickersPopperPaper = (0, _styles.styled)(_Paper.default, {
|
|
|
47
49
|
})(({
|
|
48
50
|
ownerState
|
|
49
51
|
}) => (0, _extends2.default)({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, ownerState.placement
|
|
52
|
+
outline: 0,
|
|
53
|
+
transformOrigin: 'top center'
|
|
54
|
+
}, ownerState.placement.includes('top') && {
|
|
53
55
|
transformOrigin: 'bottom center'
|
|
54
56
|
}));
|
|
55
57
|
function clickedRootScrollbar(event, doc) {
|
|
@@ -167,6 +169,47 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
167
169
|
}, [active, handleClickAway]);
|
|
168
170
|
return [nodeRef, handleSynthetic, handleSynthetic];
|
|
169
171
|
}
|
|
172
|
+
const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
173
|
+
const {
|
|
174
|
+
PaperComponent,
|
|
175
|
+
popperPlacement,
|
|
176
|
+
ownerState: inOwnerState,
|
|
177
|
+
children,
|
|
178
|
+
paperSlotProps,
|
|
179
|
+
paperClasses,
|
|
180
|
+
onPaperClick,
|
|
181
|
+
onPaperTouchStart
|
|
182
|
+
// picks up the style props provided by `Transition`
|
|
183
|
+
// https://mui.com/material-ui/transitions/#child-requirement
|
|
184
|
+
} = props,
|
|
185
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
186
|
+
const ownerState = (0, _extends2.default)({}, inOwnerState, {
|
|
187
|
+
placement: popperPlacement
|
|
188
|
+
});
|
|
189
|
+
const paperProps = (0, _utils.useSlotProps)({
|
|
190
|
+
elementType: PaperComponent,
|
|
191
|
+
externalSlotProps: paperSlotProps,
|
|
192
|
+
additionalProps: {
|
|
193
|
+
tabIndex: -1,
|
|
194
|
+
elevation: 8,
|
|
195
|
+
ref
|
|
196
|
+
},
|
|
197
|
+
className: paperClasses,
|
|
198
|
+
ownerState
|
|
199
|
+
});
|
|
200
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PaperComponent, (0, _extends2.default)({}, other, paperProps, {
|
|
201
|
+
onClick: event => {
|
|
202
|
+
onPaperClick(event);
|
|
203
|
+
paperProps.onClick?.(event);
|
|
204
|
+
},
|
|
205
|
+
onTouchStart: event => {
|
|
206
|
+
onPaperTouchStart(event);
|
|
207
|
+
paperProps.onTouchStart?.(event);
|
|
208
|
+
},
|
|
209
|
+
ownerState: ownerState,
|
|
210
|
+
children: children
|
|
211
|
+
}));
|
|
212
|
+
});
|
|
170
213
|
function PickersPopper(inProps) {
|
|
171
214
|
const props = (0, _styles.useThemeProps)({
|
|
172
215
|
props: inProps,
|
|
@@ -233,18 +276,6 @@ function PickersPopper(inProps) {
|
|
|
233
276
|
const Transition = slots?.desktopTransition ?? reduceAnimations ? _Fade.default : _Grow.default;
|
|
234
277
|
const TrapFocus = slots?.desktopTrapFocus ?? _Unstable_TrapFocus.default;
|
|
235
278
|
const Paper = slots?.desktopPaper ?? PickersPopperPaper;
|
|
236
|
-
const paperProps = (0, _utils.useSlotProps)({
|
|
237
|
-
elementType: Paper,
|
|
238
|
-
externalSlotProps: slotProps?.desktopPaper,
|
|
239
|
-
additionalProps: {
|
|
240
|
-
tabIndex: -1,
|
|
241
|
-
elevation: 8,
|
|
242
|
-
ref: handlePaperRef
|
|
243
|
-
},
|
|
244
|
-
className: classes.paper,
|
|
245
|
-
ownerState: {} // Is overridden below to use `placement
|
|
246
|
-
});
|
|
247
|
-
|
|
248
279
|
const Popper = slots?.popper ?? PickersPopperRoot;
|
|
249
280
|
const popperProps = (0, _utils.useSlotProps)({
|
|
250
281
|
elementType: Popper,
|
|
@@ -276,20 +307,17 @@ function PickersPopper(inProps) {
|
|
|
276
307
|
isEnabled: () => true
|
|
277
308
|
}, slotProps?.desktopTrapFocus, {
|
|
278
309
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Transition, (0, _extends2.default)({}, TransitionProps, slotProps?.desktopTransition, {
|
|
279
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
ownerState: (0, _extends2.default)({}, ownerState, {
|
|
289
|
-
placement: popperPlacement
|
|
290
|
-
}),
|
|
310
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersPopperPaperWrapper, {
|
|
311
|
+
PaperComponent: Paper,
|
|
312
|
+
ownerState: ownerState,
|
|
313
|
+
popperPlacement: popperPlacement,
|
|
314
|
+
ref: handlePaperRef,
|
|
315
|
+
onPaperClick: onPaperClick,
|
|
316
|
+
onPaperTouchStart: onPaperTouchStart,
|
|
317
|
+
paperClasses: classes.paper,
|
|
318
|
+
paperSlotProps: slotProps?.desktopPaper,
|
|
291
319
|
children: children
|
|
292
|
-
})
|
|
320
|
+
})
|
|
293
321
|
}))
|
|
294
322
|
}))
|
|
295
323
|
}));
|
|
@@ -41,6 +41,10 @@ const getSupportedSectionFromChildName = childName => {
|
|
|
41
41
|
}
|
|
42
42
|
return 'time';
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
46
|
+
* Please do not use it in your application.
|
|
47
|
+
*/
|
|
44
48
|
function DemoItem(props) {
|
|
45
49
|
const {
|
|
46
50
|
label,
|
|
@@ -71,6 +75,11 @@ function DemoItem(props) {
|
|
|
71
75
|
}), children]
|
|
72
76
|
});
|
|
73
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
81
|
+
* Please do not use it in your application.
|
|
82
|
+
*/
|
|
74
83
|
function DemoContainer(props) {
|
|
75
84
|
const {
|
|
76
85
|
children,
|
|
@@ -4,15 +4,20 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useDefaultReduceAnimations = exports.
|
|
7
|
+
exports.useDefaultReduceAnimations = exports.slowAnimationDevices = void 0;
|
|
8
8
|
var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
|
|
9
9
|
const PREFERS_REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
// detect if user agent has Android version < 10 or iOS version < 13
|
|
12
|
+
const mobileVersionMatches = typeof navigator !== 'undefined' && navigator.userAgent.match(/android\s(\d+)|OS\s(\d+)/i);
|
|
13
|
+
const androidVersion = mobileVersionMatches && mobileVersionMatches[1] ? parseInt(mobileVersionMatches[1], 10) : null;
|
|
14
|
+
const iOSVersion = mobileVersionMatches && mobileVersionMatches[2] ? parseInt(mobileVersionMatches[2], 10) : null;
|
|
15
|
+
const slowAnimationDevices = androidVersion && androidVersion < 10 || iOSVersion && iOSVersion < 13 || false;
|
|
16
|
+
exports.slowAnimationDevices = slowAnimationDevices;
|
|
12
17
|
const useDefaultReduceAnimations = () => {
|
|
13
18
|
const prefersReduced = (0, _useMediaQuery.default)(PREFERS_REDUCED_MOTION, {
|
|
14
19
|
defaultMatches: false
|
|
15
20
|
});
|
|
16
|
-
return prefersReduced ||
|
|
21
|
+
return prefersReduced || slowAnimationDevices;
|
|
17
22
|
};
|
|
18
23
|
exports.useDefaultReduceAnimations = useDefaultReduceAnimations;
|
|
@@ -88,7 +88,7 @@ const useDesktopPicker = _ref => {
|
|
|
88
88
|
externalSlotProps: innerSlotProps?.openPickerButton,
|
|
89
89
|
additionalProps: {
|
|
90
90
|
disabled: disabled || readOnly,
|
|
91
|
-
onClick: actions.onOpen,
|
|
91
|
+
onClick: open ? actions.onClose : actions.onOpen,
|
|
92
92
|
'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils),
|
|
93
93
|
edge: inputAdornmentProps.position
|
|
94
94
|
},
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.validateSections = exports.splitFormatIntoSections = exports.mergeDateIntoReferenceDate = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForInputFromSections = exports.cleanString = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.
|
|
7
|
+
exports.validateSections = exports.splitFormatIntoSections = exports.mergeDateIntoReferenceDate = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForInputFromSections = exports.cleanString = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.adjustSectionValue = exports.addPositionPropertiesToSections = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _dateUtils = require("../../utils/date-utils");
|
|
10
10
|
const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
|
|
@@ -670,55 +670,6 @@ const mergeDateIntoReferenceDate = (utils, timezone, dateToTransferFrom, section
|
|
|
670
670
|
exports.mergeDateIntoReferenceDate = mergeDateIntoReferenceDate;
|
|
671
671
|
const isAndroid = () => navigator.userAgent.toLowerCase().indexOf('android') > -1;
|
|
672
672
|
exports.isAndroid = isAndroid;
|
|
673
|
-
const clampDaySectionIfPossible = (utils, timezone, sections, sectionsValueBoundaries) => {
|
|
674
|
-
// We can only clamp the day value if:
|
|
675
|
-
// 1. if all the sections are filled (except the week day section which can be empty)
|
|
676
|
-
// 2. there is a day section
|
|
677
|
-
const canClamp = sections.every(section => section.type === 'weekDay' || section.value !== '') && sections.some(section => section.type === 'day');
|
|
678
|
-
if (!canClamp) {
|
|
679
|
-
return null;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// We try to generate a valid date representing the start of the month of the invalid date typed by the user.
|
|
683
|
-
const sectionsForStartOfMonth = sections.map(section => {
|
|
684
|
-
if (section.type !== 'day') {
|
|
685
|
-
return section;
|
|
686
|
-
}
|
|
687
|
-
const dayBoundaries = sectionsValueBoundaries.day({
|
|
688
|
-
currentDate: null,
|
|
689
|
-
format: section.format,
|
|
690
|
-
contentType: section.contentType
|
|
691
|
-
});
|
|
692
|
-
return (0, _extends2.default)({}, section, {
|
|
693
|
-
value: cleanDigitSectionValue(utils, timezone, dayBoundaries.minimum, dayBoundaries, section)
|
|
694
|
-
});
|
|
695
|
-
});
|
|
696
|
-
const startOfMonth = getDateFromDateSections(utils, sectionsForStartOfMonth);
|
|
697
|
-
|
|
698
|
-
// Even the start of the month is invalid, we probably have other invalid sections, the clamping failed.
|
|
699
|
-
if (startOfMonth == null || !utils.isValid(startOfMonth)) {
|
|
700
|
-
return null;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
// The only invalid section was the day of the month, we replace its value with the maximum boundary for the correct month.
|
|
704
|
-
return sections.map(section => {
|
|
705
|
-
if (section.type !== 'day') {
|
|
706
|
-
return section;
|
|
707
|
-
}
|
|
708
|
-
const dayBoundaries = sectionsValueBoundaries.day({
|
|
709
|
-
currentDate: startOfMonth,
|
|
710
|
-
format: section.format,
|
|
711
|
-
contentType: section.contentType
|
|
712
|
-
});
|
|
713
|
-
if (Number(section.value) <= dayBoundaries.maximum) {
|
|
714
|
-
return section;
|
|
715
|
-
}
|
|
716
|
-
return (0, _extends2.default)({}, section, {
|
|
717
|
-
value: dayBoundaries.maximum.toString()
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
};
|
|
721
|
-
exports.clampDaySectionIfPossible = clampDaySectionIfPossible;
|
|
722
673
|
const getSectionOrder = (sections, isRTL) => {
|
|
723
674
|
const neighbors = {};
|
|
724
675
|
if (!isRTL) {
|
|
@@ -218,21 +218,7 @@ const useFieldState = params => {
|
|
|
218
218
|
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
|
|
219
219
|
const newSections = setSectionValue(selectedSectionIndexes.startIndex, newSectionValue);
|
|
220
220
|
const newActiveDateSections = activeDateManager.getSections(newSections);
|
|
221
|
-
|
|
222
|
-
let shouldRegenSections = false;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* If the date is invalid,
|
|
226
|
-
* Then we can try to clamp the day section to see if that produces a valid date.
|
|
227
|
-
* This can be useful if the month has fewer days than the day value currently provided.
|
|
228
|
-
*/
|
|
229
|
-
if (!utils.isValid(newActiveDate)) {
|
|
230
|
-
const clampedSections = (0, _useField.clampDaySectionIfPossible)(utils, timezone, newActiveDateSections, sectionsValueBoundaries);
|
|
231
|
-
if (clampedSections != null) {
|
|
232
|
-
shouldRegenSections = true;
|
|
233
|
-
newActiveDate = (0, _useField.getDateFromDateSections)(utils, clampedSections);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
221
|
+
const newActiveDate = (0, _useField.getDateFromDateSections)(utils, newActiveDateSections);
|
|
236
222
|
let values;
|
|
237
223
|
let shouldPublish;
|
|
238
224
|
|
|
@@ -250,22 +236,16 @@ const useFieldState = params => {
|
|
|
250
236
|
shouldPublish = (newActiveDate != null && !utils.isValid(newActiveDate)) !== (activeDateManager.date != null && !utils.isValid(activeDateManager.date));
|
|
251
237
|
}
|
|
252
238
|
|
|
253
|
-
/**
|
|
254
|
-
* If the value has been modified (to clamp the day).
|
|
255
|
-
* Then we need to re-generate the sections to make sure they also have this change.
|
|
256
|
-
*/
|
|
257
|
-
const sections = shouldRegenSections ? getSectionsFromValue(values.value, state.sections) : newSections;
|
|
258
|
-
|
|
259
239
|
/**
|
|
260
240
|
* Publish or update the internal state with the new value and sections.
|
|
261
241
|
*/
|
|
262
242
|
if (shouldPublish) {
|
|
263
243
|
return publishValue((0, _extends2.default)({}, values, {
|
|
264
|
-
sections
|
|
244
|
+
sections: newSections
|
|
265
245
|
}));
|
|
266
246
|
}
|
|
267
247
|
return setState(prevState => (0, _extends2.default)({}, prevState, values, {
|
|
268
|
-
sections,
|
|
248
|
+
sections: newSections,
|
|
269
249
|
tempValueStrAndroid: null
|
|
270
250
|
}));
|
|
271
251
|
};
|
|
@@ -20,6 +20,7 @@ const renderTimeViewClock = ({
|
|
|
20
20
|
views,
|
|
21
21
|
value,
|
|
22
22
|
defaultValue,
|
|
23
|
+
referenceDate,
|
|
23
24
|
onChange,
|
|
24
25
|
className,
|
|
25
26
|
classes,
|
|
@@ -51,6 +52,7 @@ const renderTimeViewClock = ({
|
|
|
51
52
|
views: views.filter(_timeUtils.isTimeView),
|
|
52
53
|
value: value,
|
|
53
54
|
defaultValue: defaultValue,
|
|
55
|
+
referenceDate: referenceDate,
|
|
54
56
|
onChange: onChange,
|
|
55
57
|
className: className,
|
|
56
58
|
classes: classes,
|
|
@@ -84,6 +86,7 @@ const renderDigitalClockTimeView = ({
|
|
|
84
86
|
views,
|
|
85
87
|
value,
|
|
86
88
|
defaultValue,
|
|
89
|
+
referenceDate,
|
|
87
90
|
onChange,
|
|
88
91
|
className,
|
|
89
92
|
classes,
|
|
@@ -115,6 +118,7 @@ const renderDigitalClockTimeView = ({
|
|
|
115
118
|
views: views.filter(_timeUtils.isTimeView),
|
|
116
119
|
value: value,
|
|
117
120
|
defaultValue: defaultValue,
|
|
121
|
+
referenceDate: referenceDate,
|
|
118
122
|
onChange: onChange,
|
|
119
123
|
className: className,
|
|
120
124
|
classes: classes,
|
|
@@ -148,6 +152,7 @@ const renderMultiSectionDigitalClockTimeView = ({
|
|
|
148
152
|
views,
|
|
149
153
|
value,
|
|
150
154
|
defaultValue,
|
|
155
|
+
referenceDate,
|
|
151
156
|
onChange,
|
|
152
157
|
className,
|
|
153
158
|
classes,
|
|
@@ -179,6 +184,7 @@ const renderMultiSectionDigitalClockTimeView = ({
|
|
|
179
184
|
views: views.filter(_timeUtils.isTimeView),
|
|
180
185
|
value: value,
|
|
181
186
|
defaultValue: defaultValue,
|
|
187
|
+
referenceDate: referenceDate,
|
|
182
188
|
onChange: onChange,
|
|
183
189
|
className: className,
|
|
184
190
|
classes: classes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.12.1",
|
|
4
4
|
"description": "The community edition of the date picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"directory": "packages/x-date-pickers"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@babel/runtime": "^7.22.
|
|
37
|
-
"@mui/utils": "^5.14.
|
|
36
|
+
"@babel/runtime": "^7.22.11",
|
|
37
|
+
"@mui/utils": "^5.14.7",
|
|
38
38
|
"@types/react-transition-group": "^4.4.6",
|
|
39
39
|
"clsx": "^2.0.0",
|
|
40
40
|
"prop-types": "^15.8.1",
|
|
@@ -74,7 +74,7 @@ export const testControlledUnControlled = (ElementToTest, options) => {
|
|
|
74
74
|
const [value, setValue] = React.useState((props == null ? void 0 : props.value) || null);
|
|
75
75
|
const handleChange = React.useCallback(newValue => {
|
|
76
76
|
setValue(newValue);
|
|
77
|
-
props == null
|
|
77
|
+
props == null || props.onChange(newValue);
|
|
78
78
|
}, [props]);
|
|
79
79
|
return {
|
|
80
80
|
value,
|
|
@@ -11,6 +11,6 @@ export type TimeViewRendererProps<TView extends TimeViewWithMeridiem, TComponent
|
|
|
11
11
|
onViewChange?: (view: TView) => void;
|
|
12
12
|
views: readonly TView[];
|
|
13
13
|
};
|
|
14
|
-
export declare const renderTimeViewClock: <TDate extends unknown>({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, shouldDisableClock, minutesStep, ampm, ampmInClock, components, componentsProps, slots, slotProps, readOnly, disabled, sx, autoFocus, showViewSwitcher, disableIgnoringDatePartForTimeValidation, timezone, }: TimeViewRendererProps<TimeView, TimeClockProps<TDate, TimeView>>) => React.JSX.Element;
|
|
15
|
-
export declare const renderDigitalClockTimeView: <TDate extends unknown>({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, shouldDisableClock, minutesStep, ampm, components, componentsProps, slots, slotProps, readOnly, disabled, sx, autoFocus, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timezone, }: TimeViewRendererProps<"hours", Omit<DigitalClockProps<TDate>, "timeStep"> & Pick<TimePickerProps<TDate>, "timeSteps">>) => React.JSX.Element;
|
|
16
|
-
export declare const renderMultiSectionDigitalClockTimeView: <TDate extends unknown>({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, shouldDisableClock, minutesStep, ampm, components, componentsProps, slots, slotProps, readOnly, disabled, sx, autoFocus, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timezone, }: TimeViewRendererProps<TimeViewWithMeridiem, MultiSectionDigitalClockProps<TDate>>) => React.JSX.Element;
|
|
14
|
+
export declare const renderTimeViewClock: <TDate extends unknown>({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, shouldDisableClock, minutesStep, ampm, ampmInClock, components, componentsProps, slots, slotProps, readOnly, disabled, sx, autoFocus, showViewSwitcher, disableIgnoringDatePartForTimeValidation, timezone, }: TimeViewRendererProps<TimeView, TimeClockProps<TDate, TimeView>>) => React.JSX.Element;
|
|
15
|
+
export declare const renderDigitalClockTimeView: <TDate extends unknown>({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, shouldDisableClock, minutesStep, ampm, components, componentsProps, slots, slotProps, readOnly, disabled, sx, autoFocus, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timezone, }: TimeViewRendererProps<"hours", Omit<DigitalClockProps<TDate>, "timeStep"> & Pick<TimePickerProps<TDate>, "timeSteps">>) => React.JSX.Element;
|
|
16
|
+
export declare const renderMultiSectionDigitalClockTimeView: <TDate extends unknown>({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, shouldDisableClock, minutesStep, ampm, components, componentsProps, slots, slotProps, readOnly, disabled, sx, autoFocus, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timezone, }: TimeViewRendererProps<TimeViewWithMeridiem, MultiSectionDigitalClockProps<TDate>>) => React.JSX.Element;
|
|
@@ -12,6 +12,7 @@ export const renderTimeViewClock = ({
|
|
|
12
12
|
views,
|
|
13
13
|
value,
|
|
14
14
|
defaultValue,
|
|
15
|
+
referenceDate,
|
|
15
16
|
onChange,
|
|
16
17
|
className,
|
|
17
18
|
classes,
|
|
@@ -43,6 +44,7 @@ export const renderTimeViewClock = ({
|
|
|
43
44
|
views: views.filter(isTimeView),
|
|
44
45
|
value: value,
|
|
45
46
|
defaultValue: defaultValue,
|
|
47
|
+
referenceDate: referenceDate,
|
|
46
48
|
onChange: onChange,
|
|
47
49
|
className: className,
|
|
48
50
|
classes: classes,
|
|
@@ -75,6 +77,7 @@ export const renderDigitalClockTimeView = ({
|
|
|
75
77
|
views,
|
|
76
78
|
value,
|
|
77
79
|
defaultValue,
|
|
80
|
+
referenceDate,
|
|
78
81
|
onChange,
|
|
79
82
|
className,
|
|
80
83
|
classes,
|
|
@@ -106,6 +109,7 @@ export const renderDigitalClockTimeView = ({
|
|
|
106
109
|
views: views.filter(isTimeView),
|
|
107
110
|
value: value,
|
|
108
111
|
defaultValue: defaultValue,
|
|
112
|
+
referenceDate: referenceDate,
|
|
109
113
|
onChange: onChange,
|
|
110
114
|
className: className,
|
|
111
115
|
classes: classes,
|
|
@@ -138,6 +142,7 @@ export const renderMultiSectionDigitalClockTimeView = ({
|
|
|
138
142
|
views,
|
|
139
143
|
value,
|
|
140
144
|
defaultValue,
|
|
145
|
+
referenceDate,
|
|
141
146
|
onChange,
|
|
142
147
|
className,
|
|
143
148
|
classes,
|
|
@@ -169,6 +174,7 @@ export const renderMultiSectionDigitalClockTimeView = ({
|
|
|
169
174
|
views: views.filter(isTimeView),
|
|
170
175
|
value: value,
|
|
171
176
|
defaultValue: defaultValue,
|
|
177
|
+
referenceDate: referenceDate,
|
|
172
178
|
onChange: onChange,
|
|
173
179
|
className: className,
|
|
174
180
|
classes: classes,
|