@mui/x-date-pickers 8.0.0-alpha.5 → 8.0.0-alpha.7
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 +206 -1
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +13 -11
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePicker.types.d.ts +5 -0
- package/DatePicker/DatePickerToolbar.d.ts +1 -3
- package/DatePicker/DatePickerToolbar.js +10 -25
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +13 -11
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
- package/DateTimePicker/DateTimePickerTabs.js +7 -14
- package/DateTimePicker/DateTimePickerToolbar.d.ts +12 -4
- package/DateTimePicker/DateTimePickerToolbar.js +42 -48
- package/DateTimePicker/shared.d.ts +3 -3
- package/DesktopDatePicker/DesktopDatePicker.js +9 -3
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -15
- package/DesktopTimePicker/DesktopTimePicker.js +3 -7
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDatePicker/MobileDatePicker.js +2 -2
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.js +2 -2
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- package/PickersActionBar/PickersActionBar.d.ts +6 -7
- package/PickersActionBar/PickersActionBar.js +18 -16
- package/PickersLayout/PickersLayout.d.ts +2 -2
- package/PickersLayout/PickersLayout.js +1 -15
- package/PickersLayout/PickersLayout.types.d.ts +12 -15
- package/PickersLayout/usePickerLayout.d.ts +2 -2
- package/PickersLayout/usePickerLayout.js +13 -47
- 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/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +13 -11
- package/TimePicker/TimePicker.js +2 -2
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.d.ts +1 -2
- package/TimePicker/TimePickerToolbar.js +23 -35
- package/TimePicker/shared.d.ts +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -1
- package/hooks/useIsValidValue.d.ts +7 -0
- package/hooks/useIsValidValue.js +11 -0
- package/hooks/usePickerActionsContext.d.ts +7 -0
- package/hooks/usePickerActionsContext.js +15 -0
- package/hooks/usePickerContext.d.ts +3 -1
- package/hooks/usePickerContext.js +1 -2
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/PickerProvider.d.ts +14 -8
- package/internals/components/PickerProvider.js +17 -6
- package/internals/components/PickersModalDialog.d.ts +1 -3
- package/internals/components/PickersModalDialog.js +9 -3
- package/internals/components/PickersPopper.d.ts +1 -3
- package/internals/components/PickersPopper.js +11 -6
- package/internals/components/PickersToolbar.d.ts +2 -3
- package/internals/components/PickersToolbar.js +1 -1
- package/internals/hooks/date-helpers-hooks.js +4 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +10 -12
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +7 -7
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/index.d.ts +1 -1
- package/internals/hooks/useField/index.js +1 -1
- package/internals/hooks/useField/useField.d.ts +10 -1
- package/internals/hooks/useField/useField.js +17 -1
- package/internals/hooks/useField/useField.utils.js +2 -2
- package/internals/hooks/useField/useFieldState.js +2 -2
- package/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +9 -10
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +7 -7
- package/internals/hooks/useOpenState.js +3 -2
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +0 -8
- package/internals/hooks/usePicker/usePicker.types.d.ts +6 -7
- package/internals/hooks/usePicker/usePickerProvider.d.ts +5 -5
- package/internals/hooks/usePicker/usePickerProvider.js +8 -5
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +82 -217
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +82 -67
- package/internals/hooks/usePicker/usePickerViews.d.ts +35 -20
- package/internals/hooks/usePicker/usePickerViews.js +22 -14
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +6 -6
- package/internals/hooks/useUtils.js +1 -1
- package/internals/index.d.ts +9 -7
- package/internals/index.js +5 -3
- package/internals/models/index.d.ts +1 -0
- package/internals/models/index.js +2 -1
- package/internals/models/manager.d.ts +12 -0
- package/internals/models/manager.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +2 -2
- package/internals/models/props/tabs.d.ts +0 -13
- package/internals/models/props/toolbar.d.ts +1 -20
- 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.js +1 -1
- 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 +47 -0
- package/managers/useDateTimeManager.d.ts +28 -0
- package/managers/useDateTimeManager.js +52 -0
- package/managers/useTimeManager.d.ts +28 -0
- package/managers/useTimeManager.js +43 -0
- package/models/adapters.d.ts +1 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/manager.d.ts +78 -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/useDateField.js +13 -11
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DatePicker/DatePickerToolbar.js +10 -25
- package/modern/DateTimeField/useDateTimeField.js +13 -11
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +7 -14
- package/modern/DateTimePicker/DateTimePickerToolbar.js +42 -48
- package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -3
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -15
- package/modern/DesktopTimePicker/DesktopTimePicker.js +3 -7
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/modern/MobileTimePicker/MobileTimePicker.js +2 -2
- package/modern/PickersActionBar/PickersActionBar.js +18 -16
- package/modern/PickersLayout/PickersLayout.js +1 -15
- package/modern/PickersLayout/usePickerLayout.js +13 -47
- 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/useTimeField.js +13 -11
- package/modern/TimePicker/TimePicker.js +2 -2
- package/modern/TimePicker/TimePickerToolbar.js +23 -35
- package/modern/hooks/index.js +3 -1
- package/modern/hooks/useIsValidValue.js +11 -0
- package/modern/hooks/usePickerActionsContext.js +15 -0
- package/modern/hooks/usePickerContext.js +1 -2
- package/modern/index.js +3 -2
- package/modern/internals/components/PickerProvider.js +17 -6
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersPopper.js +11 -6
- 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 +10 -12
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/modern/internals/hooks/useField/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +17 -1
- package/modern/internals/hooks/useField/useField.utils.js +2 -2
- package/modern/internals/hooks/useField/useFieldState.js +2 -2
- package/modern/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +9 -10
- package/modern/internals/hooks/useOpenState.js +3 -2
- package/modern/internals/hooks/usePicker/usePicker.js +0 -8
- package/modern/internals/hooks/usePicker/usePickerProvider.js +8 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +82 -217
- package/modern/internals/hooks/usePicker/usePickerViews.js +22 -14
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/index.js +5 -3
- 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 +1 -1
- package/modern/locales/zhTW.js +73 -0
- package/modern/managers/index.js +3 -0
- package/modern/managers/useDateManager.js +47 -0
- package/modern/managers/useDateTimeManager.js +52 -0
- package/modern/managers/useTimeManager.js +43 -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/useDateField.js +12 -10
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +10 -25
- package/node/DateTimeField/useDateTimeField.js +12 -10
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +7 -14
- package/node/DateTimePicker/DateTimePickerToolbar.js +43 -49
- package/node/DesktopDatePicker/DesktopDatePicker.js +9 -3
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -15
- package/node/DesktopTimePicker/DesktopTimePicker.js +3 -7
- package/node/MobileDatePicker/MobileDatePicker.js +2 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/node/MobileTimePicker/MobileTimePicker.js +2 -2
- package/node/PickersActionBar/PickersActionBar.js +20 -18
- package/node/PickersLayout/PickersLayout.js +1 -15
- package/node/PickersLayout/usePickerLayout.js +17 -51
- 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/useTimeField.js +12 -10
- package/node/TimePicker/TimePicker.js +2 -2
- package/node/TimePicker/TimePickerToolbar.js +23 -35
- package/node/hooks/index.js +15 -1
- package/node/hooks/useIsValidValue.js +18 -0
- package/node/hooks/usePickerActionsContext.js +22 -0
- package/node/hooks/usePickerContext.js +1 -1
- package/node/index.js +13 -1
- package/node/internals/components/PickerProvider.js +18 -7
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersPopper.js +11 -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 +10 -12
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/node/internals/hooks/useField/index.js +6 -0
- package/node/internals/hooks/useField/useField.js +18 -1
- package/node/internals/hooks/useField/useField.utils.js +2 -2
- package/node/internals/hooks/useField/useFieldState.js +2 -2
- package/node/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +9 -10
- package/node/internals/hooks/useOpenState.js +4 -2
- package/node/internals/hooks/usePicker/usePicker.js +0 -9
- package/node/internals/hooks/usePicker/usePickerProvider.js +8 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +82 -217
- package/node/internals/hooks/usePicker/usePickerViews.js +22 -15
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/index.js +28 -20
- 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 +1 -1
- package/node/locales/zhTW.js +79 -0
- package/node/managers/index.js +26 -0
- package/node/managers/useDateManager.js +55 -0
- package/node/managers/useDateTimeManager.js +60 -0
- package/node/managers/useTimeManager.js +51 -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 +2 -3
- 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/modern/AdapterDateFnsJalaliV3/index.js +0 -1
- package/modern/AdapterDateFnsV3/index.js +0 -1
- package/modern/internals/hooks/defaultizedFieldProps.js +0 -40
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -299
- package/node/internals/hooks/defaultizedFieldProps.js +0 -50
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["ampm", "ampmInClock", "
|
|
5
|
+
const _excluded = ["ampm", "ampmInClock", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -122,12 +122,6 @@ function TimePickerToolbar(inProps) {
|
|
|
122
122
|
const {
|
|
123
123
|
ampm,
|
|
124
124
|
ampmInClock,
|
|
125
|
-
value,
|
|
126
|
-
isLandscape,
|
|
127
|
-
onChange,
|
|
128
|
-
view,
|
|
129
|
-
onViewChange,
|
|
130
|
-
views,
|
|
131
125
|
className,
|
|
132
126
|
classes: classesProp
|
|
133
127
|
} = props,
|
|
@@ -137,15 +131,27 @@ function TimePickerToolbar(inProps) {
|
|
|
137
131
|
const ownerState = useToolbarOwnerState();
|
|
138
132
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
139
133
|
const {
|
|
134
|
+
value,
|
|
135
|
+
setValue,
|
|
140
136
|
disabled,
|
|
141
|
-
readOnly
|
|
137
|
+
readOnly,
|
|
138
|
+
view,
|
|
139
|
+
setView,
|
|
140
|
+
views
|
|
142
141
|
} = usePickerContext();
|
|
143
142
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
144
143
|
const {
|
|
145
144
|
meridiemMode,
|
|
146
145
|
handleMeridiemChange
|
|
147
|
-
} = useMeridiemMode(value, ampm,
|
|
148
|
-
|
|
146
|
+
} = useMeridiemMode(value, ampm, newValue => setValue(newValue, {
|
|
147
|
+
changeImportance: 'set'
|
|
148
|
+
}));
|
|
149
|
+
const formatSection = format => {
|
|
150
|
+
if (!utils.isValid(value)) {
|
|
151
|
+
return '--';
|
|
152
|
+
}
|
|
153
|
+
return utils.format(value, format);
|
|
154
|
+
};
|
|
149
155
|
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
|
|
150
156
|
tabIndex: -1,
|
|
151
157
|
value: ":",
|
|
@@ -156,7 +162,6 @@ function TimePickerToolbar(inProps) {
|
|
|
156
162
|
return /*#__PURE__*/_jsxs(TimePickerToolbarRoot, _extends({
|
|
157
163
|
landscapeDirection: "row",
|
|
158
164
|
toolbarTitle: translations.timePickerToolbarTitle,
|
|
159
|
-
isLandscape: isLandscape,
|
|
160
165
|
ownerState: ownerState,
|
|
161
166
|
className: clsx(classes.root, className)
|
|
162
167
|
}, other, {
|
|
@@ -166,20 +171,20 @@ function TimePickerToolbar(inProps) {
|
|
|
166
171
|
children: [arrayIncludes(views, 'hours') && /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
167
172
|
tabIndex: -1,
|
|
168
173
|
variant: "h3",
|
|
169
|
-
onClick: () =>
|
|
174
|
+
onClick: () => setView('hours'),
|
|
170
175
|
selected: view === 'hours',
|
|
171
|
-
value:
|
|
176
|
+
value: formatSection(ampm ? 'hours12h' : 'hours24h')
|
|
172
177
|
}), arrayIncludes(views, ['hours', 'minutes']) && separator, arrayIncludes(views, 'minutes') && /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
173
178
|
tabIndex: -1,
|
|
174
179
|
variant: "h3",
|
|
175
|
-
onClick: () =>
|
|
180
|
+
onClick: () => setView('minutes'),
|
|
176
181
|
selected: view === 'minutes',
|
|
177
|
-
value:
|
|
182
|
+
value: formatSection('minutes')
|
|
178
183
|
}), arrayIncludes(views, ['minutes', 'seconds']) && separator, arrayIncludes(views, 'seconds') && /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
179
184
|
variant: "h3",
|
|
180
|
-
onClick: () =>
|
|
185
|
+
onClick: () => setView('seconds'),
|
|
181
186
|
selected: view === 'seconds',
|
|
182
|
-
value:
|
|
187
|
+
value: formatSection('seconds')
|
|
183
188
|
})]
|
|
184
189
|
}), showAmPmControl && /*#__PURE__*/_jsxs(TimePickerToolbarAmPmSelection, {
|
|
185
190
|
className: classes.ampmSelection,
|
|
@@ -221,14 +226,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
221
226
|
* @default `true` for Desktop, `false` for Mobile.
|
|
222
227
|
*/
|
|
223
228
|
hidden: PropTypes.bool,
|
|
224
|
-
isLandscape: PropTypes.bool.isRequired,
|
|
225
|
-
onChange: PropTypes.func.isRequired,
|
|
226
|
-
/**
|
|
227
|
-
* Callback called when a toolbar is clicked
|
|
228
|
-
* @template TView
|
|
229
|
-
* @param {TView} view The view to open
|
|
230
|
-
*/
|
|
231
|
-
onViewChange: PropTypes.func.isRequired,
|
|
232
229
|
/**
|
|
233
230
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
234
231
|
*/
|
|
@@ -242,15 +239,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
242
239
|
* Toolbar value placeholder—it is displayed when the value is empty.
|
|
243
240
|
* @default "––"
|
|
244
241
|
*/
|
|
245
|
-
toolbarPlaceholder: PropTypes.node
|
|
246
|
-
value: PropTypes.object,
|
|
247
|
-
/**
|
|
248
|
-
* Currently visible picker view.
|
|
249
|
-
*/
|
|
250
|
-
view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired,
|
|
251
|
-
/**
|
|
252
|
-
* Available views.
|
|
253
|
-
*/
|
|
254
|
-
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']).isRequired).isRequired
|
|
242
|
+
toolbarPlaceholder: PropTypes.node
|
|
255
243
|
} : void 0;
|
|
256
244
|
export { TimePickerToolbar };
|
package/TimePicker/shared.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface BaseTimePickerSlots extends TimeClockSlots {
|
|
|
20
20
|
export interface BaseTimePickerSlotProps extends TimeClockSlotProps {
|
|
21
21
|
toolbar?: ExportedTimePickerToolbarProps;
|
|
22
22
|
}
|
|
23
|
-
export type TimePickerViewRenderers<TView extends TimeViewWithMeridiem
|
|
23
|
+
export type TimePickerViewRenderers<TView extends TimeViewWithMeridiem> = PickerViewRendererLookup<PickerValue, TView, TimeViewRendererProps<TView, BaseClockProps<TView>>>;
|
|
24
24
|
export interface BaseTimePickerProps<TView extends TimeViewWithMeridiem> extends BasePickerInputProps<PickerValue, TView, TimeValidationError>, ExportedBaseClockProps {
|
|
25
25
|
/**
|
|
26
26
|
* Display ampm controls under the clock (instead of in the toolbar).
|
package/hooks/index.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export { usePickerTranslations } from './usePickerTranslations';
|
|
|
4
4
|
export { useSplitFieldProps } from './useSplitFieldProps';
|
|
5
5
|
export { useParsedFormat } from './useParsedFormat';
|
|
6
6
|
export { usePickerContext } from './usePickerContext';
|
|
7
|
+
export { usePickerActionsContext } from './usePickerActionsContext';
|
|
8
|
+
export { useIsValidValue } from './useIsValidValue';
|
package/hooks/index.js
CHANGED
|
@@ -2,4 +2,6 @@ export { useClearableField } from "./useClearableField.js";
|
|
|
2
2
|
export { usePickerTranslations } from "./usePickerTranslations.js";
|
|
3
3
|
export { useSplitFieldProps } from "./useSplitFieldProps.js";
|
|
4
4
|
export { useParsedFormat } from "./useParsedFormat.js";
|
|
5
|
-
export { usePickerContext } from "./usePickerContext.js";
|
|
5
|
+
export { usePickerContext } from "./usePickerContext.js";
|
|
6
|
+
export { usePickerActionsContext } from "./usePickerActionsContext.js";
|
|
7
|
+
export { useIsValidValue } from "./useIsValidValue.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerValidValue } from '../internals/models';
|
|
3
|
+
export declare const IsValidValueContext: React.Context<(value: any) => boolean>;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a function to check if a value is valid according to the validation props passed to the parent picker.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useIsValidValue<TValue extends PickerValidValue>(): (value: TValue) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const IsValidValueContext = /*#__PURE__*/React.createContext(() => true);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns a function to check if a value is valid according to the validation props passed to the parent picker.
|
|
8
|
+
*/
|
|
9
|
+
export function useIsValidValue() {
|
|
10
|
+
return React.useContext(IsValidValueContext);
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PickerActionsContextValue } from '../internals/components/PickerProvider';
|
|
2
|
+
import { DateOrTimeViewWithMeridiem, PickerValidValue, PickerValue } from '../internals/models';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a subset of the context passed by the picker wrapping the current component.
|
|
5
|
+
* It only contains the actions and never causes a re-render of the component using it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const usePickerActionsContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string>() => PickerActionsContextValue<TValue, TView, TError>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PickerActionsContext } from "../internals/components/PickerProvider.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns a subset of the context passed by the picker wrapping the current component.
|
|
7
|
+
* It only contains the actions and never causes a re-render of the component using it.
|
|
8
|
+
*/
|
|
9
|
+
export const usePickerActionsContext = () => {
|
|
10
|
+
const value = React.useContext(PickerActionsContext);
|
|
11
|
+
if (value == null) {
|
|
12
|
+
throw new Error(['MUI X: The `usePickerActionsContext` can only be called in fields that are used as a slot of a picker component'].join('\n'));
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { PickerContextValue } from '../internals/components/PickerProvider';
|
|
2
|
+
import { DateOrTimeViewWithMeridiem, PickerValidValue, PickerValue } from '../internals/models';
|
|
1
3
|
/**
|
|
2
4
|
* Returns the context passed by the picker that wraps the current component.
|
|
3
5
|
*/
|
|
4
|
-
export declare const usePickerContext: () =>
|
|
6
|
+
export declare const usePickerContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string>() => PickerContextValue<TValue, TView, TError>;
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { PickerContext } from "../internals/components/PickerProvider.js";
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Returns the context passed by the picker that wraps the current component.
|
|
8
7
|
*/
|
|
9
8
|
export const usePickerContext = () => {
|
|
10
9
|
const value = React.useContext(PickerContext);
|
|
11
10
|
if (value == null) {
|
|
12
|
-
throw new Error(
|
|
11
|
+
throw new Error('MUI X: The `usePickerContext` hook can only be called inside the context of a picker component');
|
|
13
12
|
}
|
|
14
13
|
return value;
|
|
15
14
|
};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers v8.0.0-alpha.
|
|
2
|
+
* @mui/x-date-pickers v8.0.0-alpha.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -57,4 +57,5 @@ export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./internals/utils/utils.js";
|
|
|
57
57
|
export * from "./models/index.js";
|
|
58
58
|
export * from "./icons/index.js";
|
|
59
59
|
export * from "./hooks/index.js";
|
|
60
|
-
export * from "./validation/index.js";
|
|
60
|
+
export * from "./validation/index.js";
|
|
61
|
+
export * from "./managers/index.js";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickerOwnerState } from '../../models';
|
|
3
3
|
import { PickersInputLocaleText } from '../../locales';
|
|
4
|
-
import { PickerOrientation, PickerVariant } from '../models';
|
|
5
|
-
import type { UsePickerValueContextValue } from '../hooks/usePicker/usePickerValue.types';
|
|
6
|
-
|
|
4
|
+
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from '../models';
|
|
5
|
+
import type { UsePickerValueActionsContextValue, UsePickerValueContextValue, UsePickerValuePrivateContextValue } from '../hooks/usePicker/usePickerValue.types';
|
|
6
|
+
import { UsePickerViewsActionsContextValue, UsePickerViewsContextValue } from '../hooks/usePicker/usePickerViews';
|
|
7
|
+
export declare const PickerContext: React.Context<PickerContextValue<any, any, any> | null>;
|
|
8
|
+
export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
|
|
7
9
|
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
|
8
10
|
/**
|
|
9
11
|
* Provides the context for the various parts of a picker component:
|
|
@@ -12,14 +14,16 @@ export declare const PickerPrivateContext: React.Context<PickerPrivateContextVal
|
|
|
12
14
|
*
|
|
13
15
|
* @ignore - do not document.
|
|
14
16
|
*/
|
|
15
|
-
export declare function PickerProvider(props: PickerProviderProps): React.JSX.Element;
|
|
16
|
-
export interface PickerProviderProps {
|
|
17
|
-
contextValue: PickerContextValue
|
|
17
|
+
export declare function PickerProvider<TValue extends PickerValidValue>(props: PickerProviderProps<TValue>): React.JSX.Element;
|
|
18
|
+
export interface PickerProviderProps<TValue extends PickerValidValue> {
|
|
19
|
+
contextValue: PickerContextValue<any, any, any>;
|
|
20
|
+
actionsContextValue: PickerActionsContextValue<any, any, any>;
|
|
18
21
|
privateContextValue: PickerPrivateContextValue;
|
|
22
|
+
isValidContextValue: (value: TValue) => boolean;
|
|
19
23
|
localeText: PickersInputLocaleText | undefined;
|
|
20
24
|
children: React.ReactNode;
|
|
21
25
|
}
|
|
22
|
-
export interface PickerContextValue extends UsePickerValueContextValue {
|
|
26
|
+
export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends UsePickerValueContextValue<TValue, TError>, UsePickerViewsContextValue<TView> {
|
|
23
27
|
/**
|
|
24
28
|
* `true` if the picker is disabled, `false` otherwise.
|
|
25
29
|
*/
|
|
@@ -46,7 +50,9 @@ export interface PickerContextValue extends UsePickerValueContextValue {
|
|
|
46
50
|
*/
|
|
47
51
|
orientation: PickerOrientation;
|
|
48
52
|
}
|
|
49
|
-
export interface
|
|
53
|
+
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string> extends UsePickerValueActionsContextValue<TValue, TError>, UsePickerViewsActionsContextValue<TView> {
|
|
54
|
+
}
|
|
55
|
+
export interface PickerPrivateContextValue extends UsePickerValuePrivateContextValue {
|
|
50
56
|
/**
|
|
51
57
|
* The ownerState of the picker.
|
|
52
58
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LocalizationProvider } from "../../LocalizationProvider/index.js";
|
|
3
|
+
import { IsValidValueContext } from "../../hooks/useIsValidValue.js";
|
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
export const PickerContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
+
export const PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
5
7
|
export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
6
8
|
ownerState: {
|
|
7
9
|
isPickerDisabled: false,
|
|
@@ -10,7 +12,8 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
|
10
12
|
isPickerOpen: false,
|
|
11
13
|
pickerVariant: 'desktop',
|
|
12
14
|
pickerOrientation: 'portrait'
|
|
13
|
-
}
|
|
15
|
+
},
|
|
16
|
+
dismissViews: () => {}
|
|
14
17
|
});
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -23,17 +26,25 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
|
23
26
|
export function PickerProvider(props) {
|
|
24
27
|
const {
|
|
25
28
|
contextValue,
|
|
29
|
+
actionsContextValue,
|
|
26
30
|
privateContextValue,
|
|
31
|
+
isValidContextValue,
|
|
27
32
|
localeText,
|
|
28
33
|
children
|
|
29
34
|
} = props;
|
|
30
35
|
return /*#__PURE__*/_jsx(PickerContext.Provider, {
|
|
31
36
|
value: contextValue,
|
|
32
|
-
children: /*#__PURE__*/_jsx(
|
|
33
|
-
value:
|
|
34
|
-
children: /*#__PURE__*/_jsx(
|
|
35
|
-
|
|
36
|
-
children:
|
|
37
|
+
children: /*#__PURE__*/_jsx(PickerActionsContext.Provider, {
|
|
38
|
+
value: actionsContextValue,
|
|
39
|
+
children: /*#__PURE__*/_jsx(PickerPrivateContext.Provider, {
|
|
40
|
+
value: privateContextValue,
|
|
41
|
+
children: /*#__PURE__*/_jsx(IsValidValueContext.Provider, {
|
|
42
|
+
value: isValidContextValue,
|
|
43
|
+
children: /*#__PURE__*/_jsx(LocalizationProvider, {
|
|
44
|
+
localeText: localeText,
|
|
45
|
+
children: children
|
|
46
|
+
})
|
|
47
|
+
})
|
|
37
48
|
})
|
|
38
49
|
})
|
|
39
50
|
});
|
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { DialogProps as MuiDialogProps } from '@mui/material/Dialog';
|
|
3
3
|
import { PaperProps as MuiPaperProps } from '@mui/material/Paper';
|
|
4
4
|
import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions';
|
|
5
|
-
import { UsePickerValueActions } from '../hooks/usePicker/usePickerValue.types';
|
|
6
5
|
export interface PickersModalDialogSlots {
|
|
7
6
|
/**
|
|
8
7
|
* Custom component for the dialog inside which the views are rendered on mobile.
|
|
@@ -34,7 +33,7 @@ export interface PickersModalDialogSlotProps {
|
|
|
34
33
|
*/
|
|
35
34
|
mobileTransition?: Partial<MuiTransitionProps>;
|
|
36
35
|
}
|
|
37
|
-
export interface PickersModalDialogProps
|
|
36
|
+
export interface PickersModalDialogProps {
|
|
38
37
|
/**
|
|
39
38
|
* Overridable component slots.
|
|
40
39
|
* @default {}
|
|
@@ -45,6 +44,5 @@ export interface PickersModalDialogProps extends UsePickerValueActions {
|
|
|
45
44
|
* @default {}
|
|
46
45
|
*/
|
|
47
46
|
slotProps?: PickersModalDialogSlotProps;
|
|
48
|
-
open: boolean;
|
|
49
47
|
}
|
|
50
48
|
export declare function PickersModalDialog(props: React.PropsWithChildren<PickersModalDialogProps>): React.JSX.Element;
|
|
@@ -5,6 +5,8 @@ import Fade from '@mui/material/Fade';
|
|
|
5
5
|
import MuiDialog, { dialogClasses } from '@mui/material/Dialog';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
7
|
import { DIALOG_WIDTH } from "../constants/dimensions.js";
|
|
8
|
+
import { usePickerContext } from "../../hooks/index.js";
|
|
9
|
+
import { usePickerPrivateContext } from "../hooks/usePickerPrivateContext.js";
|
|
8
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
11
|
const PickersModalDialogRoot = styled(MuiDialog)({
|
|
10
12
|
[`& .${dialogClasses.container}`]: {
|
|
@@ -23,16 +25,20 @@ const PickersModalDialogContent = styled(DialogContent)({
|
|
|
23
25
|
export function PickersModalDialog(props) {
|
|
24
26
|
const {
|
|
25
27
|
children,
|
|
26
|
-
onDismiss,
|
|
27
|
-
open,
|
|
28
28
|
slots,
|
|
29
29
|
slotProps
|
|
30
30
|
} = props;
|
|
31
|
+
const {
|
|
32
|
+
open
|
|
33
|
+
} = usePickerContext();
|
|
34
|
+
const {
|
|
35
|
+
dismissViews
|
|
36
|
+
} = usePickerPrivateContext();
|
|
31
37
|
const Dialog = slots?.dialog ?? PickersModalDialogRoot;
|
|
32
38
|
const Transition = slots?.mobileTransition ?? Fade;
|
|
33
39
|
return /*#__PURE__*/_jsx(Dialog, _extends({
|
|
34
40
|
open: open,
|
|
35
|
-
onClose:
|
|
41
|
+
onClose: dismissViews
|
|
36
42
|
}, slotProps?.dialog, {
|
|
37
43
|
TransitionComponent: Transition,
|
|
38
44
|
TransitionProps: slotProps?.mobileTransition,
|
|
@@ -5,7 +5,6 @@ import { TrapFocusProps as MuiTrapFocusProps } from '@mui/material/Unstable_Trap
|
|
|
5
5
|
import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions';
|
|
6
6
|
import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
7
7
|
import { PickersPopperClasses } from './pickersPopperClasses';
|
|
8
|
-
import { UsePickerValueActions } from '../hooks/usePicker/usePickerValue.types';
|
|
9
8
|
import { PickerOwnerState } from '../../models';
|
|
10
9
|
interface PickerPopperOwnerState extends PickerOwnerState {
|
|
11
10
|
popperPlacement: PopperPlacementType;
|
|
@@ -50,10 +49,9 @@ export interface PickersPopperSlotProps {
|
|
|
50
49
|
*/
|
|
51
50
|
popper?: SlotComponentPropsFromProps<PopperProps, {}, PickerPopperOwnerState>;
|
|
52
51
|
}
|
|
53
|
-
export interface PickerPopperProps
|
|
52
|
+
export interface PickerPopperProps {
|
|
54
53
|
role: 'tooltip' | 'dialog';
|
|
55
54
|
anchorEl: MuiPopperProps['anchorEl'];
|
|
56
|
-
open: MuiPopperProps['open'];
|
|
57
55
|
/**
|
|
58
56
|
* @default "bottom"
|
|
59
57
|
*/
|
|
@@ -14,6 +14,7 @@ import { getPickersPopperUtilityClass } from "./pickersPopperClasses.js";
|
|
|
14
14
|
import { getActiveElement } from "../utils/utils.js";
|
|
15
15
|
import { useDefaultReduceAnimations } from "../hooks/useDefaultReduceAnimations.js";
|
|
16
16
|
import { usePickerPrivateContext } from "../hooks/usePickerPrivateContext.js";
|
|
17
|
+
import { usePickerContext } from "../../hooks/index.js";
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
const useUtilityClasses = classes => {
|
|
19
20
|
const slots = {
|
|
@@ -210,8 +211,6 @@ export function PickersPopper(inProps) {
|
|
|
210
211
|
containerRef = null,
|
|
211
212
|
shouldRestoreFocus,
|
|
212
213
|
onBlur,
|
|
213
|
-
onDismiss,
|
|
214
|
-
open,
|
|
215
214
|
role,
|
|
216
215
|
placement = 'bottom',
|
|
217
216
|
slots,
|
|
@@ -219,17 +218,23 @@ export function PickersPopper(inProps) {
|
|
|
219
218
|
reduceAnimations: inReduceAnimations,
|
|
220
219
|
classes: classesProp
|
|
221
220
|
} = props;
|
|
221
|
+
const {
|
|
222
|
+
open
|
|
223
|
+
} = usePickerContext();
|
|
224
|
+
const {
|
|
225
|
+
dismissViews
|
|
226
|
+
} = usePickerPrivateContext();
|
|
222
227
|
React.useEffect(() => {
|
|
223
228
|
function handleKeyDown(nativeEvent) {
|
|
224
229
|
if (open && nativeEvent.key === 'Escape') {
|
|
225
|
-
|
|
230
|
+
dismissViews();
|
|
226
231
|
}
|
|
227
232
|
}
|
|
228
233
|
document.addEventListener('keydown', handleKeyDown);
|
|
229
234
|
return () => {
|
|
230
235
|
document.removeEventListener('keydown', handleKeyDown);
|
|
231
236
|
};
|
|
232
|
-
}, [
|
|
237
|
+
}, [dismissViews, open]);
|
|
233
238
|
const lastFocusedElementRef = React.useRef(null);
|
|
234
239
|
React.useEffect(() => {
|
|
235
240
|
if (role === 'tooltip' || shouldRestoreFocus && !shouldRestoreFocus()) {
|
|
@@ -247,7 +252,7 @@ export function PickersPopper(inProps) {
|
|
|
247
252
|
});
|
|
248
253
|
}
|
|
249
254
|
}, [open, role, shouldRestoreFocus]);
|
|
250
|
-
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, onBlur ??
|
|
255
|
+
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, onBlur ?? dismissViews);
|
|
251
256
|
const paperRef = React.useRef(null);
|
|
252
257
|
const handleRef = useForkRef(paperRef, containerRef);
|
|
253
258
|
const handlePaperRef = useForkRef(handleRef, clickAwayRef);
|
|
@@ -264,7 +269,7 @@ export function PickersPopper(inProps) {
|
|
|
264
269
|
if (event.key === 'Escape') {
|
|
265
270
|
// stop the propagation to avoid closing parent modal
|
|
266
271
|
event.stopPropagation();
|
|
267
|
-
|
|
272
|
+
dismissViews();
|
|
268
273
|
}
|
|
269
274
|
};
|
|
270
275
|
const Transition = slots?.desktopTransition ?? reduceAnimations ? Fade : Grow;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseToolbarProps } from '../models/props/toolbar';
|
|
3
3
|
import { PickersToolbarClasses } from './pickersToolbarClasses';
|
|
4
|
-
|
|
5
|
-
export interface PickersToolbarProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem> extends Pick<BaseToolbarProps<TValue, TView>, 'isLandscape' | 'hidden' | 'titleId'> {
|
|
4
|
+
export interface PickersToolbarProps extends Pick<BaseToolbarProps, 'hidden' | 'titleId'> {
|
|
6
5
|
className?: string;
|
|
7
6
|
landscapeDirection?: 'row' | 'column';
|
|
8
7
|
toolbarTitle: React.ReactNode;
|
|
9
8
|
classes?: Partial<PickersToolbarClasses>;
|
|
10
9
|
}
|
|
11
|
-
type PickersToolbarComponent = (
|
|
10
|
+
type PickersToolbarComponent = ((props: React.PropsWithChildren<PickersToolbarProps> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
12
11
|
propTypes?: any;
|
|
13
12
|
};
|
|
14
13
|
export declare const PickersToolbar: PickersToolbarComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "
|
|
3
|
+
const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "classes", "landscapeDirection"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import Typography from '@mui/material/Typography';
|
|
@@ -27,11 +27,12 @@ export function usePreviousMonthDisabled(month, {
|
|
|
27
27
|
}
|
|
28
28
|
export function useMeridiemMode(date, ampm, onChange, selectionState) {
|
|
29
29
|
const utils = useUtils();
|
|
30
|
-
const
|
|
30
|
+
const cleanDate = React.useMemo(() => !utils.isValid(date) ? null : date, [utils, date]);
|
|
31
|
+
const meridiemMode = getMeridiem(cleanDate, utils);
|
|
31
32
|
const handleMeridiemChange = React.useCallback(mode => {
|
|
32
|
-
const timeWithMeridiem =
|
|
33
|
+
const timeWithMeridiem = cleanDate == null ? null : convertToMeridiem(cleanDate, mode, Boolean(ampm), utils);
|
|
33
34
|
onChange(timeWithMeridiem, selectionState ?? 'partial');
|
|
34
|
-
}, [ampm,
|
|
35
|
+
}, [ampm, cleanDate, onChange, selectionState, utils]);
|
|
35
36
|
return {
|
|
36
37
|
meridiemMode,
|
|
37
38
|
handleMeridiemChange
|
|
@@ -52,10 +52,7 @@ export const useDesktopPicker = _ref => {
|
|
|
52
52
|
const labelId = useId();
|
|
53
53
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
54
54
|
const {
|
|
55
|
-
open,
|
|
56
|
-
actions,
|
|
57
55
|
hasUIView,
|
|
58
|
-
layoutProps,
|
|
59
56
|
providerProps,
|
|
60
57
|
renderCurrentView,
|
|
61
58
|
shouldRestoreFocus,
|
|
@@ -66,7 +63,6 @@ export const useDesktopPicker = _ref => {
|
|
|
66
63
|
fieldRef,
|
|
67
64
|
localeText,
|
|
68
65
|
autoFocusView: true,
|
|
69
|
-
additionalViewProps: {},
|
|
70
66
|
variant: 'desktop'
|
|
71
67
|
}));
|
|
72
68
|
const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
|
|
@@ -85,7 +81,11 @@ export const useDesktopPicker = _ref => {
|
|
|
85
81
|
externalSlotProps: innerSlotProps?.openPickerButton,
|
|
86
82
|
additionalProps: {
|
|
87
83
|
disabled: disabled || readOnly,
|
|
88
|
-
|
|
84
|
+
// This direct access to `providerProps` will go away in https://github.com/mui/mui-x/pull/15671
|
|
85
|
+
onClick: event => {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
providerProps.contextValue.setOpen(prevOpen => !prevOpen);
|
|
88
|
+
},
|
|
89
89
|
'aria-label': getOpenDialogAriaText(pickerFieldProps.value),
|
|
90
90
|
edge: inputAdornmentProps.position
|
|
91
91
|
},
|
|
@@ -121,7 +121,7 @@ export const useDesktopPicker = _ref => {
|
|
|
121
121
|
sx,
|
|
122
122
|
label,
|
|
123
123
|
name,
|
|
124
|
-
focused: open ? true : undefined
|
|
124
|
+
focused: providerProps.contextValue.open ? true : undefined
|
|
125
125
|
}, isToolbarHidden && {
|
|
126
126
|
id: labelId
|
|
127
127
|
}, !!inputRef && {
|
|
@@ -170,22 +170,20 @@ export const useDesktopPicker = _ref => {
|
|
|
170
170
|
slots: slotsForField,
|
|
171
171
|
slotProps: slotProps,
|
|
172
172
|
unstableFieldRef: handleFieldRef
|
|
173
|
-
})), /*#__PURE__*/_jsx(PickersPopper,
|
|
173
|
+
})), /*#__PURE__*/_jsx(PickersPopper, {
|
|
174
174
|
role: "dialog",
|
|
175
175
|
placement: "bottom-start",
|
|
176
|
-
anchorEl: containerRef.current
|
|
177
|
-
}, actions, {
|
|
178
|
-
open: open,
|
|
176
|
+
anchorEl: containerRef.current,
|
|
179
177
|
slots: slots,
|
|
180
178
|
slotProps: slotProps,
|
|
181
179
|
shouldRestoreFocus: shouldRestoreFocus,
|
|
182
180
|
reduceAnimations: reduceAnimations,
|
|
183
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({},
|
|
181
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
184
182
|
slots: slots,
|
|
185
183
|
slotProps: slotProps,
|
|
186
184
|
children: renderCurrentView()
|
|
187
185
|
}))
|
|
188
|
-
})
|
|
186
|
+
})]
|
|
189
187
|
}));
|
|
190
188
|
return {
|
|
191
189
|
renderPicker
|
|
@@ -14,7 +14,7 @@ import { DateOrTimeViewWithMeridiem, PickerValue } from '../../models';
|
|
|
14
14
|
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '../../../hooks/useClearableField';
|
|
15
15
|
import { PickersTextFieldProps } from '../../../PickersTextField';
|
|
16
16
|
import { UsePickerProviderNonStaticProps } from '../usePicker/usePickerProvider';
|
|
17
|
-
export interface UseDesktopPickerSlots
|
|
17
|
+
export interface UseDesktopPickerSlots extends Pick<PickersPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>, UseClearableFieldSlots {
|
|
18
18
|
/**
|
|
19
19
|
* Component used to enter the date with the keyboard.
|
|
20
20
|
*/
|
|
@@ -39,9 +39,9 @@ export interface UseDesktopPickerSlots<TView extends DateOrTimeViewWithMeridiem>
|
|
|
39
39
|
*/
|
|
40
40
|
openPickerIcon: React.ElementType;
|
|
41
41
|
}
|
|
42
|
-
export interface UseDesktopPickerSlotProps<
|
|
42
|
+
export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {
|
|
43
43
|
}
|
|
44
|
-
export interface ExportedUseDesktopPickerSlotProps<
|
|
44
|
+
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickersPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, UseClearableFieldSlotProps {
|
|
45
45
|
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
|
46
46
|
textField?: SlotComponentPropsFromProps<PickersTextFieldProps | TextFieldProps, {}, FieldOwnerState>;
|
|
47
47
|
inputAdornment?: SlotComponentPropsFromProps<InputAdornmentProps, {}, PickerOwnerState>;
|
|
@@ -55,19 +55,19 @@ export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNo
|
|
|
55
55
|
*/
|
|
56
56
|
autoFocus?: boolean;
|
|
57
57
|
}
|
|
58
|
-
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any
|
|
58
|
+
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
|
|
59
59
|
/**
|
|
60
60
|
* Overridable component slots.
|
|
61
61
|
* @default {}
|
|
62
62
|
*/
|
|
63
|
-
slots: UseDesktopPickerSlots
|
|
63
|
+
slots: UseDesktopPickerSlots;
|
|
64
64
|
/**
|
|
65
65
|
* The props used for each component slot.
|
|
66
66
|
* @default {}
|
|
67
67
|
*/
|
|
68
|
-
slotProps?: UseDesktopPickerSlotProps<
|
|
68
|
+
slotProps?: UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
69
69
|
}
|
|
70
|
-
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps
|
|
70
|
+
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
|
|
71
71
|
props: TExternalProps;
|
|
72
72
|
getOpenDialogAriaText: (date: PickerValidDate | null) => string;
|
|
73
73
|
}
|
|
@@ -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) {
|