@mui/x-date-pickers 8.3.1 → 8.5.0
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 +213 -0
- package/DateCalendar/DateCalendar.js +9 -6
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/dateCalendarClasses.js +5 -3
- package/DateCalendar/dayCalendarClasses.js +5 -3
- package/DateCalendar/pickersFadeTransitionGroupClasses.js +5 -3
- package/DateCalendar/pickersSlideTransitionClasses.js +5 -3
- package/DateField/DateField.js +3 -2
- package/DatePicker/DatePicker.js +5 -4
- package/DatePicker/DatePickerToolbar.js +1 -0
- package/DatePicker/datePickerToolbarClasses.js +5 -3
- package/DateTimeField/DateTimeField.js +3 -2
- package/DateTimePicker/DateTimePicker.js +5 -4
- package/DateTimePicker/DateTimePickerTabs.js +1 -0
- package/DateTimePicker/DateTimePickerToolbar.js +1 -0
- package/DateTimePicker/dateTimePickerTabsClasses.js +5 -3
- package/DateTimePicker/dateTimePickerToolbarClasses.js +5 -3
- package/DayCalendarSkeleton/dayCalendarSkeletonClasses.js +5 -3
- package/DesktopDatePicker/DesktopDatePicker.js +3 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +4 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -0
- package/DesktopTimePicker/DesktopTimePicker.js +3 -2
- package/DigitalClock/DigitalClock.js +1 -0
- package/DigitalClock/DigitalClock.types.d.ts +1 -1
- package/LocalizationProvider/LocalizationProvider.js +2 -3
- package/MobileDatePicker/MobileDatePicker.js +3 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +5 -4
- package/MobileTimePicker/MobileTimePicker.js +3 -2
- package/MonthCalendar/MonthCalendar.js +12 -9
- package/MonthCalendar/MonthCalendarButton.js +2 -1
- package/MonthCalendar/monthCalendarClasses.js +5 -3
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +5 -4
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +2 -1
- package/PickersActionBar/PickersActionBar.js +2 -1
- package/PickersCalendarHeader/PickersCalendarHeader.js +1 -0
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +1 -1
- package/PickersCalendarHeader/pickersCalendarHeaderClasses.js +5 -3
- package/PickersDay/PickersDay.js +9 -5
- package/PickersDay/pickersDayClasses.js +5 -3
- package/PickersLayout/PickersLayout.js +1 -0
- package/PickersLayout/PickersLayout.types.d.ts +1 -1
- package/PickersSectionList/PickersSectionList.js +1 -0
- package/PickersSectionList/PickersSectionList.types.d.ts +1 -1
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +3 -2
- package/PickersTextField/PickersInput/PickersInput.js +3 -2
- package/PickersTextField/PickersInputBase/PickersInputBase.js +3 -2
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +3 -2
- package/PickersTextField/PickersTextField.js +6 -3
- package/PickersTextField/usePickerTextFieldOwnerState.js +1 -0
- package/StaticDatePicker/StaticDatePicker.js +1 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +1 -0
- package/StaticTimePicker/StaticTimePicker.js +1 -0
- package/TimeClock/Clock.js +4 -3
- package/TimeClock/TimeClock.js +5 -3
- package/TimeClock/clockClasses.js +5 -3
- package/TimeClock/clockNumberClasses.js +5 -3
- package/TimeClock/clockPointerClasses.js +5 -3
- package/TimeClock/timeClockClasses.js +5 -3
- package/TimeField/TimeField.js +3 -2
- package/TimePicker/TimePicker.js +5 -4
- package/TimePicker/timePickerToolbarClasses.js +5 -3
- package/YearCalendar/YearCalendar.js +14 -10
- package/YearCalendar/YearCalendarButton.js +2 -1
- package/YearCalendar/yearCalendarClasses.js +5 -3
- package/dateViewRenderers/dateViewRenderers.js +2 -1
- package/esm/DateCalendar/DateCalendar.js +4 -1
- package/esm/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/esm/DateCalendar/dateCalendarClasses.js +2 -1
- package/esm/DateCalendar/dayCalendarClasses.js +2 -1
- package/esm/DateCalendar/pickersFadeTransitionGroupClasses.js +2 -1
- package/esm/DateCalendar/pickersSlideTransitionClasses.js +2 -1
- package/esm/DateField/DateField.js +2 -1
- package/esm/DatePicker/DatePicker.js +2 -1
- package/esm/DatePicker/DatePickerToolbar.js +1 -0
- package/esm/DatePicker/datePickerToolbarClasses.js +2 -1
- package/esm/DateTimeField/DateTimeField.js +2 -1
- package/esm/DateTimePicker/DateTimePicker.js +2 -1
- package/esm/DateTimePicker/DateTimePickerTabs.js +1 -0
- package/esm/DateTimePicker/DateTimePickerToolbar.js +1 -0
- package/esm/DateTimePicker/dateTimePickerTabsClasses.js +2 -1
- package/esm/DateTimePicker/dateTimePickerToolbarClasses.js +2 -1
- package/esm/DayCalendarSkeleton/dayCalendarSkeletonClasses.js +2 -1
- package/esm/DesktopDatePicker/DesktopDatePicker.js +2 -1
- package/esm/DesktopDateTimePicker/DesktopDateTimePicker.js +3 -1
- package/esm/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -0
- package/esm/DesktopTimePicker/DesktopTimePicker.js +2 -1
- package/esm/DigitalClock/DigitalClock.js +1 -0
- package/esm/DigitalClock/DigitalClock.types.d.ts +1 -1
- package/esm/LocalizationProvider/LocalizationProvider.js +2 -3
- package/esm/MobileDatePicker/MobileDatePicker.js +2 -1
- package/esm/MobileDateTimePicker/MobileDateTimePicker.js +2 -1
- package/esm/MobileTimePicker/MobileTimePicker.js +2 -1
- package/esm/MonthCalendar/MonthCalendar.js +4 -1
- package/esm/MonthCalendar/MonthCalendarButton.js +2 -1
- package/esm/MonthCalendar/monthCalendarClasses.js +2 -1
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +1 -1
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +2 -1
- package/esm/PickersActionBar/PickersActionBar.js +1 -0
- package/esm/PickersCalendarHeader/PickersCalendarHeader.js +1 -0
- package/esm/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +1 -1
- package/esm/PickersCalendarHeader/pickersCalendarHeaderClasses.js +2 -1
- package/esm/PickersDay/PickersDay.js +6 -2
- package/esm/PickersDay/pickersDayClasses.js +2 -1
- package/esm/PickersLayout/PickersLayout.js +1 -0
- package/esm/PickersLayout/PickersLayout.types.d.ts +1 -1
- package/esm/PickersSectionList/PickersSectionList.js +1 -0
- package/esm/PickersSectionList/PickersSectionList.types.d.ts +1 -1
- package/esm/PickersTextField/PickersFilledInput/PickersFilledInput.js +2 -1
- package/esm/PickersTextField/PickersInput/PickersInput.js +2 -1
- package/esm/PickersTextField/PickersInputBase/PickersInputBase.js +2 -1
- package/esm/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +2 -1
- package/esm/PickersTextField/PickersTextField.js +5 -2
- package/esm/PickersTextField/usePickerTextFieldOwnerState.js +1 -0
- package/esm/StaticDatePicker/StaticDatePicker.js +1 -0
- package/esm/StaticDateTimePicker/StaticDateTimePicker.js +1 -0
- package/esm/StaticTimePicker/StaticTimePicker.js +1 -0
- package/esm/TimeClock/Clock.js +2 -1
- package/esm/TimeClock/TimeClock.js +3 -1
- package/esm/TimeClock/clockClasses.js +2 -1
- package/esm/TimeClock/clockNumberClasses.js +2 -1
- package/esm/TimeClock/clockPointerClasses.js +2 -1
- package/esm/TimeClock/timeClockClasses.js +2 -1
- package/esm/TimeField/TimeField.js +2 -1
- package/esm/TimePicker/TimePicker.js +2 -1
- package/esm/TimePicker/timePickerToolbarClasses.js +2 -1
- package/esm/YearCalendar/YearCalendar.js +5 -1
- package/esm/YearCalendar/YearCalendarButton.js +2 -1
- package/esm/YearCalendar/yearCalendarClasses.js +2 -1
- package/esm/dateViewRenderers/dateViewRenderers.js +2 -1
- package/esm/hooks/useIsValidValue.js +1 -0
- package/esm/hooks/usePickerContext.js +1 -0
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.js +1 -0
- package/esm/internals/components/PickerPopper/PickerPopper.js +5 -1
- package/esm/internals/components/PickerProvider.js +2 -0
- package/esm/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +2 -1
- package/esm/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -1
- package/esm/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js +2 -1
- package/esm/internals/components/PickersToolbar.js +2 -1
- package/esm/internals/components/PickersToolbarButton.js +2 -1
- package/esm/internals/components/PickersToolbarText.js +2 -1
- package/esm/internals/components/pickersToolbarButtonClasses.js +2 -1
- package/esm/internals/components/pickersToolbarClasses.js +2 -1
- package/esm/internals/components/pickersToolbarTextClasses.js +2 -1
- package/esm/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -0
- package/esm/internals/hooks/useField/useFieldCharacterEditing.js +27 -11
- package/esm/internals/hooks/useField/useFieldSectionContainerProps.js +2 -3
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +2 -2
- package/esm/internals/hooks/useField/useFieldState.js +2 -2
- package/esm/internals/hooks/useMobilePicker/useMobilePicker.js +1 -0
- package/esm/internals/hooks/useNullableFieldPrivateContext.js +1 -0
- package/esm/internals/hooks/useStaticPicker/useStaticPicker.js +1 -0
- package/esm/timeViewRenderers/timeViewRenderers.js +4 -1
- package/hooks/useIsValidValue.js +1 -0
- package/hooks/usePickerContext.js +1 -0
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.js +1 -0
- package/internals/components/PickerPopper/PickerPopper.js +17 -13
- package/internals/components/PickerProvider.js +2 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +2 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -1
- package/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js +5 -3
- package/internals/components/PickersToolbar.js +2 -1
- package/internals/components/PickersToolbarButton.js +2 -1
- package/internals/components/PickersToolbarText.js +2 -1
- package/internals/components/pickersToolbarButtonClasses.js +5 -3
- package/internals/components/pickersToolbarClasses.js +5 -3
- package/internals/components/pickersToolbarTextClasses.js +5 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -0
- package/internals/hooks/useField/useFieldCharacterEditing.js +27 -11
- package/internals/hooks/useField/useFieldSectionContainerProps.js +2 -4
- package/internals/hooks/useField/useFieldSectionContentProps.js +2 -2
- package/internals/hooks/useField/useFieldState.js +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -0
- package/internals/hooks/useNullableFieldPrivateContext.js +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -0
- package/package.json +2 -2
- package/timeViewRenderers/timeViewRenderers.js +4 -1
|
@@ -6,6 +6,7 @@ export const IsValidValueContext = /*#__PURE__*/React.createContext(() => true);
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns a function to check if a value is valid according to the validation props passed to the parent Picker.
|
|
8
8
|
*/
|
|
9
|
+
if (process.env.NODE_ENV !== "production") IsValidValueContext.displayName = "IsValidValueContext";
|
|
9
10
|
export function useIsValidValue() {
|
|
10
11
|
return React.useContext(IsValidValueContext);
|
|
11
12
|
}
|
|
@@ -6,6 +6,7 @@ export const PickerContext = /*#__PURE__*/React.createContext(null);
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns the context passed by the Picker wrapping the current component.
|
|
8
8
|
*/
|
|
9
|
+
if (process.env.NODE_ENV !== "production") PickerContext.displayName = "PickerContext";
|
|
9
10
|
export const usePickerContext = () => {
|
|
10
11
|
const value = React.useContext(PickerContext);
|
|
11
12
|
if (value == null) {
|
package/esm/index.js
CHANGED
|
@@ -95,6 +95,7 @@ export const PickerFieldUIContext = /*#__PURE__*/React.createContext({
|
|
|
95
95
|
* Adds the button to open the Picker and the button to clear the value of the field.
|
|
96
96
|
* @ignore - internal component.
|
|
97
97
|
*/
|
|
98
|
+
if (process.env.NODE_ENV !== "production") PickerFieldUIContext.displayName = "PickerFieldUIContext";
|
|
98
99
|
export function PickerFieldUI(props) {
|
|
99
100
|
const {
|
|
100
101
|
slots,
|
|
@@ -8,7 +8,10 @@ import Fade from '@mui/material/Fade';
|
|
|
8
8
|
import MuiPaper from '@mui/material/Paper';
|
|
9
9
|
import MuiPopper from '@mui/material/Popper';
|
|
10
10
|
import BaseFocusTrap from '@mui/material/Unstable_TrapFocus';
|
|
11
|
-
import
|
|
11
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
12
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
13
|
+
import ownerDocument from '@mui/utils/ownerDocument';
|
|
14
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
12
15
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
13
16
|
import { getPickerPopperUtilityClass } from "./pickerPopperClasses.js";
|
|
14
17
|
import { executeInTheNextEventLoopTick, getActiveElement } from "../../utils/utils.js";
|
|
@@ -197,6 +200,7 @@ const PickerPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
197
200
|
children: children
|
|
198
201
|
}));
|
|
199
202
|
});
|
|
203
|
+
if (process.env.NODE_ENV !== "production") PickerPopperPaperWrapper.displayName = "PickerPopperPaperWrapper";
|
|
200
204
|
export function PickerPopper(inProps) {
|
|
201
205
|
const props = useThemeProps({
|
|
202
206
|
props: inProps,
|
|
@@ -5,6 +5,7 @@ import { PickerFieldPrivateContext } from "../hooks/useNullableFieldPrivateConte
|
|
|
5
5
|
import { PickerContext } from "../../hooks/usePickerContext.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
8
|
+
if (process.env.NODE_ENV !== "production") PickerActionsContext.displayName = "PickerActionsContext";
|
|
8
9
|
export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
9
10
|
ownerState: {
|
|
10
11
|
isPickerDisabled: false,
|
|
@@ -34,6 +35,7 @@ export const PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
|
34
35
|
*
|
|
35
36
|
* @ignore - do not document.
|
|
36
37
|
*/
|
|
38
|
+
if (process.env.NODE_ENV !== "production") PickerPrivateContext.displayName = "PickerPrivateContext";
|
|
37
39
|
export function PickerProvider(props) {
|
|
38
40
|
const {
|
|
39
41
|
contextValue,
|
|
@@ -170,4 +170,5 @@ export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function Picke
|
|
|
170
170
|
children: isRtl ? /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps)) : /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps))
|
|
171
171
|
}))]
|
|
172
172
|
}));
|
|
173
|
-
});
|
|
173
|
+
});
|
|
174
|
+
if (process.env.NODE_ENV !== "production") PickersArrowSwitcher.displayName = "PickersArrowSwitcher";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SlotComponentProps } from '@mui/utils';
|
|
2
|
+
import { SlotComponentProps } from '@mui/utils/types';
|
|
3
3
|
import IconButton from '@mui/material/IconButton';
|
|
4
4
|
import SvgIcon from '@mui/material/SvgIcon';
|
|
5
5
|
import { PickersArrowSwitcherClasses } from "./pickersArrowSwitcherClasses.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersArrowSwitcherUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersArrowSwitcher', slot);
|
|
4
5
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersToolbarButtonUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersToolbarButton', slot);
|
|
4
5
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersToolbarUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersToolbar', slot);
|
|
4
5
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersToolbarTextUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersToolbarText', slot);
|
|
4
5
|
}
|
|
@@ -126,7 +126,11 @@ export const useFieldCharacterEditing = ({
|
|
|
126
126
|
return applyQuery(params, getFirstSectionValueMatchingWithQuery);
|
|
127
127
|
};
|
|
128
128
|
const applyNumericEditing = params => {
|
|
129
|
-
const getNewSectionValue = (
|
|
129
|
+
const getNewSectionValue = ({
|
|
130
|
+
queryValue,
|
|
131
|
+
skipIfBelowMinimum,
|
|
132
|
+
section
|
|
133
|
+
}) => {
|
|
130
134
|
const cleanQueryValue = removeLocalizedDigits(queryValue, localizedDigits);
|
|
131
135
|
const queryValueNumber = Number(cleanQueryValue);
|
|
132
136
|
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
|
@@ -143,7 +147,7 @@ export const useFieldCharacterEditing = ({
|
|
|
143
147
|
// If the user types `0` on a month section,
|
|
144
148
|
// It is below the minimum, but we want to store the `0` in the query,
|
|
145
149
|
// So that when he pressed `1`, it will store `01` and move to the next section.
|
|
146
|
-
if (queryValueNumber < sectionBoundaries.minimum) {
|
|
150
|
+
if (skipIfBelowMinimum && queryValueNumber < sectionBoundaries.minimum) {
|
|
147
151
|
return {
|
|
148
152
|
saveQuery: true
|
|
149
153
|
};
|
|
@@ -157,20 +161,28 @@ export const useFieldCharacterEditing = ({
|
|
|
157
161
|
};
|
|
158
162
|
const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {
|
|
159
163
|
if (activeSection.contentType === 'digit' || activeSection.contentType === 'digit-with-letter') {
|
|
160
|
-
return getNewSectionValue(
|
|
164
|
+
return getNewSectionValue({
|
|
165
|
+
queryValue,
|
|
166
|
+
skipIfBelowMinimum: false,
|
|
167
|
+
section: activeSection
|
|
168
|
+
});
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
// When editing a letter-format month and the user presses a digit,
|
|
164
172
|
// We can support the numeric editing by using the digit-format month and re-formatting the result.
|
|
165
173
|
if (activeSection.type === 'month') {
|
|
166
174
|
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, 'digit', 'month', 'MM');
|
|
167
|
-
const response = getNewSectionValue(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
const response = getNewSectionValue({
|
|
176
|
+
queryValue,
|
|
177
|
+
skipIfBelowMinimum: true,
|
|
178
|
+
section: {
|
|
179
|
+
type: activeSection.type,
|
|
180
|
+
format: 'MM',
|
|
181
|
+
hasLeadingZerosInFormat,
|
|
182
|
+
hasLeadingZerosInInput: true,
|
|
183
|
+
contentType: 'digit',
|
|
184
|
+
maxLength: 2
|
|
185
|
+
}
|
|
174
186
|
});
|
|
175
187
|
if (isQueryResponseWithoutValue(response)) {
|
|
176
188
|
return response;
|
|
@@ -184,7 +196,11 @@ export const useFieldCharacterEditing = ({
|
|
|
184
196
|
// When editing a letter-format weekDay and the user presses a digit,
|
|
185
197
|
// We can support the numeric editing by returning the nth day in the week day array.
|
|
186
198
|
if (activeSection.type === 'weekDay') {
|
|
187
|
-
const response = getNewSectionValue(
|
|
199
|
+
const response = getNewSectionValue({
|
|
200
|
+
queryValue,
|
|
201
|
+
skipIfBelowMinimum: true,
|
|
202
|
+
section: activeSection
|
|
203
|
+
});
|
|
188
204
|
if (isQueryResponseWithoutValue(response)) {
|
|
189
205
|
return response;
|
|
190
206
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import useEventCallback from '@mui/utils/useEventCallback';
|
|
3
2
|
/**
|
|
4
3
|
* Generate the props to pass to the container element of each section of the field.
|
|
5
4
|
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
|
@@ -17,14 +16,14 @@ export function useFieldSectionContainerProps(parameters) {
|
|
|
17
16
|
disabled = false
|
|
18
17
|
}
|
|
19
18
|
} = parameters;
|
|
20
|
-
const createHandleClick =
|
|
19
|
+
const createHandleClick = React.useCallback(sectionIndex => event => {
|
|
21
20
|
// The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.
|
|
22
21
|
// We avoid this by checking if the call to this function is actually intended, or a side effect.
|
|
23
22
|
if (disabled || event.isDefaultPrevented()) {
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
setSelectedSections(sectionIndex);
|
|
27
|
-
});
|
|
26
|
+
}, [disabled, setSelectedSections]);
|
|
28
27
|
return React.useCallback(sectionIndex => ({
|
|
29
28
|
'data-sectionindex': sectionIndex,
|
|
30
29
|
onClick: createHandleClick(sectionIndex)
|
|
@@ -128,12 +128,12 @@ export function useFieldSectionContentProps(parameters) {
|
|
|
128
128
|
event.preventDefault();
|
|
129
129
|
event.dataTransfer.dropEffect = 'none';
|
|
130
130
|
});
|
|
131
|
-
const createFocusHandler =
|
|
131
|
+
const createFocusHandler = React.useCallback(sectionIndex => () => {
|
|
132
132
|
if (disabled) {
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
setSelectedSections(sectionIndex);
|
|
136
|
-
});
|
|
136
|
+
}, [disabled, setSelectedSections]);
|
|
137
137
|
return React.useCallback((section, sectionIndex) => {
|
|
138
138
|
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
|
139
139
|
currentDate: fieldValueManager.getDateFromSection(value, section),
|
|
@@ -268,10 +268,10 @@ export const useFieldState = parameters => {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
|
-
* If all the sections are filled but the date is invalid,
|
|
271
|
+
* If all the sections are filled but the date is invalid and the previous date is valid or null,
|
|
272
272
|
* Then we publish an invalid date.
|
|
273
273
|
*/
|
|
274
|
-
if (newActiveDateSections.every(sectionBis => sectionBis.value !== '')) {
|
|
274
|
+
if (newActiveDateSections.every(sectionBis => sectionBis.value !== '') && (activeDate == null || utils.isValid(activeDate))) {
|
|
275
275
|
setSectionUpdateToApplyOnNextInvalidDate(newSectionValue);
|
|
276
276
|
return publishValue(fieldValueManager.updateDateInValue(value, section, newActiveDate));
|
|
277
277
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export const PickerFieldPrivateContext = /*#__PURE__*/React.createContext(null);
|
|
3
|
+
if (process.env.NODE_ENV !== "production") PickerFieldPrivateContext.displayName = "PickerFieldPrivateContext";
|
|
3
4
|
export function useNullableFieldPrivateContext() {
|
|
4
5
|
return React.useContext(PickerFieldPrivateContext);
|
|
5
6
|
}
|
|
@@ -63,6 +63,7 @@ export const renderTimeViewClock = ({
|
|
|
63
63
|
disableIgnoringDatePartForTimeValidation: disableIgnoringDatePartForTimeValidation,
|
|
64
64
|
timezone: timezone
|
|
65
65
|
});
|
|
66
|
+
if (process.env.NODE_ENV !== "production") renderTimeViewClock.displayName = "renderTimeViewClock";
|
|
66
67
|
export const renderDigitalClockTimeView = ({
|
|
67
68
|
view,
|
|
68
69
|
onViewChange,
|
|
@@ -122,6 +123,7 @@ export const renderDigitalClockTimeView = ({
|
|
|
122
123
|
skipDisabled: skipDisabled,
|
|
123
124
|
timezone: timezone
|
|
124
125
|
});
|
|
126
|
+
if (process.env.NODE_ENV !== "production") renderDigitalClockTimeView.displayName = "renderDigitalClockTimeView";
|
|
125
127
|
export const renderMultiSectionDigitalClockTimeView = ({
|
|
126
128
|
view,
|
|
127
129
|
onViewChange,
|
|
@@ -180,4 +182,5 @@ export const renderMultiSectionDigitalClockTimeView = ({
|
|
|
180
182
|
timeSteps: timeSteps,
|
|
181
183
|
skipDisabled: skipDisabled,
|
|
182
184
|
timezone: timezone
|
|
183
|
-
});
|
|
185
|
+
});
|
|
186
|
+
if (process.env.NODE_ENV !== "production") renderMultiSectionDigitalClockTimeView.displayName = "renderMultiSectionDigitalClockTimeView";
|
package/hooks/useIsValidValue.js
CHANGED
|
@@ -13,6 +13,7 @@ const IsValidValueContext = exports.IsValidValueContext = /*#__PURE__*/React.cre
|
|
|
13
13
|
/**
|
|
14
14
|
* Returns a function to check if a value is valid according to the validation props passed to the parent Picker.
|
|
15
15
|
*/
|
|
16
|
+
if (process.env.NODE_ENV !== "production") IsValidValueContext.displayName = "IsValidValueContext";
|
|
16
17
|
function useIsValidValue() {
|
|
17
18
|
return React.useContext(IsValidValueContext);
|
|
18
19
|
}
|
|
@@ -12,6 +12,7 @@ const PickerContext = exports.PickerContext = /*#__PURE__*/React.createContext(n
|
|
|
12
12
|
/**
|
|
13
13
|
* Returns the context passed by the Picker wrapping the current component.
|
|
14
14
|
*/
|
|
15
|
+
if (process.env.NODE_ENV !== "production") PickerContext.displayName = "PickerContext";
|
|
15
16
|
const usePickerContext = () => {
|
|
16
17
|
const value = React.useContext(PickerContext);
|
|
17
18
|
if (value == null) {
|
package/index.js
CHANGED
|
@@ -109,6 +109,7 @@ const PickerFieldUIContext = exports.PickerFieldUIContext = /*#__PURE__*/React.c
|
|
|
109
109
|
* Adds the button to open the Picker and the button to clear the value of the field.
|
|
110
110
|
* @ignore - internal component.
|
|
111
111
|
*/
|
|
112
|
+
if (process.env.NODE_ENV !== "production") PickerFieldUIContext.displayName = "PickerFieldUIContext";
|
|
112
113
|
function PickerFieldUI(props) {
|
|
113
114
|
const {
|
|
114
115
|
slots,
|
|
@@ -15,10 +15,13 @@ var _Fade = _interopRequireDefault(require("@mui/material/Fade"));
|
|
|
15
15
|
var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
|
|
16
16
|
var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
|
|
17
17
|
var _Unstable_TrapFocus = _interopRequireDefault(require("@mui/material/Unstable_TrapFocus"));
|
|
18
|
-
var
|
|
18
|
+
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
19
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
20
|
+
var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
|
|
21
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
19
22
|
var _styles = require("@mui/material/styles");
|
|
20
23
|
var _pickerPopperClasses = require("./pickerPopperClasses");
|
|
21
|
-
var
|
|
24
|
+
var _utils = require("../../utils/utils");
|
|
22
25
|
var _usePickerPrivateContext = require("../../hooks/usePickerPrivateContext");
|
|
23
26
|
var _hooks = require("../../../hooks");
|
|
24
27
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -28,7 +31,7 @@ const useUtilityClasses = classes => {
|
|
|
28
31
|
root: ['root'],
|
|
29
32
|
paper: ['paper']
|
|
30
33
|
};
|
|
31
|
-
return (0,
|
|
34
|
+
return (0, _composeClasses.default)(slots, _pickerPopperClasses.getPickerPopperUtilityClass, classes);
|
|
32
35
|
};
|
|
33
36
|
const PickerPopperRoot = (0, _styles.styled)(_Popper.default, {
|
|
34
37
|
name: 'MuiPickerPopper',
|
|
@@ -93,7 +96,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
93
96
|
// clicking a checkbox to check it, hitting a button to submit a form,
|
|
94
97
|
// and hitting left arrow to move the cursor in a text input etc.
|
|
95
98
|
// Only special HTML elements have these default behaviors.
|
|
96
|
-
const handleClickAway = (0,
|
|
99
|
+
const handleClickAway = (0, _useEventCallback.default)(event => {
|
|
97
100
|
if (!activatedRef.current) {
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
@@ -102,7 +105,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
102
105
|
// we can only be confident with a positive value.
|
|
103
106
|
const insideReactTree = syntheticEventRef.current;
|
|
104
107
|
syntheticEventRef.current = false;
|
|
105
|
-
const doc = (0,
|
|
108
|
+
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
|
106
109
|
|
|
107
110
|
// 1. IE11 support, which trigger the handleClickAway even after the unbind
|
|
108
111
|
// 2. The child might render null.
|
|
@@ -137,7 +140,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
137
140
|
};
|
|
138
141
|
React.useEffect(() => {
|
|
139
142
|
if (active) {
|
|
140
|
-
const doc = (0,
|
|
143
|
+
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
|
141
144
|
const handleTouchMove = () => {
|
|
142
145
|
movedRef.current = true;
|
|
143
146
|
};
|
|
@@ -156,7 +159,7 @@ function useClickAwayListener(active, onClickAway) {
|
|
|
156
159
|
// Or if this is a timing related issues due to different Transition components
|
|
157
160
|
// Once we get rid of all the manual scheduling (for example setTimeout(update, 0)) we can revisit this code+test.
|
|
158
161
|
if (active) {
|
|
159
|
-
const doc = (0,
|
|
162
|
+
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
|
160
163
|
doc.addEventListener('click', handleClickAway);
|
|
161
164
|
return () => {
|
|
162
165
|
doc.removeEventListener('click', handleClickAway);
|
|
@@ -205,6 +208,7 @@ const PickerPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
205
208
|
children: children
|
|
206
209
|
}));
|
|
207
210
|
});
|
|
211
|
+
if (process.env.NODE_ENV !== "production") PickerPopperPaperWrapper.displayName = "PickerPopperPaperWrapper";
|
|
208
212
|
function PickerPopper(inProps) {
|
|
209
213
|
const props = (0, _styles.useThemeProps)({
|
|
210
214
|
props: inProps,
|
|
@@ -246,7 +250,7 @@ function PickerPopper(inProps) {
|
|
|
246
250
|
return;
|
|
247
251
|
}
|
|
248
252
|
if (open) {
|
|
249
|
-
lastFocusedElementRef.current = (0,
|
|
253
|
+
lastFocusedElementRef.current = (0, _utils.getActiveElement)(document);
|
|
250
254
|
} else if (lastFocusedElementRef.current && lastFocusedElementRef.current instanceof HTMLElement) {
|
|
251
255
|
// make sure the button is flushed with updated label, before returning focus to it
|
|
252
256
|
// avoids issue, where screen reader could fail to announce selected date after selection
|
|
@@ -265,10 +269,10 @@ function PickerPopper(inProps) {
|
|
|
265
269
|
const ownerState = (0, _extends2.default)({}, pickerOwnerState, {
|
|
266
270
|
popperPlacement: placement
|
|
267
271
|
});
|
|
268
|
-
const handleClickAway = (0,
|
|
272
|
+
const handleClickAway = (0, _useEventCallback.default)(() => {
|
|
269
273
|
if (viewContainerRole === 'tooltip') {
|
|
270
|
-
(0,
|
|
271
|
-
if (rootRefObject.current?.contains((0,
|
|
274
|
+
(0, _utils.executeInTheNextEventLoopTick)(() => {
|
|
275
|
+
if (rootRefObject.current?.contains((0, _utils.getActiveElement)(document)) || popupRef.current?.contains((0, _utils.getActiveElement)(document))) {
|
|
272
276
|
return;
|
|
273
277
|
}
|
|
274
278
|
dismissViews();
|
|
@@ -279,8 +283,8 @@ function PickerPopper(inProps) {
|
|
|
279
283
|
});
|
|
280
284
|
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, handleClickAway);
|
|
281
285
|
const paperRef = React.useRef(null);
|
|
282
|
-
const handleRef = (0,
|
|
283
|
-
const handlePaperRef = (0,
|
|
286
|
+
const handleRef = (0, _useForkRef.default)(paperRef, popupRef);
|
|
287
|
+
const handlePaperRef = (0, _useForkRef.default)(handleRef, clickAwayRef);
|
|
284
288
|
const handleKeyDown = event => {
|
|
285
289
|
if (event.key === 'Escape') {
|
|
286
290
|
// stop the propagation to avoid closing parent modal
|
|
@@ -13,6 +13,7 @@ var _useNullableFieldPrivateContext = require("../hooks/useNullableFieldPrivateC
|
|
|
13
13
|
var _usePickerContext = require("../../hooks/usePickerContext");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
const PickerActionsContext = exports.PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
16
|
+
if (process.env.NODE_ENV !== "production") PickerActionsContext.displayName = "PickerActionsContext";
|
|
16
17
|
const PickerPrivateContext = exports.PickerPrivateContext = /*#__PURE__*/React.createContext({
|
|
17
18
|
ownerState: {
|
|
18
19
|
isPickerDisabled: false,
|
|
@@ -42,6 +43,7 @@ const PickerPrivateContext = exports.PickerPrivateContext = /*#__PURE__*/React.c
|
|
|
42
43
|
*
|
|
43
44
|
* @ignore - do not document.
|
|
44
45
|
*/
|
|
46
|
+
if (process.env.NODE_ENV !== "production") PickerPrivateContext.displayName = "PickerPrivateContext";
|
|
45
47
|
function PickerProvider(props) {
|
|
46
48
|
const {
|
|
47
49
|
contextValue,
|
|
@@ -178,4 +178,5 @@ const PickersArrowSwitcher = exports.PickersArrowSwitcher = /*#__PURE__*/React.f
|
|
|
178
178
|
children: isRtl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(LeftArrowIcon, (0, _extends2.default)({}, leftArrowIconProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(RightArrowIcon, (0, _extends2.default)({}, rightArrowIconProps))
|
|
179
179
|
}))]
|
|
180
180
|
}));
|
|
181
|
-
});
|
|
181
|
+
});
|
|
182
|
+
if (process.env.NODE_ENV !== "production") PickersArrowSwitcher.displayName = "PickersArrowSwitcher";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SlotComponentProps } from '@mui/utils';
|
|
2
|
+
import { SlotComponentProps } from '@mui/utils/types';
|
|
3
3
|
import IconButton from '@mui/material/IconButton';
|
|
4
4
|
import SvgIcon from '@mui/material/SvgIcon';
|
|
5
5
|
import { PickersArrowSwitcherClasses } from "./pickersArrowSwitcherClasses.js";
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getPickersArrowSwitcherUtilityClass = getPickersArrowSwitcherUtilityClass;
|
|
7
8
|
exports.pickersArrowSwitcherClasses = void 0;
|
|
8
|
-
var
|
|
9
|
+
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
10
|
+
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
9
11
|
function getPickersArrowSwitcherUtilityClass(slot) {
|
|
10
|
-
return (0,
|
|
12
|
+
return (0, _generateUtilityClass.default)('MuiPickersArrowSwitcher', slot);
|
|
11
13
|
}
|
|
12
|
-
const pickersArrowSwitcherClasses = exports.pickersArrowSwitcherClasses = (0,
|
|
14
|
+
const pickersArrowSwitcherClasses = exports.pickersArrowSwitcherClasses = (0, _generateUtilityClasses.default)('MuiPickersArrowSwitcher', ['root', 'spacer', 'button', 'previousIconButton', 'nextIconButton', 'leftArrowIcon', 'rightArrowIcon']);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getPickersToolbarButtonUtilityClass = getPickersToolbarButtonUtilityClass;
|
|
7
8
|
exports.pickersToolbarButtonClasses = void 0;
|
|
8
|
-
var
|
|
9
|
+
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
10
|
+
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
9
11
|
function getPickersToolbarButtonUtilityClass(slot) {
|
|
10
|
-
return (0,
|
|
12
|
+
return (0, _generateUtilityClass.default)('MuiPickersToolbarButton', slot);
|
|
11
13
|
}
|
|
12
|
-
const pickersToolbarButtonClasses = exports.pickersToolbarButtonClasses = (0,
|
|
14
|
+
const pickersToolbarButtonClasses = exports.pickersToolbarButtonClasses = (0, _generateUtilityClasses.default)('MuiPickersToolbarButton', ['root']);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getPickersToolbarUtilityClass = getPickersToolbarUtilityClass;
|
|
7
8
|
exports.pickersToolbarClasses = void 0;
|
|
8
|
-
var
|
|
9
|
+
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
10
|
+
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
9
11
|
function getPickersToolbarUtilityClass(slot) {
|
|
10
|
-
return (0,
|
|
12
|
+
return (0, _generateUtilityClass.default)('MuiPickersToolbar', slot);
|
|
11
13
|
}
|
|
12
|
-
const pickersToolbarClasses = exports.pickersToolbarClasses = (0,
|
|
14
|
+
const pickersToolbarClasses = exports.pickersToolbarClasses = (0, _generateUtilityClasses.default)('MuiPickersToolbar', ['root', 'title', 'content']);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getPickersToolbarTextUtilityClass = getPickersToolbarTextUtilityClass;
|
|
7
8
|
exports.pickersToolbarTextClasses = void 0;
|
|
8
|
-
var
|
|
9
|
+
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
10
|
+
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
9
11
|
function getPickersToolbarTextUtilityClass(slot) {
|
|
10
|
-
return (0,
|
|
12
|
+
return (0, _generateUtilityClass.default)('MuiPickersToolbarText', slot);
|
|
11
13
|
}
|
|
12
|
-
const pickersToolbarTextClasses = exports.pickersToolbarTextClasses = (0,
|
|
14
|
+
const pickersToolbarTextClasses = exports.pickersToolbarTextClasses = (0, _generateUtilityClasses.default)('MuiPickersToolbarText', ['root']);
|