@mui/x-date-pickers 5.0.2 → 6.0.0-alpha.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 +212 -3
- package/CalendarPicker/CalendarPicker.d.ts +8 -2
- package/CalendarPicker/CalendarPicker.js +54 -71
- package/CalendarPicker/DayPicker.d.ts +2 -2
- package/CalendarPicker/DayPicker.js +6 -2
- package/CalendarPicker/PickersCalendarHeader.d.ts +3 -10
- package/CalendarPicker/PickersCalendarHeader.js +7 -20
- package/CalendarPicker/useCalendarState.d.ts +2 -2
- package/CalendarPicker/useCalendarState.js +7 -7
- package/ClockPicker/Clock.d.ts +9 -4
- package/ClockPicker/Clock.js +13 -13
- package/ClockPicker/ClockNumbers.d.ts +3 -3
- package/ClockPicker/ClockNumbers.js +2 -2
- package/ClockPicker/ClockPicker.d.ts +8 -58
- package/ClockPicker/ClockPicker.js +52 -128
- package/ClockPicker/ClockPointer.d.ts +1 -1
- package/ClockPicker/ClockPointer.js +4 -4
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +5 -1
- package/DatePicker/DatePicker.js +10 -20
- package/DateTimePicker/DateTimePicker.js +10 -39
- package/DesktopDatePicker/DesktopDatePicker.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +14 -22
- package/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +1 -1
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/DesktopTimePicker/DesktopTimePicker.d.ts +1 -1
- package/DesktopTimePicker/DesktopTimePicker.js +9 -21
- package/LocalizationProvider/LocalizationProvider.d.ts +10 -11
- package/LocalizationProvider/LocalizationProvider.js +31 -24
- package/MobileDatePicker/MobileDatePicker.d.ts +1 -1
- package/MobileDatePicker/MobileDatePicker.js +14 -22
- package/MobileDateTimePicker/MobileDateTimePicker.d.ts +1 -1
- package/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/MobileTimePicker/MobileTimePicker.d.ts +1 -1
- package/MobileTimePicker/MobileTimePicker.js +9 -21
- package/MonthPicker/MonthPicker.d.ts +12 -9
- package/MonthPicker/MonthPicker.js +60 -57
- package/MonthPicker/PickersMonth.d.ts +10 -7
- package/MonthPicker/PickersMonth.js +76 -44
- package/MonthPicker/pickersMonthClasses.d.ts +9 -1
- package/MonthPicker/pickersMonthClasses.js +1 -1
- package/PickersDay/PickersDay.d.ts +0 -6
- package/PickersDay/PickersDay.js +0 -5
- package/StaticDatePicker/StaticDatePicker.d.ts +1 -1
- package/StaticDatePicker/StaticDatePicker.js +17 -23
- package/StaticDateTimePicker/StaticDateTimePicker.d.ts +1 -1
- package/StaticDateTimePicker/StaticDateTimePicker.js +17 -42
- package/StaticTimePicker/StaticTimePicker.d.ts +1 -1
- package/StaticTimePicker/StaticTimePicker.js +17 -22
- package/TimePicker/TimePicker.js +5 -19
- package/YearPicker/PickersYear.d.ts +7 -6
- package/YearPicker/PickersYear.js +34 -23
- package/YearPicker/YearPicker.d.ts +21 -4
- package/YearPicker/YearPicker.js +109 -49
- package/YearPicker/pickersYearClasses.d.ts +1 -1
- package/index.js +1 -1
- package/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/internals/components/PickerStaticWrapper/PickerStaticWrapper.d.ts +20 -6
- package/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +38 -22
- package/internals/components/PickerStaticWrapper/index.d.ts +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.d.ts +3 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +166 -0
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +63 -0
- package/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/internals/components/PickersArrowSwitcher/index.d.ts +2 -0
- package/internals/components/PickersArrowSwitcher/index.js +1 -0
- package/internals/components/{pickersArrowSwitcherClasses.d.ts → PickersArrowSwitcher/pickersArrowSwitcherClasses.d.ts} +0 -0
- package/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/internals/components/PickersPopper.d.ts +2 -6
- package/internals/components/PickersPopper.js +5 -5
- package/internals/components/PickersToolbar.d.ts +1 -1
- package/internals/components/PickersToolbar.js +1 -2
- package/internals/components/PickersToolbarText.d.ts +1 -1
- package/internals/components/wrappers/DesktopTooltipWrapper.d.ts +1 -1
- package/internals/components/wrappers/DesktopTooltipWrapper.js +29 -24
- package/internals/components/wrappers/DesktopWrapper.d.ts +8 -3
- package/internals/components/wrappers/DesktopWrapper.js +26 -21
- package/internals/components/wrappers/MobileWrapper.d.ts +8 -3
- package/internals/components/wrappers/MobileWrapper.js +23 -18
- package/internals/hooks/useField/useField.interfaces.d.ts +0 -1
- package/internals/hooks/useField/useField.js +19 -23
- package/internals/hooks/useField/useField.utils.js +10 -2
- package/internals/hooks/useUtils.d.ts +5 -2
- package/internals/hooks/useUtils.js +11 -2
- package/internals/hooks/validation/useDateValidation.d.ts +4 -4
- package/internals/hooks/validation/useDateValidation.js +12 -2
- package/internals/index.d.ts +5 -5
- package/internals/index.js +3 -3
- package/internals/models/muiPickersAdapter.d.ts +12 -7
- package/internals/models/props/baseToolbarProps.d.ts +0 -8
- package/internals/models/props/staticPickerProps.d.ts +2 -8
- package/legacy/CalendarPicker/CalendarPicker.js +52 -69
- package/legacy/CalendarPicker/DayPicker.js +6 -2
- package/legacy/CalendarPicker/PickersCalendarHeader.js +7 -20
- package/legacy/CalendarPicker/useCalendarState.js +7 -7
- package/legacy/ClockPicker/Clock.js +13 -13
- package/legacy/ClockPicker/ClockNumbers.js +2 -2
- package/legacy/ClockPicker/ClockPicker.js +57 -133
- package/legacy/ClockPicker/ClockPointer.js +4 -4
- package/legacy/DateField/useDateField.js +5 -1
- package/legacy/DatePicker/DatePicker.js +10 -20
- package/legacy/DateTimePicker/DateTimePicker.js +10 -39
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +13 -21
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +8 -20
- package/legacy/LocalizationProvider/LocalizationProvider.js +28 -23
- package/legacy/MobileDatePicker/MobileDatePicker.js +13 -21
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/legacy/MobileTimePicker/MobileTimePicker.js +8 -20
- package/legacy/MonthPicker/MonthPicker.js +67 -62
- package/legacy/MonthPicker/PickersMonth.js +89 -57
- package/legacy/MonthPicker/pickersMonthClasses.js +1 -1
- package/legacy/PickersDay/PickersDay.js +0 -5
- package/legacy/StaticDatePicker/StaticDatePicker.js +17 -24
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +17 -43
- package/legacy/StaticTimePicker/StaticTimePicker.js +17 -23
- package/legacy/TimePicker/TimePicker.js +5 -19
- package/legacy/YearPicker/PickersYear.js +35 -25
- package/legacy/YearPicker/YearPicker.js +111 -51
- package/legacy/index.js +1 -1
- package/legacy/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/legacy/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +41 -24
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +180 -0
- package/legacy/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/legacy/internals/components/PickersArrowSwitcher/index.js +1 -0
- package/legacy/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/legacy/internals/components/PickersPopper.js +5 -5
- package/legacy/internals/components/PickersToolbar.js +1 -2
- package/legacy/internals/components/wrappers/DesktopTooltipWrapper.js +29 -24
- package/legacy/internals/components/wrappers/DesktopWrapper.js +26 -21
- package/legacy/internals/components/wrappers/MobileWrapper.js +22 -17
- package/legacy/internals/hooks/useField/useField.js +21 -23
- package/legacy/internals/hooks/useField/useField.utils.js +10 -2
- package/legacy/internals/hooks/useUtils.js +13 -2
- package/legacy/internals/hooks/validation/useDateValidation.js +12 -2
- package/legacy/internals/index.js +3 -3
- package/legacy/locales/faIR.js +52 -0
- package/legacy/locales/fiFI.js +61 -0
- package/legacy/locales/index.js +2 -0
- package/legacy/locales/isIS.js +0 -1
- package/locales/faIR.d.ts +35 -0
- package/locales/faIR.js +36 -0
- package/locales/fiFI.d.ts +35 -0
- package/locales/fiFI.js +45 -0
- package/locales/index.d.ts +2 -0
- package/locales/index.js +2 -0
- package/locales/isIS.js +0 -1
- package/locales/utils/pickersLocaleTextApi.d.ts +1 -0
- package/modern/CalendarPicker/CalendarPicker.js +54 -71
- package/modern/CalendarPicker/DayPicker.js +6 -2
- package/modern/CalendarPicker/PickersCalendarHeader.js +7 -20
- package/modern/CalendarPicker/useCalendarState.js +7 -7
- package/modern/ClockPicker/Clock.js +13 -13
- package/modern/ClockPicker/ClockNumbers.js +2 -2
- package/modern/ClockPicker/ClockPicker.js +52 -128
- package/modern/ClockPicker/ClockPointer.js +4 -4
- package/modern/DateField/useDateField.js +5 -1
- package/modern/DatePicker/DatePicker.js +10 -20
- package/modern/DateTimePicker/DateTimePicker.js +10 -39
- package/modern/DesktopDatePicker/DesktopDatePicker.js +14 -22
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/modern/DesktopTimePicker/DesktopTimePicker.js +9 -21
- package/modern/LocalizationProvider/LocalizationProvider.js +29 -24
- package/modern/MobileDatePicker/MobileDatePicker.js +14 -22
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/modern/MobileTimePicker/MobileTimePicker.js +9 -21
- package/modern/MonthPicker/MonthPicker.js +60 -57
- package/modern/MonthPicker/PickersMonth.js +76 -44
- package/modern/MonthPicker/pickersMonthClasses.js +1 -1
- package/modern/PickersDay/PickersDay.js +0 -5
- package/modern/StaticDatePicker/StaticDatePicker.js +17 -23
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +17 -42
- package/modern/StaticTimePicker/StaticTimePicker.js +17 -22
- package/modern/TimePicker/TimePicker.js +5 -19
- package/modern/YearPicker/PickersYear.js +34 -23
- package/modern/YearPicker/YearPicker.js +109 -49
- package/modern/index.js +1 -1
- package/modern/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/modern/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +38 -22
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +164 -0
- package/modern/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/modern/internals/components/PickersArrowSwitcher/index.js +1 -0
- package/modern/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/modern/internals/components/PickersPopper.js +5 -5
- package/modern/internals/components/PickersToolbar.js +1 -2
- package/modern/internals/components/wrappers/DesktopTooltipWrapper.js +29 -24
- package/modern/internals/components/wrappers/DesktopWrapper.js +26 -21
- package/modern/internals/components/wrappers/MobileWrapper.js +23 -18
- package/modern/internals/hooks/useField/useField.js +19 -21
- package/modern/internals/hooks/useField/useField.utils.js +10 -2
- package/modern/internals/hooks/useUtils.js +11 -2
- package/modern/internals/hooks/validation/useDateValidation.js +12 -2
- package/modern/internals/index.js +3 -3
- package/modern/locales/faIR.js +36 -0
- package/modern/locales/fiFI.js +45 -0
- package/modern/locales/index.js +2 -0
- package/modern/locales/isIS.js +0 -1
- package/node/CalendarPicker/CalendarPicker.js +54 -71
- package/node/CalendarPicker/DayPicker.js +5 -1
- package/node/CalendarPicker/PickersCalendarHeader.js +7 -21
- package/node/CalendarPicker/useCalendarState.js +6 -6
- package/node/ClockPicker/Clock.js +12 -12
- package/node/ClockPicker/ClockNumbers.js +2 -2
- package/node/ClockPicker/ClockPicker.js +52 -129
- package/node/ClockPicker/ClockPointer.js +4 -4
- package/node/DateField/useDateField.js +5 -1
- package/node/DatePicker/DatePicker.js +10 -20
- package/node/DateTimePicker/DateTimePicker.js +10 -39
- package/node/DesktopDatePicker/DesktopDatePicker.js +14 -22
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -40
- package/node/DesktopTimePicker/DesktopTimePicker.js +9 -21
- package/node/LocalizationProvider/LocalizationProvider.js +31 -25
- package/node/MobileDatePicker/MobileDatePicker.js +14 -22
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +13 -40
- package/node/MobileTimePicker/MobileTimePicker.js +9 -21
- package/node/MonthPicker/MonthPicker.js +61 -58
- package/node/MonthPicker/PickersMonth.js +71 -43
- package/node/MonthPicker/pickersMonthClasses.js +1 -1
- package/node/PickersDay/PickersDay.js +0 -5
- package/node/StaticDatePicker/StaticDatePicker.js +17 -23
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +17 -42
- package/node/StaticTimePicker/StaticTimePicker.js +17 -22
- package/node/TimePicker/TimePicker.js +5 -19
- package/node/YearPicker/PickersYear.js +33 -22
- package/node/YearPicker/YearPicker.js +111 -49
- package/node/index.js +1 -1
- package/node/internals/components/CalendarOrClockPicker/CalendarOrClockPicker.js +2 -2
- package/node/internals/components/PickerStaticWrapper/PickerStaticWrapper.js +39 -22
- package/node/internals/components/{PickersArrowSwitcher.js → PickersArrowSwitcher/PickersArrowSwitcher.js} +102 -58
- package/node/internals/{models/muiPickersAdapter.js → components/PickersArrowSwitcher/PickersArrowSwitcher.types.js} +0 -0
- package/node/internals/components/PickersArrowSwitcher/index.js +13 -0
- package/node/internals/components/{pickersArrowSwitcherClasses.js → PickersArrowSwitcher/pickersArrowSwitcherClasses.js} +0 -0
- package/node/internals/components/PickersPopper.js +5 -5
- package/node/internals/components/PickersToolbar.js +1 -2
- package/node/internals/components/wrappers/DesktopTooltipWrapper.js +30 -24
- package/node/internals/components/wrappers/DesktopWrapper.js +27 -21
- package/node/internals/components/wrappers/MobileWrapper.js +24 -18
- package/node/internals/hooks/useField/useField.js +19 -23
- package/node/internals/hooks/useField/useField.utils.js +10 -2
- package/node/internals/hooks/useUtils.js +15 -2
- package/node/internals/hooks/validation/useDateValidation.js +14 -4
- package/node/internals/index.js +8 -2
- package/node/locales/faIR.js +45 -0
- package/node/locales/fiFI.js +54 -0
- package/node/locales/index.js +26 -0
- package/node/locales/isIS.js +0 -1
- package/package.json +4 -4
- package/themeAugmentation/props.d.ts +3 -3
- package/internals/components/PickersArrowSwitcher.d.ts +0 -62
- package/internals/components/PickersArrowSwitcher.js +0 -124
- package/legacy/internals/components/PickersArrowSwitcher.js +0 -128
- package/modern/internals/components/PickersArrowSwitcher.js +0 -124
package/YearPicker/YearPicker.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["autoFocus", "className", "value", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { useTheme, styled, useThemeProps } from '@mui/material/styles';
|
|
5
|
-
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
6
|
-
import { useControlled } from '@mui/material/utils';
|
|
7
6
|
import clsx from 'clsx';
|
|
7
|
+
import { useTheme } from '@mui/system';
|
|
8
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
9
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
10
|
+
import { useForkRef } from '@mui/material/utils';
|
|
11
|
+
import { unstable_useControlled as useControlled, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
8
12
|
import { PickersYear } from './PickersYear';
|
|
9
13
|
import { useUtils, useNow, useDefaultDates } from '../internals/hooks/useUtils';
|
|
10
14
|
import { WrapperVariantContext } from '../internals/components/wrappers/WrapperVariantContext';
|
|
@@ -48,17 +52,20 @@ const YearPickerRoot = styled('div', {
|
|
|
48
52
|
flexWrap: 'wrap',
|
|
49
53
|
overflowY: 'auto',
|
|
50
54
|
height: '100%',
|
|
51
|
-
|
|
55
|
+
padding: '0 4px',
|
|
56
|
+
maxHeight: '304px'
|
|
52
57
|
});
|
|
53
58
|
export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inProps, ref) {
|
|
54
59
|
const now = useNow();
|
|
55
60
|
const theme = useTheme();
|
|
56
61
|
const utils = useUtils();
|
|
62
|
+
const wrapperVariant = React.useContext(WrapperVariantContext);
|
|
57
63
|
const props = useYearPickerDefaultizedProps(inProps, 'MuiYearPicker');
|
|
64
|
+
|
|
58
65
|
const {
|
|
59
66
|
autoFocus,
|
|
60
67
|
className,
|
|
61
|
-
|
|
68
|
+
value,
|
|
62
69
|
disabled,
|
|
63
70
|
disableFuture,
|
|
64
71
|
disablePast,
|
|
@@ -71,13 +78,16 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
71
78
|
onYearFocus,
|
|
72
79
|
hasFocus,
|
|
73
80
|
onFocusedViewChange
|
|
74
|
-
} = props
|
|
81
|
+
} = props,
|
|
82
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
83
|
+
|
|
75
84
|
const ownerState = props;
|
|
76
85
|
const classes = useUtilityClasses(ownerState);
|
|
77
|
-
const selectedDateOrToday =
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
const selectedDateOrToday = value != null ? value : now;
|
|
87
|
+
const todayYear = React.useMemo(() => utils.getYear(now), [utils, now]);
|
|
88
|
+
const selectedYear = React.useMemo(() => {
|
|
89
|
+
if (value != null) {
|
|
90
|
+
return utils.getYear(value);
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
if (disableHighlightToday) {
|
|
@@ -85,24 +95,22 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
return utils.getYear(now);
|
|
88
|
-
}, [now,
|
|
89
|
-
const
|
|
90
|
-
const selectedYearRef = React.useRef(null);
|
|
91
|
-
const [focusedYear, setFocusedYear] = React.useState(() => currentYear || utils.getYear(now));
|
|
98
|
+
}, [now, value, utils, disableHighlightToday]);
|
|
99
|
+
const [focusedYear, setFocusedYear] = React.useState(() => selectedYear || todayYear);
|
|
92
100
|
const [internalHasFocus, setInternalHasFocus] = useControlled({
|
|
93
101
|
name: 'YearPicker',
|
|
94
102
|
state: 'hasFocus',
|
|
95
103
|
controlled: hasFocus,
|
|
96
104
|
default: autoFocus
|
|
97
105
|
});
|
|
98
|
-
const changeHasFocus =
|
|
106
|
+
const changeHasFocus = useEventCallback(newHasFocus => {
|
|
99
107
|
setInternalHasFocus(newHasFocus);
|
|
100
108
|
|
|
101
109
|
if (onFocusedViewChange) {
|
|
102
110
|
onFocusedViewChange(newHasFocus);
|
|
103
111
|
}
|
|
104
|
-
}
|
|
105
|
-
const isYearDisabled =
|
|
112
|
+
});
|
|
113
|
+
const isYearDisabled = useEventCallback(dateToValidate => {
|
|
106
114
|
if (disablePast && utils.isBeforeYear(dateToValidate, now)) {
|
|
107
115
|
return true;
|
|
108
116
|
}
|
|
@@ -124,29 +132,28 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
return false;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const handleYearSelection = (event, year, isFinish = 'finish') => {
|
|
135
|
+
});
|
|
136
|
+
const handleYearSelection = useEventCallback((event, year) => {
|
|
130
137
|
if (readOnly) {
|
|
131
138
|
return;
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
const newDate = utils.setYear(selectedDateOrToday, year);
|
|
135
|
-
onChange(newDate
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const focusYear = React.useCallback(year => {
|
|
142
|
+
onChange(newDate);
|
|
143
|
+
});
|
|
144
|
+
const focusYear = useEventCallback(year => {
|
|
139
145
|
if (!isYearDisabled(utils.setYear(selectedDateOrToday, year))) {
|
|
140
146
|
setFocusedYear(year);
|
|
141
147
|
changeHasFocus(true);
|
|
142
148
|
onYearFocus == null ? void 0 : onYearFocus(year);
|
|
143
149
|
}
|
|
144
|
-
}
|
|
150
|
+
});
|
|
145
151
|
React.useEffect(() => {
|
|
146
|
-
setFocusedYear(prevFocusedYear =>
|
|
147
|
-
}, [
|
|
148
|
-
const
|
|
149
|
-
|
|
152
|
+
setFocusedYear(prevFocusedYear => selectedYear !== null && prevFocusedYear !== selectedYear ? selectedYear : prevFocusedYear);
|
|
153
|
+
}, [selectedYear]);
|
|
154
|
+
const handleKeyDown = useEventCallback((event, year) => {
|
|
155
|
+
const yearsInRow = wrapperVariant === 'desktop' ? 4 : 3;
|
|
156
|
+
|
|
150
157
|
switch (event.key) {
|
|
151
158
|
case 'ArrowUp':
|
|
152
159
|
focusYear(year - yearsInRow);
|
|
@@ -171,39 +178,66 @@ export const YearPicker = /*#__PURE__*/React.forwardRef(function YearPicker(inPr
|
|
|
171
178
|
default:
|
|
172
179
|
break;
|
|
173
180
|
}
|
|
174
|
-
}
|
|
175
|
-
const
|
|
181
|
+
});
|
|
182
|
+
const handleYearFocus = useEventCallback((event, year) => {
|
|
176
183
|
focusYear(year);
|
|
177
|
-
}
|
|
178
|
-
const
|
|
184
|
+
});
|
|
185
|
+
const handleYearBlur = useEventCallback((event, year) => {
|
|
179
186
|
if (focusedYear === year) {
|
|
180
187
|
changeHasFocus(false);
|
|
181
188
|
}
|
|
182
|
-
}
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
});
|
|
190
|
+
const scrollerRef = React.useRef(null);
|
|
191
|
+
const handleRef = useForkRef(ref, scrollerRef);
|
|
192
|
+
React.useEffect(() => {
|
|
193
|
+
if (autoFocus || scrollerRef.current === null) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const tabbableButton = scrollerRef.current.querySelector('[tabindex="0"]');
|
|
198
|
+
|
|
199
|
+
if (!tabbableButton) {
|
|
200
|
+
return;
|
|
201
|
+
} // Taken from useScroll in x-data-grid, but vertically centered
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
const offsetHeight = tabbableButton.offsetHeight;
|
|
205
|
+
const offsetTop = tabbableButton.offsetTop;
|
|
206
|
+
const clientHeight = scrollerRef.current.clientHeight;
|
|
207
|
+
const scrollTop = scrollerRef.current.scrollTop;
|
|
208
|
+
const elementBottom = offsetTop + offsetHeight;
|
|
209
|
+
|
|
210
|
+
if (offsetHeight > clientHeight || offsetTop < scrollTop) {
|
|
211
|
+
// Button already visible
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
scrollerRef.current.scrollTop = elementBottom - clientHeight / 2 - offsetHeight / 2;
|
|
216
|
+
}, [autoFocus]);
|
|
217
|
+
return /*#__PURE__*/_jsx(YearPickerRoot, _extends({
|
|
218
|
+
ref: handleRef,
|
|
186
219
|
className: clsx(classes.root, className),
|
|
187
|
-
ownerState: ownerState
|
|
220
|
+
ownerState: ownerState
|
|
221
|
+
}, other, {
|
|
188
222
|
children: utils.getYearRange(minDate, maxDate).map(year => {
|
|
189
223
|
const yearNumber = utils.getYear(year);
|
|
190
|
-
const
|
|
224
|
+
const isSelected = yearNumber === selectedYear;
|
|
225
|
+
const isDisabled = disabled || isYearDisabled(year);
|
|
191
226
|
return /*#__PURE__*/_jsx(PickersYear, {
|
|
192
|
-
selected:
|
|
227
|
+
selected: isSelected,
|
|
193
228
|
value: yearNumber,
|
|
194
229
|
onClick: handleYearSelection,
|
|
195
230
|
onKeyDown: handleKeyDown,
|
|
196
231
|
autoFocus: internalHasFocus && yearNumber === focusedYear,
|
|
197
|
-
|
|
198
|
-
disabled: disabled || isYearDisabled(year),
|
|
232
|
+
disabled: isDisabled,
|
|
199
233
|
tabIndex: yearNumber === focusedYear ? 0 : -1,
|
|
200
|
-
onFocus:
|
|
201
|
-
onBlur:
|
|
202
|
-
"aria-current":
|
|
234
|
+
onFocus: handleYearFocus,
|
|
235
|
+
onBlur: handleYearBlur,
|
|
236
|
+
"aria-current": todayYear === yearNumber ? 'date' : undefined,
|
|
203
237
|
children: utils.format(year, 'year')
|
|
204
238
|
}, utils.format(year, 'year'));
|
|
205
239
|
})
|
|
206
|
-
});
|
|
240
|
+
}));
|
|
207
241
|
});
|
|
208
242
|
process.env.NODE_ENV !== "production" ? YearPicker.propTypes = {
|
|
209
243
|
// ----------------------------- Warning --------------------------------
|
|
@@ -211,9 +245,20 @@ process.env.NODE_ENV !== "production" ? YearPicker.propTypes = {
|
|
|
211
245
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
212
246
|
// ----------------------------------------------------------------------
|
|
213
247
|
autoFocus: PropTypes.bool,
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Override or extend the styles applied to the component.
|
|
251
|
+
*/
|
|
214
252
|
classes: PropTypes.object,
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* className applied to the root element.
|
|
256
|
+
*/
|
|
215
257
|
className: PropTypes.string,
|
|
216
|
-
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* If `true` picker is disabled
|
|
261
|
+
*/
|
|
217
262
|
disabled: PropTypes.bool,
|
|
218
263
|
|
|
219
264
|
/**
|
|
@@ -244,10 +289,19 @@ process.env.NODE_ENV !== "production" ? YearPicker.propTypes = {
|
|
|
244
289
|
* Minimal selectable date. @DateIOType
|
|
245
290
|
*/
|
|
246
291
|
minDate: PropTypes.any,
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Callback fired when the value (the selected year) changes.
|
|
295
|
+
* @template TValue
|
|
296
|
+
* @param {TValue} value The new parsed value.
|
|
297
|
+
*/
|
|
247
298
|
onChange: PropTypes.func.isRequired,
|
|
248
|
-
onFocusedDayChange: PropTypes.func,
|
|
249
299
|
onFocusedViewChange: PropTypes.func,
|
|
250
300
|
onYearFocus: PropTypes.func,
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* If `true` picker is readonly
|
|
304
|
+
*/
|
|
251
305
|
readOnly: PropTypes.bool,
|
|
252
306
|
|
|
253
307
|
/**
|
|
@@ -257,5 +311,11 @@ process.env.NODE_ENV !== "production" ? YearPicker.propTypes = {
|
|
|
257
311
|
* @param {TDate} year The year to test.
|
|
258
312
|
* @returns {boolean} Returns `true` if the year should be disabled.
|
|
259
313
|
*/
|
|
260
|
-
shouldDisableYear: PropTypes.func
|
|
314
|
+
shouldDisableYear: PropTypes.func,
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
318
|
+
*/
|
|
319
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
320
|
+
value: PropTypes.any
|
|
261
321
|
} : void 0;
|
|
@@ -14,4 +14,4 @@ export interface PickersYearClasses {
|
|
|
14
14
|
}
|
|
15
15
|
export declare type PickersYearClassKey = keyof PickersYearClasses;
|
|
16
16
|
export declare function getPickersYearUtilityClass(slot: string): string;
|
|
17
|
-
export declare const pickersYearClasses: Record<"root" | "
|
|
17
|
+
export declare const pickersYearClasses: Record<"root" | "modeMobile" | "modeDesktop" | "disabled" | "selected" | "yearButton", string>;
|
package/index.js
CHANGED
|
@@ -162,7 +162,7 @@ export function CalendarOrClockPicker(inProps) {
|
|
|
162
162
|
}) : /*#__PURE__*/_jsxs(React.Fragment, {
|
|
163
163
|
children: [isDatePickerView(openView) && /*#__PURE__*/_jsx(CalendarPicker, _extends({
|
|
164
164
|
autoFocus: autoFocus,
|
|
165
|
-
|
|
165
|
+
value: parsedValue,
|
|
166
166
|
onViewChange: setOpenView,
|
|
167
167
|
onChange: handleChangeAndOpenNext,
|
|
168
168
|
view: openView // Unclear why the predicate `isDatePickerView` does not imply the casted type
|
|
@@ -172,7 +172,7 @@ export function CalendarOrClockPicker(inProps) {
|
|
|
172
172
|
onFocusedViewChange: setFocusedView
|
|
173
173
|
}, other)), isTimePickerView(openView) && /*#__PURE__*/_jsx(ClockPicker, _extends({}, other, {
|
|
174
174
|
autoFocus: autoFocus,
|
|
175
|
-
|
|
175
|
+
value: parsedValue,
|
|
176
176
|
view: openView // Unclear why the predicate `isDatePickerView` does not imply the casted type
|
|
177
177
|
,
|
|
178
178
|
views: views.filter(isTimePickerView),
|
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Theme } from '@mui/material/styles';
|
|
3
|
+
import { SxProps } from '@mui/system';
|
|
2
4
|
import { PickerStaticWrapperClasses } from './pickerStaticWrapperClasses';
|
|
3
5
|
import { PickersActionBarProps } from '../../../PickersActionBar';
|
|
4
6
|
import { PickerStateWrapperProps } from '../../hooks/usePickerState';
|
|
5
7
|
import { PickersSlotsComponent } from '../wrappers/WrapperProps';
|
|
8
|
+
import { PickersInputLocaleText } from '../../../locales/utils/pickersLocaleTextApi';
|
|
6
9
|
export interface PickersStaticWrapperSlotsComponent extends PickersSlotsComponent {
|
|
7
10
|
}
|
|
8
11
|
export interface PickersStaticWrapperSlotsComponentsProps {
|
|
9
12
|
actionBar: Omit<PickersActionBarProps, 'onAccept' | 'onClear' | 'onCancel' | 'onSetToday'>;
|
|
10
13
|
paperContent: Record<string, any>;
|
|
11
14
|
}
|
|
12
|
-
export interface
|
|
15
|
+
export interface ExportedPickerStaticWrapperProps<TDate> {
|
|
16
|
+
/**
|
|
17
|
+
* Force static wrapper inner components to be rendered in mobile or desktop mode.
|
|
18
|
+
* @default "mobile"
|
|
19
|
+
*/
|
|
20
|
+
displayStaticWrapperAs?: 'desktop' | 'mobile';
|
|
21
|
+
/**
|
|
22
|
+
* Locale for components texts
|
|
23
|
+
*/
|
|
24
|
+
localeText?: PickersInputLocaleText<TDate>;
|
|
25
|
+
/**
|
|
26
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
27
|
+
*/
|
|
28
|
+
sx?: SxProps<Theme>;
|
|
29
|
+
}
|
|
30
|
+
export interface PickerStaticWrapperProps<TDate> extends PickerStateWrapperProps, ExportedPickerStaticWrapperProps<TDate> {
|
|
13
31
|
className?: string;
|
|
14
32
|
children?: React.ReactNode;
|
|
15
33
|
/**
|
|
16
34
|
* Override or extend the styles applied to the component.
|
|
17
35
|
*/
|
|
18
36
|
classes?: Partial<PickerStaticWrapperClasses>;
|
|
19
|
-
/**
|
|
20
|
-
* Force static wrapper inner components to be rendered in mobile or desktop mode.
|
|
21
|
-
*/
|
|
22
|
-
displayStaticWrapperAs: 'desktop' | 'mobile';
|
|
23
37
|
/**
|
|
24
38
|
* Overrideable components.
|
|
25
39
|
* @default {}
|
|
@@ -31,7 +45,7 @@ export interface PickerStaticWrapperProps extends PickerStateWrapperProps {
|
|
|
31
45
|
*/
|
|
32
46
|
componentsProps?: Partial<PickersStaticWrapperSlotsComponentsProps>;
|
|
33
47
|
}
|
|
34
|
-
declare function PickerStaticWrapper(inProps: PickerStaticWrapperProps): JSX.Element;
|
|
48
|
+
declare function PickerStaticWrapper<TDate>(inProps: PickerStaticWrapperProps<TDate>): JSX.Element;
|
|
35
49
|
declare namespace PickerStaticWrapper {
|
|
36
50
|
var propTypes: any;
|
|
37
51
|
}
|
|
@@ -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 = ["displayStaticWrapperAs", "onAccept", "onClear", "onCancel", "
|
|
3
|
+
const _excluded = ["displayStaticWrapperAs", "onAccept", "onClear", "onCancel", "onSetToday", "children", "onDismiss", "open", "components", "componentsProps", "localeText", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
@@ -10,6 +10,7 @@ import { DIALOG_WIDTH } from '../../constants/dimensions';
|
|
|
10
10
|
import { WrapperVariantContext } from '../wrappers/WrapperVariantContext';
|
|
11
11
|
import { getStaticWrapperUtilityClass } from './pickerStaticWrapperClasses';
|
|
12
12
|
import { PickersActionBar } from '../../../PickersActionBar';
|
|
13
|
+
import { LocalizationProvider } from '../../../LocalizationProvider';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
|
|
@@ -55,7 +56,7 @@ function PickerStaticWrapper(inProps) {
|
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
const {
|
|
58
|
-
displayStaticWrapperAs,
|
|
59
|
+
displayStaticWrapperAs = 'mobile',
|
|
59
60
|
onAccept,
|
|
60
61
|
onClear,
|
|
61
62
|
onCancel,
|
|
@@ -63,6 +64,7 @@ function PickerStaticWrapper(inProps) {
|
|
|
63
64
|
children,
|
|
64
65
|
components,
|
|
65
66
|
componentsProps,
|
|
67
|
+
localeText,
|
|
66
68
|
className
|
|
67
69
|
} = props,
|
|
68
70
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
@@ -70,24 +72,27 @@ function PickerStaticWrapper(inProps) {
|
|
|
70
72
|
const classes = useUtilityClasses(props);
|
|
71
73
|
const ActionBar = (_components$ActionBar = components == null ? void 0 : components.ActionBar) != null ? _components$ActionBar : PickersActionBar;
|
|
72
74
|
const PaperContent = (components == null ? void 0 : components.PaperContent) || React.Fragment;
|
|
73
|
-
return /*#__PURE__*/_jsx(
|
|
74
|
-
|
|
75
|
-
children: /*#__PURE__*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
children: /*#__PURE__*/_jsx(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
return /*#__PURE__*/_jsx(LocalizationProvider, {
|
|
76
|
+
localeText: localeText,
|
|
77
|
+
children: /*#__PURE__*/_jsx(WrapperVariantContext.Provider, {
|
|
78
|
+
value: displayStaticWrapperAs,
|
|
79
|
+
children: /*#__PURE__*/_jsxs(PickerStaticWrapperRoot, _extends({
|
|
80
|
+
className: clsx(classes.root, className)
|
|
81
|
+
}, other, {
|
|
82
|
+
children: [/*#__PURE__*/_jsx(PickerStaticWrapperContent, {
|
|
83
|
+
className: classes.content,
|
|
84
|
+
children: /*#__PURE__*/_jsx(PaperContent, _extends({}, componentsProps == null ? void 0 : componentsProps.paperContent, {
|
|
85
|
+
children: children
|
|
86
|
+
}))
|
|
87
|
+
}), /*#__PURE__*/_jsx(ActionBar, _extends({
|
|
88
|
+
onAccept: onAccept,
|
|
89
|
+
onClear: onClear,
|
|
90
|
+
onCancel: onCancel,
|
|
91
|
+
onSetToday: onSetToday,
|
|
92
|
+
actions: displayStaticWrapperAs === 'desktop' ? [] : ['cancel', 'accept']
|
|
93
|
+
}, componentsProps == null ? void 0 : componentsProps.actionBar))]
|
|
94
|
+
}))
|
|
95
|
+
})
|
|
91
96
|
});
|
|
92
97
|
}
|
|
93
98
|
|
|
@@ -118,13 +123,24 @@ process.env.NODE_ENV !== "production" ? PickerStaticWrapper.propTypes = {
|
|
|
118
123
|
|
|
119
124
|
/**
|
|
120
125
|
* Force static wrapper inner components to be rendered in mobile or desktop mode.
|
|
126
|
+
* @default "mobile"
|
|
121
127
|
*/
|
|
122
|
-
displayStaticWrapperAs: PropTypes.oneOf(['desktop', 'mobile'])
|
|
128
|
+
displayStaticWrapperAs: PropTypes.oneOf(['desktop', 'mobile']),
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Locale for components texts
|
|
132
|
+
*/
|
|
133
|
+
localeText: PropTypes.object,
|
|
123
134
|
onAccept: PropTypes.func.isRequired,
|
|
124
135
|
onCancel: PropTypes.func.isRequired,
|
|
125
136
|
onClear: PropTypes.func.isRequired,
|
|
126
137
|
onDismiss: PropTypes.func.isRequired,
|
|
127
138
|
onSetToday: PropTypes.func.isRequired,
|
|
128
|
-
open: PropTypes.bool.isRequired
|
|
139
|
+
open: PropTypes.bool.isRequired,
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
143
|
+
*/
|
|
144
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
129
145
|
} : void 0;
|
|
130
146
|
export { PickerStaticWrapper };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { PickerStaticWrapper } from './PickerStaticWrapper';
|
|
2
|
-
export type { PickerStaticWrapperProps } from './PickerStaticWrapper';
|
|
2
|
+
export type { PickerStaticWrapperProps, ExportedPickerStaticWrapperProps, } from './PickerStaticWrapper';
|
|
3
3
|
export { pickerStaticWrapperClasses, getStaticWrapperUtilityClass, } from './pickerStaticWrapperClasses';
|
|
4
4
|
export type { PickerStaticWrapperClasses, PickerStaticWrapperClassKey, } from './pickerStaticWrapperClasses';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["children", "className", "components", "componentsProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel"],
|
|
4
|
+
_excluded2 = ["ownerState"],
|
|
5
|
+
_excluded3 = ["ownerState"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import Typography from '@mui/material/Typography';
|
|
9
|
+
import { useTheme, styled, useThemeProps } from '@mui/material/styles';
|
|
10
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
11
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
12
|
+
import IconButton from '@mui/material/IconButton';
|
|
13
|
+
import { ArrowLeft, ArrowRight } from '../icons';
|
|
14
|
+
import { getPickersArrowSwitcherUtilityClass } from './pickersArrowSwitcherClasses';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const PickersArrowSwitcherRoot = styled('div', {
|
|
18
|
+
name: 'MuiPickersArrowSwitcher',
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
})({
|
|
22
|
+
display: 'flex'
|
|
23
|
+
});
|
|
24
|
+
const PickersArrowSwitcherSpacer = styled('div', {
|
|
25
|
+
name: 'MuiPickersArrowSwitcher',
|
|
26
|
+
slot: 'Spacer',
|
|
27
|
+
overridesResolver: (props, styles) => styles.spacer
|
|
28
|
+
})(({
|
|
29
|
+
theme
|
|
30
|
+
}) => ({
|
|
31
|
+
width: theme.spacing(3)
|
|
32
|
+
}));
|
|
33
|
+
const PickersArrowSwitcherButton = styled(IconButton, {
|
|
34
|
+
name: 'MuiPickersArrowSwitcher',
|
|
35
|
+
slot: 'Button',
|
|
36
|
+
overridesResolver: (props, styles) => styles.button
|
|
37
|
+
})(({
|
|
38
|
+
ownerState
|
|
39
|
+
}) => _extends({}, ownerState.hidden && {
|
|
40
|
+
visibility: 'hidden'
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const useUtilityClasses = ownerState => {
|
|
44
|
+
const {
|
|
45
|
+
classes
|
|
46
|
+
} = ownerState;
|
|
47
|
+
const slots = {
|
|
48
|
+
root: ['root'],
|
|
49
|
+
spacer: ['spacer'],
|
|
50
|
+
button: ['button']
|
|
51
|
+
};
|
|
52
|
+
return composeClasses(slots, getPickersArrowSwitcherUtilityClass, classes);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrowSwitcher(inProps, ref) {
|
|
56
|
+
var _components$PreviousI, _components$NextIconB, _components$LeftArrow, _components$RightArro;
|
|
57
|
+
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
const isRTL = theme.direction === 'rtl';
|
|
60
|
+
const props = useThemeProps({
|
|
61
|
+
props: inProps,
|
|
62
|
+
name: 'MuiPickersArrowSwitcher'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const {
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
components = {},
|
|
69
|
+
componentsProps = {},
|
|
70
|
+
isNextDisabled,
|
|
71
|
+
isNextHidden,
|
|
72
|
+
onGoToNext,
|
|
73
|
+
nextLabel,
|
|
74
|
+
isPreviousDisabled,
|
|
75
|
+
isPreviousHidden,
|
|
76
|
+
onGoToPrevious,
|
|
77
|
+
previousLabel
|
|
78
|
+
} = props,
|
|
79
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
80
|
+
|
|
81
|
+
const ownerState = props;
|
|
82
|
+
const classes = useUtilityClasses(ownerState);
|
|
83
|
+
const nextProps = {
|
|
84
|
+
isDisabled: isNextDisabled,
|
|
85
|
+
isHidden: isNextHidden,
|
|
86
|
+
goTo: onGoToNext,
|
|
87
|
+
label: nextLabel
|
|
88
|
+
};
|
|
89
|
+
const previousProps = {
|
|
90
|
+
isDisabled: isPreviousDisabled,
|
|
91
|
+
isHidden: isPreviousHidden,
|
|
92
|
+
goTo: onGoToPrevious,
|
|
93
|
+
label: previousLabel
|
|
94
|
+
};
|
|
95
|
+
const [leftProps, rightProps] = isRTL ? [nextProps, previousProps] : [previousProps, nextProps];
|
|
96
|
+
const PreviousIconButton = (_components$PreviousI = components.PreviousIconButton) != null ? _components$PreviousI : PickersArrowSwitcherButton;
|
|
97
|
+
const previousIconButtonProps = useSlotProps({
|
|
98
|
+
elementType: PreviousIconButton,
|
|
99
|
+
externalSlotProps: componentsProps.previousIconButton,
|
|
100
|
+
additionalProps: {
|
|
101
|
+
size: 'small',
|
|
102
|
+
title: leftProps.label,
|
|
103
|
+
'aria-label': leftProps.label,
|
|
104
|
+
disabled: leftProps.isDisabled,
|
|
105
|
+
edge: 'end',
|
|
106
|
+
onClick: leftProps.goTo
|
|
107
|
+
},
|
|
108
|
+
ownerState: _extends({}, ownerState, {
|
|
109
|
+
hidden: leftProps.isHidden
|
|
110
|
+
}),
|
|
111
|
+
className: classes.button
|
|
112
|
+
});
|
|
113
|
+
const NextIconButton = (_components$NextIconB = components.NextIconButton) != null ? _components$NextIconB : PickersArrowSwitcherButton;
|
|
114
|
+
const nextIconButtonProps = useSlotProps({
|
|
115
|
+
elementType: NextIconButton,
|
|
116
|
+
externalSlotProps: componentsProps.nextIconButton,
|
|
117
|
+
additionalProps: {
|
|
118
|
+
size: 'small',
|
|
119
|
+
title: rightProps.label,
|
|
120
|
+
'aria-label': rightProps.label,
|
|
121
|
+
disabled: rightProps.isDisabled,
|
|
122
|
+
edge: 'start',
|
|
123
|
+
onClick: rightProps.goTo
|
|
124
|
+
},
|
|
125
|
+
ownerState: _extends({}, ownerState, {
|
|
126
|
+
hidden: rightProps.isHidden
|
|
127
|
+
}),
|
|
128
|
+
className: classes.button
|
|
129
|
+
});
|
|
130
|
+
const LeftArrowIcon = (_components$LeftArrow = components == null ? void 0 : components.LeftArrowIcon) != null ? _components$LeftArrow : ArrowLeft; // The spread is here to avoid this bug mui/material-ui#34056
|
|
131
|
+
|
|
132
|
+
const _useSlotProps = useSlotProps({
|
|
133
|
+
elementType: LeftArrowIcon,
|
|
134
|
+
externalSlotProps: componentsProps.leftArrowIcon,
|
|
135
|
+
ownerState: undefined
|
|
136
|
+
}),
|
|
137
|
+
leftArrowIconProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
138
|
+
|
|
139
|
+
const RightArrowIcon = (_components$RightArro = components == null ? void 0 : components.RightArrowIcon) != null ? _components$RightArro : ArrowRight; // The spread is here to avoid this bug mui/material-ui#34056
|
|
140
|
+
|
|
141
|
+
const _useSlotProps2 = useSlotProps({
|
|
142
|
+
elementType: RightArrowIcon,
|
|
143
|
+
externalSlotProps: componentsProps.rightArrowIcon,
|
|
144
|
+
ownerState: undefined
|
|
145
|
+
}),
|
|
146
|
+
rightArrowIconProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);
|
|
147
|
+
|
|
148
|
+
return /*#__PURE__*/_jsxs(PickersArrowSwitcherRoot, _extends({
|
|
149
|
+
ref: ref,
|
|
150
|
+
className: clsx(classes.root, className),
|
|
151
|
+
ownerState: ownerState
|
|
152
|
+
}, other, {
|
|
153
|
+
children: [/*#__PURE__*/_jsx(PreviousIconButton, _extends({}, previousIconButtonProps, {
|
|
154
|
+
children: isRTL ? /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps)) : /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps))
|
|
155
|
+
})), children ? /*#__PURE__*/_jsx(Typography, {
|
|
156
|
+
variant: "subtitle1",
|
|
157
|
+
component: "span",
|
|
158
|
+
children: children
|
|
159
|
+
}) : /*#__PURE__*/_jsx(PickersArrowSwitcherSpacer, {
|
|
160
|
+
className: classes.spacer,
|
|
161
|
+
ownerState: ownerState
|
|
162
|
+
}), /*#__PURE__*/_jsx(NextIconButton, _extends({}, nextIconButtonProps, {
|
|
163
|
+
children: isRTL ? /*#__PURE__*/_jsx(LeftArrowIcon, _extends({}, leftArrowIconProps)) : /*#__PURE__*/_jsx(RightArrowIcon, _extends({}, rightArrowIconProps))
|
|
164
|
+
}))]
|
|
165
|
+
}));
|
|
166
|
+
});
|