@mui/x-date-pickers 8.0.0-alpha.12 → 8.0.0-alpha.13
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/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +96 -94
- package/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/AdapterDateFnsV2/AdapterDateFnsV2.js +96 -94
- package/AdapterDayjs/AdapterDayjs.js +11 -5
- package/CHANGELOG.md +299 -0
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DatePicker/DatePicker.types.d.ts +2 -2
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/TimeClock/Clock.js +2 -2
- package/TimeClock/ClockPointer.js +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
- package/esm/AdapterDayjs/AdapterDayjs.js +9 -5
- package/esm/DateCalendar/DateCalendar.js +1 -1
- package/esm/DateField/useDateField.d.ts +1 -1
- package/esm/DatePicker/DatePicker.types.d.ts +2 -2
- package/esm/DateTimeField/useDateTimeField.d.ts +1 -1
- package/esm/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/esm/TimeClock/Clock.js +2 -2
- package/esm/TimeClock/ClockPointer.js +1 -1
- package/esm/TimeField/useTimeField.d.ts +1 -1
- package/esm/TimePicker/TimePicker.types.d.ts +2 -2
- package/esm/hooks/useSplitFieldProps.d.ts +1 -1
- package/esm/hooks/useSplitFieldProps.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.d.ts +7 -0
- package/esm/internals/components/PickerFieldUI.js +2 -2
- package/esm/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/esm/internals/components/PickerPopper/PickerPopper.js +26 -14
- package/esm/internals/components/PickerProvider.d.ts +21 -1
- package/esm/internals/components/PickerProvider.js +7 -2
- package/esm/internals/demo/DemoContainer.js +3 -3
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +0 -5
- package/esm/internals/hooks/useField/index.d.ts +1 -2
- package/esm/internals/hooks/useField/useField.types.d.ts +10 -4
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/esm/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
- package/esm/internals/hooks/useField/useFieldV6TextField.js +8 -6
- package/esm/internals/hooks/useField/useFieldV7TextField.js +7 -7
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/esm/internals/hooks/useNullableFieldPrivateContext.d.ts +6 -0
- package/esm/internals/hooks/useNullableFieldPrivateContext.js +5 -0
- package/esm/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/esm/internals/hooks/usePicker/usePicker.js +2 -2
- package/esm/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/esm/internals/hooks/usePicker/usePickerProvider.d.ts +8 -3
- package/esm/internals/hooks/usePicker/usePickerProvider.js +20 -6
- package/esm/internals/hooks/usePicker/usePickerViews.d.ts +20 -3
- package/esm/internals/hooks/usePicker/usePickerViews.js +20 -8
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/esm/internals/index.d.ts +4 -3
- package/esm/internals/index.js +2 -1
- package/esm/internals/models/fields.d.ts +3 -10
- package/esm/locales/bnBD.d.ts +80 -0
- package/esm/locales/bnBD.js +73 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/models/fields.d.ts +2 -2
- package/esm/validation/extractValidationProps.d.ts +1 -1
- package/esm/validation/index.d.ts +1 -1
- package/esm/validation/useValidation.d.ts +1 -1
- package/hooks/useSplitFieldProps.d.ts +1 -1
- package/hooks/useSplitFieldProps.js +1 -1
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.d.ts +7 -0
- package/internals/components/PickerFieldUI.js +3 -1
- package/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/internals/components/PickerPopper/PickerPopper.js +25 -13
- package/internals/components/PickerProvider.d.ts +21 -1
- package/internals/components/PickerProvider.js +8 -3
- package/internals/demo/DemoContainer.js +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +0 -5
- package/internals/hooks/useField/index.d.ts +1 -2
- package/internals/hooks/useField/useField.types.d.ts +10 -4
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -10
- package/internals/hooks/useField/useFieldV6TextField.js +8 -6
- package/internals/hooks/useField/useFieldV7TextField.js +7 -7
- package/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/internals/hooks/useNullableFieldPrivateContext.d.ts +6 -0
- package/internals/hooks/useNullableFieldPrivateContext.js +13 -0
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +2 -2
- package/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerProvider.d.ts +8 -3
- package/internals/hooks/usePicker/usePickerProvider.js +20 -6
- package/internals/hooks/usePicker/usePickerViews.d.ts +20 -3
- package/internals/hooks/usePicker/usePickerViews.js +20 -8
- package/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/internals/index.d.ts +4 -3
- package/internals/index.js +19 -0
- package/internals/models/fields.d.ts +3 -10
- package/locales/bnBD.d.ts +80 -0
- package/locales/bnBD.js +79 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/models/fields.d.ts +2 -2
- package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts +1 -1
- package/modern/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +47 -45
- package/modern/AdapterDateFnsV2/AdapterDateFnsV2.d.ts +1 -1
- package/modern/AdapterDateFnsV2/AdapterDateFnsV2.js +47 -45
- package/modern/AdapterDayjs/AdapterDayjs.js +9 -5
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/useDateField.d.ts +1 -1
- package/modern/DatePicker/DatePicker.types.d.ts +2 -2
- package/modern/DateTimeField/useDateTimeField.d.ts +1 -1
- package/modern/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/modern/TimeClock/Clock.js +2 -2
- package/modern/TimeClock/ClockPointer.js +1 -1
- package/modern/TimeField/useTimeField.d.ts +1 -1
- package/modern/TimePicker/TimePicker.types.d.ts +2 -2
- package/modern/hooks/useSplitFieldProps.d.ts +1 -1
- package/modern/hooks/useSplitFieldProps.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerFieldUI.d.ts +7 -0
- package/modern/internals/components/PickerFieldUI.js +2 -2
- package/modern/internals/components/PickerPopper/PickerPopper.d.ts +0 -3
- package/modern/internals/components/PickerPopper/PickerPopper.js +26 -14
- package/modern/internals/components/PickerProvider.d.ts +21 -1
- package/modern/internals/components/PickerProvider.js +7 -2
- package/modern/internals/demo/DemoContainer.js +3 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +5 -22
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +0 -5
- package/modern/internals/hooks/useField/index.d.ts +1 -2
- package/modern/internals/hooks/useField/useField.types.d.ts +10 -4
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +9 -9
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +16 -8
- package/modern/internals/hooks/useField/useFieldV6TextField.js +8 -6
- package/modern/internals/hooks/useField/useFieldV7TextField.js +7 -7
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +5 -21
- package/modern/internals/hooks/useNullableFieldPrivateContext.d.ts +6 -0
- package/modern/internals/hooks/useNullableFieldPrivateContext.js +5 -0
- package/modern/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/modern/internals/hooks/usePicker/usePicker.js +2 -2
- package/modern/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/modern/internals/hooks/usePicker/usePickerProvider.d.ts +8 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +20 -6
- package/modern/internals/hooks/usePicker/usePickerViews.d.ts +20 -3
- package/modern/internals/hooks/usePicker/usePickerViews.js +20 -8
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +3 -2
- package/modern/internals/index.d.ts +4 -3
- package/modern/internals/index.js +2 -1
- package/modern/internals/models/fields.d.ts +3 -10
- package/modern/locales/bnBD.d.ts +80 -0
- package/modern/locales/bnBD.js +73 -0
- package/modern/locales/index.d.ts +1 -0
- package/modern/locales/index.js +1 -0
- package/modern/models/fields.d.ts +2 -2
- package/modern/validation/extractValidationProps.d.ts +1 -1
- package/modern/validation/index.d.ts +1 -1
- package/modern/validation/useValidation.d.ts +1 -1
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/validation/extractValidationProps.d.ts +1 -1
- package/validation/index.d.ts +1 -1
- package/validation/useValidation.d.ts +1 -1
|
@@ -11,7 +11,7 @@ import BaseFocusTrap from '@mui/material/Unstable_TrapFocus';
|
|
|
11
11
|
import { unstable_useForkRef as useForkRef, unstable_useEventCallback as useEventCallback, unstable_ownerDocument as ownerDocument, unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
12
12
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
13
13
|
import { getPickerPopperUtilityClass } from "./pickerPopperClasses.js";
|
|
14
|
-
import { getActiveElement } from "../../utils/utils.js";
|
|
14
|
+
import { executeInTheNextEventLoopTick, getActiveElement } from "../../utils/utils.js";
|
|
15
15
|
import { usePickerPrivateContext } from "../../hooks/usePickerPrivateContext.js";
|
|
16
16
|
import { usePickerContext } from "../../../hooks/index.js";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -206,9 +206,6 @@ export function PickerPopper(inProps) {
|
|
|
206
206
|
});
|
|
207
207
|
const {
|
|
208
208
|
children,
|
|
209
|
-
containerRef = null,
|
|
210
|
-
onBlur,
|
|
211
|
-
role,
|
|
212
209
|
placement = 'bottom-start',
|
|
213
210
|
slots,
|
|
214
211
|
slotProps,
|
|
@@ -217,11 +214,13 @@ export function PickerPopper(inProps) {
|
|
|
217
214
|
const {
|
|
218
215
|
open,
|
|
219
216
|
triggerRef,
|
|
217
|
+
popupRef,
|
|
220
218
|
reduceAnimations
|
|
221
219
|
} = usePickerContext();
|
|
222
220
|
const {
|
|
223
221
|
dismissViews,
|
|
224
|
-
doesTheCurrentViewHasAnUI
|
|
222
|
+
doesTheCurrentViewHasAnUI,
|
|
223
|
+
viewContainerRole
|
|
225
224
|
} = usePickerPrivateContext();
|
|
226
225
|
React.useEffect(() => {
|
|
227
226
|
function handleKeyDown(nativeEvent) {
|
|
@@ -236,7 +235,7 @@ export function PickerPopper(inProps) {
|
|
|
236
235
|
}, [dismissViews, open]);
|
|
237
236
|
const lastFocusedElementRef = React.useRef(null);
|
|
238
237
|
React.useEffect(() => {
|
|
239
|
-
if (
|
|
238
|
+
if (viewContainerRole === 'tooltip' || !doesTheCurrentViewHasAnUI()) {
|
|
240
239
|
return;
|
|
241
240
|
}
|
|
242
241
|
if (open) {
|
|
@@ -250,18 +249,31 @@ export function PickerPopper(inProps) {
|
|
|
250
249
|
}
|
|
251
250
|
});
|
|
252
251
|
}
|
|
253
|
-
}, [open,
|
|
254
|
-
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, onBlur ?? dismissViews);
|
|
255
|
-
const paperRef = React.useRef(null);
|
|
256
|
-
const handleRef = useForkRef(paperRef, containerRef);
|
|
257
|
-
const handlePaperRef = useForkRef(handleRef, clickAwayRef);
|
|
252
|
+
}, [open, viewContainerRole, doesTheCurrentViewHasAnUI]);
|
|
258
253
|
const classes = useUtilityClasses(classesProp);
|
|
259
254
|
const {
|
|
260
|
-
ownerState: pickerOwnerState
|
|
255
|
+
ownerState: pickerOwnerState,
|
|
256
|
+
rootRefObject
|
|
261
257
|
} = usePickerPrivateContext();
|
|
262
258
|
const ownerState = _extends({}, pickerOwnerState, {
|
|
263
259
|
popperPlacement: placement
|
|
264
260
|
});
|
|
261
|
+
const handleClickAway = useEventCallback(() => {
|
|
262
|
+
if (viewContainerRole === 'tooltip') {
|
|
263
|
+
executeInTheNextEventLoopTick(() => {
|
|
264
|
+
if (rootRefObject.current?.contains(getActiveElement(document)) || popupRef.current?.contains(getActiveElement(document))) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
dismissViews();
|
|
268
|
+
});
|
|
269
|
+
} else {
|
|
270
|
+
dismissViews();
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, handleClickAway);
|
|
274
|
+
const paperRef = React.useRef(null);
|
|
275
|
+
const handleRef = useForkRef(paperRef, popupRef);
|
|
276
|
+
const handlePaperRef = useForkRef(handleRef, clickAwayRef);
|
|
265
277
|
const handleKeyDown = event => {
|
|
266
278
|
if (event.key === 'Escape') {
|
|
267
279
|
// stop the propagation to avoid closing parent modal
|
|
@@ -278,7 +290,7 @@ export function PickerPopper(inProps) {
|
|
|
278
290
|
externalSlotProps: slotProps?.popper,
|
|
279
291
|
additionalProps: {
|
|
280
292
|
transition: true,
|
|
281
|
-
role,
|
|
293
|
+
role: viewContainerRole == null ? undefined : viewContainerRole,
|
|
282
294
|
open,
|
|
283
295
|
placement,
|
|
284
296
|
anchorEl: triggerRef.current,
|
|
@@ -298,7 +310,7 @@ export function PickerPopper(inProps) {
|
|
|
298
310
|
// which would force screen readers to read too old label
|
|
299
311
|
,
|
|
300
312
|
disableRestoreFocus: true,
|
|
301
|
-
disableEnforceFocus:
|
|
313
|
+
disableEnforceFocus: viewContainerRole === 'tooltip',
|
|
302
314
|
isEnabled: () => true
|
|
303
315
|
}, slotProps?.desktopTrapFocus, {
|
|
304
316
|
children: /*#__PURE__*/_jsx(Transition, _extends({}, TransitionProps, slotProps?.desktopTransition, {
|
|
@@ -6,7 +6,7 @@ import { PickersInputLocaleText } from "../../locales/index.js";
|
|
|
6
6
|
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from "../models/index.js";
|
|
7
7
|
import type { UsePickerValueActionsContextValue, UsePickerValueContextValue, UsePickerValuePrivateContextValue } from '../hooks/usePicker/usePickerValue.types';
|
|
8
8
|
import { UsePickerViewsActionsContextValue, UsePickerViewsContextValue, UsePickerViewsPrivateContextValue } from "../hooks/usePicker/usePickerViews.js";
|
|
9
|
-
import { PickerFieldPrivateContextValue } from "../hooks/
|
|
9
|
+
import { PickerFieldPrivateContextValue } from "../hooks/useNullableFieldPrivateContext.js";
|
|
10
10
|
export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
|
|
11
11
|
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
|
12
12
|
/**
|
|
@@ -35,6 +35,12 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
35
35
|
* Whether the picker is read-only.
|
|
36
36
|
*/
|
|
37
37
|
readOnly: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the picker should be focused on mount.
|
|
40
|
+
* If the picker has a field and is not open, the field should be focused.
|
|
41
|
+
* If the picker does not have a field (if it is a static picker) or is not open, the view should be focused.
|
|
42
|
+
*/
|
|
43
|
+
autoFocus: boolean;
|
|
38
44
|
/**
|
|
39
45
|
* The responsive variant of the picker.
|
|
40
46
|
* It is equal to "desktop" when using a desktop picker (like <DesktopDatePicker />).
|
|
@@ -68,6 +74,11 @@ export interface PickerContextValue<TValue extends PickerValidValue, TView exten
|
|
|
68
74
|
* If it is "enabled", the field should render an interactive UI to open the Picker.
|
|
69
75
|
*/
|
|
70
76
|
triggerStatus: 'hidden' | 'disabled' | 'enabled';
|
|
77
|
+
/**
|
|
78
|
+
* The ref to attach to the popup's outermost element that contains the view, if any.
|
|
79
|
+
* When using a built-in popup component, this property is automatically attached to the appropriate element.
|
|
80
|
+
*/
|
|
81
|
+
popupRef: React.RefObject<any>;
|
|
71
82
|
/**
|
|
72
83
|
* The format to use when rendering the value in the field.
|
|
73
84
|
* It is equal to the picker `format` prop if defined.
|
|
@@ -117,4 +128,13 @@ export interface PickerPrivateContextValue extends UsePickerValuePrivateContextV
|
|
|
117
128
|
* The ownerState of the picker.
|
|
118
129
|
*/
|
|
119
130
|
ownerState: PickerOwnerState;
|
|
131
|
+
/**
|
|
132
|
+
* The ref of the root element.
|
|
133
|
+
* This is the object counterpart of the `usePickerContext().rootRef` property which can be a function.
|
|
134
|
+
*/
|
|
135
|
+
rootRefObject: React.RefObject<HTMLDivElement | null>;
|
|
136
|
+
/**
|
|
137
|
+
* The id of the label element.
|
|
138
|
+
*/
|
|
139
|
+
labelId: string | undefined;
|
|
120
140
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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/
|
|
4
|
+
import { PickerFieldPrivateContext } from "../hooks/useNullableFieldPrivateContext.js";
|
|
5
5
|
import { PickerContext } from "../../hooks/usePickerContext.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
@@ -16,7 +16,12 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
|
16
16
|
},
|
|
17
17
|
dismissViews: () => {},
|
|
18
18
|
hasUIView: true,
|
|
19
|
-
doesTheCurrentViewHasAnUI: () => true
|
|
19
|
+
doesTheCurrentViewHasAnUI: () => true,
|
|
20
|
+
rootRefObject: {
|
|
21
|
+
current: null
|
|
22
|
+
},
|
|
23
|
+
viewContainerRole: null,
|
|
24
|
+
labelId: undefined
|
|
20
25
|
});
|
|
21
26
|
|
|
22
27
|
/**
|
|
@@ -15,10 +15,10 @@ const getChildTypeFromChildName = childName => {
|
|
|
15
15
|
if (childName.match(/^Static([A-Za-z]+)/) || childName.match(/^([A-Za-z]+)(Calendar|Clock)$/)) {
|
|
16
16
|
return 'UI-view';
|
|
17
17
|
}
|
|
18
|
-
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)
|
|
18
|
+
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)) {
|
|
19
19
|
return 'multi-input-range-field';
|
|
20
20
|
}
|
|
21
|
-
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/)) {
|
|
21
|
+
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/) || childName.match(/^([A-Za-z]+)RangePicker$/)) {
|
|
22
22
|
return 'single-input-range-field';
|
|
23
23
|
}
|
|
24
24
|
return 'single-input-field';
|
|
@@ -133,7 +133,7 @@ export function DemoContainer(props) {
|
|
|
133
133
|
minWidth: {
|
|
134
134
|
xs: 300,
|
|
135
135
|
// If demo also contains MultiInputDateTimeRangeField, increase width to avoid cutting off the value.
|
|
136
|
-
md: childrenTypes.has('multi-input-range-field') ? 460 :
|
|
136
|
+
md: childrenTypes.has('multi-input-range-field') ? 460 : 440
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -4,8 +4,6 @@ const _excluded = ["props"],
|
|
|
4
4
|
_excluded2 = ["ownerState"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
-
import useId from '@mui/utils/useId';
|
|
9
7
|
import { PickerPopper } from "../../components/PickerPopper/PickerPopper.js";
|
|
10
8
|
import { usePicker } from "../usePicker/index.js";
|
|
11
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
@@ -29,35 +27,26 @@ export const useDesktopPicker = _ref => {
|
|
|
29
27
|
slotProps: innerSlotProps,
|
|
30
28
|
label,
|
|
31
29
|
inputRef,
|
|
32
|
-
readOnly,
|
|
33
|
-
autoFocus,
|
|
34
30
|
localeText
|
|
35
31
|
} = props;
|
|
36
|
-
const fieldRef = React.useRef(null);
|
|
37
|
-
const labelId = useId();
|
|
38
|
-
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
39
32
|
const {
|
|
40
33
|
providerProps,
|
|
41
34
|
renderCurrentView,
|
|
42
35
|
ownerState
|
|
43
36
|
} = usePicker(_extends({}, pickerParams, {
|
|
44
37
|
props,
|
|
45
|
-
fieldRef,
|
|
46
38
|
localeText,
|
|
47
39
|
autoFocusView: true,
|
|
40
|
+
viewContainerRole: 'dialog',
|
|
48
41
|
variant: 'desktop'
|
|
49
42
|
}));
|
|
43
|
+
const labelId = providerProps.privateContextValue.labelId;
|
|
44
|
+
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
50
45
|
const Field = slots.field;
|
|
51
46
|
const _useSlotProps = useSlotProps({
|
|
52
47
|
elementType: Field,
|
|
53
48
|
externalSlotProps: innerSlotProps?.field,
|
|
54
|
-
additionalProps: _extends({
|
|
55
|
-
// Internal props
|
|
56
|
-
readOnly,
|
|
57
|
-
autoFocus: autoFocus && !props.open,
|
|
58
|
-
// Forwarded props
|
|
59
|
-
focused: providerProps.contextValue.open ? true : undefined
|
|
60
|
-
}, isToolbarHidden && {
|
|
49
|
+
additionalProps: _extends({}, isToolbarHidden && {
|
|
61
50
|
id: labelId
|
|
62
51
|
}),
|
|
63
52
|
ownerState
|
|
@@ -80,18 +69,12 @@ export const useDesktopPicker = _ref => {
|
|
|
80
69
|
'aria-labelledby': labelledById
|
|
81
70
|
}, innerSlotProps?.popper)
|
|
82
71
|
});
|
|
83
|
-
|
|
84
|
-
// TODO: This `as any` will go away once the field ref is handled by the context.
|
|
85
|
-
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
86
72
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
87
73
|
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
88
74
|
slots: slots,
|
|
89
75
|
slotProps: slotProps,
|
|
90
76
|
inputRef: inputRef,
|
|
91
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
92
|
-
unstableFieldRef: handleFieldRef
|
|
93
|
-
})), /*#__PURE__*/_jsx(PickerPopper, {
|
|
94
|
-
role: "dialog",
|
|
77
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps)), /*#__PURE__*/_jsx(PickerPopper, {
|
|
95
78
|
slots: slots,
|
|
96
79
|
slotProps: slotProps,
|
|
97
80
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
@@ -15,11 +15,6 @@ export interface UseDesktopPickerSlots extends Pick<PickerPopperSlots, 'desktopP
|
|
|
15
15
|
* Component used to enter the date with the keyboard.
|
|
16
16
|
*/
|
|
17
17
|
field: React.ElementType;
|
|
18
|
-
/**
|
|
19
|
-
* Form control with an input to render the value inside the default field.
|
|
20
|
-
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
|
|
21
|
-
*/
|
|
22
|
-
textField?: React.ElementType;
|
|
23
18
|
}
|
|
24
19
|
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickerPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
|
25
20
|
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useField } from "./useField.js";
|
|
2
2
|
export type { FieldValueManager, UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext } from './useField.types';
|
|
3
3
|
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
|
4
|
-
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
5
|
-
export type { PickerFieldPrivateContextValue } from './useFieldInternalPropsWithDefaults';
|
|
4
|
+
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
@@ -96,6 +96,10 @@ export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableA
|
|
|
96
96
|
* @default false
|
|
97
97
|
*/
|
|
98
98
|
autoFocus?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If `true`, the component is displayed in focused state.
|
|
101
|
+
*/
|
|
102
|
+
focused?: boolean;
|
|
99
103
|
}
|
|
100
104
|
export interface UseFieldCommonAdditionalProps extends Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> {
|
|
101
105
|
/**
|
|
@@ -110,21 +114,22 @@ export interface UseFieldCommonForwardedProps extends Pick<ExportedPickerFieldUI
|
|
|
110
114
|
export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldCommonForwardedProps & (TEnableAccessibleFieldDOMStructure extends false ? UseFieldV6ForwardedProps : UseFieldV7ForwardedProps);
|
|
111
115
|
export interface UseFieldV6ForwardedProps {
|
|
112
116
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
113
|
-
onBlur?:
|
|
117
|
+
onBlur?: React.FocusEventHandler;
|
|
114
118
|
onClick?: React.MouseEventHandler;
|
|
115
|
-
onFocus?:
|
|
119
|
+
onFocus?: React.FocusEventHandler;
|
|
116
120
|
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
|
117
121
|
placeholder?: string;
|
|
118
122
|
}
|
|
119
123
|
interface UseFieldV6AdditionalProps extends Required<Pick<React.InputHTMLAttributes<HTMLInputElement>, 'inputMode' | 'placeholder' | 'value' | 'onChange' | 'autoComplete'>> {
|
|
120
124
|
enableAccessibleFieldDOMStructure: false;
|
|
125
|
+
focused?: boolean;
|
|
121
126
|
}
|
|
122
127
|
export interface UseFieldV7ForwardedProps {
|
|
123
128
|
focused?: boolean;
|
|
124
129
|
sectionListRef?: React.Ref<PickersSectionListRef>;
|
|
125
|
-
onBlur?:
|
|
130
|
+
onBlur?: React.FocusEventHandler;
|
|
126
131
|
onClick?: React.MouseEventHandler;
|
|
127
|
-
onFocus?:
|
|
132
|
+
onFocus?: React.FocusEventHandler;
|
|
128
133
|
onInput?: React.FormEventHandler<HTMLDivElement>;
|
|
129
134
|
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
|
130
135
|
}
|
|
@@ -136,6 +141,7 @@ interface UseFieldV7AdditionalProps {
|
|
|
136
141
|
value: string;
|
|
137
142
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
138
143
|
areAllSectionsEmpty: boolean;
|
|
144
|
+
focused: boolean;
|
|
139
145
|
}
|
|
140
146
|
export type UseFieldResponse<TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & {
|
|
141
147
|
[key: string]: any;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { UseFieldInternalProps } from './useField.types';
|
|
3
1
|
import { PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerFieldInternalPropsWithDefaults } from "../../models/index.js";
|
|
4
|
-
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
|
5
2
|
/**
|
|
6
3
|
* Applies the default values to the field internal props.
|
|
7
4
|
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
8
5
|
* It is only here to allow the migration to be done in smaller steps.
|
|
9
6
|
*/
|
|
10
|
-
export declare function useFieldInternalPropsWithDefaults<TManager extends PickerAnyManager>(
|
|
11
|
-
|
|
12
|
-
internalProps
|
|
13
|
-
}: {
|
|
7
|
+
export declare function useFieldInternalPropsWithDefaults<TManager extends PickerAnyManager>(parameters: UseFieldInternalPropsWithDefaultsParameters<TManager>): PickerManagerFieldInternalPropsWithDefaults<TManager>;
|
|
8
|
+
interface UseFieldInternalPropsWithDefaultsParameters<TManager extends PickerAnyManager> {
|
|
14
9
|
manager: TManager;
|
|
15
10
|
internalProps: PickerManagerFieldInternalProps<TManager>;
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Hack to make sure that on multi input range field, the `useNullableFieldPrivateContext().fieldRef` is only bound to the field matching the range position.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
skipContextFieldRefAssignment?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
4
|
import { useLocalizationContext } from "../useUtils.js";
|
|
4
5
|
import { useNullablePickerContext } from "../useNullablePickerContext.js";
|
|
5
|
-
|
|
6
|
+
import { useNullableFieldPrivateContext } from "../useNullableFieldPrivateContext.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Applies the default values to the field internal props.
|
|
9
10
|
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
10
11
|
* It is only here to allow the migration to be done in smaller steps.
|
|
11
12
|
*/
|
|
12
|
-
export function useFieldInternalPropsWithDefaults({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export function useFieldInternalPropsWithDefaults(parameters) {
|
|
14
|
+
const {
|
|
15
|
+
manager,
|
|
16
|
+
internalProps,
|
|
17
|
+
skipContextFieldRefAssignment
|
|
18
|
+
} = parameters;
|
|
16
19
|
const localizationContext = useLocalizationContext();
|
|
17
20
|
const pickerContext = useNullablePickerContext();
|
|
18
|
-
const fieldPrivateContext =
|
|
21
|
+
const fieldPrivateContext = useNullableFieldPrivateContext();
|
|
22
|
+
const handleFieldRef = useForkRef(internalProps.unstableFieldRef, skipContextFieldRefAssignment ? null : fieldPrivateContext?.fieldRef);
|
|
19
23
|
const setValue = pickerContext?.setValue;
|
|
20
24
|
const handleChangeFromPicker = React.useCallback((newValue, ctx) => {
|
|
21
25
|
return setValue?.(newValue, {
|
|
@@ -33,15 +37,19 @@ export function useFieldInternalPropsWithDefaults({
|
|
|
33
37
|
onChange: handleChangeFromPicker,
|
|
34
38
|
timezone: pickerContext.timezone,
|
|
35
39
|
disabled: pickerContext.disabled,
|
|
40
|
+
readOnly: pickerContext.readOnly,
|
|
41
|
+
autoFocus: pickerContext.autoFocus && !pickerContext.open,
|
|
42
|
+
focused: pickerContext.open ? true : undefined,
|
|
36
43
|
format: pickerContext.fieldFormat,
|
|
37
44
|
formatDensity: fieldPrivateContext.formatDensity,
|
|
38
45
|
enableAccessibleFieldDOMStructure: fieldPrivateContext.enableAccessibleFieldDOMStructure,
|
|
39
46
|
selectedSections: fieldPrivateContext.selectedSections,
|
|
40
|
-
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange
|
|
47
|
+
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange,
|
|
48
|
+
unstableFieldRef: handleFieldRef
|
|
41
49
|
}, internalProps);
|
|
42
50
|
}
|
|
43
51
|
return manager.internal_applyDefaultsToFieldInternalProps(_extends({}, localizationContext, {
|
|
44
52
|
internalProps: internalPropsWithDefaultsFromContext
|
|
45
53
|
}));
|
|
46
|
-
}, [manager, localizationContext, pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker]);
|
|
54
|
+
}, [manager, localizationContext, pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker, handleFieldRef]);
|
|
47
55
|
}
|
|
@@ -48,7 +48,8 @@ export const useFieldV6TextField = params => {
|
|
|
48
48
|
},
|
|
49
49
|
internalProps: {
|
|
50
50
|
readOnly = false,
|
|
51
|
-
disabled = false
|
|
51
|
+
disabled = false,
|
|
52
|
+
focused
|
|
52
53
|
},
|
|
53
54
|
parsedSelectedSections,
|
|
54
55
|
activeSectionIndex,
|
|
@@ -156,8 +157,8 @@ export const useFieldV6TextField = params => {
|
|
|
156
157
|
const sectionIndex = nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;
|
|
157
158
|
setSelectedSections(sectionIndex);
|
|
158
159
|
};
|
|
159
|
-
const handleInputFocus = useEventCallback(
|
|
160
|
-
onFocus?.(
|
|
160
|
+
const handleInputFocus = useEventCallback(event => {
|
|
161
|
+
onFocus?.(event);
|
|
161
162
|
// The ref is guaranteed to be resolved at this point.
|
|
162
163
|
const input = inputRef.current;
|
|
163
164
|
clearTimeout(focusTimeoutRef.current);
|
|
@@ -220,8 +221,8 @@ export const useFieldV6TextField = params => {
|
|
|
220
221
|
resetCharacterQuery();
|
|
221
222
|
updateValueFromValueStr(pastedValue);
|
|
222
223
|
});
|
|
223
|
-
const handleContainerBlur = useEventCallback(
|
|
224
|
-
onBlur?.(
|
|
224
|
+
const handleContainerBlur = useEventCallback(event => {
|
|
225
|
+
onBlur?.(event);
|
|
225
226
|
setSelectedSections(null);
|
|
226
227
|
});
|
|
227
228
|
const handleInputChange = useEventCallback(event => {
|
|
@@ -334,7 +335,8 @@ export const useFieldV6TextField = params => {
|
|
|
334
335
|
inputMode,
|
|
335
336
|
autoComplete: 'off',
|
|
336
337
|
value: shouldShowPlaceholder ? '' : valueStr,
|
|
337
|
-
onChange: handleInputChange
|
|
338
|
+
onChange: handleInputChange,
|
|
339
|
+
focused
|
|
338
340
|
}
|
|
339
341
|
};
|
|
340
342
|
};
|
|
@@ -12,7 +12,8 @@ export const useFieldV7TextField = params => {
|
|
|
12
12
|
internalProps: {
|
|
13
13
|
disabled,
|
|
14
14
|
readOnly = false,
|
|
15
|
-
autoFocus = false
|
|
15
|
+
autoFocus = false,
|
|
16
|
+
focused: focusedProp
|
|
16
17
|
},
|
|
17
18
|
forwardedProps: {
|
|
18
19
|
sectionListRef: inSectionListRef,
|
|
@@ -20,8 +21,7 @@ export const useFieldV7TextField = params => {
|
|
|
20
21
|
onClick,
|
|
21
22
|
onFocus,
|
|
22
23
|
onInput,
|
|
23
|
-
onPaste
|
|
24
|
-
focused: focusedProp
|
|
24
|
+
onPaste
|
|
25
25
|
},
|
|
26
26
|
fieldValueManager,
|
|
27
27
|
applyCharacterEditing,
|
|
@@ -198,8 +198,8 @@ export const useFieldV7TextField = params => {
|
|
|
198
198
|
resetCharacterQuery();
|
|
199
199
|
updateValueFromValueStr(pastedValue);
|
|
200
200
|
});
|
|
201
|
-
const handleContainerFocus = useEventCallback(
|
|
202
|
-
onFocus?.(
|
|
201
|
+
const handleContainerFocus = useEventCallback(event => {
|
|
202
|
+
onFocus?.(event);
|
|
203
203
|
if (focused || !sectionListRef.current) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
@@ -210,8 +210,8 @@ export const useFieldV7TextField = params => {
|
|
|
210
210
|
setSelectedSections(sectionOrder.startIndex);
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
|
-
const handleContainerBlur = useEventCallback(
|
|
214
|
-
onBlur?.(
|
|
213
|
+
const handleContainerBlur = useEventCallback(event => {
|
|
214
|
+
onBlur?.(event);
|
|
215
215
|
setTimeout(() => {
|
|
216
216
|
if (!sectionListRef.current) {
|
|
217
217
|
return;
|
|
@@ -4,8 +4,6 @@ const _excluded = ["props"],
|
|
|
4
4
|
_excluded2 = ["ownerState"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
-
import useId from '@mui/utils/useId';
|
|
9
7
|
import { PickersModalDialog } from "../../components/PickersModalDialog.js";
|
|
10
8
|
import { usePicker } from "../usePicker/index.js";
|
|
11
9
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
@@ -29,35 +27,26 @@ export const useMobilePicker = _ref => {
|
|
|
29
27
|
slotProps: innerSlotProps,
|
|
30
28
|
label,
|
|
31
29
|
inputRef,
|
|
32
|
-
readOnly,
|
|
33
|
-
autoFocus,
|
|
34
30
|
localeText
|
|
35
31
|
} = props;
|
|
36
|
-
const fieldRef = React.useRef(null);
|
|
37
|
-
const labelId = useId();
|
|
38
|
-
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
39
32
|
const {
|
|
40
33
|
providerProps,
|
|
41
34
|
renderCurrentView,
|
|
42
35
|
ownerState
|
|
43
36
|
} = usePicker(_extends({}, pickerParams, {
|
|
44
37
|
props,
|
|
45
|
-
fieldRef,
|
|
46
38
|
localeText,
|
|
47
39
|
autoFocusView: true,
|
|
40
|
+
viewContainerRole: 'dialog',
|
|
48
41
|
variant: 'mobile'
|
|
49
42
|
}));
|
|
43
|
+
const labelId = providerProps.privateContextValue.labelId;
|
|
44
|
+
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
50
45
|
const Field = slots.field;
|
|
51
46
|
const _useSlotProps = useSlotProps({
|
|
52
47
|
elementType: Field,
|
|
53
48
|
externalSlotProps: innerSlotProps?.field,
|
|
54
|
-
additionalProps: _extends({
|
|
55
|
-
// Internal props
|
|
56
|
-
readOnly,
|
|
57
|
-
autoFocus: autoFocus && !props.open,
|
|
58
|
-
// Forwarded props
|
|
59
|
-
focused: providerProps.contextValue.open ? true : undefined
|
|
60
|
-
}, isToolbarHidden && {
|
|
49
|
+
additionalProps: _extends({}, isToolbarHidden && {
|
|
61
50
|
id: labelId
|
|
62
51
|
}),
|
|
63
52
|
ownerState
|
|
@@ -80,17 +69,12 @@ export const useMobilePicker = _ref => {
|
|
|
80
69
|
'aria-labelledby': labelledById
|
|
81
70
|
}, innerSlotProps?.mobilePaper)
|
|
82
71
|
});
|
|
83
|
-
|
|
84
|
-
// TODO: This `as any` will go away once the field ref is handled by the context.
|
|
85
|
-
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
86
72
|
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
87
73
|
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
88
74
|
slots: slots,
|
|
89
75
|
slotProps: slotProps,
|
|
90
76
|
inputRef: inputRef,
|
|
91
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
92
|
-
unstableFieldRef: handleFieldRef
|
|
93
|
-
})), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
77
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps)), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
94
78
|
slots: slots,
|
|
95
79
|
slotProps: slotProps,
|
|
96
80
|
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { UseFieldInternalProps } from './useField';
|
|
3
|
+
import { UsePickerViewsFieldPrivateContextValue } from "./usePicker/usePickerViews.js";
|
|
4
|
+
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
|
5
|
+
export declare function useNullableFieldPrivateContext(): PickerFieldPrivateContextValue | null;
|
|
6
|
+
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any, any>, 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange'>, UsePickerViewsFieldPrivateContextValue {}
|
|
@@ -8,7 +8,7 @@ export declare const usePicker: <TValue extends PickerValidValue, TView extends
|
|
|
8
8
|
variant,
|
|
9
9
|
validator,
|
|
10
10
|
autoFocusView,
|
|
11
|
+
viewContainerRole,
|
|
11
12
|
rendererInterceptor,
|
|
12
|
-
fieldRef,
|
|
13
13
|
localeText
|
|
14
14
|
}: UsePickerParams<TValue, TView, TExternalProps>) => UsePickerReturnValue<TValue>;
|
|
@@ -10,8 +10,8 @@ export const usePicker = ({
|
|
|
10
10
|
variant,
|
|
11
11
|
validator,
|
|
12
12
|
autoFocusView,
|
|
13
|
+
viewContainerRole,
|
|
13
14
|
rendererInterceptor,
|
|
14
|
-
fieldRef,
|
|
15
15
|
localeText
|
|
16
16
|
}) => {
|
|
17
17
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -28,7 +28,7 @@ export const usePicker = ({
|
|
|
28
28
|
const pickerViewsResponse = usePickerViews({
|
|
29
29
|
props,
|
|
30
30
|
autoFocusView,
|
|
31
|
-
|
|
31
|
+
viewContainerRole,
|
|
32
32
|
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
33
33
|
rendererInterceptor
|
|
34
34
|
});
|
|
@@ -8,7 +8,7 @@ import { UsePickerProviderParameters, UsePickerProviderProps, UsePickerProviderR
|
|
|
8
8
|
*/
|
|
9
9
|
export interface UsePickerBaseProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any>> extends UsePickerValueBaseProps<TValue, TError>, UsePickerViewsBaseProps<TValue, TView, TExternalProps>, UsePickerProviderProps {}
|
|
10
10
|
export interface UsePickerProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TView, any>> extends UsePickerValueProps<TValue, TError>, UsePickerViewsProps<TValue, TView, TExternalProps>, UsePickerProviderProps {}
|
|
11
|
-
export interface UsePickerParams<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any>> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | 'validator'>, Pick<UsePickerViewParams<TValue, TView, TExternalProps>, 'autoFocusView' | '
|
|
11
|
+
export interface UsePickerParams<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any>> extends Pick<UsePickerValueParams<TValue, TExternalProps>, 'valueManager' | 'valueType' | 'validator'>, Pick<UsePickerViewParams<TValue, TView, TExternalProps>, 'autoFocusView' | 'viewContainerRole' | 'rendererInterceptor'>, Pick<UsePickerProviderParameters<TValue, TView, InferError<TExternalProps>>, 'localeText' | 'variant' | 'ref'> {
|
|
12
12
|
props: TExternalProps;
|
|
13
13
|
}
|
|
14
14
|
export interface UsePickerReturnValue<TValue extends PickerValidValue> {
|
|
@@ -4,12 +4,17 @@ import { PickerProviderProps } from "../../components/PickerProvider.js";
|
|
|
4
4
|
import type { UsePickerProps } from './usePicker.types';
|
|
5
5
|
import { DateOrTimeViewWithMeridiem, FormProps, PickerOrientation, PickerValidValue, PickerVariant } from "../../models/index.js";
|
|
6
6
|
import { UsePickerViewsProviderParams } from "./usePickerViews.js";
|
|
7
|
-
import {
|
|
7
|
+
import type { UseFieldInternalProps } from '../useField';
|
|
8
|
+
import { ExportedBaseToolbarProps } from "../../models/props/toolbar.js";
|
|
8
9
|
export declare const usePickerOrientation: (views: readonly DateOrTimeViewWithMeridiem[], customOrientation: PickerOrientation | undefined) => PickerOrientation;
|
|
9
10
|
export declare function usePickerProvider<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError>(parameters: UsePickerProviderParameters<TValue, TView, TError>): UsePickerProviderReturnValue<TValue>;
|
|
10
11
|
export interface UsePickerProviderParameters<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Pick<PickerProviderProps<TValue>, 'localeText'> {
|
|
11
12
|
ref: React.ForwardedRef<HTMLDivElement> | undefined;
|
|
12
|
-
props: UsePickerProps<TValue, any, any, any> & UsePickerProviderNonStaticProps
|
|
13
|
+
props: UsePickerProps<TValue, any, any, any> & UsePickerProviderNonStaticProps & {
|
|
14
|
+
slotProps?: {
|
|
15
|
+
toolbar?: ExportedBaseToolbarProps;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
13
18
|
valueManager: PickerValueManager<TValue, any>;
|
|
14
19
|
variant: PickerVariant;
|
|
15
20
|
paramsFromUsePickerValue: UsePickerValueProviderParams<TValue, TError>;
|
|
@@ -34,7 +39,7 @@ export interface UsePickerProviderProps extends FormProps {
|
|
|
34
39
|
/**
|
|
35
40
|
* Props used to create the picker's contexts and that are not available on static pickers.
|
|
36
41
|
*/
|
|
37
|
-
export interface UsePickerProviderNonStaticProps extends
|
|
42
|
+
export interface UsePickerProviderNonStaticProps extends Pick<UseFieldInternalProps<any, any, any>, 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
38
43
|
/**
|
|
39
44
|
* Format of the date when rendered in the input(s).
|
|
40
45
|
* Defaults to localized format based on the used `views`.
|