@mui/x-date-pickers 8.0.0-beta.1 → 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 +94 -0
- package/DateCalendar/DateCalendar.js +4 -8
- package/DateCalendar/DayCalendar.js +2 -2
- package/DatePicker/shared.js +3 -9
- package/DateTimePicker/shared.js +3 -13
- package/MonthCalendar/MonthCalendar.js +4 -9
- package/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/TimePicker/shared.js +3 -3
- package/YearCalendar/YearCalendar.js +4 -10
- package/esm/DateCalendar/DateCalendar.js +6 -10
- package/esm/DateCalendar/DayCalendar.js +2 -2
- package/esm/DatePicker/shared.js +3 -9
- package/esm/DateTimePicker/shared.js +4 -14
- package/esm/MonthCalendar/MonthCalendar.js +6 -11
- package/esm/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/esm/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/esm/TimePicker/shared.js +3 -3
- package/esm/YearCalendar/YearCalendar.js +5 -11
- package/esm/index.js +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.types.d.ts +8 -1
- package/esm/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/esm/internals/hooks/useField/useField.utils.js +0 -57
- 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.js +1 -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/useFieldV7TextField.js +76 -307
- package/esm/internals/index.d.ts +4 -4
- package/esm/internals/index.js +3 -3
- package/esm/locales/deDE.js +2 -3
- package/esm/managers/useDateManager.d.ts +4 -13
- package/esm/managers/useDateManager.js +18 -28
- package/esm/managers/useDateTimeManager.d.ts +4 -13
- package/esm/managers/useDateTimeManager.js +23 -33
- package/esm/managers/useTimeManager.d.ts +4 -13
- package/esm/managers/useTimeManager.js +14 -24
- package/esm/models/manager.d.ts +3 -8
- package/esm/validation/validateDate.js +3 -4
- package/index.js +1 -1
- package/internals/hooks/useField/syncSelectionToDOM.d.ts +9 -0
- package/internals/hooks/useField/syncSelectionToDOM.js +56 -0
- package/internals/hooks/useField/useField.types.d.ts +8 -1
- package/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/internals/hooks/useField/useField.utils.js +2 -61
- 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.js +1 -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/useFieldV7TextField.js +75 -306
- package/internals/index.d.ts +4 -4
- package/internals/index.js +18 -18
- package/locales/deDE.js +2 -3
- package/managers/useDateManager.d.ts +4 -13
- package/managers/useDateManager.js +18 -28
- package/managers/useDateTimeManager.d.ts +4 -13
- package/managers/useDateTimeManager.js +23 -33
- package/managers/useTimeManager.d.ts +4 -13
- package/managers/useTimeManager.js +15 -25
- package/models/manager.d.ts +3 -8
- package/modern/DateCalendar/DateCalendar.js +6 -10
- package/modern/DateCalendar/DayCalendar.js +2 -2
- package/modern/DatePicker/shared.js +3 -9
- package/modern/DateTimePicker/shared.js +4 -14
- package/modern/MonthCalendar/MonthCalendar.js +6 -11
- package/modern/PickersSectionList/PickersSectionList.d.ts +1 -1
- package/modern/PickersSectionList/PickersSectionList.types.d.ts +2 -6
- package/modern/TimePicker/shared.js +3 -3
- package/modern/YearCalendar/YearCalendar.js +5 -11
- package/modern/index.js +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.types.d.ts +8 -1
- package/modern/internals/hooks/useField/useField.utils.d.ts +1 -3
- package/modern/internals/hooks/useField/useField.utils.js +0 -57
- 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.js +1 -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/useFieldV7TextField.js +76 -307
- package/modern/internals/index.d.ts +4 -4
- package/modern/internals/index.js +3 -3
- package/modern/locales/deDE.js +2 -3
- package/modern/managers/useDateManager.d.ts +4 -13
- package/modern/managers/useDateManager.js +18 -28
- package/modern/managers/useDateTimeManager.d.ts +4 -13
- package/modern/managers/useDateTimeManager.js +23 -33
- package/modern/managers/useTimeManager.d.ts +4 -13
- package/modern/managers/useTimeManager.js +14 -24
- package/modern/models/manager.d.ts +3 -8
- package/modern/validation/validateDate.js +3 -4
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/validateDate.js +3 -4
|
@@ -11,28 +11,24 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
|
-
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
|
15
|
-
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
16
14
|
var _useField = require("./useField.utils");
|
|
17
15
|
var _utils = require("../../utils/utils");
|
|
18
16
|
var _hooks = require("../../../hooks");
|
|
19
|
-
var _usePickerTranslations = require("../../../hooks/usePickerTranslations");
|
|
20
|
-
var _useUtils = require("../useUtils");
|
|
21
17
|
var _useFieldCharacterEditing = require("./useFieldCharacterEditing");
|
|
22
|
-
var _useFieldRootHandleKeyDown = require("./useFieldRootHandleKeyDown");
|
|
23
18
|
var _useFieldState = require("./useFieldState");
|
|
24
19
|
var _useFieldInternalPropsWithDefaults = require("./useFieldInternalPropsWithDefaults");
|
|
20
|
+
var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
|
21
|
+
var _useFieldRootProps = require("./useFieldRootProps");
|
|
22
|
+
var _useFieldHiddenInputProps = require("./useFieldHiddenInputProps");
|
|
23
|
+
var _useFieldSectionContainerProps = require("./useFieldSectionContainerProps");
|
|
24
|
+
var _useFieldSectionContentProps = require("./useFieldSectionContentProps");
|
|
25
25
|
const useFieldV7TextField = parameters => {
|
|
26
|
-
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
27
|
-
const utils = (0, _useUtils.useUtils)();
|
|
28
|
-
const id = (0, _useId.default)();
|
|
29
26
|
const {
|
|
30
27
|
props,
|
|
31
28
|
manager,
|
|
32
29
|
skipContextFieldRefAssignment,
|
|
33
30
|
manager: {
|
|
34
31
|
valueType,
|
|
35
|
-
internal_fieldValueManager: fieldValueManager,
|
|
36
32
|
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
|
37
33
|
}
|
|
38
34
|
} = parameters;
|
|
@@ -65,6 +61,13 @@ const useFieldV7TextField = parameters => {
|
|
|
65
61
|
} = internalPropsWithDefaults;
|
|
66
62
|
const sectionListRef = React.useRef(null);
|
|
67
63
|
const handleSectionListRef = (0, _useForkRef.default)(sectionListRefProp, sectionListRef);
|
|
64
|
+
const domGetters = React.useMemo(() => ({
|
|
65
|
+
isReady: () => sectionListRef.current != null,
|
|
66
|
+
getRoot: () => sectionListRef.current.getRoot(),
|
|
67
|
+
getSectionContainer: sectionIndex => sectionListRef.current.getSectionContainer(sectionIndex),
|
|
68
|
+
getSectionContent: sectionIndex => sectionListRef.current.getSectionContent(sectionIndex),
|
|
69
|
+
getSectionIndexFromDOMElement: element => sectionListRef.current.getSectionIndexFromDOMElement(element)
|
|
70
|
+
}), [sectionListRef]);
|
|
68
71
|
const stateResponse = (0, _useFieldState.useFieldState)({
|
|
69
72
|
manager,
|
|
70
73
|
internalPropsWithDefaults,
|
|
@@ -76,62 +79,17 @@ const useFieldV7TextField = parameters => {
|
|
|
76
79
|
error,
|
|
77
80
|
parsedSelectedSections,
|
|
78
81
|
sectionOrder,
|
|
79
|
-
sectionsValueBoundaries,
|
|
80
82
|
state,
|
|
81
83
|
value,
|
|
82
84
|
// Methods to update the states
|
|
83
85
|
clearValue,
|
|
84
|
-
|
|
85
|
-
setCharacterQuery,
|
|
86
|
-
setSelectedSections,
|
|
87
|
-
updateSectionValue,
|
|
88
|
-
updateValueFromValueStr
|
|
86
|
+
setSelectedSections
|
|
89
87
|
} = stateResponse;
|
|
90
88
|
const applyCharacterEditing = (0, _useFieldCharacterEditing.useFieldCharacterEditing)({
|
|
91
89
|
stateResponse
|
|
92
90
|
});
|
|
93
91
|
const openPickerAriaLabel = useOpenPickerButtonAriaLabel(value);
|
|
94
92
|
const [focused, setFocused] = React.useState(false);
|
|
95
|
-
function syncSelectionToDOM() {
|
|
96
|
-
if (!sectionListRef.current) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const selection = document.getSelection();
|
|
100
|
-
if (!selection) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (parsedSelectedSections == null) {
|
|
104
|
-
// If the selection contains an element inside the field, we reset it.
|
|
105
|
-
if (selection.rangeCount > 0 && sectionListRef.current.getRoot().contains(selection.getRangeAt(0).startContainer)) {
|
|
106
|
-
selection.removeAllRanges();
|
|
107
|
-
}
|
|
108
|
-
if (focused) {
|
|
109
|
-
sectionListRef.current.getRoot().blur();
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// On multi input range pickers we want to update selection range only for the active input
|
|
115
|
-
if (!sectionListRef.current.getRoot().contains((0, _utils.getActiveElement)(document))) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const range = new window.Range();
|
|
119
|
-
let target;
|
|
120
|
-
if (parsedSelectedSections === 'all') {
|
|
121
|
-
target = sectionListRef.current.getRoot();
|
|
122
|
-
} else {
|
|
123
|
-
const section = state.sections[parsedSelectedSections];
|
|
124
|
-
if (section.type === 'empty') {
|
|
125
|
-
target = sectionListRef.current.getSectionContainer(parsedSelectedSections);
|
|
126
|
-
} else {
|
|
127
|
-
target = sectionListRef.current.getSectionContent(parsedSelectedSections);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
range.selectNodeContents(target);
|
|
131
|
-
target.focus();
|
|
132
|
-
selection.removeAllRanges();
|
|
133
|
-
selection.addRange(range);
|
|
134
|
-
}
|
|
135
93
|
function focusField(newSelectedSections = 0) {
|
|
136
94
|
if (!sectionListRef.current ||
|
|
137
95
|
// if the field is already focused, we don't need to focus it again
|
|
@@ -142,193 +100,53 @@ const useFieldV7TextField = parameters => {
|
|
|
142
100
|
setFocused(true);
|
|
143
101
|
sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();
|
|
144
102
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
const section = state.sections[sectionIndex];
|
|
155
|
-
sectionListRef.current.getSectionContent(sectionIndex).innerHTML = section.value || section.placeholder;
|
|
156
|
-
syncSelectionToDOM();
|
|
103
|
+
const rootProps = (0, _useFieldRootProps.useFieldRootProps)({
|
|
104
|
+
manager,
|
|
105
|
+
internalPropsWithDefaults,
|
|
106
|
+
stateResponse,
|
|
107
|
+
applyCharacterEditing,
|
|
108
|
+
focused,
|
|
109
|
+
setFocused,
|
|
110
|
+
domGetters
|
|
157
111
|
});
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// We avoid this by checking if the call of `handleContainerClick` is actually intended, or a side effect.
|
|
162
|
-
if (event.isDefaultPrevented() || !sectionListRef.current) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
setFocused(true);
|
|
166
|
-
onClick?.(event, ...args);
|
|
167
|
-
if (parsedSelectedSections === 'all') {
|
|
168
|
-
containerClickTimeout.start(0, () => {
|
|
169
|
-
const cursorPosition = document.getSelection().getRangeAt(0).startOffset;
|
|
170
|
-
if (cursorPosition === 0) {
|
|
171
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
let sectionIndex = 0;
|
|
175
|
-
let cursorOnStartOfSection = 0;
|
|
176
|
-
while (cursorOnStartOfSection < cursorPosition && sectionIndex < state.sections.length) {
|
|
177
|
-
const section = state.sections[sectionIndex];
|
|
178
|
-
sectionIndex += 1;
|
|
179
|
-
cursorOnStartOfSection += `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`.length;
|
|
180
|
-
}
|
|
181
|
-
setSelectedSections(sectionIndex - 1);
|
|
182
|
-
});
|
|
183
|
-
} else if (!focused) {
|
|
184
|
-
setFocused(true);
|
|
185
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
186
|
-
} else {
|
|
187
|
-
const hasClickedOnASection = sectionListRef.current.getRoot().contains(event.target);
|
|
188
|
-
if (!hasClickedOnASection) {
|
|
189
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
112
|
+
const hiddenInputProps = (0, _useFieldHiddenInputProps.useFieldHiddenInputProps)({
|
|
113
|
+
manager,
|
|
114
|
+
stateResponse
|
|
192
115
|
});
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
if (!sectionListRef.current || parsedSelectedSections !== 'all') {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
const target = event.target;
|
|
199
|
-
const keyPressed = target.textContent ?? '';
|
|
200
|
-
sectionListRef.current.getRoot().innerHTML = state.sections.map(section => `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`).join('');
|
|
201
|
-
syncSelectionToDOM();
|
|
202
|
-
if (keyPressed.length === 0 || keyPressed.charCodeAt(0) === 10) {
|
|
203
|
-
clearValue();
|
|
204
|
-
setSelectedSections('all');
|
|
205
|
-
} else if (keyPressed.length > 1) {
|
|
206
|
-
updateValueFromValueStr(keyPressed);
|
|
207
|
-
} else {
|
|
208
|
-
if (parsedSelectedSections === 'all') {
|
|
209
|
-
setSelectedSections(0);
|
|
210
|
-
}
|
|
211
|
-
applyCharacterEditing({
|
|
212
|
-
keyPressed,
|
|
213
|
-
sectionIndex: 0
|
|
214
|
-
});
|
|
215
|
-
}
|
|
116
|
+
const createSectionContainerProps = (0, _useFieldSectionContainerProps.useFieldSectionContainerProps)({
|
|
117
|
+
stateResponse
|
|
216
118
|
});
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
event.preventDefault();
|
|
225
|
-
setCharacterQuery(null);
|
|
226
|
-
updateValueFromValueStr(pastedValue);
|
|
119
|
+
const createSectionContentProps = (0, _useFieldSectionContentProps.useFieldSectionContentProps)({
|
|
120
|
+
manager,
|
|
121
|
+
stateResponse,
|
|
122
|
+
applyCharacterEditing,
|
|
123
|
+
internalPropsWithDefaults,
|
|
124
|
+
domGetters,
|
|
125
|
+
focused
|
|
227
126
|
});
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const activeElement = (0, _utils.getActiveElement)(document);
|
|
234
|
-
setFocused(true);
|
|
235
|
-
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(activeElement) != null;
|
|
236
|
-
if (!isFocusInsideASection) {
|
|
237
|
-
setSelectedSections(sectionOrder.startIndex);
|
|
238
|
-
}
|
|
127
|
+
const handleRootKeyDown = (0, _useEventCallback.default)(event => {
|
|
128
|
+
onKeyDown?.(event);
|
|
129
|
+
rootProps.onKeyDown(event);
|
|
239
130
|
});
|
|
240
|
-
const
|
|
131
|
+
const handleRootBlur = (0, _useEventCallback.default)(event => {
|
|
241
132
|
onBlur?.(event);
|
|
242
|
-
|
|
243
|
-
if (!sectionListRef.current) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
const activeElement = (0, _utils.getActiveElement)(document);
|
|
247
|
-
const shouldBlur = !sectionListRef.current.getRoot().contains(activeElement);
|
|
248
|
-
if (shouldBlur) {
|
|
249
|
-
setFocused(false);
|
|
250
|
-
setSelectedSections(null);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
133
|
+
rootProps.onBlur(event);
|
|
253
134
|
});
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
if (event.isDefaultPrevented()) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
setSelectedSections(sectionIndex);
|
|
261
|
-
});
|
|
262
|
-
const handleInputContentMouseUp = (0, _useEventCallback.default)(event => {
|
|
263
|
-
// Without this, the browser will remove the selected when clicking inside an already-selected section.
|
|
264
|
-
event.preventDefault();
|
|
135
|
+
const handleRootFocus = (0, _useEventCallback.default)(event => {
|
|
136
|
+
onFocus?.(event);
|
|
137
|
+
rootProps.onFocus(event);
|
|
265
138
|
});
|
|
266
|
-
const
|
|
267
|
-
|
|
139
|
+
const handleRootClick = (0, _useEventCallback.default)(event => {
|
|
140
|
+
onClick?.(event);
|
|
141
|
+
rootProps.onClick(event);
|
|
268
142
|
});
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (readOnly || disabled || typeof parsedSelectedSections !== 'number') {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const activeSection = state.sections[parsedSelectedSections];
|
|
276
|
-
const pastedValue = event.clipboardData.getData('text');
|
|
277
|
-
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
|
|
278
|
-
const digitsOnly = /^[0-9]+$/.test(pastedValue);
|
|
279
|
-
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
|
280
|
-
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
|
281
|
-
if (isValidPastedValue) {
|
|
282
|
-
setCharacterQuery(null);
|
|
283
|
-
updateSectionValue({
|
|
284
|
-
section: activeSection,
|
|
285
|
-
newSectionValue: pastedValue,
|
|
286
|
-
shouldGoToNextSection: true
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
// If the pasted value corresponds to a single section, but not the expected type, we skip the modification
|
|
290
|
-
else if (!lettersOnly && !digitsOnly) {
|
|
291
|
-
setCharacterQuery(null);
|
|
292
|
-
updateValueFromValueStr(pastedValue);
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
const handleInputContentDragOver = (0, _useEventCallback.default)(event => {
|
|
296
|
-
event.preventDefault();
|
|
297
|
-
event.dataTransfer.dropEffect = 'none';
|
|
143
|
+
const handleRootPaste = (0, _useEventCallback.default)(event => {
|
|
144
|
+
onPaste?.(event);
|
|
145
|
+
rootProps.onPaste(event);
|
|
298
146
|
});
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
const target = event.target;
|
|
304
|
-
const keyPressed = target.textContent ?? '';
|
|
305
|
-
const sectionIndex = sectionListRef.current.getSectionIndexFromDOMElement(target);
|
|
306
|
-
const section = state.sections[sectionIndex];
|
|
307
|
-
if (readOnly || !sectionListRef.current) {
|
|
308
|
-
revertDOMSectionChange(sectionIndex);
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (keyPressed.length === 0) {
|
|
312
|
-
if (section.value === '') {
|
|
313
|
-
revertDOMSectionChange(sectionIndex);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const inputType = event.nativeEvent.inputType;
|
|
317
|
-
if (inputType === 'insertParagraph' || inputType === 'insertLineBreak') {
|
|
318
|
-
revertDOMSectionChange(sectionIndex);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
revertDOMSectionChange(sectionIndex);
|
|
322
|
-
clearActiveSection();
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
applyCharacterEditing({
|
|
326
|
-
keyPressed,
|
|
327
|
-
sectionIndex
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// The DOM value needs to remain the one React is expecting.
|
|
331
|
-
revertDOMSectionChange(sectionIndex);
|
|
147
|
+
const handleRootInput = (0, _useEventCallback.default)(event => {
|
|
148
|
+
onInput?.(event);
|
|
149
|
+
rootProps.onInput(event);
|
|
332
150
|
});
|
|
333
151
|
const handleClear = (0, _useEventCallback.default)((event, ...args) => {
|
|
334
152
|
event.preventDefault();
|
|
@@ -341,67 +159,18 @@ const useFieldV7TextField = parameters => {
|
|
|
341
159
|
setSelectedSections(sectionOrder.startIndex);
|
|
342
160
|
}
|
|
343
161
|
});
|
|
344
|
-
const handleContainerKeyDown = (0, _useFieldRootHandleKeyDown.useFieldRootHandleKeyDown)({
|
|
345
|
-
manager,
|
|
346
|
-
internalPropsWithDefaults,
|
|
347
|
-
stateResponse
|
|
348
|
-
});
|
|
349
|
-
const wrappedHandleContainerKeyDown = (0, _useEventCallback.default)(event => {
|
|
350
|
-
onKeyDown?.(event);
|
|
351
|
-
handleContainerKeyDown(event);
|
|
352
|
-
});
|
|
353
|
-
const isContainerEditable = parsedSelectedSections === 'all';
|
|
354
162
|
const elements = React.useMemo(() => {
|
|
355
|
-
return state.sections.map((section,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
},
|
|
367
|
-
content: {
|
|
368
|
-
tabIndex: isContainerEditable || index > 0 ? -1 : 0,
|
|
369
|
-
contentEditable: !isContainerEditable && !disabled && !readOnly,
|
|
370
|
-
role: 'spinbutton',
|
|
371
|
-
id: `${id}-${section.type}`,
|
|
372
|
-
'aria-labelledby': `${id}-${section.type}`,
|
|
373
|
-
'aria-readonly': readOnly,
|
|
374
|
-
'aria-valuenow': (0, _useField.getSectionValueNow)(section, utils),
|
|
375
|
-
'aria-valuemin': sectionBoundaries.minimum,
|
|
376
|
-
'aria-valuemax': sectionBoundaries.maximum,
|
|
377
|
-
'aria-valuetext': section.value ? (0, _useField.getSectionValueText)(section, utils) : translations.empty,
|
|
378
|
-
'aria-label': translations[section.type],
|
|
379
|
-
'aria-disabled': disabled,
|
|
380
|
-
spellCheck: isEditable ? false : undefined,
|
|
381
|
-
autoCapitalize: isEditable ? 'off' : undefined,
|
|
382
|
-
autoCorrect: isEditable ? 'off' : undefined,
|
|
383
|
-
[parseInt(React.version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,
|
|
384
|
-
children: section.value || section.placeholder,
|
|
385
|
-
onInput: handleInputContentInput,
|
|
386
|
-
onPaste: handleInputContentPaste,
|
|
387
|
-
onFocus: getInputContentFocusHandler(index),
|
|
388
|
-
onDragOver: handleInputContentDragOver,
|
|
389
|
-
onMouseUp: handleInputContentMouseUp,
|
|
390
|
-
inputMode: section.contentType === 'letter' ? 'text' : 'numeric'
|
|
391
|
-
},
|
|
392
|
-
before: {
|
|
393
|
-
children: section.startSeparator
|
|
394
|
-
},
|
|
395
|
-
after: {
|
|
396
|
-
children: section.endSeparator
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
});
|
|
400
|
-
}, [disabled, fieldValueManager, getInputContainerClickHandler, getInputContentFocusHandler, handleInputContentDragOver, handleInputContentInput, handleInputContentMouseUp, handleInputContentPaste, id, isContainerEditable, readOnly, sectionsValueBoundaries, state.sections, translations, utils, value]);
|
|
401
|
-
const handleValueStrChange = (0, _useEventCallback.default)(event => {
|
|
402
|
-
updateValueFromValueStr(event.target.value);
|
|
403
|
-
});
|
|
404
|
-
const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);
|
|
163
|
+
return state.sections.map((section, sectionIndex) => ({
|
|
164
|
+
container: createSectionContainerProps(sectionIndex),
|
|
165
|
+
content: createSectionContentProps(section, sectionIndex),
|
|
166
|
+
before: {
|
|
167
|
+
children: section.startSeparator
|
|
168
|
+
},
|
|
169
|
+
after: {
|
|
170
|
+
children: section.endSeparator
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
173
|
+
}, [state.sections, createSectionContainerProps, createSectionContentProps]);
|
|
405
174
|
React.useEffect(() => {
|
|
406
175
|
if (sectionListRef.current == null) {
|
|
407
176
|
throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your Picker or Field component:', '', '<DatePicker slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\n'));
|
|
@@ -425,7 +194,11 @@ const useFieldV7TextField = parameters => {
|
|
|
425
194
|
}
|
|
426
195
|
}, [parsedSelectedSections, focused]);
|
|
427
196
|
(0, _useEnhancedEffect.default)(() => {
|
|
428
|
-
syncSelectionToDOM(
|
|
197
|
+
(0, _syncSelectionToDOM.syncSelectionToDOM)({
|
|
198
|
+
focused,
|
|
199
|
+
domGetters,
|
|
200
|
+
stateResponse
|
|
201
|
+
});
|
|
429
202
|
});
|
|
430
203
|
React.useImperativeHandle(unstableFieldRef, () => ({
|
|
431
204
|
getSections: () => state.sections,
|
|
@@ -442,26 +215,22 @@ const useFieldV7TextField = parameters => {
|
|
|
442
215
|
focusField,
|
|
443
216
|
isFieldFocused: () => isFieldFocused(sectionListRef)
|
|
444
217
|
}));
|
|
445
|
-
return (0, _extends2.default)({}, forwardedProps, {
|
|
218
|
+
return (0, _extends2.default)({}, forwardedProps, rootProps, {
|
|
219
|
+
onBlur: handleRootBlur,
|
|
220
|
+
onClick: handleRootClick,
|
|
221
|
+
onFocus: handleRootFocus,
|
|
222
|
+
onInput: handleRootInput,
|
|
223
|
+
onPaste: handleRootPaste,
|
|
224
|
+
onKeyDown: handleRootKeyDown,
|
|
225
|
+
onClear: handleClear
|
|
226
|
+
}, hiddenInputProps, {
|
|
446
227
|
error,
|
|
447
228
|
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled),
|
|
448
229
|
focused: focusedProp ?? focused,
|
|
449
230
|
sectionListRef: handleSectionListRef,
|
|
450
|
-
onBlur: handleContainerBlur,
|
|
451
|
-
onClick: handleContainerClick,
|
|
452
|
-
onFocus: handleContainerFocus,
|
|
453
|
-
onInput: handleContainerInput,
|
|
454
|
-
onPaste: handleContainerPaste,
|
|
455
|
-
onKeyDown: wrappedHandleContainerKeyDown,
|
|
456
|
-
onClear: handleClear,
|
|
457
231
|
// Additional
|
|
458
232
|
enableAccessibleFieldDOMStructure: true,
|
|
459
233
|
elements,
|
|
460
|
-
// TODO v7: Try to set to undefined when there is a section selected.
|
|
461
|
-
tabIndex: parsedSelectedSections === 0 ? -1 : 0,
|
|
462
|
-
contentEditable: isContainerEditable,
|
|
463
|
-
value: valueStr,
|
|
464
|
-
onChange: handleValueStrChange,
|
|
465
234
|
areAllSectionsEmpty,
|
|
466
235
|
disabled,
|
|
467
236
|
readOnly,
|
package/internals/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export { useLocalizationContext, useDefaultDates, useUtils, useNow } from "./hoo
|
|
|
42
42
|
export type { ExportedUseViewsOptions, UseViewsOptions } from './hooks/useViews';
|
|
43
43
|
export { useViews } from "./hooks/useViews.js";
|
|
44
44
|
export { usePreviousMonthDisabled, useNextMonthDisabled } from "./hooks/date-helpers-hooks.js";
|
|
45
|
-
export type { PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerError, PickerValueManager } from './models/manager';
|
|
45
|
+
export type { PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerFieldInternalPropsWithDefaults, PickerManagerEnableAccessibleFieldDOMStructure, PickerManagerError, PickerValueManager } from './models/manager';
|
|
46
46
|
export type { RangePosition } from './models/pickers';
|
|
47
47
|
export type { BaseSingleInputFieldProps, FieldRangeSection } from './models/fields';
|
|
48
48
|
export type { BasePickerProps, BasePickerInputProps } from './models/props/basePickerProps';
|
|
@@ -66,6 +66,6 @@ export type { ExportedDateCalendarProps } from '../DateCalendar/DateCalendar.typ
|
|
|
66
66
|
export { useCalendarState } from "../DateCalendar/useCalendarState.js";
|
|
67
67
|
export { DateTimePickerToolbarOverrideContext } from "../DateTimePicker/DateTimePickerToolbar.js";
|
|
68
68
|
export { usePickerDayOwnerState } from "../PickersDay/usePickerDayOwnerState.js";
|
|
69
|
-
export {
|
|
70
|
-
export {
|
|
71
|
-
export {
|
|
69
|
+
export { useApplyDefaultValuesToDateValidationProps } from "../managers/useDateManager.js";
|
|
70
|
+
export { useApplyDefaultValuesToTimeValidationProps } from "../managers/useTimeManager.js";
|
|
71
|
+
export { useApplyDefaultValuesToDateTimeValidationProps } from "../managers/useDateTimeManager.js";
|
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 () {
|
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,15 +25,7 @@ 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
|
}
|
|
@@ -45,22 +37,20 @@ function useOpenPickerButtonAriaLabel(value) {
|
|
|
45
37
|
return translations.openDatePickerDialogue(formattedValue);
|
|
46
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
|
}
|