@mui/x-date-pickers 8.0.0-alpha.5 → 8.0.0-alpha.6
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 +79 -0
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +6 -17
- package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
- package/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/DateTimePicker/DateTimePickerToolbar.d.ts +8 -4
- package/DateTimePicker/DateTimePickerToolbar.js +13 -24
- package/DateTimePicker/shared.d.ts +2 -2
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +2 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- package/PickersActionBar/PickersActionBar.d.ts +0 -4
- package/PickersActionBar/PickersActionBar.js +12 -13
- package/PickersLayout/PickersLayout.d.ts +2 -2
- package/PickersLayout/PickersLayout.js +1 -11
- package/PickersLayout/PickersLayout.types.d.ts +12 -14
- package/PickersLayout/usePickerLayout.d.ts +2 -2
- package/PickersLayout/usePickerLayout.js +3 -18
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.js +6 -20
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/usePickerActionsContext.d.ts +5 -0
- package/hooks/usePickerActionsContext.js +16 -0
- package/hooks/usePickerContext.d.ts +3 -1
- package/hooks/usePickerContext.js +0 -1
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +11 -6
- package/internals/components/PickerProvider.js +12 -6
- package/internals/components/PickersModalDialog.d.ts +1 -3
- package/internals/components/PickersModalDialog.js +9 -3
- package/internals/components/PickersPopper.d.ts +1 -3
- package/internals/components/PickersPopper.js +11 -6
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +5 -5
- package/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +5 -5
- package/internals/hooks/usePicker/usePicker.js +1 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +38 -17
- package/internals/hooks/usePicker/usePickerViews.d.ts +15 -4
- package/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +4 -4
- package/internals/index.d.ts +4 -4
- package/internals/index.js +1 -1
- package/internals/models/props/tabs.d.ts +0 -13
- package/internals/models/props/toolbar.d.ts +1 -16
- package/modern/DatePicker/DatePickerToolbar.js +6 -17
- package/modern/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/modern/DateTimePicker/DateTimePickerToolbar.js +13 -24
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/modern/PickersActionBar/PickersActionBar.js +12 -13
- package/modern/PickersLayout/PickersLayout.js +1 -11
- package/modern/PickersLayout/usePickerLayout.js +3 -18
- package/modern/TimePicker/TimePickerToolbar.js +6 -20
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/usePickerActionsContext.js +16 -0
- package/modern/hooks/usePickerContext.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +12 -6
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersPopper.js +11 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/modern/internals/hooks/usePicker/usePicker.js +1 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/modern/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/modern/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/modern/internals/index.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +6 -17
- package/node/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/node/DateTimePicker/DateTimePickerToolbar.js +14 -25
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/node/PickersActionBar/PickersActionBar.js +12 -13
- package/node/PickersLayout/PickersLayout.js +1 -11
- package/node/PickersLayout/usePickerLayout.js +3 -18
- package/node/TimePicker/TimePickerToolbar.js +6 -20
- package/node/hooks/index.js +8 -1
- package/node/hooks/usePickerActionsContext.js +22 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +13 -7
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersPopper.js +11 -6
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/node/internals/hooks/usePicker/usePicker.js +1 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/node/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/node/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/node/internals/index.js +2 -2
- package/package.json +2 -2
- package/themeAugmentation/props.d.ts +2 -3
|
@@ -52,8 +52,6 @@ export const useDesktopPicker = _ref => {
|
|
|
52
52
|
const labelId = useId();
|
|
53
53
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
54
54
|
const {
|
|
55
|
-
open,
|
|
56
|
-
actions,
|
|
57
55
|
hasUIView,
|
|
58
56
|
layoutProps,
|
|
59
57
|
providerProps,
|
|
@@ -85,7 +83,11 @@ export const useDesktopPicker = _ref => {
|
|
|
85
83
|
externalSlotProps: innerSlotProps?.openPickerButton,
|
|
86
84
|
additionalProps: {
|
|
87
85
|
disabled: disabled || readOnly,
|
|
88
|
-
|
|
86
|
+
// This direct access to `providerProps` will go away in https://github.com/mui/mui-x/pull/15671
|
|
87
|
+
onClick: event => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
providerProps.contextValue.setOpen(prevOpen => !prevOpen);
|
|
90
|
+
},
|
|
89
91
|
'aria-label': getOpenDialogAriaText(pickerFieldProps.value),
|
|
90
92
|
edge: inputAdornmentProps.position
|
|
91
93
|
},
|
|
@@ -121,7 +123,7 @@ export const useDesktopPicker = _ref => {
|
|
|
121
123
|
sx,
|
|
122
124
|
label,
|
|
123
125
|
name,
|
|
124
|
-
focused: open ? true : undefined
|
|
126
|
+
focused: providerProps.contextValue.open ? true : undefined
|
|
125
127
|
}, isToolbarHidden && {
|
|
126
128
|
id: labelId
|
|
127
129
|
}, !!inputRef && {
|
|
@@ -170,12 +172,10 @@ export const useDesktopPicker = _ref => {
|
|
|
170
172
|
slots: slotsForField,
|
|
171
173
|
slotProps: slotProps,
|
|
172
174
|
unstableFieldRef: handleFieldRef
|
|
173
|
-
})), /*#__PURE__*/_jsx(PickersPopper,
|
|
175
|
+
})), /*#__PURE__*/_jsx(PickersPopper, {
|
|
174
176
|
role: "dialog",
|
|
175
177
|
placement: "bottom-start",
|
|
176
|
-
anchorEl: containerRef.current
|
|
177
|
-
}, actions, {
|
|
178
|
-
open: open,
|
|
178
|
+
anchorEl: containerRef.current,
|
|
179
179
|
slots: slots,
|
|
180
180
|
slotProps: slotProps,
|
|
181
181
|
shouldRestoreFocus: shouldRestoreFocus,
|
|
@@ -185,7 +185,7 @@ export const useDesktopPicker = _ref => {
|
|
|
185
185
|
slotProps: slotProps,
|
|
186
186
|
children: renderCurrentView()
|
|
187
187
|
}))
|
|
188
|
-
})
|
|
188
|
+
})]
|
|
189
189
|
}));
|
|
190
190
|
return {
|
|
191
191
|
renderPicker
|
|
@@ -46,8 +46,6 @@ export const useMobilePicker = _ref => {
|
|
|
46
46
|
const labelId = useId();
|
|
47
47
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
48
48
|
const {
|
|
49
|
-
open,
|
|
50
|
-
actions,
|
|
51
49
|
layoutProps,
|
|
52
50
|
providerProps,
|
|
53
51
|
renderCurrentView,
|
|
@@ -86,8 +84,12 @@ export const useMobilePicker = _ref => {
|
|
|
86
84
|
}, isToolbarHidden && {
|
|
87
85
|
id: labelId
|
|
88
86
|
}, !(disabled || readOnly) && {
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
// These direct access to `providerProps` will go away in https://github.com/mui/mui-x/pull/15671
|
|
88
|
+
onClick: event => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
providerProps.contextValue.setOpen(true);
|
|
91
|
+
},
|
|
92
|
+
onKeyDown: onSpaceOrEnter(() => providerProps.contextValue.setOpen(true))
|
|
91
93
|
}, !!inputRef && {
|
|
92
94
|
inputRef
|
|
93
95
|
}),
|
|
@@ -124,8 +126,7 @@ export const useMobilePicker = _ref => {
|
|
|
124
126
|
slots: slotsForField,
|
|
125
127
|
slotProps: slotProps,
|
|
126
128
|
unstableFieldRef: handleFieldRef
|
|
127
|
-
})), /*#__PURE__*/_jsx(PickersModalDialog,
|
|
128
|
-
open: open,
|
|
129
|
+
})), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
129
130
|
slots: slots,
|
|
130
131
|
slotProps: slotProps,
|
|
131
132
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {
|
|
@@ -133,7 +134,7 @@ export const useMobilePicker = _ref => {
|
|
|
133
134
|
slotProps: slotProps,
|
|
134
135
|
children: renderCurrentView()
|
|
135
136
|
}))
|
|
136
|
-
})
|
|
137
|
+
})]
|
|
137
138
|
}));
|
|
138
139
|
return {
|
|
139
140
|
renderPicker
|
|
@@ -45,15 +45,13 @@ export const usePicker = ({
|
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
47
|
// Picker value
|
|
48
|
-
open: pickerValueResponse.open,
|
|
49
|
-
actions: pickerValueResponse.actions,
|
|
50
48
|
fieldProps: pickerValueResponse.fieldProps,
|
|
51
49
|
// Picker views
|
|
52
50
|
renderCurrentView: pickerViewsResponse.renderCurrentView,
|
|
53
51
|
hasUIView: pickerViewsResponse.provider.hasUIView,
|
|
54
52
|
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
|
|
55
53
|
// Picker layout
|
|
56
|
-
layoutProps: _extends({},
|
|
54
|
+
layoutProps: _extends({}, pickerValueResponse.layoutProps),
|
|
57
55
|
// Picker provider
|
|
58
56
|
providerProps,
|
|
59
57
|
// Picker owner state
|
|
@@ -53,18 +53,19 @@ export function usePickerProvider(parameters) {
|
|
|
53
53
|
pickerOrientation: orientation,
|
|
54
54
|
pickerVariant: variant
|
|
55
55
|
}), [utils, valueManager, paramsFromUsePickerValue.value, paramsFromUsePickerValue.contextValue.open, orientation, variant, props.disabled, props.readOnly]);
|
|
56
|
-
const contextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.contextValue, {
|
|
56
|
+
const contextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.contextValue, paramsFromUsePickerViews.contextValue, {
|
|
57
57
|
disabled: props.disabled ?? false,
|
|
58
58
|
readOnly: props.readOnly ?? false,
|
|
59
59
|
variant,
|
|
60
60
|
orientation
|
|
61
|
-
}), [paramsFromUsePickerValue.contextValue, variant, orientation, props.disabled, props.readOnly]);
|
|
62
|
-
const privateContextValue = React.useMemo(() => ({
|
|
61
|
+
}), [paramsFromUsePickerValue.contextValue, paramsFromUsePickerViews.contextValue, variant, orientation, props.disabled, props.readOnly]);
|
|
62
|
+
const privateContextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.privateContextValue, {
|
|
63
63
|
ownerState
|
|
64
|
-
}), [ownerState]);
|
|
64
|
+
}), [paramsFromUsePickerValue, ownerState]);
|
|
65
65
|
return {
|
|
66
66
|
localeText,
|
|
67
67
|
contextValue,
|
|
68
|
+
actionsContextValue: paramsFromUsePickerValue.actionsContextValue,
|
|
68
69
|
privateContextValue
|
|
69
70
|
};
|
|
70
71
|
}
|
|
@@ -251,49 +251,6 @@ export const usePickerValue = ({
|
|
|
251
251
|
hasBeenModifiedSinceMount: true
|
|
252
252
|
}));
|
|
253
253
|
}
|
|
254
|
-
const handleClear = useEventCallback(() => {
|
|
255
|
-
updateDate({
|
|
256
|
-
value: valueManager.emptyValue,
|
|
257
|
-
name: 'setValueFromAction',
|
|
258
|
-
pickerAction: 'clear'
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
const handleAccept = useEventCallback(() => {
|
|
262
|
-
updateDate({
|
|
263
|
-
value: dateState.lastPublishedValue,
|
|
264
|
-
name: 'setValueFromAction',
|
|
265
|
-
pickerAction: 'accept'
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
const handleDismiss = useEventCallback(() => {
|
|
269
|
-
updateDate({
|
|
270
|
-
value: dateState.lastPublishedValue,
|
|
271
|
-
name: 'setValueFromAction',
|
|
272
|
-
pickerAction: 'dismiss'
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
const handleCancel = useEventCallback(() => {
|
|
276
|
-
updateDate({
|
|
277
|
-
value: dateState.lastCommittedValue,
|
|
278
|
-
name: 'setValueFromAction',
|
|
279
|
-
pickerAction: 'cancel'
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
const handleSetToday = useEventCallback(() => {
|
|
283
|
-
updateDate({
|
|
284
|
-
value: valueManager.getTodayValue(utils, timezone, valueType),
|
|
285
|
-
name: 'setValueFromAction',
|
|
286
|
-
pickerAction: 'today'
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
const handleOpen = useEventCallback(event => {
|
|
290
|
-
event.preventDefault();
|
|
291
|
-
setOpen(true);
|
|
292
|
-
});
|
|
293
|
-
const handleClose = useEventCallback(event => {
|
|
294
|
-
event?.preventDefault();
|
|
295
|
-
setOpen(false);
|
|
296
|
-
});
|
|
297
254
|
const handleChange = useEventCallback((newValue, selectionState = 'partial') => updateDate({
|
|
298
255
|
name: 'setValueFromView',
|
|
299
256
|
value: newValue,
|
|
@@ -310,15 +267,6 @@ export const usePickerValue = ({
|
|
|
310
267
|
value: newValue,
|
|
311
268
|
context
|
|
312
269
|
}));
|
|
313
|
-
const actions = {
|
|
314
|
-
onClear: handleClear,
|
|
315
|
-
onAccept: handleAccept,
|
|
316
|
-
onDismiss: handleDismiss,
|
|
317
|
-
onCancel: handleCancel,
|
|
318
|
-
onSetToday: handleSetToday,
|
|
319
|
-
onOpen: handleOpen,
|
|
320
|
-
onClose: handleClose
|
|
321
|
-
};
|
|
322
270
|
const fieldResponse = {
|
|
323
271
|
value: dateState.draft,
|
|
324
272
|
onChange: handleChangeFromField
|
|
@@ -327,8 +275,8 @@ export const usePickerValue = ({
|
|
|
327
275
|
const viewResponse = {
|
|
328
276
|
value: valueWithoutError,
|
|
329
277
|
onChange: handleChange,
|
|
330
|
-
|
|
331
|
-
|
|
278
|
+
open,
|
|
279
|
+
setOpen
|
|
332
280
|
};
|
|
333
281
|
const isValid = testedValue => {
|
|
334
282
|
const error = validator({
|
|
@@ -339,28 +287,62 @@ export const usePickerValue = ({
|
|
|
339
287
|
});
|
|
340
288
|
return !valueManager.hasError(error);
|
|
341
289
|
};
|
|
342
|
-
const layoutResponse =
|
|
290
|
+
const layoutResponse = {
|
|
343
291
|
value: valueWithoutError,
|
|
344
292
|
onChange: handleChange,
|
|
345
293
|
onSelectShortcut: handleSelectShortcut,
|
|
346
294
|
isValid
|
|
295
|
+
};
|
|
296
|
+
const clearValue = useEventCallback(() => updateDate({
|
|
297
|
+
value: valueManager.emptyValue,
|
|
298
|
+
name: 'setValueFromAction',
|
|
299
|
+
pickerAction: 'clear'
|
|
300
|
+
}));
|
|
301
|
+
const setValueToToday = useEventCallback(() => updateDate({
|
|
302
|
+
value: valueManager.getTodayValue(utils, timezone, valueType),
|
|
303
|
+
name: 'setValueFromAction',
|
|
304
|
+
pickerAction: 'today'
|
|
305
|
+
}));
|
|
306
|
+
const acceptValueChanges = useEventCallback(() => updateDate({
|
|
307
|
+
value: dateState.lastPublishedValue,
|
|
308
|
+
name: 'setValueFromAction',
|
|
309
|
+
pickerAction: 'accept'
|
|
310
|
+
}));
|
|
311
|
+
const cancelValueChanges = useEventCallback(() => updateDate({
|
|
312
|
+
value: dateState.lastCommittedValue,
|
|
313
|
+
name: 'setValueFromAction',
|
|
314
|
+
pickerAction: 'cancel'
|
|
315
|
+
}));
|
|
316
|
+
const dismissViews = useEventCallback(() => {
|
|
317
|
+
updateDate({
|
|
318
|
+
value: dateState.lastPublishedValue,
|
|
319
|
+
name: 'setValueFromAction',
|
|
320
|
+
pickerAction: 'dismiss'
|
|
321
|
+
});
|
|
347
322
|
});
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
323
|
+
const actionsContextValue = React.useMemo(() => ({
|
|
324
|
+
setOpen,
|
|
325
|
+
clearValue,
|
|
326
|
+
setValueToToday,
|
|
327
|
+
acceptValueChanges,
|
|
328
|
+
cancelValueChanges
|
|
329
|
+
}), [setOpen, clearValue, setValueToToday, acceptValueChanges, cancelValueChanges]);
|
|
330
|
+
const contextValue = React.useMemo(() => _extends({}, actionsContextValue, {
|
|
331
|
+
open
|
|
332
|
+
}), [actionsContextValue, open]);
|
|
333
|
+
const privateContextValue = React.useMemo(() => ({
|
|
334
|
+
dismissViews
|
|
335
|
+
}), [dismissViews]);
|
|
354
336
|
const providerParams = {
|
|
355
337
|
value: valueWithoutError,
|
|
356
|
-
contextValue
|
|
338
|
+
contextValue,
|
|
339
|
+
actionsContextValue,
|
|
340
|
+
privateContextValue
|
|
357
341
|
};
|
|
358
342
|
return {
|
|
359
|
-
open,
|
|
360
343
|
fieldProps: fieldResponse,
|
|
361
344
|
viewProps: viewResponse,
|
|
362
345
|
layoutProps: layoutResponse,
|
|
363
|
-
actions,
|
|
364
346
|
provider: providerParams
|
|
365
347
|
};
|
|
366
348
|
};
|
|
@@ -31,8 +31,9 @@ export const usePickerViews = ({
|
|
|
31
31
|
}) => {
|
|
32
32
|
const {
|
|
33
33
|
onChange,
|
|
34
|
+
value,
|
|
34
35
|
open,
|
|
35
|
-
|
|
36
|
+
setOpen
|
|
36
37
|
} = propsFromPickerValue;
|
|
37
38
|
const {
|
|
38
39
|
view: inView,
|
|
@@ -92,7 +93,7 @@ export const usePickerViews = ({
|
|
|
92
93
|
useEnhancedEffect(() => {
|
|
93
94
|
// Handle case of `DateTimePicker` without time renderers
|
|
94
95
|
if (currentViewMode === 'field' && open) {
|
|
95
|
-
|
|
96
|
+
setOpen(false);
|
|
96
97
|
setTimeout(() => {
|
|
97
98
|
fieldRef?.current?.setSelectedSections(view);
|
|
98
99
|
// focusing the input before the range selection is done
|
|
@@ -123,18 +124,18 @@ export const usePickerViews = ({
|
|
|
123
124
|
setFocusedView(newView, true);
|
|
124
125
|
}, [open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
125
126
|
|
|
126
|
-
const
|
|
127
|
+
const contextValue = React.useMemo(() => ({
|
|
127
128
|
views,
|
|
128
129
|
view: popperView,
|
|
129
130
|
onViewChange: setView
|
|
130
|
-
};
|
|
131
|
+
}), [views, popperView, setView]);
|
|
131
132
|
const providerParams = {
|
|
132
133
|
hasUIView,
|
|
133
|
-
views
|
|
134
|
+
views,
|
|
135
|
+
contextValue
|
|
134
136
|
};
|
|
135
137
|
return {
|
|
136
138
|
shouldRestoreFocus,
|
|
137
|
-
layoutProps,
|
|
138
139
|
provider: providerParams,
|
|
139
140
|
renderCurrentView: () => {
|
|
140
141
|
if (popperView == null) {
|
|
@@ -144,9 +145,10 @@ export const usePickerViews = ({
|
|
|
144
145
|
if (renderer == null) {
|
|
145
146
|
return null;
|
|
146
147
|
}
|
|
147
|
-
const rendererProps = _extends({}, propsToForwardToView, additionalViewProps,
|
|
148
|
+
const rendererProps = _extends({}, propsToForwardToView, additionalViewProps, {
|
|
148
149
|
views,
|
|
149
150
|
timezone,
|
|
151
|
+
value,
|
|
150
152
|
onChange: setValueAndGoToNextView,
|
|
151
153
|
view: popperView,
|
|
152
154
|
onViewChange: setView,
|
|
@@ -31,4 +31,4 @@ export { applyDefaultViewProps } from "./utils/views.js";
|
|
|
31
31
|
export { DayCalendar } from "../DateCalendar/DayCalendar.js";
|
|
32
32
|
export { useCalendarState } from "../DateCalendar/useCalendarState.js";
|
|
33
33
|
export { isInternalTimeView, isTimeView } from "./utils/time-utils.js";
|
|
34
|
-
export {
|
|
34
|
+
export { DateTimePickerToolbarOverrideContext } from "../DateTimePicker/DateTimePickerToolbar.js";
|
|
@@ -21,8 +21,9 @@ var _useUtils = require("../internals/hooks/useUtils");
|
|
|
21
21
|
var _datePickerToolbarClasses = require("./datePickerToolbarClasses");
|
|
22
22
|
var _dateUtils = require("../internals/utils/date-utils");
|
|
23
23
|
var _useToolbarOwnerState = require("../internals/hooks/useToolbarOwnerState");
|
|
24
|
+
var _hooks = require("../hooks");
|
|
24
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
-
const _excluded = ["value", "isLandscape", "onChange", "toolbarFormat", "toolbarPlaceholder", "
|
|
26
|
+
const _excluded = ["value", "isLandscape", "onChange", "toolbarFormat", "toolbarPlaceholder", "className", "classes"];
|
|
26
27
|
const useUtilityClasses = classes => {
|
|
27
28
|
const slots = {
|
|
28
29
|
root: ['root'],
|
|
@@ -69,12 +70,14 @@ const DatePickerToolbar = exports.DatePickerToolbar = /*#__PURE__*/React.forward
|
|
|
69
70
|
isLandscape,
|
|
70
71
|
toolbarFormat,
|
|
71
72
|
toolbarPlaceholder = '––',
|
|
72
|
-
views,
|
|
73
73
|
className,
|
|
74
74
|
classes: classesProp
|
|
75
75
|
} = props,
|
|
76
76
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
77
77
|
const utils = (0, _useUtils.useUtils)();
|
|
78
|
+
const {
|
|
79
|
+
views
|
|
80
|
+
} = (0, _hooks.usePickerContext)();
|
|
78
81
|
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
79
82
|
const ownerState = (0, _useToolbarOwnerState.useToolbarOwnerState)();
|
|
80
83
|
const classes = useUtilityClasses(classesProp);
|
|
@@ -120,12 +123,6 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
|
|
|
120
123
|
hidden: _propTypes.default.bool,
|
|
121
124
|
isLandscape: _propTypes.default.bool.isRequired,
|
|
122
125
|
onChange: _propTypes.default.func.isRequired,
|
|
123
|
-
/**
|
|
124
|
-
* Callback called when a toolbar is clicked
|
|
125
|
-
* @template TView
|
|
126
|
-
* @param {TView} view The view to open
|
|
127
|
-
*/
|
|
128
|
-
onViewChange: _propTypes.default.func.isRequired,
|
|
129
126
|
/**
|
|
130
127
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
131
128
|
*/
|
|
@@ -140,13 +137,5 @@ process.env.NODE_ENV !== "production" ? DatePickerToolbar.propTypes = {
|
|
|
140
137
|
* @default "––"
|
|
141
138
|
*/
|
|
142
139
|
toolbarPlaceholder: _propTypes.default.node,
|
|
143
|
-
value: _propTypes.default.object
|
|
144
|
-
/**
|
|
145
|
-
* Currently visible picker view.
|
|
146
|
-
*/
|
|
147
|
-
view: _propTypes.default.oneOf(['day', 'month', 'year']).isRequired,
|
|
148
|
-
/**
|
|
149
|
-
* Available views.
|
|
150
|
-
*/
|
|
151
|
-
views: _propTypes.default.arrayOf(_propTypes.default.oneOf(['day', 'month', 'year']).isRequired).isRequired
|
|
140
|
+
value: _propTypes.default.object
|
|
152
141
|
} : void 0;
|
|
@@ -19,6 +19,7 @@ var _usePickerTranslations = require("../hooks/usePickerTranslations");
|
|
|
19
19
|
var _dateTimePickerTabsClasses = require("./dateTimePickerTabsClasses");
|
|
20
20
|
var _dateUtils = require("../internals/utils/date-utils");
|
|
21
21
|
var _usePickerPrivateContext = require("../internals/hooks/usePickerPrivateContext");
|
|
22
|
+
var _hooks = require("../hooks");
|
|
22
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
24
|
const viewToTab = view => {
|
|
24
25
|
if ((0, _dateUtils.isDatePickerView)(view)) {
|
|
@@ -72,9 +73,7 @@ const DateTimePickerTabs = exports.DateTimePickerTabs = function DateTimePickerT
|
|
|
72
73
|
});
|
|
73
74
|
const {
|
|
74
75
|
dateIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DateRangeIcon, {}),
|
|
75
|
-
onViewChange,
|
|
76
76
|
timeIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.TimeIcon, {}),
|
|
77
|
-
view,
|
|
78
77
|
hidden = typeof window === 'undefined' || window.innerHeight < 667,
|
|
79
78
|
className,
|
|
80
79
|
classes: classesProp,
|
|
@@ -84,6 +83,10 @@ const DateTimePickerTabs = exports.DateTimePickerTabs = function DateTimePickerT
|
|
|
84
83
|
const {
|
|
85
84
|
ownerState
|
|
86
85
|
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
|
86
|
+
const {
|
|
87
|
+
view,
|
|
88
|
+
onViewChange
|
|
89
|
+
} = (0, _hooks.usePickerContext)();
|
|
87
90
|
const classes = useUtilityClasses(classesProp);
|
|
88
91
|
const handleChange = (event, value) => {
|
|
89
92
|
onViewChange(tabToView(value));
|
|
@@ -133,12 +136,6 @@ process.env.NODE_ENV !== "production" ? DateTimePickerTabs.propTypes = {
|
|
|
133
136
|
* @default `window.innerHeight < 667` for `DesktopDateTimePicker` and `MobileDateTimePicker`, `displayStaticWrapperAs === 'desktop'` for `StaticDateTimePicker`
|
|
134
137
|
*/
|
|
135
138
|
hidden: _propTypes.default.bool,
|
|
136
|
-
/**
|
|
137
|
-
* Callback called when a tab is clicked.
|
|
138
|
-
* @template TView
|
|
139
|
-
* @param {TView} view The view to open
|
|
140
|
-
*/
|
|
141
|
-
onViewChange: _propTypes.default.func.isRequired,
|
|
142
139
|
/**
|
|
143
140
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
144
141
|
*/
|
|
@@ -147,9 +144,5 @@ process.env.NODE_ENV !== "production" ? DateTimePickerTabs.propTypes = {
|
|
|
147
144
|
* Time tab icon.
|
|
148
145
|
* @default Time
|
|
149
146
|
*/
|
|
150
|
-
timeIcon: _propTypes.default.node
|
|
151
|
-
/**
|
|
152
|
-
* Currently visible picker view.
|
|
153
|
-
*/
|
|
154
|
-
view: _propTypes.default.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired
|
|
147
|
+
timeIcon: _propTypes.default.node
|
|
155
148
|
} : void 0;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.DateTimePickerToolbar = DateTimePickerToolbar;
|
|
10
|
-
exports.
|
|
10
|
+
exports.DateTimePickerToolbarOverrideContext = void 0;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -30,7 +30,7 @@ var _pickersToolbarClasses = require("../internals/components/pickersToolbarClas
|
|
|
30
30
|
var _usePickerContext = require("../hooks/usePickerContext");
|
|
31
31
|
var _useToolbarOwnerState = require("../internals/hooks/useToolbarOwnerState");
|
|
32
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
|
-
const _excluded = ["ampm", "ampmInClock", "value", "onChange", "
|
|
33
|
+
const _excluded = ["ampm", "ampmInClock", "value", "onChange", "isLandscape", "toolbarFormat", "toolbarPlaceholder", "toolbarTitle", "className", "classes"];
|
|
34
34
|
const useUtilityClasses = (classes, ownerState) => {
|
|
35
35
|
const {
|
|
36
36
|
pickerOrientation,
|
|
@@ -214,10 +214,11 @@ const DateTimePickerToolbarAmPmSelection = (0, _styles.styled)('div', {
|
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
* If
|
|
217
|
+
* If `forceDesktopVariant` is set to `true`, the toolbar will always be rendered in the desktop mode.
|
|
218
|
+
* If `onViewChange` is defined, the toolbar will call it instead of calling the default handler from `usePickerContext`.
|
|
218
219
|
* This is used by the Date Time Range Picker Toolbar.
|
|
219
220
|
*/
|
|
220
|
-
const
|
|
221
|
+
const DateTimePickerToolbarOverrideContext = exports.DateTimePickerToolbarOverrideContext = /*#__PURE__*/React.createContext(null);
|
|
221
222
|
|
|
222
223
|
/**
|
|
223
224
|
* Demos:
|
|
@@ -239,12 +240,9 @@ function DateTimePickerToolbar(inProps) {
|
|
|
239
240
|
ampmInClock,
|
|
240
241
|
value,
|
|
241
242
|
onChange,
|
|
242
|
-
view,
|
|
243
243
|
isLandscape,
|
|
244
|
-
onViewChange,
|
|
245
244
|
toolbarFormat,
|
|
246
245
|
toolbarPlaceholder = '––',
|
|
247
|
-
views,
|
|
248
246
|
toolbarTitle: inToolbarTitle,
|
|
249
247
|
className,
|
|
250
248
|
classes: classesProp
|
|
@@ -253,7 +251,10 @@ function DateTimePickerToolbar(inProps) {
|
|
|
253
251
|
const {
|
|
254
252
|
disabled,
|
|
255
253
|
readOnly,
|
|
256
|
-
variant
|
|
254
|
+
variant,
|
|
255
|
+
view: viewCtx,
|
|
256
|
+
onViewChange: onViewChangeCtx,
|
|
257
|
+
views
|
|
257
258
|
} = (0, _usePickerContext.usePickerContext)();
|
|
258
259
|
const ownerState = (0, _useToolbarOwnerState.useToolbarOwnerState)();
|
|
259
260
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
@@ -263,11 +264,13 @@ function DateTimePickerToolbar(inProps) {
|
|
|
263
264
|
handleMeridiemChange
|
|
264
265
|
} = (0, _dateHelpersHooks.useMeridiemMode)(value, ampm, onChange);
|
|
265
266
|
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
266
|
-
const
|
|
267
|
-
const toolbarVariant = forceDesktopVariant ? 'desktop' : variant;
|
|
267
|
+
const overrides = React.useContext(DateTimePickerToolbarOverrideContext);
|
|
268
|
+
const toolbarVariant = overrides?.forceDesktopVariant ? 'desktop' : variant;
|
|
268
269
|
const isDesktop = toolbarVariant === 'desktop';
|
|
269
270
|
const showAmPmControl = Boolean(ampm && !ampmInClock);
|
|
270
271
|
const toolbarTitle = inToolbarTitle ?? translations.dateTimePickerToolbarTitle;
|
|
272
|
+
const view = overrides ? overrides.view : viewCtx;
|
|
273
|
+
const onViewChange = overrides ? overrides.onViewChange : onViewChangeCtx;
|
|
271
274
|
const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
|
|
272
275
|
const dateText = React.useMemo(() => {
|
|
273
276
|
if (!value) {
|
|
@@ -392,12 +395,6 @@ process.env.NODE_ENV !== "production" ? DateTimePickerToolbar.propTypes = {
|
|
|
392
395
|
hidden: _propTypes.default.bool,
|
|
393
396
|
isLandscape: _propTypes.default.bool.isRequired,
|
|
394
397
|
onChange: _propTypes.default.func.isRequired,
|
|
395
|
-
/**
|
|
396
|
-
* Callback called when a toolbar is clicked
|
|
397
|
-
* @template TView
|
|
398
|
-
* @param {TView} view The view to open
|
|
399
|
-
*/
|
|
400
|
-
onViewChange: _propTypes.default.func.isRequired,
|
|
401
398
|
/**
|
|
402
399
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
403
400
|
*/
|
|
@@ -416,13 +413,5 @@ process.env.NODE_ENV !== "production" ? DateTimePickerToolbar.propTypes = {
|
|
|
416
413
|
* If provided, it will be used instead of `dateTimePickerToolbarTitle` from localization.
|
|
417
414
|
*/
|
|
418
415
|
toolbarTitle: _propTypes.default.node,
|
|
419
|
-
value: _propTypes.default.object
|
|
420
|
-
/**
|
|
421
|
-
* Currently visible picker view.
|
|
422
|
-
*/
|
|
423
|
-
view: _propTypes.default.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
424
|
-
/**
|
|
425
|
-
* Available views.
|
|
426
|
-
*/
|
|
427
|
-
views: _propTypes.default.arrayOf(_propTypes.default.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired
|
|
416
|
+
value: _propTypes.default.object
|
|
428
417
|
} : void 0;
|
|
@@ -74,16 +74,8 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
|
|
|
74
74
|
classes: _propTypes.default.object,
|
|
75
75
|
className: _propTypes.default.string,
|
|
76
76
|
isValid: _propTypes.default.func.isRequired,
|
|
77
|
-
onAccept: _propTypes.default.func.isRequired,
|
|
78
|
-
onCancel: _propTypes.default.func.isRequired,
|
|
79
77
|
onChange: _propTypes.default.func.isRequired,
|
|
80
|
-
onClear: _propTypes.default.func.isRequired,
|
|
81
|
-
onClose: _propTypes.default.func.isRequired,
|
|
82
|
-
onDismiss: _propTypes.default.func.isRequired,
|
|
83
|
-
onOpen: _propTypes.default.func.isRequired,
|
|
84
78
|
onSelectShortcut: _propTypes.default.func.isRequired,
|
|
85
|
-
onSetToday: _propTypes.default.func.isRequired,
|
|
86
|
-
onViewChange: _propTypes.default.func.isRequired,
|
|
87
79
|
/**
|
|
88
80
|
* The props used for each component slot.
|
|
89
81
|
* @default {}
|
|
@@ -98,7 +90,5 @@ process.env.NODE_ENV !== "production" ? DesktopDateTimePickerLayout.propTypes =
|
|
|
98
90
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
99
91
|
*/
|
|
100
92
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
101
|
-
value: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.object), _propTypes.default.object])
|
|
102
|
-
view: _propTypes.default.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
103
|
-
views: _propTypes.default.arrayOf(_propTypes.default.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired
|
|
93
|
+
value: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.object), _propTypes.default.object])
|
|
104
94
|
} : void 0;
|
|
@@ -15,8 +15,9 @@ var _styles = require("@mui/material/styles");
|
|
|
15
15
|
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
16
16
|
var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));
|
|
17
17
|
var _usePickerTranslations = require("../hooks/usePickerTranslations");
|
|
18
|
+
var _hooks = require("../hooks");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["
|
|
20
|
+
const _excluded = ["actions"];
|
|
20
21
|
const PickersActionBarRoot = (0, _styles.styled)(_DialogActions.default, {
|
|
21
22
|
name: 'MuiPickersLayout',
|
|
22
23
|
slot: 'ActionBar',
|
|
@@ -35,14 +36,16 @@ const PickersActionBarRoot = (0, _styles.styled)(_DialogActions.default, {
|
|
|
35
36
|
*/
|
|
36
37
|
function PickersActionBar(props) {
|
|
37
38
|
const {
|
|
38
|
-
onAccept,
|
|
39
|
-
onClear,
|
|
40
|
-
onCancel,
|
|
41
|
-
onSetToday,
|
|
42
39
|
actions
|
|
43
40
|
} = props,
|
|
44
41
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
45
42
|
const translations = (0, _usePickerTranslations.usePickerTranslations)();
|
|
43
|
+
const {
|
|
44
|
+
clearValue,
|
|
45
|
+
setValueToToday,
|
|
46
|
+
acceptValueChanges,
|
|
47
|
+
cancelValueChanges
|
|
48
|
+
} = (0, _hooks.usePickerActionsContext)();
|
|
46
49
|
if (actions == null || actions.length === 0) {
|
|
47
50
|
return null;
|
|
48
51
|
}
|
|
@@ -50,22 +53,22 @@ function PickersActionBar(props) {
|
|
|
50
53
|
switch (actionType) {
|
|
51
54
|
case 'clear':
|
|
52
55
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
53
|
-
onClick:
|
|
56
|
+
onClick: clearValue,
|
|
54
57
|
children: translations.clearButtonLabel
|
|
55
58
|
}, actionType);
|
|
56
59
|
case 'cancel':
|
|
57
60
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
58
|
-
onClick:
|
|
61
|
+
onClick: cancelValueChanges,
|
|
59
62
|
children: translations.cancelButtonLabel
|
|
60
63
|
}, actionType);
|
|
61
64
|
case 'accept':
|
|
62
65
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
63
|
-
onClick:
|
|
66
|
+
onClick: acceptValueChanges,
|
|
64
67
|
children: translations.okButtonLabel
|
|
65
68
|
}, actionType);
|
|
66
69
|
case 'today':
|
|
67
70
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
68
|
-
onClick:
|
|
71
|
+
onClick: setValueToToday,
|
|
69
72
|
children: translations.todayButtonLabel
|
|
70
73
|
}, actionType);
|
|
71
74
|
default:
|
|
@@ -92,10 +95,6 @@ process.env.NODE_ENV !== "production" ? PickersActionBar.propTypes = {
|
|
|
92
95
|
* @default false
|
|
93
96
|
*/
|
|
94
97
|
disableSpacing: _propTypes.default.bool,
|
|
95
|
-
onAccept: _propTypes.default.func.isRequired,
|
|
96
|
-
onCancel: _propTypes.default.func.isRequired,
|
|
97
|
-
onClear: _propTypes.default.func.isRequired,
|
|
98
|
-
onSetToday: _propTypes.default.func.isRequired,
|
|
99
98
|
/**
|
|
100
99
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
101
100
|
*/
|