@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
|
@@ -12,10 +12,8 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
12
12
|
import { DateTimeField } from "../DateTimeField/index.js";
|
|
13
13
|
import { useDateTimePickerDefaultizedProps } from "../DateTimePicker/shared.js";
|
|
14
14
|
import { renderDateViewCalendar } from "../dateViewRenderers/dateViewRenderers.js";
|
|
15
|
-
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
16
15
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
17
16
|
import { validateDateTime, extractValidationProps } from "../validation/index.js";
|
|
18
|
-
import { CalendarIcon } from "../icons/index.js";
|
|
19
17
|
import { useDesktopPicker } from "../internals/hooks/useDesktopPicker/index.js";
|
|
20
18
|
import { resolveDateTimeFormat, resolveTimeViewsResponse } from "../internals/utils/date-time-utils.js";
|
|
21
19
|
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from "../timeViewRenderers/index.js";
|
|
@@ -25,7 +23,6 @@ import { DesktopDateTimePickerLayout } from "./DesktopDateTimePickerLayout.js";
|
|
|
25
23
|
import { VIEW_HEIGHT } from "../internals/constants/dimensions.js";
|
|
26
24
|
import { isInternalTimeView } from "../internals/utils/time-utils.js";
|
|
27
25
|
import { isDatePickerView } from "../internals/utils/date-utils.js";
|
|
28
|
-
import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalization.js";
|
|
29
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
30
27
|
const rendererInterceptor = function RendererInterceptor(props) {
|
|
31
28
|
const {
|
|
@@ -90,7 +87,6 @@ const rendererInterceptor = function RendererInterceptor(props) {
|
|
|
90
87
|
* - [DesktopDateTimePicker API](https://mui.com/x/api/date-pickers/desktop-date-time-picker/)
|
|
91
88
|
*/
|
|
92
89
|
const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDateTimePicker(inProps, ref) {
|
|
93
|
-
const translations = usePickerTranslations();
|
|
94
90
|
const utils = useUtils();
|
|
95
91
|
|
|
96
92
|
// Props with the default values common to all date time pickers
|
|
@@ -128,8 +124,7 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
128
124
|
shouldRenderTimeInASingleColumn,
|
|
129
125
|
slots: _extends({
|
|
130
126
|
field: DateTimeField,
|
|
131
|
-
layout: DesktopDateTimePickerLayout
|
|
132
|
-
openPickerIcon: CalendarIcon
|
|
127
|
+
layout: DesktopDateTimePickerLayout
|
|
133
128
|
}, defaultizedProps.slots),
|
|
134
129
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
135
130
|
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
@@ -150,12 +145,6 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
|
|
|
150
145
|
props,
|
|
151
146
|
valueManager: singleItemValueManager,
|
|
152
147
|
valueType: 'date-time',
|
|
153
|
-
getOpenDialogAriaText: buildGetOpenDialogAriaText({
|
|
154
|
-
utils,
|
|
155
|
-
formatKey: 'fullDate',
|
|
156
|
-
contextTranslation: translations.openDatePickerDialogue,
|
|
157
|
-
propsTranslation: props.localeText?.openDatePickerDialogue
|
|
158
|
-
}),
|
|
159
148
|
validator: validateDateTime,
|
|
160
149
|
rendererInterceptor
|
|
161
150
|
});
|
|
@@ -8,15 +8,12 @@ import { refType } from '@mui/utils';
|
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { TimeField } from "../TimeField/index.js";
|
|
10
10
|
import { useTimePickerDefaultizedProps } from "../TimePicker/shared.js";
|
|
11
|
-
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
12
11
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
13
12
|
import { extractValidationProps, validateTime } from "../validation/index.js";
|
|
14
|
-
import { ClockIcon } from "../icons/index.js";
|
|
15
13
|
import { useDesktopPicker } from "../internals/hooks/useDesktopPicker/index.js";
|
|
16
14
|
import { renderDigitalClockTimeView, renderMultiSectionDigitalClockTimeView } from "../timeViewRenderers/index.js";
|
|
17
15
|
import { resolveTimeFormat } from "../internals/utils/time-utils.js";
|
|
18
16
|
import { resolveTimeViewsResponse } from "../internals/utils/date-time-utils.js";
|
|
19
|
-
import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalization.js";
|
|
20
17
|
/**
|
|
21
18
|
* Demos:
|
|
22
19
|
*
|
|
@@ -28,7 +25,6 @@ import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalizat
|
|
|
28
25
|
* - [DesktopTimePicker API](https://mui.com/x/api/date-pickers/desktop-time-picker/)
|
|
29
26
|
*/
|
|
30
27
|
const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePicker(inProps, ref) {
|
|
31
|
-
const translations = usePickerTranslations();
|
|
32
28
|
const utils = useUtils();
|
|
33
29
|
|
|
34
30
|
// Props with the default values common to all time pickers
|
|
@@ -60,8 +56,7 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
|
|
|
60
56
|
// Allows for easy view lifecycle management
|
|
61
57
|
views: shouldRenderTimeInASingleColumn ? ['hours'] : views,
|
|
62
58
|
slots: _extends({
|
|
63
|
-
field: TimeField
|
|
64
|
-
openPickerIcon: ClockIcon
|
|
59
|
+
field: TimeField
|
|
65
60
|
}, defaultizedProps.slots),
|
|
66
61
|
slotProps: _extends({}, defaultizedProps.slotProps, {
|
|
67
62
|
field: ownerState => _extends({}, resolveComponentProps(defaultizedProps.slotProps?.field, ownerState), extractValidationProps(defaultizedProps), {
|
|
@@ -79,12 +74,6 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
|
|
|
79
74
|
props,
|
|
80
75
|
valueManager: singleItemValueManager,
|
|
81
76
|
valueType: 'time',
|
|
82
|
-
getOpenDialogAriaText: buildGetOpenDialogAriaText({
|
|
83
|
-
utils,
|
|
84
|
-
formatKey: 'fullTime',
|
|
85
|
-
contextTranslation: translations.openTimePickerDialogue,
|
|
86
|
-
propsTranslation: props.localeText?.openTimePickerDialogue
|
|
87
|
-
}),
|
|
88
77
|
validator: validateTime
|
|
89
78
|
});
|
|
90
79
|
return renderPicker();
|
|
@@ -7,14 +7,12 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
|
7
7
|
import { refType } from '@mui/utils';
|
|
8
8
|
import { useMobilePicker } from "../internals/hooks/useMobilePicker/index.js";
|
|
9
9
|
import { useDatePickerDefaultizedProps } from "../DatePicker/shared.js";
|
|
10
|
-
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
11
10
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
12
11
|
import { extractValidationProps, validateDate } from "../validation/index.js";
|
|
13
12
|
import { DateField } from "../DateField/index.js";
|
|
14
13
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
15
14
|
import { renderDateViewCalendar } from "../dateViewRenderers/index.js";
|
|
16
15
|
import { resolveDateFormat } from "../internals/utils/date-utils.js";
|
|
17
|
-
import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalization.js";
|
|
18
16
|
/**
|
|
19
17
|
* Demos:
|
|
20
18
|
*
|
|
@@ -26,7 +24,6 @@ import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalizat
|
|
|
26
24
|
* - [MobileDatePicker API](https://mui.com/x/api/date-pickers/mobile-date-picker/)
|
|
27
25
|
*/
|
|
28
26
|
const MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker(inProps, ref) {
|
|
29
|
-
const translations = usePickerTranslations();
|
|
30
27
|
const utils = useUtils();
|
|
31
28
|
|
|
32
29
|
// Props with the default values common to all date pickers
|
|
@@ -59,12 +56,6 @@ const MobileDatePicker = /*#__PURE__*/React.forwardRef(function MobileDatePicker
|
|
|
59
56
|
props,
|
|
60
57
|
valueManager: singleItemValueManager,
|
|
61
58
|
valueType: 'date',
|
|
62
|
-
getOpenDialogAriaText: buildGetOpenDialogAriaText({
|
|
63
|
-
utils,
|
|
64
|
-
formatKey: 'fullDate',
|
|
65
|
-
contextTranslation: translations.openDatePickerDialogue,
|
|
66
|
-
propsTranslation: props.localeText?.openDatePickerDialogue
|
|
67
|
-
}),
|
|
68
59
|
validator: validateDate
|
|
69
60
|
});
|
|
70
61
|
return renderPicker();
|
|
@@ -8,14 +8,12 @@ import { refType } from '@mui/utils';
|
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { DateTimeField } from "../DateTimeField/index.js";
|
|
10
10
|
import { useDateTimePickerDefaultizedProps } from "../DateTimePicker/shared.js";
|
|
11
|
-
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
12
11
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
13
12
|
import { extractValidationProps, validateDateTime } from "../validation/index.js";
|
|
14
13
|
import { useMobilePicker } from "../internals/hooks/useMobilePicker/index.js";
|
|
15
14
|
import { renderDateViewCalendar } from "../dateViewRenderers/index.js";
|
|
16
15
|
import { renderTimeViewClock } from "../timeViewRenderers/index.js";
|
|
17
16
|
import { resolveDateTimeFormat } from "../internals/utils/date-time-utils.js";
|
|
18
|
-
import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalization.js";
|
|
19
17
|
/**
|
|
20
18
|
* Demos:
|
|
21
19
|
*
|
|
@@ -27,7 +25,6 @@ import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalizat
|
|
|
27
25
|
* - [MobileDateTimePicker API](https://mui.com/x/api/date-pickers/mobile-date-time-picker/)
|
|
28
26
|
*/
|
|
29
27
|
const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTimePicker(inProps, ref) {
|
|
30
|
-
const translations = usePickerTranslations();
|
|
31
28
|
const utils = useUtils();
|
|
32
29
|
|
|
33
30
|
// Props with the default values common to all date time pickers
|
|
@@ -69,12 +66,6 @@ const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTi
|
|
|
69
66
|
props,
|
|
70
67
|
valueManager: singleItemValueManager,
|
|
71
68
|
valueType: 'date-time',
|
|
72
|
-
getOpenDialogAriaText: buildGetOpenDialogAriaText({
|
|
73
|
-
utils,
|
|
74
|
-
formatKey: 'fullDate',
|
|
75
|
-
contextTranslation: translations.openDatePickerDialogue,
|
|
76
|
-
propsTranslation: props.localeText?.openDatePickerDialogue
|
|
77
|
-
}),
|
|
78
69
|
validator: validateDateTime
|
|
79
70
|
});
|
|
80
71
|
return renderPicker();
|
|
@@ -8,13 +8,11 @@ import { refType } from '@mui/utils';
|
|
|
8
8
|
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
9
9
|
import { TimeField } from "../TimeField/index.js";
|
|
10
10
|
import { useTimePickerDefaultizedProps } from "../TimePicker/shared.js";
|
|
11
|
-
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
12
11
|
import { useUtils } from "../internals/hooks/useUtils.js";
|
|
13
12
|
import { extractValidationProps, validateTime } from "../validation/index.js";
|
|
14
13
|
import { useMobilePicker } from "../internals/hooks/useMobilePicker/index.js";
|
|
15
14
|
import { renderTimeViewClock } from "../timeViewRenderers/index.js";
|
|
16
15
|
import { resolveTimeFormat } from "../internals/utils/time-utils.js";
|
|
17
|
-
import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalization.js";
|
|
18
16
|
/**
|
|
19
17
|
* Demos:
|
|
20
18
|
*
|
|
@@ -26,7 +24,6 @@ import { buildGetOpenDialogAriaText } from "../locales/utils/getPickersLocalizat
|
|
|
26
24
|
* - [MobileTimePicker API](https://mui.com/x/api/date-pickers/mobile-time-picker/)
|
|
27
25
|
*/
|
|
28
26
|
const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker(inProps, ref) {
|
|
29
|
-
const translations = usePickerTranslations();
|
|
30
27
|
const utils = useUtils();
|
|
31
28
|
|
|
32
29
|
// Props with the default values common to all time pickers
|
|
@@ -62,12 +59,6 @@ const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker
|
|
|
62
59
|
props,
|
|
63
60
|
valueManager: singleItemValueManager,
|
|
64
61
|
valueType: 'time',
|
|
65
|
-
getOpenDialogAriaText: buildGetOpenDialogAriaText({
|
|
66
|
-
utils,
|
|
67
|
-
formatKey: 'fullTime',
|
|
68
|
-
contextTranslation: translations.openTimePickerDialogue,
|
|
69
|
-
propsTranslation: props.localeText?.openTimePickerDialogue
|
|
70
|
-
}),
|
|
71
62
|
validator: validateTime
|
|
72
63
|
});
|
|
73
64
|
return renderPicker();
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
4
|
const _excluded = ["slots", "slotProps", "InputProps", "inputProps"];
|
|
6
5
|
import * as React from 'react';
|
|
7
6
|
import PropTypes from 'prop-types';
|
|
8
|
-
import MuiTextField from '@mui/material/TextField';
|
|
9
7
|
import { useThemeProps } from '@mui/material/styles';
|
|
10
|
-
import useSlotProps from '@mui/utils/useSlotProps';
|
|
11
8
|
import { refType } from '@mui/utils';
|
|
12
9
|
import { useTimeField } from "./useTimeField.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { convertFieldResponseIntoMuiTextFieldProps } from "../internals/utils/convertFieldResponseIntoMuiTextFieldProps.js";
|
|
16
|
-
import { useFieldOwnerState } from "../internals/hooks/useFieldOwnerState.js";
|
|
10
|
+
import { PickerFieldUI, useFieldTextFieldProps } from "../internals/components/PickerFieldUI.js";
|
|
11
|
+
import { ClockIcon } from "../icons/index.js";
|
|
17
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
13
|
/**
|
|
19
14
|
* Demos:
|
|
@@ -32,33 +27,21 @@ const TimeField = /*#__PURE__*/React.forwardRef(function TimeField(inProps, inRe
|
|
|
32
27
|
});
|
|
33
28
|
const {
|
|
34
29
|
slots,
|
|
35
|
-
slotProps
|
|
36
|
-
InputProps,
|
|
37
|
-
inputProps
|
|
30
|
+
slotProps
|
|
38
31
|
} = themeProps,
|
|
39
32
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
externalSlotProps: slotProps?.textField,
|
|
45
|
-
externalForwardedProps: other,
|
|
46
|
-
ownerState,
|
|
47
|
-
additionalProps: {
|
|
48
|
-
ref: inRef
|
|
49
|
-
}
|
|
33
|
+
const textFieldProps = useFieldTextFieldProps({
|
|
34
|
+
slotProps,
|
|
35
|
+
ref: inRef,
|
|
36
|
+
externalForwardedProps: other
|
|
50
37
|
});
|
|
51
|
-
|
|
52
|
-
// TODO: Remove when mui/material-ui#35088 will be merged
|
|
53
|
-
textFieldProps.inputProps = _extends({}, inputProps, textFieldProps.inputProps);
|
|
54
|
-
textFieldProps.InputProps = _extends({}, InputProps, textFieldProps.InputProps);
|
|
55
38
|
const fieldResponse = useTimeField(textFieldProps);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
39
|
+
return /*#__PURE__*/_jsx(PickerFieldUI, {
|
|
40
|
+
slots: slots,
|
|
41
|
+
slotProps: slotProps,
|
|
42
|
+
fieldResponse: fieldResponse,
|
|
43
|
+
defaultOpenPickerIcon: ClockIcon
|
|
44
|
+
});
|
|
62
45
|
});
|
|
63
46
|
process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
64
47
|
// ----------------------------- Warning --------------------------------
|
|
@@ -81,6 +64,12 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
81
64
|
* @default false
|
|
82
65
|
*/
|
|
83
66
|
clearable: PropTypes.bool,
|
|
67
|
+
/**
|
|
68
|
+
* The position at which the clear button is placed.
|
|
69
|
+
* If the field is not clearable, the button is not rendered.
|
|
70
|
+
* @default 'end'
|
|
71
|
+
*/
|
|
72
|
+
clearButtonPosition: PropTypes.oneOf(['end', 'start']),
|
|
84
73
|
/**
|
|
85
74
|
* The color of the component.
|
|
86
75
|
* It supports both default and custom theme colors, which can be added as shown in the
|
|
@@ -234,6 +223,12 @@ process.env.NODE_ENV !== "production" ? TimeField.propTypes = {
|
|
|
234
223
|
* @param {FieldSelectedSections} newValue The new selected sections.
|
|
235
224
|
*/
|
|
236
225
|
onSelectedSectionsChange: PropTypes.func,
|
|
226
|
+
/**
|
|
227
|
+
* The position at which the opening button is placed.
|
|
228
|
+
* If there is no picker to open, the button is not rendered
|
|
229
|
+
* @default 'end'
|
|
230
|
+
*/
|
|
231
|
+
openPickerButtonPosition: PropTypes.oneOf(['end', 'start']),
|
|
237
232
|
/**
|
|
238
233
|
* If `true`, the component is read-only.
|
|
239
234
|
* When read-only, the value cannot be changed but the user can interact with the interface.
|
|
@@ -19,6 +19,7 @@ export const useTimeField = props => {
|
|
|
19
19
|
valueManager: manager.internal_valueManager,
|
|
20
20
|
fieldValueManager: manager.internal_fieldValueManager,
|
|
21
21
|
validator: manager.validator,
|
|
22
|
-
valueType: manager.valueType
|
|
22
|
+
valueType: manager.valueType,
|
|
23
|
+
getOpenPickerButtonAriaLabel: manager.internal_getOpenPickerButtonAriaLabel
|
|
23
24
|
});
|
|
24
25
|
};
|
|
@@ -6,32 +6,30 @@ import { useUtils } from "../internals/hooks/useUtils.js";
|
|
|
6
6
|
import { buildSectionsFromFormat } from "../internals/hooks/useField/buildSectionsFromFormat.js";
|
|
7
7
|
import { getLocalizedDigits } from "../internals/hooks/useField/useField.utils.js";
|
|
8
8
|
import { usePickerTranslations } from "./usePickerTranslations.js";
|
|
9
|
+
import { useNullablePickerContext } from "../internals/hooks/useNullablePickerContext.js";
|
|
9
10
|
/**
|
|
10
11
|
* Returns the parsed format to be rendered in the field when there is no value or in other parts of the Picker.
|
|
11
12
|
* This format is localized (for example `AAAA` for the year with the French locale) and cannot be parsed by your date library.
|
|
12
13
|
* @param {object} The parameters needed to build the placeholder.
|
|
13
|
-
* @param {string} params.format Format
|
|
14
|
-
* @param {'dense' | 'spacious'} params.formatDensity Density of the format (setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character).
|
|
15
|
-
* @param {boolean} params.shouldRespectLeadingZeros If `true`, the format will respect the leading zeroes, if `false`, the format will always add leading zeroes.
|
|
14
|
+
* @param {string} params.format Format to parse.
|
|
16
15
|
* @returns
|
|
17
16
|
*/
|
|
18
|
-
export const useParsedFormat = parameters => {
|
|
19
|
-
const
|
|
20
|
-
format,
|
|
21
|
-
formatDensity = 'dense',
|
|
22
|
-
shouldRespectLeadingZeros = false
|
|
23
|
-
} = parameters;
|
|
17
|
+
export const useParsedFormat = (parameters = {}) => {
|
|
18
|
+
const pickerContext = useNullablePickerContext();
|
|
24
19
|
const utils = useUtils();
|
|
25
20
|
const isRtl = useRtl();
|
|
26
21
|
const translations = usePickerTranslations();
|
|
27
22
|
const localizedDigits = React.useMemo(() => getLocalizedDigits(utils), [utils]);
|
|
23
|
+
const {
|
|
24
|
+
format = pickerContext?.fieldFormat ?? utils.formats.fullDate
|
|
25
|
+
} = parameters;
|
|
28
26
|
return React.useMemo(() => {
|
|
29
27
|
const sections = buildSectionsFromFormat({
|
|
30
28
|
utils,
|
|
31
29
|
format,
|
|
32
|
-
formatDensity,
|
|
30
|
+
formatDensity: 'dense',
|
|
33
31
|
isRtl,
|
|
34
|
-
shouldRespectLeadingZeros,
|
|
32
|
+
shouldRespectLeadingZeros: true,
|
|
35
33
|
localeText: translations,
|
|
36
34
|
localizedDigits,
|
|
37
35
|
date: null,
|
|
@@ -39,5 +37,5 @@ export const useParsedFormat = parameters => {
|
|
|
39
37
|
enableAccessibleFieldDOMStructure: false
|
|
40
38
|
});
|
|
41
39
|
return sections.map(section => `${section.startSeparator}${section.placeholder}${section.endSeparator}`).join('');
|
|
42
|
-
}, [utils, isRtl, translations, localizedDigits, format
|
|
40
|
+
}, [utils, isRtl, translations, localizedDigits, format]);
|
|
43
41
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
|
|
4
|
+
export const PickerContext = /*#__PURE__*/React.createContext(null);
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Returns the context passed by the picker that wraps the current component.
|
|
7
8
|
*/
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from "../validation/extractValidationProps.js";
|
|
6
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
|
|
6
|
+
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'unstableStartFieldRef', 'unstableEndFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator', 'autoFocus'];
|
|
7
7
|
/**
|
|
8
8
|
* Split the props received by the field component into:
|
|
9
9
|
* - `internalProps` which are used by the various hooks called by the field component.
|
|
10
10
|
* - `forwardedProps` which are passed to the underlying component.
|
|
11
11
|
* Note that some forwarded props might be used by the hooks as well.
|
|
12
|
-
* For instance, hooks like `useDateField` need props like `
|
|
12
|
+
* For instance, hooks like `useDateField` need props like `onKeyDown` to merge the default event handler and the one provided by the application.
|
|
13
13
|
* @template TProps, TValueType
|
|
14
14
|
* @param {TProps} props The props received by the field component.
|
|
15
15
|
* @param {TValueType} valueType The type of the field value ('date', 'time', or 'date-time').
|
|
@@ -40,4 +40,9 @@ export const useSplitFieldProps = (props, valueType) => {
|
|
|
40
40
|
internalProps
|
|
41
41
|
};
|
|
42
42
|
}, [props, valueType]);
|
|
43
|
-
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extract the internal props from the props received by the field component.
|
|
47
|
+
* This makes sure that the internal props not defined in the props are not present in the result.
|
|
48
|
+
*/
|
package/modern/index.js
CHANGED