@mui/x-date-pickers 8.0.0-alpha.6 → 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/AdapterDateFns/AdapterDateFns.d.ts +2 -4
- package/AdapterDateFns/AdapterDateFns.js +49 -47
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -1
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -4
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts} +2 -2
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/AdapterDateFnsJalaliV2/index.d.ts +1 -0
- package/AdapterDateFnsJalaliV2/index.js +1 -0
- package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
- package/{AdapterDateFnsV3/AdapterDateFnsV3.d.ts → AdapterDateFnsV2/AdapterDateFnsV2.d.ts} +2 -2
- package/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/AdapterDateFnsV2/index.d.ts +1 -0
- package/AdapterDateFnsV2/index.js +1 -0
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +1 -1
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.d.ts +1 -1
- package/CHANGELOG.md +242 -1
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- 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 +14 -11
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePicker.types.d.ts +5 -0
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +7 -11
- package/DatePicker/shared.d.ts +1 -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 +14 -11
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -2
- package/DateTimePicker/DateTimePickerToolbar.js +36 -31
- package/DateTimePicker/shared.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +9 -14
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +5 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +14 -22
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
- package/DesktopTimePicker/DesktopTimePicker.js +4 -19
- package/MobileDatePicker/MobileDatePicker.js +2 -11
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -11
- package/MobileTimePicker/MobileTimePicker.js +2 -11
- package/PickersActionBar/PickersActionBar.d.ts +6 -3
- package/PickersActionBar/PickersActionBar.js +6 -3
- package/PickersLayout/PickersLayout.js +1 -5
- package/PickersLayout/PickersLayout.types.d.ts +2 -3
- package/PickersLayout/usePickerLayout.js +12 -31
- package/PickersShortcuts/PickersShortcuts.d.ts +2 -5
- package/PickersShortcuts/PickersShortcuts.js +13 -10
- package/PickersShortcuts/index.d.ts +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
- package/PickersTextField/PickersTextField.js +1 -1
- 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 +14 -11
- package/TimePicker/TimePicker.js +2 -2
- package/TimePicker/TimePickerToolbar.d.ts +1 -2
- package/TimePicker/TimePickerToolbar.js +20 -18
- package/TimePicker/shared.d.ts +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useIsValidValue.d.ts +7 -0
- package/hooks/useIsValidValue.js +11 -0
- package/hooks/useParsedFormat.d.ts +8 -6
- package/hooks/useParsedFormat.js +10 -12
- package/hooks/usePickerActionsContext.d.ts +3 -1
- package/hooks/usePickerActionsContext.js +0 -1
- package/hooks/usePickerContext.d.ts +5 -3
- package/hooks/usePickerContext.js +3 -2
- package/hooks/useSplitFieldProps.d.ts +12 -3
- package/hooks/useSplitFieldProps.js +8 -3
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/PickerFieldUI.d.ts +132 -0
- package/internals/components/PickerFieldUI.js +306 -0
- package/internals/components/PickerProvider.d.ts +34 -12
- package/internals/components/PickerProvider.js +14 -4
- package/internals/components/PickersToolbar.d.ts +2 -3
- package/internals/components/PickersToolbar.js +1 -1
- package/internals/hooks/date-helpers-hooks.js +4 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts +1 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +21 -96
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +10 -33
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/index.d.ts +2 -0
- package/internals/hooks/useField/index.js +2 -1
- package/internals/hooks/useField/useField.js +12 -4
- package/internals/hooks/useField/useField.types.d.ts +11 -4
- package/internals/hooks/useField/useField.utils.js +2 -2
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts +15 -0
- package/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +46 -0
- package/internals/hooks/useField/useFieldState.js +2 -2
- package/internals/hooks/useField/useFieldV6TextField.js +2 -2
- 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 -51
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +8 -16
- package/internals/hooks/useNullablePickerContext.d.ts +5 -0
- package/internals/hooks/useNullablePickerContext.js +10 -0
- package/internals/hooks/useOpenState.js +3 -2
- package/internals/hooks/usePicker/usePicker.d.ts +1 -2
- package/internals/hooks/usePicker/usePicker.js +0 -9
- package/internals/hooks/usePicker/usePicker.types.d.ts +7 -9
- package/internals/hooks/usePicker/usePickerProvider.d.ts +12 -6
- package/internals/hooks/usePicker/usePickerProvider.js +26 -4
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +62 -185
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +52 -55
- package/internals/hooks/usePicker/usePickerViews.d.ts +27 -23
- package/internals/hooks/usePicker/usePickerViews.js +17 -11
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +2 -2
- package/internals/hooks/useUtils.d.ts +4 -3
- package/internals/hooks/useUtils.js +1 -1
- package/internals/index.d.ts +11 -6
- package/internals/index.js +6 -4
- package/internals/models/fields.d.ts +3 -16
- package/internals/models/index.d.ts +1 -0
- package/internals/models/index.js +2 -1
- package/internals/models/manager.d.ts +15 -0
- package/internals/models/manager.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +2 -14
- package/internals/models/props/toolbar.d.ts +1 -5
- package/internals/utils/date-utils.js +1 -1
- package/internals/utils/valueManagers.js +4 -4
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/nbNO.js +15 -19
- package/locales/utils/getPickersLocalization.d.ts +0 -7
- package/locales/utils/getPickersLocalization.js +0 -13
- package/locales/zhTW.d.ts +80 -0
- package/locales/zhTW.js +73 -0
- package/managers/index.d.ts +6 -0
- package/managers/index.js +3 -0
- package/managers/package.json +6 -0
- package/managers/useDateManager.d.ts +27 -0
- package/managers/useDateManager.js +55 -0
- package/managers/useDateTimeManager.d.ts +28 -0
- package/managers/useDateTimeManager.js +60 -0
- package/managers/useTimeManager.d.ts +28 -0
- package/managers/useTimeManager.js +51 -0
- package/models/adapters.d.ts +1 -1
- package/models/fields.d.ts +4 -4
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/manager.d.ts +87 -0
- package/models/manager.js +1 -0
- package/models/pickers.d.ts +7 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +49 -47
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/modern/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/modern/AdapterDateFnsJalaliV2/index.js +1 -0
- package/modern/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/modern/AdapterDateFnsV2/index.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/DateField.js +26 -31
- package/modern/DateField/useDateField.js +14 -11
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DatePicker/DatePickerToolbar.js +7 -11
- package/modern/DateTimeField/DateTimeField.js +26 -31
- package/modern/DateTimeField/useDateTimeField.js +14 -11
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/modern/DateTimePicker/DateTimePickerToolbar.js +36 -31
- package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -14
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +14 -22
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
- package/modern/DesktopTimePicker/DesktopTimePicker.js +4 -19
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -11
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -11
- package/modern/MobileTimePicker/MobileTimePicker.js +2 -11
- package/modern/PickersActionBar/PickersActionBar.js +6 -3
- package/modern/PickersLayout/PickersLayout.js +1 -5
- package/modern/PickersLayout/usePickerLayout.js +12 -31
- package/modern/PickersShortcuts/PickersShortcuts.js +13 -10
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
- package/modern/PickersTextField/PickersTextField.js +1 -1
- package/modern/TimeField/TimeField.js +25 -30
- package/modern/TimeField/useTimeField.js +14 -11
- package/modern/TimePicker/TimePicker.js +2 -2
- package/modern/TimePicker/TimePickerToolbar.js +20 -18
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/useIsValidValue.js +11 -0
- package/modern/hooks/useParsedFormat.js +10 -12
- package/modern/hooks/usePickerActionsContext.js +0 -1
- package/modern/hooks/usePickerContext.js +3 -2
- package/modern/hooks/useSplitFieldProps.js +8 -3
- package/modern/index.js +3 -2
- package/modern/internals/components/PickerFieldUI.js +306 -0
- package/modern/internals/components/PickerProvider.js +14 -4
- package/modern/internals/components/PickersToolbar.js +1 -1
- package/modern/internals/hooks/date-helpers-hooks.js +4 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +21 -96
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/modern/internals/hooks/useField/index.js +2 -1
- package/modern/internals/hooks/useField/useField.js +12 -4
- package/modern/internals/hooks/useField/useField.utils.js +2 -2
- package/modern/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +46 -0
- package/modern/internals/hooks/useField/useFieldState.js +2 -2
- package/modern/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/modern/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +20 -51
- package/modern/internals/hooks/useNullablePickerContext.js +10 -0
- package/modern/internals/hooks/useOpenState.js +3 -2
- package/modern/internals/hooks/usePicker/usePicker.js +0 -9
- package/modern/internals/hooks/usePicker/usePickerProvider.js +26 -4
- package/modern/internals/hooks/usePicker/usePickerValue.js +62 -185
- package/modern/internals/hooks/usePicker/usePickerViews.js +17 -11
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/index.js +6 -4
- package/modern/internals/models/index.js +2 -1
- package/modern/internals/models/manager.js +1 -0
- package/modern/internals/utils/date-utils.js +1 -1
- package/modern/internals/utils/valueManagers.js +4 -4
- package/modern/locales/index.js +1 -0
- package/modern/locales/nbNO.js +15 -19
- package/modern/locales/utils/getPickersLocalization.js +0 -13
- package/modern/locales/zhTW.js +73 -0
- package/modern/managers/index.js +3 -0
- package/modern/managers/useDateManager.js +55 -0
- package/modern/managers/useDateTimeManager.js +60 -0
- package/modern/managers/useTimeManager.js +51 -0
- package/modern/models/index.js +1 -0
- package/modern/models/manager.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +97 -97
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +97 -96
- package/node/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +94 -101
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/AdapterDateFnsV2/AdapterDateFnsV2.js +291 -0
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateField/DateField.js +26 -31
- package/node/DateField/useDateField.js +13 -10
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +7 -11
- package/node/DateTimeField/DateTimeField.js +26 -31
- package/node/DateTimeField/useDateTimeField.js +13 -10
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/node/DateTimePicker/DateTimePickerToolbar.js +36 -31
- package/node/DesktopDatePicker/DesktopDatePicker.js +9 -14
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +14 -22
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
- package/node/DesktopTimePicker/DesktopTimePicker.js +4 -19
- package/node/MobileDatePicker/MobileDatePicker.js +2 -11
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -11
- package/node/MobileTimePicker/MobileTimePicker.js +2 -11
- package/node/PickersActionBar/PickersActionBar.js +8 -5
- package/node/PickersLayout/PickersLayout.js +1 -5
- package/node/PickersLayout/usePickerLayout.js +16 -35
- package/node/PickersShortcuts/PickersShortcuts.js +13 -10
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
- package/node/PickersTextField/PickersTextField.js +1 -1
- package/node/TimeField/TimeField.js +25 -30
- package/node/TimeField/useTimeField.js +13 -10
- package/node/TimePicker/TimePicker.js +2 -2
- package/node/TimePicker/TimePickerToolbar.js +20 -18
- package/node/hooks/index.js +8 -1
- package/node/hooks/useIsValidValue.js +18 -0
- package/node/hooks/useParsedFormat.js +10 -12
- package/node/hooks/usePickerContext.js +5 -4
- package/node/hooks/useSplitFieldProps.js +7 -2
- package/node/index.js +13 -1
- package/node/internals/components/PickerFieldUI.js +318 -0
- package/node/internals/components/PickerProvider.js +16 -6
- package/node/internals/components/PickersToolbar.js +1 -1
- package/node/internals/hooks/date-helpers-hooks.js +4 -3
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +23 -98
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/node/internals/hooks/useField/index.js +8 -1
- package/node/internals/hooks/useField/useField.js +11 -3
- package/node/internals/hooks/useField/useField.utils.js +2 -2
- package/node/internals/hooks/useField/useFieldInternalPropsWithDefaults.js +55 -0
- package/node/internals/hooks/useField/useFieldState.js +2 -2
- package/node/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/node/internals/hooks/useField/useFieldV7TextField.js +3 -3
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +20 -51
- package/node/internals/hooks/useNullablePickerContext.js +16 -0
- package/node/internals/hooks/useOpenState.js +4 -2
- package/node/internals/hooks/usePicker/usePicker.js +0 -10
- package/node/internals/hooks/usePicker/usePickerProvider.js +26 -4
- package/node/internals/hooks/usePicker/usePickerValue.js +62 -185
- package/node/internals/hooks/usePicker/usePickerViews.js +17 -12
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/index.js +45 -19
- package/node/internals/models/index.js +11 -0
- package/node/internals/models/manager.js +5 -0
- package/node/internals/utils/date-utils.js +1 -1
- package/node/internals/utils/valueManagers.js +4 -4
- package/node/locales/index.js +11 -0
- package/node/locales/nbNO.js +15 -19
- package/node/locales/utils/getPickersLocalization.js +2 -16
- package/node/locales/zhTW.js +79 -0
- package/node/managers/index.js +26 -0
- package/node/managers/useDateManager.js +63 -0
- package/node/managers/useDateTimeManager.js +68 -0
- package/node/managers/useTimeManager.js +59 -0
- package/node/models/index.js +11 -0
- package/node/models/manager.js +5 -0
- package/package.json +3 -3
- package/themeAugmentation/props.d.ts +1 -1
- package/validation/extractValidationProps.d.ts +1 -1
- package/AdapterDateFnsJalaliV3/index.d.ts +0 -1
- package/AdapterDateFnsJalaliV3/index.js +0 -1
- package/AdapterDateFnsV3/index.d.ts +0 -1
- package/AdapterDateFnsV3/index.js +0 -1
- package/internals/hooks/defaultizedFieldProps.d.ts +0 -18
- package/internals/hooks/defaultizedFieldProps.js +0 -40
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.d.ts +0 -3
- package/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/modern/AdapterDateFnsJalaliV3/index.js +0 -1
- package/modern/AdapterDateFnsV3/index.js +0 -1
- package/modern/internals/hooks/defaultizedFieldProps.js +0 -40
- package/modern/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -44
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -299
- package/node/internals/hooks/defaultizedFieldProps.js +0 -50
- package/node/internals/utils/convertFieldResponseIntoMuiTextFieldProps.js +0 -52
|
@@ -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,74 +28,29 @@ 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
|
-
layoutProps,
|
|
57
43
|
providerProps,
|
|
58
44
|
renderCurrentView,
|
|
59
45
|
shouldRestoreFocus,
|
|
60
|
-
fieldProps: pickerFieldProps,
|
|
61
46
|
ownerState
|
|
62
47
|
} = usePicker(_extends({}, pickerParams, {
|
|
63
48
|
props,
|
|
64
49
|
fieldRef,
|
|
65
50
|
localeText,
|
|
66
51
|
autoFocusView: true,
|
|
67
|
-
additionalViewProps: {},
|
|
68
52
|
variant: 'desktop'
|
|
69
53
|
}));
|
|
70
|
-
const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
|
|
71
|
-
const _useSlotProps = useSlotProps({
|
|
72
|
-
elementType: InputAdornment,
|
|
73
|
-
externalSlotProps: innerSlotProps?.inputAdornment,
|
|
74
|
-
additionalProps: {
|
|
75
|
-
position: 'end'
|
|
76
|
-
},
|
|
77
|
-
ownerState
|
|
78
|
-
}),
|
|
79
|
-
inputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
80
|
-
const OpenPickerButton = slots.openPickerButton ?? IconButton;
|
|
81
|
-
const _useSlotProps2 = useSlotProps({
|
|
82
|
-
elementType: OpenPickerButton,
|
|
83
|
-
externalSlotProps: innerSlotProps?.openPickerButton,
|
|
84
|
-
additionalProps: {
|
|
85
|
-
disabled: disabled || readOnly,
|
|
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
|
-
},
|
|
91
|
-
'aria-label': getOpenDialogAriaText(pickerFieldProps.value),
|
|
92
|
-
edge: inputAdornmentProps.position
|
|
93
|
-
},
|
|
94
|
-
ownerState
|
|
95
|
-
}),
|
|
96
|
-
openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);
|
|
97
|
-
const OpenPickerIcon = slots.openPickerIcon;
|
|
98
|
-
const openPickerIconProps = useSlotProps({
|
|
99
|
-
elementType: OpenPickerIcon,
|
|
100
|
-
externalSlotProps: innerSlotProps?.openPickerIcon,
|
|
101
|
-
ownerState
|
|
102
|
-
});
|
|
103
54
|
const Field = slots.field;
|
|
104
55
|
const fieldProps = useSlotProps({
|
|
105
56
|
elementType: Field,
|
|
@@ -107,17 +58,7 @@ export const useDesktopPicker = _ref => {
|
|
|
107
58
|
additionalProps: _extends({
|
|
108
59
|
// Internal props
|
|
109
60
|
readOnly,
|
|
110
|
-
|
|
111
|
-
format,
|
|
112
|
-
formatDensity,
|
|
113
|
-
enableAccessibleFieldDOMStructure,
|
|
114
|
-
selectedSections,
|
|
115
|
-
onSelectedSectionsChange,
|
|
116
|
-
timezone,
|
|
117
|
-
autoFocus: autoFocus && !props.open
|
|
118
|
-
}, pickerFieldProps, {
|
|
119
|
-
// onChange and value
|
|
120
|
-
|
|
61
|
+
autoFocus: autoFocus && !props.open,
|
|
121
62
|
// Forwarded props
|
|
122
63
|
className,
|
|
123
64
|
sx,
|
|
@@ -131,24 +72,6 @@ export const useDesktopPicker = _ref => {
|
|
|
131
72
|
}),
|
|
132
73
|
ownerState
|
|
133
74
|
});
|
|
134
|
-
|
|
135
|
-
// TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
|
|
136
|
-
if (hasUIView) {
|
|
137
|
-
fieldProps.InputProps = _extends({}, fieldProps.InputProps, {
|
|
138
|
-
ref: containerRef
|
|
139
|
-
}, !props.disableOpenPicker && {
|
|
140
|
-
[`${inputAdornmentProps.position}Adornment`]: /*#__PURE__*/_jsx(InputAdornment, _extends({}, inputAdornmentProps, {
|
|
141
|
-
children: /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
142
|
-
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
143
|
-
}))
|
|
144
|
-
}))
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
const slotsForField = _extends({
|
|
148
|
-
textField: slots.textField,
|
|
149
|
-
clearIcon: slots.clearIcon,
|
|
150
|
-
clearButton: slots.clearButton
|
|
151
|
-
}, fieldProps.slots);
|
|
152
75
|
const Layout = slots.layout ?? PickersLayout;
|
|
153
76
|
let labelledById = labelId;
|
|
154
77
|
if (isToolbarHidden) {
|
|
@@ -167,25 +90,27 @@ export const useDesktopPicker = _ref => {
|
|
|
167
90
|
}, innerSlotProps?.popper)
|
|
168
91
|
});
|
|
169
92
|
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
170
|
-
const renderPicker = () => /*#__PURE__*/
|
|
171
|
-
children:
|
|
172
|
-
slots: slotsForField,
|
|
173
|
-
slotProps: slotProps,
|
|
174
|
-
unstableFieldRef: handleFieldRef
|
|
175
|
-
})), /*#__PURE__*/_jsx(PickersPopper, {
|
|
176
|
-
role: "dialog",
|
|
177
|
-
placement: "bottom-start",
|
|
178
|
-
anchorEl: containerRef.current,
|
|
93
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
94
|
+
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
179
95
|
slots: slots,
|
|
180
96
|
slotProps: slotProps,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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,
|
|
184
103
|
slots: slots,
|
|
185
104
|
slotProps: slotProps,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
})
|
|
189
114
|
}));
|
|
190
115
|
return {
|
|
191
116
|
renderPicker
|
|
@@ -113,7 +113,7 @@ const createSection = ({
|
|
|
113
113
|
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
114
114
|
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
115
115
|
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
116
|
-
const isValidDate =
|
|
116
|
+
const isValidDate = utils.isValid(date);
|
|
117
117
|
let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
118
118
|
let maxLength = null;
|
|
119
119
|
if (hasLeadingZerosInInput) {
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { useField } from "./useField.js";
|
|
2
|
-
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
|
2
|
+
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
|
3
|
+
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
|
@@ -4,7 +4,7 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
5
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
6
6
|
import { useValidation } from "../../../validation/index.js";
|
|
7
|
-
import { useUtils } from "../useUtils.js";
|
|
7
|
+
import { useLocalizationContext, useUtils } from "../useUtils.js";
|
|
8
8
|
import { adjustSectionValue, getSectionOrder } from "./useField.utils.js";
|
|
9
9
|
import { useFieldState } from "./useFieldState.js";
|
|
10
10
|
import { useFieldCharacterEditing } from "./useFieldCharacterEditing.js";
|
|
@@ -19,7 +19,8 @@ export const useField = params => {
|
|
|
19
19
|
minutesStep,
|
|
20
20
|
enableAccessibleFieldDOMStructure = true,
|
|
21
21
|
disabled = false,
|
|
22
|
-
readOnly = false
|
|
22
|
+
readOnly = false,
|
|
23
|
+
autoFocus = false
|
|
23
24
|
},
|
|
24
25
|
forwardedProps: {
|
|
25
26
|
onKeyDown,
|
|
@@ -29,7 +30,8 @@ export const useField = params => {
|
|
|
29
30
|
},
|
|
30
31
|
fieldValueManager,
|
|
31
32
|
valueManager,
|
|
32
|
-
validator
|
|
33
|
+
validator,
|
|
34
|
+
getOpenPickerButtonAriaLabel: getOpenDialogAriaText
|
|
33
35
|
} = params;
|
|
34
36
|
const isRtl = useRtl();
|
|
35
37
|
const stateResponse = useFieldState(params);
|
|
@@ -216,9 +218,15 @@ export const useField = params => {
|
|
|
216
218
|
error: inputError,
|
|
217
219
|
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled)
|
|
218
220
|
};
|
|
221
|
+
const localizationContext = useLocalizationContext();
|
|
222
|
+
const openPickerAriaLabel = React.useMemo(() => getOpenDialogAriaText(_extends({}, localizationContext, {
|
|
223
|
+
value: state.value
|
|
224
|
+
})), [getOpenDialogAriaText, state.value, localizationContext]);
|
|
219
225
|
const commonAdditionalProps = {
|
|
220
226
|
disabled,
|
|
221
|
-
readOnly
|
|
227
|
+
readOnly,
|
|
228
|
+
autoFocus,
|
|
229
|
+
openPickerAriaLabel
|
|
222
230
|
};
|
|
223
231
|
return _extends({}, params.forwardedProps, commonForwardedProps, commonAdditionalProps, returnedValue);
|
|
224
232
|
};
|
|
@@ -361,7 +361,7 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
361
361
|
currentDate
|
|
362
362
|
}) => ({
|
|
363
363
|
minimum: 1,
|
|
364
|
-
maximum:
|
|
364
|
+
maximum: utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,
|
|
365
365
|
longestMonth: longestMonth
|
|
366
366
|
}),
|
|
367
367
|
weekDay: ({
|
|
@@ -509,7 +509,7 @@ export const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections,
|
|
|
509
509
|
}, referenceDate);
|
|
510
510
|
export const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');
|
|
511
511
|
|
|
512
|
-
// TODO
|
|
512
|
+
// TODO v9: Remove
|
|
513
513
|
export const getSectionOrder = (sections, shouldApplyRTL) => {
|
|
514
514
|
const neighbors = {};
|
|
515
515
|
if (!shouldApplyRTL) {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useLocalizationContext } from "../useUtils.js";
|
|
4
|
+
import { useNullablePickerContext } from "../useNullablePickerContext.js";
|
|
5
|
+
export const PickerFieldPrivateContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Applies the default values to the field internal props.
|
|
9
|
+
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
10
|
+
* It is only here to allow the migration to be done in smaller steps.
|
|
11
|
+
*/
|
|
12
|
+
export function useFieldInternalPropsWithDefaults({
|
|
13
|
+
manager,
|
|
14
|
+
internalProps
|
|
15
|
+
}) {
|
|
16
|
+
const localizationContext = useLocalizationContext();
|
|
17
|
+
const pickerContext = useNullablePickerContext();
|
|
18
|
+
const fieldPrivateContext = React.useContext(PickerFieldPrivateContext);
|
|
19
|
+
const setValue = pickerContext?.setValue;
|
|
20
|
+
const handleChangeFromPicker = React.useCallback((newValue, ctx) => {
|
|
21
|
+
return setValue?.(newValue, {
|
|
22
|
+
validationError: ctx.validationError
|
|
23
|
+
});
|
|
24
|
+
}, [setValue]);
|
|
25
|
+
return React.useMemo(() => {
|
|
26
|
+
let internalPropsWithDefaultsFromContext = internalProps;
|
|
27
|
+
// If one of the context is null,
|
|
28
|
+
// Then the field is used as a standalone component and the other context will be null as well.
|
|
29
|
+
if (fieldPrivateContext != null && pickerContext != null) {
|
|
30
|
+
internalPropsWithDefaultsFromContext = _extends({
|
|
31
|
+
value: pickerContext.value,
|
|
32
|
+
onChange: handleChangeFromPicker,
|
|
33
|
+
timezone: pickerContext.timezone,
|
|
34
|
+
disabled: pickerContext.disabled,
|
|
35
|
+
format: pickerContext.fieldFormat,
|
|
36
|
+
formatDensity: fieldPrivateContext.formatDensity,
|
|
37
|
+
enableAccessibleFieldDOMStructure: fieldPrivateContext.enableAccessibleFieldDOMStructure,
|
|
38
|
+
selectedSections: fieldPrivateContext.selectedSections,
|
|
39
|
+
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange
|
|
40
|
+
}, internalProps);
|
|
41
|
+
}
|
|
42
|
+
return manager.internal_applyDefaultsToFieldInternalProps(_extends({}, localizationContext, {
|
|
43
|
+
internalProps: internalPropsWithDefaultsFromContext
|
|
44
|
+
}));
|
|
45
|
+
}, [manager, localizationContext, pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker]);
|
|
46
|
+
}
|
|
@@ -148,7 +148,7 @@ export const useFieldState = params => {
|
|
|
148
148
|
const updateValueFromValueStr = valueStr => {
|
|
149
149
|
const parseDateStr = (dateStr, referenceDate) => {
|
|
150
150
|
const date = utils.parse(dateStr, format);
|
|
151
|
-
if (
|
|
151
|
+
if (!utils.isValid(date)) {
|
|
152
152
|
return null;
|
|
153
153
|
}
|
|
154
154
|
const sections = buildSectionsFromFormat({
|
|
@@ -199,7 +199,7 @@ export const useFieldState = params => {
|
|
|
199
199
|
* Then we merge the value of the modified sections into the reference date.
|
|
200
200
|
* This makes sure that we don't lose some information of the initial date (like the time on a date field).
|
|
201
201
|
*/
|
|
202
|
-
if (
|
|
202
|
+
if (utils.isValid(newActiveDate)) {
|
|
203
203
|
const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);
|
|
204
204
|
values = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);
|
|
205
205
|
shouldPublish = true;
|
|
@@ -35,8 +35,8 @@ export const addPositionPropertiesToSections = (sections, localizedDigits, isRtl
|
|
|
35
35
|
};
|
|
36
36
|
export const useFieldV6TextField = params => {
|
|
37
37
|
const isRtl = useRtl();
|
|
38
|
-
const focusTimeoutRef = React.useRef();
|
|
39
|
-
const selectionSyncTimeoutRef = React.useRef();
|
|
38
|
+
const focusTimeoutRef = React.useRef(undefined);
|
|
39
|
+
const selectionSyncTimeoutRef = React.useRef(undefined);
|
|
40
40
|
const {
|
|
41
41
|
forwardedProps: {
|
|
42
42
|
onFocus,
|
|
@@ -11,7 +11,8 @@ export const useFieldV7TextField = params => {
|
|
|
11
11
|
const {
|
|
12
12
|
internalProps: {
|
|
13
13
|
disabled,
|
|
14
|
-
readOnly = false
|
|
14
|
+
readOnly = false,
|
|
15
|
+
autoFocus = false
|
|
15
16
|
},
|
|
16
17
|
forwardedProps: {
|
|
17
18
|
sectionListRef: inSectionListRef,
|
|
@@ -20,8 +21,7 @@ export const useFieldV7TextField = params => {
|
|
|
20
21
|
onFocus,
|
|
21
22
|
onInput,
|
|
22
23
|
onPaste,
|
|
23
|
-
focused: focusedProp
|
|
24
|
-
autoFocus = false
|
|
24
|
+
focused: focusedProp
|
|
25
25
|
},
|
|
26
26
|
fieldValueManager,
|
|
27
27
|
applyCharacterEditing,
|
|
@@ -1,15 +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"
|
|
3
|
+
const _excluded = ["props"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
6
6
|
import useForkRef from '@mui/utils/useForkRef';
|
|
7
7
|
import useId from '@mui/utils/useId';
|
|
8
8
|
import { PickersModalDialog } from "../../components/PickersModalDialog.js";
|
|
9
9
|
import { usePicker } from "../usePicker/index.js";
|
|
10
|
-
import { onSpaceOrEnter } from "../../utils/utils.js";
|
|
11
10
|
import { PickersLayout } from "../../../PickersLayout/index.js";
|
|
12
11
|
import { PickerProvider } from "../../components/PickerProvider.js";
|
|
12
|
+
import { PickerFieldUIContextProvider } from "../../components/PickerFieldUI.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Hook managing all the single-date mobile pickers:
|
|
@@ -20,8 +20,7 @@ import { PickerProvider } from "../../components/PickerProvider.js";
|
|
|
20
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
21
|
export const useMobilePicker = _ref => {
|
|
22
22
|
let {
|
|
23
|
-
props
|
|
24
|
-
getOpenDialogAriaText
|
|
23
|
+
props
|
|
25
24
|
} = _ref,
|
|
26
25
|
pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
27
26
|
const {
|
|
@@ -29,34 +28,25 @@ export const useMobilePicker = _ref => {
|
|
|
29
28
|
slotProps: innerSlotProps,
|
|
30
29
|
className,
|
|
31
30
|
sx,
|
|
32
|
-
format,
|
|
33
|
-
formatDensity,
|
|
34
|
-
enableAccessibleFieldDOMStructure,
|
|
35
|
-
selectedSections,
|
|
36
|
-
onSelectedSectionsChange,
|
|
37
|
-
timezone,
|
|
38
31
|
name,
|
|
39
32
|
label,
|
|
40
33
|
inputRef,
|
|
41
34
|
readOnly,
|
|
42
|
-
|
|
35
|
+
autoFocus,
|
|
43
36
|
localeText
|
|
44
37
|
} = props;
|
|
45
38
|
const fieldRef = React.useRef(null);
|
|
46
39
|
const labelId = useId();
|
|
47
40
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
48
41
|
const {
|
|
49
|
-
layoutProps,
|
|
50
42
|
providerProps,
|
|
51
43
|
renderCurrentView,
|
|
52
|
-
fieldProps: pickerFieldProps,
|
|
53
44
|
ownerState
|
|
54
45
|
} = usePicker(_extends({}, pickerParams, {
|
|
55
46
|
props,
|
|
56
47
|
fieldRef,
|
|
57
48
|
localeText,
|
|
58
49
|
autoFocusView: true,
|
|
59
|
-
additionalViewProps: {},
|
|
60
50
|
variant: 'mobile'
|
|
61
51
|
}));
|
|
62
52
|
const Field = slots.field;
|
|
@@ -65,44 +55,21 @@ export const useMobilePicker = _ref => {
|
|
|
65
55
|
externalSlotProps: innerSlotProps?.field,
|
|
66
56
|
additionalProps: _extends({
|
|
67
57
|
// Internal props
|
|
68
|
-
readOnly
|
|
69
|
-
|
|
70
|
-
format,
|
|
71
|
-
formatDensity,
|
|
72
|
-
enableAccessibleFieldDOMStructure,
|
|
73
|
-
selectedSections,
|
|
74
|
-
onSelectedSectionsChange,
|
|
75
|
-
timezone
|
|
76
|
-
}, pickerFieldProps, {
|
|
77
|
-
// onChange and value
|
|
78
|
-
|
|
58
|
+
readOnly,
|
|
59
|
+
autoFocus: autoFocus && !props.open,
|
|
79
60
|
// Forwarded props
|
|
80
61
|
className,
|
|
81
62
|
sx,
|
|
82
63
|
label,
|
|
83
|
-
name
|
|
64
|
+
name,
|
|
65
|
+
focused: providerProps.contextValue.open ? true : undefined
|
|
84
66
|
}, isToolbarHidden && {
|
|
85
67
|
id: labelId
|
|
86
|
-
}, !(disabled || readOnly) && {
|
|
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))
|
|
93
68
|
}, !!inputRef && {
|
|
94
69
|
inputRef
|
|
95
70
|
}),
|
|
96
71
|
ownerState
|
|
97
72
|
});
|
|
98
|
-
|
|
99
|
-
// TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged
|
|
100
|
-
fieldProps.inputProps = _extends({}, fieldProps.inputProps, {
|
|
101
|
-
'aria-label': getOpenDialogAriaText(pickerFieldProps.value)
|
|
102
|
-
});
|
|
103
|
-
const slotsForField = _extends({
|
|
104
|
-
textField: slots.textField
|
|
105
|
-
}, fieldProps.slots);
|
|
106
73
|
const Layout = slots.layout ?? PickersLayout;
|
|
107
74
|
let labelledById = labelId;
|
|
108
75
|
if (isToolbarHidden) {
|
|
@@ -121,20 +88,22 @@ export const useMobilePicker = _ref => {
|
|
|
121
88
|
}, innerSlotProps?.mobilePaper)
|
|
122
89
|
});
|
|
123
90
|
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
|
|
124
|
-
const renderPicker = () => /*#__PURE__*/
|
|
125
|
-
children:
|
|
126
|
-
slots: slotsForField,
|
|
127
|
-
slotProps: slotProps,
|
|
128
|
-
unstableFieldRef: handleFieldRef
|
|
129
|
-
})), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
91
|
+
const renderPicker = () => /*#__PURE__*/_jsx(PickerProvider, _extends({}, providerProps, {
|
|
92
|
+
children: /*#__PURE__*/_jsxs(PickerFieldUIContextProvider, {
|
|
130
93
|
slots: slots,
|
|
131
94
|
slotProps: slotProps,
|
|
132
|
-
children: /*#__PURE__*/_jsx(
|
|
95
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {
|
|
96
|
+
unstableFieldRef: handleFieldRef
|
|
97
|
+
})), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
133
98
|
slots: slots,
|
|
134
99
|
slotProps: slotProps,
|
|
135
|
-
children:
|
|
136
|
-
|
|
137
|
-
|
|
100
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
101
|
+
slots: slots,
|
|
102
|
+
slotProps: slotProps,
|
|
103
|
+
children: renderCurrentView()
|
|
104
|
+
}))
|
|
105
|
+
})]
|
|
106
|
+
})
|
|
138
107
|
}));
|
|
139
108
|
return {
|
|
140
109
|
renderPicker
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PickerContext } from "../../hooks/usePickerContext.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns the context passed by the picker that wraps the current component.
|
|
8
|
+
* If the context is not found, returns `null`.
|
|
9
|
+
*/
|
|
10
|
+
export const useNullablePickerContext = () => React.useContext(PickerContext);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
2
3
|
export const useOpenState = ({
|
|
3
4
|
open,
|
|
4
5
|
onOpen,
|
|
@@ -17,7 +18,7 @@ export const useOpenState = ({
|
|
|
17
18
|
setOpenState(open);
|
|
18
19
|
}
|
|
19
20
|
}, [isControllingOpenProp, open]);
|
|
20
|
-
const setOpen =
|
|
21
|
+
const setOpen = useEventCallback(action => {
|
|
21
22
|
const newOpen = typeof action === 'function' ? action(openState) : action;
|
|
22
23
|
if (!isControllingOpenProp) {
|
|
23
24
|
setOpenState(newOpen);
|
|
@@ -28,7 +29,7 @@ export const useOpenState = ({
|
|
|
28
29
|
if (!newOpen && onClose) {
|
|
29
30
|
onClose();
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
});
|
|
32
33
|
return {
|
|
33
34
|
open: openState,
|
|
34
35
|
setOpen
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
2
|
import { usePickerValue } from "./usePickerValue.js";
|
|
4
3
|
import { usePickerViews } from "./usePickerViews.js";
|
|
@@ -8,7 +7,6 @@ export const usePicker = ({
|
|
|
8
7
|
valueManager,
|
|
9
8
|
valueType,
|
|
10
9
|
variant,
|
|
11
|
-
additionalViewProps,
|
|
12
10
|
validator,
|
|
13
11
|
autoFocusView,
|
|
14
12
|
rendererInterceptor,
|
|
@@ -24,12 +22,10 @@ export const usePicker = ({
|
|
|
24
22
|
props,
|
|
25
23
|
valueManager,
|
|
26
24
|
valueType,
|
|
27
|
-
variant,
|
|
28
25
|
validator
|
|
29
26
|
});
|
|
30
27
|
const pickerViewsResponse = usePickerViews({
|
|
31
28
|
props,
|
|
32
|
-
additionalViewProps,
|
|
33
29
|
autoFocusView,
|
|
34
30
|
fieldRef,
|
|
35
31
|
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
@@ -44,14 +40,9 @@ export const usePicker = ({
|
|
|
44
40
|
paramsFromUsePickerViews: pickerViewsResponse.provider
|
|
45
41
|
});
|
|
46
42
|
return {
|
|
47
|
-
// Picker value
|
|
48
|
-
fieldProps: pickerValueResponse.fieldProps,
|
|
49
43
|
// Picker views
|
|
50
44
|
renderCurrentView: pickerViewsResponse.renderCurrentView,
|
|
51
|
-
hasUIView: pickerViewsResponse.provider.hasUIView,
|
|
52
45
|
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
|
|
53
|
-
// Picker layout
|
|
54
|
-
layoutProps: _extends({}, pickerValueResponse.layoutProps),
|
|
55
46
|
// Picker provider
|
|
56
47
|
providerProps,
|
|
57
48
|
// Picker owner state
|
|
@@ -45,6 +45,7 @@ export function usePickerProvider(parameters) {
|
|
|
45
45
|
} = parameters;
|
|
46
46
|
const utils = useUtils();
|
|
47
47
|
const orientation = usePickerOrientation(paramsFromUsePickerViews.views, props.orientation);
|
|
48
|
+
const triggerRef = React.useRef(null);
|
|
48
49
|
const ownerState = React.useMemo(() => ({
|
|
49
50
|
isPickerValueEmpty: valueManager.areValuesEqual(utils, paramsFromUsePickerValue.value, valueManager.emptyValue),
|
|
50
51
|
isPickerOpen: paramsFromUsePickerValue.contextValue.open,
|
|
@@ -53,20 +54,41 @@ export function usePickerProvider(parameters) {
|
|
|
53
54
|
pickerOrientation: orientation,
|
|
54
55
|
pickerVariant: variant
|
|
55
56
|
}), [utils, valueManager, paramsFromUsePickerValue.value, paramsFromUsePickerValue.contextValue.open, orientation, variant, props.disabled, props.readOnly]);
|
|
57
|
+
const triggerStatus = React.useMemo(() => {
|
|
58
|
+
if (props.disableOpenPicker || !paramsFromUsePickerViews.hasUIView) {
|
|
59
|
+
return 'hidden';
|
|
60
|
+
}
|
|
61
|
+
if (props.disabled || props.readOnly) {
|
|
62
|
+
return 'disabled';
|
|
63
|
+
}
|
|
64
|
+
return 'enabled';
|
|
65
|
+
}, [props.disableOpenPicker, paramsFromUsePickerViews.hasUIView, props.disabled, props.readOnly]);
|
|
56
66
|
const contextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.contextValue, paramsFromUsePickerViews.contextValue, {
|
|
57
67
|
disabled: props.disabled ?? false,
|
|
58
68
|
readOnly: props.readOnly ?? false,
|
|
59
69
|
variant,
|
|
60
|
-
orientation
|
|
61
|
-
|
|
70
|
+
orientation,
|
|
71
|
+
triggerRef,
|
|
72
|
+
triggerStatus,
|
|
73
|
+
fieldFormat: props.format ?? ''
|
|
74
|
+
}), [paramsFromUsePickerValue.contextValue, paramsFromUsePickerViews.contextValue, variant, orientation, props.disabled, props.readOnly, triggerRef, triggerStatus, props.format]);
|
|
62
75
|
const privateContextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.privateContextValue, {
|
|
63
76
|
ownerState
|
|
64
77
|
}), [paramsFromUsePickerValue, ownerState]);
|
|
78
|
+
const actionsContextValue = React.useMemo(() => _extends({}, paramsFromUsePickerValue.actionsContextValue, paramsFromUsePickerViews.actionsContextValue), [paramsFromUsePickerValue.actionsContextValue, paramsFromUsePickerViews.actionsContextValue]);
|
|
79
|
+
const fieldPrivateContextValue = React.useMemo(() => ({
|
|
80
|
+
formatDensity: props.formatDensity,
|
|
81
|
+
enableAccessibleFieldDOMStructure: props.enableAccessibleFieldDOMStructure,
|
|
82
|
+
selectedSections: props.selectedSections,
|
|
83
|
+
onSelectedSectionsChange: props.onSelectedSectionsChange
|
|
84
|
+
}), [props.formatDensity, props.enableAccessibleFieldDOMStructure, props.selectedSections, props.onSelectedSectionsChange]);
|
|
65
85
|
return {
|
|
66
86
|
localeText,
|
|
67
87
|
contextValue,
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
privateContextValue,
|
|
89
|
+
actionsContextValue,
|
|
90
|
+
fieldPrivateContextValue,
|
|
91
|
+
isValidContextValue: paramsFromUsePickerValue.isValidContextValue
|
|
70
92
|
};
|
|
71
93
|
}
|
|
72
94
|
|