@mui/x-date-pickers 8.0.0-alpha.7 → 8.0.0-alpha.8
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 +115 -0
- package/DateField/DateField.js +26 -31
- package/DateField/DateField.types.d.ts +6 -15
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +2 -1
- package/DateTimeField/DateTimeField.js +26 -31
- package/DateTimeField/DateTimeField.types.d.ts +6 -15
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +2 -1
- package/DesktopDatePicker/DesktopDatePicker.js +0 -11
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -12
- package/DesktopTimePicker/DesktopTimePicker.js +1 -12
- package/MobileDatePicker/MobileDatePicker.js +0 -9
- package/MobileDateTimePicker/MobileDateTimePicker.js +0 -9
- package/MobileTimePicker/MobileTimePicker.js +0 -9
- package/TimeField/TimeField.js +25 -30
- package/TimeField/TimeField.types.d.ts +6 -15
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +2 -1
- package/hooks/useParsedFormat.d.ts +8 -6
- package/hooks/useParsedFormat.js +10 -12
- package/hooks/usePickerActionsContext.d.ts +1 -1
- package/hooks/usePickerContext.d.ts +4 -2
- package/hooks/usePickerContext.js +2 -1
- package/hooks/useSplitFieldProps.d.ts +12 -3
- package/hooks/useSplitFieldProps.js +8 -3
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.d.ts +132 -0
- package/internals/components/PickerFieldUI.js +306 -0
- package/internals/components/PickerProvider.d.ts +25 -4
- package/internals/components/PickerProvider.js +11 -6
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +21 -94
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +8 -31
- package/internals/hooks/useField/index.d.ts +3 -1
- package/internals/hooks/useField/index.js +3 -2
- package/internals/hooks/useField/useField.d.ts +1 -10
- package/internals/hooks/useField/useField.js +11 -19
- package/internals/hooks/useField/useField.types.d.ts +11 -4
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +15 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +46 -0
- package/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/internals/hooks/useFieldOwnerState.d.ts +1 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.d.ts +1 -1
- package/internals/hooks/useMobilePicker/useMobilePicker.js +20 -49
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +6 -14
- package/internals/hooks/useNullablePickerContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerContext.js +10 -0
- package/internals/hooks/usePicker/usePicker.d.ts +1 -2
- package/internals/hooks/usePicker/usePicker.js +0 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -3
- package/internals/hooks/usePicker/usePickerProvider.d.ts +8 -2
- package/internals/hooks/usePicker/usePickerProvider.js +22 -2
- package/internals/hooks/usePicker/usePickerValue.js +5 -11
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +5 -2
- package/internals/hooks/useUtils.d.ts +4 -3
- package/internals/index.d.ts +6 -3
- package/internals/index.js +1 -1
- package/internals/models/fields.d.ts +3 -16
- package/internals/models/manager.d.ts +3 -0
- package/internals/models/props/basePickerProps.d.ts +0 -12
- package/locales/utils/getPickersLocalization.d.ts +0 -7
- package/locales/utils/getPickersLocalization.js +0 -13
- package/managers/index.d.ts +3 -3
- package/managers/useDateManager.d.ts +1 -1
- package/managers/useDateManager.js +9 -1
- package/managers/useDateTimeManager.d.ts +1 -1
- package/managers/useDateTimeManager.js +9 -1
- package/managers/useTimeManager.d.ts +1 -1
- package/managers/useTimeManager.js +9 -1
- package/models/fields.d.ts +4 -4
- package/models/manager.d.ts +12 -3
- package/modern/DateField/DateField.js +26 -31
- package/modern/DateField/useDateField.js +2 -1
- package/modern/DateTimeField/DateTimeField.js +26 -31
- package/modern/DateTimeField/useDateTimeField.js +2 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +0 -11
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -12
- package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -12
- package/modern/MobileDatePicker/MobileDatePicker.js +0 -9
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +0 -9
- package/modern/MobileTimePicker/MobileTimePicker.js +0 -9
- package/modern/TimeField/TimeField.js +25 -30
- package/modern/TimeField/useTimeField.js +2 -1
- package/modern/hooks/useParsedFormat.js +10 -12
- package/modern/hooks/usePickerContext.js +2 -1
- package/modern/hooks/useSplitFieldProps.js +8 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.js +306 -0
- package/modern/internals/components/PickerProvider.js +11 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +21 -94
- package/modern/internals/hooks/useField/index.js +3 -2
- package/modern/internals/hooks/useField/useField.js +11 -19
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +46 -0
- package/modern/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +20 -49
- package/modern/internals/hooks/useNullablePickerContext.js +10 -0
- package/modern/internals/hooks/usePicker/usePicker.js +0 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +22 -2
- package/modern/internals/hooks/usePicker/usePickerValue.js +5 -11
- package/modern/internals/index.js +1 -1
- package/modern/locales/utils/getPickersLocalization.js +0 -13
- package/modern/managers/useDateManager.js +9 -1
- package/modern/managers/useDateTimeManager.js +9 -1
- package/modern/managers/useTimeManager.js +9 -1
- package/node/DateField/DateField.js +26 -31
- package/node/DateField/useDateField.js +2 -1
- package/node/DateTimeField/DateTimeField.js +26 -31
- package/node/DateTimeField/useDateTimeField.js +2 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +0 -11
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -12
- package/node/DesktopTimePicker/DesktopTimePicker.js +1 -12
- package/node/MobileDatePicker/MobileDatePicker.js +0 -9
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +0 -9
- package/node/MobileTimePicker/MobileTimePicker.js +0 -9
- package/node/TimeField/TimeField.js +25 -30
- package/node/TimeField/useTimeField.js +2 -1
- package/node/hooks/useParsedFormat.js +10 -12
- package/node/hooks/usePickerContext.js +4 -3
- package/node/hooks/useSplitFieldProps.js +7 -2
- package/node/index.js +1 -1
- package/node/internals/components/PickerFieldUI.js +318 -0
- package/node/internals/components/PickerProvider.js +13 -8
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +23 -96
- package/node/internals/hooks/useField/index.js +3 -2
- package/node/internals/hooks/useField/useField.js +12 -21
- package/node/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +55 -0
- package/node/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +20 -49
- package/node/internals/hooks/useNullablePickerContext.js +16 -0
- package/node/internals/hooks/usePicker/usePicker.js +0 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +22 -2
- package/node/internals/hooks/usePicker/usePickerValue.js +5 -11
- package/node/internals/index.js +21 -3
- package/node/locales/utils/getPickersLocalization.js +2 -16
- package/node/managers/useDateManager.js +9 -1
- package/node/managers/useDateTimeManager.js +9 -1
- package/node/managers/useTimeManager.js +9 -1
- package/package.json +2 -2
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +0 -3
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -52
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["enableAccessibleFieldDOMStructure"],
|
|
4
|
+
_excluded2 = ["InputProps", "readOnly", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
|
|
5
|
+
_excluded3 = ["onPaste", "onKeyDown", "inputMode", "readOnly", "InputProps", "inputProps", "inputRef", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
|
|
6
|
+
_excluded4 = ["ownerState"],
|
|
7
|
+
_excluded5 = ["ownerState"],
|
|
8
|
+
_excluded6 = ["ownerState"],
|
|
9
|
+
_excluded7 = ["ownerState"],
|
|
10
|
+
_excluded8 = ["InputProps", "inputProps"];
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
13
|
+
import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
14
|
+
import MuiTextField from '@mui/material/TextField';
|
|
15
|
+
import MuiIconButton from '@mui/material/IconButton';
|
|
16
|
+
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
17
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
18
|
+
import { useFieldOwnerState } from "../hooks/useFieldOwnerState.js";
|
|
19
|
+
import { usePickerTranslations } from "../../hooks/index.js";
|
|
20
|
+
import { ClearIcon as MuiClearIcon } from "../../icons/index.js";
|
|
21
|
+
import { useNullablePickerContext } from "../hooks/useNullablePickerContext.js";
|
|
22
|
+
import { PickersTextField } from "../../PickersTextField/index.js";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
export const cleanFieldResponse = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
enableAccessibleFieldDOMStructure
|
|
27
|
+
} = _ref,
|
|
28
|
+
fieldResponse = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
|
+
if (enableAccessibleFieldDOMStructure) {
|
|
30
|
+
const {
|
|
31
|
+
InputProps,
|
|
32
|
+
readOnly,
|
|
33
|
+
onClear,
|
|
34
|
+
clearable,
|
|
35
|
+
clearButtonPosition,
|
|
36
|
+
openPickerButtonPosition,
|
|
37
|
+
openPickerAriaLabel
|
|
38
|
+
} = fieldResponse,
|
|
39
|
+
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded2);
|
|
40
|
+
return {
|
|
41
|
+
clearable,
|
|
42
|
+
onClear,
|
|
43
|
+
clearButtonPosition,
|
|
44
|
+
openPickerButtonPosition,
|
|
45
|
+
openPickerAriaLabel,
|
|
46
|
+
textFieldProps: _extends({}, other, {
|
|
47
|
+
InputProps: _extends({}, InputProps ?? {}, {
|
|
48
|
+
readOnly
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const {
|
|
54
|
+
onPaste,
|
|
55
|
+
onKeyDown,
|
|
56
|
+
inputMode,
|
|
57
|
+
readOnly,
|
|
58
|
+
InputProps,
|
|
59
|
+
inputProps,
|
|
60
|
+
inputRef,
|
|
61
|
+
onClear,
|
|
62
|
+
clearable,
|
|
63
|
+
clearButtonPosition,
|
|
64
|
+
openPickerButtonPosition,
|
|
65
|
+
openPickerAriaLabel
|
|
66
|
+
} = fieldResponse,
|
|
67
|
+
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded3);
|
|
68
|
+
return {
|
|
69
|
+
clearable,
|
|
70
|
+
onClear,
|
|
71
|
+
clearButtonPosition,
|
|
72
|
+
openPickerButtonPosition,
|
|
73
|
+
openPickerAriaLabel,
|
|
74
|
+
textFieldProps: _extends({}, other, {
|
|
75
|
+
InputProps: _extends({}, InputProps ?? {}, {
|
|
76
|
+
readOnly
|
|
77
|
+
}),
|
|
78
|
+
inputProps: _extends({}, inputProps ?? {}, {
|
|
79
|
+
inputMode,
|
|
80
|
+
onPaste,
|
|
81
|
+
onKeyDown,
|
|
82
|
+
ref: inputRef
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
const PickerFieldUIContext = /*#__PURE__*/React.createContext({
|
|
88
|
+
slots: {},
|
|
89
|
+
slotProps: {}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Adds the button to open the picker and the button to clear the value of the field.
|
|
94
|
+
* @ignore - internal component.
|
|
95
|
+
*/
|
|
96
|
+
export function PickerFieldUI(props) {
|
|
97
|
+
const {
|
|
98
|
+
slots,
|
|
99
|
+
slotProps,
|
|
100
|
+
fieldResponse,
|
|
101
|
+
defaultOpenPickerIcon
|
|
102
|
+
} = props;
|
|
103
|
+
const translations = usePickerTranslations();
|
|
104
|
+
const pickerContext = useNullablePickerContext();
|
|
105
|
+
const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
|
|
106
|
+
const {
|
|
107
|
+
textFieldProps,
|
|
108
|
+
onClear,
|
|
109
|
+
clearable,
|
|
110
|
+
openPickerAriaLabel,
|
|
111
|
+
clearButtonPosition: clearButtonPositionProp = 'end',
|
|
112
|
+
openPickerButtonPosition: openPickerButtonPositionProp = 'end'
|
|
113
|
+
} = cleanFieldResponse(fieldResponse);
|
|
114
|
+
const ownerState = useFieldOwnerState(textFieldProps);
|
|
115
|
+
const handleClickOpeningButton = useEventCallback(event => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
pickerContext?.setOpen(prev => !prev);
|
|
118
|
+
});
|
|
119
|
+
const triggerStatus = pickerContext ? pickerContext.triggerStatus : 'hidden';
|
|
120
|
+
const clearButtonPosition = clearable ? clearButtonPositionProp : null;
|
|
121
|
+
const openPickerButtonPosition = triggerStatus !== 'hidden' ? openPickerButtonPositionProp : null;
|
|
122
|
+
const TextField = slots?.textField ?? pickerFieldUIContext.slots.textField ?? (fieldResponse.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
|
|
123
|
+
const InputAdornment = slots?.inputAdornment ?? pickerFieldUIContext.slots.inputAdornment ?? MuiInputAdornment;
|
|
124
|
+
const _useSlotProps = useSlotProps({
|
|
125
|
+
elementType: InputAdornment,
|
|
126
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.inputAdornment, slotProps?.inputAdornment),
|
|
127
|
+
additionalProps: {
|
|
128
|
+
position: 'start'
|
|
129
|
+
},
|
|
130
|
+
ownerState: _extends({}, ownerState, {
|
|
131
|
+
position: 'start'
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
startInputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded4);
|
|
135
|
+
const _useSlotProps2 = useSlotProps({
|
|
136
|
+
elementType: InputAdornment,
|
|
137
|
+
externalSlotProps: slotProps?.inputAdornment,
|
|
138
|
+
additionalProps: {
|
|
139
|
+
position: 'end'
|
|
140
|
+
},
|
|
141
|
+
ownerState: _extends({}, ownerState, {
|
|
142
|
+
position: 'end'
|
|
143
|
+
})
|
|
144
|
+
}),
|
|
145
|
+
endInputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded5);
|
|
146
|
+
const OpenPickerButton = pickerFieldUIContext.slots.openPickerButton ?? MuiIconButton;
|
|
147
|
+
// We don't want to forward the `ownerState` to the `<IconButton />` component, see mui/material-ui#34056
|
|
148
|
+
const _useSlotProps3 = useSlotProps({
|
|
149
|
+
elementType: OpenPickerButton,
|
|
150
|
+
externalSlotProps: pickerFieldUIContext.slotProps.openPickerButton,
|
|
151
|
+
additionalProps: {
|
|
152
|
+
disabled: triggerStatus === 'disabled',
|
|
153
|
+
onClick: handleClickOpeningButton,
|
|
154
|
+
'aria-label': openPickerAriaLabel,
|
|
155
|
+
edge: clearButtonPosition === 'start' && openPickerButtonPosition === 'start' ? undefined : openPickerButtonPosition
|
|
156
|
+
},
|
|
157
|
+
ownerState
|
|
158
|
+
}),
|
|
159
|
+
openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps3, _excluded6);
|
|
160
|
+
const OpenPickerIcon = pickerFieldUIContext.slots.openPickerIcon ?? defaultOpenPickerIcon;
|
|
161
|
+
const openPickerIconProps = useSlotProps({
|
|
162
|
+
elementType: OpenPickerIcon,
|
|
163
|
+
externalSlotProps: pickerFieldUIContext.slotProps.openPickerIcon,
|
|
164
|
+
ownerState
|
|
165
|
+
});
|
|
166
|
+
const ClearButton = slots?.clearButton ?? pickerFieldUIContext.slots.clearButton ?? MuiIconButton;
|
|
167
|
+
// We don't want to forward the `ownerState` to the `<IconButton />` component, see mui/material-ui#34056
|
|
168
|
+
const _useSlotProps4 = useSlotProps({
|
|
169
|
+
elementType: ClearButton,
|
|
170
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.clearButton, slotProps?.clearButton),
|
|
171
|
+
className: 'clearButton',
|
|
172
|
+
additionalProps: {
|
|
173
|
+
title: translations.fieldClearLabel,
|
|
174
|
+
tabIndex: -1,
|
|
175
|
+
onClick: onClear,
|
|
176
|
+
disabled: fieldResponse.disabled || fieldResponse.readOnly,
|
|
177
|
+
edge: clearButtonPosition === 'end' && openPickerButtonPosition === 'end' ? undefined : clearButtonPosition
|
|
178
|
+
},
|
|
179
|
+
ownerState
|
|
180
|
+
}),
|
|
181
|
+
clearButtonProps = _objectWithoutPropertiesLoose(_useSlotProps4, _excluded7);
|
|
182
|
+
const ClearIcon = slots?.clearIcon ?? pickerFieldUIContext.slots.clearIcon ?? MuiClearIcon;
|
|
183
|
+
const clearIconProps = useSlotProps({
|
|
184
|
+
elementType: ClearIcon,
|
|
185
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.clearIcon, slotProps?.clearIcon),
|
|
186
|
+
additionalProps: {
|
|
187
|
+
fontSize: 'small'
|
|
188
|
+
},
|
|
189
|
+
ownerState
|
|
190
|
+
});
|
|
191
|
+
if (!textFieldProps.InputProps) {
|
|
192
|
+
textFieldProps.InputProps = {};
|
|
193
|
+
}
|
|
194
|
+
if (pickerContext) {
|
|
195
|
+
textFieldProps.InputProps.ref = pickerContext.triggerRef;
|
|
196
|
+
}
|
|
197
|
+
if (!textFieldProps.InputProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
|
|
198
|
+
textFieldProps.InputProps.startAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, startInputAdornmentProps, {
|
|
199
|
+
children: [openPickerButtonPosition === 'start' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
200
|
+
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
201
|
+
})), clearButtonPosition === 'start' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
|
|
202
|
+
children: /*#__PURE__*/_jsx(ClearIcon, _extends({}, clearIconProps))
|
|
203
|
+
}))]
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
if (!textFieldProps.InputProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
|
|
207
|
+
textFieldProps.InputProps.endAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, endInputAdornmentProps, {
|
|
208
|
+
children: [clearButtonPosition === 'end' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
|
|
209
|
+
children: /*#__PURE__*/_jsx(ClearIcon, _extends({}, clearIconProps))
|
|
210
|
+
})), openPickerButtonPosition === 'end' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
211
|
+
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
212
|
+
}))]
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
if (clearButtonPosition != null) {
|
|
216
|
+
textFieldProps.sx = [{
|
|
217
|
+
'& .clearButton': {
|
|
218
|
+
opacity: 1
|
|
219
|
+
},
|
|
220
|
+
'@media (pointer: fine)': {
|
|
221
|
+
'& .clearButton': {
|
|
222
|
+
opacity: 0
|
|
223
|
+
},
|
|
224
|
+
'&:hover, &:focus-within': {
|
|
225
|
+
'.clearButton': {
|
|
226
|
+
opacity: 1
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, ...(Array.isArray(textFieldProps.sx) ? textFieldProps.sx : [textFieldProps.sx])];
|
|
231
|
+
}
|
|
232
|
+
return /*#__PURE__*/_jsx(TextField, _extends({}, textFieldProps));
|
|
233
|
+
}
|
|
234
|
+
function mergeSlotProps(slotPropsA, slotPropsB) {
|
|
235
|
+
if (!slotPropsA) {
|
|
236
|
+
return slotPropsB;
|
|
237
|
+
}
|
|
238
|
+
if (!slotPropsB) {
|
|
239
|
+
return slotPropsA;
|
|
240
|
+
}
|
|
241
|
+
return ownerState => {
|
|
242
|
+
return _extends({}, resolveComponentProps(slotPropsB, ownerState), resolveComponentProps(slotPropsA, ownerState));
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
|
248
|
+
* Once the non-accessible DOM structure will be removed, we will be able to remove the `textField` slot and clean this logic.
|
|
249
|
+
*/
|
|
250
|
+
export function useFieldTextFieldProps(parameters) {
|
|
251
|
+
const {
|
|
252
|
+
ref,
|
|
253
|
+
externalForwardedProps,
|
|
254
|
+
slotProps
|
|
255
|
+
} = parameters;
|
|
256
|
+
const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
|
|
257
|
+
const ownerState = useFieldOwnerState(externalForwardedProps);
|
|
258
|
+
const {
|
|
259
|
+
InputProps,
|
|
260
|
+
inputProps
|
|
261
|
+
} = externalForwardedProps,
|
|
262
|
+
otherExternalForwardedProps = _objectWithoutPropertiesLoose(externalForwardedProps, _excluded8);
|
|
263
|
+
const textFieldProps = useSlotProps({
|
|
264
|
+
elementType: PickersTextField,
|
|
265
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.textField, slotProps?.textField),
|
|
266
|
+
externalForwardedProps: otherExternalForwardedProps,
|
|
267
|
+
additionalProps: {
|
|
268
|
+
ref
|
|
269
|
+
},
|
|
270
|
+
ownerState
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
274
|
+
textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps);
|
|
275
|
+
textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps);
|
|
276
|
+
return textFieldProps;
|
|
277
|
+
}
|
|
278
|
+
export function PickerFieldUIContextProvider(props) {
|
|
279
|
+
const {
|
|
280
|
+
slots = {},
|
|
281
|
+
slotProps = {},
|
|
282
|
+
children
|
|
283
|
+
} = props;
|
|
284
|
+
const contextValue = React.useMemo(() => ({
|
|
285
|
+
slots: {
|
|
286
|
+
openPickerButton: slots.openPickerButton,
|
|
287
|
+
openPickerIcon: slots.openPickerIcon,
|
|
288
|
+
textField: slots.textField,
|
|
289
|
+
inputAdornment: slots.inputAdornment,
|
|
290
|
+
clearIcon: slots.clearIcon,
|
|
291
|
+
clearButton: slots.clearButton
|
|
292
|
+
},
|
|
293
|
+
slotProps: {
|
|
294
|
+
openPickerButton: slotProps.openPickerButton,
|
|
295
|
+
openPickerIcon: slotProps.openPickerIcon,
|
|
296
|
+
textField: slotProps.textField,
|
|
297
|
+
inputAdornment: slotProps.inputAdornment,
|
|
298
|
+
clearIcon: slotProps.clearIcon,
|
|
299
|
+
clearButton: slotProps.clearButton
|
|
300
|
+
}
|
|
301
|
+
}), [slots.openPickerButton, slots.openPickerIcon, slots.textField, slots.inputAdornment, slots.clearIcon, slots.clearButton, slotProps.openPickerButton, slotProps.openPickerIcon, slotProps.textField, slotProps.inputAdornment, slotProps.clearIcon, slotProps.clearButton]);
|
|
302
|
+
return /*#__PURE__*/_jsx(PickerFieldUIContext.Provider, {
|
|
303
|
+
value: contextValue,
|
|
304
|
+
children: children
|
|
305
|
+
});
|
|
306
|
+
}
|
|
@@ -4,7 +4,7 @@ import { PickersInputLocaleText } from '../../locales';
|
|
|
4
4
|
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from '../models';
|
|
5
5
|
import type { UsePickerValueActionsContextValue, UsePickerValueContextValue, UsePickerValuePrivateContextValue } from '../hooks/usePicker/usePickerValue.types';
|
|
6
6
|
import { UsePickerViewsActionsContextValue, UsePickerViewsContextValue } from '../hooks/usePicker/usePickerViews';
|
|
7
|
-
|
|
7
|
+
import { PickerFieldPrivateContextValue } from '../hooks/useField/useFieldInternalPropsWithDefaults';
|
|
8
8
|
export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
|
|
9
9
|
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
|
10
10
|
/**
|
|
@@ -19,6 +19,7 @@ export interface PickerProviderProps<TValue extends PickerValidValue> {
|
|
|
19
19
|
contextValue: PickerContextValue<any, any, any>;
|
|
20
20
|
actionsContextValue: PickerActionsContextValue<any, any, any>;
|
|
21
21
|
privateContextValue: PickerPrivateContextValue;
|
|
22
|
+
fieldPrivateContextValue: PickerFieldPrivateContextValue;
|
|
22
23
|
isValidContextValue: (value: TValue) => boolean;
|
|
23
24
|
localeText: PickersInputLocaleText | undefined;
|
|
24
25
|
children: React.ReactNode;
|
|
@@ -38,7 +39,7 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
38
39
|
* Is equal to "mobile" when using a mobile picker (like <MobileDatePicker />).
|
|
39
40
|
* Is equal to "mobile" or "desktop" when using a responsive picker (like <DatePicker />) depending on the `desktopModeMediaQuery` prop.
|
|
40
41
|
* Is equal to "mobile" or "desktop" when using a static picker (like <StaticDatePicker />) depending on the `displayStaticWrapperAs` prop.
|
|
41
|
-
* Is always equal to "desktop" if the component you are accessing the
|
|
42
|
+
* Is always equal to "desktop" if the component you are accessing the context from is not wrapped by a picker.
|
|
42
43
|
*/
|
|
43
44
|
variant: PickerVariant;
|
|
44
45
|
/**
|
|
@@ -46,11 +47,31 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
46
47
|
* Is equal to "landscape" when the picker is in landscape orientation.
|
|
47
48
|
* Is equal to "portrait" when the picker is in portrait orientation.
|
|
48
49
|
* You can use the "orientation" on any picker component to force the orientation.
|
|
49
|
-
* Is always equal to "portrait" if the component you are accessing the
|
|
50
|
+
* Is always equal to "portrait" if the component you are accessing the context from is not wrapped by a picker.
|
|
50
51
|
*/
|
|
51
52
|
orientation: PickerOrientation;
|
|
53
|
+
/**
|
|
54
|
+
* The ref that should be attached to the element that triggers the Picker opening.
|
|
55
|
+
* When using a built-in field component, this property is automatically handled.
|
|
56
|
+
*/
|
|
57
|
+
triggerRef: React.RefObject<any>;
|
|
58
|
+
/**
|
|
59
|
+
* The status of the element that triggers the Picker opening.
|
|
60
|
+
* If it is "hidden", the field should not render the UI to open the Picker.
|
|
61
|
+
* If it is "disabled", the field should render a disabled UI to open the Picker.
|
|
62
|
+
* If it is "enabled", the field should render an interactive UI to open the Picker.
|
|
63
|
+
*/
|
|
64
|
+
triggerStatus: 'hidden' | 'disabled' | 'enabled';
|
|
65
|
+
/**
|
|
66
|
+
* Format that should be used to render the value in the field.
|
|
67
|
+
* Is equal to `props.format` on the picker component if defined.
|
|
68
|
+
* Is generated based on the available views if not defined.
|
|
69
|
+
* Is equal to an empty string if the picker does not have a field (static pickers).
|
|
70
|
+
* Is always equal to an empty string if the component you are accessing the context from is not wrapped by a picker.
|
|
71
|
+
*/
|
|
72
|
+
fieldFormat: string;
|
|
52
73
|
}
|
|
53
|
-
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string> extends UsePickerValueActionsContextValue<TValue, TError>, UsePickerViewsActionsContextValue<TView> {
|
|
74
|
+
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string | null> extends UsePickerValueActionsContextValue<TValue, TError>, UsePickerViewsActionsContextValue<TView> {
|
|
54
75
|
}
|
|
55
76
|
export interface PickerPrivateContextValue extends UsePickerValuePrivateContextValue {
|
|
56
77
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LocalizationProvider } from "../../LocalizationProvider/index.js";
|
|
3
3
|
import { IsValidValueContext } from "../../hooks/useIsValidValue.js";
|
|
4
|
+
import { PickerFieldPrivateContext } from "../hooks/useField/useFieldInternalPropsWithDefaults.js";
|
|
5
|
+
import { PickerContext } from "../../hooks/usePickerContext.js";
|
|
4
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
export const PickerContext = /*#__PURE__*/React.createContext(null);
|
|
6
7
|
export const PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
7
8
|
export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
8
9
|
ownerState: {
|
|
@@ -28,6 +29,7 @@ export function PickerProvider(props) {
|
|
|
28
29
|
contextValue,
|
|
29
30
|
actionsContextValue,
|
|
30
31
|
privateContextValue,
|
|
32
|
+
fieldPrivateContextValue,
|
|
31
33
|
isValidContextValue,
|
|
32
34
|
localeText,
|
|
33
35
|
children
|
|
@@ -38,11 +40,14 @@ export function PickerProvider(props) {
|
|
|
38
40
|
value: actionsContextValue,
|
|
39
41
|
children: /*#__PURE__*/_jsx(PickerPrivateContext.Provider, {
|
|
40
42
|
value: privateContextValue,
|
|
41
|
-
children: /*#__PURE__*/_jsx(
|
|
42
|
-
value:
|
|
43
|
-
children: /*#__PURE__*/_jsx(
|
|
44
|
-
|
|
45
|
-
children:
|
|
43
|
+
children: /*#__PURE__*/_jsx(PickerFieldPrivateContext.Provider, {
|
|
44
|
+
value: fieldPrivateContextValue,
|
|
45
|
+
children: /*#__PURE__*/_jsx(IsValidValueContext.Provider, {
|
|
46
|
+
value: isValidContextValue,
|
|
47
|
+
children: /*#__PURE__*/_jsx(LocalizationProvider, {
|
|
48
|
+
localeText: localeText,
|
|
49
|
+
children: children
|
|
50
|
+
})
|
|
46
51
|
})
|
|
47
52
|
})
|
|
48
53
|
})
|
|
@@ -7,6 +7,6 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
|
7
7
|
* - DesktopDateTimePicker
|
|
8
8
|
* - DesktopTimePicker
|
|
9
9
|
*/
|
|
10
|
-
export declare const useDesktopPicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({ props,
|
|
10
|
+
export declare const useDesktopPicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({ props, ...pickerParams }: UseDesktopPickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
|
11
11
|
renderPicker: () => React.JSX.Element;
|
|
12
12
|
};
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["props"
|
|
4
|
-
_excluded2 = ["ownerState"],
|
|
5
|
-
_excluded3 = ["ownerState"];
|
|
3
|
+
const _excluded = ["props"];
|
|
6
4
|
import * as React from 'react';
|
|
7
5
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
8
|
-
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
9
|
-
import IconButton from '@mui/material/IconButton';
|
|
10
6
|
import useForkRef from '@mui/utils/useForkRef';
|
|
11
7
|
import useId from '@mui/utils/useId';
|
|
12
8
|
import { PickersPopper } from "../../components/PickersPopper.js";
|
|
13
9
|
import { usePicker } from "../usePicker/index.js";
|
|
14
10
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
15
11
|
import { PickerProvider } from "../../components/PickerProvider.js";
|
|
12
|
+
import { PickerFieldUIContextProvider } from "../../components/PickerFieldUI.js";
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* Hook managing all the single-date desktop pickers:
|
|
@@ -23,8 +20,7 @@ import { PickerProvider } from "../../components/PickerProvider.js";
|
|
|
23
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
21
|
export const useDesktopPicker = _ref => {
|
|
25
22
|
let {
|
|
26
|
-
props
|
|
27
|
-
getOpenDialogAriaText
|
|
23
|
+
props
|
|
28
24
|
} = _ref,
|
|
29
25
|
pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
26
|
const {
|
|
@@ -32,31 +28,21 @@ export const useDesktopPicker = _ref => {
|
|
|
32
28
|
slotProps: innerSlotProps,
|
|
33
29
|
className,
|
|
34
30
|
sx,
|
|
35
|
-
format,
|
|
36
|
-
formatDensity,
|
|
37
|
-
enableAccessibleFieldDOMStructure,
|
|
38
|
-
selectedSections,
|
|
39
|
-
onSelectedSectionsChange,
|
|
40
|
-
timezone,
|
|
41
31
|
name,
|
|
42
32
|
label,
|
|
43
33
|
inputRef,
|
|
44
34
|
readOnly,
|
|
45
|
-
disabled,
|
|
46
35
|
autoFocus,
|
|
47
36
|
localeText,
|
|
48
37
|
reduceAnimations
|
|
49
38
|
} = props;
|
|
50
|
-
const containerRef = React.useRef(null);
|
|
51
39
|
const fieldRef = React.useRef(null);
|
|
52
40
|
const labelId = useId();
|
|
53
41
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
54
42
|
const {
|
|
55
|
-
hasUIView,
|
|
56
43
|
providerProps,
|
|
57
44
|
renderCurrentView,
|
|
58
45
|
shouldRestoreFocus,
|
|
59
|
-
fieldProps: pickerFieldProps,
|
|
60
46
|
ownerState
|
|
61
47
|
} = usePicker(_extends({}, pickerParams, {
|
|
62
48
|
props,
|
|
@@ -65,39 +51,6 @@ export const useDesktopPicker = _ref => {
|
|
|
65
51
|
autoFocusView: true,
|
|
66
52
|
variant: 'desktop'
|
|
67
53
|
}));
|
|
68
|
-
const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
|
|
69
|
-
const _useSlotProps = useSlotProps({
|
|
70
|
-
elementType: InputAdornment,
|
|
71
|
-
externalSlotProps: innerSlotProps?.inputAdornment,
|
|
72
|
-
additionalProps: {
|
|
73
|
-
position: 'end'
|
|
74
|
-
},
|
|
75
|
-
ownerState
|
|
76
|
-
}),
|
|
77
|
-
inputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
78
|
-
const OpenPickerButton = slots.openPickerButton ?? IconButton;
|
|
79
|
-
const _useSlotProps2 = useSlotProps({
|
|
80
|
-
elementType: OpenPickerButton,
|
|
81
|
-
externalSlotProps: innerSlotProps?.openPickerButton,
|
|
82
|
-
additionalProps: {
|
|
83
|
-
disabled: disabled || readOnly,
|
|
84
|
-
// This direct access to `providerProps` will go away in https://github.com/mui/mui-x/pull/15671
|
|
85
|
-
onClick: event => {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
providerProps.contextValue.setOpen(prevOpen => !prevOpen);
|
|
88
|
-
},
|
|
89
|
-
'aria-label': getOpenDialogAriaText(pickerFieldProps.value),
|
|
90
|
-
edge: inputAdornmentProps.position
|
|
91
|
-
},
|
|
92
|
-
ownerState
|
|
93
|
-
}),
|
|
94
|
-
openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);
|
|
95
|
-
const OpenPickerIcon = slots.openPickerIcon;
|
|
96
|
-
const openPickerIconProps = useSlotProps({
|
|
97
|
-
elementType: OpenPickerIcon,
|
|
98
|
-
externalSlotProps: innerSlotProps?.openPickerIcon,
|
|
99
|
-
ownerState
|
|
100
|
-
});
|
|
101
54
|
const Field = slots.field;
|
|
102
55
|
const fieldProps = useSlotProps({
|
|
103
56
|
elementType: Field,
|
|
@@ -105,17 +58,7 @@ export const useDesktopPicker = _ref => {
|
|
|
105
58
|
additionalProps: _extends({
|
|
106
59
|
// Internal props
|
|
107
60
|
readOnly,
|
|
108
|
-
|
|
109
|
-
format,
|
|
110
|
-
formatDensity,
|
|
111
|
-
enableAccessibleFieldDOMStructure,
|
|
112
|
-
selectedSections,
|
|
113
|
-
onSelectedSectionsChange,
|
|
114
|
-
timezone,
|
|
115
|
-
autoFocus: autoFocus && !props.open
|
|
116
|
-
}, pickerFieldProps, {
|
|
117
|
-
// onChange and value
|
|
118
|
-
|
|
61
|
+
autoFocus: autoFocus && !props.open,
|
|
119
62
|
// Forwarded props
|
|
120
63
|
className,
|
|
121
64
|
sx,
|
|
@@ -129,24 +72,6 @@ export const useDesktopPicker = _ref => {
|
|
|
129
72
|
}),
|
|
130
73
|
ownerState
|
|
131
74
|
});
|
|
132
|
-
|
|
133
|
-
// TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
|
|
134
|
-
if (hasUIView) {
|
|
135
|
-
fieldProps.InputProps = _extends({}, fieldProps.InputProps, {
|
|
136
|
-
ref: containerRef
|
|
137
|
-
}, !props.disableOpenPicker && {
|
|
138
|
-
[`${inputAdornmentProps.position}Adornment`]: /*#__PURE__*/_jsx(InputAdornment, _extends({}, inputAdornmentProps, {
|
|
139
|
-
children: /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
140
|
-
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
141
|
-
}))
|
|
142
|
-
}))
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
const slotsForField = _extends({
|
|
146
|
-
textField: slots.textField,
|
|
147
|
-
clearIcon: slots.clearIcon,
|
|
148
|
-
clearButton: slots.clearButton
|
|
149
|
-
}, fieldProps.slots);
|
|
150
75
|
const Layout = slots.layout ?? PickersLayout;
|
|
151
76
|
let labelledById = labelId;
|
|
152
77
|
if (isToolbarHidden) {
|
|
@@ -165,25 +90,27 @@ export const useDesktopPicker = _ref => {
|
|
|
165
90
|
}, innerSlotProps?.popper)
|
|
166
91
|
});
|
|
167
92
|
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
168
|
-
const renderPicker = () => /*#__PURE__*/
|
|
169
|
-
children:
|
|
170
|
-
slots: slotsForField,
|
|
171
|
-
slotProps: slotProps,
|
|
172
|
-
unstableFieldRef: handleFieldRef
|
|
173
|
-
})), /*#__PURE__*/_jsx(PickersPopper, {
|
|
174
|
-
role: "dialog",
|
|
175
|
-
placement: "bottom-start",
|
|
176
|
-
anchorEl: containerRef.current,
|
|
93
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
94
|
+
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
177
95
|
slots: slots,
|
|
178
96
|
slotProps: slotProps,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
97
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
98
|
+
unstableFieldRef: handleFieldRef
|
|
99
|
+
})), /*#__PURE__*/_jsx(PickersPopper, {
|
|
100
|
+
role: "dialog",
|
|
101
|
+
placement: "bottom-start",
|
|
102
|
+
anchorEl: providerProps.contextValue.triggerRef.current,
|
|
182
103
|
slots: slots,
|
|
183
104
|
slotProps: slotProps,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
105
|
+
shouldRestoreFocus: shouldRestoreFocus,
|
|
106
|
+
reduceAnimations: reduceAnimations,
|
|
107
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
108
|
+
slots: slots,
|
|
109
|
+
slotProps: slotProps,
|
|
110
|
+
children: renderCurrentView()
|
|
111
|
+
}))
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
187
114
|
}));
|
|
188
115
|
return {
|
|
189
116
|
renderPicker
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
-
import type { InputAdornmentProps } from '@mui/material/InputAdornment';
|
|
4
|
-
import type { TextFieldProps } from '@mui/material/TextField';
|
|
5
2
|
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
6
|
-
import {
|
|
3
|
+
import { BasePickerProps, BaseNonRangeNonStaticPickerProps } from '../../models/props/basePickerProps';
|
|
7
4
|
import { PickersPopperSlots, PickersPopperSlotProps } from '../../components/PickersPopper';
|
|
8
5
|
import { UsePickerParams } from '../usePicker';
|
|
9
|
-
import {
|
|
6
|
+
import { PickerFieldSlotProps, PickerOwnerState } from '../../../models';
|
|
10
7
|
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from '../../../PickersLayout/PickersLayout.types';
|
|
11
8
|
import { UsePickerValueNonStaticProps } from '../usePicker/usePickerValue.types';
|
|
12
9
|
import { UsePickerViewsProps } from '../usePicker/usePickerViews';
|
|
13
10
|
import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
|
|
14
|
-
import {
|
|
15
|
-
import { PickersTextFieldProps } from '../../../PickersTextField';
|
|
11
|
+
import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from '../../components/PickerFieldUI';
|
|
16
12
|
import { UsePickerProviderNonStaticProps } from '../usePicker/usePickerProvider';
|
|
17
|
-
export interface UseDesktopPickerSlots extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>,
|
|
13
|
+
export interface UseDesktopPickerSlots extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
|
|
18
14
|
/**
|
|
19
15
|
* Component used to enter the date with the keyboard.
|
|
20
16
|
*/
|
|
@@ -24,31 +20,13 @@ export interface UseDesktopPickerSlots extends Pick<PickersPopperSlots, 'desktop
|
|
|
24
20
|
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
|
|
25
21
|
*/
|
|
26
22
|
textField?: React.ElementType;
|
|
27
|
-
/**
|
|
28
|
-
* Component displayed on the start or end input adornment used to open the picker on desktop.
|
|
29
|
-
* @default InputAdornment
|
|
30
|
-
*/
|
|
31
|
-
inputAdornment?: React.ElementType<InputAdornmentProps>;
|
|
32
|
-
/**
|
|
33
|
-
* Button to open the picker on desktop.
|
|
34
|
-
* @default IconButton
|
|
35
|
-
*/
|
|
36
|
-
openPickerButton?: React.ElementType<IconButtonProps>;
|
|
37
|
-
/**
|
|
38
|
-
* Icon displayed in the open picker button on desktop.
|
|
39
|
-
*/
|
|
40
|
-
openPickerIcon: React.ElementType;
|
|
41
|
-
}
|
|
42
|
-
export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {
|
|
43
23
|
}
|
|
44
|
-
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>,
|
|
24
|
+
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
|
45
25
|
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
46
|
-
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
47
|
-
inputAdornment?: SlotComponentPropsFromProps<InputAdornmentProps, {}, PickerOwnerState>;
|
|
48
|
-
openPickerButton?: SlotComponentPropsFromProps<IconButtonProps, {}, PickerOwnerState>;
|
|
49
|
-
openPickerIcon?: SlotComponentPropsFromProps<Record<string, any>, {}, PickerOwnerState>;
|
|
50
26
|
}
|
|
51
|
-
export interface
|
|
27
|
+
export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {
|
|
28
|
+
}
|
|
29
|
+
export interface DesktopOnlyPickerProps extends BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps {
|
|
52
30
|
/**
|
|
53
31
|
* If `true`, the `input` element is focused during the first mount.
|
|
54
32
|
* @default false
|
|
@@ -69,5 +47,4 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
69
47
|
}
|
|
70
48
|
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
|
|
71
49
|
props: TExternalProps;
|
|
72
|
-
getOpenDialogAriaText: (date: PickerValidDate | null) => string;
|
|
73
50
|
}
|