@mui/x-date-pickers 8.0.0-beta.0 → 8.0.0-beta.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/CHANGELOG.md +171 -0
- package/DateCalendar/DateCalendar.js +4 -8
- package/DateCalendar/DayCalendar.d.ts +3 -7
- package/DateCalendar/DayCalendar.js +18 -10
- package/DateCalendar/index.d.ts +0 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +2 -16
- package/DatePicker/DatePicker.js +1 -0
- package/DatePicker/shared.js +3 -9
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +2 -16
- package/DateTimePicker/DateTimePicker.js +1 -0
- package/DateTimePicker/shared.js +3 -13
- package/DesktopDatePicker/DesktopDatePicker.js +1 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -0
- package/DesktopTimePicker/DesktopTimePicker.js +1 -0
- package/MobileDatePicker/MobileDatePicker.js +1 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +1 -0
- package/MobileTimePicker/MobileTimePicker.js +1 -0
- package/MonthCalendar/MonthCalendar.js +4 -9
- package/PickersDay/PickersDay.d.ts +1 -72
- package/PickersDay/PickersDay.js +30 -28
- package/PickersDay/PickersDay.types.d.ts +114 -0
- package/PickersDay/PickersDay.types.js +5 -0
- package/PickersDay/index.d.ts +1 -1
- package/PickersDay/usePickerDayOwnerState.d.ts +14 -0
- package/PickersDay/usePickerDayOwnerState.js +40 -0
- package/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +2 -16
- package/TimePicker/TimePicker.js +1 -0
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +4 -10
- package/esm/DateCalendar/DateCalendar.js +6 -10
- package/esm/DateCalendar/DayCalendar.d.ts +3 -7
- package/esm/DateCalendar/DayCalendar.js +18 -10
- package/esm/DateCalendar/index.d.ts +0 -1
- package/esm/DateField/useDateField.d.ts +1 -1
- package/esm/DateField/useDateField.js +3 -17
- package/esm/DatePicker/DatePicker.js +1 -0
- package/esm/DatePicker/shared.js +3 -9
- package/esm/DateTimeField/useDateTimeField.d.ts +1 -1
- package/esm/DateTimeField/useDateTimeField.js +3 -17
- package/esm/DateTimePicker/DateTimePicker.js +1 -0
- package/esm/DateTimePicker/shared.js +4 -14
- package/esm/DesktopDatePicker/DesktopDatePicker.js +1 -0
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -0
- package/esm/DesktopTimePicker/DesktopTimePicker.js +1 -0
- package/esm/MobileDatePicker/MobileDatePicker.js +1 -0
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +1 -0
- package/esm/MobileTimePicker/MobileTimePicker.js +1 -0
- package/esm/MonthCalendar/MonthCalendar.js +6 -11
- package/esm/PickersDay/PickersDay.d.ts +1 -72
- package/esm/PickersDay/PickersDay.js +30 -28
- package/esm/PickersDay/PickersDay.types.d.ts +114 -0
- package/esm/PickersDay/PickersDay.types.js +1 -0
- package/esm/PickersDay/index.d.ts +1 -1
- package/esm/PickersDay/usePickerDayOwnerState.d.ts +14 -0
- package/esm/PickersDay/usePickerDayOwnerState.js +32 -0
- package/esm/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/esm/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/esm/TimeField/useTimeField.d.ts +1 -1
- package/esm/TimeField/useTimeField.js +3 -17
- package/esm/TimePicker/TimePicker.js +1 -0
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +5 -11
- package/esm/hooks/useSplitFieldProps.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.d.ts +5 -5
- package/esm/internals/hooks/useField/buildSectionsFromFormat.d.ts +2 -2
- package/esm/internals/hooks/useField/buildSectionsFromFormat.js +9 -9
- package/esm/internals/hooks/useField/index.d.ts +1 -1
- package/esm/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/esm/internals/hooks/useField/syncSelectionToDOM.js +50 -0
- package/esm/internals/hooks/useField/useField.d.ts +2 -4
- package/esm/internals/hooks/useField/useField.js +5 -229
- package/esm/internals/hooks/useField/useField.types.d.ts +55 -68
- package/esm/internals/hooks/useField/useField.utils.d.ts +3 -8
- package/esm/internals/hooks/useField/useField.utils.js +7 -149
- package/esm/internals/hooks/useField/useFieldCharacterEditing.d.ts +19 -26
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +42 -60
- package/esm/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/esm/internals/hooks/useField/useFieldHiddenInputProps.js +31 -0
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts +16 -0
- package/esm/internals/hooks/useField/useFieldRootHandleKeyDown.js +205 -0
- package/esm/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/esm/internals/hooks/useField/useFieldRootProps.js +150 -0
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.js +29 -0
- package/esm/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +226 -0
- package/esm/internals/hooks/useField/useFieldState.d.ts +23 -13
- package/esm/internals/hooks/useField/useFieldState.js +103 -30
- package/esm/internals/hooks/useField/useFieldV6TextField.d.ts +3 -3
- package/esm/internals/hooks/useField/useFieldV6TextField.js +202 -135
- package/esm/internals/hooks/useField/useFieldV7TextField.d.ts +3 -2
- package/esm/internals/hooks/useField/useFieldV7TextField.js +200 -367
- package/esm/internals/hooks/usePicker/usePicker.types.d.ts +1 -0
- package/esm/internals/index.d.ts +6 -5
- package/esm/internals/index.js +4 -3
- package/esm/locales/deDE.js +2 -3
- package/esm/managers/useDateManager.d.ts +4 -13
- package/esm/managers/useDateManager.js +21 -31
- package/esm/managers/useDateTimeManager.d.ts +4 -13
- package/esm/managers/useDateTimeManager.js +26 -36
- package/esm/managers/useTimeManager.d.ts +4 -13
- package/esm/managers/useTimeManager.js +17 -27
- package/esm/models/fields.d.ts +2 -2
- package/esm/models/manager.d.ts +6 -10
- package/esm/validation/validateDate.js +3 -4
- package/hooks/useSplitFieldProps.d.ts +1 -1
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.d.ts +5 -5
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +2 -2
- package/internals/hooks/useField/buildSectionsFromFormat.js +9 -9
- package/internals/hooks/useField/index.d.ts +1 -1
- package/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/internals/hooks/useField/syncSelectionToDOM.js +56 -0
- package/internals/hooks/useField/useField.d.ts +2 -4
- package/internals/hooks/useField/useField.js +5 -231
- package/internals/hooks/useField/useField.types.d.ts +55 -68
- package/internals/hooks/useField/useField.utils.d.ts +3 -8
- package/internals/hooks/useField/useField.utils.js +9 -154
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +19 -26
- package/internals/hooks/useField/useFieldCharacterEditing.js +41 -59
- package/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/internals/hooks/useField/useFieldHiddenInputProps.js +39 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts +16 -0
- package/internals/hooks/useField/useFieldRootHandleKeyDown.js +211 -0
- package/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/internals/hooks/useField/useFieldRootProps.js +156 -0
- package/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/internals/hooks/useField/useFieldSectionContainerProps.js +37 -0
- package/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/internals/hooks/useField/useFieldSectionContentProps.js +234 -0
- package/internals/hooks/useField/useFieldState.d.ts +23 -13
- package/internals/hooks/useField/useFieldState.js +102 -29
- package/internals/hooks/useField/useFieldV6TextField.d.ts +3 -3
- package/internals/hooks/useField/useFieldV6TextField.js +202 -135
- package/internals/hooks/useField/useFieldV7TextField.d.ts +3 -2
- package/internals/hooks/useField/useFieldV7TextField.js +200 -367
- package/internals/hooks/usePicker/usePicker.types.d.ts +1 -0
- package/internals/index.d.ts +6 -5
- package/internals/index.js +25 -18
- package/locales/deDE.js +2 -3
- package/managers/useDateManager.d.ts +4 -13
- package/managers/useDateManager.js +21 -31
- package/managers/useDateTimeManager.d.ts +4 -13
- package/managers/useDateTimeManager.js +26 -36
- package/managers/useTimeManager.d.ts +4 -13
- package/managers/useTimeManager.js +18 -28
- package/models/fields.d.ts +2 -2
- package/models/manager.d.ts +6 -10
- package/modern/DateCalendar/DateCalendar.js +6 -10
- package/modern/DateCalendar/DayCalendar.d.ts +3 -7
- package/modern/DateCalendar/DayCalendar.js +18 -10
- package/modern/DateCalendar/index.d.ts +0 -1
- package/modern/DateField/useDateField.d.ts +1 -1
- package/modern/DateField/useDateField.js +3 -17
- package/modern/DatePicker/DatePicker.js +1 -0
- package/modern/DatePicker/shared.js +3 -9
- package/modern/DateTimeField/useDateTimeField.d.ts +1 -1
- package/modern/DateTimeField/useDateTimeField.js +3 -17
- package/modern/DateTimePicker/DateTimePicker.js +1 -0
- package/modern/DateTimePicker/shared.js +4 -14
- package/modern/DesktopDatePicker/DesktopDatePicker.js +1 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +1 -0
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +6 -11
- package/modern/PickersDay/PickersDay.d.ts +1 -72
- package/modern/PickersDay/PickersDay.js +30 -28
- package/modern/PickersDay/PickersDay.types.d.ts +114 -0
- package/modern/PickersDay/PickersDay.types.js +1 -0
- package/modern/PickersDay/index.d.ts +1 -1
- package/modern/PickersDay/usePickerDayOwnerState.d.ts +14 -0
- package/modern/PickersDay/usePickerDayOwnerState.js +32 -0
- package/modern/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/modern/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/modern/TimeField/useTimeField.d.ts +1 -1
- package/modern/TimeField/useTimeField.js +3 -17
- package/modern/TimePicker/TimePicker.js +1 -0
- package/modern/TimePicker/shared.js +3 -3
- package/modern/YearCalendar/YearCalendar.js +5 -11
- package/modern/hooks/useSplitFieldProps.d.ts +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.d.ts +5 -5
- package/modern/internals/hooks/useField/buildSectionsFromFormat.d.ts +2 -2
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +9 -9
- package/modern/internals/hooks/useField/index.d.ts +1 -1
- package/modern/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/modern/internals/hooks/useField/syncSelectionToDOM.js +50 -0
- package/modern/internals/hooks/useField/useField.d.ts +2 -4
- package/modern/internals/hooks/useField/useField.js +5 -229
- package/modern/internals/hooks/useField/useField.types.d.ts +55 -68
- package/modern/internals/hooks/useField/useField.utils.d.ts +3 -8
- package/modern/internals/hooks/useField/useField.utils.js +7 -149
- package/modern/internals/hooks/useField/useFieldCharacterEditing.d.ts +19 -26
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +42 -60
- package/modern/internals/hooks/useField/useFieldHiddenInputProps.d.ts +20 -0
- package/modern/internals/hooks/useField/useFieldHiddenInputProps.js +31 -0
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +8 -10
- package/modern/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts +16 -0
- package/modern/internals/hooks/useField/useFieldRootHandleKeyDown.js +205 -0
- package/modern/internals/hooks/useField/useFieldRootProps.d.ts +32 -0
- package/modern/internals/hooks/useField/useFieldRootProps.js +150 -0
- package/modern/internals/hooks/useField/useFieldSectionContainerProps.d.ts +15 -0
- package/modern/internals/hooks/useField/useFieldSectionContainerProps.js +29 -0
- package/modern/internals/hooks/useField/useFieldSectionContentProps.d.ts +23 -0
- package/modern/internals/hooks/useField/useFieldSectionContentProps.js +226 -0
- package/modern/internals/hooks/useField/useFieldState.d.ts +23 -13
- package/modern/internals/hooks/useField/useFieldState.js +103 -30
- package/modern/internals/hooks/useField/useFieldV6TextField.d.ts +3 -3
- package/modern/internals/hooks/useField/useFieldV6TextField.js +202 -135
- package/modern/internals/hooks/useField/useFieldV7TextField.d.ts +3 -2
- package/modern/internals/hooks/useField/useFieldV7TextField.js +200 -367
- package/modern/internals/hooks/usePicker/usePicker.types.d.ts +1 -0
- package/modern/internals/index.d.ts +6 -5
- package/modern/internals/index.js +4 -3
- package/modern/locales/deDE.js +2 -3
- package/modern/managers/useDateManager.d.ts +4 -13
- package/modern/managers/useDateManager.js +21 -31
- package/modern/managers/useDateTimeManager.d.ts +4 -13
- package/modern/managers/useDateTimeManager.js +26 -36
- package/modern/managers/useTimeManager.d.ts +4 -13
- package/modern/managers/useTimeManager.js +17 -27
- package/modern/models/fields.d.ts +2 -2
- package/modern/models/manager.d.ts +6 -10
- package/modern/validation/validateDate.js +3 -4
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/validateDate.js +3 -4
package/internals/index.js
CHANGED
|
@@ -159,18 +159,6 @@ Object.defineProperty(exports, "getActiveElement", {
|
|
|
159
159
|
return _utils.getActiveElement;
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
-
Object.defineProperty(exports, "getDateFieldInternalPropsDefaults", {
|
|
163
|
-
enumerable: true,
|
|
164
|
-
get: function () {
|
|
165
|
-
return _useDateManager.getDateFieldInternalPropsDefaults;
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(exports, "getDateTimeFieldInternalPropsDefaults", {
|
|
169
|
-
enumerable: true,
|
|
170
|
-
get: function () {
|
|
171
|
-
return _useDateTimeManager.getDateTimeFieldInternalPropsDefaults;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
162
|
Object.defineProperty(exports, "getDefaultReferenceDate", {
|
|
175
163
|
enumerable: true,
|
|
176
164
|
get: function () {
|
|
@@ -183,12 +171,6 @@ Object.defineProperty(exports, "getMeridiem", {
|
|
|
183
171
|
return _timeUtils.getMeridiem;
|
|
184
172
|
}
|
|
185
173
|
});
|
|
186
|
-
Object.defineProperty(exports, "getTimeFieldInternalPropsDefaults", {
|
|
187
|
-
enumerable: true,
|
|
188
|
-
get: function () {
|
|
189
|
-
return _useTimeManager.getTimeFieldInternalPropsDefaults;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
174
|
Object.defineProperty(exports, "getTodayDate", {
|
|
193
175
|
enumerable: true,
|
|
194
176
|
get: function () {
|
|
@@ -285,6 +267,24 @@ Object.defineProperty(exports, "resolveTimeViewsResponse", {
|
|
|
285
267
|
return _dateTimeUtils.resolveTimeViewsResponse;
|
|
286
268
|
}
|
|
287
269
|
});
|
|
270
|
+
Object.defineProperty(exports, "useApplyDefaultValuesToDateTimeValidationProps", {
|
|
271
|
+
enumerable: true,
|
|
272
|
+
get: function () {
|
|
273
|
+
return _useDateTimeManager.useApplyDefaultValuesToDateTimeValidationProps;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(exports, "useApplyDefaultValuesToDateValidationProps", {
|
|
277
|
+
enumerable: true,
|
|
278
|
+
get: function () {
|
|
279
|
+
return _useDateManager.useApplyDefaultValuesToDateValidationProps;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
Object.defineProperty(exports, "useApplyDefaultValuesToTimeValidationProps", {
|
|
283
|
+
enumerable: true,
|
|
284
|
+
get: function () {
|
|
285
|
+
return _useTimeManager.useApplyDefaultValuesToTimeValidationProps;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
288
|
Object.defineProperty(exports, "useCalendarState", {
|
|
289
289
|
enumerable: true,
|
|
290
290
|
get: function () {
|
|
@@ -363,6 +363,12 @@ Object.defineProperty(exports, "usePicker", {
|
|
|
363
363
|
return _usePicker.usePicker;
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
|
+
Object.defineProperty(exports, "usePickerDayOwnerState", {
|
|
367
|
+
enumerable: true,
|
|
368
|
+
get: function () {
|
|
369
|
+
return _usePickerDayOwnerState.usePickerDayOwnerState;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
366
372
|
Object.defineProperty(exports, "usePickerPrivateContext", {
|
|
367
373
|
enumerable: true,
|
|
368
374
|
get: function () {
|
|
@@ -440,6 +446,7 @@ var _views = require("./utils/views");
|
|
|
440
446
|
var _DayCalendar = require("../DateCalendar/DayCalendar");
|
|
441
447
|
var _useCalendarState = require("../DateCalendar/useCalendarState");
|
|
442
448
|
var _DateTimePickerToolbar = require("../DateTimePicker/DateTimePickerToolbar");
|
|
449
|
+
var _usePickerDayOwnerState = require("../PickersDay/usePickerDayOwnerState");
|
|
443
450
|
var _useDateManager = require("../managers/useDateManager");
|
|
444
451
|
var _useTimeManager = require("../managers/useTimeManager");
|
|
445
452
|
var _useDateTimeManager = require("../managers/useDateTimeManager");
|
package/locales/deDE.js
CHANGED
|
@@ -37,8 +37,7 @@ const deDEPickers = {
|
|
|
37
37
|
dateTimePickerToolbarTitle: 'Datum & Uhrzeit auswählen',
|
|
38
38
|
timePickerToolbarTitle: 'Uhrzeit auswählen',
|
|
39
39
|
dateRangePickerToolbarTitle: 'Datumsbereich auswählen',
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
timeRangePickerToolbarTitle: 'Zeitspanne auswählen',
|
|
42
41
|
// Clock labels
|
|
43
42
|
clockLabelText: (view, formattedTime) => `${timeViews[view] ?? view} auswählen. ${!formattedTime ? 'Keine Uhrzeit ausgewählt' : `Gewählte Uhrzeit ist ${formattedTime}`}`,
|
|
44
43
|
hoursClockNumberText: hours => `${hours} ${timeViews.hours}`,
|
|
@@ -54,7 +53,7 @@ const deDEPickers = {
|
|
|
54
53
|
// Open Picker labels
|
|
55
54
|
openDatePickerDialogue: formattedDate => formattedDate ? `Datum auswählen, gewähltes Datum ist ${formattedDate}` : 'Datum auswählen',
|
|
56
55
|
openTimePickerDialogue: formattedTime => formattedTime ? `Uhrzeit auswählen, gewählte Uhrzeit ist ${formattedTime}` : 'Uhrzeit auswählen',
|
|
57
|
-
|
|
56
|
+
openRangePickerDialogue: formattedRange => formattedRange ? `Zeitspanne auswählen, die aktuell ausgewählte Zeitspanne ist ${formattedRange}` : 'Zeitspanne auswählen',
|
|
58
57
|
fieldClearLabel: 'Wert leeren',
|
|
59
58
|
// Table labels
|
|
60
59
|
timeTableLabel: 'Uhrzeit auswählen',
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { PickerManager, DateValidationError } from "../models/index.js";
|
|
3
3
|
import { UseFieldInternalProps } from "../internals/hooks/useField/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { PickerManagerFieldInternalPropsWithDefaults, PickerValue } from "../internals/models/index.js";
|
|
4
|
+
import { ExportedValidateDateProps, ValidateDateProps } from "../validation/validateDate.js";
|
|
5
|
+
import { PickerValue } from "../internals/models/index.js";
|
|
7
6
|
export declare function useDateManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Is used by the `useDateManager` and `useDateRangeManager` hooks.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getDateFieldInternalPropsDefaults(parameters: GetDateFieldInternalPropsDefaultsParameters): GetDateFieldInternalPropsDefaultsReturnValue;
|
|
7
|
+
type SharedDateAndDateRangeValidationProps = 'disablePast' | 'disableFuture' | 'minDate' | 'maxDate';
|
|
8
|
+
export declare function useApplyDefaultValuesToDateValidationProps(props: Pick<ExportedValidateDateProps, SharedDateAndDateRangeValidationProps>): Pick<ValidateDateProps, SharedDateAndDateRangeValidationProps>;
|
|
13
9
|
export interface UseDateManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> {
|
|
14
10
|
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
15
11
|
}
|
|
16
12
|
export type UseDateManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, DateValidationError, ValidateDateProps, DateManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>>;
|
|
17
13
|
export interface DateManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateValidationError>, 'format'>, ExportedValidateDateProps {}
|
|
18
|
-
type DateManagerFieldPropsToDefault = 'format' | ValidateDatePropsToDefault;
|
|
19
|
-
interface GetDateFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'defaultDates' | 'utils'> {
|
|
20
|
-
internalProps: Pick<DateManagerFieldInternalProps<true>, DateManagerFieldPropsToDefault>;
|
|
21
|
-
}
|
|
22
|
-
interface GetDateFieldInternalPropsDefaultsReturnValue extends Pick<PickerManagerFieldInternalPropsWithDefaults<UseDateManagerReturnValue<true>>, DateManagerFieldPropsToDefault> {}
|
|
23
14
|
export {};
|
|
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
9
|
+
exports.useApplyDefaultValuesToDateValidationProps = useApplyDefaultValuesToDateValidationProps;
|
|
10
10
|
exports.useDateManager = useDateManager;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -25,42 +25,32 @@ function useDateManager(parameters = {}) {
|
|
|
25
25
|
internal_valueManager: _valueManagers.singleItemValueManager,
|
|
26
26
|
internal_fieldValueManager: _valueManagers.singleItemFieldValueManager,
|
|
27
27
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
28
|
-
|
|
29
|
-
internalProps,
|
|
30
|
-
utils,
|
|
31
|
-
defaultDates
|
|
32
|
-
}) => (0, _extends2.default)({}, internalProps, getDateFieldInternalPropsDefaults({
|
|
33
|
-
defaultDates,
|
|
34
|
-
utils,
|
|
35
|
-
internalProps
|
|
36
|
-
})),
|
|
28
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateFieldInternalProps,
|
|
37
29
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
38
30
|
}), [enableAccessibleFieldDOMStructure]);
|
|
39
31
|
}
|
|
40
|
-
function useOpenPickerButtonAriaLabel() {
|
|
32
|
+
function useOpenPickerButtonAriaLabel(value) {
|
|
41
33
|
const utils = (0, _useUtils.useUtils)();
|
|
42
34
|
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
43
|
-
return React.
|
|
35
|
+
return React.useMemo(() => {
|
|
44
36
|
const formattedValue = utils.isValid(value) ? utils.format(value, 'fullDate') : null;
|
|
45
37
|
return translations.openDatePickerDialogue(formattedValue);
|
|
46
|
-
}, [translations, utils]);
|
|
38
|
+
}, [value, translations, utils]);
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
maxDate: (0, _dateUtils.applyDefaultDate)(utils, internalProps.maxDate, defaultDates.maxDate)
|
|
65
|
-
};
|
|
40
|
+
function useApplyDefaultValuesToDateFieldInternalProps(internalProps) {
|
|
41
|
+
const utils = (0, _useUtils.useUtils)();
|
|
42
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(internalProps);
|
|
43
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
44
|
+
format: internalProps.format ?? utils.formats.keyboardDate
|
|
45
|
+
}), [internalProps, validationProps, utils]);
|
|
46
|
+
}
|
|
47
|
+
function useApplyDefaultValuesToDateValidationProps(props) {
|
|
48
|
+
const utils = (0, _useUtils.useUtils)();
|
|
49
|
+
const defaultDates = (0, _useUtils.useDefaultDates)();
|
|
50
|
+
return React.useMemo(() => ({
|
|
51
|
+
disablePast: props.disablePast ?? false,
|
|
52
|
+
disableFuture: props.disableFuture ?? false,
|
|
53
|
+
minDate: (0, _dateUtils.applyDefaultDate)(utils, props.minDate, defaultDates.minDate),
|
|
54
|
+
maxDate: (0, _dateUtils.applyDefaultDate)(utils, props.maxDate, defaultDates.maxDate)
|
|
55
|
+
}), [props.minDate, props.maxDate, props.disableFuture, props.disablePast, utils, defaultDates]);
|
|
66
56
|
}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { PickerManager, DateTimeValidationError } from "../models/index.js";
|
|
3
3
|
import { UseFieldInternalProps } from "../internals/hooks/useField/index.js";
|
|
4
|
-
import { MuiPickersAdapterContextValue } from "../LocalizationProvider/LocalizationProvider.js";
|
|
5
4
|
import { AmPmProps } from "../internals/models/props/time.js";
|
|
6
|
-
import { ExportedValidateDateTimeProps, ValidateDateTimeProps
|
|
7
|
-
import {
|
|
5
|
+
import { ExportedValidateDateTimeProps, ValidateDateTimeProps } from "../validation/validateDateTime.js";
|
|
6
|
+
import { PickerValue } from "../internals/models/index.js";
|
|
8
7
|
export declare function useDateTimeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseDateTimeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseDateTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Is used by the `useDateTimeManager` and `useDateTimeRangeManager` hooks.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getDateTimeFieldInternalPropsDefaults(parameters: GetDateTimeFieldInternalPropsDefaultsParameters): GetDateTimeFieldInternalPropsDefaultsReturnValue;
|
|
8
|
+
type SharedDateTimeAndDateTimeRangeValidationProps = 'disablePast' | 'disableFuture' | 'minTime' | 'maxTime' | 'minDate' | 'maxDate';
|
|
9
|
+
export declare function useApplyDefaultValuesToDateTimeValidationProps(props: Pick<ExportedValidateDateTimeProps, SharedDateTimeAndDateTimeRangeValidationProps | 'minDateTime' | 'maxDateTime'>): Pick<ValidateDateTimeProps, SharedDateTimeAndDateTimeRangeValidationProps>;
|
|
14
10
|
export interface UseDateTimeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> {
|
|
15
11
|
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
16
12
|
}
|
|
17
13
|
export type UseDateTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError, ValidateDateTimeProps, DateTimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>>;
|
|
18
14
|
export interface DateTimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, DateTimeValidationError>, 'format'>, ExportedValidateDateTimeProps, AmPmProps {}
|
|
19
|
-
type DateTimeManagerFieldPropsToDefault = 'format' | 'minTime' | 'maxTime' | ValidateDateTimePropsToDefault;
|
|
20
|
-
interface GetDateTimeFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'defaultDates' | 'utils'> {
|
|
21
|
-
internalProps: Pick<DateTimeManagerFieldInternalProps<true>, DateTimeManagerFieldPropsToDefault | 'minDateTime' | 'maxDateTime' | 'ampm'>;
|
|
22
|
-
}
|
|
23
|
-
interface GetDateTimeFieldInternalPropsDefaultsReturnValue extends Pick<PickerManagerFieldInternalPropsWithDefaults<UseDateTimeManagerReturnValue<true>>, DateTimeManagerFieldPropsToDefault | 'disableIgnoringDatePartForTimeValidation'> {}
|
|
24
15
|
export {};
|
|
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
9
|
+
exports.useApplyDefaultValuesToDateTimeValidationProps = useApplyDefaultValuesToDateTimeValidationProps;
|
|
10
10
|
exports.useDateTimeManager = useDateTimeManager;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -25,47 +25,37 @@ function useDateTimeManager(parameters = {}) {
|
|
|
25
25
|
internal_valueManager: _valueManagers.singleItemValueManager,
|
|
26
26
|
internal_fieldValueManager: _valueManagers.singleItemFieldValueManager,
|
|
27
27
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
28
|
-
|
|
29
|
-
internalProps,
|
|
30
|
-
utils,
|
|
31
|
-
defaultDates
|
|
32
|
-
}) => (0, _extends2.default)({}, internalProps, getDateTimeFieldInternalPropsDefaults({
|
|
33
|
-
internalProps,
|
|
34
|
-
utils,
|
|
35
|
-
defaultDates
|
|
36
|
-
})),
|
|
28
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToDateTimeFieldInternalProps,
|
|
37
29
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
38
30
|
}), [enableAccessibleFieldDOMStructure]);
|
|
39
31
|
}
|
|
40
|
-
function useOpenPickerButtonAriaLabel() {
|
|
32
|
+
function useOpenPickerButtonAriaLabel(value) {
|
|
41
33
|
const utils = (0, _useUtils.useUtils)();
|
|
42
34
|
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
43
|
-
return React.
|
|
35
|
+
return React.useMemo(() => {
|
|
44
36
|
const formattedValue = utils.isValid(value) ? utils.format(value, 'fullDate') : null;
|
|
45
37
|
return translations.openDatePickerDialogue(formattedValue);
|
|
46
|
-
}, [translations, utils]);
|
|
38
|
+
}, [value, translations, utils]);
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
maxTime: internalProps.maxDateTime ?? internalProps.maxTime
|
|
70
|
-
};
|
|
40
|
+
function useApplyDefaultValuesToDateTimeFieldInternalProps(internalProps) {
|
|
41
|
+
const utils = (0, _useUtils.useUtils)();
|
|
42
|
+
const validationProps = useApplyDefaultValuesToDateTimeValidationProps(internalProps);
|
|
43
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
44
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
45
|
+
format: internalProps.format ?? (ampm ? utils.formats.keyboardDateTime12h : utils.formats.keyboardDateTime24h)
|
|
46
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
47
|
+
}
|
|
48
|
+
function useApplyDefaultValuesToDateTimeValidationProps(props) {
|
|
49
|
+
const utils = (0, _useUtils.useUtils)();
|
|
50
|
+
const defaultDates = (0, _useUtils.useDefaultDates)();
|
|
51
|
+
return React.useMemo(() => ({
|
|
52
|
+
disablePast: props.disablePast ?? false,
|
|
53
|
+
disableFuture: props.disableFuture ?? false,
|
|
54
|
+
// TODO: Explore if we can remove it from the public API
|
|
55
|
+
disableIgnoringDatePartForTimeValidation: !!props.minDateTime || !!props.maxDateTime || !!props.disableFuture || !!props.disablePast,
|
|
56
|
+
minDate: (0, _dateUtils.applyDefaultDate)(utils, props.minDateTime ?? props.minDate, defaultDates.minDate),
|
|
57
|
+
maxDate: (0, _dateUtils.applyDefaultDate)(utils, props.maxDateTime ?? props.maxDate, defaultDates.maxDate),
|
|
58
|
+
minTime: props.minDateTime ?? props.minTime,
|
|
59
|
+
maxTime: props.maxDateTime ?? props.maxTime
|
|
60
|
+
}), [props.minDateTime, props.maxDateTime, props.minTime, props.maxTime, props.minDate, props.maxDate, props.disableFuture, props.disablePast, utils, defaultDates]);
|
|
71
61
|
}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import type { MakeOptional } from '@mui/x-internals/types';
|
|
2
2
|
import { PickerManager, TimeValidationError } from "../models/index.js";
|
|
3
3
|
import { UseFieldInternalProps } from "../internals/hooks/useField/index.js";
|
|
4
|
-
import { MuiPickersAdapterContextValue } from "../LocalizationProvider/LocalizationProvider.js";
|
|
5
4
|
import { AmPmProps } from "../internals/models/props/time.js";
|
|
6
|
-
import { ExportedValidateTimeProps, ValidateTimeProps
|
|
7
|
-
import {
|
|
5
|
+
import { ExportedValidateTimeProps, ValidateTimeProps } from "../validation/validateTime.js";
|
|
6
|
+
import { PickerValue } from "../internals/models/index.js";
|
|
8
7
|
export declare function useTimeManager<TEnableAccessibleFieldDOMStructure extends boolean = true>(parameters?: UseTimeManagerParameters<TEnableAccessibleFieldDOMStructure>): UseTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Is used by the `useTimeManager` and `useTimeRangeManager` hooks.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getTimeFieldInternalPropsDefaults(parameters: GetTimeFieldInternalPropsDefaultsParameters): GetTimeFieldInternalPropsDefaultsReturnValue;
|
|
8
|
+
type SharedTimeAndTimeRangeValidationProps = 'disablePast' | 'disableFuture';
|
|
9
|
+
export declare function useApplyDefaultValuesToTimeValidationProps(props: Pick<ExportedValidateTimeProps, SharedTimeAndTimeRangeValidationProps>): Pick<ValidateTimeProps, SharedTimeAndTimeRangeValidationProps>;
|
|
14
10
|
export interface UseTimeManagerParameters<TEnableAccessibleFieldDOMStructure extends boolean> extends AmPmProps {
|
|
15
11
|
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
|
16
12
|
}
|
|
17
13
|
export type UseTimeManagerReturnValue<TEnableAccessibleFieldDOMStructure extends boolean> = PickerManager<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError, ValidateTimeProps, TimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure>>;
|
|
18
14
|
export interface TimeManagerFieldInternalProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<UseFieldInternalProps<PickerValue, TEnableAccessibleFieldDOMStructure, TimeValidationError>, 'format'>, ExportedValidateTimeProps, AmPmProps {}
|
|
19
|
-
type TimeManagerFieldPropsToDefault = 'format' | ValidateTimePropsToDefault;
|
|
20
|
-
interface GetTimeFieldInternalPropsDefaultsParameters extends Pick<MuiPickersAdapterContextValue, 'utils'> {
|
|
21
|
-
internalProps: Pick<TimeManagerFieldInternalProps<true>, TimeManagerFieldPropsToDefault | 'ampm'>;
|
|
22
|
-
}
|
|
23
|
-
interface GetTimeFieldInternalPropsDefaultsReturnValue extends Pick<PickerManagerFieldInternalPropsWithDefaults<UseTimeManagerReturnValue<true>>, TimeManagerFieldPropsToDefault> {}
|
|
24
15
|
export {};
|
|
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.
|
|
9
|
+
exports.useApplyDefaultValuesToTimeValidationProps = useApplyDefaultValuesToTimeValidationProps;
|
|
10
10
|
exports.useTimeManager = useTimeManager;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -25,42 +25,32 @@ function useTimeManager(parameters = {}) {
|
|
|
25
25
|
internal_valueManager: _valueManagers.singleItemValueManager,
|
|
26
26
|
internal_fieldValueManager: _valueManagers.singleItemFieldValueManager,
|
|
27
27
|
internal_enableAccessibleFieldDOMStructure: enableAccessibleFieldDOMStructure,
|
|
28
|
-
|
|
29
|
-
internalProps,
|
|
30
|
-
utils
|
|
31
|
-
}) => (0, _extends2.default)({}, internalProps, getTimeFieldInternalPropsDefaults({
|
|
32
|
-
utils,
|
|
33
|
-
internalProps
|
|
34
|
-
})),
|
|
28
|
+
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToTimeFieldInternalProps,
|
|
35
29
|
internal_useOpenPickerButtonAriaLabel: createUseOpenPickerButtonAriaLabel(ampm)
|
|
36
30
|
}), [ampm, enableAccessibleFieldDOMStructure]);
|
|
37
31
|
}
|
|
38
32
|
function createUseOpenPickerButtonAriaLabel(ampm) {
|
|
39
|
-
return function useOpenPickerButtonAriaLabel() {
|
|
33
|
+
return function useOpenPickerButtonAriaLabel(value) {
|
|
40
34
|
const utils = (0, _useUtils.useUtils)();
|
|
41
35
|
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
42
|
-
return React.
|
|
36
|
+
return React.useMemo(() => {
|
|
43
37
|
const formatKey = ampm ?? utils.is12HourCycleInCurrentLocale() ? 'fullTime12h' : 'fullTime24h';
|
|
44
38
|
const formattedValue = utils.isValid(value) ? utils.format(value, formatKey) : null;
|
|
45
39
|
return translations.openTimePickerDialogue(formattedValue);
|
|
46
|
-
}, [translations, utils]);
|
|
40
|
+
}, [value, translations, utils]);
|
|
47
41
|
};
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
disablePast: internalProps.disablePast ?? false,
|
|
63
|
-
disableFuture: internalProps.disableFuture ?? false,
|
|
64
|
-
format: internalProps.format ?? defaultFormat
|
|
65
|
-
};
|
|
43
|
+
function useApplyDefaultValuesToTimeFieldInternalProps(internalProps) {
|
|
44
|
+
const utils = (0, _useUtils.useUtils)();
|
|
45
|
+
const validationProps = useApplyDefaultValuesToTimeValidationProps(internalProps);
|
|
46
|
+
const ampm = React.useMemo(() => internalProps.ampm ?? utils.is12HourCycleInCurrentLocale(), [internalProps.ampm, utils]);
|
|
47
|
+
return React.useMemo(() => (0, _extends2.default)({}, internalProps, validationProps, {
|
|
48
|
+
format: internalProps.format ?? (ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h)
|
|
49
|
+
}), [internalProps, validationProps, ampm, utils]);
|
|
50
|
+
}
|
|
51
|
+
function useApplyDefaultValuesToTimeValidationProps(props) {
|
|
52
|
+
return React.useMemo(() => ({
|
|
53
|
+
disablePast: props.disablePast ?? false,
|
|
54
|
+
disableFuture: props.disableFuture ?? false
|
|
55
|
+
}), [props.disablePast, props.disableFuture]);
|
|
66
56
|
}
|
package/models/fields.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
3
|
import type { ExportedPickersSectionListProps } from '../PickersSectionList';
|
|
4
|
-
import type { UseFieldInternalProps,
|
|
4
|
+
import type { UseFieldInternalProps, UseFieldReturnValue } from '../internals/hooks/useField';
|
|
5
5
|
import type { PickersTextFieldProps } from '../PickersTextField';
|
|
6
6
|
import { BaseSingleInputFieldProps, FieldRangeSection, PickerRangeValue, PickerValidValue } from "../internals/models/index.js";
|
|
7
7
|
import { PickerOwnerState } from "./pickers.js";
|
|
@@ -131,7 +131,7 @@ export type PickerFieldSlotProps<TValue extends PickerValidValue, TEnableAccessi
|
|
|
131
131
|
* Props the text field receives when used inside a single input Picker.
|
|
132
132
|
* Only contains what the MUI components are passing to the text field, not what users can pass using the `props.slotProps.field` and `props.slotProps.textField`.
|
|
133
133
|
*/
|
|
134
|
-
export type BaseSingleInputPickersTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = Omit<
|
|
134
|
+
export type BaseSingleInputPickersTextFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = Omit<UseFieldReturnValue<TEnableAccessibleFieldDOMStructure, BaseSingleInputFieldProps>, 'slots' | 'slotProps' | 'clearable' | 'onClear' | 'openPickerButtonPosition' | 'clearButtonPosition' | 'openPickerAriaLabel'>;
|
|
135
135
|
/**
|
|
136
136
|
* Props the built-in text field component can receive.
|
|
137
137
|
*/
|
package/models/manager.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FieldValueManager, UseFieldInternalProps } from '../internals/hooks/useField';
|
|
2
|
-
import type { UseLocalizationContextReturnValue } from '../internals/hooks/useUtils';
|
|
3
2
|
import type { PickerValidValue, PickerValueManager } from '../internals/models';
|
|
4
3
|
import type { Validator } from '../validation';
|
|
5
4
|
import type { PickerValueType } from './common';
|
|
@@ -66,17 +65,14 @@ export interface PickerManager<TValue extends PickerValidValue, TEnableAccessibl
|
|
|
66
65
|
* - a default format to display the value in the field
|
|
67
66
|
* - some default validation props that are needed to validate the value (e.g: minDate, maxDate)
|
|
68
67
|
* This property is not part of the public API and should not be used directly.
|
|
69
|
-
* @param {
|
|
68
|
+
* @param {TFieldInternalProps<TFieldInternalProps>} internalProps The field internal props to apply the defaults to.
|
|
70
69
|
* @returns {TFieldInternalPropsWithDefaults} The field internal props with the defaults applied.
|
|
71
70
|
*/
|
|
72
|
-
|
|
71
|
+
internal_useApplyDefaultValuesToFieldInternalProps: (internalProps: TFieldInternalProps) => UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, TError> & TValidationProps;
|
|
73
72
|
/**
|
|
74
73
|
* Returns a hook that creates the aria-label to apply on the button that opens the Picker.
|
|
75
|
-
* @
|
|
74
|
+
* @param {TValue} value The value of the Picker.
|
|
75
|
+
* @returns {string} The aria-label to apply on the button that opens the Picker.
|
|
76
76
|
*/
|
|
77
|
-
internal_useOpenPickerButtonAriaLabel: (
|
|
78
|
-
}
|
|
79
|
-
interface ApplyDefaultsToFieldInternalPropsParameters<TFieldInternalProps extends {}> extends UseLocalizationContextReturnValue {
|
|
80
|
-
internalProps: TFieldInternalProps;
|
|
81
|
-
}
|
|
82
|
-
export {};
|
|
77
|
+
internal_useOpenPickerButtonAriaLabel: (value: TValue) => string;
|
|
78
|
+
}
|
|
@@ -10,14 +10,14 @@ import useSlotProps from '@mui/utils/useSlotProps';
|
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import { unstable_composeClasses as composeClasses, unstable_useId as useId, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
12
12
|
import { useCalendarState } from "./useCalendarState.js";
|
|
13
|
-
import {
|
|
13
|
+
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
14
14
|
import { PickersFadeTransitionGroup } from "./PickersFadeTransitionGroup.js";
|
|
15
15
|
import { DayCalendar } from "./DayCalendar.js";
|
|
16
16
|
import { MonthCalendar } from "../MonthCalendar/index.js";
|
|
17
17
|
import { YearCalendar } from "../YearCalendar/index.js";
|
|
18
18
|
import { useViews } from "../internals/hooks/useViews.js";
|
|
19
19
|
import { PickersCalendarHeader } from "../PickersCalendarHeader/index.js";
|
|
20
|
-
import { findClosestEnabledDate,
|
|
20
|
+
import { findClosestEnabledDate, mergeDateAndTime } from "../internals/utils/date-utils.js";
|
|
21
21
|
import { PickerViewRoot } from "../internals/components/PickerViewRoot/index.js";
|
|
22
22
|
import { useReduceAnimations } from "../internals/hooks/useReduceAnimations.js";
|
|
23
23
|
import { getDateCalendarUtilityClass } from "./dateCalendarClasses.js";
|
|
@@ -25,6 +25,7 @@ import { useControlledValue } from "../internals/hooks/useControlledValue.js";
|
|
|
25
25
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
26
26
|
import { VIEW_HEIGHT } from "../internals/constants/dimensions.js";
|
|
27
27
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
28
|
+
import { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
28
29
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
30
|
const useUtilityClasses = classes => {
|
|
30
31
|
const slots = {
|
|
@@ -34,25 +35,20 @@ const useUtilityClasses = classes => {
|
|
|
34
35
|
return composeClasses(slots, getDateCalendarUtilityClass, classes);
|
|
35
36
|
};
|
|
36
37
|
function useDateCalendarDefaultizedProps(props, name) {
|
|
37
|
-
const utils = useUtils();
|
|
38
|
-
const defaultDates = useDefaultDates();
|
|
39
38
|
const themeProps = useThemeProps({
|
|
40
39
|
props,
|
|
41
40
|
name
|
|
42
41
|
});
|
|
43
42
|
const reduceAnimations = useReduceAnimations(themeProps.reduceAnimations);
|
|
44
|
-
|
|
43
|
+
const validationProps = useApplyDefaultValuesToDateValidationProps(themeProps);
|
|
44
|
+
return _extends({}, themeProps, validationProps, {
|
|
45
45
|
loading: themeProps.loading ?? false,
|
|
46
|
-
disablePast: themeProps.disablePast ?? false,
|
|
47
|
-
disableFuture: themeProps.disableFuture ?? false,
|
|
48
46
|
openTo: themeProps.openTo ?? 'day',
|
|
49
47
|
views: themeProps.views ?? ['year', 'day'],
|
|
50
48
|
reduceAnimations,
|
|
51
49
|
renderLoading: themeProps.renderLoading ?? (() => /*#__PURE__*/_jsx("span", {
|
|
52
50
|
children: "..."
|
|
53
|
-
}))
|
|
54
|
-
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
55
|
-
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
51
|
+
}))
|
|
56
52
|
});
|
|
57
53
|
}
|
|
58
54
|
const DateCalendarRoot = styled(PickerViewRoot, {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DefaultizedProps, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
3
|
-
import {
|
|
3
|
+
import { PickerDayOwnerState, PickersDayProps } from "../PickersDay/index.js";
|
|
4
|
+
import { ExportedPickersDayProps } from "../PickersDay/PickersDay.types.js";
|
|
4
5
|
import { PickerOnChangeFn } from "../internals/hooks/useViews.js";
|
|
5
6
|
import { SlideDirection, SlideTransitionProps } from "./PickersSlideTransition.js";
|
|
6
7
|
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from "../internals/models/validation.js";
|
|
7
8
|
import { DayCalendarClasses } from "./dayCalendarClasses.js";
|
|
8
|
-
import {
|
|
9
|
+
import { PickerValidDate, TimezoneProps } from "../models/index.js";
|
|
9
10
|
import { FormProps } from "../internals/models/formProps.js";
|
|
10
11
|
export interface DayCalendarSlots {
|
|
11
12
|
/**
|
|
@@ -18,11 +19,6 @@ export interface DayCalendarSlots {
|
|
|
18
19
|
export interface DayCalendarSlotProps {
|
|
19
20
|
day?: SlotComponentPropsFromProps<PickersDayProps, {}, PickerDayOwnerState>;
|
|
20
21
|
}
|
|
21
|
-
export interface PickerDayOwnerState extends PickerOwnerState {
|
|
22
|
-
isDaySelected: boolean;
|
|
23
|
-
isDayDisabled: boolean;
|
|
24
|
-
day: PickerValidDate;
|
|
25
|
-
}
|
|
26
22
|
export interface ExportedDayCalendarProps extends ExportedPickersDayProps {
|
|
27
23
|
/**
|
|
28
24
|
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
|
@@ -12,7 +12,7 @@ import { useRtl } from '@mui/system/RtlProvider';
|
|
|
12
12
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
13
13
|
import composeClasses from '@mui/utils/composeClasses';
|
|
14
14
|
import clsx from 'clsx';
|
|
15
|
-
import { PickersDay } from "../PickersDay/
|
|
15
|
+
import { PickersDay } from "../PickersDay/index.js";
|
|
16
16
|
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
17
17
|
import { useUtils, useNow } from "../internals/hooks/useUtils.js";
|
|
18
18
|
import { DAY_SIZE, DAY_MARGIN } from "../internals/constants/dimensions.js";
|
|
@@ -20,7 +20,7 @@ import { PickersSlideTransition } from "./PickersSlideTransition.js";
|
|
|
20
20
|
import { useIsDateDisabled } from "./useIsDateDisabled.js";
|
|
21
21
|
import { findClosestEnabledDate, getWeekdays } from "../internals/utils/date-utils.js";
|
|
22
22
|
import { getDayCalendarUtilityClass } from "./dayCalendarClasses.js";
|
|
23
|
-
import {
|
|
23
|
+
import { usePickerDayOwnerState } from "../PickersDay/usePickerDayOwnerState.js";
|
|
24
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
25
|
const useUtilityClasses = classes => {
|
|
26
26
|
const slots = {
|
|
@@ -81,7 +81,7 @@ const PickersCalendarWeekNumberLabel = styled(Typography, {
|
|
|
81
81
|
display: 'flex',
|
|
82
82
|
justifyContent: 'center',
|
|
83
83
|
alignItems: 'center',
|
|
84
|
-
color: theme.palette.text.disabled
|
|
84
|
+
color: (theme.vars || theme).palette.text.disabled
|
|
85
85
|
}));
|
|
86
86
|
const PickersCalendarWeekNumber = styled(Typography, {
|
|
87
87
|
name: 'MuiDayCalendar',
|
|
@@ -94,7 +94,7 @@ const PickersCalendarWeekNumber = styled(Typography, {
|
|
|
94
94
|
height: DAY_SIZE,
|
|
95
95
|
padding: 0,
|
|
96
96
|
margin: `0 ${DAY_MARGIN}px`,
|
|
97
|
-
color: theme.palette.text.disabled,
|
|
97
|
+
color: (theme.vars || theme).palette.text.disabled,
|
|
98
98
|
fontSize: '0.75rem',
|
|
99
99
|
alignItems: 'center',
|
|
100
100
|
justifyContent: 'center',
|
|
@@ -155,14 +155,23 @@ function WrappedDay(_ref) {
|
|
|
155
155
|
} = parentProps;
|
|
156
156
|
const utils = useUtils();
|
|
157
157
|
const now = useNow(timezone);
|
|
158
|
-
const {
|
|
159
|
-
ownerState
|
|
160
|
-
} = usePickerPrivateContext();
|
|
161
158
|
const isFocusableDay = focusedDay != null && utils.isSameDay(day, focusedDay);
|
|
162
159
|
const isFocusedDay = isViewFocused && isFocusableDay;
|
|
163
160
|
const isSelected = selectedDays.some(selectedDay => utils.isSameDay(selectedDay, day));
|
|
164
161
|
const isToday = utils.isSameDay(day, now);
|
|
165
162
|
const isDisabled = React.useMemo(() => disabled || isDateDisabled(day), [disabled, isDateDisabled, day]);
|
|
163
|
+
const isOutsideCurrentMonth = React.useMemo(() => utils.getMonth(day) !== currentMonthNumber, [utils, day, currentMonthNumber]);
|
|
164
|
+
const ownerState = usePickerDayOwnerState({
|
|
165
|
+
day,
|
|
166
|
+
selected: isSelected,
|
|
167
|
+
disabled: isDisabled,
|
|
168
|
+
today: isToday,
|
|
169
|
+
outsideCurrentMonth: isOutsideCurrentMonth,
|
|
170
|
+
disableMargin: undefined,
|
|
171
|
+
// This prop can only be defined using slotProps.day so the ownerState for useSlotProps cannot have its value.
|
|
172
|
+
disableHighlightToday,
|
|
173
|
+
showDaysOutsideCurrentMonth
|
|
174
|
+
});
|
|
166
175
|
const Day = slots?.day ?? PickersDay;
|
|
167
176
|
// We don't want to pass to ownerState down, to avoid re-rendering all the day whenever a prop changes.
|
|
168
177
|
const _useSlotProps = useSlotProps({
|
|
@@ -183,7 +192,6 @@ function WrappedDay(_ref) {
|
|
|
183
192
|
})
|
|
184
193
|
}),
|
|
185
194
|
dayProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
186
|
-
const outsideCurrentMonth = React.useMemo(() => utils.getMonth(day) !== currentMonthNumber, [utils, day, currentMonthNumber]);
|
|
187
195
|
const isFirstVisibleCell = React.useMemo(() => {
|
|
188
196
|
const startOfMonth = utils.startOfMonth(utils.setMonth(day, currentMonthNumber));
|
|
189
197
|
if (!showDaysOutsideCurrentMonth) {
|
|
@@ -201,9 +209,9 @@ function WrappedDay(_ref) {
|
|
|
201
209
|
return /*#__PURE__*/_jsx(Day, _extends({}, dayProps, {
|
|
202
210
|
day: day,
|
|
203
211
|
disabled: isDisabled,
|
|
204
|
-
autoFocus: !
|
|
212
|
+
autoFocus: !isOutsideCurrentMonth && isFocusedDay,
|
|
205
213
|
today: isToday,
|
|
206
|
-
outsideCurrentMonth:
|
|
214
|
+
outsideCurrentMonth: isOutsideCurrentMonth,
|
|
207
215
|
isFirstVisibleCell: isFirstVisibleCell,
|
|
208
216
|
isLastVisibleCell: isLastVisibleCell,
|
|
209
217
|
selected: isSelected,
|