@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
|
@@ -334,9 +334,14 @@ DesktopDateTimePicker.propTypes = {
|
|
|
334
334
|
readOnly: PropTypes.bool,
|
|
335
335
|
/**
|
|
336
336
|
* If `true`, disable heavy animations.
|
|
337
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
337
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
338
338
|
*/
|
|
339
339
|
reduceAnimations: PropTypes.bool,
|
|
340
|
+
/**
|
|
341
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
342
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
343
|
+
*/
|
|
344
|
+
referenceDate: PropTypes.any,
|
|
340
345
|
/**
|
|
341
346
|
* Component displaying when passed `loading` true.
|
|
342
347
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -256,9 +256,14 @@ DesktopTimePicker.propTypes = {
|
|
|
256
256
|
readOnly: PropTypes.bool,
|
|
257
257
|
/**
|
|
258
258
|
* If `true`, disable heavy animations.
|
|
259
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
259
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
260
260
|
*/
|
|
261
261
|
reduceAnimations: PropTypes.bool,
|
|
262
|
+
/**
|
|
263
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
264
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
265
|
+
*/
|
|
266
|
+
referenceDate: PropTypes.any,
|
|
262
267
|
/**
|
|
263
268
|
* The currently selected sections.
|
|
264
269
|
* This prop accept four formats:
|
|
@@ -257,9 +257,14 @@ MobileDatePicker.propTypes = {
|
|
|
257
257
|
readOnly: PropTypes.bool,
|
|
258
258
|
/**
|
|
259
259
|
* If `true`, disable heavy animations.
|
|
260
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
260
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
261
261
|
*/
|
|
262
262
|
reduceAnimations: PropTypes.bool,
|
|
263
|
+
/**
|
|
264
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
265
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
266
|
+
*/
|
|
267
|
+
referenceDate: PropTypes.any,
|
|
263
268
|
/**
|
|
264
269
|
* Component displaying when passed `loading` true.
|
|
265
270
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -306,9 +306,14 @@ MobileDateTimePicker.propTypes = {
|
|
|
306
306
|
readOnly: PropTypes.bool,
|
|
307
307
|
/**
|
|
308
308
|
* If `true`, disable heavy animations.
|
|
309
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
309
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
310
310
|
*/
|
|
311
311
|
reduceAnimations: PropTypes.bool,
|
|
312
|
+
/**
|
|
313
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
314
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
315
|
+
*/
|
|
316
|
+
referenceDate: PropTypes.any,
|
|
312
317
|
/**
|
|
313
318
|
* Component displaying when passed `loading` true.
|
|
314
319
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -234,9 +234,14 @@ MobileTimePicker.propTypes = {
|
|
|
234
234
|
readOnly: PropTypes.bool,
|
|
235
235
|
/**
|
|
236
236
|
* If `true`, disable heavy animations.
|
|
237
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
237
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
238
238
|
*/
|
|
239
239
|
reduceAnimations: PropTypes.bool,
|
|
240
|
+
/**
|
|
241
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
242
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
243
|
+
*/
|
|
244
|
+
referenceDate: PropTypes.any,
|
|
240
245
|
/**
|
|
241
246
|
* The currently selected sections.
|
|
242
247
|
* This prop accept four formats:
|
|
@@ -100,7 +100,7 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
|
|
|
100
100
|
useEnhancedEffect(() => {
|
|
101
101
|
if (autoFocus) {
|
|
102
102
|
var _ref$current;
|
|
103
|
-
(_ref$current = ref.current) == null
|
|
103
|
+
(_ref$current = ref.current) == null || _ref$current.focus();
|
|
104
104
|
}
|
|
105
105
|
}, [autoFocus]);
|
|
106
106
|
return /*#__PURE__*/_jsx(PickersMonthRoot, _extends({
|
|
@@ -202,9 +202,14 @@ StaticDatePicker.propTypes = {
|
|
|
202
202
|
readOnly: PropTypes.bool,
|
|
203
203
|
/**
|
|
204
204
|
* If `true`, disable heavy animations.
|
|
205
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
205
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
206
206
|
*/
|
|
207
207
|
reduceAnimations: PropTypes.bool,
|
|
208
|
+
/**
|
|
209
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
210
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
211
|
+
*/
|
|
212
|
+
referenceDate: PropTypes.any,
|
|
208
213
|
/**
|
|
209
214
|
* Component displaying when passed `loading` true.
|
|
210
215
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -250,9 +250,14 @@ StaticDateTimePicker.propTypes = {
|
|
|
250
250
|
readOnly: PropTypes.bool,
|
|
251
251
|
/**
|
|
252
252
|
* If `true`, disable heavy animations.
|
|
253
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
253
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
254
254
|
*/
|
|
255
255
|
reduceAnimations: PropTypes.bool,
|
|
256
|
+
/**
|
|
257
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
258
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
259
|
+
*/
|
|
260
|
+
referenceDate: PropTypes.any,
|
|
256
261
|
/**
|
|
257
262
|
* Component displaying when passed `loading` true.
|
|
258
263
|
* @returns {React.ReactNode} The node to render when loading.
|
|
@@ -177,9 +177,14 @@ StaticTimePicker.propTypes = {
|
|
|
177
177
|
readOnly: PropTypes.bool,
|
|
178
178
|
/**
|
|
179
179
|
* If `true`, disable heavy animations.
|
|
180
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
180
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
181
181
|
*/
|
|
182
182
|
reduceAnimations: PropTypes.bool,
|
|
183
|
+
/**
|
|
184
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
185
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
186
|
+
*/
|
|
187
|
+
referenceDate: PropTypes.any,
|
|
183
188
|
/**
|
|
184
189
|
* Disable specific clock time.
|
|
185
190
|
* @param {number} clockValue The value to check.
|
package/TimeField/TimeField.js
CHANGED
|
@@ -225,10 +225,6 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
225
225
|
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
226
226
|
*/
|
|
227
227
|
onChange: PropTypes.func,
|
|
228
|
-
/**
|
|
229
|
-
* @ignore
|
|
230
|
-
*/
|
|
231
|
-
onClick: PropTypes.func,
|
|
232
228
|
/**
|
|
233
229
|
* Callback fired when the error associated to the current value changes.
|
|
234
230
|
* @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.
|
package/TimePicker/TimePicker.js
CHANGED
|
@@ -215,9 +215,14 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
215
215
|
readOnly: PropTypes.bool,
|
|
216
216
|
/**
|
|
217
217
|
* If `true`, disable heavy animations.
|
|
218
|
-
* @default `@media(prefers-reduced-motion: reduce)` ||
|
|
218
|
+
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
|
219
219
|
*/
|
|
220
220
|
reduceAnimations: PropTypes.bool,
|
|
221
|
+
/**
|
|
222
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
223
|
+
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
|
|
224
|
+
*/
|
|
225
|
+
referenceDate: PropTypes.any,
|
|
221
226
|
/**
|
|
222
227
|
* The currently selected sections.
|
|
223
228
|
* This prop accept four formats:
|
|
@@ -51,7 +51,10 @@ const YearCalendarRoot = styled('div', {
|
|
|
51
51
|
height: '100%',
|
|
52
52
|
padding: '0 4px',
|
|
53
53
|
width: 320,
|
|
54
|
-
maxHeight: 304
|
|
54
|
+
maxHeight: 304,
|
|
55
|
+
// avoid padding increasing width over defined
|
|
56
|
+
boxSizing: 'border-box',
|
|
57
|
+
position: 'relative'
|
|
55
58
|
});
|
|
56
59
|
export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(inProps, ref) {
|
|
57
60
|
const props = useYearCalendarDefaultizedProps(inProps, 'MuiYearCalendar');
|
|
@@ -157,7 +160,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
157
160
|
if (!isYearDisabled(utils.setYear(value != null ? value : referenceDate, year))) {
|
|
158
161
|
setFocusedYear(year);
|
|
159
162
|
changeHasFocus(true);
|
|
160
|
-
onYearFocus == null
|
|
163
|
+
onYearFocus == null || onYearFocus(year);
|
|
161
164
|
}
|
|
162
165
|
});
|
|
163
166
|
React.useEffect(() => {
|
|
@@ -10,4 +10,4 @@ export interface DateTimeViewRendererProps<TDate> extends Omit<DateCalendarProps
|
|
|
10
10
|
focusedView: DateOrTimeViewWithMeridiem | null;
|
|
11
11
|
timeViewsCount: number;
|
|
12
12
|
}
|
|
13
|
-
export declare const renderDesktopDateTimeView: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minDate, minTime, maxDate, maxTime, shouldDisableDate, shouldDisableMonth, shouldDisableYear, shouldDisableTime, shouldDisableClock, reduceAnimations, minutesStep, ampm, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timeViewsCount, }: DateTimeViewRendererProps<TDate>) => React.JSX.Element;
|
|
13
|
+
export declare const renderDesktopDateTimeView: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, minTime, maxDate, maxTime, shouldDisableDate, shouldDisableMonth, shouldDisableYear, shouldDisableTime, shouldDisableClock, reduceAnimations, minutesStep, ampm, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timeViewsCount, }: DateTimeViewRendererProps<TDate>) => React.JSX.Element;
|
|
@@ -17,6 +17,7 @@ export const renderDesktopDateTimeView = ({
|
|
|
17
17
|
onFocusedViewChange,
|
|
18
18
|
value,
|
|
19
19
|
defaultValue,
|
|
20
|
+
referenceDate,
|
|
20
21
|
onChange,
|
|
21
22
|
className,
|
|
22
23
|
classes,
|
|
@@ -72,6 +73,7 @@ export const renderDesktopDateTimeView = ({
|
|
|
72
73
|
onFocusedViewChange: onFocusedViewChange,
|
|
73
74
|
value: value,
|
|
74
75
|
defaultValue: defaultValue,
|
|
76
|
+
referenceDate: referenceDate,
|
|
75
77
|
onChange: onChange,
|
|
76
78
|
className: className,
|
|
77
79
|
classes: classes,
|
|
@@ -115,6 +117,7 @@ export const renderDesktopDateTimeView = ({
|
|
|
115
117
|
views: views.filter(isInternalTimeView),
|
|
116
118
|
value: value,
|
|
117
119
|
defaultValue: defaultValue,
|
|
120
|
+
referenceDate: referenceDate,
|
|
118
121
|
onChange: onChange,
|
|
119
122
|
className: className,
|
|
120
123
|
classes: classes,
|
|
@@ -8,4 +8,4 @@ export interface DateViewRendererProps<TDate, TView extends DateOrTimeViewWithMe
|
|
|
8
8
|
views: readonly TView[];
|
|
9
9
|
focusedView: TView | null;
|
|
10
10
|
}
|
|
11
|
-
export declare const renderDateViewCalendar: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, }: DateViewRendererProps<TDate, DateView>) => React.JSX.Element;
|
|
11
|
+
export declare const renderDateViewCalendar: <TDate extends unknown>({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsPerRow, defaultCalendarMonth, components, componentsProps, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone, }: DateViewRendererProps<TDate, DateView>) => React.JSX.Element;
|
|
@@ -10,6 +10,7 @@ export const renderDateViewCalendar = ({
|
|
|
10
10
|
onFocusedViewChange,
|
|
11
11
|
value,
|
|
12
12
|
defaultValue,
|
|
13
|
+
referenceDate,
|
|
13
14
|
onChange,
|
|
14
15
|
className,
|
|
15
16
|
classes,
|
|
@@ -50,6 +51,7 @@ export const renderDateViewCalendar = ({
|
|
|
50
51
|
onFocusedViewChange: onFocusedViewChange,
|
|
51
52
|
value: value,
|
|
52
53
|
defaultValue: defaultValue,
|
|
54
|
+
referenceDate: referenceDate,
|
|
53
55
|
onChange: onChange,
|
|
54
56
|
className: className,
|
|
55
57
|
classes: classes,
|
package/index.js
CHANGED
|
@@ -7,6 +7,9 @@ import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions
|
|
|
7
7
|
import { PickersPopperClasses } from './pickersPopperClasses';
|
|
8
8
|
import { UncapitalizeObjectKeys } from '../utils/slots-migration';
|
|
9
9
|
import { UsePickerValueActions } from '../hooks/usePicker/usePickerValue.types';
|
|
10
|
+
interface PickersPopperOwnerState extends PickerPopperProps {
|
|
11
|
+
placement: PopperPlacementType;
|
|
12
|
+
}
|
|
10
13
|
export interface PickersPopperSlotsComponent {
|
|
11
14
|
/**
|
|
12
15
|
* Custom component for the paper rendered inside the desktop picker's Popper.
|
|
@@ -33,9 +36,7 @@ export interface PickersPopperSlotsComponentsProps {
|
|
|
33
36
|
/**
|
|
34
37
|
* Props passed down to the desktop [Paper](https://mui.com/material-ui/api/paper/) component.
|
|
35
38
|
*/
|
|
36
|
-
desktopPaper?: SlotComponentProps<typeof MuiPaper, {},
|
|
37
|
-
placement: PopperPlacementType | undefined;
|
|
38
|
-
}>;
|
|
39
|
+
desktopPaper?: SlotComponentProps<typeof MuiPaper, {}, PickersPopperOwnerState>;
|
|
39
40
|
/**
|
|
40
41
|
* Props passed down to the desktop [Transition](https://mui.com/material-ui/transitions/) component.
|
|
41
42
|
*/
|
|
@@ -64,3 +65,4 @@ export interface PickerPopperProps extends UsePickerValueActions {
|
|
|
64
65
|
reduceAnimations?: boolean;
|
|
65
66
|
}
|
|
66
67
|
export declare function PickersPopper(inProps: PickerPopperProps): React.JSX.Element;
|
|
68
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["PaperComponent", "popperPlacement", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { useSlotProps } from '@mui/base/utils';
|
|
4
6
|
import Grow from '@mui/material/Grow';
|
|
@@ -38,9 +40,9 @@ const PickersPopperPaper = styled(MuiPaper, {
|
|
|
38
40
|
})(({
|
|
39
41
|
ownerState
|
|
40
42
|
}) => _extends({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, ownerState.placement
|
|
43
|
+
outline: 0,
|
|
44
|
+
transformOrigin: 'top center'
|
|
45
|
+
}, ownerState.placement.includes('top') && {
|
|
44
46
|
transformOrigin: 'bottom center'
|
|
45
47
|
}));
|
|
46
48
|
function clickedRootScrollbar(event, doc) {
|
|
@@ -158,6 +160,49 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
158
160
|
}, [active, handleClickAway]);
|
|
159
161
|
return [nodeRef, handleSynthetic, handleSynthetic];
|
|
160
162
|
}
|
|
163
|
+
const PickersPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
164
|
+
const {
|
|
165
|
+
PaperComponent,
|
|
166
|
+
popperPlacement,
|
|
167
|
+
ownerState: inOwnerState,
|
|
168
|
+
children,
|
|
169
|
+
paperSlotProps,
|
|
170
|
+
paperClasses,
|
|
171
|
+
onPaperClick,
|
|
172
|
+
onPaperTouchStart
|
|
173
|
+
// picks up the style props provided by `Transition`
|
|
174
|
+
// https://mui.com/material-ui/transitions/#child-requirement
|
|
175
|
+
} = props,
|
|
176
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
177
|
+
const ownerState = _extends({}, inOwnerState, {
|
|
178
|
+
placement: popperPlacement
|
|
179
|
+
});
|
|
180
|
+
const paperProps = useSlotProps({
|
|
181
|
+
elementType: PaperComponent,
|
|
182
|
+
externalSlotProps: paperSlotProps,
|
|
183
|
+
additionalProps: {
|
|
184
|
+
tabIndex: -1,
|
|
185
|
+
elevation: 8,
|
|
186
|
+
ref
|
|
187
|
+
},
|
|
188
|
+
className: paperClasses,
|
|
189
|
+
ownerState
|
|
190
|
+
});
|
|
191
|
+
return /*#__PURE__*/_jsx(PaperComponent, _extends({}, other, paperProps, {
|
|
192
|
+
onClick: event => {
|
|
193
|
+
var _paperProps$onClick;
|
|
194
|
+
onPaperClick(event);
|
|
195
|
+
(_paperProps$onClick = paperProps.onClick) == null || _paperProps$onClick.call(paperProps, event);
|
|
196
|
+
},
|
|
197
|
+
onTouchStart: event => {
|
|
198
|
+
var _paperProps$onTouchSt;
|
|
199
|
+
onPaperTouchStart(event);
|
|
200
|
+
(_paperProps$onTouchSt = paperProps.onTouchStart) == null || _paperProps$onTouchSt.call(paperProps, event);
|
|
201
|
+
},
|
|
202
|
+
ownerState: ownerState,
|
|
203
|
+
children: children
|
|
204
|
+
}));
|
|
205
|
+
});
|
|
161
206
|
export function PickersPopper(inProps) {
|
|
162
207
|
var _slots$desktopTransit, _slots$desktopTrapFoc, _slots$desktopPaper, _slots$popper;
|
|
163
208
|
const props = useThemeProps({
|
|
@@ -225,18 +270,6 @@ export function PickersPopper(inProps) {
|
|
|
225
270
|
const Transition = ((_slots$desktopTransit = slots == null ? void 0 : slots.desktopTransition) != null ? _slots$desktopTransit : reduceAnimations) ? Fade : Grow;
|
|
226
271
|
const TrapFocus = (_slots$desktopTrapFoc = slots == null ? void 0 : slots.desktopTrapFocus) != null ? _slots$desktopTrapFoc : MuiTrapFocus;
|
|
227
272
|
const Paper = (_slots$desktopPaper = slots == null ? void 0 : slots.desktopPaper) != null ? _slots$desktopPaper : PickersPopperPaper;
|
|
228
|
-
const paperProps = useSlotProps({
|
|
229
|
-
elementType: Paper,
|
|
230
|
-
externalSlotProps: slotProps == null ? void 0 : slotProps.desktopPaper,
|
|
231
|
-
additionalProps: {
|
|
232
|
-
tabIndex: -1,
|
|
233
|
-
elevation: 8,
|
|
234
|
-
ref: handlePaperRef
|
|
235
|
-
},
|
|
236
|
-
className: classes.paper,
|
|
237
|
-
ownerState: {} // Is overridden below to use `placement
|
|
238
|
-
});
|
|
239
|
-
|
|
240
273
|
const Popper = (_slots$popper = slots == null ? void 0 : slots.popper) != null ? _slots$popper : PickersPopperRoot;
|
|
241
274
|
const popperProps = useSlotProps({
|
|
242
275
|
elementType: Popper,
|
|
@@ -268,22 +301,17 @@ export function PickersPopper(inProps) {
|
|
|
268
301
|
isEnabled: () => true
|
|
269
302
|
}, slotProps == null ? void 0 : slotProps.desktopTrapFocus, {
|
|
270
303
|
children: /*#__PURE__*/_jsx(Transition, _extends({}, TransitionProps, slotProps == null ? void 0 : slotProps.desktopTransition, {
|
|
271
|
-
children: /*#__PURE__*/_jsx(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
(_paperProps$onTouchSt = paperProps.onTouchStart) == null ? void 0 : _paperProps$onTouchSt.call(paperProps, event);
|
|
281
|
-
},
|
|
282
|
-
ownerState: _extends({}, ownerState, {
|
|
283
|
-
placement: popperPlacement
|
|
284
|
-
}),
|
|
304
|
+
children: /*#__PURE__*/_jsx(PickersPopperPaperWrapper, {
|
|
305
|
+
PaperComponent: Paper,
|
|
306
|
+
ownerState: ownerState,
|
|
307
|
+
popperPlacement: popperPlacement,
|
|
308
|
+
ref: handlePaperRef,
|
|
309
|
+
onPaperClick: onPaperClick,
|
|
310
|
+
onPaperTouchStart: onPaperTouchStart,
|
|
311
|
+
paperClasses: classes.paper,
|
|
312
|
+
paperSlotProps: slotProps == null ? void 0 : slotProps.desktopPaper,
|
|
285
313
|
children: children
|
|
286
|
-
})
|
|
314
|
+
})
|
|
287
315
|
}))
|
|
288
316
|
}))
|
|
289
317
|
}));
|
|
@@ -10,6 +10,14 @@ interface DemoItemProps {
|
|
|
10
10
|
component?: string;
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
15
|
+
* Please do not use it in your application.
|
|
16
|
+
*/
|
|
13
17
|
export declare function DemoItem(props: DemoItemProps): React.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
20
|
+
* Please do not use it in your application.
|
|
21
|
+
*/
|
|
14
22
|
export declare function DemoContainer(props: DemoGridProps): React.JSX.Element;
|
|
15
23
|
export {};
|
|
@@ -32,6 +32,10 @@ const getSupportedSectionFromChildName = childName => {
|
|
|
32
32
|
}
|
|
33
33
|
return 'time';
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
37
|
+
* Please do not use it in your application.
|
|
38
|
+
*/
|
|
35
39
|
export function DemoItem(props) {
|
|
36
40
|
const {
|
|
37
41
|
label,
|
|
@@ -62,6 +66,11 @@ export function DemoItem(props) {
|
|
|
62
66
|
}), children]
|
|
63
67
|
});
|
|
64
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
|
72
|
+
* Please do not use it in your application.
|
|
73
|
+
*/
|
|
65
74
|
export function DemoContainer(props) {
|
|
66
75
|
const {
|
|
67
76
|
children,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const slowAnimationDevices: boolean;
|
|
2
2
|
export declare const useDefaultReduceAnimations: () => boolean;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
2
2
|
const PREFERS_REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// detect if user agent has Android version < 10 or iOS version < 13
|
|
5
|
+
const mobileVersionMatches = typeof navigator !== 'undefined' && navigator.userAgent.match(/android\s(\d+)|OS\s(\d+)/i);
|
|
6
|
+
const androidVersion = mobileVersionMatches && mobileVersionMatches[1] ? parseInt(mobileVersionMatches[1], 10) : null;
|
|
7
|
+
const iOSVersion = mobileVersionMatches && mobileVersionMatches[2] ? parseInt(mobileVersionMatches[2], 10) : null;
|
|
8
|
+
export const slowAnimationDevices = androidVersion && androidVersion < 10 || iOSVersion && iOSVersion < 13 || false;
|
|
4
9
|
export const useDefaultReduceAnimations = () => {
|
|
5
10
|
const prefersReduced = useMediaQuery(PREFERS_REDUCED_MOTION, {
|
|
6
11
|
defaultMatches: false
|
|
7
12
|
});
|
|
8
|
-
return prefersReduced ||
|
|
13
|
+
return prefersReduced || slowAnimationDevices;
|
|
9
14
|
};
|
|
@@ -81,7 +81,7 @@ export const useDesktopPicker = _ref => {
|
|
|
81
81
|
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.openPickerButton,
|
|
82
82
|
additionalProps: {
|
|
83
83
|
disabled: disabled || readOnly,
|
|
84
|
-
onClick: actions.onOpen,
|
|
84
|
+
onClick: open ? actions.onClose : actions.onOpen,
|
|
85
85
|
'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils),
|
|
86
86
|
edge: inputAdornmentProps.position
|
|
87
87
|
},
|
|
@@ -41,7 +41,7 @@ export interface UseDesktopPickerSlotsComponent<TDate, TView extends DateOrTimeV
|
|
|
41
41
|
export interface UseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView>, Pick<PickersLayoutSlotsComponentsProps<TDate | null, TDate, TView>, 'toolbar'> {
|
|
42
42
|
}
|
|
43
43
|
export interface ExportedUseDesktopPickerSlotsComponentsProps<TDate, TView extends DateOrTimeViewWithMeridiem> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<TDate | null, TDate, TView> {
|
|
44
|
-
field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, any, FieldSection, any, any, any>>;
|
|
44
|
+
field?: SlotComponentProps<React.ElementType<BaseSingleInputFieldProps<TDate | null, TDate, FieldSection, unknown>>, {}, UsePickerProps<TDate | null, TDate, any, FieldSection, any, any, any>>;
|
|
45
45
|
textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>;
|
|
46
46
|
inputAdornment?: Partial<InputAdornmentProps>;
|
|
47
47
|
openPickerButton?: SlotComponentProps<typeof IconButton, {}, UseDesktopPickerProps<TDate, any, any, any>>;
|
|
@@ -53,7 +53,7 @@ export interface DesktopOnlyPickerProps<TDate> extends BaseNonStaticPickerProps,
|
|
|
53
53
|
*/
|
|
54
54
|
autoFocus?: boolean;
|
|
55
55
|
}
|
|
56
|
-
export interface UseDesktopPickerProps<TDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, TView, any, any>> extends BasePickerProps<TDate | null, TDate, TView, TError, TExternalProps, {}>, DesktopOnlyPickerProps<TDate> {
|
|
56
|
+
export interface UseDesktopPickerProps<TDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<any, any, TView, any, any>> extends BasePickerProps<TDate | null, TDate, TView, TError, TExternalProps, {}>, DesktopOnlyPickerProps<TDate> {
|
|
57
57
|
/**
|
|
58
58
|
* Overridable component slots.
|
|
59
59
|
* @default {}
|
|
@@ -86,17 +86,17 @@ export const useField = params => {
|
|
|
86
86
|
setSelectedSections(sectionIndex);
|
|
87
87
|
};
|
|
88
88
|
const handleInputClick = useEventCallback((...args) => {
|
|
89
|
-
onClick == null
|
|
89
|
+
onClick == null || onClick(...args);
|
|
90
90
|
syncSelectionFromDOM();
|
|
91
91
|
});
|
|
92
92
|
const handleInputMouseUp = useEventCallback(event => {
|
|
93
|
-
onMouseUp == null
|
|
93
|
+
onMouseUp == null || onMouseUp(event);
|
|
94
94
|
|
|
95
95
|
// Without this, the browser will remove the selected when clicking inside an already-selected section.
|
|
96
96
|
event.preventDefault();
|
|
97
97
|
});
|
|
98
98
|
const handleInputFocus = useEventCallback((...args) => {
|
|
99
|
-
onFocus == null
|
|
99
|
+
onFocus == null || onFocus(...args);
|
|
100
100
|
// The ref is guaranteed to be resolved at this point.
|
|
101
101
|
const input = inputRef.current;
|
|
102
102
|
window.clearTimeout(focusTimeoutRef.current);
|
|
@@ -118,11 +118,11 @@ export const useField = params => {
|
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
const handleInputBlur = useEventCallback((...args) => {
|
|
121
|
-
onBlur == null
|
|
121
|
+
onBlur == null || onBlur(...args);
|
|
122
122
|
setSelectedSections(null);
|
|
123
123
|
});
|
|
124
124
|
const handleInputPaste = useEventCallback(event => {
|
|
125
|
-
onPaste == null
|
|
125
|
+
onPaste == null || onPaste(event);
|
|
126
126
|
if (readOnly) {
|
|
127
127
|
event.preventDefault();
|
|
128
128
|
return;
|
|
@@ -203,7 +203,7 @@ export const useField = params => {
|
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
const handleInputKeyDown = useEventCallback(event => {
|
|
206
|
-
onKeyDown == null
|
|
206
|
+
onKeyDown == null || onKeyDown(event);
|
|
207
207
|
|
|
208
208
|
// eslint-disable-next-line default-case
|
|
209
209
|
switch (true) {
|
|
@@ -27,5 +27,4 @@ export declare const getSectionsBoundaries: <TDate>(utils: MuiPickersAdapter<TDa
|
|
|
27
27
|
export declare const validateSections: <TSection extends FieldSection>(sections: TSection[], valueType: FieldValueType) => void;
|
|
28
28
|
export declare const mergeDateIntoReferenceDate: <TDate>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, dateToTransferFrom: TDate, sections: FieldSectionWithoutPosition[], referenceDate: TDate, shouldLimitToEditedSections: boolean) => TDate;
|
|
29
29
|
export declare const isAndroid: () => boolean;
|
|
30
|
-
export declare const clampDaySectionIfPossible: <TDate, TSection extends FieldSection>(utils: MuiPickersAdapter<TDate, any>, timezone: PickersTimezone, sections: TSection[], sectionsValueBoundaries: FieldSectionsValueBoundaries<TDate>) => TSection[] | null;
|
|
31
30
|
export declare const getSectionOrder: (sections: FieldSectionWithoutPosition[], isRTL: boolean) => SectionOrdering;
|
|
@@ -645,54 +645,6 @@ export const mergeDateIntoReferenceDate = (utils, timezone, dateToTransferFrom,
|
|
|
645
645
|
return mergedDate;
|
|
646
646
|
}, referenceDate);
|
|
647
647
|
export const isAndroid = () => navigator.userAgent.toLowerCase().indexOf('android') > -1;
|
|
648
|
-
export const clampDaySectionIfPossible = (utils, timezone, sections, sectionsValueBoundaries) => {
|
|
649
|
-
// We can only clamp the day value if:
|
|
650
|
-
// 1. if all the sections are filled (except the week day section which can be empty)
|
|
651
|
-
// 2. there is a day section
|
|
652
|
-
const canClamp = sections.every(section => section.type === 'weekDay' || section.value !== '') && sections.some(section => section.type === 'day');
|
|
653
|
-
if (!canClamp) {
|
|
654
|
-
return null;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// We try to generate a valid date representing the start of the month of the invalid date typed by the user.
|
|
658
|
-
const sectionsForStartOfMonth = sections.map(section => {
|
|
659
|
-
if (section.type !== 'day') {
|
|
660
|
-
return section;
|
|
661
|
-
}
|
|
662
|
-
const dayBoundaries = sectionsValueBoundaries.day({
|
|
663
|
-
currentDate: null,
|
|
664
|
-
format: section.format,
|
|
665
|
-
contentType: section.contentType
|
|
666
|
-
});
|
|
667
|
-
return _extends({}, section, {
|
|
668
|
-
value: cleanDigitSectionValue(utils, timezone, dayBoundaries.minimum, dayBoundaries, section)
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
const startOfMonth = getDateFromDateSections(utils, sectionsForStartOfMonth);
|
|
672
|
-
|
|
673
|
-
// Even the start of the month is invalid, we probably have other invalid sections, the clamping failed.
|
|
674
|
-
if (startOfMonth == null || !utils.isValid(startOfMonth)) {
|
|
675
|
-
return null;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// The only invalid section was the day of the month, we replace its value with the maximum boundary for the correct month.
|
|
679
|
-
return sections.map(section => {
|
|
680
|
-
if (section.type !== 'day') {
|
|
681
|
-
return section;
|
|
682
|
-
}
|
|
683
|
-
const dayBoundaries = sectionsValueBoundaries.day({
|
|
684
|
-
currentDate: startOfMonth,
|
|
685
|
-
format: section.format,
|
|
686
|
-
contentType: section.contentType
|
|
687
|
-
});
|
|
688
|
-
if (Number(section.value) <= dayBoundaries.maximum) {
|
|
689
|
-
return section;
|
|
690
|
-
}
|
|
691
|
-
return _extends({}, section, {
|
|
692
|
-
value: dayBoundaries.maximum.toString()
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
};
|
|
696
648
|
export const getSectionOrder = (sections, isRTL) => {
|
|
697
649
|
const neighbors = {};
|
|
698
650
|
if (!isRTL) {
|